decompiled_code:
__int64 __fastcall fixup_replace_from2(const char **a1, int a2)
{
const char **v3; // rax
const char **v4; // rbx
const char *v5; // r13
int v6; // esi
__int64 result; // rax
int v8; // er11
const char *v9; // r12
unsigned int v10; // eax
char *v11; // rax
const char *v12; // r13
int v13; // esi
const char *v14; // rbx
unsigned int v15; // eax
const char *v16; // rbp
unsigned int v17; // eax
int v18; // edi

v3 = (const char **)qm_malloc(mem_block, 16LL);
if ( !v3 )
{
v8 = get_debug_level(&LC0, 3LL);
result = 4294967294LL;
if ( v8 >= -2 )
{
result = 4294967294LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v9 = (const char *)*((_QWORD *)&log_level_info + 6);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
process_no,
v10,
v9,
"uac [uac.c:199]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:199]: ",
"fixup_replace_from2");
}
--dprint_crit;
result = 4294967294LL;
}
}
return result;
}
v4 = v3;
v5 = *a1;
*v3 = *a1;
v6 = strlen(v5);
*((_DWORD *)v4 + 2) = v6;
if ( v6 )
{
if ( a2 != 1 )
{
LABEL_4:
*a1 = (const char *)v4;
return 0LL;
}
}
else
{
qm_free(mem_block, v5);
*v4 = 0LL;
if ( a2 != 1 )
{
if ( a2 != 2 || *(_QWORD *)*(a1 - 1) )
goto LABEL_4;
v18 = get_debug_level(&LC0, 3LL);
result = 0xFFFFFFFFLL;
if ( v18 >= -2 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v16 = (const char *)*((_QWORD *)&log_level_info + 6);
v17 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
process_no,
v17,
v16,
"uac [uac.c:233]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:233]: ",
"fixup_replace_from2");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}
v6 = *((_DWORD *)v4 + 2);
if ( !v6 )
goto LABEL_4;
}
v11 = (char *)qm_malloc(mem_block, v6 + 2);
v12 = v11;
if ( v11 )
{
*v11 = 34;
memcpy(v11 + 1, *v4, *((int *)v4 + 2));
v12[*((int *)v4 + 2) + 1] = 34;
qm_free(mem_block, *v4);
*v4 = v12;
*((_DWORD *)v4 + 2) += 2;
goto LABEL_4;
}
v13 = get_debug_level(&LC0, 3LL);
result = 4294967294LL;
if ( v13 >= -2 )
{
result = 4294967294LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v14 = (const char *)*((_QWORD *)&log_level_info + 6);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
process_no,
v15,
v14,
"uac [uac.c:218]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:218]: ",
"fixup_replace_from2");
}
--dprint_crit;
result = 4294967294LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char **a1, int a2)
{
const char **v3; // rax
const char **v4; // rbx
const char *v5; // r13
int v6; // esi
__int64 result; // rax
int v8; // er11
const char *v9; // r12
unsigned int v10; // eax
char *v11; // rax
const char *v12; // r13
int v13; // esi
const char *v14; // rbx
unsigned int v15; // eax
const char *v16; // rbp
unsigned int v17; // eax
int v18; // edi

v3 = (const char **)qm_malloc(mem_block, 16LL);
if ( !v3 )
{
v8 = get_debug_level(&LC0, 3LL);
result = 4294967294LL;
if ( v8 >= -2 )
{
result = 4294967294LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v9 = (const char *)*((_QWORD *)&log_level_info + 6);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
process_no,
v10,
v9,
"uac [uac.c:199]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:199]: ",
"fixup_replace_from2");
}
--dprint_crit;
result = 4294967294LL;
}
}
return result;
}
v4 = v3;
v5 = *a1;
*v3 = *a1;
v6 = strlen(v5);
*((_DWORD *)v4 + 2) = v6;
if ( v6 )
{
if ( a2 != 1 )
{
LABEL_4:
*a1 = (const char *)v4;
return 0LL;
}
}
else
{
qm_free(mem_block, v5);
*v4 = 0LL;
if ( a2 != 1 )
{
if ( a2 != 2 || *(_QWORD *)*(a1 - 1) )
goto LABEL_4;
v18 = get_debug_level(&LC0, 3LL);
result = 0xFFFFFFFFLL;
if ( v18 >= -2 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v16 = (const char *)*((_QWORD *)&log_level_info + 6);
v17 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
process_no,
v17,
v16,
"uac [uac.c:233]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:233]: ",
"fixup_replace_from2");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}
v6 = *((_DWORD *)v4 + 2);
if ( !v6 )
goto LABEL_4;
}
v11 = (char *)qm_malloc(mem_block, v6 + 2);
v12 = v11;
if ( v11 )
{
*v11 = 34;
memcpy(v11 + 1, *v4, *((int *)v4 + 2));
v12[*((int *)v4 + 2) + 1] = 34;
qm_free(mem_block, *v4);
*v4 = v12;
*((_DWORD *)v4 + 2) += 2;
goto LABEL_4;
}
v13 = get_debug_level(&LC0, 3LL);
result = 4294967294LL;
if ( v13 >= -2 )
{
result = 4294967294LL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v14 = (const char *)*((_QWORD *)&log_level_info + 6);
v15 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
process_no,
v15,
v14,
"uac [uac.c:218]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:218]: ",
"fixup_replace_from2");
}
--dprint_crit;
result = 4294967294LL;
}
}
return result;
}

original_code:
static int fixup_replace_from2(void** param, int param_no)
{
 char *p;
 str *s;
 s = (str*)qm_malloc(mem_block, (sizeof(str)));
 if (s==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 s->s = (char*)*param;
 s->len = strlen(s->s);
 if (s->len==0)
 {
  qm_free(mem_block, (s->s));
  s->s = 0;
 }
 if (param_no==1)
 {
  if (s->len)
  {
   p = (char*)qm_malloc(mem_block, (s->len+2));
   if (p==0)
   {
    do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    return -2;
   }
   p[0] = '\"';
   memcpy( p+1, s->s, s->len);
   p[s->len+1] = '\"';
   qm_free(mem_block, (s->s));
   s->s = p;
   s->len += 2;
  }
 } else if (param_no==2)
 {
  if (s->s==0 && ((str*)(*(param-1)))->s==0 )
  {
   do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
 }
 *param=(void*)s;
 return 0;
}

canonical_original_code:
static int fixup_replace_from2(void **param, int param_no)
{
 char *p;
 struct _str *s;
 s = (struct _str *)qm_malloc(mem_block, (sizeof(str)));
 if (s==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 s->s = (char *)*param;
 s->len = strlen(s->s);
 if (s->len==0)
 {
  qm_free(mem_block, (s->s));
  s->s = 0;
 }
 if (param_no==1)
 {
  if (s->len)
  {
   p = (char *)qm_malloc(mem_block, (s->len+2));
   if (p==0)
   {
    do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    return -2;
   }
   p[0] = '\"';
   memcpy( p+1, s->s, s->len);
   p[s->len+1] = '\"';
   qm_free(mem_block, (s->s));
   s->s = p;
   s->len += 2;
  }
 } else if (param_no==2)
 {
  if (s->s==0 && ((struct _str *)(*(param-1)))->s==0 )
  {
   do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
 }
 *param=(void *)s;
 return 0;
}


repo: virtualolson/who

decompiled_code:
__int64 mod_destroy()
{
return destroy_credentials();
}

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

original_code:
static void mod_destroy()
{
 destroy_credentials();
}

return_type: void


decompiled_code:
int __fastcall err2reason_phrase(int a1, _DWORD *a2, char *a3, int a4, const char *a5)
{
const char *v5; // r11

if ( a1 > 0 )
goto LABEL_25;
if ( a1 < -18 )
{
if ( a1 == -478 )
{
*a2 = 478;
v5 = "Unresolvable destination";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 < -477 )
{
if ( a1 == -487 )
{
*a2 = 487;
v5 = "transaction canceled";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -479 )
{
*a2 = 479;
v5 = "Regretfully, we were not able to process the URI";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
else
{
if ( a1 == -477 )
{
*a2 = 477;
v5 = "Unfortunately error on sending to next hop occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -400 )
{
*a2 = 400;
v5 = "Bad Request";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
LABEL_25:
*a2 = 500;
v5 = "I'm terribly sorry, server error occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
switch ( a1 )
{
case -18:
*a2 = 400;
v5 = "Decimal part missing in q";
break;
case -17:
*a2 = 400;
v5 = "q parameter too big";
break;
case -16:
*a2 = 400;
v5 = "Empty q parameter";
break;
case -15:
*a2 = 400;
v5 = "Invalid character in q parameter";
break;
case -13:
*a2 = 400;
v5 = "Bad To";
break;
case -12:
*a2 = 500;
v5 = "Forking capacity exceeded";
break;
case -11:
*a2 = 500;
v5 = "Error in external logic";
break;
case -9:
*a2 = 400;
v5 = "Transaction tuple incomplete";
break;
case -2:
case 0:
*a2 = 500;
v5 = "No error";
break;
default:
goto LABEL_25;
}
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}

canonical_decompiled_code:
int __fastcall func0(int a1, _DWORD *a2, char *a3, int a4, const char *a5)
{
const char *v5; // r11

if ( a1 > 0 )
goto LABEL_25;
if ( a1 < -18 )
{
if ( a1 == -478 )
{
*a2 = 478;
v5 = "Unresolvable destination";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 < -477 )
{
if ( a1 == -487 )
{
*a2 = 487;
v5 = "transaction canceled";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -479 )
{
*a2 = 479;
v5 = "Regretfully, we were not able to process the URI";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
else
{
if ( a1 == -477 )
{
*a2 = 477;
v5 = "Unfortunately error on sending to next hop occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -400 )
{
*a2 = 400;
v5 = "Bad Request";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
LABEL_25:
*a2 = 500;
v5 = "I'm terribly sorry, server error occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
switch ( a1 )
{
case -18:
*a2 = 400;
v5 = "Decimal part missing in q";
break;
case -17:
*a2 = 400;
v5 = "q parameter too big";
break;
case -16:
*a2 = 400;
v5 = "Empty q parameter";
break;
case -15:
*a2 = 400;
v5 = "Invalid character in q parameter";
break;
case -13:
*a2 = 400;
v5 = "Bad To";
break;
case -12:
*a2 = 500;
v5 = "Forking capacity exceeded";
break;
case -11:
*a2 = 500;
v5 = "Error in external logic";
break;
case -9:
*a2 = 400;
v5 = "Transaction tuple incomplete";
break;
case -2:
case 0:
*a2 = 500;
v5 = "No error";
break;
default:
goto LABEL_25;
}
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}

original_code:
int err2reason_phrase(
 int ser_error,
 int *sip_error,
 char *phrase,
 int etl,
 char *signature )
{
 char *error_txt;
 switch( ser_error ) {
  case -477:
   error_txt="Unfortunately error on sending to next hop occurred";
   *sip_error=-ser_error;
   break;
  case -478:
   error_txt="Unresolvable destination";
   *sip_error=-ser_error;
   break;
  case -400:
   error_txt="Bad Request";
   *sip_error=-ser_error;
   break;
  case -479:
   error_txt="Regretfully, we were not able to process the URI";
   *sip_error=-ser_error;
   break;
  case -9:
   error_txt="Transaction tuple incomplete";
   *sip_error=- -400;
   break;
  case -13:
   error_txt="Bad To";
   *sip_error=- -400;
   break;
  case -11:
   error_txt="Error in external logic";
   *sip_error=- -500;
   break;
  case -12:
   error_txt="Forking capacity exceeded";
   *sip_error=- -500;
   break;
         case -15:
   error_txt="Invalid character in q parameter";
   *sip_error=- -400;
   break;
         case -16:
   error_txt="Empty q parameter";
   *sip_error=- -400;
   break;;
         case -17:
   error_txt="q parameter too big";
   *sip_error=- -400;
   break;
         case -18:
   error_txt="Decimal part missing in q";
   *sip_error=- -400;
   break;
  case -487:
   error_txt="transaction canceled";
   *sip_error=-ser_error;
   break;
  case -2:
  case 0:
   error_txt="No error";
   *sip_error=500;
   break;
  default:
   error_txt="I'm terribly sorry, server error occurred";
   *sip_error=500;
   break;
 }
 return snprintf( phrase, etl, "%s (%d/%s)", error_txt,
  -ser_error, signature );
}

canonical_original_code:
int err2reason_phrase(int ser_error, int *sip_error, char *phrase, int etl, char *signature)
{
 char *error_txt;
 switch( ser_error ) {
  case -477:
   error_txt="Unfortunately error on sending to next hop occurred";
   *sip_error=-ser_error;
   break;
  case -478:
   error_txt="Unresolvable destination";
   *sip_error=-ser_error;
   break;
  case -400:
   error_txt="Bad Request";
   *sip_error=-ser_error;
   break;
  case -479:
   error_txt="Regretfully, we were not able to process the URI";
   *sip_error=-ser_error;
   break;
  case -9:
   error_txt="Transaction tuple incomplete";
   *sip_error=- -400;
   break;
  case -13:
   error_txt="Bad To";
   *sip_error=- -400;
   break;
  case -11:
   error_txt="Error in external logic";
   *sip_error=- -500;
   break;
  case -12:
   error_txt="Forking capacity exceeded";
   *sip_error=- -500;
   break;
         case -15:
   error_txt="Invalid character in q parameter";
   *sip_error=- -400;
   break;
         case -16:
   error_txt="Empty q parameter";
   *sip_error=- -400;
   break;;
         case -17:
   error_txt="q parameter too big";
   *sip_error=- -400;
   break;
         case -18:
   error_txt="Decimal part missing in q";
   *sip_error=- -400;
   break;
  case -487:
   error_txt="transaction canceled";
   *sip_error=-ser_error;
   break;
  case -2:
  case 0:
   error_txt="No error";
   *sip_error=500;
   break;
  default:
   error_txt="I'm terribly sorry, server error occurred";
   *sip_error=500;
   break;
 }
 return snprintf( phrase, etl, "%s (%d/%s)", error_txt,
  -ser_error, signature );
}

variable_types:
phrase
char *

variable_types: etl int

variable_types:
signature
char *

return_type: int


decompiled_code:
const char *__fastcall error_text(int a1)
{
const char *result; // rax

if ( a1 > 606 )
{
LABEL_53:
result = "Global Failure";
if ( a1 > 599 )
return result;
result = "Server Failure";
if ( a1 > 499 )
return result;
result = "Request Failure";
if ( a1 > 399 )
return result;
if ( a1 > 299 )
return "Redirection";
goto LABEL_59;
}
if ( a1 > 299 )
{
switch ( a1 )
{
case 300:
result = "Multiple Choices";
break;
case 301:
result = "Moved Permanently";
break;
case 302:
result = "Moved Temporarily";
break;
case 305:
result = "Use Proxy";
break;
case 380:
result = "Alternative Service";
break;
case 400:
result = "Bad Request";
break;
case 401:
result = "Unauthorized";
break;
case 402:
result = "Payment Required";
break;
case 403:
result = "Forbidden";
break;
case 404:
result = "Not Found";
break;
case 405:
result = "Method not Allowed";
break;
case 406:
result = "Not Acceptable";
break;
case 407:
result = "Proxy authentication Required";
break;
case 408:
result = "Request Timeout";
break;
case 410:
result = "Gone";
break;
case 413:
result = "Request Entity Too Large";
break;
case 414:
result = "Request-URI Too Long";
break;
case 415:
result = "Unsupported Media Type";
break;
case 416:
result = "Unsupported URI Scheme";
break;
case 417:
result = "Bad Extension";
break;
case 421:
result = "Extension Required";
break;
case 423:
result = "Interval Too Brief";
break;
case 480:
result = "Temporarily Unavailable";
break;
case 481:
result = "Call/Transaction Does not Exist";
break;
case 482:
result = "Loop Detected";
break;
case 483:
result = "Too Many Hops";
break;
case 484:
result = "Address Incomplete";
break;
case 485:
result = "Ambiguous";
break;
case 486:
result = "Busy Here";
break;
case 487:
result = "Request Terminated";
break;
case 488:
result = "Not Acceptable Here";
break;
case 491:
result = "Request Pending";
break;
case 500:
result = "Server Internal Error";
break;
case 501:
result = "Not Implemented";
break;
case 502:
result = "Bad Gateway";
break;
case 503:
result = "Service Unavailable";
break;
case 504:
result = "Server Time-out";
break;
case 505:
result = "Version not Supported";
break;
case 513:
result = "Message Too Large";
break;
case 600:
result = "Busy Everywhere";
break;
case 603:
result = "Decline";
break;
case 604:
result = "Does not Exist Anywhere";
break;
case 606:
result = "Not Acceptable";
break;
default:
goto LABEL_53;
}
return result;
}
if ( a1 == 100 )
return "Trying";
if ( (unsigned int)(a1 - 180) > 0x14 )
{
LABEL_59:
result = "Successful";
if ( a1 <= 199 )
{
result = "Provisional";
if ( a1 <= 99 )
result = "Unspecified";
}
return result;
}
switch ( a1 )
{
case 180:
result = "Ringing";
break;
case 181:
result = "Call is Being Forwarded";
break;
case 182:
result = "Queued";
break;
case 183:
result = "Session Progress";
break;
case 200:
result = "OK";
break;
default:
goto LABEL_53;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(int a1)
{
const char *result; // rax

if ( a1 > 606 )
{
LABEL_53:
result = "Global Failure";
if ( a1 > 599 )
return result;
result = "Server Failure";
if ( a1 > 499 )
return result;
result = "Request Failure";
if ( a1 > 399 )
return result;
if ( a1 > 299 )
return "Redirection";
goto LABEL_59;
}
if ( a1 > 299 )
{
switch ( a1 )
{
case 300:
result = "Multiple Choices";
break;
case 301:
result = "Moved Permanently";
break;
case 302:
result = "Moved Temporarily";
break;
case 305:
result = "Use Proxy";
break;
case 380:
result = "Alternative Service";
break;
case 400:
result = "Bad Request";
break;
case 401:
result = "Unauthorized";
break;
case 402:
result = "Payment Required";
break;
case 403:
result = "Forbidden";
break;
case 404:
result = "Not Found";
break;
case 405:
result = "Method not Allowed";
break;
case 406:
result = "Not Acceptable";
break;
case 407:
result = "Proxy authentication Required";
break;
case 408:
result = "Request Timeout";
break;
case 410:
result = "Gone";
break;
case 413:
result = "Request Entity Too Large";
break;
case 414:
result = "Request-URI Too Long";
break;
case 415:
result = "Unsupported Media Type";
break;
case 416:
result = "Unsupported URI Scheme";
break;
case 417:
result = "Bad Extension";
break;
case 421:
result = "Extension Required";
break;
case 423:
result = "Interval Too Brief";
break;
case 480:
result = "Temporarily Unavailable";
break;
case 481:
result = "Call/Transaction Does not Exist";
break;
case 482:
result = "Loop Detected";
break;
case 483:
result = "Too Many Hops";
break;
case 484:
result = "Address Incomplete";
break;
case 485:
result = "Ambiguous";
break;
case 486:
result = "Busy Here";
break;
case 487:
result = "Request Terminated";
break;
case 488:
result = "Not Acceptable Here";
break;
case 491:
result = "Request Pending";
break;
case 500:
result = "Server Internal Error";
break;
case 501:
result = "Not Implemented";
break;
case 502:
result = "Bad Gateway";
break;
case 503:
result = "Service Unavailable";
break;
case 504:
result = "Server Time-out";
break;
case 505:
result = "Version not Supported";
break;
case 513:
result = "Message Too Large";
break;
case 600:
result = "Busy Everywhere";
break;
case 603:
result = "Decline";
break;
case 604:
result = "Does not Exist Anywhere";
break;
case 606:
result = "Not Acceptable";
break;
default:
goto LABEL_53;
}
return result;
}
if ( a1 == 100 )
return "Trying";
if ( (unsigned int)(a1 - 180) > 0x14 )
{
LABEL_59:
result = "Successful";
if ( a1 <= 199 )
{
result = "Provisional";
if ( a1 <= 99 )
result = "Unspecified";
}
return result;
}
switch ( a1 )
{
case 180:
result = "Ringing";
break;
case 181:
result = "Call is Being Forwarded";
break;
case 182:
result = "Queued";
break;
case 183:
result = "Session Progress";
break;
case 200:
result = "OK";
break;
default:
goto LABEL_53;
}
return result;
}

original_code:
char *error_text( int code )
{
 switch(code) {
  case 100: return "Trying";
  case 180: return "Ringing";
  case 181: return "Call is Being Forwarded";
  case 182: return "Queued";
  case 183: return "Session Progress";
  case 200: return "OK";
  case 300: return "Multiple Choices";
  case 301: return "Moved Permanently";
  case 302: return "Moved Temporarily";
  case 305: return "Use Proxy";
  case 380: return "Alternative Service";
  case 400: return "Bad Request";
  case 401: return "Unauthorized";
  case 402: return "Payment Required";
  case 403: return "Forbidden";
  case 404: return "Not Found";
  case 405: return "Method not Allowed";
  case 406: return "Not Acceptable";
  case 407: return "Proxy authentication Required";
  case 408: return "Request Timeout";
  case 410: return "Gone";
  case 413: return "Request Entity Too Large";
  case 414: return "Request-URI Too Long";
  case 415: return "Unsupported Media Type";
  case 416: return "Unsupported URI Scheme";
  case 417: return "Bad Extension";
  case 421: return "Extension Required";
  case 423: return "Interval Too Brief";
  case 480: return "Temporarily Unavailable";
  case 481: return "Call/Transaction Does not Exist";
  case 482: return "Loop Detected";
  case 483: return "Too Many Hops";
  case 484: return "Address Incomplete";
  case 485: return "Ambiguous";
  case 486: return "Busy Here";
  case 487: return "Request Terminated";
  case 488: return "Not Acceptable Here";
  case 491: return "Request Pending";
  case 500: return "Server Internal Error";
  case 501: return "Not Implemented";
  case 502: return "Bad Gateway";
  case 503: return "Service Unavailable";
  case 504: return "Server Time-out";
  case 505: return "Version not Supported";
  case 513: return "Message Too Large";
  case 600: return "Busy Everywhere";
  case 603: return "Decline";
  case 604: return "Does not Exist Anywhere";
  case 606: return "Not Acceptable";
 }
 if (code>=600) return "Global Failure";
 else if (code>=500) return "Server Failure";
 else if (code>=400) return "Request Failure";
 else if (code>=300) return "Redirection";
 else if (code>=200) return "Successful";
 else if (code>=100) return "Provisional";
 else return "Unspecified";
}

canonical_original_code:
char *error_text(int code)
{
 switch(code) {
  case 100: return "Trying";
  case 180: return "Ringing";
  case 181: return "Call is Being Forwarded";
  case 182: return "Queued";
  case 183: return "Session Progress";
  case 200: return "OK";
  case 300: return "Multiple Choices";
  case 301: return "Moved Permanently";
  case 302: return "Moved Temporarily";
  case 305: return "Use Proxy";
  case 380: return "Alternative Service";
  case 400: return "Bad Request";
  case 401: return "Unauthorized";
  case 402: return "Payment Required";
  case 403: return "Forbidden";
  case 404: return "Not Found";
  case 405: return "Method not Allowed";
  case 406: return "Not Acceptable";
  case 407: return "Proxy authentication Required";
  case 408: return "Request Timeout";
  case 410: return "Gone";
  case 413: return "Request Entity Too Large";
  case 414: return "Request-URI Too Long";
  case 415: return "Unsupported Media Type";
  case 416: return "Unsupported URI Scheme";
  case 417: return "Bad Extension";
  case 421: return "Extension Required";
  case 423: return "Interval Too Brief";
  case 480: return "Temporarily Unavailable";
  case 481: return "Call/Transaction Does not Exist";
  case 482: return "Loop Detected";
  case 483: return "Too Many Hops";
  case 484: return "Address Incomplete";
  case 485: return "Ambiguous";
  case 486: return "Busy Here";
  case 487: return "Request Terminated";
  case 488: return "Not Acceptable Here";
  case 491: return "Request Pending";
  case 500: return "Server Internal Error";
  case 501: return "Not Implemented";
  case 502: return "Bad Gateway";
  case 503: return "Service Unavailable";
  case 504: return "Server Time-out";
  case 505: return "Version not Supported";
  case 513: return "Message Too Large";
  case 600: return "Busy Everywhere";
  case 603: return "Decline";
  case 604: return "Does not Exist Anywhere";
  case 606: return "Not Acceptable";
 }
 if (code>=600) return "Global Failure";
 else if (code>=500) return "Server Failure";
 else if (code>=400) return "Request Failure";
 else if (code>=300) return "Redirection";
 else if (code>=200) return "Successful";
 else if (code>=100) return "Provisional";
 else return "Unspecified";
}

variable_types: code int

return_type: char *


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 defunct_gw(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+4h] [rbp-24h] BYREF
unsigned int v4; // [rsp+8h] [rbp-20h] BYREF
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( (*(int (__fastcall **)(__int64, const char *, unsigned int *, unsigned int *, unsigned int *))(a1 + 24))(
a2,
"ddd",
v5,
&v4,
&v3) <= 2 )
return (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"lcr_id, gw_id, and timestamp parameters required");
result = rpc_defunct_gw(v5[0], v4, v3);
if ( !(_DWORD)result )
result = (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"parameter value error (see syslog)");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+4h] [rbp-24h] BYREF
unsigned int v4; // [rsp+8h] [rbp-20h] BYREF
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( (*(int (__fastcall **)(__int64, const char *, unsigned int *, unsigned int *, unsigned int *))(a1 + 24))(
a2,
"ddd",
v5,
&v4,
&v3) <= 2 )
return (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"lcr_id, gw_id, and timestamp parameters required");
result = rpc_defunct_gw(v5[0], v4, v3);
if ( !(_DWORD)result )
result = (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"parameter value error (see syslog)");
return result;
}

original_code:
static void defunct_gw(rpc_t* rpc, void* c)
{
    unsigned int lcr_id, gw_id, until;
    if (rpc->scan(c, "ddd", &lcr_id, &gw_id, &until) < 3) {
 rpc->fault(c, 400, "lcr_id, gw_id, and timestamp parameters required");
 return;
    }
    if (rpc_defunct_gw(lcr_id, gw_id, until) == 0) {
 rpc->fault(c, 400, "parameter value error (see syslog)");
    }
    return;
}

canonical_original_code:
static void defunct_gw(struct rpc *rpc, void *c)
{
    unsigned int lcr_id; unsigned int gw_id; unsigned int until;
    if (rpc->scan(c, "ddd", &lcr_id, &gw_id, &until) < 3) {
 rpc->fault(c, 400, "lcr_id, gw_id, and timestamp parameters required");
 return;
    }
    if (rpc_defunct_gw(lcr_id, gw_id, until) == 0) {
 rpc->fault(c, 400, "parameter value error (see syslog)");
    }
    return;
}

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:
until
unsigned 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); }


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 func3(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


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 func4(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));
 }
}


reload

decompiled_code:
__int64 __fastcall reload(void (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
futex_get(reload_lock);
if ( (unsigned int)reload_tables() != 1 )
(*a1)(a2, 500LL, "LCR Module Reload Failed");
return futex_release(reload_lock);
}

canonical_decompiled_code:
__int64 __fastcall func5(void (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
func3(reload_lock);
if ( (unsigned int)reload_tables() != 1 )
(*a1)(a2, 500LL, "LCR Module Reload Failed");
return func4(reload_lock);
}

original_code:
static void reload(rpc_t* rpc, void* c)
{
    futex_get(reload_lock);
    if (reload_tables() != 1)
 rpc->fault(c, 500, "LCR Module Reload Failed");
    futex_release(reload_lock);
}

canonical_original_code:
static void reload(struct rpc *rpc, void *c)
{
    futex_get(reload_lock);
    if (reload_tables() != 1)
 rpc->fault(c, 500, "LCR Module Reload Failed");
    futex_release(reload_lock);
}

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 db_gen_init(_QWORD *a1)
{
__int64 result; // rax

*a1 = 0LL;
a1[16] = 0LL;
result = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 136) >> 3));
return result;
}

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

*a1 = 0LL;
a1[16] = 0LL;
result = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 136) >> 3));
return result;
}

original_code:
int db_gen_init(db_gen_t* gen)
{
 memset(gen, '\0', sizeof(db_gen_t));
 return 0;
}

canonical_original_code:
int db_gen_init(struct db_gen *gen)
{
 memset(gen, '\0', sizeof(db_gen_t));
 return 0;
}

variable_types: struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv { void (*free)(struct db_gen *db_struct, struct db_drv *payload); } *data[16]; } *

user_defined_types: struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv *data[16]; }


decompiled_code:
__int64 __fastcall tcp_info(__int64 a1, int a2)
{
__int64 result; // rax
_DWORD v3[10]; // [rsp-Ch] [rbp-28h] BYREF

result = 0LL;
if ( !tcp_disable )
{
tcp_get_info(v3);
if ( a2 == 1 )
{
result = v3[3];
}
else
{
result = 0LL;
if ( a2 == 2 )
result = v3[5];
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
__int64 result; // rax
_DWORD v3[10]; // [rsp-Ch] [rbp-28h] BYREF

result = 0LL;
if ( !tcp_disable )
{
tcp_get_info(v3);
if ( a2 == 1 )
{
result = v3[3];
}
else
{
result = 0LL;
if ( a2 == 2 )
result = v3[5];
}
}
return result;
}

original_code:
static counter_val_t tcp_info(counter_handle_t h, void* what)
{
 enum tcp_info_req w;
 struct tcp_gen_info ti;
 if (tcp_disable)
  return 0;
 w = (int)(long)what;
 tcp_get_info(&ti);
 switch(w) {
  case TCP_INFO_CONN_NO:
   return ti.tcp_connections_no;
  case TCP_INFO_WR_QUEUE_SZ:
   return ti.tcp_write_queued;
  case TCP_INFO_NONE:
   break;
 };
 return 0;
}

canonical_original_code:
static long tcp_info(struct counter_handle_s h, void *what)
{
 enum tcp_info_req w;
 struct tcp_gen_info ti;
 if (tcp_disable)
  return 0;
 w = (int)(long)what;
 tcp_get_info(&ti);
 switch(w) {
  case TCP_INFO_CONN_NO:
   return ti.tcp_connections_no;
  case TCP_INFO_WR_QUEUE_SZ:
   return ti.tcp_write_queued;
  case TCP_INFO_NONE:
   break;
 };
 return 0;
}

variable_types: struct counter_handle_s { unsigned short id; }

variable_types:
what
void *

variable_types: enum tcp_info_req { TCP_INFO_NONE=0, TCP_INFO_CONN_NO=1, TCP_INFO_WR_QUEUE_SZ=2 }

variable_types: struct tcp_gen_info { int tcp_readers; int tcp_max_connections; int tls_max_connections; int tcp_connections_no; int tls_connections_no; int tcp_write_queued; }

return_type: long


decompiled_code:
__int64 tcp_stats_init()
{
return (unsigned int)((int)counter_register_array(&unk_2B2, &tcp_cnt_defs) >> 31);
}

canonical_decompiled_code:
__int64 func1()
{
return (unsigned int)((int)counter_register_array(&unk_2B2, &tcp_cnt_defs) >> 31);
}

original_code:
int tcp_stats_init()
{
 if (counter_register_array("tcp", tcp_cnt_defs) < 0)
  goto error;
 return 0;
error:
 return -1;
}


decompiled_code:
void tcp_stats_destroy()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void tcp_stats_destroy()
{
}

canonical_original_code:
void tcp_stats_destroy()
{
}


original_code:
int netstring_read_fd(int fd, char **netstring) {
  int i, bytes;
 size_t len = 0;
  *netstring = ((void *)0);
 char buffer[10]={0};
 bytes = recv(fd,buffer,10,MSG_PEEK);
 if (bytes<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 < bytes && ((*__ctype_b_loc ())[(int) ((buffer[i]))] & (unsigned short int) _ISdigit); i++) {
    if (i >= 9) return -1;
    len = len*10 + (buffer[i] - '0');
  }
  if (buffer[i++] != ':') return -2;
 size_t read_len = i+len+1;
 char *buffer2 = qm_malloc(mem_block, (read_len));
 if (!buffer2) {
  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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 bytes = recv(fd,buffer2,read_len,0);
  if (read_len > bytes) return -3;
  if (buffer2[read_len-1] != ',') return -4;
 buffer2[read_len-1] = '\0';
 int x;
 for(x=0;x<=read_len-i-1;x++) {
  buffer2[x]=buffer2[x+i];
 }
 *netstring = buffer2;
  return 0;
}

canonical_original_code:
int netstring_read_fd(int fd, char **netstring) {
  int i; int bytes;
 unsigned long len = 0;
  *netstring = ((void *)0);
 char buffer[10] = {0};
 bytes = recv(fd,buffer,10,MSG_PEEK);
 if (bytes<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 < bytes && ((*__ctype_b_loc ())[(int) ((buffer[i]))] & (unsigned short) _ISdigit); i++) {
    if (i >= 9) return -1;
    len = len*10 + (buffer[i] - '0');
  }
  if (buffer[i++] != ':') return -2;
 unsigned long read_len = i+len+1;
 char *buffer2 = qm_malloc(mem_block, (read_len));
 if (!buffer2) {
  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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __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" ":" "71" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 bytes = recv(fd,buffer2,read_len,0);
  if (read_len > bytes) return -3;
  if (buffer2[read_len-1] != ',') return -4;
 buffer2[read_len-1] = '\0';
 int x;
 for(x=0;x<=read_len-i-1;x++) {
  buffer2[x]=buffer2[x+i];
 }
 *netstring = buffer2;
  return 0;
}

variable_types: fd int

variable_types:
netstring
char **

variable_types: bytes int

variable_types:
len
unsigned long

variable_types:
buffer
char [10]

variable_types: x int

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


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 *


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


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:
data
char *

variable_types:
ns
char *


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 *


decompiled_code:
__int64 MD5Update()
{
return U_MD5Update();
}

canonical_decompiled_code:
__int64 func1()
{
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 *


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


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