decompiled_code:
char *__fastcall crc32_uint(char *a1, unsigned int *a2)
{
char *result; // rax
int v4; // esi
char *v5; // rdx
unsigned int v6; // ecx
unsigned int v7; // er11
char *v8; // r10
int v9; // eax
int v10; // er9
unsigned int v11; // er11
unsigned int v12; // er11
int v13; // er9
unsigned int v14; // er11
unsigned int v15; // er11
unsigned int v16; // er11
unsigned int v17; // er11
unsigned int v18; // er11
unsigned int v19; // er11
unsigned int v20; // er11
unsigned int v21; // esi
int v22; // esi
int v23; // esi
int v24; // er8
int v25; // ecx
int v26; // er8
int v27; // er9
int v28; // er8
int v29; // edx
unsigned int v30; // er11
unsigned int v31; // er11
unsigned int v32; // er11
unsigned int v33; // er11
unsigned int v34; // er11
unsigned int v35; // er11
unsigned int v36; // er11
int v37; // er8

result = a1;
v4 = *((_DWORD *)result + 2);
v5 = *(char **)result;
v6 = v4 / 4;
if ( v4 / 4 )
{
v7 = -1;
v8 = &v5[4 * v6];
if ( (v6 & 1) == 0 )
goto LABEL_25;
v9 = *v5;
v10 = v5[1];
v5 += 4;
LOBYTE(v9) = ~(_BYTE)v9;
v11 = LODWORD(crc_32_tab[v10 ^ (unsigned __int8)~LOBYTE(crc_32_tab[v9])]) ^ (((unsigned int)crc_32_tab[v9] ^ 0xFFFFFF) >> 8);
result = (char *)(unsigned int)*(v5 - 1);
v12 = LODWORD(crc_32_tab[*(v5 - 2) ^ (unsigned __int8)v11]) ^ (v11 >> 8);
v7 = LODWORD(crc_32_tab[(unsigned int)result ^ (unsigned __int8)v12]) ^ (v12 >> 8);
if ( v5 != v8 )
{
LABEL_25:
do
{
v13 = *v5;
v5 += 8;
v14 = LODWORD(crc_32_tab[v13 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v15 = LODWORD(crc_32_tab[*(v5 - 7) ^ (unsigned __int8)v14]) ^ (v14 >> 8);
v16 = LODWORD(crc_32_tab[*(v5 - 6) ^ (unsigned __int8)v15]) ^ (v15 >> 8);
v17 = LODWORD(crc_32_tab[*(v5 - 5) ^ (unsigned __int8)v16]) ^ (v16 >> 8);
v18 = LODWORD(crc_32_tab[*(v5 - 4) ^ (unsigned __int8)v17]) ^ (v17 >> 8);
v19 = LODWORD(crc_32_tab[*(v5 - 3) ^ (unsigned __int8)v18]) ^ (v18 >> 8);
v20 = LODWORD(crc_32_tab[*(v5 - 2) ^ (unsigned __int8)v19]) ^ (v19 >> 8);
result = (char *)(*(v5 - 1) ^ (unsigned int)(unsigned __int8)v20);
v7 = LODWORD(crc_32_tab[(int)result]) ^ (v20 >> 8);
}
while ( v5 != v8 );
}
}
else
{
v8 = *(char **)result;
v7 = -1;
}
v21 = v4 % 4;
if ( v21 )
{
result = &v8[v21];
v22 = v21 & 7;
if ( !v22 )
goto LABEL_26;
if ( v22 != 1LL )
{
if ( v22 != 2LL )
{
if ( v22 != 3LL )
{
if ( v22 != 4LL )
{
if ( v22 != 5LL )
{
if ( v22 != 6LL )
{
v37 = *v8++;
v7 = LODWORD(crc_32_tab[v37 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v23 = *v8++;
v7 = LODWORD(crc_32_tab[v23 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v24 = *v8++;
v7 = LODWORD(crc_32_tab[v24 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v25 = *v8++;
v7 = LODWORD(crc_32_tab[v25 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v26 = *v8++;
v7 = LODWORD(crc_32_tab[v26 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v27 = *v8++;
v7 = LODWORD(crc_32_tab[v27 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v28 = *v8++;
v7 = LODWORD(crc_32_tab[v28 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
if ( v8 != result )
{
LABEL_26:
do
{
v29 = *v8;
v8 += 8;
v30 = LODWORD(crc_32_tab[v29 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v31 = LODWORD(crc_32_tab[*(v8 - 7) ^ (unsigned __int8)v30]) ^ (v30 >> 8);
v32 = LODWORD(crc_32_tab[*(v8 - 6) ^ (unsigned __int8)v31]) ^ (v31 >> 8);
v33 = LODWORD(crc_32_tab[*(v8 - 5) ^ (unsigned __int8)v32]) ^ (v32 >> 8);
v34 = LODWORD(crc_32_tab[*(v8 - 4) ^ (unsigned __int8)v33]) ^ (v33 >> 8);
v35 = LODWORD(crc_32_tab[*(v8 - 3) ^ (unsigned __int8)v34]) ^ (v34 >> 8);
v36 = LODWORD(crc_32_tab[*(v8 - 2) ^ (unsigned __int8)v35]) ^ (v35 >> 8);
v7 = LODWORD(crc_32_tab[*(v8 - 1) ^ (unsigned __int8)v36]) ^ (v36 >> 8);
}
while ( v8 != result );
}
}
*a2 = ~v7;
return result;
}

canonical_decompiled_code:
char *__fastcall func5(char *a1, unsigned int *a2)
{
char *result; // rax
int v4; // esi
char *v5; // rdx
unsigned int v6; // ecx
unsigned int v7; // er11
char *v8; // r10
int v9; // eax
int v10; // er9
unsigned int v11; // er11
unsigned int v12; // er11
int v13; // er9
unsigned int v14; // er11
unsigned int v15; // er11
unsigned int v16; // er11
unsigned int v17; // er11
unsigned int v18; // er11
unsigned int v19; // er11
unsigned int v20; // er11
unsigned int v21; // esi
int v22; // esi
int v23; // esi
int v24; // er8
int v25; // ecx
int v26; // er8
int v27; // er9
int v28; // er8
int v29; // edx
unsigned int v30; // er11
unsigned int v31; // er11
unsigned int v32; // er11
unsigned int v33; // er11
unsigned int v34; // er11
unsigned int v35; // er11
unsigned int v36; // er11
int v37; // er8

result = a1;
v4 = *((_DWORD *)result + 2);
v5 = *(char **)result;
v6 = v4 / 4;
if ( v4 / 4 )
{
v7 = -1;
v8 = &v5[4 * v6];
if ( (v6 & 1) == 0 )
goto LABEL_25;
v9 = *v5;
v10 = v5[1];
v5 += 4;
LOBYTE(v9) = ~(_BYTE)v9;
v11 = LODWORD(crc_32_tab[v10 ^ (unsigned __int8)~LOBYTE(crc_32_tab[v9])]) ^ (((unsigned int)crc_32_tab[v9] ^ 0xFFFFFF) >> 8);
result = (char *)(unsigned int)*(v5 - 1);
v12 = LODWORD(crc_32_tab[*(v5 - 2) ^ (unsigned __int8)v11]) ^ (v11 >> 8);
v7 = LODWORD(crc_32_tab[(unsigned int)result ^ (unsigned __int8)v12]) ^ (v12 >> 8);
if ( v5 != v8 )
{
LABEL_25:
do
{
v13 = *v5;
v5 += 8;
v14 = LODWORD(crc_32_tab[v13 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v15 = LODWORD(crc_32_tab[*(v5 - 7) ^ (unsigned __int8)v14]) ^ (v14 >> 8);
v16 = LODWORD(crc_32_tab[*(v5 - 6) ^ (unsigned __int8)v15]) ^ (v15 >> 8);
v17 = LODWORD(crc_32_tab[*(v5 - 5) ^ (unsigned __int8)v16]) ^ (v16 >> 8);
v18 = LODWORD(crc_32_tab[*(v5 - 4) ^ (unsigned __int8)v17]) ^ (v17 >> 8);
v19 = LODWORD(crc_32_tab[*(v5 - 3) ^ (unsigned __int8)v18]) ^ (v18 >> 8);
v20 = LODWORD(crc_32_tab[*(v5 - 2) ^ (unsigned __int8)v19]) ^ (v19 >> 8);
result = (char *)(*(v5 - 1) ^ (unsigned int)(unsigned __int8)v20);
v7 = LODWORD(crc_32_tab[(int)result]) ^ (v20 >> 8);
}
while ( v5 != v8 );
}
}
else
{
v8 = *(char **)result;
v7 = -1;
}
v21 = v4 % 4;
if ( v21 )
{
result = &v8[v21];
v22 = v21 & 7;
if ( !v22 )
goto LABEL_26;
if ( v22 != 1LL )
{
if ( v22 != 2LL )
{
if ( v22 != 3LL )
{
if ( v22 != 4LL )
{
if ( v22 != 5LL )
{
if ( v22 != 6LL )
{
v37 = *v8++;
v7 = LODWORD(crc_32_tab[v37 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v23 = *v8++;
v7 = LODWORD(crc_32_tab[v23 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v24 = *v8++;
v7 = LODWORD(crc_32_tab[v24 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v25 = *v8++;
v7 = LODWORD(crc_32_tab[v25 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v26 = *v8++;
v7 = LODWORD(crc_32_tab[v26 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v27 = *v8++;
v7 = LODWORD(crc_32_tab[v27 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v28 = *v8++;
v7 = LODWORD(crc_32_tab[v28 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
if ( v8 != result )
{
LABEL_26:
do
{
v29 = *v8;
v8 += 8;
v30 = LODWORD(crc_32_tab[v29 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v31 = LODWORD(crc_32_tab[*(v8 - 7) ^ (unsigned __int8)v30]) ^ (v30 >> 8);
v32 = LODWORD(crc_32_tab[*(v8 - 6) ^ (unsigned __int8)v31]) ^ (v31 >> 8);
v33 = LODWORD(crc_32_tab[*(v8 - 5) ^ (unsigned __int8)v32]) ^ (v32 >> 8);
v34 = LODWORD(crc_32_tab[*(v8 - 4) ^ (unsigned __int8)v33]) ^ (v33 >> 8);
v35 = LODWORD(crc_32_tab[*(v8 - 3) ^ (unsigned __int8)v34]) ^ (v34 >> 8);
v36 = LODWORD(crc_32_tab[*(v8 - 2) ^ (unsigned __int8)v35]) ^ (v35 >> 8);
v7 = LODWORD(crc_32_tab[*(v8 - 1) ^ (unsigned __int8)v36]) ^ (v36 >> 8);
}
while ( v8 != result );
}
}
*a2 = ~v7;
return result;
}

original_code:
void crc32_uint (str *source_string, unsigned int *hash_ret)
{
 unsigned int hash;
 unsigned int len;
 const char *data;
 hash = 0xffffffff;
 data = source_string->s;
 for (len = source_string->len / 4; len--; data += 4) {
  hash = crc_32_tab[((unsigned char)hash) ^ data[0]] ^ (hash >> 8);
  hash = crc_32_tab[((unsigned char)hash) ^ data[1]] ^ (hash >> 8);
  hash = crc_32_tab[((unsigned char)hash) ^ data[2]] ^ (hash >> 8);
  hash = crc_32_tab[((unsigned char)hash) ^ data[3]] ^ (hash >> 8);
 }
 for (len = source_string->len % 4; len--; data++) {
  hash = crc_32_tab[((unsigned char)hash) ^ *data] ^ (hash >> 8);
 }
 *hash_ret = ~hash;
}

canonical_original_code:
void crc32_uint(struct _str *source_string, unsigned int *hash_ret)
{
 unsigned int hash;
 unsigned int len;
 char *data;
 hash = 0xffffffff;
 data = source_string->s;
 for (len = source_string->len / 4; len--; data += 4) {
  hash = crc_32_tab[((unsigned char)hash) ^ data[0]] ^ (hash >> 8);
  hash = crc_32_tab[((unsigned char)hash) ^ data[1]] ^ (hash >> 8);
  hash = crc_32_tab[((unsigned char)hash) ^ data[2]] ^ (hash >> 8);
  hash = crc_32_tab[((unsigned char)hash) ^ data[3]] ^ (hash >> 8);
 }
 for (len = source_string->len % 4; len--; data++) {
  hash = crc_32_tab[((unsigned char)hash) ^ *data] ^ (hash >> 8);
 }
 *hash_ret = ~hash;
}

variable_types:
hash
unsigned int

variable_types:
data
char *


xmlstrcmp

repo: virtualolson/who

decompiled_code:
int __fastcall xmlstrcmp(const char *a1, const char *a2)
{
if ( !a1 )
return -1;
if ( a2 )
return strcmp(a1, a2);
return 1;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1, const char *a2)
{
if ( !a1 )
return -1;
if ( a2 )
return strcmp(a1, a2);
return 1;
}

original_code:
int xmlstrcmp(const xmlChar *xmls, const char *name)
{
 if (!xmls) return -1;
 if (!name) return 1;
 return strcmp((const char*)xmls, name);
}

canonical_original_code:
int xmlstrcmp(unsigned char *xmls, char *name)
{
 if (!xmls) return -1;
 if (!name) return 1;
 return strcmp((char *)xmls, name);
}

variable_types:
xmls
unsigned char *

variable_types:
name
char *

return_type: int


decompiled_code:
__int64 xmltime2time()
{
const char *v1; // r12
unsigned int v2; // eax

if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v1 = (const char *)*((_QWORD *)&log_level_info + 8);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't translate xmltime to time_t: not finished yet!\n",
process_no,
v2,
v1,
"<core> [xml_utils.c:140]: ",
"xmltime2time");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't translate xmltime to time_t: not finished yet!\n",
*((const char **)&log_level_info + 8),
"<core> [xml_utils.c:140]: ",
"xmltime2time");
}
--dprint_crit;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
const char *v1; // r12
unsigned int v2; // eax

if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v1 = (const char *)*((_QWORD *)&log_level_info + 8);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't translate xmltime to time_t: not finished yet!\n",
process_no,
v2,
v1,
"<core> [xml_utils.c:140]: ",
"xmltime2time");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't translate xmltime to time_t: not finished yet!\n",
*((const char **)&log_level_info + 8),
"<core> [xml_utils.c:140]: ",
"xmltime2time");
}
--dprint_crit;
}
return 0LL;
}

original_code:
time_t xmltime2time(const char *xt)
{
 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(): " "can't translate xmltime to time_t: not finished yet!\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", process_no, my_pid(), ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
}

canonical_original_code:
long xmltime2time(char *xt)
{
 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(): " "can't translate xmltime to time_t: not finished yet!\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", process_no, my_pid(), ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't translate xmltime to time_t: not finished yet!\n", ("<core> [" "xml_utils.c" ":" "140" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
}

variable_types:
xt
char *

return_type: long

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


decompiled_code:
__int64 __fastcall str2int(const char *a1, int *a2)
{
int v2; // eax
unsigned int v3; // er8

if ( a1 )
{
v2 = atoi(a1);
v3 = 0;
}
else
{
v2 = 0;
v3 = -1;
}
*a2 = v2;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, int *a2)
{
int v2; // eax
unsigned int v3; // er8

if ( a1 )
{
v2 = atoi(a1);
v3 = 0;
}
else
{
v2 = 0;
v3 = -1;
}
*a2 = v2;
return v3;
}

original_code:
static int str2int(const char *s, int *dst)
{
 if (!s) {
  *dst = 0;
  return -1;
 }
 else *dst = atoi(s);
 return 0;
}

canonical_original_code:
static int str2int(char *s, int *dst)
{
 if (!s) {
  *dst = 0;
  return -1;
 }
 else *dst = atoi(s);
 return 0;
}

variable_types:
s
char *

variable_types:
dst
int *


decompiled_code:
__int64 __fastcall serialize_dlg_state(__int64 a1, unsigned int *a2)
{
int v3; // er12
unsigned int v4; // eax
__int64 result; // rax
const char *v6; // r13
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
const char *v9; // r8
const char *v10; // r9
__int64 v11; // r13
const char *v12; // r12
unsigned int v13; // eax
struct _IO_FILE *v14; // rdi
__int64 v15; // rdx
__int64 v16; // rcx
__int64 v17; // [rsp-8h] [rbp-40h]
const char *v18; // [rsp-8h] [rbp-40h]
const char *v19; // [rsp+0h] [rbp-38h]
_QWORD v20[6]; // [rsp+8h] [rbp-30h] BYREF

v3 = *(_DWORD *)(a1 + 52);
HIDWORD(v20[0]) = -1;
if ( !v3 )
{
result = serialize_int(a1, (char *)v20 + 4);
if ( !(_DWORD)result )
{
if ( HIDWORD(v20[0]) == 2 )
{
*a2 = 2;
return result;
}
if ( SHIDWORD(v20[0]) > 2 )
{
if ( HIDWORD(v20[0]) == 3 )
{
*a2 = 3;
return result;
}
}
else
{
if ( !HIDWORD(v20[0]) )
{
*a2 = 0;
return result;
}
if ( HIDWORD(v20[0]) == 1 )
{
*a2 = 1;
return result;
}
}
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v11 = HIDWORD(v20[0]);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): deserializing unknow dialog state (%d)!\n",
process_no,
v13,
v12,
"dialog [serialize_dlg.c:45]: ",
"serialize_dlg_state",
v11);
if ( log_color )
dprint_color_reset(
v14,
"%2d(%d) %s: %s%s(): deserializing unknow dialog state (%d)!\n",
v15,
v16,
(const char *)log_color,
v18,
v19,
v20[0]);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): deserializing unknow dialog state (%d)!\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:45]: ",
"serialize_dlg_state",
HIDWORD(v20[0]));
}
--dprint_crit;
}
}
return 0xFFFFFFFFLL;
}
v4 = *a2;
if ( *a2 == 2 )
{
HIDWORD(v20[0]) = 2;
}
else if ( v4 > 2 )
{
if ( v4 == 3 )
{
HIDWORD(v20[0]) = 3;
}
else if ( (int)get_debug_level("dialog", 6LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 10);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
process_no,
v7,
v6,
"dialog [serialize_dlg.c:57]: ",
"serialize_dlg_state");
if ( log_color )
dprint_color_reset(
v8,
"%2d(%d) %s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
v17,
log_color,
v9,
v10,
v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
*((const char **)&log_level_info + 10),
"dialog [serialize_dlg.c:57]: ",
"serialize_dlg_state");
}
--dprint_crit;
}
}
else
{
HIDWORD(v20[0]) = v4 != 0;
}
serialize_int(a1, (char *)v20 + 4);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int *a2)
{
int v3; // er12
unsigned int v4; // eax
__int64 result; // rax
const char *v6; // r13
unsigned int v7; // eax
struct _IO_FILE *v8; // rdi
const char *v9; // r8
const char *v10; // r9
__int64 v11; // r13
const char *v12; // r12
unsigned int v13; // eax
struct _IO_FILE *v14; // rdi
__int64 v15; // rdx
__int64 v16; // rcx
__int64 v17; // [rsp-8h] [rbp-40h]
const char *v18; // [rsp-8h] [rbp-40h]
const char *v19; // [rsp+0h] [rbp-38h]
_QWORD v20[6]; // [rsp+8h] [rbp-30h] BYREF

v3 = *(_DWORD *)(a1 + 52);
HIDWORD(v20[0]) = -1;
if ( !v3 )
{
result = serialize_int(a1, (char *)v20 + 4);
if ( !(_DWORD)result )
{
if ( HIDWORD(v20[0]) == 2 )
{
*a2 = 2;
return result;
}
if ( SHIDWORD(v20[0]) > 2 )
{
if ( HIDWORD(v20[0]) == 3 )
{
*a2 = 3;
return result;
}
}
else
{
if ( !HIDWORD(v20[0]) )
{
*a2 = 0;
return result;
}
if ( HIDWORD(v20[0]) == 1 )
{
*a2 = 1;
return result;
}
}
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v11 = HIDWORD(v20[0]);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v14 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): deserializing unknow dialog state (%d)!\n",
process_no,
v13,
v12,
"dialog [serialize_dlg.c:45]: ",
"serialize_dlg_state",
v11);
if ( log_color )
dprint_color_reset(
v14,
"%2d(%d) %s: %s%s(): deserializing unknow dialog state (%d)!\n",
v15,
v16,
(const char *)log_color,
v18,
v19,
v20[0]);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): deserializing unknow dialog state (%d)!\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:45]: ",
"serialize_dlg_state",
HIDWORD(v20[0]));
}
--dprint_crit;
}
}
return 0xFFFFFFFFLL;
}
v4 = *a2;
if ( *a2 == 2 )
{
HIDWORD(v20[0]) = 2;
}
else if ( v4 > 2 )
{
if ( v4 == 3 )
{
HIDWORD(v20[0]) = 3;
}
else if ( (int)get_debug_level("dialog", 6LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v6 = (const char *)*((_QWORD *)&log_level_info + 10);
v7 = my_pid();
v8 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
process_no,
v7,
v6,
"dialog [serialize_dlg.c:57]: ",
"serialize_dlg_state");
if ( log_color )
dprint_color_reset(
v8,
"%2d(%d) %s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
v17,
log_color,
v9,
v10,
v19);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
*((const char **)&log_level_info + 10),
"dialog [serialize_dlg.c:57]: ",
"serialize_dlg_state");
}
--dprint_crit;
}
}
else
{
HIDWORD(v20[0]) = v4 != 0;
}
serialize_int(a1, (char *)v20 + 4);
return 0LL;
}

original_code:
static int serialize_dlg_state(sstream_t *ss, dlg_state_t *state)
{
 int i = -1;
 if ((ss->type == sstream_in)) {
  if (serialize_int(ss, &i) != 0) return -1;
  switch (i) {
   case 0: *state = DLG_NEW; break;
   case 1: *state = DLG_EARLY; break;
   case 2: *state = DLG_CONFIRMED; break;
   case 3: *state = DLG_DESTROYED; break;
   default:
    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(): " "deserializing unknow dialog state (%d)!\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); 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(): " "deserializing unknow dialog state (%d)!\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "deserializing unknow dialog state (%d)!\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); 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(): " "deserializing unknow dialog state (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "deserializing unknow dialog state (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); } } (dprint_crit--); } } while(0);
    return -1;
  }
 }
 else {
  switch (*state) {
   case DLG_NEW: i = 0; break;
   case DLG_EARLY: i = 1; break;
   case DLG_CONFIRMED: i = 2; break;
   case DLG_DESTROYED: i = 3; break;
  }
  if (i == -1) {
   do { if (get_debug_level("dialog", (sizeof("dialog")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", (log_level_info[((0)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  }
  serialize_int(ss, &i);
 }
 return 0;
}

canonical_original_code:
static int serialize_dlg_state(struct sstream_t *ss, enum dlg_state *state)
{
 int i = -1;
 if ((ss->type == sstream_in)) {
  if (serialize_int(ss, &i) != 0) return -1;
  switch (i) {
   case 0: *state = DLG_NEW; break;
   case 1: *state = DLG_EARLY; break;
   case 2: *state = DLG_CONFIRMED; break;
   case 3: *state = DLG_DESTROYED; break;
   default:
    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(): " "deserializing unknow dialog state (%d)!\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); 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(): " "deserializing unknow dialog state (%d)!\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "deserializing unknow dialog state (%d)!\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); 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(): " "deserializing unknow dialog state (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "deserializing unknow dialog state (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "45" "]: ") , __func__, i); } } (dprint_crit--); } } while(0);
    return -1;
  }
 }
 else {
  switch (*state) {
   case DLG_NEW: i = 0; break;
   case DLG_EARLY: i = 1; break;
   case DLG_CONFIRMED: i = 2; break;
   case DLG_DESTROYED: i = 3; break;
  }
  if (i == -1) {
   do { if (get_debug_level("dialog", (sizeof("dialog")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", (log_level_info[((0)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "serializing unknow dialog state (probably unloadable!)\n", ("dialog" " [" "serialize_dlg.c" ":" "57" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  }
  serialize_int(ss, &i);
 }
 return 0;
}

variable_types: struct sstream_t { struct _dstring_t { struct _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; } *first; struct _dstr_buff_t *last; int len; int buff_size; int error; } out; struct _str { char *s; int len; } in; int in_pos; enum { sstream_in=0, sstream_out=1 } type; } *

variable_types: enum dlg_state { DLG_NEW=0, DLG_EARLY=1, DLG_CONFIRMED=2, DLG_DESTROYED=3 } *

variable_types: i int

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 _dstring_t { struct _dstr_buff_t *first; struct _dstr_buff_t *last; int len; int buff_size; int error; }


decompiled_code:
__int64 __fastcall serialize_dlg(__int64 a1, __int64 a2)
{
int v2; // er12
int v3; // er12
int v4; // er12
int v5; // er12
int v6; // er13
int v7; // er12
int v8; // er12
int v9; // er12
int v10; // er13
int v11; // er12
int v12; // er12
int v13; // er12
__int64 v14; // r12
int v15; // eax
const char *v17; // r13
unsigned int v18; // eax
struct _IO_FILE *v19; // rdi
__int64 v20; // [rsp-8h] [rbp-30h]

if ( !*(_DWORD *)(a1 + 52) )
{
*(_QWORD *)a2 = 0LL;
*(_QWORD *)(a2 + 240) = 0LL;
memset(
(void *)((a2 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a2 - (((_DWORD)a2 + 8) & 0xFFFFFFF8) + 248) >> 3));
}
v2 = serialize_str(a1, a2);
v3 = serialize_str(a1, a2 + 16) | v2;
v4 = serialize_str(a1, a2 + 32) | v3;
v5 = serialize_uint(a1, a2 + 48) | v4;
v6 = v5 | serialize_uchar(a1, a2 + 52);
v7 = v6 | serialize_uint(a1, a2 + 56);
v8 = serialize_uchar(a1, a2 + 60) | v7;
v9 = serialize_str(a1, a2 + 64) | v8;
v10 = v9 | serialize_str(a1, a2 + 80);
v11 = v10 | serialize_str(a1, a2 + 96);
v12 = serialize_uchar(a1, a2 + 160) | v11;
v13 = serialize_dlg_state(a1, (unsigned int *)(a2 + 164)) | v12;
LODWORD(v14) = serialize_route_set(a1, a2 + 168) | v13;
if ( !(_DWORD)v14 && !*(_DWORD *)(a1 + 52) )
{
v15 = tmb[27](a2);
v14 = (unsigned int)v15;
if ( v15 < 0 && (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v17 = (const char *)*((_QWORD *)&log_level_info + 8);
v18 = my_pid();
v19 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): error during calculate_hooks (%d)!\n",
process_no,
v18,
v17,
"dialog [serialize_dlg.c:313]: ",
"serialize_dlg",
v14);
if ( log_color )
dprint_color_reset(v19, (const char *)log_color, v20);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): error during calculate_hooks (%d)!\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:313]: ",
"serialize_dlg",
(unsigned int)v14);
}
--dprint_crit;
}
}
return (unsigned int)v14;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
int v2; // er12
int v3; // er12
int v4; // er12
int v5; // er12
int v6; // er13
int v7; // er12
int v8; // er12
int v9; // er12
int v10; // er13
int v11; // er12
int v12; // er12
int v13; // er12
__int64 v14; // r12
int v15; // eax
const char *v17; // r13
unsigned int v18; // eax
struct _IO_FILE *v19; // rdi
__int64 v20; // [rsp-8h] [rbp-30h]

if ( !*(_DWORD *)(a1 + 52) )
{
*(_QWORD *)a2 = 0LL;
*(_QWORD *)(a2 + 240) = 0LL;
memset(
(void *)((a2 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a2 - (((_DWORD)a2 + 8) & 0xFFFFFFF8) + 248) >> 3));
}
v2 = serialize_str(a1, a2);
v3 = serialize_str(a1, a2 + 16) | v2;
v4 = serialize_str(a1, a2 + 32) | v3;
v5 = serialize_uint(a1, a2 + 48) | v4;
v6 = v5 | serialize_uchar(a1, a2 + 52);
v7 = v6 | serialize_uint(a1, a2 + 56);
v8 = serialize_uchar(a1, a2 + 60) | v7;
v9 = serialize_str(a1, a2 + 64) | v8;
v10 = v9 | serialize_str(a1, a2 + 80);
v11 = v10 | serialize_str(a1, a2 + 96);
v12 = serialize_uchar(a1, a2 + 160) | v11;
v13 = func0(a1, (unsigned int *)(a2 + 164)) | v12;
LODWORD(v14) = serialize_route_set(a1, a2 + 168) | v13;
if ( !(_DWORD)v14 && !*(_DWORD *)(a1 + 52) )
{
v15 = tmb[27](a2);
v14 = (unsigned int)v15;
if ( v15 < 0 && (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v17 = (const char *)*((_QWORD *)&log_level_info + 8);
v18 = my_pid();
v19 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): error during calculate_hooks (%d)!\n",
process_no,
v18,
v17,
"dialog [serialize_dlg.c:313]: ",
"serialize_dlg",
v14);
if ( log_color )
dprint_color_reset(v19, (const char *)log_color, v20);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): error during calculate_hooks (%d)!\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:313]: ",
"serialize_dlg",
(unsigned int)v14);
}
--dprint_crit;
}
}
return (unsigned int)v14;
}

original_code:
int serialize_dlg(sstream_t *ss, dlg_t *dlg)
{
 int res = 0;
 if ((ss->type == sstream_in)) {
  memset(dlg, 0, sizeof(*dlg));
 }
 res = serialize_str(ss, &dlg->id.call_id) | res;
 res = serialize_str(ss, &dlg->id.rem_tag) | res;
 res = serialize_str(ss, &dlg->id.loc_tag) | res;
 res = serialize_uint(ss, &dlg->loc_seq.value) | res;
 res = serialize_uchar(ss, &dlg->loc_seq.is_set) | res;
 res = serialize_uint(ss, &dlg->rem_seq.value) | res;
 res = serialize_uchar(ss, &dlg->rem_seq.is_set) | res;
 res = serialize_str(ss, &dlg->loc_uri) | res;
 res = serialize_str(ss, &dlg->rem_uri) | res;
 res = serialize_str(ss, &dlg->rem_target) | res;
 res = serialize_uchar(ss, &dlg->secure) | res;
 res = serialize_dlg_state(ss, &dlg->state) | res;
 res = serialize_route_set(ss, &dlg->route_set) | res;
 if ((res == 0) && ((ss->type == sstream_in))) {
  res = tmb.calculate_hooks(dlg);
  if (res < 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(): " "error during calculate_hooks (%d)!\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); 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 during calculate_hooks (%d)!\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "error during calculate_hooks (%d)!\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); 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 during calculate_hooks (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "error during calculate_hooks (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); } } (dprint_crit--); } } while(0);
  }
 }
 return res;
}

canonical_original_code:
int serialize_dlg(struct sstream_t *ss, struct dlg *dlg)
{
 int res = 0;
 if ((ss->type == sstream_in)) {
  memset(dlg, 0, sizeof(*dlg));
 }
 res = serialize_str(ss, &dlg->id.call_id) | res;
 res = serialize_str(ss, &dlg->id.rem_tag) | res;
 res = serialize_str(ss, &dlg->id.loc_tag) | res;
 res = serialize_uint(ss, &dlg->loc_seq.value) | res;
 res = serialize_uchar(ss, &dlg->loc_seq.is_set) | res;
 res = serialize_uint(ss, &dlg->rem_seq.value) | res;
 res = serialize_uchar(ss, &dlg->rem_seq.is_set) | res;
 res = serialize_str(ss, &dlg->loc_uri) | res;
 res = serialize_str(ss, &dlg->rem_uri) | res;
 res = serialize_str(ss, &dlg->rem_target) | res;
 res = serialize_uchar(ss, &dlg->secure) | res;
 res = serialize_dlg_state(ss, &dlg->state) | res;
 res = serialize_route_set(ss, &dlg->route_set) | res;
 if ((res == 0) && ((ss->type == sstream_in))) {
  res = tmb.calculate_hooks(dlg);
  if (res < 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(): " "error during calculate_hooks (%d)!\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); 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 during calculate_hooks (%d)!\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "error during calculate_hooks (%d)!\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); 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 during calculate_hooks (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "error during calculate_hooks (%d)!\n", ("dialog" " [" "serialize_dlg.c" ":" "313" "]: ") , __func__, res); } } (dprint_crit--); } } while(0);
  }
 }
 return res;
}

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

variable_types: res int

user_defined_types: struct dlg { struct dlg_id id; struct dlg_seq loc_seq; struct dlg_seq rem_seq; struct _str loc_uri; struct _str rem_uri; struct _str rem_target; struct _str dst_uri; struct _str loc_dname; struct _str rem_dname; unsigned char secure; enum dlg_state state; struct rr *route_set; struct dlg_hooks hooks; struct socket_info *send_sock; }

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

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

user_defined_types: struct _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; }

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

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

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

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

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


decompiled_code:
__int64 __fastcall str2dlg(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
const char *v7; // r8
const char *v8; // r9
__int64 v9; // [rsp-8h] [rbp-70h]
const char *v10[13]; // [rsp+0h] [rbp-68h] BYREF

if ( !a1 )
return (unsigned int)-1;
init_input_sstream(v10, *(_QWORD *)a1, *(unsigned int *)(a1 + 8));
v2 = serialize_dlg((__int64)v10, a2);
if ( v2 )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -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(): can't de-serialize dialog\n",
process_no,
v5,
v4,
"dialog [serialize_dlg.c:351]: ",
"str2dlg");
if ( log_color )
dprint_color_reset(v6, "%2d(%d) %s: %s%s(): can't de-serialize dialog\n", v9, log_color, v7, v8, v10[0]);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't de-serialize dialog\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:351]: ",
"str2dlg");
}
v2 = -1;
--dprint_crit;
}
}
destroy_sstream(v10);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
const char *v4; // r13
unsigned int v5; // eax
struct _IO_FILE *v6; // rdi
const char *v7; // r8
const char *v8; // r9
__int64 v9; // [rsp-8h] [rbp-70h]
const char *v10[13]; // [rsp+0h] [rbp-68h] BYREF

if ( !a1 )
return (unsigned int)-1;
init_input_sstream(v10, *(_QWORD *)a1, *(unsigned int *)(a1 + 8));
v2 = func1((__int64)v10, a2);
if ( v2 )
{
v2 = -1;
if ( (int)get_debug_level("dialog", 6LL) >= -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(): can't de-serialize dialog\n",
process_no,
v5,
v4,
"dialog [serialize_dlg.c:351]: ",
"str2dlg");
if ( log_color )
dprint_color_reset(v6, "%2d(%d) %s: %s%s(): can't de-serialize dialog\n", v9, log_color, v7, v8, v10[0]);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't de-serialize dialog\n",
*((const char **)&log_level_info + 8),
"dialog [serialize_dlg.c:351]: ",
"str2dlg");
}
v2 = -1;
--dprint_crit;
}
}
destroy_sstream(v10);
return v2;
}

original_code:
int str2dlg(const str *s, dlg_t *dst_dlg)
{
 int res = 0;
 sstream_t store;
 if (!s) return -1;
 init_input_sstream(&store, s->s, s->len);
 if (serialize_dlg(&store, dst_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 de-serialize dialog\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __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 de-serialize dialog\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't de-serialize dialog\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __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 de-serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __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 de-serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 destroy_sstream(&store);
 return res;
}

canonical_original_code:
int str2dlg(struct _str *s, struct dlg *dst_dlg)
{
 int res = 0;
 struct sstream_t store;
 if (!s) return -1;
 init_input_sstream(&store, s->s, s->len);
 if (serialize_dlg(&store, dst_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 de-serialize dialog\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __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 de-serialize dialog\n", (log_level_info[((-1)) - (-5)].name), ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't de-serialize dialog\n", process_no, my_pid(), ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __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 de-serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __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 de-serialize dialog\n", ("dialog" " [" "serialize_dlg.c" ":" "351" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  res = -1;
 }
 destroy_sstream(&store);
 return res;
}

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

variable_types: struct sstream_t { struct _dstring_t { struct _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; } *first; struct _dstr_buff_t *last; int len; int buff_size; int error; } out; struct _str { char *s; int len; } in; int in_pos; enum { sstream_in=0, sstream_out=1 } type; }

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

user_defined_types: struct dlg_seq { unsigned int value; unsigned char is_set; }

user_defined_types: enum dlg_state { DLG_NEW=0, DLG_EARLY=1, DLG_CONFIRMED=2, DLG_DESTROYED=3 }

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

user_defined_types: struct name_addr { struct _str name; struct _str uri; int len; }

user_defined_types: struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; }

user_defined_types: enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 }

user_defined_types: struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

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

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


decompiled_code:
__int64 __fastcall dlg2str(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
const char *v4; // rbx
unsigned int v5; // eax
const char *v6; // rsi
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v10; // r8
__int64 v11; // r9
const char *v12; // r13
unsigned int v13; // eax
__int64 v14; // [rsp-10h] [rbp-10h]
__int64 v15; // [rsp-8h] [rbp-8h]
_BYTE savedregs[104]; // [rsp+0h] [rbp+0h] BYREF

init_output_sstream(savedregs, 256LL);
if ( (unsigned int)serialize_dlg((__int64)savedregs, a1) )
{
if ( (int)get_debug_level("dialog", 6LL) < -1 || dprint_crit )
goto LABEL_7;
++dprint_crit;
if ( !log_stderr )
{
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");
LABEL_6:
--dprint_crit;
goto LABEL_7;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = "%2d(%d) %s: %s%s(): can't serialize dialog\n";
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't serialize dialog\n",
process_no,
v5,
v4,
"dialog [serialize_dlg.c:328]: ",
"dlg2str");
v9 = log_color;
v10 = v14;
v11 = v15;
if ( !log_color )
goto LABEL_6;
goto LABEL_17;
}
v2 = get_serialized_sstream(savedregs, a2);
if ( !v2 )
goto LABEL_8;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
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");
goto LABEL_6;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v7 = stderr;
v6 = "%2d(%d) %s: %s%s(): can't get serialized dialog data\n";
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't get serialized dialog data\n",
process_no,
v13,
v12,
"dialog [serialize_dlg.c:333]: ",
"dlg2str");
v8 = log_color;
if ( !log_color )
goto LABEL_6;
LABEL_17:
dprint_color_reset(v7, v6, v8, v9, v10, v11);
goto LABEL_6;
}
LABEL_7:
v2 = -1;
LABEL_8:
destroy_sstream(savedregs);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
const char *v4; // rbx
unsigned int v5; // eax
const char *v6; // rsi
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v10; // r8
__int64 v11; // r9
const char *v12; // r13
unsigned int v13; // eax
__int64 v14; // [rsp-10h] [rbp-10h]
__int64 v15; // [rsp-8h] [rbp-8h]
_BYTE savedregs[104]; // [rsp+0h] [rbp+0h] BYREF

init_output_sstream(savedregs, 256LL);
if ( (unsigned int)func1((__int64)savedregs, a1) )
{
if ( (int)get_debug_level("dialog", 6LL) < -1 || dprint_crit )
goto LABEL_7;
++dprint_crit;
if ( !log_stderr )
{
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");
LABEL_6:
--dprint_crit;
goto LABEL_7;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v4 = (const char *)*((_QWORD *)&log_level_info + 8);
v5 = my_pid();
v6 = "%2d(%d) %s: %s%s(): can't serialize dialog\n";
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't serialize dialog\n",
process_no,
v5,
v4,
"dialog [serialize_dlg.c:328]: ",
"dlg2str");
v9 = log_color;
v10 = v14;
v11 = v15;
if ( !log_color )
goto LABEL_6;
goto LABEL_17;
}
v2 = get_serialized_sstream(savedregs, a2);
if ( !v2 )
goto LABEL_8;
if ( (int)get_debug_level("dialog", 6LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
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");
goto LABEL_6;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v12 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v7 = stderr;
v6 = "%2d(%d) %s: %s%s(): can't get serialized dialog data\n";
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't get serialized dialog data\n",
process_no,
v13,
v12,
"dialog [serialize_dlg.c:333]: ",
"dlg2str");
v8 = log_color;
if ( !log_color )
goto LABEL_6;
LABEL_17:
dprint_color_reset(v7, v6, v8, v9, v10, v11);
goto LABEL_6;
}
LABEL_7:
v2 = -1;
LABEL_8:
destroy_sstream(savedregs);
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 dlg { struct dlg_id id; struct dlg_seq loc_seq; struct dlg_seq rem_seq; struct _str loc_uri; struct _str rem_uri; struct _str rem_target; struct _str dst_uri; struct _str loc_dname; struct _str rem_dname; unsigned char secure; enum dlg_state state; struct rr *route_set; struct dlg_hooks hooks; struct socket_info *send_sock; }

user_defined_types: struct _dstring_t { struct _dstr_buff_t *first; struct _dstr_buff_t *last; int len; int buff_size; int error; }

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 rr { struct name_addr nameaddr; struct param *r2; struct param *params; int len; struct rr *next; }

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

user_defined_types: struct _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; }


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

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

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