decompiled_code:
__int64 __fastcall dlg2str(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v3; // rbp
unsigned int v4; // eax
const char *v6; // r12
unsigned int v7; // eax
_BYTE v8[88]; // [rsp+0h] [rbp-58h] BYREF

init_output_sstream(v8, 256LL);
if ( (unsigned int)serialize_dlg((__int64)v8, a1) )
{
if ( (int)get_debug_level("dialog", 6LL) < -1 )
{
v2 = -1;
}
else
{
v2 = -1;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't serialize dialog\n",
process_no,
v4,
v3,
"dialog [serialize_dlg.c:328]: ",
"dlg2str");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't serialize dialog\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:328]: ",
"dlg2str");
}
--dprint_crit;
v2 = -1;
}
}
}
else
{
v2 = get_serialized_sstream(v8, a2);
if ( v2 )
{
if ( (int)get_debug_level("dialog", 6LL) < -1 )
{
v2 = -1;
}
else
{
v2 = -1;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't get serialized dialog data\n",
process_no,
v7,
v6,
"dialog [serialize_dlg.c:333]: ",
"dlg2str");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't get serialized dialog data\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:333]: ",
"dlg2str");
}
--dprint_crit;
v2 = -1;
}
}
}
}
destroy_sstream(v8);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v3; // rbp
unsigned int v4; // eax
const char *v6; // r12
unsigned int v7; // eax
_BYTE v8[88]; // [rsp+0h] [rbp-58h] BYREF

init_output_sstream(v8, 256LL);
if ( (unsigned int)func1((__int64)v8, a1) )
{
if ( (int)get_debug_level("dialog", 6LL) < -1 )
{
v2 = -1;
}
else
{
v2 = -1;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't serialize dialog\n",
process_no,
v4,
v3,
"dialog [serialize_dlg.c:328]: ",
"dlg2str");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't serialize dialog\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:328]: ",
"dlg2str");
}
--dprint_crit;
v2 = -1;
}
}
}
else
{
v2 = get_serialized_sstream(v8, a2);
if ( v2 )
{
if ( (int)get_debug_level("dialog", 6LL) < -1 )
{
v2 = -1;
}
else
{
v2 = -1;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't get serialized dialog data\n",
process_no,
v7,
v6,
"dialog [serialize_dlg.c:333]: ",
"dlg2str");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't get serialized dialog data\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:333]: ",
"dlg2str");
}
--dprint_crit;
v2 = -1;
}
}
}
}
destroy_sstream(v8);
return v2;
}

original_code:
int dlg2str(dlg_t *dlg, str *dst_str)
{
 int res = 0;
 sstream_t store;
 init_output_sstream(&store, 256);
 if (serialize_dlg(&store, dlg) != 0) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't serialize dialog\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __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(): " "can't serialize dialog\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't serialize dialog\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __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(): " "can't serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 else {
  if (get_serialized_sstream(&store, dst_str) != 0) {
   do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't get serialized dialog data\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __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(): " "can't get serialized dialog data\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't get serialized dialog data\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __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(): " "can't get serialized dialog data\n", ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't get serialized dialog data\n", ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   res = -1;
  }
 }
 destroy_sstream(&store);
 return res;
}

canonical_original_code:
int dlg2str(struct dlg *dlg, struct _str *dst_str)
{
 int res = 0;
 struct sstream_t store;
 init_output_sstream(&store, 256);
 if (serialize_dlg(&store, dlg) != 0) {
  do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't serialize dialog\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __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(): " "can't serialize dialog\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't serialize dialog\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __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(): " "can't serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "328" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 else {
  if (get_serialized_sstream(&store, dst_str) != 0) {
   do { if (get_debug_level("dialog", (sizeof("dialog")-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(): " "can't get serialized dialog data\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __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(): " "can't get serialized dialog data\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't get serialized dialog data\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __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(): " "can't get serialized dialog data\n", ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't get serialized dialog data\n", ("dialog" " [" "serialize_dlg.c" ":" "333" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   res = -1;
  }
 }
 destroy_sstream(&store);
 return res;
}

variable_types: struct dlg { struct dlg_id { struct _str { char *s; int len; } call_id; struct _str rem_tag; struct _str loc_tag; } id; struct dlg_seq { unsigned int value; unsigned char is_set; } loc_seq; struct dlg_seq rem_seq; struct _str loc_uri; struct _str rem_uri; struct _str rem_target; struct _str dst_uri; struct _str loc_dname; struct _str rem_dname; unsigned char secure; enum dlg_state { DLG_NEW=0, DLG_EARLY=1, DLG_CONFIRMED=2, DLG_DESTROYED=3 } state; struct rr { struct name_addr { struct _str name; struct _str uri; int len; } nameaddr; struct param { enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 } type; struct _str name; struct _str body; int len; struct param *next; } *r2; struct param *params; int len; struct rr *next; } *route_set; struct dlg_hooks { struct _str ru; struct _str nh; struct _str *request_uri; struct _str *next_hop; struct rr *first_route; struct _str *last_route; } hooks; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *send_sock; } *

user_defined_types: struct sstream_t { struct _dstring_t out; struct _str in; int in_pos; enum { sstream_in=0, sstream_out=1 } type; }

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

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

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

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

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

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


repo: virtualolson/who

decompiled_code:
__int64 __fastcall sip_msg_cloner(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)(a1 + 32) == 2 )
result = sip_msg_shm_clone(a1, a2, 1LL);
else
result = sip_msg_shm_clone(a1, a2, 0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)(a1 + 32) == 2 )
result = sip_msg_shm_clone(a1, a2, 1LL);
else
result = sip_msg_shm_clone(a1, a2, 0LL);
return result;
}

original_code:
struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
{
 if (org_msg->first_line.type==2)
  return sip_msg_shm_clone(org_msg, sip_msg_len, 1);
 return sip_msg_shm_clone(org_msg, sip_msg_len, 0);
}

canonical_original_code:
struct sip_msg *sip_msg_cloner(struct sip_msg *org_msg, int *sip_msg_len)
{
 if (org_msg->first_line.type==2)
  return sip_msg_shm_clone(org_msg, sip_msg_len, 1);
 return sip_msg_shm_clone(org_msg, sip_msg_len, 0);
}

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

user_defined_types: struct sip_msg { unsigned int id; int pid; struct timeval tval; struct snd_flags fwd_send_flags; struct snd_flags rpl_send_flags; struct msg_start first_line; struct via_body *via1; struct via_body *via2; struct hdr_field *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 *body; char *eoh; char *unparsed; struct receive_info rcv; char *buf; unsigned int len; struct _str new_uri; struct _str dst_uri; int parsed_uri_ok; struct sip_uri parsed_uri; int parsed_orig_ruri_ok; struct sip_uri parsed_orig_ruri; struct lump *add_rm; struct lump *body_lumps; struct lump_rpl *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 ldv; }

user_defined_types: struct msg_start { int type; int len; union { struct { struct _str 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; }

user_defined_types: struct receive_info { struct ip_addr src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union src_su; struct socket_info *bind_address; char proto; }

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

user_defined_types: struct msg_ldata { struct ocd_flow flow; }

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

user_defined_types: struct hdr_field { enum _hdr_types_t type; struct _str name; struct _str body; int len; void *parsed; struct hdr_field *next; }

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

user_defined_types: struct lump { enum _hdr_types_t type; enum lump_op op; union { int offset; enum lump_subst subst; enum lump_conditions cond; char *value; } u; int len; struct lump *before; struct lump *after; struct lump *next; enum lump_flag flags; }


decompiled_code:
__int64 __fastcall save_msg_lumps(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
int v3; // ebp
const char *v5; // r12
unsigned int v6; // eax
const char *v7; // r12
unsigned int v8; // eax
const char *v9; // rbp
unsigned int v10; // eax
__int64 v11; // [rsp+8h] [rbp-30h] BYREF
__int64 v12; // [rsp+10h] [rbp-28h] BYREF
__int64 v13[4]; // [rsp+18h] [rbp-20h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
int v3; // ebp
const char *v5; // r12
unsigned int v6; // eax
const char *v7; // r12
unsigned int v8; // eax
const char *v9; // rbp
unsigned int v10; // eax
__int64 v11; // [rsp+8h] [rbp-30h] BYREF
__int64 v12; // [rsp+10h] [rbp-28h] BYREF
__int64 v13[4]; // [rsp+18h] [rbp-20h] BYREF

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

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

return_type: int


decompiled_code:
__int64 __fastcall trim_leading(unsigned __int8 **a1)
{
__int64 result; // rax
int v2; // edx
unsigned __int8 *v3; // r10
unsigned __int8 v4; // cl
unsigned __int8 *v5; // r11
unsigned __int8 v6; // cl
unsigned __int8 *v7; // r9
unsigned __int8 v8; // cl
unsigned __int8 v9; // cl
unsigned __int8 v10; // cl
unsigned __int8 v11; // cl
char *v12; // r10
unsigned __int8 v13; // cl

result = *((unsigned int *)a1 + 2);
if ( (int)result > 0 )
{
v2 = (_DWORD)a1[1] & 3;
if ( (result & 3) != 0 )
{
if ( v2 != 1 )
{
if ( v2 != 2 )
{
v3 = *a1;
v4 = **a1;
if ( v4 > 0x20u || ((1LL << v4) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v3 + 1;
}
v5 = *a1;
v6 = **a1;
if ( v6 > 0x20u || ((1LL << v6) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v5 + 1;
}
v7 = *a1;
v8 = **a1;
if ( v8 > 0x20u )
return result;
if ( ((1LL << v8) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v7 + 1;
if ( !(_DWORD)result )
return result;
}
do
{
v12 = (char *)*a1;
v13 = **a1;
if ( v13 > 0x20u )
break;
if ( ((1LL << v13) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 1);
v9 = v12[1];
if ( v9 > 0x20u )
break;
if ( ((1LL << v9) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 1;
*a1 = (unsigned __int8 *)(v12 + 2);
v10 = v12[2];
if ( v10 > 0x20u )
break;
if ( ((1LL << v10) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 2;
*a1 = (unsigned __int8 *)(v12 + 3);
v11 = v12[3];
if ( v11 > 0x20u )
break;
if ( ((1LL << v11) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 3);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 4);
}
while ( (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 **a1)
{
__int64 result; // rax
int v2; // edx
unsigned __int8 *v3; // r10
unsigned __int8 v4; // cl
unsigned __int8 *v5; // r11
unsigned __int8 v6; // cl
unsigned __int8 *v7; // r9
unsigned __int8 v8; // cl
unsigned __int8 v9; // cl
unsigned __int8 v10; // cl
unsigned __int8 v11; // cl
char *v12; // r10
unsigned __int8 v13; // cl

result = *((unsigned int *)a1 + 2);
if ( (int)result > 0 )
{
v2 = (_DWORD)a1[1] & 3;
if ( (result & 3) != 0 )
{
if ( v2 != 1 )
{
if ( v2 != 2 )
{
v3 = *a1;
v4 = **a1;
if ( v4 > 0x20u || ((1LL << v4) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v3 + 1;
}
v5 = *a1;
v6 = **a1;
if ( v6 > 0x20u || ((1LL << v6) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v5 + 1;
}
v7 = *a1;
v8 = **a1;
if ( v8 > 0x20u )
return result;
if ( ((1LL << v8) & 0x100002600LL) == 0 )
return result;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = v7 + 1;
if ( !(_DWORD)result )
return result;
}
do
{
v12 = (char *)*a1;
v13 = **a1;
if ( v13 > 0x20u )
break;
if ( ((1LL << v13) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 1);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 1);
v9 = v12[1];
if ( v9 > 0x20u )
break;
if ( ((1LL << v9) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 1;
*a1 = (unsigned __int8 *)(v12 + 2);
v10 = v12[2];
if ( v10 > 0x20u )
break;
if ( ((1LL << v10) & 0x100002600LL) == 0 )
break;
*((_DWORD *)a1 + 2) = result - 2;
*a1 = (unsigned __int8 *)(v12 + 3);
v11 = v12[3];
if ( v11 > 0x20u )
break;
if ( ((1LL << v11) & 0x100002600LL) == 0 )
break;
result = (unsigned int)(result - 3);
*((_DWORD *)a1 + 2) = result;
*a1 = (unsigned __int8 *)(v12 + 4);
}
while ( (_DWORD)result );
}
return result;
}

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

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

return_type: void


decompiled_code:
__int64 __fastcall sdpops_get_ids_by_name(__int64 a1, __m128i *a2)
{
int v3; // ebx
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

if ( sdpops_codecsmap_table )
{
v3 = *(_DWORD *)(a1 + 8);
if ( v3 == *((_DWORD *)&sdpops_codecsmap_table + 2) )
{
v16 = strncasecmp(sdpops_codecsmap_table, *(const char **)a1, v3);
if ( !v16 )
goto LABEL_29;
}
v4 = *(&sdpops_codecsmap_table + 4);
if ( v4 )
{
if ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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:
*a2 = _mm_load_si128((const __m128i *)&(&sdpops_codecsmap_table)[4 * v16 + 2]);
return 0LL;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
a2->m128i_i64[0] = 0LL;
a2->m128i_i32[2] = 0;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __m128i *a2)
{
int v3; // ebx
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

if ( sdpops_codecsmap_table )
{
v3 = *(_DWORD *)(a1 + 8);
if ( v3 == *((_DWORD *)&sdpops_codecsmap_table + 2) )
{
v16 = strncasecmp(sdpops_codecsmap_table, *(const char **)a1, v3);
if ( !v16 )
goto LABEL_29;
}
v4 = *(&sdpops_codecsmap_table + 4);
if ( v4 )
{
if ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 ( 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:
*a2 = _mm_load_si128((const __m128i *)&(&sdpops_codecsmap_table)[4 * v16 + 2]);
return 0LL;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
a2->m128i_i64[0] = 0LL;
a2->m128i_i32[2] = 0;
return 0xFFFFFFFFLL;
}

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


decompiled_code:
__int64 __fastcall sdpops_sdp_get_ids_by_name(__int64 a1, __int64 a2, __int64 a3, int a4)
{
int v6; // er12
unsigned int j; // er14
const __m128i *k; // rbx
int v9; // edx
__int64 v10; // rax
__int64 result; // rax
unsigned int i; // [rsp+4h] [rbp-44h]

v6 = 0;
for ( i = 0; get_sdp_session_sdp(a1, i); ++i )
{
for ( j = 0; ; ++j )
{
v10 = get_sdp_stream_sdp(a1, i, j);
if ( !v10 )
break;
for ( k = *(const __m128i **)(v10 + 288); k; k = (const __m128i *)k->m128i_i64[0] )
{
v9 = *(_DWORD *)(a2 + 8);
if ( k[2].m128i_i32[2] == v9 && !strncasecmp(*(const char **)a2, (const char *)k[2].m128i_i64[0], v9) )
{
if ( a4 == v6 )
goto LABEL_17;
*(__m128i *)(a3 + 16LL * v6++) = _mm_loadu_si128(k + 1);
}
}
}
}
if ( v6 )
{
result = 0LL;
if ( v6 < a4 )
{
*(_QWORD *)(a3 + 16LL * v6) = 0LL;
result = 0LL;
}
}
else
{
LABEL_17:
*(_QWORD *)a3 = 0LL;
*(_DWORD *)(a3 + 8) = 0;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, int a4)
{
int v6; // er12
unsigned int j; // er14
const __m128i *k; // rbx
int v9; // edx
__int64 v10; // rax
__int64 result; // rax
unsigned int i; // [rsp+4h] [rbp-44h]

v6 = 0;
for ( i = 0; get_sdp_session_sdp(a1, i); ++i )
{
for ( j = 0; ; ++j )
{
v10 = get_sdp_stream_sdp(a1, i, j);
if ( !v10 )
break;
for ( k = *(const __m128i **)(v10 + 288); k; k = (const __m128i *)k->m128i_i64[0] )
{
v9 = *(_DWORD *)(a2 + 8);
if ( k[2].m128i_i32[2] == v9 && !strncasecmp(*(const char **)a2, (const char *)k[2].m128i_i64[0], v9) )
{
if ( a4 == v6 )
goto LABEL_17;
*(__m128i *)(a3 + 16LL * v6++) = _mm_loadu_si128(k + 1);
}
}
}
}
if ( v6 )
{
result = 0LL;
if ( v6 < a4 )
{
*(_QWORD *)(a3 + 16LL * v6) = 0LL;
result = 0LL;
}
}
else
{
LABEL_17:
*(_QWORD *)a3 = 0LL;
*(_DWORD *)(a3 + 8) = 0;
result = 0xFFFFFFFFLL;
}
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; }


decompiled_code:
__int64 __fastcall str_find_token(__int64 a1, __int64 a2, char a3)
{
unsigned __int8 *v5; // rsi
__int64 v6; // rdx
unsigned __int8 v7; // cl
char v8; // al

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
if ( **(_BYTE **)a1 == a3 )
{
++*(_QWORD *)a1;
--*(_DWORD *)(a1 + 8);
}
trim_leading((unsigned __int8 **)a1);
v5 = *(unsigned __int8 **)a1;
*(_QWORD *)a2 = *(_QWORD *)a1;
*(_DWORD *)(a2 + 8) = 0;
if ( *(int *)(a1 + 8) <= 0 )
return 0LL;
v6 = 0LL;
while ( 1 )
{
v7 = v5[v6];
v8 = 1;
if ( v7 <= 0xDu )
v8 = ((0x2401uLL >> v7) ^ 1) & 1;
if ( v7 == a3 || !v8 )
break;
++*(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 8) <= (int)++v6 )
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, char a3)
{
unsigned __int8 *v5; // rsi
__int64 v6; // rdx
unsigned __int8 v7; // cl
char v8; // al

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
if ( **(_BYTE **)a1 == a3 )
{
++*(_QWORD *)a1;
--*(_DWORD *)(a1 + 8);
}
func0((unsigned __int8 **)a1);
v5 = *(unsigned __int8 **)a1;
*(_QWORD *)a2 = *(_QWORD *)a1;
*(_DWORD *)(a2 + 8) = 0;
if ( *(int *)(a1 + 8) <= 0 )
return 0LL;
v6 = 0LL;
while ( 1 )
{
v7 = v5[v6];
v8 = 1;
if ( v7 <= 0xDu )
v8 = ((0x2401uLL >> v7) ^ 1) & 1;
if ( v7 == a3 || !v8 )
break;
++*(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 8) <= (int)++v6 )
return 0LL;
}
return 0LL;
}

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