decompiled_code:
__int64 __fastcall preset_dialog_route(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
int v3; // ebp
const char *v5; // r12
unsigned int v6; // eax
const char *v7; // rbp
unsigned int v8; // eax
const char *v9; // r12
unsigned int v10; // eax
const char *v11; // rbx
unsigned int v12; // eax
const char *v13; // r12
unsigned int v14; // eax
const char *v15; // rbp
unsigned int v16; // eax
__int64 v17; // [rsp+0h] [rbp-28h] BYREF
__int64 v18[4]; // [rsp+8h] [rbp-20h] BYREF

v17 = 0LL;
if ( !a1 || (v2 = is_str_empty(a2)) != 0 )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): bad parameters\n",
process_no,
v6,
v5,
"dialog [dlg_utils.c:16]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): bad parameters\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:16]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else if ( *(_DWORD *)(a1 + 164) )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Dialog is not in DLG_NEW state\n",
process_no,
v8,
v7,
"dialog [dlg_utils.c:20]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Dialog is not in DLG_NEW state\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:20]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else if ( (int)parse_rr_body(*(_QWORD *)a2, *(unsigned int *)(a2 + 8), &v17) < 0 )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't parse given route\n",
process_no,
v10,
v9,
"dialog [dlg_utils.c:25]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't parse given route\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:25]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else if ( v17 )
{
v18[0] = *(_QWORD *)(a1 + 168);
*(_QWORD *)(a1 + 168) = 0LL;
v3 = shm_duplicate_rr(a1 + 168);
if ( v17 )
free_rr(&v17);
if ( v3 < 0 )
{
*(_QWORD *)(a1 + 168) = v18[0];
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't duplicate route\n",
process_no,
v14,
v13,
"dialog [dlg_utils.c:41]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't duplicate route\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:41]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else
{
if ( v18[0] )
shm_free_rr(v18);
if ( tmb[27](a1) < 0 )
{
v2 = -2;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v15 = (const char *)*((_QWORD *)&log_level_info + 8);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Error while calculating hooks\n",
process_no,
v16,
v15,
"dialog [dlg_utils.c:50]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Error while calculating hooks\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:50]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -2;
}
}
}
}
else
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v11 = (const char *)*((_QWORD *)&log_level_info + 8);
v12 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): empty route\n",
process_no,
v12,
v11,
"dialog [dlg_utils.c:30]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): empty route\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:30]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
int v3; // ebp
const char *v5; // r12
unsigned int v6; // eax
const char *v7; // rbp
unsigned int v8; // eax
const char *v9; // r12
unsigned int v10; // eax
const char *v11; // rbx
unsigned int v12; // eax
const char *v13; // r12
unsigned int v14; // eax
const char *v15; // rbp
unsigned int v16; // eax
__int64 v17; // [rsp+0h] [rbp-28h] BYREF
__int64 v18[4]; // [rsp+8h] [rbp-20h] BYREF

v17 = 0LL;
if ( !a1 || (v2 = is_str_empty(a2)) != 0 )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): bad parameters\n",
process_no,
v6,
v5,
"dialog [dlg_utils.c:16]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): bad parameters\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:16]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else if ( *(_DWORD *)(a1 + 164) )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Dialog is not in DLG_NEW state\n",
process_no,
v8,
v7,
"dialog [dlg_utils.c:20]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Dialog is not in DLG_NEW state\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:20]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else if ( (int)parse_rr_body(*(_QWORD *)a2, *(unsigned int *)(a2 + 8), &v17) < 0 )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't parse given route\n",
process_no,
v10,
v9,
"dialog [dlg_utils.c:25]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't parse given route\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:25]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else if ( v17 )
{
v18[0] = *(_QWORD *)(a1 + 168);
*(_QWORD *)(a1 + 168) = 0LL;
v3 = shm_duplicate_rr(a1 + 168);
if ( v17 )
free_rr(&v17);
if ( v3 < 0 )
{
*(_QWORD *)(a1 + 168) = v18[0];
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't duplicate route\n",
process_no,
v14,
v13,
"dialog [dlg_utils.c:41]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't duplicate route\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:41]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
else
{
if ( v18[0] )
shm_free_rr(v18);
if ( tmb[27](a1) < 0 )
{
v2 = -2;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v15 = (const char *)*((_QWORD *)&log_level_info + 8);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Error while calculating hooks\n",
process_no,
v16,
v15,
"dialog [dlg_utils.c:50]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Error while calculating hooks\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:50]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -2;
}
}
}
}
else
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v11 = (const char *)*((_QWORD *)&log_level_info + 8);
v12 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): empty route\n",
process_no,
v12,
v11,
"dialog [dlg_utils.c:30]: ",
"preset_dialog_route");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): empty route\n",
*((const char **)&log_level_info + 8),
"dialog [dlg_utils.c:30]: ",
"preset_dialog_route");
}
--dprint_crit;
v2 = -1;
}
}
return v2;
}

original_code:
int preset_dialog_route(dlg_t* dialog, str *route)
{
 rr_t *old_r, *r = ((void *)0);
 int res;
 if ((!dialog) || (is_str_empty(route))) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "bad parameters\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __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(): " "bad parameters\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "bad parameters\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __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(): " "bad parameters\n", ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "bad parameters\n", ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (dialog->state != DLG_NEW) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "Dialog is not in DLG_NEW state\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __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(): " "Dialog is not in DLG_NEW state\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Dialog is not in DLG_NEW state\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __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(): " "Dialog is not in DLG_NEW state\n", ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Dialog is not in DLG_NEW state\n", ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (parse_rr_body(route->s, route->len, &r) < 0) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't parse given route\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __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(): " "can't parse given route\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't parse given route\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __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(): " "can't parse given route\n", ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't parse given route\n", ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (!r) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "empty route\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __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(): " "empty route\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "empty route\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __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(): " "empty route\n", ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty route\n", ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 old_r = dialog->route_set;
 dialog->route_set = ((void *)0);
 res = shm_duplicate_rr(&dialog->route_set, r);
 if (r) free_rr(&r);
 if (res < 0) {
  dialog->route_set = old_r;
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't duplicate route\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __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(): " "can't duplicate route\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't duplicate route\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __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(): " "can't duplicate route\n", ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't duplicate route\n", ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (old_r) shm_free_rr(&old_r);
 res = tmb.calculate_hooks(dialog);
 if (res < 0) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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 while calculating hooks\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __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 while calculating hooks\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Error while calculating hooks\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __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 while calculating hooks\n", ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Error while calculating hooks\n", ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 return 0;
}

canonical_original_code:
int preset_dialog_route(struct dlg *dialog, struct _str *route)
{
 struct rr *old_r; struct rr *r = ((void *)0);
 int res;
 if ((!dialog) || (is_str_empty(route))) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "bad parameters\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __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(): " "bad parameters\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "bad parameters\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __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(): " "bad parameters\n", ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "bad parameters\n", ("dialog" " [" "dlg_utils.c" ":" "16" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (dialog->state != DLG_NEW) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "Dialog is not in DLG_NEW state\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __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(): " "Dialog is not in DLG_NEW state\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Dialog is not in DLG_NEW state\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __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(): " "Dialog is not in DLG_NEW state\n", ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Dialog is not in DLG_NEW state\n", ("dialog" " [" "dlg_utils.c" ":" "20" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (parse_rr_body(route->s, route->len, &r) < 0) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't parse given route\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __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(): " "can't parse given route\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't parse given route\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __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(): " "can't parse given route\n", ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't parse given route\n", ("dialog" " [" "dlg_utils.c" ":" "25" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (!r) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "empty route\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __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(): " "empty route\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "empty route\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __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(): " "empty route\n", ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty route\n", ("dialog" " [" "dlg_utils.c" ":" "30" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 old_r = dialog->route_set;
 dialog->route_set = ((void *)0);
 res = shm_duplicate_rr(&dialog->route_set, r);
 if (r) free_rr(&r);
 if (res < 0) {
  dialog->route_set = old_r;
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't duplicate route\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __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(): " "can't duplicate route\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't duplicate route\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __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(): " "can't duplicate route\n", ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't duplicate route\n", ("dialog" " [" "dlg_utils.c" ":" "41" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (old_r) shm_free_rr(&old_r);
 res = tmb.calculate_hooks(dialog);
 if (res < 0) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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 while calculating hooks\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __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 while calculating hooks\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Error while calculating hooks\n", process_no, my_pid(), ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __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 while calculating hooks\n", ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Error while calculating hooks\n", ("dialog" " [" "dlg_utils.c" ":" "50" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 return 0;
}

variable_types: struct dlg { struct dlg_id { struct _str { char *s; int len; } call_id; struct _str rem_tag; struct _str loc_tag; } id; struct dlg_seq { unsigned int value; unsigned char is_set; } loc_seq; struct dlg_seq rem_seq; struct _str loc_uri; struct _str rem_uri; struct _str rem_target; struct _str dst_uri; struct _str loc_dname; struct _str rem_dname; unsigned char secure; enum dlg_state { DLG_NEW=0, DLG_EARLY=1, DLG_CONFIRMED=2, DLG_DESTROYED=3 } state; struct rr { struct name_addr { struct _str name; struct _str uri; int len; } nameaddr; struct param { enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 } type; struct _str name; struct _str body; int len; struct param *next; } *r2; struct param *params; int len; struct rr *next; } *route_set; struct dlg_hooks { struct _str ru; struct _str nh; struct _str *request_uri; struct _str *next_hop; struct rr *first_route; struct _str *last_route; } hooks; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *send_sock; } *

variable_types:
route
struct _str *

variable_types: struct rr { struct name_addr { struct _str { char *s; int len; } name; struct _str uri; int len; } nameaddr; struct param { enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 } type; struct _str name; struct _str body; int len; struct param *next; } *r2; struct param *params; int len; struct rr *next; } *

variable_types: res int

user_defined_types: struct dlg { struct dlg_id id; struct dlg_seq loc_seq; struct dlg_seq rem_seq; struct _str loc_uri; struct _str rem_uri; struct _str rem_target; struct _str dst_uri; struct _str loc_dname; struct _str rem_dname; unsigned char secure; enum dlg_state state; struct rr *route_set; struct dlg_hooks hooks; struct socket_info *send_sock; }

user_defined_types: struct rr { struct name_addr nameaddr; struct param *r2; struct param *params; int len; struct rr *next; }

user_defined_types: struct dlg_id { struct _str call_id; struct _str rem_tag; struct _str loc_tag; }

user_defined_types: struct param { enum ptype type; struct _str name; struct _str body; int len; struct param *next; }


repo: virtualolson/who

decompiled_code:
__int64 __fastcall hash_dlg_id(__int64 a1)
{
const char *v1; // rdx
const char *v2; // r9
const char *v3; // r8
unsigned int v4; // eax
char v6[520]; // [rsp-208h] [rbp-208h] BYREF

if ( !a1 )
return 0LL;
v1 = (const char *)&LC19;
if ( *(_QWORD *)(a1 + 32) )
v1 = *(const char **)(a1 + 32);
v2 = *(const char **)(a1 + 16);
if ( !v2 )
v2 = (const char *)&LC19;
v3 = *(const char **)a1;
if ( !*(_QWORD *)a1 )
v3 = (const char *)&LC19;
v4 = snprintf(
v6,
0x200uLL,
"%.*s%.*s%.*s",
*(_DWORD *)(a1 + 8),
v3,
*(_DWORD *)(a1 + 24),
v2,
*(_DWORD *)(a1 + 40),
v1);
return rshash(v6, v4);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
const char *v1; // rdx
const char *v2; // r9
const char *v3; // r8
unsigned int v4; // eax
char v6[520]; // [rsp-208h] [rbp-208h] BYREF

if ( !a1 )
return 0LL;
v1 = (const char *)&LC19;
if ( *(_QWORD *)(a1 + 32) )
v1 = *(const char **)(a1 + 32);
v2 = *(const char **)(a1 + 16);
if ( !v2 )
v2 = (const char *)&LC19;
v3 = *(const char **)a1;
if ( !*(_QWORD *)a1 )
v3 = (const char *)&LC19;
v4 = snprintf(
v6,
0x200uLL,
"%.*s%.*s%.*s",
*(_DWORD *)(a1 + 8),
v3,
*(_DWORD *)(a1 + 24),
v2,
*(_DWORD *)(a1 + 40),
v1);
return rshash(v6, v4);
}

original_code:
unsigned int hash_dlg_id(dlg_id_t *id)
{
 char tmp[512];
 int len;
 if (!id) return 0;
 len = snprintf(tmp, sizeof(tmp), "%.*s%.*s%.*s",
   (id->call_id).len,((id->call_id).s ? (id->call_id).s : ""),
   (id->rem_tag).len,((id->rem_tag).s ? (id->rem_tag).s : ""),
   (id->loc_tag).len,((id->loc_tag).s ? (id->loc_tag).s : ""));
 return rshash(tmp, len);
}

canonical_original_code:
unsigned int hash_dlg_id(struct dlg_id *id)
{
 char tmp[512];
 int len;
 if (!id) return 0;
 len = snprintf(tmp, sizeof(tmp), "%.*s%.*s%.*s",
   (id->call_id).len,((id->call_id).s ? (id->call_id).s : ""),
   (id->rem_tag).len,((id->rem_tag).s ? (id->rem_tag).s : ""),
   (id->loc_tag).len,((id->loc_tag).s ? (id->loc_tag).s : ""));
 return rshash(tmp, len);
}

variable_types: struct dlg_id { struct _str { char *s; int len; } call_id; struct _str rem_tag; struct _str loc_tag; } *

variable_types:
tmp
char [512]

variable_types: len int

return_type: unsigned int


decompiled_code:
__int64 __fastcall cmp_dlg_ids(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // edx
int v4; // ecx

if ( !a1 )
return (unsigned int)-(a2 == 0);
result = 1LL;
if ( a2 )
{
v3 = ((__int64 (*)(void))str_case_equals)();
result = 1LL;
if ( !v3 )
{
v4 = str_case_equals(a1 + 16, a2 + 16);
result = 1LL;
if ( !v4 )
result = (unsigned int)str_case_equals(a1 + 32, a2 + 32) != 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // edx
int v4; // ecx

if ( !a1 )
return (unsigned int)-(a2 == 0);
result = 1LL;
if ( a2 )
{
v3 = ((__int64 (*)(void))str_case_equals)();
result = 1LL;
if ( !v3 )
{
v4 = str_case_equals(a1 + 16, a2 + 16);
result = 1LL;
if ( !v4 )
result = (unsigned int)str_case_equals(a1 + 32, a2 + 32) != 0;
}
}
return result;
}

original_code:
int cmp_dlg_ids(dlg_id_t *a, dlg_id_t *b)
{
 if (!a) {
  if (!b) return -1;
  else return 0;
 }
 if (!b) return 1;
 if (str_case_equals(&a->call_id, &b->call_id) != 0) return 1;
 if (str_case_equals(&a->rem_tag, &b->rem_tag) != 0) return 1;
 if (str_case_equals(&a->loc_tag, &b->loc_tag) != 0) return 1;
 return 0;
}

canonical_original_code:
int cmp_dlg_ids(struct dlg_id *a, struct dlg_id *b)
{
 if (!a) {
  if (!b) return -1;
  else return 0;
 }
 if (!b) return 1;
 if (str_case_equals(&a->call_id, &b->call_id) != 0) return 1;
 if (str_case_equals(&a->rem_tag, &b->rem_tag) != 0) return 1;
 if (str_case_equals(&a->loc_tag, &b->loc_tag) != 0) return 1;
 return 0;
}

variable_types:
b
struct dlg_id *

return_type: int


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

canonical_decompiled_code:
__int64 __fastcall 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 func2(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ebp
int v3; // ebp

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

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

return_type: void


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 func3(volatile __int32 *a1)
{
__int64 result; // rax

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

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

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


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

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

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

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

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

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

variable_types:
size
unsigned int

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 __fastcall vector_add(int *a1, const void *a2)
{
int v3; // eax
int v4; // er13
void *v5; // rax
void *v6; // r12
const void *v7; // rsi

v3 = a1[2];
if ( a1[1] < v3 )
{
LABEL_7:
memcpy((void *)(*((_QWORD *)a1 + 2) + a1[1] * *a1), a2, *a1);
++a1[1];
return 0LL;
}
v4 = a1[3] + v3;
if ( v3 >= v4 )
return 0xFFFFFFFFLL;
v5 = (void *)shm_malloc(*a1 * v4);
v6 = v5;
if ( v5 )
{
v7 = (const void *)*((_QWORD *)a1 + 2);
if ( v7 )
{
memcpy(v5, v7, a1[2] * *a1);
futex_get(mem_lock);
qm_free(shm_block, *((_QWORD *)a1 + 2));
futex_release(mem_lock);
}
*((_QWORD *)a1 + 2) = v6;
a1[2] = v4;
goto LABEL_7;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1, const void *a2)
{
int v3; // eax
int v4; // er13
void *v5; // rax
void *v6; // r12
const void *v7; // rsi

v3 = a1[2];
if ( a1[1] < v3 )
{
LABEL_7:
memcpy((void *)(*((_QWORD *)a1 + 2) + a1[1] * *a1), a2, *a1);
++a1[1];
return 0LL;
}
v4 = a1[3] + v3;
if ( v3 >= v4 )
return 0xFFFFFFFFLL;
v5 = (void *)func4(*a1 * v4);
v6 = v5;
if ( v5 )
{
v7 = (const void *)*((_QWORD *)a1 + 2);
if ( v7 )
{
memcpy(v5, v7, a1[2] * *a1);
func2(mem_lock);
qm_free(shm_block, *((_QWORD *)a1 + 2));
func3(mem_lock);
}
*((_QWORD *)a1 + 2) = v6;
a1[2] = v4;
goto LABEL_7;
}
return 0xFFFFFFFFLL;
}

original_code:
int vector_add(vector_t *vector, void *element)
{
 if (vector->element_count >= vector->allocated_count) {
  void *new_data;
  int new_size = vector->allocated_count + vector->allocation_count;
  if (new_size <= vector->allocated_count) return -1;
  new_data = (void *)shm_malloc(vector->element_size * new_size);
  if (!new_data) return -1;
  if (vector->data) {
   memcpy(new_data, vector->data,
     vector->element_size * vector->allocated_count);
   do { futex_get(mem_lock); qm_free(shm_block, (vector->data)); futex_release(mem_lock); }while(0);
  }
  vector->data = new_data;
  vector->allocated_count = new_size;
 }
 memcpy(vector->data + (vector->element_count * vector->element_size),
   element, vector->element_size);
 vector->element_count++;
 return 0;
}

canonical_original_code:
int vector_add(struct vector_t *vector, void *element)
{
 if (vector->element_count >= vector->allocated_count) {
  void *new_data;
  int new_size = vector->allocated_count + vector->allocation_count;
  if (new_size <= vector->allocated_count) return -1;
  new_data = (void *)shm_malloc(vector->element_size * new_size);
  if (!new_data) return -1;
  if (vector->data) {
   memcpy(new_data, vector->data,
     vector->element_size * vector->allocated_count);
   do { futex_get(mem_lock); qm_free(shm_block, (vector->data)); futex_release(mem_lock); }while(0);
  }
  vector->data = new_data;
  vector->allocated_count = new_size;
 }
 memcpy(vector->data + (vector->element_count * vector->element_size),
   element, vector->element_size);
 vector->element_count++;
 return 0;
}

variable_types: struct vector_t { int element_size; int element_count; int allocated_count; int allocation_count; void *data; } *

variable_types:
element
void *


original_code:
int vector_remove(vector_t *vector, int index)
{
 int cnt;
 if (index >= vector->element_count) return -1;
 cnt = vector->element_count - index - 1;
 if (cnt > 0) {
  memmove(vector->data + (index * vector->element_size),
   vector->data + ((index + 1) * vector->element_size),
   cnt * vector->element_size);
 }
 vector->element_count--;
 return 0;
}

canonical_original_code:
int vector_remove(struct vector_t *vector, int index)
{
 int cnt;
 if (index >= vector->element_count) return -1;
 cnt = vector->element_count - index - 1;
 if (cnt > 0) {
  memmove(vector->data + (index * vector->element_size),
   vector->data + ((index + 1) * vector->element_size),
   cnt * vector->element_size);
 }
 vector->element_count--;
 return 0;
}

variable_types: index int

variable_types: cnt int

user_defined_types: struct vector_t { int element_size; int element_count; int allocated_count; int allocation_count; void *data; }


decompiled_code:
__int64 __fastcall vector_get(int *a1, int a2, void *a3)
{
if ( a1[1] <= a2 )
return 0xFFFFFFFFLL;
memcpy(a3, (const void *)(*((_QWORD *)a1 + 2) + a2 * *a1), *a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(int *a1, int a2, void *a3)
{
if ( a1[1] <= a2 )
return 0xFFFFFFFFLL;
memcpy(a3, (const void *)(*((_QWORD *)a1 + 2) + a2 * *a1), *a1);
return 0LL;
}

original_code:
int vector_get(vector_t *vector, int index, void *element_dst)
{
 if (index >= vector->element_count) return -1;
 memcpy(element_dst, vector->data + (index * vector->element_size), vector->element_size);
 return 0;
}

canonical_original_code:
int vector_get(struct vector_t *vector, int index, void *element_dst)
{
 if (index >= vector->element_count) return -1;
 memcpy(element_dst, vector->data + (index * vector->element_size), vector->element_size);
 return 0;
}


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

result = 0LL;
if ( *(_DWORD *)(a1 + 4) > a2 )
result = *(_QWORD *)(a1 + 16) + *(_DWORD *)a1 * a2;
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1 + 4) > a2 )
result = *(_QWORD *)(a1 + 16) + *(_DWORD *)a1 * a2;
return result;
}

original_code:
void* vector_get_ptr(vector_t *vector, int index)
{
 if (index >= vector->element_count) return ((void *)0);
 else return vector->data + (index * vector->element_size);
}

canonical_original_code:
void *vector_get_ptr(struct vector_t *vector, int index)
{
 if (index >= vector->element_count) return ((void *)0);
 else return vector->data + (index * vector->element_size);
}


decompiled_code:
__int64 __fastcall vector_destroy(__int64 a1)
{
__int64 result; // rax

if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
{
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 16));
result = futex_release(mem_lock);
}
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)(a1 + 12) = 0;
*(_DWORD *)(a1 + 4) = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax

if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
{
func2(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 16));
result = func3(mem_lock);
}
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)(a1 + 12) = 0;
*(_DWORD *)(a1 + 4) = 0;
}
return result;
}

original_code:
void vector_destroy(vector_t *vector)
{
 if (vector) {
  if (vector->data) do { futex_get(mem_lock); qm_free(shm_block, (vector->data)); futex_release(mem_lock); }while(0);
  vector->data = ((void *)0);
  vector->allocation_count = 0;
  vector->element_count = 0;
 }
}

canonical_original_code:
void vector_destroy(struct vector_t *vector)
{
 if (vector) {
  if (vector->data) do { futex_get(mem_lock); qm_free(shm_block, (vector->data)); futex_release(mem_lock); }while(0);
  vector->data = ((void *)0);
  vector->allocation_count = 0;
  vector->element_count = 0;
 }
}


decompiled_code:
__int64 __fastcall vector_init(__int64 a1, int a2, int a3)
{
__int64 v4; // rax
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
*(_DWORD *)a1 = a2;
*(_DWORD *)(a1 + 4) = 0;
*(_DWORD *)(a1 + 12) = a3;
v4 = shm_malloc(a3 * a2);
*(_QWORD *)(a1 + 16) = v4;
if ( v4 )
{
*(_DWORD *)(a1 + 8) = a3;
result = 0LL;
}
else
{
*(_DWORD *)(a1 + 8) = 0;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2, int a3)
{
__int64 v4; // rax
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
*(_DWORD *)a1 = a2;
*(_DWORD *)(a1 + 4) = 0;
*(_DWORD *)(a1 + 12) = a3;
v4 = func4(a3 * a2);
*(_QWORD *)(a1 + 16) = v4;
if ( v4 )
{
*(_DWORD *)(a1 + 8) = a3;
result = 0LL;
}
else
{
*(_DWORD *)(a1 + 8) = 0;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int vector_init(vector_t *vector, int element_size, int allocation_count)
{
 if (!vector) return -1;
 vector->element_size = element_size;
 vector->element_count = 0;
 vector->allocation_count = allocation_count;
 vector->data = (void *)shm_malloc(element_size * allocation_count);
 if (!vector->data) {
  vector->allocated_count = 0;
  return -1;
 }
 else {
  vector->allocated_count = allocation_count;
  return 0;
 }
}

canonical_original_code:
int vector_init(struct vector_t *vector, int element_size, int allocation_count)
{
 if (!vector) return -1;
 vector->element_size = element_size;
 vector->element_count = 0;
 vector->allocation_count = allocation_count;
 vector->data = (void *)shm_malloc(element_size * allocation_count);
 if (!vector->data) {
  vector->allocated_count = 0;
  return -1;
 }
 else {
  vector->allocated_count = allocation_count;
  return 0;
 }
}


decompiled_code:
__int64 vector_test()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func11()
{
return 0LL;
}

original_code:
int vector_test(void)
{
 return 0;
}

canonical_original_code:
int vector_test()
{
 return 0;
}


decompiled_code:
void sr_core_ert_init()
{
int v0; // eax
const char *v1; // rbx
unsigned int v2; // eax

sr_core_ert_list = 0;
v0 = route_get(&event_rt, "core:receive-parse-error");
sr_core_ert_list = v0;
if ( v0 > 0 && *(_QWORD *)(event_rt + 8LL * v0) )
{
if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): event_route[core:receive-parse-error] is defined\n",
process_no,
v2,
v1,
"<core> [events.c:55]: ",
"sr_core_ert_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_route[core:receive-parse-error] is defined\n",
*((const char **)&log_level_info + 16),
"<core> [events.c:55]: ",
"sr_core_ert_init");
}
--dprint_crit;
}
}
else
{
sr_core_ert_list = -1;
}
}

canonical_decompiled_code:
void func0()
{
int v0; // eax
const char *v1; // rbx
unsigned int v2; // eax

sr_core_ert_list = 0;
v0 = route_get(&event_rt, "core:receive-parse-error");
sr_core_ert_list = v0;
if ( v0 > 0 && *(_QWORD *)(event_rt + 8LL * v0) )
{
if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): event_route[core:receive-parse-error] is defined\n",
process_no,
v2,
v1,
"<core> [events.c:55]: ",
"sr_core_ert_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_route[core:receive-parse-error] is defined\n",
*((const char **)&log_level_info + 16),
"<core> [events.c:55]: ",
"sr_core_ert_init");
}
--dprint_crit;
}
}
else
{
sr_core_ert_list = -1;
}
}

original_code:
void sr_core_ert_init(void)
{
 memset(&_sr_core_ert_list, 0, sizeof(sr_core_ert_t));
 _sr_core_ert_list.init_parse_error = route_get(&event_rt,
           "core:receive-parse-error");
 if(_sr_core_ert_list.init_parse_error<=0
    || event_rt.rlist[_sr_core_ert_list.init_parse_error]==((void *)0)) {
  _sr_core_ert_list.init_parse_error = -1;
 } 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(): " "event_route[core:receive-parse-error] is defined\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "events.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "event_route[core:receive-parse-error] is defined\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "events.c" ":" "55" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_route[core:receive-parse-error] is defined\n", process_no, my_pid(), ("<core> [" "events.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_route[core:receive-parse-error] is defined\n", ("<core> [" "events.c" ":" "55" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_route[core:receive-parse-error] is defined\n", ("<core> [" "events.c" ":" "55" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
}

canonical_original_code:
void sr_core_ert_init()
{
 memset(&_sr_core_ert_list, 0, sizeof(sr_core_ert_t));
 _sr_core_ert_list.init_parse_error = route_get(&event_rt,
           "core:receive-parse-error");
 if(_sr_core_ert_list.init_parse_error<=0
    || event_rt.rlist[_sr_core_ert_list.init_parse_error]==((void *)0)) {
  _sr_core_ert_list.init_parse_error = -1;
 } 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(): " "event_route[core:receive-parse-error] is defined\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "events.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "event_route[core:receive-parse-error] is defined\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "events.c" ":" "55" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_route[core:receive-parse-error] is defined\n", process_no, my_pid(), ("<core> [" "events.c" ":" "55" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_route[core:receive-parse-error] is defined\n", ("<core> [" "events.c" ":" "55" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_route[core:receive-parse-error] is defined\n", ("<core> [" "events.c" ":" "55" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
}

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


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

if ( !sr_events_inited )
{
result = 0LL;
memset(&sr_events_list, 0, 0x60uLL);
sr_events_inited = 1;
}
return result;
}

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

if ( !sr_events_inited )
{
result = 0LL;
memset(&sr_events_list, 0, 0x60uLL);
sr_events_inited = 1;
}
return result;
}

original_code:
void sr_event_cb_init(void)
{
 if(_sr_events_inited == 0)
 {
  memset(&_sr_events_list, 0, sizeof(sr_event_cb_t));
  _sr_events_inited = 1;
 }
}

canonical_original_code:
void sr_event_cb_init()
{
 if(_sr_events_inited == 0)
 {
  memset(&_sr_events_list, 0, sizeof(sr_event_cb_t));
  _sr_events_inited = 1;
 }
}


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

sr_event_cb_init();
switch ( a1 )
{
case 1:
if ( sr_events_list )
{
result = 0xFFFFFFFFLL;
}
else
{
sr_events_list = a2;
result = 0LL;
}
break;
case 2:
if ( qword_648 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_648 = a2;
result = 0LL;
}
break;
case 3:
if ( qword_650 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_650 = a2;
result = 0LL;
}
break;
case 4:
if ( qword_658 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_658 = a2;
result = 0LL;
}
break;
case 5:
if ( qword_660 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_660 = a2;
result = 0LL;
}
break;
case 6:
if ( qword_668 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_668 = a2;
result = 0LL;
}
break;
case 7:
if ( qword_670 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_670 = a2;
result = 0LL;
}
break;
case 8:
if ( qword_678 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_678 = a2;
result = 0LL;
}
break;
case 9:
if ( qword_680 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_680 = a2;
result = 0LL;
}
break;
case 10:
if ( qword_688 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_688 = a2;
result = 0LL;
}
break;
case 11:
if ( qword_690 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_690 = a2;
result = 0LL;
}
break;
case 12:
if ( qword_698 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_698 = a2;
result = 0LL;
}
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

func2();
switch ( a1 )
{
case 1:
if ( sr_events_list )
{
result = 0xFFFFFFFFLL;
}
else
{
sr_events_list = a2;
result = 0LL;
}
break;
case 2:
if ( qword_648 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_648 = a2;
result = 0LL;
}
break;
case 3:
if ( qword_650 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_650 = a2;
result = 0LL;
}
break;
case 4:
if ( qword_658 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_658 = a2;
result = 0LL;
}
break;
case 5:
if ( qword_660 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_660 = a2;
result = 0LL;
}
break;
case 6:
if ( qword_668 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_668 = a2;
result = 0LL;
}
break;
case 7:
if ( qword_670 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_670 = a2;
result = 0LL;
}
break;
case 8:
if ( qword_678 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_678 = a2;
result = 0LL;
}
break;
case 9:
if ( qword_680 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_680 = a2;
result = 0LL;
}
break;
case 10:
if ( qword_688 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_688 = a2;
result = 0LL;
}
break;
case 11:
if ( qword_690 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_690 = a2;
result = 0LL;
}
break;
case 12:
if ( qword_698 )
{
result = 0xFFFFFFFFLL;
}
else
{
qword_698 = a2;
result = 0LL;
}
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
int sr_event_register_cb(int type, sr_event_cb_f f)
{
 sr_event_cb_init();
 switch(type) {
  case 1:
    if(_sr_events_list.net_data_in==0)
     _sr_events_list.net_data_in = f;
    else return -1;
   break;
  case 2:
    if(_sr_events_list.net_data_out==0)
     _sr_events_list.net_data_out = f;
    else return -1;
   break;
  case 3:
    if(_sr_events_list.core_stats==0)
     _sr_events_list.core_stats = f;
    else return -1;
   break;
  case 4:
    if(_sr_events_list.run_action==0)
     _sr_events_list.run_action = f;
    else return -1;
   break;
  case 5:
    if(_sr_events_list.pkg_set_used==0)
     _sr_events_list.pkg_set_used = f;
    else return -1;
   break;
  case 6:
    if(_sr_events_list.pkg_set_real_used==0)
     _sr_events_list.pkg_set_real_used = f;
    else return -1;
   break;
  case 7:
    if(_sr_events_list.net_dgram_in==0)
     _sr_events_list.net_dgram_in = f;
    else return -1;
   break;
  case 8:
    if(_sr_events_list.tcp_http_100c==0)
     _sr_events_list.tcp_http_100c = f;
    else return -1;
   break;
  case 9:
    if(_sr_events_list.tcp_msrp_frame==0)
     _sr_events_list.tcp_msrp_frame = f;
    else return -1;
   break;
  case 10:
    if(_sr_events_list.tcp_ws_frame_in==0)
     _sr_events_list.tcp_ws_frame_in = f;
    else return -1;
   break;
  case 11:
    if(_sr_events_list.tcp_ws_frame_out==0)
     _sr_events_list.tcp_ws_frame_out = f;
    else return -1;
   break;
  case 12:
    if(_sr_events_list.stun_in==0)
     _sr_events_list.stun_in = f;
    else return -1;
   break;
  default:
   return -1;
 }
 return 0;
}

canonical_original_code:
int sr_event_register_cb(int type, int (*f)(void *data))
{
 sr_event_cb_init();
 switch(type) {
  case 1:
    if(_sr_events_list.net_data_in==0)
     _sr_events_list.net_data_in = f;
    else return -1;
   break;
  case 2:
    if(_sr_events_list.net_data_out==0)
     _sr_events_list.net_data_out = f;
    else return -1;
   break;
  case 3:
    if(_sr_events_list.core_stats==0)
     _sr_events_list.core_stats = f;
    else return -1;
   break;
  case 4:
    if(_sr_events_list.run_action==0)
     _sr_events_list.run_action = f;
    else return -1;
   break;
  case 5:
    if(_sr_events_list.pkg_set_used==0)
     _sr_events_list.pkg_set_used = f;
    else return -1;
   break;
  case 6:
    if(_sr_events_list.pkg_set_real_used==0)
     _sr_events_list.pkg_set_real_used = f;
    else return -1;
   break;
  case 7:
    if(_sr_events_list.net_dgram_in==0)
     _sr_events_list.net_dgram_in = f;
    else return -1;
   break;
  case 8:
    if(_sr_events_list.tcp_http_100c==0)
     _sr_events_list.tcp_http_100c = f;
    else return -1;
   break;
  case 9:
    if(_sr_events_list.tcp_msrp_frame==0)
     _sr_events_list.tcp_msrp_frame = f;
    else return -1;
   break;
  case 10:
    if(_sr_events_list.tcp_ws_frame_in==0)
     _sr_events_list.tcp_ws_frame_in = f;
    else return -1;
   break;
  case 11:
    if(_sr_events_list.tcp_ws_frame_out==0)
     _sr_events_list.tcp_ws_frame_out = f;
    else return -1;
   break;
  case 12:
    if(_sr_events_list.stun_in==0)
     _sr_events_list.stun_in = f;
    else return -1;
   break;
  default:
   return -1;
 }
 return 0;
}

variable_types: type int

variable_types:
f
int (*)(void *data)


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

switch ( a1 )
{
case 0u:
result = 0xFFFFFFFFLL;
break;
case 1u:
result = a1;
if ( sr_events_list )
result = sr_events_list(a2);
break;
case 2u:
result = 1LL;
if ( qword_648 )
result = qword_648(a2);
break;
case 3u:
result = 1LL;
if ( qword_650 )
result = qword_650(a2);
break;
case 4u:
result = 1LL;
if ( qword_658 )
result = qword_658(a2);
break;
case 5u:
result = 1LL;
if ( qword_660 )
result = qword_660(a2);
break;
case 6u:
result = 1LL;
if ( qword_668 )
result = qword_668(a2);
break;
case 7u:
result = 1LL;
if ( qword_670 )
result = qword_670(a2);
break;
case 8u:
result = 1LL;
if ( qword_678 )
result = qword_678(a2);
break;
case 9u:
result = 1LL;
if ( qword_680 )
result = qword_680(a2);
break;
case 0xAu:
result = 1LL;
if ( qword_688 )
result = qword_688(a2);
break;
case 0xBu:
result = 1LL;
if ( qword_690 )
result = qword_690(a2);
break;
case 0xCu:
result = 1LL;
if ( qword_698 )
result = qword_698(a2);
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

switch ( a1 )
{
case 0u:
result = 0xFFFFFFFFLL;
break;
case 1u:
result = a1;
if ( sr_events_list )
result = sr_events_list(a2);
break;
case 2u:
result = 1LL;
if ( qword_648 )
result = qword_648(a2);
break;
case 3u:
result = 1LL;
if ( qword_650 )
result = qword_650(a2);
break;
case 4u:
result = 1LL;
if ( qword_658 )
result = qword_658(a2);
break;
case 5u:
result = 1LL;
if ( qword_660 )
result = qword_660(a2);
break;
case 6u:
result = 1LL;
if ( qword_668 )
result = qword_668(a2);
break;
case 7u:
result = 1LL;
if ( qword_670 )
result = qword_670(a2);
break;
case 8u:
result = 1LL;
if ( qword_678 )
result = qword_678(a2);
break;
case 9u:
result = 1LL;
if ( qword_680 )
result = qword_680(a2);
break;
case 0xAu:
result = 1LL;
if ( qword_688 )
result = qword_688(a2);
break;
case 0xBu:
result = 1LL;
if ( qword_690 )
result = qword_690(a2);
break;
case 0xCu:
result = 1LL;
if ( qword_698 )
result = qword_698(a2);
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
int sr_event_exec(int type, void *data)
{
 int ret;
 switch(type) {
  case 1:
    if(__builtin_expect(!!(_sr_events_list.net_data_in!=0), 0))
    {
     ret = _sr_events_list.net_data_in(data);
     return ret;
    } else return 1;
   break;
  case 2:
    if(__builtin_expect(!!(_sr_events_list.net_data_out!=0), 0))
    {
     ret = _sr_events_list.net_data_out(data);
     return ret;
    } else return 1;
   break;
  case 3:
    if(__builtin_expect(!!(_sr_events_list.core_stats!=0), 0))
    {
     ret = _sr_events_list.core_stats(data);
     return ret;
    } else return 1;
   break;
  case 4:
    if(__builtin_expect(!!(_sr_events_list.run_action!=0), 0))
    {
     ret = _sr_events_list.run_action(data);
     return ret;
    } else return 1;
  case 5:
    if(__builtin_expect(!!(_sr_events_list.pkg_set_used!=0), 0))
    {
     ret = _sr_events_list.pkg_set_used(data);
     return ret;
    } else return 1;
  case 6:
    if(__builtin_expect(!!(_sr_events_list.pkg_set_real_used!=0), 0))
    {
     ret = _sr_events_list.pkg_set_real_used(data);
     return ret;
    } else return 1;
  case 7:
    if(__builtin_expect(!!(_sr_events_list.net_dgram_in!=0), 0))
    {
     ret = _sr_events_list.net_dgram_in(data);
     return ret;
    } else return 1;
  case 8:
    if(__builtin_expect(!!(_sr_events_list.tcp_http_100c!=0), 0))
    {
     ret = _sr_events_list.tcp_http_100c(data);
     return ret;
    } else return 1;
  case 9:
    if(__builtin_expect(!!(_sr_events_list.tcp_msrp_frame!=0), 0))
    {
     ret = _sr_events_list.tcp_msrp_frame(data);
     return ret;
    } else return 1;
  case 10:
    if(__builtin_expect(!!(_sr_events_list.tcp_ws_frame_in!=0), 0))
    {
     ret = _sr_events_list.tcp_ws_frame_in(data);
     return ret;
    } else return 1;
  case 11:
    if(__builtin_expect(!!(_sr_events_list.tcp_ws_frame_out!=0), 0))
    {
     ret = _sr_events_list.tcp_ws_frame_out(data);
     return ret;
    } else return 1;
  case 12:
    if(__builtin_expect(!!(_sr_events_list.stun_in!=0), 0))
    {
     ret = _sr_events_list.stun_in(data);
     return ret;
    } else return 1;
  default:
   return -1;
 }
}

variable_types:
data
void *

variable_types: ret int


decompiled_code:
_BOOL8 __fastcall sr_event_enabled(int a1)
{
_BOOL8 result; // rax

switch ( a1 )
{
case 1:
result = sr_events_list != 0LL;
break;
case 2:
result = qword_648 != 0LL;
break;
case 3:
result = qword_650 != 0LL;
break;
case 4:
result = qword_658 != 0LL;
break;
case 5:
result = qword_660 != 0LL;
break;
case 6:
result = qword_668 != 0LL;
break;
case 7:
result = qword_670 != 0LL;
break;
case 8:
result = qword_678 != 0LL;
break;
case 9:
result = qword_680 != 0LL;
break;
case 10:
result = qword_688 != 0LL;
break;
case 11:
result = qword_690 != 0LL;
break;
case 12:
result = qword_698 != 0LL;
break;
default:
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(int a1)
{
_BOOL8 result; // rax

switch ( a1 )
{
case 1:
result = sr_events_list != 0LL;
break;
case 2:
result = qword_648 != 0LL;
break;
case 3:
result = qword_650 != 0LL;
break;
case 4:
result = qword_658 != 0LL;
break;
case 5:
result = qword_660 != 0LL;
break;
case 6:
result = qword_668 != 0LL;
break;
case 7:
result = qword_670 != 0LL;
break;
case 8:
result = qword_678 != 0LL;
break;
case 9:
result = qword_680 != 0LL;
break;
case 10:
result = qword_688 != 0LL;
break;
case 11:
result = qword_690 != 0LL;
break;
case 12:
result = qword_698 != 0LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
int sr_event_enabled(int type)
{
 switch(type) {
  case 1:
    return (_sr_events_list.net_data_in!=0)?1:0;
  case 2:
    return (_sr_events_list.net_data_out!=0)?1:0;
  case 3:
    return (_sr_events_list.core_stats!=0)?1:0;
  case 4:
    return (_sr_events_list.run_action!=0)?1:0;
  case 5:
    return (_sr_events_list.pkg_set_used!=0)?1:0;
  case 6:
    return (_sr_events_list.pkg_set_real_used!=0)?1:0;
  case 7:
    return (_sr_events_list.net_dgram_in!=0)?1:0;
  case 8:
    return (_sr_events_list.tcp_http_100c!=0)?1:0;
  case 9:
    return (_sr_events_list.tcp_msrp_frame!=0)?1:0;
  case 10:
    return (_sr_events_list.tcp_ws_frame_in!=0)?1:0;
  case 11:
    return (_sr_events_list.tcp_ws_frame_out!=0)?1:0;
  case 12:
    return (_sr_events_list.stun_in!=0)?1:0;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall shm_malloc_x(unsigned int a1)
{
return shm_malloc(a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1)
{
return func4(a1);
}

original_code:
void* shm_malloc_x(unsigned int size)
{
 return shm_malloc(size);
}

canonical_original_code:
void *shm_malloc_x(unsigned int size)
{
 return shm_malloc(size);
}


decompiled_code:
__int64 __fastcall shm_free_x(__int64 a1)
{
futex_get(mem_lock);
qm_free(shm_block, a1);
return futex_release(mem_lock);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
func2(mem_lock);
qm_free(shm_block, a1);
return func3(mem_lock);
}

original_code:
void shm_free_x(void *ptr)
{
 do { futex_get(mem_lock); qm_free(shm_block, (ptr)); futex_release(mem_lock); }while(0);
}

variable_types:
ptr
void *


decompiled_code:
int __fastcall cmp_str(__int64 a1, __int64 a2)
{
int v2; // ebx
int result; // eax
int v4; // ebp
int v5; // edx

v2 = *(_DWORD *)(a1 + 8);
if ( !v2 )
return -(*(_DWORD *)(a2 + 8) != 0);
v4 = *(_DWORD *)(a2 + 8);
result = 1;
if ( v4 )
{
v5 = *(_DWORD *)(a2 + 8);
if ( v2 <= v4 )
v5 = *(_DWORD *)(a1 + 8);
result = strncmp(*(const char **)a1, *(const char **)a2, v5);
if ( !result && v2 != v4 )
result = 2 * (v2 >= v4) - 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2)
{
int v2; // ebx
int result; // eax
int v4; // ebp
int v5; // edx

v2 = *(_DWORD *)(a1 + 8);
if ( !v2 )
return -(*(_DWORD *)(a2 + 8) != 0);
v4 = *(_DWORD *)(a2 + 8);
result = 1;
if ( v4 )
{
v5 = *(_DWORD *)(a2 + 8);
if ( v2 <= v4 )
v5 = *(_DWORD *)(a1 + 8);
result = strncmp(*(const char **)a1, *(const char **)a2, v5);
if ( !result && v2 != v4 )
result = 2 * (v2 >= v4) - 1;
}
return result;
}

original_code:
int cmp_str(str *s1, str *s2)
{
 int ret = 0;
 int len = 0;
 if(s1->len==0 && s2->len==0)
  return 0;
 if(s1->len==0)
  return -1;
 if(s2->len==0)
  return 1;
 len = (s1->len<s2->len)?s1->len:s2->len;
 ret = strncmp(s1->s, s2->s, len);
 if(ret==0)
 {
  if(s1->len==s2->len)
   return 0;
  if(s1->len<s2->len)
   return -1;
  return 1;
 }
 return ret;
}

canonical_original_code:
int cmp_str(struct _str *s1, struct _str *s2)
{
 int ret = 0;
 int len = 0;
 if(s1->len==0 && s2->len==0)
  return 0;
 if(s1->len==0)
  return -1;
 if(s2->len==0)
  return 1;
 len = (s1->len<s2->len)?s1->len:s2->len;
 ret = strncmp(s1->s, s2->s, len);
 if(ret==0)
 {
  if(s1->len==s2->len)
   return 0;
  if(s1->len<s2->len)
   return -1;
  return 1;
 }
 return ret;
}

variable_types: len int


decompiled_code:
int __fastcall cmpi_str(__int64 a1, __int64 a2)
{
int v2; // ebx
int result; // eax
int v4; // ebp
int v5; // edx

v2 = *(_DWORD *)(a1 + 8);
if ( !v2 )
return -(*(_DWORD *)(a2 + 8) != 0);
v4 = *(_DWORD *)(a2 + 8);
result = 1;
if ( v4 )
{
v5 = *(_DWORD *)(a2 + 8);
if ( v2 <= v4 )
v5 = *(_DWORD *)(a1 + 8);
result = strncasecmp(*(const char **)a1, *(const char **)a2, v5);
if ( !result && v2 != v4 )
result = 2 * (v2 >= v4) - 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, __int64 a2)
{
int v2; // ebx
int result; // eax
int v4; // ebp
int v5; // edx

v2 = *(_DWORD *)(a1 + 8);
if ( !v2 )
return -(*(_DWORD *)(a2 + 8) != 0);
v4 = *(_DWORD *)(a2 + 8);
result = 1;
if ( v4 )
{
v5 = *(_DWORD *)(a2 + 8);
if ( v2 <= v4 )
v5 = *(_DWORD *)(a1 + 8);
result = strncasecmp(*(const char **)a1, *(const char **)a2, v5);
if ( !result && v2 != v4 )
result = 2 * (v2 >= v4) - 1;
}
return result;
}

original_code:
int cmpi_str(str *s1, str *s2)
{
 int ret = 0;
 int len = 0;
 if(s1->len==0 && s2->len==0)
  return 0;
 if(s1->len==0)
  return -1;
 if(s2->len==0)
  return 1;
 len = (s1->len<s2->len)?s1->len:s2->len;
 ret = strncasecmp(s1->s, s2->s, len);
 if(ret==0)
 {
  if(s1->len==s2->len)
   return 0;
  if(s1->len<s2->len)
   return -1;
  return 1;
 }
 return ret;
}

canonical_original_code:
int cmpi_str(struct _str *s1, struct _str *s2)
{
 int ret = 0;
 int len = 0;
 if(s1->len==0 && s2->len==0)
  return 0;
 if(s1->len==0)
  return -1;
 if(s2->len==0)
  return 1;
 len = (s1->len<s2->len)?s1->len:s2->len;
 ret = strncasecmp(s1->s, s2->s, len);
 if(ret==0)
 {
  if(s1->len==s2->len)
   return 0;
  if(s1->len<s2->len)
   return -1;
  return 1;
 }
 return ret;
}


decompiled_code:
int __fastcall cmp_hdrname_str(__int64 a1, __int64 a2)
{
return cmpi_str(a1, a2);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 a2)
{
return func1(a1, a2);
}

original_code:
int cmp_hdrname_str(str *s1, str *s2)
{
 return cmpi_str(s1, s2);
}

canonical_original_code:
int cmp_hdrname_str(struct _str *s1, struct _str *s2)
{
 return cmpi_str(s1, s2);
}


decompiled_code:
int __fastcall cmp_hdrname_strzn(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // [rsp+0h] [rbp-18h] BYREF
int v5; // [rsp+8h] [rbp-10h]

v4 = a2;
v5 = a3;
return cmpi_str(a1, (__int64)&v4);
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // [rsp+0h] [rbp-18h] BYREF
int v5; // [rsp+8h] [rbp-10h]

v4 = a2;
v5 = a3;
return func1(a1, (__int64)&v4);
}

original_code:
int cmp_hdrname_strzn(str *s1, char *s2, size_t n)
{
 str s;
 s.s = s2;
 s.len = n;
 return cmpi_str(s1, &s);
}

canonical_original_code:
int cmp_hdrname_strzn(struct _str *s1, char *s2, unsigned long n)
{
 struct _str s;
 s.s = s2;
 s.len = n;
 return cmpi_str(s1, &s);
}

variable_types:
n
unsigned long

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


decompiled_code:
__int64 __fastcall cmp_str_params(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
int v4; // ecx
__int64 v5; // r12
__int64 v6; // r13
__int64 v7; // rbx
int v8; // eax
int v9; // esi
int v10; // ebp
__int64 v11; // [rsp+0h] [rbp-C8h] BYREF
__int64 v12; // [rsp+48h] [rbp-80h] BYREF
char v13[72]; // [rsp+50h] [rbp-78h] BYREF
__int64 v14[6]; // [rsp+98h] [rbp-30h] BYREF

v14[0] = 0LL;
v12 = 0LL;
v2 = parse_params(a1, 0LL, v13, v14);
result = 0xFFFFFFFFLL;
if ( v2 >= 0 )
{
v4 = parse_params(a2, 0LL, &v11, &v12);
result = 0xFFFFFFFFLL;
if ( v4 >= 0 )
{
v5 = v14[0];
if ( !v14[0] )
return 0LL;
v6 = v12;
while ( !v6 )
{
LABEL_11:
v5 = *(_QWORD *)(v5 + 48);
if ( !v5 )
return 0LL;
}
v10 = *(_DWORD *)(v5 + 16);
v7 = v6;
while ( 1 )
{
v8 = *(_DWORD *)(v7 + 16);
if ( v10 == v8 && !strncasecmp(*(const char **)(v5 + 8), *(const char **)(v7 + 8), v8) )
{
v9 = *(_DWORD *)(v7 + 32);
if ( *(_DWORD *)(v5 + 32) != v9 )
return 1LL;
if ( strncasecmp(*(const char **)(v5 + 24), *(const char **)(v7 + 24), v9) )
return 1LL;
}
v7 = *(_QWORD *)(v7 + 48);
if ( !v7 )
goto LABEL_11;
}
}
}
return result;
}

original_code:
int cmp_str_params(str *s1, str *s2)
{
 param_t* pl1 = ((void *)0);
 param_hooks_t phooks1;
 param_t *pit1=((void *)0);
 param_t* pl2 = ((void *)0);
 param_hooks_t phooks2;
 param_t *pit2=((void *)0);
 if (parse_params(s1, CLASS_ANY, &phooks1, &pl1)<0)
  return -1;
 if (parse_params(s2, CLASS_ANY, &phooks2, &pl2)<0)
  return -1;
 for (pit1 = pl1; pit1; pit1=pit1->next)
 {
  for (pit2 = pl2; pit2; pit2=pit2->next)
  {
   if (pit1->name.len==pit2->name.len
    && strncasecmp(pit1->name.s, pit2->name.s, pit2->name.len)==0)
   {
    if(pit1->body.len!=pit2->body.len
      || strncasecmp(pit1->body.s, pit2->body.s,
       pit2->body.len)!=0)
     return 1;
   }
  }
 }
 return 0;
}

canonical_original_code:
int cmp_str_params(struct _str *s1, struct _str *s2)
{
 struct param *pl1 = ((void *)0);
 union param_hooks phooks1;
 struct param *pit1 = ((void *)0);
 struct param *pl2 = ((void *)0);
 union param_hooks phooks2;
 struct param *pit2 = ((void *)0);
 if (parse_params(s1, CLASS_ANY, &phooks1, &pl1)<0)
  return -1;
 if (parse_params(s2, CLASS_ANY, &phooks2, &pl2)<0)
  return -1;
 for (pit1 = pl1; pit1; pit1=pit1->next)
 {
  for (pit2 = pl2; pit2; pit2=pit2->next)
  {
   if (pit1->name.len==pit2->name.len
    && strncasecmp(pit1->name.s, pit2->name.s, pit2->name.len)==0)
   {
    if(pit1->body.len!=pit2->body.len
      || strncasecmp(pit1->body.s, pit2->body.s,
       pit2->body.len)!=0)
     return 1;
   }
  }
 }
 return 0;
}

variable_types: union param_hooks { struct contact_hooks { struct param { enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 } type; struct _str { char *s; int len; } name; struct _str body; int len; struct param *next; } *expires; struct param *q; struct param *methods; struct param *received; struct param *instance; struct param *reg_id; struct param *ob; } contact; struct uri_hooks { struct param *transport; struct param *lr; struct param *r2; struct param *maddr; struct param *ttl; struct param *dstip; struct param *dstport; struct param *ftag; struct param *ob; } uri; struct event_dialog_hooks { struct param *call_id; struct param *from_tag; struct param *to_tag; struct param *include_session_description; struct param *sla; struct param *ma; } event_dialog; }

user_defined_types: union param_hooks { struct contact_hooks contact; struct uri_hooks uri; struct event_dialog_hooks event_dialog; }

user_defined_types: struct contact_hooks { struct param *expires; struct param *q; struct param *methods; struct param *received; struct param *instance; struct param *reg_id; struct param *ob; }


original_code:
int cmp_uri(struct sip_uri *uri1, struct sip_uri *uri2)
{
 if(uri1->type!=uri2->type)
  return 1;
 if(uri1->user.len!=uri2->user.len
   || uri1->host.len!=uri2->host.len
   || uri1->port.len!=uri2->port.len
   || uri1->passwd.len!=uri2->passwd.len)
  return 1;
 if(cmp_str(&uri1->user, &uri2->user)!=0)
  return 1;
 if(cmp_str(&uri1->port, &uri2->port)!=0)
  return 1;
 if(cmp_str(&uri1->passwd, &uri2->passwd)!=0)
  return 1;
 if(cmpi_str(&uri1->host, &uri2->host)!=0)
  return 1;
 if(uri1->params.len==0 && uri2->params.len==0)
  return 0;
 if(uri1->params.len==0)
 {
  if(uri2->user_param.len!=0)
   return 1;
  if(uri2->ttl.len!=0)
   return 1;
  if(uri2->method.len!=0)
   return 1;
  if(uri2->maddr.len!=0)
   return 1;
 }
 if(uri2->params.len==0)
 {
  if(uri1->user_param.len!=0)
   return 1;
  if(uri1->ttl.len!=0)
   return 1;
  if(uri1->method.len!=0)
   return 1;
  if(uri1->maddr.len!=0)
   return 1;
 }
 return cmp_str_params(&uri1->params, &uri2->params);
}

variable_types: struct sip_uri { struct _str { char *s; int len; } user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type { ERROR_URI_T=0, SIP_URI_T=1, SIPS_URI_T=2, TEL_URI_T=3, TELS_URI_T=4, URN_URI_T=5 } type; enum _uri_flags { URI_USER_NORMALIZE=1, URI_SIP_USER_PHONE=2 } flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; } *

user_defined_types: struct sip_uri { struct _str user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type type; enum _uri_flags flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; }


decompiled_code:
__int64 __fastcall cmp_uri_str(__int64 a1, __int64 a2)
{
_DWORD v3[96]; // [rsp+0h] [rbp-308h] BYREF
_DWORD v4[98]; // [rsp+180h] [rbp-188h] BYREF

if ( (unsigned int)parse_uri(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), v4) )
return 0xFFFFFFFFLL;
if ( (unsigned int)parse_uri(*(_QWORD *)a2, *(unsigned int *)(a2 + 8), v3) )
return 0xFFFFFFFFLL;
return cmp_uri(v4, v3);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
_DWORD v3[96]; // [rsp+0h] [rbp-308h] BYREF
_DWORD v4[98]; // [rsp+180h] [rbp-188h] BYREF

if ( (unsigned int)parse_uri(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), v4) )
return 0xFFFFFFFFLL;
if ( (unsigned int)parse_uri(*(_QWORD *)a2, *(unsigned int *)(a2 + 8), v3) )
return 0xFFFFFFFFLL;
return func5(v4, v3);
}

original_code:
int cmp_uri_str(str *s1, str *s2)
{
 struct sip_uri uri1;
 struct sip_uri uri2;
 if(parse_uri(s1->s, s1->len, &uri1)!=0)
  return -1;
 if(parse_uri(s2->s, s2->len, &uri2)!=0)
  return -1;
 return cmp_uri(&uri1, &uri2);
}

canonical_original_code:
int cmp_uri_str(struct _str *s1, struct _str *s2)
{
 struct sip_uri uri1;
 struct sip_uri uri2;
 if(parse_uri(s1->s, s1->len, &uri1)!=0)
  return -1;
 if(parse_uri(s2->s, s2->len, &uri2)!=0)
  return -1;
 return cmp_uri(&uri1, &uri2);
}

variable_types: struct sip_uri { struct _str { char *s; int len; } user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type { ERROR_URI_T=0, SIP_URI_T=1, SIPS_URI_T=2, TEL_URI_T=3, TELS_URI_T=4, URN_URI_T=5 } type; enum _uri_flags { URI_USER_NORMALIZE=1, URI_SIP_USER_PHONE=2 } flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; }


original_code:
int cmp_aor(struct sip_uri *uri1, struct sip_uri *uri2)
{
 if(uri1->user.len!=uri2->user.len
   || uri1->host.len!=uri2->host.len)
  return 1;
 if(cmp_str(&uri1->user, &uri2->user)!=0)
  return 1;
 if(cmp_str(&uri1->port, &uri2->port)!=0)
 {
  if(uri1->port.len==0 && uri2->port_no!=5060)
   return 1;
  if(uri2->port.len==0 && uri1->port_no!=5060)
   return 1;
 }
 if(cmpi_str(&uri1->host, &uri2->host)!=0)
  return 1;
 return 0;
}

user_defined_types: enum _uri_type { ERROR_URI_T=0, SIP_URI_T=1, SIPS_URI_T=2, TEL_URI_T=3, TELS_URI_T=4, URN_URI_T=5 }

user_defined_types: enum _uri_flags { URI_USER_NORMALIZE=1, URI_SIP_USER_PHONE=2 }


decompiled_code:
__int64 __fastcall cmp_aor_str(__int64 a1, __int64 a2)
{
_BYTE v3[384]; // [rsp+0h] [rbp-308h] BYREF
char v4[392]; // [rsp+180h] [rbp-188h] BYREF

if ( (unsigned int)parse_uri(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), v4) )
return 0xFFFFFFFFLL;
if ( (unsigned int)parse_uri(*(_QWORD *)a2, *(unsigned int *)(a2 + 8), v3) )
return 0xFFFFFFFFLL;
return cmp_aor((__int64)v4, (__int64)v3);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
_BYTE v3[384]; // [rsp+0h] [rbp-308h] BYREF
char v4[392]; // [rsp+180h] [rbp-188h] BYREF

if ( (unsigned int)parse_uri(*(_QWORD *)a1, *(unsigned int *)(a1 + 8), v4) )
return 0xFFFFFFFFLL;
if ( (unsigned int)parse_uri(*(_QWORD *)a2, *(unsigned int *)(a2 + 8), v3) )
return 0xFFFFFFFFLL;
return func7((__int64)v4, (__int64)v3);
}

original_code:
int cmp_aor_str(str *s1, str *s2)
{
 struct sip_uri uri1;
 struct sip_uri uri2;
 if(parse_uri(s1->s, s1->len, &uri1)!=0)
  return -1;
 if(parse_uri(s2->s, s2->len, &uri2)!=0)
  return -1;
 return cmp_aor(&uri1, &uri2);
}

canonical_original_code:
int cmp_aor_str(struct _str *s1, struct _str *s2)
{
 struct sip_uri uri1;
 struct sip_uri uri2;
 if(parse_uri(s1->s, s1->len, &uri1)!=0)
  return -1;
 if(parse_uri(s2->s, s2->len, &uri2)!=0)
  return -1;
 return cmp_aor(&uri1, &uri2);
}


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

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

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

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

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

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