decompiled_code:
__int64 lua_nextvar()
{
unsigned int v0; // ebx
int v1; // edx
__int64 result; // rax
_DWORD *i; // rdx
__int64 v4; // rax
__int64 v5; // rbx

v0 = lua_getparam(1LL);
if ( !v0 )
lua_error("too few arguments to function `nextvar'");
if ( (unsigned int)lua_getparam(2LL) )
lua_error("too many arguments to function `nextvar'");
v1 = lua_type(v0);
result = 0LL;
if ( v1 != -1 )
{
if ( !(unsigned int)lua_isstring(v0) )
return lua_error("incorrect argument to function `nextvar'");
v4 = lua_getstring(v0);
result = (unsigned int)luaI_findsymbolbyname(v4) + 1;
}
if ( (unsigned __int16)result < (unsigned __int16)lua_ntable )
{
for ( i = (_DWORD *)(lua_table + 24LL * (unsigned __int16)result); *i == -1; i += 6 )
{
result = (unsigned int)(result + 1);
if ( (_WORD)result == lua_ntable )
return result;
}
if ( (unsigned __int16)lua_ntable > (unsigned __int16)result )
{
v5 = 24LL * (unsigned __int16)result;
lua_pushstring(*(_QWORD *)(lua_table + v5 + 16) + 20LL);
result = luaI_pushobject(lua_table + v5);
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
unsigned int v0; // ebx
int v1; // edx
__int64 result; // rax
_DWORD *i; // rdx
__int64 v4; // rax
__int64 v5; // rbx

v0 = lua_getparam(1LL);
if ( !v0 )
lua_error("too few arguments to function `nextvar'");
if ( (unsigned int)lua_getparam(2LL) )
lua_error("too many arguments to function `nextvar'");
v1 = lua_type(v0);
result = 0LL;
if ( v1 != -1 )
{
if ( !(unsigned int)lua_isstring(v0) )
return lua_error("incorrect argument to function `nextvar'");
v4 = lua_getstring(v0);
result = (unsigned int)func6(v4) + 1;
}
if ( (unsigned __int16)result < (unsigned __int16)lua_ntable )
{
for ( i = (_DWORD *)(lua_table + 24LL * (unsigned __int16)result); *i == -1; i += 6 )
{
result = (unsigned int)(result + 1);
if ( (_WORD)result == lua_ntable )
return result;
}
if ( (unsigned __int16)lua_ntable > (unsigned __int16)result )
{
v5 = 24LL * (unsigned __int16)result;
lua_pushstring(*(_QWORD *)(lua_table + v5 + 16) + 20LL);
result = luaI_pushobject(lua_table + v5);
}
}
return result;
}

original_code:
static void lua_nextvar (void)
{
 lua_Word next;
 lua_Object o = lua_getparam(1);
 if (o == 0)
   lua_error("too few arguments to function `nextvar'");
 if (lua_getparam(2) != 0)
   lua_error("too many arguments to function `nextvar'");
 if ((lua_type(o)==LUA_T_NIL))
   next = 0;
 else if (!lua_isstring(o))
 {
   lua_error("incorrect argument to function `nextvar'");
   return;
 }
 else
   next = luaI_findsymbolbyname(lua_getstring(o)) + 1;
 while (next < lua_ntable && (((&(lua_table[next].object))->tag)) == LUA_T_NIL) next++;
 if (next < lua_ntable)
 {
  lua_pushstring(lua_table[next].varname->str);
  luaI_pushobject(&(lua_table[next].object));
 }
}

canonical_original_code:
static void lua_nextvar()
{
 unsigned short next;
 unsigned int o = lua_getparam(1);
 if (o == 0)
   lua_error("too few arguments to function `nextvar'");
 if (lua_getparam(2) != 0)
   lua_error("too many arguments to function `nextvar'");
 if ((lua_type(o)==LUA_T_NIL))
   next = 0;
 else if (!lua_isstring(o))
 {
   lua_error("incorrect argument to function `nextvar'");
   return;
 }
 else
   next = luaI_findsymbolbyname(lua_getstring(o)) + 1;
 while (next < lua_ntable && (((&(lua_table[next].object))->tag)) == LUA_T_NIL) next++;
 if (next < lua_ntable)
 {
  lua_pushstring(lua_table[next].varname->str);
  luaI_pushobject(&(lua_table[next].object));
 }
}

variable_types:
next
unsigned short

variable_types:
o
unsigned int


repo: cskau/VM

decompiled_code:
__int64 luaI_findconstantbyname()
{
__int64 v0; // rax

v0 = luaI_createfixedstring();
return luaI_findconstant(v0);
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rax

v0 = func5();
return func4(v0);
}

original_code:
lua_Word luaI_findconstantbyname (char *name)
{
  return luaI_findconstant(luaI_createfixedstring(name));
}

canonical_original_code:
unsigned short luaI_findconstantbyname(char *name)
{
  return luaI_findconstant(luaI_createfixedstring(name));
}

variable_types:
name
char *

return_type: unsigned short


decompiled_code:
__int64 luaI_initconstant()
{
lua_maxconstant = 256LL;
lua_constant = luaI_realloc(0LL, 2048LL);
luaI_findconstantbyname("table overflow");
return luaI_findconstantbyname("not enough memory");
}

canonical_decompiled_code:
__int64 func10()
{
lua_maxconstant = 256LL;
lua_constant = luaI_realloc(0LL, 2048LL);
func9("table overflow");
return func9("not enough memory");
}

original_code:
void luaI_initconstant (void)
{
 lua_maxconstant = 256;
 lua_constant = ((TaggedString * *)luaI_realloc(((void *)0), ((lua_maxconstant)*sizeof(TaggedString *))));
 luaI_findconstantbyname("table overflow");
 luaI_findconstantbyname("not enough memory");
}

canonical_original_code:
void luaI_initconstant()
{
 lua_maxconstant = 256;
 lua_constant = ((struct TaggedString **)luaI_realloc(((void *)0), ((lua_maxconstant)*sizeof(struct TaggedString *))));
 luaI_findconstantbyname("table overflow");
 luaI_findconstantbyname("not enough memory");
}

return_type: void

user_defined_types: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; }


decompiled_code:
__int64 __fastcall luaI_ismarked(int *a1)
{
int v1; // eax

v1 = *a1;
if ( *a1 == -4 )
return (unsigned int)*(char *)(*((_QWORD *)a1 + 1) + 24LL);
if ( v1 == -3 )
return *(unsigned int *)(*((_QWORD *)a1 + 1) + 16LL);
if ( v1 == -5 )
return *(unsigned int *)(*((_QWORD *)a1 + 1) + 8LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(int *a1)
{
int v1; // eax

v1 = *a1;
if ( *a1 == -4 )
return (unsigned int)*(char *)(*((_QWORD *)a1 + 1) + 24LL);
if ( v1 == -3 )
return *(unsigned int *)(*((_QWORD *)a1 + 1) + 16LL);
if ( v1 == -5 )
return *(unsigned int *)(*((_QWORD *)a1 + 1) + 8LL);
return 1LL;
}

original_code:
int luaI_ismarked (Object *o)
{
  switch (o->tag)
  {
   case LUA_T_STRING:
     return o->value.ts->marked;
   case LUA_T_FUNCTION:
    return o->value.tf->marked;
   case LUA_T_ARRAY:
    return o->value.a->mark;
   default:
    return 1;
  }
}

canonical_original_code:
int luaI_ismarked(struct Object *o)
{
  switch (o->tag)
  {
   case LUA_T_STRING:
     return o->value.ts->marked;
   case LUA_T_FUNCTION:
    return o->value.tf->marked;
   case LUA_T_ARRAY:
    return o->value.a->mark;
   default:
    return 1;
  }
}

variable_types: struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash { struct Hash *next; struct node { struct Object ref; struct Object val; } *node; int nhash; int nuse; char mark; } *a; void *u; int i; } value; } *

return_type: int

user_defined_types: struct Object { enum lua_Type tag; union Value value; }

user_defined_types: union Value { void (*f)(); float n; struct TaggedString *ts; struct TFunc *tf; struct Hash *a; void *u; int i; }

user_defined_types: struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar *locvars; }

user_defined_types: struct Hash { struct Hash *next; struct node *node; int nhash; int nuse; char mark; }


decompiled_code:
__int64 luaI_collectgarbage()
{
__int64 v0; // rbx
__int64 v1; // rbx

lua_travstack(lua_markobject);
lua_travsymbol((unsigned int (__fastcall *)(__int64))lua_markobject);
luaI_travlock(lua_markobject);
luaI_travfallbacks(lua_markobject);
luaI_invalidaterefs();
v0 = lua_strcollector();
v1 = lua_hashcollector() + v0;
return v1 + luaI_funccollector();
}

canonical_decompiled_code:
__int64 func12()
{
__int64 v0; // rbx
__int64 v1; // rbx

lua_travstack(lua_markobject);
func0((unsigned int (__fastcall *)(__int64))lua_markobject);
luaI_travlock(lua_markobject);
luaI_travfallbacks(lua_markobject);
luaI_invalidaterefs();
v0 = lua_strcollector();
v1 = lua_hashcollector() + v0;
return v1 + luaI_funccollector();
}

original_code:
lua_Long luaI_collectgarbage (void)
{
  lua_Long recovered = 0;
  lua_travstack(lua_markobject);
  lua_travsymbol(lua_markobject);
  luaI_travlock(lua_markobject);
  luaI_travfallbacks(lua_markobject);
  luaI_invalidaterefs();
  recovered += lua_strcollector();
  recovered += lua_hashcollector();
  recovered += luaI_funccollector();
  return recovered;
}

canonical_original_code:
long luaI_collectgarbage()
{
  long recovered = 0;
  lua_travstack(lua_markobject);
  lua_travsymbol(lua_markobject);
  luaI_travlock(lua_markobject);
  luaI_travfallbacks(lua_markobject);
  luaI_invalidaterefs();
  recovered += lua_strcollector();
  recovered += lua_hashcollector();
  recovered += luaI_funccollector();
  return recovered;
}

variable_types: recovered long

return_type: long


decompiled_code:
unsigned __int64 lua_pack()
{
unsigned __int64 result; // rax
__int64 v1; // rdx

result = nentity_1++;
if ( result >= block_0 )
{
v1 = luaI_collectgarbage();
result = 2 * (block_0 - v1);
block_0 = result;
nentity_1 -= v1;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 func13()
{
unsigned __int64 result; // rax
__int64 v1; // rdx

result = nentity_1++;
if ( result >= block_0 )
{
v1 = func12();
result = 2 * (block_0 - v1);
block_0 = result;
nentity_1 -= v1;
}
return result;
}

original_code:
void lua_pack (void)
{
  static unsigned long block = 50;
  static unsigned long nentity = 0;
  unsigned long recovered = 0;
  if (nentity++ < block) return;
  recovered = luaI_collectgarbage();
  block = 2*(block-recovered);
  nentity -= recovered;
}

canonical_original_code:
void lua_pack()
{
  static unsigned long block = 50;
  static unsigned long nentity = 0;
  unsigned long recovered = 0;
  if (nentity++ < block) return;
  recovered = luaI_collectgarbage();
  block = 2*(block-recovered);
  nentity -= recovered;
}

variable_types:
block
unsigned long

variable_types:
nentity
unsigned long

variable_types:
recovered
unsigned long


decompiled_code:
const char *__fastcall lua_getobjname(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
const char *v3; // rdx
__int64 v5; // rax

functofind = luaI_Address();
v2 = luaI_travfallbacks(checkfunc);
*a2 = v2;
v3 = "fallback";
if ( !v2 )
{
v5 = lua_travsymbol((unsigned int (__fastcall *)(__int64))checkfunc);
*a2 = v5;
v3 = "global";
if ( !v5 )
v3 = (const char *)&unk_5CB;
}
return v3;
}

canonical_decompiled_code:
const char *__fastcall func14(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
const char *v3; // rdx
__int64 v5; // rax

functofind = luaI_Address();
v2 = luaI_travfallbacks(checkfunc);
*a2 = v2;
v3 = "fallback";
if ( !v2 )
{
v5 = func0((unsigned int (__fastcall *)(__int64))checkfunc);
*a2 = v5;
v3 = "global";
if ( !v5 )
v3 = (const char *)&unk_5CB;
}
return v3;
}

original_code:
char *lua_getobjname (lua_Object o, char **name)
{
  functofind = luaI_Address(o);
  if ((*name = luaI_travfallbacks(checkfunc)) != ((void *)0))
    return "fallback";
  else if ((*name = lua_travsymbol(checkfunc)) != ((void *)0))
    return "global";
  else return "";
}

canonical_original_code:
char *lua_getobjname(unsigned int o, char **name)
{
  functofind = luaI_Address(o);
  if ((*name = luaI_travfallbacks(checkfunc)) != ((void *)0))
    return "fallback";
  else if ((*name = lua_travsymbol(checkfunc)) != ((void *)0))
    return "global";
  else return "";
}

variable_types:
name
char **

return_type: char *


original_code:
void luaI_initTFunc (TFunc *f)
{
  f->next = ((void *)0);
  f->marked = 0;
  f->size = 0;
  f->code = ((void *)0);
  f->lineDefined = 0;
  f->fileName = ((void *)0);
  f->locvars = ((void *)0);
}

canonical_original_code:
void luaI_initTFunc(struct TFunc *f)
{
  f->next = ((void *)0);
  f->marked = 0;
  f->size = 0;
  f->code = ((void *)0);
  f->lineDefined = 0;
  f->fileName = ((void *)0);
  f->locvars = ((void *)0);
}

variable_types: struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *varname; int line; } *locvars; } *

user_defined_types: struct LocVar { struct TaggedString *varname; int line; }


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

lua_pack();
result = function_root;
*(_QWORD *)a1 = function_root;
function_root = a1;
*(_DWORD *)(a1 + 8) = 0;
return result;
}

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

lua_pack();
result = function_root;
*(_QWORD *)a1 = function_root;
function_root = a1;
*(_DWORD *)(a1 + 8) = 0;
return result;
}

original_code:
void luaI_insertfunction (TFunc *f)
{
  lua_pack();
  f->next = function_root;
  function_root = f;
  f->marked = 0;
}

canonical_original_code:
void luaI_insertfunction(struct TFunc *f)
{
  lua_pack();
  f->next = function_root;
  function_root = f;
  f->marked = 0;
}


decompiled_code:
__int64 __fastcall luaI_freefunc(__int64 a1)
{
luaI_free(*(_QWORD *)(a1 + 16));
luaI_free(*(_QWORD *)(a1 + 40));
return luaI_free(a1);
}

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

original_code:
void luaI_freefunc (TFunc *f)
{
  luaI_free (f->code);
  luaI_free (f->locvars);
  luaI_free (f);
}

canonical_original_code:
void luaI_freefunc(struct TFunc *f)
{
  luaI_free (f->code);
  luaI_free (f->locvars);
  luaI_free (f);
}


decompiled_code:
__int64 luaI_funccollector()
{
_QWORD *v0; // rbx
__int64 v1; // r12
_QWORD *v2; // rbp
__int64 v3; // rdi

v0 = (_QWORD *)function_root;
if ( !function_root )
return 0LL;
v1 = 0LL;
v2 = 0LL;
do
{
v3 = (__int64)v0;
v0 = (_QWORD *)*v0;
if ( *(_DWORD *)(v3 + 8) )
{
*(_DWORD *)(v3 + 8) = 0;
v2 = (_QWORD *)v3;
}
else
{
if ( v2 )
*v2 = v0;
else
function_root = (__int64)v0;
luaI_freefunc(v3);
++v1;
}
}
while ( v0 );
return v1;
}

canonical_decompiled_code:
__int64 func3()
{
_QWORD *v0; // rbx
__int64 v1; // r12
_QWORD *v2; // rbp
__int64 v3; // rdi

v0 = (_QWORD *)function_root;
if ( !function_root )
return 0LL;
v1 = 0LL;
v2 = 0LL;
do
{
v3 = (__int64)v0;
v0 = (_QWORD *)*v0;
if ( *(_DWORD *)(v3 + 8) )
{
*(_DWORD *)(v3 + 8) = 0;
v2 = (_QWORD *)v3;
}
else
{
if ( v2 )
*v2 = v0;
else
function_root = (__int64)v0;
func2(v3);
++v1;
}
}
while ( v0 );
return v1;
}

original_code:
lua_Long luaI_funccollector (void)
{
  TFunc *curr = function_root;
  TFunc *prev = ((void *)0);
  lua_Long counter = 0;
  while (curr)
  {
    TFunc *next = curr->next;
    if (!curr->marked)
    {
      if (prev == ((void *)0))
        function_root = next;
      else
        prev->next = next;
      luaI_freefunc (curr);
      ++counter;
    }
    else
    {
      curr->marked = 0;
      prev = curr;
    }
    curr = next;
  }
  return counter;
}

canonical_original_code:
long luaI_funccollector()
{
  struct TFunc *curr = function_root;
  struct TFunc *prev = ((void *)0);
  long counter = 0;
  while (curr)
  {
    struct TFunc *next = curr->next;
    if (!curr->marked)
    {
      if (prev == ((void *)0))
        function_root = next;
      else
        prev->next = next;
      luaI_freefunc (curr);
      ++counter;
    }
    else
    {
      curr->marked = 0;
      prev = curr;
    }
    curr = next;
  }
  return counter;
}

variable_types: counter long


decompiled_code:
__int64 __fastcall luaI_registerlocalvar(__int64 a1, int a2)
{
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

if ( numcurrvars >= maxcurrvars )
maxcurrvars = luaI_growvector(&currvars, maxcurrvars, 16LL, &unk_2A4, 65533LL);
v2 = numcurrvars;
v3 = 16LL * numcurrvars;
*(_QWORD *)((char *)currvars + v3) = a1;
*(_DWORD *)((char *)currvars + v3 + 8) = a2;
result = (unsigned int)(v2 + 1);
numcurrvars = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

if ( numcurrvars >= maxcurrvars )
maxcurrvars = luaI_growvector(&currvars, maxcurrvars, 16LL, &unk_2A4, 65533LL);
v2 = numcurrvars;
v3 = 16LL * numcurrvars;
*(_QWORD *)((char *)currvars + v3) = a1;
*(_DWORD *)((char *)currvars + v3 + 8) = a2;
result = (unsigned int)(v2 + 1);
numcurrvars = result;
return result;
}

original_code:
void luaI_registerlocalvar (TaggedString *varname, int line)
{
  if (numcurrvars >= maxcurrvars)
    maxcurrvars = (luaI_growvector((void**)&currvars,maxcurrvars,sizeof(LocVar),"",((0x7fff * 2 + 1)-2)));
  currvars[numcurrvars].varname = varname;
  currvars[numcurrvars].line = line;
  numcurrvars++;
}

canonical_original_code:
void luaI_registerlocalvar(struct TaggedString *varname, int line)
{
  if (numcurrvars >= maxcurrvars)
    maxcurrvars = (luaI_growvector((void **)&currvars,maxcurrvars,sizeof(LocVar),"",((0x7fff * 2 + 1)-2)));
  currvars[numcurrvars].varname = varname;
  currvars[numcurrvars].line = line;
  numcurrvars++;
}

variable_types: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *

variable_types: line int


decompiled_code:
__int64 __fastcall luaI_unregisterlocalvar(int a1)
{
return luaI_registerlocalvar(0LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
return func5(0LL, a1);
}

original_code:
void luaI_unregisterlocalvar (int line)
{
  luaI_registerlocalvar(((void *)0), line);
}

canonical_original_code:
void luaI_unregisterlocalvar(int line)
{
  luaI_registerlocalvar(((void *)0), line);
}


decompiled_code:
__int64 __fastcall luaI_closelocalvars(__int64 a1)
{
void *v1; // rax
size_t v2; // rbx
__int64 result; // rax

v1 = (void *)luaI_realloc(0LL, 16LL * (numcurrvars + 1));
*(_QWORD *)(a1 + 40) = v1;
v2 = 16LL * numcurrvars;
memcpy(v1, currvars, v2);
*(_QWORD *)(*(_QWORD *)(a1 + 40) + v2) = 0LL;
result = *(_QWORD *)(a1 + 40);
*(_DWORD *)(result + v2 + 8) = -1;
numcurrvars = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
void *v1; // rax
size_t v2; // rbx
__int64 result; // rax

v1 = (void *)luaI_realloc(0LL, 16LL * (numcurrvars + 1));
*(_QWORD *)(a1 + 40) = v1;
v2 = 16LL * numcurrvars;
memcpy(v1, currvars, v2);
*(_QWORD *)(*(_QWORD *)(a1 + 40) + v2) = 0LL;
result = *(_QWORD *)(a1 + 40);
*(_DWORD *)(result + v2 + 8) = -1;
numcurrvars = 0;
return result;
}

original_code:
void luaI_closelocalvars (TFunc *func)
{
  func->locvars = ((LocVar *)luaI_realloc(((void *)0), ((numcurrvars+1)*sizeof(LocVar))));
  memcpy (func->locvars, currvars, numcurrvars*sizeof(LocVar));
  func->locvars[numcurrvars].varname = ((void *)0);
  func->locvars[numcurrvars].line = -1;
  numcurrvars = 0;
}

canonical_original_code:
void luaI_closelocalvars(struct TFunc *func)
{
  func->locvars = ((struct LocVar *)luaI_realloc(((void *)0), ((numcurrvars+1)*sizeof(LocVar))));
  memcpy (func->locvars, currvars, numcurrvars*sizeof(LocVar));
  func->locvars[numcurrvars].varname = ((void *)0);
  func->locvars[numcurrvars].line = -1;
  numcurrvars = 0;
}


original_code:
char *luaI_getlocalname (TFunc *func, int local_number, int line)
{
  int count = 0;
  char *varname = ((void *)0);
  LocVar *lv = func->locvars;
  if (lv == ((void *)0))
    return ((void *)0);
  for (; lv->line != -1 && lv->line < line; lv++)
  {
    if (lv->varname)
    {
      if (++count == local_number)
        varname = lv->varname->str;
    }
    else
      if (--count < local_number)
        varname = ((void *)0);
  }
  return varname;
}

canonical_original_code:
char *luaI_getlocalname(struct TFunc *func, int local_number, int line)
{
  int count = 0;
  char *varname = ((void *)0);
  struct LocVar *lv = func->locvars;
  if (lv == ((void *)0))
    return ((void *)0);
  for (; lv->line != -1 && lv->line < line; lv++)
  {
    if (lv->varname)
    {
      if (++count == local_number)
        varname = lv->varname->str;
    }
    else
      if (--count < local_number)
        varname = ((void *)0);
  }
  return varname;
}

variable_types: count int

variable_types:
varname
char *

variable_types: struct LocVar { struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *varname; int line; } *


usage

decompiled_code:
void __noreturn usage()
{
fwrite("usage: luac [-dlpv] [-o output] file ...\n", 1uLL, 0x29uLL, stderr);
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
fwrite("usage: luac [-dlpv] [-o output] file ...\n", 1uLL, 0x29uLL, stderr);
exit(0);
}

original_code:
static void usage(void)
{
 fprintf(stderr,"usage: luac [-dlpv] [-o output] file ...\n");
 exit(0);
}

canonical_original_code:
static void usage()
{
 fprintf(stderr,"usage: luac [-dlpv] [-o output] file ...\n");
 exit(0);
}


decompiled_code:
__int64 __fastcall do_dump(_QWORD *a1)
{
_QWORD *v1; // rbx
__int64 result; // rax
_QWORD *v3; // rbp

v1 = a1;
if ( dumping )
result = DumpHeader(D);
if ( a1 )
{
while ( 1 )
{
if ( listing )
PrintFunction(v1);
if ( dumping )
DumpFunction(v1, D);
v3 = (_QWORD *)*v1;
result = luaI_freefunc(v1);
if ( !v3 )
break;
v1 = v3;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
_QWORD *v1; // rbx
__int64 result; // rax
_QWORD *v3; // rbp

v1 = a1;
if ( dumping )
result = DumpHeader(D);
if ( a1 )
{
while ( 1 )
{
if ( listing )
PrintFunction(v1);
if ( dumping )
DumpFunction(v1, D);
v3 = (_QWORD *)*v1;
result = luaI_freefunc(v1);
if ( !v3 )
break;
v1 = v3;
}
}
return result;
}

original_code:
static void do_dump(TFunc* tf)
{
 if (dumping) DumpHeader(D);
 while (tf!=((void *)0))
 {
  TFunc* nf;
  if (listing) PrintFunction(tf);
  if (dumping) DumpFunction(tf,D);
  nf=tf->next;
  luaI_freefunc(tf);
  tf=nf;
 }
}

canonical_original_code:
static void do_dump(struct TFunc *tf)
{
 if (dumping) DumpHeader(D);
 while (tf!=((void *)0))
 {
  struct TFunc *nf;
  if (listing) PrintFunction(tf);
  if (dumping) DumpFunction(tf,D);
  nf=tf->next;
  luaI_freefunc(tf);
  tf=nf;
 }
}


decompiled_code:
__int64 do_compile()
{
_QWORD *v0; // rbx

v0 = (_QWORD *)luaI_realloc(0LL, 48LL);
luaI_initTFunc(v0);
v0[4] = lua_parsedfile;
lua_parse(v0);
return do_dump(v0);
}

canonical_decompiled_code:
__int64 func2()
{
_QWORD *v0; // rbx

v0 = (_QWORD *)luaI_realloc(0LL, 48LL);
luaI_initTFunc(v0);
v0[4] = lua_parsedfile;
lua_parse(v0);
return func1(v0);
}

original_code:
static void do_compile(void)
{
 TFunc* tf=((TFunc *)luaI_realloc(((void *)0), (sizeof(TFunc))));
 luaI_initTFunc(tf);
 tf->fileName = lua_parsedfile;
 lua_parse(tf);
 do_dump(tf);
}

canonical_original_code:
static void do_compile()
{
 struct TFunc *tf = ((TFunc *)luaI_realloc(((void *)0), (sizeof(TFunc))));
 luaI_initTFunc(tf);
 tf->fileName = lua_parsedfile;
 lua_parse(tf);
 do_dump(tf);
}


compile

decompiled_code:
__int64 __fastcall compile(char *s)
{
if ( !lua_openfile() )
{
fwrite("luac: cannot open ", 1uLL, 0x12uLL, stderr);
perror(s);
exit(1);
}
do_compile();
return lua_closefile();
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s)
{
if ( !lua_openfile() )
{
fwrite("luac: cannot open ", 1uLL, 0x12uLL, stderr);
perror(s);
exit(1);
}
func2();
return lua_closefile();
}

original_code:
static void compile(char* filename)
{
 if (lua_openfile(filename)==((void *)0))
 {
  fprintf(stderr,"luac: cannot open ");
  perror(filename);
  exit(1);
 }
 do_compile();
 lua_closefile();
}

canonical_original_code:
static void compile(char *filename)
{
 if (lua_openfile(filename)==((void *)0))
 {
  fprintf(stderr,"luac: cannot open ");
  perror(filename);
  exit(1);
 }
 do_compile();
 lua_closefile();
}

variable_types:
filename
char *


main

canonical_name: main

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er13
const char **v4; // r12
int v5; // ebx
const char *v6; // rbp
__int64 v7; // rcx
bool v8; // cf
bool v9; // zf
char v10; // dl
bool v11; // cf
bool v12; // zf
__int64 v13; // r8
const char *v14; // rax
bool v15; // cf
bool v16; // zf
__int64 v17; // rcx
char v18; // dl
bool v19; // cf
bool v20; // zf
__int64 v21; // rcx
char v22; // dl
__int64 v23; // rcx
char v24; // dl
bool v25; // cf
bool v26; // zf
__int64 v27; // rcx
char v28; // dl
bool v29; // cf
bool v30; // zf
const char *v31; // rdi
__int64 v32; // rcx
const char *v33; // rsi
int v34; // ebx
int v35; // er13
const char **v36; // rax
const char **v37; // r12
__int64 v38; // r13
const char **v39; // rbx
FILE *v40; // rax
char *v41; // rax

if ( argc <= 1 )
goto LABEL_46;
v3 = argc;
v4 = argv;
v5 = 1;
v6 = "luac.out";
do
{
v13 = v5;
v14 = v4[v13];
v15 = *v14 < 0x2Du;
v16 = *v14 == 45;
if ( *v14 != 45 )
break;
*(_QWORD *)&argc = "-";
v17 = 2LL;
argv = (const char **)v4[v5];
do
{
if ( !v17 )
break;
v15 = *(_BYTE *)argv < **(_BYTE **)&argc;
v16 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v17;
}
while ( v16 );
v18 = (!v15 && !v16) - v15;
v19 = 0;
v20 = v18 == 0;
if ( !v18 )
break;
*(_QWORD *)&argc = "-d";
v21 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v21 )
break;
v19 = *(_BYTE *)argv < **(_BYTE **)&argc;
v20 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v21;
}
while ( v20 );
v22 = (!v19 && !v20) - v19;
v8 = 0;
v9 = v22 == 0;
if ( v22 )
{
*(_QWORD *)&argc = "-l";
v7 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v7 )
break;
v8 = *(_BYTE *)argv < **(_BYTE **)&argc;
v9 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v7;
}
while ( v9 );
v10 = (!v8 && !v9) - v8;
v11 = 0;
v12 = v10 == 0;
if ( v10 )
{
*(_QWORD *)&argc = "-o";
v23 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v23 )
break;
v11 = *(_BYTE *)argv < **(_BYTE **)&argc;
v12 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v23;
}
while ( v12 );
v24 = (!v11 && !v12) - v11;
v25 = 0;
v26 = v24 == 0;
if ( v24 )
{
*(_QWORD *)&argc = "-p";
v27 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v27 )
break;
v25 = *(_BYTE *)argv < **(_BYTE **)&argc;
v26 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v27;
}
while ( v26 );
v28 = (!v25 && !v26) - v25;
v29 = 0;
v30 = v28 == 0;
if ( v28 )
{
v31 = "-v";
v32 = 3LL;
v33 = v4[v5];
do
{
if ( !v32 )
break;
v29 = *v33 < (unsigned int)*v31;
v30 = *v33++ == *v31++;
--v32;
}
while ( v30 );
if ( (!v29 && !v30) != v29 )
usage(v31, v33);
argv = (const char **)"Lua 2.5.1";
*(_QWORD *)&argc = "%s %s\n(written by %s)\n\n";
printf(
"%s %s\n(written by %s)\n\n",
"Lua 2.5.1",
"Copyright (C) 1994-1996 TeCGraf",
"W. Celes, R. Ierusalimschy & L. H. de Figueiredo");
}
else
{
dumping = 0;
}
}
else
{
++v5;
v6 = v4[v13 + 1];
}
}
else
{
listing = 1;
}
}
else
{
lua_debug = 1;
}
++v5;
}
while ( v3 > v5 );
v34 = v5 - 1;
v35 = v3 - v34;
v36 = &v4[v34];
if ( v35 <= 1 )
LABEL_46:
usage(*(_QWORD *)&argc, argv);
v37 = v36 + 1;
v38 = (__int64)&v36[(unsigned int)(v35 - 2) + 2];
v39 = v36 + 1;
do
{
if ( !strcmp(*v39, v6) )
{
fprintf(stderr, "luac: will not overwrite input file \"%s\"\n", v6);
exit(1);
}
++v39;
}
while ( v39 != (const char **)v38 );
v40 = stdout;
if ( dumping )
v40 = fopen(v6, "wb");
D = v40;
if ( !v40 )
{
fwrite("luac: cannot open ", 1uLL, 0x12uLL, stderr);
perror(v6);
exit(1);
}
do
{
v41 = (char *)*v37;
if ( !strcmp(*v37, "-") )
v41 = 0LL;
compile(v41);
++v37;
}
while ( v37 != (const char **)v38 );
fclose(D);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er13
const char **v4; // r12
int v5; // ebx
const char *v6; // rbp
__int64 v7; // rcx
bool v8; // cf
bool v9; // zf
char v10; // dl
bool v11; // cf
bool v12; // zf
__int64 v13; // r8
const char *v14; // rax
bool v15; // cf
bool v16; // zf
__int64 v17; // rcx
char v18; // dl
bool v19; // cf
bool v20; // zf
__int64 v21; // rcx
char v22; // dl
__int64 v23; // rcx
char v24; // dl
bool v25; // cf
bool v26; // zf
__int64 v27; // rcx
char v28; // dl
bool v29; // cf
bool v30; // zf
const char *v31; // rdi
__int64 v32; // rcx
const char *v33; // rsi
int v34; // ebx
int v35; // er13
const char **v36; // rax
const char **v37; // r12
__int64 v38; // r13
const char **v39; // rbx
FILE *v40; // rax
char *v41; // rax

if ( argc <= 1 )
goto LABEL_46;
v3 = argc;
v4 = argv;
v5 = 1;
v6 = "luac.out";
do
{
v13 = v5;
v14 = v4[v13];
v15 = *v14 < 0x2Du;
v16 = *v14 == 45;
if ( *v14 != 45 )
break;
*(_QWORD *)&argc = "-";
v17 = 2LL;
argv = (const char **)v4[v5];
do
{
if ( !v17 )
break;
v15 = *(_BYTE *)argv < **(_BYTE **)&argc;
v16 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v17;
}
while ( v16 );
v18 = (!v15 && !v16) - v15;
v19 = 0;
v20 = v18 == 0;
if ( !v18 )
break;
*(_QWORD *)&argc = "-d";
v21 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v21 )
break;
v19 = *(_BYTE *)argv < **(_BYTE **)&argc;
v20 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v21;
}
while ( v20 );
v22 = (!v19 && !v20) - v19;
v8 = 0;
v9 = v22 == 0;
if ( v22 )
{
*(_QWORD *)&argc = "-l";
v7 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v7 )
break;
v8 = *(_BYTE *)argv < **(_BYTE **)&argc;
v9 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v7;
}
while ( v9 );
v10 = (!v8 && !v9) - v8;
v11 = 0;
v12 = v10 == 0;
if ( v10 )
{
*(_QWORD *)&argc = "-o";
v23 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v23 )
break;
v11 = *(_BYTE *)argv < **(_BYTE **)&argc;
v12 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v23;
}
while ( v12 );
v24 = (!v11 && !v12) - v11;
v25 = 0;
v26 = v24 == 0;
if ( v24 )
{
*(_QWORD *)&argc = "-p";
v27 = 3LL;
argv = (const char **)v4[v5];
do
{
if ( !v27 )
break;
v25 = *(_BYTE *)argv < **(_BYTE **)&argc;
v26 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v27;
}
while ( v26 );
v28 = (!v25 && !v26) - v25;
v29 = 0;
v30 = v28 == 0;
if ( v28 )
{
v31 = "-v";
v32 = 3LL;
v33 = v4[v5];
do
{
if ( !v32 )
break;
v29 = *v33 < (unsigned int)*v31;
v30 = *v33++ == *v31++;
--v32;
}
while ( v30 );
if ( (!v29 && !v30) != v29 )
func0(v31, v33);
argv = (const char **)"Lua 2.5.1";
*(_QWORD *)&argc = "%s %s\n(written by %s)\n\n";
printf(
"%s %s\n(written by %s)\n\n",
"Lua 2.5.1",
"Copyright (C) 1994-1996 TeCGraf",
"W. Celes, R. Ierusalimschy & L. H. de Figueiredo");
}
else
{
dumping = 0;
}
}
else
{
++v5;
v6 = v4[v13 + 1];
}
}
else
{
listing = 1;
}
}
else
{
lua_debug = 1;
}
++v5;
}
while ( v3 > v5 );
v34 = v5 - 1;
v35 = v3 - v34;
v36 = &v4[v34];
if ( v35 <= 1 )
LABEL_46:
func0(*(_QWORD *)&argc, argv);
v37 = v36 + 1;
v38 = (__int64)&v36[(unsigned int)(v35 - 2) + 2];
v39 = v36 + 1;
do
{
if ( !strcmp(*v39, v6) )
{
fprintf(stderr, "luac: will not overwrite input file \"%s\"\n", v6);
exit(1);
}
++v39;
}
while ( v39 != (const char **)v38 );
v40 = stdout;
if ( dumping )
v40 = fopen(v6, "wb");
D = v40;
if ( !v40 )
{
fwrite("luac: cannot open ", 1uLL, 0x12uLL, stderr);
perror(v6);
exit(1);
}
do
{
v41 = (char *)*v37;
if ( !strcmp(*v37, "-") )
v41 = 0LL;
func3(v41);
++v37;
}
while ( v37 != (const char **)v38 );
fclose(D);
return 0;
}

original_code:
int main(int argc, char* argv[])
{
 char* d="luac.out";
 int i;
 for (i=1; i<argc; i++)
 {
  if (argv[i][0]!='-')
   break;
  else if ((strcmp(argv[i],"-")==0))
   break;
  else if ((strcmp(argv[i],"-d")==0))
   lua_debug=1;
  else if ((strcmp(argv[i],"-l")==0))
   listing=1;
  else if ((strcmp(argv[i],"-o")==0))
   d=argv[++i];
  else if ((strcmp(argv[i],"-p")==0))
   dumping=0;
  else if ((strcmp(argv[i],"-v")==0))
   printf("%s  %s\n(written by %s)\n\n","Lua 2.5.1","Copyright (C) 1994-1996 TeCGraf","W. Celes, R. Ierusalimschy & L. H. de Figueiredo");
  else
   usage();
 }
 --i;
 argc-=i;
 argv+=i;
 if (argc<2) usage();
 for (i=1; i<argc; i++)
  if ((strcmp(argv[i],d)==0))
  {
   fprintf(stderr,"luac: will not overwrite input file \"%s\"\n",d);
   exit(1);
  }
 D=(dumping) ? fopen(d,"wb") : stdout;
 if (D==((void *)0))
 {
  fprintf(stderr,"luac: cannot open ");
  perror(d);
  exit(1);
 }
 for (i=1; i<argc; i++) compile((strcmp(argv[i],"-")==0)? ((void *)0) : argv[i]);
 fclose(D);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 char *d = "luac.out";
 int i;
 for (i=1; i<argc; i++)
 {
  if (argv[i][0]!='-')
   break;
  else if ((strcmp(argv[i],"-")==0))
   break;
  else if ((strcmp(argv[i],"-d")==0))
   lua_debug=1;
  else if ((strcmp(argv[i],"-l")==0))
   listing=1;
  else if ((strcmp(argv[i],"-o")==0))
   d=argv[++i];
  else if ((strcmp(argv[i],"-p")==0))
   dumping=0;
  else if ((strcmp(argv[i],"-v")==0))
   printf("%s  %s\n(written by %s)\n\n","Lua 2.5.1","Copyright (C) 1994-1996 TeCGraf","W. Celes, R. Ierusalimschy & L. H. de Figueiredo");
  else
   usage();
 }
 --i;
 argc-=i;
 argv+=i;
 if (argc<2) usage();
 for (i=1; i<argc; i++)
  if ((strcmp(argv[i],d)==0))
  {
   fprintf(stderr,"luac: will not overwrite input file \"%s\"\n",d);
   exit(1);
  }
 D=(dumping) ? fopen(d,"wb") : stdout;
 if (D==((void *)0))
 {
  fprintf(stderr,"luac: cannot open ");
  perror(d);
  exit(1);
 }
 for (i=1; i<argc; i++) compile((strcmp(argv[i],"-")==0)? ((void *)0) : argv[i]);
 fclose(D);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
d
char *

variable_types: i int


hash

decompiled_code:
__int64 __fastcall hash(unsigned __int8 *a1)
{
unsigned __int8 v1; // cl
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
result = 0LL;
do
{
++a1;
result = (31 * result) ^ v1;
v1 = *a1;
}
while ( *a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1)
{
unsigned __int8 v1; // cl
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
result = 0LL;
do
{
++a1;
result = (31 * result) ^ v1;
v1 = *a1;
}
while ( *a1 );
return result;
}

original_code:
static unsigned long hash (char *str)
{
  unsigned long h = 0;
  while (*str)
    h = ((h<<5)-h)^(unsigned char)*(str++);
  return h;
}

canonical_original_code:
static unsigned long hash(char *str)
{
  unsigned long h = 0;
  while (*str)
    h = ((h<<5)-h)^(unsigned char)*(str++);
  return h;
}

variable_types:
str
char *

variable_types:
h
unsigned long

return_type: unsigned long


initialize

decompiled_code:
__int64 initialize()
{
initialized = 1;
luaI_addReserved();
luaI_initsymbol();
return luaI_initconstant();
}

canonical_decompiled_code:
__int64 func1()
{
initialized = 1;
luaI_addReserved();
luaI_initsymbol();
return luaI_initconstant();
}

original_code:
static void initialize (void)
{
  initialized = 1;
  luaI_addReserved();
  luaI_initsymbol();
  luaI_initconstant();
}

canonical_original_code:
static void initialize()
{
  initialized = 1;
  luaI_addReserved();
  luaI_initsymbol();
  luaI_initconstant();
}


grow

original_code:
static void grow (stringtable *tb)
{
  int newsize = luaI_redimension(tb->size);
  TaggedString **newhash = ((TaggedString * *)luaI_realloc(((void *)0), ((newsize)*sizeof(TaggedString *))));
  int i;
  for (i=0; i<newsize; i++)
    newhash[i] = ((void *)0);
  tb->nuse = 0;
  for (i=0; i<tb->size; i++)
    if (tb->hash[i] != ((void *)0) && tb->hash[i] != &EMPTY)
    {
      int h = tb->hash[i]->hash%newsize;
      while (newhash[h])
        h = (h+1)%newsize;
      newhash[h] = tb->hash[i];
      tb->nuse++;
    }
  luaI_free(tb->hash);
  tb->size = newsize;
  tb->hash = newhash;
}

canonical_original_code:
static void grow(struct stringtable *tb)
{
  int newsize = luaI_redimension(tb->size);
  struct TaggedString **newhash = ((TaggedString * *)luaI_realloc(((void *)0), ((newsize)*sizeof(TaggedString *))));
  int i;
  for (i=0; i<newsize; i++)
    newhash[i] = ((void *)0);
  tb->nuse = 0;
  for (i=0; i<tb->size; i++)
    if (tb->hash[i] != ((void *)0) && tb->hash[i] != &EMPTY)
    {
      int h = tb->hash[i]->hash%newsize;
      while (newhash[h])
        h = (h+1)%newsize;
      newhash[h] = tb->hash[i];
      tb->nuse++;
    }
  luaI_free(tb->hash);
  tb->size = newsize;
  tb->hash = newhash;
}

variable_types: struct stringtable { int size; int nuse; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } **hash; } *

variable_types: newsize int

variable_types: h int

user_defined_types: struct stringtable { int size; int nuse; struct TaggedString **hash; }


insert

original_code:
static TaggedString *insert (char *str, stringtable *tb)
{
  TaggedString *ts;
  unsigned long h = hash(str);
  int i;
  int j = -1;
  if ((lua_Long)tb->nuse*3 >= (lua_Long)tb->size*2)
  {
    if (!initialized)
      initialize();
    grow(tb);
  }
  i = h%tb->size;
  while (tb->hash[i])
  {
    if (tb->hash[i] == &EMPTY)
      j = i;
    else if (strcmp(str, tb->hash[i]->str) == 0)
      return tb->hash[i];
    i = (i+1)%tb->size;
  }
  lua_pack();
  if (j != -1)
    i = j;
  else
    tb->nuse++;
  ts = tb->hash[i] = (TaggedString *)luaI_realloc(((void *)0), (sizeof(TaggedString)+strlen(str)));
  strcpy(ts->str, str);
  ts->marked = 0;
  ts->hash = h;
  ts->varindex = ts->constindex = 0xFFFE;
  return ts;
}

canonical_original_code:
static struct TaggedString *insert(char *str, struct stringtable *tb)
{
  struct TaggedString *ts;
  unsigned long h = hash(str);
  int i;
  int j = -1;
  if ((long)tb->nuse*3 >= (long)tb->size*2)
  {
    if (!initialized)
      initialize();
    grow(tb);
  }
  i = h%tb->size;
  while (tb->hash[i])
  {
    if (tb->hash[i] == &EMPTY)
      j = i;
    else if (strcmp(str, tb->hash[i]->str) == 0)
      return tb->hash[i];
    i = (i+1)%tb->size;
  }
  lua_pack();
  if (j != -1)
    i = j;
  else
    tb->nuse++;
  ts = tb->hash[i] = (struct TaggedString *)luaI_realloc(((void *)0), (sizeof(TaggedString)+strlen(str)));
  strcpy(ts->str, str);
  ts->marked = 0;
  ts->hash = h;
  ts->varindex = ts->constindex = 0xFFFE;
  return ts;
}

variable_types: struct stringtable { int size; int nuse; struct TaggedString **hash; } *

variable_types: j int

return_type: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *


decompiled_code:
__int64 __fastcall lua_createstring(char *a1)
{
return insert(a1, &string_root[4 * (*a1 & 0x3F)]);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
return func3(a1, &string_root[4 * (*a1 & 0x3F)]);
}

original_code:
TaggedString *lua_createstring (char *str)
{
  return insert(str, &string_root[(unsigned)str[0]%64]);
}

canonical_original_code:
struct TaggedString *lua_createstring(char *str)
{
  return insert(str, &string_root[(unsigned int)str[0]%64]);
}


original_code:
lua_Long lua_strcollector (void)
{
  lua_Long counter = 0;
  int i;
  for (i=0; i<64; i++)
  {
    stringtable *tb = &string_root[i];
    int j;
    for (j=0; j<tb->size; j++)
    {
      TaggedString *t = tb->hash[j];
      if (t != ((void *)0) && t->marked <= 1)
      {
        if (t->marked)
          t->marked = 0;
        else
        {
          luaI_free(t);
          tb->hash[j] = &EMPTY;
          counter++;
        }
      }
    }
  }
  return counter;
}

canonical_original_code:
long lua_strcollector()
{
  long counter = 0;
  int i;
  for (i=0; i<64; i++)
  {
    struct stringtable *tb = &string_root[i];
    int j;
    for (j=0; j<tb->size; j++)
    {
      struct TaggedString *t = tb->hash[j];
      if (t != ((void *)0) && t->marked <= 1)
      {
        if (t->marked)
          t->marked = 0;
        else
        {
          luaI_free(t);
          tb->hash[j] = &EMPTY;
          counter++;
        }
      }
    }
  }
  return counter;
}

variable_types: counter long

variable_types: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *


hashindex

decompiled_code:
__int64 __fastcall hashindex(__int64 a1, _DWORD *a2)
{
__int64 v2; // rax

if ( *a2 < 0xFFFFFFFA )
{
v2 = (unsigned int)a2[2];
}
else
{
switch ( *a2 )
{
case 0xFFFFFFFA:
v2 = (unsigned int)a2[2];
break;
case 0xFFFFFFFB:
v2 = (unsigned int)a2[2];
break;
case 0xFFFFFFFC:
v2 = (unsigned int)a2[2];
break;
case 0xFFFFFFFD:
v2 = *(_QWORD *)(*((_QWORD *)a2 + 1) + 8LL);
break;
case 0xFFFFFFFE:
goto LABEL_4;
case 0xFFFFFFFF:
lua_error("unexpected type to index table");
LABEL_4:
v2 = (unsigned int)(int)*((float *)a2 + 2);
break;
}
}
return (unsigned int)((__int64)abs64(v2) % *(int *)(a1 + 16));
}

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

if ( *a2 < 0xFFFFFFFA )
{
v2 = (unsigned int)a2[2];
}
else
{
switch ( *a2 )
{
case 0xFFFFFFFA:
v2 = (unsigned int)a2[2];
break;
case 0xFFFFFFFB:
v2 = (unsigned int)a2[2];
break;
case 0xFFFFFFFC:
v2 = (unsigned int)a2[2];
break;
case 0xFFFFFFFD:
v2 = *(_QWORD *)(*((_QWORD *)a2 + 1) + 8LL);
break;
case 0xFFFFFFFE:
goto LABEL_4;
case 0xFFFFFFFF:
lua_error("unexpected type to index table");
LABEL_4:
v2 = (unsigned int)(int)*((float *)a2 + 2);
break;
}
}
return (unsigned int)((__int64)abs64(v2) % *(int *)(a1 + 16));
}

original_code:
static int hashindex (Hash *t, Object *ref)
{
  long int h;
  switch (((ref)->tag)) {
    case LUA_T_NIL:
      lua_error ("unexpected type to index table");
      h = 0;
    case LUA_T_NUMBER:
      h = (long int)((ref)->value.n); break;
    case LUA_T_STRING:
      h = ((ref)->value.ts)->hash; break;
    case LUA_T_FUNCTION:
      h = (IntPoint)ref->value.tf; break;
    case LUA_T_CFUNCTION:
      h = (IntPoint)((ref)->value.f); break;
    case LUA_T_ARRAY:
      h = (IntPoint)((ref)->value.a); break;
    default:
      h = (IntPoint)((ref)->value.u); break;
  }
  if (h < 0) h = -h;
  return h%((t)->nhash);
}

canonical_original_code:
static int hashindex(struct Hash *t, struct Object *ref)
{
  long h;
  switch (((ref)->tag)) {
    case LUA_T_NIL:
      lua_error ("unexpected type to index table");
      h = 0;
    case LUA_T_NUMBER:
      h = (long)((ref)->value.n); break;
    case LUA_T_STRING:
      h = ((ref)->value.ts)->hash; break;
    case LUA_T_FUNCTION:
      h = (unsigned int)ref->value.tf; break;
    case LUA_T_CFUNCTION:
      h = (IntPoint)((ref)->value.f); break;
    case LUA_T_ARRAY:
      h = (IntPoint)((ref)->value.a); break;
    default:
      h = (IntPoint)((ref)->value.u); break;
  }
  if (h < 0) h = -h;
  return h%((t)->nhash);
}

variable_types: struct Hash { struct Hash *next; struct node { struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash *a; void *u; int i; } value; } ref; struct Object val; } *node; int nhash; int nuse; char mark; } *

variable_types:
ref
struct Object *

variable_types: h long

user_defined_types: struct node { struct Object ref; struct Object val; }


decompiled_code:
__int64 call_fallbacks()
{
__int64 i; // rbx
int v2; // [rsp+0h] [rbp-18h] BYREF
__int64 v3; // [rsp+8h] [rbp-10h]

v2 = -4;
for ( i = listhead; i; i = *(_QWORD *)i )
{
if ( *(_BYTE *)(i + 24) != 1 )
{
v3 = i;
luaI_gcFB(&v2);
}
}
v2 = -1;
return luaI_gcFB(&v2);
}

original_code:
static void call_fallbacks (void)
{
  Hash *curr_array;
  Object t;
  ((&t)->tag) = LUA_T_ARRAY;
  for (curr_array = listhead; curr_array; curr_array = curr_array->next)
    if (((curr_array)->mark) != 1)
    {
      ((&t)->value.a) = curr_array;
      luaI_gcFB(&t);
    }
  ((&t)->tag) = LUA_T_NIL;
  luaI_gcFB(&t);
}

canonical_original_code:
static void call_fallbacks()
{
  struct Hash *curr_array;
  struct Object t;
  ((&t)->tag) = LUA_T_ARRAY;
  for (curr_array = listhead; curr_array; curr_array = curr_array->next)
    if (((curr_array)->mark) != 1)
    {
      ((&t)->value.a) = curr_array;
      luaI_gcFB(&t);
    }
  ((&t)->tag) = LUA_T_NIL;
  luaI_gcFB(&t);
}

variable_types: struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash { struct Hash *next; struct node { struct Object ref; struct Object val; } *node; int nhash; int nuse; char mark; } *a; void *u; int i; } value; }


hashdelete

decompiled_code:
__int64 __fastcall hashdelete(__int64 a1)
{
luaI_free(*(_QWORD *)(a1 + 8));
return luaI_free(a1);
}

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

original_code:
static void hashdelete (Hash *t)
{
 luaI_free (((t)->node));
 luaI_free(t);
}

canonical_original_code:
static void hashdelete(struct Hash *t)
{
 luaI_free (((t)->node));
 luaI_free(t);
}

user_defined_types: enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 }


hashnext

original_code:
static void hashnext (Hash *t, int i)
{
 if (i >= ((t)->nhash))
  return;
 while ((((&((&(t)->node[i]))->ref))->tag) == LUA_T_NIL || (((&((&(t)->node[i]))->val))->tag) == LUA_T_NIL)
 {
  if (++i >= ((t)->nhash))
   return;
 }
 luaI_pushobject((&((&(t)->node[i]))->ref));
 luaI_pushobject((&((&(t)->node[i]))->val));
}

canonical_original_code:
static void hashnext(struct Hash *t, int i)
{
 if (i >= ((t)->nhash))
  return;
 while ((((&((&(t)->node[i]))->ref))->tag) == LUA_T_NIL || (((&((&(t)->node[i]))->val))->tag) == LUA_T_NIL)
 {
  if (++i >= ((t)->nhash))
   return;
 }
 luaI_pushobject((&((&(t)->node[i]))->ref));
 luaI_pushobject((&((&(t)->node[i]))->val));
}


decompiled_code:
__int64 __fastcall luaI_redimension(int a1)
{
_QWORD *v1; // rdx
__int64 result; // rax

v1 = &unk_728;
result = 3LL;
while ( a1 >= result )
{
result = *v1++;
if ( result > 2147483644 )
{
lua_error("table overflow");
return 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
_QWORD *v1; // rdx
__int64 result; // rax

v1 = &unk_728;
result = 3LL;
while ( a1 >= result )
{
result = *v1++;
if ( result > 2147483644 )
{
lua_error("table overflow");
return 0LL;
}
}
return result;
}

original_code:
int luaI_redimension (int nhash)
{
 int i;
 for (i=0; dimensions[i]<(0x7fffffff -2); i++)
 {
  if (dimensions[i] > nhash)
   return dimensions[i];
 }
 lua_error("table overflow");
 return 0;
}

canonical_original_code:
int luaI_redimension(int nhash)
{
 int i;
 for (i=0; dimensions[i]<(0x7fffffff -2); i++)
 {
  if (dimensions[i] > nhash)
   return dimensions[i];
 }
 lua_error("table overflow");
 return 0;
}

variable_types: nhash int


hashcreate

decompiled_code:
__int64 __fastcall hashcreate(int a1)
{
__int64 v1; // rbx
int v2; // ebp

v1 = luaI_realloc(0LL, 32LL);
v2 = luaI_redimension((int)((float)a1 / 0.7));
*(_QWORD *)(v1 + 8) = hashnodecreate(v2);
*(_DWORD *)(v1 + 16) = v2;
*(_DWORD *)(v1 + 20) = 0;
*(_BYTE *)(v1 + 24) = 0;
return v1;
}

original_code:
static Hash *hashcreate (int nhash)
{
 Hash *t = ((Hash *)luaI_realloc(0, (sizeof(Hash))));
 nhash = luaI_redimension((int)((float)nhash/0.70));
 ((t)->node) = hashnodecreate(nhash);
 ((t)->nhash) = nhash;
 ((t)->nuse) = 0;
 ((t)->mark) = 0;
 return t;
}

canonical_original_code:
static struct Hash *hashcreate(int nhash)
{
 struct Hash *t = ((Hash *)luaI_realloc(0, (sizeof(Hash))));
 nhash = luaI_redimension((int)((float)nhash/0.70));
 ((t)->node) = hashnodecreate(nhash);
 ((t)->nhash) = nhash;
 ((t)->nuse) = 0;
 ((t)->mark) = 0;
 return t;
}

return_type: struct Hash { struct Hash *next; struct node { struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash *a; void *u; int i; } value; } ref; struct Object val; } *node; int nhash; int nuse; char mark; } *


decompiled_code:
_BOOL8 __fastcall lua_equalObj(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
_BOOL4 v3; // edx

v2 = *(_DWORD *)a1;
v3 = 0;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 < 0xFFFFFFFA )
{
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
}
else
{
switch ( v2 )
{
case 0xFFFFFFFA:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFB:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFC:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFD:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFE:
v3 = *(float *)(a1 + 8) == *(float *)(a2 + 8);
break;
case 0xFFFFFFFF:
v3 = 1;
break;
}
}
}
return v3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
_BOOL4 v3; // edx

v2 = *(_DWORD *)a1;
v3 = 0;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 < 0xFFFFFFFA )
{
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
}
else
{
switch ( v2 )
{
case 0xFFFFFFFA:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFB:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFC:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFD:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
break;
case 0xFFFFFFFE:
v3 = *(float *)(a1 + 8) == *(float *)(a2 + 8);
break;
case 0xFFFFFFFF:
v3 = 1;
break;
}
}
}
return v3;
}

original_code:
int lua_equalObj (Object *t1, Object *t2)
{
  if (((t1)->tag) != ((t2)->tag)) return 0;
  switch (((t1)->tag))
  {
    case LUA_T_NIL: return 1;
    case LUA_T_NUMBER: return ((t1)->value.n) == ((t2)->value.n);
    case LUA_T_STRING: return ((t1)->value.ts->str) == ((t2)->value.ts->str);
    case LUA_T_ARRAY: return ((t1)->value.a) == ((t2)->value.a);
    case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf;
    case LUA_T_CFUNCTION: return ((t1)->value.f) == ((t2)->value.f);
    default: return ((t1)->value.u) == ((t2)->value.u);
  }
}

canonical_original_code:
int lua_equalObj(struct Object *t1, struct Object *t2)
{
  if (((t1)->tag) != ((t2)->tag)) return 0;
  switch (((t1)->tag))
  {
    case LUA_T_NIL: return 1;
    case LUA_T_NUMBER: return ((t1)->value.n) == ((t2)->value.n);
    case LUA_T_STRING: return ((t1)->value.ts->str) == ((t2)->value.ts->str);
    case LUA_T_ARRAY: return ((t1)->value.a) == ((t2)->value.a);
    case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf;
    case LUA_T_CFUNCTION: return ((t1)->value.f) == ((t2)->value.f);
    default: return ((t1)->value.u) == ((t2)->value.u);
  }
}

variable_types: struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash { struct Hash *next; struct node { struct Object ref; struct Object val; } *node; int nhash; int nuse; char mark; } *a; void *u; int i; } value; } *


present

decompiled_code:
__int64 __fastcall present(__int64 a1, _DWORD *a2)
{
unsigned int v3; // ebx
__int64 v4; // r13
_DWORD *i; // rsi

v3 = hashindex(a1, a2);
v4 = *(_QWORD *)(a1 + 8);
for ( i = (_DWORD *)(v4 + 32LL * (int)v3); *i != -1; i = (_DWORD *)(v4 + 32LL * (int)v3) )
{
if ( lua_equalObj((__int64)a2, (__int64)i) )
break;
v3 = (int)(v3 + 1) % *(_DWORD *)(a1 + 16);
}
return v3;
}

original_code:
static int present (Hash *t, Object *ref)
{
 int h = hashindex(t, ref);
 while ((((&((&(t)->node[h]))->ref))->tag) != LUA_T_NIL)
 {
  if (lua_equalObj(ref, (&((&(t)->node[h]))->ref)))
    return h;
  h = (h+1) % ((t)->nhash);
 }
 return h;
}

canonical_original_code:
static int present(struct Hash *t, struct Object *ref)
{
 int h = hashindex(t, ref);
 while ((((&((&(t)->node[h]))->ref))->tag) != LUA_T_NIL)
 {
  if (lua_equalObj(ref, (&((&(t)->node[h]))->ref)))
    return h;
  h = (h+1) % ((t)->nhash);
 }
 return h;
}


rehash

original_code:
static void rehash (Hash *t)
{
 int i;
 int nold = ((t)->nhash);
 Node *vold = ((t)->node);
 ((t)->nhash) = luaI_redimension(((t)->nhash));
 ((t)->node) = hashnodecreate(((t)->nhash));
 for (i=0; i<nold; i++)
 {
  Node *n = vold+i;
  if ((((&(n)->ref))->tag) != LUA_T_NIL && (((&(n)->val))->tag) != LUA_T_NIL)
   *(&(t)->node[present(t, (&(n)->ref))]) = *n;
 }
 luaI_free(vold);
}

canonical_original_code:
static void rehash(struct Hash *t)
{
 int i;
 int nold = ((t)->nhash);
 struct node *vold = ((t)->node);
 ((t)->nhash) = luaI_redimension(((t)->nhash));
 ((t)->node) = hashnodecreate(((t)->nhash));
 for (i=0; i<nold; i++)
 {
  struct node *n = vold+i;
  if ((((&(n)->ref))->tag) != LUA_T_NIL && (((&(n)->val))->tag) != LUA_T_NIL)
   *(&(t)->node[present(t, (&(n)->ref))]) = *n;
 }
 luaI_free(vold);
}

variable_types: nold int

variable_types: struct node { struct Object { enum lua_Type { LUA_T_NIL=-1, LUA_T_NUMBER=-2, LUA_T_STRING=-3, LUA_T_ARRAY=-4, LUA_T_FUNCTION=-5, LUA_T_CFUNCTION=-6, LUA_T_MARK=-7, LUA_T_CMARK=-8, LUA_T_LINE=-9, LUA_T_USERDATA=0 } tag; union Value { void (*f)(); float n; struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *ts; struct TFunc { struct TFunc *next; int marked; int size; unsigned char *code; int lineDefined; char *fileName; struct LocVar { struct TaggedString *varname; int line; } *locvars; } *tf; struct Hash { struct Hash *next; struct node *node; int nhash; int nuse; char mark; } *a; void *u; int i; } value; } ref; struct Object val; } *


original_code:
void lua_hashmark (Hash *h)
{
 if (((h)->mark) == 0)
 {
  int i;
  ((h)->mark) = 1;
  for (i=0; i<((h)->nhash); i++)
  {
   Node *n = (&(h)->node[i]);
   if ((((&(n)->ref))->tag) != LUA_T_NIL)
   {
    lua_markobject(&n->ref);
    lua_markobject(&n->val);
   }
  }
 }
}

canonical_original_code:
void lua_hashmark(struct Hash *h)
{
 if (((h)->mark) == 0)
 {
  int i;
  ((h)->mark) = 1;
  for (i=0; i<((h)->nhash); i++)
  {
   struct node *n = (&(h)->node[i]);
   if ((((&(n)->ref))->tag) != LUA_T_NIL)
   {
    lua_markobject(&n->ref);
    lua_markobject(&n->val);
   }
  }
 }
}

variable_types: i int


decompiled_code:
__int64 lua_hashcollector()
{
_QWORD *v0; // rbx
__int64 v1; // r12
_QWORD *v2; // rbp
__int64 v3; // rdi

v0 = (_QWORD *)listhead;
call_fallbacks();
if ( !v0 )
return 0LL;
v1 = 0LL;
v2 = 0LL;
do
{
v3 = (__int64)v0;
v0 = (_QWORD *)*v0;
if ( *(_BYTE *)(v3 + 24) == 1 )
{
*(_BYTE *)(v3 + 24) = 0;
v2 = (_QWORD *)v3;
}
else
{
if ( v2 )
*v2 = v0;
else
listhead = (__int64)v0;
hashdelete(v3);
++v1;
}
}
while ( v0 );
return v1;
}

original_code:
lua_Long lua_hashcollector (void)
{
 Hash *curr_array = listhead, *prev = 0;
 lua_Long counter = 0;
 call_fallbacks();
 while (curr_array != 0)
 {
  Hash *next = curr_array->next;
  if (((curr_array)->mark) != 1)
  {
   if (prev == 0) listhead = next;
   else prev->next = next;
   hashdelete(curr_array);
   ++counter;
  }
  else
  {
   ((curr_array)->mark) = 0;
   prev = curr_array;
  }
  curr_array = next;
 }
 return counter;
}

canonical_original_code:
long lua_hashcollector()
{
 struct Hash *curr_array = listhead; struct Hash *prev = 0;
 long counter = 0;
 call_fallbacks();
 while (curr_array != 0)
 {
  struct Hash *next = curr_array->next;
  if (((curr_array)->mark) != 1)
  {
   if (prev == 0) listhead = next;
   else prev->next = next;
   hashdelete(curr_array);
   ++counter;
  }
  else
  {
   ((curr_array)->mark) = 0;
   prev = curr_array;
  }
  curr_array = next;
 }
 return counter;
}


decompiled_code:
void lua_next()
{
unsigned int v0; // ebx
unsigned int v1; // eax
unsigned int v2; // ebp
__int64 v3; // rbx
_DWORD *v4; // rax
int v5; // eax

v0 = lua_getparam(1LL);
v1 = lua_getparam(2LL);
v2 = v1;
if ( !v0 || !v1 )
lua_error("too few arguments to function `next'");
if ( (unsigned int)lua_getparam(3LL) )
lua_error("too many arguments to function `next'");
if ( (unsigned int)lua_type(v0) != -4 )
lua_error("first argument of function `next' is not a table");
v3 = *(_QWORD *)(luaI_Address(v0) + 8);
if ( (unsigned int)lua_type(v2) == -1 )
{
hashnext(v3, 0);
}
else
{
v4 = (_DWORD *)luaI_Address(v2);
v5 = present(v3, v4);
hashnext(v3, v5 + 1);
}
}

canonical_decompiled_code:
void func11()
{
unsigned int v0; // ebx
unsigned int v1; // eax
unsigned int v2; // ebp
__int64 v3; // rbx
_DWORD *v4; // rax
int v5; // eax

v0 = lua_getparam(1LL);
v1 = lua_getparam(2LL);
v2 = v1;
if ( !v0 || !v1 )
lua_error("too few arguments to function `next'");
if ( (unsigned int)lua_getparam(3LL) )
lua_error("too many arguments to function `next'");
if ( (unsigned int)lua_type(v0) != -4 )
lua_error("first argument of function `next' is not a table");
v3 = *(_QWORD *)(luaI_Address(v0) + 8);
if ( (unsigned int)lua_type(v2) == -1 )
{
func3(v3, 0);
}
else
{
v4 = (_DWORD *)luaI_Address(v2);
v5 = func7(v3, v4);
func3(v3, v5 + 1);
}
}

original_code:
void lua_next (void)
{
 Hash *t;
 lua_Object o = lua_getparam(1);
 lua_Object r = lua_getparam(2);
 if (o == 0 || r == 0)
   lua_error ("too few arguments to function `next'");
 if (lua_getparam(3) != 0)
   lua_error ("too many arguments to function `next'");
 if (!(lua_type(o)==LUA_T_ARRAY))
   lua_error ("first argument of function `next' is not a table");
 t = ((luaI_Address(o))->value.a);
 if ((lua_type(r)==LUA_T_NIL))
 {
  hashnext(t, 0);
 }
 else
 {
  int h = present (t, luaI_Address(r));
  hashnext(t, h+1);
 }
}

canonical_original_code:
void lua_next()
{
 struct Hash *t;
 unsigned int o = lua_getparam(1);
 unsigned int r = lua_getparam(2);
 if (o == 0 || r == 0)
   lua_error ("too few arguments to function `next'");
 if (lua_getparam(3) != 0)
   lua_error ("too many arguments to function `next'");
 if (!(lua_type(o)==LUA_T_ARRAY))
   lua_error ("first argument of function `next' is not a table");
 t = ((luaI_Address(o))->value.a);
 if ((lua_type(r)==LUA_T_NIL))
 {
  hashnext(t, 0);
 }
 else
 {
  int h = present (t, luaI_Address(r));
  hashnext(t, h+1);
 }
}

variable_types:
o
unsigned int

variable_types:
r
unsigned int


decompiled_code:
__int64 math_pow()
{
unsigned int v0; // ebx
unsigned int v1; // ebp
unsigned int v2; // er12
unsigned int v3; // er13
__int64 result; // rax
float v5; // xmm1_4
float v6; // xmm0_4
float v7; // [rsp+Ch] [rbp-2Ch]

v0 = lua_getparam(1LL);
v1 = lua_getparam(2LL);
v2 = lua_getparam(3LL);
if ( (unsigned int)lua_isnumber(v0) && (unsigned int)lua_isnumber(v1) && *(_BYTE *)lua_getstring(v2) == 112 )
{
v7 = lua_getnumber(v0);
v5 = lua_getnumber(v1);
v6 = pow(v7, v5);
result = lua_pushnumber(v6);
}
else
{
v3 = lua_getref((unsigned int)old_pow);
lua_pushobject(v0);
lua_pushobject(v1);
lua_pushobject(v2);
result = lua_callfunction(v3);
if ( (_DWORD)result )
result = lua_error(0LL);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // ebx
unsigned int v1; // ebp
unsigned int v2; // er12
unsigned int v3; // er13
__int64 result; // rax
float v5; // xmm1_4
float v6; // xmm0_4
float v7; // [rsp+Ch] [rbp-2Ch]

v0 = lua_getparam(1LL);
v1 = lua_getparam(2LL);
v2 = lua_getparam(3LL);
if ( (unsigned int)lua_isnumber(v0) && (unsigned int)lua_isnumber(v1) && *(_BYTE *)lua_getstring(v2) == 112 )
{
v7 = lua_getnumber(v0);
v5 = lua_getnumber(v1);
v6 = pow(v7, v5);
result = lua_pushnumber(v6);
}
else
{
v3 = lua_getref((unsigned int)old_pow);
lua_pushobject(v0);
lua_pushobject(v1);
lua_pushobject(v2);
result = lua_callfunction(v3);
if ( (_DWORD)result )
result = lua_error(0LL);
}
return result;
}

original_code:
static void math_pow (void)
{
 lua_Object o1 = lua_getparam (1);
 lua_Object o2 = lua_getparam (2);
 lua_Object op = lua_getparam(3);
 if (!lua_isnumber(o1) || !lua_isnumber(o2) || *(lua_getstring(op)) != 'p')
 {
   lua_Object old = lua_getref(old_pow);
   lua_pushobject(o1);
   lua_pushobject(o2);
   lua_pushobject(op);
   if (lua_callfunction(old) != 0)
     lua_error(((void *)0));
 }
 else
 {
   double d1 = lua_getnumber(o1);
   double d2 = lua_getnumber(o2);
   lua_pushnumber (pow(d1,d2));
 }
}

canonical_original_code:
static void math_pow()
{
 unsigned int o1 = lua_getparam (1);
 unsigned int o2 = lua_getparam (2);
 unsigned int op = lua_getparam(3);
 if (!lua_isnumber(o1) || !lua_isnumber(o2) || *(lua_getstring(op)) != 'p')
 {
   unsigned int old = lua_getref(old_pow);
   lua_pushobject(o1);
   lua_pushobject(o2);
   lua_pushobject(op);
   if (lua_callfunction(old) != 0)
     lua_error(((void *)0));
 }
 else
 {
   double d1 = lua_getnumber(o1);
   double d2 = lua_getnumber(o2);
   lua_pushnumber (pow(d1,d2));
 }
}

variable_types:
op
unsigned int

variable_types:
old
unsigned int


decompiled_code:
__int64 math_rad()
{
float v0; // xmm0_4
float v1; // xmm0_4

v0 = lua_check_number(1LL, &unk_7BC);
v1 = v0 / 180.0 * 3.141592653589793;
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func1()
{
float v0; // xmm0_4
float v1; // xmm0_4

v0 = lua_check_number(1LL, &unk_7BC);
v1 = v0 / 180.0 * 3.141592653589793;
return lua_pushnumber(v1);
}

original_code:
static void math_rad (void)
{
 float d = lua_check_number(1, "rad");
 lua_pushnumber (d/180.*3.14159265358979323846);
}

canonical_original_code:
static void math_rad()
{
 float d = lua_check_number(1, "rad");
 lua_pushnumber (d/180.*3.14159265358979323846);
}

variable_types: d float


decompiled_code:
__int64 math_deg()
{
float v0; // xmm0_4
float v1; // xmm0_4

v0 = lua_check_number(1LL, &unk_7C0);
v1 = v0 * 180.0 / 3.141592653589793;
return lua_pushnumber(v1);
}

original_code:
static void math_deg (void)
{
 float d = lua_check_number(1, "deg");
 lua_pushnumber (d*180./3.14159265358979323846);
}

canonical_original_code:
static void math_deg()
{
 float d = lua_check_number(1, "deg");
 lua_pushnumber (d*180./3.14159265358979323846);
}


decompiled_code:
__int64 math_max()
{
unsigned int i; // ebx
float v1; // xmm0_4
double v3; // [rsp+8h] [rbp-10h]

v3 = lua_check_number(1LL, &unk_7C4);
for ( i = 1; (unsigned int)lua_getparam(++i); v3 = fmax(lua_check_number(i, &unk_7C4), v3) )
;
v1 = v3;
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func3()
{
unsigned int i; // ebx
float v1; // xmm0_4
double v3; // [rsp+8h] [rbp-10h]

v3 = lua_check_number(1LL, &unk_7C4);
for ( i = 1; (unsigned int)lua_getparam(++i); v3 = fmax(lua_check_number(i, &unk_7C4), v3) )
;
v1 = v3;
return lua_pushnumber(v1);
}

original_code:
static void math_max (void)
{
 int i=1;
 double dmax = lua_check_number(i, "max");
 while (lua_getparam(++i) != 0)
 {
  double d = lua_check_number(i, "max");
  if (d > dmax) dmax = d;
 }
 lua_pushnumber (dmax);
}

canonical_original_code:
static void math_max()
{
 int i = 1;
 double dmax = lua_check_number(i, "max");
 while (lua_getparam(++i) != 0)
 {
  double d = lua_check_number(i, "max");
  if (d > dmax) dmax = d;
 }
 lua_pushnumber (dmax);
}

variable_types: dmax double

variable_types: d double


decompiled_code:
__int64 math_min()
{
unsigned int i; // ebx
float v1; // xmm0_4
double v3; // [rsp+8h] [rbp-10h]

v3 = lua_check_number(1LL, &unk_7C8);
for ( i = 1; (unsigned int)lua_getparam(++i); v3 = fmin(lua_check_number(i, &unk_7C8), v3) )
;
v1 = v3;
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int i; // ebx
float v1; // xmm0_4
double v3; // [rsp+8h] [rbp-10h]

v3 = lua_check_number(1LL, &unk_7C8);
for ( i = 1; (unsigned int)lua_getparam(++i); v3 = fmin(lua_check_number(i, &unk_7C8), v3) )
;
v1 = v3;
return lua_pushnumber(v1);
}

original_code:
static void math_min (void)
{
 int i=1;
 double dmin = lua_check_number(i, "min");
 while (lua_getparam(++i) != 0)
 {
  double d = lua_check_number(i, "min");
  if (d < dmin) dmin = d;
 }
 lua_pushnumber (dmin);
}

canonical_original_code:
static void math_min()
{
 int i = 1;
 double dmin = lua_check_number(i, "min");
 while (lua_getparam(++i) != 0)
 {
  double d = lua_check_number(i, "min");
  if (d < dmin) dmin = d;
 }
 lua_pushnumber (dmin);
}

variable_types: dmin double


decompiled_code:
__int64 math_abs()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, &unk_7CC);
if ( v0 < 0.0 )
*(_QWORD *)&v0 ^= LC8;
v1 = v0;
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func5()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, &unk_7CC);
if ( v0 < 0.0 )
*(_QWORD *)&v0 ^= LC8;
v1 = v0;
return lua_pushnumber(v1);
}

original_code:
static void math_abs (void)
{
 double d = lua_check_number(1, "abs");
 if (d < 0) d = -d;
 lua_pushnumber (d);
}

canonical_original_code:
static void math_abs()
{
 double d = lua_check_number(1, "abs");
 if (d < 0) d = -d;
 lua_pushnumber (d);
}


decompiled_code:
void math_randomseed()
{
double v0; // xmm0_8

v0 = lua_check_number(1LL, "randomseed");
srand((int)v0);
}

canonical_decompiled_code:
void func6()
{
double v0; // xmm0_8

v0 = lua_check_number(1LL, "randomseed");
srand((int)v0);
}

original_code:
static void math_randomseed (void)
{
  srand(lua_check_number(1, "randomseed"));
}

canonical_original_code:
static void math_randomseed()
{
  srand(lua_check_number(1, "randomseed"));
}


decompiled_code:
__int64 math_random()
{
float v0; // xmm0_4

v0 = (double)(rand() % 0x7FFFFFFF) / 2147483647.0;
return lua_pushnumber(v0);
}

canonical_decompiled_code:
__int64 func7()
{
float v0; // xmm0_4

v0 = (double)(rand() % 0x7FFFFFFF) / 2147483647.0;
return lua_pushnumber(v0);
}

original_code:
static void math_random (void)
{
  lua_pushnumber((double)(rand()%2147483647) / (double)2147483647);
}

canonical_original_code:
static void math_random()
{
  lua_pushnumber((double)(rand()%2147483647) / (double)2147483647);
}


decompiled_code:
__int64 math_exp()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "exp");
v1 = exp(v0);
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func8()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "exp");
v1 = exp(v0);
return lua_pushnumber(v1);
}

original_code:
static void math_exp (void)
{
 double d = lua_check_number(1, "exp");
 lua_pushnumber (exp(d));
}

canonical_original_code:
static void math_exp()
{
 double d = lua_check_number(1, "exp");
 lua_pushnumber (exp(d));
}


decompiled_code:
__int64 math_log10()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "log10");
v1 = log10(v0);
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func9()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "log10");
v1 = log10(v0);
return lua_pushnumber(v1);
}

original_code:
static void math_log10 (void)
{
 double d = lua_check_number(1, "log10");
 lua_pushnumber (log10(d));
}

canonical_original_code:
static void math_log10()
{
 double d = lua_check_number(1, "log10");
 lua_pushnumber (log10(d));
}


decompiled_code:
__int64 math_log()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "log");
v1 = log(v0);
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func10()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "log");
v1 = log(v0);
return lua_pushnumber(v1);
}

original_code:
static void math_log (void)
{
 double d = lua_check_number(1, "log");
 lua_pushnumber (log(d));
}

canonical_original_code:
static void math_log()
{
 double d = lua_check_number(1, "log");
 lua_pushnumber (log(d));
}


decompiled_code:
__int64 math_sqrt()
{
double v0; // xmm0_8
double v1; // xmm0_8
float v2; // xmm0_4

v0 = lua_check_number(1LL, "sqrt");
if ( v0 < 0.0 )
v1 = sqrt(v0);
else
v1 = sqrt(v0);
v2 = v1;
return lua_pushnumber(v2);
}

canonical_decompiled_code:
__int64 func11()
{
double v0; // xmm0_8
double v1; // xmm0_8
float v2; // xmm0_4

v0 = lua_check_number(1LL, "sqrt");
if ( v0 < 0.0 )
v1 = sqrt(v0);
else
v1 = sqrt(v0);
v2 = v1;
return lua_pushnumber(v2);
}

original_code:
static void math_sqrt (void)
{
 double d = lua_check_number(1, "sqrt");
 lua_pushnumber (sqrt(d));
}

canonical_original_code:
static void math_sqrt()
{
 double d = lua_check_number(1, "sqrt");
 lua_pushnumber (sqrt(d));
}


original_code:
static void math_floor (void)
{
 double d = lua_check_number(1, "floor");
 lua_pushnumber (floor(d));
}

canonical_original_code:
static void math_floor()
{
 double d = lua_check_number(1, "floor");
 lua_pushnumber (floor(d));
}


original_code:
static void math_ceil (void)
{
 double d = lua_check_number(1, "ceil");
 lua_pushnumber (ceil(d));
}

canonical_original_code:
static void math_ceil()
{
 double d = lua_check_number(1, "ceil");
 lua_pushnumber (ceil(d));
}


decompiled_code:
__int64 math_atan2()
{
double v0; // rbx
double v1; // xmm1_8
float v2; // xmm0_4

v0 = lua_check_number(1LL, "atan2");
v1 = lua_check_number(2LL, "atan2");
v2 = atan2(v0, v1) * 180.0 / 3.141592653589793;
return lua_pushnumber(v2);
}

canonical_decompiled_code:
__int64 func15()
{
double v0; // rbx
double v1; // xmm1_8
float v2; // xmm0_4

v0 = lua_check_number(1LL, "atan2");
v1 = lua_check_number(2LL, "atan2");
v2 = atan2(v0, v1) * 180.0 / 3.141592653589793;
return lua_pushnumber(v2);
}

original_code:
static void math_atan2 (void)
{
 double d1 = lua_check_number(1, "atan2");
 double d2 = lua_check_number(2, "atan2");
 lua_pushnumber (((atan2(d1, d2))*180.0/3.14159265358979323846));
}

canonical_original_code:
static void math_atan2()
{
 double d1 = lua_check_number(1, "atan2");
 double d2 = lua_check_number(2, "atan2");
 lua_pushnumber (((atan2(d1, d2))*180.0/3.14159265358979323846));
}


decompiled_code:
__int64 math_atan()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "atan");
v1 = atan(v0) * 180.0 / 3.141592653589793;
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func16()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "atan");
v1 = atan(v0) * 180.0 / 3.141592653589793;
return lua_pushnumber(v1);
}

original_code:
static void math_atan (void)
{
 double d = lua_check_number(1, "atan");
 lua_pushnumber (((atan(d))*180.0/3.14159265358979323846));
}

canonical_original_code:
static void math_atan()
{
 double d = lua_check_number(1, "atan");
 lua_pushnumber (((atan(d))*180.0/3.14159265358979323846));
}


decompiled_code:
__int64 math_acos()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "acos");
v1 = acos(v0) * 180.0 / 3.141592653589793;
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func17()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "acos");
v1 = acos(v0) * 180.0 / 3.141592653589793;
return lua_pushnumber(v1);
}

original_code:
static void math_acos (void)
{
 double d = lua_check_number(1, "acos");
 lua_pushnumber (((acos(d))*180.0/3.14159265358979323846));
}

canonical_original_code:
static void math_acos()
{
 double d = lua_check_number(1, "acos");
 lua_pushnumber (((acos(d))*180.0/3.14159265358979323846));
}


decompiled_code:
__int64 math_asin()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "asin");
v1 = asin(v0) * 180.0 / 3.141592653589793;
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func18()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "asin");
v1 = asin(v0) * 180.0 / 3.141592653589793;
return lua_pushnumber(v1);
}

original_code:
static void math_asin (void)
{
 double d = lua_check_number(1, "asin");
 lua_pushnumber (((asin(d))*180.0/3.14159265358979323846));
}

canonical_original_code:
static void math_asin()
{
 double d = lua_check_number(1, "asin");
 lua_pushnumber (((asin(d))*180.0/3.14159265358979323846));
}


decompiled_code:
__int64 math_tan()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "tan");
v1 = tan(v0 * 3.141592653589793 / 180.0);
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func19()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "tan");
v1 = tan(v0 * 3.141592653589793 / 180.0);
return lua_pushnumber(v1);
}

original_code:
static void math_tan (void)
{
 double d = lua_check_number(1, "tan");
 lua_pushnumber (tan(((d)*3.14159265358979323846/180.0)));
}

canonical_original_code:
static void math_tan()
{
 double d = lua_check_number(1, "tan");
 lua_pushnumber (tan(((d)*3.14159265358979323846/180.0)));
}


decompiled_code:
__int64 math_cos()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "cos");
v1 = cos(v0 * 3.141592653589793 / 180.0);
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func20()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "cos");
v1 = cos(v0 * 3.141592653589793 / 180.0);
return lua_pushnumber(v1);
}

original_code:
static void math_cos (void)
{
 double d = lua_check_number(1, "cos");
 lua_pushnumber (cos(((d)*3.14159265358979323846/180.0)));
}

canonical_original_code:
static void math_cos()
{
 double d = lua_check_number(1, "cos");
 lua_pushnumber (cos(((d)*3.14159265358979323846/180.0)));
}


decompiled_code:
__int64 math_sin()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "sin");
v1 = sin(v0 * 3.141592653589793 / 180.0);
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func21()
{
double v0; // xmm0_8
float v1; // xmm0_4

v0 = lua_check_number(1LL, "sin");
v1 = sin(v0 * 3.141592653589793 / 180.0);
return lua_pushnumber(v1);
}

original_code:
static void math_sin (void)
{
 double d = lua_check_number(1, "sin");
 lua_pushnumber (sin(((d)*3.14159265358979323846/180.0)));
}

canonical_original_code:
static void math_sin()
{
 double d = lua_check_number(1, "sin");
 lua_pushnumber (sin(((d)*3.14159265358979323846/180.0)));
}


decompiled_code:
__int64 mathlib_open()
{
unsigned int v0; // eax
__int64 result; // rax

luaI_openlib(&mathlib, 21LL);
v0 = lua_setfallback("arith", math_pow);
lua_pushobject(v0);
result = lua_ref(1LL);
old_pow = result;
return result;
}

canonical_decompiled_code:
__int64 func22()
{
unsigned int v0; // eax
__int64 result; // rax

luaI_openlib(&mathlib, 21LL);
v0 = lua_setfallback("arith", math_pow);
lua_pushobject(v0);
result = lua_ref(1LL);
old_pow = result;
return result;
}

original_code:
void mathlib_open (void)
{
  luaI_openlib(mathlib, (sizeof(mathlib)/sizeof(mathlib[0])));
  old_pow = (lua_pushobject(lua_setfallback("arith", math_pow)), lua_ref(1));
}

canonical_original_code:
void mathlib_open()
{
  luaI_openlib(mathlib, (sizeof(mathlib)/sizeof(mathlib[0])));
  old_pow = (lua_pushobject(lua_setfallback("arith", math_pow)), lua_ref(1));
}


stringinput

decompiled_code:
__int64 stringinput()
{
char *v0; // rax

v0 = (char *)st++;
return (unsigned int)*v0;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rax

v0 = (char *)st++;
return (unsigned int)*v0;
}

original_code:
static int stringinput (void)
{
 return *st++;
}

canonical_original_code:
static int stringinput()
{
 return *st++;
}


fileinput

decompiled_code:
int fileinput()
{
int result; // eax

result = fgetc(fp);
if ( result == -1 )
result = 0;
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax

result = fgetc(fp);
if ( result == -1 )
result = 0;
return result;
}

original_code:
static int fileinput (void)
{
  int c = fgetc(fp);
  return (c == (-1)) ? 0 : c;
}

canonical_original_code:
static int fileinput()
{
  int c = fgetc(fp);
  return (c == (-1)) ? 0 : c;
}

variable_types: c int


passresults

decompiled_code:
__int64 passresults()
{
unsigned int i; // ebp
unsigned int v1; // eax

for ( i = 0; ; ++i )
{
v1 = lua_getparam(i + 1);
if ( !v1 )
break;
lua_pushobject(v1);
}
return i;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int i; // ebp
unsigned int v1; // eax

for ( i = 0; ; ++i )
{
v1 = lua_getparam(i + 1);
if ( !v1 )
break;
lua_pushobject(v1);
}
return i;
}

original_code:
static int passresults (void)
{
  int arg = 0;
  lua_Object obj;
  while ((obj = lua_getparam(++arg)) != 0)
    lua_pushobject(obj);
  return arg-1;
}

canonical_original_code:
static int passresults()
{
  int arg = 0;
  unsigned int obj;
  while ((obj = lua_getparam(++arg)) != 0)
    lua_pushobject(obj);
  return arg-1;
}

variable_types: arg int

variable_types:
obj
unsigned int


decompiled_code:
__int64 __fastcall check_arg(int a1, const char *a2)
{
__int64 result; // rax
char v3[120]; // [rsp-78h] [rbp-78h] BYREF

if ( !a1 )
{
sprintf(v3, "incorrect argument to function `%s'", a2);
result = lua_error(v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, const char *a2)
{
__int64 result; // rax
char v3[120]; // [rsp-78h] [rbp-78h] BYREF

if ( !a1 )
{
sprintf(v3, "incorrect argument to function `%s'", a2);
result = lua_error(v3);
}
return result;
}

original_code:
static void check_arg (int cond, char *func)
{
  if (!cond)
  {
    char buff[100];
    sprintf(buff, "incorrect argument to function `%s'", func);
    lua_error(buff);
  }
}

canonical_original_code:
static void check_arg(int cond, char *func)
{
  if (!cond)
  {
    char buff[100];
    sprintf(buff, "incorrect argument to function `%s'", func);
    lua_error(buff);
  }
}

variable_types: cond int

variable_types:
func
char *

variable_types:
buff
char [100]


tostring

decompiled_code:
__int64 __fastcall tostring(unsigned int a1)
{
char *v1; // rbx
int v2; // eax
__int64 v3; // rax
const void *v5; // rax
__int64 v6; // rax
const void *v7; // rax

v1 = (char *)luaI_buffer(20LL);
if ( (unsigned int)lua_isstring(a1) )
return lua_getstring(a1);
v2 = lua_type(a1);
if ( v2 == -4 )
{
v6 = luaI_Address(a1);
sprintf(v1, "table: %p", *(const void **)(v6 + 8));
return (__int64)v1;
}
if ( v2 >= -3 )
{
if ( v2 == -1 )
{
*(_DWORD *)v1 = 7104878;
return (__int64)v1;
}
LABEL_13:
v7 = (const void *)lua_getuserdata(a1);
sprintf(v1, "userdata: %p", v7);
return (__int64)v1;
}
if ( v2 == -6 )
{
v5 = (const void *)lua_getcfunction(a1);
sprintf(v1, "cfunction: %p", v5);
return (__int64)v1;
}
if ( v2 != -5 )
goto LABEL_13;
v3 = luaI_Address(a1);
sprintf(v1, "function: %p", *(const void **)(v3 + 8));
return (__int64)v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
char *v1; // rbx
int v2; // eax
__int64 v3; // rax
const void *v5; // rax
__int64 v6; // rax
const void *v7; // rax

v1 = (char *)luaI_buffer(20LL);
if ( (unsigned int)lua_isstring(a1) )
return lua_getstring(a1);
v2 = lua_type(a1);
if ( v2 == -4 )
{
v6 = luaI_Address(a1);
sprintf(v1, "table: %p", *(const void **)(v6 + 8));
return (__int64)v1;
}
if ( v2 >= -3 )
{
if ( v2 == -1 )
{
*(_DWORD *)v1 = 7104878;
return (__int64)v1;
}
LABEL_13:
v7 = (const void *)lua_getuserdata(a1);
sprintf(v1, "userdata: %p", v7);
return (__int64)v1;
}
if ( v2 == -6 )
{
v5 = (const void *)lua_getcfunction(a1);
sprintf(v1, "cfunction: %p", v5);
return (__int64)v1;
}
if ( v2 != -5 )
goto LABEL_13;
v3 = luaI_Address(a1);
sprintf(v1, "function: %p", *(const void **)(v3 + 8));
return (__int64)v1;
}

original_code:
static char *tostring (lua_Object obj)
{
  char *buff = luaI_buffer(20);
  if (lua_isstring(obj))
    return lua_getstring(obj);
  else switch(lua_type(obj))
  {
    case LUA_T_FUNCTION:
      sprintf(buff, "function: %p", (luaI_Address(obj))->value.tf);
      break;
    case LUA_T_CFUNCTION:
      sprintf(buff, "cfunction: %p", lua_getcfunction(obj));
      break;
    case LUA_T_ARRAY:
      sprintf(buff, "table: %p", ((luaI_Address(obj))->value.a));
      break;
    case LUA_T_NIL:
      sprintf(buff, "nil");
      break;
    default:
      sprintf(buff, "userdata: %p", lua_getuserdata(obj));
      break;
  }
  return buff;
}

canonical_original_code:
static char *tostring(unsigned int obj)
{
  char *buff = luaI_buffer(20);
  if (lua_isstring(obj))
    return lua_getstring(obj);
  else switch(lua_type(obj))
  {
    case LUA_T_FUNCTION:
      sprintf(buff, "function: %p", (luaI_Address(obj))->value.tf);
      break;
    case LUA_T_CFUNCTION:
      sprintf(buff, "cfunction: %p", lua_getcfunction(obj));
      break;
    case LUA_T_ARRAY:
      sprintf(buff, "table: %p", ((luaI_Address(obj))->value.a));
      break;
    case LUA_T_NIL:
      sprintf(buff, "nil");
      break;
    default:
      sprintf(buff, "userdata: %p", lua_getuserdata(obj));
      break;
  }
  return buff;
}

variable_types:
buff
char *


decompiled_code:
int lua_closefile()
{
int result; // eax

if ( fp )
{
if ( fp != stdin )
{
result = fclose(fp);
fp = 0LL;
}
}
return result;
}

canonical_decompiled_code:
int func5()
{
int result; // eax

if ( fp )
{
if ( fp != stdin )
{
result = fclose(fp);
fp = 0LL;
}
}
return result;
}

original_code:
void lua_closefile (void)
{
 if (fp != ((void *)0) && fp != stdin)
 {
  fclose (fp);
  fp = ((void *)0);
 }
}

canonical_original_code:
void lua_closefile()
{
 if (fp != ((void *)0) && fp != stdin)
 {
  fclose (fp);
  fp = ((void *)0);
 }
}


decompiled_code:
__int64 __fastcall lua_openstring(char *s)
{
__int64 result; // rax
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

lua_setinput(stringinput);
st = (__int64)s;
strcpy(v2, "(dostring) >> ");
strncat(v2, s, 0x14uLL);
if ( strlen(s) > 0x14 )
*(_DWORD *)&v2[strlen(v2)] = 3026478;
result = luaI_createfixedstring(v2) + 20;
lua_parsedfile = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *s)
{
__int64 result; // rax
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

lua_setinput(stringinput);
st = (__int64)s;
strcpy(v2, "(dostring) >> ");
strncat(v2, s, 0x14uLL);
if ( strlen(s) > 0x14 )
*(_DWORD *)&v2[strlen(v2)] = 3026478;
result = luaI_createfixedstring(v2) + 20;
lua_parsedfile = result;
return result;
}

original_code:
void lua_openstring (char *s)
{
  char buff[20 +25];
  lua_setinput(stringinput);
  st = s;
  strcpy(buff, "(dostring) >> ");
  strncat(buff, s, 20);
  if (strlen(s) > 20) strcat(buff, "...");
  lua_parsedfile = luaI_createfixedstring(buff)->str;
}

canonical_original_code:
void lua_openstring(char *s)
{
  char buff[-1];
  lua_setinput(stringinput);
  st = s;
  strcpy(buff, "(dostring) >> ");
  strncat(buff, s, 20);
  if (strlen(s) > 20) strcat(buff, "...");
  lua_parsedfile = luaI_createfixedstring(buff)->str;
}

variable_types:
s
char *

variable_types:
buff
char [-1]


decompiled_code:
void lua_closestring()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void lua_closestring (void)
{
}

canonical_original_code:
void lua_closestring()
{
}


decompiled_code:
__int64 lua_internaldostring()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rax

v0 = (unsigned int)lua_getparam(1LL);
result = lua_isstring(v0);
if ( (_DWORD)result )
{
v2 = lua_getstring((unsigned int)v0);
result = lua_dostring(v2);
if ( !(_DWORD)result )
{
result = passresults();
if ( !(_DWORD)result )
result = lua_pushusertag(0LL, 0LL);
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rax

v0 = (unsigned int)lua_getparam(1LL);
result = lua_isstring(v0);
if ( (_DWORD)result )
{
v2 = lua_getstring((unsigned int)v0);
result = lua_dostring(v2);
if ( !(_DWORD)result )
{
result = func2();
if ( !(_DWORD)result )
result = lua_pushusertag(0LL, 0LL);
}
}
return result;
}

original_code:
void lua_internaldostring (void)
{
  lua_Object obj = lua_getparam (1);
  if (lua_isstring(obj) && lua_dostring(lua_getstring(obj)) == 0)
    if (passresults() == 0)
      lua_pushusertag(((void *)0), LUA_T_USERDATA);
}

canonical_original_code:
void lua_internaldostring()
{
  unsigned int obj = lua_getparam (1);
  if (lua_isstring(obj) && lua_dostring(lua_getstring(obj)) == 0)
    if (passresults() == 0)
      lua_pushusertag(((void *)0), LUA_T_USERDATA);
}


decompiled_code:
__int64 lua_internaldofile()
{
__int64 v0; // rbx
__int64 v1; // rdi
__int64 result; // rax

v0 = (unsigned int)lua_getparam(1LL);
if ( (unsigned int)lua_isstring(v0) )
{
v1 = lua_getstring((unsigned int)v0);
}
else
{
v1 = 0LL;
if ( (_DWORD)v0 )
{
lua_error("invalid argument to function `dofile'");
v1 = 0LL;
}
}
result = lua_dofile(v1);
if ( !(_DWORD)result )
{
result = passresults();
if ( !(_DWORD)result )
result = lua_pushusertag(0LL, 0LL);
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rbx
__int64 v1; // rdi
__int64 result; // rax

v0 = (unsigned int)lua_getparam(1LL);
if ( (unsigned int)lua_isstring(v0) )
{
v1 = lua_getstring((unsigned int)v0);
}
else
{
v1 = 0LL;
if ( (_DWORD)v0 )
{
lua_error("invalid argument to function `dofile'");
v1 = 0LL;
}
}
result = lua_dofile(v1);
if ( !(_DWORD)result )
{
result = func2();
if ( !(_DWORD)result )
result = lua_pushusertag(0LL, 0LL);
}
return result;
}

original_code:
void lua_internaldofile (void)
{
 lua_Object obj = lua_getparam (1);
 char *fname = ((void *)0);
 if (lua_isstring(obj))
   fname = lua_getstring(obj);
 else if (obj != 0)
   lua_error("invalid argument to function `dofile'");
 if (lua_dofile(fname) == 0)
    if (passresults() == 0)
      lua_pushusertag(((void *)0), LUA_T_USERDATA);
}

canonical_original_code:
void lua_internaldofile()
{
 unsigned int obj = lua_getparam (1);
 char *fname = ((void *)0);
 if (lua_isstring(obj))
   fname = lua_getstring(obj);
 else if (obj != 0)
   lua_error("invalid argument to function `dofile'");
 if (lua_dofile(fname) == 0)
    if (passresults() == 0)
      lua_pushusertag(((void *)0), LUA_T_USERDATA);
}

variable_types:
fname
char *


decompiled_code:
__int64 luaI_tostring()
{
unsigned int v0; // eax
__int64 v1; // rax

v0 = lua_getparam(1LL);
v1 = tostring(v0);
return lua_pushstring(v1);
}

canonical_decompiled_code:
__int64 func10()
{
unsigned int v0; // eax
__int64 v1; // rax

v0 = lua_getparam(1LL);
v1 = func4(v0);
return lua_pushstring(v1);
}

original_code:
void luaI_tostring (void)
{
  lua_pushstring(tostring(lua_getparam(1)));
}

canonical_original_code:
void luaI_tostring()
{
  lua_pushstring(tostring(lua_getparam(1)));
}


decompiled_code:
__int64 luaI_print()
{
__int64 i; // rdi
const char *v1; // rax
__int64 result; // rax

for ( i = 1LL; ; i = (unsigned int)(i + 1) )
{
result = lua_getparam(i);
if ( !(_DWORD)result )
break;
v1 = (const char *)tostring(result);
puts(v1);
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 i; // rdi
const char *v1; // rax
__int64 result; // rax

for ( i = 1LL; ; i = (unsigned int)(i + 1) )
{
result = lua_getparam(i);
if ( !(_DWORD)result )
break;
v1 = (const char *)func4(result);
puts(v1);
}
return result;
}

original_code:
void luaI_print (void)
{
  int i = 1;
  lua_Object obj;
  while ((obj = lua_getparam(i++)) != 0)
    printf("%s\n", tostring(obj));
}

canonical_original_code:
void luaI_print()
{
  int i = 1;
  unsigned int obj;
  while ((obj = lua_getparam(i++)) != 0)
    printf("%s\n", tostring(obj));
}

variable_types: i int


decompiled_code:
__int64 luaI_type()
{
unsigned int v0; // ebx
int v1; // ebx

v0 = lua_getparam(1LL);
if ( !v0 )
lua_error("no parameter to function 'type'");
v1 = lua_type(v0);
if ( (unsigned int)v1 < 0xFFFFFFFA )
{
lua_pushstring("userdata");
}
else
{
switch ( v1 )
{
case -6:
case -5:
lua_pushstring("function");
break;
case -4:
lua_pushstring("table");
break;
case -3:
lua_pushstring("string");
break;
case -2:
lua_pushstring("number");
break;
case -1:
lua_pushstring("nil");
break;
}
}
return lua_pushnumber((float)v1);
}

canonical_decompiled_code:
__int64 func12()
{
unsigned int v0; // ebx
int v1; // ebx

v0 = lua_getparam(1LL);
if ( !v0 )
lua_error("no parameter to function 'type'");
v1 = lua_type(v0);
if ( (unsigned int)v1 < 0xFFFFFFFA )
{
lua_pushstring("userdata");
}
else
{
switch ( v1 )
{
case -6:
case -5:
lua_pushstring("function");
break;
case -4:
lua_pushstring("table");
break;
case -3:
lua_pushstring("string");
break;
case -2:
lua_pushstring("number");
break;
case -1:
lua_pushstring("nil");
break;
}
}
return lua_pushnumber((float)v1);
}

original_code:
void luaI_type (void)
{
  lua_Object o = lua_getparam(1);
  int t;
  if (o == 0)
    lua_error("no parameter to function 'type'");
  t = lua_type(o);
  switch (t)
  {
    case LUA_T_NIL :
      lua_pushstring("nil");
      break;
    case LUA_T_NUMBER :
      lua_pushstring("number");
      break;
    case LUA_T_STRING :
      lua_pushstring("string");
      break;
    case LUA_T_ARRAY :
      lua_pushstring("table");
      break;
    case LUA_T_FUNCTION :
    case LUA_T_CFUNCTION :
      lua_pushstring("function");
      break;
    default :
      lua_pushstring("userdata");
      break;
  }
  lua_pushnumber(t);
}

canonical_original_code:
void luaI_type()
{
  unsigned int o = lua_getparam(1);
  int t;
  if (o == 0)
    lua_error("no parameter to function 'type'");
  t = lua_type(o);
  switch (t)
  {
    case LUA_T_NIL :
      lua_pushstring("nil");
      break;
    case LUA_T_NUMBER :
      lua_pushstring("number");
      break;
    case LUA_T_STRING :
      lua_pushstring("string");
      break;
    case LUA_T_ARRAY :
      lua_pushstring("table");
      break;
    case LUA_T_FUNCTION :
    case LUA_T_CFUNCTION :
      lua_pushstring("function");
      break;
    default :
      lua_pushstring("userdata");
      break;
  }
  lua_pushnumber(t);
}

variable_types:
o
unsigned int

variable_types: t int


decompiled_code:
__int64 lua_obj2number()
{
__int64 v0; // rbx
__int64 result; // rax
float v2; // xmm0_4

v0 = (unsigned int)lua_getparam(1LL);
result = lua_isnumber(v0);
if ( (_DWORD)result )
{
v2 = lua_getnumber((unsigned int)v0);
result = lua_pushnumber(v2);
}
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 v0; // rbx
__int64 result; // rax
float v2; // xmm0_4

v0 = (unsigned int)lua_getparam(1LL);
result = lua_isnumber(v0);
if ( (_DWORD)result )
{
v2 = lua_getnumber((unsigned int)v0);
result = lua_pushnumber(v2);
}
return result;
}

original_code:
void lua_obj2number (void)
{
  lua_Object o = lua_getparam(1);
  if (lua_isnumber(o))
    lua_pushnumber(lua_getnumber(o));
}

canonical_original_code:
void lua_obj2number()
{
  unsigned int o = lua_getparam(1);
  if (lua_isnumber(o))
    lua_pushnumber(lua_getnumber(o));
}


decompiled_code:
__int64 luaI_error()
{
unsigned int v0; // eax
const char *v1; // rdi

v0 = lua_getparam(1LL);
v1 = (const char *)lua_getstring(v0);
if ( !v1 )
v1 = "(no message)";
return lua_error(v1);
}

canonical_decompiled_code:
__int64 func14()
{
unsigned int v0; // eax
const char *v1; // rdi

v0 = lua_getparam(1LL);
v1 = (const char *)lua_getstring(v0);
if ( !v1 )
v1 = "(no message)";
return lua_error(v1);
}

original_code:
void luaI_error (void)
{
  char *s = lua_getstring(lua_getparam(1));
  if (s == ((void *)0)) s = "(no message)";
  lua_error(s);
}

canonical_original_code:
void luaI_error()
{
  char *s = lua_getstring(lua_getparam(1));
  if (s == ((void *)0)) s = "(no message)";
  lua_error(s);
}


decompiled_code:
__int64 luaI_assert()
{
unsigned int v0; // eax
__int64 result; // rax

v0 = lua_getparam(1LL);
if ( !v0 || (result = lua_type(v0), (_DWORD)result == -1) )
result = lua_error("assertion failed!");
return result;
}

canonical_decompiled_code:
__int64 func15()
{
unsigned int v0; // eax
__int64 result; // rax

v0 = lua_getparam(1LL);
if ( !v0 || (result = lua_type(v0), (_DWORD)result == -1) )
result = lua_error("assertion failed!");
return result;
}

original_code:
void luaI_assert (void)
{
  lua_Object p = lua_getparam(1);
  if (p == 0 || (lua_type(p)==LUA_T_NIL))
    lua_error("assertion failed!");
}

canonical_original_code:
void luaI_assert()
{
  unsigned int p = lua_getparam(1);
  if (p == 0 || (lua_type(p)==LUA_T_NIL))
    lua_error("assertion failed!");
}

variable_types:
p
unsigned int


decompiled_code:
__int64 luaI_setglobal()
{
unsigned int v0; // ebp
unsigned int v1; // ebx
int v2; // eax
__int64 v3; // rax

v0 = lua_getparam(1LL);
v1 = lua_getparam(2LL);
v2 = lua_isstring(v0);
check_arg(v2, "setglobal");
lua_pushobject(v1);
v3 = lua_getstring(v0);
lua_storeglobal(v3);
return lua_pushobject(v1);
}

canonical_decompiled_code:
__int64 func16()
{
unsigned int v0; // ebp
unsigned int v1; // ebx
int v2; // eax
__int64 v3; // rax

v0 = lua_getparam(1LL);
v1 = lua_getparam(2LL);
v2 = lua_isstring(v0);
func3(v2, "setglobal");
lua_pushobject(v1);
v3 = lua_getstring(v0);
lua_storeglobal(v3);
return lua_pushobject(v1);
}

original_code:
void luaI_setglobal (void)
{
  lua_Object name = lua_getparam(1);
  lua_Object value = lua_getparam(2);
  check_arg(lua_isstring(name), "setglobal");
  lua_pushobject(value);
  lua_storeglobal(lua_getstring(name));
  lua_pushobject(value);
}

canonical_original_code:
void luaI_setglobal()
{
  unsigned int name = lua_getparam(1);
  unsigned int value = lua_getparam(2);
  check_arg(lua_isstring(name), "setglobal");
  lua_pushobject(value);
  lua_storeglobal(lua_getstring(name));
  lua_pushobject(value);
}

variable_types:
name
unsigned int

variable_types:
value
unsigned int


decompiled_code:
__int64 luaI_getglobal()
{
__int64 v0; // rbx
int v1; // eax
__int64 v2; // rax
unsigned int v3; // eax

v0 = (unsigned int)lua_getparam(1LL);
v1 = lua_isstring(v0);
check_arg(v1, "getglobal");
v2 = lua_getstring((unsigned int)v0);
v3 = lua_getglobal(v2);
return lua_pushobject(v3);
}

canonical_decompiled_code:
__int64 func17()
{
__int64 v0; // rbx
int v1; // eax
__int64 v2; // rax
unsigned int v3; // eax

v0 = (unsigned int)lua_getparam(1LL);
v1 = lua_isstring(v0);
func3(v1, "getglobal");
v2 = lua_getstring((unsigned int)v0);
v3 = lua_getglobal(v2);
return lua_pushobject(v3);
}

original_code:
void luaI_getglobal (void)
{
  lua_Object name = lua_getparam(1);
  check_arg(lua_isstring(name), "getglobal");
  lua_pushobject(lua_getglobal(lua_getstring(name)));
}

canonical_original_code:
void luaI_getglobal()
{
  unsigned int name = lua_getparam(1);
  check_arg(lua_isstring(name), "getglobal");
  lua_pushobject(lua_getglobal(lua_getstring(name)));
}


decompiled_code:
__int64 luaI_call()
{
unsigned int v0; // er14
__int64 v1; // r12
int v2; // eax
int v3; // eax
__int64 v4; // rbx
int v5; // ebp
__int64 v6; // rbx
unsigned int v7; // eax
__int64 v8; // rbx
__int64 result; // rax
int v10[270]; // [rsp+0h] [rbp-438h]

v0 = lua_getparam(1LL);
v1 = (unsigned int)lua_getparam(2LL);
v2 = lua_type(v1);
check_arg(v2 == -4, "call");
v3 = lua_isfunction(v0);
check_arg(v3, "call");
lua_pushobject((unsigned int)v1);
lua_pushstring("n");
v4 = (unsigned int)lua_getsubscript();
v5 = 257;
if ( !(unsigned int)lua_isnumber(v4) || (v5 = (int)lua_getnumber((unsigned int)v4), v5 > 0) )
{
v6 = 0LL;
while ( 1 )
{
if ( (int)v6 > 255 )
lua_error("argument list too long in function `call'");
lua_pushobject((unsigned int)v1);
lua_pushnumber((float)(v6 + 1));
v7 = lua_getsubscript();
v10[v6] = v7;
if ( v5 == 257 && (unsigned int)lua_type(v7) == -1 )
break;
if ( v5 <= (int)++v6 )
goto LABEL_12;
}
if ( (int)v6 <= 0 )
goto LABEL_14;
v5 = v6;
LABEL_12:
v8 = 0LL;
do
lua_pushobject((unsigned int)v10[v8++]);
while ( v5 > (int)v8 );
}
LABEL_14:
if ( (unsigned int)lua_callfunction(v0) )
result = lua_error(0LL);
else
result = passresults();
return result;
}

canonical_decompiled_code:
__int64 func18()
{
unsigned int v0; // er14
__int64 v1; // r12
int v2; // eax
int v3; // eax
__int64 v4; // rbx
int v5; // ebp
__int64 v6; // rbx
unsigned int v7; // eax
__int64 v8; // rbx
__int64 result; // rax
int v10[270]; // [rsp+0h] [rbp-438h]

v0 = lua_getparam(1LL);
v1 = (unsigned int)lua_getparam(2LL);
v2 = lua_type(v1);
func3(v2 == -4, "call");
v3 = lua_isfunction(v0);
func3(v3, "call");
lua_pushobject((unsigned int)v1);
lua_pushstring("n");
v4 = (unsigned int)lua_getsubscript();
v5 = 257;
if ( !(unsigned int)lua_isnumber(v4) || (v5 = (int)lua_getnumber((unsigned int)v4), v5 > 0) )
{
v6 = 0LL;
while ( 1 )
{
if ( (int)v6 > 255 )
lua_error("argument list too long in function `call'");
lua_pushobject((unsigned int)v1);
lua_pushnumber((float)(v6 + 1));
v7 = lua_getsubscript();
v10[v6] = v7;
if ( v5 == 257 && (unsigned int)lua_type(v7) == -1 )
break;
if ( v5 <= (int)++v6 )
goto LABEL_12;
}
if ( (int)v6 <= 0 )
goto LABEL_14;
v5 = v6;
LABEL_12:
v8 = 0LL;
do
lua_pushobject((unsigned int)v10[v8++]);
while ( v5 > (int)v8 );
}
LABEL_14:
if ( (unsigned int)lua_callfunction(v0) )
result = lua_error(0LL);
else
result = func2();
return result;
}

original_code:
void luaI_call (void)
{
  lua_Object f = lua_getparam(1);
  lua_Object arg = lua_getparam(2);
  lua_Object temp, params[256];
  int narg, i;
  check_arg((lua_type(arg)==LUA_T_ARRAY), "call");
  check_arg(lua_isfunction(f), "call");
  lua_pushobject(arg);
  lua_pushstring("n");
  temp = lua_getsubscript();
  narg = lua_isnumber(temp) ? lua_getnumber(temp) : 256 +1;
  for (i=0; i<narg; i++) {
    if (i>=256)
      lua_error("argument list too long in function `call'");
    lua_pushobject(arg);
    lua_pushnumber(i+1);
    params[i] = lua_getsubscript();
    if (narg == 256 +1 && (lua_type(params[i])==LUA_T_NIL)) {
      narg = i;
      break;
    }
  }
  for (i=0; i<narg; i++)
    lua_pushobject(params[i]);
  if (lua_callfunction(f))
    lua_error(((void *)0));
  else
    passresults();
}

canonical_original_code:
void luaI_call()
{
  unsigned int f = lua_getparam(1);
  unsigned int arg = lua_getparam(2);
  unsigned int temp; unsigned int params[256];
  int narg; int i;
  check_arg((lua_type(arg)==LUA_T_ARRAY), "call");
  check_arg(lua_isfunction(f), "call");
  lua_pushobject(arg);
  lua_pushstring("n");
  temp = lua_getsubscript();
  narg = lua_isnumber(temp) ? lua_getnumber(temp) : 256 +1;
  for (i=0; i<narg; i++) {
    if (i>=256)
      lua_error("argument list too long in function `call'");
    lua_pushobject(arg);
    lua_pushnumber(i+1);
    params[i] = lua_getsubscript();
    if (narg == 256 +1 && (lua_type(params[i])==LUA_T_NIL)) {
      narg = i;
      break;
    }
  }
  for (i=0; i<narg; i++)
    lua_pushobject(params[i]);
  if (lua_callfunction(f))
    lua_error(((void *)0));
  else
    passresults();
}

variable_types:
f
unsigned int

variable_types:
arg
unsigned int

variable_types:
temp
unsigned int

variable_types:
params
unsigned int [256]

variable_types: narg int


decompiled_code:
__int64 __fastcall lua_arg_error(const char *a1)
{
char v2[120]; // [rsp+0h] [rbp-78h] BYREF

sprintf(v2, "incorrect arguments to function `%s'", a1);
return lua_error(v2);
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
char v2[120]; // [rsp+0h] [rbp-78h] BYREF

sprintf(v2, "incorrect arguments to function `%s'", a1);
return lua_error(v2);
}

original_code:
void lua_arg_error(char *funcname)
{
  char buff[100];
  sprintf(buff, "incorrect arguments to function `%s'", funcname);
  lua_error(buff);
}

variable_types:
funcname
char *