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

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

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

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

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

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


repo: cskau/VM

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

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

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

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

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

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

variable_types:
p
unsigned int

return_type: void


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

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

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

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

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

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

variable_types:
name
unsigned int

variable_types:
value
unsigned int


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

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

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

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

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

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


decompiled_code:
__int64 luaI_call()
{
int v0; // ebp
unsigned int v1; // er14
__int64 v2; // r12
int v3; // eax
int v4; // eax
__int64 v5; // r13
__int64 i; // rbx
unsigned int v7; // eax
unsigned int *v8; // rbx
unsigned int *v9; // rbp
__int64 v10; // rdi
__int64 result; // rax
int v12[2]; // [rsp+0h] [rbp-42Ch]
_BYTE v13[1064]; // [rsp+4h] [rbp-428h] BYREF

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

canonical_decompiled_code:
__int64 func18()
{
int v0; // ebp
unsigned int v1; // er14
__int64 v2; // r12
int v3; // eax
int v4; // eax
__int64 v5; // r13
__int64 i; // rbx
unsigned int v7; // eax
unsigned int *v8; // rbx
unsigned int *v9; // rbp
__int64 v10; // rdi
__int64 result; // rax
int v12[2]; // [rsp+0h] [rbp-42Ch]
_BYTE v13[1064]; // [rsp+4h] [rbp-428h] BYREF

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

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

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

variable_types:
f
unsigned int

variable_types:
arg
unsigned int

variable_types:
temp
unsigned int

variable_types:
params
unsigned int [256]

variable_types: narg int

variable_types: i int


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

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

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

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

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

variable_types:
funcname
char *

variable_types:
buff
char [100]


decompiled_code:
__int64 str_upper()
{
char *v0; // rbp
__int64 v1; // rbx
const __int32_t **v2; // r12
void *v3; // rax

v0 = (char *)lua_check_string(1LL, "strupper");
luaI_addchar(0);
v1 = *v0;
if ( (_BYTE)v1 )
{
v2 = _ctype_toupper_loc();
do
{
++v0;
luaI_addchar((*v2)[v1]);
v1 = *v0;
}
while ( (_BYTE)v1 );
}
v3 = luaI_addchar(0);
return lua_pushstring(v3);
}

canonical_decompiled_code:
__int64 func8()
{
char *v0; // rbp
__int64 v1; // rbx
const __int32_t **v2; // r12
void *v3; // rax

v0 = (char *)func1(1LL, "strupper");
func7(0);
v1 = *v0;
if ( (_BYTE)v1 )
{
v2 = _ctype_toupper_loc();
do
{
++v0;
func7((*v2)[v1]);
v1 = *v0;
}
while ( (_BYTE)v1 );
}
v3 = func7(0);
return lua_pushstring(v3);
}

original_code:
static void str_upper (void)
{
  char *s = lua_check_string(1, "strupper");
  luaI_addchar(0);
  while (*s)
    luaI_addchar(toupper(*s++));
  lua_pushstring(luaI_addchar(0));
}

canonical_original_code:
static void str_upper()
{
  char *s = lua_check_string(1, "strupper");
  luaI_addchar(0);
  while (*s)
    luaI_addchar(toupper(*s++));
  lua_pushstring(luaI_addchar(0));
}

variable_types:
s
char *


decompiled_code:
__int64 str_lower()
{
char *v0; // rbp
__int64 v1; // rbx
const __int32_t **v2; // r12
void *v3; // rax

v0 = (char *)lua_check_string(1LL, "strlower");
luaI_addchar(0);
v1 = *v0;
if ( (_BYTE)v1 )
{
v2 = _ctype_tolower_loc();
do
{
++v0;
luaI_addchar((*v2)[v1]);
v1 = *v0;
}
while ( (_BYTE)v1 );
}
v3 = luaI_addchar(0);
return lua_pushstring(v3);
}

canonical_decompiled_code:
__int64 func9()
{
char *v0; // rbp
__int64 v1; // rbx
const __int32_t **v2; // r12
void *v3; // rax

v0 = (char *)func1(1LL, "strlower");
func7(0);
v1 = *v0;
if ( (_BYTE)v1 )
{
v2 = _ctype_tolower_loc();
do
{
++v0;
func7((*v2)[v1]);
v1 = *v0;
}
while ( (_BYTE)v1 );
}
v3 = func7(0);
return lua_pushstring(v3);
}

original_code:
static void str_lower (void)
{
  char *s = lua_check_string(1, "strlower");
  luaI_addchar(0);
  while (*s)
    luaI_addchar(tolower(*s++));
  lua_pushstring(luaI_addchar(0));
}

canonical_original_code:
static void str_lower()
{
  char *s = lua_check_string(1, "strlower");
  luaI_addchar(0);
  while (*s)
    luaI_addchar(tolower(*s++));
  lua_pushstring(luaI_addchar(0));
}


decompiled_code:
__int64 __fastcall luaI_openlib(__int64 a1, int a2)
{
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdi
__int64 result; // rax

if ( a2 > 0 )
{
v2 = a1;
v3 = a1 + 16LL * (unsigned int)(a2 - 1) + 16;
do
{
v4 = *(_QWORD *)(v2 + 8);
v2 += 16LL;
lua_pushcfunction(v4);
result = lua_storeglobal(*(_QWORD *)(v2 - 16));
}
while ( v2 != v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, int a2)
{
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdi
__int64 result; // rax

if ( a2 > 0 )
{
v2 = a1;
v3 = a1 + 16LL * (unsigned int)(a2 - 1) + 16;
do
{
v4 = *(_QWORD *)(v2 + 8);
v2 += 16LL;
lua_pushcfunction(v4);
result = lua_storeglobal(*(_QWORD *)(v2 - 16));
}
while ( v2 != v3 );
}
return result;
}

original_code:
void luaI_openlib (struct lua_reg *l, int n)
{
  int i;
  for (i=0; i<n; i++)
    (lua_pushcfunction(l[i].func), lua_storeglobal(l[i].name));
}

canonical_original_code:
void luaI_openlib(struct lua_reg *l, int n)
{
  int i;
  for (i=0; i<n; i++)
    (lua_pushcfunction(l[i].func), lua_storeglobal(l[i].name));
}

variable_types: struct lua_reg { char *name; void (*func)(); } *

variable_types: n int


decompiled_code:
__int64 strlib_open()
{
return luaI_openlib((__int64)&strlib, 7);
}

canonical_decompiled_code:
__int64 func14()
{
return func13((__int64)&strlib, 7);
}

original_code:
void strlib_open (void)
{
  luaI_openlib(strlib, (sizeof(strlib)/sizeof(strlib[0])));
}

canonical_original_code:
void strlib_open()
{
  luaI_openlib(strlib, (sizeof(strlib)/sizeof(strlib[0])));
}


LocStr

decompiled_code:
void *__fastcall LocStr(int a1)
{
void *result; // rax

result = &unk_330;
if ( V )
result = (void *)(*(_QWORD *)(V + 16LL * a1) + 20LL);
return result;
}

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

result = &unk_330;
if ( V )
result = (void *)(*(_QWORD *)(V + 16LL * a1) + 20LL);
return result;
}

original_code:
static char* LocStr(int i)
{
 if (V==((void *)0)) return ""; else return V[i].varname->str;
}

canonical_original_code:
static char *LocStr(int i)
{
 if (V==((void *)0)) return ""; else return V[i].varname->str;
}

return_type: char *


PrintCode

decompiled_code:
void __fastcall PrintCode(unsigned __int8 *a1, unsigned __int8 *a2)
{
unsigned __int8 *v3; // rbp
unsigned int v4; // ebx
__int64 v5; // rsi
const char *v6; // rax
__int64 v7; // rsi
__int64 v8; // rsi
__int64 v9; // rdx
__int64 v10; // rsi
__int64 v11; // rdx
__int64 v12; // rax
__int64 v13; // rsi
const char *v14; // rax
float v15; // xmm0_4
int v16; // ebx
unsigned __int8 *v17; // r15
__int64 v18; // rdx
unsigned __int8 *v19; // rbx
unsigned __int8 *v20; // rbp
unsigned __int8 *v21; // rsi
__int64 v22; // rsi
unsigned __int8 v23; // [rsp+1h] [rbp-39h]

if ( a1 != a2 )
{
v3 = a1;
do
{
v4 = *v3;
if ( v4 > 0x43 )
v4 = 67;
printf("%6d\t%s", v3 - a1, OpCodeName[v4]);
switch ( v4 )
{
case 0u:
case 1u:
case 2u:
case 3u:
case 0x15u:
case 0x23u:
case 0x28u:
case 0x2Bu:
case 0x2Cu:
case 0x2Du:
case 0x2Eu:
case 0x2Fu:
case 0x30u:
case 0x31u:
case 0x32u:
case 0x33u:
case 0x34u:
case 0x35u:
case 0x36u:
case 0x37u:
case 0x3Eu:
case 0x40u:
goto LABEL_8;
case 4u:
case 0x24u:
case 0x25u:
case 0x29u:
case 0x41u:
v8 = v3[1];
v3 += 2;
printf("\t%d", v8);
break;
case 5u:
case 0x2Au:
case 0x38u:
case 0x39u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Du:
case 0x42u:
v7 = *(unsigned __int16 *)(v3 + 1);
v3 += 3;
printf("\t%d", v7);
break;
case 6u:
v15 = *(float *)(v3 + 1);
v3 += 5;
printf("\t%g", v15);
break;
case 7u:
case 0x16u:
v11 = *(unsigned __int16 *)(v3 + 1);
v3 += 3;
printf("\t%d\t; \"%s\"", v11, (const char *)(*(_QWORD *)(lua_constant + 8 * v11) + 20LL));
break;
case 8u:
v22 = *(_QWORD *)(v3 + 1);
v3 += 9;
printf("\t%p\t; \"%s\":%d", (const void *)v22, *(const char **)(v22 + 32), *(unsigned int *)(v22 + 24));
break;
case 9u:
case 0xAu:
case 0xBu:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x11u:
case 0x12u:
v5 = v4 - 9;
goto LABEL_7;
case 0x13u:
case 0x21u:
v13 = v3[1];
v3 += 2;
v14 = (const char *)LocStr(v13);
printf("\t%d\t; %s", v13, v14);
break;
case 0x14u:
case 0x22u:
v12 = *(unsigned __int16 *)(v3 + 1);
v3 += 3;
printf("\t%d\t; %s", v12, (const char *)(*(_QWORD *)(lua_table + 24 * v12 + 16) + 20LL));
break;
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Du:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
v5 = v4 - 23;
LABEL_7:
v6 = (const char *)LocStr(v5);
printf("\t%d\t; %s", v5, v6);
LABEL_8:
++v3;
break;
case 0x26u:
case 0x3Fu:
v9 = v3[2];
v10 = v3[1];
v3 += 3;
printf("\t%d %d", v10, v9);
break;
case 0x27u:
v16 = v3[1];
v17 = v3 + 2;
v23 = v3[1];
printf("\t%d", v23);
if ( v16 )
{
v18 = (unsigned int)(v16 + 1);
v19 = v3 + 2;
v20 = &v3[2 * v18];
do
{
v21 = v19;
v19 += 2;
printf("\n%6d\t FIELD", v21 - a1);
printf(
"\t%d\t; \"%s\"",
*((unsigned __int16 *)v19 - 1),
(const char *)(*(_QWORD *)(lua_constant + 8LL * *((unsigned __int16 *)v19 - 1)) + 20LL));
}
while ( v19 != v20 );
v3 = &v17[2 * v23];
}
else
{
v3 += 2;
}
break;
default:
printf("\tcannot happen: opcode=%d", *v3);
exit(1);
}
putchar(10);
}
while ( v3 != a2 );
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned __int8 *a1, unsigned __int8 *a2)
{
unsigned __int8 *v3; // rbp
unsigned int v4; // ebx
__int64 v5; // rsi
const char *v6; // rax
__int64 v7; // rsi
__int64 v8; // rsi
__int64 v9; // rdx
__int64 v10; // rsi
__int64 v11; // rdx
__int64 v12; // rax
__int64 v13; // rsi
const char *v14; // rax
float v15; // xmm0_4
int v16; // ebx
unsigned __int8 *v17; // r15
__int64 v18; // rdx
unsigned __int8 *v19; // rbx
unsigned __int8 *v20; // rbp
unsigned __int8 *v21; // rsi
__int64 v22; // rsi
unsigned __int8 v23; // [rsp+1h] [rbp-39h]

if ( a1 != a2 )
{
v3 = a1;
do
{
v4 = *v3;
if ( v4 > 0x43 )
v4 = 67;
printf("%6d\t%s", v3 - a1, OpCodeName[v4]);
switch ( v4 )
{
case 0u:
case 1u:
case 2u:
case 3u:
case 0x15u:
case 0x23u:
case 0x28u:
case 0x2Bu:
case 0x2Cu:
case 0x2Du:
case 0x2Eu:
case 0x2Fu:
case 0x30u:
case 0x31u:
case 0x32u:
case 0x33u:
case 0x34u:
case 0x35u:
case 0x36u:
case 0x37u:
case 0x3Eu:
case 0x40u:
goto LABEL_8;
case 4u:
case 0x24u:
case 0x25u:
case 0x29u:
case 0x41u:
v8 = v3[1];
v3 += 2;
printf("\t%d", v8);
break;
case 5u:
case 0x2Au:
case 0x38u:
case 0x39u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Du:
case 0x42u:
v7 = *(unsigned __int16 *)(v3 + 1);
v3 += 3;
printf("\t%d", v7);
break;
case 6u:
v15 = *(float *)(v3 + 1);
v3 += 5;
printf("\t%g", v15);
break;
case 7u:
case 0x16u:
v11 = *(unsigned __int16 *)(v3 + 1);
v3 += 3;
printf("\t%d\t; \"%s\"", v11, (const char *)(*(_QWORD *)(lua_constant + 8 * v11) + 20LL));
break;
case 8u:
v22 = *(_QWORD *)(v3 + 1);
v3 += 9;
printf("\t%p\t; \"%s\":%d", (const void *)v22, *(const char **)(v22 + 32), *(unsigned int *)(v22 + 24));
break;
case 9u:
case 0xAu:
case 0xBu:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x11u:
case 0x12u:
v5 = v4 - 9;
goto LABEL_7;
case 0x13u:
case 0x21u:
v13 = v3[1];
v3 += 2;
v14 = (const char *)func0(v13);
printf("\t%d\t; %s", v13, v14);
break;
case 0x14u:
case 0x22u:
v12 = *(unsigned __int16 *)(v3 + 1);
v3 += 3;
printf("\t%d\t; %s", v12, (const char *)(*(_QWORD *)(lua_table + 24 * v12 + 16) + 20LL));
break;
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Du:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
v5 = v4 - 23;
LABEL_7:
v6 = (const char *)func0(v5);
printf("\t%d\t; %s", v5, v6);
LABEL_8:
++v3;
break;
case 0x26u:
case 0x3Fu:
v9 = v3[2];
v10 = v3[1];
v3 += 3;
printf("\t%d %d", v10, v9);
break;
case 0x27u:
v16 = v3[1];
v17 = v3 + 2;
v23 = v3[1];
printf("\t%d", v23);
if ( v16 )
{
v18 = (unsigned int)(v16 + 1);
v19 = v3 + 2;
v20 = &v3[2 * v18];
do
{
v21 = v19;
v19 += 2;
printf("\n%6d\t FIELD", v21 - a1);
printf(
"\t%d\t; \"%s\"",
*((unsigned __int16 *)v19 - 1),
(const char *)(*(_QWORD *)(lua_constant + 8LL * *((unsigned __int16 *)v19 - 1)) + 20LL));
}
while ( v19 != v20 );
v3 = &v17[2 * v23];
}
else
{
v3 += 2;
}
break;
default:
printf("\tcannot happen: opcode=%d", *v3);
exit(1);
}
putchar(10);
}
while ( v3 != a2 );
}
}

original_code:
static void PrintCode(lua_Byte* code, lua_Byte* end)
{
 lua_Byte* p;
 for (p=code; p!=end;)
 {
 OpCode op=(OpCode)*p;
 if (op>SETLINE) op=SETLINE+1;
 printf("%6d\t%s",(int)(p-code),OpCodeName[op]);
 switch (op)
 {
 case PUSHNIL:
 case PUSH0:
 case PUSH1:
 case PUSH2:
 case PUSHINDEXED:
 case STOREINDEXED0:
 case ADJUST0:
 case EQOP:
 case LTOP:
 case LEOP:
 case GTOP:
 case GEOP:
 case ADDOP:
 case SUBOP:
 case MULTOP:
 case DIVOP:
 case POWOP:
 case CONCOP:
 case MINUSOP:
 case NOTOP:
 case POP:
 case RETCODE0:
  p++;
  break;
 case PUSHLOCAL0:
 case PUSHLOCAL1:
 case PUSHLOCAL2:
 case PUSHLOCAL3:
 case PUSHLOCAL4:
 case PUSHLOCAL5:
 case PUSHLOCAL6:
 case PUSHLOCAL7:
 case PUSHLOCAL8:
 case PUSHLOCAL9:
 {
  int i=op-PUSHLOCAL0;
  printf("\t%d\t; %s",i,LocStr(i));
  p++;
  break;
 }
 case STORELOCAL0:
 case STORELOCAL1:
 case STORELOCAL2:
 case STORELOCAL3:
 case STORELOCAL4:
 case STORELOCAL5:
 case STORELOCAL6:
 case STORELOCAL7:
 case STORELOCAL8:
 case STORELOCAL9:
 {
  int i=op-STORELOCAL0;
  printf("\t%d\t; %s",i,LocStr(i));
  p++;
  break;
 }
 case PUSHLOCAL:
 case STORELOCAL:
 {
  int i=*(p+1);
  printf("\t%d\t; %s",i,LocStr(i));
  p+=2;
  break;
 }
 case PUSHBYTE:
 case STOREINDEXED:
 case STORELIST0:
 case ADJUST:
 case RETCODE:
  printf("\t%d",*(p+1));
  p+=2;
  break;
 case PUSHWORD:
 case CREATEARRAY:
 case ONTJMP:
 case ONFJMP:
 case JMP:
 case UPJMP:
 case IFFJMP:
 case IFFUPJMP:
 case SETLINE:
 {
  lua_Word w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  printf("\t%d",w);
  break;
 }
 case PUSHFLOAT:
 {
  float f;
  p++;
  {memcpy(&f, p, sizeof(float)); p+=sizeof(float);};
  printf("\t%g",f);
  break;
 }
 case PUSHSELF:
 case PUSHSTRING:
 {
  lua_Word w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  printf("\t%d\t; \"%s\"",w,(lua_constant[w]->str));
  break;
 }
 case PUSHFUNCTION:
 {
  TFunc* tf;
  p++;
  {memcpy(&tf, p, sizeof(TFunc *)); p+=sizeof(TFunc *);};
  printf("\t%p\t; \"%s\":%d",tf,tf->fileName,tf->lineDefined);
  break;
 }
 case PUSHGLOBAL:
 case STOREGLOBAL:
 {
  lua_Word w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  printf("\t%d\t; %s",w,(lua_table[w].varname->str));
  break;
 }
 case STORELIST:
 case CALLFUNC:
  printf("\t%d %d",*(p+1),*(p+2));
  p+=3;
  break;
 case STORERECORD:
 {
  int n=*++p;
  printf("\t%d",n);
  p++;
  while (n--)
  {
   lua_Word w;
   printf("\n%6d\t      FIELD",(int)(p-code));
   {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
   printf("\t%d\t; \"%s\"",w,(lua_constant[w]->str));
  }
  break;
 }
 default:
  printf("\tcannot happen:  opcode=%d",*p);
  exit(1);
  break;
 }
 printf("\n");
 }
}

canonical_original_code:
static void PrintCode(unsigned char *code, unsigned char *end)
{
 unsigned char *p;
 for (p=code; p!=end;)
 {
 enum OpCode op = (OpCode)*p;
 if (op>SETLINE) op=SETLINE+1;
 printf("%6d\t%s",(int)(p-code),OpCodeName[op]);
 switch (op)
 {
 case PUSHNIL:
 case PUSH0:
 case PUSH1:
 case PUSH2:
 case PUSHINDEXED:
 case STOREINDEXED0:
 case ADJUST0:
 case EQOP:
 case LTOP:
 case LEOP:
 case GTOP:
 case GEOP:
 case ADDOP:
 case SUBOP:
 case MULTOP:
 case DIVOP:
 case POWOP:
 case CONCOP:
 case MINUSOP:
 case NOTOP:
 case POP:
 case RETCODE0:
  p++;
  break;
 case PUSHLOCAL0:
 case PUSHLOCAL1:
 case PUSHLOCAL2:
 case PUSHLOCAL3:
 case PUSHLOCAL4:
 case PUSHLOCAL5:
 case PUSHLOCAL6:
 case PUSHLOCAL7:
 case PUSHLOCAL8:
 case PUSHLOCAL9:
 {
  int i = op-PUSHLOCAL0;
  printf("\t%d\t; %s",i,LocStr(i));
  p++;
  break;
 }
 case STORELOCAL0:
 case STORELOCAL1:
 case STORELOCAL2:
 case STORELOCAL3:
 case STORELOCAL4:
 case STORELOCAL5:
 case STORELOCAL6:
 case STORELOCAL7:
 case STORELOCAL8:
 case STORELOCAL9:
 {
  int i = op-STORELOCAL0;
  printf("\t%d\t; %s",i,LocStr(i));
  p++;
  break;
 }
 case PUSHLOCAL:
 case STORELOCAL:
 {
  int i = *(p+1);
  printf("\t%d\t; %s",i,LocStr(i));
  p+=2;
  break;
 }
 case PUSHBYTE:
 case STOREINDEXED:
 case STORELIST0:
 case ADJUST:
 case RETCODE:
  printf("\t%d",*(p+1));
  p+=2;
  break;
 case PUSHWORD:
 case CREATEARRAY:
 case ONTJMP:
 case ONFJMP:
 case JMP:
 case UPJMP:
 case IFFJMP:
 case IFFUPJMP:
 case SETLINE:
 {
  unsigned short w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  printf("\t%d",w);
  break;
 }
 case PUSHFLOAT:
 {
  float f;
  p++;
  {memcpy(&f, p, sizeof(float)); p+=sizeof(float);};
  printf("\t%g",f);
  break;
 }
 case PUSHSELF:
 case PUSHSTRING:
 {
  unsigned short w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  printf("\t%d\t; \"%s\"",w,(lua_constant[w]->str));
  break;
 }
 case PUSHFUNCTION:
 {
  struct TFunc *tf;
  p++;
  {memcpy(&tf, p, sizeof(struct TFunc *)); p+=sizeof(struct TFunc *);};
  printf("\t%p\t; \"%s\":%d",tf,tf->fileName,tf->lineDefined);
  break;
 }
 case PUSHGLOBAL:
 case STOREGLOBAL:
 {
  unsigned short w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  printf("\t%d\t; %s",w,(lua_table[w].varname->str));
  break;
 }
 case STORELIST:
 case CALLFUNC:
  printf("\t%d %d",*(p+1),*(p+2));
  p+=3;
  break;
 case STORERECORD:
 {
  int n = *++p;
  printf("\t%d",n);
  p++;
  while (n--)
  {
   unsigned short w;
   printf("\n%6d\t      FIELD",(int)(p-code));
   {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
   printf("\t%d\t; \"%s\"",w,(lua_constant[w]->str));
  }
  break;
 }
 default:
  printf("\tcannot happen:  opcode=%d",*p);
  exit(1);
  break;
 }
 printf("\n");
 }
}

variable_types:
code
unsigned char *

variable_types:
end
unsigned char *

variable_types:
p
unsigned char *

variable_types: enum OpCode { PUSHNIL=0, PUSH0=1, PUSH1=2, PUSH2=3, PUSHBYTE=4, PUSHWORD=5, PUSHFLOAT=6, PUSHSTRING=7, PUSHFUNCTION=8, PUSHLOCAL0=9, PUSHLOCAL1=10, PUSHLOCAL2=11, PUSHLOCAL3=12, PUSHLOCAL4=13, PUSHLOCAL5=14, PUSHLOCAL6=15, PUSHLOCAL7=16, PUSHLOCAL8=17, PUSHLOCAL9=18, PUSHLOCAL=19, PUSHGLOBAL=20, PUSHINDEXED=21, PUSHSELF=22, STORELOCAL0=23, STORELOCAL1=24, STORELOCAL2=25, STORELOCAL3=26, STORELOCAL4=27, STORELOCAL5=28, STORELOCAL6=29, STORELOCAL7=30, STORELOCAL8=31, STORELOCAL9=32, STORELOCAL=33, STOREGLOBAL=34, STOREINDEXED0=35, STOREINDEXED=36, STORELIST0=37, STORELIST=38, STORERECORD=39, ADJUST0=40, ADJUST=41, CREATEARRAY=42, EQOP=43, LTOP=44, LEOP=45, GTOP=46, GEOP=47, ADDOP=48, SUBOP=49, MULTOP=50, DIVOP=51, POWOP=52, CONCOP=53, MINUSOP=54, NOTOP=55, ONTJMP=56, ONFJMP=57, JMP=58, UPJMP=59, IFFJMP=60, IFFUPJMP=61, POP=62, CALLFUNC=63, RETCODE0=64, RETCODE=65, SETLINE=66, VARARGS=67 }

variable_types:
w
unsigned short

variable_types: f float

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

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

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


PrintFunction

decompiled_code:
void __fastcall PrintFunction(__int64 a1)
{
__int64 v1; // rdx
unsigned int v3; // er10
const char *v4; // rsi
unsigned __int8 *v5; // rdi
unsigned __int8 *v6; // rsi

v1 = *(unsigned int *)(a1 + 24);
v3 = *(_DWORD *)(a1 + 12);
v4 = *(const char **)(a1 + 32);
if ( (_DWORD)v1 )
printf(
"\nfunction \"%s\":%d (%d bytes at %p); used at main+%d\n",
v4,
v1,
v3,
(const void *)a1,
*(unsigned int *)(a1 + 8));
else
printf("\nmain of \"%s\" (%d bytes at %p)\n", v4, v3, (const void *)a1);
v5 = *(unsigned __int8 **)(a1 + 16);
v6 = &v5[*(int *)(a1 + 12)];
V = *(_QWORD *)(a1 + 40);
PrintCode(v5, v6);
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
__int64 v1; // rdx
unsigned int v3; // er10
const char *v4; // rsi
unsigned __int8 *v5; // rdi
unsigned __int8 *v6; // rsi

v1 = *(unsigned int *)(a1 + 24);
v3 = *(_DWORD *)(a1 + 12);
v4 = *(const char **)(a1 + 32);
if ( (_DWORD)v1 )
printf(
"\nfunction \"%s\":%d (%d bytes at %p); used at main+%d\n",
v4,
v1,
v3,
(const void *)a1,
*(unsigned int *)(a1 + 8));
else
printf("\nmain of \"%s\" (%d bytes at %p)\n", v4, v3, (const void *)a1);
v5 = *(unsigned __int8 **)(a1 + 16);
v6 = &v5[*(int *)(a1 + 12)];
V = *(_QWORD *)(a1 + 40);
func1(v5, v6);
}

original_code:
void PrintFunction(TFunc* tf)
{
 if ((tf->lineDefined==0))
  printf("\nmain of \"%s\" (%d bytes at %p)\n",tf->fileName,tf->size,tf);
 else
  printf("\nfunction \"%s\":%d (%d bytes at %p); used at main+%d\n",
 tf->fileName,tf->lineDefined,tf->size,tf,tf->marked);
 V=tf->locvars;
 PrintCode(tf->code,tf->code+tf->size);
}

canonical_original_code:
void PrintFunction(struct TFunc *tf)
{
 if ((tf->lineDefined==0))
  printf("\nmain of \"%s\" (%d bytes at %p)\n",tf->fileName,tf->size,tf);
 else
  printf("\nfunction \"%s\":%d (%d bytes at %p); used at main+%d\n",
 tf->fileName,tf->lineDefined,tf->size,tf,tf->marked);
 V=tf->locvars;
 PrintCode(tf->code,tf->code+tf->size);
}

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


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

result = 0LL;
input = a1;
current = 10;
lua_linenumber = 0;
return result;
}

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

result = 0LL;
input = a1;
current = 10;
lua_linenumber = 0;
return result;
}

original_code:
void lua_setinput (Input fn)
{
  current = '\n';
  lua_linenumber = 0;
  input = fn;
}

canonical_original_code:
void lua_setinput(int (*fn)())
{
  current = '\n';
  lua_linenumber = 0;
  input = fn;
}

variable_types:
fn
int (*)()


decompiled_code:
__int64 __fastcall luaI_syntaxerror(__int64 a1)
{
const char *v1; // rcx
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

v1 = (const char *)luaI_buffer(1LL);
if ( !*v1 )
v1 = "<eof>";
sprintf(v3, "%s;\n> last token read: \"%s\" at line %d in file %s", a1, v1, lua_linenumber, lua_parsedfile);
return lua_error(v3);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
const char *v1; // rcx
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

v1 = (const char *)luaI_buffer(1LL);
if ( !*v1 )
v1 = "<eof>";
sprintf(v3, "%s;\n> last token read: \"%s\" at line %d in file %s", a1, v1, lua_linenumber, lua_parsedfile);
return lua_error(v3);
}

original_code:
void luaI_syntaxerror (char *s)
{
  char msg[256];
  char *token = luaI_buffer(1);
  if (token[0] == 0)
    token = "<eof>";
  sprintf (msg,"%s;\n> last token read: \"%s\" at line %d in file %s",
           s, token, lua_linenumber, lua_parsedfile);
  lua_error (msg);
}

canonical_original_code:
void luaI_syntaxerror(char *s)
{
  char msg[256];
  char *token = luaI_buffer(1);
  if (token[0] == 0)
    token = "<eof>";
  sprintf (msg,"%s;\n> last token read: \"%s\" at line %d in file %s",
           s, token, lua_linenumber, lua_parsedfile);
  lua_error (msg);
}

variable_types:
msg
char [256]

variable_types:
token
char *


inclinenumber

decompiled_code:
__int64 __fastcall inclinenumber(int a1)
{
__int64 result; // rax
unsigned __int64 v2; // rbp
const char *v3; // r12
int v4; // ebx
const unsigned __int16 **v5; // r13

LOWORD(result) = ++lua_linenumber;
if ( !a1 || current != 36 )
return (unsigned __int16)result;
v2 = 0LL;
v3 = (const char *)luaI_buffer(261LL);
current = input();
v4 = current;
v5 = _ctype_b_loc();
while ( ((*v5)[v4] & 8) != 0 )
{
if ( v2 > 0x103 )
{
luaI_syntaxerror((__int64)"pragma too long");
LOBYTE(v4) = current;
}
v3[v2++] = v4;
current = input();
v4 = current;
}
v3[(int)v2] = 0;
if ( !strcmp(v3, "debug") )
{
lua_debug = 1;
LOWORD(result) = lua_linenumber;
}
else
{
if ( !strcmp(v3, "nodebug") )
lua_debug = 0;
else
luaI_syntaxerror((__int64)"invalid pragma");
LOWORD(result) = lua_linenumber;
}
return (unsigned __int16)result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 result; // rax
unsigned __int64 v2; // rbp
const char *v3; // r12
int v4; // ebx
const unsigned __int16 **v5; // r13

LOWORD(result) = ++lua_linenumber;
if ( !a1 || current != 36 )
return (unsigned __int16)result;
v2 = 0LL;
v3 = (const char *)luaI_buffer(261LL);
current = input();
v4 = current;
v5 = _ctype_b_loc();
while ( ((*v5)[v4] & 8) != 0 )
{
if ( v2 > 0x103 )
{
func1((__int64)"pragma too long");
LOBYTE(v4) = current;
}
v3[v2++] = v4;
current = input();
v4 = current;
}
v3[(int)v2] = 0;
if ( !strcmp(v3, "debug") )
{
lua_debug = 1;
LOWORD(result) = lua_linenumber;
}
else
{
if ( !strcmp(v3, "nodebug") )
lua_debug = 0;
else
func1((__int64)"invalid pragma");
LOWORD(result) = lua_linenumber;
}
return (unsigned __int16)result;
}

original_code:
static int inclinenumber (int pragma_allowed)
{
  ++lua_linenumber;
  if (pragma_allowed && current == '$') {
    char *buff = luaI_buffer(260 +1);
    int i = 0;
    (current = input());
    while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short int) _ISalnum)) {
      if (i >= 260) luaI_syntaxerror("pragma too long");
      buff[i++] = current;
      (current = input());
    }
    buff[i] = 0;
    if (strcmp(buff, "debug") == 0)
      lua_debug = 1;
    else if (strcmp(buff, "nodebug") == 0)
      lua_debug = 0;
    else luaI_syntaxerror("invalid pragma");
  }
  return lua_linenumber;
}

canonical_original_code:
static int inclinenumber(int pragma_allowed)
{
  ++lua_linenumber;
  if (pragma_allowed && current == '$') {
    char *buff = luaI_buffer(260 +1);
    int i = 0;
    (current = input());
    while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short) _ISalnum)) {
      if (i >= 260) luaI_syntaxerror("pragma too long");
      buff[i++] = current;
      (current = input());
    }
    buff[i] = 0;
    if (strcmp(buff, "debug") == 0)
      lua_debug = 1;
    else if (strcmp(buff, "nodebug") == 0)
      lua_debug = 0;
    else luaI_syntaxerror("invalid pragma");
  }
  return lua_linenumber;
}

variable_types:
buff
char *

return_type: int


decompiled_code:
__int64 luaI_addReserved()
{
const char *v0; // rdi
__int64 *i; // rbx
__int64 result; // rax
int v3; // edx

v0 = "and";
for ( i = (__int64 *)&unk_FE8; ; v0 = (const char *)*(i - 1) )
{
result = lua_createstring(v0);
v3 = *(_DWORD *)i;
i += 2;
*(_DWORD *)(result + 16) = v3;
if ( i == &LC9 )
break;
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
const char *v0; // rdi
__int64 *i; // rbx
__int64 result; // rax
int v3; // edx

v0 = "and";
for ( i = (__int64 *)&unk_FE8; ; v0 = (const char *)*(i - 1) )
{
result = lua_createstring(v0);
v3 = *(_DWORD *)i;
i += 2;
*(_DWORD *)(result + 16) = v3;
if ( i == &LC9 )
break;
}
return result;
}

original_code:
void luaI_addReserved (void)
{
  int i;
  for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++)
  {
    TaggedString *ts = lua_createstring(reserved[i].name);
    ts->marked = reserved[i].token;
  }
}

canonical_original_code:
void luaI_addReserved()
{
  int i;
  for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++)
  {
    struct TaggedString *ts = lua_createstring(reserved[i].name);
    ts->marked = reserved[i].token;
  }
}

variable_types: i int

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


decompiled_code:
__int64 __fastcall luaY_lex(double a1)
{
__int64 v1; // rax
char *v2; // rbp
unsigned int v3; // er12
__int64 (*v4)(void); // rbx
__int64 v5; // r13
const unsigned __int16 **v6; // r15
__int64 v7; // r14
__int64 v8; // rdx
const unsigned __int16 *v9; // rax
__int64 v10; // rax
int v11; // eax
_BYTE *v13; // r15
int v14; // er13
const unsigned __int16 **v15; // r14
__int64 v16; // rcx
const unsigned __int16 *v17; // rax
unsigned __int16 v18; // ax
char *v19; // rbx
double v20; // xmm1_8
__int64 v21; // rdx
const unsigned __int16 *v22; // rax
int v23; // er15
int v24; // er13
int v25; // eax
int v26; // ebx
int v27; // er12
__int64 v28; // r13
double v29; // xmm1_8
const unsigned __int16 *v30; // rdx
double v31; // xmm1_8
float v32; // xmm0_4
__int64 v33; // r14
int v34; // eax
int v35; // ebx
char *v36; // r13
int v37; // er15
int v38; // eax
int v39; // ebx
int v40; // eax
int v41; // eax
__int64 v42; // r12
__int64 v43; // rbx
int v44; // eax
char *v45; // r12
double v46; // [rsp+8h] [rbp-50h]
char v47; // [rsp+8h] [rbp-50h]
int v48; // [rsp+1Ch] [rbp-3Ch]

v1 = luaI_buffer(260LL);
*(_WORD *)(v1 + 1) = 0;
v2 = (char *)v1;
*(_BYTE *)(v1 + 3) = 0;
if ( lua_debug )
luaI_codedebugline((unsigned int)linelasttoken_0);
v3 = current;
linelasttoken_0 = lua_linenumber;
while ( 2 )
{
v4 = (__int64 (*)(void))input;
switch ( v3 )
{
case 9u:
case 0xDu:
case 0x20u:
current = ((__int64 (*)(void))input)();
v3 = current;
continue;
case 0xAu:
current = ((__int64 (*)(void))input)();
v38 = inclinenumber(1);
v3 = current;
linelasttoken_0 = v38;
continue;
case 0x22u:
case 0x27u:
v47 = v3;
v33 = 1LL;
*v2 = v3;
v34 = v4();
v35 = 260;
current = v34;
if ( v34 != v3 )
{
v36 = v2 + 1;
if ( v34 == 10 )
{
LABEL_44:
*v36 = 0;
return 257;
}
while ( v34 == 92 )
{
v34 = ((__int64 (*)(void))input)();
v37 = v33 + 1;
current = v34;
if ( v34 == 114 )
{
*v36 = 13;
v34 = ((__int64 (*)(void))input)();
current = v34;
}
else if ( v34 > 114 )
{
if ( v34 != 116 )
goto LABEL_39;
*v36 = 9;
v34 = ((__int64 (*)(void))input)();
current = v34;
}
else if ( v34 == 10 )
{
*v36 = 10;
current = ((__int64 (*)(void))input)();
inclinenumber(0);
v34 = current;
}
else
{
if ( v34 != 110 )
goto LABEL_39;
*v36 = 10;
v34 = ((__int64 (*)(void))input)();
current = v34;
}
LABEL_40:
if ( v34 == v3 )
{
v42 = v37;
v43 = v37 + 1;
goto LABEL_79;
}
if ( v35 - v37 <= 2 )
{
v35 *= 2;
v2 = (char *)luaI_buffer(v35);
v34 = current;
}
v36 = &v2[++v33];
if ( v34 == 10 )
goto LABEL_44;
}
if ( !v34 )
goto LABEL_44;
v37 = v33 + 1;
LABEL_39:
*v36 = v34;
v34 = ((__int64 (*)(void))input)();
current = v34;
goto LABEL_40;
}
v43 = 2LL;
v42 = 1LL;
LABEL_79:
v44 = ((__int64 (*)(void))input)();
v45 = &v2[v42];
*v45 = 0;
current = v44;
luaY_lval = luaI_findconstantbyname(v2 + 1);
*v45 = v47;
v3 = 273;
v2[v43] = 0;
return v3;
case 0x2Du:
*v2 = 45;
current = v4();
if ( current != 45 )
return v3;
do
{
v40 = ((__int64 (*)(void))input)();
current = v40;
v3 = v40;
}
while ( v40 != 10 && v40 );
continue;
case 0x2Eu:
*v2 = 46;
current = v4();
v39 = current;
if ( current == 46 )
{
v2[1] = 46;
v3 = 281;
current = ((__int64 (*)(void))input)();
if ( current == 46 )
{
v2[2] = 46;
v3 = 271;
current = ((__int64 (*)(void))input)();
}
}
else
{
v15 = _ctype_b_loc();
v18 = (*v15)[v39];
if ( (v18 & 0x800) != 0 )
{
v3 = v39;
v14 = 1;
v46 = 0.0;
LABEL_17:
v19 = &v2[v14];
v20 = *(double *)&LC8;
while ( 1 )
{
v23 = (_DWORD)v19 - (_DWORD)v2;
if ( (v18 & 0x800) == 0 )
break;
*v19++ = v3;
v46 = (double)(int)(v3 - 48) * v20 + v46;
a1 = *(double *)&LC9;
v20 = v20 / 10.0;
v21 = (int)((__int64 (*)(void))input)();
v22 = *v15;
current = v21;
v3 = v21;
v18 = v22[v21];
}
if ( (v3 & 0xFFFFFFDF) != 69 )
goto LABEL_32;
*v19 = v3;
v24 = v23 + 1;
v25 = input(a1, v20);
current = v25;
v26 = v25;
if ( ((v25 - 43) & 0xFFFFFFFD) == 0 )
{
v2[v24] = v25;
v24 = v23 + 2;
v25 = input(a1, v20);
current = v25;
}
if ( ((*v15)[v25] & 0x800) != 0 )
{
v27 = 0;
v28 = v24 + 1;
do
{
v2[v28 - 1] = v25;
v23 = v28++;
v29 = (double)v27 * 10.0 + (double)(v25 - 48);
v27 = (int)v29;
v25 = input(10.0, v29);
v30 = *v15;
current = v25;
}
while ( (v30[v25] & 0x800) != 0 );
v31 = *(double *)&LC8;
if ( v26 != 45 )
v31 = *(double *)&LC9;
if ( v27 > 0 )
{
do
{
if ( (v27 & 1) != 0 )
v46 = v46 * v31;
v31 = v31 * v31;
v27 >>= 1;
}
while ( v27 );
}
LABEL_32:
v32 = v46;
luaY_lval = LODWORD(v32);
v2[v23] = 0;
return 272;
}
v3 = 257;
v2[v24] = 0;
}
}
return v3;
case 0x30u:
case 0x31u:
case 0x32u:
case 0x33u:
case 0x34u:
case 0x35u:
case 0x36u:
case 0x37u:
case 0x38u:
case 0x39u:
v13 = v2;
v14 = 0;
a1 = *(double *)&LC9;
v15 = _ctype_b_loc();
v46 = 0.0;
while ( 1 )
{
*v13++ = v3;
v48 = v14++;
v46 = (double)(int)(v3 - 48) + v46 * 10.0;
v16 = (int)v4();
v17 = *v15;
current = v16;
v3 = v16;
v18 = v17[v16];
if ( (v18 & 0x800) == 0 )
break;
v4 = (__int64 (*)(void))input;
}
if ( (_DWORD)v16 == 46 )
{
v2[v14] = 46;
v41 = ((__int64 (*)(void))input)();
current = v41;
v3 = v41;
v14 = v48 + 2;
if ( v41 == 46 )
{
luaI_syntaxerror((__int64)"ambiguous syntax (decimal point x string concatenation)");
v3 = current;
v18 = (*v15)[current];
}
else
{
v18 = (*v15)[v41];
}
}
goto LABEL_17;
case 0x3Cu:
*v2 = 60;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 279;
current = ((__int64 (*)(void))input)();
}
return v3;
case 0x3Du:
*v2 = 61;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 277;
current = ((__int64 (*)(void))input)();
}
return v3;
case 0x3Eu:
*v2 = 62;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 280;
current = ((__int64 (*)(void))input)();
}
return v3;
case 0x41u:
case 0x42u:
case 0x43u:
case 0x44u:
case 0x45u:
case 0x46u:
case 0x47u:
case 0x48u:
case 0x49u:
case 0x4Au:
case 0x4Bu:
case 0x4Cu:
case 0x4Du:
case 0x4Eu:
case 0x4Fu:
case 0x50u:
case 0x51u:
case 0x52u:
case 0x53u:
case 0x54u:
case 0x55u:
case 0x56u:
case 0x57u:
case 0x58u:
case 0x59u:
case 0x5Au:
case 0x5Fu:
case 0x61u:
case 0x62u:
case 0x63u:
case 0x64u:
case 0x65u:
case 0x66u:
case 0x67u:
case 0x68u:
case 0x69u:
case 0x6Au:
case 0x6Bu:
case 0x6Cu:
case 0x6Du:
case 0x6Eu:
case 0x6Fu:
case 0x70u:
case 0x71u:
case 0x72u:
case 0x73u:
case 0x74u:
case 0x75u:
case 0x76u:
case 0x77u:
case 0x78u:
case 0x79u:
case 0x7Au:
v5 = 1LL;
v6 = _ctype_b_loc();
while ( 1 )
{
v2[v5 - 1] = v3;
v7 = (int)v5++;
v8 = (int)v4();
v9 = *v6;
current = v8;
LOBYTE(v3) = v8;
if ( (v9[v8] & 8) == 0 && (_DWORD)v8 != 95 )
break;
v4 = (__int64 (*)(void))input;
}
v2[v7] = 0;
v10 = lua_createstring(v2);
v3 = *(_DWORD *)(v10 + 16);
if ( (int)v3 <= 2 )
{
luaY_lval = v10;
v3 = 274;
*(_DWORD *)(v10 + 16) = 2;
}
return v3;
case 0x5Bu:
*v2 = 91;
current = v4();
if ( current != 91 )
return v3;
v2[1] = 91;
current = ((__int64 (*)(void))input)();
return read_long_string_constprop_0((__int64)v2);
case 0x7Eu:
*v2 = 126;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 278;
current = ((__int64 (*)(void))input)();
}
return v3;
default:
*v2 = v3;
v11 = v4();
v3 = *v2;
current = v11;
return v3;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func5(double a1)
{
__int64 v1; // rax
char *v2; // rbp
unsigned int v3; // er12
__int64 (*v4)(void); // rbx
__int64 v5; // r13
const unsigned __int16 **v6; // r15
__int64 v7; // r14
__int64 v8; // rdx
const unsigned __int16 *v9; // rax
__int64 v10; // rax
int v11; // eax
_BYTE *v13; // r15
int v14; // er13
const unsigned __int16 **v15; // r14
__int64 v16; // rcx
const unsigned __int16 *v17; // rax
unsigned __int16 v18; // ax
char *v19; // rbx
double v20; // xmm1_8
__int64 v21; // rdx
const unsigned __int16 *v22; // rax
int v23; // er15
int v24; // er13
int v25; // eax
int v26; // ebx
int v27; // er12
__int64 v28; // r13
double v29; // xmm1_8
const unsigned __int16 *v30; // rdx
double v31; // xmm1_8
float v32; // xmm0_4
__int64 v33; // r14
int v34; // eax
int v35; // ebx
char *v36; // r13
int v37; // er15
int v38; // eax
int v39; // ebx
int v40; // eax
int v41; // eax
__int64 v42; // r12
__int64 v43; // rbx
int v44; // eax
char *v45; // r12
double v46; // [rsp+8h] [rbp-50h]
char v47; // [rsp+8h] [rbp-50h]
int v48; // [rsp+1Ch] [rbp-3Ch]

v1 = luaI_buffer(260LL);
*(_WORD *)(v1 + 1) = 0;
v2 = (char *)v1;
*(_BYTE *)(v1 + 3) = 0;
if ( lua_debug )
luaI_codedebugline((unsigned int)linelasttoken_0);
v3 = current;
linelasttoken_0 = lua_linenumber;
while ( 2 )
{
v4 = (__int64 (*)(void))input;
switch ( v3 )
{
case 9u:
case 0xDu:
case 0x20u:
current = ((__int64 (*)(void))input)();
v3 = current;
continue;
case 0xAu:
current = ((__int64 (*)(void))input)();
v38 = func2(1);
v3 = current;
linelasttoken_0 = v38;
continue;
case 0x22u:
case 0x27u:
v47 = v3;
v33 = 1LL;
*v2 = v3;
v34 = v4();
v35 = 260;
current = v34;
if ( v34 != v3 )
{
v36 = v2 + 1;
if ( v34 == 10 )
{
LABEL_44:
*v36 = 0;
return 257;
}
while ( v34 == 92 )
{
v34 = ((__int64 (*)(void))input)();
v37 = v33 + 1;
current = v34;
if ( v34 == 114 )
{
*v36 = 13;
v34 = ((__int64 (*)(void))input)();
current = v34;
}
else if ( v34 > 114 )
{
if ( v34 != 116 )
goto LABEL_39;
*v36 = 9;
v34 = ((__int64 (*)(void))input)();
current = v34;
}
else if ( v34 == 10 )
{
*v36 = 10;
current = ((__int64 (*)(void))input)();
func2(0);
v34 = current;
}
else
{
if ( v34 != 110 )
goto LABEL_39;
*v36 = 10;
v34 = ((__int64 (*)(void))input)();
current = v34;
}
LABEL_40:
if ( v34 == v3 )
{
v42 = v37;
v43 = v37 + 1;
goto LABEL_79;
}
if ( v35 - v37 <= 2 )
{
v35 *= 2;
v2 = (char *)luaI_buffer(v35);
v34 = current;
}
v36 = &v2[++v33];
if ( v34 == 10 )
goto LABEL_44;
}
if ( !v34 )
goto LABEL_44;
v37 = v33 + 1;
LABEL_39:
*v36 = v34;
v34 = ((__int64 (*)(void))input)();
current = v34;
goto LABEL_40;
}
v43 = 2LL;
v42 = 1LL;
LABEL_79:
v44 = ((__int64 (*)(void))input)();
v45 = &v2[v42];
*v45 = 0;
current = v44;
luaY_lval = luaI_findconstantbyname(v2 + 1);
*v45 = v47;
v3 = 273;
v2[v43] = 0;
return v3;
case 0x2Du:
*v2 = 45;
current = v4();
if ( current != 45 )
return v3;
do
{
v40 = ((__int64 (*)(void))input)();
current = v40;
v3 = v40;
}
while ( v40 != 10 && v40 );
continue;
case 0x2Eu:
*v2 = 46;
current = v4();
v39 = current;
if ( current == 46 )
{
v2[1] = 46;
v3 = 281;
current = ((__int64 (*)(void))input)();
if ( current == 46 )
{
v2[2] = 46;
v3 = 271;
current = ((__int64 (*)(void))input)();
}
}
else
{
v15 = _ctype_b_loc();
v18 = (*v15)[v39];
if ( (v18 & 0x800) != 0 )
{
v3 = v39;
v14 = 1;
v46 = 0.0;
LABEL_17:
v19 = &v2[v14];
v20 = *(double *)&LC8;
while ( 1 )
{
v23 = (_DWORD)v19 - (_DWORD)v2;
if ( (v18 & 0x800) == 0 )
break;
*v19++ = v3;
v46 = (double)(int)(v3 - 48) * v20 + v46;
a1 = *(double *)&LC9;
v20 = v20 / 10.0;
v21 = (int)((__int64 (*)(void))input)();
v22 = *v15;
current = v21;
v3 = v21;
v18 = v22[v21];
}
if ( (v3 & 0xFFFFFFDF) != 69 )
goto LABEL_32;
*v19 = v3;
v24 = v23 + 1;
v25 = input(a1, v20);
current = v25;
v26 = v25;
if ( ((v25 - 43) & 0xFFFFFFFD) == 0 )
{
v2[v24] = v25;
v24 = v23 + 2;
v25 = input(a1, v20);
current = v25;
}
if ( ((*v15)[v25] & 0x800) != 0 )
{
v27 = 0;
v28 = v24 + 1;
do
{
v2[v28 - 1] = v25;
v23 = v28++;
v29 = (double)v27 * 10.0 + (double)(v25 - 48);
v27 = (int)v29;
v25 = input(10.0, v29);
v30 = *v15;
current = v25;
}
while ( (v30[v25] & 0x800) != 0 );
v31 = *(double *)&LC8;
if ( v26 != 45 )
v31 = *(double *)&LC9;
if ( v27 > 0 )
{
do
{
if ( (v27 & 1) != 0 )
v46 = v46 * v31;
v31 = v31 * v31;
v27 >>= 1;
}
while ( v27 );
}
LABEL_32:
v32 = v46;
luaY_lval = LODWORD(v32);
v2[v23] = 0;
return 272;
}
v3 = 257;
v2[v24] = 0;
}
}
return v3;
case 0x30u:
case 0x31u:
case 0x32u:
case 0x33u:
case 0x34u:
case 0x35u:
case 0x36u:
case 0x37u:
case 0x38u:
case 0x39u:
v13 = v2;
v14 = 0;
a1 = *(double *)&LC9;
v15 = _ctype_b_loc();
v46 = 0.0;
while ( 1 )
{
*v13++ = v3;
v48 = v14++;
v46 = (double)(int)(v3 - 48) + v46 * 10.0;
v16 = (int)v4();
v17 = *v15;
current = v16;
v3 = v16;
v18 = v17[v16];
if ( (v18 & 0x800) == 0 )
break;
v4 = (__int64 (*)(void))input;
}
if ( (_DWORD)v16 == 46 )
{
v2[v14] = 46;
v41 = ((__int64 (*)(void))input)();
current = v41;
v3 = v41;
v14 = v48 + 2;
if ( v41 == 46 )
{
func1((__int64)"ambiguous syntax (decimal point x string concatenation)");
v3 = current;
v18 = (*v15)[current];
}
else
{
v18 = (*v15)[v41];
}
}
goto LABEL_17;
case 0x3Cu:
*v2 = 60;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 279;
current = ((__int64 (*)(void))input)();
}
return v3;
case 0x3Du:
*v2 = 61;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 277;
current = ((__int64 (*)(void))input)();
}
return v3;
case 0x3Eu:
*v2 = 62;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 280;
current = ((__int64 (*)(void))input)();
}
return v3;
case 0x41u:
case 0x42u:
case 0x43u:
case 0x44u:
case 0x45u:
case 0x46u:
case 0x47u:
case 0x48u:
case 0x49u:
case 0x4Au:
case 0x4Bu:
case 0x4Cu:
case 0x4Du:
case 0x4Eu:
case 0x4Fu:
case 0x50u:
case 0x51u:
case 0x52u:
case 0x53u:
case 0x54u:
case 0x55u:
case 0x56u:
case 0x57u:
case 0x58u:
case 0x59u:
case 0x5Au:
case 0x5Fu:
case 0x61u:
case 0x62u:
case 0x63u:
case 0x64u:
case 0x65u:
case 0x66u:
case 0x67u:
case 0x68u:
case 0x69u:
case 0x6Au:
case 0x6Bu:
case 0x6Cu:
case 0x6Du:
case 0x6Eu:
case 0x6Fu:
case 0x70u:
case 0x71u:
case 0x72u:
case 0x73u:
case 0x74u:
case 0x75u:
case 0x76u:
case 0x77u:
case 0x78u:
case 0x79u:
case 0x7Au:
v5 = 1LL;
v6 = _ctype_b_loc();
while ( 1 )
{
v2[v5 - 1] = v3;
v7 = (int)v5++;
v8 = (int)v4();
v9 = *v6;
current = v8;
LOBYTE(v3) = v8;
if ( (v9[v8] & 8) == 0 && (_DWORD)v8 != 95 )
break;
v4 = (__int64 (*)(void))input;
}
v2[v7] = 0;
v10 = lua_createstring(v2);
v3 = *(_DWORD *)(v10 + 16);
if ( (int)v3 <= 2 )
{
luaY_lval = v10;
v3 = 274;
*(_DWORD *)(v10 + 16) = 2;
}
return v3;
case 0x5Bu:
*v2 = 91;
current = v4();
if ( current != 91 )
return v3;
v2[1] = 91;
current = ((__int64 (*)(void))input)();
return func3((__int64)v2);
case 0x7Eu:
*v2 = 126;
current = v4();
if ( current == 61 )
{
v2[1] = 61;
v3 = 278;
current = ((__int64 (*)(void))input)();
}
return v3;
default:
*v2 = v3;
v11 = v4();
v3 = *v2;
current = v11;
return v3;
}
}
}

original_code:
int luaY_lex (void)
{
  static int linelasttoken = 0;
  double a;
  int buffsize = 260;
  char *yytext = luaI_buffer(buffsize);
  yytext[1] = yytext[2] = yytext[3] = 0;
  if (lua_debug)
    luaI_codedebugline(linelasttoken);
  linelasttoken = lua_linenumber;
  while (1)
  {
    int tokensize = 0;
    switch (current)
    {
      case '\n':
        (current = input());
        linelasttoken = inclinenumber(1);
        continue;
      case ' ': case '\t': case '\r':
        (current = input());
        continue;
      case '-':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '-') return '-';
        do { (current = input()); } while (current != '\n' && current != 0);
        continue;
      case '[':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '[') return '[';
        else
        {
          ((yytext[tokensize++] = (current)), (current = input()));
          return read_long_string(yytext, buffsize);
        }
      case '=':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '=';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 277; }
      case '<':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '<';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 279; }
      case '>':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '>';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 280; }
      case '~':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '~';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 278; }
      case '"':
      case '\'':
      {
        int del = current;
        ((yytext[tokensize++] = (current)), (current = input()));
        while (current != del)
        {
          if (buffsize-tokensize <= 2)
            yytext = luaI_buffer(buffsize *= 2);
          switch (current)
          {
            case 0:
            case '\n':
              (yytext[tokensize++] = (0));
              return 257;
            case '\\':
              (current = input());
              switch (current)
              {
                case 'n': (yytext[tokensize++] = ('\n')); (current = input()); break;
                case 't': (yytext[tokensize++] = ('\t')); (current = input()); break;
                case 'r': (yytext[tokensize++] = ('\r')); (current = input()); break;
                case '\n': ((yytext[tokensize++] = (current)), (current = input())); inclinenumber(0); break;
                default : ((yytext[tokensize++] = (current)), (current = input())); break;
              }
              break;
            default:
              ((yytext[tokensize++] = (current)), (current = input()));
          }
        }
        (current = input());
        (yytext[tokensize++] = (0));
        luaY_lval.vWord = luaI_findconstantbyname(yytext+1);
        tokensize--;
        (yytext[tokensize++] = (del)); (yytext[tokensize++] = (0));
        return 273;
      }
      case 'a': case 'b': case 'c': case 'd': case 'e':
      case 'f': case 'g': case 'h': case 'i': case 'j':
      case 'k': case 'l': case 'm': case 'n': case 'o':
      case 'p': case 'q': case 'r': case 's': case 't':
      case 'u': case 'v': case 'w': case 'x': case 'y':
      case 'z':
      case 'A': case 'B': case 'C': case 'D': case 'E':
      case 'F': case 'G': case 'H': case 'I': case 'J':
      case 'K': case 'L': case 'M': case 'N': case 'O':
      case 'P': case 'Q': case 'R': case 'S': case 'T':
      case 'U': case 'V': case 'W': case 'X': case 'Y':
      case 'Z':
      case '_':
      {
        TaggedString *ts;
        do { ((yytext[tokensize++] = (current)), (current = input())); } while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short int) _ISalnum) || current == '_');
        (yytext[tokensize++] = (0));
        ts = lua_createstring(yytext);
        if (ts->marked > 2)
          return ts->marked;
        luaY_lval.pTStr = ts;
        ts->marked = 2;
        return 274;
      }
      case '.':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current == '.')
        {
          ((yytext[tokensize++] = (current)), (current = input()));
          if (current == '.')
          {
            ((yytext[tokensize++] = (current)), (current = input()));
            return 271;
          }
          else return 281;
        }
        else if (!((*__ctype_b_loc ())[(int) ((current))] & (unsigned short int) _ISdigit)) return '.';
 a=0.0;
        goto fraction;
      case '0': case '1': case '2': case '3': case '4':
      case '5': case '6': case '7': case '8': case '9':
 a=0.0;
        do {
          a=10.0*a+(current-'0');
          ((yytext[tokensize++] = (current)), (current = input()));
        } while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short int) _ISdigit));
        if (current == '.') {
          ((yytext[tokensize++] = (current)), (current = input()));
          if (current == '.')
            luaI_syntaxerror(
              "ambiguous syntax (decimal point x string concatenation)");
        }
      fraction:
 { double da=0.1;
   while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short int) _ISdigit))
   {
            a+=(current-'0')*da;
            da/=10.0;
            ((yytext[tokensize++] = (current)), (current = input()));
          }
          if (current == 'e' || current == 'E')
          {
     int e=0;
     int neg;
     double ea;
            ((yytext[tokensize++] = (current)), (current = input()));
     neg=(current=='-');
            if (current == '+' || current == '-') ((yytext[tokensize++] = (current)), (current = input()));
            if (!((*__ctype_b_loc ())[(int) ((current))] & (unsigned short int) _ISdigit)) { (yytext[tokensize++] = (0)); return 257; }
            do {
              e=10.0*e+(current-'0');
              ((yytext[tokensize++] = (current)), (current = input()));
            } while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short int) _ISdigit));
     for (ea=neg?0.1:10.0; e>0; e>>=1)
     {
       if (e & 1) a*=ea;
       ea*=ea;
     }
          }
          luaY_lval.vFloat = a;
          (yytext[tokensize++] = (0));
          return 272;
        }
      default:
      {
        ((yytext[tokensize++] = (current)), (current = input()));
        return yytext[0];
      }
    }
  }
}

canonical_original_code:
int luaY_lex()
{
  static int linelasttoken = 0;
  double a;
  int buffsize = 260;
  char *yytext = luaI_buffer(buffsize);
  yytext[1] = yytext[2] = yytext[3] = 0;
  if (lua_debug)
    luaI_codedebugline(linelasttoken);
  linelasttoken = lua_linenumber;
  while (1)
  {
    int tokensize = 0;
    switch (current)
    {
      case '\n':
        (current = input());
        linelasttoken = inclinenumber(1);
        continue;
      case ' ': case '\t': case '\r':
        (current = input());
        continue;
      case '-':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '-') return '-';
        do { (current = input()); } while (current != '\n' && current != 0);
        continue;
      case '[':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '[') return '[';
        else
        {
          ((yytext[tokensize++] = (current)), (current = input()));
          return read_long_string(yytext, buffsize);
        }
      case '=':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '=';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 277; }
      case '<':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '<';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 279; }
      case '>':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '>';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 280; }
      case '~':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current != '=') return '~';
        else { ((yytext[tokensize++] = (current)), (current = input())); return 278; }
      case '"':
      case '\'':
      {
        int del = current;
        ((yytext[tokensize++] = (current)), (current = input()));
        while (current != del)
        {
          if (buffsize-tokensize <= 2)
            yytext = luaI_buffer(buffsize *= 2);
          switch (current)
          {
            case 0:
            case '\n':
              (yytext[tokensize++] = (0));
              return 257;
            case '\\':
              (current = input());
              switch (current)
              {
                case 'n': (yytext[tokensize++] = ('\n')); (current = input()); break;
                case 't': (yytext[tokensize++] = ('\t')); (current = input()); break;
                case 'r': (yytext[tokensize++] = ('\r')); (current = input()); break;
                case '\n': ((yytext[tokensize++] = (current)), (current = input())); inclinenumber(0); break;
                default : ((yytext[tokensize++] = (current)), (current = input())); break;
              }
              break;
            default:
              ((yytext[tokensize++] = (current)), (current = input()));
          }
        }
        (current = input());
        (yytext[tokensize++] = (0));
        luaY_lval.vWord = luaI_findconstantbyname(yytext+1);
        tokensize--;
        (yytext[tokensize++] = (del)); (yytext[tokensize++] = (0));
        return 273;
      }
      case 'a': case 'b': case 'c': case 'd': case 'e':
      case 'f': case 'g': case 'h': case 'i': case 'j':
      case 'k': case 'l': case 'm': case 'n': case 'o':
      case 'p': case 'q': case 'r': case 's': case 't':
      case 'u': case 'v': case 'w': case 'x': case 'y':
      case 'z':
      case 'A': case 'B': case 'C': case 'D': case 'E':
      case 'F': case 'G': case 'H': case 'I': case 'J':
      case 'K': case 'L': case 'M': case 'N': case 'O':
      case 'P': case 'Q': case 'R': case 'S': case 'T':
      case 'U': case 'V': case 'W': case 'X': case 'Y':
      case 'Z':
      case '_':
      {
        struct TaggedString *ts;
        do { ((yytext[tokensize++] = (current)), (current = input())); } while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short) _ISalnum) || current == '_');
        (yytext[tokensize++] = (0));
        ts = lua_createstring(yytext);
        if (ts->marked > 2)
          return ts->marked;
        luaY_lval.pTStr = ts;
        ts->marked = 2;
        return 274;
      }
      case '.':
        ((yytext[tokensize++] = (current)), (current = input()));
        if (current == '.')
        {
          ((yytext[tokensize++] = (current)), (current = input()));
          if (current == '.')
          {
            ((yytext[tokensize++] = (current)), (current = input()));
            return 271;
          }
          else return 281;
        }
        else if (!((*__ctype_b_loc ())[(int) ((current))] & (unsigned short) _ISdigit)) return '.';
 a=0.0;
        goto fraction;
      case '0': case '1': case '2': case '3': case '4':
      case '5': case '6': case '7': case '8': case '9':
 a=0.0;
        do {
          a=10.0*a+(current-'0');
          ((yytext[tokensize++] = (current)), (current = input()));
        } while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short) _ISdigit));
        if (current == '.') {
          ((yytext[tokensize++] = (current)), (current = input()));
          if (current == '.')
            luaI_syntaxerror(
              "ambiguous syntax (decimal point x string concatenation)");
        }
      fraction:
 { double da = 0.1;
   while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short) _ISdigit))
   {
            a+=(current-'0')*da;
            da/=10.0;
            ((yytext[tokensize++] = (current)), (current = input()));
          }
          if (current == 'e' || current == 'E')
          {
     int e = 0;
     int neg;
     double ea;
            ((yytext[tokensize++] = (current)), (current = input()));
     neg=(current=='-');
            if (current == '+' || current == '-') ((yytext[tokensize++] = (current)), (current = input()));
            if (!((*__ctype_b_loc ())[(int) ((current))] & (unsigned short) _ISdigit)) { (yytext[tokensize++] = (0)); return 257; }
            do {
              e=10.0*e+(current-'0');
              ((yytext[tokensize++] = (current)), (current = input()));
            } while (((*__ctype_b_loc ())[(int) ((current))] & (unsigned short) _ISdigit));
     for (ea=neg?0.1:10.0; e>0; e>>=1)
     {
       if (e & 1) a*=ea;
       ea*=ea;
     }
          }
          luaY_lval.vFloat = a;
          (yytext[tokensize++] = (0));
          return 272;
        }
      default:
      {
        ((yytext[tokensize++] = (current)), (current = input()));
        return yytext[0];
      }
    }
  }
}

variable_types: linelasttoken int

variable_types: a double

variable_types: buffsize int

variable_types:
yytext
char *

variable_types: tokensize int

variable_types: del int

variable_types: da double

variable_types: e int

variable_types: neg int

variable_types: ea double


GDFB

decompiled_code:
void GDFB()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code: static void GDFB (void) { }

canonical_original_code: static void GDFB() { }


funcFB

decompiled_code:
__int64 funcFB()
{
return lua_error("call expression not a function");
}

canonical_decompiled_code:
__int64 func1()
{
return lua_error("call expression not a function");
}

original_code:
static void funcFB (void)
{
  lua_error("call expression not a function");
}

canonical_original_code:
static void funcFB()
{
  lua_error("call expression not a function");
}


concatFB

decompiled_code:
__int64 concatFB()
{
return lua_error("unexpected type at conversion to string");
}

canonical_decompiled_code:
__int64 func2()
{
return lua_error("unexpected type at conversion to string");
}

original_code:
static void concatFB (void)
{
  lua_error("unexpected type at conversion to string");
}

canonical_original_code:
static void concatFB()
{
  lua_error("unexpected type at conversion to string");
}


orderFB

decompiled_code:
__int64 orderFB()
{
return lua_error("unexpected type at comparison");
}

canonical_decompiled_code:
__int64 func3()
{
return lua_error("unexpected type at comparison");
}

original_code:
static void orderFB (void)
{
  lua_error("unexpected type at comparison");
}

canonical_original_code:
static void orderFB()
{
  lua_error("unexpected type at comparison");
}


arithFB

decompiled_code:
__int64 arithFB()
{
return lua_error("unexpected type at conversion to number");
}

canonical_decompiled_code:
__int64 func4()
{
return lua_error("unexpected type at conversion to number");
}

original_code:
static void arithFB (void)
{
  lua_error("unexpected type at conversion to number");
}

canonical_original_code:
static void arithFB()
{
  lua_error("unexpected type at conversion to number");
}


gettableFB

decompiled_code:
__int64 gettableFB()
{
return lua_error("indexed expression not a table");
}

canonical_decompiled_code:
__int64 func5()
{
return lua_error("indexed expression not a table");
}

original_code:
static void gettableFB (void)
{
  lua_error("indexed expression not a table");
}

canonical_original_code:
static void gettableFB()
{
  lua_error("indexed expression not a table");
}


indexFB

decompiled_code:
// attributes: thunk
__int64 indexFB()
{
return lua_pushnil();
}

canonical_decompiled_code:
__int64 func6()
{
return lua_pushnil();
}

original_code:
static void indexFB (void)
{
  lua_pushnil();
}

canonical_original_code:
static void indexFB()
{
  lua_pushnil();
}


errorFB

decompiled_code:
int errorFB()
{
__int64 v0; // rbp
const char *v1; // rax

v0 = (unsigned int)lua_getparam(1LL);
if ( !(unsigned int)lua_isstring(v0) )
return fwrite("lua: unknown error\n", 1uLL, 0x13uLL, stderr);
v1 = (const char *)lua_getstring((unsigned int)v0);
return fprintf(stderr, "lua: %s\n", v1);
}

canonical_decompiled_code:
int func7()
{
__int64 v0; // rbp
const char *v1; // rax

v0 = (unsigned int)lua_getparam(1LL);
if ( !(unsigned int)lua_isstring(v0) )
return fwrite("lua: unknown error\n", 1uLL, 0x13uLL, stderr);
v1 = (const char *)lua_getstring((unsigned int)v0);
return fprintf(stderr, "lua: %s\n", v1);
}

original_code:
static void errorFB (void)
{
  lua_Object o = lua_getparam(1);
  if (lua_isstring(o))
    fprintf (stderr, "lua: %s\n", lua_getstring(o));
  else
    fprintf(stderr, "lua: unknown error\n");
}

canonical_original_code:
static void errorFB()
{
  unsigned int o = lua_getparam(1);
  if (lua_isstring(o))
    fprintf (stderr, "lua: %s\n", lua_getstring(o));
  else
    fprintf(stderr, "lua: unknown error\n");
}

variable_types:
o
unsigned int


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

if ( a1 >= 0 && refSize > a1 )
{
result = refArray + 24LL * a1;
*(_DWORD *)(result + 16) = 2;
}
return result;
}

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

if ( a1 >= 0 && refSize > a1 )
{
result = refArray + 24LL * a1;
*(_DWORD *)(result + 16) = 2;
}
return result;
}

original_code:
void lua_unref (int ref)
{
  if (ref >= 0 && ref < refSize)
    refArray[ref].status = FREE;
}

canonical_original_code:
void lua_unref(int ref)
{
  if (ref >= 0 && ref < refSize)
    refArray[ref].status = FREE;
}

variable_types: ref int


decompiled_code:
__int64 luaI_invalidaterefs()
{
__int64 result; // rax
int v1; // ebp
__int64 v2; // rbx

result = (unsigned int)refSize;
if ( refSize > 0 )
{
v1 = 0;
v2 = 0LL;
do
{
while ( 1 )
{
if ( *(_DWORD *)(v2 + refArray + 16) == 1 )
{
result = luaI_ismarked();
if ( !(_DWORD)result )
break;
}
++v1;
v2 += 24LL;
if ( refSize <= v1 )
return result;
}
result = refArray;
++v1;
*(_DWORD *)(refArray + v2 + 16) = 3;
v2 += 24LL;
}
while ( refSize > v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
__int64 result; // rax
int v1; // ebp
__int64 v2; // rbx

result = (unsigned int)refSize;
if ( refSize > 0 )
{
v1 = 0;
v2 = 0LL;
do
{
while ( 1 )
{
if ( *(_DWORD *)(v2 + refArray + 16) == 1 )
{
result = luaI_ismarked();
if ( !(_DWORD)result )
break;
}
++v1;
v2 += 24LL;
if ( refSize <= v1 )
return result;
}
result = refArray;
++v1;
*(_DWORD *)(refArray + v2 + 16) = 3;
v2 += 24LL;
}
while ( refSize > v1 );
}
return result;
}

original_code:
void luaI_invalidaterefs (void)
{
  int i;
  for (i=0; i<refSize; i++)
    if (refArray[i].status == HOLD && !luaI_ismarked(&refArray[i].o))
      refArray[i].status = COLLECTED;
}

canonical_original_code:
void luaI_invalidaterefs()
{
  int i;
  for (i=0; i<refSize; i++)
    if (refArray[i].status == HOLD && !luaI_ismarked(&refArray[i].o))
      refArray[i].status = COLLECTED;
}


decompiled_code:
void __fastcall luaI_free(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
void luaI_free (void *block)
{
  if (block)
  {
    *((int *)block) = -1;
    free(block);
  }
}

canonical_original_code:
void luaI_free(void *block)
{
  if (block)
  {
    *((int *)block) = -1;
    free(block);
  }
}

variable_types:
block
void *


decompiled_code:
void *__fastcall luaI_realloc(void *a1, size_t a2)
{
void *result; // rax

if ( a1 )
result = realloc(a1, a2);
else
result = malloc(a2);
if ( !result )
{
lua_error("not enough memory");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1, size_t a2)
{
void *result; // rax

if ( a1 )
result = realloc(a1, a2);
else
result = malloc(a2);
if ( !result )
{
lua_error("not enough memory");
result = 0LL;
}
return result;
}

original_code:
void *luaI_realloc (void *oldblock, unsigned long size)
{
  void *block;
  size_t s = (size_t)size;
  if (s != size)
    lua_error("Allocation Error: Block too big");
  block = oldblock ? realloc(oldblock, s) : malloc(s);
  if (block == ((void *)0))
    lua_error("not enough memory");
  return block;
}

canonical_original_code:
void *luaI_realloc(void *oldblock, unsigned long size)
{
  void *block;
  unsigned long s = (size_t)size;
  if (s != size)
    lua_error("Allocation Error: Block too big");
  block = oldblock ? realloc(oldblock, s) : malloc(s);
  if (block == ((void *)0))
    lua_error("not enough memory");
  return block;
}

variable_types:
oldblock
void *

variable_types:
size
unsigned long

variable_types:
s
unsigned long

return_type: void *


decompiled_code:
__int64 __fastcall luaI_growvector(void **a1, unsigned __int64 a2, int a3, __int64 a4, unsigned __int64 a5)
{
unsigned __int64 v8; // rbx
void *v9; // rdi

if ( a2 >= a5 )
lua_error(a4);
v8 = 2 * a2;
if ( !a2 )
v8 = 20LL;
v9 = *a1;
if ( v8 > a5 )
v8 = a5;
*a1 = luaI_realloc(v9, v8 * a3);
return (unsigned int)v8;
}

canonical_decompiled_code:
__int64 __fastcall func2(void **a1, unsigned __int64 a2, int a3, __int64 a4, unsigned __int64 a5)
{
unsigned __int64 v8; // rbx
void *v9; // rdi

if ( a2 >= a5 )
lua_error(a4);
v8 = 2 * a2;
if ( !a2 )
v8 = 20LL;
v9 = *a1;
if ( v8 > a5 )
v8 = a5;
*a1 = func1(v9, v8 * a3);
return (unsigned int)v8;
}

original_code:
int luaI_growvector (void **block, unsigned long nelems, int size,
                       char *errormsg, unsigned long limit)
{
  if (nelems >= limit)
    lua_error(errormsg);
  nelems = (nelems == 0) ? 20 : nelems*2;
  if (nelems > limit)
    nelems = limit;
  *block = luaI_realloc(*block, nelems*size);
  return (int)nelems;
}

canonical_original_code:
int luaI_growvector(void **block, unsigned long nelems, int size, char *errormsg, unsigned long limit)
{
  if (nelems >= limit)
    lua_error(errormsg);
  nelems = (nelems == 0) ? 20 : nelems*2;
  if (nelems > limit)
    nelems = limit;
  *block = luaI_realloc(*block, nelems*size);
  return (int)nelems;
}

variable_types:
block
void **

variable_types:
nelems
unsigned long

variable_types: size int

variable_types:
errormsg
char *

variable_types:
limit
unsigned long


decompiled_code:
void *__fastcall luaI_buffer(size_t a1)
{
void *result; // rax

result = (void *)buffer_0;
if ( buffsize_1 < a1 )
{
buffsize_1 = a1;
result = luaI_realloc((void *)buffer_0, a1);
buffer_0 = (__int64)result;
}
return result;
}

canonical_decompiled_code:
void *__fastcall func3(size_t a1)
{
void *result; // rax

result = (void *)buffer_0;
if ( buffsize_1 < a1 )
{
buffsize_1 = a1;
result = func1((void *)buffer_0, a1);
buffer_0 = (__int64)result;
}
return result;
}

original_code:
void* luaI_buffer (unsigned long size)
{
  static unsigned long buffsize = 0;
  static char* buffer = ((void *)0);
  if (size > buffsize)
    buffer = luaI_realloc(buffer, buffsize=size);
  return buffer;
}

canonical_original_code:
void *luaI_buffer(unsigned long size)
{
  static unsigned long buffsize = 0;
  static char *buffer = ((void *)0);
  if (size > buffsize)
    buffer = luaI_realloc(buffer, buffsize=size);
  return buffer;
}

variable_types:
buffsize
unsigned long

variable_types:
buffer
char *


decompiled_code:
char *manual_input()
{
char *result; // rax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

while ( 1 )
{
result = fgets(v1, 250, stdin);
if ( !result )
break;
lua_beginblock();
lua_dostring(v1);
lua_endblock();
}
return result;
}

canonical_decompiled_code:
char *func0()
{
char *result; // rax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

while ( 1 )
{
result = fgets(v1, 250, stdin);
if ( !result )
break;
lua_beginblock();
lua_dostring(v1);
lua_endblock();
}
return result;
}

original_code:
static void manual_input (void)
{
  if ((0==0)) {
    char buffer[250];
    while (fgets(buffer, sizeof(buffer), stdin) != 0) {
      lua_beginblock();
      lua_dostring(buffer);
      lua_endblock();
    }
  }
  else
    lua_dofile(((void *)0));
}

canonical_original_code:
static void manual_input()
{
  if ((0==0)) {
    char buffer[250];
    while (fgets(buffer, sizeof(buffer), stdin) != 0) {
      lua_beginblock();
      lua_dostring(buffer);
      lua_endblock();
    }
  }
  else
    lua_dofile(((void *)0));
}

variable_types:
buffer
char [250]


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
__int64 v4; // rax
const char **v5; // r14
const char *v6; // rbp
int v7; // eax
int v9; // er12

v3 = 1;
iolib_open(argc, argv, envp);
strlib_open();
mathlib_open();
if ( argc <= 1 )
{
manual_input();
return 0;
}
while ( 1 )
{
while ( 1 )
{
v4 = v3;
v5 = &argv[v4];
v6 = argv[v4];
if ( *(_WORD *)v6 == 45 )
{
manual_input();
goto LABEL_4;
}
if ( *v6 != 45 )
break;
if ( v6[1] != 118 || v6[2] )
{
if ( v6[1] == 101 && !v6[2] )
{
v5 = &argv[v4 + 1];
++v3;
v6 = *v5;
LABEL_11:
if ( (unsigned int)lua_dostring(v6) )
{
v9 = 1;
fprintf(stderr, "lua: error running argument `%s'\n", *v5);
return v9;
}
goto LABEL_4;
}
break;
}
++v3;
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 ( argc <= v3 )
return 0;
}
if ( strchr(argv[v3], 61) )
goto LABEL_11;
v7 = lua_dofile(v6);
if ( v7 )
break;
LABEL_4:
if ( argc <= ++v3 )
return 0;
}
v9 = 1;
if ( v7 == 2 )
{
fprintf(stderr, "lua: cannot execute file `%s' - ", *v5);
perror(0LL);
}
return v9;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
__int64 v4; // rax
const char **v5; // r14
const char *v6; // rbp
int v7; // eax
int v9; // er12

v3 = 1;
iolib_open(argc, argv, envp);
strlib_open();
mathlib_open();
if ( argc <= 1 )
{
func0();
return 0;
}
while ( 1 )
{
while ( 1 )
{
v4 = v3;
v5 = &argv[v4];
v6 = argv[v4];
if ( *(_WORD *)v6 == 45 )
{
func0();
goto LABEL_4;
}
if ( *v6 != 45 )
break;
if ( v6[1] != 118 || v6[2] )
{
if ( v6[1] == 101 && !v6[2] )
{
v5 = &argv[v4 + 1];
++v3;
v6 = *v5;
LABEL_11:
if ( (unsigned int)lua_dostring(v6) )
{
v9 = 1;
fprintf(stderr, "lua: error running argument `%s'\n", *v5);
return v9;
}
goto LABEL_4;
}
break;
}
++v3;
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 ( argc <= v3 )
return 0;
}
if ( strchr(argv[v3], 61) )
goto LABEL_11;
v7 = lua_dofile(v6);
if ( v7 )
break;
LABEL_4:
if ( argc <= ++v3 )
return 0;
}
v9 = 1;
if ( v7 == 2 )
{
fprintf(stderr, "lua: cannot execute file `%s' - ", *v5);
perror(0LL);
}
return v9;
}

original_code:
int main (int argc, char *argv[])
{
  int i;
  int result = 0;
  iolib_open ();
  strlib_open ();
  mathlib_open ();
  if (argc < 2)
    manual_input();
  else for (i=1; i<argc; i++) {
    if (strcmp(argv[i], "-") == 0)
      manual_input();
    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 if ((strcmp(argv[i], "-e") == 0 && i++) || strchr(argv[i], '=')) {
      if (lua_dostring(argv[i]) != 0) {
        fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
        return 1;
      }
    }
    else {
      result = lua_dofile (argv[i]);
      if (result) {
        if (result == 2) {
          fprintf(stderr, "lua: cannot execute file `%s' - ", argv[i]);
          perror(((void *)0));
        }
        return 1;
      }
    }
  }
  return result;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  int i;
  int result = 0;
  iolib_open ();
  strlib_open ();
  mathlib_open ();
  if (argc < 2)
    manual_input();
  else for (i=1; i<argc; i++) {
    if (strcmp(argv[i], "-") == 0)
      manual_input();
    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 if ((strcmp(argv[i], "-e") == 0 && i++) || strchr(argv[i], '=')) {
      if (lua_dostring(argv[i]) != 0) {
        fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
        return 1;
      }
    }
    else {
      result = lua_dofile (argv[i]);
      if (result) {
        if (result == 2) {
          fprintf(stderr, "lua: cannot execute file `%s' - ", argv[i]);
          perror(((void *)0));
        }
        return 1;
      }
    }
  }
  return result;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: i int

variable_types: result int


SawVar

decompiled_code:
__int64 __fastcall SawVar(int a1, __int16 a2)
{
_WORD *v2; // rax
unsigned int v3; // er8

v2 = *(_WORD **)(lua_table + 24LL * a1 + 16);
v3 = (unsigned __int16)*v2;
*v2 = a2;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int16 a2)
{
_WORD *v2; // rax
unsigned int v3; // er8

v2 = *(_WORD **)(lua_table + 24LL * a1 + 16);
v3 = (unsigned __int16)*v2;
*v2 = a2;
return v3;
}

original_code:
static int SawVar(int i, int at)
{
 int old=(lua_table[i].varname->varindex);
 (lua_table[i].varname->varindex)=at;
 return old;
}

canonical_original_code:
static int SawVar(int i, int at)
{
 int old = (lua_table[i].varname->varindex);
 (lua_table[i].varname->varindex)=at;
 return old;
}

variable_types: at int

variable_types: old int


SawStr

decompiled_code:
__int64 __fastcall SawStr(int a1, __int16 a2)
{
__int64 v2; // rax
unsigned int v3; // er8

v2 = *(_QWORD *)(lua_constant + 8LL * a1);
v3 = *(unsigned __int16 *)(v2 + 2);
*(_WORD *)(v2 + 2) = a2;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, __int16 a2)
{
__int64 v2; // rax
unsigned int v3; // er8

v2 = *(_QWORD *)(lua_constant + 8LL * a1);
v3 = *(unsigned __int16 *)(v2 + 2);
*(_WORD *)(v2 + 2) = a2;
return v3;
}

original_code:
static int SawStr(int i, int at)
{
 int old=(lua_constant[i]->constindex);
 (lua_constant[i]->constindex)=at;
 return old;
}

canonical_original_code:
static int SawStr(int i, int at)
{
 int old = (lua_constant[i]->constindex);
 (lua_constant[i]->constindex)=at;
 return old;
}


ThreadCode

decompiled_code:
__int64 __fastcall ThreadCode(unsigned __int8 *a1, unsigned __int8 *a2)
{
int v2; // er9
_WORD **v4; // rax
__int64 v5; // rcx
_WORD *v6; // rdx
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // rcx
unsigned __int8 *v10; // rcx
int v11; // esi
__int64 v12; // rcx
unsigned __int8 *v13; // r11
__int64 v14; // rcx
unsigned __int8 *v15; // rdx
unsigned __int8 *v16; // rbx
unsigned __int16 *v17; // rdx
unsigned __int8 v18; // r11
unsigned __int16 *v19; // rcx
__int64 *v20; // rdx

v2 = (int)a1;
if ( lua_ntable )
{
v4 = (_WORD **)(lua_table + 16LL);
v5 = lua_table + 24LL * ((unsigned int)lua_ntable - 1) + 40;
do
{
v6 = *v4;
v4 += 3;
*v6 = 0;
}
while ( v4 != (_WORD **)v5 );
}
result = lua_nconstant;
if ( lua_nconstant )
{
v8 = lua_constant;
result = lua_constant + 8LL;
v9 = lua_constant + 8LL + 8LL * ((unsigned int)lua_nconstant - 1);
while ( 1 )
{
*(_WORD *)(*(_QWORD *)v8 + 2LL) = 0;
v8 = result;
if ( result == v9 )
break;
result += 8LL;
}
}
if ( a1 != a2 )
{
v10 = a1;
do
{
result = *v10;
v11 = (_DWORD)v10 - v2 + 1;
switch ( (char)result )
{
case 0:
case 1:
case 2:
case 3:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 21:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 35:
case 40:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 62:
case 64:
++v10;
break;
case 4:
case 19:
case 33:
case 36:
case 37:
case 41:
case 65:
v10 += 2;
break;
case 5:
case 38:
case 42:
case 56:
case 57:
case 58:
case 59:
case 60:
case 61:
case 63:
case 66:
v10 += 3;
break;
case 6:
v10 += 5;
break;
case 7:
case 22:
result = SawStr(*(unsigned __int16 *)(v10 + 1), v11);
*(_WORD *)(v14 + 1) = result;
v10 = v15;
break;
case 8:
result = *(_QWORD *)(v10 + 1);
v20 = (__int64 *)lastF;
v10 += 9;
*(_DWORD *)(result + 8) = v11;
*(_QWORD *)result = 0LL;
lastF = result;
*v20 = result;
break;
case 20:
case 34:
result = SawVar(*(unsigned __int16 *)(v10 + 1), v11);
*(_WORD *)(v12 + 1) = result;
v10 = v13;
break;
case 39:
result = v10[1];
v16 = v10 + 2;
if ( v10[1] )
{
v17 = (unsigned __int16 *)(v10 + 2);
do
{
result = SawStr(*v17, (unsigned __int16)v17 - (unsigned __int16)v2);
*(v17 - 1) = result;
}
while ( v19 != v17 );
v10 = &v16[2 * v18];
}
else
{
v10 += 2;
}
break;
default:
fprintf(stderr, "luac: cannot happen: opcode=%d", (unsigned __int8)result);
exit(1);
}
}
while ( v10 != a2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1, unsigned __int8 *a2)
{
int v2; // er9
_WORD **v4; // rax
__int64 v5; // rcx
_WORD *v6; // rdx
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // rcx
unsigned __int8 *v10; // rcx
int v11; // esi
__int64 v12; // rcx
unsigned __int8 *v13; // r11
__int64 v14; // rcx
unsigned __int8 *v15; // rdx
unsigned __int8 *v16; // rbx
unsigned __int16 *v17; // rdx
unsigned __int8 v18; // r11
unsigned __int16 *v19; // rcx
__int64 *v20; // rdx

v2 = (int)a1;
if ( lua_ntable )
{
v4 = (_WORD **)(lua_table + 16LL);
v5 = lua_table + 24LL * ((unsigned int)lua_ntable - 1) + 40;
do
{
v6 = *v4;
v4 += 3;
*v6 = 0;
}
while ( v4 != (_WORD **)v5 );
}
result = lua_nconstant;
if ( lua_nconstant )
{
v8 = lua_constant;
result = lua_constant + 8LL;
v9 = lua_constant + 8LL + 8LL * ((unsigned int)lua_nconstant - 1);
while ( 1 )
{
*(_WORD *)(*(_QWORD *)v8 + 2LL) = 0;
v8 = result;
if ( result == v9 )
break;
result += 8LL;
}
}
if ( a1 != a2 )
{
v10 = a1;
do
{
result = *v10;
v11 = (_DWORD)v10 - v2 + 1;
switch ( (char)result )
{
case 0:
case 1:
case 2:
case 3:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 21:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 35:
case 40:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 62:
case 64:
++v10;
break;
case 4:
case 19:
case 33:
case 36:
case 37:
case 41:
case 65:
v10 += 2;
break;
case 5:
case 38:
case 42:
case 56:
case 57:
case 58:
case 59:
case 60:
case 61:
case 63:
case 66:
v10 += 3;
break;
case 6:
v10 += 5;
break;
case 7:
case 22:
result = func1(*(unsigned __int16 *)(v10 + 1), v11);
*(_WORD *)(v14 + 1) = result;
v10 = v15;
break;
case 8:
result = *(_QWORD *)(v10 + 1);
v20 = (__int64 *)lastF;
v10 += 9;
*(_DWORD *)(result + 8) = v11;
*(_QWORD *)result = 0LL;
lastF = result;
*v20 = result;
break;
case 20:
case 34:
result = func0(*(unsigned __int16 *)(v10 + 1), v11);
*(_WORD *)(v12 + 1) = result;
v10 = v13;
break;
case 39:
result = v10[1];
v16 = v10 + 2;
if ( v10[1] )
{
v17 = (unsigned __int16 *)(v10 + 2);
do
{
result = func1(*v17, (unsigned __int16)v17 - (unsigned __int16)v2);
*(v17 - 1) = result;
}
while ( v19 != v17 );
v10 = &v16[2 * v18];
}
else
{
v10 += 2;
}
break;
default:
fprintf(stderr, "luac: cannot happen: opcode=%d", (unsigned __int8)result);
exit(1);
}
}
while ( v10 != a2 );
}
return result;
}

original_code:
static void ThreadCode(lua_Byte* code, lua_Byte* end)
{
 lua_Byte* p;
 int i;
 for (i=0; i<lua_ntable; i++) (lua_table[i].varname->varindex)=0;
 for (i=0; i<lua_nconstant; i++) (lua_constant[i]->constindex)=0;
 for (p=code; p!=end;)
 {
 OpCode op=(OpCode)*p;
 int at=p-code+1;
 switch (op)
 {
 case PUSHNIL:
 case PUSH0:
 case PUSH1:
 case PUSH2:
 case PUSHLOCAL0:
 case PUSHLOCAL1:
 case PUSHLOCAL2:
 case PUSHLOCAL3:
 case PUSHLOCAL4:
 case PUSHLOCAL5:
 case PUSHLOCAL6:
 case PUSHLOCAL7:
 case PUSHLOCAL8:
 case PUSHLOCAL9:
 case PUSHINDEXED:
 case STORELOCAL0:
 case STORELOCAL1:
 case STORELOCAL2:
 case STORELOCAL3:
 case STORELOCAL4:
 case STORELOCAL5:
 case STORELOCAL6:
 case STORELOCAL7:
 case STORELOCAL8:
 case STORELOCAL9:
 case STOREINDEXED0:
 case ADJUST0:
 case EQOP:
 case LTOP:
 case LEOP:
 case GTOP:
 case GEOP:
 case ADDOP:
 case SUBOP:
 case MULTOP:
 case DIVOP:
 case POWOP:
 case CONCOP:
 case MINUSOP:
 case NOTOP:
 case POP:
 case RETCODE0:
  p++;
  break;
 case PUSHBYTE:
 case PUSHLOCAL:
 case STORELOCAL:
 case STOREINDEXED:
 case STORELIST0:
 case ADJUST:
 case RETCODE:
  p+=2;
  break;
 case PUSHWORD:
 case CREATEARRAY:
 case ONTJMP:
 case ONFJMP:
 case JMP:
 case UPJMP:
 case IFFJMP:
 case IFFUPJMP:
 case SETLINE:
 case STORELIST:
 case CALLFUNC:
  p+=3;
  break;
 case PUSHFLOAT:
  p+=5;
  break;
 case PUSHSELF:
 case PUSHSTRING:
 {
  lua_Word w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  w=SawStr(w,at);
  memcpy(p-2,&w,sizeof(w));
  break;
 }
 case PUSHFUNCTION:
 {
  TFunc* tf;
  p++;
  {memcpy(&tf, p, sizeof(TFunc *)); p+=sizeof(TFunc *);};
  tf->marked=at;
  tf->next=((void *)0);
  lastF=lastF->next=tf;
  break;
 }
 case PUSHGLOBAL:
 case STOREGLOBAL:
 {
  lua_Word w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  w=SawVar(w,at);
  memcpy(p-2,&w,sizeof(w));
  break;
 }
 case STORERECORD:
 {
  int n=*++p;
  p++;
  while (n--)
  {
   lua_Word w;
   at=p-code;
   {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
   w=SawStr(w,at);
   memcpy(p-2,&w,sizeof(w));
  }
  break;
 }
 default:
  fprintf(stderr,"luac: cannot happen:  opcode=%d",*p);
  exit(1);
  break;
 }
 }
}

canonical_original_code:
static void ThreadCode(unsigned char *code, unsigned char *end)
{
 unsigned char *p;
 int i;
 for (i=0; i<lua_ntable; i++) (lua_table[i].varname->varindex)=0;
 for (i=0; i<lua_nconstant; i++) (lua_constant[i]->constindex)=0;
 for (p=code; p!=end;)
 {
 enum OpCode op = (OpCode)*p;
 int at = p-code+1;
 switch (op)
 {
 case PUSHNIL:
 case PUSH0:
 case PUSH1:
 case PUSH2:
 case PUSHLOCAL0:
 case PUSHLOCAL1:
 case PUSHLOCAL2:
 case PUSHLOCAL3:
 case PUSHLOCAL4:
 case PUSHLOCAL5:
 case PUSHLOCAL6:
 case PUSHLOCAL7:
 case PUSHLOCAL8:
 case PUSHLOCAL9:
 case PUSHINDEXED:
 case STORELOCAL0:
 case STORELOCAL1:
 case STORELOCAL2:
 case STORELOCAL3:
 case STORELOCAL4:
 case STORELOCAL5:
 case STORELOCAL6:
 case STORELOCAL7:
 case STORELOCAL8:
 case STORELOCAL9:
 case STOREINDEXED0:
 case ADJUST0:
 case EQOP:
 case LTOP:
 case LEOP:
 case GTOP:
 case GEOP:
 case ADDOP:
 case SUBOP:
 case MULTOP:
 case DIVOP:
 case POWOP:
 case CONCOP:
 case MINUSOP:
 case NOTOP:
 case POP:
 case RETCODE0:
  p++;
  break;
 case PUSHBYTE:
 case PUSHLOCAL:
 case STORELOCAL:
 case STOREINDEXED:
 case STORELIST0:
 case ADJUST:
 case RETCODE:
  p+=2;
  break;
 case PUSHWORD:
 case CREATEARRAY:
 case ONTJMP:
 case ONFJMP:
 case JMP:
 case UPJMP:
 case IFFJMP:
 case IFFUPJMP:
 case SETLINE:
 case STORELIST:
 case CALLFUNC:
  p+=3;
  break;
 case PUSHFLOAT:
  p+=5;
  break;
 case PUSHSELF:
 case PUSHSTRING:
 {
  unsigned short w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  w=SawStr(w,at);
  memcpy(p-2,&w,sizeof(w));
  break;
 }
 case PUSHFUNCTION:
 {
  struct TFunc *tf;
  p++;
  {memcpy(&tf, p, sizeof(struct TFunc *)); p+=sizeof(struct TFunc *);};
  tf->marked=at;
  tf->next=((void *)0);
  lastF=lastF->next=tf;
  break;
 }
 case PUSHGLOBAL:
 case STOREGLOBAL:
 {
  unsigned short w;
  p++;
  {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
  w=SawVar(w,at);
  memcpy(p-2,&w,sizeof(w));
  break;
 }
 case STORERECORD:
 {
  int n = *++p;
  p++;
  while (n--)
  {
   unsigned short w;
   at=p-code;
   {memcpy(&w, p, sizeof(lua_Word)); p+=sizeof(lua_Word);};
   w=SawStr(w,at);
   memcpy(p-2,&w,sizeof(w));
  }
  break;
 }
 default:
  fprintf(stderr,"luac: cannot happen:  opcode=%d",*p);
  exit(1);
  break;
 }
 }
}

variable_types:
code
unsigned char *

variable_types:
end
unsigned char *

variable_types:
p
unsigned char *

variable_types: enum OpCode { PUSHNIL=0, PUSH0=1, PUSH1=2, PUSH2=3, PUSHBYTE=4, PUSHWORD=5, PUSHFLOAT=6, PUSHSTRING=7, PUSHFUNCTION=8, PUSHLOCAL0=9, PUSHLOCAL1=10, PUSHLOCAL2=11, PUSHLOCAL3=12, PUSHLOCAL4=13, PUSHLOCAL5=14, PUSHLOCAL6=15, PUSHLOCAL7=16, PUSHLOCAL8=17, PUSHLOCAL9=18, PUSHLOCAL=19, PUSHGLOBAL=20, PUSHINDEXED=21, PUSHSELF=22, STORELOCAL0=23, STORELOCAL1=24, STORELOCAL2=25, STORELOCAL3=26, STORELOCAL4=27, STORELOCAL5=28, STORELOCAL6=29, STORELOCAL7=30, STORELOCAL8=31, STORELOCAL9=32, STORELOCAL=33, STOREGLOBAL=34, STOREINDEXED0=35, STOREINDEXED=36, STORELIST0=37, STORELIST=38, STORERECORD=39, ADJUST0=40, ADJUST=41, CREATEARRAY=42, EQOP=43, LTOP=44, LEOP=45, GTOP=46, GEOP=47, ADDOP=48, SUBOP=49, MULTOP=50, DIVOP=51, POWOP=52, CONCOP=53, MINUSOP=54, NOTOP=55, ONTJMP=56, ONFJMP=57, JMP=58, UPJMP=59, IFFJMP=60, IFFUPJMP=61, POP=62, CALLFUNC=63, RETCODE0=64, RETCODE=65, SETLINE=66, VARARGS=67 }

variable_types:
w
unsigned short

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

variable_types: n int


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

v0 = tmpnam(0LL);
return lua_pushstring(v0);
}

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

v0 = tmpnam(0LL);
return lua_pushstring(v0);
}

original_code:
static void io_tmpname (void)
{
  lua_pushstring(tmpnam(((void *)0)));
}

canonical_original_code:
static void io_tmpname()
{
  lua_pushstring(tmpnam(((void *)0)));
}


decompiled_code:
__int64 io_remove()
{
const char *v0; // rax
int v1; // eax

v0 = (const char *)lua_check_string(1LL, "remove");
v1 = remove(v0);
return pushresult(v1 == 0);
}

canonical_decompiled_code:
__int64 func9()
{
const char *v0; // rax
int v1; // eax

v0 = (const char *)lua_check_string(1LL, "remove");
v1 = remove(v0);
return func7(v1 == 0);
}

original_code:
static void io_remove (void)
{
  pushresult(remove(lua_check_string(1, "remove")) == 0);
}

canonical_original_code:
static void io_remove()
{
  pushresult(remove(lua_check_string(1, "remove")) == 0);
}


decompiled_code:
__int64 io_execute()
{
const char *v0; // rdi
float v1; // xmm0_4

v0 = (const char *)lua_check_string(1LL, "execute");
v1 = (float)system(v0);
return lua_pushnumber(v1);
}

canonical_decompiled_code:
__int64 func10()
{
const char *v0; // rdi
float v1; // xmm0_4

v0 = (const char *)lua_check_string(1LL, "execute");
v1 = (float)system(v0);
return lua_pushnumber(v1);
}

original_code:
static void io_execute (void)
{
  lua_pushnumber(system(lua_check_string(1, "execute")));
}

canonical_original_code:
static void io_execute()
{
  lua_pushnumber(system(lua_check_string(1, "execute")));
}


parseString

decompiled_code:
__int64 __fastcall parseString(void *src, _QWORD *a2)
{
size_t v2; // rbx
void *v3; // r12
_QWORD *v4; // rax
__int64 v5; // rax
__int64 v6; // rbx
unsigned int v7; // er12
char **v8; // r13
char *v9; // rax

v2 = strlen((const char *)src);
v3 = malloc(v2);
memcpy(v3, src, v2 + 1);
v4 = malloc(0x320uLL);
*a2 = v4;
*v4 = strtok((char *)v3, "| \t");
v5 = 0LL;
do
{
v6 = v5 + 1;
v7 = v5 + 1;
v8 = (char **)(*a2 + 8 * (v5 + 1));
v9 = strtok(0LL, "| \t");
*v8 = v9;
if ( !v9 )
return v7;
v5 = v6;
}
while ( v6 != 100 );
return 100LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(void *src, _QWORD *a2)
{
size_t v2; // rbx
void *v3; // r12
_QWORD *v4; // rax
__int64 v5; // rax
__int64 v6; // rbx
unsigned int v7; // er12
char **v8; // r13
char *v9; // rax

v2 = strlen((const char *)src);
v3 = malloc(v2);
memcpy(v3, src, v2 + 1);
v4 = malloc(0x320uLL);
*a2 = v4;
*v4 = strtok((char *)v3, "| \t");
v5 = 0LL;
do
{
v6 = v5 + 1;
v7 = v5 + 1;
v8 = (char **)(*a2 + 8 * (v5 + 1));
v9 = strtok(0LL, "| \t");
*v8 = v9;
if ( !v9 )
return v7;
v5 = v6;
}
while ( v6 != 100 );
return 100LL;
}

original_code:
int parseString(char* line, char*** argv) {
  char* buffer;
  int argc;
  buffer = (char*) malloc(strlen(line) * sizeof(char));
  strcpy(buffer,line);
  (*argv) = (char**) malloc(100 * sizeof(char**));
  argc = 0;
  (*argv)[argc++] = strtok(buffer, "| \t");
  while ((((*argv)[argc] = strtok(((void *)0), "| \t")) != ((void *)0)) &&
  (argc < 100)) ++argc;
  return argc;
}

canonical_original_code:
int parseString(char *line, char ***argv) {
  char *buffer;
  int argc;
  buffer = (char *) malloc(strlen(line) * sizeof(char));
  strcpy(buffer,line);
  (*argv) = (char **) malloc(100 * sizeof(char **));
  argc = 0;
  (*argv)[argc++] = strtok(buffer, "| \t");
  while ((((*argv)[argc] = strtok(((void *)0), "| \t")) != ((void *)0)) &&
  (argc < 100)) ++argc;
  return argc;
}

variable_types:
line
char *

variable_types:
argv
char ***


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
__int64 v5; // rcx
struct termios *v6; // rdi
__int64 v7; // rax
int v8; // eax
__int64 v9; // [rsp+8h] [rbp-1A0h]
struct termios termios_p; // [rsp+10h] [rbp-198h] BYREF
struct termios v11; // [rsp+50h] [rbp-158h] BYREF
char buf[280]; // [rsp+90h] [rbp-118h] BYREF

v3 = open("/dev/ttyUSB0", 258, envp);
if ( v3 >= 0 )
{
v4 = v3;
tcgetattr(v3, &termios_p);
v5 = 15LL;
v6 = &v11;
while ( v5 )
{
v6->c_iflag = 0;
v6 = (struct termios *)((char *)v6 + 4);
--v5;
}
v11.c_iflag = 260;
*(_QWORD *)&v11.c_cflag = 0x2800008BCLL;
v11.c_cc[4] = 4;
v11.c_cc[6] = 1;
tcflush(v4, 0);
tcsetattr(v4, 0, &v11);
buf[(int)read(v4, buf, 0xFFuLL)] = 0;
if ( (int)parseString(buf) > 0 )
{
v7 = strtol(*(const char **)(v9 + 16), 0LL, 16);
printf("%d\n", v7);
puts("12400");
v8 = strtol(*(const char **)(v9 + 64), 0LL, 16);
printf("%d seconds\n", (unsigned int)(16 * v8));
puts("dac");
}
tcsetattr(v4, 0, &termios_p);
exit(0);
}
perror("/dev/ttyUSB0");
exit(-1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
__int64 v5; // rcx
struct termios *v6; // rdi
__int64 v7; // rax
int v8; // eax
__int64 v9; // [rsp+8h] [rbp-1A0h]
struct termios termios_p; // [rsp+10h] [rbp-198h] BYREF
struct termios v11; // [rsp+50h] [rbp-158h] BYREF
char buf[280]; // [rsp+90h] [rbp-118h] BYREF

v3 = open("/dev/ttyUSB0", 258, envp);
if ( v3 >= 0 )
{
v4 = v3;
tcgetattr(v3, &termios_p);
v5 = 15LL;
v6 = &v11;
while ( v5 )
{
v6->c_iflag = 0;
v6 = (struct termios *)((char *)v6 + 4);
--v5;
}
v11.c_iflag = 260;
*(_QWORD *)&v11.c_cflag = 0x2800008BCLL;
v11.c_cc[4] = 4;
v11.c_cc[6] = 1;
tcflush(v4, 0);
tcsetattr(v4, 0, &v11);
buf[(int)read(v4, buf, 0xFFuLL)] = 0;
if ( (int)func7(buf) > 0 )
{
v7 = strtol(*(const char **)(v9 + 16), 0LL, 16);
printf("%d\n", v7);
puts("12400");
v8 = strtol(*(const char **)(v9 + 64), 0LL, 16);
printf("%d seconds\n", (unsigned int)(16 * v8));
puts("dac");
}
tcsetattr(v4, 0, &termios_p);
exit(0);
}
perror("/dev/ttyUSB0");
exit(-1);
}

original_code:
int main()
{
  int fd,res;
  struct termios oldtio,newtio;
  char buf[255];
  char **A;
  int n;
 fd = open("/dev/ttyUSB0", 02 | 0400 );
 if (fd <0) {perror("/dev/ttyUSB0"); exit(-1); }
 tcgetattr(fd,&oldtio);
 bzero(&newtio, sizeof(newtio));
 newtio.c_cflag = 0000014 | 020000000000 | 0000060 | 0004000 | 0000200;
 newtio.c_iflag = 0000004 | 0000400;
 newtio.c_oflag = 0;
 newtio.c_lflag = 0000002;
 newtio.c_cc[0] = 0;
 newtio.c_cc[1] = 0;
 newtio.c_cc[2] = 0;
 newtio.c_cc[3] = 0;
 newtio.c_cc[4] = 4;
 newtio.c_cc[5] = 0;
 newtio.c_cc[6] = 1;
 newtio.c_cc[7] = 0;
 newtio.c_cc[8] = 0;
 newtio.c_cc[9] = 0;
 newtio.c_cc[10] = 0;
 newtio.c_cc[11] = 0;
 newtio.c_cc[12] = 0;
 newtio.c_cc[13] = 0;
 newtio.c_cc[14] = 0;
 newtio.c_cc[15] = 0;
 newtio.c_cc[16] = 0;
 tcflush(fd, 0);
 tcsetattr(fd,0,&newtio);
    res = read(fd,buf,255);
    buf[res]=0;
    n = parseString(buf, &A);
    if ( n > 0) {
     printf("%d\n", (int) strtol(A[2], ((void *)0), 16));
     printf("12400\n" );
     printf("%d seconds\n", (int) strtol(A[8], ((void *)0), 16) * 16);
     printf("dac\n");
    }
    tcsetattr(fd,0,&oldtio);
    exit(0);
}

canonical_original_code:
int main()
{
  int fd; int res;
  struct termios oldtio; struct termios newtio;
  char buf[255];
  char **A;
  int n;
 fd = open("/dev/ttyUSB0", 02 | 0400 );
 if (fd <0) {perror("/dev/ttyUSB0"); exit(-1); }
 tcgetattr(fd,&oldtio);
 bzero(&newtio, sizeof(newtio));
 newtio.c_cflag = 0000014 | 020000000000 | 0000060 | 0004000 | 0000200;
 newtio.c_iflag = 0000004 | 0000400;
 newtio.c_oflag = 0;
 newtio.c_lflag = 0000002;
 newtio.c_cc[0] = 0;
 newtio.c_cc[1] = 0;
 newtio.c_cc[2] = 0;
 newtio.c_cc[3] = 0;
 newtio.c_cc[4] = 4;
 newtio.c_cc[5] = 0;
 newtio.c_cc[6] = 1;
 newtio.c_cc[7] = 0;
 newtio.c_cc[8] = 0;
 newtio.c_cc[9] = 0;
 newtio.c_cc[10] = 0;
 newtio.c_cc[11] = 0;
 newtio.c_cc[12] = 0;
 newtio.c_cc[13] = 0;
 newtio.c_cc[14] = 0;
 newtio.c_cc[15] = 0;
 newtio.c_cc[16] = 0;
 tcflush(fd, 0);
 tcsetattr(fd,0,&newtio);
    res = read(fd,buf,255);
    buf[res]=0;
    n = parseString(buf, &A);
    if ( n > 0) {
     printf("%d\n", (int) strtol(A[2], ((void *)0), 16));
     printf("12400\n" );
     printf("%d seconds\n", (int) strtol(A[8], ((void *)0), 16) * 16);
     printf("dac\n");
    }
    tcsetattr(fd,0,&oldtio);
    exit(0);
}

variable_types: fd int

variable_types: res int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

variable_types:
buf
char [255]

variable_types:
A
char **