decompiled_code:
__int64 __fastcall rls_trace(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
unsigned int v3; // ebp
__int64 result; // rax
int v5[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v5[0] = 0;
if ( (*(int (__fastcall **)(__int64, const char *, int *))(a1 + 24))(a2, "d", v5) <= 0 )
v5[0] = 0;
(*(void (__fastcall **)(__int64, __int64, const char *))a1)(a2, 200LL, "OK");
(*(void (__fastcall **)(__int64, const char *, const char *))(a1 + 16))(a2, "s", "RLS Trace:");
if ( rls )
{
v2 = *rls_manager;
if ( *rls_manager )
{
v3 = 0;
do
{
++v3;
if ( v5[0] > 0 )
rls_trace_subscription(a1, a2, *(unsigned int **)(v2 + 56), v5[0]);
v2 = *(_QWORD *)(v2 + 72);
}
while ( v2 );
}
else
{
v3 = 0;
}
(*(void (**)(__int64, const char *, ...))(a1 + 32))(a2, "subscription count: %d", v3);
result = (*(__int64 (__fastcall **)(__int64))(a1 + 8))(a2);
}
else
{
(*(void (__fastcall **)(__int64, const char *))(a1 + 32))(a2, "problems");
result = (*(__int64 (__fastcall **)(__int64))(a1 + 8))(a2);
}
return result;
}

original_code:
static void rls_trace(rpc_t *rpc, void *c)
{
 int i = 0;
 subscription_data_t *s;
 rl_subscription_t *rs;
 int details = 0;
 if (rpc->scan(c, "d", &details) <= 0)
  details = 0;
 rpc->fault(c, 200, "OK");
 rpc->add(c, "s", "RLS Trace:");
 if (!rls) {
  rpc->printf(c, "problems");
  rpc->send(c);
  return;
 }
 s = rls_manager->first;
 while (s) {
  i++;
  rs = (rl_subscription_t*)(s->usr_data);
  if (details > 0) rls_trace_subscription(rpc, c, rs, details);
  s = s->next;
 }
 rpc->printf(c, "subscription count: %d", i);
 do { } while (0);
 rpc->send(c);
}

canonical_original_code:
static void rls_trace(struct rpc *rpc, void *c)
{
 int i = 0;
 struct _subscription_data_t *s;
 struct _rl_subscription_t *rs;
 int details = 0;
 if (rpc->scan(c, "d", &details) <= 0)
  details = 0;
 rpc->fault(c, 200, "OK");
 rpc->add(c, "s", "RLS Trace:");
 if (!rls) {
  rpc->printf(c, "problems");
  rpc->send(c);
  return;
 }
 s = rls_manager->first;
 while (s) {
  i++;
  rs = (struct _rl_subscription_t *)(s->usr_data);
  if (details > 0) rls_trace_subscription(rpc, c, rs, details);
  s = s->next;
 }
 rpc->printf(c, "subscription count: %d", i);
 do { } while (0);
 rpc->send(c);
}

variable_types: struct _subscription_data_t { struct _time_event_data_t { unsigned int tick_time; void (*cb)(struct _time_event_data_t *s); void *cb_param; void *cb_param1; struct _time_event_data_t *next; struct _time_event_data_t *prev; } expiration; struct dlg { struct dlg_id { struct _str { char *s; int len; } call_id; struct _str rem_tag; struct _str loc_tag; } id; struct dlg_seq { unsigned int value; unsigned char is_set; } loc_seq; struct dlg_seq rem_seq; struct _str loc_uri; struct _str rem_uri; struct _str rem_target; struct _str dst_uri; struct _str loc_dname; struct _str rem_dname; unsigned char secure; enum dlg_state { DLG_NEW=0, DLG_EARLY=1, DLG_CONFIRMED=2, DLG_DESTROYED=3 } state; struct rr { struct name_addr { struct _str name; struct _str uri; int len; } nameaddr; struct param { enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 } type; struct _str name; struct _str body; int len; struct param *next; } *r2; struct param *params; int len; struct rr *next; } *route_set; struct dlg_hooks { struct _str ru; struct _str nh; struct _str *request_uri; struct _str *next_hop; struct rr *first_route; struct _str *last_route; } hooks; 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; } *send_sock; } *dialog; void *usr_data; enum subscription_status_t { subscription_uninitialized=0, subscription_active=1, subscription_pending=2, subscription_terminated=3, subscription_terminated_to=4, subscription_terminated_pending=5, subscription_terminated_pending_to=6 } status; struct _subscription_data_t *next; struct _subscription_data_t *prev; struct _str contact; struct _str record_id; struct _str package; struct _str subscriber; } *

user_defined_types: struct _rl_subscription_t { enum rls_subscription_type_t type; struct xcap_query_params_t xcap_params; union { struct _subscription_data_t external; struct internal_subscription_data_t internal; } u; int doc_version; int changed; struct vector_t vs; struct _str from_uid; char dbid[48]; }

user_defined_types: enum rls_subscription_type_t { rls_internal_subscription=0, rls_external_subscription=1 }

user_defined_types: struct dlg_id { struct _str call_id; struct _str rem_tag; struct _str loc_tag; }

user_defined_types: struct _qsa_subscription_data_t { struct msg_queue *dst; struct _str record_id; struct _str subscriber_id; struct _qsa_subscription_params_t *first_param; void *subscriber_data; }

user_defined_types: struct vector_t { int element_size; int element_count; int allocated_count; int allocation_count; void *data; }

user_defined_types: struct _qsa_subscription_t { struct atomic_t *mutex; struct _notifier_package_t *package; int allow_notifications; struct _qsa_subscription_data_t *data; struct _qsa_subscription_t *prev; struct reference_counter_data_t ref; }

user_defined_types: struct msg_queue { struct reference_counter_data_t ref; struct _mq_message_t *first; struct _mq_message_t *last; struct atomic_t q_mutex; unsigned int flags; }

user_defined_types: struct _qsa_subscription_params_t { struct _str name; struct _str value; char buf[1]; }

user_defined_types: struct reference_counter_data_t { int cntr; struct atomic_t *mutex; }

user_defined_types: struct _notifier_package_t { struct _str name; struct _notifier_domain_t *domain; struct _notifier_t *first_notifier; struct _qsa_subscription_t *first_subscription; struct _notifier_package_t *next; }

user_defined_types: struct _mq_message_t { void *data; int data_len; struct _mq_message_t *next; void (*destroy_function)(void *); enum { message_allocated_with_data=0, message_holding_data_ptr=1 } allocation_style; char data_buf[1]; }

user_defined_types: struct _notifier_t { int (*subscribe)(struct _notifier_t *n, struct _qsa_subscription_t *subscription); void (*unsubscribe)(struct _notifier_t *n, struct _qsa_subscription_t *subscription); void *user_data; struct _notifier_package_t *package; struct _notifier_t *prev; }

user_defined_types: struct _qsa_content_type_t { struct _qsa_content_type_t *next; struct _str name; void (*destroy_func)(void *); char buf[1]; }

user_defined_types: struct reference_counter_group_t { int mutex_cnt; int mutex_to_assign; struct atomic_t mutexes[1]; }


repo: virtualolson/who

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

return_type: int


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *

variable_types: i int

return_type: void


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

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

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

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

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

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


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

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

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

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

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

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

variable_types:
size
unsigned int

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 __fastcall create_new_regsessiondata(__int64 a1, __int64 a2, _QWORD *a3)
{
signed int v4; // ebp
_DWORD *v5; // rax
_DWORD *v6; // rbx
int v7; // eax
_BYTE *v8; // r14
int v9; // eax
__int64 result; // rax
int v11; // er8
const char *v12; // r12
unsigned int v13; // eax
const char *v14; // rbp
unsigned int v15; // eax

v4 = *(_DWORD *)(a1 + 8) + *(_DWORD *)(a2 + 8) + 89;
v5 = (_DWORD *)shm_malloc(v4);
if ( v5 )
{
v6 = v5;
memset(v5, 0, v4);
v6[12] = 1;
*((_QWORD *)v6 + 7) = v6 + 22;
memcpy(v6 + 22, *(const void **)a1, *(int *)(a1 + 8));
v7 = *(_DWORD *)(a1 + 8);
v6[16] = v7;
v8 = (char *)v6 + v7 + 88;
*v8 = 0;
*((_QWORD *)v6 + 9) = v8 + 1;
memcpy(v8 + 1, *(const void **)a2, *(int *)(a2 + 8));
v9 = *(_DWORD *)(a2 + 8);
v6[20] = v9;
if ( &v8[v9 + 1] == (char *)v6 + v4 )
{
*a3 = v6;
result = 1LL;
}
else
{
if ( (int)get_debug_level("ims_qos", 7LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): buffer over/underflow\n",
process_no,
v15,
v14,
"ims_qos [rx_authdata.c:95]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): buffer over/underflow\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:95]: ",
"create_new_regsessiondata");
}
--dprint_crit;
}
futex_get(mem_lock);
qm_free(shm_block, v6);
futex_release(mem_lock);
result = 0xFFFFFFFFLL;
}
}
else
{
v11 = get_debug_level("ims_qos", 7LL);
result = 0xFFFFFFFFLL;
if ( v11 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shm memory\n",
process_no,
v13,
v12,
"ims_qos [rx_authdata.c:76]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more shm memory\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:76]: ",
"create_new_regsessiondata");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, _QWORD *a3)
{
signed int v4; // ebp
_DWORD *v5; // rax
_DWORD *v6; // rbx
int v7; // eax
_BYTE *v8; // r14
int v9; // eax
__int64 result; // rax
int v11; // er8
const char *v12; // r12
unsigned int v13; // eax
const char *v14; // rbp
unsigned int v15; // eax

v4 = *(_DWORD *)(a1 + 8) + *(_DWORD *)(a2 + 8) + 89;
v5 = (_DWORD *)func4(v4);
if ( v5 )
{
v6 = v5;
memset(v5, 0, v4);
v6[12] = 1;
*((_QWORD *)v6 + 7) = v6 + 22;
memcpy(v6 + 22, *(const void **)a1, *(int *)(a1 + 8));
v7 = *(_DWORD *)(a1 + 8);
v6[16] = v7;
v8 = (char *)v6 + v7 + 88;
*v8 = 0;
*((_QWORD *)v6 + 9) = v8 + 1;
memcpy(v8 + 1, *(const void **)a2, *(int *)(a2 + 8));
v9 = *(_DWORD *)(a2 + 8);
v6[20] = v9;
if ( &v8[v9 + 1] == (char *)v6 + v4 )
{
*a3 = v6;
result = 1LL;
}
else
{
if ( (int)get_debug_level("ims_qos", 7LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): buffer over/underflow\n",
process_no,
v15,
v14,
"ims_qos [rx_authdata.c:95]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): buffer over/underflow\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:95]: ",
"create_new_regsessiondata");
}
--dprint_crit;
}
func2(mem_lock);
qm_free(shm_block, v6);
func3(mem_lock);
result = 0xFFFFFFFFLL;
}
}
else
{
v11 = get_debug_level("ims_qos", 7LL);
result = 0xFFFFFFFFLL;
if ( v11 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shm memory\n",
process_no,
v13,
v12,
"ims_qos [rx_authdata.c:76]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more shm memory\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:76]: ",
"create_new_regsessiondata");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int create_new_regsessiondata(str* domain, str* aor, rx_authsessiondata_t** session_data) {
 int len = (domain->len + 1) + aor->len + sizeof(rx_authsessiondata_t);
 rx_authsessiondata_t* p_session_data = shm_malloc(len);
 if (!p_session_data) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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 shm memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __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 shm memory\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more shm memory\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __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 shm memory\n", ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __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 shm memory\n", ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(p_session_data, 0, len);
 p_session_data->subscribed_to_signaling_path_status = 1;
 char* p = (char*)(p_session_data + 1);
 p_session_data->domain.s = p;
 memcpy(p, domain->s, domain->len);
 p_session_data->domain.len = domain->len;
 p += domain->len;
 *p++ = '\0';
 p_session_data->registration_aor.s = p;
 memcpy(p, aor->s, aor->len);
 p_session_data->registration_aor.len = aor->len;
 p += aor->len;
 if (p != (((char*)p_session_data) + len)) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "buffer over/underflow\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __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(): " "buffer over/underflow\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "buffer over/underflow\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __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(): " "buffer over/underflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "buffer over/underflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (p_session_data)); futex_release(mem_lock); }while(0);
  p_session_data = 0;
  return -1;
 }
 *session_data = p_session_data;
 return 1;
}

canonical_original_code:
int create_new_regsessiondata(struct _str *domain, struct _str *aor, struct rx_authsessiondata **session_data) {
 int len = (domain->len + 1) + aor->len + sizeof(rx_authsessiondata_t);
 struct rx_authsessiondata *p_session_data = shm_malloc(len);
 if (!p_session_data) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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 shm memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __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 shm memory\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more shm memory\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __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 shm memory\n", ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __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 shm memory\n", ("ims_qos" " [" "rx_authdata.c" ":" "76" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(p_session_data, 0, len);
 p_session_data->subscribed_to_signaling_path_status = 1;
 char *p = (char*)(p_session_data + 1);
 p_session_data->domain.s = p;
 memcpy(p, domain->s, domain->len);
 p_session_data->domain.len = domain->len;
 p += domain->len;
 *p++ = '\0';
 p_session_data->registration_aor.s = p;
 memcpy(p, aor->s, aor->len);
 p_session_data->registration_aor.len = aor->len;
 p += aor->len;
 if (p != (((char *)p_session_data) + len)) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "buffer over/underflow\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __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(): " "buffer over/underflow\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "buffer over/underflow\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __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(): " "buffer over/underflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "buffer over/underflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "95" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (p_session_data)); futex_release(mem_lock); }while(0);
  p_session_data = 0;
  return -1;
 }
 *session_data = p_session_data;
 return 1;
}

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

variable_types:
aor
struct _str *

variable_types: struct rx_authsessiondata { struct _str callid; struct _str ftag; struct _str ttag; int subscribed_to_signaling_path_status; struct _str domain; struct _str registration_aor; } **

variable_types: len int

variable_types: struct rx_authsessiondata { struct _str { char *s; int len; } callid; struct _str ftag; struct _str ttag; int subscribed_to_signaling_path_status; struct _str domain; struct _str registration_aor; } *

variable_types:
p
char *

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


decompiled_code:
__int64 __fastcall create_new_callsessiondata(_QWORD *a1, _QWORD *a2, _QWORD *a3, _QWORD *a4)
{
__int64 v5; // rbx
char *v6; // rax
char *v7; // rbp
char *v8; // r15
int v9; // eax
int v10; // eax
int v11; // eax
__int64 result; // rax
int v13; // er14
const char *v14; // r13
unsigned int v15; // eax
unsigned int v16; // eax
const char *v17; // r14
unsigned int v18; // eax
const char *v19; // r13
int v20; // er14
unsigned int v21; // eax
const char *v22; // r12
unsigned int v23; // eax
const char *v25; // [rsp+8h] [rbp-50h]
int v26; // [rsp+8h] [rbp-50h]
const char *v27; // [rsp+8h] [rbp-50h]
int v28; // [rsp+10h] [rbp-48h]
const char *v29; // [rsp+10h] [rbp-48h]
const char *v30; // [rsp+18h] [rbp-40h]

v5 = (unsigned int)(*((_DWORD *)a3 + 2) + *((_DWORD *)a1 + 2) + *((_DWORD *)a2 + 2) + 88);
v6 = (char *)shm_malloc(v5);
if ( v6 )
{
v7 = v6;
memset(v6, 0, (int)v5);
*((_DWORD *)v7 + 12) = 0;
v8 = v7 + 88;
if ( *((int *)a1 + 2) > 0 && *a1 )
{
if ( (int)get_debug_level("ims_qos", 7LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v25 = (const char *)*a1;
v28 = *((_DWORD *)a1 + 2);
v30 = (const char *)*((_QWORD *)&log_level_info + 16);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Copying callid [%.*s] into call session data\n",
process_no,
v16,
v30,
"ims_qos [rx_authdata.c:119]: ",
"create_new_callsessiondata",
v28,
v25);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Copying callid [%.*s] into call session data\n",
*((_QWORD *)&log_level_info + 16),
"ims_qos [rx_authdata.c:119]: ",
"create_new_callsessiondata",
*((unsigned int *)a1 + 2),
*a1);
}
--dprint_crit;
}
*(_QWORD *)v7 = v8;
memcpy(v7 + 88, (const void *)*a1, *((int *)a1 + 2));
v9 = *((_DWORD *)a1 + 2);
*((_DWORD *)v7 + 2) = v9;
v8 += v9;
}
if ( *((int *)a2 + 2) > 0 && *a2 )
{
if ( (int)get_debug_level("ims_qos", 7LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v17 = (const char *)*a2;
v26 = *((_DWORD *)a2 + 2);
v29 = (const char *)*((_QWORD *)&log_level_info + 16);
v18 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Copying ftag [%.*s] into call session data\n",
process_no,
v18,
v29,
"ims_qos [rx_authdata.c:126]: ",
"create_new_callsessiondata",
v26,
v17);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Copying ftag [%.*s] into call session data\n",
*((_QWORD *)&log_level_info + 16),
"ims_qos [rx_authdata.c:126]: ",
"create_new_callsessiondata",
*((unsigned int *)a2 + 2),
*a2);
}
--dprint_crit;
}
*((_QWORD *)v7 + 2) = v8;
memcpy(v8, (const void *)*a2, *((int *)a2 + 2));
v10 = *((_DWORD *)a2 + 2);
*((_DWORD *)v7 + 6) = v10;
v8 += v10;
}
if ( *((int *)a3 + 2) > 0 && *a3 )
{
if ( (int)get_debug_level("ims_qos", 7LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v19 = (const char *)*a3;
v20 = *((_DWORD *)a3 + 2);
v27 = (const char *)*((_QWORD *)&log_level_info + 16);
v21 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Copying ttag [%.*s] into call session data\n",
process_no,
v21,
v27,
"ims_qos [rx_authdata.c:133]: ",
"create_new_callsessiondata",
v20,
v19);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Copying ttag [%.*s] into call session data\n",
*((_QWORD *)&log_level_info + 16),
"ims_qos [rx_authdata.c:133]: ",
"create_new_callsessiondata",
*((unsigned int *)a3 + 2),
*a3);
}
--dprint_crit;
}
*((_QWORD *)v7 + 4) = v8;
memcpy(v8, (const void *)*a3, *((int *)a3 + 2));
v11 = *((_DWORD *)a3 + 2);
*((_DWORD *)v7 + 10) = v11;
v8 += v11;
}
if ( v8 == &v7[(int)v5] )
{
*a4 = v7;
result = 1LL;
}
else
{
if ( (int)get_debug_level("ims_qos", 7LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v22 = (const char *)*((_QWORD *)&log_level_info + 8);
v23 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): buffer under/overflow\n",
process_no,
v23,
v22,
"ims_qos [rx_authdata.c:140]: ",
"create_new_callsessiondata");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): buffer under/overflow\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:140]: ",
"create_new_callsessiondata");
}
--dprint_crit;
}
futex_get(mem_lock);
qm_free(shm_block, v7);
futex_release(mem_lock);
result = 0xFFFFFFFFLL;
}
}
else
{
v13 = get_debug_level("ims_qos", 7LL);
result = 0xFFFFFFFFLL;
if ( v13 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shm mem trying to create call_session_data of size %d\n",
process_no,
v15,
v14,
"ims_qos [rx_authdata.c:110]: ",
"create_new_callsessiondata",
v5);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more shm mem trying to create call_session_data of size %d\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:110]: ",
"create_new_callsessiondata",
(unsigned int)v5);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, _QWORD *a2, _QWORD *a3, _QWORD *a4)
{
__int64 v5; // rbx
char *v6; // rax
char *v7; // rbp
char *v8; // r15
int v9; // eax
int v10; // eax
int v11; // eax
__int64 result; // rax
int v13; // er14
const char *v14; // r13
unsigned int v15; // eax
unsigned int v16; // eax
const char *v17; // r14
unsigned int v18; // eax
const char *v19; // r13
int v20; // er14
unsigned int v21; // eax
const char *v22; // r12
unsigned int v23; // eax
const char *v25; // [rsp+8h] [rbp-50h]
int v26; // [rsp+8h] [rbp-50h]
const char *v27; // [rsp+8h] [rbp-50h]
int v28; // [rsp+10h] [rbp-48h]
const char *v29; // [rsp+10h] [rbp-48h]
const char *v30; // [rsp+18h] [rbp-40h]

v5 = (unsigned int)(*((_DWORD *)a3 + 2) + *((_DWORD *)a1 + 2) + *((_DWORD *)a2 + 2) + 88);
v6 = (char *)func4(v5);
if ( v6 )
{
v7 = v6;
memset(v6, 0, (int)v5);
*((_DWORD *)v7 + 12) = 0;
v8 = v7 + 88;
if ( *((int *)a1 + 2) > 0 && *a1 )
{
if ( (int)get_debug_level("ims_qos", 7LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v25 = (const char *)*a1;
v28 = *((_DWORD *)a1 + 2);
v30 = (const char *)*((_QWORD *)&log_level_info + 16);
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Copying callid [%.*s] into call session data\n",
process_no,
v16,
v30,
"ims_qos [rx_authdata.c:119]: ",
"create_new_callsessiondata",
v28,
v25);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Copying callid [%.*s] into call session data\n",
*((_QWORD *)&log_level_info + 16),
"ims_qos [rx_authdata.c:119]: ",
"create_new_callsessiondata",
*((unsigned int *)a1 + 2),
*a1);
}
--dprint_crit;
}
*(_QWORD *)v7 = v8;
memcpy(v7 + 88, (const void *)*a1, *((int *)a1 + 2));
v9 = *((_DWORD *)a1 + 2);
*((_DWORD *)v7 + 2) = v9;
v8 += v9;
}
if ( *((int *)a2 + 2) > 0 && *a2 )
{
if ( (int)get_debug_level("ims_qos", 7LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v17 = (const char *)*a2;
v26 = *((_DWORD *)a2 + 2);
v29 = (const char *)*((_QWORD *)&log_level_info + 16);
v18 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Copying ftag [%.*s] into call session data\n",
process_no,
v18,
v29,
"ims_qos [rx_authdata.c:126]: ",
"create_new_callsessiondata",
v26,
v17);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Copying ftag [%.*s] into call session data\n",
*((_QWORD *)&log_level_info + 16),
"ims_qos [rx_authdata.c:126]: ",
"create_new_callsessiondata",
*((unsigned int *)a2 + 2),
*a2);
}
--dprint_crit;
}
*((_QWORD *)v7 + 2) = v8;
memcpy(v8, (const void *)*a2, *((int *)a2 + 2));
v10 = *((_DWORD *)a2 + 2);
*((_DWORD *)v7 + 6) = v10;
v8 += v10;
}
if ( *((int *)a3 + 2) > 0 && *a3 )
{
if ( (int)get_debug_level("ims_qos", 7LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v19 = (const char *)*a3;
v20 = *((_DWORD *)a3 + 2);
v27 = (const char *)*((_QWORD *)&log_level_info + 16);
v21 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Copying ttag [%.*s] into call session data\n",
process_no,
v21,
v27,
"ims_qos [rx_authdata.c:133]: ",
"create_new_callsessiondata",
v20,
v19);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Copying ttag [%.*s] into call session data\n",
*((_QWORD *)&log_level_info + 16),
"ims_qos [rx_authdata.c:133]: ",
"create_new_callsessiondata",
*((unsigned int *)a3 + 2),
*a3);
}
--dprint_crit;
}
*((_QWORD *)v7 + 4) = v8;
memcpy(v8, (const void *)*a3, *((int *)a3 + 2));
v11 = *((_DWORD *)a3 + 2);
*((_DWORD *)v7 + 10) = v11;
v8 += v11;
}
if ( v8 == &v7[(int)v5] )
{
*a4 = v7;
result = 1LL;
}
else
{
if ( (int)get_debug_level("ims_qos", 7LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v22 = (const char *)*((_QWORD *)&log_level_info + 8);
v23 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): buffer under/overflow\n",
process_no,
v23,
v22,
"ims_qos [rx_authdata.c:140]: ",
"create_new_callsessiondata");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): buffer under/overflow\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:140]: ",
"create_new_callsessiondata");
}
--dprint_crit;
}
func2(mem_lock);
qm_free(shm_block, v7);
func3(mem_lock);
result = 0xFFFFFFFFLL;
}
}
else
{
v13 = get_debug_level("ims_qos", 7LL);
result = 0xFFFFFFFFLL;
if ( v13 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = (const char *)*((_QWORD *)&log_level_info + 8);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shm mem trying to create call_session_data of size %d\n",
process_no,
v15,
v14,
"ims_qos [rx_authdata.c:110]: ",
"create_new_callsessiondata",
v5);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more shm mem trying to create call_session_data of size %d\n",
*((const char **)&log_level_info + 8),
"ims_qos [rx_authdata.c:110]: ",
"create_new_callsessiondata",
(unsigned int)v5);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int create_new_callsessiondata(str* callid, str* ftag, str* ttag, rx_authsessiondata_t** session_data) {
 int len = callid->len + ftag->len + ttag->len + sizeof(rx_authsessiondata_t);
 rx_authsessiondata_t* call_session_data = shm_malloc(len);
 if (!call_session_data){
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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 shm mem trying to create call_session_data of size %d\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); 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 shm mem trying to create call_session_data of size %d\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more shm mem trying to create call_session_data of size %d\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); 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 shm mem trying to create call_session_data of size %d\n", ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more shm mem trying to create call_session_data of size %d\n", ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(call_session_data, 0, len);
 call_session_data->subscribed_to_signaling_path_status = 0;
 char *p = (char*)(call_session_data + 1);
 if (callid && callid->len>0 && callid->s) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "Copying callid [%.*s] into call session data\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Copying callid [%.*s] into call session data\n", (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Copying callid [%.*s] into call session data\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying callid [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying callid [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); } } (dprint_crit--); } } while(0);
  call_session_data->callid.s = p;
  memcpy(call_session_data->callid.s, callid->s, callid->len);
                call_session_data->callid.len = callid->len;
  p+=callid->len;
 }
 if (ftag && ftag->len > 0 && ftag->s) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "Copying ftag [%.*s] into call session data\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Copying ftag [%.*s] into call session data\n", (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Copying ftag [%.*s] into call session data\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ftag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ftag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); } } (dprint_crit--); } } while(0);
  call_session_data->ftag.s = p;
  memcpy(call_session_data->ftag.s, ftag->s, ftag->len);
                call_session_data->ftag.len = ftag->len;
  p += ftag->len;
 }
 if (ttag && ttag->len > 0 && ttag->s) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "Copying ttag [%.*s] into call session data\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Copying ttag [%.*s] into call session data\n", (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Copying ttag [%.*s] into call session data\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ttag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ttag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); } } (dprint_crit--); } } while(0);
  call_session_data->ttag.s = p;
  memcpy(call_session_data->ttag.s, ttag->s, ttag->len);
                call_session_data->ttag.len = ttag->len;
  p += ttag->len;
 }
 if (p != ((char*)(call_session_data) + len)) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "buffer under/overflow\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "buffer under/overflow\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "buffer under/overflow\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "buffer under/overflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "buffer under/overflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (call_session_data)); futex_release(mem_lock); }while(0);
  return -1;
 }
 *session_data = call_session_data;
 return 1;
}

canonical_original_code:
int create_new_callsessiondata(struct _str *callid, struct _str *ftag, struct _str *ttag, struct rx_authsessiondata **session_data) {
 int len = callid->len + ftag->len + ttag->len + sizeof(rx_authsessiondata_t);
 struct rx_authsessiondata *call_session_data = shm_malloc(len);
 if (!call_session_data){
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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 shm mem trying to create call_session_data of size %d\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); 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 shm mem trying to create call_session_data of size %d\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more shm mem trying to create call_session_data of size %d\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); 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 shm mem trying to create call_session_data of size %d\n", ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more shm mem trying to create call_session_data of size %d\n", ("ims_qos" " [" "rx_authdata.c" ":" "110" "]: ") , __func__, len); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(call_session_data, 0, len);
 call_session_data->subscribed_to_signaling_path_status = 0;
 char *p = (char*)(call_session_data + 1);
 if (callid && callid->len>0 && callid->s) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "Copying callid [%.*s] into call session data\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Copying callid [%.*s] into call session data\n", (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Copying callid [%.*s] into call session data\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying callid [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying callid [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "119" "]: ") , __func__, callid->len, callid->s); } } (dprint_crit--); } } while(0);
  call_session_data->callid.s = p;
  memcpy(call_session_data->callid.s, callid->s, callid->len);
                call_session_data->callid.len = callid->len;
  p+=callid->len;
 }
 if (ftag && ftag->len > 0 && ftag->s) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "Copying ftag [%.*s] into call session data\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Copying ftag [%.*s] into call session data\n", (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Copying ftag [%.*s] into call session data\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ftag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ftag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "126" "]: ") , __func__, ftag->len, ftag->s); } } (dprint_crit--); } } while(0);
  call_session_data->ftag.s = p;
  memcpy(call_session_data->ftag.s, ftag->s, ftag->len);
                call_session_data->ftag.len = ftag->len;
  p += ftag->len;
 }
 if (ttag && ttag->len > 0 && ttag->s) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "Copying ttag [%.*s] into call session data\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Copying ttag [%.*s] into call session data\n", (log_level_info[((3)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Copying ttag [%.*s] into call session data\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ttag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Copying ttag [%.*s] into call session data\n", ("ims_qos" " [" "rx_authdata.c" ":" "133" "]: ") , __func__, ttag->len, ttag->s); } } (dprint_crit--); } } while(0);
  call_session_data->ttag.s = p;
  memcpy(call_session_data->ttag.s, ttag->s, ttag->len);
                call_session_data->ttag.len = ttag->len;
  p += ttag->len;
 }
 if (p != ((char *)(call_session_data) + len)) {
  do { if (get_debug_level("ims_qos", (sizeof("ims_qos")-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(): " "buffer under/overflow\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "buffer under/overflow\n", (log_level_info[((-1)) - (-5)].name), ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "buffer under/overflow\n", process_no, my_pid(), ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "buffer under/overflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "buffer under/overflow\n", ("ims_qos" " [" "rx_authdata.c" ":" "140" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (call_session_data)); futex_release(mem_lock); }while(0);
  return -1;
 }
 *session_data = call_session_data;
 return 1;
}

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

variable_types:
ftag
struct _str *

variable_types:
ttag
struct _str *

user_defined_types: struct rx_authsessiondata { struct _str callid; struct _str ftag; struct _str ttag; int subscribed_to_signaling_path_status; struct _str domain; struct _str registration_aor; }


original_code:
int ldap_rfc4515_escape(str *sin, str *sout, int url_encode)
{
 char *src, *dst;
 if (sin == ((void *)0) || sout == ((void *)0) || sin->s == ((void *)0) || sout->s == ((void *)0)
   || sin->len <= 0 || sout->len < 3*sin->len+1)
 {
  return -1;
 }
 src = sin->s;
 dst = sout->s;
 while (src < (sin->s + sin->len))
 {
  switch (*src)
  {
  case '*':
   *dst++ = '\\';
   *dst++ = '2';
   *dst = 'a';
   break;
  case '(':
   *dst++ = '\\';
   *dst++ = '2';
   *dst = '8';
   break;
  case ')':
   *dst++ = '\\';
   *dst++ = '2';
   *dst = '9';
   break;
  case '\\':
   *dst++ = '\\';
   *dst++ = '5';
   *dst = 'c';
   break;
  case '?':
   if (url_encode)
   {
    *dst++ = '%';
    *dst++ = '3';
    *dst = 'F';
   } else
   {
    *dst = *src;
   }
   break;
  default:
   *dst = *src;
  }
  src++;
  dst++;
 }
 *dst = 0;
 sout->len = dst - sout->s;
 return 0;
}

canonical_original_code:
int ldap_rfc4515_escape(struct _str *sin, struct _str *sout, int url_encode)
{
 char *src; char *dst;
 if (sin == ((void *)0) || sout == ((void *)0) || sin->s == ((void *)0) || sout->s == ((void *)0)
   || sin->len <= 0 || sout->len < 3*sin->len+1)
 {
  return -1;
 }
 src = sin->s;
 dst = sout->s;
 while (src < (sin->s + sin->len))
 {
  switch (*src)
  {
  case '*':
   *dst++ = '\\';
   *dst++ = '2';
   *dst = 'a';
   break;
  case '(':
   *dst++ = '\\';
   *dst++ = '2';
   *dst = '8';
   break;
  case ')':
   *dst++ = '\\';
   *dst++ = '2';
   *dst = '9';
   break;
  case '\\':
   *dst++ = '\\';
   *dst++ = '5';
   *dst = 'c';
   break;
  case '?':
   if (url_encode)
   {
    *dst++ = '%';
    *dst++ = '3';
    *dst = 'F';
   } else
   {
    *dst = *src;
   }
   break;
  default:
   *dst = *src;
  }
  src++;
  dst++;
 }
 *dst = 0;
 sout->len = dst - sout->s;
 return 0;
}

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

variable_types:
sout
struct _str *

variable_types:
src
char *

variable_types:
dst
char *


replace

original_code:
int replace(regmatch_t* pmatch, char* string, char* replacement, str* result)
{
 int len, i, j, digit, size;
 len = strlen(replacement);
 j = 0;
 for (i = 0; i < len; i++) {
  if (replacement[i] == '\\') {
   if (i < len - 1) {
    if (((*__ctype_b_loc ())[(int) (((unsigned char)replacement[i+1]))] & (unsigned short int) _ISdigit)) {
     digit = replacement[i+1] - '0';
     if (pmatch[digit].rm_so != -1) {
      size = pmatch[digit].rm_eo - pmatch[digit].rm_so;
      if (j + size < result->len) {
       memcpy(&(result->s[j]), string+pmatch[digit].rm_so, size);
       j = j + size;
      } else {
       return -1;
      }
     } else {
      return -2;
     }
     i = i + 1;
     continue;
    } else {
     i = i + 1;
    }
   } else {
    return -3;
   }
  }
  if (j + 1 < result->len) {
   result->s[j] = replacement[i];
   j = j + 1;
  } else {
   return -4;
  }
 }
 result->len = j;
 return 1;
}

canonical_original_code:
int replace(struct regmatch_t *pmatch, char *string, char *replacement, struct _str *result)
{
 int len; int i; int j; int digit; int size;
 len = strlen(replacement);
 j = 0;
 for (i = 0; i < len; i++) {
  if (replacement[i] == '\\') {
   if (i < len - 1) {
    if (((*__ctype_b_loc ())[(int) (((unsigned char)replacement[i+1]))] & (unsigned short) _ISdigit)) {
     digit = replacement[i+1] - '0';
     if (pmatch[digit].rm_so != -1) {
      size = pmatch[digit].rm_eo - pmatch[digit].rm_so;
      if (j + size < result->len) {
       memcpy(&(result->s[j]), string+pmatch[digit].rm_so, size);
       j = j + size;
      } else {
       return -1;
      }
     } else {
      return -2;
     }
     i = i + 1;
     continue;
    } else {
     i = i + 1;
    }
   } else {
    return -3;
   }
  }
  if (j + 1 < result->len) {
   result->s[j] = replacement[i];
   j = j + 1;
  } else {
   return -4;
  }
 }
 result->len = j;
 return 1;
}

variable_types: struct regmatch_t { int rm_so; int rm_eo; } *

variable_types:
string
char *

variable_types:
replacement
char *

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

variable_types: j int

variable_types: digit int

variable_types: size int


decompiled_code:
__int64 __fastcall reg_replace(char *pattern, const char *a2, char *a3, __int64 a4)
{
__int64 result; // rax
const char *v7; // r14
unsigned int v8; // eax
regmatch_t v9[11]; // [rsp+0h] [rbp-58h] BYREF

if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): pattern: '%s', replacement: '%s', string: '%s'\n",
process_no,
v8,
v7,
"<core> [regexp.c:113]: ",
"reg_replace",
pattern,
a2,
a3);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): pattern: '%s', replacement: '%s', string: '%s'\n",
*((const char **)&log_level_info + 16),
"<core> [regexp.c:113]: ",
"reg_replace",
pattern,
a2,
a3);
}
--dprint_crit;
}
if ( (unsigned int)reg_match(pattern, a3, v9) )
result = 0xFFFFFFFFLL;
else
result = replace((__int64)v9, (__int64)a3, a2, a4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *pattern, const char *a2, char *a3, __int64 a4)
{
__int64 result; // rax
const char *v7; // r14
unsigned int v8; // eax
regmatch_t v9[11]; // [rsp+0h] [rbp-58h] BYREF

if ( (int)get_debug_level("core", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v7 = (const char *)*((_QWORD *)&log_level_info + 16);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): pattern: '%s', replacement: '%s', string: '%s'\n",
process_no,
v8,
v7,
"<core> [regexp.c:113]: ",
"reg_replace",
pattern,
a2,
a3);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): pattern: '%s', replacement: '%s', string: '%s'\n",
*((const char **)&log_level_info + 16),
"<core> [regexp.c:113]: ",
"reg_replace",
pattern,
a2,
a3);
}
--dprint_crit;
}
if ( (unsigned int)func1(pattern, a3, v9) )
result = 0xFFFFFFFFLL;
else
result = func0((__int64)v9, (__int64)a3, a2, a4);
return result;
}

original_code:
int reg_replace(char *pattern, char *replacement, char *string, str *result)
{
 regmatch_t pmatch[6];
 do { if (get_debug_level("core", (sizeof("core")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "pattern: '%s', replacement: '%s', string: '%s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); 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(): " "pattern: '%s', replacement: '%s', string: '%s'\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "pattern: '%s', replacement: '%s', string: '%s'\n", process_no, my_pid(), ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); 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(): " "pattern: '%s', replacement: '%s', string: '%s'\n", ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "pattern: '%s', replacement: '%s', string: '%s'\n", ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); } } (dprint_crit--); } } while(0);
 if (reg_match(pattern, string, &(pmatch[0]))) {
  return -1;
 }
 return replace(&pmatch[0], string, replacement, result);
}

canonical_original_code:
int reg_replace(char *pattern, char *replacement, char *string, struct _str *result)
{
 struct regmatch_t pmatch[6];
 do { if (get_debug_level("core", (sizeof("core")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "pattern: '%s', replacement: '%s', string: '%s'\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); 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(): " "pattern: '%s', replacement: '%s', string: '%s'\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "pattern: '%s', replacement: '%s', string: '%s'\n", process_no, my_pid(), ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); 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(): " "pattern: '%s', replacement: '%s', string: '%s'\n", ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "pattern: '%s', replacement: '%s', string: '%s'\n", ("<core> [" "regexp.c" ":" "113" "]: ") , __func__, pattern, replacement, string); } } (dprint_crit--); } } while(0);
 if (reg_match(pattern, string, &(pmatch[0]))) {
  return -1;
 }
 return replace(&pmatch[0], string, replacement, result);
}

variable_types:
pattern
char *

variable_types: struct regmatch_t { int rm_so; int rm_eo; } [6]


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 parse_priv_value(char *s1, unsigned int a2, _DWORD *a3)
{
int v5; // edx
__int64 result; // rax
const char *v7; // rbp
unsigned int v8; // eax
int v9; // ecx
int v10; // er11
char v11; // cl
int v12; // er9
int v13; // er8
int v14; // edi

if ( s1 && a3 )
{
switch ( *s1 )
{
case 'C':
case 'c':
result = 0LL;
if ( a2 > 7 )
{
v9 = strncasecmp(s1, "critical", 8uLL);
result = 0LL;
if ( !v9 )
{
*a3 = 16;
result = 8LL;
goto LABEL_25;
}
}
break;
case 'H':
case 'h':
result = 0LL;
if ( a2 > 5 )
{
if ( !strncasecmp(s1, "header", 6uLL) )
{
*a3 = 2;
result = 6LL;
goto LABEL_25;
}
result = 0LL;
if ( a2 > 6 )
{
v10 = strncasecmp(s1, "history", 7uLL);
result = 0LL;
if ( !v10 )
{
*a3 = 64;
result = 7LL;
goto LABEL_25;
}
}
}
break;
case 'I':
case 'i':
result = 0LL;
if ( a2 > 1 && (s1[1] & 0xDF) == 68 )
{
*a3 = 32;
result = 2LL;
goto LABEL_25;
}
break;
case 'N':
case 'n':
result = 0LL;
if ( a2 > 3 )
{
v12 = strncasecmp(s1, "none", 4uLL);
result = 0LL;
if ( !v12 )
{
*a3 = 8;
result = 4LL;
goto LABEL_25;
}
}
break;
case 'S':
case 's':
result = 0LL;
if ( a2 > 6 )
{
v13 = strncasecmp(s1, "session", 7uLL);
result = 0LL;
if ( !v13 )
{
*a3 = 4;
result = 7LL;
goto LABEL_25;
}
}
break;
case 'U':
case 'u':
result = 0LL;
if ( a2 > 3 )
{
v14 = strncasecmp(s1, "user", 4uLL);
result = 0LL;
if ( !v14 )
{
*a3 = 1;
result = 4LL;
LABEL_25:
if ( a2 > (unsigned int)result )
{
v11 = s1[(unsigned int)result];
if ( (unsigned __int8)v11 > 0x3Bu )
{
result = 0LL;
}
else if ( ((0x800000100002601uLL >> v11) & 1) == 0 )
{
result = 0LL;
}
}
}
}
break;
default:
result = 0LL;
break;
}
}
else
{
v5 = get_debug_level("core", 4LL);
result = 0LL;
if ( v5 >= -1 )
{
result = 0LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid parameter value\n",
process_no,
v8,
v7,
"<core> [parse_privacy.c:51]: ",
"parse_priv_value");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parse_privacy.c:51]: ",
"parse_priv_value");
}
--dprint_crit;
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1, unsigned int a2, _DWORD *a3)
{
int v5; // edx
__int64 result; // rax
const char *v7; // rbp
unsigned int v8; // eax
int v9; // ecx
int v10; // er11
char v11; // cl
int v12; // er9
int v13; // er8
int v14; // edi

if ( s1 && a3 )
{
switch ( *s1 )
{
case 'C':
case 'c':
result = 0LL;
if ( a2 > 7 )
{
v9 = strncasecmp(s1, "critical", 8uLL);
result = 0LL;
if ( !v9 )
{
*a3 = 16;
result = 8LL;
goto LABEL_25;
}
}
break;
case 'H':
case 'h':
result = 0LL;
if ( a2 > 5 )
{
if ( !strncasecmp(s1, "header", 6uLL) )
{
*a3 = 2;
result = 6LL;
goto LABEL_25;
}
result = 0LL;
if ( a2 > 6 )
{
v10 = strncasecmp(s1, "history", 7uLL);
result = 0LL;
if ( !v10 )
{
*a3 = 64;
result = 7LL;
goto LABEL_25;
}
}
}
break;
case 'I':
case 'i':
result = 0LL;
if ( a2 > 1 && (s1[1] & 0xDF) == 68 )
{
*a3 = 32;
result = 2LL;
goto LABEL_25;
}
break;
case 'N':
case 'n':
result = 0LL;
if ( a2 > 3 )
{
v12 = strncasecmp(s1, "none", 4uLL);
result = 0LL;
if ( !v12 )
{
*a3 = 8;
result = 4LL;
goto LABEL_25;
}
}
break;
case 'S':
case 's':
result = 0LL;
if ( a2 > 6 )
{
v13 = strncasecmp(s1, "session", 7uLL);
result = 0LL;
if ( !v13 )
{
*a3 = 4;
result = 7LL;
goto LABEL_25;
}
}
break;
case 'U':
case 'u':
result = 0LL;
if ( a2 > 3 )
{
v14 = strncasecmp(s1, "user", 4uLL);
result = 0LL;
if ( !v14 )
{
*a3 = 1;
result = 4LL;
LABEL_25:
if ( a2 > (unsigned int)result )
{
v11 = s1[(unsigned int)result];
if ( (unsigned __int8)v11 > 0x3Bu )
{
result = 0LL;
}
else if ( ((0x800000100002601uLL >> v11) & 1) == 0 )
{
result = 0LL;
}
}
}
}
break;
default:
result = 0LL;
break;
}
}
else
{
v5 = get_debug_level("core", 4LL);
result = 0LL;
if ( v5 >= -1 )
{
result = 0LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v7 = (const char *)*((_QWORD *)&log_level_info + 8);
v8 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): invalid parameter value\n",
process_no,
v8,
v7,
"<core> [parse_privacy.c:51]: ",
"parse_priv_value");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parse_privacy.c:51]: ",
"parse_priv_value");
}
--dprint_crit;
result = 0LL;
}
}
}
return result;
}

original_code:
unsigned int parse_priv_value(char* start, unsigned int max_len,
         unsigned int* value)
{
    unsigned int len;
    if (!start || !value) {
 do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_privacy.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(): " "invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_privacy.c" ":" "51" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid parameter value\n", process_no, my_pid(), ("<core> [" "parse_privacy.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(): " "invalid parameter value\n", ("<core> [" "parse_privacy.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(): " "invalid parameter value\n", ("<core> [" "parse_privacy.c" ":" "51" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
    }
    switch (start[0]) {
    case 'c':
    case 'C':
 if(max_len < 8)
     return 0;
 if (strncasecmp(start, "critical", 8) == 0) {
     *value = PRIVACY_CRITICAL;
     len = 8;
     break;
 } else {
     return 0;
 }
    case 'h':
    case 'H':
 if (max_len < 6)
     return 0;
 if (strncasecmp(start, "header", 6) == 0) {
     *value = PRIVACY_HEADER;
     len = 6;
     break;
 }
 if (max_len < 7)
     return 0;
 if (strncasecmp(start, "history", 7) == 0) {
     *value = PRIVACY_HISTORY;
     len = 7;
     break;
 } else {
     return 0;
 }
    case 'i':
    case 'I':
 if(max_len < 2)
     return 0;
 if (start[1] == 'd' || start[1] == 'D') {
     *value = PRIVACY_ID;
     len = 2;
     break;
 } else {
     return 0;
 }
    case 'n':
    case 'N':
 if(max_len < 4)
     return 0;
 if (strncasecmp(start, "none", 4) == 0) {
     *value = PRIVACY_NONE;
     len = 4;
     break;
 } else {
     return 0;
 }
    case 's':
    case 'S':
 if(max_len < 7)
     return 0;
 if (strncasecmp(start, "session", 7) == 0) {
     *value = PRIVACY_SESSION;
     len = 7;
     break;
 } else {
     return 0;
 }
    case 'u':
    case 'U':
 if(max_len < 4)
     return 0;
 if (strncasecmp(start, "user", 4) == 0) {
     *value = PRIVACY_USER;
     len = 4;
     break;
 } else {
     return 0;
 }
    default:
 return 0;
    }
    if(len < max_len) {
 if(start[len] != '\0' && start[len] != ';' && start[len] != ' '
    && start[len] != '\t' && start[len] != '\r' && start[len] != '\n')
     return 0;
    }
    return len;
}

canonical_original_code:
unsigned int parse_priv_value(char *start, unsigned int max_len, unsigned int *value)
{
    unsigned int len;
    if (!start || !value) {
 do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_privacy.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(): " "invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parse_privacy.c" ":" "51" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid parameter value\n", process_no, my_pid(), ("<core> [" "parse_privacy.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(): " "invalid parameter value\n", ("<core> [" "parse_privacy.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(): " "invalid parameter value\n", ("<core> [" "parse_privacy.c" ":" "51" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
    }
    switch (start[0]) {
    case 'c':
    case 'C':
 if(max_len < 8)
     return 0;
 if (strncasecmp(start, "critical", 8) == 0) {
     *value = PRIVACY_CRITICAL;
     len = 8;
     break;
 } else {
     return 0;
 }
    case 'h':
    case 'H':
 if (max_len < 6)
     return 0;
 if (strncasecmp(start, "header", 6) == 0) {
     *value = PRIVACY_HEADER;
     len = 6;
     break;
 }
 if (max_len < 7)
     return 0;
 if (strncasecmp(start, "history", 7) == 0) {
     *value = PRIVACY_HISTORY;
     len = 7;
     break;
 } else {
     return 0;
 }
    case 'i':
    case 'I':
 if(max_len < 2)
     return 0;
 if (start[1] == 'd' || start[1] == 'D') {
     *value = PRIVACY_ID;
     len = 2;
     break;
 } else {
     return 0;
 }
    case 'n':
    case 'N':
 if(max_len < 4)
     return 0;
 if (strncasecmp(start, "none", 4) == 0) {
     *value = PRIVACY_NONE;
     len = 4;
     break;
 } else {
     return 0;
 }
    case 's':
    case 'S':
 if(max_len < 7)
     return 0;
 if (strncasecmp(start, "session", 7) == 0) {
     *value = PRIVACY_SESSION;
     len = 7;
     break;
 } else {
     return 0;
 }
    case 'u':
    case 'U':
 if(max_len < 4)
     return 0;
 if (strncasecmp(start, "user", 4) == 0) {
     *value = PRIVACY_USER;
     len = 4;
     break;
 } else {
     return 0;
 }
    default:
 return 0;
    }
    if(len < max_len) {
 if(start[len] != '\0' && start[len] != ';' && start[len] != ' '
    && start[len] != '\t' && start[len] != '\r' && start[len] != '\n')
     return 0;
    }
    return len;
}

variable_types:
start
char *

variable_types:
value
unsigned int *

variable_types:
len
unsigned int

return_type: unsigned int


decompiled_code:
__int64 init_ulcb_list()
{
_QWORD *v0; // rax
__int64 result; // rax
int v2; // ebx
const char *v3; // rbx
unsigned int v4; // eax

v0 = (_QWORD *)shm_malloc(0x10u);
ulcb_list = v0;
if ( v0 )
{
*v0 = 0LL;
*(_DWORD *)(ulcb_list + 8LL) = 0;
result = 1LL;
}
else
{
v2 = get_debug_level("usrloc", 6LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -3 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 4);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shared mem\n",
process_no,
v4,
v3,
"usrloc [ul_callback.c:52]: ",
"init_ulcb_list");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more shared mem\n",
*((const char **)&log_level_info + 4),
"usrloc [ul_callback.c:52]: ",
"init_ulcb_list");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
_QWORD *v0; // rax
__int64 result; // rax
int v2; // ebx
const char *v3; // rbx
unsigned int v4; // eax

v0 = (_QWORD *)func4(0x10u);
ulcb_list = v0;
if ( v0 )
{
*v0 = 0LL;
*(_DWORD *)(ulcb_list + 8LL) = 0;
result = 1LL;
}
else
{
v2 = get_debug_level("usrloc", 6LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -3 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967293LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 4);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shared mem\n",
process_no,
v4,
v3,
"usrloc [ul_callback.c:52]: ",
"init_ulcb_list");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 10) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): no more shared mem\n",
*((const char **)&log_level_info + 4),
"usrloc [ul_callback.c:52]: ",
"init_ulcb_list");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int init_ulcb_list(void)
{
 ulcb_list = (struct ulcb_head_list*)shm_malloc
  ( sizeof(struct ulcb_head_list) );
 if (ulcb_list==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(): " "no more shared mem\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "no more shared mem\n", (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more shared mem\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more shared mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more shared mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 ulcb_list->first = 0;
 ulcb_list->reg_types = 0;
 return 1;
}

canonical_original_code:
int init_ulcb_list()
{
 ulcb_list = (struct ulcb_head_list *)shm_malloc
  ( sizeof(struct ulcb_head_list) );
 if (ulcb_list==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(): " "no more shared mem\n", process_no, my_pid(), (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "no more shared mem\n", (log_level_info[((-3)) - (-5)].name), ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "no more shared mem\n", process_no, my_pid(), ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more shared mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "no more shared mem\n", ("p_usrloc" " [" "ul_callback.c" ":" "52" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 ulcb_list->first = 0;
 ulcb_list->reg_types = 0;
 return 1;
}

user_defined_types: struct ulcb_head_list { struct ul_callback *first; int reg_types; }

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

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: enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 }

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

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

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

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

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 { unsigned short sa_family; char sa_data[14]; }

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

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

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }

user_defined_types: struct _sr_data { void *p; void (*pfree)(void *d, void (*sfree)(void *d)); }