decompiled_code:
__int64 __fastcall find_closestsymbol(const char *a1, int a2)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // [rsp+0h] [rbp-28h] BYREF
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

if ( sc_status == 1 )
return 0LL;
result = 0LL;
if ( *a1 )
{
v3 = find_closestsymbol_table_isra_0(a1, loctab, a2, &v4);
if ( v3 <= (int)find_closestsymbol_table_isra_0(a1, glbtab, a2, v5) )
result = v4;
else
result = v5[0];
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, int a2)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // [rsp+0h] [rbp-28h] BYREF
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

if ( sc_status == 1 )
return 0LL;
result = 0LL;
if ( *a1 )
{
v3 = func6(a1, loctab, a2, &v4);
if ( v3 <= (int)func6(a1, glbtab, a2, v5) )
result = v4;
else
result = v5[0];
}
return result;
}

original_code:
symbol *find_closestsymbol(const char *name,int symboltype)
{
  symbol *symloc,*symglb;
  int distloc,distglb;
  if (sc_status==statFIRST)
    return ((void *)0);
  ((void) (0));
  if (strlen(name)==0)
    return ((void *)0);
  distloc=find_closestsymbol_table(name,&loctab,symboltype,&symloc);
  distglb=find_closestsymbol_table(name,&glbtab,symboltype,&symglb);
  return (distglb<distloc) ? symglb : symloc;
}

canonical_original_code:
struct s_symbol *find_closestsymbol(char *name, int symboltype)
{
  struct s_symbol *symloc; struct s_symbol *symglb;
  int distloc; int distglb;
  if (sc_status==statFIRST)
    return ((void *)0);
  ((void) (0));
  if (strlen(name)==0)
    return ((void *)0);
  distloc=find_closestsymbol_table(name,&loctab,symboltype,&symloc);
  distglb=find_closestsymbol_table(name,&glbtab,symboltype,&symglb);
  return (distglb<distloc) ? symglb : symloc;
}

variable_types: symboltype int

variable_types: struct s_symbol { struct s_symbol *next; struct s_symbol *parent; char name[-1]; unsigned int hash; long addr; long codeaddr; int index; char vclass; char ident; short usage; char flags; int compound; int tag; union { int declared; struct s_constvalue { struct s_constvalue *next; char name[-1]; long value; int index; char usage; } *lib; long stacksize; int enumlist; } x; union { struct s_arginfo { char name[-1]; char ident; char usage; int *tags; int numtags; int dim[3]; struct s_constvalue *dimnames[3]; int numdim; unsigned char hasdefault; union { long val; struct { char *symname; short level; } size; struct { long *data; int size; int arraysize; long addr; } array; } defvalue; int defvalue_tag; } *arglist; struct { long length; short level; struct s_constvalue *names; } array; } dim; struct s_statelist { struct s_statelist *next; int label; long addr; long endaddr; int id; } *states; int fvisible; int fnumber; int lnumber; struct s_symbol **refer; int numrefers; char *documentation; } *

variable_types: distloc int

variable_types: distglb int

user_defined_types: struct s_symbol { struct s_symbol *next; struct s_symbol *parent; char name[-1]; unsigned int hash; long addr; long codeaddr; int index; char vclass; char ident; short usage; char flags; int compound; int tag; union { int declared; struct s_constvalue *lib; long stacksize; int enumlist; } x; union { struct s_arginfo *arglist; struct { long length; short level; struct s_constvalue *names; } array; } dim; struct s_statelist *states; int fvisible; int fnumber; int lnumber; struct s_symbol **refer; int numrefers; char *documentation; }


repo: lukesalisbury/meg

decompiled_code:
__int64 __fastcall error_suggest(int a1, const char *a2, int a3)
{
__int64 v3; // rax
__int64 v4; // r12
__int64 result; // rax

v3 = find_closestsymbol(a2, a3);
if ( v3 && (v4 = v3 + 16, strcmp(a2, (const char *)(v3 + 16))) )
{
error_localalias(a1 | 0x100000000LL, a2, v4);
result = 0LL;
}
else
{
error_localalias(a1, a2);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, const char *a2, int a3)
{
__int64 v3; // rax
__int64 v4; // r12
__int64 result; // rax

v3 = func7(a2, a3);
if ( v3 && (v4 = v3 + 16, strcmp(a2, (const char *)(v3 + 16))) )
{
func1(a1 | 0x100000000LL, a2, v4);
result = 0LL;
}
else
{
func1(a1, a2);
result = 0LL;
}
return result;
}

original_code:
int error_suggest(int number,const char *name,int ident)
{
  symbol *closestsym=find_closestsymbol(name,ident);
  if (closestsym!=((void *)0) && strcmp(name,closestsym->name)!=0)
    error(((long)(number) | ((long)(1) << (sizeof(long)*4))),name,closestsym->name);
  else
    error(number,name);
  return 0;
}

canonical_original_code:
int error_suggest(int number, char *name, int ident)
{
  struct s_symbol *closestsym = find_closestsymbol(name,ident);
  if (closestsym!=((void *)0) && strcmp(name,closestsym->name)!=0)
    error(((long)(number) | ((long)(1) << (sizeof(long)*4))),name,closestsym->name);
  else
    error(number,name);
  return 0;
}

variable_types: number int

variable_types:
name
char *

variable_types: ident int

return_type: int

user_defined_types: struct s_statelist { struct s_statelist *next; int label; long addr; long endaddr; int id; }

user_defined_types: struct s_constvalue { struct s_constvalue *next; char name[-1]; long value; int index; char usage; }

user_defined_types: struct s_arginfo { char name[-1]; char ident; char usage; int *tags; int numtags; int dim[3]; struct s_constvalue *dimnames[3]; int numdim; unsigned char hasdefault; union { long val; struct { char *symname; short level; } size; struct { long *data; int size; int arraysize; long addr; } array; } defvalue; int defvalue_tag; }


decompiled_code:
void __fastcall delete_stringpairtable(__int64 a1)
{
void **v1; // rbx
void **v2; // rbp

v1 = *(void ***)a1;
if ( *(_QWORD *)a1 )
{
do
{
v2 = v1;
v1 = (void **)*v1;
free(v2[1]);
free(v2[2]);
free(v2);
}
while ( v1 );
}
*(_OWORD *)a1 = 0LL;
*(_OWORD *)(a1 + 16) = 0LL;
}

original_code:
static void delete_stringpairtable(stringpair *root)
{
  stringpair *cur, *next;
  ((void) (0));
  cur=root->next;
  while (cur!=((void *)0)) {
    next=cur->next;
    ((void) (0));
    ((void) (0));
    free(cur->first);
    free(cur->second);
    free(cur);
    cur=next;
  }
  memset(root,0,sizeof(stringpair));
}

canonical_original_code:
static void delete_stringpairtable(struct s_stringpair *root)
{
  struct s_stringpair *cur; struct s_stringpair *next;
  ((void) (0));
  cur=root->next;
  while (cur!=((void *)0)) {
    next=cur->next;
    ((void) (0));
    ((void) (0));
    free(cur->first);
    free(cur->second);
    free(cur);
    cur=next;
  }
  memset(root,0,sizeof(stringpair));
}

variable_types: struct s_stringpair { struct s_stringpair *next; char *first; char *second; int matchlength; } *

return_type: void


duplicatestring

decompiled_code:
void *__fastcall duplicatestring(void *src)
{
size_t v1; // r12
void *v2; // rax

v1 = strlen((const char *)src) + 1;
v2 = malloc(v1);
return memcpy(v2, src, v1);
}

canonical_decompiled_code:
void *__fastcall func4(void *src)
{
size_t v1; // r12
void *v2; // rax

v1 = strlen((const char *)src) + 1;
v2 = malloc(v1);
return memcpy(v2, src, v1);
}

original_code:
char* duplicatestring(const char* sourcestring)
{
  char* result=(char*)malloc(strlen(sourcestring)+1);
  strcpy(result,sourcestring);
  return result;
}

canonical_original_code:
char *duplicatestring(char *sourcestring)
{
  char *result = (char*)malloc(strlen(sourcestring)+1);
  strcpy(result,sourcestring);
  return result;
}

variable_types:
sourcestring
char *

variable_types:
result
char *

return_type: char *


decompiled_code:
void __fastcall delete_stringtable(void ***a1)
{
void **v1; // rbx
void **v2; // rbp

v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = (void **)*v1;
free(v2[1]);
free(v2);
}
*(_OWORD *)a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func5(void ***a1)
{
void **v1; // rbx
void **v2; // rbp

v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = (void **)*v1;
free(v2[1]);
free(v2);
}
*(_OWORD *)a1 = 0LL;
}

original_code:
void delete_stringtable(stringlist *root)
{
  stringlist *cur,*next;
  ((void) (0));
  cur=root->next;
  while (cur!=((void *)0)) {
    next=cur->next;
    ((void) (0));
    free(cur->line);
    free(cur);
    cur=next;
  }
  memset(root,0,sizeof(stringlist));
}

canonical_original_code:
void delete_stringtable(struct s_stringlist *root)
{
  struct s_stringlist *cur; struct s_stringlist *next;
  ((void) (0));
  cur=root->next;
  while (cur!=((void *)0)) {
    next=cur->next;
    ((void) (0));
    free(cur->line);
    free(cur);
    cur=next;
  }
  memset(root,0,sizeof(stringlist));
}

variable_types: struct s_stringlist { struct s_stringlist *next; char *line; } *


decompiled_code:
_BOOL8 __fastcall lookup_alias(char *dest, char *s)
{
int v2; // eax
__int64 *v3; // rax
__int64 *v4; // rbx

v2 = strlen(s);
v3 = find_stringpair((__int64 *)alias_tab, s, v2);
v4 = v3;
if ( v3 )
strcpy(dest, (const char *)v3[2]);
return v4 != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(char *dest, char *s)
{
int v2; // eax
__int64 *v3; // rax
__int64 *v4; // rbx

v2 = strlen(s);
v3 = find_stringpair((__int64 *)alias_tab, s, v2);
v4 = v3;
if ( v3 )
strcpy(dest, (const char *)v3[2]);
return v4 != 0LL;
}

original_code:
int lookup_alias(char *target,char *name)
{
  stringpair *cur=find_stringpair(alias_tab.next,name,(int)strlen(name));
  if (cur!=((void *)0)) {
    ((void) (0));
    strcpy(target,cur->second);
  }
  return cur!=((void *)0);
}

canonical_original_code:
int lookup_alias(char *target, char *name)
{
  struct s_stringpair *cur = find_stringpair(alias_tab.next,name,(int)strlen(name));
  if (cur!=((void *)0)) {
    ((void) (0));
    strcpy(target,cur->second);
  }
  return cur!=((void *)0);
}

variable_types:
target
char *

user_defined_types: struct s_stringpair { struct s_stringpair *next; char *first; char *second; int matchlength; }


decompiled_code:
void delete_aliastable()
{
delete_stringpairtable((__int64)&alias_tab);
}

canonical_decompiled_code:
void func7()
{
func1((__int64)&alias_tab);
}

original_code:
void delete_aliastable(void)
{
  delete_stringpairtable(&alias_tab);
}

canonical_original_code:
void delete_aliastable()
{
  delete_stringpairtable(&alias_tab);
}


decompiled_code:
void delete_pathtable()
{
delete_stringtable((void ***)&includepaths);
}

canonical_decompiled_code:
void func9()
{
func5((void ***)&includepaths);
}

original_code:
void delete_pathtable(void)
{
  delete_stringtable(&includepaths);
  ((void) (0));
}

canonical_original_code:
void delete_pathtable()
{
  delete_stringtable(&includepaths);
  ((void) (0));
}


decompiled_code:
__int64 __fastcall delete_subst(const char *a1, int a2)
{
unsigned int v2; // er12
__int64 *v4; // rdi
__int64 *v5; // rdi

v2 = 0;
v4 = (__int64 *)substindex[*a1 - 64];
if ( v4 )
{
v5 = find_stringpair(v4, a1, a2);
if ( v5 )
{
delete_stringpair_constprop_0_isra_0(v5);
v2 = 1;
adjustindex(*a1);
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func10(const char *a1, int a2)
{
unsigned int v2; // er12
__int64 *v4; // rdi
__int64 *v5; // rdi

v2 = 0;
v4 = (__int64 *)substindex[*a1 - 64];
if ( v4 )
{
v5 = find_stringpair(v4, a1, a2);
if ( v5 )
{
func2(v5);
v2 = 1;
func0(*a1);
}
}
return v2;
}

original_code:
int delete_subst(char *name,int length)
{
  stringpair *item;
  ((void) (0));
  ((void) (0));
  ((void) (0));
  item=substindex[(int)*name-'@'];
  if (item!=((void *)0))
    item=find_stringpair(item,name,length);
  if (item==((void *)0))
    return 0;
  delete_stringpair(&substpair,item);
  adjustindex(*name);
  return 1;
}

canonical_original_code:
int delete_subst(char *name, int length)
{
  struct s_stringpair *item;
  ((void) (0));
  ((void) (0));
  ((void) (0));
  item=substindex[(int)*name-'@'];
  if (item!=((void *)0))
    item=find_stringpair(item,name,length);
  if (item==((void *)0))
    return 0;
  delete_stringpair(&substpair,item);
  adjustindex(*name);
  return 1;
}

variable_types: length int


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

delete_stringpairtable((__int64)&substpair);
result = 0LL;
memset(substindex, 0, 0x1D8uLL);
return result;
}

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

func1((__int64)&substpair);
result = 0LL;
memset(substindex, 0, 0x1D8uLL);
return result;
}

original_code:
void delete_substtable(void)
{
  int i;
  delete_stringpairtable(&substpair);
  for (i=0; i<sizeof substindex/sizeof substindex[0]; i++)
    substindex[i]=((void *)0);
}

canonical_original_code:
void delete_substtable()
{
  int i;
  delete_stringpairtable(&substpair);
  for (i=0; i<sizeof substindex/sizeof substindex[0]; i++)
    substindex[i]=((void *)0);
}

variable_types: i int


decompiled_code:
void delete_sourcefiletable()
{
delete_stringtable((void ***)&sourcefiles);
}

canonical_decompiled_code:
void func13()
{
func5((void ***)&sourcefiles);
}

original_code:
void delete_sourcefiletable(void)
{
  delete_stringtable(&sourcefiles);
  ((void) (0));
}

canonical_original_code:
void delete_sourcefiletable()
{
  delete_stringtable(&sourcefiles);
  ((void) (0));
}


decompiled_code:
void delete_inputfiletable()
{
delete_stringtable((void ***)&inputfiles);
}

canonical_decompiled_code:
void func15()
{
func5((void ***)&inputfiles);
}

original_code:
void delete_inputfiletable(void)
{
  delete_stringtable(&inputfiles);
  ((void) (0));
}

canonical_original_code:
void delete_inputfiletable()
{
  delete_stringtable(&inputfiles);
  ((void) (0));
}


decompiled_code:
void delete_autolisttable()
{
delete_stringtable((void ***)&autolist);
}

canonical_decompiled_code:
void func17()
{
func5((void ***)&autolist);
}

original_code:
void delete_autolisttable(void)
{
  delete_stringtable(&autolist);
  ((void) (0));
}

canonical_original_code:
void delete_autolisttable()
{
  delete_stringtable(&autolist);
  ((void) (0));
}


decompiled_code:
__int64 __fastcall popfront_heaplist(_QWORD *a1, _QWORD *a2)
{
void **v3; // rdi

v3 = (void **)heaplist;
if ( !heaplist )
return 0LL;
*a1 = *((_QWORD *)heaplist + 1);
*a2 = v3[2];
heaplist = *v3;
free(v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func18(_QWORD *a1, _QWORD *a2)
{
void **v3; // rdi

v3 = (void **)heaplist;
if ( !heaplist )
return 0LL;
*a1 = *((_QWORD *)heaplist + 1);
*a2 = v3[2];
heaplist = *v3;
free(v3);
return 1LL;
}

original_code:
int popfront_heaplist(long *first, long *second)
{
  valuepair *front=heaplist.next;
  if (front==((void *)0))
    return 0;
  *first=front->first;
  *second=front->second;
  heaplist.next=front->next;
  free(front);
  return 1;
}

canonical_original_code:
int popfront_heaplist(long *first, long *second)
{
  struct s_valuepair *front = heaplist.next;
  if (front==((void *)0))
    return 0;
  *first=front->first;
  *second=front->second;
  heaplist.next=front->next;
  free(front);
  return 1;
}

variable_types:
first
long *

variable_types:
second
long *

variable_types: struct s_valuepair { struct s_valuepair *next; long first; long second; } *


decompiled_code:
void delete_heaplisttable()
{
void **i; // rdi

for ( i = (void **)heaplist; heaplist; i = (void **)heaplist )
{
heaplist = *i;
free(i);
}
}

canonical_decompiled_code:
void func19()
{
void **i; // rdi

for ( i = (void **)heaplist; heaplist; i = (void **)heaplist )
{
heaplist = *i;
free(i);
}
}

original_code:
void delete_heaplisttable(void)
{
  valuepair *cur;
  while (heaplist.next!=((void *)0)) {
    cur=heaplist.next;
    heaplist.next=cur->next;
    free(cur);
  }
}

canonical_original_code:
void delete_heaplisttable()
{
  struct s_valuepair *cur;
  while (heaplist.next!=((void *)0)) {
    cur=heaplist.next;
    heaplist.next=cur->next;
    free(cur);
  }
}

user_defined_types: struct s_valuepair { struct s_valuepair *next; long first; long second; }


decompiled_code:
void delete_dbgstringtable()
{
delete_stringtable((void ***)&dbgstrings);
}

canonical_decompiled_code:
void func21()
{
func5((void ***)&dbgstrings);
}

original_code:
void delete_dbgstringtable(void)
{
  delete_stringtable(&dbgstrings);
  ((void) (0));
}

canonical_original_code:
void delete_dbgstringtable()
{
  delete_stringtable(&dbgstrings);
  ((void) (0));
}


strlcpy

decompiled_code:
__int64 __fastcall strlcpy(_BYTE *a1, char *a2, __int64 a3)
{
char *v5; // rax
unsigned __int64 v6; // rdx
char v7; // cl

v5 = a2;
if ( !a3 )
{
do
{
LABEL_9:
if ( !*v5++ )
break;
++v5;
}
while ( *(v5 - 1) );
return v5 - a2 - 1;
}
if ( a3 == 1 )
{
LABEL_8:
*a1 = 0;
goto LABEL_9;
}
v6 = (unsigned __int64)a1;
while ( 1 )
{
v7 = *v5++;
*(_BYTE *)v6++ = v7;
if ( !v7 )
return v5 - a2 - 1;
if ( !&a1[a3 + ~v6] )
{
a1 = (_BYTE *)v6;
goto LABEL_8;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, char *a2, __int64 a3)
{
char *v5; // rax
unsigned __int64 v6; // rdx
char v7; // cl

v5 = a2;
if ( !a3 )
{
do
{
LABEL_9:
if ( !*v5++ )
break;
++v5;
}
while ( *(v5 - 1) );
return v5 - a2 - 1;
}
if ( a3 == 1 )
{
LABEL_8:
*a1 = 0;
goto LABEL_9;
}
v6 = (unsigned __int64)a1;
while ( 1 )
{
v7 = *v5++;
*(_BYTE *)v6++ = v7;
if ( !v7 )
return v5 - a2 - 1;
if ( !&a1[a3 + ~v6] )
{
a1 = (_BYTE *)v6;
goto LABEL_8;
}
}
}

original_code:
size_t
strlcpy(char *dst, const char *src, size_t siz)
{
 char *d = dst;
 const char *s = src;
 size_t n = siz;
 if (n != 0 && --n != 0) {
  do {
   if ((*d++ = *s++) == 0)
    break;
  } while (--n != 0);
 }
 if (n == 0) {
  if (siz != 0)
   *d = '\0';
  while (*s++)
   ;
 }
 return(s - src - 1);
}

canonical_original_code:
unsigned long strlcpy(char *dst, char *src, unsigned long siz)
{
 char *d = dst;
 char *s = src;
 unsigned long n = siz;
 if (n != 0 && --n != 0) {
  do {
   if ((*d++ = *s++) == 0)
    break;
  } while (--n != 0);
 }
 if (n == 0) {
  if (siz != 0)
   *d = '\0';
  while (*s++)
   ;
 }
 return(s - src - 1);
}

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
siz
unsigned long

variable_types:
d
char *

variable_types:
s
char *

variable_types:
n
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall handling_error_code(unsigned int a1, __int64 a2, const char *a3, int a4, unsigned int a5, __int64 a6)
{
const char *v6; // r12
const char *v9; // rbp
__int64 v10; // rdx
char *v11; // rsi
__int64 v13; // r12
__int64 v14; // rdx
__int64 v15; // [rsp-40h] [rbp-40h]

if ( !ignore_errors )
{
v6 = a3;
if ( !a3 )
return 0LL;
v9 = (const char *)g_strdup_vprintf(a2, a6);
if ( a1 - 1 > 0xC6 )
{
v11 = (char *)v6;
if ( strcmp(source_filepath, v6) )
goto LABEL_6;
v11 = (char *)use_original_filename;
if ( !use_original_filename )
goto LABEL_6;
}
else
{
++fatal_error_count;
if ( strcmp(source_filepath, v6) )
goto LABEL_9;
v11 = (char *)use_original_filename;
if ( !use_original_filename )
{
LABEL_6:
if ( a1 - 1 > 0x12A )
{
LABEL_7:
g_free(v9, v11, v10);
return 0LL;
}
LABEL_9:
v11 = prefix_0[(int)a1 / 100];
if ( xml_output )
{
if ( a4 < 0 )
{
v13 = g_markup_printf_escaped(
"<%s file=\"%s\" line=\"%d\" code=\"%d\" message=\"%s\"/>\n",
v11,
v6,
a5,
a1,
v9);
}
else
{
v13 = g_markup_printf_escaped(
"<%s file=\"%s\" line=\"%d\" lastline=\"%d\" code=\"%d\" message=\"%s\"/>\n",
v11,
v6,
(unsigned int)a4,
a5,
a1,
v9);
v14 = v15;
}
if ( v13 )
{
v11 = (char *)v13;
xml_content = g_string_append(xml_content, v13, v14);
}
g_free(v13, v11, v14);
}
else
{
if ( a4 < 0 )
g_print("%s(%d) : %s %03d: ", v6, a5, prefix_0[(int)a1 / 100], a1);
else
g_print("%s(%d -- %d) : %s %03d: ", v6, (unsigned int)a4, a5, prefix_0[(int)a1 / 100], a1);
v11 = (char *)v9;
g_print("%s", v9);
}
goto LABEL_7;
}
}
v6 = (const char *)source_filename;
goto LABEL_6;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 a2, const char *a3, int a4, unsigned int a5, __int64 a6)
{
const char *v6; // r12
const char *v9; // rbp
__int64 v10; // rdx
char *v11; // rsi
__int64 v13; // r12
__int64 v14; // rdx
__int64 v15; // [rsp-40h] [rbp-40h]

if ( !ignore_errors )
{
v6 = a3;
if ( !a3 )
return 0LL;
v9 = (const char *)g_strdup_vprintf(a2, a6);
if ( a1 - 1 > 0xC6 )
{
v11 = (char *)v6;
if ( strcmp(source_filepath, v6) )
goto LABEL_6;
v11 = (char *)use_original_filename;
if ( !use_original_filename )
goto LABEL_6;
}
else
{
++fatal_error_count;
if ( strcmp(source_filepath, v6) )
goto LABEL_9;
v11 = (char *)use_original_filename;
if ( !use_original_filename )
{
LABEL_6:
if ( a1 - 1 > 0x12A )
{
LABEL_7:
g_free(v9, v11, v10);
return 0LL;
}
LABEL_9:
v11 = prefix_0[(int)a1 / 100];
if ( xml_output )
{
if ( a4 < 0 )
{
v13 = g_markup_printf_escaped(
"<%s file=\"%s\" line=\"%d\" code=\"%d\" message=\"%s\"/>\n",
v11,
v6,
a5,
a1,
v9);
}
else
{
v13 = g_markup_printf_escaped(
"<%s file=\"%s\" line=\"%d\" lastline=\"%d\" code=\"%d\" message=\"%s\"/>\n",
v11,
v6,
(unsigned int)a4,
a5,
a1,
v9);
v14 = v15;
}
if ( v13 )
{
v11 = (char *)v13;
xml_content = g_string_append(xml_content, v13, v14);
}
g_free(v13, v11, v14);
}
else
{
if ( a4 < 0 )
g_print("%s(%d) : %s %03d: ", v6, a5, prefix_0[(int)a1 / 100], a1);
else
g_print("%s(%d -- %d) : %s %03d: ", v6, (unsigned int)a4, a5, prefix_0[(int)a1 / 100], a1);
v11 = (char *)v9;
g_print("%s", v9);
}
goto LABEL_7;
}
}
v6 = (const char *)source_filename;
goto LABEL_6;
}
return 0LL;
}

original_code:
int handling_error_code( int number, char * message, char *filename, int firstline, int lastline, va_list argptr )
{
 if ( ignore_errors )
 {
  return 0;
 }
 if ( !filename )
 {
  return 0;
 }
 static char * prefix[4] = { "error", "fatalerror", "warning", "" };
 char * vmsg = g_strdup_vprintf(message,argptr);
 char * source_file = filename;
 if ( number > 0 && number < 200 )
 {
  fatal_error_count++;
 }
 if ( strcmp( source_filepath, filename ) == 0 )
 {
  if ( use_original_filename )
   source_file = source_filename;
 }
 if ( number > 0 && number < 300 )
 {
  char * pre = prefix[number/100];
  if ( xml_output )
  {
   char * output = ((void *)0);
   if ( firstline >= 0 )
   {
    output = g_markup_printf_escaped(
       "<%s file=\"%s\" line=\"%d\" lastline=\"%d\" code=\"%d\" message=\"%s\"/>\n",
       pre, source_file, firstline, lastline, number, vmsg
       );
   }
   else
   {
    output = g_markup_printf_escaped(
       "<%s file=\"%s\" line=\"%d\" code=\"%d\" message=\"%s\"/>\n",
       pre, source_file, lastline, number, vmsg
       );
   }
   if ( output )
   {
    xml_content = g_string_append(xml_content, output);
   }
   g_free(output);
  }
  else
  {
   if ( firstline>=0)
    g_print("%s(%d -- %d) : %s %03d: ",source_file,firstline,lastline,pre,number);
   else
    g_print("%s(%d) : %s %03d: ",source_file,lastline,pre,number);
   g_print("%s", vmsg);
  }
 }
 g_free(vmsg);
 return 0;
}

canonical_original_code:
int handling_error_code(int number, char *message, char *filename, int firstline, int lastline, __builtin_va_list argptr)
{
 if ( ignore_errors )
 {
  return 0;
 }
 if ( !filename )
 {
  return 0;
 }
 static char *prefix[4] = { "error", "fatalerror", "warning", "" };
 char *vmsg = g_strdup_vprintf(message,argptr);
 char *source_file = filename;
 if ( number > 0 && number < 200 )
 {
  fatal_error_count++;
 }
 if ( strcmp( source_filepath, filename ) == 0 )
 {
  if ( use_original_filename )
   source_file = source_filename;
 }
 if ( number > 0 && number < 300 )
 {
  char *pre = prefix[number/100];
  if ( xml_output )
  {
   char *output = ((void *)0);
   if ( firstline >= 0 )
   {
    output = g_markup_printf_escaped(
       "<%s file=\"%s\" line=\"%d\" lastline=\"%d\" code=\"%d\" message=\"%s\"/>\n",
       pre, source_file, firstline, lastline, number, vmsg
       );
   }
   else
   {
    output = g_markup_printf_escaped(
       "<%s file=\"%s\" line=\"%d\" code=\"%d\" message=\"%s\"/>\n",
       pre, source_file, lastline, number, vmsg
       );
   }
   if ( output )
   {
    xml_content = g_string_append(xml_content, output);
   }
   g_free(output);
  }
  else
  {
   if ( firstline>=0)
    g_print("%s(%d -- %d) : %s %03d: ",source_file,firstline,lastline,pre,number);
   else
    g_print("%s(%d) : %s %03d: ",source_file,lastline,pre,number);
   g_print("%s", vmsg);
  }
 }
 g_free(vmsg);
 return 0;
}

variable_types: number int

variable_types:
message
char *

variable_types:
filename
char *

variable_types: firstline int

variable_types: lastline int

variable_types:
prefix
char *[4]

variable_types:
vmsg
char *

variable_types:
pre
char *

variable_types:
output
char *


decompiled_code:
__int64 __fastcall fix_path(_BYTE *a1)
{
__int64 result; // rax

while ( 1 )
{
result = (unsigned __int8)*a1;
if ( !(_BYTE)result )
break;
if ( (_BYTE)result == 47 )
*a1 = 47;
++a1;
}
return result;
}

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

while ( 1 )
{
result = (unsigned __int8)*a1;
if ( !(_BYTE)result )
break;
if ( (_BYTE)result == 47 )
*a1 = 47;
++a1;
}
return result;
}

original_code:
void fix_path( gchar * str )
{
 gsize c = 0;
 while ( str[c] )
 {
  if ( str[c] == '/' )
   str[c] = '/';
  c++;
 }
}

canonical_original_code:
void fix_path(char *str)
{
 unsigned long c = 0;
 while ( str[c] )
 {
  if ( str[c] == '/' )
   str[c] = '/';
  c++;
 }
}

variable_types:
str
char *

variable_types:
c
unsigned long


decompiled_code:
__int64 get_global_include_path()
{
_QWORD *v0; // rax
__int64 v1; // rdi
_QWORD *v2; // r13
_QWORD *v3; // rbp
__int64 v4; // rbx
__int64 *v5; // r12
__int64 v6; // rbp
__int64 v7; // rdx
__int64 v8; // r15
__int64 v9; // rdx
__int64 v11; // rbp
int v12; // eax
__int64 v13; // rdx

v0 = (_QWORD *)g_get_system_data_dirs();
v1 = *v0;
if ( !*v0 )
{
LABEL_13:
v8 = 0LL;
v11 = g_build_path("/", program_directory, "..", "share", "mokoi-1.0");
v12 = g_file_test(v11, 4LL);
v13 = 0LL;
if ( v12 )
v8 = g_strdup(v11);
g_free(v11, 4LL, v13);
return v8;
}
v2 = v0;
v3 = v0;
LODWORD(v4) = 0;
while ( 1 )
{
v4 = (unsigned int)(v4 + 1);
v5 = &v2[v4];
if ( !(unsigned int)g_str_has_suffix(v1, "share") && !(unsigned int)g_str_has_suffix(*v3, "share/") )
goto LABEL_4;
v6 = g_build_path("/", *v3, "mokoi-1.0", "include", 0LL);
if ( !(unsigned int)g_file_test(v6, 4LL) )
{
g_free(v6, 4LL, v7);
LABEL_4:
v1 = *v5;
if ( !*v5 )
goto LABEL_13;
goto LABEL_5;
}
v8 = g_strdup(v6);
g_free(v6, 4LL, v9);
v1 = *v5;
if ( !*v5 )
break;
if ( v8 )
return v8;
LABEL_5:
v3 = &v2[v4];
}
if ( !v8 )
goto LABEL_13;
return v8;
}

canonical_decompiled_code:
__int64 func2()
{
_QWORD *v0; // rax
__int64 v1; // rdi
_QWORD *v2; // r13
_QWORD *v3; // rbp
__int64 v4; // rbx
__int64 *v5; // r12
__int64 v6; // rbp
__int64 v7; // rdx
__int64 v8; // r15
__int64 v9; // rdx
__int64 v11; // rbp
int v12; // eax
__int64 v13; // rdx

v0 = (_QWORD *)g_get_system_data_dirs();
v1 = *v0;
if ( !*v0 )
{
LABEL_13:
v8 = 0LL;
v11 = g_build_path("/", program_directory, "..", "share", "mokoi-1.0");
v12 = g_file_test(v11, 4LL);
v13 = 0LL;
if ( v12 )
v8 = g_strdup(v11);
g_free(v11, 4LL, v13);
return v8;
}
v2 = v0;
v3 = v0;
LODWORD(v4) = 0;
while ( 1 )
{
v4 = (unsigned int)(v4 + 1);
v5 = &v2[v4];
if ( !(unsigned int)g_str_has_suffix(v1, "share") && !(unsigned int)g_str_has_suffix(*v3, "share/") )
goto LABEL_4;
v6 = g_build_path("/", *v3, "mokoi-1.0", "include", 0LL);
if ( !(unsigned int)g_file_test(v6, 4LL) )
{
g_free(v6, 4LL, v7);
LABEL_4:
v1 = *v5;
if ( !*v5 )
goto LABEL_13;
goto LABEL_5;
}
v8 = g_strdup(v6);
g_free(v6, 4LL, v9);
v1 = *v5;
if ( !*v5 )
break;
if ( v8 )
return v8;
LABEL_5:
v3 = &v2[v4];
}
if ( !v8 )
goto LABEL_13;
return v8;
}

original_code:
gchar * get_global_include_path( )
{
 gchar * directory = ((void *)0);
 guint lc = 0;
 const gchar * const * data_dirs;
 data_dirs = g_get_system_data_dirs();
 while ( data_dirs[lc] != ((void *)0) && directory == ((void *)0) )
 {
  if ( g_str_has_suffix(data_dirs[lc], "share") || g_str_has_suffix(data_dirs[lc], "share/") )
  {
   gchar * include_path = g_build_path("/", data_dirs[lc], "mokoi-1.0", "include", ((void *)0) );
   if ( g_file_test(include_path, G_FILE_TEST_IS_DIR ))
   {
    directory = g_strdup( include_path );
   }
   g_free(include_path);
  }
  lc++;
 }
 if ( !directory )
 {
  gchar * include_path = g_build_path("/", program_directory, "..", "share", "mokoi-1.0", "include", ((void *)0) );
  if ( g_file_test(include_path, G_FILE_TEST_IS_DIR ))
  {
   directory = g_strdup( include_path );
  }
  g_free(include_path);
 }
 return directory;
}

canonical_original_code:
char *get_global_include_path()
{
 char *directory = ((void *)0);
 unsigned int lc = 0;
 char **data_dirs;
 data_dirs = g_get_system_data_dirs();
 while ( data_dirs[lc] != ((void *)0) && directory == ((void *)0) )
 {
  if ( g_str_has_suffix(data_dirs[lc], "share") || g_str_has_suffix(data_dirs[lc], "share/") )
  {
   char *include_path = g_build_path("/", data_dirs[lc], "mokoi-1.0", "include", ((void *)0) );
   if ( g_file_test(include_path, G_FILE_TEST_IS_DIR ))
   {
    directory = g_strdup( include_path );
   }
   g_free(include_path);
  }
  lc++;
 }
 if ( !directory )
 {
  char *include_path = g_build_path("/", program_directory, "..", "share", "mokoi-1.0", "include", ((void *)0) );
  if ( g_file_test(include_path, G_FILE_TEST_IS_DIR ))
  {
   directory = g_strdup( include_path );
  }
  g_free(include_path);
 }
 return directory;
}

variable_types:
directory
char *

variable_types:
lc
unsigned int


decompiled_code:
void __fastcall main_args(int a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // r8
_BYTE *v5; // rdi

if ( a1 > 1 )
{
v2 = a2 + 8LL * a1;
v3 = v2 - 8 - 8LL * (unsigned int)(a1 - 2);
while ( 1 )
{
v5 = *(_BYTE **)(v2 - 8);
if ( *v5 != 45 )
break;
if ( (unsigned int)g_strcmp0("--xmloutput", *(_QWORD *)(v2 - 8)) )
{
if ( (unsigned int)g_str_has_prefix(*(_QWORD *)(v2 - 8), "--temporary=") )
{
temporary_filepath = g_strdup(*(_QWORD *)(v2 - 8) + 12LL);
}
else if ( (unsigned int)g_str_has_prefix(*(_QWORD *)(v2 - 8), "--project=") )
{
project_directory = g_strdup(*(_QWORD *)(v2 - 8) + 10LL);
}
else if ( (unsigned int)g_str_has_prefix(*(_QWORD *)(v2 - 8), "--parent=") )
{
parent_directory = g_strdup(*(_QWORD *)(v2 - 8) + 9LL);
}
LABEL_6:
v2 -= 8LL;
if ( v2 == v3 )
return;
}
else
{
v2 -= 8LL;
xml_output = 1;
if ( v2 == v3 )
return;
}
}
source_filepath = (_BYTE *)g_strdup(v5);
fix_path(source_filepath);
source_directory = g_path_get_dirname(source_filepath);
source_filename = g_path_get_basename(source_filepath);
if ( parent_directory )
{
routines_directory = g_build_path("/", parent_directory, source_directory, "routines", 0LL);
if ( (unsigned int)g_str_has_suffix(source_directory, "/maps") )
routines_global_directory = g_build_path("/", parent_directory, source_directory, "..", "routines");
}
else
{
routines_directory = g_build_path("/", source_directory, "routines", 0LL, v4);
if ( (unsigned int)g_str_has_suffix(source_directory, "/maps") )
routines_global_directory = g_build_path("/", source_directory, "..", "routines", 0LL);
}
goto LABEL_6;
}
}

canonical_decompiled_code:
void __fastcall func3(int a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // r8
_BYTE *v5; // rdi

if ( a1 > 1 )
{
v2 = a2 + 8LL * a1;
v3 = v2 - 8 - 8LL * (unsigned int)(a1 - 2);
while ( 1 )
{
v5 = *(_BYTE **)(v2 - 8);
if ( *v5 != 45 )
break;
if ( (unsigned int)g_strcmp0("--xmloutput", *(_QWORD *)(v2 - 8)) )
{
if ( (unsigned int)g_str_has_prefix(*(_QWORD *)(v2 - 8), "--temporary=") )
{
temporary_filepath = g_strdup(*(_QWORD *)(v2 - 8) + 12LL);
}
else if ( (unsigned int)g_str_has_prefix(*(_QWORD *)(v2 - 8), "--project=") )
{
project_directory = g_strdup(*(_QWORD *)(v2 - 8) + 10LL);
}
else if ( (unsigned int)g_str_has_prefix(*(_QWORD *)(v2 - 8), "--parent=") )
{
parent_directory = g_strdup(*(_QWORD *)(v2 - 8) + 9LL);
}
LABEL_6:
v2 -= 8LL;
if ( v2 == v3 )
return;
}
else
{
v2 -= 8LL;
xml_output = 1;
if ( v2 == v3 )
return;
}
}
source_filepath = (_BYTE *)g_strdup(v5);
func1(source_filepath);
source_directory = g_path_get_dirname(source_filepath);
source_filename = g_path_get_basename(source_filepath);
if ( parent_directory )
{
routines_directory = g_build_path("/", parent_directory, source_directory, "routines", 0LL);
if ( (unsigned int)g_str_has_suffix(source_directory, "/maps") )
routines_global_directory = g_build_path("/", parent_directory, source_directory, "..", "routines");
}
else
{
routines_directory = g_build_path("/", source_directory, "routines", 0LL, v4);
if ( (unsigned int)g_str_has_suffix(source_directory, "/maps") )
routines_global_directory = g_build_path("/", source_directory, "..", "routines", 0LL);
}
goto LABEL_6;
}
}

original_code:
void main_args( int argc, char *argv[])
{
 int c = argc;
 while ( c > 1 ) {
  --c;
  if ( argv[c][0] != '-' )
  {
   source_filepath = g_strdup(argv[c]);
   fix_path( source_filepath );
   source_directory = g_path_get_dirname(source_filepath);
   source_filename = g_path_get_basename(source_filepath);
   if ( parent_directory )
   {
    routines_directory = g_build_path( "/", parent_directory, source_directory, "routines", ((void *)0) );
    if ( g_str_has_suffix(source_directory, "/""maps") )
    {
     routines_global_directory = g_build_path( "/", parent_directory, source_directory, "..", "routines", ((void *)0) );
    }
   }
   else
   {
    routines_directory = g_build_path( "/", source_directory, "routines", ((void *)0) );
    if ( g_str_has_suffix(source_directory, "/""maps") )
    {
     routines_global_directory = g_build_path( "/", source_directory, "..", "routines", ((void *)0) );
    }
   }
  }
  else if ( !g_strcmp0("--xmloutput", argv[c]) )
  {
   xml_output = (!(0));
  }
  else if ( g_str_has_prefix( argv[c], "--temporary=" ) )
  {
   char * dir = argv[c] + 12;
   temporary_filepath = g_strdup(dir);
  }
  else if ( g_str_has_prefix( argv[c], "--project=" ) )
  {
   char * dir = argv[c] + 10;
   project_directory = g_strdup(dir);
  }
  else if ( g_str_has_prefix( argv[c], "--parent=" ) )
  {
   char * dir = argv[c] + 9;
   parent_directory = g_strdup(dir);
  }
 }
}

canonical_original_code:
void main_args(int argc, char *argv[])
{
 int c = argc;
 while ( c > 1 ) {
  --c;
  if ( argv[c][0] != '-' )
  {
   source_filepath = g_strdup(argv[c]);
   fix_path( source_filepath );
   source_directory = g_path_get_dirname(source_filepath);
   source_filename = g_path_get_basename(source_filepath);
   if ( parent_directory )
   {
    routines_directory = g_build_path( "/", parent_directory, source_directory, "routines", ((void *)0) );
    if ( g_str_has_suffix(source_directory, "/""maps") )
    {
     routines_global_directory = g_build_path( "/", parent_directory, source_directory, "..", "routines", ((void *)0) );
    }
   }
   else
   {
    routines_directory = g_build_path( "/", source_directory, "routines", ((void *)0) );
    if ( g_str_has_suffix(source_directory, "/""maps") )
    {
     routines_global_directory = g_build_path( "/", source_directory, "..", "routines", ((void *)0) );
    }
   }
  }
  else if ( !g_strcmp0("--xmloutput", argv[c]) )
  {
   xml_output = (!(0));
  }
  else if ( g_str_has_prefix( argv[c], "--temporary=" ) )
  {
   char *dir = argv[c] + 12;
   temporary_filepath = g_strdup(dir);
  }
  else if ( g_str_has_prefix( argv[c], "--project=" ) )
  {
   char *dir = argv[c] + 10;
   project_directory = g_strdup(dir);
  }
  else if ( g_str_has_prefix( argv[c], "--parent=" ) )
  {
   char *dir = argv[c] + 9;
   parent_directory = g_strdup(dir);
  }
 }
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: c int

variable_types:
dir
char *


decompiled_code:
__int64 __fastcall print_args(int a1, __int64 a2)
{
__int64 v2; // rbx
const char *v3; // rdx
__int64 result; // rax

if ( a1 > 1 )
{
v2 = a1;
do
{
v3 = *(const char **)(a2 + 8 * v2-- - 8);
result = g_print("%d: %s\n", (unsigned int)v2, v3);
}
while ( (int)v2 > 1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, __int64 a2)
{
__int64 v2; // rbx
const char *v3; // rdx
__int64 result; // rax

if ( a1 > 1 )
{
v2 = a1;
do
{
v3 = *(const char **)(a2 + 8 * v2-- - 8);
result = g_print("%d: %s\n", (unsigned int)v2, v3);
}
while ( (int)v2 > 1 );
}
return result;
}

original_code:
void print_args( int argc, char *argv[])
{
 int c = argc;
 while ( c > 1 ) {
  --c;
  g_print("%d: %s\n", c, argv[c] );
 }
}

canonical_original_code:
void print_args(int argc, char *argv[])
{
 int c = argc;
 while ( c > 1 ) {
  --c;
  g_print("%d: %s\n", c, argv[c] );
 }
}


decompiled_code:
__int64 __fastcall strip_file_extension(__int64 a1)
{
__int64 v1; // r12
_BYTE *v2; // rax

v1 = g_strdup(a1);
v2 = (_BYTE *)g_utf8_strrchr(v1, -1LL, 46LL);
if ( v2 )
*v2 = 0;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v1; // r12
_BYTE *v2; // rax

v1 = g_strdup(a1);
v2 = (_BYTE *)g_utf8_strrchr(v1, -1LL, 46LL);
if ( v2 )
*v2 = 0;
return v1;
}

original_code:
char * strip_file_extension( char * input_filename )
{
 char * output_filename = g_strdup( input_filename );
 char * dotpos = g_utf8_strrchr( output_filename, -1, '.' );
 if ( dotpos )
 {
  *dotpos = '\0';
 }
 return output_filename;
}

canonical_original_code:
char *strip_file_extension(char *input_filename)
{
 char *output_filename = g_strdup( input_filename );
 char *dotpos = g_utf8_strrchr( output_filename, -1, '.' );
 if ( dotpos )
 {
  *dotpos = '\0';
 }
 return output_filename;
}

variable_types:
dotpos
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // rax
const char *v4; // rsi
size_t v5; // rcx
__int64 v6; // rax
const char *v7; // rsi
const char *v8; // rdx
unsigned int v9; // ebp
__int64 *v10; // rsi
__int64 v11; // rdx
__int64 v12; // rdx
__int64 v13; // rdx
__int64 v14; // rdx
__int64 v15; // rdx
__int64 v16; // rdx
const char **v18; // rax
__int64 v19; // rdx
__int64 v20; // rdx
const char *v21; // rax
__int64 v22; // [rsp+0h] [rbp-78h] BYREF
__int64 v23; // [rsp+8h] [rbp-70h]
__int64 v24; // [rsp+10h] [rbp-68h]
__int64 v25; // [rsp+18h] [rbp-60h]
__int64 v26; // [rsp+20h] [rbp-58h]
__int64 v27; // [rsp+28h] [rbp-50h]
__int64 v28; // [rsp+30h] [rbp-48h]

program_directory = g_path_get_dirname(*argv);
v22 = g_strdup(*argv);
include_directory = get_global_include_path();
if ( !include_directory )
include_directory = g_strdup(".");
main_args(argc, (__int64)argv);
v3 = source_filepath;
if ( !source_filepath )
{
g_print("Mokoi Pawn Compiler\n");
v21 = (const char *)get_global_include_path();
g_print("Headers located at %s\n", v21);
g_print("No file given\n");
g_print("\n");
return 0;
}
if ( temporary_filepath )
v3 = (_BYTE *)temporary_filepath;
filename = v3;
output_filename = (const char *)strip_file_extension((__int64)source_filename);
if ( project_directory )
{
if ( (unsigned int)g_str_has_prefix(source_filepath, project_directory) )
{
v4 = project_directory;
v5 = source_directory + strlen(project_directory);
}
else
{
v4 = project_directory;
v5 = source_directory;
if ( !source_directory )
{
output_directory = (const char *)g_strdup(project_directory);
goto LABEL_10;
}
}
output_directory = (const char *)g_build_path("/", v4, "c", v5, 0LL);
}
else
{
output_directory = (const char *)g_strdup(source_directory);
}
LABEL_10:
g_mkdir_with_parents(output_directory, 493LL);
v6 = g_strdup_printf("%s.amx64", output_filename);
v7 = output_filename;
output_filename_64 = v6;
v8 = (const char *)g_strdup_printf("%s.amx", output_filename);
output_filename_32 = v8;
if ( xml_output )
{
xml_content = g_string_new(&LC26, v7, v8);
g_string_printf(xml_content, "<results file=\"%s\">\n", source_filename);
}
else
{
g_print("Saving to %s %s\n", output_directory, v8);
}
v23 = g_strdup(filename);
v9 = 6;
v24 = g_strconcat("-i", include_directory, 0LL);
v25 = g_strconcat("-i", routines_directory, 0LL);
if ( routines_global_directory )
{
v9 = 7;
v28 = g_strconcat("-i", routines_global_directory, 0LL);
}
v26 = g_strconcat("-o", output_directory, "/");
v10 = &v22;
v27 = g_strdup("-C32");
compiler_main(v9, &v22, handling_error_code);
g_free(v26, &v22, v11);
g_free(v27, &v22, v12);
v13 = fatal_error_count;
if ( !fatal_error_count )
{
v26 = g_strconcat("-o", output_directory, "/");
v10 = &v22;
v27 = g_strdup("-C64");
compiler_main(v9, &v22, handling_error_code);
g_free(v26, &v22, v19);
g_free(v27, &v22, v20);
}
if ( xml_output )
{
v18 = (const char **)g_string_append(xml_content, "</results>\n", v13);
xml_content = v18;
if ( v18 )
{
v10 = (__int64 *)*v18;
g_print("%s", *v18);
}
else
{
v10 = (__int64 *)source_filepath;
g_print("<error source=\"%s\"/>\n", source_filepath);
}
}
g_free(v22, v10, v13);
g_free(v23, v10, v14);
g_free(v24, v10, v15);
g_free(v25, v10, v16);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // rax
const char *v4; // rsi
size_t v5; // rcx
__int64 v6; // rax
const char *v7; // rsi
const char *v8; // rdx
unsigned int v9; // ebp
__int64 *v10; // rsi
__int64 v11; // rdx
__int64 v12; // rdx
__int64 v13; // rdx
__int64 v14; // rdx
__int64 v15; // rdx
__int64 v16; // rdx
const char **v18; // rax
__int64 v19; // rdx
__int64 v20; // rdx
const char *v21; // rax
__int64 v22; // [rsp+0h] [rbp-78h] BYREF
__int64 v23; // [rsp+8h] [rbp-70h]
__int64 v24; // [rsp+10h] [rbp-68h]
__int64 v25; // [rsp+18h] [rbp-60h]
__int64 v26; // [rsp+20h] [rbp-58h]
__int64 v27; // [rsp+28h] [rbp-50h]
__int64 v28; // [rsp+30h] [rbp-48h]

program_directory = g_path_get_dirname(*argv);
v22 = g_strdup(*argv);
include_directory = func2();
if ( !include_directory )
include_directory = g_strdup(".");
func3(argc, (__int64)argv);
v3 = source_filepath;
if ( !source_filepath )
{
g_print("Mokoi Pawn Compiler\n");
v21 = (const char *)func2();
g_print("Headers located at %s\n", v21);
g_print("No file given\n");
g_print("\n");
return 0;
}
if ( temporary_filepath )
v3 = (_BYTE *)temporary_filepath;
filename = v3;
output_filename = (const char *)func5((__int64)source_filename);
if ( project_directory )
{
if ( (unsigned int)g_str_has_prefix(source_filepath, project_directory) )
{
v4 = project_directory;
v5 = source_directory + strlen(project_directory);
}
else
{
v4 = project_directory;
v5 = source_directory;
if ( !source_directory )
{
output_directory = (const char *)g_strdup(project_directory);
goto LABEL_10;
}
}
output_directory = (const char *)g_build_path("/", v4, "c", v5, 0LL);
}
else
{
output_directory = (const char *)g_strdup(source_directory);
}
LABEL_10:
g_mkdir_with_parents(output_directory, 493LL);
v6 = g_strdup_printf("%s.amx64", output_filename);
v7 = output_filename;
output_filename_64 = v6;
v8 = (const char *)g_strdup_printf("%s.amx", output_filename);
output_filename_32 = v8;
if ( xml_output )
{
xml_content = g_string_new(&LC26, v7, v8);
g_string_printf(xml_content, "<results file=\"%s\">\n", source_filename);
}
else
{
g_print("Saving to %s %s\n", output_directory, v8);
}
v23 = g_strdup(filename);
v9 = 6;
v24 = g_strconcat("-i", include_directory, 0LL);
v25 = g_strconcat("-i", routines_directory, 0LL);
if ( routines_global_directory )
{
v9 = 7;
v28 = g_strconcat("-i", routines_global_directory, 0LL);
}
v26 = g_strconcat("-o", output_directory, "/");
v10 = &v22;
v27 = g_strdup("-C32");
compiler_main(v9, &v22, handling_error_code);
g_free(v26, &v22, v11);
g_free(v27, &v22, v12);
v13 = fatal_error_count;
if ( !fatal_error_count )
{
v26 = g_strconcat("-o", output_directory, "/");
v10 = &v22;
v27 = g_strdup("-C64");
compiler_main(v9, &v22, handling_error_code);
g_free(v26, &v22, v19);
g_free(v27, &v22, v20);
}
if ( xml_output )
{
v18 = (const char **)g_string_append(xml_content, "</results>\n", v13);
xml_content = v18;
if ( v18 )
{
v10 = (__int64 *)*v18;
g_print("%s", *v18);
}
else
{
v10 = (__int64 *)source_filepath;
g_print("<error source=\"%s\"/>\n", source_filepath);
}
}
g_free(v22, v10, v13);
g_free(v23, v10, v14);
g_free(v24, v10, v15);
g_free(v25, v10, v16);
return 0;
}

original_code:
int main( int argc, char *argv[] )
{
 int arg_c = 6;
 char * arg_v[7];
 program_directory = g_path_get_dirname(argv[0]);
 arg_v[0] = g_strdup(argv[0]);
 include_directory = get_global_include_path();
 if ( !include_directory )
 {
  include_directory = g_strdup(".");
 }
 main_args(argc, argv);
 if ( !source_filepath )
 {
  g_print("Mokoi Pawn Compiler\n");
  g_print("Headers located at %s\n", get_global_include_path() );
  g_print("No file given\n");
  g_print("\n");
  return 0;
 }
 if ( temporary_filepath )
 {
  filename = temporary_filepath;
 }
 else
 {
  filename = source_filepath;
 }
 output_filename = strip_file_extension( source_filename );
 if ( project_directory )
 {
  if ( g_str_has_prefix( source_filepath, project_directory ) )
  {
   char * dir = source_directory + strlen(project_directory);
   output_directory = g_build_path("/", project_directory, "c", dir, ((void *)0));
  }
  else if (source_directory)
  {
   output_directory = g_build_path("/", project_directory, "c", source_directory, ((void *)0));
  }
  else
  {
   output_directory = g_strdup(project_directory);
  }
 }
 else
 {
  output_directory = g_strdup(source_directory);
 }
 g_mkdir_with_parents( output_directory, 0755 );
 output_filename_64 = g_strdup_printf( "%s.amx64", output_filename );
 output_filename_32 = g_strdup_printf( "%s.amx", output_filename );
 if ( xml_output )
 {
  xml_content = g_string_new("");
  g_string_printf(xml_content, "<results file=\"%s\">\n", source_filename);
 }
 else
 {
  g_print( "Saving to %s %s\n", output_directory, output_filename_32 );
 }
 arg_v[1] = g_strdup( filename );
 arg_v[2] = g_strconcat( "-i", include_directory, ((void *)0) );
 arg_v[3] = g_strconcat( "-i", routines_directory, ((void *)0) );
 if ( routines_global_directory )
 {
  arg_c++;
  arg_v[6] = g_strconcat( "-i", routines_global_directory, ((void *)0) );
 }
 arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_32, ((void *)0) );
 arg_v[5] = g_strdup("-C32");
 compiler_main(arg_c, arg_v, handling_error_code);
 g_free(arg_v[4]);
 g_free(arg_v[5]);
 if ( !fatal_error_count )
 {
  arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_64, ((void *)0) );
  arg_v[5] = g_strdup("-C64");
  compiler_main(arg_c, arg_v, handling_error_code);
  g_free(arg_v[4]);
  g_free(arg_v[5]);
 }
 if ( xml_output )
 {
  xml_content = g_string_append(xml_content, "</results>\n");
  if ( xml_content )
   g_print( "%s", xml_content->str );
  else
   g_print("<error source=\"%s\"/>\n", source_filepath);
 }
 g_free(arg_v[0]);
 g_free(arg_v[1]);
 g_free(arg_v[2]);
 g_free(arg_v[3]);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int arg_c = 6;
 char *arg_v[7];
 program_directory = g_path_get_dirname(argv[0]);
 arg_v[0] = g_strdup(argv[0]);
 include_directory = get_global_include_path();
 if ( !include_directory )
 {
  include_directory = g_strdup(".");
 }
 main_args(argc, argv);
 if ( !source_filepath )
 {
  g_print("Mokoi Pawn Compiler\n");
  g_print("Headers located at %s\n", get_global_include_path() );
  g_print("No file given\n");
  g_print("\n");
  return 0;
 }
 if ( temporary_filepath )
 {
  filename = temporary_filepath;
 }
 else
 {
  filename = source_filepath;
 }
 output_filename = strip_file_extension( source_filename );
 if ( project_directory )
 {
  if ( g_str_has_prefix( source_filepath, project_directory ) )
  {
   char *dir = source_directory + strlen(project_directory);
   output_directory = g_build_path("/", project_directory, "c", dir, ((void *)0));
  }
  else if (source_directory)
  {
   output_directory = g_build_path("/", project_directory, "c", source_directory, ((void *)0));
  }
  else
  {
   output_directory = g_strdup(project_directory);
  }
 }
 else
 {
  output_directory = g_strdup(source_directory);
 }
 g_mkdir_with_parents( output_directory, 0755 );
 output_filename_64 = g_strdup_printf( "%s.amx64", output_filename );
 output_filename_32 = g_strdup_printf( "%s.amx", output_filename );
 if ( xml_output )
 {
  xml_content = g_string_new("");
  g_string_printf(xml_content, "<results file=\"%s\">\n", source_filename);
 }
 else
 {
  g_print( "Saving to %s %s\n", output_directory, output_filename_32 );
 }
 arg_v[1] = g_strdup( filename );
 arg_v[2] = g_strconcat( "-i", include_directory, ((void *)0) );
 arg_v[3] = g_strconcat( "-i", routines_directory, ((void *)0) );
 if ( routines_global_directory )
 {
  arg_c++;
  arg_v[6] = g_strconcat( "-i", routines_global_directory, ((void *)0) );
 }
 arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_32, ((void *)0) );
 arg_v[5] = g_strdup("-C32");
 compiler_main(arg_c, arg_v, handling_error_code);
 g_free(arg_v[4]);
 g_free(arg_v[5]);
 if ( !fatal_error_count )
 {
  arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_64, ((void *)0) );
  arg_v[5] = g_strdup("-C64");
  compiler_main(arg_c, arg_v, handling_error_code);
  g_free(arg_v[4]);
  g_free(arg_v[5]);
 }
 if ( xml_output )
 {
  xml_content = g_string_append(xml_content, "</results>\n");
  if ( xml_content )
   g_print( "%s", xml_content->str );
  else
   g_print("<error source=\"%s\"/>\n", source_filepath);
 }
 g_free(arg_v[0]);
 g_free(arg_v[1]);
 g_free(arg_v[2]);
 g_free(arg_v[3]);
 return 0;
}


decompiled_code:
__int64 __fastcall KeeLoq_Encrypt(int a1, unsigned __int64 a2)
{
__int64 result; // rax
int i; // esi
char v5; // cl

LODWORD(result) = a1;
for ( i = 0; i != 528; ++i )
{
v5 = i;
result = ((unsigned int)result >> 1) ^ (((979137582 >> (((result & 2) != 0)
+ 2
* (((result & 0x200) != 0)
+ 2
* (((result & 0x100000) != 0)
+ 2 * (((result & 0x4000000) != 0) + 2 * ((int)result < 0)))))) ^ (unsigned int)(a2 >> v5) ^ WORD1(result) ^ (unsigned int)result) << 31);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, unsigned __int64 a2)
{
__int64 result; // rax
int i; // esi
char v5; // cl

LODWORD(result) = a1;
for ( i = 0; i != 528; ++i )
{
v5 = i;
result = ((unsigned int)result >> 1) ^ (((979137582 >> (((result & 2) != 0)
+ 2
* (((result & 0x200) != 0)
+ 2
* (((result & 0x100000) != 0)
+ 2 * (((result & 0x4000000) != 0) + 2 * ((int)result < 0)))))) ^ (unsigned int)(a2 >> v5) ^ WORD1(result) ^ (unsigned int)result) << 31);
}
return result;
}

variable_types:
data
unsigned int

variable_types:
key
unsigned long

variable_types:
x
unsigned int

variable_types:
r
unsigned int

return_type: unsigned int


decompiled_code:
unsigned __int64 __fastcall KeeLoq_Decrypt(int a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax
int i; // er8
char v4; // cl

LODWORD(result) = a1;
for ( i = 15; i != -513; --i )
{
v4 = i;
result = (a2 >> v4) & 1 ^ __ROL4__(result, 1) ^ ((unsigned int)result >> 15) & 1 ^ (979137582 >> ((result & 1) + 2 * ((BYTE1(result) & 1) + 2 * (((result & 0x80000) != 0) + 2 * ((((unsigned int)result >> 29) & 2) + ((result & 0x2000000) != 0)))))) & 1;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(int a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax
int i; // er8
char v4; // cl

LODWORD(result) = a1;
for ( i = 15; i != -513; --i )
{
v4 = i;
result = (a2 >> v4) & 1 ^ __ROL4__(result, 1) ^ ((unsigned int)result >> 15) & 1 ^ (979137582 >> ((result & 1) + 2 * ((BYTE1(result) & 1) + 2 * (((result & 0x80000) != 0) + 2 * ((((unsigned int)result >> 29) & 2) + ((result & 0x2000000) != 0)))))) & 1;
}
return result;
}


decompiled_code:
const char *__fastcall find_automaton(char *s1, _DWORD *a2, char *a3)
{
const char *v4; // r12
int v5; // er14
int v6; // eax
int v7; // eax
int v9; // [rsp+Ch] [rbp-3Ch]

*a2 = 0;
if ( a3 )
*a3 = 0;
v4 = (const char *)sc_automaton_tab;
if ( !sc_automaton_tab )
return 0LL;
v5 = 0x7FFFFFFF;
while ( strcmp(s1, v4 + 8) )
{
if ( a3 )
{
if ( v4[8] )
{
v7 = levenshtein_distance(s1, v4 + 8);
if ( v7 < v5 )
{
v9 = v7;
if ( v7 <= 2 )
{
strcpy(a3, v4 + 8);
v5 = v9;
}
}
}
}
v6 = *((_DWORD *)v4 + 12);
if ( v6 > *a2 )
*a2 = v6;
v4 = *(const char **)v4;
if ( !v4 )
return 0LL;
}
return v4;
}

canonical_decompiled_code:
const char *__fastcall func0(char *s1, _DWORD *a2, char *a3)
{
const char *v4; // r12
int v5; // er14
int v6; // eax
int v7; // eax
int v9; // [rsp+Ch] [rbp-3Ch]

*a2 = 0;
if ( a3 )
*a3 = 0;
v4 = (const char *)sc_automaton_tab;
if ( !sc_automaton_tab )
return 0LL;
v5 = 0x7FFFFFFF;
while ( strcmp(s1, v4 + 8) )
{
if ( a3 )
{
if ( v4[8] )
{
v7 = levenshtein_distance(s1, v4 + 8);
if ( v7 < v5 )
{
v9 = v7;
if ( v7 <= 2 )
{
strcpy(a3, v4 + 8);
v5 = v9;
}
}
}
}
v6 = *((_DWORD *)v4 + 12);
if ( v6 > *a2 )
*a2 = v6;
v4 = *(const char **)v4;
if ( !v4 )
return 0LL;
}
return v4;
}

original_code:
static constvalue *find_automaton(const char *name,int *last,char *closestmatch)
{
  constvalue *ptr;
  int dist,closestdist=0x7fffffff;
  ((void) (0));
  *last=0;
  if (closestmatch!=((void *)0))
    *closestmatch='\0';
  ptr=sc_automaton_tab.next;
  while (ptr!=((void *)0)) {
    if (strcmp(name,ptr->name)==0)
      return ptr;
    if (closestmatch!=((void *)0) && strlen(ptr->name)>0) {
      dist=levenshtein_distance(name,ptr->name);
      if (dist<closestdist && dist<=2) {
        strcpy(closestmatch,ptr->name);
        closestdist=dist;
      }
    }
    if (ptr->index>*last)
      *last=ptr->index;
    ptr=ptr->next;
  }
  return ((void *)0);
}

canonical_original_code:
static struct s_constvalue *find_automaton(char *name, int *last, char *closestmatch)
{
  struct s_constvalue *ptr;
  int dist; int closestdist = 0x7fffffff;
  ((void) (0));
  *last=0;
  if (closestmatch!=((void *)0))
    *closestmatch='\0';
  ptr=sc_automaton_tab.next;
  while (ptr!=((void *)0)) {
    if (strcmp(name,ptr->name)==0)
      return ptr;
    if (closestmatch!=((void *)0) && strlen(ptr->name)>0) {
      dist=levenshtein_distance(name,ptr->name);
      if (dist<closestdist && dist<=2) {
        strcpy(closestmatch,ptr->name);
        closestdist=dist;
      }
    }
    if (ptr->index>*last)
      *last=ptr->index;
    ptr=ptr->next;
  }
  return ((void *)0);
}

variable_types:
name
char *

variable_types:
last
int *

variable_types:
closestmatch
char *

variable_types: struct s_constvalue { struct s_constvalue *next; char name[-1]; long value; int index; char usage; } *

variable_types: dist int

variable_types: closestdist int


decompiled_code:
const char *__fastcall find_state(char *s1, int a2, _DWORD *a3, char *a4)
{
const char *v6; // r12
__int64 v7; // rax
int v9; // eax
int v10; // [rsp+8h] [rbp-40h]
int v11; // [rsp+Ch] [rbp-3Ch]

*a3 = 0;
if ( a4 )
*a4 = 0;
v6 = (const char *)sc_state_tab;
if ( sc_state_tab )
{
v10 = 0x7FFFFFFF;
do
{
while ( 1 )
{
if ( *((_DWORD *)v6 + 12) == a2 )
{
if ( !strcmp(s1, v6 + 8) )
return v6;
if ( a4 )
{
if ( v6[8] )
{
v9 = levenshtein_distance(s1, v6 + 8);
if ( v9 < v10 )
{
v11 = v9;
if ( v9 <= 2 )
{
strcpy(a4, v6 + 8);
v10 = v11;
}
}
}
}
v7 = *((_QWORD *)v6 + 5);
if ( (int)v7 > *a3 )
break;
}
v6 = *(const char **)v6;
if ( !v6 )
return 0LL;
}
v6 = *(const char **)v6;
*a3 = v7;
}
while ( v6 );
}
return 0LL;
}

canonical_decompiled_code:
const char *__fastcall func1(char *s1, int a2, _DWORD *a3, char *a4)
{
const char *v6; // r12
__int64 v7; // rax
int v9; // eax
int v10; // [rsp+8h] [rbp-40h]
int v11; // [rsp+Ch] [rbp-3Ch]

*a3 = 0;
if ( a4 )
*a4 = 0;
v6 = (const char *)sc_state_tab;
if ( sc_state_tab )
{
v10 = 0x7FFFFFFF;
do
{
while ( 1 )
{
if ( *((_DWORD *)v6 + 12) == a2 )
{
if ( !strcmp(s1, v6 + 8) )
return v6;
if ( a4 )
{
if ( v6[8] )
{
v9 = levenshtein_distance(s1, v6 + 8);
if ( v9 < v10 )
{
v11 = v9;
if ( v9 <= 2 )
{
strcpy(a4, v6 + 8);
v10 = v11;
}
}
}
}
v7 = *((_QWORD *)v6 + 5);
if ( (int)v7 > *a3 )
break;
}
v6 = *(const char **)v6;
if ( !v6 )
return 0LL;
}
v6 = *(const char **)v6;
*a3 = v7;
}
while ( v6 );
}
return 0LL;
}

original_code:
static constvalue *find_state(const char *name,int fsa,int *last,char *closestmatch)
{
  constvalue *ptr;
  int dist,closestdist=0x7fffffff;
  ((void) (0));
  *last=0;
  if (closestmatch!=((void *)0))
    *closestmatch='\0';
  ptr=sc_state_tab.next;
  while (ptr!=((void *)0)) {
    if (ptr->index==fsa) {
      if (strcmp(name,ptr->name)==0)
        return ptr;
      if (closestmatch!=((void *)0) && strlen(ptr->name)>0) {
        dist=levenshtein_distance(name,ptr->name);
        if (dist<closestdist && dist<=2) {
          strcpy(closestmatch,ptr->name);
          closestdist=dist;
        }
      }
      if ((int)ptr->value>*last)
        *last=(int)ptr->value;
    }
    ptr=ptr->next;
  }
  return ((void *)0);
}

canonical_original_code:
static struct s_constvalue *find_state(char *name, int fsa, int *last, char *closestmatch)
{
  struct s_constvalue *ptr;
  int dist; int closestdist = 0x7fffffff;
  ((void) (0));
  *last=0;
  if (closestmatch!=((void *)0))
    *closestmatch='\0';
  ptr=sc_state_tab.next;
  while (ptr!=((void *)0)) {
    if (ptr->index==fsa) {
      if (strcmp(name,ptr->name)==0)
        return ptr;
      if (closestmatch!=((void *)0) && strlen(ptr->name)>0) {
        dist=levenshtein_distance(name,ptr->name);
        if (dist<closestdist && dist<=2) {
          strcpy(closestmatch,ptr->name);
          closestdist=dist;
        }
      }
      if ((int)ptr->value>*last)
        *last=(int)ptr->value;
    }
    ptr=ptr->next;
  }
  return ((void *)0);
}

variable_types: fsa int

return_type: struct s_constvalue { struct s_constvalue *next; char name[-1]; long value; int index; char usage; } *


decompiled_code:
const char *__fastcall automaton_find(char *a1, char *a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

return find_automaton(a1, v3, a2);
}

canonical_decompiled_code:
const char *__fastcall func4(char *a1, char *a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

return func0(a1, v3, a2);
}

original_code:
constvalue *automaton_find(const char *name,char *closestmatch)
{
  int last;
  return find_automaton(name,&last,closestmatch);
}

canonical_original_code:
struct s_constvalue *automaton_find(char *name, char *closestmatch)
{
  int last;
  return find_automaton(name,&last,closestmatch);
}

variable_types: last int


decompiled_code:
const char *__fastcall state_add(char *a1, __int16 a2)
{
const char *result; // rax
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = find_state(a1, a2, v3, 0LL);
if ( !result )
result = (const char *)append_constval(&sc_state_tab, a1, v3[0] + 1, (unsigned int)a2);
return result;
}

canonical_decompiled_code:
const char *__fastcall func5(char *a1, __int16 a2)
{
const char *result; // rax
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = func1(a1, a2, v3, 0LL);
if ( !result )
result = (const char *)append_constval(&sc_state_tab, a1, v3[0] + 1, (unsigned int)a2);
return result;
}

original_code:
constvalue *state_add(const char *name,int fsa)
{
  constvalue *ptr;
  int last;
  ((void) (0));
  ptr=find_state(name,fsa,&last,((void *)0));
  if (ptr==((void *)0)) {
    ((void) (0));
    ptr=append_constval(&sc_state_tab,name,(cell)(last+1),(short)fsa);
  }
  return ptr;
}

canonical_original_code:
struct s_constvalue *state_add(char *name, int fsa)
{
  struct s_constvalue *ptr;
  int last;
  ((void) (0));
  ptr=find_state(name,fsa,&last,((void *)0));
  if (ptr==((void *)0)) {
    ((void) (0));
    ptr=append_constval(&sc_state_tab,name,(cell)(last+1),(short)fsa);
  }
  return ptr;
}


decompiled_code:
const char *__fastcall state_find(char *a1, int a2, char *a3)
{
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

return find_state(a1, a2, v4, a3);
}

canonical_decompiled_code:
const char *__fastcall func6(char *a1, int a2, char *a3)
{
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

return func1(a1, a2, v4, a3);
}

original_code:
constvalue *state_find(const char *name,int fsa_id,char *closestmatch)
{
  int last;
  return find_state(name,fsa_id,&last,closestmatch);
}

canonical_original_code:
struct s_constvalue *state_find(char *name, int fsa_id, char *closestmatch)
{
  int last;
  return find_state(name,fsa_id,&last,closestmatch);
}


decompiled_code:
__int64 __fastcall state_addlist(void *src, int a2, int a3)
{
_DWORD *v5; // rax
__int64 result; // rax
const char *v7; // rdx
_QWORD *v8; // r13
void *v9; // rax
void *v10; // rdi
int v11; // eax
void *v12; // rdx
const char *v13; // rdx
int v14[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v5 = state_findlist((__int64)src, a2, a3, v14);
if ( v5 )
return (unsigned int)v5[6];
v8 = malloc(0x20uLL);
if ( !v8 )
error(103, a2, v7);
v9 = malloc(4LL * a2);
v8[1] = v9;
v10 = v9;
if ( !v9 )
{
free(v8);
error(103, a2, v13);
v10 = (void *)v8[1];
}
memcpy(v10, src, 4LL * a2);
v11 = v14[0];
v12 = statepool_tab;
*((_DWORD *)v8 + 4) = a2;
*((_DWORD *)v8 + 5) = a3;
result = (unsigned int)(v11 + 1);
*v8 = v12;
*((_DWORD *)v8 + 6) = result;
statepool_tab = v8;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(void *src, int a2, int a3)
{
_DWORD *v5; // rax
__int64 result; // rax
const char *v7; // rdx
_QWORD *v8; // r13
void *v9; // rax
void *v10; // rdi
int v11; // eax
void *v12; // rdx
const char *v13; // rdx
int v14[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v5 = state_findlist((__int64)src, a2, a3, v14);
if ( v5 )
return (unsigned int)v5[6];
v8 = malloc(0x20uLL);
if ( !v8 )
error(103, a2, v7);
v9 = malloc(4LL * a2);
v8[1] = v9;
v10 = v9;
if ( !v9 )
{
free(v8);
error(103, a2, v13);
v10 = (void *)v8[1];
}
memcpy(v10, src, 4LL * a2);
v11 = v14[0];
v12 = statepool_tab;
*((_DWORD *)v8 + 4) = a2;
*((_DWORD *)v8 + 5) = a3;
result = (unsigned int)(v11 + 1);
*v8 = v12;
*((_DWORD *)v8 + 6) = result;
statepool_tab = v8;
return result;
}

original_code:
int state_addlist(int *list,int count,int fsa)
{
  statepool *ptr;
  int last;
  ((void) (0));
  ((void) (0));
  ptr=state_findlist(list,count,fsa,&last);
  if (ptr==((void *)0)) {
    if ((ptr=(statepool*)malloc(sizeof(statepool)))==((void *)0))
      error(103);
    if ((ptr->states=(int*)malloc(count*sizeof(int)))==((void *)0)) {
      free(ptr);
      error(103);
    }
    memcpy(ptr->states,list,count*sizeof(int));
    ptr->numstates=count;
    ptr->fsa=fsa;
    ptr->listid=last+1;
    ptr->next=statepool_tab.next;
    statepool_tab.next=ptr;
  }
  ((void) (0));
  return ptr->listid;
}

canonical_original_code:
int state_addlist(int *list, int count, int fsa)
{
  struct s_statepool *ptr;
  int last;
  ((void) (0));
  ((void) (0));
  ptr=state_findlist(list,count,fsa,&last);
  if (ptr==((void *)0)) {
    if ((ptr=(struct s_statepool *)malloc(sizeof(statepool)))==((void *)0))
      error(103);
    if ((ptr->states=(int *)malloc(count*sizeof(int)))==((void *)0)) {
      free(ptr);
      error(103);
    }
    memcpy(ptr->states,list,count*sizeof(int));
    ptr->numstates=count;
    ptr->fsa=fsa;
    ptr->listid=last+1;
    ptr->next=statepool_tab.next;
    statepool_tab.next=ptr;
  }
  ((void) (0));
  return ptr->listid;
}

variable_types:
list
int *

variable_types: count int

variable_types: struct s_statepool { struct s_statepool *next; int *states; int numstates; int fsa; int listid; } *


decompiled_code:
void state_deletetable()
{
_QWORD *v0; // rbx
_QWORD *v1; // rbp
void *v2; // rdi

v0 = statepool_tab;
if ( statepool_tab )
{
do
{
v1 = v0;
v0 = (_QWORD *)*v0;
v2 = (void *)v1[1];
statepool_tab = v0;
free(v2);
free(v1);
}
while ( v0 );
}
}

canonical_decompiled_code:
void func9()
{
_QWORD *v0; // rbx
_QWORD *v1; // rbp
void *v2; // rdi

v0 = statepool_tab;
if ( statepool_tab )
{
do
{
v1 = v0;
v0 = (_QWORD *)*v0;
v2 = (void *)v1[1];
statepool_tab = v0;
free(v2);
free(v1);
}
while ( v0 );
}
}

original_code:
void state_deletetable(void)
{
  statepool *ptr;
  while (statepool_tab.next!=((void *)0)) {
    ptr=statepool_tab.next;
    statepool_tab.next=ptr->next;
    ((void) (0));
    free(ptr->states);
    free(ptr);
  }
}

canonical_original_code:
void state_deletetable()
{
  struct s_statepool *ptr;
  while (statepool_tab.next!=((void *)0)) {
    ptr=statepool_tab.next;
    statepool_tab.next=ptr->next;
    ((void) (0));
    free(ptr->states);
    free(ptr);
  }
}

user_defined_types: struct s_statepool { struct s_statepool *next; int *states; int numstates; int fsa; int listid; }


decompiled_code:
__int64 __fastcall state_getfsa(int a1)
{
_DWORD *v1; // rax
__int64 result; // rax

if ( a1 && (v1 = state_getlist_ptr(a1)) != 0LL )
result = (unsigned int)v1[5];
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1)
{
_DWORD *v1; // rax
__int64 result; // rax

if ( a1 && (v1 = state_getlist_ptr(a1)) != 0LL )
result = (unsigned int)v1[5];
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int state_getfsa(int listid)
{
  statepool *ptr;
  ((void) (0));
  if (listid==0)
    return -1;
  ptr=state_getlist_ptr(listid);
  return (ptr!=((void *)0)) ? ptr->fsa : -1;
}

canonical_original_code:
int state_getfsa(int listid)
{
  struct s_statepool *ptr;
  ((void) (0));
  if (listid==0)
    return -1;
  ptr=state_getlist_ptr(listid);
  return (ptr!=((void *)0)) ? ptr->fsa : -1;
}

variable_types: listid int


decompiled_code:
__int64 __fastcall state_count(int a1)
{
_DWORD *v1; // rax
__int64 result; // rax

v1 = state_getlist_ptr(a1);
if ( v1 )
result = (unsigned int)v1[4];
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1)
{
_DWORD *v1; // rax
__int64 result; // rax

v1 = state_getlist_ptr(a1);
if ( v1 )
result = (unsigned int)v1[4];
else
result = 0LL;
return result;
}

original_code:
int state_count(int listid)
{
  statepool *ptr=state_getlist_ptr(listid);
  if (ptr==((void *)0))
    return 0;
  return ptr->numstates;
}

canonical_original_code:
int state_count(int listid)
{
  struct s_statepool *ptr = state_getlist_ptr(listid);
  if (ptr==((void *)0))
    return 0;
  return ptr->numstates;
}


decompiled_code:
__int64 __fastcall state_inlist(int a1, int a2)
{
_DWORD *v2; // rax
int v3; // edx
_DWORD *v4; // rax
__int64 v5; // rdx

v2 = state_getlist_ptr(a1);
if ( !v2 )
return 0LL;
v3 = v2[4];
if ( v3 <= 0 )
return 0LL;
v4 = (_DWORD *)*((_QWORD *)v2 + 1);
v5 = (__int64)&v4[v3 - 1 + 1];
while ( *v4 != a2 )
{
if ( ++v4 == (_DWORD *)v5 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2)
{
_DWORD *v2; // rax
int v3; // edx
_DWORD *v4; // rax
__int64 v5; // rdx

v2 = state_getlist_ptr(a1);
if ( !v2 )
return 0LL;
v3 = v2[4];
if ( v3 <= 0 )
return 0LL;
v4 = (_DWORD *)*((_QWORD *)v2 + 1);
v5 = (__int64)&v4[v3 - 1 + 1];
while ( *v4 != a2 )
{
if ( ++v4 == (_DWORD *)v5 )
return 0LL;
}
return 1LL;
}

original_code:
int state_inlist(int listid,int state)
{
  statepool *ptr;
  int i;
  ptr=state_getlist_ptr(listid);
  if (ptr==((void *)0))
    return 0;
  for (i=0; i<ptr->numstates; i++)
    if (ptr->states[i]==state)
      return 1;
  return 0;
}

canonical_original_code:
int state_inlist(int listid, int state)
{
  struct s_statepool *ptr;
  int i;
  ptr=state_getlist_ptr(listid);
  if (ptr==((void *)0))
    return 0;
  for (i=0; i<ptr->numstates; i++)
    if (ptr->states[i]==state)
      return 1;
  return 0;
}

variable_types: state int

variable_types: i int


decompiled_code:
__int64 __fastcall state_listitem(int a1, int a2)
{
return *(unsigned int *)(*((_QWORD *)state_getlist_ptr(a1) + 1) + 4LL * a2);
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, int a2)
{
return *(unsigned int *)(*((_QWORD *)state_getlist_ptr(a1) + 1) + 4LL * a2);
}

original_code:
int state_listitem(int listid,int index)
{
  statepool *ptr;
  ptr=state_getlist_ptr(listid);
  ((void) (0));
  ((void) (0));
  return ptr->states[index];
}

canonical_original_code:
int state_listitem(int listid, int index)
{
  struct s_statepool *ptr;
  ptr=state_getlist_ptr(listid);
  ((void) (0));
  ((void) (0));
  return ptr->states[index];
}

variable_types: index int


original_code:
void state_conflict(symbol *root)
{
  statepool *psrc,*ptgt;
  statelist *srcptr,*tgtptr;
  symbol *sym;
  ((void) (0));
  for (sym=root->next; sym!=((void *)0); sym=sym->next) {
    if (sym->parent!=((void *)0) || sym->ident!=9)
      continue;
    if (sym->states==((void *)0))
      continue;
    for (srcptr=sym->states->next; srcptr!=((void *)0); srcptr=srcptr->next) {
      if (srcptr->id==-1)
        continue;
      psrc=state_getlist_ptr(srcptr->id);
      ((void) (0));
      for (tgtptr=srcptr->next; tgtptr!=((void *)0); tgtptr=tgtptr->next) {
        if (tgtptr->id==-1)
          continue;
        ptgt=state_getlist_ptr(tgtptr->id);
        ((void) (0));
        if (psrc->fsa!=ptgt->fsa && strcmp(sym->name,"entry")!=0)
          error(83,sym->name);
        if (checkconflict(psrc,ptgt))
          error(84,sym->name);
      }
    }
  }
}

canonical_original_code:
void state_conflict(struct s_symbol *root)
{
  struct s_statepool *psrc; struct s_statepool *ptgt;
  struct s_statelist *srcptr; struct s_statelist *tgtptr;
  struct s_symbol *sym;
  ((void) (0));
  for (sym=root->next; sym!=((void *)0); sym=sym->next) {
    if (sym->parent!=((void *)0) || sym->ident!=9)
      continue;
    if (sym->states==((void *)0))
      continue;
    for (srcptr=sym->states->next; srcptr!=((void *)0); srcptr=srcptr->next) {
      if (srcptr->id==-1)
        continue;
      psrc=state_getlist_ptr(srcptr->id);
      ((void) (0));
      for (tgtptr=srcptr->next; tgtptr!=((void *)0); tgtptr=tgtptr->next) {
        if (tgtptr->id==-1)
          continue;
        ptgt=state_getlist_ptr(tgtptr->id);
        ((void) (0));
        if (psrc->fsa!=ptgt->fsa && strcmp(sym->name,"entry")!=0)
          error(83,sym->name);
        if (checkconflict(psrc,ptgt))
          error(84,sym->name);
      }
    }
  }
}

variable_types: struct s_symbol { struct s_symbol *next; struct s_symbol *parent; char name[-1]; unsigned int hash; long addr; long codeaddr; int index; char vclass; char ident; short usage; char flags; int compound; int tag; union { int declared; struct s_constvalue { struct s_constvalue *next; char name[-1]; long value; int index; char usage; } *lib; long stacksize; int enumlist; } x; union { struct s_arginfo { char name[-1]; char ident; char usage; int *tags; int numtags; int dim[3]; struct s_constvalue *dimnames[3]; int numdim; unsigned char hasdefault; union { long val; struct { char *symname; short level; } size; struct { long *data; int size; int arraysize; long addr; } array; } defvalue; int defvalue_tag; } *arglist; struct { long length; short level; struct s_constvalue *names; } array; } dim; struct s_statelist { struct s_statelist *next; int label; long addr; long endaddr; int id; } *states; int fvisible; int fnumber; int lnumber; struct s_symbol **refer; int numrefers; char *documentation; } *


decompiled_code:
__int64 __fastcall state_conflict_id(int a1, int a2)
{
_DWORD *v2; // rax
__int64 v3; // rdx

state_getlist_ptr(a1);
v2 = state_getlist_ptr(a2);
return checkconflict_isra_0(*(_DWORD **)(v3 + 8), *(_DWORD *)(v3 + 16), (__int64)v2);
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1, int a2)
{
_DWORD *v2; // rax
__int64 v3; // rdx

state_getlist_ptr(a1);
v2 = state_getlist_ptr(a2);
return func2(*(_DWORD **)(v3 + 8), *(_DWORD *)(v3 + 16), (__int64)v2);
}

original_code:
int state_conflict_id(int listid1,int listid2)
{
  statepool *psrc,*ptgt;
  psrc=state_getlist_ptr(listid1);
  ((void) (0));
  ptgt=state_getlist_ptr(listid2);
  ((void) (0));
  return checkconflict(psrc,ptgt);
}

canonical_original_code:
int state_conflict_id(int listid1, int listid2)
{
  struct s_statepool *psrc; struct s_statepool *ptgt;
  psrc=state_getlist_ptr(listid1);
  ((void) (0));
  ptgt=state_getlist_ptr(listid2);
  ((void) (0));
  return checkconflict(psrc,ptgt);
}


decompiled_code:
void __fastcall delete_statelisttable(__int64 a1)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
free(v3);
}
while ( v2 );
}
*(_QWORD *)(a1 + 32) = 0LL;
*(_OWORD *)a1 = 0LL;
*(_OWORD *)(a1 + 16) = 0LL;
}

original_code:
void delete_statelisttable(statelist *root)
{
  statelist *cur,*next;
  ((void) (0));
  cur=root->next;
  while (cur!=((void *)0)) {
    next=cur->next;
    free(cur);
    cur=next;
  }
  memset(root,0,sizeof(statelist));
}

canonical_original_code:
void delete_statelisttable(struct s_statelist *root)
{
  struct s_statelist *cur; struct s_statelist *next;
  ((void) (0));
  cur=root->next;
  while (cur!=((void *)0)) {
    next=cur->next;
    free(cur);
    cur=next;
  }
  memset(root,0,sizeof(statelist));
}

variable_types: struct s_statelist { struct s_statelist *next; int label; long addr; long endaddr; int id; } *


decompiled_code:
__int64 sdl_playback_quit()
{
Mix_CloseAudio();
return SDL_Quit();
}

canonical_decompiled_code:
__int64 func1()
{
Mix_CloseAudio();
return SDL_Quit();
}

original_code:
__attribute__((visibility("default"))) void sdl_playback_quit()
{
 Mix_CloseAudio();
 SDL_Quit();
}


decompiled_code:
__int64 sdl_playback_init()
{
__int64 result; // rax
const char *v1; // rax
const char *v2; // rax

if ( (unsigned int)SDL_Init(16LL) == -1 )
{
v1 = (const char *)SDL_GetError();
g_log(0LL, 16LL, "Meg_Audio: %s\n", v1);
}
result = Mix_OpenAudio(44100LL, 32784LL, 2LL, 1024LL);
if ( (_DWORD)result == -1 )
{
v2 = (const char *)SDL_GetError();
result = g_log(0LL, 16LL, "Meg_Audio: %s\n", v2);
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
const char *v1; // rax
const char *v2; // rax

if ( (unsigned int)SDL_Init(16LL) == -1 )
{
v1 = (const char *)SDL_GetError();
g_log(0LL, 16LL, "Meg_Audio: %s\n", v1);
}
result = Mix_OpenAudio(44100LL, 32784LL, 2LL, 1024LL);
if ( (_DWORD)result == -1 )
{
v2 = (const char *)SDL_GetError();
result = g_log(0LL, 16LL, "Meg_Audio: %s\n", v2);
}
return result;
}

original_code:
__attribute__((visibility("default"))) void sdl_playback_init()
{
 if ( SDL_Init( 0x00000010u ) == -1 )
 {
  g_log (((gchar*) 0), G_LOG_LEVEL_WARNING, "Meg_Audio: %s\n", SDL_GetError());
 }
 if ( Mix_OpenAudio( 44100, 0x8010, 2, 1024 ) == -1 )
 {
  g_log (((gchar*) 0), G_LOG_LEVEL_WARNING, "Meg_Audio: %s\n", SDL_GetError());
 }
}

canonical_original_code:
void sdl_playback_init()
{
 if ( SDL_Init( 0x00000010u ) == -1 )
 {
  g_log (((char *) 0), G_LOG_LEVEL_WARNING, "Meg_Audio: %s\n", SDL_GetError());
 }
 if ( Mix_OpenAudio( 44100, 0x8010, 2, 1024 ) == -1 )
 {
  g_log (((char *) 0), G_LOG_LEVEL_WARNING, "Meg_Audio: %s\n", SDL_GetError());
 }
}


decompiled_code:
void __fastcall memfile_destroy(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void memfile_destroy(memfile_t *mf)
{
 ((void) (0));
 free(mf->name);
 free(mf->base);
 free(mf);
}

canonical_original_code:
void memfile_destroy(struct memfile_s *mf)
{
 ((void) (0));
 free(mf->name);
 free(mf->base);
 free(mf);
}

variable_types: struct memfile_s { char *name; char *base; unsigned long offs; unsigned long usedoffs; unsigned long size; } *


decompiled_code:
void __fastcall memfile_seek(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 16) = a2;
}

original_code:
void memfile_seek(memfile_t *mf, long seek)
{
 ((void) (0));
 mf->offs = seek;
}

canonical_original_code:
void memfile_seek(struct memfile_s *mf, long seek)
{
 ((void) (0));
 mf->offs = seek;
}

variable_types: seek long

user_defined_types: struct memfile_s { char *name; char *base; unsigned long offs; unsigned long usedoffs; unsigned long size; }


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

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

original_code:
size_t memfile_tell(const memfile_t *mf)
{
 ((void) (0));
 return mf->offs;
}

canonical_original_code:
unsigned long memfile_tell(struct memfile_s *mf)
{
 ((void) (0));
 return mf->offs;
}


decompiled_code:
size_t __fastcall memfile_read(_QWORD *a1, void *a2, size_t a3)
{
unsigned __int64 v5; // rax
unsigned __int64 v6; // rsi
size_t v8; // rax
size_t v9; // r12

if ( !a3 )
return 0LL;
v5 = a1[3];
v6 = a1[2];
if ( v6 >= v5 )
return 0LL;
v8 = v5 - v6;
if ( v8 <= a3 )
a3 = v8;
v9 = a3;
memcpy(a2, (const void *)(a1[1] + v6), a3);
a1[2] += v9;
return v9;
}

canonical_decompiled_code:
size_t __fastcall func3(_QWORD *a1, void *a2, size_t a3)
{
unsigned __int64 v5; // rax
unsigned __int64 v6; // rsi
size_t v8; // rax
size_t v9; // r12

if ( !a3 )
return 0LL;
v5 = a1[3];
v6 = a1[2];
if ( v6 >= v5 )
return 0LL;
v8 = v5 - v6;
if ( v8 <= a3 )
a3 = v8;
v9 = a3;
memcpy(a2, (const void *)(a1[1] + v6), a3);
a1[2] += v9;
return v9;
}

original_code:
size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize)
{
 ((void) (0));
 ((void) (0));
 if (!maxsize || mf->offs >= mf->usedoffs)
  return 0;
 if (mf->usedoffs - mf->offs < maxsize)
 {
  maxsize = mf->usedoffs - mf->offs;
  if (!maxsize)
   return 0;
 }
 memcpy(buffer, mf->base + mf->offs, maxsize);
 mf->offs += maxsize;
 return maxsize;
}

canonical_original_code:
unsigned long memfile_read(struct memfile_s *mf, void *buffer, unsigned long maxsize)
{
 ((void) (0));
 ((void) (0));
 if (!maxsize || mf->offs >= mf->usedoffs)
  return 0;
 if (mf->usedoffs - mf->offs < maxsize)
 {
  maxsize = mf->usedoffs - mf->offs;
  if (!maxsize)
   return 0;
 }
 memcpy(buffer, mf->base + mf->offs, maxsize);
 mf->offs += maxsize;
 return maxsize;
}

variable_types:
buffer
void *

variable_types:
maxsize
unsigned long


original_code:
int memfile_write(memfile_t *mf, const void *buffer, size_t size)
{
 ((void) (0));
 ((void) (0));
 if (mf->offs + size > mf->size)
 {
   char *orgbase = mf->base;
  size_t newsize = (mf->size + size) * 2;
  mf->base = (char *)realloc(mf->base, newsize);
  if (!mf->base)
  {
    mf->base = orgbase;
   return 0;
  }
  mf->size = newsize;
 }
 memcpy(mf->base + mf->offs, buffer, size);
 mf->offs += size;
 if (mf->offs > mf->usedoffs)
 {
  mf->usedoffs = mf->offs;
 }
 return 1;
}

canonical_original_code:
int memfile_write(struct memfile_s *mf, void *buffer, unsigned long size)
{
 ((void) (0));
 ((void) (0));
 if (mf->offs + size > mf->size)
 {
   char *orgbase = mf->base;
  unsigned long newsize = (mf->size + size) * 2;
  mf->base = (char *)realloc(mf->base, newsize);
  if (!mf->base)
  {
    mf->base = orgbase;
   return 0;
  }
  mf->size = newsize;
 }
 memcpy(mf->base + mf->offs, buffer, size);
 mf->offs += size;
 if (mf->offs > mf->usedoffs)
 {
  mf->usedoffs = mf->offs;
 }
 return 1;
}

variable_types:
size
unsigned long

variable_types:
orgbase
char *

variable_types:
newsize
unsigned long


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

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

original_code:
int pc_printf(const char *message,...)
{
  return 0;
}

canonical_original_code:
int pc_printf(char *message, ...)
{
  return 0;
}

variable_types:
message
char *


decompiled_code:
__int64 pc_error()
{
if ( error_callback )
error_callback();
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
if ( error_callback )
error_callback();
return 0LL;
}

original_code:
int pc_error(int number, char * message, char *filename, int firstline,int lastline, va_list argptr)
{
    if ( error_callback )
        error_callback(number, message, filename,firstline,lastline, argptr );
    return 0;
}

canonical_original_code:
int pc_error(int number, char *message, char *filename, int firstline, int lastline, __builtin_va_list argptr)
{
    if ( error_callback )
        error_callback(number, message, filename,firstline,lastline, argptr );
    return 0;
}

variable_types: number int

variable_types:
filename
char *

variable_types: firstline int

variable_types: lastline int


decompiled_code:
void pc_clearpossrc()
{
srcposalloc = 0;
srcpositions = 0LL;
xmmword_2B0 = 0LL;
xmmword_2C0 = 0LL;
xmmword_2D0 = 0LL;
}

canonical_decompiled_code:
void func5()
{
srcposalloc = 0;
srcpositions = 0LL;
xmmword_2B0 = 0LL;
xmmword_2C0 = 0LL;
xmmword_2D0 = 0LL;
}

original_code:
void pc_clearpossrc(void)
{
  memset(srcpositions,0,sizeof srcpositions);
  memset(srcposalloc,0,sizeof srcposalloc);
}

canonical_original_code:
void pc_clearpossrc()
{
  memset(srcpositions,0,sizeof srcpositions);
  memset(srcposalloc,0,sizeof srcposalloc);
}


decompiled_code:
__int64 __fastcall compiler_main(__int64 a1, __int64 a2, __int64 (*a3)(void))
{
error_callback = a3;
return pc_compile();
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2, __int64 (*a3)(void))
{
error_callback = a3;
return pc_compile();
}

original_code:
int compiler_main( int argc, char *argv[], int (*error_handling)(int number, char * message, char *filename, int firstline, int lastline, va_list argptr) )
{
    error_callback = error_handling;
 return pc_compile(argc, argv);
}

canonical_original_code:
int compiler_main(int argc, char *argv[], int (*error_handling)(int number, char *message, char *filename, int firstline, int lastline, __builtin_va_list argptr))
{
    error_callback = error_handling;
 return pc_compile(argc, argv);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: int (*)(int number, char *message, char *filename, int firstline, int lastline, __builtin_va_list argptr)


strexpand

original_code:
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2])
{
  unsigned char stack[16];
  short c, top = 0;
  int len;
  ((void) (0));
  len = 1;
  for (;;) {
    if (top)
      c = stack[--top];
    else if ((c = *(unsigned char *)source++) == '\0')
      break;
    if (c > 127) {
      ((void) (0));
      stack[top++] = pairtable[c-128][1];
      stack[top++] = pairtable[c-128][0];
    }
    else {
      len++;
      if (maxlen > 1) {
        *dest++ = (char)c;
        maxlen--;
      }
    }
  }
  *dest = '\0';
  return len;
}

canonical_original_code:
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2])
{
  unsigned char stack[16];
  short c; short top = 0;
  int len;
  ((void) (0));
  len = 1;
  for (;;) {
    if (top)
      c = stack[--top];
    else if ((c = *(unsigned char *)source++) == '\0')
      break;
    if (c > 127) {
      ((void) (0));
      stack[top++] = pairtable[c-128][1];
      stack[top++] = pairtable[c-128][0];
    }
    else {
      len++;
      if (maxlen > 1) {
        *dest++ = (char)c;
        maxlen--;
      }
    }
  }
  *dest = '\0';
  return len;
}

variable_types:
dest
char *

variable_types:
source
unsigned char *

variable_types: maxlen int

variable_types:
pairtable
unsigned char [128][2]

variable_types:
stack
unsigned char [16]

variable_types: c short

variable_types: top short

variable_types: len int


original_code:
cell get_utf8_char(const unsigned char *string,const unsigned char **endptr)
{
  int follow=0;
  long lowmark=0;
  cell result=0;
  if (endptr!=((void *)0))
    *endptr=string;
  for ( ;; ) {
    unsigned char ch=*string++;
    if (follow>0 && (ch & 0xc0)==0x80) {
      result=(result << 6) | (ch & 0x3f);
      if (--follow==0) {
        if (result<lowmark)
          return -1;
        if (result>=0xd800 && result<=0xdfff || result==0xfffe || result==0xffff)
          return -1;
        break;
      }
    } else if (follow==0 && (ch & 0x80)==0x80) {
      if ((ch & 0xe0)==0xc0) {
        follow=1;
        lowmark=0x80L;
        result=ch & 0x1f;
      } else if ((ch & 0xf0)==0xe0) {
        follow=2;
        lowmark=0x800L;
        result=ch & 0x0f;
      } else if ((ch & 0xf8)==0xf0) {
        follow=3;
        lowmark=0x10000L;
        result=ch & 0x07;
      } else if ((ch & 0xfc)==0xf8) {
        follow=4;
        lowmark=0x200000L;
        result=ch & 0x03;
      } else if ((ch & 0xfe)==0xfc) {
        follow=5;
        lowmark=0x4000000L;
        result=ch & 0x01;
      } else {
        return -1;
      }
    } else if (follow==0 && (ch & 0x80)==0x00) {
      result=ch;
      break;
    } else {
      return -1;
    }
  }
  if (endptr!=((void *)0))
    *endptr=string;
  return result;
}

canonical_original_code:
long get_utf8_char(unsigned char *string, unsigned char **endptr)
{
  int follow = 0;
  long lowmark = 0;
  long result = 0;
  if (endptr!=((void *)0))
    *endptr=string;
  for ( ;; ) {
    unsigned char ch = *string++;
    if (follow>0 && (ch & 0xc0)==0x80) {
      result=(result << 6) | (ch & 0x3f);
      if (--follow==0) {
        if (result<lowmark)
          return -1;
        if (result>=0xd800 && result<=0xdfff || result==0xfffe || result==0xffff)
          return -1;
        break;
      }
    } else if (follow==0 && (ch & 0x80)==0x80) {
      if ((ch & 0xe0)==0xc0) {
        follow=1;
        lowmark=0x80L;
        result=ch & 0x1f;
      } else if ((ch & 0xf0)==0xe0) {
        follow=2;
        lowmark=0x800L;
        result=ch & 0x0f;
      } else if ((ch & 0xf8)==0xf0) {
        follow=3;
        lowmark=0x10000L;
        result=ch & 0x07;
      } else if ((ch & 0xfc)==0xf8) {
        follow=4;
        lowmark=0x200000L;
        result=ch & 0x03;
      } else if ((ch & 0xfe)==0xfc) {
        follow=5;
        lowmark=0x4000000L;
        result=ch & 0x01;
      } else {
        return -1;
      }
    } else if (follow==0 && (ch & 0x80)==0x00) {
      result=ch;
      break;
    } else {
      return -1;
    }
  }
  if (endptr!=((void *)0))
    *endptr=string;
  return result;
}

variable_types:
string
unsigned char *

variable_types:
endptr
unsigned char **

variable_types: follow int

variable_types: lowmark long

variable_types: result long

variable_types:
ch
unsigned char

return_type: long


main

canonical_decompiled_code:
__int64 __fastcall main(int a1, char **a2, char **a3)
{
if ( a1 <= 1 )
{
g_print();
}
else
{
g_timer_new();
if ( a1 != 2 )
{
qword_404108 = (__int64)a2[3];
if ( a1 != 3 )
{
qword_404100 = (__int64)a2[4];
if ( a1 != 4 )
qword_4040F8 = (__int64)a2[5];
}
}
g_strdup();
if ( func8(a2[1]) )
{
g_timer_elapsed();
g_print();
g_file_set_contents();
}
g_free();
g_string_free();
}
return 0LL;
}

original_code:
int main( int argc, char *argv[] )
{
 int arg_c = 6;
 char * arg_v[7];
 program_directory = g_path_get_dirname(argv[0]);
 arg_v[0] = g_strdup(argv[0]);
 include_directory = get_global_include_path();
 if ( !include_directory )
 {
  include_directory = g_strdup(".");
 }
 main_args(argc, argv);
 if ( !source_filepath )
 {
  g_print("Mokoi Pawn Compiler\n");
  g_print("Headers located at %s\n", get_global_include_path() );
  g_print("No file given\n");
  g_print("\n");
  return 0;
 }
 if ( temporary_filepath )
 {
  filename = temporary_filepath;
 }
 else
 {
  filename = source_filepath;
 }
 output_filename = strip_file_extension( source_filename );
 if ( project_directory )
 {
  if ( g_str_has_prefix( source_filepath, project_directory ) )
  {
   char * dir = source_directory + strlen(project_directory);
   output_directory = g_build_path("/", project_directory, "c", dir, ((void *)0));
  }
  else if (source_directory)
  {
   output_directory = g_build_path("/", project_directory, "c", source_directory, ((void *)0));
  }
  else
  {
   output_directory = g_strdup(project_directory);
  }
 }
 else
 {
  output_directory = g_strdup(source_directory);
 }
 g_mkdir_with_parents( output_directory, 0755 );
 output_filename_64 = g_strdup_printf( "%s.amx64", output_filename );
 output_filename_32 = g_strdup_printf( "%s.amx", output_filename );
 if ( xml_output )
 {
  xml_content = g_string_new("");
  g_string_printf(xml_content, "<results file=\"%s\">\n", source_filename);
 }
 else
 {
  g_print( "Saving to %s %s\n", output_directory, output_filename_32 );
 }
 arg_v[1] = g_strdup( filename );
 arg_v[2] = g_strconcat( "-i", include_directory, ((void *)0) );
 arg_v[3] = g_strconcat( "-i", routines_directory, ((void *)0) );
 if ( routines_global_directory )
 {
  arg_c++;
  arg_v[6] = g_strconcat( "-i", routines_global_directory, ((void *)0) );
 }
 arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_32, ((void *)0) );
 arg_v[5] = g_strdup("-C32");
 compiler_main(arg_c, arg_v, handling_error_code);
 g_free(arg_v[4]);
 g_free(arg_v[5]);
 if ( !fatal_error_count )
 {
  arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_64, ((void *)0) );
  arg_v[5] = g_strdup("-C64");
  compiler_main(arg_c, arg_v, handling_error_code);
  g_free(arg_v[4]);
  g_free(arg_v[5]);
 }
 if ( xml_output )
 {
  xml_content = g_string_append(xml_content, "</results>\n");
  if ( xml_content )
   g_print( "%s", xml_content->str );
  else
   g_print("<error source=\"%s\"/>\n", source_filepath);
 }
 g_free(arg_v[0]);
 g_free(arg_v[1]);
 g_free(arg_v[2]);
 g_free(arg_v[3]);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int arg_c = 6;
 char *arg_v[7];
 program_directory = g_path_get_dirname(argv[0]);
 arg_v[0] = g_strdup(argv[0]);
 include_directory = get_global_include_path();
 if ( !include_directory )
 {
  include_directory = g_strdup(".");
 }
 main_args(argc, argv);
 if ( !source_filepath )
 {
  g_print("Mokoi Pawn Compiler\n");
  g_print("Headers located at %s\n", get_global_include_path() );
  g_print("No file given\n");
  g_print("\n");
  return 0;
 }
 if ( temporary_filepath )
 {
  filename = temporary_filepath;
 }
 else
 {
  filename = source_filepath;
 }
 output_filename = strip_file_extension( source_filename );
 if ( project_directory )
 {
  if ( g_str_has_prefix( source_filepath, project_directory ) )
  {
   char *dir = source_directory + strlen(project_directory);
   output_directory = g_build_path("/", project_directory, "c", dir, ((void *)0));
  }
  else if (source_directory)
  {
   output_directory = g_build_path("/", project_directory, "c", source_directory, ((void *)0));
  }
  else
  {
   output_directory = g_strdup(project_directory);
  }
 }
 else
 {
  output_directory = g_strdup(source_directory);
 }
 g_mkdir_with_parents( output_directory, 0755 );
 output_filename_64 = g_strdup_printf( "%s.amx64", output_filename );
 output_filename_32 = g_strdup_printf( "%s.amx", output_filename );
 if ( xml_output )
 {
  xml_content = g_string_new("");
  g_string_printf(xml_content, "<results file=\"%s\">\n", source_filename);
 }
 else
 {
  g_print( "Saving to %s %s\n", output_directory, output_filename_32 );
 }
 arg_v[1] = g_strdup( filename );
 arg_v[2] = g_strconcat( "-i", include_directory, ((void *)0) );
 arg_v[3] = g_strconcat( "-i", routines_directory, ((void *)0) );
 if ( routines_global_directory )
 {
  arg_c++;
  arg_v[6] = g_strconcat( "-i", routines_global_directory, ((void *)0) );
 }
 arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_32, ((void *)0) );
 arg_v[5] = g_strdup("-C32");
 compiler_main(arg_c, arg_v, handling_error_code);
 g_free(arg_v[4]);
 g_free(arg_v[5]);
 if ( !fatal_error_count )
 {
  arg_v[4] = g_strconcat( "-o", output_directory, "/", output_filename_64, ((void *)0) );
  arg_v[5] = g_strdup("-C64");
  compiler_main(arg_c, arg_v, handling_error_code);
  g_free(arg_v[4]);
  g_free(arg_v[5]);
 }
 if ( xml_output )
 {
  xml_content = g_string_append(xml_content, "</results>\n");
  if ( xml_content )
   g_print( "%s", xml_content->str );
  else
   g_print("<error source=\"%s\"/>\n", source_filepath);
 }
 g_free(arg_v[0]);
 g_free(arg_v[1]);
 g_free(arg_v[2]);
 g_free(arg_v[3]);
 return 0;
}

variable_types: argc int

variable_types:
dir
char *


init

decompiled_code:
void __fastcall init(unsigned int a1, __int64 a2, __int64 a3)
{
signed __int64 v4; // rbp
__int64 i; // rbx

init_proc();
v4 = &off_403D38 - &off_403D30;
if ( v4 )
{
for ( i = 0LL; i != v4; ++i )
((void (__fastcall *)(_QWORD, __int64, __int64))*(&off_403D30 + i))(a1, a2, a3);
}
}

canonical_decompiled_code:
void __fastcall func9(unsigned int a1, __int64 a2, __int64 a3)
{
signed __int64 v4; // rbp
__int64 i; // rbx

init_proc();
v4 = &off_403D38 - &off_403D30;
if ( v4 )
{
for ( i = 0LL; i != v4; ++i )
((void (__fastcall *)(_QWORD, __int64, __int64))*(&off_403D30 + i))(a1, a2, a3);
}
}

original_code:
static cell init(int ident,int usage,int *tag,int *errorfound,int *packcount,cell *packitem)
{
  cell val;
  char *str;
  int tok;
  int curlit=litidx;
  cell i = 0;
  tok=lex(&val,&str);
  if (tok!=330 && tok!=331)
 lexpush();
  if (tok==330 || tok==331) {
 if (ident==1) {
   error(6);
   litidx=curlit+1;
 }
 if (tok==330 && (usage & 0x020)!=0 || tok==331 && (usage & 0x020)==0)
   error(229);
 *tag=0;
  } else if (constexpr(&i,tag,((void *)0))) {
 if (packcount!=((void *)0) && *packcount>=0) {
   ((void) (0));
   ((void) (0));
   if ((ucell)i>=(ucell)(1 << 8))
  error(43,(long)i);
   *packcount+=1;
   *packitem|=(i & 0xff) << ((pc_cellsize-*packcount)*8);
   if (*packcount==pc_cellsize) {
  litadd(*packitem);
  *packitem=0;
  *packcount=0;
   }
 } else {
   litadd(i);
 }
  } else {
 if (errorfound!=((void *)0))
   *errorfound=1;
  }
  return i;
}

canonical_original_code:
static long init(int ident, int usage, int *tag, int *errorfound, int *packcount, long *packitem)
{
  long val;
  char *str;
  int tok;
  int curlit = litidx;
  long i = 0;
  tok=lex(&val,&str);
  if (tok!=330 && tok!=331)
 lexpush();
  if (tok==330 || tok==331) {
 if (ident==1) {
   error(6);
   litidx=curlit+1;
 }
 if (tok==330 && (usage & 0x020)!=0 || tok==331 && (usage & 0x020)==0)
   error(229);
 *tag=0;
  } else if (constexpr(&i,tag,((void *)0))) {
 if (packcount!=((void *)0) && *packcount>=0) {
   ((void) (0));
   ((void) (0));
   if ((unsigned long)i>=(ucell)(1 << 8))
  error(43,(long)i);
   *packcount+=1;
   *packitem|=(i & 0xff) << ((pc_cellsize-*packcount)*8);
   if (*packcount==pc_cellsize) {
  litadd(*packitem);
  *packitem=0;
  *packcount=0;
   }
 } else {
   litadd(i);
 }
  } else {
 if (errorfound!=((void *)0))
   *errorfound=1;
  }
  return i;
}

variable_types: ident int

variable_types: usage int

variable_types:
tag
int *

variable_types:
errorfound
int *

variable_types:
packcount
int *

variable_types:
packitem
long *

variable_types: val long

variable_types:
str
char *

variable_types: tok int

variable_types: curlit int

variable_types: i long


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
const char *v4; // rsi
int v5; // eax
char v6; // r12
const char *v7; // rbp
__int64 v8; // rax
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v12; // rcx
const char **v13; // [rsp+0h] [rbp-28h] BYREF
int v14[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v14[0] = argc;
v13 = argv;
g_set_application_name("Meg", argv, envp);
gtk_init(v14, &v13);
PHYSFS_init(*v13);
Meg_Directory_Set(*v13);
v3 = gtk_settings_get_default();
gtk_settings_set_long_property(v3, "gtk-button-images", 1LL, "main");
v4 = "gtk-menu-images";
gtk_settings_set_long_property(v3, "gtk-menu-images", 1LL, "main");
Meg_Preference_Load();
Meg_Icon_Update();
checkDirectoryValues();
v5 = v14[0];
if ( v14[0] <= 1 )
goto LABEL_11;
v6 = 0;
v7 = 0LL;
LABEL_3:
v8 = v5 - 1;
while ( 1 )
{
v9 = (unsigned int)(v8 + 1);
if ( (int)v9 <= 1 )
break;
v4 = v13[v8];
v14[0] = v8--;
if ( *v4 == 45 )
{
if ( (unsigned int)g_ascii_strcasecmp("--rebuild", v4, v9, v13) )
{
v6 = 2;
}
else
{
v4 = v13[v14[0]];
if ( (unsigned int)g_ascii_strcasecmp("--compile", v4, v14[0], v12) )
v6 = 1;
}
v5 = v14[0];
goto LABEL_3;
}
v7 = v4;
}
if ( !v7 )
goto LABEL_11;
if ( v6 == 1 )
{
g_print("Rebuild Entities\n", v4, v9, v13);
AL_LoadProject(v7);
Entity_RebuildAll();
}
else
{
if ( v6 != 2 )
{
Meg_Loaders_Init(v7, v4, v9, v13);
LABEL_11:
v10 = AL_PrecheckFiles();
if ( v10 )
g_timeout_add(20LL, Meg_Load_Wait, v10);
else
Meg_Main_Init();
gtk_main();
goto LABEL_14;
}
g_print("Compile Game\n", v4, v9, v13);
AL_LoadProject(v7);
MegProject_Compile();
}
LABEL_14:
Funclist_Free();
if ( (unsigned int)PHYSFS_isInit() )
PHYSFS_deinit();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
const char *v4; // rsi
int v5; // eax
char v6; // r12
const char *v7; // rbp
__int64 v8; // rax
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v12; // rcx
const char **v13; // [rsp+0h] [rbp-28h] BYREF
int v14[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v14[0] = argc;
v13 = argv;
g_set_application_name("Meg", argv, envp);
gtk_init(v14, &v13);
PHYSFS_init(*v13);
Meg_Directory_Set(*v13);
v3 = gtk_settings_get_default();
gtk_settings_set_long_property(v3, "gtk-button-images", 1LL, "main");
v4 = "gtk-menu-images";
gtk_settings_set_long_property(v3, "gtk-menu-images", 1LL, "main");
func2();
func3();
func1();
v5 = v14[0];
if ( v14[0] <= 1 )
goto LABEL_11;
v6 = 0;
v7 = 0LL;
LABEL_3:
v8 = v5 - 1;
while ( 1 )
{
v9 = (unsigned int)(v8 + 1);
if ( (int)v9 <= 1 )
break;
v4 = v13[v8];
v14[0] = v8--;
if ( *v4 == 45 )
{
if ( (unsigned int)g_ascii_strcasecmp("--rebuild", v4, v9, v13) )
{
v6 = 2;
}
else
{
v4 = v13[v14[0]];
if ( (unsigned int)g_ascii_strcasecmp("--compile", v4, v14[0], v12) )
v6 = 1;
}
v5 = v14[0];
goto LABEL_3;
}
v7 = v4;
}
if ( !v7 )
goto LABEL_11;
if ( v6 == 1 )
{
g_print("Rebuild Entities\n", v4, v9, v13);
AL_LoadProject(v7);
Entity_RebuildAll();
}
else
{
if ( v6 != 2 )
{
Meg_Loaders_Init(v7, v4, v9, v13);
LABEL_11:
v10 = AL_PrecheckFiles();
if ( v10 )
g_timeout_add(20LL, Meg_Load_Wait, v10);
else
Meg_Main_Init();
gtk_main();
goto LABEL_14;
}
g_print("Compile Game\n", v4, v9, v13);
AL_LoadProject(v7);
MegProject_Compile();
}
LABEL_14:
Funclist_Free();
if ( (unsigned int)PHYSFS_isInit() )
PHYSFS_deinit();
return 0;
}

variable_types:
argv
char *[]


keyUp

repo: luksamuk/opengames

decompiled_code:
__int64 __fastcall keyUp(char a1)
{
if ( a1 == 97 )
{
movLeft = 0;
}
else if ( a1 == 100 )
{
movRight = 0;
}
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func8(char a1)
{
if ( a1 == 97 )
{
movLeft = 0;
}
else if ( a1 == 100 )
{
movRight = 0;
}
return glutPostRedisplay();
}

original_code:
static void keyUp(unsigned char key, int x, int y)
{
    switch(key)
    {
    case 'a':
        movLeft = 0;
        break;
    case 'd':
        movRight = 0;
        break;
    }
    glutPostRedisplay();
}

variable_types:
key
unsigned char

variable_types: x int

variable_types: y int


keyDown

decompiled_code:
__int64 __fastcall keyDown(char a1)
{
if ( a1 == 97 )
{
movLeft = 1;
}
else if ( a1 == 100 )
{
movRight = 1;
}
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func9(char a1)
{
if ( a1 == 97 )
{
movLeft = 1;
}
else if ( a1 == 100 )
{
movRight = 1;
}
return glutPostRedisplay();
}

original_code:
static void keyDown(unsigned char key, int x, int y)
{
    switch(key)
    {
    case 'a':
        movLeft = 1;
        break;
    case 'd':
        movRight = 1;
        break;
    }
    glutPostRedisplay();
}


setpad

decompiled_code:
__int64 setpad()
{
glColor3f();
glBegin();
glVertex2f();
glVertex2f();
glVertex2f();
glVertex2f();
return glEnd();
}

canonical_decompiled_code:
__int64 func10()
{
glColor3f();
glBegin();
glVertex2f();
glVertex2f();
glVertex2f();
glVertex2f();
return glEnd();
}

variable_types: x float


setball

decompiled_code:
__int64 setball()
{
glColor3f();
glBegin();
glVertex2f();
glVertex2f();
glVertex2f();
glVertex2f();
return glEnd();
}

canonical_decompiled_code:
__int64 func11()
{
glColor3f();
glBegin();
glVertex2f();
glVertex2f();
glVertex2f();
glVertex2f();
return glEnd();
}

original_code:
void setball(GLfloat x, GLfloat y)
{
    glColor3f(1.0f, 1.0f, 1.0f);
    glBegin(0x0007);
        glVertex2f(x - 0.025f/2, y - 0.025f);
        glVertex2f(x - 0.025f/2, y);
        glVertex2f(x + 0.025f/2, y);
        glVertex2f(x + 0.025f/2, y - 0.025f);
    glEnd();
}

canonical_original_code:
void setball(float x, float y)
{
    glColor3f(1.0f, 1.0f, 1.0f);
    glBegin(0x0007);
        glVertex2f(x - 0.025f/2, y - 0.025f);
        glVertex2f(x - 0.025f/2, y);
        glVertex2f(x + 0.025f/2, y);
        glVertex2f(x + 0.025f/2, y - 0.025f);
    glEnd();
}

variable_types: y float


display

decompiled_code:
__int64 display()
{
glClear();
setpad(0x4000LL, *(float *)&Xpad);
setball(*(float *)&ball_Xpos, *(float *)&ball_Ypos);
return glutSwapBuffers();
}

canonical_decompiled_code:
__int64 func12()
{
glClear();
func10(0x4000LL, *(float *)&Xpad);
func11(*(float *)&ball_Xpos, *(float *)&ball_Ypos);
return glutSwapBuffers();
}

original_code:
static void display(void)
{
    glClear(0x00004000);
    setpad(Xpad);
    setball(ball_Xpos, ball_Ypos);
    glutSwapBuffers();
}

canonical_original_code:
static void display()
{
    glClear(0x00004000);
    setpad(Xpad);
    setball(ball_Xpos, ball_Ypos);
    glutSwapBuffers();
}