duplicatestring

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

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

canonical_decompiled_code:
char *__fastcall func3(char *src)
{
size_t v1; // rax
char *v2; // rax

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

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 *


repo: lukesalisbury/meg

decompiled_code:
void __fastcall delete_stringtable(__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);
}
while ( v1 );
}
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 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; } *

return_type: void


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 func5(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 *

variable_types:
name
char *

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

return_type: int


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

canonical_decompiled_code:
void func6()
{
func2((__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((__int64)includepaths);
}

canonical_decompiled_code:
void func7()
{
func4((__int64)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)
{
__int64 *v3; // rdi
__int64 result; // rax
__int64 *v5; // rsi

v3 = (__int64 *)substindex[*a1 - 64];
result = 0LL;
if ( v3 )
{
v5 = find_stringpair(v3, a1, a2);
if ( v5 )
{
delete_stringpair((void **)&substpair, (void **)v5);
adjustindex(*a1);
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1, int a2)
{
__int64 *v3; // rdi
__int64 result; // rax
__int64 *v5; // rsi

v3 = (__int64 *)substindex[*a1 - 64];
result = 0LL;
if ( v3 )
{
v5 = find_stringpair(v3, a1, a2);
if ( v5 )
{
func1((void **)&substpair, (void **)v5);
func0(*a1);
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

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

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


decompiled_code:
_QWORD *delete_substtable()
{
_QWORD *result; // rax

delete_stringpairtable((__int64)&substpair);
result = substindex;
do
*result++ = 0LL;
while ( result != &substindex[59] );
return result;
}

canonical_decompiled_code:
_QWORD *func9()
{
_QWORD *result; // rax

func2((__int64)&substpair);
result = substindex;
do
*result++ = 0LL;
while ( result != &substindex[59] );
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((__int64)sourcefiles);
}

canonical_decompiled_code:
void func10()
{
func4((__int64)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((__int64)inputfiles);
}

canonical_decompiled_code:
void func11()
{
func4((__int64)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((__int64)autolist);
}

canonical_decompiled_code:
void func12()
{
func4((__int64)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 func13(_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 func14()
{
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((__int64)dbgstrings);
}

canonical_decompiled_code:
void func15()
{
func4((__int64)dbgstrings);
}

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

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


strlcpy

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
const char *v10; // rsi
__int64 v11; // r12

if ( !ignore_errors )
{
v6 = a3;
if ( !a3 )
return 0LL;
v9 = (const char *)g_strdup_vprintf(a2, a6);
if ( a1 - 1 > 0xC6 )
{
if ( strcmp(source_filepath, v6) || !use_original_filename )
{
LABEL_21:
if ( a1 - 1 > 0x12A )
{
LABEL_22:
g_free(v9);
return 0LL;
}
LABEL_5:
v10 = prefix_0[(int)a1 / 100];
if ( xml_output )
{
if ( a4 < 0 )
v11 = g_markup_printf_escaped(
"<%s file=\"%s\" line=\"%d\" code=\"%d\" message=\"%s\"/>\n",
v10,
v6,
a5,
a1,
v9);
else
v11 = g_markup_printf_escaped(
"<%s file=\"%s\" line=\"%d\" lastline=\"%d\" code=\"%d\" message=\"%s\"/>\n",
v10,
v6,
(unsigned int)a4,
a5,
a1,
v9);
if ( v11 )
xml_content = g_string_append(xml_content, v11);
g_free(v11);
}
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);
g_print("%s", v9);
}
goto LABEL_22;
}
}
else
{
++fatal_error_count;
if ( strcmp(source_filepath, v6) || !use_original_filename )
goto LABEL_5;
}
v6 = (const char *)source_filename;
goto LABEL_21;
}
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
const char *v10; // rsi
__int64 v11; // r12

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

for ( result = (unsigned __int8)*a1; (_BYTE)result; result = (unsigned __int8)*a1 )
{
if ( (_BYTE)result == 47 )
*a1 = 47;
++a1;
}
return result;
}

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

for ( result = (unsigned __int8)*a1; (_BYTE)result; result = (unsigned __int8)*a1 )
{
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()
{
__int64 *v0; // rax
__int64 v1; // r15
__int64 *v2; // r13
__int64 *v3; // rbp
int v4; // ebx
__int64 v5; // rbp
__int64 v6; // r12
__int64 v8; // rbp

v0 = (__int64 *)g_get_system_data_dirs();
v1 = *v0;
if ( !*v0 )
goto LABEL_14;
v2 = v0;
v3 = v0;
v4 = 0;
do
{
if ( (unsigned int)g_str_has_suffix(v1, "share") || (v6 = 0LL, (unsigned int)g_str_has_suffix(*v3, "share/")) )
{
v5 = g_build_path("/", *v3, "mokoi-1.0", "include", 0LL);
v6 = 0LL;
if ( (unsigned int)g_file_test(v5, 4LL) )
v6 = g_strdup(v5);
g_free(v5);
}
v3 = &v2[++v4];
v1 = *v3;
}
while ( !v6 && v1 );
if ( !v6 )
{
v1 = 0LL;
LABEL_14:
v8 = g_build_path("/", program_directory, "..", "share", "mokoi-1.0");
if ( (unsigned int)g_file_test(v8, 4LL) )
v1 = g_strdup(v8);
g_free(v8);
v6 = v1;
}
return v6;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 *v0; // rax
__int64 v1; // r15
__int64 *v2; // r13
__int64 *v3; // rbp
int v4; // ebx
__int64 v5; // rbp
__int64 v6; // r12
__int64 v8; // rbp

v0 = (__int64 *)g_get_system_data_dirs();
v1 = *v0;
if ( !*v0 )
goto LABEL_14;
v2 = v0;
v3 = v0;
v4 = 0;
do
{
if ( (unsigned int)g_str_has_suffix(v1, "share") || (v6 = 0LL, (unsigned int)g_str_has_suffix(*v3, "share/")) )
{
v5 = g_build_path("/", *v3, "mokoi-1.0", "include", 0LL);
v6 = 0LL;
if ( (unsigned int)g_file_test(v5, 4LL) )
v6 = g_strdup(v5);
g_free(v5);
}
v3 = &v2[++v4];
v1 = *v3;
}
while ( !v6 && v1 );
if ( !v6 )
{
v1 = 0LL;
LABEL_14:
v8 = g_build_path("/", program_directory, "..", "share", "mokoi-1.0");
if ( (unsigned int)g_file_test(v8, 4LL) )
v1 = g_strdup(v8);
g_free(v8);
v6 = v1;
}
return v6;
}

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

return_type: char *


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

if ( a1 > 1 )
{
v2 = a2 + 8LL * a1;
v3 = v2 - 8 - 8LL * (unsigned int)(a1 - 2);
do
{
v4 = *(_BYTE **)(v2 - 8);
if ( *v4 == 45 )
{
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);
}
}
else
{
xml_output = 1;
}
}
else
{
source_filepath = (_BYTE *)g_strdup(v4);
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, v5);
if ( (unsigned int)g_str_has_suffix(source_directory, "/maps") )
routines_global_directory = g_build_path("/", source_directory, "..", "routines", 0LL);
}
}
v2 -= 8LL;
}
while ( v2 != v3 );
}
}

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

if ( a1 > 1 )
{
v2 = a2 + 8LL * a1;
v3 = v2 - 8 - 8LL * (unsigned int)(a1 - 2);
do
{
v4 = *(_BYTE **)(v2 - 8);
if ( *v4 == 45 )
{
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);
}
}
else
{
xml_output = 1;
}
}
else
{
source_filepath = (_BYTE *)g_strdup(v4);
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, v5);
if ( (unsigned int)g_str_has_suffix(source_directory, "/maps") )
routines_global_directory = g_build_path("/", source_directory, "..", "routines", 0LL);
}
}
v2 -= 8LL;
}
while ( v2 != v3 );
}
}

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
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func4(int a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( a1 > 1 )
{
v2 = a1;
do
{
result = g_print("%d: %s\n", (unsigned int)(v2 - 1), *(const char **)(a2 + 8 * v2 - 8));
--v2;
}
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
__int64 v4; // rax
const char *v5; // rdx
unsigned int v6; // ebp
const char *v8; // rax
const char *v9; // rbp
size_t v10; // rax
const char **v11; // rax
__int64 v12; // [rsp+0h] [rbp-58h] BYREF
__int64 v13; // [rsp+8h] [rbp-50h]
__int64 v14; // [rsp+10h] [rbp-48h]
__int64 v15; // [rsp+18h] [rbp-40h]
__int64 v16; // [rsp+20h] [rbp-38h]
__int64 v17; // [rsp+28h] [rbp-30h]
__int64 v18; // [rsp+30h] [rbp-28h]

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

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // rax
__int64 v4; // rax
const char *v5; // rdx
unsigned int v6; // ebp
const char *v8; // rax
const char *v9; // rbp
size_t v10; // rax
const char **v11; // rax
__int64 v12; // [rsp+0h] [rbp-58h] BYREF
__int64 v13; // [rsp+8h] [rbp-50h]
__int64 v14; // [rsp+10h] [rbp-48h]
__int64 v15; // [rsp+18h] [rbp-40h]
__int64 v16; // [rsp+20h] [rbp-38h]
__int64 v17; // [rsp+28h] [rbp-30h]
__int64 v18; // [rsp+30h] [rbp-28h]

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

LODWORD(result) = a1;
for ( i = 0; i != 528; ++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 >> i) ^ 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

LODWORD(result) = a1;
for ( i = 0; i != 528; ++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 >> i) ^ 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

LODWORD(result) = a1;
for ( i = 15; i != -513; --i )
result = (a2 >> i) & 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

LODWORD(result) = a1;
for ( i = 15; i != -513; --i )
result = (a2 >> i) & 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; // eax
int v6; // eax
int v7; // er15
int v9; // [rsp+Ch] [rbp-3Ch]

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

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

*a2 = 0;
if ( a3 )
*a3 = 0;
v4 = (const char *)sc_automaton_tab;
if ( sc_automaton_tab )
{
v9 = 0x7FFFFFFF;
do
{
if ( !strcmp(s1, v4 + 8) )
break;
if ( a3 )
{
if ( v4[8] )
{
v6 = levenshtein_distance(s1, v4 + 8);
v7 = v6;
if ( v6 < v9 && v6 <= 2 )
{
strcpy(a3, v4 + 8);
v9 = v7;
}
}
}
v5 = *((_DWORD *)v4 + 12);
if ( v5 > *a2 )
*a2 = v5;
v4 = *(const char **)v4;
}
while ( v4 );
}
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 v8; // 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
{
if ( *((_DWORD *)v6 + 12) == a2 )
{
if ( !strcmp(s1, v6 + 8) )
return v6;
if ( a4 )
{
if ( v6[8] )
{
v8 = levenshtein_distance(s1, v6 + 8);
if ( v8 < v10 )
{
v11 = v8;
if ( v8 <= 2 )
{
strcpy(a4, v6 + 8);
v10 = v11;
}
}
}
}
v7 = *((_QWORD *)v6 + 5);
if ( (int)v7 > *a3 )
*a3 = v7;
}
v6 = *(const char **)v6;
}
while ( v6 );
}
return v6;
}

canonical_decompiled_code:
const char *__fastcall func2(char *s1, int a2, _DWORD *a3, char *a4)
{
const char *v6; // r12
__int64 v7; // rax
int v8; // 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
{
if ( *((_DWORD *)v6 + 12) == a2 )
{
if ( !strcmp(s1, v6 + 8) )
return v6;
if ( a4 )
{
if ( v6[8] )
{
v8 = levenshtein_distance(s1, v6 + 8);
if ( v8 < v10 )
{
v11 = v8;
if ( v8 <= 2 )
{
strcpy(a4, v6 + 8);
v10 = v11;
}
}
}
}
v7 = *((_QWORD *)v6 + 5);
if ( (int)v7 > *a3 )
*a3 = v7;
}
v6 = *(const char **)v6;
}
while ( v6 );
}
return v6;
}

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

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


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 = func2(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 func2(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)
{
_QWORD *v4; // rbx
const char *v6; // rdx
void *v7; // rax
const char *v8; // rdx
int v9[11]; // [rsp+Ch] [rbp-2Ch] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func8(void *src, int a2, int a3)
{
_QWORD *v4; // rbx
const char *v6; // rdx
void *v7; // rax
const char *v8; // rdx
int v9[11]; // [rsp+Ch] [rbp-2Ch] BYREF

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

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()
{
void **v0; // rbx
void **v1; // rbp

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

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

v0 = (void **)statepool_tab;
if ( statepool_tab )
{
do
{
v1 = v0;
v0 = (void **)*v0;
statepool_tab = v0;
free(v1[1]);
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 )
return 0xFFFFFFFFLL;
v1 = state_getlist_ptr(a1);
if ( v1 )
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 )
return 0xFFFFFFFFLL;
v1 = state_getlist_ptr(a1);
if ( v1 )
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; } *

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


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

v2 = state_getlist_ptr(a1);
v3 = state_getlist_ptr(a2);
return checkconflict((__int64)v2, (__int64)v3);
}

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

v2 = state_getlist_ptr(a1);
v3 = state_getlist_ptr(a2);
return func0((__int64)v2, (__int64)v3);
}

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 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 32) = 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)
{
size_t v3; // r12
unsigned __int64 v6; // rsi
unsigned __int64 v7; // rax
size_t v8; // rax

v3 = a3;
if ( a3 )
{
v6 = a1[2];
v7 = a1[3];
v3 = 0LL;
if ( v6 < v7 )
{
v8 = v7 - v6;
if ( v8 <= a3 )
a3 = v8;
v3 = a3;
memcpy(a2, (const void *)(a1[1] + v6), a3);
a1[2] += v3;
}
}
return v3;
}

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

v3 = a3;
if ( a3 )
{
v6 = a1[2];
v7 = a1[3];
v3 = 0LL;
if ( v6 < v7 )
{
v8 = v7 - v6;
if ( v8 <= a3 )
a3 = v8;
v3 = a3;
memcpy(a2, (const void *)(a1[1] + v6), a3);
a1[2] += v3;
}
}
return v3;
}

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


decompiled_code:
void *__fastcall memfile_write(_QWORD *a1, const void *a2, size_t a3)
{
size_t v4; // rax
void *v5; // r14
size_t v6; // r13
void *result; // rax
size_t v8; // rbp

v4 = a1[4];
if ( a1[2] + a3 > v4 )
{
v5 = (void *)a1[1];
v6 = 2 * (a3 + v4);
result = realloc(v5, v6);
a1[1] = result;
if ( !result )
{
a1[1] = v5;
return result;
}
a1[4] = v6;
}
memcpy((void *)(a1[1] + a1[2]), a2, a3);
v8 = a1[2] + a3;
a1[2] = v8;
result = memfile_creat + 1;
if ( v8 > a1[3] )
a1[3] = v8;
return result;
}

canonical_decompiled_code:
void *__fastcall func4(_QWORD *a1, const void *a2, size_t a3)
{
size_t v4; // rax
void *v5; // r14
size_t v6; // r13
void *result; // rax
size_t v8; // rbp

v4 = a1[4];
if ( a1[2] + a3 > v4 )
{
v5 = (void *)a1[1];
v6 = 2 * (a3 + v4);
result = realloc(v5, v6);
a1[1] = result;
if ( !result )
{
a1[1] = v5;
return result;
}
a1[4] = v6;
}
memcpy((void *)(a1[1] + a1[2]), a2, a3);
v8 = a1[2] + a3;
a1[2] = v8;
result = memfile_creat + 1;
if ( v8 > a1[3] )
a1[3] = v8;
return result;
}

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()
{
srcpositions = 0LL;
qword_2E8 = 0LL;
qword_2F0 = 0LL;
qword_2F8 = 0LL;
qword_300 = 0LL;
qword_308 = 0LL;
qword_310 = 0LL;
qword_318 = 0LL;
srcposalloc = 0;
}

canonical_decompiled_code:
void func5()
{
srcpositions = 0LL;
qword_2E8 = 0LL;
qword_2F0 = 0LL;
qword_2F8 = 0LL;
qword_300 = 0LL;
qword_308 = 0LL;
qword_310 = 0LL;
qword_318 = 0LL;
srcposalloc = 0;
}

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

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 ( sub_40142C(a2[1]) )
{
g_timer_elapsed();
g_print();
g_file_set_contents();
}
g_free();
g_string_free();
}
return 0LL;
}

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
char v5; // bl
const char *v6; // rbp
int v7; // eax
__int64 v8; // rax
__int64 v9; // rdx
const char **v11; // [rsp+0h] [rbp-28h] BYREF
int v12[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v12[0] = argc;
v11 = argv;
g_set_application_name("Meg", argv, envp);
gtk_init(v12, &v11);
PHYSFS_init(*v11);
Meg_Directory_Set(*v11);
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 = 0;
v6 = 0LL;
if ( v12[0] <= 1 )
goto LABEL_14;
while ( 1 )
{
v7 = v12[0];
if ( v12[0] <= 1 )
break;
--v12[0];
v8 = v7 - 1;
v4 = v11[v8];
if ( *v4 == 45 )
{
if ( (unsigned int)g_ascii_strcasecmp("--rebuild", v4, v11) )
{
v5 = 2;
}
else
{
v4 = v11[v12[0]];
if ( (unsigned int)g_ascii_strcasecmp("--compile", v4, v12[0]) )
v5 = 1;
}
}
else
{
v6 = v11[v8];
}
}
if ( !v6 )
goto LABEL_14;
if ( v5 == 1 )
{
g_print("Rebuild Entities\n", v4, v11);
AL_LoadProject(v6);
Entity_RebuildAll();
}
else
{
if ( v5 != 2 )
{
Meg_Loaders_Init(v6, v4, v11);
LABEL_14:
v9 = AL_PrecheckFiles();
if ( v9 )
g_timeout_add(20LL, Meg_Load_Wait, v9);
else
Meg_Main_Init();
gtk_main();
goto LABEL_17;
}
g_print("Compile Game\n", v4, v11);
AL_LoadProject(v6);
MegProject_Compile();
}
LABEL_17:
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
char v5; // bl
const char *v6; // rbp
int v7; // eax
__int64 v8; // rax
__int64 v9; // rdx
const char **v11; // [rsp+0h] [rbp-28h] BYREF
int v12[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v12[0] = argc;
v11 = argv;
g_set_application_name("Meg", argv, envp);
gtk_init(v12, &v11);
PHYSFS_init(*v11);
Meg_Directory_Set(*v11);
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 = 0;
v6 = 0LL;
if ( v12[0] <= 1 )
goto LABEL_14;
while ( 1 )
{
v7 = v12[0];
if ( v12[0] <= 1 )
break;
--v12[0];
v8 = v7 - 1;
v4 = v11[v8];
if ( *v4 == 45 )
{
if ( (unsigned int)g_ascii_strcasecmp("--rebuild", v4, v11) )
{
v5 = 2;
}
else
{
v4 = v11[v12[0]];
if ( (unsigned int)g_ascii_strcasecmp("--compile", v4, v12[0]) )
v5 = 1;
}
}
else
{
v6 = v11[v8];
}
}
if ( !v6 )
goto LABEL_14;
if ( v5 == 1 )
{
g_print("Rebuild Entities\n", v4, v11);
AL_LoadProject(v6);
Entity_RebuildAll();
}
else
{
if ( v5 != 2 )
{
Meg_Loaders_Init(v6, v4, v11);
LABEL_14:
v9 = AL_PrecheckFiles();
if ( v9 )
g_timeout_add(20LL, Meg_Load_Wait, v9);
else
Meg_Main_Init();
gtk_main();
goto LABEL_17;
}
g_print("Compile Game\n", v4, v11);
AL_LoadProject(v6);
MegProject_Compile();
}
LABEL_17:
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();
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
glutInit();
glutInitWindowSize();
glutInitWindowPosition();
glutInitDisplayMode();
glutCreateWindow();
glutDisplayFunc();
glutKeyboardFunc();
glutKeyboardUpFunc();
glutIdleFunc();
glClearColor();
glutMainLoop();
return 0;
}

original_code:
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitWindowSize(640,480);
    glutInitWindowPosition(10,10);
    glutInitDisplayMode(0x0000 | 0x0002);
    glutCreateWindow("cbreakout");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyDown);
    glutKeyboardUpFunc(keyUp);
    glutIdleFunc(idle);
    glClearColor(0,0,0,0);
    glutMainLoop();
    return 0;
}

variable_types: argc int

variable_types:
argv
char **


OnReshape

decompiled_code:
void __fastcall OnReshape(int a1, int a2)
{
vwprt_x = a1;
vwprt_y = a2;
}

canonical_decompiled_code:
void __fastcall func7(int a1, int a2)
{
vwprt_x = a1;
vwprt_y = a2;
}

original_code:
void OnReshape(int width, int height)
{
 vwprt_x = width;
 vwprt_y = height;
}

variable_types: width int

variable_types: height int


OnKeyPress

decompiled_code:
void OnKeyPress()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void OnKeyPress(unsigned char key, int x, int y)
{
}


OnMouseClick

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

result = (unsigned __int8)MouseLButton;
oldMouseLButton = MouseLButton;
if ( !a1 )
{
if ( a2 )
{
if ( a2 == 1 )
MouseLButton = 0;
}
else
{
MouseLButton = 1;
}
}
return result;
}

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

result = (unsigned __int8)MouseLButton;
oldMouseLButton = MouseLButton;
if ( !a1 )
{
if ( a2 )
{
if ( a2 == 1 )
MouseLButton = 0;
}
else
{
MouseLButton = 1;
}
}
return result;
}

original_code:
void OnMouseClick(int button, int state, int x, int y)
{
 oldMouseLButton = MouseLButton;
 if(button == 0x0000)
 {
  switch(state)
  {
   case 0x0001:
    MouseLButton = 0;
    break;
   case 0x0000:
    MouseLButton = 1;
    break;
  }
 }
}

variable_types: button int

variable_types: state int


OnMouseMove

decompiled_code:
void __fastcall OnMouseMove(int a1, int a2)
{
*(float *)&mousepressX = (float)((float)a1 / (float)vwprt_x) + (float)((float)a1 / (float)vwprt_x);
*(float *)&mousepressY = (float)((float)a2 / (float)vwprt_y) + (float)((float)a2 / (float)vwprt_y);
}

canonical_decompiled_code:
void __fastcall func10(int a1, int a2)
{
*(float *)&mousepressX = (float)((float)a1 / (float)vwprt_x) + (float)((float)a1 / (float)vwprt_x);
*(float *)&mousepressY = (float)((float)a2 / (float)vwprt_y) + (float)((float)a2 / (float)vwprt_y);
}

original_code:
void OnMouseMove(int x, int y)
{
 mousepressX = (((float)x / (float)vwprt_x) * 2.0f);
 mousepressY = (((float)y / (float)vwprt_y) * 2.0f);
}


renderBitmapString

decompiled_code:
__int64 __fastcall renderBitmapString(char *a1, double a2, float a3)
{
char *v3; // rbx
__int64 result; // rax
char i; // si
float v6; // xmm2_4

v3 = a1;
result = glRasterPos2f();
for ( i = *a1; *v3; i = *v3 )
{
if ( i == 10 )
{
v6 = a3 - 0.045;
a3 = v6;
result = glRasterPos2f();
}
else
{
result = glutBitmapCharacter();
}
++v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(char *a1, double a2, float a3)
{
char *v3; // rbx
__int64 result; // rax
char i; // si
float v6; // xmm2_4

v3 = a1;
result = glRasterPos2f();
for ( i = *a1; *v3; i = *v3 )
{
if ( i == 10 )
{
v6 = a3 - 0.045;
a3 = v6;
result = glRasterPos2f();
}
else
{
result = glutBitmapCharacter();
}
++v3;
}
return result;
}

original_code:
void renderBitmapString(float x, float y, char *string)
{
    glRasterPos2f(x, y);
 char* c;
    for (c = string; *c != '\0'; c++)
    {
        if((*c) == '\n')
        {
            y -= 0.045;
            glRasterPos2f(x, y);
        }
        else glutBitmapCharacter(((void *) &glutBitmapHelvetica18), *c);
    }
}

canonical_original_code:
void renderBitmapString(float x, float y, char *string)
{
    glRasterPos2f(x, y);
 char *c;
    for (c = string; *c != '\0'; c++)
    {
        if((*c) == '\n')
        {
            y -= 0.045;
            glRasterPos2f(x, y);
        }
        else glutBitmapCharacter(((void *) &glutBitmapHelvetica18), *c);
    }
}

variable_types:
string
char *

variable_types:
c
char *


drawTabuleiro

decompiled_code:
__int64 drawTabuleiro()
{
__int64 v0; // rbp
int i; // er12
__int64 j; // rbx
char v3; // al

glColor3f();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glPointSize();
glBegin();
v0 = 0LL;
for ( i = 0; i != 8; ++i )
{
for ( j = 0LL; j != 8; ++j )
{
v3 = tabuleiro[v0 + j];
if ( v3 )
{
if ( v3 == 1 || v3 == 2 )
glColor3f();
glVertex2f();
}
}
v0 += 8LL;
}
return glEnd();
}

canonical_decompiled_code:
__int64 func12()
{
__int64 v0; // rbp
int i; // er12
__int64 j; // rbx
char v3; // al

glColor3f();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glBegin();
glVertex2f();
glVertex2f();
glEnd();
glPointSize();
glBegin();
v0 = 0LL;
for ( i = 0; i != 8; ++i )
{
for ( j = 0LL; j != 8; ++j )
{
v3 = tabuleiro[v0 + j];
if ( v3 )
{
if ( v3 == 1 || v3 == 2 )
glColor3f();
glVertex2f();
}
}
v0 += 8LL;
}
return glEnd();
}

variable_types: i int

variable_types: j int


OnDisplay

decompiled_code:
__int64 OnDisplay()
{
glClear();
drawTabuleiro(0x4000LL);
glColor3f();
renderBitmapString(msg, COERCE_DOUBLE(3212836864LL), 0.89999998);
return glutSwapBuffers();
}

canonical_decompiled_code:
__int64 func13()
{
glClear();
func12(0x4000LL);
glColor3f();
func11(msg, COERCE_DOUBLE(3212836864LL), 0.89999998);
return glutSwapBuffers();
}

original_code:
void OnDisplay()
{
 glClear(0x00004000);
 drawTabuleiro();
 glColor3f(1.0f, 1.0f, 1.0f);
 renderBitmapString(-1.0f, 0.9f, msg);
 glutSwapBuffers();
}