decompiled_code:
_QWORD **destroy_ulcb_list()
{
_QWORD **result; // rax
__int64 v1; // rbx
__int64 v2; // rbp

result = &ulcb_list;
if ( ulcb_list )
{
v1 = *ulcb_list;
while ( v1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 24);
if ( *(_QWORD *)(v2 + 16) )
{
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(v2 + 16));
futex_release(mem_lock);
}
futex_get(mem_lock);
qm_free(shm_block, v2);
futex_release(mem_lock);
}
futex_get(mem_lock);
qm_free(shm_block, ulcb_list);
result = (_QWORD **)futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
_QWORD **func6()
{
_QWORD **result; // rax
__int64 v1; // rbx
__int64 v2; // rbp

result = &ulcb_list;
if ( ulcb_list )
{
v1 = *ulcb_list;
while ( v1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 24);
if ( *(_QWORD *)(v2 + 16) )
{
func2(mem_lock);
qm_free(shm_block, *(_QWORD *)(v2 + 16));
func3(mem_lock);
}
func2(mem_lock);
qm_free(shm_block, v2);
func3(mem_lock);
}
func2(mem_lock);
qm_free(shm_block, ulcb_list);
result = (_QWORD **)func3(mem_lock);
}
return result;
}

original_code:
void destroy_ulcb_list(void)
{
 struct ul_callback *cbp, *cbp_tmp;
 if (!ulcb_list)
  return;
 for( cbp=ulcb_list->first; cbp ; ) {
  cbp_tmp = cbp;
  cbp = cbp->next;
  if (cbp_tmp->param) do { futex_get(mem_lock); qm_free(shm_block, (cbp_tmp->param)); futex_release(mem_lock); }while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (cbp_tmp)); futex_release(mem_lock); }while(0);
 }
 do { futex_get(mem_lock); qm_free(shm_block, (ulcb_list)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
void destroy_ulcb_list()
{
 struct ul_callback *cbp; struct ul_callback *cbp_tmp;
 if (!ulcb_list)
  return;
 for( cbp=ulcb_list->first; cbp ; ) {
  cbp_tmp = cbp;
  cbp = cbp->next;
  if (cbp_tmp->param) do { futex_get(mem_lock); qm_free(shm_block, (cbp_tmp->param)); futex_release(mem_lock); }while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (cbp_tmp)); futex_release(mem_lock); }while(0);
 }
 do { futex_get(mem_lock); qm_free(shm_block, (ulcb_list)); futex_release(mem_lock); }while(0);
}

variable_types: struct ul_callback { int id; int types; void (*callback)(struct ucontact { struct _str { char *s; int len; } *domain; struct _str ruid; struct _str *aor; struct _str c; struct _str received; struct _str path; long expires; int q; struct _str callid; int cseq; enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 } state; unsigned int flags; unsigned int cflags; struct _str user_agent; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *sock; long last_modified; long last_keepalive; unsigned int methods; struct _str instance; unsigned int reg_id; int tcpconn_id; struct _sr_xavp { unsigned int id; struct _str name; struct _sr_xval { enum sr_xtype_t { SR_XTYPE_NULL=0, SR_XTYPE_INT=1, SR_XTYPE_STR=2, SR_XTYPE_TIME=3, SR_XTYPE_LONG=4, SR_XTYPE_LLONG=5, SR_XTYPE_XAVP=6, SR_XTYPE_DATA=7 } type; union { int i; struct _str s; long t; long l; long long ll; struct _sr_xavp *xavp; struct _sr_data { void *p; void (*pfree)(void *d, void (*sfree)(void *d)); } *data; } v; } val; struct _sr_xavp *next; } *xavp; struct ucontact *next; struct ucontact *prev; } *c, int type, void *param); void *param; struct ul_callback *next; } *

user_defined_types: struct ul_callback { int id; int types; void (*callback)(struct ucontact *c, int type, void *param); void *param; struct ul_callback *next; }


repo: virtualolson/who

decompiled_code:
__int64 __fastcall register_ulcb(unsigned int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 *v5; // rcx
_DWORD *v6; // r8
__int64 result; // rax
int v8; // er9
const char *v9; // rbp
unsigned int v10; // eax
int v11; // esi
const char *v12; // r12
unsigned int v13; // eax
int v14; // er10
const char *v15; // rbx
unsigned int v16; // eax

if ( a1 > 0xF )
{
v8 = get_debug_level("usrloc", 6LL);
result = 4294967291LL;
if ( v8 >= -3 )
{
result = 4294967291LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v9 = (const char *)*((_QWORD *)&log_level_info + 4);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid callback types: mask=%d\n",
process_no,
v10,
v9,
"usrloc [ul_callback.c:89]: ",
"register_ulcb",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid callback types: mask=%d\n",
*((const char **)&log_level_info + 4),
"usrloc [ul_callback.c:89]: ",
"register_ulcb",
a1);
}
--dprint_crit;
result = 4294967291LL;
}
}
}
else if ( a2 )
{
v4 = shm_malloc(0x20u);
if ( v4 )
{
v5 = ulcb_list;
*(_QWORD *)(v4 + 24) = *ulcb_list;
*v5 = v4;
*((_DWORD *)ulcb_list + 2) |= a1;
*(_QWORD *)(v4 + 8) = a2;
*(_QWORD *)(v4 + 16) = a3;
*(_DWORD *)(v4 + 4) = a1;
v6 = *(_DWORD **)(v4 + 24);
if ( v6 )
*(_DWORD *)v4 = *v6 + 1;
else
*(_DWORD *)v4 = 0;
result = 1LL;
}
else
{
v14 = get_debug_level("usrloc", 6LL);
result = 4294967294LL;
if ( v14 >= -1 )
{
result = 4294967294LL;
if ( !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 mem\n",
process_no,
v16,
v15,
"usrloc [ul_callback.c:100]: ",
"register_ulcb");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more share mem\n",
*((const char **)&log_level_info + 8),
"usrloc [ul_callback.c:100]: ",
"register_ulcb");
}
--dprint_crit;
result = 4294967294LL;
}
}
}
}
else
{
v11 = get_debug_level("usrloc", 6LL);
result = 4294967291LL;
if ( v11 >= -3 )
{
result = 4294967291LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 4);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): null callback function\n",
process_no,
v13,
v12,
"usrloc [ul_callback.c:94]: ",
"register_ulcb");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null callback function\n",
*((const char **)&log_level_info + 4),
"usrloc [ul_callback.c:94]: ",
"register_ulcb");
}
--dprint_crit;
result = 4294967291LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 *v5; // rcx
_DWORD *v6; // r8
__int64 result; // rax
int v8; // er9
const char *v9; // rbp
unsigned int v10; // eax
int v11; // esi
const char *v12; // r12
unsigned int v13; // eax
int v14; // er10
const char *v15; // rbx
unsigned int v16; // eax

if ( a1 > 0xF )
{
v8 = get_debug_level("usrloc", 6LL);
result = 4294967291LL;
if ( v8 >= -3 )
{
result = 4294967291LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v9 = (const char *)*((_QWORD *)&log_level_info + 4);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid callback types: mask=%d\n",
process_no,
v10,
v9,
"usrloc [ul_callback.c:89]: ",
"register_ulcb",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid callback types: mask=%d\n",
*((const char **)&log_level_info + 4),
"usrloc [ul_callback.c:89]: ",
"register_ulcb",
a1);
}
--dprint_crit;
result = 4294967291LL;
}
}
}
else if ( a2 )
{
v4 = func4(0x20u);
if ( v4 )
{
v5 = ulcb_list;
*(_QWORD *)(v4 + 24) = *ulcb_list;
*v5 = v4;
*((_DWORD *)ulcb_list + 2) |= a1;
*(_QWORD *)(v4 + 8) = a2;
*(_QWORD *)(v4 + 16) = a3;
*(_DWORD *)(v4 + 4) = a1;
v6 = *(_DWORD **)(v4 + 24);
if ( v6 )
*(_DWORD *)v4 = *v6 + 1;
else
*(_DWORD *)v4 = 0;
result = 1LL;
}
else
{
v14 = get_debug_level("usrloc", 6LL);
result = 4294967294LL;
if ( v14 >= -1 )
{
result = 4294967294LL;
if ( !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 mem\n",
process_no,
v16,
v15,
"usrloc [ul_callback.c:100]: ",
"register_ulcb");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more share mem\n",
*((const char **)&log_level_info + 8),
"usrloc [ul_callback.c:100]: ",
"register_ulcb");
}
--dprint_crit;
result = 4294967294LL;
}
}
}
}
else
{
v11 = get_debug_level("usrloc", 6LL);
result = 4294967291LL;
if ( v11 >= -3 )
{
result = 4294967291LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 4);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): null callback function\n",
process_no,
v13,
v12,
"usrloc [ul_callback.c:94]: ",
"register_ulcb");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): null callback function\n",
*((const char **)&log_level_info + 4),
"usrloc [ul_callback.c:94]: ",
"register_ulcb");
}
--dprint_crit;
result = 4294967291LL;
}
}
}
return result;
}

original_code:
int register_ulcb( int types, ul_cb f, void *param )
{
 struct ul_callback *cbp;
 if ( types<0 || types>((1<<4)-1) ) {
  do { if (get_debug_level("p_usrloc", (sizeof("p_usrloc")-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(): " "invalid callback types: mask=%d\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); 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(): " "invalid callback types: mask=%d\n", (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid callback types: mask=%d\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); 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(): " "invalid callback types: mask=%d\n", ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid callback types: mask=%d\n", ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); } } (dprint_crit--); } } while(0);
  return -5;
 }
 if (f==0) {
  do { if (get_debug_level("p_usrloc", (sizeof("p_usrloc")-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(): " "null callback function\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __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(): " "null callback function\n", (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null callback function\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __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(): " "null callback function\n", ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null callback function\n", ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -5;
 }
 if (!(cbp=(struct ul_callback*)shm_malloc(sizeof( struct ul_callback)))) {
  do { if (get_debug_level("p_usrloc", (sizeof("p_usrloc")-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 mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __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 mem\n", (log_level_info[((-1)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more share mem\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __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 mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __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 mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 cbp->next = ulcb_list->first;
 ulcb_list->first = cbp;
 ulcb_list->reg_types |= types;
 cbp->callback = f;
 cbp->param = param;
 cbp->types = types;
 if (cbp->next)
  cbp->id = cbp->next->id+1;
 else
  cbp->id = 0;
 return 1;
}

canonical_original_code:
int register_ulcb(int types, void f(struct ucontact *c, int type, void *param), void *param)
{
 struct ul_callback *cbp;
 if ( types<0 || types>((1<<4)-1) ) {
  do { if (get_debug_level("p_usrloc", (sizeof("p_usrloc")-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(): " "invalid callback types: mask=%d\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); 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(): " "invalid callback types: mask=%d\n", (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid callback types: mask=%d\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); 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(): " "invalid callback types: mask=%d\n", ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid callback types: mask=%d\n", ("p_usrloc" " [" "ul_callback.c" ":" "89" "]: ") , __func__,types); } } (dprint_crit--); } } while(0);
  return -5;
 }
 if (f==0) {
  do { if (get_debug_level("p_usrloc", (sizeof("p_usrloc")-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(): " "null callback function\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __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(): " "null callback function\n", (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "null callback function\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __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(): " "null callback function\n", ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "null callback function\n", ("p_usrloc" " [" "ul_callback.c" ":" "94" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -5;
 }
 if (!(cbp=(struct ul_callback *)shm_malloc(sizeof( struct ul_callback)))) {
  do { if (get_debug_level("p_usrloc", (sizeof("p_usrloc")-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 mem\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __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 mem\n", (log_level_info[((-1)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more share mem\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __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 mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __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 mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "100" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 cbp->next = ulcb_list->first;
 ulcb_list->first = cbp;
 ulcb_list->reg_types |= types;
 cbp->callback = f;
 cbp->param = param;
 cbp->types = types;
 if (cbp->next)
  cbp->id = cbp->next->id+1;
 else
  cbp->id = 0;
 return 1;
}

variable_types: types int

variable_types: void (struct ucontact { struct _str { char *s; int len; } *domain; struct _str ruid; struct _str *aor; struct _str c; struct _str received; struct _str path; long expires; int q; struct _str callid; int cseq; enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 } state; unsigned int flags; unsigned int cflags; struct _str user_agent; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *sock; long last_modified; long last_keepalive; unsigned int methods; struct _str instance; unsigned int reg_id; int tcpconn_id; struct _sr_xavp { unsigned int id; struct _str name; struct _sr_xval { enum sr_xtype_t { SR_XTYPE_NULL=0, SR_XTYPE_INT=1, SR_XTYPE_STR=2, SR_XTYPE_TIME=3, SR_XTYPE_LONG=4, SR_XTYPE_LLONG=5, SR_XTYPE_XAVP=6, SR_XTYPE_DATA=7 } type; union { int i; struct _str s; long t; long l; long long ll; struct _sr_xavp *xavp; struct _sr_data { void *p; void (*pfree)(void *d, void (*sfree)(void *d)); } *data; } v; } val; struct _sr_xavp *next; } *xavp; struct ucontact *next; struct ucontact *prev; } *c, int type, void *param)

variable_types:
param
void *

return_type: int

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

user_defined_types: struct ucontact { struct _str *domain; struct _str ruid; struct _str *aor; struct _str c; struct _str received; struct _str path; long expires; int q; struct _str callid; int cseq; enum cstate state; unsigned int flags; unsigned int cflags; struct _str user_agent; struct socket_info *sock; long last_modified; long last_keepalive; unsigned int methods; struct _str instance; unsigned int reg_id; int tcpconn_id; struct _sr_xavp *xavp; struct ucontact *next; struct ucontact *prev; }

user_defined_types: struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info useinfo; }

user_defined_types: struct _sr_xavp { unsigned int id; struct _str name; struct _sr_xval val; struct _sr_xavp *next; }

user_defined_types: union sockaddr_union { struct sockaddr s; struct sockaddr_in sin; struct sockaddr_in6 sin6; }

user_defined_types: struct _sr_xval { enum sr_xtype_t type; union { int i; struct _str s; long t; long l; long long ll; struct _sr_xavp *xavp; struct _sr_data *data; } v; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }

user_defined_types: struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; }


decompiled_code:
__int64 destroy_script_cb()
{
__int64 *v0; // rbx
__int64 *v1; // rbp
__int64 result; // rax

v0 = &pre_script_cb;
v1 = &post_script_cb;
do
{
destroy_cb_list(v0);
result = destroy_cb_list(v1);
++v0;
++v1;
}
while ( v0 != (__int64 *)"core" );
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 *v0; // rbx
__int64 *v1; // rbp
__int64 result; // rax

v0 = &pre_script_cb;
v1 = &post_script_cb;
do
{
func1(v0);
result = func1(v1);
++v0;
++v1;
}
while ( v0 != (__int64 *)"core" );
return result;
}

original_code:
void destroy_script_cb()
{
 int i;
 for (i=0; i<(MAX_CB_TYPE-1); i++) {
  destroy_cb_list(&pre_script_cb[i]);
  destroy_cb_list(&post_script_cb[i]);
 }
}

variable_types: i int

return_type: void


decompiled_code:
__int64 ld_mod_destroy()
{
return ld_cfg_free();
}

canonical_decompiled_code:
__int64 func0()
{
return ld_cfg_free();
}

original_code:
static void ld_mod_destroy(void)
{
 ld_cfg_free();
}

canonical_original_code:
static void ld_mod_destroy()
{
 ld_cfg_free();
}


decompiled_code:
__int64 ld_mod_init()
{
__int64 result; // rax
int v1; // edx
const char *v2; // rbx
unsigned int v3; // eax

result = ld_load_cfg(&ld_cfg_file);
if ( (_DWORD)result )
{
v1 = get_debug_level("db2_ldap", 8LL);
result = 0xFFFFFFFFLL;
if ( v1 >= -1 )
{
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(): ldap: Error while loading configuration file\n",
process_no,
v3,
v2,
"db2_ldap [ld_mod.c:529]: ",
"ld_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ldap: Error while loading configuration file\n",
*((const char **)&log_level_info + 8),
"db2_ldap [ld_mod.c:529]: ",
"ld_mod_init");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
int v1; // edx
const char *v2; // rbx
unsigned int v3; // eax

result = ld_load_cfg(&ld_cfg_file);
if ( (_DWORD)result )
{
v1 = get_debug_level("db2_ldap", 8LL);
result = 0xFFFFFFFFLL;
if ( v1 >= -1 )
{
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(): ldap: Error while loading configuration file\n",
process_no,
v3,
v2,
"db2_ldap [ld_mod.c:529]: ",
"ld_mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ldap: Error while loading configuration file\n",
*((const char **)&log_level_info + 8),
"db2_ldap [ld_mod.c:529]: ",
"ld_mod_init");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
static int ld_mod_init(void)
{
 if (ld_load_cfg(&ld_cfg_file)) {
   do { if (get_debug_level("db2_ldap", (sizeof("db2_ldap")-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(): " "ldap: Error while loading configuration file\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __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(): " "ldap: Error while loading configuration file\n", (log_level_info[((-1)) - (-5)].name), ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ldap: Error while loading configuration file\n", process_no, my_pid(), ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __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(): " "ldap: Error while loading configuration file\n", ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ldap: Error while loading configuration file\n", ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
 }
 return 0;
}

canonical_original_code:
static int ld_mod_init()
{
 if (ld_load_cfg(&ld_cfg_file)) {
   do { if (get_debug_level("db2_ldap", (sizeof("db2_ldap")-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(): " "ldap: Error while loading configuration file\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __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(): " "ldap: Error while loading configuration file\n", (log_level_info[((-1)) - (-5)].name), ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ldap: Error while loading configuration file\n", process_no, my_pid(), ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __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(): " "ldap: Error while loading configuration file\n", ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ldap: Error while loading configuration file\n", ("db2_ldap" " [" "ld_mod.c" ":" "529" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
 }
 return 0;
}


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


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 str2sub_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 = 3;
}
else
{
v2 = strcmp(a1, "block") == 0;
result = !v2;
if ( v2 )
{
*a2 = 0;
}
else
{
v2 = strcmp(a1, "polite-block") == 0;
result = !v2;
if ( v2 )
{
*a2 = 2;
}
else
{
v2 = strcmp(a1, "confirm") == 0;
result = !v2;
if ( v2 )
{
*a2 = 1;
}
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 sub-handling value: '%s'\n",
process_no,
v5,
v4,
"<core> [parse_pres_rules.c:59]: ",
"str2sub_handling",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid sub-handling value: '%s'\n",
*((const char **)&log_level_info + 8),
"<core> [parse_pres_rules.c:59]: ",
"str2sub_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 = 3;
}
else
{
v2 = strcmp(a1, "block") == 0;
result = !v2;
if ( v2 )
{
*a2 = 0;
}
else
{
v2 = strcmp(a1, "polite-block") == 0;
result = !v2;
if ( v2 )
{
*a2 = 2;
}
else
{
v2 = strcmp(a1, "confirm") == 0;
result = !v2;
if ( v2 )
{
*a2 = 1;
}
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 sub-handling value: '%s'\n",
process_no,
v5,
v4,
"<core> [parse_pres_rules.c:59]: ",
"str2sub_handling",
a1);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid sub-handling value: '%s'\n",
*((const char **)&log_level_info + 8),
"<core> [parse_pres_rules.c:59]: ",
"str2sub_handling",
a1);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
}
}
return result;
}

original_code:
static int str2sub_handling(const char *s, sub_handling_t *dst)
{
 if (!s) return (-1);
 if (strcmp(s, "allow") == 0) {
  *dst = sub_handling_allow;
  return 0;
 }
 if (strcmp(s, "block") == 0) {
  *dst = sub_handling_block;
  return 0;
 }
 if (strcmp(s, "polite-block") == 0) {
  *dst = sub_handling_polite_block;
  return 0;
 }
 if (strcmp(s, "confirm") == 0) {
  *dst = sub_handling_confirm;
  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 sub-handling value: \'%s\'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __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 sub-handling value: \'%s\'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __func__, s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid sub-handling value: \'%s\'\n", process_no, my_pid(), ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __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 sub-handling value: \'%s\'\n", ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __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 sub-handling value: \'%s\'\n", ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __func__, s); } } (dprint_crit--); } } while(0);
 return (-1);
}

canonical_original_code:
static int str2sub_handling(char *s, enum sub_handling_t *dst)
{
 if (!s) return (-1);
 if (strcmp(s, "allow") == 0) {
  *dst = sub_handling_allow;
  return 0;
 }
 if (strcmp(s, "block") == 0) {
  *dst = sub_handling_block;
  return 0;
 }
 if (strcmp(s, "polite-block") == 0) {
  *dst = sub_handling_polite_block;
  return 0;
 }
 if (strcmp(s, "confirm") == 0) {
  *dst = sub_handling_confirm;
  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 sub-handling value: \'%s\'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __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 sub-handling value: \'%s\'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __func__, s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid sub-handling value: \'%s\'\n", process_no, my_pid(), ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __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 sub-handling value: \'%s\'\n", ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __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 sub-handling value: \'%s\'\n", ("<core> [" "parse_pres_rules.c" ":" "59" "]: ") , __func__, s); } } (dprint_crit--); } } while(0);
 return (-1);
}

variable_types:
s
char *

variable_types: enum sub_handling_t { sub_handling_block=0, sub_handling_confirm=1, sub_handling_polite_block=2, sub_handling_allow=3 } *


decompiled_code:
__int64 __fastcall parse_pres_rules(__int64 a1, __int64 a2, __int64 a3)
{
return parse_common_rules(a1, a2, a3, read_pres_actions, &free_pres_actions);
}

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

original_code:
int parse_pres_rules(const char *data, int dsize, cp_ruleset_t **dst)
{
 return parse_common_rules(data, dsize, dst, read_pres_actions, free_pres_actions);
}

canonical_original_code:
int parse_pres_rules(char *data, int dsize, struct cp_ruleset_t **dst)
{
 return parse_common_rules(data, dsize, dst, read_pres_actions, free_pres_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:
void *__fastcall load_dnsfunc(void **a1)
{
void *result; // rax

result = *a1;
dns_func = *a1;
*(&dns_func + 1) = a1[1];
*(&dns_func + 2) = a1[2];
*(&dns_func + 3) = a1[3];
return result;
}

canonical_decompiled_code:
void *__fastcall func0(void **a1)
{
void *result; // rax

result = *a1;
dns_func = *a1;
*(&dns_func + 1) = a1[1];
*(&dns_func + 2) = a1[2];
*(&dns_func + 3) = a1[3];
return result;
}

original_code:
void load_dnsfunc(struct dns_func_t *d) {
 dns_func.sr_res_init = d->sr_res_init;
 dns_func.sr_res_search = d->sr_res_search;
 dns_func.sr_gethostbyname = d->sr_gethostbyname;
 dns_func.sr_gethostbyname2 = d->sr_gethostbyname2;
}

variable_types: struct dns_func_t { int (*sr_res_init)(); int (*sr_res_search)(char *, int, int, unsigned char *, int); struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *(*sr_gethostbyname)(char *); struct hostent *(*sr_gethostbyname2)(char *, int); } *

user_defined_types: struct dns_func_t { int (*sr_res_init)(); int (*sr_res_search)(char *, int, int, unsigned char *, int); struct hostent *(*sr_gethostbyname)(char *); struct hostent *(*sr_gethostbyname2)(char *, int); }


original_code:
int parse_nameaddr(str* _s, name_addr_t* _a)
{
 char* uri_end;
 if (!_s || !_a) {
  return -1;
 }
 _a->name.s = _s->s;
 _a->uri.s = find_not_quoted(_s, '<');
 if (_a->uri.s) {
  _a->name.len = _a->uri.s - _a->name.s;
  _a->uri.s++;
 } else {
  return -3;
 }
 _a->uri.len = _s->len - _a->name.len - 1;
 uri_end = find_not_quoted(&_a->uri, '>');
 if (!uri_end) {
  return -4;
 }
 _a->len = uri_end - _a->name.s + 1;
 _a->uri.len = uri_end - _a->uri.s;
 return 0;
}

canonical_original_code:
int parse_nameaddr(struct _str *_s, struct name_addr *_a)
{
 char *uri_end;
 if (!_s || !_a) {
  return -1;
 }
 _a->name.s = _s->s;
 _a->uri.s = find_not_quoted(_s, '<');
 if (_a->uri.s) {
  _a->name.len = _a->uri.s - _a->name.s;
  _a->uri.s++;
 } else {
  return -3;
 }
 _a->uri.len = _s->len - _a->name.len - 1;
 uri_end = find_not_quoted(&_a->uri, '>');
 if (!uri_end) {
  return -4;
 }
 _a->len = uri_end - _a->name.s + 1;
 _a->uri.len = uri_end - _a->uri.s;
 return 0;
}

variable_types: struct name_addr { struct _str name; struct _str uri; int len; } *


decompiled_code:
__int64 __fastcall ro_send_ccr_fixup(_BYTE **a1, unsigned int a2)
{
__int64 result; // rax
int v3; // edx
const char *v4; // rbp
unsigned int v5; // eax

if ( **a1 )
return fixup_var_int_12(a1, 1LL);
v3 = get_debug_level("ims_charging", 12LL);
result = 0xFFFFFFFFLL;
if ( v3 >= -1 )
{
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(): empty parameter %d not allowed\n",
process_no,
v5,
v4,
"ims_charging [ro_fixup.c:13]: ",
"ro_send_ccr_fixup",
a2);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): empty parameter %d not allowed\n",
*((const char **)&log_level_info + 8),
"ims_charging [ro_fixup.c:13]: ",
"ro_send_ccr_fixup",
a2);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE **a1, unsigned int a2)
{
__int64 result; // rax
int v3; // edx
const char *v4; // rbp
unsigned int v5; // eax

if ( **a1 )
return fixup_var_int_12(a1, 1LL);
v3 = get_debug_level("ims_charging", 12LL);
result = 0xFFFFFFFFLL;
if ( v3 >= -1 )
{
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(): empty parameter %d not allowed\n",
process_no,
v5,
v4,
"ims_charging [ro_fixup.c:13]: ",
"ro_send_ccr_fixup",
a2);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): empty parameter %d not allowed\n",
*((const char **)&log_level_info + 8),
"ims_charging [ro_fixup.c:13]: ",
"ro_send_ccr_fixup",
a2);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int ro_send_ccr_fixup(void** param, int param_no) {
    if (strlen((char*) *param) <= 0) {
        do { if (get_debug_level("ims_charging", (sizeof("ims_charging")-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 %d not allowed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); 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 %d not allowed\n", (log_level_info[((-1)) - (-5)].name), ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "empty parameter %d not allowed\n", process_no, my_pid(), ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); 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 %d not allowed\n", ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty parameter %d not allowed\n", ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); } } (dprint_crit--); } } while(0);
        return -1;
    }
    return fixup_var_int_12(param, 1);
}

canonical_original_code:
int ro_send_ccr_fixup(void **param, int param_no) {
    if (strlen((char *) *param) <= 0) {
        do { if (get_debug_level("ims_charging", (sizeof("ims_charging")-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 %d not allowed\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); 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 %d not allowed\n", (log_level_info[((-1)) - (-5)].name), ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "empty parameter %d not allowed\n", process_no, my_pid(), ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); 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 %d not allowed\n", ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "empty parameter %d not allowed\n", ("ims_charging" " [" "ro_fixup.c" ":" "13" "]: ") , __func__, param_no); } } (dprint_crit--); } } while(0);
        return -1;
    }
    return fixup_var_int_12(param, 1);
}

variable_types:
param
void **

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 init_lock_ops()
{
__int64 result; // rax
int v1; // edx
const char *v2; // rbx
unsigned int v3; // eax

if ( (int)get_sys_version(0LL, 0LL, 0LL) > 132421 )
return 0LL;
v1 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v1 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 6);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: init_lock_ops: old kernel: compiled with FUTEX support which is not present in the ru"
"nning kernel (try 2.6+)\n",
process_no,
v3,
v2,
"<core> [lock_ops.c:58]: ",
"init_lock_ops");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: init_lock_ops: old kernel: compiled with FUTEX support which is not present in the running ke"
"rnel (try 2.6+)\n",
*((const char **)&log_level_info + 6),
"<core> [lock_ops.c:58]: ",
"init_lock_ops");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
int v1; // edx
const char *v2; // rbx
unsigned int v3; // eax

if ( (int)get_sys_version(0LL, 0LL, 0LL) > 132421 )
return 0LL;
v1 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v1 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 6);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: init_lock_ops: old kernel: compiled with FUTEX support which is not present in the ru"
"nning kernel (try 2.6+)\n",
process_no,
v3,
v2,
"<core> [lock_ops.c:58]: ",
"init_lock_ops");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: init_lock_ops: old kernel: compiled with FUTEX support which is not present in the running ke"
"rnel (try 2.6+)\n",
*((const char **)&log_level_info + 6),
"<core> [lock_ops.c:58]: ",
"init_lock_ops");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int init_lock_ops(void)
{
 int os_ver;
 os_ver=get_sys_version(0, 0, 0);
 if (os_ver < 0x020546 ){
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", process_no, my_pid(), ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return 0;
}

canonical_original_code:
int init_lock_ops()
{
 int os_ver;
 os_ver=get_sys_version(0, 0, 0);
 if (os_ver < 0x020546 ){
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", process_no, my_pid(), ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: init_lock_ops: old kernel:" " compiled with FUTEX support which is not present in the" " running kernel (try  2.6+)\n", ("<core> [" "lock_ops.c" ":" "58" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return 0;
}


decompiled_code:
void destroy_lock_ops()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void destroy_lock_ops(void)
{
}

canonical_original_code:
void destroy_lock_ops()
{
}


variable_types:
begin
char *

variable_types:
end
char *

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

variable_types:
p
char *

variable_types:
val
unsigned int

return_type: char *


decompiled_code:
size_t __fastcall curlmem_cb(void *src, __int64 a2, __int64 a3, __int64 a4)
{
size_t v4; // rsi
__int64 v5; // rax
size_t v6; // rbx

v4 = a3 * a2;
v5 = *(int *)(a4 + 8);
v6 = 0LL;
if ( v5 + v4 <= 0x1FFF )
{
v6 = v4;
memcpy((void *)(*(_QWORD *)a4 + v5), src, v4);
*(_DWORD *)(a4 + 8) += v4;
}
return v6;
}

canonical_decompiled_code:
size_t __fastcall func0(void *src, __int64 a2, __int64 a3, __int64 a4)
{
size_t v4; // rsi
__int64 v5; // rax
size_t v6; // rbx

v4 = a3 * a2;
v5 = *(int *)(a4 + 8);
v6 = 0LL;
if ( v5 + v4 <= 0x1FFF )
{
v6 = v4;
memcpy((void *)(*(_QWORD *)a4 + v5), src, v4);
*(_DWORD *)(a4 + 8) += v4;
}
return v6;
}

original_code:
size_t curlmem_cb(void *ptr, size_t size, size_t nmemb, void *data)
{
 size_t irealsize = size * nmemb;
 if (((str*)data)->len + irealsize >= 8*1024)
  return 0;
 memcpy(&(((str*)data)->s[((str*)data)->len]), ptr, irealsize);
 ((str*)data)->len+=irealsize;
 return irealsize;
}

canonical_original_code:
unsigned long curlmem_cb(void *ptr, unsigned long size, unsigned long nmemb, void *data)
{
 unsigned long irealsize = size * nmemb;
 if (((struct _str *)data)->len + irealsize >= 8*1024)
  return 0;
 memcpy(&(((struct _str *)data)->s[((struct _str *)data)->len]), ptr, irealsize);
 ((struct _str *)data)->len+=irealsize;
 return irealsize;
}

variable_types:
ptr
void *

variable_types:
size
unsigned long

variable_types:
nmemb
unsigned long

variable_types:
data
void *

variable_types:
irealsize
unsigned long

return_type: unsigned long


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


decompiled_code:
__int64 __fastcall contact_parser(unsigned __int8 *a1, int a2, _BYTE *a3)
{
__int64 result; // rax
int v5; // er9
const char *v6; // rbx
unsigned int v7; // eax
int v8; // edx
const char *v9; // rbx
unsigned int v10; // eax
unsigned __int8 *v11; // [rsp+0h] [rbp-18h] BYREF
int v12; // [rsp+8h] [rbp-10h]

v11 = a1;
v12 = a2;
trim_leading(&v11);
if ( v12 )
{
if ( *v11 == 42 )
{
*a3 = 1;
result = 0LL;
}
else if ( (int)parse_contacts(&v11, a3 + 8) < 0 )
{
v8 = get_debug_level("core", 4LL);
result = 4294967294LL;
if ( v8 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): contact_parser(): Error while parsing contacts\n",
process_no,
v10,
v9,
"<core> [parser/contact/parse_contact.c:59]: ",
"contact_parser");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): contact_parser(): Error while parsing contacts\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:59]: ",
"contact_parser");
}
--dprint_crit;
result = 4294967294LL;
}
}
else
{
result = 0LL;
}
}
else
{
v5 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 && !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(): contact_parser(): Empty body\n",
process_no,
v7,
v6,
"<core> [parser/contact/parse_contact.c:51]: ",
"contact_parser");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): contact_parser(): Empty body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:51]: ",
"contact_parser");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, int a2, _BYTE *a3)
{
__int64 result; // rax
int v5; // er9
const char *v6; // rbx
unsigned int v7; // eax
int v8; // edx
const char *v9; // rbx
unsigned int v10; // eax
unsigned __int8 *v11; // [rsp+0h] [rbp-18h] BYREF
int v12; // [rsp+8h] [rbp-10h]

v11 = a1;
v12 = a2;
func0(&v11);
if ( v12 )
{
if ( *v11 == 42 )
{
*a3 = 1;
result = 0LL;
}
else if ( (int)parse_contacts(&v11, a3 + 8) < 0 )
{
v8 = get_debug_level("core", 4LL);
result = 4294967294LL;
if ( v8 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): contact_parser(): Error while parsing contacts\n",
process_no,
v10,
v9,
"<core> [parser/contact/parse_contact.c:59]: ",
"contact_parser");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): contact_parser(): Error while parsing contacts\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:59]: ",
"contact_parser");
}
--dprint_crit;
result = 4294967294LL;
}
}
else
{
result = 0LL;
}
}
else
{
v5 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 && !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(): contact_parser(): Empty body\n",
process_no,
v7,
v6,
"<core> [parser/contact/parse_contact.c:51]: ",
"contact_parser");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): contact_parser(): Empty body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:51]: ",
"contact_parser");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
static inline int contact_parser(char* _s, int _l, contact_body_t* _c)
{
 str tmp;
 tmp.s = _s;
 tmp.len = _l;
 trim_leading(&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(): " "contact_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __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(): " "contact_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "contact_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __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(): " "contact_parser(): Empty body\n", ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "contact_parser(): Empty body\n", ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (tmp.s[0] == '*') {
  _c->star = 1;
 } else {
  if (parse_contacts(&tmp, &(_c->contacts)) < 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(): " "contact_parser(): Error while parsing contacts\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.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(): " "contact_parser(): Error while parsing contacts\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.c" ":" "59" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "contact_parser(): Error while parsing contacts\n", process_no, my_pid(), ("<core> [" "parser/contact/parse_contact.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(): " "contact_parser(): Error while parsing contacts\n", ("<core> [" "parser/contact/parse_contact.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(): " "contact_parser(): Error while parsing contacts\n", ("<core> [" "parser/contact/parse_contact.c" ":" "59" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -2;
  }
 }
 return 0;
}

canonical_original_code:
static inline int contact_parser(char *_s, int _l, struct contact_body *_c)
{
 struct _str tmp;
 tmp.s = _s;
 tmp.len = _l;
 trim_leading(&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(): " "contact_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __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(): " "contact_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "contact_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __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(): " "contact_parser(): Empty body\n", ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "contact_parser(): Empty body\n", ("<core> [" "parser/contact/parse_contact.c" ":" "51" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (tmp.s[0] == '*') {
  _c->star = 1;
 } else {
  if (parse_contacts(&tmp, &(_c->contacts)) < 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(): " "contact_parser(): Error while parsing contacts\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.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(): " "contact_parser(): Error while parsing contacts\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/contact/parse_contact.c" ":" "59" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "contact_parser(): Error while parsing contacts\n", process_no, my_pid(), ("<core> [" "parser/contact/parse_contact.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(): " "contact_parser(): Error while parsing contacts\n", ("<core> [" "parser/contact/parse_contact.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(): " "contact_parser(): Error while parsing contacts\n", ("<core> [" "parser/contact/parse_contact.c" ":" "59" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -2;
  }
 }
 return 0;
}

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

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

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

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

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


decompiled_code:
__int64 __fastcall parse_contact(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rax
__int64 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 = qm_malloc(mem_block, 16LL);
v3 = v2;
if ( v2 )
{
*(_QWORD *)v2 = 0LL;
*(_QWORD *)(v2 + 8) = 0LL;
if ( (int)contact_parser(*(unsigned __int8 **)(a1 + 24), *(_DWORD *)(a1 + 32), (_BYTE *)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_contact(): Error while parsing\n",
process_no,
v8,
v7,
"<core> [parser/contact/parse_contact.c:88]: ",
"parse_contact");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_contact(): Error while parsing\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:88]: ",
"parse_contact");
}
--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_contact(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/contact/parse_contact.c:81]: ",
"parse_contact");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_contact(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:81]: ",
"parse_contact");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rax
__int64 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 = qm_malloc(mem_block, 16LL);
v3 = v2;
if ( v2 )
{
*(_QWORD *)v2 = 0LL;
*(_QWORD *)(v2 + 8) = 0LL;
if ( (int)func1(*(unsigned __int8 **)(a1 + 24), *(_DWORD *)(a1 + 32), (_BYTE *)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_contact(): Error while parsing\n",
process_no,
v8,
v7,
"<core> [parser/contact/parse_contact.c:88]: ",
"parse_contact");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_contact(): Error while parsing\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:88]: ",
"parse_contact");
}
--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_contact(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/contact/parse_contact.c:81]: ",
"parse_contact");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_contact(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/contact/parse_contact.c:81]: ",
"parse_contact");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

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

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

user_defined_types: enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 }


decompiled_code:
void clear_params()
{
xcap_root = 0;
}

canonical_decompiled_code:
void func0()
{
xcap_root = 0;
}

original_code:
static void clear_params()
{
 *xcap_root = 0;
}