original_code:
static FH_STATUS get_line_config(const int line_index, struct feed_group *group)
{
    fh_arca_cfg_line_t *line_cfg = &fh_arca_cfg.lines[line_index];
    strcpy(&group->primary_mcast_ip_addrs[0], inet_ntoa(line_cfg->primary.address));
    strcpy(&group->primary_mcast_intfc[0], line_cfg->primary.interface);
    if (line_cfg->primary.enabled) {
        group->primary_mcast_port = line_cfg->primary.port;
    }
    else {
        group->primary_mcast_port = 0;
    }
    strcpy(&group->secondary_mcast_ip_addrs[0], inet_ntoa(line_cfg->secondary.address));
    strcpy(&group->secondary_mcast_intfc[0], line_cfg->secondary.interface);
    if (line_cfg->secondary.enabled) {
        group->secondary_mcast_port = line_cfg->secondary.port;
    }
    else {
        group->secondary_mcast_port = 0;
    }
    group->fast_mode = line_cfg->fast;
    strcpy(&group->feed_name[0], line_cfg->name);
    strcpy(&group->process_name[0], fh_arca_cfg.name);
    group->notification_line_id = ((line_index & 0x03) << 30);
    group->maximum_sessions = line_cfg->maximum_sessions;
    group->maximum_symbols = line_cfg->maximum_symbols;
    group->maximum_firms = line_cfg->maximum_firms;
    group->maximum_orders = line_cfg->maximum_orders;
    return (0);
}

canonical_original_code:
static int get_line_config(int line_index, struct feed_group *group)
{
    struct fh_arca_cfg_line_t *line_cfg = &fh_arca_cfg.lines[line_index];
    strcpy(&group->primary_mcast_ip_addrs[0], inet_ntoa(line_cfg->primary.address));
    strcpy(&group->primary_mcast_intfc[0], line_cfg->primary.interface);
    if (line_cfg->primary.enabled) {
        group->primary_mcast_port = line_cfg->primary.port;
    }
    else {
        group->primary_mcast_port = 0;
    }
    strcpy(&group->secondary_mcast_ip_addrs[0], inet_ntoa(line_cfg->secondary.address));
    strcpy(&group->secondary_mcast_intfc[0], line_cfg->secondary.interface);
    if (line_cfg->secondary.enabled) {
        group->secondary_mcast_port = line_cfg->secondary.port;
    }
    else {
        group->secondary_mcast_port = 0;
    }
    group->fast_mode = line_cfg->fast;
    strcpy(&group->feed_name[0], line_cfg->name);
    strcpy(&group->process_name[0], fh_arca_cfg.name);
    group->notification_line_id = ((line_index & 0x03) << 30);
    group->maximum_sessions = line_cfg->maximum_sessions;
    group->maximum_symbols = line_cfg->maximum_symbols;
    group->maximum_firms = line_cfg->maximum_firms;
    group->maximum_orders = line_cfg->maximum_orders;
    return (0);
}

variable_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 { 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]; } *

variable_types: struct fh_arca_cfg_line_t { char name[255]; struct fh_arca_cfg_connection_t { struct in_addr { unsigned int s_addr; } address; unsigned short port; char interface[16]; int enabled; } primary; struct fh_arca_cfg_connection_t secondary; int fast; int strict_ordering; unsigned int maximum_sessions; unsigned int maximum_symbols; unsigned int maximum_firms; unsigned int maximum_orders; } *

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]; }

user_defined_types: struct fh_arca_cfg_line_t { char name[255]; struct fh_arca_cfg_connection_t primary; struct fh_arca_cfg_connection_t secondary; int fast; int strict_ordering; unsigned int maximum_sessions; unsigned int maximum_symbols; unsigned int maximum_firms; unsigned int maximum_orders; }

user_defined_types: struct fh_arca_cfg_connection_t { struct in_addr address; unsigned short port; char interface[16]; int enabled; }


repo: csinitiative/fhce

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]; } *

return_type: int

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


decompiled_code:
__int64 __fastcall get_config(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er14
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rbx
__int64 v7; // rax

if ( !(unsigned int)get_process_config(a2) )
{
v2 = get_source_id(a1);
if ( !v2 )
{
v3 = 0LL;
if ( (int)a2[23] <= 0 )
return v2;
while ( 1 )
{
v4 = new_feed_group();
v5 = v4;
if ( !v4 )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "group != NULL", "fh_arca_config.c", 152LL);
fh_log("fh_arca_config.c", 152LL, 0LL, "ERR", v7);
exit(1);
}
default_config(v4);
strcpy((char *)(v5 + 262782), source_id);
if ( (unsigned int)get_line_config(v3, v5) )
break;
*(_QWORD *)&a2[2 * v3++] = v5;
if ( a2[23] <= (int)v3 )
return v2;
}
}
}
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er14
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rbx
__int64 v7; // rax

if ( !(unsigned int)func3(a2) )
{
v2 = func0(a1);
if ( !v2 )
{
v3 = 0LL;
if ( (int)a2[23] <= 0 )
return v2;
while ( 1 )
{
v4 = new_feed_group();
v5 = v4;
if ( !v4 )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "group != NULL", "fh_arca_config.c", 152LL);
fh_log("fh_arca_config.c", 152LL, 0LL, "ERR", v7);
exit(1);
}
default_config(v4);
strcpy((char *)(v5 + 262782), source_id);
if ( (unsigned int)func1(v3, v5) )
break;
*(_QWORD *)&a2[2 * v3++] = v5;
if ( a2[23] <= (int)v3 )
return v2;
}
}
}
return (unsigned int)-1;
}

original_code:
FH_STATUS get_config(const fh_cfg_node_t *config, struct process_maps *p_map)
{
    struct feed_group *group;
    int i = 0;
    if (get_process_config(p_map) != (0)) {
        return (-1);
    }
    if (get_source_id(config) != (0)) {
        return (-1);
    }
    for (i = 0; i < p_map->line_count; i++) {
        group = new_feed_group();
        do { int nok = !(group != ((void *)0)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "group != NULL", "fh_arca_config.c", 152); fh_log("fh_arca_config.c", 152, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        default_config(group);
        strcpy(&group->source_id[0], source_id);
        if (get_line_config(i, group) != (0)) {
            return (-1);
        }
        p_map->groups[i] = group;
    }
    return (0);
}

canonical_original_code:
int get_config(struct fh_cfg_node *config, struct process_maps *p_map)
{
    struct feed_group *group;
    int i = 0;
    if (get_process_config(p_map) != (0)) {
        return (-1);
    }
    if (get_source_id(config) != (0)) {
        return (-1);
    }
    for (i = 0; i < p_map->line_count; i++) {
        group = new_feed_group();
        do { int nok = !(group != ((void *)0)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "group != NULL", "fh_arca_config.c", 152); fh_log("fh_arca_config.c", 152, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        default_config(group);
        strcpy(&group->source_id[0], source_id);
        if (get_line_config(i, group) != (0)) {
            return (-1);
        }
        p_map->groups[i] = group;
    }
    return (0);
}

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

variable_types: i int

variable_types: nok int

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


decompiled_code:
int __fastcall init_mutexes(pthread_mutex_t *a1)
{
pthread_mutex_init(a1 + 13124, 0LL);
pthread_mutex_init(a1 + 13125, 0LL);
return pthread_mutex_init(a1 + 13126, 0LL);
}

canonical_decompiled_code:
int __fastcall func0(pthread_mutex_t *a1)
{
pthread_mutex_init(a1 + 13124, 0LL);
pthread_mutex_init(a1 + 13125, 0LL);
return pthread_mutex_init(a1 + 13126, 0LL);
}

original_code:
static inline void init_mutexes(struct feed_group * const group)
{
    pthread_mutex_init(&group->access_missing,((void *)0));
    pthread_mutex_init(&group->access_primary_sequence,((void *)0));
    pthread_mutex_init(&group->access_secondary_sequence,((void *)0));
}

canonical_original_code:
static inline void init_mutexes(struct feed_group *group)
{
    pthread_mutex_init(&group->access_missing,((void *)0));
    pthread_mutex_init(&group->access_primary_sequence,((void *)0));
    pthread_mutex_init(&group->access_secondary_sequence,((void *)0));
}

return_type: void


decompiled_code:
__int64 __fastcall default_config(pthread_mutex_t *a1)
{
init_mutexes(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(pthread_mutex_t *a1)
{
func0(a1);
return 0LL;
}

original_code:
int default_config(struct feed_group * const group)
{
    init_mutexes(group);
    return 0;
}

canonical_original_code:
int default_config(struct feed_group *group)
{
    init_mutexes(group);
    return 0;
}


decompiled_code:
_DWORD *new_feed_group()
{
_DWORD *result; // rax

result = calloc(0x83DB0uLL, 1uLL);
if ( result )
{
result[65602] = 540080;
*((_BYTE *)result + 262808) = 1;
}
return result;
}

canonical_decompiled_code:
_DWORD *func2()
{
_DWORD *result; // rax

result = calloc(0x83DB0uLL, 1uLL);
if ( result )
{
result[65602] = 540080;
*((_BYTE *)result + 262808) = 1;
}
return result;
}

original_code:
struct feed_group* new_feed_group()
{
    struct feed_group *group;
    int modulo=0;
    int dwords=0;
    size_t feed_group_size = 0;
    feed_group_size = sizeof(struct feed_group);
    dwords = feed_group_size / 8;
    modulo = feed_group_size % 8;
    if (modulo>0)
    {
        feed_group_size = (dwords+1)*8;
    }
    group = (struct feed_group*) malloc((size_t)feed_group_size);
    if (group == ((void *)0)) return (struct feed_group*)0;
    memset(group,0,feed_group_size);
    group->feed_group_space_size = feed_group_size;
    group->in_sequence = 1;
    return group;
}

canonical_original_code:
struct feed_group *new_feed_group()
{
    struct feed_group *group;
    int modulo = 0;
    int dwords = 0;
    unsigned long feed_group_size = 0;
    feed_group_size = sizeof(struct feed_group);
    dwords = feed_group_size / 8;
    modulo = feed_group_size % 8;
    if (modulo>0)
    {
        feed_group_size = (dwords+1)*8;
    }
    group = (struct feed_group *) malloc((unsigned long)feed_group_size);
    if (group == ((void *)0)) return (struct feed_group *)0;
    memset(group,0,feed_group_size);
    group->feed_group_space_size = feed_group_size;
    group->in_sequence = 1;
    return group;
}

variable_types: modulo int

variable_types: dwords int

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


original_code:
int add_sequences_2_missing(struct feed_group * const group,
    const uint32_t first_sequence, const uint32_t count)
{
    uint32_t nextPktSeq = 0;
    uint32_t modulo_val = 0;
    uint32_t offset = 0;
    uint32_t index = 0;
    uint64_t mask;
    uint32_t sequ = first_sequence;
    if (sequ <= group->missing_base)
    {
        return -1;
    }
    nextPktSeq = first_sequence + count - 1;
    if (group->missing_count ==0)
    {
        group->missing_base = first_sequence;
        memset(&(group->missing_sequence[0]),0,sizeof(group->missing_sequence));
        group->missing_lowest = first_sequence;
        group->missing_highest = first_sequence + count-1;
    }
    if (nextPktSeq >= group->missing_highest)
    {
        group->missing_highest = nextPktSeq;
    }
    while (sequ <= nextPktSeq)
    {
        modulo_val = sequ-group->missing_base;
        offset = modulo_val >> 6;
        index = modulo_val % 64;
        mask = missing_modulos[index];
        group->missing_sequence[offset] |= mask;
        sequ++;
    }
    group->missing_count += count;
    return 0;
}

canonical_original_code:
int add_sequences_2_missing(struct feed_group *group, unsigned int first_sequence, unsigned int count)
{
    unsigned int nextPktSeq = 0;
    unsigned int modulo_val = 0;
    unsigned int offset = 0;
    unsigned int index = 0;
    unsigned long mask;
    unsigned int sequ = first_sequence;
    if (sequ <= group->missing_base)
    {
        return -1;
    }
    nextPktSeq = first_sequence + count - 1;
    if (group->missing_count ==0)
    {
        group->missing_base = first_sequence;
        memset(&(group->missing_sequence[0]),0,sizeof(group->missing_sequence));
        group->missing_lowest = first_sequence;
        group->missing_highest = first_sequence + count-1;
    }
    if (nextPktSeq >= group->missing_highest)
    {
        group->missing_highest = nextPktSeq;
    }
    while (sequ <= nextPktSeq)
    {
        modulo_val = sequ-group->missing_base;
        offset = modulo_val >> 6;
        index = modulo_val % 64;
        mask = missing_modulos[index];
        group->missing_sequence[offset] |= mask;
        sequ++;
    }
    group->missing_count += count;
    return 0;
}

variable_types:
count
unsigned int

variable_types:
nextPktSeq
unsigned int

variable_types:
offset
unsigned int

variable_types:
index
unsigned int

variable_types:
mask
unsigned long

variable_types:
sequ
unsigned int


decompiled_code:
// attributes: thunk
__int64 stop_book_refresh()
{
return start_book_refresh_localalias();
}

canonical_decompiled_code:
__int64 func5()
{
return func4();
}

original_code:
int stop_book_refresh(struct feed_group * const group)
{
    if(group){}
    return 0;
}

canonical_original_code:
int stop_book_refresh(struct feed_group *group)
{
    if(group){}
    return 0;
}


decompiled_code:
__int64 fh_opra_ml_init()
{
void (__fastcall *v0)(unsigned int *, void *); // rdx
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
unsigned int v10[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( dword_990 || ml_init )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "sess.sess_init == 0 && ml_init == NULL", "fh_opra_ml.c", 57LL);
fh_log("fh_opra_ml.c", 57LL, 0LL, "ERR", v6);
exit(1);
}
ml_flush = fh_plugin_get_hook(2LL);
if ( ml_flush && (fh_log_lvl[12] & 4) != 0 )
{
v5 = fh_log_fmt("FH Plugin loaded: OPRA message layer flush");
fh_log("fh_opra_ml.c", 64LL, "MGMT", "STATE", v5);
}
ml_send = fh_plugin_get_hook(1LL);
if ( ml_send && (fh_log_lvl[12] & 4) != 0 )
{
v4 = fh_log_fmt("FH Plugin loaded: OPRA message layer send");
fh_log("fh_opra_ml.c", 69LL, "MGMT", "STATE", v4);
}
ml_init = fh_plugin_get_hook(3LL);
if ( ml_init && (fh_log_lvl[12] & 4) != 0 )
{
v3 = fh_log_fmt("FH Plugin loaded: OPRA message layer init");
fh_log("fh_opra_ml.c", 74LL, "MGMT", "STATE", v3);
}
ml_opt_add = fh_plugin_get_hook(14LL);
if ( ml_opt_add && (fh_log_lvl[12] & 4) != 0 )
{
v2 = fh_log_fmt("FH Plugin loaded: OPRA message layer option creation");
fh_log("fh_opra_ml.c", 79LL, "MGMT", "STATE", v2);
v0 = (void (__fastcall *)(unsigned int *, void *))ml_init;
if ( ml_init )
goto LABEL_15;
return fh_msg_init(&sess);
}
v0 = (void (__fastcall *)(unsigned int *, void *))ml_init;
if ( !ml_init )
return fh_msg_init(&sess);
LABEL_15:
if ( !ml_send )
{
v9 = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_send", "fh_opra_ml.c", 87LL);
fh_log("fh_opra_ml.c", 87LL, 0LL, "ERR", v9);
exit(1);
}
if ( !ml_flush )
{
v8 = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_flush", "fh_opra_ml.c", 88LL);
fh_log("fh_opra_ml.c", 88LL, 0LL, "ERR", v8);
exit(1);
}
if ( !ml_opt_add )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_opt_add", "fh_opra_ml.c", 89LL);
fh_log("fh_opra_ml.c", 89LL, 0LL, "ERR", v7);
exit(1);
}
v0(v10, &opra_cfg);
return v10[0];
}

canonical_decompiled_code:
__int64 func0()
{
void (__fastcall *v0)(unsigned int *, void *); // rdx
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
unsigned int v10[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( dword_990 || ml_init )
{
v6 = fh_log_fmt("assertion '%s' failed at %s:%d", "sess.sess_init == 0 && ml_init == NULL", "fh_opra_ml.c", 57LL);
fh_log("fh_opra_ml.c", 57LL, 0LL, "ERR", v6);
exit(1);
}
ml_flush = fh_plugin_get_hook(2LL);
if ( ml_flush && (fh_log_lvl[12] & 4) != 0 )
{
v5 = fh_log_fmt("FH Plugin loaded: OPRA message layer flush");
fh_log("fh_opra_ml.c", 64LL, "MGMT", "STATE", v5);
}
ml_send = fh_plugin_get_hook(1LL);
if ( ml_send && (fh_log_lvl[12] & 4) != 0 )
{
v4 = fh_log_fmt("FH Plugin loaded: OPRA message layer send");
fh_log("fh_opra_ml.c", 69LL, "MGMT", "STATE", v4);
}
ml_init = fh_plugin_get_hook(3LL);
if ( ml_init && (fh_log_lvl[12] & 4) != 0 )
{
v3 = fh_log_fmt("FH Plugin loaded: OPRA message layer init");
fh_log("fh_opra_ml.c", 74LL, "MGMT", "STATE", v3);
}
ml_opt_add = fh_plugin_get_hook(14LL);
if ( ml_opt_add && (fh_log_lvl[12] & 4) != 0 )
{
v2 = fh_log_fmt("FH Plugin loaded: OPRA message layer option creation");
fh_log("fh_opra_ml.c", 79LL, "MGMT", "STATE", v2);
v0 = (void (__fastcall *)(unsigned int *, void *))ml_init;
if ( ml_init )
goto LABEL_15;
return fh_msg_init(&sess);
}
v0 = (void (__fastcall *)(unsigned int *, void *))ml_init;
if ( !ml_init )
return fh_msg_init(&sess);
LABEL_15:
if ( !ml_send )
{
v9 = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_send", "fh_opra_ml.c", 87LL);
fh_log("fh_opra_ml.c", 87LL, 0LL, "ERR", v9);
exit(1);
}
if ( !ml_flush )
{
v8 = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_flush", "fh_opra_ml.c", 88LL);
fh_log("fh_opra_ml.c", 88LL, 0LL, "ERR", v8);
exit(1);
}
if ( !ml_opt_add )
{
v7 = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_opt_add", "fh_opra_ml.c", 89LL);
fh_log("fh_opra_ml.c", 89LL, 0LL, "ERR", v7);
exit(1);
}
v0(v10, &opra_cfg);
return v10[0];
}

original_code:
FH_STATUS fh_opra_ml_init()
{
    FH_STATUS rc;
    do { int nok = !(sess.sess_init == 0 && ml_init == ((void *)0)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "sess.sess_init == 0 && ml_init == NULL", "fh_opra_ml.c", 57); fh_log("fh_opra_ml.c", 57, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    ml_flush = fh_plugin_get_hook((2));
    if (ml_flush) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer flush"); fh_log("fh_opra_ml.c", 64, "MGMT", "STATE", _msg); } } while (0);
    }
    ml_send = fh_plugin_get_hook((1));
    if (ml_send) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer send"); fh_log("fh_opra_ml.c", 69, "MGMT", "STATE", _msg); } } while (0);
    }
    ml_init = fh_plugin_get_hook((3));
    if (ml_init) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer init"); fh_log("fh_opra_ml.c", 74, "MGMT", "STATE", _msg); } } while (0);
    }
    ml_opt_add = fh_plugin_get_hook((14));
    if (ml_opt_add) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer option creation"); fh_log("fh_opra_ml.c", 79, "MGMT", "STATE", _msg); } } while (0);
    }
    if (ml_init) {
        do { int nok = !(ml_send); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_send", "fh_opra_ml.c", 87); fh_log("fh_opra_ml.c", 87, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        do { int nok = !(ml_flush); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_flush", "fh_opra_ml.c", 88); fh_log("fh_opra_ml.c", 88, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        do { int nok = !(ml_opt_add); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_opt_add", "fh_opra_ml.c", 89); fh_log("fh_opra_ml.c", 89, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        ml_init(&rc, &opra_cfg);
        return rc;
    }
    rc = fh_msg_init(&sess);
    if (rc != (0)) {
        return rc;
    }
    return (0);
}

canonical_original_code:
int fh_opra_ml_init()
{
    int rc;
    do { int nok = !(sess.sess_init == 0 && ml_init == ((void *)0)); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "sess.sess_init == 0 && ml_init == NULL", "fh_opra_ml.c", 57); fh_log("fh_opra_ml.c", 57, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    ml_flush = fh_plugin_get_hook((2));
    if (ml_flush) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer flush"); fh_log("fh_opra_ml.c", 64, "MGMT", "STATE", _msg); } } while (0);
    }
    ml_send = fh_plugin_get_hook((1));
    if (ml_send) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer send"); fh_log("fh_opra_ml.c", 69, "MGMT", "STATE", _msg); } } while (0);
    }
    ml_init = fh_plugin_get_hook((3));
    if (ml_init) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer init"); fh_log("fh_opra_ml.c", 74, "MGMT", "STATE", _msg); } } while (0);
    }
    ml_opt_add = fh_plugin_get_hook((14));
    if (ml_opt_add) {
        do { if ((fh_log_lvl[(3)] & ((0x00000004)))) { char *_msg = fh_log_fmt ("FH Plugin loaded: OPRA message layer option creation"); fh_log("fh_opra_ml.c", 79, "MGMT", "STATE", _msg); } } while (0);
    }
    if (ml_init) {
        do { int nok = !(ml_send); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_send", "fh_opra_ml.c", 87); fh_log("fh_opra_ml.c", 87, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        do { int nok = !(ml_flush); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_flush", "fh_opra_ml.c", 88); fh_log("fh_opra_ml.c", 88, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        do { int nok = !(ml_opt_add); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "ml_opt_add", "fh_opra_ml.c", 89); fh_log("fh_opra_ml.c", 89, ((void *)0), "ERR", _msg); exit(1); } } while (0);
        ml_init(&rc, &opra_cfg);
        return rc;
    }
    rc = fh_msg_init(&sess);
    if (rc != (0)) {
        return rc;
    }
    return (0);
}

variable_types: rc int


decompiled_code:
__int64 fh_opra_ml_flush()
{
unsigned int v1[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( !ml_flush )
return fh_msg_flush(&sess);
ml_flush(v1);
return v1[0];
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v1[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( !ml_flush )
return fh_msg_flush(&sess);
ml_flush(v1);
return v1[0];
}

original_code:
FH_STATUS fh_opra_ml_flush()
{
    FH_STATUS rc;
    if (ml_flush) {
        ml_flush(&rc);
        return rc;
    }
    return fh_msg_flush(&sess);
}

canonical_original_code:
int fh_opra_ml_flush()
{
    int rc;
    if (ml_flush) {
        ml_flush(&rc);
        return rc;
    }
    return fh_msg_flush(&sess);
}


decompiled_code:
__int64 __fastcall fh_opra_ml_send(__int64 a1, unsigned int a2)
{
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = 0;
if ( !ml_send )
return fh_msg_send(&sess, a1, a2);
ml_send(v3, a1, a2);
return v3[0];
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2)
{
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = 0;
if ( !ml_send )
return fh_msg_send(&sess, a1, a2);
ml_send(v3, a1, a2);
return v3[0];
}

original_code:
FH_STATUS fh_opra_ml_send(void *msg, int length)
{
    FH_STATUS rc = (0);
    if (ml_send) {
        ml_send(&rc, msg, length);
        return rc;
    }
    rc = fh_msg_send(&sess, msg, length);
    return rc;
}

canonical_original_code:
int fh_opra_ml_send(void *msg, int length)
{
    int rc = (0);
    if (ml_send) {
        ml_send(&rc, msg, length);
        return rc;
    }
    rc = fh_msg_send(&sess, msg, length);
    return rc;
}

variable_types:
msg
void *

variable_types: length int


decompiled_code:
__int64 __fastcall fh_opra_ml_opt_add(__int64 a1)
{
__int64 result; // rax
unsigned int v2[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( ml_opt_add )
{
ml_opt_add(v2, a1);
result = v2[0];
}
else
{
*(_QWORD *)(a1 + 72) = 0LL;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
unsigned int v2[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( ml_opt_add )
{
ml_opt_add(v2, a1);
result = v2[0];
}
else
{
*(_QWORD *)(a1 + 72) = 0LL;
result = 0LL;
}
return result;
}

original_code:
FH_STATUS fh_opra_ml_opt_add(fh_opra_opt_t *opt)
{
    FH_STATUS rc;
    if (ml_opt_add) {
        ml_opt_add(&rc, opt);
        return rc;
    }
    opt->opt_priv = ((void *)0);
    return (0);
}

canonical_original_code:
int fh_opra_ml_opt_add(struct fh_opra_opt *opt)
{
    int rc;
    if (ml_opt_add) {
        ml_opt_add(&rc, opt);
        return rc;
    }
    opt->opt_priv = ((void *)0);
    return (0);
}

variable_types: struct fh_opra_opt { struct fh_opra_opt_le_t { struct fh_opra_opt *tqe_next; struct fh_opra_opt **tqe_prev; } opt_line_le; char opt_topic[32]; struct fh_opra_opt_key_t { char k_symbol[5]; unsigned char k_year; unsigned char k_month; unsigned char k_day; char k_putcall; char k_exchid; unsigned short k_fraction; unsigned int k_decimal; } opt_key; struct fh_opra_lo_t { char lo_root[-1]; char lo_sec[-1]; } *opt_lo; void *opt_priv; unsigned short opt_ftline_idx; unsigned short opt_init; unsigned int opt_uflags; union opra_exp_date_t { char exp_year_v1; struct { char exp_year[2]; char exp_date[2]; } exp_date_v2; } opt_exp_date; char opt_session; char opt_bo_partid; char opt_bb_partid; unsigned int opt_seq_num; unsigned int opt_time; unsigned int opt_open_bid; unsigned int opt_open_offer; unsigned int opt_open_price; unsigned int opt_close_price; unsigned int opt_last_price; unsigned int opt_high_price; unsigned int opt_low_price; unsigned int opt_daily_high; unsigned int opt_daily_low; unsigned int opt_bid_price; unsigned int opt_offer_price; unsigned long opt_cum_volume; unsigned long opt_cum_value; unsigned long opt_halttime; unsigned long opt_unhalttime; } *

user_defined_types: struct fh_opra_opt { struct fh_opra_opt_le_t opt_line_le; char opt_topic[32]; struct fh_opra_opt_key_t opt_key; struct fh_opra_lo_t *opt_lo; void *opt_priv; unsigned short opt_ftline_idx; unsigned short opt_init; unsigned int opt_uflags; union opra_exp_date_t opt_exp_date; char opt_session; char opt_bo_partid; char opt_bb_partid; unsigned int opt_seq_num; unsigned int opt_time; unsigned int opt_open_bid; unsigned int opt_open_offer; unsigned int opt_open_price; unsigned int opt_close_price; unsigned int opt_last_price; unsigned int opt_high_price; unsigned int opt_low_price; unsigned int opt_daily_high; unsigned int opt_daily_low; unsigned int opt_bid_price; unsigned int opt_offer_price; unsigned long opt_cum_volume; unsigned long opt_cum_value; unsigned long opt_halttime; unsigned long opt_unhalttime; }


decompiled_code:
__int64 __fastcall fh_arca_cfg_get_long(__int64 a1, __int64 a2, __int64 *a3)
{
const char *v4; // rax
const char *v5; // rbx

v4 = (const char *)fh_cfg_get_string();
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = v4;
*a3 = strtol(v4, 0LL, 0);
return (unsigned int)-(*v5 == 0);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 *a3)
{
const char *v4; // rax
const char *v5; // rbx

v4 = (const char *)fh_cfg_get_string();
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = v4;
*a3 = strtol(v4, 0LL, 0);
return (unsigned int)-(*v5 == 0);
}

original_code:
static FH_STATUS fh_arca_cfg_get_long(const fh_cfg_node_t *config, const char *property,
                                      long *where)
{
    const char *value = ((void *)0);
    char **endptr = ((void *)0);
    value = fh_cfg_get_string(config, property);
    if (value == ((void *)0)) return (-1);
    *where = strtol(value, endptr, 0);
    if (value[0] == '\0' || endptr != ((void *)0)) return (-1);
    return (0);
}

canonical_original_code:
static int fh_arca_cfg_get_long(struct fh_cfg_node *config, char *property, long *where)
{
    char *value = ((void *)0);
    char **endptr = ((void *)0);
    value = fh_cfg_get_string(config, property);
    if (value == ((void *)0)) return (-1);
    *where = strtol(value, endptr, 0);
    if (value[0] == '\0' || endptr != ((void *)0)) return (-1);
    return (0);
}

variable_types:
property
char *

variable_types:
where
long *

variable_types:
value
char *

variable_types:
endptr
char **

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


decompiled_code:
__int64 __fastcall fh_arca_cfg_yesno(__int64 a1)
{
unsigned int v1; // er12
__int64 v3; // rax
__int64 v4; // rax

if ( !a1 )
{
v1 = 0;
if ( (fh_log_lvl & 2) != 0 )
{
v4 = fh_log_fmt("null yes/no value, defaulting to no");
fh_log("fh_arca_cfg.c", 54LL, "CSI", "WARN", v4);
}
return v1;
}
v1 = 1;
if ( !strcmp((const char *)a1, "yes") )
return v1;
if ( *(_BYTE *)a1 == 110 && *(_BYTE *)(a1 + 1) == 111 && !*(_BYTE *)(a1 + 2) )
return *(unsigned __int8 *)(a1 + 2);
v1 = 0;
if ( (fh_log_lvl & 2) == 0 )
return v1;
v3 = fh_log_fmt("invalid yes/no value \"%s\", defaulting to no", (const char *)a1);
fh_log("fh_arca_cfg.c", 63LL, "CSI", "WARN", v3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // er12
__int64 v3; // rax
__int64 v4; // rax

if ( !a1 )
{
v1 = 0;
if ( (fh_log_lvl & 2) != 0 )
{
v4 = fh_log_fmt("null yes/no value, defaulting to no");
fh_log("fh_arca_cfg.c", 54LL, "CSI", "WARN", v4);
}
return v1;
}
v1 = 1;
if ( !strcmp((const char *)a1, "yes") )
return v1;
if ( *(_BYTE *)a1 == 110 && *(_BYTE *)(a1 + 1) == 111 && !*(_BYTE *)(a1 + 2) )
return *(unsigned __int8 *)(a1 + 2);
v1 = 0;
if ( (fh_log_lvl & 2) == 0 )
return v1;
v3 = fh_log_fmt("invalid yes/no value \"%s\", defaulting to no", (const char *)a1);
fh_log("fh_arca_cfg.c", 63LL, "CSI", "WARN", v3);
return 0LL;
}

original_code:
static int fh_arca_cfg_yesno(const char *str)
{
    if (str == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("null yes/no value, defaulting to no"); fh_log("fh_arca_cfg.c", 54, "CSI", "WARN", _msg); } } while (0);
        return 0;
    }
    if (str && !strcmp(str, "yes")) return 1;
    if (str && !strcmp(str, "no")) return 0;
    do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("invalid yes/no value \"%s\", defaulting to no", str); fh_log("fh_arca_cfg.c", 63, "CSI", "WARN", _msg); } } while (0);
    return 0;
}

canonical_original_code:
static int fh_arca_cfg_yesno(char *str)
{
    if (str == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("null yes/no value, defaulting to no"); fh_log("fh_arca_cfg.c", 54, "CSI", "WARN", _msg); } } while (0);
        return 0;
    }
    if (str && !strcmp(str, "yes")) return 1;
    if (str && !strcmp(str, "no")) return 0;
    do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("invalid yes/no value \"%s\", defaulting to no", str); fh_log("fh_arca_cfg.c", 63, "CSI", "WARN", _msg); } } while (0);
    return 0;
}

variable_types:
str
char *


decompiled_code:
__int64 __fastcall fh_arca_cfg_load_connection(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbp
const char *v6; // rax
const char *v7; // rax
__int64 v8; // rax
const char *v9; // rax
__int64 v10; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax

v4 = fh_cfg_get_node();
if ( v4 )
{
v5 = v4;
v6 = (const char *)fh_cfg_get_string(v4, "address");
if ( inet_aton(v6, (struct in_addr *)a3) )
{
v7 = (const char *)fh_cfg_get_string(v5, "port");
v8 = strtol(v7, 0LL, 0);
if ( (unsigned __int64)(v8 - 1) <= 0xFFFF )
{
*(_WORD *)(a3 + 4) = v8;
v9 = (const char *)fh_cfg_get_string(v5, "interface");
strcpy((char *)(a3 + 6), v9);
v10 = fh_cfg_get_string(v5, "enable");
*(_DWORD *)(a3 + 24) = fh_arca_cfg_yesno(v10);
return 0LL;
}
if ( (fh_log_lvl & 1) != 0 )
{
v12 = fh_log_fmt("missing or invalid port property for connection: %s", a2);
fh_log("fh_arca_cfg.c", 124LL, "CSI", "ERR", v12);
return 0xFFFFFFFFLL;
}
}
else if ( (fh_log_lvl & 1) != 0 )
{
v14 = fh_log_fmt("missing or invalid address property for connection: %s", a2);
fh_log("fh_arca_cfg.c", 116LL, "CSI", "ERR", v14);
}
return 0xFFFFFFFFLL;
}
if ( (fh_log_lvl & 1) == 0 )
return 0xFFFFFFFFLL;
v13 = fh_log_fmt("missing configuration for connection: %s", a2);
fh_log("fh_arca_cfg.c", 110LL, "CSI", "ERR", v13);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbp
const char *v6; // rax
const char *v7; // rax
__int64 v8; // rax
const char *v9; // rax
__int64 v10; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax

v4 = fh_cfg_get_node();
if ( v4 )
{
v5 = v4;
v6 = (const char *)fh_cfg_get_string(v4, "address");
if ( inet_aton(v6, (struct in_addr *)a3) )
{
v7 = (const char *)fh_cfg_get_string(v5, "port");
v8 = strtol(v7, 0LL, 0);
if ( (unsigned __int64)(v8 - 1) <= 0xFFFF )
{
*(_WORD *)(a3 + 4) = v8;
v9 = (const char *)fh_cfg_get_string(v5, "interface");
strcpy((char *)(a3 + 6), v9);
v10 = fh_cfg_get_string(v5, "enable");
*(_DWORD *)(a3 + 24) = func1(v10);
return 0LL;
}
if ( (fh_log_lvl & 1) != 0 )
{
v12 = fh_log_fmt("missing or invalid port property for connection: %s", a2);
fh_log("fh_arca_cfg.c", 124LL, "CSI", "ERR", v12);
return 0xFFFFFFFFLL;
}
}
else if ( (fh_log_lvl & 1) != 0 )
{
v14 = fh_log_fmt("missing or invalid address property for connection: %s", a2);
fh_log("fh_arca_cfg.c", 116LL, "CSI", "ERR", v14);
}
return 0xFFFFFFFFLL;
}
if ( (fh_log_lvl & 1) == 0 )
return 0xFFFFFFFFLL;
v13 = fh_log_fmt("missing configuration for connection: %s", a2);
fh_log("fh_arca_cfg.c", 110LL, "CSI", "ERR", v13);
return 0xFFFFFFFFLL;
}

original_code:
static FH_STATUS fh_arca_cfg_load_connection(const fh_cfg_node_t *config, char *name,
                                             fh_arca_cfg_connection_t *connection)
{
    const fh_cfg_node_t *node = ((void *)0);
    long port = 0;
    const char *value = ((void *)0);
    char **endptr = ((void *)0);
    node = fh_cfg_get_node(config, name);
    if (node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing configuration for connection: %s", name); fh_log("fh_arca_cfg.c", 110, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (!inet_aton(fh_cfg_get_string(node, "address"), &connection->address)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid address property for connection: %s", name); fh_log("fh_arca_cfg.c", 116, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    value = fh_cfg_get_string(node, "port");
    port = strtol(value, endptr, 0);
    if (value == ((void *)0) || endptr != ((void *)0) || port < 1 || port > 65536) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid port property for connection: %s", name); fh_log("fh_arca_cfg.c", 124, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    connection->port = (uint16_t)port;
    strcpy(connection->interface, fh_cfg_get_string(node, "interface"));
    if (connection->interface == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid interface property for connection: %s", name); fh_log("fh_arca_cfg.c", 132, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    connection->enabled = fh_arca_cfg_yesno(fh_cfg_get_string(node, "enable"));
    return (0);
}

canonical_original_code:
static int fh_arca_cfg_load_connection(struct fh_cfg_node *config, char *name, struct fh_arca_cfg_connection_t *connection)
{
    struct fh_cfg_node *node = ((void *)0);
    long port = 0;
    char *value = ((void *)0);
    char **endptr = ((void *)0);
    node = fh_cfg_get_node(config, name);
    if (node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing configuration for connection: %s", name); fh_log("fh_arca_cfg.c", 110, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (!inet_aton(fh_cfg_get_string(node, "address"), &connection->address)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid address property for connection: %s", name); fh_log("fh_arca_cfg.c", 116, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    value = fh_cfg_get_string(node, "port");
    port = strtol(value, endptr, 0);
    if (value == ((void *)0) || endptr != ((void *)0) || port < 1 || port > 65536) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid port property for connection: %s", name); fh_log("fh_arca_cfg.c", 124, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    connection->port = (unsigned short)port;
    strcpy(connection->interface, fh_cfg_get_string(node, "interface"));
    if (connection->interface == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid interface property for connection: %s", name); fh_log("fh_arca_cfg.c", 132, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    connection->enabled = fh_arca_cfg_yesno(fh_cfg_get_string(node, "enable"));
    return (0);
}

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

variable_types:
name
char *

variable_types: struct fh_arca_cfg_connection_t { struct in_addr { unsigned int s_addr; } address; unsigned short port; char interface[16]; int enabled; } *

variable_types: port long


decompiled_code:
__int64 __fastcall fh_arca_cfg_add_line(__int64 a1, const char *a2)
{
__int64 v2; // rax
__int64 v3; // rbp
char *v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v7; // rax
__int64 result; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
char v13[296]; // [rsp+0h] [rbp-128h] BYREF

sprintf(v13, "arca.lines.%s", a2);
v2 = fh_cfg_get_node(a1, v13);
if ( v2 )
{
v3 = v2;
v4 = (char *)realloc(*(void **)&fh_arca_cfg[256], 336 * (*(unsigned __int16 *)&fh_arca_cfg[264] + 1LL));
*(_QWORD *)&fh_arca_cfg[256] = v4;
if ( v4 )
{
v5 = *(unsigned __int16 *)&fh_arca_cfg[264];
*(_WORD *)&fh_arca_cfg[264] = v5 + 1;
v6 = &v4[336 * v5];
strcpy(v6, a2);
v7 = fh_cfg_get_string(v3, "fast");
*((_DWORD *)v6 + 78) = fh_arca_cfg_yesno(v7);
if ( (unsigned int)fh_arca_cfg_load_connection(v3, "primary", (__int64)(v6 + 256)) )
{
if ( (fh_log_lvl & 1) != 0 )
{
v11 = fh_log_fmt("unable to load primary connection information for line: %s", a2);
fh_log("fh_arca_cfg.c", 180LL, "CSI", "ERR", v11);
}
}
else
{
result = fh_arca_cfg_load_connection(v3, "secondary", (__int64)(v6 + 284));
if ( !(_DWORD)result )
{
*((_DWORD *)v6 + 80) = *(_QWORD *)&fh_arca_cfg[288];
*((_DWORD *)v6 + 81) = *(_QWORD *)&fh_arca_cfg[296];
*((_DWORD *)v6 + 82) = *(_QWORD *)&fh_arca_cfg[304];
*((_DWORD *)v6 + 83) = *(_QWORD *)&fh_arca_cfg[312];
return result;
}
if ( (fh_log_lvl & 1) != 0 )
{
v9 = fh_log_fmt("unable to load secondary connection information for line: %s", a2);
fh_log("fh_arca_cfg.c", 184LL, "CSI", "ERR", v9);
return 0xFFFFFFFFLL;
}
}
return 0xFFFFFFFFLL;
}
if ( (fh_log_lvl & 1) == 0 )
return 0xFFFFFFFFLL;
v12 = fh_log_fmt("unable to allocate memory for Arca line configuration list");
fh_log("fh_arca_cfg.c", 167LL, "CSI", "ERR", v12);
result = 0xFFFFFFFFLL;
}
else
{
if ( (fh_log_lvl & 1) == 0 )
return 0xFFFFFFFFLL;
v10 = fh_log_fmt("no configuration data for line: %s", a2);
fh_log("fh_arca_cfg.c", 159LL, "CSI", "ERR", v10);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2)
{
__int64 v2; // rax
__int64 v3; // rbp
char *v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v7; // rax
__int64 result; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
char v13[296]; // [rsp+0h] [rbp-128h] BYREF

sprintf(v13, "arca.lines.%s", a2);
v2 = fh_cfg_get_node(a1, v13);
if ( v2 )
{
v3 = v2;
v4 = (char *)realloc(*(void **)&fh_arca_cfg[256], 336 * (*(unsigned __int16 *)&fh_arca_cfg[264] + 1LL));
*(_QWORD *)&fh_arca_cfg[256] = v4;
if ( v4 )
{
v5 = *(unsigned __int16 *)&fh_arca_cfg[264];
*(_WORD *)&fh_arca_cfg[264] = v5 + 1;
v6 = &v4[336 * v5];
strcpy(v6, a2);
v7 = fh_cfg_get_string(v3, "fast");
*((_DWORD *)v6 + 78) = func1(v7);
if ( (unsigned int)func2(v3, "primary", (__int64)(v6 + 256)) )
{
if ( (fh_log_lvl & 1) != 0 )
{
v11 = fh_log_fmt("unable to load primary connection information for line: %s", a2);
fh_log("fh_arca_cfg.c", 180LL, "CSI", "ERR", v11);
}
}
else
{
result = func2(v3, "secondary", (__int64)(v6 + 284));
if ( !(_DWORD)result )
{
*((_DWORD *)v6 + 80) = *(_QWORD *)&fh_arca_cfg[288];
*((_DWORD *)v6 + 81) = *(_QWORD *)&fh_arca_cfg[296];
*((_DWORD *)v6 + 82) = *(_QWORD *)&fh_arca_cfg[304];
*((_DWORD *)v6 + 83) = *(_QWORD *)&fh_arca_cfg[312];
return result;
}
if ( (fh_log_lvl & 1) != 0 )
{
v9 = fh_log_fmt("unable to load secondary connection information for line: %s", a2);
fh_log("fh_arca_cfg.c", 184LL, "CSI", "ERR", v9);
return 0xFFFFFFFFLL;
}
}
return 0xFFFFFFFFLL;
}
if ( (fh_log_lvl & 1) == 0 )
return 0xFFFFFFFFLL;
v12 = fh_log_fmt("unable to allocate memory for Arca line configuration list");
fh_log("fh_arca_cfg.c", 167LL, "CSI", "ERR", v12);
result = 0xFFFFFFFFLL;
}
else
{
if ( (fh_log_lvl & 1) == 0 )
return 0xFFFFFFFFLL;
v10 = fh_log_fmt("no configuration data for line: %s", a2);
fh_log("fh_arca_cfg.c", 159LL, "CSI", "ERR", v10);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static FH_STATUS fh_arca_cfg_add_line(const fh_cfg_node_t *config, char *line)
{
    char line_cfg_property[255];
    const fh_cfg_node_t *node = ((void *)0);
    fh_arca_cfg_line_t *line_cfg = ((void *)0);
    sprintf(line_cfg_property, "arca.lines.%s", line);
    node = fh_cfg_get_node(config, line_cfg_property);
    if (node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("no configuration data for line: %s", line); fh_log("fh_arca_cfg.c", 159, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    fh_arca_cfg.lines = (fh_arca_cfg_line_t *)realloc(fh_arca_cfg.lines, sizeof(fh_arca_cfg_line_t)
                                                      * (fh_arca_cfg.num_lines + 1));
    if (fh_arca_cfg.lines == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to allocate memory for Arca line configuration list"); fh_log("fh_arca_cfg.c", 167, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line_cfg = &fh_arca_cfg.lines[fh_arca_cfg.num_lines++];
    strcpy(&line_cfg->name[0], line);
    line_cfg->fast = fh_arca_cfg_yesno(fh_cfg_get_string(node, "fast"));
    if (fh_arca_cfg_load_connection(node, "primary", &line_cfg->primary) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to load primary connection information for line: %s", line); fh_log("fh_arca_cfg.c", 180, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (fh_arca_cfg_load_connection(node, "secondary", &line_cfg->secondary) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to load secondary connection information for line: %s", line); fh_log("fh_arca_cfg.c", 184, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line_cfg->maximum_sessions = (uint32_t) fh_arca_cfg.max_sessions;
    line_cfg->maximum_symbols = (uint32_t) fh_arca_cfg.max_symbols;
    line_cfg->maximum_firms = (uint32_t) fh_arca_cfg.max_firms;
    line_cfg->maximum_orders = (uint32_t) fh_arca_cfg.max_orders;
    return (0);
}

canonical_original_code:
static int fh_arca_cfg_add_line(struct fh_cfg_node *config, char *line)
{
    char line_cfg_property[255];
    struct fh_cfg_node *node = ((void *)0);
    struct fh_arca_cfg_line_t *line_cfg = ((void *)0);
    sprintf(line_cfg_property, "arca.lines.%s", line);
    node = fh_cfg_get_node(config, line_cfg_property);
    if (node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("no configuration data for line: %s", line); fh_log("fh_arca_cfg.c", 159, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    fh_arca_cfg.lines = (struct fh_arca_cfg_line_t *)realloc(fh_arca_cfg.lines, sizeof(fh_arca_cfg_line_t)
                                                      * (fh_arca_cfg.num_lines + 1));
    if (fh_arca_cfg.lines == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to allocate memory for Arca line configuration list"); fh_log("fh_arca_cfg.c", 167, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line_cfg = &fh_arca_cfg.lines[fh_arca_cfg.num_lines++];
    strcpy(&line_cfg->name[0], line);
    line_cfg->fast = fh_arca_cfg_yesno(fh_cfg_get_string(node, "fast"));
    if (fh_arca_cfg_load_connection(node, "primary", &line_cfg->primary) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to load primary connection information for line: %s", line); fh_log("fh_arca_cfg.c", 180, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (fh_arca_cfg_load_connection(node, "secondary", &line_cfg->secondary) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to load secondary connection information for line: %s", line); fh_log("fh_arca_cfg.c", 184, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    line_cfg->maximum_sessions = (unsigned int) fh_arca_cfg.max_sessions;
    line_cfg->maximum_symbols = (unsigned int) fh_arca_cfg.max_symbols;
    line_cfg->maximum_firms = (unsigned int) fh_arca_cfg.max_firms;
    line_cfg->maximum_orders = (unsigned int) fh_arca_cfg.max_orders;
    return (0);
}

variable_types:
line
char *

variable_types: struct fh_arca_cfg_line_t { char name[255]; struct fh_arca_cfg_connection_t { struct in_addr { unsigned int s_addr; } address; unsigned short port; char interface[16]; int enabled; } primary; struct fh_arca_cfg_connection_t secondary; int fast; int strict_ordering; unsigned int maximum_sessions; unsigned int maximum_symbols; unsigned int maximum_firms; unsigned int maximum_orders; } *


decompiled_code:
__int64 __fastcall fh_arca_cfg_load(__int64 a1, const char *a2)
{
__int64 v2; // rax
__int64 v3; // r13
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // rbx
__int64 result; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
char v17[296]; // [rsp+0h] [rbp-128h] BYREF

if ( !a1 )
{
v16 = fh_log_fmt("assertion '%s' failed at %s:%d", "config", "fh_arca_cfg.c", 210LL);
fh_log("fh_arca_cfg.c", 210LL, 0LL, "ERR", v16);
exit(1);
}
memset(fh_arca_cfg, 0, sizeof(fh_arca_cfg));
strcpy(fh_arca_cfg, a2);
sprintf(v17, "arca.processes.%s", a2);
v2 = fh_cfg_get_node(a1, v17);
v3 = v2;
if ( v2 )
{
if ( (unsigned int)fh_arca_cfg_get_long(v2, (__int64)"cpu", (__int64 *)&fh_arca_cfg[272]) )
{
if ( (fh_log_lvl & 1) != 0 )
{
v13 = fh_log_fmt("missing or invalid cpu configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 228LL, "CSI", "ERR", v13);
}
}
else
{
if ( (unsigned int)fh_arca_cfg_get_long(v3, (__int64)"index", (__int64 *)&fh_arca_cfg[280]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v9 = fh_log_fmt("missing or invalid index configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 232LL, "CSI", "WARN", v9);
}
*(_QWORD *)&fh_arca_cfg[280] = -1LL;
}
if ( (unsigned int)fh_arca_cfg_get_long(v3, (__int64)"max_sessions", (__int64 *)&fh_arca_cfg[288]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v10 = fh_log_fmt("missing or invalid max_sessions configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 236LL, "CSI", "WARN", v10);
}
*(_QWORD *)&fh_arca_cfg[288] = 10LL;
}
if ( (unsigned int)fh_arca_cfg_get_long(v3, (__int64)"max_symbols", (__int64 *)&fh_arca_cfg[296]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v11 = fh_log_fmt("missing or invalid max_symbols configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 240LL, "CSI", "WARN", v11);
}
*(_QWORD *)&fh_arca_cfg[296] = 20000LL;
}
if ( (unsigned int)fh_arca_cfg_get_long(v3, (__int64)"max_firms", (__int64 *)&fh_arca_cfg[304]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v12 = fh_log_fmt("missing or invalid max_firms configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 244LL, "CSI", "WARN", v12);
}
*(_QWORD *)&fh_arca_cfg[304] = 2000LL;
}
if ( (unsigned int)fh_arca_cfg_get_long(v3, (__int64)"max_orders", (__int64 *)&fh_arca_cfg[312]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v8 = fh_log_fmt("missing or invalid max_orders configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 248LL, "CSI", "WARN", v8);
}
*(_QWORD *)&fh_arca_cfg[312] = 10000000LL;
}
v4 = fh_cfg_get_node(v3, "lines");
v5 = v4;
if ( v4 && *(int *)(v4 + 284) > 0 )
{
v6 = 0LL;
while ( 1 )
{
result = fh_arca_cfg_add_line(a1, *(const char **)(*(_QWORD *)(v5 + 272) + 8 * v6));
if ( (_DWORD)result )
break;
if ( *(_DWORD *)(v5 + 284) <= (int)++v6 )
return result;
}
}
else if ( (fh_log_lvl & 1) != 0 )
{
v14 = fh_log_fmt("you must specify at least one line per process: %s", a2);
fh_log("fh_arca_cfg.c", 255LL, "CSI", "ERR", v14);
return 0xFFFFFFFFLL;
}
}
}
else if ( (fh_log_lvl & 1) != 0 )
{
v15 = fh_log_fmt("no configuration data for process: %s", a2);
fh_log("fh_arca_cfg.c", 222LL, "CSI", "ERR", v15);
return 0xFFFFFFFFLL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2)
{
__int64 v2; // rax
__int64 v3; // r13
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // rbx
__int64 result; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
char v17[296]; // [rsp+0h] [rbp-128h] BYREF

if ( !a1 )
{
v16 = fh_log_fmt("assertion '%s' failed at %s:%d", "config", "fh_arca_cfg.c", 210LL);
fh_log("fh_arca_cfg.c", 210LL, 0LL, "ERR", v16);
exit(1);
}
memset(fh_arca_cfg, 0, sizeof(fh_arca_cfg));
strcpy(fh_arca_cfg, a2);
sprintf(v17, "arca.processes.%s", a2);
v2 = fh_cfg_get_node(a1, v17);
v3 = v2;
if ( v2 )
{
if ( (unsigned int)func0(v2, (__int64)"cpu", (__int64 *)&fh_arca_cfg[272]) )
{
if ( (fh_log_lvl & 1) != 0 )
{
v13 = fh_log_fmt("missing or invalid cpu configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 228LL, "CSI", "ERR", v13);
}
}
else
{
if ( (unsigned int)func0(v3, (__int64)"index", (__int64 *)&fh_arca_cfg[280]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v9 = fh_log_fmt("missing or invalid index configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 232LL, "CSI", "WARN", v9);
}
*(_QWORD *)&fh_arca_cfg[280] = -1LL;
}
if ( (unsigned int)func0(v3, (__int64)"max_sessions", (__int64 *)&fh_arca_cfg[288]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v10 = fh_log_fmt("missing or invalid max_sessions configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 236LL, "CSI", "WARN", v10);
}
*(_QWORD *)&fh_arca_cfg[288] = 10LL;
}
if ( (unsigned int)func0(v3, (__int64)"max_symbols", (__int64 *)&fh_arca_cfg[296]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v11 = fh_log_fmt("missing or invalid max_symbols configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 240LL, "CSI", "WARN", v11);
}
*(_QWORD *)&fh_arca_cfg[296] = 20000LL;
}
if ( (unsigned int)func0(v3, (__int64)"max_firms", (__int64 *)&fh_arca_cfg[304]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v12 = fh_log_fmt("missing or invalid max_firms configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 244LL, "CSI", "WARN", v12);
}
*(_QWORD *)&fh_arca_cfg[304] = 2000LL;
}
if ( (unsigned int)func0(v3, (__int64)"max_orders", (__int64 *)&fh_arca_cfg[312]) )
{
if ( (fh_log_lvl & 2) != 0 )
{
v8 = fh_log_fmt("missing or invalid max_orders configuration parameter: %s", a2);
fh_log("fh_arca_cfg.c", 248LL, "CSI", "WARN", v8);
}
*(_QWORD *)&fh_arca_cfg[312] = 10000000LL;
}
v4 = fh_cfg_get_node(v3, "lines");
v5 = v4;
if ( v4 && *(int *)(v4 + 284) > 0 )
{
v6 = 0LL;
while ( 1 )
{
result = func3(a1, *(const char **)(*(_QWORD *)(v5 + 272) + 8 * v6));
if ( (_DWORD)result )
break;
if ( *(_DWORD *)(v5 + 284) <= (int)++v6 )
return result;
}
}
else if ( (fh_log_lvl & 1) != 0 )
{
v14 = fh_log_fmt("you must specify at least one line per process: %s", a2);
fh_log("fh_arca_cfg.c", 255LL, "CSI", "ERR", v14);
return 0xFFFFFFFFLL;
}
}
}
else if ( (fh_log_lvl & 1) != 0 )
{
v15 = fh_log_fmt("no configuration data for process: %s", a2);
fh_log("fh_arca_cfg.c", 222LL, "CSI", "ERR", v15);
return 0xFFFFFFFFLL;
}
return 0xFFFFFFFFLL;
}

original_code:
FH_STATUS fh_arca_cfg_load(const fh_cfg_node_t *config, const char *process)
{
    int i;
    char property[255];
    const fh_cfg_node_t *node = ((void *)0);
    do { int nok = !(config); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "config", "fh_arca_cfg.c", 210); fh_log("fh_arca_cfg.c", 210, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    memset((void *)&fh_arca_cfg, 0, sizeof(fh_arca_cfg));
    strcpy(fh_arca_cfg.name, process);
    sprintf(property, "arca.processes.%s", process);
    node = fh_cfg_get_node(config, property);
    if (node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("no configuration data for process: %s", process); fh_log("fh_arca_cfg.c", 222, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (fh_arca_cfg_get_long(node, "cpu", &fh_arca_cfg.cpu) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid cpu configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 228, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (fh_arca_cfg_get_long(node, "index", &fh_arca_cfg.index) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid index configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 232, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.index = -1;
    }
    if (fh_arca_cfg_get_long(node, "max_sessions", &fh_arca_cfg.max_sessions) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_sessions configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 236, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_sessions = 10;
    }
    if (fh_arca_cfg_get_long(node, "max_symbols", &fh_arca_cfg.max_symbols) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_symbols configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 240, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_symbols = 20000;
    }
    if (fh_arca_cfg_get_long(node, "max_firms", &fh_arca_cfg.max_firms) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_firms configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 244, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_firms = 2000;
    }
    if (fh_arca_cfg_get_long(node, "max_orders", &fh_arca_cfg.max_orders) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_orders configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 248, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_orders = 10000000;
    }
    node = fh_cfg_get_node(node, "lines");
    if (node == ((void *)0) || node->num_values <= 0) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("you must specify at least one line per process: %s", process); fh_log("fh_arca_cfg.c", 255, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    for (i = 0; i < node->num_values; i++) {
        if(fh_arca_cfg_add_line(config, node->values[i]) != (0)) return (-1);
    }
    return (0);
}

canonical_original_code:
int fh_arca_cfg_load(struct fh_cfg_node *config, char *process)
{
    int i;
    char property[255];
    struct fh_cfg_node *node = ((void *)0);
    do { int nok = !(config); if (nok) { char *_msg = fh_log_fmt("assertion '%s' failed at %s:%d", "config", "fh_arca_cfg.c", 210); fh_log("fh_arca_cfg.c", 210, ((void *)0), "ERR", _msg); exit(1); } } while (0);
    memset((void *)&fh_arca_cfg, 0, sizeof(fh_arca_cfg));
    strcpy(fh_arca_cfg.name, process);
    sprintf(property, "arca.processes.%s", process);
    node = fh_cfg_get_node(config, property);
    if (node == ((void *)0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("no configuration data for process: %s", process); fh_log("fh_arca_cfg.c", 222, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (fh_arca_cfg_get_long(node, "cpu", &fh_arca_cfg.cpu) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("missing or invalid cpu configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 228, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    if (fh_arca_cfg_get_long(node, "index", &fh_arca_cfg.index) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid index configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 232, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.index = -1;
    }
    if (fh_arca_cfg_get_long(node, "max_sessions", &fh_arca_cfg.max_sessions) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_sessions configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 236, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_sessions = 10;
    }
    if (fh_arca_cfg_get_long(node, "max_symbols", &fh_arca_cfg.max_symbols) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_symbols configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 240, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_symbols = 20000;
    }
    if (fh_arca_cfg_get_long(node, "max_firms", &fh_arca_cfg.max_firms) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_firms configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 244, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_firms = 2000;
    }
    if (fh_arca_cfg_get_long(node, "max_orders", &fh_arca_cfg.max_orders) != (0)) {
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("missing or invalid max_orders configuration parameter: %s", process); fh_log("fh_arca_cfg.c", 248, "CSI", "WARN", _msg); } } while (0);
        fh_arca_cfg.max_orders = 10000000;
    }
    node = fh_cfg_get_node(node, "lines");
    if (node == ((void *)0) || node->num_values <= 0) {
        do { if ((fh_log_lvl[(0)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("you must specify at least one line per process: %s", process); fh_log("fh_arca_cfg.c", 255, "CSI", "ERR", _msg); } } while (0);
        return (-1);
    }
    for (i = 0; i < node->num_values; i++) {
        if(fh_arca_cfg_add_line(config, node->values[i]) != (0)) return (-1);
    }
    return (0);
}

variable_types:
process
char *

variable_types: i int

variable_types:
property
char [255]

variable_types: nok int


original_code:
void fh_arca_cfg_dump()
{
    fh_arca_cfg_process_t *config = &fh_arca_cfg;
    register uint32_t i;
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 276, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Arca Process Configuration:"); fh_log("fh_arca_cfg.c", 277, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 278, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Name         : %s", config->name); fh_log("fh_arca_cfg.c", 279, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> CPU          : %d", config->cpu); fh_log("fh_arca_cfg.c", 280, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Sessions : %d", config->max_sessions); fh_log("fh_arca_cfg.c", 281, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Symbols  : %d", config->max_symbols); fh_log("fh_arca_cfg.c", 282, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Firms    : %d", config->max_firms); fh_log("fh_arca_cfg.c", 283, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Orders   : %d", config->max_orders); fh_log("fh_arca_cfg.c", 284, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 285, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Process Lines:"); fh_log("fh_arca_cfg.c", 286, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 287, ((void *)0), "DIAG", _msg); } while (0);
    for (i = 0; i < config->num_lines; i++) {
        fh_arca_cfg_line_t *line = &config->lines[i];
        do { char *_msg = fh_log_fmt ("> %s (fast: %s)", line->name, ((line->fast) ? "yes" : "no")); fh_log("fh_arca_cfg.c", 291, ((void *)0), "DIAG", _msg); } while (0);
        do { char *_msg = fh_log_fmt ("    + primary   - %s:%d @ %s - %s", inet_ntoa(line->primary.address), line->primary.port, line->primary.interface, ((line->primary.enabled) ? "enabled " : "disabled")); fh_log("fh_arca_cfg.c", 293, ((void *)0), "DIAG", _msg); } while (0);
        do { char *_msg = fh_log_fmt ("    + secondary - %s:%d @ %s - %s", inet_ntoa(line->secondary.address), line->secondary.port, line->secondary.interface, ((line->secondary.enabled) ? "enabled " : "disabled")); fh_log("fh_arca_cfg.c", 296, ((void *)0), "DIAG", _msg); } while (0);
    }
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 301, ((void *)0), "DIAG", _msg); } while (0);
}

canonical_original_code:
void fh_arca_cfg_dump()
{
    struct fh_arca_cfg_process_t *config = &fh_arca_cfg;
    register unsigned int i;
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 276, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Arca Process Configuration:"); fh_log("fh_arca_cfg.c", 277, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 278, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Name         : %s", config->name); fh_log("fh_arca_cfg.c", 279, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> CPU          : %d", config->cpu); fh_log("fh_arca_cfg.c", 280, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Sessions : %d", config->max_sessions); fh_log("fh_arca_cfg.c", 281, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Symbols  : %d", config->max_symbols); fh_log("fh_arca_cfg.c", 282, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Firms    : %d", config->max_firms); fh_log("fh_arca_cfg.c", 283, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Max Orders   : %d", config->max_orders); fh_log("fh_arca_cfg.c", 284, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 285, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("> Process Lines:"); fh_log("fh_arca_cfg.c", 286, ((void *)0), "DIAG", _msg); } while (0);
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 287, ((void *)0), "DIAG", _msg); } while (0);
    for (i = 0; i < config->num_lines; i++) {
        struct fh_arca_cfg_line_t *line = &config->lines[i];
        do { char *_msg = fh_log_fmt ("> %s (fast: %s)", line->name, ((line->fast) ? "yes" : "no")); fh_log("fh_arca_cfg.c", 291, ((void *)0), "DIAG", _msg); } while (0);
        do { char *_msg = fh_log_fmt ("    + primary   - %s:%d @ %s - %s", inet_ntoa(line->primary.address), line->primary.port, line->primary.interface, ((line->primary.enabled) ? "enabled " : "disabled")); fh_log("fh_arca_cfg.c", 293, ((void *)0), "DIAG", _msg); } while (0);
        do { char *_msg = fh_log_fmt ("    + secondary - %s:%d @ %s - %s", inet_ntoa(line->secondary.address), line->secondary.port, line->secondary.interface, ((line->secondary.enabled) ? "enabled " : "disabled")); fh_log("fh_arca_cfg.c", 296, ((void *)0), "DIAG", _msg); } while (0);
    }
    do { char *_msg = fh_log_fmt ("--------------------------------------------------------"); fh_log("fh_arca_cfg.c", 301, ((void *)0), "DIAG", _msg); } while (0);
}

variable_types: struct fh_arca_cfg_process_t { char name[255]; struct fh_arca_cfg_line_t { char name[255]; struct fh_arca_cfg_connection_t { struct in_addr { unsigned int s_addr; } address; unsigned short port; char interface[16]; int enabled; } primary; struct fh_arca_cfg_connection_t secondary; int fast; int strict_ordering; unsigned int maximum_sessions; unsigned int maximum_symbols; unsigned int maximum_firms; unsigned int maximum_orders; } *lines; unsigned short num_lines; long cpu; long index; long max_sessions; long max_symbols; long max_firms; long max_orders; } *

variable_types:
i
unsigned int

user_defined_types: struct fh_arca_cfg_process_t { char name[255]; struct fh_arca_cfg_line_t *lines; unsigned short num_lines; long cpu; long index; long max_sessions; long max_symbols; long max_firms; long max_orders; }


decompiled_code:
__int64 fh_shr_mmcast_exit()
{
fh_shr_mgmt_exit();
return fh_shr_lh_exit();
}

canonical_decompiled_code:
__int64 func0()
{
fh_shr_mgmt_exit();
return fh_shr_lh_exit();
}

original_code:
void fh_shr_mmcast_exit()
{
    fh_shr_mgmt_exit();
    fh_shr_lh_exit();
}


decompiled_code:
__int128 *fh_shr_mmcast_status()
{
if ( !DWORD2(proc_info) )
DWORD2(proc_info) = fh_shr_lh_get_tid();
return &proc_info;
}

canonical_decompiled_code:
__int128 *func1()
{
if ( !DWORD2(proc_info) )
DWORD2(proc_info) = fh_shr_lh_get_tid();
return &proc_info;
}

original_code:
fh_info_proc_t *fh_shr_mmcast_status()
{
    if (proc_info.tid <= 0) {
        proc_info.tid = fh_shr_lh_get_tid();
    }
    return &proc_info;
}

canonical_original_code:
struct fh_info_proc *fh_shr_mmcast_status()
{
    if (proc_info.tid <= 0) {
        proc_info.tid = fh_shr_lh_get_tid();
    }
    return &proc_info;
}

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


decompiled_code:
void __fastcall fh_shr_mmcast_sig_handle(unsigned int a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax

switch ( a1 )
{
case 2u:
if ( (fh_log_lvl & 2) != 0 )
{
v3 = fh_log_fmt("SIGINT caught - exiting - ");
fh_log("fh_shr_mmcast.c", 70LL, "CSI", "WARN", v3);
}
break;
case 0xFu:
if ( (fh_log_lvl & 2) != 0 )
{
v2 = fh_log_fmt("SIGTERM caught - exiting - ");
fh_log("fh_shr_mmcast.c", 62LL, "CSI", "WARN", v2);
}
break;
case 1u:
if ( (fh_log_lvl & 2) != 0 )
{
v1 = fh_log_fmt("SIGHUP caught - exiting - ");
fh_log("fh_shr_mmcast.c", 66LL, "CSI", "WARN", v1);
}
break;
default:
if ( (fh_log_lvl & 2) != 0 )
{
v4 = fh_log_fmt("unhandled signal received: %d", a1);
fh_log("fh_shr_mmcast.c", 74LL, "CSI", "WARN", v4);
}
break;
}
fh_shr_mmcast_exit();
}

canonical_decompiled_code:
void __fastcall func2(unsigned int a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax

switch ( a1 )
{
case 2u:
if ( (fh_log_lvl & 2) != 0 )
{
v3 = fh_log_fmt("SIGINT caught - exiting - ");
fh_log("fh_shr_mmcast.c", 70LL, "CSI", "WARN", v3);
}
break;
case 0xFu:
if ( (fh_log_lvl & 2) != 0 )
{
v2 = fh_log_fmt("SIGTERM caught - exiting - ");
fh_log("fh_shr_mmcast.c", 62LL, "CSI", "WARN", v2);
}
break;
case 1u:
if ( (fh_log_lvl & 2) != 0 )
{
v1 = fh_log_fmt("SIGHUP caught - exiting - ");
fh_log("fh_shr_mmcast.c", 66LL, "CSI", "WARN", v1);
}
break;
default:
if ( (fh_log_lvl & 2) != 0 )
{
v4 = fh_log_fmt("unhandled signal received: %d", a1);
fh_log("fh_shr_mmcast.c", 74LL, "CSI", "WARN", v4);
}
break;
}
func0();
}

original_code:
static void fh_shr_mmcast_sig_handle(int32_t signo)
{
    switch (signo) {
    case 15:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("SIGTERM caught - exiting - "); fh_log("fh_shr_mmcast.c", 62, "CSI", "WARN", _msg); } } while (0);
        break;
    case 1:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("SIGHUP caught - exiting - "); fh_log("fh_shr_mmcast.c", 66, "CSI", "WARN", _msg); } } while (0);
        break;
    case 2:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("SIGINT caught - exiting - "); fh_log("fh_shr_mmcast.c", 70, "CSI", "WARN", _msg); } } while (0);
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("unhandled signal received: %d", signo); fh_log("fh_shr_mmcast.c", 74, "CSI", "WARN", _msg); } } while (0);
    }
    fh_shr_mmcast_exit();
}

canonical_original_code:
static void fh_shr_mmcast_sig_handle(int signo)
{
    switch (signo) {
    case 15:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("SIGTERM caught - exiting - "); fh_log("fh_shr_mmcast.c", 62, "CSI", "WARN", _msg); } } while (0);
        break;
    case 1:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("SIGHUP caught - exiting - "); fh_log("fh_shr_mmcast.c", 66, "CSI", "WARN", _msg); } } while (0);
        break;
    case 2:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("SIGINT caught - exiting - "); fh_log("fh_shr_mmcast.c", 70, "CSI", "WARN", _msg); } } while (0);
        break;
    default:
        do { if ((fh_log_lvl[(0)] & ((0x00000002)))) { char *_msg = fh_log_fmt ("unhandled signal received: %d", signo); fh_log("fh_shr_mmcast.c", 74, "CSI", "WARN", _msg); } } while (0);
    }
    fh_shr_mmcast_exit();
}

variable_types: signo int


decompiled_code:
__sighandler_t fh_shr_mmcast_sig_init()
{
__sighandler_t result; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax

if ( signal(2, (__sighandler_t)fh_shr_mmcast_sig_handle) == (__sighandler_t)-1LL )
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v3 = fh_log_fmt("unable to register for SIGINT...exiting");
fh_log("fh_shr_mmcast.c", 87LL, "LH", "ERR", v3);
}
LABEL_7:
exit(1);
}
if ( signal(1, (__sighandler_t)fh_shr_mmcast_sig_handle) == (__sighandler_t)-1LL )
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v2 = fh_log_fmt("unable to register for SIGHUP...exiting");
fh_log("fh_shr_mmcast.c", 92LL, "LH", "ERR", v2);
}
goto LABEL_7;
}
result = signal(15, (__sighandler_t)fh_shr_mmcast_sig_handle);
if ( result == (__sighandler_t)-1LL )
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v1 = fh_log_fmt("unable to register for SIGTERM...exiting");
fh_log("fh_shr_mmcast.c", 97LL, "LH", "ERR", v1);
}
goto LABEL_7;
}
return result;
}

canonical_decompiled_code:
__sighandler_t func3()
{
__sighandler_t result; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax

if ( signal(2, (__sighandler_t)fh_shr_mmcast_sig_handle) == (__sighandler_t)-1LL )
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v3 = fh_log_fmt("unable to register for SIGINT...exiting");
fh_log("fh_shr_mmcast.c", 87LL, "LH", "ERR", v3);
}
LABEL_7:
exit(1);
}
if ( signal(1, (__sighandler_t)fh_shr_mmcast_sig_handle) == (__sighandler_t)-1LL )
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v2 = fh_log_fmt("unable to register for SIGHUP...exiting");
fh_log("fh_shr_mmcast.c", 92LL, "LH", "ERR", v2);
}
goto LABEL_7;
}
result = signal(15, (__sighandler_t)fh_shr_mmcast_sig_handle);
if ( result == (__sighandler_t)-1LL )
{
if ( (fh_log_lvl[8] & 1) != 0 )
{
v1 = fh_log_fmt("unable to register for SIGTERM...exiting");
fh_log("fh_shr_mmcast.c", 97LL, "LH", "ERR", v1);
}
goto LABEL_7;
}
return result;
}

original_code:
static void fh_shr_mmcast_sig_init()
{
    if (signal(2, fh_shr_mmcast_sig_handle) == ((__sighandler_t) -1)) {
        do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to register for SIGINT...exiting"); fh_log("fh_shr_mmcast.c", 87, "LH", "ERR", _msg); } } while (0);
        exit(1);
    }
    if (signal(1, fh_shr_mmcast_sig_handle) == ((__sighandler_t) -1)) {
        do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to register for SIGHUP...exiting"); fh_log("fh_shr_mmcast.c", 92, "LH", "ERR", _msg); } } while (0);
        exit(1);
    }
    if (signal(15, fh_shr_mmcast_sig_handle) == ((__sighandler_t) -1)) {
        do { if ((fh_log_lvl[(2)] & ((0x00000001)))) { char *_msg = fh_log_fmt ("unable to register for SIGTERM...exiting"); fh_log("fh_shr_mmcast.c", 97, "LH", "ERR", _msg); } } while (0);
        exit(1);
    }
}


decompiled_code:
__int64 __fastcall fh_shr_mmcast_version(__int64 a1, __int64 a2)
{
__int64 result; // rax

fh_info_version_msg();
result = *(unsigned int *)(a2 + 8);
if ( (_DWORD)result )
exit(0);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax

fh_info_version_msg();
result = *(unsigned int *)(a2 + 8);
if ( (_DWORD)result )
exit(0);
return result;
}

original_code:
void fh_shr_mmcast_version(const fh_info_build_t *info, fh_shr_cfg_options_t *options)
{
    fh_info_version_msg(info);
    if (options->display_version) {
        exit(0);
    }
}

canonical_original_code:
void fh_shr_mmcast_version(struct fh_info_build *info, struct fh_shr_cfg_options_t *options)
{
    fh_info_version_msg(info);
    if (options->display_version) {
        exit(0);
    }
}

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: struct fh_shr_cfg_options_t { int standalone; int debug_level; int display_version; int version; char process[255]; char logging_tag[255]; char config_file[-1]; char plugin_path[-1]; char *program_name; } *