zzresynch

decompiled_code:
__int64 __fastcall zzresynch(__int64 a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( consumed_2 )
{
result = zztoken;
if ( (a2 & *(_BYTE *)(a1 + zztoken)) != 0 || zztoken == 1 )
{
consumed_2 = 0;
}
else
{
do
{
zzgettok();
result = zztoken;
}
while ( (*(_BYTE *)(a1 + zztoken) & a2) == 0 && zztoken != 1 );
consumed_2 = 1;
}
}
else
{
result = zzgettok();
consumed_2 = 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( consumed_2 )
{
result = zztoken;
if ( (a2 & *(_BYTE *)(a1 + zztoken)) != 0 || zztoken == 1 )
{
consumed_2 = 0;
}
else
{
do
{
zzgettok();
result = zztoken;
}
while ( (*(_BYTE *)(a1 + zztoken) & a2) == 0 && zztoken != 1 );
consumed_2 = 1;
}
}
else
{
result = zzgettok();
consumed_2 = 1;
}
return result;
}

original_code:
void
zzresynch(SetWordType *wd,SetWordType mask)
{
 static int consumed = 1;
 if ( !consumed ) {zzgettok();; consumed=1; return;}
 if ( wd[zztoken]&mask || zztoken == 1 ) {consumed=0; return;}
 while ( !(wd[zztoken]&mask) && zztoken != 1 ) {zzgettok();;}
 consumed=1;
}

canonical_original_code:
void zzresynch(unsigned char *wd, unsigned char mask)
{
 static int consumed = 1;
 if ( !consumed ) {zzgettok();; consumed=1; return;}
 if ( wd[zztoken]&mask || zztoken == 1 ) {consumed=0; return;}
 while ( !(wd[zztoken]&mask) && zztoken != 1 ) {zzgettok();;}
 consumed=1;
}

variable_types:
wd
unsigned char *

variable_types:
mask
unsigned char

variable_types: consumed int


zzconsumeUntilToken

repo: AlertProject/CCCC

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

for ( result = zztoken; zztoken != 1 && zztoken != a1; result = zztoken )
zzgettok();
return result;
}

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

for ( result = zztoken; zztoken != 1 && zztoken != a1; result = zztoken )
zzgettok();
return result;
}

original_code:
void
zzconsumeUntilToken(int t)
{
    int tmp;
 while ( (tmp=zztoken) !=t && tmp!=1 ) { zzgettok();; }
}

variable_types: t int

variable_types: tmp int

return_type: void


zzTraceGuessDone

decompiled_code:
void zzTraceGuessDone()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void zzTraceGuessDone(zzantlr_state *state)
{
}

canonical_original_code:
void zzTraceGuessDone(struct _zzantlr_state *state)
{
}

variable_types: struct _zzantlr_state { int asp; int ast_sp; int token; char text[2000]; } *


decompiled_code:
char *__fastcall zzsave_antlr_state(__int64 a1)
{
*(_DWORD *)a1 = zzasp;
*(_DWORD *)(a1 + 8) = zztoken;
return strcpy((char *)(a1 + 12), zzlextext);
}

canonical_decompiled_code:
char *__fastcall func3(__int64 a1)
{
*(_DWORD *)a1 = zzasp;
*(_DWORD *)(a1 + 8) = zztoken;
return strcpy((char *)(a1 + 12), zzlextext);
}

original_code:
void
zzsave_antlr_state(zzantlr_state *buf)
{
 buf->asp = zzasp;
 buf->token = zztoken;
 strcpy(buf->text, zzlextext);
}

canonical_original_code:
void zzsave_antlr_state(struct _zzantlr_state *buf)
{
 buf->asp = zzasp;
 buf->token = zztoken;
 strcpy(buf->text, zzlextext);
}

user_defined_types: struct _zzantlr_state { int asp; int ast_sp; int token; char text[2000]; }


decompiled_code:
char *__fastcall zzrestore_antlr_state(__int64 a1)
{
zzasp = *(_DWORD *)a1;
zztoken = *(_DWORD *)(a1 + 8);
return strcpy(zzlextext, (const char *)(a1 + 12));
}

canonical_decompiled_code:
char *__fastcall func4(__int64 a1)
{
zzasp = *(_DWORD *)a1;
zztoken = *(_DWORD *)(a1 + 8);
return strcpy(zzlextext, (const char *)(a1 + 12));
}

original_code:
void
zzrestore_antlr_state(zzantlr_state *buf)
{
 zzasp = buf->asp;
 zztoken = buf->token;
 strcpy(zzlextext, buf->text);
}

canonical_original_code:
void zzrestore_antlr_state(struct _zzantlr_state *buf)
{
 zzasp = buf->asp;
 zztoken = buf->token;
 strcpy(zzlextext, buf->text);
}


decompiled_code:
__int64 __fastcall zzset_el(unsigned int a1, __int64 a2)
{
return (unsigned __int8)(bitmask[a1 & 7] & *(_BYTE *)(a2 + (a1 >> 3)));
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, __int64 a2)
{
return (unsigned __int8)(bitmask[a1 & 7] & *(_BYTE *)(a2 + (a1 >> 3)));
}

original_code:
int
zzset_el(unsigned b, SetWordType *p)
{
 return( p[((b) >> 3)] & bitmask[((b) & (8 -1))] );
}

canonical_original_code:
int zzset_el(unsigned int b, unsigned char *p)
{
 return( p[((b) >> 3)] & bitmask[((b) & (8 -1))] );
}

variable_types:
b
unsigned int

variable_types:
p
unsigned char *

return_type: int


zzconsumeUntil

decompiled_code:
__int64 __fastcall zzconsumeUntil(__int64 a1)
{
int v1; // ebx
__int64 result; // rax

while ( 1 )
{
v1 = zztoken;
result = zzset_el(zztoken, a1);
if ( v1 == 1 || (_DWORD)result )
break;
zzgettok();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int v1; // ebx
__int64 result; // rax

while ( 1 )
{
v1 = zztoken;
result = func5(zztoken, a1);
if ( v1 == 1 || (_DWORD)result )
break;
zzgettok();
}
return result;
}

original_code:
void
zzconsumeUntil(SetWordType *st)
{
    int tmp;
 while ( !zzset_el( (tmp=zztoken), st) && tmp!=1 ) {
                                                      zzgettok();; }
}

canonical_original_code:
void zzconsumeUntil(unsigned char *st)
{
    int tmp;
 while ( !zzset_el( (tmp=zztoken), st) && tmp!=1 ) {
                                                      zzgettok();; }
}

variable_types:
st
unsigned char *


zzTraceReset

decompiled_code:
void zzTraceReset()
{
;
}

canonical_decompiled_code:
void func16()
{
;
}

original_code:
void zzTraceReset(void)
{
}

canonical_original_code:
void zzTraceReset()
{
}


zzTraceGuessFail

decompiled_code:
void zzTraceGuessFail()
{
;
}

canonical_decompiled_code:
void func17()
{
;
}

original_code:
void zzTraceGuessFail(void)
{
}

canonical_original_code:
void zzTraceGuessFail()
{
}


zzTraceIn

decompiled_code:
void zzTraceIn()
{
;
}

canonical_decompiled_code:
void func18()
{
;
}

original_code:
void zzTraceIn(char * rule)
{
  return;
}

canonical_original_code:
void zzTraceIn(char *rule)
{
  return;
}

variable_types:
rule
char *


zzTraceOut

decompiled_code:
void zzTraceOut()
{
;
}

canonical_decompiled_code:
void func19()
{
;
}

original_code:
void zzTraceOut(char * rule)
{
}

canonical_original_code:
void zzTraceOut(char *rule)
{
}


zzTraceOption

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

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

original_code:
int zzTraceOption(int delta)
{
    return 0;
}

variable_types: delta int


zzTraceGuessOption

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

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

original_code:
int zzTraceGuessOption(int delta)
{
    return 0;
}


decompiled_code:
void __fastcall __noreturn internal_error(char *format, __int64 a2, unsigned int a3)
{
fprintf(stderr, format, a2, a3);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(char *format, __int64 a2, unsigned int a3)
{
fprintf(stderr, format, a2, a3);
exit(1);
}

original_code:
void internal_error(char *s, char *file,int line)
{
 fprintf(stderr,s,file,line);
 exit(1);
}

canonical_original_code:
void internal_error(char *s, char *file, int line)
{
 fprintf(stderr,s,file,line);
 exit(1);
}

variable_types:
s
char *

variable_types:
file
char *

variable_types: line int


decompiled_code:
void *__fastcall dlg_malloc(int a1, __int64 a2, unsigned int a3)
{
void *result; // rax

result = malloc(a1);
if ( !result )
internal_error("%s(%d): unable to allocate memory\n", a2, a3);
return result;
}

canonical_decompiled_code:
void *__fastcall func1(int a1, __int64 a2, unsigned int a3)
{
void *result; // rax

result = malloc(a1);
if ( !result )
func0("%s(%d): unable to allocate memory\n", a2, a3);
return result;
}

original_code:
char *dlg_malloc(int bytes,char *file,int line)
{
 char *t;
 t = (char *) malloc(bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

canonical_original_code:
char *dlg_malloc(int bytes, char *file, int line)
{
 char *t;
 t = (char *) malloc(bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

variable_types: bytes int

variable_types:
t
char *

return_type: char *


decompiled_code:
void *__fastcall dlg_calloc(int a1, int a2, __int64 a3, unsigned int a4)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
internal_error("%s(%d): unable to allocate memory\n", a3, a4);
return result;
}

canonical_decompiled_code:
void *__fastcall func2(int a1, int a2, __int64 a3, unsigned int a4)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
func0("%s(%d): unable to allocate memory\n", a3, a4);
return result;
}

original_code:
char *dlg_calloc(int n,int bytes,char *file,int line)
{
 char *t;
 t = (char *) calloc(n,bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

canonical_original_code:
char *dlg_calloc(int n, int bytes, char *file, int line)
{
 char *t;
 t = (char *) calloc(n,bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

variable_types: n int


fatal

decompiled_code:
void __fastcall __noreturn fatal(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
fprintf(stderr, " Fatal: %s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
fprintf(stderr, " Fatal: %s\n", a1);
exit(1);
}

original_code:
void fatal(char *message,int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Fatal: %s\n", message);
 exit(1);
}

canonical_original_code:
void fatal(char *message, int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Fatal: %s\n", message);
 exit(1);
}

variable_types:
message
char *


warning

decompiled_code:
int __fastcall warning(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
return fprintf(stderr, " Warning: %s\n", a1);
}

canonical_decompiled_code:
int __fastcall func6(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
return fprintf(stderr, " Warning: %s\n", a1);
}

original_code:
void warning(char *message,int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Warning: %s\n", message);
}

canonical_original_code:
void warning(char *message, int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Warning: %s\n", message);
}


error

decompiled_code:
int __fastcall error(const char *a1, unsigned int a2)
{
const char *v2; // rdx
int result; // eax

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
result = fprintf(stderr, " Error: %s\n", a1);
err_found = 1;
return result;
}

canonical_decompiled_code:
int __fastcall func5(const char *a1, unsigned int a2)
{
const char *v2; // rdx
int result; // eax

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
result = fprintf(stderr, " Error: %s\n", a1);
err_found = 1;
return result;
}

original_code:
void error(char *message,int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Error: %s\n", message);
 err_found = 1;
}

canonical_original_code:
void error(char *message, int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Error: %s\n", message);
 err_found = 1;
}


OutMetaName

decompiled_code:
char *__fastcall OutMetaName(char *s)
{
char *v1; // rbx
const char *v2; // rbp
char *v3; // rdx
char *v4; // rax
size_t v5; // rax

v1 = s;
v2 = OutputDirectory;
v3 = s;
if ( strcmp(OutputDirectory, ".") )
{
v4 = strrchr(s, 47);
if ( v4 )
v1 = v4 + 1;
strcpy(newname_0, v2);
v5 = strlen(newname_0);
if ( byte_31F[v5] != 47 )
*(_WORD *)&newname_0[v5] = 47;
strcat(newname_0, v1);
v3 = newname_0;
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func7(char *s)
{
char *v1; // rbx
const char *v2; // rbp
char *v3; // rdx
char *v4; // rax
size_t v5; // rax

v1 = s;
v2 = OutputDirectory;
v3 = s;
if ( strcmp(OutputDirectory, ".") )
{
v4 = strrchr(s, 47);
if ( v4 )
v1 = v4 + 1;
strcpy(newname_0, v2);
v5 = strlen(newname_0);
if ( byte_31F[v5] != 47 )
*(_WORD *)&newname_0[v5] = 47;
strcat(newname_0, v1);
v3 = newname_0;
}
return v3;
}

original_code:
char *OutMetaName(char *n)
{
    static char *dir_sym = "/";
    static char newname[300 +1];
    char *p;
    if (strcmp(OutputDirectory, ".") == 0)
  return n;
 if ((p = strrchr(n, *dir_sym)) != ((void *)0))
  p++;
 else
  p = n;
 strcpy(newname, OutputDirectory);
 if (newname[strlen(newname)-1] != *dir_sym)
  strcat(newname, dir_sym);
 strcat(newname, p);
 return newname;
}

canonical_original_code:
char *OutMetaName(char *n)
{
    static char *dir_sym = "/";
    static char newname[-1];
    char *p;
    if (strcmp(OutputDirectory, ".") == 0)
  return n;
 if ((p = strrchr(n, *dir_sym)) != ((void *)0))
  p++;
 else
  p = n;
 strcpy(newname, OutputDirectory);
 if (newname[strlen(newname)-1] != *dir_sym)
  strcat(newname, dir_sym);
 strcat(newname, p);
 return newname;
}

variable_types:
n
char *

variable_types:
newname
char [-1]

variable_types:
p
char *


newHashTable

decompiled_code:
void *newHashTable()
{
void *v0; // rax
void *v1; // rbx
void *v3; // rax

v0 = calloc(0x229uLL, 8uLL);
if ( !v0 )
{
fprintf(stderr, "%s(%d):", "hash.c", 78LL);
fprintf(stderr, " %s\n", "cannot allocate hash table");
exit(1);
}
v1 = v0;
if ( !strings )
{
v3 = calloc(0xF4240uLL, 1uLL);
strings = (__int64)v3;
if ( !v3 )
{
fprintf(stderr, "%s(%d):", "hash.c", 82LL);
fprintf(stderr, " %s\n", "cannot allocate string table");
exit(1);
}
strp = (__int64)v3;
}
return v1;
}

canonical_decompiled_code:
void *func0()
{
void *v0; // rax
void *v1; // rbx
void *v3; // rax

v0 = calloc(0x229uLL, 8uLL);
if ( !v0 )
{
fprintf(stderr, "%s(%d):", "hash.c", 78LL);
fprintf(stderr, " %s\n", "cannot allocate hash table");
exit(1);
}
v1 = v0;
if ( !strings )
{
v3 = calloc(0xF4240uLL, 1uLL);
strings = (__int64)v3;
if ( !v3 )
{
fprintf(stderr, "%s(%d):", "hash.c", 82LL);
fprintf(stderr, " %s\n", "cannot allocate string table");
exit(1);
}
strp = (__int64)v3;
}
return v1;
}

original_code:
Entry **
newHashTable( void )
{
 Entry **table;
 table = (Entry **) calloc(size, sizeof(Entry *));
 {if ( !(table != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 78); fprintf(stderr, " %s\n", "cannot allocate hash table"); exit(1);};};
 if ( strings == ((void *)0) )
 {
  strings = (char *) calloc(strsize, sizeof(char));
  {if ( !(strings != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 82); fprintf(stderr, " %s\n", "cannot allocate string table"); exit(1);};};
  strp = strings;
 }
 return table;
}

canonical_original_code:
struct _entry **newHashTable()
{
 struct _entry **table;
 table = (struct _entry **) calloc(size, sizeof(struct _entry *));
 {if ( !(table != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 78); fprintf(stderr, " %s\n", "cannot allocate hash table"); exit(1);};};
 if ( strings == ((void *)0) )
 {
  strings = (char *) calloc(strsize, sizeof(char));
  {if ( !(strings != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 82); fprintf(stderr, " %s\n", "cannot allocate string table"); exit(1);};};
  strp = strings;
 }
 return table;
}

variable_types: struct _entry { char *str; struct _entry *next; } **


killHashTable

decompiled_code:
void __fastcall killHashTable(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func1(void *a1)
{
free(a1);
}

original_code:
void
killHashTable( Entry **table )
{
 free( (char *) table );
}

canonical_original_code:
void killHashTable(struct _entry **table)
{
 free( (char *) table );
}

user_defined_types: struct _entry { char *str; struct _entry *next; }


decompiled_code:
__int64 __fastcall hash_add(__int64 a1, char *a2, __int64 a3)
{
char v4; // al
unsigned int i; // edx
_QWORD *v6; // rax

if ( a3 == 0 || a1 == 0 || !a2 )
{
fprintf(stderr, "%s(%d):", "hash.c", 113LL);
fprintf(stderr, " %s\n", "add: invalid addition");
exit(1);
}
v4 = *a2;
for ( i = 0; *a2; v4 = *a2 )
{
++a2;
i = v4 + 2 * i;
}
v6 = (_QWORD *)(a1 + 8LL * (i % 0x229));
*(_QWORD *)(a3 + 8) = *v6;
*v6 = a3;
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char *a2, __int64 a3)
{
char v4; // al
unsigned int i; // edx
_QWORD *v6; // rax

if ( a3 == 0 || a1 == 0 || !a2 )
{
fprintf(stderr, "%s(%d):", "hash.c", 113LL);
fprintf(stderr, " %s\n", "add: invalid addition");
exit(1);
}
v4 = *a2;
for ( i = 0; *a2; v4 = *a2 )
{
++a2;
i = v4 + 2 * i;
}
v6 = (_QWORD *)(a1 + 8LL * (i % 0x229));
*(_QWORD *)(a3 + 8) = *v6;
*v6 = a3;
return a3;
}

original_code:
Entry *
hash_add( Entry **table, char *key, Entry *rec )
{
 unsigned h=0;
 char *p=key;
 {if ( !(table!=((void *)0) && key!=((void *)0) && rec!=((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 113); fprintf(stderr, " %s\n", "add: invalid addition"); exit(1);};};
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 rec->next = table[h];
 table[h] = rec;
 return rec;
}

canonical_original_code:
struct _entry *hash_add(struct _entry **table, char *key, struct _entry *rec)
{
 unsigned int h = 0;
 char *p = key;
 {if ( !(table!=((void *)0) && key!=((void *)0) && rec!=((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 113); fprintf(stderr, " %s\n", "add: invalid addition"); exit(1);};};
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 rec->next = table[h];
 table[h] = rec;
 return rec;
}

variable_types:
table
struct _entry **

variable_types:
key
char *

variable_types:
rec
struct _entry *

variable_types:
h
unsigned int

return_type: struct _entry { char *str; struct _entry *next; } *


decompiled_code:
// write access to const memory has been detected, the output may be wrong!
__int64 __fastcall hash_get(__int64 a1, const char *a2)
{
char v2; // al
char *v3; // rdx
unsigned int v4; // ecx
__int64 i; // rbx

if ( !a1 || !a2 )
loc_22 = 3;
v2 = *a2;
if ( *a2 )
{
v3 = (char *)a2;
v4 = 0;
do
{
++v3;
v4 = v2 + 2 * v4;
v2 = *v3;
}
while ( *v3 );
}
else
{
v4 = 0;
}
for ( i = *(_QWORD *)(a1 + 8LL * (v4 % 0x229)); i; i = *(_QWORD *)(i + 8) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2)
{
char v2; // al
char *v3; // rdx
unsigned int v4; // ecx
__int64 i; // rbx

if ( !a1 || !a2 )
loc_22 = 3;
v2 = *a2;
if ( *a2 )
{
v3 = (char *)a2;
v4 = 0;
do
{
++v3;
v4 = v2 + 2 * v4;
v2 = *v3;
}
while ( *v3 );
}
else
{
v4 = 0;
}
for ( i = *(_QWORD *)(a1 + 8LL * (v4 % 0x229)); i; i = *(_QWORD *)(i + 8) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

original_code:
Entry *
hash_get( Entry **table, char *key )
{
 unsigned h=0;
 char *p=key;
 Entry *q;
 if ( !(table!=((void *)0) && key!=((void *)0)) ) *((char *) 34) = 3;
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 for (q = table[h]; q != ((void *)0); q = q->next)
 {
  if ( strcmp(key, q->str) == 0 ) return( q );
 }
 return( ((void *)0) );
}

canonical_original_code:
struct _entry *hash_get(struct _entry **table, char *key)
{
 unsigned int h = 0;
 char *p = key;
 struct _entry *q;
 if ( !(table!=((void *)0) && key!=((void *)0)) ) *((char *) 34) = 3;
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 for (q = table[h]; q != ((void *)0); q = q->next)
 {
  if ( strcmp(key, q->str) == 0 ) return( q );
 }
 return( ((void *)0) );
}

variable_types: struct _entry { char *str; struct _entry *next; } *


mystrdup

decompiled_code:
__int64 __fastcall mystrdup(char *a1)
{
__int64 v1; // r9
char v2; // dl
unsigned __int64 v3; // rcx
_BYTE *v4; // rax
char v5; // si
_BYTE *v6; // rax

v1 = strp;
if ( !a1 )
{
fprintf(stderr, "%s(%d):", "hash.c", 210LL);
fprintf(stderr, " %s\n", "mystrdup: NULL string");
exit(1);
}
v2 = *a1;
if ( *a1 )
{
v3 = strings + 999998;
v4 = (_BYTE *)strp;
v5 = 0;
do
{
if ( v3 < (unsigned __int64)v4 )
{
if ( v5 )
strp = (__int64)v4;
fprintf(stderr, "%s(%d):", "hash.c", 214LL);
fprintf(stderr, " %s\n", "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n");
exit(1);
}
++a1;
*v4++ = v2;
v2 = *a1;
v5 = 1;
}
while ( *a1 );
strp = (__int64)v4;
}
v6 = (_BYTE *)strp++;
*v6 = 0;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
__int64 v1; // r9
char v2; // dl
unsigned __int64 v3; // rcx
_BYTE *v4; // rax
char v5; // si
_BYTE *v6; // rax

v1 = strp;
if ( !a1 )
{
fprintf(stderr, "%s(%d):", "hash.c", 210LL);
fprintf(stderr, " %s\n", "mystrdup: NULL string");
exit(1);
}
v2 = *a1;
if ( *a1 )
{
v3 = strings + 999998;
v4 = (_BYTE *)strp;
v5 = 0;
do
{
if ( v3 < (unsigned __int64)v4 )
{
if ( v5 )
strp = (__int64)v4;
fprintf(stderr, "%s(%d):", "hash.c", 214LL);
fprintf(stderr, " %s\n", "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n");
exit(1);
}
++a1;
*v4++ = v2;
v2 = *a1;
v5 = 1;
}
while ( *a1 );
strp = (__int64)v4;
}
v6 = (_BYTE *)strp++;
*v6 = 0;
return v1;
}

original_code:
char *
mystrdup( char *s )
{
 char *start=strp;
 {if ( !(s!=((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 210); fprintf(stderr, " %s\n", "mystrdup: NULL string"); exit(1);};};
 while ( *s != '\0' )
 {
  {if ( !(strp <= &(strings[strsize-2])) ) {fprintf(stderr, "%s(%d):", "hash.c", 214); fprintf(stderr, " %s\n", "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n"); exit(1);};};
  *strp++ = *s++;
 }
 *strp++ = '\0';
 return( start );
}

canonical_original_code:
char *mystrdup(char *s)
{
 char *start = strp;
 {if ( !(s!=((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 210); fprintf(stderr, " %s\n", "mystrdup: NULL string"); exit(1);};};
 while ( *s != '\0' )
 {
  {if ( !(strp <= &(strings[strsize-2])) ) {fprintf(stderr, "%s(%d):", "hash.c", 214); fprintf(stderr, " %s\n", "string table overflow\nIncrease StrTableSize in hash.h and recompile hash.c\n"); exit(1);};};
  *strp++ = *s++;
 }
 *strp++ = '\0';
 return( start );
}

variable_types:
start
char *


decompiled_code:
const char **__fastcall dumpFcache1(const char *a1)
{
__int64 *v1; // r14
__int64 v2; // r15
const char **v3; // r12
__int64 v4; // rbx
const char *v5; // rbp
int v7; // [rsp+4h] [rbp-44h]
__int64 v8; // [rsp+8h] [rbp-40h]

v1 = (__int64 *)Fcache;
v8 = Fcache;
v2 = Fcache + 4424LL;
v3 = 0LL;
v7 = 0;
do
{
v4 = *v1;
if ( !*v1 || v7 )
{
if ( !v4 )
goto LABEL_10;
}
else
{
v7 = ((__int64)v1 - v8) >> 3;
}
do
{
v5 = *(const char **)v4;
if ( strcmp(*(const char **)v4, a1) > 0 )
{
if ( v3 )
{
if ( strcmp(v5, *v3) < 0 )
v3 = (const char **)v4;
}
else
{
v3 = (const char **)v4;
}
}
v4 = *(_QWORD *)(v4 + 8);
}
while ( v4 );
LABEL_10:
++v1;
}
while ( v1 != (__int64 *)v2 );
return v3;
}

canonical_decompiled_code:
const char **__fastcall func0(const char *a1)
{
__int64 *v1; // r14
__int64 v2; // r15
const char **v3; // r12
__int64 v4; // rbx
const char *v5; // rbp
int v7; // [rsp+4h] [rbp-44h]
__int64 v8; // [rsp+8h] [rbp-40h]

v1 = (__int64 *)Fcache;
v8 = Fcache;
v2 = Fcache + 4424LL;
v3 = 0LL;
v7 = 0;
do
{
v4 = *v1;
if ( !*v1 || v7 )
{
if ( !v4 )
goto LABEL_10;
}
else
{
v7 = ((__int64)v1 - v8) >> 3;
}
do
{
v5 = *(const char **)v4;
if ( strcmp(*(const char **)v4, a1) > 0 )
{
if ( v3 )
{
if ( strcmp(v5, *v3) < 0 )
v3 = (const char **)v4;
}
else
{
v3 = (const char **)v4;
}
}
v4 = *(_QWORD *)(v4 + 8);
}
while ( v4 );
LABEL_10:
++v1;
}
while ( v1 != (__int64 *)v2 );
return v3;
}

original_code:
CacheEntry *dumpFcache1(char *prev)
{
    Entry **table=Fcache;
    int low=0;
    int hi=0;
    CacheEntry *least=((void *)0);
 Entry **p;
 for (p=table; p<&(table[553]); p++) {
  CacheEntry *q =(CacheEntry *) *p;
  if ( q != ((void *)0) && low==0 ) low = p-table;
  while ( q != ((void *)0) ) {
            if (strcmp(q->str,prev) > 0) {
              if (least == ((void *)0)) {
                least=q;
              } else {
                if (strcmp(q->str,least->str) < 0) {
                  least=q;
                };
              };
            };
   q = q->next;
  };
  if ( *p != ((void *)0) ) hi = p-table;
 }
    return least;
}

canonical_original_code:
struct _f *dumpFcache1(char *prev)
{
    struct _entry **table = Fcache;
    int low = 0;
    int hi = 0;
    struct _f *least = ((void *)0);
 struct _entry **p;
 for (p=table; p<&(table[553]); p++) {
  struct _f *q = (CacheEntry *) *p;
  if ( q != ((void *)0) && low==0 ) low = p-table;
  while ( q != ((void *)0) ) {
            if (strcmp(q->str,prev) > 0) {
              if (least == ((void *)0)) {
                least=q;
              } else {
                if (strcmp(q->str,least->str) < 0) {
                  least=q;
                };
              };
            };
   q = q->next;
  };
  if ( *p != ((void *)0) ) hi = p-table;
 }
    return least;
}

variable_types:
prev
char *

variable_types: low int

variable_types: hi int

variable_types: struct _f { char *str; struct _f *next; struct _set { unsigned int n; unsigned int *setword; } fset; struct _set rk; int incomplete; } *

user_defined_types: struct _f { char *str; struct _f *next; struct _set fset; struct _set rk; int incomplete; }


reportFcache

decompiled_code:
__int64 __fastcall reportFcache(char **a1)
{
char *v2; // rbx
char v3; // di

fwrite("\nrule ", 1uLL, 6uLL, stdout);
v2 = *a1;
v3 = **a1;
if ( v3 != 42 )
{
do
{
fputc(v3, stdout);
v3 = *++v2;
}
while ( *v2 != 42 );
}
if ( v2[1] == 105 )
fwrite(" First[", 1uLL, 7uLL, stdout);
if ( v2[1] == 111 )
fwrite(" Follow[", 1uLL, 8uLL, stdout);
fprintf(stdout, "%s]", v2 + 2);
if ( *((_DWORD *)a1 + 12) )
fwrite(" *** incomplete ***", 1uLL, 0x13uLL, stdout);
fputc(10, stdout);
return MR_dumpTokenSet(stdout, 1LL, *((unsigned int *)a1 + 4), a1[3]);
}

canonical_decompiled_code:
__int64 __fastcall func1(char **a1)
{
char *v2; // rbx
char v3; // di

fwrite("\nrule ", 1uLL, 6uLL, stdout);
v2 = *a1;
v3 = **a1;
if ( v3 != 42 )
{
do
{
fputc(v3, stdout);
v3 = *++v2;
}
while ( *v2 != 42 );
}
if ( v2[1] == 105 )
fwrite(" First[", 1uLL, 7uLL, stdout);
if ( v2[1] == 111 )
fwrite(" Follow[", 1uLL, 8uLL, stdout);
fprintf(stdout, "%s]", v2 + 2);
if ( *((_DWORD *)a1 + 12) )
fwrite(" *** incomplete ***", 1uLL, 0x13uLL, stdout);
fputc(10, stdout);
return MR_dumpTokenSet(stdout, 1LL, *((unsigned int *)a1 + 4), a1[3]);
}

original_code:
void reportFcache(CacheEntry *q)
{
    char *qstr;
    fprintf(stdout,"\nrule ");
    for (qstr=q->str; *qstr != '*' ; qstr++) {
      fprintf(stdout,"%c",*qstr);
    };
    qstr++;
    if (*qstr == 'i') fprintf(stdout," First[");
    if (*qstr == 'o') fprintf(stdout," Follow[");
    qstr++;
    fprintf(stdout,"%s]",qstr);
    if (q->incomplete) fprintf(stdout," *** incomplete ***");
    fprintf(stdout,"\n");
    MR_dumpTokenSet(stdout,1,q->fset);
}

canonical_original_code:
void reportFcache(struct _f *q)
{
    char *qstr;
    fprintf(stdout,"\nrule ");
    for (qstr=q->str; *qstr != '*' ; qstr++) {
      fprintf(stdout,"%c",*qstr);
    };
    qstr++;
    if (*qstr == 'i') fprintf(stdout," First[");
    if (*qstr == 'o') fprintf(stdout," Follow[");
    qstr++;
    fprintf(stdout,"%s]",qstr);
    if (q->incomplete) fprintf(stdout," *** incomplete ***");
    fprintf(stdout,"\n");
    MR_dumpTokenSet(stdout,1,q->fset);
}

variable_types:
qstr
char *

user_defined_types: struct _set { unsigned int n; unsigned int *setword; }


DumpFcache

decompiled_code:
size_t DumpFcache()
{
const char *i; // rdi
char **v1; // rax
const char **v2; // rbx

fwrite("\n\nDump of First/Follow Cache\n", 1uLL, 0x1DuLL, stdout);
for ( i = (const char *)&unk_23D; ; i = *v2 )
{
v1 = (char **)dumpFcache1(i);
v2 = (const char **)v1;
if ( !v1 )
break;
reportFcache(v1);
}
return fwrite("\nEnd dump of First/Follow Cache\n", 1uLL, 0x20uLL, stdout);
}

canonical_decompiled_code:
size_t func2()
{
const char *i; // rdi
char **v1; // rax
const char **v2; // rbx

fwrite("\n\nDump of First/Follow Cache\n", 1uLL, 0x1DuLL, stdout);
for ( i = (const char *)&unk_23D; ; i = *v2 )
{
v1 = (char **)func0(i);
v2 = (const char **)v1;
if ( !v1 )
break;
func1(v1);
}
return fwrite("\nEnd dump of First/Follow Cache\n", 1uLL, 0x20uLL, stdout);
}

original_code:
void
DumpFcache(void)
{
    char *prev="";
    int n=0;
    CacheEntry *next;
    fprintf(stdout,"\n\nDump of First/Follow Cache\n");
    for(;;) {
      next=dumpFcache1(prev);
      if (next == ((void *)0)) break;
      reportFcache(next);
      ++n;
      prev=next->str;
    };
    fprintf(stdout,"\nEnd dump of First/Follow Cache\n");
}

canonical_original_code:
void DumpFcache()
{
    char *prev = "";
    int n = 0;
    struct _f *next;
    fprintf(stdout,"\n\nDump of First/Follow Cache\n");
    for(;;) {
      next=dumpFcache1(prev);
      if (next == ((void *)0)) break;
      reportFcache(next);
      ++n;
      prev=next->str;
    };
    fprintf(stdout,"\nEnd dump of First/Follow Cache\n");
}

variable_types: n int


decompiled_code:
__int64 *clear_hash()
{
__int64 *result; // rax

result = &dfa_hash;
do
*result++ = 0LL;
while ( result != (__int64 *)(unsigned int)((_DWORD)&dfa_hash + 1688) );
return result;
}

canonical_decompiled_code:
__int64 *func0()
{
__int64 *result; // rax

result = &dfa_hash;
do
*result++ = 0LL;
while ( result != (__int64 *)(unsigned int)((_DWORD)&dfa_hash + 1688) );
return result;
}

original_code:
void
clear_hash(void)
{
 register int i;
 for(i=0; i<211; ++i)
  dfa_hash[i] = 0;
}

canonical_original_code:
void clear_hash()
{
 register int i;
 for(i=0; i<211; ++i)
  dfa_hash[i] = 0;
}

variable_types: i int


reach

decompiled_code:
__int64 __fastcall reach(_DWORD *a1, unsigned int a2, _DWORD *a3)
{
unsigned int v4; // er13
_DWORD *v5; // rbx
unsigned int v6; // eax
__int64 v7; // r15
int *v8; // rdx
int v9; // eax

v4 = 0;
if ( a1 )
{
v5 = a1;
v6 = *a1;
if ( *a1 == -1 )
{
v4 = 0;
}
else
{
do
{
v7 = *(_QWORD *)(nfa_array + 8LL * v6);
if ( (unsigned int)set_el(a2, *(unsigned int *)(v7 + 32), *(_QWORD *)(v7 + 40)) )
{
v8 = *(int **)(v7 + 16);
v9 = 0;
if ( v8 )
v9 = *v8;
*a3++ = v9;
v4 = 1;
}
v6 = *++v5;
}
while ( *v5 != -1 );
}
}
*a3 = -1;
return v4;
}

original_code:
int
reach(unsigned *nfa_list, register int a, unsigned *reach_list)
{
 register unsigned *e;
 register struct _nfa_node *node;
 int t=0;
 e = nfa_list;
 if (e){
  while (*e != (~((unsigned) 0))){
   node = (nfa_array[*e]);
   if (set_el(a,node->label)){
    t=1;
    *reach_list=( (node->trans[0]) ? (node->trans[0])->node_no : 0);
    ++reach_list;
   }
   ++e;
  }
 }
 *reach_list=(~((unsigned) 0));
 return t;
}

canonical_original_code:
int reach(unsigned int *nfa_list, int a, unsigned int *reach_list)
{
 register unsigned int *e;
 register struct _nfa_node *node;
 int t = 0;
 e = nfa_list;
 if (e){
  while (*e != (~((unsigned int) 0))){
   node = (nfa_array[*e]);
   if (set_el(a,node->label)){
    t=1;
    *reach_list=( (node->trans[0]) ? (node->trans[0])->node_no : 0);
    ++reach_list;
   }
   ++e;
  }
 }
 *reach_list=(~((unsigned int) 0));
 return t;
}

variable_types: a int

variable_types:
e
unsigned int *

variable_types: struct _nfa_node { int node_no; int nfa_set; int accept; struct _nfa_node *trans[2]; struct _set { unsigned int n; unsigned int *setword; } label; } *

variable_types: t int

user_defined_types: struct _nfa_node { int node_no; int nfa_set; int accept; struct _nfa_node *trans[2]; struct _set label; }


decompiled_code:
void __fastcall close1(__int64 a1, unsigned int a2, __int64 a3)
{
unsigned int *v4; // r13
unsigned int *v5; // rbx

*(_DWORD *)(a1 + 4) = a2;
v4 = *(unsigned int **)(a1 + 16);
if ( v4 && (unsigned int)set_nil(*(unsigned int *)(a1 + 32), *(_QWORD *)(a1 + 40)) && v4[1] != a2 )
{
set_orel(*v4, a3);
close1(v4, a2, a3);
}
v5 = *(unsigned int **)(a1 + 24);
if ( v5 )
{
if ( v5[1] != a2 )
{
set_orel(*v5, a3);
close1(v5, a2, a3);
}
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, unsigned int a2, __int64 a3)
{
unsigned int *v4; // r13
unsigned int *v5; // rbx

*(_DWORD *)(a1 + 4) = a2;
v4 = *(unsigned int **)(a1 + 16);
if ( v4 && (unsigned int)set_nil(*(unsigned int *)(a1 + 32), *(_QWORD *)(a1 + 40)) && v4[1] != a2 )
{
set_orel(*v4, a3);
func3(v4, a2, a3);
}
v5 = *(unsigned int **)(a1 + 24);
if ( v5 )
{
if ( v5[1] != a2 )
{
set_orel(*v5, a3);
func3(v5, a2, a3);
}
}
}

original_code:
void close1(struct _nfa_node *node, int o, set *b)
{
 register struct _nfa_node *n;
 node->nfa_set = o;
 if ((n=node->trans[0]) != 0 && set_nil(node->label) &&
   (n->nfa_set != o)){
  set_orel(( (n) ? (n)->node_no : 0),b);
  close1(n,o,b);
 }
 if ((n=node->trans[1]) != 0 &&
   (n->nfa_set != o)){
  set_orel(( (node->trans[1]) ? (node->trans[1])->node_no : 0),b);
  close1(n,o,b);
 }
}

canonical_original_code:
void close1(struct _nfa_node *node, int o, struct _set *b)
{
 register struct _nfa_node *n;
 node->nfa_set = o;
 if ((n=node->trans[0]) != 0 && set_nil(node->label) &&
   (n->nfa_set != o)){
  set_orel(( (n) ? (n)->node_no : 0),b);
  close1(n,o,b);
 }
 if ((n=node->trans[1]) != 0 &&
   (n->nfa_set != o)){
  set_orel(( (node->trans[1]) ? (node->trans[1])->node_no : 0),b);
  close1(n,o,b);
 }
}

variable_types: o int

variable_types:
b
struct _set *


closure

decompiled_code:
__int64 __fastcall closure(__int64 a1, unsigned int *a2)
{
unsigned int v3; // eax
unsigned int *v4; // rbp
unsigned int *v5; // rbx
unsigned int *v6; // rbx
__int64 v7; // rdi
unsigned int *v8; // r14

++operation_no;
v3 = *a2;
if ( *a2 != -1 )
{
v4 = a2;
do
{
v6 = *(unsigned int **)(nfa_array + 8LL * v3);
v7 = 0LL;
if ( v6 )
v7 = *v6;
set_orel(v7, a1);
v6[1] = operation_no;
v8 = (unsigned int *)*((_QWORD *)v6 + 2);
if ( v8 && (unsigned int)set_nil(v6[8], *((_QWORD *)v6 + 5)) && v8[1] != operation_no )
{
set_orel(*v8, a1);
close1((__int64)v8, operation_no, a1);
}
v5 = (unsigned int *)*((_QWORD *)v6 + 3);
if ( v5 && v5[1] != operation_no )
{
set_orel(*v5, a1);
close1((__int64)v5, operation_no, a1);
}
v3 = *++v4;
}
while ( *v4 != -1 );
}
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int *a2)
{
unsigned int v3; // eax
unsigned int *v4; // rbp
unsigned int *v5; // rbx
unsigned int *v6; // rbx
__int64 v7; // rdi
unsigned int *v8; // r14

++operation_no;
v3 = *a2;
if ( *a2 != -1 )
{
v4 = a2;
do
{
v6 = *(unsigned int **)(nfa_array + 8LL * v3);
v7 = 0LL;
if ( v6 )
v7 = *v6;
set_orel(v7, a1);
v6[1] = operation_no;
v8 = (unsigned int *)*((_QWORD *)v6 + 2);
if ( v8 && (unsigned int)set_nil(v6[8], *((_QWORD *)v6 + 5)) && v8[1] != operation_no )
{
set_orel(*v8, a1);
func3((__int64)v8, operation_no, a1);
}
v5 = (unsigned int *)*((_QWORD *)v6 + 3);
if ( v5 && v5[1] != operation_no )
{
set_orel(*v5, a1);
func3((__int64)v5, operation_no, a1);
}
v3 = *++v4;
}
while ( *v4 != -1 );
}
return *(_QWORD *)a1;
}

original_code:
set
closure(set *b, unsigned *reach_list)
{
 register struct _nfa_node *node,*n;
 register unsigned *e;
 ++operation_no;
 e=reach_list;
 while (*e != (~((unsigned) 0))){
  node = (nfa_array[*e]);
  set_orel(( (node) ? (node)->node_no : 0),b);
  node->nfa_set = operation_no;
  if ((n=node->trans[0]) != 0 && set_nil(node->label) &&
    (n->nfa_set != operation_no)){
   set_orel(( (n) ? (n)->node_no : 0),b);
   close1(n,operation_no,b);
  }
  if ((n=node->trans[1]) != 0 &&
    (n->nfa_set != operation_no)){
   set_orel(( (node->trans[1]) ? (node->trans[1])->node_no : 0),b);
   close1(n,operation_no,b);
  }
  ++e;
 }
 return *b;
}

canonical_original_code:
struct _set closure(struct _set *b, unsigned int *reach_list)
{
 register struct _nfa_node *node; register struct _nfa_node *n;
 register unsigned int *e;
 ++operation_no;
 e=reach_list;
 while (*e != (~((unsigned int) 0))){
  node = (nfa_array[*e]);
  set_orel(( (node) ? (node)->node_no : 0),b);
  node->nfa_set = operation_no;
  if ((n=node->trans[0]) != 0 && set_nil(node->label) &&
    (n->nfa_set != operation_no)){
   set_orel(( (n) ? (n)->node_no : 0),b);
   close1(n,operation_no,b);
  }
  if ((n=node->trans[1]) != 0 &&
    (n->nfa_set != operation_no)){
   set_orel(( (node->trans[1]) ? (node->trans[1])->node_no : 0),b);
   close1(n,operation_no,b);
  }
  ++e;
 }
 return *b;
}

return_type: struct _set { unsigned int n; unsigned int *setword; }


decompiled_code:
void *__fastcall nfa_to_dfa(unsigned int *a1)
{
unsigned int *v1; // rax
unsigned int *v2; // rbp
__int64 v3; // rdx
int *v4; // rax
int *v5; // r12
int v6; // er14
__int64 v7; // r15
int *v8; // rax
int v9; // edx
__int64 v10; // rbx
_DWORD *v11; // r13
__m128i ptr; // [rsp+0h] [rbp-48h] BYREF

v1 = (unsigned int *)malloc(4LL * (nfa_allocated + 2));
if ( !a1 )
return 0LL;
v2 = v1;
ptr.m128i_i32[0] = set_of(*a1);
ptr.m128i_i64[1] = v3;
set_pdq(ptr.m128i_u32[0], v3, v2);
closure((__int64)&ptr, v2);
v4 = (int *)dfastate(ptr.m128i_u32[0], ptr.m128i_i64[1]);
v5 = v4;
v6 = 0;
if ( v4 )
v6 = *v4;
v7 = 8LL * v6 + 8;
do
{
v5[3] = 1;
v11 = (_DWORD *)set_pdq((unsigned int)v5[4], *((_QWORD *)v5 + 3));
if ( class_no > 0 )
{
v10 = 0LL;
do
{
reach(v11, v10, v2);
if ( *v2 != -1 )
{
if ( ptr.m128i_i64[1] )
free((void *)ptr.m128i_i64[1]);
ptr = _mm_loadu_si128(&empty);
closure((__int64)&ptr, v2);
v8 = (int *)dfastate(ptr.m128i_u32[0], ptr.m128i_i64[1]);
v9 = 0;
if ( v8 )
v9 = *v8;
v5[v10 + 8] = v9;
v5[2] = 1;
}
++v10;
}
while ( class_no > (int)v10 );
}
free(v11);
++v6;
v5 = *(int **)((char *)dfa_array + v7);
v7 += 8LL;
}
while ( dfa_allocated >= v6 );
free(v2);
if ( ptr.m128i_i64[1] )
free((void *)ptr.m128i_i64[1]);
return dfa_array;
}

original_code:
struct _dfa_node **
nfa_to_dfa(struct _nfa_node *start)
{
 register struct _dfa_node *d_state, *trans_d_state;
 register int a;
 set t;
 int last_done;
 unsigned *nfa_list;
 unsigned *reach_list;
 reach_list = (unsigned *) malloc((2+nfa_allocated)*sizeof(unsigned));
 if (!start) return ((void *)0);
 t = set_of(( (start) ? (start)->node_no : 0));
 _set_pdq(t,reach_list);
 closure(&t,reach_list);
 d_state = dfastate(t);
 last_done = ( (d_state) ? (d_state)->node_no : 0);
 do {
  d_state->done = 1;
  nfa_list = set_pdq(d_state->nfa_states);
  for (a = 0; a<class_no; ++a) {
   reach(nfa_list,a,reach_list);
   if ((*reach_list)!=(~((unsigned) 0))) {
    {if ( (t).setword != ((void *)0) ) free((char *)((t).setword)); (t) = empty;};
    closure(&t,reach_list);
    trans_d_state = dfastate(t);
    d_state->trans[a] = ( (trans_d_state) ? (trans_d_state)->node_no : 0);
    d_state->alternatives = 1;
   }
  }
  free(nfa_list);
  ++last_done;
  d_state = (dfa_array[last_done]);
 } while (last_done<=dfa_allocated);
 free(reach_list);
 {if ( (t).setword != ((void *)0) ) free((char *)((t).setword)); (t) = empty;};
 return dfa_array;
}

canonical_original_code:
struct _dfa_node **nfa_to_dfa(struct _nfa_node *start)
{
 register struct _dfa_node *d_state; register struct _dfa_node *trans_d_state;
 register int a;
 struct _set t;
 int last_done;
 unsigned int *nfa_list;
 unsigned int *reach_list;
 reach_list = (unsigned int *) malloc((2+nfa_allocated)*sizeof(unsigned int));
 if (!start) return ((void *)0);
 t = set_of(( (start) ? (start)->node_no : 0));
 _set_pdq(t,reach_list);
 closure(&t,reach_list);
 d_state = dfastate(t);
 last_done = ( (d_state) ? (d_state)->node_no : 0);
 do {
  d_state->done = 1;
  nfa_list = set_pdq(d_state->nfa_states);
  for (a = 0; a<class_no; ++a) {
   reach(nfa_list,a,reach_list);
   if ((*reach_list)!=(~((unsigned int) 0))) {
    {if ( (t).setword != ((void *)0) ) free((char *)((t).setword)); (t) = empty;};
    closure(&t,reach_list);
    trans_d_state = dfastate(t);
    d_state->trans[a] = ( (trans_d_state) ? (trans_d_state)->node_no : 0);
    d_state->alternatives = 1;
   }
  }
  free(nfa_list);
  ++last_done;
  d_state = (dfa_array[last_done]);
 } while (last_done<=dfa_allocated);
 free(reach_list);
 {if ( (t).setword != ((void *)0) ) free((char *)((t).setword)); (t) = empty;};
 return dfa_array;
}

variable_types: struct _nfa_node { int node_no; int nfa_set; int accept; struct _nfa_node *trans[2]; struct _set label; } *

return_type: struct _dfa_node { int node_no; int dfa_set; int alternatives; int done; struct _set { unsigned int n; unsigned int *setword; } nfa_states; int trans[1]; } **

user_defined_types: struct _dfa_node { int node_no; int dfa_set; int alternatives; int done; struct _set nfa_states; int trans[1]; }


arrayCheck

decompiled_code:
void arrayCheck()
{
int v0; // er14
int v1; // ebx
_QWORD *v2; // rbp
_QWORD *v3; // r12
_QWORD *v4; // r13
_QWORD *v5; // r8
_QWORD *v6; // rdi
_QWORD *v7; // rsi
__int64 v8; // rax
__int64 v9; // rdx
void *v10; // rdi

if ( BlkLevel > highWater )
highWater = BlkLevel;
v0 = arraySize;
if ( BlkLevel >= arraySize )
{
v1 = BlkLevel + 5;
v2 = calloc(BlkLevel + 5, 8uLL);
v3 = calloc(v1, 8uLL);
v4 = calloc(v1, 8uLL);
if ( v0 <= 0 )
{
arraySize = v1;
v10 = egArray;
if ( !egArray )
goto LABEL_9;
}
else
{
v5 = egArray;
v6 = leArray;
v7 = altArray;
v8 = 0LL;
do
{
v2[v8] = v5[v8];
v3[v8] = v6[v8];
v4[v8] = v7[v8];
v9 = v8++;
}
while ( v9 != v0 - 1 );
arraySize = v1;
v10 = egArray;
}
free(v10);
LABEL_9:
if ( leArray )
free(leArray);
if ( altArray )
free(altArray);
egArray = v2;
leArray = v3;
altArray = v4;
}
}

canonical_decompiled_code:
void func0()
{
int v0; // er14
int v1; // ebx
_QWORD *v2; // rbp
_QWORD *v3; // r12
_QWORD *v4; // r13
_QWORD *v5; // r8
_QWORD *v6; // rdi
_QWORD *v7; // rsi
__int64 v8; // rax
__int64 v9; // rdx
void *v10; // rdi

if ( BlkLevel > highWater )
highWater = BlkLevel;
v0 = arraySize;
if ( BlkLevel >= arraySize )
{
v1 = BlkLevel + 5;
v2 = calloc(BlkLevel + 5, 8uLL);
v3 = calloc(v1, 8uLL);
v4 = calloc(v1, 8uLL);
if ( v0 <= 0 )
{
arraySize = v1;
v10 = egArray;
if ( !egArray )
goto LABEL_9;
}
else
{
v5 = egArray;
v6 = leArray;
v7 = altArray;
v8 = 0LL;
do
{
v2[v8] = v5[v8];
v3[v8] = v6[v8];
v4[v8] = v7[v8];
v9 = v8++;
}
while ( v9 != v0 - 1 );
arraySize = v1;
v10 = egArray;
}
free(v10);
LABEL_9:
if ( leArray )
free(leArray);
if ( altArray )
free(altArray);
egArray = v2;
leArray = v3;
altArray = v4;
}
}

original_code:
static void
arrayCheck(void)
{
  ExceptionGroup **egArrayNew;
  LabelEntry **leArrayNew;
  Junction **altArrayNew;
  int arraySizeNew;
  int i;
  if (BlkLevel > highWater) highWater=BlkLevel;
  if (BlkLevel >= arraySize) {
    arraySizeNew=BlkLevel+5;
    egArrayNew=(ExceptionGroup **)
        calloc(arraySizeNew,sizeof(ExceptionGroup *));
    leArrayNew=(LabelEntry **)
        calloc(arraySizeNew,sizeof(LabelEntry *));
    altArrayNew=(Junction **)
        calloc(arraySizeNew,sizeof(Junction *));
    for (i=0; i<arraySize ; i++) {
      egArrayNew[i]=egArray[i];
      leArrayNew[i]=leArray[i];
      altArrayNew[i]=altArray[i];
    };
    arraySize=arraySizeNew;
    if (egArray != ((void *)0)) free( (char *) egArray);
    if (leArray != ((void *)0)) free( (char *) leArray);
    if (altArray != ((void *)0)) free( (char *) altArray);
    egArray=egArrayNew;
    leArray=leArrayNew;
    altArray=altArrayNew;
  };
}

canonical_original_code:
static void arrayCheck()
{
  struct _ExceptionGroup **egArrayNew;
  struct _LabelEntry **leArrayNew;
  struct _junct **altArrayNew;
  int arraySizeNew;
  int i;
  if (BlkLevel > highWater) highWater=BlkLevel;
  if (BlkLevel >= arraySize) {
    arraySizeNew=BlkLevel+5;
    egArrayNew=(struct _ExceptionGroup **)
        calloc(arraySizeNew,sizeof(struct _ExceptionGroup *));
    leArrayNew=(struct _LabelEntry **)
        calloc(arraySizeNew,sizeof(struct _LabelEntry *));
    altArrayNew=(struct _junct **)
        calloc(arraySizeNew,sizeof(struct _junct *));
    for (i=0; i<arraySize ; i++) {
      egArrayNew[i]=egArray[i];
      leArrayNew[i]=leArray[i];
      altArrayNew[i]=altArray[i];
    };
    arraySize=arraySizeNew;
    if (egArray != ((void *)0)) free( (char *) egArray);
    if (leArray != ((void *)0)) free( (char *) leArray);
    if (altArray != ((void *)0)) free( (char *) altArray);
    egArray=egArrayNew;
    leArray=leArrayNew;
    altArray=altArrayNew;
  };
}

variable_types: struct _ExceptionGroup { struct _ListNode { void *elem; struct _ListNode *next; } *handlers; char *label; char *altID; struct _ExceptionGroup *pendingLink; struct _ExceptionGroup *outerEG; struct _LabelEntry { char *str; struct _f { char *str; struct _f *next; struct _set { unsigned int n; unsigned int *setword; } fset; struct _set rk; int incomplete; } *next; struct _node { int ntype; char *rname; int file; int line; } *elem; struct _ExceptionGroup *ex_group; struct _ExceptionGroup *outerEG; struct _LabelEntry *pendingLink; int curAltNum; } *labelEntry; int forRule; int used; } **

variable_types: struct _LabelEntry { char *str; struct _f { char *str; struct _f *next; struct _set { unsigned int n; unsigned int *setword; } fset; struct _set rk; int incomplete; } *next; struct _node { int ntype; char *rname; int file; int line; } *elem; struct _ExceptionGroup { struct _ListNode { void *elem; struct _ListNode *next; } *handlers; char *label; char *altID; struct _ExceptionGroup *pendingLink; struct _ExceptionGroup *outerEG; struct _LabelEntry *labelEntry; int forRule; int used; } *ex_group; struct _ExceptionGroup *outerEG; struct _LabelEntry *pendingLink; int curAltNum; } **

variable_types: struct _junct { int ntype; char *rname; int file; int line; int seq; char ignore; char visited; char pvisited; char fvisited; char *lock; char *pred_lock; int altnum; int jtype; struct _junct *end; struct _node { int ntype; char *rname; int file; int line; } *p1; char halt; char *pdecl; char *parm; char predparm; char *ret; char *erraction; int blockid; char *exception_label; struct _set { unsigned int n; unsigned int *setword; } *fset; struct _tree { struct _tree *down; int token; union { int rk; struct _tree *tref; struct _set sref; } v; } *ftree; struct _Predicate { struct _Predicate *down; struct _Predicate *up; char *expr; struct _tree *tcontext; int k; struct _set scontext[2]; struct _set completionTree; struct _set completionSet; struct _PredEntry { char *str; struct _PredEntry *next; int file; int line; struct _Predicate *pred; char *predLiteral; } *predEntry; struct _anode { int ntype; char *rname; int file; int line; struct _node *next; char *action; int is_predicate; int done; int init_action; char *pred_fail; struct _Predicate *guardpred; unsigned char frmwarned; unsigned char ctxwarned; unsigned char predTooLong; unsigned char noHoist; struct _Predicate *ampersandPred; struct _junct *guardNodes; struct _PredEntry *predEntry; int inverted; } *source; char cloned; char redundant; char ampersandStyle; char inverted; char isConst; char constValue; char conflictReported; struct _set plainSet; } *predicate; char guess; char alpha_beta_guess_end; struct _node *guess_analysis_point; char approx; struct _set tokrefs; struct _set rulerefs; struct _ListNode { void *elem; struct _ListNode *next; } *exceptions; struct _ListNode *el_labels; struct _ExceptionGroup { struct _ListNode *handlers; char *label; char *altID; struct _ExceptionGroup *pendingLink; struct _ExceptionGroup *outerEG; struct _LabelEntry { char *str; struct _f { char *str; struct _f *next; struct _set fset; struct _set rk; int incomplete; } *next; struct _node *elem; struct _ExceptionGroup *ex_group; struct _ExceptionGroup *outerEG; struct _LabelEntry *pendingLink; int curAltNum; } *labelEntry; int forRule; int used; } *outerEG; int curAltNum; struct _junct *pendingLink; char overlap_warning; } **

variable_types: arraySizeNew int

user_defined_types: struct _ExceptionGroup { struct _ListNode *handlers; char *label; char *altID; struct _ExceptionGroup *pendingLink; struct _ExceptionGroup *outerEG; struct _LabelEntry *labelEntry; int forRule; int used; }

user_defined_types: struct _LabelEntry { char *str; struct _f *next; struct _node *elem; struct _ExceptionGroup *ex_group; struct _ExceptionGroup *outerEG; struct _LabelEntry *pendingLink; int curAltNum; }

user_defined_types: struct _junct { int ntype; char *rname; int file; int line; int seq; char ignore; char visited; char pvisited; char fvisited; char *lock; char *pred_lock; int altnum; int jtype; struct _junct *end; struct _node *p1; char halt; char *pdecl; char *parm; char predparm; char *ret; char *erraction; int blockid; char *exception_label; struct _set *fset; struct _tree *ftree; struct _Predicate *predicate; char guess; char alpha_beta_guess_end; struct _node *guess_analysis_point; char approx; struct _set tokrefs; struct _set rulerefs; struct _ListNode *exceptions; struct _ListNode *el_labels; struct _ExceptionGroup *outerEG; int curAltNum; struct _junct *pendingLink; char overlap_warning; }

user_defined_types: struct _Predicate { struct _Predicate *down; struct _Predicate *up; char *expr; struct _tree *tcontext; int k; struct _set scontext[2]; struct _set completionTree; struct _set completionSet; struct _PredEntry *predEntry; struct _anode *source; char cloned; char redundant; char ampersandStyle; char inverted; char isConst; char constValue; char conflictReported; struct _set plainSet; }


egFixup

decompiled_code:
__int64 egFixup()
{
__int64 result; // rax
__int64 *v1; // rcx
char *v2; // rdi
__int64 v3; // rdx

result = (unsigned int)highWater;
if ( highWater > 0 )
{
v1 = (__int64 *)((char *)egArray + 8);
v2 = (char *)egArray + 8 * (unsigned int)(highWater - 1) + 16;
do
{
for ( result = *v1; result; *(_QWORD *)(v3 + 24) = 0LL )
{
v3 = result;
result = *(_QWORD *)(result + 24);
}
*v1++ = 0LL;
}
while ( v1 != (__int64 *)v2 );
}
lastEG = 0LL;
lastBlkLevel = 0;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
__int64 *v1; // rcx
char *v2; // rdi
__int64 v3; // rdx

result = (unsigned int)highWater;
if ( highWater > 0 )
{
v1 = (__int64 *)((char *)egArray + 8);
v2 = (char *)egArray + 8 * (unsigned int)(highWater - 1) + 16;
do
{
for ( result = *v1; result; *(_QWORD *)(v3 + 24) = 0LL )
{
v3 = result;
result = *(_QWORD *)(result + 24);
}
*v1++ = 0LL;
}
while ( v1 != (__int64 *)v2 );
}
lastEG = 0LL;
lastBlkLevel = 0;
return result;
}

original_code:
void
egFixup(void)
{
  int i;
  ExceptionGroup *nextEG;
  ExceptionGroup *innerEG;
  for (i=1; i<=highWater ; i++) {
    for (innerEG=egArray[i]; innerEG != ((void *)0) ; innerEG=nextEG) {
      nextEG=innerEG->pendingLink;
      innerEG->pendingLink=((void *)0);
    };
    egArray[i]=((void *)0);
  };
  lastEG=((void *)0);
  lastBlkLevel=0;
}

canonical_original_code:
void egFixup()
{
  int i;
  struct _ExceptionGroup *nextEG;
  struct _ExceptionGroup *innerEG;
  for (i=1; i<=highWater ; i++) {
    for (innerEG=egArray[i]; innerEG != ((void *)0) ; innerEG=nextEG) {
      nextEG=innerEG->pendingLink;
      innerEG->pendingLink=((void *)0);
    };
    egArray[i]=((void *)0);
  };
  lastEG=((void *)0);
  lastBlkLevel=0;
}

variable_types: struct _ExceptionGroup { struct _ListNode { void *elem; struct _ListNode *next; } *handlers; char *label; char *altID; struct _ExceptionGroup *pendingLink; struct _ExceptionGroup *outerEG; struct _LabelEntry { char *str; struct _f { char *str; struct _f *next; struct _set { unsigned int n; unsigned int *setword; } fset; struct _set rk; int incomplete; } *next; struct _node { int ntype; char *rname; int file; int line; } *elem; struct _ExceptionGroup *ex_group; struct _ExceptionGroup *outerEG; struct _LabelEntry *pendingLink; int curAltNum; } *labelEntry; int forRule; int used; } *


leFixup

decompiled_code:
__int64 leFixup()
{
__int64 result; // rax
__int64 *v1; // rcx
char *v2; // rdi
__int64 v3; // rdx

result = (unsigned int)highWater;
if ( BlkLevel <= highWater )
{
v1 = (__int64 *)((char *)leArray + 8 * BlkLevel);
v2 = (char *)leArray + 8 * BlkLevel + 8 * (unsigned __int64)(unsigned int)(highWater - BlkLevel) + 8;
do
{
for ( result = *v1; result; *(_QWORD *)(v3 + 40) = 0LL )
{
v3 = result;
result = *(_QWORD *)(result + 40);
}
*v1++ = 0LL;
}
while ( v1 != (__int64 *)v2 );
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
__int64 *v1; // rcx
char *v2; // rdi
__int64 v3; // rdx

result = (unsigned int)highWater;
if ( BlkLevel <= highWater )
{
v1 = (__int64 *)((char *)leArray + 8 * BlkLevel);
v2 = (char *)leArray + 8 * BlkLevel + 8 * (unsigned __int64)(unsigned int)(highWater - BlkLevel) + 8;
do
{
for ( result = *v1; result; *(_QWORD *)(v3 + 40) = 0LL )
{
v3 = result;
result = *(_QWORD *)(result + 40);
}
*v1++ = 0LL;
}
while ( v1 != (__int64 *)v2 );
}
return result;
}

original_code:
void leFixup(void)
{
  int i;
  LabelEntry *nextLE;
  LabelEntry *innerLE;
  for (i=BlkLevel; i<=highWater ; i++) {
    for (innerLE=leArray[i]; innerLE != ((void *)0) ; innerLE=nextLE) {
      nextLE=innerLE->pendingLink;
      innerLE->pendingLink=((void *)0);
    };
    leArray[i]=((void *)0);
  };
}

canonical_original_code:
void leFixup()
{
  int i;
  struct _LabelEntry *nextLE;
  struct _LabelEntry *innerLE;
  for (i=BlkLevel; i<=highWater ; i++) {
    for (innerLE=leArray[i]; innerLE != ((void *)0) ; innerLE=nextLE) {
      nextLE=innerLE->pendingLink;
      innerLE->pendingLink=((void *)0);
    };
    leArray[i]=((void *)0);
  };
}

variable_types: struct _LabelEntry { char *str; struct _f { char *str; struct _f *next; struct _set { unsigned int n; unsigned int *setword; } fset; struct _set rk; int incomplete; } *next; struct _node { int ntype; char *rname; int file; int line; } *elem; struct _ExceptionGroup { struct _ListNode { void *elem; struct _ListNode *next; } *handlers; char *label; char *altID; struct _ExceptionGroup *pendingLink; struct _ExceptionGroup *outerEG; struct _LabelEntry *labelEntry; int forRule; int used; } *ex_group; struct _ExceptionGroup *outerEG; struct _LabelEntry *pendingLink; int curAltNum; } *


altFixup

decompiled_code:
void altFixup()
{
int v0; // er9
_QWORD *v1; // rdi
int v2; // esi
__int64 v3; // r8
__int64 v4; // rcx
__int64 v5; // rdx
__int64 v6; // rax

v0 = highWater;
if ( BlkLevel <= highWater )
{
v1 = altArray;
v2 = lastBlkLevel;
v3 = lastEG;
v4 = BlkLevel;
do
{
v6 = v1[v4];
if ( v6 )
{
while ( 1 )
{
if ( v2 <= (int)v4 && !*(_QWORD *)(v6 + 240) )
*(_QWORD *)(v6 + 240) = v3;
v5 = *(_QWORD *)(v6 + 256);
*(_QWORD *)(v6 + 256) = 0LL;
if ( !v5 )
break;
v6 = v5;
}
}
v1[v4++] = 0LL;
}
while ( v0 >= (int)v4 );
}
}

canonical_decompiled_code:
void func3()
{
int v0; // er9
_QWORD *v1; // rdi
int v2; // esi
__int64 v3; // r8
__int64 v4; // rcx
__int64 v5; // rdx
__int64 v6; // rax

v0 = highWater;
if ( BlkLevel <= highWater )
{
v1 = altArray;
v2 = lastBlkLevel;
v3 = lastEG;
v4 = BlkLevel;
do
{
v6 = v1[v4];
if ( v6 )
{
while ( 1 )
{
if ( v2 <= (int)v4 && !*(_QWORD *)(v6 + 240) )
*(_QWORD *)(v6 + 240) = v3;
v5 = *(_QWORD *)(v6 + 256);
*(_QWORD *)(v6 + 256) = 0LL;
if ( !v5 )
break;
v6 = v5;
}
}
v1[v4++] = 0LL;
}
while ( v0 >= (int)v4 );
}
}

original_code:
void altFixup(void)
{
  int i;
  Junction *nextAlt;
  Junction *innerAlt;
  for (i=BlkLevel; i<=highWater ; i++) {
    for (innerAlt=altArray[i]; innerAlt != ((void *)0) ; innerAlt=nextAlt) {
      if (lastBlkLevel <= i) {
        if (innerAlt->outerEG == ((void *)0)) {
          innerAlt->outerEG=lastEG;
        };
      };
      nextAlt=innerAlt->pendingLink;
      innerAlt->pendingLink=((void *)0);
    };
    altArray[i]=((void *)0);
  };
}

canonical_original_code:
void altFixup()
{
  int i;
  struct _junct *nextAlt;
  struct _junct *innerAlt;
  for (i=BlkLevel; i<=highWater ; i++) {
    for (innerAlt=altArray[i]; innerAlt != ((void *)0) ; innerAlt=nextAlt) {
      if (lastBlkLevel <= i) {
        if (innerAlt->outerEG == ((void *)0)) {
          innerAlt->outerEG=lastEG;
        };
      };
      nextAlt=innerAlt->pendingLink;
      innerAlt->pendingLink=((void *)0);
    };
    altArray[i]=((void *)0);
  };
}

variable_types: struct _junct { int ntype; char *rname; int file; int line; int seq; char ignore; char visited; char pvisited; char fvisited; char *lock; char *pred_lock; int altnum; int jtype; struct _junct *end; struct _node { int ntype; char *rname; int file; int line; } *p1; char halt; char *pdecl; char *parm; char predparm; char *ret; char *erraction; int blockid; char *exception_label; struct _set { unsigned int n; unsigned int *setword; } *fset; struct _tree { struct _tree *down; int token; union { int rk; struct _tree *tref; struct _set sref; } v; } *ftree; struct _Predicate { struct _Predicate *down; struct _Predicate *up; char *expr; struct _tree *tcontext; int k; struct _set scontext[2]; struct _set completionTree; struct _set completionSet; struct _PredEntry { char *str; struct _PredEntry *next; int file; int line; struct _Predicate *pred; char *predLiteral; } *predEntry; struct _anode { int ntype; char *rname; int file; int line; struct _node *next; char *action; int is_predicate; int done; int init_action; char *pred_fail; struct _Predicate *guardpred; unsigned char frmwarned; unsigned char ctxwarned; unsigned char predTooLong; unsigned char noHoist; struct _Predicate *ampersandPred; struct _junct *guardNodes; struct _PredEntry *predEntry; int inverted; } *source; char cloned; char redundant; char ampersandStyle; char inverted; char isConst; char constValue; char conflictReported; struct _set plainSet; } *predicate; char guess; char alpha_beta_guess_end; struct _node *guess_analysis_point; char approx; struct _set tokrefs; struct _set rulerefs; struct _ListNode { void *elem; struct _ListNode *next; } *exceptions; struct _ListNode *el_labels; struct _ExceptionGroup { struct _ListNode *handlers; char *label; char *altID; struct _ExceptionGroup *pendingLink; struct _ExceptionGroup *outerEG; struct _LabelEntry { char *str; struct _f { char *str; struct _f *next; struct _set fset; struct _set rk; int incomplete; } *next; struct _node *elem; struct _ExceptionGroup *ex_group; struct _ExceptionGroup *outerEG; struct _LabelEntry *pendingLink; int curAltNum; } *labelEntry; int forRule; int used; } *outerEG; int curAltNum; struct _junct *pendingLink; char overlap_warning; } *


repo: AlexMax/deutex

decompiled_code:
__int64 __fastcall is_prefix(char *a1, __int64 a2)
{
char v2; // dl
__int64 v3; // rax

v2 = *a1;
if ( !*a1 )
return 1LL;
v3 = 0LL;
while ( *(_BYTE *)(a2 + v3) == v2 )
{
v2 = a1[++v3];
if ( !v2 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, __int64 a2)
{
char v2; // dl
__int64 v3; // rax

v2 = *a1;
if ( !*a1 )
return 1LL;
v3 = 0LL;
while ( *(_BYTE *)(a2 + v3) == v2 )
{
v2 = a1[++v3];
if ( !v2 )
return 1LL;
}
return 0LL;
}

original_code:
static int is_prefix (const char *s1, const char *s2)
{
  for (;; s1++, s2++)
  {
    if (*s1 == '\0')
      return 1;
    if (*s2 != *s1)
      return 0;
  }
}

canonical_original_code:
static int is_prefix(char *s1, char *s2)
{
  for (;; s1++, s2++)
  {
    if (*s1 == '\0')
      return 1;
    if (*s2 != *s1)
      return 0;
  }
}


COMwintex

decompiled_code:
char *__fastcall COMwintex(__int64 a1, __int64 a2)
{
char *result; // rax

PrintInit(1LL);
PrintVerbosity(3LL);
DoomDir = 0LL;
result = strncpy(MainWAD, *(const char **)(a2 + 8), 0x80uLL);
Select |= 0x7FFu;
trnR = 0;
trnG = -1;
trnB = -1;
return result;
}

canonical_decompiled_code:
char *__fastcall func1(__int64 a1, __int64 a2)
{
char *result; // rax

PrintInit(1LL);
PrintVerbosity(3LL);
DoomDir = 0LL;
result = strncpy(MainWAD, *(const char **)(a2 + 8), 0x80uLL);
Select |= 0x7FFu;
trnR = 0;
trnG = -1;
trnB = -1;
return result;
}

original_code:
void COMwintex(int argc, const char *argv[])
{ PrintInit(1);
   PrintVerbosity(3);
   DoomDir=((void *)0);
   strncpy(MainWAD,argv[1],128);
   DataDir=".";
   Select|= (0x7FF);
   trnR= 0;trnG= 255;trnB= 255;
   (void)argc;
}

canonical_original_code:
void COMwintex(int argc, char *argv[])
{ PrintInit(1);
   PrintVerbosity(3);
   DoomDir=((void *)0);
   strncpy(MainWAD,argv[1],128);
   DataDir=".";
   Select|= (0x7FF);
   trnR= 0;trnG= 255;trnB= 255;
   (void)argc;
}

variable_types: argc int

variable_types:
argv
char *[]


COMverbose

decompiled_code:
__int64 __fastcall COMverbose(__int64 a1, __int64 a2)
{
PrintVerbosity((unsigned int)(__int16)(*(char *)(*(_QWORD *)a2 + 2LL) - 48));
return Info("Verbosity level is %c.\n", (unsigned int)*(char *)(*(_QWORD *)a2 + 2LL));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
PrintVerbosity((unsigned int)(__int16)(*(char *)(*(_QWORD *)a2 + 2LL) - 48));
return Info("Verbosity level is %c.\n", (unsigned int)*(char *)(*(_QWORD *)a2 + 2LL));
}

original_code:
void COMverbose(int argc, const char *argv[])
{ PrintVerbosity(argv[0][2]-'0');
   Info("Verbosity level is %c.\n",argv[0][2]);
   (void)argc;
}

canonical_original_code:
void COMverbose(int argc, char *argv[])
{ PrintVerbosity(argv[0][2]-'0');
   Info("Verbosity level is %c.\n",argv[0][2]);
   (void)argc;
}


COMdoom

decompiled_code:
__int64 __fastcall COMdoom(__int64 a1, __int64 a2)
{
DoomDir = *(_QWORD *)(a2 + 8);
return Info("Main directory: %s.\n", (const char *)DoomDir);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
DoomDir = *(_QWORD *)(a2 + 8);
return Info("Main directory: %s.\n", (const char *)DoomDir);
}

original_code:
void COMdoom(int argc, const char *argv[])
{ DoomDir=argv[1];
   Info("Main directory: %s.\n",DoomDir);
   (void)argc;
}

canonical_original_code:
void COMdoom(int argc, char *argv[])
{ DoomDir=argv[1];
   Info("Main directory: %s.\n",DoomDir);
   (void)argc;
}


COMmain

decompiled_code:
__int64 __fastcall COMmain(__int64 a1, __int64 a2)
{
DoomDir = 0LL;
strncpy(MainWAD, *(const char **)(a2 + 8), 0x80uLL);
return Info("Main IWAD file: %s.\n", MainWAD);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
DoomDir = 0LL;
strncpy(MainWAD, *(const char **)(a2 + 8), 0x80uLL);
return Info("Main IWAD file: %s.\n", MainWAD);
}

original_code:
void COMmain(int argc, const char *argv[])
{ DoomDir=((void *)0);
   strncpy(MainWAD,argv[1],128);
   Info("Main IWAD file: %s.\n",MainWAD);
   (void)argc;
}

canonical_original_code:
void COMmain(int argc, char *argv[])
{ DoomDir=((void *)0);
   strncpy(MainWAD,argv[1],128);
   Info("Main IWAD file: %s.\n",MainWAD);
   (void)argc;
}


COMwadir

decompiled_code:
__int64 __fastcall COMwadir(int a1, __int64 a2)
{
__int64 v2; // rax

v2 = 0LL;
if ( a1 > 1 )
v2 = *(_QWORD *)(a2 + 8);
return XTRlistDir(MainWAD, v2, (unsigned int)Select);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, __int64 a2)
{
__int64 v2; // rax

v2 = 0LL;
if ( a1 > 1 )
v2 = *(_QWORD *)(a2 + 8);
return XTRlistDir(MainWAD, v2, (unsigned int)Select);
}

original_code:
void COMwadir(int argc, const char *argv[])
{ XTRlistDir(MainWAD,((argc<2)? ((void *)0): argv[1]),Select);
}

canonical_original_code:
void COMwadir(int argc, char *argv[])
{ XTRlistDir(MainWAD,((argc<2)? ((void *)0): argv[1]),Select);
}


COMadd

decompiled_code:
__int64 __fastcall COMadd(__int64 a1, __int64 a2)
{
return ADDallSpriteFloor(*(_QWORD *)(a2 + 16), MainWAD, *(_QWORD *)(a2 + 8), (unsigned int)Select);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
return ADDallSpriteFloor(*(_QWORD *)(a2 + 16), MainWAD, *(_QWORD *)(a2 + 8), (unsigned int)Select);
}

original_code:
void COMadd(int argc, const char *argv[])
{ ADDallSpriteFloor(argv[2],MainWAD,argv[1],Select);
  (void)argc;
}

canonical_original_code:
void COMadd(int argc, char *argv[])
{ ADDallSpriteFloor(argv[2],MainWAD,argv[1],Select);
  (void)argc;
}


COMapp

decompiled_code:
__int64 __fastcall COMapp(__int64 a1, __int64 a2)
{
return ADDappendSpriteFloor(MainWAD, *(_QWORD *)(a2 + 8), (unsigned int)Select);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
return ADDappendSpriteFloor(MainWAD, *(_QWORD *)(a2 + 8), (unsigned int)Select);
}

original_code:
void COMapp(int argc, const char *argv[])
{ ADDappendSpriteFloor(MainWAD,argv[1],Select);
  (void)argc;
}

canonical_original_code:
void COMapp(int argc, char *argv[])
{ ADDappendSpriteFloor(MainWAD,argv[1],Select);
  (void)argc;
}


COMapps

decompiled_code:
__int64 __fastcall COMapps(__int64 a1, __int64 a2)
{
Select = 1919;
return ADDappendSpriteFloor(MainWAD, *(_QWORD *)(a2 + 8), 1919LL);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
Select = 1919;
return ADDappendSpriteFloor(MainWAD, *(_QWORD *)(a2 + 8), 1919LL);
}

original_code:
void COMapps(int argc, const char *argv[])
{ Select= ((0x7FF)) & (~(0x80));
  ADDappendSpriteFloor(MainWAD,argv[1],Select);
  (void)argc;
}

canonical_original_code:
void COMapps(int argc, char *argv[])
{ Select= ((0x7FF)) & (~(0x80));
  ADDappendSpriteFloor(MainWAD,argv[1],Select);
  (void)argc;
}


COMappf

decompiled_code:
__int64 __fastcall COMappf(__int64 a1, __int64 a2)
{
Select = 2015;
return ADDappendSpriteFloor(MainWAD, *(_QWORD *)(a2 + 8), 2015LL);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
Select = 2015;
return ADDappendSpriteFloor(MainWAD, *(_QWORD *)(a2 + 8), 2015LL);
}

original_code:
void COMappf(int argc, const char *argv[])
{ Select= ((0x7FF)) & (~(0x20));
  ADDappendSpriteFloor(MainWAD,argv[1],Select);
  (void)argc;
}

canonical_original_code:
void COMappf(int argc, char *argv[])
{ Select= ((0x7FF)) & (~(0x20));
  ADDappendSpriteFloor(MainWAD,argv[1],Select);
  (void)argc;
}


COMjoin

decompiled_code:
__int64 __fastcall COMjoin(__int64 a1, __int64 a2)
{
return ADDjoinWads(MainWAD, *(_QWORD *)(a2 + 8), *(_QWORD *)(a2 + 16), (unsigned int)Select);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2)
{
return ADDjoinWads(MainWAD, *(_QWORD *)(a2 + 8), *(_QWORD *)(a2 + 16), (unsigned int)Select);
}

original_code:
void COMjoin(int argc, const char *argv[])
{ ADDjoinWads(MainWAD,argv[1],argv[2],Select);
  (void)argc;
}

canonical_original_code:
void COMjoin(int argc, char *argv[])
{ ADDjoinWads(MainWAD,argv[1],argv[2],Select);
  (void)argc;
}


COMmerge

decompiled_code:
__int64 __fastcall COMmerge(__int64 a1, __int64 a2)
{
Select = 2047;
return PSTmergeWAD(MainWAD, *(_QWORD *)(a2 + 8), 2047LL);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
Select = 2047;
return PSTmergeWAD(MainWAD, *(_QWORD *)(a2 + 8), 2047LL);
}

original_code:
void COMmerge(int argc, const char *argv[])
{ Select = (0x7FF);
  PSTmergeWAD(MainWAD,argv[1],Select);
  (void)argc;
}

canonical_original_code:
void COMmerge(int argc, char *argv[])
{ Select = (0x7FF);
  PSTmergeWAD(MainWAD,argv[1],Select);
  (void)argc;
}


COMrestor

decompiled_code:
__int64 __fastcall COMrestor(int a1, __int64 a2)
{
char *v3; // rdi

v3 = MainWAD;
if ( a1 > 1 )
v3 = *(char **)(a2 + 8);
return HDRrestoreWAD(v3);
}

canonical_decompiled_code:
__int64 __fastcall func16(int a1, __int64 a2)
{
char *v3; // rdi

v3 = MainWAD;
if ( a1 > 1 )
v3 = *(char **)(a2 + 8);
return HDRrestoreWAD(v3);
}

original_code:
void COMrestor(int argc, const char *argv[])
{ HDRrestoreWAD((argc>=2)? argv[1]:MainWAD);
}

canonical_original_code:
void COMrestor(int argc, char *argv[])
{ HDRrestoreWAD((argc>=2)? argv[1]:MainWAD);
}


COMtf

decompiled_code:
char __fastcall COMtf(int a1, const char **a2)
{
const char *v2; // rax
bool v3; // zf
_BOOL4 v4; // ebx
int v5; // er13
const char *v6; // rax

v2 = *a2;
v3 = strcmp(*a2, "itf") == 0;
v4 = !v3;
if ( !v3 )
{
if ( !strcmp(v2, "otf") )
{
v4 = 1;
}
else
{
v4 = 1;
if ( !strcmp(v2, "tf") )
goto LABEL_4;
Bug("COMtf: bad argv[0] \"%.32s\"", v2);
v4 = 0;
}
v5 = 0;
if ( a1 <= 1 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
LABEL_36:
if ( !v4 )
return (char)v6;
goto LABEL_10;
}
goto LABEL_5;
}
LABEL_4:
v5 = 1;
if ( a1 <= 1 )
{
ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
goto LABEL_35;
}
LABEL_5:
v6 = a2[1];
if ( !strcmp(v6, "nameless") )
{
if ( v5 )
{
input_texture_format = 1;
if ( !v4 )
{
LABEL_35:
LOBYTE(v6) = Info("Input texture format is \"%s\"\n", a2[1]);
goto LABEL_36;
}
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 1;
}
else if ( !strcmp(a2[1], "none") )
{
if ( v5 )
{
input_texture_format = 2;
if ( !v4 )
goto LABEL_35;
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 2;
}
else if ( !strcmp(a2[1], "normal") )
{
if ( v5 )
{
input_texture_format = 0;
if ( !v4 )
goto LABEL_35;
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 0;
}
else
{
v3 = strcmp(a2[1], "strife11") == 0;
LOBYTE(v6) = !v3;
if ( !v3 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
if ( !v5 )
goto LABEL_36;
goto LABEL_35;
}
if ( v5 )
{
input_texture_format = 3;
if ( !v4 )
goto LABEL_35;
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 3;
}
if ( v5 )
goto LABEL_35;
LABEL_10:
LOBYTE(v6) = Info("Output texture format is \"%s\"\n", a2[1]);
return (char)v6;
}

canonical_decompiled_code:
char __fastcall func17(int a1, const char **a2)
{
const char *v2; // rax
bool v3; // zf
_BOOL4 v4; // ebx
int v5; // er13
const char *v6; // rax

v2 = *a2;
v3 = strcmp(*a2, "itf") == 0;
v4 = !v3;
if ( !v3 )
{
if ( !strcmp(v2, "otf") )
{
v4 = 1;
}
else
{
v4 = 1;
if ( !strcmp(v2, "tf") )
goto LABEL_4;
Bug("COMtf: bad argv[0] \"%.32s\"", v2);
v4 = 0;
}
v5 = 0;
if ( a1 <= 1 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
LABEL_36:
if ( !v4 )
return (char)v6;
goto LABEL_10;
}
goto LABEL_5;
}
LABEL_4:
v5 = 1;
if ( a1 <= 1 )
{
ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
goto LABEL_35;
}
LABEL_5:
v6 = a2[1];
if ( !strcmp(v6, "nameless") )
{
if ( v5 )
{
input_texture_format = 1;
if ( !v4 )
{
LABEL_35:
LOBYTE(v6) = Info("Input texture format is \"%s\"\n", a2[1]);
goto LABEL_36;
}
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 1;
}
else if ( !strcmp(a2[1], "none") )
{
if ( v5 )
{
input_texture_format = 2;
if ( !v4 )
goto LABEL_35;
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 2;
}
else if ( !strcmp(a2[1], "normal") )
{
if ( v5 )
{
input_texture_format = 0;
if ( !v4 )
goto LABEL_35;
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 0;
}
else
{
v3 = strcmp(a2[1], "strife11") == 0;
LOBYTE(v6) = !v3;
if ( !v3 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
if ( !v5 )
goto LABEL_36;
goto LABEL_35;
}
if ( v5 )
{
input_texture_format = 3;
if ( !v4 )
goto LABEL_35;
}
else if ( !v4 )
{
return (char)v6;
}
output_texture_format = 3;
}
if ( v5 )
goto LABEL_35;
LABEL_10:
LOBYTE(v6) = Info("Output texture format is \"%s\"\n", a2[1]);
return (char)v6;
}

original_code:
void COMtf (int argc, const char *argv[])
{
  int set_in = 0;
  int set_out = 0;
  if (! strcmp (argv[0], "itf"))
    set_in = 1;
  else if (! strcmp (argv[0], "otf"))
    set_out = 1;
  else if (! strcmp (argv[0], "tf"))
  {
    set_in = 1;
    set_out = 1;
  }
  else
    Bug ("COMtf: bad argv[0] \"%.32s\"", argv[0]);
  if (argc >= 2 && ! strcmp (argv[1], "nameless"))
  {
    if (set_in)
      input_texture_format = TF_NAMELESS;
    if (set_out)
      output_texture_format = TF_NAMELESS;
  }
  else if (argc >= 2 && ! strcmp (argv[1], "none"))
  {
    if (set_in)
      input_texture_format = TF_NONE;
    if (set_out)
      output_texture_format = TF_NONE;
  }
  else if (argc >= 2 && ! strcmp (argv[1], "normal"))
  {
    if (set_in)
      input_texture_format = TF_NORMAL;
    if (set_out)
      output_texture_format = TF_NORMAL;
  }
  else if (argc >= 2 && ! strcmp (argv[1], "strife11"))
  {
    if (set_in)
      input_texture_format = TF_STRIFE11;
    if (set_out)
      output_texture_format = TF_STRIFE11;
  }
  else
    ProgError ("Usage is \"-%.32s {nameless|none|normal|strife11}\"", argv[0]);
  if (set_in)
    Info ("Input texture format is \"%s\"\n", argv[1]);
  if (set_out)
    Info ("Output texture format is \"%s\"\n", argv[1]);
}

canonical_original_code:
void COMtf(int argc, char *argv[])
{
  int set_in = 0;
  int set_out = 0;
  if (! strcmp (argv[0], "itf"))
    set_in = 1;
  else if (! strcmp (argv[0], "otf"))
    set_out = 1;
  else if (! strcmp (argv[0], "tf"))
  {
    set_in = 1;
    set_out = 1;
  }
  else
    Bug ("COMtf: bad argv[0] \"%.32s\"", argv[0]);
  if (argc >= 2 && ! strcmp (argv[1], "nameless"))
  {
    if (set_in)
      input_texture_format = TF_NAMELESS;
    if (set_out)
      output_texture_format = TF_NAMELESS;
  }
  else if (argc >= 2 && ! strcmp (argv[1], "none"))
  {
    if (set_in)
      input_texture_format = TF_NONE;
    if (set_out)
      output_texture_format = TF_NONE;
  }
  else if (argc >= 2 && ! strcmp (argv[1], "normal"))
  {
    if (set_in)
      input_texture_format = TF_NORMAL;
    if (set_out)
      output_texture_format = TF_NORMAL;
  }
  else if (argc >= 2 && ! strcmp (argv[1], "strife11"))
  {
    if (set_in)
      input_texture_format = TF_STRIFE11;
    if (set_out)
      output_texture_format = TF_STRIFE11;
  }
  else
    ProgError ("Usage is \"-%.32s {nameless|none|normal|strife11}\"", argv[0]);
  if (set_in)
    Info ("Input texture format is \"%s\"\n", argv[1]);
  if (set_out)
    Info ("Output texture format is \"%s\"\n", argv[1]);
}


COMcheck

decompiled_code:
__int64 __fastcall COMcheck(__int64 a1, __int64 a2)
{
return XTRstructureTest(MainWAD, *(_QWORD *)(a2 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 a2)
{
return XTRstructureTest(MainWAD, *(_QWORD *)(a2 + 8));
}

original_code:
void COMcheck(int argc, const char *argv[])
{ XTRstructureTest(MainWAD,argv[1]);
  (void)argc;
}

canonical_original_code:
void COMcheck(int argc, char *argv[])
{ XTRstructureTest(MainWAD,argv[1]);
  (void)argc;
}


COMformat

decompiled_code:
__int64 COMformat()
{
char **v0; // rbx
const char *v1; // rsi
__int64 result; // rax

v0 = off_1C28;
v1 = "To work with this progam, your PWAD must respect this format:";
do
{
result = Output("%s\n", v1);
v1 = *v0++;
}
while ( v1 );
return result;
}

canonical_decompiled_code:
__int64 func19()
{
char **v0; // rbx
const char *v1; // rsi
__int64 result; // rax

v0 = off_1C28;
v1 = "To work with this progam, your PWAD must respect this format:";
do
{
result = Output("%s\n", v1);
v1 = *v0++;
}
while ( v1 );
return result;
}

original_code:
void COMformat(int argc, const char *argv[])
{ int i;
  for(i=0;Format[i]!=((void *)0);i++)
  { Output("%s\n",Format[i]);
  }
  (void)argc;(void)argv;
}

canonical_original_code:
void COMformat(int argc, char *argv[])
{ int i;
  for(i=0;Format[i]!=((void *)0);i++)
  { Output("%s\n",Format[i]);
  }
  (void)argc;(void)argv;
}

variable_types: i int


COMvers

decompiled_code:
void __noreturn COMvers()
{
print_version();
exit(0);
}

canonical_decompiled_code:
void __noreturn func21()
{
print_version();
exit(0);
}

original_code:
void COMvers (int argc, const char *argv[])
{
  (void) argc;
  (void) argv;
  print_version ();
  exit (0);
}

canonical_original_code:
void COMvers(int argc, char *argv[])
{
  (void) argc;
  (void) argv;
  print_version ();
  exit (0);
}


original_code:
void usedidx_end_lump (cusage_t *cusage)
{
  int i;
  if (cusage == ((void *)0))
    Bug ("usedidx_end_lump: bad cusage %p", cusage);
  for (i = 0; i < 256; i++)
  {
    if (cusage->lump_uses[i] > 0)
    {
      if (cusage->uses[i] == 0)
 memcpy (cusage->where_first[i], cusage->lump_name,
     sizeof cusage->where_first[i]);
      cusage->uses[i] += cusage->lump_uses[i];
      cusage->nlumps[i]++;
    }
  }
  Free (cusage->lump_uses);
}

canonical_original_code:
void usedidx_end_lump(struct cusage_s *cusage)
{
  int i;
  if (cusage == ((void *)0))
    Bug ("usedidx_end_lump: bad cusage %p", cusage);
  for (i = 0; i < 256; i++)
  {
    if (cusage->lump_uses[i] > 0)
    {
      if (cusage->uses[i] == 0)
 memcpy (cusage->where_first[i], cusage->lump_name,
     sizeof cusage->where_first[i]);
      cusage->uses[i] += cusage->lump_uses[i];
      cusage->nlumps[i]++;
    }
  }
  Free (cusage->lump_uses);
}

variable_types: struct cusage_s { char lump_name[8]; unsigned long *lump_uses; unsigned long uses[256]; unsigned long nlumps[256]; char where_first[256][8]; } *


original_code:
void usedidx_rectangle (const char *buf, long buf_size, const char *name,
    cusage_t *cusage)
{
  const unsigned char *p = (const unsigned char *) buf;
  const unsigned char *pmax = p + buf_size;
  unsigned long *uses = Malloc (256 * sizeof *uses);
  int i;
  for (i = 0; i < 256; i++)
    uses[i] = 0;
  for (; p < pmax; p++)
    uses[*p]++;
  for (i = 0; i < 256; i++)
  {
    if (uses[i] > 0)
    {
      if (cusage->uses[i] == 0)
 memcpy (cusage->where_first[i], name, 8);
      cusage->uses[i] += uses[i];
      cusage->nlumps[i]++;
    }
  }
  Free (uses);
}

canonical_original_code:
void usedidx_rectangle(char *buf, long buf_size, char *name, struct cusage_s *cusage)
{
  unsigned char *p = (const unsigned char *) buf;
  unsigned char *pmax = p + buf_size;
  unsigned long *uses = Malloc (256 * sizeof *uses);
  int i;
  for (i = 0; i < 256; i++)
    uses[i] = 0;
  for (; p < pmax; p++)
    uses[*p]++;
  for (i = 0; i < 256; i++)
  {
    if (uses[i] > 0)
    {
      if (cusage->uses[i] == 0)
 memcpy (cusage->where_first[i], name, 8);
      cusage->uses[i] += uses[i];
      cusage->nlumps[i]++;
    }
  }
  Free (uses);
}

variable_types:
buf
char *

variable_types:
name
char *

variable_types:
p
unsigned char *

variable_types:
pmax
unsigned char *

variable_types:
uses
unsigned long *

user_defined_types: struct cusage_s { char lump_name[8]; unsigned long *lump_uses; unsigned long uses[256]; unsigned long nlumps[256]; char where_first[256][8]; }


decompiled_code:
unsigned __int64 __fastcall read_i32_le(unsigned __int16 *a1, unsigned __int64 *a2)
{
unsigned __int64 result; // rax

result = *a1 | ((unsigned __int64)*((unsigned __int8 *)a1 + 3) << 24) | ((unsigned __int64)*((unsigned __int8 *)a1 + 2) << 16);
*a2 = result;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(unsigned __int16 *a1, unsigned __int64 *a2)
{
unsigned __int64 result; // rax

result = *a1 | ((unsigned __int64)*((unsigned __int8 *)a1 + 3) << 24) | ((unsigned __int64)*((unsigned __int8 *)a1 + 2) << 16);
*a2 = result;
return result;
}

original_code:
void read_i32_le (const void *ptr, Int32 *buf)
{
  *buf = ((const unsigned char *) ptr)[0]
   | ((UInt16) ((const unsigned char *) ptr)[1] << 8)
   | ((Int32) ((const unsigned char *) ptr)[2] << 16)
   | ((Int32) ((const unsigned char *) ptr)[3] << 24);
}

canonical_original_code:
void read_i32_le(void *ptr, long *buf)
{
  *buf = ((unsigned char *) ptr)[0]
   | ((UInt16) ((unsigned char *) ptr)[1] << 8)
   | ((Int32) ((unsigned char *) ptr)[2] << 16)
   | ((Int32) ((unsigned char *) ptr)[3] << 24);
}

variable_types:
ptr
void *

variable_types:
buf
long *


decompiled_code:
__int64 __fastcall peek_i16_le(unsigned __int16 *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int16 *a1)
{
return *a1;
}

original_code:
Int16 peek_i16_le (const void *ptr)
{
  return ((const unsigned char *) ptr)[0]
      | (((const unsigned char *) ptr)[1] << 8);
}

canonical_original_code:
short peek_i16_le(void *ptr)
{
  return ((unsigned char *) ptr)[0]
      | (((unsigned char *) ptr)[1] << 8);
}

return_type: short


decompiled_code:
__int64 __fastcall peek_u16_le(unsigned __int16 *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int16 *a1)
{
return *a1;
}

original_code:
UInt16 peek_u16_le (const void *ptr)
{
  return ((const unsigned char *) ptr)[0]
      | (((const unsigned char *) ptr)[1] << 8);
}

canonical_original_code:
unsigned short peek_u16_le(void *ptr)
{
  return ((unsigned char *) ptr)[0]
      | (((unsigned char *) ptr)[1] << 8);
}

return_type: unsigned short


decompiled_code:
unsigned __int64 __fastcall peek_i32_be(unsigned __int8 *a1)
{
return (a1[2] << 8) | a1[3] | ((unsigned __int64)a1[1] << 16) | ((unsigned __int64)*a1 << 24);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned __int8 *a1)
{
return (a1[2] << 8) | a1[3] | ((unsigned __int64)a1[1] << 16) | ((unsigned __int64)*a1 << 24);
}

original_code:
Int32 peek_i32_be (const void *ptr)
{
  return ((Int32) (((const unsigned char *) ptr)[0]) << 24)
       | ((Int32) (((const unsigned char *) ptr)[1]) << 16)
       | ((UInt16) (((const unsigned char *) ptr)[2]) << 8)
       | ((const unsigned char *) ptr)[3];
}

canonical_original_code:
long peek_i32_be(void *ptr)
{
  return ((Int32) (((unsigned char *) ptr)[0]) << 24)
       | ((Int32) (((unsigned char *) ptr)[1]) << 16)
       | ((UInt16) (((unsigned char *) ptr)[2]) << 8)
       | ((unsigned char *) ptr)[3];
}

return_type: long


decompiled_code:
unsigned __int64 __fastcall peek_i32_le(unsigned __int16 *a1)
{
return *a1 | ((unsigned __int64)*((unsigned __int8 *)a1 + 3) << 24) | ((unsigned __int64)*((unsigned __int8 *)a1 + 2) << 16);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int16 *a1)
{
return *a1 | ((unsigned __int64)*((unsigned __int8 *)a1 + 3) << 24) | ((unsigned __int64)*((unsigned __int8 *)a1 + 2) << 16);
}

original_code:
Int32 peek_i32_le (const void *ptr)
{
  return ((const unsigned char *) ptr)[0]
   | ((UInt16) ((const unsigned char *) ptr)[1] << 8)
   | ((Int32) ((const unsigned char *) ptr)[2] << 16)
   | ((Int32) ((const unsigned char *) ptr)[3] << 24);
}

canonical_original_code:
long peek_i32_le(void *ptr)
{
  return ((unsigned char *) ptr)[0]
   | ((UInt16) ((unsigned char *) ptr)[1] << 8)
   | ((Int32) ((unsigned char *) ptr)[2] << 16)
   | ((Int32) ((unsigned char *) ptr)[3] << 24);
}


decompiled_code:
__int64 __fastcall write_i16_le(_WORD *a1, __int16 a2)
{
*a1 = a2;
return HIBYTE(a2);
}

canonical_decompiled_code:
__int64 __fastcall func6(_WORD *a1, __int16 a2)
{
*a1 = a2;
return HIBYTE(a2);
}

original_code:
void write_i16_le (void *ptr, Int16 val)
{
  ((unsigned char *) ptr)[0] = val;
  ((unsigned char *) ptr)[1] = val >> 8;
}

canonical_original_code:
void write_i16_le(void *ptr, short val)
{
  ((unsigned char *) ptr)[0] = val;
  ((unsigned char *) ptr)[1] = val >> 8;
}

variable_types: val short


decompiled_code:
__int64 __fastcall write_i32_le(__int64 a1, __int64 a2)
{
__int64 result; // rax

*(_WORD *)a1 = a2;
result = a2 >> 16;
*(_BYTE *)(a1 + 2) = BYTE2(a2);
*(_BYTE *)(a1 + 3) = BYTE3(a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 result; // rax

*(_WORD *)a1 = a2;
result = a2 >> 16;
*(_BYTE *)(a1 + 2) = BYTE2(a2);
*(_BYTE *)(a1 + 3) = BYTE3(a2);
return result;
}

original_code:
void write_i32_le (void *ptr, Int32 val)
{
  ((unsigned char *) ptr)[0] = val;
  ((unsigned char *) ptr)[1] = val >> 8;
  ((unsigned char *) ptr)[2] = val >> 16;
  ((unsigned char *) ptr)[3] = val >> 24;
}

canonical_original_code:
void write_i32_le(void *ptr, long val)
{
  ((unsigned char *) ptr)[0] = val;
  ((unsigned char *) ptr)[1] = val >> 8;
  ((unsigned char *) ptr)[2] = val >> 16;
  ((unsigned char *) ptr)[3] = val >> 24;
}

variable_types: val long


TXTinit

decompiled_code:
__int64 TXTinit()
{
const unsigned __int16 *v0; // r8
__int16 v1; // si
__int64 i; // rdx
__int64 result; // rax
unsigned __int16 v4; // cx
unsigned int v5; // edi
unsigned int v6; // edi

v0 = *_ctype_b_loc();
v1 = 1;
for ( i = 0LL; ; ++i )
{
switch ( (__int16)i )
{
case 0:
case 10:
result = 4LL;
break;
case 32:
case 33:
case 34:
case 36:
case 37:
case 38:
case 39:
case 40:
case 41:
case 44:
case 46:
case 47:
case 58:
case 60:
case 62:
case 63:
case 64:
case 94:
result = 256LL;
break;
case 35:
result = 520LL;
break;
case 42:
result = 384LL;
break;
case 43:
case 45:
result = 320LL;
break;
case 59:
result = 264LL;
break;
case 61:
result = 1280LL;
break;
case 91:
case 93:
result = 304LL;
break;
case 92:
case 95:
result = 288LL;
break;
default:
result = 0LL;
break;
}
v4 = v0[i];
HIWORD(v5) = WORD1(result);
if ( (v4 & 0x800) != 0 )
{
LOWORD(v5) = result | 0x140;
result = v5;
}
HIWORD(v6) = WORD1(result);
if ( (v4 & 0x400) != 0 )
{
LOWORD(v6) = result | 0x130;
result = v6;
}
if ( (v4 & 0x2000) != 0 )
result = (unsigned int)result | 2;
if ( (_WORD)i != 37 )
break;
TXTval[i] = result | 0x20;
LABEL_20:
++v1;
}
TXTval[i] = result;
if ( v1 <= 255 )
goto LABEL_20;
TXTok = 1;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
const unsigned __int16 *v0; // r8
__int16 v1; // si
__int64 i; // rdx
__int64 result; // rax
unsigned __int16 v4; // cx
unsigned int v5; // edi
unsigned int v6; // edi

v0 = *_ctype_b_loc();
v1 = 1;
for ( i = 0LL; ; ++i )
{
switch ( (__int16)i )
{
case 0:
case 10:
result = 4LL;
break;
case 32:
case 33:
case 34:
case 36:
case 37:
case 38:
case 39:
case 40:
case 41:
case 44:
case 46:
case 47:
case 58:
case 60:
case 62:
case 63:
case 64:
case 94:
result = 256LL;
break;
case 35:
result = 520LL;
break;
case 42:
result = 384LL;
break;
case 43:
case 45:
result = 320LL;
break;
case 59:
result = 264LL;
break;
case 61:
result = 1280LL;
break;
case 91:
case 93:
result = 304LL;
break;
case 92:
case 95:
result = 288LL;
break;
default:
result = 0LL;
break;
}
v4 = v0[i];
HIWORD(v5) = WORD1(result);
if ( (v4 & 0x800) != 0 )
{
LOWORD(v5) = result | 0x140;
result = v5;
}
HIWORD(v6) = WORD1(result);
if ( (v4 & 0x400) != 0 )
{
LOWORD(v6) = result | 0x130;
result = v6;
}
if ( (v4 & 0x2000) != 0 )
result = (unsigned int)result | 2;
if ( (_WORD)i != 37 )
break;
TXTval[i] = result | 0x20;
LABEL_20:
++v1;
}
TXTval[i] = result;
if ( v1 <= 255 )
goto LABEL_20;
TXTok = 1;
return result;
}

original_code:
void TXTinit(void)
{ Int16 n,val;
  for(n=0;n<256;n++)
    { val=0;
      switch(n)
      { case '#':
    val |=BOUNDARY+COMMENT;break;
 case ';':
    val |=COMMENT+EXESTRNG;break;
 case '\0': case '\n':
    val |=NEWLINE;break;
 case '_':
 case '\\':
    val |=NAME+EXESTRNG;break;
 case '[':
 case ']':
    val |=SECTION+NAME+EXESTRNG;break;
 case '-': case '+':
    val |=NUMBER+EXESTRNG;break;
 case '*':
    val |= EXESTRNG+STPATCH;break;
 case '=':
    val |= STEQUAL+EXESTRNG;break;
 case '?': case '!':
 case '.': case ',': case '\'':
 case '&': case '(': case ')':
 case '$': case '%': case '@':
 case '/': case '<': case '>':
 case ' ': case '^': case '\"':
 case ':':
    val |=EXESTRNG;break;
 default: break;
      }
      if(((*__ctype_b_loc ())[(int) ((n))] & (unsigned short int) _ISdigit)) val |= NUMBER+EXESTRNG;
      if(((*__ctype_b_loc ())[(int) ((n))] & (unsigned short int) _ISalpha)) val |= SECTION+NAME+EXESTRNG;
      if(((*__ctype_b_loc ())[(int) ((n))] & (unsigned short int) _ISspace)) val |= SPACE;
      if (n == '%')
 val |= NAME;
      TXTval[n]=val;
    }
  TXTok=1;
}

canonical_original_code:
void TXTinit()
{ short n; short val;
  for(n=0;n<256;n++)
    { val=0;
      switch(n)
      { case '#':
    val |=BOUNDARY+COMMENT;break;
 case ';':
    val |=COMMENT+EXESTRNG;break;
 case '\0': case '\n':
    val |=NEWLINE;break;
 case '_':
 case '\\':
    val |=NAME+EXESTRNG;break;
 case '[':
 case ']':
    val |=SECTION+NAME+EXESTRNG;break;
 case '-': case '+':
    val |=NUMBER+EXESTRNG;break;
 case '*':
    val |= EXESTRNG+STPATCH;break;
 case '=':
    val |= STEQUAL+EXESTRNG;break;
 case '?': case '!':
 case '.': case ',': case '\'':
 case '&': case '(': case ')':
 case '$': case '%': case '@':
 case '/': case '<': case '>':
 case ' ': case '^': case '\"':
 case ':':
    val |=EXESTRNG;break;
 default: break;
      }
      if(((*__ctype_b_loc ())[(int) ((n))] & (unsigned short) _ISdigit)) val |= NUMBER+EXESTRNG;
      if(((*__ctype_b_loc ())[(int) ((n))] & (unsigned short) _ISalpha)) val |= SECTION+NAME+EXESTRNG;
      if(((*__ctype_b_loc ())[(int) ((n))] & (unsigned short) _ISspace)) val |= SPACE;
      if (n == '%')
 val |= NAME;
      TXTval[n]=val;
    }
  TXTok=1;
}

variable_types: n short


decompiled_code:
void *__fastcall set_output_wad_endianness(int a1)
{
void *result; // rax

if ( a1 )
{
wad_write_i16 = &fwrite_i16_be;
result = &fwrite_i32_be;
}
else
{
wad_write_i16 = &fwrite_i16_le;
result = &fwrite_i32_le;
}
wad_write_i32 = result;
return result;
}

canonical_decompiled_code:
void *__fastcall func0(int a1)
{
void *result; // rax

if ( a1 )
{
wad_write_i16 = &fwrite_i16_be;
result = &fwrite_i32_be;
}
else
{
wad_write_i16 = &fwrite_i16_le;
result = &fwrite_i32_le;
}
wad_write_i32 = result;
return result;
}

original_code:
void set_output_wad_endianness (int big_endian)
{
  wad_write_i16 = big_endian ? fwrite_i16_be : fwrite_i16_le;
  wad_write_i32 = big_endian ? fwrite_i32_be : fwrite_i32_le;
}

canonical_original_code:
void set_output_wad_endianness(int big_endian)
{
  wad_write_i16 = big_endian ? fwrite_i16_be : fwrite_i16_le;
  wad_write_i32 = big_endian ? fwrite_i32_be : fwrite_i32_le;
}


decompiled_code:
void *__fastcall set_input_wad_endianness(int a1)
{
void *result; // rax

if ( a1 )
{
wad_read_i16 = &fread_i16_be;
result = &fread_i32_be;
}
else
{
wad_read_i16 = &fread_i16_le;
result = &fread_i32_le;
}
wad_read_i32 = result;
return result;
}

canonical_decompiled_code:
void *__fastcall func1(int a1)
{
void *result; // rax

if ( a1 )
{
wad_read_i16 = &fread_i16_be;
result = &fread_i32_be;
}
else
{
wad_read_i16 = &fread_i16_le;
result = &fread_i32_le;
}
wad_read_i32 = result;
return result;
}

original_code:
void set_input_wad_endianness (int big_endian)
{
  wad_read_i16 = big_endian ? fread_i16_be : fread_i16_le;
  wad_read_i32 = big_endian ? fread_i32_be : fread_i32_le;
}

canonical_original_code:
void set_input_wad_endianness(int big_endian)
{
  wad_read_i16 = big_endian ? fread_i16_be : fread_i16_le;
  wad_read_i32 = big_endian ? fread_i32_be : fread_i32_le;
}


decompiled_code:
__int64 __fastcall parse_pic_header(unsigned __int8 *a1, __int64 a2, __int64 a3, char *a4)
{
unsigned __int64 v6; // r13
int v7; // eax
bool v8; // zf
__int16 v9; // dx
unsigned __int8 *v10; // rbp
__int16 v11; // cx
__int16 v12; // cx
__int16 v13; // cx
unsigned __int64 v14; // rbp
__int64 result; // rax

v6 = (unsigned __int64)&a1[a2 - 1];
v7 = picture_format;
v8 = picture_format == 0;
*(_DWORD *)(a3 + 32) = picture_format == 0;
if ( v8 )
{
*(_QWORD *)(a3 + 24) = 4LL;
}
else
{
*(_QWORD *)(a3 + 24) = 2LL;
if ( v7 == 1 )
{
if ( v6 >= (unsigned __int64)(a1 + 3) )
{
v9 = *a1;
*(_WORD *)a3 = v9;
*(_WORD *)(a3 + 2) = a1[1];
*(_WORD *)(a3 + 4) = a1[2];
*(_WORD *)(a3 + 6) = a1[3];
if ( v9 > 0 )
{
v10 = a1 + 4;
v11 = *(_WORD *)(a3 + 2);
if ( v11 > 0 )
goto LABEL_6;
goto LABEL_24;
}
goto LABEL_18;
}
result = 1LL;
if ( !a4 )
return result;
LABEL_39:
strcpy(a4, "header too short");
return 1LL;
}
}
if ( v6 < (unsigned __int64)(a1 + 7) )
{
result = 1LL;
if ( !a4 )
return result;
goto LABEL_39;
}
read_i16_le(a1, a3);
read_i16_le(a1 + 2, a3 + 2);
read_i16_le(a1 + 4, a3 + 4);
read_i16_le(a1 + 6, a3 + 6);
v9 = *(_WORD *)a3;
if ( *(__int16 *)a3 <= 0 )
{
LABEL_18:
result = 1LL;
if ( a4 )
{
sprintf(a4, "width < 1 (%d)", (unsigned int)v9);
result = 1LL;
}
return result;
}
if ( v9 <= 4096 )
{
v10 = a1 + 8;
v11 = *(_WORD *)(a3 + 2);
if ( v11 <= 0 )
{
LABEL_24:
result = 1LL;
if ( a4 )
{
sprintf(a4, "height < 1 (%d)", (unsigned int)v11);
result = 1LL;
}
return result;
}
if ( v11 <= 4096 )
{
LABEL_6:
v12 = *(_WORD *)(a3 + 4);
if ( v12 < -4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "X-offset < -4096 (%d)", (unsigned int)v12);
result = 1LL;
}
}
else if ( v12 > 4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "X-offset > 4096 (%d)", (unsigned int)v12);
result = 1LL;
}
}
else
{
v13 = *(_WORD *)(a3 + 6);
if ( v13 < -4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "Y-offset < -4096 (%d)", (unsigned int)v13);
result = 1LL;
}
}
else if ( v13 > 4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "Y-offset > 4096 (%d)", (unsigned int)v13);
result = 1LL;
}
}
else
{
*(_QWORD *)(a3 + 8) = v10;
v14 = (unsigned __int64)&v10[*(_QWORD *)(a3 + 24) * v9];
if ( v6 < v14 )
{
result = 1LL;
if ( a4 )
{
strcpy(a4, "offsets table too short");
result = 1LL;
}
}
else
{
*(_QWORD *)(a3 + 16) = v14;
result = 0LL;
}
}
}
return result;
}
result = 1LL;
if ( a4 )
{
sprintf(a4, "height > 4096 (%d)", (unsigned int)v11);
result = 1LL;
}
}
else
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "width > 4096 (%d)", (unsigned int)v9);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, __int64 a2, __int64 a3, char *a4)
{
unsigned __int64 v6; // r13
int v7; // eax
bool v8; // zf
__int16 v9; // dx
unsigned __int8 *v10; // rbp
__int16 v11; // cx
__int16 v12; // cx
__int16 v13; // cx
unsigned __int64 v14; // rbp
__int64 result; // rax

v6 = (unsigned __int64)&a1[a2 - 1];
v7 = picture_format;
v8 = picture_format == 0;
*(_DWORD *)(a3 + 32) = picture_format == 0;
if ( v8 )
{
*(_QWORD *)(a3 + 24) = 4LL;
}
else
{
*(_QWORD *)(a3 + 24) = 2LL;
if ( v7 == 1 )
{
if ( v6 >= (unsigned __int64)(a1 + 3) )
{
v9 = *a1;
*(_WORD *)a3 = v9;
*(_WORD *)(a3 + 2) = a1[1];
*(_WORD *)(a3 + 4) = a1[2];
*(_WORD *)(a3 + 6) = a1[3];
if ( v9 > 0 )
{
v10 = a1 + 4;
v11 = *(_WORD *)(a3 + 2);
if ( v11 > 0 )
goto LABEL_6;
goto LABEL_24;
}
goto LABEL_18;
}
result = 1LL;
if ( !a4 )
return result;
LABEL_39:
strcpy(a4, "header too short");
return 1LL;
}
}
if ( v6 < (unsigned __int64)(a1 + 7) )
{
result = 1LL;
if ( !a4 )
return result;
goto LABEL_39;
}
read_i16_le(a1, a3);
read_i16_le(a1 + 2, a3 + 2);
read_i16_le(a1 + 4, a3 + 4);
read_i16_le(a1 + 6, a3 + 6);
v9 = *(_WORD *)a3;
if ( *(__int16 *)a3 <= 0 )
{
LABEL_18:
result = 1LL;
if ( a4 )
{
sprintf(a4, "width < 1 (%d)", (unsigned int)v9);
result = 1LL;
}
return result;
}
if ( v9 <= 4096 )
{
v10 = a1 + 8;
v11 = *(_WORD *)(a3 + 2);
if ( v11 <= 0 )
{
LABEL_24:
result = 1LL;
if ( a4 )
{
sprintf(a4, "height < 1 (%d)", (unsigned int)v11);
result = 1LL;
}
return result;
}
if ( v11 <= 4096 )
{
LABEL_6:
v12 = *(_WORD *)(a3 + 4);
if ( v12 < -4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "X-offset < -4096 (%d)", (unsigned int)v12);
result = 1LL;
}
}
else if ( v12 > 4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "X-offset > 4096 (%d)", (unsigned int)v12);
result = 1LL;
}
}
else
{
v13 = *(_WORD *)(a3 + 6);
if ( v13 < -4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "Y-offset < -4096 (%d)", (unsigned int)v13);
result = 1LL;
}
}
else if ( v13 > 4096 )
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "Y-offset > 4096 (%d)", (unsigned int)v13);
result = 1LL;
}
}
else
{
*(_QWORD *)(a3 + 8) = v10;
v14 = (unsigned __int64)&v10[*(_QWORD *)(a3 + 24) * v9];
if ( v6 < v14 )
{
result = 1LL;
if ( a4 )
{
strcpy(a4, "offsets table too short");
result = 1LL;
}
}
else
{
*(_QWORD *)(a3 + 16) = v14;
result = 0LL;
}
}
}
return result;
}
result = 1LL;
if ( a4 )
{
sprintf(a4, "height > 4096 (%d)", (unsigned int)v11);
result = 1LL;
}
}
else
{
result = 1LL;
if ( a4 )
{
sprintf(a4, "width > 4096 (%d)", (unsigned int)v9);
result = 1LL;
}
}
return result;
}

original_code:
int parse_pic_header (
    const unsigned char *buf,
    long bufsz,
    pic_head_t *h,
    char *message)
{
   const unsigned char *p = (const unsigned char *) buf;
   const unsigned char *buf_end = ((const unsigned char *) buf) + bufsz - 1;
   h->dummy_bytes = picture_format == PF_NORMAL;
   h->colofs_size = (picture_format == PF_NORMAL) ? 4 : 2;
   if (picture_format != PF_ALPHA)
   {
      if (p + 8 - 1 > buf_end)
  do{if (message) strcpy (message, "header too short"); return 1;}while(0);
      read_i16_le (p, &h->width);
      p += 2;
      read_i16_le (p, &h->height);
      p += 2;
      read_i16_le (p, &h->xofs);
      p += 2;
      read_i16_le (p, &h->yofs);
      p += 2;
   }
   else
   {
      if (p + 4 - 1 > buf_end)
  do{if (message) strcpy (message, "header too short"); return 1;}while(0);
      h->width = *p++;
      h->height = *p++;
      h->xofs = *p++;
      h->yofs = *p++;
   }
   if (h->width < 1)
      do{if (message) sprintf (message, "width < 1 (%d)", (int) h->width); return 1;}while(0);
   if (h->width > 4096)
      do{if (message) sprintf (message, "width > 4096 (%d)", (int) h->width); return 1;}while(0);
   if (h->height < 1)
      do{if (message) sprintf (message, "height < 1 (%d)", (int) h->height); return 1;}while(0);
   if (h->height > 4096)
      do{if (message) sprintf (message, "height > 4096 (%d)", (int)h->height); return 1;}while(0);
   if (h->xofs < -4096)
      do{if (message) sprintf (message, "X-offset < -4096 (%d)", (int) h->xofs); return 1;}while(0);
   if (h->xofs > 4096)
      do{if (message) sprintf (message, "X-offset > 4096 (%d)", (int) h->xofs); return 1;}while(0);
   if (h->yofs < -4096)
      do{if (message) sprintf (message, "Y-offset < -4096 (%d)", (int) h->yofs); return 1;}while(0);
   if (h->yofs > 4096)
      do{if (message) sprintf (message, "Y-offset > 4096 (%d)", (int) h->yofs); return 1;}while(0);
   h->colofs = p;
   p += (long) h->colofs_size * h->width;
   if (p > buf_end)
      do{if (message) strcpy (message, "offsets table too short"); return 1;}while(0);
   h->data = p;
   return 0;
}

canonical_original_code:
int parse_pic_header(unsigned char *buf, long bufsz, struct pic_head_t *h, char *message)
{
   unsigned char *p = (const unsigned char *) buf;
   unsigned char *buf_end = ((const unsigned char *) buf) + bufsz - 1;
   h->dummy_bytes = picture_format == PF_NORMAL;
   h->colofs_size = (picture_format == PF_NORMAL) ? 4 : 2;
   if (picture_format != PF_ALPHA)
   {
      if (p + 8 - 1 > buf_end)
  do{if (message) strcpy (message, "header too short"); return 1;}while(0);
      read_i16_le (p, &h->width);
      p += 2;
      read_i16_le (p, &h->height);
      p += 2;
      read_i16_le (p, &h->xofs);
      p += 2;
      read_i16_le (p, &h->yofs);
      p += 2;
   }
   else
   {
      if (p + 4 - 1 > buf_end)
  do{if (message) strcpy (message, "header too short"); return 1;}while(0);
      h->width = *p++;
      h->height = *p++;
      h->xofs = *p++;
      h->yofs = *p++;
   }
   if (h->width < 1)
      do{if (message) sprintf (message, "width < 1 (%d)", (int) h->width); return 1;}while(0);
   if (h->width > 4096)
      do{if (message) sprintf (message, "width > 4096 (%d)", (int) h->width); return 1;}while(0);
   if (h->height < 1)
      do{if (message) sprintf (message, "height < 1 (%d)", (int) h->height); return 1;}while(0);
   if (h->height > 4096)
      do{if (message) sprintf (message, "height > 4096 (%d)", (int)h->height); return 1;}while(0);
   if (h->xofs < -4096)
      do{if (message) sprintf (message, "X-offset < -4096 (%d)", (int) h->xofs); return 1;}while(0);
   if (h->xofs > 4096)
      do{if (message) sprintf (message, "X-offset > 4096 (%d)", (int) h->xofs); return 1;}while(0);
   if (h->yofs < -4096)
      do{if (message) sprintf (message, "Y-offset < -4096 (%d)", (int) h->yofs); return 1;}while(0);
   if (h->yofs > 4096)
      do{if (message) sprintf (message, "Y-offset > 4096 (%d)", (int) h->yofs); return 1;}while(0);
   h->colofs = p;
   p += (long) h->colofs_size * h->width;
   if (p > buf_end)
      do{if (message) strcpy (message, "offsets table too short"); return 1;}while(0);
   h->data = p;
   return 0;
}

variable_types:
buf
unsigned char *

variable_types: bufsz long

variable_types: struct pic_head_t { short width; short height; short xofs; short yofs; void *colofs; unsigned char *data; unsigned long colofs_size; int dummy_bytes; } *

variable_types:
message
char *