main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
time_t *v3; // rbx
_DWORD *v4; // r14
char *v5; // rbp
const char *v6; // r15
int v7; // eax
int v8; // eax
const char *v9; // r15
struct tm *v10; // r12
char *v11; // rax
char *v12; // rax
char *v13; // rax
double v14; // [rsp+8h] [rbp-60h]
int v15; // [rsp+18h] [rbp-50h] BYREF
char v16; // [rsp+1Fh] [rbp-49h] BYREF
int longind; // [rsp+20h] [rbp-48h] BYREF
int v18; // [rsp+24h] [rbp-44h] BYREF
time_t time1; // [rsp+28h] [rbp-40h] BYREF

v18 = 20;
v3 = (time_t *)malloc(8uLL);
v4 = malloc(4uLL);
*v4 = 0;
longind = 0;
v16 = 109;
v5 = 0LL;
while ( 1 )
{
v8 = getopt_long(argc, (char *const *)argv, "t:s:", &long_options, &longind);
if ( v8 == -1 )
break;
if ( v8 == 115 )
{
v6 = optarg;
v7 = strlen(optarg);
v5 = (char *)malloc(v7 + 1);
strcpy(v5, v6);
}
else if ( v8 == 116 )
{
v9 = optarg;
v18 = atoi(optarg);
v16 = v9[strlen(v9) - 1];
}
}
initscr();
noecho();
cbreak();
wtimeout(_bss_start, 500);
*v3 = time(0LL);
v10 = localtime(v3);
setTime((unsigned int *)&v18, &v16, v10);
time1 = mktime(v10);
v11 = ctime(v3);
mvprintw(0, 0, "Tiempo inicial: %s", v11);
if ( !v5 )
{
v5 = (char *)malloc(0x17uLL);
strcpy(v5, "Tarea no especificada.");
}
mvprintw(5, 0, "Tarea: %s", v5);
while ( 1 )
{
v14 = difftime(time1, *v3);
if ( v14 <= 0.0 )
break;
v13 = ctime(&time1);
mvprintw(1, 0, "Tiempo final: %s", v13);
*v3 = time(0LL);
v15 = wgetch(_bss_start);
eleccion(v4, &v15, v3);
if ( *v4 )
time1 = *v3 + (int)v14;
v12 = ctime(v3);
mvprintw(2, 0, "Tiempo actual: %s", v12);
}
endwin();
free(v4);
free(v3);
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
time_t *v3; // rbx
_DWORD *v4; // r14
char *v5; // rbp
const char *v6; // r15
int v7; // eax
int v8; // eax
const char *v9; // r15
struct tm *v10; // r12
char *v11; // rax
char *v12; // rax
char *v13; // rax
double v14; // [rsp+8h] [rbp-60h]
int v15; // [rsp+18h] [rbp-50h] BYREF
char v16; // [rsp+1Fh] [rbp-49h] BYREF
int longind; // [rsp+20h] [rbp-48h] BYREF
int v18; // [rsp+24h] [rbp-44h] BYREF
time_t time1; // [rsp+28h] [rbp-40h] BYREF

v18 = 20;
v3 = (time_t *)malloc(8uLL);
v4 = malloc(4uLL);
*v4 = 0;
longind = 0;
v16 = 109;
v5 = 0LL;
while ( 1 )
{
v8 = getopt_long(argc, (char *const *)argv, "t:s:", &long_options, &longind);
if ( v8 == -1 )
break;
if ( v8 == 115 )
{
v6 = optarg;
v7 = strlen(optarg);
v5 = (char *)malloc(v7 + 1);
strcpy(v5, v6);
}
else if ( v8 == 116 )
{
v9 = optarg;
v18 = atoi(optarg);
v16 = v9[strlen(v9) - 1];
}
}
initscr();
noecho();
cbreak();
wtimeout(_bss_start, 500);
*v3 = time(0LL);
v10 = localtime(v3);
func7((unsigned int *)&v18, &v16, v10);
time1 = mktime(v10);
v11 = ctime(v3);
mvprintw(0, 0, "Tiempo inicial: %s", v11);
if ( !v5 )
{
v5 = (char *)malloc(0x17uLL);
strcpy(v5, "Tarea no especificada.");
}
mvprintw(5, 0, "Tarea: %s", v5);
while ( 1 )
{
v14 = difftime(time1, *v3);
if ( v14 <= 0.0 )
break;
v13 = ctime(&time1);
mvprintw(1, 0, "Tiempo final: %s", v13);
*v3 = time(0LL);
v15 = wgetch(_bss_start);
func8(v4, &v15, v3);
if ( *v4 )
time1 = *v3 + (int)v14;
v12 = ctime(v3);
mvprintw(2, 0, "Tiempo actual: %s", v12);
}
endwin();
free(v4);
free(v3);
exit(0);
}

original_code:
int main(int argc, char *argv[]) {
  struct tm *tiempo;
  time_t final;
  time_t *actual;
  int valor = 20;
  double diferencia = 0;
  actual = (time_t *)malloc(sizeof(time_t));
  int *sesion = ((void *)0);
  sesion = (int *)malloc(sizeof(int));
  *sesion = 0;
  int long_index = 0;
  int opt = 0;
  int longitud = 0;
  char tipo = 'm';
  char *tarea = ((void *)0);
  while ((opt = getopt_long(argc, argv, "t:s:",
          long_options, &long_index)) != -1) {
    switch(opt) {
      case 't':
        valor = atoi(optarg);
        tipo = *(optarg + strlen(optarg) - 1);
        break;
      case 's':
        longitud = strlen(optarg);
        tarea = (char *)malloc(longitud + 1);
        strcpy(tarea, optarg);
      default:
        break;
    }
  }
  initscr();
  noecho();
  cbreak();
  wtimeout(stdscr,(500));
  *actual = time(((void *)0));
  tiempo = localtime(actual);
  setTime(&valor, &tipo, tiempo);
  final = mktime(tiempo);
  mvprintw(0,0,"Tiempo inicial: %s", ctime(actual));
  if (tarea == ((void *)0)) {
    longitud = strlen("Tarea no especificada.");
    tarea = (char *)malloc(longitud + 1);
    strcpy(tarea, "Tarea no especificada.");
  }
  mvprintw(5,0,"Tarea: %s", tarea);
  while ((diferencia = difftime(final, *actual)) > 0) {
    mvprintw(1,0,"Tiempo final:   %s", ctime(&final));
    *actual = time(((void *)0));
    int c = wgetch(stdscr);
    eleccion(sesion, &c, actual);
    if (*sesion) {
      final = *actual + (int) diferencia;
    }
    mvprintw(2,0,"Tiempo actual:  %s", ctime(actual));
  }
  endwin();
  if (sesion != ((void *)0)) free(sesion);
  if (actual != ((void *)0)) free(actual);
  exit(0);
}

canonical_original_code:
int main(int argc, char *argv[]) {
  struct tm *tiempo;
  long final;
  long *actual;
  int valor = 20;
  double diferencia = 0;
  actual = (long *)malloc(sizeof(time_t));
  int *sesion = ((void *)0);
  sesion = (int *)malloc(sizeof(int));
  *sesion = 0;
  int long_index = 0;
  int opt = 0;
  int longitud = 0;
  char tipo = 'm';
  char *tarea = ((void *)0);
  while ((opt = getopt_long(argc, argv, "t:s:",
          long_options, &long_index)) != -1) {
    switch(opt) {
      case 't':
        valor = atoi(optarg);
        tipo = *(optarg + strlen(optarg) - 1);
        break;
      case 's':
        longitud = strlen(optarg);
        tarea = (char *)malloc(longitud + 1);
        strcpy(tarea, optarg);
      default:
        break;
    }
  }
  initscr();
  noecho();
  cbreak();
  wtimeout(stdscr,(500));
  *actual = time(((void *)0));
  tiempo = localtime(actual);
  setTime(&valor, &tipo, tiempo);
  final = mktime(tiempo);
  mvprintw(0,0,"Tiempo inicial: %s", ctime(actual));
  if (tarea == ((void *)0)) {
    longitud = strlen("Tarea no especificada.");
    tarea = (char *)malloc(longitud + 1);
    strcpy(tarea, "Tarea no especificada.");
  }
  mvprintw(5,0,"Tarea: %s", tarea);
  while ((diferencia = difftime(final, *actual)) > 0) {
    mvprintw(1,0,"Tiempo final:   %s", ctime(&final));
    *actual = time(((void *)0));
    int c = wgetch(stdscr);
    eleccion(sesion, &c, actual);
    if (*sesion) {
      final = *actual + (int) diferencia;
    }
    mvprintw(2,0,"Tiempo actual:  %s", ctime(actual));
  }
  endwin();
  if (sesion != ((void *)0)) free(sesion);
  if (actual != ((void *)0)) free(actual);
  exit(0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: final long

variable_types: valor int

variable_types: diferencia double

variable_types:
sesion
int *

variable_types: opt int

variable_types: longitud int

variable_types: tipo char

variable_types:
tarea
char *

variable_types: c int

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


isPE

repo: davidgfnet/exec-analysis

decompiled_code:
_BOOL8 __fastcall isPE(_BYTE *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == 77 )
result = a1[1] == 90;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_BYTE *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == 77 )
result = a1[1] == 90;
return result;
}

original_code:
int isPE(unsigned char * pBuffer) {
 return (pBuffer[0] == 0x4d && pBuffer[1] == 0x5a);
}

canonical_original_code:
int isPE(unsigned char *pBuffer) {
 return (pBuffer[0] == 0x4d && pBuffer[1] == 0x5a);
}

variable_types:
pBuffer
unsigned char *

return_type: int


floatabs

repo: davidgfnet/math-evaluator

decompiled_code:
__m128 __fastcall floatabs(__m128 result)
{
if ( result.m128_f32[0] < 0.0 )
result = _mm_xor_ps(result, (__m128)LC1);
return result;
}

canonical_decompiled_code:
__m128 __fastcall func0(__m128 result)
{
if ( result.m128_f32[0] < 0.0 )
result = _mm_xor_ps(result, (__m128)LC1);
return result;
}

original_code: float floatabs(float a) { if (a < 0) return -a; return a; }

variable_types: a float

return_type: float


ReadLiteral

original_code:
float ReadLiteral(const char * string, int length) {
 float sign = 1;
 if (*string == '-') { sign = -1; string++; length--; }
 int i = 0;
 int p1 = 0, p2 = 0;
 while (i < length) {
  if (string[i] == '.') break;
  p1 = p1 * 10;
  p1 = p1 + (int)(string[i]-'0');
  i++;
 }
 if (string[i++] != '.') {
  float ret = p1;
  return sign*ret;
 }else{
  float div = 1;
  while (i < length) {
   p2 = p2 * 10;
   p2 = p2 + (int)(string[i]-'0');
   div *= 10;
   i++;
  }
  float ret = p1; float ret2 = p2;
  ret2 = ret2 / div;
  return sign*(ret+ret2);
 }
}

canonical_original_code:
float ReadLiteral(char *string, int length) {
 float sign = 1;
 if (*string == '-') { sign = -1; string++; length--; }
 int i = 0;
 int p1 = 0; int p2 = 0;
 while (i < length) {
  if (string[i] == '.') break;
  p1 = p1 * 10;
  p1 = p1 + (int)(string[i]-'0');
  i++;
 }
 if (string[i++] != '.') {
  float ret = p1;
  return sign*ret;
 }else{
  float div = 1;
  while (i < length) {
   p2 = p2 * 10;
   p2 = p2 + (int)(string[i]-'0');
   div *= 10;
   i++;
  }
  float ret = p1; float ret2 = p2;
  ret2 = ret2 / div;
  return sign*(ret+ret2);
 }
}

variable_types:
string
char *

variable_types: length int

variable_types: sign float

variable_types: i int

variable_types: ret float

variable_types: div float


SearchCloseParenthesis

decompiled_code:
__int64 __fastcall SearchCloseParenthesis(__int64 a1, int a2)
{
__int64 v2; // rcx
__int64 v3; // rax
int v4; // esi
unsigned int v5; // er8
char v6; // dl

if ( a2 <= 0 )
return 0;
v2 = (unsigned int)a2;
v3 = 0LL;
v4 = 0;
do
{
v5 = v3;
v6 = *(_BYTE *)(a1 + v3);
if ( v6 == 40 )
{
++v4;
}
else if ( v6 == 41 )
{
if ( !v4 )
return v5;
--v4;
}
++v3;
}
while ( v3 != v2 );
return 0;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
__int64 v2; // rcx
__int64 v3; // rax
int v4; // esi
unsigned int v5; // er8
char v6; // dl

if ( a2 <= 0 )
return 0;
v2 = (unsigned int)a2;
v3 = 0LL;
v4 = 0;
do
{
v5 = v3;
v6 = *(_BYTE *)(a1 + v3);
if ( v6 == 40 )
{
++v4;
}
else if ( v6 == 41 )
{
if ( !v4 )
return v5;
--v4;
}
++v3;
}
while ( v3 != v2 );
return 0;
}

original_code:
int SearchCloseParenthesis(const char * string, int length) {
 int i = 0, nump = 0;
 while (i < length) {
  if (string[i] == '(') nump++;
  else if (string[i] == ')') {
   if (nump == 0) return i;
   nump--;
  }
  i++;
 }
 return 0;
}

canonical_original_code:
int SearchCloseParenthesis(char *string, int length) {
 int i = 0; int nump = 0;
 while (i < length) {
  if (string[i] == '(') nump++;
  else if (string[i] == ')') {
   if (nump == 0) return i;
   nump--;
  }
  i++;
 }
 return 0;
}

variable_types: nump int


SearchCloseParenthesisInv

decompiled_code:
__int64 __fastcall SearchCloseParenthesisInv(__int64 a1, int a2)
{
int v2; // esi
__int64 v3; // rax
int v4; // ecx
unsigned int v5; // esi
char v6; // dl

v2 = a2 - 1;
if ( v2 < 0 )
return 0;
v3 = v2;
v4 = 0;
do
{
v5 = v3;
v6 = *(_BYTE *)(a1 + v3);
if ( v6 == 41 )
{
++v4;
}
else if ( v6 == 40 )
{
if ( !v4 )
return v5;
--v4;
}
--v3;
}
while ( (int)v3 >= 0 );
return 0;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
int v2; // esi
__int64 v3; // rax
int v4; // ecx
unsigned int v5; // esi
char v6; // dl

v2 = a2 - 1;
if ( v2 < 0 )
return 0;
v3 = v2;
v4 = 0;
do
{
v5 = v3;
v6 = *(_BYTE *)(a1 + v3);
if ( v6 == 41 )
{
++v4;
}
else if ( v6 == 40 )
{
if ( !v4 )
return v5;
--v4;
}
--v3;
}
while ( (int)v3 >= 0 );
return 0;
}

original_code:
int SearchCloseParenthesisInv(const char * string, int length) {
 int i = length-1, nump = 0;
 while (i >= 0) {
  if (string[i] == ')') nump++;
  else if (string[i] == '(') {
   if (nump == 0) return i;
   nump--;
  }
  i--;
 }
 return 0;
}

canonical_original_code:
int SearchCloseParenthesisInv(char *string, int length) {
 int i = length-1; int nump = 0;
 while (i >= 0) {
  if (string[i] == ')') nump++;
  else if (string[i] == '(') {
   if (nump == 0) return i;
   nump--;
  }
  i--;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall CreateExpressionFromString_int(_BYTE *a1, int a2, __int64 a3)
{
int v5; // er12
int v6; // eax
int v7; // edx
_BYTE *v8; // rax
int v9; // er14
int v10; // er13
__int64 result; // rax
_BYTE *v12; // rdx
char *v13; // rdx
char v14; // al
unsigned int v15; // er13
__int64 i; // r13
int *v17; // r14
int v18; // er15
unsigned int v19; // eax

v5 = 1;
while ( v5 )
{
if ( a2 <= 2 )
{
v5 = 0;
}
else if ( *a1 == 40 )
{
v6 = SearchCloseParenthesis((__int64)(a1 + 1), a2 - 1);
v7 = a2 - 2;
if ( v6 == a2 - 2 )
a2 -= 2;
if ( v6 == v7 )
++a1;
if ( v6 != v7 )
v5 = 0;
}
else
{
v5 = 0;
}
}
if ( a2 <= 1 )
{
if ( (unsigned __int8)(*a1 - 45) > 1u && (unsigned __int8)(*a1 - 48) > 9u )
{
if ( a2 == 1 )
{
*(_DWORD *)a3 = 1;
*(_BYTE *)(a3 + 8) = *a1;
result = a3 + 32;
}
else
{
LABEL_21:
v9 = a2 - 1;
if ( a2 - 1 < 0 )
{
LABEL_36:
if ( a2 > 0 )
{
v15 = 0;
goto LABEL_40;
}
result = 0LL;
}
else
{
LABEL_22:
v10 = v9;
do
{
v12 = &a1[v10];
if ( ((*v12 - 43) & 0xFD) == 0 )
{
*(_DWORD *)a3 = 3;
*(_DWORD *)(a3 + 8) = *v12 != 43;
*(_QWORD *)(a3 + 16) = a3 + 32;
*(_QWORD *)(a3 + 24) = CreateExpressionFromString_int(a1, (unsigned int)v10);
return CreateExpressionFromString_int(&a1[v10 + 1], (unsigned int)(a2 - v10 - 1));
}
if ( *v12 == 41 )
v10 = SearchCloseParenthesisInv((__int64)a1, v10);
--v10;
}
while ( v10 >= 0 );
while ( 1 )
{
v13 = &a1[v9];
v14 = *v13;
if ( *v13 == 42 || v14 == 47 )
break;
if ( v14 == 41 )
v9 = SearchCloseParenthesisInv((__int64)a1, v9);
if ( --v9 < 0 )
goto LABEL_36;
}
*(_DWORD *)a3 = 3;
*(_DWORD *)(a3 + 8) = (*v13 != 42) + 2;
*(_QWORD *)(a3 + 16) = a3 + 32;
*(_QWORD *)(a3 + 24) = CreateExpressionFromString_int(a1, (unsigned int)v9);
result = CreateExpressionFromString_int(&a1[v9 + 1], (unsigned int)(a2 - v9 - 1));
}
}
}
else
{
LABEL_56:
*(_DWORD *)a3 = 0;
*(float *)(a3 + 8) = ReadLiteral(a1, a2);
result = a3 + 32;
}
}
else
{
v8 = a1 + 1;
do
{
if ( (unsigned __int8)(*v8 - 48) > 9u && *v8 != 46 )
{
if ( (unsigned __int8)(*a1 - 48) <= 9u || (unsigned __int8)(*a1 - 45) <= 1u )
goto LABEL_21;
goto LABEL_59;
}
++v8;
}
while ( v8 != &a1[a2 - 2 + 2] );
if ( (unsigned __int8)(*a1 - 48) <= 9u || (unsigned __int8)(*a1 - 45) <= 1u )
goto LABEL_56;
LABEL_59:
v9 = a2 - 1;
v15 = 0;
if ( a2 - 1 >= 0 )
goto LABEL_22;
do
{
LABEL_40:
if ( a1[v15] == 40 )
v15 += SearchCloseParenthesis((__int64)&a1[v15 + 1], a2 - v15 - 1) + 2;
if ( a1[v15] == 94 )
{
*(_DWORD *)a3 = 3;
*(_DWORD *)(a3 + 8) = 5;
*(_QWORD *)(a3 + 16) = a3 + 32;
*(_QWORD *)(a3 + 24) = CreateExpressionFromString_int(a1, v15);
return CreateExpressionFromString_int(&a1[v15 + 1], a2 - v15 - 1);
}
++v15;
}
while ( a2 > (int)v15 );
for ( i = 0LL; a1[i] != 40; ++i )
{
LABEL_45:
if ( a2 - 1 == i )
return 0LL;
}
v17 = function_names;
v18 = 0;
while ( 1 )
{
v19 = internal_strlen(v17);
if ( !(unsigned int)mem_compare((__int64)a1, (__int64)v17, v19) )
break;
++v18;
v17 += 3;
if ( v18 == 9 )
goto LABEL_45;
}
*(_DWORD *)a3 = 2;
*(_DWORD *)(a3 + 8) = function_names[3 * v18 + 2];
*(_QWORD *)(a3 + 16) = a3 + 32;
result = CreateExpressionFromString_int(&a1[i + 1], (unsigned int)(a2 - i - 2));
}
return result;
}

original_code:
struct expression * CreateExpressionFromString_int (const char * string, int length, struct expression * ret) {
 int i,j,k;
 int changed = 1;
 while (changed) {
  changed = 0;
  if (length > 2) {
   if (string[0] == '(') {
   if (SearchCloseParenthesis(&string[1],length-1) == length-2) {
    string++;
    length-=2;
    changed = 1;
   }
   }
  }
 }
 int literal = 1;
 for (i = 1; i < length; i++)
  if (!((string[i] >= '0' && string[i] <= '9') || string[i] == '.')) { literal = 0; break; }
 if (!((string[0] >= '0' && string[0] <= '9') || string[0] == '.' || string[0] == '-')) literal = 0;
 if (literal == 1) {
  ret->type = eLiteral;
  ret->evalue.literal_value = ReadLiteral(string,length);
  return ret+1;
 }
 if (length == 1) {
  ret->type = eVariable;
  ret->evalue.var = *string;
  return ret+1;
 }
 for (i = length-1; i >= 0; i--) {
  if (string[i] == '+' || string[i] == '-') {
   ret->type = eParent;
   if (string[i] == '+') ret->evalue.child.op = mAdd;
   else ret->evalue.child.op = mSub;
   ret->evalue.child.e1 = ret +1;
   ret->evalue.child.e2 = CreateExpressionFromString_int(string,i,ret->evalue.child.e1);
   return CreateExpressionFromString_int(&string[i+1],length-i-1,ret->evalue.child.e2);
  }
  if (string[i] == ')') {
   j = SearchCloseParenthesisInv(string,i);
   i = j-1+1;
  }
 }
 for (i = length-1; i >= 0; i--) {
  if (string[i] == '*' || string[i] == '/') {
   ret->type = eParent;
   if (string[i] == '*') ret->evalue.child.op = mMul;
   else ret->evalue.child.op = mDiv;
   ret->evalue.child.e1 = ret +1;
   ret->evalue.child.e2 = CreateExpressionFromString_int(string,i,ret->evalue.child.e1);
   return CreateExpressionFromString_int(&string[i+1],length-i-1,ret->evalue.child.e2);
  }
  if (string[i] == ')') {
   j = SearchCloseParenthesisInv(string,i);
   i = j-1+1;
  }
 }
 for (i = 0; i < length; i++) {
  if (string[i] == '(') {
   j = SearchCloseParenthesis(&string[i+1],length -i -1);
   i = i+1+ j+1;
  }
  if (string[i] == '^') {
   ret->type = eParent;
   ret->evalue.child.op = mPow;
   ret->evalue.child.e1 = ret +1;
   ret->evalue.child.e2 = CreateExpressionFromString_int(string,i,ret->evalue.child.e1);
   return CreateExpressionFromString_int(&string[i+1],length-i-1,ret->evalue.child.e2);
  }
 }
 for (i = 0; i < length; i++) {
  if (string[i] == '(') {
   for (j = 0; j < 9; j++) {
    if (_mem_compare(string,function_names[j].fname,_internal_strlen(function_names[j].fname)) == 0) {
     ret->type = eFunction;
     ret->evalue.function.func = function_names[j].fnumber;
     ret->evalue.function.e = ret+1;
     return CreateExpressionFromString_int(&string[i+1],length-i-1-1,ret->evalue.function.e);
    }
   }
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct expression *CreateExpressionFromString_int(char *string, int length, struct expression *ret) {
 int i; int j; int k;
 int changed = 1;
 while (changed) {
  changed = 0;
  if (length > 2) {
   if (string[0] == '(') {
   if (SearchCloseParenthesis(&string[1],length-1) == length-2) {
    string++;
    length-=2;
    changed = 1;
   }
   }
  }
 }
 int literal = 1;
 for (i = 1; i < length; i++)
  if (!((string[i] >= '0' && string[i] <= '9') || string[i] == '.')) { literal = 0; break; }
 if (!((string[0] >= '0' && string[0] <= '9') || string[0] == '.' || string[0] == '-')) literal = 0;
 if (literal == 1) {
  ret->type = eLiteral;
  ret->evalue.literal_value = ReadLiteral(string,length);
  return ret+1;
 }
 if (length == 1) {
  ret->type = eVariable;
  ret->evalue.var = *string;
  return ret+1;
 }
 for (i = length-1; i >= 0; i--) {
  if (string[i] == '+' || string[i] == '-') {
   ret->type = eParent;
   if (string[i] == '+') ret->evalue.child.op = mAdd;
   else ret->evalue.child.op = mSub;
   ret->evalue.child.e1 = ret +1;
   ret->evalue.child.e2 = CreateExpressionFromString_int(string,i,ret->evalue.child.e1);
   return CreateExpressionFromString_int(&string[i+1],length-i-1,ret->evalue.child.e2);
  }
  if (string[i] == ')') {
   j = SearchCloseParenthesisInv(string,i);
   i = j-1+1;
  }
 }
 for (i = length-1; i >= 0; i--) {
  if (string[i] == '*' || string[i] == '/') {
   ret->type = eParent;
   if (string[i] == '*') ret->evalue.child.op = mMul;
   else ret->evalue.child.op = mDiv;
   ret->evalue.child.e1 = ret +1;
   ret->evalue.child.e2 = CreateExpressionFromString_int(string,i,ret->evalue.child.e1);
   return CreateExpressionFromString_int(&string[i+1],length-i-1,ret->evalue.child.e2);
  }
  if (string[i] == ')') {
   j = SearchCloseParenthesisInv(string,i);
   i = j-1+1;
  }
 }
 for (i = 0; i < length; i++) {
  if (string[i] == '(') {
   j = SearchCloseParenthesis(&string[i+1],length -i -1);
   i = i+1+ j+1;
  }
  if (string[i] == '^') {
   ret->type = eParent;
   ret->evalue.child.op = mPow;
   ret->evalue.child.e1 = ret +1;
   ret->evalue.child.e2 = CreateExpressionFromString_int(string,i,ret->evalue.child.e1);
   return CreateExpressionFromString_int(&string[i+1],length-i-1,ret->evalue.child.e2);
  }
 }
 for (i = 0; i < length; i++) {
  if (string[i] == '(') {
   for (j = 0; j < 9; j++) {
    if (_mem_compare(string,function_names[j].fname,_internal_strlen(function_names[j].fname)) == 0) {
     ret->type = eFunction;
     ret->evalue.function.func = function_names[j].fnumber;
     ret->evalue.function.e = ret+1;
     return CreateExpressionFromString_int(&string[i+1],length-i-1-1,ret->evalue.function.e);
    }
   }
  }
 }
 return ((void *)0);
}

variable_types:
ret
struct expression *

variable_types: j int

variable_types: k int

variable_types: changed int

variable_types: literal int

return_type: struct expression { enum expType { eLiteral=0, eVariable=1, eFunction=2, eParent=3 } type; union evalue { float literal_value; char var; struct sfunction { enum math_function { fSin=0, fCos=1, fTan=2, fASin=3, fACos=4, fATan=5, fAbs=6, fLog=7, fLn=8 } func; struct expression *e; } function; struct schild { enum math_operation { mAdd=0, mSub=1, mMul=2, mDiv=3, mMod=4, mPow=5, mRoot=6 } op; struct expression *e1; struct expression *e2; } child; } evalue; } *

user_defined_types: struct expression { enum expType type; union evalue evalue; }

user_defined_types: union evalue { float literal_value; char var; struct sfunction function; struct schild child; }

user_defined_types: struct sfunction { enum math_function func; struct expression *e; }

user_defined_types: struct schild { enum math_operation op; struct expression *e1; struct expression *e2; }


CreateExpressionFromString

original_code:
struct expression * CreateExpressionFromString (const char * string) {
 char * good_expr = (char*)malloc(_internal_strlen(string)+1);
 char * tptr = good_expr;
 int len = 0;
 while (*string != 0) {
  if (*string != ' ') {
   *(tptr++) = *string;
   len++;
  }
  string++;
 }
 int i; int num_nodes = 0;
 for (i = 0; i < len; i++) {
  switch (good_expr[i]) {
  case '+': case '-': case '*': case '/': case '%': case '^':
   num_nodes++; break;
  default:
   if ((good_expr[i] >= '0' && good_expr[i] <= '9') || good_expr[i] == '.') {
    num_nodes++;
    while ((good_expr[i+1] >= '0' && good_expr[i+1] <= '9') || good_expr[i+1] == '.') i++;
   }
   if (good_expr[i] >= 'a' && good_expr[i] <= 'z') {
    num_nodes++;
    while (good_expr[i+1] >= 'a' && good_expr[i+1] <= 'z') i++;
   }
   break;
  }
 }
 struct expression * elist = (struct expression *)malloc((num_nodes)*sizeof(struct expression));
 CreateExpressionFromString_int(&good_expr[0],len,elist);
 free(good_expr);
 return elist;
}

canonical_original_code:
struct expression *CreateExpressionFromString(char *string) {
 char *good_expr = (char*)malloc(_internal_strlen(string)+1);
 char *tptr = good_expr;
 int len = 0;
 while (*string != 0) {
  if (*string != ' ') {
   *(tptr++) = *string;
   len++;
  }
  string++;
 }
 int i; int num_nodes = 0;
 for (i = 0; i < len; i++) {
  switch (good_expr[i]) {
  case '+': case '-': case '*': case '/': case '%': case '^':
   num_nodes++; break;
  default:
   if ((good_expr[i] >= '0' && good_expr[i] <= '9') || good_expr[i] == '.') {
    num_nodes++;
    while ((good_expr[i+1] >= '0' && good_expr[i+1] <= '9') || good_expr[i+1] == '.') i++;
   }
   if (good_expr[i] >= 'a' && good_expr[i] <= 'z') {
    num_nodes++;
    while (good_expr[i+1] >= 'a' && good_expr[i+1] <= 'z') i++;
   }
   break;
  }
 }
 struct expression *elist = (struct expression *)malloc((num_nodes)*sizeof(struct expression));
 CreateExpressionFromString_int(&good_expr[0],len,elist);
 free(good_expr);
 return elist;
}

variable_types:
tptr
char *

variable_types: len int

variable_types: struct expression { enum expType { eLiteral=0, eVariable=1, eFunction=2, eParent=3 } type; union evalue { float literal_value; char var; struct sfunction { enum math_function { fSin=0, fCos=1, fTan=2, fASin=3, fACos=4, fATan=5, fAbs=6, fLog=7, fLn=8 } func; struct expression *e; } function; struct schild { enum math_operation { mAdd=0, mSub=1, mMul=2, mDiv=3, mMod=4, mPow=5, mRoot=6 } op; struct expression *e1; struct expression *e2; } child; } evalue; } *


EvaluateExpression

decompiled_code:
float __fastcall EvaluateExpression(__int64 a1, float *a2)
{
float *v2; // rbx
unsigned int v3; // eax
char v4; // al
float result; // xmm0_4
unsigned int v6; // eax
float (__fastcall *v7)(float); // r12
float v8; // xmm0_4
float v9; // [rsp+Ch] [rbp-1Ch]
float v10; // [rsp+Ch] [rbp-1Ch]
float v11; // [rsp+Ch] [rbp-1Ch]
float v12; // [rsp+Ch] [rbp-1Ch]

v2 = a2;
v3 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 == 2 )
{
v7 = (float (__fastcall *)(float))*(&function_pointers + *(unsigned int *)(a1 + 8));
v8 = EvaluateExpression(*(_QWORD *)(a1 + 16));
result = v7(v8);
}
else if ( v3 > 2 )
{
result = 0.0;
if ( v3 == 3 )
{
v6 = *(_DWORD *)(a1 + 8);
if ( v6 == 2 )
{
v12 = EvaluateExpression(*(_QWORD *)(a1 + 16));
result = EvaluateExpression(*(_QWORD *)(a1 + 24)) * v12;
}
else if ( v6 > 2 )
{
result = 0.0;
if ( v6 == 3 )
{
v10 = EvaluateExpression(*(_QWORD *)(a1 + 16));
result = v10 / EvaluateExpression(*(_QWORD *)(a1 + 24));
}
}
else if ( v6 )
{
v9 = EvaluateExpression(*(_QWORD *)(a1 + 16));
result = v9 - EvaluateExpression(*(_QWORD *)(a1 + 24));
}
else
{
v11 = EvaluateExpression(*(_QWORD *)(a1 + 16));
result = EvaluateExpression(*(_QWORD *)(a1 + 24)) + v11;
}
}
}
else if ( v3 )
{
v4 = *(_BYTE *)a2;
result = 0.0;
if ( *(_BYTE *)a2 )
{
while ( *(_BYTE *)(a1 + 8) != v4 )
{
v2 += 2;
v4 = *(_BYTE *)v2;
if ( !*(_BYTE *)v2 )
return 0.0;
}
result = v2[1];
}
}
else
{
result = *(float *)(a1 + 8);
}
return result;
}

canonical_decompiled_code:
float __fastcall func8(__int64 a1, float *a2)
{
float *v2; // rbx
unsigned int v3; // eax
char v4; // al
float result; // xmm0_4
unsigned int v6; // eax
float (__fastcall *v7)(float); // r12
float v8; // xmm0_4
float v9; // [rsp+Ch] [rbp-1Ch]
float v10; // [rsp+Ch] [rbp-1Ch]
float v11; // [rsp+Ch] [rbp-1Ch]
float v12; // [rsp+Ch] [rbp-1Ch]

v2 = a2;
v3 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 == 2 )
{
v7 = (float (__fastcall *)(float))*(&function_pointers + *(unsigned int *)(a1 + 8));
v8 = func8(*(_QWORD *)(a1 + 16));
result = v7(v8);
}
else if ( v3 > 2 )
{
result = 0.0;
if ( v3 == 3 )
{
v6 = *(_DWORD *)(a1 + 8);
if ( v6 == 2 )
{
v12 = func8(*(_QWORD *)(a1 + 16));
result = func8(*(_QWORD *)(a1 + 24)) * v12;
}
else if ( v6 > 2 )
{
result = 0.0;
if ( v6 == 3 )
{
v10 = func8(*(_QWORD *)(a1 + 16));
result = v10 / func8(*(_QWORD *)(a1 + 24));
}
}
else if ( v6 )
{
v9 = func8(*(_QWORD *)(a1 + 16));
result = v9 - func8(*(_QWORD *)(a1 + 24));
}
else
{
v11 = func8(*(_QWORD *)(a1 + 16));
result = func8(*(_QWORD *)(a1 + 24)) + v11;
}
}
}
else if ( v3 )
{
v4 = *(_BYTE *)a2;
result = 0.0;
if ( *(_BYTE *)a2 )
{
while ( *(_BYTE *)(a1 + 8) != v4 )
{
v2 += 2;
v4 = *(_BYTE *)v2;
if ( !*(_BYTE *)v2 )
return 0.0;
}
result = v2[1];
}
}
else
{
result = *(float *)(a1 + 8);
}
return result;
}

original_code:
float EvaluateExpression (struct expression * expr, struct type_variable * variables) {
 switch (expr->type) {
 case eLiteral:
  return expr->evalue.literal_value;
  break;
 case eVariable:
  while (variables->variable != 0) {
   if (expr->evalue.var == variables->variable)
    return variables->value;
   variables++;
  }
  return 0;
  break;
 case eFunction:
  return function_pointers[expr->evalue.function.func](EvaluateExpression(expr->evalue.function.e,variables));
  break;
 case eParent:
  switch (expr->evalue.child.op) {
   case mAdd:
    return EvaluateExpression(expr->evalue.child.e1,variables)+EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mSub:
    return EvaluateExpression(expr->evalue.child.e1,variables)-EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mMul:
    return EvaluateExpression(expr->evalue.child.e1,variables)*EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mDiv:
    return EvaluateExpression(expr->evalue.child.e1,variables)/EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mMod:
    return 0; break;
   case mPow:
    return 0; break;
   default: return 0; break;
  };
  break;
 default: return 0; break;
 };
}

canonical_original_code:
float EvaluateExpression(struct expression *expr, struct type_variable *variables) {
 switch (expr->type) {
 case eLiteral:
  return expr->evalue.literal_value;
  break;
 case eVariable:
  while (variables->variable != 0) {
   if (expr->evalue.var == variables->variable)
    return variables->value;
   variables++;
  }
  return 0;
  break;
 case eFunction:
  return function_pointers[expr->evalue.function.func](EvaluateExpression(expr->evalue.function.e,variables));
  break;
 case eParent:
  switch (expr->evalue.child.op) {
   case mAdd:
    return EvaluateExpression(expr->evalue.child.e1,variables)+EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mSub:
    return EvaluateExpression(expr->evalue.child.e1,variables)-EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mMul:
    return EvaluateExpression(expr->evalue.child.e1,variables)*EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mDiv:
    return EvaluateExpression(expr->evalue.child.e1,variables)/EvaluateExpression(expr->evalue.child.e2,variables); break;
   case mMod:
    return 0; break;
   case mPow:
    return 0; break;
   default: return 0; break;
  };
  break;
 default: return 0; break;
 };
}

variable_types: struct type_variable { char variable; float value; } *

user_defined_types: enum expType { eLiteral=0, eVariable=1, eFunction=2, eParent=3 }

user_defined_types: enum math_function { fSin=0, fCos=1, fTan=2, fASin=3, fACos=4, fATan=5, fAbs=6, fLog=7, fLn=8 }

user_defined_types: enum math_operation { mAdd=0, mSub=1, mMul=2, mDiv=3, mMod=4, mPow=5, mRoot=6 }


DeleteExpression

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

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

original_code:
void DeleteExpression (struct expression * expr) {
 free(expr);
}

canonical_original_code:
void DeleteExpression(struct expression *expr) {
 free(expr);
}

return_type: void


main

canonical_name: main

original_code:
int main() {
 struct expression * ret = CreateExpressionFromString("(1-(1*5*(3*(9-3*1-3)/4)*2/3)-1*cos(3.1416))");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 ret = CreateExpressionFromString("2*2*(4*3)+2*2-3*1-1*6-5*6*(5-6+1)*(-1)");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 ret = CreateExpressionFromString("1/2/3/4/5+(4*1-(8*6*(-5))/3/2)");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 ret = CreateExpressionFromString("(((5*6))/(2*((2-1-1+1))))");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 struct type_variable vlist[3];
 vlist[0].variable = 'b';
 vlist[0].value = 1.6f;
 vlist[1].variable = 'c';
 vlist[1].value = -3.0f;
 vlist[2].variable = 0;
 ret = CreateExpressionFromString("(((5*c))/(2*((2-b-1+1))))");
 printf("%f\n",EvaluateExpression(ret,&vlist[0]));
 DeleteExpression(ret);
 return 0;
}

canonical_original_code:
int main() {
 struct expression *ret = CreateExpressionFromString("(1-(1*5*(3*(9-3*1-3)/4)*2/3)-1*cos(3.1416))");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 ret = CreateExpressionFromString("2*2*(4*3)+2*2-3*1-1*6-5*6*(5-6+1)*(-1)");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 ret = CreateExpressionFromString("1/2/3/4/5+(4*1-(8*6*(-5))/3/2)");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 ret = CreateExpressionFromString("(((5*6))/(2*((2-1-1+1))))");
 printf("%f\n",EvaluateExpression(ret,((void *)0)));
 DeleteExpression(ret);
 struct type_variable vlist[3];
 vlist[0].variable = 'b';
 vlist[0].value = 1.6f;
 vlist[1].variable = 'c';
 vlist[1].value = -3.0f;
 vlist[2].variable = 0;
 ret = CreateExpressionFromString("(((5*c))/(2*((2-b-1+1))))");
 printf("%f\n",EvaluateExpression(ret,&vlist[0]));
 DeleteExpression(ret);
 return 0;
}

variable_types: struct type_variable { char variable; float value; } [3]


notify

repo: davidgfnet/pecomparator

decompiled_code:
void __fastcall __noreturn notify(const char *a1)
{
puts(a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(const char *a1)
{
puts(a1);
exit(0);
}

original_code:
void notify(const char * c) {
 printf("%s\n",c);
 exit(0);
}

canonical_original_code:
void notify(char *c) {
 printf("%s\n",c);
 exit(0);
}

variable_types:
c
char *


checkFileName

original_code:
int checkFileName(char fname[13], const unsigned char DIR_Name[11]){
    int i,j;
    for(i=0;i<8 && DIR_Name[i] != ' ';i++){
        fname[i] = DIR_Name[i];
    }
    if(DIR_Name[8] != ' '){
        fname[i++] = '.';
        for(j=8;j<=10 && DIR_Name[j] != ' ';j++,i++){
            fname[i] = DIR_Name[j];
        }
    }
    fname[i] = 0;
    return i;
}

canonical_original_code:
int checkFileName(char fname[13], unsigned char DIR_Name[11]){
    int i; int j;
    for(i=0;i<8 && DIR_Name[i] != ' ';i++){
        fname[i] = DIR_Name[i];
    }
    if(DIR_Name[8] != ' '){
        fname[i++] = '.';
        for(j=8;j<=10 && DIR_Name[j] != ' ';j++,i++){
            fname[i] = DIR_Name[j];
        }
    }
    fname[i] = 0;
    return i;
}

variable_types:
fname
char [13]


printInfo

decompiled_code:
int __fastcall printInfo(__int64 a1, unsigned int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, __int64 a8, unsigned __int8 a9)
{
_DWORD *v9; // rax
__int64 v10; // rdx
int v11; // ebx
__int64 v12; // rsi

printf("Number of FATs = %hhu\n", a9);
printf("Number of bytes per sector = %hu\n", *(unsigned __int16 *)((char *)&a8 + 3));
printf("Number of sectors per cluster = %hhu\n", BYTE5(a8));
printf("Number of reserved sectors = %hu\n", HIWORD(a8));
if ( a2 <= 2 )
{
v11 = 0;
v12 = 0LL;
}
else
{
v9 = (_DWORD *)(a1 + 8);
v10 = a1 + 4LL * (a2 - 3) + 12;
v11 = 0;
v12 = 0LL;
do
{
if ( *v9 )
v12 = (unsigned int)(v12 + 1);
else
++v11;
++v9;
}
while ( v9 != (_DWORD *)v10 );
}
printf("Number of allocated clusters = %d\n", v12);
return printf("Number of free clusters = %d\n", (unsigned int)(v11 + 2));
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, unsigned int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, __int64 a8, unsigned __int8 a9)
{
_DWORD *v9; // rax
__int64 v10; // rdx
int v11; // ebx
__int64 v12; // rsi

printf("Number of FATs = %hhu\n", a9);
printf("Number of bytes per sector = %hu\n", *(unsigned __int16 *)((char *)&a8 + 3));
printf("Number of sectors per cluster = %hhu\n", BYTE5(a8));
printf("Number of reserved sectors = %hu\n", HIWORD(a8));
if ( a2 <= 2 )
{
v11 = 0;
v12 = 0LL;
}
else
{
v9 = (_DWORD *)(a1 + 8);
v10 = a1 + 4LL * (a2 - 3) + 12;
v11 = 0;
v12 = 0LL;
do
{
if ( *v9 )
v12 = (unsigned int)(v12 + 1);
else
++v11;
++v9;
}
while ( v9 != (_DWORD *)v10 );
}
printf("Number of allocated clusters = %d\n", v12);
return printf("Number of free clusters = %d\n", (unsigned int)(v11 + 2));
}

original_code:
void printInfo(BOOTSECTOR be,unsigned int *FAT,unsigned int totalDataCluster){
    int i;
    int numOfAlloc = 0;
    int numOfFree = 0;
    printf("Number of FATs = %hhu\n",be.BPB_NumFATs);
    printf("Number of bytes per sector = %hu\n",be.BPB_BytsPerSec);
    printf("Number of sectors per cluster = %hhu\n",be.BPB_SecPerClus);
    printf("Number of reserved sectors = %hu\n",be.BPB_RsvdSecCnt);
    for(i=2;i<totalDataCluster;i++){
        if(FAT[i]==0){
            numOfFree++;
        }else{
            numOfAlloc++;
        }
    }
    printf("Number of allocated clusters = %d\n",numOfAlloc);
    printf("Number of free clusters = %d\n",numOfFree+2);
}

canonical_original_code:
void printInfo(struct BootEntry be, unsigned int *FAT, unsigned int totalDataCluster){
    int i;
    int numOfAlloc = 0;
    int numOfFree = 0;
    printf("Number of FATs = %hhu\n",be.BPB_NumFATs);
    printf("Number of bytes per sector = %hu\n",be.BPB_BytsPerSec);
    printf("Number of sectors per cluster = %hhu\n",be.BPB_SecPerClus);
    printf("Number of reserved sectors = %hu\n",be.BPB_RsvdSecCnt);
    for(i=2;i<totalDataCluster;i++){
        if(FAT[i]==0){
            numOfFree++;
        }else{
            numOfAlloc++;
        }
    }
    printf("Number of allocated clusters = %d\n",numOfAlloc);
    printf("Number of free clusters = %d\n",numOfFree+2);
}

variable_types: struct BootEntry { unsigned char BS_jmpBoot[3]; unsigned char BS_OEMName[8]; unsigned short BPB_BytsPerSec; unsigned char BPB_SecPerClus; unsigned short BPB_RsvdSecCnt; unsigned char BPB_NumFATs; unsigned short BPB_RootEntCnt; unsigned short BPB_TotSec16; unsigned char BPB_Media; unsigned short BPB_FATSz16; unsigned short BPB_SecPerTrk; unsigned short BPB_NumHeads; unsigned int BPB_HiddSec; unsigned int BPB_TotSec32; unsigned int BPB_FATSz32; unsigned short BPB_ExtFlags; unsigned short BPB_FSVer; unsigned int BPB_RootClus; unsigned short BPB_FSInfo; unsigned short BPB_BkBootSec; unsigned char BPB_Reserved[12]; unsigned char BS_DrvNum; unsigned char BS_Reserved1; unsigned char BS_BootSig; unsigned int BS_VolID; unsigned char BS_VolLab[11]; unsigned char BS_FilSysType[8]; }

variable_types:
FAT
unsigned int *

variable_types:
totalDataCluster
unsigned int

variable_types: numOfAlloc int

variable_types: numOfFree int


detectArgv

decompiled_code:
char __fastcall detectArgv(int a1, __int64 a2)
{
char result; // al
const char **v3; // rbx
int v4; // er12
int v5; // er15
int v6; // ebp
bool v7; // zf
int v8; // [rsp+0h] [rbp-44h]
int v9; // [rsp+4h] [rbp-40h]
int v10; // [rsp+8h] [rbp-3Ch]

result = 0;
if ( a1 > 3 )
{
v3 = (const char **)(a2 + 8);
v8 = 0;
v4 = 0;
v5 = 0;
v10 = 0;
v9 = 0;
v6 = 0;
do
{
if ( v6 == 2 )
{
if ( **v3 == 45 )
return 0;
devicename = (__int64)*v3;
v6 = 1;
}
else if ( v4 == 2 )
{
if ( **v3 == 45 )
return 0;
filename = (__int64)*v3;
filenameLength = strlen(*v3);
v4 = 1;
}
else if ( v5 == 2 )
{
if ( **v3 == 45 )
return 0;
filename = (__int64)*v3;
filenameLength = strlen(*v3);
v5 = 1;
}
else if ( v8 == 2 )
{
if ( **v3 == 45 )
return 0;
md5 = (__int64)*v3;
md5Length = strlen(*v3);
v8 = 1;
}
else
{
v7 = strcmp(*v3, "-d") == 0;
result = !v7;
if ( v7 )
{
if ( v6 )
return result;
v6 = 2;
}
else
{
v7 = strcmp(*v3, "-r") == 0;
result = !v7;
if ( v7 )
{
if ( v4 )
return result;
v4 = 2;
}
else
{
v7 = strcmp(*v3, "-R") == 0;
result = !v7;
if ( v7 )
{
if ( v5 )
return result;
v5 = 2;
}
else
{
v7 = strcmp(*v3, "-m") == 0;
result = !v7;
if ( v7 )
{
if ( v8 )
return result;
v8 = 2;
}
else
{
v7 = strcmp(*v3, "-i") == 0;
result = !v7;
if ( v7 )
{
if ( v9 )
return result;
v9 = 1;
}
else
{
if ( (strcmp(*v3, "-l") != 0) | v10 )
return 0;
v10 = 1;
}
}
}
}
}
}
++v3;
}
while ( (const char **)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) != v3 );
result = 0;
if ( (v6 & 0xFFFFFFFD) != 0 && v4 + v5 + v10 + v9 <= 1 && v8 + v9 <= 1 && v8 + v10 <= 1 && v5 + v8 <= 1 )
{
if ( v9 == 1 )
{
result = 105;
}
else if ( v10 == 1 )
{
result = 108;
}
else if ( v4 == 1 )
{
if ( v8 == 1 )
{
result = 109;
}
else
{
result = 0;
if ( v8 != 2 )
result = 114;
}
}
else
{
result = 82;
if ( v5 != 1 )
result = 0;
}
}
}
return result;
}

canonical_decompiled_code:
char __fastcall func3(int a1, __int64 a2)
{
char result; // al
const char **v3; // rbx
int v4; // er12
int v5; // er15
int v6; // ebp
bool v7; // zf
int v8; // [rsp+0h] [rbp-44h]
int v9; // [rsp+4h] [rbp-40h]
int v10; // [rsp+8h] [rbp-3Ch]

result = 0;
if ( a1 > 3 )
{
v3 = (const char **)(a2 + 8);
v8 = 0;
v4 = 0;
v5 = 0;
v10 = 0;
v9 = 0;
v6 = 0;
do
{
if ( v6 == 2 )
{
if ( **v3 == 45 )
return 0;
devicename = (__int64)*v3;
v6 = 1;
}
else if ( v4 == 2 )
{
if ( **v3 == 45 )
return 0;
filename = (__int64)*v3;
filenameLength = strlen(*v3);
v4 = 1;
}
else if ( v5 == 2 )
{
if ( **v3 == 45 )
return 0;
filename = (__int64)*v3;
filenameLength = strlen(*v3);
v5 = 1;
}
else if ( v8 == 2 )
{
if ( **v3 == 45 )
return 0;
md5 = (__int64)*v3;
md5Length = strlen(*v3);
v8 = 1;
}
else
{
v7 = strcmp(*v3, "-d") == 0;
result = !v7;
if ( v7 )
{
if ( v6 )
return result;
v6 = 2;
}
else
{
v7 = strcmp(*v3, "-r") == 0;
result = !v7;
if ( v7 )
{
if ( v4 )
return result;
v4 = 2;
}
else
{
v7 = strcmp(*v3, "-R") == 0;
result = !v7;
if ( v7 )
{
if ( v5 )
return result;
v5 = 2;
}
else
{
v7 = strcmp(*v3, "-m") == 0;
result = !v7;
if ( v7 )
{
if ( v8 )
return result;
v8 = 2;
}
else
{
v7 = strcmp(*v3, "-i") == 0;
result = !v7;
if ( v7 )
{
if ( v9 )
return result;
v9 = 1;
}
else
{
if ( (strcmp(*v3, "-l") != 0) | v10 )
return 0;
v10 = 1;
}
}
}
}
}
}
++v3;
}
while ( (const char **)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) != v3 );
result = 0;
if ( (v6 & 0xFFFFFFFD) != 0 && v4 + v5 + v10 + v9 <= 1 && v8 + v9 <= 1 && v8 + v10 <= 1 && v5 + v8 <= 1 )
{
if ( v9 == 1 )
{
result = 105;
}
else if ( v10 == 1 )
{
result = 108;
}
else if ( v4 == 1 )
{
if ( v8 == 1 )
{
result = 109;
}
else
{
result = 0;
if ( v8 != 2 )
result = 114;
}
}
else
{
result = 82;
if ( v5 != 1 )
result = 0;
}
}
}
return result;
}

original_code:
char detectArgv(int argc,char** argv){
    int i;
    int hasD = 0;
    int hasI = 0;
    int hasL = 0;
    int hasR = 0;
    int hasr = 0;
    int hasM = 0;
    if(argc < 4){
        return 0;
    }else{
     for(i = 1; i < argc; i++){
      if(hasD == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        devicename = argv[i];
        hasD=1;
       }
      }else if(hasr == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        filename = argv[i];
                    filenameLength = strlen(argv[i]);
        hasr=1;
       }
      }else if(hasR == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        filename = argv[i];
                    filenameLength = strlen(argv[i]);
        hasR=1;
       }
      }else if(hasM == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        md5 = argv[i];
                    md5Length = strlen(argv[i]);
        hasM=1;
       }
      }else if(strcmp(argv[i],"-d")==0){
       if(hasD == 0){ hasD = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-r")==0){
       if(hasr == 0){ hasr = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-R")==0){
       if(hasR == 0){ hasR = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-m")==0){
       if(hasM == 0){ hasM = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-i")==0){
       if(hasI == 0){ hasI = 1; }else{ return 0; }
      }else if(strcmp(argv[i],"-l")==0){
       if(hasL == 0){ hasL = 1; }else{ return 0; }
      }else{
       return 0;
      }
     }
     if(hasD == 0 || hasD == 2){ return 0;}
     if((hasI + hasL + hasR + hasr)>1){ return 0; }
     if((hasM + hasI) > 1 || (hasM + hasL) > 1 || (hasM + hasR) > 1){ return 0;}
     if(hasI == 1){ return 'i';}
     if(hasL == 1){ return 'l';}
  if(hasr == 1){ if(hasM == 1){ return 'm';}
        else if(hasM == 2){ return 0; }
        else{return 'r';}
      }
  if(hasR == 1){ return 'R';}
  return 0;
    }
}

canonical_original_code:
char detectArgv(int argc, char **argv){
    int i;
    int hasD = 0;
    int hasI = 0;
    int hasL = 0;
    int hasR = 0;
    int hasr = 0;
    int hasM = 0;
    if(argc < 4){
        return 0;
    }else{
     for(i = 1; i < argc; i++){
      if(hasD == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        devicename = argv[i];
        hasD=1;
       }
      }else if(hasr == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        filename = argv[i];
                    filenameLength = strlen(argv[i]);
        hasr=1;
       }
      }else if(hasR == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        filename = argv[i];
                    filenameLength = strlen(argv[i]);
        hasR=1;
       }
      }else if(hasM == 2){
       if(argv[i][0]=='-'){
        return 0;
       }else{
        md5 = argv[i];
                    md5Length = strlen(argv[i]);
        hasM=1;
       }
      }else if(strcmp(argv[i],"-d")==0){
       if(hasD == 0){ hasD = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-r")==0){
       if(hasr == 0){ hasr = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-R")==0){
       if(hasR == 0){ hasR = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-m")==0){
       if(hasM == 0){ hasM = 2; }else{ return 0; }
      }else if(strcmp(argv[i],"-i")==0){
       if(hasI == 0){ hasI = 1; }else{ return 0; }
      }else if(strcmp(argv[i],"-l")==0){
       if(hasL == 0){ hasL = 1; }else{ return 0; }
      }else{
       return 0;
      }
     }
     if(hasD == 0 || hasD == 2){ return 0;}
     if((hasI + hasL + hasR + hasr)>1){ return 0; }
     if((hasM + hasI) > 1 || (hasM + hasL) > 1 || (hasM + hasR) > 1){ return 0;}
     if(hasI == 1){ return 'i';}
     if(hasL == 1){ return 'l';}
  if(hasr == 1){ if(hasM == 1){ return 'm';}
        else if(hasM == 2){ return 0; }
        else{return 'r';}
      }
  if(hasR == 1){ return 'R';}
  return 0;
    }
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int

variable_types: hasD int

variable_types: hasI int

variable_types: hasL int

variable_types: hasR int

variable_types: hasr int

variable_types: hasM int

return_type: char


toUpperCase

decompiled_code:
__int64 __fastcall toUpperCase(_BYTE *a1)
{
__int64 result; // rax

for ( result = (unsigned __int8)*a1; (_BYTE)result; result = (unsigned __int8)*a1 )
{
if ( (unsigned __int8)(result - 97) <= 0x19u )
*a1 = result - 32;
++a1;
}
return result;
}

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

for ( result = (unsigned __int8)*a1; (_BYTE)result; result = (unsigned __int8)*a1 )
{
if ( (unsigned __int8)(result - 97) <= 0x19u )
*a1 = result - 32;
++a1;
}
return result;
}

original_code:
void toUpperCase(char *str){
    int i;
    for(i=0;str[i];i++){
        if(str[i] >= 'a' && str[i] <= 'z'){
            str[i] -= ('a' - 'A');
        }
    }
}

variable_types:
str
char *


decompiled_code:
void __fastcall base64_encode_init(__int64 a1)
{
*(_DWORD *)a1 = 0;
*(_BYTE *)(a1 + 4) = 0;
}

original_code:
void base64_encode_init(base64_encodestate *S) {
    S->step = step_A;
    S->result = 0;
}

canonical_original_code:
void base64_encode_init(struct base64_encodestate *S) {
    S->step = step_A;
    S->result = 0;
}

variable_types: struct base64_encodestate { enum base64_encodestep { step_A=0, step_B=1, step_C=2 } step; unsigned char result; } *

user_defined_types: struct base64_encodestate { enum base64_encodestep step; unsigned char result; }


decompiled_code:
__int64 __fastcall base64_encode_value(unsigned __int8 a1)
{
__int64 result; // rax

result = 61LL;
if ( a1 <= 0x3Fu )
result = (unsigned __int8)byte_402040[a1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int8 a1)
{
__int64 result; // rax

result = 61LL;
if ( a1 <= 0x3Fu )
result = (unsigned __int8)byte_402040[a1];
return result;
}

original_code:
char base64_encode_value(uint8_t value) {
    static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    if (value > 63) return '=';
    return encoding[value];
}

canonical_original_code:
char base64_encode_value(unsigned char value) {
    static char *encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    if (value > 63) return '=';
    return encoding[value];
}

variable_types:
value
unsigned char

variable_types:
encoding
char *


original_code:
ptrdiff_t base64_encode_final(base64_encodestate *S, char *encoded) {
    char *encoded_begin = encoded;
    switch (S->step) {
    case step_B:
        *encoded++ = base64_encode_value(S->result);
        *encoded++ = '=';
        *encoded++ = '=';
        break;
    case step_C:
        *encoded++ = base64_encode_value(S->result);
        *encoded++ = '=';
        break;
    case step_A:
        break;
    }
    return encoded - encoded_begin;
}

canonical_original_code:
long base64_encode_final(struct base64_encodestate *S, char *encoded) {
    char *encoded_begin = encoded;
    switch (S->step) {
    case step_B:
        *encoded++ = base64_encode_value(S->result);
        *encoded++ = '=';
        *encoded++ = '=';
        break;
    case step_C:
        *encoded++ = base64_encode_value(S->result);
        *encoded++ = '=';
        break;
    case step_A:
        break;
    }
    return encoded - encoded_begin;
}

variable_types:
encoded
char *

return_type: long

user_defined_types: enum base64_encodestep { step_A=0, step_B=1, step_C=2 }


decompiled_code:
int __fastcall print_usage(const char *a1)
{
return fprintf(stderr, "Usage: %s [-hv]\n", a1);
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
return fprintf(stderr, "Usage: %s [-hv]\n", a1);
}

original_code:
void print_usage(char *name) {
 fprintf(stderr, "Usage: %s [-hv]\n", name);
}

variable_types:
name
char *


decompiled_code:
int print_version()
{
return fprintf(stdout, "Version %s\n", version);
}

canonical_decompiled_code:
int func1()
{
return fprintf(stdout, "Version %s\n", version);
}

original_code:
void print_version() {
 fprintf(stdout, "Version %s\n", version);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // r14
size_t i; // rbx
const char *v5; // rbp
char v6; // al
int result; // eax
char *v8; // rbx
void *v9; // rbp
unsigned int v10; // eax
unsigned int v11; // eax
char *ptr; // [rsp+8h] [rbp-60h] BYREF
void *v13[3]; // [rsp+10h] [rbp-58h] BYREF
void *v14; // [rsp+28h] [rbp-40h] BYREF

if ( argc <= 1 )
{
v14 = 0LL;
get_latest_version(v13, VERSIONS_URL, envp);
v8 = (char *)v13[0];
v9 = v13[2];
printf("Latest available version is %s\n", (const char *)v13[0]);
v10 = get_current_version(&v14);
if ( v10 > 1 )
{
fprintf(stderr, "current version failed with %d\n", v10);
result = 1;
}
else
{
printf("Current version is %s\n", (const char *)v14);
if ( !v14 || (int)compare_versions(v8) > 0 )
{
ptr = 0LL;
asprintf(&ptr, "%s%s.jar", SERVER_FILE, v8);
if ( !v9 )
puts("No download URL!\n");
v11 = update_minecraft(ptr, v9);
if ( v11 )
fprintf(stderr, "Failed to update minecraft server: error %d\n", v11);
}
free(v8);
free(v13[1]);
free(v9);
free(v14);
result = 0;
}
}
else
{
v3 = argv + 1;
do
{
if ( **v3 != 45 )
{
LABEL_12:
print_usage(*argv);
return 1;
}
for ( i = 1LL; ; ++i )
{
v5 = *v3;
if ( strlen(*v3) <= i )
break;
v6 = v5[i];
if ( v6 == 104 )
{
print_usage(*argv);
}
else
{
if ( v6 != 118 )
goto LABEL_12;
print_version();
}
}
++v3;
}
while ( v3 != &argv[(unsigned int)(argc - 2) + 2] );
result = 0;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // r14
size_t i; // rbx
const char *v5; // rbp
char v6; // al
int result; // eax
char *v8; // rbx
void *v9; // rbp
unsigned int v10; // eax
unsigned int v11; // eax
char *ptr; // [rsp+8h] [rbp-60h] BYREF
void *v13[3]; // [rsp+10h] [rbp-58h] BYREF
void *v14; // [rsp+28h] [rbp-40h] BYREF

if ( argc <= 1 )
{
v14 = 0LL;
get_latest_version(v13, VERSIONS_URL, envp);
v8 = (char *)v13[0];
v9 = v13[2];
printf("Latest available version is %s\n", (const char *)v13[0]);
v10 = get_current_version(&v14);
if ( v10 > 1 )
{
fprintf(stderr, "current version failed with %d\n", v10);
result = 1;
}
else
{
printf("Current version is %s\n", (const char *)v14);
if ( !v14 || (int)compare_versions(v8) > 0 )
{
ptr = 0LL;
asprintf(&ptr, "%s%s.jar", SERVER_FILE, v8);
if ( !v9 )
puts("No download URL!\n");
v11 = update_minecraft(ptr, v9);
if ( v11 )
fprintf(stderr, "Failed to update minecraft server: error %d\n", v11);
}
free(v8);
free(v13[1]);
free(v9);
free(v14);
result = 0;
}
}
else
{
v3 = argv + 1;
do
{
if ( **v3 != 45 )
{
LABEL_12:
func0(*argv);
return 1;
}
for ( i = 1LL; ; ++i )
{
v5 = *v3;
if ( strlen(*v3) <= i )
break;
v6 = v5[i];
if ( v6 == 104 )
{
func0(*argv);
}
else
{
if ( v6 != 118 )
goto LABEL_12;
func1();
}
}
++v3;
}
while ( v3 != &argv[(unsigned int)(argc - 2) + 2] );
result = 0;
}
return result;
}

original_code:
int main(int argc, char *argv[]) {
 if (argc > 1) {
  for (int i = 1; i < argc; ++i) {
   if (argv[i][0] != '-') {
    print_usage(argv[0]);
    return 1;
   }
   for (int j = 1; j < strlen(argv[i]); ++j) {
    switch (argv[i][j]) {
     case 'v': print_version(); break;
     case 'h': print_usage(argv[0]); break;
     default: print_usage(argv[0]); return 1;
    }
   }
  }
  return 0;
 }
 char *current_ver = ((void *)0);
 Version latest_ver;
 latest_ver = get_latest_version(VERSIONS_URL);
 printf("Latest available version is %s\n", latest_ver.id);
 int success = get_current_version(&current_ver);
 if (success != 0 && success != 1) {
   fprintf(stderr, "current version failed with %d\n", success);
   return 1;
 }
 printf("Current version is %s\n", current_ver);
 if (current_ver == ((void *)0) || compare_versions(latest_ver.id, current_ver) > 0 ) {
  char * filename = ((void *)0);
  asprintf(&filename, "%s%s.jar", SERVER_FILE, latest_ver.id);
  if (latest_ver.download_url == ((void *)0)) {
   puts("No download URL!\n");
  }
  success = update_minecraft(filename,
   latest_ver.download_url);
  if (success != 0) {
    fprintf(stderr, "Failed to update minecraft server: error %d\n", success);
  }
 }
 free(latest_ver.id);
 free(latest_ver.metadata_url);
 free(latest_ver.download_url);
 free(current_ver);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 if (argc > 1) {
  for (int i = 1; i < argc; ++i) {
   if (argv[i][0] != '-') {
    print_usage(argv[0]);
    return 1;
   }
   for (int j = 1; j < strlen(argv[i]); ++j) {
    switch (argv[i][j]) {
     case 'v': print_version(); break;
     case 'h': print_usage(argv[0]); break;
     default: print_usage(argv[0]); return 1;
    }
   }
  }
  return 0;
 }
 char *current_ver = ((void *)0);
 struct Version latest_ver;
 latest_ver = get_latest_version(VERSIONS_URL);
 printf("Latest available version is %s\n", latest_ver.id);
 int success = get_current_version(&current_ver);
 if (success != 0 && success != 1) {
   fprintf(stderr, "current version failed with %d\n", success);
   return 1;
 }
 printf("Current version is %s\n", current_ver);
 if (current_ver == ((void *)0) || compare_versions(latest_ver.id, current_ver) > 0 ) {
  char *filename = ((void *)0);
  asprintf(&filename, "%s%s.jar", SERVER_FILE, latest_ver.id);
  if (latest_ver.download_url == ((void *)0)) {
   puts("No download URL!\n");
  }
  success = update_minecraft(filename,
   latest_ver.download_url);
  if (success != 0) {
    fprintf(stderr, "Failed to update minecraft server: error %d\n", success);
  }
 }
 free(latest_ver.id);
 free(latest_ver.metadata_url);
 free(latest_ver.download_url);
 free(current_ver);
 return 0;
}

variable_types:
argv
char *[]

variable_types: j int

variable_types: struct Version { char *id; char *metadata_url; char *download_url; }

variable_types: success int

variable_types:
filename
char *


FieldVarMore

decompiled_code:
void FieldVarMore()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void FieldVarMore(TreeNode * t){
}

canonical_original_code:
void FieldVarMore(struct node *t){
}

variable_types: struct node { struct node *child[3]; struct node *Sibling; int Lineno; enum NodeKind { ProK=0, PheadK=1, TypeK=2, VarK=3, ProcDecK=4, StmLK=5, DecK=6, StmtK=7, ExpK=8 } nodeKind; char nodeKindStr[30]; union k { enum dec { ArrayK=0, CharK=1, IntegerK=2, RecordK=3, IdK=4 } d; enum stmt { IfK=0, WhileK=1, AssignK=2, ReadK=3, WriteK=4, CallK=5, ReturnK=6 } s; enum exp { OpK=0, ConstK=1, IdEK=2 } e; char name[30]; } kind; int idnum; char name[10][30]; char type_name[30]; union a { struct array { int low; int up; enum dec { ArrayK=0, CharK=1, IntegerK=2, RecordK=3, IdK=4 } childType; } a_attr; struct expAttr { char op; int val; enum varKind { IdV=0, ArrayMembV=1, FieldMembV=2 } varkind; enum ExpType { Void=0, Integer=1, Boolean=2 } type; } e_attr; struct proc { enum ProcAttrType { valparamtype=0, varparamtype=1 } paramt; } p_attr; } attr; } *

user_defined_types: struct node { struct node *child[3]; struct node *Sibling; int Lineno; enum NodeKind nodeKind; char nodeKindStr[30]; union k kind; int idnum; char name[10][30]; char type_name[30]; union a attr; }

user_defined_types: union k { enum dec d; enum stmt s; enum exp e; char name[30]; }

user_defined_types: union a { struct array a_attr; struct expAttr e_attr; struct proc p_attr; }

user_defined_types: struct array { int low; int up; enum dec childType; }

user_defined_types: struct expAttr { char op; int val; enum varKind varkind; enum ExpType type; }

user_defined_types: struct proc { enum ProcAttrType paramt; }


FieldVar

decompiled_code:
__int64 FieldVar()
{
ReadToken();
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
ReadToken();
return 0LL;
}

original_code:
TreeNode * FieldVar(){
  TreeNode * t = ((void *)0);
  ReadToken();
  if( t )
    FieldVarMore(t);
  return t;
}

canonical_original_code:
struct node *FieldVar(){
  struct node *t = ((void *)0);
  ReadToken();
  if( t )
    FieldVarMore(t);
  return t;
}

return_type: struct node { struct node *child[3]; struct node *Sibling; int Lineno; enum NodeKind { ProK=0, PheadK=1, TypeK=2, VarK=3, ProcDecK=4, StmLK=5, DecK=6, StmtK=7, ExpK=8 } nodeKind; char nodeKindStr[30]; union k { enum dec { ArrayK=0, CharK=1, IntegerK=2, RecordK=3, IdK=4 } d; enum stmt { IfK=0, WhileK=1, AssignK=2, ReadK=3, WriteK=4, CallK=5, ReturnK=6 } s; enum exp { OpK=0, ConstK=1, IdEK=2 } e; char name[30]; } kind; int idnum; char name[10][30]; char type_name[30]; union a { struct array { int low; int up; enum dec { ArrayK=0, CharK=1, IntegerK=2, RecordK=3, IdK=4 } childType; } a_attr; struct expAttr { char op; int val; enum varKind { IdV=0, ArrayMembV=1, FieldMembV=2 } varkind; enum ExpType { Void=0, Integer=1, Boolean=2 } type; } e_attr; struct proc { enum ProcAttrType { valparamtype=0, varparamtype=1 } paramt; } p_attr; } attr; } *


IntegerExpk

decompiled_code:
void *IntegerExpk()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
*((_DWORD *)v0 + 9) = 8;
sprintf((char *)v0 + 40, "ExpK %d", i_tokenValueBuffer);
return v0;
}

canonical_decompiled_code:
void *func2()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
*((_DWORD *)v0 + 9) = 8;
sprintf((char *)v0 + 40, "ExpK %d", i_tokenValueBuffer);
return v0;
}

original_code:
TreeNode * IntegerExpk(){
  TreeNode * t = (TreeNode *)malloc(sizeof(TreeNode));
  t->nodeKind = ExpK;
  sprintf(t->nodeKindStr, "ExpK %d", i_tokenValueBuffer);
  return t;
}

canonical_original_code:
struct node *IntegerExpk(){
  struct node *t = (TreeNode *)malloc(sizeof(TreeNode));
  t->nodeKind = ExpK;
  sprintf(t->nodeKindStr, "ExpK %d", i_tokenValueBuffer);
  return t;
}

user_defined_types: enum NodeKind { ProK=0, PheadK=1, TypeK=2, VarK=3, ProcDecK=4, StmLK=5, DecK=6, StmtK=7, ExpK=8 }

user_defined_types: enum dec { ArrayK=0, CharK=1, IntegerK=2, RecordK=3, IdK=4 }

user_defined_types: enum stmt { IfK=0, WhileK=1, AssignK=2, ReadK=3, WriteK=4, CallK=5, ReturnK=6 }

user_defined_types: enum varKind { IdV=0, ArrayMembV=1, FieldMembV=2 }

user_defined_types: enum ExpType { Void=0, Integer=1, Boolean=2 }

user_defined_types: enum ProcAttrType { valparamtype=0, varparamtype=1 }


Exp

decompiled_code:
__int64 Exp()
{
__int64 v0; // rbp
char *v1; // rax
_QWORD *v2; // rbx

v0 = SimpleExp();
ReadToken();
if ( (unsigned int)is_not_symbol("<") && (unsigned int)is_not_symbol(":=") && (unsigned int)is_not_symbol(">") )
{
UnReadToken();
}
else
{
v1 = (char *)malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*(_QWORD *)v1 = v0;
v1[440] = tokenValueBuffer;
*((_DWORD *)v1 + 9) = 8;
sprintf(v1 + 40, "ExpK Op %s", &tokenValueBuffer);
}
else
{
if ( !v0 )
return v0;
v2 = (_QWORD *)v0;
}
v2[1] = SimpleExp();
v0 = (__int64)v2;
}
return v0;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbp
char *v1; // rax
_QWORD *v2; // rbx

v0 = func8();
ReadToken();
if ( (unsigned int)is_not_symbol("<") && (unsigned int)is_not_symbol(":=") && (unsigned int)is_not_symbol(">") )
{
UnReadToken();
}
else
{
v1 = (char *)malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*(_QWORD *)v1 = v0;
v1[440] = tokenValueBuffer;
*((_DWORD *)v1 + 9) = 8;
sprintf(v1 + 40, "ExpK Op %s", &tokenValueBuffer);
}
else
{
if ( !v0 )
return v0;
v2 = (_QWORD *)v0;
}
v2[1] = func8();
v0 = (__int64)v2;
}
return v0;
}

original_code:
TreeNode * Exp(){
  TreeNode * t = SimpleExp();
  ReadToken();
  if( is_not_symbol("<") && is_not_symbol(":=") && is_not_symbol(">") ){
    UnReadToken();
    return t;
  }
  TreeNode * p = (TreeNode *)malloc(sizeof(TreeNode));
  if( p ){
    p->child[0] = t;
    p->attr.e_attr.op = tokenValueBuffer[0];
    p->nodeKind = ExpK;
    sprintf(p->nodeKindStr,"ExpK Op %s", tokenValueBuffer);
    t = p;
  }
  if( t )
    t->child[1] = SimpleExp();
  return t;
}

canonical_original_code:
struct node *Exp(){
  struct node *t = SimpleExp();
  ReadToken();
  if( is_not_symbol("<") && is_not_symbol(":=") && is_not_symbol(">") ){
    UnReadToken();
    return t;
  }
  struct node *p = (TreeNode *)malloc(sizeof(TreeNode));
  if( p ){
    p->child[0] = t;
    p->attr.e_attr.op = tokenValueBuffer[0];
    p->nodeKind = ExpK;
    sprintf(p->nodeKindStr,"ExpK Op %s", tokenValueBuffer);
    t = p;
  }
  if( t )
    t->child[1] = SimpleExp();
  return t;
}


variMore

decompiled_code:
__int64 __fastcall variMore(_QWORD *a1)
{
__int64 result; // rax

ReadToken();
if ( !(unsigned int)is_symbol("[") )
return UnReadToken();
*a1 = Exp();
ReadToken();
result = is_not_symbol("]");
if ( (_DWORD)result )
{
fwrite("VarMore ']' miss\n", 1uLL, 0x11uLL, stderr);
result = UnReadToken();
}
return result;
}

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

ReadToken();
if ( !(unsigned int)is_symbol("[") )
return UnReadToken();
*a1 = func3();
ReadToken();
result = is_not_symbol("]");
if ( (_DWORD)result )
{
fwrite("VarMore ']' miss\n", 1uLL, 0x11uLL, stderr);
result = UnReadToken();
}
return result;
}

original_code:
void variMore(TreeNode * t){
  ReadToken();
  if( is_symbol("[") ){
    t->child[0] = Exp();
    ReadToken();
    if( is_not_symbol("]") ){
      fprintf(stderr, "VarMore ']' miss\n");
      UnReadToken();
    }
    return;
  }
  UnReadToken();
}

canonical_original_code:
void variMore(struct node *t){
  ReadToken();
  if( is_symbol("[") ){
    t->child[0] = Exp();
    ReadToken();
    if( is_not_symbol("]") ){
      fprintf(stderr, "VarMore ']' miss\n");
      UnReadToken();
    }
    return;
  }
  UnReadToken();
}


Variable

decompiled_code:
_QWORD *Variable()
{
_QWORD *v0; // rbx
int v2; // eax

v0 = malloc(0x1C8uLL);
ReadToken();
if ( v0 && tokenType == 5 )
{
*((_DWORD *)v0 + 9) = 8;
strcpy((char *)v0 + 40, "ExpK");
v2 = *((_DWORD *)v0 + 26);
*((_DWORD *)v0 + 26) = v2 + 1;
strcpy((char *)v0 + 30 * v2 + 108, &tokenValueBuffer);
variMore(v0);
}
return v0;
}

canonical_decompiled_code:
_QWORD *func5()
{
_QWORD *v0; // rbx
int v2; // eax

v0 = malloc(0x1C8uLL);
ReadToken();
if ( v0 && tokenType == 5 )
{
*((_DWORD *)v0 + 9) = 8;
strcpy((char *)v0 + 40, "ExpK");
v2 = *((_DWORD *)v0 + 26);
*((_DWORD *)v0 + 26) = v2 + 1;
strcpy((char *)v0 + 30 * v2 + 108, &tokenValueBuffer);
func4(v0);
}
return v0;
}

original_code:
TreeNode * Variable(){
  TreeNode * t = (TreeNode *)malloc(sizeof(TreeNode));
  ReadToken();
  if( t && ( tokenType == SNL_ID ) ){
    t->nodeKind = ExpK;
    sprintf(t->nodeKindStr, "ExpK");
    strcpy(t->name[t->idnum++], tokenValueBuffer);
    variMore(t);
  }
  return t;
}

canonical_original_code:
struct node *Variable(){
  struct node *t = (TreeNode *)malloc(sizeof(TreeNode));
  ReadToken();
  if( t && ( tokenType == SNL_ID ) ){
    t->nodeKind = ExpK;
    sprintf(t->nodeKindStr, "ExpK");
    strcpy(t->name[t->idnum++], tokenValueBuffer);
    variMore(t);
  }
  return t;
}


Factor

decompiled_code:
void *Factor()
{
void *v0; // rbx

ReadToken();
if ( tokenType == 5 )
{
UnReadToken();
v0 = Variable();
}
else if ( tokenType )
{
v0 = 0LL;
if ( (unsigned int)is_symbol("(") )
{
v0 = (void *)Exp();
ReadToken();
if ( (unsigned int)is_not_symbol(")") )
fwrite("Factor miss ')'\n", 1uLL, 0x10uLL, stderr);
}
}
else
{
v0 = IntegerExpk();
}
return v0;
}

canonical_decompiled_code:
void *func6()
{
void *v0; // rbx

ReadToken();
if ( tokenType == 5 )
{
UnReadToken();
v0 = func5();
}
else if ( tokenType )
{
v0 = 0LL;
if ( (unsigned int)is_symbol("(") )
{
v0 = (void *)func3();
ReadToken();
if ( (unsigned int)is_not_symbol(")") )
fwrite("Factor miss ')'\n", 1uLL, 0x10uLL, stderr);
}
}
else
{
v0 = func2();
}
return v0;
}

original_code:
TreeNode * Factor(){
  TreeNode * t = ((void *)0);
  ReadToken();
  if( ( tokenType == SNL_ID ) ){
    UnReadToken();
    return Variable();
  }
  if( ( tokenType == SNL_INTERGER ) ){
    return IntegerExpk();
  }
  if( is_symbol("(") ){
    t = Exp();
    ReadToken();
    if( is_not_symbol(")") )
      fprintf(stderr, "Factor miss ')'\n");
  }
  return t;
}

canonical_original_code:
struct node *Factor(){
  struct node *t = ((void *)0);
  ReadToken();
  if( ( tokenType == SNL_ID ) ){
    UnReadToken();
    return Variable();
  }
  if( ( tokenType == SNL_INTERGER ) ){
    return IntegerExpk();
  }
  if( is_symbol("(") ){
    t = Exp();
    ReadToken();
    if( is_not_symbol(")") )
      fprintf(stderr, "Factor miss ')'\n");
  }
  return t;
}


Term

decompiled_code:
_QWORD *Term()
{
_QWORD *i; // rbp
char *v1; // rax
char *v2; // rbx

for ( i = Factor(); ; i[1] = Factor() )
{
ReadToken();
if ( (unsigned int)is_not_symbol("/") )
{
if ( (unsigned int)is_not_symbol("*") )
break;
}
v1 = (char *)malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*(_QWORD *)v1 = i;
v1[440] = tokenValueBuffer;
*((_DWORD *)v1 + 9) = 8;
sprintf(v1 + 40, "ExpK Op %s", &tokenValueBuffer);
i = v2;
}
}
UnReadToken();
return i;
}

canonical_decompiled_code:
_QWORD *func7()
{
_QWORD *i; // rbp
char *v1; // rax
char *v2; // rbx

for ( i = func6(); ; i[1] = func6() )
{
ReadToken();
if ( (unsigned int)is_not_symbol("/") )
{
if ( (unsigned int)is_not_symbol("*") )
break;
}
v1 = (char *)malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*(_QWORD *)v1 = i;
v1[440] = tokenValueBuffer;
*((_DWORD *)v1 + 9) = 8;
sprintf(v1 + 40, "ExpK Op %s", &tokenValueBuffer);
i = v2;
}
}
UnReadToken();
return i;
}

original_code:
TreeNode * Term(){
  TreeNode * t = Factor();
  TreeNode * p = ((void *)0);
  while(1){
    ReadToken();
    if( is_not_symbol("/") && is_not_symbol("*") ){
      UnReadToken();
      return t;
    }
    p = (TreeNode *)malloc(sizeof(TreeNode));
    if( p ){
      p->child[0] = t;
      p->attr.e_attr.op = tokenValueBuffer[0];
      p->nodeKind = ExpK;
      sprintf(p->nodeKindStr,"ExpK Op %s", tokenValueBuffer);
      t = p;
    }
    t->child[1] = Factor();
  }
  return t;
}

canonical_original_code:
struct node *Term(){
  struct node *t = Factor();
  struct node *p = ((void *)0);
  while(1){
    ReadToken();
    if( is_not_symbol("/") && is_not_symbol("*") ){
      UnReadToken();
      return t;
    }
    p = (struct node *)malloc(sizeof(TreeNode));
    if( p ){
      p->child[0] = t;
      p->attr.e_attr.op = tokenValueBuffer[0];
      p->nodeKind = ExpK;
      sprintf(p->nodeKindStr,"ExpK Op %s", tokenValueBuffer);
      t = p;
    }
    t->child[1] = Factor();
  }
  return t;
}


SimpleExp

decompiled_code:
_QWORD *SimpleExp()
{
_QWORD *i; // rbp
_BYTE *v1; // rax
_QWORD *v2; // rbx

for ( i = Term(); ; i[1] = Term() )
{
ReadToken();
if ( (unsigned int)is_not_symbol("+") )
{
if ( (unsigned int)is_not_symbol("-") )
break;
}
v1 = malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*(_QWORD *)v1 = i;
v1[440] = tokenValueBuffer;
*((_DWORD *)v1 + 9) = 8;
sprintf(v1 + 40, "ExpK Op %s", &tokenValueBuffer);
i = v2;
}
}
UnReadToken();
return i;
}

canonical_decompiled_code:
_QWORD *func8()
{
_QWORD *i; // rbp
_BYTE *v1; // rax
_QWORD *v2; // rbx

for ( i = func7(); ; i[1] = func7() )
{
ReadToken();
if ( (unsigned int)is_not_symbol("+") )
{
if ( (unsigned int)is_not_symbol("-") )
break;
}
v1 = malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*(_QWORD *)v1 = i;
v1[440] = tokenValueBuffer;
*((_DWORD *)v1 + 9) = 8;
sprintf(v1 + 40, "ExpK Op %s", &tokenValueBuffer);
i = v2;
}
}
UnReadToken();
return i;
}

original_code:
TreeNode * SimpleExp(){
  TreeNode * t = Term();
  TreeNode * p = ((void *)0);
  while(1){
    ReadToken();
    if( is_not_symbol("+") && is_not_symbol("-") ){
      UnReadToken();
      return t;
    }
    p = (TreeNode *)malloc(sizeof(TreeNode));
    if( p ){
      p->child[0] = t;
      p->attr.e_attr.op = tokenValueBuffer[0];
      p->nodeKind = ExpK;
      sprintf(p->nodeKindStr,"ExpK Op %s", tokenValueBuffer);
      t = p;
    }
    t->child[1] = Term();
  }
  return ((void *)0);
}

canonical_original_code:
struct node *SimpleExp(){
  struct node *t = Term();
  struct node *p = ((void *)0);
  while(1){
    ReadToken();
    if( is_not_symbol("+") && is_not_symbol("-") ){
      UnReadToken();
      return t;
    }
    p = (struct node *)malloc(sizeof(TreeNode));
    if( p ){
      p->child[0] = t;
      p->attr.e_attr.op = tokenValueBuffer[0];
      p->nodeKind = ExpK;
      sprintf(p->nodeKindStr,"ExpK Op %s", tokenValueBuffer);
      t = p;
    }
    t->child[1] = Term();
  }
  return ((void *)0);
}


ActParamList

decompiled_code:
__int64 ActParamList()
{
__int64 v0; // rbx

v0 = 0LL;
if ( !(unsigned int)is_symbol(")") )
{
v0 = Exp();
if ( v0 )
*(_QWORD *)(v0 + 24) = ActParamMore();
}
return v0;
}

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

v0 = 0LL;
if ( !(unsigned int)is_symbol(")") )
{
v0 = func3();
if ( v0 )
*(_QWORD *)(v0 + 24) = func10();
}
return v0;
}

original_code:
TreeNode * ActParamList(){
  if( is_symbol(")") )
    return ((void *)0);
  TreeNode * t = Exp();
  if( t )
    t->Sibling = ActParamMore();
  return t;
}

canonical_original_code:
struct node *ActParamList(){
  if( is_symbol(")") )
    return ((void *)0);
  struct node *t = Exp();
  if( t )
    t->Sibling = ActParamMore();
  return t;
}


ActParamMore

decompiled_code:
__int64 ActParamMore()
{
int v0; // edx
__int64 result; // rax
int v2; // edx

ReadToken();
v0 = is_symbol(")");
result = 0LL;
if ( !v0 )
{
v2 = is_symbol(",");
result = 0LL;
if ( v2 )
result = ActParamList();
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
int v0; // edx
__int64 result; // rax
int v2; // edx

ReadToken();
v0 = is_symbol(")");
result = 0LL;
if ( !v0 )
{
v2 = is_symbol(",");
result = 0LL;
if ( v2 )
result = func9();
}
return result;
}

original_code:
TreeNode * ActParamMore(){
  ReadToken();
  if( is_symbol(")") )
    return ((void *)0);
  if( is_symbol(",") )
    return ActParamList();
  return ((void *)0);
}

canonical_original_code:
struct node *ActParamMore(){
  ReadToken();
  if( is_symbol(")") )
    return ((void *)0);
  if( is_symbol(",") )
    return ActParamList();
  return ((void *)0);
}


AssCall

decompiled_code:
void *AssCall()
{
void *v0; // rbp
char *v1; // rax
char *v2; // rbx
int v3; // eax

v0 = malloc(0x1C8uLL);
v1 = (char *)malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*((_DWORD *)v1 + 9) = 8;
strcpy(v1 + 40, "ExpK");
v3 = *((_DWORD *)v1 + 26);
*((_DWORD *)v2 + 26) = v3 + 1;
strcpy(&v2[30 * v3 + 108], &tokenValueBuffer);
variMore(v2);
}
ReadToken();
if ( (unsigned int)is_symbol(":=") && v0 )
{
*(_QWORD *)v0 = v2;
*((_QWORD *)v0 + 1) = Exp();
*((_DWORD *)v0 + 9) = 8;
strcpy((char *)v0 + 40, "ExpK Op :=");
}
else if ( (unsigned int)is_symbol("(") && v0 )
{
*(_QWORD *)v0 = v2;
*((_QWORD *)v0 + 1) = ActParamList();
*((_DWORD *)v0 + 9) = 8;
strcpy((char *)v0 + 40, "ExpK Call");
if ( (unsigned int)is_not_symbol(")") )
fwrite("Call method miss ')'\n", 1uLL, 0x15uLL, stderr);
}
else
{
fwrite("AssCall error\n", 1uLL, 0xEuLL, stderr);
v0 = 0LL;
}
return v0;
}

canonical_decompiled_code:
void *func11()
{
void *v0; // rbp
char *v1; // rax
char *v2; // rbx
int v3; // eax

v0 = malloc(0x1C8uLL);
v1 = (char *)malloc(0x1C8uLL);
v2 = v1;
if ( v1 )
{
*((_DWORD *)v1 + 9) = 8;
strcpy(v1 + 40, "ExpK");
v3 = *((_DWORD *)v1 + 26);
*((_DWORD *)v2 + 26) = v3 + 1;
strcpy(&v2[30 * v3 + 108], &tokenValueBuffer);
func4(v2);
}
ReadToken();
if ( (unsigned int)is_symbol(":=") && v0 )
{
*(_QWORD *)v0 = v2;
*((_QWORD *)v0 + 1) = func3();
*((_DWORD *)v0 + 9) = 8;
strcpy((char *)v0 + 40, "ExpK Op :=");
}
else if ( (unsigned int)is_symbol("(") && v0 )
{
*(_QWORD *)v0 = v2;
*((_QWORD *)v0 + 1) = func9();
*((_DWORD *)v0 + 9) = 8;
strcpy((char *)v0 + 40, "ExpK Call");
if ( (unsigned int)is_not_symbol(")") )
fwrite("Call method miss ')'\n", 1uLL, 0x15uLL, stderr);
}
else
{
fwrite("AssCall error\n", 1uLL, 0xEuLL, stderr);
v0 = 0LL;
}
return v0;
}

original_code:
TreeNode * AssCall(){
  TreeNode * t = (TreeNode * )malloc(sizeof(TreeNode));
  TreeNode * p = (TreeNode * )malloc(sizeof(TreeNode));
  if( p ){
    p->nodeKind = ExpK;
    strcpy(p->nodeKindStr, "ExpK");
    strcpy(p->name[p->idnum++], tokenValueBuffer);
    variMore(p);
  }
  ReadToken();
  if( is_symbol(":=") && t ){
    t->child[0] = p;
    t->child[1] = Exp();
    t->nodeKind = ExpK;
    strcpy(t->nodeKindStr,"ExpK Op :=");
    return t;
  }
  if( is_symbol("(") && t ){
    t->child[0] = p;
    t->child[1] = ActParamList();
    t->nodeKind = ExpK;
    strcpy(t->nodeKindStr,"ExpK Call");
    if( is_not_symbol(")") )
      fprintf(stderr, "Call method miss ')'\n");
    return t;
  }
  fprintf(stderr, "AssCall error\n");
  return ((void *)0);
}

canonical_original_code:
struct node *AssCall(){
  struct node *t = (TreeNode * )malloc(sizeof(TreeNode));
  struct node *p = (TreeNode * )malloc(sizeof(TreeNode));
  if( p ){
    p->nodeKind = ExpK;
    strcpy(p->nodeKindStr, "ExpK");
    strcpy(p->name[p->idnum++], tokenValueBuffer);
    variMore(p);
  }
  ReadToken();
  if( is_symbol(":=") && t ){
    t->child[0] = p;
    t->child[1] = Exp();
    t->nodeKind = ExpK;
    strcpy(t->nodeKindStr,"ExpK Op :=");
    return t;
  }
  if( is_symbol("(") && t ){
    t->child[0] = p;
    t->child[1] = ActParamList();
    t->nodeKind = ExpK;
    strcpy(t->nodeKindStr,"ExpK Call");
    if( is_not_symbol(")") )
      fprintf(stderr, "Call method miss ')'\n");
    return t;
  }
  fprintf(stderr, "AssCall error\n");
  return ((void *)0);
}


ReturnStm

decompiled_code:
__int64 ReturnStm()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func12()
{
return 0LL;
}

original_code:
TreeNode * ReturnStm(){
  return ((void *)0);
}

canonical_original_code:
struct node *ReturnStm(){
  return ((void *)0);
}


InputStm

decompiled_code:
void *InputStm()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
ReadToken();
if ( (unsigned int)is_not_symbol("(") )
fwrite("InputStm miss '('\n", 1uLL, 0x12uLL, stderr);
if ( v0 )
*(_QWORD *)v0 = Variable();
*((_DWORD *)v0 + 9) = 7;
strcpy((char *)v0 + 40, "StmtK Input");
ReadToken();
if ( (unsigned int)is_not_symbol(")") )
fwrite("InputStm miss ')'\n", 1uLL, 0x12uLL, stderr);
return v0;
}

canonical_decompiled_code:
void *func13()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
ReadToken();
if ( (unsigned int)is_not_symbol("(") )
fwrite("InputStm miss '('\n", 1uLL, 0x12uLL, stderr);
if ( v0 )
*(_QWORD *)v0 = func5();
*((_DWORD *)v0 + 9) = 7;
strcpy((char *)v0 + 40, "StmtK Input");
ReadToken();
if ( (unsigned int)is_not_symbol(")") )
fwrite("InputStm miss ')'\n", 1uLL, 0x12uLL, stderr);
return v0;
}

original_code:
TreeNode * InputStm(){
  TreeNode * t = (TreeNode * )malloc(sizeof(TreeNode));
  ReadToken();
  if( is_not_symbol("(") )
    fprintf(stderr, "InputStm miss '('\n");
  if( t )
    t->child[0] = Variable();
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK Input");
  ReadToken();
  if( is_not_symbol(")") )
    fprintf(stderr, "InputStm miss ')'\n");
  return t;
}

canonical_original_code:
struct node *InputStm(){
  struct node *t = (TreeNode * )malloc(sizeof(TreeNode));
  ReadToken();
  if( is_not_symbol("(") )
    fprintf(stderr, "InputStm miss '('\n");
  if( t )
    t->child[0] = Variable();
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK Input");
  ReadToken();
  if( is_not_symbol(")") )
    fprintf(stderr, "InputStm miss ')'\n");
  return t;
}


OutputStm

decompiled_code:
void *OutputStm()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
ReadToken();
if ( (unsigned int)is_not_symbol("(") )
fwrite("OutputStm miss '('\n", 1uLL, 0x13uLL, stderr);
if ( v0 )
*(_QWORD *)v0 = Exp();
*((_DWORD *)v0 + 9) = 7;
strcpy((char *)v0 + 40, "StmtK Write");
ReadToken();
if ( (unsigned int)is_not_symbol(")") )
fwrite("OutputStm miss ')'\n", 1uLL, 0x13uLL, stderr);
return v0;
}

canonical_decompiled_code:
void *func14()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
ReadToken();
if ( (unsigned int)is_not_symbol("(") )
fwrite("OutputStm miss '('\n", 1uLL, 0x13uLL, stderr);
if ( v0 )
*(_QWORD *)v0 = func3();
*((_DWORD *)v0 + 9) = 7;
strcpy((char *)v0 + 40, "StmtK Write");
ReadToken();
if ( (unsigned int)is_not_symbol(")") )
fwrite("OutputStm miss ')'\n", 1uLL, 0x13uLL, stderr);
return v0;
}

original_code:
TreeNode * OutputStm(){
  TreeNode * t = (TreeNode * )malloc(sizeof(TreeNode));
  ReadToken();
  if( is_not_symbol("(") )
    fprintf(stderr, "OutputStm miss '('\n");
  if( t )
    t->child[0] = Exp();
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK Write");
  ReadToken();
  if( is_not_symbol(")") )
    fprintf(stderr, "OutputStm miss ')'\n");
  return t;
}

canonical_original_code:
struct node *OutputStm(){
  struct node *t = (TreeNode * )malloc(sizeof(TreeNode));
  ReadToken();
  if( is_not_symbol("(") )
    fprintf(stderr, "OutputStm miss '('\n");
  if( t )
    t->child[0] = Exp();
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK Write");
  ReadToken();
  if( is_not_symbol(")") )
    fprintf(stderr, "OutputStm miss ')'\n");
  return t;
}


ConditionalStm

decompiled_code:
void *ConditionalStm()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
*((_DWORD *)v0 + 9) = 7;
strcpy((char *)v0 + 40, "StmtK If");
*(_QWORD *)v0 = Exp();
ReadToken();
if ( (unsigned int)is_reversed_word("then") )
*((_QWORD *)v0 + 1) = Exp();
else
fwrite("Conditional Stm miss 'then' \n", 1uLL, 0x1DuLL, stderr);
ReadToken();
if ( (unsigned int)is_reversed_word("else") )
*((_QWORD *)v0 + 2) = Exp();
ReadToken();
if ( (unsigned int)is_not_reversed_word("fi") )
fwrite("Conditional Stm miss 'fi' \n", 1uLL, 0x1BuLL, stderr);
return v0;
}

canonical_decompiled_code:
void *func15()
{
void *v0; // rbx

v0 = malloc(0x1C8uLL);
*((_DWORD *)v0 + 9) = 7;
strcpy((char *)v0 + 40, "StmtK If");
*(_QWORD *)v0 = func3();
ReadToken();
if ( (unsigned int)is_reversed_word("then") )
*((_QWORD *)v0 + 1) = func3();
else
fwrite("Conditional Stm miss 'then' \n", 1uLL, 0x1DuLL, stderr);
ReadToken();
if ( (unsigned int)is_reversed_word("else") )
*((_QWORD *)v0 + 2) = func3();
ReadToken();
if ( (unsigned int)is_not_reversed_word("fi") )
fwrite("Conditional Stm miss 'fi' \n", 1uLL, 0x1BuLL, stderr);
return v0;
}

original_code:
TreeNode * ConditionalStm(){
  TreeNode * t = (TreeNode * )malloc(sizeof(TreeNode));
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK If");
  if( t )
    t->child[0] = Exp();
  ReadToken();
  if( is_reversed_word("then") && t)
    t->child[1] = Exp();
  else
    fprintf(stderr, "Conditional Stm miss 'then' \n");
  ReadToken();
  if( is_reversed_word("else") && t)
    t->child[2] = Exp();
  ReadToken();
  if( is_not_reversed_word("fi") )
    fprintf(stderr, "Conditional Stm miss 'fi' \n");
  return t;
}

canonical_original_code:
struct node *ConditionalStm(){
  struct node *t = (TreeNode * )malloc(sizeof(TreeNode));
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK If");
  if( t )
    t->child[0] = Exp();
  ReadToken();
  if( is_reversed_word("then") && t)
    t->child[1] = Exp();
  else
    fprintf(stderr, "Conditional Stm miss 'then' \n");
  ReadToken();
  if( is_reversed_word("else") && t)
    t->child[2] = Exp();
  ReadToken();
  if( is_not_reversed_word("fi") )
    fprintf(stderr, "Conditional Stm miss 'fi' \n");
  return t;
}


StmMore

decompiled_code:
__int64 StmMore()
{
int v0; // edx
__int64 result; // rax

ReadToken();
if ( (unsigned int)is_reversed_word("end") || (unsigned int)is_reversed_word("endwh") )
{
UnReadToken();
result = 0LL;
}
else
{
v0 = is_symbol(";");
result = 0LL;
if ( v0 )
result = StmList();
}
return result;
}

canonical_decompiled_code:
__int64 func17()
{
int v0; // edx
__int64 result; // rax

ReadToken();
if ( (unsigned int)is_reversed_word("end") || (unsigned int)is_reversed_word("endwh") )
{
UnReadToken();
result = 0LL;
}
else
{
v0 = is_symbol(";");
result = 0LL;
if ( v0 )
result = func16();
}
return result;
}

original_code:
TreeNode * StmMore(){
  TreeNode * t = ((void *)0);
  ReadToken();
  if( is_reversed_word("end") || is_reversed_word("endwh") ){
    UnReadToken();
    return ((void *)0);
  }
  if( is_symbol(";") )
    return StmList();
  return t;
}

canonical_original_code:
struct node *StmMore(){
  struct node *t = ((void *)0);
  ReadToken();
  if( is_reversed_word("end") || is_reversed_word("endwh") ){
    UnReadToken();
    return ((void *)0);
  }
  if( is_symbol(";") )
    return StmList();
  return t;
}


LoopStm

decompiled_code:
char *LoopStm()
{
char *v0; // rax
char *v1; // rbx

v0 = (char *)malloc(0x1C8uLL);
v1 = v0;
if ( v0 )
{
*((_DWORD *)v0 + 9) = 7;
strcpy(v0 + 40, "StmtK While");
*(_QWORD *)v0 = Exp();
ReadToken();
if ( (unsigned int)is_not_reversed_word("do") )
fwrite("LoopStm miss 'do'\n", 1uLL, 0x12uLL, stderr);
*((_QWORD *)v1 + 1) = StmList();
ReadToken();
if ( (unsigned int)is_not_reversed_word("endwh") )
fwrite("LoopStm miss 'endwh'\n", 1uLL, 0x15uLL, stderr);
}
return v1;
}

canonical_decompiled_code:
char *func18()
{
char *v0; // rax
char *v1; // rbx

v0 = (char *)malloc(0x1C8uLL);
v1 = v0;
if ( v0 )
{
*((_DWORD *)v0 + 9) = 7;
strcpy(v0 + 40, "StmtK While");
*(_QWORD *)v0 = func3();
ReadToken();
if ( (unsigned int)is_not_reversed_word("do") )
fwrite("LoopStm miss 'do'\n", 1uLL, 0x12uLL, stderr);
*((_QWORD *)v1 + 1) = func16();
ReadToken();
if ( (unsigned int)is_not_reversed_word("endwh") )
fwrite("LoopStm miss 'endwh'\n", 1uLL, 0x15uLL, stderr);
}
return v1;
}

original_code:
TreeNode * LoopStm(){
  TreeNode * t = (TreeNode * )malloc(sizeof(TreeNode));
  if( t == ((void *)0) )
    return t;
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK While");
  t->child[0] = Exp();
  ReadToken();
  if( is_not_reversed_word("do") )
    fprintf(stderr, "LoopStm miss 'do'\n");
  t->child[1] = StmList();
  ReadToken();
  if( is_not_reversed_word("endwh") )
    fprintf(stderr, "LoopStm miss 'endwh'\n");
  return t;
}

canonical_original_code:
struct node *LoopStm(){
  struct node *t = (TreeNode * )malloc(sizeof(TreeNode));
  if( t == ((void *)0) )
    return t;
  t->nodeKind = StmtK;
  strcpy(t->nodeKindStr, "StmtK While");
  t->child[0] = Exp();
  ReadToken();
  if( is_not_reversed_word("do") )
    fprintf(stderr, "LoopStm miss 'do'\n");
  t->child[1] = StmList();
  ReadToken();
  if( is_not_reversed_word("endwh") )
    fprintf(stderr, "LoopStm miss 'endwh'\n");
  return t;
}


Stm

decompiled_code:
char *Stm()
{
char *result; // rax

ReadToken();
if ( (unsigned int)is_reversed_word("if") )
return (char *)ConditionalStm();
if ( (unsigned int)is_reversed_word("while") )
return LoopStm();
if ( (unsigned int)is_reversed_word("return") )
return (char *)ReturnStm();
if ( (unsigned int)is_reversed_word("write") )
return (char *)OutputStm();
if ( (unsigned int)is_reversed_word("read") )
return (char *)InputStm();
if ( tokenType == 5 )
{
strcpy(temp_name, &tokenValueBuffer);
result = (char *)AssCall();
}
else
{
UnReadToken();
result = 0LL;
}
return result;
}

canonical_decompiled_code:
char *func19()
{
char *result; // rax

ReadToken();
if ( (unsigned int)is_reversed_word("if") )
return (char *)func15();
if ( (unsigned int)is_reversed_word("while") )
return func18();
if ( (unsigned int)is_reversed_word("return") )
return (char *)func12();
if ( (unsigned int)is_reversed_word("write") )
return (char *)func14();
if ( (unsigned int)is_reversed_word("read") )
return (char *)func13();
if ( tokenType == 5 )
{
strcpy(temp_name, &tokenValueBuffer);
result = (char *)func11();
}
else
{
UnReadToken();
result = 0LL;
}
return result;
}

original_code:
TreeNode * Stm(){
  ReadToken();
  if( is_reversed_word("if") )
    return ConditionalStm();
  if( is_reversed_word("while") )
    return LoopStm();
  if( is_reversed_word("return") )
    return ReturnStm();
  if( is_reversed_word("write") )
    return OutputStm();
  if( is_reversed_word("read") )
    return InputStm();
  if( ( tokenType == SNL_ID ) ) {
    strcpy(temp_name, tokenValueBuffer);
    return AssCall();
  }
  UnReadToken();
  return ((void *)0);
}

canonical_original_code:
struct node *Stm(){
  ReadToken();
  if( is_reversed_word("if") )
    return ConditionalStm();
  if( is_reversed_word("while") )
    return LoopStm();
  if( is_reversed_word("return") )
    return ReturnStm();
  if( is_reversed_word("write") )
    return OutputStm();
  if( is_reversed_word("read") )
    return InputStm();
  if( ( tokenType == SNL_ID ) ) {
    strcpy(temp_name, tokenValueBuffer);
    return AssCall();
  }
  UnReadToken();
  return ((void *)0);
}


ProgramBody

decompiled_code:
void *ProgramBody()
{
void *v0; // rbx

ReadToken();
if ( (unsigned int)is_not_reversed_word("begin") )
{
fwrite("Program body miss reversed word 'begin' \n", 1uLL, 0x29uLL, stderr);
UnReadToken();
v0 = 0LL;
}
else
{
v0 = malloc(0x1C8uLL);
*((_DWORD *)v0 + 9) = 5;
strcpy((char *)v0 + 40, "StmLK");
*(_QWORD *)v0 = StmList();
ReadToken();
if ( (unsigned int)is_not_reversed_word("end") )
{
fwrite("Program body miss reversed word 'end' \n", 1uLL, 0x27uLL, stderr);
UnReadToken();
v0 = 0LL;
}
}
return v0;
}

canonical_decompiled_code:
void *func20()
{
void *v0; // rbx

ReadToken();
if ( (unsigned int)is_not_reversed_word("begin") )
{
fwrite("Program body miss reversed word 'begin' \n", 1uLL, 0x29uLL, stderr);
UnReadToken();
v0 = 0LL;
}
else
{
v0 = malloc(0x1C8uLL);
*((_DWORD *)v0 + 9) = 5;
strcpy((char *)v0 + 40, "StmLK");
*(_QWORD *)v0 = func16();
ReadToken();
if ( (unsigned int)is_not_reversed_word("end") )
{
fwrite("Program body miss reversed word 'end' \n", 1uLL, 0x27uLL, stderr);
UnReadToken();
v0 = 0LL;
}
}
return v0;
}

original_code:
TreeNode * ProgramBody(){
  TreeNode * t = ((void *)0);
  ReadToken();
  if( is_not_reversed_word("begin") ){
    fprintf(stderr, "Program body miss reversed word 'begin' \n");
    UnReadToken();
    return ((void *)0);
  }
  t = (TreeNode * )malloc(sizeof(TreeNode));
  t->nodeKind = StmLK;
  strcpy(t->nodeKindStr, "StmLK");
  if(t)
    t->child[0] = StmList();
  ReadToken();
  if( is_not_reversed_word("end") ){
    fprintf(stderr, "Program body miss reversed word 'end' \n");
    UnReadToken();
    return ((void *)0);
  }
  return t;
}

canonical_original_code:
struct node *ProgramBody(){
  struct node *t = ((void *)0);
  ReadToken();
  if( is_not_reversed_word("begin") ){
    fprintf(stderr, "Program body miss reversed word 'begin' \n");
    UnReadToken();
    return ((void *)0);
  }
  t = (struct node * )malloc(sizeof(TreeNode));
  t->nodeKind = StmLK;
  strcpy(t->nodeKindStr, "StmLK");
  if(t)
    t->child[0] = StmList();
  ReadToken();
  if( is_not_reversed_word("end") ){
    fprintf(stderr, "Program body miss reversed word 'end' \n");
    UnReadToken();
    return ((void *)0);
  }
  return t;
}


VarIdList

decompiled_code:
__int64 __fastcall VarIdList(__int64 a1)
{
int v2; // eax

ReadToken();
if ( tokenType == 5 )
{
v2 = *(_DWORD *)(a1 + 104);
*(_DWORD *)(a1 + 104) = v2 + 1;
strcpy((char *)(a1 + 30LL * v2 + 108), &tokenValueBuffer);
}
return VarIdMore(a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v2; // eax

ReadToken();
if ( tokenType == 5 )
{
v2 = *(_DWORD *)(a1 + 104);
*(_DWORD *)(a1 + 104) = v2 + 1;
strcpy((char *)(a1 + 30LL * v2 + 108), &tokenValueBuffer);
}
return func1(a1);
}

original_code:
void VarIdList(TreeNode * t){
  ReadToken();
  if( ( tokenType == SNL_ID ) )
    strcpy(t->name[t->idnum++], tokenValueBuffer);
  VarIdMore(t);
}

canonical_original_code:
void VarIdList(struct node *t){
  ReadToken();
  if( ( tokenType == SNL_ID ) )
    strcpy(t->name[t->idnum++], tokenValueBuffer);
  VarIdMore(t);
}


VarIdMore

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

ReadToken();
result = is_symbol(&unk_1B1);
if ( !(_DWORD)result )
{
result = is_symbol(&unk_1B3);
if ( (_DWORD)result )
result = VarIdList(a1);
}
return result;
}

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

ReadToken();
result = is_symbol(&unk_1B1);
if ( !(_DWORD)result )
{
result = is_symbol(&unk_1B3);
if ( (_DWORD)result )
result = func0(a1);
}
return result;
}

original_code:
void VarIdMore(TreeNode * t){
  ReadToken();
  if( is_symbol(";") )
    return;
  else if( is_symbol(",") )
    VarIdList(t);
}

canonical_original_code:
void VarIdMore(struct node *t){
  ReadToken();
  if( is_symbol(";") )
    return;
  else if( is_symbol(",") )
    VarIdList(t);
}


VarDecList

decompiled_code:
__int64 VarDecList()
{
void *v0; // rax
__int64 v1; // rbx

v0 = malloc(0x1C8uLL);
v1 = (__int64)v0;
if ( v0 )
{
TypeDef(v0);
VarIdList(v1);
*(_DWORD *)(v1 + 36) = 6;
strcpy((char *)(v1 + 40), "DecK");
*(_QWORD *)(v1 + 24) = VarDecMore();
}
return v1;
}

original_code:
TreeNode * VarDecList(){
  TreeNode * t = (TreeNode *)malloc(sizeof(TreeNode));
  if(t == ((void *)0))
    return t;
  TypeDef(t);
  VarIdList(t);
  t->nodeKind = DecK;
  strcpy(t->nodeKindStr, "DecK");
  t->Sibling = VarDecMore();
  return t;
}

canonical_original_code:
struct node *VarDecList(){
  struct node *t = (TreeNode *)malloc(sizeof(TreeNode));
  if(t == ((void *)0))
    return t;
  TypeDef(t);
  VarIdList(t);
  t->nodeKind = DecK;
  strcpy(t->nodeKindStr, "DecK");
  t->Sibling = VarDecMore();
  return t;
}


VarDecMore

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

ReadToken();
if ( (unsigned int)is_reversed_word("integer")
|| (unsigned int)is_reversed_word("char")
|| (unsigned int)is_reversed_word("array")
|| (unsigned int)is_reversed_word("record")
|| tokenType == 5 )
{
UnReadToken();
result = VarDecList();
}
else
{
UnReadToken();
result = 0LL;
}
return result;
}

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

ReadToken();
if ( (unsigned int)is_reversed_word("integer")
|| (unsigned int)is_reversed_word("char")
|| (unsigned int)is_reversed_word("array")
|| (unsigned int)is_reversed_word("record")
|| tokenType == 5 )
{
UnReadToken();
result = func2();
}
else
{
UnReadToken();
result = 0LL;
}
return result;
}

original_code:
TreeNode * VarDecMore(){
  TreeNode * t = ((void *)0);
  ReadToken();
  if(
      is_reversed_word("integer") ||
      is_reversed_word("char") ||
      is_reversed_word("array") ||
      is_reversed_word("record") ||
      ( tokenType == SNL_ID )
    )
  {
    UnReadToken();
    t = VarDecList();
  } else
    UnReadToken();
  return t;
}

canonical_original_code:
struct node *VarDecMore(){
  struct node *t = ((void *)0);
  ReadToken();
  if(
      is_reversed_word("integer") ||
      is_reversed_word("char") ||
      is_reversed_word("array") ||
      is_reversed_word("record") ||
      ( tokenType == SNL_ID )
    )
  {
    UnReadToken();
    t = VarDecList();
  } else
    UnReadToken();
  return t;
}


VarDeclaration

decompiled_code:
__int64 VarDeclaration()
{
__int64 v0; // rbx

v0 = VarDecList();
if ( !v0 )
fwrite("Error var dec", 1uLL, 0xDuLL, stderr);
return v0;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbx

v0 = func2();
if ( !v0 )
fwrite("Error var dec", 1uLL, 0xDuLL, stderr);
return v0;
}

original_code:
TreeNode * VarDeclaration(){
  TreeNode * t = VarDecList();
  if( t == ((void *)0) )
    fprintf(stderr, "Error var dec");
  return t;
}

canonical_original_code:
struct node *VarDeclaration(){
  struct node *t = VarDecList();
  if( t == ((void *)0) )
    fprintf(stderr, "Error var dec");
  return t;
}


VarDec

decompiled_code:
__int64 VarDec()
{
ReadToken();
if ( (unsigned int)is_reversed_word("var") )
return VarDeclaration();
UnReadToken();
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
ReadToken();
if ( (unsigned int)is_reversed_word("var") )
return func4();
UnReadToken();
return 0LL;
}

original_code:
TreeNode * VarDec(){
  ReadToken();
  if( is_reversed_word("var") ){
    return VarDeclaration();
  }
  else {
    UnReadToken();
  }
  return ((void *)0);
}

canonical_original_code:
struct node *VarDec(){
  ReadToken();
  if( is_reversed_word("var") ){
    return VarDeclaration();
  }
  else {
    UnReadToken();
  }
  return ((void *)0);
}


ProcBody

decompiled_code:
__int64 ProcBody()
{
__int64 v0; // rbx

v0 = ProgramBody();
if ( !v0 )
fwrite("no procedure body error\n", 1uLL, 0x18uLL, stderr);
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbx

v0 = ProgramBody();
if ( !v0 )
fwrite("no procedure body error\n", 1uLL, 0x18uLL, stderr);
return v0;
}

original_code:
TreeNode * ProcBody(){
  TreeNode * t = ProgramBody();
  if( t == ((void *)0) )
    fprintf(stderr, "no procedure body error\n");
  return t;
}

canonical_original_code:
struct node *ProcBody(){
  struct node *t = ProgramBody();
  if( t == ((void *)0) )
    fprintf(stderr, "no procedure body error\n");
  return t;
}


ProcDecPart

decompiled_code:
__int64 ProcDecPart()
{
return DeclarePart();
}

canonical_decompiled_code:
__int64 func1()
{
return DeclarePart();
}

original_code:
TreeNode * ProcDecPart(){
  return DeclarePart();
}

canonical_original_code:
struct node *ProcDecPart(){
  return DeclarePart();
}


FormList

decompiled_code:
__int64 __fastcall FormList(__int64 a1)
{
int v2; // eax

ReadToken();
if ( tokenType == 5 )
{
v2 = *(_DWORD *)(a1 + 104);
*(_DWORD *)(a1 + 104) = v2 + 1;
strcpy((char *)(a1 + 30LL * v2 + 108), &tokenValueBuffer);
}
return FidMore(a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v2; // eax

ReadToken();
if ( tokenType == 5 )
{
v2 = *(_DWORD *)(a1 + 104);
*(_DWORD *)(a1 + 104) = v2 + 1;
strcpy((char *)(a1 + 30LL * v2 + 108), &tokenValueBuffer);
}
return func3(a1);
}

original_code:
void FormList(TreeNode * t){
  ReadToken();
  if( ( tokenType == SNL_ID ) )
    strcpy(t->name[t->idnum++], tokenValueBuffer);
  FidMore(t);
}

canonical_original_code:
void FormList(struct node *t){
  ReadToken();
  if( ( tokenType == SNL_ID ) )
    strcpy(t->name[t->idnum++], tokenValueBuffer);
  FidMore(t);
}


FidMore

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

ReadToken();
result = is_symbol(";");
if ( !(_DWORD)result )
{
result = is_symbol(")");
if ( !(_DWORD)result )
{
if ( (unsigned int)is_symbol(",") )
result = FormList(a1);
else
result = fwrite("FormList Error\n", 1uLL, 0xFuLL, stderr);
}
}
return result;
}

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

ReadToken();
result = is_symbol(";");
if ( !(_DWORD)result )
{
result = is_symbol(")");
if ( !(_DWORD)result )
{
if ( (unsigned int)is_symbol(",") )
result = func2(a1);
else
result = fwrite("FormList Error\n", 1uLL, 0xFuLL, stderr);
}
}
return result;
}

original_code:
void FidMore(TreeNode * t){
  ReadToken();
  if( is_symbol(";") || is_symbol(")") )
    return;
  if( is_symbol(",") ){
    FormList(t);
    return;
  }
  fprintf(stderr, "FormList Error\n");
}

canonical_original_code:
void FidMore(struct node *t){
  ReadToken();
  if( is_symbol(";") || is_symbol(")") )
    return;
  if( is_symbol(",") ){
    FormList(t);
    return;
  }
  fprintf(stderr, "FormList Error\n");
}


Param

decompiled_code:
_DWORD *Param()
{
_DWORD *v0; // rbx

v0 = malloc(0x1C8uLL);
if ( v0 )
{
if ( (unsigned int)is_reversed_word("integer")
|| (unsigned int)is_reversed_word("char")
|| (unsigned int)is_reversed_word("record")
|| (unsigned int)is_reversed_word("array")
|| tokenType == 5 )
{
v0[110] = 1;
UnReadToken();
TypeDef(v0);
FormList((__int64)v0);
}
else if ( (unsigned int)is_reversed_word("var") )
{
v0[110] = 1;
TypeDef(v0);
FormList((__int64)v0);
}
}
return v0;
}

canonical_decompiled_code:
_DWORD *func4()
{
_DWORD *v0; // rbx

v0 = malloc(0x1C8uLL);
if ( v0 )
{
if ( (unsigned int)is_reversed_word("integer")
|| (unsigned int)is_reversed_word("char")
|| (unsigned int)is_reversed_word("record")
|| (unsigned int)is_reversed_word("array")
|| tokenType == 5 )
{
v0[110] = 1;
UnReadToken();
TypeDef(v0);
func2((__int64)v0);
}
else if ( (unsigned int)is_reversed_word("var") )
{
v0[110] = 1;
TypeDef(v0);
func2((__int64)v0);
}
}
return v0;
}

original_code:
TreeNode * Param(){
  TreeNode * t = (TreeNode *)malloc(sizeof(TreeNode));
  if( t == ((void *)0) )
    return ((void *)0);
  if(
      is_reversed_word("integer") ||
      is_reversed_word("char") ||
      is_reversed_word("record") ||
      is_reversed_word("array") ||
      ( tokenType == SNL_ID )
    ){
    t->attr.p_attr.paramt = varparamtype;
    UnReadToken();
    TypeDef(t);
    FormList(t);
  } else if( is_reversed_word("var") ){
    t->attr.p_attr.paramt = varparamtype;
    TypeDef(t);
    FormList(t);
  }
  return t;
}

canonical_original_code:
struct node *Param(){
  struct node *t = (TreeNode *)malloc(sizeof(TreeNode));
  if( t == ((void *)0) )
    return ((void *)0);
  if(
      is_reversed_word("integer") ||
      is_reversed_word("char") ||
      is_reversed_word("record") ||
      is_reversed_word("array") ||
      ( tokenType == SNL_ID )
    ){
    t->attr.p_attr.paramt = varparamtype;
    UnReadToken();
    TypeDef(t);
    FormList(t);
  } else if( is_reversed_word("var") ){
    t->attr.p_attr.paramt = varparamtype;
    TypeDef(t);
    FormList(t);
  }
  return t;
}


ParamDecList

decompiled_code:
char *ParamDecList()
{
char *v0; // rbx
__int64 v1; // rax

v0 = (char *)Param();
v1 = ParamMore();
*((_DWORD *)v0 + 9) = 6;
strcpy(v0 + 40, "DecK");
if ( v1 )
*((_QWORD *)v0 + 3) = v1;
return v0;
}

original_code:
TreeNode * ParamDecList(){
  TreeNode * t = Param();
  TreeNode * p = ParamMore();
  t->nodeKind = DecK;
  strcpy(t->nodeKindStr, "DecK");
  if(p)
    t->Sibling = p;
  return t;
}

canonical_original_code:
struct node *ParamDecList(){
  struct node *t = Param();
  struct node *p = ParamMore();
  t->nodeKind = DecK;
  strcpy(t->nodeKindStr, "DecK");
  if(p)
    t->Sibling = p;
  return t;
}


ParamMore

decompiled_code:
char *ParamMore()
{
char *result; // rax

if ( (unsigned int)is_symbol(")") )
{
UnReadToken();
result = 0LL;
}
else if ( !(unsigned int)is_symbol(";") || (ReadToken(), (result = ParamDecList()) == 0LL) )
{
fwrite("Param More Error\n", 1uLL, 0x11uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
char *func6()
{
char *result; // rax

if ( (unsigned int)is_symbol(")") )
{
UnReadToken();
result = 0LL;
}
else if ( !(unsigned int)is_symbol(";") || (ReadToken(), (result = func5()) == 0LL) )
{
fwrite("Param More Error\n", 1uLL, 0x11uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
TreeNode * ParamMore(){
  if( is_symbol(")") ){
    UnReadToken();
    return ((void *)0);
  }
  TreeNode * t = ((void *)0);
  if( is_symbol(";") ){
    ReadToken();
    t = ParamDecList();
  }
  if( t == ((void *)0) )
    fprintf(stderr,"Param More Error\n");
  return t;
}

canonical_original_code:
struct node *ParamMore(){
  if( is_symbol(")") ){
    UnReadToken();
    return ((void *)0);
  }
  struct node *t = ((void *)0);
  if( is_symbol(";") ){
    ReadToken();
    t = ParamDecList();
  }
  if( t == ((void *)0) )
    fprintf(stderr,"Param More Error\n");
  return t;
}