decompiled_code:
char *__fastcall parse_retry_after(char *a1, unsigned __int64 a2, __int64 a3, _DWORD *a4)
{
unsigned __int64 v5; // rbx
char *v6; // rax
__int64 v7; // rdx
_DWORD *v8; // r10
char *v9; // r12
int v10; // esi
__int64 v11; // rax
unsigned __int64 v12; // rax
char *v13; // rdi
int v14; // er8
__int64 v16; // r8
char *v17; // r10
char v18; // di
const char *v19; // rbx
unsigned int v20; // eax
struct _IO_FILE *v21; // rdi
__int64 v22; // rcx
const char *v23; // r8
const char *v24; // r9
const char *v25; // r12
unsigned int v26; // eax
struct _IO_FILE *v27; // rdi
__int64 v28; // rcx
const char *v29; // [rsp-10h] [rbp-28h]
const char *v30; // [rsp-8h] [rbp-20h]
const char *v31; // [rsp+0h] [rbp-18h]

v5 = a2;
v6 = eat_lws_end(a1, a2);
v9 = v6;
if ( (unsigned __int64)v6 >= a2 )
goto LABEL_19;
v7 = 0LL;
v10 = 0;
v11 = ((_BYTE)v5 - (_BYTE)v6) & 3;
if ( (((_BYTE)v5 - (_BYTE)v9) & 3) != 0 )
{
if ( v11 == 1 )
goto LABEL_7;
if ( v11 != 2 )
{
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) > 9u )
goto LABEL_26;
v7 = (unsigned int)(v12 - 48);
v10 = 1;
++v9;
}
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) <= 9u )
{
++v10;
++v9;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
LABEL_7:
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) <= 9u )
{
++v9;
++v10;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
if ( v9 != (char *)v5 )
goto LABEL_9;
goto LABEL_14;
}
goto LABEL_26;
}
}
else
{
LABEL_9:
while ( 1 )
{
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) > 9u )
break;
v13 = v9 + 1;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v12 = (unsigned int)v9[1];
v14 = v10 + 1;
++v9;
++v10;
if ( (unsigned __int8)(v12 - 48) > 9u )
break;
++v9;
++v10;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) > 9u )
break;
v9 = v13 + 2;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v12 = (unsigned int)v13[2];
v10 = v14 + 2;
if ( (unsigned __int8)(v13[2] - 48) > 9u )
break;
v10 = v14 + 3;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v9 = v13 + 3;
if ( v13 + 3 == (char *)v5 )
goto LABEL_14;
}
}
LABEL_26:
if ( (unsigned __int8)v12 <= 0x3Bu )
{
v16 = 0x800000100002600LL;
if ( _bittest64(&v16, v12) )
{
if ( v10 <= 10 && v10 )
{
for ( *v8 = v7; (unsigned __int64)v9 < v5; ++v9 )
{
if ( *v9 == 10 )
{
v17 = v9 + 1;
if ( v5 <= (unsigned __int64)(v9 + 1) )
goto LABEL_40;
v18 = v9[1];
if ( v18 == 13 )
{
v17 = v9 + 2;
if ( (unsigned __int64)(v9 + 2) >= v5 )
goto LABEL_40;
v18 = v9[2];
}
if ( v18 != 32 && v18 != 9 )
{
LABEL_40:
*a4 = 0;
return v17;
}
v9 = v17;
}
}
v5 = (unsigned __int64)v9;
LABEL_14:
v9 = (char *)v5;
if ( (int)get_debug_level("core", 4LL, v7) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v25 = (const char *)*((_QWORD *)&log_level_info + 8);
v26 = my_pid();
v27 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: strange EoHF\n",
process_no,
v26,
v25,
"<core> [parser/parse_retry_after.c:88]: ",
"parse_retry_after");
if ( log_color )
dprint_color_reset(
v27,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: strange EoHF\n",
v7,
v28,
v29,
v30,
v31);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_retry_after: strange EoHF\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_retry_after.c:88]: ",
"parse_retry_after");
}
v9 = (char *)v5;
--dprint_crit;
}
goto LABEL_19;
}
}
}
LABEL_19:
if ( (int)get_debug_level("core", 4LL, v7) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v19 = (const char *)*((_QWORD *)&log_level_info + 8);
v20 = my_pid();
v21 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: bad Retry-After header \n",
process_no,
v20,
v19,
"<core> [parser/parse_retry_after.c:91]: ",
"parse_retry_after");
if ( log_color )
dprint_color_reset(
v21,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: bad Retry-After header \n",
v30,
v22,
v23,
v24,
v31);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_retry_after: bad Retry-After header \n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_retry_after.c:91]: ",
"parse_retry_after");
}
--dprint_crit;
}
*a4 = 1;
return v9;
}

canonical_decompiled_code:
char *__fastcall func1(char *a1, unsigned __int64 a2, __int64 a3, _DWORD *a4)
{
unsigned __int64 v5; // rbx
char *v6; // rax
__int64 v7; // rdx
_DWORD *v8; // r10
char *v9; // r12
int v10; // esi
__int64 v11; // rax
unsigned __int64 v12; // rax
char *v13; // rdi
int v14; // er8
__int64 v16; // r8
char *v17; // r10
char v18; // di
const char *v19; // rbx
unsigned int v20; // eax
struct _IO_FILE *v21; // rdi
__int64 v22; // rcx
const char *v23; // r8
const char *v24; // r9
const char *v25; // r12
unsigned int v26; // eax
struct _IO_FILE *v27; // rdi
__int64 v28; // rcx
const char *v29; // [rsp-10h] [rbp-28h]
const char *v30; // [rsp-8h] [rbp-20h]
const char *v31; // [rsp+0h] [rbp-18h]

v5 = a2;
v6 = func0(a1, a2);
v9 = v6;
if ( (unsigned __int64)v6 >= a2 )
goto LABEL_19;
v7 = 0LL;
v10 = 0;
v11 = ((_BYTE)v5 - (_BYTE)v6) & 3;
if ( (((_BYTE)v5 - (_BYTE)v9) & 3) != 0 )
{
if ( v11 == 1 )
goto LABEL_7;
if ( v11 != 2 )
{
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) > 9u )
goto LABEL_26;
v7 = (unsigned int)(v12 - 48);
v10 = 1;
++v9;
}
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) <= 9u )
{
++v10;
++v9;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
LABEL_7:
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) <= 9u )
{
++v9;
++v10;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
if ( v9 != (char *)v5 )
goto LABEL_9;
goto LABEL_14;
}
goto LABEL_26;
}
}
else
{
LABEL_9:
while ( 1 )
{
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) > 9u )
break;
v13 = v9 + 1;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v12 = (unsigned int)v9[1];
v14 = v10 + 1;
++v9;
++v10;
if ( (unsigned __int8)(v12 - 48) > 9u )
break;
++v9;
++v10;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v12 = (unsigned int)*v9;
if ( (unsigned __int8)(*v9 - 48) > 9u )
break;
v9 = v13 + 2;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v12 = (unsigned int)v13[2];
v10 = v14 + 2;
if ( (unsigned __int8)(v13[2] - 48) > 9u )
break;
v10 = v14 + 3;
v7 = (unsigned int)(v12 + 10 * v7 - 48);
v9 = v13 + 3;
if ( v13 + 3 == (char *)v5 )
goto LABEL_14;
}
}
LABEL_26:
if ( (unsigned __int8)v12 <= 0x3Bu )
{
v16 = 0x800000100002600LL;
if ( _bittest64(&v16, v12) )
{
if ( v10 <= 10 && v10 )
{
for ( *v8 = v7; (unsigned __int64)v9 < v5; ++v9 )
{
if ( *v9 == 10 )
{
v17 = v9 + 1;
if ( v5 <= (unsigned __int64)(v9 + 1) )
goto LABEL_40;
v18 = v9[1];
if ( v18 == 13 )
{
v17 = v9 + 2;
if ( (unsigned __int64)(v9 + 2) >= v5 )
goto LABEL_40;
v18 = v9[2];
}
if ( v18 != 32 && v18 != 9 )
{
LABEL_40:
*a4 = 0;
return v17;
}
v9 = v17;
}
}
v5 = (unsigned __int64)v9;
LABEL_14:
v9 = (char *)v5;
if ( (int)get_debug_level("core", 4LL, v7) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v25 = (const char *)*((_QWORD *)&log_level_info + 8);
v26 = my_pid();
v27 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: strange EoHF\n",
process_no,
v26,
v25,
"<core> [parser/parse_retry_after.c:88]: ",
"parse_retry_after");
if ( log_color )
dprint_color_reset(
v27,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: strange EoHF\n",
v7,
v28,
v29,
v30,
v31);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_retry_after: strange EoHF\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_retry_after.c:88]: ",
"parse_retry_after");
}
v9 = (char *)v5;
--dprint_crit;
}
goto LABEL_19;
}
}
}
LABEL_19:
if ( (int)get_debug_level("core", 4LL, v7) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v19 = (const char *)*((_QWORD *)&log_level_info + 8);
v20 = my_pid();
v21 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: bad Retry-After header \n",
process_no,
v20,
v19,
"<core> [parser/parse_retry_after.c:91]: ",
"parse_retry_after");
if ( log_color )
dprint_color_reset(
v21,
"%2d(%d) %s: %s%s(): ERROR: parse_retry_after: bad Retry-After header \n",
v30,
v22,
v23,
v24,
v31);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR: parse_retry_after: bad Retry-After header \n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_retry_after.c:91]: ",
"parse_retry_after");
}
--dprint_crit;
}
*a4 = 1;
return v9;
}

original_code:
char* parse_retry_after(char* const buf, const char* const end, unsigned* const after, int* const err)
{
 char *t;
 int i;
 unsigned val;
 val=0;
 t=buf;
 t=eat_lws_end(t, end);
 if (t>=end) goto error;
 for (i=0; t<end; i++,t++){
  if ((*t >= '0') && (*t <= '9')){
   val=val*10+(*t-'0');
  }else{
   switch(*t){
    case ' ':
    case '\t':
    case ';':
    case '\r':
    case '\n':
     goto found;
    default:
     goto error;
   }
  }
 }
 goto error_nocrlf;
found:
 if (i>10 || i==0)
  goto error;
 *after=val;
 for (; t<end; t++){
  if (*t=='\n'){
   if (((t+1)<end) && (*(t+1)=='\r'))
    t++;
   if (((t+1)<end) && (*(t+1)==' ' || *(t+1)=='\t')){
    t++;
    continue;
   }
   *err=0;
   return t+1;
  }
 }
error_nocrlf:
 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_retry_after: strange EoHF\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __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_retry_after: strange EoHF\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_retry_after: strange EoHF\n", process_no, my_pid(), ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __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_retry_after: strange EoHF\n", ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __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_retry_after: strange EoHF\n", ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 goto error;
error:
 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_retry_after: bad Retry-After header \n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.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(): " "ERROR: parse_retry_after: bad Retry-After header \n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.c" ":" "91" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_retry_after: bad Retry-After header \n", process_no, my_pid(), ("<core> [" "parser/parse_retry_after.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(): " "ERROR: parse_retry_after: bad Retry-After header \n", ("<core> [" "parser/parse_retry_after.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(): " "ERROR: parse_retry_after: bad Retry-After header \n", ("<core> [" "parser/parse_retry_after.c" ":" "91" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 *err=1;
 return t;
}

canonical_original_code:
char *parse_retry_after(char *buf, char *end, unsigned int *after, int *err)
{
 char *t;
 int i;
 unsigned int val;
 val=0;
 t=buf;
 t=eat_lws_end(t, end);
 if (t>=end) goto error;
 for (i=0; t<end; i++,t++){
  if ((*t >= '0') && (*t <= '9')){
   val=val*10+(*t-'0');
  }else{
   switch(*t){
    case ' ':
    case '\t':
    case ';':
    case '\r':
    case '\n':
     goto found;
    default:
     goto error;
   }
  }
 }
 goto error_nocrlf;
found:
 if (i>10 || i==0)
  goto error;
 *after=val;
 for (; t<end; t++){
  if (*t=='\n'){
   if (((t+1)<end) && (*(t+1)=='\r'))
    t++;
   if (((t+1)<end) && (*(t+1)==' ' || *(t+1)=='\t')){
    t++;
    continue;
   }
   *err=0;
   return t+1;
  }
 }
error_nocrlf:
 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_retry_after: strange EoHF\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __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_retry_after: strange EoHF\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_retry_after: strange EoHF\n", process_no, my_pid(), ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __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_retry_after: strange EoHF\n", ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __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_retry_after: strange EoHF\n", ("<core> [" "parser/parse_retry_after.c" ":" "88" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 goto error;
error:
 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_retry_after: bad Retry-After header \n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.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(): " "ERROR: parse_retry_after: bad Retry-After header \n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_retry_after.c" ":" "91" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR: parse_retry_after: bad Retry-After header \n", process_no, my_pid(), ("<core> [" "parser/parse_retry_after.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(): " "ERROR: parse_retry_after: bad Retry-After header \n", ("<core> [" "parser/parse_retry_after.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(): " "ERROR: parse_retry_after: bad Retry-After header \n", ("<core> [" "parser/parse_retry_after.c" ":" "91" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 *err=1;
 return t;
}

variable_types:
buf
char *

variable_types:
end
char *

variable_types:
after
unsigned int *

variable_types:
err
int *

variable_types:
t
char *

variable_types:
val
unsigned int

return_type: char *

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


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 get_first_socket()
{
__int64 result; // rax

result = udp_listen;
if ( !udp_listen )
{
result = tcp_listen;
if ( !tcp_listen )
result = tls_listen;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

result = udp_listen;
if ( !udp_listen )
{
result = tcp_listen;
if ( !tcp_listen )
result = tls_listen;
}
return result;
}

original_code:
inline static struct socket_info* get_first_socket(void)
{
 if (udp_listen) return udp_listen;
 else if (tcp_listen) return tcp_listen;
 else if (tls_listen) return tls_listen;
 return 0;
}

canonical_original_code:
inline static struct socket_info *get_first_socket()
{
 if (udp_listen) return udp_listen;
 else if (tcp_listen) return tcp_listen;
 else if (tls_listen) return tls_listen;
 return 0;
}

return_type: struct socket_info { int socket; struct _str { char *s; int len; } name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *

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

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

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

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

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


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

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

original_code:
static int dlg_mod_child_init(int _rank)
{
 return 0;
}


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 func3(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:
// attributes: thunk
__int64 init_dialog_tags()
{
return init_tags_constprop_0();
}

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

original_code:
static void init_dialog_tags()
{
 init_tags(dialog_tags, &dialog_tag_suffix, "SER-DIALOG/tags", '-');
}


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

result = func6(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 = func6(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func6(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func6(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func6(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func6(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func6(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func6(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func6(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 destroy_dialog_mutex()
{
__int64 result; // rax

if ( dlg_mutex )
{
futex_get(mem_lock);
qm_free(shm_block, dlg_mutex);
result = futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax

if ( dlg_mutex )
{
func7(mem_lock);
qm_free(shm_block, dlg_mutex);
result = func3(mem_lock);
}
return result;
}

original_code:
static void destroy_dialog_mutex()
{
 if (dlg_mutex) {
  ;
  do { futex_get(mem_lock); qm_free(shm_block, ((void*)dlg_mutex)); futex_release(mem_lock); }while(0);
 }
}

canonical_original_code:
static void destroy_dialog_mutex()
{
 if (dlg_mutex) {
  ;
  do { futex_get(mem_lock); qm_free(shm_block, ((void *)dlg_mutex)); futex_release(mem_lock); }while(0);
 }
}


decompiled_code:
__int64 dlg_mod_destroy()
{
return destroy_dialog_mutex();
}

canonical_decompiled_code:
__int64 func9()
{
return func8();
}

original_code:
static void dlg_mod_destroy(void)
{
 destroy_dialog_mutex();
}

canonical_original_code:
static void dlg_mod_destroy()
{
 destroy_dialog_mutex();
}


decompiled_code:
__int64 init_dialog_mutex()
{
_DWORD *v0; // rdi

v0 = (_DWORD *)shm_malloc_constprop_0();
dlg_mutex = v0;
if ( !v0 )
return 0xFFFFFFFFLL;
futex_init_isra_0(v0);
return 0LL;
}

canonical_decompiled_code:
__int64 func12()
{
_DWORD *v0; // rdi

v0 = (_DWORD *)func10();
dlg_mutex = v0;
if ( !v0 )
return 0xFFFFFFFFLL;
func11(v0);
return 0LL;
}

original_code:
static int init_dialog_mutex()
{
 dlg_mutex = (gen_lock_t*)shm_malloc(sizeof(*dlg_mutex));
 if (!dlg_mutex) return -1;
 futex_init(dlg_mutex);
 return 0;
}

canonical_original_code:
static int init_dialog_mutex()
{
 dlg_mutex = (struct atomic_t *)shm_malloc(sizeof(*dlg_mutex));
 if (!dlg_mutex) return -1;
 futex_init(dlg_mutex);
 return 0;
}


original_code:
int m_apo_escape(char* src, int slen, char* dst, int dlen)
{
 int i, j;
 if(!src || !dst || dlen <= 0)
  return -1;
 if(slen == -1)
  slen = strlen(src);
 for(i=j=0; i<slen; i++)
 {
  switch(src[i])
  {
   case '\'':
     if(j+2>=dlen)
      return -2;
     memcpy(&dst[j], "\\'", 2);
     j += 2;
    break;
   default:
    if(j+1>=dlen)
      return -2;
    dst[j] = src[i];
    j++;
  }
 }
 dst[j] = '\0';
 return j;
}

canonical_original_code:
int m_apo_escape(char *src, int slen, char *dst, int dlen)
{
 int i; int j;
 if(!src || !dst || dlen <= 0)
  return -1;
 if(slen == -1)
  slen = strlen(src);
 for(i=j=0; i<slen; i++)
 {
  switch(src[i])
  {
   case '\'':
     if(j+2>=dlen)
      return -2;
     memcpy(&dst[j], "\\'", 2);
     j += 2;
    break;
   default:
    if(j+1>=dlen)
      return -2;
    dst[j] = src[i];
    j++;
  }
 }
 dst[j] = '\0';
 return j;
}

variable_types:
src
char *

variable_types: slen int

variable_types:
dst
char *

variable_types: dlen int

variable_types: j int