initdynstr

decompiled_code:
__int64 __fastcall initdynstr(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 result; // rax
int v4; // er8
const char *v5; // r12
struct _IO_FILE *v6; // rdi
__int64 v7; // [rsp-20h] [rbp-28h]
unsigned int v8; // [rsp-18h] [rbp-20h]

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

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 result; // rax
int v4; // er8
const char *v5; // r12
struct _IO_FILE *v6; // rdi
__int64 v7; // [rsp-20h] [rbp-28h]
unsigned int v8; // [rsp-18h] [rbp-20h]

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

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

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

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

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


repo: virtualolson/who

decompiled_code:
__int64 __fastcall cpy2dynstr(__int64 a1, __int64 a2)
{
int v2; // er12
void *v4; // rdi
size_t v5; // rdx
__int64 v6; // rax
__int64 result; // rax
int v8; // er8
const char *v9; // r12
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-10h] [rbp-28h]
unsigned int v12; // [rsp-8h] [rbp-20h]

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
int v2; // er12
void *v4; // rdi
size_t v5; // rdx
__int64 v6; // rax
__int64 result; // rax
int v8; // er8
const char *v9; // r12
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-10h] [rbp-28h]
unsigned int v12; // [rsp-8h] [rbp-20h]

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

return_type: int


decompiled_code:
__int64 __fastcall app2dynchr(__int64 a1, char a2)
{
__int64 v3; // rcx
__int64 v4; // rsi
__int64 result; // rax
__int64 v6; // rax
__int64 v7; // rcx
int v8; // er8
char v9; // cc
__int64 v10; // r8
__int64 v11; // rsi
__int64 v12; // rdi
const char *v13; // r12
struct _IO_FILE *v14; // rdi
__int64 v15; // [rsp-10h] [rbp-28h]
unsigned int v16; // [rsp-8h] [rbp-20h]

v3 = *(int *)(a1 + 8);
v4 = *(_QWORD *)a1;
if ( *(_DWORD *)(a1 + 16) >= (int)v3 + 1 )
goto LABEL_2;
v6 = qm_realloc(mem_block, v4, (int)v3 + 1);
v4 = v6;
if ( v6 )
{
++*(_DWORD *)(a1 + 16);
v3 = *(int *)(a1 + 8);
*(_QWORD *)a1 = v6;
LABEL_2:
*(_BYTE *)(v4 + v3) = a2;
result = 0LL;
++*(_DWORD *)(a1 + 8);
return result;
}
v8 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
v9 = (v8 + 1 < 0) ^ __OFADD__(1, v8);
v10 = (unsigned int)(v8 + 1);
if ( !v9 )
{
v11 = dprint_crit;
if ( !dprint_crit )
{
v12 = ++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v12 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v16 = my_pid(v12, v11, &log_level_info, v7, v10);
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n",
process_no,
v16,
v13,
"auth_identity [auth_dynstr.c:89]: ",
"app2dynchr");
if ( log_color )
dprint_color_reset(v14, "%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n", v15);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char a2)
{
__int64 v3; // rcx
__int64 v4; // rsi
__int64 result; // rax
__int64 v6; // rax
__int64 v7; // rcx
int v8; // er8
char v9; // cc
__int64 v10; // r8
__int64 v11; // rsi
__int64 v12; // rdi
const char *v13; // r12
struct _IO_FILE *v14; // rdi
__int64 v15; // [rsp-10h] [rbp-28h]
unsigned int v16; // [rsp-8h] [rbp-20h]

v3 = *(int *)(a1 + 8);
v4 = *(_QWORD *)a1;
if ( *(_DWORD *)(a1 + 16) >= (int)v3 + 1 )
goto LABEL_2;
v6 = qm_realloc(mem_block, v4, (int)v3 + 1);
v4 = v6;
if ( v6 )
{
++*(_DWORD *)(a1 + 16);
v3 = *(int *)(a1 + 8);
*(_QWORD *)a1 = v6;
LABEL_2:
*(_BYTE *)(v4 + v3) = a2;
result = 0LL;
++*(_DWORD *)(a1 + 8);
return result;
}
v8 = get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
v9 = (v8 + 1 < 0) ^ __OFADD__(1, v8);
v10 = (unsigned int)(v8 + 1);
if ( !v9 )
{
v11 = dprint_crit;
if ( !dprint_crit )
{
v12 = ++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v12 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v16 = my_pid(v12, v11, &log_level_info, v7, v10);
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n",
process_no,
v16,
v13,
"auth_identity [auth_dynstr.c:89]: ",
"app2dynchr");
if ( log_color )
dprint_color_reset(v14, "%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynchr: Not enough memory error\n", v15);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
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: capp char


decompiled_code:
__int64 __fastcall app2dynstr(__int64 a1, __int64 a2)
{
size_t v4; // rdx
__int64 v5; // rdi
__int64 v6; // rsi
int v7; // er12
__int64 v8; // rax
__int64 result; // rax
__int64 v10; // rdi
__int64 v11; // r8
__int64 v12; // rdx
__int64 v13; // rcx
const char *v14; // r12
struct _IO_FILE *v15; // rdi
__int64 v16; // [rsp-10h] [rbp-28h]
unsigned int v17; // [rsp-8h] [rbp-20h]

v4 = *(int *)(a2 + 8);
v5 = *(int *)(a1 + 8);
v6 = *(_QWORD *)a1;
v7 = v5 + v4;
if ( *(_DWORD *)(a1 + 16) >= (int)v5 + (int)v4 )
goto LABEL_4;
v8 = qm_realloc(mem_block, v6, v7);
v6 = v8;
if ( v8 )
{
v4 = *(int *)(a2 + 8);
v5 = *(int *)(a1 + 8);
*(_QWORD *)a1 = v8;
*(_DWORD *)(a1 + 16) = v7;
LABEL_4:
memcpy((void *)(v6 + v5), *(const void **)a2, v4);
*(_DWORD *)(a1 + 8) = v7;
return 0LL;
}
v10 = (__int64)"auth_identity";
v11 = (unsigned int)get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( (int)v11 >= -1 )
{
v12 = dprint_crit;
if ( !dprint_crit )
{
v13 = ++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v10 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v17 = my_pid(v10, &log_stderr, v12, v13, v11);
v15 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n",
process_no,
v17,
v14,
"auth_identity [auth_dynstr.c:110]: ",
"app2dynstr");
if ( log_color )
dprint_color_reset(v15, "%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n", v16);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
size_t v4; // rdx
__int64 v5; // rdi
__int64 v6; // rsi
int v7; // er12
__int64 v8; // rax
__int64 result; // rax
__int64 v10; // rdi
__int64 v11; // r8
__int64 v12; // rdx
__int64 v13; // rcx
const char *v14; // r12
struct _IO_FILE *v15; // rdi
__int64 v16; // [rsp-10h] [rbp-28h]
unsigned int v17; // [rsp-8h] [rbp-20h]

v4 = *(int *)(a2 + 8);
v5 = *(int *)(a1 + 8);
v6 = *(_QWORD *)a1;
v7 = v5 + v4;
if ( *(_DWORD *)(a1 + 16) >= (int)v5 + (int)v4 )
goto LABEL_4;
v8 = qm_realloc(mem_block, v6, v7);
v6 = v8;
if ( v8 )
{
v4 = *(int *)(a2 + 8);
v5 = *(int *)(a1 + 8);
*(_QWORD *)a1 = v8;
*(_DWORD *)(a1 + 16) = v7;
LABEL_4:
memcpy((void *)(v6 + v5), *(const void **)a2, v4);
*(_DWORD *)(a1 + 8) = v7;
return 0LL;
}
v10 = (__int64)"auth_identity";
v11 = (unsigned int)get_debug_level("auth_identity", 13LL);
result = 0xFFFFFFFFLL;
if ( (int)v11 >= -1 )
{
v12 = dprint_crit;
if ( !dprint_crit )
{
v13 = ++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v10 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v17 = my_pid(v10, &log_stderr, v12, v13, v11);
v15 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n",
process_no,
v17,
v14,
"auth_identity [auth_dynstr.c:110]: ",
"app2dynstr");
if ( log_color )
dprint_color_reset(v15, "%2d(%d) %s: %s%s(): AUTH_IDENTITY:app2dynstr: Not enough memory error\n", v16);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
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
{
result = (unsigned int)(a1 - 4);
if ( (unsigned __int8)a1 <= 0x33u )
result = (unsigned int)(a1 + 71);
}
}
}
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
{
result = (unsigned int)(a1 - 4);
if ( (unsigned __int8)a1 <= 0x33u )
result = (unsigned int)(a1 + 71);
}
}
}
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


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, __int64 a4, const char *a5, const char *a6)
{
__gnuc_va_list v6; // rcx
char *v8; // r12
int v9; // eax
__int64 v10; // rbx
unsigned int v12; // er13
int *v13; // rax
char *v14; // rax
__int64 v15; // rdi
char *v16; // r12
const char *v17; // r14
unsigned int v18; // eax
struct _IO_FILE *v19; // rdi
__int64 v20; // rcx
const char *v21; // r8
const char *v22; // r9
const char *v23; // r13
unsigned int v24; // eax
struct _IO_FILE *v25; // rdi
__int64 v26; // rdx
__int64 v27; // rcx
const char *v28; // [rsp-10h] [rbp-58h]
const char *v29; // [rsp-8h] [rbp-50h]
const char *v30; // [rsp+0h] [rbp-48h]
int *v31; // [rsp+8h] [rbp-40h]
const char *v32; // [rsp+10h] [rbp-38h]

v6 = arg;
v8 = (char *)mi_fmt_buf;
if ( mi_fmt_buf )
goto LABEL_2;
if ( !(unsigned int)mi_fmt_init(
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
arg,
a3,
(const char *)arg,
a5,
a6,
v30,
(const char *)arg) )
{
v8 = (char *)mi_fmt_buf;
v6 = v31;
LABEL_2:
v9 = vsnprintf(v8, mi_fmt_buf_len, format, v6);
v10 = (unsigned int)v9;
if ( v9 >= 0 && mi_fmt_buf_len > v9 )
{
*a3 = v9;
return (char *)mi_fmt_buf;
}
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
v12 = log_stderr;
++dprint_crit;
v13 = _errno_location();
if ( v12 )
{
if ( log_color )
{
v31 = v13;
dprint_color(0xFFFFFFFFLL);
v13 = v31;
}
v16 = strerror(*v13);
v17 = (const char *)*((_QWORD *)&log_level_info + 8);
v18 = my_pid();
v19 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
process_no,
v18,
v17,
"<core> [fmt.h:63]: ",
"mi_print_fmt",
v10,
v16);
if ( log_color )
dprint_color_reset(
v19,
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
log_color,
v20,
v21,
v22,
v30,
v31,
v32);
}
else
{
v14 = strerror(*v13);
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)v10,
v14);
}
--dprint_crit;
}
return 0LL;
}
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return 0LL;
v15 = log_stderr;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v15 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v23 = (const char *)*((_QWORD *)&log_level_info + 8);
v24 = my_pid();
v29 = (const char *)v15;
v25 = stderr;
fprintf(stderr, "%2d(%d) %s: %s%s(): failed to init\n", process_no, v24, v23, "<core> [fmt.h:56]: ", "mi_print_fmt");
if ( log_color )
dprint_color_reset(v25, "%2d(%d) %s: %s%s(): failed to init\n", v26, v27, v28, v29, v30);
}
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 v8;
}

canonical_decompiled_code:
char *__fastcall func0(char *format, __gnuc_va_list arg, int *a3, __int64 a4, const char *a5, const char *a6)
{
__gnuc_va_list v6; // rcx
char *v8; // r12
int v9; // eax
__int64 v10; // rbx
unsigned int v12; // er13
int *v13; // rax
char *v14; // rax
__int64 v15; // rdi
char *v16; // r12
const char *v17; // r14
unsigned int v18; // eax
struct _IO_FILE *v19; // rdi
__int64 v20; // rcx
const char *v21; // r8
const char *v22; // r9
const char *v23; // r13
unsigned int v24; // eax
struct _IO_FILE *v25; // rdi
__int64 v26; // rdx
__int64 v27; // rcx
const char *v28; // [rsp-10h] [rbp-58h]
const char *v29; // [rsp-8h] [rbp-50h]
const char *v30; // [rsp+0h] [rbp-48h]
int *v31; // [rsp+8h] [rbp-40h]
const char *v32; // [rsp+10h] [rbp-38h]

v6 = arg;
v8 = (char *)mi_fmt_buf;
if ( mi_fmt_buf )
goto LABEL_2;
if ( !(unsigned int)mi_fmt_init(
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
arg,
a3,
(const char *)arg,
a5,
a6,
v30,
(const char *)arg) )
{
v8 = (char *)mi_fmt_buf;
v6 = v31;
LABEL_2:
v9 = vsnprintf(v8, mi_fmt_buf_len, format, v6);
v10 = (unsigned int)v9;
if ( v9 >= 0 && mi_fmt_buf_len > v9 )
{
*a3 = v9;
return (char *)mi_fmt_buf;
}
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
v12 = log_stderr;
++dprint_crit;
v13 = _errno_location();
if ( v12 )
{
if ( log_color )
{
v31 = v13;
dprint_color(0xFFFFFFFFLL);
v13 = v31;
}
v16 = strerror(*v13);
v17 = (const char *)*((_QWORD *)&log_level_info + 8);
v18 = my_pid();
v19 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
process_no,
v18,
v17,
"<core> [fmt.h:63]: ",
"mi_print_fmt",
v10,
v16);
if ( log_color )
dprint_color_reset(
v19,
"%2d(%d) %s: %s%s(): formatting failed with n=%d, %s\n",
log_color,
v20,
v21,
v22,
v30,
v31,
v32);
}
else
{
v14 = strerror(*v13);
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)v10,
v14);
}
--dprint_crit;
}
return 0LL;
}
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return 0LL;
v15 = log_stderr;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v15 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v23 = (const char *)*((_QWORD *)&log_level_info + 8);
v24 = my_pid();
v29 = (const char *)v15;
v25 = stderr;
fprintf(stderr, "%2d(%d) %s: %s%s(): failed to init\n", process_no, v24, v23, "<core> [fmt.h:56]: ", "mi_print_fmt");
if ( log_color )
dprint_color_reset(v25, "%2d(%d) %s: %s%s(): failed to init\n", v26, v27, v28, v29, v30);
}
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 v8;
}

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:
const char *addf_mi_attr(__int64 a1, char a2, const char *a3, __int64 a4, char *a5, ...)
{
int v5; // er13
const char *result; // rax
unsigned int v8; // [rsp+4h] [rbp-F4h] BYREF
gcc_va_list arg; // [rsp+8h] [rbp-F0h] BYREF
const char *v10; // [rsp+48h] [rbp-B0h]

va_start(arg, a5);
v10 = va_arg(arg, const char *);
va_end(arg);
va_start(arg, a5);
v5 = a4;
v8 = 0;
result = mi_print_fmt(a5, arg, (int *)&v8, a4, a5, v10);
if ( result )
result = (const char *)add_mi_attr(a1, a2 | 2u, a3, v5, result, v8);
return result;
}

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

va_start(arg, a5);
v10 = va_arg(arg, const char *);
va_end(arg);
va_start(arg, a5);
v5 = a4;
v8 = 0;
result = func0(a5, arg, (int *)&v8, a4, a5, v10);
if ( result )
result = (const char *)add_mi_attr(a1, a2 | 2u, a3, v5, 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 v3; // rbp
__int64 v4; // rbx
size_t v6; // r14
__int64 result; // rax

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v3 = *(_QWORD *)(a1 + 56);
if ( !v3 )
return 0LL;
v4 = *(_QWORD *)(v3 + 32);
if ( !v4 )
return 0LL;
v6 = a3;
while ( *(_DWORD *)(v3 + 8) != a3 || strncasecmp(a2, *(const char **)v3, v6) )
{
result = *(_QWORD *)(v4 + 32);
v3 = v4;
if ( !result )
return result;
v4 = *(_QWORD *)(v4 + 32);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2, int a3)
{
__int64 v3; // rbp
__int64 v4; // rbx
size_t v6; // r14
__int64 result; // rax

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v3 = *(_QWORD *)(a1 + 56);
if ( !v3 )
return 0LL;
v4 = *(_QWORD *)(v3 + 32);
if ( !v4 )
return 0LL;
v6 = a3;
while ( *(_DWORD *)(v3 + 8) != a3 || strncasecmp(a2, *(const char **)v3, v6) )
{
result = *(_QWORD *)(v4 + 32);
v3 = v4;
if ( !result )
return result;
v4 = *(_QWORD *)(v4 + 32);
}
return v3;
}

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:
// attributes: thunk
__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; // r12

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; // r12

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; // r12

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; // r12

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
__int64 v2; // rdx
int v3; // er8
char v4; // cc
__int64 v5; // r8
__int64 v6; // rcx
__int64 v7; // rdi
__int64 v8; // rsi
const char *v9; // r12
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-10h] [rbp-28h]
unsigned int v12; // [rsp-8h] [rbp-20h]

mi_fmt_buf = malloc((unsigned int)size);
if ( mi_fmt_buf )
{
mi_fmt_buf_len = size;
result = 0LL;
}
else
{
v3 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
v4 = (v3 + 1 < 0) ^ __OFADD__(1, v3);
v5 = (unsigned int)(v3 + 1);
if ( !v4 )
{
v6 = dprint_crit;
if ( !dprint_crit )
{
v7 = (__int64)&log_stderr;
v8 = ++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v7 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL, v8, v2, v6, v5);
}
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v12 = my_pid(v7, v8, v2, v6, v5);
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more pkg mem\n",
process_no,
v12,
v9,
"<core> [fmt.c:47]: ",
"mi_fmt_init");
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): no more pkg mem\n", v11);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(size_t size)
{
__int64 result; // rax
__int64 v2; // rdx
int v3; // er8
char v4; // cc
__int64 v5; // r8
__int64 v6; // rcx
__int64 v7; // rdi
__int64 v8; // rsi
const char *v9; // r12
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-10h] [rbp-28h]
unsigned int v12; // [rsp-8h] [rbp-20h]

mi_fmt_buf = malloc((unsigned int)size);
if ( mi_fmt_buf )
{
mi_fmt_buf_len = size;
result = 0LL;
}
else
{
v3 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
v4 = (v3 + 1 < 0) ^ __OFADD__(1, v3);
v5 = (unsigned int)(v3 + 1);
if ( !v4 )
{
v6 = dprint_crit;
if ( !dprint_crit )
{
v7 = (__int64)&log_stderr;
v8 = ++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v7 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL, v8, v2, v6, v5);
}
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v12 = my_pid(v7, v8, v2, v6, v5);
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more pkg mem\n",
process_no,
v12,
v9,
"<core> [fmt.c:47]: ",
"mi_fmt_init");
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): no more pkg mem\n", v11);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
}
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 *v2; // r12
__int64 v4; // r13
int v5; // eax
__int64 v6; // r14
const char *v7; // r15
unsigned int v8; // eax
struct _IO_FILE *v9; // rdi
__int64 v10; // rcx
const char *v11; // r8
const char *v12; // r9
const char *v13; // r15
unsigned int v14; // eax
struct _IO_FILE *v15; // rdi
__int64 v16; // rdx
const char *v17; // [rsp-10h] [rbp-58h]
const char *v18; // [rsp+0h] [rbp-48h]
__int64 v19; // [rsp+8h] [rbp-40h]
const char *v20; // [rsp+10h] [rbp-38h]
__int64 v21; // [rsp+18h] [rbp-30h]

v2 = (unsigned int *)g_hash_table_lookup(hash, a1);
if ( !v2 )
{
v4 = g_strdup(a1);
v2 = (unsigned int *)qm_malloc(mem_block, 4LL);
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
v5 = (int)v2;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
dprint_color(3LL);
v5 = (int)v2;
}
HIDWORD(v19) = v5;
v13 = (const char *)*((_QWORD *)&log_level_info + 16);
v14 = my_pid();
v15 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): counter created @0x%08x\n",
process_no,
v14,
v13,
"purple [hashtable.c:39]: ",
"get_counter",
HIDWORD(v19));
if ( log_color )
dprint_color_reset(
v15,
"%2d(%d) %s: %s%s(): counter created @0x%08x\n",
v16,
&log_color,
v17,
(const char *)log_color,
v18,
v19);
}
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)v2);
}
--dprint_crit;
}
*v2 = 0;
g_hash_table_insert(hash, v4, v2);
}
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = *v2;
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
v9 = stderr;
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",
(unsigned int)v2,
a1,
v6);
if ( log_color )
dprint_color_reset(
v9,
"%2d(%d) %s: %s%s(): counter@0x%08x: key: %s ; value: %d\n",
log_color,
v10,
v11,
v12,
v18,
v19,
v20,
v21);
}
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)v2,
a1,
*v2);
}
--dprint_crit;
}
return v2;
}

canonical_decompiled_code:
unsigned int *__fastcall func0(const char *a1)
{
unsigned int *v2; // r12
__int64 v4; // r13
int v5; // eax
__int64 v6; // r14
const char *v7; // r15
unsigned int v8; // eax
struct _IO_FILE *v9; // rdi
__int64 v10; // rcx
const char *v11; // r8
const char *v12; // r9
const char *v13; // r15
unsigned int v14; // eax
struct _IO_FILE *v15; // rdi
__int64 v16; // rdx
const char *v17; // [rsp-10h] [rbp-58h]
const char *v18; // [rsp+0h] [rbp-48h]
__int64 v19; // [rsp+8h] [rbp-40h]
const char *v20; // [rsp+10h] [rbp-38h]
__int64 v21; // [rsp+18h] [rbp-30h]

v2 = (unsigned int *)g_hash_table_lookup(hash, a1);
if ( !v2 )
{
v4 = g_strdup(a1);
v2 = (unsigned int *)qm_malloc(mem_block, 4LL);
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
v5 = (int)v2;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
dprint_color(3LL);
v5 = (int)v2;
}
HIDWORD(v19) = v5;
v13 = (const char *)*((_QWORD *)&log_level_info + 16);
v14 = my_pid();
v15 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): counter created @0x%08x\n",
process_no,
v14,
v13,
"purple [hashtable.c:39]: ",
"get_counter",
HIDWORD(v19));
if ( log_color )
dprint_color_reset(
v15,
"%2d(%d) %s: %s%s(): counter created @0x%08x\n",
v16,
&log_color,
v17,
(const char *)log_color,
v18,
v19);
}
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)v2);
}
--dprint_crit;
}
*v2 = 0;
g_hash_table_insert(hash, v4, v2);
}
if ( (int)get_debug_level("purple", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = *v2;
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
v9 = stderr;
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",
(unsigned int)v2,
a1,
v6);
if ( log_color )
dprint_color_reset(
v9,
"%2d(%d) %s: %s%s(): counter@0x%08x: key: %s ; value: %d\n",
log_color,
v10,
v11,
v12,
v18,
v19,
v20,
v21);
}
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)v2,
a1,
*v2);
}
--dprint_crit;
}
return v2;
}

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; // r12
unsigned int v2; // eax
struct _IO_FILE *v3; // rdi
const char *v4; // r8
const char *v5; // r9
__int64 v6; // [rsp-8h] [rbp-20h]
const char *v7; // [rsp+0h] [rbp-18h]

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();
v3 = stderr;
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(v3, "%2d(%d) %s: %s%s(): error removing counter\n", v6, log_color, v4, v5, v7);
}
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; // r12
unsigned int v2; // eax
struct _IO_FILE *v3; // rdi
const char *v4; // r8
const char *v5; // r9
__int64 v6; // [rsp-8h] [rbp-20h]
const char *v7; // [rsp+0h] [rbp-18h]

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();
v3 = stderr;
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(v3, "%2d(%d) %s: %s%s(): error removing counter\n", v6, log_color, v4, v5, v7);
}
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 *v2; // rbp
__int64 result; // rax
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
const char *v7; // r8
const char *v8; // r9
__int64 v9; // [rsp-8h] [rbp-30h]
const char *v10; // [rsp+0h] [rbp-28h]
const char *v11; // [rsp+8h] [rbp-20h]

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();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): incrementing counter for <%s>\n",
process_no,
v5,
v4,
"purple [hashtable.c:59]: ",
"hashtable_inc_counter",
a1);
if ( log_color )
dprint_color_reset(v6, "%2d(%d) %s: %s%s(): incrementing counter for <%s>\n", v9, log_color, v7, v8, v10, v11);
}
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;
}
v2 = get_counter(a1);
result = *v2 + 1;
*v2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
unsigned int *v2; // rbp
__int64 result; // rax
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
const char *v7; // r8
const char *v8; // r9
__int64 v9; // [rsp-8h] [rbp-30h]
const char *v10; // [rsp+0h] [rbp-28h]
const char *v11; // [rsp+8h] [rbp-20h]

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();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): incrementing counter for <%s>\n",
process_no,
v5,
v4,
"purple [hashtable.c:59]: ",
"hashtable_inc_counter",
a1);
if ( log_color )
dprint_color_reset(v6, "%2d(%d) %s: %s%s(): incrementing counter for <%s>\n", v9, log_color, v7, v8, v10, v11);
}
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;
}
v2 = func0(a1);
result = *v2 + 1;
*v2 = 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 *v2; // rbx
__int64 result; // rax
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
const char *v7; // r8
const char *v8; // r9
__int64 v9; // [rsp-8h] [rbp-30h]
const char *v10; // [rsp+0h] [rbp-28h]
const char *v11; // [rsp+8h] [rbp-20h]

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();
v6 = stderr;
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(v6, "%2d(%d) %s: %s%s(): decrementing counter for <%s>\n", v9, log_color, v7, v8, v10, v11);
}
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;
}
v2 = get_counter(a1);
result = *v2;
if ( (int)result > 0 )
{
result = (unsigned int)(result - 1);
*v2 = result;
}
if ( !(_DWORD)result )
{
remove_counter((__int64)a1);
result = *v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1)
{
unsigned int *v2; // rbx
__int64 result; // rax
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
const char *v7; // r8
const char *v8; // r9
__int64 v9; // [rsp-8h] [rbp-30h]
const char *v10; // [rsp+0h] [rbp-28h]
const char *v11; // [rsp+8h] [rbp-20h]

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();
v6 = stderr;
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(v6, "%2d(%d) %s: %s%s(): decrementing counter for <%s>\n", v9, log_color, v7, v8, v10, v11);
}
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;
}
v2 = func0(a1);
result = *v2;
if ( (int)result > 0 )
{
result = (unsigned int)(result - 1);
*v2 = result;
}
if ( !(_DWORD)result )
{
func1((__int64)a1);
result = *v2;
}
return result;
}

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
__int64 v2; // rbx
int v3; // ebp
int v4; // eax
__int64 v5; // rax
__int64 result; // rax
__int64 v7; // rax
__int64 v8; // rsi
__int64 v9; // rax
__int64 v10; // rdi

v1 = a1 + 255;
if ( a1 >= 0 )
v1 = a1;
v2 = active_buffer;
LOBYTE(v1) = 0;
v3 = v1 + 256;
if ( *(_QWORD *)&buffer[v2] )
{
v4 = active_buffer - 1;
if ( !active_buffer )
v4 = 1;
active_buffer = v4;
v5 = v4;
if ( SDWORD2(buffer[v5]) >= a1 )
{
HIDWORD(buffer[v5]) = 0;
return 1LL;
}
v7 = qm_realloc(mem_block, *(_QWORD *)&buffer[v5], v3);
if ( v7 )
{
v8 = active_buffer;
*(_QWORD *)&buffer[v8] = v7;
result = 1LL;
DWORD2(buffer[v8]) = v3;
HIDWORD(buffer[v8]) = 0;
return result;
}
return 0LL;
}
v9 = qm_malloc(mem_block, v3, active_buffer);
*(_QWORD *)&buffer[v2] = v9;
if ( !v9 )
return 0LL;
result = 1LL;
v10 = active_buffer;
DWORD2(buffer[v10]) = v3;
HIDWORD(buffer[v10]) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
int v1; // eax
__int64 v2; // rbx
int v3; // ebp
int v4; // eax
__int64 v5; // rax
__int64 result; // rax
__int64 v7; // rax
__int64 v8; // rsi
__int64 v9; // rax
__int64 v10; // rdi

v1 = a1 + 255;
if ( a1 >= 0 )
v1 = a1;
v2 = active_buffer;
LOBYTE(v1) = 0;
v3 = v1 + 256;
if ( *(_QWORD *)&buffer[v2] )
{
v4 = active_buffer - 1;
if ( !active_buffer )
v4 = 1;
active_buffer = v4;
v5 = v4;
if ( SDWORD2(buffer[v5]) >= a1 )
{
HIDWORD(buffer[v5]) = 0;
return 1LL;
}
v7 = qm_realloc(mem_block, *(_QWORD *)&buffer[v5], v3);
if ( v7 )
{
v8 = active_buffer;
*(_QWORD *)&buffer[v8] = v7;
result = 1LL;
DWORD2(buffer[v8]) = v3;
HIDWORD(buffer[v8]) = 0;
return result;
}
return 0LL;
}
v9 = qm_malloc(mem_block, v3, active_buffer);
*(_QWORD *)&buffer[v2] = v9;
if ( !v9 )
return 0LL;
result = 1LL;
v10 = active_buffer;
DWORD2(buffer[v10]) = v3;
HIDWORD(buffer[v10]) = 0;
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 v1; // rdx
__int64 v2; // rcx
__int64 v3; // rax
int v4; // esi
__int64 v5; // rdx
__int64 result; // rax
int v7; // er8

v1 = active_buffer;
v2 = active_buffer;
v3 = SHIDWORD(buffer[v2]);
v4 = v3 + a1;
if ( SDWORD2(buffer[v2]) >= (int)v3 + a1 )
goto LABEL_2;
v7 = allocate_buffer(a1);
result = 0LL;
if ( v7 )
{
v1 = active_buffer;
v3 = SHIDWORD(buffer[active_buffer]);
v4 = a1 + v3;
LABEL_2:
v5 = v1;
HIDWORD(buffer[v5]) = v4;
result = *(_QWORD *)&buffer[v5] + v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 v1; // rdx
__int64 v2; // rcx
__int64 v3; // rax
int v4; // esi
__int64 v5; // rdx
__int64 result; // rax
int v7; // er8

v1 = active_buffer;
v2 = active_buffer;
v3 = SHIDWORD(buffer[v2]);
v4 = v3 + a1;
if ( SDWORD2(buffer[v2]) >= (int)v3 + a1 )
goto LABEL_2;
v7 = func0(a1);
result = 0LL;
if ( v7 )
{
v1 = active_buffer;
v3 = SHIDWORD(buffer[active_buffer]);
v4 = a1 + v3;
LABEL_2:
v5 = v1;
HIDWORD(buffer[v5]) = v4;
result = *(_QWORD *)&buffer[v5] + 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()
{
__int64 result; // rax

if ( active_buffer == -1 )
{
active_buffer = 0;
result = 0LL;
buffer[0] = 0LL;
unk_930 = 0LL;
}
else
{
HIDWORD(buffer[0]) = 0;
result = 0LL;
dword_93C = 0;
active_buffer = 0;
}
return result;
}

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

if ( active_buffer == -1 )
{
active_buffer = 0;
result = 0LL;
buffer[0] = 0LL;
unk_930 = 0LL;
}
else
{
HIDWORD(buffer[0]) = 0;
result = 0LL;
dword_93C = 0;
active_buffer = 0;
}
return result;
}

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 *