decompiled_code:
__int64 __fastcall futex_release(volatile __int32 *a1)
{
__int64 result; // rax

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

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

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

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

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


repo: virtualolson/who

decompiled_code:
__int64 __fastcall str2msg_handling(const char *a1, _DWORD *a2)
{
bool v2; // zf
__int64 result; // rax
const char *v4; // rbp
unsigned int v5; // eax

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = strcmp(a1, "allow") == 0;
result = !v2;
if ( v2 )
{
*a2 = 1;
}
else
{
v2 = strcmp(a1, "block") == 0;
result = !v2;
if ( v2 )
{
*a2 = 0;
}
else if ( (int)get_debug_level("core", 4LL, a2) < -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid im-handling value: '%s'\n",
process_no,
v5,
v4,
"<core> [parse_msg_rules.c:60]: ",
"str2msg_handling",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid im-handling value: '%s'\n",
*((const char **)&log_level_info + 8),
"<core> [parse_msg_rules.c:60]: ",
"str2msg_handling",
a1);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, _DWORD *a2)
{
bool v2; // zf
__int64 result; // rax
const char *v4; // rbp
unsigned int v5; // eax

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = strcmp(a1, "allow") == 0;
result = !v2;
if ( v2 )
{
*a2 = 1;
}
else
{
v2 = strcmp(a1, "block") == 0;
result = !v2;
if ( v2 )
{
*a2 = 0;
}
else if ( (int)get_debug_level("core", 4LL, a2) < -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid im-handling value: '%s'\n",
process_no,
v5,
v4,
"<core> [parse_msg_rules.c:60]: ",
"str2msg_handling",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid im-handling value: '%s'\n",
*((const char **)&log_level_info + 8),
"<core> [parse_msg_rules.c:60]: ",
"str2msg_handling",
a1);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
static int str2msg_handling(const char *s, msg_handling_t *dst)
{
 if (!s) return (-1);
 if (strcmp(s, "allow") == 0) {
  *dst = msg_handling_allow;
  return 0;
 }
 if (strcmp(s, "block") == 0) {
  *dst = msg_handling_block;
  return 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 im-handling value: \'%s\'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, 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(): " "invalid im-handling value: \'%s\'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid im-handling value: \'%s\'\n", process_no, my_pid(), ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, 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(): " "invalid im-handling value: \'%s\'\n", ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid im-handling value: \'%s\'\n", ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, s); } } (dprint_crit--); } } while(0);
 return (-1);
}

canonical_original_code:
static int str2msg_handling(char *s, enum msg_handling_t *dst)
{
 if (!s) return (-1);
 if (strcmp(s, "allow") == 0) {
  *dst = msg_handling_allow;
  return 0;
 }
 if (strcmp(s, "block") == 0) {
  *dst = msg_handling_block;
  return 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 im-handling value: \'%s\'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, 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(): " "invalid im-handling value: \'%s\'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid im-handling value: \'%s\'\n", process_no, my_pid(), ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, 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(): " "invalid im-handling value: \'%s\'\n", ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid im-handling value: \'%s\'\n", ("<core> [" "parse_msg_rules.c" ":" "60" "]: ") , __func__, s); } } (dprint_crit--); } } while(0);
 return (-1);
}

variable_types:
s
char *

variable_types: enum msg_handling_t { msg_handling_block=0, msg_handling_allow=1 } *

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


decompiled_code:
__int64 __fastcall parse_msg_rules(__int64 a1, __int64 a2, __int64 a3)
{
return parse_common_rules(a1, a2, a3, read_msg_actions, &free_msg_actions);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
return parse_common_rules(a1, a2, a3, read_msg_actions, &free_msg_actions);
}

original_code:
int parse_msg_rules(const char *data, int dsize, cp_ruleset_t **dst)
{
 return parse_common_rules(data, dsize, dst,
   read_msg_actions, free_msg_actions);
}

canonical_original_code:
int parse_msg_rules(char *data, int dsize, struct cp_ruleset_t **dst)
{
 return parse_common_rules(data, dsize, dst,
   read_msg_actions, free_msg_actions);
}

variable_types:
data
char *

variable_types: dsize int

variable_types: struct cp_ruleset_t { struct _cp_rule_t { struct _cp_rule_t *next; struct cp_conditions_t { struct cp_validity_t { long from; long to; } *validity; struct cp_identity_t { struct _cp_id_t { struct _cp_id_t *next; struct _str { char *s; int len; } entity; } *ids; struct _cp_domain_t { struct _cp_domain_t *next; struct _str domain; } *domains; struct _cp_except_t { struct _cp_except_t *next; struct _str entity; } *excepts; struct cp_any_identity_t { struct _cp_domain_t *domains; struct _cp_except_domain_t { struct _cp_except_domain_t *next; struct _str domain; } *except_domains; } *any_identity; } *identity; struct _cp_sphere_t { struct _cp_sphere_t *next; struct _str value; } *spheres; } *conditions; struct cp_actions_t { struct _cp_unknown_t { struct _cp_unknown_t *next; char data[1]; } *unknown; } *actions; struct cp_transformations_t { struct _cp_unknown_t *unknown; } *transformations; struct _str id; } *rules; } **

user_defined_types: struct cp_ruleset_t { struct _cp_rule_t *rules; }

user_defined_types: struct _cp_rule_t { struct _cp_rule_t *next; struct cp_conditions_t *conditions; struct cp_actions_t *actions; struct cp_transformations_t *transformations; struct _str id; }

user_defined_types: struct cp_conditions_t { struct cp_validity_t *validity; struct cp_identity_t *identity; struct _cp_sphere_t *spheres; }

user_defined_types: struct cp_actions_t { struct _cp_unknown_t *unknown; }

user_defined_types: struct cp_identity_t { struct _cp_id_t *ids; struct _cp_domain_t *domains; struct _cp_except_t *excepts; struct cp_any_identity_t *any_identity; }

user_defined_types: struct _cp_id_t { struct _cp_id_t *next; struct _str entity; }

user_defined_types: struct cp_any_identity_t { struct _cp_domain_t *domains; struct _cp_except_domain_t *except_domains; }


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

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

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

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

variable_types:
var
int *

variable_types: v int


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *

variable_types: i int

return_type: void


decompiled_code:
__int64 __fastcall register_xcapcb(int a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 result; // rax
int v4; // esi
const char *v5; // rbx
unsigned int v6; // eax

v2 = (_QWORD *)shm_malloc(0x18u);
if ( v2 )
{
*v2 = 0LL;
v2[1] = a2;
*(_DWORD *)v2 = a1;
v2[2] = xcapcb_list;
xcapcb_list = v2;
result = 0LL;
}
else
{
v4 = get_debug_level("xcap_client", 11LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No more %s memory\n",
process_no,
v6,
v5,
"xcap_client [xcap_callbacks.c:58]: ",
"register_xcapcb",
"share");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No more %s memory\n",
*((const char **)&log_level_info + 8),
"xcap_client [xcap_callbacks.c:58]: ",
"register_xcapcb",
"share");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 result; // rax
int v4; // esi
const char *v5; // rbx
unsigned int v6; // eax

v2 = (_QWORD *)func4(0x18u);
if ( v2 )
{
*v2 = 0LL;
v2[1] = a2;
*(_DWORD *)v2 = a1;
v2[2] = xcapcb_list;
xcapcb_list = v2;
result = 0LL;
}
else
{
v4 = get_debug_level("xcap_client", 11LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No more %s memory\n",
process_no,
v6,
v5,
"xcap_client [xcap_callbacks.c:58]: ",
"register_xcapcb",
"share");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No more %s memory\n",
*((const char **)&log_level_info + 8),
"xcap_client [xcap_callbacks.c:58]: ",
"register_xcapcb",
"share");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int register_xcapcb( int types, xcap_cb f)
{
 xcap_callback_t* xcb;
 xcb= (xcap_callback_t*)shm_malloc(sizeof(xcap_callback_t));
 if(xcb== ((void *)0))
 {
  do { if (get_debug_level("xcap_client", (sizeof("xcap_client")-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(): " "No more %s memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); 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(): " "No more %s memory\n", (log_level_info[((-1)) - (-5)].name), ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No more %s memory\n", process_no, my_pid(), ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); 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(): " "No more %s memory\n", ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No more %s memory\n", ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); } } (dprint_crit--); } } while(0); goto error;
 }
 memset(xcb, 0, sizeof(xcap_callback_t));
 xcb->callback= f;
 xcb->types= types;
 xcb->next= xcapcb_list;
 xcapcb_list= xcb;
 return 0;
error:
 return -1;
}

canonical_original_code:
int register_xcapcb(int types, int f(int doc_type, struct _str xid, char *doc))
{
 struct xcap_callback *xcb;
 xcb= (struct xcap_callback *)shm_malloc(sizeof(xcap_callback_t));
 if(xcb== ((void *)0))
 {
  do { if (get_debug_level("xcap_client", (sizeof("xcap_client")-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(): " "No more %s memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); 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(): " "No more %s memory\n", (log_level_info[((-1)) - (-5)].name), ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No more %s memory\n", process_no, my_pid(), ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); 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(): " "No more %s memory\n", ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No more %s memory\n", ("xcap_client" " [" "xcap_callbacks.c" ":" "58" "]: ") , __func__,"share"); } } (dprint_crit--); } } while(0); goto error;
 }
 memset(xcb, 0, sizeof(xcap_callback_t));
 xcb->callback= f;
 xcb->types= types;
 xcb->next= xcapcb_list;
 xcapcb_list= xcb;
 return 0;
error:
 return -1;
}

variable_types: types int

variable_types: int (int doc_type, struct _str { char *s; int len; } xid, char *doc)

variable_types: struct xcap_callback { int types; int (*callback)(int doc_type, struct _str { char *s; int len; } xid, char *doc); struct xcap_callback *next; } *

user_defined_types: struct xcap_callback { int types; int (*callback)(int doc_type, struct _str xid, char *doc); struct xcap_callback *next; }


decompiled_code:
_QWORD *destroy_xcapcb_list()
{
_QWORD *result; // rax
__int64 i; // rbx
__int64 v2; // r12

result = &xcapcb_list;
for ( i = xcapcb_list; i; result = (_QWORD *)futex_release(mem_lock) )
{
v2 = i;
i = *(_QWORD *)(i + 16);
futex_get(mem_lock);
qm_free(shm_block, v2);
}
return result;
}

canonical_decompiled_code:
_QWORD *func6()
{
_QWORD *result; // rax
__int64 i; // rbx
__int64 v2; // r12

result = &xcapcb_list;
for ( i = xcapcb_list; i; result = (_QWORD *)func3(mem_lock) )
{
v2 = i;
i = *(_QWORD *)(i + 16);
func2(mem_lock);
qm_free(shm_block, v2);
}
return result;
}

original_code:
void destroy_xcapcb_list(void)
{
 xcap_callback_t* xcb, *prev_xcb;
 xcb= xcapcb_list;
 while(xcb)
 {
  prev_xcb= xcb;
  xcb= xcb->next;
  do { futex_get(mem_lock); qm_free(shm_block, (prev_xcb)); futex_release(mem_lock); }while(0);
 }
}

canonical_original_code:
void destroy_xcapcb_list()
{
 struct xcap_callback *xcb; struct xcap_callback *prev_xcb;
 xcb= xcapcb_list;
 while(xcb)
 {
  prev_xcb= xcb;
  xcb= xcb->next;
  do { futex_get(mem_lock); qm_free(shm_block, (prev_xcb)); futex_release(mem_lock); }while(0);
 }
}


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

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

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

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

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

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

variable_types:
size
unsigned int

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 __fastcall get_user_script(const char **a1, __int64 a2, int a3)
{
__int64 v4; // r13
__int64 v5; // r12
const char *v6; // r14
const char *v7; // r13
unsigned int v8; // eax
__int64 result; // rax
const char *v10; // r14
unsigned int v11; // eax
const char *v12; // r14
int v13; // er13
const char *v14; // r12
unsigned int v15; // eax
const char *v16; // r14
int v17; // er13
const char *v18; // r12
unsigned int v19; // eax
unsigned int v20; // edi
void *v21; // rdi
__int64 v22; // r14
const char *v23; // rbp
unsigned int v24; // eax
const char *v25; // r13
unsigned int v26; // eax
__int64 v27[6]; // [rsp+8h] [rbp-30h] BYREF

v27[0] = 0LL;
*(_QWORD *)(*(_QWORD *)(get_script + 560) + 152LL) = *a1;
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = *a1;
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: fetching script for user <%s>\n",
process_no,
v8,
v7,
"cpl-c [cpl_db.c:122]: ",
"get_user_script",
v6);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: fetching script for user <%s>\n",
*((const char **)&log_level_info + 16),
"cpl-c [cpl_db.c:122]: ",
"get_user_script",
*a1);
}
--dprint_crit;
}
if ( (int)db_exec(v27, get_script) < 0 )
{
if ( (int)get_debug_level("cpl-c", 5LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:cpl-c:get_user_script: db_query failed\n",
process_no,
v11,
v10,
"cpl-c [cpl_db.c:124]: ",
"get_user_script");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:cpl-c:get_user_script: db_query failed\n",
*((const char **)&log_level_info + 8),
"cpl-c [cpl_db.c:124]: ",
"get_user_script");
}
--dprint_crit;
}
}
else
{
if ( !v27[0] || (v4 = db_first()) == 0 )
{
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v12 = *a1;
v13 = *((_DWORD *)a1 + 2);
v14 = (const char *)*((_QWORD *)&log_level_info + 16);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: user <%.*s> not found in db -> probably he has no script\n",
process_no,
v15,
v14,
"cpl-c [cpl_db.c:129]: ",
"get_user_script",
v13,
v12);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: user <%.*s> not found in db -> probably he has no script\n",
*((_QWORD *)&log_level_info + 16),
"cpl-c [cpl_db.c:129]: ",
"get_user_script",
*((unsigned int *)a1 + 2),
*a1);
}
--dprint_crit;
}
*(_QWORD *)a2 = 0LL;
*(_DWORD *)(a2 + 8) = 0;
goto LABEL_38;
}
v5 = 176LL * (a3 == 0);
if ( (*(_BYTE *)(*(_QWORD *)(v4 + 144) + v5 + 148) & 1) != 0 )
{
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v16 = *a1;
v17 = *((_DWORD *)a1 + 2);
v18 = (const char *)*((_QWORD *)&log_level_info + 16);
v19 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: user <%.*s> has a NULL script\n",
process_no,
v19,
v18,
"cpl-c [cpl_db.c:135]: ",
"get_user_script",
v17,
v16);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: user <%.*s> has a NULL script\n",
*((_QWORD *)&log_level_info + 16),
"cpl-c [cpl_db.c:135]: ",
"get_user_script",
*((unsigned int *)a1 + 2),
*a1);
}
--dprint_crit;
}
*(_QWORD *)a2 = 0LL;
*(_DWORD *)(a2 + 8) = 0;
goto LABEL_38;
}
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v22 = *(unsigned int *)(*(_QWORD *)(v4 + 144) + v5 + 160);
v23 = (const char *)*((_QWORD *)&log_level_info + 16);
v24 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: we got the script len=%d\n",
process_no,
v24,
v23,
"cpl-c [cpl_db.c:140]: ",
"get_user_script",
v22);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: we got the script len=%d\n",
*((const char **)&log_level_info + 16),
"cpl-c [cpl_db.c:140]: ",
"get_user_script",
*(unsigned int *)(*(_QWORD *)(v4 + 144) + v5 + 160));
}
--dprint_crit;
}
v20 = *(_DWORD *)(*(_QWORD *)(v4 + 144) + v5 + 160);
*(_DWORD *)(a2 + 8) = v20;
v21 = (void *)shm_malloc(v20);
*(_QWORD *)a2 = v21;
if ( v21 )
{
memcpy(v21, *(const void **)(*(_QWORD *)(v4 + 144) + v5 + 152), *(int *)(a2 + 8));
LABEL_38:
result = 1LL;
if ( v27[0] )
{
db_res_free();
result = 1LL;
}
return result;
}
if ( (int)get_debug_level("cpl-c", 5LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v25 = (const char *)*((_QWORD *)&log_level_info + 8);
v26 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:cpl-c:get_user_script: no free sh_mem\n",
process_no,
v26,
v25,
"cpl-c [cpl_db.c:145]: ",
"get_user_script");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:cpl-c:get_user_script: no free sh_mem\n",
*((const char **)&log_level_info + 8),
"cpl-c [cpl_db.c:145]: ",
"get_user_script");
}
--dprint_crit;
}
}
if ( v27[0] )
db_res_free();
*(_QWORD *)a2 = 0LL;
*(_DWORD *)(a2 + 8) = 0;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char **a1, __int64 a2, int a3)
{
__int64 v4; // r13
__int64 v5; // r12
const char *v6; // r14
const char *v7; // r13
unsigned int v8; // eax
__int64 result; // rax
const char *v10; // r14
unsigned int v11; // eax
const char *v12; // r14
int v13; // er13
const char *v14; // r12
unsigned int v15; // eax
const char *v16; // r14
int v17; // er13
const char *v18; // r12
unsigned int v19; // eax
unsigned int v20; // edi
void *v21; // rdi
__int64 v22; // r14
const char *v23; // rbp
unsigned int v24; // eax
const char *v25; // r13
unsigned int v26; // eax
__int64 v27[6]; // [rsp+8h] [rbp-30h] BYREF

v27[0] = 0LL;
*(_QWORD *)(*(_QWORD *)(get_script + 560) + 152LL) = *a1;
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = *a1;
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: fetching script for user <%s>\n",
process_no,
v8,
v7,
"cpl-c [cpl_db.c:122]: ",
"get_user_script",
v6);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: fetching script for user <%s>\n",
*((const char **)&log_level_info + 16),
"cpl-c [cpl_db.c:122]: ",
"get_user_script",
*a1);
}
--dprint_crit;
}
if ( (int)db_exec(v27, get_script) < 0 )
{
if ( (int)get_debug_level("cpl-c", 5LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:cpl-c:get_user_script: db_query failed\n",
process_no,
v11,
v10,
"cpl-c [cpl_db.c:124]: ",
"get_user_script");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:cpl-c:get_user_script: db_query failed\n",
*((const char **)&log_level_info + 8),
"cpl-c [cpl_db.c:124]: ",
"get_user_script");
}
--dprint_crit;
}
}
else
{
if ( !v27[0] || (v4 = db_first()) == 0 )
{
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v12 = *a1;
v13 = *((_DWORD *)a1 + 2);
v14 = (const char *)*((_QWORD *)&log_level_info + 16);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: user <%.*s> not found in db -> probably he has no script\n",
process_no,
v15,
v14,
"cpl-c [cpl_db.c:129]: ",
"get_user_script",
v13,
v12);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: user <%.*s> not found in db -> probably he has no script\n",
*((_QWORD *)&log_level_info + 16),
"cpl-c [cpl_db.c:129]: ",
"get_user_script",
*((unsigned int *)a1 + 2),
*a1);
}
--dprint_crit;
}
*(_QWORD *)a2 = 0LL;
*(_DWORD *)(a2 + 8) = 0;
goto LABEL_38;
}
v5 = 176LL * (a3 == 0);
if ( (*(_BYTE *)(*(_QWORD *)(v4 + 144) + v5 + 148) & 1) != 0 )
{
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v16 = *a1;
v17 = *((_DWORD *)a1 + 2);
v18 = (const char *)*((_QWORD *)&log_level_info + 16);
v19 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: user <%.*s> has a NULL script\n",
process_no,
v19,
v18,
"cpl-c [cpl_db.c:135]: ",
"get_user_script",
v17,
v16);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: user <%.*s> has a NULL script\n",
*((_QWORD *)&log_level_info + 16),
"cpl-c [cpl_db.c:135]: ",
"get_user_script",
*((unsigned int *)a1 + 2),
*a1);
}
--dprint_crit;
}
*(_QWORD *)a2 = 0LL;
*(_DWORD *)(a2 + 8) = 0;
goto LABEL_38;
}
if ( (int)get_debug_level("cpl-c", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v22 = *(unsigned int *)(*(_QWORD *)(v4 + 144) + v5 + 160);
v23 = (const char *)*((_QWORD *)&log_level_info + 16);
v24 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG:get_user_script: we got the script len=%d\n",
process_no,
v24,
v23,
"cpl-c [cpl_db.c:140]: ",
"get_user_script",
v22);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG:get_user_script: we got the script len=%d\n",
*((const char **)&log_level_info + 16),
"cpl-c [cpl_db.c:140]: ",
"get_user_script",
*(unsigned int *)(*(_QWORD *)(v4 + 144) + v5 + 160));
}
--dprint_crit;
}
v20 = *(_DWORD *)(*(_QWORD *)(v4 + 144) + v5 + 160);
*(_DWORD *)(a2 + 8) = v20;
v21 = (void *)func4(v20);
*(_QWORD *)a2 = v21;
if ( v21 )
{
memcpy(v21, *(const void **)(*(_QWORD *)(v4 + 144) + v5 + 152), *(int *)(a2 + 8));
LABEL_38:
result = 1LL;
if ( v27[0] )
{
db_res_free();
result = 1LL;
}
return result;
}
if ( (int)get_debug_level("cpl-c", 5LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v25 = (const char *)*((_QWORD *)&log_level_info + 8);
v26 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:cpl-c:get_user_script: no free sh_mem\n",
process_no,
v26,
v25,
"cpl-c [cpl_db.c:145]: ",
"get_user_script");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:cpl-c:get_user_script: no free sh_mem\n",
*((const char **)&log_level_info + 8),
"cpl-c [cpl_db.c:145]: ",
"get_user_script");
}
--dprint_crit;
}
}
if ( v27[0] )
db_res_free();
*(_QWORD *)a2 = 0LL;
*(_DWORD *)(a2 + 8) = 0;
return 0xFFFFFFFFLL;
}

original_code:
int get_user_script(str *username, str *domain, str *script, str* key)
{
 db_key_t keys_cmp[2];
 db_key_t keys_ret[1];
 db_val_t vals[2];
 db1_res_t *res = ((void *)0);
 int n;
 keys_cmp[0] = &cpl_username_col;
 keys_cmp[1] = &cpl_domain_col;
 keys_ret[0] = key;
 do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "fetching script for user <%.*s>\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "fetching script for user <%.*s>\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "fetching script for user <%.*s>\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "fetching script for user <%.*s>\n", ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "fetching script for user <%.*s>\n", ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); } } (dprint_crit--); } } while(0);
 vals[0].type = DB1_STR;
 vals[0].nul = 0;
 vals[0].val.str_val = *username;
 n = 1;
 if (domain) {
  vals[1].type = DB1_STR;
  vals[1].nul = 0;
  vals[1].val.str_val = *domain;
  n++;
 }
 if (cpl_dbf.query(db_hdl, keys_cmp, 0, vals, keys_ret, n, 1, ((void *)0), &res)
   < 0){
  do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "db_query failed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "db_query failed\n", (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_query failed\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_query failed\n", ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_query failed\n", ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 if (res->n==0) {
  do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "user <%.*s> not found in db -> probably " "he has no script\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); } } (dprint_crit--); } } while(0);
  script->s = 0;
  script->len = 0;
 } else {
  if (res->rows[0].values[0].nul) {
   do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "user <%.*s> has a NULL script\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "user <%.*s> has a NULL script\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "user <%.*s> has a NULL script\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> has a NULL script\n", ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> has a NULL script\n", ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); } } (dprint_crit--); } } while(0);
   script->s = 0;
   script->len = 0;
  } else {
   do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "we got the script len=%d\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); 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(): " "we got the script len=%d\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "we got the script len=%d\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); 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(): " "we got the script len=%d\n", ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "we got the script len=%d\n", ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); } } (dprint_crit--); } } while(0);
   script->len = res->rows[0].values[0].val.blob_val.len;
   script->s = shm_malloc( script->len );
   if (!script->s) {
    do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "no free sh_mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __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(): " "no free sh_mem\n", (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no free sh_mem\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __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(): " "no free sh_mem\n", ("cpl-c" " [" "cpl_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(): " "no free sh_mem\n", ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    goto error;
   }
   memcpy( script->s, res->rows[0].values[0].val.blob_val.s,
    script->len);
  }
 }
 cpl_dbf.free_result( db_hdl, res);
 return 1;
error:
 if (res)
  cpl_dbf.free_result( db_hdl, res);
 script->s = 0;
 script->len = 0;
 return -1;
}

canonical_original_code:
int get_user_script(struct _str *username, struct _str *domain, struct _str *script, struct _str *key)
{
 struct _str *keys_cmp[2];
 struct _str *keys_ret[1];
 struct db_val_t vals[2];
 struct db1_res *res = ((void *)0);
 int n;
 keys_cmp[0] = &cpl_username_col;
 keys_cmp[1] = &cpl_domain_col;
 keys_ret[0] = key;
 do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "fetching script for user <%.*s>\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "fetching script for user <%.*s>\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "fetching script for user <%.*s>\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "fetching script for user <%.*s>\n", ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "fetching script for user <%.*s>\n", ("cpl-c" " [" "cpl_db.c" ":" "125" "]: ") , __func__, username->len,username->s); } } (dprint_crit--); } } while(0);
 vals[0].type = DB1_STR;
 vals[0].nul = 0;
 vals[0].val.str_val = *username;
 n = 1;
 if (domain) {
  vals[1].type = DB1_STR;
  vals[1].nul = 0;
  vals[1].val.str_val = *domain;
  n++;
 }
 if (cpl_dbf.query(db_hdl, keys_cmp, 0, vals, keys_ret, n, 1, ((void *)0), &res)
   < 0){
  do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "db_query failed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "db_query failed\n", (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "db_query failed\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_query failed\n", ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "db_query failed\n", ("cpl-c" " [" "cpl_db.c" ":" "140" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 if (res->n==0) {
  do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "user <%.*s> not found in db -> probably " "he has no script\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> not found in db -> probably " "he has no script\n", ("cpl-c" " [" "cpl_db.c" ":" "145" "]: ") , __func__,username->len, username->s); } } (dprint_crit--); } } while(0);
  script->s = 0;
  script->len = 0;
 } else {
  if (res->rows[0].values[0].nul) {
   do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "user <%.*s> has a NULL script\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "user <%.*s> has a NULL script\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "user <%.*s> has a NULL script\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> has a NULL script\n", ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "user <%.*s> has a NULL script\n", ("cpl-c" " [" "cpl_db.c" ":" "151" "]: ") , __func__, username->len, username->s); } } (dprint_crit--); } } while(0);
   script->s = 0;
   script->len = 0;
  } else {
   do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "we got the script len=%d\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); 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(): " "we got the script len=%d\n", (log_level_info[((3)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "we got the script len=%d\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); 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(): " "we got the script len=%d\n", ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "we got the script len=%d\n", ("cpl-c" " [" "cpl_db.c" ":" "156" "]: ") , __func__, res->rows[0].values[0].val.blob_val.len); } } (dprint_crit--); } } while(0);
   script->len = res->rows[0].values[0].val.blob_val.len;
   script->s = shm_malloc( script->len );
   if (!script->s) {
    do { if (get_debug_level("cpl-c", (sizeof("cpl-c")-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(): " "no free sh_mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __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(): " "no free sh_mem\n", (log_level_info[((-1)) - (-5)].name), ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no free sh_mem\n", process_no, my_pid(), ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __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(): " "no free sh_mem\n", ("cpl-c" " [" "cpl_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(): " "no free sh_mem\n", ("cpl-c" " [" "cpl_db.c" ":" "161" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    goto error;
   }
   memcpy( script->s, res->rows[0].values[0].val.blob_val.s,
    script->len);
  }
 }
 cpl_dbf.free_result( db_hdl, res);
 return 1;
error:
 if (res)
  cpl_dbf.free_result( db_hdl, res);
 script->s = 0;
 script->len = 0;
 return -1;
}

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

variable_types:
domain
struct _str *

variable_types:
script
struct _str *

variable_types:
key
struct _str *

variable_types: 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 { char *s; int len; } str_val; struct _str blob_val; unsigned int bitmap_val; } val; } [2]

variable_types: struct db1_res { struct { struct _str { char *s; int len; } **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 { 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; } *values; int n; } *rows; int n; int res_rows; int last_row; void *ptr; } *

variable_types: n int

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

user_defined_types: struct db_row { struct db_val_t *values; int n; }


decompiled_code:
__int64 bdb_mod_destroy()
{
km_destroy();
return bdblib_destroy();
}

canonical_decompiled_code:
__int64 func0()
{
km_destroy();
return bdblib_destroy();
}

original_code:
static void bdb_mod_destroy(void)
{
 km_destroy();
 bdblib_destroy();
}

canonical_original_code:
static void bdb_mod_destroy()
{
 km_destroy();
 bdblib_destroy();
}


decompiled_code:
__int64 bdb_mod_init()
{
__int64 result; // rax
int v1[6]; // [rsp+0h] [rbp-18h] BYREF

v1[1] = auto_reload;
v1[2] = log_enable;
v1[0] = 0x400000;
v1[3] = journal_roll_interval;
if ( (unsigned int)bdblib_init(v1) )
result = 0xFFFFFFFFLL;
else
result = km_mod_init();
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
int v1[6]; // [rsp+0h] [rbp-18h] BYREF

v1[1] = auto_reload;
v1[2] = log_enable;
v1[0] = 0x400000;
v1[3] = journal_roll_interval;
if ( (unsigned int)bdblib_init(v1) )
result = 0xFFFFFFFFLL;
else
result = km_mod_init();
return result;
}

original_code:
static int bdb_mod_init(void)
{
 bdb_params_t p;
 p.auto_reload = auto_reload;
 p.log_enable = log_enable;
 p.cache_size = (4 * 1024 * 1024);
 p.journal_roll_interval = journal_roll_interval;
 if(bdblib_init(&p))
  return -1;
 return km_mod_init();
}

canonical_original_code:
static int bdb_mod_init()
{
 struct _bdb_params p;
 p.auto_reload = auto_reload;
 p.log_enable = log_enable;
 p.cache_size = (4 * 1024 * 1024);
 p.journal_roll_interval = journal_roll_interval;
 if(bdblib_init(&p))
  return -1;
 return km_mod_init();
}

variable_types: struct _bdb_params { unsigned int cache_size; int auto_reload; int log_enable; int journal_roll_interval; }


decompiled_code:
__int64 mod_register()
{
return (unsigned int)((int)db_api_init() >> 31);
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)((int)db_api_init() >> 31);
}

original_code:
int mod_register(char *path, int *dlflags, void *p1, void *p2)
{
 if(db_api_init()<0)
  return -1;
 return 0;
}

variable_types:
path
char *

variable_types:
dlflags
int *


decompiled_code:
__int64 __fastcall bdb_fld_free(__int64 a1, __int64 a2)
{
db_drv_free(a2);
if ( *(_QWORD *)(a2 + 32) )
qm_free(mem_block);
if ( *(_QWORD *)(a2 + 8) )
qm_free(mem_block);
return qm_free(mem_block);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
db_drv_free(a2);
if ( *(_QWORD *)(a2 + 32) )
qm_free(mem_block);
if ( *(_QWORD *)(a2 + 8) )
qm_free(mem_block);
return qm_free(mem_block);
}

original_code:
static void bdb_fld_free(db_fld_t* fld, bdb_fld_t* payload)
{
 db_drv_free(&payload->gen);
 if (payload->buf.s) qm_free(mem_block, (payload->buf.s));
 if (payload->name) qm_free(mem_block, (payload->name));
 qm_free(mem_block, (payload));
}

canonical_original_code:
static void bdb_fld_free(struct db_fld *fld, struct _bdb_fld *payload)
{
 db_drv_free(&payload->gen);
 if (payload->buf.s) qm_free(mem_block, (payload->buf.s));
 if (payload->name) qm_free(mem_block, (payload->name));
 qm_free(mem_block, (payload));
}

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

variable_types: struct _bdb_fld { struct db_drv gen; char *name; int is_null; unsigned long length; struct _str buf; int col_pos; } *

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


decompiled_code:
__int64 __fastcall bdb_fld(__int64 a1)
{
_QWORD *v1; // rax
_QWORD *v2; // rbx
__int64 result; // rax
int v4; // esi
const char *v5; // rbp
unsigned int v6; // eax

v1 = (_QWORD *)qm_malloc(mem_block, 56LL);
if ( v1 )
{
v2 = v1;
*v1 = 0LL;
v1[1] = 0LL;
v1[2] = 0LL;
v1[3] = 0LL;
v1[4] = 0LL;
v1[5] = 0LL;
v1[6] = 0LL;
*((_DWORD *)v1 + 12) = -1;
if ( (int)db_drv_init(v1, bdb_fld_free) < 0 )
{
qm_free(mem_block);
result = 0xFFFFFFFFLL;
}
else
{
*(_QWORD *)(a1 + 8LL * db_payload_idx + 8) = v2;
result = 0LL;
}
}
else
{
v4 = get_debug_level("db_berkeley", 11LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): oracle: No memory left\n",
process_no,
v6,
v5,
"db_berkeley [bdb_fld.c:64]: ",
"bdb_fld");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): oracle: No memory left\n",
*((const char **)&log_level_info + 8),
"db_berkeley [bdb_fld.c:64]: ",
"bdb_fld");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
_QWORD *v1; // rax
_QWORD *v2; // rbx
__int64 result; // rax
int v4; // esi
const char *v5; // rbp
unsigned int v6; // eax

v1 = (_QWORD *)qm_malloc(mem_block, 56LL);
if ( v1 )
{
v2 = v1;
*v1 = 0LL;
v1[1] = 0LL;
v1[2] = 0LL;
v1[3] = 0LL;
v1[4] = 0LL;
v1[5] = 0LL;
v1[6] = 0LL;
*((_DWORD *)v1 + 12) = -1;
if ( (int)db_drv_init(v1, bdb_fld_free) < 0 )
{
qm_free(mem_block);
result = 0xFFFFFFFFLL;
}
else
{
*(_QWORD *)(a1 + 8LL * db_payload_idx + 8) = v2;
result = 0LL;
}
}
else
{
v4 = get_debug_level("db_berkeley", 11LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): oracle: No memory left\n",
process_no,
v6,
v5,
"db_berkeley [bdb_fld.c:64]: ",
"bdb_fld");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): oracle: No memory left\n",
*((const char **)&log_level_info + 8),
"db_berkeley [bdb_fld.c:64]: ",
"bdb_fld");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int bdb_fld(db_fld_t* fld, char* table)
{
 bdb_fld_t *res;
 res = (bdb_fld_t*)qm_malloc(mem_block, (sizeof(bdb_fld_t)));
 if (res == ((void *)0)) {
  do { if (get_debug_level("db_berkeley", (sizeof("db_berkeley")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "oracle: No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __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(): " "oracle: No memory left\n", (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "oracle: No memory left\n", process_no, my_pid(), ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __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(): " "oracle: No memory left\n", ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "oracle: No memory left\n", ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(res, '\0', sizeof(bdb_fld_t));
 res->col_pos = -1;
 if (db_drv_init(&res->gen, bdb_fld_free) < 0) goto error;
 do { ((struct db_gen*)(fld))->data[db_payload_idx] = (struct db_drv*)(res); } while(0);
 return 0;
error:
 if (res) qm_free(mem_block, (res));
 return -1;
}

canonical_original_code:
int bdb_fld(struct db_fld *fld, char *table)
{
 struct _bdb_fld *res;
 res = (struct _bdb_fld *)qm_malloc(mem_block, (sizeof(bdb_fld_t)));
 if (res == ((void *)0)) {
  do { if (get_debug_level("db_berkeley", (sizeof("db_berkeley")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "oracle: No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __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(): " "oracle: No memory left\n", (log_level_info[((-1)) - (-5)].name), ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "oracle: No memory left\n", process_no, my_pid(), ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __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(): " "oracle: No memory left\n", ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "oracle: No memory left\n", ("db_berkeley" " [" "bdb_fld.c" ":" "64" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(res, '\0', sizeof(bdb_fld_t));
 res->col_pos = -1;
 if (db_drv_init(&res->gen, bdb_fld_free) < 0) goto error;
 do { ((struct db_gen *)(fld))->data[db_payload_idx] = (struct db_drv *)(res); } while(0);
 return 0;
error:
 if (res) qm_free(mem_block, (res));
 return -1;
}

variable_types:
table
char *

variable_types: struct _bdb_fld { struct db_drv { void (*free)(struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv *data[16]; } *db_struct, struct db_drv *payload); } gen; char *name; int is_null; unsigned long length; struct _str { char *s; int len; } buf; int col_pos; } *

user_defined_types: struct _bdb_fld { struct db_drv gen; char *name; int is_null; unsigned long length; struct _str buf; int col_pos; }

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

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

user_defined_types: enum db_fld_op { DB_EQ=0, DB_NE=1, DB_LT=2, DB_GT=3, DB_LEQ=4, DB_GEQ=5 }


decompiled_code:
_QWORD *ul_unlock_locks()
{
_QWORD *result; // rax
unsigned int v1; // ebx

result = &ul_locks;
if ( ul_locks && ul_locks_no )
{
v1 = 0;
do
result = (_QWORD *)futex_release((volatile __int32 *)(*(_QWORD *)(ul_locks + 8LL) + 4LL * v1++));
while ( ul_locks_no > v1 );
}
return result;
}

canonical_decompiled_code:
_QWORD *func6()
{
_QWORD *result; // rax
unsigned int v1; // ebx

result = &ul_locks;
if ( ul_locks && ul_locks_no )
{
v1 = 0;
do
result = (_QWORD *)func3((volatile __int32 *)(*(_QWORD *)(ul_locks + 8LL) + 4LL * v1++));
while ( ul_locks_no > v1 );
}
return result;
}

original_code:
void ul_unlock_locks(void)
{
 unsigned int i;
 if (ul_locks==0)
  return;
 for (i=0;i<ul_locks_no;i++) {
  futex_release(&ul_locks->locks[i]);
 };
}

canonical_original_code:
void ul_unlock_locks()
{
 unsigned int i;
 if (ul_locks==0)
  return;
 for (i=0;i<ul_locks_no;i++) {
  futex_release(&ul_locks->locks[i]);
 };
}

variable_types:
i
unsigned int


decompiled_code:
_QWORD *ul_destroy_locks()
{
_QWORD *result; // rax

result = &ul_locks;
if ( ul_locks )
{
futex_get(mem_lock);
qm_free(shm_block, ul_locks);
result = (_QWORD *)futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
_QWORD *func7()
{
_QWORD *result; // rax

result = &ul_locks;
if ( ul_locks )
{
func2(mem_lock);
qm_free(shm_block, ul_locks);
result = (_QWORD *)func3(mem_lock);
}
return result;
}

original_code:
void ul_destroy_locks(void)
{
 if (ul_locks !=0){
  ;
  do { futex_get(mem_lock); qm_free(shm_block, ((void*)ul_locks)); futex_release(mem_lock); }while(0);
 };
}

canonical_original_code:
void ul_destroy_locks()
{
 if (ul_locks !=0){
  ;
  do { futex_get(mem_lock); qm_free(shm_block, ((void *)ul_locks)); futex_release(mem_lock); }while(0);
 };
}


decompiled_code:
__int64 __fastcall reg_statistic(const char *a1)
{
char *v1; // rax
const char *v2; // rbx
int v3; // ebx
__int64 v4; // rax
__int64 result; // rax
int v6; // er8
const char *v7; // rbx
unsigned int v8; // eax
int v9; // edx
const char *v10; // rbp
unsigned int v11; // eax
int v12; // er11
const char *v13; // rbp
unsigned int v14; // eax

if ( a1 && *a1 )
{
v1 = strchr(a1, 47);
if ( !v1 )
{
v3 = 0;
LABEL_6:
v4 = qm_malloc(mem_block, 24LL);
if ( v4 )
{
*(_QWORD *)v4 = a1;
*(_DWORD *)(v4 + 8) = v3;
*(_QWORD *)(v4 + 16) = stat_list;
stat_list = v4;
result = 0LL;
}
else
{
v12 = get_debug_level("statistics", 10LL);
result = 0xFFFFFFFFLL;
if ( v12 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more pkg mem\n",
process_no,
v14,
v13,
"statistics [stats_funcs.c:78]: ",
"reg_statistic");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more pkg mem\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:78]: ",
"reg_statistic");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}
*v1 = 0;
v2 = v1 + 1;
if ( !strcasecmp(v1 + 1, "no_reset") )
{
v3 = 1;
goto LABEL_6;
}
v9 = get_debug_level("statistics", 10LL);
result = 0xFFFFFFFFLL;
if ( v9 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): unsuported flag <%s>\n",
process_no,
v11,
v10,
"statistics [stats_funcs.c:71]: ",
"reg_statistic",
v2);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): unsuported flag <%s>\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:71]: ",
"reg_statistic",
v2);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
else
{
v6 = get_debug_level("statistics", 10LL);
result = 0xFFFFFFFFLL;
if ( v6 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): empty parameter\n",
process_no,
v8,
v7,
"statistics [stats_funcs.c:59]: ",
"reg_statistic");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): empty parameter\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:59]: ",
"reg_statistic");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
char *v1; // rax
const char *v2; // rbx
int v3; // ebx
__int64 v4; // rax
__int64 result; // rax
int v6; // er8
const char *v7; // rbx
unsigned int v8; // eax
int v9; // edx
const char *v10; // rbp
unsigned int v11; // eax
int v12; // er11
const char *v13; // rbp
unsigned int v14; // eax

if ( a1 && *a1 )
{
v1 = strchr(a1, 47);
if ( !v1 )
{
v3 = 0;
LABEL_6:
v4 = qm_malloc(mem_block, 24LL);
if ( v4 )
{
*(_QWORD *)v4 = a1;
*(_DWORD *)(v4 + 8) = v3;
*(_QWORD *)(v4 + 16) = stat_list;
stat_list = v4;
result = 0LL;
}
else
{
v12 = get_debug_level("statistics", 10LL);
result = 0xFFFFFFFFLL;
if ( v12 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more pkg mem\n",
process_no,
v14,
v13,
"statistics [stats_funcs.c:78]: ",
"reg_statistic");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more pkg mem\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:78]: ",
"reg_statistic");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}
*v1 = 0;
v2 = v1 + 1;
if ( !strcasecmp(v1 + 1, "no_reset") )
{
v3 = 1;
goto LABEL_6;
}
v9 = get_debug_level("statistics", 10LL);
result = 0xFFFFFFFFLL;
if ( v9 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): unsuported flag <%s>\n",
process_no,
v11,
v10,
"statistics [stats_funcs.c:71]: ",
"reg_statistic",
v2);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): unsuported flag <%s>\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:71]: ",
"reg_statistic",
v2);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
else
{
v6 = get_debug_level("statistics", 10LL);
result = 0xFFFFFFFFLL;
if ( v6 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): empty parameter\n",
process_no,
v8,
v7,
"statistics [stats_funcs.c:59]: ",
"reg_statistic");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): empty parameter\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:59]: ",
"reg_statistic");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int reg_statistic( char* name)
{
 stat_elem *se;
 char *flag_str;
 int flags;
 if (name==0 || *name==0) {
  do { if (get_debug_level("statistics", (sizeof("statistics")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "empty parameter\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "empty parameter\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "empty parameter\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty parameter\n", ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty parameter\n", ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 flags = 0;
 flag_str = strchr( name, '/');
 if (flag_str) {
  *flag_str = 0;
  flag_str++;
  if (strcasecmp( flag_str, "no_reset")==0) {
   flags |= 1;
  } else {
   do { if (get_debug_level("statistics", (sizeof("statistics")-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(): " "unsuported flag <%s>\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); 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(): " "unsuported flag <%s>\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "unsuported flag <%s>\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); 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(): " "unsuported flag <%s>\n", ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "unsuported flag <%s>\n", ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); } } (dprint_crit--); } } while(0);
   goto error;
  }
 }
 se = (stat_elem*)qm_malloc(mem_block, (sizeof(stat_elem)));
 if (se==0) {
  do { if (get_debug_level("statistics", (sizeof("statistics")-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(): " "no more pkg mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __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(): " "no more pkg mem\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more pkg mem\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __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(): " "no more pkg mem\n", ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more pkg mem\n", ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 se->name = name;
 se->flags = flags;
 se->next = stat_list;
 stat_list = se;
 return 0;
error:
 return -1;
}

canonical_original_code:
int reg_statistic(char *name)
{
 struct stat_mod_elem_ *se;
 char *flag_str;
 int flags;
 if (name==0 || *name==0) {
  do { if (get_debug_level("statistics", (sizeof("statistics")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "empty parameter\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "empty parameter\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "empty parameter\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty parameter\n", ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty parameter\n", ("statistics" " [" "stats_funcs.c" ":" "59" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 flags = 0;
 flag_str = strchr( name, '/');
 if (flag_str) {
  *flag_str = 0;
  flag_str++;
  if (strcasecmp( flag_str, "no_reset")==0) {
   flags |= 1;
  } else {
   do { if (get_debug_level("statistics", (sizeof("statistics")-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(): " "unsuported flag <%s>\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); 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(): " "unsuported flag <%s>\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "unsuported flag <%s>\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); 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(): " "unsuported flag <%s>\n", ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "unsuported flag <%s>\n", ("statistics" " [" "stats_funcs.c" ":" "71" "]: ") , __func__,flag_str); } } (dprint_crit--); } } while(0);
   goto error;
  }
 }
 se = (struct stat_mod_elem_ *)qm_malloc(mem_block, (sizeof(stat_elem)));
 if (se==0) {
  do { if (get_debug_level("statistics", (sizeof("statistics")-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(): " "no more pkg mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __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(): " "no more pkg mem\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more pkg mem\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __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(): " "no more pkg mem\n", ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more pkg mem\n", ("statistics" " [" "stats_funcs.c" ":" "78" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  goto error;
 }
 se->name = name;
 se->flags = flags;
 se->next = stat_list;
 stat_list = se;
 return 0;
error:
 return -1;
}

variable_types:
name
char *

variable_types: struct stat_mod_elem_ { char *name; int flags; struct stat_mod_elem_ *next; } *

variable_types: flags int

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


decompiled_code:
__int64 register_all_mod_stats()
{
__int64 v0; // rbp
const char **v1; // r12
unsigned int v2; // ebx
__int64 v4; // r13
const char *v5; // r12
const char *v6; // rbx
unsigned int v7; // eax
__int64 v8[6]; // [rsp+8h] [rbp-30h] BYREF

v0 = stat_list;
v8[0] = 0LL;
if ( !stat_list )
return 0;
while ( 1 )
{
v1 = (const char **)v0;
v0 = *(_QWORD *)(v0 + 16);
v2 = register_stat("script", *v1, v8, *((unsigned int *)v1 + 2));
if ( v2 )
break;
qm_free(mem_block, v1);
if ( !v0 )
return v2;
}
v2 = -1;
if ( (int)get_debug_level("statistics", 10LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = *((unsigned int *)v1 + 2);
v5 = *v1;
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to register var. <%s> flags %d\n",
process_no,
v7,
v6,
"statistics [stats_funcs.c:108]: ",
"register_all_mod_stats",
v5,
v4);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to register var. <%s> flags %d\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:108]: ",
"register_all_mod_stats",
*v1,
*((unsigned int *)v1 + 2));
}
--dprint_crit;
v2 = -1;
}
return v2;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbp
const char **v1; // r12
unsigned int v2; // ebx
__int64 v4; // r13
const char *v5; // r12
const char *v6; // rbx
unsigned int v7; // eax
__int64 v8[6]; // [rsp+8h] [rbp-30h] BYREF

v0 = stat_list;
v8[0] = 0LL;
if ( !stat_list )
return 0;
while ( 1 )
{
v1 = (const char **)v0;
v0 = *(_QWORD *)(v0 + 16);
v2 = register_stat("script", *v1, v8, *((unsigned int *)v1 + 2));
if ( v2 )
break;
qm_free(mem_block, v1);
if ( !v0 )
return v2;
}
v2 = -1;
if ( (int)get_debug_level("statistics", 10LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = *((unsigned int *)v1 + 2);
v5 = *v1;
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to register var. <%s> flags %d\n",
process_no,
v7,
v6,
"statistics [stats_funcs.c:108]: ",
"register_all_mod_stats",
v5,
v4);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to register var. <%s> flags %d\n",
*((const char **)&log_level_info + 8),
"statistics [stats_funcs.c:108]: ",
"register_all_mod_stats",
*v1,
*((unsigned int *)v1 + 2));
}
--dprint_crit;
v2 = -1;
}
return v2;
}

original_code:
int register_all_mod_stats(void)
{
 stat_var *stat;
 stat_elem *se;
 stat_elem *se_tmp;
 se = stat_list;
 stat = ((void *)0);
 while( se ) {
  se_tmp = se;
  se = se->next;
  if (register_stat("script", se_tmp->name, &stat, se_tmp->flags)!=0){
   do { if (get_debug_level("statistics", (sizeof("statistics")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "failed to register var. <%s> flags %d\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "failed to register var. <%s> flags %d\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to register var. <%s> flags %d\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to register var. <%s> flags %d\n", ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to register var. <%s> flags %d\n", ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); } } (dprint_crit--); } } while(0);
   return -1;
  }
  qm_free(mem_block, (se_tmp));
 }
 return 0;
}

canonical_original_code:
int register_all_mod_stats()
{
 void *stat;
 struct stat_mod_elem_ *se;
 struct stat_mod_elem_ *se_tmp;
 se = stat_list;
 stat = ((void *)0);
 while( se ) {
  se_tmp = se;
  se = se->next;
  if (register_stat("script", se_tmp->name, &stat, se_tmp->flags)!=0){
   do { if (get_debug_level("statistics", (sizeof("statistics")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "failed to register var. <%s> flags %d\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "failed to register var. <%s> flags %d\n", (log_level_info[((-1)) - (-5)].name), ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to register var. <%s> flags %d\n", process_no, my_pid(), ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to register var. <%s> flags %d\n", ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to register var. <%s> flags %d\n", ("statistics" " [" "stats_funcs.c" ":" "108" "]: ") , __func__, se_tmp->name,se_tmp->flags); } } (dprint_crit--); } } while(0);
   return -1;
  }
  qm_free(mem_block, (se_tmp));
 }
 return 0;
}

variable_types:
stat
void *

user_defined_types: struct stat_mod_elem_ { char *name; int flags; struct stat_mod_elem_ *next; }