decompiled_code:
__int64 mod_init()
{
const char *v1; // r12
unsigned int v2; // eax
struct _IO_FILE *v3; // rdi
__int64 v4; // r15
const char *v5; // r14
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
const char *v9; // r15
int v10; // er14
const char *v11; // r13
unsigned int v12; // eax
struct _IO_FILE *v13; // rdi
__int64 v14; // rdx
const char *v15; // r14
const char *v16; // r13
unsigned int v17; // eax
struct _IO_FILE *v18; // rdi
__int64 v19; // [rsp-8h] [rbp-40h]

fwrite("print - initializing\n", 1uLL, 0x15uLL, stderr);
if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v15 = string_param;
v16 = (const char *)*((_QWORD *)&log_level_info + 16);
v17 = my_pid();
v18 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: string_param = '%s'\n",
process_no,
v17,
v16,
"print [print.c:98]: ",
"mod_init",
v15);
if ( log_color )
dprint_color_reset(v18, "%2d(%d) %s: %s%s(): print: string_param = '%s'\n", v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: string_param = '%s'\n",
*((const char **)&log_level_info + 16),
"print [print.c:98]: ",
"mod_init",
string_param);
}
--dprint_crit;
}
if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v9 = (const char *)str_param;
v10 = *((_DWORD *)&str_param + 2);
v11 = (const char *)*((_QWORD *)&log_level_info + 16);
v12 = my_pid();
v13 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: str_param = '%.*s'\n",
process_no,
v12,
v11,
"print [print.c:99]: ",
"mod_init",
v10,
v9);
if ( log_color )
dprint_color_reset(v13, "%2d(%d) %s: %s%s(): print: str_param = '%.*s'\n", v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: str_param = '%.*s'\n",
*((_QWORD *)&log_level_info + 16),
"print [print.c:99]: ",
"mod_init",
*((unsigned int *)&str_param + 2),
str_param);
}
--dprint_crit;
}
if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = int_param;
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: int_param = %d\n",
process_no,
v6,
v5,
"print [print.c:100]: ",
"mod_init",
v4);
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): print: int_param = %d\n", v8);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: int_param = %d\n",
*((const char **)&log_level_info + 16),
"print [print.c:100]: ",
"mod_init",
int_param);
}
--dprint_crit;
}
if ( (int)get_debug_level("print", 5LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 10);
v2 = my_pid();
v3 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): this is an example module, it has no practical use\n",
process_no,
v2,
v1,
"print [print.c:101]: ",
"mod_init");
if ( log_color )
dprint_color_reset(v3, "%2d(%d) %s: %s%s(): this is an example module, it has no practical use\n", v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): this is an example module, it has no practical use\n",
*((const char **)&log_level_info + 10),
"print [print.c:101]: ",
"mod_init");
}
--dprint_crit;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
const char *v1; // r12
unsigned int v2; // eax
struct _IO_FILE *v3; // rdi
__int64 v4; // r15
const char *v5; // r14
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
const char *v9; // r15
int v10; // er14
const char *v11; // r13
unsigned int v12; // eax
struct _IO_FILE *v13; // rdi
__int64 v14; // rdx
const char *v15; // r14
const char *v16; // r13
unsigned int v17; // eax
struct _IO_FILE *v18; // rdi
__int64 v19; // [rsp-8h] [rbp-40h]

fwrite("print - initializing\n", 1uLL, 0x15uLL, stderr);
if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v15 = string_param;
v16 = (const char *)*((_QWORD *)&log_level_info + 16);
v17 = my_pid();
v18 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: string_param = '%s'\n",
process_no,
v17,
v16,
"print [print.c:98]: ",
"mod_init",
v15);
if ( log_color )
dprint_color_reset(v18, "%2d(%d) %s: %s%s(): print: string_param = '%s'\n", v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: string_param = '%s'\n",
*((const char **)&log_level_info + 16),
"print [print.c:98]: ",
"mod_init",
string_param);
}
--dprint_crit;
}
if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v9 = (const char *)str_param;
v10 = *((_DWORD *)&str_param + 2);
v11 = (const char *)*((_QWORD *)&log_level_info + 16);
v12 = my_pid();
v13 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: str_param = '%.*s'\n",
process_no,
v12,
v11,
"print [print.c:99]: ",
"mod_init",
v10,
v9);
if ( log_color )
dprint_color_reset(v13, "%2d(%d) %s: %s%s(): print: str_param = '%.*s'\n", v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: str_param = '%.*s'\n",
*((_QWORD *)&log_level_info + 16),
"print [print.c:99]: ",
"mod_init",
*((unsigned int *)&str_param + 2),
str_param);
}
--dprint_crit;
}
if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = int_param;
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: int_param = %d\n",
process_no,
v6,
v5,
"print [print.c:100]: ",
"mod_init",
v4);
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): print: int_param = %d\n", v8);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: int_param = %d\n",
*((const char **)&log_level_info + 16),
"print [print.c:100]: ",
"mod_init",
int_param);
}
--dprint_crit;
}
if ( (int)get_debug_level("print", 5LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 10);
v2 = my_pid();
v3 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): this is an example module, it has no practical use\n",
process_no,
v2,
v1,
"print [print.c:101]: ",
"mod_init");
if ( log_color )
dprint_color_reset(v3, "%2d(%d) %s: %s%s(): this is an example module, it has no practical use\n", v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): this is an example module, it has no practical use\n",
*((const char **)&log_level_info + 10),
"print [print.c:101]: ",
"mod_init");
}
--dprint_crit;
}
return 0LL;
}

original_code:
static int mod_init(void)
{
 fprintf(stderr, "print - initializing\n");
 do { if (get_debug_level("print", (sizeof("print")-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(): " "print: string_param = '%s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); 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(): " "print: string_param = '%s'\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: string_param = '%s'\n", process_no, my_pid(), ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); 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(): " "print: string_param = '%s'\n", ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: string_param = '%s'\n", ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("print", (sizeof("print")-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(): " "print: str_param = '%.*s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.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(): " "print: str_param = '%.*s'\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: str_param = '%.*s'\n", process_no, my_pid(), ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.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(): " "print: str_param = '%.*s'\n", ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: str_param = '%.*s'\n", ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.s); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("print", (sizeof("print")-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(): " "print: int_param = %d\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); 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(): " "print: int_param = %d\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: int_param = %d\n", process_no, my_pid(), ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); 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(): " "print: int_param = %d\n", ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: int_param = %d\n", ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("print", (sizeof("print")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "this is an example module, it has no practical use\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("print" " [" "print.c" ":" "101" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "this is an example module, it has no practical use\n", (log_level_info[((0)) - (-5)].name), ("print" " [" "print.c" ":" "101" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "this is an example module, it has no practical use\n", process_no, my_pid(), ("print" " [" "print.c" ":" "101" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "this is an example module, it has no practical use\n", ("print" " [" "print.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(): " "this is an example module, it has no practical use\n", ("print" " [" "print.c" ":" "101" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
}

canonical_original_code:
static int mod_init()
{
 fprintf(stderr, "print - initializing\n");
 do { if (get_debug_level("print", (sizeof("print")-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(): " "print: string_param = '%s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); 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(): " "print: string_param = '%s'\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: string_param = '%s'\n", process_no, my_pid(), ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); 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(): " "print: string_param = '%s'\n", ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: string_param = '%s'\n", ("print" " [" "print.c" ":" "98" "]: ") , __func__, string_param); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("print", (sizeof("print")-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(): " "print: str_param = '%.*s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.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(): " "print: str_param = '%.*s'\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: str_param = '%.*s'\n", process_no, my_pid(), ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.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(): " "print: str_param = '%.*s'\n", ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: str_param = '%.*s'\n", ("print" " [" "print.c" ":" "99" "]: ") , __func__, str_param.len, str_param.s); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("print", (sizeof("print")-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(): " "print: int_param = %d\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); 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(): " "print: int_param = %d\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: int_param = %d\n", process_no, my_pid(), ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); 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(): " "print: int_param = %d\n", ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: int_param = %d\n", ("print" " [" "print.c" ":" "100" "]: ") , __func__, int_param); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("print", (sizeof("print")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "this is an example module, it has no practical use\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("print" " [" "print.c" ":" "101" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "this is an example module, it has no practical use\n", (log_level_info[((0)) - (-5)].name), ("print" " [" "print.c" ":" "101" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "this is an example module, it has no practical use\n", process_no, my_pid(), ("print" " [" "print.c" ":" "101" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "this is an example module, it has no practical use\n", ("print" " [" "print.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(): " "this is an example module, it has no practical use\n", ("print" " [" "print.c" ":" "101" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
}


repo: virtualolson/who

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

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

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

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

variable_types:
var
int *

variable_types: v int

return_type: int


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *

return_type: void


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

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

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

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

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

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

variable_types: i int


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

futex_get(reload_lock);
if ( (unsigned int)reload_tables() == 1 )
{
futex_release(reload_lock);
result = init_mi_tree(200LL, &LC0, 2LL);
}
else
{
futex_release(reload_lock);
result = init_mi_tree(500LL, "Domain table reload failed", 26LL);
}
return result;
}

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

func3(reload_lock);
if ( (unsigned int)reload_tables() == 1 )
{
func1(reload_lock);
result = init_mi_tree(200LL, &LC0, 2LL);
}
else
{
func1(reload_lock);
result = init_mi_tree(500LL, "Domain table reload failed", 26LL);
}
return result;
}

original_code:
struct mi_root* mi_domain_reload(struct mi_root *cmd_tree, void *param)
{
    futex_get(reload_lock);
    if (reload_tables() == 1) {
 futex_release(reload_lock);
 return init_mi_tree( 200, "OK", (sizeof("OK")-1));
    } else {
 futex_release(reload_lock);
 return init_mi_tree( 500, "Domain table reload failed", 26);
    }
}

canonical_original_code:
struct mi_root *mi_domain_reload(struct mi_root *cmd_tree, void *param)
{
    futex_get(reload_lock);
    if (reload_tables() == 1) {
 futex_release(reload_lock);
 return init_mi_tree( 200, "OK", (sizeof("OK")-1));
    } else {
 futex_release(reload_lock);
 return init_mi_tree( 500, "Domain table reload failed", 26);
    }
}

variable_types:
param
void *

return_type: struct mi_root { unsigned int code; struct _str { char *s; int len; } reason; struct mi_handler { void (*handler_f)(struct mi_root *, struct mi_handler *, int); void *param; } *async_hdl; struct mi_node { struct _str value; struct _str name; struct mi_node *kids; struct mi_node *next; struct mi_node *last; struct mi_attr { struct _str name; struct _str value; struct mi_attr *next; } *attributes; } node; } *

user_defined_types: struct mi_root { unsigned int code; struct _str reason; struct mi_handler *async_hdl; struct mi_node node; }

user_defined_types: struct mi_node { struct _str value; struct _str name; struct mi_node *kids; struct mi_node *next; struct mi_node *last; struct mi_attr *attributes; }


decompiled_code:
__int64 mi_domain_dump()
{
__int64 v0; // rax
__int64 v1; // r12
__int64 v3; // rdi
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi

v0 = init_mi_tree(200LL, &LC0, 2LL);
v1 = v0;
if ( v0 && (int)hash_table_mi_print(*hash_table, v0 + 32) < 0 )
{
if ( (int)get_debug_level("domain", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to add node\n",
process_no,
v5,
v4,
"domain [mi.c:66]: ",
"mi_domain_dump");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v6,
"%2d(%d) %s: %s%s(): failed to add node\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to add node\n",
*((const char **)&log_level_info + 8),
"domain [mi.c:66]: ",
"mi_domain_dump");
}
--dprint_crit;
}
v3 = v1;
v1 = 0LL;
free_mi_tree(v3);
}
return v1;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rax
__int64 v1; // r12
__int64 v3; // rdi
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi

v0 = init_mi_tree(200LL, &LC0, 2LL);
v1 = v0;
if ( v0 && (int)hash_table_mi_print(*hash_table, v0 + 32) < 0 )
{
if ( (int)get_debug_level("domain", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to add node\n",
process_no,
v5,
v4,
"domain [mi.c:66]: ",
"mi_domain_dump");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v6,
"%2d(%d) %s: %s%s(): failed to add node\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to add node\n",
*((const char **)&log_level_info + 8),
"domain [mi.c:66]: ",
"mi_domain_dump");
}
--dprint_crit;
}
v3 = v1;
v1 = 0LL;
free_mi_tree(v3);
}
return v1;
}

original_code:
struct mi_root* mi_domain_dump(struct mi_root *cmd_tree, void *param)
{
    struct mi_root* rpl_tree;
    rpl_tree = init_mi_tree( 200, "OK", (sizeof("OK")-1));
    if (rpl_tree == ((void *)0)) return 0;
    if(hash_table_mi_print(*hash_table, &rpl_tree->node) < 0) {
 do { if (get_debug_level("domain", (sizeof("domain")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "failed to add node\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "failed to add node\n", (log_level_info[((-1)) - (-5)].name), ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to add node\n", process_no, my_pid(), ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add node\n", ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add node\n", ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 free_mi_tree(rpl_tree);
 return 0;
    }
    return rpl_tree;
}

canonical_original_code:
struct mi_root *mi_domain_dump(struct mi_root *cmd_tree, void *param)
{
    struct mi_root *rpl_tree;
    rpl_tree = init_mi_tree( 200, "OK", (sizeof("OK")-1));
    if (rpl_tree == ((void *)0)) return 0;
    if(hash_table_mi_print(*hash_table, &rpl_tree->node) < 0) {
 do { if (get_debug_level("domain", (sizeof("domain")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "failed to add node\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "failed to add node\n", (log_level_info[((-1)) - (-5)].name), ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to add node\n", process_no, my_pid(), ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add node\n", ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add node\n", ("domain" " [" "mi.c" ":" "66" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 free_mi_tree(rpl_tree);
 return 0;
    }
    return rpl_tree;
}

variable_types: struct mi_root { unsigned int code; struct _str { char *s; int len; } reason; struct mi_handler { void (*handler_f)(struct mi_root *, struct mi_handler *, int); void *param; } *async_hdl; struct mi_node { struct _str value; struct _str name; struct mi_node *kids; struct mi_node *next; struct mi_node *last; struct mi_attr { struct _str name; struct _str value; struct mi_attr *next; } *attributes; } node; } *

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 endianness_sanity_check()
{
return (unsigned int)-(endian_test_int != 1);
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)-(endian_test_int != 1);
}

original_code:
int endianness_sanity_check()
{
 return (*(char*)&_endian_test_int==1)-1;
}

canonical_original_code:
int endianness_sanity_check()
{
 return (*(char *)&_endian_test_int==1)-1;
}


decompiled_code:
__int64 __fastcall parse_bdb_uri(__int64 a1, __int64 a2)
{
_BYTE *v2; // rbp
int v3; // er12
void *v5; // rax
const char *v6; // rdi
__int64 result; // rax
void *v8; // rax
__m128i *v9; // rdx
const char *v10; // r12
struct _IO_FILE *v11; // rdi
const char *v12; // r8
const char *v13; // r9
const char *v14; // r12
unsigned int v15; // eax
__int64 v16; // rdx
__int64 v17; // rcx
const char *v18; // r9
__int64 v19; // [rsp-48h] [rbp-48h]
__int64 v20; // [rsp-48h] [rbp-48h]
__int64 v21; // [rsp-40h] [rbp-40h]
const char *v22; // [rsp-38h] [rbp-38h]

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = *(_BYTE **)a2;
if ( !*(_QWORD *)a2 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a2 + 8);
v5 = (void *)qm_malloc(mem_block, v3 + 1);
*(_QWORD *)(a1 + 8) = v5;
if ( v5 )
{
memcpy(v5, v2, v3);
*(_BYTE *)(*(_QWORD *)(a1 + 8) + v3) = 0;
if ( *v2 == 47 )
{
v6 = *(const char **)(a1 + 8);
*(_QWORD *)(a1 + 16) = v6;
*(_DWORD *)(a1 + 24) = strlen(v6);
return 0LL;
}
v8 = (void *)qm_malloc(mem_block, v3 + 27LL);
*(_QWORD *)(a1 + 16) = v8;
memset(v8, 0, v3 + 27LL);
v9 = *(__m128i **)(a1 + 16);
if ( v9 )
{
strcpy(v9[1].m128i_i8, "amailio/");
*v9 = _mm_load_si128((const __m128i *)&LC7);
*(_BYTE *)(*(_QWORD *)(a1 + 16) + 25LL) = 47;
strncpy((char *)(*(_QWORD *)(a1 + 16) + 26LL), v2, v3);
*(_DWORD *)(a1 + 24) = v3 + 25;
return 0LL;
}
if ( (int)get_debug_level("db_berkeley", 11LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v21 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): bdb: no more pkg.\n",
process_no,
(unsigned int)v21,
v10,
"db_berkeley [bdb_uri.c:112]: ",
"parse_bdb_uri");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): bdb: no more pkg.\n", v19, v21, v12, v13, v22);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): bdb: no more pkg.\n",
*((const char **)&log_level_info + 8),
"db_berkeley [bdb_uri.c:112]: ",
"parse_bdb_uri");
}
--dprint_crit;
}
qm_free(mem_block, *(_QWORD *)(a1 + 8));
*(_QWORD *)(a1 + 8) = 0LL;
return 0xFFFFFFFFLL;
}
if ( (int)get_debug_level("db_berkeley", 11LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): bdb: no more pkg\n",
process_no,
v15,
v14,
"db_berkeley [bdb_uri.c:99]: ",
"parse_bdb_uri");
if ( log_color )
dprint_color_reset(v20, "%2d(%d) %s: %s%s(): bdb: no more pkg\n", v16, v17, (_BYTE *)&loc_A + 1, v18, v22);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): bdb: no more pkg\n",
*((const char **)&log_level_info + 8),
"db_berkeley [bdb_uri.c:99]: ",
"parse_bdb_uri");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
_BYTE *v2; // rbp
int v3; // er12
void *v5; // rax
const char *v6; // rdi
__int64 result; // rax
void *v8; // rax
__m128i *v9; // rdx
const char *v10; // r12
struct _IO_FILE *v11; // rdi
const char *v12; // r8
const char *v13; // r9
const char *v14; // r12
unsigned int v15; // eax
__int64 v16; // rdx
__int64 v17; // rcx
const char *v18; // r9
__int64 v19; // [rsp-48h] [rbp-48h]
__int64 v20; // [rsp-48h] [rbp-48h]
__int64 v21; // [rsp-40h] [rbp-40h]
const char *v22; // [rsp-38h] [rbp-38h]

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = *(_BYTE **)a2;
if ( !*(_QWORD *)a2 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a2 + 8);
v5 = (void *)qm_malloc(mem_block, v3 + 1);
*(_QWORD *)(a1 + 8) = v5;
if ( v5 )
{
memcpy(v5, v2, v3);
*(_BYTE *)(*(_QWORD *)(a1 + 8) + v3) = 0;
if ( *v2 == 47 )
{
v6 = *(const char **)(a1 + 8);
*(_QWORD *)(a1 + 16) = v6;
*(_DWORD *)(a1 + 24) = strlen(v6);
return 0LL;
}
v8 = (void *)qm_malloc(mem_block, v3 + 27LL);
*(_QWORD *)(a1 + 16) = v8;
memset(v8, 0, v3 + 27LL);
v9 = *(__m128i **)(a1 + 16);
if ( v9 )
{
strcpy(v9[1].m128i_i8, "amailio/");
*v9 = _mm_load_si128((const __m128i *)&LC7);
*(_BYTE *)(*(_QWORD *)(a1 + 16) + 25LL) = 47;
strncpy((char *)(*(_QWORD *)(a1 + 16) + 26LL), v2, v3);
*(_DWORD *)(a1 + 24) = v3 + 25;
return 0LL;
}
if ( (int)get_debug_level("db_berkeley", 11LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v21 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): bdb: no more pkg.\n",
process_no,
(unsigned int)v21,
v10,
"db_berkeley [bdb_uri.c:112]: ",
"parse_bdb_uri");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): bdb: no more pkg.\n", v19, v21, v12, v13, v22);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): bdb: no more pkg.\n",
*((const char **)&log_level_info + 8),
"db_berkeley [bdb_uri.c:112]: ",
"parse_bdb_uri");
}
--dprint_crit;
}
qm_free(mem_block, *(_QWORD *)(a1 + 8));
*(_QWORD *)(a1 + 8) = 0LL;
return 0xFFFFFFFFLL;
}
if ( (int)get_debug_level("db_berkeley", 11LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): bdb: no more pkg\n",
process_no,
v15,
v14,
"db_berkeley [bdb_uri.c:99]: ",
"parse_bdb_uri");
if ( log_color )
dprint_color_reset(v20, "%2d(%d) %s: %s%s(): bdb: no more pkg\n", v16, v17, (_BYTE *)&loc_A + 1, v18, v22);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): bdb: no more pkg\n",
*((const char **)&log_level_info + 8),
"db_berkeley [bdb_uri.c:99]: ",
"parse_bdb_uri");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
return result;
}

original_code:
int parse_bdb_uri(bdb_uri_t* res, str* uri)
{
 str s;
 if(uri==((void *)0) || uri->s==((void *)0))
  return -1;
 s = *uri;
 res->uri = (char*)qm_malloc(mem_block, ((s.len+1)*sizeof(char)));
 if(res->uri == ((void *)0))
 {
  do { if (get_debug_level("db_berkeley", (sizeof("db_berkeley")-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(): " "bdb: no more pkg\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __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(): " "bdb: no more pkg\n", (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "bdb: no more pkg\n", process_no, my_pid(), ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __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(): " "bdb: no more pkg\n", ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "bdb: no more pkg\n", ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memcpy(res->uri, s.s, s.len);
 res->uri[s.len] = '\0';
 if(s.s[0]!='/')
 {
  res->path.s = (char*)qm_malloc(mem_block, ((sizeof("/usr/local/etc/kamailio/")+s.len+2)*sizeof(char)));
  memset(res->path.s, 0, (sizeof("/usr/local/etc/kamailio/")+s.len+2)*sizeof(char));
  if(res->path.s==((void *)0))
  {
   do { if (get_debug_level("db_berkeley", (sizeof("db_berkeley")-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(): " "bdb: no more pkg.\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __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(): " "bdb: no more pkg.\n", (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "bdb: no more pkg.\n", process_no, my_pid(), ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __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(): " "bdb: no more pkg.\n", ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "bdb: no more pkg.\n", ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   qm_free(mem_block, (res->uri));
   res->uri = ((void *)0);
   return -1;
  }
  strcpy(res->path.s, "/usr/local/etc/kamailio/");
  res->path.s[sizeof("/usr/local/etc/kamailio/")] = '/';
  strncpy(&res->path.s[sizeof("/usr/local/etc/kamailio/")+1], s.s, s.len);
  res->path.len = sizeof("/usr/local/etc/kamailio/")+s.len;
 } else {
  res->path.s = res->uri;
  res->path.len = strlen(res->path.s);
 }
 return 0;
}

canonical_original_code:
int parse_bdb_uri(struct bdb_uri *res, struct _str *uri)
{
 struct _str s;
 if(uri==((void *)0) || uri->s==((void *)0))
  return -1;
 s = *uri;
 res->uri = (char *)qm_malloc(mem_block, ((s.len+1)*sizeof(char)));
 if(res->uri == ((void *)0))
 {
  do { if (get_debug_level("db_berkeley", (sizeof("db_berkeley")-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(): " "bdb: no more pkg\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __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(): " "bdb: no more pkg\n", (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "bdb: no more pkg\n", process_no, my_pid(), ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __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(): " "bdb: no more pkg\n", ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "bdb: no more pkg\n", ("db_berkeley" " [" "bdb_uri.c" ":" "99" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memcpy(res->uri, s.s, s.len);
 res->uri[s.len] = '\0';
 if(s.s[0]!='/')
 {
  res->path.s = (char *)qm_malloc(mem_block, ((sizeof("/usr/local/etc/kamailio/")+s.len+2)*sizeof(char)));
  memset(res->path.s, 0, (sizeof("/usr/local/etc/kamailio/")+s.len+2)*sizeof(char));
  if(res->path.s==((void *)0))
  {
   do { if (get_debug_level("db_berkeley", (sizeof("db_berkeley")-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(): " "bdb: no more pkg.\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __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(): " "bdb: no more pkg.\n", (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "bdb: no more pkg.\n", process_no, my_pid(), ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __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(): " "bdb: no more pkg.\n", ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "bdb: no more pkg.\n", ("db_berkeley" " [" "bdb_uri.c" ":" "112" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   qm_free(mem_block, (res->uri));
   res->uri = ((void *)0);
   return -1;
  }
  strcpy(res->path.s, "/usr/local/etc/kamailio/");
  res->path.s[sizeof("/usr/local/etc/kamailio/")] = '/';
  strncpy(&res->path.s[sizeof("/usr/local/etc/kamailio/")+1], s.s, s.len);
  res->path.len = sizeof("/usr/local/etc/kamailio/")+s.len;
 } else {
  res->path.s = res->uri;
  res->path.len = strlen(res->path.s);
 }
 return 0;
}

variable_types: struct bdb_uri { 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); } drv; char *uri; struct _str { char *s; int len; } path; } *

variable_types:
uri
struct _str *

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

user_defined_types: struct bdb_uri { struct db_drv drv; char *uri; struct _str path; }

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


decompiled_code:
__int64 __fastcall db_ctx_data_free(_QWORD *a1)
{
if ( *a1 )
qm_free(mem_block);
return qm_free(mem_block);
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
if ( *a1 )
qm_free(mem_block);
return qm_free(mem_block);
}

original_code:
static void db_ctx_data_free(struct db_ctx_data* ptr)
{
 if (ptr->module.s) qm_free(mem_block, (ptr->module.s));
 qm_free(mem_block, (ptr));
}

canonical_original_code:
static void db_ctx_data_free(struct db_ctx_data *ptr)
{
 if (ptr->module.s) qm_free(mem_block, (ptr->module.s));
 qm_free(mem_block, (ptr));
}

variable_types: struct db_ctx_data { struct _str { char *s; int len; } module; 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); } *data; struct { struct db_ctx_data *sle_next; } next; } *

user_defined_types: struct db_ctx_data { struct _str module; struct db_drv *data; struct { struct db_ctx_data *sle_next; } next; }


decompiled_code:
__int64 __fastcall search_the_list(__int64 a1, const char *a2)
{
__int64 v2; // rbx

if ( !a1 )
return 0LL;
v2 = a1;
do
{
if ( !strcasecmp(*(const char **)(v2 + 8), a2) )
return *(_QWORD *)v2;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 0LL;
}

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

if ( !a1 )
return 0LL;
v2 = a1;
do
{
if ( !strcasecmp(*(const char **)(v2 + 8), a2) )
return *(_QWORD *)v2;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 0LL;
}

original_code:
char* search_the_list(struct node *head, char *name)
{
 struct node *n;
 n = head;
 while (n) {
  if (strcasecmp(n->name,name)==0)
   return n->offset;
  n = n->next;
 }
 return 0;
}

canonical_original_code:
char *search_the_list(struct node *head, char *name)
{
 struct node *n;
 n = head;
 while (n) {
  if (strcasecmp(n->name,name)==0)
   return n->offset;
  n = n->next;
 }
 return 0;
}

variable_types: struct node { char *offset; char *name; struct node *next; } *

variable_types:
name
char *

return_type: char *


decompiled_code:
__int64 __fastcall delete_list(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rsi
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 16);
result = qm_free(mem_block, v2);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rsi
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 16);
result = qm_free(mem_block, v2);
}
while ( v1 );
}
return result;
}

original_code:
void delete_list(struct node* head)
{
 struct node *n;
;
 while (head) {
  n=head->next;
  qm_free(mem_block, (head));
  head = n;
 }
}

canonical_original_code:
void delete_list(struct node *head)
{
 struct node *n;
;
 while (head) {
  n=head->next;
  qm_free(mem_block, (head));
  head = n;
 }
}

user_defined_types: struct node { char *offset; char *name; struct node *next; }


decompiled_code:
__int64 __fastcall cnt_cbk_wrapper(__int64 a1, __int64 (*a2)(void))
{
return a2();
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 (*a2)(void))
{
return a2();
}

original_code:
static counter_val_t cnt_cbk_wrapper(counter_handle_t h, void* param)
{
 stat_function k_stat_f;
 k_stat_f = param;
 return k_stat_f();
}

canonical_original_code:
static long cnt_cbk_wrapper(struct counter_handle_s h, void *param)
{
 long (*k_stat_f)();
 k_stat_f = param;
 return k_stat_f();
}

variable_types: struct counter_handle_s { unsigned short id; }

return_type: long


decompiled_code:
__int64 __fastcall register_stat(const char *a1, const char *a2, _QWORD *a3, char a4)
{
unsigned int v5; // er12
int v6; // eax
int v8; // eax
const char *v9; // r15
unsigned int v10; // eax
const char *v11; // r15
unsigned int v12; // eax
__int16 v13[29]; // [rsp+Eh] [rbp-3Ah] BYREF

if ( a3 == 0LL || a2 == 0LL || !a1 )
{
if ( (int)get_debug_level("core", 4LL) >= -4 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967292LL);
v11 = (const char *)*((_QWORD *)&log_level_info + 2);
v12 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid parameters (%p, %p, %p)\n",
process_no,
v12,
v11,
"<core> [kstats_wrapper.c:58]: ",
"register_stat",
a1,
a2,
a3);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 6) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid parameters (%p, %p, %p)\n",
*((const char **)&log_level_info + 2),
"<core> [kstats_wrapper.c:58]: ",
"register_stat",
a1,
a2,
a3);
}
--dprint_crit;
}
return (unsigned int)-1;
}
v5 = a4 & 8;
if ( (a4 & 8) != 0 )
{
v8 = counter_register(v13, a1, a2, a4 & 1, cnt_cbk_wrapper, a3, "kamailio statistic (no description)", 0LL);
if ( v8 >= 0 )
return 0;
if ( v8 != -2 || (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return (unsigned int)-1;
LABEL_15:
++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(): counter %s.%s already registered\n",
process_no,
v10,
v9,
"<core> [kstats_wrapper.c:73]: ",
"register_stat",
a1,
a2);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): counter %s.%s already registered\n",
*((const char **)&log_level_info + 8),
"<core> [kstats_wrapper.c:73]: ",
"register_stat",
a1,
a2);
}
--dprint_crit;
if ( v5 )
return (unsigned int)-1;
LABEL_10:
*a3 = 0LL;
return (unsigned int)-1;
}
v6 = counter_register(v13, a1, a2, a4 & 1, 0LL, 0LL, "kamailio statistic (no description)", 0LL);
if ( v6 < 0 )
{
if ( v6 != -2 || (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
goto LABEL_10;
goto LABEL_15;
}
*a3 = (unsigned __int16)v13[0];
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, const char *a2, _QWORD *a3, char a4)
{
unsigned int v5; // er12
int v6; // eax
int v8; // eax
const char *v9; // r15
unsigned int v10; // eax
const char *v11; // r15
unsigned int v12; // eax
__int16 v13[29]; // [rsp+Eh] [rbp-3Ah] BYREF

if ( a3 == 0LL || a2 == 0LL || !a1 )
{
if ( (int)get_debug_level("core", 4LL) >= -4 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967292LL);
v11 = (const char *)*((_QWORD *)&log_level_info + 2);
v12 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid parameters (%p, %p, %p)\n",
process_no,
v12,
v11,
"<core> [kstats_wrapper.c:58]: ",
"register_stat",
a1,
a2,
a3);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 6) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid parameters (%p, %p, %p)\n",
*((const char **)&log_level_info + 2),
"<core> [kstats_wrapper.c:58]: ",
"register_stat",
a1,
a2,
a3);
}
--dprint_crit;
}
return (unsigned int)-1;
}
v5 = a4 & 8;
if ( (a4 & 8) != 0 )
{
v8 = counter_register(v13, a1, a2, a4 & 1, cnt_cbk_wrapper, a3, "kamailio statistic (no description)", 0LL);
if ( v8 >= 0 )
return 0;
if ( v8 != -2 || (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return (unsigned int)-1;
LABEL_15:
++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(): counter %s.%s already registered\n",
process_no,
v10,
v9,
"<core> [kstats_wrapper.c:73]: ",
"register_stat",
a1,
a2);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): counter %s.%s already registered\n",
*((const char **)&log_level_info + 8),
"<core> [kstats_wrapper.c:73]: ",
"register_stat",
a1,
a2);
}
--dprint_crit;
if ( v5 )
return (unsigned int)-1;
LABEL_10:
*a3 = 0LL;
return (unsigned int)-1;
}
v6 = counter_register(v13, a1, a2, a4 & 1, 0LL, 0LL, "kamailio statistic (no description)", 0LL);
if ( v6 < 0 )
{
if ( v6 != -2 || (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
goto LABEL_10;
goto LABEL_15;
}
*a3 = (unsigned __int16)v13[0];
return v5;
}

original_code:
int register_stat( char *module, char *name, stat_var **pvar, int flags)
{
 int cnt_flags;
 counter_handle_t h;
 int ret;
 if (module == 0 || name == 0 || pvar == 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-4)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-4)) >= -5) && (((-4)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "invalid parameters (%p, %p, %p)\n", process_no, my_pid(), (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-4)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "invalid parameters (%p, %p, %p)\n", (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid parameters (%p, %p, %p)\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-4))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid parameters (%p, %p, %p)\n", ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid parameters (%p, %p, %p)\n", ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); } } (dprint_crit--); } } while(0);
  return -1;
 }
 cnt_flags = (flags & 1) ? 1 : 0;
 if (flags & 8)
  ret = counter_register(&h, module, name, cnt_flags,
     cnt_cbk_wrapper,(stat_function)pvar,
     "kamailio statistic (no description)",
     0);
 else
  ret = counter_register(&h, module, name, cnt_flags, 0, 0,
     "kamailio statistic (no description)", 0);
 if (ret < 0) {
  if (ret == -2)
   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(): " "counter %s.%s already registered\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); 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(): " "counter %s.%s already registered\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "counter %s.%s already registered\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); 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(): " "counter %s.%s already registered\n", ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "counter %s.%s already registered\n", ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); } } (dprint_crit--); } } while(0);
  goto error;
 }
 if (!(flags & 8))
  *pvar = (void*)(unsigned long)h.id;
 return 0;
error:
 if (!(flags & 8))
  *pvar = 0;
 return -1;
}

canonical_original_code:
int register_stat(char *module, char *name, void **pvar, int flags)
{
 int cnt_flags;
 struct counter_handle_s h;
 int ret;
 if (module == 0 || name == 0 || pvar == 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-4)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-4)) >= -5) && (((-4)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "invalid parameters (%p, %p, %p)\n", process_no, my_pid(), (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-4)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "invalid parameters (%p, %p, %p)\n", (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid parameters (%p, %p, %p)\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-4))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid parameters (%p, %p, %p)\n", ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid parameters (%p, %p, %p)\n", ("<core> [" "kstats_wrapper.c" ":" "58" "]: ") , __func__, module, name, pvar); } } (dprint_crit--); } } while(0);
  return -1;
 }
 cnt_flags = (flags & 1) ? 1 : 0;
 if (flags & 8)
  ret = counter_register(&h, module, name, cnt_flags,
     cnt_cbk_wrapper,(long (*)())pvar,
     "kamailio statistic (no description)",
     0);
 else
  ret = counter_register(&h, module, name, cnt_flags, 0, 0,
     "kamailio statistic (no description)", 0);
 if (ret < 0) {
  if (ret == -2)
   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(): " "counter %s.%s already registered\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); 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(): " "counter %s.%s already registered\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "counter %s.%s already registered\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); 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(): " "counter %s.%s already registered\n", ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "counter %s.%s already registered\n", ("<core> [" "kstats_wrapper.c" ":" "73" "]: ") , __func__, module, name); } } (dprint_crit--); } } while(0);
  goto error;
 }
 if (!(flags & 8))
  *pvar = (void *)(unsigned long)h.id;
 return 0;
error:
 if (!(flags & 8))
  *pvar = 0;
 return -1;
}

variable_types:
module
char *

variable_types:
pvar
void **

variable_types: flags int

variable_types: ret int

user_defined_types: struct counter_handle_s { unsigned short id; }


decompiled_code:
__int64 __fastcall register_module_stats(const char *a1, const char **a2)
{
const char **v3; // rbx
__int64 result; // rax
const char *v5; // r13
const char *v6; // rbx
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
__int64 v9; // rcx
const char *v10; // r8
const char *v11; // r9
const char *v12; // r12
unsigned int v13; // eax
struct _IO_FILE *v14; // rdi
__int64 v15; // rdx
__int64 v16; // rcx
const char *v17; // r8
const char *v18; // [rsp-10h] [rbp-38h]
const char *v19; // [rsp+0h] [rbp-28h]
const char *v20; // [rsp+8h] [rbp-20h]
const char *v21; // [rsp+10h] [rbp-18h]

if ( a1 && *a1 )
{
v3 = a2;
if ( a2 )
{
while ( *v3 )
{
if ( (int)register_stat(a1, *v3, v3[2], *((_DWORD *)v3 + 2)) < 0 )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
goto LABEL_14;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = *v3;
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to add statistic %s.%s\n",
process_no,
v7,
v6,
"<core> [kstats_wrapper.c:99]: ",
"register_module_stats",
a1,
v5);
if ( log_color )
dprint_color_reset(
v8,
"%2d(%d) %s: %s%s(): failed to add statistic %s.%s\n",
log_color,
v9,
v10,
v11,
v19,
v20,
v21);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to add statistic %s.%s\n",
*((const char **)&log_level_info + 8),
"<core> [kstats_wrapper.c:99]: ",
"register_module_stats",
a1,
*v3);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
return result;
}
v3 += 3;
}
}
result = 0LL;
}
else if ( (int)get_debug_level("core", 4LL) < -4 || dprint_crit )
{
LABEL_14:
result = 0xFFFFFFFFLL;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967292LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 2);
v13 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): null or empty module name\n",
process_no,
v13,
v12,
"<core> [kstats_wrapper.c:90]: ",
"register_module_stats");
if ( log_color )
dprint_color_reset(v14, "%2d(%d) %s: %s%s(): null or empty module name\n", v15, v16, v17, v18, v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 6) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null or empty module name\n",
*((const char **)&log_level_info + 2),
"<core> [kstats_wrapper.c:90]: ",
"register_module_stats");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, const char **a2)
{
const char **v3; // rbx
__int64 result; // rax
const char *v5; // r13
const char *v6; // rbx
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
__int64 v9; // rcx
const char *v10; // r8
const char *v11; // r9
const char *v12; // r12
unsigned int v13; // eax
struct _IO_FILE *v14; // rdi
__int64 v15; // rdx
__int64 v16; // rcx
const char *v17; // r8
const char *v18; // [rsp-10h] [rbp-38h]
const char *v19; // [rsp+0h] [rbp-28h]
const char *v20; // [rsp+8h] [rbp-20h]
const char *v21; // [rsp+10h] [rbp-18h]

if ( a1 && *a1 )
{
v3 = a2;
if ( a2 )
{
while ( *v3 )
{
if ( (int)func1(a1, *v3, v3[2], *((_DWORD *)v3 + 2)) < 0 )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
goto LABEL_14;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = *v3;
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to add statistic %s.%s\n",
process_no,
v7,
v6,
"<core> [kstats_wrapper.c:99]: ",
"register_module_stats",
a1,
v5);
if ( log_color )
dprint_color_reset(
v8,
"%2d(%d) %s: %s%s(): failed to add statistic %s.%s\n",
log_color,
v9,
v10,
v11,
v19,
v20,
v21);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to add statistic %s.%s\n",
*((const char **)&log_level_info + 8),
"<core> [kstats_wrapper.c:99]: ",
"register_module_stats",
a1,
*v3);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
return result;
}
v3 += 3;
}
}
result = 0LL;
}
else if ( (int)get_debug_level("core", 4LL) < -4 || dprint_crit )
{
LABEL_14:
result = 0xFFFFFFFFLL;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967292LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 2);
v13 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): null or empty module name\n",
process_no,
v13,
v12,
"<core> [kstats_wrapper.c:90]: ",
"register_module_stats");
if ( log_color )
dprint_color_reset(v14, "%2d(%d) %s: %s%s(): null or empty module name\n", v15, v16, v17, v18, v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 6) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null or empty module name\n",
*((const char **)&log_level_info + 2),
"<core> [kstats_wrapper.c:90]: ",
"register_module_stats");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
return result;
}

original_code:
int register_module_stats(char *module, stat_export_t *stats)
{
 if (module == 0 || *module == 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-4)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-4)) >= -5) && (((-4)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "null or empty module name\n", process_no, my_pid(), (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-4)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "null or empty module name\n", (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null or empty module name\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-4))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null or empty module name\n", ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null or empty module name\n", ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 if (stats == 0 || stats[0].name == 0)
  return 0;
 for (; stats->name; stats++)
  if (register_stat(module, stats->name, stats->stat_pointer,
       stats->flags) < 0 ){
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "failed to add statistic %s.%s\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "failed to add statistic %s.%s\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to add statistic %s.%s\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add statistic %s.%s\n", ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add statistic %s.%s\n", ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); } } (dprint_crit--); } } while(0);
   goto error;
  }
 return 0;
error:
 return -1;
}

canonical_original_code:
int register_module_stats(char *module, struct stat_export_s *stats)
{
 if (module == 0 || *module == 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-4)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-4)) >= -5) && (((-4)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "null or empty module name\n", process_no, my_pid(), (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-4)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "null or empty module name\n", (log_level_info[((-4)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-4)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null or empty module name\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-4))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null or empty module name\n", ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null or empty module name\n", ("<core> [" "kstats_wrapper.c" ":" "90" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 if (stats == 0 || stats[0].name == 0)
  return 0;
 for (; stats->name; stats++)
  if (register_stat(module, stats->name, stats->stat_pointer,
       stats->flags) < 0 ){
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "failed to add statistic %s.%s\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "failed to add statistic %s.%s\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to add statistic %s.%s\n", process_no, my_pid(), ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add statistic %s.%s\n", ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to add statistic %s.%s\n", ("<core> [" "kstats_wrapper.c" ":" "99" "]: ") , __func__, module, stats->name); } } (dprint_crit--); } } while(0);
   goto error;
  }
 return 0;
error:
 return -1;
}

variable_types: struct stat_export_s { char *name; int flags; void **stat_pointer; } *


decompiled_code:
// attributes: thunk
__int64 __fastcall set_mod_param(const char *a1, const char *a2, int a3, const __m128i *a4)
{
return set_mod_param_regex(a1, a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, const char *a2, int a3, const __m128i *a4)
{
return func0(a1, a2, a3, a4);
}

original_code:
int set_mod_param(char* _mod, char* _name, modparam_t _type, void* _val)
{
 return set_mod_param_regex(_mod, _name, _type, _val);
}

canonical_original_code:
int set_mod_param(char *_mod, char *_name, unsigned int _type, void *_val)
{
 return set_mod_param_regex(_mod, _name, _type, _val);
}