original_code:
int netstring_read(char *buffer, size_t buffer_length,
     char **netstring_start, size_t *netstring_length) {
  int i;
  size_t len = 0;
  *netstring_start = ((void *)0); *netstring_length = 0;
  if (buffer_length < 3) return -3;
  if (buffer[0] == '0' && ((*__ctype_b_loc ())[(int) ((buffer[1]))] & (unsigned short int) _ISdigit))
    return -5;
  if (!((*__ctype_b_loc ())[(int) ((buffer[0]))] & (unsigned short int) _ISdigit)) return -6;
  for (i = 0; i < buffer_length && ((*__ctype_b_loc ())[(int) ((buffer[i]))] & (unsigned short int) _ISdigit); i++) {
    if (i >= 9) return -1;
    len = len*10 + (buffer[i] - '0');
  }
  if (i + len + 1 >= buffer_length) return -3;
  if (buffer[i++] != ':') return -2;
  if (buffer[i + len] != ',') return -4;
  *netstring_start = &buffer[i]; *netstring_length = len;
  return 0;
}

canonical_original_code:
int netstring_read(char *buffer, unsigned long buffer_length, char **netstring_start, unsigned long *netstring_length) {
  int i;
  unsigned long len = 0;
  *netstring_start = ((void *)0); *netstring_length = 0;
  if (buffer_length < 3) return -3;
  if (buffer[0] == '0' && ((*__ctype_b_loc ())[(int) ((buffer[1]))] & (unsigned short) _ISdigit))
    return -5;
  if (!((*__ctype_b_loc ())[(int) ((buffer[0]))] & (unsigned short) _ISdigit)) return -6;
  for (i = 0; i < buffer_length && ((*__ctype_b_loc ())[(int) ((buffer[i]))] & (unsigned short) _ISdigit); i++) {
    if (i >= 9) return -1;
    len = len*10 + (buffer[i] - '0');
  }
  if (i + len + 1 >= buffer_length) return -3;
  if (buffer[i++] != ':') return -2;
  if (buffer[i + len] != ',') return -4;
  *netstring_start = &buffer[i]; *netstring_length = len;
  return 0;
}

variable_types:
buffer
char *


repo: virtualolson/who

original_code:
size_t netstring_buffer_size(size_t data_length) {
  if (data_length == 0) return 3;
  return (size_t)ceil(log10((double)data_length + 1)) + data_length + 2;
}

canonical_original_code:
unsigned long netstring_buffer_size(unsigned long data_length) {
  if (data_length == 0) return 3;
  return (unsigned long)ceil(log10((double)data_length + 1)) + data_length + 2;
}

return_type: unsigned long


decompiled_code:
__int64 __fastcall netstring_encode_new(__int64 *a1, const void *a2, size_t a3)
{
__int64 v4; // rax
__int64 v5; // rbx
unsigned __int64 v6; // r15
double v8; // xmm0_8
double v9; // xmm0_8
__m128d v10; // xmm6
__m128d v11; // xmm5
char *v12; // rax
const char *v13; // r15
unsigned int v14; // eax
const char *v15; // r9
__int64 v16; // rcx
struct _IO_FILE *v17; // rdi
unsigned int v18; // eax

if ( a3 )
{
if ( (a3 & 0x8000000000000000LL) != 0LL )
v8 = (double)(int)(a3 & 1 | (a3 >> 1)) + (double)(int)(a3 & 1 | (a3 >> 1));
else
v8 = (double)(int)a3;
v9 = log10(v8 + 1.0);
if ( COERCE_DOUBLE(*(_QWORD *)&v9 & LC6) < 4.503599627370496e15 )
{
v10.m128d_f64[0] = v9;
v11.m128d_f64[0] = (double)(int)v9;
*(_QWORD *)&v9 = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v10, v11) & LC4) + v11.m128d_f64[0]) | ~LC6 & *(_QWORD *)&v9;
}
if ( v9 >= 9.223372036854776e18 )
v6 = (unsigned int)(int)(v9 - 9.223372036854776e18) ^ 0x8000000000000000LL;
else
v6 = (unsigned int)(int)v9;
v12 = (char *)qm_malloc(mem_block, v6 + a3 + 2);
v5 = (__int64)v12;
if ( v12 )
{
sprintf(v12, "%lu:", a3);
memcpy((void *)(v5 + v6 + 1), a2, a3);
*(_BYTE *)(v5 + v6 + a3 + 1) = 44;
goto LABEL_4;
}
if ( (int)get_debug_level("jsonrpc-c", 9LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Out of memory!",
*((const char **)&log_level_info + 8),
"jsonrpc-c [netstring.c:187]: ",
"netstring_encode_new");
LABEL_23:
--dprint_crit;
return 0LL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
v15 = "jsonrpc-c [netstring.c:187]: ";
v16 = v14;
LABEL_28:
v17 = stderr;
fprintf(stderr, "%2d(%d) %s: %s%s(): Out of memory!", process_no, v16, v13, v15, "netstring_encode_new");
if ( log_color )
dprint_color_reset(v17, "%2d(%d) %s: %s%s(): Out of memory!");
goto LABEL_23;
}
}
else
{
v4 = qm_malloc(mem_block, 3LL);
v5 = v4;
if ( v4 )
{
*(_BYTE *)(v4 + 2) = 44;
v6 = 1LL;
*(_WORD *)v4 = 14896;
LABEL_4:
*a1 = v5;
return v6 + a3 + 2;
}
if ( (int)get_debug_level("jsonrpc-c", 9LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Out of memory!",
*((const char **)&log_level_info + 8),
"jsonrpc-c [netstring.c:177]: ",
"netstring_encode_new");
goto LABEL_23;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v18 = my_pid();
v15 = "jsonrpc-c [netstring.c:177]: ";
v16 = v18;
goto LABEL_28;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, const void *a2, size_t a3)
{
__int64 v4; // rax
__int64 v5; // rbx
unsigned __int64 v6; // r15
double v8; // xmm0_8
double v9; // xmm0_8
__m128d v10; // xmm6
__m128d v11; // xmm5
char *v12; // rax
const char *v13; // r15
unsigned int v14; // eax
const char *v15; // r9
__int64 v16; // rcx
struct _IO_FILE *v17; // rdi
unsigned int v18; // eax

if ( a3 )
{
if ( (a3 & 0x8000000000000000LL) != 0LL )
v8 = (double)(int)(a3 & 1 | (a3 >> 1)) + (double)(int)(a3 & 1 | (a3 >> 1));
else
v8 = (double)(int)a3;
v9 = log10(v8 + 1.0);
if ( COERCE_DOUBLE(*(_QWORD *)&v9 & LC6) < 4.503599627370496e15 )
{
v10.m128d_f64[0] = v9;
v11.m128d_f64[0] = (double)(int)v9;
*(_QWORD *)&v9 = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v10, v11) & LC4) + v11.m128d_f64[0]) | ~LC6 & *(_QWORD *)&v9;
}
if ( v9 >= 9.223372036854776e18 )
v6 = (unsigned int)(int)(v9 - 9.223372036854776e18) ^ 0x8000000000000000LL;
else
v6 = (unsigned int)(int)v9;
v12 = (char *)qm_malloc(mem_block, v6 + a3 + 2);
v5 = (__int64)v12;
if ( v12 )
{
sprintf(v12, "%lu:", a3);
memcpy((void *)(v5 + v6 + 1), a2, a3);
*(_BYTE *)(v5 + v6 + a3 + 1) = 44;
goto LABEL_4;
}
if ( (int)get_debug_level("jsonrpc-c", 9LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Out of memory!",
*((const char **)&log_level_info + 8),
"jsonrpc-c [netstring.c:187]: ",
"netstring_encode_new");
LABEL_23:
--dprint_crit;
return 0LL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
v15 = "jsonrpc-c [netstring.c:187]: ";
v16 = v14;
LABEL_28:
v17 = stderr;
fprintf(stderr, "%2d(%d) %s: %s%s(): Out of memory!", process_no, v16, v13, v15, "netstring_encode_new");
if ( log_color )
dprint_color_reset(v17, "%2d(%d) %s: %s%s(): Out of memory!");
goto LABEL_23;
}
}
else
{
v4 = qm_malloc(mem_block, 3LL);
v5 = v4;
if ( v4 )
{
*(_BYTE *)(v4 + 2) = 44;
v6 = 1LL;
*(_WORD *)v4 = 14896;
LABEL_4:
*a1 = v5;
return v6 + a3 + 2;
}
if ( (int)get_debug_level("jsonrpc-c", 9LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Out of memory!",
*((const char **)&log_level_info + 8),
"jsonrpc-c [netstring.c:177]: ",
"netstring_encode_new");
goto LABEL_23;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v13 = (const char *)*((_QWORD *)&log_level_info + 8);
v18 = my_pid();
v15 = "jsonrpc-c [netstring.c:177]: ";
v16 = v18;
goto LABEL_28;
}
}
return 0LL;
}

original_code:
size_t netstring_encode_new(char **netstring, char *data, size_t len) {
  char *ns;
  size_t num_len = 1;
  if (len == 0) {
    ns = qm_malloc(mem_block, (3));
 if (!ns) {
  do { if (get_debug_level("jsonrpc-c", (sizeof("jsonrpc-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Out of memory!", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __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(): " "Out of memory!", (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Out of memory!", process_no, my_pid(), ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __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(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
    ns[0] = '0';
    ns[1] = ':';
    ns[2] = ',';
  } else {
    num_len = (size_t)ceil(log10((double)len + 1));
    ns = qm_malloc(mem_block, (num_len + len + 2));
 if (!ns) {
  do { if (get_debug_level("jsonrpc-c", (sizeof("jsonrpc-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Out of memory!", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __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(): " "Out of memory!", (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Out of memory!", process_no, my_pid(), ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __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(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
    sprintf(ns, "%lu:", (unsigned long)len);
    memcpy(ns + num_len + 1, data, len);
    ns[num_len + len + 1] = ',';
  }
  *netstring = ns;
  return num_len + len + 2;
}

canonical_original_code:
unsigned long netstring_encode_new(char **netstring, char *data, unsigned long len) {
  char *ns;
  unsigned long num_len = 1;
  if (len == 0) {
    ns = qm_malloc(mem_block, (3));
 if (!ns) {
  do { if (get_debug_level("jsonrpc-c", (sizeof("jsonrpc-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Out of memory!", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __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(): " "Out of memory!", (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Out of memory!", process_no, my_pid(), ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __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(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "177" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
    ns[0] = '0';
    ns[1] = ':';
    ns[2] = ',';
  } else {
    num_len = (unsigned long)ceil(log10((double)len + 1));
    ns = qm_malloc(mem_block, (num_len + len + 2));
 if (!ns) {
  do { if (get_debug_level("jsonrpc-c", (sizeof("jsonrpc-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Out of memory!", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __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(): " "Out of memory!", (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Out of memory!", process_no, my_pid(), ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __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(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "187" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
    sprintf(ns, "%lu:", (unsigned long)len);
    memcpy(ns + num_len + 1, data, len);
    ns[num_len + len + 1] = ',';
  }
  *netstring = ns;
  return num_len + len + 2;
}

variable_types:
netstring
char **

variable_types:
data
char *

variable_types:
len
unsigned long

variable_types:
ns
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 stderr_println(const char *a1)
{
fprintf(stderr, "%s\n", a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
fprintf(stderr, "%s\n", a1);
return 0LL;
}

original_code:
int stderr_println(char* text)
{
 fprintf(stderr, "%s\n", text);
 return 0;
}

canonical_original_code:
int stderr_println(char *text)
{
 fprintf(stderr, "%s\n", text);
 return 0;
}

variable_types:
text
char *

return_type: int


decompiled_code:
// attributes: thunk
__int64 MD5Update()
{
return U_MD5Update();
}

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

original_code:
static inline void MD5Update(MD5_CTX *ctx, const char *str, size_t len) {
 U_MD5Update(ctx, (const unsigned char *)str, len);
}

canonical_original_code:
static inline void MD5Update(struct MD5Context *ctx, char *str, unsigned long len) {
 U_MD5Update(ctx, (unsigned char *)str, len);
}

variable_types: struct MD5Context { unsigned int state[4]; unsigned int count; unsigned char buffer[64]; } *

variable_types:
str
char *

return_type: void


decompiled_code:
int __fastcall MD5StringArray(_BYTE *a1, __int64 a2, int a3)
{
__int64 v3; // r12
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // r13
int v9; // edx
_BYTE *v10; // rsi
__int64 v11; // rax
int v12; // edx
unsigned __int64 v13; // rcx
int v14; // edx
int v15; // er8
char v16; // cl
_BYTE *v17; // rax
int v18; // er11
char v19; // di
char v20; // r9
char v21; // r8
char v22; // r10
char v23; // cl
char v24; // di
int result; // eax
__int64 v26; // r8
unsigned __int64 v27; // r9
unsigned __int64 v28; // r10
unsigned __int64 v29; // r11
__int64 v30; // rax
unsigned __int64 v31; // rax
unsigned __int64 v32; // rcx
unsigned __int64 v33; // rdi
unsigned __int64 v34; // r9
unsigned __int64 v35; // rdi
unsigned __int64 v36; // rdi
unsigned __int64 v37; // r8
unsigned __int64 v38; // r9
unsigned __int64 v39; // r10
unsigned __int64 v40; // r11
unsigned __int64 v41; // rcx
const char *v42; // r12
unsigned int v43; // eax
int v44; // [rsp-10h] [rbp-A8h]
_BYTE v45[16]; // [rsp+0h] [rbp-98h] BYREF
char v46[136]; // [rsp+10h] [rbp-88h] BYREF

v3 = a2;
MD5Init(v46);
if ( a3 > 0 )
{
v6 = (unsigned int)(a3 - 1);
v7 = 0x100002601LL;
v8 = a2 + 16 * v6 + 16;
while ( 1 )
{
v9 = *(_DWORD *)(v3 + 8);
if ( !v9 )
goto LABEL_58;
v10 = *(_BYTE **)v3;
v11 = v9;
v12 = *(_DWORD *)(v3 + 8) & 7;
if ( !v12 )
break;
if ( v12 == 1 )
{
LABEL_100:
v41 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v41 > 0x20u || !_bittest64(&v7, v41) )
goto LABEL_12;
if ( (_DWORD)--v11 )
break;
v3 += 16LL;
if ( v8 == v3 )
goto LABEL_59;
}
else
{
if ( v12 != 2 )
{
if ( v12 != 3 )
{
if ( v12 != 4 )
{
if ( v12 != 5 )
{
if ( v12 != 6 )
{
v13 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v13 > 0x20u || !_bittest64(&v7, v13) )
goto LABEL_12;
--v11;
}
v36 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v36 > 0x20u || !_bittest64(&v7, v36) )
goto LABEL_12;
--v11;
}
v37 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v37 > 0x20u || !_bittest64(&v7, v37) )
goto LABEL_12;
--v11;
}
v38 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v38 > 0x20u || !_bittest64(&v7, v38) )
goto LABEL_12;
--v11;
}
v39 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v39 > 0x20u || !_bittest64(&v7, v39) )
goto LABEL_12;
--v11;
}
v40 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v40 <= 0x20u && _bittest64(&v7, v40) )
{
--v11;
goto LABEL_100;
}
if ( !v14 )
goto LABEL_58;
LABEL_12:
v15 = v14 & 7;
if ( (v14 & 7) == 0 )
goto LABEL_41;
if ( v15 != 1 )
{
if ( v15 != 2 )
{
if ( v15 != 3 )
{
if ( v15 != 4 )
{
if ( v15 != 5 )
{
if ( v15 != 6 )
{
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
++v10;
if ( --v14 )
{
LABEL_41:
while ( *v10 == 32 || *v10 == 9 )
{
v16 = v10[1];
v17 = v10 + 1;
v18 = --v14;
++v10;
if ( v16 != 32 && v16 != 9 )
break;
v19 = v17[1];
v14 = v18 - 1;
v10 = v17 + 1;
if ( v19 != 32 && v19 != 9 )
break;
v20 = v17[2];
v14 = v18 - 2;
v10 = v17 + 2;
if ( v20 != 32 && v20 != 9 )
break;
v21 = v17[3];
v14 = v18 - 3;
v10 = v17 + 3;
if ( v21 != 32 && v21 != 9 )
break;
v22 = v17[4];
v14 = v18 - 4;
v10 = v17 + 4;
if ( v22 != 32 && v22 != 9 )
break;
v23 = v17[5];
v14 = v18 - 5;
v10 = v17 + 5;
if ( v23 != 32 && v23 != 9 )
break;
v24 = v17[6];
v14 = v18 - 6;
v10 = v17 + 6;
if ( v24 != 32 && v24 != 9 )
break;
v10 = v17 + 7;
v14 = v18 - 7;
if ( v18 == 7 )
goto LABEL_58;
}
LABEL_105:
if ( v14 <= 0 )
goto LABEL_58;
v3 += 16LL;
MD5Update(v46, v10, v14);
if ( v8 == v3 )
goto LABEL_59;
}
else
{
LABEL_58:
v3 += 16LL;
if ( v8 == v3 )
goto LABEL_59;
}
}
}
while ( 1 )
{
v35 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v35 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v35) )
goto LABEL_12;
v26 = v11 - 1;
v27 = (unsigned __int8)v10[v11 - 2];
v14 = v11 - 1;
if ( (unsigned __int8)v27 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v27) )
goto LABEL_12;
v28 = (unsigned __int8)v10[v11 - 3];
v14 = v11 - 2;
if ( (unsigned __int8)v28 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v28) )
goto LABEL_12;
v29 = (unsigned __int8)v10[v11 - 4];
v14 = v11 - 3;
if ( (unsigned __int8)v29 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v29) )
goto LABEL_12;
v30 = v11 - 4;
v14 = v30;
v31 = (unsigned __int8)v10[v30 - 1];
if ( (unsigned __int8)v31 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v31) )
goto LABEL_12;
v32 = (unsigned __int8)v10[v26 - 5];
v14 = v26 - 4;
if ( (unsigned __int8)v32 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v32) )
goto LABEL_12;
v33 = (unsigned __int8)v10[v26 - 6];
v14 = v26 - 5;
if ( (unsigned __int8)v33 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v33) )
goto LABEL_12;
v34 = (unsigned __int8)v10[v26 - 7];
v14 = v26 - 6;
if ( (unsigned __int8)v34 > 0x20u || !_bittest64(&v7, v34) )
goto LABEL_12;
v11 = v26 - 7;
if ( (_DWORD)v26 == 7 )
goto LABEL_58;
}
}
LABEL_59:
U_MD5Final(v45, v46);
string2hex_constprop_0_isra_0(v45, a1);
result = get_debug_level("core", 4LL);
if ( result > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v42 = (const char *)*((_QWORD *)&log_level_info + 16);
v43 = my_pid();
result = fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: MD5 calculated: %.*s\n",
process_no,
v43,
v42,
"<core> [md5utils.c:67]: ",
"MD5StringArray",
32,
a1);
if ( log_color )
result = dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: MD5 calculated: %.*s\n",
*((_QWORD *)&log_level_info + 16),
"<core> [md5utils.c:67]: ",
"MD5StringArray",
32LL,
a1);
result = v44;
}
--dprint_crit;
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(_BYTE *a1, __int64 a2, int a3)
{
__int64 v3; // r12
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // r13
int v9; // edx
_BYTE *v10; // rsi
__int64 v11; // rax
int v12; // edx
unsigned __int64 v13; // rcx
int v14; // edx
int v15; // er8
char v16; // cl
_BYTE *v17; // rax
int v18; // er11
char v19; // di
char v20; // r9
char v21; // r8
char v22; // r10
char v23; // cl
char v24; // di
int result; // eax
__int64 v26; // r8
unsigned __int64 v27; // r9
unsigned __int64 v28; // r10
unsigned __int64 v29; // r11
__int64 v30; // rax
unsigned __int64 v31; // rax
unsigned __int64 v32; // rcx
unsigned __int64 v33; // rdi
unsigned __int64 v34; // r9
unsigned __int64 v35; // rdi
unsigned __int64 v36; // rdi
unsigned __int64 v37; // r8
unsigned __int64 v38; // r9
unsigned __int64 v39; // r10
unsigned __int64 v40; // r11
unsigned __int64 v41; // rcx
const char *v42; // r12
unsigned int v43; // eax
int v44; // [rsp-10h] [rbp-A8h]
_BYTE v45[16]; // [rsp+0h] [rbp-98h] BYREF
char v46[136]; // [rsp+10h] [rbp-88h] BYREF

v3 = a2;
MD5Init(v46);
if ( a3 > 0 )
{
v6 = (unsigned int)(a3 - 1);
v7 = 0x100002601LL;
v8 = a2 + 16 * v6 + 16;
while ( 1 )
{
v9 = *(_DWORD *)(v3 + 8);
if ( !v9 )
goto LABEL_58;
v10 = *(_BYTE **)v3;
v11 = v9;
v12 = *(_DWORD *)(v3 + 8) & 7;
if ( !v12 )
break;
if ( v12 == 1 )
{
LABEL_100:
v41 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v41 > 0x20u || !_bittest64(&v7, v41) )
goto LABEL_12;
if ( (_DWORD)--v11 )
break;
v3 += 16LL;
if ( v8 == v3 )
goto LABEL_59;
}
else
{
if ( v12 != 2 )
{
if ( v12 != 3 )
{
if ( v12 != 4 )
{
if ( v12 != 5 )
{
if ( v12 != 6 )
{
v13 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v13 > 0x20u || !_bittest64(&v7, v13) )
goto LABEL_12;
--v11;
}
v36 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v36 > 0x20u || !_bittest64(&v7, v36) )
goto LABEL_12;
--v11;
}
v37 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v37 > 0x20u || !_bittest64(&v7, v37) )
goto LABEL_12;
--v11;
}
v38 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v38 > 0x20u || !_bittest64(&v7, v38) )
goto LABEL_12;
--v11;
}
v39 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v39 > 0x20u || !_bittest64(&v7, v39) )
goto LABEL_12;
--v11;
}
v40 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v40 <= 0x20u && _bittest64(&v7, v40) )
{
--v11;
goto LABEL_100;
}
if ( !v14 )
goto LABEL_58;
LABEL_12:
v15 = v14 & 7;
if ( (v14 & 7) == 0 )
goto LABEL_41;
if ( v15 != 1 )
{
if ( v15 != 2 )
{
if ( v15 != 3 )
{
if ( v15 != 4 )
{
if ( v15 != 5 )
{
if ( v15 != 6 )
{
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
--v14;
++v10;
}
if ( *v10 != 32 && *v10 != 9 )
goto LABEL_105;
++v10;
if ( --v14 )
{
LABEL_41:
while ( *v10 == 32 || *v10 == 9 )
{
v16 = v10[1];
v17 = v10 + 1;
v18 = --v14;
++v10;
if ( v16 != 32 && v16 != 9 )
break;
v19 = v17[1];
v14 = v18 - 1;
v10 = v17 + 1;
if ( v19 != 32 && v19 != 9 )
break;
v20 = v17[2];
v14 = v18 - 2;
v10 = v17 + 2;
if ( v20 != 32 && v20 != 9 )
break;
v21 = v17[3];
v14 = v18 - 3;
v10 = v17 + 3;
if ( v21 != 32 && v21 != 9 )
break;
v22 = v17[4];
v14 = v18 - 4;
v10 = v17 + 4;
if ( v22 != 32 && v22 != 9 )
break;
v23 = v17[5];
v14 = v18 - 5;
v10 = v17 + 5;
if ( v23 != 32 && v23 != 9 )
break;
v24 = v17[6];
v14 = v18 - 6;
v10 = v17 + 6;
if ( v24 != 32 && v24 != 9 )
break;
v10 = v17 + 7;
v14 = v18 - 7;
if ( v18 == 7 )
goto LABEL_58;
}
LABEL_105:
if ( v14 <= 0 )
goto LABEL_58;
v3 += 16LL;
func0(v46, v10, v14);
if ( v8 == v3 )
goto LABEL_59;
}
else
{
LABEL_58:
v3 += 16LL;
if ( v8 == v3 )
goto LABEL_59;
}
}
}
while ( 1 )
{
v35 = (unsigned __int8)v10[v11 - 1];
v14 = v11;
if ( (unsigned __int8)v35 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v35) )
goto LABEL_12;
v26 = v11 - 1;
v27 = (unsigned __int8)v10[v11 - 2];
v14 = v11 - 1;
if ( (unsigned __int8)v27 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v27) )
goto LABEL_12;
v28 = (unsigned __int8)v10[v11 - 3];
v14 = v11 - 2;
if ( (unsigned __int8)v28 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v28) )
goto LABEL_12;
v29 = (unsigned __int8)v10[v11 - 4];
v14 = v11 - 3;
if ( (unsigned __int8)v29 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v29) )
goto LABEL_12;
v30 = v11 - 4;
v14 = v30;
v31 = (unsigned __int8)v10[v30 - 1];
if ( (unsigned __int8)v31 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v31) )
goto LABEL_12;
v32 = (unsigned __int8)v10[v26 - 5];
v14 = v26 - 4;
if ( (unsigned __int8)v32 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v32) )
goto LABEL_12;
v33 = (unsigned __int8)v10[v26 - 6];
v14 = v26 - 5;
if ( (unsigned __int8)v33 > 0x20u )
goto LABEL_12;
if ( !_bittest64(&v7, v33) )
goto LABEL_12;
v34 = (unsigned __int8)v10[v26 - 7];
v14 = v26 - 6;
if ( (unsigned __int8)v34 > 0x20u || !_bittest64(&v7, v34) )
goto LABEL_12;
v11 = v26 - 7;
if ( (_DWORD)v26 == 7 )
goto LABEL_58;
}
}
LABEL_59:
U_MD5Final(v45, v46);
func1(v45, a1);
result = get_debug_level("core", 4LL);
if ( result > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v42 = (const char *)*((_QWORD *)&log_level_info + 16);
v43 = my_pid();
result = fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: MD5 calculated: %.*s\n",
process_no,
v43,
v42,
"<core> [md5utils.c:67]: ",
"MD5StringArray",
32,
a1);
if ( log_color )
result = dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: MD5 calculated: %.*s\n",
*((_QWORD *)&log_level_info + 16),
"<core> [md5utils.c:67]: ",
"MD5StringArray",
32LL,
a1);
result = v44;
}
--dprint_crit;
}
return result;
}

original_code:
void MD5StringArray (char *dst, str src[], int size)
{
 MD5_CTX context;
 unsigned char digest[16];
  int i;
 int len;
 char *s;
 MD5Init (&context);
 for (i=0; i<size; i++) {
  do{ static char _c; (len)=(src[i]).len; while ((len) && ((_c=(src[i]).s[(len)-1])==0 || _c=='\r' || _c=='\n' || _c==' ' || _c=='\t' )) (len)--; (s)=(src[i]).s; while ((len) && ((_c=*(s))==' ' || _c=='\t')) { (len)--; (s)++; } }while(0);
  if (len > 0)
     MD5Update (&context, s, len);
  }
  U_MD5Final (digest, &context);
  string2hex(digest, 16, dst );
  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(): " "DEBUG: MD5 calculated: %.*s\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); 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(): " "DEBUG: MD5 calculated: %.*s\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DEBUG: MD5 calculated: %.*s\n", process_no, my_pid(), ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); 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(): " "DEBUG: MD5 calculated: %.*s\n", ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: MD5 calculated: %.*s\n", ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); } } (dprint_crit--); } } while(0);
}

canonical_original_code:
void MD5StringArray(char *dst, struct _str src[], int size)
{
 struct MD5Context context;
 unsigned char digest[16];
  int i;
 int len;
 char *s;
 MD5Init (&context);
 for (i=0; i<size; i++) {
  do{ static char _c; (len)=(src[i]).len; while ((len) && ((_c=(src[i]).s[(len)-1])==0 || _c=='\r' || _c=='\n' || _c==' ' || _c=='\t' )) (len)--; (s)=(src[i]).s; while ((len) && ((_c=*(s))==' ' || _c=='\t')) { (len)--; (s)++; } }while(0);
  if (len > 0)
     MD5Update (&context, s, len);
  }
  U_MD5Final (digest, &context);
  string2hex(digest, 16, dst );
  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(): " "DEBUG: MD5 calculated: %.*s\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); 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(): " "DEBUG: MD5 calculated: %.*s\n", (log_level_info[((3)) - (-5)].name), ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DEBUG: MD5 calculated: %.*s\n", process_no, my_pid(), ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); 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(): " "DEBUG: MD5 calculated: %.*s\n", ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: MD5 calculated: %.*s\n", ("<core> [" "md5utils.c" ":" "67" "]: ") , __func__, 32, dst); } } (dprint_crit--); } } while(0);
}

variable_types:
dst
char *

variable_types:
src
struct _str { char *s; int len; } []

variable_types: size int

variable_types: struct MD5Context { unsigned int state[4]; unsigned int count; unsigned char buffer[64]; }

variable_types:
digest
unsigned char [16]

variable_types: i int

variable_types: len int

variable_types:
s
char *


original_code:
static void trace_vs(rpc_t *rpc, void *c, virtual_subscription_t *vs, int details)
{
 rpc->printf(c, " Virtual subscriptions:");
 do { } while (0);
 rpc->printf(c, " -> URI = %.*s", (vs->uri).len,((vs->uri).s ? (vs->uri).s : ""));
 do { } while (0);
 rpc->printf(c, " -> status = %d", vs->status);
 do { } while (0);
 if (details > 0) {
  rpc->printf(c, " -> document = %.*s", (vs->state_document).len,((vs->state_document).s ? (vs->state_document).s : ""));
  do { } while (0);
 }
 do { } while (0);
}

canonical_original_code:
static void trace_vs(struct rpc *rpc, void *c, struct _virtual_subscription_t *vs, int details)
{
 rpc->printf(c, " Virtual subscriptions:");
 do { } while (0);
 rpc->printf(c, " -> URI = %.*s", (vs->uri).len,((vs->uri).s ? (vs->uri).s : ""));
 do { } while (0);
 rpc->printf(c, " -> status = %d", vs->status);
 do { } while (0);
 if (details > 0) {
  rpc->printf(c, " -> document = %.*s", (vs->state_document).len,((vs->state_document).s ? (vs->state_document).s : ""));
  do { } while (0);
 }
 do { } while (0);
}

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

variable_types:
c
void *

variable_types: struct _virtual_subscription_t { struct _qsa_subscription_data_t { struct msg_queue { struct reference_counter_data_t { int cntr; struct atomic_t { int val; } *mutex; } ref; 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]; } *first; struct _mq_message_t *last; struct atomic_t q_mutex; unsigned int flags; } *dst; struct _str { char *s; int len; } record_id; struct _str subscriber_id; struct _qsa_subscription_params_t { struct _str name; struct _str value; char buf[1]; } *first_param; void *subscriber_data; } local_subscription_pres_data; struct _qsa_subscription_t { struct atomic_t *mutex; struct _notifier_package_t { struct _str name; struct _notifier_domain_t { struct atomic_t mutex; struct atomic_t data_mutex; struct _str name; struct _notifier_package_t *first_package; struct _qsa_content_type_t { struct _qsa_content_type_t *next; struct _str name; void (*destroy_func)(void *); char buf[1]; } *first_content_type; struct reference_counter_data_t ref; struct reference_counter_group_t { int mutex_cnt; int mutex_to_assign; struct atomic_t mutexes[1]; } *rc_grp; } *domain; 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; } *first_notifier; struct _qsa_subscription_t *first_subscription; struct _notifier_package_t *next; } *package; int allow_notifications; struct _qsa_subscription_data_t *data; struct _qsa_subscription_t *prev; struct reference_counter_data_t ref; } *local_subscription_pres; struct _rl_subscription_t { enum rls_subscription_type_t { rls_internal_subscription=0, rls_external_subscription=1 } type; struct xcap_query_params_t { struct _str xcap_root; struct _str auth_user; struct _str auth_pass; int enable_unverified_ssl_peer; } xcap_params; union { 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 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; } external; struct internal_subscription_data_t { struct _str *package; struct _str *record_id; struct _str *subscriber_id; struct _virtual_subscription_t *vs; } internal; } u; int doc_version; int changed; struct vector_t { int element_size; int element_count; int allocated_count; int allocation_count; void *data; } vs; struct _str from_uid; char dbid[48]; } *local_subscription_list; struct vector_t display_names; struct _rl_subscription_t *subscription; int changed; struct _str state_document; struct _str content_type; 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 _str uri; struct _virtual_subscription_t *next; struct _virtual_subscription_t *prev; char dbid[48]; char uri_str[1]; } *

variable_types: details int

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

user_defined_types: struct _virtual_subscription_t { struct _qsa_subscription_data_t local_subscription_pres_data; struct _qsa_subscription_t *local_subscription_pres; struct _rl_subscription_t *local_subscription_list; struct vector_t display_names; struct _rl_subscription_t *subscription; int changed; struct _str state_document; struct _str content_type; enum subscription_status_t status; struct _str uri; struct _virtual_subscription_t *next; struct _virtual_subscription_t *prev; char dbid[48]; char uri_str[1]; }

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 _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 _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: 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 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 _subscription_data_t { struct _time_event_data_t expiration; struct dlg *dialog; void *usr_data; enum subscription_status_t 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 _notifier_domain_t { struct atomic_t mutex; struct atomic_t data_mutex; struct _str name; struct _notifier_package_t *first_package; struct _qsa_content_type_t *first_content_type; struct reference_counter_data_t ref; struct reference_counter_group_t *rc_grp; }

user_defined_types: struct dlg { struct dlg_id id; struct dlg_seq 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 state; struct rr *route_set; struct dlg_hooks hooks; struct socket_info *send_sock; }

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

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: union sockaddr_union { struct sockaddr s; struct sockaddr_in sin; struct sockaddr_in6 sin6; }

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

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

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

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


decompiled_code:
__int64 __fastcall rls_trace_subscription(__int64 a1, __int64 a2, unsigned int *a3, int a4)
{
__int64 result; // rax
const char *v7; // rcx
unsigned int v8; // edx
int v9; // ecx
unsigned int *v10; // rbp
bool v11; // r13
unsigned int v12; // ebx
int v13; // er12
int v14; // ecx
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
unsigned int v18; // ebx
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rbx
void *v22; // rcx
int v23; // [rsp+Ch] [rbp-3Ch]

result = *a3;
if ( (_DWORD)result )
{
if ( (_DWORD)result == 1 )
{
v7 = (const char *)*((_QWORD *)a3 + 21);
v8 = a3[44];
if ( !v7 )
v7 = (const char *)&LC0;
result = (*(__int64 (**)(__int64, const char *, ...))(a1 + 32))(a2, "URI = %.*s", v8, v7);
}
}
else
{
v21 = *((_QWORD *)a3 + 9);
v22 = *(void **)v21;
if ( !*(_QWORD *)v21 )
v22 = &LC0;
result = (*(__int64 (__fastcall **)(__int64, const char *, _QWORD, void *))(a1 + 32))(
a2,
"URI = %.*s",
*(unsigned int *)(v21 + 8),
v22);
}
v9 = a3[57];
v23 = v9;
if ( v9 > 0 )
{
v10 = a3 + 56;
v11 = a4 > 0;
v12 = 0;
v13 = a4 - 1;
v14 = v9 & 3;
if ( !v14 )
goto LABEL_41;
if ( v14 != 1 )
{
if ( v14 != 2 )
{
v15 = ptr_vector_get(v10, 0LL);
if ( v15 && v11 )
trace_vs(a1, a2, v15, v13);
v12 = 1;
}
v16 = ptr_vector_get(v10, v12);
if ( v16 && v11 )
trace_vs(a1, a2, v16, v13);
++v12;
}
result = ptr_vector_get(v10, v12);
if ( result && v11 )
result = trace_vs(a1, a2, result, v13);
if ( v23 != ++v12 )
{
LABEL_41:
do
{
v17 = ptr_vector_get(v10, v12);
if ( v17 && v11 )
trace_vs(a1, a2, v17, v13);
v18 = v12 + 1;
v19 = ptr_vector_get(v10, v18);
if ( v19 && v11 )
trace_vs(a1, a2, v19, v13);
v20 = ptr_vector_get(v10, v18 + 1);
if ( v20 && v11 )
trace_vs(a1, a2, v20, v13);
result = ptr_vector_get(v10, v18 + 2);
if ( result )
{
if ( v11 )
result = trace_vs(a1, a2, result, v13);
}
v12 = v18 + 3;
}
while ( v23 != v12 );
}
}
return result;
}

original_code:
static void rls_trace_subscription(rpc_t *rpc, void *c, rl_subscription_t *s, int details)
{
 virtual_subscription_t *vs;
 int cnt, i;
 switch (s->type) {
  case rls_internal_subscription:
   rpc->printf(c, "URI = %.*s", (*s->u.internal.record_id).len,((*s->u.internal.record_id).s ? (*s->u.internal.record_id).s : ""));
   do { } while (0);
   break;
  case rls_external_subscription:
   rpc->printf(c, "URI = %.*s", (s->u.external.record_id).len,((s->u.external.record_id).s ? (s->u.external.record_id).s : ""));
   do { } while (0);
   break;
 }
 cnt = (&s->vs)->element_count;
 for (i = 0; i < cnt; i++) {
  vs = ptr_vector_get(&s->vs, i);
  if (!vs) continue;
  if (details > 0) trace_vs(rpc, c, vs, details - 1);
 }
 do { } while (0);
}

canonical_original_code:
static void rls_trace_subscription(struct rpc *rpc, void *c, struct _rl_subscription_t *s, int details)
{
 struct _virtual_subscription_t *vs;
 int cnt; int i;
 switch (s->type) {
  case rls_internal_subscription:
   rpc->printf(c, "URI = %.*s", (*s->u.internal.record_id).len,((*s->u.internal.record_id).s ? (*s->u.internal.record_id).s : ""));
   do { } while (0);
   break;
  case rls_external_subscription:
   rpc->printf(c, "URI = %.*s", (s->u.external.record_id).len,((s->u.external.record_id).s ? (s->u.external.record_id).s : ""));
   do { } while (0);
   break;
 }
 cnt = (&s->vs)->element_count;
 for (i = 0; i < cnt; i++) {
  vs = ptr_vector_get(&s->vs, i);
  if (!vs) continue;
  if (details > 0) trace_vs(rpc, c, vs, details - 1);
 }
 do { } while (0);
}

variable_types: struct _rl_subscription_t { enum rls_subscription_type_t { rls_internal_subscription=0, rls_external_subscription=1 } type; struct xcap_query_params_t { struct _str { char *s; int len; } xcap_root; struct _str auth_user; struct _str auth_pass; int enable_unverified_ssl_peer; } xcap_params; union { 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 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; } external; struct internal_subscription_data_t { struct _str *package; struct _str *record_id; struct _str *subscriber_id; struct _virtual_subscription_t { struct _qsa_subscription_data_t { struct msg_queue { struct reference_counter_data_t { int cntr; struct atomic_t { int val; } *mutex; } ref; 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]; } *first; struct _mq_message_t *last; struct atomic_t q_mutex; unsigned int flags; } *dst; struct _str record_id; struct _str subscriber_id; struct _qsa_subscription_params_t { struct _str name; struct _str value; char buf[1]; } *first_param; void *subscriber_data; } local_subscription_pres_data; struct _qsa_subscription_t { struct atomic_t *mutex; struct _notifier_package_t { struct _str name; struct _notifier_domain_t { struct atomic_t mutex; struct atomic_t data_mutex; struct _str name; struct _notifier_package_t *first_package; struct _qsa_content_type_t { struct _qsa_content_type_t *next; struct _str name; void (*destroy_func)(void *); char buf[1]; } *first_content_type; struct reference_counter_data_t ref; struct reference_counter_group_t { int mutex_cnt; int mutex_to_assign; struct atomic_t mutexes[1]; } *rc_grp; } *domain; 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; } *first_notifier; struct _qsa_subscription_t *first_subscription; struct _notifier_package_t *next; } *package; int allow_notifications; struct _qsa_subscription_data_t *data; struct _qsa_subscription_t *prev; struct reference_counter_data_t ref; } *local_subscription_pres; struct _rl_subscription_t *local_subscription_list; struct vector_t { int element_size; int element_count; int allocated_count; int allocation_count; void *data; } display_names; struct _rl_subscription_t *subscription; int changed; struct _str state_document; struct _str content_type; 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 _str uri; struct _virtual_subscription_t *next; struct _virtual_subscription_t *prev; char dbid[48]; char uri_str[1]; } *vs; } internal; } u; int doc_version; int changed; struct vector_t vs; struct _str from_uid; char dbid[48]; } *

variable_types: cnt int

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

user_defined_types: struct _virtual_subscription_t { struct _qsa_subscription_data_t local_subscription_pres_data; struct _qsa_subscription_t *local_subscription_pres; struct _rl_subscription_t *local_subscription_list; struct vector_t display_names; struct _rl_subscription_t *subscription; int changed; struct _str state_document; struct _str content_type; enum subscription_status_t status; struct _str uri; struct _virtual_subscription_t *next; struct _virtual_subscription_t *prev; char dbid[48]; char uri_str[1]; }

user_defined_types: struct xcap_query_params_t { struct _str xcap_root; struct _str auth_user; struct _str auth_pass; int enable_unverified_ssl_peer; }

user_defined_types: struct internal_subscription_data_t { struct _str *package; struct _str *record_id; struct _str *subscriber_id; struct _virtual_subscription_t *vs; }

user_defined_types: enum rpc_capabilities { RPC_DELAYED_REPLY=expr }

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


decompiled_code:
__int64 __fastcall rls_trace(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 i; // rbx
__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 = 0;
for ( i = *rls_manager; i; i = *(_QWORD *)(i + 72) )
{
++v2;
if ( v5[0] > 0 )
rls_trace_subscription(a1, a2, *(unsigned int **)(i + 56), v5[0]);
}
(*(void (**)(__int64, const char *, ...))(a1 + 32))(a2, "subscription count: %d", v2);
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]; }


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

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

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

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

variable_types:
var
int *

variable_types: v int


decompiled_code:
__int64 __fastcall futex_release(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

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

canonical_decompiled_code:
__int64 __fastcall func1(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

result = func0(a1, 0);
if ( (_DWORD)result == 2 )
{
syscall(202LL, a1, 1LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
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));
 }
}

variable_types:
lock
struct atomic_t { int val; } *


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

result = atomic_cmpxchg_int_constprop_0(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
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_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
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 func3(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = func2(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = func0(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
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);
}


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

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; // r12

func3(mem_lock);
v1 = qm_malloc(shm_block, a1);
func1(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 v5; // ebx
char *v6; // rax
char *v7; // rbp
size_t v8; // rdx
char *v9; // rbx
size_t v10; // rdx
_BYTE *v11; // rax
__int64 v12; // rsi
char *v13; // rdi
size_t v14; // rdx
char *v15; // rax
__int64 v16; // r9
__int64 result; // rax
int v18; // ebx
const char *v19; // rbp
unsigned int v20; // eax
struct _IO_FILE *v21; // rdi
__int64 v22; // rdx
__int64 v23; // rcx
const char *v24; // r13
unsigned int v25; // eax
struct _IO_FILE *v26; // rdi
__int64 v27; // rcx
const char *v28; // r9
const char *v29; // [rsp-10h] [rbp-38h]
const char *v30; // [rsp-8h] [rbp-30h]
const char *v31; // [rsp+0h] [rbp-28h]

v5 = *(_DWORD *)(a1 + 8) + *(_DWORD *)(a2 + 8) + 89;
v6 = (char *)shm_malloc(v5);
if ( v6 )
{
v7 = v6;
v8 = v5;
v9 = &v6[v5];
memset(v6, 0, v8);
*((_DWORD *)v7 + 12) = 1;
v10 = *(int *)(a1 + 8);
*((_QWORD *)v7 + 7) = v7 + 88;
v11 = memcpy(v7 + 88, *(const void **)a1, v10);
v12 = *(int *)(a1 + 8);
*((_DWORD *)v7 + 16) = v12;
v13 = &v11[v12 + 1];
v11[v12] = 0;
v14 = *(int *)(a2 + 8);
*((_QWORD *)v7 + 9) = v13;
v15 = (char *)memcpy(v13, *(const void **)a2, v14);
v16 = *(int *)(a2 + 8);
*((_DWORD *)v7 + 20) = v16;
if ( &v15[v16] == v9 )
{
*a3 = 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);
v24 = (const char *)*((_QWORD *)&log_level_info + 8);
v25 = my_pid();
v26 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): buffer over/underflow\n",
process_no,
v25,
v24,
"ims_qos [rx_authdata.c:95]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset(
v26,
"%2d(%d) %s: %s%s(): buffer over/underflow\n",
v30,
v27,
(const char *)log_color,
v28,
v31);
}
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, v7);
futex_release(mem_lock);
result = 0xFFFFFFFFLL;
}
}
else
{
v18 = get_debug_level("ims_qos", 7LL);
result = 0xFFFFFFFFLL;
if ( v18 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v19 = (const char *)*((_QWORD *)&log_level_info + 8);
v20 = my_pid();
v21 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shm memory\n",
process_no,
v20,
v19,
"ims_qos [rx_authdata.c:76]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset(v21, "%2d(%d) %s: %s%s(): no more shm memory\n", v22, v23, v29, v30, v31);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, _QWORD *a3)
{
signed int v5; // ebx
char *v6; // rax
char *v7; // rbp
size_t v8; // rdx
char *v9; // rbx
size_t v10; // rdx
_BYTE *v11; // rax
__int64 v12; // rsi
char *v13; // rdi
size_t v14; // rdx
char *v15; // rax
__int64 v16; // r9
__int64 result; // rax
int v18; // ebx
const char *v19; // rbp
unsigned int v20; // eax
struct _IO_FILE *v21; // rdi
__int64 v22; // rdx
__int64 v23; // rcx
const char *v24; // r13
unsigned int v25; // eax
struct _IO_FILE *v26; // rdi
__int64 v27; // rcx
const char *v28; // r9
const char *v29; // [rsp-10h] [rbp-38h]
const char *v30; // [rsp-8h] [rbp-30h]
const char *v31; // [rsp+0h] [rbp-28h]

v5 = *(_DWORD *)(a1 + 8) + *(_DWORD *)(a2 + 8) + 89;
v6 = (char *)func4(v5);
if ( v6 )
{
v7 = v6;
v8 = v5;
v9 = &v6[v5];
memset(v6, 0, v8);
*((_DWORD *)v7 + 12) = 1;
v10 = *(int *)(a1 + 8);
*((_QWORD *)v7 + 7) = v7 + 88;
v11 = memcpy(v7 + 88, *(const void **)a1, v10);
v12 = *(int *)(a1 + 8);
*((_DWORD *)v7 + 16) = v12;
v13 = &v11[v12 + 1];
v11[v12] = 0;
v14 = *(int *)(a2 + 8);
*((_QWORD *)v7 + 9) = v13;
v15 = (char *)memcpy(v13, *(const void **)a2, v14);
v16 = *(int *)(a2 + 8);
*((_DWORD *)v7 + 20) = v16;
if ( &v15[v16] == v9 )
{
*a3 = 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);
v24 = (const char *)*((_QWORD *)&log_level_info + 8);
v25 = my_pid();
v26 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): buffer over/underflow\n",
process_no,
v25,
v24,
"ims_qos [rx_authdata.c:95]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset(
v26,
"%2d(%d) %s: %s%s(): buffer over/underflow\n",
v30,
v27,
(const char *)log_color,
v28,
v31);
}
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;
}
func3(mem_lock);
qm_free(shm_block, v7);
func1(mem_lock);
result = 0xFFFFFFFFLL;
}
}
else
{
v18 = get_debug_level("ims_qos", 7LL);
result = 0xFFFFFFFFLL;
if ( v18 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v19 = (const char *)*((_QWORD *)&log_level_info + 8);
v20 = my_pid();
v21 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): no more shm memory\n",
process_no,
v20,
v19,
"ims_qos [rx_authdata.c:76]: ",
"create_new_regsessiondata");
if ( log_color )
dprint_color_reset(v21, "%2d(%d) %s: %s%s(): no more shm memory\n", v22, v23, v29, v30, v31);
}
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");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
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: 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; }