decompiled_code:
__int64 __fastcall event_parser(char *a1, int a2, __int64 a3)
{
int v4; // er12
char *v5; // r13
int v6; // esi
char *v7; // rax
char *v8; // r14
int v9; // ebp
int v10; // ecx
int v12; // eax
__int64 v13; // rsi
__int64 v14; // rdx
int v15; // eax
__int64 v16; // rbp
unsigned int v17; // eax
__int64 v18; // rdx
const char *v19; // r9
const char *v20; // rsi
__int64 v21; // r8
__int64 v22; // rcx
__int64 v23; // r8
struct _IO_FILE *v24; // rdi
__int64 v25; // rbx
unsigned int v26; // eax
__int64 v27; // r10
__int64 v28; // rbx
unsigned int v29; // eax
__int64 v30; // [rsp-8h] [rbp-40h]
__int64 v31; // [rsp-8h] [rbp-40h]
char *s1; // [rsp+0h] [rbp-38h] BYREF
int v33; // [rsp+8h] [rbp-30h]

if ( !a3 )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_parser: Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:91]: ",
"event_parser");
goto LABEL_39;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v25 = *((_QWORD *)&log_level_info + 8);
v26 = my_pid();
v18 = process_no;
v19 = "<core> [parser/parse_event.c:91]: ";
v20 = "%2d(%d) %s: %s%s(): event_parser: Invalid parameter value\n";
v30 = v27;
v22 = v26;
v23 = v25;
goto LABEL_48;
}
s1 = a1;
v33 = a2;
trim_leading((__int64)&s1);
v4 = v33;
if ( !v33 )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_parser: Empty body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:100]: ",
"event_parser");
goto LABEL_39;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v16 = *((_QWORD *)&log_level_info + 8);
v17 = my_pid();
v18 = process_no;
v19 = "<core> [parser/parse_event.c:100]: ";
v20 = "%2d(%d) %s: %s%s(): event_parser: Empty body\n";
v30 = v21;
v22 = v17;
v23 = v16;
LABEL_48:
v24 = stderr;
fprintf(stderr, v20, v18, v22, v23, v19, "event_parser", v30);
if ( log_color )
dprint_color_reset(v24, v20, v31);
goto LABEL_39;
}
v5 = s1;
v6 = v33;
*(_QWORD *)(a3 + 8) = s1;
v7 = skip_token(v5, v6);
*(_DWORD *)a3 = 0;
v8 = v7;
v9 = (_DWORD)v7 - (_DWORD)v5;
*(_DWORD *)(a3 + 16) = (_DWORD)v7 - (_DWORD)v5;
if ( (_DWORD)v7 - (_DWORD)v5 == 8 )
{
v12 = strncasecmp(v5, "presence", 8uLL);
if ( !v12 )
goto LABEL_14;
}
else if ( v9 == 14 )
{
if ( !strncasecmp(v5, "presence.winfo", 0xEuLL) )
{
v12 = 1;
LABEL_14:
*(_DWORD *)a3 = dword_E30[6 * v12];
goto LABEL_9;
}
}
else
{
if ( v9 != 11 )
{
if ( v9 == 15 )
{
if ( strncasecmp(v5, "message-summary", 0xFuLL) )
goto LABEL_9;
v12 = 4;
}
else if ( v9 == 6 )
{
if ( strncasecmp(v5, "dialog", 6uLL) )
goto LABEL_9;
v12 = 5;
}
else
{
if ( v9 != 10 || strncasecmp(v5, "ua-profile", 0xAuLL) )
goto LABEL_9;
v12 = 6;
}
goto LABEL_14;
}
if ( !strncasecmp(v5, "xcap-change", 0xBuLL) )
{
v12 = 2;
goto LABEL_14;
}
if ( !strncasecmp(v5, "sip-profile", 0xBuLL) )
{
v12 = 3;
goto LABEL_14;
}
}
LABEL_9:
s1 = v8;
v33 = v4 - v9;
trim_leading((__int64)&s1);
v10 = v33;
*(_QWORD *)(a3 + 96) = 0LL;
if ( !v10 )
return 0LL;
if ( *s1 != 59 )
return 0LL;
++s1;
v33 = v10 - 1;
trim_leading((__int64)&s1);
if ( !v33 )
return 0LL;
v13 = 0LL;
v14 = 0LL;
if ( *(_DWORD *)a3 == 5 )
{
v14 = a3 + 24;
v13 = 3LL;
}
if ( (int)parse_params(&s1, v13, v14, a3 + 96) >= 0 )
return 0LL;
v15 = get_debug_level("core", 4LL);
if ( v15 + 1 < 0 == __OFADD__(1, v15) && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_parser: Error while parsing parameters parameters\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:137]: ",
"event_parser");
LABEL_39:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v28 = *((_QWORD *)&log_level_info + 8);
v29 = my_pid();
v18 = process_no;
v19 = "<core> [parser/parse_event.c:137]: ";
v30 = 4LL;
v22 = v29;
v23 = v28;
v20 = "%2d(%d) %s: %s%s(): event_parser: Error while parsing parameters parameters\n";
goto LABEL_48;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1, int a2, __int64 a3)
{
int v4; // er12
char *v5; // r13
int v6; // esi
char *v7; // rax
char *v8; // r14
int v9; // ebp
int v10; // ecx
int v12; // eax
__int64 v13; // rsi
__int64 v14; // rdx
int v15; // eax
__int64 v16; // rbp
unsigned int v17; // eax
__int64 v18; // rdx
const char *v19; // r9
const char *v20; // rsi
__int64 v21; // r8
__int64 v22; // rcx
__int64 v23; // r8
struct _IO_FILE *v24; // rdi
__int64 v25; // rbx
unsigned int v26; // eax
__int64 v27; // r10
__int64 v28; // rbx
unsigned int v29; // eax
__int64 v30; // [rsp-8h] [rbp-40h]
__int64 v31; // [rsp-8h] [rbp-40h]
char *s1; // [rsp+0h] [rbp-38h] BYREF
int v33; // [rsp+8h] [rbp-30h]

if ( !a3 )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_parser: Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:91]: ",
"event_parser");
goto LABEL_39;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v25 = *((_QWORD *)&log_level_info + 8);
v26 = my_pid();
v18 = process_no;
v19 = "<core> [parser/parse_event.c:91]: ";
v20 = "%2d(%d) %s: %s%s(): event_parser: Invalid parameter value\n";
v30 = v27;
v22 = v26;
v23 = v25;
goto LABEL_48;
}
s1 = a1;
v33 = a2;
func0((__int64)&s1);
v4 = v33;
if ( !v33 )
{
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_parser: Empty body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:100]: ",
"event_parser");
goto LABEL_39;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v16 = *((_QWORD *)&log_level_info + 8);
v17 = my_pid();
v18 = process_no;
v19 = "<core> [parser/parse_event.c:100]: ";
v20 = "%2d(%d) %s: %s%s(): event_parser: Empty body\n";
v30 = v21;
v22 = v17;
v23 = v16;
LABEL_48:
v24 = stderr;
fprintf(stderr, v20, v18, v22, v23, v19, "event_parser", v30);
if ( log_color )
dprint_color_reset(v24, v20, v31);
goto LABEL_39;
}
v5 = s1;
v6 = v33;
*(_QWORD *)(a3 + 8) = s1;
v7 = skip_token(v5, v6);
*(_DWORD *)a3 = 0;
v8 = v7;
v9 = (_DWORD)v7 - (_DWORD)v5;
*(_DWORD *)(a3 + 16) = (_DWORD)v7 - (_DWORD)v5;
if ( (_DWORD)v7 - (_DWORD)v5 == 8 )
{
v12 = strncasecmp(v5, "presence", 8uLL);
if ( !v12 )
goto LABEL_14;
}
else if ( v9 == 14 )
{
if ( !strncasecmp(v5, "presence.winfo", 0xEuLL) )
{
v12 = 1;
LABEL_14:
*(_DWORD *)a3 = dword_E30[6 * v12];
goto LABEL_9;
}
}
else
{
if ( v9 != 11 )
{
if ( v9 == 15 )
{
if ( strncasecmp(v5, "message-summary", 0xFuLL) )
goto LABEL_9;
v12 = 4;
}
else if ( v9 == 6 )
{
if ( strncasecmp(v5, "dialog", 6uLL) )
goto LABEL_9;
v12 = 5;
}
else
{
if ( v9 != 10 || strncasecmp(v5, "ua-profile", 0xAuLL) )
goto LABEL_9;
v12 = 6;
}
goto LABEL_14;
}
if ( !strncasecmp(v5, "xcap-change", 0xBuLL) )
{
v12 = 2;
goto LABEL_14;
}
if ( !strncasecmp(v5, "sip-profile", 0xBuLL) )
{
v12 = 3;
goto LABEL_14;
}
}
LABEL_9:
s1 = v8;
v33 = v4 - v9;
func0((__int64)&s1);
v10 = v33;
*(_QWORD *)(a3 + 96) = 0LL;
if ( !v10 )
return 0LL;
if ( *s1 != 59 )
return 0LL;
++s1;
v33 = v10 - 1;
func0((__int64)&s1);
if ( !v33 )
return 0LL;
v13 = 0LL;
v14 = 0LL;
if ( *(_DWORD *)a3 == 5 )
{
v14 = a3 + 24;
v13 = 3LL;
}
if ( (int)parse_params(&s1, v13, v14, a3 + 96) >= 0 )
return 0LL;
v15 = get_debug_level("core", 4LL);
if ( v15 + 1 < 0 == __OFADD__(1, v15) && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): event_parser: Error while parsing parameters parameters\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:137]: ",
"event_parser");
LABEL_39:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v28 = *((_QWORD *)&log_level_info + 8);
v29 = my_pid();
v18 = process_no;
v19 = "<core> [parser/parse_event.c:137]: ";
v30 = 4LL;
v22 = v29;
v23 = v28;
v20 = "%2d(%d) %s: %s%s(): event_parser: Error while parsing parameters parameters\n";
goto LABEL_48;
}
return 0xFFFFFFFFLL;
}

original_code:
int event_parser(char* s, int len, event_t* e)
{
 int i;
 str tmp;
 char* end;
 param_hooks_t* phooks = ((void *)0);
 enum pclass pclass = CLASS_ANY;
 if (e == ((void *)0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "event_parser: Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __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(): " "event_parser: Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_parser: Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __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(): " "event_parser: Invalid parameter value\n", ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_parser: Invalid parameter value\n", ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 tmp.s = s;
 tmp.len = len;
 trim_leading(&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(): " "event_parser: Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __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(): " "event_parser: Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_parser: Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __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(): " "event_parser: Empty body\n", ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_parser: Empty body\n", ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 e->name.s = tmp.s;
 end = skip_token(tmp.s, tmp.len);
 e->name.len = end - tmp.s;
 e->type = EVENT_OTHER;
 for(i = 0; events[i].name.len; i++) {
  if (e->name.len == events[i].name.len &&
   !strncasecmp(e->name.s, events[i].name.s, e->name.len)) {
   e->type = events[i].type;
   break;
  }
 }
 tmp.len -= end - tmp.s;
 tmp.s = end;
 trim_leading(&tmp);
 e->params.list = ((void *)0);
 if (tmp.len && (tmp.s[0] == ';')) {
  tmp.s++; tmp.len--;
  trim_leading(&tmp);
  if (!tmp.len) return 0;
  if (e->type == EVENT_DIALOG) {
   pclass = CLASS_EVENT_DIALOG;
   phooks = (param_hooks_t*)&e->params.hooks;
  }
  if (parse_params(&tmp, pclass, phooks, &e->params.list) < 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(): " "event_parser: Error while parsing parameters parameters\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __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(): " "event_parser: Error while parsing parameters parameters\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_parser: Error while parsing parameters parameters\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __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(): " "event_parser: Error while parsing parameters parameters\n", ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_parser: Error while parsing parameters parameters\n", ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
 }
 return 0;
}

canonical_original_code:
int event_parser(char *s, int len, struct event *e)
{
 int i;
 struct _str tmp;
 char *end;
 union param_hooks *phooks = ((void *)0);
 enum pclass pclass = CLASS_ANY;
 if (e == ((void *)0)) {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "event_parser: Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __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(): " "event_parser: Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_parser: Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __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(): " "event_parser: Invalid parameter value\n", ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_parser: Invalid parameter value\n", ("<core> [" "parser/parse_event.c" ":" "91" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 tmp.s = s;
 tmp.len = len;
 trim_leading(&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(): " "event_parser: Empty body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __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(): " "event_parser: Empty body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_parser: Empty body\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __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(): " "event_parser: Empty body\n", ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_parser: Empty body\n", ("<core> [" "parser/parse_event.c" ":" "100" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 e->name.s = tmp.s;
 end = skip_token(tmp.s, tmp.len);
 e->name.len = end - tmp.s;
 e->type = EVENT_OTHER;
 for(i = 0; events[i].name.len; i++) {
  if (e->name.len == events[i].name.len &&
   !strncasecmp(e->name.s, events[i].name.s, e->name.len)) {
   e->type = events[i].type;
   break;
  }
 }
 tmp.len -= end - tmp.s;
 tmp.s = end;
 trim_leading(&tmp);
 e->params.list = ((void *)0);
 if (tmp.len && (tmp.s[0] == ';')) {
  tmp.s++; tmp.len--;
  trim_leading(&tmp);
  if (!tmp.len) return 0;
  if (e->type == EVENT_DIALOG) {
   pclass = CLASS_EVENT_DIALOG;
   phooks = (union param_hooks *)&e->params.hooks;
  }
  if (parse_params(&tmp, pclass, phooks, &e->params.list) < 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(): " "event_parser: Error while parsing parameters parameters\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __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(): " "event_parser: Error while parsing parameters parameters\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "event_parser: Error while parsing parameters parameters\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __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(): " "event_parser: Error while parsing parameters parameters\n", ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "event_parser: Error while parsing parameters parameters\n", ("<core> [" "parser/parse_event.c" ":" "137" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
 }
 return 0;
}

variable_types:
s
char *

variable_types: struct event { enum event_type { EVENT_OTHER=0, EVENT_PRESENCE=1, EVENT_PRESENCE_WINFO=2, EVENT_SIP_PROFILE=3, EVENT_XCAP_CHANGE=4, EVENT_DIALOG=5, EVENT_MESSAGE_SUMMARY=6, EVENT_UA_PROFILE=7 } type; struct _str { char *s; int len; } name; struct event_params { union param_hooks { struct contact_hooks { struct param { enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 } type; struct _str name; struct _str body; int len; struct param *next; } *expires; struct param *q; struct param *methods; struct param *received; struct param *instance; struct param *reg_id; struct param *ob; } contact; struct uri_hooks { struct param *transport; struct param *lr; struct param *r2; struct param *maddr; struct param *ttl; struct param *dstip; struct param *dstport; struct param *ftag; struct param *ob; } uri; struct event_dialog_hooks { struct param *call_id; struct param *from_tag; struct param *to_tag; struct param *include_session_description; struct param *sla; struct param *ma; } event_dialog; } hooks; struct param *list; } params; } *

variable_types: i int

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

variable_types:
end
char *

variable_types: union param_hooks { struct contact_hooks { struct param { enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 } type; struct _str { char *s; int len; } name; struct _str body; int len; struct param *next; } *expires; struct param *q; struct param *methods; struct param *received; struct param *instance; struct param *reg_id; struct param *ob; } contact; struct uri_hooks { struct param *transport; struct param *lr; struct param *r2; struct param *maddr; struct param *ttl; struct param *dstip; struct param *dstport; struct param *ftag; struct param *ob; } uri; struct event_dialog_hooks { struct param *call_id; struct param *from_tag; struct param *to_tag; struct param *include_session_description; struct param *sla; struct param *ma; } event_dialog; } *

variable_types: enum pclass { CLASS_ANY=0, CLASS_CONTACT=1, CLASS_URI=2, CLASS_EVENT_DIALOG=3 }

user_defined_types: struct event { enum event_type type; struct _str name; struct event_params params; }

user_defined_types: struct event_params { union param_hooks hooks; struct param *list; }


repo: virtualolson/who

decompiled_code:
__int64 __fastcall parse_event(__int64 a1)
{
unsigned int v1; // er12
_QWORD *v3; // rax
_QWORD *v4; // rbp
const char *v5; // rbp
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 = (_QWORD *)qm_malloc(mem_block, 104LL);
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_event(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/parse_event.c:158]: ",
"parse_event");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): parse_event(): No memory left\n", v7);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_event(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:158]: ",
"parse_event");
}
v1 = -1;
--dprint_crit;
}
return v1;
}
*v3 = 0LL;
v3[12] = 0LL;
memset(
(void *)((unsigned __int64)(v3 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v3 - (((_DWORD)v3 + 8) & 0xFFFFFFF8) + 104) >> 3));
if ( (int)event_parser(*(char **)(a1 + 24), *(_DWORD *)(a1 + 32), (__int64)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_event(): Error in event_parser\n",
process_no,
v9,
v8,
"<core> [parser/parse_event.c:165]: ",
"parse_event");
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): parse_event(): Error in event_parser\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_event(): Error in event_parser\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:165]: ",
"parse_event");
}
--dprint_crit;
}
v1 = -2;
qm_free(mem_block, v4);
return v1;
}
*(_QWORD *)(a1 + 48) = v4;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // er12
_QWORD *v3; // rax
_QWORD *v4; // rbp
const char *v5; // rbp
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 = (_QWORD *)qm_malloc(mem_block, 104LL);
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_event(): No memory left\n",
process_no,
v6,
v5,
"<core> [parser/parse_event.c:158]: ",
"parse_event");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): parse_event(): No memory left\n", v7);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_event(): No memory left\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:158]: ",
"parse_event");
}
v1 = -1;
--dprint_crit;
}
return v1;
}
*v3 = 0LL;
v3[12] = 0LL;
memset(
(void *)((unsigned __int64)(v3 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v3 - (((_DWORD)v3 + 8) & 0xFFFFFFF8) + 104) >> 3));
if ( (int)func1(*(char **)(a1 + 24), *(_DWORD *)(a1 + 32), (__int64)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_event(): Error in event_parser\n",
process_no,
v9,
v8,
"<core> [parser/parse_event.c:165]: ",
"parse_event");
if ( log_color )
dprint_color_reset(v10, "%2d(%d) %s: %s%s(): parse_event(): Error in event_parser\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_event(): Error in event_parser\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_event.c:165]: ",
"parse_event");
}
--dprint_crit;
}
v1 = -2;
qm_free(mem_block, v4);
return v1;
}
*(_QWORD *)(a1 + 48) = v4;
return 0LL;
}

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

canonical_original_code:
int parse_event(struct hdr_field *_h)
{
 struct event *e;
 if (_h->parsed != 0) {
  return 0;
 }
 e = (struct event *)qm_malloc(mem_block, (sizeof(event_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_event(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "158" "]: ") , __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_event(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "158" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_event(): No memory left\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "158" "]: ") , __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_event(): No memory left\n", ("<core> [" "parser/parse_event.c" ":" "158" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_event(): No memory left\n", ("<core> [" "parser/parse_event.c" ":" "158" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(e, 0, sizeof(event_t));
 if (event_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_event(): Error in event_parser\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "165" "]: ") , __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_event(): Error in event_parser\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_event.c" ":" "165" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_event(): Error in event_parser\n", process_no, my_pid(), ("<core> [" "parser/parse_event.c" ":" "165" "]: ") , __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_event(): Error in event_parser\n", ("<core> [" "parser/parse_event.c" ":" "165" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_event(): Error in event_parser\n", ("<core> [" "parser/parse_event.c" ":" "165" "]: ") , __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; } *

return_type: int

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

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

user_defined_types: enum event_type { EVENT_OTHER=0, EVENT_PRESENCE=1, EVENT_PRESENCE_WINFO=2, EVENT_SIP_PROFILE=3, EVENT_XCAP_CHANGE=4, EVENT_DIALOG=5, EVENT_MESSAGE_SUMMARY=6, EVENT_UA_PROFILE=7 }

user_defined_types: union param_hooks { struct contact_hooks contact; struct uri_hooks uri; struct event_dialog_hooks event_dialog; }

user_defined_types: struct contact_hooks { struct param *expires; struct param *q; struct param *methods; struct param *received; struct param *instance; struct param *reg_id; struct param *ob; }

user_defined_types: struct uri_hooks { struct param *transport; struct param *lr; struct param *r2; struct param *maddr; struct param *ttl; struct param *dstip; struct param *dstport; struct param *ftag; struct param *ob; }

user_defined_types: struct event_dialog_hooks { struct param *call_id; struct param *from_tag; struct param *to_tag; struct param *include_session_description; struct param *sla; struct param *ma; }

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

user_defined_types: enum ptype { P_OTHER=0, P_Q=1, P_EXPIRES=2, P_METHODS=3, P_RECEIVED=4, P_TRANSPORT=5, P_LR=6, P_R2=7, P_MADDR=8, P_TTL=9, P_DSTIP=10, P_DSTPORT=11, P_INSTANCE=12, P_REG_ID=13, P_FTAG=14, P_CALL_ID=15, P_FROM_TAG=16, P_TO_TAG=17, P_ISD=18, P_SLA=19, P_MA=20, P_OB=21 }


decompiled_code:
size_t __fastcall print_event(const char **a1)
{
fwrite("===Event===\n", 1uLL, 0xCuLL, stderr);
fprintf(stderr, "name : '%.*s'\n", *((_DWORD *)a1 + 4), a1[1]);
fprintf(stderr, "type: %d\n", *(unsigned int *)a1);
if ( a1[12] )
print_params(stderr);
return fwrite("===/Event===\n", 1uLL, 0xDuLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func4(const char **a1)
{
fwrite("===Event===\n", 1uLL, 0xCuLL, stderr);
fprintf(stderr, "name : '%.*s'\n", *((_DWORD *)a1 + 4), a1[1]);
fprintf(stderr, "type: %d\n", *(unsigned int *)a1);
if ( a1[12] )
print_params(stderr);
return fwrite("===/Event===\n", 1uLL, 0xDuLL, stderr);
}

original_code:
void print_event(event_t* e)
{
 fprintf(stderr, "===Event===\n");
 fprintf(stderr, "name  : \'%.*s\'\n", ((&e->name != (str *)0) ? (&e->name)->len : 0), ((&e->name != (str *)0) ? (&e->name)->s : ""));
 fprintf(stderr, "type: %d\n", e->type);
 if (e->params.list) {
  print_params(stderr, e->params.list);
 }
 fprintf(stderr, "===/Event===\n");
}

canonical_original_code:
void print_event(struct event *e)
{
 fprintf(stderr, "===Event===\n");
 fprintf(stderr, "name  : \'%.*s\'\n", ((&e->name != (struct _str *)0) ? (&e->name)->len : 0), ((&e->name != (struct _str *)0) ? (&e->name)->s : ""));
 fprintf(stderr, "type: %d\n", e->type);
 if (e->params.list) {
  print_params(stderr, e->params.list);
 }
 fprintf(stderr, "===/Event===\n");
}

return_type: void


decompiled_code:
__int64 __fastcall append_str_list(__int64 a1, int a2, __int64 a3, _DWORD *a4)
{
__int64 v6; // rax
__int64 v7; // r12
const char *v9; // r13
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi

v6 = qm_malloc(mem_block, 24LL);
v7 = v6;
if ( v6 )
{
*(_QWORD *)(v6 + 16) = 0LL;
*(_QWORD *)v6 = a1;
*(_DWORD *)(v6 + 8) = a2;
*(_QWORD *)(*(_QWORD *)a3 + 16LL) = v6;
*(_QWORD *)a3 = v6;
*a4 += a2;
}
else if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): could not allocate private memory from available pool",
process_no,
v10,
v9,
"<core> [str_list.c:48]: ",
"append_str_list");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v11,
"%2d(%d) %s: %s%s(): could not allocate private memory from available pool");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): could not allocate private memory from available pool",
*((const char **)&log_level_info + 8),
"<core> [str_list.c:48]: ",
"append_str_list");
}
--dprint_crit;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, __int64 a3, _DWORD *a4)
{
__int64 v6; // rax
__int64 v7; // r12
const char *v9; // r13
unsigned int v10; // eax
struct _IO_FILE *v11; // rdi

v6 = qm_malloc(mem_block, 24LL);
v7 = v6;
if ( v6 )
{
*(_QWORD *)(v6 + 16) = 0LL;
*(_QWORD *)v6 = a1;
*(_DWORD *)(v6 + 8) = a2;
*(_QWORD *)(*(_QWORD *)a3 + 16LL) = v6;
*(_QWORD *)a3 = v6;
*a4 += a2;
}
else if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v9 = (const char *)*((_QWORD *)&log_level_info + 8);
v10 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): could not allocate private memory from available pool",
process_no,
v10,
v9,
"<core> [str_list.c:48]: ",
"append_str_list");
if ( log_color )
((void (__fastcall *)(struct _IO_FILE *, const char *))dprint_color_reset)(
v11,
"%2d(%d) %s: %s%s(): could not allocate private memory from available pool");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): could not allocate private memory from available pool",
*((const char **)&log_level_info + 8),
"<core> [str_list.c:48]: ",
"append_str_list");
}
--dprint_crit;
}
return v7;
}

original_code:
struct str_list *append_str_list(char *s, int len, struct str_list **last, int *total)
{
 struct str_list *new;
 new = qm_malloc(mem_block, (sizeof(struct str_list)));
 if (!new) {
  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(): " "could not allocate private memory from available pool", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "str_list.c" ":" "48" "]: ") , __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(): " "could not allocate private memory from available pool", (log_level_info[((-1)) - (-5)].name), ("<core> [" "str_list.c" ":" "48" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "could not allocate private memory from available pool", process_no, my_pid(), ("<core> [" "str_list.c" ":" "48" "]: ") , __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(): " "could not allocate private memory from available pool", ("<core> [" "str_list.c" ":" "48" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "could not allocate private memory from available pool", ("<core> [" "str_list.c" ":" "48" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 new->s.s = s;
 new->s.len = len;
 new->next = 0;
 (*last)->next = new;
 *last = new;
 *total += len;
 return new;
}

variable_types: len int

variable_types:
last
struct str_list **

variable_types:
total
int *

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

user_defined_types: struct str_list { struct _str s; struct str_list *next; }


decompiled_code:
__int64 pv_register_core_vars()
{
return register_pvars_mod("core", &core_pvs);
}

canonical_decompiled_code:
__int64 func1()
{
return register_pvars_mod("core", &core_pvs);
}

original_code:
int pv_register_core_vars(void)
{
 return register_pvars_mod("core", core_pvs);
}

canonical_original_code:
int pv_register_core_vars()
{
 return register_pvars_mod("core", core_pvs);
}