decompiled_code:
void events_mod_destroy()
{
const char *v0; // rbx
unsigned int v1; // eax
const char *v2; // rbx
unsigned int v3; // eax
const char *v4; // rbx
unsigned int v5; // eax
const char *v6; // rbx
unsigned int v7; // eax
const char *v8; // rbx
unsigned int v9; // eax

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v0 = (const char *)*((_QWORD *)&log_level_info + 16);
v1 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup\n",
process_no,
v1,
v0,
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
}
--dprint_crit;
}
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 16);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... events UAC\n",
process_no,
v3,
v2,
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... events UAC\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_uac_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = (const char *)*((_QWORD *)&log_level_info + 16);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... qsa interface\n",
process_no,
v5,
v4,
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... qsa interface\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_qsa_interface_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 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();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libs\n",
process_no,
v7,
v6,
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libs\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
}
--dprint_crit;
}
qsa_cleanup();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v8 = (const char *)*((_QWORD *)&log_level_info + 16);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup finished\n",
process_no,
v9,
v8,
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup finished\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
}
--dprint_crit;
}
}

canonical_decompiled_code:
void func3()
{
const char *v0; // rbx
unsigned int v1; // eax
const char *v2; // rbx
unsigned int v3; // eax
const char *v4; // rbx
unsigned int v5; // eax
const char *v6; // rbx
unsigned int v7; // eax
const char *v8; // rbx
unsigned int v9; // eax

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v0 = (const char *)*((_QWORD *)&log_level_info + 16);
v1 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup\n",
process_no,
v1,
v0,
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
}
--dprint_crit;
}
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 16);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... events UAC\n",
process_no,
v3,
v2,
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... events UAC\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_uac_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = (const char *)*((_QWORD *)&log_level_info + 16);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... qsa interface\n",
process_no,
v5,
v4,
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... qsa interface\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_qsa_interface_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 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();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libs\n",
process_no,
v7,
v6,
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libs\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
}
--dprint_crit;
}
qsa_cleanup();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v8 = (const char *)*((_QWORD *)&log_level_info + 16);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup finished\n",
process_no,
v9,
v8,
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup finished\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
}
--dprint_crit;
}
}

original_code:
void events_mod_destroy(void)
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "presence_b2b module cleanup\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __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(): " "presence_b2b module cleanup\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __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(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... events UAC\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __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(): " " ... events UAC\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... events UAC\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __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(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_uac_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... qsa interface\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __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(): " " ... qsa interface\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... qsa interface\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __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(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_qsa_interface_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... common libs\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __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(): " " ... common libs\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libs\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __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(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_cleanup();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __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(): " "presence_b2b module cleanup finished\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __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(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } (dprint_crit--); } } while(0);
}

canonical_original_code:
void events_mod_destroy()
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "presence_b2b module cleanup\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __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(): " "presence_b2b module cleanup\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __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(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... events UAC\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __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(): " " ... events UAC\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... events UAC\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __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(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_uac_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... qsa interface\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __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(): " " ... qsa interface\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... qsa interface\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __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(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_qsa_interface_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... common libs\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __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(): " " ... common libs\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libs\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __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(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_cleanup();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __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(): " "presence_b2b module cleanup finished\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __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(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } (dprint_crit--); } } while(0);
}


repo: virtualolson/who

decompiled_code:
void __fastcall atomic_inc_int(volatile signed __int32 *a1)
{
_InterlockedIncrement(a1);
}

canonical_decompiled_code:
void __fastcall func0(volatile signed __int32 *a1)
{
_InterlockedIncrement(a1);
}

original_code: inline static void atomic_inc_int (volatile int* var) { asm volatile( "lock ;" " " "incl %0" " \n\t" : "=m"(*var) : "m"(*var) : "cc", "memory" ); }

canonical_original_code: inline static void atomic_inc_int(int *var) { asm volatile( "lock ;" " " "incl %0" " \n\t" : "=m"(*var) : "m"(*var) : "cc", "memory" ); }

variable_types:
var
int *

return_type: void


decompiled_code:
_BOOL8 __fastcall atomic_dec_and_test_int(volatile signed __int32 *a1)
{
return _InterlockedDecrement(a1) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(volatile signed __int32 *a1)
{
return _InterlockedDecrement(a1) == 0;
}

original_code: inline static int atomic_dec_and_test_int(volatile int* var) { char ret; asm volatile( "lock ;" " " "decl %0" "\n\t" "setz %1 \n\t" : "=m" (*var), "=qm"(ret) : "m"(*var) : "cc", "memory" ); return ret; }

canonical_original_code: inline static int atomic_dec_and_test_int(int *var) { char ret; asm volatile( "lock ;" " " "decl %0" "\n\t" "setz %1 \n\t" : "=m" (*var), "=qm"(ret) : "m"(*var) : "cc", "memory" ); return ret; }

variable_types: ret char

return_type: int


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

canonical_decompiled_code:
__int64 __fastcall func2(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: v int


decompiled_code:
unsigned __int64 *cfg_reset_handles()
{
__int64 i; // rbx
unsigned __int64 *result; // rax
unsigned __int64 v2; // rsi

if ( cfg_local )
{
for ( i = cfg_group; i; i = *(_QWORD *)(i + 72) )
{
if ( !cfg_ginst_count )
break;
result = *(unsigned __int64 **)(i + 48);
v2 = *result;
if ( *result < cfg_local + 4LL || v2 > cfg_block_size + cfg_local + 4LL )
result = (unsigned __int64 *)cfg_move_handle(i, v2 - 36, 0LL);
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 *func5()
{
__int64 i; // rbx
unsigned __int64 *result; // rax
unsigned __int64 v2; // rsi

if ( cfg_local )
{
for ( i = cfg_group; i; i = *(_QWORD *)(i + 72) )
{
if ( !cfg_ginst_count )
break;
result = *(unsigned __int64 **)(i + 48);
v2 = *result;
if ( *result < cfg_local + 4LL || v2 > cfg_block_size + cfg_local + 4LL )
result = (unsigned __int64 *)cfg_move_handle(i, v2 - 36, 0LL);
}
}
return result;
}

original_code:
static inline void cfg_reset_handles(void)
{
 cfg_group_t *group;
 if (!cfg_local)
  return;
 for ( group = cfg_group;
  group && cfg_ginst_count;
  group = group->next
 ) {
  if (((unsigned char*)*(group->handle) < cfg_local->vars)
   || ((unsigned char*)*(group->handle) > cfg_local->vars + cfg_block_size)
  )
   cfg_move_handle(group,
     ( (((unsigned char*)(*(group->handle)) < cfg_local->vars) || ((unsigned char*)(*(group->handle)) > cfg_local->vars + cfg_block_size) ) ? (cfg_group_inst_t*)((char*)(*(group->handle)) - (unsigned long)&((cfg_group_inst_t *)0)->vars) : ((void *)0) ),
     ((void *)0));
 }
}

canonical_original_code:
static inline void cfg_reset_handles()
{
 struct _cfg_group *group;
 if (!cfg_local)
  return;
 for ( group = cfg_group;
  group && cfg_ginst_count;
  group = group->next
 ) {
  if (((unsigned char *)*(group->handle) < cfg_local->vars)
   || ((unsigned char *)*(group->handle) > cfg_local->vars + cfg_block_size)
  )
   cfg_move_handle(group,
     ( (((unsigned char *)(*(group->handle)) < cfg_local->vars) || ((unsigned char *)(*(group->handle)) > cfg_local->vars + cfg_block_size) ) ? (struct _cfg_group_inst *)((char *)(*(group->handle)) - (unsigned long)&((struct _cfg_group_inst *)0)->vars) : ((void *)0) ),
     ((void *)0));
 }
}

variable_types: struct _cfg_group { int num; struct _cfg_mapping { struct _cfg_def { char *name; unsigned int type; int min; int max; int (*on_change_cb)(void *, struct _str { char *s; int len; } *, struct _str *, void **); void (*on_set_child_cb)(struct _str *, struct _str *); char *descr; } *def; int name_len; int pos; int offset; unsigned int flag; } *mapping; char *vars; struct _cfg_add_var { struct _cfg_add_var *next; unsigned int type; union { char *ch; struct _str s; int i; } val; unsigned int group_id; int name_len; char name[1]; } *add_var; int size; int meta_offset; int var_offset; void **handle; void *orig_handle; unsigned char dynamic; struct _cfg_group *next; int name_len; char name[1]; } *

user_defined_types: struct _cfg_group { int num; struct _cfg_mapping *mapping; char *vars; struct _cfg_add_var *add_var; int size; int meta_offset; int var_offset; void **handle; void *orig_handle; unsigned char dynamic; struct _cfg_group *next; int name_len; char name[1]; }

user_defined_types: struct _cfg_group_inst { unsigned int id; unsigned int set[-1]; unsigned char vars[1]; }

user_defined_types: struct _cfg_mapping { struct _cfg_def *def; int name_len; int pos; int offset; unsigned int flag; }

user_defined_types: struct _cfg_def { char *name; unsigned int type; int min; int max; int (*on_change_cb)(void *, struct _str *, struct _str *, void **); void (*on_set_child_cb)(struct _str *, struct _str *); char *descr; }


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *

variable_types: i int


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

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

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

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

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

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


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

v1 = *(_QWORD **)(a1 + 48);
if ( v1 )
{
if ( *v1 )
{
v2 = 0LL;
do
{
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2));
futex_release(mem_lock);
v2 += 8LL;
}
while ( *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2) );
}
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 48));
futex_release(mem_lock);
}
futex_get(mem_lock);
qm_free(shm_block, a1);
return futex_release(mem_lock);
}

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

v1 = *(_QWORD **)(a1 + 48);
if ( v1 )
{
if ( *v1 )
{
v2 = 0LL;
do
{
func6(mem_lock);
qm_free(shm_block, *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2));
func7(mem_lock);
v2 += 8LL;
}
while ( *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2) );
}
func6(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 48));
func7(mem_lock);
}
func6(mem_lock);
qm_free(shm_block, a1);
return func7(mem_lock);
}

original_code:
static inline void cfg_child_cb_free_item(cfg_child_cb_t *cb)
{
 int i;
 if (cb->replaced) {
  for (i=0; cb->replaced[i]; i++)
   do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced[i])); futex_release(mem_lock); }while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced)); futex_release(mem_lock); }while(0);
 }
 do { futex_get(mem_lock); qm_free(shm_block, (cb)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
static inline void cfg_child_cb_free_item(struct _cfg_child_cb *cb)
{
 int i;
 if (cb->replaced) {
  for (i=0; cb->replaced[i]; i++)
   do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced[i])); futex_release(mem_lock); }while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced)); futex_release(mem_lock); }while(0);
 }
 do { futex_get(mem_lock); qm_free(shm_block, (cb)); futex_release(mem_lock); }while(0);
}

variable_types: struct _cfg_child_cb { struct atomic_t { int val; } refcnt; struct atomic_t cb_count; struct _str { char *s; int len; } gname; void (*cb)(struct _str *, struct _str *); void **replaced; struct _cfg_child_cb *next; } *

user_defined_types: struct _cfg_child_cb { struct atomic_t refcnt; struct atomic_t cb_count; struct _str gname; void (*cb)(struct _str *, struct _str *); void **replaced; struct _cfg_child_cb *next; }


decompiled_code:
int __fastcall sleep_us(unsigned int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

v2.tv_sec = a1 / 0xF4240;
v2.tv_usec = a1 % 0xF4240;
return select(0, 0LL, 0LL, 0LL, &v2);
}

canonical_decompiled_code:
int __fastcall func10(unsigned int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

v2.tv_sec = a1 / 0xF4240;
v2.tv_usec = a1 % 0xF4240;
return select(0, 0LL, 0LL, 0LL, &v2);
}

original_code:
inline static void sleep_us( unsigned int nusecs )
{
 struct timeval tval;
 tval.tv_sec =nusecs/1000000;
 tval.tv_usec=nusecs%1000000;
 select(0, ((void *)0), ((void *)0), ((void *)0), &tval );
}

canonical_original_code:
inline static void sleep_us(unsigned int nusecs)
{
 struct timeval tval;
 tval.tv_sec =nusecs/1000000;
 tval.tv_usec=nusecs%1000000;
 select(0, ((void *)0), ((void *)0), ((void *)0), &tval );
}

variable_types:
nusecs
unsigned int

variable_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
__int64 __fastcall register_basic_timers(unsigned int a1)
{
if ( (int)register_procs() < 0 )
return 0xFFFFFFFFLL;
cfg_register_child(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1)
{
if ( (int)register_procs() < 0 )
return 0xFFFFFFFFLL;
cfg_register_child(a1);
return 0LL;
}

original_code:
int register_basic_timers(int timers)
{
 if(register_procs(timers)<0)
  return -1;
 cfg_register_child(timers);
 return 0;
}

variable_types: timers int


decompiled_code:
__int64 __fastcall fork_basic_timer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int v10; // eax

result = fork_process();
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
sleep(a6);
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local(0);
v10 = get_ticks();
a4(v10, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int v10; // eax

result = fork_process();
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
sleep(a6);
if ( cfg_ginst_count )
func5();
if ( *cfg_global != cfg_local )
func9(0);
v10 = get_ticks();
a4(v10, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int fork_basic_timer(int child_id, char* desc, int make_sock,
      timer_function* f, void* param, int interval)
{
 int pid;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep(interval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
  }
 }
 return pid;
}

canonical_original_code:
int fork_basic_timer(int child_id, char *desc, int make_sock, void (*f)(unsigned int ticks, void *param), void *param, int interval)
{
 int pid;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep(interval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
  }
 }
 return pid;
}

variable_types:
desc
char *

variable_types: void (*)(unsigned int ticks, void *param)

variable_types:
param
void *

variable_types: interval int

variable_types: pid int


decompiled_code:
__int64 __fastcall fork_basic_utimer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
int v10; // eax

result = fork_process();
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
sleep_us(a6);
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local(0);
v10 = get_ticks_raw();
a4((unsigned int)(1000 * v10) >> 4, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
int v10; // eax

result = fork_process();
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
func10(a6);
if ( cfg_ginst_count )
func5();
if ( *cfg_global != cfg_local )
func9(0);
v10 = get_ticks_raw();
a4((unsigned int)(1000 * v10) >> 4, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int fork_basic_utimer(int child_id, char* desc, int make_sock,
      utimer_function* f, void* param, int uinterval)
{
 int pid;
 ticks_t ts;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep_us(uinterval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   ts = get_ticks_raw();
   f((((ts)*1000U)/16U), param);
  }
 }
 return pid;
}

canonical_original_code:
int fork_basic_utimer(int child_id, char *desc, int make_sock, void (*f)(unsigned int uticks, void *param), void *param, int uinterval)
{
 int pid;
 unsigned int ts;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep_us(uinterval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   ts = get_ticks_raw();
   f((((ts)*1000U)/16U), param);
  }
 }
 return pid;
}

variable_types: void (*)(unsigned int uticks, void *param)

variable_types: uinterval int

variable_types:
ts
unsigned int


decompiled_code:
__int64 __fastcall fork_local_timer_process(unsigned int a1, __int64 a2, unsigned int a3, __int64 *a4)
{
__int64 v6; // rbx
__int64 result; // rax
unsigned int v8; // eax

v6 = shm_malloc(0x44018u);
result = 0xFFFFFFFFLL;
if ( v6 )
{
v8 = get_ticks_raw();
if ( (int)init_local_timer(v6, v8) < 0 || (result = fork_process(a1, a2, a3), (int)result < 0) )
{
futex_get(mem_lock);
qm_free(shm_block, v6);
futex_release(mem_lock);
result = 0xFFFFFFFFLL;
}
else
{
*a4 = v6;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, __int64 a2, unsigned int a3, __int64 *a4)
{
__int64 v6; // rbx
__int64 result; // rax
unsigned int v8; // eax

v6 = func11(0x44018u);
result = 0xFFFFFFFFLL;
if ( v6 )
{
v8 = get_ticks_raw();
if ( (int)init_local_timer(v6, v8) < 0 || (result = fork_process(a1, a2, a3), (int)result < 0) )
{
func6(mem_lock);
qm_free(shm_block, v6);
func7(mem_lock);
result = 0xFFFFFFFFLL;
}
else
{
*a4 = v6;
}
}
return result;
}

original_code:
int fork_local_timer_process(int child_id, char* desc, int make_sock,
      struct local_timer** lt_h)
{
 int pid;
 struct local_timer* lt;
 lt=shm_malloc(sizeof(*lt));
 if (lt==0) goto error;
 if (init_local_timer(lt, get_ticks_raw())<0) goto error;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) goto error;
 *lt_h=lt;
 return pid;
error:
 if (lt) do { futex_get(mem_lock); qm_free(shm_block, (lt)); futex_release(mem_lock); }while(0);
 return -1;
}

canonical_original_code:
int fork_local_timer_process(int child_id, char *desc, int make_sock, struct local_timer **lt_h)
{
 int pid;
 struct local_timer *lt;
 lt=shm_malloc(sizeof(*lt));
 if (lt==0) goto error;
 if (init_local_timer(lt, get_ticks_raw())<0) goto error;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) goto error;
 *lt_h=lt;
 return pid;
error:
 if (lt) do { futex_get(mem_lock); qm_free(shm_block, (lt)); futex_release(mem_lock); }while(0);
 return -1;
}

variable_types: struct local_timer { unsigned int prev_ticks; struct timer_lists { struct timer_head { struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; } *next; struct timer_ln *prev; } h0[-1]; struct timer_head h1[-1]; struct timer_head h2[-1]; struct timer_head expired; } timer_lst; } **

user_defined_types: struct local_timer { unsigned int prev_ticks; struct timer_lists timer_lst; }

user_defined_types: struct timer_lists { struct timer_head h0[-1]; struct timer_head h1[-1]; struct timer_head h2[-1]; struct timer_head expired; }

user_defined_types: struct timer_head { struct timer_ln *next; struct timer_ln *prev; }


decompiled_code:
__int64 __fastcall register_sync_timers(unsigned int a1)
{
if ( (int)register_procs() < 0 )
return 0xFFFFFFFFLL;
cfg_register_child(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1)
{
if ( (int)register_procs() < 0 )
return 0xFFFFFFFFLL;
cfg_register_child(a1);
return 0LL;
}

original_code:
int register_sync_timers(int timers)
{
 if(register_procs(timers)<0)
  return -1;
 cfg_register_child(timers);
 return 0;
}


decompiled_code:
__int64 __fastcall fork_sync_timer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // edi
int v11; // ebx
unsigned int v12; // eax

result = fork_process(a1, a2, a3);
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v11 - get_ticks() )
{
if ( i )
sleep(i);
else
sleep(1u);
v11 = get_ticks();
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local(0);
v12 = get_ticks();
a4(v12, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // edi
int v11; // ebx
unsigned int v12; // eax

result = fork_process(a1, a2, a3);
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v11 - get_ticks() )
{
if ( i )
sleep(i);
else
sleep(1u);
v11 = get_ticks();
if ( cfg_ginst_count )
func5();
if ( *cfg_global != cfg_local )
func9(0);
v12 = get_ticks();
a4(v12, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int fork_sync_timer(int child_id, char* desc, int make_sock,
      timer_function* f, void* param, int interval)
{
 int pid;
 ticks_t ts1 = 0;
 ticks_t ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = interval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep(ts2);
   else sleep(1);
   ts1 = get_ticks();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
   ts2 = interval - get_ticks() + ts1;
  }
 }
 return pid;
}

canonical_original_code:
int fork_sync_timer(int child_id, char *desc, int make_sock, void (*f)(unsigned int ticks, void *param), void *param, int interval)
{
 int pid;
 unsigned int ts1 = 0;
 unsigned int ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = interval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep(ts2);
   else sleep(1);
   ts1 = get_ticks();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
   ts2 = interval - get_ticks() + ts1;
  }
 }
 return pid;
}


decompiled_code:
__int64 __fastcall fork_sync_utimer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // ebx
int v11; // ebx

result = fork_process(a1, a2, a3);
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v11 - get_ticks_raw() )
{
if ( i )
sleep_us(a6);
else
sleep_us(1u);
v11 = get_ticks_raw();
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local(0);
a4((unsigned int)(1000 * v11) >> 4, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // ebx
int v11; // ebx

result = fork_process(a1, a2, a3);
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
if ( !(_DWORD)result )
{
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v11 - get_ticks_raw() )
{
if ( i )
func10(a6);
else
func10(1u);
v11 = get_ticks_raw();
if ( cfg_ginst_count )
func5();
if ( *cfg_global != cfg_local )
func9(0);
a4((unsigned int)(1000 * v11) >> 4, a5);
}
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int fork_sync_utimer(int child_id, char* desc, int make_sock,
      utimer_function* f, void* param, int uinterval)
{
 int pid;
 ticks_t ts1 = 0;
 ticks_t ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = uinterval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep_us(uinterval);
   else sleep_us(1);
   ts1 = get_ticks_raw();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f((((ts1)*1000U)/16U), param);
   ts2 = uinterval - get_ticks_raw() + ts1;
  }
 }
 return pid;
}

canonical_original_code:
int fork_sync_utimer(int child_id, char *desc, int make_sock, void (*f)(unsigned int uticks, void *param), void *param, int uinterval)
{
 int pid;
 unsigned int ts1 = 0;
 unsigned int ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = uinterval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep_us(uinterval);
   else sleep_us(1);
   ts1 = get_ticks_raw();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f((((ts1)*1000U)/16U), param);
   ts2 = uinterval - get_ticks_raw() + ts1;
  }
 }
 return pid;
}


decompiled_code:
__int64 init_pkg_mallocs()
{
size_t v0; // rbx
void *v1; // rdi
const char *v3; // rbx
unsigned int v4; // eax

if ( !pkg_mem_size )
pkg_mem_size = 0x400000LL;
v0 = pkg_mem_size;
v1 = malloc(pkg_mem_size);
mem_pool = v1;
if ( v1 )
mem_block = qm_malloc_init(v1, v0);
if ( mem_block )
return 0LL;
if ( (int)get_debug_level("core", 4LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 6);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): could not initialize memory pool\n",
process_no,
v4,
v3,
"<core> [mem/mem.c:88]: ",
"init_pkg_mallocs");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): could not initialize memory pool\n",
*((const char **)&log_level_info + 6),
"<core> [mem/mem.c:88]: ",
"init_pkg_mallocs");
}
--dprint_crit;
}
fprintf(stderr, "Too much pkg memory demanded: %ld bytes\n", pkg_mem_size);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func0()
{
size_t v0; // rbx
void *v1; // rdi
const char *v3; // rbx
unsigned int v4; // eax

if ( !pkg_mem_size )
pkg_mem_size = 0x400000LL;
v0 = pkg_mem_size;
v1 = malloc(pkg_mem_size);
mem_pool = v1;
if ( v1 )
mem_block = qm_malloc_init(v1, v0);
if ( mem_block )
return 0LL;
if ( (int)get_debug_level("core", 4LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 6);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): could not initialize memory pool\n",
process_no,
v4,
v3,
"<core> [mem/mem.c:88]: ",
"init_pkg_mallocs");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): could not initialize memory pool\n",
*((const char **)&log_level_info + 6),
"<core> [mem/mem.c:88]: ",
"init_pkg_mallocs");
}
--dprint_crit;
}
fprintf(stderr, "Too much pkg memory demanded: %ld bytes\n", pkg_mem_size);
return 0xFFFFFFFFLL;
}

original_code:
int init_pkg_mallocs(void)
{
  if (pkg_mem_size == 0)
   pkg_mem_size = 4*1024*1024;
  mem_pool = malloc(pkg_mem_size);
  if (mem_pool)
   mem_block=qm_malloc_init(mem_pool, pkg_mem_size);
 if (mem_block==0){
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "could not initialize memory pool\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "could not initialize memory pool\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "could not initialize memory pool\n", process_no, my_pid(), ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "could not initialize memory pool\n", ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "could not initialize memory pool\n", ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  fprintf(stderr, "Too much pkg memory demanded: %ld bytes\n",
      pkg_mem_size);
  return -1;
 }
 return 0;
}

canonical_original_code:
int init_pkg_mallocs()
{
  if (pkg_mem_size == 0)
   pkg_mem_size = 4*1024*1024;
  mem_pool = malloc(pkg_mem_size);
  if (mem_pool)
   mem_block=qm_malloc_init(mem_pool, pkg_mem_size);
 if (mem_block==0){
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "could not initialize memory pool\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "could not initialize memory pool\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "could not initialize memory pool\n", process_no, my_pid(), ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "could not initialize memory pool\n", ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "could not initialize memory pool\n", ("<core> [" "mem/mem.c" ":" "88" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  fprintf(stderr, "Too much pkg memory demanded: %ld bytes\n",
      pkg_mem_size);
  return -1;
 }
 return 0;
}

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:
void destroy_pkg_mallocs()
{
if ( mem_pool )
{
free(mem_pool);
mem_pool = 0LL;
}
}

canonical_decompiled_code:
void func1()
{
if ( mem_pool )
{
free(mem_pool);
mem_pool = 0LL;
}
}

original_code:
void destroy_pkg_mallocs(void)
{
  if (mem_pool) {
   free(mem_pool);
   mem_pool = 0;
  }
}

canonical_original_code:
void destroy_pkg_mallocs()
{
  if (mem_pool) {
   free(mem_pool);
   mem_pool = 0;
  }
}


decompiled_code:
__int64 init_shm_mallocs()
{
const char *v1; // rbx
unsigned int v2; // eax

if ( (int)shm_mem_init() >= 0 )
return 0LL;
if ( (int)get_debug_level("core", 4LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 6);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): could not initialize shared memory pool, exiting...\n",
process_no,
v2,
v1,
"<core> [mem/mem.c:125]: ",
"init_shm_mallocs");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): could not initialize shared memory pool, exiting...\n",
*((const char **)&log_level_info + 6),
"<core> [mem/mem.c:125]: ",
"init_shm_mallocs");
}
--dprint_crit;
}
fprintf(stderr, "Too much shared memory demanded: %ld\n", shm_mem_size);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func2()
{
const char *v1; // rbx
unsigned int v2; // eax

if ( (int)shm_mem_init() >= 0 )
return 0LL;
if ( (int)get_debug_level("core", 4LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 6);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): could not initialize shared memory pool, exiting...\n",
process_no,
v2,
v1,
"<core> [mem/mem.c:125]: ",
"init_shm_mallocs");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): could not initialize shared memory pool, exiting...\n",
*((const char **)&log_level_info + 6),
"<core> [mem/mem.c:125]: ",
"init_shm_mallocs");
}
--dprint_crit;
}
fprintf(stderr, "Too much shared memory demanded: %ld\n", shm_mem_size);
return 0xFFFFFFFFLL;
}

original_code:
int init_shm_mallocs(int force_alloc)
{
 if (shm_mem_init(force_alloc)<0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "could not initialize shared memory pool, exiting...\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "mem/mem.c" ":" "125" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "could not initialize shared memory pool, exiting...\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "mem/mem.c" ":" "125" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "could not initialize shared memory pool, exiting...\n", process_no, my_pid(), ("<core> [" "mem/mem.c" ":" "125" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "could not initialize shared memory pool, exiting...\n", ("<core> [" "mem/mem.c" ":" "125" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "could not initialize shared memory pool, exiting...\n", ("<core> [" "mem/mem.c" ":" "125" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   fprintf(stderr, "Too much shared memory demanded: %ld\n",
   shm_mem_size );
  return -1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall ws_close_fixup(__int64 a1, int a2)
{
__int64 result; // rax

if ( a2 == 2 )
return fixup_spve_null(a1, 1LL);
result = 0LL;
if ( (a2 & 0xFFFFFFFD) == 1 )
result = fixup_var_int_1();
return result;
}

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

if ( a2 == 2 )
return fixup_spve_null(a1, 1LL);
result = 0LL;
if ( (a2 & 0xFFFFFFFD) == 1 )
result = fixup_var_int_1();
return result;
}

original_code:
static int ws_close_fixup(void** param, int param_no)
{
 switch(param_no) {
 case 1:
 case 3:
  return fixup_var_int_1(param, 1);
 case 2:
  return fixup_spve_null(param, 1);
 default:
  return 0;
 }
}

canonical_original_code:
static int ws_close_fixup(void **param, int param_no)
{
 switch(param_no) {
 case 1:
 case 3:
  return fixup_var_int_1(param, 1);
 case 2:
  return fixup_spve_null(param, 1);
 default:
  return 0;
 }
}

variable_types:
param
void **


decompiled_code:
__int64 __fastcall child_init(int a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // edx
const char *v4; // r12
unsigned int v5; // eax

result = 0LL;
if ( !a1 )
{
result = ws_keepalive_mechanism;
if ( ws_keepalive_mechanism )
{
if ( ws_keepalive_processes <= 0 )
{
result = 0LL;
}
else
{
v2 = 0;
while ( (int)fork_sync_timer(
0xFFFFFFFFLL,
"WEBSOCKET KEEPALIVE",
1LL,
&ws_keepalive,
0LL,
(unsigned int)ws_keepalive_interval) >= 0 )
{
if ( ++v2 >= ws_keepalive_processes )
return 0LL;
}
v3 = get_debug_level("websocket", 9LL);
result = 0xFFFFFFFFLL;
if ( v3 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): starting keepalive process\n",
process_no,
v5,
v4,
"websocket [ws_mod.c:313]: ",
"child_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): starting keepalive process\n",
*((const char **)&log_level_info + 8),
"websocket [ws_mod.c:313]: ",
"child_init");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // edx
const char *v4; // r12
unsigned int v5; // eax

result = 0LL;
if ( !a1 )
{
result = ws_keepalive_mechanism;
if ( ws_keepalive_mechanism )
{
if ( ws_keepalive_processes <= 0 )
{
result = 0LL;
}
else
{
v2 = 0;
while ( (int)fork_sync_timer(
0xFFFFFFFFLL,
"WEBSOCKET KEEPALIVE",
1LL,
&ws_keepalive,
0LL,
(unsigned int)ws_keepalive_interval) >= 0 )
{
if ( ++v2 >= ws_keepalive_processes )
return 0LL;
}
v3 = get_debug_level("websocket", 9LL);
result = 0xFFFFFFFFLL;
if ( v3 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): starting keepalive process\n",
process_no,
v5,
v4,
"websocket [ws_mod.c:313]: ",
"child_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): starting keepalive process\n",
*((const char **)&log_level_info + 8),
"websocket [ws_mod.c:313]: ",
"child_init");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
}
}
return result;
}

original_code:
static int child_init(int rank)
{
 int i;
 if (rank == -127 || rank == -4)
  return 0;
 if (rank == 0
  && ws_keepalive_mechanism != KEEPALIVE_MECHANISM_NONE)
 {
  for (i = 0; i < ws_keepalive_processes; i++)
  {
   if (fork_sync_timer(-1, "WEBSOCKET KEEPALIVE",
      1, ws_keepalive, ((void *)0),
      ws_keepalive_interval) < 0)
   {
    do { if (get_debug_level("websocket", (sizeof("websocket")-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(): " "starting keepalive process\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("websocket" " [" "ws_mod.c" ":" "313" "]: ") , __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(): " "starting keepalive process\n", (log_level_info[((-1)) - (-5)].name), ("websocket" " [" "ws_mod.c" ":" "313" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "starting keepalive process\n", process_no, my_pid(), ("websocket" " [" "ws_mod.c" ":" "313" "]: ") , __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(): " "starting keepalive process\n", ("websocket" " [" "ws_mod.c" ":" "313" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "starting keepalive process\n", ("websocket" " [" "ws_mod.c" ":" "313" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    return -1;
   }
  }
 }
 return 0;
}

variable_types: rank int


destroy

decompiled_code:
__int64 destroy()
{
return wsconn_destroy();
}

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

original_code:
static void destroy(void)
{
 wsconn_destroy();
}

canonical_original_code:
static void destroy()
{
 wsconn_destroy();
}