decompiled_code:
__int64 __fastcall hex2int(char a1)
{
__int64 result; // rax
__int64 v2; // r9
const char *v3; // r12
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
__int64 v6; // [rsp-14h] [rbp-30h]
unsigned int v7; // [rsp+0h] [rbp-1Ch]

if ( (unsigned __int8)(a1 - 48) <= 9u )
return (unsigned int)(char)(a1 - 48);
if ( (unsigned __int8)(a1 - 97) <= 5u )
return (unsigned int)(char)(a1 - 87);
if ( (unsigned __int8)(a1 - 65) <= 5u )
return (unsigned int)(char)(a1 - 55);
if ( (int)get_debug_level(&LC0, 3LL) < -1 )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
v2 = (unsigned int)a1;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
dprint_color(0xFFFFFFFFLL);
LODWORD(v2) = a1;
}
v7 = v2;
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
process_no,
v4,
v3,
"rls [../../ut.h:561]: ",
"hex2int",
v7);
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): ERROR: hex2int: '%c' is no hex char\n", v6);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
*((const char **)&log_level_info + 8),
"rls [../../ut.h:561]: ",
"hex2int",
v2);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
__int64 result; // rax
__int64 v2; // r9
const char *v3; // r12
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
__int64 v6; // [rsp-14h] [rbp-30h]
unsigned int v7; // [rsp+0h] [rbp-1Ch]

if ( (unsigned __int8)(a1 - 48) <= 9u )
return (unsigned int)(char)(a1 - 48);
if ( (unsigned __int8)(a1 - 97) <= 5u )
return (unsigned int)(char)(a1 - 87);
if ( (unsigned __int8)(a1 - 65) <= 5u )
return (unsigned int)(char)(a1 - 55);
if ( (int)get_debug_level(&LC0, 3LL) < -1 )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( !dprint_crit )
{
v2 = (unsigned int)a1;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
dprint_color(0xFFFFFFFFLL);
LODWORD(v2) = a1;
}
v7 = v2;
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
process_no,
v4,
v3,
"rls [../../ut.h:561]: ",
"hex2int",
v7);
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): ERROR: hex2int: '%c' is no hex char\n", v6);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: hex2int: '%c' is no hex char\n",
*((const char **)&log_level_info + 8),
"rls [../../ut.h:561]: ",
"hex2int",
v2);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
return result;
}

original_code:
inline static int hex2int(char hex_digit)
{
 if (hex_digit>='0' && hex_digit<='9')
  return hex_digit-'0';
 if (hex_digit>='a' && hex_digit<='f')
  return hex_digit-'a'+10;
 if (hex_digit>='A' && hex_digit<='F')
  return hex_digit-'A'+10;
 do { if (get_debug_level("rls", (sizeof("rls")-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: hex2int: '%c' is no hex char\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); 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: hex2int: '%c' is no hex char\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: hex2int: '%c' is no hex char\n", process_no, my_pid(), ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); 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: hex2int: '%c' is no hex char\n", ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: hex2int: '%c' is no hex char\n", ("rls" " [" "../../ut.h" ":" "561" "]: ") , __func__, hex_digit); } } (dprint_crit--); } } while(0);
 return -1;
}


repo: virtualolson/who

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

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

return_type: void


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

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


original_code:
static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
{
 int i;
 str tmp;
 tmp.s = _s;
 tmp.len = _l;
 trim(&tmp);
 if (tmp.len == 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(): " "expires_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "expires_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  _e->valid = 0;
  return -1;
 }
 _e->text.s = tmp.s;
 _e->text.len = tmp.len;
 if (tmp.len > 10) {
  _e->valid = 0;
  return 0;
 }
 for(i = 0; i < tmp.len; i++) {
  if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) {
   _e->val *= 10;
   _e->val += tmp.s[i] - '0';
  } else {
   switch(tmp.s[i]) {
   case ' ':
   case '\t':
   case '\r':
   case '\n':
    _e->text.len = i;
    _e->valid = 1;
    return 0;
   default:
    _e->valid = 0;
    return 0;
   }
  }
 }
 _e->valid = 1;
 return 0;
}

canonical_original_code:
static inline int expires_parser(char *_s, int _l, struct exp_body *_e)
{
 int i;
 struct _str tmp;
 tmp.s = _s;
 tmp.len = _l;
 trim(&tmp);
 if (tmp.len == 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(): " "expires_parser(): Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "expires_parser(): Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __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(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "expires_parser(): Empty body\n", ("<core> [" "parser/parse_expires.c" ":" "61" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  _e->valid = 0;
  return -1;
 }
 _e->text.s = tmp.s;
 _e->text.len = tmp.len;
 if (tmp.len > 10) {
  _e->valid = 0;
  return 0;
 }
 for(i = 0; i < tmp.len; i++) {
  if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) {
   _e->val *= 10;
   _e->val += tmp.s[i] - '0';
  } else {
   switch(tmp.s[i]) {
   case ' ':
   case '\t':
   case '\r':
   case '\n':
    _e->text.len = i;
    _e->valid = 1;
    return 0;
   default:
    _e->valid = 0;
    return 0;
   }
  }
 }
 _e->valid = 1;
 return 0;
}

variable_types: struct exp_body { struct _str { char *s; int len; } text; unsigned char valid; unsigned int val; } *

variable_types: i int

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

return_type: int

user_defined_types: struct exp_body { struct _str text; unsigned char valid; unsigned int val; }

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 parse_expires(__int64 a1)
{
unsigned int v1; // er12
__int64 v3; // rax
__int64 v4; // rbp
const char *v5; // rbx
unsigned int v6; // eax
__int64 v7; // rdx
const char *v8; // r12
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-10h] [rbp-28h]
__int64 v12; // [rsp-10h] [rbp-28h]

v1 = 0;
if ( *(_QWORD *)(a1 + 48) )
return v1;
v3 = qm_malloc(mem_block, 24LL);
v4 = v3;
if ( !v3 )
{
v1 = -1;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): parse_expires(): No memory left\n", v7);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
}
v1 = -1;
--dprint_crit;
}
return v1;
}
*(_QWORD *)(v3 + 16) = 0LL;
*(_OWORD *)v3 = 0LL;
if ( (int)expires_parser(*(_QWORD *)(a1 + 24), *(_DWORD *)(a1 + 32), v3) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): Error while parsing\n",
process_no,
v9,
v8,
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): parse_expires(): Error while parsing\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): Error while parsing\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
}
--dprint_crit;
}
v1 = -2;
qm_free(mem_block, v4);
return v1;
}
*(_QWORD *)(a1 + 48) = v4;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned int v1; // er12
__int64 v3; // rax
__int64 v4; // rbp
const char *v5; // rbx
unsigned int v6; // eax
__int64 v7; // rdx
const char *v8; // r12
unsigned int v9; // eax
struct _IO_FILE *v10; // rdi
__int64 v11; // [rsp-10h] [rbp-28h]
__int64 v12; // [rsp-10h] [rbp-28h]

v1 = 0;
if ( *(_QWORD *)(a1 + 48) )
return v1;
v3 = qm_malloc(mem_block, 24LL);
v4 = v3;
if ( !v3 )
{
v1 = -1;
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v5 = (const char *)*((_QWORD *)&log_level_info + 8);
v6 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): parse_expires(): No memory left\n", v7);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:121]: ",
"parse_expires");
}
v1 = -1;
--dprint_crit;
}
return v1;
}
*(_QWORD *)(v3 + 16) = 0LL;
*(_OWORD *)v3 = 0LL;
if ( (int)func3(*(_QWORD *)(a1 + 24), *(_DWORD *)(a1 + 32), v3) < 0 )
{
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v8 = (const char *)*((_QWORD *)&log_level_info + 8);
v9 = my_pid();
v10 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_expires(): Error while parsing\n",
process_no,
v9,
v8,
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): parse_expires(): Error while parsing\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_expires(): Error while parsing\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_expires.c:128]: ",
"parse_expires");
}
--dprint_crit;
}
v1 = -2;
qm_free(mem_block, v4);
return v1;
}
*(_QWORD *)(a1 + 48) = v4;
return 0LL;
}

original_code:
int parse_expires(struct hdr_field* _h)
{
 exp_body_t* e;
 if (_h->parsed) {
  return 0;
 }
 e = (exp_body_t*)qm_malloc(mem_block, (sizeof(exp_body_t)));
 if (e == 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(): " "parse_expires(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __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(): " "parse_expires(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): No memory left\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __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(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(e, 0, sizeof(exp_body_t));
 if (expires_parser(_h->body.s, _h->body.len, e) < 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(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __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(): " "parse_expires(): Error while parsing\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __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(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  qm_free(mem_block, (e));
  return -2;
 }
 _h->parsed = (void*)e;
 return 0;
}

canonical_original_code:
int parse_expires(struct hdr_field *_h)
{
 struct exp_body *e;
 if (_h->parsed) {
  return 0;
 }
 e = (struct exp_body *)qm_malloc(mem_block, (sizeof(exp_body_t)));
 if (e == 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(): " "parse_expires(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __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(): " "parse_expires(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): No memory left\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __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(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): No memory left\n", ("<core> [" "parser/parse_expires.c" ":" "121" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(e, 0, sizeof(exp_body_t));
 if (expires_parser(_h->body.s, _h->body.len, e) < 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(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __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(): " "parse_expires(): Error while parsing\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_expires(): Error while parsing\n", process_no, my_pid(), ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __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(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_expires(): Error while parsing\n", ("<core> [" "parser/parse_expires.c" ":" "128" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  qm_free(mem_block, (e));
  return -2;
 }
 _h->parsed = (void *)e;
 return 0;
}

variable_types: 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 { char *s; int len; } name; struct _str body; int len; void *parsed; struct hdr_field *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; }


decompiled_code:
int __fastcall print_expires(__int64 a1)
{
void *v1; // rdx

puts("===Expires===");
v1 = *(void **)a1;
if ( !*(_QWORD *)a1 )
v1 = &unk_91D;
printf("text: '%.*s'\n", *(unsigned int *)(a1 + 8), v1);
printf("val : %d\n", *(unsigned int *)(a1 + 20));
return puts("===/Expires===");
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1)
{
void *v1; // rdx

puts("===Expires===");
v1 = *(void **)a1;
if ( !*(_QWORD *)a1 )
v1 = &unk_91D;
printf("text: '%.*s'\n", *(unsigned int *)(a1 + 8), v1);
printf("val : %d\n", *(unsigned int *)(a1 + 20));
return puts("===/Expires===");
}

original_code:
void print_expires(exp_body_t* _e)
{
 printf("===Expires===\n");
 printf("text: \'%.*s\'\n", _e->text.len, ((_e->text.s)?(_e->text.s):""));
 printf("val : %d\n", _e->val);
 printf("===/Expires===\n");
}

canonical_original_code:
void print_expires(struct exp_body *_e)
{
 printf("===Expires===\n");
 printf("text: \'%.*s\'\n", _e->text.len, ((_e->text.s)?(_e->text.s):""));
 printf("val : %d\n", _e->val);
 printf("===/Expires===\n");
}


decompiled_code:
__int64 events_child_init()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
int events_child_init(int _rank)
{
 return 0;
}


decompiled_code:
__int64 events_mod_init()
{
const char *v1; // r12
unsigned int v2; // eax
const char *v3; // r12
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
__int64 v6; // rdx
const char *v7; // r12
unsigned int v8; // eax
struct _IO_FILE *v9; // rdi
const char *v10; // r8
const char *v11; // r9
const char *v12; // [rsp-10h] [rbp-28h]
const char *v13; // [rsp-8h] [rbp-20h]
const char *v14; // [rsp+0h] [rbp-18h]

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module initialization\n",
process_no,
v2,
v1,
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module initialization\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
}
--dprint_crit;
}
xmlInitParser();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 16);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libraries\n",
process_no,
v4,
v3,
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): ... common libraries\n", v6, log_color, v12, v13, v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libraries\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
}
--dprint_crit;
}
qsa_initialize();
if ( (unsigned int)events_uac_init() )
return 0xFFFFFFFFLL;
if ( !handle_presence_subscriptions && (int)get_debug_level("presence_b2b", 12LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v7 = (const char *)*((_QWORD *)&log_level_info + 10);
v8 = my_pid();
v9 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): NOT handling presence subscriptions\n",
process_no,
v8,
v7,
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset(
v9,
"%2d(%d) %s: %s%s(): NOT handling presence subscriptions\n",
v13,
log_color,
v10,
v11,
v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): NOT handling presence subscriptions\n",
*((const char **)&log_level_info + 10),
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
}
--dprint_crit;
}
return (unsigned int)-((unsigned int)events_qsa_interface_init() != 0);
}

canonical_decompiled_code:
__int64 func2()
{
const char *v1; // r12
unsigned int v2; // eax
const char *v3; // r12
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
__int64 v6; // rdx
const char *v7; // r12
unsigned int v8; // eax
struct _IO_FILE *v9; // rdi
const char *v10; // r8
const char *v11; // r9
const char *v12; // [rsp-10h] [rbp-28h]
const char *v13; // [rsp-8h] [rbp-20h]
const char *v14; // [rsp+0h] [rbp-18h]

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module initialization\n",
process_no,
v2,
v1,
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module initialization\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:79]: ",
"events_mod_init");
}
--dprint_crit;
}
xmlInitParser();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v3 = (const char *)*((_QWORD *)&log_level_info + 16);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libraries\n",
process_no,
v4,
v3,
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): ... common libraries\n", v6, log_color, v12, v13, v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libraries\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:84]: ",
"events_mod_init");
}
--dprint_crit;
}
qsa_initialize();
if ( (unsigned int)events_uac_init() )
return 0xFFFFFFFFLL;
if ( !handle_presence_subscriptions && (int)get_debug_level("presence_b2b", 12LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v7 = (const char *)*((_QWORD *)&log_level_info + 10);
v8 = my_pid();
v9 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): NOT handling presence subscriptions\n",
process_no,
v8,
v7,
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
if ( log_color )
dprint_color_reset(
v9,
"%2d(%d) %s: %s%s(): NOT handling presence subscriptions\n",
v13,
log_color,
v10,
v11,
v14);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): NOT handling presence subscriptions\n",
*((const char **)&log_level_info + 10),
"presence_b2b [events_mod.c:92]: ",
"events_mod_init");
}
--dprint_crit;
}
return (unsigned int)-((unsigned int)events_qsa_interface_init() != 0);
}

original_code:
int events_mod_init(void)
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "presence_b2b module initialization\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module initialization\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module initialization\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 xmlInitParser();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... common libraries\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... common libraries\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libraries\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_initialize();
 if (events_uac_init() != 0) {
  return -1;
 }
 if (!handle_presence_subscriptions) {
  do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "NOT handling presence subscriptions\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __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(): " "NOT handling presence subscriptions\n", (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "NOT handling presence subscriptions\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __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(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 if (events_qsa_interface_init(handle_presence_subscriptions) != 0) return -1;
 return 0;
}

canonical_original_code:
int events_mod_init()
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "presence_b2b module initialization\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module initialization\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module initialization\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module initialization\n", ("presence_b2b" " [" "events_mod.c" ":" "79" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 xmlInitParser();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... common libraries\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... common libraries\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libraries\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libraries\n", ("presence_b2b" " [" "events_mod.c" ":" "84" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_initialize();
 if (events_uac_init() != 0) {
  return -1;
 }
 if (!handle_presence_subscriptions) {
  do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-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(): " "NOT handling presence subscriptions\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __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(): " "NOT handling presence subscriptions\n", (log_level_info[((0)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "NOT handling presence subscriptions\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __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(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "NOT handling presence subscriptions\n", ("presence_b2b" " [" "events_mod.c" ":" "92" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 }
 if (events_qsa_interface_init(handle_presence_subscriptions) != 0) return -1;
 return 0;
}


decompiled_code:
void events_mod_destroy()
{
const char *v0; // r12
unsigned int v1; // eax
struct _IO_FILE *v2; // rdi
const char *v3; // r8
const char *v4; // r9
const char *v5; // r12
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
const char *v9; // r12
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi
const char *v12; // r8
const char *v13; // r9
const char *v14; // r12
unsigned int v15; // eax
struct _IO_FILE *v16; // rdi
__int64 v17; // rdx
const char *v18; // r8
const char *v19; // r9
const char *v20; // r12
unsigned int v21; // eax
struct _IO_FILE *v22; // rdi
__int64 v23; // rcx
const char *v24; // [rsp-10h] [rbp-28h]
const char *v25; // [rsp-10h] [rbp-28h]
const char *v26; // [rsp-8h] [rbp-20h]
const char *v27; // [rsp+0h] [rbp-18h]

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v20 = (const char *)*((_QWORD *)&log_level_info + 16);
v21 = my_pid();
v22 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup\n",
process_no,
v21,
v20,
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v22, "%2d(%d) %s: %s%s(): presence_b2b module cleanup\n", log_color, v23, v25, v26, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
}
--dprint_crit;
}
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v9 = (const char *)*((_QWORD *)&log_level_info + 16);
v10 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... events UAC\n",
process_no,
v10,
v9,
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): ... events UAC\n", v26, log_color, v12, v13, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... events UAC\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_uac_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v14 = (const char *)*((_QWORD *)&log_level_info + 16);
v15 = my_pid();
v16 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... qsa interface\n",
process_no,
v15,
v14,
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v16, "%2d(%d) %s: %s%s(): ... qsa interface\n", v17, log_color, v18, v19, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... qsa interface\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_qsa_interface_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libs\n",
process_no,
v6,
v5,
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): ... common libs\n", v8, log_color, v24, v26, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libs\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
}
--dprint_crit;
}
qsa_cleanup();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v0 = (const char *)*((_QWORD *)&log_level_info + 16);
v1 = my_pid();
v2 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup finished\n",
process_no,
v1,
v0,
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(
v2,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup finished\n",
v26,
log_color,
v3,
v4,
v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup finished\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
}
--dprint_crit;
}
}

canonical_decompiled_code:
void func3()
{
const char *v0; // r12
unsigned int v1; // eax
struct _IO_FILE *v2; // rdi
const char *v3; // r8
const char *v4; // r9
const char *v5; // r12
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi
__int64 v8; // rdx
const char *v9; // r12
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi
const char *v12; // r8
const char *v13; // r9
const char *v14; // r12
unsigned int v15; // eax
struct _IO_FILE *v16; // rdi
__int64 v17; // rdx
const char *v18; // r8
const char *v19; // r9
const char *v20; // r12
unsigned int v21; // eax
struct _IO_FILE *v22; // rdi
__int64 v23; // rcx
const char *v24; // [rsp-10h] [rbp-28h]
const char *v25; // [rsp-10h] [rbp-28h]
const char *v26; // [rsp-8h] [rbp-20h]
const char *v27; // [rsp+0h] [rbp-18h]

if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v20 = (const char *)*((_QWORD *)&log_level_info + 16);
v21 = my_pid();
v22 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup\n",
process_no,
v21,
v20,
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v22, "%2d(%d) %s: %s%s(): presence_b2b module cleanup\n", log_color, v23, v25, v26, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:110]: ",
"events_mod_destroy");
}
--dprint_crit;
}
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v9 = (const char *)*((_QWORD *)&log_level_info + 16);
v10 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... events UAC\n",
process_no,
v10,
v9,
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): ... events UAC\n", v26, log_color, v12, v13, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... events UAC\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:112]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_uac_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v14 = (const char *)*((_QWORD *)&log_level_info + 16);
v15 = my_pid();
v16 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... qsa interface\n",
process_no,
v15,
v14,
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v16, "%2d(%d) %s: %s%s(): ... qsa interface\n", v17, log_color, v18, v19, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... qsa interface\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:115]: ",
"events_mod_destroy");
}
--dprint_crit;
}
events_qsa_interface_destroy();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ... common libs\n",
process_no,
v6,
v5,
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): ... common libs\n", v8, log_color, v24, v26, v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ... common libs\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:118]: ",
"events_mod_destroy");
}
--dprint_crit;
}
qsa_cleanup();
if ( (int)get_debug_level("presence_b2b", 12LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v0 = (const char *)*((_QWORD *)&log_level_info + 16);
v1 = my_pid();
v2 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup finished\n",
process_no,
v1,
v0,
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
if ( log_color )
dprint_color_reset(
v2,
"%2d(%d) %s: %s%s(): presence_b2b module cleanup finished\n",
v26,
log_color,
v3,
v4,
v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): presence_b2b module cleanup finished\n",
*((const char **)&log_level_info + 16),
"presence_b2b [events_mod.c:123]: ",
"events_mod_destroy");
}
--dprint_crit;
}
}

original_code:
void events_mod_destroy(void)
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "presence_b2b module cleanup\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module cleanup\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... events UAC\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... events UAC\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... events UAC\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_uac_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... qsa interface\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... qsa interface\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... qsa interface\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_qsa_interface_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... common libs\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... common libs\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libs\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_cleanup();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module cleanup finished\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } (dprint_crit--); } } while(0);
}

canonical_original_code:
void events_mod_destroy()
{
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "presence_b2b module cleanup\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module cleanup\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup\n", ("presence_b2b" " [" "events_mod.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... events UAC\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... events UAC\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... events UAC\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... events UAC\n", ("presence_b2b" " [" "events_mod.c" ":" "112" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_uac_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... qsa interface\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... qsa interface\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... qsa interface\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... qsa interface\n", ("presence_b2b" " [" "events_mod.c" ":" "115" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 events_qsa_interface_destroy();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " " ... common libs\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " " ... common libs\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " " ... common libs\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " " ... common libs\n", ("presence_b2b" " [" "events_mod.c" ":" "118" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 qsa_cleanup();
 do { if (get_debug_level("presence_b2b", (sizeof("presence_b2b")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "presence_b2b module cleanup finished\n", (log_level_info[((3)) - (-5)].name), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "presence_b2b module cleanup finished\n", process_no, my_pid(), ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "presence_b2b module cleanup finished\n", ("presence_b2b" " [" "events_mod.c" ":" "123" "]: ") , __func__); } } (dprint_crit--); } } while(0);
}


decompiled_code:
void __fastcall atomic_inc_int(volatile signed __int32 *a1)
{
_InterlockedIncrement(a1);
}

canonical_decompiled_code:
void __fastcall func0(volatile signed __int32 *a1)
{
_InterlockedIncrement(a1);
}

original_code: inline static void atomic_inc_int (volatile int* var) { asm volatile( "lock ;" " " "incl %0" " \n\t" : "=m"(*var) : "m"(*var) : "cc", "memory" ); }

canonical_original_code: inline static void atomic_inc_int(int *var) { asm volatile( "lock ;" " " "incl %0" " \n\t" : "=m"(*var) : "m"(*var) : "cc", "memory" ); }

variable_types:
var
int *


decompiled_code:
_BOOL8 __fastcall atomic_dec_and_test_int(volatile signed __int32 *a1)
{
return _InterlockedDecrement(a1) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(volatile signed __int32 *a1)
{
return _InterlockedDecrement(a1) == 0;
}

original_code: inline static int atomic_dec_and_test_int(volatile int* var) { char ret; asm volatile( "lock ;" " " "decl %0" "\n\t" "setz %1 \n\t" : "=m" (*var), "=qm"(ret) : "m"(*var) : "cc", "memory" ); return ret; }

canonical_original_code: inline static int atomic_dec_and_test_int(int *var) { char ret; asm volatile( "lock ;" " " "decl %0" "\n\t" "setz %1 \n\t" : "=m" (*var), "=qm"(ret) : "m"(*var) : "cc", "memory" ); return ret; }

variable_types: ret char


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

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

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

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

variable_types: v int


decompiled_code:
__int64 cfg_reset_handles()
{
__int64 i; // rbx
unsigned __int64 *v1; // rdx
unsigned __int64 v2; // rsi
__int64 result; // rax

if ( cfg_local )
{
for ( i = cfg_group; i; i = *(_QWORD *)(i + 72) )
{
result = cfg_ginst_count;
if ( !cfg_ginst_count )
break;
v1 = *(unsigned __int64 **)(i + 48);
v2 = *v1;
if ( *v1 < cfg_local + 4LL || v2 > cfg_block_size + cfg_local + 4LL )
result = cfg_move_handle(i, v2 - 36, 0LL);
}
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 i; // rbx
unsigned __int64 *v1; // rdx
unsigned __int64 v2; // rsi
__int64 result; // rax

if ( cfg_local )
{
for ( i = cfg_group; i; i = *(_QWORD *)(i + 72) )
{
result = cfg_ginst_count;
if ( !cfg_ginst_count )
break;
v1 = *(unsigned __int64 **)(i + 48);
v2 = *v1;
if ( *v1 < cfg_local + 4LL || v2 > cfg_block_size + cfg_local + 4LL )
result = cfg_move_handle(i, v2 - 36, 0LL);
}
}
return result;
}

original_code:
static inline void cfg_reset_handles(void)
{
 cfg_group_t *group;
 if (!cfg_local)
  return;
 for ( group = cfg_group;
  group && cfg_ginst_count;
  group = group->next
 ) {
  if (((unsigned char*)*(group->handle) < cfg_local->vars)
   || ((unsigned char*)*(group->handle) > cfg_local->vars + cfg_block_size)
  )
   cfg_move_handle(group,
     ( (((unsigned char*)(*(group->handle)) < cfg_local->vars) || ((unsigned char*)(*(group->handle)) > cfg_local->vars + cfg_block_size) ) ? (cfg_group_inst_t*)((char*)(*(group->handle)) - (unsigned long)&((cfg_group_inst_t *)0)->vars) : ((void *)0) ),
     ((void *)0));
 }
}

canonical_original_code:
static inline void cfg_reset_handles()
{
 struct _cfg_group *group;
 if (!cfg_local)
  return;
 for ( group = cfg_group;
  group && cfg_ginst_count;
  group = group->next
 ) {
  if (((unsigned char *)*(group->handle) < cfg_local->vars)
   || ((unsigned char *)*(group->handle) > cfg_local->vars + cfg_block_size)
  )
   cfg_move_handle(group,
     ( (((unsigned char *)(*(group->handle)) < cfg_local->vars) || ((unsigned char *)(*(group->handle)) > cfg_local->vars + cfg_block_size) ) ? (struct _cfg_group_inst *)((char *)(*(group->handle)) - (unsigned long)&((struct _cfg_group_inst *)0)->vars) : ((void *)0) ),
     ((void *)0));
 }
}

variable_types: struct _cfg_group { int num; struct _cfg_mapping { struct _cfg_def { char *name; unsigned int type; int min; int max; int (*on_change_cb)(void *, struct _str { char *s; int len; } *, struct _str *, void **); void (*on_set_child_cb)(struct _str *, struct _str *); char *descr; } *def; int name_len; int pos; int offset; unsigned int flag; } *mapping; char *vars; struct _cfg_add_var { struct _cfg_add_var *next; unsigned int type; union { char *ch; struct _str s; int i; } val; unsigned int group_id; int name_len; char name[1]; } *add_var; int size; int meta_offset; int var_offset; void **handle; void *orig_handle; unsigned char dynamic; struct _cfg_group *next; int name_len; char name[1]; } *

user_defined_types: struct _cfg_group { int num; struct _cfg_mapping *mapping; char *vars; struct _cfg_add_var *add_var; int size; int meta_offset; int var_offset; void **handle; void *orig_handle; unsigned char dynamic; struct _cfg_group *next; int name_len; char name[1]; }

user_defined_types: struct _cfg_group_inst { unsigned int id; unsigned int set[-1]; unsigned char vars[1]; }

user_defined_types: struct _cfg_mapping { struct _cfg_def *def; int name_len; int pos; int offset; unsigned int flag; }

user_defined_types: struct _cfg_def { char *name; unsigned int type; int min; int max; int (*on_change_cb)(void *, struct _str *, struct _str *, void **); void (*on_set_child_cb)(struct _str *, struct _str *); char *descr; }


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

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

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

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

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

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

variable_types:
lock
struct atomic_t { int val; } *


decompiled_code:
int __fastcall sleep_us(unsigned int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

v2.tv_sec = a1 / 0xF4240;
v2.tv_usec = a1 % 0xF4240;
return select(0, 0LL, 0LL, 0LL, &v2);
}

canonical_decompiled_code:
int __fastcall func5(unsigned int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

v2.tv_sec = a1 / 0xF4240;
v2.tv_usec = a1 % 0xF4240;
return select(0, 0LL, 0LL, 0LL, &v2);
}

original_code:
inline static void sleep_us( unsigned int nusecs )
{
 struct timeval tval;
 tval.tv_sec =nusecs/1000000;
 tval.tv_usec=nusecs%1000000;
 select(0, ((void *)0), ((void *)0), ((void *)0), &tval );
}

canonical_original_code:
inline static void sleep_us(unsigned int nusecs)
{
 struct timeval tval;
 tval.tv_sec =nusecs/1000000;
 tval.tv_usec=nusecs%1000000;
 select(0, ((void *)0), ((void *)0), ((void *)0), &tval );
}

variable_types:
nusecs
unsigned int

variable_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
__int64 __fastcall futex_get(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = atomic_cmpxchg_int_constprop_0(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = atomic_get_and_set_int(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = atomic_get_and_set_int(a1, 2); (_DWORD)result; result = atomic_get_and_set_int(a1, 2) )
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
return result;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = func7(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = func2(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func7(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = func2(a1, 2); (_DWORD)result; result = func2(a1, 2) )
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
return result;
}
}
}
}
return result;
}

original_code:
inline static void futex_get(futex_lock_t* lock)
{
 int v;
 register int i=1024;
retry:
 v=atomic_cmpxchg_int(&(lock)->val, 0, 1);
 if (__builtin_expect(!!(v==0), 1)){
  do {} while(0);
  return;
 }else if (__builtin_expect(!!(v==2), 0)){
  do{
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }while(v);
 }else{
  if (i>0){
   i--;
   goto retry;
  }
  v=atomic_get_and_set_int(&(lock)->val, 2);
  while(v){
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }
 }
 do {} while(0);
}

canonical_original_code:
inline static void futex_get(struct atomic_t *lock)
{
 int v;
 register int i = 1024;
retry:
 v=atomic_cmpxchg_int(&(lock)->val, 0, 1);
 if (__builtin_expect(!!(v==0), 1)){
  do {} while(0);
  return;
 }else if (__builtin_expect(!!(v==2), 0)){
  do{
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }while(v);
 }else{
  if (i>0){
   i--;
   goto retry;
  }
  v=atomic_get_and_set_int(&(lock)->val, 2);
  while(v){
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }
 }
 do {} while(0);
}


decompiled_code:
__int64 __fastcall cfg_child_cb_free_item(__int64 a1)
{
_QWORD *v1; // rax
__int64 v2; // rbx
__int64 v3; // rsi

v1 = *(_QWORD **)(a1 + 48);
if ( v1 )
{
if ( *v1 )
{
v2 = 0LL;
do
{
futex_get(mem_lock);
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2);
v2 += 8LL;
qm_free(shm_block, v3);
futex_release(mem_lock);
}
while ( *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2) );
}
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 48));
futex_release(mem_lock);
}
futex_get(mem_lock);
qm_free(shm_block, a1);
return futex_release(mem_lock);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
_QWORD *v1; // rax
__int64 v2; // rbx
__int64 v3; // rsi

v1 = *(_QWORD **)(a1 + 48);
if ( v1 )
{
if ( *v1 )
{
v2 = 0LL;
do
{
func8(mem_lock);
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2);
v2 += 8LL;
qm_free(shm_block, v3);
func4(mem_lock);
}
while ( *(_QWORD *)(*(_QWORD *)(a1 + 48) + v2) );
}
func8(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 48));
func4(mem_lock);
}
func8(mem_lock);
qm_free(shm_block, a1);
return func4(mem_lock);
}

original_code:
static inline void cfg_child_cb_free_item(cfg_child_cb_t *cb)
{
 int i;
 if (cb->replaced) {
  for (i=0; cb->replaced[i]; i++)
   do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced[i])); futex_release(mem_lock); }while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced)); futex_release(mem_lock); }while(0);
 }
 do { futex_get(mem_lock); qm_free(shm_block, (cb)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
static inline void cfg_child_cb_free_item(struct _cfg_child_cb *cb)
{
 int i;
 if (cb->replaced) {
  for (i=0; cb->replaced[i]; i++)
   do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced[i])); futex_release(mem_lock); }while(0);
  do { futex_get(mem_lock); qm_free(shm_block, (cb->replaced)); futex_release(mem_lock); }while(0);
 }
 do { futex_get(mem_lock); qm_free(shm_block, (cb)); futex_release(mem_lock); }while(0);
}

variable_types: struct _cfg_child_cb { struct atomic_t { int val; } refcnt; struct atomic_t cb_count; struct _str { char *s; int len; } gname; void (*cb)(struct _str *, struct _str *); void **replaced; struct _cfg_child_cb *next; } *

user_defined_types: struct _cfg_child_cb { struct atomic_t refcnt; struct atomic_t cb_count; struct _str gname; void (*cb)(struct _str *, struct _str *); void **replaced; struct _cfg_child_cb *next; }


decompiled_code:
__int64 __fastcall register_basic_timers(unsigned int a1)
{
if ( (int)register_procs() < 0 )
return 0xFFFFFFFFLL;
cfg_register_child(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1)
{
if ( (int)register_procs() < 0 )
return 0xFFFFFFFFLL;
cfg_register_child(a1);
return 0LL;
}

original_code:
int register_basic_timers(int timers)
{
 if(register_procs(timers)<0)
  return -1;
 cfg_register_child(timers);
 return 0;
}

variable_types: timers int


decompiled_code:
__int64 __fastcall fork_basic_timer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int v10; // eax

result = fork_process();
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
sleep(a6);
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local_constprop_0();
v10 = get_ticks();
a4(v10, a5);
}
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int v10; // eax

result = fork_process();
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
sleep(a6);
if ( cfg_ginst_count )
func3();
if ( *cfg_global != cfg_local )
func10();
v10 = get_ticks();
a4(v10, a5);
}
}
}
return 0xFFFFFFFFLL;
}

original_code:
int fork_basic_timer(int child_id, char* desc, int make_sock,
      timer_function* f, void* param, int interval)
{
 int pid;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep(interval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
  }
 }
 return pid;
}

canonical_original_code:
int fork_basic_timer(int child_id, char *desc, int make_sock, void (*f)(unsigned int ticks, void *param), void *param, int interval)
{
 int pid;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep(interval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
  }
 }
 return pid;
}

variable_types:
desc
char *

variable_types: void (*)(unsigned int ticks, void *param)

variable_types:
param
void *

variable_types: interval int

variable_types: pid int


decompiled_code:
__int64 __fastcall fork_basic_utimer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
int v10; // eax

result = fork_process();
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
sleep_us(a6);
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local_constprop_0();
v10 = get_ticks_raw();
a4((unsigned int)(1000 * v10) >> 4, a5);
}
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
int v10; // eax

result = fork_process();
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
while ( 1 )
{
func5(a6);
if ( cfg_ginst_count )
func3();
if ( *cfg_global != cfg_local )
func10();
v10 = get_ticks_raw();
a4((unsigned int)(1000 * v10) >> 4, a5);
}
}
}
return 0xFFFFFFFFLL;
}

original_code:
int fork_basic_utimer(int child_id, char* desc, int make_sock,
      utimer_function* f, void* param, int uinterval)
{
 int pid;
 ticks_t ts;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep_us(uinterval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   ts = get_ticks_raw();
   f((((ts)*1000U)/16U), param);
  }
 }
 return pid;
}

canonical_original_code:
int fork_basic_utimer(int child_id, char *desc, int make_sock, void (*f)(unsigned int uticks, void *param), void *param, int uinterval)
{
 int pid;
 unsigned int ts;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  if (cfg_child_init()) return -1;
  for(;;){
   sleep_us(uinterval);
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   ts = get_ticks_raw();
   f((((ts)*1000U)/16U), param);
  }
 }
 return pid;
}

variable_types: void (*)(unsigned int uticks, void *param)

variable_types: uinterval int

variable_types:
ts
unsigned int


decompiled_code:
__int64 __fastcall fork_local_timer_process(unsigned int a1, __int64 a2, unsigned int a3, __int64 *a4)
{
__int64 v6; // rbp
__int64 result; // rax
unsigned int v8; // eax

v6 = shm_malloc_constprop_0();
result = 0xFFFFFFFFLL;
if ( v6 )
{
v8 = get_ticks_raw();
if ( (int)init_local_timer(v6, v8) < 0 || (result = fork_process(a1, a2, a3), (int)result < 0) )
{
futex_get(mem_lock);
qm_free(shm_block, v6);
futex_release(mem_lock);
result = 0xFFFFFFFFLL;
}
else
{
*a4 = v6;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, __int64 a2, unsigned int a3, __int64 *a4)
{
__int64 v6; // rbp
__int64 result; // rax
unsigned int v8; // eax

v6 = func11();
result = 0xFFFFFFFFLL;
if ( v6 )
{
v8 = get_ticks_raw();
if ( (int)init_local_timer(v6, v8) < 0 || (result = fork_process(a1, a2, a3), (int)result < 0) )
{
func8(mem_lock);
qm_free(shm_block, v6);
func4(mem_lock);
result = 0xFFFFFFFFLL;
}
else
{
*a4 = v6;
}
}
return result;
}

original_code:
int fork_local_timer_process(int child_id, char* desc, int make_sock,
      struct local_timer** lt_h)
{
 int pid;
 struct local_timer* lt;
 lt=shm_malloc(sizeof(*lt));
 if (lt==0) goto error;
 if (init_local_timer(lt, get_ticks_raw())<0) goto error;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) goto error;
 *lt_h=lt;
 return pid;
error:
 if (lt) do { futex_get(mem_lock); qm_free(shm_block, (lt)); futex_release(mem_lock); }while(0);
 return -1;
}

canonical_original_code:
int fork_local_timer_process(int child_id, char *desc, int make_sock, struct local_timer **lt_h)
{
 int pid;
 struct local_timer *lt;
 lt=shm_malloc(sizeof(*lt));
 if (lt==0) goto error;
 if (init_local_timer(lt, get_ticks_raw())<0) goto error;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) goto error;
 *lt_h=lt;
 return pid;
error:
 if (lt) do { futex_get(mem_lock); qm_free(shm_block, (lt)); futex_release(mem_lock); }while(0);
 return -1;
}

variable_types: struct local_timer { unsigned int prev_ticks; struct timer_lists { struct timer_head { struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; } *next; struct timer_ln *prev; } h0[-1]; struct timer_head h1[-1]; struct timer_head h2[-1]; struct timer_head expired; } timer_lst; } **

user_defined_types: struct local_timer { unsigned int prev_ticks; struct timer_lists timer_lst; }

user_defined_types: struct timer_lists { struct timer_head h0[-1]; struct timer_head h1[-1]; struct timer_head h2[-1]; struct timer_head expired; }

user_defined_types: struct timer_head { struct timer_ln *next; struct timer_ln *prev; }


decompiled_code:
// attributes: thunk
__int64 __fastcall register_sync_timers(unsigned int a1)
{
return register_basic_timers(a1);
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1)
{
return func12(a1);
}

original_code:
int register_sync_timers(int timers)
{
 if(register_procs(timers)<0)
  return -1;
 cfg_register_child(timers);
 return 0;
}


decompiled_code:
__int64 __fastcall fork_sync_timer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // edi
unsigned int v11; // eax
int v12; // ebx

result = fork_process(a1, a2, a3);
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v12 - get_ticks() )
{
if ( !i )
i = 1;
sleep(i);
v12 = get_ticks();
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local_constprop_0();
v11 = get_ticks();
a4(v11, a5);
}
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // edi
unsigned int v11; // eax
int v12; // ebx

result = fork_process(a1, a2, a3);
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v12 - get_ticks() )
{
if ( !i )
i = 1;
sleep(i);
v12 = get_ticks();
if ( cfg_ginst_count )
func3();
if ( *cfg_global != cfg_local )
func10();
v11 = get_ticks();
a4(v11, a5);
}
}
}
return 0xFFFFFFFFLL;
}

original_code:
int fork_sync_timer(int child_id, char* desc, int make_sock,
      timer_function* f, void* param, int interval)
{
 int pid;
 ticks_t ts1 = 0;
 ticks_t ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = interval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep(ts2);
   else sleep(1);
   ts1 = get_ticks();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
   ts2 = interval - get_ticks() + ts1;
  }
 }
 return pid;
}

canonical_original_code:
int fork_sync_timer(int child_id, char *desc, int make_sock, void (*f)(unsigned int ticks, void *param), void *param, int interval)
{
 int pid;
 unsigned int ts1 = 0;
 unsigned int ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = interval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep(ts2);
   else sleep(1);
   ts1 = get_ticks();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f(get_ticks(), param);
   ts2 = interval - get_ticks() + ts1;
  }
 }
 return pid;
}


decompiled_code:
__int64 __fastcall fork_sync_utimer(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // ebx
int v11; // ebx

result = fork_process(a1, a2, a3);
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v11 - get_ticks_raw() )
{
if ( i )
sleep_us(a6);
else
sleep_us(1u);
v11 = get_ticks_raw();
if ( cfg_ginst_count )
cfg_reset_handles();
if ( *cfg_global != cfg_local )
cfg_update_local_constprop_0();
a4((unsigned int)(1000 * v11) >> 4, a5);
}
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 a2, __int64 a3, void (__fastcall *a4)(_QWORD, __int64), __int64 a5, unsigned int a6)
{
__int64 result; // rax
unsigned int i; // ebx
int v11; // ebx

result = fork_process(a1, a2, a3);
if ( (int)result >= 0 )
{
if ( (_DWORD)result )
return result;
if ( !(unsigned int)cfg_child_init() )
{
for ( i = a6; ; i = a6 + v11 - get_ticks_raw() )
{
if ( i )
func5(a6);
else
func5(1u);
v11 = get_ticks_raw();
if ( cfg_ginst_count )
func3();
if ( *cfg_global != cfg_local )
func10();
a4((unsigned int)(1000 * v11) >> 4, a5);
}
}
}
return 0xFFFFFFFFLL;
}

original_code:
int fork_sync_utimer(int child_id, char* desc, int make_sock,
      utimer_function* f, void* param, int uinterval)
{
 int pid;
 ticks_t ts1 = 0;
 ticks_t ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = uinterval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep_us(uinterval);
   else sleep_us(1);
   ts1 = get_ticks_raw();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f((((ts1)*1000U)/16U), param);
   ts2 = uinterval - get_ticks_raw() + ts1;
  }
 }
 return pid;
}

canonical_original_code:
int fork_sync_utimer(int child_id, char *desc, int make_sock, void (*f)(unsigned int uticks, void *param), void *param, int uinterval)
{
 int pid;
 unsigned int ts1 = 0;
 unsigned int ts2 = 0;
 pid=fork_process(child_id, desc, make_sock);
 if (pid<0) return -1;
 if (pid==0){
  ts2 = uinterval;
  if (cfg_child_init()) return -1;
  for(;;){
   if(ts2>0) sleep_us(uinterval);
   else sleep_us(1);
   ts1 = get_ticks_raw();
   do { if (__builtin_expect(!!(cfg_ginst_count), 0)) cfg_reset_handles(); if (__builtin_expect(!!(cfg_local != *cfg_global), 0)) cfg_update_local(0); } while(0);
   f((((ts1)*1000U)/16U), param);
   ts2 = uinterval - get_ticks_raw() + ts1;
  }
 }
 return pid;
}