decompiled_code:
__int64 sctp_core_check_support()
{
__int64 result; // rax
int v1; // edx
const char *v2; // rbx
unsigned int v3; // eax

if ( sctp_srapi_set )
return (*(&xmmword_590 + 1))();
v1 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v1 > 1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(2LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 14);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): SCTP API not enabled - if you want to use it, load sctp module\n",
process_no,
v3,
v2,
"<core> [sctp_core.c:69]: ",
"sctp_core_check_support");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 30) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): SCTP API not enabled - if you want to use it, load sctp module\n",
*((const char **)&log_level_info + 14),
"<core> [sctp_core.c:69]: ",
"sctp_core_check_support");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
int v1; // edx
const char *v2; // rbx
unsigned int v3; // eax

if ( sctp_srapi_set )
return (*(&xmmword_590 + 1))();
v1 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v1 > 1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(2LL);
v2 = (const char *)*((_QWORD *)&log_level_info + 14);
v3 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): SCTP API not enabled - if you want to use it, load sctp module\n",
process_no,
v3,
v2,
"<core> [sctp_core.c:69]: ",
"sctp_core_check_support");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 30) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): SCTP API not enabled - if you want to use it, load sctp module\n",
*((const char **)&log_level_info + 14),
"<core> [sctp_core.c:69]: ",
"sctp_core_check_support");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int sctp_core_check_support(void)
{
 if(_sctp_srapi_set==0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((2)) >= -5) && (((2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", process_no, my_pid(), (log_level_info[((2)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", (log_level_info[((2)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", process_no, my_pid(), ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return _sctp_srapi.check_support();
}

canonical_original_code:
int sctp_core_check_support()
{
 if(_sctp_srapi_set==0) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((2)) >= -5) && (((2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", process_no, my_pid(), (log_level_info[((2)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", (log_level_info[((2)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", process_no, my_pid(), ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "SCTP API not enabled" " - if you want to use it, load sctp module\n", ("<core> [" "sctp_core.c" ":" "69" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return _sctp_srapi.check_support();
}


repo: virtualolson/who

decompiled_code:
__int64 sctp_core_rcv_loop()
{
return xmmword_5A0();
}

canonical_decompiled_code:
__int64 func4()
{
return xmmword_5A0();
}

original_code:
int sctp_core_rcv_loop(void)
{
 return _sctp_srapi.rcv_loop();
}

canonical_original_code:
int sctp_core_rcv_loop()
{
 return _sctp_srapi.rcv_loop();
}

return_type: int


decompiled_code:
__int64 sctp_core_msg_send()
{
return (*(&xmmword_5A0 + 1))();
}

original_code:
int sctp_core_msg_send(struct dest_info* dst, char* buf, unsigned len)
{
 return _sctp_srapi.msg_send(dst, buf, len);
}

canonical_original_code:
int sctp_core_msg_send(struct dest_info *dst, char *buf, unsigned int len)
{
 return _sctp_srapi.msg_send(dst, buf, len);
}

variable_types: struct dest_info { struct socket_info { int socket; struct _str { char *s; int len; } 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; union sockaddr_union to; int id; char proto; struct snd_flags { unsigned char f; unsigned char blst_imask; } send_flags; } *

variable_types:
buf
char *

variable_types:
len
unsigned int

user_defined_types: struct dest_info { struct socket_info *send_sock; union sockaddr_union to; int id; char proto; struct snd_flags send_flags; }

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


decompiled_code:
__int64 __fastcall sctp_core_register_api(const __m128i *a1)
{
__int64 result; // rax
int v2; // edi
const char *v3; // rbx
unsigned int v4; // eax
int v5; // edx
const char *v6; // rbx
unsigned int v7; // eax

if ( a1 && a1->m128i_i64[0] )
{
if ( sctp_srapi_set == 1 )
{
v5 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 && !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(): SCTP API already initialized\n",
process_no,
v7,
v6,
"<core> [sctp_core.c:103]: ",
"sctp_core_register_api");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): SCTP API already initialized\n",
*((const char **)&log_level_info + 8),
"<core> [sctp_core.c:103]: ",
"sctp_core_register_api");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
else
{
sctp_srapi_set = 1;
*(__m128i *)&sctp_srapi = _mm_loadu_si128(a1);
*(__m128i *)&xmmword_590 = _mm_loadu_si128(a1 + 1);
*(__m128i *)&xmmword_5A0 = _mm_loadu_si128(a1 + 2);
result = 0LL;
}
}
else
{
v2 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -1 && !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(): invalid parameters\n",
process_no,
v4,
v3,
"<core> [sctp_core.c:99]: ",
"sctp_core_register_api");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid parameters\n",
*((const char **)&log_level_info + 8),
"<core> [sctp_core.c:99]: ",
"sctp_core_register_api");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(const __m128i *a1)
{
__int64 result; // rax
int v2; // edi
const char *v3; // rbx
unsigned int v4; // eax
int v5; // edx
const char *v6; // rbx
unsigned int v7; // eax

if ( a1 && a1->m128i_i64[0] )
{
if ( sctp_srapi_set == 1 )
{
v5 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v5 >= -1 && !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(): SCTP API already initialized\n",
process_no,
v7,
v6,
"<core> [sctp_core.c:103]: ",
"sctp_core_register_api");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): SCTP API already initialized\n",
*((const char **)&log_level_info + 8),
"<core> [sctp_core.c:103]: ",
"sctp_core_register_api");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
else
{
sctp_srapi_set = 1;
*(__m128i *)&sctp_srapi = _mm_loadu_si128(a1);
*(__m128i *)&xmmword_590 = _mm_loadu_si128(a1 + 1);
*(__m128i *)&xmmword_5A0 = _mm_loadu_si128(a1 + 2);
result = 0LL;
}
}
else
{
v2 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -1 && !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(): invalid parameters\n",
process_no,
v4,
v3,
"<core> [sctp_core.c:99]: ",
"sctp_core_register_api");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): invalid parameters\n",
*((const char **)&log_level_info + 8),
"<core> [sctp_core.c:99]: ",
"sctp_core_register_api");
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int sctp_core_register_api(sctp_srapi_t *api)
{
 if(api==((void *)0) || api->init==((void *)0)) {
  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(): " "invalid parameters\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "99" "]: ") , __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(): " "invalid parameters\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "99" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid parameters\n", process_no, my_pid(), ("<core> [" "sctp_core.c" ":" "99" "]: ") , __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(): " "invalid parameters\n", ("<core> [" "sctp_core.c" ":" "99" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid parameters\n", ("<core> [" "sctp_core.c" ":" "99" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if(_sctp_srapi_set==1) {
  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(): " "SCTP API already initialized\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "103" "]: ") , __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(): " "SCTP API already initialized\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "103" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "SCTP API already initialized\n", process_no, my_pid(), ("<core> [" "sctp_core.c" ":" "103" "]: ") , __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(): " "SCTP API already initialized\n", ("<core> [" "sctp_core.c" ":" "103" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "SCTP API already initialized\n", ("<core> [" "sctp_core.c" ":" "103" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 _sctp_srapi_set = 1;
 memcpy(&_sctp_srapi, api, sizeof(sctp_srapi_t));
 return 0;
}

canonical_original_code:
int sctp_core_register_api(struct sctp_srapi *api)
{
 if(api==((void *)0) || api->init==((void *)0)) {
  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(): " "invalid parameters\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "99" "]: ") , __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(): " "invalid parameters\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "99" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "invalid parameters\n", process_no, my_pid(), ("<core> [" "sctp_core.c" ":" "99" "]: ") , __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(): " "invalid parameters\n", ("<core> [" "sctp_core.c" ":" "99" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "invalid parameters\n", ("<core> [" "sctp_core.c" ":" "99" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 if(_sctp_srapi_set==1) {
  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(): " "SCTP API already initialized\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "103" "]: ") , __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(): " "SCTP API already initialized\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "sctp_core.c" ":" "103" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "SCTP API already initialized\n", process_no, my_pid(), ("<core> [" "sctp_core.c" ":" "103" "]: ") , __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(): " "SCTP API already initialized\n", ("<core> [" "sctp_core.c" ":" "103" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "SCTP API already initialized\n", ("<core> [" "sctp_core.c" ":" "103" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 _sctp_srapi_set = 1;
 memcpy(&_sctp_srapi, api, sizeof(sctp_srapi_t));
 return 0;
}

variable_types: struct sctp_srapi { int (*init)(); void (*destroy)(); int (*init_sock)(struct socket_info { int socket; struct _str { char *s; int len; } 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; } *sock_info); int (*check_support)(); int (*rcv_loop)(); int (*msg_send)(struct dest_info { struct socket_info *send_sock; union sockaddr_union to; int id; char proto; struct snd_flags { unsigned char f; unsigned char blst_imask; } send_flags; } *dst, char *buf, unsigned int len); } *

user_defined_types: struct sctp_srapi { int (*init)(); void (*destroy)(); int (*init_sock)(struct socket_info *sock_info); int (*check_support)(); int (*rcv_loop)(); int (*msg_send)(struct dest_info *dst, char *buf, unsigned int len); }

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 sca_event_from_str(__int64 a1)
{
const void *v1; // rbp
int v2; // ebx
__int64 result; // rax
int v4; // edx

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = *(const void **)a1;
if ( !*(_QWORD *)a1 )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a1 + 8);
if ( v2 != *((_DWORD *)&SCA_EVENT_NAME_CALL_INFO + 2)
|| (v4 = memcmp(*(const void **)a1, SCA_EVENT_NAME_CALL_INFO, v2), result = 1LL, v4) )
{
if ( v2 == *((_DWORD *)&SCA_EVENT_NAME_LINE_SEIZE + 2) )
result = memcmp(v1, SCA_EVENT_NAME_LINE_SEIZE, v2) == 0 ? 2 : -1;
else
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
const void *v1; // rbp
int v2; // ebx
__int64 result; // rax
int v4; // edx

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = *(const void **)a1;
if ( !*(_QWORD *)a1 )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a1 + 8);
if ( v2 != *((_DWORD *)&SCA_EVENT_NAME_CALL_INFO + 2)
|| (v4 = memcmp(*(const void **)a1, SCA_EVENT_NAME_CALL_INFO, v2), result = 1LL, v4) )
{
if ( v2 == *((_DWORD *)&SCA_EVENT_NAME_LINE_SEIZE + 2) )
result = memcmp(v1, SCA_EVENT_NAME_LINE_SEIZE, v2) == 0 ? 2 : -1;
else
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
sca_event_from_str( str *event_str )
{
    int event = SCA_EVENT_TYPE_UNKNOWN;
    if ( event_str == ((void *)0) || event_str->s == ((void *)0) ) {
 return( SCA_EVENT_TYPE_UNKNOWN );
    }
    if ( (((*event_str).len == (SCA_EVENT_NAME_CALL_INFO).len) && (memcmp((*event_str).s, (SCA_EVENT_NAME_CALL_INFO).s, (*event_str).len) == 0))) {
 event = SCA_EVENT_TYPE_CALL_INFO;
    } else if ( (((*event_str).len == (SCA_EVENT_NAME_LINE_SEIZE).len) && (memcmp((*event_str).s, (SCA_EVENT_NAME_LINE_SEIZE).s, (*event_str).len) == 0))) {
 event = SCA_EVENT_TYPE_LINE_SEIZE;
    }
    return( event );
}

canonical_original_code:
int sca_event_from_str(struct _str *event_str)
{
    int event = SCA_EVENT_TYPE_UNKNOWN;
    if ( event_str == ((void *)0) || event_str->s == ((void *)0) ) {
 return( SCA_EVENT_TYPE_UNKNOWN );
    }
    if ( (((*event_str).len == (SCA_EVENT_NAME_CALL_INFO).len) && (memcmp((*event_str).s, (SCA_EVENT_NAME_CALL_INFO).s, (*event_str).len) == 0))) {
 event = SCA_EVENT_TYPE_CALL_INFO;
    } else if ( (((*event_str).len == (SCA_EVENT_NAME_LINE_SEIZE).len) && (memcmp((*event_str).s, (SCA_EVENT_NAME_LINE_SEIZE).s, (*event_str).len) == 0))) {
 event = SCA_EVENT_TYPE_LINE_SEIZE;
    }
    return( event );
}

variable_types: event int


decompiled_code:
const char *__fastcall sca_event_name_from_type(int a1)
{
if ( a1 == 1 )
return SCA_EVENT_NAME_CALL_INFO;
if ( a1 == 2 )
return SCA_EVENT_NAME_LINE_SEIZE;
return "unknown";
}

canonical_decompiled_code:
const char *__fastcall func1(int a1)
{
if ( a1 == 1 )
return SCA_EVENT_NAME_CALL_INFO;
if ( a1 == 2 )
return SCA_EVENT_NAME_LINE_SEIZE;
return "unknown";
}

original_code:
char *
sca_event_name_from_type( int event_type )
{
    switch ( event_type ) {
    case SCA_EVENT_TYPE_CALL_INFO:
 return( SCA_EVENT_NAME_CALL_INFO.s );
    case SCA_EVENT_TYPE_LINE_SEIZE:
 return( SCA_EVENT_NAME_LINE_SEIZE.s );
    default:
 break;
    }
    return( "unknown" );
}

canonical_original_code:
char *sca_event_name_from_type(int event_type)
{
    switch ( event_type ) {
    case SCA_EVENT_TYPE_CALL_INFO:
 return( SCA_EVENT_NAME_CALL_INFO.s );
    case SCA_EVENT_TYPE_LINE_SEIZE:
 return( SCA_EVENT_NAME_LINE_SEIZE.s );
    default:
 break;
    }
    return( "unknown" );
}

return_type: char *


decompiled_code:
int __fastcall sca_event_append_header_for_type(int a1, char *a2, int a3)
{
const char *v4; // rax
int result; // eax
int v6; // edx
const char *v7; // rax
const char *v8; // r12
const char *v9; // rbp
unsigned int v10; // eax

v4 = sca_event_name_from_type(a1);
result = snprintf(a2, a3, "Event: %s%s", v4, "\r\n");
if ( result >= a3 )
{
v6 = get_debug_level("sca", 3LL);
result = -1;
if ( v6 >= -1 )
{
result = -1;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = sca_event_name_from_type(a1);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): %s Event header too long",
process_no,
v10,
v9,
"sca [sca_event.c:74]: ",
"sca_event_append_header_for_type",
v8);
if ( log_color )
dprint_color_reset();
}
else
{
v7 = sca_event_name_from_type(a1);
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): %s Event header too long",
*((const char **)&log_level_info + 8),
"sca [sca_event.c:74]: ",
"sca_event_append_header_for_type",
v7);
}
--dprint_crit;
result = -1;
}
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, char *a2, int a3)
{
const char *v4; // rax
int result; // eax
int v6; // edx
const char *v7; // rax
const char *v8; // r12
const char *v9; // rbp
unsigned int v10; // eax

v4 = func1(a1);
result = snprintf(a2, a3, "Event: %s%s", v4, "\r\n");
if ( result >= a3 )
{
v6 = get_debug_level("sca", 3LL);
result = -1;
if ( v6 >= -1 )
{
result = -1;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = func1(a1);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): %s Event header too long",
process_no,
v10,
v9,
"sca [sca_event.c:74]: ",
"sca_event_append_header_for_type",
v8);
if ( log_color )
dprint_color_reset();
}
else
{
v7 = func1(a1);
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): %s Event header too long",
*((const char **)&log_level_info + 8),
"sca [sca_event.c:74]: ",
"sca_event_append_header_for_type",
v7);
}
--dprint_crit;
result = -1;
}
}
}
return result;
}

original_code:
int
sca_event_append_header_for_type( int event_type, char *hdrbuf, int maxlen )
{
    int len;
    len = snprintf( hdrbuf, maxlen, "Event: %s%s",
      sca_event_name_from_type( event_type ), "\r\n" );
    if ( len >= maxlen ) {
 do { if (get_debug_level("sca", (sizeof("sca")-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(): " "%s Event header too long", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); 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(): " "%s Event header too long", (log_level_info[((-1)) - (-5)].name), ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "%s Event header too long", process_no, my_pid(), ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); 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(): " "%s Event header too long", ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "%s Event header too long", ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); } } (dprint_crit--); } } while(0);
 return( -1 );
    }
    return( len );
}

canonical_original_code:
int sca_event_append_header_for_type(int event_type, char *hdrbuf, int maxlen)
{
    int len;
    len = snprintf( hdrbuf, maxlen, "Event: %s%s",
      sca_event_name_from_type( event_type ), "\r\n" );
    if ( len >= maxlen ) {
 do { if (get_debug_level("sca", (sizeof("sca")-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(): " "%s Event header too long", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); 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(): " "%s Event header too long", (log_level_info[((-1)) - (-5)].name), ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "%s Event header too long", process_no, my_pid(), ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); 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(): " "%s Event header too long", ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "%s Event header too long", ("sca" " [" "sca_event.c" ":" "74" "]: ") , __func__, sca_event_name_from_type( event_type)); } } (dprint_crit--); } } while(0);
 return( -1 );
    }
    return( len );
}

variable_types:
hdrbuf
char *

variable_types: maxlen int

variable_types: len int


decompiled_code:
__int64 __fastcall crcitt_string_ex(_BYTE *a1, int a2, int a3)
{
int v3; // eax
_BYTE *v4; // rdx
int v5; // esi
unsigned __int16 v6; // ax
unsigned __int16 v7; // ax
unsigned __int16 v8; // ax

v3 = ~a3;
if ( a2 )
{
v4 = &a1[a2];
v5 = a2 & 3;
if ( !v5 )
goto LABEL_12;
if ( v5 != 1LL )
{
if ( v5 != 2LL )
LOWORD(v3) = ccitt_tab[(unsigned __int8)(*a1++ ^ v3)] ^ BYTE1(v3);
LOWORD(v3) = ccitt_tab[(unsigned __int8)(*a1++ ^ v3)] ^ BYTE1(v3);
}
LOWORD(v3) = ccitt_tab[(unsigned __int8)(*a1++ ^ v3)] ^ BYTE1(v3);
if ( a1 != v4 )
{
LABEL_12:
do
{
v6 = ccitt_tab[(unsigned __int8)(*a1 ^ v3)] ^ BYTE1(v3);
v7 = ccitt_tab[(unsigned __int8)(a1[1] ^ v6)] ^ HIBYTE(v6);
v8 = ccitt_tab[(unsigned __int8)(a1[2] ^ v7)] ^ HIBYTE(v7);
LOWORD(v3) = ccitt_tab[(unsigned __int8)(a1[3] ^ v8)] ^ HIBYTE(v8);
a1 += 4;
}
while ( a1 != v4 );
}
}
return (unsigned int)~v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1, int a2, int a3)
{
int v3; // eax
_BYTE *v4; // rdx
int v5; // esi
unsigned __int16 v6; // ax
unsigned __int16 v7; // ax
unsigned __int16 v8; // ax

v3 = ~a3;
if ( a2 )
{
v4 = &a1[a2];
v5 = a2 & 3;
if ( !v5 )
goto LABEL_12;
if ( v5 != 1LL )
{
if ( v5 != 2LL )
LOWORD(v3) = ccitt_tab[(unsigned __int8)(*a1++ ^ v3)] ^ BYTE1(v3);
LOWORD(v3) = ccitt_tab[(unsigned __int8)(*a1++ ^ v3)] ^ BYTE1(v3);
}
LOWORD(v3) = ccitt_tab[(unsigned __int8)(*a1++ ^ v3)] ^ BYTE1(v3);
if ( a1 != v4 )
{
LABEL_12:
do
{
v6 = ccitt_tab[(unsigned __int8)(*a1 ^ v3)] ^ BYTE1(v3);
v7 = ccitt_tab[(unsigned __int8)(a1[1] ^ v6)] ^ HIBYTE(v6);
v8 = ccitt_tab[(unsigned __int8)(a1[2] ^ v7)] ^ HIBYTE(v7);
LOWORD(v3) = ccitt_tab[(unsigned __int8)(a1[3] ^ v8)] ^ HIBYTE(v8);
a1 += 4;
}
while ( a1 != v4 );
}
}
return (unsigned int)~v3;
}

original_code:
unsigned short crcitt_string_ex( char *s, int len, register unsigned short ccitt) {
 ccitt = ~ccitt;
 while( len ) {
  ccitt = (ccitt_tab[((ccitt) ^ (*s)) & 0xff] ^ ((ccitt) >> 8));
  s++; len--;
 }
 return ~ccitt;
}

canonical_original_code:
unsigned short crcitt_string_ex(char *s, int len, unsigned short ccitt) {
 ccitt = ~ccitt;
 while( len ) {
  ccitt = (ccitt_tab[((ccitt) ^ (*s)) & 0xff] ^ ((ccitt) >> 8));
  s++; len--;
 }
 return ~ccitt;
}

variable_types:
s
char *

variable_types:
ccitt
unsigned short

return_type: unsigned short


decompiled_code:
__int64 __fastcall crcitt_string(_BYTE *a1, int a2)
{
return crcitt_string_ex(a1, a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1, int a2)
{
return func1(a1, a2, 0);
}

original_code:
unsigned short crcitt_string( char *s, int len )
{
 return crcitt_string_ex(s, len, 0);
}

canonical_original_code:
unsigned short crcitt_string(char *s, int len)
{
 return crcitt_string_ex(s, len, 0);
}


decompiled_code:
void __fastcall crcitt_string_array(_BYTE *a1, __int64 a2, int a3)
{
__int64 v3; // rdi
unsigned __int16 v4; // ax
_BYTE *v5; // rbx
int v6; // er8
_BYTE *v7; // r10
__int64 v8; // r9
unsigned __int16 v9; // ax
unsigned __int16 v10; // ax
unsigned __int16 v11; // ax
const char *v12; // rbx
unsigned int v13; // eax
_BYTE *v14; // [rsp+8h] [rbp-20h] BYREF
int v15[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v14 = a1;
v15[0] = 4;
if ( a3 <= 0 )
{
v4 = -1;
}
else
{
v3 = a2 + 16LL * (unsigned int)(a3 - 1) + 16;
v4 = -1;
do
{
v5 = *(_BYTE **)a2;
v6 = *(_DWORD *)(a2 + 8);
if ( v6 )
{
v7 = &v5[v6];
v8 = v6 & 3;
if ( (v6 & 3) == 0 )
goto LABEL_29;
if ( v8 != 1 )
{
if ( v8 != 2 )
v4 = ccitt_tab[(unsigned __int8)(*v5++ ^ v4)] ^ HIBYTE(v4);
v4 = ccitt_tab[(unsigned __int8)(*v5++ ^ v4)] ^ HIBYTE(v4);
}
v4 = ccitt_tab[(unsigned __int8)(*v5++ ^ v4)] ^ HIBYTE(v4);
if ( v7 != v5 )
{
LABEL_29:
do
{
v9 = ccitt_tab[(unsigned __int8)(*v5 ^ v4)] ^ HIBYTE(v4);
v10 = ccitt_tab[(unsigned __int8)(v5[1] ^ v9)] ^ HIBYTE(v9);
v11 = ccitt_tab[(unsigned __int8)(v5[2] ^ v10)] ^ HIBYTE(v10);
v4 = ccitt_tab[(unsigned __int8)(v5[3] ^ v11)] ^ HIBYTE(v11);
v5 += 4;
}
while ( v7 != v5 );
}
}
a2 += 16LL;
}
while ( a2 != v3 );
}
if ( (unsigned int)int2reverse_hex(&v14, v15, (unsigned __int16)~v4) == -1
&& (int)get_debug_level("core", 4LL) >= -2
&& !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 6);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: crcitt_string_array: string conversion incomplete\n",
process_no,
v13,
v12,
"<core> [crc.c:246]: ",
"crcitt_string_array");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: crcitt_string_array: string conversion incomplete\n",
*((const char **)&log_level_info + 6),
"<core> [crc.c:246]: ",
"crcitt_string_array");
}
--dprint_crit;
}
for ( ; v15[0]; --v15[0] )
*v14++ = 48;
}

canonical_decompiled_code:
void __fastcall func3(_BYTE *a1, __int64 a2, int a3)
{
__int64 v3; // rdi
unsigned __int16 v4; // ax
_BYTE *v5; // rbx
int v6; // er8
_BYTE *v7; // r10
__int64 v8; // r9
unsigned __int16 v9; // ax
unsigned __int16 v10; // ax
unsigned __int16 v11; // ax
const char *v12; // rbx
unsigned int v13; // eax
_BYTE *v14; // [rsp+8h] [rbp-20h] BYREF
int v15[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v14 = a1;
v15[0] = 4;
if ( a3 <= 0 )
{
v4 = -1;
}
else
{
v3 = a2 + 16LL * (unsigned int)(a3 - 1) + 16;
v4 = -1;
do
{
v5 = *(_BYTE **)a2;
v6 = *(_DWORD *)(a2 + 8);
if ( v6 )
{
v7 = &v5[v6];
v8 = v6 & 3;
if ( (v6 & 3) == 0 )
goto LABEL_29;
if ( v8 != 1 )
{
if ( v8 != 2 )
v4 = ccitt_tab[(unsigned __int8)(*v5++ ^ v4)] ^ HIBYTE(v4);
v4 = ccitt_tab[(unsigned __int8)(*v5++ ^ v4)] ^ HIBYTE(v4);
}
v4 = ccitt_tab[(unsigned __int8)(*v5++ ^ v4)] ^ HIBYTE(v4);
if ( v7 != v5 )
{
LABEL_29:
do
{
v9 = ccitt_tab[(unsigned __int8)(*v5 ^ v4)] ^ HIBYTE(v4);
v10 = ccitt_tab[(unsigned __int8)(v5[1] ^ v9)] ^ HIBYTE(v9);
v11 = ccitt_tab[(unsigned __int8)(v5[2] ^ v10)] ^ HIBYTE(v10);
v4 = ccitt_tab[(unsigned __int8)(v5[3] ^ v11)] ^ HIBYTE(v11);
v5 += 4;
}
while ( v7 != v5 );
}
}
a2 += 16LL;
}
while ( a2 != v3 );
}
if ( (unsigned int)func0(&v14, v15, (unsigned __int16)~v4) == -1
&& (int)get_debug_level("core", 4LL) >= -2
&& !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 6);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: crcitt_string_array: string conversion incomplete\n",
process_no,
v13,
v12,
"<core> [crc.c:246]: ",
"crcitt_string_array");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: crcitt_string_array: string conversion incomplete\n",
*((const char **)&log_level_info + 6),
"<core> [crc.c:246]: ",
"crcitt_string_array");
}
--dprint_crit;
}
for ( ; v15[0]; --v15[0] )
*v14++ = 48;
}

original_code:
void crcitt_string_array( char *dst, str src[], int size )
{
 register int i;
 register unsigned short ccitt;
 register char *c;
 register int len;
 int str_len;
 ccitt = 0xFFFF;
 str_len=4;
 for (i=0; i<size; i++ ) {
  c=src[i].s;
  len=src[i].len;
  while(len) {
   ccitt = (ccitt_tab[((ccitt) ^ (*c)) & 0xff] ^ ((ccitt) >> 8));
   c++;len--;
  }
 }
 ccitt = ~ccitt;
 if (int2reverse_hex( &dst, &str_len, ccitt )==-1) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "crc.c" ":" "246" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "crc.c" ":" "246" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", process_no, my_pid(), ("<core> [" "crc.c" ":" "246" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", ("<core> [" "crc.c" ":" "246" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", ("<core> [" "crc.c" ":" "246" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 while( str_len ) {
  *dst='0';
  dst++;
  str_len--;
 }
}

canonical_original_code:
void crcitt_string_array(char *dst, struct _str src[], int size)
{
 register int i;
 register unsigned short ccitt;
 register char *c;
 register int len;
 int str_len;
 ccitt = 0xFFFF;
 str_len=4;
 for (i=0; i<size; i++ ) {
  c=src[i].s;
  len=src[i].len;
  while(len) {
   ccitt = (ccitt_tab[((ccitt) ^ (*c)) & 0xff] ^ ((ccitt) >> 8));
   c++;len--;
  }
 }
 ccitt = ~ccitt;
 if (int2reverse_hex( &dst, &str_len, ccitt )==-1) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("<core> [" "crc.c" ":" "246" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", (log_level_info[((-2)) - (-5)].name), ("<core> [" "crc.c" ":" "246" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", process_no, my_pid(), ("<core> [" "crc.c" ":" "246" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", ("<core> [" "crc.c" ":" "246" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: crcitt_string_array: string conversion incomplete\n", ("<core> [" "crc.c" ":" "246" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 while( str_len ) {
  *dst='0';
  dst++;
  str_len--;
 }
}

variable_types:
dst
char *

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

variable_types: size int

variable_types: i int

variable_types:
c
char *

return_type: void


decompiled_code:
__int64 __fastcall crc32_uint(__int64 a1, _DWORD *a2)
{
char *v4; // rdx
int v5; // esi
unsigned int v6; // er8
unsigned int v7; // eax
char *v8; // r11
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
unsigned int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax
bool v16; // zf
int v17; // esi
int v18; // esi
__int64 v19; // r10
__int64 v20; // r8
unsigned int v21; // eax
unsigned int v22; // eax
unsigned int v23; // eax
__int64 result; // rax
unsigned int v25; // eax
unsigned int v26; // eax
unsigned int v27; // eax

v4 = *(char **)a1;
v5 = *(_DWORD *)(a1 + 8);
v6 = v5 / 4 - 1;
if ( v5 / 4 )
{
v7 = -1;
v8 = &v4[4 * v6 + 4];
if ( (v6 & 1) != 0
|| (v25 = LODWORD(crc_32_tab[*v4 ^ 0xFF]) ^ 0xFFFFFF,
v26 = LODWORD(crc_32_tab[v4[1] ^ (unsigned __int8)v25]) ^ (v25 >> 8),
v27 = LODWORD(crc_32_tab[v4[2] ^ (unsigned __int8)v26]) ^ (v26 >> 8),
v7 = LODWORD(crc_32_tab[v4[3] ^ (unsigned __int8)v27]) ^ (v27 >> 8),
v4 += 4,
v4 != v8) )
{
do
{
v9 = LODWORD(crc_32_tab[*v4 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v10 = LODWORD(crc_32_tab[v4[1] ^ (unsigned __int8)v9]) ^ (v9 >> 8);
v11 = LODWORD(crc_32_tab[v4[2] ^ (unsigned __int8)v10]) ^ (v10 >> 8);
v12 = LODWORD(crc_32_tab[v4[3] ^ (unsigned __int8)v11]) ^ (v11 >> 8);
v13 = LODWORD(crc_32_tab[v4[4] ^ (unsigned __int8)v12]) ^ (v12 >> 8);
v14 = LODWORD(crc_32_tab[v4[5] ^ (unsigned __int8)v13]) ^ (v13 >> 8);
v15 = LODWORD(crc_32_tab[v4[6] ^ (unsigned __int8)v14]) ^ (v14 >> 8);
v7 = LODWORD(crc_32_tab[v4[7] ^ (unsigned __int8)v15]) ^ (v15 >> 8);
v4 += 8;
}
while ( v4 != v8 );
}
}
else
{
v8 = *(char **)a1;
v7 = -1;
}
v17 = v5 % 4;
v16 = v17 == 0;
v18 = v17 - 1;
if ( !v16 )
{
v19 = (__int64)&v8[v18 + 1];
v20 = ((_BYTE)v18 + 1) & 3;
if ( (((_BYTE)v18 + 1) & 3) == 0 )
goto LABEL_18;
if ( v20 != 1 )
{
if ( v20 != 2 )
v7 = LODWORD(crc_32_tab[*v8++ ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v7 = LODWORD(crc_32_tab[*v8++ ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v7 = LODWORD(crc_32_tab[*v8++ ^ (unsigned __int8)v7]) ^ (v7 >> 8);
if ( v8 != (char *)v19 )
{
LABEL_18:
do
{
v21 = LODWORD(crc_32_tab[*v8 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v22 = LODWORD(crc_32_tab[v8[1] ^ (unsigned __int8)v21]) ^ (v21 >> 8);
v23 = LODWORD(crc_32_tab[v8[2] ^ (unsigned __int8)v22]) ^ (v22 >> 8);
v7 = LODWORD(crc_32_tab[v8[3] ^ (unsigned __int8)v23]) ^ (v23 >> 8);
v8 += 4;
}
while ( v8 != (char *)v19 );
}
}
result = ~v7;
*a2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _DWORD *a2)
{
char *v4; // rdx
int v5; // esi
unsigned int v6; // er8
unsigned int v7; // eax
char *v8; // r11
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
unsigned int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax
bool v16; // zf
int v17; // esi
int v18; // esi
__int64 v19; // r10
__int64 v20; // r8
unsigned int v21; // eax
unsigned int v22; // eax
unsigned int v23; // eax
__int64 result; // rax
unsigned int v25; // eax
unsigned int v26; // eax
unsigned int v27; // eax

v4 = *(char **)a1;
v5 = *(_DWORD *)(a1 + 8);
v6 = v5 / 4 - 1;
if ( v5 / 4 )
{
v7 = -1;
v8 = &v4[4 * v6 + 4];
if ( (v6 & 1) != 0
|| (v25 = LODWORD(crc_32_tab[*v4 ^ 0xFF]) ^ 0xFFFFFF,
v26 = LODWORD(crc_32_tab[v4[1] ^ (unsigned __int8)v25]) ^ (v25 >> 8),
v27 = LODWORD(crc_32_tab[v4[2] ^ (unsigned __int8)v26]) ^ (v26 >> 8),
v7 = LODWORD(crc_32_tab[v4[3] ^ (unsigned __int8)v27]) ^ (v27 >> 8),
v4 += 4,
v4 != v8) )
{
do
{
v9 = LODWORD(crc_32_tab[*v4 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v10 = LODWORD(crc_32_tab[v4[1] ^ (unsigned __int8)v9]) ^ (v9 >> 8);
v11 = LODWORD(crc_32_tab[v4[2] ^ (unsigned __int8)v10]) ^ (v10 >> 8);
v12 = LODWORD(crc_32_tab[v4[3] ^ (unsigned __int8)v11]) ^ (v11 >> 8);
v13 = LODWORD(crc_32_tab[v4[4] ^ (unsigned __int8)v12]) ^ (v12 >> 8);
v14 = LODWORD(crc_32_tab[v4[5] ^ (unsigned __int8)v13]) ^ (v13 >> 8);
v15 = LODWORD(crc_32_tab[v4[6] ^ (unsigned __int8)v14]) ^ (v14 >> 8);
v7 = LODWORD(crc_32_tab[v4[7] ^ (unsigned __int8)v15]) ^ (v15 >> 8);
v4 += 8;
}
while ( v4 != v8 );
}
}
else
{
v8 = *(char **)a1;
v7 = -1;
}
v17 = v5 % 4;
v16 = v17 == 0;
v18 = v17 - 1;
if ( !v16 )
{
v19 = (__int64)&v8[v18 + 1];
v20 = ((_BYTE)v18 + 1) & 3;
if ( (((_BYTE)v18 + 1) & 3) == 0 )
goto LABEL_18;
if ( v20 != 1 )
{
if ( v20 != 2 )
v7 = LODWORD(crc_32_tab[*v8++ ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v7 = LODWORD(crc_32_tab[*v8++ ^ (unsigned __int8)v7]) ^ (v7 >> 8);
}
v7 = LODWORD(crc_32_tab[*v8++ ^ (unsigned __int8)v7]) ^ (v7 >> 8);
if ( v8 != (char *)v19 )
{
LABEL_18:
do
{
v21 = LODWORD(crc_32_tab[*v8 ^ (unsigned __int8)v7]) ^ (v7 >> 8);
v22 = LODWORD(crc_32_tab[v8[1] ^ (unsigned __int8)v21]) ^ (v21 >> 8);
v23 = LODWORD(crc_32_tab[v8[2] ^ (unsigned __int8)v22]) ^ (v22 >> 8);
v7 = LODWORD(crc_32_tab[v8[3] ^ (unsigned __int8)v23]) ^ (v23 >> 8);
v8 += 4;
}
while ( v8 != (char *)v19 );
}
}
result = ~v7;
*a2 = result;
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

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 *


decompiled_code:
__int64 xmltime2time()
{
const char *v1; // rbx
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; // rbx
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


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

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

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:
dst
int *


decompiled_code:
__int64 __fastcall serialize_dlg_state(__int64 a1, unsigned int *a2)
{
unsigned int v2; // eax
__int64 result; // rax
int v4; // ebp
__int64 v5; // rbp
const char *v6; // rbx
unsigned int v7; // eax
const char *v8; // rbp
unsigned int v9; // eax
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = -1;
if ( *(_DWORD *)(a1 + 52) )
{
v2 = *a2;
if ( *a2 == 2 )
{
v10[0] = 2;
}
else if ( v2 > 2 )
{
if ( v2 == 3 )
{
v10[0] = 3;
}
else if ( (int)get_debug_level("dialog", 6LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v8 = (const char *)*((_QWORD *)&log_level_info + 10);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
process_no,
v9,
v8,
"dialog [serialize_dlg.c:57]: ",
"serialize_dlg_state");
if ( log_color )
dprint_color_reset();
}
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
{
v10[0] = v2 != 0;
}
serialize_int(a1, v10);
result = 0LL;
}
else
{
result = serialize_int(a1, v10);
if ( (_DWORD)result )
{
result = 0xFFFFFFFFLL;
}
else if ( v10[0] == 2 )
{
*a2 = 2;
}
else
{
if ( v10[0] > 2 )
{
if ( v10[0] == 3 )
{
*a2 = 3;
return result;
}
}
else
{
if ( !v10[0] )
{
*a2 = 0;
return 0LL;
}
if ( v10[0] == 1 )
{
*a2 = 1;
return result;
}
}
v4 = get_debug_level("dialog", 6LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (unsigned int)v10[0];
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): deserializing unknow dialog state (%d)!\n",
process_no,
v7,
v6,
"dialog [serialize_dlg.c:45]: ",
"serialize_dlg_state",
v5);
if ( log_color )
dprint_color_reset();
}
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",
(unsigned int)v10[0]);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int *a2)
{
unsigned int v2; // eax
__int64 result; // rax
int v4; // ebp
__int64 v5; // rbp
const char *v6; // rbx
unsigned int v7; // eax
const char *v8; // rbp
unsigned int v9; // eax
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = -1;
if ( *(_DWORD *)(a1 + 52) )
{
v2 = *a2;
if ( *a2 == 2 )
{
v10[0] = 2;
}
else if ( v2 > 2 )
{
if ( v2 == 3 )
{
v10[0] = 3;
}
else if ( (int)get_debug_level("dialog", 6LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v8 = (const char *)*((_QWORD *)&log_level_info + 10);
v9 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): serializing unknow dialog state (probably unloadable!)\n",
process_no,
v9,
v8,
"dialog [serialize_dlg.c:57]: ",
"serialize_dlg_state");
if ( log_color )
dprint_color_reset();
}
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
{
v10[0] = v2 != 0;
}
serialize_int(a1, v10);
result = 0LL;
}
else
{
result = serialize_int(a1, v10);
if ( (_DWORD)result )
{
result = 0xFFFFFFFFLL;
}
else if ( v10[0] == 2 )
{
*a2 = 2;
}
else
{
if ( v10[0] > 2 )
{
if ( v10[0] == 3 )
{
*a2 = 3;
return result;
}
}
else
{
if ( !v10[0] )
{
*a2 = 0;
return 0LL;
}
if ( v10[0] == 1 )
{
*a2 = 1;
return result;
}
}
v4 = get_debug_level("dialog", 6LL);
result = 0xFFFFFFFFLL;
if ( v4 >= -1 )
{
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (unsigned int)v10[0];
v6 = (const char *)*((_QWORD *)&log_level_info + 8);
v7 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): deserializing unknow dialog state (%d)!\n",
process_no,
v7,
v6,
"dialog [serialize_dlg.c:45]: ",
"serialize_dlg_state",
v5);
if ( log_color )
dprint_color_reset();
}
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",
(unsigned int)v10[0]);
}
--dprint_crit;
result = 0xFFFFFFFFLL;
}
}
}
}
return result;
}

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

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

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

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();
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();
}
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 _dstr_buff_t { int len; int used; struct _dstr_buff_t *next; char data[1]; }

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


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

if ( !a1 )
return (unsigned int)-1;
init_input_sstream(v6, *(_QWORD *)a1, *(unsigned int *)(a1 + 8));
v2 = serialize_dlg((__int64)v6, 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();
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();
}
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");
}
--dprint_crit;
v2 = -1;
}
}
destroy_sstream(v6);
return v2;
}

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

if ( !a1 )
return (unsigned int)-1;
init_input_sstream(v6, *(_QWORD *)a1, *(unsigned int *)(a1 + 8));
v2 = func1((__int64)v6, 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();
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();
}
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");
}
--dprint_crit;
v2 = -1;
}
}
destroy_sstream(v6);
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; }