decompiled_code:
__int64 __fastcall domain_reload(__int64 (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
__int64 result; // rax

if ( !db_mode )
return (*a1)(a2, 200LL, "Server Domain Cache Disabled");
result = reload_domain_list();
if ( (int)result < 0 )
result = (*a1)(a2, 400LL, "Domain Table Reload Failed");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
__int64 result; // rax

if ( !db_mode )
return (*a1)(a2, 200LL, "Server Domain Cache Disabled");
result = reload_domain_list();
if ( (int)result < 0 )
result = (*a1)(a2, 400LL, "Domain Table Reload Failed");
return result;
}

original_code:
static void domain_reload(rpc_t* rpc, void* ctx)
{
 if (!db_mode) {
  rpc->fault(ctx, 200, "Server Domain Cache Disabled");
  return;
 }
 if (reload_domain_list() < 0) {
  rpc->fault(ctx, 400, "Domain Table Reload Failed");
 }
}

canonical_original_code:
static void domain_reload(struct rpc *rpc, void *ctx)
{
 if (!db_mode) {
  rpc->fault(ctx, 200, "Server Domain Cache Disabled");
  return;
 }
 if (reload_domain_list() < 0) {
  rpc->fault(ctx, 400, "Domain Table Reload Failed");
 }
}

variable_types: struct rpc { void (*fault)(void *ctx, int code, char *fmt, ...); int (*send)(void *ctx); int (*add)(void *ctx, char *fmt, ...); int (*scan)(void *ctx, char *fmt, ...); int (*printf)(void *ctx, char *fmt, ...); int (*struct_add)(void *ctx, char *fmt, ...); int (*struct_scan)(void *ctx, char *fmt, ...); int (*struct_printf)(void *ctx, char *name, char *fmt, ...); enum rpc_capabilities { RPC_DELAYED_REPLY=expr } (*capabilities)(void *ctx); struct rpc_delayed_ctx { struct rpc rpc; void *reply_ctx; } *(*delayed_ctx_new)(void *ctx); void (*delayed_ctx_close)(struct rpc_delayed_ctx *dctx); } *

variable_types:
ctx
void *


repo: virtualolson/who

decompiled_code:
__int64 __fastcall dump_domain_list(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rbx
__int64 result; // rax

if ( a3 )
{
v3 = a3;
do
{
result = dump_domain(a1, a2, v3);
v3 = *(_QWORD *)(v3 + 48);
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rbx
__int64 result; // rax

if ( a3 )
{
v3 = a3;
do
{
result = func0(a1, a2, v3);
v3 = *(_QWORD *)(v3 + 48);
}
while ( v3 );
}
return result;
}

original_code:
void dump_domain_list(rpc_t* rpc, void* ctx, domain_t* list)
{
 while(list) {
  dump_domain(rpc, ctx, list);
  list = list->next;
 }
}

canonical_original_code:
void dump_domain_list(struct rpc *rpc, void *ctx, struct domain *list)
{
 while(list) {
  dump_domain(rpc, ctx, list);
  list = list->next;
 }
}

variable_types: struct domain { struct _str { char *s; int len; } did; int n; struct _str *domain; unsigned int *flags; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *attrs; struct domain *next; } *

return_type: void

user_defined_types: struct rpc { void (*fault)(void *ctx, int code, char *fmt, ...); int (*send)(void *ctx); int (*add)(void *ctx, char *fmt, ...); int (*scan)(void *ctx, char *fmt, ...); int (*printf)(void *ctx, char *fmt, ...); int (*struct_add)(void *ctx, char *fmt, ...); int (*struct_scan)(void *ctx, char *fmt, ...); int (*struct_printf)(void *ctx, char *name, char *fmt, ...); enum rpc_capabilities (*capabilities)(void *ctx); struct rpc_delayed_ctx *(*delayed_ctx_new)(void *ctx); void (*delayed_ctx_close)(struct rpc_delayed_ctx *dctx); }

user_defined_types: struct domain { struct _str did; int n; struct _str *domain; unsigned int *flags; struct usr_avp *attrs; struct domain *next; }

user_defined_types: struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data d; }

user_defined_types: enum rpc_capabilities { RPC_DELAYED_REPLY=expr }

user_defined_types: struct rpc_delayed_ctx { struct rpc rpc; void *reply_ctx; }


decompiled_code:
__int64 __fastcall domain_dump(__int64 (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
if ( !db_mode )
return (*a1)(a2, 400LL, "Server Domain Cache Disabled");
if ( *active_hash == hash_1 )
return dump_domain_list((__int64)a1, a2, *domains_1);
return dump_domain_list((__int64)a1, a2, *domains_2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
if ( !db_mode )
return (*a1)(a2, 400LL, "Server Domain Cache Disabled");
if ( *active_hash == hash_1 )
return func2((__int64)a1, a2, *domains_1);
return func2((__int64)a1, a2, *domains_2);
}

original_code:
static void domain_dump(rpc_t* rpc, void* ctx)
{
 domain_t* list;
 if (!db_mode) {
  rpc->fault(ctx, 400, "Server Domain Cache Disabled");
  return;
 }
 if (*active_hash == hash_1) list = *domains_1;
 else list = *domains_2;
 dump_domain_list(rpc, ctx, list);
}

canonical_original_code:
static void domain_dump(struct rpc *rpc, void *ctx)
{
 struct domain *list;
 if (!db_mode) {
  rpc->fault(ctx, 400, "Server Domain Cache Disabled");
  return;
 }
 if (*active_hash == hash_1) list = *domains_1;
 else list = *domains_2;
 dump_domain_list(rpc, ctx, list);
}

user_defined_types: union usr_avp_data { void *p; long l; char data[-1]; }


decompiled_code:
void __fastcall dump_hdr_field(unsigned int *a1)
{
const char *v1; // rbp
const char *v2; // r8
const char *v3; // rbp
unsigned int v4; // er15
const char *v5; // r12
__int64 v6; // r13
unsigned int v7; // er14
const char *v8; // rbx
unsigned int v9; // eax
const void *v10; // [rsp+0h] [rbp-48h]
const void *v11; // [rsp+8h] [rbp-40h]

if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)&unk_473;
v4 = a1[8];
v11 = (const void *)*((_QWORD *)a1 + 7);
v5 = (const char *)*((_QWORD *)a1 + 3);
v10 = (const void *)*((_QWORD *)a1 + 6);
v6 = *a1;
if ( !v5 )
v5 = (const char *)&unk_473;
if ( *((_QWORD *)a1 + 1) )
v3 = (const char *)*((_QWORD *)a1 + 1);
v7 = a1[4];
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: dump_hdr_field: type=%d, name=%.*s, body=%.*s, parsed=%p, next=%p\n",
process_no,
v9,
v8,
"<core> [parser/hf.c:232]: ",
"dump_hdr_field",
v6,
v7,
v3,
v4,
v5,
v10,
v11);
if ( log_color )
dprint_color_reset();
}
else
{
v1 = (const char *)*((_QWORD *)a1 + 3);
v2 = (const char *)*((_QWORD *)a1 + 1);
if ( !v1 )
v1 = (const char *)&unk_473;
if ( !v2 )
v2 = (const char *)&unk_473;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: dump_hdr_field: type=%d, name=%.*s, body=%.*s, parsed=%p, next=%p\n",
*((const char **)&log_level_info + 8),
"<core> [parser/hf.c:232]: ",
"dump_hdr_field",
*a1,
a1[4],
v2,
a1[8],
v1,
*((const void **)a1 + 6),
*((const void **)a1 + 7));
}
--dprint_crit;
}
}

canonical_decompiled_code:
void __fastcall func0(unsigned int *a1)
{
const char *v1; // rbp
const char *v2; // r8
const char *v3; // rbp
unsigned int v4; // er15
const char *v5; // r12
__int64 v6; // r13
unsigned int v7; // er14
const char *v8; // rbx
unsigned int v9; // eax
const void *v10; // [rsp+0h] [rbp-48h]
const void *v11; // [rsp+8h] [rbp-40h]

if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)&unk_473;
v4 = a1[8];
v11 = (const void *)*((_QWORD *)a1 + 7);
v5 = (const char *)*((_QWORD *)a1 + 3);
v10 = (const void *)*((_QWORD *)a1 + 6);
v6 = *a1;
if ( !v5 )
v5 = (const char *)&unk_473;
if ( *((_QWORD *)a1 + 1) )
v3 = (const char *)*((_QWORD *)a1 + 1);
v7 = a1[4];
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: dump_hdr_field: type=%d, name=%.*s, body=%.*s, parsed=%p, next=%p\n",
process_no,
v9,
v8,
"<core> [parser/hf.c:232]: ",
"dump_hdr_field",
v6,
v7,
v3,
v4,
v5,
v10,
v11);
if ( log_color )
dprint_color_reset();
}
else
{
v1 = (const char *)*((_QWORD *)a1 + 3);
v2 = (const char *)*((_QWORD *)a1 + 1);
if ( !v1 )
v1 = (const char *)&unk_473;
if ( !v2 )
v2 = (const char *)&unk_473;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: dump_hdr_field: type=%d, name=%.*s, body=%.*s, parsed=%p, next=%p\n",
*((const char **)&log_level_info + 8),
"<core> [parser/hf.c:232]: ",
"dump_hdr_field",
*a1,
a1[4],
v2,
a1[8],
v1,
*((const void **)a1 + 6),
*((const void **)a1 + 7));
}
--dprint_crit;
}
}

original_code:
void dump_hdr_field(struct hdr_field const* const hf )
{
 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(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); 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(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", process_no, my_pid(), ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); 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(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); } } (dprint_crit--); } } while(0);
}

canonical_original_code:
void dump_hdr_field(struct hdr_field *hf)
{
 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(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); 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(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", process_no, my_pid(), ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); 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(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: dump_hdr_field: type=%d, name=%.*s, " "body=%.*s, parsed=%p, next=%p\n", ("<core> [" "parser/hf.c" ":" "232" "]: ") , __func__, hf->type, hf->name.len, ((hf->name.s)?(hf->name.s):""), hf->body.len, ((hf->body.s)?(hf->body.s):""), hf->parsed, hf->next); } } (dprint_crit--); } } while(0);
}

variable_types: struct hdr_field { enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 } type; struct _str { char *s; int len; } name; struct _str body; int len; void *parsed; struct hdr_field *next; } *

user_defined_types: struct hdr_field { enum _hdr_types_t type; struct _str name; struct _str body; int len; void *parsed; struct hdr_field *next; }

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


decompiled_code:
void __fastcall clean_hdr_field(unsigned int *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // rdi
unsigned int *v6; // r8
__int64 v7; // rbx
const char *v8; // rbp
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-8h] [rbp-20h]

v5 = *((_QWORD *)a1 + 6);
if ( v5 )
{
v6 = a1 + 12;
switch ( *a1 )
{
case 1u:
free_via_list(v5, a2, a3, a4, v6);
break;
case 3u:
case 4u:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
free_to(v5, a2, a3, a4, v6);
break;
case 5u:
free_cseq(v5, a2, a3, a4, v6);
break;
case 6u:
case 8u:
case 0xBu:
case 0xCu:
case 0x11u:
case 0x12u:
case 0x13u:
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x23u:
case 0x25u:
case 0x26u:
case 0x27u:
case 0x28u:
case 0x29u:
case 0x2Au:
case 0x2Bu:
case 0x2Cu:
case 0x30u:
case 0x33u:
case 0x34u:
case 0x35u:
return;
case 7u:
free_contact(a1 + 12);
break;
case 9u:
case 0xAu:
free_rr(a1 + 12);
break;
case 0xDu:
case 0xFu:
free_credentials(a1 + 12);
break;
case 0xEu:
free_expires(a1 + 12);
break;
case 0x10u:
case 0x22u:
hdr_free_parsed((void (***)(void))a1 + 6);
break;
case 0x14u:
free_allow_header(a1, a2, a3, a4, v6);
break;
case 0x15u:
free_event(a1 + 12);
break;
case 0x16u:
qm_free(mem_block, v5, a3, a4, v6);
break;
case 0x1Du:
free_disposition(a1 + 12);
break;
case 0x21u:
free_sipifmatch(a1 + 12);
break;
case 0x24u:
free_subscription_state(a1 + 12);
break;
case 0x2Du:
free_date(v5, a2, a3, a4, v6);
break;
case 0x2Eu:
free_identity(v5, a2, a3, a4, v6);
break;
case 0x2Fu:
free_identityinfo(v5, a2, a3, a4, v6);
break;
case 0x31u:
case 0x32u:
free_pai_ppi_body(v5, a2, a3, a4, v6);
break;
default:
if ( (int)get_debug_level("core", 4LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v7 = *a1;
v8 = (const char *)*((_QWORD *)&log_level_info + 6);
v9 = my_pid();
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG: clean_hdr_field: unknown header type %d\n",
process_no,
v9,
v8,
"<core> [parser/hf.c:207]: ",
"clean_hdr_field",
v7);
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): BUG: clean_hdr_field: unknown header type %d\n", v11);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG: clean_hdr_field: unknown header type %d\n",
*((const char **)&log_level_info + 6),
"<core> [parser/hf.c:207]: ",
"clean_hdr_field",
*a1);
}
--dprint_crit;
}
break;
}
}
}

canonical_decompiled_code:
void __fastcall func2(unsigned int *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // rdi
unsigned int *v6; // r8
__int64 v7; // rbx
const char *v8; // rbp
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-8h] [rbp-20h]

v5 = *((_QWORD *)a1 + 6);
if ( v5 )
{
v6 = a1 + 12;
switch ( *a1 )
{
case 1u:
free_via_list(v5, a2, a3, a4, v6);
break;
case 3u:
case 4u:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
free_to(v5, a2, a3, a4, v6);
break;
case 5u:
free_cseq(v5, a2, a3, a4, v6);
break;
case 6u:
case 8u:
case 0xBu:
case 0xCu:
case 0x11u:
case 0x12u:
case 0x13u:
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x23u:
case 0x25u:
case 0x26u:
case 0x27u:
case 0x28u:
case 0x29u:
case 0x2Au:
case 0x2Bu:
case 0x2Cu:
case 0x30u:
case 0x33u:
case 0x34u:
case 0x35u:
return;
case 7u:
free_contact(a1 + 12);
break;
case 9u:
case 0xAu:
free_rr(a1 + 12);
break;
case 0xDu:
case 0xFu:
free_credentials(a1 + 12);
break;
case 0xEu:
free_expires(a1 + 12);
break;
case 0x10u:
case 0x22u:
func1((void (***)(void))a1 + 6);
break;
case 0x14u:
free_allow_header(a1, a2, a3, a4, v6);
break;
case 0x15u:
free_event(a1 + 12);
break;
case 0x16u:
qm_free(mem_block, v5, a3, a4, v6);
break;
case 0x1Du:
free_disposition(a1 + 12);
break;
case 0x21u:
free_sipifmatch(a1 + 12);
break;
case 0x24u:
free_subscription_state(a1 + 12);
break;
case 0x2Du:
free_date(v5, a2, a3, a4, v6);
break;
case 0x2Eu:
free_identity(v5, a2, a3, a4, v6);
break;
case 0x2Fu:
free_identityinfo(v5, a2, a3, a4, v6);
break;
case 0x31u:
case 0x32u:
free_pai_ppi_body(v5, a2, a3, a4, v6);
break;
default:
if ( (int)get_debug_level("core", 4LL) >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v7 = *a1;
v8 = (const char *)*((_QWORD *)&log_level_info + 6);
v9 = my_pid();
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG: clean_hdr_field: unknown header type %d\n",
process_no,
v9,
v8,
"<core> [parser/hf.c:207]: ",
"clean_hdr_field",
v7);
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): BUG: clean_hdr_field: unknown header type %d\n", v11);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG: clean_hdr_field: unknown header type %d\n",
*((const char **)&log_level_info + 6),
"<core> [parser/hf.c:207]: ",
"clean_hdr_field",
*a1);
}
--dprint_crit;
}
break;
}
}
}

original_code:
void clean_hdr_field(struct hdr_field* const hf)
{
 void** h_parsed;
 if (hf->parsed){
  h_parsed=&hf->parsed;
  switch(hf->type){
  case HDR_ACCEPT_T:
   qm_free(mem_block, (hf->parsed));
   break;
  case HDR_ALLOW_T:
   free_allow_header(hf);
   break;
  case HDR_AUTHORIZATION_T:
   free_credentials((auth_body_t**)h_parsed);
   break;
  case HDR_CONTACT_T:
   free_contact((contact_body_t**)h_parsed);
   break;
  case HDR_CONTENTDISPOSITION_T:
   free_disposition( ((struct disposition**)h_parsed));
   break;
  case HDR_CSEQ_T:
   free_cseq(hf->parsed);
   break;
  case HDR_DATE_T:
   free_date(hf->parsed);
   break;
  case HDR_DIVERSION_T:
   free_to(hf->parsed);
   break;
  case HDR_EVENT_T:
   free_event((event_t**)h_parsed);
   break;
  case HDR_EXPIRES_T:
   free_expires((exp_body_t**)h_parsed);
   break;
  case HDR_FROM_T:
   free_to(hf->parsed);
   break;
  case HDR_IDENTITY_INFO_T:
   free_identityinfo(hf->parsed);
   break;
  case HDR_IDENTITY_T:
   free_identity(hf->parsed);
   break;
  case HDR_PAI_T:
   free_pai_ppi_body(hf->parsed);
   break;
  case HDR_PPI_T:
   free_pai_ppi_body(hf->parsed);
   break;
  case HDR_PROXYAUTH_T:
   free_credentials((auth_body_t**)h_parsed);
   break;
  case HDR_RECORDROUTE_T:
   free_rr((rr_t**)h_parsed);
   break;
  case HDR_REFER_TO_T:
   free_to(hf->parsed);
   break;
  case HDR_ROUTE_T:
   free_rr((rr_t**)h_parsed);
   break;
  case HDR_RPID_T:
   free_to(hf->parsed);
   break;
  case HDR_SESSIONEXPIRES_T:
   hdr_free_parsed(h_parsed);
   break;
  case HDR_SIPIFMATCH_T:
   free_sipifmatch((str **)h_parsed);
   break;
  case HDR_SUBSCRIPTION_STATE_T:
   free_subscription_state((subscription_state_t**)h_parsed);
   break;
  case HDR_SUPPORTED_T:
   hdr_free_parsed(h_parsed);
   break;
  case HDR_TO_T:
   free_to(hf->parsed);
   break;
  case HDR_VIA_T:
   free_via_list(hf->parsed);
   break;
  case HDR_CALLID_T:
  case HDR_MAXFORWARDS_T:
  case HDR_CONTENTTYPE_T:
  case HDR_CONTENTLENGTH_T:
  case HDR_RETRY_AFTER_T:
  case HDR_REQUIRE_T:
  case HDR_PROXYREQUIRE_T:
  case HDR_UNSUPPORTED_T:
  case HDR_ACCEPTLANGUAGE_T:
  case HDR_ORGANIZATION_T:
  case HDR_PRIORITY_T:
  case HDR_SUBJECT_T:
  case HDR_USERAGENT_T:
  case HDR_SERVER_T:
  case HDR_MIN_SE_T:
  case HDR_ACCEPTCONTACT_T:
  case HDR_ALLOWEVENTS_T:
  case HDR_CONTENTENCODING_T:
  case HDR_REFERREDBY_T:
  case HDR_REJECTCONTACT_T:
  case HDR_REQUESTDISPOSITION_T:
  case HDR_WWW_AUTHENTICATE_T:
  case HDR_PROXY_AUTHENTICATE_T:
  case HDR_PATH_T:
  case HDR_PRIVACY_T:
  case HDR_REASON_T:
   break;
  default:
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", process_no, my_pid(), ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); } } (dprint_crit--); } } while(0);
   break;
  }
 }
}

canonical_original_code:
void clean_hdr_field(struct hdr_field *hf)
{
 void **h_parsed;
 if (hf->parsed){
  h_parsed=&hf->parsed;
  switch(hf->type){
  case HDR_ACCEPT_T:
   qm_free(mem_block, (hf->parsed));
   break;
  case HDR_ALLOW_T:
   free_allow_header(hf);
   break;
  case HDR_AUTHORIZATION_T:
   free_credentials((struct auth_body **)h_parsed);
   break;
  case HDR_CONTACT_T:
   free_contact((struct contact_body **)h_parsed);
   break;
  case HDR_CONTENTDISPOSITION_T:
   free_disposition( ((struct disposition **)h_parsed));
   break;
  case HDR_CSEQ_T:
   free_cseq(hf->parsed);
   break;
  case HDR_DATE_T:
   free_date(hf->parsed);
   break;
  case HDR_DIVERSION_T:
   free_to(hf->parsed);
   break;
  case HDR_EVENT_T:
   free_event((struct event **)h_parsed);
   break;
  case HDR_EXPIRES_T:
   free_expires((struct exp_body **)h_parsed);
   break;
  case HDR_FROM_T:
   free_to(hf->parsed);
   break;
  case HDR_IDENTITY_INFO_T:
   free_identityinfo(hf->parsed);
   break;
  case HDR_IDENTITY_T:
   free_identity(hf->parsed);
   break;
  case HDR_PAI_T:
   free_pai_ppi_body(hf->parsed);
   break;
  case HDR_PPI_T:
   free_pai_ppi_body(hf->parsed);
   break;
  case HDR_PROXYAUTH_T:
   free_credentials((struct auth_body **)h_parsed);
   break;
  case HDR_RECORDROUTE_T:
   free_rr((struct rr **)h_parsed);
   break;
  case HDR_REFER_TO_T:
   free_to(hf->parsed);
   break;
  case HDR_ROUTE_T:
   free_rr((struct rr **)h_parsed);
   break;
  case HDR_RPID_T:
   free_to(hf->parsed);
   break;
  case HDR_SESSIONEXPIRES_T:
   hdr_free_parsed(h_parsed);
   break;
  case HDR_SIPIFMATCH_T:
   free_sipifmatch((struct _str **)h_parsed);
   break;
  case HDR_SUBSCRIPTION_STATE_T:
   free_subscription_state((struct _subscription_state_t **)h_parsed);
   break;
  case HDR_SUPPORTED_T:
   hdr_free_parsed(h_parsed);
   break;
  case HDR_TO_T:
   free_to(hf->parsed);
   break;
  case HDR_VIA_T:
   free_via_list(hf->parsed);
   break;
  case HDR_CALLID_T:
  case HDR_MAXFORWARDS_T:
  case HDR_CONTENTTYPE_T:
  case HDR_CONTENTLENGTH_T:
  case HDR_RETRY_AFTER_T:
  case HDR_REQUIRE_T:
  case HDR_PROXYREQUIRE_T:
  case HDR_UNSUPPORTED_T:
  case HDR_ACCEPTLANGUAGE_T:
  case HDR_ORGANIZATION_T:
  case HDR_PRIORITY_T:
  case HDR_SUBJECT_T:
  case HDR_USERAGENT_T:
  case HDR_SERVER_T:
  case HDR_MIN_SE_T:
  case HDR_ACCEPTCONTACT_T:
  case HDR_ALLOWEVENTS_T:
  case HDR_CONTENTENCODING_T:
  case HDR_REFERREDBY_T:
  case HDR_REJECTCONTACT_T:
  case HDR_REQUESTDISPOSITION_T:
  case HDR_WWW_AUTHENTICATE_T:
  case HDR_PROXY_AUTHENTICATE_T:
  case HDR_PATH_T:
  case HDR_PRIVACY_T:
  case HDR_REASON_T:
   break;
  default:
   do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", process_no, my_pid(), ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG: clean_hdr_field: unknown header type %d\n", ("<core> [" "parser/hf.c" ":" "207" "]: ") , __func__, hf->type); } } (dprint_crit--); } } while(0);
   break;
  }
 }
}

user_defined_types: enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 }

user_defined_types: struct auth_body { struct hdr_field *authorized; struct dig_cred digest; unsigned char stale; }

user_defined_types: struct contact_body { unsigned char star; struct contact *contacts; }

user_defined_types: struct disposition { struct _str type; struct disposition_param *params; }

user_defined_types: struct event { enum event_type type; struct _str name; struct event_params params; }

user_defined_types: struct exp_body { struct _str text; unsigned char valid; unsigned int val; }

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

user_defined_types: struct _subscription_state_t { enum substate_value_t value; unsigned int expires; int expires_set; }

user_defined_types: struct dig_cred { struct username username; struct _str realm; struct _str nonce; struct _str uri; struct _str response; struct algorithm alg; struct _str cnonce; struct _str opaque; struct qp qop; struct _str nc; }

user_defined_types: enum event_type { EVENT_OTHER=0, EVENT_PRESENCE=1, EVENT_PRESENCE_WINFO=2, EVENT_SIP_PROFILE=3, EVENT_XCAP_CHANGE=4, EVENT_DIALOG=5, EVENT_MESSAGE_SUMMARY=6, EVENT_UA_PROFILE=7 }

user_defined_types: struct event_params { union param_hooks hooks; struct param *list; }

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

user_defined_types: enum substate_value_t { ss_active=0, ss_pending=1, ss_terminated=2, ss_extension=3 }

user_defined_types: struct username { struct _str whole; struct _str user; struct _str domain; }

user_defined_types: struct algorithm { struct _str alg_str; enum alg alg_parsed; }

user_defined_types: struct qp { struct _str qop_str; enum qop_type qop_parsed; }

user_defined_types: struct contact { struct _str name; struct _str uri; struct param *q; struct param *expires; struct param *methods; struct param *received; struct param *instance; struct param *reg_id; struct param *params; int len; struct contact *next; }

user_defined_types: struct disposition_param { struct _str name; struct _str body; int is_quoted; struct disposition_param *next; }

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

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

user_defined_types: enum alg { ALG_UNSPEC=0, ALG_MD5=1, ALG_MD5SESS=2, ALG_OTHER=4 }

user_defined_types: enum qop_type { QOP_UNSPEC=0, QOP_AUTH=1, QOP_AUTHINT=2, QOP_OTHER=4 }

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

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

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

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 free_hdr_field_lst(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rbx
unsigned int *v5; // rbp
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // r8
__int64 result; // rax

if ( a1 )
{
v4 = a1;
do
{
v5 = (unsigned int *)v4;
v4 = *(_QWORD *)(v4 + 56);
clean_hdr_field(v5, a2, a3, a4);
a2 = (__int64)v5;
result = qm_free(mem_block, v5, v6, v7, v8);
}
while ( v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rbx
unsigned int *v5; // rbp
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // r8
__int64 result; // rax

if ( a1 )
{
v4 = a1;
do
{
v5 = (unsigned int *)v4;
v4 = *(_QWORD *)(v4 + 56);
func2(v5, a2, a3, a4);
a2 = (__int64)v5;
result = qm_free(mem_block, v5, v6, v7, v8);
}
while ( v4 );
}
return result;
}

original_code:
void free_hdr_field_lst(struct hdr_field* hf)
{
 struct hdr_field* foo;
 while(hf) {
  foo=hf;
  hf=hf->next;
  clean_hdr_field(foo);
  qm_free(mem_block, (foo));
 }
}

canonical_original_code:
void free_hdr_field_lst(struct hdr_field *hf)
{
 struct hdr_field *foo;
 while(hf) {
  foo=hf;
  hf=hf->next;
  clean_hdr_field(foo);
  qm_free(mem_block, (foo));
 }
}

user_defined_types: struct hdr_field { enum _hdr_types_t type; struct _str name; struct _str body; int len; void *parsed; struct hdr_field *next; }

user_defined_types: enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 }


isendofhash

decompiled_code:
__int64 __fastcall isendofhash(char *a1, char *a2)
{
char v2; // al
unsigned int v3; // er8
__int64 result; // rax

v2 = *a1;
if ( (a1 >= a2 || (v3 = 1, v2 != 34)) && (v2 == 10 || (v3 = 0, v2 == 13)) )
result = a2 == a1 + 1;
else
result = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, char *a2)
{
char v2; // al
unsigned int v3; // er8
__int64 result; // rax

v2 = *a1;
if ( (a1 >= a2 || (v3 = 1, v2 != 34)) && (v2 == 10 || (v3 = 0, v2 == 13)) )
result = a2 == a1 + 1;
else
result = v3;
return result;
}

original_code:
inline static int isendofhash (char* p, char* end)
{
 if ((p<end && *p=='"')
  || ((*p=='\n' || *p=='\r') && p+1==end))
  return 1;
 else
  return 0;
}

canonical_original_code:
inline static int isendofhash(char *p, char *end)
{
 if ((p<end && *p=='"')
  || ((*p=='\n' || *p=='\r') && p+1==end))
  return 1;
 else
  return 0;
}

variable_types:
p
char *

variable_types:
end
char *

return_type: int


movetomybuffer

decompiled_code:
__int64 __fastcall movetomybuffer(void *src, char *a2, char *a3, __int64 a4)
{
__int64 v5; // rdx
void *v6; // rax
__int64 result; // rax
int v8; // er8
const char *v9; // rbx
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi
__int64 v12; // [rsp-10h] [rbp-28h]

while ( !(unsigned int)isendofhash(a3, a2) )
a3 = (char *)(v5 + 1);
v6 = (void *)qm_malloc(mem_block, v5 - (_QWORD)src);
*(_QWORD *)(a4 + 8) = v6;
if ( v6 )
{
*(_DWORD *)(a4 + 4) = 1;
memcpy(v6, src, *(int *)(a4 + 16));
result = 0LL;
}
else
{
v8 = get_debug_level("core", 4LL);
result = 4294967294LL;
if ( v8 >= -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(): parse_identity: out of memory\n",
process_no,
v10,
v9,
"<core> [parser/parse_identity.c:71]: ",
"movetomybuffer");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): parse_identity: out of memory\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_identity: out of memory\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_identity.c:71]: ",
"movetomybuffer");
}
result = 4294967294LL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *src, char *a2, char *a3, __int64 a4)
{
__int64 v5; // rdx
void *v6; // rax
__int64 result; // rax
int v8; // er8
const char *v9; // rbx
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi
__int64 v12; // [rsp-10h] [rbp-28h]

while ( !(unsigned int)func0(a3, a2) )
a3 = (char *)(v5 + 1);
v6 = (void *)qm_malloc(mem_block, v5 - (_QWORD)src);
*(_QWORD *)(a4 + 8) = v6;
if ( v6 )
{
*(_DWORD *)(a4 + 4) = 1;
memcpy(v6, src, *(int *)(a4 + 16));
result = 0LL;
}
else
{
v8 = get_debug_level("core", 4LL);
result = 4294967294LL;
if ( v8 >= -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(): parse_identity: out of memory\n",
process_no,
v10,
v9,
"<core> [parser/parse_identity.c:71]: ",
"movetomybuffer");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): parse_identity: out of memory\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_identity: out of memory\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_identity.c:71]: ",
"movetomybuffer");
}
result = 4294967294LL;
--dprint_crit;
}
}
return result;
}

original_code:
int movetomybuffer (char *pstart,
     char *pend,
     char *pcur,
     struct identity_body *ib)
{
 char *phashend;
 for (phashend = pcur; !isendofhash(phashend, pend); phashend++);
 if (!(ib->hash.s=qm_malloc(mem_block, (phashend-pstart)))) {
  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(): " "parse_identity: out of memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __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(): " "parse_identity: out of memory\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_identity: out of memory\n", process_no, my_pid(), ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __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(): " "parse_identity: out of memory\n", ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_identity: out of memory\n", ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 ib->ballocated=1;
 memcpy(ib->hash.s, pstart, ib->hash.len);
 return 0;
}

canonical_original_code:
int movetomybuffer(char *pstart, char *pend, char *pcur, struct identity_body *ib)
{
 char *phashend;
 for (phashend = pcur; !isendofhash(phashend, pend); phashend++);
 if (!(ib->hash.s=qm_malloc(mem_block, (phashend-pstart)))) {
  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(): " "parse_identity: out of memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __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(): " "parse_identity: out of memory\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_identity: out of memory\n", process_no, my_pid(), ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __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(): " "parse_identity: out of memory\n", ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_identity: out of memory\n", ("<core> [" "parser/parse_identity.c" ":" "71" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 ib->ballocated=1;
 memcpy(ib->hash.s, pstart, ib->hash.len);
 return 0;
}

variable_types:
pstart
char *

variable_types:
pend
char *

variable_types:
pcur
char *

variable_types: struct identity_body { int error; int ballocated; struct _str { char *s; int len; } hash; } *

variable_types:
phashend
char *

user_defined_types: struct identity_body { int error; int ballocated; struct _str hash; }

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


original_code:
void parse_identity(char *buffer, char* end, struct identity_body* ib)
{
 char *p=((void *)0), *pstart=((void *)0);
 if (!buffer || !end || !ib)
  goto error;
 ib->error=-1;
 *buffer == '"' ? (pstart = buffer + 1) : (pstart = buffer);
 ib->hash.s=pstart;
 ib->hash.len=0;
 for (p = pstart; p < end; p++) {
  if (((*p >= 'a' && *p <='z')
   || (*p >= 'A' && *p <='Z')
   || (*p >= '0' && *p <='9')
   || (*p == '+' || *p == '/' || *p == '='))) {
   if (ib->ballocated)
    ib->hash.s[ib->hash.len]=*p;
   ib->hash.len++;
   continue;
  }
  if (*p=='\n' && p+1<end && ((*(p+1))=='\t' || (*(p+1))==' ')) {
   if (!ib->ballocated && (movetomybuffer(pstart, end, p-1, ib)))
    goto error;
   for (p+=1; p + 1 < end && ((*(p + 1))=='\t' || (*(p + 1))==' '); p++);
   continue;
  }
  if (*p=='\r' && p+2<end && *(p+1)=='\n' && ((*(p+2))=='\t' || (*(p+2))==' ')) {
   if (!ib->ballocated && (movetomybuffer(pstart, end, p-1, ib)))
    goto error;
   for (p+=2; p + 1 < end && ((*(p + 1))=='\t' || (*(p + 1))==' '); p++);
   continue;
  }
  if (isendofhash(p, end))
   break;
  goto parseerror;
 }
 ib->error=1;
 return ;
parseerror:
 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(): " "ERROR: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); 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: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", process_no, my_pid(), ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); 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: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); } } (dprint_crit--); } } while(0);
error:
 return ;
}

canonical_original_code:
void parse_identity(char *buffer, char *end, struct identity_body *ib)
{
 char *p = ((void *)0); char *pstart = ((void *)0);
 if (!buffer || !end || !ib)
  goto error;
 ib->error=-1;
 *buffer == '"' ? (pstart = buffer + 1) : (pstart = buffer);
 ib->hash.s=pstart;
 ib->hash.len=0;
 for (p = pstart; p < end; p++) {
  if (((*p >= 'a' && *p <='z')
   || (*p >= 'A' && *p <='Z')
   || (*p >= '0' && *p <='9')
   || (*p == '+' || *p == '/' || *p == '='))) {
   if (ib->ballocated)
    ib->hash.s[ib->hash.len]=*p;
   ib->hash.len++;
   continue;
  }
  if (*p=='\n' && p+1<end && ((*(p+1))=='\t' || (*(p+1))==' ')) {
   if (!ib->ballocated && (movetomybuffer(pstart, end, p-1, ib)))
    goto error;
   for (p+=1; p + 1 < end && ((*(p + 1))=='\t' || (*(p + 1))==' '); p++);
   continue;
  }
  if (*p=='\r' && p+2<end && *(p+1)=='\n' && ((*(p+2))=='\t' || (*(p+2))==' ')) {
   if (!ib->ballocated && (movetomybuffer(pstart, end, p-1, ib)))
    goto error;
   for (p+=2; p + 1 < end && ((*(p + 1))=='\t' || (*(p + 1))==' '); p++);
   continue;
  }
  if (isendofhash(p, end))
   break;
  goto parseerror;
 }
 ib->error=1;
 return ;
parseerror:
 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(): " "ERROR: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); 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: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", process_no, my_pid(), ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); 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: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_identity: " "unexpected char [0x%X]: <<%.*s>> .\n", ("<core> [" "parser/parse_identity.c" ":" "138" "]: ") , __func__, *p,(int)(p-buffer), ((buffer)?(buffer):"")); } } (dprint_crit--); } } while(0);
error:
 return ;
}

variable_types:
buffer
char *


decompiled_code:
__int64 __fastcall free_identity(__int64 a1)
{
if ( *(_DWORD *)(a1 + 4) )
qm_free(mem_block, *(_QWORD *)(a1 + 8));
return qm_free(mem_block, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
if ( *(_DWORD *)(a1 + 4) )
qm_free(mem_block, *(_QWORD *)(a1 + 8));
return qm_free(mem_block, a1);
}

original_code:
void free_identity(struct identity_body *ib)
{
 if (ib->ballocated)
  qm_free(mem_block, (ib->hash.s));
 qm_free(mem_block, (ib));
}


decompiled_code:
__int64 __fastcall connect_http_db(_QWORD *a1, int a2)
{
__int64 v2; // rbx
__int64 v3; // rax
__int64 result; // rax
int v5; // er8
const char *v6; // r12
struct _IO_FILE *v7; // rdi
__int64 v8; // [rsp-10h] [rbp-28h]
unsigned int v9; // [rsp-8h] [rbp-20h]

v2 = *a1 + 208LL * a2;
if ( *(_QWORD *)(v2 + 32) )
{
v5 = get_debug_level("xhttp_pi", 8LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -3 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 4);
v9 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG - db connection found already open\n",
process_no,
v9,
v6,
"xhttp_pi [http_db_handler.c:37]: ",
"connect_http_db");
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): BUG - db connection found already open\n", v8);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG - db connection found already open\n",
*((const char **)&log_level_info + 4),
"xhttp_pi [http_db_handler.c:37]: ",
"connect_http_db");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
else
{
v3 = (*(__int64 (__fastcall **)(__int64))(v2 + 56))(v2 + 16);
*(_QWORD *)(v2 + 32) = v3;
result = (unsigned int)-(v3 == 0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, int a2)
{
__int64 v2; // rbx
__int64 v3; // rax
__int64 result; // rax
int v5; // er8
const char *v6; // r12
struct _IO_FILE *v7; // rdi
__int64 v8; // [rsp-10h] [rbp-28h]
unsigned int v9; // [rsp-8h] [rbp-20h]

v2 = *a1 + 208LL * a2;
if ( *(_QWORD *)(v2 + 32) )
{
v5 = get_debug_level("xhttp_pi", 8LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -3 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 4);
v9 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): BUG - db connection found already open\n",
process_no,
v9,
v6,
"xhttp_pi [http_db_handler.c:37]: ",
"connect_http_db");
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): BUG - db connection found already open\n", v8);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): BUG - db connection found already open\n",
*((const char **)&log_level_info + 4),
"xhttp_pi [http_db_handler.c:37]: ",
"connect_http_db");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
else
{
v3 = (*(__int64 (__fastcall **)(__int64))(v2 + 56))(v2 + 16);
*(_QWORD *)(v2 + 32) = v3;
result = (unsigned int)-(v3 == 0);
}
return result;
}

original_code:
int connect_http_db(ph_framework_t *framework_data, int index)
{
 ph_db_url_t *ph_db_urls = framework_data->ph_db_urls;
 if (ph_db_urls[index].http_db_handle) {
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "BUG - db connection found already open\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __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(): " "BUG - db connection found already open\n", (log_level_info[((-3)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "BUG - db connection found already open\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __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(): " "BUG - db connection found already open\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG - db connection found already open\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if ((ph_db_urls[index].http_db_handle =
  ph_db_urls[index].http_dbf.init(&ph_db_urls[index].db_url)) == ((void *)0)) {
  return -1;
 }
 return 0;
}

canonical_original_code:
int connect_http_db(struct ph_framework_ *framework_data, int index)
{
 struct ph_db_url_ *ph_db_urls = framework_data->ph_db_urls;
 if (ph_db_urls[index].http_db_handle) {
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "BUG - db connection found already open\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __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(): " "BUG - db connection found already open\n", (log_level_info[((-3)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "BUG - db connection found already open\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __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(): " "BUG - db connection found already open\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "BUG - db connection found already open\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "37" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if ((ph_db_urls[index].http_db_handle =
  ph_db_urls[index].http_dbf.init(&ph_db_urls[index].db_url)) == ((void *)0)) {
  return -1;
 }
 return 0;
}

variable_types: struct ph_framework_ { struct ph_db_url_ { struct _str { char *s; int len; } id; struct _str db_url; struct db1_con_t { struct _str *table; unsigned long tail; } *http_db_handle; struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t { DB_POOLING_PERMITTED=0, DB_POOLING_NONE=1 } _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t { enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; } *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res { struct { struct _str **names; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } *types; int n; } col; struct db_row { struct db_val_t *values; int n; } *rows; int n; int res_rows; int last_row; void *ptr; } **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t { DB_LOCKING_NONE=0, DB_LOCKING_WRITE=1, DB_LOCKING_FULL=2 } _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); } http_dbf; } *ph_db_urls; int ph_db_urls_size; struct ph_db_table_ { struct _str id; struct _str name; struct ph_db_url_ *db_url; struct ph_table_col_ { struct _str field; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } type; short validation; } *cols; int cols_size; } *ph_db_tables; int ph_db_tables_size; struct ph_mod_ { struct _str module; struct ph_cmd_ { struct _str name; unsigned int type; struct ph_db_table_ *db_table; char **c_ops; struct _str **c_keys; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } *c_types; struct ph_vals_ { struct _str *ids; struct _str *vals; int vals_size; } *c_vals; int c_keys_size; struct _str **q_keys; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } *q_types; struct ph_vals_ *q_vals; int q_keys_size; struct _str **o_keys; int o_keys_size; } *cmds; int cmds_size; } *ph_modules; int ph_modules_size; } *

variable_types: index int

user_defined_types: struct ph_framework_ { struct ph_db_url_ *ph_db_urls; int ph_db_urls_size; struct ph_db_table_ *ph_db_tables; int ph_db_tables_size; struct ph_mod_ *ph_modules; int ph_modules_size; }

user_defined_types: struct ph_db_url_ { struct _str id; struct _str db_url; struct db1_con_t *http_db_handle; struct db_func http_dbf; }

user_defined_types: struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); }

user_defined_types: struct ph_db_table_ { struct _str id; struct _str name; struct ph_db_url_ *db_url; struct ph_table_col_ *cols; int cols_size; }

user_defined_types: struct ph_mod_ { struct _str module; struct ph_cmd_ *cmds; int cmds_size; }

user_defined_types: struct ph_table_col_ { struct _str field; enum db_type_t type; short validation; }

user_defined_types: struct ph_cmd_ { struct _str name; unsigned int type; struct ph_db_table_ *db_table; char **c_ops; struct _str **c_keys; enum db_type_t *c_types; struct ph_vals_ *c_vals; int c_keys_size; struct _str **q_keys; enum db_type_t *q_types; struct ph_vals_ *q_vals; int q_keys_size; struct _str **o_keys; int o_keys_size; }

user_defined_types: struct db_val_t { enum db_type_t type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; }

user_defined_types: struct db1_res { struct { struct _str **names; enum db_type_t *types; int n; } col; struct db_row *rows; int n; int res_rows; int last_row; void *ptr; }


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

if ( a1 )
{
v1 = *(_QWORD *)(a1 + 32);
if ( v1 )
{
v3 = *(_QWORD *)(v1 + 32);
if ( v3 )
{
(*(void (__fastcall **)(__int64, __int64))(v1 + 48))(v3, a1 + 16);
return 0LL;
}
if ( (int)get_debug_level("xhttp_pi", 8LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null db handle for table [%s]\n",
*((const char **)&log_level_info + 8),
"xhttp_pi [http_db_handler.c:61]: ",
"use_table",
*(const char **)(a1 + 16));
LABEL_14:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = *(_QWORD *)(a1 + 16);
v9 = *((_QWORD *)&log_level_info + 8);
v10 = my_pid();
v21 = v8;
v11 = "xhttp_pi [http_db_handler.c:61]: ";
v12 = v10;
v13 = v9;
v14 = "%2d(%d) %s: %s%s(): null db handle for table [%s]\n";
v15 = process_no;
}
else
{
if ( (int)get_debug_level("xhttp_pi", 8LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null db_url for table [%s]\n",
*((const char **)&log_level_info + 8),
"xhttp_pi [http_db_handler.c:56]: ",
"use_table",
*(const char **)(a1 + 16));
goto LABEL_14;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v17 = *(_QWORD *)(a1 + 16);
v18 = *((_QWORD *)&log_level_info + 8);
v19 = my_pid();
v21 = v17;
v11 = "xhttp_pi [http_db_handler.c:56]: ";
v12 = v19;
v13 = v18;
v14 = "%2d(%d) %s: %s%s(): null db_url for table [%s]\n";
v15 = process_no;
}
v16 = stderr;
fprintf(stderr, v14, v15, v12, v13, v11, "use_table");
if ( log_color )
dprint_color_reset(v16, v14, v21);
goto LABEL_14;
}
if ( (int)get_debug_level("xhttp_pi", 8LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++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(): null db_table handler\n",
process_no,
v6,
v5,
"xhttp_pi [http_db_handler.c:52]: ",
"use_table");
if ( log_color )
dprint_color_reset(v20, "%2d(%d) %s: %s%s(): null db_table handler\n", v7);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null db_table handler\n",
*((const char **)&log_level_info + 8),
"xhttp_pi [http_db_handler.c:52]: ",
"use_table");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
return result;
}

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

if ( a1 )
{
v1 = *(_QWORD *)(a1 + 32);
if ( v1 )
{
v3 = *(_QWORD *)(v1 + 32);
if ( v3 )
{
(*(void (__fastcall **)(__int64, __int64))(v1 + 48))(v3, a1 + 16);
return 0LL;
}
if ( (int)get_debug_level("xhttp_pi", 8LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null db handle for table [%s]\n",
*((const char **)&log_level_info + 8),
"xhttp_pi [http_db_handler.c:61]: ",
"use_table",
*(const char **)(a1 + 16));
LABEL_14:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = *(_QWORD *)(a1 + 16);
v9 = *((_QWORD *)&log_level_info + 8);
v10 = my_pid();
v21 = v8;
v11 = "xhttp_pi [http_db_handler.c:61]: ";
v12 = v10;
v13 = v9;
v14 = "%2d(%d) %s: %s%s(): null db handle for table [%s]\n";
v15 = process_no;
}
else
{
if ( (int)get_debug_level("xhttp_pi", 8LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null db_url for table [%s]\n",
*((const char **)&log_level_info + 8),
"xhttp_pi [http_db_handler.c:56]: ",
"use_table",
*(const char **)(a1 + 16));
goto LABEL_14;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v17 = *(_QWORD *)(a1 + 16);
v18 = *((_QWORD *)&log_level_info + 8);
v19 = my_pid();
v21 = v17;
v11 = "xhttp_pi [http_db_handler.c:56]: ";
v12 = v19;
v13 = v18;
v14 = "%2d(%d) %s: %s%s(): null db_url for table [%s]\n";
v15 = process_no;
}
v16 = stderr;
fprintf(stderr, v14, v15, v12, v13, v11, "use_table");
if ( log_color )
dprint_color_reset(v16, v14, v21);
goto LABEL_14;
}
if ( (int)get_debug_level("xhttp_pi", 8LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++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(): null db_table handler\n",
process_no,
v6,
v5,
"xhttp_pi [http_db_handler.c:52]: ",
"use_table");
if ( log_color )
dprint_color_reset(v20, "%2d(%d) %s: %s%s(): null db_table handler\n", v7);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null db_table handler\n",
*((const char **)&log_level_info + 8),
"xhttp_pi [http_db_handler.c:52]: ",
"use_table");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
return result;
}

original_code:
int use_table(ph_db_table_t *db_table)
{
 ph_db_url_t *db_url;
 if(db_table==((void *)0)){
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "null db_table handler\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __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(): " "null db_table handler\n", (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null db_table handler\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __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(): " "null db_table handler\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db_table handler\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if(db_table->db_url==((void *)0)){
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "null db_url for table [%s]\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "null db_url for table [%s]\n", (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null db_url for table [%s]\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db_url for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db_url for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); } } (dprint_crit--); } } while(0);
  return -1;
 }
 db_url = db_table->db_url;
 if(db_url->http_db_handle==((void *)0)){
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "null db handle for table [%s]\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "null db handle for table [%s]\n", (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null db handle for table [%s]\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db handle for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db handle for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); } } (dprint_crit--); } } while(0);
  return -1;
 }
 db_table->db_url->http_dbf.use_table(db_table->db_url->http_db_handle,
      &db_table->name);
 return 0;
}

canonical_original_code:
int use_table(struct ph_db_table_ *db_table)
{
 struct ph_db_url_ *db_url;
 if(db_table==((void *)0)){
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "null db_table handler\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __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(): " "null db_table handler\n", (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null db_table handler\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __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(): " "null db_table handler\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db_table handler\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "52" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if(db_table->db_url==((void *)0)){
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "null db_url for table [%s]\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "null db_url for table [%s]\n", (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null db_url for table [%s]\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db_url for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db_url for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "56" "]: ") , __func__, db_table->name.s); } } (dprint_crit--); } } while(0);
  return -1;
 }
 db_url = db_table->db_url;
 if(db_url->http_db_handle==((void *)0)){
  do { if (get_debug_level("xhttp_pi", (sizeof("xhttp_pi")-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(): " "null db handle for table [%s]\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "null db handle for table [%s]\n", (log_level_info[((-1)) - (-5)].name), ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null db handle for table [%s]\n", process_no, my_pid(), ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db handle for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null db handle for table [%s]\n", ("xhttp_pi" " [" "http_db_handler.c" ":" "61" "]: ") , __func__, db_table->name.s); } } (dprint_crit--); } } while(0);
  return -1;
 }
 db_table->db_url->http_dbf.use_table(db_table->db_url->http_db_handle,
      &db_table->name);
 return 0;
}

variable_types: struct ph_db_table_ { struct _str { char *s; int len; } id; struct _str name; struct ph_db_url_ { struct _str id; struct _str db_url; struct db1_con_t { struct _str *table; unsigned long tail; } *http_db_handle; struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t { DB_POOLING_PERMITTED=0, DB_POOLING_NONE=1 } _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t { enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; } *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res { struct { struct _str **names; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } *types; int n; } col; struct db_row { struct db_val_t *values; int n; } *rows; int n; int res_rows; int last_row; void *ptr; } **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t { DB_LOCKING_NONE=0, DB_LOCKING_WRITE=1, DB_LOCKING_FULL=2 } _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); } http_dbf; } *db_url; struct ph_table_col_ { struct _str field; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } type; short validation; } *cols; int cols_size; } *

variable_types: struct ph_db_url_ { struct _str { char *s; int len; } id; struct _str db_url; struct db1_con_t { struct _str *table; unsigned long tail; } *http_db_handle; struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t { DB_POOLING_PERMITTED=0, DB_POOLING_NONE=1 } _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t { enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; } *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res { struct { struct _str **names; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } *types; int n; } col; struct db_row { struct db_val_t *values; int n; } *rows; int n; int res_rows; int last_row; void *ptr; } **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t { DB_LOCKING_NONE=0, DB_LOCKING_WRITE=1, DB_LOCKING_FULL=2 } _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); } http_dbf; } *