decompiled_code:
__int64 __fastcall luaI_findconstant(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rsi
__int64 v3; // rdx
int v4; // eax

result = *(unsigned __int16 *)(a1 + 2);
if ( (_WORD)result == 0xFFFE )
{
v2 = (unsigned __int16)lua_nconstant;
result = (unsigned __int16)lua_nconstant;
if ( (unsigned __int16)lua_nconstant == lua_maxconstant )
{
v4 = luaI_growvector(&lua_constant, (unsigned __int16)lua_nconstant, 8LL, "constant table overflow", 65533LL);
v2 = (unsigned __int16)lua_nconstant;
lua_maxconstant = v4;
result = (unsigned __int16)lua_nconstant;
}
v3 = lua_constant;
*(_WORD *)(a1 + 2) = result;
*(_QWORD *)(v3 + 8 * v2) = a1;
lua_nconstant = result + 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rsi
__int64 v3; // rdx
int v4; // eax

result = *(unsigned __int16 *)(a1 + 2);
if ( (_WORD)result == 0xFFFE )
{
v2 = (unsigned __int16)lua_nconstant;
result = (unsigned __int16)lua_nconstant;
if ( (unsigned __int16)lua_nconstant == lua_maxconstant )
{
v4 = luaI_growvector(&lua_constant, (unsigned __int16)lua_nconstant, 8LL, "constant table overflow", 65533LL);
v2 = (unsigned __int16)lua_nconstant;
lua_maxconstant = v4;
result = (unsigned __int16)lua_nconstant;
}
v3 = lua_constant;
*(_WORD *)(a1 + 2) = result;
*(_QWORD *)(v3 + 8 * v2) = a1;
lua_nconstant = result + 1;
}
return result;
}

original_code:
lua_Word luaI_findconstant (TaggedString *t)
{
 if (t->constindex == 0xFFFE)
 {
  if (lua_nconstant == lua_maxconstant)
    lua_maxconstant = (luaI_growvector((void**)&lua_constant,lua_maxconstant,sizeof(TaggedString *),"constant table overflow",((0x7fff * 2 + 1)-2)));
  t->constindex = lua_nconstant;
  lua_constant[lua_nconstant] = t;
  lua_nconstant++;
 }
 return t->constindex;
}

canonical_original_code:
unsigned short luaI_findconstant(struct TaggedString *t)
{
 if (t->constindex == 0xFFFE)
 {
  if (lua_nconstant == lua_maxconstant)
    lua_maxconstant = (luaI_growvector((void **)&lua_constant,lua_maxconstant,sizeof(struct TaggedString *),"constant table overflow",((0x7fff * 2 + 1)-2)));
  t->constindex = lua_nconstant;
  lua_constant[lua_nconstant] = t;
  lua_nconstant++;
 }
 return t->constindex;
}


repo: cskau/VM

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

result = lua_createstring();
if ( !*(_DWORD *)(result + 16) )
*(_DWORD *)(result + 16) = 2;
return result;
}

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

result = lua_createstring();
if ( !*(_DWORD *)(result + 16) )
*(_DWORD *)(result + 16) = 2;
return result;
}

original_code:
TaggedString *luaI_createfixedstring (char *name)
{
  TaggedString *ts = lua_createstring(name);
  if (!ts->marked)
    ts->marked = 2;
  return ts;
}

canonical_original_code:
struct TaggedString *luaI_createfixedstring(char *name)
{
  struct TaggedString *ts = lua_createstring(name);
  if (!ts->marked)
    ts->marked = 2;
  return ts;
}

variable_types:
name
char *

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


decompiled_code:
__int64 luaI_findsymbolbyname()
{
_WORD *v0; // rax

v0 = (_WORD *)luaI_createfixedstring();
return luaI_findsymbol(v0);
}

canonical_decompiled_code:
__int64 func6()
{
_WORD *v0; // rax

v0 = (_WORD *)func5();
return func3(v0);
}

original_code:
lua_Word luaI_findsymbolbyname (char *name)
{
  return luaI_findsymbol(luaI_createfixedstring(name));
}

canonical_original_code:
unsigned short luaI_findsymbolbyname(char *name)
{
  return luaI_findsymbol(luaI_createfixedstring(name));
}

return_type: unsigned short


decompiled_code:
__int64 luaI_initsymbol()
{
void **v0; // rbx
const char *v1; // rdi
__int64 v2; // rax
__int64 v3; // rdx
__int64 v4; // rbx
__int64 result; // rax

v0 = &off_7C8;
lua_maxsymbol = 256LL;
v1 = "assert";
lua_table = luaI_realloc(0LL, 6144LL);
while ( 1 )
{
v0 += 2;
v2 = lua_table + 24LL * (unsigned __int16)luaI_findsymbolbyname(v1);
v3 = (__int64)*(v0 - 2);
*(_DWORD *)v2 = -6;
*(_QWORD *)(v2 + 8) = v3;
if ( v0 == (void **)&unk_8A8 )
break;
v1 = (const char *)*(v0 - 1);
}
v4 = lua_table + 24LL * (unsigned __int16)luaI_findsymbolbyname("_VERSION_");
*(_DWORD *)v4 = -3;
result = lua_createstring("Lua 2.5.1");
*(_QWORD *)(v4 + 8) = result;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
void **v0; // rbx
const char *v1; // rdi
__int64 v2; // rax
__int64 v3; // rdx
__int64 v4; // rbx
__int64 result; // rax

v0 = &off_7C8;
lua_maxsymbol = 256LL;
v1 = "assert";
lua_table = luaI_realloc(0LL, 6144LL);
while ( 1 )
{
v0 += 2;
v2 = lua_table + 24LL * (unsigned __int16)func6(v1);
v3 = (__int64)*(v0 - 2);
*(_DWORD *)v2 = -6;
*(_QWORD *)(v2 + 8) = v3;
if ( v0 == (void **)&unk_8A8 )
break;
v1 = (const char *)*(v0 - 1);
}
v4 = lua_table + 24LL * (unsigned __int16)func6("_VERSION_");
*(_DWORD *)v4 = -3;
result = lua_createstring("Lua 2.5.1");
*(_QWORD *)(v4 + 8) = result;
return result;
}

original_code:
void luaI_initsymbol (void)
{
  int i;
  lua_Word n;
  lua_maxsymbol = 256;
  lua_table = ((Symbol *)luaI_realloc(((void *)0), ((lua_maxsymbol)*sizeof(Symbol))));
  for (i=0; i<(sizeof(int_funcs)/sizeof(int_funcs[0])); i++)
  {
    n = luaI_findsymbolbyname(int_funcs[i].name);
    (((&(lua_table[n].object))->tag)) = LUA_T_CFUNCTION; (((&(lua_table[n].object))->value.f)) = int_funcs[i].func;
  }
  n = luaI_findsymbolbyname("_VERSION_");
  (((&(lua_table[n].object))->tag)) = LUA_T_STRING; (((&(lua_table[n].object))->value.ts)) = lua_createstring("Lua 2.5.1");
}

canonical_original_code:
void luaI_initsymbol()
{
  int i;
  unsigned short n;
  lua_maxsymbol = 256;
  lua_table = ((struct Symbol *)luaI_realloc(((void *)0), ((lua_maxsymbol)*sizeof(Symbol))));
  for (i=0; i<(sizeof(int_funcs)/sizeof(int_funcs[0])); i++)
  {
    n = luaI_findsymbolbyname(int_funcs[i].name);
    (((&(lua_table[n].object))->tag)) = LUA_T_CFUNCTION; (((&(lua_table[n].object))->value.f)) = int_funcs[i].func;
  }
  n = luaI_findsymbolbyname("_VERSION_");
  (((&(lua_table[n].object))->tag)) = LUA_T_STRING; (((&(lua_table[n].object))->value.ts)) = lua_createstring("Lua 2.5.1");
}

variable_types: i int

variable_types:
n
unsigned short

return_type: void

user_defined_types: struct Symbol { struct Object object; struct TaggedString *varname; }

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

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 }

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 TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; }

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

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

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


decompiled_code:
__int64 __fastcall lua_nextvar(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
__int64 result; // rax
__int64 v4; // rdx
unsigned __int16 v5; // cx
__int64 v6; // rbx
unsigned __int64 v7; // rdx
__int64 v8; // rax

v2 = lua_getparam(1LL);
if ( !v2 )
lua_error("too few arguments to function `nextvar'");
if ( (unsigned int)lua_getparam(2LL) )
lua_error("too many arguments to function `nextvar'");
result = lua_type(v2);
v5 = 0;
if ( (_DWORD)result != -1 )
{
if ( !(unsigned int)lua_isstring(v2, a2, v4, 0LL) )
return lua_error("incorrect argument to function `nextvar'");
v8 = lua_getstring(v2);
result = luaI_findsymbolbyname(v8);
v5 = result + 1;
}
if ( v5 < (unsigned __int16)lua_ntable )
{
result = lua_table;
v6 = 24LL * v5;
v7 = 24 * (v5 + (unsigned __int64)(unsigned __int16)(lua_ntable - 1 - v5) + 1);
while ( *(_DWORD *)(lua_table + v6) == -1 )
{
v6 += 24LL;
if ( v6 == v7 )
return result;
}
lua_pushstring(*(_QWORD *)(lua_table + v6 + 16) + 20LL, v5, v7);
result = luaI_pushobject(v6 + lua_table);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
__int64 result; // rax
__int64 v4; // rdx
unsigned __int16 v5; // cx
__int64 v6; // rbx
unsigned __int64 v7; // rdx
__int64 v8; // rax

v2 = lua_getparam(1LL);
if ( !v2 )
lua_error("too few arguments to function `nextvar'");
if ( (unsigned int)lua_getparam(2LL) )
lua_error("too many arguments to function `nextvar'");
result = lua_type(v2);
v5 = 0;
if ( (_DWORD)result != -1 )
{
if ( !(unsigned int)lua_isstring(v2, a2, v4, 0LL) )
return lua_error("incorrect argument to function `nextvar'");
v8 = lua_getstring(v2);
result = func6(v8);
v5 = result + 1;
}
if ( v5 < (unsigned __int16)lua_ntable )
{
result = lua_table;
v6 = 24LL * v5;
v7 = 24 * (v5 + (unsigned __int64)(unsigned __int16)(lua_ntable - 1 - v5) + 1);
while ( *(_DWORD *)(lua_table + v6) == -1 )
{
v6 += 24LL;
if ( v6 == v7 )
return result;
}
lua_pushstring(*(_QWORD *)(lua_table + v6 + 16) + 20LL, v5, v7);
result = luaI_pushobject(v6 + lua_table);
}
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


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


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


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


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:
__int64 lua_pack()
{
__int64 result; // rax
__int64 v2; // rax

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

canonical_decompiled_code:
__int64 func13()
{
__int64 result; // rax
__int64 v2; // rax

result = nentity_1;
if ( nentity_1++ >= (unsigned __int64)block_0 )
{
v2 = func12();
nentity_1 -= v2;
result = 2 * (block_0 - v2);
block_0 = result;
}
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
__int64 v4; // rax
const char *v5; // r8

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

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

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

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


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

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

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

lua_pack();
result = function_root;
*(_DWORD *)(a1 + 8) = 0;
function_root = a1;
*(_QWORD *)a1 = result;
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()
{
__int64 v0; // r12
_QWORD *v1; // rbx
_QWORD *v2; // rbp
__int64 v3; // rdi

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

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

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

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:
char *__fastcall luaI_registerlocalvar(__int64 a1, int a2)
{
int v2; // edx
char *result; // rax
int v4; // eax

v2 = numcurrvars;
if ( numcurrvars >= maxcurrvars )
{
v4 = luaI_growvector(&currvars, maxcurrvars, 16LL, &unk_2D4, 65533LL);
v2 = numcurrvars;
maxcurrvars = v4;
}
result = (char *)currvars + 16 * v2;
numcurrvars = v2 + 1;
*(_QWORD *)result = a1;
*((_DWORD *)result + 2) = a2;
return result;
}

canonical_decompiled_code:
char *__fastcall func5(__int64 a1, int a2)
{
int v2; // edx
char *result; // rax
int v4; // eax

v2 = numcurrvars;
if ( numcurrvars >= maxcurrvars )
{
v4 = luaI_growvector(&currvars, maxcurrvars, 16LL, &unk_2D4, 65533LL);
v2 = numcurrvars;
maxcurrvars = v4;
}
result = (char *)currvars + 16 * v2;
numcurrvars = v2 + 1;
*(_QWORD *)result = a1;
*((_DWORD *)result + 2) = a2;
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: line int


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

canonical_decompiled_code:
char *__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:
void *__fastcall luaI_closelocalvars(__int64 a1)
{
void *v1; // rax
size_t v2; // rbx
const void *v3; // rsi
void *result; // rax
size_t v5; // rbx

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

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

v1 = (void *)luaI_realloc(0LL, 16LL * (numcurrvars + 1));
v2 = numcurrvars;
v3 = currvars;
*(_QWORD *)(a1 + 40) = v1;
v2 *= 16LL;
result = memcpy(v1, v3, v2);
v5 = *(_QWORD *)(a1 + 40) + v2;
numcurrvars = 0;
*(_QWORD *)v5 = 0LL;
*(_DWORD *)(v5 + 8) = -1;
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; // rbp
_QWORD *v2; // rbx
__int64 result; // rax

v1 = a1;
if ( dumping )
result = DumpHeader(D);
if ( a1 )
{
while ( 1 )
{
if ( listing )
{
PrintFunction(v1);
if ( !dumping )
goto LABEL_6;
}
else if ( !dumping )
{
goto LABEL_6;
}
DumpFunction(v1, D);
LABEL_6:
v2 = (_QWORD *)*v1;
result = luaI_freefunc(v1);
if ( !v2 )
return result;
v1 = v2;
}
}
return result;
}

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

v1 = a1;
if ( dumping )
result = DumpHeader(D);
if ( a1 )
{
while ( 1 )
{
if ( listing )
{
PrintFunction(v1);
if ( !dumping )
goto LABEL_6;
}
else if ( !dumping )
{
goto LABEL_6;
}
DumpFunction(v1, D);
LABEL_6:
v2 = (_QWORD *)*v1;
result = luaI_freefunc(v1);
if ( !v2 )
return result;
v1 = v2;
}
}
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; // rbp

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

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; // ebp
const char **v4; // r13
int v5; // ebx
const char *v6; // r12
_BYTE *v7; // rax
int v8; // ebx
const char **v9; // rax
char **v10; // rbp
__int64 v11; // r13
const char **v12; // rbx
FILE *v13; // rax
char *v14; // rdi

if ( argc <= 1 )
goto LABEL_10;
v3 = argc;
v4 = argv;
v5 = 1;
v6 = "luac.out";
while ( 1 )
{
argv = (const char **)(8LL * v5);
v7 = *(const char **)((char *)argv + (_QWORD)v4);
if ( *v7 != 45 )
break;
envp = (const char **)(unsigned __int8)v7[1];
if ( !v7[1] )
break;
if ( (_DWORD)envp != 100 || v7[2] )
{
if ( v7[1] == 108 && !v7[2] )
{
listing = 1;
goto LABEL_5;
}
if ( v7[1] == 111 && !v7[2] )
{
v6 = *(const char **)((char *)argv + (_QWORD)v4 + 8);
++v5;
goto LABEL_5;
}
if ( v7[1] == 112 && !v7[2] )
{
dumping = 0;
goto LABEL_5;
}
if ( v7[1] != 118 || v7[2] )
goto LABEL_10;
++v5;
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");
if ( v3 <= v5 )
break;
}
else
{
lua_debug = 1;
LABEL_5:
if ( v3 <= ++v5 )
break;
}
}
v8 = v5 - 1;
*(_QWORD *)&argc = (unsigned int)(v3 - v8);
v9 = &v4[v8];
if ( argc <= 1 )
LABEL_10:
usage(*(_QWORD *)&argc, argv, envp);
v10 = (char **)(v9 + 1);
v11 = (__int64)&v9[(unsigned int)(argc - 2) + 2];
v12 = v9 + 1;
do
{
if ( !strcmp(*v12, v6) )
{
fprintf(stderr, "luac: will not overwrite input file \"%s\"\n", v6);
exit(1);
}
++v12;
}
while ( v12 != (const char **)v11 );
v13 = stdout;
if ( dumping )
v13 = fopen(v6, "wb");
D = v13;
if ( !v13 )
{
fwrite("luac: cannot open ", 1uLL, 0x12uLL, stderr);
perror(v6);
exit(1);
}
do
{
v14 = *v10;
if ( **v10 == 45 && !v14[1] )
v14 = 0LL;
compile(v14);
++v10;
}
while ( v10 != (char **)v11 );
fclose(D);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
const char **v4; // r13
int v5; // ebx
const char *v6; // r12
_BYTE *v7; // rax
int v8; // ebx
const char **v9; // rax
char **v10; // rbp
__int64 v11; // r13
const char **v12; // rbx
FILE *v13; // rax
char *v14; // rdi

if ( argc <= 1 )
goto LABEL_10;
v3 = argc;
v4 = argv;
v5 = 1;
v6 = "luac.out";
while ( 1 )
{
argv = (const char **)(8LL * v5);
v7 = *(const char **)((char *)argv + (_QWORD)v4);
if ( *v7 != 45 )
break;
envp = (const char **)(unsigned __int8)v7[1];
if ( !v7[1] )
break;
if ( (_DWORD)envp != 100 || v7[2] )
{
if ( v7[1] == 108 && !v7[2] )
{
listing = 1;
goto LABEL_5;
}
if ( v7[1] == 111 && !v7[2] )
{
v6 = *(const char **)((char *)argv + (_QWORD)v4 + 8);
++v5;
goto LABEL_5;
}
if ( v7[1] == 112 && !v7[2] )
{
dumping = 0;
goto LABEL_5;
}
if ( v7[1] != 118 || v7[2] )
goto LABEL_10;
++v5;
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");
if ( v3 <= v5 )
break;
}
else
{
lua_debug = 1;
LABEL_5:
if ( v3 <= ++v5 )
break;
}
}
v8 = v5 - 1;
*(_QWORD *)&argc = (unsigned int)(v3 - v8);
v9 = &v4[v8];
if ( argc <= 1 )
LABEL_10:
func0(*(_QWORD *)&argc, argv, envp);
v10 = (char **)(v9 + 1);
v11 = (__int64)&v9[(unsigned int)(argc - 2) + 2];
v12 = v9 + 1;
do
{
if ( !strcmp(*v12, v6) )
{
fprintf(stderr, "luac: will not overwrite input file \"%s\"\n", v6);
exit(1);
}
++v12;
}
while ( v12 != (const char **)v11 );
v13 = stdout;
if ( dumping )
v13 = fopen(v6, "wb");
D = v13;
if ( !v13 )
{
fwrite("luac: cannot open ", 1uLL, 0x12uLL, stderr);
perror(v6);
exit(1);
}
do
{
v14 = *v10;
if ( **v10 == 45 && !v14[1] )
v14 = 0LL;
func3(v14);
++v10;
}
while ( v10 != (char **)v11 );
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
__int64 v3; // rdx
__int64 v4; // rax

v1 = *a1;
for ( result = 0LL; *a1; result = v3 ^ v4 )
{
++a1;
v3 = 31 * result;
v4 = v1;
v1 = *a1;
}
return result;
}

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

v1 = *a1;
for ( result = 0LL; *a1; result = v3 ^ v4 )
{
++a1;
v3 = 31 * result;
v4 = v1;
v1 = *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

decompiled_code:
__int64 __fastcall grow(int *a1)
{
int v2; // eax
unsigned __int64 v3; // r13
size_t v4; // r14
int v5; // ebx
char *v6; // rax
char *v7; // rbp
int v8; // eax
_QWORD *v9; // r8
_QWORD *v10; // rcx
__int64 v11; // rdi
_QWORD *v12; // rsi
unsigned __int64 v13; // rdx
char *i; // rax
__int64 result; // rax

v2 = luaI_redimension((unsigned int)*a1);
v3 = v2;
v4 = 8LL * v2;
v5 = v2;
v6 = (char *)luaI_realloc(0LL, v4);
v7 = v6;
if ( (int)v3 > 0 )
memset(v6, 0, v4);
v8 = *a1;
v9 = (_QWORD *)*((_QWORD *)a1 + 1);
a1[1] = 0;
if ( v8 > 0 )
{
v10 = v9;
v11 = (__int64)&v9[(unsigned int)(v8 - 1) + 1];
do
{
v12 = (_QWORD *)*v10;
if ( (_UNKNOWN *)*v10 != &EMPTY && v12 )
{
v13 = v12[1] % v3;
for ( i = &v7[8 * (int)v13]; *(_QWORD *)i; i = &v7[8 * (int)v13] )
LODWORD(v13) = ((int)v13 + 1) % v5;
*(_QWORD *)i = v12;
++a1[1];
}
++v10;
}
while ( v10 != (_QWORD *)v11 );
}
result = luaI_free(v9);
*a1 = v5;
*((_QWORD *)a1 + 1) = v7;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int *a1)
{
int v2; // eax
unsigned __int64 v3; // r13
size_t v4; // r14
int v5; // ebx
char *v6; // rax
char *v7; // rbp
int v8; // eax
_QWORD *v9; // r8
_QWORD *v10; // rcx
__int64 v11; // rdi
_QWORD *v12; // rsi
unsigned __int64 v13; // rdx
char *i; // rax
__int64 result; // rax

v2 = luaI_redimension((unsigned int)*a1);
v3 = v2;
v4 = 8LL * v2;
v5 = v2;
v6 = (char *)luaI_realloc(0LL, v4);
v7 = v6;
if ( (int)v3 > 0 )
memset(v6, 0, v4);
v8 = *a1;
v9 = (_QWORD *)*((_QWORD *)a1 + 1);
a1[1] = 0;
if ( v8 > 0 )
{
v10 = v9;
v11 = (__int64)&v9[(unsigned int)(v8 - 1) + 1];
do
{
v12 = (_QWORD *)*v10;
if ( (_UNKNOWN *)*v10 != &EMPTY && v12 )
{
v13 = v12[1] % v3;
for ( i = &v7[8 * (int)v13]; *(_QWORD *)i; i = &v7[8 * (int)v13] )
LODWORD(v13) = ((int)v13 + 1) % v5;
*(_QWORD *)i = v12;
++a1[1];
}
++v10;
}
while ( v10 != (_QWORD *)v11 );
}
result = luaI_free(v9);
*a1 = v5;
*((_QWORD *)a1 + 1) = v7;
return result;
}

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: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *

variable_types: j int


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

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


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


hashindex

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

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

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

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


decompiled_code:
__int64 call_fallbacks()
{
__int64 v0; // rbx
int i; // [rsp+0h] [rbp+0h] BYREF
__int64 vars8; // [rsp+8h] [rbp+8h]

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

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbx
int i; // [rsp+0h] [rbp+0h] BYREF
__int64 vars8; // [rsp+8h] [rbp+8h]

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

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


hashnext

decompiled_code:
unsigned __int64 __fastcall hashnext(__int64 a1, int a2)
{
unsigned __int64 result; // rax
__int64 v4; // rbx
_DWORD *i; // rdi

result = *(unsigned int *)(a1 + 16);
if ( (int)result > a2 )
{
v4 = 32LL * a2;
result = 32 * (a2 + (unsigned __int64)(unsigned int)(~a2 + result) + 1);
for ( i = (_DWORD *)(v4 + *(_QWORD *)(a1 + 8)); *i == -1 || i[4] == -1; i += 8 )
{
v4 += 32LL;
if ( v4 == result )
return result;
}
((void (*)(void))luaI_pushobject)();
result = luaI_pushobject(*(_QWORD *)(a1 + 8) + v4 + 16);
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(__int64 a1, int a2)
{
unsigned __int64 result; // rax
__int64 v4; // rbx
_DWORD *i; // rdi

result = *(unsigned int *)(a1 + 16);
if ( (int)result > a2 )
{
v4 = 32LL * a2;
result = 32 * (a2 + (unsigned __int64)(unsigned int)(~a2 + result) + 1);
for ( i = (_DWORD *)(v4 + *(_QWORD *)(a1 + 8)); *i == -1 || i[4] == -1; i += 8 )
{
v4 += 32LL;
if ( v4 == result )
return result;
}
((void (*)(void))luaI_pushobject)();
result = luaI_pushobject(*(_QWORD *)(a1 + 8) + v4 + 16);
}
return result;
}

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)
{
__int64 *v1; // rdx
__int64 result; // rax

v1 = (__int64 *)&unk_7A8;
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)
{
__int64 *v1; // rdx
__int64 result; // rax

v1 = (__int64 *)&unk_7A8;
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; // r12
int v2; // ebx
_DWORD *v3; // rax
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
__int64 v1; // r12
int v2; // ebx
_DWORD *v3; // rax
__int64 result; // rax

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

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

v2 = *(_DWORD *)a1;
v3 = 0;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 < 0xFFFFFFFA )
{
LABEL_4:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
}
else
{
switch ( v2 )
{
case 0xFFFFFFFA:
case 0xFFFFFFFB:
case 0xFFFFFFFC:
case 0xFFFFFFFD:
goto LABEL_4;
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; // er8

v2 = *(_DWORD *)a1;
v3 = 0;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 < 0xFFFFFFFA )
{
LABEL_4:
v3 = *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8);
}
else
{
switch ( v2 )
{
case 0xFFFFFFFA:
case 0xFFFFFFFB:
case 0xFFFFFFFC:
case 0xFFFFFFFD:
goto LABEL_4;
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)
{
__int64 v3; // r9
_DWORD *i; // rsi
__int64 v5; // rcx

LODWORD(v3) = hashindex(a1, a2);
for ( i = (_DWORD *)(*(_QWORD *)(a1 + 8) + 32LL * (int)v3); *i != -1; i = (_DWORD *)(v5 + 32 * v3) )
{
if ( lua_equalObj((__int64)a2, (__int64)i) )
break;
v3 = ((int)v3 + 1) % *(_DWORD *)(a1 + 16);
}
return (unsigned int)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; } *


decompiled_code:
__int64 __fastcall lua_hashmark(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp
_DWORD *v3; // rbx

if ( !*(_BYTE *)(a1 + 24) )
{
result = *(unsigned int *)(a1 + 16);
*(_BYTE *)(a1 + 24) = 1;
if ( (int)result > 0 )
{
v2 = 0LL;
do
{
v3 = (_DWORD *)(*(_QWORD *)(a1 + 8) + 32 * v2);
if ( *v3 != -1 )
{
lua_markobject(*(_QWORD *)(a1 + 8) + 32 * v2);
result = lua_markobject(v3 + 4);
}
++v2;
}
while ( *(_DWORD *)(a1 + 16) > (int)v2 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp
_DWORD *v3; // rbx

if ( !*(_BYTE *)(a1 + 24) )
{
result = *(unsigned int *)(a1 + 16);
*(_BYTE *)(a1 + 24) = 1;
if ( (int)result > 0 )
{
v2 = 0LL;
do
{
v3 = (_DWORD *)(*(_QWORD *)(a1 + 8) + 32 * v2);
if ( *v3 != -1 )
{
lua_markobject(*(_QWORD *)(a1 + 8) + 32 * v2);
result = lua_markobject(v3 + 4);
}
++v2;
}
while ( *(_DWORD *)(a1 + 16) > (int)v2 );
}
}
return result;
}

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()
{
__int64 v0; // r12
_QWORD *v1; // rbx
_QWORD *v2; // rbp
__int64 v3; // rdi

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

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:
unsigned __int64 lua_next()
{
unsigned int v0; // ebp
unsigned int v1; // eax
unsigned int v2; // er12
__int64 v3; // rbp
int v4; // esi
_DWORD *v5; // rax

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);
v4 = 0;
if ( (unsigned int)lua_type(v2) != -1 )
{
v5 = (_DWORD *)luaI_Address(v2);
v4 = present(v3, v5) + 1;
}
return hashnext(v3, v4);
}

canonical_decompiled_code:
unsigned __int64 func11()
{
unsigned int v0; // ebp
unsigned int v1; // eax
unsigned int v2; // er12
__int64 v3; // rbp
int v4; // esi
_DWORD *v5; // rax

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);
v4 = 0;
if ( (unsigned int)lua_type(v2) != -1 )
{
v5 = (_DWORD *)luaI_Address(v2);
v4 = func7(v3, v5) + 1;
}
return func3(v3, v4);
}

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 __fastcall math_pow(__m128i a1)
{
unsigned int v1; // ebp
unsigned int v2; // er12
unsigned int v3; // er13
unsigned int v4; // er14
__int64 result; // rax
float v6; // ebp
double v7; // xmm0_8
float v8; // xmm0_4

v1 = lua_getparam(1LL);
v2 = lua_getparam(2LL);
v3 = lua_getparam(3LL);
if ( (unsigned int)lua_isnumber(v1) && (unsigned int)lua_isnumber(v2) && *(_BYTE *)lua_getstring(v3) == 112 )
{
*(double *)a1.m128i_i64 = lua_getnumber(v1);
v6 = COERCE_FLOAT(_mm_cvtsi128_si32(a1));
v7 = lua_getnumber(v2);
v8 = pow(v6, *(float *)&v7);
result = lua_pushnumber(v8);
}
else
{
v4 = lua_getref((unsigned int)old_pow);
lua_pushobject(v1);
lua_pushobject(v2);
lua_pushobject(v3);
result = lua_callfunction(v4);
if ( (_DWORD)result )
result = lua_error(0LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__m128i a1)
{
unsigned int v1; // ebp
unsigned int v2; // er12
unsigned int v3; // er13
unsigned int v4; // er14
__int64 result; // rax
float v6; // ebp
double v7; // xmm0_8
float v8; // xmm0_4

v1 = lua_getparam(1LL);
v2 = lua_getparam(2LL);
v3 = lua_getparam(3LL);
if ( (unsigned int)lua_isnumber(v1) && (unsigned int)lua_isnumber(v2) && *(_BYTE *)lua_getstring(v3) == 112 )
{
*(double *)a1.m128i_i64 = lua_getnumber(v1);
v6 = COERCE_FLOAT(_mm_cvtsi128_si32(a1));
v7 = lua_getnumber(v2);
v8 = pow(v6, *(float *)&v7);
result = lua_pushnumber(v8);
}
else
{
v4 = lua_getref((unsigned int)old_pow);
lua_pushobject(v1);
lua_pushobject(v2);
lua_pushobject(v3);
result = lua_callfunction(v4);
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_8BC);
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_8BC);
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_8C0);
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 v0; // ebx
float v1; // xmm0_4
double i; // [rsp+8h] [rbp-10h]

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

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

v0 = 1;
for ( i = lua_check_number(1LL, &unk_8C4); (unsigned int)lua_getparam(++v0); i = fmax(
lua_check_number(v0, &unk_8C4),
i) )
;
v1 = i;
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 v0; // ebx
float v1; // xmm0_4
double i; // [rsp+8h] [rbp-10h]

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

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

v0 = 1;
for ( i = lua_check_number(1LL, &unk_8C8); (unsigned int)lua_getparam(++v0); i = fmin(
lua_check_number(v0, &unk_8C8),
i) )
;
v1 = i;
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_8D0);
if ( v0 < 0.0 )
*(_QWORD *)&v0 ^= LC9;
v1 = v0;
return lua_pushnumber(v1);
}

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

v0 = lua_check_number(1LL, &unk_8D0);
if ( v0 < 0.0 )
*(_QWORD *)&v0 ^= LC9;
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 func7()
{
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 func8()
{
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 func9()
{
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 func10()
{
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 func11()
{
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 func12()
{
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));
}


decompiled_code:
__int64 math_ceil()
{
double v0; // xmm0_8
__m128d v1; // xmm3
__m128d v2; // xmm1
float v3; // xmm0_4

v0 = lua_check_number(1LL, "ceil");
if ( COERCE_DOUBLE(*(_QWORD *)&v0 & LC18) < 4.503599627370496e15 )
{
v1.m128d_f64[0] = v0;
v2.m128d_f64[0] = (double)(int)v0;
*(_QWORD *)&v0 = COERCE_UNSIGNED_INT64(v2.m128d_f64[0] + COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v1, v2) & LC19)) | ~LC18 & *(_QWORD *)&v0;
}
v3 = v0;
return lua_pushnumber(v3);
}

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; // xmm1_8
float v1; // xmm0_4
double y; // [rsp+8h] [rbp-10h]

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

canonical_decompiled_code:
__int64 func15()
{
double v0; // xmm1_8
float v1; // xmm0_4
double y; // [rsp+8h] [rbp-10h]

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

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()
{
return (unsigned int)*(char *)st++;
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)*(char *)st++;
}

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; // er12
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; // er12
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; // r12
int v2; // eax
__int64 v3; // rax
__int64 result; // rax
const void *v5; // rax
const void *v6; // rax
__int64 v7; // rax

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

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

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

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; // rbp
__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; // rbp
__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; // rbp
__int64 v1; // r12
__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'");
result = lua_dofile(0LL);
if ( (_DWORD)result )
return result;
goto LABEL_6;
}
}
result = lua_dofile(v1);
if ( (_DWORD)result )
return result;
LABEL_6:
result = passresults();
if ( !(_DWORD)result )
result = lua_pushusertag(0LL, 0LL);
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rbp
__int64 v1; // r12
__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'");
result = lua_dofile(0LL);
if ( (_DWORD)result )
return result;
goto LABEL_6;
}
}
result = lua_dofile(v1);
if ( (_DWORD)result )
return result;
LABEL_6:
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; // ebp
int v1; // ebx
__int64 result; // rax

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");
result = lua_pushnumber((float)v1);
}
else
{
switch ( v1 )
{
case -6:
case -5:
lua_pushstring("function");
result = lua_pushnumber((float)v1);
break;
case -4:
lua_pushstring("table");
result = lua_pushnumber((float)v1);
break;
case -3:
lua_pushstring("string");
result = lua_pushnumber((float)v1);
break;
case -2:
lua_pushstring("number");
result = lua_pushnumber((float)v1);
break;
case -1:
lua_pushstring("nil");
result = lua_pushnumber((float)v1);
break;
}
}
return result;
}

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

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");
result = lua_pushnumber((float)v1);
}
else
{
switch ( v1 )
{
case -6:
case -5:
lua_pushstring("function");
result = lua_pushnumber((float)v1);
break;
case -4:
lua_pushstring("table");
result = lua_pushnumber((float)v1);
break;
case -3:
lua_pushstring("string");
result = lua_pushnumber((float)v1);
break;
case -2:
lua_pushstring("number");
result = lua_pushnumber((float)v1);
break;
case -1:
lua_pushstring("nil");
result = lua_pushnumber((float)v1);
break;
}
}
return result;
}

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; // rbp
__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; // rbp
__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));
}