decompiled_code:
__int64 __fastcall adm_stats_req_pack(char *src, char *dest, _DWORD *a3)
{
*a3 = 16;
if ( dest )
strcpy(dest, src);
return 0LL;
}

original_code:
FH_STATUS adm_stats_req_pack(void *msg, char *data, int *length)
{
    fh_adm_stats_req_t *m_stats = (fh_adm_stats_req_t *) msg;
    fh_adm_stats_req_t *d_stats = (fh_adm_stats_req_t *) data;
    *length = sizeof(fh_adm_stats_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    strcpy(d_stats->stats_service, m_stats->stats_service);
    return (0);
}

canonical_original_code:
int adm_stats_req_pack(void *msg, char *data, int *length)
{
    struct fh_adm_stats_req_t *m_stats = (fh_adm_stats_req_t *) msg;
    struct fh_adm_stats_req_t *d_stats = (fh_adm_stats_req_t *) data;
    *length = sizeof(fh_adm_stats_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    strcpy(d_stats->stats_service, m_stats->stats_service);
    return (0);
}

variable_types:
msg
void *

variable_types:
data
char *

variable_types:
length
int *

variable_types: struct fh_adm_stats_req_t { char stats_service[16]; } *


repo: csinitiative/fhce

decompiled_code:
__int64 __fastcall adm_stats_req_unpack(char *a1, const char *a2, int a3)
{
__int64 v4; // rax

if ( a3 != 16 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_stats_req_t)",
"admin/fh_adm_stats_req.c",
56LL);
fh_log("admin/fh_adm_stats_req.c", 56LL, 0LL, "ERR", v4);
exit(1);
}
strcpy(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1, const char *a2, int a3)
{
__int64 v4; // rax

if ( a3 != 16 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_stats_req_t)",
"admin/fh_adm_stats_req.c",
56LL);
fh_log("admin/fh_adm_stats_req.c", 56LL, 0LL, "ERR", v4);
exit(1);
}
strcpy(a1, a2);
return 0LL;
}

original_code:
FH_STATUS adm_stats_req_unpack(void *msg, char *data, int length)
{
    fh_adm_stats_req_t *m_stats = (fh_adm_stats_req_t *) msg;
    fh_adm_stats_req_t *d_stats = (fh_adm_stats_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_stats_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_stats_req_t)", "admin/fh_adm_stats_req.c", 56); fh_log("admin/fh_adm_stats_req.c", 56, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    strcpy(m_stats->stats_service, d_stats->stats_service);
    return (0);
}

canonical_original_code:
int adm_stats_req_unpack(void *msg, char *data, int length)
{
    struct fh_adm_stats_req_t *m_stats = (fh_adm_stats_req_t *) msg;
    struct fh_adm_stats_req_t *d_stats = (fh_adm_stats_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_stats_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_stats_req_t)", "admin/fh_adm_stats_req.c", 56); fh_log("admin/fh_adm_stats_req.c", 56, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    strcpy(m_stats->stats_service, d_stats->stats_service);
    return (0);
}

variable_types: length int

variable_types: nok int

return_type: int

user_defined_types: struct fh_adm_stats_req_t { char stats_service[16]; }


original_code:
FH_STATUS adm_sgt_resp_pack(void *msg, char *data, int *length)
{
    fh_adm_sgt_resp_t *m_sgt = (fh_adm_sgt_resp_t *) msg;
    fh_adm_sgt_resp_t *d_sgt = (fh_adm_sgt_resp_t *) data;
    int i;
    *length = sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size;
    if (data == ((void *)0)) {
        return (0);
    }
    d_sgt->sgt_count = __bswap_16 (m_sgt->sgt_count);
    d_sgt->sgt_size = __bswap_16 (m_sgt->sgt_size);
    if (m_sgt->sgt_count > 0) {
        char *m_ptr = (char *)(m_sgt+1);
        char *d_ptr = (char *)(d_sgt+1);
        for (i=0; i<m_sgt->sgt_count; i++) {
            fh_adm_sg_resp_t *m_sg = (fh_adm_sg_resp_t *)m_ptr;
            fh_adm_sg_resp_t *d_sg = (fh_adm_sg_resp_t *)d_ptr;
            strcpy(d_sg->sg_name, m_sg->sg_name);
            d_sg->sg_serv_count = __bswap_32 (m_sg->sg_serv_count);
            d_sg->sg_serv_size = __bswap_32 (m_sg->sg_serv_size);
            if (m_sg->sg_serv_count > 0) {
                char *m_serv_ptr = (char *)(m_sg+1);
                char *d_serv_ptr = (char *)(d_sg+1);
                memcpy(d_serv_ptr, m_serv_ptr, m_sg->sg_serv_count *
                       sizeof(fh_adm_sg_serv_resp_t));
            }
            m_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
            d_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
        }
    }
    return (0);
}

canonical_original_code:
int adm_sgt_resp_pack(void *msg, char *data, int *length)
{
    struct fh_adm_sgt_resp_t *m_sgt = (fh_adm_sgt_resp_t *) msg;
    struct fh_adm_sgt_resp_t *d_sgt = (fh_adm_sgt_resp_t *) data;
    int i;
    *length = sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size;
    if (data == ((void *)0)) {
        return (0);
    }
    d_sgt->sgt_count = __bswap_16 (m_sgt->sgt_count);
    d_sgt->sgt_size = __bswap_16 (m_sgt->sgt_size);
    if (m_sgt->sgt_count > 0) {
        char *m_ptr = (char *)(m_sgt+1);
        char *d_ptr = (char *)(d_sgt+1);
        for (i=0; i<m_sgt->sgt_count; i++) {
            struct fh_adm_sg_resp_t *m_sg = (fh_adm_sg_resp_t *)m_ptr;
            struct fh_adm_sg_resp_t *d_sg = (fh_adm_sg_resp_t *)d_ptr;
            strcpy(d_sg->sg_name, m_sg->sg_name);
            d_sg->sg_serv_count = __bswap_32 (m_sg->sg_serv_count);
            d_sg->sg_serv_size = __bswap_32 (m_sg->sg_serv_size);
            if (m_sg->sg_serv_count > 0) {
                char *m_serv_ptr = (char *)(m_sg+1);
                char *d_serv_ptr = (char *)(d_sg+1);
                memcpy(d_serv_ptr, m_serv_ptr, m_sg->sg_serv_count *
                       sizeof(fh_adm_sg_serv_resp_t));
            }
            m_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
            d_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
        }
    }
    return (0);
}

variable_types: struct fh_adm_sgt_resp_t { unsigned short sgt_count; unsigned short sgt_size; } *

variable_types: i int

variable_types: struct fh_adm_sg_resp_t { char sg_name[16]; unsigned int sg_serv_count; unsigned int sg_serv_size; } *


decompiled_code:
__int64 __fastcall adm_sgt_resp_unpack(__int16 *a1, __int16 *a2, int a3)
{
__int16 v4; // bx
unsigned __int16 v5; // ax
unsigned __int16 *v6; // r12
__int16 *v7; // rbp
int v8; // er13
__int64 v9; // rax
__int64 v10; // rbx
unsigned int v11; // er15
unsigned int v12; // ebx

v4 = _bswap_16(*a2);
*a1 = v4;
v5 = _bswap_16(a2[1]);
a1[1] = v5;
if ( a3 != v5 + 4LL )
{
v9 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"(uint32_t)length == (sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size)",
"admin/fh_adm_sgt_resp.c",
90LL);
fh_log("admin/fh_adm_sgt_resp.c", 90LL, 0LL, "ERR", v9);
exit(1);
}
if ( v4 )
{
v6 = (unsigned __int16 *)(a1 + 2);
v7 = a2 + 2;
v8 = 0;
do
{
strcpy((char *)v6, (const char *)v7);
v11 = _bswap_32(*((_DWORD *)v7 + 4));
*((_DWORD *)v6 + 4) = v11;
v12 = _bswap_32(*((_DWORD *)v7 + 5));
*((_DWORD *)v6 + 5) = v12;
if ( v11 )
memcpy(v6 + 12, v7 + 12, 16LL * v11);
v10 = v12 + 24LL;
v6 = (unsigned __int16 *)((char *)v6 + v10);
v7 = (__int16 *)((char *)v7 + v10);
++v8;
}
while ( (unsigned __int16)*a1 > v8 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int16 *a1, __int16 *a2, int a3)
{
__int16 v4; // bx
unsigned __int16 v5; // ax
unsigned __int16 *v6; // r12
__int16 *v7; // rbp
int v8; // er13
__int64 v9; // rax
__int64 v10; // rbx
unsigned int v11; // er15
unsigned int v12; // ebx

v4 = func0(*a2);
*a1 = v4;
v5 = func0(a2[1]);
a1[1] = v5;
if ( a3 != v5 + 4LL )
{
v9 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"(uint32_t)length == (sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size)",
"admin/fh_adm_sgt_resp.c",
90LL);
fh_log("admin/fh_adm_sgt_resp.c", 90LL, 0LL, "ERR", v9);
exit(1);
}
if ( v4 )
{
v6 = (unsigned __int16 *)(a1 + 2);
v7 = a2 + 2;
v8 = 0;
do
{
strcpy((char *)v6, (const char *)v7);
v11 = func1(*((_DWORD *)v7 + 4));
*((_DWORD *)v6 + 4) = v11;
v12 = func1(*((_DWORD *)v7 + 5));
*((_DWORD *)v6 + 5) = v12;
if ( v11 )
memcpy(v6 + 12, v7 + 12, 16LL * v11);
v10 = v12 + 24LL;
v6 = (unsigned __int16 *)((char *)v6 + v10);
v7 = (__int16 *)((char *)v7 + v10);
++v8;
}
while ( (unsigned __int16)*a1 > v8 );
}
return 0LL;
}

original_code:
FH_STATUS adm_sgt_resp_unpack(void *msg, char *data, int length)
{
    fh_adm_sgt_resp_t *m_sgt = (fh_adm_sgt_resp_t *) msg;
    fh_adm_sgt_resp_t *d_sgt = (fh_adm_sgt_resp_t *) data;
    int i;
    m_sgt->sgt_count = __bswap_16 (d_sgt->sgt_count);
    m_sgt->sgt_size = __bswap_16 (d_sgt->sgt_size);
    do { int nok = !((uint32_t)length == (sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "(uint32_t)length == (sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size)", "admin/fh_adm_sgt_resp.c", 90); fh_log("admin/fh_adm_sgt_resp.c", 90, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    if (m_sgt->sgt_count > 0) {
        char *m_ptr = (char *)(m_sgt+1);
        char *d_ptr = (char *)(d_sgt+1);
        for (i=0; i<m_sgt->sgt_count; i++) {
            fh_adm_sg_resp_t *m_sg = (fh_adm_sg_resp_t *)m_ptr;
            fh_adm_sg_resp_t *d_sg = (fh_adm_sg_resp_t *)d_ptr;
            strcpy(m_sg->sg_name, d_sg->sg_name);
            m_sg->sg_serv_count = __bswap_32 (d_sg->sg_serv_count);
            m_sg->sg_serv_size = __bswap_32 (d_sg->sg_serv_size);
            if (m_sg->sg_serv_count > 0) {
                char *m_serv_ptr = (char *)(m_sg+1);
                char *d_serv_ptr = (char *)(d_sg+1);
                memcpy(m_serv_ptr, d_serv_ptr, m_sg->sg_serv_count *
                       sizeof(fh_adm_sg_serv_resp_t));
            }
            m_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
            d_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
        }
    }
    return (0);
}

canonical_original_code:
int adm_sgt_resp_unpack(void *msg, char *data, int length)
{
    struct fh_adm_sgt_resp_t *m_sgt = (fh_adm_sgt_resp_t *) msg;
    struct fh_adm_sgt_resp_t *d_sgt = (fh_adm_sgt_resp_t *) data;
    int i;
    m_sgt->sgt_count = __bswap_16 (d_sgt->sgt_count);
    m_sgt->sgt_size = __bswap_16 (d_sgt->sgt_size);
    do { int nok = !((uint32_t)length == (sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "(uint32_t)length == (sizeof(fh_adm_sgt_resp_t) + m_sgt->sgt_size)", "admin/fh_adm_sgt_resp.c", 90); fh_log("admin/fh_adm_sgt_resp.c", 90, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    if (m_sgt->sgt_count > 0) {
        char *m_ptr = (char *)(m_sgt+1);
        char *d_ptr = (char *)(d_sgt+1);
        for (i=0; i<m_sgt->sgt_count; i++) {
            struct fh_adm_sg_resp_t *m_sg = (fh_adm_sg_resp_t *)m_ptr;
            struct fh_adm_sg_resp_t *d_sg = (fh_adm_sg_resp_t *)d_ptr;
            strcpy(m_sg->sg_name, d_sg->sg_name);
            m_sg->sg_serv_count = __bswap_32 (d_sg->sg_serv_count);
            m_sg->sg_serv_size = __bswap_32 (d_sg->sg_serv_size);
            if (m_sg->sg_serv_count > 0) {
                char *m_serv_ptr = (char *)(m_sg+1);
                char *d_serv_ptr = (char *)(d_sg+1);
                memcpy(m_serv_ptr, d_serv_ptr, m_sg->sg_serv_count *
                       sizeof(fh_adm_sg_serv_resp_t));
            }
            m_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
            d_ptr += sizeof(fh_adm_sg_resp_t) + m_sg->sg_serv_size;
        }
    }
    return (0);
}

user_defined_types: struct fh_adm_sgt_resp_t { unsigned short sgt_count; unsigned short sgt_size; }

user_defined_types: struct fh_adm_sg_resp_t { char sg_name[16]; unsigned int sg_serv_count; unsigned int sg_serv_size; }


decompiled_code:
char *__fastcall fh_arca_util_thread_name(char *s)
{
int v1; // ebx
int v2; // eax
char *v3; // rax
char *v4; // rbx
__int64 v6; // rax

v1 = strlen(&fh_arca_cfg);
v2 = strlen(s);
v3 = (char *)malloc(v1 + v2 + 2);
if ( !v3 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "thread_name != NULL", "fh_arca_util.c", 53LL);
fh_log("fh_arca_util.c", 53LL, 0LL, "ERR", v6);
exit(1);
}
v4 = v3;
sprintf(v3, "%s_%s", s, &fh_arca_cfg);
return v4;
}

canonical_decompiled_code:
char *__fastcall func0(char *s)
{
int v1; // ebx
int v2; // eax
char *v3; // rax
char *v4; // rbx
__int64 v6; // rax

v1 = strlen(&fh_arca_cfg);
v2 = strlen(s);
v3 = (char *)malloc(v1 + v2 + 2);
if ( !v3 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "thread_name != NULL", "fh_arca_util.c", 53LL);
fh_log("fh_arca_util.c", 53LL, 0LL, "ERR", v6);
exit(1);
}
v4 = v3;
sprintf(v3, "%s_%s", s, &fh_arca_cfg);
return v4;
}

original_code:
char *fh_arca_util_thread_name(const char *base)
{
    int string_chars;
    char *thread_name = ((void *)0);
    string_chars = strlen(fh_arca_cfg.name) + strlen(base) + 1;
    thread_name = (char *)malloc((string_chars + 1) * sizeof(char));
    do { int nok = !(thread_name != ((void *)0)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "thread_name != NULL", "fh_arca_util.c", 53); fh_log("fh_arca_util.c", 53, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    sprintf(thread_name, "%s_%s", base, fh_arca_cfg.name);
    return thread_name;
}

canonical_original_code:
char *fh_arca_util_thread_name(char *base)
{
    int string_chars;
    char *thread_name = ((void *)0);
    string_chars = strlen(fh_arca_cfg.name) + strlen(base) + 1;
    thread_name = (char *)malloc((string_chars + 1) * sizeof(char));
    do { int nok = !(thread_name != ((void *)0)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "thread_name != NULL", "fh_arca_util.c", 53); fh_log("fh_arca_util.c", 53, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    sprintf(thread_name, "%s_%s", base, fh_arca_cfg.name);
    return thread_name;
}

variable_types:
base
char *

return_type: char *


decompiled_code:
__int64 __fastcall adm_getver_req_pack(char *src, char *dest, _DWORD *a3)
{
*a3 = 16;
if ( dest )
strcpy(dest, src);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src, char *dest, _DWORD *a3)
{
*a3 = 16;
if ( dest )
strcpy(dest, src);
return 0LL;
}

original_code:
FH_STATUS adm_getver_req_pack(void *msg, char *data, int *length)
{
    fh_adm_getver_req_t *m_getver = (fh_adm_getver_req_t *) msg;
    fh_adm_getver_req_t *d_getver = (fh_adm_getver_req_t *) data;
    *length = sizeof(fh_adm_getver_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    strcpy(d_getver->getver_service, m_getver->getver_service);
    return (0);
}

canonical_original_code:
int adm_getver_req_pack(void *msg, char *data, int *length)
{
    struct fh_adm_getver_req_t *m_getver = (fh_adm_getver_req_t *) msg;
    struct fh_adm_getver_req_t *d_getver = (fh_adm_getver_req_t *) data;
    *length = sizeof(fh_adm_getver_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    strcpy(d_getver->getver_service, m_getver->getver_service);
    return (0);
}

variable_types: struct fh_adm_getver_req_t { char getver_service[16]; } *


decompiled_code:
__int64 __fastcall adm_getver_req_unpack(char *a1, const char *a2, int a3)
{
__int64 v4; // rax

if ( a3 != 16 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_getver_req_t)",
"admin/fh_adm_getver_req.c",
56LL);
fh_log("admin/fh_adm_getver_req.c", 56LL, 0LL, "ERR", v4);
exit(1);
}
strcpy(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1, const char *a2, int a3)
{
__int64 v4; // rax

if ( a3 != 16 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_getver_req_t)",
"admin/fh_adm_getver_req.c",
56LL);
fh_log("admin/fh_adm_getver_req.c", 56LL, 0LL, "ERR", v4);
exit(1);
}
strcpy(a1, a2);
return 0LL;
}

original_code:
FH_STATUS adm_getver_req_unpack(void *msg, char *data, int length)
{
    fh_adm_getver_req_t *m_getver = (fh_adm_getver_req_t *) msg;
    fh_adm_getver_req_t *d_getver = (fh_adm_getver_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_getver_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_getver_req_t)", "admin/fh_adm_getver_req.c", 56); fh_log("admin/fh_adm_getver_req.c", 56, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    strcpy(m_getver->getver_service, d_getver->getver_service);
    return (0);
}

canonical_original_code:
int adm_getver_req_unpack(void *msg, char *data, int length)
{
    struct fh_adm_getver_req_t *m_getver = (fh_adm_getver_req_t *) msg;
    struct fh_adm_getver_req_t *d_getver = (fh_adm_getver_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_getver_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_getver_req_t)", "admin/fh_adm_getver_req.c", 56); fh_log("admin/fh_adm_getver_req.c", 56, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    strcpy(m_getver->getver_service, d_getver->getver_service);
    return (0);
}

user_defined_types: struct fh_adm_getver_req_t { char getver_service[16]; }


decompiled_code:
__int64 __fastcall adm_serv_req_pack(char *src, char *dest, _DWORD *a3)
{
*a3 = 20;
if ( dest )
{
*((_DWORD *)dest + 4) = _bswap_32(*((_DWORD *)src + 4));
strcpy(dest, src);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *src, char *dest, _DWORD *a3)
{
*a3 = 20;
if ( dest )
{
*((_DWORD *)dest + 4) = func0(*((_DWORD *)src + 4));
strcpy(dest, src);
}
return 0LL;
}

original_code:
FH_STATUS adm_serv_req_pack(void *msg, char *data, int *length)
{
    fh_adm_serv_req_t *m_serv = (fh_adm_serv_req_t *) msg;
    fh_adm_serv_req_t *d_serv = (fh_adm_serv_req_t *) data;
    *length = sizeof(fh_adm_serv_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    d_serv->serv_cmd = __bswap_32 (m_serv->serv_cmd);
    strcpy(d_serv->serv_name, m_serv->serv_name);
    return (0);
}

canonical_original_code:
int adm_serv_req_pack(void *msg, char *data, int *length)
{
    struct fh_adm_serv_req_t *m_serv = (fh_adm_serv_req_t *) msg;
    struct fh_adm_serv_req_t *d_serv = (fh_adm_serv_req_t *) data;
    *length = sizeof(fh_adm_serv_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    d_serv->serv_cmd = __bswap_32 (m_serv->serv_cmd);
    strcpy(d_serv->serv_name, m_serv->serv_name);
    return (0);
}

variable_types: struct fh_adm_serv_req_t { char serv_name[16]; unsigned int serv_cmd; } *


decompiled_code:
__int64 __fastcall adm_serv_req_unpack(char *dest, char *src, int a3)
{
__int64 v4; // rax

if ( a3 != 20 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_serv_req_t)",
"admin/fh_adm_serv_req.c",
57LL);
fh_log("admin/fh_adm_serv_req.c", 57LL, 0LL, "ERR", v4);
exit(1);
}
*((_DWORD *)dest + 4) = _bswap_32(*((_DWORD *)src + 4));
strcpy(dest, src);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *dest, char *src, int a3)
{
__int64 v4; // rax

if ( a3 != 20 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_serv_req_t)",
"admin/fh_adm_serv_req.c",
57LL);
fh_log("admin/fh_adm_serv_req.c", 57LL, 0LL, "ERR", v4);
exit(1);
}
*((_DWORD *)dest + 4) = func0(*((_DWORD *)src + 4));
strcpy(dest, src);
return 0LL;
}

original_code:
FH_STATUS adm_serv_req_unpack(void *msg, char *data, int length)
{
    fh_adm_serv_req_t *m_serv = (fh_adm_serv_req_t *) msg;
    fh_adm_serv_req_t *d_serv = (fh_adm_serv_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_serv_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_serv_req_t)", "admin/fh_adm_serv_req.c", 57); fh_log("admin/fh_adm_serv_req.c", 57, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    m_serv->serv_cmd = __bswap_32 (d_serv->serv_cmd);
    strcpy(m_serv->serv_name, d_serv->serv_name);
    return (0);
}

canonical_original_code:
int adm_serv_req_unpack(void *msg, char *data, int length)
{
    struct fh_adm_serv_req_t *m_serv = (fh_adm_serv_req_t *) msg;
    struct fh_adm_serv_req_t *d_serv = (fh_adm_serv_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_serv_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_serv_req_t)", "admin/fh_adm_serv_req.c", 57); fh_log("admin/fh_adm_serv_req.c", 57, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    m_serv->serv_cmd = __bswap_32 (d_serv->serv_cmd);
    strcpy(m_serv->serv_name, d_serv->serv_name);
    return (0);
}

user_defined_types: struct fh_adm_serv_req_t { char serv_name[16]; unsigned int serv_cmd; }


decompiled_code:
__int64 __fastcall fh_shr_cfg_lh_load(const char *a1, const char *a2, __int64 a3, __int64 a4)
{
__int64 v5; // rax
__int64 v6; // r13
const char *v7; // rax
const char *v8; // r12
int v9; // eax
int v10; // eax
int v11; // eax
__int64 v12; // rax
__int64 v13; // r12
__int64 v14; // rbx
char v15; // dl
__int64 result; // rax
void (__fastcall *v17)(unsigned int *, __int64); // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
unsigned int v26; // [rsp+Ch] [rbp-12Ch] BYREF
char s[296]; // [rsp+10h] [rbp-128h] BYREF

*(_QWORD *)a4 = 0LL;
*(_QWORD *)(a4 + 808) = 0LL;
memset(
(void *)((a4 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a4 - (((_DWORD)a4 + 8) & 0xFFFFFFF8) + 816) >> 3));
v5 = fh_cfg_get_node(a3, a2);
if ( v5 )
{
v6 = v5;
sprintf(s, "processes.%s", a1);
v7 = (const char *)fh_cfg_get_node(v6, s);
v8 = v7;
if ( v7 )
{
strcpy((char *)a4, v7);
v9 = fh_cfg_set_int(v8, "cpu", a4 + 256);
if ( v9 )
{
if ( v9 == 1 )
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v20 = fh_log_fmt("%s: missing CPU specification", a1);
fh_log("fh_shr_cfg_lh.c", 217LL, "CSI", "WARN", v20);
}
*(_DWORD *)(a4 + 256) = -1;
}
else
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v21 = fh_log_fmt("%s: invalid CPU specification", a1);
fh_log("fh_shr_cfg_lh.c", 222LL, "CSI", "WARN", v21);
}
*(_DWORD *)(a4 + 256) = -1;
}
}
v10 = fh_cfg_set_int(v6, "fill_gaps.max", a4 + 276);
if ( v10 )
{
if ( v10 == 1 )
{
*(_DWORD *)(a4 + 276) = 0;
}
else
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v22 = fh_log_fmt("%s: invalid fill_gaps.max option (default = 0)", a1);
fh_log("fh_shr_cfg_lh.c", 238LL, "CSI", "WARN", v22);
}
*(_DWORD *)(a4 + 276) = 0;
}
}
v11 = fh_cfg_set_int(v6, "fill_gaps.timeout", a4 + 280);
if ( v11 )
{
if ( v11 == 1 )
{
*(_DWORD *)(a4 + 280) = 0;
}
else
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v23 = fh_log_fmt("%s: invalid fill_gaps.timeout option (default = 0)", a1);
fh_log("fh_shr_cfg_lh.c", 254LL, "CSI", "WARN", v23);
}
*(_DWORD *)(a4 + 280) = 0;
}
}
fh_shr_cfg_tbl_load(v6, "symbol_table", a4 + 284);
fh_shr_cfg_tbl_load(v6, "order_table", a4 + 544);
v12 = fh_cfg_get_node(v8, "lines");
v13 = v12;
if ( v12 )
{
v14 = 0LL;
if ( *(int *)(v12 + 284) <= 0 )
{
LABEL_18:
v15 = fh_plugin_is_hook_registered(74LL);
result = 0LL;
if ( v15 )
{
v17 = (void (__fastcall *)(unsigned int *, __int64))fh_plugin_get_hook(74LL);
v17(&v26, a4);
result = v26;
if ( v26 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v25 = fh_log_fmt("error occured during plugin configuration (%d)", v26);
fh_log("fh_shr_cfg_lh.c", 281LL, "MGMT", "ERR", v25);
}
result = v26;
}
}
}
else
{
while ( !(unsigned int)add_line(v6, *(const char **)(*(_QWORD *)(v13 + 272) + 8 * v14), a4) )
{
if ( *(_DWORD *)(v13 + 284) <= (int)++v14 )
goto LABEL_18;
}
result = 0xFFFFFFFFLL;
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[0] & 1) != 0 )
{
v24 = fh_log_fmt("process configuration '%s' contains no lines", a1);
fh_log("fh_shr_cfg_lh.c", 266LL, "CSI", "ERR", v24);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[0] & 1) != 0 )
{
v19 = fh_log_fmt("no process configuration for '%s'", a1);
fh_log("fh_shr_cfg_lh.c", 203LL, "CSI", "ERR", v19);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[0] & 1) != 0 )
{
v18 = fh_log_fmt("missing top configuration node, '%s'", a2);
fh_log("fh_shr_cfg_lh.c", 195LL, "CSI", "ERR", v18);
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, const char *a2, __int64 a3, __int64 a4)
{
__int64 v5; // rax
__int64 v6; // r13
const char *v7; // rax
const char *v8; // r12
int v9; // eax
int v10; // eax
int v11; // eax
__int64 v12; // rax
__int64 v13; // r12
__int64 v14; // rbx
char v15; // dl
__int64 result; // rax
void (__fastcall *v17)(unsigned int *, __int64); // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
unsigned int v26; // [rsp+Ch] [rbp-12Ch] BYREF
char s[296]; // [rsp+10h] [rbp-128h] BYREF

*(_QWORD *)a4 = 0LL;
*(_QWORD *)(a4 + 808) = 0LL;
memset(
(void *)((a4 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a4 - (((_DWORD)a4 + 8) & 0xFFFFFFF8) + 816) >> 3));
v5 = fh_cfg_get_node(a3, a2);
if ( v5 )
{
v6 = v5;
sprintf(s, "processes.%s", a1);
v7 = (const char *)fh_cfg_get_node(v6, s);
v8 = v7;
if ( v7 )
{
strcpy((char *)a4, v7);
v9 = fh_cfg_set_int(v8, "cpu", a4 + 256);
if ( v9 )
{
if ( v9 == 1 )
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v20 = fh_log_fmt("%s: missing CPU specification", a1);
fh_log("fh_shr_cfg_lh.c", 217LL, "CSI", "WARN", v20);
}
*(_DWORD *)(a4 + 256) = -1;
}
else
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v21 = fh_log_fmt("%s: invalid CPU specification", a1);
fh_log("fh_shr_cfg_lh.c", 222LL, "CSI", "WARN", v21);
}
*(_DWORD *)(a4 + 256) = -1;
}
}
v10 = fh_cfg_set_int(v6, "fill_gaps.max", a4 + 276);
if ( v10 )
{
if ( v10 == 1 )
{
*(_DWORD *)(a4 + 276) = 0;
}
else
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v22 = fh_log_fmt("%s: invalid fill_gaps.max option (default = 0)", a1);
fh_log("fh_shr_cfg_lh.c", 238LL, "CSI", "WARN", v22);
}
*(_DWORD *)(a4 + 276) = 0;
}
}
v11 = fh_cfg_set_int(v6, "fill_gaps.timeout", a4 + 280);
if ( v11 )
{
if ( v11 == 1 )
{
*(_DWORD *)(a4 + 280) = 0;
}
else
{
if ( (fh_log_lvl[0] & 2) != 0 )
{
v23 = fh_log_fmt("%s: invalid fill_gaps.timeout option (default = 0)", a1);
fh_log("fh_shr_cfg_lh.c", 254LL, "CSI", "WARN", v23);
}
*(_DWORD *)(a4 + 280) = 0;
}
}
fh_shr_cfg_tbl_load(v6, "symbol_table", a4 + 284);
fh_shr_cfg_tbl_load(v6, "order_table", a4 + 544);
v12 = fh_cfg_get_node(v8, "lines");
v13 = v12;
if ( v12 )
{
v14 = 0LL;
if ( *(int *)(v12 + 284) <= 0 )
{
LABEL_18:
v15 = fh_plugin_is_hook_registered(74LL);
result = 0LL;
if ( v15 )
{
v17 = (void (__fastcall *)(unsigned int *, __int64))fh_plugin_get_hook(74LL);
v17(&v26, a4);
result = v26;
if ( v26 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v25 = fh_log_fmt("error occured during plugin configuration (%d)", v26);
fh_log("fh_shr_cfg_lh.c", 281LL, "MGMT", "ERR", v25);
}
result = v26;
}
}
}
else
{
while ( !(unsigned int)func1(v6, *(const char **)(*(_QWORD *)(v13 + 272) + 8 * v14), a4) )
{
if ( *(_DWORD *)(v13 + 284) <= (int)++v14 )
goto LABEL_18;
}
result = 0xFFFFFFFFLL;
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[0] & 1) != 0 )
{
v24 = fh_log_fmt("process configuration '%s' contains no lines", a1);
fh_log("fh_shr_cfg_lh.c", 266LL, "CSI", "ERR", v24);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[0] & 1) != 0 )
{
v19 = fh_log_fmt("no process configuration for '%s'", a1);
fh_log("fh_shr_cfg_lh.c", 203LL, "CSI", "ERR", v19);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[0] & 1) != 0 )
{
v18 = fh_log_fmt("missing top configuration node, '%s'", a2);
fh_log("fh_shr_cfg_lh.c", 195LL, "CSI", "ERR", v18);
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
FH_STATUS fh_shr_cfg_lh_load(const char *process, const char *root,
                             const fh_cfg_node_t *config, fh_shr_cfg_lh_proc_t *lh_config)
{
    char process_node_name[255];
    int i;
    FH_STATUS rc;
    const fh_cfg_node_t *top_node = ((void *)0);
    const fh_cfg_node_t *process_node = ((void *)0);
    const fh_cfg_node_t *lines_node = ((void *)0);
    memset(lh_config, 0, sizeof(fh_shr_cfg_lh_proc_t));
    top_node = fh_cfg_get_node(config, root);
    if (top_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing top configuration node, '%s'", root); fh_log("fh_shr_cfg_lh.c", 195, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    sprintf(process_node_name, "processes.%s", process);
    process_node = fh_cfg_get_node(top_node, process_node_name);
    if (process_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("no process configuration for '%s'", process); fh_log("fh_shr_cfg_lh.c", 203, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    strcpy(lh_config->name, process_node->name);
    switch (fh_cfg_set_int(process_node, "cpu", &lh_config->cpu)) {
    case (0):
        break;
    case (1):
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: missing CPU specification", process); fh_log("fh_shr_cfg_lh.c", 217, "CSI", "WARN", _msg); } } while (0);
        lh_config->cpu = -1;
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: invalid CPU specification", process); fh_log("fh_shr_cfg_lh.c", 222, "CSI", "WARN", _msg); } } while (0);
        lh_config->cpu = -1;
        break;
    }
    switch (fh_cfg_set_int(top_node, "fill_gaps.max", &lh_config->gap_list_max)) {
    case (0):
        break;
    case (1):
        lh_config->gap_list_max = 0;
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: invalid fill_gaps.max option (default = 0)", process); fh_log("fh_shr_cfg_lh.c", 238, "CSI", "WARN", _msg); } } while (0);
        lh_config->gap_list_max = 0;
        break;
    }
    switch (fh_cfg_set_int(top_node, "fill_gaps.timeout", &lh_config->gap_timeout)) {
    case (0):
        break;
    case (1):
        lh_config->gap_timeout = 0;
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: invalid fill_gaps.timeout option (default = 0)", process); fh_log("fh_shr_cfg_lh.c", 254, "CSI", "WARN", _msg); } } while (0);
        lh_config->gap_timeout = 0;
        break;
    }
    fh_shr_cfg_tbl_load(top_node, "symbol_table", &lh_config->symbol_table);
    fh_shr_cfg_tbl_load(top_node, "order_table", &lh_config->order_table);
    lines_node = fh_cfg_get_node(process_node, "lines");
    if (lines_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("process configuration '%s' contains no lines", process); fh_log("fh_shr_cfg_lh.c", 266, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    for (i = 0; i < lines_node->num_values; i++) {
        if (add_line(top_node, lines_node->values[i], lh_config) != (0)) {
            return (-1);
        }
    }
    if (fh_plugin_is_hook_registered((74))) {
        fh_plugin_get_hook((74))(&rc, lh_config);
        if (rc != (0)) {
            do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("error occured during plugin configuration (%d)", rc); fh_log("fh_shr_cfg_lh.c", 281, "MGMT", "ERR", _msg); } } while (0);
            return rc;
        }
    }
    return (0);
}

canonical_original_code:
int fh_shr_cfg_lh_load(char *process, char *root, struct fh_cfg_node *config, struct fh_shr_cfg_lh_proc *lh_config)
{
    char process_node_name[255];
    int i;
    int rc;
    struct fh_cfg_node *top_node = ((void *)0);
    struct fh_cfg_node *process_node = ((void *)0);
    struct fh_cfg_node *lines_node = ((void *)0);
    memset(lh_config, 0, sizeof(fh_shr_cfg_lh_proc_t));
    top_node = fh_cfg_get_node(config, root);
    if (top_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing top configuration node, '%s'", root); fh_log("fh_shr_cfg_lh.c", 195, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    sprintf(process_node_name, "processes.%s", process);
    process_node = fh_cfg_get_node(top_node, process_node_name);
    if (process_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("no process configuration for '%s'", process); fh_log("fh_shr_cfg_lh.c", 203, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    strcpy(lh_config->name, process_node->name);
    switch (fh_cfg_set_int(process_node, "cpu", &lh_config->cpu)) {
    case (0):
        break;
    case (1):
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: missing CPU specification", process); fh_log("fh_shr_cfg_lh.c", 217, "CSI", "WARN", _msg); } } while (0);
        lh_config->cpu = -1;
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: invalid CPU specification", process); fh_log("fh_shr_cfg_lh.c", 222, "CSI", "WARN", _msg); } } while (0);
        lh_config->cpu = -1;
        break;
    }
    switch (fh_cfg_set_int(top_node, "fill_gaps.max", &lh_config->gap_list_max)) {
    case (0):
        break;
    case (1):
        lh_config->gap_list_max = 0;
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: invalid fill_gaps.max option (default = 0)", process); fh_log("fh_shr_cfg_lh.c", 238, "CSI", "WARN", _msg); } } while (0);
        lh_config->gap_list_max = 0;
        break;
    }
    switch (fh_cfg_set_int(top_node, "fill_gaps.timeout", &lh_config->gap_timeout)) {
    case (0):
        break;
    case (1):
        lh_config->gap_timeout = 0;
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("%s: invalid fill_gaps.timeout option (default = 0)", process); fh_log("fh_shr_cfg_lh.c", 254, "CSI", "WARN", _msg); } } while (0);
        lh_config->gap_timeout = 0;
        break;
    }
    fh_shr_cfg_tbl_load(top_node, "symbol_table", &lh_config->symbol_table);
    fh_shr_cfg_tbl_load(top_node, "order_table", &lh_config->order_table);
    lines_node = fh_cfg_get_node(process_node, "lines");
    if (lines_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("process configuration '%s' contains no lines", process); fh_log("fh_shr_cfg_lh.c", 266, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    for (i = 0; i < lines_node->num_values; i++) {
        if (add_line(top_node, lines_node->values[i], lh_config) != (0)) {
            return (-1);
        }
    }
    if (fh_plugin_is_hook_registered((74))) {
        fh_plugin_get_hook((74))(&rc, lh_config);
        if (rc != (0)) {
            do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("error occured during plugin configuration (%d)", rc); fh_log("fh_shr_cfg_lh.c", 281, "MGMT", "ERR", _msg); } } while (0);
            return rc;
        }
    }
    return (0);
}

variable_types:
process
char *

variable_types:
root
char *

variable_types: struct fh_cfg_node { char name[255]; struct fh_cfg_node **children; struct fh_cfg_node *parent; char **values; int num_children; int num_values; } *

variable_types: struct fh_shr_cfg_lh_proc { char name[255]; int cpu; struct fh_shr_cfg_lh_line { struct fh_shr_cfg_lh_proc *process; char name[255]; struct fh_shr_cfg_lh_conn { struct fh_shr_cfg_lh_line *line; unsigned char enabled; unsigned short port; unsigned int address; char login_name[6]; char login_passwd[10]; char interface[255]; void *context; } primary; struct fh_shr_cfg_lh_conn secondary; void *context; } *lines; int num_lines; int gap_list_max; int gap_timeout; struct fh_shr_cfg_tbl { char name[255]; unsigned char enabled; unsigned int size; } symbol_table; struct fh_shr_cfg_tbl order_table; void *context; } *

variable_types: rc int

user_defined_types: struct fh_shr_cfg_lh_proc { char name[255]; int cpu; struct fh_shr_cfg_lh_line *lines; int num_lines; int gap_list_max; int gap_timeout; struct fh_shr_cfg_tbl symbol_table; struct fh_shr_cfg_tbl order_table; void *context; }

user_defined_types: struct fh_shr_cfg_lh_line { struct fh_shr_cfg_lh_proc *process; char name[255]; struct fh_shr_cfg_lh_conn primary; struct fh_shr_cfg_lh_conn secondary; void *context; }


decompiled_code:
__int64 __fastcall fh_shr_cfg_lh_get_proc(char *dest, const char *a2, __int64 a3)
{
__int64 v4; // rax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

sprintf(v6, "%s.processes", a2);
v4 = fh_cfg_get_node(a3, v6);
if ( *dest )
return (unsigned int)-(fh_cfg_get_node(v4, dest) == 0);
if ( !v4 )
return 0xFFFFFFFFLL;
if ( *(int *)(v4 + 280) <= 0 )
return 0xFFFFFFFFLL;
strcpy(dest, **(const char ***)(v4 + 256));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *dest, const char *a2, __int64 a3)
{
__int64 v4; // rax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

sprintf(v6, "%s.processes", a2);
v4 = fh_cfg_get_node(a3, v6);
if ( *dest )
return (unsigned int)-(fh_cfg_get_node(v4, dest) == 0);
if ( !v4 )
return 0xFFFFFFFFLL;
if ( *(int *)(v4 + 280) <= 0 )
return 0xFFFFFFFFLL;
strcpy(dest, **(const char ***)(v4 + 256));
return 0LL;
}

original_code:
FH_STATUS fh_shr_cfg_lh_get_proc(char *proc, const char *root, const fh_cfg_node_t *config)
{
    char node_name[255];
    const fh_cfg_node_t *node = ((void *)0);
    sprintf(node_name, "%s.processes", root);
    node = fh_cfg_get_node(config, node_name);
    if (proc[0] == '\0') {
        if (node == ((void *)0) || node->num_children <= 0) {
            return (-1);
        }
        strcpy(proc, node->children[0]->name);
    }
    else {
        if (fh_cfg_get_node(node, proc) == ((void *)0)) {
            return (-1);
        }
    }
    return (0);
}

canonical_original_code:
int fh_shr_cfg_lh_get_proc(char *proc, char *root, struct fh_cfg_node *config)
{
    char node_name[255];
    struct fh_cfg_node *node = ((void *)0);
    sprintf(node_name, "%s.processes", root);
    node = fh_cfg_get_node(config, node_name);
    if (proc[0] == '\0') {
        if (node == ((void *)0) || node->num_children <= 0) {
            return (-1);
        }
        strcpy(proc, node->children[0]->name);
    }
    else {
        if (fh_cfg_get_node(node, proc) == ((void *)0)) {
            return (-1);
        }
    }
    return (0);
}

variable_types:
proc
char *

user_defined_types: struct fh_cfg_node { char name[255]; struct fh_cfg_node **children; struct fh_cfg_node *parent; char **values; int num_children; int num_values; }


decompiled_code:
__int64 __fastcall add_connection(__int64 a1, const char *a2, __int64 a3)
{
__int64 v5; // rax
__int64 v6; // r13
unsigned int v7; // eax
unsigned int v8; // ebx
__int64 v9; // rax
const char *v11; // rax
const char *v12; // r14
__int64 v13; // rax
__int64 v14; // rax
unsigned int v15; // eax
__int64 v16; // rax
__int64 v17; // rax
const char *v18; // rsi
__int64 v19; // rax
struct in_addr inp; // [rsp+Ch] [rbp-2Ch] BYREF

v5 = fh_cfg_get_node();
if ( v5 )
{
v6 = v5;
v7 = fh_cfg_set_yesno(v5, "enabled", a3 + 8);
v8 = v7;
if ( v7 )
{
if ( v7 == 1 )
{
if ( (fh_log_lvl & 2) != 0 )
{
v14 = fh_log_fmt("connection %s: missing property 'enabled'...disabling", a2);
fh_log("fh_shr_cfg_lh.c", 70LL, "CSI", "WARN", v14);
}
}
else
{
v8 = -1;
if ( (fh_log_lvl & 2) != 0 )
{
v9 = fh_log_fmt("connection %s: property 'enabled' must be 'yes' or 'no'", a2);
fh_log("fh_shr_cfg_lh.c", 75LL, "CSI", "WARN", v9);
}
}
}
else if ( *(_BYTE *)(a3 + 8) )
{
v11 = (const char *)fh_cfg_get_string(v6, "address");
v12 = v11;
if ( v11 && inet_aton(v11, &inp) )
{
*(struct in_addr *)(a3 + 12) = inp;
v15 = fh_cfg_set_uint16(v6, "port", a3 + 10);
v8 = v15;
if ( v15 )
{
if ( v15 == 1 )
{
if ( (fh_log_lvl & 2) != 0 )
{
v16 = fh_log_fmt("connection %s: missing port address property", a2);
fh_log("fh_shr_cfg_lh.c", 97LL, "CSI", "WARN", v16);
}
}
else
{
v8 = -1;
if ( (fh_log_lvl & 1) != 0 )
{
v17 = fh_log_fmt("connection %s: invalid port address", a2);
fh_log("fh_shr_cfg_lh.c", 101LL, "CSI", "ERR", v17);
}
}
}
else
{
v18 = (const char *)fh_cfg_get_string(v6, "interface");
if ( v18 )
{
strcpy((char *)(a3 + 32), v18);
*(_BYTE *)(a3 + 8) = 1;
}
else
{
v8 = 1;
if ( (fh_log_lvl & 1) != 0 )
{
v19 = fh_log_fmt("missing interface specification for %s connection", a2);
fh_log("fh_shr_cfg_lh.c", 108LL, "CSI", "ERR", v19);
}
}
}
}
else
{
v8 = -1;
if ( (fh_log_lvl & 1) != 0 )
{
v13 = fh_log_fmt("invalid ip address '%s' for %s connection", v12, a2);
fh_log("fh_shr_cfg_lh.c", 85LL, "CSI", "ERR", v13);
}
}
}
}
else
{
*(_BYTE *)(a3 + 8) = 0;
v8 = 0;
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, __int64 a3)
{
__int64 v5; // rax
__int64 v6; // r13
unsigned int v7; // eax
unsigned int v8; // ebx
__int64 v9; // rax
const char *v11; // rax
const char *v12; // r14
__int64 v13; // rax
__int64 v14; // rax
unsigned int v15; // eax
__int64 v16; // rax
__int64 v17; // rax
const char *v18; // rsi
__int64 v19; // rax
struct in_addr inp; // [rsp+Ch] [rbp-2Ch] BYREF

v5 = fh_cfg_get_node();
if ( v5 )
{
v6 = v5;
v7 = fh_cfg_set_yesno(v5, "enabled", a3 + 8);
v8 = v7;
if ( v7 )
{
if ( v7 == 1 )
{
if ( (fh_log_lvl & 2) != 0 )
{
v14 = fh_log_fmt("connection %s: missing property 'enabled'...disabling", a2);
fh_log("fh_shr_cfg_lh.c", 70LL, "CSI", "WARN", v14);
}
}
else
{
v8 = -1;
if ( (fh_log_lvl & 2) != 0 )
{
v9 = fh_log_fmt("connection %s: property 'enabled' must be 'yes' or 'no'", a2);
fh_log("fh_shr_cfg_lh.c", 75LL, "CSI", "WARN", v9);
}
}
}
else if ( *(_BYTE *)(a3 + 8) )
{
v11 = (const char *)fh_cfg_get_string(v6, "address");
v12 = v11;
if ( v11 && inet_aton(v11, &inp) )
{
*(struct in_addr *)(a3 + 12) = inp;
v15 = fh_cfg_set_uint16(v6, "port", a3 + 10);
v8 = v15;
if ( v15 )
{
if ( v15 == 1 )
{
if ( (fh_log_lvl & 2) != 0 )
{
v16 = fh_log_fmt("connection %s: missing port address property", a2);
fh_log("fh_shr_cfg_lh.c", 97LL, "CSI", "WARN", v16);
}
}
else
{
v8 = -1;
if ( (fh_log_lvl & 1) != 0 )
{
v17 = fh_log_fmt("connection %s: invalid port address", a2);
fh_log("fh_shr_cfg_lh.c", 101LL, "CSI", "ERR", v17);
}
}
}
else
{
v18 = (const char *)fh_cfg_get_string(v6, "interface");
if ( v18 )
{
strcpy((char *)(a3 + 32), v18);
*(_BYTE *)(a3 + 8) = 1;
}
else
{
v8 = 1;
if ( (fh_log_lvl & 1) != 0 )
{
v19 = fh_log_fmt("missing interface specification for %s connection", a2);
fh_log("fh_shr_cfg_lh.c", 108LL, "CSI", "ERR", v19);
}
}
}
}
else
{
v8 = -1;
if ( (fh_log_lvl & 1) != 0 )
{
v13 = fh_log_fmt("invalid ip address '%s' for %s connection", v12, a2);
fh_log("fh_shr_cfg_lh.c", 85LL, "CSI", "ERR", v13);
}
}
}
}
else
{
*(_BYTE *)(a3 + 8) = 0;
v8 = 0;
}
return v8;
}

original_code:
static FH_STATUS add_connection(const fh_cfg_node_t *config, const char *name,
                                fh_shr_cfg_lh_conn_t *conn)
{
    const fh_cfg_node_t *node = ((void *)0);
    const char *property = ((void *)0);
    struct in_addr address;
    node = fh_cfg_get_node(config, name);
    if (node == ((void *)0)) {
        conn->enabled = 0;
        return (0);
    }
    switch(fh_cfg_set_yesno(node, "enabled", &conn->enabled)) {
    case (0):
        if (!conn->enabled) return (0);
        break;
    case (1):
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("connection %s: missing property 'enabled'...disabling", name); fh_log("fh_shr_cfg_lh.c", 70, "CSI", "WARN", _msg); } } while (0);
        return (1);
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("connection %s: property 'enabled' must be 'yes' or 'no'", name); fh_log("fh_shr_cfg_lh.c", 75, "CSI", "WARN", _msg); } } while (0);
        return (-1);
    }
    property = fh_cfg_get_string(node, "address");
    if (property == ((void *)0) || !inet_aton(property, &address)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("invalid ip address '%s' for %s connection", property, name); fh_log("fh_shr_cfg_lh.c", 85, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    conn->address = address.s_addr;
    switch(fh_cfg_set_uint16(node, "port", &conn->port)) {
    case (0):
        break;
    case (1):
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("connection %s: missing port address property", name); fh_log("fh_shr_cfg_lh.c", 97, "CSI", "WARN", _msg); } } while (0);
        return (1);
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("connection %s: invalid port address", name); fh_log("fh_shr_cfg_lh.c", 101, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    property = fh_cfg_get_string(node, "interface");
    if (property == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing interface specification for %s connection", name); fh_log("fh_shr_cfg_lh.c", 108, "CSI", "ERR", _msg); } } while (0);
        return (1);
    }
    strcpy(conn->interface, property);
    conn->enabled = 1;
    return (0);
}

canonical_original_code:
static int add_connection(struct fh_cfg_node *config, char *name, struct fh_shr_cfg_lh_conn *conn)
{
    struct fh_cfg_node *node = ((void *)0);
    char *property = ((void *)0);
    struct in_addr address;
    node = fh_cfg_get_node(config, name);
    if (node == ((void *)0)) {
        conn->enabled = 0;
        return (0);
    }
    switch(fh_cfg_set_yesno(node, "enabled", &conn->enabled)) {
    case (0):
        if (!conn->enabled) return (0);
        break;
    case (1):
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("connection %s: missing property 'enabled'...disabling", name); fh_log("fh_shr_cfg_lh.c", 70, "CSI", "WARN", _msg); } } while (0);
        return (1);
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("connection %s: property 'enabled' must be 'yes' or 'no'", name); fh_log("fh_shr_cfg_lh.c", 75, "CSI", "WARN", _msg); } } while (0);
        return (-1);
    }
    property = fh_cfg_get_string(node, "address");
    if (property == ((void *)0) || !inet_aton(property, &address)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("invalid ip address '%s' for %s connection", property, name); fh_log("fh_shr_cfg_lh.c", 85, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    conn->address = address.s_addr;
    switch(fh_cfg_set_uint16(node, "port", &conn->port)) {
    case (0):
        break;
    case (1):
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("connection %s: missing port address property", name); fh_log("fh_shr_cfg_lh.c", 97, "CSI", "WARN", _msg); } } while (0);
        return (1);
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("connection %s: invalid port address", name); fh_log("fh_shr_cfg_lh.c", 101, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    property = fh_cfg_get_string(node, "interface");
    if (property == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing interface specification for %s connection", name); fh_log("fh_shr_cfg_lh.c", 108, "CSI", "ERR", _msg); } } while (0);
        return (1);
    }
    strcpy(conn->interface, property);
    conn->enabled = 1;
    return (0);
}

variable_types:
name
char *

variable_types: struct fh_shr_cfg_lh_conn { struct fh_shr_cfg_lh_line { struct fh_shr_cfg_lh_proc { char name[255]; int cpu; struct fh_shr_cfg_lh_line *lines; int num_lines; int gap_list_max; int gap_timeout; struct fh_shr_cfg_tbl { char name[255]; unsigned char enabled; unsigned int size; } symbol_table; struct fh_shr_cfg_tbl order_table; void *context; } *process; char name[255]; struct fh_shr_cfg_lh_conn primary; struct fh_shr_cfg_lh_conn secondary; void *context; } *line; unsigned char enabled; unsigned short port; unsigned int address; char login_name[6]; char login_passwd[10]; char interface[255]; void *context; } *

variable_types:
property
char *

variable_types:
address
struct in_addr { unsigned int s_addr; }

user_defined_types: struct fh_shr_cfg_lh_conn { struct fh_shr_cfg_lh_line *line; unsigned char enabled; unsigned short port; unsigned int address; char login_name[6]; char login_passwd[10]; char interface[255]; void *context; }


decompiled_code:
__int64 __fastcall add_line(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r12
char *v6; // rax
int v7; // edx
char *v8; // rbx
__int64 result; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax

v4 = fh_cfg_get_node(a1, "lines");
if ( v4 )
{
v5 = fh_cfg_get_node(v4, a2);
if ( v5 )
{
v6 = (char *)realloc(*(void **)(a3 + 264), 864LL * (*(_DWORD *)(a3 + 272) + 1));
*(_QWORD *)(a3 + 264) = v6;
if ( v6 )
{
v7 = *(_DWORD *)(a3 + 272);
*(_DWORD *)(a3 + 272) = v7 + 1;
v8 = &v6[864 * v7];
memset(v8, 0, 0x360uLL);
*(_QWORD *)v8 = a3;
strcpy(v8 + 8, a2);
if ( (unsigned int)add_connection(v5, "primary", (__int64)(v8 + 264)) )
{
*((_QWORD *)v8 + 33) = v8;
result = 0xFFFFFFFFLL;
}
else
{
result = add_connection(v5, "secondary", (__int64)(v8 + 560));
if ( (_DWORD)result )
{
*((_QWORD *)v8 + 70) = v8;
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl & 1) != 0 )
{
v12 = fh_log_fmt("unable to allocate memory for line '%s'", a2);
fh_log("fh_shr_cfg_lh.c", 152LL, "CSI", "ERR", v12);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl & 1) != 0 )
{
v11 = fh_log_fmt("missing configuration for line '%d'", a2);
fh_log("fh_shr_cfg_lh.c", 144LL, "CSI", "ERR", v11);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl & 1) != 0 )
{
v10 = fh_log_fmt("missing configuration option 'lines'");
fh_log("fh_shr_cfg_lh.c", 137LL, "CSI", "ERR", v10);
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r12
char *v6; // rax
int v7; // edx
char *v8; // rbx
__int64 result; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax

v4 = fh_cfg_get_node(a1, "lines");
if ( v4 )
{
v5 = fh_cfg_get_node(v4, a2);
if ( v5 )
{
v6 = (char *)realloc(*(void **)(a3 + 264), 864LL * (*(_DWORD *)(a3 + 272) + 1));
*(_QWORD *)(a3 + 264) = v6;
if ( v6 )
{
v7 = *(_DWORD *)(a3 + 272);
*(_DWORD *)(a3 + 272) = v7 + 1;
v8 = &v6[864 * v7];
memset(v8, 0, 0x360uLL);
*(_QWORD *)v8 = a3;
strcpy(v8 + 8, a2);
if ( (unsigned int)func0(v5, "primary", (__int64)(v8 + 264)) )
{
*((_QWORD *)v8 + 33) = v8;
result = 0xFFFFFFFFLL;
}
else
{
result = func0(v5, "secondary", (__int64)(v8 + 560));
if ( (_DWORD)result )
{
*((_QWORD *)v8 + 70) = v8;
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl & 1) != 0 )
{
v12 = fh_log_fmt("unable to allocate memory for line '%s'", a2);
fh_log("fh_shr_cfg_lh.c", 152LL, "CSI", "ERR", v12);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl & 1) != 0 )
{
v11 = fh_log_fmt("missing configuration for line '%d'", a2);
fh_log("fh_shr_cfg_lh.c", 144LL, "CSI", "ERR", v11);
result = 0xFFFFFFFFLL;
}
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl & 1) != 0 )
{
v10 = fh_log_fmt("missing configuration option 'lines'");
fh_log("fh_shr_cfg_lh.c", 137LL, "CSI", "ERR", v10);
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
static FH_STATUS add_line(const fh_cfg_node_t *config, const char *name,
                          fh_shr_cfg_lh_proc_t *lh_config)
{
    const fh_cfg_node_t *lines_node = ((void *)0);
    const fh_cfg_node_t *line_node = ((void *)0);
    fh_shr_cfg_lh_line_t *line;
    lines_node = fh_cfg_get_node(config, "lines");
    if (lines_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing configuration option 'lines'"); fh_log("fh_shr_cfg_lh.c", 137, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line_node = fh_cfg_get_node(lines_node, name);
    if (line_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing configuration for line '%d'", name); fh_log("fh_shr_cfg_lh.c", 144, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    lh_config->lines = (fh_shr_cfg_lh_line_t *)realloc(lh_config->lines,
                        sizeof(fh_shr_cfg_lh_line_t) * (lh_config->num_lines + 1));
    if (lh_config->lines == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to allocate memory for line '%s'", name); fh_log("fh_shr_cfg_lh.c", 152, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line = &lh_config->lines[lh_config->num_lines++];
    memset(line, 0, sizeof(fh_shr_cfg_lh_line_t));
    line->process = lh_config;
    strcpy(line->name, name);
    if (add_connection(line_node, "primary", &line->primary) != (0)) {
        line->primary.line = line;
        return (-1);
    }
    if (add_connection(line_node, "secondary", &line->secondary) != (0)) {
        line->secondary.line = line;
        return (-1);
    }
    return (0);
}

canonical_original_code:
static int add_line(struct fh_cfg_node *config, char *name, struct fh_shr_cfg_lh_proc *lh_config)
{
    struct fh_cfg_node *lines_node = ((void *)0);
    struct fh_cfg_node *line_node = ((void *)0);
    struct fh_shr_cfg_lh_line *line;
    lines_node = fh_cfg_get_node(config, "lines");
    if (lines_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing configuration option 'lines'"); fh_log("fh_shr_cfg_lh.c", 137, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line_node = fh_cfg_get_node(lines_node, name);
    if (line_node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing configuration for line '%d'", name); fh_log("fh_shr_cfg_lh.c", 144, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    lh_config->lines = (struct fh_shr_cfg_lh_line *)realloc(lh_config->lines,
                        sizeof(fh_shr_cfg_lh_line_t) * (lh_config->num_lines + 1));
    if (lh_config->lines == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to allocate memory for line '%s'", name); fh_log("fh_shr_cfg_lh.c", 152, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line = &lh_config->lines[lh_config->num_lines++];
    memset(line, 0, sizeof(fh_shr_cfg_lh_line_t));
    line->process = lh_config;
    strcpy(line->name, name);
    if (add_connection(line_node, "primary", &line->primary) != (0)) {
        line->primary.line = line;
        return (-1);
    }
    if (add_connection(line_node, "secondary", &line->secondary) != (0)) {
        line->secondary.line = line;
        return (-1);
    }
    return (0);
}

variable_types: struct fh_shr_cfg_lh_line { struct fh_shr_cfg_lh_proc { char name[255]; int cpu; struct fh_shr_cfg_lh_line *lines; int num_lines; int gap_list_max; int gap_timeout; struct fh_shr_cfg_tbl { char name[255]; unsigned char enabled; unsigned int size; } symbol_table; struct fh_shr_cfg_tbl order_table; void *context; } *process; char name[255]; struct fh_shr_cfg_lh_conn { struct fh_shr_cfg_lh_line *line; unsigned char enabled; unsigned short port; unsigned int address; char login_name[6]; char login_passwd[10]; char interface[255]; void *context; } primary; struct fh_shr_cfg_lh_conn secondary; void *context; } *


original_code:
FH_STATUS adm_reg_req_pack(void *msg, char *data, int *length)
{
    fh_adm_reg_req_t *m_reg = (fh_adm_reg_req_t *) msg;
    fh_adm_reg_req_t *d_reg = (fh_adm_reg_req_t *) data;
    *length = sizeof(fh_adm_reg_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    d_reg->reg_type = __bswap_16 (m_reg->reg_type);
    d_reg->reg_port = __bswap_16 (m_reg->reg_port);
    d_reg->reg_pid = __bswap_32 (m_reg->reg_pid);
    d_reg->reg_addr = m_reg->reg_addr;
    strcpy(d_reg->reg_srv, m_reg->reg_srv);
    return (0);
}

canonical_original_code:
int adm_reg_req_pack(void *msg, char *data, int *length)
{
    struct fh_adm_reg_req_t *m_reg = (fh_adm_reg_req_t *) msg;
    struct fh_adm_reg_req_t *d_reg = (fh_adm_reg_req_t *) data;
    *length = sizeof(fh_adm_reg_req_t);
    if (data == ((void *)0)) {
        return (0);
    }
    d_reg->reg_type = __bswap_16 (m_reg->reg_type);
    d_reg->reg_port = __bswap_16 (m_reg->reg_port);
    d_reg->reg_pid = __bswap_32 (m_reg->reg_pid);
    d_reg->reg_addr = m_reg->reg_addr;
    strcpy(d_reg->reg_srv, m_reg->reg_srv);
    return (0);
}

variable_types:
msg
void *

variable_types:
data
char *

variable_types:
length
int *

variable_types: struct fh_adm_reg_req_t { unsigned short reg_type; unsigned short reg_port; unsigned int reg_addr; unsigned int reg_pid; char reg_srv[16]; } *


decompiled_code:
__int64 __fastcall adm_reg_req_unpack(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // rax

if ( a3 != 28 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_reg_req_t)",
"admin/fh_adm_reg_req.c",
60LL);
fh_log("admin/fh_adm_reg_req.c", 60LL, 0LL, "ERR", v4);
exit(1);
}
*(_WORD *)a1 = _bswap_16(*(_WORD *)a2);
*(_WORD *)(a1 + 2) = _bswap_16(*(_WORD *)(a2 + 2));
*(_DWORD *)(a1 + 8) = _bswap_32(*(_DWORD *)(a2 + 8));
*(_DWORD *)(a1 + 4) = *(_DWORD *)(a2 + 4);
strcpy((char *)(a1 + 12), (const char *)(a2 + 12));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // rax

if ( a3 != 28 )
{
v4 = fh_log_fmt(
"assertion '%s' failed at %s:%d",
"length == sizeof(fh_adm_reg_req_t)",
"admin/fh_adm_reg_req.c",
60LL);
fh_log("admin/fh_adm_reg_req.c", 60LL, 0LL, "ERR", v4);
exit(1);
}
*(_WORD *)a1 = func0(*(_WORD *)a2);
*(_WORD *)(a1 + 2) = func0(*(_WORD *)(a2 + 2));
*(_DWORD *)(a1 + 8) = func1(*(_DWORD *)(a2 + 8));
*(_DWORD *)(a1 + 4) = *(_DWORD *)(a2 + 4);
strcpy((char *)(a1 + 12), (const char *)(a2 + 12));
return 0LL;
}

original_code:
FH_STATUS adm_reg_req_unpack(void *msg, char *data, int length)
{
    fh_adm_reg_req_t *m_reg = (fh_adm_reg_req_t *) msg;
    fh_adm_reg_req_t *d_reg = (fh_adm_reg_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_reg_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_reg_req_t)", "admin/fh_adm_reg_req.c", 60); fh_log("admin/fh_adm_reg_req.c", 60, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    m_reg->reg_type = __bswap_16 (d_reg->reg_type);
    m_reg->reg_port = __bswap_16 (d_reg->reg_port);
    m_reg->reg_pid = __bswap_32 (d_reg->reg_pid);
    m_reg->reg_addr = d_reg->reg_addr;
    strcpy(m_reg->reg_srv, d_reg->reg_srv);
    return (0);
}

canonical_original_code:
int adm_reg_req_unpack(void *msg, char *data, int length)
{
    struct fh_adm_reg_req_t *m_reg = (fh_adm_reg_req_t *) msg;
    struct fh_adm_reg_req_t *d_reg = (fh_adm_reg_req_t *) data;
    do { int nok = !(length == sizeof(fh_adm_reg_req_t)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "length == sizeof(fh_adm_reg_req_t)", "admin/fh_adm_reg_req.c", 60); fh_log("admin/fh_adm_reg_req.c", 60, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    m_reg->reg_type = __bswap_16 (d_reg->reg_type);
    m_reg->reg_port = __bswap_16 (d_reg->reg_port);
    m_reg->reg_pid = __bswap_32 (d_reg->reg_pid);
    m_reg->reg_addr = d_reg->reg_addr;
    strcpy(m_reg->reg_srv, d_reg->reg_srv);
    return (0);
}

variable_types: length int

variable_types: nok int

user_defined_types: struct fh_adm_reg_req_t { unsigned short reg_type; unsigned short reg_port; unsigned int reg_addr; unsigned int reg_pid; char reg_srv[16]; }


decompiled_code:
__int64 __fastcall fh_cli_filter_match(char *string)
{
__int64 result; // rax
int v2; // eax

result = 1LL;
if ( rep )
{
v2 = regexec(rep, string, 0LL, 0LL, 0);
if ( exclude )
result = (unsigned int)-(v2 == 0);
else
result = (unsigned int)-(v2 != 0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *string)
{
__int64 result; // rax
int v2; // eax

result = 1LL;
if ( rep )
{
v2 = regexec(rep, string, 0LL, 0LL, 0);
if ( exclude )
result = (unsigned int)-(v2 == 0);
else
result = (unsigned int)-(v2 != 0);
}
return result;
}

original_code:
int fh_cli_filter_match(char *string)
{
    int rc = -1;
    if (rep == ((void *)0)) {
        return 1;
    }
    if (!regexec(rep, string, 0, 0, 0)) {
        rc = 0;
    }
    if (exclude) {
        rc = (rc == 0) ? -1 : 0;
    }
    return rc;
}

variable_types:
string
char *


decompiled_code:
int __fastcall fh_cli_filter_init(const char *a1, const char *a2)
{
int v4; // eax
unsigned __int64 v5; // rcx
int result; // eax
unsigned __int64 v7; // rcx

if ( a1 )
{
v4 = strlen(a1);
rep = &regex;
v5 = 8LL;
if ( (unsigned __int64)v4 <= 8 )
v5 = v4;
if ( !memcmp(a1, "exclude", v5) )
{
exclude = 0;
}
else
{
v7 = 8LL;
if ( (unsigned __int64)v4 <= 8 )
v7 = v4;
if ( memcmp(a1, "include", v7) )
{
rep = 0LL;
fh_cli_write("Invalid filter keyword: %s\n", a1);
return -1;
}
exclude = 1;
}
result = regcomp(&regex, a2, 11);
if ( result )
{
rep = 0LL;
fh_cli_write("Invalid regexp \"%s\"\n", a2);
result = -1;
}
}
else
{
rep = 0LL;
result = 0;
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1, const char *a2)
{
int v4; // eax
unsigned __int64 v5; // rcx
int result; // eax
unsigned __int64 v7; // rcx

if ( a1 )
{
v4 = strlen(a1);
rep = &regex;
v5 = 8LL;
if ( (unsigned __int64)v4 <= 8 )
v5 = v4;
if ( !memcmp(a1, "exclude", v5) )
{
exclude = 0;
}
else
{
v7 = 8LL;
if ( (unsigned __int64)v4 <= 8 )
v7 = v4;
if ( memcmp(a1, "include", v7) )
{
rep = 0LL;
fh_cli_write("Invalid filter keyword: %s\n", a1);
return -1;
}
exclude = 1;
}
result = regcomp(&regex, a2, 11);
if ( result )
{
rep = 0LL;
fh_cli_write("Invalid regexp \"%s\"\n", a2);
result = -1;
}
}
else
{
rep = 0LL;
result = 0;
}
return result;
}

original_code:
int fh_cli_filter_init(char *filter, char *regexp)
{
    int filter_len = filter ? strlen(filter) : 0;
    if (filter == ((void *)0)) {
        rep = ((void *)0);
        return 0;
    }
    else {
        rep = &_regex;
    }
    if (strncmp(filter, "exclude", filter_len) == 0) {
        exclude = 0;
    }
    else if (strncmp(filter, "include", filter_len) == 0) {
        exclude = 1;
    }
    else {
        rep = ((void *)0);
        fh_cli_write("Invalid filter keyword: %s\n", filter);
        return -1;
    }
    if (regcomp(rep, regexp, ((1 << 3)|1|(1 << 1)))) {
        rep = ((void *)0);
        fh_cli_write("Invalid regexp \"%s\"\n", regexp);
        return -1;
    }
    return 0;
}

variable_types:
filter
char *

variable_types:
regexp
char *


decompiled_code:
void fh_cli_filter_clean()
{
if ( rep )
{
regfree(rep);
rep = 0LL;
}
}

canonical_decompiled_code:
void func2()
{
if ( rep )
{
regfree(rep);
rep = 0LL;
}
}

original_code:
void fh_cli_filter_clean()
{
    if (rep) {
        regfree(rep);
        rep = ((void *)0);
    }
}

return_type: void


decompiled_code:
__int64 sample_init()
{
__int64 result; // rax

if ( (unsigned int)fh_plugin_register(0LL, sample_log_msg) )
exit(-1);
result = fh_plugin_register(0LL, sample_log_msg);
if ( (_DWORD)result )
exit(-1);
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

if ( (unsigned int)fh_plugin_register(0LL, sample_log_msg) )
exit(-1);
result = fh_plugin_register(0LL, sample_log_msg);
if ( (_DWORD)result )
exit(-1);
return result;
}

original_code:
void __attribute__ ((constructor)) sample_init(void) {
    if (fh_plugin_register((0), sample_log_msg) != (0)) {
        exit(-1);
    }
    if (fh_plugin_register((0), sample_log_msg) != (0)) {
        exit(-1);
    }
}

canonical_original_code:
void sample_init() {
    if (fh_plugin_register((0), sample_log_msg) != (0)) {
        exit(-1);
    }
    if (fh_plugin_register((0), sample_log_msg) != (0)) {
        exit(-1);
    }
}


original_code:
FH_STATUS fh_opra_topic_fmt(fh_opra_topic_fmt_t *tfmt, fh_opra_opt_key_t *k,
                            char *topic, uint32_t length)
{
    register uint32_t i = 0;
    register uint32_t j = 0;
    for (i = 0; i < tfmt->tfmt_num_stanzas && j < length; i++) {
        register char *ptr = tfmt->tfmt_stanza_fmts[i];
        if (ptr == ((void *)0)) {
            do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Topic format is missing stanza[%d]", i); fh_log("fh_opra_topic.c", 48, "MGMT", "ERR", _msg); } } while (0);
            return (-1);
        }
        do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("Topic format stanza[%d] = '%s'", i, ptr); fh_log("fh_opra_topic.c", 52, "MGMT", "DIAG", _msg); } } while (0);
        while (*ptr != '\0' && j < length) {
            if (*ptr != '$') {
                topic[j++] = *ptr++;
            }
            else {
                ptr++;
                if (*ptr == '\0') {
                    do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Invalid topic format: stanza[%d] = '%s'", i, tfmt->tfmt_stanza_fmts[i]); fh_log("fh_opra_topic.c", 62, "MGMT", "ERR", _msg); } } while (0);
                }
                switch (*ptr++) {
                case ('S'):
                {
                    register char *uptr = k->k_symbol;
                    register int count = 0;
                    while (*uptr != '\0' && count++ < (5) && j < length) {
                        topic[j++] = *uptr++;
                    }
                }
                break;
                case ('Y'):
                {
                    sprintf(&topic[j], "%.2u", k->k_year);
                    j += 2;
                }
                break;
                case ('M'):
                {
                    sprintf(&topic[j], "%.2u", k->k_month);
                    j += 2;
                }
                break;
                case ('D'):
                {
                    sprintf(&topic[j], "%.2u", k->k_day);
                    j += 2;
                }
                break;
                case ('C'):
                {
                    topic[j++] = k->k_putcall;
                }
                break;
                case ('I'):
                {
                    sprintf(&topic[j], "%.5u", k->k_decimal);
                    j += 5;
                }
                break;
                case ('F'):
                {
                    sprintf(&topic[j], "%.3u", k->k_fraction * 1000);
                    j += 3;
                }
                break;
                case ('X'):
                {
                    topic[j++] = k->k_exchid;
                }
                break;
                default:
                    do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Invalid topic format variable: $%c - stanza[%d] = '%s'", *ptr, i, tfmt->tfmt_stanza_fmts[i]); fh_log("fh_opra_topic.c", 126, "MGMT", "ERR", _msg); } } while (0);
                    do { int nok = !(1); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "1", "fh_opra_topic.c", 128); fh_log("fh_opra_topic.c", 128, ((void *)0), "ERR", _msg); exit(1); } } while (0);
                }
            }
        }
        if (j < length && (i+1) != tfmt->tfmt_num_stanzas) {
            topic[j++] = tfmt->tfmt_stanza_delim;
        }
    }
    if (j == length) {
        topic[j-1] = '\0';
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Topic too long (len:%d): topic: %s", topic); fh_log("fh_opra_topic.c", 141, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    topic[j] = '\0';
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("Topic formatted successfully: topic: %s (len:%d)", topic, j); fh_log("fh_opra_topic.c", 148, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

canonical_original_code:
int fh_opra_topic_fmt(struct fh_opra_topic_fmt_t *tfmt, struct fh_opra_opt_key_t *k, char *topic, unsigned int length)
{
    register unsigned int i = 0;
    register unsigned int j = 0;
    for (i = 0; i < tfmt->tfmt_num_stanzas && j < length; i++) {
        register char *ptr = tfmt->tfmt_stanza_fmts[i];
        if (ptr == ((void *)0)) {
            do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Topic format is missing stanza[%d]", i); fh_log("fh_opra_topic.c", 48, "MGMT", "ERR", _msg); } } while (0);
            return (-1);
        }
        do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("Topic format stanza[%d] = '%s'", i, ptr); fh_log("fh_opra_topic.c", 52, "MGMT", "DIAG", _msg); } } while (0);
        while (*ptr != '\0' && j < length) {
            if (*ptr != '$') {
                topic[j++] = *ptr++;
            }
            else {
                ptr++;
                if (*ptr == '\0') {
                    do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Invalid topic format: stanza[%d] = '%s'", i, tfmt->tfmt_stanza_fmts[i]); fh_log("fh_opra_topic.c", 62, "MGMT", "ERR", _msg); } } while (0);
                }
                switch (*ptr++) {
                case ('S'):
                {
                    register char *uptr = k->k_symbol;
                    register int count = 0;
                    while (*uptr != '\0' && count++ < (5) && j < length) {
                        topic[j++] = *uptr++;
                    }
                }
                break;
                case ('Y'):
                {
                    sprintf(&topic[j], "%.2u", k->k_year);
                    j += 2;
                }
                break;
                case ('M'):
                {
                    sprintf(&topic[j], "%.2u", k->k_month);
                    j += 2;
                }
                break;
                case ('D'):
                {
                    sprintf(&topic[j], "%.2u", k->k_day);
                    j += 2;
                }
                break;
                case ('C'):
                {
                    topic[j++] = k->k_putcall;
                }
                break;
                case ('I'):
                {
                    sprintf(&topic[j], "%.5u", k->k_decimal);
                    j += 5;
                }
                break;
                case ('F'):
                {
                    sprintf(&topic[j], "%.3u", k->k_fraction * 1000);
                    j += 3;
                }
                break;
                case ('X'):
                {
                    topic[j++] = k->k_exchid;
                }
                break;
                default:
                    do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Invalid topic format variable: $%c - stanza[%d] = '%s'", *ptr, i, tfmt->tfmt_stanza_fmts[i]); fh_log("fh_opra_topic.c", 126, "MGMT", "ERR", _msg); } } while (0);
                    do { int nok = !(1); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "1", "fh_opra_topic.c", 128); fh_log("fh_opra_topic.c", 128, ((void *)0), "ERR", _msg); exit(1); } } while (0);
                }
            }
        }
        if (j < length && (i+1) != tfmt->tfmt_num_stanzas) {
            topic[j++] = tfmt->tfmt_stanza_delim;
        }
    }
    if (j == length) {
        topic[j-1] = '\0';
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Topic too long (len:%d): topic: %s", topic); fh_log("fh_opra_topic.c", 141, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    topic[j] = '\0';
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("Topic formatted successfully: topic: %s (len:%d)", topic, j); fh_log("fh_opra_topic.c", 148, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

variable_types: struct fh_opra_topic_fmt_t { unsigned int tfmt_num_stanzas; char tfmt_stanza_delim; char *tfmt_stanza_fmts[-1]; } *

variable_types: struct fh_opra_opt_key_t { char k_symbol[5]; unsigned char k_year; unsigned char k_month; unsigned char k_day; char k_putcall; char k_exchid; unsigned short k_fraction; unsigned int k_decimal; } *

variable_types:
topic
char *

variable_types:
length
unsigned int

variable_types:
i
unsigned int

variable_types:
j
unsigned int

variable_types:
ptr
char *

variable_types:
uptr
char *

variable_types: count int


decompiled_code:
__int64 __fastcall fh_edge_main(__int64 a1, __int64 a2, int a3)
{
__int64 v4[5]; // [rsp+0h] [rbp-28h] BYREF

v4[0] = (__int64)&fh_edge_parse_init;
v4[1] = (__int64)&fh_edge_parse_msg;
v4[2] = (__int64)&fh_edge_conn_login;
v4[3] = (__int64)&fh_edge_alarm;
dword_E8 = a3;
return fh_shr_tcp_main(a1, a2, "edge", &version_info, v4);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v4[5]; // [rsp+0h] [rbp-28h] BYREF

v4[0] = (__int64)&fh_edge_parse_init;
v4[1] = (__int64)&fh_edge_parse_msg;
v4[2] = (__int64)&fh_edge_conn_login;
v4[3] = (__int64)&fh_edge_alarm;
dword_E8 = a3;
return fh_shr_tcp_main(a1, a2, "edge", &version_info, v4);
}

original_code:
int fh_edge_main(int argc, char **argv, int version)
{
    fh_shr_tcp_cb_t callbacks = {
        fh_edge_parse_init,
        fh_edge_parse_msg,
        fh_edge_conn_login,
        fh_edge_alarm,
    };
    version_info.version = version;
    return fh_shr_tcp_main(argc, argv, "edge", &version_info, &callbacks) ;
}

canonical_original_code:
int fh_edge_main(int argc, char **argv, int version)
{
    struct fh_shr_tcp_cb_t callbacks = {
        fh_edge_parse_init,
        fh_edge_parse_msg,
        fh_edge_conn_login,
        fh_edge_alarm,
    };
    version_info.version = version;
    return fh_shr_tcp_main(argc, argv, "edge", &version_info, &callbacks) ;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: version int

variable_types: struct fh_shr_tcp_cb_t { int (*init)(struct fh_shr_lh_proc { struct fh_shr_lh_line { struct fh_shr_lh_proc *process; struct fh_shr_lh_conn { struct fh_shr_lh_line *line; int socket; struct fh_shr_cfg_lh_conn { struct fh_shr_cfg_lh_line { struct fh_shr_cfg_lh_proc { char name[255]; int cpu; struct fh_shr_cfg_lh_line *lines; int num_lines; int gap_list_max; int gap_timeout; struct fh_shr_cfg_tbl { char name[255]; unsigned char enabled; unsigned int size; } symbol_table; struct fh_shr_cfg_tbl order_table; void *context; } *process; char name[255]; struct fh_shr_cfg_lh_conn primary; struct fh_shr_cfg_lh_conn secondary; void *context; } *line; unsigned char enabled; unsigned short port; unsigned int address; char login_name[6]; char login_passwd[10]; char interface[255]; void *context; } *config; char tag[10]; unsigned long timestamp; struct fh_info_stats { unsigned long packets; unsigned long messages; unsigned long bytes; unsigned long packet_errors; unsigned long message_errors; unsigned long duplicate_packets; unsigned long gaps; unsigned long lost_messages; unsigned long recovered_messages; } stats; void *context; } primary; struct fh_shr_cfg_lh_line *config; unsigned long next_seq_no; unsigned long timestamp; struct fh_info_stats stats; void *context; } *lines; int num_lines; struct fh_shr_cfg_lh_proc *config; struct fh_info_stats stats; struct fh_shr_lkp_tbl { struct fh_mpool_t { char *mp_name; struct _mp_mblock { struct _mp_mblock *mb_next; } *mp_mblocks; struct _mp_mchunk { struct _mp_mchunk *mc_next; } *mp_mchunks; unsigned int mp_chunksize; unsigned int mp_nchunks; unsigned int mp_nblocks; unsigned int mp_flags; unsigned int mp_free; unsigned int mp_inuse; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mp_lock; } *mempool; struct fh_ht_t { struct fh_mpool_t *ht_mpool; struct he_head_t { struct _fh_ht_elt { struct he_entry_t { struct _fh_ht_elt *tqe_next; struct _fh_ht_elt **tqe_prev; } he_next; struct he_head_t *he_chead; void *he_value; void *he_key; int he_klen; unsigned int he_hashval; } *tqh_first; struct _fh_ht_elt **tqh_last; } *ht_table; unsigned int ht_size; unsigned int ht_count; unsigned int ht_mask; unsigned int ht_flags; struct fh_ht_kops_t { unsigned int (*kops_khash)(void *key, int klen); char *(*kops_kdump)(void *key, int klen); int (*kops_kcmp)(void *key_a, void *key_b, int klen); } ht_kops; } *hash; unsigned int size; unsigned int count; } symbol_table; struct fh_shr_lkp_tbl order_table; void *context; } *); int (*parse)(char *, unsigned int, char, struct fh_shr_lh_conn *, struct fh_shr_cfg_lh_line *, unsigned long *); int (*connect)(struct fh_shr_lh_proc *, struct fh_shr_cfg_lh_line *, unsigned long *); int (*alarm)(char *, int, int); }

user_defined_types: struct fh_shr_tcp_cb_t { int (*init)(struct fh_shr_lh_proc *); int (*parse)(char *, unsigned int, char, struct fh_shr_lh_conn *, struct fh_shr_cfg_lh_line *, unsigned long *); int (*connect)(struct fh_shr_lh_proc *, struct fh_shr_cfg_lh_line *, unsigned long *); int (*alarm)(char *, int, int); }

user_defined_types: struct fh_shr_lh_proc { struct fh_shr_lh_line *lines; int num_lines; struct fh_shr_cfg_lh_proc *config; struct fh_info_stats stats; struct fh_shr_lkp_tbl symbol_table; struct fh_shr_lkp_tbl order_table; void *context; }

user_defined_types: struct fh_shr_lkp_tbl { struct fh_mpool_t *mempool; struct fh_ht_t *hash; unsigned int size; unsigned int count; }

user_defined_types: struct fh_shr_lh_line { struct fh_shr_lh_proc *process; struct fh_shr_lh_conn primary; struct fh_shr_cfg_lh_line *config; unsigned long next_seq_no; unsigned long timestamp; struct fh_info_stats stats; void *context; }

user_defined_types: struct fh_shr_lh_conn { struct fh_shr_lh_line *line; int socket; struct fh_shr_cfg_lh_conn *config; char tag[10]; unsigned long timestamp; struct fh_info_stats stats; void *context; }

user_defined_types: struct fh_mpool_t { char *mp_name; struct _mp_mblock *mp_mblocks; struct _mp_mchunk *mp_mchunks; unsigned int mp_chunksize; unsigned int mp_nchunks; unsigned int mp_nblocks; unsigned int mp_flags; unsigned int mp_free; unsigned int mp_inuse; union pthread_mutex_t mp_lock; }

user_defined_types: struct fh_ht_t { struct fh_mpool_t *ht_mpool; struct he_head_t *ht_table; unsigned int ht_size; unsigned int ht_count; unsigned int ht_mask; unsigned int ht_flags; struct fh_ht_kops_t ht_kops; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct he_head_t { struct _fh_ht_elt *tqh_first; struct _fh_ht_elt **tqh_last; }

user_defined_types: struct _fh_ht_elt { struct he_entry_t he_next; struct he_head_t *he_chead; void *he_value; void *he_key; int he_klen; unsigned int he_hashval; }


decompiled_code:
__int64 __fastcall fh_itch_main(__int64 a1, __int64 a2, int a3)
{
__int64 v4[3]; // [rsp+0h] [rbp-18h] BYREF

v4[0] = (__int64)&fh_itch_parse_init;
v4[1] = (__int64)&fh_itch_parse_pkt;
dword_C8 = a3;
return fh_shr_mmcast_main(a1, a2, "itch", &version_info, v4);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v4[3]; // [rsp+0h] [rbp-18h] BYREF

v4[0] = (__int64)&fh_itch_parse_init;
v4[1] = (__int64)&fh_itch_parse_pkt;
dword_C8 = a3;
return fh_shr_mmcast_main(a1, a2, "itch", &version_info, v4);
}

original_code:
int fh_itch_main(int argc, char **argv, int version)
{
    fh_shr_mmcast_cb_t callbacks = {
        fh_itch_parse_init,
        fh_itch_parse_pkt
    };
    version_info.version = version;
    return fh_shr_mmcast_main(argc, argv, "itch", &version_info, &callbacks);
}

canonical_original_code:
int fh_itch_main(int argc, char **argv, int version)
{
    struct fh_shr_mmcast_cb_t callbacks = {
        fh_itch_parse_init,
        fh_itch_parse_pkt
    };
    version_info.version = version;
    return fh_shr_mmcast_main(argc, argv, "itch", &version_info, &callbacks);
}

variable_types: struct fh_shr_mmcast_cb_t { int (*init)(struct fh_shr_lh_proc { struct fh_shr_lh_line { struct fh_shr_lh_proc *process; struct fh_shr_lh_conn { struct fh_shr_lh_line *line; int socket; struct fh_shr_cfg_lh_conn { struct fh_shr_cfg_lh_line { struct fh_shr_cfg_lh_proc { char name[255]; int cpu; struct fh_shr_cfg_lh_line *lines; int num_lines; int gap_list_max; int gap_timeout; struct fh_shr_cfg_tbl { char name[255]; unsigned char enabled; unsigned int size; } symbol_table; struct fh_shr_cfg_tbl order_table; void *context; } *process; char name[255]; struct fh_shr_cfg_lh_conn primary; struct fh_shr_cfg_lh_conn secondary; void *context; } *line; unsigned char enabled; unsigned short port; unsigned int address; char login_name[6]; char login_passwd[10]; char interface[255]; void *context; } *config; char tag[10]; unsigned long timestamp; unsigned long last_recv; struct fh_info_stats { unsigned long packets; unsigned long messages; unsigned long bytes; unsigned long packet_errors; unsigned long message_errors; unsigned long duplicate_packets; unsigned long gaps; unsigned long lost_messages; unsigned long recovered_messages; } stats; void *context; } primary; struct fh_shr_lh_conn secondary; struct fh_shr_lh_conn request; struct fh_shr_cfg_lh_line *config; unsigned long next_seq_no; unsigned long timestamp; struct fh_info_stats stats; void *context; } *lines; int num_lines; struct fh_shr_cfg_lh_proc *config; struct fh_info_stats stats; struct fh_shr_lkp_tbl { struct fh_mpool_t { char *mp_name; struct _mp_mblock { struct _mp_mblock *mb_next; } *mp_mblocks; struct _mp_mchunk { struct _mp_mchunk *mc_next; } *mp_mchunks; unsigned int mp_chunksize; unsigned int mp_nchunks; unsigned int mp_nblocks; unsigned int mp_flags; unsigned int mp_free; unsigned int mp_inuse; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mp_lock; } *mempool; struct fh_ht_t { struct fh_mpool_t *ht_mpool; struct he_head_t { struct _fh_ht_elt { struct he_entry_t { struct _fh_ht_elt *tqe_next; struct _fh_ht_elt **tqe_prev; } he_next; struct he_head_t *he_chead; void *he_value; void *he_key; int he_klen; unsigned int he_hashval; } *tqh_first; struct _fh_ht_elt **tqh_last; } *ht_table; unsigned int ht_size; unsigned int ht_count; unsigned int ht_mask; unsigned int ht_flags; struct fh_ht_kops_t { unsigned int (*kops_khash)(void *key, int klen); char *(*kops_kdump)(void *key, int klen); int (*kops_kcmp)(void *key_a, void *key_b, int klen); } ht_kops; } *hash; unsigned int size; unsigned int count; } symbol_table; struct fh_shr_lkp_tbl order_table; void *context; } *); int (*parser)(unsigned char *, int, struct fh_shr_lh_conn *); }

user_defined_types: struct fh_shr_mmcast_cb_t { int (*init)(struct fh_shr_lh_proc *); int (*parser)(unsigned char *, int, struct fh_shr_lh_conn *); }

user_defined_types: struct fh_shr_lh_line { struct fh_shr_lh_proc *process; struct fh_shr_lh_conn primary; struct fh_shr_lh_conn secondary; struct fh_shr_lh_conn request; struct fh_shr_cfg_lh_line *config; unsigned long next_seq_no; unsigned long timestamp; struct fh_info_stats stats; void *context; }

user_defined_types: struct fh_shr_lh_conn { struct fh_shr_lh_line *line; int socket; struct fh_shr_cfg_lh_conn *config; char tag[10]; unsigned long timestamp; unsigned long last_recv; struct fh_info_stats stats; void *context; }


repo: cskau/VM

decompiled_code:
__int64 __fastcall lua_travsymbol(unsigned int (__fastcall *a1)(__int64))
{
unsigned __int16 v1; // bp

if ( !lua_ntable )
return 0LL;
v1 = 0;
while ( !a1(lua_table + 24LL * v1) )
{
if ( (unsigned __int16)lua_ntable <= ++v1 )
return 0LL;
}
return *(_QWORD *)(lua_table + 24LL * v1 + 16) + 20LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int (__fastcall *a1)(__int64))
{
unsigned __int16 v1; // bp

if ( !lua_ntable )
return 0LL;
v1 = 0;
while ( !a1(lua_table + 24LL * v1) )
{
if ( (unsigned __int16)lua_ntable <= ++v1 )
return 0LL;
}
return *(_QWORD *)(lua_table + 24LL * v1 + 16) + 20LL;
}

original_code:
static char *lua_travsymbol (int (*fn)(Object *))
{
 lua_Word i;
 for (i=0; i<lua_ntable; i++)
  if (fn(&(lua_table[i].object)))
    return lua_table[i].varname->str;
 return ((void *)0);
}

canonical_original_code:
static char *lua_travsymbol(int (*fn)(struct Object *))
{
 unsigned short i;
 for (i=0; i<lua_ntable; i++)
  if (fn(&(lua_table[i].object)))
    return lua_table[i].varname->str;
 return ((void *)0);
}

variable_types: int (*)(struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash { struct Hash *next; struct node { struct Object ref; struct Object val; } *node; int nhash; int nuse; char mark; } *a; void *u; int i; } value; } *)

variable_types:
i
unsigned short

user_defined_types: struct Object { enum lua_Type tag; union Value value; }

user_defined_types: union Value { void (*f)(); float n; struct TaggedString *ts; struct TFunc *tf; struct Hash *a; void *u; int i; }

user_defined_types: struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar *locvars; }

user_defined_types: struct Hash { struct Hash *next; struct node *node; int nhash; int nuse; char mark; }


checkfunc

decompiled_code:
_BOOL8 __fastcall checkfunc(__int64 a1)
{
_BOOL4 v1; // edx

if ( *(_DWORD *)a1 == -5 )
{
v1 = 0;
if ( (*(_DWORD *)functofind & 0xFFFFFFFD) == -7 )
v1 = *(_QWORD *)(functofind + 8) == *(_QWORD *)(a1 + 8);
}
else
{
v1 = 0;
if ( *(_DWORD *)a1 == -6 && (*(_DWORD *)functofind & 0xFFFFFFFD) == -8 )
v1 = *(_QWORD *)(functofind + 8) == *(_QWORD *)(a1 + 8);
}
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
_BOOL4 v1; // edx

if ( *(_DWORD *)a1 == -5 )
{
v1 = 0;
if ( (*(_DWORD *)functofind & 0xFFFFFFFD) == -7 )
v1 = *(_QWORD *)(functofind + 8) == *(_QWORD *)(a1 + 8);
}
else
{
v1 = 0;
if ( *(_DWORD *)a1 == -6 && (*(_DWORD *)functofind & 0xFFFFFFFD) == -8 )
v1 = *(_QWORD *)(functofind + 8) == *(_QWORD *)(a1 + 8);
}
return v1;
}

original_code:
static int checkfunc (Object *o)
{
  if (o->tag == LUA_T_FUNCTION)
    return
       ((functofind->tag == LUA_T_FUNCTION || functofind->tag == LUA_T_MARK)
            && (functofind->value.tf == o->value.tf));
  if (o->tag == LUA_T_CFUNCTION)
    return
       ((functofind->tag == LUA_T_CFUNCTION || functofind->tag == LUA_T_CMARK)
            && (functofind->value.f == o->value.f));
  return 0;
}

canonical_original_code:
static int checkfunc(struct Object *o)
{
  if (o->tag == LUA_T_FUNCTION)
    return
       ((functofind->tag == LUA_T_FUNCTION || functofind->tag == LUA_T_MARK)
            && (functofind->value.tf == o->value.tf));
  if (o->tag == LUA_T_CFUNCTION)
    return
       ((functofind->tag == LUA_T_CFUNCTION || functofind->tag == LUA_T_CMARK)
            && (functofind->value.f == o->value.f));
  return 0;
}

variable_types: struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash { struct Hash *next; struct node { struct Object ref; struct Object val; } *node; int nhash; int nuse; char mark; } *a; void *u; int i; } value; } *


original_code:
int lua_markobject (Object *o)
{
 if (((o)->tag) == LUA_T_STRING && !((o)->value.ts)->marked)
   ((o)->value.ts)->marked = 1;
 else if (((o)->tag) == LUA_T_ARRAY)
   lua_hashmark (((o)->value.a));
 else if ((o->tag == LUA_T_FUNCTION || o->tag == LUA_T_MARK)
           && !o->value.tf->marked)
   o->value.tf->marked = 1;
 return 0;
}

canonical_original_code:
int lua_markobject(struct Object *o)
{
 if (((o)->tag) == LUA_T_STRING && !((o)->value.ts)->marked)
   ((o)->value.ts)->marked = 1;
 else if (((o)->tag) == LUA_T_ARRAY)
   lua_hashmark (((o)->value.a));
 else if ((o->tag == LUA_T_FUNCTION || o->tag == LUA_T_MARK)
           && !o->value.tf->marked)
   o->value.tf->marked = 1;
 return 0;
}

user_defined_types: enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 }

user_defined_types: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; }

user_defined_types: struct LocVar { struct TaggedString *varname; int line; }

user_defined_types: struct node { struct Object ref; struct Object val; }


decompiled_code:
__int64 __fastcall luaI_findsymbol(unsigned __int16 *a1)
{
unsigned __int16 v2; // ax
__int64 v3; // rax

if ( *a1 == 0xFFFE )
{
if ( (unsigned __int16)lua_ntable == lua_maxsymbol )
lua_maxsymbol = (int)luaI_growvector(&lua_table, lua_maxsymbol, 24LL, "symbol table overflow", 65533LL);
v2 = lua_ntable;
*a1 = lua_ntable;
v3 = lua_table + 24LL * v2;
*(_QWORD *)(v3 + 16) = a1;
*(_DWORD *)v3 = -1;
++lua_ntable;
}
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int16 *a1)
{
unsigned __int16 v2; // ax
__int64 v3; // rax

if ( *a1 == 0xFFFE )
{
if ( (unsigned __int16)lua_ntable == lua_maxsymbol )
lua_maxsymbol = (int)luaI_growvector(&lua_table, lua_maxsymbol, 24LL, "symbol table overflow", 65533LL);
v2 = lua_ntable;
*a1 = lua_ntable;
v3 = lua_table + 24LL * v2;
*(_QWORD *)(v3 + 16) = a1;
*(_DWORD *)v3 = -1;
++lua_ntable;
}
return *a1;
}

original_code:
lua_Word luaI_findsymbol (TaggedString *t)
{
 if (t->varindex == 0xFFFE)
 {
  if (lua_ntable == lua_maxsymbol)
    lua_maxsymbol = (luaI_growvector((void**)&lua_table,lua_maxsymbol,sizeof(Symbol),"symbol table overflow",((0x7fff * 2 + 1)-2)));
  t->varindex = lua_ntable;
  lua_table[lua_ntable].varname = t;
  (((&(lua_table[lua_ntable].object))->tag)) = LUA_T_NIL;
  lua_ntable++;
 }
 return t->varindex;
}

canonical_original_code:
unsigned short luaI_findsymbol(struct TaggedString *t)
{
 if (t->varindex == 0xFFFE)
 {
  if (lua_ntable == lua_maxsymbol)
    lua_maxsymbol = (luaI_growvector((void **)&lua_table,lua_maxsymbol,sizeof(Symbol),"symbol table overflow",((0x7fff * 2 + 1)-2)));
  t->varindex = lua_ntable;
  lua_table[lua_ntable].varname = t;
  (((&(lua_table[lua_ntable].object))->tag)) = LUA_T_NIL;
  lua_ntable++;
 }
 return t->varindex;
}

variable_types: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *

return_type: unsigned short


decompiled_code:
__int64 __fastcall luaI_findconstant(__int64 a1)
{
unsigned __int16 v2; // ax

if ( *(_WORD *)(a1 + 2) == 0xFFFE )
{
if ( (unsigned __int16)lua_nconstant == lua_maxconstant )
lua_maxconstant = (int)luaI_growvector(&lua_constant, lua_maxconstant, 8LL, "constant table overflow", 65533LL);
v2 = lua_nconstant;
*(_WORD *)(a1 + 2) = lua_nconstant;
*(_QWORD *)(lua_constant + 8LL * v2) = a1;
++lua_nconstant;
}
return *(unsigned __int16 *)(a1 + 2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned __int16 v2; // ax

if ( *(_WORD *)(a1 + 2) == 0xFFFE )
{
if ( (unsigned __int16)lua_nconstant == lua_maxconstant )
lua_maxconstant = (int)luaI_growvector(&lua_constant, lua_maxconstant, 8LL, "constant table overflow", 65533LL);
v2 = lua_nconstant;
*(_WORD *)(a1 + 2) = lua_nconstant;
*(_QWORD *)(lua_constant + 8LL * v2) = a1;
++lua_nconstant;
}
return *(unsigned __int16 *)(a1 + 2);
}

original_code:
lua_Word luaI_findconstant (TaggedString *t)
{
 if (t->constindex == 0xFFFE)
 {
  if (lua_nconstant == lua_maxconstant)
    lua_maxconstant = (luaI_growvector((void**)&lua_constant,lua_maxconstant,sizeof(TaggedString *),"constant table overflow",((0x7fff * 2 + 1)-2)));
  t->constindex = lua_nconstant;
  lua_constant[lua_nconstant] = t;
  lua_nconstant++;
 }
 return t->constindex;
}

canonical_original_code:
unsigned short luaI_findconstant(struct TaggedString *t)
{
 if (t->constindex == 0xFFFE)
 {
  if (lua_nconstant == lua_maxconstant)
    lua_maxconstant = (luaI_growvector((void **)&lua_constant,lua_maxconstant,sizeof(struct TaggedString *),"constant table overflow",((0x7fff * 2 + 1)-2)));
  t->constindex = lua_nconstant;
  lua_constant[lua_nconstant] = t;
  lua_nconstant++;
 }
 return t->constindex;
}


decompiled_code:
__int64 luaI_createfixedstring()
{
__int64 result; // rax

result = lua_createstring();
if ( !*(_DWORD *)(result + 16) )
*(_DWORD *)(result + 16) = 2;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax

result = lua_createstring();
if ( !*(_DWORD *)(result + 16) )
*(_DWORD *)(result + 16) = 2;
return result;
}

original_code:
TaggedString *luaI_createfixedstring (char *name)
{
  TaggedString *ts = lua_createstring(name);
  if (!ts->marked)
    ts->marked = 2;
  return ts;
}

canonical_original_code:
struct TaggedString *luaI_createfixedstring(char *name)
{
  struct TaggedString *ts = lua_createstring(name);
  if (!ts->marked)
    ts->marked = 2;
  return ts;
}

variable_types:
name
char *

return_type: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *


decompiled_code:
__int64 luaI_findsymbolbyname()
{
unsigned __int16 *v0; // rax

v0 = (unsigned __int16 *)luaI_createfixedstring();
return luaI_findsymbol(v0);
}

canonical_decompiled_code:
__int64 func6()
{
unsigned __int16 *v0; // rax

v0 = (unsigned __int16 *)func5();
return func3(v0);
}

original_code:
lua_Word luaI_findsymbolbyname (char *name)
{
  return luaI_findsymbol(luaI_createfixedstring(name));
}

canonical_original_code:
unsigned short luaI_findsymbolbyname(char *name)
{
  return luaI_findsymbol(luaI_createfixedstring(name));
}


decompiled_code:
__int64 luaI_initsymbol()
{
char **v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rbx
__int64 result; // rax

lua_maxsymbol = 256LL;
lua_table = luaI_realloc(0LL, 6144LL);
v0 = &int_funcs;
do
{
v1 = 3LL * (unsigned __int16)luaI_findsymbolbyname(*v0);
*(_DWORD *)(lua_table + 8 * v1) = -6;
*(_QWORD *)(lua_table + 8 * v1 + 8) = v0[1];
v0 += 2;
}
while ( v0 != (char **)&unk_7E0 );
v2 = 24LL * (unsigned __int16)luaI_findsymbolbyname("_VERSION_");
*(_DWORD *)(lua_table + v2) = -3;
v3 = lua_table + v2;
result = lua_createstring("Lua 2.5.1");
*(_QWORD *)(v3 + 8) = result;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
char **v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rbx
__int64 result; // rax

lua_maxsymbol = 256LL;
lua_table = luaI_realloc(0LL, 6144LL);
v0 = &int_funcs;
do
{
v1 = 3LL * (unsigned __int16)func6(*v0);
*(_DWORD *)(lua_table + 8 * v1) = -6;
*(_QWORD *)(lua_table + 8 * v1 + 8) = v0[1];
v0 += 2;
}
while ( v0 != (char **)&unk_7E0 );
v2 = 24LL * (unsigned __int16)func6("_VERSION_");
*(_DWORD *)(lua_table + v2) = -3;
v3 = lua_table + v2;
result = lua_createstring("Lua 2.5.1");
*(_QWORD *)(v3 + 8) = result;
return result;
}

original_code:
void luaI_initsymbol (void)
{
  int i;
  lua_Word n;
  lua_maxsymbol = 256;
  lua_table = ((Symbol *)luaI_realloc(((void *)0), ((lua_maxsymbol)*sizeof(Symbol))));
  for (i=0; i<(sizeof(int_funcs)/sizeof(int_funcs[0])); i++)
  {
    n = luaI_findsymbolbyname(int_funcs[i].name);
    (((&(lua_table[n].object))->tag)) = LUA_T_CFUNCTION; (((&(lua_table[n].object))->value.f)) = int_funcs[i].func;
  }
  n = luaI_findsymbolbyname("_VERSION_");
  (((&(lua_table[n].object))->tag)) = LUA_T_STRING; (((&(lua_table[n].object))->value.ts)) = lua_createstring("Lua 2.5.1");
}

canonical_original_code:
void luaI_initsymbol()
{
  int i;
  unsigned short n;
  lua_maxsymbol = 256;
  lua_table = ((struct Symbol *)luaI_realloc(((void *)0), ((lua_maxsymbol)*sizeof(Symbol))));
  for (i=0; i<(sizeof(int_funcs)/sizeof(int_funcs[0])); i++)
  {
    n = luaI_findsymbolbyname(int_funcs[i].name);
    (((&(lua_table[n].object))->tag)) = LUA_T_CFUNCTION; (((&(lua_table[n].object))->value.f)) = int_funcs[i].func;
  }
  n = luaI_findsymbolbyname("_VERSION_");
  (((&(lua_table[n].object))->tag)) = LUA_T_STRING; (((&(lua_table[n].object))->value.ts)) = lua_createstring("Lua 2.5.1");
}

variable_types: i int

variable_types:
n
unsigned short

user_defined_types: struct Symbol { struct Object object; struct TaggedString *varname; }