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

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

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

v0 = (char *)func1(1LL, "strupper");
func7(0);
v1 = *v0;
if ( *v0 )
{
v2 = _ctype_toupper_loc();
do
{
++v0;
func7((*v2)[v1]);
v1 = *v0;
}
while ( *v0 );
}
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));
}


repo: cskau/VM

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

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

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

v0 = (char *)func1(1LL, "strlower");
func7(0);
v1 = *v0;
if ( *v0 )
{
v2 = _ctype_tolower_loc();
do
{
++v0;
func7((*v2)[v1]);
v1 = *v0;
}
while ( *v0 );
}
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));
}

variable_types:
s
char *

return_type: void


decompiled_code:
__int64 __fastcall luaI_openlib(_QWORD *a1, int a2)
{
_QWORD *v2; // rbx
__int64 result; // rax

if ( a2 > 0 )
{
v2 = a1;
do
{
lua_pushcfunction(v2[1]);
result = lua_storeglobal(*v2);
v2 += 2;
}
while ( v2 != &a1[2 * (unsigned int)(a2 - 1) + 2] );
}
return result;
}

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

if ( a2 > 0 )
{
v2 = a1;
do
{
lua_pushcfunction(v2[1]);
result = lua_storeglobal(*v2);
v2 += 2;
}
while ( v2 != &a1[2 * (unsigned int)(a2 - 1) + 2] );
}
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

variable_types: i int


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

canonical_decompiled_code:
__int64 func14()
{
return func13(&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_358;
if ( V )
result = (void *)(*(_QWORD *)(V + 16LL * a1) + 20LL);
return result;
}

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

result = &unk_358;
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; // rbx
unsigned int v4; // er14
unsigned int v5; // er14
const char *v6; // rax
unsigned int v7; // er14
const char *v8; // rax
unsigned int v9; // er14
const char *v10; // rax
unsigned __int16 v11; // si
float v12; // xmm0_4
unsigned __int16 v13; // si
__int64 v14; // rsi
unsigned __int16 v15; // si
unsigned __int8 v16; // r14
__int64 v17; // r15
char *v18; // rbx
unsigned __int16 v19; // si
unsigned __int8 *v20; // [rsp+0h] [rbp-40h]

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:
++v3;
break;
case 4u:
case 0x24u:
case 0x25u:
case 0x29u:
case 0x41u:
printf("\t%d", v3[1]);
v3 += 2;
break;
case 5u:
case 0x2Au:
case 0x38u:
case 0x39u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Du:
case 0x42u:
v11 = *(_WORD *)(v3 + 1);
v3 += 3;
printf("\t%d", v11);
break;
case 6u:
v12 = *(float *)(v3 + 1);
v3 += 5;
printf("\t%g", v12);
break;
case 7u:
case 0x16u:
v13 = *(_WORD *)(v3 + 1);
v3 += 3;
printf("\t%d\t; \"%s\"", v13, (const char *)(*(_QWORD *)(lua_constant + 8LL * v13) + 20LL));
break;
case 8u:
v14 = *(_QWORD *)(v3 + 1);
v3 += 9;
printf("\t%p\t; \"%s\":%d", (const void *)v14, *(const char **)(v14 + 32), *(unsigned int *)(v14 + 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;
v6 = (const char *)LocStr(v5);
printf("\t%d\t; %s", v5, v6);
++v3;
break;
case 0x13u:
case 0x21u:
v9 = v3[1];
v10 = (const char *)LocStr(v9);
printf("\t%d\t; %s", v9, v10);
v3 += 2;
break;
case 0x14u:
case 0x22u:
v15 = *(_WORD *)(v3 + 1);
v3 += 3;
printf("\t%d\t; %s", v15, (const char *)(*(_QWORD *)(lua_table + 24LL * v15 + 16) + 20LL));
break;
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Du:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
v7 = v4 - 23;
v8 = (const char *)LocStr(v7);
printf("\t%d\t; %s", v7, v8);
++v3;
break;
case 0x26u:
case 0x3Fu:
printf("\t%d %d", v3[1], v3[2]);
v3 += 3;
break;
case 0x27u:
v16 = v3[1];
printf("\t%d", v16);
v20 = v3 + 2;
if ( v16 )
{
v17 = (__int64)&v3[2 * v16 + 2];
v18 = (char *)(v3 + 2);
do
{
printf("\n%6d\t FIELD", v18 - (char *)a1);
v19 = *(_WORD *)v18;
v18 += 2;
printf("\t%d\t; \"%s\"", v19, (const char *)(*(_QWORD *)(lua_constant + 8LL * v19) + 20LL));
}
while ( v18 != (char *)v17 );
v3 = &v20[2 * v16];
}
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; // rbx
unsigned int v4; // er14
unsigned int v5; // er14
const char *v6; // rax
unsigned int v7; // er14
const char *v8; // rax
unsigned int v9; // er14
const char *v10; // rax
unsigned __int16 v11; // si
float v12; // xmm0_4
unsigned __int16 v13; // si
__int64 v14; // rsi
unsigned __int16 v15; // si
unsigned __int8 v16; // r14
__int64 v17; // r15
char *v18; // rbx
unsigned __int16 v19; // si
unsigned __int8 *v20; // [rsp+0h] [rbp-40h]

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:
++v3;
break;
case 4u:
case 0x24u:
case 0x25u:
case 0x29u:
case 0x41u:
printf("\t%d", v3[1]);
v3 += 2;
break;
case 5u:
case 0x2Au:
case 0x38u:
case 0x39u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Du:
case 0x42u:
v11 = *(_WORD *)(v3 + 1);
v3 += 3;
printf("\t%d", v11);
break;
case 6u:
v12 = *(float *)(v3 + 1);
v3 += 5;
printf("\t%g", v12);
break;
case 7u:
case 0x16u:
v13 = *(_WORD *)(v3 + 1);
v3 += 3;
printf("\t%d\t; \"%s\"", v13, (const char *)(*(_QWORD *)(lua_constant + 8LL * v13) + 20LL));
break;
case 8u:
v14 = *(_QWORD *)(v3 + 1);
v3 += 9;
printf("\t%p\t; \"%s\":%d", (const void *)v14, *(const char **)(v14 + 32), *(unsigned int *)(v14 + 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;
v6 = (const char *)func0(v5);
printf("\t%d\t; %s", v5, v6);
++v3;
break;
case 0x13u:
case 0x21u:
v9 = v3[1];
v10 = (const char *)func0(v9);
printf("\t%d\t; %s", v9, v10);
v3 += 2;
break;
case 0x14u:
case 0x22u:
v15 = *(_WORD *)(v3 + 1);
v3 += 3;
printf("\t%d\t; %s", v15, (const char *)(*(_QWORD *)(lua_table + 24LL * v15 + 16) + 20LL));
break;
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Du:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
v7 = v4 - 23;
v8 = (const char *)func0(v7);
printf("\t%d\t; %s", v7, v8);
++v3;
break;
case 0x26u:
case 0x3Fu:
printf("\t%d %d", v3[1], v3[2]);
v3 += 3;
break;
case 0x27u:
v16 = v3[1];
printf("\t%d", v16);
v20 = v3 + 2;
if ( v16 )
{
v17 = (__int64)&v3[2 * v16 + 2];
v18 = (char *)(v3 + 2);
do
{
printf("\n%6d\t FIELD", v18 - (char *)a1);
v19 = *(_WORD *)v18;
v18 += 2;
printf("\t%d\t; \"%s\"", v19, (const char *)(*(_QWORD *)(lua_constant + 8LL * v19) + 20LL));
}
while ( v18 != (char *)v17 );
v3 = &v20[2 * v16];
}
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

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

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
__int64 v1; // rdx

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

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:
void __fastcall lua_setinput(__int64 a1)
{
current = 10;
lua_linenumber = 0;
input = a1;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
current = 10;
lua_linenumber = 0;
input = a1;
}

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(const char *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(const char *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)
{
const char *v2; // rbp
const unsigned __int16 **v3; // r12
__int64 v4; // rbx

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

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
const char *v2; // rbp
const unsigned __int16 **v3; // r12
__int64 v4; // rbx

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

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()
{
__int64 *v0; // rbx
__int64 result; // rax

v0 = (__int64 *)&reserved;
do
{
result = lua_createstring(*v0);
*(_DWORD *)(result + 16) = *((_DWORD *)v0 + 2);
v0 += 2;
}
while ( v0 != &LC7 );
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 *v0; // rbx
__int64 result; // rax

v0 = (__int64 *)&reserved;
do
{
result = lua_createstring(*v0);
*(_DWORD *)(result + 16) = *((_DWORD *)v0 + 2);
v0 += 2;
}
while ( v0 != &LC7 );
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: struct TaggedString { unsigned short varindex; unsigned short constindex; unsigned long hash; int marked; char str[1]; } *


decompiled_code:
__int64 __fastcall luaY_lex(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
__int64 v3; // rdx
char *v4; // rbx
unsigned int v5; // ebp
int v6; // eax
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx
__int64 v12; // rdx
__int64 v13; // r12
int v14; // er13
int v15; // er14
int v16; // er15
char *v17; // rbp
int v18; // eax
__int64 v19; // rdx
__int64 v20; // r12
int v21; // er13
int v22; // ebp
__int64 v23; // rax
int v24; // er12
__int64 v25; // rbp
_BYTE *v26; // r13
int v27; // er14
int v28; // er12
const unsigned __int16 **v29; // r13
int v30; // er12
int v31; // er14
int v32; // er15
__int64 v33; // r14
int v34; // ebp
double v35; // xmm0_8
float v36; // xmm0_4
char v38; // [rsp+0h] [rbp-48h]
double v39; // [rsp+0h] [rbp-48h]
double v40; // [rsp+8h] [rbp-40h]

v2 = 260LL;
v4 = (char *)luaI_buffer(260LL);
v4[3] = 0;
v4[2] = 0;
v4[1] = 0;
if ( lua_debug )
{
v2 = (unsigned int)linelasttoken_0;
luaI_codedebugline((unsigned int)linelasttoken_0);
}
linelasttoken_0 = lua_linenumber;
while ( 2 )
{
v5 = current;
switch ( current )
{
case 9:
case 13:
case 32:
current = input(v2, a2, v3);
continue;
case 10:
current = input(v2, a2, v3);
v2 = 1LL;
linelasttoken_0 = inclinenumber(1);
continue;
case 34:
case 39:
v38 = current;
*v4 = current;
current = ((__int64 (*)(void))input)();
v13 = 1LL;
v14 = 2;
v15 = 260;
v16 = 1;
if ( v5 == current )
goto LABEL_22;
while ( 2 )
{
switch ( current )
{
case 10:
goto LABEL_31;
case 92:
v18 = input(v2, a2, (unsigned int)v13);
current = v18;
if ( v18 == 114 )
{
v16 = v14;
v4[v13] = 13;
current = input(v2, a2, v19);
break;
}
if ( v18 > 114 )
{
if ( v18 == 116 )
{
v16 = v14;
v4[v13] = 9;
current = input(v2, a2, v19);
break;
}
}
else
{
if ( v18 == 10 )
{
v16 = v14;
v4[v13] = 10;
current = input(v2, a2, v19);
v2 = 0LL;
inclinenumber(0);
break;
}
if ( v18 == 110 )
{
v16 = v14;
v4[v13] = 10;
current = input(v2, a2, v19);
break;
}
}
v16 = v14;
v4[v13] = v18;
current = input(v2, a2, v19);
break;
case 0:
LABEL_31:
v4[(int)v13] = 0;
return 257;
default:
v16 = v14;
v4[v13] = current;
current = input(v2, a2, (unsigned int)v13);
break;
}
if ( v5 != current )
{
if ( v15 - v16 <= 2 )
{
v15 *= 2;
v2 = v15;
v4 = (char *)luaI_buffer(v15);
}
++v14;
++v13;
continue;
}
break;
}
LABEL_22:
current = input(v2, a2, v12);
v17 = &v4[v16];
*v17 = 0;
luaY_lval = luaI_findconstantbyname(v4 + 1);
*v17 = v38;
v4[v16 + 1] = 0;
return 273;
case 45:
*v4 = 45;
current = input(v2, a2, v3);
if ( current != 45 )
return v5;
do
{
v6 = input(v2, a2, v3);
current = v6;
}
while ( v6 != 10 && v6 );
continue;
case 46:
*v4 = 46;
v24 = ((__int64 (*)(void))input)();
current = v24;
if ( v24 == 46 )
{
v4[1] = 46;
current = ((__int64 (*)(void))input)();
v5 = 281;
if ( current == 46 )
{
v4[2] = 46;
current = ((__int64 (*)(void))input)();
v5 = 271;
}
}
else
{
if ( ((*_ctype_b_loc())[v24] & 0x800) == 0 )
return v5;
LODWORD(v25) = 1;
v39 = 0.0;
LABEL_55:
v29 = _ctype_b_loc();
v25 = (int)v25;
v40 = *(double *)&LC7;
while ( 1 )
{
v30 = v25;
if ( ((*v29)[current] & 0x800) == 0 )
break;
v39 = (double)(current - 48) * v40 + v39;
v40 = v40 / 10.0;
v4[v25] = current;
current = ((__int64 (*)(void))input)();
++v25;
}
if ( (current & 0xFFFFFFDF) != 69 )
goto LABEL_69;
v31 = v25 + 1;
v4[(int)v25] = current;
v32 = ((__int64 (*)(void))input)();
current = v32;
if ( ((v32 - 43) & 0xFFFFFFFD) == 0 )
{
v4[v31] = v32;
current = ((__int64 (*)(void))input)();
v31 = v25 + 2;
}
if ( ((*v29)[current] & 0x800) != 0 )
{
v33 = v31 + 1;
v34 = 0;
do
{
v34 = (int)((double)v34 * 10.0 + (double)(current - 48));
v30 = v33;
v4[v33 - 1] = current;
current = ((__int64 (*)(void))input)();
++v33;
}
while ( ((*v29)[current] & 0x800) != 0 );
v35 = *(double *)&LC7;
if ( v32 != 45 )
v35 = *(double *)&LC8;
for ( ; v34 > 0; v34 >>= 1 )
{
if ( (v34 & 1) != 0 )
v39 = v39 * v35;
v35 = v35 * v35;
}
LABEL_69:
v36 = v39;
luaY_lval = LODWORD(v36);
v4[v30] = 0;
return 272;
}
v4[v31] = 0;
v5 = 257;
}
return v5;
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
v26 = v4;
LODWORD(v25) = 0;
v39 = 0.0;
do
{
v39 = (double)(current - 48) + 10.0 * v39;
v27 = v25;
LODWORD(v25) = v25 + 1;
*v26 = current;
v28 = ((__int64 (*)(void))input)();
current = v28;
++v26;
}
while ( ((*_ctype_b_loc())[v28] & 0x800) != 0 );
if ( v28 == 46 )
{
v4[(int)v25] = 46;
current = ((__int64 (*)(void))input)();
LODWORD(v25) = v27 + 2;
if ( current == 46 )
luaI_syntaxerror("ambiguous syntax (decimal point x string concatenation)");
}
goto LABEL_55;
case 60:
*v4 = 60;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v9);
v5 = 279;
}
return v5;
case 61:
*v4 = 61;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v8);
v5 = 277;
}
return v5;
case 62:
*v4 = 62;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v10);
v5 = 280;
}
return v5;
case 65:
case 66:
case 67:
case 68:
case 69:
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
case 95:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
case 108:
case 109:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 120:
case 121:
case 122:
v20 = 1LL;
do
{
do
{
v21 = v20;
v4[v20 - 1] = current;
v22 = ((__int64 (*)(void))input)();
current = v22;
++v20;
}
while ( ((*_ctype_b_loc())[v22] & 8) != 0 );
}
while ( v22 == 95 );
v4[v21] = 0;
v23 = lua_createstring(v4);
v5 = *(_DWORD *)(v23 + 16);
if ( (int)v5 <= 2 )
{
luaY_lval = v23;
*(_DWORD *)(v23 + 16) = 2;
v5 = 274;
}
return v5;
case 91:
*v4 = 91;
current = input(v2, a2, v3);
if ( current == 91 )
{
v4[1] = 91;
current = input(v2, a2, v7);
v5 = read_long_string((__int64)v4, 260);
}
return v5;
case 126:
*v4 = 126;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v11);
v5 = 278;
}
return v5;
default:
*v4 = current;
current = ((__int64 (*)(void))input)();
return (unsigned int)*v4;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
__int64 v3; // rdx
char *v4; // rbx
unsigned int v5; // ebp
int v6; // eax
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx
__int64 v12; // rdx
__int64 v13; // r12
int v14; // er13
int v15; // er14
int v16; // er15
char *v17; // rbp
int v18; // eax
__int64 v19; // rdx
__int64 v20; // r12
int v21; // er13
int v22; // ebp
__int64 v23; // rax
int v24; // er12
__int64 v25; // rbp
_BYTE *v26; // r13
int v27; // er14
int v28; // er12
const unsigned __int16 **v29; // r13
int v30; // er12
int v31; // er14
int v32; // er15
__int64 v33; // r14
int v34; // ebp
double v35; // xmm0_8
float v36; // xmm0_4
char v38; // [rsp+0h] [rbp-48h]
double v39; // [rsp+0h] [rbp-48h]
double v40; // [rsp+8h] [rbp-40h]

v2 = 260LL;
v4 = (char *)luaI_buffer(260LL);
v4[3] = 0;
v4[2] = 0;
v4[1] = 0;
if ( lua_debug )
{
v2 = (unsigned int)linelasttoken_0;
luaI_codedebugline((unsigned int)linelasttoken_0);
}
linelasttoken_0 = lua_linenumber;
while ( 2 )
{
v5 = current;
switch ( current )
{
case 9:
case 13:
case 32:
current = input(v2, a2, v3);
continue;
case 10:
current = input(v2, a2, v3);
v2 = 1LL;
linelasttoken_0 = func2(1);
continue;
case 34:
case 39:
v38 = current;
*v4 = current;
current = ((__int64 (*)(void))input)();
v13 = 1LL;
v14 = 2;
v15 = 260;
v16 = 1;
if ( v5 == current )
goto LABEL_22;
while ( 2 )
{
switch ( current )
{
case 10:
goto LABEL_31;
case 92:
v18 = input(v2, a2, (unsigned int)v13);
current = v18;
if ( v18 == 114 )
{
v16 = v14;
v4[v13] = 13;
current = input(v2, a2, v19);
break;
}
if ( v18 > 114 )
{
if ( v18 == 116 )
{
v16 = v14;
v4[v13] = 9;
current = input(v2, a2, v19);
break;
}
}
else
{
if ( v18 == 10 )
{
v16 = v14;
v4[v13] = 10;
current = input(v2, a2, v19);
v2 = 0LL;
func2(0);
break;
}
if ( v18 == 110 )
{
v16 = v14;
v4[v13] = 10;
current = input(v2, a2, v19);
break;
}
}
v16 = v14;
v4[v13] = v18;
current = input(v2, a2, v19);
break;
case 0:
LABEL_31:
v4[(int)v13] = 0;
return 257;
default:
v16 = v14;
v4[v13] = current;
current = input(v2, a2, (unsigned int)v13);
break;
}
if ( v5 != current )
{
if ( v15 - v16 <= 2 )
{
v15 *= 2;
v2 = v15;
v4 = (char *)luaI_buffer(v15);
}
++v14;
++v13;
continue;
}
break;
}
LABEL_22:
current = input(v2, a2, v12);
v17 = &v4[v16];
*v17 = 0;
luaY_lval = luaI_findconstantbyname(v4 + 1);
*v17 = v38;
v4[v16 + 1] = 0;
return 273;
case 45:
*v4 = 45;
current = input(v2, a2, v3);
if ( current != 45 )
return v5;
do
{
v6 = input(v2, a2, v3);
current = v6;
}
while ( v6 != 10 && v6 );
continue;
case 46:
*v4 = 46;
v24 = ((__int64 (*)(void))input)();
current = v24;
if ( v24 == 46 )
{
v4[1] = 46;
current = ((__int64 (*)(void))input)();
v5 = 281;
if ( current == 46 )
{
v4[2] = 46;
current = ((__int64 (*)(void))input)();
v5 = 271;
}
}
else
{
if ( ((*_ctype_b_loc())[v24] & 0x800) == 0 )
return v5;
LODWORD(v25) = 1;
v39 = 0.0;
LABEL_55:
v29 = _ctype_b_loc();
v25 = (int)v25;
v40 = *(double *)&LC7;
while ( 1 )
{
v30 = v25;
if ( ((*v29)[current] & 0x800) == 0 )
break;
v39 = (double)(current - 48) * v40 + v39;
v40 = v40 / 10.0;
v4[v25] = current;
current = ((__int64 (*)(void))input)();
++v25;
}
if ( (current & 0xFFFFFFDF) != 69 )
goto LABEL_69;
v31 = v25 + 1;
v4[(int)v25] = current;
v32 = ((__int64 (*)(void))input)();
current = v32;
if ( ((v32 - 43) & 0xFFFFFFFD) == 0 )
{
v4[v31] = v32;
current = ((__int64 (*)(void))input)();
v31 = v25 + 2;
}
if ( ((*v29)[current] & 0x800) != 0 )
{
v33 = v31 + 1;
v34 = 0;
do
{
v34 = (int)((double)v34 * 10.0 + (double)(current - 48));
v30 = v33;
v4[v33 - 1] = current;
current = ((__int64 (*)(void))input)();
++v33;
}
while ( ((*v29)[current] & 0x800) != 0 );
v35 = *(double *)&LC7;
if ( v32 != 45 )
v35 = *(double *)&LC8;
for ( ; v34 > 0; v34 >>= 1 )
{
if ( (v34 & 1) != 0 )
v39 = v39 * v35;
v35 = v35 * v35;
}
LABEL_69:
v36 = v39;
luaY_lval = LODWORD(v36);
v4[v30] = 0;
return 272;
}
v4[v31] = 0;
v5 = 257;
}
return v5;
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
v26 = v4;
LODWORD(v25) = 0;
v39 = 0.0;
do
{
v39 = (double)(current - 48) + 10.0 * v39;
v27 = v25;
LODWORD(v25) = v25 + 1;
*v26 = current;
v28 = ((__int64 (*)(void))input)();
current = v28;
++v26;
}
while ( ((*_ctype_b_loc())[v28] & 0x800) != 0 );
if ( v28 == 46 )
{
v4[(int)v25] = 46;
current = ((__int64 (*)(void))input)();
LODWORD(v25) = v27 + 2;
if ( current == 46 )
func1("ambiguous syntax (decimal point x string concatenation)");
}
goto LABEL_55;
case 60:
*v4 = 60;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v9);
v5 = 279;
}
return v5;
case 61:
*v4 = 61;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v8);
v5 = 277;
}
return v5;
case 62:
*v4 = 62;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v10);
v5 = 280;
}
return v5;
case 65:
case 66:
case 67:
case 68:
case 69:
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
case 95:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
case 108:
case 109:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 120:
case 121:
case 122:
v20 = 1LL;
do
{
do
{
v21 = v20;
v4[v20 - 1] = current;
v22 = ((__int64 (*)(void))input)();
current = v22;
++v20;
}
while ( ((*_ctype_b_loc())[v22] & 8) != 0 );
}
while ( v22 == 95 );
v4[v21] = 0;
v23 = lua_createstring(v4);
v5 = *(_DWORD *)(v23 + 16);
if ( (int)v5 <= 2 )
{
luaY_lval = v23;
*(_DWORD *)(v23 + 16) = 2;
v5 = 274;
}
return v5;
case 91:
*v4 = 91;
current = input(v2, a2, v3);
if ( current == 91 )
{
v4[1] = 91;
current = input(v2, a2, v7);
v5 = func3((__int64)v4, 260);
}
return v5;
case 126:
*v4 = 126;
current = input(v2, a2, v3);
if ( current == 61 )
{
v4[1] = 61;
current = input(v2, a2, v11);
v5 = 278;
}
return v5;
default:
*v4 = current;
current = ((__int64 (*)(void))input)();
return (unsigned int)*v4;
}
}
}

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:
__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; // rbx
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; // rbx
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:
void luaI_invalidaterefs()
{
__int64 v0; // rbx
int v1; // ebp

if ( refSize > 0 )
{
v0 = 0LL;
v1 = 0;
do
{
if ( *(_DWORD *)(refArray + v0 + 16) == 1 && !(unsigned int)luaI_ismarked() )
*(_DWORD *)(refArray + v0 + 16) = 3;
++v1;
v0 += 24LL;
}
while ( refSize > v1 );
}
}

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

if ( refSize > 0 )
{
v0 = 0LL;
v1 = 0;
do
{
if ( *(_DWORD *)(refArray + v0 + 16) == 1 && !(unsigned int)luaI_ismarked() )
*(_DWORD *)(refArray + v0 + 16) = 3;
++v1;
v0 += 24LL;
}
while ( refSize > v1 );
}
}

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

variable_types: i int


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 *v2; // rbx

if ( a1 )
v2 = realloc(a1, a2);
else
v2 = malloc(a2);
if ( !v2 )
lua_error("not enough memory");
return v2;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1, size_t a2)
{
void *v2; // rbx

if ( a1 )
v2 = realloc(a1, a2);
else
v2 = malloc(a2);
if ( !v2 )
lua_error("not enough memory");
return v2;
}

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 v7; // rbx

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

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

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

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:
__int64 __fastcall luaI_buffer(size_t a1)
{
if ( buffsize_1 < a1 )
{
buffsize_1 = a1;
buffer_0 = (__int64)luaI_realloc((void *)buffer_0, a1);
}
return buffer_0;
}

canonical_decompiled_code:
__int64 __fastcall func3(size_t a1)
{
if ( buffsize_1 < a1 )
{
buffsize_1 = a1;
buffer_0 = (__int64)func1((void *)buffer_0, a1);
}
return buffer_0;
}

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
int v4; // edx
const char **v5; // r14
const char *v6; // r13
const char **v7; // r13
int v8; // eax

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

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // edx
const char **v5; // r14
const char *v6; // r13
const char **v7; // r13
int v8; // eax

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

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: result int


SawVar

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

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

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

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

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

variable_types: i int


ThreadCode

decompiled_code:
void __fastcall ThreadCode(unsigned __int8 *a1, unsigned __int8 *a2)
{
int v2; // ebp
__int64 v4; // rdx
int v5; // eax
__int64 v6; // rcx
__int64 v7; // rax
unsigned __int8 *v8; // rbx
int v9; // esi
__int64 v10; // rax
unsigned __int8 v11; // r13
unsigned __int8 *v12; // r14
__int64 v13; // r15
unsigned __int16 *v14; // rbx
__int16 v15; // si
unsigned __int16 v16; // di

v2 = (int)a1;
if ( lua_ntable )
{
v4 = 0LL;
v5 = 0;
do
{
**(_WORD **)(lua_table + v4 + 16) = 0;
++v5;
v4 += 24LL;
}
while ( lua_ntable > v5 );
}
if ( lua_nconstant )
{
v6 = 8LL * lua_nconstant;
v7 = 0LL;
do
{
*(_WORD *)(*(_QWORD *)(lua_constant + v7) + 2LL) = 0;
v7 += 8LL;
}
while ( v7 != v6 );
}
if ( a1 != a2 )
{
v8 = a1;
do
{
v9 = (_DWORD)v8 - v2 + 1;
switch ( *v8 )
{
case 0u:
case 1u:
case 2u:
case 3u:
case 9u:
case 0xAu:
case 0xBu:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x11u:
case 0x12u:
case 0x15u:
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Du:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
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:
++v8;
break;
case 4u:
case 0x13u:
case 0x21u:
case 0x24u:
case 0x25u:
case 0x29u:
case 0x41u:
v8 += 2;
break;
case 5u:
case 0x26u:
case 0x2Au:
case 0x38u:
case 0x39u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Du:
case 0x3Fu:
case 0x42u:
v8 += 3;
break;
case 6u:
v8 += 5;
break;
case 7u:
case 0x16u:
*(_WORD *)(v8 + 1) = SawStr(*(unsigned __int16 *)(v8 + 1), v9);
v8 += 3;
break;
case 8u:
v10 = *(_QWORD *)(v8 + 1);
v8 += 9;
*(_DWORD *)(v10 + 8) = v9;
*(_QWORD *)v10 = 0LL;
*(_QWORD *)lastF = v10;
lastF = v10;
break;
case 0x14u:
case 0x22u:
*(_WORD *)(v8 + 1) = SawVar(*(unsigned __int16 *)(v8 + 1), v9);
v8 += 3;
break;
case 0x27u:
v11 = v8[1];
v12 = v8 + 2;
if ( v11 )
{
v13 = (__int64)&v8[2 * v11 + 2];
v14 = (unsigned __int16 *)(v8 + 2);
do
{
v15 = (_WORD)v14 - v2;
v16 = *v14++;
*(v14 - 1) = SawStr(v16, v15);
}
while ( (unsigned __int16 *)v13 != v14 );
v8 = &v12[2 * v11];
}
else
{
v8 += 2;
}
break;
default:
fprintf(stderr, "luac: cannot happen: opcode=%d", *v8);
exit(1);
}
}
while ( a2 != v8 );
}
}

canonical_decompiled_code:
void __fastcall func2(unsigned __int8 *a1, unsigned __int8 *a2)
{
int v2; // ebp
__int64 v4; // rdx
int v5; // eax
__int64 v6; // rcx
__int64 v7; // rax
unsigned __int8 *v8; // rbx
int v9; // esi
__int64 v10; // rax
unsigned __int8 v11; // r13
unsigned __int8 *v12; // r14
__int64 v13; // r15
unsigned __int16 *v14; // rbx
__int16 v15; // si
unsigned __int16 v16; // di

v2 = (int)a1;
if ( lua_ntable )
{
v4 = 0LL;
v5 = 0;
do
{
**(_WORD **)(lua_table + v4 + 16) = 0;
++v5;
v4 += 24LL;
}
while ( lua_ntable > v5 );
}
if ( lua_nconstant )
{
v6 = 8LL * lua_nconstant;
v7 = 0LL;
do
{
*(_WORD *)(*(_QWORD *)(lua_constant + v7) + 2LL) = 0;
v7 += 8LL;
}
while ( v7 != v6 );
}
if ( a1 != a2 )
{
v8 = a1;
do
{
v9 = (_DWORD)v8 - v2 + 1;
switch ( *v8 )
{
case 0u:
case 1u:
case 2u:
case 3u:
case 9u:
case 0xAu:
case 0xBu:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x11u:
case 0x12u:
case 0x15u:
case 0x17u:
case 0x18u:
case 0x19u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Du:
case 0x1Eu:
case 0x1Fu:
case 0x20u:
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:
++v8;
break;
case 4u:
case 0x13u:
case 0x21u:
case 0x24u:
case 0x25u:
case 0x29u:
case 0x41u:
v8 += 2;
break;
case 5u:
case 0x26u:
case 0x2Au:
case 0x38u:
case 0x39u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Du:
case 0x3Fu:
case 0x42u:
v8 += 3;
break;
case 6u:
v8 += 5;
break;
case 7u:
case 0x16u:
*(_WORD *)(v8 + 1) = func1(*(unsigned __int16 *)(v8 + 1), v9);
v8 += 3;
break;
case 8u:
v10 = *(_QWORD *)(v8 + 1);
v8 += 9;
*(_DWORD *)(v10 + 8) = v9;
*(_QWORD *)v10 = 0LL;
*(_QWORD *)lastF = v10;
lastF = v10;
break;
case 0x14u:
case 0x22u:
*(_WORD *)(v8 + 1) = func0(*(unsigned __int16 *)(v8 + 1), v9);
v8 += 3;
break;
case 0x27u:
v11 = v8[1];
v12 = v8 + 2;
if ( v11 )
{
v13 = (__int64)&v8[2 * v11 + 2];
v14 = (unsigned __int16 *)(v8 + 2);
do
{
v15 = (_WORD)v14 - v2;
v16 = *v14++;
*(v14 - 1) = func1(v16, v15);
}
while ( (unsigned __int16 *)v13 != v14 );
v8 = &v12[2 * v11];
}
else
{
v8 += 2;
}
break;
default:
fprintf(stderr, "luac: cannot happen: opcode=%d", *v8);
exit(1);
}
}
while ( a2 != v8 );
}
}

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(char *src, _QWORD *a2)
{
size_t v2; // rax
char *v3; // rbp
_QWORD *v4; // rbx
__int64 v5; // rbx
int i; // ebp
char **v7; // r12
char *v8; // rax

v2 = strlen(src);
v3 = (char *)malloc(v2);
strcpy(v3, src);
v4 = malloc(0x320uLL);
*a2 = v4;
*v4 = strtok(v3, "| \t");
v5 = 8LL;
for ( i = 1; ; ++i )
{
v7 = (char **)(*a2 + v5);
v8 = strtok(0LL, "| \t");
*v7 = v8;
v5 += 8LL;
if ( i > 99 || !v8 )
break;
}
return (unsigned int)i;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *src, _QWORD *a2)
{
size_t v2; // rax
char *v3; // rbp
_QWORD *v4; // rbx
__int64 v5; // rbx
int i; // ebp
char **v7; // r12
char *v8; // rax

v2 = strlen(src);
v3 = (char *)malloc(v2);
strcpy(v3, src);
v4 = malloc(0x320uLL);
*a2 = v4;
*v4 = strtok(v3, "| \t");
v5 = 8LL;
for ( i = 1; ; ++i )
{
v7 = (char **)(*a2 + v5);
v8 = strtok(0LL, "| \t");
*v7 = v8;
v5 += 8LL;
if ( i > 99 || !v8 )
break;
}
return (unsigned int)i;
}

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; // ebx
__int64 v5; // rcx
struct termios *v6; // rdi
__int64 v7; // rax
int v8; // eax
__int64 v9; // [rsp+8h] [rbp-1A0h] BYREF
char buf[256]; // [rsp+10h] [rbp-198h] BYREF
struct termios v11; // [rsp+110h] [rbp-98h] BYREF
struct termios termios_p; // [rsp+150h] [rbp-58h] 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_cflag = -2147481412;
v11.c_iflag = 260;
v11.c_lflag = 2;
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, &v9) > 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; // ebx
__int64 v5; // rcx
struct termios *v6; // rdi
__int64 v7; // rax
int v8; // eax
__int64 v9; // [rsp+8h] [rbp-1A0h] BYREF
char buf[256]; // [rsp+10h] [rbp-198h] BYREF
struct termios v11; // [rsp+110h] [rbp-98h] BYREF
struct termios termios_p; // [rsp+150h] [rbp-58h] 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_cflag = -2147481412;
v11.c_iflag = 260;
v11.c_lflag = 2;
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, &v9) > 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 **


repo: cthulhuology/Jawas

decompiled_code:
__int64 __fastcall parse_uri_encoded(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // r15
signed int v5; // er13
const unsigned __int16 **v6; // r14
const unsigned __int16 *v7; // rbp
__int64 v9; // rdx
unsigned int v10; // eax
unsigned int v11; // ebp
__int64 v12; // r14
unsigned int v13; // ebp
int v14; // eax
int v15; // ebx

if ( !a2 )
return 0LL;
v3 = a1;
v5 = len(a2);
if ( !a1 )
v3 = new_headers();
v6 = _ctype_b_loc();
while ( 1 )
{
v7 = *v6;
if ( (v7[(char)at(a2, a3)] & 0x2000) == 0 )
break;
++a3;
}
if ( (int)a3 < v5 )
{
while ( 1 )
{
v10 = find(a2, a3, &unk_4B3, 1LL);
v11 = v10;
if ( v5 <= (int)v10 )
break;
v12 = ref(*(_QWORD *)(a2 + 8) + (int)a3, v10 - a3);
v13 = v11 + 1;
v14 = find(a2, v13, "&\r\n", 1LL);
v15 = v14;
if ( v5 >= v14 )
v9 = ref(*(_QWORD *)(a2 + 8) + (int)v13, v14 - v13);
else
v9 = ref(*(_QWORD *)(a2 + 8) + (int)v13, v5 - v13);
append_header(v3, v12, v9);
a3 = v15 + 1;
if ( v5 <= (int)a3 )
return v3;
}
log_msg(3LL, "Key not found %i > %i", v10, (unsigned int)v5);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // r15
signed int v5; // er13
const unsigned __int16 **v6; // r14
const unsigned __int16 *v7; // rbp
__int64 v9; // rdx
unsigned int v10; // eax
unsigned int v11; // ebp
__int64 v12; // r14
unsigned int v13; // ebp
int v14; // eax
int v15; // ebx

if ( !a2 )
return 0LL;
v3 = a1;
v5 = len(a2);
if ( !a1 )
v3 = new_headers();
v6 = _ctype_b_loc();
while ( 1 )
{
v7 = *v6;
if ( (v7[(char)at(a2, a3)] & 0x2000) == 0 )
break;
++a3;
}
if ( (int)a3 < v5 )
{
while ( 1 )
{
v10 = find(a2, a3, &unk_4B3, 1LL);
v11 = v10;
if ( v5 <= (int)v10 )
break;
v12 = ref(*(_QWORD *)(a2 + 8) + (int)a3, v10 - a3);
v13 = v11 + 1;
v14 = find(a2, v13, "&\r\n", 1LL);
v15 = v14;
if ( v5 >= v14 )
v9 = ref(*(_QWORD *)(a2 + 8) + (int)v13, v14 - v13);
else
v9 = ref(*(_QWORD *)(a2 + 8) + (int)v13, v5 - v13);
append_header(v3, v12, v9);
a3 = v15 + 1;
if ( v5 <= (int)a3 )
return v3;
}
log_msg(3LL, "Key not found %i > %i", v10, (unsigned int)v5);
}
return v3;
}

original_code:
Headers
parse_uri_encoded(Headers head, str buf, int pos)
{
 if (!buf) return ((void *)0);
 int i,o,l = len(buf);
 str key = ((void *)0), value = ((void *)0);
 Headers retval = (head ? head : new_headers());
 for (i = pos; ((*__ctype_b_loc ())[(int) ((at(buf,i)))] & (unsigned short int) _ISspace); ++i);
 for (; i < l; ++i) {
  o = find(buf,i,"=",1);
  if (o >= l) {
    log_msg(3,"Key not found %i > %i",o,l);
    break;
  }
  key = ref(buf->data+i,o-i);
  i = o+1;
  o = find(buf,i,"&\r\n",1);
  value = (o > l) ?
   ref(buf->data+i,l-i):
   ref(buf->data+i,o-i);
  append_header(retval,key,value);
  i = o;
 }
 return retval;
}

canonical_original_code:
struct headers_struct *parse_uri_encoded(struct headers_struct *head, struct str_struct *buf, int pos)
{
 if (!buf) return ((void *)0);
 int i; int o; int l = len(buf);
 struct str_struct *key = ((void *)0); struct str_struct *value = ((void *)0);
 struct headers_struct *retval = (head ? head : new_headers());
 for (i = pos; ((*__ctype_b_loc ())[(int) ((at(buf,i)))] & (unsigned short) _ISspace); ++i);
 for (; i < l; ++i) {
  o = find(buf,i,"=",1);
  if (o >= l) {
    log_msg(3,"Key not found %i > %i",o,l);
    break;
  }
  key = ref(buf->data+i,o-i);
  i = o+1;
  o = find(buf,i,"&\r\n",1);
  value = (o > l) ?
   ref(buf->data+i,l-i):
   ref(buf->data+i,o-i);
  append_header(retval,key,value);
  i = o;
 }
 return retval;
}

variable_types:
head
struct headers_struct *

variable_types:
buf
struct str_struct *

variable_types: pos int

variable_types: o int

variable_types: l int

variable_types: struct headers_struct { int nslots; struct headers_data_struct { struct str_struct { int length; char *data; char contents[]; } *key; struct str_struct *value; } slots[250]; } *

user_defined_types: struct headers_struct { int nslots; struct headers_data_struct slots[250]; }

user_defined_types: struct headers_data_struct { struct str_struct *key; struct str_struct *value; }


decompiled_code:
__int64 __fastcall is_mark_char(char a1)
{
const char *v1; // rax

v1 = "-_.!~*'()";
while ( *v1 != a1 )
{
if ( ++v1 == "" )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1)
{
const char *v1; // rax

v1 = "-_.!~*'()";
while ( *v1 != a1 )
{
if ( ++v1 == "" )
return 0LL;
}
return 1LL;
}

original_code:
int
is_mark_char(char c)
{
 int k;
 for (k = 0; k < mark_len; ++k)
  if (mark_chars[k] == c)
   return 1;
 return 0;
}

variable_types: c char

variable_types: k int


decompiled_code:
_BOOL8 __fastcall is_clean_char(char a1)
{
int v1; // edx
_BOOL8 result; // rax
int v3; // edx
int v4; // edx

v1 = between(65LL, (unsigned int)a1, 90LL);
result = 1LL;
if ( !v1 )
{
v3 = between(97LL, (unsigned int)a1, 122LL);
result = 1LL;
if ( !v3 )
{
v4 = between(48LL, (unsigned int)a1, 57LL);
result = 1LL;
if ( !v4 )
result = (unsigned int)is_mark_char(a1) != 0;
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(char a1)
{
int v1; // edx
_BOOL8 result; // rax
int v3; // edx
int v4; // edx

v1 = between(65LL, (unsigned int)a1, 90LL);
result = 1LL;
if ( !v1 )
{
v3 = between(97LL, (unsigned int)a1, 122LL);
result = 1LL;
if ( !v3 )
{
v4 = between(48LL, (unsigned int)a1, 57LL);
result = 1LL;
if ( !v4 )
result = (unsigned int)func1(a1) != 0;
}
}
return result;
}

original_code:
int
is_clean_char(char c)
{
 return (between('A',c,'Z')
  || between('a',c,'z')
  || between('0',c,'9')
  || is_mark_char(c));
}


decompiled_code:
__int64 __fastcall uri_encode(__int64 a1)
{
int v1; // eax
int v2; // ebp
unsigned int v3; // ebx
unsigned int i; // er13
char v5; // al
__int64 v6; // r15
unsigned int v7; // ebp
unsigned int j; // er12
unsigned int v9; // er14
char v10; // bl

v1 = len(a1);
if ( v1 <= 0 )
return blank(0LL);
v2 = v1;
v3 = 0;
for ( i = 0; ; ++i )
{
v5 = at(a1, i);
v3 += !is_clean_char(v5) ? 3 : 1;
if ( v2 == i + 1 )
break;
}
v6 = blank(v3);
v7 = 0;
for ( j = 0; ; ++j )
{
v10 = at(a1, j);
if ( is_clean_char(v10) )
{
set(v6, v7++, (unsigned int)v10);
}
else
{
set(v6, v7, 37LL);
v9 = v7 + 2;
set(v6, v7 + 1, (unsigned int)hex_chars[v10 / 16]);
v7 += 3;
set(v6, v9, (unsigned int)hex_chars[v10 % 16]);
}
if ( i == j )
break;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v1; // eax
int v2; // ebp
unsigned int v3; // ebx
unsigned int i; // er13
char v5; // al
__int64 v6; // r15
unsigned int v7; // ebp
unsigned int j; // er12
unsigned int v9; // er14
char v10; // bl

v1 = len(a1);
if ( v1 <= 0 )
return blank(0LL);
v2 = v1;
v3 = 0;
for ( i = 0; ; ++i )
{
v5 = at(a1, i);
v3 += !func2(v5) ? 3 : 1;
if ( v2 == i + 1 )
break;
}
v6 = blank(v3);
v7 = 0;
for ( j = 0; ; ++j )
{
v10 = at(a1, j);
if ( func2(v10) )
{
set(v6, v7++, (unsigned int)v10);
}
else
{
set(v6, v7, 37LL);
v9 = v7 + 2;
set(v6, v7 + 1, (unsigned int)hex_chars[v10 / 16]);
v7 += 3;
set(v6, v9, (unsigned int)hex_chars[v10 % 16]);
}
if ( i == j )
break;
}
return v6;
}

original_code:
str
uri_encode(str s)
{
 str retval = ((void *)0);
 int i, j = 0, l = len(s);
 for (i = 0; i < l; ++i)
  j += is_clean_char(at(s,i)) ? 1 : 3;
 retval = blank(j);
 j = 0;
 for (i = 0; i < l; ++i) {
  char c = at(s,i);
  if (is_clean_char(c)) {
   set(retval,j++,c);
  } else {
   set(retval,j++,'%');
   set(retval,j++,hex_chars[c/16]);
   set(retval,j++,hex_chars[c%16]);
  }
 }
 return retval;
}

canonical_original_code:
struct str_struct *uri_encode(struct str_struct *s)
{
 struct str_struct *retval = ((void *)0);
 int i; int j = 0; int l = len(s);
 for (i = 0; i < l; ++i)
  j += is_clean_char(at(s,i)) ? 1 : 3;
 retval = blank(j);
 j = 0;
 for (i = 0; i < l; ++i) {
  char c = at(s,i);
  if (is_clean_char(c)) {
   set(retval,j++,c);
  } else {
   set(retval,j++,'%');
   set(retval,j++,hex_chars[c/16]);
   set(retval,j++,hex_chars[c%16]);
  }
 }
 return retval;
}

variable_types:
s
struct str_struct *

variable_types: struct str_struct { int length; char *data; char contents[]; } *

variable_types: i int

variable_types: j int


decompiled_code:
__int64 __fastcall from_hex(char a1, int a2)
{
unsigned int v2; // ebx

v2 = 16 * a1;
if ( !(unsigned int)between(48LL, (unsigned int)a1, 57LL) )
v2 = 0;
if ( (unsigned int)between(65LL, (unsigned int)a1, 70LL) )
v2 += 16 * (a1 - 55);
if ( (unsigned int)between(97LL, (unsigned int)a1, 102LL) )
v2 += 16 * (a1 - 87);
if ( (unsigned int)between(48LL, (unsigned int)(char)a2, 57LL) )
v2 = v2 + a2 - 48;
if ( (unsigned int)between(65LL, (unsigned int)(char)a2, 70LL) )
v2 = v2 + a2 - 55;
if ( (unsigned int)between(97LL, (unsigned int)(char)a2, 102LL) )
v2 = v2 + a2 - 87;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(char a1, int a2)
{
unsigned int v2; // ebx

v2 = 16 * a1;
if ( !(unsigned int)between(48LL, (unsigned int)a1, 57LL) )
v2 = 0;
if ( (unsigned int)between(65LL, (unsigned int)a1, 70LL) )
v2 += 16 * (a1 - 55);
if ( (unsigned int)between(97LL, (unsigned int)a1, 102LL) )
v2 += 16 * (a1 - 87);
if ( (unsigned int)between(48LL, (unsigned int)(char)a2, 57LL) )
v2 = v2 + a2 - 48;
if ( (unsigned int)between(65LL, (unsigned int)(char)a2, 70LL) )
v2 = v2 + a2 - 55;
if ( (unsigned int)between(97LL, (unsigned int)(char)a2, 102LL) )
v2 = v2 + a2 - 87;
return v2;
}

original_code:
char
from_hex(char a, char b)
{
 char retval = 0;
 if (between('0',a,'9')) retval += (a - '0')*16;
 if (between('A',a,'F')) retval += (a - 'A'+10)*16;
 if (between('a',a,'f')) retval += (a - 'a'+10)*16;
 if (between('0',b,'9')) retval += (b - '0');
 if (between('A',b,'F')) retval += (b - 'A'+10);
 if (between('a',b,'f')) retval += (b - 'a'+10);
 return retval;
}

variable_types: a char

variable_types: b char

variable_types: retval char

return_type: char


decompiled_code:
int *__fastcall uri_decode(__int64 a1)
{
int v1; // er14
int *v2; // r15
int v3; // ebp
unsigned int i; // ebx
unsigned int v5; // er13
char v6; // al
char v7; // al
char v8; // al
int v10; // [rsp+8h] [rbp-40h]
char v11; // [rsp+8h] [rbp-40h]

v1 = len(a1);
v2 = (int *)blank((unsigned int)v1);
if ( v1 <= 0 )
{
v10 = 0;
}
else
{
v3 = 1;
for ( i = 0; (int)i < v1; ++i )
{
v5 = v3 - 1;
if ( (unsigned __int8)at(a1, i) == 43 )
{
v10 = v3;
set(v2, v5, 32LL);
}
else if ( (unsigned __int8)at(a1, i) == 37 )
{
v11 = at(a1, i + 2);
v7 = at(a1, i + 1);
v8 = from_hex(v7, v11);
v10 = v3;
set(v2, v5, (unsigned int)v8);
i += 2;
}
else
{
v6 = at(a1, i);
v10 = v3;
set(v2, v5, (unsigned int)v6);
}
++v3;
}
}
*v2 = v10;
return v2;
}

canonical_decompiled_code:
int *__fastcall func5(__int64 a1)
{
int v1; // er14
int *v2; // r15
int v3; // ebp
unsigned int i; // ebx
unsigned int v5; // er13
char v6; // al
char v7; // al
char v8; // al
int v10; // [rsp+8h] [rbp-40h]
char v11; // [rsp+8h] [rbp-40h]

v1 = len(a1);
v2 = (int *)blank((unsigned int)v1);
if ( v1 <= 0 )
{
v10 = 0;
}
else
{
v3 = 1;
for ( i = 0; (int)i < v1; ++i )
{
v5 = v3 - 1;
if ( (unsigned __int8)at(a1, i) == 43 )
{
v10 = v3;
set(v2, v5, 32LL);
}
else if ( (unsigned __int8)at(a1, i) == 37 )
{
v11 = at(a1, i + 2);
v7 = at(a1, i + 1);
v8 = func4(v7, v11);
v10 = v3;
set(v2, v5, (unsigned int)v8);
i += 2;
}
else
{
v6 = at(a1, i);
v10 = v3;
set(v2, v5, (unsigned int)v6);
}
++v3;
}
}
*v2 = v10;
return v2;
}

original_code:
str
uri_decode(str s)
{
 int i, j = 0, l = len(s);
 str retval = blank(l);
 for(i = 0; i < l; ++i)
  if (at(s,i) == '+') {
   set(retval,j++,' ');
  } else if (at(s,i) == '%') {
   set(retval,j++,from_hex(at(s,i+1),at(s,i+2)));
   i += 2;
  } else {
   set(retval,j++,at(s,i));
  }
 retval->length = j;
 return retval;
}

canonical_original_code:
struct str_struct *uri_decode(struct str_struct *s)
{
 int i; int j = 0; int l = len(s);
 struct str_struct *retval = blank(l);
 for(i = 0; i < l; ++i)
  if (at(s,i) == '+') {
   set(retval,j++,' ');
  } else if (at(s,i) == '%') {
   set(retval,j++,from_hex(at(s,i+1),at(s,i+2)));
   i += 2;
  } else {
   set(retval,j++,at(s,i));
  }
 retval->length = j;
 return retval;
}

return_type: struct str_struct { int length; char *data; char contents[]; } *


decompiled_code:
__int64 head_method()
{
return error_handler(405LL);
}

canonical_decompiled_code:
__int64 func0()
{
return error_handler(405LL);
}

original_code: int head_method() { return error_handler(405); }


decompiled_code:
__int64 put_method()
{
return error_handler(405LL);
}

canonical_decompiled_code:
__int64 func1()
{
return error_handler(405LL);
}

original_code: int put_method() { return error_handler(405); }


decompiled_code:
__int64 delete_method()
{
return error_handler(405LL);
}

canonical_decompiled_code:
__int64 func2()
{
return error_handler(405LL);
}

original_code: int delete_method() { return error_handler(405); }


decompiled_code:
__int64 options_method()
{
return error_handler(405LL);
}

canonical_decompiled_code:
__int64 func3()
{
return error_handler(405LL);
}

original_code: int options_method() { return error_handler(405); }


decompiled_code:
__int64 trace_method()
{
return error_handler(405LL);
}

canonical_decompiled_code:
__int64 func4()
{
return error_handler(405LL);
}

original_code: int trace_method() { return error_handler(405); }