mystrdup

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

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

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

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

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 *


repo: AlertProject/CCCC

decompiled_code:
const char **__fastcall dumpFcache1(char *s2)
{
const char **v1; // r12
__int64 *v2; // r14
__int64 v3; // r15
__int64 i; // rbx
const char *v5; // rbp

v1 = 0LL;
v2 = (__int64 *)Fcache;
v3 = Fcache + 4424LL;
do
{
for ( i = *v2; i; i = *(_QWORD *)(i + 8) )
{
while ( 1 )
{
v5 = *(const char **)i;
if ( strcmp(*(const char **)i, s2) > 0 )
break;
LABEL_6:
i = *(_QWORD *)(i + 8);
if ( !i )
goto LABEL_10;
}
if ( v1 )
{
if ( strcmp(v5, *v1) < 0 )
v1 = (const char **)i;
goto LABEL_6;
}
v1 = (const char **)i;
}
LABEL_10:
++v2;
}
while ( v2 != (__int64 *)v3 );
return v1;
}

canonical_decompiled_code:
const char **__fastcall func0(char *s2)
{
const char **v1; // r12
__int64 *v2; // r14
__int64 v3; // r15
__int64 i; // rbx
const char *v5; // rbp

v1 = 0LL;
v2 = (__int64 *)Fcache;
v3 = Fcache + 4424LL;
do
{
for ( i = *v2; i; i = *(_QWORD *)(i + 8) )
{
while ( 1 )
{
v5 = *(const char **)i;
if ( strcmp(*(const char **)i, s2) > 0 )
break;
LABEL_6:
i = *(_QWORD *)(i + 8);
if ( !i )
goto LABEL_10;
}
if ( v1 )
{
if ( strcmp(v5, *v1) < 0 )
v1 = (const char **)i;
goto LABEL_6;
}
v1 = (const char **)i;
}
LABEL_10:
++v2;
}
while ( v2 != (__int64 *)v3 );
return v1;
}

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: struct _entry { char *str; struct _entry *next; } **

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
int i; // edi
char v4; // al

fwrite("\nrule ", 1uLL, 6uLL, stdout);
v2 = *a1;
for ( i = **a1; *v2 != 42; i = *v2 )
{
++v2;
fputc(i, stdout);
}
v4 = v2[1];
if ( v4 == 105 )
{
fwrite(" First[", 1uLL, 7uLL, stdout);
v4 = v2[1];
}
if ( v4 == 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
int i; // edi
char v4; // al

fwrite("\nrule ", 1uLL, 6uLL, stdout);
v2 = *a1;
for ( i = **a1; *v2 != 42; i = *v2 )
{
++v2;
fputc(i, stdout);
}
v4 = v2[1];
if ( v4 == 105 )
{
fwrite(" First[", 1uLL, 7uLL, stdout);
v4 = v2[1];
}
if ( v4 == 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 *

return_type: void

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


DumpFcache

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

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

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

fwrite("\n\nDump of First/Follow Cache\n", 1uLL, 0x1DuLL, stdout);
for ( i = (char *)&unk_24E; ; i = *v2 )
{
v1 = (char **)func0(i);
v2 = 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 = 0LL;
memset(&dfa_hash, 0, 0x698uLL);
return result;
}

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

result = 0LL;
memset(&dfa_hash, 0, 0x698uLL);
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(unsigned int *a1, unsigned int a2, _DWORD *a3)
{
unsigned int v3; // er13
__int64 v5; // rax
unsigned int *i; // rbx
__int64 v7; // r14
int *v8; // rdx
int v9; // eax
__int64 result; // rax

v3 = 0;
if ( a1 )
{
v5 = *a1;
for ( i = a1; (_DWORD)v5 != -1; ++i )
{
v7 = *(_QWORD *)(nfa_array + 8 * v5);
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;
v3 = 1;
++a3;
}
v5 = i[1];
}
}
result = v3;
*a3 = -1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1, unsigned int a2, _DWORD *a3)
{
unsigned int v3; // er13
__int64 v5; // rax
unsigned int *i; // rbx
__int64 v7; // r14
int *v8; // rdx
int v9; // eax
__int64 result; // rax

v3 = 0;
if ( a1 )
{
v5 = *a1;
for ( i = a1; (_DWORD)v5 != -1; ++i )
{
v7 = *(_QWORD *)(nfa_array + 8 * v5);
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;
v3 = 1;
++a3;
}
v5 = i[1];
}
}
result = v3;
*a3 = -1;
return result;
}

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

return_type: 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(unsigned int *a1, unsigned int a2, __int64 a3)
{
unsigned int *i; // rbx
unsigned int *v5; // r12

i = a1;
v5 = (unsigned int *)*((_QWORD *)a1 + 2);
a1[1] = a2;
if ( v5 )
{
LABEL_2:
if ( (unsigned int)set_nil(i[8], *((_QWORD *)i + 5)) )
{
if ( v5[1] != a2 )
{
set_orel(*v5, a3);
close1(v5, a2, a3);
}
}
}
for ( i = (unsigned int *)*((_QWORD *)i + 3); i; i = (unsigned int *)*((_QWORD *)i + 3) )
{
if ( i[1] == a2 )
break;
set_orel(*i, a3);
v5 = (unsigned int *)*((_QWORD *)i + 2);
i[1] = a2;
if ( v5 )
goto LABEL_2;
}
}

canonical_decompiled_code:
void __fastcall func2(unsigned int *a1, unsigned int a2, __int64 a3)
{
unsigned int *i; // rbx
unsigned int *v5; // r12

i = a1;
v5 = (unsigned int *)*((_QWORD *)a1 + 2);
a1[1] = a2;
if ( v5 )
{
LABEL_2:
if ( (unsigned int)set_nil(i[8], *((_QWORD *)i + 5)) )
{
if ( v5[1] != a2 )
{
set_orel(*v5, a3);
func2(v5, a2, a3);
}
}
}
for ( i = (unsigned int *)*((_QWORD *)i + 3); i; i = (unsigned int *)*((_QWORD *)i + 3) )
{
if ( i[1] == a2 )
break;
set_orel(*i, a3);
v5 = (unsigned int *)*((_QWORD *)i + 2);
i[1] = a2;
if ( v5 )
goto LABEL_2;
}
}

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)
{
__int64 v3; // rax
unsigned int *v4; // rbp
__int64 v5; // rdi
unsigned int *v6; // rbx
unsigned int *v7; // r12
unsigned int *v8; // r12

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

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

++operation_no;
v3 = *a2;
if ( (_DWORD)v3 != -1 )
{
v4 = a2;
do
{
v5 = 0LL;
v6 = *(unsigned int **)(nfa_array + 8 * v3);
if ( v6 )
v5 = *v6;
set_orel(v5, a1);
v7 = (unsigned int *)*((_QWORD *)v6 + 2);
v6[1] = operation_no;
if ( v7 && (unsigned int)set_nil(v6[8], *((_QWORD *)v6 + 5)) && v7[1] != operation_no )
{
set_orel(*v7, a1);
func2(v7, operation_no, a1);
}
v8 = (unsigned int *)*((_QWORD *)v6 + 3);
if ( v8 && v8[1] != operation_no )
{
set_orel(*v8, a1);
func2(v8, operation_no, a1);
}
v3 = v4[1];
++v4;
}
while ( (_DWORD)v3 != -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; }


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; // ebp
_QWORD *v1; // r12
_QWORD *v2; // r13
_QWORD *v3; // rax
_QWORD *v4; // rdi
_QWORD *v5; // rbx
_QWORD *v6; // r14
_QWORD *v7; // r15
__int64 v8; // rax
int v9; // [rsp+0h] [rbp-3Ch]

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

canonical_decompiled_code:
void func0()
{
int v0; // ebp
_QWORD *v1; // r12
_QWORD *v2; // r13
_QWORD *v3; // rax
_QWORD *v4; // rdi
_QWORD *v5; // rbx
_QWORD *v6; // r14
_QWORD *v7; // r15
__int64 v8; // rax
int v9; // [rsp+0h] [rbp-3Ch]

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

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; // rsi
__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; // rsi
__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; // rsi
__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; // rsi
__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()
{
__int64 v0; // rcx
int v1; // er9
_QWORD *v2; // rdi
int v3; // esi
__int64 v4; // r8
__int64 v5; // rax
__int64 v6; // rdx

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

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

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

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)
{
const char *v2; // rsi
char *result; // rax

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

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

PrintInit(1LL);
PrintVerbosity(3LL);
v2 = *(const char **)(a2 + 8);
DoomDir = 0LL;
result = strncpy(MainWAD, v2, 0x80uLL);
trnR = 0;
Select |= 0x7FFu;
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)
{
const char *v2; // rsi

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

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
const char *v2; // rsi

v2 = *(const char **)(a2 + 8);
DoomDir = 0LL;
strncpy(MainWAD, v2, 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; // r8

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; // r8

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)
{
__int64 v2; // rsi

v2 = *(_QWORD *)(a2 + 8);
Select = 1919;
return ADDappendSpriteFloor(MainWAD, v2, 1919LL);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
__int64 v2; // rsi

v2 = *(_QWORD *)(a2 + 8);
Select = 1919;
return ADDappendSpriteFloor(MainWAD, v2, 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)
{
__int64 v2; // rsi

v2 = *(_QWORD *)(a2 + 8);
Select = 2015;
return ADDappendSpriteFloor(MainWAD, v2, 2015LL);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
__int64 v2; // rsi

v2 = *(_QWORD *)(a2 + 8);
Select = 2015;
return ADDappendSpriteFloor(MainWAD, v2, 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)
{
__int64 v2; // rsi

v2 = *(_QWORD *)(a2 + 8);
Select = 2047;
return PSTmergeWAD(MainWAD, v2, 2047LL);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
__int64 v2; // rsi

v2 = *(_QWORD *)(a2 + 8);
Select = 2047;
return PSTmergeWAD(MainWAD, v2, 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; // r8
bool v3; // zf
_BOOL4 v4; // ebx
const char *v5; // r8
int v6; // eax
int v7; // er12

v2 = *a2;
v3 = strcmp(*a2, "itf") == 0;
v4 = !v3;
if ( v3 )
goto LABEL_13;
if ( !strcmp(v2, "otf") )
{
if ( a1 <= 1 )
{
ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", v2);
LABEL_32:
v5 = a2[1];
goto LABEL_9;
}
v5 = a2[1];
v6 = 1;
v4 = strcmp(v5, "nameless") != 0;
if ( v4 )
goto LABEL_5;
LABEL_37:
output_texture_format = 1;
goto LABEL_8;
}
if ( *v2 == 116 && v2[1] == 102 )
{
v4 = 1;
if ( !v2[2] )
{
LABEL_13:
if ( a1 <= 1 )
{
ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", v2);
v5 = a2[1];
goto LABEL_34;
}
v5 = a2[1];
if ( strcmp(v5, "nameless") )
{
v7 = 1;
if ( !strcmp(a2[1], "none") )
{
input_texture_format = 2;
if ( v4 )
{
LABEL_7:
output_texture_format = 2;
goto LABEL_8;
}
goto LABEL_25;
}
goto LABEL_16;
}
input_texture_format = 1;
if ( !v4 )
goto LABEL_25;
goto LABEL_37;
}
}
Bug("COMtf: bad argv[0] \"%.32s\"", v2);
if ( a1 <= 1 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
return v6;
}
v5 = a2[1];
v3 = strcmp(v5, "nameless") == 0;
LOBYTE(v6) = !v3;
if ( v3 )
return v6;
v6 = 0;
LABEL_5:
v3 = strcmp(v5, "none") == 0;
v4 = !v3;
if ( v3 )
{
if ( !v6 )
return v6;
goto LABEL_7;
}
v4 = v6;
v7 = 0;
LABEL_16:
v3 = strcmp(v5, "normal") == 0;
LOBYTE(v6) = !v3;
if ( v3 )
{
if ( !v7 )
{
if ( !v4 )
return v6;
goto LABEL_19;
}
input_texture_format = 0;
if ( v4 )
{
LABEL_19:
output_texture_format = 0;
v4 = v7;
goto LABEL_8;
}
LABEL_25:
LOBYTE(v6) = Info("Input texture format is \"%s\"\n", v5);
return v6;
}
v3 = strcmp(v5, "strife11") == 0;
LOBYTE(v6) = !v3;
if ( !v3 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
if ( !v7 )
{
LABEL_35:
if ( !v4 )
return v6;
goto LABEL_32;
}
v5 = a2[1];
LABEL_34:
LOBYTE(v6) = Info("Input texture format is \"%s\"\n", v5);
goto LABEL_35;
}
if ( v7 )
{
input_texture_format = 3;
if ( !v4 )
goto LABEL_25;
}
else if ( !v4 )
{
return v6;
}
output_texture_format = 3;
v4 = v7;
LABEL_8:
if ( v4 )
goto LABEL_34;
LABEL_9:
LOBYTE(v6) = Info("Output texture format is \"%s\"\n", v5);
return v6;
}

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

v2 = *a2;
v3 = strcmp(*a2, "itf") == 0;
v4 = !v3;
if ( v3 )
goto LABEL_13;
if ( !strcmp(v2, "otf") )
{
if ( a1 <= 1 )
{
ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", v2);
LABEL_32:
v5 = a2[1];
goto LABEL_9;
}
v5 = a2[1];
v6 = 1;
v4 = strcmp(v5, "nameless") != 0;
if ( v4 )
goto LABEL_5;
LABEL_37:
output_texture_format = 1;
goto LABEL_8;
}
if ( *v2 == 116 && v2[1] == 102 )
{
v4 = 1;
if ( !v2[2] )
{
LABEL_13:
if ( a1 <= 1 )
{
ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", v2);
v5 = a2[1];
goto LABEL_34;
}
v5 = a2[1];
if ( strcmp(v5, "nameless") )
{
v7 = 1;
if ( !strcmp(a2[1], "none") )
{
input_texture_format = 2;
if ( v4 )
{
LABEL_7:
output_texture_format = 2;
goto LABEL_8;
}
goto LABEL_25;
}
goto LABEL_16;
}
input_texture_format = 1;
if ( !v4 )
goto LABEL_25;
goto LABEL_37;
}
}
Bug("COMtf: bad argv[0] \"%.32s\"", v2);
if ( a1 <= 1 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
return v6;
}
v5 = a2[1];
v3 = strcmp(v5, "nameless") == 0;
LOBYTE(v6) = !v3;
if ( v3 )
return v6;
v6 = 0;
LABEL_5:
v3 = strcmp(v5, "none") == 0;
v4 = !v3;
if ( v3 )
{
if ( !v6 )
return v6;
goto LABEL_7;
}
v4 = v6;
v7 = 0;
LABEL_16:
v3 = strcmp(v5, "normal") == 0;
LOBYTE(v6) = !v3;
if ( v3 )
{
if ( !v7 )
{
if ( !v4 )
return v6;
goto LABEL_19;
}
input_texture_format = 0;
if ( v4 )
{
LABEL_19:
output_texture_format = 0;
v4 = v7;
goto LABEL_8;
}
LABEL_25:
LOBYTE(v6) = Info("Input texture format is \"%s\"\n", v5);
return v6;
}
v3 = strcmp(v5, "strife11") == 0;
LOBYTE(v6) = !v3;
if ( !v3 )
{
LOBYTE(v6) = ProgError("Usage is \"-%.32s {nameless|none|normal|strife11}\"", *a2);
if ( !v7 )
{
LABEL_35:
if ( !v4 )
return v6;
goto LABEL_32;
}
v5 = a2[1];
LABEL_34:
LOBYTE(v6) = Info("Input texture format is \"%s\"\n", v5);
goto LABEL_35;
}
if ( v7 )
{
input_texture_format = 3;
if ( !v4 )
goto LABEL_25;
}
else if ( !v4 )
{
return v6;
}
output_texture_format = 3;
v4 = v7;
LABEL_8:
if ( v4 )
goto LABEL_34;
LABEL_9:
LOBYTE(v6) = Info("Output texture format is \"%s\"\n", v5);
return 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()
{
const char *v0; // rsi
char **v1; // rbx
__int64 result; // rax

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

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

v0 = "To work with this progam, your PWAD must respect this format:";
v1 = off_1D08;
do
{
++v1;
result = Output("%s\n", v0);
v0 = *(v1 - 1);
}
while ( v0 );
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:
__int64 __fastcall read_i32_le(unsigned int *a1, _QWORD *a2)
{
__int64 result; // rax

result = *a1;
*a2 = result;
return result;
}

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

result = *a1;
*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:
__int64 __fastcall peek_i32_be(unsigned int *a1)
{
return _byteswap_ulong(*a1);
}

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

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:
__int64 __fastcall peek_i32_le(unsigned int *a1)
{
return *a1;
}

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

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:
void __fastcall write_i16_le(_WORD *a1, __int16 a2)
{
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func6(_WORD *a1, __int16 a2)
{
*a1 = 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:
void __fastcall write_i32_le(_DWORD *a1, int a2)
{
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func8(_DWORD *a1, int a2)
{
*a1 = a2;
}

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; // rax
unsigned __int64 v1; // rdx
const unsigned __int16 *v2; // rdi
__int16 v3; // ax
unsigned __int16 v4; // cx
__int64 result; // rax

v0 = _ctype_b_loc();
v1 = 0LL;
v2 = *v0;
while ( 1 )
{
v3 = 0;
if ( v1 <= 0x5F )
v3 = CSWTCH_67[v1];
v4 = v2[v1];
if ( (v4 & 0x800) != 0 )
v3 |= 0x140u;
if ( (v4 & 0x400) != 0 )
v3 |= 0x130u;
if ( (v4 & 0x2000) != 0 )
v3 |= 2u;
if ( v1 != 37 )
break;
word_FEA = v3 | 0x20;
LABEL_3:
++v1;
}
TXTval[v1] = v3;
if ( v1 != 255 )
goto LABEL_3;
result = 1LL;
TXTok = 1;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
const unsigned __int16 **v0; // rax
unsigned __int64 v1; // rdx
const unsigned __int16 *v2; // rdi
__int16 v3; // ax
unsigned __int16 v4; // cx
__int64 result; // rax

v0 = _ctype_b_loc();
v1 = 0LL;
v2 = *v0;
while ( 1 )
{
v3 = 0;
if ( v1 <= 0x5F )
v3 = CSWTCH_67[v1];
v4 = v2[v1];
if ( (v4 & 0x800) != 0 )
v3 |= 0x140u;
if ( (v4 & 0x400) != 0 )
v3 |= 0x130u;
if ( (v4 & 0x2000) != 0 )
v3 |= 2u;
if ( v1 != 37 )
break;
word_FEA = v3 | 0x20;
LABEL_3:
++v1;
}
TXTval[v1] = v3;
if ( v1 != 255 )
goto LABEL_3;
result = 1LL;
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 *v1; // rdx
void *result; // rax

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

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

v1 = &fwrite_i16_be;
if ( !a1 )
v1 = &fwrite_i16_le;
result = &fwrite_i32_be;
if ( !a1 )
result = &fwrite_i32_le;
wad_write_i16 = v1;
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 *v1; // rdx
void *result; // rax

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

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

v1 = &fread_i16_be;
if ( !a1 )
v1 = &fread_i16_le;
result = &fread_i32_be;
if ( !a1 )
result = &fread_i32_le;
wad_read_i16 = v1;
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, __int16 *a3, char *a4)
{
unsigned __int64 v5; // rbp
int v7; // eax
bool v8; // zf
__int64 v9; // rdx
__int16 v10; // ax
unsigned __int8 *v11; // r12
__int16 v12; // ax
__int16 v13; // ax
__int64 v14; // rdx
unsigned __int64 v15; // r12
__int64 result; // rax
__m128i v17; // xmm0
__m128i v18; // xmm0

v5 = (unsigned __int64)&a1[a2 - 1];
v7 = picture_format;
v8 = picture_format == 0;
*((_DWORD *)a3 + 8) = picture_format == 0;
if ( v8 )
{
*((_QWORD *)a3 + 3) = 4LL;
}
else
{
*((_QWORD *)a3 + 3) = 2LL;
if ( v7 == 1 )
{
if ( v5 >= (unsigned __int64)(a1 + 3) )
{
v9 = *a1;
*a3 = v9;
v10 = a1[1];
a3[1] = v10;
a3[2] = a1[2];
a3[3] = a1[3];
if ( (_WORD)v9 )
{
v11 = a1 + 4;
if ( v10 )
goto LABEL_6;
LABEL_20:
if ( a4 )
{
sprintf(a4, "height < 1 (%d)", (unsigned int)v10);
return 1LL;
}
return 1LL;
}
LABEL_26:
if ( a4 )
{
sprintf(a4, "width < 1 (%d)", v9);
return 1LL;
}
return 1LL;
}
LABEL_14:
if ( a4 )
{
v17 = _mm_load_si128((const __m128i *)&LC8);
a4[16] = 0;
result = 1LL;
*(__m128i *)a4 = v17;
return result;
}
return 1LL;
}
}
if ( v5 < (unsigned __int64)(a1 + 7) )
goto LABEL_14;
read_i16_le(a1, a3);
read_i16_le(a1 + 2, a3 + 1);
read_i16_le(a1 + 4, a3 + 2);
read_i16_le(a1 + 6, a3 + 3);
v9 = *a3;
if ( (__int16)v9 <= 0 )
goto LABEL_26;
if ( (__int16)v9 > 4096 )
{
if ( a4 )
{
sprintf(a4, "width > 4096 (%d)", v9);
return 1LL;
}
return 1LL;
}
v10 = a3[1];
v11 = a1 + 8;
if ( v10 <= 0 )
goto LABEL_20;
if ( v10 > 4096 )
{
if ( a4 )
{
sprintf(a4, "height > 4096 (%d)", (unsigned int)v10);
return 1LL;
}
return 1LL;
}
LABEL_6:
v12 = a3[2];
if ( v12 < -4096 )
{
if ( a4 )
{
sprintf(a4, "X-offset < -4096 (%d)", (unsigned int)v12);
return 1LL;
}
return 1LL;
}
if ( v12 > 4096 )
{
if ( a4 )
{
sprintf(a4, "X-offset > 4096 (%d)", (unsigned int)v12);
return 1LL;
}
return 1LL;
}
v13 = a3[3];
if ( v13 < -4096 )
{
if ( a4 )
{
sprintf(a4, "Y-offset < -4096 (%d)", (unsigned int)v13);
return 1LL;
}
return 1LL;
}
if ( v13 <= 4096 )
{
v14 = *((_QWORD *)a3 + 3) * v9;
*((_QWORD *)a3 + 1) = v11;
v15 = (unsigned __int64)&v11[v14];
if ( v5 >= v15 )
{
*((_QWORD *)a3 + 2) = v15;
return 0LL;
}
if ( a4 )
{
v18 = _mm_load_si128((const __m128i *)&LC9);
*((_QWORD *)a4 + 2) = 0x74726F6873206FLL;
*(__m128i *)a4 = v18;
}
return 1LL;
}
if ( !a4 )
return 1LL;
sprintf(a4, "Y-offset > 4096 (%d)", (unsigned int)v13);
return 1LL;
}

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 *


repo: AlexPnt/Library-Management-System

decompiled_code:
__int64 __fastcall compara_data(unsigned __int64 a1, int a2, unsigned __int64 a3, int a4)
{
int v4; // er9
int v5; // er8
unsigned __int64 v6; // rdi
__int64 result; // rax
unsigned __int64 v8; // rdx

v4 = a1;
v5 = a3;
v6 = HIDWORD(a1);
result = 0xFFFFFFFFLL;
v8 = HIDWORD(a3);
if ( a2 >= a4 )
{
result = 1LL;
if ( a2 <= a4 )
{
result = 0xFFFFFFFFLL;
if ( (int)v6 >= (int)v8 )
{
result = 1LL;
if ( (int)v6 <= (int)v8 )
{
result = v4 > v5;
if ( v4 < v5 )
result = 0xFFFFFFFFLL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1, int a2, unsigned __int64 a3, int a4)
{
int v4; // er9
int v5; // er8
unsigned __int64 v6; // rdi
__int64 result; // rax
unsigned __int64 v8; // rdx

v4 = a1;
v5 = a3;
v6 = HIDWORD(a1);
result = 0xFFFFFFFFLL;
v8 = HIDWORD(a3);
if ( a2 >= a4 )
{
result = 1LL;
if ( a2 <= a4 )
{
result = 0xFFFFFFFFLL;
if ( (int)v6 >= (int)v8 )
{
result = 1LL;
if ( (int)v6 <= (int)v8 )
{
result = v4 > v5;
if ( v4 < v5 )
result = 0xFFFFFFFFLL;
}
}
}
}
return result;
}

original_code:
int compara_data(Data d1,Data d2)
{
    int comparacao;
    if(d1.ano<d2.ano)
        comparacao= -1;
    else if(d1.ano>d2.ano)
        comparacao= 1;
    else
    {
        if(d1.mes<d2.mes)
            comparacao= -1;
        else if(d1.mes>d2.mes)
            comparacao= 1;
        else
        {
            if(d1.dia<d2.dia)
                comparacao= -1;
            else if(d1.dia>d2.dia)
                comparacao= 1;
            else
                comparacao= 0;
        }
    }
    return comparacao;
}

canonical_original_code:
int compara_data(struct Data d1, struct Data d2)
{
    int comparacao;
    if(d1.ano<d2.ano)
        comparacao= -1;
    else if(d1.ano>d2.ano)
        comparacao= 1;
    else
    {
        if(d1.mes<d2.mes)
            comparacao= -1;
        else if(d1.mes>d2.mes)
            comparacao= 1;
        else
        {
            if(d1.dia<d2.dia)
                comparacao= -1;
            else if(d1.dia>d2.dia)
                comparacao= 1;
            else
                comparacao= 0;
        }
    }
    return comparacao;
}

variable_types: struct Data { int dia; int mes; int ano; }

variable_types: comparacao int


decompiled_code:
__int64 __fastcall sete_dias(unsigned __int64 a1, int a2)
{
struct tm *v2; // rax
int v3; // edx
int v4; // ecx
time_t timer; // [rsp+18h] [rbp-20h] BYREF
unsigned __int64 v7; // [rsp+24h] [rbp-14h]

timer = time(0LL) - 604800;
v2 = localtime(&timer);
v3 = v2->tm_year;
v4 = v2->tm_mon;
LODWORD(v2) = v2->tm_mday;
HIDWORD(v7) = v4 + 1;
LODWORD(v7) = (_DWORD)v2;
return compara_data(v7, v3 + 1900, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 a1, int a2)
{
struct tm *v2; // rax
int v3; // edx
int v4; // ecx
time_t timer; // [rsp+18h] [rbp-20h] BYREF
unsigned __int64 v7; // [rsp+24h] [rbp-14h]

timer = time(0LL) - 604800;
v2 = localtime(&timer);
v3 = v2->tm_year;
v4 = v2->tm_mon;
LODWORD(v2) = v2->tm_mday;
HIDWORD(v7) = v4 + 1;
LODWORD(v7) = (_DWORD)v2;
return func0(v7, v3 + 1900, a1, a2);
}

original_code:
int sete_dias(Data data)
{
    struct tm *data_aux;
    time_t data_hj,data_7dias;
    Data data_comp;
    data_hj = time(0);
    data_7dias = data_hj - (7*24*3600);
    data_aux = localtime(&data_7dias);
    data_comp.ano = data_aux->tm_year+1900;
    data_comp.mes = data_aux->tm_mon+1;
    data_comp.dia = data_aux->tm_mday;
    return (compara_data(data_comp,data));
}

canonical_original_code:
int sete_dias(struct Data data)
{
    struct tm *data_aux;
    long data_hj; long data_7dias;
    struct Data data_comp;
    data_hj = time(0);
    data_7dias = data_hj - (7*24*3600);
    data_aux = localtime(&data_7dias);
    data_comp.ano = data_aux->tm_year+1900;
    data_comp.mes = data_aux->tm_mon+1;
    data_comp.dia = data_aux->tm_mday;
    return (compara_data(data_comp,data));
}

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

user_defined_types: struct Data { int dia; int mes; int ano; }


decompiled_code:
__int64 __fastcall data_actual(_DWORD *a1)
{
struct tm *v1; // rax
int v2; // ecx
int v3; // esi
__int64 result; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = time(0LL);
v1 = localtime(&timer);
v2 = v1->tm_year;
v3 = v1->tm_mon;
result = (unsigned int)v1->tm_mday;
a1[2] = v2 + 1900;
a1[1] = v3 + 1;
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1)
{
struct tm *v1; // rax
int v2; // ecx
int v3; // esi
__int64 result; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = time(0LL);
v1 = localtime(&timer);
v2 = v1->tm_year;
v3 = v1->tm_mon;
result = (unsigned int)v1->tm_mday;
a1[2] = v2 + 1900;
a1[1] = v3 + 1;
*a1 = result;
return result;
}

original_code:
void data_actual(Data *d1)
{
    struct tm *ptr_data;
    time_t lt;
    lt = time(0);
    ptr_data=localtime(&lt);
    d1->ano = ptr_data->tm_year+1900;
    d1->mes = ptr_data->tm_mon+1;
    d1->dia = ptr_data->tm_mday;
}

canonical_original_code:
void data_actual(struct Data *d1)
{
    struct tm *ptr_data;
    long lt;
    lt = time(0);
    ptr_data=localtime(&lt);
    d1->ano = ptr_data->tm_year+1900;
    d1->mes = ptr_data->tm_mon+1;
    d1->dia = ptr_data->tm_mday;
}

variable_types: struct Data { int dia; int mes; int ano; } *

variable_types: lt long

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


decompiled_code:
const char *__fastcall valida_u(__int64 a1)
{
const char *v1; // rax
const char *v2; // r12
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

do
{
do
{
printf("\nIntroduza o codigo do utente: ");
_isoc99_scanf("%d", v4);
puts("\n");
}
while ( getchar() != 10 );
}
while ( v4[0] <= 0 );
v1 = (const char *)pesquisa_lista_u(a1);
v2 = v1;
if ( v1 )
printf("\tNome: %s\n\n", v1);
return v2;
}

canonical_decompiled_code:
const char *__fastcall func3(__int64 a1)
{
const char *v1; // rax
const char *v2; // r12
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

do
{
do
{
printf("\nIntroduza o codigo do utente: ");
_isoc99_scanf("%d", v4);
puts("\n");
}
while ( getchar() != 10 );
}
while ( v4[0] <= 0 );
v1 = (const char *)pesquisa_lista_u(a1);
v2 = v1;
if ( v1 )
printf("\tNome: %s\n\n", v1);
return v2;
}

original_code:
Utente valida_u(Utente utentes)
{
    int utente_code;
    Utente aux_u;
    do {
    printf("\nIntroduza o codigo do utente: ");
    scanf("%d",&utente_code);
    printf("\n\n");
    } while (getchar()!='\n' || utente_code<1);
    if((aux_u=pesquisa_lista_u(utentes,utente_code)))
        printf("\tNome: %s\n\n",aux_u->registo.nome);
    return aux_u;
}

canonical_original_code:
struct no_u *valida_u(struct no_u *utentes)
{
    int utente_code;
    struct no_u *aux_u;
    do {
    printf("\nIntroduza o codigo do utente: ");
    scanf("%d",&utente_code);
    printf("\n\n");
    } while (getchar()!='\n' || utente_code<1);
    if((aux_u=pesquisa_lista_u(utentes,utente_code)))
        printf("\tNome: %s\n\n",aux_u->registo.nome);
    return aux_u;
}

variable_types:
utentes
struct no_u *

variable_types: struct no_u { struct Utente_str { char nome[100]; int cod_utente; } registo; struct no_u *prox; } *

user_defined_types: struct no_u { struct Utente_str registo; struct no_u *prox; }


decompiled_code:
const char *__fastcall valida_l(__int64 a1)
{
const char *v1; // rax
const char *v2; // r12
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

do
{
do
{
printf("\nIntroduza o codigo do livro: ");
_isoc99_scanf("%d", v4);
puts("\n");
}
while ( getchar() != 10 );
}
while ( v4[0] <= 0 );
v1 = (const char *)pesquisa_lista_l(a1);
v2 = v1;
if ( v1 )
printf("\tTitulo: %s\n\n", v1);
return v2;
}

canonical_decompiled_code:
const char *__fastcall func4(__int64 a1)
{
const char *v1; // rax
const char *v2; // r12
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

do
{
do
{
printf("\nIntroduza o codigo do livro: ");
_isoc99_scanf("%d", v4);
puts("\n");
}
while ( getchar() != 10 );
}
while ( v4[0] <= 0 );
v1 = (const char *)pesquisa_lista_l(a1);
v2 = v1;
if ( v1 )
printf("\tTitulo: %s\n\n", v1);
return v2;
}

original_code:
Livro valida_l(Livro livros)
{
    int livro_code;
    Livro aux_l;
    do {
    printf("\nIntroduza o codigo do livro: ");
    scanf("%d",&livro_code);
    printf("\n\n");
    } while (getchar()!='\n' || livro_code<1);
    if((aux_l=pesquisa_lista_l(livros,livro_code)))
        printf("\tTitulo: %s\n\n",aux_l->dados.nome);
    return aux_l;
}

canonical_original_code:
struct no_l *valida_l(struct no_l *livros)
{
    int livro_code;
    struct no_l *aux_l;
    do {
    printf("\nIntroduza o codigo do livro: ");
    scanf("%d",&livro_code);
    printf("\n\n");
    } while (getchar()!='\n' || livro_code<1);
    if((aux_l=pesquisa_lista_l(livros,livro_code)))
        printf("\tTitulo: %s\n\n",aux_l->dados.nome);
    return aux_l;
}

variable_types:
livros
struct no_l *

variable_types: struct no_l { struct Livro_str { char nome[100]; int cod_livro; } dados; struct no_l *prox; } *

user_defined_types: struct no_l { struct Livro_str dados; struct no_l *prox; }


decompiled_code:
__int64 __fastcall valida_r(__int64 a1)
{
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

do
{
do
{
printf("\nIntroduza o codigo do livro: ");
_isoc99_scanf("%d", v2);
puts("\n");
}
while ( getchar() != 10 );
}
while ( v2[0] <= 0 );
return pesquisa_lista_r(a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

do
{
do
{
printf("\nIntroduza o codigo do livro: ");
_isoc99_scanf("%d", v2);
puts("\n");
}
while ( getchar() != 10 );
}
while ( v2[0] <= 0 );
return pesquisa_lista_r(a1);
}

original_code:
Requisit valida_r(Requisit requisit)
{
    int livro_code;
    do {
    printf("\nIntroduza o codigo do livro: ");
    scanf("%d",&livro_code);
    printf("\n\n");
    } while (getchar()!='\n' || livro_code<1);
    return (pesquisa_lista_r(requisit,livro_code));
}

canonical_original_code:
struct no_r *valida_r(struct no_r *requisit)
{
    int livro_code;
    do {
    printf("\nIntroduza o codigo do livro: ");
    scanf("%d",&livro_code);
    printf("\n\n");
    } while (getchar()!='\n' || livro_code<1);
    return (pesquisa_lista_r(requisit,livro_code));
}

variable_types:
requisit
struct no_r *

return_type: struct no_r { struct Requisit_str { int cod_livro; int cod_utente; struct Data { int dia; int mes; int ano; } data_r; struct Ctrl_fila { struct node_fila { int cod_utente; struct node_fila *prox; } *primeiro; struct node_fila *ultimo; } reserva; } info; struct no_r *prox; } *

user_defined_types: struct no_r { struct Requisit_str info; struct no_r *prox; }

user_defined_types: struct Requisit_str { int cod_livro; int cod_utente; struct Data data_r; struct Ctrl_fila reserva; }

user_defined_types: struct Ctrl_fila { struct node_fila *primeiro; struct node_fila *ultimo; }


original_code:
int vagas_u(Requisit requisit, int utente_code)
{
    int conta=0;
    Requisit aux_r;
    f_espera aux_fila;
    aux_r = requisit->prox;
    while(aux_r)
    {
        if(aux_r->info.cod_utente==utente_code)
            conta++;
        aux_fila = aux_r->info.reserva.primeiro;
        while(aux_fila)
        {
            if(aux_fila->cod_utente==utente_code)
                conta++;
            aux_fila = aux_fila->prox;
        }
        aux_r=aux_r->prox;
    }
    if(conta<4)
        return 1;
    else return 0;
}

canonical_original_code:
int vagas_u(struct no_r *requisit, int utente_code)
{
    int conta = 0;
    struct no_r *aux_r;
    struct node_fila *aux_fila;
    aux_r = requisit->prox;
    while(aux_r)
    {
        if(aux_r->info.cod_utente==utente_code)
            conta++;
        aux_fila = aux_r->info.reserva.primeiro;
        while(aux_fila)
        {
            if(aux_fila->cod_utente==utente_code)
                conta++;
            aux_fila = aux_fila->prox;
        }
        aux_r=aux_r->prox;
    }
    if(conta<4)
        return 1;
    else return 0;
}

variable_types: struct no_r { struct Requisit_str { int cod_livro; int cod_utente; struct Data { int dia; int mes; int ano; } data_r; struct Ctrl_fila { struct node_fila { int cod_utente; struct node_fila *prox; } *primeiro; struct node_fila *ultimo; } reserva; } info; struct no_r *prox; } *

variable_types: conta int


clear

decompiled_code:
int clear()
{
return system("clear");
}

canonical_decompiled_code:
int func7()
{
return system("clear");
}

original_code:
void clear()
{
    system("clear");
}

canonical_original_code:
void clear()
{
    system("clear");
}


decompiled_code:
int __fastcall imprime_info_l(const char *a1, __int64 a2)
{
__int64 v2; // rbx
unsigned int *i; // rbx

if ( !a1 )
return puts("\n\tO livro com esse codigo nao existe.\n\n");
v2 = pesquisa_lista_r(a2);
if ( !v2 )
return printf("\tTitulo: %s\n\n\tO livro nao se encontra requisitado.\n\n\n", a1);
clear();
printf("\n\n\n\tInformacao sobre o livro com o titulo: ' %s '\n\n", a1);
puts("+--------------------------------------------------------------+");
puts("| Codigo do utente | Data de | Codigo dos utentes em espera |");
puts("| que o requisitou | Requisicao | com pedido de reserva |");
puts("+--------------------------------------------------------------+");
printf(
"%12d %02d/%02d/%-8d\n\n",
*(unsigned int *)(v2 + 4),
*(unsigned int *)(v2 + 8),
*(unsigned int *)(v2 + 12),
*(unsigned int *)(v2 + 16));
for ( i = *(unsigned int **)(v2 + 24); i; i = (unsigned int *)*((_QWORD *)i + 1) )
printf("%50d \n\n", *i);
return puts("+--------------------------------------------------------------+\n\n");
}

canonical_decompiled_code:
int __fastcall func8(const char *a1, __int64 a2)
{
__int64 v2; // rbx
unsigned int *i; // rbx

if ( !a1 )
return puts("\n\tO livro com esse codigo nao existe.\n\n");
v2 = pesquisa_lista_r(a2);
if ( !v2 )
return printf("\tTitulo: %s\n\n\tO livro nao se encontra requisitado.\n\n\n", a1);
func7();
printf("\n\n\n\tInformacao sobre o livro com o titulo: ' %s '\n\n", a1);
puts("+--------------------------------------------------------------+");
puts("| Codigo do utente | Data de | Codigo dos utentes em espera |");
puts("| que o requisitou | Requisicao | com pedido de reserva |");
puts("+--------------------------------------------------------------+");
printf(
"%12d %02d/%02d/%-8d\n\n",
*(unsigned int *)(v2 + 4),
*(unsigned int *)(v2 + 8),
*(unsigned int *)(v2 + 12),
*(unsigned int *)(v2 + 16));
for ( i = *(unsigned int **)(v2 + 24); i; i = (unsigned int *)*((_QWORD *)i + 1) )
printf("%50d \n\n", *i);
return puts("+--------------------------------------------------------------+\n\n");
}

original_code:
void imprime_info_l(Livro aux_l,Requisit requisit)
{
    Requisit aux_r;
    f_espera aux_fila;
    if(aux_l)
    {
        aux_r = pesquisa_lista_r(requisit,aux_l->dados.cod_livro);
        if(aux_r)
        {
            clear();
            printf("\n\n\n\tInformacao sobre o livro com o titulo: ' %s '\n\n",aux_l->dados.nome);
            printf("+--------------------------------------------------------------+\n");
            printf("| Codigo do utente |  Data de   | Codigo dos utentes em espera |\n");
            printf("| que o requisitou | Requisicao |   com pedido de reserva      |\n");
            printf("+--------------------------------------------------------------+\n");
            printf("%12d         %02d/%02d/%-8d\n\n",aux_r->info.cod_utente,aux_r->info.data_r.dia,aux_r->info.data_r.mes,aux_r->info.data_r.ano);
            aux_fila = aux_r->info.reserva.primeiro;
            while(aux_fila)
            {
                printf("%50d \n\n",aux_fila->cod_utente);
                aux_fila = aux_fila->prox;
            }
        printf("+--------------------------------------------------------------+\n\n\n");
        }
        else printf("\tTitulo: %s\n\n\tO livro nao se encontra requisitado.\n\n\n",aux_l->dados.nome);
    }
    else
        printf("\n\tO livro com esse codigo nao existe.\n\n\n");
}

canonical_original_code:
void imprime_info_l(struct no_l *aux_l, struct no_r *requisit)
{
    struct no_r *aux_r;
    struct node_fila *aux_fila;
    if(aux_l)
    {
        aux_r = pesquisa_lista_r(requisit,aux_l->dados.cod_livro);
        if(aux_r)
        {
            clear();
            printf("\n\n\n\tInformacao sobre o livro com o titulo: ' %s '\n\n",aux_l->dados.nome);
            printf("+--------------------------------------------------------------+\n");
            printf("| Codigo do utente |  Data de   | Codigo dos utentes em espera |\n");
            printf("| que o requisitou | Requisicao |   com pedido de reserva      |\n");
            printf("+--------------------------------------------------------------+\n");
            printf("%12d         %02d/%02d/%-8d\n\n",aux_r->info.cod_utente,aux_r->info.data_r.dia,aux_r->info.data_r.mes,aux_r->info.data_r.ano);
            aux_fila = aux_r->info.reserva.primeiro;
            while(aux_fila)
            {
                printf("%50d \n\n",aux_fila->cod_utente);
                aux_fila = aux_fila->prox;
            }
        printf("+--------------------------------------------------------------+\n\n\n");
        }
        else printf("\tTitulo: %s\n\n\tO livro nao se encontra requisitado.\n\n\n",aux_l->dados.nome);
    }
    else
        printf("\n\tO livro com esse codigo nao existe.\n\n\n");
}

variable_types: struct node_fila { int cod_utente; struct node_fila *prox; } *

user_defined_types: struct Livro_str { char nome[100]; int cod_livro; }


pause

decompiled_code:
int pause()
{
return system("read -p 'Prima qualquer tecla para continuar . . .'");
}

canonical_decompiled_code:
int func9()
{
return system("read -p 'Prima qualquer tecla para continuar . . .'");
}

original_code:
void pause()
{
    system("read -p 'Prima qualquer tecla para continuar . . .'");
}


original_code:
int historial_u(Requisit requisit,Livro livros,int utente_code,int opcao)
{
    Livro aux_l;
    Requisit aux_r;
    f_espera aux_fila;
    int existe=0,conta=0;
    aux_r = requisit->prox;
    if (opcao==1)
        printf("\n\n\tLista de livros requisitados pelo utente:\n\n");
    else if (opcao==2)
        printf("\n\n\tLista de livros reservados pelo utente:\n\n");
     else if (opcao==3)
        printf("\n\n\n\tLista de livros requisitados e reservados pelo utente:\n\n");
    printf("+--------------------------------------------------------------------------------------------+\n");
    printf("| Cod. Livro |                        Nome do Livro                          |      OBS      |\n");
    printf("+--------------------------------------------------------------------------------------------+\n");
    while(aux_r)
    {
        if (opcao==1 || opcao==3)
        {
            if(aux_r->info.cod_utente==utente_code)
            {
                aux_l = pesquisa_lista_l(livros,aux_r->info.cod_livro);
                printf("%9d       %-60s    requisitado\n\n",aux_r->info.cod_livro,aux_l->dados.nome);
                existe=1;
                conta++;
            }
        }
        if (opcao==2 || opcao==3)
        {
            aux_fila = aux_r->info.reserva.primeiro;
            while(aux_fila)
            {
                if(aux_fila->cod_utente==utente_code)
                {
                    aux_l = pesquisa_lista_l(livros,aux_r->info.cod_livro);
                    printf("%9d       %-60s    (reservado)\n\n",aux_l->dados.cod_livro,aux_l->dados.nome);
                    existe=1;
                    conta++;
                }
                aux_fila = aux_fila->prox;
            }
        }
        aux_r=aux_r->prox;
        if(conta==20)
        {
            conta=0;
            pause();
        }
    }
    printf("+--------------------------------------------------------------------------------------------+\n\n\n");
    return existe;
}

canonical_original_code:
int historial_u(struct no_r *requisit, struct no_l *livros, int utente_code, int opcao)
{
    struct no_l *aux_l;
    struct no_r *aux_r;
    struct node_fila *aux_fila;
    int existe = 0; int conta = 0;
    aux_r = requisit->prox;
    if (opcao==1)
        printf("\n\n\tLista de livros requisitados pelo utente:\n\n");
    else if (opcao==2)
        printf("\n\n\tLista de livros reservados pelo utente:\n\n");
     else if (opcao==3)
        printf("\n\n\n\tLista de livros requisitados e reservados pelo utente:\n\n");
    printf("+--------------------------------------------------------------------------------------------+\n");
    printf("| Cod. Livro |                        Nome do Livro                          |      OBS      |\n");
    printf("+--------------------------------------------------------------------------------------------+\n");
    while(aux_r)
    {
        if (opcao==1 || opcao==3)
        {
            if(aux_r->info.cod_utente==utente_code)
            {
                aux_l = pesquisa_lista_l(livros,aux_r->info.cod_livro);
                printf("%9d       %-60s    requisitado\n\n",aux_r->info.cod_livro,aux_l->dados.nome);
                existe=1;
                conta++;
            }
        }
        if (opcao==2 || opcao==3)
        {
            aux_fila = aux_r->info.reserva.primeiro;
            while(aux_fila)
            {
                if(aux_fila->cod_utente==utente_code)
                {
                    aux_l = pesquisa_lista_l(livros,aux_r->info.cod_livro);
                    printf("%9d       %-60s    (reservado)\n\n",aux_l->dados.cod_livro,aux_l->dados.nome);
                    existe=1;
                    conta++;
                }
                aux_fila = aux_fila->prox;
            }
        }
        aux_r=aux_r->prox;
        if(conta==20)
        {
            conta=0;
            pause();
        }
    }
    printf("+--------------------------------------------------------------------------------------------+\n\n\n");
    return existe;
}

variable_types: opcao int

variable_types: existe int

user_defined_types: struct node_fila { int cod_utente; struct node_fila *prox; }


boneco

decompiled_code:
int __fastcall boneco(int a1)
{
int result; // eax

if ( a1 == 1 )
result = system("cat entrada.txt");
else
result = system("cat saida.txt");
return result;
}

canonical_decompiled_code:
int __fastcall func11(int a1)
{
int result; // eax

if ( a1 == 1 )
result = system("cat entrada.txt");
else
result = system("cat saida.txt");
return result;
}

original_code:
void boneco(int tipo)
{
    if(tipo==1)
    {
        system("cat entrada.txt");
    }
    else
    {
        system("cat saida.txt");
    }
}

variable_types: tipo int


decompiled_code:
_DWORD *cria_lista_l()
{
_DWORD *result; // rax

result = malloc(0x70uLL);
if ( result )
{
result[25] = 0;
*(_WORD *)result = 48;
*((_QWORD *)result + 13) = 0LL;
}
return result;
}

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

result = malloc(0x70uLL);
if ( result )
{
result[25] = 0;
*(_WORD *)result = 48;
*((_QWORD *)result + 13) = 0LL;
}
return result;
}

original_code:
Livro cria_lista_l(void)
{
    Livro aux;
    aux = (Livro) malloc (sizeof (No_livros));
    if (aux != ((void *)0)) {
        strcpy(aux->dados.nome,"0");
        aux->dados.cod_livro = 0;
        aux->prox = ((void *)0);
    }
    return aux;
}

canonical_original_code:
struct no_l *cria_lista_l()
{
    struct no_l *aux;
    aux = (struct no_l *) malloc (sizeof (No_livros));
    if (aux != ((void *)0)) {
        strcpy(aux->dados.nome,"0");
        aux->dados.cod_livro = 0;
        aux->prox = ((void *)0);
    }
    return aux;
}

return_type: struct no_l { struct Livro_str { char nome[100]; int cod_livro; } dados; struct no_l *prox; } *


decompiled_code:
_BOOL8 __fastcall lista_vazia_l(__int64 a1)
{
return *(_QWORD *)(a1 + 104) == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
return *(_QWORD *)(a1 + 104) == 0LL;
}

original_code:
int lista_vazia_l(Livro lista)
{
    return (lista->prox == ((void *)0) ? 1 : 0);
}

canonical_original_code:
int lista_vazia_l(struct no_l *lista)
{
    return (lista->prox == ((void *)0) ? 1 : 0);
}