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

if ( (int)get_debug_level("dnssec", 6LL) > 1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(2LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 14);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DNSSEC - initializing\n",
process_no,
v2,
v1,
"dnssec [dnssec_mod.c:108]: ",
"dnssec_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 30) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DNSSEC - initializing\n",
*((const char **)&log_level_info + 14),
"dnssec [dnssec_mod.c:108]: ",
"dnssec_init");
}
--dprint_crit;
}
if ( flags )
set_context_flags();
if ( (unsigned int)load_dns() && (int)get_debug_level("dnssec", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): loaded dnssec wrappers failed\n",
process_no,
v4,
v3,
"dnssec [dnssec_mod.c:121]: ",
"dnssec_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): loaded dnssec wrappers failed\n",
*((const char **)&log_level_info + 8),
"dnssec [dnssec_mod.c:121]: ",
"dnssec_init");
}
--dprint_crit;
}
return 0LL;
}

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

if ( (int)get_debug_level("dnssec", 6LL) > 1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(2LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 14);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DNSSEC - initializing\n",
process_no,
v2,
v1,
"dnssec [dnssec_mod.c:108]: ",
"dnssec_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 30) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DNSSEC - initializing\n",
*((const char **)&log_level_info + 14),
"dnssec [dnssec_mod.c:108]: ",
"dnssec_init");
}
--dprint_crit;
}
if ( flags )
set_context_flags();
if ( (unsigned int)func1() && (int)get_debug_level("dnssec", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): loaded dnssec wrappers failed\n",
process_no,
v4,
v3,
"dnssec [dnssec_mod.c:121]: ",
"dnssec_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): loaded dnssec wrappers failed\n",
*((const char **)&log_level_info + 8),
"dnssec [dnssec_mod.c:121]: ",
"dnssec_init");
}
--dprint_crit;
}
return 0LL;
}

original_code:
static int dnssec_init(void)
{
 do { if (get_debug_level("dnssec", (sizeof("dnssec")-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(): " "DNSSEC  - initializing\n", process_no, my_pid(), (log_level_info[((2)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __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(): " "DNSSEC  - initializing\n", (log_level_info[((2)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DNSSEC  - initializing\n", process_no, my_pid(), ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __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(): " "DNSSEC  - initializing\n", ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DNSSEC  - initializing\n", ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 if(flags) set_context_flags(flags);
 if(load_dns() != 0) {
  do { if (get_debug_level("dnssec", (sizeof("dnssec")-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(): " "loaded dnssec wrappers failed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __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(): " "loaded dnssec wrappers failed\n", (log_level_info[((-1)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "loaded dnssec wrappers failed\n", process_no, my_pid(), ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __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(): " "loaded dnssec wrappers failed\n", ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "loaded dnssec wrappers failed\n", ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 return 0;
}

canonical_original_code:
static int dnssec_init()
{
 do { if (get_debug_level("dnssec", (sizeof("dnssec")-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(): " "DNSSEC  - initializing\n", process_no, my_pid(), (log_level_info[((2)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __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(): " "DNSSEC  - initializing\n", (log_level_info[((2)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DNSSEC  - initializing\n", process_no, my_pid(), ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __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(): " "DNSSEC  - initializing\n", ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DNSSEC  - initializing\n", ("dnssec" " [" "dnssec_mod.c" ":" "108" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 if(flags) set_context_flags(flags);
 if(load_dns() != 0) {
  do { if (get_debug_level("dnssec", (sizeof("dnssec")-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(): " "loaded dnssec wrappers failed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __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(): " "loaded dnssec wrappers failed\n", (log_level_info[((-1)) - (-5)].name), ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "loaded dnssec wrappers failed\n", process_no, my_pid(), ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __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(): " "loaded dnssec wrappers failed\n", ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "loaded dnssec wrappers failed\n", ("dnssec" " [" "dnssec_mod.c" ":" "121" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 return 0;
}


repo: virtualolson/who

decompiled_code:
__int64 __fastcall generic_fn(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
if ( a3 == -1 )
{
if ( a2 < a4 )
return 0xFFFFFFFFLL;
a3 = a2;
if ( a2 > a5 )
return 0xFFFFFFFFLL;
}
else
{
if ( a2 < a4 || a2 > a5 )
return 0xFFFFFFFFLL;
if ( a3 < a4 || a3 > a5 )
return 0xFFFFFFFFLL;
if ( a3 < a2 )
return (a1 >= a2) | (unsigned __int8)(a1 <= a3);
}
return (a1 <= a3) & (unsigned __int8)(a1 >= a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
if ( a3 == -1 )
{
if ( a2 < a4 )
return 0xFFFFFFFFLL;
a3 = a2;
if ( a2 > a5 )
return 0xFFFFFFFFLL;
}
else
{
if ( a2 < a4 || a2 > a5 )
return 0xFFFFFFFFLL;
if ( a3 < a4 || a3 > a5 )
return 0xFFFFFFFFLL;
if ( a3 < a2 )
return (a1 >= a2) | (unsigned __int8)(a1 <= a3);
}
return (a1 <= a3) & (unsigned __int8)(a1 >= a2);
}

original_code:
static int generic_fn(const int time_var, const long f, long t, const long min, const long max) {
 if (t == -1)
  t = f;
 if (f < min || f > max)
  return -1;
 if (t < min || t > max)
  return -1;
 if (f > t) {
  if (f <= time_var || t >= time_var)
   return 1;
 }
 else if (f <= time_var && time_var <= t)
  return 1;
 return 0;
}

canonical_original_code:
static int generic_fn(int time_var, long f, long t, long min, long max) {
 if (t == -1)
  t = f;
 if (f < min || f > max)
  return -1;
 if (t < min || t > max)
  return -1;
 if (f > t) {
  if (f <= time_var || t >= time_var)
   return 1;
 }
 else if (f <= time_var && time_var <= t)
  return 1;
 return 0;
}

variable_types: f long

variable_types: t long

variable_types: min long

variable_types: max long

return_type: int


decompiled_code:
__int64 __fastcall second_fn(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "second_fn", a1, a2, a3);
return generic_fn(a1, a2, a3, 0LL, 60LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "second_fn", a1, a2, a3);
return func0(a1, a2, a3, 0LL, 60LL);
}

original_code:
static int second_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 0, 60);
}

canonical_original_code:
static int second_fn(int time_var, char *from, char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 0, 60);
}

variable_types:
from
char *

variable_types:
to
char *


decompiled_code:
__int64 __fastcall minute_fn(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "minute_fn", a1, a2, a3);
return generic_fn(a1, a2, a3, 0LL, 59LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "minute_fn", a1, a2, a3);
return func0(a1, a2, a3, 0LL, 59LL);
}

original_code:
static int minute_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 0, 59);
}

canonical_original_code:
static int minute_fn(int time_var, char *from, char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 0, 59);
}


decompiled_code:
__int64 __fastcall hour_fn(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "hour_fn", a1, a2, a3);
return generic_fn(a1, a2, a3, 0LL, 23LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "hour_fn", a1, a2, a3);
return func0(a1, a2, a3, 0LL, 23LL);
}

original_code:
static int hour_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 0, 23);
}

canonical_original_code:
static int hour_fn(int time_var, char *from, char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 0, 23);
}


decompiled_code:
__int64 __fastcall yday_fn(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "yday_fn", a1, a2, a3);
return generic_fn(a1, a2, a3, 1LL, 366LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "yday_fn", a1, a2, a3);
return func0(a1, a2, a3, 1LL, 366LL);
}

original_code:
static int yday_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 1, 366);
}

canonical_original_code:
static int yday_fn(int time_var, char *from, char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 1, 366);
}


decompiled_code:
__int64 __fastcall mday_fn(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "mday_fn", a1, a2, a3);
return generic_fn(a1, a2, a3, 1LL, 31LL);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "mday_fn", a1, a2, a3);
return func0(a1, a2, a3, 1LL, 31LL);
}

original_code:
static int mday_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 1, 31);
}

canonical_original_code:
static int mday_fn(int time_var, char *from, char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 1, 31);
}


decompiled_code:
__int64 __fastcall week_fn(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "week_fn", a1, a2, a3);
return generic_fn(a1, a2, a3, 1LL, 6LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, __int64 a2, __int64 a3)
{
printf("%s %i %li %li\n", "week_fn", a1, a2, a3);
return func0(a1, a2, a3, 1LL, 6LL);
}

original_code:
static int week_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 1, 6);
}

canonical_original_code:
static int week_fn(int time_var, char *from, char *to) {
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 return generic_fn(time_var, (long) from, (long) to, 1, 6);
}


original_code:
static int year_fn(const int time_var, const char *from, const char *to) {
 long f, t, c;
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 f = (long) from;
 t = (long) to;
 if (t == -1)
  t = f;
 c = time_var / 100;
 if (t < 0)
  return -1;
 else if (t <= 99)
  t += c;
 else if (t < 1970)
  return -1;
 if (f < 0)
  return -1;
 else if (f <= 99)
  f += c;
 else if (f < 1970)
  return -1;
 if (time_var >= f && time_var <= t)
  return 1;
 return 0;
}

canonical_original_code:
static int year_fn(int time_var, char *from, char *to) {
 long f; long t; long c;
 printf("%s %i %li %li\n", __FUNCTION__, time_var, (long) from, (long) to);
 f = (long) from;
 t = (long) to;
 if (t == -1)
  t = f;
 c = time_var / 100;
 if (t < 0)
  return -1;
 else if (t <= 99)
  t += c;
 else if (t < 1970)
  return -1;
 if (f < 0)
  return -1;
 else if (f <= 99)
  f += c;
 else if (f < 1970)
  return -1;
 if (time_var >= f && time_var <= t)
  return 1;
 return 0;
}

variable_types: c long


decompiled_code:
__int64 __fastcall wday_fn(unsigned int a1, const char *a2, const char *a3)
{
printf("%s %i '%s' '%s'\n", "wday_fn", a1, a2, a3);
return generic_named_fn(a1, a2, a3, (const char **)weekdays, 7, 2);
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, const char *a2, const char *a3)
{
printf("%s %i '%s' '%s'\n", "wday_fn", a1, a2, a3);
return func8(a1, a2, a3, (const char **)weekdays, 7, 2);
}

original_code:
static int wday_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i '%s' '%s'\n", __FUNCTION__, time_var, from, to);
 return generic_named_fn(time_var, from, to, weekdays, 7, 2);
}

canonical_original_code:
static int wday_fn(int time_var, char *from, char *to) {
 printf("%s %i '%s' '%s'\n", __FUNCTION__, time_var, from, to);
 return generic_named_fn(time_var, from, to, weekdays, 7, 2);
}


decompiled_code:
__int64 __fastcall month_fn(unsigned int a1, const char *a2, const char *a3)
{
printf("%s %i '%s' '%s'\n", "month_fn", a1, a2, a3);
return generic_named_fn(a1, a2, a3, (const char **)months, 12, 3);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, const char *a2, const char *a3)
{
printf("%s %i '%s' '%s'\n", "month_fn", a1, a2, a3);
return func8(a1, a2, a3, (const char **)months, 12, 3);
}

original_code:
static int month_fn(const int time_var, const char *from, const char *to) {
 printf("%s %i '%s' '%s'\n", __FUNCTION__, time_var, from, to);
 return generic_named_fn(time_var, from, to, months, 12, 3);
}

canonical_original_code:
static int month_fn(int time_var, char *from, char *to) {
 printf("%s %i '%s' '%s'\n", __FUNCTION__, time_var, from, to);
 return generic_named_fn(time_var, from, to, months, 12, 3);
}


decompiled_code:
__int64 __fastcall get_time_vars(_DWORD *a1, time_t a2)
{
int v2; // ecx
int v3; // er8
int v4; // edx
__int64 result; // rax
time_t timer; // [rsp+8h] [rbp-50h] BYREF
struct tm tp; // [rsp+10h] [rbp-48h] BYREF

timer = a2;
localtime_r(&timer, &tp);
*a1 = tp.tm_year + 1900;
a1[1] = tp.tm_mon + 1;
v2 = tp.tm_mday;
v3 = tp.tm_wday;
v4 = tp.tm_mday + (tp.tm_wday - tp.tm_mday + 1) % 7 - 1;
result = v4;
a1[2] = v4 / 7 + 1;
a1[3] = v2;
a1[4] = v3 + 1;
a1[5] = tp.tm_yday + 1;
a1[6] = tp.tm_hour;
a1[7] = tp.tm_min;
a1[8] = tp.tm_sec;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_DWORD *a1, time_t a2)
{
int v2; // ecx
int v3; // er8
int v4; // edx
__int64 result; // rax
time_t timer; // [rsp+8h] [rbp-50h] BYREF
struct tm tp; // [rsp+10h] [rbp-48h] BYREF

timer = a2;
localtime_r(&timer, &tp);
*a1 = tp.tm_year + 1900;
a1[1] = tp.tm_mon + 1;
v2 = tp.tm_mday;
v3 = tp.tm_wday;
v4 = tp.tm_mday + (tp.tm_wday - tp.tm_mday + 1) % 7 - 1;
result = v4;
a1[2] = v4 / 7 + 1;
a1[3] = v2;
a1[4] = v3 + 1;
a1[5] = tp.tm_yday + 1;
a1[6] = tp.tm_hour;
a1[7] = tp.tm_min;
a1[8] = tp.tm_sec;
return result;
}

original_code:
static void get_time_vars(int time_vars[SCALE_MAX], time_t t) {
 struct tm tm;
 localtime_r(&t, &tm);
 time_vars[SCALE_YEAR] = tm.tm_year + 1900;
 time_vars[SCALE_MONTH] = tm.tm_mon + 1;
 time_vars[SCALE_WEEK] = (tm.tm_mday - 1 + (tm.tm_wday - tm.tm_mday + 1) % 7) / 7 + 1;
 time_vars[SCALE_MDAY] = tm.tm_mday;
 time_vars[SCALE_WDAY] = tm.tm_wday + 1;
 time_vars[SCALE_YDAY] = tm.tm_yday + 1;
 time_vars[SCALE_HOUR] = tm.tm_hour;
 time_vars[SCALE_MINUTE] = tm.tm_min;
 time_vars[SCALE_SECOND] = tm.tm_sec;
}

canonical_original_code:
static void get_time_vars(int time_vars[-1], long t) {
 struct tm tm;
 localtime_r(&t, &tm);
 time_vars[SCALE_YEAR] = tm.tm_year + 1900;
 time_vars[SCALE_MONTH] = tm.tm_mon + 1;
 time_vars[SCALE_WEEK] = (tm.tm_mday - 1 + (tm.tm_wday - tm.tm_mday + 1) % 7) / 7 + 1;
 time_vars[SCALE_MDAY] = tm.tm_mday;
 time_vars[SCALE_WDAY] = tm.tm_wday + 1;
 time_vars[SCALE_YDAY] = tm.tm_yday + 1;
 time_vars[SCALE_HOUR] = tm.tm_hour;
 time_vars[SCALE_MINUTE] = tm.tm_min;
 time_vars[SCALE_SECOND] = tm.tm_sec;
}

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }

return_type: void


original_code:
int in_period(time_t t, const char *p) {
 int time_vars[SCALE_MAX];
 int scale_results[SCALE_MAX];
 int scale, j, len, res;
 const char *c, *a1, *a2;
 char from[16], to[16], *str;
 if (!p)
  return 1;
 while (*p == ' ') p++;;
 if (!*p)
  return 1;
 if (!strcasecmp(p, "none") || !strcasecmp(p, "never"))
  return 0;
 get_time_vars(time_vars, t);
 while (1) {
  memset(scale_results, -1, sizeof(scale_results));
  while (1) {
   for (scale = 0; scale < SCALE_MAX; scale++) {
    for (j = 0; j < 2; j++) {
     c = defs[scale].codes[j];
     len = strlen(c);
     if (strncasecmp(p, c, len))
      continue;
     if (p[len] == ' ' || p[len] == '{')
      goto found_scale;
    }
   }
   return -1;
found_scale:
   p += len;
   while (*p == ' ') p++;;
   if (*p != '{')
    return -1;
   p++;
   while (*p == ' ') p++;;
   if (scale_results[scale] == -1)
    scale_results[scale] = 0;
   else if (scale_results[scale] == 1) {
    while (*p && *p != '}')
     p++;
    if (!*p)
     return -1;
    goto close_brace;
   }
   while (1) {
    str = from;
    len = sizeof(from) - 1;
    *from = *to = '\0';
    while (1) {
     switch (*p) {
      case '\0':
       return -1;
      case ' ':
       while (*p == ' ') p++;;
       if (*p == '-')
        goto hyphen;
       break;
      case '-':
hyphen:
       if (!*from)
        return -1;
       if (*to)
        return -1;
       *str = '\0';
       str = to;
       len = sizeof(to) - 1;
       p++;
       while (*p == ' ') p++;;
       continue;
      case '}':
       break;
      default:
       if (len <= 0)
        return -1;
       *str++ = *p++ | 0x20;
       len--;
       continue;
     }
     break;
    }
    *str = '\0';
    if (!*from) {
     if (*p == '}')
      break;
     continue;
    }
    a1 = from;
    a2 = *to ? to : ((void *)0);
    if ((defs[scale].flags & 0x1)) {
     a1 = (void *) atol(a1);
     a2 = (void *) (a2 ? atol(a2) : -1);
    }
    res = defs[scale].func(time_vars[scale], a1, a2);
    printf("result: %i\n", res);
    if (res == -1)
     return -1;
    else if (res == 1)
     scale_results[scale] = 1;
   }
close_brace:
   p++;
   while (*p == ' ') p++;;
   if (!*p || *p == ',') {
    for (scale = 0; scale < SCALE_MAX; scale++) {
     if (scale_results[scale] == 0)
      goto no_match;
    }
    return 1;
no_match:
    if (*p == ',') {
     p++;
     while (*p == ' ') p++;;
     break;
    }
    return 0;
   }
   continue;
  }
 }
}

canonical_original_code:
int in_period(long t, char *p) {
 int time_vars[-1];
 int scale_results[-1];
 int scale; int j; int len; int res;
 char *c; char *a1; char *a2;
 char from[16]; char to[16]; char *str;
 if (!p)
  return 1;
 while (*p == ' ') p++;;
 if (!*p)
  return 1;
 if (!strcasecmp(p, "none") || !strcasecmp(p, "never"))
  return 0;
 get_time_vars(time_vars, t);
 while (1) {
  memset(scale_results, -1, sizeof(scale_results));
  while (1) {
   for (scale = 0; scale < SCALE_MAX; scale++) {
    for (j = 0; j < 2; j++) {
     c = defs[scale].codes[j];
     len = strlen(c);
     if (strncasecmp(p, c, len))
      continue;
     if (p[len] == ' ' || p[len] == '{')
      goto found_scale;
    }
   }
   return -1;
found_scale:
   p += len;
   while (*p == ' ') p++;;
   if (*p != '{')
    return -1;
   p++;
   while (*p == ' ') p++;;
   if (scale_results[scale] == -1)
    scale_results[scale] = 0;
   else if (scale_results[scale] == 1) {
    while (*p && *p != '}')
     p++;
    if (!*p)
     return -1;
    goto close_brace;
   }
   while (1) {
    str = from;
    len = sizeof(from) - 1;
    *from = *to = '\0';
    while (1) {
     switch (*p) {
      case '\0':
       return -1;
      case ' ':
       while (*p == ' ') p++;;
       if (*p == '-')
        goto hyphen;
       break;
      case '-':
hyphen:
       if (!*from)
        return -1;
       if (*to)
        return -1;
       *str = '\0';
       str = to;
       len = sizeof(to) - 1;
       p++;
       while (*p == ' ') p++;;
       continue;
      case '}':
       break;
      default:
       if (len <= 0)
        return -1;
       *str++ = *p++ | 0x20;
       len--;
       continue;
     }
     break;
    }
    *str = '\0';
    if (!*from) {
     if (*p == '}')
      break;
     continue;
    }
    a1 = from;
    a2 = *to ? to : ((void *)0);
    if ((defs[scale].flags & 0x1)) {
     a1 = (void *) atol(a1);
     a2 = (void *) (a2 ? atol(a2) : -1);
    }
    res = defs[scale].func(time_vars[scale], a1, a2);
    printf("result: %i\n", res);
    if (res == -1)
     return -1;
    else if (res == 1)
     scale_results[scale] = 1;
   }
close_brace:
   p++;
   while (*p == ' ') p++;;
   if (!*p || *p == ',') {
    for (scale = 0; scale < SCALE_MAX; scale++) {
     if (scale_results[scale] == 0)
      goto no_match;
    }
    return 1;
no_match:
    if (*p == ',') {
     p++;
     while (*p == ' ') p++;;
     break;
    }
    return 0;
   }
   continue;
  }
 }
}

variable_types:
p
char *

variable_types: scale int

variable_types: j int

variable_types: len int

variable_types: res int

variable_types:
c
char *

variable_types:
from
char [16]

variable_types:
to
char [16]

variable_types:
str
char *


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

result = udp_listen;
if ( !udp_listen )
{
result = tcp_listen;
if ( !tcp_listen )
result = tls_listen;
}
return result;
}

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

result = udp_listen;
if ( !udp_listen )
{
result = tcp_listen;
if ( !tcp_listen )
result = tls_listen;
}
return result;
}

original_code:
inline static struct socket_info* get_first_socket(void)
{
 if (udp_listen) return udp_listen;
 else if (tcp_listen) return tcp_listen;
 else if (tls_listen) return tls_listen;
 return 0;
}

canonical_original_code:
inline static struct socket_info *get_first_socket()
{
 if (udp_listen) return udp_listen;
 else if (tcp_listen) return tcp_listen;
 else if (tls_listen) return tls_listen;
 return 0;
}

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

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


decompiled_code:
__int64 __fastcall inc_hexchar(char *a1)
{
char v1; // al
__int64 result; // rax

v1 = *a1;
if ( *a1 == 57 )
{
*a1 = 97;
result = 0LL;
}
else if ( v1 == 102 )
{
*a1 = 48;
result = 1LL;
}
else
{
*a1 = v1 + 1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1)
{
char v1; // al
__int64 result; // rax

v1 = *a1;
if ( *a1 == 57 )
{
*a1 = 97;
result = 0LL;
}
else if ( v1 == 102 )
{
*a1 = 48;
result = 1LL;
}
else
{
*a1 = v1 + 1;
result = 0LL;
}
return result;
}

original_code:
static inline int inc_hexchar(char* _c)
{
 if (*_c == '9') {
  *_c = 'a';
  return 0;
 }
 if (*_c == 'f') {
  *_c = '0';
  return 1;
 }
 (*_c)++;
 return 0;
}

canonical_original_code:
static inline int inc_hexchar(char *_c)
{
 if (*_c == '9') {
  *_c = 'a';
  return 0;
 }
 if (*_c == 'f') {
  *_c = '0';
  return 1;
 }
 (*_c)++;
 return 0;
}


decompiled_code:
__int64 init_callid()
{
int i; // edx
int v1; // ebp
__int64 v2; // rbx
__int64 v3; // rax
unsigned int v4; // ebx
const char *v6; // rbx
unsigned int v7; // eax
const char *v8; // r13
int v9; // er12
const char *v10; // rbp
unsigned int v11; // eax

dword_9F8 = 16;
callid_prefix = (__int64)callid_buf;
for ( i = 2; i != 32; i += 10 )
;
callid_nr = rand();
v1 = 2;
do
{
v2 = callid_nr << 32;
v3 = v2 | rand();
callid_nr = v3;
--v1;
}
while ( v1 );
snprintf(callid_buf, 0x11uLL, "%0*lx", 16, v3);
if ( dword_9F8 <= 15 )
{
v4 = -2;
if ( (int)get_debug_level("tm", 2LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 6);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG: SORRY, callid calculation failed\n",
process_no,
v7,
v6,
"tm [callid.c:101]: ",
"init_callid");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG: SORRY, callid calculation failed\n",
*((const char **)&log_level_info + 6),
"tm [callid.c:101]: ",
"init_callid");
}
--dprint_crit;
v4 = -2;
}
}
else
{
v4 = 0;
if ( (int)get_debug_level("tm", 2LL) > 2 )
{
v4 = dprint_crit;
if ( dprint_crit )
{
v4 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v8 = (const char *)callid_prefix;
v9 = dword_9F8;
v10 = (const char *)*((_QWORD *)&log_level_info + 16);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Call-ID initialization: '%.*s'\n",
process_no,
v11,
v10,
"tm [callid.c:105]: ",
"init_callid",
v9,
v8);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Call-ID initialization: '%.*s'\n",
*((_QWORD *)&log_level_info + 16),
"tm [callid.c:105]: ",
"init_callid",
(unsigned int)dword_9F8,
callid_prefix);
}
--dprint_crit;
}
}
}
return v4;
}

canonical_decompiled_code:
__int64 func2()
{
int i; // edx
int v1; // ebp
__int64 v2; // rbx
__int64 v3; // rax
unsigned int v4; // ebx
const char *v6; // rbx
unsigned int v7; // eax
const char *v8; // r13
int v9; // er12
const char *v10; // rbp
unsigned int v11; // eax

dword_9F8 = 16;
callid_prefix = (__int64)callid_buf;
for ( i = 2; i != 32; i += 10 )
;
callid_nr = rand();
v1 = 2;
do
{
v2 = callid_nr << 32;
v3 = v2 | rand();
callid_nr = v3;
--v1;
}
while ( v1 );
snprintf(callid_buf, 0x11uLL, "%0*lx", 16, v3);
if ( dword_9F8 <= 15 )
{
v4 = -2;
if ( (int)get_debug_level("tm", 2LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 6);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG: SORRY, callid calculation failed\n",
process_no,
v7,
v6,
"tm [callid.c:101]: ",
"init_callid");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG: SORRY, callid calculation failed\n",
*((const char **)&log_level_info + 6),
"tm [callid.c:101]: ",
"init_callid");
}
--dprint_crit;
v4 = -2;
}
}
else
{
v4 = 0;
if ( (int)get_debug_level("tm", 2LL) > 2 )
{
v4 = dprint_crit;
if ( dprint_crit )
{
v4 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v8 = (const char *)callid_prefix;
v9 = dword_9F8;
v10 = (const char *)*((_QWORD *)&log_level_info + 16);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Call-ID initialization: '%.*s'\n",
process_no,
v11,
v10,
"tm [callid.c:105]: ",
"init_callid",
v9,
v8);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Call-ID initialization: '%.*s'\n",
*((_QWORD *)&log_level_info + 16),
"tm [callid.c:105]: ",
"init_callid",
(unsigned int)dword_9F8,
callid_prefix);
}
--dprint_crit;
}
}
}
return v4;
}

original_code:
int init_callid(void)
{
 int rand_bits, i;
 callid_prefix.len = sizeof(unsigned long) * 2;
 callid_prefix.s = callid_buf;
 if (callid_prefix.len > 20) {
  do { if (get_debug_level("tm", (sizeof("tm")-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: Too small callid buffer\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: Too small callid buffer\n", (log_level_info[((-1)) - (-5)].name), ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: Too small callid buffer\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: Too small callid buffer\n", ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: Too small callid buffer\n", ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 for(rand_bits = 1, i = 2147483647; i; i >>= 1, rand_bits++);
 i = callid_prefix.len * 4 / rand_bits;
        callid_nr = rand();
 while(i--) {
  callid_nr <<= rand_bits;
  callid_nr |= rand();
 }
 i = snprintf(callid_prefix.s, callid_prefix.len + 1, "%0*lx", callid_prefix.len, callid_nr);
 if ((i == -1) || (i > callid_prefix.len)) {
  do { if (get_debug_level("tm", (sizeof("tm")-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(): " "BUG: SORRY, callid calculation failed\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("tm" " [" "callid.c" ":" "101" "]: ") , __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(): " "BUG: SORRY, callid calculation failed\n", (log_level_info[((-2)) - (-5)].name), ("tm" " [" "callid.c" ":" "101" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "BUG: SORRY, callid calculation failed\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "101" "]: ") , __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(): " "BUG: SORRY, callid calculation failed\n", ("tm" " [" "callid.c" ":" "101" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG: SORRY, callid calculation failed\n", ("tm" " [" "callid.c" ":" "101" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 do { if (get_debug_level("tm", (sizeof("tm")-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(): " "Call-ID initialization: '%.*s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); 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(): " "Call-ID initialization: '%.*s'\n", (log_level_info[((3)) - (-5)].name), ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Call-ID initialization: '%.*s'\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); 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(): " "Call-ID initialization: '%.*s'\n", ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Call-ID initialization: '%.*s'\n", ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); } } (dprint_crit--); } } while(0);
 return 0;
}

canonical_original_code:
int init_callid()
{
 int rand_bits; int i;
 callid_prefix.len = sizeof(unsigned long) * 2;
 callid_prefix.s = callid_buf;
 if (callid_prefix.len > 20) {
  do { if (get_debug_level("tm", (sizeof("tm")-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: Too small callid buffer\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: Too small callid buffer\n", (log_level_info[((-1)) - (-5)].name), ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: Too small callid buffer\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: Too small callid buffer\n", ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: Too small callid buffer\n", ("tm" " [" "callid.c" ":" "83" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 for(rand_bits = 1, i = 2147483647; i; i >>= 1, rand_bits++);
 i = callid_prefix.len * 4 / rand_bits;
        callid_nr = rand();
 while(i--) {
  callid_nr <<= rand_bits;
  callid_nr |= rand();
 }
 i = snprintf(callid_prefix.s, callid_prefix.len + 1, "%0*lx", callid_prefix.len, callid_nr);
 if ((i == -1) || (i > callid_prefix.len)) {
  do { if (get_debug_level("tm", (sizeof("tm")-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(): " "BUG: SORRY, callid calculation failed\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("tm" " [" "callid.c" ":" "101" "]: ") , __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(): " "BUG: SORRY, callid calculation failed\n", (log_level_info[((-2)) - (-5)].name), ("tm" " [" "callid.c" ":" "101" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "BUG: SORRY, callid calculation failed\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "101" "]: ") , __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(): " "BUG: SORRY, callid calculation failed\n", ("tm" " [" "callid.c" ":" "101" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG: SORRY, callid calculation failed\n", ("tm" " [" "callid.c" ":" "101" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 do { if (get_debug_level("tm", (sizeof("tm")-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(): " "Call-ID initialization: '%.*s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); 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(): " "Call-ID initialization: '%.*s'\n", (log_level_info[((3)) - (-5)].name), ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Call-ID initialization: '%.*s'\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); 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(): " "Call-ID initialization: '%.*s'\n", ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Call-ID initialization: '%.*s'\n", ("tm" " [" "callid.c" ":" "105" "]: ") , __func__, callid_prefix.len, callid_prefix.s); } } (dprint_crit--); } } while(0);
 return 0;
}

variable_types: i 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 child_init_callid()
{
__int64 v0; // rax
const char *v1; // rbp
int v2; // ebx
unsigned int v3; // eax
int v4; // eax
unsigned int v5; // ebx
const char *v6; // r13
unsigned int v7; // eax
const char *v8; // rbx
unsigned int v9; // eax
const char *v10; // r13
int v11; // ebp
const char *v12; // r12
unsigned int v13; // eax

v0 = bind_address;
if ( bind_address || (v0 = get_first_socket()) != 0 )
{
callid_suffix = &callid_buf[dword_9F8];
v1 = *(const char **)(v0 + 48);
v2 = *(_DWORD *)(v0 + 56);
v3 = my_pid();
v4 = snprintf(callid_suffix, 0x43uLL, "%c%d@%.*s", 45LL, v3, v2, v1);
dword_9E8 = v4;
if ( v4 == -1 || v4 > 67 )
{
v5 = -1;
if ( (int)get_debug_level("tm", 2LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: child_init_callid: buffer too small\n",
process_no,
v9,
v8,
"tm [callid.c:133]: ",
"child_init_callid");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: child_init_callid: buffer too small\n",
*((const char **)&log_level_info + 8),
"tm [callid.c:133]: ",
"child_init_callid");
}
--dprint_crit;
v5 = -1;
}
}
else
{
v5 = 0;
if ( (int)get_debug_level("tm", 2LL) > 2 )
{
v5 = dprint_crit;
if ( dprint_crit )
{
v5 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v10 = (const char *)callid_prefix;
v11 = dword_9F8 + dword_9E8;
v12 = (const char *)*((_QWORD *)&log_level_info + 16);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: callid: '%.*s'\n",
process_no,
v13,
v12,
"tm [callid.c:137]: ",
"child_init_callid",
v11,
v10);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: callid: '%.*s'\n",
*((_QWORD *)&log_level_info + 16),
"tm [callid.c:137]: ",
"child_init_callid",
(unsigned int)(dword_9E8 + dword_9F8),
callid_prefix);
}
--dprint_crit;
}
}
}
}
else
{
v5 = -1;
if ( (int)get_debug_level("tm", 2LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 6);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG: child_init_callid: null socket list\n",
process_no,
v7,
v6,
"tm [callid.c:123]: ",
"child_init_callid");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG: child_init_callid: null socket list\n",
*((const char **)&log_level_info + 6),
"tm [callid.c:123]: ",
"child_init_callid");
}
--dprint_crit;
v5 = -1;
}
}
return v5;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
const char *v1; // rbp
int v2; // ebx
unsigned int v3; // eax
int v4; // eax
unsigned int v5; // ebx
const char *v6; // r13
unsigned int v7; // eax
const char *v8; // rbx
unsigned int v9; // eax
const char *v10; // r13
int v11; // ebp
const char *v12; // r12
unsigned int v13; // eax

v0 = bind_address;
if ( bind_address || (v0 = func0()) != 0 )
{
callid_suffix = &callid_buf[dword_9F8];
v1 = *(const char **)(v0 + 48);
v2 = *(_DWORD *)(v0 + 56);
v3 = my_pid();
v4 = snprintf(callid_suffix, 0x43uLL, "%c%d@%.*s", 45LL, v3, v2, v1);
dword_9E8 = v4;
if ( v4 == -1 || v4 > 67 )
{
v5 = -1;
if ( (int)get_debug_level("tm", 2LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: child_init_callid: buffer too small\n",
process_no,
v9,
v8,
"tm [callid.c:133]: ",
"child_init_callid");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: child_init_callid: buffer too small\n",
*((const char **)&log_level_info + 8),
"tm [callid.c:133]: ",
"child_init_callid");
}
--dprint_crit;
v5 = -1;
}
}
else
{
v5 = 0;
if ( (int)get_debug_level("tm", 2LL) > 2 )
{
v5 = dprint_crit;
if ( dprint_crit )
{
v5 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v10 = (const char *)callid_prefix;
v11 = dword_9F8 + dword_9E8;
v12 = (const char *)*((_QWORD *)&log_level_info + 16);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: callid: '%.*s'\n",
process_no,
v13,
v12,
"tm [callid.c:137]: ",
"child_init_callid",
v11,
v10);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: callid: '%.*s'\n",
*((_QWORD *)&log_level_info + 16),
"tm [callid.c:137]: ",
"child_init_callid",
(unsigned int)(dword_9E8 + dword_9F8),
callid_prefix);
}
--dprint_crit;
}
}
}
}
else
{
v5 = -1;
if ( (int)get_debug_level("tm", 2LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 6);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG: child_init_callid: null socket list\n",
process_no,
v7,
v6,
"tm [callid.c:123]: ",
"child_init_callid");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG: child_init_callid: null socket list\n",
*((const char **)&log_level_info + 6),
"tm [callid.c:123]: ",
"child_init_callid");
}
--dprint_crit;
v5 = -1;
}
}
return v5;
}

original_code:
int child_init_callid(int rank)
{
 struct socket_info *si;
 si=bind_address?bind_address:get_first_socket();
 if (si==0){
  do { if (get_debug_level("tm", (sizeof("tm")-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(): " "BUG: child_init_callid: null socket list\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("tm" " [" "callid.c" ":" "123" "]: ") , __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(): " "BUG: child_init_callid: null socket list\n", (log_level_info[((-2)) - (-5)].name), ("tm" " [" "callid.c" ":" "123" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "BUG: child_init_callid: null socket list\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "123" "]: ") , __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(): " "BUG: child_init_callid: null socket list\n", ("tm" " [" "callid.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(): " "BUG: child_init_callid: null socket list\n", ("tm" " [" "callid.c" ":" "123" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 callid_suffix.s = callid_buf + callid_prefix.len;
 callid_suffix.len = snprintf(callid_suffix.s, ( 1 + 5 + 42 + 2 + 1 + 16 ),
         "%c%d@%.*s", '-', my_pid(),
         si->address_str.len,
         si->address_str.s);
 if ((callid_suffix.len == -1) || (callid_suffix.len > ( 1 + 5 + 42 + 2 + 1 + 16 ))) {
  do { if (get_debug_level("tm", (sizeof("tm")-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: child_init_callid: buffer too small\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("tm" " [" "callid.c" ":" "133" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: child_init_callid: buffer too small\n", (log_level_info[((-1)) - (-5)].name), ("tm" " [" "callid.c" ":" "133" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: child_init_callid: buffer too small\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "133" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: child_init_callid: buffer too small\n", ("tm" " [" "callid.c" ":" "133" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: child_init_callid: buffer too small\n", ("tm" " [" "callid.c" ":" "133" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 do { if (get_debug_level("tm", (sizeof("tm")-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(): " "DEBUG: callid: '%.*s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("tm" " [" "callid.c" ":" "137" "]: ") , __func__, callid_prefix.len + callid_suffix.len, callid_prefix.s); 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(): " "DEBUG: callid: '%.*s'\n", (log_level_info[((3)) - (-5)].name), ("tm" " [" "callid.c" ":" "137" "]: ") , __func__, callid_prefix.len + callid_suffix.len, callid_prefix.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DEBUG: callid: '%.*s'\n", process_no, my_pid(), ("tm" " [" "callid.c" ":" "137" "]: ") , __func__, callid_prefix.len + callid_suffix.len, callid_prefix.s); 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(): " "DEBUG: callid: '%.*s'\n", ("tm" " [" "callid.c" ":" "137" "]: ") , __func__, callid_prefix.len + callid_suffix.len, callid_prefix.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: callid: '%.*s'\n", ("tm" " [" "callid.c" ":" "137" "]: ") , __func__, callid_prefix.len + callid_suffix.len, callid_prefix.s); } } (dprint_crit--); } } while(0);
 return 0;
}

variable_types: rank int

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


decompiled_code:
void __fastcall generate_callid(__int64 a1)
{
int v1; // er12
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdx
__int64 v5; // rbx

v1 = dword_9F8;
if ( dword_9F8 )
{
v2 = dword_9F8 - 1LL;
v3 = dword_9F8 - 2LL - (unsigned int)(dword_9F8 - 1);
v4 = (-1 - (-2 - ((_BYTE)dword_9F8 - 1))) & 7;
if ( ((-1 - (-2 - ((_BYTE)dword_9F8 - 1))) & 7) == 0 )
goto LABEL_35;
if ( v4 != 1 )
{
if ( v4 != 2 )
{
if ( v4 != 3 )
{
if ( v4 != 4 )
{
if ( v4 != 5 )
{
if ( v4 != 6 )
{
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
goto LABEL_32;
v2 = v1 - 2LL;
}
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( (unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
{
if ( --v2 != v3 )
{
LABEL_35:
do
{
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v2)) )
break;
v5 = v2 - 1;
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v5)) )
break;
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v5 - 1)) )
break;
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v5 - 2)) )
break;
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v5 - 3)) )
break;
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v5 - 4)) )
break;
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v5 - 5)) )
break;
if ( !(unsigned int)inc_hexchar((char *)(callid_prefix + v5 - 6)) )
break;
v2 = v5 - 7;
}
while ( v2 != v3 );
}
}
}
LABEL_32:
*(_QWORD *)a1 = callid_prefix;
*(_DWORD *)(a1 + 8) = dword_9E8 + v1;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
int v1; // er12
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdx
__int64 v5; // rbx

v1 = dword_9F8;
if ( dword_9F8 )
{
v2 = dword_9F8 - 1LL;
v3 = dword_9F8 - 2LL - (unsigned int)(dword_9F8 - 1);
v4 = (-1 - (-2 - ((_BYTE)dword_9F8 - 1))) & 7;
if ( ((-1 - (-2 - ((_BYTE)dword_9F8 - 1))) & 7) == 0 )
goto LABEL_35;
if ( v4 != 1 )
{
if ( v4 != 2 )
{
if ( v4 != 3 )
{
if ( v4 != 4 )
{
if ( v4 != 5 )
{
if ( v4 != 6 )
{
if ( !(unsigned int)func1((char *)(callid_prefix + v2)) )
goto LABEL_32;
v2 = v1 - 2LL;
}
if ( !(unsigned int)func1((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)func1((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)func1((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)func1((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( !(unsigned int)func1((char *)(callid_prefix + v2)) )
goto LABEL_32;
--v2;
}
if ( (unsigned int)func1((char *)(callid_prefix + v2)) )
{
if ( --v2 != v3 )
{
LABEL_35:
do
{
if ( !(unsigned int)func1((char *)(callid_prefix + v2)) )
break;
v5 = v2 - 1;
if ( !(unsigned int)func1((char *)(callid_prefix + v5)) )
break;
if ( !(unsigned int)func1((char *)(callid_prefix + v5 - 1)) )
break;
if ( !(unsigned int)func1((char *)(callid_prefix + v5 - 2)) )
break;
if ( !(unsigned int)func1((char *)(callid_prefix + v5 - 3)) )
break;
if ( !(unsigned int)func1((char *)(callid_prefix + v5 - 4)) )
break;
if ( !(unsigned int)func1((char *)(callid_prefix + v5 - 5)) )
break;
if ( !(unsigned int)func1((char *)(callid_prefix + v5 - 6)) )
break;
v2 = v5 - 7;
}
while ( v2 != v3 );
}
}
}
LABEL_32:
*(_QWORD *)a1 = callid_prefix;
*(_DWORD *)(a1 + 8) = dword_9E8 + v1;
}

original_code:
void generate_callid(str* callid)
{
 int i;
 for(i = callid_prefix.len; i; i--) {
  if (!inc_hexchar(callid_prefix.s + i - 1)) break;
 }
 callid->s = callid_prefix.s;
 callid->len = callid_prefix.len + callid_suffix.len;
}

canonical_original_code:
void generate_callid(struct _str *callid)
{
 int i;
 for(i = callid_prefix.len; i; i--) {
  if (!inc_hexchar(callid_prefix.s + i - 1)) break;
 }
 callid->s = callid_prefix.s;
 callid->len = callid_prefix.len + callid_suffix.len;
}

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


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

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

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

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

variable_types:
v
void *

variable_types: struct counter_handle_s { unsigned short id; }

return_type: unsigned long


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

v0 = get_stat_val(aar_replies_received);
if ( v0 )
v0 = get_stat_val(aar_replies_response_time) / v0;
return v0;
}

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

v0 = func0(aar_replies_received);
if ( v0 )
v0 = func0(aar_replies_response_time) / v0;
return v0;
}

original_code:
unsigned long get_avg_aar_response_time() {
 long rpls_received = get_stat_val(aar_replies_received);
 if (!rpls_received)
  return 0;
 return get_stat_val(aar_replies_response_time)/rpls_received;
}


decompiled_code:
__int64 __fastcall db_drv_init(_QWORD *a1, __int64 a2)
{
*a1 = a2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, __int64 a2)
{
*a1 = a2;
return 0LL;
}

original_code:
int db_drv_init(db_drv_t* ptr, void* free_func)
{
 ptr->free = free_func;
 return 0;
}

canonical_original_code:
int db_drv_init(struct db_drv *ptr, void *free_func)
{
 ptr->free = free_func;
 return 0;
}

variable_types: struct db_drv { void (*free)(struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv *data[16]; } *db_struct, struct db_drv *payload); } *

user_defined_types: struct db_drv { void (*free)(struct db_gen *db_struct, struct db_drv *payload); }


decompiled_code:
__int64 __fastcall db_drv_func(_QWORD *a1, _QWORD *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // r14
__int64 result; // rax
const char *v8; // rbx
unsigned int v9; // eax
const char *v10; // r14
int v11; // er12
const char *v12; // r13
unsigned int v13; // eax

v4 = qm_malloc(mem_block, *((_DWORD *)a2 + 2) + 4);
if ( v4 )
{
v5 = v4;
*(_WORD *)v4 = 25188;
*(_BYTE *)(v4 + 2) = 95;
v6 = v4 + 3;
memcpy((void *)(v4 + 3), (const void *)*a2, *((int *)a2 + 2));
*(_BYTE *)(v5 + *((_DWORD *)a2 + 2) + 3) = 0;
if ( find_module_by_name(v5) )
{
v6 = v5;
LABEL_4:
*a1 = find_mod_export(v6, a3, 0LL, 0LL);
qm_free(mem_block, v5);
return *a1 == 0LL;
}
if ( find_module_by_name(v6) )
goto LABEL_4;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*a2;
v11 = *((_DWORD *)a2 + 2);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db_drv_func: database driver for '%.*s' not found\n",
process_no,
v13,
v12,
"<core> [db_drv.c:83]: ",
"db_drv_func",
v11,
v10);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db_drv_func: database driver for '%.*s' not found\n",
*((_QWORD *)&log_level_info + 8),
"<core> [db_drv.c:83]: ",
"db_drv_func",
*((unsigned int *)a2 + 2),
*a2);
}
--dprint_crit;
}
qm_free(mem_block, v5);
result = 0xFFFFFFFFLL;
}
else
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db_drv_func: No memory left\n",
process_no,
v9,
v8,
"<core> [db_drv.c:69]: ",
"db_drv_func");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db_drv_func: No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [db_drv.c:69]: ",
"db_drv_func");
}
--dprint_crit;
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, _QWORD *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // r14
__int64 result; // rax
const char *v8; // rbx
unsigned int v9; // eax
const char *v10; // r14
int v11; // er12
const char *v12; // r13
unsigned int v13; // eax

v4 = qm_malloc(mem_block, *((_DWORD *)a2 + 2) + 4);
if ( v4 )
{
v5 = v4;
*(_WORD *)v4 = 25188;
*(_BYTE *)(v4 + 2) = 95;
v6 = v4 + 3;
memcpy((void *)(v4 + 3), (const void *)*a2, *((int *)a2 + 2));
*(_BYTE *)(v5 + *((_DWORD *)a2 + 2) + 3) = 0;
if ( find_module_by_name(v5) )
{
v6 = v5;
LABEL_4:
*a1 = find_mod_export(v6, a3, 0LL, 0LL);
qm_free(mem_block, v5);
return *a1 == 0LL;
}
if ( find_module_by_name(v6) )
goto LABEL_4;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*a2;
v11 = *((_DWORD *)a2 + 2);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db_drv_func: database driver for '%.*s' not found\n",
process_no,
v13,
v12,
"<core> [db_drv.c:83]: ",
"db_drv_func",
v11,
v10);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db_drv_func: database driver for '%.*s' not found\n",
*((_QWORD *)&log_level_info + 8),
"<core> [db_drv.c:83]: ",
"db_drv_func",
*((unsigned int *)a2 + 2),
*a2);
}
--dprint_crit;
}
qm_free(mem_block, v5);
result = 0xFFFFFFFFLL;
}
else
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db_drv_func: No memory left\n",
process_no,
v9,
v8,
"<core> [db_drv.c:69]: ",
"db_drv_func");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db_drv_func: No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [db_drv.c:69]: ",
"db_drv_func");
}
--dprint_crit;
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int db_drv_func(db_drv_func_t* func, str* module, char* func_name)
{
 static str prefix = {("db_"), sizeof("db_") - 1};
 char* buf = ((void *)0), *name;
 if ((buf = qm_malloc(mem_block, (prefix.len + module->len + 1))) == ((void *)0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "db_drv_func: No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "69" "]: ") , __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(): " "db_drv_func: No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "69" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_drv_func: No memory left\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "69" "]: ") , __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(): " "db_drv_func: No memory left\n", ("<core> [" "db_drv.c" ":" "69" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_drv_func: No memory left\n", ("<core> [" "db_drv.c" ":" "69" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 memcpy(buf, prefix.s, prefix.len);
 memcpy(buf + prefix.len, module->s, module->len);
 buf[prefix.len + module->len] = '\0';
 name = buf;
 if (find_module_by_name(name) == 0) {
  name = buf + prefix.len;
  if (find_module_by_name(name) == 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(): " "db_drv_func: database driver for '%.*s' not found\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (str *)0) ? (module)->len : 0), ((module != (str *)0) ? (module)->s : "")); 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(): " "db_drv_func: database driver for '%.*s' not found\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (str *)0) ? (module)->len : 0), ((module != (str *)0) ? (module)->s : "")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_drv_func: database driver for '%.*s' not found\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (str *)0) ? (module)->len : 0), ((module != (str *)0) ? (module)->s : "")); 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(): " "db_drv_func: database driver for '%.*s' not found\n", ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (str *)0) ? (module)->len : 0), ((module != (str *)0) ? (module)->s : "")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_drv_func: database driver for '%.*s' not found\n", ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (str *)0) ? (module)->len : 0), ((module != (str *)0) ? (module)->s : "")); } } (dprint_crit--); } } while(0);
   goto error;
  }
 }
 *func = (db_drv_func_t)find_mod_export(name, func_name, 0, 0);
 if (buf) qm_free(mem_block, (buf));
 if (*func) return 0;
 else return 1;
error:
 if (buf) qm_free(mem_block, (buf));
 return -1;
}

canonical_original_code:
int db_drv_func(int (**func)(void *db_struct, ...), struct _str *module, char *func_name)
{
 static struct _str prefix = {("db_"), sizeof("db_") - 1};
 char *buf = ((void *)0); char *name;
 if ((buf = qm_malloc(mem_block, (prefix.len + module->len + 1))) == ((void *)0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "db_drv_func: No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "69" "]: ") , __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(): " "db_drv_func: No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "69" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_drv_func: No memory left\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "69" "]: ") , __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(): " "db_drv_func: No memory left\n", ("<core> [" "db_drv.c" ":" "69" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_drv_func: No memory left\n", ("<core> [" "db_drv.c" ":" "69" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 memcpy(buf, prefix.s, prefix.len);
 memcpy(buf + prefix.len, module->s, module->len);
 buf[prefix.len + module->len] = '\0';
 name = buf;
 if (find_module_by_name(name) == 0) {
  name = buf + prefix.len;
  if (find_module_by_name(name) == 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(): " "db_drv_func: database driver for '%.*s' not found\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (struct _str *)0) ? (module)->len : 0), ((module != (struct _str *)0) ? (module)->s : "")); 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(): " "db_drv_func: database driver for '%.*s' not found\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (struct _str *)0) ? (module)->len : 0), ((module != (struct _str *)0) ? (module)->s : "")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_drv_func: database driver for '%.*s' not found\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (struct _str *)0) ? (module)->len : 0), ((module != (struct _str *)0) ? (module)->s : "")); 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(): " "db_drv_func: database driver for '%.*s' not found\n", ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (struct _str *)0) ? (module)->len : 0), ((module != (struct _str *)0) ? (module)->s : "")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_drv_func: database driver for '%.*s' not found\n", ("<core> [" "db_drv.c" ":" "83" "]: ") , __func__, ((module != (struct _str *)0) ? (module)->len : 0), ((module != (struct _str *)0) ? (module)->s : "")); } } (dprint_crit--); } } while(0);
   goto error;
  }
 }
 *func = (int (*)(void *db_struct, ...))find_mod_export(name, func_name, 0, 0);
 if (buf) qm_free(mem_block, (buf));
 if (*func) return 0;
 else return 1;
error:
 if (buf) qm_free(mem_block, (buf));
 return -1;
}

variable_types:
func
int (**)(void *db_struct, ...)

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

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

variable_types:
buf
char *

variable_types:
name
char *


decompiled_code:
__int64 __fastcall db_drv_call(__int64 a1, const char *a2, __int64 a3, int a4)
{
int v6; // eax
__int64 result; // rax
int v8; // edx
const char *v9; // r12
unsigned int v10; // eax
int v11; // edx
void *v12; // r9
const char *v13; // r12
int v14; // er13
const char *v15; // rbx
unsigned int v16; // eax
__int64 v17[6]; // [rsp+8h] [rbp-30h] BYREF

v6 = db_drv_func(v17, (_QWORD *)a1, (__int64)a2);
if ( v6 < 0 )
{
v8 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v8 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db: db_drv_call failed\n",
process_no,
v10,
v9,
"<core> [db_drv.c:115]: ",
"db_drv_call");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db: db_drv_call failed\n",
*((const char **)&log_level_info + 8),
"<core> [db_drv.c:115]: ",
"db_drv_call");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
else if ( v6 )
{
v11 = get_debug_level("core", 4LL);
result = 1LL;
if ( v11 > 2 )
{
result = 1LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v13 = (const char *)&LC7;
if ( *(_QWORD *)a1 )
v13 = *(const char **)a1;
v14 = *(_DWORD *)(a1 + 8);
v15 = (const char *)*((_QWORD *)&log_level_info + 16);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db_drv_call: DB driver for %.*s does not export function %s\n",
process_no,
v16,
v15,
"<core> [db_drv.c:123]: ",
"db_drv_call",
v14,
v13,
a2);
if ( log_color )
dprint_color_reset();
}
else
{
v12 = *(void **)a1;
if ( !*(_QWORD *)a1 )
v12 = &LC7;
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db_drv_call: DB driver for %.*s does not export function %s\n",
*((_QWORD *)&log_level_info + 16),
"<core> [db_drv.c:123]: ",
"db_drv_call",
*(unsigned int *)(a1 + 8),
v12,
a2);
}
--dprint_crit;
result = 1LL;
}
}
}
else
{
db_payload_idx = a4;
result = ((__int64 (__fastcall *)(__int64))v17[0])(a3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2, __int64 a3, int a4)
{
int v6; // eax
__int64 result; // rax
int v8; // edx
const char *v9; // r12
unsigned int v10; // eax
int v11; // edx
void *v12; // r9
const char *v13; // r12
int v14; // er13
const char *v15; // rbx
unsigned int v16; // eax
__int64 v17[6]; // [rsp+8h] [rbp-30h] BYREF

v6 = func2(v17, (_QWORD *)a1, (__int64)a2);
if ( v6 < 0 )
{
v8 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v8 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db: db_drv_call failed\n",
process_no,
v10,
v9,
"<core> [db_drv.c:115]: ",
"db_drv_call");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db: db_drv_call failed\n",
*((const char **)&log_level_info + 8),
"<core> [db_drv.c:115]: ",
"db_drv_call");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
else if ( v6 )
{
v11 = get_debug_level("core", 4LL);
result = 1LL;
if ( v11 > 2 )
{
result = 1LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v13 = (const char *)&LC7;
if ( *(_QWORD *)a1 )
v13 = *(const char **)a1;
v14 = *(_DWORD *)(a1 + 8);
v15 = (const char *)*((_QWORD *)&log_level_info + 16);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): db_drv_call: DB driver for %.*s does not export function %s\n",
process_no,
v16,
v15,
"<core> [db_drv.c:123]: ",
"db_drv_call",
v14,
v13,
a2);
if ( log_color )
dprint_color_reset();
}
else
{
v12 = *(void **)a1;
if ( !*(_QWORD *)a1 )
v12 = &LC7;
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): db_drv_call: DB driver for %.*s does not export function %s\n",
*((_QWORD *)&log_level_info + 16),
"<core> [db_drv.c:123]: ",
"db_drv_call",
*(unsigned int *)(a1 + 8),
v12,
a2);
}
--dprint_crit;
result = 1LL;
}
}
}
else
{
db_payload_idx = a4;
result = ((__int64 (__fastcall *)(__int64))v17[0])(a3);
}
return result;
}

original_code:
int db_drv_call(str* module, char* func_name, void* db_struct, int offset)
{
 db_drv_func_t func;
 int ret;
 ret = db_drv_func(&func, module, func_name);
 if (ret < 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(): " "db: db_drv_call failed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "115" "]: ") , __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(): " "db: db_drv_call failed\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "115" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db: db_drv_call failed\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "115" "]: ") , __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(): " "db: db_drv_call failed\n", ("<core> [" "db_drv.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(): " "db: db_drv_call failed\n", ("<core> [" "db_drv.c" ":" "115" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (ret == 0) {
  db_payload_idx = offset;
  return func(db_struct);
 } else {
  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(): " "db_drv_call: DB driver for %.*s does not export function %s\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); 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(): " "db_drv_call: DB driver for %.*s does not export function %s\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_drv_call: DB driver for %.*s does not export function %s\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); 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(): " "db_drv_call: DB driver for %.*s does not export function %s\n", ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_drv_call: DB driver for %.*s does not export function %s\n", ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); } } (dprint_crit--); } } while(0);
  return 1;
 }
}

canonical_original_code:
int db_drv_call(struct _str *module, char *func_name, void *db_struct, int offset)
{
 int (*func)(void *db_struct, ...);
 int ret;
 ret = db_drv_func(&func, module, func_name);
 if (ret < 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(): " "db: db_drv_call failed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "115" "]: ") , __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(): " "db: db_drv_call failed\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "db_drv.c" ":" "115" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db: db_drv_call failed\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "115" "]: ") , __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(): " "db: db_drv_call failed\n", ("<core> [" "db_drv.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(): " "db: db_drv_call failed\n", ("<core> [" "db_drv.c" ":" "115" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (ret == 0) {
  db_payload_idx = offset;
  return func(db_struct);
 } else {
  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(): " "db_drv_call: DB driver for %.*s does not export function %s\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); 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(): " "db_drv_call: DB driver for %.*s does not export function %s\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_drv_call: DB driver for %.*s does not export function %s\n", process_no, my_pid(), ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); 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(): " "db_drv_call: DB driver for %.*s does not export function %s\n", ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_drv_call: DB driver for %.*s does not export function %s\n", ("<core> [" "db_drv.c" ":" "123" "]: ") , __func__, module->len, ((module->s)?(module->s):""), func_name); } } (dprint_crit--); } } while(0);
  return 1;
 }
}

variable_types: offset int

variable_types:
func
int (*)(void *db_struct, ...)

variable_types: ret 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 func0(volatile __int32 *a1, __int32 a2)
{
return (unsigned int)_InterlockedExchange(a1, a2);
}

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

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

variable_types:
var
int *

variable_types: v int


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

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

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

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

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 = func0(a1, 0);
if ( (_DWORD)result == 2 )
result = syscall(202LL, a1, 1LL, 1LL, 0LL, 0LL, 0LL);
return result;
}

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

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