decompiled_code:
__int64 __fastcall cpy2dynstr(__int64 a1, __int64 a2)
{
int v2; // er12
__int64 v3; // rax
__int64 result; // rax
int v5; // edx
const char *v6; // rbx
unsigned int v7; // eax

v2 = *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) >= v2 )
goto LABEL_4;
v3 = qm_realloc(mem_block, *(_QWORD *)a1, v2);
if ( v3 )
{
*(_QWORD *)a1 = v3;
*(_DWORD *)(a1 + 16) = v2;
LABEL_4:
memcpy(*(void **)a1, *(const void **)a2, *(int *)(a2 + 8));
*(_DWORD *)(a1 + 8) = v2;
return 0LL;
}
v5 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n",
process_no,
v7,
v6,
"auth_identity [auth_dynstr.c:68]: ",
"cpy2dynstr");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n",
*((const char **)&log_level_info + 8),
"auth_identity [auth_dynstr.c:68]: ",
"cpy2dynstr");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
int v2; // er12
__int64 v3; // rax
__int64 result; // rax
int v5; // edx
const char *v6; // rbx
unsigned int v7; // eax

v2 = *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) >= v2 )
goto LABEL_4;
v3 = qm_realloc(mem_block, *(_QWORD *)a1, v2);
if ( v3 )
{
*(_QWORD *)a1 = v3;
*(_DWORD *)(a1 + 16) = v2;
LABEL_4:
memcpy(*(void **)a1, *(const void **)a2, *(int *)(a2 + 8));
*(_DWORD *)(a1 + 8) = v2;
return 0LL;
}
v5 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n",
process_no,
v7,
v6,
"auth_identity [auth_dynstr.c:68]: ",
"cpy2dynstr");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n",
*((const char **)&log_level_info + 8),
"auth_identity [auth_dynstr.c:68]: ",
"cpy2dynstr");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int cpy2dynstr(dynstr *sout, str *s2app)
{
 char *stmp;
 int isize = s2app->len;
 if (isize > sout->size) {
  stmp=qm_realloc(mem_block, (sout->sd.s), (isize));
  if (!stmp) {
   do { if (get_debug_level("auth_identity", (sizeof("auth_identity")-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(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __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(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", process_no, my_pid(), ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __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(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
  sout->sd.s=stmp;
  sout->size=isize;
 }
 memcpy(sout->sd.s,s2app->s,s2app->len);
 sout->sd.len = isize;
 return 0;
}

canonical_original_code:
int cpy2dynstr(struct _dstr *sout, struct _str *s2app)
{
 char *stmp;
 int isize = s2app->len;
 if (isize > sout->size) {
  stmp=qm_realloc(mem_block, (sout->sd.s), (isize));
  if (!stmp) {
   do { if (get_debug_level("auth_identity", (sizeof("auth_identity")-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(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __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(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", process_no, my_pid(), ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __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(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "68" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
  sout->sd.s=stmp;
  sout->size=isize;
 }
 memcpy(sout->sd.s,s2app->s,s2app->len);
 sout->sd.len = isize;
 return 0;
}

variable_types:
stmp
char *


repo: virtualolson/who

decompiled_code:
__int64 __fastcall app2dynchr(__int64 a1, char a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // er8
const char *v6; // rbx
unsigned int v7; // eax

v2 = *(_DWORD *)(a1 + 8) + 1;
if ( *(_DWORD *)(a1 + 16) >= v2 )
goto LABEL_2;
v4 = qm_realloc(mem_block, *(_QWORD *)a1, v2);
if ( v4 )
{
*(_QWORD *)a1 = v4;
++*(_DWORD *)(a1 + 16);
LABEL_2:
*(_BYTE *)(*(_QWORD *)a1 + (int)(*(_DWORD *)(a1 + 8))++) = a2;
return 0LL;
}
v5 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n",
process_no,
v7,
v6,
"auth_identity [auth_dynstr.c:89]: ",
"app2dynchr");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n",
*((const char **)&log_level_info + 8),
"auth_identity [auth_dynstr.c:89]: ",
"app2dynchr");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // er8
const char *v6; // rbx
unsigned int v7; // eax

v2 = *(_DWORD *)(a1 + 8) + 1;
if ( *(_DWORD *)(a1 + 16) >= v2 )
goto LABEL_2;
v4 = qm_realloc(mem_block, *(_QWORD *)a1, v2);
if ( v4 )
{
*(_QWORD *)a1 = v4;
++*(_DWORD *)(a1 + 16);
LABEL_2:
*(_BYTE *)(*(_QWORD *)a1 + (int)(*(_DWORD *)(a1 + 8))++) = a2;
return 0LL;
}
v5 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n",
process_no,
v7,
v6,
"auth_identity [auth_dynstr.c:89]: ",
"app2dynchr");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n",
*((const char **)&log_level_info + 8),
"auth_identity [auth_dynstr.c:89]: ",
"app2dynchr");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int app2dynchr(dynstr *sout, char capp)
{
 char *stmp;
 int isize = sout->sd.len + 1;
 if (isize > sout->size) {
  stmp=qm_realloc(mem_block, (sout->sd.s), (isize));
  if (!stmp) {
   do { if (get_debug_level("auth_identity", (sizeof("auth_identity")-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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "89" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", process_no, my_pid(), ("auth_identity" " [" "auth_dynstr.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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "89" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
  sout->sd.s=stmp;
  sout->size++;
 }
 sout->sd.s[sout->sd.len]=capp;
 sout->sd.len++;
 return 0;
}

canonical_original_code:
int app2dynchr(struct _dstr *sout, char capp)
{
 char *stmp;
 int isize = sout->sd.len + 1;
 if (isize > sout->size) {
  stmp=qm_realloc(mem_block, (sout->sd.s), (isize));
  if (!stmp) {
   do { if (get_debug_level("auth_identity", (sizeof("auth_identity")-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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "89" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", process_no, my_pid(), ("auth_identity" " [" "auth_dynstr.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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.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(): " "AUTH_IDENTITY:app2dynchr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "89" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
  sout->sd.s=stmp;
  sout->size++;
 }
 sout->sd.s[sout->sd.len]=capp;
 sout->sd.len++;
 return 0;
}

variable_types: struct _dstr { struct _str { char *s; int len; } sd; int size; } *

variable_types: capp char

variable_types: isize int

return_type: int

user_defined_types: struct _dstr { struct _str sd; int size; }

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 app2dynstr(__int64 a1, __int64 a2)
{
int v2; // ebp
__int64 v3; // rax
__int64 result; // rax
int v5; // edx
const char *v6; // rbx
unsigned int v7; // eax

v2 = *(_DWORD *)(a1 + 8) + *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) >= v2 )
goto LABEL_4;
v3 = qm_realloc(mem_block, *(_QWORD *)a1, v2);
if ( v3 )
{
*(_QWORD *)a1 = v3;
*(_DWORD *)(a1 + 16) = v2;
LABEL_4:
memcpy((void *)(*(_QWORD *)a1 + *(int *)(a1 + 8)), *(const void **)a2, *(int *)(a2 + 8));
*(_DWORD *)(a1 + 8) = v2;
return 0LL;
}
v5 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n",
process_no,
v7,
v6,
"auth_identity [auth_dynstr.c:110]: ",
"app2dynstr");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n",
*((const char **)&log_level_info + 8),
"auth_identity [auth_dynstr.c:110]: ",
"app2dynstr");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
int v2; // ebp
__int64 v3; // rax
__int64 result; // rax
int v5; // edx
const char *v6; // rbx
unsigned int v7; // eax

v2 = *(_DWORD *)(a1 + 8) + *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) >= v2 )
goto LABEL_4;
v3 = qm_realloc(mem_block, *(_QWORD *)a1, v2);
if ( v3 )
{
*(_QWORD *)a1 = v3;
*(_DWORD *)(a1 + 16) = v2;
LABEL_4:
memcpy((void *)(*(_QWORD *)a1 + *(int *)(a1 + 8)), *(const void **)a2, *(int *)(a2 + 8));
*(_DWORD *)(a1 + 8) = v2;
return 0LL;
}
v5 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n",
process_no,
v7,
v6,
"auth_identity [auth_dynstr.c:110]: ",
"app2dynstr");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n",
*((const char **)&log_level_info + 8),
"auth_identity [auth_dynstr.c:110]: ",
"app2dynstr");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int app2dynstr(dynstr *sout, str *s2app)
{
 char *stmp;
 int isize = sout->sd.len + s2app->len;
 if (isize > sout->size) {
  stmp=qm_realloc(mem_block, (sout->sd.s), (isize));
  if (!stmp) {
   do { if (get_debug_level("auth_identity", (sizeof("auth_identity")-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(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __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(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", process_no, my_pid(), ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __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(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
  sout->sd.s=stmp;
  sout->size=isize;
 }
 memcpy(&sout->sd.s[sout->sd.len],s2app->s,s2app->len);
 sout->sd.len = isize;
 return 0;
}

canonical_original_code:
int app2dynstr(struct _dstr *sout, struct _str *s2app)
{
 char *stmp;
 int isize = sout->sd.len + s2app->len;
 if (isize > sout->size) {
  stmp=qm_realloc(mem_block, (sout->sd.s), (isize));
  if (!stmp) {
   do { if (get_debug_level("auth_identity", (sizeof("auth_identity")-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(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __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(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", (log_level_info[((-1)) - (-5)].name), ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", process_no, my_pid(), ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __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(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "AUTH_IDENTITY:app2dynstr: Not enough memory error\n", ("auth_identity" " [" "auth_dynstr.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
  sout->sd.s=stmp;
  sout->size=isize;
 }
 memcpy(&sout->sd.s[sout->sd.len],s2app->s,s2app->len);
 sout->sd.len = isize;
 return 0;
}


decompiled_code:
__int64 shm_initialized()
{
return (unsigned int)shm_init;
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)shm_init;
}

original_code:
int shm_initialized()
{
 return shm_init;
}


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

if ( !user || uid || (int)user2uid(&uid, &gid) >= 0 )
{
if ( !shm_mem_size )
shm_mem_size = 0x2000000LL;
result = init_shm_mallocs(shm_force_alloc);
if ( (_DWORD)result != -1 )
{
shm_init = 1;
result = 0LL;
}
}
else
{
fprintf(stderr, "bad user name/uid number: -u %s\n", user);
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( !user || uid || (int)user2uid(&uid, &gid) >= 0 )
{
if ( !shm_mem_size )
shm_mem_size = 0x2000000LL;
result = init_shm_mallocs(shm_force_alloc);
if ( (_DWORD)result != -1 )
{
shm_init = 1;
result = 0LL;
}
}
else
{
fprintf(stderr, "bad user name/uid number: -u %s\n", user);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int init_shm()
{
 if (user && uid == 0){
  if (user2uid(&uid, &gid, user)<0){
   fprintf(stderr, "bad user name/uid number: -u %s\n", user);
   goto error;
  }
 }
 if (shm_mem_size == 0)
  shm_mem_size=32 * 1024 * 1024;
 if (init_shm_mallocs(shm_force_alloc)==-1)
  goto error;
 shm_init=1;
 return 0;
error:
 return -1;
}


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

result = 43LL;
if ( (_BYTE)a1 != 62 )
{
result = 47LL;
if ( (_BYTE)a1 != 63 )
{
if ( (unsigned __int8)a1 <= 0x19u )
{
result = (unsigned int)(a1 + 65);
}
else if ( (unsigned __int8)a1 <= 0x33u )
{
result = (unsigned int)(a1 + 71);
}
else
{
result = (unsigned int)(a1 - 4);
if ( (unsigned __int8)a1 >= 0x3Eu )
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

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

result = 43LL;
if ( (_BYTE)a1 != 62 )
{
result = 47LL;
if ( (_BYTE)a1 != 63 )
{
if ( (unsigned __int8)a1 <= 0x19u )
{
result = (unsigned int)(a1 + 65);
}
else if ( (unsigned __int8)a1 <= 0x33u )
{
result = (unsigned int)(a1 + 71);
}
else
{
result = (unsigned int)(a1 - 4);
if ( (unsigned __int8)a1 >= 0x3Eu )
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
inline static unsigned char base64_enc_char(unsigned char v)
{
 switch(v){
  case 0x3f:
   return '/';
  case 0x3e:
   return '+';
  default:
   if (v<=25)
    return v+'A';
   else if (v<=51)
    return v-26+'a';
   else if (v<=61)
    return v-52+'0';
 }
 return 0xff;
}

variable_types:
v
unsigned char

return_type: unsigned char


decompiled_code:
__int64 __fastcall base64_dec_char(unsigned __int8 a1)
{
__int64 result; // rax

result = 63LL;
if ( a1 != 47 )
{
if ( a1 > 0x2Fu )
{
if ( a1 > 0x40u )
{
result = 255LL;
if ( (unsigned __int8)(a1 - 91) <= 5u )
return result;
}
else
{
result = 255LL;
if ( a1 > 0x39u )
return result;
}
if ( a1 <= 0x39u )
{
result = (unsigned int)a1 + 4;
}
else if ( a1 <= 0x5Au )
{
result = (unsigned int)a1 - 65;
}
else
{
result = (unsigned int)a1 - 71;
if ( a1 >= 0x7Bu )
result = 255LL;
}
}
else
{
result = 255LL;
if ( a1 == 43 )
result = 62LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 a1)
{
__int64 result; // rax

result = 63LL;
if ( a1 != 47 )
{
if ( a1 > 0x2Fu )
{
if ( a1 > 0x40u )
{
result = 255LL;
if ( (unsigned __int8)(a1 - 91) <= 5u )
return result;
}
else
{
result = 255LL;
if ( a1 > 0x39u )
return result;
}
if ( a1 <= 0x39u )
{
result = (unsigned int)a1 + 4;
}
else if ( a1 <= 0x5Au )
{
result = (unsigned int)a1 - 65;
}
else
{
result = (unsigned int)a1 - 71;
if ( a1 >= 0x7Bu )
result = 255LL;
}
}
else
{
result = 255LL;
if ( a1 == 43 )
result = 62LL;
}
}
return result;
}

original_code:
inline static unsigned base64_dec_char(unsigned char v)
{
 switch(v){
  case '/':
   return 0x3f;
  case '+':
   return 0x3e;
  case ':':
  case ';':
  case '<':
  case '=':
  case '>':
  case '?':
  case '@':
  case '[':
  case '\\':
  case ']':
  case '^':
  case '_':
  case '`':
   return 0xff;
  default:
   if ((v)<'0')
    return 0xff;
   if ((v)<='9')
    return (v)-'0'+0x34;
   else if ((v)<='Z')
    return (v)-'A';
   else if ((v) <='z')
    return (v)-'a'+0x1a;
 }
 return 0xff;
}

canonical_original_code:
inline static unsigned int base64_dec_char(unsigned char v)
{
 switch(v){
  case '/':
   return 0x3f;
  case '+':
   return 0x3e;
  case ':':
  case ';':
  case '<':
  case '=':
  case '>':
  case '?':
  case '@':
  case '[':
  case '\\':
  case ']':
  case '^':
  case '_':
  case '`':
   return 0xff;
  default:
   if ((v)<'0')
    return 0xff;
   if ((v)<='9')
    return (v)-'0'+0x34;
   else if ((v)<='Z')
    return (v)-'A';
   else if ((v) <='z')
    return (v)-'a'+0x1a;
 }
 return 0xff;
}

return_type: unsigned int


decompiled_code:
__int64 init_basex()
{
__int64 v0; // r12
unsigned __int8 v1; // bl
__int64 v2; // rbx
unsigned __int8 v3; // bp
unsigned __int8 v4; // bp
unsigned __int8 v5; // bp
__int64 v6; // rbp
__int64 v7; // rbx

v0 = 0LL;
do
{
v1 = base64_enc_char((unsigned __int8)((int)v0 >> 6));
bx_b64_12[v0] = v1 | (unsigned __int16)((unsigned __int16)base64_enc_char(v0 & 0x3F) << 8);
v2 = v0 + 1;
v3 = base64_enc_char((unsigned __int8)(((int)v0 + 1) >> 6));
bx_b64_12[v2] = v3 | (unsigned __int16)((unsigned __int16)base64_enc_char(((_BYTE)v0 + 1) & 0x3F) << 8);
v4 = base64_enc_char((unsigned __int8)(((int)v0 + 2) >> 6));
bx_b64_12[v0 + 2] = v4 | (unsigned __int16)((unsigned __int16)base64_enc_char(((_BYTE)v0 + 2) & 0x3F) << 8);
v5 = base64_enc_char((unsigned __int8)(((int)v0 + 3) >> 6));
bx_b64_12[v0 + 3] = v5 | (unsigned __int16)((unsigned __int16)base64_enc_char(((_BYTE)v0 + 3) & 0x3F) << 8);
v0 += 4LL;
}
while ( v2 != 4093 );
v6 = 0LL;
do
{
bx_ub64[v6] = base64_dec_char(v6);
v7 = v6 + 1;
bx_ub64[v6 + 1] = base64_dec_char((unsigned __int8)v6 + 1);
bx_ub64[v6 + 2] = base64_dec_char((unsigned __int8)v6 + 2);
bx_ub64[v6 + 3] = base64_dec_char((unsigned __int8)v6 + 3);
bx_ub64[v6 + 4] = base64_dec_char((unsigned __int8)v6 + 4);
bx_ub64[v6 + 5] = base64_dec_char((unsigned __int8)v6 + 5);
bx_ub64[v6 + 6] = base64_dec_char((unsigned __int8)v6 + 6);
bx_ub64[v6 + 7] = base64_dec_char((unsigned __int8)v6 + 7);
v6 += 8LL;
}
while ( v7 != 249 );
return 0LL;
}

original_code:
int init_basex()
{
 int r;
 for (r=0; r< 4096; r++)
  _bx_b64_12[r]=base64_enc_char(r>>6)|(base64_enc_char(r&0x3f)<<8);
 for (r=0; r<256; r++)
  _bx_ub64[r]=base64_dec_char((unsigned char)r);
 return 0;
}

variable_types: r int


decompiled_code:
char *__fastcall mi_print_fmt(char *format, __gnuc_va_list arg, int *a3)
{
char *v4; // rbp
int v5; // eax
__int64 v6; // rbx
const char *v8; // r12
unsigned int v9; // eax
int *v10; // rax
char *v11; // r12
int *v12; // rax
char *v13; // rbp
const char *v14; // r13
unsigned int v15; // eax

v4 = mi_fmt_buf;
if ( mi_fmt_buf || !(unsigned int)mi_fmt_init(2048LL) )
{
v5 = vsnprintf(mi_fmt_buf, mi_fmt_buf_len, format, arg);
v6 = (unsigned int)v5;
if ( v5 < 0 || mi_fmt_buf_len <= v5 )
{
v4 = 0LL;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = _errno_location();
v13 = strerror(*v12);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
process_no,
v15,
v14,
"<core> [fmt.h:63]: ",
"mi_print_fmt",
v6,
v13);
if ( log_color )
dprint_color_reset();
}
else
{
v10 = _errno_location();
v11 = strerror(*v10);
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): formatting failed with n=%d, %s\n",
*((const char **)&log_level_info + 8),
"<core> [fmt.h:63]: ",
"mi_print_fmt",
(unsigned int)v6,
v11);
}
--dprint_crit;
v4 = 0LL;
}
}
else
{
*a3 = v5;
v4 = mi_fmt_buf;
}
}
else if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(stderr, "%2d(%d) %s: %s%s(): failed to init\n", process_no, v9, v8, "<core> [fmt.h:56]: ", "mi_print_fmt");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to init\n",
*((const char **)&log_level_info + 8),
"<core> [fmt.h:56]: ",
"mi_print_fmt");
}
--dprint_crit;
}
return v4;
}

canonical_decompiled_code:
char *__fastcall func0(char *format, __gnuc_va_list arg, int *a3)
{
char *v4; // rbp
int v5; // eax
__int64 v6; // rbx
const char *v8; // r12
unsigned int v9; // eax
int *v10; // rax
char *v11; // r12
int *v12; // rax
char *v13; // rbp
const char *v14; // r13
unsigned int v15; // eax

v4 = mi_fmt_buf;
if ( mi_fmt_buf || !(unsigned int)mi_fmt_init(2048LL) )
{
v5 = vsnprintf(mi_fmt_buf, mi_fmt_buf_len, format, arg);
v6 = (unsigned int)v5;
if ( v5 < 0 || mi_fmt_buf_len <= v5 )
{
v4 = 0LL;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = _errno_location();
v13 = strerror(*v12);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
process_no,
v15,
v14,
"<core> [fmt.h:63]: ",
"mi_print_fmt",
v6,
v13);
if ( log_color )
dprint_color_reset();
}
else
{
v10 = _errno_location();
v11 = strerror(*v10);
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): formatting failed with n=%d, %s\n",
*((const char **)&log_level_info + 8),
"<core> [fmt.h:63]: ",
"mi_print_fmt",
(unsigned int)v6,
v11);
}
--dprint_crit;
v4 = 0LL;
}
}
else
{
*a3 = v5;
v4 = mi_fmt_buf;
}
}
else if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(stderr, "%2d(%d) %s: %s%s(): failed to init\n", process_no, v9, v8, "<core> [fmt.h:56]: ", "mi_print_fmt");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to init\n",
*((const char **)&log_level_info + 8),
"<core> [fmt.h:56]: ",
"mi_print_fmt");
}
--dprint_crit;
}
return v4;
}

original_code:
static inline char* mi_print_fmt(char *fmt, va_list ap, int *len)
{
 int n;
 if (mi_fmt_buf==((void *)0)) {
  if (mi_fmt_init(2048)!=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(): " "failed to init\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "56" "]: ") , __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(): " "failed to init\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "56" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to init\n", process_no, my_pid(), ("<core> [" "fmt.h" ":" "56" "]: ") , __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(): " "failed to init\n", ("<core> [" "fmt.h" ":" "56" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to init\n", ("<core> [" "fmt.h" ":" "56" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return 0;
  }
 }
 n = vsnprintf( mi_fmt_buf, mi_fmt_buf_len, fmt, ap);
 if (n<0 || n>=mi_fmt_buf_len) {
  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(): " "formatting failed with n=%d, %s\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); 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(): " "formatting failed with n=%d, %s\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "formatting failed with n=%d, %s\n", process_no, my_pid(), ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); 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(): " "formatting failed with n=%d, %s\n", ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "formatting failed with n=%d, %s\n", ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); } } (dprint_crit--); } } while(0);
  return 0;
 }
 *len = n;
 return mi_fmt_buf;
}

canonical_original_code:
static inline char *mi_print_fmt(char *fmt, __builtin_va_list ap, int *len)
{
 int n;
 if (mi_fmt_buf==((void *)0)) {
  if (mi_fmt_init(2048)!=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(): " "failed to init\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "56" "]: ") , __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(): " "failed to init\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "56" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to init\n", process_no, my_pid(), ("<core> [" "fmt.h" ":" "56" "]: ") , __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(): " "failed to init\n", ("<core> [" "fmt.h" ":" "56" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to init\n", ("<core> [" "fmt.h" ":" "56" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return 0;
  }
 }
 n = vsnprintf( mi_fmt_buf, mi_fmt_buf_len, fmt, ap);
 if (n<0 || n>=mi_fmt_buf_len) {
  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(): " "formatting failed with n=%d, %s\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); 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(): " "formatting failed with n=%d, %s\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "formatting failed with n=%d, %s\n", process_no, my_pid(), ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); 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(): " "formatting failed with n=%d, %s\n", ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "formatting failed with n=%d, %s\n", ("<core> [" "fmt.h" ":" "63" "]: ") , __func__,n,strerror((*__errno_location ()))); } } (dprint_crit--); } } while(0);
  return 0;
 }
 *len = n;
 return mi_fmt_buf;
}

variable_types:
fmt
char *

variable_types:
len
int *

variable_types: n int

return_type: char *


decompiled_code:
char *addf_mi_attr(__int64 a1, char a2, const char *a3, int a4, char *a5, ...)
{
char *result; // rax
int v8; // [rsp+4h] [rbp-F4h] BYREF
gcc_va_list arg; // [rsp+8h] [rbp-F0h] BYREF

va_start(arg, a5);
v8 = 0;
result = mi_print_fmt(a5, arg, &v8);
if ( result )
result = add_mi_attr(a1, a2 | 2u, a3, a4, result, v8);
return result;
}

canonical_decompiled_code:
char *func2(__int64 a1, char a2, const char *a3, int a4, char *a5, ...)
{
char *result; // rax
int v8; // [rsp+4h] [rbp-F4h] BYREF
gcc_va_list arg; // [rsp+8h] [rbp-F0h] BYREF

va_start(arg, a5);
v8 = 0;
result = func0(a5, arg, &v8);
if ( result )
result = func1(a1, a2 | 2u, a3, a4, result, v8);
return result;
}

original_code:
struct mi_attr *addf_mi_attr(struct mi_node *node, int flags,
       char *name, int name_len, char *fmt_val, ...)
{
 va_list ap;
 char *p;
 int len = 0;
 __builtin_va_start(ap,fmt_val);
 p = mi_print_fmt( fmt_val, ap, &len);
 __builtin_va_end(ap);
 if (p==((void *)0))
  return 0;
 return add_mi_attr(node, flags|(1<<1), name, name_len, p, len);
}

canonical_original_code:
struct mi_attr *addf_mi_attr(struct mi_node *node, int flags, char *name, int name_len, char *fmt_val, ...)
{
 __builtin_va_list ap;
 char *p;
 int len = 0;
 __builtin_va_start(ap,fmt_val);
 p = mi_print_fmt( fmt_val, ap, &len);
 __builtin_va_end(ap);
 if (p==((void *)0))
  return 0;
 return add_mi_attr(node, flags|(1<<1), name, name_len, p, len);
}

variable_types: struct mi_node { struct _str value; struct _str name; struct mi_node *kids; struct mi_node *next; struct mi_node *last; struct mi_attr *attributes; } *

variable_types: flags int

variable_types:
name
char *

variable_types:
p
char *

variable_types: len int

return_type: struct mi_attr { struct _str { char *s; int len; } name; struct _str value; struct mi_attr *next; } *

user_defined_types: struct mi_attr { struct _str name; struct _str value; struct mi_attr *next; }


decompiled_code:
__int64 __fastcall get_mi_attr_by_name(__int64 a1, const char *a2, int a3)
{
__int64 v4; // rbp
__int64 v5; // rbx
__int64 result; // rax
int v7; // edx

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v4 = *(_QWORD *)(a1 + 56);
if ( !v4 )
return 0LL;
v5 = *(_QWORD *)(v4 + 32);
if ( !v5 )
return 0LL;
while ( 1 )
{
v7 = *(_DWORD *)(v4 + 8);
if ( v7 == a3 && !strncasecmp(a2, *(const char **)v4, v7) )
break;
result = *(_QWORD *)(v5 + 32);
v4 = v5;
if ( !result )
return result;
v5 = *(_QWORD *)(v5 + 32);
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2, int a3)
{
__int64 v4; // rbp
__int64 v5; // rbx
__int64 result; // rax
int v7; // edx

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v4 = *(_QWORD *)(a1 + 56);
if ( !v4 )
return 0LL;
v5 = *(_QWORD *)(v4 + 32);
if ( !v5 )
return 0LL;
while ( 1 )
{
v7 = *(_DWORD *)(v4 + 8);
if ( v7 == a3 && !strncasecmp(a2, *(const char **)v4, v7) )
break;
result = *(_QWORD *)(v5 + 32);
v4 = v5;
if ( !result )
return result;
v5 = *(_QWORD *)(v5 + 32);
}
return v4;
}

original_code:
struct mi_attr *get_mi_attr_by_name(struct mi_node *node, char *name, int len)
{
 struct mi_attr *head;
 if(!node || !name || !(node->attributes))
  return ((void *)0);
 for(head = node->attributes ; head->next ; head = head->next)
  if(len == head->name.len
  && !strncasecmp(name, head->name.s, head->name.len))
   return head;
 return ((void *)0);
}

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

user_defined_types: struct mi_node { struct _str value; struct _str name; struct mi_node *kids; struct mi_node *next; struct mi_node *last; struct mi_attr *attributes; }


decompiled_code:
void __fastcall del_mi_attr_list(__int64 a1)
{
_QWORD *v2; // rbx
void *v3; // rdi

if ( a1 )
{
v2 = *(_QWORD **)(a1 + 56);
if ( v2 )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[4];
free(v3);
}
while ( v2 );
*(_QWORD *)(a1 + 56) = 0LL;
}
}
}

original_code:
void del_mi_attr_list(struct mi_node *node)
{
 struct mi_attr *p, *head;
 if(!node || !(node->attributes))
  return;
 for(head = node->attributes; head ;){
  p = head->next;
  free(head);
  head = p;
 }
 node->attributes = ((void *)0);
}

canonical_original_code:
void del_mi_attr_list(struct mi_node *node)
{
 struct mi_attr *p; struct mi_attr *head;
 if(!node || !(node->attributes))
  return;
 for(head = node->attributes; head ;){
  p = head->next;
  free(head);
  head = p;
 }
 node->attributes = ((void *)0);
}

variable_types: struct mi_node { struct _str { char *s; int len; } value; struct _str name; struct mi_node *kids; struct mi_node *next; struct mi_node *last; struct mi_attr { struct _str name; struct _str value; struct mi_attr *next; } *attributes; } *

return_type: void


decompiled_code:
__int64 get_stat_val()
{
return counter_get_val();
}

canonical_decompiled_code:
__int64 func0()
{
return counter_get_val();
}

original_code:
inline static unsigned long get_stat_val(stat_var *v)
{
 counter_handle_t h;
 h.id = (unsigned short)(unsigned long)v;
 return (unsigned long)counter_get_val(h);
}

canonical_original_code:
inline static unsigned long get_stat_val(void *v)
{
 struct counter_handle_s h;
 h.id = (unsigned short)(unsigned long)v;
 return (unsigned long)counter_get_val(h);
}

variable_types:
v
void *

variable_types: struct counter_handle_s { unsigned short id; }

return_type: unsigned long


decompiled_code:
unsigned __int64 get_avg_uar_response_time()
{
unsigned __int64 v0; // rbx

v0 = get_stat_val(uar_replies_received);
if ( v0 )
v0 = get_stat_val(uar_replies_response_time) / v0;
return v0;
}

canonical_decompiled_code:
unsigned __int64 func2()
{
unsigned __int64 v0; // rbx

v0 = func0(uar_replies_received);
if ( v0 )
v0 = func0(uar_replies_response_time) / v0;
return v0;
}

original_code:
unsigned long get_avg_uar_response_time() {
 long rpls_received = get_stat_val(uar_replies_received);
 if (!rpls_received)
  return 0;
 return get_stat_val(uar_replies_response_time)/rpls_received;
}


decompiled_code:
unsigned __int64 get_avg_lir_response_time()
{
unsigned __int64 v0; // rbx

v0 = get_stat_val(lir_replies_received);
if ( v0 )
v0 = get_stat_val(lir_replies_response_time) / v0;
return v0;
}

canonical_decompiled_code:
unsigned __int64 func3()
{
unsigned __int64 v0; // rbx

v0 = func0(lir_replies_received);
if ( v0 )
v0 = func0(lir_replies_response_time) / v0;
return v0;
}

original_code:
unsigned long get_avg_lir_response_time() {
 long rpls_received = get_stat_val(lir_replies_received);
 if (!rpls_received)
  return 0;
 return get_stat_val(lir_replies_response_time)/rpls_received;
}


decompiled_code:
__int64 __fastcall mi_fmt_init(size_t size)
{
__int64 result; // rax
int v2; // ecx
const char *v3; // rbx
unsigned int v4; // eax

mi_fmt_buf = malloc((unsigned int)size);
if ( mi_fmt_buf )
{
mi_fmt_buf_len = size;
result = 0LL;
}
else
{
v2 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more pkg mem\n",
process_no,
v4,
v3,
"<core> [fmt.c:47]: ",
"mi_fmt_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more pkg mem\n",
*((const char **)&log_level_info + 8),
"<core> [fmt.c:47]: ",
"mi_fmt_init");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(size_t size)
{
__int64 result; // rax
int v2; // ecx
const char *v3; // rbx
unsigned int v4; // eax

mi_fmt_buf = malloc((unsigned int)size);
if ( mi_fmt_buf )
{
mi_fmt_buf_len = size;
result = 0LL;
}
else
{
v2 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more pkg mem\n",
process_no,
v4,
v3,
"<core> [fmt.c:47]: ",
"mi_fmt_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more pkg mem\n",
*((const char **)&log_level_info + 8),
"<core> [fmt.c:47]: ",
"mi_fmt_init");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int mi_fmt_init( unsigned int size )
{
 mi_fmt_buf = (char*)malloc(size);
 if (mi_fmt_buf==((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 mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.c" ":" "47" "]: ") , __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 mem\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.c" ":" "47" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more pkg mem\n", process_no, my_pid(), ("<core> [" "fmt.c" ":" "47" "]: ") , __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 mem\n", ("<core> [" "fmt.c" ":" "47" "]: ") , __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 mem\n", ("<core> [" "fmt.c" ":" "47" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 mi_fmt_buf_len = size;
 return 0;
}

canonical_original_code:
int mi_fmt_init(unsigned int size)
{
 mi_fmt_buf = (char *)malloc(size);
 if (mi_fmt_buf==((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 mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.c" ":" "47" "]: ") , __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 mem\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "fmt.c" ":" "47" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more pkg mem\n", process_no, my_pid(), ("<core> [" "fmt.c" ":" "47" "]: ") , __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 mem\n", ("<core> [" "fmt.c" ":" "47" "]: ") , __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 mem\n", ("<core> [" "fmt.c" ":" "47" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 mi_fmt_buf_len = size;
 return 0;
}

variable_types:
size
unsigned int


decompiled_code:
unsigned int *__fastcall get_counter(const char *a1)
{
unsigned int *v1; // rbx
__int64 v3; // r12
const char *v4; // r13
unsigned int v5; // eax
__int64 v6; // r13
const char *v7; // r12
unsigned int v8; // eax

v1 = (unsigned int *)g_hash_table_lookup(hash, a1);
if ( !v1 )
{
v3 = g_strdup(a1);
v1 = (unsigned int *)qm_malloc(mem_block, 4LL);
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = (const char *)*((_QWORD *)&log_level_info + 16);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): counter created @0x%08x\n",
process_no,
v5,
v4,
"purple [hashtable.c:39]: ",
"get_counter",
v1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): counter created @0x%08x\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:39]: ",
"get_counter",
(unsigned int)v1);
}
--dprint_crit;
}
*v1 = 0;
g_hash_table_insert(hash, v3, v1);
}
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = *v1;
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): counter@0x%08x: key: %s ; value: %d\n",
process_no,
v8,
v7,
"purple [hashtable.c:43]: ",
"get_counter",
v1,
a1,
v6);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): counter@0x%08x: key: %s ; value: %d\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:43]: ",
"get_counter",
(unsigned int)v1,
a1,
*v1);
}
--dprint_crit;
}
return v1;
}

canonical_decompiled_code:
unsigned int *__fastcall func0(const char *a1)
{
unsigned int *v1; // rbx
__int64 v3; // r12
const char *v4; // r13
unsigned int v5; // eax
__int64 v6; // r13
const char *v7; // r12
unsigned int v8; // eax

v1 = (unsigned int *)g_hash_table_lookup(hash, a1);
if ( !v1 )
{
v3 = g_strdup(a1);
v1 = (unsigned int *)qm_malloc(mem_block, 4LL);
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = (const char *)*((_QWORD *)&log_level_info + 16);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): counter created @0x%08x\n",
process_no,
v5,
v4,
"purple [hashtable.c:39]: ",
"get_counter",
v1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): counter created @0x%08x\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:39]: ",
"get_counter",
(unsigned int)v1);
}
--dprint_crit;
}
*v1 = 0;
g_hash_table_insert(hash, v3, v1);
}
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = *v1;
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): counter@0x%08x: key: %s ; value: %d\n",
process_no,
v8,
v7,
"purple [hashtable.c:43]: ",
"get_counter",
v1,
a1,
v6);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): counter@0x%08x: key: %s ; value: %d\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:43]: ",
"get_counter",
(unsigned int)v1,
a1,
*v1);
}
--dprint_crit;
}
return v1;
}

original_code:
static int *get_counter(char *key) {
 int *d = g_hash_table_lookup(hash, key);
 if (d == ((void *)0)) {
  gchar *k = g_strdup(key);
  d = (int*) qm_malloc(mem_block, (sizeof(int)));
  do { if (get_debug_level("purple", (sizeof("purple")-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(): " "counter created @0x%08x\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); 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(): " "counter created @0x%08x\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "counter created @0x%08x\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); 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(): " "counter created @0x%08x\n", ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "counter created @0x%08x\n", ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); } } (dprint_crit--); } } while(0);
  *d = 0;
  g_hash_table_insert(hash, k, d);
 }
 do { if (get_debug_level("purple", (sizeof("purple")-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(): " "counter@0x%08x: key: %s ; value: %d\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); 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(): " "counter@0x%08x: key: %s ; value: %d\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "counter@0x%08x: key: %s ; value: %d\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); 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(): " "counter@0x%08x: key: %s ; value: %d\n", ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "counter@0x%08x: key: %s ; value: %d\n", ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); } } (dprint_crit--); } } while(0);
 return d;
}

canonical_original_code:
static int *get_counter(char *key) {
 int *d = g_hash_table_lookup(hash, key);
 if (d == ((void *)0)) {
  char *k = g_strdup(key);
  d = (int *) qm_malloc(mem_block, (sizeof(int)));
  do { if (get_debug_level("purple", (sizeof("purple")-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(): " "counter created @0x%08x\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); 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(): " "counter created @0x%08x\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "counter created @0x%08x\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); 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(): " "counter created @0x%08x\n", ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "counter created @0x%08x\n", ("purple" " [" "hashtable.c" ":" "39" "]: ") , __func__, (unsigned int)d); } } (dprint_crit--); } } while(0);
  *d = 0;
  g_hash_table_insert(hash, k, d);
 }
 do { if (get_debug_level("purple", (sizeof("purple")-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(): " "counter@0x%08x: key: %s ; value: %d\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); 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(): " "counter@0x%08x: key: %s ; value: %d\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "counter@0x%08x: key: %s ; value: %d\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); 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(): " "counter@0x%08x: key: %s ; value: %d\n", ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "counter@0x%08x: key: %s ; value: %d\n", ("purple" " [" "hashtable.c" ":" "43" "]: ") , __func__, (unsigned int)d, key, *d); } } (dprint_crit--); } } while(0);
 return d;
}

variable_types:
key
char *

variable_types:
d
int *

variable_types:
k
char *

return_type: int *


decompiled_code:
void __fastcall remove_counter(__int64 a1)
{
const char *v1; // rbx
unsigned int v2; // eax

if ( !(unsigned int)g_hash_table_remove(hash, a1) && (int)get_debug_level("purple", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v1 = (const char *)*((_QWORD *)&log_level_info + 8);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): error removing counter\n",
process_no,
v2,
v1,
"purple [hashtable.c:49]: ",
"remove_counter");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): error removing counter\n",
*((const char **)&log_level_info + 8),
"purple [hashtable.c:49]: ",
"remove_counter");
}
--dprint_crit;
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
const char *v1; // rbx
unsigned int v2; // eax

if ( !(unsigned int)g_hash_table_remove(hash, a1) && (int)get_debug_level("purple", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v1 = (const char *)*((_QWORD *)&log_level_info + 8);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): error removing counter\n",
process_no,
v2,
v1,
"purple [hashtable.c:49]: ",
"remove_counter");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): error removing counter\n",
*((const char **)&log_level_info + 8),
"purple [hashtable.c:49]: ",
"remove_counter");
}
--dprint_crit;
}
}

original_code:
static void remove_counter(char *key) {
 if (!g_hash_table_remove(hash, key))
  do { if (get_debug_level("purple", (sizeof("purple")-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(): " "error removing counter\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "49" "]: ") , __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(): " "error removing counter\n", (log_level_info[((-1)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "49" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "error removing counter\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "49" "]: ") , __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(): " "error removing counter\n", ("purple" " [" "hashtable.c" ":" "49" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "error removing counter\n", ("purple" " [" "hashtable.c" ":" "49" "]: ") , __func__); } } (dprint_crit--); } } while(0);
}


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

result = g_hash_table_new_full(&g_str_hash, &g_str_equal, &free, &free);
hash = result;
return result;
}

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

result = g_hash_table_new_full(&g_str_hash, &g_str_equal, &free, &free);
hash = result;
return result;
}

original_code:
void hashtable_init(void) {
 hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
}

canonical_original_code:
void hashtable_init() {
 hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
}


decompiled_code:
__int64 __fastcall hashtable_get_counter(const char *a1)
{
return *get_counter(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
return *func0(a1);
}

original_code:
int hashtable_get_counter(char* key) {
 int *d = get_counter(key);
 return *d;
}

canonical_original_code:
int hashtable_get_counter(char *key) {
 int *d = get_counter(key);
 return *d;
}


decompiled_code:
__int64 __fastcall hashtable_inc_counter(const char *a1)
{
unsigned int *v1; // rbx
__int64 result; // rax
const char *v3; // rbp
unsigned int v4; // eax

if ( (int)get_debug_level("purple", 6LL) > 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();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): incrementing counter for <%s>\n",
process_no,
v4,
v3,
"purple [hashtable.c:59]: ",
"hashtable_inc_counter",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): incrementing counter for <%s>\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:59]: ",
"hashtable_inc_counter",
a1);
}
--dprint_crit;
}
v1 = get_counter(a1);
result = *v1 + 1;
*v1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
unsigned int *v1; // rbx
__int64 result; // rax
const char *v3; // rbp
unsigned int v4; // eax

if ( (int)get_debug_level("purple", 6LL) > 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();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): incrementing counter for <%s>\n",
process_no,
v4,
v3,
"purple [hashtable.c:59]: ",
"hashtable_inc_counter",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): incrementing counter for <%s>\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:59]: ",
"hashtable_inc_counter",
a1);
}
--dprint_crit;
}
v1 = func0(a1);
result = *v1 + 1;
*v1 = result;
return result;
}

original_code:
int hashtable_inc_counter(char* key) {
 do { if (get_debug_level("purple", (sizeof("purple")-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(): " "incrementing counter for <%s>\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); 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(): " "incrementing counter for <%s>\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "incrementing counter for <%s>\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); 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(): " "incrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "incrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); } } (dprint_crit--); } } while(0);
 int *d = get_counter(key);
 *d = *d + 1;
 return *d;
}

canonical_original_code:
int hashtable_inc_counter(char *key) {
 do { if (get_debug_level("purple", (sizeof("purple")-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(): " "incrementing counter for <%s>\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); 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(): " "incrementing counter for <%s>\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "incrementing counter for <%s>\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); 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(): " "incrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "incrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "59" "]: ") , __func__, key); } } (dprint_crit--); } } while(0);
 int *d = get_counter(key);
 *d = *d + 1;
 return *d;
}


decompiled_code:
__int64 __fastcall hashtable_dec_counter(const char *a1)
{
unsigned int *v1; // rax
unsigned int *v2; // rbx
const char *v4; // rbx
unsigned int v5; // eax

if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = (const char *)*((_QWORD *)&log_level_info + 16);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): decrementing counter for <%s>\n",
process_no,
v5,
v4,
"purple [hashtable.c:66]: ",
"hashtable_dec_counter",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): decrementing counter for <%s>\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:66]: ",
"hashtable_dec_counter",
a1);
}
--dprint_crit;
}
v1 = get_counter(a1);
v2 = v1;
if ( (int)*v1 > 0 )
--*v1;
if ( !*v1 )
remove_counter((__int64)a1);
return *v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1)
{
unsigned int *v1; // rax
unsigned int *v2; // rbx
const char *v4; // rbx
unsigned int v5; // eax

if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = (const char *)*((_QWORD *)&log_level_info + 16);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): decrementing counter for <%s>\n",
process_no,
v5,
v4,
"purple [hashtable.c:66]: ",
"hashtable_dec_counter",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): decrementing counter for <%s>\n",
*((const char **)&log_level_info + 16),
"purple [hashtable.c:66]: ",
"hashtable_dec_counter",
a1);
}
--dprint_crit;
}
v1 = func0(a1);
v2 = v1;
if ( (int)*v1 > 0 )
--*v1;
if ( !*v1 )
func1((__int64)a1);
return *v2;
}

original_code:
int hashtable_dec_counter(char* key) {
 do { if (get_debug_level("purple", (sizeof("purple")-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(): " "decrementing counter for <%s>\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); 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(): " "decrementing counter for <%s>\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "decrementing counter for <%s>\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); 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(): " "decrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "decrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); } } (dprint_crit--); } } while(0);
 int *d = get_counter(key);
 if (*d > 0)
  *d = *d - 1;
 if (*d == 0)
  remove_counter(key);
 return *d;
}

canonical_original_code:
int hashtable_dec_counter(char *key) {
 do { if (get_debug_level("purple", (sizeof("purple")-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(): " "decrementing counter for <%s>\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); 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(): " "decrementing counter for <%s>\n", (log_level_info[((3)) - (-5)].name), ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "decrementing counter for <%s>\n", process_no, my_pid(), ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); 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(): " "decrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "decrementing counter for <%s>\n", ("purple" " [" "hashtable.c" ":" "66" "]: ") , __func__, key); } } (dprint_crit--); } } while(0);
 int *d = get_counter(key);
 if (*d > 0)
  *d = *d - 1;
 if (*d == 0)
  remove_counter(key);
 return *d;
}


decompiled_code:
__int64 __fastcall allocate_buffer(int a1)
{
int v1; // eax
int v2; // ebx
int v3; // ebp
int v4; // eax
__int64 result; // rax
__int64 v6; // r9
__int64 v7; // r11
__int64 v8; // rdi
__int64 v9; // r8

v1 = a1 + 255;
if ( a1 >= 0 )
v1 = a1;
LOBYTE(v1) = 0;
v2 = v1 + 256;
v3 = active_buffer;
if ( buffer[2 * active_buffer] )
{
v4 = active_buffer - 1;
if ( !active_buffer )
v4 = 1;
active_buffer = v4;
if ( SLODWORD(qword_888[2 * v4]) < a1 )
{
v8 = qm_realloc(mem_block, buffer[2 * v4], v2);
result = 0LL;
if ( v8 )
{
v9 = 2LL * active_buffer;
buffer[v9] = v8;
LODWORD(qword_888[v9]) = v2;
HIDWORD(qword_888[v9]) = 0;
result = 1LL;
}
}
else
{
HIDWORD(qword_888[2 * v4]) = 0;
result = 1LL;
}
}
else
{
v6 = qm_malloc(mem_block, v2);
buffer[2 * v3] = v6;
result = 0LL;
if ( v6 )
{
v7 = 2LL * active_buffer;
LODWORD(qword_888[v7]) = v2;
HIDWORD(qword_888[v7]) = 0;
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
int v1; // eax
int v2; // ebx
int v3; // ebp
int v4; // eax
__int64 result; // rax
__int64 v6; // r9
__int64 v7; // r11
__int64 v8; // rdi
__int64 v9; // r8

v1 = a1 + 255;
if ( a1 >= 0 )
v1 = a1;
LOBYTE(v1) = 0;
v2 = v1 + 256;
v3 = active_buffer;
if ( buffer[2 * active_buffer] )
{
v4 = active_buffer - 1;
if ( !active_buffer )
v4 = 1;
active_buffer = v4;
if ( SLODWORD(qword_888[2 * v4]) < a1 )
{
v8 = qm_realloc(mem_block, buffer[2 * v4], v2);
result = 0LL;
if ( v8 )
{
v9 = 2LL * active_buffer;
buffer[v9] = v8;
LODWORD(qword_888[v9]) = v2;
HIDWORD(qword_888[v9]) = 0;
result = 1LL;
}
}
else
{
HIDWORD(qword_888[2 * v4]) = 0;
result = 1LL;
}
}
else
{
v6 = qm_malloc(mem_block, v2);
buffer[2 * v3] = v6;
result = 0LL;
if ( v6 )
{
v7 = 2LL * active_buffer;
LODWORD(qword_888[v7]) = v2;
HIDWORD(qword_888[v7]) = 0;
result = 1LL;
}
}
return result;
}

original_code:
static int allocate_buffer(int req_size) {
 void *b;
 int size=(((req_size/256)+1)*256);
 if (buffer[active_buffer].b == ((void *)0)) {
  if ((buffer[active_buffer].b=qm_malloc(mem_block, (size)))==((void *)0))
   return 0;
  buffer[active_buffer].size=size;
  buffer[active_buffer].offset=0;
  return 1;
 }
 active_buffer = (active_buffer?active_buffer:2)-1;
 if (buffer[active_buffer].size >= req_size) {
  buffer[active_buffer].offset = 0;
  return 1;
 }
 if ((b=qm_realloc(mem_block, (buffer[active_buffer].b), (size)))) {
  buffer[active_buffer].b=b;
  buffer[active_buffer].size=size;
  buffer[active_buffer].offset=0;
  return 1;
 }
 return 0;
}

canonical_original_code:
static int allocate_buffer(int req_size) {
 void *b;
 int size = (((req_size/256)+1)*256);
 if (buffer[active_buffer].b == ((void *)0)) {
  if ((buffer[active_buffer].b=qm_malloc(mem_block, (size)))==((void *)0))
   return 0;
  buffer[active_buffer].size=size;
  buffer[active_buffer].offset=0;
  return 1;
 }
 active_buffer = (active_buffer?active_buffer:2)-1;
 if (buffer[active_buffer].size >= req_size) {
  buffer[active_buffer].offset = 0;
  return 1;
 }
 if ((b=qm_realloc(mem_block, (buffer[active_buffer].b), (size)))) {
  buffer[active_buffer].b=b;
  buffer[active_buffer].size=size;
  buffer[active_buffer].offset=0;
  return 1;
 }
 return 0;
}

variable_types:
b
void *

variable_types: size int


decompiled_code:
__int64 __fastcall get_static_buffer(int a1)
{
__int64 v2; // rsi
int v3; // edi
__int64 result; // rax
int v5; // ecx

if ( SLODWORD(qword_888[2 * active_buffer]) >= HIDWORD(qword_888[2 * active_buffer]) + a1
|| (v5 = allocate_buffer(a1), result = 0LL, v5) )
{
v2 = 2LL * active_buffer;
v3 = HIDWORD(qword_888[v2]);
result = buffer[v2] + v3;
HIDWORD(buffer[v2 + 1]) = a1 + v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 v2; // rsi
int v3; // edi
__int64 result; // rax
int v5; // ecx

if ( SLODWORD(qword_888[2 * active_buffer]) >= HIDWORD(qword_888[2 * active_buffer]) + a1
|| (v5 = func0(a1), result = 0LL, v5) )
{
v2 = 2LL * active_buffer;
v3 = HIDWORD(qword_888[v2]);
result = buffer[v2] + v3;
HIDWORD(buffer[v2 + 1]) = a1 + v3;
}
return result;
}

original_code:
char* get_static_buffer(int req_size) {
 char *p = ((void *)0);
 if ((buffer[active_buffer].size >= buffer[active_buffer].offset + req_size)
   || (allocate_buffer(req_size))) {
  p = buffer[active_buffer].b+buffer[active_buffer].offset;
  buffer[active_buffer].offset += req_size;
  return p;
 }
 return ((void *)0);
}

canonical_original_code:
char *get_static_buffer(int req_size) {
 char *p = ((void *)0);
 if ((buffer[active_buffer].size >= buffer[active_buffer].offset + req_size)
   || (allocate_buffer(req_size))) {
  p = buffer[active_buffer].b+buffer[active_buffer].offset;
  buffer[active_buffer].offset += req_size;
  return p;
 }
 return ((void *)0);
}


decompiled_code:
__int64 reset_static_buffer()
{
if ( active_buffer == -1 )
{
buffer[0] = 0LL;
qword_888[0] = 0LL;
qword_890 = 0LL;
unk_898 = 0LL;
}
else
{
HIDWORD(qword_888[0]) = 0;
dword_89C = 0;
}
active_buffer = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
if ( active_buffer == -1 )
{
buffer[0] = 0LL;
qword_888[0] = 0LL;
qword_890 = 0LL;
unk_898 = 0LL;
}
else
{
HIDWORD(qword_888[0]) = 0;
dword_89C = 0;
}
active_buffer = 0;
return 0LL;
}

original_code:
int reset_static_buffer(void) {
 int i;
 if (active_buffer == -1) {
  memset(buffer, 0, sizeof(buffer));
 } else {
  for (i=0; i<2; i++)
   buffer[i].offset=0;
 }
 active_buffer=0;
 return 0;
}

canonical_original_code:
int reset_static_buffer() {
 int i;
 if (active_buffer == -1) {
  memset(buffer, 0, sizeof(buffer));
 } else {
  for (i=0; i<2; i++)
   buffer[i].offset=0;
 }
 active_buffer=0;
 return 0;
}

variable_types: i int


decompiled_code:
__int64 __fastcall str_to_static_buffer(__int64 a1, __int64 a2)
{
void *v2; // rax

v2 = (void *)get_static_buffer(*(_DWORD *)(a2 + 8));
*(_QWORD *)a1 = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
memcpy(v2, *(const void **)a2, *(int *)(a2 + 8));
*(_DWORD *)(a1 + 8) = *(_DWORD *)(a2 + 8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
void *v2; // rax

v2 = (void *)func2(*(_DWORD *)(a2 + 8));
*(_QWORD *)a1 = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
memcpy(v2, *(const void **)a2, *(int *)(a2 + 8));
*(_DWORD *)(a1 + 8) = *(_DWORD *)(a2 + 8);
return 0LL;
}

original_code:
int str_to_static_buffer(str* res, str* s)
{
 res->s = get_static_buffer(s->len);
 if (!res->s) return -1;
 memcpy(res->s, s->s, s->len);
 res->len = s->len;
 return 0;
}

canonical_original_code:
int str_to_static_buffer(struct _str *res, struct _str *s)
{
 res->s = get_static_buffer(s->len);
 if (!res->s) return -1;
 memcpy(res->s, s->s, s->len);
 res->len = s->len;
 return 0;
}

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

variable_types:
s
struct _str *


decompiled_code:
__int64 __fastcall int_to_static_buffer(_DWORD *a1, int a2)
{
_BYTE *v2; // r12
_BYTE *v3; // rax

v2 = int2str((int)abs32(a2), a1 + 2);
v3 = (_BYTE *)get_static_buffer(a1[2] + ((unsigned int)a2 >> 31) != 0);
*(_QWORD *)a1 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
if ( a2 < 0 )
{
*v3 = 45;
memcpy((void *)(*(_QWORD *)a1 + 1LL), v2, (int)a1[2]++);
}
else
{
memcpy(v3, v2, (int)a1[2]);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1, int a2)
{
_BYTE *v2; // r12
_BYTE *v3; // rax

v2 = int2str((int)abs32(a2), a1 + 2);
v3 = (_BYTE *)func2(a1[2] + ((unsigned int)a2 >> 31) != 0);
*(_QWORD *)a1 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
if ( a2 < 0 )
{
*v3 = 45;
memcpy((void *)(*(_QWORD *)a1 + 1LL), v2, (int)a1[2]++);
}
else
{
memcpy(v3, v2, (int)a1[2]);
}
return 0LL;
}

original_code:
int int_to_static_buffer(str* res, int val)
{
 char *c;
 c = int2str(abs(val), &res->len);
 res->s = get_static_buffer(res->len+(val<0)?1:0);
 if (!res->s) return -1;
 if (val < 0) {
  res->s[0] = '-';
  memcpy(res->s+1, c, res->len);
  res->len++;
 }
 else {
  memcpy(res->s, c, res->len);
 }
 return 0;
}

canonical_original_code:
int int_to_static_buffer(struct _str *res, int val)
{
 char *c;
 c = int2str(abs(val), &res->len);
 res->s = get_static_buffer(res->len+(val<0)?1:0);
 if (!res->s) return -1;
 if (val < 0) {
  res->s[0] = '-';
  memcpy(res->s+1, c, res->len);
  res->len++;
 }
 else {
  memcpy(res->s, c, res->len);
 }
 return 0;
}

variable_types: val int

variable_types:
c
char *


decompiled_code:
__int64 __fastcall uint_to_static_buffer(__int64 a1, unsigned int a2)
{
_BYTE *v2; // rbp
void *v3; // rax

v2 = int2str(a2, (_DWORD *)(a1 + 8));
v3 = (void *)get_static_buffer(*(_DWORD *)(a1 + 8));
*(_QWORD *)a1 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
memcpy(v3, v2, *(int *)(a1 + 8));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2)
{
_BYTE *v2; // rbp
void *v3; // rax

v2 = int2str(a2, (_DWORD *)(a1 + 8));
v3 = (void *)func2(*(_DWORD *)(a1 + 8));
*(_QWORD *)a1 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
memcpy(v3, v2, *(int *)(a1 + 8));
return 0LL;
}

original_code:
int uint_to_static_buffer(str* res, unsigned int val)
{
 char *c;
 c = int2str(val, &res->len);
 res->s = get_static_buffer(res->len);
 if (!res->s) return -1;
 memcpy(res->s, c, res->len);
 return 0;
}

canonical_original_code:
int uint_to_static_buffer(struct _str *res, unsigned int val)
{
 char *c;
 c = int2str(val, &res->len);
 res->s = get_static_buffer(res->len);
 if (!res->s) return -1;
 memcpy(res->s, c, res->len);
 return 0;
}

variable_types:
val
unsigned int


decompiled_code:
__int64 __fastcall uint_to_static_buffer_ex(__int64 a1, unsigned int a2, unsigned int a3, int a4)
{
char *v4; // rbp
void *v5; // rax

v4 = int2str_base_0pad(a2, (_DWORD *)(a1 + 8), a3, a4);
v5 = (void *)get_static_buffer(*(_DWORD *)(a1 + 8));
*(_QWORD *)a1 = v5;
if ( !v5 )
return 0xFFFFFFFFLL;
memcpy(v5, v4, *(int *)(a1 + 8));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, unsigned int a3, int a4)
{
char *v4; // rbp
void *v5; // rax

v4 = func1(a2, (_DWORD *)(a1 + 8), a3, a4);
v5 = (void *)func2(*(_DWORD *)(a1 + 8));
*(_QWORD *)a1 = v5;
if ( !v5 )
return 0xFFFFFFFFLL;
memcpy(v5, v4, *(int *)(a1 + 8));
return 0LL;
}

original_code:
int uint_to_static_buffer_ex(str* res, unsigned int val, int base, int pad)
{
 char *c;
 c = int2str_base_0pad(val, &res->len, base, pad);
 res->s = get_static_buffer(res->len);
 if (!res->s) return -1;
 memcpy(res->s, c, res->len);
 return 0;
}

canonical_original_code:
int uint_to_static_buffer_ex(struct _str *res, unsigned int val, int base, int pad)
{
 char *c;
 c = int2str_base_0pad(val, &res->len, base, pad);
 res->s = get_static_buffer(res->len);
 if (!res->s) return -1;
 memcpy(res->s, c, res->len);
 return 0;
}

variable_types: base int

variable_types: pad int