decompiled_code:
__int64 __fastcall parse_methods(__int64 a1, _DWORD *a2)
{
char *v2; // rdx
int v3; // ecx
unsigned int v4; // er12
__int64 v6; // r12
unsigned int v7; // eax
__int64 v8; // rdx
const char *v9; // r9
__int64 v10; // rcx
__int64 v11; // r8
const char *v12; // rsi
struct _IO_FILE *v13; // rdi
__int64 v14; // r12
unsigned int v15; // eax
const char *v16; // rbx
unsigned int v17; // eax
struct _IO_FILE *v18; // rdi
__int64 v19; // rbx
unsigned int v20; // eax
int v21; // [rsp+Ch] [rbp-2Ch] BYREF
char *v22; // [rsp+10h] [rbp-28h] BYREF
int v23; // [rsp+18h] [rbp-20h]

v21 = 0;
if ( !a1 || !a2 )
{
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(): parse_methods: Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:367]: ",
"parse_methods");
LABEL_21:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v19 = *((_QWORD *)&log_level_info + 8);
v20 = my_pid();
v8 = process_no;
v9 = "<core> [parser/parse_methods.c:367]: ";
v12 = "%2d(%d) %s: %s%s(): parse_methods: Invalid parameter value\n";
v10 = v20;
v11 = v19;
LABEL_29:
v13 = stderr;
fprintf(stderr, v12, v8, v10, v11, v9, "parse_methods");
if ( log_color )
dprint_color_reset(v13, v12);
goto LABEL_21;
}
v2 = *(char **)a1;
v23 = *(_DWORD *)(a1 + 8);
v22 = v2;
trim_leading((__int64)&v22);
v3 = v23;
*a2 = 0;
if ( v3 )
{
while ( 1 )
{
if ( !(unsigned int)parse_method_advance(&v22, &v21) )
{
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(): ERROR: parse_methods: Invalid method\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:386]: ",
"parse_methods");
goto LABEL_21;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = *((_QWORD *)&log_level_info + 8);
v7 = my_pid();
v8 = process_no;
v9 = "<core> [parser/parse_methods.c:386]: ";
v10 = v7;
v11 = v6;
v12 = "%2d(%d) %s: %s%s(): ERROR: parse_methods: Invalid method\n";
goto LABEL_29;
}
*a2 |= v21;
trim_leading((__int64)&v22);
if ( !v23 )
return 0;
if ( *v22 != 44 )
break;
--v23;
++v22;
trim_leading((__int64)&v22);
if ( !v23 )
{
if ( (int)get_debug_level("core", 4LL) < -1 )
return 0;
v4 = dprint_crit;
if ( dprint_crit )
return 0;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v16 = (const char *)*((_QWORD *)&log_level_info + 8);
v17 = my_pid();
v18 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_methods: Method expected\n",
process_no,
v17,
v16,
"<core> [parser/parse_methods.c:397]: ",
"parse_methods");
if ( log_color )
dprint_color_reset(v18, "%2d(%d) %s: %s%s(): ERROR: parse_methods: Method expected\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_methods: Method expected\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:397]: ",
"parse_methods");
}
--dprint_crit;
return v4;
}
}
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(): ERROR: parse_methods: Comma expected\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:401]: ",
"parse_methods");
goto LABEL_21;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = *((_QWORD *)&log_level_info + 8);
v15 = my_pid();
v8 = process_no;
v9 = "<core> [parser/parse_methods.c:401]: ";
v10 = v15;
v11 = v14;
v12 = "%2d(%d) %s: %s%s(): ERROR: parse_methods: Comma expected\n";
goto LABEL_29;
}
return 0;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2)
{
char *v2; // rdx
int v3; // ecx
unsigned int v4; // er12
__int64 v6; // r12
unsigned int v7; // eax
__int64 v8; // rdx
const char *v9; // r9
__int64 v10; // rcx
__int64 v11; // r8
const char *v12; // rsi
struct _IO_FILE *v13; // rdi
__int64 v14; // r12
unsigned int v15; // eax
const char *v16; // rbx
unsigned int v17; // eax
struct _IO_FILE *v18; // rdi
__int64 v19; // rbx
unsigned int v20; // eax
int v21; // [rsp+Ch] [rbp-2Ch] BYREF
char *v22; // [rsp+10h] [rbp-28h] BYREF
int v23; // [rsp+18h] [rbp-20h]

v21 = 0;
if ( !a1 || !a2 )
{
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(): parse_methods: Invalid parameter value\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:367]: ",
"parse_methods");
LABEL_21:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v19 = *((_QWORD *)&log_level_info + 8);
v20 = my_pid();
v8 = process_no;
v9 = "<core> [parser/parse_methods.c:367]: ";
v12 = "%2d(%d) %s: %s%s(): parse_methods: Invalid parameter value\n";
v10 = v20;
v11 = v19;
LABEL_29:
v13 = stderr;
fprintf(stderr, v12, v8, v10, v11, v9, "parse_methods");
if ( log_color )
dprint_color_reset(v13, v12);
goto LABEL_21;
}
v2 = *(char **)a1;
v23 = *(_DWORD *)(a1 + 8);
v22 = v2;
func0((__int64)&v22);
v3 = v23;
*a2 = 0;
if ( v3 )
{
while ( 1 )
{
if ( !(unsigned int)func2(&v22, &v21) )
{
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(): ERROR: parse_methods: Invalid method\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:386]: ",
"parse_methods");
goto LABEL_21;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v6 = *((_QWORD *)&log_level_info + 8);
v7 = my_pid();
v8 = process_no;
v9 = "<core> [parser/parse_methods.c:386]: ";
v10 = v7;
v11 = v6;
v12 = "%2d(%d) %s: %s%s(): ERROR: parse_methods: Invalid method\n";
goto LABEL_29;
}
*a2 |= v21;
func0((__int64)&v22);
if ( !v23 )
return 0;
if ( *v22 != 44 )
break;
--v23;
++v22;
func0((__int64)&v22);
if ( !v23 )
{
if ( (int)get_debug_level("core", 4LL) < -1 )
return 0;
v4 = dprint_crit;
if ( dprint_crit )
return 0;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v16 = (const char *)*((_QWORD *)&log_level_info + 8);
v17 = my_pid();
v18 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_methods: Method expected\n",
process_no,
v17,
v16,
"<core> [parser/parse_methods.c:397]: ",
"parse_methods");
if ( log_color )
dprint_color_reset(v18, "%2d(%d) %s: %s%s(): ERROR: parse_methods: Method expected\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_methods: Method expected\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:397]: ",
"parse_methods");
}
--dprint_crit;
return v4;
}
}
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(): ERROR: parse_methods: Comma expected\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_methods.c:401]: ",
"parse_methods");
goto LABEL_21;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = *((_QWORD *)&log_level_info + 8);
v15 = my_pid();
v8 = process_no;
v9 = "<core> [parser/parse_methods.c:401]: ";
v10 = v15;
v11 = v14;
v12 = "%2d(%d) %s: %s%s(): ERROR: parse_methods: Comma expected\n";
goto LABEL_29;
}
return 0;
}

original_code:
int parse_methods(const str* const _body, unsigned int* const _methods)
 {
  str next;
  unsigned int method;
 method=0;
 if (!_body || !_methods) {
  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_methods: Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __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_methods: Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_methods: Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __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_methods: Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_methods: Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 next.len = _body->len;
 next.s = _body->s;
  trim_leading(&next);
   *_methods = 0;
  if (next.len == 0) {
   return 0;
  }
  while (1) {
   if (parse_method_advance(&next, &method)) {
    *_methods |= method;
   } else {
    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(): " "ERROR: parse_methods: Invalid method\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: parse_methods: Invalid method\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_methods: Invalid method\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Invalid method\n", ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Invalid method\n", ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    return -1;
   }
   trim_leading(&next);
   if (next.len) {
    if (next.s[0] == ',') {
     next.len--;
     next.s++;
     trim_leading(&next);
     if (next.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(): " "ERROR: parse_methods: Method expected\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: parse_methods: Method expected\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_methods: Method expected\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Method expected\n", ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Method expected\n", ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); } } (dprint_crit--); } } while(0);
      return 0;
     }
    } else {
     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(): " "ERROR: parse_methods: Comma expected\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: parse_methods: Comma expected\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_methods: Comma expected\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Comma expected\n", ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Comma expected\n", ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); } } (dprint_crit--); } } while(0);
     return -1;
    }
   } else {
    break;
   }
  }
  return 0;
 }

canonical_original_code:
int parse_methods(struct _str *_body, unsigned int *_methods)
 {
  struct _str next;
  unsigned int method;
 method=0;
 if (!_body || !_methods) {
  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_methods: Invalid parameter value\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __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_methods: Invalid parameter value\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_methods: Invalid parameter value\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __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_methods: Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_methods: Invalid parameter value\n", ("<core> [" "parser/parse_methods.c" ":" "367" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 next.len = _body->len;
 next.s = _body->s;
  trim_leading(&next);
   *_methods = 0;
  if (next.len == 0) {
   return 0;
  }
  while (1) {
   if (parse_method_advance(&next, &method)) {
    *_methods |= method;
   } else {
    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(): " "ERROR: parse_methods: Invalid method\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: parse_methods: Invalid method\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_methods: Invalid method\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Invalid method\n", ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Invalid method\n", ("<core> [" "parser/parse_methods.c" ":" "386" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    return -1;
   }
   trim_leading(&next);
   if (next.len) {
    if (next.s[0] == ',') {
     next.len--;
     next.s++;
     trim_leading(&next);
     if (next.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(): " "ERROR: parse_methods: Method expected\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: parse_methods: Method expected\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_methods: Method expected\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Method expected\n", ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Method expected\n", ("<core> [" "parser/parse_methods.c" ":" "397" "]: ") , __func__); } } (dprint_crit--); } } while(0);
      return 0;
     }
    } else {
     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(): " "ERROR: parse_methods: Comma expected\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR: parse_methods: Comma expected\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_methods: Comma expected\n", process_no, my_pid(), ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Comma expected\n", ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR: parse_methods: Comma expected\n", ("<core> [" "parser/parse_methods.c" ":" "401" "]: ") , __func__); } } (dprint_crit--); } } while(0);
     return -1;
    }
   } else {
    break;
   }
  }
  return 0;
 }

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

variable_types:
method
unsigned int


repo: virtualolson/who

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 func0(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:
var
int *

variable_types: v int

return_type: int


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 func1(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

result = func0(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; } *

return_type: void


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 func3(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = func2(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = func0(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = func0(a1, 2); (_DWORD)result; result = func0(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);
}

variable_types: i int


decompiled_code:
__int64 __fastcall notify_watchers(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 i; // rbx
__int64 result; // rax

for ( i = *(_QWORD *)(a1 + 72); i; i = *(_QWORD *)(i + 16) )
result = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD, _QWORD))i)(a1 + 8, a2 + 32, a3, *(_QWORD *)(i + 8));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 i; // rbx
__int64 result; // rax

for ( i = *(_QWORD *)(a1 + 72); i; i = *(_QWORD *)(i + 16) )
result = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD, _QWORD))i)(a1 + 8, a2 + 32, a3, *(_QWORD *)(i + 8));
return result;
}

original_code:
void notify_watchers(struct urecord* _r, ucontact_t *_c, int state)
{
 notify_cb_t* n;
 n = _r->watchers;
        while(n) {
  n->cb(&_r->uid, &_c->c, state, n->data);
  n = n->next;
 }
}

canonical_original_code:
void notify_watchers(struct urecord *_r, struct ucontact *_c, int state)
{
 struct notify_cb *n;
 n = _r->watchers;
        while(n) {
  n->cb(&_r->uid, &_c->c, state, n->data);
  n = n->next;
 }
}

variable_types: struct urecord { struct _str { char *s; int len; } *domain; struct _str uid; struct ucontact { struct _str *domain; struct _str *uid; struct _str aor; struct _str c; struct _str received; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *sock; long expires; int q; struct _str callid; int cseq; enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 } state; unsigned int flags; struct _str user_agent; struct _str instance; int server_id; struct ucontact *next; struct ucontact *prev; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *avps; } *contacts; struct hslot { int n; struct urecord *first; struct urecord *last; struct udomain { struct _str *name; int users; int expired; int db_cmd_idx; struct hslot *table; struct { int n; struct urecord *first; struct urecord *last; } d_ll; struct atomic_t { int val; } lock; } *d; } *slot; struct { struct urecord *prev; struct urecord *next; } d_ll; struct { struct urecord *prev; struct urecord *next; } s_ll; struct notify_cb { void (*cb)(struct _str *uid, struct _str *_contact, enum pres_state { PRES_OFFLINE=0, PRES_ONLINE=1 } _p, void *_d); void *data; struct notify_cb *next; } *watchers; } *

variable_types: state int

variable_types: struct notify_cb { void (*cb)(struct _str { char *s; int len; } *uid, struct _str *_contact, enum pres_state { PRES_OFFLINE=0, PRES_ONLINE=1 } _p, void *_d); void *data; struct notify_cb *next; } *

user_defined_types: struct urecord { struct _str *domain; struct _str uid; struct ucontact *contacts; struct hslot *slot; struct { struct urecord *prev; struct urecord *next; } d_ll; struct { struct urecord *prev; struct urecord *next; } s_ll; struct notify_cb *watchers; }

user_defined_types: struct notify_cb { void (*cb)(struct _str *uid, struct _str *_contact, enum pres_state _p, void *_d); void *data; struct notify_cb *next; }

user_defined_types: struct ucontact { struct _str *domain; struct _str *uid; struct _str aor; struct _str c; struct _str received; struct socket_info *sock; long expires; int q; struct _str callid; int cseq; enum cstate state; unsigned int flags; struct _str user_agent; struct _str instance; int server_id; struct ucontact *next; struct ucontact *prev; struct usr_avp *avps; }

user_defined_types: struct hslot { int n; struct urecord *first; struct urecord *last; struct udomain *d; }

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

user_defined_types: struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data d; }

user_defined_types: struct udomain { struct _str *name; int users; int expired; int db_cmd_idx; struct hslot *table; struct { int n; struct urecord *first; struct urecord *last; } d_ll; struct atomic_t lock; }

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

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

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

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


decompiled_code:
__int64 __fastcall add_watcher(__int64 a1, void (__fastcall *a2)(__int64, __int64, __int64, __int64), void (__fastcall *a3)(__int64, __int64, __int64, __int64))
{
void (__fastcall *v3)(__int64, __int64, __int64, __int64); // r12
void (__fastcall **v4)(__int64, __int64, __int64, __int64); // rax
__int64 v5; // rdx
void (__fastcall *v6)(__int64, __int64, __int64, __int64); // rcx
void (__fastcall **v7)(__int64, __int64, __int64, __int64); // rbp
__int64 v8; // rbx
__int64 result; // rax
int v10; // er8
const char *v11; // rbx
struct _IO_FILE *v12; // rdi
__int64 v13; // [rsp-10h] [rbp-48h]
unsigned int v14; // [rsp-8h] [rbp-40h]

v3 = a2;
v4 = (void (__fastcall **)(__int64, __int64, __int64, __int64))shm_malloc_constprop_0();
v6 = a3;
if ( v4 )
{
*v4 = a2;
v7 = v4;
v8 = *(_QWORD *)(a1 + 24);
v4[1] = a3;
v4[2] = *(void (__fastcall **)(__int64, __int64, __int64, __int64))(a1 + 72);
*(_QWORD *)(a1 + 72) = v4;
if ( v8 )
{
while ( 1 )
{
v3(a1 + 8, v8 + 32, 1LL, (__int64)v6);
v8 = *(_QWORD *)(v8 + 160);
if ( !v8 )
break;
v3 = *v7;
v6 = v7[1];
}
}
result = 0LL;
}
else
{
v10 = get_debug_level("usrloc", 6LL, v5, a3);
result = 0xFFFFFFFFLL;
if ( v10 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v11 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
v12 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): add_watcher(): No memory left\n",
process_no,
v14,
v11,
"usrloc [notify.c:58]: ",
"add_watcher");
if ( log_color )
dprint_color_reset(v12, "%2d(%d) %s: %s%s(): add_watcher(): No memory left\n", v13);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): add_watcher(): No memory left\n",
*((const char **)&log_level_info + 8),
"usrloc [notify.c:58]: ",
"add_watcher");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, void (__fastcall *a2)(__int64, __int64, __int64, __int64), void (__fastcall *a3)(__int64, __int64, __int64, __int64))
{
void (__fastcall *v3)(__int64, __int64, __int64, __int64); // r12
void (__fastcall **v4)(__int64, __int64, __int64, __int64); // rax
__int64 v5; // rdx
void (__fastcall *v6)(__int64, __int64, __int64, __int64); // rcx
void (__fastcall **v7)(__int64, __int64, __int64, __int64); // rbp
__int64 v8; // rbx
__int64 result; // rax
int v10; // er8
const char *v11; // rbx
struct _IO_FILE *v12; // rdi
__int64 v13; // [rsp-10h] [rbp-48h]
unsigned int v14; // [rsp-8h] [rbp-40h]

v3 = a2;
v4 = (void (__fastcall **)(__int64, __int64, __int64, __int64))func4();
v6 = a3;
if ( v4 )
{
*v4 = a2;
v7 = v4;
v8 = *(_QWORD *)(a1 + 24);
v4[1] = a3;
v4[2] = *(void (__fastcall **)(__int64, __int64, __int64, __int64))(a1 + 72);
*(_QWORD *)(a1 + 72) = v4;
if ( v8 )
{
while ( 1 )
{
v3(a1 + 8, v8 + 32, 1LL, (__int64)v6);
v8 = *(_QWORD *)(v8 + 160);
if ( !v8 )
break;
v3 = *v7;
v6 = v7[1];
}
}
result = 0LL;
}
else
{
v10 = get_debug_level("usrloc", 6LL, v5, a3);
result = 0xFFFFFFFFLL;
if ( v10 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v11 = (const char *)*((_QWORD *)&log_level_info + 8);
v14 = my_pid();
v12 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): add_watcher(): No memory left\n",
process_no,
v14,
v11,
"usrloc [notify.c:58]: ",
"add_watcher");
if ( log_color )
dprint_color_reset(v12, "%2d(%d) %s: %s%s(): add_watcher(): No memory left\n", v13);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): add_watcher(): No memory left\n",
*((const char **)&log_level_info + 8),
"usrloc [notify.c:58]: ",
"add_watcher");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

original_code:
int add_watcher(struct urecord* _r, notcb_t _c, void* _d)
{
 notify_cb_t* ptr;
 ucontact_t *c;
 ptr = (notify_cb_t*)shm_malloc(sizeof(notify_cb_t));
 if (ptr == 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "add_watcher(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "58" "]: ") , __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(): " "add_watcher(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "58" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "add_watcher(): No memory left\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "58" "]: ") , __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(): " "add_watcher(): No memory left\n", ("usrloc" " [" "notify.c" ":" "58" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "add_watcher(): No memory left\n", ("usrloc" " [" "notify.c" ":" "58" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 ptr->cb = _c;
 ptr->data = _d;
 ptr->next = _r->watchers;
 _r->watchers = ptr;
 c = _r->contacts;
 while (c) {
  ptr->cb(&_r->uid, &c->c, PRES_ONLINE, ptr->data);
  c = c->next;
 }
 return 0;
}

canonical_original_code:
int add_watcher(struct urecord *_r, void (*_c)(struct _str *uid, struct _str *_contact, enum pres_state _p, void *_d), void *_d)
{
 struct notify_cb *ptr;
 struct ucontact *c;
 ptr = (struct notify_cb *)shm_malloc(sizeof(notify_cb_t));
 if (ptr == 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "add_watcher(): No memory left\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "58" "]: ") , __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(): " "add_watcher(): No memory left\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "58" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "add_watcher(): No memory left\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "58" "]: ") , __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(): " "add_watcher(): No memory left\n", ("usrloc" " [" "notify.c" ":" "58" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "add_watcher(): No memory left\n", ("usrloc" " [" "notify.c" ":" "58" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 ptr->cb = _c;
 ptr->data = _d;
 ptr->next = _r->watchers;
 _r->watchers = ptr;
 c = _r->contacts;
 while (c) {
  ptr->cb(&_r->uid, &c->c, PRES_ONLINE, ptr->data);
  c = c->next;
 }
 return 0;
}

variable_types: void (*)(struct _str *uid, struct _str *_contact, enum pres_state { PRES_OFFLINE=0, PRES_ONLINE=1 } _p, void *_d)

variable_types: struct ucontact { struct _str { char *s; int len; } *domain; struct _str *uid; struct _str aor; struct _str c; struct _str received; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *sock; long expires; int q; struct _str callid; int cseq; enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 } state; unsigned int flags; struct _str user_agent; struct _str instance; int server_id; struct ucontact *next; struct ucontact *prev; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *avps; } *

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 register_watcher(__int64 a1, __int64 a2, void (__fastcall *a3)(__int64, __int64, __int64, __int64), void (__fastcall *a4)(__int64, __int64, __int64, __int64))
{
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rdx
__int64 v9; // rcx
__int64 result; // rax
int v11; // ebp
char *v12; // r12
__int64 v13; // rdx
__int64 v14; // rcx
int v15; // ebx
const char *v16; // r12
int v17; // ebx
const char *v18; // r14
struct _IO_FILE *v19; // rdi
__int64 v20; // rdx
const char *v21; // r12
struct _IO_FILE *v22; // rdi
const char *v23; // r14
unsigned int v24; // eax
struct _IO_FILE *v25; // rdi
__int64 v26; // rdx
__int64 v27; // [rsp-10h] [rbp-48h]
unsigned int v28; // [rsp-8h] [rbp-40h]
unsigned int v29; // [rsp-8h] [rbp-40h]
__int64 v30; // [rsp+0h] [rbp-38h] BYREF
__int64 v31[6]; // [rsp+8h] [rbp-30h] BYREF

if ( (int)find_domain(&dom, &v30) > 0 )
{
v11 = get_debug_level("usrloc", 6LL, v6, v7);
result = 0xFFFFFFFFLL;
if ( v11 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v16 = dom;
if ( !dom )
v16 = (const char *)&LC4;
v17 = *((_DWORD *)&dom + 2);
v18 = (const char *)*((_QWORD *)&log_level_info + 8);
v28 = my_pid();
v19 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): register_watcher(): Domain '%.*s' not found\n",
process_no,
v28,
v18,
"usrloc [notify.c:101]: ",
"register_watcher",
v17,
v16);
if ( log_color )
dprint_color_reset(v19, "%2d(%d) %s: %s%s(): register_watcher(): Domain '%.*s' not found\n", v20);
}
else
{
v12 = dom;
if ( !dom )
v12 = (char *)&LC4;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): register_watcher(): Domain '%.*s' not found\n",
*((_QWORD *)&log_level_info + 8),
"usrloc [notify.c:101]: ",
"register_watcher",
*((unsigned int *)&dom + 2),
v12);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
else
{
lock_udomain(v30);
if ( (int)get_urecord(v30, a2, v31) > 0 && (int)insert_urecord(v30, a2, v31) < 0 )
{
unlock_udomain(v30);
v15 = get_debug_level("usrloc", 6LL, v13, v14);
result = 4294967294LL;
if ( v15 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v23 = (const char *)*((_QWORD *)&log_level_info + 8);
v24 = my_pid();
v25 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): register_watcher(): Error while creating a new record\n",
process_no,
v24,
v23,
"usrloc [notify.c:110]: ",
"register_watcher");
if ( log_color )
dprint_color_reset(v25, "%2d(%d) %s: %s%s(): register_watcher(): Error while creating a new record\n", v26);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): register_watcher(): Error while creating a new record\n",
*((const char **)&log_level_info + 8),
"usrloc [notify.c:110]: ",
"register_watcher");
}
result = 4294967294LL;
--dprint_crit;
}
}
else if ( (int)add_watcher(v31[0], a3, a4) < 0 )
{
if ( (int)get_debug_level("usrloc", 6LL, v8, v9) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v21 = (const char *)*((_QWORD *)&log_level_info + 8);
v29 = my_pid();
v22 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): register_watcher(): Error while adding a watcher\n",
process_no,
v29,
v21,
"usrloc [notify.c:116]: ",
"register_watcher");
if ( log_color )
dprint_color_reset(v22, "%2d(%d) %s: %s%s(): register_watcher(): Error while adding a watcher\n", v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): register_watcher(): Error while adding a watcher\n",
*((const char **)&log_level_info + 8),
"usrloc [notify.c:116]: ",
"register_watcher");
}
--dprint_crit;
}
release_urecord(v31[0]);
unlock_udomain(v30);
result = 4294967293LL;
}
else
{
unlock_udomain(v30);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, void (__fastcall *a3)(__int64, __int64, __int64, __int64), void (__fastcall *a4)(__int64, __int64, __int64, __int64))
{
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rdx
__int64 v9; // rcx
__int64 result; // rax
int v11; // ebp
char *v12; // r12
__int64 v13; // rdx
__int64 v14; // rcx
int v15; // ebx
const char *v16; // r12
int v17; // ebx
const char *v18; // r14
struct _IO_FILE *v19; // rdi
__int64 v20; // rdx
const char *v21; // r12
struct _IO_FILE *v22; // rdi
const char *v23; // r14
unsigned int v24; // eax
struct _IO_FILE *v25; // rdi
__int64 v26; // rdx
__int64 v27; // [rsp-10h] [rbp-48h]
unsigned int v28; // [rsp-8h] [rbp-40h]
unsigned int v29; // [rsp-8h] [rbp-40h]
__int64 v30; // [rsp+0h] [rbp-38h] BYREF
__int64 v31[6]; // [rsp+8h] [rbp-30h] BYREF

if ( (int)find_domain(&dom, &v30) > 0 )
{
v11 = get_debug_level("usrloc", 6LL, v6, v7);
result = 0xFFFFFFFFLL;
if ( v11 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v16 = dom;
if ( !dom )
v16 = (const char *)&LC4;
v17 = *((_DWORD *)&dom + 2);
v18 = (const char *)*((_QWORD *)&log_level_info + 8);
v28 = my_pid();
v19 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): register_watcher(): Domain '%.*s' not found\n",
process_no,
v28,
v18,
"usrloc [notify.c:101]: ",
"register_watcher",
v17,
v16);
if ( log_color )
dprint_color_reset(v19, "%2d(%d) %s: %s%s(): register_watcher(): Domain '%.*s' not found\n", v20);
}
else
{
v12 = dom;
if ( !dom )
v12 = (char *)&LC4;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): register_watcher(): Domain '%.*s' not found\n",
*((_QWORD *)&log_level_info + 8),
"usrloc [notify.c:101]: ",
"register_watcher",
*((unsigned int *)&dom + 2),
v12);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
else
{
lock_udomain(v30);
if ( (int)get_urecord(v30, a2, v31) > 0 && (int)insert_urecord(v30, a2, v31) < 0 )
{
unlock_udomain(v30);
v15 = get_debug_level("usrloc", 6LL, v13, v14);
result = 4294967294LL;
if ( v15 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v23 = (const char *)*((_QWORD *)&log_level_info + 8);
v24 = my_pid();
v25 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): register_watcher(): Error while creating a new record\n",
process_no,
v24,
v23,
"usrloc [notify.c:110]: ",
"register_watcher");
if ( log_color )
dprint_color_reset(v25, "%2d(%d) %s: %s%s(): register_watcher(): Error while creating a new record\n", v26);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): register_watcher(): Error while creating a new record\n",
*((const char **)&log_level_info + 8),
"usrloc [notify.c:110]: ",
"register_watcher");
}
result = 4294967294LL;
--dprint_crit;
}
}
else if ( (int)func6(v31[0], a3, a4) < 0 )
{
if ( (int)get_debug_level("usrloc", 6LL, v8, v9) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v21 = (const char *)*((_QWORD *)&log_level_info + 8);
v29 = my_pid();
v22 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): register_watcher(): Error while adding a watcher\n",
process_no,
v29,
v21,
"usrloc [notify.c:116]: ",
"register_watcher");
if ( log_color )
dprint_color_reset(v22, "%2d(%d) %s: %s%s(): register_watcher(): Error while adding a watcher\n", v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): register_watcher(): Error while adding a watcher\n",
*((const char **)&log_level_info + 8),
"usrloc [notify.c:116]: ",
"register_watcher");
}
--dprint_crit;
}
release_urecord(v31[0]);
unlock_udomain(v30);
result = 4294967293LL;
}
else
{
unlock_udomain(v30);
result = 0LL;
}
}
return result;
}

original_code:
int register_watcher(str* _f, str* _t, notcb_t _c, void* _data)
{
 udomain_t* d;
 urecord_t* r;
 if (find_domain(&dom, &d) > 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "register_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "register_watcher(): Domain '%.*s' not found\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "register_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "register_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "register_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } (dprint_crit--); } } while(0);
  return -1;
 }
 lock_udomain(d);
 if (get_urecord(d, _t, &r) > 0) {
  if (insert_urecord(d, _t, &r) < 0) {
   unlock_udomain(d);
   do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "register_watcher(): Error while creating a new record\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "110" "]: ") , __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(): " "register_watcher(): Error while creating a new record\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "register_watcher(): Error while creating a new record\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "110" "]: ") , __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(): " "register_watcher(): Error while creating a new record\n", ("usrloc" " [" "notify.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(): " "register_watcher(): Error while creating a new record\n", ("usrloc" " [" "notify.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -2;
  }
 }
 if (add_watcher(r, _c, _data) < 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "register_watcher(): Error while adding a watcher\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "116" "]: ") , __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(): " "register_watcher(): Error while adding a watcher\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "116" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "register_watcher(): Error while adding a watcher\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "116" "]: ") , __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(): " "register_watcher(): Error while adding a watcher\n", ("usrloc" " [" "notify.c" ":" "116" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "register_watcher(): Error while adding a watcher\n", ("usrloc" " [" "notify.c" ":" "116" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  release_urecord(r);
  unlock_udomain(d);
  return -3;
 }
 unlock_udomain(d);
 return 0;
}

canonical_original_code:
int register_watcher(struct _str *_f, struct _str *_t, void (*_c)(struct _str *uid, struct _str *_contact, enum pres_state _p, void *_d), void *_data)
{
 struct udomain *d;
 struct urecord *r;
 if (find_domain(&dom, &d) > 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "register_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "register_watcher(): Domain '%.*s' not found\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "register_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "register_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "register_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "101" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } (dprint_crit--); } } while(0);
  return -1;
 }
 lock_udomain(d);
 if (get_urecord(d, _t, &r) > 0) {
  if (insert_urecord(d, _t, &r) < 0) {
   unlock_udomain(d);
   do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "register_watcher(): Error while creating a new record\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "110" "]: ") , __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(): " "register_watcher(): Error while creating a new record\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "110" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "register_watcher(): Error while creating a new record\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "110" "]: ") , __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(): " "register_watcher(): Error while creating a new record\n", ("usrloc" " [" "notify.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(): " "register_watcher(): Error while creating a new record\n", ("usrloc" " [" "notify.c" ":" "110" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -2;
  }
 }
 if (add_watcher(r, _c, _data) < 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "register_watcher(): Error while adding a watcher\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "116" "]: ") , __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(): " "register_watcher(): Error while adding a watcher\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "116" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "register_watcher(): Error while adding a watcher\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "116" "]: ") , __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(): " "register_watcher(): Error while adding a watcher\n", ("usrloc" " [" "notify.c" ":" "116" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "register_watcher(): Error while adding a watcher\n", ("usrloc" " [" "notify.c" ":" "116" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  release_urecord(r);
  unlock_udomain(d);
  return -3;
 }
 unlock_udomain(d);
 return 0;
}

variable_types: struct udomain { struct _str { char *s; int len; } *name; int users; int expired; int db_cmd_idx; struct hslot { int n; struct urecord { struct _str *domain; struct _str uid; struct ucontact { struct _str *domain; struct _str *uid; struct _str aor; struct _str c; struct _str received; struct socket_info { int socket; struct _str name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *sock; long expires; int q; struct _str callid; int cseq; enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 } state; unsigned int flags; struct _str user_agent; struct _str instance; int server_id; struct ucontact *next; struct ucontact *prev; struct usr_avp { unsigned short id; unsigned int flags; struct usr_avp *next; union usr_avp_data { void *p; long l; char data[-1]; } d; } *avps; } *contacts; struct hslot *slot; struct { struct urecord *prev; struct urecord *next; } d_ll; struct { struct urecord *prev; struct urecord *next; } s_ll; struct notify_cb { void (*cb)(struct _str *uid, struct _str *_contact, enum pres_state { PRES_OFFLINE=0, PRES_ONLINE=1 } _p, void *_d); void *data; struct notify_cb *next; } *watchers; } *first; struct urecord *last; struct udomain *d; } *table; struct { int n; struct urecord *first; struct urecord *last; } d_ll; struct atomic_t { int val; } lock; } *


decompiled_code:
__int64 __fastcall unregister_watcher(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rdx
unsigned int v9; // er12
__int64 result; // rax
__int64 v11; // rdx
__int64 v12; // rcx
unsigned int v13; // er12
char *v14; // r8
const char *v15; // r13
unsigned int v16; // eax
struct _IO_FILE *v17; // rdi
const char *v18; // rbx
const char *v19; // r13
int v20; // er14
unsigned int v21; // eax
struct _IO_FILE *v22; // rdi
__int64 v23; // rdx
__int64 v24; // [rsp+0h] [rbp-38h] BYREF
__int64 v25[6]; // [rsp+8h] [rbp-30h] BYREF

if ( (int)find_domain(&dom, &v24) > 0 )
{
v9 = -1;
if ( (int)get_debug_level("usrloc", 6LL, v6, v7) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v18 = dom;
if ( !dom )
v18 = (const char *)&LC4;
v19 = (const char *)*((_QWORD *)&log_level_info + 8);
v20 = *((_DWORD *)&dom + 2);
v21 = my_pid();
v22 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): unregister_watcher(): Domain '%.*s' not found\n",
process_no,
v21,
v19,
"usrloc [notify.c:134]: ",
"unregister_watcher",
v20,
v18);
if ( log_color )
dprint_color_reset(v22, "%2d(%d) %s: %s%s(): unregister_watcher(): Domain '%.*s' not found\n", v23);
}
else
{
v14 = dom;
if ( !dom )
v14 = (char *)&LC4;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): unregister_watcher(): Domain '%.*s' not found\n",
*((_QWORD *)&log_level_info + 8),
"usrloc [notify.c:134]: ",
"unregister_watcher",
*((unsigned int *)&dom + 2),
v14);
}
v9 = -1;
--dprint_crit;
}
return v9;
}
lock_udomain(v24);
if ( (int)get_urecord(v24, a2, v25) <= 0 )
{
v8 = a4;
v9 = 0;
remove_watcher(v25[0], a3, v8);
release_urecord(v25[0]);
unlock_udomain(v24);
return v9;
}
v9 = 0;
unlock_udomain(v24);
if ( (int)get_debug_level("usrloc", 6LL, v11, v12) <= 2 )
return v9;
v13 = dprint_crit;
if ( dprint_crit )
return 0LL;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v15 = (const char *)*((_QWORD *)&log_level_info + 16);
v16 = my_pid();
v17 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): unregister_watcher(): Record not found\n",
process_no,
v16,
v15,
"usrloc [notify.c:142]: ",
"unregister_watcher");
if ( log_color )
dprint_color_reset(v17, "%2d(%d) %s: %s%s(): unregister_watcher(): Record not found\n", log_color);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): unregister_watcher(): Record not found\n",
*((const char **)&log_level_info + 16),
"usrloc [notify.c:142]: ",
"unregister_watcher");
}
result = v13;
--dprint_crit;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rdx
unsigned int v9; // er12
__int64 result; // rax
__int64 v11; // rdx
__int64 v12; // rcx
unsigned int v13; // er12
char *v14; // r8
const char *v15; // r13
unsigned int v16; // eax
struct _IO_FILE *v17; // rdi
const char *v18; // rbx
const char *v19; // r13
int v20; // er14
unsigned int v21; // eax
struct _IO_FILE *v22; // rdi
__int64 v23; // rdx
__int64 v24; // [rsp+0h] [rbp-38h] BYREF
__int64 v25[6]; // [rsp+8h] [rbp-30h] BYREF

if ( (int)find_domain(&dom, &v24) > 0 )
{
v9 = -1;
if ( (int)get_debug_level("usrloc", 6LL, v6, v7) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v18 = dom;
if ( !dom )
v18 = (const char *)&LC4;
v19 = (const char *)*((_QWORD *)&log_level_info + 8);
v20 = *((_DWORD *)&dom + 2);
v21 = my_pid();
v22 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): unregister_watcher(): Domain '%.*s' not found\n",
process_no,
v21,
v19,
"usrloc [notify.c:134]: ",
"unregister_watcher",
v20,
v18);
if ( log_color )
dprint_color_reset(v22, "%2d(%d) %s: %s%s(): unregister_watcher(): Domain '%.*s' not found\n", v23);
}
else
{
v14 = dom;
if ( !dom )
v14 = (char *)&LC4;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): unregister_watcher(): Domain '%.*s' not found\n",
*((_QWORD *)&log_level_info + 8),
"usrloc [notify.c:134]: ",
"unregister_watcher",
*((unsigned int *)&dom + 2),
v14);
}
v9 = -1;
--dprint_crit;
}
return v9;
}
lock_udomain(v24);
if ( (int)get_urecord(v24, a2, v25) <= 0 )
{
v8 = a4;
v9 = 0;
func7(v25[0], a3, v8);
release_urecord(v25[0]);
unlock_udomain(v24);
return v9;
}
v9 = 0;
unlock_udomain(v24);
if ( (int)get_debug_level("usrloc", 6LL, v11, v12) <= 2 )
return v9;
v13 = dprint_crit;
if ( dprint_crit )
return 0LL;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v15 = (const char *)*((_QWORD *)&log_level_info + 16);
v16 = my_pid();
v17 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): unregister_watcher(): Record not found\n",
process_no,
v16,
v15,
"usrloc [notify.c:142]: ",
"unregister_watcher");
if ( log_color )
dprint_color_reset(v17, "%2d(%d) %s: %s%s(): unregister_watcher(): Record not found\n", log_color);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): unregister_watcher(): Record not found\n",
*((const char **)&log_level_info + 16),
"usrloc [notify.c:142]: ",
"unregister_watcher");
}
result = v13;
--dprint_crit;
return result;
}

original_code:
int unregister_watcher(str* _f, str* _t, notcb_t _c, void* _data)
{
 udomain_t* d;
 urecord_t* r;
 if (find_domain(&dom, &d) > 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "unregister_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "unregister_watcher(): Domain '%.*s' not found\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "unregister_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "unregister_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "unregister_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } (dprint_crit--); } } while(0);
  return -1;
 }
 lock_udomain(d);
 if (get_urecord(d, _t, &r) > 0) {
  unlock_udomain(d);
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "unregister_watcher(): Record not found\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "142" "]: ") , __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(): " "unregister_watcher(): Record not found\n", (log_level_info[((3)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "142" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "unregister_watcher(): Record not found\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "142" "]: ") , __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(): " "unregister_watcher(): Record not found\n", ("usrloc" " [" "notify.c" ":" "142" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "unregister_watcher(): Record not found\n", ("usrloc" " [" "notify.c" ":" "142" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 remove_watcher(r, _c, _data);
 release_urecord(r);
 unlock_udomain(d);
 return 0;
}

canonical_original_code:
int unregister_watcher(struct _str *_f, struct _str *_t, void (*_c)(struct _str *uid, struct _str *_contact, enum pres_state _p, void *_d), void *_data)
{
 struct udomain *d;
 struct urecord *r;
 if (find_domain(&dom, &d) > 0) {
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "unregister_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "unregister_watcher(): Domain '%.*s' not found\n", (log_level_info[((-1)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "unregister_watcher(): Domain '%.*s' not found\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); 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(): " "unregister_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "unregister_watcher(): Domain '%.*s' not found\n", ("usrloc" " [" "notify.c" ":" "134" "]: ") , __func__, dom.len, ((dom.s)?(dom.s):"")); } } (dprint_crit--); } } while(0);
  return -1;
 }
 lock_udomain(d);
 if (get_urecord(d, _t, &r) > 0) {
  unlock_udomain(d);
  do { if (get_debug_level("usrloc", (sizeof("usrloc")-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(): " "unregister_watcher(): Record not found\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "142" "]: ") , __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(): " "unregister_watcher(): Record not found\n", (log_level_info[((3)) - (-5)].name), ("usrloc" " [" "notify.c" ":" "142" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "unregister_watcher(): Record not found\n", process_no, my_pid(), ("usrloc" " [" "notify.c" ":" "142" "]: ") , __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(): " "unregister_watcher(): Record not found\n", ("usrloc" " [" "notify.c" ":" "142" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "unregister_watcher(): Record not found\n", ("usrloc" " [" "notify.c" ":" "142" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return 0;
 }
 remove_watcher(r, _c, _data);
 release_urecord(r);
 unlock_udomain(d);
 return 0;
}

user_defined_types: enum pres_state { PRES_OFFLINE=0, PRES_ONLINE=1 }

user_defined_types: enum cstate { CS_NEW=0, CS_SYNC=1, CS_DIRTY=2 }

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

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

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

user_defined_types: union usr_avp_data { void *p; long l; char data[-1]; }

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

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