repo: virtadpt/eBBS

decompiled_code:
__int64 yy_get_previous_state()
{
unsigned __int8 *v0; // r8
__int64 result; // rax
int v2; // er11
__int64 v3; // r10
char v4; // r9
__int64 v5; // rdx
int v6; // er12
int v7; // edx
__int64 v8; // rcx
__int64 v9; // rsi
int v10; // edi
int v11; // eax
__int16 v12; // dx

v0 = (unsigned __int8 *)yytext;
result = (unsigned int)yy_start;
if ( (unsigned __int64)yytext < yy_c_buf_p )
{
v2 = yy_last_accepting_state;
v3 = yy_last_accepting_cpos;
v4 = 0;
do
{
v5 = *v0;
if ( (_BYTE)v5 )
{
v6 = yy_ec[v5];
v7 = (unsigned __int8)v6;
LODWORD(v8) = (unsigned __int8)v6;
}
else
{
LODWORD(v8) = 1;
v7 = 1;
LOBYTE(v6) = 1;
}
v9 = (int)result;
v10 = yy_base[(int)result];
if ( yy_accept[(int)result] )
v3 = (__int64)v0;
if ( yy_accept[(int)result] )
{
v2 = result;
if ( yy_accept[(int)result] )
v4 = 1;
}
if ( yy_chk[v10 + v7] != (_DWORD)result )
{
v8 = (unsigned __int8)v6;
do
{
v11 = yy_def[v9];
v12 = yy_def[v9];
if ( v12 > 80 )
LODWORD(v8) = (unsigned __int8)yy_meta[4 * v8];
v9 = yy_def[v9];
v10 = yy_base[v11];
}
while ( v12 != yy_chk[v10 + (int)v8] );
}
++v0;
result = (unsigned int)yy_nxt[(unsigned int)(v10 + v8)];
}
while ( v0 != (unsigned __int8 *)yy_c_buf_p );
if ( v4 )
{
yy_last_accepting_state = v2;
yy_last_accepting_cpos = v3;
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned __int8 *v0; // r8
__int64 result; // rax
int v2; // er11
__int64 v3; // r10
char v4; // r9
__int64 v5; // rdx
int v6; // er12
int v7; // edx
__int64 v8; // rcx
__int64 v9; // rsi
int v10; // edi
int v11; // eax
__int16 v12; // dx

v0 = (unsigned __int8 *)yytext;
result = (unsigned int)yy_start;
if ( (unsigned __int64)yytext < yy_c_buf_p )
{
v2 = yy_last_accepting_state;
v3 = yy_last_accepting_cpos;
v4 = 0;
do
{
v5 = *v0;
if ( (_BYTE)v5 )
{
v6 = yy_ec[v5];
v7 = (unsigned __int8)v6;
LODWORD(v8) = (unsigned __int8)v6;
}
else
{
LODWORD(v8) = 1;
v7 = 1;
LOBYTE(v6) = 1;
}
v9 = (int)result;
v10 = yy_base[(int)result];
if ( yy_accept[(int)result] )
v3 = (__int64)v0;
if ( yy_accept[(int)result] )
{
v2 = result;
if ( yy_accept[(int)result] )
v4 = 1;
}
if ( yy_chk[v10 + v7] != (_DWORD)result )
{
v8 = (unsigned __int8)v6;
do
{
v11 = yy_def[v9];
v12 = yy_def[v9];
if ( v12 > 80 )
LODWORD(v8) = (unsigned __int8)yy_meta[4 * v8];
v9 = yy_def[v9];
v10 = yy_base[v11];
}
while ( v12 != yy_chk[v10 + (int)v8] );
}
++v0;
result = (unsigned int)yy_nxt[(unsigned int)(v10 + v8)];
}
while ( v0 != (unsigned __int8 *)yy_c_buf_p );
if ( v4 )
{
yy_last_accepting_state = v2;
yy_last_accepting_cpos = v3;
}
}
return result;
}

original_code:
static yy_state_type yy_get_previous_state()
 {
 register yy_state_type yy_current_state;
 register char *yy_cp;
 yy_current_state = yy_start;
 for ( yy_cp = yytext + 0; yy_cp < yy_c_buf_p; ++yy_cp )
  {
  register YY_CHAR yy_c = (*yy_cp ? yy_ec[((unsigned int) (unsigned char) *yy_cp)] : 1);
  if ( yy_accept[yy_current_state] )
   {
   yy_last_accepting_state = yy_current_state;
   yy_last_accepting_cpos = yy_cp;
   }
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
   {
   yy_current_state = (int) yy_def[yy_current_state];
   if ( yy_current_state >= 81 )
    yy_c = yy_meta[(unsigned int) yy_c];
   }
  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  }
 return yy_current_state;
 }

canonical_original_code:
static int yy_get_previous_state()
 {
 register int yy_current_state;
 register char *yy_cp;
 yy_current_state = yy_start;
 for ( yy_cp = yytext + 0; yy_cp < yy_c_buf_p; ++yy_cp )
  {
  register unsigned char yy_c = (*yy_cp ? yy_ec[((unsigned int) (unsigned char) *yy_cp)] : 1);
  if ( yy_accept[yy_current_state] )
   {
   yy_last_accepting_state = yy_current_state;
   yy_last_accepting_cpos = yy_cp;
   }
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
   {
   yy_current_state = (int) yy_def[yy_current_state];
   if ( yy_current_state >= 81 )
    yy_c = yy_meta[(unsigned int) yy_c];
   }
  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  }
 return yy_current_state;
 }


decompiled_code:
__int64 __fastcall yy_try_NUL_trans(int a1)
{
__int64 v1; // rdx
int v2; // esi
__int64 result; // rax

v1 = a1;
if ( yy_accept[a1] )
{
yy_last_accepting_state = a1;
yy_last_accepting_cpos = yy_c_buf_p;
}
v2 = yy_base[a1];
if ( a1 != yy_chk[v2 + 1] )
{
do
{
v1 = yy_def[v1];
v2 = yy_base[v1];
}
while ( (_WORD)v1 != yy_chk[v2 + 1] );
}
result = (unsigned int)yy_nxt[v2 + 1];
if ( (_DWORD)result == 80 )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 v1; // rdx
int v2; // esi
__int64 result; // rax

v1 = a1;
if ( yy_accept[a1] )
{
yy_last_accepting_state = a1;
yy_last_accepting_cpos = yy_c_buf_p;
}
v2 = yy_base[a1];
if ( a1 != yy_chk[v2 + 1] )
{
do
{
v1 = yy_def[v1];
v2 = yy_base[v1];
}
while ( (_WORD)v1 != yy_chk[v2 + 1] );
}
result = (unsigned int)yy_nxt[v2 + 1];
if ( (_DWORD)result == 80 )
result = 0LL;
return result;
}

original_code:
static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
 {
 register int yy_is_jam;
 register char *yy_cp = yy_c_buf_p;
 register YY_CHAR yy_c = 1;
 if ( yy_accept[yy_current_state] )
  {
  yy_last_accepting_state = yy_current_state;
  yy_last_accepting_cpos = yy_cp;
  }
 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  {
  yy_current_state = (int) yy_def[yy_current_state];
  if ( yy_current_state >= 81 )
   yy_c = yy_meta[(unsigned int) yy_c];
  }
 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 yy_is_jam = (yy_current_state == 80);
 return yy_is_jam ? 0 : yy_current_state;
 }

canonical_original_code:
static int yy_try_NUL_trans(int yy_current_state)
 {
 register int yy_is_jam;
 register char *yy_cp = yy_c_buf_p;
 register unsigned char yy_c = 1;
 if ( yy_accept[yy_current_state] )
  {
  yy_last_accepting_state = yy_current_state;
  yy_last_accepting_cpos = yy_cp;
  }
 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  {
  yy_current_state = (int) yy_def[yy_current_state];
  if ( yy_current_state >= 81 )
   yy_c = yy_meta[(unsigned int) yy_c];
  }
 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 yy_is_jam = (yy_current_state == 80);
 return yy_is_jam ? 0 : yy_current_state;
 }

return_type: int


decompiled_code:
void *__fastcall yy_flex_realloc(void *a1, unsigned int a2)
{
return realloc(a1, a2);
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, unsigned int a2)
{
return realloc(a1, a2);
}

original_code:
static void *yy_flex_realloc( void *ptr, unsigned int size )
 {
 return (void *) realloc( ptr, size );
 }

canonical_original_code:
static void *yy_flex_realloc(void *ptr, unsigned int size)
 {
 return (void *) realloc( ptr, size );
 }

variable_types:
ptr
void *

variable_types:
size
unsigned int

return_type: void *


decompiled_code:
void __fastcall __noreturn yy_fatal_error(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

original_code:
static void yy_fatal_error( const char msg[] )
 {
 (void) fprintf( stderr, "%s\n", msg );
 exit( 1 );
 }

canonical_original_code:
static void yy_fatal_error(char msg[])
 {
 (void) fprintf( stderr, "%s\n", msg );
 exit( 1 );
 }

variable_types:
msg
char []

return_type: void


decompiled_code:
void *__fastcall yy_flex_alloc(size_t size)
{
return malloc((unsigned int)size);
}

canonical_decompiled_code:
void *__fastcall func4(size_t size)
{
return malloc((unsigned int)size);
}

original_code:
static void *yy_flex_alloc( unsigned int size )
 {
 return (void *) malloc( size );
 }

canonical_original_code:
static void *yy_flex_alloc(unsigned int size)
 {
 return (void *) malloc( size );
 }


decompiled_code:
// attributes: thunk
void yy_flex_free(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func5(void *ptr)
{
free(ptr);
}

original_code:
static void yy_flex_free( void *ptr )
 {
 free( ptr );
 }

canonical_original_code:
static void yy_flex_free(void *ptr)
 {
 free( ptr );
 }


decompiled_code:
void *get_yytext()
{
return yytext;
}

canonical_decompiled_code:
void *func6()
{
return yytext;
}

original_code: char *get_yytext() { return yytext ; }

canonical_original_code: char *get_yytext() { return yytext ; }

return_type: char *


decompiled_code:
__int64 yy_load_buffer_state()
{
FILE *v0; // rdx
__int64 result; // rax

yy_n_chars = *(_DWORD *)(yy_current_buffer + 28);
v0 = *(FILE **)yy_current_buffer;
yy_c_buf_p = *(_QWORD *)(yy_current_buffer + 16);
yytext = (void *)yy_c_buf_p;
yyin = v0;
result = *(unsigned __int8 *)yy_c_buf_p;
yy_hold_char = *(_BYTE *)yy_c_buf_p;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
FILE *v0; // rdx
__int64 result; // rax

yy_n_chars = *(_DWORD *)(yy_current_buffer + 28);
v0 = *(FILE **)yy_current_buffer;
yy_c_buf_p = *(_QWORD *)(yy_current_buffer + 16);
yytext = (void *)yy_c_buf_p;
yyin = v0;
result = *(unsigned __int8 *)yy_c_buf_p;
yy_hold_char = *(_BYTE *)yy_c_buf_p;
return result;
}

original_code:
void yy_load_buffer_state( void )
 {
 yy_n_chars = yy_current_buffer->yy_n_chars;
 yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
 yyin = yy_current_buffer->yy_input_file;
 yy_hold_char = *yy_c_buf_p;
 }

canonical_original_code:
void yy_load_buffer_state()
 {
 yy_n_chars = yy_current_buffer->yy_n_chars;
 yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
 yyin = yy_current_buffer->yy_input_file;
 yy_hold_char = *yy_c_buf_p;
 }


yylex

decompiled_code:
__int64 yylex()
{
FILE *v0; // r8
__int64 v1; // rdi
_BYTE *v2; // rbp
__int64 v3; // rax
int v4; // er11
void *v5; // r12
__int64 v6; // rsi
__int64 v7; // r9
__int64 v8; // r10
__int64 v9; // r8
__int64 v10; // rdi
int v11; // eax
__int64 v12; // rcx
int v13; // er11
__int16 v14; // dx
__int64 v15; // rax
int v16; // eax
char v17; // dl
int v19; // er11
__int64 v20; // rdx
int v21; // er13
__int64 v22; // rax
int v23; // eax
__int64 v24; // rdx
__int64 v25; // rcx
__int64 v26; // r8
__int64 v27; // r9
int v28; // eax
int v29; // edx
int v30; // eax
char *v31; // r13
unsigned int v32; // eax
int v33; // eax

if ( !yy_init )
goto LABEL_8;
if ( yy_start )
{
v0 = yyin;
if ( yyin )
goto LABEL_4;
}
else
{
v0 = yyin;
yy_start = 1;
if ( yyin )
{
LABEL_4:
if ( yyout )
goto LABEL_5;
LABEL_27:
v1 = yy_current_buffer;
yyout = stdout;
if ( yy_current_buffer )
goto LABEL_6;
LABEL_28:
yy_current_buffer = yy_create_buffer(v0, 0x4000);
goto LABEL_7;
}
}
v0 = stdin;
yyin = stdin;
if ( !yyout )
goto LABEL_27;
LABEL_5:
v1 = yy_current_buffer;
if ( !yy_current_buffer )
goto LABEL_28;
LABEL_6:
yy_init_buffer(v1, v0);
LABEL_7:
yy_load_buffer_state();
yy_init = 0;
while ( 1 )
{
LABEL_8:
v2 = (_BYTE *)yy_c_buf_p;
v3 = (unsigned __int8)yy_hold_char;
v4 = yy_start;
*(_BYTE *)yy_c_buf_p = yy_hold_char;
v5 = v2;
LABEL_9:
v6 = v4;
v7 = (unsigned int)yy_last_accepting_state;
v8 = yy_last_accepting_cpos;
v9 = 0LL;
LODWORD(v10) = yy_base[v4];
while ( 1 )
{
v11 = yy_ec[v3];
if ( yy_accept[v6] )
v7 = (unsigned int)v4;
if ( yy_accept[v6] )
{
v8 = (__int64)v2;
if ( yy_accept[v6] )
v9 = 1LL;
}
v12 = (unsigned __int8)v11;
if ( v4 != yy_chk[(int)(v10 + (unsigned __int8)v11)] )
{
do
{
v13 = yy_def[v6];
v14 = yy_def[v6];
if ( v14 > 80 )
v12 = (unsigned __int8)yy_meta[4 * (unsigned int)v12];
v6 = yy_def[v6];
LODWORD(v10) = yy_base[v13];
}
while ( v14 != yy_chk[(int)v10 + (int)v12] );
}
v15 = (unsigned int)(v10 + v12);
++v2;
v6 = yy_nxt[v15];
v10 = (unsigned int)yy_base[v6];
v4 = yy_nxt[v15];
if ( yy_base[v6] == 120 )
break;
v3 = (unsigned __int8)*v2;
}
if ( (_BYTE)v9 )
{
yy_last_accepting_cpos = v8;
yy_last_accepting_state = v7;
}
LABEL_23:
yytext = v5;
v16 = yy_accept[v6];
yy_c_buf_p = (__int64)v2;
yyleng = (_DWORD)v2 - (_DWORD)v5;
v17 = *v2;
*v2 = 0;
yy_hold_char = v17;
LABEL_24:
switch ( v16 )
{
case 0:
v19 = yy_last_accepting_state;
*v2 = yy_hold_char;
v2 = (_BYTE *)yy_last_accepting_cpos;
goto LABEL_38;
case 1:
case 2:
return 258LL;
case 3:
case 4:
return 259LL;
case 5:
case 6:
return 260LL;
case 7:
return 265LL;
case 8:
return 263LL;
case 9:
return 264LL;
case 10:
return 266LL;
case 11:
return 267LL;
case 12:
return 261LL;
case 13:
case 14:
return 270LL;
case 15:
return 262LL;
case 16:
return 271LL;
case 17:
return 268LL;
case 18:
return 269LL;
case 19:
case 21:
case 22:
continue;
case 20:
++line_num;
continue;
case 23:
return 272LL;
case 24:
fwrite(yytext, yyleng, 1uLL, yyout);
continue;
case 25:
v20 = yy_current_buffer;
v21 = (_DWORD)v2 - (_DWORD)yytext - 1;
*v2 = yy_hold_char;
if ( *(FILE **)v20 == yyin )
{
v22 = yy_n_chars;
}
else
{
*(_QWORD *)v20 = yyin;
v22 = *(int *)(v20 + 28);
yy_n_chars = *(_DWORD *)(v20 + 28);
}
if ( yy_c_buf_p <= (unsigned __int64)(*(_QWORD *)(v20 + 8) + v22) )
{
v31 = (char *)yytext + v21;
yy_c_buf_p = (__int64)v31;
v32 = yy_get_previous_state(v10, v6, v20, v12, v9, v7);
v10 = v32;
v33 = yy_try_NUL_trans(v32);
v5 = yytext;
v29 = v33;
if ( !v33 )
goto LABEL_38;
v2 = v31 + 1;
yy_c_buf_p = (__int64)(v31 + 1);
LABEL_54:
v3 = (unsigned __int8)*v2;
v4 = v29;
goto LABEL_9;
}
v23 = yy_get_next_buffer(v10, v6, v20, v12, v9, v7);
switch ( v23 )
{
case 1:
yy_did_buffer_switch_on_eof = 0;
if ( (unsigned int)yywrap() )
{
yy_c_buf_p = (__int64)yytext;
v16 = (yy_start - 1) / 2 + 26;
goto LABEL_24;
}
if ( !yy_did_buffer_switch_on_eof )
yyrestart(yyin);
break;
case 2:
v2 = (_BYTE *)(*(_QWORD *)(yy_current_buffer + 8) + yy_n_chars);
yy_c_buf_p = (__int64)v2;
v30 = yy_get_previous_state(v10, v6, v24, v25, v26, v27);
v5 = yytext;
v19 = v30;
LABEL_38:
v6 = v19;
goto LABEL_23;
case 0:
v2 = (char *)yytext + v21;
yy_c_buf_p = (__int64)v2;
v28 = yy_get_previous_state(v10, v6, v24, v25, v26, v27);
v5 = yytext;
v29 = v28;
goto LABEL_54;
}
break;
case 26:
return 0LL;
default:
yy_fatal_error("fatal flex scanner internal error--no action found");
}
}
}

canonical_decompiled_code:
__int64 func14()
{
FILE *v0; // r8
__int64 v1; // rdi
_BYTE *v2; // rbp
__int64 v3; // rax
int v4; // er11
void *v5; // r12
__int64 v6; // rsi
__int64 v7; // r9
__int64 v8; // r10
__int64 v9; // r8
__int64 v10; // rdi
int v11; // eax
__int64 v12; // rcx
int v13; // er11
__int16 v14; // dx
__int64 v15; // rax
int v16; // eax
char v17; // dl
int v19; // er11
__int64 v20; // rdx
int v21; // er13
__int64 v22; // rax
int v23; // eax
__int64 v24; // rdx
__int64 v25; // rcx
__int64 v26; // r8
__int64 v27; // r9
int v28; // eax
int v29; // edx
int v30; // eax
char *v31; // r13
unsigned int v32; // eax
int v33; // eax

if ( !yy_init )
goto LABEL_8;
if ( yy_start )
{
v0 = yyin;
if ( yyin )
goto LABEL_4;
}
else
{
v0 = yyin;
yy_start = 1;
if ( yyin )
{
LABEL_4:
if ( yyout )
goto LABEL_5;
LABEL_27:
v1 = yy_current_buffer;
yyout = stdout;
if ( yy_current_buffer )
goto LABEL_6;
LABEL_28:
yy_current_buffer = func11(v0, 0x4000);
goto LABEL_7;
}
}
v0 = stdin;
yyin = stdin;
if ( !yyout )
goto LABEL_27;
LABEL_5:
v1 = yy_current_buffer;
if ( !yy_current_buffer )
goto LABEL_28;
LABEL_6:
func10(v1, v0);
LABEL_7:
func7();
yy_init = 0;
while ( 1 )
{
LABEL_8:
v2 = (_BYTE *)yy_c_buf_p;
v3 = (unsigned __int8)yy_hold_char;
v4 = yy_start;
*(_BYTE *)yy_c_buf_p = yy_hold_char;
v5 = v2;
LABEL_9:
v6 = v4;
v7 = (unsigned int)yy_last_accepting_state;
v8 = yy_last_accepting_cpos;
v9 = 0LL;
LODWORD(v10) = yy_base[v4];
while ( 1 )
{
v11 = yy_ec[v3];
if ( yy_accept[v6] )
v7 = (unsigned int)v4;
if ( yy_accept[v6] )
{
v8 = (__int64)v2;
if ( yy_accept[v6] )
v9 = 1LL;
}
v12 = (unsigned __int8)v11;
if ( v4 != yy_chk[(int)(v10 + (unsigned __int8)v11)] )
{
do
{
v13 = yy_def[v6];
v14 = yy_def[v6];
if ( v14 > 80 )
v12 = (unsigned __int8)yy_meta[4 * (unsigned int)v12];
v6 = yy_def[v6];
LODWORD(v10) = yy_base[v13];
}
while ( v14 != yy_chk[(int)v10 + (int)v12] );
}
v15 = (unsigned int)(v10 + v12);
++v2;
v6 = yy_nxt[v15];
v10 = (unsigned int)yy_base[v6];
v4 = yy_nxt[v15];
if ( yy_base[v6] == 120 )
break;
v3 = (unsigned __int8)*v2;
}
if ( (_BYTE)v9 )
{
yy_last_accepting_cpos = v8;
yy_last_accepting_state = v7;
}
LABEL_23:
yytext = v5;
v16 = yy_accept[v6];
yy_c_buf_p = (__int64)v2;
yyleng = (_DWORD)v2 - (_DWORD)v5;
v17 = *v2;
*v2 = 0;
yy_hold_char = v17;
LABEL_24:
switch ( v16 )
{
case 0:
v19 = yy_last_accepting_state;
*v2 = yy_hold_char;
v2 = (_BYTE *)yy_last_accepting_cpos;
goto LABEL_38;
case 1:
case 2:
return 258LL;
case 3:
case 4:
return 259LL;
case 5:
case 6:
return 260LL;
case 7:
return 265LL;
case 8:
return 263LL;
case 9:
return 264LL;
case 10:
return 266LL;
case 11:
return 267LL;
case 12:
return 261LL;
case 13:
case 14:
return 270LL;
case 15:
return 262LL;
case 16:
return 271LL;
case 17:
return 268LL;
case 18:
return 269LL;
case 19:
case 21:
case 22:
continue;
case 20:
++line_num;
continue;
case 23:
return 272LL;
case 24:
fwrite(yytext, yyleng, 1uLL, yyout);
continue;
case 25:
v20 = yy_current_buffer;
v21 = (_DWORD)v2 - (_DWORD)yytext - 1;
*v2 = yy_hold_char;
if ( *(FILE **)v20 == yyin )
{
v22 = yy_n_chars;
}
else
{
*(_QWORD *)v20 = yyin;
v22 = *(int *)(v20 + 28);
yy_n_chars = *(_DWORD *)(v20 + 28);
}
if ( yy_c_buf_p <= (unsigned __int64)(*(_QWORD *)(v20 + 8) + v22) )
{
v31 = (char *)yytext + v21;
yy_c_buf_p = (__int64)v31;
v32 = func0(v10, v6, v20, v12, v9, v7);
v10 = v32;
v33 = func1(v32);
v5 = yytext;
v29 = v33;
if ( !v33 )
goto LABEL_38;
v2 = v31 + 1;
yy_c_buf_p = (__int64)(v31 + 1);
LABEL_54:
v3 = (unsigned __int8)*v2;
v4 = v29;
goto LABEL_9;
}
v23 = func13(v10, v6, v20, v12, v9, v7);
switch ( v23 )
{
case 1:
yy_did_buffer_switch_on_eof = 0;
if ( (unsigned int)yywrap() )
{
yy_c_buf_p = (__int64)yytext;
v16 = (yy_start - 1) / 2 + 26;
goto LABEL_24;
}
if ( !yy_did_buffer_switch_on_eof )
func12(yyin);
break;
case 2:
v2 = (_BYTE *)(*(_QWORD *)(yy_current_buffer + 8) + yy_n_chars);
yy_c_buf_p = (__int64)v2;
v30 = func0(v10, v6, v24, v25, v26, v27);
v5 = yytext;
v19 = v30;
LABEL_38:
v6 = v19;
goto LABEL_23;
case 0:
v2 = (char *)yytext + v21;
yy_c_buf_p = (__int64)v2;
v28 = func0(v10, v6, v24, v25, v26, v27);
v5 = yytext;
v29 = v28;
goto LABEL_54;
}
break;
case 26:
return 0LL;
default:
func3("fatal flex scanner internal error--no action found");
}
}
}

original_code:
int yylex ( void )
 {
 register yy_state_type yy_current_state;
 register char *yy_cp, *yy_bp;
 register int yy_act;
 if ( yy_init )
  {
  if ( ! yy_start )
   yy_start = 1;
  if ( ! yyin )
   yyin = stdin;
  if ( ! yyout )
   yyout = stdout;
  if ( yy_current_buffer )
   yy_init_buffer( yy_current_buffer, yyin );
  else
   yy_current_buffer =
    yy_create_buffer( yyin, 16384 );
  yy_load_buffer_state();
  yy_init = 0;
  }
 while ( 1 )
  {
  yy_cp = yy_c_buf_p;
  *yy_cp = yy_hold_char;
  yy_bp = yy_cp;
  yy_current_state = yy_start;
yy_match:
  do
   {
   register YY_CHAR yy_c = yy_ec[((unsigned int) (unsigned char) *yy_cp)];
   if ( yy_accept[yy_current_state] )
    {
    yy_last_accepting_state = yy_current_state;
    yy_last_accepting_cpos = yy_cp;
    }
   while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
    {
    yy_current_state = (int) yy_def[yy_current_state];
    if ( yy_current_state >= 81 )
     yy_c = yy_meta[(unsigned int) yy_c];
    }
   yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
   ++yy_cp;
   }
  while ( yy_base[yy_current_state] != 120 );
yy_find_action:
  yy_act = yy_accept[yy_current_state];
  yytext = yy_bp; yyleng = yy_cp - yy_bp; yy_hold_char = *yy_cp; *yy_cp = '\0'; yy_c_buf_p = yy_cp;;
do_action:
  switch ( yy_act )
 {
   case 0:
   *yy_cp = yy_hold_char;
   yy_cp = yy_last_accepting_cpos;
   yy_current_state = yy_last_accepting_state;
   goto yy_find_action;
case 1:

case 2:

{return 258;}
 break;
case 3:

case 4:

{return 259;}
 break;
case 5:

case 6:

{return 260;}
 break;
case 7:

{return 265;}
 break;
case 8:

{return 263;}
 break;
case 9:

{return 264;}
 break;
case 10:

{return 266;}
 break;
case 11:

{return 267;}
 break;
case 12:

{return 261;}
 break;
case 13:

{return 270;}
 break;
case 14:

{return 270;}
 break;
case 15:

{return 262;}
 break;
case 16:

{return 271;}
 break;
case 17:

{return 268;}
 break;
case 18:

{return 269;}
 break;
case 19:

;
 break;
case 20:

{line_num++; }
 break;
case 21:

;
 break;
case 22:

;
 break;
case 23:

{return 272 ; }
 break;
case 24:

(void) fwrite( yytext, yyleng, 1, yyout );
 break;
case (25 + 0 + 1):
 return 0;
 case 25:
  {
  int yy_amount_of_matched_text = yy_cp - yytext - 1;
  *yy_cp = yy_hold_char;
  if ( yy_current_buffer->yy_input_file != yyin )
   {
   yy_current_buffer->yy_input_file = yyin;
   yy_n_chars = yy_current_buffer->yy_n_chars;
   }
  if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
   {
   yy_state_type yy_next_state;
   yy_c_buf_p = yytext + yy_amount_of_matched_text;
   yy_current_state = yy_get_previous_state();
   yy_next_state = yy_try_NUL_trans( yy_current_state );
   yy_bp = yytext + 0;
   if ( yy_next_state )
    {
    yy_cp = ++yy_c_buf_p;
    yy_current_state = yy_next_state;
    goto yy_match;
    }
   else
    {
    goto yy_find_action;
    }
   }
  else switch ( yy_get_next_buffer() )
   {
   case 1:
    {
    yy_did_buffer_switch_on_eof = 0;
    if ( yywrap() )
     {
     yy_c_buf_p = yytext + 0;
     yy_act = (25 + ((yy_start - 1) / 2) + 1);
     goto do_action;
     }
    else
     {
     if ( ! yy_did_buffer_switch_on_eof )
      yyrestart( yyin );
     }
    break;
    }
   case 0:
    yy_c_buf_p =
     yytext + yy_amount_of_matched_text;
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_match;
   case 2:
    yy_c_buf_p =
    &yy_current_buffer->yy_ch_buf[yy_n_chars];
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_find_action;
   }
  break;
  }
 default:
  yy_fatal_error( "fatal flex scanner internal error--no action found" );
 }
  }
 }

canonical_original_code:
int yylex()
 {
 register int yy_current_state;
 register char *yy_cp; register char *yy_bp;
 register int yy_act;
 if ( yy_init )
  {
  if ( ! yy_start )
   yy_start = 1;
  if ( ! yyin )
   yyin = stdin;
  if ( ! yyout )
   yyout = stdout;
  if ( yy_current_buffer )
   yy_init_buffer( yy_current_buffer, yyin );
  else
   yy_current_buffer =
    yy_create_buffer( yyin, 16384 );
  yy_load_buffer_state();
  yy_init = 0;
  }
 while ( 1 )
  {
  yy_cp = yy_c_buf_p;
  *yy_cp = yy_hold_char;
  yy_bp = yy_cp;
  yy_current_state = yy_start;
yy_match:
  do
   {
   register unsigned char yy_c = yy_ec[((unsigned int) (unsigned char) *yy_cp)];
   if ( yy_accept[yy_current_state] )
    {
    yy_last_accepting_state = yy_current_state;
    yy_last_accepting_cpos = yy_cp;
    }
   while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
    {
    yy_current_state = (int) yy_def[yy_current_state];
    if ( yy_current_state >= 81 )
     yy_c = yy_meta[(unsigned int) yy_c];
    }
   yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
   ++yy_cp;
   }
  while ( yy_base[yy_current_state] != 120 );
yy_find_action:
  yy_act = yy_accept[yy_current_state];
  yytext = yy_bp; yyleng = yy_cp - yy_bp; yy_hold_char = *yy_cp; *yy_cp = '\0'; yy_c_buf_p = yy_cp;;
do_action:
  switch ( yy_act )
 {
   case 0:
   *yy_cp = yy_hold_char;
   yy_cp = yy_last_accepting_cpos;
   yy_current_state = yy_last_accepting_state;
   goto yy_find_action;
case 1:

case 2:

{return 258;}
 break;
case 3:

case 4:

{return 259;}
 break;
case 5:

case 6:

{return 260;}
 break;
case 7:

{return 265;}
 break;
case 8:

{return 263;}
 break;
case 9:

{return 264;}
 break;
case 10:

{return 266;}
 break;
case 11:

{return 267;}
 break;
case 12:

{return 261;}
 break;
case 13:

{return 270;}
 break;
case 14:

{return 270;}
 break;
case 15:

{return 262;}
 break;
case 16:

{return 271;}
 break;
case 17:

{return 268;}
 break;
case 18:

{return 269;}
 break;
case 19:

;
 break;
case 20:

{line_num++; }
 break;
case 21:

;
 break;
case 22:

;
 break;
case 23:

{return 272 ; }
 break;
case 24:

(void) fwrite( yytext, yyleng, 1, yyout );
 break;
case (25 + 0 + 1):
 return 0;
 case 25:
  {
  int yy_amount_of_matched_text = yy_cp - yytext - 1;
  *yy_cp = yy_hold_char;
  if ( yy_current_buffer->yy_input_file != yyin )
   {
   yy_current_buffer->yy_input_file = yyin;
   yy_n_chars = yy_current_buffer->yy_n_chars;
   }
  if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
   {
   int yy_next_state;
   yy_c_buf_p = yytext + yy_amount_of_matched_text;
   yy_current_state = yy_get_previous_state();
   yy_next_state = yy_try_NUL_trans( yy_current_state );
   yy_bp = yytext + 0;
   if ( yy_next_state )
    {
    yy_cp = ++yy_c_buf_p;
    yy_current_state = yy_next_state;
    goto yy_match;
    }
   else
    {
    goto yy_find_action;
    }
   }
  else switch ( yy_get_next_buffer() )
   {
   case 1:
    {
    yy_did_buffer_switch_on_eof = 0;
    if ( yywrap() )
     {
     yy_c_buf_p = yytext + 0;
     yy_act = (25 + ((yy_start - 1) / 2) + 1);
     goto do_action;
     }
    else
     {
     if ( ! yy_did_buffer_switch_on_eof )
      yyrestart( yyin );
     }
    break;
    }
   case 0:
    yy_c_buf_p =
     yytext + yy_amount_of_matched_text;
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_match;
   case 2:
    yy_c_buf_p =
    &yy_current_buffer->yy_ch_buf[yy_n_chars];
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_find_action;
   }
  break;
  }
 default:
  yy_fatal_error( "fatal flex scanner internal error--no action found" );
 }
  }
 }


MenuGetch

decompiled_code:
__int64 MenuGetch()
{
const unsigned __int16 **v0; // rbx
char v1; // al
char v2; // al

v0 = _ctype_b_loc();
LABEL_2:
v1 = igetch();
if ( ((*v0)[v1] & 0x4000) != 0 )
return (unsigned int)v1;
while ( 1 )
{
if ( v1 == 13 || (v1 & 0xFD) == 8 || v1 == 127 )
return 10LL;
if ( v1 == 12 )
{
redoscr();
goto LABEL_2;
}
if ( v1 != 27 )
goto LABEL_2;
if ( (unsigned __int8)igetch() == 91 )
{
v2 = igetch();
if ( v2 == 65 )
return 16LL;
if ( v2 == 66 )
return 14LL;
}
bell();
v1 = igetch();
if ( ((*v0)[v1] & 0x4000) != 0 )
return (unsigned int)v1;
}
}

canonical_decompiled_code:
__int64 func12()
{
const unsigned __int16 **v0; // rbx
char v1; // al
char v2; // al

v0 = _ctype_b_loc();
LABEL_2:
v1 = igetch();
if ( ((*v0)[v1] & 0x4000) != 0 )
return (unsigned int)v1;
while ( 1 )
{
if ( v1 == 13 || (v1 & 0xFD) == 8 || v1 == 127 )
return 10LL;
if ( v1 == 12 )
{
redoscr();
goto LABEL_2;
}
if ( v1 != 27 )
goto LABEL_2;
if ( (unsigned __int8)igetch() == 91 )
{
v2 = igetch();
if ( v2 == 65 )
return 16LL;
if ( v2 == 66 )
return 14LL;
}
bell();
v1 = igetch();
if ( ((*v0)[v1] & 0x4000) != 0 )
return (unsigned int)v1;
}
}

original_code:
int
MenuGetch()
{
  char c;
  int keymode = (0);
  while (1) {
    c = igetch();
    switch (keymode) {
    case (0):
      if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISprint)) return c;
      if (c == '\r' || c == '\n' || c == '\010' || c == '\177') {
 c = '\n';
 return c;
      }
      if (c == ('L'&037)) {
        redoscr() ;
      }
      if (c == 27) keymode = (1);
      break;
    case (1):
      if (c == '[') keymode = (2);
      else {
 bell();
 keymode = (0);
      }
      break;
    case (2):
      if (c == 'A') return (16);
      else if (c == 'B') return (14);
      else {
 bell();
 keymode = (0);
      }
    }
  }
}

canonical_original_code:
int MenuGetch()
{
  char c;
  int keymode = (0);
  while (1) {
    c = igetch();
    switch (keymode) {
    case (0):
      if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISprint)) return c;
      if (c == '\r' || c == '\n' || c == '\010' || c == '\177') {
 c = '\n';
 return c;
      }
      if (c == ('L'&037)) {
        redoscr() ;
      }
      if (c == 27) keymode = (1);
      break;
    case (1):
      if (c == '[') keymode = (2);
      else {
 bell();
 keymode = (0);
      }
      break;
    case (2):
      if (c == 'A') return (16);
      else if (c == 'B') return (14);
      else {
 bell();
 keymode = (0);
      }
    }
  }
}

variable_types: c char

variable_types: keymode int


decompiled_code:
void hit_alarm_clock()
{
int v0; // edi

if ( !input_active )
disconnect(-3);
input_active = 0;
signal(14, hit_alarm_clock);
v0 = *(_DWORD *)&myinfo[16];
if ( v0 )
alarm(60 * v0);
}

canonical_decompiled_code:
void func3()
{
int v0; // edi

if ( !input_active )
func1(-3);
input_active = 0;
signal(14, hit_alarm_clock);
v0 = *(_DWORD *)&myinfo[16];
if ( v0 )
alarm(60 * v0);
}

original_code:
void
hit_alarm_clock()
{
  if (!input_active) {
    disconnect(-3);
  }
  input_active = 0;
  signal(14, hit_alarm_clock);
  if (myinfo.idletimeout) alarm((int)myinfo.idletimeout*60);
}


InitializeTerminal

decompiled_code:
__int64 InitializeTerminal()
{
__int64 result; // rax
char dest[12]; // [rsp+4h] [rbp-184h] BYREF
char v2[108]; // [rsp+10h] [rbp-178h] BYREF
char src[268]; // [rsp+7Ch] [rbp-10Ch] BYREF

if ( (unsigned int)local_bbs_owninfo(v2) )
{
prints("Can't determine your terminal type!\n");
prints("Defaulting to 'dumb'.\n");
return term_init("dumb");
}
strncpy(dest, src, 0xBuLL);
result = term_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' terminals!\n", dest);
prints("Defaulting terminal type to 'dumb'.\n");
return term_init("dumb");
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
char dest[12]; // [rsp+4h] [rbp-184h] BYREF
char v2[108]; // [rsp+10h] [rbp-178h] BYREF
char src[268]; // [rsp+7Ch] [rbp-10Ch] BYREF

if ( (unsigned int)local_bbs_owninfo(v2) )
{
prints("Can't determine your terminal type!\n");
prints("Defaulting to 'dumb'.\n");
return term_init("dumb");
}
strncpy(dest, src, 0xBuLL);
result = term_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' terminals!\n", dest);
prints("Defaulting terminal type to 'dumb'.\n");
return term_init("dumb");
}
return result;
}

original_code:
void
InitializeTerminal()
{
  TERM t;
  ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your terminal type!\n");
    prints("Defaulting to 'dumb'.\n");
    term_init("dumb");
    return;
  }
  strncpy(t, acct.terminal, 11);
  if (term_init(t) == -1) {
    prints("I don't know about '%s' terminals!\n", t);
    prints("Defaulting terminal type to 'dumb'.\n");
    term_init("dumb");
  }
}

canonical_original_code:
void InitializeTerminal()
{
  char t[-1];
  struct _ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your terminal type!\n");
    prints("Defaulting to 'dumb'.\n");
    term_init("dumb");
    return;
  }
  strncpy(t, acct.terminal, 11);
  if (term_init(t) == -1) {
    prints("I don't know about '%s' terminals!\n", t);
    prints("Defaulting terminal type to 'dumb'.\n");
    term_init("dumb");
  }
}

variable_types:
t
char [-1]

variable_types: struct _ACCOUNT { char userid[-1]; char passwd[-1]; char username[-1]; unsigned int perms; unsigned short flags; unsigned int lastlogin; char fromhost[-1]; char terminal[-1]; char charset[-1]; char realname[-1]; char address[-1]; char email[-1]; char protocol[-1]; char editor[-1]; }


InitializeCharset

decompiled_code:
__int64 InitializeCharset()
{
__int64 result; // rax
char dest[12]; // [rsp+4h] [rbp-184h] BYREF
char v2[120]; // [rsp+10h] [rbp-178h] BYREF
char src[256]; // [rsp+88h] [rbp-100h] BYREF

if ( (unsigned int)local_bbs_owninfo(v2) )
{
prints("Can't determine your character set!\n");
prints("Defaulting to 'ascii'.\n");
return conv_init("ascii");
}
strncpy(dest, src, 0xBuLL);
result = conv_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' charset!\n", dest);
prints("Defaulting character set to 'ascii'.\n");
return conv_init("ascii");
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
char dest[12]; // [rsp+4h] [rbp-184h] BYREF
char v2[120]; // [rsp+10h] [rbp-178h] BYREF
char src[256]; // [rsp+88h] [rbp-100h] BYREF

if ( (unsigned int)local_bbs_owninfo(v2) )
{
prints("Can't determine your character set!\n");
prints("Defaulting to 'ascii'.\n");
return conv_init("ascii");
}
strncpy(dest, src, 0xBuLL);
result = conv_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' charset!\n", dest);
prints("Defaulting character set to 'ascii'.\n");
return conv_init("ascii");
}
return result;
}

original_code:
void
InitializeCharset()
{
  CSET c;
  ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your character set!\n");
    prints("Defaulting to 'ascii'.\n");
    conv_init("ascii");
    return;
  }
  strncpy(c, acct.charset, 11);
  if (conv_init(c) == -1) {
    prints("I don't know about '%s' charset!\n", c);
    prints("Defaulting character set to 'ascii'.\n");
    conv_init("ascii");
  }
}

canonical_original_code:
void InitializeCharset()
{
  char c[-1];
  struct _ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your character set!\n");
    prints("Defaulting to 'ascii'.\n");
    conv_init("ascii");
    return;
  }
  strncpy(c, acct.charset, 11);
  if (conv_init(c) == -1) {
    prints("I don't know about '%s' charset!\n", c);
    prints("Defaulting character set to 'ascii'.\n");
    conv_init("ascii");
  }
}

variable_types:
c
char [-1]

user_defined_types: struct _ACCOUNT { char userid[-1]; char passwd[-1]; char username[-1]; unsigned int perms; unsigned short flags; unsigned int lastlogin; char fromhost[-1]; char terminal[-1]; char charset[-1]; char realname[-1]; char address[-1]; char email[-1]; char protocol[-1]; char editor[-1]; }


bbslog

decompiled_code:
int bbslog(int a1, const char *a2, ...)
{
int result; // eax
struct tm *v3; // rax
time_t v4; // [rsp+0h] [rbp-108h] BYREF
gcc_va_list arg; // [rsp+8h] [rbp-100h] BYREF
char s[48]; // [rsp+20h] [rbp-E8h] BYREF

va_start(arg, a2);
result = (int)arg[0].reg_save_area;
if ( bbs_loglevel >= a1 )
{
fseek(bbs_log, 0LL, 2);
if ( fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource) == -1 )
{
close_bbslog();
open_bbslog(bbs_logfile, bbs_loglevel);
fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource);
}
time(&v4);
v3 = localtime(&v4);
strftime(s, 0x28uLL, "%x %X", v3);
fprintf(bbs_log, "%s ", s);
vfprintf(bbs_log, a2, arg);
result = fflush(bbs_log);
}
return result;
}

canonical_decompiled_code:
int func3(int a1, const char *a2, ...)
{
int result; // eax
struct tm *v3; // rax
time_t v4; // [rsp+0h] [rbp-108h] BYREF
gcc_va_list arg; // [rsp+8h] [rbp-100h] BYREF
char s[48]; // [rsp+20h] [rbp-E8h] BYREF

va_start(arg, a2);
result = (int)arg[0].reg_save_area;
if ( bbs_loglevel >= a1 )
{
fseek(bbs_log, 0LL, 2);
if ( fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource) == -1 )
{
func1();
func0(bbs_logfile, bbs_loglevel);
fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource);
}
time(&v4);
v3 = localtime(&v4);
strftime(s, 0x28uLL, "%x %X", v3);
fprintf(bbs_log, "%s ", s);
vfprintf(bbs_log, a2, arg);
result = fflush(bbs_log);
}
return result;
}

original_code:
void
bbslog(int level, char *fmt, ...)
{
  va_list args;
  time_t now;
  char timestr[40];
  __builtin_va_start(args,fmt);
  if (level > bbs_loglevel) {
    __builtin_va_end(args);
    return;
  }
  fseek(bbs_log, 0, 2);
  if (fprintf(bbs_log, "%-16s ", bbs_logsource) == (-1)) {
    close_bbslog();
    open_bbslog(bbs_logfile, bbs_loglevel);
    fprintf(bbs_log, "%-16s ", bbs_logsource);
  }
  time(&now);
  strftime(timestr, sizeof timestr, "%x %X", localtime(&now));
  fprintf(bbs_log, "%s ", timestr);
  vfprintf(bbs_log, fmt, args);
  fflush(bbs_log);
  __builtin_va_end(args);
}

canonical_original_code:
void bbslog(int level, char *fmt, ...)
{
  __builtin_va_list args;
  long now;
  char timestr[40];
  __builtin_va_start(args,fmt);
  if (level > bbs_loglevel) {
    __builtin_va_end(args);
    return;
  }
  fseek(bbs_log, 0, 2);
  if (fprintf(bbs_log, "%-16s ", bbs_logsource) == (-1)) {
    close_bbslog();
    open_bbslog(bbs_logfile, bbs_loglevel);
    fprintf(bbs_log, "%-16s ", bbs_logsource);
  }
  time(&now);
  strftime(timestr, sizeof timestr, "%x %X", localtime(&now));
  fprintf(bbs_log, "%s ", timestr);
  vfprintf(bbs_log, fmt, args);
  fflush(bbs_log);
  __builtin_va_end(args);
}

variable_types: level int

variable_types:
fmt
char *

variable_types: now long

variable_types:
timestr
char [40]


igetch

decompiled_code:
__int64 __fastcall igetch(__int64 a1, char *a2)
{
int i; // eax
__int64 v3; // rdx
__int64 v4; // rdi
int v5; // edx
int v6; // eax
int v7; // er12
int v8; // edx
int v9; // eax
struct timeval v11; // [rsp+0h] [rbp-A8h] BYREF
fd_set readfds; // [rsp+10h] [rbp-98h] BYREF

for ( i = icurrchar; ; i = ++icurrchar )
{
if ( ibufsize != i )
goto LABEL_2;
v11.tv_sec = 0LL;
v11.tv_usec = 0LL;
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v4 = 1LL;
if ( i_newfd )
{
v5 = i_newfd + 63;
v4 = (unsigned int)(i_newfd + 1);
if ( i_newfd >= 0 )
v5 = i_newfd;
readfds.fds_bits[v5 >> 6] |= 1LL << (i_newfd % 64);
}
if ( select(v4, &readfds, 0LL, 0LL, &v11) <= 0 )
{
if ( flushf )
flushf(v4, &readfds);
if ( dumb_term )
oflush();
else
refresh();
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v7 = 1;
if ( i_newfd )
{
v8 = i_newfd + 63;
v7 = i_newfd + 1;
if ( i_newfd >= 0 )
v8 = i_newfd;
readfds.fds_bits[v8 >> 6] |= 1LL << (i_newfd % 64);
}
while ( 1 )
{
v9 = select(v7, &readfds, 0LL, 0LL, i_top);
if ( v9 >= 0 )
break;
if ( *_errno_location() != 4 )
{
perror("select");
fwrite("abnormal select conditions\n", 1uLL, 0x1BuLL, stderr);
return 0xFFFFFFFFLL;
}
}
if ( !v9 )
return 4294967294LL;
}
if ( i_newfd && (readfds.fds_bits[i_newfd / 64] & (1LL << (i_newfd % 64))) != 0 )
break;
while ( 1 )
{
a2 = inbuf;
a1 = 0LL;
v6 = read(0, inbuf, 0x100uLL);
ibufsize = v6;
if ( v6 > 0 )
break;
if ( !v6 )
{
generic_abort(0LL, inbuf);
v6 = ibufsize;
}
if ( v6 < 0 && *_errno_location() != 4 )
generic_abort(0LL, inbuf);
}
icurrchar = 0;
i = 0;
LABEL_2:
input_active = 1;
v3 = (unsigned __int8)inbuf[i];
if ( (_BYTE)v3 != 12 )
{
icurrchar = i + 1;
return *((unsigned int *)&conv_table + 2 * v3);
}
redoscr(a1, a2);
}
return 4294967293LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2)
{
int i; // eax
__int64 v3; // rdx
__int64 v4; // rdi
int v5; // edx
int v6; // eax
int v7; // er12
int v8; // edx
int v9; // eax
struct timeval v11; // [rsp+0h] [rbp-A8h] BYREF
fd_set readfds; // [rsp+10h] [rbp-98h] BYREF

for ( i = icurrchar; ; i = ++icurrchar )
{
if ( ibufsize != i )
goto LABEL_2;
v11.tv_sec = 0LL;
v11.tv_usec = 0LL;
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v4 = 1LL;
if ( i_newfd )
{
v5 = i_newfd + 63;
v4 = (unsigned int)(i_newfd + 1);
if ( i_newfd >= 0 )
v5 = i_newfd;
readfds.fds_bits[v5 >> 6] |= 1LL << (i_newfd % 64);
}
if ( select(v4, &readfds, 0LL, 0LL, &v11) <= 0 )
{
if ( flushf )
flushf(v4, &readfds);
if ( dumb_term )
func0();
else
refresh();
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v7 = 1;
if ( i_newfd )
{
v8 = i_newfd + 63;
v7 = i_newfd + 1;
if ( i_newfd >= 0 )
v8 = i_newfd;
readfds.fds_bits[v8 >> 6] |= 1LL << (i_newfd % 64);
}
while ( 1 )
{
v9 = select(v7, &readfds, 0LL, 0LL, i_top);
if ( v9 >= 0 )
break;
if ( *_errno_location() != 4 )
{
perror("select");
fwrite("abnormal select conditions\n", 1uLL, 0x1BuLL, stderr);
return 0xFFFFFFFFLL;
}
}
if ( !v9 )
return 4294967294LL;
}
if ( i_newfd && (readfds.fds_bits[i_newfd / 64] & (1LL << (i_newfd % 64))) != 0 )
break;
while ( 1 )
{
a2 = inbuf;
a1 = 0LL;
v6 = read(0, inbuf, 0x100uLL);
ibufsize = v6;
if ( v6 > 0 )
break;
if ( !v6 )
{
generic_abort(0LL, inbuf);
v6 = ibufsize;
}
if ( v6 < 0 && *_errno_location() != 4 )
generic_abort(0LL, inbuf);
}
icurrchar = 0;
i = 0;
LABEL_2:
input_active = 1;
v3 = (unsigned __int8)inbuf[i];
if ( (_BYTE)v3 != 12 )
{
icurrchar = i + 1;
return *((unsigned int *)&conv_table + 2 * v3);
}
redoscr(a1, a2);
}
return 4294967293LL;
}

original_code:
int
igetch()
{
igetagain:
    if(ibufsize == icurrchar) {
        fd_set readfds ;
        struct timeval to ;
        int nfds, sr ;
        to.tv_sec = 0 ;
        to.tv_usec = 0 ;
        do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
        nfds = 1;
     ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
        if(i_newfd) {
            ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
     nfds = i_newfd+1;
        }
        if((sr = select(nfds, &readfds, ((void *)0), ((void *)0), &to)) <= 0) {
            if(flushf)
                (*flushf)() ;
            if(dumb_term)
                oflush() ;
            else
                refresh() ;
selectagain:
            do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
            nfds = 1;
           ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
            if(i_newfd) {
                ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
           nfds = i_newfd+1;
     }
            while((sr = select(nfds, &readfds, ((void *)0), ((void *)0), i_top)) <0) {
                if((*__errno_location ()) == 4) {
        continue ;
  }
                else {
                    perror("select") ;
                    fprintf(stderr,"abnormal select conditions\n") ;
                    return -1 ;
                }
            }
            if(sr == 0)
                return (-2) ;
        }
        if(i_newfd && ((((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
            return (-3) ;
        }
        while((ibufsize = read(0,inbuf,(256))) <= 0) {
            if(ibufsize == 0)
                generic_abort() ;
            if(ibufsize < 0 && (*__errno_location ()) != 4)
                generic_abort() ;
        }
        icurrchar = 0 ;
    }
    input_active = 1;
    switch(inbuf[icurrchar]) {
      case ('L'&037):
        redoscr() ;
        icurrchar++ ;
        goto igetagain ;
      default:
        break ;
    }
    return conv_table[inbuf[icurrchar++]][0] ;
}

canonical_original_code:
int igetch()
{
igetagain:
    if(ibufsize == icurrchar) {
        struct fd_set readfds;
        struct timeval to;
        int nfds; int sr;
        to.tv_sec = 0 ;
        to.tv_usec = 0 ;
        do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
        nfds = 1;
     ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
        if(i_newfd) {
            ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
     nfds = i_newfd+1;
        }
        if((sr = select(nfds, &readfds, ((void *)0), ((void *)0), &to)) <= 0) {
            if(flushf)
                (*flushf)() ;
            if(dumb_term)
                oflush() ;
            else
                refresh() ;
selectagain:
            do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
            nfds = 1;
           ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
            if(i_newfd) {
                ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
           nfds = i_newfd+1;
     }
            while((sr = select(nfds, &readfds, ((void *)0), ((void *)0), i_top)) <0) {
                if((*__errno_location ()) == 4) {
        continue ;
  }
                else {
                    perror("select") ;
                    fprintf(stderr,"abnormal select conditions\n") ;
                    return -1 ;
                }
            }
            if(sr == 0)
                return (-2) ;
        }
        if(i_newfd && ((((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
            return (-3) ;
        }
        while((ibufsize = read(0,inbuf,(256))) <= 0) {
            if(ibufsize == 0)
                generic_abort() ;
            if(ibufsize < 0 && (*__errno_location ()) != 4)
                generic_abort() ;
        }
        icurrchar = 0 ;
    }
    input_active = 1;
    switch(inbuf[icurrchar]) {
      case ('L'&037):
        redoscr() ;
        icurrchar++ ;
        goto igetagain ;
      default:
        break ;
    }
    return conv_table[inbuf[icurrchar++]][0] ;
}

variable_types:
readfds
struct fd_set { long __fds_bits[-1]; }

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

variable_types: nfds int

variable_types: sr int


repo: virtualolson/who

decompiled_code:
__int64 __fastcall db_cluster_bind_api(_QWORD *a1)
{
unsigned __int64 v2; // rdi

if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
v2 = (unsigned __int64)(a1 + 1);
*(_QWORD *)(v2 + 152) = 0LL;
memset((void *)(v2 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)a1 - (v2 & 0xFFFFFFF8) + 168) >> 3));
a1[1] = &db_cluster_use_table;
a1[2] = &db_cluster_init;
a1[4] = &db_cluster_close;
a1[5] = &db_cluster_query;
a1[6] = &db_cluster_fetch_result;
a1[7] = &db_cluster_raw_query;
a1[8] = &db_cluster_free_result;
a1[9] = &db_cluster_insert;
a1[10] = &db_cluster_delete;
a1[11] = &db_cluster_update;
a1[12] = &db_cluster_replace;
a1[13] = &db_cluster_last_inserted_id;
a1[14] = &db_cluster_insert_update;
a1[15] = &db_cluster_insert_delayed;
a1[16] = &db_cluster_affected_rows;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
unsigned __int64 v2; // rdi

if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
v2 = (unsigned __int64)(a1 + 1);
*(_QWORD *)(v2 + 152) = 0LL;
memset((void *)(v2 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)a1 - (v2 & 0xFFFFFFF8) + 168) >> 3));
a1[1] = &db_cluster_use_table;
a1[2] = &db_cluster_init;
a1[4] = &db_cluster_close;
a1[5] = &db_cluster_query;
a1[6] = &db_cluster_fetch_result;
a1[7] = &db_cluster_raw_query;
a1[8] = &db_cluster_free_result;
a1[9] = &db_cluster_insert;
a1[10] = &db_cluster_delete;
a1[11] = &db_cluster_update;
a1[12] = &db_cluster_replace;
a1[13] = &db_cluster_last_inserted_id;
a1[14] = &db_cluster_insert_update;
a1[15] = &db_cluster_insert_delayed;
a1[16] = &db_cluster_affected_rows;
return 0LL;
}

original_code:
int db_cluster_bind_api(db_func_t *dbb)
{
 if(dbb==((void *)0))
  return -1;
 memset(dbb, 0, sizeof(db_func_t));
 dbb->use_table = db_cluster_use_table;
 dbb->init = db_cluster_init;
 dbb->close = db_cluster_close;
 dbb->query = db_cluster_query;
 dbb->fetch_result = db_cluster_fetch_result;
 dbb->raw_query = db_cluster_raw_query;
 dbb->free_result = db_cluster_free_result;
 dbb->insert = db_cluster_insert;
 dbb->delete = db_cluster_delete;
 dbb->update = db_cluster_update;
 dbb->replace = db_cluster_replace;
 dbb->last_inserted_id = db_cluster_last_inserted_id;
 dbb->insert_update = db_cluster_insert_update;
 dbb->insert_delayed = db_cluster_insert_delayed;
 dbb->affected_rows = db_cluster_affected_rows;
 return 0;
}

canonical_original_code:
int db_cluster_bind_api(struct db_func *dbb)
{
 if(dbb==((void *)0))
  return -1;
 memset(dbb, 0, sizeof(db_func_t));
 dbb->use_table = db_cluster_use_table;
 dbb->init = db_cluster_init;
 dbb->close = db_cluster_close;
 dbb->query = db_cluster_query;
 dbb->fetch_result = db_cluster_fetch_result;
 dbb->raw_query = db_cluster_raw_query;
 dbb->free_result = db_cluster_free_result;
 dbb->insert = db_cluster_insert;
 dbb->delete = db_cluster_delete;
 dbb->update = db_cluster_update;
 dbb->replace = db_cluster_replace;
 dbb->last_inserted_id = db_cluster_last_inserted_id;
 dbb->insert_update = db_cluster_insert_update;
 dbb->insert_delayed = db_cluster_insert_delayed;
 dbb->affected_rows = db_cluster_affected_rows;
 return 0;
}

variable_types: struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t { struct _str { char *s; int len; } *table; unsigned long tail; } *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t { DB_POOLING_PERMITTED=0, DB_POOLING_NONE=1 } _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t { enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; } *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res { struct { struct _str **names; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } *types; int n; } col; struct db_row { struct db_val_t *values; int n; } *rows; int n; int res_rows; int last_row; void *ptr; } **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t { DB_LOCKING_NONE=0, DB_LOCKING_WRITE=1, DB_LOCKING_FULL=2 } _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); } *

user_defined_types: struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); }

user_defined_types: struct db1_con_t { struct _str *table; unsigned long tail; }

user_defined_types: struct db_val_t { enum db_type_t type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; }

user_defined_types: struct db1_res { struct { struct _str **names; enum db_type_t *types; int n; } col; struct db_row *rows; int n; int res_rows; int last_row; void *ptr; }


decompiled_code:
__int64 __fastcall dbcl_con_param(__int64 a1, __int64 a2)
{
return dbcl_parse_con_param(a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return dbcl_parse_con_param(a2);
}

original_code:
int dbcl_con_param(modparam_t type, void *val)
{
 return dbcl_parse_con_param((char*)val);
}

canonical_original_code:
int dbcl_con_param(unsigned int type, void *val)
{
 return dbcl_parse_con_param((char *)val);
}

variable_types:
type
unsigned int

variable_types:
val
void *


decompiled_code:
__int64 __fastcall dbcl_cls_param(__int64 a1, __int64 a2)
{
return dbcl_parse_cls_param(a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
return dbcl_parse_cls_param(a2);
}

original_code:
int dbcl_cls_param(modparam_t type, void *val)
{
 return dbcl_parse_cls_param((char*)val);
}

canonical_original_code:
int dbcl_cls_param(unsigned int type, void *val)
{
 return dbcl_parse_cls_param((char *)val);
}


decompiled_code:
__int64 mod_init()
{
const char *v1; // r12
unsigned int v2; // eax

if ( (int)get_debug_level("db_cluster", 10LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Setting up DB cluster\n",
process_no,
v2,
v1,
"db_cluster [db_cluster_mod.c:77]: ",
"mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Setting up DB cluster\n",
*((const char **)&log_level_info + 16),
"db_cluster [db_cluster_mod.c:77]: ",
"mod_init");
}
--dprint_crit;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
const char *v1; // r12
unsigned int v2; // eax

if ( (int)get_debug_level("db_cluster", 10LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v1 = (const char *)*((_QWORD *)&log_level_info + 16);
v2 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Setting up DB cluster\n",
process_no,
v2,
v1,
"db_cluster [db_cluster_mod.c:77]: ",
"mod_init");
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Setting up DB cluster\n",
*((const char **)&log_level_info + 16),
"db_cluster [db_cluster_mod.c:77]: ",
"mod_init");
}
--dprint_crit;
}
return 0LL;
}

original_code:
int mod_init(void)
{
 do { if (get_debug_level("db_cluster", (sizeof("db_cluster")-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(): " "Setting up DB cluster\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __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(): " "Setting up DB cluster\n", (log_level_info[((3)) - (-5)].name), ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Setting up DB cluster\n", process_no, my_pid(), ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __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(): " "Setting up DB cluster\n", ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Setting up DB cluster\n", ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
}

canonical_original_code:
int mod_init()
{
 do { if (get_debug_level("db_cluster", (sizeof("db_cluster")-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(): " "Setting up DB cluster\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __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(): " "Setting up DB cluster\n", (log_level_info[((3)) - (-5)].name), ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Setting up DB cluster\n", process_no, my_pid(), ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __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(): " "Setting up DB cluster\n", ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Setting up DB cluster\n", ("db_cluster" " [" "db_cluster_mod.c" ":" "77" "]: ") , __func__); } } (dprint_crit--); } } while(0);
 return 0;
}

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


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


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


original_code:
static void tem_do_step(time_event_manager_t *tem)
{
 time_event_data_t *e, *n, *unprocessed_first, *unprocessed_last;
 time_event_slot_t *slot;

 if (tem->mutex) futex_get(tem->mutex);
 unprocessed_first = ((void *)0);
 unprocessed_last = ((void *)0);
 slot = &tem->time_slots[tem->tick_counter % tem->slot_cnt];
 e = slot->first;
 while (e) {
  n = e->next;
  if (e->tick_time == tem->tick_counter) {
   if (e->cb) e->cb(e);
  }
  else {
   e->prev = unprocessed_last;
   e->next = ((void *)0);
   if (unprocessed_last) unprocessed_last->next = e;
   else unprocessed_first = e;
   unprocessed_last = e;
  }
  e = n;
 }
 slot->first = unprocessed_first;
 slot->last = unprocessed_last;
 tem->tick_counter++;
 if (tem->mutex) futex_release(tem->mutex);

}

canonical_original_code:
static void tem_do_step(struct _time_event_manager_t *tem)
{
 struct _time_event_data_t *e; struct _time_event_data_t *n; struct _time_event_data_t *unprocessed_first; struct _time_event_data_t *unprocessed_last;
 struct _time_event_slot_t *slot;

 if (tem->mutex) futex_get(tem->mutex);
 unprocessed_first = ((void *)0);
 unprocessed_last = ((void *)0);
 slot = &tem->time_slots[tem->tick_counter % tem->slot_cnt];
 e = slot->first;
 while (e) {
  n = e->next;
  if (e->tick_time == tem->tick_counter) {
   if (e->cb) e->cb(e);
  }
  else {
   e->prev = unprocessed_last;
   e->next = ((void *)0);
   if (unprocessed_last) unprocessed_last->next = e;
   else unprocessed_first = e;
   unprocessed_last = e;
  }
  e = n;
 }
 slot->first = unprocessed_first;
 slot->last = unprocessed_last;
 tem->tick_counter++;
 if (tem->mutex) futex_release(tem->mutex);

}

variable_types: struct _time_event_manager_t { struct _time_event_slot_t { struct _time_event_data_t { unsigned int tick_time; void (*cb)(struct _time_event_data_t *s); void *cb_param; void *cb_param1; struct _time_event_data_t *next; struct _time_event_data_t *prev; } *first; } *time_slots; unsigned int slot_cnt; unsigned int atomic_time; int enable_delay; unsigned int tick_counter; struct atomic_t { int val; } *mutex; unsigned int process_timer_counter; struct _time_event_manager_t *next; struct _time_event_manager_t *prev; } *

user_defined_types: struct _time_event_manager_t { struct _time_event_slot_t *time_slots; unsigned int slot_cnt; unsigned int atomic_time; int enable_delay; unsigned int tick_counter; struct atomic_t *mutex; unsigned int process_timer_counter; struct _time_event_manager_t *next; struct _time_event_manager_t *prev; }

user_defined_types: struct _time_event_slot_t { struct _time_event_data_t *first; }


decompiled_code:
__int64 tem_timer_cb()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rbp

result = tem_info;
if ( tem_info )
{
v1 = *(_QWORD *)tem_info;
while ( v1 )
{
while ( 1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 40);
if ( (*(_DWORD *)(v2 + 32))-- != 1 )
break;
result = tem_do_step(v2);
*(_DWORD *)(v2 + 32) = *(_DWORD *)(v2 + 12);
if ( !v1 )
return result;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rbp

result = tem_info;
if ( tem_info )
{
v1 = *(_QWORD *)tem_info;
while ( v1 )
{
while ( 1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 40);
if ( (*(_DWORD *)(v2 + 32))-- != 1 )
break;
result = func4(v2);
*(_DWORD *)(v2 + 32) = *(_DWORD *)(v2 + 12);
if ( !v1 )
return result;
}
}
}
return result;
}

original_code:
static void tem_timer_cb(unsigned int ticks, void *param)
{
 time_event_manager_t *e, *n;

 if (!tem_info) return;
 e = tem_info->first;
 while (e) {
  n = e->next;
  if (--e->process_timer_counter == 0) {
   tem_do_step(e);
   e->process_timer_counter = e->atomic_time;
  }
  e = n;
 }

}

canonical_original_code:
static void tem_timer_cb(unsigned int ticks, void *param)
{
 struct _time_event_manager_t *e; struct _time_event_manager_t *n;

 if (!tem_info) return;
 e = tem_info->first;
 while (e) {
  n = e->next;
  if (--e->process_timer_counter == 0) {
   tem_do_step(e);
   e->process_timer_counter = e->atomic_time;
  }
  e = n;
 }

}

variable_types:
ticks
unsigned int

variable_types:
param
void *

user_defined_types: struct _time_event_data_t { unsigned int tick_time; void (*cb)(struct _time_event_data_t *s); void *cb_param; void *cb_param1; struct _time_event_data_t *next; struct _time_event_data_t *prev; }


decompiled_code:
__int64 __fastcall shm_malloc(unsigned int a1)
{
__int64 v1; // r12

futex_get(mem_lock);
v1 = qm_malloc(shm_block, a1);
futex_release(mem_lock);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
__int64 v1; // r12

func3(mem_lock);
v1 = qm_malloc(shm_block, a1);
func1(mem_lock);
return v1;
}

original_code:
inline static void* shm_malloc(unsigned int size)
{
 void *p;
 futex_get(mem_lock);
 p=qm_malloc(shm_block, (size));
 futex_release(mem_lock);
  return p;
}

canonical_original_code:
inline static void *shm_malloc(unsigned int size)
{
 void *p;
 futex_get(mem_lock);
 p=qm_malloc(shm_block, (size));
 futex_release(mem_lock);
  return p;
}

variable_types:
size
unsigned int

variable_types:
p
void *


decompiled_code:
__int64 time_event_management_init()
{
__int64 v1; // rax
__int64 v2; // rdi
__int64 v3; // r12
const char *v4; // rsi
__int64 v5; // rcx
__int64 v6; // r8
__int64 v7; // rdx
const char *v8; // r9
struct _IO_FILE *v9; // rdi
__int64 v10; // r12
__int64 v11; // [rsp-20h] [rbp-20h]
__int64 v12; // [rsp-20h] [rbp-20h]

if ( tem_info )
return 0LL;
v1 = shm_malloc(0x18u);
tem_info = v1;
if ( !v1 )
{
v2 = (__int64)&LC0;
if ( (int)get_debug_level(&LC0, 3LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): time_event_management_init(): can't allocate shared memory\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:44]: ",
"time_event_management_init");
LABEL_10:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
{
v2 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v3 = *((_QWORD *)&log_level_info + 8);
v4 = "%2d(%d) %s: %s%s(): time_event_management_init(): can't allocate shared memory\n";
v11 = v2;
v5 = (unsigned int)my_pid();
v6 = v3;
v7 = process_no;
v8 = "rls [time_event_manager.c:44]: ";
LABEL_19:
v9 = stderr;
fprintf(stderr, v4, v7, v5, v6, v8, "time_event_management_init", v11);
if ( log_color )
dprint_color_reset(v9, v4, v12);
goto LABEL_10;
}
*(_QWORD *)v1 = 0LL;
*(_QWORD *)(v1 + 8) = 0LL;
futex_init_isra_0((_DWORD *)(v1 + 16));
if ( (int)register_timer(tem_timer_cb, 0LL) >= 0 )
return 0LL;
if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): time_event_management_init(): can't register timer\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:53]: ",
"time_event_management_init");
goto LABEL_10;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = *((_QWORD *)&log_level_info + 8);
v5 = (unsigned int)my_pid();
v11 = 3LL;
v6 = v10;
v4 = "%2d(%d) %s: %s%s(): time_event_management_init(): can't register timer\n";
v7 = process_no;
v8 = "rls [time_event_manager.c:53]: ";
goto LABEL_19;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 v1; // rax
__int64 v2; // rdi
__int64 v3; // r12
const char *v4; // rsi
__int64 v5; // rcx
__int64 v6; // r8
__int64 v7; // rdx
const char *v8; // r9
struct _IO_FILE *v9; // rdi
__int64 v10; // r12
__int64 v11; // [rsp-20h] [rbp-20h]
__int64 v12; // [rsp-20h] [rbp-20h]

if ( tem_info )
return 0LL;
v1 = func6(0x18u);
tem_info = v1;
if ( !v1 )
{
v2 = (__int64)&LC0;
if ( (int)get_debug_level(&LC0, 3LL) < -1 || dprint_crit )
return 0xFFFFFFFFLL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): time_event_management_init(): can't allocate shared memory\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:44]: ",
"time_event_management_init");
LABEL_10:
--dprint_crit;
return 0xFFFFFFFFLL;
}
if ( log_color )
{
v2 = 0xFFFFFFFFLL;
dprint_color(0xFFFFFFFFLL);
}
v3 = *((_QWORD *)&log_level_info + 8);
v4 = "%2d(%d) %s: %s%s(): time_event_management_init(): can't allocate shared memory\n";
v11 = v2;
v5 = (unsigned int)my_pid();
v6 = v3;
v7 = process_no;
v8 = "rls [time_event_manager.c:44]: ";
LABEL_19:
v9 = stderr;
fprintf(stderr, v4, v7, v5, v6, v8, "time_event_management_init", v11);
if ( log_color )
dprint_color_reset(v9, v4, v12);
goto LABEL_10;
}
*(_QWORD *)v1 = 0LL;
*(_QWORD *)(v1 + 8) = 0LL;
func7((_DWORD *)(v1 + 16));
if ( (int)register_timer(tem_timer_cb, 0LL) >= 0 )
return 0LL;
if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): time_event_management_init(): can't register timer\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:53]: ",
"time_event_management_init");
goto LABEL_10;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = *((_QWORD *)&log_level_info + 8);
v5 = (unsigned int)my_pid();
v11 = 3LL;
v6 = v10;
v4 = "%2d(%d) %s: %s%s(): time_event_management_init(): can't register timer\n";
v7 = process_no;
v8 = "rls [time_event_manager.c:53]: ";
goto LABEL_19;
}
return 0xFFFFFFFFLL;
}

original_code:
int time_event_management_init()
{
 if (tem_info) return 0;
 tem_info = (tem_info_t *)shm_malloc(sizeof(tem_info_t));
 if (!tem_info) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "time_event_management_init(): can't allocate shared memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __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(): " "time_event_management_init(): can't allocate shared memory\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "time_event_management_init(): can't allocate shared memory\n", process_no, my_pid(), ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __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(): " "time_event_management_init(): can't allocate shared memory\n", ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "time_event_management_init(): can't allocate shared memory\n", ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 tem_info->first = ((void *)0);
 tem_info->last = ((void *)0);
 futex_init(&tem_info->structure_mutex);
 if (register_timer(tem_timer_cb, ((void *)0), 1) < 0) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "time_event_management_init(): can't register timer\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __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(): " "time_event_management_init(): can't register timer\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "time_event_management_init(): can't register timer\n", process_no, my_pid(), ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __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(): " "time_event_management_init(): can't register timer\n", ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "time_event_management_init(): can't register timer\n", ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return 0;
}

canonical_original_code:
int time_event_management_init()
{
 if (tem_info) return 0;
 tem_info = (struct tem_info_t *)shm_malloc(sizeof(tem_info_t));
 if (!tem_info) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "time_event_management_init(): can't allocate shared memory\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __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(): " "time_event_management_init(): can't allocate shared memory\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "time_event_management_init(): can't allocate shared memory\n", process_no, my_pid(), ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __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(): " "time_event_management_init(): can't allocate shared memory\n", ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "time_event_management_init(): can't allocate shared memory\n", ("rls" " [" "time_event_manager.c" ":" "44" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 tem_info->first = ((void *)0);
 tem_info->last = ((void *)0);
 futex_init(&tem_info->structure_mutex);
 if (register_timer(tem_timer_cb, ((void *)0), 1) < 0) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "time_event_management_init(): can't register timer\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __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(): " "time_event_management_init(): can't register timer\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "time_event_management_init(): can't register timer\n", process_no, my_pid(), ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __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(): " "time_event_management_init(): can't register timer\n", ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "time_event_management_init(): can't register timer\n", ("rls" " [" "time_event_manager.c" ":" "53" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 return 0;
}

user_defined_types: struct tem_info_t { struct _time_event_manager_t *first; struct _time_event_manager_t *last; struct atomic_t structure_mutex; }


decompiled_code:
__int64 __fastcall tem_init(__int64 a1, int a2, unsigned int a3, int a4, __int64 a5)
{
void *v6; // rax
__int64 v7; // rbp
__int64 v8; // rax
__int64 result; // rax
const char *v10; // r12
struct _IO_FILE *v11; // rdi
__int64 v12; // [rsp-28h] [rbp-28h]
unsigned int v13; // [rsp-20h] [rbp-20h]

if ( !a1 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 20) = 0;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 8) = a3;
*(_DWORD *)(a1 + 16) = a4;
*(_QWORD *)(a1 + 24) = a5;
v6 = (void *)shm_malloc(16 * a3);
*(_QWORD *)a1 = v6;
if ( v6 )
{
memset(v6, 0, 16LL * a3);
v7 = tem_info;
*(_DWORD *)(a1 + 32) = a2;
*(_QWORD *)(a1 + 40) = 0LL;
futex_get((volatile signed __int32 *)(v7 + 16));
v8 = *(_QWORD *)(v7 + 8);
*(_QWORD *)(a1 + 48) = v8;
if ( v8 )
*(_QWORD *)(v8 + 40) = a1;
else
*(_QWORD *)v7 = a1;
*(_QWORD *)(v7 + 8) = a1;
futex_release((volatile __int32 *)(v7 + 16));
result = 0LL;
}
else
{
if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't initialize time event manager slots\n",
process_no,
v13,
v10,
"rls [time_event_manager.c:91]: ",
"tem_init");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): can't initialize time event manager slots\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't initialize time event manager slots\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:91]: ",
"tem_init");
}
--dprint_crit;
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2, unsigned int a3, int a4, __int64 a5)
{
void *v6; // rax
__int64 v7; // rbp
__int64 v8; // rax
__int64 result; // rax
const char *v10; // r12
struct _IO_FILE *v11; // rdi
__int64 v12; // [rsp-28h] [rbp-28h]
unsigned int v13; // [rsp-20h] [rbp-20h]

if ( !a1 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 20) = 0;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 8) = a3;
*(_DWORD *)(a1 + 16) = a4;
*(_QWORD *)(a1 + 24) = a5;
v6 = (void *)func6(16 * a3);
*(_QWORD *)a1 = v6;
if ( v6 )
{
memset(v6, 0, 16LL * a3);
v7 = tem_info;
*(_DWORD *)(a1 + 32) = a2;
*(_QWORD *)(a1 + 40) = 0LL;
func3((volatile signed __int32 *)(v7 + 16));
v8 = *(_QWORD *)(v7 + 8);
*(_QWORD *)(a1 + 48) = v8;
if ( v8 )
*(_QWORD *)(v8 + 40) = a1;
else
*(_QWORD *)v7 = a1;
*(_QWORD *)(v7 + 8) = a1;
func1((volatile __int32 *)(v7 + 16));
result = 0LL;
}
else
{
if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v13 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't initialize time event manager slots\n",
process_no,
v13,
v10,
"rls [time_event_manager.c:91]: ",
"tem_init");
if ( log_color )
dprint_color_reset(v11, "%2d(%d) %s: %s%s(): can't initialize time event manager slots\n", v12);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't initialize time event manager slots\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:91]: ",
"tem_init");
}
--dprint_crit;
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int tem_init(time_event_manager_t *tm, unsigned int atomic_time,
  unsigned int slot_cnt, int enable_delay, gen_lock_t *mutex)
{
 if (!tm) return -1;
 tm->tick_counter = 0;
 tm->atomic_time = atomic_time;
 tm->slot_cnt = slot_cnt;
 tm->enable_delay = enable_delay;
 tm->mutex = mutex;
 tm->time_slots = (time_event_slot_t *)shm_malloc(slot_cnt * sizeof(time_event_slot_t));
 if (!tm->time_slots) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't initialize time event manager slots\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.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(): " "can't initialize time event manager slots\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "91" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't initialize time event manager slots\n", process_no, my_pid(), ("rls" " [" "time_event_manager.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(): " "can't initialize time event manager slots\n", ("rls" " [" "time_event_manager.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(): " "can't initialize time event manager slots\n", ("rls" " [" "time_event_manager.c" ":" "91" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(tm->time_slots, 0, slot_cnt * sizeof(time_event_slot_t));
 tm->next = ((void *)0);
 tm->process_timer_counter = atomic_time;
 futex_get(&tem_info->structure_mutex);
 tm->prev = tem_info->last;
 if (tem_info->last) tem_info->last->next = tm;
 else tem_info->first = tm;
 tem_info->last = tm;
 futex_release(&tem_info->structure_mutex);
 return 0;
}

canonical_original_code:
int tem_init(struct _time_event_manager_t *tm, unsigned int atomic_time, unsigned int slot_cnt, int enable_delay, struct atomic_t *mutex)
{
 if (!tm) return -1;
 tm->tick_counter = 0;
 tm->atomic_time = atomic_time;
 tm->slot_cnt = slot_cnt;
 tm->enable_delay = enable_delay;
 tm->mutex = mutex;
 tm->time_slots = (struct _time_event_slot_t *)shm_malloc(slot_cnt * sizeof(time_event_slot_t));
 if (!tm->time_slots) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't initialize time event manager slots\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.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(): " "can't initialize time event manager slots\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "91" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't initialize time event manager slots\n", process_no, my_pid(), ("rls" " [" "time_event_manager.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(): " "can't initialize time event manager slots\n", ("rls" " [" "time_event_manager.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(): " "can't initialize time event manager slots\n", ("rls" " [" "time_event_manager.c" ":" "91" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(tm->time_slots, 0, slot_cnt * sizeof(time_event_slot_t));
 tm->next = ((void *)0);
 tm->process_timer_counter = atomic_time;
 futex_get(&tem_info->structure_mutex);
 tm->prev = tem_info->last;
 if (tem_info->last) tem_info->last->next = tm;
 else tem_info->first = tm;
 tem_info->last = tm;
 futex_release(&tem_info->structure_mutex);
 return 0;
}

variable_types:
mutex
struct atomic_t *


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

v6 = shm_malloc(0x38u);
v7 = v6;
if ( v6 )
{
if ( (unsigned int)tem_init(v6, a1, a2, a3, a4) )
{
futex_get(mem_lock);
v9 = v7;
v7 = 0LL;
qm_free(shm_block, v9);
futex_release(mem_lock);
}
}
else if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
v12 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't allocate time event manager\n",
process_no,
v11,
v10,
"rls [time_event_manager.c:117]: ",
"tem_create");
if ( log_color )
dprint_color_reset(v12, "%2d(%d) %s: %s%s(): can't allocate time event manager\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't allocate time event manager\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:117]: ",
"tem_create");
}
--dprint_crit;
}
return v7;
}

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

v6 = func6(0x38u);
v7 = v6;
if ( v6 )
{
if ( (unsigned int)func9(v6, a1, a2, a3, a4) )
{
func3(mem_lock);
v9 = v7;
v7 = 0LL;
qm_free(shm_block, v9);
func1(mem_lock);
}
}
else if ( (int)get_debug_level(&LC0, 3LL) >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v10 = (const char *)*((_QWORD *)&log_level_info + 8);
v11 = my_pid();
v12 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): can't allocate time event manager\n",
process_no,
v11,
v10,
"rls [time_event_manager.c:117]: ",
"tem_create");
if ( log_color )
dprint_color_reset(v12, "%2d(%d) %s: %s%s(): can't allocate time event manager\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): can't allocate time event manager\n",
*((const char **)&log_level_info + 8),
"rls [time_event_manager.c:117]: ",
"tem_create");
}
--dprint_crit;
}
return v7;
}

original_code:
time_event_manager_t *tem_create(unsigned int atomic_time, unsigned int slot_cnt, int enable_delay, gen_lock_t *mutex)
{
 time_event_manager_t *tm;
 tm = (time_event_manager_t*)shm_malloc(sizeof(time_event_manager_t));
 if (!tm) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't allocate time event manager\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't allocate time event manager\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't allocate time event manager\n", process_no, my_pid(), ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't allocate time event manager\n", ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't allocate time event manager\n", ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return tm;
 }
 if (tem_init(tm, atomic_time, slot_cnt, enable_delay, mutex) != 0) {
  do { futex_get(mem_lock); qm_free(shm_block, (tm)); futex_release(mem_lock); }while(0);
  return ((void *)0);
 }
 return tm;
}

canonical_original_code:
struct _time_event_manager_t *tem_create(unsigned int atomic_time, unsigned int slot_cnt, int enable_delay, struct atomic_t *mutex)
{
 struct _time_event_manager_t *tm;
 tm = (struct _time_event_manager_t *)shm_malloc(sizeof(time_event_manager_t));
 if (!tm) {
  do { if (get_debug_level("rls", (sizeof("rls")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "can't allocate time event manager\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "can't allocate time event manager\n", (log_level_info[((-1)) - (-5)].name), ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "can't allocate time event manager\n", process_no, my_pid(), ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't allocate time event manager\n", ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "can't allocate time event manager\n", ("rls" " [" "time_event_manager.c" ":" "117" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return tm;
 }
 if (tem_init(tm, atomic_time, slot_cnt, enable_delay, mutex) != 0) {
  do { futex_get(mem_lock); qm_free(shm_block, (tm)); futex_release(mem_lock); }while(0);
  return ((void *)0);
 }
 return tm;
}

return_type: struct _time_event_manager_t { struct _time_event_slot_t { struct _time_event_data_t { unsigned int tick_time; void (*cb)(struct _time_event_data_t *s); void *cb_param; void *cb_param1; struct _time_event_data_t *next; struct _time_event_data_t *prev; } *first; } *time_slots; unsigned int slot_cnt; unsigned int atomic_time; int enable_delay; unsigned int tick_counter; struct atomic_t { int val; } *mutex; unsigned int process_timer_counter; struct _time_event_manager_t *next; struct _time_event_manager_t *prev; } *