decompiled_code:
__int64 __fastcall parse_sipifmatch(__int64 a1)
{
unsigned int v2; // er12
_OWORD *v4; // rax
_OWORD *v5; // rbp
const char *v6; // r12
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
__int64 v9; // rdx
const char *v10; // rbp
unsigned int v11; // eax
__int64 v12; // rdx
const char *v13; // rbx
unsigned int v14; // eax
struct _IO_FILE *v15; // rdi
__int64 v16; // [rsp-10h] [rbp-28h]
__int64 v17; // [rsp-10h] [rbp-28h]

if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 16);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch() called\n",
process_no,
v7,
v6,
"<core> [parser/parse_sipifmatch.c:79]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset(v8, "%2d(%d) %s: %s%s(): parse_sipifmatch() called\n", v9);
}
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;
}
v2 = 0;
if ( *(_QWORD *)(a1 + 48) )
return v2;
v4 = (_OWORD *)qm_malloc(mem_block, 16LL);
v5 = v4;
if ( !v4 )
{
v2 = -1;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_ifsipmatch(): No memory left\n",
process_no,
v11,
v10,
"<core> [parser/parse_sipifmatch.c:87]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset(v16, "%2d(%d) %s: %s%s(): parse_ifsipmatch(): No memory left\n", v12);
}
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");
}
v2 = -1;
--dprint_crit;
}
return v2;
}
*v4 = 0LL;
if ( (int)etag_parser(*(_QWORD *)(a1 + 24), *(_DWORD *)(a1 + 32), (__int64)v4) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
v15 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch(): Error in tag_parser\n",
process_no,
v14,
v13,
"<core> [parser/parse_sipifmatch.c:94]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset(v15, "%2d(%d) %s: %s%s(): parse_sipifmatch(): Error in tag_parser\n", v17);
}
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;
}
v2 = -2;
qm_free(mem_block, v5);
return v2;
}
*(_QWORD *)(a1 + 48) = v5;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v2; // er12
_OWORD *v4; // rax
_OWORD *v5; // rbp
const char *v6; // r12
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
__int64 v9; // rdx
const char *v10; // rbp
unsigned int v11; // eax
__int64 v12; // rdx
const char *v13; // rbx
unsigned int v14; // eax
struct _IO_FILE *v15; // rdi
__int64 v16; // [rsp-10h] [rbp-28h]
__int64 v17; // [rsp-10h] [rbp-28h]

if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 16);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch() called\n",
process_no,
v7,
v6,
"<core> [parser/parse_sipifmatch.c:79]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset(v8, "%2d(%d) %s: %s%s(): parse_sipifmatch() called\n", v9);
}
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;
}
v2 = 0;
if ( *(_QWORD *)(a1 + 48) )
return v2;
v4 = (_OWORD *)qm_malloc(mem_block, 16LL);
v5 = v4;
if ( !v4 )
{
v2 = -1;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_ifsipmatch(): No memory left\n",
process_no,
v11,
v10,
"<core> [parser/parse_sipifmatch.c:87]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset(v16, "%2d(%d) %s: %s%s(): parse_ifsipmatch(): No memory left\n", v12);
}
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");
}
v2 = -1;
--dprint_crit;
}
return v2;
}
*v4 = 0LL;
if ( (int)func1(*(_QWORD *)(a1 + 24), *(_DWORD *)(a1 + 32), (__int64)v4) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
v15 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_sipifmatch(): Error in tag_parser\n",
process_no,
v14,
v13,
"<core> [parser/parse_sipifmatch.c:94]: ",
"parse_sipifmatch");
if ( log_color )
dprint_color_reset(v15, "%2d(%d) %s: %s%s(): parse_sipifmatch(): Error in tag_parser\n", v17);
}
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;
}
v2 = -2;
qm_free(mem_block, v5);
return v2;
}
*(_QWORD *)(a1 + 48) = v5;
return 0LL;
}

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:
e
struct _str { char *s; int len; } *

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


repo: virtualolson/who

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 *

return_type: 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

return_type: int


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *


decompiled_code:
__int64 __fastcall fixup_str2int(const char **a1, int a2)
{
__int64 result; // rax
char *v3; // rbp
int v4; // eax
const char *v5; // r12
int v6; // er8
const char *v7; // r12
const char *v8; // rbx
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-14h] [rbp-50h]
int v12[11]; // [rsp+10h] [rbp-2Ch] BYREF

result = 0LL;
if ( a2 == 1 )
{
v3 = (char *)*a1;
v4 = strlen(*a1);
v5 = (const char *)(unsigned __int16)str2s((unsigned __int8 *)v3, v4, v12);
if ( v12[0] )
{
v6 = get_debug_level("pike", 4LL);
result = 4294967290LL;
if ( v6 >= -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();
v10 = stderr;
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(v10, "%2d(%d) %s: %s%s(): ERROR: fixup_str2int: bad number <%s>\n", v11);
}
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);
}
result = 4294967290LL;
--dprint_crit;
}
}
else
{
qm_free(mem_block, *a1);
*a1 = v5;
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char **a1, int a2)
{
__int64 result; // rax
char *v3; // rbp
int v4; // eax
const char *v5; // r12
int v6; // er8
const char *v7; // r12
const char *v8; // rbx
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-14h] [rbp-50h]
int v12[11]; // [rsp+10h] [rbp-2Ch] BYREF

result = 0LL;
if ( a2 == 1 )
{
v3 = (char *)*a1;
v4 = strlen(*a1);
v5 = (const char *)(unsigned __int16)func1((unsigned __int8 *)v3, v4, v12);
if ( v12[0] )
{
v6 = get_debug_level("pike", 4LL);
result = 4294967290LL;
if ( v6 >= -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();
v10 = stderr;
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(v10, "%2d(%d) %s: %s%s(): ERROR: fixup_str2int: bad number <%s>\n", v11);
}
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);
}
result = 4294967290LL;
--dprint_crit;
}
}
else
{
qm_free(mem_block, *a1);
*a1 = v5;
result = 0LL;
}
}
return result;
}

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

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 futex_get(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

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

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

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

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

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

variable_types: i int


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

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

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

func6(mem_lock);
v1 = qm_malloc(shm_block, a1);
func2(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 *


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

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


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

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


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

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

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

result = func1(a1, &v3);
if ( result )
return 1;
*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)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

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


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

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


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

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


decompiled_code:
// attributes: thunk
__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:
// attributes: thunk
__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]; }


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


strlower

decompiled_code:
const __int32_t **__fastcall strlower(__int64 a1)
{
const __int32_t **result; // rax
__int64 v2; // r8
_BYTE *v3; // rdx

result = (const __int32_t **)*(unsigned int *)(a1 + 8);
if ( (int)result > 0 )
{
result = _ctype_tolower_loc();
v2 = 0LL;
do
{
v3 = (_BYTE *)(v2 + *(_QWORD *)a1);
++v2;
*v3 = (*result)[(char)*v3];
}
while ( *(_DWORD *)(a1 + 8) > (int)v2 );
}
return result;
}

canonical_decompiled_code:
const __int32_t **__fastcall func1(__int64 a1)
{
const __int32_t **result; // rax
__int64 v2; // r8
_BYTE *v3; // rdx

result = (const __int32_t **)*(unsigned int *)(a1 + 8);
if ( (int)result > 0 )
{
result = _ctype_tolower_loc();
v2 = 0LL;
do
{
v3 = (_BYTE *)(v2 + *(_QWORD *)a1);
++v2;
*v3 = (*result)[(char)*v3];
}
while ( *(_DWORD *)(a1 + 8) > (int)v2 );
}
return result;
}

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 v2; // edi
int v3; // eax
void *result; // rax
char v5[1048]; // [rsp+0h] [rbp-418h] BYREF

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

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

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

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


decompiled_code:
__int64 __fastcall obj_set_str(__int64 a1, size_t a2, const void *a3)
{
_BYTE *v4; // rax

*(_BYTE *)a1 = 1;
v4 = malloc(a2 + 1);
if ( !v4 )
return 0LL;
*(_QWORD *)(a1 + 8) = v4;
v4[a2] = 0;
if ( !a2 )
return 0LL;
memcpy(v4, a3, a2);
return (unsigned int)a2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, size_t a2, const void *a3)
{
_BYTE *v4; // rax

*(_BYTE *)a1 = 1;
v4 = malloc(a2 + 1);
if ( !v4 )
return 0LL;
*(_QWORD *)(a1 + 8) = v4;
v4[a2] = 0;
if ( !a2 )
return 0LL;
memcpy(v4, a3, a2);
return (unsigned int)a2;
}

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
unsigned __int8 v5; // al
__int64 v6; // rdx
__int64 result; // rax

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

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

v2 = *a1;
if ( *a1 == 58 )
{
result = 1LL;
v4 = 0LL;
}
else
{
v3 = 0LL;
v4 = 0LL;
while ( 1 )
{
v5 = v2 - 48;
v6 = 10 * v4;
if ( v5 > 9u )
return 0LL;
v4 = (char)v5 + v6;
v2 = a1[v3 + 1];
if ( v2 == 58 )
break;
++v3;
}
result = v3 + 2;
}
*a2 = v4;
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

return_type: unsigned long


decompiled_code:
size_t __fastcall bc_read_string(char *a1, _QWORD *a2)
{
__int64 v2; // rax
size_t v3; // rbx
__int64 v5; // r12
_BYTE *v6; // rax
size_t n[6]; // [rsp+8h] [rbp-30h] BYREF

n[0] = 0LL;
v2 = bc_read_lenstr(a1, (__int64 *)n);
v3 = n[0];
if ( !n[0] )
return 0LL;
v5 = v2;
v6 = malloc(n[0] + 1);
if ( !v6 )
return 0LL;
*a2 = v6;
v6[v3] = 0;
memcpy(v6, &a1[v5], v3);
return v3 + v5;
}

canonical_decompiled_code:
size_t __fastcall func2(char *a1, _QWORD *a2)
{
__int64 v2; // rax
size_t v3; // rbx
__int64 v5; // r12
_BYTE *v6; // rax
size_t n[6]; // [rsp+8h] [rbp-30h] BYREF

n[0] = 0LL;
v2 = func1(a1, (__int64 *)n);
v3 = n[0];
if ( !n[0] )
return 0LL;
v5 = v2;
v6 = malloc(n[0] + 1);
if ( !v6 )
return 0LL;
*a2 = v6;
v6[v3] = 0;
memcpy(v6, &a1[v5], v3);
return v3 + v5;
}

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(__int64 a1)
{
_QWORD *v1; // rbp
_QWORD *v2; // r8
unsigned __int16 v3; // bx

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

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
_QWORD *v1; // rbp
_QWORD *v2; // r8
unsigned __int16 v3; // bx

v1 = *(_QWORD **)a1;
v2 = *(_QWORD **)(*(_QWORD *)a1 + 8LL);
if ( **(_DWORD **)a1 )
{
v3 = 0;
do
{
if ( v2[v3] )
{
obj_destroy();
v2 = (_QWORD *)v1[1];
}
++v3;
}
while ( (unsigned int)v3 < *(_DWORD *)v1 );
}
free(v2);
free(v1);
*(_QWORD *)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(unsigned int *a1, __int64 a2)
{
__int64 v3; // rax
void *v4; // rdi
void *v6; // rax

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

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1, __int64 a2)
{
__int64 v3; // rax
void *v4; // rdi
void *v6; // rax

v3 = *a1;
v4 = (void *)*((_QWORD *)a1 + 1);
if ( (_DWORD)v3 != a1[1] )
goto LABEL_2;
v6 = realloc(v4, 8LL * (unsigned int)(v3 + 10));
*((_QWORD *)a1 + 1) = v6;
v4 = v6;
if ( v6 )
{
a1[1] += 10;
v3 = *a1;
LABEL_2:
*a1 = v3 + 1;
*((_QWORD *)v4 + v3) = a2;
return 0LL;
}
a1[1] = 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 *


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


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: universe int

variable_types: i int

variable_types: j int

variable_types: sorted int

variable_types: chosen int

variable_types: n long


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)
{
__int64 v2; // rbp
unsigned int v3; // er13
unsigned int v4; // eax
int v5; // er14
__int64 v6; // rbx
__int64 v7; // rax
int *v8; // rcx
int v9; // esi
int *v10; // rax

v2 = a2;
v3 = a2 >> 2;
v4 = time(0LL);
srandom(v4);
if ( a2 >> 2 )
{
v5 = 0;
do
{
++v5;
v6 = random();
v7 = random();
v8 = (int *)(a1 + 4LL * (int)(v6 % v2));
v9 = *v8;
v10 = (int *)(a1 + 4LL * (int)(v7 % v2));
*v8 = *v10;
*v10 = v9;
}
while ( v3 != v5 );
}
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, unsigned int a2)
{
__int64 v2; // rbp
unsigned int v3; // er13
unsigned int v4; // eax
int v5; // er14
__int64 v6; // rbx
__int64 v7; // rax
int *v8; // rcx
int v9; // esi
int *v10; // rax

v2 = a2;
v3 = a2 >> 2;
v4 = time(0LL);
srandom(v4);
if ( a2 >> 2 )
{
v5 = 0;
do
{
++v5;
v6 = random();
v7 = random();
v8 = (int *)(a1 + 4LL * (int)(v6 % v2));
v9 = *v8;
v10 = (int *)(a1 + 4LL * (int)(v7 % v2));
*v8 = *v10;
*v10 = v9;
}
while ( v3 != v5 );
}
}

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:
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: i long

variable_types:
mask
unsigned int


decompiled_code:
int __fastcall save_array_to_file(__int64 a1, const char *a2, __int64 a3)
{
__int64 v3; // r12
__int64 v4; // rbx
int v5; // er14
int v6; // eax

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

canonical_decompiled_code:
int __fastcall func10(__int64 a1, const char *a2, __int64 a3)
{
__int64 v3; // r12
__int64 v4; // rbx
int v5; // er14
int v6; // eax

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

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 *result; // rax
int v5; // esi

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

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

v3 = (int *)(a1 + 4LL * a2);
result = (int *)(a1 + 4LL * a3);
v5 = *v3;
*v3 = *result;
*result = v5;
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

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char v4; // bp
void *v5; // r14
int v6; // er15
unsigned int v7; // ebx
char *v8; // r12
__int64 v9; // rsi
char *v10; // r12
__int64 v11; // rsi
char *v12; // r12
__int64 v13; // rsi
__int64 v14; // rbx
__int64 v15; // rsi
unsigned int i; // ebx
char *v17; // r12
__int64 v18; // rsi
char *v19; // r12
__int64 v20; // rsi
char *v21; // r12
__int64 v22; // rsi
int v23; // [rsp+0h] [rbp-98h]
int v24; // [rsp+0h] [rbp-98h]
int v25; // [rsp+4h] [rbp-94h]
int v26; // [rsp+4h] [rbp-94h]
char *ptr; // [rsp+8h] [rbp-90h]
char *v28; // [rsp+10h] [rbp-88h]
unsigned int v29; // [rsp+18h] [rbp-80h]
unsigned int v30; // [rsp+1Ch] [rbp-7Ch]
int v31; // [rsp+28h] [rbp-70h]
unsigned int v32; // [rsp+2Ch] [rbp-6Ch]
unsigned int v33; // [rsp+30h] [rbp-68h]
int v34; // [rsp+34h] [rbp-64h]
unsigned int *v35; // [rsp+38h] [rbp-60h]
struct timespec tp; // [rsp+40h] [rbp-58h] BYREF
struct timespec v37; // [rsp+50h] [rbp-48h] BYREF

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

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char v4; // bp
void *v5; // r14
int v6; // er15
unsigned int v7; // ebx
char *v8; // r12
__int64 v9; // rsi
char *v10; // r12
__int64 v11; // rsi
char *v12; // r12
__int64 v13; // rsi
__int64 v14; // rbx
__int64 v15; // rsi
unsigned int i; // ebx
char *v17; // r12
__int64 v18; // rsi
char *v19; // r12
__int64 v20; // rsi
char *v21; // r12
__int64 v22; // rsi
int v23; // [rsp+0h] [rbp-98h]
int v24; // [rsp+0h] [rbp-98h]
int v25; // [rsp+4h] [rbp-94h]
int v26; // [rsp+4h] [rbp-94h]
char *ptr; // [rsp+8h] [rbp-90h]
char *v28; // [rsp+10h] [rbp-88h]
unsigned int v29; // [rsp+18h] [rbp-80h]
unsigned int v30; // [rsp+1Ch] [rbp-7Ch]
int v31; // [rsp+28h] [rbp-70h]
unsigned int v32; // [rsp+2Ch] [rbp-6Ch]
unsigned int v33; // [rsp+30h] [rbp-68h]
int v34; // [rsp+34h] [rbp-64h]
unsigned int *v35; // [rsp+38h] [rbp-60h]
struct timespec tp; // [rsp+40h] [rbp-58h] BYREF
struct timespec v37; // [rsp+50h] [rbp-48h] BYREF

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

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: universe int

variable_types: i int

variable_types: j int

variable_types: sorted int

variable_types: chosen int

variable_types: n long


canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char v4; // bp
void *v5; // r14
int v6; // er15
unsigned int v7; // ebx
char *v8; // r12
__int64 v9; // rsi
char *v10; // r12
__int64 v11; // rsi
char *v12; // r12
__int64 v13; // rsi
__int64 v14; // rbx
__int64 v15; // rsi
unsigned int i; // ebx
char *v17; // r12
__int64 v18; // rsi
char *v19; // r12
__int64 v20; // rsi
char *v21; // r12
__int64 v22; // rsi
int v23; // [rsp+0h] [rbp-98h]
int v24; // [rsp+0h] [rbp-98h]
int v25; // [rsp+4h] [rbp-94h]
int v26; // [rsp+4h] [rbp-94h]
char *ptr; // [rsp+8h] [rbp-90h]
char *v28; // [rsp+10h] [rbp-88h]
unsigned int v29; // [rsp+18h] [rbp-80h]
unsigned int v30; // [rsp+1Ch] [rbp-7Ch]
int v31; // [rsp+28h] [rbp-70h]
unsigned int v32; // [rsp+2Ch] [rbp-6Ch]
unsigned int v33; // [rsp+30h] [rbp-68h]
int v34; // [rsp+34h] [rbp-64h]
unsigned int *v35; // [rsp+38h] [rbp-60h]
struct timespec tp; // [rsp+40h] [rbp-58h] BYREF
struct timespec v37; // [rsp+50h] [rbp-48h] BYREF

if ( argc <= 4 )
{
puts("Usage : run_once exp_n k exp_universe repetitions");
exit(1);
}
v32 = atoi(argv[3]);
v3 = atoi(argv[2]);
v4 = atoi(argv[1]);
v34 = atoi(argv[4]);
v33 = v3 << v4;
v29 = 1 << v4;
ptr = (char *)func16("insertions");
v28 = (char *)func16("deletions");
v35 = (unsigned int *)func16("finds");
v5 = (void *)func7((unsigned int)(v3 << v4), v32);
if ( !v34 )
{
LABEL_34:
free(ptr);
free(v28);
free(v35);
func14(v5);
exit(0);
}
v31 = 0;
v6 = v3;
v30 = v3 - 1;
while ( 1 )
{
v7 = 0;
clock_gettime(1, &tp);
v23 = 0;
v25 = 0;
if ( v29 )
{
do
{
if ( v6 )
{
v8 = &ptr[4 * v25];
do
{
v9 = *(unsigned int *)v8;
v8 += 4;
dict_set(v5, v9, v7);
}
while ( v8 != &ptr[4 * v30 + 4 + 4 * (__int64)v25] );
v26 = v6 + v25;
v10 = &v28[4 * v23];
do
{
v11 = *(unsigned int *)v10;
v10 += 4;
func12(v5, v11);
}
while ( v10 != &v28[4 * v30 + 4 + 4 * (__int64)v23] );
v23 += v6;
v12 = &ptr[4 * v26];
do
{
v13 = *(unsigned int *)v12;
v12 += 4;
dict_set(v5, v13, v7);
}
while ( &ptr[4 * v30 + 4 + 4 * (__int64)v26] != v12 );
v25 = v6 + v26;
}
++v7;
}
while ( v29 != v7 );
}
clock_gettime(1, &v37);
if ( v32 <= 0x14 )
{
printf("idi: %lldns\t", v37.tv_nsec + 1000000000 * (v37.tv_sec - tp.tv_sec) - tp.tv_nsec);
clock_gettime(1, &tp);
if ( !v33 )
{
clock_gettime(1, &v37);
LABEL_38:
printf("f: %lldns\t", v37.tv_nsec + 1000000000 * (v37.tv_sec - tp.tv_sec) - tp.tv_nsec);
clock_gettime(1, &tp);
if ( !v29 )
{
clock_gettime(1, &v37);
LABEL_40:
printf("did: %lldns\t\n", v37.tv_nsec + 1000000000 * (v37.tv_sec - tp.tv_sec) - tp.tv_nsec);
goto LABEL_33;
}
goto LABEL_21;
}
}
else
{
printf("idi: %lldms\t", 1000 * (v37.tv_sec - tp.tv_sec) + (v37.tv_nsec - tp.tv_nsec) / 1000000);
clock_gettime(1, &tp);
if ( !v33 )
{
clock_gettime(1, &v37);
goto LABEL_20;
}
}
v14 = 0LL;
do
{
v15 = v35[v14++];
func10(v5, v15);
}
while ( v33 > (unsigned int)v14 );
clock_gettime(1, &v37);
if ( v32 <= 0x14 )
goto LABEL_38;
LABEL_20:
printf("f: %lldms\t", 1000 * (v37.tv_sec - tp.tv_sec) + (v37.tv_nsec - tp.tv_nsec) / 1000000);
clock_gettime(1, &tp);
if ( !v29 )
{
clock_gettime(1, &v37);
goto LABEL_32;
}
LABEL_21:
for ( i = 0; i < v29; ++i )
{
if ( v6 )
{
v17 = &v28[4 * v23];
do
{
v18 = *(unsigned int *)v17;
v17 += 4;
func12(v5, v18);
}
while ( &v28[4 * v30 + 4 + 4 * (__int64)v23] != v17 );
v24 = v6 + v23;
v19 = &ptr[4 * v25];
do
{
v20 = *(unsigned int *)v19;
v19 += 4;
dict_set(v5, v20, i);
}
while ( &ptr[4 * v30 + 4 + 4 * (__int64)v25] != v19 );
v25 += v6;
v21 = &v28[4 * v24];
do
{
v22 = *(unsigned int *)v21;
v21 += 4;
func12(v5, v22);
}
while ( &v28[4 * v24 + 4 + 4 * (unsigned __int64)v30] != v21 );
v23 = v6 + v24;
}
}
clock_gettime(1, &v37);
if ( v32 <= 0x14 )
goto LABEL_40;
LABEL_32:
printf("did: %lldms\t\n", 1000 * (v37.tv_sec - tp.tv_sec) + (v37.tv_nsec - tp.tv_nsec) / 1000000);
LABEL_33:
if ( v34 == ++v31 )
goto LABEL_34;
}
}


repo: vivekseth/Object-Oriented-C

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
const char *v4; // rax
__int64 v5; // rbp
const char *v6; // rax

v3 = new_Object(argc, argv, envp);
v4 = (const char *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(v3 + 8) + 8LL))(v3);
puts(v4);
(**(void (__fastcall ***)(__int64))(v3 + 8))(v3);
v5 = new_Person("Vivek");
(*(void (__fastcall **)(__int64))(*(_QWORD *)(v5 + 8) + 24LL))(v5);
v6 = (const char *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(v5 + 8) + 8LL))(v5);
puts(v6);
(*(void (__fastcall **)(__int64))(*(_QWORD *)(v5 + 8) + 16LL))(v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
const char *v4; // rax
__int64 v5; // rbp
const char *v6; // rax

v3 = func12(argc, argv, envp);
v4 = (const char *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(v3 + 8) + 8LL))(v3);
puts(v4);
(**(void (__fastcall ***)(__int64))(v3 + 8))(v3);
v5 = new_Person("Vivek");
(*(void (__fastcall **)(__int64))(*(_QWORD *)(v5 + 8) + 24LL))(v5);
v6 = (const char *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(v5 + 8) + 8LL))(v5);
puts(v6);
(*(void (__fastcall **)(__int64))(*(_QWORD *)(v5 + 8) + 16LL))(v5);
return 0;
}

original_code:
int main(int argc, char const *argv[])
{
 Object * obj = new_Object();
 char *str = obj->methods->toString(obj);
 printf("%s\n", str);
 obj->methods->delete(obj);
 Person * psn = new_Person("Vivek");
 psn->methods->print(psn);
 Object * o = (Object *) psn;
 printf("%s\n", o->methods->toString(o));
 psn->methods->delete(psn);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct Object *obj = new_Object();
 char *str = obj->methods->toString(obj);
 printf("%s\n", str);
 obj->methods->delete(obj);
 struct Person *psn = new_Person("Vivek");
 psn->methods->print(psn);
 struct Object *o = (Object *) psn;
 printf("%s\n", o->methods->toString(o));
 psn->methods->delete(psn);
 return 0;
}

variable_types:
argv
char *[]

variable_types: struct Object { struct Properties { char *_; } *prop; struct Methods { void (*delete)(struct Object *o); char *(*toString)(void *o); } *methods; } *

variable_types:
str
char *

variable_types: struct Person { struct Person_Properties { struct Properties { char *_; } super; char *name; } *prop; struct Person_Methods { struct Methods { void (*delete)(struct Object { struct Properties *prop; struct Methods *methods; } *o); char *(*toString)(void *o); } super; void (*delete)(struct Person *o); void (*print)(void *o); } *methods; struct Object *super; } *

user_defined_types: struct Person { struct Person_Properties *prop; struct Person_Methods *methods; struct Object *super; }

user_defined_types: struct Person_Properties { struct Properties super; char *name; }

user_defined_types: struct Person_Methods { struct Methods super; void (*delete)(struct Person *o); void (*print)(void *o); }


decompiled_code:
const char *toString_Object()
{
return "(Object)";
}

canonical_decompiled_code:
const char *func7()
{
return "(Object)";
}

original_code:
char* toString_Object(void * o) {
 return "(Object)";
}

canonical_original_code:
char *toString_Object(void *o) {
 return "(Object)";
}

variable_types:
o
void *

return_type: char *


decompiled_code:
void init_Properties()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void init_Properties(Properties * p) {
}

canonical_original_code:
void init_Properties(struct Properties *p) {
}

variable_types:
p
struct Properties { char *_; } *


decompiled_code:
void uninit_Properties()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void uninit_Properties(Properties * p) {
}

canonical_original_code:
void uninit_Properties(struct Properties *p) {
}


decompiled_code:
void new_Object()
{
_QWORD *v0; // r12

v0 = malloc(0x10uLL);
*v0 = malloc(8uLL);
v0[1] = malloc(0x10uLL);
init_Object((__int64)v0);
}

canonical_decompiled_code:
void func12()
{
_QWORD *v0; // r12

v0 = malloc(0x10uLL);
*v0 = malloc(8uLL);
v0[1] = malloc(0x10uLL);
func11((__int64)v0);
}

original_code:
Object * new_Object() {
 Object * o = malloc(sizeof(Object));
 o->prop = malloc(sizeof(Properties));
 o->methods = malloc(sizeof(Methods));
 init_Object(o);
 return o;
}

canonical_original_code:
struct Object *new_Object() {
 struct Object *o = malloc(sizeof(Object));
 o->prop = malloc(sizeof(Properties));
 o->methods = malloc(sizeof(Methods));
 init_Object(o);
 return o;
}

return_type: struct Object { struct Properties { char *_; } *prop; struct Methods { void (*delete)(struct Object *o); char *(*toString)(void *o); } *methods; } *

user_defined_types: struct Object { struct Properties *prop; struct Methods *methods; }


decompiled_code:
void __fastcall uninit_Object(__int64 a1)
{
uninit_Methods(*(_QWORD **)(a1 + 8));
}

canonical_decompiled_code:
void __fastcall func14(__int64 a1)
{
func13(*(_QWORD **)(a1 + 8));
}

original_code:
void uninit_Object(Object * o) {
 uninit_Properties(o->prop);
 uninit_Methods(o->methods);
}

canonical_original_code:
void uninit_Object(struct Object *o) {
 uninit_Properties(o->prop);
 uninit_Methods(o->methods);
}

user_defined_types: struct Methods { void (*delete)(struct Object *o); char *(*toString)(void *o); }


decompiled_code:
void __fastcall delete_Object(void *ptr)
{
uninit_Object((__int64)ptr);
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func15(void *ptr)
{
func14((__int64)ptr);
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void delete_Object(Object * o) {
 uninit_Object(o);
 free(o->prop);
 o->prop = 0;
 free(o->methods);
 o->methods = 0;
 free(o);
 o = 0;
}

canonical_original_code:
void delete_Object(struct Object *o) {
 uninit_Object(o);
 free(o->prop);
 o->prop = 0;
 free(o->methods);
 o->methods = 0;
 free(o);
 o = 0;
}


decompiled_code:
__int64 __fastcall toString_Person(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)a1 + 8LL);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)a1 + 8LL);
}

original_code:
char* toString_Person(void * ptr) {
 Person * psn = (Person *)ptr;
 char * name = psn->prop->name;
 return name;
}

canonical_original_code:
char *toString_Person(void *ptr) {
 struct Person *psn = (Person *)ptr;
 char *name = psn->prop->name;
 return name;
}

variable_types:
ptr
void *

variable_types:
name
char *


print

decompiled_code:
int __fastcall print(__int64 a1)
{
const char *v1; // rax

v1 = (const char *)(*(__int64 (**)(void))(*(_QWORD *)(a1 + 8) + 8LL))();
return puts(v1);
}

canonical_decompiled_code:
int __fastcall func17(__int64 a1)
{
const char *v1; // rax

v1 = (const char *)(*(__int64 (**)(void))(*(_QWORD *)(a1 + 8) + 8LL))();
return puts(v1);
}

original_code:
void print(void * ptr) {
 Person * psn = (Person *)ptr;
 Object * o = (Object *)psn;
 char * str = o->methods->toString(o);
 printf("%s\n", str);
}

canonical_original_code:
void print(void *ptr) {
 struct Person *psn = (Person *)ptr;
 struct Object *o = (Object *)psn;
 char *str = o->methods->toString(o);
 printf("%s\n", str);
}


decompiled_code:
void __fastcall init_Person_Properties(__int64 a1, __int64 a2)
{
init_Properties();
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void init_Person_Properties(Person_Properties * p, char * name) {
 init_Properties((Properties *)p);
 p->name = name;
}

canonical_original_code:
void init_Person_Properties(struct Person_Properties *p, char *name) {
 init_Properties((struct Properties *)p);
 p->name = name;
}

variable_types: struct Person_Properties { struct Properties { char *_; } super; char *name; } *


decompiled_code:
void __fastcall uninit_Person_Properties(__int64 a1)
{
uninit_Properties();
*(_QWORD *)(a1 + 8) = 0LL;
}

canonical_decompiled_code:
void __fastcall func19(__int64 a1)
{
func9();
*(_QWORD *)(a1 + 8) = 0LL;
}

original_code:
void uninit_Person_Properties(Person_Properties * p) {
 uninit_Properties((Properties *)p);
 p->name = 0;
}

canonical_original_code:
void uninit_Person_Properties(struct Person_Properties *p) {
 uninit_Properties((struct Properties *)p);
 p->name = 0;
}


decompiled_code:
void __fastcall delete_Person(void *ptr)
{
uninit_Person_Properties(*(_QWORD *)ptr);
free(*(void **)ptr);
*(_QWORD *)ptr = 0LL;
init_Person_Methods(*((_QWORD **)ptr + 1));
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func21(void *ptr)
{
func19(*(_QWORD *)ptr);
free(*(void **)ptr);
*(_QWORD *)ptr = 0LL;
func20(*((_QWORD **)ptr + 1));
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void delete_Person(Person * o) {
 uninit_Person_Properties(o->prop);
 free(o->prop);
 o->prop = 0;
 init_Person_Methods(o->methods);
 free(o->methods);
 o->methods = 0;
 free(o);
 o = 0;
}

canonical_original_code:
void delete_Person(struct Person *o) {
 uninit_Person_Properties(o->prop);
 free(o->prop);
 o->prop = 0;
 init_Person_Methods(o->methods);
 free(o->methods);
 o->methods = 0;
 free(o);
 o = 0;
}