decompiled_code:
__int64 init_im_db()
{
const char *v1; // r12
struct _IO_FILE *v2; // rdi
const char *v3; // r8
const char *v4; // r9
__int64 v5; // [rsp-10h] [rbp-398h]
__int64 v6; // [rsp-8h] [rbp-390h]
const char *v7[113]; // [rsp+0h] [rbp-388h] BYREF

memset(v7, 0, 0x370uLL);
v7[17] = "ip";
LODWORD(v7[18]) = 4;
v7[39] = "avp_val";
LODWORD(v7[40]) = 4;
v7[61] = "mark";
LODWORD(v7[62]) = 8;
v7[83] = "flags";
LODWORD(v7[84]) = 8;
if ( db_mode != 1 )
return 0LL;
if ( db_conn )
{
cmd_load_im = db_cmd(2LL, db_conn, ipmatch_table, v7, 0LL, 0LL);
if ( cmd_load_im )
return 0LL;
if ( (int)get_debug_level("permissions", 11LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v1 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
v2 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): init_im_db(): failed to prepare DB commands\n",
process_no,
(unsigned int)v6,
v1,
"permissions [im_db.c:55]: ",
"init_im_db");
if ( log_color )
dprint_color_reset(
v2,
"%2d(%d) %s: %s%s(): init_im_db(): failed to prepare DB commands\n",
v5,
v6,
v3,
v4,
v7[0]);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): init_im_db(): failed to prepare DB commands\n",
*((const char **)&log_level_info + 8),
"permissions [im_db.c:55]: ",
"init_im_db");
}
--dprint_crit;
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func5()
{
const char *v1; // r12
struct _IO_FILE *v2; // rdi
const char *v3; // r8
const char *v4; // r9
__int64 v5; // [rsp-10h] [rbp-398h]
__int64 v6; // [rsp-8h] [rbp-390h]
const char *v7[113]; // [rsp+0h] [rbp-388h] BYREF

memset(v7, 0, 0x370uLL);
v7[17] = "ip";
LODWORD(v7[18]) = 4;
v7[39] = "avp_val";
LODWORD(v7[40]) = 4;
v7[61] = "mark";
LODWORD(v7[62]) = 8;
v7[83] = "flags";
LODWORD(v7[84]) = 8;
if ( db_mode != 1 )
return 0LL;
if ( db_conn )
{
cmd_load_im = db_cmd(2LL, db_conn, ipmatch_table, v7, 0LL, 0LL);
if ( cmd_load_im )
return 0LL;
if ( (int)get_debug_level("permissions", 11LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v1 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
v2 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): init_im_db(): failed to prepare DB commands\n",
process_no,
(unsigned int)v6,
v1,
"permissions [im_db.c:55]: ",
"init_im_db");
if ( log_color )
dprint_color_reset(
v2,
"%2d(%d) %s: %s%s(): init_im_db(): failed to prepare DB commands\n",
v5,
v6,
v3,
v4,
v7[0]);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): init_im_db(): failed to prepare DB commands\n",
*((const char **)&log_level_info + 8),
"permissions [im_db.c:55]: ",
"init_im_db");
}
--dprint_crit;
}
}
return 0xFFFFFFFFLL;
}

original_code:
int init_im_db(void)
{
 db_fld_t load_res_cols[] = {
  {.name = "ip", .type = DB_CSTR},
  {.name = "avp_val", .type = DB_CSTR},
  {.name = "mark", .type = DB_BITMAP},
  {.name = "flags", .type = DB_BITMAP},
  {.name = ((void *)0)}
 };
 if (db_mode != 1) return 0;
 if (!db_conn) return -1;
 cmd_load_im =
  db_cmd(DB_GET, db_conn, ipmatch_table, load_res_cols, ((void *)0), ((void *)0));
 if (!cmd_load_im) {
  do { if (get_debug_level("permissions", (sizeof("permissions")-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(): " "init_im_db(): failed to prepare DB commands\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "55" "]: ") , __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(): " "init_im_db(): failed to prepare DB commands\n", (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "55" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "init_im_db(): failed to prepare DB commands\n", process_no, my_pid(), ("permissions" " [" "im_db.c" ":" "55" "]: ") , __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(): " "init_im_db(): failed to prepare DB commands\n", ("permissions" " [" "im_db.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(): " "init_im_db(): failed to prepare DB commands\n", ("permissions" " [" "im_db.c" ":" "55" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return 0;
}

canonical_original_code:
int init_im_db()
{
 struct db_fld load_res_cols[] = {
  {.name = "ip", .type = DB_CSTR},
  {.name = "avp_val", .type = DB_CSTR},
  {.name = "mark", .type = DB_BITMAP},
  {.name = "flags", .type = DB_BITMAP},
  {.name = ((void *)0)}
 };
 if (db_mode != 1) return 0;
 if (!db_conn) return -1;
 cmd_load_im =
  db_cmd(DB_GET, db_conn, ipmatch_table, load_res_cols, ((void *)0), ((void *)0));
 if (!cmd_load_im) {
  do { if (get_debug_level("permissions", (sizeof("permissions")-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(): " "init_im_db(): failed to prepare DB commands\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "55" "]: ") , __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(): " "init_im_db(): failed to prepare DB commands\n", (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "55" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "init_im_db(): failed to prepare DB commands\n", process_no, my_pid(), ("permissions" " [" "im_db.c" ":" "55" "]: ") , __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(): " "init_im_db(): failed to prepare DB commands\n", ("permissions" " [" "im_db.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(): " "init_im_db(): failed to prepare DB commands\n", ("permissions" " [" "im_db.c" ":" "55" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return 0;
}

variable_types: struct db_fld { struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv { void (*free)(struct db_gen *db_struct, struct db_drv *payload); } *data[16]; } gen; char *name; enum db_fld_type { DB_NONE=0, DB_INT=1, DB_FLOAT=2, DB_DOUBLE=3, DB_CSTR=4, DB_STR=5, DB_DATETIME=6, DB_BLOB=7, DB_BITMAP=8 } type; unsigned int flags; union db_fld_val { int int4; float flt; double dbl; long time; char *cstr; struct _str { char *s; int len; } lstr; struct _str blob; unsigned int bitmap; long long int8; } v; enum db_fld_op { DB_EQ=0, DB_NE=1, DB_LT=2, DB_GT=3, DB_LEQ=4, DB_GEQ=5 } op; } []

user_defined_types: struct db_fld { struct db_gen gen; char *name; enum db_fld_type type; unsigned int flags; union db_fld_val v; enum db_fld_op op; }

user_defined_types: struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv *data[16]; }

user_defined_types: union db_fld_val { int int4; float flt; double dbl; long time; char *cstr; struct _str lstr; struct _str blob; unsigned int bitmap; long long int8; }


repo: virtualolson/who

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

if ( cmd_load_im )
{
result = db_cmd_free();
cmd_load_im = 0LL;
}
return result;
}

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

if ( cmd_load_im )
{
result = db_cmd_free();
cmd_load_im = 0LL;
}
return result;
}

original_code:
void destroy_im_db(void)
{
 if (cmd_load_im) {
  db_cmd_free(cmd_load_im);
  cmd_load_im = ((void *)0);
 }
}

canonical_original_code:
void destroy_im_db()
{
 if (cmd_load_im) {
  db_cmd_free(cmd_load_im);
  cmd_load_im = ((void *)0);
 }
}

return_type: void


decompiled_code:
__int64 reload_im_cache()
{
__int64 v0; // rax
__int64 v1; // rbp
unsigned int v2; // eax
unsigned int v3; // er12
__int64 v4; // r12
__int64 v6; // rdi
const char *v7; // rsi
const char *v8; // r15
unsigned int v9; // eax
__int64 v10; // rdx
__int64 v11; // rcx
const char *v12; // r9
const char *v13; // r15
struct _IO_FILE *v14; // rdi
const char *v15; // r8
const char *v16; // r9
__int64 v17; // [rsp-10h] [rbp-48h]
__int64 v18; // [rsp-10h] [rbp-48h]
__int64 v19; // [rsp-8h] [rbp-40h]
const char *v20; // [rsp+0h] [rbp-38h]

if ( IM_HASH )
{
futex_get((volatile signed __int32 *)IM_HASH + 3);
v0 = new_im_hash();
v1 = v0;
if ( v0 )
{
v2 = load_db(v0);
v3 = v2;
if ( v2 == -1 )
{
if ( (int)get_debug_level("permissions", 11LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v19 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): could not reload cache\n",
process_no,
(unsigned int)v19,
v13,
"permissions [im_db.c:177]: ",
"reload_im_cache");
if ( log_color )
dprint_color_reset(
v14,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): could not reload cache\n",
v18,
v19,
v15,
v16,
v20);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: reload_im_cache(): could not reload cache\n",
*((const char **)&log_level_info + 8),
"permissions [im_db.c:177]: ",
"reload_im_cache");
}
--dprint_crit;
}
free_im_hash(v1);
futex_release((volatile __int32 *)IM_HASH + 3);
}
else
{
if ( v2 == -2 )
{
v6 = v1;
v1 = 0LL;
delete_im_hash(v6);
}
v4 = *IM_HASH;
set_wd_imhash();
*IM_HASH = v1;
del_wd_imhash();
if ( v4 )
free_im_hash(v4);
v3 = 0;
futex_release((volatile __int32 *)IM_HASH + 3);
}
}
else
{
v3 = -1;
futex_release((volatile __int32 *)IM_HASH + 3);
}
}
else
{
v3 = -1;
if ( (int)get_debug_level("permissions", 11LL) >= -2 && !dprint_crit )
{
v7 = (const char *)log_stderr;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v8 = (const char *)*((_QWORD *)&log_level_info + 6);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): ipmatch hash table is not initialied. Have you set the database url?\n",
process_no,
v9,
v8,
"permissions [im_db.c:161]: ",
"reload_im_cache");
if ( log_color )
dprint_color_reset(
v17,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): ipmatch hash table is not initialied. Have you set the database url?\n",
v10,
v11,
v7,
v12,
v20);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: reload_im_cache(): ipmatch hash table is not initialied. Have you set the database url?\n",
*((const char **)&log_level_info + 6),
"permissions [im_db.c:161]: ",
"reload_im_cache");
}
v3 = -1;
--dprint_crit;
}
}
return v3;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rax
__int64 v1; // rbp
unsigned int v2; // eax
unsigned int v3; // er12
__int64 v4; // r12
__int64 v6; // rdi
const char *v7; // rsi
const char *v8; // r15
unsigned int v9; // eax
__int64 v10; // rdx
__int64 v11; // rcx
const char *v12; // r9
const char *v13; // r15
struct _IO_FILE *v14; // rdi
const char *v15; // r8
const char *v16; // r9
__int64 v17; // [rsp-10h] [rbp-48h]
__int64 v18; // [rsp-10h] [rbp-48h]
__int64 v19; // [rsp-8h] [rbp-40h]
const char *v20; // [rsp+0h] [rbp-38h]

if ( IM_HASH )
{
func4((volatile signed __int32 *)IM_HASH + 3);
v0 = new_im_hash();
v1 = v0;
if ( v0 )
{
v2 = func2(v0);
v3 = v2;
if ( v2 == -1 )
{
if ( (int)get_debug_level("permissions", 11LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v19 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): could not reload cache\n",
process_no,
(unsigned int)v19,
v13,
"permissions [im_db.c:177]: ",
"reload_im_cache");
if ( log_color )
dprint_color_reset(
v14,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): could not reload cache\n",
v18,
v19,
v15,
v16,
v20);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: reload_im_cache(): could not reload cache\n",
*((const char **)&log_level_info + 8),
"permissions [im_db.c:177]: ",
"reload_im_cache");
}
--dprint_crit;
}
free_im_hash(v1);
func1((volatile __int32 *)IM_HASH + 3);
}
else
{
if ( v2 == -2 )
{
v6 = v1;
v1 = 0LL;
delete_im_hash(v6);
}
v4 = *IM_HASH;
set_wd_imhash();
*IM_HASH = v1;
del_wd_imhash();
if ( v4 )
free_im_hash(v4);
v3 = 0;
func1((volatile __int32 *)IM_HASH + 3);
}
}
else
{
v3 = -1;
func1((volatile __int32 *)IM_HASH + 3);
}
}
else
{
v3 = -1;
if ( (int)get_debug_level("permissions", 11LL) >= -2 && !dprint_crit )
{
v7 = (const char *)log_stderr;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v8 = (const char *)*((_QWORD *)&log_level_info + 6);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): ipmatch hash table is not initialied. Have you set the database url?\n",
process_no,
v9,
v8,
"permissions [im_db.c:161]: ",
"reload_im_cache");
if ( log_color )
dprint_color_reset(
v17,
"%2d(%d) %s: %s%s(): ERROR: reload_im_cache(): ipmatch hash table is not initialied. Have you set the database url?\n",
v10,
v11,
v7,
v12,
v20);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: reload_im_cache(): ipmatch hash table is not initialied. Have you set the database url?\n",
*((const char **)&log_level_info + 6),
"permissions [im_db.c:161]: ",
"reload_im_cache");
}
v3 = -1;
--dprint_crit;
}
}
return v3;
}

original_code:
int reload_im_cache(void)
{
 im_entry_t **hash, **old_hash;
 int ret;
 if (!IM_HASH) {
  do { if (get_debug_level("permissions", (sizeof("permissions")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", (log_level_info[((-2)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", process_no, my_pid(), ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 futex_get(&(IM_HASH)->write_lock);;
 if (!(hash = new_im_hash())) {
  futex_release(&(IM_HASH)->write_lock);;
  return -1;
 }
 ret = load_db(hash);
 if (ret == -1) {
  do { if (get_debug_level("permissions", (sizeof("permissions")-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: reload_im_cache(): could not reload cache\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "177" "]: ") , __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: reload_im_cache(): could not reload cache\n", (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "177" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: reload_im_cache(): could not reload cache\n", process_no, my_pid(), ("permissions" " [" "im_db.c" ":" "177" "]: ") , __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: reload_im_cache(): could not reload cache\n", ("permissions" " [" "im_db.c" ":" "177" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: reload_im_cache(): could not reload cache\n", ("permissions" " [" "im_db.c" ":" "177" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  free_im_hash(hash);
  futex_release(&(IM_HASH)->write_lock);;
  return -1;
 } else if (ret == -2) {
  delete_im_hash(hash);
  hash = ((void *)0);
 }
 old_hash = IM_HASH->entries;
 set_wd_imhash();
 IM_HASH->entries = hash;
 del_wd_imhash();
 if (old_hash) free_im_hash(old_hash);
 futex_release(&(IM_HASH)->write_lock);;
 return 0;
}

canonical_original_code:
int reload_im_cache()
{
 struct im_entry **hash; struct im_entry **old_hash;
 int ret;
 if (!IM_HASH) {
  do { if (get_debug_level("permissions", (sizeof("permissions")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", (log_level_info[((-2)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", process_no, my_pid(), ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: reload_im_cache(): ipmatch hash table is not initialied. " "Have you set the database url?\n", ("permissions" " [" "im_db.c" ":" "161" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 futex_get(&(IM_HASH)->write_lock);;
 if (!(hash = new_im_hash())) {
  futex_release(&(IM_HASH)->write_lock);;
  return -1;
 }
 ret = load_db(hash);
 if (ret == -1) {
  do { if (get_debug_level("permissions", (sizeof("permissions")-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: reload_im_cache(): could not reload cache\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "177" "]: ") , __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: reload_im_cache(): could not reload cache\n", (log_level_info[((-1)) - (-5)].name), ("permissions" " [" "im_db.c" ":" "177" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: reload_im_cache(): could not reload cache\n", process_no, my_pid(), ("permissions" " [" "im_db.c" ":" "177" "]: ") , __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: reload_im_cache(): could not reload cache\n", ("permissions" " [" "im_db.c" ":" "177" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: reload_im_cache(): could not reload cache\n", ("permissions" " [" "im_db.c" ":" "177" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  free_im_hash(hash);
  futex_release(&(IM_HASH)->write_lock);;
  return -1;
 } else if (ret == -2) {
  delete_im_hash(hash);
  hash = ((void *)0);
 }
 old_hash = IM_HASH->entries;
 set_wd_imhash();
 IM_HASH->entries = hash;
 del_wd_imhash();
 if (old_hash) free_im_hash(old_hash);
 futex_release(&(IM_HASH)->write_lock);;
 return 0;
}

variable_types: struct im_entry { 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; } ip; unsigned short port; struct _str { char *s; int len; } avp_val; unsigned int mark; struct im_entry *next; } **

variable_types: ret int

return_type: int

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

user_defined_types: struct im_entry { struct ip_addr ip; unsigned short port; struct _str avp_val; unsigned int mark; struct im_entry *next; }


decompiled_code:
__int64 __fastcall rr_dup(_QWORD *a1, __int64 a2)
{
__int64 v3; // rbp
__int64 result; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v5[0] = a2;
if ( a2 )
{
v3 = a2;
do
{
result = shm_duplicate_rr(a1, v3);
v3 = *(_QWORD *)(v3 + 64);
a1 = (_QWORD *)(*a1 + 64LL);
}
while ( v3 );
if ( v5[0] )
result = free_rr(v5);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, __int64 a2)
{
__int64 v3; // rbp
__int64 result; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v5[0] = a2;
if ( a2 )
{
v3 = a2;
do
{
result = shm_duplicate_rr(a1, v3);
v3 = *(_QWORD *)(v3 + 64);
a1 = (_QWORD *)(*a1 + 64LL);
}
while ( v3 );
if ( v5[0] )
result = free_rr(v5);
}
return result;
}

original_code:
static void rr_dup(rr_t **dst, rr_t *pkg_rr)
{
 rr_t *tmp = ((void *)0);
 int res;
 tmp = pkg_rr;
 while (pkg_rr) {
  res = shm_duplicate_rr(dst, pkg_rr);
  dst = &(*dst)->next;
  pkg_rr = pkg_rr->next;
 }
 if (tmp) free_rr(&tmp);
}

canonical_original_code:
static void rr_dup(struct rr **dst, struct rr *pkg_rr)
{
 struct rr *tmp = ((void *)0);
 int res;
 tmp = pkg_rr;
 while (pkg_rr) {
  res = shm_duplicate_rr(dst, pkg_rr);
  dst = &(*dst)->next;
  pkg_rr = pkg_rr->next;
 }
 if (tmp) free_rr(&tmp);
}

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 rr { struct name_addr nameaddr; struct param *r2; struct param *params; int len; struct rr *next; }

user_defined_types: struct name_addr { struct _str name; struct _str uri; int len; }

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


original_code:
int serialize_route_set(sstream_t *ss, rr_t **route_set)
{
 rr_t *r, *first = ((void *)0), *last = ((void *)0);
 int res = 0;
 if ((ss->type == sstream_in)) {
  do {
   res = serialize_route(ss, &r) | res;
   if (last) last->next = r;
   else first = r;
   last = r;
   if (last) {
    while (last->next) last = last->next;
   }
  } while (r);
  *route_set = first;
 }
 else {
  r = *route_set;
  while (r) {
   serialize_route(ss, &r);
   r = r->next;
  }
  r = ((void *)0);
  serialize_route(ss, &r);
 }
 return 0;
}

canonical_original_code:
int serialize_route_set(struct sstream_t *ss, struct rr **route_set)
{
 struct rr *r; struct rr *first = ((void *)0); struct rr *last = ((void *)0);
 int res = 0;
 if ((ss->type == sstream_in)) {
  do {
   res = serialize_route(ss, &r) | res;
   if (last) last->next = r;
   else first = r;
   last = r;
   if (last) {
    while (last->next) last = last->next;
   }
  } while (r);
  *route_set = first;
 }
 else {
  r = *route_set;
  while (r) {
   serialize_route(ss, &r);
   r = r->next;
  }
  r = ((void *)0);
  serialize_route(ss, &r);
 }
 return 0;
}

variable_types: struct sstream_t { struct _dstring_t { struct _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; } *first; struct _dstr_buff_t *last; int len; int buff_size; int error; } out; struct _str { char *s; int len; } in; int in_pos; enum { sstream_in=0, sstream_out=1 } type; } *

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

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

user_defined_types: struct sstream_t { struct _dstring_t out; struct _str in; int in_pos; enum { sstream_in=0, sstream_out=1 } type; }

user_defined_types: struct _dstring_t { struct _dstr_buff_t *first; struct _dstr_buff_t *last; int len; int buff_size; int error; }


decompiled_code:
__int64 __fastcall route_set2str(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v4; // r13
unsigned int v5; // eax
__int64 v6; // r13
unsigned int v7; // eax
__int64 v8; // [rsp+8h] [rbp-70h] BYREF
char v9[104]; // [rsp+10h] [rbp-68h] BYREF

v8 = a1;
init_output_sstream(v9, 256LL);
if ( (unsigned int)serialize_route_set((__int64)v9, &v8) )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
goto LABEL_7;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't serialize route set\n",
*((const char **)&log_level_info + 8),
"<core> [rr_serialize.c:94]: ",
"route_set2str");
LABEL_6:
--dprint_crit;
goto LABEL_7;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = *((_QWORD *)&log_level_info + 8);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't serialize route set\n",
process_no,
v5,
v4,
"<core> [rr_serialize.c:94]: ",
"route_set2str");
goto LABEL_17;
}
v2 = get_serialized_sstream(v9, a2);
if ( !v2 )
goto LABEL_8;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't get serialized data\n",
*((const char **)&log_level_info + 8),
"<core> [rr_serialize.c:99]: ",
"route_set2str");
goto LABEL_6;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = *((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't get serialized data\n",
process_no,
v7,
v6,
"<core> [rr_serialize.c:99]: ",
"route_set2str");
LABEL_17:
if ( log_color )
dprint_color_reset();
goto LABEL_6;
}
LABEL_7:
v2 = -1;
LABEL_8:
destroy_sstream(v9);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v4; // r13
unsigned int v5; // eax
__int64 v6; // r13
unsigned int v7; // eax
__int64 v8; // [rsp+8h] [rbp-70h] BYREF
char v9[104]; // [rsp+10h] [rbp-68h] BYREF

v8 = a1;
init_output_sstream(v9, 256LL);
if ( (unsigned int)func2((__int64)v9, &v8) )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
goto LABEL_7;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't serialize route set\n",
*((const char **)&log_level_info + 8),
"<core> [rr_serialize.c:94]: ",
"route_set2str");
LABEL_6:
--dprint_crit;
goto LABEL_7;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = *((_QWORD *)&log_level_info + 8);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't serialize route set\n",
process_no,
v5,
v4,
"<core> [rr_serialize.c:94]: ",
"route_set2str");
goto LABEL_17;
}
v2 = get_serialized_sstream(v9, a2);
if ( !v2 )
goto LABEL_8;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't get serialized data\n",
*((const char **)&log_level_info + 8),
"<core> [rr_serialize.c:99]: ",
"route_set2str");
goto LABEL_6;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = *((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't get serialized data\n",
process_no,
v7,
v6,
"<core> [rr_serialize.c:99]: ",
"route_set2str");
LABEL_17:
if ( log_color )
dprint_color_reset();
goto LABEL_6;
}
LABEL_7:
v2 = -1;
LABEL_8:
destroy_sstream(v9);
return v2;
}

original_code:
int route_set2str(rr_t *rr, str_t *dst_str)
{
 int res = 0;
 sstream_t store;
 init_output_sstream(&store, 256);
 if (serialize_route_set(&store, &rr) != 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't serialize route set\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't serialize route set\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't serialize route set\n", process_no, my_pid(), ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't serialize route set\n", ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't serialize route set\n", ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 else {
  if (get_serialized_sstream(&store, dst_str) != 0) {
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't get serialized data\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't get serialized data\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't get serialized data\n", process_no, my_pid(), ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't get serialized data\n", ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't get serialized data\n", ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   res = -1;
  }
 }
 destroy_sstream(&store);
 return res;
}

canonical_original_code:
int route_set2str(struct rr *rr, struct _str *dst_str)
{
 int res = 0;
 struct sstream_t store;
 init_output_sstream(&store, 256);
 if (serialize_route_set(&store, &rr) != 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't serialize route set\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't serialize route set\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't serialize route set\n", process_no, my_pid(), ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't serialize route set\n", ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't serialize route set\n", ("<core> [" "rr_serialize.c" ":" "94" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 else {
  if (get_serialized_sstream(&store, dst_str) != 0) {
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't get serialized data\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't get serialized data\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't get serialized data\n", process_no, my_pid(), ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't get serialized data\n", ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't get serialized data\n", ("<core> [" "rr_serialize.c" ":" "99" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   res = -1;
  }
 }
 destroy_sstream(&store);
 return res;
}

variable_types: struct sstream_t { struct _dstring_t { struct _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; } *first; struct _dstr_buff_t *last; int len; int buff_size; int error; } out; struct _str { char *s; int len; } in; int in_pos; enum { sstream_in=0, sstream_out=1 } type; }

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


decompiled_code:
__int64 __fastcall str2route_set(__int64 a1, __int64 *a2)
{
unsigned int v2; // er12
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
_BYTE v7[104]; // [rsp+0h] [rbp-68h] BYREF

if ( !a1 )
return (unsigned int)-1;
init_input_sstream(v7, *(_QWORD *)a1, *(unsigned int *)(a1 + 8));
v2 = serialize_route_set((__int64)v7, a2);
if ( v2 )
{
v2 = -1;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't de-serialize route set\n",
process_no,
v5,
v4,
"<core> [rr_serialize.c:117]: ",
"str2route_set");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v6,
"%2d(%d) %s: %s%s(): can't de-serialize route set\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't de-serialize route set\n",
*((const char **)&log_level_info + 8),
"<core> [rr_serialize.c:117]: ",
"str2route_set");
}
v2 = -1;
--dprint_crit;
}
}
destroy_sstream(v7);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 *a2)
{
unsigned int v2; // er12
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
_BYTE v7[104]; // [rsp+0h] [rbp-68h] BYREF

if ( !a1 )
return (unsigned int)-1;
init_input_sstream(v7, *(_QWORD *)a1, *(unsigned int *)(a1 + 8));
v2 = func2((__int64)v7, a2);
if ( v2 )
{
v2 = -1;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't de-serialize route set\n",
process_no,
v5,
v4,
"<core> [rr_serialize.c:117]: ",
"str2route_set");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v6,
"%2d(%d) %s: %s%s(): can't de-serialize route set\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't de-serialize route set\n",
*((const char **)&log_level_info + 8),
"<core> [rr_serialize.c:117]: ",
"str2route_set");
}
v2 = -1;
--dprint_crit;
}
}
destroy_sstream(v7);
return v2;
}

original_code:
int str2route_set(const str_t *s, rr_t **rr)
{
 int res = 0;
 sstream_t store;
 if (!s) return -1;
 init_input_sstream(&store, s->s, s->len);
 if (serialize_route_set(&store, rr) != 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't de-serialize route set\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __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 de-serialize route set\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't de-serialize route set\n", process_no, my_pid(), ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __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 de-serialize route set\n", ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __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 de-serialize route set\n", ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 destroy_sstream(&store);
 return res;
}

canonical_original_code:
int str2route_set(struct _str *s, struct rr **rr)
{
 int res = 0;
 struct sstream_t store;
 if (!s) return -1;
 init_input_sstream(&store, s->s, s->len);
 if (serialize_route_set(&store, rr) != 0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't de-serialize route set\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __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 de-serialize route set\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't de-serialize route set\n", process_no, my_pid(), ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __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 de-serialize route set\n", ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __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 de-serialize route set\n", ("<core> [" "rr_serialize.c" ":" "117" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 destroy_sstream(&store);
 return res;
}

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

user_defined_types: struct _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; }


decompiled_code:
char *__fastcall get_ini_key_name(const char *a1, const char *a2)
{
sprintf(ini_key_name, "%s:%s", a1, a2);
return ini_key_name;
}

canonical_decompiled_code:
char *__fastcall func2(const char *a1, const char *a2)
{
sprintf(ini_key_name, "%s:%s", a1, a2);
return ini_key_name;
}

original_code:
char* get_ini_key_name(char* _section, char* _key)
{
 sprintf(ini_key_name, "%s:%s", _section, _key);
 return ini_key_name;
}

canonical_original_code:
char *get_ini_key_name(char *_section, char *_key)
{
 sprintf(ini_key_name, "%s:%s", _section, _key);
 return ini_key_name;
}

return_type: char *


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


decompiled_code:
__int64 __fastcall token_char(int a1)
{
__int64 v1; // rcx
unsigned int v2; // er8

if ( (unsigned __int8)(a1 - 33) <= 0x39u )
{
v1 = 0x3FFFFFF01FFB651LL;
v2 = 1;
if ( _bittest64(&v1, (unsigned int)(a1 - 33)) )
return v2;
return (_BYTE)a1 == 126;
}
if ( (unsigned __int8)(a1 - 95) > 0x1Bu )
return (_BYTE)a1 == 126;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 v1; // rcx
unsigned int v2; // er8

if ( (unsigned __int8)(a1 - 33) <= 0x39u )
{
v1 = 0x3FFFFFF01FFB651LL;
v2 = 1;
if ( _bittest64(&v1, (unsigned int)(a1 - 33)) )
return v2;
return (_BYTE)a1 == 126;
}
if ( (unsigned __int8)(a1 - 95) > 0x1Bu )
return (_BYTE)a1 == 126;
return 1LL;
}


original_code:
static int parse_method_advance(str* const _next, enum request_method* const _method)
 {
 char* end;
  if (__builtin_expect(!!(!_next || !_method), 0)) {
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __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(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __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(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return 0;
  }
  if (__builtin_expect(!!(!_next->len || !_next->s), 0)) {
   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(): " "No input\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __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(): " "No input\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No input\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __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(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   *_method = METHOD_OTHER;
   return 1;
  }
 end=_next->s+_next->len;
  switch ((_next->s)[0]) {
  case 'A':
  case 'a':
   if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ck", 2)) {
    *_method = METHOD_ACK;
    _next->len -= 3;
    _next->s += 3;
   goto found;
   } else {
    goto unknown;
   }
  case 'B':
  case 'b':
   if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ye", 2)) {
    *_method = METHOD_BYE;
    _next->len -= 3;
    _next->s += 3;
   goto found;
   } else {
    goto unknown;
   }
  case 'C':
  case 'c':
   if ((_next->len > 5) && !strncasecmp(_next->s + 1, "ancel", 5)) {
    *_method = METHOD_CANCEL;
    _next->len -= 6;
    _next->s += 6;
   goto found;
   } else {
    goto unknown;
   }
  case 'I':
  case 'i':
   if ((_next->len > 3) &&
       ((*(_next->s + 1) == 'N') || (*(_next->s + 1) == 'n'))) {
    if (!strncasecmp(_next->s + 2, "fo", 2)) {
     *_method = METHOD_INFO;
     _next->len -= 4;
     _next->s += 4;
    goto found;
    }
    if ((_next->len > 5) && !strncasecmp(_next->s + 2, "vite", 4)) {
     *_method = METHOD_INVITE;
     _next->len -= 6;
     _next->s += 6;
    goto found;
    }
   }
   goto unknown;
  case 'M':
  case 'm':
   if ((_next->len > 6) && !strncasecmp(_next->s + 1, "essage", 6)) {
    *_method = METHOD_MESSAGE;
    _next->len -= 7;
    _next->s += 7;
   goto found;
   } else {
    goto unknown;
   }
  case 'N':
  case 'n':
   if ((_next->len > 5) && !strncasecmp(_next->s + 1, "otify", 5)) {
    *_method = METHOD_NOTIFY;
    _next->len -= 6;
    _next->s += 6;
   goto found;
   } else {
    goto unknown;
   }
  case 'O':
  case 'o':
   if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ptions", 6)) {
    *_method = METHOD_OPTIONS;
    _next->len -= 7;
    _next->s += 7;
   goto found;
   } else {
    goto unknown;
   }
  case 'P':
  case 'p':
   if ((_next->len > 4) && !strncasecmp(_next->s + 1, "rack", 4)) {
    *_method = METHOD_PRACK;
    _next->len -= 5;
    _next->s += 5;
   goto found;
   }
   if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ublish", 6)) {
    *_method = METHOD_PUBLISH;
    _next->len -= 7;
    _next->s += 7;
   goto found;
   }
   goto unknown;
  case 'R':
  case 'r':
   if ((_next->len > 4) &&
       ((*(_next->s + 1) == 'E') || (*(_next->s + 1) == 'e'))) {
    if (!strncasecmp(_next->s + 2, "fer", 3)) {
     *_method = METHOD_REFER;
     _next->len -= 5;
     _next->s += 5;
    goto found;
    }
    if ((_next->len > 7) && !strncasecmp(_next->s + 2, "gister", 6)) {
     *_method = METHOD_REGISTER;
     _next->len -= 8;
     _next->s += 8;
    goto found;
    }
   }
   goto unknown;
  case 'S':
  case 's':
   if ((_next->len > 8) && !strncasecmp(_next->s + 1, "ubscribe", 8)) {
    *_method = METHOD_SUBSCRIBE;
    _next->len -= 9;
    _next->s += 9;
   goto found;
   } else {
    goto unknown;
   }
  case 'U':
  case 'u':
   if ((_next->len > 5) && !strncasecmp(_next->s + 1, "pdate", 5)) {
    *_method = METHOD_UPDATE;
    _next->len -= 6;
    _next->s += 6;
   goto found;
   } else {
    goto unknown;
   }
  default:
   goto unknown;
  }
 unknown:
  if (token_char(*(_next->s))) {
   do {
    _next->s++;
    _next->len--;
   } while (_next->len && token_char(*(_next->s)));
   *_method = METHOD_OTHER;
   return 1;
  } else {
   return 0;
  }
found:
 return (_next->s>=end) || (!token_char(*(_next->s)));
 }

canonical_original_code:
static int parse_method_advance(struct _str *_next, enum request_method *_method)
 {
 char *end;
  if (__builtin_expect(!!(!_next || !_method), 0)) {
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __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(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __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(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "178" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return 0;
  }
  if (__builtin_expect(!!(!_next->len || !_next->s), 0)) {
   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(): " "No input\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __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(): " "No input\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No input\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __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(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "183" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   *_method = METHOD_OTHER;
   return 1;
  }
 end=_next->s+_next->len;
  switch ((_next->s)[0]) {
  case 'A':
  case 'a':
   if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ck", 2)) {
    *_method = METHOD_ACK;
    _next->len -= 3;
    _next->s += 3;
   goto found;
   } else {
    goto unknown;
   }
  case 'B':
  case 'b':
   if ((_next->len > 2) && !strncasecmp(_next->s + 1, "ye", 2)) {
    *_method = METHOD_BYE;
    _next->len -= 3;
    _next->s += 3;
   goto found;
   } else {
    goto unknown;
   }
  case 'C':
  case 'c':
   if ((_next->len > 5) && !strncasecmp(_next->s + 1, "ancel", 5)) {
    *_method = METHOD_CANCEL;
    _next->len -= 6;
    _next->s += 6;
   goto found;
   } else {
    goto unknown;
   }
  case 'I':
  case 'i':
   if ((_next->len > 3) &&
       ((*(_next->s + 1) == 'N') || (*(_next->s + 1) == 'n'))) {
    if (!strncasecmp(_next->s + 2, "fo", 2)) {
     *_method = METHOD_INFO;
     _next->len -= 4;
     _next->s += 4;
    goto found;
    }
    if ((_next->len > 5) && !strncasecmp(_next->s + 2, "vite", 4)) {
     *_method = METHOD_INVITE;
     _next->len -= 6;
     _next->s += 6;
    goto found;
    }
   }
   goto unknown;
  case 'M':
  case 'm':
   if ((_next->len > 6) && !strncasecmp(_next->s + 1, "essage", 6)) {
    *_method = METHOD_MESSAGE;
    _next->len -= 7;
    _next->s += 7;
   goto found;
   } else {
    goto unknown;
   }
  case 'N':
  case 'n':
   if ((_next->len > 5) && !strncasecmp(_next->s + 1, "otify", 5)) {
    *_method = METHOD_NOTIFY;
    _next->len -= 6;
    _next->s += 6;
   goto found;
   } else {
    goto unknown;
   }
  case 'O':
  case 'o':
   if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ptions", 6)) {
    *_method = METHOD_OPTIONS;
    _next->len -= 7;
    _next->s += 7;
   goto found;
   } else {
    goto unknown;
   }
  case 'P':
  case 'p':
   if ((_next->len > 4) && !strncasecmp(_next->s + 1, "rack", 4)) {
    *_method = METHOD_PRACK;
    _next->len -= 5;
    _next->s += 5;
   goto found;
   }
   if ((_next->len > 6) && !strncasecmp(_next->s + 1, "ublish", 6)) {
    *_method = METHOD_PUBLISH;
    _next->len -= 7;
    _next->s += 7;
   goto found;
   }
   goto unknown;
  case 'R':
  case 'r':
   if ((_next->len > 4) &&
       ((*(_next->s + 1) == 'E') || (*(_next->s + 1) == 'e'))) {
    if (!strncasecmp(_next->s + 2, "fer", 3)) {
     *_method = METHOD_REFER;
     _next->len -= 5;
     _next->s += 5;
    goto found;
    }
    if ((_next->len > 7) && !strncasecmp(_next->s + 2, "gister", 6)) {
     *_method = METHOD_REGISTER;
     _next->len -= 8;
     _next->s += 8;
    goto found;
    }
   }
   goto unknown;
  case 'S':
  case 's':
   if ((_next->len > 8) && !strncasecmp(_next->s + 1, "ubscribe", 8)) {
    *_method = METHOD_SUBSCRIBE;
    _next->len -= 9;
    _next->s += 9;
   goto found;
   } else {
    goto unknown;
   }
  case 'U':
  case 'u':
   if ((_next->len > 5) && !strncasecmp(_next->s + 1, "pdate", 5)) {
    *_method = METHOD_UPDATE;
    _next->len -= 6;
    _next->s += 6;
   goto found;
   } else {
    goto unknown;
   }
  default:
   goto unknown;
  }
 unknown:
  if (token_char(*(_next->s))) {
   do {
    _next->s++;
    _next->len--;
   } while (_next->len && token_char(*(_next->s)));
   *_method = METHOD_OTHER;
   return 1;
  } else {
   return 0;
  }
found:
 return (_next->s>=end) || (!token_char(*(_next->s)));
 }

variable_types: enum request_method { METHOD_UNDEF=0, METHOD_INVITE=1, METHOD_CANCEL=2, METHOD_ACK=4, METHOD_BYE=8, METHOD_INFO=16, METHOD_REGISTER=32, METHOD_SUBSCRIBE=64, METHOD_NOTIFY=128, METHOD_MESSAGE=256, METHOD_OPTIONS=512, METHOD_PRACK=1024, METHOD_UPDATE=2048, METHOD_REFER=4096, METHOD_PUBLISH=8192, METHOD_OTHER=16384 } *

variable_types:
end
char *


decompiled_code:
int __fastcall parse_method_name(__int64 *a1, _DWORD *a2)
{
int v2; // edx
__int64 v3; // rdi
int result; // eax
int v5; // ebx
const char *v6; // rbp
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
const char *v9; // rbp
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi

if ( a1 && a2 )
{
v2 = *((_DWORD *)a1 + 2);
if ( v2 && (v3 = *a1) != 0 )
{
switch ( *(_BYTE *)v3 )
{
case 'A':
case 'a':
if ( v2 != 3 )
break;
result = strncasecmp((const char *)(v3 + 1), "ck", 2uLL);
if ( result )
break;
*a2 = 4;
return result;
case 'B':
case 'b':
if ( v2 != 3 )
break;
result = strncasecmp((const char *)(v3 + 1), "ye", 2uLL);
if ( result )
break;
*a2 = 8;
return result;
case 'C':
case 'c':
if ( v2 != 6 )
break;
result = strncasecmp((const char *)(v3 + 1), "ancel", 5uLL);
if ( result )
break;
*a2 = 2;
return result;
case 'I':
case 'i':
if ( v2 == 6 )
{
result = strncasecmp((const char *)(v3 + 1), "nvite", 5uLL);
if ( result )
break;
*a2 = 1;
return result;
}
if ( v2 == 4 )
{
result = strncasecmp((const char *)(v3 + 1), "nfo", 3uLL);
if ( !result )
{
*a2 = 16;
return result;
}
}
break;
case 'M':
case 'm':
if ( v2 != 7 )
break;
result = strncasecmp((const char *)(v3 + 1), "essage", 6uLL);
if ( result )
break;
*a2 = 256;
return result;
case 'N':
case 'n':
if ( v2 != 6 )
break;
result = strncasecmp((const char *)(v3 + 1), "otify", 5uLL);
if ( result )
break;
*a2 = 128;
return result;
case 'O':
case 'o':
if ( v2 != 7 )
break;
result = strncasecmp((const char *)(v3 + 1), "ptions", 6uLL);
if ( result )
break;
*a2 = 512;
return result;
case 'P':
case 'p':
if ( v2 == 5 )
{
result = strncasecmp((const char *)(v3 + 1), "rack", 4uLL);
if ( result )
break;
*a2 = 1024;
return result;
}
if ( v2 == 7 )
{
result = strncasecmp((const char *)(v3 + 1), "ublish", 6uLL);
if ( !result )
{
*a2 = 0x2000;
return result;
}
}
break;
case 'R':
case 'r':
if ( v2 == 8 )
{
result = strncasecmp((const char *)(v3 + 1), "egister", 7uLL);
if ( result )
break;
*a2 = 32;
return result;
}
if ( v2 == 5 )
{
result = strncasecmp((const char *)(v3 + 1), "efer", 4uLL);
if ( !result )
{
*a2 = 4096;
return result;
}
}
break;
case 'S':
case 's':
if ( v2 != 9 )
break;
result = strncasecmp((const char *)(v3 + 1), "ubscribe", 8uLL);
if ( result )
break;
*a2 = 64;
return result;
case 'U':
case 'u':
if ( v2 != 6 )
break;
result = strncasecmp((const char *)(v3 + 1), "pdate", 5uLL);
if ( result )
break;
*a2 = 2048;
return result;
default:
break;
}
}
else if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 16);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No input\n",
process_no,
v7,
v6,
"<core> [parser/parse_methods.c:62]: ",
"parse_method_name");
if ( log_color )
dprint_color_reset(v8, "%2d(%d) %s: %s%s(): No input\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No input\n",
*((const char **)&log_level_info + 16),
"<core> [parser/parse_methods.c:62]: ",
"parse_method_name");
}
--dprint_crit;
}
*a2 = 0x4000;
result = 0;
}
else
{
v5 = get_debug_level("core", 4LL);
result = -1;
if ( v5 >= -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();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Invalid parameter value\n",
process_no,
v10,
v9,
"<core> [parser/parse_methods.c:57]: ",
"parse_method_name");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): Invalid parameter value\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:57]: ",
"parse_method_name");
}
result = -1;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 *a1, _DWORD *a2)
{
int v2; // edx
__int64 v3; // rdi
int result; // eax
int v5; // ebx
const char *v6; // rbp
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
const char *v9; // rbp
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi

if ( a1 && a2 )
{
v2 = *((_DWORD *)a1 + 2);
if ( v2 && (v3 = *a1) != 0 )
{
switch ( *(_BYTE *)v3 )
{
case 'A':
case 'a':
if ( v2 != 3 )
break;
result = strncasecmp((const char *)(v3 + 1), "ck", 2uLL);
if ( result )
break;
*a2 = 4;
return result;
case 'B':
case 'b':
if ( v2 != 3 )
break;
result = strncasecmp((const char *)(v3 + 1), "ye", 2uLL);
if ( result )
break;
*a2 = 8;
return result;
case 'C':
case 'c':
if ( v2 != 6 )
break;
result = strncasecmp((const char *)(v3 + 1), "ancel", 5uLL);
if ( result )
break;
*a2 = 2;
return result;
case 'I':
case 'i':
if ( v2 == 6 )
{
result = strncasecmp((const char *)(v3 + 1), "nvite", 5uLL);
if ( result )
break;
*a2 = 1;
return result;
}
if ( v2 == 4 )
{
result = strncasecmp((const char *)(v3 + 1), "nfo", 3uLL);
if ( !result )
{
*a2 = 16;
return result;
}
}
break;
case 'M':
case 'm':
if ( v2 != 7 )
break;
result = strncasecmp((const char *)(v3 + 1), "essage", 6uLL);
if ( result )
break;
*a2 = 256;
return result;
case 'N':
case 'n':
if ( v2 != 6 )
break;
result = strncasecmp((const char *)(v3 + 1), "otify", 5uLL);
if ( result )
break;
*a2 = 128;
return result;
case 'O':
case 'o':
if ( v2 != 7 )
break;
result = strncasecmp((const char *)(v3 + 1), "ptions", 6uLL);
if ( result )
break;
*a2 = 512;
return result;
case 'P':
case 'p':
if ( v2 == 5 )
{
result = strncasecmp((const char *)(v3 + 1), "rack", 4uLL);
if ( result )
break;
*a2 = 1024;
return result;
}
if ( v2 == 7 )
{
result = strncasecmp((const char *)(v3 + 1), "ublish", 6uLL);
if ( !result )
{
*a2 = 0x2000;
return result;
}
}
break;
case 'R':
case 'r':
if ( v2 == 8 )
{
result = strncasecmp((const char *)(v3 + 1), "egister", 7uLL);
if ( result )
break;
*a2 = 32;
return result;
}
if ( v2 == 5 )
{
result = strncasecmp((const char *)(v3 + 1), "efer", 4uLL);
if ( !result )
{
*a2 = 4096;
return result;
}
}
break;
case 'S':
case 's':
if ( v2 != 9 )
break;
result = strncasecmp((const char *)(v3 + 1), "ubscribe", 8uLL);
if ( result )
break;
*a2 = 64;
return result;
case 'U':
case 'u':
if ( v2 != 6 )
break;
result = strncasecmp((const char *)(v3 + 1), "pdate", 5uLL);
if ( result )
break;
*a2 = 2048;
return result;
default:
break;
}
}
else if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 16);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No input\n",
process_no,
v7,
v6,
"<core> [parser/parse_methods.c:62]: ",
"parse_method_name");
if ( log_color )
dprint_color_reset(v8, "%2d(%d) %s: %s%s(): No input\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No input\n",
*((const char **)&log_level_info + 16),
"<core> [parser/parse_methods.c:62]: ",
"parse_method_name");
}
--dprint_crit;
}
*a2 = 0x4000;
result = 0;
}
else
{
v5 = get_debug_level("core", 4LL);
result = -1;
if ( v5 >= -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();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Invalid parameter value\n",
process_no,
v10,
v9,
"<core> [parser/parse_methods.c:57]: ",
"parse_method_name");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): Invalid parameter value\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:57]: ",
"parse_method_name");
}
result = -1;
--dprint_crit;
}
}
return result;
}

original_code:
int parse_method_name(const str* const s, enum request_method* const method)
 {
 if (__builtin_expect(!!(!s || !method), 0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __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(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __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(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (__builtin_expect(!!(!s->len || (s->s==0)), 0)) {
  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(): " "No input\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __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(): " "No input\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No input\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __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(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  *method = METHOD_OTHER;
  return 0;
 }
 switch ((s->s)[0]) {
  case 'R':
  case 'r':
   if (__builtin_expect(!!((s->len == 8) && !strncasecmp(s->s + 1, "egister", 7)), 1)) {
    *method = METHOD_REGISTER;
    return 0;
   }
   if (__builtin_expect(!!((s->len==5) && !strncasecmp(s->s + 1, "efer", 4)), 1)) {
    *method = METHOD_REFER;
    return 0;
   }
   break;
  case 'A':
  case 'a':
   if (__builtin_expect(!!((s->len==3) && !strncasecmp(s->s + 1, "ck", 2)), 1)) {
    *method = METHOD_ACK;
    return 0;
   }
   break;
  case 'I':
  case 'i':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "nvite", 5)), 1)){
    *method = METHOD_INVITE;
    return 0;
   }
   if (__builtin_expect(!!((s->len==4) && !strncasecmp(s->s + 1, "nfo", 3)), 1)) {
    *method = METHOD_INFO;
    return 0;
   }
   break;
  case 'P':
  case 'p':
   if (__builtin_expect(!!((s->len==5) && !strncasecmp(s->s + 1, "rack", 4)), 1)) {
    *method = METHOD_PRACK;
    return 0;
   }
   if (__builtin_expect(!!((s->len==7) && !strncasecmp(s->s + 1, "ublish", 6)), 1)) {
    *method = METHOD_PUBLISH;
    return 0;
   }
   break;
  case 'C':
  case 'c':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "ancel", 5)), 1)) {
    *method = METHOD_CANCEL;
    return 0;
   }
   break;
  case 'B':
  case 'b':
   if (__builtin_expect(!!((s->len==3) && !strncasecmp(s->s + 1, "ye", 2)), 1)) {
    *method = METHOD_BYE;
    return 0;
   }
   break;
  case 'M':
  case 'm':
   if (__builtin_expect(!!((s->len==7) && !strncasecmp(s->s + 1, "essage", 6)), 1)) {
    *method = METHOD_MESSAGE;
    return 0;
   }
   break;
  case 'O':
  case 'o':
   if (__builtin_expect(!!((s->len==7) && !strncasecmp(s->s + 1, "ptions", 6)), 1)) {
    *method = METHOD_OPTIONS;
    return 0;
   }
   break;
  case 'S':
  case 's':
   if (__builtin_expect(!!((s->len==9) && !strncasecmp(s->s + 1, "ubscribe", 8)), 1)) {
    *method = METHOD_SUBSCRIBE;
    return 0;
   }
   break;
  case 'N':
  case 'n':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "otify", 5)), 1)){
    *method = METHOD_NOTIFY;
    return 0;
   }
   break;
  case 'U':
  case 'u':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "pdate", 5)), 1)){
    *method = METHOD_UPDATE;
    return 0;
   }
   break;
  default:
   break;
 }
 *method = METHOD_OTHER;
 return 0;
}

canonical_original_code:
int parse_method_name(struct _str *s, enum request_method *method)
 {
 if (__builtin_expect(!!(!s || !method), 0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __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(): " "Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __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(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "57" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (__builtin_expect(!!(!s->len || (s->s==0)), 0)) {
  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(): " "No input\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __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(): " "No input\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No input\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __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(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No input\n", ("<core> [" "parser/parse_methods.c" ":" "62" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  *method = METHOD_OTHER;
  return 0;
 }
 switch ((s->s)[0]) {
  case 'R':
  case 'r':
   if (__builtin_expect(!!((s->len == 8) && !strncasecmp(s->s + 1, "egister", 7)), 1)) {
    *method = METHOD_REGISTER;
    return 0;
   }
   if (__builtin_expect(!!((s->len==5) && !strncasecmp(s->s + 1, "efer", 4)), 1)) {
    *method = METHOD_REFER;
    return 0;
   }
   break;
  case 'A':
  case 'a':
   if (__builtin_expect(!!((s->len==3) && !strncasecmp(s->s + 1, "ck", 2)), 1)) {
    *method = METHOD_ACK;
    return 0;
   }
   break;
  case 'I':
  case 'i':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "nvite", 5)), 1)){
    *method = METHOD_INVITE;
    return 0;
   }
   if (__builtin_expect(!!((s->len==4) && !strncasecmp(s->s + 1, "nfo", 3)), 1)) {
    *method = METHOD_INFO;
    return 0;
   }
   break;
  case 'P':
  case 'p':
   if (__builtin_expect(!!((s->len==5) && !strncasecmp(s->s + 1, "rack", 4)), 1)) {
    *method = METHOD_PRACK;
    return 0;
   }
   if (__builtin_expect(!!((s->len==7) && !strncasecmp(s->s + 1, "ublish", 6)), 1)) {
    *method = METHOD_PUBLISH;
    return 0;
   }
   break;
  case 'C':
  case 'c':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "ancel", 5)), 1)) {
    *method = METHOD_CANCEL;
    return 0;
   }
   break;
  case 'B':
  case 'b':
   if (__builtin_expect(!!((s->len==3) && !strncasecmp(s->s + 1, "ye", 2)), 1)) {
    *method = METHOD_BYE;
    return 0;
   }
   break;
  case 'M':
  case 'm':
   if (__builtin_expect(!!((s->len==7) && !strncasecmp(s->s + 1, "essage", 6)), 1)) {
    *method = METHOD_MESSAGE;
    return 0;
   }
   break;
  case 'O':
  case 'o':
   if (__builtin_expect(!!((s->len==7) && !strncasecmp(s->s + 1, "ptions", 6)), 1)) {
    *method = METHOD_OPTIONS;
    return 0;
   }
   break;
  case 'S':
  case 's':
   if (__builtin_expect(!!((s->len==9) && !strncasecmp(s->s + 1, "ubscribe", 8)), 1)) {
    *method = METHOD_SUBSCRIBE;
    return 0;
   }
   break;
  case 'N':
  case 'n':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "otify", 5)), 1)){
    *method = METHOD_NOTIFY;
    return 0;
   }
   break;
  case 'U':
  case 'u':
   if (__builtin_expect(!!((s->len==6) && !strncasecmp(s->s + 1, "pdate", 5)), 1)){
    *method = METHOD_UPDATE;
    return 0;
   }
   break;
  default:
   break;
 }
 *method = METHOD_OTHER;
 return 0;
}

user_defined_types: enum request_method { METHOD_UNDEF=0, METHOD_INVITE=1, METHOD_CANCEL=2, METHOD_ACK=4, METHOD_BYE=8, METHOD_INFO=16, METHOD_REGISTER=32, METHOD_SUBSCRIBE=64, METHOD_NOTIFY=128, METHOD_MESSAGE=256, METHOD_OPTIONS=512, METHOD_PRACK=1024, METHOD_UPDATE=2048, METHOD_REFER=4096, METHOD_PUBLISH=8192, METHOD_OTHER=16384 }