decompiled_code:
void errors_begin_pass()
{
ErrorReport = -1;
*((_QWORD *)&ErrorReport + 1) = "<no text read yet>";
*((_QWORD *)&ErrorReport + 2) = 0LL;
}

canonical_decompiled_code:
void func27()
{
ErrorReport = -1;
*((_QWORD *)&ErrorReport + 1) = "<no text read yet>";
*((_QWORD *)&ErrorReport + 2) = 0LL;
}

original_code:
extern void errors_begin_pass(void)
{ ErrorReport.line_number = 0;
    ErrorReport.file_number = -1;
    ErrorReport.source = "<no text read yet>";
    ErrorReport.main_flag = 0;
}

canonical_original_code:
extern void errors_begin_pass()
{ ErrorReport.line_number = 0;
    ErrorReport.file_number = -1;
    ErrorReport.source = "<no text read yet>";
    ErrorReport.main_flag = 0;
}


repo: ricpelo/elcirculo

decompiled_code:
__int64 errors_allocate_arrays()
{
__int64 result; // rax

result = my_malloc(512LL, "errors buffer");
forerrors_buff = result;
return result;
}

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

result = my_malloc(512LL, "errors buffer");
forerrors_buff = result;
return result;
}

original_code:
extern void errors_allocate_arrays(void)
{ forerrors_buff = my_malloc(512, "errors buffer");
}

canonical_original_code:
extern void errors_allocate_arrays()
{ forerrors_buff = my_malloc(512, "errors buffer");
}

return_type: void


decompiled_code:
__int64 errors_free_arrays()
{
return my_free(&forerrors_buff, "errors buffer");
}

canonical_decompiled_code:
__int64 func29()
{
return my_free(&forerrors_buff, "errors buffer");
}

original_code:
extern void errors_free_arrays(void)
{ my_free(&forerrors_buff, "errors buffer");
}

canonical_original_code:
extern void errors_free_arrays()
{ my_free(&forerrors_buff, "errors buffer");
}


message

decompiled_code:
int __fastcall message(int a1, const char *a2)
{
int result; // eax
__int64 v3; // rax
__int64 v4; // rsi

if ( hash_printed_since_newline )
putchar(10);
hash_printed_since_newline = 0;
print_preamble();
switch ( a1 )
{
case 3:
printf("Error: [linking '%s'] ", (const char *)&current_module_filename);
++no_link_errors;
++no_errors;
return printf(" %s\n", a2);
case 4:
printf("*** Compiler error: ");
++no_compiler_errors;
return printf(" %s\n", a2);
case 2:
printf("Warning: ");
++no_warnings;
break;
default:
printf("Error: ");
++no_errors;
break;
}
printf(" %s\n", a2);
result = concise_switch;
if ( !concise_switch )
{
result = forerrors_pointer;
if ( a1 <= 2 && forerrors_pointer > 0 )
{
*(_BYTE *)(forerrors_buff + forerrors_pointer) = 0;
v3 = forerrors_buff;
*(_QWORD *)(forerrors_buff + 68) = 0x6374652E2E2E2020LL;
v4 = forerrors_buff;
*(_BYTE *)(v3 + 76) = 0;
result = printf("> %s\n", v4);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, const char *a2)
{
int result; // eax
__int64 v3; // rax
__int64 v4; // rsi

if ( hash_printed_since_newline )
putchar(10);
hash_printed_since_newline = 0;
func0();
switch ( a1 )
{
case 3:
printf("Error: [linking '%s'] ", (const char *)&current_module_filename);
++no_link_errors;
++no_errors;
return printf(" %s\n", a2);
case 4:
printf("*** Compiler error: ");
++no_compiler_errors;
return printf(" %s\n", a2);
case 2:
printf("Warning: ");
++no_warnings;
break;
default:
printf("Error: ");
++no_errors;
break;
}
printf(" %s\n", a2);
result = concise_switch;
if ( !concise_switch )
{
result = forerrors_pointer;
if ( a1 <= 2 && forerrors_pointer > 0 )
{
*(_BYTE *)(forerrors_buff + forerrors_pointer) = 0;
v3 = forerrors_buff;
*(_QWORD *)(forerrors_buff + 68) = 0x6374652E2E2E2020LL;
v4 = forerrors_buff;
*(_BYTE *)(v3 + 76) = 0;
result = printf("> %s\n", v4);
}
}
return result;
}

original_code:
static void message(int style, char *s)
{ int throw_style = style;
    if (hash_printed_since_newline) printf("\n");
    hash_printed_since_newline = 0;
    print_preamble();
    switch(style)
    { case 1: printf("Error: "); no_errors++; break;
        case 2: printf("Warning: "); no_warnings++; break;
        case 3: printf("Error:  [linking '%s']  ", current_module_filename);
                no_link_errors++; no_errors++; throw_style=1; break;
        case 4: printf("*** Compiler error: ");
                no_compiler_errors++; throw_style=1; break;
    }
    printf(" %s\n", s);
    if ((!concise_switch) && (forerrors_pointer > 0) && (style <= 2))
    { forerrors_buff[forerrors_pointer] = 0;
        sprintf(forerrors_buff+68,"  ...etc");
        printf("> %s\n",forerrors_buff);
    }
}

variable_types: style int

variable_types:
s
char *


decompiled_code:
char *__fastcall deeper_babel_init(const char *a1, __int64 a2)
{
char *v2; // rax
const char *v3; // r13
__int64 v4; // rbp
const __int32_t **v5; // rcx
char *v6; // rax
__int64 (__fastcall *v7)(__int64, _QWORD, _QWORD, char *, __int64); // rax
__int64 v8; // rbp
__int64 (__fastcall *v9)(__int64, _QWORD, _QWORD, _QWORD, _QWORD); // rax
__int64 (__fastcall *v10)(__int64, _QWORD, _QWORD, char *, __int64); // rax
__int64 v11; // rbp
__int64 v12; // rbp
int v13; // er13
int v14; // eax
__int64 (__fastcall *v15)(__int64, _QWORD, _QWORD, char *, __int64); // rax
int v16; // er8
char *result; // rax
__int64 v18; // rbp
int v19; // er14
int v20; // er12
int v21; // eax
__int64 v22; // rax
int v23; // eax
__int64 (__fastcall *v24)(__int64, _QWORD, _QWORD, char *, __int64); // rax
__int64 v25; // rbp
__int64 v26; // rax
char v27[512]; // [rsp+0h] [rbp-428h] BYREF
char s2[552]; // [rsp+200h] [rbp-228h] BYREF

if ( a1 && (v2 = strrchr(a1, 46), (v3 = v2) != 0LL) )
{
v4 = *v2;
if ( (_BYTE)v4 )
{
v5 = _ctype_tolower_loc();
v6 = (char *)v3;
do
{
*v6++ = (*v5)[v4];
v4 = *v6;
}
while ( (_BYTE)v4 );
}
v7 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))container_registry;
v8 = 0LL;
if ( !container_registry )
goto LABEL_12;
while ( (int)v7(515LL, 0LL, 0LL, buffer_0, 512LL) < 0
|| !strstr(buffer_0, v3)
|| (int)(*(&container_registry + v8))(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL) < 0 )
{
++v8;
v7 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&container_registry + v8);
if ( !v7 )
goto LABEL_11;
}
v8 = (int)v8;
v22 = (__int64)*(&container_registry + (int)v8);
if ( v22 )
{
LABEL_46:
*(_QWORD *)a2 = v22;
(*(&container_registry + v8))(514LL, 0LL, 0LL, v27, 512LL);
*(_BYTE *)(a2 + 44) = 1;
v23 = (*(&container_registry + v8))(1297LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL);
*(_DWORD *)(a2 + 40) = v23;
if ( v23 <= 0 )
return 0LL;
*(_QWORD *)(a2 + 32) = my_malloc((unsigned int)v23, "contained story file");
if ( *(int *)(a2 + 40) <= 0 )
return 0LL;
if ( (int)(*(&container_registry + v8))(1808LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), s2, 512LL) < 0 )
return 0LL;
if ( (int)(*(&container_registry + v8))(
1809LL,
*(_QWORD *)(a2 + 16),
*(unsigned int *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(unsigned int *)(a2 + 40)) <= 0 )
return 0LL;
v24 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !treaty_registry )
return 0LL;
v25 = 0LL;
while ( (int)v24(514LL, 0LL, 0LL, buffer_0, 512LL) < 0
|| strcmp(buffer_0, s2)
|| (int)(*(&treaty_registry + v25))(260LL, *(_QWORD *)(a2 + 32), *(unsigned int *)(a2 + 40), 0LL, 0LL) < 0 )
{
++v25;
v24 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v25);
if ( !v24 )
return 0LL;
}
v26 = (__int64)*(&treaty_registry + (int)v25);
if ( !v26 )
return 0LL;
*(_QWORD *)(a2 + 8) = v26;
sprintf(buffer_0, "%sed %s", v27, s2);
return buffer_0;
}
LABEL_11:
v9 = container_registry;
if ( !container_registry )
{
LABEL_12:
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !treaty_registry )
return 0LL;
LABEL_13:
v11 = 0LL;
while ( (int)v10(515LL, 0LL, 0LL, buffer_0, 512LL) < 0
|| !strstr(buffer_0, v3)
|| (int)(*(&treaty_registry + v11))(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL) < 0 )
{
++v11;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v11);
if ( !v10 )
goto LABEL_18;
}
v15 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + (int)v11);
if ( !v15 )
{
LABEL_18:
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
goto LABEL_19;
}
LABEL_27:
*(_QWORD *)a2 = v15;
v16 = v15(514LL, 0LL, 0LL, buffer_0, 512LL);
result = buffer_0;
if ( v16 < 0 )
return 0LL;
return result;
}
}
else
{
v9 = container_registry;
if ( !container_registry )
{
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
LABEL_19:
if ( !v10 )
return 0LL;
v12 = 0LL;
v13 = -1;
while ( 1 )
{
v14 = v10(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL);
if ( v14 == 1 )
break;
if ( !v14 && v13 < 0 )
v13 = v12;
++v12;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v12);
if ( !v10 )
goto LABEL_66;
}
v15 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + (int)v12);
if ( v15 )
goto LABEL_27;
LABEL_66:
if ( v13 <= 0 )
return 0LL;
*(_BYTE *)(a2 + 56) = 0;
v15 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v13);
goto LABEL_27;
}
v3 = 0LL;
}
v18 = 0LL;
v19 = -1;
do
{
v20 = v18;
v21 = v9(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL);
if ( v21 == 1 )
{
v22 = (__int64)*(&container_registry + (int)v18);
if ( v19 == -1 )
goto LABEL_41;
if ( v22 )
goto LABEL_45;
LABEL_40:
v20 = v19;
*(_BYTE *)(a2 + 56) = 0;
v22 = (__int64)*(&container_registry + v19);
LABEL_41:
if ( !v22 )
{
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !v3 )
goto LABEL_19;
goto LABEL_43;
}
LABEL_45:
v8 = v20;
goto LABEL_46;
}
if ( !v21 && v19 < 0 )
v19 = v18;
++v18;
v9 = *(&container_registry + v18);
}
while ( v9 );
if ( v19 != -1 )
goto LABEL_40;
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !v3 )
goto LABEL_19;
LABEL_43:
if ( v10 )
goto LABEL_13;
return 0LL;
}

canonical_decompiled_code:
char *__fastcall func0(const char *a1, __int64 a2)
{
char *v2; // rax
const char *v3; // r13
__int64 v4; // rbp
const __int32_t **v5; // rcx
char *v6; // rax
__int64 (__fastcall *v7)(__int64, _QWORD, _QWORD, char *, __int64); // rax
__int64 v8; // rbp
__int64 (__fastcall *v9)(__int64, _QWORD, _QWORD, _QWORD, _QWORD); // rax
__int64 (__fastcall *v10)(__int64, _QWORD, _QWORD, char *, __int64); // rax
__int64 v11; // rbp
__int64 v12; // rbp
int v13; // er13
int v14; // eax
__int64 (__fastcall *v15)(__int64, _QWORD, _QWORD, char *, __int64); // rax
int v16; // er8
char *result; // rax
__int64 v18; // rbp
int v19; // er14
int v20; // er12
int v21; // eax
__int64 v22; // rax
int v23; // eax
__int64 (__fastcall *v24)(__int64, _QWORD, _QWORD, char *, __int64); // rax
__int64 v25; // rbp
__int64 v26; // rax
char v27[512]; // [rsp+0h] [rbp-428h] BYREF
char s2[552]; // [rsp+200h] [rbp-228h] BYREF

if ( a1 && (v2 = strrchr(a1, 46), (v3 = v2) != 0LL) )
{
v4 = *v2;
if ( (_BYTE)v4 )
{
v5 = _ctype_tolower_loc();
v6 = (char *)v3;
do
{
*v6++ = (*v5)[v4];
v4 = *v6;
}
while ( (_BYTE)v4 );
}
v7 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))container_registry;
v8 = 0LL;
if ( !container_registry )
goto LABEL_12;
while ( (int)v7(515LL, 0LL, 0LL, buffer_0, 512LL) < 0
|| !strstr(buffer_0, v3)
|| (int)(*(&container_registry + v8))(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL) < 0 )
{
++v8;
v7 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&container_registry + v8);
if ( !v7 )
goto LABEL_11;
}
v8 = (int)v8;
v22 = (__int64)*(&container_registry + (int)v8);
if ( v22 )
{
LABEL_46:
*(_QWORD *)a2 = v22;
(*(&container_registry + v8))(514LL, 0LL, 0LL, v27, 512LL);
*(_BYTE *)(a2 + 44) = 1;
v23 = (*(&container_registry + v8))(1297LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL);
*(_DWORD *)(a2 + 40) = v23;
if ( v23 <= 0 )
return 0LL;
*(_QWORD *)(a2 + 32) = my_malloc((unsigned int)v23, "contained story file");
if ( *(int *)(a2 + 40) <= 0 )
return 0LL;
if ( (int)(*(&container_registry + v8))(1808LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), s2, 512LL) < 0 )
return 0LL;
if ( (int)(*(&container_registry + v8))(
1809LL,
*(_QWORD *)(a2 + 16),
*(unsigned int *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(unsigned int *)(a2 + 40)) <= 0 )
return 0LL;
v24 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !treaty_registry )
return 0LL;
v25 = 0LL;
while ( (int)v24(514LL, 0LL, 0LL, buffer_0, 512LL) < 0
|| strcmp(buffer_0, s2)
|| (int)(*(&treaty_registry + v25))(260LL, *(_QWORD *)(a2 + 32), *(unsigned int *)(a2 + 40), 0LL, 0LL) < 0 )
{
++v25;
v24 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v25);
if ( !v24 )
return 0LL;
}
v26 = (__int64)*(&treaty_registry + (int)v25);
if ( !v26 )
return 0LL;
*(_QWORD *)(a2 + 8) = v26;
sprintf(buffer_0, "%sed %s", v27, s2);
return buffer_0;
}
LABEL_11:
v9 = container_registry;
if ( !container_registry )
{
LABEL_12:
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !treaty_registry )
return 0LL;
LABEL_13:
v11 = 0LL;
while ( (int)v10(515LL, 0LL, 0LL, buffer_0, 512LL) < 0
|| !strstr(buffer_0, v3)
|| (int)(*(&treaty_registry + v11))(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL) < 0 )
{
++v11;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v11);
if ( !v10 )
goto LABEL_18;
}
v15 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + (int)v11);
if ( !v15 )
{
LABEL_18:
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
goto LABEL_19;
}
LABEL_27:
*(_QWORD *)a2 = v15;
v16 = v15(514LL, 0LL, 0LL, buffer_0, 512LL);
result = buffer_0;
if ( v16 < 0 )
return 0LL;
return result;
}
}
else
{
v9 = container_registry;
if ( !container_registry )
{
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
LABEL_19:
if ( !v10 )
return 0LL;
v12 = 0LL;
v13 = -1;
while ( 1 )
{
v14 = v10(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL);
if ( v14 == 1 )
break;
if ( !v14 && v13 < 0 )
v13 = v12;
++v12;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v12);
if ( !v10 )
goto LABEL_66;
}
v15 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + (int)v12);
if ( v15 )
goto LABEL_27;
LABEL_66:
if ( v13 <= 0 )
return 0LL;
*(_BYTE *)(a2 + 56) = 0;
v15 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))*(&treaty_registry + v13);
goto LABEL_27;
}
v3 = 0LL;
}
v18 = 0LL;
v19 = -1;
do
{
v20 = v18;
v21 = v9(260LL, *(_QWORD *)(a2 + 16), *(unsigned int *)(a2 + 24), 0LL, 0LL);
if ( v21 == 1 )
{
v22 = (__int64)*(&container_registry + (int)v18);
if ( v19 == -1 )
goto LABEL_41;
if ( v22 )
goto LABEL_45;
LABEL_40:
v20 = v19;
*(_BYTE *)(a2 + 56) = 0;
v22 = (__int64)*(&container_registry + v19);
LABEL_41:
if ( !v22 )
{
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !v3 )
goto LABEL_19;
goto LABEL_43;
}
LABEL_45:
v8 = v20;
goto LABEL_46;
}
if ( !v21 && v19 < 0 )
v19 = v18;
++v18;
v9 = *(&container_registry + v18);
}
while ( v9 );
if ( v19 != -1 )
goto LABEL_40;
*(_BYTE *)(a2 + 44) = 0;
v10 = (__int64 (__fastcall *)(__int64, _QWORD, _QWORD, char *, __int64))treaty_registry;
if ( !v3 )
goto LABEL_19;
LABEL_43:
if ( v10 )
goto LABEL_13;
return 0LL;
}

original_code:
static char *deeper_babel_init(char *story_name, void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 int i;
 char *ext;
 static char buffer[512];
 int best_candidate;
 char buffert[512];
 if (story_name)
  {
   ext=strrchr(story_name,'.');
   if (ext) for(i=0;ext[i];i++) ext[i]=tolower(ext[i]);
  }
 else ext=((void *)0);
 best_candidate=-1;
 if (ext)
  for(i=0;container_registry[i];i++)
   if (container_registry[i](0x203,((void *)0),0,buffer,512) >=0 &&
       strstr(buffer,ext) &&
       container_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0)>=0)
    break;
  if (!ext || !container_registry[i])
  {
  for(i=0;container_registry[i];i++)
   {int l=container_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0);
    if (l==1)
    break;
    else if (l==0 && best_candidate < 0) best_candidate=i;
    }
}
 if (!container_registry[i] && best_candidate >=0) { bh->auth=0; i=best_candidate; }
 if (container_registry[i])
 {
   char buffer2[512];
   bh->treaty_handler=container_registry[i];
   container_registry[i](0x202,((void *)0),0,buffert,512);
   bh->blorb_mode=1;
   bh->story_file_blorbed_extent=container_registry[i](0x511,bh->story_file,bh->story_file_extent,((void *)0),0);
   if (bh->story_file_blorbed_extent>0) bh->story_file_blorbed=my_malloc(bh->story_file_blorbed_extent, "contained story file");
   if (bh->story_file_blorbed_extent<=0 ||
       container_registry[i](0x710,bh->story_file,bh->story_file_extent,buffer2,512)<0 ||
       container_registry[i](0x711,bh->story_file,bh->story_file_extent,bh->story_file_blorbed,bh->story_file_blorbed_extent)<=0
      )
    return ((void *)0);
   for(i=0;treaty_registry[i];i++)
    if (treaty_registry[i](0x202,((void *)0),0,buffer,512)>=0 &&
        strcmp(buffer,buffer2)==0 &&
        treaty_registry[i](0x104,bh->story_file_blorbed,bh->story_file_blorbed_extent,((void *)0),0)>=0)
     break;
  if (!treaty_registry[i])
   return ((void *)0);
  bh->treaty_backup=treaty_registry[i];
  sprintf(buffer,"%sed %s",buffert,buffer2);
  return buffer;
  }
 bh->blorb_mode=0;
 best_candidate=-1;
 if (ext)
  for(i=0;treaty_registry[i];i++)
   if (treaty_registry[i](0x203,((void *)0),0,buffer,512) >=0 &&
       strstr(buffer,ext) &&
       treaty_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0)>=0)
    break;
  if (!ext || !treaty_registry[i])
  {
  for(i=0;treaty_registry[i];i++)
   {int l;
   l=treaty_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0);
    if (l==1)
    break;
    else if (l==0 && best_candidate < 0) best_candidate=i;
    }
  }
  if (!treaty_registry[i])
   if (best_candidate>0) { i=best_candidate; bh->auth=0; }
   else return ((void *)0);
  bh->treaty_handler=treaty_registry[i];
  if (bh->treaty_handler(0x202,((void *)0),0,buffer,512)>=0)
  return buffer;
  return ((void *)0);
}

canonical_original_code:
static char *deeper_babel_init(char *story_name, void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 int i;
 char *ext;
 static char buffer[512];
 int best_candidate;
 char buffert[512];
 if (story_name)
  {
   ext=strrchr(story_name,'.');
   if (ext) for(i=0;ext[i];i++) ext[i]=tolower(ext[i]);
  }
 else ext=((void *)0);
 best_candidate=-1;
 if (ext)
  for(i=0;container_registry[i];i++)
   if (container_registry[i](0x203,((void *)0),0,buffer,512) >=0 &&
       strstr(buffer,ext) &&
       container_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0)>=0)
    break;
  if (!ext || !container_registry[i])
  {
  for(i=0;container_registry[i];i++)
   {int l = container_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0);
    if (l==1)
    break;
    else if (l==0 && best_candidate < 0) best_candidate=i;
    }
}
 if (!container_registry[i] && best_candidate >=0) { bh->auth=0; i=best_candidate; }
 if (container_registry[i])
 {
   char buffer2[512];
   bh->treaty_handler=container_registry[i];
   container_registry[i](0x202,((void *)0),0,buffert,512);
   bh->blorb_mode=1;
   bh->story_file_blorbed_extent=container_registry[i](0x511,bh->story_file,bh->story_file_extent,((void *)0),0);
   if (bh->story_file_blorbed_extent>0) bh->story_file_blorbed=my_malloc(bh->story_file_blorbed_extent, "contained story file");
   if (bh->story_file_blorbed_extent<=0 ||
       container_registry[i](0x710,bh->story_file,bh->story_file_extent,buffer2,512)<0 ||
       container_registry[i](0x711,bh->story_file,bh->story_file_extent,bh->story_file_blorbed,bh->story_file_blorbed_extent)<=0
      )
    return ((void *)0);
   for(i=0;treaty_registry[i];i++)
    if (treaty_registry[i](0x202,((void *)0),0,buffer,512)>=0 &&
        strcmp(buffer,buffer2)==0 &&
        treaty_registry[i](0x104,bh->story_file_blorbed,bh->story_file_blorbed_extent,((void *)0),0)>=0)
     break;
  if (!treaty_registry[i])
   return ((void *)0);
  bh->treaty_backup=treaty_registry[i];
  sprintf(buffer,"%sed %s",buffert,buffer2);
  return buffer;
  }
 bh->blorb_mode=0;
 best_candidate=-1;
 if (ext)
  for(i=0;treaty_registry[i];i++)
   if (treaty_registry[i](0x203,((void *)0),0,buffer,512) >=0 &&
       strstr(buffer,ext) &&
       treaty_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0)>=0)
    break;
  if (!ext || !treaty_registry[i])
  {
  for(i=0;treaty_registry[i];i++)
   {int l;
   l=treaty_registry[i](0x104,bh->story_file,bh->story_file_extent,((void *)0),0);
    if (l==1)
    break;
    else if (l==0 && best_candidate < 0) best_candidate=i;
    }
  }
  if (!treaty_registry[i])
   if (best_candidate>0) { i=best_candidate; bh->auth=0; }
   else return ((void *)0);
  bh->treaty_handler=treaty_registry[i];
  if (bh->treaty_handler(0x202,((void *)0),0,buffer,512)>=0)
  return buffer;
  return ((void *)0);
}

variable_types:
bhp
void *

variable_types: struct babel_handler { int (*treaty_handler)(int selector, void *, int, void *, int); int (*treaty_backup)(int selector, void *, int, void *, int); void *story_file; int story_file_extent; void *story_file_blorbed; int story_file_blorbed_extent; char blorb_mode; char *format_name; char auth; } *

variable_types: i int

variable_types:
ext
char *

variable_types:
buffer
char [512]

variable_types:
buffert
char [512]

variable_types: l int

return_type: char *


decompiled_code:
char *__fastcall babel_init_ctx(const char *a1, __int64 a2)
{
char *v2; // rax
char *v3; // r12

v2 = deep_babel_init(a1, a2);
v3 = v2;
if ( v2 )
*(_QWORD *)(a2 + 48) = strdup(v2);
return v3;
}

canonical_decompiled_code:
char *__fastcall func2(const char *a1, __int64 a2)
{
char *v2; // rax
char *v3; // r12

v2 = func1(a1, a2);
v3 = v2;
if ( v2 )
*(_QWORD *)(a2 + 48) = strdup(v2);
return v3;
}

original_code:
char *babel_init_ctx(char *sf, void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 char *b;
 b=deep_babel_init(sf,bh);
 if (b) bh->format_name=strdup(b);
 return b;
}

canonical_original_code:
char *babel_init_ctx(char *sf, void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 char *b;
 b=deep_babel_init(sf,bh);
 if (b) bh->format_name=strdup(b);
 return b;
}

variable_types:
sf
char *

variable_types:
b
char *

user_defined_types: struct babel_handler { int (*treaty_handler)(int selector, void *, int, void *, int); int (*treaty_backup)(int selector, void *, int, void *, int); void *story_file; int story_file_extent; void *story_file_blorbed; int story_file_blorbed_extent; char blorb_mode; char *format_name; char auth; }


decompiled_code:
char *__fastcall babel_init(const char *a1)
{
return babel_init_ctx(a1, (__int64)&default_ctx);
}

canonical_decompiled_code:
char *__fastcall func3(const char *a1)
{
return func2(a1, (__int64)&default_ctx);
}

original_code:
char *babel_init(char *sf)
{
  return babel_init_ctx(sf, &default_ctx);
}


decompiled_code:
char *__fastcall babel_init_raw_ctx(void *src, unsigned int a2, __int64 a3)
{
void *v4; // rax
char *v5; // rax
char *v6; // r12

*(_DWORD *)(a3 + 24) = a2;
*(_QWORD *)a3 = 0LL;
*(_QWORD *)(a3 + 8) = 0LL;
*(_QWORD *)(a3 + 16) = 0LL;
*(_QWORD *)(a3 + 32) = 0LL;
*(_DWORD *)(a3 + 40) = 0;
*(_QWORD *)(a3 + 48) = 0LL;
*(_BYTE *)(a3 + 56) = 1;
v4 = (void *)my_malloc(a2, "story file storage");
*(_QWORD *)(a3 + 16) = v4;
memcpy(v4, src, (int)a2);
v5 = deeper_babel_init(0LL, a3);
v6 = v5;
if ( v5 )
*(_QWORD *)(a3 + 48) = strdup(v5);
return v6;
}

original_code:
char *babel_init_raw_ctx(void *sf, int32 extent, void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 char *b;
 bh->treaty_handler=((void *)0);
 bh->treaty_backup=((void *)0);
 bh->story_file=((void *)0);
 bh->story_file_extent=0;
 bh->story_file_blorbed=((void *)0);
 bh->story_file_blorbed_extent=0;
 bh->format_name=((void *)0);
 bh->story_file_extent=extent;
 bh->auth=1;
 bh->story_file=my_malloc(bh->story_file_extent,"story file storage");
 memcpy(bh->story_file,sf,extent);
 b=deeper_babel_init(((void *)0), bhp);
 if (b) bh->format_name=strdup(b);
 return b;
}

canonical_original_code:
char *babel_init_raw_ctx(void *sf, int extent, void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 char *b;
 bh->treaty_handler=((void *)0);
 bh->treaty_backup=((void *)0);
 bh->story_file=((void *)0);
 bh->story_file_extent=0;
 bh->story_file_blorbed=((void *)0);
 bh->story_file_blorbed_extent=0;
 bh->format_name=((void *)0);
 bh->story_file_extent=extent;
 bh->auth=1;
 bh->story_file=my_malloc(bh->story_file_extent,"story file storage");
 memcpy(bh->story_file,sf,extent);
 b=deeper_babel_init(((void *)0), bhp);
 if (b) bh->format_name=strdup(b);
 return b;
}

variable_types:
sf
void *

variable_types: extent int


decompiled_code:
char *__fastcall babel_init_raw(void *a1, unsigned int a2)
{
return babel_init_raw_ctx(a1, a2, (__int64)&default_ctx);
}

canonical_decompiled_code:
char *__fastcall func5(void *a1, unsigned int a2)
{
return func4(a1, a2, (__int64)&default_ctx);
}

original_code:
char *babel_init_raw(void *sf, int32 extent)
{
  return babel_init_raw_ctx(sf, extent, &default_ctx);
}

canonical_original_code:
char *babel_init_raw(void *sf, int extent)
{
  return babel_init_raw_ctx(sf, extent, &default_ctx);
}


decompiled_code:
void __fastcall babel_release_ctx(_QWORD *a1)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

v2 = (void *)a1[2];
if ( v2 )
free(v2);
v3 = (void *)a1[4];
a1[2] = 0LL;
if ( v3 )
free(v3);
v4 = (void *)a1[6];
a1[4] = 0LL;
if ( v4 )
free(v4);
a1[6] = 0LL;
}

canonical_decompiled_code:
void __fastcall func6(_QWORD *a1)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

v2 = (void *)a1[2];
if ( v2 )
free(v2);
v3 = (void *)a1[4];
a1[2] = 0LL;
if ( v3 )
free(v3);
v4 = (void *)a1[6];
a1[4] = 0LL;
if ( v4 )
free(v4);
a1[6] = 0LL;
}

original_code:
void babel_release_ctx(void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 if (bh->story_file) free(bh->story_file);
 bh->story_file=((void *)0);
 if (bh->story_file_blorbed) free(bh->story_file_blorbed);
 bh->story_file_blorbed=((void *)0);
 if (bh->format_name) free(bh->format_name);
 bh->format_name=((void *)0);
}

canonical_original_code:
void babel_release_ctx(void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 if (bh->story_file) free(bh->story_file);
 bh->story_file=((void *)0);
 if (bh->story_file_blorbed) free(bh->story_file_blorbed);
 bh->story_file_blorbed=((void *)0);
 if (bh->format_name) free(bh->format_name);
 bh->format_name=((void *)0);
}


decompiled_code:
void babel_release()
{
babel_release_ctx(default_ctx);
}

canonical_decompiled_code:
void func7()
{
func6(default_ctx);
}

original_code:
void babel_release()
{
 babel_release_ctx(&default_ctx);
}


original_code:
int32 babel_md5_ifid_ctx(char *buffer, int32 extent, void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 md5_state_t md5;
 int i;
 unsigned char ob[16];
 if (extent <33 || bh->story_file==((void *)0))
  return 0;
 md5_init(&md5);
 md5_append(&md5,bh->story_file,bh->story_file_extent);
 md5_finish(&md5,ob);
 for(i=0;i<16;i++)
  sprintf(buffer+(2*i),"%02X",ob[i]);
 buffer[32]=0;
 return 1;
}

canonical_original_code:
int babel_md5_ifid_ctx(char *buffer, int extent, void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 struct md5_state_s md5;
 int i;
 unsigned char ob[16];
 if (extent <33 || bh->story_file==((void *)0))
  return 0;
 md5_init(&md5);
 md5_append(&md5,bh->story_file,bh->story_file_extent);
 md5_finish(&md5,ob);
 for(i=0;i<16;i++)
  sprintf(buffer+(2*i),"%02X",ob[i]);
 buffer[32]=0;
 return 1;
}

variable_types:
buffer
char *

variable_types: struct md5_state_s { unsigned int count[2]; unsigned int abcd[4]; unsigned char buf[64]; }

variable_types:
ob
unsigned char [16]

return_type: int


decompiled_code:
__int64 __fastcall babel_md5_ifid(char *a1, int a2)
{
return babel_md5_ifid_ctx(a1, a2, (__int64)default_ctx);
}

canonical_decompiled_code:
__int64 __fastcall func9(char *a1, int a2)
{
return func8(a1, a2, (__int64)default_ctx);
}

original_code:
int32 babel_md5_ifid(char *buffer, int32 extent)
{
 return babel_md5_ifid_ctx(buffer, extent,
                &default_ctx);
}

canonical_original_code:
int babel_md5_ifid(char *buffer, int extent)
{
 return babel_md5_ifid_ctx(buffer, extent,
                &default_ctx);
}


decompiled_code:
__int64 __fastcall babel_treaty_ctx(unsigned int a1, char *a2, unsigned int a3, __int64 a4)
{
__int64 result; // rax
bool v7; // cl
size_t v8; // rax

if ( (a1 & 0x100) == 0 && *(_BYTE *)(a4 + 44) )
goto LABEL_3;
result = (*(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, char *, _QWORD))a4)(
a1,
*(_QWORD *)(a4 + 16),
*(unsigned int *)(a4 + 24),
a2,
a3);
if ( (((_DWORD)result + 2) & 0xFFFFFFFD) != 0 )
{
v7 = a1 == 776;
goto LABEL_9;
}
if ( *(_BYTE *)(a4 + 44) )
LABEL_3:
result = (*(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, char *, _QWORD))(a4 + 8))(
a1,
*(_QWORD *)(a4 + 32),
*(unsigned int *)(a4 + 40),
a2,
a3);
v7 = a1 == 776;
if ( !(_DWORD)result && a1 == 776 )
return babel_md5_ifid_ctx(a2, a3, a4);
LABEL_9:
if ( (_DWORD)result == -4 && v7 )
{
v8 = strlen(a2);
result = babel_md5_ifid_ctx(&a2[v8], a3 - (unsigned int)v8, a4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, char *a2, unsigned int a3, __int64 a4)
{
__int64 result; // rax
bool v7; // cl
size_t v8; // rax

if ( (a1 & 0x100) == 0 && *(_BYTE *)(a4 + 44) )
goto LABEL_3;
result = (*(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, char *, _QWORD))a4)(
a1,
*(_QWORD *)(a4 + 16),
*(unsigned int *)(a4 + 24),
a2,
a3);
if ( (((_DWORD)result + 2) & 0xFFFFFFFD) != 0 )
{
v7 = a1 == 776;
goto LABEL_9;
}
if ( *(_BYTE *)(a4 + 44) )
LABEL_3:
result = (*(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, char *, _QWORD))(a4 + 8))(
a1,
*(_QWORD *)(a4 + 32),
*(unsigned int *)(a4 + 40),
a2,
a3);
v7 = a1 == 776;
if ( !(_DWORD)result && a1 == 776 )
return func8(a2, a3, a4);
LABEL_9:
if ( (_DWORD)result == -4 && v7 )
{
v8 = strlen(a2);
result = func8(&a2[v8], a3 - (unsigned int)v8, a4);
}
return result;
}

original_code:
int32 babel_treaty_ctx(int32 sel, void *output, int32 output_extent,void *bhp)
{
 int32 rv;
 struct babel_handler *bh=(struct babel_handler *) bhp;
 if (!(sel & 0x100) && bh->blorb_mode)
  rv=bh->treaty_backup(sel,bh->story_file_blorbed,bh->story_file_blorbed_extent,output, output_extent);
 else
 {
  rv=bh->treaty_handler(sel,bh->story_file,bh->story_file_extent,output,output_extent);
  if ((!rv|| rv==-2) && bh->blorb_mode)
   rv=bh->treaty_backup(sel,bh->story_file_blorbed,bh->story_file_blorbed_extent,output, output_extent);
  }
 if (!rv && sel==0x308)
  return babel_md5_ifid_ctx(output,output_extent, bh);
 if (rv==-4 && sel==0x308)
  return babel_md5_ifid_ctx((void *)((char *) output+strlen((char *)output)),
                            output_extent-strlen((char *)output),
                            bh);
 return rv;
}

canonical_original_code:
int babel_treaty_ctx(int sel, void *output, int output_extent, void *bhp)
{
 int rv;
 struct babel_handler *bh = (struct babel_handler *) bhp;
 if (!(sel & 0x100) && bh->blorb_mode)
  rv=bh->treaty_backup(sel,bh->story_file_blorbed,bh->story_file_blorbed_extent,output, output_extent);
 else
 {
  rv=bh->treaty_handler(sel,bh->story_file,bh->story_file_extent,output,output_extent);
  if ((!rv|| rv==-2) && bh->blorb_mode)
   rv=bh->treaty_backup(sel,bh->story_file_blorbed,bh->story_file_blorbed_extent,output, output_extent);
  }
 if (!rv && sel==0x308)
  return babel_md5_ifid_ctx(output,output_extent, bh);
 if (rv==-4 && sel==0x308)
  return babel_md5_ifid_ctx((void *)((char *) output+strlen((char *)output)),
                            output_extent-strlen((char *)output),
                            bh);
 return rv;
}

variable_types: sel int

variable_types:
output
void *

variable_types: rv int


decompiled_code:
__int64 __fastcall babel_treaty(unsigned int a1, char *a2, unsigned int a3)
{
return babel_treaty_ctx(a1, a2, a3, (__int64)default_ctx);
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1, char *a2, unsigned int a3)
{
return func10(a1, a2, a3, (__int64)default_ctx);
}

original_code:
int32 babel_treaty(int32 sel, void *output, int32 output_extent)
{
 return babel_treaty_ctx(sel, output, output_extent, &default_ctx);
}

canonical_original_code:
int babel_treaty(int sel, void *output, int output_extent)
{
 return babel_treaty_ctx(sel, output, output_extent, &default_ctx);
}


decompiled_code:
__int64 __fastcall babel_get_format_ctx(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

original_code:
char *babel_get_format_ctx(void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 return bh->format_name;
}

canonical_original_code:
char *babel_get_format_ctx(void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 return bh->format_name;
}

variable_types:
bhp
void *


decompiled_code:
__int64 babel_get_format()
{
return babel_get_format_ctx((__int64)default_ctx);
}

canonical_decompiled_code:
__int64 func13()
{
return func12((__int64)default_ctx);
}

original_code:
char *babel_get_format()
{
 return babel_get_format_ctx(&default_ctx);
}


decompiled_code:
__int64 get_babel_ctx()
{
return my_malloc(64LL, "babel handler context");
}

canonical_decompiled_code:
__int64 func14()
{
return my_malloc(64LL, "babel handler context");
}

original_code:
void *get_babel_ctx()
{
 return my_malloc(sizeof(struct babel_handler), "babel handler context");
}

return_type: void *


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

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

original_code:
void release_babel_ctx(void *b)
{
 free(b);
}

variable_types:
b
void *


decompiled_code:
__int64 __fastcall babel_get_length_ctx(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

original_code:
int32 babel_get_length_ctx(void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 return bh->story_file_extent;
}

canonical_original_code:
int babel_get_length_ctx(void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 return bh->story_file_extent;
}

variable_types: struct babel_handler { int (*treaty_handler)(int selector, void *, int, void *, int); int (*treaty_backup)(int selector, void *, int, void *, int); void *story_file; int story_file_extent; void *story_file_blorbed; int story_file_blorbed_extent; char blorb_mode; char *format_name; char auth; } *


decompiled_code:
__int64 babel_get_length()
{
return babel_get_length_ctx((__int64)default_ctx);
}

canonical_decompiled_code:
__int64 func17()
{
return func16((__int64)default_ctx);
}

original_code:
int32 babel_get_length()
{
 return babel_get_length_ctx(&default_ctx);
}

canonical_original_code:
int babel_get_length()
{
 return babel_get_length_ctx(&default_ctx);
}


decompiled_code:
__int64 __fastcall babel_get_authoritative_ctx(__int64 a1)
{
return (unsigned int)*(char *)(a1 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return (unsigned int)*(char *)(a1 + 56);
}

original_code:
int32 babel_get_authoritative_ctx(void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 return bh->auth;
}

canonical_original_code:
int babel_get_authoritative_ctx(void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 return bh->auth;
}


decompiled_code:
__int64 babel_get_authoritative()
{
return babel_get_authoritative_ctx((__int64)default_ctx);
}

canonical_decompiled_code:
__int64 func19()
{
return func18((__int64)default_ctx);
}

original_code:
int32 babel_get_authoritative()
{
  return babel_get_authoritative_ctx(&default_ctx);
}

canonical_original_code:
int babel_get_authoritative()
{
  return babel_get_authoritative_ctx(&default_ctx);
}


decompiled_code:
__int64 __fastcall babel_get_file_ctx(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
void *babel_get_file_ctx(void *bhp)
{
 struct babel_handler *bh=(struct babel_handler *) bhp;
 return bh->story_file;
}

canonical_original_code:
void *babel_get_file_ctx(void *bhp)
{
 struct babel_handler *bh = (struct babel_handler *) bhp;
 return bh->story_file;
}


decompiled_code:
__int64 babel_get_file()
{
return babel_get_file_ctx((__int64)default_ctx);
}

canonical_decompiled_code:
__int64 func21()
{
return func20((__int64)default_ctx);
}

original_code:
void *babel_get_file()
{
 return babel_get_file_ctx(&default_ctx);
}


decompiled_code:
__int64 __fastcall babel_get_story_length_ctx(__int64 a1)
{
__int64 result; // rax

if ( *(_BYTE *)(a1 + 44) )
result = *(unsigned int *)(a1 + 40);
else
result = *(unsigned int *)(a1 + 24);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
__int64 result; // rax

if ( *(_BYTE *)(a1 + 44) )
result = *(unsigned int *)(a1 + 40);
else
result = *(unsigned int *)(a1 + 24);
return result;
}

original_code:
int32 babel_get_story_length_ctx(void *ctx)
{
  struct babel_handler *bh=(struct babel_handler *) ctx;
  if (bh->blorb_mode) return bh->story_file_blorbed_extent;
  return bh->story_file_extent;
}

canonical_original_code:
int babel_get_story_length_ctx(void *ctx)
{
  struct babel_handler *bh = (struct babel_handler *) ctx;
  if (bh->blorb_mode) return bh->story_file_blorbed_extent;
  return bh->story_file_extent;
}

variable_types:
ctx
void *


decompiled_code:
__int64 babel_get_story_length()
{
return babel_get_story_length_ctx((__int64)default_ctx);
}

canonical_decompiled_code:
__int64 func23()
{
return func22((__int64)default_ctx);
}

original_code:
int32 babel_get_story_length()
{
 return babel_get_story_length_ctx(&default_ctx);
}

canonical_original_code:
int babel_get_story_length()
{
 return babel_get_story_length_ctx(&default_ctx);
}


decompiled_code:
__int64 __fastcall babel_get_story_file_ctx(__int64 a1)
{
__int64 result; // rax

if ( *(_BYTE *)(a1 + 44) )
result = *(_QWORD *)(a1 + 32);
else
result = *(_QWORD *)(a1 + 16);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1)
{
__int64 result; // rax

if ( *(_BYTE *)(a1 + 44) )
result = *(_QWORD *)(a1 + 32);
else
result = *(_QWORD *)(a1 + 16);
return result;
}

original_code:
void *babel_get_story_file_ctx(void *ctx)
{
  struct babel_handler *bh=(struct babel_handler *) ctx;
  if (bh->blorb_mode) return bh->story_file_blorbed;
  return bh->story_file;
}

canonical_original_code:
void *babel_get_story_file_ctx(void *ctx)
{
  struct babel_handler *bh = (struct babel_handler *) ctx;
  if (bh->blorb_mode) return bh->story_file_blorbed;
  return bh->story_file;
}


decompiled_code:
__int64 babel_get_story_file()
{
return babel_get_story_file_ctx((__int64)default_ctx);
}

canonical_decompiled_code:
__int64 func25()
{
return func24((__int64)default_ctx);
}

original_code:
void *babel_get_story_file()
{
 return babel_get_story_file_ctx(&default_ctx);
}


decompiled_code:
__int64 __fastcall read_alan_int(unsigned int *a1)
{
return _byteswap_ulong(*a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1)
{
return _byteswap_ulong(*a1);
}

original_code:
static int32 read_alan_int(unsigned char *from)
{
 return ((unsigned long int) from[3])| ((unsigned long int)from[2] << 8) |
       ((unsigned long int) from[1]<<16)| ((unsigned long int)from[0] << 24);
}

canonical_original_code:
static int read_alan_int(unsigned char *from)
{
 return ((unsigned long) from[3])| ((unsigned long)from[2] << 8) |
       ((unsigned long) from[1]<<16)| ((unsigned long)from[0] << 24);
}

variable_types:
from
unsigned char *


original_code:
int32 alan_treaty(int32 selector,
                   void *story_file, int32 extent,
                   void *output, int32 output_extent)
{
 int32 ll, csf;
 if ((0x100 & selector) &&
     (csf=claim_story_file(story_file, extent))<0)
         return -1;
 if ((0x200 & selector) &&
     (output_extent ==0 ||
     output==((void *)0)))
        return -3;
 switch(selector)
 {
  case 0x201:
                do { if (output_extent < ((signed) strlen("http://www.alanif.se/")+1)) return -3; } while (0);
                strcpy((char *) output,"http://www.alanif.se/");
                return 0;
  case 0x202:
                do { if (output_extent < (512)) return -3; } while (0);
                strncpy((char *) output,"alan",output_extent-1);
                return 0;
  case 0x203:
                ll=(strlen(".acd")+1) < 512 ? (strlen(".acd")+1):512;
                do { if (output_extent < (ll)) return -3; } while (0);
                strncpy((char *) output, ".acd", output_extent);
                return 0;
  case 0x104:
                return csf;
  case 0x105:
  case 0x309:
                return 0;
  case 0x106:
  case 0x107:
  case 0x30A:
                return 0;
  case 0x308:
                return get_story_file_IFID(story_file, extent, (char *)output, output_extent);
  case 0x30B:
                return get_story_file_extension(story_file, extent, (char *)output, output_extent);
 }
 return -2;
}

canonical_original_code:
int alan_treaty(int selector, void *story_file, int extent, void *output, int output_extent)
{
 int ll; int csf;
 if ((0x100 & selector) &&
     (csf=claim_story_file(story_file, extent))<0)
         return -1;
 if ((0x200 & selector) &&
     (output_extent ==0 ||
     output==((void *)0)))
        return -3;
 switch(selector)
 {
  case 0x201:
                do { if (output_extent < ((int) strlen("http://www.alanif.se/")+1)) return -3; } while (0);
                strcpy((char *) output,"http://www.alanif.se/");
                return 0;
  case 0x202:
                do { if (output_extent < (512)) return -3; } while (0);
                strncpy((char *) output,"alan",output_extent-1);
                return 0;
  case 0x203:
                ll=(strlen(".acd")+1) < 512 ? (strlen(".acd")+1):512;
                do { if (output_extent < (ll)) return -3; } while (0);
                strncpy((char *) output, ".acd", output_extent);
                return 0;
  case 0x104:
                return csf;
  case 0x105:
  case 0x309:
                return 0;
  case 0x106:
  case 0x107:
  case 0x30A:
                return 0;
  case 0x308:
                return get_story_file_IFID(story_file, extent, (char *)output, output_extent);
  case 0x30B:
                return get_story_file_extension(story_file, extent, (char *)output, output_extent);
 }
 return -2;
}

variable_types: selector int

variable_types: ll int

variable_types: csf int


decompiled_code:
__int64 __fastcall claim_story_file(_DWORD *a1, int a2)
{
unsigned int v2; // er8
int v3; // esi
__int64 v4; // rcx
unsigned int *v5; // rdx
__int64 v6; // rdx
__int64 v7; // rcx
unsigned int *v8; // r8
int v9; // er9
int v10; // er9
unsigned __int8 *v11; // rax
int v12; // edx
int v13; // esi
int v14; // eax
int v15; // edx
int v16; // er8

v2 = -1;
if ( a2 > 159 )
{
v3 = a2 >> 2;
if ( *a1 != 1312902209 && (int)read_alan_int(a1 + 1) <= v3 )
{
v5 = (unsigned int *)(v4 + 24);
do
{
if ( (int)read_alan_int(v5) > v3 )
return (unsigned int)-1;
v5 = (unsigned int *)(v6 + 4);
}
while ( v5 != v8 );
v10 = 4 * v9;
if ( v10 > 160 )
{
v11 = (unsigned __int8 *)(v7 + 160);
v12 = 0;
do
{
v13 = *v11++;
v12 += v13;
}
while ( (unsigned __int8 *)(v7 + (unsigned int)(v10 - 161) + 161) != v11 );
}
v14 = read_alan_int((unsigned int *)(v7 + 152));
LOBYTE(v16) = v14 == v15;
v2 = 2 * v16 - 1;
}
}
return v2;
}

original_code:
static int32 claim_story_file(void *story_file, int32 extent)
{
 unsigned char *sf = (unsigned char *) story_file;
 int32 bf, i, crc=0;
 if (extent < 160) return -1;
 if (memcmp(sf,"ALAN",4))
 {
 bf=read_alan_int(sf+4);
 if (bf > extent/4) return -1;
 for (i=24;i<81;i+=4)
 if (read_alan_int(sf+i) > extent/4) return -1;
 for (i=160;i<(bf*4);i++)
 crc+=sf[i];
 if (crc!=read_alan_int(sf+152)) return -1;
 return 1;
 }
 else
 {
   bf=read_alan_int(sf+12);
   if (bf > (extent/4)) return -1;
   for (i=184;i<(bf*4);i++)
    crc+=sf[i];
 if (crc!=read_alan_int(sf+176)) return -1;
 }
 return -1;
}

canonical_original_code:
static int claim_story_file(void *story_file, int extent)
{
 unsigned char *sf = (unsigned char *) story_file;
 int bf; int i; int crc = 0;
 if (extent < 160) return -1;
 if (memcmp(sf,"ALAN",4))
 {
 bf=read_alan_int(sf+4);
 if (bf > extent/4) return -1;
 for (i=24;i<81;i+=4)
 if (read_alan_int(sf+i) > extent/4) return -1;
 for (i=160;i<(bf*4);i++)
 crc+=sf[i];
 if (crc!=read_alan_int(sf+152)) return -1;
 return 1;
 }
 else
 {
   bf=read_alan_int(sf+12);
   if (bf > (extent/4)) return -1;
   for (i=184;i<(bf*4);i++)
    crc+=sf[i];
 if (crc!=read_alan_int(sf+176)) return -1;
 }
 return -1;
}

variable_types:
sf
unsigned char *

variable_types: bf int

variable_types: i int

variable_types: crc int


decompiled_code:
size_t __fastcall get_story_file_extension(__int64 a1, int a2, const char *a3, int a4)
{
char v5; // dl
int v7; // ecx
__int64 v8; // rax
unsigned int i; // eax
__int64 v10; // rdx

if ( !a1 || !a2 )
return 0xFFFFFFFFLL;
v5 = 97;
v7 = 1;
v8 = 2LL;
do
{
if ( v5 == 44 )
break;
v5 = byte_309[v8];
v7 = v8++;
}
while ( v5 );
if ( a4 <= v7 )
return 4294967293LL;
if ( v7 )
{
for ( i = 0; i < v7; ++i )
{
v10 = i;
a3[v10] = byte_309[v10];
}
}
a3[v7] = 0;
return strlen(a3);
}

canonical_decompiled_code:
size_t __fastcall func2(__int64 a1, int a2, const char *a3, int a4)
{
char v5; // dl
int v7; // ecx
__int64 v8; // rax
unsigned int i; // eax
__int64 v10; // rdx

if ( !a1 || !a2 )
return 0xFFFFFFFFLL;
v5 = 97;
v7 = 1;
v8 = 2LL;
do
{
if ( v5 == 44 )
break;
v5 = byte_309[v8];
v7 = v8++;
}
while ( v5 );
if ( a4 <= v7 )
return 4294967293LL;
if ( v7 )
{
for ( i = 0; i < v7; ++i )
{
v10 = i;
a3[v10] = byte_309[v10];
}
}
a3[v7] = 0;
return strlen(a3);
}

original_code:
static int32 get_story_file_extension(void *sf, int32 extent, char *out, int32 output_extent)
{
 int i;
 if (!sf || !extent) return -1;
 for(i=0;".acd"[i] && ".acd"[i]!=',';i++);
 do { if (output_extent < (i+1)) return -3; } while (0);
 memcpy(out,".acd",i);
 out[i]=0;
 return strlen(out);
}

canonical_original_code:
static int get_story_file_extension(void *sf, int extent, char *out, int output_extent)
{
 int i;
 if (!sf || !extent) return -1;
 for(i=0;".acd"[i] && ".acd"[i]!=',';i++);
 do { if (output_extent < (i+1)) return -3; } while (0);
 memcpy(out,".acd",i);
 out[i]=0;
 return strlen(out);
}

variable_types:
sf
void *

variable_types: extent int

variable_types:
out
char *


decompiled_code:
__int64 __fastcall DL_ISO8583_DEFS_1987_GetHandler(__int64 a1)
{
return DL_ISO8583_COMMON_SetHandler(&iso8583_1987_fields, 129LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return DL_ISO8583_COMMON_SetHandler(&iso8583_1987_fields, 129LL, a1);
}

original_code:
void DL_ISO8583_DEFS_1987_GetHandler ( DL_ISO8583_HANDLER *oHandler )
{
 DL_ISO8583_COMMON_SetHandler(
  _iso8583_1987_fields,
  (DL_UINT8)(sizeof(_iso8583_1987_fields)/sizeof(DL_ISO8583_FIELD_DEF)),
  oHandler);
 return;
}

canonical_original_code:
void DL_ISO8583_DEFS_1987_GetHandler(struct DL_ISO8583_HANDLER_S *oHandler)
{
 DL_ISO8583_COMMON_SetHandler(
  _iso8583_1987_fields,
  (DL_UINT8)(sizeof(_iso8583_1987_fields)/sizeof(DL_ISO8583_FIELD_DEF)),
  oHandler);
 return;
}

variable_types: struct DL_ISO8583_HANDLER_S { struct DL_ISO8583_FIELD_DEF_S { unsigned char fieldType; unsigned int len; unsigned char varLen; } *fieldArr; unsigned char fieldItems; } *

user_defined_types: struct DL_ISO8583_HANDLER_S { struct DL_ISO8583_FIELD_DEF_S *fieldArr; unsigned char fieldItems; }


repo: sabotage-linux/gettext-tiny

original_code:
static inline enum po_error poparser_clean(struct po_parser *p, po_message_t msg) {
 if (p->strcnt) {
  if (p->first) p->first = 0;
  msg->strlen[p->strcnt] = 0;
  switch (msg->sysdep) {
  case (1 << st_priu32):
  case (1 << st_priu64):
   msg->sysdep = 2;
   break;
  case (1 << st_priu32)|(1 << st_priu64):
   msg->sysdep = 3;
   break;
  default:
   msg->sysdep = 1;
   break;
  }
  if (p->cb)
   p->cb(msg, p->cbdata);
  msg->sysdep = 0;
  msg->ctxt_len = 0;
  msg->id_len = 0;
  msg->plural_len = 0;
  msg->flags = 0;
  p->strcnt = 0;
 }
 return po_success;
}

canonical_original_code:
static inline enum po_error poparser_clean(struct po_parser *p, struct po_message *msg) {
 if (p->strcnt) {
  if (p->first) p->first = 0;
  msg->strlen[p->strcnt] = 0;
  switch (msg->sysdep) {
  case (1 << st_priu32):
  case (1 << st_priu64):
   msg->sysdep = 2;
   break;
  case (1 << st_priu32)|(1 << st_priu64):
   msg->sysdep = 3;
   break;
  default:
   msg->sysdep = 1;
   break;
  }
  if (p->cb)
   p->cb(msg, p->cbdata);
  msg->sysdep = 0;
  msg->ctxt_len = 0;
  msg->id_len = 0;
  msg->plural_len = 0;
  msg->flags = 0;
  p->strcnt = 0;
 }
 return po_success;
}

variable_types: struct po_parser { struct po_header { char charset[12]; unsigned int nplurals; } hdr; struct po_message { char *ctxt; char *id; char *plural; char *str[6]; int sysdep; unsigned long ctxt_len; unsigned long id_len; unsigned long plural_len; unsigned long strlen[6]; int flags; } msg; enum po_stage { ps_size=0, ps_parse=1, ps_max=expr } stage; _Bool first; _Bool strict; void *cd; enum po_entry { po_ctxt=0, po_id=1, po_plural=2, po_str=3 } previous; unsigned int strcnt; unsigned long max_ctxt_len; unsigned long max_id_len; unsigned long max_plural_len; unsigned long max_strlen[6]; char *buf; unsigned long bufsize; int (*cb)(struct po_message *msg, void *user); void *cbdata; } *

variable_types:
msg
struct po_message *

return_type: enum po_error { po_success=0, po_unsupported_charset=1, po_failed_iconv=2, po_excepted_token=3, po_plurals_overflow=4, po_invalid_entry=5, po_internal=6, po_error_last=expr }

user_defined_types: struct po_parser { struct po_header hdr; struct po_message msg; enum po_stage stage; _Bool first; _Bool strict; void *cd; enum po_entry previous; unsigned int strcnt; unsigned long max_ctxt_len; unsigned long max_id_len; unsigned long max_plural_len; unsigned long max_strlen[6]; char *buf; unsigned long bufsize; int (*cb)(struct po_message *msg, void *user); void *cbdata; }


decompiled_code:
__int64 __fastcall poparser_feed_hdr(char *fromcode, char *haystack)
{
char *v2; // rax
char *v3; // r13
__int64 v4; // rbx
const unsigned __int16 *v5; // rdx
char *v6; // rax
signed __int64 v7; // rbx
iconv_t v8; // rax
char *v9; // rax
bool v11; // zf

if ( !fromcode[180] )
return 0LL;
if ( !haystack )
return 0LL;
v2 = strstr(haystack, "charset=");
v3 = v2;
if ( v2 )
{
v4 = *v2;
if ( (_BYTE)v4 == 92 || !(_BYTE)v4 )
return 0xFFFFFFFFLL;
v5 = *_ctype_b_loc();
v6 = v3;
do
{
if ( (v5[v4] & 0x2000) != 0 )
break;
v4 = *++v6;
if ( !(_BYTE)v4 )
break;
}
while ( (_BYTE)v4 != 92 );
v7 = v6 - v3;
if ( (unsigned __int64)(v6 - v3 - 7) > 0xC )
return 0xFFFFFFFFLL;
memcpy(fromcode, v3 + 8, v7 - 8);
fromcode[v7 - 8] = 0;
v8 = iconv_open("UTF-8", fromcode);
if ( v8 != (iconv_t)-1LL )
{
*((_QWORD *)fromcode + 23) = v8;
goto LABEL_13;
}
v11 = fromcode[181] == 0;
*((_QWORD *)fromcode + 23) = 0LL;
if ( !v11 )
return 0xFFFFFFFFLL;
}
LABEL_13:
v9 = strstr(haystack, "nplurals=");
if ( v9 )
*((_DWORD *)fromcode + 3) = v9[9] - 48;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *fromcode, char *haystack)
{
char *v2; // rax
char *v3; // r13
__int64 v4; // rbx
const unsigned __int16 *v5; // rdx
char *v6; // rax
signed __int64 v7; // rbx
iconv_t v8; // rax
char *v9; // rax
bool v11; // zf

if ( !fromcode[180] )
return 0LL;
if ( !haystack )
return 0LL;
v2 = strstr(haystack, "charset=");
v3 = v2;
if ( v2 )
{
v4 = *v2;
if ( (_BYTE)v4 == 92 || !(_BYTE)v4 )
return 0xFFFFFFFFLL;
v5 = *_ctype_b_loc();
v6 = v3;
do
{
if ( (v5[v4] & 0x2000) != 0 )
break;
v4 = *++v6;
if ( !(_BYTE)v4 )
break;
}
while ( (_BYTE)v4 != 92 );
v7 = v6 - v3;
if ( (unsigned __int64)(v6 - v3 - 7) > 0xC )
return 0xFFFFFFFFLL;
memcpy(fromcode, v3 + 8, v7 - 8);
fromcode[v7 - 8] = 0;
v8 = iconv_open("UTF-8", fromcode);
if ( v8 != (iconv_t)-1LL )
{
*((_QWORD *)fromcode + 23) = v8;
goto LABEL_13;
}
v11 = fromcode[181] == 0;
*((_QWORD *)fromcode + 23) = 0LL;
if ( !v11 )
return 0xFFFFFFFFLL;
}
LABEL_13:
v9 = strstr(haystack, "nplurals=");
if ( v9 )
*((_DWORD *)fromcode + 3) = v9[9] - 48;
return 0LL;
}

original_code:
static inline enum po_error poparser_feed_hdr(struct po_parser *p, char* msg) {
 char *x, *y;
 if (p->first && msg) {
  if ((x = strstr(msg, "charset="))) {
   for (y = x; *y && *y != '\\' && !((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short int) _ISspace); y++);
   if ((uintptr_t)(y-x-7) > sizeof(p->hdr.charset))
    return -po_unsupported_charset;
   memcpy(p->hdr.charset, x+8, y-x-8);
   p->hdr.charset[y-x-8] = 0;
   p->cd = iconv_open("UTF-8", p->hdr.charset);
   if (p->cd == (iconv_t)-1) {
    p->cd = 0;
    if (p->strict) return -po_unsupported_charset;
   }
  }
  if ((x = strstr(msg, "nplurals="))) {
   p->hdr.nplurals = *(x+9) - '0';
  }
 }
 return po_success;
}

canonical_original_code:
static inline enum po_error poparser_feed_hdr(struct po_parser *p, char *msg) {
 char *x; char *y;
 if (p->first && msg) {
  if ((x = strstr(msg, "charset="))) {
   for (y = x; *y && *y != '\\' && !((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short) _ISspace); y++);
   if ((unsigned long)(y-x-7) > sizeof(p->hdr.charset))
    return -po_unsupported_charset;
   memcpy(p->hdr.charset, x+8, y-x-8);
   p->hdr.charset[y-x-8] = 0;
   p->cd = iconv_open("UTF-8", p->hdr.charset);
   if (p->cd == (iconv_t)-1) {
    p->cd = 0;
    if (p->strict) return -po_unsupported_charset;
   }
  }
  if ((x = strstr(msg, "nplurals="))) {
   p->hdr.nplurals = *(x+9) - '0';
  }
 }
 return po_success;
}

variable_types:
msg
char *

variable_types:
x
char *

variable_types:
y
char *

user_defined_types: enum po_error { po_success=0, po_unsupported_charset=1, po_failed_iconv=2, po_excepted_token=3, po_plurals_overflow=4, po_invalid_entry=5, po_internal=6, po_error_last=expr }

user_defined_types: struct po_header { char charset[12]; unsigned int nplurals; }

user_defined_types: struct po_message { char *ctxt; char *id; char *plural; char *str[6]; int sysdep; unsigned long ctxt_len; unsigned long id_len; unsigned long plural_len; unsigned long strlen[6]; int flags; }

user_defined_types: enum po_stage { ps_size=0, ps_parse=1, ps_max=expr }

user_defined_types: enum po_entry { po_ctxt=0, po_id=1, po_plural=2, po_str=3 }


original_code:
void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_callback cb, void* cbdata) {
 int cnt;
 memset(p, 0, sizeof(struct po_parser));
 p->buf = workbuf;
 p->bufsize = bufsize;
 p->cb = cb;
 p->cbdata = cbdata;
 p->hdr.nplurals = 6;
 p->max_ctxt_len = 1;
 p->max_id_len = 1;
 p->max_plural_len = 1;
 for (cnt = 0; cnt < 6; cnt++)
  p->max_strlen[cnt] = 1;
 p->strcnt = 0;
 p->first = 1;
}

canonical_original_code:
void poparser_init(struct po_parser *p, char *workbuf, unsigned long bufsize, int (*cb)(struct po_message *msg, void *user), void *cbdata) {
 int cnt;
 memset(p, 0, sizeof(struct po_parser));
 p->buf = workbuf;
 p->bufsize = bufsize;
 p->cb = cb;
 p->cbdata = cbdata;
 p->hdr.nplurals = 6;
 p->max_ctxt_len = 1;
 p->max_id_len = 1;
 p->max_plural_len = 1;
 for (cnt = 0; cnt < 6; cnt++)
  p->max_strlen[cnt] = 1;
 p->strcnt = 0;
 p->first = 1;
}

variable_types:
workbuf
char *

variable_types:
bufsize
unsigned long

variable_types: int (*)(struct po_message *msg, void *user)

variable_types:
cbdata
void *

variable_types: cnt int


decompiled_code:
__int64 __fastcall poparser_feed_line(char *fromcode, __int64 a2, size_t a3)
{
char v3; // al
char *v4; // rbp
char *v6; // r14
unsigned int v7; // er13
int v8; // er12
char *v9; // rax
unsigned __int64 v10; // rdx
unsigned __int64 v11; // rax
unsigned __int64 v12; // rax
unsigned __int64 v13; // rax
char *v15; // r12
char *v16; // rax
const char *v17; // rbp
_QWORD *v18; // r13
char *v19; // rax
char *v20; // r12
char *v21; // rax
void *v22; // rdi
signed __int64 v23; // rdx
char *v24; // rax
char *v25; // rax
char *v26; // rbp
char *v27; // rax
void *v28; // rdi
__int64 v29; // rdx
char *v30; // rax
char *v31; // rax
char **v32; // r12
_DWORD *v33; // r13
unsigned int v34; // eax
size_t v35; // rax
__int64 v36; // rax
__int64 v37; // rbp
size_t v38; // rax
size_t v39; // rax
size_t v40; // rax
const unsigned __int16 **v41; // rax
__int64 v42; // rcx
size_t v43; // rax
__int64 v44; // rbp
int v45; // eax
unsigned int v46; // eax
bool v47; // zf
const char *v48; // r14
char **v49; // rbp
_DWORD *v50; // r12
const char *v51; // r14
char **v52; // rbp
_DWORD *v53; // r12
size_t v54; // rax
size_t v55; // rax
__int64 v56; // rsi
__int64 v57; // rsi
__int64 v58; // rsi
__int64 v59; // rsi
char *v60; // [rsp+0h] [rbp-58h] BYREF
size_t inbytesleft; // [rsp+8h] [rbp-50h] BYREF
size_t outbytesleft; // [rsp+10h] [rbp-48h] BYREF
char *outbuf[8]; // [rsp+18h] [rbp-40h] BYREF

v60 = (char *)a2;
inbytesleft = a3;
if ( !a3 )
return 0;
v3 = *(_BYTE *)a2;
v4 = (char *)a2;
if ( *(_BYTE *)a2 == 10 )
return 0;
v6 = fromcode + 16;
if ( v3 == 35 )
{
if ( *((_DWORD *)fromcode + 48) == 3 )
{
v7 = poparser_clean((__int64)fromcode, (__int64)(fromcode + 16));
if ( v7 )
return v7;
v4 = v60;
}
if ( v4[1] != 44 )
return 0;
v15 = v4 + 2;
v7 = *((_DWORD *)fromcode + 44);
for ( outbuf[0] = v4 + 2; *v15; outbuf[0] = v15 )
{
v16 = strpbrk(v15, " ,\n");
v17 = v16;
if ( !v16 )
break;
if ( v15 != v16 && !memcmp(v15, "fuzzy", v16 - v15) )
*((_DWORD *)fromcode + 42) |= 1u;
v15 = (char *)&v17[strspn(v17, " ,\n")];
}
v8 = 0;
goto LABEL_7;
}
if ( v3 == 34 )
{
v26 = (char *)(a2 + 1);
outbuf[0] = (char *)(a2 + 1);
v27 = strrchr((const char *)(a2 + 1), 34);
if ( v27 )
{
*v27 = 0;
v28 = (void *)*((_QWORD *)fromcode + 23);
v29 = v27 - v26;
outbytesleft = v27 - v26;
if ( v28 )
{
v60 = (char *)(a2 + 1);
v30 = (char *)*((_QWORD *)fromcode + 34);
inbytesleft = v29 + 1;
outbuf[0] = v30;
outbytesleft = *((_QWORD *)fromcode + 35);
if ( iconv(v28, &v60, &inbytesleft, outbuf, &outbytesleft) == -1LL || inbytesleft )
return (unsigned int)-2;
v26 = (char *)*((_QWORD *)fromcode + 34);
v31 = (char *)(outbuf[0] - v26);
outbuf[0] = v26;
outbytesleft = (size_t)v31;
}
v32 = sysdep_str;
v33 = &sysdep;
if ( !strstr(v26, "<PRIu32>") )
goto LABEL_49;
LABEL_48:
*((_DWORD *)fromcode + 22) |= *v33;
LABEL_49:
while ( 1 )
{
++v32;
++v33;
if ( &sysdep_str[3] == v32 )
break;
if ( strstr(v26, *v32) )
goto LABEL_48;
}
v34 = *((_DWORD *)fromcode + 48);
if ( v34 == 2 )
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v40 = unescape(v26, *((_QWORD *)fromcode + 4) + *((_QWORD *)fromcode + 14), *((_QWORD *)fromcode + 27));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v40 = outbytesleft;
}
*((_QWORD *)fromcode + 14) += v40;
v8 = 3;
goto LABEL_7;
}
if ( v34 <= 2 )
{
if ( v34 )
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v35 = unescape(v26, *((_QWORD *)fromcode + 3) + *((_QWORD *)fromcode + 13), *((_QWORD *)fromcode + 26));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v35 = outbytesleft;
}
*((_QWORD *)fromcode + 13) += v35;
v8 = 3;
}
else
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v39 = unescape(v26, *((_QWORD *)fromcode + 2) + *((_QWORD *)fromcode + 12), *((_QWORD *)fromcode + 25));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v39 = outbytesleft;
}
*((_QWORD *)fromcode + 12) += v39;
v8 = 3;
}
goto LABEL_7;
}
v7 = -5;
if ( v34 == 3 )
{
v7 = poparser_feed_hdr(fromcode, v26);
if ( !v7 )
{
v7 = *((_DWORD *)fromcode + 44);
v8 = *((_DWORD *)fromcode + 49) - 1;
if ( v7 == 1 )
{
v37 = v8;
v36 = unescape(
outbuf[0],
*(_QWORD *)&fromcode[8 * v8 + 40] + *(_QWORD *)&fromcode[8 * v8 + 120],
*(_QWORD *)&fromcode[8 * v8 + 224]);
v7 = *((_DWORD *)fromcode + 44);
outbytesleft = v36;
}
else
{
v36 = outbytesleft;
v37 = v8;
}
*(_QWORD *)&fromcode[8 * v37 + 120] += v36;
goto LABEL_7;
}
}
return v7;
}
return (unsigned int)-3;
}
if ( *(_WORD *)a2 != 29549 || *(_BYTE *)(a2 + 2) != 103 )
{
v7 = *((_DWORD *)fromcode + 44);
v8 = 0;
LABEL_7:
if ( !v7 )
{
v9 = &fromcode[8 * v8];
v10 = *((_QWORD *)v9 + 15);
if ( *((_QWORD *)v9 + 28) < v10 )
*((_QWORD *)v9 + 28) = v10 + 1;
v11 = *((_QWORD *)fromcode + 14);
if ( *((_QWORD *)fromcode + 27) < v11 )
*((_QWORD *)fromcode + 27) = v11 + 1;
v12 = *((_QWORD *)fromcode + 13);
if ( *((_QWORD *)fromcode + 26) < v12 )
*((_QWORD *)fromcode + 26) = v12 + 1;
v13 = *((_QWORD *)fromcode + 12);
if ( *((_QWORD *)fromcode + 25) < v13 )
{
*((_QWORD *)fromcode + 25) = v13 + 1;
return v7;
}
}
return 0;
}
v18 = (_QWORD *)(a2 + 3);
v19 = strchr((const char *)(a2 + 3), 34);
if ( !v19 )
return (unsigned int)-3;
v20 = v19 + 1;
v21 = strrchr(v19 + 1, 34);
if ( !v21 )
return (unsigned int)-3;
*v21 = 0;
v22 = (void *)*((_QWORD *)fromcode + 23);
v23 = v21 - v20;
outbuf[0] = v20;
outbytesleft = v21 - v20;
if ( !v22 )
goto LABEL_35;
v60 = v20;
v24 = (char *)*((_QWORD *)fromcode + 34);
inbytesleft = v23 + 1;
outbuf[0] = v24;
outbytesleft = *((_QWORD *)fromcode + 35);
if ( iconv(v22, &v60, &inbytesleft, outbuf, &outbytesleft) == -1LL || inbytesleft )
return (unsigned int)-2;
v25 = &outbuf[0][-*((_QWORD *)fromcode + 34)];
outbuf[0] = *((char **)fromcode + 34);
outbytesleft = (size_t)v25;
LABEL_35:
if ( *(_DWORD *)(a2 + 3) == 1954051171 && ((*_ctype_b_loc())[*(char *)(a2 + 7)] & 0x2000) != 0 )
{
v7 = poparser_clean((__int64)fromcode, (__int64)v6);
if ( v7 )
return v7;
if ( !*((_QWORD *)fromcode + 13) && !*((_QWORD *)fromcode + 14) )
{
v48 = outbuf[0];
v49 = sysdep_str;
v50 = &sysdep;
if ( !strstr(outbuf[0], "<PRIu32>") )
goto LABEL_104;
LABEL_103:
*((_DWORD *)fromcode + 22) |= *v50;
LABEL_104:
while ( 1 )
{
++v49;
++v50;
if ( &sysdep_str[3] == v49 )
break;
if ( strstr(v48, *v49) )
goto LABEL_103;
}
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v59 = *((_QWORD *)fromcode + 2);
if ( !v59 )
return (unsigned int)-6;
v55 = unescape(v48, v59, *((_QWORD *)fromcode + 25));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v55 = outbytesleft;
}
*((_QWORD *)fromcode + 12) = v55;
v8 = 3;
*((_DWORD *)fromcode + 48) = 0;
goto LABEL_7;
}
return (unsigned int)-5;
}
if ( *(_WORD *)(a2 + 3) == 25705 && ((*_ctype_b_loc())[*(char *)(a2 + 5)] & 0x2000) != 0 )
{
v7 = poparser_clean((__int64)fromcode, (__int64)v6);
if ( v7 )
return v7;
if ( !*((_QWORD *)fromcode + 14) )
{
v51 = outbuf[0];
v52 = sysdep_str;
v53 = &sysdep;
if ( !strstr(outbuf[0], "<PRIu32>") )
goto LABEL_111;
LABEL_110:
*((_DWORD *)fromcode + 22) |= *v53;
LABEL_111:
while ( 1 )
{
++v52;
++v53;
if ( v52 == &sysdep_str[3] )
break;
if ( strstr(v51, *v52) )
goto LABEL_110;
}
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v58 = *((_QWORD *)fromcode + 3);
if ( !v58 )
return (unsigned int)-6;
v54 = unescape(v51, v58, *((_QWORD *)fromcode + 26));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v54 = outbytesleft;
}
*((_QWORD *)fromcode + 13) = v54;
v8 = 3;
*((_DWORD *)fromcode + 48) = 1;
goto LABEL_7;
}
return (unsigned int)-5;
}
if ( *v18 == 0x6172756C705F6469LL && *(_BYTE *)(a2 + 11) == 108 )
{
v8 = 0;
if ( ((*_ctype_b_loc())[*(char *)(a2 + 12)] & 0x2000) != 0 )
{
if ( *((_QWORD *)fromcode + 13) && !*((_DWORD *)fromcode + 49) )
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 != 1 )
{
v38 = outbytesleft;
LABEL_74:
*((_QWORD *)fromcode + 14) = v38;
*((_DWORD *)fromcode + 48) = 2;
goto LABEL_7;
}
v56 = *((_QWORD *)fromcode + 4);
if ( v56 )
{
v38 = unescape(outbuf[0], v56, *((_QWORD *)fromcode + 27));
v7 = *((_DWORD *)fromcode + 44);
goto LABEL_74;
}
return (unsigned int)-6;
}
return (unsigned int)-5;
}
}
if ( *(_WORD *)v18 != 29811 )
return (unsigned int)-5;
if ( *(_BYTE *)(a2 + 5) != 114 )
return (unsigned int)-5;
v8 = 0;
if ( !*((_QWORD *)fromcode + 13) && !fromcode[180] )
return (unsigned int)-5;
v41 = _ctype_b_loc();
v42 = *(char *)(a2 + 6);
if ( ((*v41)[v42] & 0x2000) != 0 )
{
if ( *((_DWORD *)fromcode + 49) || *((_QWORD *)fromcode + 14) )
return (unsigned int)-5;
*((_DWORD *)fromcode + 49) = 1;
LABEL_88:
v7 = poparser_feed_hdr(fromcode, outbuf[0]);
if ( v7 )
return v7;
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v44 = v8;
v57 = *(_QWORD *)&fromcode[8 * v8 + 40];
if ( !v57 )
return (unsigned int)-6;
v43 = unescape(outbuf[0], v57, *(_QWORD *)&fromcode[8 * v8 + 224]);
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v43 = outbytesleft;
v44 = v8;
}
*(_QWORD *)&fromcode[8 * v44 + 120] = v43;
*((_DWORD *)fromcode + 48) = 3;
goto LABEL_7;
}
v7 = -3;
if ( (_BYTE)v42 != 91 )
return v7;
if ( !*((_QWORD *)fromcode + 14) )
return (unsigned int)-5;
if ( *(_BYTE *)(a2 + 8) == 93 && ((*v41)[*(char *)(a2 + 9)] & 0x2000) != 0 )
{
v45 = *(char *)(a2 + 7);
v8 = v45 - 48;
v46 = v45 - 47;
v47 = fromcode[181] == 0;
*((_DWORD *)fromcode + 49) = v46;
if ( v47 )
goto LABEL_88;
v7 = -4;
if ( v46 <= *((_DWORD *)fromcode + 3) )
goto LABEL_88;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *fromcode, __int64 a2, size_t a3)
{
char v3; // al
char *v4; // rbp
char *v6; // r14
unsigned int v7; // er13
int v8; // er12
char *v9; // rax
unsigned __int64 v10; // rdx
unsigned __int64 v11; // rax
unsigned __int64 v12; // rax
unsigned __int64 v13; // rax
char *v15; // r12
char *v16; // rax
const char *v17; // rbp
_QWORD *v18; // r13
char *v19; // rax
char *v20; // r12
char *v21; // rax
void *v22; // rdi
signed __int64 v23; // rdx
char *v24; // rax
char *v25; // rax
char *v26; // rbp
char *v27; // rax
void *v28; // rdi
__int64 v29; // rdx
char *v30; // rax
char *v31; // rax
char **v32; // r12
_DWORD *v33; // r13
unsigned int v34; // eax
size_t v35; // rax
__int64 v36; // rax
__int64 v37; // rbp
size_t v38; // rax
size_t v39; // rax
size_t v40; // rax
const unsigned __int16 **v41; // rax
__int64 v42; // rcx
size_t v43; // rax
__int64 v44; // rbp
int v45; // eax
unsigned int v46; // eax
bool v47; // zf
const char *v48; // r14
char **v49; // rbp
_DWORD *v50; // r12
const char *v51; // r14
char **v52; // rbp
_DWORD *v53; // r12
size_t v54; // rax
size_t v55; // rax
__int64 v56; // rsi
__int64 v57; // rsi
__int64 v58; // rsi
__int64 v59; // rsi
char *v60; // [rsp+0h] [rbp-58h] BYREF
size_t inbytesleft; // [rsp+8h] [rbp-50h] BYREF
size_t outbytesleft; // [rsp+10h] [rbp-48h] BYREF
char *outbuf[8]; // [rsp+18h] [rbp-40h] BYREF

v60 = (char *)a2;
inbytesleft = a3;
if ( !a3 )
return 0;
v3 = *(_BYTE *)a2;
v4 = (char *)a2;
if ( *(_BYTE *)a2 == 10 )
return 0;
v6 = fromcode + 16;
if ( v3 == 35 )
{
if ( *((_DWORD *)fromcode + 48) == 3 )
{
v7 = func0((__int64)fromcode, (__int64)(fromcode + 16));
if ( v7 )
return v7;
v4 = v60;
}
if ( v4[1] != 44 )
return 0;
v15 = v4 + 2;
v7 = *((_DWORD *)fromcode + 44);
for ( outbuf[0] = v4 + 2; *v15; outbuf[0] = v15 )
{
v16 = strpbrk(v15, " ,\n");
v17 = v16;
if ( !v16 )
break;
if ( v15 != v16 && !memcmp(v15, "fuzzy", v16 - v15) )
*((_DWORD *)fromcode + 42) |= 1u;
v15 = (char *)&v17[strspn(v17, " ,\n")];
}
v8 = 0;
goto LABEL_7;
}
if ( v3 == 34 )
{
v26 = (char *)(a2 + 1);
outbuf[0] = (char *)(a2 + 1);
v27 = strrchr((const char *)(a2 + 1), 34);
if ( v27 )
{
*v27 = 0;
v28 = (void *)*((_QWORD *)fromcode + 23);
v29 = v27 - v26;
outbytesleft = v27 - v26;
if ( v28 )
{
v60 = (char *)(a2 + 1);
v30 = (char *)*((_QWORD *)fromcode + 34);
inbytesleft = v29 + 1;
outbuf[0] = v30;
outbytesleft = *((_QWORD *)fromcode + 35);
if ( iconv(v28, &v60, &inbytesleft, outbuf, &outbytesleft) == -1LL || inbytesleft )
return (unsigned int)-2;
v26 = (char *)*((_QWORD *)fromcode + 34);
v31 = (char *)(outbuf[0] - v26);
outbuf[0] = v26;
outbytesleft = (size_t)v31;
}
v32 = sysdep_str;
v33 = &sysdep;
if ( !strstr(v26, "<PRIu32>") )
goto LABEL_49;
LABEL_48:
*((_DWORD *)fromcode + 22) |= *v33;
LABEL_49:
while ( 1 )
{
++v32;
++v33;
if ( &sysdep_str[3] == v32 )
break;
if ( strstr(v26, *v32) )
goto LABEL_48;
}
v34 = *((_DWORD *)fromcode + 48);
if ( v34 == 2 )
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v40 = unescape(v26, *((_QWORD *)fromcode + 4) + *((_QWORD *)fromcode + 14), *((_QWORD *)fromcode + 27));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v40 = outbytesleft;
}
*((_QWORD *)fromcode + 14) += v40;
v8 = 3;
goto LABEL_7;
}
if ( v34 <= 2 )
{
if ( v34 )
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v35 = unescape(v26, *((_QWORD *)fromcode + 3) + *((_QWORD *)fromcode + 13), *((_QWORD *)fromcode + 26));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v35 = outbytesleft;
}
*((_QWORD *)fromcode + 13) += v35;
v8 = 3;
}
else
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v39 = unescape(v26, *((_QWORD *)fromcode + 2) + *((_QWORD *)fromcode + 12), *((_QWORD *)fromcode + 25));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v39 = outbytesleft;
}
*((_QWORD *)fromcode + 12) += v39;
v8 = 3;
}
goto LABEL_7;
}
v7 = -5;
if ( v34 == 3 )
{
v7 = func1(fromcode, v26);
if ( !v7 )
{
v7 = *((_DWORD *)fromcode + 44);
v8 = *((_DWORD *)fromcode + 49) - 1;
if ( v7 == 1 )
{
v37 = v8;
v36 = unescape(
outbuf[0],
*(_QWORD *)&fromcode[8 * v8 + 40] + *(_QWORD *)&fromcode[8 * v8 + 120],
*(_QWORD *)&fromcode[8 * v8 + 224]);
v7 = *((_DWORD *)fromcode + 44);
outbytesleft = v36;
}
else
{
v36 = outbytesleft;
v37 = v8;
}
*(_QWORD *)&fromcode[8 * v37 + 120] += v36;
goto LABEL_7;
}
}
return v7;
}
return (unsigned int)-3;
}
if ( *(_WORD *)a2 != 29549 || *(_BYTE *)(a2 + 2) != 103 )
{
v7 = *((_DWORD *)fromcode + 44);
v8 = 0;
LABEL_7:
if ( !v7 )
{
v9 = &fromcode[8 * v8];
v10 = *((_QWORD *)v9 + 15);
if ( *((_QWORD *)v9 + 28) < v10 )
*((_QWORD *)v9 + 28) = v10 + 1;
v11 = *((_QWORD *)fromcode + 14);
if ( *((_QWORD *)fromcode + 27) < v11 )
*((_QWORD *)fromcode + 27) = v11 + 1;
v12 = *((_QWORD *)fromcode + 13);
if ( *((_QWORD *)fromcode + 26) < v12 )
*((_QWORD *)fromcode + 26) = v12 + 1;
v13 = *((_QWORD *)fromcode + 12);
if ( *((_QWORD *)fromcode + 25) < v13 )
{
*((_QWORD *)fromcode + 25) = v13 + 1;
return v7;
}
}
return 0;
}
v18 = (_QWORD *)(a2 + 3);
v19 = strchr((const char *)(a2 + 3), 34);
if ( !v19 )
return (unsigned int)-3;
v20 = v19 + 1;
v21 = strrchr(v19 + 1, 34);
if ( !v21 )
return (unsigned int)-3;
*v21 = 0;
v22 = (void *)*((_QWORD *)fromcode + 23);
v23 = v21 - v20;
outbuf[0] = v20;
outbytesleft = v21 - v20;
if ( !v22 )
goto LABEL_35;
v60 = v20;
v24 = (char *)*((_QWORD *)fromcode + 34);
inbytesleft = v23 + 1;
outbuf[0] = v24;
outbytesleft = *((_QWORD *)fromcode + 35);
if ( iconv(v22, &v60, &inbytesleft, outbuf, &outbytesleft) == -1LL || inbytesleft )
return (unsigned int)-2;
v25 = &outbuf[0][-*((_QWORD *)fromcode + 34)];
outbuf[0] = *((char **)fromcode + 34);
outbytesleft = (size_t)v25;
LABEL_35:
if ( *(_DWORD *)(a2 + 3) == 1954051171 && ((*_ctype_b_loc())[*(char *)(a2 + 7)] & 0x2000) != 0 )
{
v7 = func0((__int64)fromcode, (__int64)v6);
if ( v7 )
return v7;
if ( !*((_QWORD *)fromcode + 13) && !*((_QWORD *)fromcode + 14) )
{
v48 = outbuf[0];
v49 = sysdep_str;
v50 = &sysdep;
if ( !strstr(outbuf[0], "<PRIu32>") )
goto LABEL_104;
LABEL_103:
*((_DWORD *)fromcode + 22) |= *v50;
LABEL_104:
while ( 1 )
{
++v49;
++v50;
if ( &sysdep_str[3] == v49 )
break;
if ( strstr(v48, *v49) )
goto LABEL_103;
}
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v59 = *((_QWORD *)fromcode + 2);
if ( !v59 )
return (unsigned int)-6;
v55 = unescape(v48, v59, *((_QWORD *)fromcode + 25));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v55 = outbytesleft;
}
*((_QWORD *)fromcode + 12) = v55;
v8 = 3;
*((_DWORD *)fromcode + 48) = 0;
goto LABEL_7;
}
return (unsigned int)-5;
}
if ( *(_WORD *)(a2 + 3) == 25705 && ((*_ctype_b_loc())[*(char *)(a2 + 5)] & 0x2000) != 0 )
{
v7 = func0((__int64)fromcode, (__int64)v6);
if ( v7 )
return v7;
if ( !*((_QWORD *)fromcode + 14) )
{
v51 = outbuf[0];
v52 = sysdep_str;
v53 = &sysdep;
if ( !strstr(outbuf[0], "<PRIu32>") )
goto LABEL_111;
LABEL_110:
*((_DWORD *)fromcode + 22) |= *v53;
LABEL_111:
while ( 1 )
{
++v52;
++v53;
if ( v52 == &sysdep_str[3] )
break;
if ( strstr(v51, *v52) )
goto LABEL_110;
}
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v58 = *((_QWORD *)fromcode + 3);
if ( !v58 )
return (unsigned int)-6;
v54 = unescape(v51, v58, *((_QWORD *)fromcode + 26));
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v54 = outbytesleft;
}
*((_QWORD *)fromcode + 13) = v54;
v8 = 3;
*((_DWORD *)fromcode + 48) = 1;
goto LABEL_7;
}
return (unsigned int)-5;
}
if ( *v18 == 0x6172756C705F6469LL && *(_BYTE *)(a2 + 11) == 108 )
{
v8 = 0;
if ( ((*_ctype_b_loc())[*(char *)(a2 + 12)] & 0x2000) != 0 )
{
if ( *((_QWORD *)fromcode + 13) && !*((_DWORD *)fromcode + 49) )
{
v7 = *((_DWORD *)fromcode + 44);
if ( v7 != 1 )
{
v38 = outbytesleft;
LABEL_74:
*((_QWORD *)fromcode + 14) = v38;
*((_DWORD *)fromcode + 48) = 2;
goto LABEL_7;
}
v56 = *((_QWORD *)fromcode + 4);
if ( v56 )
{
v38 = unescape(outbuf[0], v56, *((_QWORD *)fromcode + 27));
v7 = *((_DWORD *)fromcode + 44);
goto LABEL_74;
}
return (unsigned int)-6;
}
return (unsigned int)-5;
}
}
if ( *(_WORD *)v18 != 29811 )
return (unsigned int)-5;
if ( *(_BYTE *)(a2 + 5) != 114 )
return (unsigned int)-5;
v8 = 0;
if ( !*((_QWORD *)fromcode + 13) && !fromcode[180] )
return (unsigned int)-5;
v41 = _ctype_b_loc();
v42 = *(char *)(a2 + 6);
if ( ((*v41)[v42] & 0x2000) != 0 )
{
if ( *((_DWORD *)fromcode + 49) || *((_QWORD *)fromcode + 14) )
return (unsigned int)-5;
*((_DWORD *)fromcode + 49) = 1;
LABEL_88:
v7 = func1(fromcode, outbuf[0]);
if ( v7 )
return v7;
v7 = *((_DWORD *)fromcode + 44);
if ( v7 == 1 )
{
v44 = v8;
v57 = *(_QWORD *)&fromcode[8 * v8 + 40];
if ( !v57 )
return (unsigned int)-6;
v43 = unescape(outbuf[0], v57, *(_QWORD *)&fromcode[8 * v8 + 224]);
v7 = *((_DWORD *)fromcode + 44);
}
else
{
v43 = outbytesleft;
v44 = v8;
}
*(_QWORD *)&fromcode[8 * v44 + 120] = v43;
*((_DWORD *)fromcode + 48) = 3;
goto LABEL_7;
}
v7 = -3;
if ( (_BYTE)v42 != 91 )
return v7;
if ( !*((_QWORD *)fromcode + 14) )
return (unsigned int)-5;
if ( *(_BYTE *)(a2 + 8) == 93 && ((*v41)[*(char *)(a2 + 9)] & 0x2000) != 0 )
{
v45 = *(char *)(a2 + 7);
v8 = v45 - 48;
v46 = v45 - 47;
v47 = fromcode[181] == 0;
*((_DWORD *)fromcode + 49) = v46;
if ( v47 )
goto LABEL_88;
v7 = -4;
if ( v46 <= *((_DWORD *)fromcode + 3) )
goto LABEL_88;
}
return v7;
}

original_code:
enum po_error poparser_feed_line(struct po_parser *p, char* in, size_t in_len) {
 char *line = in;
 size_t line_len = in_len;
 po_message_t msg = &p->msg;
 int cnt = 0;
 enum po_error t;
 size_t len;
 char *x, *y, *z;
 if (line_len == 0 || line[0] == '\n') {
  return po_success;
 } else if (line[0] == '#') {
  if (p->previous == po_str) {
   if ( (t = poparser_clean(p, msg)) != po_success)
    return t;
  }
  switch (line[1]) {
  case ',':
   x = &line[2];
   while (*x && (y = strpbrk(x, " ,\n"))) {
    if (y != x && !memcmp(x, "fuzzy", y-x)) {
     msg->flags |= 1u;
    }
    x = y + strspn(y, " ,\n");
   }
   break;
  case '.':
  case ':':
  case '|':
  default:
   return po_success;
  }
 } else if (line[0] == '"') {
  if ( (y = strrchr(x = &line[1], '"')) == ((void *)0))
   return -po_excepted_token;
  len = y - x;
  *y = 0;
  if (p->cd) {
   line = x;
   line_len = len + 1;
   x = p->buf;
   len = p->bufsize;
   if (iconv(p->cd, &line, &line_len, &x, &len) == (size_t)-1)
    return -po_failed_iconv;
   if (line_len != 0)
    return -po_failed_iconv;
   len = x - p->buf;
   x = p->buf;
  }
  for (cnt = 0; cnt < st_max; cnt++) {
   if (strstr(x, sysdep_str[cnt])) {
    msg->sysdep |= sysdep[cnt];
   }
  }
  switch (p->previous) {
  case po_str:
   if ((t = poparser_feed_hdr(p, x)) != po_success) {
    return t;
   }
   cnt = p->strcnt - 1;
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->str[cnt][msg->strlen[cnt]], p->max_strlen[cnt]);
   }
   msg->strlen[cnt] += len;
   break;
  case po_plural:
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->plural[msg->plural_len], p->max_plural_len);
   }
   msg->plural_len += len;
   break;
  case po_id:
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->id[msg->id_len], p->max_id_len);
   }
   msg->id_len += len;
   break;
  case po_ctxt:
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->ctxt[msg->ctxt_len], p->max_ctxt_len);
   }
   msg->ctxt_len += len;
   break;
  default:
   return -po_invalid_entry;
  }
 } else if ((z = (memcmp(line, "msg", sizeof("msg") - 1) ? ((void *)0) : (line + (sizeof("msg") - 1))))) {
  if ( (x = strchr(z, '"')) == ((void *)0))
   return -po_excepted_token;
  if ( (y = strrchr(x+1, '"')) == ((void *)0))
   return -po_excepted_token;
  len = y - ++x;
  *y = 0;
  if (p->cd) {
   line = x;
   line_len = len + 1;
   x = p->buf;
   len = p->bufsize;
   if (iconv(p->cd, &line, &line_len, &x, &len) == (size_t)-1)
    return -po_failed_iconv;
   if (line_len != 0)
    return -po_failed_iconv;
   len = x - p->buf;
   x = p->buf;
  }
  if ((y = (memcmp(z, "ctxt", sizeof("ctxt") - 1) ? ((void *)0) : (z + (sizeof("ctxt") - 1)))) && ((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short int) _ISspace)) {
   if ( (t = poparser_clean(p, msg)) != po_success)
    return t;
   if (msg->id_len || msg->plural_len)
    return -po_invalid_entry;
   for (cnt = 0; cnt < st_max; cnt++) {
    if (strstr(x, sysdep_str[cnt])) {
     msg->sysdep |= sysdep[cnt];
    }
   }
   if (p->stage == ps_parse) {
    if (msg->ctxt == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->ctxt, p->max_ctxt_len);
   }
   msg->ctxt_len = len;
   p->previous = po_ctxt;
  } else if ((y = (memcmp(z, "id", sizeof("id") - 1) ? ((void *)0) : (z + (sizeof("id") - 1)))) && ((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short int) _ISspace)) {
   if ( (t = poparser_clean(p, msg)) != po_success)
    return t;
   if (msg->plural_len)
    return -po_invalid_entry;
   for (cnt = 0; cnt < st_max; cnt++) {
    if (strstr(x, sysdep_str[cnt])) {
     msg->sysdep |= sysdep[cnt];
    }
   }
   if (p->stage == ps_parse) {
    if (msg->id == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->id, p->max_id_len);
   }
   msg->id_len = len;
   p->previous = po_id;
  } else if ((y = (memcmp(z, "id_plural", sizeof("id_plural") - 1) ? ((void *)0) : (z + (sizeof("id_plural") - 1)))) && ((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short int) _ISspace)) {
   if (!msg->id_len || p->strcnt)
    return -po_invalid_entry;
   if (p->stage == ps_parse) {
    if (msg->plural == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->plural, p->max_plural_len);
   }
   msg->plural_len = len;
   p->previous = po_plural;
  } else if ((y = (memcmp(z, "str", sizeof("str") - 1) ? ((void *)0) : (z + (sizeof("str") - 1))))) {
   if (!msg->id_len && !p->first)
    return -po_invalid_entry;
   if (((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short int) _ISspace)) {
    if (p->strcnt || msg->plural_len)
     return -po_invalid_entry;
    cnt = (p->strcnt = 1) - 1;
   } else if (*y == '[') {
    if (!msg->plural_len)
     return -po_invalid_entry;
    if (y[2] != ']' || !((*__ctype_b_loc ())[(int) ((y[3]))] & (unsigned short int) _ISspace)) return -po_excepted_token;
    p->strcnt = (cnt = y[1] - '0') + 1;
    if (p->strict && p->strcnt > p->hdr.nplurals) {
     return -po_plurals_overflow;
    }
   } else {
    return -po_excepted_token;
   }
   if ((t = poparser_feed_hdr(p, x)) != po_success) {
    return t;
   }
   if (p->stage == ps_parse) {
    if (msg->str[cnt] == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->str[cnt], p->max_strlen[cnt]);
   }
   msg->strlen[cnt] = len;
   p->previous = po_str;
  } else {
   return -po_invalid_entry;
  }
 }
 if (p->stage == ps_size) {
  if (p->max_strlen[cnt] < msg->strlen[cnt])
   p->max_strlen[cnt] = msg->strlen[cnt] + 1;
  if (p->max_plural_len < msg->plural_len)
   p->max_plural_len = msg->plural_len + 1;
  if (p->max_id_len < msg->id_len)
   p->max_id_len = msg->id_len + 1;
  if (p->max_ctxt_len < msg->ctxt_len)
   p->max_ctxt_len = msg->ctxt_len + 1;
 }
 return po_success;
}

canonical_original_code:
enum po_error poparser_feed_line(struct po_parser *p, char *in, unsigned long in_len) {
 char *line = in;
 unsigned long line_len = in_len;
 struct po_message *msg = &p->msg;
 int cnt = 0;
 enum po_error t;
 unsigned long len;
 char *x; char *y; char *z;
 if (line_len == 0 || line[0] == '\n') {
  return po_success;
 } else if (line[0] == '#') {
  if (p->previous == po_str) {
   if ( (t = poparser_clean(p, msg)) != po_success)
    return t;
  }
  switch (line[1]) {
  case ',':
   x = &line[2];
   while (*x && (y = strpbrk(x, " ,\n"))) {
    if (y != x && !memcmp(x, "fuzzy", y-x)) {
     msg->flags |= 1u;
    }
    x = y + strspn(y, " ,\n");
   }
   break;
  case '.':
  case ':':
  case '|':
  default:
   return po_success;
  }
 } else if (line[0] == '"') {
  if ( (y = strrchr(x = &line[1], '"')) == ((void *)0))
   return -po_excepted_token;
  len = y - x;
  *y = 0;
  if (p->cd) {
   line = x;
   line_len = len + 1;
   x = p->buf;
   len = p->bufsize;
   if (iconv(p->cd, &line, &line_len, &x, &len) == (unsigned long)-1)
    return -po_failed_iconv;
   if (line_len != 0)
    return -po_failed_iconv;
   len = x - p->buf;
   x = p->buf;
  }
  for (cnt = 0; cnt < st_max; cnt++) {
   if (strstr(x, sysdep_str[cnt])) {
    msg->sysdep |= sysdep[cnt];
   }
  }
  switch (p->previous) {
  case po_str:
   if ((t = poparser_feed_hdr(p, x)) != po_success) {
    return t;
   }
   cnt = p->strcnt - 1;
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->str[cnt][msg->strlen[cnt]], p->max_strlen[cnt]);
   }
   msg->strlen[cnt] += len;
   break;
  case po_plural:
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->plural[msg->plural_len], p->max_plural_len);
   }
   msg->plural_len += len;
   break;
  case po_id:
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->id[msg->id_len], p->max_id_len);
   }
   msg->id_len += len;
   break;
  case po_ctxt:
   if (p->stage == ps_parse) {
    len = unescape(x, &msg->ctxt[msg->ctxt_len], p->max_ctxt_len);
   }
   msg->ctxt_len += len;
   break;
  default:
   return -po_invalid_entry;
  }
 } else if ((z = (memcmp(line, "msg", sizeof("msg") - 1) ? ((void *)0) : (line + (sizeof("msg") - 1))))) {
  if ( (x = strchr(z, '"')) == ((void *)0))
   return -po_excepted_token;
  if ( (y = strrchr(x+1, '"')) == ((void *)0))
   return -po_excepted_token;
  len = y - ++x;
  *y = 0;
  if (p->cd) {
   line = x;
   line_len = len + 1;
   x = p->buf;
   len = p->bufsize;
   if (iconv(p->cd, &line, &line_len, &x, &len) == (unsigned long)-1)
    return -po_failed_iconv;
   if (line_len != 0)
    return -po_failed_iconv;
   len = x - p->buf;
   x = p->buf;
  }
  if ((y = (memcmp(z, "ctxt", sizeof("ctxt") - 1) ? ((void *)0) : (z + (sizeof("ctxt") - 1)))) && ((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short) _ISspace)) {
   if ( (t = poparser_clean(p, msg)) != po_success)
    return t;
   if (msg->id_len || msg->plural_len)
    return -po_invalid_entry;
   for (cnt = 0; cnt < st_max; cnt++) {
    if (strstr(x, sysdep_str[cnt])) {
     msg->sysdep |= sysdep[cnt];
    }
   }
   if (p->stage == ps_parse) {
    if (msg->ctxt == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->ctxt, p->max_ctxt_len);
   }
   msg->ctxt_len = len;
   p->previous = po_ctxt;
  } else if ((y = (memcmp(z, "id", sizeof("id") - 1) ? ((void *)0) : (z + (sizeof("id") - 1)))) && ((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short) _ISspace)) {
   if ( (t = poparser_clean(p, msg)) != po_success)
    return t;
   if (msg->plural_len)
    return -po_invalid_entry;
   for (cnt = 0; cnt < st_max; cnt++) {
    if (strstr(x, sysdep_str[cnt])) {
     msg->sysdep |= sysdep[cnt];
    }
   }
   if (p->stage == ps_parse) {
    if (msg->id == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->id, p->max_id_len);
   }
   msg->id_len = len;
   p->previous = po_id;
  } else if ((y = (memcmp(z, "id_plural", sizeof("id_plural") - 1) ? ((void *)0) : (z + (sizeof("id_plural") - 1)))) && ((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short) _ISspace)) {
   if (!msg->id_len || p->strcnt)
    return -po_invalid_entry;
   if (p->stage == ps_parse) {
    if (msg->plural == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->plural, p->max_plural_len);
   }
   msg->plural_len = len;
   p->previous = po_plural;
  } else if ((y = (memcmp(z, "str", sizeof("str") - 1) ? ((void *)0) : (z + (sizeof("str") - 1))))) {
   if (!msg->id_len && !p->first)
    return -po_invalid_entry;
   if (((*__ctype_b_loc ())[(int) ((*y))] & (unsigned short) _ISspace)) {
    if (p->strcnt || msg->plural_len)
     return -po_invalid_entry;
    cnt = (p->strcnt = 1) - 1;
   } else if (*y == '[') {
    if (!msg->plural_len)
     return -po_invalid_entry;
    if (y[2] != ']' || !((*__ctype_b_loc ())[(int) ((y[3]))] & (unsigned short) _ISspace)) return -po_excepted_token;
    p->strcnt = (cnt = y[1] - '0') + 1;
    if (p->strict && p->strcnt > p->hdr.nplurals) {
     return -po_plurals_overflow;
    }
   } else {
    return -po_excepted_token;
   }
   if ((t = poparser_feed_hdr(p, x)) != po_success) {
    return t;
   }
   if (p->stage == ps_parse) {
    if (msg->str[cnt] == ((void *)0)) {
     return -po_internal;
    }
    len = unescape(x, msg->str[cnt], p->max_strlen[cnt]);
   }
   msg->strlen[cnt] = len;
   p->previous = po_str;
  } else {
   return -po_invalid_entry;
  }
 }
 if (p->stage == ps_size) {
  if (p->max_strlen[cnt] < msg->strlen[cnt])
   p->max_strlen[cnt] = msg->strlen[cnt] + 1;
  if (p->max_plural_len < msg->plural_len)
   p->max_plural_len = msg->plural_len + 1;
  if (p->max_id_len < msg->id_len)
   p->max_id_len = msg->id_len + 1;
  if (p->max_ctxt_len < msg->ctxt_len)
   p->max_ctxt_len = msg->ctxt_len + 1;
 }
 return po_success;
}

variable_types:
in
char *

variable_types:
line
char *

variable_types: struct po_message { char *ctxt; char *id; char *plural; char *str[6]; int sysdep; unsigned long ctxt_len; unsigned long id_len; unsigned long plural_len; unsigned long strlen[6]; int flags; } *

variable_types: enum po_error { po_success=0, po_unsupported_charset=1, po_failed_iconv=2, po_excepted_token=3, po_plurals_overflow=4, po_invalid_entry=5, po_internal=6, po_error_last=expr }

variable_types:
len
unsigned long

variable_types:
z
char *


original_code:
enum po_error poparser_finish(struct po_parser *p) {
 size_t len;
 int cnt;
 enum po_error t;
 po_message_t msg = &p->msg;
 if (p->stage == ps_size) {
  if ( (t = poparser_clean(p, msg)) != po_success)
   return t;
  len = p->max_ctxt_len;
  len += p->max_id_len;
  len += p->max_plural_len;
  for (cnt = 0; cnt < 6; cnt++)
   len += p->max_strlen[cnt];
  memset(msg, 0, sizeof(struct po_message));
  msg->ctxt = (char*)malloc(len);
  msg->id = msg->ctxt + p->max_ctxt_len;
  msg->plural = msg->id + p->max_id_len;
  msg->str[0] = msg->plural + p->max_plural_len;
  for (cnt = 1; cnt < 6; cnt++)
   msg->str[cnt] = msg->str[cnt-1] + p->max_strlen[cnt-1];
  p->hdr.nplurals = 2;
  p->first = 1;
 } else {
  if ( (t = poparser_clean(p, msg)) != po_success)
   return t;
  if (msg->ctxt) free(msg->ctxt);
  if (p->cd) iconv_close(p->cd);
 }
 if (p->stage < ps_parse) p->stage++;
 return po_success;
}

canonical_original_code:
enum po_error poparser_finish(struct po_parser *p) {
 unsigned long len;
 int cnt;
 enum po_error t;
 struct po_message *msg = &p->msg;
 if (p->stage == ps_size) {
  if ( (t = poparser_clean(p, msg)) != po_success)
   return t;
  len = p->max_ctxt_len;
  len += p->max_id_len;
  len += p->max_plural_len;
  for (cnt = 0; cnt < 6; cnt++)
   len += p->max_strlen[cnt];
  memset(msg, 0, sizeof(struct po_message));
  msg->ctxt = (char *)malloc(len);
  msg->id = msg->ctxt + p->max_ctxt_len;
  msg->plural = msg->id + p->max_id_len;
  msg->str[0] = msg->plural + p->max_plural_len;
  for (cnt = 1; cnt < 6; cnt++)
   msg->str[cnt] = msg->str[cnt-1] + p->max_strlen[cnt-1];
  p->hdr.nplurals = 2;
  p->first = 1;
 } else {
  if ( (t = poparser_clean(p, msg)) != po_success)
   return t;
  if (msg->ctxt) free(msg->ctxt);
  if (p->cd) iconv_close(p->cd);
 }
 if (p->stage < ps_parse) p->stage++;
 return po_success;
}


decompiled_code:
__int64 __fastcall poparser_sysdep(char *s, void *dest, int a3)
{
char *i; // rbp
char *v5; // rax
char *v6; // rbx
__int64 v7; // r12
__int64 v8; // r13
size_t v9; // r15
const char *j; // r14
const char *v11; // r12
size_t v12; // rax
size_t v13; // rbx
size_t v14; // rax
size_t v15; // rbx

LABEL_2:
for ( i = (char *)dest; ; i += v13 )
{
v5 = strchr(s, 37);
if ( !v5 )
break;
v6 = v5 + 1;
v7 = v5 + 1 - s;
if ( dest )
memcpy(i, s, v5 + 1 - s);
i += v7;
v8 = 0LL;
v9 = 8LL;
for ( j = "<PRIu32>"; strncmp(v6, j, v9); v9 = strlen(j) )
{
if ( ++v8 == 3 )
{
s = v6;
goto LABEL_2;
}
j = sysdep_str[v8];
}
s = &v6[v9];
v11 = (&sysdep_repl[3 * (int)v8])[a3];
v12 = strlen(v11);
v13 = v12;
if ( dest )
memcpy(i, v11, v12);
}
v14 = strlen(s);
v15 = v14;
if ( dest )
memcpy(i, s, v14 + 1);
return &i[v15] - (_BYTE *)dest;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s, void *dest, int a3)
{
char *i; // rbp
char *v5; // rax
char *v6; // rbx
__int64 v7; // r12
__int64 v8; // r13
size_t v9; // r15
const char *j; // r14
const char *v11; // r12
size_t v12; // rax
size_t v13; // rbx
size_t v14; // rax
size_t v15; // rbx

LABEL_2:
for ( i = (char *)dest; ; i += v13 )
{
v5 = strchr(s, 37);
if ( !v5 )
break;
v6 = v5 + 1;
v7 = v5 + 1 - s;
if ( dest )
memcpy(i, s, v5 + 1 - s);
i += v7;
v8 = 0LL;
v9 = 8LL;
for ( j = "<PRIu32>"; strncmp(v6, j, v9); v9 = strlen(j) )
{
if ( ++v8 == 3 )
{
s = v6;
goto LABEL_2;
}
j = sysdep_str[v8];
}
s = &v6[v9];
v11 = (&sysdep_repl[3 * (int)v8])[a3];
v12 = strlen(v11);
v13 = v12;
if ( dest )
memcpy(i, v11, v12);
}
v14 = strlen(s);
v15 = v14;
if ( dest )
memcpy(i, s, v14 + 1);
return &i[v15] - (_BYTE *)dest;
}

original_code:
size_t poparser_sysdep(const char *in, char *out, int num) {
 const char *x, *y, *outs;
 size_t m;
 int n;
 outs = out;
 x = in;
 while ((y = strchr(x, '%'))) {
  y++;
  if (outs)
   memcpy(out, x, y-x);
  out += y-x;
  x = y;
  for (n=0; n < st_max; n++) {
   m = strlen(sysdep_str[n]);
   if (!strncmp(y, sysdep_str[n], m)) {
    x = y + m;
    y = sysdep_repl[n][num];
    m = strlen(y);
    if (outs)
     memcpy(out, y, m);
    out += m;
    break;
   }
  }
 }
 m = strlen(x);
 if (outs)
  memcpy(out, x, m+1);
 out += m;
 return out - outs;
}

canonical_original_code:
unsigned long poparser_sysdep(char *in, char *out, int num) {
 char *x; char *y; char *outs;
 unsigned long m;
 int n;
 outs = out;
 x = in;
 while ((y = strchr(x, '%'))) {
  y++;
  if (outs)
   memcpy(out, x, y-x);
  out += y-x;
  x = y;
  for (n=0; n < st_max; n++) {
   m = strlen(sysdep_str[n]);
   if (!strncmp(y, sysdep_str[n], m)) {
    x = y + m;
    y = sysdep_repl[n][num];
    m = strlen(y);
    if (outs)
     memcpy(out, y, m);
    out += m;
    break;
   }
  }
 }
 m = strlen(x);
 if (outs)
  memcpy(out, x, m+1);
 out += m;
 return out - outs;
}

variable_types:
out
char *

variable_types: num int

variable_types:
outs
char *

variable_types:
m
unsigned long

variable_types: n int

return_type: unsigned long


decompiled_code:
int __fastcall strtbl_cmp(const void *a1, const void *a2)
{
return strcmp(
(const char *)(*((unsigned int *)a1 + 1) + *(_QWORD *)(cb_for_qsort + 40)),
(const char *)(*(_QWORD *)(cb_for_qsort + 40) + *((unsigned int *)a2 + 1)));
}

canonical_decompiled_code:
int __fastcall func0(const void *a1, const void *a2)
{
return strcmp(
(const char *)(*((unsigned int *)a1 + 1) + *(_QWORD *)(cb_for_qsort + 40)),
(const char *)(*(_QWORD *)(cb_for_qsort + 40) + *((unsigned int *)a2 + 1)));
}

original_code:
int strtbl_cmp(const void *a_, const void *b_) {
 const struct strmap *a = a_, *b = b_;
 return strcmp(cb_for_qsort->buf[0] + a->str.off, cb_for_qsort->buf[0] + b->str.off);
}

canonical_original_code:
int strtbl_cmp(void *a_, void *b_) {
 struct strmap *a = a_; struct strmap *b = b_;
 return strcmp(cb_for_qsort->buf[0] + a->str.off, cb_for_qsort->buf[0] + b->str.off);
}

variable_types: struct strmap { struct strtbl { unsigned int len; } str; struct strtbl trans; } *

user_defined_types: struct strmap { struct strtbl str; struct strtbl trans; }