decompiled_code:
__int64 __fastcall save_msg_lumps(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rdx
__int64 v4; // rcx
const char *v6; // r13
unsigned int v7; // eax
const char *v8; // r13
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // rdx
const char *v12; // rbx
unsigned int v13; // eax
struct _IO_FILE *v14; // rdi
const char *v15; // r8
const char *v16; // r9
const char *v17; // [rsp-10h] [rbp-58h]
__int64 v18; // [rsp-8h] [rbp-50h]
const char *v20; // [rsp-8h] [rbp-50h]
const char *v21; // [rsp+0h] [rbp-48h]
const void *v22; // [rsp+8h] [rbp-40h] BYREF
__int64 v23; // [rsp+10h] [rbp-38h] BYREF
__int64 v24[6]; // [rsp+18h] [rbp-30h] BYREF

if ( lumps_are_cloned )
{
if ( (int)get_debug_level(&LC0, 2LL) > 2 )
{
v2 = dprint_crit;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 16);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: save_msg_lumps: lumps have been already cloned\n",
process_no,
v7,
v6,
"tm [sip_msg.c:119]: ",
"save_msg_lumps");
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: save_msg_lumps: lumps have been already cloned\n",
*((const char **)&log_level_info + 16),
"tm [sip_msg.c:119]: ",
"save_msg_lumps");
}
--dprint_crit;
return v2;
}
}
return 0LL;
}
if ( a1 && (*(_BYTE *)(a1 + 1532) & 0x10) != 0 )
{
if ( *(_DWORD *)(a1 + 32) == 1 )
{
if ( *(_DWORD *)(a1 + 88) != 4 )
{
free_via_clen_lump((__int64 *)(a2 + 1440));
lumps_are_cloned = 1;
v2 = msg_lump_cloner(a2, &v22, &v23, v24);
if ( v2 )
return (unsigned int)((int)v2 >> 31);
v3 = v23;
v4 = v24[0];
*(_QWORD *)(a1 + 1440) = v22;
*(_QWORD *)(a1 + 1448) = v3;
*(_QWORD *)(a1 + 1456) = v4;
return v2;
}
return 0LL;
}
if ( (int)get_debug_level(&LC0, 2LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, the function should be called only for requests\n",
process_no,
v13,
v12,
"tm [sip_msg.c:129]: ",
"save_msg_lumps");
if ( log_color )
dprint_color_reset(
v14,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, the function should be called only for requests\n",
v18,
log_color,
v15,
v16,
v21);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: save_msg_lumps: BUG, the function should be called only for requests\n",
*((const char **)&log_level_info + 8),
"tm [sip_msg.c:129]: ",
"save_msg_lumps");
}
--dprint_crit;
}
}
else if ( (int)get_debug_level(&LC0, 2LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, there is no shmem-ized message (shm_msg=%p)\n",
process_no,
v9,
v8,
"tm [sip_msg.c:124]: ",
"save_msg_lumps",
(const void *)a1);
if ( log_color )
dprint_color_reset(
v10,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, there is no shmem-ized message (shm_msg=%p)\n",
v11,
log_color,
v17,
v20,
v21,
v22);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: save_msg_lumps: BUG, there is no shmem-ized message (shm_msg=%p)\n",
*((const char **)&log_level_info + 8),
"tm [sip_msg.c:124]: ",
"save_msg_lumps",
(const void *)a1);
}
v2 = -1;
--dprint_crit;
return v2;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rdx
__int64 v4; // rcx
const char *v6; // r13
unsigned int v7; // eax
const char *v8; // r13
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // rdx
const char *v12; // rbx
unsigned int v13; // eax
struct _IO_FILE *v14; // rdi
const char *v15; // r8
const char *v16; // r9
const char *v17; // [rsp-10h] [rbp-58h]
__int64 v18; // [rsp-8h] [rbp-50h]
const char *v20; // [rsp-8h] [rbp-50h]
const char *v21; // [rsp+0h] [rbp-48h]
const void *v22; // [rsp+8h] [rbp-40h] BYREF
__int64 v23; // [rsp+10h] [rbp-38h] BYREF
__int64 v24[6]; // [rsp+18h] [rbp-30h] BYREF

if ( lumps_are_cloned )
{
if ( (int)get_debug_level(&LC0, 2LL) > 2 )
{
v2 = dprint_crit;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 16);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): DEBUG: save_msg_lumps: lumps have been already cloned\n",
process_no,
v7,
v6,
"tm [sip_msg.c:119]: ",
"save_msg_lumps");
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): DEBUG: save_msg_lumps: lumps have been already cloned\n",
*((const char **)&log_level_info + 16),
"tm [sip_msg.c:119]: ",
"save_msg_lumps");
}
--dprint_crit;
return v2;
}
}
return 0LL;
}
if ( a1 && (*(_BYTE *)(a1 + 1532) & 0x10) != 0 )
{
if ( *(_DWORD *)(a1 + 32) == 1 )
{
if ( *(_DWORD *)(a1 + 88) != 4 )
{
func0((__int64 *)(a2 + 1440));
lumps_are_cloned = 1;
v2 = msg_lump_cloner(a2, &v22, &v23, v24);
if ( v2 )
return (unsigned int)((int)v2 >> 31);
v3 = v23;
v4 = v24[0];
*(_QWORD *)(a1 + 1440) = v22;
*(_QWORD *)(a1 + 1448) = v3;
*(_QWORD *)(a1 + 1456) = v4;
return v2;
}
return 0LL;
}
if ( (int)get_debug_level(&LC0, 2LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, the function should be called only for requests\n",
process_no,
v13,
v12,
"tm [sip_msg.c:129]: ",
"save_msg_lumps");
if ( log_color )
dprint_color_reset(
v14,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, the function should be called only for requests\n",
v18,
log_color,
v15,
v16,
v21);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: save_msg_lumps: BUG, the function should be called only for requests\n",
*((const char **)&log_level_info + 8),
"tm [sip_msg.c:129]: ",
"save_msg_lumps");
}
--dprint_crit;
}
}
else if ( (int)get_debug_level(&LC0, 2LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, there is no shmem-ized message (shm_msg=%p)\n",
process_no,
v9,
v8,
"tm [sip_msg.c:124]: ",
"save_msg_lumps",
(const void *)a1);
if ( log_color )
dprint_color_reset(
v10,
"%2d(%d) %s: %s%s(): ERROR: save_msg_lumps: BUG, there is no shmem-ized message (shm_msg=%p)\n",
v11,
log_color,
v17,
v20,
v21,
v22);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: save_msg_lumps: BUG, there is no shmem-ized message (shm_msg=%p)\n",
*((const char **)&log_level_info + 8),
"tm [sip_msg.c:124]: ",
"save_msg_lumps",
(const void *)a1);
}
v2 = -1;
--dprint_crit;
return v2;
}
return 0xFFFFFFFFLL;
}

original_code:
int save_msg_lumps( struct sip_msg *shm_msg, struct sip_msg *pkg_msg)
{
 int ret;
 struct lump* add_rm;
 struct lump* body_lumps;
 struct lump_rpl* reply_lump;
 if (lumps_are_cloned) {
  do { if (get_debug_level("tm", (sizeof("tm")-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: save_msg_lumps: lumps have been already cloned\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", (log_level_info[((3)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", process_no, my_pid(), ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 if (__builtin_expect(!!(!shm_msg || ((shm_msg->msg_flags & (1 << 4))==0)), 0)) {
  do { if (get_debug_level("tm", (sizeof("tm")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", process_no, my_pid(), ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (__builtin_expect(!!(shm_msg->first_line.type!=1), 0)) {
  do { if (get_debug_level("tm", (sizeof("tm")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __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(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", process_no, my_pid(), ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __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(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (shm_msg->first_line.u.request.method_value == METHOD_ACK)
  return 0;
 free_via_clen_lump(&pkg_msg->add_rm);
 lumps_are_cloned = 1;
 ret=msg_lump_cloner(pkg_msg, &add_rm, &body_lumps, &reply_lump);
 if (__builtin_expect(!!(ret==0), 1)){
  asm volatile ("" : : : "memory");
  shm_msg->add_rm = add_rm;
  shm_msg->body_lumps = body_lumps;
  shm_msg->reply_lump = reply_lump;
 }
 return ret<0?-1:0;
}

canonical_original_code:
int save_msg_lumps(struct sip_msg *shm_msg, struct sip_msg *pkg_msg)
{
 int ret;
 struct lump *add_rm;
 struct lump *body_lumps;
 struct lump_rpl *reply_lump;
 if (lumps_are_cloned) {
  do { if (get_debug_level("tm", (sizeof("tm")-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: save_msg_lumps: lumps have been already cloned\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", (log_level_info[((3)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", process_no, my_pid(), ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "DEBUG: save_msg_lumps: lumps have been already cloned\n", ("tm" " [" "sip_msg.c" ":" "119" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 if (__builtin_expect(!!(!shm_msg || ((shm_msg->msg_flags & (1 << 4))==0)), 0)) {
  do { if (get_debug_level("tm", (sizeof("tm")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", process_no, my_pid(), ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: save_msg_lumps: BUG, there is no shmem-ized message" " (shm_msg=%p)\n", ("tm" " [" "sip_msg.c" ":" "124" "]: ") , __func__, shm_msg); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (__builtin_expect(!!(shm_msg->first_line.type!=1), 0)) {
  do { if (get_debug_level("tm", (sizeof("tm")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __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(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", (log_level_info[((-1)) - (-5)].name), ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", process_no, my_pid(), ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __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(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: save_msg_lumps: BUG, the function should be called only for requests\n", ("tm" " [" "sip_msg.c" ":" "129" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if (shm_msg->first_line.u.request.method_value == METHOD_ACK)
  return 0;
 free_via_clen_lump(&pkg_msg->add_rm);
 lumps_are_cloned = 1;
 ret=msg_lump_cloner(pkg_msg, &add_rm, &body_lumps, &reply_lump);
 if (__builtin_expect(!!(ret==0), 1)){
  asm volatile ("" : : : "memory");
  shm_msg->add_rm = add_rm;
  shm_msg->body_lumps = body_lumps;
  shm_msg->reply_lump = reply_lump;
 }
 return ret<0?-1:0;
}

variable_types: struct sip_msg { unsigned int id; int pid; struct timeval { long tv_sec; long tv_usec; } tval; struct snd_flags { unsigned char f; unsigned char blst_imask; } fwd_send_flags; struct snd_flags rpl_send_flags; struct msg_start { int type; int len; union { struct { struct _str { char *s; int len; } method; struct _str uri; struct _str version; int method_value; } request; struct { struct _str version; struct _str status; struct _str reason; unsigned int statuscode; } reply; } u; } first_line; struct via_body { int error; struct _str hdr; struct _str name; struct _str version; struct _str transport; struct _str host; short proto; unsigned short port; struct _str port_str; struct _str params; struct _str comment; int bsize; struct via_param { int type; struct _str name; struct _str value; char *start; int size; struct via_param *next; } *param_lst; struct via_param *last_param; struct via_param *branch; struct _str tid; struct via_param *received; struct via_param *rport; struct via_param *i; struct via_param *alias; struct via_body *next; } *via1; struct via_body *via2; struct hdr_field { enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 } type; struct _str name; struct _str body; int len; void *parsed; struct hdr_field *next; } *headers; struct hdr_field *last_header; unsigned long long parsed_flag; struct hdr_field *h_via1; struct hdr_field *h_via2; struct hdr_field *callid; struct hdr_field *to; struct hdr_field *cseq; struct hdr_field *from; struct hdr_field *contact; struct hdr_field *maxforwards; struct hdr_field *route; struct hdr_field *record_route; struct hdr_field *content_type; struct hdr_field *content_length; struct hdr_field *authorization; struct hdr_field *expires; struct hdr_field *proxy_auth; struct hdr_field *supported; struct hdr_field *require; struct hdr_field *proxy_require; struct hdr_field *unsupported; struct hdr_field *allow; struct hdr_field *event; struct hdr_field *accept; struct hdr_field *accept_language; struct hdr_field *organization; struct hdr_field *priority; struct hdr_field *subject; struct hdr_field *user_agent; struct hdr_field *server; struct hdr_field *content_disposition; struct hdr_field *diversion; struct hdr_field *rpid; struct hdr_field *refer_to; struct hdr_field *session_expires; struct hdr_field *min_se; struct hdr_field *sipifmatch; struct hdr_field *subscription_state; struct hdr_field *date; struct hdr_field *identity; struct hdr_field *identity_info; struct hdr_field *pai; struct hdr_field *ppi; struct hdr_field *path; struct hdr_field *privacy; struct msg_body { enum msg_body_type { MSG_BODY_UNKNOWN=0, MSG_BODY_SDP=1 } type; void (*free)(struct msg_body **ptr); } *body; char *eoh; char *unparsed; struct receive_info { 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; } src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; 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; } src_su; struct socket_info { int socket; struct _str name; struct ip_addr 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 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; } *bind_address; char proto; } rcv; char *buf; unsigned int len; struct _str new_uri; struct _str dst_uri; int parsed_uri_ok; struct sip_uri { struct _str user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type { ERROR_URI_T=0, SIP_URI_T=1, SIPS_URI_T=2, TEL_URI_T=3, TELS_URI_T=4, URN_URI_T=5 } type; enum _uri_flags { URI_USER_NORMALIZE=1, URI_SIP_USER_PHONE=2 } flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; } parsed_uri; int parsed_orig_ruri_ok; struct sip_uri parsed_orig_ruri; struct lump { enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 } type; enum lump_op { LUMP_NOP=0, LUMP_DEL=1, LUMP_ADD=2, LUMP_ADD_SUBST=3, LUMP_ADD_OPT=4 } op; union { int offset; enum lump_subst { SUBST_NOP=0, SUBST_RCV_IP=1, SUBST_SND_IP=2, SUBST_RCV_PORT=3, SUBST_SND_PORT=4, SUBST_RCV_PROTO=5, SUBST_SND_PROTO=6, SUBST_RCV_ALL=7, SUBST_SND_ALL=8 } subst; enum lump_conditions { COND_FALSE=0, COND_TRUE=1, COND_IF_DIFF_REALMS=2, COND_IF_DIFF_AF=3, COND_IF_DIFF_PROTO=4, COND_IF_DIFF_PORT=5, COND_IF_DIFF_IP=6, COND_IF_RAND=7 } cond; char *value; } u; int len; struct lump *before; struct lump *after; struct lump *next; enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2, LUMPFLAG_BRANCH=4, LUMPFLAG_COND_TRUE=8 } flags; } *add_rm; struct lump *body_lumps; struct lump_rpl { struct _str text; int flags; struct lump_rpl *next; } *reply_lump; char add_to_branch_s[-1]; int add_to_branch_len; unsigned int hash_index; unsigned int msg_flags; unsigned int flags; struct _str set_global_address; struct _str set_global_port; struct socket_info *force_send_socket; struct _str path_vec; struct _str instance; unsigned int reg_id; struct _str ruid; struct _str location_ua; struct msg_ldata { struct ocd_flow { int decoded; struct receive_info rcv; } flow; } ldv; } *

variable_types: ret int

variable_types: struct lump_rpl { struct _str { char *s; int len; } text; int flags; struct lump_rpl *next; } *

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


repo: virtualolson/who

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

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

return_type: void


decompiled_code:
__int64 __fastcall sdpops_get_ids_by_name(__int64 a1, __m128i *a2)
{
size_t v3; // r14
const char *v4; // rdi
const char *v5; // rdi
const char *v6; // rdi
const char *v7; // rdi
const char *v8; // rdi
const char *v9; // rdi
const char *v10; // rdi
const char *v11; // rdi
const char *v12; // rdi
const char *v13; // rdi
const char *v14; // rdi
const char *v15; // rdi
int v16; // eax
__m128i v17; // xmm0
__int64 result; // rax

if ( sdpops_codecsmap_table )
{
v3 = *(int *)(a1 + 8);
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 2) )
{
v16 = strncasecmp(sdpops_codecsmap_table, *(const char **)a1, *(int *)(a1 + 8));
if ( !v16 )
goto LABEL_29;
}
v4 = *(&sdpops_codecsmap_table + 4);
if ( v4 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 10) && !strncasecmp(v4, *(const char **)a1, v3) )
{
v16 = 1;
goto LABEL_29;
}
v5 = *(&sdpops_codecsmap_table + 8);
if ( v5 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 18) && !strncasecmp(v5, *(const char **)a1, v3) )
{
v16 = 2;
goto LABEL_29;
}
v6 = *(&sdpops_codecsmap_table + 12);
if ( v6 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 26) && !strncasecmp(v6, *(const char **)a1, v3) )
{
v16 = 3;
goto LABEL_29;
}
v7 = *(&sdpops_codecsmap_table + 16);
if ( v7 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 34) && !strncasecmp(v7, *(const char **)a1, v3) )
{
v16 = 4;
goto LABEL_29;
}
v8 = *(&sdpops_codecsmap_table + 20);
if ( v8 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 42) && !strncasecmp(v8, *(const char **)a1, v3) )
{
v16 = 5;
goto LABEL_29;
}
v9 = *(&sdpops_codecsmap_table + 24);
if ( v9 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 50) && !strncasecmp(v9, *(const char **)a1, v3) )
{
v16 = 6;
goto LABEL_29;
}
v10 = *(&sdpops_codecsmap_table + 28);
if ( v10 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 58)
&& !strncasecmp(v10, *(const char **)a1, v3) )
{
v16 = 7;
goto LABEL_29;
}
v11 = *(&sdpops_codecsmap_table + 32);
if ( v11 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 66)
&& !strncasecmp(v11, *(const char **)a1, v3) )
{
v16 = 8;
goto LABEL_29;
}
v12 = *(&sdpops_codecsmap_table + 36);
if ( v12 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 74)
&& !strncasecmp(v12, *(const char **)a1, v3) )
{
v16 = 9;
goto LABEL_29;
}
v13 = *(&sdpops_codecsmap_table + 40);
if ( v13 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 82)
&& !strncasecmp(v13, *(const char **)a1, v3) )
{
v16 = 10;
goto LABEL_29;
}
v14 = *(&sdpops_codecsmap_table + 44);
if ( v14 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 90)
&& !strncasecmp(v14, *(const char **)a1, v3) )
{
v16 = 11;
goto LABEL_29;
}
v15 = *(&sdpops_codecsmap_table + 48);
if ( v15 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 98)
&& !strncasecmp(v15, *(const char **)a1, v3) )
{
v16 = 12;
goto LABEL_29;
}
if ( *(&sdpops_codecsmap_table + 52) )
{
v16 = 13;
LABEL_29:
v17 = _mm_load_si128((const __m128i *)&(&sdpops_codecsmap_table)[4 * v16 + 2]);
result = 0LL;
*a2 = v17;
return result;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
result = 0xFFFFFFFFLL;
a2->m128i_i64[0] = 0LL;
a2->m128i_i32[2] = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __m128i *a2)
{
size_t v3; // r14
const char *v4; // rdi
const char *v5; // rdi
const char *v6; // rdi
const char *v7; // rdi
const char *v8; // rdi
const char *v9; // rdi
const char *v10; // rdi
const char *v11; // rdi
const char *v12; // rdi
const char *v13; // rdi
const char *v14; // rdi
const char *v15; // rdi
int v16; // eax
__m128i v17; // xmm0
__int64 result; // rax

if ( sdpops_codecsmap_table )
{
v3 = *(int *)(a1 + 8);
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 2) )
{
v16 = strncasecmp(sdpops_codecsmap_table, *(const char **)a1, *(int *)(a1 + 8));
if ( !v16 )
goto LABEL_29;
}
v4 = *(&sdpops_codecsmap_table + 4);
if ( v4 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 10) && !strncasecmp(v4, *(const char **)a1, v3) )
{
v16 = 1;
goto LABEL_29;
}
v5 = *(&sdpops_codecsmap_table + 8);
if ( v5 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 18) && !strncasecmp(v5, *(const char **)a1, v3) )
{
v16 = 2;
goto LABEL_29;
}
v6 = *(&sdpops_codecsmap_table + 12);
if ( v6 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 26) && !strncasecmp(v6, *(const char **)a1, v3) )
{
v16 = 3;
goto LABEL_29;
}
v7 = *(&sdpops_codecsmap_table + 16);
if ( v7 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 34) && !strncasecmp(v7, *(const char **)a1, v3) )
{
v16 = 4;
goto LABEL_29;
}
v8 = *(&sdpops_codecsmap_table + 20);
if ( v8 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 42) && !strncasecmp(v8, *(const char **)a1, v3) )
{
v16 = 5;
goto LABEL_29;
}
v9 = *(&sdpops_codecsmap_table + 24);
if ( v9 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 50) && !strncasecmp(v9, *(const char **)a1, v3) )
{
v16 = 6;
goto LABEL_29;
}
v10 = *(&sdpops_codecsmap_table + 28);
if ( v10 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 58)
&& !strncasecmp(v10, *(const char **)a1, v3) )
{
v16 = 7;
goto LABEL_29;
}
v11 = *(&sdpops_codecsmap_table + 32);
if ( v11 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 66)
&& !strncasecmp(v11, *(const char **)a1, v3) )
{
v16 = 8;
goto LABEL_29;
}
v12 = *(&sdpops_codecsmap_table + 36);
if ( v12 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 74)
&& !strncasecmp(v12, *(const char **)a1, v3) )
{
v16 = 9;
goto LABEL_29;
}
v13 = *(&sdpops_codecsmap_table + 40);
if ( v13 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 82)
&& !strncasecmp(v13, *(const char **)a1, v3) )
{
v16 = 10;
goto LABEL_29;
}
v14 = *(&sdpops_codecsmap_table + 44);
if ( v14 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 90)
&& !strncasecmp(v14, *(const char **)a1, v3) )
{
v16 = 11;
goto LABEL_29;
}
v15 = *(&sdpops_codecsmap_table + 48);
if ( v15 )
{
if ( (_DWORD)v3 == *((_DWORD *)&sdpops_codecsmap_table + 98)
&& !strncasecmp(v15, *(const char **)a1, v3) )
{
v16 = 12;
goto LABEL_29;
}
if ( *(&sdpops_codecsmap_table + 52) )
{
v16 = 13;
LABEL_29:
v17 = _mm_load_si128((const __m128i *)&(&sdpops_codecsmap_table)[4 * v16 + 2]);
result = 0LL;
*a2 = v17;
return result;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
result = 0xFFFFFFFFLL;
a2->m128i_i64[0] = 0LL;
a2->m128i_i32[2] = 0;
return result;
}

original_code:
int sdpops_get_ids_by_name(str *name, str *ids)
{
 int i;
 for(i=0; sdpops_codecsmap_table[i].name.s!=0; i++)
 {
  if(name->len==sdpops_codecsmap_table[i].name.len
    && strncasecmp(sdpops_codecsmap_table[i].name.s, name->s,
     name->len)==0)
  {
   *ids = sdpops_codecsmap_table[i].ids;
   return 0;
  }
 }
 ids->s = ((void *)0);
 ids->len = 0;
 return -1;
}

canonical_original_code:
int sdpops_get_ids_by_name(struct _str *name, struct _str *ids)
{
 int i;
 for(i=0; sdpops_codecsmap_table[i].name.s!=0; i++)
 {
  if(name->len==sdpops_codecsmap_table[i].name.len
    && strncasecmp(sdpops_codecsmap_table[i].name.s, name->s,
     name->len)==0)
  {
   *ids = sdpops_codecsmap_table[i].ids;
   return 0;
  }
 }
 ids->s = ((void *)0);
 ids->len = 0;
 return -1;
}

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

variable_types:
ids
struct _str *

variable_types: i int

return_type: int


decompiled_code:
__int64 __fastcall sdpops_sdp_get_ids_by_name(__int64 a1, __int64 a2, __int64 a3, int a4)
{
unsigned int v4; // er15
int v6; // ebx
unsigned int i; // er12
__int64 v8; // rax
const __m128i *v9; // r13
size_t v10; // rdx
__m128i v11; // xmm0
__int64 v12; // rax
__int64 result; // rax

v4 = 0;
v6 = 0;
LABEL_2:
if ( get_sdp_session_sdp(a1, v4) )
{
for ( i = 0; ; ++i )
{
v8 = get_sdp_stream_sdp(a1, v4, i);
if ( !v8 )
{
++v4;
goto LABEL_2;
}
v9 = *(const __m128i **)(v8 + 288);
if ( v9 )
break;
LABEL_12:
;
}
while ( 1 )
{
while ( 1 )
{
v10 = *(int *)(a2 + 8);
if ( v9[2].m128i_i32[2] == (_DWORD)v10
&& !strncasecmp(*(const char **)a2, (const char *)v9[2].m128i_i64[0], v10) )
{
break;
}
v9 = (const __m128i *)v9->m128i_i64[0];
if ( !v9 )
goto LABEL_12;
}
if ( a4 == v6 )
goto LABEL_13;
v11 = _mm_loadu_si128(v9 + 1);
v12 = v6;
v9 = (const __m128i *)v9->m128i_i64[0];
++v6;
*(__m128i *)(a3 + 16 * v12) = v11;
if ( !v9 )
goto LABEL_12;
}
}
if ( !v6 )
{
LABEL_13:
*(_QWORD *)a3 = 0LL;
result = 0xFFFFFFFFLL;
*(_DWORD *)(a3 + 8) = 0;
return result;
}
result = 0LL;
if ( v6 < a4 )
*(_QWORD *)(a3 + 16LL * v6) = 0LL;
return result;
}

original_code:
int sdpops_sdp_get_ids_by_name(sdp_info_t *sdp, str *cname, str *cids, int n)
{
 int sdp_session_num;
 int sdp_stream_num;
 sdp_session_cell_t *sdp_session;
 sdp_stream_cell_t *sdp_stream;
 sdp_payload_attr_t *sdp_payload;
 int i;
 sdp_session_num = 0;
 i = 0;
 for(;;)
 {
  sdp_session = get_sdp_session_sdp(sdp, sdp_session_num);
  if(!sdp_session) break;
  sdp_stream_num = 0;
  for(;;)
  {
   sdp_stream = get_sdp_stream_sdp(sdp, sdp_session_num,
       sdp_stream_num);
   if(!sdp_stream) break;
   sdp_payload = sdp_stream->payload_attr;
   while (sdp_payload) {
    if(sdp_payload->rtp_enc.len==cname->len
      && strncasecmp(cname->s, sdp_payload->rtp_enc.s,
        cname->len)==0)
    {
     if(i==n)
      goto notfound;
     cids[i] = sdp_payload->rtp_payload;
     i++;
    }
    sdp_payload=sdp_payload->next;
   }
   sdp_stream_num++;
  }
  sdp_session_num++;
 }
 if(i==0)
  goto notfound;
 if(i<n)
  cids[i].s = ((void *)0);
 return 0;
notfound:
 cids[0].s = ((void *)0);
 cids[0].len = 0;
 return -1;
}

canonical_original_code:
int sdpops_sdp_get_ids_by_name(struct sdp_info *sdp, struct _str *cname, struct _str *cids, int n)
{
 int sdp_session_num;
 int sdp_stream_num;
 struct sdp_session_cell *sdp_session;
 struct sdp_stream_cell *sdp_stream;
 struct sdp_payload_attr *sdp_payload;
 int i;
 sdp_session_num = 0;
 i = 0;
 for(;;)
 {
  sdp_session = get_sdp_session_sdp(sdp, sdp_session_num);
  if(!sdp_session) break;
  sdp_stream_num = 0;
  for(;;)
  {
   sdp_stream = get_sdp_stream_sdp(sdp, sdp_session_num,
       sdp_stream_num);
   if(!sdp_stream) break;
   sdp_payload = sdp_stream->payload_attr;
   while (sdp_payload) {
    if(sdp_payload->rtp_enc.len==cname->len
      && strncasecmp(cname->s, sdp_payload->rtp_enc.s,
        cname->len)==0)
    {
     if(i==n)
      goto notfound;
     cids[i] = sdp_payload->rtp_payload;
     i++;
    }
    sdp_payload=sdp_payload->next;
   }
   sdp_stream_num++;
  }
  sdp_session_num++;
 }
 if(i==0)
  goto notfound;
 if(i<n)
  cids[i].s = ((void *)0);
 return 0;
notfound:
 cids[0].s = ((void *)0);
 cids[0].len = 0;
 return -1;
}

variable_types: struct sdp_info { enum msg_body_type { MSG_BODY_UNKNOWN=0, MSG_BODY_SDP=1 } type; void (*free)(struct msg_body { enum msg_body_type { MSG_BODY_UNKNOWN=0, MSG_BODY_SDP=1 } type; void (*free)(struct msg_body **ptr); } **ptr); struct _str { char *s; int len; } text; int sessions_num; int streams_num; struct _str raw_sdp; struct sdp_session_cell { struct sdp_session_cell *next; int session_num; struct _str cnt_disp; int pf; struct _str ip_addr; int o_pf; struct _str o_ip_addr; struct _str bw_type; struct _str bw_width; int streams_num; struct sdp_stream_cell { struct sdp_stream_cell *next; int pf; struct _str ip_addr; int stream_num; int is_rtp; int is_on_hold; struct _str media; struct _str port; struct _str transport; struct _str sendrecv_mode; struct _str ptime; struct _str payloads; int payloads_num; struct _str bw_type; struct _str bw_width; struct _str rtcp_port; struct _str path; struct _str max_size; struct _str accept_types; struct _str accept_wrapped_types; struct _str raw_stream; struct sdp_payload_attr { struct sdp_payload_attr *next; int payload_num; struct _str rtp_payload; struct _str rtp_enc; struct _str rtp_clock; struct _str rtp_params; struct _str fmtp_string; } **p_payload_attr; struct sdp_payload_attr *payload_attr; int ice_attrs_num; struct sdp_ice_attr { struct sdp_ice_attr *next; struct _str foundation; unsigned int component_id; struct _str transport; struct _str connection_addr; struct _str port; struct _str candidate_type; int candidateType; } *ice_attr; struct _str remote_candidates; } *streams; } *sessions; } *

variable_types:
cname
struct _str *

variable_types:
cids
struct _str *

variable_types: n int

variable_types: struct sdp_session_cell { struct sdp_session_cell *next; int session_num; struct _str { char *s; int len; } cnt_disp; int pf; struct _str ip_addr; int o_pf; struct _str o_ip_addr; struct _str bw_type; struct _str bw_width; int streams_num; struct sdp_stream_cell { struct sdp_stream_cell *next; int pf; struct _str ip_addr; int stream_num; int is_rtp; int is_on_hold; struct _str media; struct _str port; struct _str transport; struct _str sendrecv_mode; struct _str ptime; struct _str payloads; int payloads_num; struct _str bw_type; struct _str bw_width; struct _str rtcp_port; struct _str path; struct _str max_size; struct _str accept_types; struct _str accept_wrapped_types; struct _str raw_stream; struct sdp_payload_attr { struct sdp_payload_attr *next; int payload_num; struct _str rtp_payload; struct _str rtp_enc; struct _str rtp_clock; struct _str rtp_params; struct _str fmtp_string; } **p_payload_attr; struct sdp_payload_attr *payload_attr; int ice_attrs_num; struct sdp_ice_attr { struct sdp_ice_attr *next; struct _str foundation; unsigned int component_id; struct _str transport; struct _str connection_addr; struct _str port; struct _str candidate_type; int candidateType; } *ice_attr; struct _str remote_candidates; } *streams; } *

variable_types: struct sdp_stream_cell { struct sdp_stream_cell *next; int pf; struct _str { char *s; int len; } ip_addr; int stream_num; int is_rtp; int is_on_hold; struct _str media; struct _str port; struct _str transport; struct _str sendrecv_mode; struct _str ptime; struct _str payloads; int payloads_num; struct _str bw_type; struct _str bw_width; struct _str rtcp_port; struct _str path; struct _str max_size; struct _str accept_types; struct _str accept_wrapped_types; struct _str raw_stream; struct sdp_payload_attr { struct sdp_payload_attr *next; int payload_num; struct _str rtp_payload; struct _str rtp_enc; struct _str rtp_clock; struct _str rtp_params; struct _str fmtp_string; } **p_payload_attr; struct sdp_payload_attr *payload_attr; int ice_attrs_num; struct sdp_ice_attr { struct sdp_ice_attr *next; struct _str foundation; unsigned int component_id; struct _str transport; struct _str connection_addr; struct _str port; struct _str candidate_type; int candidateType; } *ice_attr; struct _str remote_candidates; } *

variable_types: struct sdp_payload_attr { struct sdp_payload_attr *next; int payload_num; struct _str { char *s; int len; } rtp_payload; struct _str rtp_enc; struct _str rtp_clock; struct _str rtp_params; struct _str fmtp_string; } *

user_defined_types: struct sdp_info { enum msg_body_type type; void (*free)(struct msg_body **ptr); struct _str text; int sessions_num; int streams_num; struct _str raw_sdp; struct sdp_session_cell *sessions; }

user_defined_types: struct sdp_session_cell { struct sdp_session_cell *next; int session_num; struct _str cnt_disp; int pf; struct _str ip_addr; int o_pf; struct _str o_ip_addr; struct _str bw_type; struct _str bw_width; int streams_num; struct sdp_stream_cell *streams; }

user_defined_types: struct sdp_stream_cell { struct sdp_stream_cell *next; int pf; struct _str ip_addr; int stream_num; int is_rtp; int is_on_hold; struct _str media; struct _str port; struct _str transport; struct _str sendrecv_mode; struct _str ptime; struct _str payloads; int payloads_num; struct _str bw_type; struct _str bw_width; struct _str rtcp_port; struct _str path; struct _str max_size; struct _str accept_types; struct _str accept_wrapped_types; struct _str raw_stream; struct sdp_payload_attr **p_payload_attr; struct sdp_payload_attr *payload_attr; int ice_attrs_num; struct sdp_ice_attr *ice_attr; struct _str remote_candidates; }

user_defined_types: struct msg_body { enum msg_body_type type; void (*free)(struct msg_body **ptr); }


original_code:
int str_find_token(str *text, str *result, char delim)
{
 int i;
 if(text==((void *)0) || result==((void *)0))
  return -1;
 if(text->s[0] == delim)
 {
   text->s += 1;
   text->len -= 1;
 }
 trim_leading(text);
 result->s = text->s;
 result->len = 0;
 for (i=0; i<text->len; i++)
 {
  if(result->s[i]==delim || result->s[i]=='\0'
    || result->s[i]=='\r' || result->s[i]=='\n')
   return 0;
  result->len++;
 }
 return 0;
}

canonical_original_code:
int str_find_token(struct _str *text, struct _str *result, char delim)
{
 int i;
 if(text==((void *)0) || result==((void *)0))
  return -1;
 if(text->s[0] == delim)
 {
   text->s += 1;
   text->len -= 1;
 }
 trim_leading(text);
 result->s = text->s;
 result->len = 0;
 for (i=0; i<text->len; i++)
 {
  if(result->s[i]==delim || result->s[i]=='\0'
    || result->s[i]=='\r' || result->s[i]=='\n')
   return 0;
  result->len++;
 }
 return 0;
}

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

variable_types:
result
struct _str *

variable_types: delim char


decompiled_code:
__int64 __fastcall sdpops_build_ids_list(__int64 a1, const __m128i *a2, _QWORD *a3)
{
char *v4; // rbx
__m128i v5; // xmm0
__m128i *v6; // r13
const char *v7; // rsi
__int32 v8; // er12
unsigned int v9; // er12
int v11; // edi
const char *v12; // r12
unsigned int v13; // eax
__int32 v14; // er15
const char *v15; // r13
unsigned int v16; // eax
__int32 v17; // er15
const char *v18; // r13
unsigned int v19; // eax
int v20; // er13
const char *v21; // r15
__int32 v22; // er14
const char *v23; // rbp
unsigned int v24; // eax
const char *v25; // [rsp+0h] [rbp-128h]
const char *v27; // [rsp+30h] [rbp-F8h]
const char *v28; // [rsp+30h] [rbp-F8h]
const char *v29; // [rsp+38h] [rbp-F0h]
const char *v30; // [rsp+38h] [rbp-F0h]
unsigned int v31; // [rsp+40h] [rbp-E8h]
unsigned int v32; // [rsp+40h] [rbp-E8h]
__int32 v33; // [rsp+44h] [rbp-E4h]
__int32 v34; // [rsp+44h] [rbp-E4h]
const char *v35; // [rsp+48h] [rbp-E0h]
const char *v36; // [rsp+48h] [rbp-E0h]
__m128i v37; // [rsp+50h] [rbp-D8h] BYREF
const char *v38; // [rsp+60h] [rbp-C8h] BYREF
unsigned int v39; // [rsp+68h] [rbp-C0h]
__m128i v40; // [rsp+70h] [rbp-B8h] BYREF
__int64 v41; // [rsp+80h] [rbp-A8h]
char v42; // [rsp+F0h] [rbp-38h] BYREF

v4 = local_idslist_1;
v5 = _mm_loadu_si128(a2);
*((_DWORD *)a3 + 2) = 0;
*a3 = 0LL;
v37 = v5;
LABEL_2:
while ( !(unsigned int)str_find_token((__int64)&v37, (__int64)&v38, 44) && (int)v39 > 0 )
{
v37.m128i_i32[2] -= v39;
v37.m128i_i64[0] = (__int64)&v38[v39];
v40.m128i_i64[0] = 0LL;
if ( (unsigned int)sdpops_get_ids_by_name((__int64)&v38, &v40) )
{
if ( !(unsigned int)sdpops_sdp_get_ids_by_name(a1, (__int64)&v38, (__int64)&v40, 8)
&& (int)get_debug_level("sdpops", 6LL) > 2
&& !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v36 = (const char *)v40.m128i_i64[0];
v34 = v40.m128i_i32[2];
v32 = v39;
v17 = a2->m128i_i32[2];
v28 = (const char *)a2->m128i_i64[0];
v18 = (const char *)*((_QWORD *)&log_level_info + 16);
v30 = v38;
v19 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n",
process_no,
v19,
v18,
"sdpops [sdpops_data.c:228]: ",
"sdpops_build_ids_list",
v17,
v28,
v32,
v30,
v34,
v36);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n",
*((_QWORD *)&log_level_info + 16),
"sdpops [sdpops_data.c:228]: ",
"sdpops_build_ids_list",
a2->m128i_u32[2],
a2->m128i_i64[0],
v39,
v38,
v40.m128i_u32[2],
v40.m128i_i64[0]);
}
--dprint_crit;
}
}
else
{
if ( (int)get_debug_level("sdpops", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v29 = v38;
v14 = a2->m128i_i32[2];
v35 = (const char *)v40.m128i_i64[0];
v33 = v40.m128i_i32[2];
v31 = v39;
v15 = (const char *)*((_QWORD *)&log_level_info + 16);
v27 = (const char *)a2->m128i_i64[0];
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n",
process_no,
v16,
v15,
"sdpops [sdpops_data.c:221]: ",
"sdpops_build_ids_list",
v14,
v27,
v31,
v29,
v33,
v35);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n",
*((_QWORD *)&log_level_info + 16),
"sdpops [sdpops_data.c:221]: ",
"sdpops_build_ids_list",
a2->m128i_u32[2],
a2->m128i_i64[0],
v39,
v38,
v40.m128i_u32[2],
v40.m128i_i64[0]);
}
--dprint_crit;
}
v41 = 0LL;
}
v6 = &v40;
while ( 1 )
{
v7 = (const char *)v6->m128i_i64[0];
if ( !v6->m128i_i64[0] )
break;
v8 = v6->m128i_i32[2];
if ( v8 + *((_DWORD *)a3 + 2) > 63 )
{
if ( (int)get_debug_level("sdpops", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): the list with codecs ids is too big\n",
process_no,
v13,
v12,
"sdpops [sdpops_data.c:237]: ",
"sdpops_build_ids_list");
if ( log_color )
((void (__fastcall *)())dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): the list with codecs ids is too big\n",
*((const char **)&log_level_info + 8),
"sdpops [sdpops_data.c:237]: ",
"sdpops_build_ids_list");
}
--dprint_crit;
}
*((_DWORD *)a3 + 2) = 0;
v9 = -1;
*a3 = 0LL;
return v9;
}
++v6;
strncpy(v4, v7, v8);
v4 += v8 + 1;
*(v4 - 1) = 44;
*((_DWORD *)a3 + 2) += v8 + 1;
if ( &v42 == (char *)v6 )
goto LABEL_2;
}
}
v11 = *((_DWORD *)a3 + 2);
v9 = -1;
if ( v11 > 0 )
{
v9 = 0;
*((_DWORD *)a3 + 2) = v11 - 1;
*(v4 - 1) = 0;
*a3 = local_idslist_1;
if ( (int)get_debug_level("sdpops", 6LL) > 2 )
{
v9 = dprint_crit;
if ( dprint_crit )
{
v9 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v20 = *((_DWORD *)a3 + 2);
v21 = (const char *)a2->m128i_i64[0];
v22 = a2->m128i_i32[2];
v25 = (const char *)*a3;
v23 = (const char *)*((_QWORD *)&log_level_info + 16);
v24 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): codecs list [%.*s] - ids list [%.*s]\n",
process_no,
v24,
v23,
"sdpops [sdpops_data.c:255]: ",
"sdpops_build_ids_list",
v22,
v21,
v20,
v25);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): codecs list [%.*s] - ids list [%.*s]\n",
*((_QWORD *)&log_level_info + 16),
"sdpops [sdpops_data.c:255]: ",
"sdpops_build_ids_list",
a2->m128i_u32[2],
a2->m128i_i64[0],
*((unsigned int *)a3 + 2),
*a3);
}
--dprint_crit;
}
}
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const __m128i *a2, _QWORD *a3)
{
char *v4; // rbx
__m128i v5; // xmm0
__m128i *v6; // r13
const char *v7; // rsi
__int32 v8; // er12
unsigned int v9; // er12
int v11; // edi
const char *v12; // r12
unsigned int v13; // eax
__int32 v14; // er15
const char *v15; // r13
unsigned int v16; // eax
__int32 v17; // er15
const char *v18; // r13
unsigned int v19; // eax
int v20; // er13
const char *v21; // r15
__int32 v22; // er14
const char *v23; // rbp
unsigned int v24; // eax
const char *v25; // [rsp+0h] [rbp-128h]
const char *v27; // [rsp+30h] [rbp-F8h]
const char *v28; // [rsp+30h] [rbp-F8h]
const char *v29; // [rsp+38h] [rbp-F0h]
const char *v30; // [rsp+38h] [rbp-F0h]
unsigned int v31; // [rsp+40h] [rbp-E8h]
unsigned int v32; // [rsp+40h] [rbp-E8h]
__int32 v33; // [rsp+44h] [rbp-E4h]
__int32 v34; // [rsp+44h] [rbp-E4h]
const char *v35; // [rsp+48h] [rbp-E0h]
const char *v36; // [rsp+48h] [rbp-E0h]
__m128i v37; // [rsp+50h] [rbp-D8h] BYREF
const char *v38; // [rsp+60h] [rbp-C8h] BYREF
unsigned int v39; // [rsp+68h] [rbp-C0h]
__m128i v40; // [rsp+70h] [rbp-B8h] BYREF
__int64 v41; // [rsp+80h] [rbp-A8h]
char v42; // [rsp+F0h] [rbp-38h] BYREF

v4 = local_idslist_1;
v5 = _mm_loadu_si128(a2);
*((_DWORD *)a3 + 2) = 0;
*a3 = 0LL;
v37 = v5;
LABEL_2:
while ( !(unsigned int)func3((__int64)&v37, (__int64)&v38, 44) && (int)v39 > 0 )
{
v37.m128i_i32[2] -= v39;
v37.m128i_i64[0] = (__int64)&v38[v39];
v40.m128i_i64[0] = 0LL;
if ( (unsigned int)func1((__int64)&v38, &v40) )
{
if ( !(unsigned int)func2(a1, (__int64)&v38, (__int64)&v40, 8)
&& (int)get_debug_level("sdpops", 6LL) > 2
&& !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v36 = (const char *)v40.m128i_i64[0];
v34 = v40.m128i_i32[2];
v32 = v39;
v17 = a2->m128i_i32[2];
v28 = (const char *)a2->m128i_i64[0];
v18 = (const char *)*((_QWORD *)&log_level_info + 16);
v30 = v38;
v19 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n",
process_no,
v19,
v18,
"sdpops [sdpops_data.c:228]: ",
"sdpops_build_ids_list",
v17,
v28,
v32,
v30,
v34,
v36);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n",
*((_QWORD *)&log_level_info + 16),
"sdpops [sdpops_data.c:228]: ",
"sdpops_build_ids_list",
a2->m128i_u32[2],
a2->m128i_i64[0],
v39,
v38,
v40.m128i_u32[2],
v40.m128i_i64[0]);
}
--dprint_crit;
}
}
else
{
if ( (int)get_debug_level("sdpops", 6LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v29 = v38;
v14 = a2->m128i_i32[2];
v35 = (const char *)v40.m128i_i64[0];
v33 = v40.m128i_i32[2];
v31 = v39;
v15 = (const char *)*((_QWORD *)&log_level_info + 16);
v27 = (const char *)a2->m128i_i64[0];
v16 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n",
process_no,
v16,
v15,
"sdpops [sdpops_data.c:221]: ",
"sdpops_build_ids_list",
v14,
v27,
v31,
v29,
v33,
v35);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n",
*((_QWORD *)&log_level_info + 16),
"sdpops [sdpops_data.c:221]: ",
"sdpops_build_ids_list",
a2->m128i_u32[2],
a2->m128i_i64[0],
v39,
v38,
v40.m128i_u32[2],
v40.m128i_i64[0]);
}
--dprint_crit;
}
v41 = 0LL;
}
v6 = &v40;
while ( 1 )
{
v7 = (const char *)v6->m128i_i64[0];
if ( !v6->m128i_i64[0] )
break;
v8 = v6->m128i_i32[2];
if ( v8 + *((_DWORD *)a3 + 2) > 63 )
{
if ( (int)get_debug_level("sdpops", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): the list with codecs ids is too big\n",
process_no,
v13,
v12,
"sdpops [sdpops_data.c:237]: ",
"sdpops_build_ids_list");
if ( log_color )
((void (__fastcall *)())dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): the list with codecs ids is too big\n",
*((const char **)&log_level_info + 8),
"sdpops [sdpops_data.c:237]: ",
"sdpops_build_ids_list");
}
--dprint_crit;
}
*((_DWORD *)a3 + 2) = 0;
v9 = -1;
*a3 = 0LL;
return v9;
}
++v6;
strncpy(v4, v7, v8);
v4 += v8 + 1;
*(v4 - 1) = 44;
*((_DWORD *)a3 + 2) += v8 + 1;
if ( &v42 == (char *)v6 )
goto LABEL_2;
}
}
v11 = *((_DWORD *)a3 + 2);
v9 = -1;
if ( v11 > 0 )
{
v9 = 0;
*((_DWORD *)a3 + 2) = v11 - 1;
*(v4 - 1) = 0;
*a3 = local_idslist_1;
if ( (int)get_debug_level("sdpops", 6LL) > 2 )
{
v9 = dprint_crit;
if ( dprint_crit )
{
v9 = 0;
}
else
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v20 = *((_DWORD *)a3 + 2);
v21 = (const char *)a2->m128i_i64[0];
v22 = a2->m128i_i32[2];
v25 = (const char *)*a3;
v23 = (const char *)*((_QWORD *)&log_level_info + 16);
v24 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): codecs list [%.*s] - ids list [%.*s]\n",
process_no,
v24,
v23,
"sdpops [sdpops_data.c:255]: ",
"sdpops_build_ids_list",
v22,
v21,
v20,
v25);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): codecs list [%.*s] - ids list [%.*s]\n",
*((_QWORD *)&log_level_info + 16),
"sdpops [sdpops_data.c:255]: ",
"sdpops_build_ids_list",
a2->m128i_u32[2],
a2->m128i_i64[0],
*((unsigned int *)a3 + 2),
*a3);
}
--dprint_crit;
}
}
}
return v9;
}

original_code:
int sdpops_build_ids_list(sdp_info_t *sdp, str *names, str *ids)
{
 static char _local_idslist[64];
 str tmp;
 str codec;
 str cids[8];
 char *p;
 int i;
 tmp = *names;
 ids->len = 0;
 ids->s = 0;
 p = _local_idslist;
 while(str_find_token(&tmp, &codec, ',')==0
  && codec.len>0)
 {
  tmp.len -= (int)(&codec.s[codec.len]-codec.s);
  tmp.s = codec.s + codec.len;
  cids[0].s = ((void *)0);
  if(sdpops_get_ids_by_name(&codec, &cids[0])==0) {
   do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } (dprint_crit--); } } while(0);
   cids[1].s = ((void *)0);
  } else {
   if(sdpops_sdp_get_ids_by_name(sdp, &codec, cids, 8)==0) {
    do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } (dprint_crit--); } } while(0);
   }
  }
  for(i=0; i<8 && cids[i].s!=((void *)0); i++) {
   if(ids->len + cids[i].len>=64)
   {
    do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "the list with codecs ids is too big\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __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(): " "the list with codecs ids is too big\n", (log_level_info[((-1)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "the list with codecs ids is too big\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __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(): " "the list with codecs ids is too big\n", ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "the list with codecs ids is too big\n", ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    ids->len = 0;
    ids->s = 0;
    return -1;
   }
   strncpy(p, cids[i].s, cids[i].len);
   p += cids[i].len;
   *p = ',';
   p++;
   ids->len += cids[i].len + 1;
  }
 }
 if(ids->len>0)
 {
  p--;
  ids->len--;
  *p = '\0';
  ids->s = _local_idslist;
  do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "codecs list [%.*s] - ids list [%.*s]\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); } } (dprint_crit--); } } while(0);
  return 0;
 }
 return -1;
}

canonical_original_code:
int sdpops_build_ids_list(struct sdp_info *sdp, struct _str *names, struct _str *ids)
{
 static char _local_idslist[64];
 struct _str tmp;
 struct _str codec;
 struct _str cids[8];
 char *p;
 int i;
 tmp = *names;
 ids->len = 0;
 ids->s = 0;
 p = _local_idslist;
 while(str_find_token(&tmp, &codec, ',')==0
  && codec.len>0)
 {
  tmp.len -= (int)(&codec.s[codec.len]-codec.s);
  tmp.s = codec.s + codec.len;
  cids[0].s = ((void *)0);
  if(sdpops_get_ids_by_name(&codec, &cids[0])==0) {
   do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with list ids [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "221" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } (dprint_crit--); } } while(0);
   cids[1].s = ((void *)0);
  } else {
   if(sdpops_sdp_get_ids_by_name(sdp, &codec, cids, 8)==0) {
    do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - at name [%.*s] with first sdp id [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "228" "]: ") , __func__, names->len, names->s, codec.len, codec.s, cids[0].len, cids[0].s); } } (dprint_crit--); } } while(0);
   }
  }
  for(i=0; i<8 && cids[i].s!=((void *)0); i++) {
   if(ids->len + cids[i].len>=64)
   {
    do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "the list with codecs ids is too big\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __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(): " "the list with codecs ids is too big\n", (log_level_info[((-1)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "the list with codecs ids is too big\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __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(): " "the list with codecs ids is too big\n", ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "the list with codecs ids is too big\n", ("sdpops" " [" "sdpops_data.c" ":" "237" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    ids->len = 0;
    ids->s = 0;
    return -1;
   }
   strncpy(p, cids[i].s, cids[i].len);
   p += cids[i].len;
   *p = ',';
   p++;
   ids->len += cids[i].len + 1;
  }
 }
 if(ids->len>0)
 {
  p--;
  ids->len--;
  *p = '\0';
  ids->s = _local_idslist;
  do { if (get_debug_level("sdpops", (sizeof("sdpops")-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(): " "codecs list [%.*s] - ids list [%.*s]\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", (log_level_info[((3)) - (-5)].name), ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", process_no, my_pid(), ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "codecs list [%.*s] - ids list [%.*s]\n", ("sdpops" " [" "sdpops_data.c" ":" "255" "]: ") , __func__, names->len, names->s, ids->len, ids->s); } } (dprint_crit--); } } while(0);
  return 0;
 }
 return -1;
}

variable_types:
names
struct _str *

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

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

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

variable_types:
p
char *

user_defined_types: enum msg_body_type { MSG_BODY_UNKNOWN=0, MSG_BODY_SDP=1 }

user_defined_types: struct sdp_ice_attr { struct sdp_ice_attr *next; struct _str foundation; unsigned int component_id; struct _str transport; struct _str connection_addr; struct _str port; struct _str candidate_type; int candidateType; }

user_defined_types: struct sdp_payload_attr { struct sdp_payload_attr *next; int payload_num; struct _str rtp_payload; struct _str rtp_enc; struct _str rtp_clock; struct _str rtp_params; struct _str fmtp_string; }


decompiled_code:
__int64 __fastcall find_mime(int *a1, int a2)
{
int v2; // edx
__int64 result; // rax

v2 = *a1;
if ( !*a1 )
return 0xFFFFFFFFLL;
result = 0LL;
while ( a2 != v2 )
{
v2 = a1[++result];
if ( !v2 )
return 0xFFFFFFFFLL;
}
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, int a2)
{
int v2; // edx
__int64 result; // rax

v2 = *a1;
if ( !*a1 )
return 0xFFFFFFFFLL;
result = 0LL;
while ( a2 != v2 )
{
v2 = a1[++result];
if ( !v2 )
return 0xFFFFFFFFLL;
}
return (unsigned int)result;
}

original_code:
static int find_mime(int *mimes, int m)
{
 int i;
 for (i = 0; mimes[i]; i++) {
  if (mimes[i] == m) return i;
 }
 return -1;
}

variable_types:
mimes
int *

variable_types: m int


decompiled_code:
__int64 __fastcall get_accepted_mime_type_idx(int *a1, __int64 a2)
{
int v2; // esi
__int64 v3; // rcx
__int64 v4; // r9
unsigned int v5; // er10

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a2 + 4);
if ( !v2 )
return 0xFFFFFFFFLL;
while ( (int)find_mime(a1, v2) < 0 )
{
v2 = *(_DWORD *)(v4 + 4 * (v3 + 1) + 4);
if ( !v2 )
return 0xFFFFFFFFLL;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1, __int64 a2)
{
int v2; // esi
__int64 v3; // rcx
__int64 v4; // r9
unsigned int v5; // er10

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a2 + 4);
if ( !v2 )
return 0xFFFFFFFFLL;
while ( (int)func0(a1, v2) < 0 )
{
v2 = *(_DWORD *)(v4 + 4 * (v3 + 1) + 4);
if ( !v2 )
return 0xFFFFFFFFLL;
}
return v5;
}

original_code:
static int get_accepted_mime_type_idx(int *accepts_mimes, event_mimetypes_t *em)
{
 int i, mt;
 if (accepts_mimes) {
  i = 0;
  while ((mt = em->mimes[i]) != 0) {
   if (find_mime(accepts_mimes, mt) >= 0) return i;
   i++;
  }
 }
 return -1;
}

canonical_original_code:
static int get_accepted_mime_type_idx(int *accepts_mimes, struct event_mimetypes_t *em)
{
 int i; int mt;
 if (accepts_mimes) {
  i = 0;
  while ((mt = em->mimes[i]) != 0) {
   if (find_mime(accepts_mimes, mt) >= 0) return i;
   i++;
  }
 }
 return -1;
}

variable_types: struct event_mimetypes_t { int event_type; int mimes[128]; } *

variable_types: i int

variable_types: mt int


decompiled_code:
int *__fastcall find_event_mimetypes(int a1)
{
__int64 v1; // rcx

if ( event_package_mimetypes[0] == -1 || a1 == event_package_mimetypes[0] )
return event_package_mimetypes;
if ( a1 == dword_524 || (v1 = 2LL, dword_524 == -1) )
v1 = 1LL;
return &event_package_mimetypes[129 * v1];
}

canonical_decompiled_code:
int *__fastcall func2(int a1)
{
__int64 v1; // rcx

if ( event_package_mimetypes[0] == -1 || a1 == event_package_mimetypes[0] )
return event_package_mimetypes;
if ( a1 == dword_524 || (v1 = 2LL, dword_524 == -1) )
v1 = 1LL;
return &event_package_mimetypes[129 * v1];
}

original_code:
event_mimetypes_t *find_event_mimetypes(int et)
{
 int i;
 event_mimetypes_t *em;
 i = 0;
 while (et != event_package_mimetypes[i].event_type) {
  if (event_package_mimetypes[i].event_type == -1) break;
  i++;
 }
 em = &event_package_mimetypes[i];
 return em;
}

canonical_original_code:
struct event_mimetypes_t *find_event_mimetypes(int et)
{
 int i;
 struct event_mimetypes_t *em;
 i = 0;
 while (et != event_package_mimetypes[i].event_type) {
  if (event_package_mimetypes[i].event_type == -1) break;
  i++;
 }
 em = &event_package_mimetypes[i];
 return em;
}

variable_types: et int

return_type: struct event_mimetypes_t { int event_type; int mimes[128]; } *


decompiled_code:
__int64 __fastcall check_mime_types(int *a1, __int64 a2)
{
__int64 result; // rax
int v3; // er9
int v4; // eax
int *v5; // rcx
int v6; // er9
int v7; // edx

result = 0LL;
if ( a1 )
{
v3 = *(_DWORD *)(a2 + 4);
if ( v3 )
{
while ( 1 )
{
v4 = find_mime(a1, v3);
if ( v4 >= 0 )
break;
v3 = *v5;
if ( !*v5 )
goto LABEL_7;
}
v7 = *a1;
*a1 = v6;
a1[v4] = v7;
result = 0LL;
}
else
{
LABEL_7:
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, __int64 a2)
{
__int64 result; // rax
int v3; // er9
int v4; // eax
int *v5; // rcx
int v6; // er9
int v7; // edx

result = 0LL;
if ( a1 )
{
v3 = *(_DWORD *)(a2 + 4);
if ( v3 )
{
while ( 1 )
{
v4 = func0(a1, v3);
if ( v4 >= 0 )
break;
v3 = *v5;
if ( !*v5 )
goto LABEL_7;
}
v7 = *a1;
*a1 = v6;
a1[v4] = v7;
result = 0LL;
}
else
{
LABEL_7:
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int check_mime_types(int *accepts_mimes, event_mimetypes_t *em)
{
 if (accepts_mimes) {
  int j = 0, k;
  int mimetype;
  while ((mimetype = em->mimes[j]) != 0) {
   k = find_mime(accepts_mimes, mimetype);
   if (k >= 0) {
    int am0 = accepts_mimes[0];
    accepts_mimes[0] = mimetype;
    accepts_mimes[k] = am0;
    return 0;
   }
   j++;
  }
  return -1;
 }
 return 0;
}

canonical_original_code:
int check_mime_types(int *accepts_mimes, struct event_mimetypes_t *em)
{
 if (accepts_mimes) {
  int j = 0; int k;
  int mimetype;
  while ((mimetype = em->mimes[j]) != 0) {
   k = find_mime(accepts_mimes, mimetype);
   if (k >= 0) {
    int am0 = accepts_mimes[0];
    accepts_mimes[0] = mimetype;
    accepts_mimes[k] = am0;
    return 0;
   }
   j++;
  }
  return -1;
 }
 return 0;
}

variable_types: j int

variable_types: k int

variable_types: mimetype int

user_defined_types: struct event_mimetypes_t { int event_type; int mimes[128]; }


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

v1 = &dword_E4;
srandom(a1);
do
{
v1 += 8;
*(v1 - 8) = random();
*(v1 - 7) = random();
*(v1 - 6) = random();
*(v1 - 5) = random();
*(v1 - 4) = random();
*(v1 - 3) = random();
*(v1 - 2) = random();
*(v1 - 1) = random();
}
while ( v1 != (int *)&unk_4E4 );
return randinit(&is_ctx, 1LL);
}

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

v1 = &dword_E4;
srandom(a1);
do
{
v1 += 8;
*(v1 - 8) = random();
*(v1 - 7) = random();
*(v1 - 6) = random();
*(v1 - 5) = random();
*(v1 - 4) = random();
*(v1 - 3) = random();
*(v1 - 2) = random();
*(v1 - 1) = random();
}
while ( v1 != (int *)&unk_4E4 );
return randinit(&is_ctx, 1LL);
}

original_code:
void fastrand_seed(unsigned int seed)
{
 int i;
 srandom(seed);
 for (i=0; i<(1<<(8)); i++)
  is_ctx.randrsl[i]=random();
 randinit(&is_ctx, 1);
}

variable_types:
seed
unsigned int


fastrand

decompiled_code:
__int64 fastrand()
{
int v0; // edx
__int64 v1; // rax
__int64 result; // rax

v0 = is_ctx;
v1 = (unsigned int)--is_ctx;
if ( v0 )
return (unsigned int)dword_E4[v1];
isaac(&is_ctx);
result = (unsigned int)dword_4E0;
is_ctx = 255;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // edx
__int64 v1; // rax
__int64 result; // rax

v0 = is_ctx;
v1 = (unsigned int)--is_ctx;
if ( v0 )
return (unsigned int)dword_E4[v1];
isaac(&is_ctx);
result = (unsigned int)dword_4E0;
is_ctx = 255;
return result;
}

original_code:
unsigned int fastrand()
{
 return (!(&is_ctx)->randcnt-- ? (isaac(&is_ctx), (&is_ctx)->randcnt=(1<<(8))-1, (&is_ctx)->randrsl[(&is_ctx)->randcnt]) : (&is_ctx)->randrsl[(&is_ctx)->randcnt]);
}

return_type: unsigned int


decompiled_code:
__int64 __fastcall fastrand_max(int a1)
{
return (unsigned int)fastrand() % (a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
return (unsigned int)func1() % (a1 + 1);
}

original_code:
unsigned int fastrand_max(unsigned int max)
{
 return fastrand()%(max+1);
}

variable_types:
max
unsigned int


decompiled_code:
__int64 __fastcall char2int(_BYTE *a1, _DWORD *a2)
{
__int64 result; // rax

if ( (unsigned __int8)(*a1 - 48) > 9u || (unsigned __int8)(a1[1] - 48) > 9u )
return 0xFFFFFFFFLL;
result = 0LL;
*a2 = (char)a1[1] + 10 * (char)(*a1 - 48) - 48;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _DWORD *a2)
{
__int64 result; // rax

if ( (unsigned __int8)(*a1 - 48) > 9u || (unsigned __int8)(a1[1] - 48) > 9u )
return 0xFFFFFFFFLL;
result = 0LL;
*a2 = (char)a1[1] + 10 * (char)(*a1 - 48) - 48;
return result;
}

variable_types:
t
int *


original_code:
static int rfc1123totm (char *stime, struct tm *ttm ) {
 char *ptime = stime;
 unsigned int uval;
 int ires;
 uval = (*(ptime + 0) + (*(ptime + 1) << 8) + (*(ptime + 2) << 16) + (*(ptime + 3) << 24));
 ptime+=4;
 switch (uval) {
  case 0x2c6e7553: ttm->tm_wday = 0; break;
  case 0x2c6e6f4d: ttm->tm_wday = 1; break;
  case 0x2c657554: ttm->tm_wday = 2; break;
  case 0x2c646557: ttm->tm_wday = 3; break;
  case 0x2c756854: ttm->tm_wday = 4; break;
  case 0x2c697246: ttm->tm_wday = 5; break;
  case 0x2c746153: ttm->tm_wday = 6; break;
  default: return -2;
 }
 if (*(ptime++)!=' ') return -3;
 if (char2int(ptime,&ttm->tm_mday) || ttm->tm_mday > 31) return -4;
 ptime+=2;
 if (*(ptime++) != ' ') return -5;
 uval = (*(ptime + 0) + (*(ptime + 1) << 8) + (*(ptime + 2) << 16) + (*(ptime + 3) << 24));
 ptime+=4;
 switch (uval) {
  case 0x206e614a: ttm->tm_mon = 0; break;
  case 0x20626546: ttm->tm_mon = 1; break;
  case 0x2072614d: ttm->tm_mon = 2; break;
  case 0x20727041: ttm->tm_mon = 3; break;
  case 0x2079614d: ttm->tm_mon = 4; break;
  case 0x206e754a: ttm->tm_mon = 5; break;
  case 0x206c754a: ttm->tm_mon = 6; break;
  case 0x20677541: ttm->tm_mon = 7; break;
  case 0x20706553: ttm->tm_mon = 8; break;
  case 0x2074634f: ttm->tm_mon = 9; break;
  case 0x20766f4e: ttm->tm_mon = 10; break;
  case 0x20636544: ttm->tm_mon = 11; break;
  default: return -6;
 }
 if (char2int(ptime,&ires)) return -7;
 ptime+=2;
 if (char2int(ptime,&ttm->tm_year)) return -8;
 ptime+=2;
 ttm->tm_year+=(ires-19)*100;
 if (*(ptime++) != ' ') return -9;
 if (char2int(ptime,&ttm->tm_hour) || ttm->tm_hour > 23) return -10;
 ptime+=2;
 if (*(ptime++) != ':') return -11;
 if (char2int(ptime,&ttm->tm_min) || ttm->tm_min > 59) return -12;
 ptime+=2;
 if (*(ptime++) != ':') return -13;
 if (char2int(ptime,&ttm->tm_sec) || ttm->tm_sec > 59) return -14;
 ptime+=2;
 uval = (*(ptime + 0) + (*(ptime + 1) << 8) + (*(ptime + 2) << 16) + (*(ptime + 3) << 24));
 if ((uval | 0x20202020) != 0x746d6720) return -15;
 return 0;
}

canonical_original_code:
static int rfc1123totm(char *stime, struct tm *ttm) {
 char *ptime = stime;
 unsigned int uval;
 int ires;
 uval = (*(ptime + 0) + (*(ptime + 1) << 8) + (*(ptime + 2) << 16) + (*(ptime + 3) << 24));
 ptime+=4;
 switch (uval) {
  case 0x2c6e7553: ttm->tm_wday = 0; break;
  case 0x2c6e6f4d: ttm->tm_wday = 1; break;
  case 0x2c657554: ttm->tm_wday = 2; break;
  case 0x2c646557: ttm->tm_wday = 3; break;
  case 0x2c756854: ttm->tm_wday = 4; break;
  case 0x2c697246: ttm->tm_wday = 5; break;
  case 0x2c746153: ttm->tm_wday = 6; break;
  default: return -2;
 }
 if (*(ptime++)!=' ') return -3;
 if (char2int(ptime,&ttm->tm_mday) || ttm->tm_mday > 31) return -4;
 ptime+=2;
 if (*(ptime++) != ' ') return -5;
 uval = (*(ptime + 0) + (*(ptime + 1) << 8) + (*(ptime + 2) << 16) + (*(ptime + 3) << 24));
 ptime+=4;
 switch (uval) {
  case 0x206e614a: ttm->tm_mon = 0; break;
  case 0x20626546: ttm->tm_mon = 1; break;
  case 0x2072614d: ttm->tm_mon = 2; break;
  case 0x20727041: ttm->tm_mon = 3; break;
  case 0x2079614d: ttm->tm_mon = 4; break;
  case 0x206e754a: ttm->tm_mon = 5; break;
  case 0x206c754a: ttm->tm_mon = 6; break;
  case 0x20677541: ttm->tm_mon = 7; break;
  case 0x20706553: ttm->tm_mon = 8; break;
  case 0x2074634f: ttm->tm_mon = 9; break;
  case 0x20766f4e: ttm->tm_mon = 10; break;
  case 0x20636544: ttm->tm_mon = 11; break;
  default: return -6;
 }
 if (char2int(ptime,&ires)) return -7;
 ptime+=2;
 if (char2int(ptime,&ttm->tm_year)) return -8;
 ptime+=2;
 ttm->tm_year+=(ires-19)*100;
 if (*(ptime++) != ' ') return -9;
 if (char2int(ptime,&ttm->tm_hour) || ttm->tm_hour > 23) return -10;
 ptime+=2;
 if (*(ptime++) != ':') return -11;
 if (char2int(ptime,&ttm->tm_min) || ttm->tm_min > 59) return -12;
 ptime+=2;
 if (*(ptime++) != ':') return -13;
 if (char2int(ptime,&ttm->tm_sec) || ttm->tm_sec > 59) return -14;
 ptime+=2;
 uval = (*(ptime + 0) + (*(ptime + 1) << 8) + (*(ptime + 2) << 16) + (*(ptime + 3) << 24));
 if ((uval | 0x20202020) != 0x746d6720) return -15;
 return 0;
}

variable_types:
stime
char *

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types:
ptime
char *

variable_types:
uval
unsigned int

variable_types: ires int


decompiled_code:
void __fastcall parse_date(char *a1, __int64 a2, _DWORD *a3)
{
const char *v4; // rbx
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi

*a3 = -1;
if ( a2 - (__int64)a1 <= 28 || (unsigned int)rfc1123totm(a1, (__int64)(a3 + 2)) )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_date: parse error\n",
process_no,
v5,
v4,
"<core> [parser/parse_date.c:157]: ",
"parse_date");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v6,
"%2d(%d) %s: %s%s(): ERROR: parse_date: parse error\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_date: parse error\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_date.c:157]: ",
"parse_date");
}
--dprint_crit;
}
}
else
{
*a3 = 1;
}
}

canonical_decompiled_code:
void __fastcall func2(char *a1, __int64 a2, _DWORD *a3)
{
const char *v4; // rbx
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi

*a3 = -1;
if ( a2 - (__int64)a1 <= 28 || (unsigned int)func1(a1, (__int64)(a3 + 2)) )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_date: parse error\n",
process_no,
v5,
v4,
"<core> [parser/parse_date.c:157]: ",
"parse_date");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v6,
"%2d(%d) %s: %s%s(): ERROR: parse_date: parse error\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_date: parse error\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_date.c:157]: ",
"parse_date");
}
--dprint_crit;
}
}
else
{
*a3 = 1;
}
}

original_code:
void parse_date(char *buffer, char *end, struct date_body *db)
{
 db->error=-1;
 if (end - buffer < 29)
  goto error;
 if (rfc1123totm(buffer,&db->date))
  goto error;
 db->error=1;
 return ;
error:
 do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: parse_date: parse error\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_date.c" ":" "157" "]: ") , __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(): " "ERROR: parse_date: parse error\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_date.c" ":" "157" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_date: parse error\n", process_no, my_pid(), ("<core> [" "parser/parse_date.c" ":" "157" "]: ") , __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(): " "ERROR: parse_date: parse error\n", ("<core> [" "parser/parse_date.c" ":" "157" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_date: parse error\n", ("<core> [" "parser/parse_date.c" ":" "157" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return ;
}

variable_types:
buffer
char *

variable_types:
end
char *

variable_types: struct date_body { int error; struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } date; } *

user_defined_types: struct date_body { int error; struct tm date; }


decompiled_code:
__int64 __fastcall free_date(__int64 a1)
{
return qm_free(mem_block, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return qm_free(mem_block, a1);
}

original_code:
void free_date(struct date_body *db)
{
 qm_free(mem_block, (db));
}

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


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

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

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

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

variable_types:
var
int *

variable_types: v int


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *


decompiled_code:
__int64 __fastcall destroy_failure_route_rule_list(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rdi
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 80);
result = destroy_failure_route_rule(v2);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rdi
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 80);
result = destroy_failure_route_rule(v2);
}
while ( v1 );
}
return result;
}

original_code:
static void destroy_failure_route_rule_list(void *data) {
 struct failure_route_rule *rs, *rs_tmp;
 rs = (struct failure_route_rule *)(data);
 while (rs != ((void *)0)) {
  rs_tmp = rs->next;
  destroy_failure_route_rule(rs);
  rs = rs_tmp;
 }
}

canonical_original_code:
static void destroy_failure_route_rule_list(void *data) {
 struct failure_route_rule *rs; struct failure_route_rule *rs_tmp;
 rs = (struct failure_route_rule *)(data);
 while (rs != ((void *)0)) {
  rs_tmp = rs->next;
  destroy_failure_route_rule(rs);
  rs = rs_tmp;
 }
}

variable_types:
data
void *

variable_types: struct failure_route_rule { struct _str { char *s; int len; } host; struct _str comment; struct _str prefix; struct _str reply_code; int next_domain; unsigned int flags; unsigned int mask; struct failure_route_rule *next; } *

user_defined_types: struct failure_route_rule { struct _str host; struct _str comment; struct _str prefix; struct _str reply_code; int next_domain; unsigned int flags; unsigned int mask; struct failure_route_rule *next; }


decompiled_code:
__int64 __fastcall destroy_route_flags_list(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rdi
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 40);
result = destroy_route_flags(v2);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rdi
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 40);
result = destroy_route_flags(v2);
}
while ( v1 );
}
return result;
}

original_code:
static void destroy_route_flags_list(void *data) {
 struct route_flags *rf, *rf_tmp;
 rf=(struct route_flags *)(data);
 while (rf!=((void *)0)) {
  rf_tmp = rf->next;
  destroy_route_flags(rf);
  rf = rf_tmp;
 }
}

canonical_original_code:
static void destroy_route_flags_list(void *data) {
 struct route_flags *rf; struct route_flags *rf_tmp;
 rf=(struct route_flags *)(data);
 while (rf!=((void *)0)) {
  rf_tmp = rf->next;
  destroy_route_flags(rf);
  rf = rf_tmp;
 }
}

variable_types: struct route_flags { unsigned int flags; unsigned int mask; struct route_rule { int dice_to; double prob; double orig_prob; struct _str { char *s; int len; } host; int strip; struct _str local_prefix; struct _str local_suffix; struct _str comment; struct _str prefix; int status; struct route_rule_p_list { struct route_rule *rr; int hash_index; struct route_rule_p_list *next; } *backed_up; struct route_rule_p_list *backup; int hash_index; struct route_rule *next; } *rule_list; struct route_rule **rules; int rule_num; int dice_max; int max_targets; struct route_flags *next; } *

user_defined_types: struct route_flags { unsigned int flags; unsigned int mask; struct route_rule *rule_list; struct route_rule **rules; int rule_num; int dice_max; int max_targets; struct route_flags *next; }

user_defined_types: struct route_rule { int dice_to; double prob; double orig_prob; struct _str host; int strip; struct _str local_prefix; struct _str local_suffix; struct _str comment; struct _str prefix; int status; struct route_rule_p_list *backed_up; struct route_rule_p_list *backup; int hash_index; struct route_rule *next; }