original_code:
int str2q(qvalue_t* q, char* s, int len)
{
 int i, digits, order;
 enum {
  ST_START,
  ST_0,
  ST_1,
  ST_0_PT,
  ST_1_PT,
  ST_1_PT_0,
  ST_0_PT_N
 } state = ST_START;
 if (!q || !s) {
  return -14;
 }
 digits = 1;
 order = 100;
 for(i = 0; i < len; i++) {
  switch(state) {
  case ST_START:
   switch(s[i]) {
   case ' ':
   case '\t':
    break;
   case '0':
    *q = 0;
    state = ST_0;
    break;
   case '1':
    *q = 1000;
    state = ST_1;
    break;
   case '.':
    state = ST_0_PT;
    break;
   default:
    return -15;
   }
   break;
  case ST_0:
   switch(s[i]) {
   case '0':
    break;
   case '.':
    state = ST_0_PT;
    break;
   case '1':
    *q = 1000;
    state = ST_1;
    break;
   default:
    if (s[i] >= '2' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_1:
   if (s[i] == '.') {
    state = ST_1_PT;
    break;
   } else {
    if (s[i] >= '0' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_0_PT:
   if (s[i] >= '0' && s[i] <= '9') {
    *q = (s[i] - '0') * order;
    order /= 10;
    state = ST_0_PT_N;
   } else {
    return -15;
   }
   break;
  case ST_1_PT:
   if (s[i] == '0') {
    state = ST_1_PT_0;
   } else {
    if (s[i] >= '1' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_1_PT_0:
   if (s[i] == '0') {
    break;
   } else {
    if (s[i] >= '1' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_0_PT_N:
   if (s[i] >= '0' && s[i] <= '9') {
    if (digits <= 3) {
     *q += (s[i] - '0') * order;
     order /= 10;
     digits++;
    }
   } else {
    return -15;
   }
   break;
  }
 }
 switch(state) {
 case ST_START:
  return -16;
 case ST_0_PT:
 case ST_1_PT:
  return -18;
 default:
  return 0;
 }
}

canonical_original_code:
int str2q(int *q, char *s, int len)
{
 int i; int digits; int order;
 enum { ST_START=0, ST_0=1, ST_1=2, ST_0_PT=3, ST_1_PT=4, ST_1_PT_0=5, ST_0_PT_N=6 } state = ST_START;
 if (!q || !s) {
  return -14;
 }
 digits = 1;
 order = 100;
 for(i = 0; i < len; i++) {
  switch(state) {
  case ST_START:
   switch(s[i]) {
   case ' ':
   case '\t':
    break;
   case '0':
    *q = 0;
    state = ST_0;
    break;
   case '1':
    *q = 1000;
    state = ST_1;
    break;
   case '.':
    state = ST_0_PT;
    break;
   default:
    return -15;
   }
   break;
  case ST_0:
   switch(s[i]) {
   case '0':
    break;
   case '.':
    state = ST_0_PT;
    break;
   case '1':
    *q = 1000;
    state = ST_1;
    break;
   default:
    if (s[i] >= '2' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_1:
   if (s[i] == '.') {
    state = ST_1_PT;
    break;
   } else {
    if (s[i] >= '0' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_0_PT:
   if (s[i] >= '0' && s[i] <= '9') {
    *q = (s[i] - '0') * order;
    order /= 10;
    state = ST_0_PT_N;
   } else {
    return -15;
   }
   break;
  case ST_1_PT:
   if (s[i] == '0') {
    state = ST_1_PT_0;
   } else {
    if (s[i] >= '1' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_1_PT_0:
   if (s[i] == '0') {
    break;
   } else {
    if (s[i] >= '1' && s[i] <= '9') {
     return -17;
    } else {
     return -15;
    }
   }
   break;
  case ST_0_PT_N:
   if (s[i] >= '0' && s[i] <= '9') {
    if (digits <= 3) {
     *q += (s[i] - '0') * order;
     order /= 10;
     digits++;
    }
   } else {
    return -15;
   }
   break;
  }
 }
 switch(state) {
 case ST_START:
  return -16;
 case ST_0_PT:
 case ST_1_PT:
  return -18;
 default:
  return 0;
 }
}

variable_types:
q
int *

variable_types:
s
char *

variable_types: len int

variable_types: i int

variable_types: digits int

variable_types: order int


repo: virtualolson/who

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

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

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

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

variable_types:
v
void *

variable_types: struct counter_handle_s { unsigned short id; }

return_type: unsigned long


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

v0 = get_stat_val(mar_replies_received);
if ( v0 )
v0 = get_stat_val(mar_replies_response_time) / v0;
return v0;
}

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

v0 = func0(mar_replies_received);
if ( v0 )
v0 = func0(mar_replies_response_time) / v0;
return v0;
}

original_code:
unsigned long get_avg_mar_response_time() {
 long rpls_received = get_stat_val(mar_replies_received);
 if (!rpls_received)
  return 0;
 return get_stat_val(mar_replies_response_time)/rpls_received;
}


decompiled_code:
__int64 __fastcall trim_leading(unsigned __int8 **a1)
{
__int64 result; // rax
int v2; // edx
unsigned __int8 *v3; // r10
unsigned __int8 v4; // cl
unsigned __int8 *v5; // r11
unsigned __int8 v6; // cl
unsigned __int8 *v7; // r9
unsigned __int8 v8; // cl
unsigned __int8 v9; // cl
unsigned __int8 v10; // cl
unsigned __int8 v11; // cl
char *v12; // r10
unsigned __int8 v13; // cl

result = *((unsigned int *)a1 + 2);
if ( (int)result > 0 )
{
v2 = (_DWORD)a1[1] & 3;
if ( (result & 3) != 0 )
{
if ( v2 != 1 )
{
if ( v2 != 2 )
{
v3 = *a1;
v4 = **a1;
if ( v4 > 0x20u || ((1LL << v4) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v3 + 1;
}
v5 = *a1;
v6 = **a1;
if ( v6 > 0x20u || ((1LL << v6) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v5 + 1;
}
v7 = *a1;
v8 = **a1;
if ( v8 > 0x20u )
return result;
if ( ((1LL << v8) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v7 + 1;
if ( !(_DWORD)result )
return result;
}
do
{
v12 = (char *)*a1;
v13 = **a1;
if ( v13 > 0x20u )
break;
if ( ((1LL << v13) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 1);
v9 = v12[1];
if ( v9 > 0x20u )
break;
if ( ((1LL << v9) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 1;
*a1 = (unsigned __int8 *)(v12 + 2);
v10 = v12[2];
if ( v10 > 0x20u )
break;
if ( ((1LL << v10) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 2;
*a1 = (unsigned __int8 *)(v12 + 3);
v11 = v12[3];
if ( v11 > 0x20u )
break;
if ( ((1LL << v11) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 3);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 4);
}
while ( (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 **a1)
{
__int64 result; // rax
int v2; // edx
unsigned __int8 *v3; // r10
unsigned __int8 v4; // cl
unsigned __int8 *v5; // r11
unsigned __int8 v6; // cl
unsigned __int8 *v7; // r9
unsigned __int8 v8; // cl
unsigned __int8 v9; // cl
unsigned __int8 v10; // cl
unsigned __int8 v11; // cl
char *v12; // r10
unsigned __int8 v13; // cl

result = *((unsigned int *)a1 + 2);
if ( (int)result > 0 )
{
v2 = (_DWORD)a1[1] & 3;
if ( (result & 3) != 0 )
{
if ( v2 != 1 )
{
if ( v2 != 2 )
{
v3 = *a1;
v4 = **a1;
if ( v4 > 0x20u || ((1LL << v4) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v3 + 1;
}
v5 = *a1;
v6 = **a1;
if ( v6 > 0x20u || ((1LL << v6) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v5 + 1;
}
v7 = *a1;
v8 = **a1;
if ( v8 > 0x20u )
return result;
if ( ((1LL << v8) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v7 + 1;
if ( !(_DWORD)result )
return result;
}
do
{
v12 = (char *)*a1;
v13 = **a1;
if ( v13 > 0x20u )
break;
if ( ((1LL << v13) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 1);
v9 = v12[1];
if ( v9 > 0x20u )
break;
if ( ((1LL << v9) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 1;
*a1 = (unsigned __int8 *)(v12 + 2);
v10 = v12[2];
if ( v10 > 0x20u )
break;
if ( ((1LL << v10) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 2;
*a1 = (unsigned __int8 *)(v12 + 3);
v11 = v12[3];
if ( v11 > 0x20u )
break;
if ( ((1LL << v11) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 3);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 4);
}
while ( (_DWORD)result );
}
return result;
}

original_code:
static inline void trim_leading(str* _s)
{
 for(; _s->len > 0; _s->len--, _s->s++) {
  switch(*(_s->s)) { case ' ': case '\t': case '\r': case '\n': break; default: return; };
 }
}

canonical_original_code:
static inline void trim_leading(struct _str *_s)
{
 for(; _s->len > 0; _s->len--, _s->s++) {
  switch(*(_s->s)) { case ' ': case '\t': case '\r': case '\n': break; default: return; };
 }
}

return_type: void


decompiled_code:
__int64 __fastcall etag_parser(_BYTE *a1, int a2, _BYTE **a3)
{
int v4; // esi
unsigned __int8 *v5; // rbp
__int64 result; // rax
int v7; // edx
const char *v8; // rbx
unsigned int v9; // eax

*a3 = a1;
*((_DWORD *)a3 + 2) = a2;
trim_leading(a3);
v4 = *((_DWORD *)a3 + 2);
if ( v4 )
{
v5 = *a3;
*((_DWORD *)a3 + 2) = (unsigned int)skip_token(*a3, v4) - (_DWORD)v5;
result = 0LL;
}
else
{
v7 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v7 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): etag_parser(): Empty body\n",
process_no,
v9,
v8,
"<core> [parser/parse_sipifmatch.c:64]: ",
"etag_parser");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): etag_parser(): Empty body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_sipifmatch.c:64]: ",
"etag_parser");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1, int a2, _BYTE **a3)
{
int v4; // esi
unsigned __int8 *v5; // rbp
__int64 result; // rax
int v7; // edx
const char *v8; // rbx
unsigned int v9; // eax

*a3 = a1;
*((_DWORD *)a3 + 2) = a2;
func0(a3);
v4 = *((_DWORD *)a3 + 2);
if ( v4 )
{
v5 = *a3;
*((_DWORD *)a3 + 2) = (unsigned int)skip_token(*a3, v4) - (_DWORD)v5;
result = 0LL;
}
else
{
v7 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v7 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): etag_parser(): Empty body\n",
process_no,
v9,
v8,
"<core> [parser/parse_sipifmatch.c:64]: ",
"etag_parser");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): etag_parser(): Empty body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_sipifmatch.c:64]: ",
"etag_parser");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int etag_parser(char *_s, int _l, str *_e)
{
        char* end;
        _e->s = _s;
        _e->len = _l;
        trim_leading(_e);
        if (_e->len == 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(): " "etag_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __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(): " "etag_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "etag_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __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(): " "etag_parser(): Empty body\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "etag_parser(): Empty body\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                return -1;
        }
        end = skip_token(_e->s, _e->len);
        _e->len = end - _e->s;
 return 0;
}

canonical_original_code:
int etag_parser(char *_s, int _l, struct _str *_e)
{
        char *end;
        _e->s = _s;
        _e->len = _l;
        trim_leading(_e);
        if (_e->len == 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(): " "etag_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __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(): " "etag_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "etag_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __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(): " "etag_parser(): Empty body\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "etag_parser(): Empty body\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "64" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                return -1;
        }
        end = skip_token(_e->s, _e->len);
        _e->len = end - _e->s;
 return 0;
}

variable_types:
end
char *

return_type: int

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


decompiled_code:
__int64 __fastcall parse_sipifmatch(__int64 a1)
{
__int64 result; // rax
const char *v2; // rbp
unsigned int v3; // eax
__int64 v4; // rax
__int64 v5; // rbp
int v6; // er11
const char *v7; // rbp
unsigned int v8; // eax
const char *v9; // rbx
unsigned int v10; // eax

if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 16);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch() called\n",
process_no,
v3,
v2,
"<core> [parser/parse_sipifmatch.c:79]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_sipifmatch() called\n",
*((const char **)&log_level_info + 16),
"<core> [parser/parse_sipifmatch.c:79]: ",
"parse_sipifmatch");
}
--dprint_crit;
}
result = 0LL;
if ( !*(_QWORD *)(a1 + 48) )
{
v4 = qm_malloc(mem_block, 16LL);
v5 = v4;
if ( v4 )
{
*(_QWORD *)v4 = 0LL;
*(_QWORD *)(v4 + 8) = 0LL;
if ( (int)etag_parser(*(_BYTE **)(a1 + 24), *(_DWORD *)(a1 + 32), (_BYTE **)v4) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch(): Error in tag_parser\n",
process_no,
v10,
v9,
"<core> [parser/parse_sipifmatch.c:94]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_sipifmatch(): Error in tag_parser\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_sipifmatch.c:94]: ",
"parse_sipifmatch");
}
--dprint_crit;
}
qm_free(mem_block, v5);
result = 4294967294LL;
}
else
{
*(_QWORD *)(a1 + 48) = v5;
result = 0LL;
}
}
else
{
v6 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v6 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_ifsipmatch(): No memory left\n",
process_no,
v8,
v7,
"<core> [parser/parse_sipifmatch.c:87]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_ifsipmatch(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_sipifmatch.c:87]: ",
"parse_sipifmatch");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
const char *v2; // rbp
unsigned int v3; // eax
__int64 v4; // rax
__int64 v5; // rbp
int v6; // er11
const char *v7; // rbp
unsigned int v8; // eax
const char *v9; // rbx
unsigned int v10; // eax

if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 16);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch() called\n",
process_no,
v3,
v2,
"<core> [parser/parse_sipifmatch.c:79]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_sipifmatch() called\n",
*((const char **)&log_level_info + 16),
"<core> [parser/parse_sipifmatch.c:79]: ",
"parse_sipifmatch");
}
--dprint_crit;
}
result = 0LL;
if ( !*(_QWORD *)(a1 + 48) )
{
v4 = qm_malloc(mem_block, 16LL);
v5 = v4;
if ( v4 )
{
*(_QWORD *)v4 = 0LL;
*(_QWORD *)(v4 + 8) = 0LL;
if ( (int)func1(*(_BYTE **)(a1 + 24), *(_DWORD *)(a1 + 32), (_BYTE **)v4) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch(): Error in tag_parser\n",
process_no,
v10,
v9,
"<core> [parser/parse_sipifmatch.c:94]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_sipifmatch(): Error in tag_parser\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_sipifmatch.c:94]: ",
"parse_sipifmatch");
}
--dprint_crit;
}
qm_free(mem_block, v5);
result = 4294967294LL;
}
else
{
*(_QWORD *)(a1 + 48) = v5;
result = 0LL;
}
}
else
{
v6 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v6 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_ifsipmatch(): No memory left\n",
process_no,
v8,
v7,
"<core> [parser/parse_sipifmatch.c:87]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_ifsipmatch(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_sipifmatch.c:87]: ",
"parse_sipifmatch");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int parse_sipifmatch(struct hdr_field* _h)
{
 str *e;
 do { if (get_debug_level("core", (sizeof("core")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "parse_sipifmatch() called\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "parse_sipifmatch() called\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_sipifmatch() called\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_sipifmatch() called\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_sipifmatch() called\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); } } (dprint_crit--); } } while(0);
        if (_h->parsed != 0) {
                return 0;
        }
        e = (str*)qm_malloc(mem_block, (sizeof(str)));
        if (e == 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(): " "parse_ifsipmatch(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __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(): " "parse_ifsipmatch(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_ifsipmatch(): No memory left\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __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(): " "parse_ifsipmatch(): No memory left\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_ifsipmatch(): No memory left\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                return -1;
        }
        memset(e, 0, sizeof(str));
        if (etag_parser(_h->body.s, _h->body.len, e) < 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(): " "parse_sipifmatch(): Error in tag_parser\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __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(): " "parse_sipifmatch(): Error in tag_parser\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_sipifmatch(): Error in tag_parser\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __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(): " "parse_sipifmatch(): Error in tag_parser\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_sipifmatch(): Error in tag_parser\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                qm_free(mem_block, (e));
                return -2;
        }
        _h->parsed = (void*)e;
        return 0;
}

canonical_original_code:
int parse_sipifmatch(struct hdr_field *_h)
{
 struct _str *e;
 do { if (get_debug_level("core", (sizeof("core")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "parse_sipifmatch() called\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "parse_sipifmatch() called\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_sipifmatch() called\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_sipifmatch() called\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_sipifmatch() called\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "79" "]: ") , __func__); } } (dprint_crit--); } } while(0);
        if (_h->parsed != 0) {
                return 0;
        }
        e = (struct _str *)qm_malloc(mem_block, (sizeof(str)));
        if (e == 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(): " "parse_ifsipmatch(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __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(): " "parse_ifsipmatch(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_ifsipmatch(): No memory left\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __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(): " "parse_ifsipmatch(): No memory left\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_ifsipmatch(): No memory left\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "87" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                return -1;
        }
        memset(e, 0, sizeof(str));
        if (etag_parser(_h->body.s, _h->body.len, e) < 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(): " "parse_sipifmatch(): Error in tag_parser\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __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(): " "parse_sipifmatch(): Error in tag_parser\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_sipifmatch(): Error in tag_parser\n", process_no, my_pid(), ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __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(): " "parse_sipifmatch(): Error in tag_parser\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_sipifmatch(): Error in tag_parser\n", ("<core> [" "parser/parse_sipifmatch.c" ":" "94" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                qm_free(mem_block, (e));
                return -2;
        }
        _h->parsed = (void *)e;
        return 0;
}

variable_types: struct hdr_field { enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 } type; struct _str { char *s; int len; } name; struct _str body; int len; void *parsed; struct hdr_field *next; } *

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

user_defined_types: struct hdr_field { enum _hdr_types_t type; struct _str name; struct _str body; int len; void *parsed; struct hdr_field *next; }


decompiled_code:
__int64 __fastcall trusted_reload(__int64 (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
__int64 result; // rax

if ( db_mode != 1 )
return (*a1)(a2, 400LL, "Database cache is not enabled");
result = reload_trusted_table();
if ( (int)result < 0 )
result = (*a1)(a2, 400LL, "Trusted Table Reload Failed");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
__int64 result; // rax

if ( db_mode != 1 )
return (*a1)(a2, 400LL, "Database cache is not enabled");
result = reload_trusted_table();
if ( (int)result < 0 )
result = (*a1)(a2, 400LL, "Trusted Table Reload Failed");
return result;
}

original_code:
void trusted_reload(rpc_t* rpc, void* ctx)
{
 if (db_mode != 1) {
  rpc->fault(ctx, 400, "Database cache is not enabled");
  return;
 }
 if (reload_trusted_table() < 0) {
  rpc->fault(ctx, 400, "Trusted Table Reload Failed");
 }
}

canonical_original_code:
void trusted_reload(struct rpc *rpc, void *ctx)
{
 if (db_mode != 1) {
  rpc->fault(ctx, 400, "Database cache is not enabled");
  return;
 }
 if (reload_trusted_table() < 0) {
  rpc->fault(ctx, 400, "Trusted Table Reload Failed");
 }
}

variable_types: struct rpc { void (*fault)(void *ctx, int code, char *fmt, ...); int (*send)(void *ctx); int (*add)(void *ctx, char *fmt, ...); int (*scan)(void *ctx, char *fmt, ...); int (*printf)(void *ctx, char *fmt, ...); int (*struct_add)(void *ctx, char *fmt, ...); int (*struct_scan)(void *ctx, char *fmt, ...); int (*struct_printf)(void *ctx, char *name, char *fmt, ...); enum rpc_capabilities { RPC_DELAYED_REPLY=expr } (*capabilities)(void *ctx); struct rpc_delayed_ctx { struct rpc rpc; void *reply_ctx; } *(*delayed_ctx_new)(void *ctx); void (*delayed_ctx_close)(struct rpc_delayed_ctx *dctx); } *

variable_types:
ctx
void *

user_defined_types: struct rpc { void (*fault)(void *ctx, int code, char *fmt, ...); int (*send)(void *ctx); int (*add)(void *ctx, char *fmt, ...); int (*scan)(void *ctx, char *fmt, ...); int (*printf)(void *ctx, char *fmt, ...); int (*struct_add)(void *ctx, char *fmt, ...); int (*struct_scan)(void *ctx, char *fmt, ...); int (*struct_printf)(void *ctx, char *name, char *fmt, ...); enum rpc_capabilities (*capabilities)(void *ctx); struct rpc_delayed_ctx *(*delayed_ctx_new)(void *ctx); void (*delayed_ctx_close)(struct rpc_delayed_ctx *dctx); }


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

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

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

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

variable_types:
var
int *

variable_types: v int


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *


decompiled_code:
__int64 __fastcall futex_release(volatile __int32 *a1)
{
__int64 result; // rax

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

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

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

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

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


decompiled_code:
__int64 __fastcall shm_malloc(unsigned int a1)
{
__int64 v1; // rbx

futex_get(mem_lock);
v1 = qm_malloc(shm_block, a1);
futex_release(mem_lock);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
__int64 v1; // rbx

func3(mem_lock);
v1 = qm_malloc(shm_block, a1);
func4(mem_lock);
return v1;
}

original_code:
inline static void* shm_malloc(unsigned int size)
{
 void *p;
 futex_get(mem_lock);
 p=qm_malloc(shm_block, (size));
 futex_release(mem_lock);
  return p;
}

canonical_original_code:
inline static void *shm_malloc(unsigned int size)
{
 void *p;
 futex_get(mem_lock);
 p=qm_malloc(shm_block, (size));
 futex_release(mem_lock);
  return p;
}

variable_types:
size
unsigned int

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 __fastcall fixup_str2int(const char **a1, int a2)
{
unsigned int v2; // ebx
char *v4; // rbx
int v5; // eax
const char *v6; // r12
const char *v7; // rbp
const char *v8; // r12
unsigned int v9; // eax
unsigned int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = 0;
if ( a2 == 1 )
{
v4 = (char *)*a1;
v5 = strlen(*a1);
v6 = (const char *)(unsigned __int16)str2s((unsigned __int8 *)v4, v5, v10);
v2 = v10[0];
if ( v10[0] )
{
v2 = -6;
if ( (int)get_debug_level("pike", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = *a1;
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: fixup_str2int: bad number <%s>\n",
process_no,
v9,
v8,
"pike [pike.c:88]: ",
"fixup_str2int",
v7);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: fixup_str2int: bad number <%s>\n",
*((const char **)&log_level_info + 8),
"pike [pike.c:88]: ",
"fixup_str2int",
*a1);
}
--dprint_crit;
v2 = -6;
}
}
else
{
qm_free(mem_block, *a1);
*a1 = v6;
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char **a1, int a2)
{
unsigned int v2; // ebx
char *v4; // rbx
int v5; // eax
const char *v6; // r12
const char *v7; // rbp
const char *v8; // r12
unsigned int v9; // eax
unsigned int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = 0;
if ( a2 == 1 )
{
v4 = (char *)*a1;
v5 = strlen(*a1);
v6 = (const char *)(unsigned __int16)func2((unsigned __int8 *)v4, v5, v10);
v2 = v10[0];
if ( v10[0] )
{
v2 = -6;
if ( (int)get_debug_level("pike", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = *a1;
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: fixup_str2int: bad number <%s>\n",
process_no,
v9,
v8,
"pike [pike.c:88]: ",
"fixup_str2int",
v7);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: fixup_str2int: bad number <%s>\n",
*((const char **)&log_level_info + 8),
"pike [pike.c:88]: ",
"fixup_str2int",
*a1);
}
--dprint_crit;
v2 = -6;
}
}
else
{
qm_free(mem_block, *a1);
*a1 = v6;
}
}
return v2;
}

original_code:
static int fixup_str2int( void** param, int param_no)
{
 unsigned long go_to;
 int err;
 if (param_no == 1) {
  go_to = str2s(*param, strlen(*param), &err);
  if (err == 0) {
   qm_free(mem_block, (*param));
   *param = (void *)go_to;
   return 0;
  } else {
   do { if (get_debug_level("pike", (sizeof("pike")-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: fixup_str2int: bad number <%s>\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); 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: fixup_str2int: bad number <%s>\n", (log_level_info[((-1)) - (-5)].name), ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: fixup_str2int: bad number <%s>\n", process_no, my_pid(), ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); 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: fixup_str2int: bad number <%s>\n", ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: fixup_str2int: bad number <%s>\n", ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); } } (dprint_crit--); } } while(0);
   return -6;
  }
 }
 return 0;
}

canonical_original_code:
static int fixup_str2int(void **param, int param_no)
{
 unsigned long go_to;
 int err;
 if (param_no == 1) {
  go_to = str2s(*param, strlen(*param), &err);
  if (err == 0) {
   qm_free(mem_block, (*param));
   *param = (void *)go_to;
   return 0;
  } else {
   do { if (get_debug_level("pike", (sizeof("pike")-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: fixup_str2int: bad number <%s>\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); 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: fixup_str2int: bad number <%s>\n", (log_level_info[((-1)) - (-5)].name), ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: fixup_str2int: bad number <%s>\n", process_no, my_pid(), ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); 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: fixup_str2int: bad number <%s>\n", ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: fixup_str2int: bad number <%s>\n", ("pike" " [" "pike.c" ":" "88" "]: ") , __func__, (char *)(*param)); } } (dprint_crit--); } } while(0);
   return -6;
  }
 }
 return 0;
}

variable_types:
param
void **

variable_types: err int


canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1)
{
__int64 v1; // rbx

func3(mem_lock);
v1 = qm_malloc(shm_block, a1);
func4(mem_lock);
return v1;
}


decompiled_code:
__int64 __fastcall find_domain(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

result = find_dlist(a1, &v3);
if ( (_DWORD)result )
return 1LL;
*a2 = *(_QWORD *)(v3 + 16);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

result = func2(a1, &v3);
if ( (_DWORD)result )
return 1LL;
*a2 = *(_QWORD *)(v3 + 16);
return result;
}

original_code:
int find_domain(str* _d, udomain_t** _p)
{
 dlist_t* d;
 if (find_dlist(_d, &d) == 0) {
         *_p = d->d;
  return 0;
 }
 return 1;
}

canonical_original_code:
int find_domain(struct _str *_d, struct udomain **_p)
{
 struct dlist *d;
 if (find_dlist(_d, &d) == 0) {
         *_p = d->d;
  return 0;
 }
 return 1;
}

variable_types: struct udomain { struct _str *name; int users; int expired; int db_cmd_idx; struct hslot { int n; struct urecord { struct _str *domain; struct _str uid; struct ucontact { struct _str *domain; struct _str *uid; struct _str aor; struct _str c; struct _str received; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *sock; long expires; int q; struct _str callid; int cseq; enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 } state; unsigned int flags; struct _str user_agent; struct _str instance; int server_id; struct ucontact *next; struct ucontact *prev; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *avps; } *contacts; struct hslot *slot; struct { struct urecord *prev; struct urecord *next; } d_ll; struct { struct urecord *prev; struct urecord *next; } s_ll; struct notify_cb { void (*cb)(struct _str *uid, struct _str *_contact, enum pres_state { PRES_OFFLINE=0, PRES_ONLINE=1 } _p, void *_d); void *data; struct notify_cb *next; } *watchers; } *first; struct urecord *last; struct udomain *d; } *table; struct { int n; struct urecord *first; struct urecord *last; } d_ll; struct atomic_t { int val; } lock; } **

variable_types: struct dlist { struct _str { char *s; int len; } name; struct udomain { struct _str *name; int users; int expired; int db_cmd_idx; struct hslot { int n; struct urecord { struct _str *domain; struct _str uid; struct ucontact { struct _str *domain; struct _str *uid; struct _str aor; struct _str c; struct _str received; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *sock; long expires; int q; struct _str callid; int cseq; enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 } state; unsigned int flags; struct _str user_agent; struct _str instance; int server_id; struct ucontact *next; struct ucontact *prev; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *avps; } *contacts; struct hslot *slot; struct { struct urecord *prev; struct urecord *next; } d_ll; struct { struct urecord *prev; struct urecord *next; } s_ll; struct notify_cb { void (*cb)(struct _str *uid, struct _str *_contact, enum pres_state { PRES_OFFLINE=0, PRES_ONLINE=1 } _p, void *_d); void *data; struct notify_cb *next; } *watchers; } *first; struct urecord *last; struct udomain *d; } *table; struct { int n; struct urecord *first; struct urecord *last; } d_ll; struct atomic_t { int val; } lock; } *d; struct dlist *next; } *

user_defined_types: struct dlist { struct _str name; struct udomain *d; struct dlist *next; }

user_defined_types: struct udomain { struct _str *name; int users; int expired; int db_cmd_idx; struct hslot *table; struct { int n; struct urecord *first; struct urecord *last; } d_ll; struct atomic_t lock; }

user_defined_types: struct hslot { int n; struct urecord *first; struct urecord *last; struct udomain *d; }

user_defined_types: struct urecord { struct _str *domain; struct _str uid; struct ucontact *contacts; struct hslot *slot; struct { struct urecord *prev; struct urecord *next; } d_ll; struct { struct urecord *prev; struct urecord *next; } s_ll; struct notify_cb *watchers; }

user_defined_types: struct ucontact { struct _str *domain; struct _str *uid; struct _str aor; struct _str c; struct _str received; struct socket_info *sock; long expires; int q; struct _str callid; int cseq; enum cstate state; unsigned int flags; struct _str user_agent; struct _str instance; int server_id; struct ucontact *next; struct ucontact *prev; struct usr_avp *avps; }

user_defined_types: struct notify_cb { void (*cb)(struct _str *uid, struct _str *_contact, enum pres_state _p, void *_d); void *data; struct notify_cb *next; }

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

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

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

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

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

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


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


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

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

variable_types: i int


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

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


canonical_decompiled_code:
__int64 __fastcall func2(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ebp
int v3; // ebp

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


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

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


canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
__int64 v1; // rbx

func2(mem_lock);
v1 = qm_malloc(shm_block, a1);
func3(mem_lock);
return v1;
}


canonical_decompiled_code:
__int64 __fastcall func6(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ebp
int v3; // ebp

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


canonical_decompiled_code:
__int64 __fastcall func7(volatile __int32 *a1)
{
__int64 result; // rax

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


canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
__int64 v1; // rbx

func6(mem_lock);
v1 = qm_malloc(shm_block, a1);
func7(mem_lock);
return v1;
}


decompiled_code:
__int64 MD5Update()
{
return U_MD5Update();
}

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

original_code:
static inline void MD5Update(MD5_CTX *ctx, const char *str, size_t len) {
 U_MD5Update(ctx, (const unsigned char *)str, len);
}

canonical_original_code:
static inline void MD5Update(struct MD5Context *ctx, char *str, unsigned long len) {
 U_MD5Update(ctx, (unsigned char *)str, len);
}

variable_types: struct MD5Context { unsigned int state[4]; unsigned int count; unsigned char buffer[64]; } *

variable_types:
str
char *

variable_types:
len
unsigned long


decompiled_code:
__int64 MD5Final()
{
return U_MD5Final();
}

canonical_decompiled_code:
__int64 func1()
{
return U_MD5Final();
}

original_code:
static inline void MD5Final(char buf[16], MD5_CTX *ctx) {
 U_MD5Final((unsigned char *)buf, ctx);
}

canonical_original_code:
static inline void MD5Final(char buf[16], struct MD5Context *ctx) {
 U_MD5Final((unsigned char *)buf, ctx);
}

variable_types:
buf
char [16]

user_defined_types: struct MD5Context { unsigned int state[4]; unsigned int count; unsigned char buffer[64]; }


canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 **a1)
{
__int64 result; // rax
int v2; // edx
unsigned __int8 *v3; // r10
unsigned __int8 v4; // cl
unsigned __int8 *v5; // r11
unsigned __int8 v6; // cl
unsigned __int8 *v7; // r9
unsigned __int8 v8; // cl
unsigned __int8 v9; // cl
unsigned __int8 v10; // cl
unsigned __int8 v11; // cl
char *v12; // r10
unsigned __int8 v13; // cl

result = *((unsigned int *)a1 + 2);
if ( (int)result > 0 )
{
v2 = (_DWORD)a1[1] & 3;
if ( (result & 3) != 0 )
{
if ( v2 != 1 )
{
if ( v2 != 2 )
{
v3 = *a1;
v4 = **a1;
if ( v4 > 0x20u || ((1LL << v4) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v3 + 1;
}
v5 = *a1;
v6 = **a1;
if ( v6 > 0x20u || ((1LL << v6) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v5 + 1;
}
v7 = *a1;
v8 = **a1;
if ( v8 > 0x20u )
return result;
if ( ((1LL << v8) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v7 + 1;
if ( !(_DWORD)result )
return result;
}
do
{
v12 = (char *)*a1;
v13 = **a1;
if ( v13 > 0x20u )
break;
if ( ((1LL << v13) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 1);
v9 = v12[1];
if ( v9 > 0x20u )
break;
if ( ((1LL << v9) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 1;
*a1 = (unsigned __int8 *)(v12 + 2);
v10 = v12[2];
if ( v10 > 0x20u )
break;
if ( ((1LL << v10) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 2;
*a1 = (unsigned __int8 *)(v12 + 3);
v11 = v12[3];
if ( v11 > 0x20u )
break;
if ( ((1LL << v11) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 3);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 4);
}
while ( (_DWORD)result );
}
return result;
}


strlower

original_code:
static inline void strlower(str* _s)
{
 int i;
 for(i = 0; i < _s->len; i++) {
  _s->s[i] = tolower(_s->s[i]);
 }
}

canonical_original_code:
static inline void strlower(struct _str *_s)
{
 int i;
 for(i = 0; i < _s->len; i++) {
  _s->s[i] = tolower(_s->s[i]);
 }
}


serverThread

decompiled_code:
void *__fastcall serverThread(void *a1)
{
int v1; // eax
char v3[1048]; // [rsp+0h] [rbp-418h] BYREF

printf("DEBUG: connection made, connectionDesc=%d\n", *(unsigned int *)a1);
if ( *(int *)a1 < 0 )
{
puts("Accept failed");
}
else
{
while ( 1 )
{
v1 = read(*(_DWORD *)a1, v3, 0x400uLL);
if ( v1 <= 0 )
break;
v3[v1] = 0;
printf("Message: %s\n", v3);
if ( (int)write(*(_DWORD *)a1, "GOT IT", 7uLL) < 0 )
{
perror("Server: write error");
return 0LL;
}
}
close(*(_DWORD *)a1);
free(a1);
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func7(void *a1)
{
int v1; // eax
char v3[1048]; // [rsp+0h] [rbp-418h] BYREF

printf("DEBUG: connection made, connectionDesc=%d\n", *(unsigned int *)a1);
if ( *(int *)a1 < 0 )
{
puts("Accept failed");
}
else
{
while ( 1 )
{
v1 = read(*(_DWORD *)a1, v3, 0x400uLL);
if ( v1 <= 0 )
break;
v3[v1] = 0;
printf("Message: %s\n", v3);
if ( (int)write(*(_DWORD *)a1, "GOT IT", 7uLL) < 0 )
{
perror("Server: write error");
return 0LL;
}
}
close(*(_DWORD *)a1);
free(a1);
}
return 0LL;
}

original_code:
void *serverThread(void *parmPtr) {
    int recievedMsgLen;
    char messageBuf[1025];
    printf("DEBUG: connection made, connectionDesc=%d\n",
            ((struct serverParm *) parmPtr)->connectionDesc);
    if (((struct serverParm *) parmPtr)->connectionDesc < 0) {
        printf("Accept failed\n");
        return(0);
    }
    while ((recievedMsgLen=
            read(((struct serverParm *) parmPtr)->connectionDesc,messageBuf,sizeof(messageBuf)-1)) > 0)
    {
        recievedMsgLen[messageBuf] = '\0';
        printf("Message: %s\n",messageBuf);
        if (write(((struct serverParm *) parmPtr)->connectionDesc,"GOT IT\0",7) < 0) {
               perror("Server: write error");
               return(0);
           }
    }
    close(((struct serverParm *) parmPtr)->connectionDesc);
    free(((struct serverParm *) parmPtr));
    return(0);
}

variable_types:
parmPtr
void *

variable_types: recievedMsgLen int

variable_types:
messageBuf
char [1025]

user_defined_types: struct serverParm { int connectionDesc; }


repo: vitalikp/stream

decompiled_code:
void __fastcall obj_destroy(void ***a1)
{
void **v1; // rbp
unsigned __int8 v2; // al

v1 = *a1;
v2 = *(_BYTE *)*a1;
if ( v2 <= 2u )
{
if ( v2 )
free(v1[1]);
}
else if ( v2 == 3 )
{
list_destroy(v1 + 1);
}
free(v1);
*a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func0(void ***a1)
{
void **v1; // rbp
unsigned __int8 v2; // al

v1 = *a1;
v2 = *(_BYTE *)*a1;
if ( v2 <= 2u )
{
if ( v2 )
free(v1[1]);
}
else if ( v2 == 3 )
{
list_destroy(v1 + 1);
}
free(v1);
*a1 = 0LL;
}

original_code:
void obj_destroy(obj_t **obj)
{
 obj_t *p = *obj;
 switch (p->type)
 {
  case 0x1:
  case 0x2:
   free(p->value);
   break;
  case 0x3:
   list_destroy((list_t**)&(p->value));
   break;
  case 0x4:
   break;
 }
 free(p);
 *obj = ((void *)0);
}

canonical_original_code:
void obj_destroy(struct obj_t **obj)
{
 struct obj_t *p = *obj;
 switch (p->type)
 {
  case 0x1:
  case 0x2:
   free(p->value);
   break;
  case 0x3:
   list_destroy((struct list_t **)&(p->value));
   break;
  case 0x4:
   break;
 }
 free(p);
 *obj = ((void *)0);
}

variable_types: struct obj_t { unsigned char type; void *value; } **

user_defined_types: struct list_t { unsigned int size; unsigned int len; struct obj_t **value; }


original_code:
int obj_set_str(obj_t *obj, size_t len, char *value)
{
 obj->type = 0x1;
 char *p = malloc(len + 1);
 if (!p)
      return 0;
 obj->value = p;
 p[len] = '\0';
 size_t i = 0;
 while (len > 0)
 {
  *(p++) = value[i++];
  len--;
 }
 return i;
}

canonical_original_code:
int obj_set_str(struct obj_t *obj, unsigned long len, char *value)
{
 obj->type = 0x1;
 char *p = malloc(len + 1);
 if (!p)
      return 0;
 obj->value = p;
 p[len] = '\0';
 unsigned long i = 0;
 while (len > 0)
 {
  *(p++) = value[i++];
  len--;
 }
 return i;
}

variable_types: struct obj_t { unsigned char type; void *value; } *

variable_types:
value
char *

variable_types:
p
char *

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall bc_decode_type(char a1)
{
int v1; // eax

if ( a1 == 105 )
return 2LL;
if ( a1 == 108 )
return 3LL;
LOBYTE(v1) = a1 == 100;
return (unsigned int)(3 * v1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
int v1; // eax

if ( a1 == 105 )
return 2LL;
if ( a1 == 108 )
return 3LL;
LOBYTE(v1) = a1 == 100;
return (unsigned int)(3 * v1 + 1);
}

original_code:
uint8_t bc_decode_type(char c)
{
 if (c == 'i')
  return 0x2;
 if (c == 'l')
  return 0x3;
 if (c == 'd')
  return 0x4;
 return 0x1;
}

canonical_original_code:
unsigned char bc_decode_type(char c)
{
 if (c == 'i')
  return 0x2;
 if (c == 'l')
  return 0x3;
 if (c == 'd')
  return 0x4;
 return 0x1;
}

variable_types: c char

return_type: unsigned char


decompiled_code:
__int64 __fastcall bc_read_lenstr(char *a1, __int64 *a2)
{
char v2; // al
__int64 v3; // rcx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 result; // rax

v2 = *a1;
if ( *a1 == 58 )
{
v3 = 0LL;
v4 = 0LL;
LABEL_5:
result = v3 + 1;
*a2 = v4;
}
else
{
v3 = 0LL;
v4 = 0LL;
while ( 1 )
{
v5 = 10 * v4;
if ( (unsigned __int8)(v2 - 48) > 9u )
break;
v4 = v2 - 48 + v5;
v2 = a1[++v3];
if ( v2 == 58 )
goto LABEL_5;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1, __int64 *a2)
{
char v2; // al
__int64 v3; // rcx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 result; // rax

v2 = *a1;
if ( *a1 == 58 )
{
v3 = 0LL;
v4 = 0LL;
LABEL_5:
result = v3 + 1;
*a2 = v4;
}
else
{
v3 = 0LL;
v4 = 0LL;
while ( 1 )
{
v5 = 10 * v4;
if ( (unsigned __int8)(v2 - 48) > 9u )
break;
v4 = v2 - 48 + v5;
v2 = a1[++v3];
if ( v2 == 58 )
goto LABEL_5;
}
result = 0LL;
}
return result;
}

original_code:
size_t bc_read_lenstr(char *in, size_t *len)
{
 size_t size = 0;
 size_t i = 0;
 while (in[i] != ':')
 {
  size *= 10;
  if (in[i] < '0' || in[i] > '9')
   return 0;
  size += in[i] - '0';
  i++;
 }
 i++;
 *len = size;
 return i;
}

canonical_original_code:
unsigned long bc_read_lenstr(char *in, unsigned long *len)
{
 unsigned long size = 0;
 unsigned long i = 0;
 while (in[i] != ':')
 {
  size *= 10;
  if (in[i] < '0' || in[i] > '9')
   return 0;
  size += in[i] - '0';
  i++;
 }
 i++;
 *len = size;
 return i;
}

variable_types:
in
char *

variable_types:
len
unsigned long *

variable_types:
size
unsigned long


original_code:
size_t bc_read_string(char *in, char **str)
{
 size_t size = 0;
 size_t i = 0;
 i += bc_read_lenstr(in, &size);
 if (size < 1)
  return 0;
 char *p = malloc(size+1);
 if (!p)
  return 0;
 *str = p;
 p[size] = '\0';
 while (size > 0)
 {
  *(p++) = in[i++];
  size--;
 }
 return i;
}

canonical_original_code:
unsigned long bc_read_string(char *in, char **str)
{
 unsigned long size = 0;
 unsigned long i = 0;
 i += bc_read_lenstr(in, &size);
 if (size < 1)
  return 0;
 char *p = malloc(size+1);
 if (!p)
  return 0;
 *str = p;
 p[size] = '\0';
 while (size > 0)
 {
  *(p++) = in[i++];
  size--;
 }
 return i;
}

variable_types:
str
char **


canonical_original_code:
unsigned long bc_read_int(char *in, unsigned int *val)
{
 unsigned int p = 0;
 unsigned long i = 0;
 if (in[i] == '-')
 {
  if (in[i+1] == 'e')
   return 0;
  if (in[i+1] == '0')
   return 0;
  i++;
 }
 while (in[i] != 'e')
 {
  p *= 10;
  if (in[i] < '0' || in[i] > '9')
   return 0;
  p += in[i] - '0';
  i++;
 }
 i++;
 if (in[0] == '-')
  p = -p;
 *val = p;
 return i;
}

variable_types:
val
unsigned int *

variable_types:
p
unsigned int


decompiled_code:
void __fastcall list_destroy(_DWORD **a1)
{
_DWORD *v1; // rbp
unsigned __int16 v2; // bx

v1 = *a1;
if ( **a1 )
{
v2 = 0;
do
{
if ( *(_QWORD *)(*((_QWORD *)v1 + 1) + 8LL * v2) )
obj_destroy();
++v2;
}
while ( (unsigned int)v2 < *v1 );
}
free(*((void **)v1 + 1));
free(v1);
*a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func0(_DWORD **a1)
{
_DWORD *v1; // rbp
unsigned __int16 v2; // bx

v1 = *a1;
if ( **a1 )
{
v2 = 0;
do
{
if ( *(_QWORD *)(*((_QWORD *)v1 + 1) + 8LL * v2) )
obj_destroy();
++v2;
}
while ( (unsigned int)v2 < *v1 );
}
free(*((void **)v1 + 1));
free(v1);
*a1 = 0LL;
}

original_code:
void list_destroy(list_t **list)
{
 list_t *obj = *list;
 uint16_t i = 0;
 for (i = 0; i<obj->size;i++)
  if (obj->value[i])
  {
   obj_destroy(&obj->value[i]);
  }
 free(obj->value);
 free(obj);
 *list = ((void *)0);
}

canonical_original_code:
void list_destroy(struct list_t **list)
{
 struct list_t *obj = *list;
 unsigned short i = 0;
 for (i = 0; i<obj->size;i++)
  if (obj->value[i])
  {
   obj_destroy(&obj->value[i]);
  }
 free(obj->value);
 free(obj);
 *list = ((void *)0);
}

variable_types: struct list_t { unsigned int size; unsigned int len; struct obj_t { unsigned char type; void *value; } **value; } **

variable_types:
i
unsigned short


decompiled_code:
__int64 __fastcall list_add(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdx
unsigned int v4; // eax
void *v6; // rax

v2 = *(_DWORD *)(a1 + 4);
if ( *(_DWORD *)a1 != v2 )
goto LABEL_2;
v6 = realloc(*(void **)(a1 + 8), 8LL * (unsigned int)(v2 + 10));
*(_QWORD *)(a1 + 8) = v6;
if ( v6 )
{
*(_DWORD *)(a1 + 4) += 10;
LABEL_2:
v3 = *(_QWORD *)(a1 + 8);
v4 = (*(_DWORD *)a1)++;
*(_QWORD *)(v3 + 8LL * v4) = a2;
return 0LL;
}
*(_DWORD *)(a1 + 4) = 0;
return 0xFFFFFFFFLL;
}

original_code:
uint8_t list_add(list_t *list, obj_t *value)
{
 if (list->size == list->len)
 {
  list->value = realloc(list->value, sizeof(obj_t*)*(list->len+10));
  if (!list->value)
  {
   list->len = 0;
   return -1;
  }
  list->len += 10;
 }
 list->value[list->size++] = value;
 return 0;
}

canonical_original_code:
unsigned char list_add(struct list_t *list, struct obj_t *value)
{
 if (list->size == list->len)
 {
  list->value = realloc(list->value, sizeof(struct obj_t *)*(list->len+10));
  if (!list->value)
  {
   list->len = 0;
   return -1;
  }
  list->len += 10;
 }
 list->value[list->size++] = value;
 return 0;
}

variable_types: struct list_t { unsigned int size; unsigned int len; struct obj_t { unsigned char type; void *value; } **value; } *

variable_types:
value
struct obj_t *


decompiled_code:
__int64 __fastcall list_remove(unsigned int *a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // eax

result = *a1;
if ( (unsigned int)result >= a2 )
{
LODWORD(result) = result - 1;
for ( *a1 = result; a2 < *a1; LODWORD(result) = *a1 )
{
v3 = a2++;
*(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL * v3) = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL * a2);
}
result = (unsigned int)result;
*(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL * (unsigned int)result) = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // eax

result = *a1;
if ( (unsigned int)result >= a2 )
{
LODWORD(result) = result - 1;
for ( *a1 = result; a2 < *a1; LODWORD(result) = *a1 )
{
v3 = a2++;
*(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL * v3) = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL * a2);
}
result = (unsigned int)result;
*(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL * (unsigned int)result) = 0LL;
}
return result;
}

original_code:
void list_remove(list_t *list, uint32_t index)
{
 if (index < 0 || index > list->size)
  return;
 list->size--;
 uint32_t i = index;
 while (i < list->size)
 {
  list->value[i] = list->value[i + 1];
  i++;
 }
 list->value[list->size] = ((void *)0);
}

canonical_original_code:
void list_remove(struct list_t *list, unsigned int index)
{
 if (index < 0 || index > list->size)
  return;
 list->size--;
 unsigned int i = index;
 while (i < list->size)
 {
  list->value[i] = list->value[i + 1];
  i++;
 }
 list->value[list->size] = ((void *)0);
}

variable_types:
index
unsigned int

variable_types:
i
unsigned int

user_defined_types: struct obj_t { unsigned char type; void *value; }


decompiled_code:
__int64 __fastcall int_cmp(const void *a1, const void *a2)
{
__int64 result; // rax

result = 0LL;
if ( *(_DWORD *)a1 != *(_DWORD *)a2 )
result = *(_DWORD *)a1 < *(_DWORD *)a2 ? -1 : 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const void *a1, const void *a2)
{
__int64 result; // rax

result = 0LL;
if ( *(_DWORD *)a1 != *(_DWORD *)a2 )
result = *(_DWORD *)a1 < *(_DWORD *)a2 ? -1 : 1;
return result;
}

original_code:
int int_cmp(const void *a, const void *b) {
    const unsigned int *ia = (const unsigned int *)a;
    const unsigned int *ib = (const unsigned int *)b;
    if (*ia == *ib) {
        return 0;
    } else if (*ia < *ib) {
        return -1;
    } else {
        return 1;
    }
}

canonical_original_code:
int int_cmp(void *a, void *b) {
    unsigned int *ia = (const unsigned int *)a;
    unsigned int *ib = (const unsigned int *)b;
    if (*ia == *ib) {
        return 0;
    } else if (*ia < *ib) {
        return -1;
    } else {
        return 1;
    }
}

variable_types:
a
void *

variable_types:
b
void *

variable_types:
ia
unsigned int *

variable_types:
ib
unsigned int *


semisort

decompiled_code:
void __fastcall semisort(__int64 a1, unsigned int a2)
{
unsigned int v4; // er14
unsigned int v5; // eax
int i; // er12
__int64 v7; // rbx
__int64 v8; // rax
int *v9; // rsi
int v10; // edi
int *v11; // rax

v4 = a2 >> 2;
v5 = time(0LL);
srandom(v5);
if ( a2 >> 2 )
{
for ( i = 0; i != v4; ++i )
{
v7 = random();
v8 = random();
v9 = (int *)(a1 + 4LL * (int)(v7 % a2));
v10 = *v9;
v11 = (int *)(a1 + 4LL * (int)(v8 % a2));
*v9 = *v11;
*v11 = v10;
}
}
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, unsigned int a2)
{
unsigned int v4; // er14
unsigned int v5; // eax
int i; // er12
__int64 v7; // rbx
__int64 v8; // rax
int *v9; // rsi
int v10; // edi
int *v11; // rax

v4 = a2 >> 2;
v5 = time(0LL);
srandom(v5);
if ( a2 >> 2 )
{
for ( i = 0; i != v4; ++i )
{
v7 = random();
v8 = random();
v9 = (int *)(a1 + 4LL * (int)(v7 % a2));
v10 = *v9;
v11 = (int *)(a1 + 4LL * (int)(v8 % a2));
*v9 = *v11;
*v11 = v10;
}
}
}

original_code:
void semisort(unsigned int *elems, unsigned int size) {
    int i1, i2, i, n_swaps;
    unsigned int aux;
    n_swaps = size/4;
    srandom(time(((void *)0)));
    for (i = 0; i < n_swaps; i++) {
        i1 = random() % size;
        i2 = random() % size;
        aux = elems[i1];
        elems[i1] = elems[i2];
        elems[i2] = aux;
    }
}

canonical_original_code:
void semisort(unsigned int *elems, unsigned int size) {
    int i1; int i2; int i; int n_swaps;
    unsigned int aux;
    n_swaps = size/4;
    srandom(time(((void *)0)));
    for (i = 0; i < n_swaps; i++) {
        i1 = random() % size;
        i2 = random() % size;
        aux = elems[i1];
        elems[i1] = elems[i2];
        elems[i2] = aux;
    }
}

variable_types:
elems
unsigned int *

variable_types:
size
unsigned int

variable_types: i int

variable_types:
aux
unsigned int


decompiled_code:
void __fastcall create_random_array(__int64 a1, char a2, __int64 a3)
{
unsigned int v4; // eax
__int64 v5; // rbx

v4 = time(0LL);
srandom(v4);
if ( a3 > 0 )
{
v5 = 0LL;
do
*(_DWORD *)(a1 + 4 * v5++) = ~(-1 << a2) & random();
while ( a3 != v5 );
}
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1, char a2, __int64 a3)
{
unsigned int v4; // eax
__int64 v5; // rbx

v4 = time(0LL);
srandom(v4);
if ( a3 > 0 )
{
v5 = 0LL;
do
*(_DWORD *)(a1 + 4 * v5++) = ~(-1 << a2) & random();
while ( a3 != v5 );
}
}

original_code:
void create_random_array(unsigned int *arr, int universe, off_t n_elems) {
    off_t i;
    unsigned int mask;
    mask = ~((~0) << universe);
    srandom(time(((void *)0)));
    for (i = 0; i < n_elems; i++) {
        arr[i] = random() & mask;
    }
}

canonical_original_code:
void create_random_array(unsigned int *arr, int universe, long n_elems) {
    long i;
    unsigned int mask;
    mask = ~((~0) << universe);
    srandom(time(((void *)0)));
    for (i = 0; i < n_elems; i++) {
        arr[i] = random() & mask;
    }
}

variable_types:
arr
unsigned int *

variable_types: universe int

variable_types: i long

variable_types:
mask
unsigned int


decompiled_code:
int __fastcall save_array_to_file(__int64 a1, const char *a2, __int64 a3)
{
__int64 v3; // r13
int v4; // er12
__int64 i; // rbx
int v6; // eax

v3 = 4 * a3;
v4 = open(a2, 66, 484LL);
for ( i = 0LL; ; i += v6 )
{
v6 = write(v4, (const void *)(a1 + i), v3 - i);
if ( v3 - i <= 0 || v6 <= 0LL )
break;
}
return close(v4);
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, const char *a2, __int64 a3)
{
__int64 v3; // r13
int v4; // er12
__int64 i; // rbx
int v6; // eax

v3 = 4 * a3;
v4 = open(a2, 66, 484LL);
for ( i = 0LL; ; i += v6 )
{
v6 = write(v4, (const void *)(a1 + i), v3 - i);
if ( v3 - i <= 0 || v6 <= 0LL )
break;
}
return close(v4);
}

original_code:
void save_array_to_file(unsigned int *array, const char *filename, off_t size) {
    off_t ret, idx;
    int fd;
    char *foo;
    size *= 4;
    fd = open(filename, 02 | 0100, (0400|0200|0100) | (0400 >> 3) | ((0400 >> 3) >> 3));
    idx = 0;
    foo = (char *) array;
    while ((ret = write(fd, &(foo[idx]), size - idx)) > 0 && (size - idx) > 0) idx += ret;
    close(fd);
}

canonical_original_code:
void save_array_to_file(unsigned int *array, char *filename, long size) {
    long ret; long idx;
    int fd;
    char *foo;
    size *= 4;
    fd = open(filename, 02 | 0100, (0400|0200|0100) | (0400 >> 3) | ((0400 >> 3) >> 3));
    idx = 0;
    foo = (char *) array;
    while ((ret = write(fd, &(foo[idx]), size - idx)) > 0 && (size - idx) > 0) idx += ret;
    close(fd);
}

variable_types:
array
unsigned int *

variable_types:
filename
char *

variable_types: size long

variable_types: ret long

variable_types: idx long

variable_types: fd int

variable_types:
foo
char *


swap

decompiled_code:
int *__fastcall swap(__int64 a1, int a2, int a3)
{
int *v3; // rcx
int v4; // esi
int *result; // rax

v3 = (int *)(a1 + 4LL * a2);
v4 = *v3;
result = (int *)(a1 + 4LL * a3);
*v3 = *result;
*result = v4;
return result;
}

canonical_decompiled_code:
int *__fastcall func11(__int64 a1, int a2, int a3)
{
int *v3; // rcx
int v4; // esi
int *result; // rax

v3 = (int *)(a1 + 4LL * a2);
v4 = *v3;
result = (int *)(a1 + 4LL * a3);
*v3 = *result;
*result = v4;
return result;
}

original_code:
void swap(unsigned int *array, int i1, int i2) {
    unsigned int aux;
    aux = array[i1];
    array[i1] = array[i2];
    array[i2] = aux;
}


main

canonical_name: main

original_code:
int main(int argc, char **argv) {
    unsigned int *insertions, *deletions, *finds;
    int exp_n, k, universe;
    int i, j;
    int ins_idx, del_idx, find_idx;
    int sorted, chosen;
    off_t n, ins_size, find_size;
    exp_n = atoi(argv[1]);
    k = atoi(argv[2]);
    universe = atoi(argv[3]);
    n = 1 << exp_n;
    ins_size = 3 * k * n;
    find_size = k * n;
    insertions = (unsigned int *)malloc(sizeof(unsigned int) * ins_size);
    deletions = (unsigned int *)malloc(sizeof(unsigned int) * ins_size);
    finds = (unsigned int *)malloc(sizeof(unsigned int) * find_size);
    create_random_array(insertions, universe, ins_size);
    sorted = atoi(argv[4]);
    if (sorted == 2 || sorted == 3) {
        qsort(insertions, ins_size, sizeof(unsigned int), int_cmp);
        semisort(insertions, ins_size);
    }
    save_array_to_file(insertions, "insertions", ins_size);
    ins_idx = del_idx = find_idx = 0;
    for (i = 0; i < n; i++) {
        ins_idx += k;
        for (j = 0; j < k; j++) {
            chosen = (random() % (ins_idx - del_idx)) + del_idx;
            deletions[del_idx] = insertions[chosen];
            swap(insertions, del_idx, chosen);
            del_idx++;
        }
        if (sorted == 2 || sorted == 4) {
            qsort(deletions + del_idx - k, k, sizeof(unsigned int), int_cmp);
            semisort(deletions + del_idx - k, k);
        }
        ins_idx += k;
    }
    create_random_array(finds, universe, find_size / 2);
    for (find_idx = (find_size / 2) + 1; find_idx < find_size; find_idx++) {
        chosen = (random() % (ins_idx - del_idx)) + del_idx;
        finds[find_idx] = insertions[chosen];
    }
    save_array_to_file(finds, "finds", find_size);
    for (i = 0; i < n; i++) {
        for (j = 0; j < k; j++) {
            chosen = (random() % (ins_idx - del_idx)) + del_idx;
            deletions[del_idx] = insertions[chosen];
            swap(insertions, del_idx, chosen);
            del_idx++;
        }
        if (sorted == 2 || sorted == 4) {
            qsort(deletions + del_idx - k, k, sizeof(unsigned int), int_cmp);
            semisort(deletions + del_idx - k, k);
        }
        ins_idx += k;
        for (j = 0; j < k; j++) {
            chosen = (random() % (ins_idx - del_idx)) + del_idx;
            deletions[del_idx] = insertions[chosen];
            swap(insertions, del_idx, chosen);
            del_idx++;
        }
        if (sorted == 2 || sorted == 4) {
            qsort(deletions + del_idx - k, k, sizeof(unsigned int), int_cmp);
            semisort(deletions + del_idx - k, k);
        }
    }
    save_array_to_file(deletions, "deletions", ins_size);
}

canonical_original_code:
int main(int argc, char **argv) {
    unsigned int *insertions; unsigned int *deletions; unsigned int *finds;
    int exp_n; int k; int universe;
    int i; int j;
    int ins_idx; int del_idx; int find_idx;
    int sorted; int chosen;
    long n; long ins_size; long find_size;
    exp_n = atoi(argv[1]);
    k = atoi(argv[2]);
    universe = atoi(argv[3]);
    n = 1 << exp_n;
    ins_size = 3 * k * n;
    find_size = k * n;
    insertions = (unsigned int *)malloc(sizeof(unsigned int) * ins_size);
    deletions = (unsigned int *)malloc(sizeof(unsigned int) * ins_size);
    finds = (unsigned int *)malloc(sizeof(unsigned int) * find_size);
    create_random_array(insertions, universe, ins_size);
    sorted = atoi(argv[4]);
    if (sorted == 2 || sorted == 3) {
        qsort(insertions, ins_size, sizeof(unsigned int), int_cmp);
        semisort(insertions, ins_size);
    }
    save_array_to_file(insertions, "insertions", ins_size);
    ins_idx = del_idx = find_idx = 0;
    for (i = 0; i < n; i++) {
        ins_idx += k;
        for (j = 0; j < k; j++) {
            chosen = (random() % (ins_idx - del_idx)) + del_idx;
            deletions[del_idx] = insertions[chosen];
            swap(insertions, del_idx, chosen);
            del_idx++;
        }
        if (sorted == 2 || sorted == 4) {
            qsort(deletions + del_idx - k, k, sizeof(unsigned int), int_cmp);
            semisort(deletions + del_idx - k, k);
        }
        ins_idx += k;
    }
    create_random_array(finds, universe, find_size / 2);
    for (find_idx = (find_size / 2) + 1; find_idx < find_size; find_idx++) {
        chosen = (random() % (ins_idx - del_idx)) + del_idx;
        finds[find_idx] = insertions[chosen];
    }
    save_array_to_file(finds, "finds", find_size);
    for (i = 0; i < n; i++) {
        for (j = 0; j < k; j++) {
            chosen = (random() % (ins_idx - del_idx)) + del_idx;
            deletions[del_idx] = insertions[chosen];
            swap(insertions, del_idx, chosen);
            del_idx++;
        }
        if (sorted == 2 || sorted == 4) {
            qsort(deletions + del_idx - k, k, sizeof(unsigned int), int_cmp);
            semisort(deletions + del_idx - k, k);
        }
        ins_idx += k;
        for (j = 0; j < k; j++) {
            chosen = (random() % (ins_idx - del_idx)) + del_idx;
            deletions[del_idx] = insertions[chosen];
            swap(insertions, del_idx, chosen);
            del_idx++;
        }
        if (sorted == 2 || sorted == 4) {
            qsort(deletions + del_idx - k, k, sizeof(unsigned int), int_cmp);
            semisort(deletions + del_idx - k, k);
        }
    }
    save_array_to_file(deletions, "deletions", ins_size);
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
insertions
unsigned int *

variable_types:
deletions
unsigned int *

variable_types:
finds
unsigned int *

variable_types: k int

variable_types: j int

variable_types: sorted int

variable_types: chosen int

variable_types: n long


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er15
char v4; // bp
_DWORD *v5; // r13
unsigned int *v6; // rbx
int v7; // er14
unsigned int *v8; // rbx
unsigned int *v9; // rbx
int v10; // er14
int v11; // ebp
__int64 v12; // rbx
unsigned int v13; // er15
int v14; // er14
unsigned int *v15; // rbx
int v16; // er14
unsigned int *v17; // rbx
unsigned int *v18; // rbx
int v19; // [rsp+Ch] [rbp-9Ch]
char *ptr; // [rsp+10h] [rbp-98h]
char *v21; // [rsp+18h] [rbp-90h]
unsigned int v22; // [rsp+28h] [rbp-80h]
int v23; // [rsp+2Ch] [rbp-7Ch]
int v24; // [rsp+30h] [rbp-78h]
unsigned int v25; // [rsp+34h] [rbp-74h]
int v26; // [rsp+38h] [rbp-70h]
unsigned int v27; // [rsp+3Ch] [rbp-6Ch]
unsigned int v28; // [rsp+40h] [rbp-68h]
int v29; // [rsp+44h] [rbp-64h]
char *v30; // [rsp+48h] [rbp-60h]
struct timespec v31; // [rsp+50h] [rbp-58h] BYREF
struct timespec tp; // [rsp+60h] [rbp-48h] BYREF

if ( argc <= 4 )
{
puts("Usage : run_once exp_n k exp_universe repetitions");
exit(1);
}
v27 = atoi(argv[3]);
v3 = atoi(argv[2]);
v19 = v3;
v4 = atoi(argv[1]);
v29 = atoi(argv[4]);
v22 = 1 << v4;
v28 = v3 << v4;
ptr = load_file_into_array("insertions", (unsigned int)(3 * (v3 << v4)));
v21 = load_file_into_array("deletions", (unsigned int)(3 * (v3 << v4)));
v30 = load_file_into_array("finds", (unsigned int)(v3 << v4));
v5 = dict_new();
if ( !v29 )
{
LABEL_41:
free(ptr);
free(v21);
free(v30);
dict_free(v5);
exit(0);
}
v26 = 0;
v25 = v3 - 1;
while ( 1 )
{
clock_gettime(1, &tp);
v23 = 0;
v10 = 0;
v11 = 0;
if ( v22 )
{
do
{
if ( v19 )
{
v6 = (unsigned int *)&ptr[4 * v10];
do
dict_set((__int64)v5, *v6++, v11);
while ( v6 != (unsigned int *)&ptr[4 * v25 + 4 + 4 * (__int64)v10] );
v7 = v19 + v10;
v8 = (unsigned int *)&v21[4 * v23];
do
dict_delete((__int64)v5, *v8++);
while ( v8 != (unsigned int *)&v21[4 * v25 + 4 + 4 * (__int64)v23] );
v23 += v19;
v9 = (unsigned int *)&ptr[4 * v7];
do
dict_set((__int64)v5, *v9++, v11);
while ( v9 != (unsigned int *)&ptr[4 * v25 + 4 + 4 * (__int64)v7] );
v10 = v19 + v7;
}
++v11;
}
while ( v22 != v11 );
}
clock_gettime(1, &v31);
if ( v27 <= 0x14 )
{
printf("idi: %lldns\t", v31.tv_nsec + 1000000000 * (v31.tv_sec - tp.tv_sec) - tp.tv_nsec);
clock_gettime(1, &tp);
if ( !v28 )
{
clock_gettime(1, &v31);
LABEL_19:
printf("f: %lldns\t", v31.tv_nsec + 1000000000 * (v31.tv_sec - tp.tv_sec) - tp.tv_nsec);
clock_gettime(1, &tp);
if ( !v22 )
{
clock_gettime(1, &v31);
LABEL_40:
printf("did: %lldns\t\n", v31.tv_nsec + 1000000000 * (v31.tv_sec - tp.tv_sec) - tp.tv_nsec);
goto LABEL_24;
}
goto LABEL_20;
}
}
else
{
printf("idi: %lldms\t", 1000 * (v31.tv_sec - tp.tv_sec) + (v31.tv_nsec - tp.tv_nsec) / 1000000);
clock_gettime(1, &tp);
if ( !v28 )
{
clock_gettime(1, &v31);
goto LABEL_21;
}
}
v12 = 0LL;
do
dict_get((__int64 *)v5, *(_DWORD *)&v30[4 * v12++]);
while ( v28 > (unsigned int)v12 );
clock_gettime(1, &v31);
if ( v27 <= 0x14 )
goto LABEL_19;
LABEL_21:
printf("f: %lldms\t", 1000 * (v31.tv_sec - tp.tv_sec) + (v31.tv_nsec - tp.tv_nsec) / 1000000);
clock_gettime(1, &tp);
if ( !v22 )
{
clock_gettime(1, &v31);
goto LABEL_23;
}
LABEL_20:
v13 = 0;
v24 = v10;
v14 = v23;
do
{
if ( v19 )
{
v15 = (unsigned int *)&v21[4 * v14];
do
dict_delete((__int64)v5, *v15++);
while ( v15 != (unsigned int *)&v21[4 * v25 + 4 + 4 * (__int64)v14] );
v16 = v19 + v14;
v17 = (unsigned int *)&ptr[4 * v24];
do
dict_set((__int64)v5, *v17++, v13);
while ( v17 != (unsigned int *)&ptr[4 * v25 + 4 + 4 * (__int64)v24] );
v24 += v19;
v18 = (unsigned int *)&v21[4 * v16];
do
dict_delete((__int64)v5, *v18++);
while ( v18 != (unsigned int *)&v21[4 * v25 + 4 + 4 * (__int64)v16] );
v14 = v19 + v16;
}
++v13;
}
while ( v22 > v13 );
clock_gettime(1, &v31);
if ( v27 <= 0x14 )
goto LABEL_40;
LABEL_23:
printf("did: %lldms\t\n", 1000 * (v31.tv_sec - tp.tv_sec) + (v31.tv_nsec - tp.tv_nsec) / 1000000);
LABEL_24:
if ( v29 == ++v26 )
goto LABEL_41;
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er15
char v4; // bp
_DWORD *v5; // r13
unsigned int *v6; // rbx
int v7; // er14
unsigned int *v8; // rbx
unsigned int *v9; // rbx
int v10; // er14
int v11; // ebp
__int64 v12; // rbx
unsigned int v13; // er15
int v14; // er14
unsigned int *v15; // rbx
int v16; // er14
unsigned int *v17; // rbx
unsigned int *v18; // rbx
int v19; // [rsp+Ch] [rbp-9Ch]
char *ptr; // [rsp+10h] [rbp-98h]
char *v21; // [rsp+18h] [rbp-90h]
unsigned int v22; // [rsp+28h] [rbp-80h]
int v23; // [rsp+2Ch] [rbp-7Ch]
int v24; // [rsp+30h] [rbp-78h]
unsigned int v25; // [rsp+34h] [rbp-74h]
int v26; // [rsp+38h] [rbp-70h]
unsigned int v27; // [rsp+3Ch] [rbp-6Ch]
unsigned int v28; // [rsp+40h] [rbp-68h]
int v29; // [rsp+44h] [rbp-64h]
char *v30; // [rsp+48h] [rbp-60h]
struct timespec v31; // [rsp+50h] [rbp-58h] BYREF
struct timespec tp; // [rsp+60h] [rbp-48h] BYREF

if ( argc <= 4 )
{
puts("Usage : run_once exp_n k exp_universe repetitions");
exit(1);
}
v27 = atoi(argv[3]);
v3 = atoi(argv[2]);
v19 = v3;
v4 = atoi(argv[1]);
v29 = atoi(argv[4]);
v22 = 1 << v4;
v28 = v3 << v4;
ptr = func15("insertions", (unsigned int)(3 * (v3 << v4)));
v21 = func15("deletions", (unsigned int)(3 * (v3 << v4)));
v30 = func15("finds", (unsigned int)(v3 << v4));
v5 = func7();
if ( !v29 )
{
LABEL_41:
free(ptr);
free(v21);
free(v30);
func13(v5);
exit(0);
}
v26 = 0;
v25 = v3 - 1;
while ( 1 )
{
clock_gettime(1, &tp);
v23 = 0;
v10 = 0;
v11 = 0;
if ( v22 )
{
do
{
if ( v19 )
{
v6 = (unsigned int *)&ptr[4 * v10];
do
dict_set((__int64)v5, *v6++, v11);
while ( v6 != (unsigned int *)&ptr[4 * v25 + 4 + 4 * (__int64)v10] );
v7 = v19 + v10;
v8 = (unsigned int *)&v21[4 * v23];
do
dict_delete((__int64)v5, *v8++);
while ( v8 != (unsigned int *)&v21[4 * v25 + 4 + 4 * (__int64)v23] );
v23 += v19;
v9 = (unsigned int *)&ptr[4 * v7];
do
dict_set((__int64)v5, *v9++, v11);
while ( v9 != (unsigned int *)&ptr[4 * v25 + 4 + 4 * (__int64)v7] );
v10 = v19 + v7;
}
++v11;
}
while ( v22 != v11 );
}
clock_gettime(1, &v31);
if ( v27 <= 0x14 )
{
printf("idi: %lldns\t", v31.tv_nsec + 1000000000 * (v31.tv_sec - tp.tv_sec) - tp.tv_nsec);
clock_gettime(1, &tp);
if ( !v28 )
{
clock_gettime(1, &v31);
LABEL_19:
printf("f: %lldns\t", v31.tv_nsec + 1000000000 * (v31.tv_sec - tp.tv_sec) - tp.tv_nsec);
clock_gettime(1, &tp);
if ( !v22 )
{
clock_gettime(1, &v31);
LABEL_40:
printf("did: %lldns\t\n", v31.tv_nsec + 1000000000 * (v31.tv_sec - tp.tv_sec) - tp.tv_nsec);
goto LABEL_24;
}
goto LABEL_20;
}
}
else
{
printf("idi: %lldms\t", 1000 * (v31.tv_sec - tp.tv_sec) + (v31.tv_nsec - tp.tv_nsec) / 1000000);
clock_gettime(1, &tp);
if ( !v28 )
{
clock_gettime(1, &v31);
goto LABEL_21;
}
}
v12 = 0LL;
do
func10((__int64 *)v5, *(_DWORD *)&v30[4 * v12++]);
while ( v28 > (unsigned int)v12 );
clock_gettime(1, &v31);
if ( v27 <= 0x14 )
goto LABEL_19;
LABEL_21:
printf("f: %lldms\t", 1000 * (v31.tv_sec - tp.tv_sec) + (v31.tv_nsec - tp.tv_nsec) / 1000000);
clock_gettime(1, &tp);
if ( !v22 )
{
clock_gettime(1, &v31);
goto LABEL_23;
}
LABEL_20:
v13 = 0;
v24 = v10;
v14 = v23;
do
{
if ( v19 )
{
v15 = (unsigned int *)&v21[4 * v14];
do
dict_delete((__int64)v5, *v15++);
while ( v15 != (unsigned int *)&v21[4 * v25 + 4 + 4 * (__int64)v14] );
v16 = v19 + v14;
v17 = (unsigned int *)&ptr[4 * v24];
do
dict_set((__int64)v5, *v17++, v13);
while ( v17 != (unsigned int *)&ptr[4 * v25 + 4 + 4 * (__int64)v24] );
v24 += v19;
v18 = (unsigned int *)&v21[4 * v16];
do
dict_delete((__int64)v5, *v18++);
while ( v18 != (unsigned int *)&v21[4 * v25 + 4 + 4 * (__int64)v16] );
v14 = v19 + v16;
}
++v13;
}
while ( v22 > v13 );
clock_gettime(1, &v31);
if ( v27 <= 0x14 )
goto LABEL_40;
LABEL_23:
printf("did: %lldms\t\n", 1000 * (v31.tv_sec - tp.tv_sec) + (v31.tv_nsec - tp.tv_nsec) / 1000000);
LABEL_24:
if ( v29 == ++v26 )
goto LABEL_41;
}
}

variable_types: universe int

variable_types: i int