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


repo: virtualolson/who

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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *

variable_types: i int

return_type: void


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

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

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

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

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

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


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

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

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

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

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

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

variable_types:
size
unsigned int

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 init_pua_evlist()
{
__int64 v0; // rax
__int64 v1; // rbx
const char *v3; // rbp
unsigned int v4; // eax

v0 = shm_malloc(0x38u);
v1 = v0;
if ( v0 )
{
*(_QWORD *)(v0 + 48) = 0LL;
}
else if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more share memory\n",
process_no,
v4,
v3,
"pua [event_list.c:42]: ",
"init_pua_evlist");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more share memory\n",
*((const char **)&log_level_info + 8),
"pua [event_list.c:42]: ",
"init_pua_evlist");
}
--dprint_crit;
}
return v1;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rax
__int64 v1; // rbx
const char *v3; // rbp
unsigned int v4; // eax

v0 = func4(0x38u);
v1 = v0;
if ( v0 )
{
*(_QWORD *)(v0 + 48) = 0LL;
}
else if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more share memory\n",
process_no,
v4,
v3,
"pua [event_list.c:42]: ",
"init_pua_evlist");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more share memory\n",
*((const char **)&log_level_info + 8),
"pua [event_list.c:42]: ",
"init_pua_evlist");
}
--dprint_crit;
}
return v1;
}

original_code:
pua_event_t* init_pua_evlist(void)
{
 pua_event_t* list= ((void *)0);
 list= (pua_event_t*)shm_malloc(sizeof(pua_event_t));
 if(list== ((void *)0))
 {
  do { if (get_debug_level("pua", (sizeof("pua")-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 share memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.c" ":" "42" "]: ") , __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 share memory\n", (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.c" ":" "42" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more share memory\n", process_no, my_pid(), ("pua" " [" "event_list.c" ":" "42" "]: ") , __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 share memory\n", ("pua" " [" "event_list.c" ":" "42" "]: ") , __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 share memory\n", ("pua" " [" "event_list.c" ":" "42" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return ((void *)0);
 }
 list->next= ((void *)0);
 return list;
}

canonical_original_code:
struct pua_event *init_pua_evlist()
{
 struct pua_event *list = ((void *)0);
 list= (struct pua_event *)shm_malloc(sizeof(pua_event_t));
 if(list== ((void *)0))
 {
  do { if (get_debug_level("pua", (sizeof("pua")-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 share memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.c" ":" "42" "]: ") , __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 share memory\n", (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.c" ":" "42" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more share memory\n", process_no, my_pid(), ("pua" " [" "event_list.c" ":" "42" "]: ") , __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 share memory\n", ("pua" " [" "event_list.c" ":" "42" "]: ") , __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 share memory\n", ("pua" " [" "event_list.c" ":" "42" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return ((void *)0);
 }
 list->next= ((void *)0);
 return list;
}

variable_types: struct pua_event { int ev_flag; struct _str { char *s; int len; } name; struct _str content_type; int (*process_body)(struct publ_info { struct _str id; struct _str *pres_uri; struct _str *body; int expires; int flag; int source_flag; int event; struct _str content_type; struct _str *etag; struct _str *extra_headers; void *cb_param; } *, struct _str **final_body, int ver, struct _str **tuple); struct pua_event *next; } *

user_defined_types: struct pua_event { int ev_flag; struct _str name; struct _str content_type; int (*process_body)(struct publ_info *, struct _str **final_body, int ver, struct _str **tuple); struct pua_event *next; }

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


decompiled_code:
__int64 __fastcall contains_pua_event(__int64 a1)
{
__int64 v1; // rbx
int v2; // ebp

v1 = *(_QWORD *)(pua_evlist + 48LL);
if ( v1 )
{
v2 = *(_DWORD *)(a1 + 8);
do
{
if ( *(_DWORD *)(v1 + 16) == v2 && !strncmp(*(const char **)(v1 + 8), *(const char **)a1, v2) )
break;
v1 = *(_QWORD *)(v1 + 48);
}
while ( v1 );
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v1; // rbx
int v2; // ebp

v1 = *(_QWORD *)(pua_evlist + 48LL);
if ( v1 )
{
v2 = *(_DWORD *)(a1 + 8);
do
{
if ( *(_DWORD *)(v1 + 16) == v2 && !strncmp(*(const char **)(v1 + 8), *(const char **)a1, v2) )
break;
v1 = *(_QWORD *)(v1 + 48);
}
while ( v1 );
}
return v1;
}

original_code:
pua_event_t* contains_pua_event(str* name)
{
 pua_event_t* event;
 event= pua_evlist->next;
 while(event)
 {
  if(event->name.len== name->len &&
    strncmp(event->name.s, name->s, name->len)== 0)
  {
   return event;
  }
  event= event->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct pua_event *contains_pua_event(struct _str *name)
{
 struct pua_event *event;
 event= pua_evlist->next;
 while(event)
 {
  if(event->name.len== name->len &&
    strncmp(event->name.s, name->s, name->len)== 0)
  {
   return event;
  }
  event= event->next;
 }
 return ((void *)0);
}

variable_types:
name
struct _str *

return_type: struct pua_event { int ev_flag; struct _str { char *s; int len; } name; struct _str content_type; int (*process_body)(struct publ_info { struct _str id; struct _str *pres_uri; struct _str *body; int expires; int flag; int source_flag; int event; struct _str content_type; struct _str *etag; struct _str *extra_headers; void *cb_param; } *, struct _str **final_body, int ver, struct _str **tuple); struct pua_event *next; } *


decompiled_code:
__int64 __fastcall add_pua_event(int a1, const char *a2, const char *a3, __int64 a4)
{
int v5; // ebx
int v6; // er14
_QWORD *v7; // rax
_QWORD *v8; // rbp
char *v9; // rdi
__int64 v10; // rsi
unsigned int v11; // er13
const char *v13; // rbx
unsigned int v14; // eax
const char *v15; // r12
unsigned int v16; // eax
const char *v19; // [rsp+10h] [rbp-48h] BYREF
int v20; // [rsp+18h] [rbp-40h]

v5 = strlen(a2);
v19 = a2;
v20 = v5;
if ( contains_pua_event((__int64)&v19) )
{
v11 = 0;
if ( (int)get_debug_level(&LC0, 3LL) > 2 )
{
v11 = dprint_crit;
if ( dprint_crit )
{
v11 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v13 = (const char *)*((_QWORD *)&log_level_info + 16);
v14 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Event already exists\n",
process_no,
v14,
v13,
"pua [event_list.c:67]: ",
"add_pua_event");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Event already exists\n",
*((const char **)&log_level_info + 16),
"pua [event_list.c:67]: ",
"add_pua_event");
}
--dprint_crit;
}
}
}
else
{
v6 = 0;
if ( a3 )
v6 = strlen(a3);
v7 = (_QWORD *)shm_malloc(v6 + v5 + 56);
v8 = v7;
if ( v7 )
{
memset(v7, 0, v6 + v5 + 56);
v8[1] = v8 + 7;
memcpy(v8 + 7, a2, v5);
*((_DWORD *)v8 + 4) = v5;
if ( a3 )
{
v9 = (char *)v8 + v5 + 56;
v8[3] = v9;
memcpy(v9, a3, v6);
*((_DWORD *)v8 + 8) = v6;
}
v8[5] = a4;
*(_DWORD *)v8 = a1;
v10 = pua_evlist;
v8[6] = *(_QWORD *)(pua_evlist + 48LL);
*(_QWORD *)(v10 + 48) = v8;
v11 = 0;
}
else
{
v11 = -1;
if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v15 = (const char *)*((_QWORD *)&log_level_info + 8);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No more share memory\n",
process_no,
v16,
v15,
"pua [event_list.c:78]: ",
"add_pua_event");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No more share memory\n",
*((const char **)&log_level_info + 8),
"pua [event_list.c:78]: ",
"add_pua_event");
}
--dprint_crit;
v11 = -1;
}
}
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, const char *a2, const char *a3, __int64 a4)
{
int v5; // ebx
int v6; // er14
_QWORD *v7; // rax
_QWORD *v8; // rbp
char *v9; // rdi
__int64 v10; // rsi
unsigned int v11; // er13
const char *v13; // rbx
unsigned int v14; // eax
const char *v15; // r12
unsigned int v16; // eax
const char *v19; // [rsp+10h] [rbp-48h] BYREF
int v20; // [rsp+18h] [rbp-40h]

v5 = strlen(a2);
v19 = a2;
v20 = v5;
if ( func6((__int64)&v19) )
{
v11 = 0;
if ( (int)get_debug_level(&LC0, 3LL) > 2 )
{
v11 = dprint_crit;
if ( dprint_crit )
{
v11 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v13 = (const char *)*((_QWORD *)&log_level_info + 16);
v14 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Event already exists\n",
process_no,
v14,
v13,
"pua [event_list.c:67]: ",
"add_pua_event");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Event already exists\n",
*((const char **)&log_level_info + 16),
"pua [event_list.c:67]: ",
"add_pua_event");
}
--dprint_crit;
}
}
}
else
{
v6 = 0;
if ( a3 )
v6 = strlen(a3);
v7 = (_QWORD *)func4(v6 + v5 + 56);
v8 = v7;
if ( v7 )
{
memset(v7, 0, v6 + v5 + 56);
v8[1] = v8 + 7;
memcpy(v8 + 7, a2, v5);
*((_DWORD *)v8 + 4) = v5;
if ( a3 )
{
v9 = (char *)v8 + v5 + 56;
v8[3] = v9;
memcpy(v9, a3, v6);
*((_DWORD *)v8 + 8) = v6;
}
v8[5] = a4;
*(_DWORD *)v8 = a1;
v10 = pua_evlist;
v8[6] = *(_QWORD *)(pua_evlist + 48LL);
*(_QWORD *)(v10 + 48) = v8;
v11 = 0;
}
else
{
v11 = -1;
if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v15 = (const char *)*((_QWORD *)&log_level_info + 8);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No more share memory\n",
process_no,
v16,
v15,
"pua [event_list.c:78]: ",
"add_pua_event");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No more share memory\n",
*((const char **)&log_level_info + 8),
"pua [event_list.c:78]: ",
"add_pua_event");
}
--dprint_crit;
v11 = -1;
}
}
}
return v11;
}

original_code:
int add_pua_event(int ev_flag, char* name, char* content_type,
  evs_process_body_t* process_body)
{
 pua_event_t* event= ((void *)0);
 int size;
 int name_len;
 int ctype_len= 0;
 str str_name;
 name_len= strlen(name);
 str_name.s= name;
 str_name.len= name_len;
 if(contains_pua_event(&str_name))
 {
  do { if (get_debug_level("pua", (sizeof("pua")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Event already exists\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Event already exists\n", (log_level_info[((3)) - (-5)].name), ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Event already exists\n", process_no, my_pid(), ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Event already exists\n", ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Event already exists\n", ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 if(content_type)
  ctype_len= strlen(content_type);
 size= sizeof(pua_event_t)+ (name_len+ ctype_len)* sizeof(char);
 event= (pua_event_t*)shm_malloc(size);
 if(event== ((void *)0))
 {
  do { if (get_debug_level("pua", (sizeof("pua")-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 share memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.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 share memory\n", (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.c" ":" "78" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No more share memory\n", process_no, my_pid(), ("pua" " [" "event_list.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 share memory\n", ("pua" " [" "event_list.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 share memory\n", ("pua" " [" "event_list.c" ":" "78" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(event, 0, size);
 size= sizeof(pua_event_t);
 event->name.s= (char*)event+ size;
 memcpy(event->name.s, name, name_len);
 event->name.len= name_len;
 size+= name_len;
 if(content_type)
 {
  event->content_type.s= (char*)event+ size;
  memcpy(event->content_type.s, content_type, ctype_len);
  event->content_type.len= ctype_len;
  size+= ctype_len;
 }
 event->process_body= process_body;
 event->ev_flag= ev_flag;
 event->next= pua_evlist->next;
 pua_evlist->next= event;
 return 0;
}

canonical_original_code:
int add_pua_event(int ev_flag, char *name, char *content_type, int (*process_body)(struct publ_info *, struct _str **final_body, int ver, struct _str **tuple))
{
 struct pua_event *event = ((void *)0);
 int size;
 int name_len;
 int ctype_len = 0;
 struct _str str_name;
 name_len= strlen(name);
 str_name.s= name;
 str_name.len= name_len;
 if(contains_pua_event(&str_name))
 {
  do { if (get_debug_level("pua", (sizeof("pua")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Event already exists\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Event already exists\n", (log_level_info[((3)) - (-5)].name), ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Event already exists\n", process_no, my_pid(), ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Event already exists\n", ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Event already exists\n", ("pua" " [" "event_list.c" ":" "67" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 if(content_type)
  ctype_len= strlen(content_type);
 size= sizeof(pua_event_t)+ (name_len+ ctype_len)* sizeof(char);
 event= (struct pua_event *)shm_malloc(size);
 if(event== ((void *)0))
 {
  do { if (get_debug_level("pua", (sizeof("pua")-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 share memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.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 share memory\n", (log_level_info[((-1)) - (-5)].name), ("pua" " [" "event_list.c" ":" "78" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No more share memory\n", process_no, my_pid(), ("pua" " [" "event_list.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 share memory\n", ("pua" " [" "event_list.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 share memory\n", ("pua" " [" "event_list.c" ":" "78" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(event, 0, size);
 size= sizeof(pua_event_t);
 event->name.s= (char *)event+ size;
 memcpy(event->name.s, name, name_len);
 event->name.len= name_len;
 size+= name_len;
 if(content_type)
 {
  event->content_type.s= (char *)event+ size;
  memcpy(event->content_type.s, content_type, ctype_len);
  event->content_type.len= ctype_len;
  size+= ctype_len;
 }
 event->process_body= process_body;
 event->ev_flag= ev_flag;
 event->next= pua_evlist->next;
 pua_evlist->next= event;
 return 0;
}

variable_types:
name
char *

variable_types: int (*)(struct publ_info { struct _str { char *s; int len; } id; struct _str *pres_uri; struct _str *body; int expires; int flag; int source_flag; int event; struct _str content_type; struct _str *etag; struct _str *extra_headers; void *cb_param; } *, struct _str **final_body, int ver, struct _str **tuple)

variable_types: size int

return_type: int

user_defined_types: struct publ_info { struct _str id; struct _str *pres_uri; struct _str *body; int expires; int flag; int source_flag; int event; struct _str content_type; struct _str *etag; struct _str *extra_headers; void *cb_param; }


decompiled_code:
_QWORD *destroy_pua_evlist()
{
_QWORD *result; // rax
__int64 v1; // rbx
__int64 v2; // r12

result = &pua_evlist;
if ( pua_evlist )
{
v1 = *(_QWORD *)(pua_evlist + 48LL);
while ( v1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 48);
futex_get(mem_lock);
qm_free(shm_block, v2);
futex_release(mem_lock);
}
futex_get(mem_lock);
qm_free(shm_block, pua_evlist);
result = (_QWORD *)futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
_QWORD *func9()
{
_QWORD *result; // rax
__int64 v1; // rbx
__int64 v2; // r12

result = &pua_evlist;
if ( pua_evlist )
{
v1 = *(_QWORD *)(pua_evlist + 48LL);
while ( v1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 48);
func2(mem_lock);
qm_free(shm_block, v2);
func3(mem_lock);
}
func2(mem_lock);
qm_free(shm_block, pua_evlist);
result = (_QWORD *)func3(mem_lock);
}
return result;
}

original_code:
void destroy_pua_evlist(void)
{
 pua_event_t* e1, *e2;
 if(pua_evlist)
 {
  e1= pua_evlist->next;
  while(e1)
  {
   e2= e1->next;
   do { futex_get(mem_lock); qm_free(shm_block, (e1)); futex_release(mem_lock); }while(0);
   e1= e2;
  }
  do { futex_get(mem_lock); qm_free(shm_block, (pua_evlist)); futex_release(mem_lock); }while(0);
 }
}

canonical_original_code:
void destroy_pua_evlist()
{
 struct pua_event *e1; struct pua_event *e2;
 if(pua_evlist)
 {
  e1= pua_evlist->next;
  while(e1)
  {
   e2= e1->next;
   do { futex_get(mem_lock); qm_free(shm_block, (e1)); futex_release(mem_lock); }while(0);
   e1= e2;
  }
  do { futex_get(mem_lock); qm_free(shm_block, (pua_evlist)); futex_release(mem_lock); }while(0);
 }
}


decompiled_code:
char **__fastcall normalize_sip_uri(_QWORD *a1)
{
char *v1; // rbx
int v2; // esi
char **result; // rax
char *v4; // rdi
int v5; // er11
const char *v6; // rbx
unsigned int v7; // eax

normalized_uri_5 = (char *)&buf_4;
if ( (int)un_escape(a1, (__int64)&normalized_uri_5) < 0 )
{
v5 = get_debug_level(&LC0, 3LL);
result = (char **)&null_str_2;
if ( v5 >= -1 )
{
result = (char **)&null_str_2;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): un-escaping URI\n",
process_no,
v7,
v6,
"rls [utils.c:38]: ",
"normalize_sip_uri");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): un-escaping URI\n",
*((const char **)&log_level_info + 8),
"rls [utils.c:38]: ",
"normalize_sip_uri");
}
--dprint_crit;
result = (char **)&null_str_2;
}
}
}
else
{
normalized_uri_5[dword_E88] = 0;
v1 = normalized_uri_5;
v2 = strncasecmp(normalized_uri_5, "sip:", 4uLL);
result = &normalized_uri_5;
if ( v2 )
{
v4 = strchr(v1, 64);
result = &normalized_uri_5;
if ( v4 )
{
memmove(v1 + 4, v1, dword_E88 + 1);
*(_DWORD *)normalized_uri_5 = 980445555;
dword_E88 += 4;
result = &normalized_uri_5;
}
}
}
return result;
}

canonical_decompiled_code:
char **__fastcall func2(_QWORD *a1)
{
char *v1; // rbx
int v2; // esi
char **result; // rax
char *v4; // rdi
int v5; // er11
const char *v6; // rbx
unsigned int v7; // eax

normalized_uri_5 = (char *)&buf_4;
if ( (int)func1(a1, (__int64)&normalized_uri_5) < 0 )
{
v5 = get_debug_level(&LC0, 3LL);
result = (char **)&null_str_2;
if ( v5 >= -1 )
{
result = (char **)&null_str_2;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): un-escaping URI\n",
process_no,
v7,
v6,
"rls [utils.c:38]: ",
"normalize_sip_uri");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): un-escaping URI\n",
*((const char **)&log_level_info + 8),
"rls [utils.c:38]: ",
"normalize_sip_uri");
}
--dprint_crit;
result = (char **)&null_str_2;
}
}
}
else
{
normalized_uri_5[dword_E88] = 0;
v1 = normalized_uri_5;
v2 = strncasecmp(normalized_uri_5, "sip:", 4uLL);
result = &normalized_uri_5;
if ( v2 )
{
v4 = strchr(v1, 64);
result = &normalized_uri_5;
if ( v4 )
{
memmove(v1 + 4, v1, dword_E88 + 1);
*(_DWORD *)normalized_uri_5 = 980445555;
dword_E88 += 4;
result = &normalized_uri_5;
}
}
}
return result;
}

original_code:
str* normalize_sip_uri(const str *uri)
{
        static str normalized_uri;
        static str null_str = {((void *)0), 0};
        static char buf[1024];
        normalized_uri.s = buf;
        if (un_escape((str *)uri, &normalized_uri) < 0)
        {
                do { if (get_debug_level("rls", (sizeof("rls")-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(): " "un-escaping URI\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "utils.c" ":" "38" "]: ") , __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(): " "un-escaping URI\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "utils.c" ":" "38" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "un-escaping URI\n", process_no, my_pid(), ("rls" " [" "utils.c" ":" "38" "]: ") , __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(): " "un-escaping URI\n", ("rls" " [" "utils.c" ":" "38" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "un-escaping URI\n", ("rls" " [" "utils.c" ":" "38" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                return &null_str;
        }
        normalized_uri.s[normalized_uri.len] = '\0';
        if (strncasecmp(normalized_uri.s, "sip:", sizeof("sip:")-1) != 0 && strchr(normalized_uri.s, '@') != ((void *)0))
        {
                memmove(normalized_uri.s+sizeof("sip:")-1, normalized_uri.s, normalized_uri.len+1);
                memcpy(normalized_uri.s, "sip:", sizeof("sip:")-1);
                normalized_uri.len += sizeof("sip:")-1;
        }
        return &normalized_uri;
}

canonical_original_code:
struct _str *normalize_sip_uri(struct _str *uri)
{
        static struct _str normalized_uri;
        static struct _str null_str = {((void *)0), 0};
        static char buf[1024];
        normalized_uri.s = buf;
        if (un_escape((struct _str *)uri, &normalized_uri) < 0)
        {
                do { if (get_debug_level("rls", (sizeof("rls")-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(): " "un-escaping URI\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "utils.c" ":" "38" "]: ") , __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(): " "un-escaping URI\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "utils.c" ":" "38" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "un-escaping URI\n", process_no, my_pid(), ("rls" " [" "utils.c" ":" "38" "]: ") , __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(): " "un-escaping URI\n", ("rls" " [" "utils.c" ":" "38" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "un-escaping URI\n", ("rls" " [" "utils.c" ":" "38" "]: ") , __func__); } } (dprint_crit--); } } while(0);
                return &null_str;
        }
        normalized_uri.s[normalized_uri.len] = '\0';
        if (strncasecmp(normalized_uri.s, "sip:", sizeof("sip:")-1) != 0 && strchr(normalized_uri.s, '@') != ((void *)0))
        {
                memmove(normalized_uri.s+sizeof("sip:")-1, normalized_uri.s, normalized_uri.len+1);
                memcpy(normalized_uri.s, "sip:", sizeof("sip:")-1);
                normalized_uri.len += sizeof("sip:")-1;
        }
        return &normalized_uri;
}

variable_types:
uri
struct _str *

variable_types:
buf
char [1024]

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


decompiled_code:
__int64 __fastcall hex2int(char a1)
{
__int64 result; // rax
const char *v2; // rbp
unsigned int v3; // eax

if ( (unsigned __int8)(a1 - 48) <= 9u )
return (unsigned int)(a1 - 48);
if ( (unsigned __int8)(a1 - 97) <= 5u )
return (unsigned int)(a1 - 87);
if ( (unsigned __int8)(a1 - 65) <= 5u )
return (unsigned int)(a1 - 55);
if ( (int)get_debug_level(&LC0, 3LL) < -1 )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v2 = (const char *)*((_QWORD *)&log_level_info + 8);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
process_no,
v3,
v2,
"rls [../../ut.h:561]: ",
"hex2int",
(unsigned int)a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
*((const char **)&log_level_info + 8),
"rls [../../ut.h:561]: ",
"hex2int",
(unsigned int)a1);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
__int64 result; // rax
const char *v2; // rbp
unsigned int v3; // eax

if ( (unsigned __int8)(a1 - 48) <= 9u )
return (unsigned int)(a1 - 48);
if ( (unsigned __int8)(a1 - 97) <= 5u )
return (unsigned int)(a1 - 87);
if ( (unsigned __int8)(a1 - 65) <= 5u )
return (unsigned int)(a1 - 55);
if ( (int)get_debug_level(&LC0, 3LL) < -1 )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v2 = (const char *)*((_QWORD *)&log_level_info + 8);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
process_no,
v3,
v2,
"rls [../../ut.h:561]: ",
"hex2int",
(unsigned int)a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
*((const char **)&log_level_info + 8),
"rls [../../ut.h:561]: ",
"hex2int",
(unsigned int)a1);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
inline static int hex2int(char hex_digit)
{
 if (hex_digit>='0' && hex_digit<='9')
  return hex_digit-'0';
 if (hex_digit>='a' && hex_digit<='f')
  return hex_digit-'a'+10;
 if (hex_digit>='A' && hex_digit<='F')
  return hex_digit-'A'+10;
 do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: hex2int: '%c' is no hex char\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: hex2int: '%c' is no hex char\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: hex2int: '%c' is no hex char\n", process_no, my_pid(), ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: hex2int: '%c' is no hex char\n", ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: hex2int: '%c' is no hex char\n", ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); } } (dprint_crit--); } } while(0);
 return -1;
}


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

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

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

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

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

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


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

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


original_code:
static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
{
 int i;
 str tmp;
 tmp.s = _s;
 tmp.len = _l;
 trim(&tmp);
 if (tmp.len == 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(): " "expires_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "expires_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  _e->valid = 0;
  return -1;
 }
 _e->text.s = tmp.s;
 _e->text.len = tmp.len;
 if (tmp.len > 10) {
  _e->valid = 0;
  return 0;
 }
 for(i = 0; i < tmp.len; i++) {
  if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) {
   _e->val *= 10;
   _e->val += tmp.s[i] - '0';
  } else {
   switch(tmp.s[i]) {
   case ' ':
   case '\t':
   case '\r':
   case '\n':
    _e->text.len = i;
    _e->valid = 1;
    return 0;
   default:
    _e->valid = 0;
    return 0;
   }
  }
 }
 _e->valid = 1;
 return 0;
}

canonical_original_code:
static inline int expires_parser(char *_s, int _l, struct exp_body *_e)
{
 int i;
 struct _str tmp;
 tmp.s = _s;
 tmp.len = _l;
 trim(&tmp);
 if (tmp.len == 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(): " "expires_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "expires_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  _e->valid = 0;
  return -1;
 }
 _e->text.s = tmp.s;
 _e->text.len = tmp.len;
 if (tmp.len > 10) {
  _e->valid = 0;
  return 0;
 }
 for(i = 0; i < tmp.len; i++) {
  if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) {
   _e->val *= 10;
   _e->val += tmp.s[i] - '0';
  } else {
   switch(tmp.s[i]) {
   case ' ':
   case '\t':
   case '\r':
   case '\n':
    _e->text.len = i;
    _e->valid = 1;
    return 0;
   default:
    _e->valid = 0;
    return 0;
   }
  }
 }
 _e->valid = 1;
 return 0;
}

variable_types: struct exp_body { struct _str { char *s; int len; } text; unsigned char valid; unsigned int val; } *

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

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


decompiled_code:
__int64 __fastcall parse_expires(__int64 a1)
{
__int64 result; // rax
_QWORD *v2; // rax
_QWORD *v3; // rbp
int v4; // edi
const char *v5; // rbp
unsigned int v6; // eax
const char *v7; // rbx
unsigned int v8; // eax

result = 0LL;
if ( !*(_QWORD *)(a1 + 48) )
{
v2 = (_QWORD *)qm_malloc(mem_block, 24LL);
v3 = v2;
if ( v2 )
{
*v2 = 0LL;
v2[1] = 0LL;
v2[2] = 0LL;
if ( (int)expires_parser(*(unsigned __int8 **)(a1 + 24), *(_DWORD *)(a1 + 32), (__int64)v2) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): Error while parsing\n",
process_no,
v8,
v7,
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): Error while parsing\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
}
--dprint_crit;
}
qm_free(mem_block, v3);
result = 4294967294LL;
}
else
{
*(_QWORD *)(a1 + 48) = v3;
result = 0LL;
}
}
else
{
v4 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax
_QWORD *v2; // rax
_QWORD *v3; // rbp
int v4; // edi
const char *v5; // rbp
unsigned int v6; // eax
const char *v7; // rbx
unsigned int v8; // eax

result = 0LL;
if ( !*(_QWORD *)(a1 + 48) )
{
v2 = (_QWORD *)qm_malloc(mem_block, 24LL);
v3 = v2;
if ( v2 )
{
*v2 = 0LL;
v2[1] = 0LL;
v2[2] = 0LL;
if ( (int)func3(*(unsigned __int8 **)(a1 + 24), *(_DWORD *)(a1 + 32), (__int64)v2) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): Error while parsing\n",
process_no,
v8,
v7,
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): Error while parsing\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
}
--dprint_crit;
}
qm_free(mem_block, v3);
result = 4294967294LL;
}
else
{
*(_QWORD *)(a1 + 48) = v3;
result = 0LL;
}
}
else
{
v4 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int parse_expires(struct hdr_field* _h)
{
 exp_body_t* e;
 if (_h->parsed) {
  return 0;
 }
 e = (exp_body_t*)qm_malloc(mem_block, (sizeof(exp_body_t)));
 if (e == 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(): " "parse_expires(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "parse_expires(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): No memory left\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(e, 0, sizeof(exp_body_t));
 if (expires_parser(_h->body.s, _h->body.len, e) < 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(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "parse_expires(): Error while parsing\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  qm_free(mem_block, (e));
  return -2;
 }
 _h->parsed = (void*)e;
 return 0;
}

canonical_original_code:
int parse_expires(struct hdr_field *_h)
{
 struct exp_body *e;
 if (_h->parsed) {
  return 0;
 }
 e = (struct exp_body *)qm_malloc(mem_block, (sizeof(exp_body_t)));
 if (e == 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(): " "parse_expires(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "parse_expires(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): No memory left\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(e, 0, sizeof(exp_body_t));
 if (expires_parser(_h->body.s, _h->body.len, e) < 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(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "parse_expires(): Error while parsing\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  qm_free(mem_block, (e));
  return -2;
 }
 _h->parsed = (void *)e;
 return 0;
}

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

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


decompiled_code:
int __fastcall print_expires(__int64 a1)
{
const char *v1; // rdx

puts("===Expires===");
v1 = *(const char **)a1;
if ( !*(_QWORD *)a1 )
v1 = (const char *)&unk_907;
printf("text: '%.*s'\n", *(_DWORD *)(a1 + 8), v1);
printf("val : %d\n", *(unsigned int *)(a1 + 20));
return puts("===/Expires===");
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1)
{
const char *v1; // rdx

puts("===Expires===");
v1 = *(const char **)a1;
if ( !*(_QWORD *)a1 )
v1 = (const char *)&unk_907;
printf("text: '%.*s'\n", *(_DWORD *)(a1 + 8), v1);
printf("val : %d\n", *(unsigned int *)(a1 + 20));
return puts("===/Expires===");
}

original_code:
void print_expires(exp_body_t* _e)
{
 printf("===Expires===\n");
 printf("text: \'%.*s\'\n", _e->text.len, ((_e->text.s)?(_e->text.s):""));
 printf("val : %d\n", _e->val);
 printf("===/Expires===\n");
}

canonical_original_code:
void print_expires(struct exp_body *_e)
{
 printf("===Expires===\n");
 printf("text: \'%.*s\'\n", _e->text.len, ((_e->text.s)?(_e->text.s):""));
 printf("val : %d\n", _e->val);
 printf("===/Expires===\n");
}


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

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

original_code:
int events_child_init(int _rank)
{
 return 0;
}


decompiled_code:
__int64 events_mod_init()
{
const char *v1; // rbx
unsigned int v2; // eax
const char *v3; // rbx
unsigned int v4; // eax
const char *v5; // rbx
unsigned int v6; // eax

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module initialization\n",
process_no,
v2,
v1,
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module initialization\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
}
--dprint_crit;
}
xmlInitParser();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 16);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libraries\n",
process_no,
v4,
v3,
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libraries\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
}
--dprint_crit;
}
qsa_initialize();
if ( (unsigned int)events_uac_init() )
return 0xFFFFFFFFLL;
if ( !handle_presence_subscriptions && (int)get_debug_level("presence_b2b", 12LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v5 = (const char *)*((_QWORD *)&log_level_info + 10);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): NOT handling presence subscriptions\n",
process_no,
v6,
v5,
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): NOT handling presence subscriptions\n",
*((const char **)&log_level_info + 10),
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
}
--dprint_crit;
}
return (unsigned int)-((unsigned int)events_qsa_interface_init((unsigned int)handle_presence_subscriptions) != 0);
}

canonical_decompiled_code:
__int64 func2()
{
const char *v1; // rbx
unsigned int v2; // eax
const char *v3; // rbx
unsigned int v4; // eax
const char *v5; // rbx
unsigned int v6; // eax

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module initialization\n",
process_no,
v2,
v1,
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module initialization\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
}
--dprint_crit;
}
xmlInitParser();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 16);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libraries\n",
process_no,
v4,
v3,
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libraries\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
}
--dprint_crit;
}
qsa_initialize();
if ( (unsigned int)events_uac_init() )
return 0xFFFFFFFFLL;
if ( !handle_presence_subscriptions && (int)get_debug_level("presence_b2b", 12LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v5 = (const char *)*((_QWORD *)&log_level_info + 10);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): NOT handling presence subscriptions\n",
process_no,
v6,
v5,
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): NOT handling presence subscriptions\n",
*((const char **)&log_level_info + 10),
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
}
--dprint_crit;
}
return (unsigned int)-((unsigned int)events_qsa_interface_init((unsigned int)handle_presence_subscriptions) != 0);
}

original_code:
int events_mod_init(void)
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "presence_b2b module initialization\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module initialization\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module initialization\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 xmlInitParser();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... common libraries\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... common libraries\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libraries\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_initialize();
 if (events_uac_init() != 0) {
  return -1;
 }
 if (!handle_presence_subscriptions) {
  do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "NOT handling presence subscriptions\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "NOT handling presence subscriptions\n", (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "NOT handling presence subscriptions\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 if (events_qsa_interface_init(handle_presence_subscriptions) != 0) return -1;
 return 0;
}

canonical_original_code:
int events_mod_init()
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "presence_b2b module initialization\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module initialization\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module initialization\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 xmlInitParser();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " " ... common libraries\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... common libraries\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libraries\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_initialize();
 if (events_uac_init() != 0) {
  return -1;
 }
 if (!handle_presence_subscriptions) {
  do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "NOT handling presence subscriptions\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "NOT handling presence subscriptions\n", (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "NOT handling presence subscriptions\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 if (events_qsa_interface_init(handle_presence_subscriptions) != 0) return -1;
 return 0;
}