decompiled_code:
__int64 __fastcall fh_shr_mgmt_cmd_status(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
int *v4; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
char v11[20]; // [rsp+0h] [rbp-58h] BYREF
int v12; // [rsp+14h] [rbp-44h]
int v13; // [rsp+18h] [rbp-40h]
int v14; // [rsp+1Ch] [rbp-3Ch]
int v15; // [rsp+20h] [rbp-38h]
int v16; // [rsp+24h] [rbp-34h]
int v17; // [rsp+28h] [rbp-30h]
int v18; // [rsp+2Ch] [rbp-2Ch]
char src[40]; // [rsp+30h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 9 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_shr_mgmt.c", 197LL);
fh_log("fh_shr_mgmt.c", 197LL, 0LL, "ERR", v6);
exit(1);
}
if ( a3 != 16 )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_shr_mgmt.c", 198LL);
fh_log("fh_shr_mgmt.c", 198LL, 0LL, "ERR", v7);
exit(1);
}
v3 = fh_adm_parse(9LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v8 = fh_log_fmt("received request for status from the manager service");
fh_log("fh_shr_mgmt.c", 207LL, "MGMT", "DIAG", v8);
}
strcpy(v11, src);
v4 = (int *)(*(&xmmword_C60 + 1))();
v12 = *v4;
v13 = v4[1];
v14 = v4[2];
v15 = v4[3];
v16 = 0;
v17 = 0;
v18 = 0;
v3 = fh_adm_send((unsigned int)conn_context, 10LL, *(unsigned int *)(a1 + 8), v11, 48LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v9 = fh_log_fmt("failed to send status response");
fh_log("fh_shr_mgmt.c", 226LL, "MGMT", "ERR", v9);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v10 = fh_log_fmt("sent status response");
fh_log("fh_shr_mgmt.c", 231LL, "MGMT", "DIAG", v10);
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
int *v4; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
char v11[20]; // [rsp+0h] [rbp-58h] BYREF
int v12; // [rsp+14h] [rbp-44h]
int v13; // [rsp+18h] [rbp-40h]
int v14; // [rsp+1Ch] [rbp-3Ch]
int v15; // [rsp+20h] [rbp-38h]
int v16; // [rsp+24h] [rbp-34h]
int v17; // [rsp+28h] [rbp-30h]
int v18; // [rsp+2Ch] [rbp-2Ch]
char src[40]; // [rsp+30h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 9 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_shr_mgmt.c", 197LL);
fh_log("fh_shr_mgmt.c", 197LL, 0LL, "ERR", v6);
exit(1);
}
if ( a3 != 16 )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_shr_mgmt.c", 198LL);
fh_log("fh_shr_mgmt.c", 198LL, 0LL, "ERR", v7);
exit(1);
}
v3 = fh_adm_parse(9LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v8 = fh_log_fmt("received request for status from the manager service");
fh_log("fh_shr_mgmt.c", 207LL, "MGMT", "DIAG", v8);
}
strcpy(v11, src);
v4 = (int *)(*(&xmmword_C60 + 1))();
v12 = *v4;
v13 = v4[1];
v14 = v4[2];
v15 = v4[3];
v16 = 0;
v17 = 0;
v18 = 0;
v3 = fh_adm_send((unsigned int)conn_context, 10LL, *(unsigned int *)(a1 + 8), v11, 48LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v9 = fh_log_fmt("failed to send status response");
fh_log("fh_shr_mgmt.c", 226LL, "MGMT", "ERR", v9);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v10 = fh_log_fmt("sent status response");
fh_log("fh_shr_mgmt.c", 231LL, "MGMT", "DIAG", v10);
}
}
return v3;
}

original_code:
static FH_STATUS fh_shr_mgmt_cmd_status(fh_adm_cmd_t *cmd, char *cmd_buf, int cmd_len)
{
    fh_adm_status_req_t status_req;
    fh_adm_status_resp_t status_resp;
    fh_info_proc_t *info;
    FH_STATUS rc;
    do { int nok = !(cmd->cmd_type == (9)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_shr_mgmt.c", 197); fh_log("fh_shr_mgmt.c", 197, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(status_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_shr_mgmt.c", 198); fh_log("fh_shr_mgmt.c", 198, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, cmd_buf, &status_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("received request for status from the manager service"); fh_log("fh_shr_mgmt.c", 207, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(status_resp.status_service, status_req.status_service);
    info = callbacks.getstatus();
    status_resp.status_pid = info->pid;
    status_resp.status_fp_cpu = info->cpu;
    status_resp.status_fp_tid = info->tid;
    status_resp.status_uptime = info->start_time;
    status_resp.status_pmem = 0;
    status_resp.status_putime = 0;
    status_resp.status_pstime = 0;
    rc = fh_adm_send(conn_context.mcl_fd, (10), cmd->cmd_tid, &status_resp,
                     sizeof(status_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send status response"); fh_log("fh_shr_mgmt.c", 226, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent status response"); fh_log("fh_shr_mgmt.c", 231, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

canonical_original_code:
static int fh_shr_mgmt_cmd_status(struct fh_adm_cmd_t *cmd, char *cmd_buf, int cmd_len)
{
    struct fh_adm_status_req_t status_req;
    struct fh_adm_status_resp_t status_resp;
    struct fh_info_proc *info;
    int rc;
    do { int nok = !(cmd->cmd_type == (9)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_shr_mgmt.c", 197); fh_log("fh_shr_mgmt.c", 197, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(status_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_shr_mgmt.c", 198); fh_log("fh_shr_mgmt.c", 198, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, cmd_buf, &status_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("received request for status from the manager service"); fh_log("fh_shr_mgmt.c", 207, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(status_resp.status_service, status_req.status_service);
    info = callbacks.getstatus();
    status_resp.status_pid = info->pid;
    status_resp.status_fp_cpu = info->cpu;
    status_resp.status_fp_tid = info->tid;
    status_resp.status_uptime = info->start_time;
    status_resp.status_pmem = 0;
    status_resp.status_putime = 0;
    status_resp.status_pstime = 0;
    rc = fh_adm_send(conn_context.mcl_fd, (10), cmd->cmd_tid, &status_resp,
                     sizeof(status_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send status response"); fh_log("fh_shr_mgmt.c", 226, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent status response"); fh_log("fh_shr_mgmt.c", 231, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

variable_types: struct fh_adm_status_req_t { char status_service[16]; }

variable_types: struct fh_adm_status_resp_t { char status_service[16]; unsigned int status_state; unsigned int status_pid; unsigned int status_fp_cpu; unsigned int status_fp_tid; unsigned int status_uptime; unsigned int status_pmem; unsigned int status_putime; unsigned int status_pstime; }

variable_types: struct fh_info_proc { unsigned int pid; unsigned int cpu; unsigned int tid; unsigned int start_time; } *

user_defined_types: struct fh_adm_cmd_t { unsigned int cmd_magic; unsigned int cmd_type; unsigned int cmd_tid; unsigned int cmd_len; }


repo: csinitiative/fhce

decompiled_code:
__int64 __fastcall fh_shr_mgmt_cmd_version(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
char v10[20]; // [rsp+0h] [rbp-68h] BYREF
char dest[24]; // [rsp+14h] [rbp-54h] BYREF
char v12[20]; // [rsp+2Ch] [rbp-3Ch] BYREF
char src[40]; // [rsp+40h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 3 )
{
v5 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_shr_mgmt.c", 152LL);
fh_log("fh_shr_mgmt.c", 152LL, 0LL, "ERR", v5);
exit(1);
}
if ( a3 != 16 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_shr_mgmt.c", 153LL);
fh_log("fh_shr_mgmt.c", 153LL, 0LL, "ERR", v6);
exit(1);
}
v3 = fh_adm_parse(3LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v7 = fh_log_fmt("get Arca version request for: %s", src);
fh_log("fh_shr_mgmt.c", 162LL, "MGMT", "DIAG", v7);
}
strcpy(v10, src);
strcpy(dest, ::src);
strcpy(v12, qword_CC0);
v3 = fh_adm_send((unsigned int)conn_context, 4LL, *(unsigned int *)(a1 + 8), v10, 52LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = fh_log_fmt("failed to send 'get version' response for %s", src);
fh_log("fh_shr_mgmt.c", 171LL, "MGMT", "ERR", v8);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("sent 'get version' response for: %s", src);
fh_log("fh_shr_mgmt.c", 177LL, "MGMT", "DIAG", v9);
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
char v10[20]; // [rsp+0h] [rbp-68h] BYREF
char dest[24]; // [rsp+14h] [rbp-54h] BYREF
char v12[20]; // [rsp+2Ch] [rbp-3Ch] BYREF
char src[40]; // [rsp+40h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 3 )
{
v5 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_shr_mgmt.c", 152LL);
fh_log("fh_shr_mgmt.c", 152LL, 0LL, "ERR", v5);
exit(1);
}
if ( a3 != 16 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_shr_mgmt.c", 153LL);
fh_log("fh_shr_mgmt.c", 153LL, 0LL, "ERR", v6);
exit(1);
}
v3 = fh_adm_parse(3LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v7 = fh_log_fmt("get Arca version request for: %s", src);
fh_log("fh_shr_mgmt.c", 162LL, "MGMT", "DIAG", v7);
}
strcpy(v10, src);
strcpy(dest, ::src);
strcpy(v12, qword_CC0);
v3 = fh_adm_send((unsigned int)conn_context, 4LL, *(unsigned int *)(a1 + 8), v10, 52LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = fh_log_fmt("failed to send 'get version' response for %s", src);
fh_log("fh_shr_mgmt.c", 171LL, "MGMT", "ERR", v8);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("sent 'get version' response for: %s", src);
fh_log("fh_shr_mgmt.c", 177LL, "MGMT", "DIAG", v9);
}
}
return v3;
}

original_code:
static FH_STATUS fh_shr_mgmt_cmd_version(fh_adm_cmd_t *cmd, char *cmd_buf, int cmd_len)
{
    fh_adm_getver_req_t getver_req;
    fh_adm_getver_resp_t getver_resp;
    FH_STATUS rc;
    do { int nok = !(cmd->cmd_type == (3)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_shr_mgmt.c", 152); fh_log("fh_shr_mgmt.c", 152, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(getver_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_shr_mgmt.c", 153); fh_log("fh_shr_mgmt.c", 153, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, cmd_buf, &getver_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("get Arca version request for: %s", getver_req.getver_service); fh_log("fh_shr_mgmt.c", 162, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(getver_resp.getver_service, getver_req.getver_service);
    strcpy(getver_resp.getver_build_date, fh_info.build_date);
    strcpy(getver_resp.getver_build_rev, fh_info.build_svn_rev);
    rc = fh_adm_send(conn_context.mcl_fd, (4), cmd->cmd_tid, &getver_resp,
                     sizeof(getver_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send 'get version' response for %s", getver_req.getver_service); fh_log("fh_shr_mgmt.c", 171, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent 'get version' response for: %s", getver_req.getver_service); fh_log("fh_shr_mgmt.c", 177, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

canonical_original_code:
static int fh_shr_mgmt_cmd_version(struct fh_adm_cmd_t *cmd, char *cmd_buf, int cmd_len)
{
    struct fh_adm_getver_req_t getver_req;
    struct fh_adm_getver_resp_t getver_resp;
    int rc;
    do { int nok = !(cmd->cmd_type == (3)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_shr_mgmt.c", 152); fh_log("fh_shr_mgmt.c", 152, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(getver_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_shr_mgmt.c", 153); fh_log("fh_shr_mgmt.c", 153, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, cmd_buf, &getver_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("get Arca version request for: %s", getver_req.getver_service); fh_log("fh_shr_mgmt.c", 162, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(getver_resp.getver_service, getver_req.getver_service);
    strcpy(getver_resp.getver_build_date, fh_info.build_date);
    strcpy(getver_resp.getver_build_rev, fh_info.build_svn_rev);
    rc = fh_adm_send(conn_context.mcl_fd, (4), cmd->cmd_tid, &getver_resp,
                     sizeof(getver_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send 'get version' response for %s", getver_req.getver_service); fh_log("fh_shr_mgmt.c", 171, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent 'get version' response for: %s", getver_req.getver_service); fh_log("fh_shr_mgmt.c", 177, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

variable_types: struct fh_adm_cmd_t { unsigned int cmd_magic; unsigned int cmd_type; unsigned int cmd_tid; unsigned int cmd_len; } *

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

variable_types: struct fh_adm_getver_resp_t { char getver_service[16]; unsigned int getver_state; char getver_build_date[24]; char getver_build_rev[8]; }

variable_types: rc int

variable_types: nok int

return_type: int


decompiled_code:
__int64 __fastcall fh_shr_mgmt_process(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax
__int64 v5; // rax

v3 = *(unsigned int *)(a1 + 4);
if ( (_DWORD)v3 == 9 )
return fh_shr_mgmt_cmd_status(a1, a1, a2);
if ( (unsigned int)v3 > 9 )
{
if ( (_DWORD)v3 == 11 )
return fh_shr_mgmt_cmd_action(a1, a1, a2);
}
else
{
if ( (_DWORD)v3 == 3 )
return fh_shr_mgmt_cmd_version(a1, a1, a2);
if ( (_DWORD)v3 == 7 )
return fh_shr_mgmt_cmd_stats(a1, a1, a2);
}
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v5 = fh_log_fmt("unexpected client command: %d", v3);
fh_log("fh_shr_mgmt.c", 266LL, "MGMT", "ERR", v5);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax
__int64 v5; // rax

v3 = *(unsigned int *)(a1 + 4);
if ( (_DWORD)v3 == 9 )
return func3(a1, a1, a2);
if ( (unsigned int)v3 > 9 )
{
if ( (_DWORD)v3 == 11 )
return func1(a1, a1, a2);
}
else
{
if ( (_DWORD)v3 == 3 )
return func4(a1, a1, a2);
if ( (_DWORD)v3 == 7 )
return func2(a1, a1, a2);
}
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v5 = fh_log_fmt("unexpected client command: %d", v3);
fh_log("fh_shr_mgmt.c", 266LL, "MGMT", "ERR", v5);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static FH_STATUS fh_shr_mgmt_process(char *cmd_buf, int cmd_len)
{
    fh_adm_cmd_t *cmd = (fh_adm_cmd_t *)cmd_buf;
    FH_STATUS rc = (0);
    switch (cmd->cmd_type) {
    case (7):
        rc = fh_shr_mgmt_cmd_stats(cmd, cmd_buf, cmd_len);
        break;
    case (9):
        rc = fh_shr_mgmt_cmd_status(cmd, cmd_buf, cmd_len);
        break;
    case (3):
        rc = fh_shr_mgmt_cmd_version(cmd, cmd_buf, cmd_len);
        break;
    case (11):
        rc = fh_shr_mgmt_cmd_action(cmd, cmd_buf, cmd_len);
        break;
    default:
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unexpected client command: %d", cmd->cmd_type); fh_log("fh_shr_mgmt.c", 266, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    return rc;
}

canonical_original_code:
static int fh_shr_mgmt_process(char *cmd_buf, int cmd_len)
{
    struct fh_adm_cmd_t *cmd = (fh_adm_cmd_t *)cmd_buf;
    int rc = (0);
    switch (cmd->cmd_type) {
    case (7):
        rc = fh_shr_mgmt_cmd_stats(cmd, cmd_buf, cmd_len);
        break;
    case (9):
        rc = fh_shr_mgmt_cmd_status(cmd, cmd_buf, cmd_len);
        break;
    case (3):
        rc = fh_shr_mgmt_cmd_version(cmd, cmd_buf, cmd_len);
        break;
    case (11):
        rc = fh_shr_mgmt_cmd_action(cmd, cmd_buf, cmd_len);
        break;
    default:
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unexpected client command: %d", cmd->cmd_type); fh_log("fh_shr_mgmt.c", 266, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    return rc;
}


decompiled_code:
__int64 __fastcall fh_shr_mgmt_start(int a1, const __m128i *a2, const char *a3, const __m128i *a4)
{
__int64 result; // rax
unsigned int v7; // ebx
char *v8; // rax
__int64 v9; // rax

fh_time_get(&uptime);
fh_info = (__int128)_mm_loadu_si128(a2);
xmmword_C90 = (__int128)_mm_loadu_si128(a2 + 1);
xmmword_CA0 = (__int128)_mm_loadu_si128(a2 + 2);
*(__m128i *)&src = _mm_loadu_si128(a2 + 3);
qword_CC0 = (char *)a2[4].m128i_i64[0];
*(__m128i *)&callbacks = _mm_loadu_si128(a4);
*(__m128i *)&xmmword_C50 = _mm_loadu_si128(a4 + 1);
*(__m128i *)&xmmword_C60 = _mm_loadu_si128(a4 + 2);
strcpy(proc_name, a3);
if ( a1 )
conn_context = -1;
if ( pthread_create(&mgmt_thread, 0LL, fh_shr_mgmt_run, 0LL) >= 0 )
return 0LL;
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v7 = *_errno_location();
v8 = strerror(v7);
v9 = fh_log_fmt("failed to start %s management thread (%s): %s (%d)", (const char *)fh_info, proc_name, v8, v7);
fh_log("fh_shr_mgmt.c", 369LL, "MGMT", "ERR", v9);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, const __m128i *a2, const char *a3, const __m128i *a4)
{
__int64 result; // rax
unsigned int v7; // ebx
char *v8; // rax
__int64 v9; // rax

fh_time_get(&uptime);
fh_info = (__int128)_mm_loadu_si128(a2);
xmmword_C90 = (__int128)_mm_loadu_si128(a2 + 1);
xmmword_CA0 = (__int128)_mm_loadu_si128(a2 + 2);
*(__m128i *)&src = _mm_loadu_si128(a2 + 3);
qword_CC0 = (char *)a2[4].m128i_i64[0];
*(__m128i *)&callbacks = _mm_loadu_si128(a4);
*(__m128i *)&xmmword_C50 = _mm_loadu_si128(a4 + 1);
*(__m128i *)&xmmword_C60 = _mm_loadu_si128(a4 + 2);
strcpy(proc_name, a3);
if ( a1 )
conn_context = -1;
if ( pthread_create(&mgmt_thread, 0LL, fh_shr_mgmt_run, 0LL) >= 0 )
return 0LL;
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v7 = *_errno_location();
v8 = strerror(v7);
v9 = fh_log_fmt("failed to start %s management thread (%s): %s (%d)", (const char *)fh_info, proc_name, v8, v7);
fh_log("fh_shr_mgmt.c", 369LL, "MGMT", "ERR", v9);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
FH_STATUS fh_shr_mgmt_start(int standalone, const fh_info_build_t *info, const char *proc,
                            fh_shr_mgmt_cb_t *cb)
{
    fh_time_get(&uptime);
    memcpy(&fh_info, info, sizeof(fh_info_build_t));
    memcpy(&callbacks, cb, sizeof(fh_shr_mgmt_cb_t));
    strcpy(proc_name, proc);
    if (standalone) {
        conn_context.mcl_fd = -1;
    }
    if (pthread_create(&mgmt_thread, ((void *)0), fh_shr_mgmt_run, ((void *)0)) < 0) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to start %s management thread (%s): %s (%d)", fh_info.name, proc_name, strerror((*__errno_location ())), (*__errno_location ())); fh_log("fh_shr_mgmt.c", 369, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    return (0);
}

canonical_original_code:
int fh_shr_mgmt_start(int standalone, struct fh_info_build *info, char *proc, struct fh_shr_mgmt_cb_t *cb)
{
    fh_time_get(&uptime);
    memcpy(&fh_info, info, sizeof(fh_info_build_t));
    memcpy(&callbacks, cb, sizeof(fh_shr_mgmt_cb_t));
    strcpy(proc_name, proc);
    if (standalone) {
        conn_context.mcl_fd = -1;
    }
    if (pthread_create(&mgmt_thread, ((void *)0), fh_shr_mgmt_run, ((void *)0)) < 0) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to start %s management thread (%s): %s (%d)", fh_info.name, proc_name, strerror((*__errno_location ())), (*__errno_location ())); fh_log("fh_shr_mgmt.c", 369, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    return (0);
}

variable_types: standalone int

variable_types: struct fh_info_build { char *name; int version; char *build_user; char *build_host; char *build_arch; char *build_kernel; char *build_date; char *build_svn_url; char *build_svn_rev; } *

variable_types:
proc
char *

variable_types: struct fh_shr_mgmt_cb_t { void (*exit)(); void (*getstats)(struct fh_adm_stats_resp_t { char stats_service[16]; unsigned int stats_state; unsigned int stats_line_cnt; struct fh_adm_line_stats_t { char line_name[32]; unsigned long line_pkt_rx; unsigned long line_pkt_dups; unsigned long line_pkt_errs; unsigned long line_pkt_late; unsigned long line_pkt_until_reset; unsigned long line_pkt_bad_times; unsigned long line_pkt_seq_jump; unsigned long line_pkt_wrap_noreset; unsigned long line_msg_rx; unsigned long line_msg_loss; unsigned long line_msg_recovered; unsigned long line_msg_late; unsigned long line_bytes; } stats_lines[-1]; } *); void (*clrstats)(); void (*snapstats)(); void (*snaplatency)(); struct fh_info_proc { unsigned int pid; unsigned int cpu; unsigned int tid; unsigned int start_time; } *(*getstatus)(); } *

user_defined_types: struct fh_shr_mgmt_cb_t { void (*exit)(); void (*getstats)(struct fh_adm_stats_resp_t *); void (*clrstats)(); void (*snapstats)(); void (*snaplatency)(); struct fh_info_proc *(*getstatus)(); }

user_defined_types: struct fh_adm_stats_resp_t { char stats_service[16]; unsigned int stats_state; unsigned int stats_line_cnt; struct fh_adm_line_stats_t stats_lines[-1]; }


decompiled_code:
void fh_shr_mgmt_wait()
{
__int64 v0; // rax

if ( mgmt_thread )
{
pthread_join(mgmt_thread, 0LL);
if ( (fh_log_lvl[12] & 8) != 0 )
{
v0 = fh_log_fmt("%s management thread (%s) exited", (const char *)fh_info, proc_name);
fh_log("fh_shr_mgmt.c", 385LL, "MGMT", "VSTATE", v0);
}
}
}

canonical_decompiled_code:
void func7()
{
__int64 v0; // rax

if ( mgmt_thread )
{
pthread_join(mgmt_thread, 0LL);
if ( (fh_log_lvl[12] & 8) != 0 )
{
v0 = fh_log_fmt("%s management thread (%s) exited", (const char *)fh_info, proc_name);
fh_log("fh_shr_mgmt.c", 385LL, "MGMT", "VSTATE", v0);
}
}
}

original_code:
void fh_shr_mgmt_wait()
{
    if (mgmt_thread) {
        pthread_join(mgmt_thread, ((void *)0));
        do { if ((fh_log_lvl[(3)] & ((0x00000008)))) { char *_msg = fh_log_fmt ("%s management thread (%s) exited", fh_info.name, proc_name); fh_log("fh_shr_mgmt.c", 385, "MGMT", "VSTATE", _msg); } } while (0);
    }
}

return_type: void


decompiled_code:
void fh_shr_mgmt_exit()
{
finished = 1;
}

canonical_decompiled_code:
void func8()
{
finished = 1;
}


decompiled_code:
int __fastcall fh_shr_lkp_ord_dump(__int64 a1)
{
printf("order_no : %lu\n", *(_QWORD *)(a1 + 32));
printf("price : %lu\n", *(_QWORD *)(a1 + 64));
printf("shares : %u\n", *(unsigned int *)(a1 + 72));
printf("buy_sell : %c\n", (unsigned int)*(char *)(a1 + 76));
return printf("stock : %s\n", (const char *)(a1 + 77));
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
printf("order_no : %lu\n", *(_QWORD *)(a1 + 32));
printf("price : %lu\n", *(_QWORD *)(a1 + 64));
printf("shares : %u\n", *(unsigned int *)(a1 + 72));
printf("buy_sell : %c\n", (unsigned int)*(char *)(a1 + 76));
return printf("stock : %s\n", (const char *)(a1 + 77));
}

original_code:
void fh_shr_lkp_ord_dump(fh_shr_lkp_ord_t *entry)
{
    printf("order_no : %lu\n", entry->order_no);
    printf("price    : %lu\n", entry->price);
    printf("shares   : %u\n", entry->shares);
    printf("buy_sell : %c\n", entry->buy_sell_ind);
    printf("stock    : %s\n", entry->stock);
}

canonical_original_code:
void fh_shr_lkp_ord_dump(struct fh_shr_lkp_ord *entry)
{
    printf("order_no : %lu\n", entry->order_no);
    printf("price    : %lu\n", entry->price);
    printf("shares   : %u\n", entry->shares);
    printf("buy_sell : %c\n", entry->buy_sell_ind);
    printf("stock    : %s\n", entry->stock);
}

variable_types: struct fh_shr_lkp_ord { struct fh_shr_lkp_ord_key { unsigned long order_no; char order_no_str[20]; } key; unsigned long order_no; char order_no_str[20]; unsigned long price; unsigned int shares; char buy_sell_ind; char stock[6]; struct fh_shr_lkp_sym { struct fh_shr_lkp_sym_key { char symbol[20]; } key; char symbol[20]; void *context; } *sym_entry; void *context; } *

user_defined_types: struct fh_shr_lkp_ord { struct fh_shr_lkp_ord_key key; unsigned long order_no; char order_no_str[20]; unsigned long price; unsigned int shares; char buy_sell_ind; char stock[6]; struct fh_shr_lkp_sym *sym_entry; void *context; }

user_defined_types: struct fh_shr_lkp_sym { struct fh_shr_lkp_sym_key key; char symbol[20]; void *context; }


decompiled_code:
__int64 __fastcall fh_shr_lkp_ord_init(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

*(_QWORD *)a2 = 0LL;
*(_QWORD *)(a2 + 8) = 0LL;
*(_QWORD *)(a2 + 16) = 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 255) )
{
v3 = fh_mpool_new("OrderTable", 104LL, *(unsigned int *)(a1 + 256), 0LL);
*(_QWORD *)a2 = v3;
if ( v3 )
{
v4 = fh_ht_new(*(unsigned int *)(a1 + 256), 0LL, key_operations_1);
*(_QWORD *)(a2 + 8) = v4;
if ( v4 )
{
if ( (fh_log_lvl[8] & 4) != 0 )
{
v7 = fh_log_fmt("Order table initialized: size:%d key size:%d", *(unsigned int *)(a1 + 256), 32LL);
fh_log("fh_shr_lkp_order.c", 90LL, "LH", "STATE", v7);
}
*(_DWORD *)(a2 + 16) = *(_DWORD *)(a1 + 256);
*(_DWORD *)(a2 + 20) = 0;
result = 0LL;
}
else
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v6 = fh_log_fmt("Failed to initialize the order hash table");
fh_log("fh_shr_lkp_order.c", 85LL, "LH", "ERR", v6);
}
fh_mpool_free(*(_QWORD *)a2);
result = 0xFFFFFFFFLL;
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[8] & 1) != 0 )
{
v5 = fh_log_fmt("failed to initialize the order table memory pool");
fh_log("fh_shr_lkp_order.c", 78LL, "LH", "ERR", v5);
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

*(_QWORD *)a2 = 0LL;
*(_QWORD *)(a2 + 8) = 0LL;
*(_QWORD *)(a2 + 16) = 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 255) )
{
v3 = fh_mpool_new("OrderTable", 104LL, *(unsigned int *)(a1 + 256), 0LL);
*(_QWORD *)a2 = v3;
if ( v3 )
{
v4 = fh_ht_new(*(unsigned int *)(a1 + 256), 0LL, key_operations_1);
*(_QWORD *)(a2 + 8) = v4;
if ( v4 )
{
if ( (fh_log_lvl[8] & 4) != 0 )
{
v7 = fh_log_fmt("Order table initialized: size:%d key size:%d", *(unsigned int *)(a1 + 256), 32LL);
fh_log("fh_shr_lkp_order.c", 90LL, "LH", "STATE", v7);
}
*(_DWORD *)(a2 + 16) = *(_DWORD *)(a1 + 256);
*(_DWORD *)(a2 + 20) = 0;
result = 0LL;
}
else
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v6 = fh_log_fmt("Failed to initialize the order hash table");
fh_log("fh_shr_lkp_order.c", 85LL, "LH", "ERR", v6);
}
fh_mpool_free(*(_QWORD *)a2);
result = 0xFFFFFFFFLL;
}
}
else
{
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[8] & 1) != 0 )
{
v5 = fh_log_fmt("failed to initialize the order table memory pool");
fh_log("fh_shr_lkp_order.c", 78LL, "LH", "ERR", v5);
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
FH_STATUS fh_shr_lkp_ord_init(fh_shr_cfg_tbl_t *config, fh_shr_lkp_tbl_t *table)
{
    memset(table, 0, sizeof(fh_shr_lkp_tbl_t));
    if (config->enabled) {
        static fh_ht_kops_t key_operations = {
            .kops_khash = (fh_ht_khash_t *)key_hash,
            .kops_kcmp = (fh_ht_kcmp_t *)key_compare,
            .kops_kdump = (fh_ht_kdump_t *)key_dump,
        };
        table->mempool = fh_mpool_new("OrderTable", sizeof(fh_shr_lkp_ord_t), config->size, 0);
        if (!table->mempool) {
            do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to initialize the order table memory pool"); fh_log("fh_shr_lkp_order.c", 78, "LH", "ERR", _msg); } } while (0);
            return (-1);
        }
        table->hash = fh_ht_new(config->size, 0, &key_operations);
        if (!table->hash) {
            do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Failed to initialize the order hash table"); fh_log("fh_shr_lkp_order.c", 85, "LH", "ERR", _msg); } } while (0);
            fh_mpool_free(table->mempool);
            return (-1);
        }
        do { if ((fh_log_lvl[(2)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("Order table initialized: size:%d key size:%d", config->size, sizeof(fh_shr_lkp_ord_key_t)); fh_log("fh_shr_lkp_order.c", 90, "LH", "STATE", _msg); } } while (0);
        table->size = config->size;
        table->count = 0;
    }
    return (0);
}

canonical_original_code:
int fh_shr_lkp_ord_init(struct fh_shr_cfg_tbl *config, struct fh_shr_lkp_tbl *table)
{
    memset(table, 0, sizeof(fh_shr_lkp_tbl_t));
    if (config->enabled) {
        static struct fh_ht_kops_t key_operations = {
            .kops_khash = (fh_ht_khash_t *)key_hash,
            .kops_kcmp = (fh_ht_kcmp_t *)key_compare,
            .kops_kdump = (fh_ht_kdump_t *)key_dump,
        };
        table->mempool = fh_mpool_new("OrderTable", sizeof(fh_shr_lkp_ord_t), config->size, 0);
        if (!table->mempool) {
            do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to initialize the order table memory pool"); fh_log("fh_shr_lkp_order.c", 78, "LH", "ERR", _msg); } } while (0);
            return (-1);
        }
        table->hash = fh_ht_new(config->size, 0, &key_operations);
        if (!table->hash) {
            do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Failed to initialize the order hash table"); fh_log("fh_shr_lkp_order.c", 85, "LH", "ERR", _msg); } } while (0);
            fh_mpool_free(table->mempool);
            return (-1);
        }
        do { if ((fh_log_lvl[(2)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("Order table initialized: size:%d key size:%d", config->size, sizeof(fh_shr_lkp_ord_key_t)); fh_log("fh_shr_lkp_order.c", 90, "LH", "STATE", _msg); } } while (0);
        table->size = config->size;
        table->count = 0;
    }
    return (0);
}

variable_types: struct fh_shr_cfg_tbl { char name[255]; unsigned char enabled; unsigned int size; } *

variable_types: 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; } *

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_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_shr_lkp_ord_get(__int64 a1, __int64 a2, __int64 a3)
{
return fh_ht_get(*(_QWORD *)(a1 + 8), a2, 32LL, a3);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
return fh_ht_get(*(_QWORD *)(a1 + 8), a2, 32LL, a3);
}

original_code:
FH_STATUS fh_shr_lkp_ord_get(fh_shr_lkp_tbl_t *table, fh_shr_lkp_ord_key_t *key,
                             fh_shr_lkp_ord_t **entry)
{
    return fh_ht_get(table->hash, key, sizeof(fh_shr_lkp_ord_key_t), (void **)entry);
}

canonical_original_code:
int fh_shr_lkp_ord_get(struct fh_shr_lkp_tbl *table, struct fh_shr_lkp_ord_key *key, struct fh_shr_lkp_ord **entry)
{
    return fh_ht_get(table->hash, key, sizeof(fh_shr_lkp_ord_key_t), (void **)entry);
}

variable_types: struct fh_shr_lkp_ord_key { unsigned long order_no; char order_no_str[20]; } *

variable_types: struct fh_shr_lkp_ord { struct fh_shr_lkp_ord_key key; unsigned long order_no; char order_no_str[20]; unsigned long price; unsigned int shares; char buy_sell_ind; char stock[6]; struct fh_shr_lkp_sym { struct fh_shr_lkp_sym_key { char symbol[20]; } key; char symbol[20]; void *context; } *sym_entry; void *context; } **

user_defined_types: 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); }

user_defined_types: struct _mp_mblock { struct _mp_mblock *mb_next; }

user_defined_types: struct _mp_mchunk { struct _mp_mchunk *mc_next; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: struct he_entry_t { struct _fh_ht_elt *tqe_next; struct _fh_ht_elt **tqe_prev; }


original_code:
FH_STATUS fh_shr_lkp_ord_add(fh_shr_lkp_tbl_t *table, fh_shr_lkp_ord_t *entry,
                             fh_shr_lkp_ord_t **tblentry)
{
    fh_shr_lkp_ord_t *nentry;
    nentry = (fh_shr_lkp_ord_t *)fh_mpool_get(table->mempool);
    if (nentry == ((void *)0)) {
        do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to get a new order table entry"); fh_log("fh_shr_lkp_order.c", 122, "LH", "ERR", _msg); } } while (0);
        return (-1);
    }
    memcpy(nentry, entry, sizeof(fh_shr_lkp_ord_t));
    nentry->key.order_no = nentry->order_no;
    memcpy(&nentry->key.order_no_str[0], &nentry->order_no_str[0], 20);
    if (fh_ht_put(table->hash, &nentry->key, sizeof(fh_shr_lkp_ord_key_t), nentry) == (2)) {
        do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("duplicate order in order table: %ld", nentry->key.order_no); fh_log("fh_shr_lkp_order.c", 135, "LH", "ERR", _msg); } } while (0);
        fh_mpool_put(table->mempool, nentry);
        return (2);
    }
    table->count++;
    *tblentry = nentry;
    if ((10 * table->count) > (9 * table->size) && (table->count % 100) == 0) {
        do { if ((fh_log_lvl[(2)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("order table over 90%% full (count: %d)", table->count); fh_log("fh_shr_lkp_order.c", 146, "LH", "WARN", _msg); } } while (0);
    }
    return (0);
}

canonical_original_code:
int fh_shr_lkp_ord_add(struct fh_shr_lkp_tbl *table, struct fh_shr_lkp_ord *entry, struct fh_shr_lkp_ord **tblentry)
{
    struct fh_shr_lkp_ord *nentry;
    nentry = (struct fh_shr_lkp_ord *)fh_mpool_get(table->mempool);
    if (nentry == ((void *)0)) {
        do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to get a new order table entry"); fh_log("fh_shr_lkp_order.c", 122, "LH", "ERR", _msg); } } while (0);
        return (-1);
    }
    memcpy(nentry, entry, sizeof(fh_shr_lkp_ord_t));
    nentry->key.order_no = nentry->order_no;
    memcpy(&nentry->key.order_no_str[0], &nentry->order_no_str[0], 20);
    if (fh_ht_put(table->hash, &nentry->key, sizeof(fh_shr_lkp_ord_key_t), nentry) == (2)) {
        do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("duplicate order in order table: %ld", nentry->key.order_no); fh_log("fh_shr_lkp_order.c", 135, "LH", "ERR", _msg); } } while (0);
        fh_mpool_put(table->mempool, nentry);
        return (2);
    }
    table->count++;
    *tblentry = nentry;
    if ((10 * table->count) > (9 * table->size) && (table->count % 100) == 0) {
        do { if ((fh_log_lvl[(2)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("order table over 90%% full (count: %d)", table->count); fh_log("fh_shr_lkp_order.c", 146, "LH", "WARN", _msg); } } while (0);
    }
    return (0);
}

variable_types:
tblentry
struct fh_shr_lkp_ord **

user_defined_types: struct fh_shr_lkp_ord_key { unsigned long order_no; char order_no_str[20]; }

user_defined_types: struct fh_shr_lkp_sym_key { char symbol[20]; }


decompiled_code:
__int64 __fastcall fh_shr_lkp_ord_del(__int64 a1, __int64 a2, _QWORD *a3)
{
unsigned int v4; // ebx
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

v4 = fh_ht_delete(*(_QWORD *)(a1 + 8), a2, 32LL, v6);
if ( v4 )
{
*a3 = 0LL;
}
else
{
fh_mpool_put(*(_QWORD *)a1, v6[0]);
--*(_DWORD *)(a1 + 20);
*a3 = v6[0];
}
return v4;
}

original_code:
FH_STATUS fh_shr_lkp_ord_del(fh_shr_lkp_tbl_t *table, fh_shr_lkp_ord_key_t *key,
                             fh_shr_lkp_ord_t **entry)
{
    void *old_entry;
    FH_STATUS rc;
    rc = fh_ht_delete(table->hash, key, sizeof(fh_shr_lkp_ord_key_t), &old_entry);
    if (rc == (0)) {
        fh_mpool_put(table->mempool, old_entry);
        table->count--;
        *entry = (fh_shr_lkp_ord_t *)old_entry;
    }
    else {
        *entry = ((void *)0);
    }
    return rc;
}

canonical_original_code:
int fh_shr_lkp_ord_del(struct fh_shr_lkp_tbl *table, struct fh_shr_lkp_ord_key *key, struct fh_shr_lkp_ord **entry)
{
    void *old_entry;
    int rc;
    rc = fh_ht_delete(table->hash, key, sizeof(fh_shr_lkp_ord_key_t), &old_entry);
    if (rc == (0)) {
        fh_mpool_put(table->mempool, old_entry);
        table->count--;
        *entry = (struct fh_shr_lkp_ord *)old_entry;
    }
    else {
        *entry = ((void *)0);
    }
    return rc;
}


yyparse

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 6)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-17))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 269 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 18 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 4:
    { fh_cfg_prop_prev(); }
    break;
  case 6:
    { popcount++; }
    break;
  case 7:
    { fh_cfg_prop_new(yytext); }
    break;
  case 14:
    { fh_cfg_dequote_string(yytext); }
    break;
  case 15:
    { fh_cfg_val_new(yytext); }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 15;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 18 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 269 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-17))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 18 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 269 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

canonical_original_code:
int yyparse()
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    int yyvsa[200];
    int *yyvs;
    int *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  int yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 6)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-17))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 269 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 18 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 4:
    { fh_cfg_prop_prev(); }
    break;
  case 6:
    { popcount++; }
    break;
  case 7:
    { fh_cfg_prop_new(yytext); }
    break;
  case 14:
    { fh_cfg_dequote_string(yytext); }
    break;
  case 15:
    { fh_cfg_val_new(yytext); }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 15;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 18 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 269 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-17))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 18 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 269 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types:
yyvsa
int [200]

variable_types:
yyvs
int *

variable_types:
yyvsp
int *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yyval int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; int yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int


decompiled_code:
const char *__fastcall fh_cfg_dequote_string(const char *a1)
{
const char *result; // rax
unsigned int i; // ebp
__int64 v3; // r12

result = &a1[strlen(a1) - 1];
if ( *result == 34 )
*result = 0;
if ( *a1 == 34 )
{
for ( i = 0; ; a1[v3] = a1[i] )
{
v3 = i;
result = (const char *)(strlen(a1) - 1);
if ( i >= (unsigned __int64)result )
break;
++i;
}
result[(_QWORD)a1] = 0;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(const char *a1)
{
const char *result; // rax
unsigned int i; // ebp
__int64 v3; // r12

result = &a1[strlen(a1) - 1];
if ( *result == 34 )
*result = 0;
if ( *a1 == 34 )
{
for ( i = 0; ; a1[v3] = a1[i] )
{
v3 = i;
result = (const char *)(strlen(a1) - 1);
if ( i >= (unsigned __int64)result )
break;
++i;
}
result[(_QWORD)a1] = 0;
}
return result;
}

original_code:
void fh_cfg_dequote_string(char *s)
{
    unsigned int i;
    if (s[strlen(s) - 1] == '"') s[strlen(s) - 1] = '\0';
    if (s[0] == '"') {
        for (i = 0; i < strlen(s) - 1; i++) {
            s[i] = s[i + 1];
        }
        s[strlen(s) - 1] = '\0';
    }
}

variable_types:
s
char *

variable_types:
i
unsigned int


decompiled_code:
int *fh_cfg_prop_prev()
{
__int64 v0; // rdx
int v1; // eax
int *result; // rax

if ( popcount > 0 )
{
v0 = current;
v1 = 0;
do
{
v0 = *(_QWORD *)(v0 + 264);
++v1;
}
while ( v1 != popcount );
current = v0;
}
result = &popcount;
popcount = 1;
return result;
}

canonical_decompiled_code:
int *func2()
{
__int64 v0; // rdx
int v1; // eax
int *result; // rax

if ( popcount > 0 )
{
v0 = current;
v1 = 0;
do
{
v0 = *(_QWORD *)(v0 + 264);
++v1;
}
while ( v1 != popcount );
current = v0;
}
result = &popcount;
popcount = 1;
return result;
}

original_code:
void fh_cfg_prop_prev()
{
    int i;
    for (i = 0; i < popcount; i++) {
        current = current->parent;
    }
    popcount = 1;
}

variable_types: i int


yyerror

decompiled_code:
__int64 __fastcall yyerror(const char *a1)
{
fprintf(stderr, "ERROR: '%s' at line %d (last token parsed = %s).\n", a1, current_line, yytext);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
fprintf(stderr, "ERROR: '%s' at line %d (last token parsed = %s).\n", a1, current_line, yytext);
return 0xFFFFFFFFLL;
}

original_code:
int yyerror(char *s)
{
    fprintf(stderr, "ERROR: '%s' at line %d (last token parsed = %s).\n", s, current_line, yytext);
 return -1;
}


decompiled_code:
void *__fastcall fh_arca_mgmt_run(void *a1)
{
const char *v1; // rbx
__int64 v2; // rax
int *v3; // rax
char *v4; // rax
__int64 v5; // rax
__int64 v7; // rax

if ( a1 )
{
v2 = fh_log_fmt("assertion '%s' failed at %s:%d", "arg == NULL", "fh_arca_mgmt.c", 284LL);
fh_log("fh_arca_mgmt.c", 284LL, 0LL, "ERR", v2);
exit(1);
}
v1 = (const char *)fh_arca_util_thread_name("Mgmt");
fh_log_thread_start(v1);
if ( sem_post(&fh_arca_thread_init) != -1 )
{
if ( fh_arca_stopped )
goto LABEL_16;
while ( 1 )
{
if ( arca_mgmt_cl == -1 )
{
usleep(0xF4240u);
}
else if ( (unsigned int)fh_mgmt_cl_process(&arca_mgmt_cl, 1000000LL) )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v7 = fh_log_fmt("%s management connection failed", v1);
fh_log("fh_arca_mgmt.c", 306LL, "MGMT", "ERR", v7);
}
fh_arca_stopped = 1;
goto LABEL_16;
}
fh_arca_lh_rates();
if ( fh_arca_stopped )
goto LABEL_16;
}
}
if ( (fh_log_lvl[12] & 1) != 0 )
{
v3 = _errno_location();
v4 = strerror(*v3);
v5 = fh_log_fmt("unable to unlock init semaphore for MGMT thread: %s", v4);
fh_log("fh_arca_mgmt.c", 292LL, "MGMT", "ERR", v5);
}
fh_arca_stopped = 1;
LABEL_16:
fh_log_thread_stop(v1);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
const char *v1; // rbx
__int64 v2; // rax
int *v3; // rax
char *v4; // rax
__int64 v5; // rax
__int64 v7; // rax

if ( a1 )
{
v2 = fh_log_fmt("assertion '%s' failed at %s:%d", "arg == NULL", "fh_arca_mgmt.c", 284LL);
fh_log("fh_arca_mgmt.c", 284LL, 0LL, "ERR", v2);
exit(1);
}
v1 = (const char *)fh_arca_util_thread_name("Mgmt");
fh_log_thread_start(v1);
if ( sem_post(&fh_arca_thread_init) != -1 )
{
if ( fh_arca_stopped )
goto LABEL_16;
while ( 1 )
{
if ( arca_mgmt_cl == -1 )
{
usleep(0xF4240u);
}
else if ( (unsigned int)fh_mgmt_cl_process(&arca_mgmt_cl, 1000000LL) )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v7 = fh_log_fmt("%s management connection failed", v1);
fh_log("fh_arca_mgmt.c", 306LL, "MGMT", "ERR", v7);
}
fh_arca_stopped = 1;
goto LABEL_16;
}
fh_arca_lh_rates();
if ( fh_arca_stopped )
goto LABEL_16;
}
}
if ( (fh_log_lvl[12] & 1) != 0 )
{
v3 = _errno_location();
v4 = strerror(*v3);
v5 = fh_log_fmt("unable to unlock init semaphore for MGMT thread: %s", v4);
fh_log("fh_arca_mgmt.c", 292LL, "MGMT", "ERR", v5);
}
fh_arca_stopped = 1;
LABEL_16:
fh_log_thread_stop(v1);
return 0LL;
}

original_code:
static void *fh_arca_mgmt_run(void *arg)
{
    char *thread_name = ((void *)0);
    int ticks = 0;
    do { int nok = !(arg == ((void *)0)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "arg == NULL", "fh_arca_mgmt.c", 284); fh_log("fh_arca_mgmt.c", 284, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    thread_name = fh_arca_util_thread_name("Mgmt");
    fh_log_thread_start(thread_name);
    if (sem_post(&fh_arca_thread_init) == -1) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to unlock init semaphore for MGMT thread: %s", strerror((*__errno_location ()))); fh_log("fh_arca_mgmt.c", 292, "MGMT", "ERR", _msg); } } while (0);
        fh_arca_stopped = 1;
    }
    while (!fh_arca_stopped) {
        ticks++;
        if (arca_mgmt_cl.mcl_fd == -1) {
            usleep((1000000 / (1)));
        }
        else {
            if (fh_mgmt_cl_process(&arca_mgmt_cl, (1000000 / (1))) != (0)) {
                do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("%s management connection failed", thread_name); fh_log("fh_arca_mgmt.c", 306, "MGMT", "ERR", _msg); } } while (0);
                fh_arca_stopped = 1;
                break;
            }
        }
        if ((ticks % (1)) == 0) {
            fh_arca_lh_rates();
        }
    }
    fh_log_thread_stop(thread_name);
    return ((void *)0);
}

variable_types:
arg
void *

variable_types: ticks int

variable_types: nok int

return_type: void *


decompiled_code:
__int64 __fastcall fh_arca_mgmt_cmd_stats(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
char v10[1664]; // [rsp+0h] [rbp-6A8h] BYREF
char src[40]; // [rsp+680h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 7 )
{
v5 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATS_REQ", "fh_arca_mgmt.c", 73LL);
fh_log("fh_arca_mgmt.c", 73LL, 0LL, "ERR", v5);
exit(1);
}
if ( a3 != 16 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(stats_req)", "fh_arca_mgmt.c", 74LL);
fh_log("fh_arca_mgmt.c", 74LL, 0LL, "ERR", v6);
exit(1);
}
v3 = fh_adm_parse(7LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v7 = fh_log_fmt("received management request for statistics");
fh_log("fh_arca_mgmt.c", 83LL, "MGMT", "DIAG", v7);
}
strcpy(v10, src);
fh_arca_lh_get_stats(v10);
v3 = fh_adm_send((unsigned int)arca_mgmt_cl, 8LL, *(unsigned int *)(a1 + 8), v10, 1656LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = fh_log_fmt("failed to send statistics response to management server");
fh_log("fh_arca_mgmt.c", 91LL, "MGMT", "ERR", v8);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("statistics response sent successfully");
fh_log("fh_arca_mgmt.c", 96LL, "MGMT", "DIAG", v9);
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
char v10[1664]; // [rsp+0h] [rbp-6A8h] BYREF
char src[40]; // [rsp+680h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 7 )
{
v5 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATS_REQ", "fh_arca_mgmt.c", 73LL);
fh_log("fh_arca_mgmt.c", 73LL, 0LL, "ERR", v5);
exit(1);
}
if ( a3 != 16 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(stats_req)", "fh_arca_mgmt.c", 74LL);
fh_log("fh_arca_mgmt.c", 74LL, 0LL, "ERR", v6);
exit(1);
}
v3 = fh_adm_parse(7LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v7 = fh_log_fmt("received management request for statistics");
fh_log("fh_arca_mgmt.c", 83LL, "MGMT", "DIAG", v7);
}
strcpy(v10, src);
fh_arca_lh_get_stats(v10);
v3 = fh_adm_send((unsigned int)arca_mgmt_cl, 8LL, *(unsigned int *)(a1 + 8), v10, 1656LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = fh_log_fmt("failed to send statistics response to management server");
fh_log("fh_arca_mgmt.c", 91LL, "MGMT", "ERR", v8);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("statistics response sent successfully");
fh_log("fh_arca_mgmt.c", 96LL, "MGMT", "DIAG", v9);
}
}
return v3;
}

original_code:
static FH_STATUS fh_arca_mgmt_cmd_stats(const fh_adm_cmd_t *cmd, const char *cmd_buf,
    const int cmd_len)
{
    fh_adm_stats_req_t stats_req;
    fh_adm_stats_resp_t stats_resp;
    FH_STATUS rc;
    do { int nok = !(cmd->cmd_type == (7)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATS_REQ", "fh_arca_mgmt.c", 73); fh_log("fh_arca_mgmt.c", 73, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(stats_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(stats_req)", "fh_arca_mgmt.c", 74); fh_log("fh_arca_mgmt.c", 74, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, (char*) cmd_buf, &stats_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("received management request for statistics"); fh_log("fh_arca_mgmt.c", 83, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(stats_resp.stats_service, stats_req.stats_service);
    fh_arca_lh_get_stats(&stats_resp);
    rc = fh_adm_send(arca_mgmt_cl.mcl_fd, (8), cmd->cmd_tid, &stats_resp,
                     sizeof(stats_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send statistics response to management server"); fh_log("fh_arca_mgmt.c", 91, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("statistics response sent successfully"); fh_log("fh_arca_mgmt.c", 96, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

canonical_original_code:
static int fh_arca_mgmt_cmd_stats(struct fh_adm_cmd_t *cmd, char *cmd_buf, int cmd_len)
{
    struct fh_adm_stats_req_t stats_req;
    struct fh_adm_stats_resp_t stats_resp;
    int rc;
    do { int nok = !(cmd->cmd_type == (7)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATS_REQ", "fh_arca_mgmt.c", 73); fh_log("fh_arca_mgmt.c", 73, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(stats_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(stats_req)", "fh_arca_mgmt.c", 74); fh_log("fh_arca_mgmt.c", 74, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, (char *) cmd_buf, &stats_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("received management request for statistics"); fh_log("fh_arca_mgmt.c", 83, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(stats_resp.stats_service, stats_req.stats_service);
    fh_arca_lh_get_stats(&stats_resp);
    rc = fh_adm_send(arca_mgmt_cl.mcl_fd, (8), cmd->cmd_tid, &stats_resp,
                     sizeof(stats_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send statistics response to management server"); fh_log("fh_arca_mgmt.c", 91, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("statistics response sent successfully"); fh_log("fh_arca_mgmt.c", 96, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

variable_types: struct fh_adm_cmd_t { unsigned int cmd_magic; unsigned int cmd_type; unsigned int cmd_tid; unsigned int cmd_len; } *

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

variable_types: struct fh_adm_stats_resp_t { char stats_service[16]; unsigned int stats_state; unsigned int stats_line_cnt; struct fh_adm_line_stats_t { char line_name[32]; unsigned long line_pkt_rx; unsigned long line_pkt_dups; unsigned long line_pkt_errs; unsigned long line_pkt_late; unsigned long line_pkt_until_reset; unsigned long line_pkt_bad_times; unsigned long line_pkt_seq_jump; unsigned long line_pkt_wrap_noreset; unsigned long line_msg_rx; unsigned long line_msg_loss; unsigned long line_msg_recovered; unsigned long line_msg_late; unsigned long line_bytes; } stats_lines[-1]; }

variable_types: rc int

user_defined_types: struct fh_adm_stats_resp_t { char stats_service[16]; unsigned int stats_state; unsigned int stats_line_cnt; struct fh_adm_line_stats_t stats_lines[-1]; }


decompiled_code:
__int64 __fastcall fh_arca_mgmt_cmd_status(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
char v10[20]; // [rsp+0h] [rbp-58h] BYREF
__pid_t v11; // [rsp+14h] [rbp-44h]
int v12; // [rsp+18h] [rbp-40h]
int v13; // [rsp+1Ch] [rbp-3Ch]
int v14; // [rsp+20h] [rbp-38h]
int v15; // [rsp+24h] [rbp-34h]
int v16; // [rsp+28h] [rbp-30h]
int v17; // [rsp+2Ch] [rbp-2Ch]
char src[40]; // [rsp+30h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 9 )
{
v5 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_arca_mgmt.c", 115LL);
fh_log("fh_arca_mgmt.c", 115LL, 0LL, "ERR", v5);
exit(1);
}
if ( a3 != 16 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_arca_mgmt.c", 116LL);
fh_log("fh_arca_mgmt.c", 116LL, 0LL, "ERR", v6);
exit(1);
}
v3 = fh_adm_parse(9LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v7 = fh_log_fmt("received request for status from the fh manager service");
fh_log("fh_arca_mgmt.c", 125LL, "MGMT", "DIAG", v7);
}
strcpy(v10, src);
v11 = getpid();
v12 = fh_arca_cfg[34];
v13 = fh_arca_lh_get_tid();
v14 = arca_mgmt_uptime / 0xF4240uLL;
v15 = 0;
v16 = 0;
v17 = 0;
v3 = fh_adm_send((unsigned int)arca_mgmt_cl, 10LL, *(unsigned int *)(a1 + 8), v10, 48LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = fh_log_fmt("failed to send status response");
fh_log("fh_arca_mgmt.c", 143LL, "MGMT", "ERR", v8);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("sent status response");
fh_log("fh_arca_mgmt.c", 148LL, "MGMT", "DIAG", v9);
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
char v10[20]; // [rsp+0h] [rbp-58h] BYREF
__pid_t v11; // [rsp+14h] [rbp-44h]
int v12; // [rsp+18h] [rbp-40h]
int v13; // [rsp+1Ch] [rbp-3Ch]
int v14; // [rsp+20h] [rbp-38h]
int v15; // [rsp+24h] [rbp-34h]
int v16; // [rsp+28h] [rbp-30h]
int v17; // [rsp+2Ch] [rbp-2Ch]
char src[40]; // [rsp+30h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 9 )
{
v5 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_arca_mgmt.c", 115LL);
fh_log("fh_arca_mgmt.c", 115LL, 0LL, "ERR", v5);
exit(1);
}
if ( a3 != 16 )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_arca_mgmt.c", 116LL);
fh_log("fh_arca_mgmt.c", 116LL, 0LL, "ERR", v6);
exit(1);
}
v3 = fh_adm_parse(9LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v7 = fh_log_fmt("received request for status from the fh manager service");
fh_log("fh_arca_mgmt.c", 125LL, "MGMT", "DIAG", v7);
}
strcpy(v10, src);
v11 = getpid();
v12 = fh_arca_cfg[34];
v13 = fh_arca_lh_get_tid();
v14 = arca_mgmt_uptime / 0xF4240uLL;
v15 = 0;
v16 = 0;
v17 = 0;
v3 = fh_adm_send((unsigned int)arca_mgmt_cl, 10LL, *(unsigned int *)(a1 + 8), v10, 48LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = fh_log_fmt("failed to send status response");
fh_log("fh_arca_mgmt.c", 143LL, "MGMT", "ERR", v8);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("sent status response");
fh_log("fh_arca_mgmt.c", 148LL, "MGMT", "DIAG", v9);
}
}
return v3;
}

original_code:
static FH_STATUS fh_arca_mgmt_cmd_status(const fh_adm_cmd_t *cmd, const char *cmd_buf,
    const int cmd_len)
{
    fh_adm_status_req_t status_req;
    fh_adm_status_resp_t status_resp;
    FH_STATUS rc;
    do { int nok = !(cmd->cmd_type == (9)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_arca_mgmt.c", 115); fh_log("fh_arca_mgmt.c", 115, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(status_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_arca_mgmt.c", 116); fh_log("fh_arca_mgmt.c", 116, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, (char*) cmd_buf, &status_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("received request for status from the fh manager service"); fh_log("fh_arca_mgmt.c", 125, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(status_resp.status_service, status_req.status_service);
    status_resp.status_pid = getpid();
    status_resp.status_fp_cpu = fh_arca_cfg.cpu;
    status_resp.status_fp_tid = fh_arca_lh_get_tid();
    status_resp.status_uptime = (uint32_t)(arca_mgmt_uptime / 1000000);
    status_resp.status_pmem = 0;
    status_resp.status_putime = 0;
    status_resp.status_pstime = 0;
    rc = fh_adm_send(arca_mgmt_cl.mcl_fd, (10), cmd->cmd_tid, &status_resp,
                     sizeof(status_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send status response"); fh_log("fh_arca_mgmt.c", 143, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent status response"); fh_log("fh_arca_mgmt.c", 148, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

canonical_original_code:
static int fh_arca_mgmt_cmd_status(struct fh_adm_cmd_t *cmd, char *cmd_buf, int cmd_len)
{
    struct fh_adm_status_req_t status_req;
    struct fh_adm_status_resp_t status_resp;
    int rc;
    do { int nok = !(cmd->cmd_type == (9)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_STATUS_REQ", "fh_arca_mgmt.c", 115); fh_log("fh_arca_mgmt.c", 115, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(status_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(status_req)", "fh_arca_mgmt.c", 116); fh_log("fh_arca_mgmt.c", 116, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, (char *) cmd_buf, &status_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("received request for status from the fh manager service"); fh_log("fh_arca_mgmt.c", 125, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(status_resp.status_service, status_req.status_service);
    status_resp.status_pid = getpid();
    status_resp.status_fp_cpu = fh_arca_cfg.cpu;
    status_resp.status_fp_tid = fh_arca_lh_get_tid();
    status_resp.status_uptime = (unsigned int)(arca_mgmt_uptime / 1000000);
    status_resp.status_pmem = 0;
    status_resp.status_putime = 0;
    status_resp.status_pstime = 0;
    rc = fh_adm_send(arca_mgmt_cl.mcl_fd, (10), cmd->cmd_tid, &status_resp,
                     sizeof(status_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send status response"); fh_log("fh_arca_mgmt.c", 143, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent status response"); fh_log("fh_arca_mgmt.c", 148, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

variable_types: struct fh_adm_status_req_t { char status_service[16]; }

variable_types: struct fh_adm_status_resp_t { char status_service[16]; unsigned int status_state; unsigned int status_pid; unsigned int status_fp_cpu; unsigned int status_fp_tid; unsigned int status_uptime; unsigned int status_pmem; unsigned int status_putime; unsigned int status_pstime; }

user_defined_types: struct fh_adm_cmd_t { unsigned int cmd_magic; unsigned int cmd_type; unsigned int cmd_tid; unsigned int cmd_len; }


decompiled_code:
__int64 __fastcall fh_arca_mgmt_cmd_version(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
const char *v4; // rsi
const char *v5; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
char v12[20]; // [rsp+0h] [rbp-68h] BYREF
char dest[24]; // [rsp+14h] [rbp-54h] BYREF
char v14[20]; // [rsp+2Ch] [rbp-3Ch] BYREF
char src[40]; // [rsp+40h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 3 )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_arca_mgmt.c", 208LL);
fh_log("fh_arca_mgmt.c", 208LL, 0LL, "ERR", v7);
exit(1);
}
if ( a3 != 16 )
{
v8 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_arca_mgmt.c", 209LL);
fh_log("fh_arca_mgmt.c", 209LL, 0LL, "ERR", v8);
exit(1);
}
v3 = fh_adm_parse(3LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("get Arca version request for: %s", src);
fh_log("fh_arca_mgmt.c", 218LL, "MGMT", "DIAG", v9);
}
strcpy(v12, src);
v4 = (const char *)get_build_date();
strcpy(dest, v4);
v5 = (const char *)get_build_rev();
strcpy(v14, v5);
v3 = fh_adm_send((unsigned int)arca_mgmt_cl, 4LL, *(unsigned int *)(a1 + 8), v12, 52LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v10 = fh_log_fmt("failed to send 'get version' response for %s", src);
fh_log("fh_arca_mgmt.c", 227LL, "MGMT", "ERR", v10);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v11 = fh_log_fmt("sent 'get version' response for: %s", src);
fh_log("fh_arca_mgmt.c", 233LL, "MGMT", "DIAG", v11);
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3)
{
unsigned int v3; // ebx
const char *v4; // rsi
const char *v5; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
char v12[20]; // [rsp+0h] [rbp-68h] BYREF
char dest[24]; // [rsp+14h] [rbp-54h] BYREF
char v14[20]; // [rsp+2Ch] [rbp-3Ch] BYREF
char src[40]; // [rsp+40h] [rbp-28h] BYREF

if ( *(_DWORD *)(a1 + 4) != 3 )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_arca_mgmt.c", 208LL);
fh_log("fh_arca_mgmt.c", 208LL, 0LL, "ERR", v7);
exit(1);
}
if ( a3 != 16 )
{
v8 = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_arca_mgmt.c", 209LL);
fh_log("fh_arca_mgmt.c", 209LL, 0LL, "ERR", v8);
exit(1);
}
v3 = fh_adm_parse(3LL, a2, src);
if ( !v3 )
{
if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v9 = fh_log_fmt("get Arca version request for: %s", src);
fh_log("fh_arca_mgmt.c", 218LL, "MGMT", "DIAG", v9);
}
strcpy(v12, src);
v4 = (const char *)get_build_date();
strcpy(dest, v4);
v5 = (const char *)get_build_rev();
strcpy(v14, v5);
v3 = fh_adm_send((unsigned int)arca_mgmt_cl, 4LL, *(unsigned int *)(a1 + 8), v12, 52LL);
if ( v3 )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v10 = fh_log_fmt("failed to send 'get version' response for %s", src);
fh_log("fh_arca_mgmt.c", 227LL, "MGMT", "ERR", v10);
}
}
else if ( (fh_log_lvl[12] & 0x10) != 0 )
{
v11 = fh_log_fmt("sent 'get version' response for: %s", src);
fh_log("fh_arca_mgmt.c", 233LL, "MGMT", "DIAG", v11);
}
}
return v3;
}

original_code:
static FH_STATUS fh_arca_mgmt_cmd_version(const fh_adm_cmd_t *cmd, const char *cmd_buf,
    const int cmd_len)
{
    fh_adm_getver_req_t getver_req;
    fh_adm_getver_resp_t getver_resp;
    FH_STATUS rc;
    do { int nok = !(cmd->cmd_type == (3)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_arca_mgmt.c", 208); fh_log("fh_arca_mgmt.c", 208, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(getver_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_arca_mgmt.c", 209); fh_log("fh_arca_mgmt.c", 209, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, (char*)cmd_buf, &getver_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("get Arca version request for: %s", getver_req.getver_service); fh_log("fh_arca_mgmt.c", 218, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(getver_resp.getver_service, getver_req.getver_service);
    strcpy(getver_resp.getver_build_date, get_build_date());
    strcpy(getver_resp.getver_build_rev, get_build_rev());
    rc = fh_adm_send(arca_mgmt_cl.mcl_fd, (4), cmd->cmd_tid, &getver_resp,
                     sizeof(getver_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send 'get version' response for %s", getver_req.getver_service); fh_log("fh_arca_mgmt.c", 227, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent 'get version' response for: %s", getver_req.getver_service); fh_log("fh_arca_mgmt.c", 233, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

canonical_original_code:
static int fh_arca_mgmt_cmd_version(struct fh_adm_cmd_t *cmd, char *cmd_buf, int cmd_len)
{
    struct fh_adm_getver_req_t getver_req;
    struct fh_adm_getver_resp_t getver_resp;
    int rc;
    do { int nok = !(cmd->cmd_type == (3)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd->cmd_type == FH_ADM_CMD_GETVER_REQ", "fh_arca_mgmt.c", 208); fh_log("fh_arca_mgmt.c", 208, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    do { int nok = !(cmd_len == sizeof(getver_req)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "cmd_len == sizeof(getver_req)", "fh_arca_mgmt.c", 209); fh_log("fh_arca_mgmt.c", 209, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    rc = fh_adm_parse(cmd->cmd_type, (char *)cmd_buf, &getver_req);
    if (rc != (0)) {
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("get Arca version request for: %s", getver_req.getver_service); fh_log("fh_arca_mgmt.c", 218, "MGMT", "DIAG", _msg); } } while (0);
    strcpy(getver_resp.getver_service, getver_req.getver_service);
    strcpy(getver_resp.getver_build_date, get_build_date());
    strcpy(getver_resp.getver_build_rev, get_build_rev());
    rc = fh_adm_send(arca_mgmt_cl.mcl_fd, (4), cmd->cmd_tid, &getver_resp,
                     sizeof(getver_resp));
    if (rc != (0)) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("failed to send 'get version' response for %s", getver_req.getver_service); fh_log("fh_arca_mgmt.c", 227, "MGMT", "ERR", _msg); } } while (0);
        return rc;
    }
    do { if ((fh_log_lvl[(3)] & ((0x00000010)))) { char *_msg = fh_log_fmt ("sent 'get version' response for: %s", getver_req.getver_service); fh_log("fh_arca_mgmt.c", 233, "MGMT", "DIAG", _msg); } } while (0);
    return (0);
}

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

variable_types: struct fh_adm_getver_resp_t { char getver_service[16]; unsigned int getver_state; char getver_build_date[24]; char getver_build_rev[8]; }


decompiled_code:
__int64 __fastcall fh_arca_mgmt_process(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax
__int64 v5; // rax

v3 = *(unsigned int *)(a1 + 4);
if ( (_DWORD)v3 == 9 )
return fh_arca_mgmt_cmd_status(a1, a1, a2);
if ( (unsigned int)v3 > 9 )
{
if ( (_DWORD)v3 == 11 )
return fh_arca_mgmt_cmd_action(a1, a1, a2);
}
else
{
if ( (_DWORD)v3 == 3 )
return fh_arca_mgmt_cmd_version(a1, a1, a2);
if ( (_DWORD)v3 == 7 )
return fh_arca_mgmt_cmd_stats(a1, a1, a2);
}
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v5 = fh_log_fmt("unexpected client command: %d", v3);
fh_log("fh_arca_mgmt.c", 266LL, "MGMT", "ERR", v5);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax
__int64 v5; // rax

v3 = *(unsigned int *)(a1 + 4);
if ( (_DWORD)v3 == 9 )
return func2(a1, a1, a2);
if ( (unsigned int)v3 > 9 )
{
if ( (_DWORD)v3 == 11 )
return func4(a1, a1, a2);
}
else
{
if ( (_DWORD)v3 == 3 )
return func3(a1, a1, a2);
if ( (_DWORD)v3 == 7 )
return func1(a1, a1, a2);
}
result = 0xFFFFFFFFLL;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v5 = fh_log_fmt("unexpected client command: %d", v3);
fh_log("fh_arca_mgmt.c", 266LL, "MGMT", "ERR", v5);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static FH_STATUS fh_arca_mgmt_process(char *cmd_buf, const int cmd_len)
{
    fh_adm_cmd_t *cmd = (fh_adm_cmd_t *)cmd_buf;
    FH_STATUS rc = (0);
    switch (cmd->cmd_type) {
    case (7):
        rc = fh_arca_mgmt_cmd_stats(cmd, cmd_buf, cmd_len);
        break;
    case (9):
        rc = fh_arca_mgmt_cmd_status(cmd, cmd_buf, cmd_len);
        break;
    case (3):
        rc = fh_arca_mgmt_cmd_version(cmd, cmd_buf, cmd_len);
        break;
    case (11):
        rc = fh_arca_mgmt_cmd_action(cmd, cmd_buf, cmd_len);
        break;
    default:
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unexpected client command: %d", cmd->cmd_type); fh_log("fh_arca_mgmt.c", 266, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    return rc;
}

canonical_original_code:
static int fh_arca_mgmt_process(char *cmd_buf, int cmd_len)
{
    struct fh_adm_cmd_t *cmd = (fh_adm_cmd_t *)cmd_buf;
    int rc = (0);
    switch (cmd->cmd_type) {
    case (7):
        rc = fh_arca_mgmt_cmd_stats(cmd, cmd_buf, cmd_len);
        break;
    case (9):
        rc = fh_arca_mgmt_cmd_status(cmd, cmd_buf, cmd_len);
        break;
    case (3):
        rc = fh_arca_mgmt_cmd_version(cmd, cmd_buf, cmd_len);
        break;
    case (11):
        rc = fh_arca_mgmt_cmd_action(cmd, cmd_buf, cmd_len);
        break;
    default:
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unexpected client command: %d", cmd->cmd_type); fh_log("fh_arca_mgmt.c", 266, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    return rc;
}


decompiled_code:
__int64 __fastcall fh_arca_mgmt_start(int a1)
{
in_addr_t v1; // er12
unsigned int v2; // ebx
int *v4; // rax
char *v5; // rax
__int64 v6; // rax
__int64 v7; // rax
unsigned int v8; // ebx
char *v9; // rax
__int64 v10; // rax
struct timespec v11; // [rsp+0h] [rbp-28h] BYREF

v1 = inet_addr("127.0.0.1");
v11.tv_sec = 0LL;
v11.tv_nsec = 0LL;
v11.tv_sec = time(0LL) + 5;
if ( sem_timedwait(&fh_arca_thread_init, &v11) != -1 )
{
fh_time_get(&arca_mgmt_uptime);
if ( a1 )
{
arca_mgmt_cl = -1;
}
else if ( (unsigned int)fh_mgmt_cl_init(&arca_mgmt_cl, fh_arca_mgmt_process, 2LL, v1, 40000LL, fh_arca_cfg, 0LL) )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v7 = fh_log_fmt("%s failed to establish management connection", (const char *)fh_arca_cfg);
fh_log("fh_arca_mgmt.c", 357LL, "MGMT", "ERR", v7);
}
goto LABEL_12;
}
if ( pthread_create(&arca_mgmt_thread, 0LL, fh_arca_mgmt_run, 0LL) >= 0 )
return 0;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = *_errno_location();
v9 = strerror(v8);
v10 = fh_log_fmt("Failed to start Arca management thread (%s): %s (%d)", (const char *)fh_arca_cfg, v9, v8);
fh_log("fh_arca_mgmt.c", 365LL, "MGMT", "ERR", v10);
}
LABEL_12:
sem_post(&fh_arca_thread_init);
return (unsigned int)-1;
}
v2 = -1;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v4 = _errno_location();
v5 = strerror(*v4);
v6 = fh_log_fmt("unable to lock init semaphore for MGMT thread: %s", v5);
fh_log("fh_arca_mgmt.c", 341LL, "MGMT", "ERR", v6);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
in_addr_t v1; // er12
unsigned int v2; // ebx
int *v4; // rax
char *v5; // rax
__int64 v6; // rax
__int64 v7; // rax
unsigned int v8; // ebx
char *v9; // rax
__int64 v10; // rax
struct timespec v11; // [rsp+0h] [rbp-28h] BYREF

v1 = inet_addr("127.0.0.1");
v11.tv_sec = 0LL;
v11.tv_nsec = 0LL;
v11.tv_sec = time(0LL) + 5;
if ( sem_timedwait(&fh_arca_thread_init, &v11) != -1 )
{
fh_time_get(&arca_mgmt_uptime);
if ( a1 )
{
arca_mgmt_cl = -1;
}
else if ( (unsigned int)fh_mgmt_cl_init(&arca_mgmt_cl, fh_arca_mgmt_process, 2LL, v1, 40000LL, fh_arca_cfg, 0LL) )
{
if ( (fh_log_lvl[12] & 1) != 0 )
{
v7 = fh_log_fmt("%s failed to establish management connection", (const char *)fh_arca_cfg);
fh_log("fh_arca_mgmt.c", 357LL, "MGMT", "ERR", v7);
}
goto LABEL_12;
}
if ( pthread_create(&arca_mgmt_thread, 0LL, fh_arca_mgmt_run, 0LL) >= 0 )
return 0;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v8 = *_errno_location();
v9 = strerror(v8);
v10 = fh_log_fmt("Failed to start Arca management thread (%s): %s (%d)", (const char *)fh_arca_cfg, v9, v8);
fh_log("fh_arca_mgmt.c", 365LL, "MGMT", "ERR", v10);
}
LABEL_12:
sem_post(&fh_arca_thread_init);
return (unsigned int)-1;
}
v2 = -1;
if ( (fh_log_lvl[12] & 1) != 0 )
{
v4 = _errno_location();
v5 = strerror(*v4);
v6 = fh_log_fmt("unable to lock init semaphore for MGMT thread: %s", v5);
fh_log("fh_arca_mgmt.c", 341LL, "MGMT", "ERR", v6);
}
return v2;
}

original_code:
FH_STATUS fh_arca_mgmt_start(const int standalone)
{
    FH_STATUS rc;
    struct timespec lock_wait;
    uint32_t daddr = inet_addr("127.0.0.1");
    memset(&lock_wait, 0, sizeof(struct timespec));
    lock_wait.tv_sec = time(((void *)0)) + 5;
    if (sem_timedwait(&fh_arca_thread_init, &lock_wait) == -1) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to lock init semaphore for MGMT thread: %s", strerror((*__errno_location ()))); fh_log("fh_arca_mgmt.c", 341, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    fh_time_get(&arca_mgmt_uptime);
    if (standalone) {
        arca_mgmt_cl.mcl_fd = -1;
    }
    else {
        rc = fh_mgmt_cl_init(&arca_mgmt_cl, fh_arca_mgmt_process, (0x00000002), daddr,
                             (40000), fh_arca_cfg.name, 0);
        if (rc != (0)) {
            do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("%s failed to establish management connection", fh_arca_cfg.name); fh_log("fh_arca_mgmt.c", 357, "MGMT", "ERR", _msg); } } while (0);
            sem_post(&fh_arca_thread_init);
            return (-1);
        }
    }
    if (pthread_create(&arca_mgmt_thread, ((void *)0), fh_arca_mgmt_run, ((void *)0)) < 0) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Failed to start Arca management thread (%s): %s (%d)", fh_arca_cfg.name, strerror((*__errno_location ())), (*__errno_location ())); fh_log("fh_arca_mgmt.c", 365, "MGMT", "ERR", _msg); } } while (0);
        sem_post(&fh_arca_thread_init);
        return (-1);
    }
    return (0);
}

canonical_original_code:
int fh_arca_mgmt_start(int standalone)
{
    int rc;
    struct timespec lock_wait;
    unsigned int daddr = inet_addr("127.0.0.1");
    memset(&lock_wait, 0, sizeof(struct timespec));
    lock_wait.tv_sec = time(((void *)0)) + 5;
    if (sem_timedwait(&fh_arca_thread_init, &lock_wait) == -1) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to lock init semaphore for MGMT thread: %s", strerror((*__errno_location ()))); fh_log("fh_arca_mgmt.c", 341, "MGMT", "ERR", _msg); } } while (0);
        return (-1);
    }
    fh_time_get(&arca_mgmt_uptime);
    if (standalone) {
        arca_mgmt_cl.mcl_fd = -1;
    }
    else {
        rc = fh_mgmt_cl_init(&arca_mgmt_cl, fh_arca_mgmt_process, (0x00000002), daddr,
                             (40000), fh_arca_cfg.name, 0);
        if (rc != (0)) {
            do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("%s failed to establish management connection", fh_arca_cfg.name); fh_log("fh_arca_mgmt.c", 357, "MGMT", "ERR", _msg); } } while (0);
            sem_post(&fh_arca_thread_init);
            return (-1);
        }
    }
    if (pthread_create(&arca_mgmt_thread, ((void *)0), fh_arca_mgmt_run, ((void *)0)) < 0) {
        do { if ((fh_log_lvl[(3)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("Failed to start Arca management thread (%s): %s (%d)", fh_arca_cfg.name, strerror((*__errno_location ())), (*__errno_location ())); fh_log("fh_arca_mgmt.c", 365, "MGMT", "ERR", _msg); } } while (0);
        sem_post(&fh_arca_thread_init);
        return (-1);
    }
    return (0);
}

variable_types: standalone int

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types:
daddr
unsigned int


decompiled_code:
void fh_arca_mgmt_wait()
{
__int64 v0; // rax

if ( arca_mgmt_thread )
{
pthread_join(arca_mgmt_thread, 0LL);
if ( (fh_log_lvl[12] & 8) != 0 )
{
v0 = fh_log_fmt("Arca management thread (%s) exited", (const char *)fh_arca_cfg);
fh_log("fh_arca_mgmt.c", 381LL, "MGMT", "VSTATE", v0);
}
}
}

canonical_decompiled_code:
void func7()
{
__int64 v0; // rax

if ( arca_mgmt_thread )
{
pthread_join(arca_mgmt_thread, 0LL);
if ( (fh_log_lvl[12] & 8) != 0 )
{
v0 = fh_log_fmt("Arca management thread (%s) exited", (const char *)fh_arca_cfg);
fh_log("fh_arca_mgmt.c", 381LL, "MGMT", "VSTATE", v0);
}
}
}

original_code:
void fh_arca_mgmt_wait()
{
    if (arca_mgmt_thread) {
        pthread_join(arca_mgmt_thread, ((void *)0));
        do { if ((fh_log_lvl[(3)] & ((0x00000008)))) { char *_msg = fh_log_fmt ("Arca management thread (%s) exited", fh_arca_cfg.name); fh_log("fh_arca_mgmt.c", 381, "MGMT", "VSTATE", _msg); } } while (0);
    }
}


original_code:
static FH_STATUS get_process_config(struct process_maps *p_map)
{
    get_lines(p_map);
    p_map->feed_cpu = fh_arca_cfg.cpu;
    p_map->refresh_cpu = fh_arca_cfg.cpu;
    p_map->retrans_cpu = fh_arca_cfg.cpu;
    p_map->max_symbols = fh_arca_cfg.max_symbols;
    p_map->max_sessions = fh_arca_cfg.max_sessions;
    p_map->max_firms = fh_arca_cfg.max_firms;
    p_map->max_orders = fh_arca_cfg.max_orders;
    return (0);
}

canonical_original_code:
static int get_process_config(struct process_maps *p_map)
{
    get_lines(p_map);
    p_map->feed_cpu = fh_arca_cfg.cpu;
    p_map->refresh_cpu = fh_arca_cfg.cpu;
    p_map->retrans_cpu = fh_arca_cfg.cpu;
    p_map->max_symbols = fh_arca_cfg.max_symbols;
    p_map->max_sessions = fh_arca_cfg.max_sessions;
    p_map->max_firms = fh_arca_cfg.max_firms;
    p_map->max_orders = fh_arca_cfg.max_orders;
    return (0);
}

variable_types: struct process_maps { struct feed_group { unsigned long arca_primary_feed; unsigned long arca_publishing; unsigned long arca_retrans_feed; unsigned long arca_request_service; unsigned long arca_measurement_service; int arca_main; unsigned long missing_sequence[-1]; unsigned long feed_time; unsigned long publish_time; unsigned long origination_time; unsigned long missing_packet_incidence; unsigned long missing_message_range; unsigned long unrecoverable_messages; unsigned long restored_message_incidence; unsigned long loss_of_in_sequence; unsigned long restoral_of_in_sequence; unsigned long packets_lost_incidence; unsigned long loss_of_feed_source; unsigned long symbol_table_error; unsigned long firm_table_error; unsigned long publication_failed; unsigned long publication_succeeded; unsigned long pckt_rcvd_from_primary; unsigned long pckt_rcvd_from_secondary; unsigned long bytes_rcvd_from_primary; unsigned long bytes_rcvd_from_secondary; unsigned long msgs_rcvd_from_primary; unsigned long msgs_rcvd_from_secondary; unsigned long pkt_format_errors_primary; unsigned long pkt_format_errors_secondary; unsigned long pkt_duplicate_primary; unsigned long pkt_duplicate_secondary; unsigned long previous_primary; unsigned long previous_secondary; unsigned int feed_group_space_size; unsigned int primary_expected_sequence; unsigned int secondary_expected_sequence; unsigned int missing_base; unsigned int missing_count; unsigned int missing_lowest; unsigned int missing_highest; unsigned int maximum_sessions; unsigned int maximum_symbols; unsigned int maximum_firms; unsigned int maximum_orders; unsigned int notification_line_id; long latest_mapping_update; int primary_mcast_port; int secondary_mcast_port; int primary_retran_tcp_port; int primary_retran_mcast_port; int secondary_retran_mcast_port; int primary_mcast_socket; int secondary_mcast_socket; int primary_retran_tcp_socket; int primary_retran_mcast_socket; int secondary_retran_mcast_socket; int primary_mcast_affinity; int publish_affinity; int retrans_mcast_affinity; int measurement_affinity; int restart_time; char primary_mcast_ip_addrs[16]; char secondary_mcast_ip_addrs[16]; char primary_retran_tcp_ip_addrs[16]; char primary_retran_mcast_ip_addrs[16]; char secondary_retran_mcast_ip_addrs[16]; char primary_mcast_intfc[10]; char secondary_mcast_intfc[10]; char primary_request_intfc[10]; char primary_retran_intfc[10]; char secondary_retran_intfc[10]; char feed_name[64]; char process_name[64]; char source_id[21]; unsigned char session_id; unsigned char fast_mode; unsigned char request_or_interval; unsigned char enable_restart; unsigned char purge_mode; unsigned char in_sequence; unsigned char primary_on_line; unsigned char secondary_on_line; unsigned char process_halt; unsigned char expecting_retrans; unsigned char expecting_book_refresh; unsigned char expecting_imbalance_refresh; char store_ring[-1]; 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; } access_missing; union pthread_mutex_t access_primary_sequence; union pthread_mutex_t access_secondary_sequence; char primary_fast_buffer[1500]; char secondary_fast_buffer[1500]; char primary_buffer[-1]; char secondary_buffer[-1]; } *groups[10]; int feed_cpu; int refresh_cpu; int retrans_cpu; int line_count; int max_symbols; int max_sessions; int max_firms; int max_orders; char line_names[10][20]; } *

user_defined_types: struct process_maps { struct feed_group *groups[10]; int feed_cpu; int refresh_cpu; int retrans_cpu; int line_count; int max_symbols; int max_sessions; int max_firms; int max_orders; char line_names[10][20]; }

user_defined_types: struct feed_group { unsigned long arca_primary_feed; unsigned long arca_publishing; unsigned long arca_retrans_feed; unsigned long arca_request_service; unsigned long arca_measurement_service; int arca_main; unsigned long missing_sequence[-1]; unsigned long feed_time; unsigned long publish_time; unsigned long origination_time; unsigned long missing_packet_incidence; unsigned long missing_message_range; unsigned long unrecoverable_messages; unsigned long restored_message_incidence; unsigned long loss_of_in_sequence; unsigned long restoral_of_in_sequence; unsigned long packets_lost_incidence; unsigned long loss_of_feed_source; unsigned long symbol_table_error; unsigned long firm_table_error; unsigned long publication_failed; unsigned long publication_succeeded; unsigned long pckt_rcvd_from_primary; unsigned long pckt_rcvd_from_secondary; unsigned long bytes_rcvd_from_primary; unsigned long bytes_rcvd_from_secondary; unsigned long msgs_rcvd_from_primary; unsigned long msgs_rcvd_from_secondary; unsigned long pkt_format_errors_primary; unsigned long pkt_format_errors_secondary; unsigned long pkt_duplicate_primary; unsigned long pkt_duplicate_secondary; unsigned long previous_primary; unsigned long previous_secondary; unsigned int feed_group_space_size; unsigned int primary_expected_sequence; unsigned int secondary_expected_sequence; unsigned int missing_base; unsigned int missing_count; unsigned int missing_lowest; unsigned int missing_highest; unsigned int maximum_sessions; unsigned int maximum_symbols; unsigned int maximum_firms; unsigned int maximum_orders; unsigned int notification_line_id; long latest_mapping_update; int primary_mcast_port; int secondary_mcast_port; int primary_retran_tcp_port; int primary_retran_mcast_port; int secondary_retran_mcast_port; int primary_mcast_socket; int secondary_mcast_socket; int primary_retran_tcp_socket; int primary_retran_mcast_socket; int secondary_retran_mcast_socket; int primary_mcast_affinity; int publish_affinity; int retrans_mcast_affinity; int measurement_affinity; int restart_time; char primary_mcast_ip_addrs[16]; char secondary_mcast_ip_addrs[16]; char primary_retran_tcp_ip_addrs[16]; char primary_retran_mcast_ip_addrs[16]; char secondary_retran_mcast_ip_addrs[16]; char primary_mcast_intfc[10]; char secondary_mcast_intfc[10]; char primary_request_intfc[10]; char primary_retran_intfc[10]; char secondary_retran_intfc[10]; char feed_name[64]; char process_name[64]; char source_id[21]; unsigned char session_id; unsigned char fast_mode; unsigned char request_or_interval; unsigned char enable_restart; unsigned char purge_mode; unsigned char in_sequence; unsigned char primary_on_line; unsigned char secondary_on_line; unsigned char process_halt; unsigned char expecting_retrans; unsigned char expecting_book_refresh; unsigned char expecting_imbalance_refresh; char store_ring[-1]; union pthread_mutex_t access_missing; union pthread_mutex_t access_primary_sequence; union pthread_mutex_t access_secondary_sequence; char primary_fast_buffer[1500]; char secondary_fast_buffer[1500]; char primary_buffer[-1]; char secondary_buffer[-1]; }