decompiled_code:
__int64 qsa_initialize()
{
_DWORD *v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // r8
const char *v5; // r12
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
const char *v9; // r12
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi
__int64 v12; // rcx
const char *v13; // r9
const char *v14; // [rsp-10h] [rbp-28h]
const char *v15; // [rsp-8h] [rbp-20h]
const char *v16; // [rsp+0h] [rbp-18h]

if ( init )
{
if ( *(int *)init > 0 )
{
++*(_DWORD *)init;
return 0LL;
}
}
else
{
v1 = (_DWORD *)shm_malloc_constprop_0();
init = (__int64)v1;
if ( !v1 )
return 0xFFFFFFFFLL;
*v1 = 0;
}
if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): init the content\n",
process_no,
v6,
v5,
"<core> [qsa.c:55]: ",
"qsa_initialize");
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): init the content\n", v8, log_color, v14, v15, v16);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): init the content\n",
*((const char **)&log_level_info + 16),
"<core> [qsa.c:55]: ",
"qsa_initialize");
}
--dprint_crit;
}
v2 = init;
v3 = create_domain_maintainer();
v4 = init;
*(_QWORD *)(v2 + 8) = v3;
if ( *(_QWORD *)(v4 + 8) )
{
++*(_DWORD *)v4;
return 0LL;
}
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): qsa_initialize error - can't initialize domain maintainer\n",
process_no,
v10,
v9,
"<core> [qsa.c:60]: ",
"qsa_initialize");
if ( log_color )
dprint_color_reset(
v11,
"%2d(%d) %s: %s%s(): qsa_initialize error - can't initialize domain maintainer\n",
v15,
v12,
(const char *)log_color,
v13,
v16);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): qsa_initialize error - can't initialize domain maintainer\n",
*((const char **)&log_level_info + 8),
"<core> [qsa.c:60]: ",
"qsa_initialize");
}
--dprint_crit;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func5()
{
_DWORD *v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // r8
const char *v5; // r12
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
const char *v9; // r12
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi
__int64 v12; // rcx
const char *v13; // r9
const char *v14; // [rsp-10h] [rbp-28h]
const char *v15; // [rsp-8h] [rbp-20h]
const char *v16; // [rsp+0h] [rbp-18h]

if ( init )
{
if ( *(int *)init > 0 )
{
++*(_DWORD *)init;
return 0LL;
}
}
else
{
v1 = (_DWORD *)func4();
init = (__int64)v1;
if ( !v1 )
return 0xFFFFFFFFLL;
*v1 = 0;
}
if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): init the content\n",
process_no,
v6,
v5,
"<core> [qsa.c:55]: ",
"qsa_initialize");
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): init the content\n", v8, log_color, v14, v15, v16);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): init the content\n",
*((const char **)&log_level_info + 16),
"<core> [qsa.c:55]: ",
"qsa_initialize");
}
--dprint_crit;
}
v2 = init;
v3 = create_domain_maintainer();
v4 = init;
*(_QWORD *)(v2 + 8) = v3;
if ( *(_QWORD *)(v4 + 8) )
{
++*(_DWORD *)v4;
return 0LL;
}
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): qsa_initialize error - can't initialize domain maintainer\n",
process_no,
v10,
v9,
"<core> [qsa.c:60]: ",
"qsa_initialize");
if ( log_color )
dprint_color_reset(
v11,
"%2d(%d) %s: %s%s(): qsa_initialize error - can't initialize domain maintainer\n",
v15,
v12,
(const char *)log_color,
v13,
v16);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): qsa_initialize error - can't initialize domain maintainer\n",
*((const char **)&log_level_info + 8),
"<core> [qsa.c:60]: ",
"qsa_initialize");
}
--dprint_crit;
}
return 0xFFFFFFFFLL;
}

original_code:
int qsa_initialize()
{
 int res = 0;
 if (!init) {
  init = (init_data_t*)shm_malloc(sizeof(init_data_t));
  if (!init) return -1;
  init->init_cnt = 0;
 }
 if (init->init_cnt > 0) {
  init->init_cnt++;
  return 0;
 }
 else {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "init the content\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "init the content\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "init the content\n", process_no, my_pid(), ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "init the content\n", ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "init the content\n", ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  init->dm = create_domain_maintainer();
  if (!init->dm) {
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", process_no, my_pid(), ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   res = -1;
  }
 }
 if (res == 0) init->init_cnt++;
 return res;
}

canonical_original_code:
int qsa_initialize()
{
 int res = 0;
 if (!init) {
  init = (struct init_data_t *)shm_malloc(sizeof(init_data_t));
  if (!init) return -1;
  init->init_cnt = 0;
 }
 if (init->init_cnt > 0) {
  init->init_cnt++;
  return 0;
 }
 else {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "init the content\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "init the content\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "init the content\n", process_no, my_pid(), ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "init the content\n", ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "init the content\n", ("<core> [" "qsa.c" ":" "55" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  init->dm = create_domain_maintainer();
  if (!init->dm) {
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", process_no, my_pid(), ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize error - can't initialize domain maintainer\n", ("<core> [" "qsa.c" ":" "60" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   res = -1;
  }
 }
 if (res == 0) init->init_cnt++;
 return res;
}

variable_types: res int

user_defined_types: struct init_data_t { int init_cnt; struct domain_maintainer_t *dm; }

user_defined_types: struct domain_maintainer_t { struct vector_t registered_domains; struct reference_counter_group_t *rc_grp; struct atomic_t mutex; }

user_defined_types: struct vector_t { int element_size; int element_count; int allocated_count; int allocation_count; void *data; }

user_defined_types: struct reference_counter_group_t { int mutex_cnt; int mutex_to_assign; struct atomic_t mutexes[1]; }


repo: virtualolson/who

decompiled_code:
void __fastcall qsa_cleanup()
{
const char *v0; // rbx
__int64 v2; // rbp
const char *v3; // r12
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
const char *v6; // r8
const char *v7; // r9
__int64 v8; // [rsp-20h] [rbp-20h]

if ( init )
{
if ( (*(_DWORD *)init)-- == 1 )
{
if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 16);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): cleaning the content\n",
process_no,
v4,
v3,
"<core> [qsa.c:73]: ",
"qsa_cleanup");
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): cleaning the content\n", v8, log_color, v6, v7, v0);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): cleaning the content\n",
*((const char **)&log_level_info + 16),
"<core> [qsa.c:73]: ",
"qsa_cleanup");
}
--dprint_crit;
}
v2 = init;
if ( *(_QWORD *)(init + 8) )
{
destroy_domain_maintainer();
v2 = init;
}
futex_get(mem_lock);
qm_free(shm_block, v2);
futex_release(mem_lock);
init = 0LL;
}
}
}

canonical_decompiled_code:
void __fastcall func6()
{
const char *v0; // rbx
__int64 v2; // rbp
const char *v3; // r12
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
const char *v6; // r8
const char *v7; // r9
__int64 v8; // [rsp-20h] [rbp-20h]

if ( init )
{
if ( (*(_DWORD *)init)-- == 1 )
{
if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 16);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): cleaning the content\n",
process_no,
v4,
v3,
"<core> [qsa.c:73]: ",
"qsa_cleanup");
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): cleaning the content\n", v8, log_color, v6, v7, v0);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): cleaning the content\n",
*((const char **)&log_level_info + 16),
"<core> [qsa.c:73]: ",
"qsa_cleanup");
}
--dprint_crit;
}
v2 = init;
if ( *(_QWORD *)(init + 8) )
{
destroy_domain_maintainer();
v2 = init;
}
func3(mem_lock);
qm_free(shm_block, v2);
func1(mem_lock);
init = 0LL;
}
}
}

original_code:
void qsa_cleanup()
{
 if (init) {
  if (--init->init_cnt == 0) {
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "cleaning the content\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "qsa.c" ":" "73" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "cleaning the content\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "qsa.c" ":" "73" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "cleaning the content\n", process_no, my_pid(), ("<core> [" "qsa.c" ":" "73" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "cleaning the content\n", ("<core> [" "qsa.c" ":" "73" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "cleaning the content\n", ("<core> [" "qsa.c" ":" "73" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   if (init->dm) destroy_domain_maintainer(init->dm);
   do { futex_get(mem_lock); qm_free(shm_block, (init)); futex_release(mem_lock); }while(0);
   init = ((void *)0);
  }
 }
}

return_type: void

user_defined_types: struct cfg_group_core { int debug; int log_facility; int memdbg; int use_dst_blacklist; unsigned int blst_timeout; unsigned int blst_max_mem; unsigned int blst_udp_imask; unsigned int blst_tcp_imask; unsigned int blst_tls_imask; unsigned int blst_sctp_imask; int dns_try_ipv6; int dns_try_naptr; int dns_udp_pref; int dns_tcp_pref; int dns_tls_pref; int dns_sctp_pref; int dns_retr_time; int dns_retr_no; int dns_servers_no; int dns_search_list; int dns_search_fmatch; int dns_reinit; int use_dns_cache; int dns_cache_flags; int use_dns_failover; int dns_srv_lb; unsigned int dns_neg_cache_ttl; unsigned int dns_cache_min_ttl; unsigned int dns_cache_max_ttl; unsigned int dns_cache_max_mem; int dns_cache_del_nonexp; int dns_cache_rec_pref; int mem_dump_pkg; int mem_dump_shm; int max_while_loops; int udp_mtu; int udp_mtu_try_proto; int udp4_raw; int udp4_raw_mtu; int udp4_raw_ttl; int force_rport; int memlog; int mem_summary; int mem_safety; int mem_join; int corelog; int latency_log; int latency_limit_db; int latency_limit_action; }


decompiled_code:
__int64 __fastcall qsa_register_domain(__int64 a1)
{
const char *v1; // rbx
__int64 v3; // rdi
__int64 result; // rax
const char *v5; // r12
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
const char *v8; // r8
const char *v9; // r9
__int64 v10; // [rsp-20h] [rbp-20h]

if ( init )
{
v3 = *(_QWORD *)(init + 8);
if ( v3 )
result = register_notifier_domain(v3, a1);
else
result = 0LL;
}
else
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): qsa_initialize was not called - can't register domain\n",
process_no,
v6,
v5,
"<core> [qsa.c:89]: ",
"qsa_register_domain");
if ( log_color )
dprint_color_reset(
v7,
"%2d(%d) %s: %s%s(): qsa_initialize was not called - can't register domain\n",
v10,
log_color,
v8,
v9,
v1);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): qsa_initialize was not called - can't register domain\n",
*((const char **)&log_level_info + 8),
"<core> [qsa.c:89]: ",
"qsa_register_domain");
}
--dprint_crit;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
const char *v1; // rbx
__int64 v3; // rdi
__int64 result; // rax
const char *v5; // r12
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
const char *v8; // r8
const char *v9; // r9
__int64 v10; // [rsp-20h] [rbp-20h]

if ( init )
{
v3 = *(_QWORD *)(init + 8);
if ( v3 )
result = register_notifier_domain(v3, a1);
else
result = 0LL;
}
else
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): qsa_initialize was not called - can't register domain\n",
process_no,
v6,
v5,
"<core> [qsa.c:89]: ",
"qsa_register_domain");
if ( log_color )
dprint_color_reset(
v7,
"%2d(%d) %s: %s%s(): qsa_initialize was not called - can't register domain\n",
v10,
log_color,
v8,
v9,
v1);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): qsa_initialize was not called - can't register domain\n",
*((const char **)&log_level_info + 8),
"<core> [qsa.c:89]: ",
"qsa_register_domain");
}
--dprint_crit;
}
result = 0LL;
}
return result;
}

original_code:
notifier_domain_t *qsa_register_domain(const str_t *name)
{
 notifier_domain_t *d = ((void *)0);
 if (!init) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "qsa_initialize was not called - can't register domain\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "qsa_initialize was not called - can't register domain\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "qsa_initialize was not called - can't register domain\n", process_no, my_pid(), ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize was not called - can't register domain\n", ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize was not called - can't register domain\n", ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return ((void *)0);
 }
 if (init->dm) d = register_notifier_domain(init->dm, name);
 return d;
}

canonical_original_code:
struct _notifier_domain_t *qsa_register_domain(struct _str *name)
{
 struct _notifier_domain_t *d = ((void *)0);
 if (!init) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "qsa_initialize was not called - can't register domain\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "qsa_initialize was not called - can't register domain\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "qsa_initialize was not called - can't register domain\n", process_no, my_pid(), ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize was not called - can't register domain\n", ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "qsa_initialize was not called - can't register domain\n", ("<core> [" "qsa.c" ":" "89" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return ((void *)0);
 }
 if (init->dm) d = register_notifier_domain(init->dm, name);
 return d;
}

variable_types:
name
struct _str *

variable_types: struct _notifier_domain_t { struct atomic_t { int val; } mutex; struct atomic_t data_mutex; struct _str { char *s; int len; } name; struct _notifier_package_t { struct _str name; struct _notifier_domain_t *domain; struct _notifier_t { int (*subscribe)(struct _notifier_t *n, struct _qsa_subscription_t { struct atomic_t *mutex; struct _notifier_package_t *package; int allow_notifications; struct _qsa_subscription_data_t { struct msg_queue { struct reference_counter_data_t { int cntr; struct atomic_t *mutex; } ref; struct _mq_message_t { void *data; int data_len; struct _mq_message_t *next; void (*destroy_function)(void *); enum { message_allocated_with_data=0, message_holding_data_ptr=1 } allocation_style; char data_buf[1]; } *first; struct _mq_message_t *last; struct atomic_t q_mutex; unsigned int flags; } *dst; struct _str record_id; struct _str subscriber_id; struct _qsa_subscription_params_t { struct _str name; struct _str value; char buf[1]; } *first_param; void *subscriber_data; } *data; struct _qsa_subscription_t *prev; struct reference_counter_data_t ref; } *subscription); void (*unsubscribe)(struct _notifier_t *n, struct _qsa_subscription_t *subscription); void *user_data; struct _notifier_package_t *package; struct _notifier_t *prev; } *first_notifier; struct _qsa_subscription_t *first_subscription; struct _notifier_package_t *next; } *first_package; struct _qsa_content_type_t { struct _qsa_content_type_t *next; struct _str name; void (*destroy_func)(void *); char buf[1]; } *first_content_type; struct reference_counter_data_t ref; struct reference_counter_group_t { int mutex_cnt; int mutex_to_assign; struct atomic_t mutexes[1]; } *rc_grp; } *

user_defined_types: struct _notifier_domain_t { struct atomic_t mutex; struct atomic_t data_mutex; struct _str name; struct _notifier_package_t *first_package; struct _qsa_content_type_t *first_content_type; struct reference_counter_data_t ref; struct reference_counter_group_t *rc_grp; }

user_defined_types: struct _notifier_package_t { struct _str name; struct _notifier_domain_t *domain; struct _notifier_t *first_notifier; struct _qsa_subscription_t *first_subscription; struct _notifier_package_t *next; }

user_defined_types: struct _notifier_t { int (*subscribe)(struct _notifier_t *n, struct _qsa_subscription_t *subscription); void (*unsubscribe)(struct _notifier_t *n, struct _qsa_subscription_t *subscription); void *user_data; struct _notifier_package_t *package; struct _notifier_t *prev; }

user_defined_types: struct _qsa_subscription_t { struct atomic_t *mutex; struct _notifier_package_t *package; int allow_notifications; struct _qsa_subscription_data_t *data; struct _qsa_subscription_t *prev; struct reference_counter_data_t ref; }

user_defined_types: struct _qsa_subscription_data_t { struct msg_queue *dst; struct _str record_id; struct _str subscriber_id; struct _qsa_subscription_params_t *first_param; void *subscriber_data; }

user_defined_types: struct msg_queue { struct reference_counter_data_t ref; struct _mq_message_t *first; struct _mq_message_t *last; struct atomic_t q_mutex; unsigned int flags; }


decompiled_code:
__int64 qsa_get_default_domain()
{
return qsa_register_domain(0LL);
}

canonical_decompiled_code:
__int64 func8()
{
return func7(0LL);
}

canonical_original_code:
struct _notifier_domain_t *qsa_get_default_domain()
{
 return qsa_register_domain(((void *)0));
}

return_type: struct _notifier_domain_t { struct atomic_t { int val; } mutex; struct atomic_t data_mutex; struct _str { char *s; int len; } name; struct _notifier_package_t { struct _str name; struct _notifier_domain_t *domain; struct _notifier_t { int (*subscribe)(struct _notifier_t *n, struct _qsa_subscription_t { struct atomic_t *mutex; struct _notifier_package_t *package; int allow_notifications; struct _qsa_subscription_data_t { struct msg_queue { struct reference_counter_data_t { int cntr; struct atomic_t *mutex; } ref; struct _mq_message_t { void *data; int data_len; struct _mq_message_t *next; void (*destroy_function)(void *); enum { message_allocated_with_data=0, message_holding_data_ptr=1 } allocation_style; char data_buf[1]; } *first; struct _mq_message_t *last; struct atomic_t q_mutex; unsigned int flags; } *dst; struct _str record_id; struct _str subscriber_id; struct _qsa_subscription_params_t { struct _str name; struct _str value; char buf[1]; } *first_param; void *subscriber_data; } *data; struct _qsa_subscription_t *prev; struct reference_counter_data_t ref; } *subscription); void (*unsubscribe)(struct _notifier_t *n, struct _qsa_subscription_t *subscription); void *user_data; struct _notifier_package_t *package; struct _notifier_t *prev; } *first_notifier; struct _qsa_subscription_t *first_subscription; struct _notifier_package_t *next; } *first_package; struct _qsa_content_type_t { struct _qsa_content_type_t *next; struct _str name; void (*destroy_func)(void *); char buf[1]; } *first_content_type; struct reference_counter_data_t ref; struct reference_counter_group_t { int mutex_cnt; int mutex_to_assign; struct atomic_t mutexes[1]; } *rc_grp; } *


decompiled_code:
__int64 __fastcall qsa_release_domain(__int64 a1)
{
__int64 result; // rax

result = init;
if ( init )
{
if ( *(_QWORD *)(init + 8) )
result = release_notifier_domain(*(_QWORD *)(init + 8), a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax

result = init;
if ( init )
{
if ( *(_QWORD *)(init + 8) )
result = release_notifier_domain(*(_QWORD *)(init + 8), a1);
}
return result;
}

original_code:
void qsa_release_domain(notifier_domain_t *domain)
{
 if (init)
  if (init->dm) release_notifier_domain(init->dm, domain);
}

canonical_original_code:
void qsa_release_domain(struct _notifier_domain_t *domain)
{
 if (init)
  if (init->dm) release_notifier_domain(init->dm, domain);
}

user_defined_types: struct _qsa_content_type_t { struct _qsa_content_type_t *next; struct _str name; void (*destroy_func)(void *); char buf[1]; }

user_defined_types: struct _qsa_subscription_params_t { struct _str name; struct _str value; char buf[1]; }

user_defined_types: struct reference_counter_data_t { int cntr; struct atomic_t *mutex; }

user_defined_types: struct _mq_message_t { void *data; int data_len; struct _mq_message_t *next; void (*destroy_function)(void *); enum { message_allocated_with_data=0, message_holding_data_ptr=1 } allocation_style; char data_buf[1]; }


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

result = tick_counter;
++tick_counter[0];
return result;
}

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

result = tick_counter;
++tick_counter[0];
return result;
}

original_code:
void prof_handler(int a, siginfo_t *info, void *b)
{
 tick_counter++;
}

canonical_original_code:
void prof_handler(int a, struct siginfo_t *info, void *b)
{
 tick_counter++;
}

variable_types: a int

variable_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *

variable_types:
b
void *

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


decompiled_code:
void trace_handler()
{
if ( trace_function )
trace_function();
}

canonical_decompiled_code:
void func1()
{
if ( trace_function )
trace_function();
}

original_code:
void trace_handler(int a)
{
 if (trace_function) trace_function();
}


decompiled_code:
int reset_timer()
{
struct itimerval v1; // [rsp+0h] [rbp-28h] BYREF

v1.it_interval.tv_sec = 0LL;
v1.it_interval.tv_usec = 1000LL;
v1.it_value.tv_sec = 0LL;
v1.it_value.tv_usec = 1000LL;
return setitimer(ITIMER_PROF, &v1, 0LL);
}

canonical_decompiled_code:
int func2()
{
struct itimerval v1; // [rsp+0h] [rbp-28h] BYREF

v1.it_interval.tv_sec = 0LL;
v1.it_interval.tv_usec = 1000LL;
v1.it_value.tv_sec = 0LL;
v1.it_value.tv_usec = 1000LL;
return setitimer(ITIMER_PROF, &v1, 0LL);
}

original_code:
int reset_timer()
{
 struct itimerval tv;
 int res;
 tv.it_interval.tv_sec = 0;
 tv.it_interval.tv_usec = 1000;
 tv.it_value.tv_sec = tv.it_interval.tv_sec;
 tv.it_value.tv_usec = tv.it_interval.tv_usec;
 res = setitimer(ITIMER_PROF, &tv, ((void *)0));
 return res;
}

variable_types: struct itimerval { struct timeval { long tv_sec; long tv_usec; } it_interval; struct timeval it_value; }

return_type: int

user_defined_types: struct itimerval { struct timeval it_interval; struct timeval it_value; }


decompiled_code:
int __fastcall start_profile(__int64 (*a1)(void))
{
int result; // eax
int v2; // er9
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

result = 1;
if ( !initialized )
{
trace_function = a1;
initialized = 1;
v3.sa_handler = (__sighandler_t)prof_handler;
memset(&v3.sa_mask, 0, 0x90uLL);
sigemptyset(&v3.sa_mask);
v3.sa_flags = 4;
v2 = sigaction(27, &v3, &old_sigprof_action);
result = -1;
if ( !v2 )
{
old_sigx_action = signal(5, (__sighandler_t)trace_handler);
result = reset_timer();
if ( result )
{
signal(5, old_sigx_action);
sigaction(27, &old_sigprof_action, 0LL);
result = -1;
}
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 (*a1)(void))
{
int result; // eax
int v2; // er9
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

result = 1;
if ( !initialized )
{
trace_function = a1;
initialized = 1;
v3.sa_handler = (__sighandler_t)prof_handler;
memset(&v3.sa_mask, 0, 0x90uLL);
sigemptyset(&v3.sa_mask);
v3.sa_flags = 4;
v2 = sigaction(27, &v3, &old_sigprof_action);
result = -1;
if ( !v2 )
{
old_sigx_action = signal(5, (__sighandler_t)trace_handler);
result = func2();
if ( result )
{
signal(5, old_sigx_action);
sigaction(27, &old_sigprof_action, 0LL);
result = -1;
}
}
}
return result;
}

original_code:
int start_profile(trace_f tf)
{
 struct sigaction action;
 int res;
 if (initialized) return 1;
 initialized = 1;
 trace_function = tf;
 memset(&action, 0, sizeof(action));
 action.__sigaction_handler.sa_sigaction = prof_handler;
    sigemptyset(&action.sa_mask);
 action.sa_flags = 4;
 res = sigaction(27, &action, &old_sigprof_action);
 if (res != 0) {
  return -1;
 }
 old_sigx_action = signal(5, &trace_handler);
 res = reset_timer();
 if (res != 0) {
  signal(5, old_sigx_action);
  sigaction(27, &old_sigprof_action, ((void *)0));
  return -1;
 }
 return 0;
}

canonical_original_code:
int start_profile(void (*tf)())
{
 struct sigaction action;
 int res;
 if (initialized) return 1;
 initialized = 1;
 trace_function = tf;
 memset(&action, 0, sizeof(action));
 action.__sigaction_handler.sa_sigaction = prof_handler;
    sigemptyset(&action.sa_mask);
 action.sa_flags = 4;
 res = sigaction(27, &action, &old_sigprof_action);
 if (res != 0) {
  return -1;
 }
 old_sigx_action = signal(5, &trace_handler);
 res = reset_timer();
 if (res != 0) {
  signal(5, old_sigx_action);
  sigaction(27, &old_sigprof_action, ((void *)0));
  return -1;
 }
 return 0;
}

variable_types:
tf
void (*)()

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }


decompiled_code:
int stop_profile()
{
if ( !initialized )
return -1;
initialized = 0;
signal(5, old_sigx_action);
return sigaction(27, &old_sigprof_action, 0LL);
}

canonical_decompiled_code:
int func4()
{
if ( !initialized )
return -1;
initialized = 0;
signal(5, old_sigx_action);
return sigaction(27, &old_sigprof_action, 0LL);
}

original_code:
int stop_profile()
{
 if (initialized) {
  initialized = 0;
  signal(5, old_sigx_action);
  return sigaction(27, &old_sigprof_action, ((void *)0));
 }
 else return -1;
}


original_code:
static int match_ip_and_port(int *ipOne, int *ipArray, int sizeOf_ipArray)
{
 int curIPAddrIdx;
 int curOctetIdx;
 int ipArrayIndex;
 for (curIPAddrIdx = 0; curIPAddrIdx < sizeOf_ipArray; curIPAddrIdx++) {
  for (curOctetIdx = 0; curOctetIdx < 4 + 1; curOctetIdx++) {
   ipArrayIndex =
    curIPAddrIdx * (4 + 1) + curOctetIdx;
   if (ipOne[curOctetIdx] != ipArray[ipArrayIndex]) {
    break;
   }
  }
  if (curOctetIdx == 4 + 1) {
   return 1;
  }
 }
 return 0;
}

variable_types:
ipOne
int *

variable_types:
ipArray
int *

variable_types: curIPAddrIdx int

variable_types: curOctetIdx int

variable_types: ipArrayIndex int


decompiled_code:
__int64 __fastcall get_stat(__int64 a1)
{
__int64 result; // rax
unsigned __int16 v2; // [rsp+Eh] [rbp-1Ah] BYREF
__int64 v3; // [rsp+10h] [rbp-18h] BYREF
int v4; // [rsp+18h] [rbp-10h]

v3 = 0LL;
v4 = 0;
if ( (int)counter_lookup_str(&v2, &v3, a1) < 0 )
result = 0LL;
else
result = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 result; // rax
unsigned __int16 v2; // [rsp+Eh] [rbp-1Ah] BYREF
__int64 v3; // [rsp+10h] [rbp-18h] BYREF
int v4; // [rsp+18h] [rbp-10h]

v3 = 0LL;
v4 = 0;
if ( (int)counter_lookup_str(&v2, &v3, a1) < 0 )
result = 0LL;
else
result = v2;
return result;
}

original_code:
inline static stat_var* get_stat(str *name)
{
 counter_handle_t h;
 str grp;
 grp.s = 0;
 grp.len = 0;
 if (counter_lookup_str(&h, &grp, name) < 0)
  return 0;
 return (void*)(unsigned long)h.id;
}

canonical_original_code:
inline static void *get_stat(struct _str *name)
{
 struct counter_handle_s h;
 struct _str grp;
 grp.s = 0;
 grp.len = 0;
 if (counter_lookup_str(&h, &grp, name) < 0)
  return 0;
 return (void *)(unsigned long)h.id;
}

variable_types:
name
struct _str { char *s; int len; } *

variable_types: struct counter_handle_s { unsigned short id; }

variable_types:
grp
struct _str { char *s; int len; }

return_type: void *


decompiled_code:
__int64 __fastcall parse_proc_net_line(char *a1, _DWORD *a2, int *a3)
{
char *v5; // rbx
char *v6; // rax
char *v7; // r15
int v8; // eax
int v9; // edi
int v10; // er8
int v11; // edx
int v12; // ecx
int v13; // esi
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-50h] BYREF
int v16[4]; // [rsp+10h] [rbp-48h] BYREF
char v17; // [rsp+20h] [rbp-38h] BYREF

v5 = (char *)v16;
while ( 1 )
{
v6 = strchr(a1, 58);
if ( !v6 )
break;
v7 = v6 + 1;
v8 = strtol(v6 + 1, &endptr, 16);
a1 = endptr;
*(_DWORD *)v5 = v8;
if ( a1 == v7 )
break;
v5 += 4;
if ( v5 == &v17 )
{
v9 = v16[1];
v10 = v16[3];
v11 = LOBYTE(v16[0]);
v12 = BYTE1(v16[0]);
v13 = v16[0] >> 16;
a2[3] = v16[0] >> 24;
result = 1LL;
*a2 = v11;
a2[1] = v12;
a2[2] = (unsigned __int8)v13;
a2[4] = v9;
*a3 = v10;
return result;
}
}
return 0LL;
}

original_code:
static int parse_proc_net_line(char *line, int *ipAddress, int *rx_queue)
{
 int i;
 int ipOctetExtractionMask = 0xFF;
 char *currColonLocation;
 char *nextNonNumericalChar;
 char *currentLocationInLine = line;
 int parsedInteger[4];
 for (i = 0; i < 4; i++) {
  currColonLocation = strchr(currentLocationInLine, ':');
  if (currColonLocation == ((void *)0)) {
   return 0;
  }
  parsedInteger[i] =
   (int) strtol(++currColonLocation, &nextNonNumericalChar,
     16);
  if (nextNonNumericalChar == currColonLocation) {
   return 0;
  }
  currentLocationInLine = nextNonNumericalChar;
 }
 for (i = 0; i < 4; i++) {
  ipAddress[i] =
   parsedInteger[0] & (ipOctetExtractionMask << i*8);
  ipAddress[i] >>= i*8;
 }
 ipAddress[4] = parsedInteger[1];
 *rx_queue = parsedInteger[3];
 return 1;
}

variable_types:
line
char *

variable_types:
ipAddress
int *

variable_types: i int

variable_types: ipOctetExtractionMask int

variable_types:
currColonLocation
char *

variable_types:
nextNonNumericalChar
char *

variable_types:
currentLocationInLine
char *

variable_types:
parsedInteger
int [4]


original_code:
stat_var *get_stat_var_from_num_code(unsigned int numerical_code, int out_codes)
{
 static char msg_code[(19+1+1+1)+4];
 str stat_name;
 stat_name.s = int2bstr( (unsigned long)numerical_code, msg_code,
  &stat_name.len);
 stat_name.s[stat_name.len++] = '_';
 if (out_codes) {
  stat_name.s[stat_name.len++] = 'o';
  stat_name.s[stat_name.len++] = 'u';
  stat_name.s[stat_name.len++] = 't';
 } else {
  stat_name.s[stat_name.len++] = 'i';
  stat_name.s[stat_name.len++] = 'n';
 }
 return get_stat(&stat_name);
}

canonical_original_code:
void *get_stat_var_from_num_code(unsigned int numerical_code, int out_codes)
{
 static char msg_code[-1];
 struct _str stat_name;
 stat_name.s = int2bstr( (unsigned long)numerical_code, msg_code,
  &stat_name.len);
 stat_name.s[stat_name.len++] = '_';
 if (out_codes) {
  stat_name.s[stat_name.len++] = 'o';
  stat_name.s[stat_name.len++] = 'u';
  stat_name.s[stat_name.len++] = 't';
 } else {
  stat_name.s[stat_name.len++] = 'i';
  stat_name.s[stat_name.len++] = 'n';
 }
 return get_stat(&stat_name);
}


original_code:
int get_socket_list_from_proto_and_family(int **ipList, int protocol, int family) {
 struct socket_info *si;
 struct socket_info** list;
 int num_ip_octets = family == 2 ? 4 : 16;
 int numberOfSockets = 0;
 int currentRow = 0;
 if (protocol == PROTO_SCTP)
 {
  return 0;
 }
 if (protocol == PROTO_WS || protocol == PROTO_WSS)
  return 0;
 list=get_sock_info_list(protocol);
 for(si=list?*list:0; si; si=si->next){
  if (si->address.af == family) {
   numberOfSockets++;
  }
 }
 if (numberOfSockets == 0)
 {
  return 0;
 }
 *ipList = qm_malloc(mem_block, (numberOfSockets * (num_ip_octets + 1) * sizeof(int)));
 if (*ipList == ((void *)0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "no more pkg memory", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "no more pkg memory", (log_level_info[((-1)) - (-5)].name), ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more pkg memory", process_no, my_pid(), ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more pkg memory", ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more pkg memory", ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 list=get_sock_info_list(protocol);
 for(si=list?*list:0; si; si=si->next){
  int i;
  if (si->address.af != family) {
   continue;
  }
  for (i = 0; i < num_ip_octets; i++) {
   (*ipList)[currentRow*(num_ip_octets + 1) + i ] =
    si->address.u.addr[i];
  }
  (*ipList)[currentRow*(num_ip_octets + 1) + i] =
   si->port_no;
  currentRow++;
 }
 return numberOfSockets;
}

canonical_original_code:
int get_socket_list_from_proto_and_family(int **ipList, int protocol, int family) {
 struct socket_info *si;
 struct socket_info **list;
 int num_ip_octets = family == 2 ? 4 : 16;
 int numberOfSockets = 0;
 int currentRow = 0;
 if (protocol == PROTO_SCTP)
 {
  return 0;
 }
 if (protocol == PROTO_WS || protocol == PROTO_WSS)
  return 0;
 list=get_sock_info_list(protocol);
 for(si=list?*list:0; si; si=si->next){
  if (si->address.af == family) {
   numberOfSockets++;
  }
 }
 if (numberOfSockets == 0)
 {
  return 0;
 }
 *ipList = qm_malloc(mem_block, (numberOfSockets * (num_ip_octets + 1) * sizeof(int)));
 if (*ipList == ((void *)0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "no more pkg memory", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "no more pkg memory", (log_level_info[((-1)) - (-5)].name), ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more pkg memory", process_no, my_pid(), ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more pkg memory", ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more pkg memory", ("<core> [" "statistics.c" ":" "197" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 list=get_sock_info_list(protocol);
 for(si=list?*list:0; si; si=si->next){
  int i;
  if (si->address.af != family) {
   continue;
  }
  for (i = 0; i < num_ip_octets; i++) {
   (*ipList)[currentRow*(num_ip_octets + 1) + i ] =
    si->address.u.addr[i];
  }
  (*ipList)[currentRow*(num_ip_octets + 1) + i] =
   si->port_no;
  currentRow++;
 }
 return numberOfSockets;
}

variable_types:
ipList
int **

variable_types: protocol int

variable_types: family int

variable_types: struct socket_info { int socket; struct _str { char *s; int len; } name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } **

variable_types: numberOfSockets int

variable_types: currentRow int

user_defined_types: struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info useinfo; }

user_defined_types: union sockaddr_union { struct sockaddr s; struct sockaddr_in sin; struct sockaddr_in6 sin6; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }

user_defined_types: struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; }


decompiled_code:
__int64 __fastcall get_socket_list_from_proto(__int64 *a1, int a2)
{
return get_socket_list_from_proto_and_family(a1, a2, 2);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1, int a2)
{
return func5(a1, a2, 2);
}

original_code:
int get_socket_list_from_proto(int **ipList, int protocol) {
 return get_socket_list_from_proto_and_family(ipList, protocol, 2);
}


decompiled_code:
__int64 get_total_bytes_waiting()
{
int v0; // er15
int v1; // er13
int v2; // ebp
int v3; // er14
int v4; // er12
int v5; // ebx
int v7; // [rsp+Ch] [rbp-6Ch]
int v8; // [rsp+Ch] [rbp-6Ch]
int v9; // [rsp+Ch] [rbp-6Ch]
int v10; // [rsp+Ch] [rbp-6Ch]
int v11; // [rsp+Ch] [rbp-6Ch]
unsigned int v12; // [rsp+Ch] [rbp-6Ch]
_DWORD *v13; // [rsp+10h] [rbp-68h] BYREF
_DWORD *v14; // [rsp+18h] [rbp-60h] BYREF
_DWORD *v15; // [rsp+20h] [rbp-58h] BYREF
_DWORD *v16; // [rsp+28h] [rbp-50h] BYREF
_DWORD *v17; // [rsp+30h] [rbp-48h] BYREF
__int64 v18[8]; // [rsp+38h] [rbp-40h] BYREF

v13 = 0LL;
v14 = 0LL;
v15 = 0LL;
v16 = 0LL;
v17 = 0LL;
v18[0] = 0LL;
v0 = get_socket_list_from_proto((__int64 *)&v13, 1);
v1 = get_socket_list_from_proto((__int64 *)&v14, 2);
v2 = get_socket_list_from_proto((__int64 *)&v15, 3);
v3 = get_socket_list_from_proto_and_family((__int64 *)&v16, 1, 10);
v4 = get_socket_list_from_proto_and_family((__int64 *)&v17, 2, 10);
v5 = get_socket_list_from_proto_and_family(v18, 3, 10);
v7 = get_used_waiting_queue(0, v13, v0);
v8 = v7 + get_used_waiting_queue(1, v14, v1);
v9 = v8 + get_used_waiting_queue(1, v15, v2);
v10 = v9 + get_used_waiting_queue(0, v16, v3);
v11 = v10 + get_used_waiting_queue(1, v17, v4);
v12 = v11 + get_used_waiting_queue(1, (_DWORD *)v18[0], v5);
if ( v0 > 0 )
qm_free(mem_block, v13);
if ( v3 > 0 )
qm_free(mem_block, v16);
if ( v1 > 0 )
qm_free(mem_block, v14);
if ( v4 > 0 )
qm_free(mem_block, v17);
if ( v2 > 0 )
qm_free(mem_block, v15);
if ( v5 > 0 )
qm_free(mem_block, v18[0]);
return v12;
}

original_code:
int get_total_bytes_waiting(void)
{
 int bytesWaiting = 0;
 int *UDPList = ((void *)0);
 int *TCPList = ((void *)0);
 int *TLSList = ((void *)0);
 int *UDP6List = ((void *)0);
 int *TCP6List = ((void *)0);
 int *TLS6List = ((void *)0);
 int numUDPSockets = 0;
 int numTCPSockets = 0;
 int numTLSSockets = 0;
 int numUDP6Sockets = 0;
 int numTCP6Sockets = 0;
 int numTLS6Sockets = 0;
 numUDPSockets = get_socket_list_from_proto(&UDPList, PROTO_UDP);
 numTCPSockets = get_socket_list_from_proto(&TCPList, PROTO_TCP);
 numTLSSockets = get_socket_list_from_proto(&TLSList, PROTO_TLS);
 numUDP6Sockets = get_socket_list_from_proto_and_family(&UDP6List, PROTO_UDP, 10);
 numTCP6Sockets = get_socket_list_from_proto_and_family(&TCP6List, PROTO_TCP, 10);
 numTLS6Sockets = get_socket_list_from_proto_and_family(&TLS6List, PROTO_TLS, 10);
 bytesWaiting += get_used_waiting_queue(0, UDPList, numUDPSockets);
 bytesWaiting += get_used_waiting_queue(1, TCPList, numTCPSockets);
 bytesWaiting += get_used_waiting_queue(1, TLSList, numTLSSockets);
 bytesWaiting += get_used_waiting_queue(0, UDP6List, numUDP6Sockets);
 bytesWaiting += get_used_waiting_queue(1, TCP6List, numTCP6Sockets);
 bytesWaiting += get_used_waiting_queue(1, TLS6List, numTLS6Sockets);
 if (numUDPSockets > 0)
 {
  qm_free(mem_block, (UDPList));
 }
 if (numUDP6Sockets > 0)
 {
  qm_free(mem_block, (UDP6List));
 }
 if (numTCPSockets > 0)
 {
  qm_free(mem_block, (TCPList));
 }
 if (numTCP6Sockets > 0)
 {
  qm_free(mem_block, (TCP6List));
 }
 if (numTLSSockets > 0)
 {
  qm_free(mem_block, (TLSList));
 }
 if (numTLS6Sockets > 0)
 {
  qm_free(mem_block, (TLS6List));
 }
 return bytesWaiting;
}

canonical_original_code:
int get_total_bytes_waiting()
{
 int bytesWaiting = 0;
 int *UDPList = ((void *)0);
 int *TCPList = ((void *)0);
 int *TLSList = ((void *)0);
 int *UDP6List = ((void *)0);
 int *TCP6List = ((void *)0);
 int *TLS6List = ((void *)0);
 int numUDPSockets = 0;
 int numTCPSockets = 0;
 int numTLSSockets = 0;
 int numUDP6Sockets = 0;
 int numTCP6Sockets = 0;
 int numTLS6Sockets = 0;
 numUDPSockets = get_socket_list_from_proto(&UDPList, PROTO_UDP);
 numTCPSockets = get_socket_list_from_proto(&TCPList, PROTO_TCP);
 numTLSSockets = get_socket_list_from_proto(&TLSList, PROTO_TLS);
 numUDP6Sockets = get_socket_list_from_proto_and_family(&UDP6List, PROTO_UDP, 10);
 numTCP6Sockets = get_socket_list_from_proto_and_family(&TCP6List, PROTO_TCP, 10);
 numTLS6Sockets = get_socket_list_from_proto_and_family(&TLS6List, PROTO_TLS, 10);
 bytesWaiting += get_used_waiting_queue(0, UDPList, numUDPSockets);
 bytesWaiting += get_used_waiting_queue(1, TCPList, numTCPSockets);
 bytesWaiting += get_used_waiting_queue(1, TLSList, numTLSSockets);
 bytesWaiting += get_used_waiting_queue(0, UDP6List, numUDP6Sockets);
 bytesWaiting += get_used_waiting_queue(1, TCP6List, numTCP6Sockets);
 bytesWaiting += get_used_waiting_queue(1, TLS6List, numTLS6Sockets);
 if (numUDPSockets > 0)
 {
  qm_free(mem_block, (UDPList));
 }
 if (numUDP6Sockets > 0)
 {
  qm_free(mem_block, (UDP6List));
 }
 if (numTCPSockets > 0)
 {
  qm_free(mem_block, (TCPList));
 }
 if (numTCP6Sockets > 0)
 {
  qm_free(mem_block, (TCP6List));
 }
 if (numTLSSockets > 0)
 {
  qm_free(mem_block, (TLSList));
 }
 if (numTLS6Sockets > 0)
 {
  qm_free(mem_block, (TLS6List));
 }
 return bytesWaiting;
}

variable_types: bytesWaiting int

variable_types:
UDPList
int *

variable_types:
TCPList
int *

variable_types:
TLSList
int *

variable_types: numUDPSockets int

variable_types: numTCPSockets int

variable_types: numTLSSockets int


decompiled_code:
__int64 __fastcall atomic_get_and_set_int(volatile __int32 *a1, __int32 a2)
{
return (unsigned int)_InterlockedExchange(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(volatile __int32 *a1, __int32 a2)
{
return (unsigned int)_InterlockedExchange(a1, a2);
}

original_code: inline static int atomic_get_and_set_int(volatile int* var, int v) { asm volatile( "xchgl %1, %0" " \n\t" : "+q"(v), "=m"(*var) : "m"(*var) : "memory" ); return v; }

canonical_original_code: inline static int atomic_get_and_set_int(int *var, int v) { asm volatile( "xchgl %1, %0" " \n\t" : "+q"(v), "=m"(*var) : "m"(*var) : "memory" ); return v; }

variable_types:
var
int *

variable_types: v int


decompiled_code:
__int64 __fastcall futex_release(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

result = atomic_get_and_set_int(a1, 0);
if ( (_DWORD)result == 2 )
{
syscall(202LL, a1, 1LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

result = func0(a1, 0);
if ( (_DWORD)result == 2 )
{
syscall(202LL, a1, 1LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
return result;
}

original_code:
inline static void futex_release(futex_lock_t* lock)
{
 int v;
 do {} while(0);
 v=atomic_get_and_set_int(&(lock)->val, 0);
 if (__builtin_expect(!!(v==2), 0)){
  syscall(202 , (&(lock)->val), (1), (1), (0), (0), (0));
 }
}

canonical_original_code:
inline static void futex_release(struct atomic_t *lock)
{
 int v;
 do {} while(0);
 v=atomic_get_and_set_int(&(lock)->val, 0);
 if (__builtin_expect(!!(v==2), 0)){
  syscall(202 , (&(lock)->val), (1), (1), (0), (0), (0));
 }
}

variable_types:
lock
struct atomic_t { int val; } *


decompiled_code:
__int64 __fastcall futex_get(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = atomic_cmpxchg_int_constprop_0(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = atomic_get_and_set_int(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = atomic_get_and_set_int(a1, 2); (_DWORD)result; result = atomic_get_and_set_int(a1, 2) )
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
return result;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = func2(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = func0(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = func0(a1, 2); (_DWORD)result; result = func0(a1, 2) )
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
return result;
}
}
}
}
return result;
}

original_code:
inline static void futex_get(futex_lock_t* lock)
{
 int v;
 register int i=1024;
retry:
 v=atomic_cmpxchg_int(&(lock)->val, 0, 1);
 if (__builtin_expect(!!(v==0), 1)){
  do {} while(0);
  return;
 }else if (__builtin_expect(!!(v==2), 0)){
  do{
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }while(v);
 }else{
  if (i>0){
   i--;
   goto retry;
  }
  v=atomic_get_and_set_int(&(lock)->val, 2);
  while(v){
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }
 }
 do {} while(0);
}

canonical_original_code:
inline static void futex_get(struct atomic_t *lock)
{
 int v;
 register int i = 1024;
retry:
 v=atomic_cmpxchg_int(&(lock)->val, 0, 1);
 if (__builtin_expect(!!(v==0), 1)){
  do {} while(0);
  return;
 }else if (__builtin_expect(!!(v==2), 0)){
  do{
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }while(v);
 }else{
  if (i>0){
   i--;
   goto retry;
  }
  v=atomic_get_and_set_int(&(lock)->val, 2);
  while(v){
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }
 }
 do {} while(0);
}

variable_types: i int


decompiled_code:
__int64 __fastcall free_hash_entry(__int64 a1)
{
__int64 result; // rax

if ( a1 )
{
futex_get(mem_lock);
qm_free(shm_block, a1);
result = futex_release(mem_lock);
}
return result;
}

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

if ( a1 )
{
func3(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
static void free_hash_entry(struct hash_entry* e)
{
 if (e) do { futex_get(mem_lock); qm_free(shm_block, (e)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
static void free_hash_entry(struct hash_entry *e)
{
 if (e) do { futex_get(mem_lock); qm_free(shm_block, (e)); futex_release(mem_lock); }while(0);
}

variable_types: struct hash_entry { struct _str { char *s; int len; } key; struct domain { struct _str did; int n; struct _str *domain; unsigned int *flags; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *attrs; struct domain *next; } *domain; struct hash_entry *next; } *

user_defined_types: struct hash_entry { struct _str key; struct domain *domain; struct hash_entry *next; }

user_defined_types: struct domain { struct _str did; int n; struct _str *domain; unsigned int *flags; struct usr_avp *attrs; struct domain *next; }

user_defined_types: struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data d; }


decompiled_code:
__int64 __fastcall gen_domain_table(__int64 *a1, __int64 a2)
{
__int64 v2; // r15
__int64 v3; // r14
__int64 v4; // r12
__int64 *v5; // rcx
__int64 v6; // rbp
__int64 v7; // rbx
__int64 result; // rax
int v9; // er8
const char *v10; // r14
unsigned int v11; // eax
const char *v12; // rdx
struct _IO_FILE *v13; // rdi
const char *v14; // [rsp-8h] [rbp-40h]

if ( a1 )
{
v2 = a2;
if ( a2 )
{
while ( *(int *)(v2 + 16) <= 0 )
{
LABEL_9:
v2 = *(_QWORD *)(v2 + 48);
if ( !v2 )
goto LABEL_10;
}
v3 = *(_QWORD *)(v2 + 24);
v4 = 0LL;
while ( 1 )
{
v6 = 16 * v4;
v7 = new_hash_entry((const __m128i *)(v3 + 16 * v4), v2);
if ( !v7 )
break;
v3 = *(_QWORD *)(v2 + 24);
++v4;
v5 = &a1[(unsigned int)calc_hash_isra_0(*(char **)(v3 + v6), *(_DWORD *)(v3 + v6 + 8))];
*(_QWORD *)(v7 + 24) = *v5;
*v5 = v7;
if ( *(_DWORD *)(v2 + 16) <= (int)v4 )
goto LABEL_9;
}
free_table(a1);
result = 0xFFFFFFFFLL;
}
else
{
LABEL_10:
result = 0LL;
}
}
else
{
v9 = get_debug_level("uid_domain", 10LL);
result = 0xFFFFFFFFLL;
if ( v9 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
v14 = v12;
v13 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Invalid parameter value\n",
process_no,
v11,
v10,
"uid_domain [hash.c:116]: ",
"gen_domain_table");
if ( log_color )
dprint_color_reset(v13, v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"uid_domain [hash.c:116]: ",
"gen_domain_table");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 *a1, __int64 a2)
{
__int64 v2; // r15
__int64 v3; // r14
__int64 v4; // r12
__int64 *v5; // rcx
__int64 v6; // rbp
__int64 v7; // rbx
__int64 result; // rax
int v9; // er8
const char *v10; // r14
unsigned int v11; // eax
const char *v12; // rdx
struct _IO_FILE *v13; // rdi
const char *v14; // [rsp-8h] [rbp-40h]

if ( a1 )
{
v2 = a2;
if ( a2 )
{
while ( *(int *)(v2 + 16) <= 0 )
{
LABEL_9:
v2 = *(_QWORD *)(v2 + 48);
if ( !v2 )
goto LABEL_10;
}
v3 = *(_QWORD *)(v2 + 24);
v4 = 0LL;
while ( 1 )
{
v6 = 16 * v4;
v7 = func6((const __m128i *)(v3 + 16 * v4), v2);
if ( !v7 )
break;
v3 = *(_QWORD *)(v2 + 24);
++v4;
v5 = &a1[(unsigned int)func7(*(char **)(v3 + v6), *(_DWORD *)(v3 + v6 + 8))];
*(_QWORD *)(v7 + 24) = *v5;
*v5 = v7;
if ( *(_DWORD *)(v2 + 16) <= (int)v4 )
goto LABEL_9;
}
func8(a1);
result = 0xFFFFFFFFLL;
}
else
{
LABEL_10:
result = 0LL;
}
}
else
{
v9 = get_debug_level("uid_domain", 10LL);
result = 0xFFFFFFFFLL;
if ( v9 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
v14 = v12;
v13 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Invalid parameter value\n",
process_no,
v11,
v10,
"uid_domain [hash.c:116]: ",
"gen_domain_table");
if ( log_color )
dprint_color_reset(v13, v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"uid_domain [hash.c:116]: ",
"gen_domain_table");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

original_code:
int gen_domain_table(struct hash_entry** table, domain_t* list)
{
 struct hash_entry* e;
 unsigned int slot;
 int i;
 if (!table) {
  do { if (get_debug_level("uid_domain", (sizeof("uid_domain")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 while(list) {
  for(i = 0; i < list->n; i++) {
   e = new_hash_entry(&list->domain[i], list);
   if (!e) goto error;
   slot = calc_hash(&list->domain[i]);
   e->next = table[slot];
   table[slot] = e;
  }
  list = list->next;
 }
 return 0;
 error:
 free_table(table);
 return -1;
}

canonical_original_code:
int gen_domain_table(struct hash_entry **table, struct domain *list)
{
 struct hash_entry *e;
 unsigned int slot;
 int i;
 if (!table) {
  do { if (get_debug_level("uid_domain", (sizeof("uid_domain")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "116" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 while(list) {
  for(i = 0; i < list->n; i++) {
   e = new_hash_entry(&list->domain[i], list);
   if (!e) goto error;
   slot = calc_hash(&list->domain[i]);
   e->next = table[slot];
   table[slot] = e;
  }
  list = list->next;
 }
 return 0;
 error:
 free_table(table);
 return -1;
}

variable_types: struct hash_entry { struct _str { char *s; int len; } key; struct domain { struct _str did; int n; struct _str *domain; unsigned int *flags; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *attrs; struct domain *next; } *domain; struct hash_entry *next; } **

variable_types:
list
struct domain *

variable_types:
slot
unsigned int

user_defined_types: struct cfg_group_core { int debug; int log_facility; int memdbg; int use_dst_blacklist; unsigned int blst_timeout; unsigned int blst_max_mem; unsigned int blst_udp_imask; unsigned int blst_tcp_imask; unsigned int blst_tls_imask; unsigned int blst_sctp_imask; int dns_try_ipv6; int dns_try_naptr; int dns_udp_pref; int dns_tcp_pref; int dns_tls_pref; int dns_sctp_pref; int dns_retr_time; int dns_retr_no; int dns_servers_no; int dns_search_list; int dns_search_fmatch; int dns_reinit; int use_dns_cache; int dns_cache_flags; int use_dns_failover; int dns_srv_lb; unsigned int dns_neg_cache_ttl; unsigned int dns_cache_min_ttl; unsigned int dns_cache_max_ttl; unsigned int dns_cache_max_mem; int dns_cache_del_nonexp; int dns_cache_rec_pref; int mem_dump_pkg; int mem_dump_shm; int max_while_loops; int udp_mtu; int udp_mtu_try_proto; int udp4_raw; int udp4_raw_mtu; int udp4_raw_ttl; int force_rport; int memlog; int mem_summary; int mem_safety; int mem_join; int corelog; int latency_log; int latency_limit_db; int latency_limit_action; }


decompiled_code:
__int64 __fastcall gen_did_table(__int64 *a1, const __m128i *a2)
{
const __m128i *v2; // rbx
int v3; // eax
__int64 *v4; // rcx
__int64 v5; // rbp
__int64 result; // rax
int v7; // er8
const char *v8; // r12
struct _IO_FILE *v9; // rdi
const char *v10; // r8
const char *v11; // r9
__int64 v12; // [rsp-10h] [rbp-28h]
__int64 v13; // [rsp-8h] [rbp-20h]
const char *v14; // [rsp+0h] [rbp-18h]

if ( a1 )
{
v2 = a2;
if ( a2 )
{
while ( 1 )
{
v5 = new_hash_entry(v2, (__int64)v2);
if ( !v5 )
break;
v3 = calc_hash_isra_0((char *)v2->m128i_i64[0], v2->m128i_u32[2]);
v2 = (const __m128i *)v2[3].m128i_i64[0];
v4 = &a1[v3];
*(_QWORD *)(v5 + 24) = *v4;
*v4 = v5;
if ( !v2 )
goto LABEL_7;
}
free_table(a1);
result = 0xFFFFFFFFLL;
}
else
{
LABEL_7:
result = 0LL;
}
}
else
{
v7 = get_debug_level("uid_domain", 10LL);
result = 0xFFFFFFFFLL;
if ( v7 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v9 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Invalid parameter value\n",
process_no,
(unsigned int)v13,
v8,
"uid_domain [hash.c:148]: ",
"gen_did_table");
if ( log_color )
dprint_color_reset(v9, "%2d(%d) %s: %s%s(): Invalid parameter value\n", v12, v13, v10, v11, v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"uid_domain [hash.c:148]: ",
"gen_did_table");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 *a1, const __m128i *a2)
{
const __m128i *v2; // rbx
int v3; // eax
__int64 *v4; // rcx
__int64 v5; // rbp
__int64 result; // rax
int v7; // er8
const char *v8; // r12
struct _IO_FILE *v9; // rdi
const char *v10; // r8
const char *v11; // r9
__int64 v12; // [rsp-10h] [rbp-28h]
__int64 v13; // [rsp-8h] [rbp-20h]
const char *v14; // [rsp+0h] [rbp-18h]

if ( a1 )
{
v2 = a2;
if ( a2 )
{
while ( 1 )
{
v5 = func6(v2, (__int64)v2);
if ( !v5 )
break;
v3 = func7((char *)v2->m128i_i64[0], v2->m128i_u32[2]);
v2 = (const __m128i *)v2[3].m128i_i64[0];
v4 = &a1[v3];
*(_QWORD *)(v5 + 24) = *v4;
*v4 = v5;
if ( !v2 )
goto LABEL_7;
}
func8(a1);
result = 0xFFFFFFFFLL;
}
else
{
LABEL_7:
result = 0LL;
}
}
else
{
v7 = get_debug_level("uid_domain", 10LL);
result = 0xFFFFFFFFLL;
if ( v7 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v9 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Invalid parameter value\n",
process_no,
(unsigned int)v13,
v8,
"uid_domain [hash.c:148]: ",
"gen_did_table");
if ( log_color )
dprint_color_reset(v9, "%2d(%d) %s: %s%s(): Invalid parameter value\n", v12, v13, v10, v11, v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"uid_domain [hash.c:148]: ",
"gen_did_table");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

original_code:
int gen_did_table(struct hash_entry** table, domain_t* list)
{
 unsigned int slot;
 struct hash_entry* e;
 if (!table) {
  do { if (get_debug_level("uid_domain", (sizeof("uid_domain")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 while(list) {
  e = new_hash_entry(&list->did, list);
  if (!e) goto error;
  slot = calc_hash(&list->did);
  e->next = table[slot];
  table[slot] = e;
  list = list->next;
 }
 return 0;
 error:
 free_table(table);
 return -1;
}

canonical_original_code:
int gen_did_table(struct hash_entry **table, struct domain *list)
{
 unsigned int slot;
 struct hash_entry *e;
 if (!table) {
  do { if (get_debug_level("uid_domain", (sizeof("uid_domain")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("uid_domain" " [" "hash.c" ":" "148" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 while(list) {
  e = new_hash_entry(&list->did, list);
  if (!e) goto error;
  slot = calc_hash(&list->did);
  e->next = table[slot];
  table[slot] = e;
  list = list->next;
 }
 return 0;
 error:
 free_table(table);
 return -1;
}

user_defined_types: union usr_avp_data { void *p; long l; char data[-1]; }


decompiled_code:
__int64 __fastcall hash_lookup(_QWORD *a1, __int64 a2, __int64 a3)
{
const char *v3; // r12
signed int v4; // ebp
__int64 v5; // rbx
__int64 result; // rax

v3 = *(const char **)a3;
v4 = *(_DWORD *)(a3 + 8);
v5 = *(_QWORD *)(a2 + 8LL * (unsigned int)calc_hash_isra_0(*(char **)a3, v4));
if ( v5 )
{
while ( *(_DWORD *)(v5 + 8) != v4 || strncmp(*(const char **)v5, v3, v4) )
{
v5 = *(_QWORD *)(v5 + 24);
if ( !v5 )
goto LABEL_8;
}
result = 1LL;
if ( a1 )
*a1 = *(_QWORD *)(v5 + 16);
}
else
{
LABEL_8:
result = 0xFFFFFFFFLL;
if ( a1 )
*a1 = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1, __int64 a2, __int64 a3)
{
const char *v3; // r12
signed int v4; // ebp
__int64 v5; // rbx
__int64 result; // rax

v3 = *(const char **)a3;
v4 = *(_DWORD *)(a3 + 8);
v5 = *(_QWORD *)(a2 + 8LL * (unsigned int)func7(*(char **)a3, v4));
if ( v5 )
{
while ( *(_DWORD *)(v5 + 8) != v4 || strncmp(*(const char **)v5, v3, v4) )
{
v5 = *(_QWORD *)(v5 + 24);
if ( !v5 )
goto LABEL_8;
}
result = 1LL;
if ( a1 )
*a1 = *(_QWORD *)(v5 + 16);
}
else
{
LABEL_8:
result = 0xFFFFFFFFLL;
if ( a1 )
*a1 = 0LL;
}
return result;
}

original_code:
int hash_lookup(domain_t** d, struct hash_entry** table, str* key)
{
 struct hash_entry* np;
 for (np = table[calc_hash(key)]; np != ((void *)0); np = np->next) {
  if ((np->key.len == key->len) &&
   (strncmp(np->key.s, key->s, key->len) == 0)) {
   if (d) *d = np->domain;
   return 1;
  }
 }
 if (d) *d = 0;
 return -1;
}

canonical_original_code:
int hash_lookup(struct domain **d, struct hash_entry **table, struct _str *key)
{
 struct hash_entry *np;
 for (np = table[calc_hash(key)]; np != ((void *)0); np = np->next) {
  if ((np->key.len == key->len) &&
   (strncmp(np->key.s, key->s, key->len) == 0)) {
   if (d) *d = np->domain;
   return 1;
  }
 }
 if (d) *d = 0;
 return -1;
}

variable_types: struct domain { struct _str { char *s; int len; } did; int n; struct _str *domain; unsigned int *flags; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *attrs; struct domain *next; } **

variable_types: struct hash_entry { struct _str key; struct domain *domain; struct hash_entry *next; } **

variable_types:
key
struct _str *


decompiled_code:
__int64 __fastcall free_msg_actions(_QWORD **a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // r12
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = (_QWORD *)*v1;
futex_get(mem_lock);
qm_free(shm_block, v2);
futex_release(mem_lock);
}
futex_get(mem_lock);
qm_free(shm_block, a1);
result = futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD **a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // r12
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = (_QWORD *)*v1;
func3(mem_lock);
qm_free(shm_block, v2);
func1(mem_lock);
}
func3(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
void free_msg_actions(cp_actions_t *a)
{
 cp_unknown_t *u, *nu;
 if (!a) return;
 u = a->unknown;
 while (u) {
  nu = u->next;
  do { futex_get(mem_lock); qm_free(shm_block, (u)); futex_release(mem_lock); }while(0);
  u = nu;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (a)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
void free_msg_actions(struct cp_actions_t *a)
{
 struct _cp_unknown_t *u; struct _cp_unknown_t *nu;
 if (!a) return;
 u = a->unknown;
 while (u) {
  nu = u->next;
  do { futex_get(mem_lock); qm_free(shm_block, (u)); futex_release(mem_lock); }while(0);
  u = nu;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (a)); futex_release(mem_lock); }while(0);
}

variable_types: struct cp_actions_t { struct _cp_unknown_t { struct _cp_unknown_t *next; char data[1]; } *unknown; } *

user_defined_types: struct cp_actions_t { struct _cp_unknown_t *unknown; }