decompiled_code:
__int64 __fastcall Arguments_Read(int *a1, __int64 a2, __int64 *a3)
{
__int64 v5; // rdx
__int64 *v6; // rbx
unsigned int v7; // er13
__int16 v8; // ax
__int64 v10; // rax
__int64 v11; // r14
const char *v12; // rdi
__int64 v13; // rax

v5 = *a3;
if ( !v5 )
{
v7 = 0;
goto LABEL_13;
}
v6 = a3 + 3;
v7 = 0;
do
{
v8 = *((_WORD *)v6 - 8);
switch ( v8 )
{
case 0:
break;
case 6:
if ( (unsigned int)CheckArguments(a1, a2, v5) )
{
++v7;
((void (*)(void))*(v6 - 1))();
}
break;
case 1:
v10 = GetStringFromArguments(a1, a2, v5);
v11 = v10;
if ( !v10 )
break;
if ( !(unsigned int)StringCmp(v10, &unk_362) || !(unsigned int)StringCmp(v11, &unk_366) )
{
LABEL_19:
++v7;
*(_WORD *)*(v6 - 1) = 0;
break;
}
if ( !(unsigned int)StringCmp(v11, &unk_36A) || !(unsigned int)StringCmp(v11, &unk_36D) )
goto LABEL_21;
break;
case 2:
if ( !(unsigned int)CheckArguments(a1, a2, v5) )
break;
LABEL_21:
++v7;
*(_WORD *)*(v6 - 1) = 1;
break;
case 3:
if ( (unsigned int)CheckArguments(a1, a2, v5) )
goto LABEL_19;
break;
case 4:
v12 = (const char *)GetStringFromArguments(a1, a2, v5);
if ( v12 )
{
++v7;
*(_DWORD *)*(v6 - 1) = atoi(v12);
}
break;
case 5:
v13 = GetStringFromArguments(a1, a2, v5);
if ( v13 )
{
++v7;
*(_QWORD *)*(v6 - 1) = v13;
}
break;
}
v5 = *v6;
v6 += 3;
}
while ( v5 );
while ( *a1 > 1 )
{
fprintf(stderr, "ERROR : Unknown Argument : %s\n", *(const char **)(a2 + 8));
DeleteArgument(a1, a2, 1);
LABEL_13:
;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, __int64 a2, __int64 *a3)
{
__int64 v5; // rdx
__int64 *v6; // rbx
unsigned int v7; // er13
__int16 v8; // ax
__int64 v10; // rax
__int64 v11; // r14
const char *v12; // rdi
__int64 v13; // rax

v5 = *a3;
if ( !v5 )
{
v7 = 0;
goto LABEL_13;
}
v6 = a3 + 3;
v7 = 0;
do
{
v8 = *((_WORD *)v6 - 8);
switch ( v8 )
{
case 0:
break;
case 6:
if ( (unsigned int)func1(a1, a2, v5) )
{
++v7;
((void (*)(void))*(v6 - 1))();
}
break;
case 1:
v10 = func2(a1, a2, v5);
v11 = v10;
if ( !v10 )
break;
if ( !(unsigned int)StringCmp(v10, &unk_362) || !(unsigned int)StringCmp(v11, &unk_366) )
{
LABEL_19:
++v7;
*(_WORD *)*(v6 - 1) = 0;
break;
}
if ( !(unsigned int)StringCmp(v11, &unk_36A) || !(unsigned int)StringCmp(v11, &unk_36D) )
goto LABEL_21;
break;
case 2:
if ( !(unsigned int)func1(a1, a2, v5) )
break;
LABEL_21:
++v7;
*(_WORD *)*(v6 - 1) = 1;
break;
case 3:
if ( (unsigned int)func1(a1, a2, v5) )
goto LABEL_19;
break;
case 4:
v12 = (const char *)func2(a1, a2, v5);
if ( v12 )
{
++v7;
*(_DWORD *)*(v6 - 1) = atoi(v12);
}
break;
case 5:
v13 = func2(a1, a2, v5);
if ( v13 )
{
++v7;
*(_QWORD *)*(v6 - 1) = v13;
}
break;
}
v5 = *v6;
v6 += 3;
}
while ( v5 );
while ( *a1 > 1 )
{
fprintf(stderr, "ERROR : Unknown Argument : %s\n", *(const char **)(a2 + 8));
func0(a1, a2, 1);
LABEL_13:
;
}
return v7;
}

original_code:
int Arguments_Read(int * argc, char ** argv, Argument arguments[])
{
  int i;
  char * p;
  void (*funcp)();
  int n = 0;
  for (i = 0; arguments[i].name != ((void *)0); i++) {
    if (arguments[i].flag == 0) {
    } else if (arguments[i].flag == 6) {
      if (CheckArguments(argc, argv, arguments[i].name)) {
        funcp = (void (*)())(arguments[i].value);
        (*funcp)();
 n++;
      }
    } else if (arguments[i].flag == 1) {
      if ((p = GetStringFromArguments(argc,argv,arguments[i].name)) != ((void *)0)) {
        if ( (!StringCmp(p, "off")) || (!StringCmp(p, "OFF")) ) {
   *((short int *)(arguments[i].value)) = 0;
   n++;
 } else if ( (!StringCmp(p, "on" )) || (!StringCmp(p, "ON" )) ) {
   *((short int *)(arguments[i].value)) = 1;
   n++;
 }
      }
    } else if (arguments[i].flag == 2) {
      if (CheckArguments(argc, argv, arguments[i].name)) {
        *((short int *)(arguments[i].value)) = 1;
 n++;
      }
    } else if (arguments[i].flag == 3) {
      if (CheckArguments(argc, argv, arguments[i].name)) {
        *((short int *)(arguments[i].value)) = 0;
 n++;
      }
    } else if (arguments[i].flag == 4) {
      if ((p=GetStringFromArguments(argc, argv, arguments[i].name)) != ((void *)0)) {
        *((int *)(arguments[i].value)) = atoi(p);
 n++;
      }
    } else if (arguments[i].flag == 5) {
      if ((p=GetStringFromArguments(argc, argv, arguments[i].name)) != ((void *)0)) {
        *((char **)(arguments[i].value)) = p;
 n++;
      }
    }
  }
  while (*argc > 1) {
    fprintf(stderr, "ERROR : Unknown Argument : %s\n", argv[1]);
    DeleteArgument(argc, argv, 1);
  }
  return (n);
}

canonical_original_code:
int Arguments_Read(int *argc, char **argv, struct _Argument arguments[])
{
  int i;
  char *p;
  void (*funcp)();
  int n = 0;
  for (i = 0; arguments[i].name != ((void *)0); i++) {
    if (arguments[i].flag == 0) {
    } else if (arguments[i].flag == 6) {
      if (CheckArguments(argc, argv, arguments[i].name)) {
        funcp = (void (*)())(arguments[i].value);
        (*funcp)();
 n++;
      }
    } else if (arguments[i].flag == 1) {
      if ((p = GetStringFromArguments(argc,argv,arguments[i].name)) != ((void *)0)) {
        if ( (!StringCmp(p, "off")) || (!StringCmp(p, "OFF")) ) {
   *((short *)(arguments[i].value)) = 0;
   n++;
 } else if ( (!StringCmp(p, "on" )) || (!StringCmp(p, "ON" )) ) {
   *((short *)(arguments[i].value)) = 1;
   n++;
 }
      }
    } else if (arguments[i].flag == 2) {
      if (CheckArguments(argc, argv, arguments[i].name)) {
        *((short *)(arguments[i].value)) = 1;
 n++;
      }
    } else if (arguments[i].flag == 3) {
      if (CheckArguments(argc, argv, arguments[i].name)) {
        *((short *)(arguments[i].value)) = 0;
 n++;
      }
    } else if (arguments[i].flag == 4) {
      if ((p=GetStringFromArguments(argc, argv, arguments[i].name)) != ((void *)0)) {
        *((int *)(arguments[i].value)) = atoi(p);
 n++;
      }
    } else if (arguments[i].flag == 5) {
      if ((p=GetStringFromArguments(argc, argv, arguments[i].name)) != ((void *)0)) {
        *((char **)(arguments[i].value)) = p;
 n++;
      }
    }
  }
  while (*argc > 1) {
    fprintf(stderr, "ERROR : Unknown Argument : %s\n", argv[1]);
    DeleteArgument(argc, argv, 1);
  }
  return (n);
}

variable_types: struct _Argument { char *name; short flag; void *value; } []

variable_types:
funcp
void (*)()

variable_types: n int


CheckWord

repo: yabuki/xfireworks

decompiled_code:
__int64 __fastcall CheckWord(_BYTE *a1, int a2)
{
if ( a2 != -1 && a1 )
{
while ( *a1 )
{
if ( (char)*a1 == a2 )
return 1LL;
++a1;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, int a2)
{
if ( a2 != -1 && a1 )
{
while ( *a1 )
{
if ( (char)*a1 == a2 )
return 1LL;
++a1;
}
}
return 0LL;
}

original_code:
static int CheckWord(char * s, int c)
{
  if (c == (-1)) return (0);
  if (s == ((void *)0)) return (0);
  while (*s != '\0') {
    if (c == *s) return (1);
    s++;
  }
  return (0);
}

canonical_original_code:
static int CheckWord(char *s, int c)
{
  if (c == (-1)) return (0);
  if (s == ((void *)0)) return (0);
  while (*s != '\0') {
    if (c == *s) return (1);
    s++;
  }
  return (0);
}

variable_types:
s
char *

variable_types: c int

return_type: int


decompiled_code:
void __fastcall __noreturn Stream_ErrorExit(const char *a1, const char *a2)
{
fprintf(stderr, "Error in %s():%s\n", a1, a2);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(const char *a1, const char *a2)
{
fprintf(stderr, "Error in %s():%s\n", a1, a2);
exit(1);
}

original_code:
static void Stream_ErrorExit(char * function, char * message)
{
  fprintf(stderr, "Error in %s():%s\n", function, message);
  exit(1);
}

canonical_original_code:
static void Stream_ErrorExit(char *function, char *message)
{
  fprintf(stderr, "Error in %s():%s\n", function, message);
  exit(1);
}

variable_types:
function
char *

variable_types:
message
char *

return_type: void


Error

decompiled_code:
void __fastcall __noreturn Error(const char *a1, const char *a2)
{
fprintf(stderr, "Error in %s:%s\n", a1, a2);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1, const char *a2)
{
fprintf(stderr, "Error in %s:%s\n", a1, a2);
exit(1);
}

original_code:
int Error(char * funcname, char * message)
{
  fprintf(stderr, "Error in %s:%s\n", funcname, message);
  exit (1);
}

canonical_original_code:
int Error(char *funcname, char *message)
{
  fprintf(stderr, "Error in %s:%s\n", funcname, message);
  exit (1);
}

variable_types:
funcname
char *


InitializeRand

decompiled_code:
void InitializeRand()
{
unsigned int v0; // eax

v0 = time(0LL);
srand(v0);
}

canonical_decompiled_code:
void func1()
{
unsigned int v0; // eax

v0 = time(0LL);
srand(v0);
}

original_code:
void InitializeRand()
{
  srand((unsigned)time(((void *)0)));
}

canonical_original_code:
void InitializeRand()
{
  srand((unsigned int)time(((void *)0)));
}


Rand

decompiled_code:
__int64 __fastcall Rand(int a1)
{
return (unsigned int)(rand() % a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
return (unsigned int)(rand() % a1);
}

original_code:
int Rand(int n)
{
  return (rand() % n);
}


DoubleRand

decompiled_code:
double __fastcall DoubleRand(double a1)
{
return (double)(int)Rand(10001) / 10000.0 * a1;
}

canonical_decompiled_code:
double __fastcall func3(double a1)
{
return (double)(int)func2(10001) / 10000.0 * a1;
}

original_code:
double DoubleRand(double d)
{
  return ((double)Rand(10001) / 10000.0 * d);
}

variable_types: d double

return_type: double


StringLen

decompiled_code:
__int64 __fastcall StringLen(_BYTE *a1)
{
__int64 v1; // rax
unsigned int v2; // er8

if ( !*a1 )
return 0LL;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1)
{
__int64 v1; // rax
unsigned int v2; // er8

if ( !*a1 )
return 0LL;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

original_code:
int StringLen(char * str)
{
  int i;
  for (i = 0; str[i] != '\0'; i++) { }
  return (i);
}

canonical_original_code:
int StringLen(char *str)
{
  int i;
  for (i = 0; str[i] != '\0'; i++) { }
  return (i);
}

variable_types:
str
char *

variable_types: i int


StringCpy

decompiled_code:
__int64 __fastcall StringCpy(_BYTE *a1, char *a2)
{
char v2; // dl
__int64 v3; // rax
unsigned int v4; // er8
__int64 v5; // rcx
__int64 result; // rax

v2 = *a2;
if ( *a2 )
{
v3 = 1LL;
do
{
a1[v3 - 1] = v2;
v4 = v3;
v5 = v3++;
v2 = a2[v3 - 1];
}
while ( v2 );
result = v4;
a1[v5] = 0;
}
else
{
*a1 = 0;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_BYTE *a1, char *a2)
{
char v2; // dl
__int64 v3; // rax
unsigned int v4; // er8
__int64 v5; // rcx
__int64 result; // rax

v2 = *a2;
if ( *a2 )
{
v3 = 1LL;
do
{
a1[v3 - 1] = v2;
v4 = v3;
v5 = v3++;
v2 = a2[v3 - 1];
}
while ( v2 );
result = v4;
a1[v5] = 0;
}
else
{
*a1 = 0;
result = 0LL;
}
return result;
}

original_code:
int StringCpy(char * dst, char * src)
{
  int i;
  for (i = 0; src[i] != '\0'; i++) { dst[i] = src[i]; }
  dst[i] = '\0';
  return (i);
}

canonical_original_code:
int StringCpy(char *dst, char *src)
{
  int i;
  for (i = 0; src[i] != '\0'; i++) { dst[i] = src[i]; }
  dst[i] = '\0';
  return (i);
}

variable_types:
dst
char *

variable_types:
src
char *


StringCat

decompiled_code:
__int64 __fastcall StringCat(_BYTE *a1, char *a2)
{
int v2; // eax

v2 = StringLen(a1);
return StringCpy(&a1[v2], a2);
}

canonical_decompiled_code:
__int64 __fastcall func6(_BYTE *a1, char *a2)
{
int v2; // eax

v2 = func4(a1);
return func5(&a1[v2], a2);
}

original_code:
int StringCat(char * dst, char * src)
{
  return (StringCpy(dst + StringLen(dst), src));
}

canonical_original_code:
int StringCat(char *dst, char *src)
{
  return (StringCpy(dst + StringLen(dst), src));
}


StringCmp

decompiled_code:
__int64 __fastcall StringCmp(char *a1, _BYTE *a2)
{
char v2; // dl
__int64 v3; // rax
char v4; // cl

v2 = *a1;
if ( !*a1 )
return (unsigned int)-(*a2 != 0);
v3 = 0LL;
while ( 1 )
{
v4 = a2[v3];
if ( !v4 || v4 < v2 )
return 1LL;
if ( v4 > v2 )
break;
v2 = a1[++v3];
if ( !v2 )
{
a2 += v3;
return (unsigned int)-(*a2 != 0);
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *a1, _BYTE *a2)
{
char v2; // dl
__int64 v3; // rax
char v4; // cl

v2 = *a1;
if ( !*a1 )
return (unsigned int)-(*a2 != 0);
v3 = 0LL;
while ( 1 )
{
v4 = a2[v3];
if ( !v4 || v4 < v2 )
return 1LL;
if ( v4 > v2 )
break;
v2 = a1[++v3];
if ( !v2 )
{
a2 += v3;
return (unsigned int)-(*a2 != 0);
}
}
return 0xFFFFFFFFLL;
}

original_code:
int StringCmp(char * str1, char * str2)
{
  int i = 0;
  while (1) {
    if ( (str1[i] == '\0') && (str2[i] == '\0') ) return (0);
    if (str1[i] == '\0') return (-1);
    if (str2[i] == '\0') return ( 1);
    if (str1[i] > str2[i]) return ( 1);
    if (str1[i] < str2[i]) return (-1);
    i++;
  }
}

canonical_original_code:
int StringCmp(char *str1, char *str2)
{
  int i = 0;
  while (1) {
    if ( (str1[i] == '\0') && (str2[i] == '\0') ) return (0);
    if (str1[i] == '\0') return (-1);
    if (str2[i] == '\0') return ( 1);
    if (str1[i] > str2[i]) return ( 1);
    if (str1[i] < str2[i]) return (-1);
    i++;
  }
}


StringEqual

decompiled_code:
_BOOL8 __fastcall StringEqual(char *a1, _BYTE *a2)
{
return (unsigned int)StringCmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(char *a1, _BYTE *a2)
{
return (unsigned int)func7(a1, a2) == 0;
}

original_code:
int StringEqual(char * str1, char * str2)
{
  return (!StringCmp(str1, str2));
}

canonical_original_code:
int StringEqual(char *str1, char *str2)
{
  return (!StringCmp(str1, str2));
}


decompiled_code:
__int64 __fastcall Calculator_Destroy(void *ptr)
{
void *v2; // rdi

if ( !ptr )
return 0LL;
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *ptr)
{
void *v2; // rdi

if ( !ptr )
return 0LL;
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
return 0LL;
}

original_code:
Calculator Calculator_Destroy(Calculator cal)
{
  if (!cal) return (((void *)0));
  if (cal->sine) free(cal->sine);
  free(cal);
  return (((void *)0));
}

canonical_original_code:
struct _Calculator *Calculator_Destroy(struct _Calculator *cal)
{
  if (!cal) return (((void *)0));
  if (cal->sine) free(cal->sine);
  free(cal);
  return (((void *)0));
}

variable_types:
cal
struct _Calculator *

return_type: struct _Calculator { int degree_number; double *sine; } *


decompiled_code:
double __fastcall Calculator_GetSin(int *a1, int a2)
{
int v2; // ecx
int i; // eax

v2 = *a1;
for ( i = a2; i < 0; i += v2 )
;
return *(double *)(*((_QWORD *)a1 + 1) + 8LL * (i % v2));
}

canonical_decompiled_code:
double __fastcall func2(int *a1, int a2)
{
int v2; // ecx
int i; // eax

v2 = *a1;
for ( i = a2; i < 0; i += v2 )
;
return *(double *)(*((_QWORD *)a1 + 1) + 8LL * (i % v2));
}

original_code:
double Calculator_GetSin(Calculator cal, int degree)
{
  while (degree < 0) degree += cal->degree_number;
  degree = degree % cal->degree_number;
  return (cal->sine[degree]);
}

canonical_original_code:
double Calculator_GetSin(struct _Calculator *cal, int degree)
{
  while (degree < 0) degree += cal->degree_number;
  degree = degree % cal->degree_number;
  return (cal->sine[degree]);
}

variable_types: struct _Calculator { int degree_number; double *sine; } *

variable_types: degree int


decompiled_code:
double __fastcall Calculator_GetCos(int *a1, int a2)
{
int v3; // esi

v3 = *a1 + 3;
if ( *a1 >= 0 )
v3 = *a1;
return Calculator_GetSin(a1, (v3 >> 2) - a2);
}

canonical_decompiled_code:
double __fastcall func3(int *a1, int a2)
{
int v3; // esi

v3 = *a1 + 3;
if ( *a1 >= 0 )
v3 = *a1;
return func2(a1, (v3 >> 2) - a2);
}

original_code:
double Calculator_GetCos(Calculator cal, int degree)
{
  return (Calculator_GetSin(cal, cal->degree_number / 4 - degree));
}

canonical_original_code:
double Calculator_GetCos(struct _Calculator *cal, int degree)
{
  return (Calculator_GetSin(cal, cal->degree_number / 4 - degree));
}

user_defined_types: struct _Calculator { int degree_number; double *sine; }


help

decompiled_code:
void __noreturn help()
{
printf("%s\n\n", "XFireworks-1.3");
puts("XFireworks Copyright (c) 2000 Sakai Hiroaki.");
puts("All Rights Reserved.\n");
puts("Usage:");
puts(" xfireworks [options]\n");
puts("Options:");
puts(" -h, -help");
puts(" -display [displayname]");
puts(" -bg, -background, -background-color [backgroundcolor]");
puts(" -f, -file [filename]");
puts(" -wait [micro seconds]");
puts(" -fine [number]");
puts(" -gradation [number]");
puts(" -direct-draw, -no-direct-draw");
puts(" -probability, -probability-magnification [number]");
puts(" -size, -size-magnification [number]");
puts(" -air, -air-magnification [number]");
puts(" -gravity, -gravity-magnification [number]");
puts(" -transmission, -transmission-magnification [number]");
puts(" -after-image, -after-image-magnification [number]");
puts(" -color-length, -color-length-magnification [number]");
puts(" -next-power, -next-power-magnification [number]");
puts(" -next-number, -next-number-magnification [number]");
putchar(10);
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
printf("%s\n\n", "XFireworks-1.3");
puts("XFireworks Copyright (c) 2000 Sakai Hiroaki.");
puts("All Rights Reserved.\n");
puts("Usage:");
puts(" xfireworks [options]\n");
puts("Options:");
puts(" -h, -help");
puts(" -display [displayname]");
puts(" -bg, -background, -background-color [backgroundcolor]");
puts(" -f, -file [filename]");
puts(" -wait [micro seconds]");
puts(" -fine [number]");
puts(" -gradation [number]");
puts(" -direct-draw, -no-direct-draw");
puts(" -probability, -probability-magnification [number]");
puts(" -size, -size-magnification [number]");
puts(" -air, -air-magnification [number]");
puts(" -gravity, -gravity-magnification [number]");
puts(" -transmission, -transmission-magnification [number]");
puts(" -after-image, -after-image-magnification [number]");
puts(" -color-length, -color-length-magnification [number]");
puts(" -next-power, -next-power-magnification [number]");
puts(" -next-number, -next-number-magnification [number]");
putchar(10);
exit(0);
}

original_code:
void help()
{
  printf("%s\n\n", "XFireworks-1.3");
  printf("XFireworks Copyright (c) 2000 Sakai Hiroaki.\n");
  printf("All Rights Reserved.\n\n");
  printf("Usage:\n");
  printf("        xfireworks [options]\n\n");
  printf("Options:\n");
  printf("        -h, -help\n");
  printf("        -display [displayname]\n");
  printf("        -bg, -background, -background-color [backgroundcolor]\n");
  printf("        -f, -file [filename]\n");
  printf("        -wait [micro seconds]\n");
  printf("        -fine [number]\n");
  printf("        -gradation [number]\n");
  printf("        -direct-draw, -no-direct-draw\n");
  printf("        -probability, -probability-magnification [number]\n");
  printf("        -size, -size-magnification [number]\n");
  printf("        -air, -air-magnification [number]\n");
  printf("        -gravity, -gravity-magnification [number]\n");
  printf("        -transmission, -transmission-magnification [number]\n");
  printf("        -after-image, -after-image-magnification [number]\n");
  printf("        -color-length, -color-length-magnification [number]\n");
  printf("        -next-power, -next-power-magnification [number]\n");
  printf("        -next-number, -next-number-magnification [number]\n");
  printf("\n");
  exit (0);
}


usage

repo: yami/pacfind

decompiled_code:
int usage()
{
return puts(
"Usage: \n"
" Query a binary\n"
" pacfind [-c <config file>] -q <binary_name>\n"
" Update the database\n"
" pacfind [-c <config file>] -u\n"
"\n"
"Default config file is /etc/pacfind.conf");
}

canonical_decompiled_code:
int func0()
{
return puts(
"Usage: \n"
" Query a binary\n"
" pacfind [-c <config file>] -q <binary_name>\n"
" Update the database\n"
" pacfind [-c <config file>] -u\n"
"\n"
"Default config file is /etc/pacfind.conf");
}

original_code:
static void
usage()
{
    printf("Usage: \n"
           "  Query a binary\n"
           "    pacfind [-c <config file>] -q <binary_name>\n"
           "  Update the database\n"
           "    pacfind [-c <config file>] -u\n"
           "\n"
           "Default config file is /etc/pacfind.conf\n"
        );
}


decompiled_code:
_BOOL8 __fastcall are_options_valid(int a1)
{
_BOOL8 result; // rax

if ( (a1 & 0x10) == 0 || (result = 0LL, (a1 & 0xFFFFFFEF) == 0) )
result = (a1 & 5) != 5;
return result;
}

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

if ( (a1 & 0x10) == 0 || (result = 0LL, (a1 & 0xFFFFFFEF) == 0) )
result = (a1 & 5) != 5;
return result;
}

original_code:
int are_options_valid(int options, const char* argument)
{
    if ((options & (1<<4)) && (options & ~(1<<4))) {
        return 0;
    }
    if ((options & (1<<0)) && (options & (1<<2))) {
        return 0;
    }
    return 1;
}

canonical_original_code:
int are_options_valid(int options, char *argument)
{
    if ((options & (1<<4)) && (options & ~(1<<4))) {
        return 0;
    }
    if ((options & (1<<0)) && (options & (1<<2))) {
        return 0;
    }
    return 1;
}

variable_types: options int

variable_types:
argument
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r15
__int64 v4; // r14
int v6; // ebx
__int64 v7; // r13
int v8; // eax
__int64 v9; // rdx
__int64 v10; // rsi
__int64 v11; // rbp
int v12; // eax
int result; // eax
int v14; // [rsp+Ch] [rbp-3Ch]

v3 = 0LL;
v4 = 0LL;
v6 = 0;
v7 = xstrdup(Default_Config_Path, argv, envp);
while ( 2 )
{
v8 = getopt(argc, (char *const *)argv, "uc:q:l:h");
if ( v8 != -1 )
{
switch ( v8 )
{
case 'c':
v6 |= 2u;
v7 = xstrdup(optarg, argv, v9);
continue;
case 'h':
v6 |= 0x10u;
continue;
case 'l':
v6 |= 8u;
v3 = xstrdup(optarg, argv, v9);
continue;
case 'q':
v6 |= 4u;
v4 = xstrdup(optarg, argv, v9);
continue;
case 'u':
v6 |= 1u;
continue;
default:
goto LABEL_17;
}
}
break;
}
v10 = 0LL;
if ( optind < argc )
v10 = xstrdup(argv[optind], 0LL, v9);
if ( are_options_valid(v6) )
{
v11 = read_config_file(v7, v10);
v12 = v6 & 1;
if ( (v6 & 1) != 0 )
v12 = do_update(v11);
if ( (v6 & 4) != 0 )
v12 = do_query(v11, v4);
v14 = v12;
xfree(v7);
xfree(v4);
xfree(v3);
config_delete(v11);
result = v14;
}
else
{
LABEL_17:
usage();
result = 1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r15
__int64 v4; // r14
int v6; // ebx
__int64 v7; // r13
int v8; // eax
__int64 v9; // rdx
__int64 v10; // rsi
__int64 v11; // rbp
int v12; // eax
int result; // eax
int v14; // [rsp+Ch] [rbp-3Ch]

v3 = 0LL;
v4 = 0LL;
v6 = 0;
v7 = xstrdup(Default_Config_Path, argv, envp);
while ( 2 )
{
v8 = getopt(argc, (char *const *)argv, "uc:q:l:h");
if ( v8 != -1 )
{
switch ( v8 )
{
case 'c':
v6 |= 2u;
v7 = xstrdup(optarg, argv, v9);
continue;
case 'h':
v6 |= 0x10u;
continue;
case 'l':
v6 |= 8u;
v3 = xstrdup(optarg, argv, v9);
continue;
case 'q':
v6 |= 4u;
v4 = xstrdup(optarg, argv, v9);
continue;
case 'u':
v6 |= 1u;
continue;
default:
goto LABEL_17;
}
}
break;
}
v10 = 0LL;
if ( optind < argc )
v10 = xstrdup(argv[optind], 0LL, v9);
if ( func1(v6) )
{
v11 = read_config_file(v7, v10);
v12 = v6 & 1;
if ( (v6 & 1) != 0 )
v12 = do_update(v11);
if ( (v6 & 4) != 0 )
v12 = do_query(v11, v4);
v14 = v12;
xfree(v7);
xfree(v4);
xfree(v3);
config_delete(v11);
result = v14;
}
else
{
LABEL_17:
func0();
result = 1;
}
return result;
}

original_code:
int main(int argc, char *argv[])
{
    int opt;
    int options = 0;
    char *config_file = xstrdup(Default_Config_Path);
    char *query_string = ((void *)0);
    char *logging_spec = ((void *)0);
    char *argument = ((void *)0);
    int ret = 0;
    while ( (opt = getopt(argc, argv, "uc:q:l:h")) != -1) {
        switch (opt) {
            case 'u':
                options |= (1<<0);
                break;
            case 'c':
                options |= (1<<1);
                config_file = xstrdup(optarg);
                break;
            case 'q':
                options |= (1<<2);
                query_string = xstrdup(optarg);
                break;
            case 'l':
                options |= (1<<3);
                logging_spec = xstrdup(optarg);
                break;
            case 'h':
                options |= (1<<4);
                break;
            default:
                usage();
                return 1;
        }
    }
    if (optind < argc) {
        argument = xstrdup(argv[optind]);
    }
    if (!are_options_valid(options, argument)) {
        usage();
        return 1;
    }
    struct config *config = read_config_file(config_file);
    if (options & (1<<3)) {
        logging_config(logging_spec);
    }
    if (options & (1<<0)) {
        ret = do_update(config);
    }
    if (options & (1<<2)) {
        ret = do_query(config, query_string);
    }
    xfree(config_file);
    xfree(query_string);
    xfree(logging_spec);
    config_delete(config);
    return ret;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int

variable_types: ret int

variable_types: struct config { char *update_server; char **repositories; char *bindb_dir; char *bindb_file; } *


decompiled_code:
_BOOL8 __fastcall slist_empty(_QWORD *a1)
{
_BOOL8 result; // rax

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

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

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

original_code:
static inline int
slist_empty(struct slist *slist)
{
    return !slist->head && !slist->tail;
}

variable_types: struct slist { struct slist_entry { void *data; struct slist_entry *next; } *head; struct slist_entry *tail; } *

user_defined_types: struct slist { struct slist_entry *head; struct slist_entry *tail; }


decompiled_code:
_BOOL8 __fastcall do_query(__int64 a1, const char *a2)
{
__int64 *v2; // rax
__int64 *v3; // rbp
_BOOL4 v4; // er13
__int64 *i; // rbx
const char **v6; // rax

v2 = (__int64 *)bindb_query(*(_QWORD *)(a1 + 16), *(_QWORD *)(a1 + 24), a2);
if ( !v2 )
{
v4 = 1;
fprintf(stderr, "do_query: failed to query %s\n", a2);
return v4;
}
v3 = v2;
v4 = slist_empty(v2);
if ( !v4 )
{
for ( i = (__int64 *)slist_head_isra_0(*v3); i; i = (__int64 *)slist_entry_next_isra_0(i[1]) )
{
v6 = (const char **)slist_entry_data_isra_0(*i);
printf("%s is found in repository %s as package %s\n", a2, *v6, v6[1]);
}
slist_delete(v3);
return v4;
}
fprintf(stderr, "do_query: %s not found\n", a2);
return 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1, const char *a2)
{
__int64 *v2; // rax
__int64 *v3; // rbp
_BOOL4 v4; // er13
__int64 *i; // rbx
const char **v6; // rax

v2 = (__int64 *)bindb_query(*(_QWORD *)(a1 + 16), *(_QWORD *)(a1 + 24), a2);
if ( !v2 )
{
v4 = 1;
fprintf(stderr, "do_query: failed to query %s\n", a2);
return v4;
}
v3 = v2;
v4 = func0(v2);
if ( !v4 )
{
for ( i = (__int64 *)func3(*v3); i; i = (__int64 *)func2(i[1]) )
{
v6 = (const char **)func1(*i);
printf("%s is found in repository %s as package %s\n", a2, *v6, v6[1]);
}
slist_delete(v3);
return v4;
}
fprintf(stderr, "do_query: %s not found\n", a2);
return 0LL;
}

original_code:
int do_query(struct config *config, const char *bin)
{
    struct slist *qlist = bindb_query(config->bindb_dir, config->bindb_file, bin);
    if (!qlist) {
        fprintf(stderr, "do_query: failed to query %s\n", bin);
        return 1;
    }
    if (slist_empty(qlist)) {
        fprintf(stderr, "do_query: %s not found\n", bin);
        return 0;
    }
    for (struct slist_entry *ent = slist_head(qlist);
         ent;
         ent = slist_entry_next(ent)) {
        struct bindb_qentry *qent = (struct bindb_qentry *) slist_entry_data(ent);
        printf("%s is found in repository %s as package %s\n",
               bin, qent->repository, qent->package);
    }
    slist_delete(qlist);
    return 0;
}

canonical_original_code:
int do_query(struct config *config, char *bin)
{
    struct slist *qlist = bindb_query(config->bindb_dir, config->bindb_file, bin);
    if (!qlist) {
        fprintf(stderr, "do_query: failed to query %s\n", bin);
        return 1;
    }
    if (slist_empty(qlist)) {
        fprintf(stderr, "do_query: %s not found\n", bin);
        return 0;
    }
    for (struct slist_entry *ent = slist_head(qlist);
         ent;
         ent = slist_entry_next(ent)) {
        struct bindb_qentry *qent = (struct bindb_qentry *) slist_entry_data(ent);
        printf("%s is found in repository %s as package %s\n",
               bin, qent->repository, qent->package);
    }
    slist_delete(qlist);
    return 0;
}

variable_types:
bin
char *

variable_types: struct slist_entry { void *data; struct slist_entry *next; } *

variable_types: struct bindb_qentry { char *repository; char *package; } *

user_defined_types: struct config { char *update_server; char **repositories; char *bindb_dir; char *bindb_file; }


original_code:
static char *
ttemp_parse_variable(const char *template, const char ** endp )
{
    const char *t = template;
    const char *vbeg = ((void *)0);
    const char *vend = ((void *)0);
    char *var = ((void *)0);
    int embraced = 0;
    ;
    *endp = ((void *)0);
    t++;
    if (*t == '{') {
        t++;
        embraced = 1;
    }
    for (vbeg = t; *t; t++) {
        if (!((*__ctype_b_loc ())[(int) ((*t))] & (unsigned short int) _ISalnum) && *t != '_') {
            if (embraced && *t != '}') {
                return ((void *)0);
            }
            break;
        }
    }
    vend = t;
    if (vend == vbeg) {
        return ((void *)0);
    }
    var = zmalloc(vend - vbeg + 1);
    memcpy(var, vbeg, vend - vbeg);
    *endp = vend;
    return var;
}

canonical_original_code:
static char *ttemp_parse_variable(char *template, char **endp)
{
    char *t = template;
    char *vbeg = ((void *)0);
    char *vend = ((void *)0);
    char *var = ((void *)0);
    int embraced = 0;
    ;
    *endp = ((void *)0);
    t++;
    if (*t == '{') {
        t++;
        embraced = 1;
    }
    for (vbeg = t; *t; t++) {
        if (!((*__ctype_b_loc ())[(int) ((*t))] & (unsigned short) _ISalnum) && *t != '_') {
            if (embraced && *t != '}') {
                return ((void *)0);
            }
            break;
        }
    }
    vend = t;
    if (vend == vbeg) {
        return ((void *)0);
    }
    var = zmalloc(vend - vbeg + 1);
    memcpy(var, vbeg, vend - vbeg);
    *endp = vend;
    return var;
}

variable_types:
template
char *

variable_types:
endp
char **

variable_types:
t
char *

variable_types:
vbeg
char *

variable_types:
vend
char *

variable_types:
var
char *

variable_types: embraced int

return_type: char *


decompiled_code:
__int64 __fastcall ttemp_nv_lookup(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rbx
__int64 v3; // rdi

v2 = a1;
v3 = *a1;
if ( !v3 )
return 0LL;
while ( !(unsigned int)string_eq(v3, a2) )
{
v3 = v2[2];
v2 += 2;
if ( !v3 )
return 0LL;
}
return v2[1];
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rbx
__int64 v3; // rdi

v2 = a1;
v3 = *a1;
if ( !v3 )
return 0LL;
while ( !(unsigned int)string_eq(v3, a2) )
{
v3 = v2[2];
v2 += 2;
if ( !v3 )
return 0LL;
}
return v2[1];
}

original_code:
static const char *
ttemp_nv_lookup(struct ttemp_nv *nv, const char *name)
{
    while (nv->name) {
        ;
        if (string_eq(nv->name, name)) {
            return nv->value;
        }
        nv++;
    }
    return ((void *)0);
}

canonical_original_code:
static char *ttemp_nv_lookup(struct ttemp_nv *nv, char *name)
{
    while (nv->name) {
        ;
        if (string_eq(nv->name, name)) {
            return nv->value;
        }
        nv++;
    }
    return ((void *)0);
}

variable_types: struct ttemp_nv { char *name; char *value; } *

variable_types:
name
char *


original_code:
const char *
ttemp_fill(const char *template, struct ttemp_nv *nv)
{
    const char *start = template;
    const char *t = template;
    char *filled = zmalloc(1);
    size_t len = 1;
    size_t nadd = 0;
    size_t plen = 0;
    const char *variable;
    const char *value;
    const char *next;
    while (*t) {
        if (*t == '$') {
            variable = ttemp_parse_variable(t, &next);
            if (!variable) {
                goto error;
            }
            value = ttemp_nv_lookup(nv, variable);
            if (!value) {
                goto error;
            }
            plen = t - start;
            nadd = plen + strlen(value);
            filled = xrealloc(filled, nadd + len);
            memcpy(filled + len - 1, start, plen);
            strcpy(filled + len - 1 + plen, value);
            len += nadd;
            t = start = next;
        } else {
            t++;
        }
    }
    nadd = plen = t - start;
    if (nadd) {
        filled = xrealloc(filled, nadd + len);
        memcpy(filled + len - 1, start, plen);
    }
    return filled;
error:
    xfree(filled);
    return ((void *)0);
}

canonical_original_code:
char *ttemp_fill(char *template, struct ttemp_nv *nv)
{
    char *start = template;
    char *t = template;
    char *filled = zmalloc(1);
    unsigned long len = 1;
    unsigned long nadd = 0;
    unsigned long plen = 0;
    char *variable;
    char *value;
    char *next;
    while (*t) {
        if (*t == '$') {
            variable = ttemp_parse_variable(t, &next);
            if (!variable) {
                goto error;
            }
            value = ttemp_nv_lookup(nv, variable);
            if (!value) {
                goto error;
            }
            plen = t - start;
            nadd = plen + strlen(value);
            filled = xrealloc(filled, nadd + len);
            memcpy(filled + len - 1, start, plen);
            strcpy(filled + len - 1 + plen, value);
            len += nadd;
            t = start = next;
        } else {
            t++;
        }
    }
    nadd = plen = t - start;
    if (nadd) {
        filled = xrealloc(filled, nadd + len);
        memcpy(filled + len - 1, start, plen);
    }
    return filled;
error:
    xfree(filled);
    return ((void *)0);
}

variable_types:
start
char *

variable_types:
filled
char *

variable_types:
len
unsigned long

variable_types:
nadd
unsigned long

variable_types:
plen
unsigned long

variable_types:
variable
char *

variable_types:
value
char *

variable_types:
next
char *

user_defined_types: struct ttemp_nv { char *name; char *value; }


xfree

decompiled_code:
// attributes: thunk
void xfree(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func3(void *ptr)
{
free(ptr);
}

original_code:
void
xfree(void *p)
{
    free(p);
}

canonical_original_code:
void xfree(void *p)
{
    free(p);
}

variable_types:
p
void *


decompiled_code:
_BOOL8 __fastcall double_eq(double a1, double a2)
{
return COERCE_DOUBLE(COERCE_UNSIGNED_INT64(a1 - a2) & LC6) < 2.220446049250313e-16;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(double a1, double a2)
{
return COERCE_DOUBLE(COERCE_UNSIGNED_INT64(a1 - a2) & LC6) < 2.220446049250313e-16;
}

variable_types: x double

variable_types: y double


decompiled_code:
_BOOL8 __fastcall string_eq(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int string_eq(const char *x, const char *y)
{
    return strcmp(x, y) == 0;
}

canonical_original_code:
int string_eq(char *x, char *y)
{
    return strcmp(x, y) == 0;
}

variable_types:
x
char *

variable_types:
y
char *


decompiled_code:
char *__fastcall j_status_string(int a1)
{
return J_Status_String[a1];
}

canonical_decompiled_code:
char *__fastcall func0(int a1)
{
return J_Status_String[a1];
}

original_code:
static const char *
j_status_string(j_status_t s)
{
    ;
    return J_Status_String[s];
}

canonical_original_code:
static char *j_status_string(enum j_status s)
{
    ;
    return J_Status_String[s];
}

variable_types: enum j_status { J_OK=0, J_NotFound=1, J_BadType=2, J_EmptyArray=3, J_Max=4 }


decompiled_code:
__int64 config_new()
{
return zmalloc(32LL);
}

canonical_decompiled_code:
__int64 func3()
{
return zmalloc(32LL);
}

original_code:
struct config *
config_new()
{
    return zmalloc(sizeof(struct config));
}

canonical_original_code:
struct config *config_new()
{
    return zmalloc(sizeof(struct config));
}

return_type: struct config { char *update_server; char **repositories; char *bindb_dir; char *bindb_file; } *


decompiled_code:
__int64 __fastcall config_delete(_QWORD *a1)
{
__int64 *v2; // rbp
__int64 v3; // rdi
__int64 result; // rax

if ( a1 )
{
xfree(*a1);
v2 = (__int64 *)a1[1];
if ( v2 )
{
v3 = *v2;
if ( *v2 )
{
do
{
xfree(v3);
v3 = v2[1];
++v2;
}
while ( v3 );
v2 = (__int64 *)a1[1];
}
xfree(v2);
}
xfree(a1[2]);
result = xfree(a1[3]);
}
return result;
}

original_code:
void config_delete(struct config *config)
{
    if (!config)
        return;
    xfree(config->update_server);
    if (config->repositories) {
        for (char **repo = config->repositories; *repo; repo++) {
            xfree(*repo);
        }
        xfree(config->repositories);
    }
    xfree(config->bindb_dir);
    xfree(config->bindb_file);
}

variable_types: struct config { char *update_server; char **repositories; char *bindb_dir; char *bindb_file; } *

variable_types:
repo
char **


decompiled_code:
__int64 __fastcall dcontext_set_string(__int64 *a1, __int64 a2)
{
__int64 result; // rax

xfree(*a1);
result = xstrdup(a2);
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, __int64 a2)
{
__int64 result; // rax

xfree(*a1);
result = xstrdup(a2);
*a1 = result;
return result;
}

original_code:
void
dcontext_set_string(char **dst, const char *src)
{
    xfree(*dst);
    *dst = xstrdup(src);
}

canonical_original_code:
void dcontext_set_string(char **dst, char *src)
{
    xfree(*dst);
    *dst = xstrdup(src);
}

variable_types:
dst
char **

variable_types:
src
char *


decompiled_code:
__int64 __fastcall slist_delete(__int64 *a1)
{
__int64 v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // rbp
__int64 v5; // rax
__int64 v6; // rdi

v2 = slist_head_isra_0(*a1);
if ( v2 )
{
v3 = (_QWORD *)v2;
do
{
v4 = v3;
v5 = slist_entry_next_isra_0(v3[1]);
v6 = *v3;
v3 = (_QWORD *)v5;
xfree(v6);
xfree(v4);
}
while ( v3 );
}
return xfree(a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1)
{
__int64 v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // rbp
__int64 v5; // rax
__int64 v6; // rdi

v2 = func1(*a1);
if ( v2 )
{
v3 = (_QWORD *)v2;
do
{
v4 = v3;
v5 = func0(v3[1]);
v6 = *v3;
v3 = (_QWORD *)v5;
xfree(v6);
xfree(v4);
}
while ( v3 );
}
return xfree(a1);
}

original_code:
void
slist_delete(struct slist *slist)
{
    struct slist_entry *next;
    for (struct slist_entry *ent = slist_head(slist);
         ent;
         ent = next) {
        next = slist_entry_next(ent);
        xfree(ent->data);
        xfree(ent);
    }
    xfree(slist);
}

variable_types: struct slist { struct slist_entry { void *data; struct slist_entry *next; } *head; struct slist_entry *tail; } *


canonical_original_code:
static inline int slist_empty(struct slist *slist)
{
    return !slist->head && !slist->tail;
}

user_defined_types: struct slist_entry { void *data; struct slist_entry *next; }


decompiled_code:
__int64 slist_new()
{
return zmalloc(16LL);
}

canonical_decompiled_code:
__int64 func2()
{
return zmalloc(16LL);
}

original_code:
static inline struct slist *
slist_new()
{
    return zmalloc(sizeof(struct slist));
}

canonical_original_code:
static inline struct slist *slist_new()
{
    return zmalloc(sizeof(struct slist));
}

return_type: struct slist { struct slist_entry { void *data; struct slist_entry *next; } *head; struct slist_entry *tail; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdi

if ( argc != 2 )
{
puts("Please use ./compile filename...");
exit(0);
}
source = fopen(argv[1], "r");
if ( !source )
{
printf(&byte_FF, argv[1]);
exit(1);
}
puts("Press any key to begin lexical ananlyze...");
getchar();
while ( (unsigned int)getToken() )
;
fclose(source);
printf("%d lexical errors!\n", lex_error);
if ( lex_error )
goto LABEL_10;
v3 = argv[1];
lineno = 0;
EOF_Flag = 0;
source = fopen(v3, "r");
if ( !source )
{
printf(&byte_FF, argv[1]);
exit(2);
}
puts("Press any key to begin syntax analyze...");
getchar();
syntaxAnalyze();
printf("%d syntax errors!\n", syntax_error);
fclose(source);
if ( syntax_error )
LABEL_10:
exit(1);
puts("Press any key to generate objective code...");
getchar();
printCode();
puts("Press any key to interpret run the objective code...");
getchar();
InterpretRun();
return 0;
}

original_code:
int main(int argc, char* argv[])
{
    if (argc != 2)
    {
 printf("Please use ./compile filename...\n");
 exit(0);
    }
    source = fopen(argv[1], "r");
    if (source == ((void *)0))
    {
 printf("文件%s打开失败!\n", argv[1]);
 exit(1);
    }
    printf("Press any key to begin lexical ananlyze...\n");
    getchar();
    while (getToken() != ENDFILE)
 ;
    fclose(source);
    printf("%d lexical errors!\n", lex_error);
    if (lex_error != 0)
    {
 exit(1);
    }
    lineno = 0;
    lex_error = 0;
    EOF_Flag = 0;
    source = fopen(argv[1], "r");
    if (source == ((void *)0))
    {
 printf("文件%s打开失败!\n", argv[1]);
 exit(2);
    }
    printf("Press any key to begin syntax analyze...\n");
    getchar();
    syntaxAnalyze();
    printf("%d syntax errors!\n", syntax_error);
    fclose(source);
    if (syntax_error != 0)
    {
 exit(1);
    }
    printf("Press any key to generate objective code...\n");
    getchar();
    printCode();
    printf("Press any key to interpret run the objective code...\n");
    getchar();
    InterpretRun();
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
 printf("Please use ./compile filename...\n");
 exit(0);
    }
    source = fopen(argv[1], "r");
    if (source == ((void *)0))
    {
 printf("文件%s打开失败!\n", argv[1]);
 exit(1);
    }
    printf("Press any key to begin lexical ananlyze...\n");
    getchar();
    while (getToken() != ENDFILE)
 ;
    fclose(source);
    printf("%d lexical errors!\n", lex_error);
    if (lex_error != 0)
    {
 exit(1);
    }
    lineno = 0;
    lex_error = 0;
    EOF_Flag = 0;
    source = fopen(argv[1], "r");
    if (source == ((void *)0))
    {
 printf("文件%s打开失败!\n", argv[1]);
 exit(2);
    }
    printf("Press any key to begin syntax analyze...\n");
    getchar();
    syntaxAnalyze();
    printf("%d syntax errors!\n", syntax_error);
    fclose(source);
    if (syntax_error != 0)
    {
 exit(1);
    }
    printf("Press any key to generate objective code...\n");
    getchar();
    printCode();
    printf("Press any key to interpret run the objective code...\n");
    getchar();
    InterpretRun();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


syntaxError

decompiled_code:
int __fastcall syntaxError(const char *a1)
{
int result; // eax

if ( !a1 )
_assert_fail("message != NULL", "syntax.c", 0x1Fu, "syntaxError");
printf("\n>>>");
result = printf("syntax error at line %d:%s", lineno, a1);
++syntax_error;
return result;
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
int result; // eax

if ( !a1 )
_assert_fail("message != NULL", "syntax.c", 0x1Fu, "syntaxError");
printf("\n>>>");
result = printf("syntax error at line %d:%s", lineno, a1);
++syntax_error;
return result;
}

original_code:
void syntaxError(char* message)
{
    ((void) sizeof ((message != ((void *)0)) ? 1 : 0), __extension__ ({ if (message != ((void *)0)) ; else __assert_fail ("message != NULL", "syntax.c", 31, __extension__ __PRETTY_FUNCTION__); }));
    if (message == ((void *)0))
 return;
    printf("\n>>>");
    printf("syntax error at line %d:%s", lineno, message);
    ++syntax_error;
}

canonical_original_code:
void syntaxError(char *message)
{
    ((void) sizeof ((message != ((void *)0)) ? 1 : 0), __extension__ ({ if (message != ((void *)0)) ; else __assert_fail ("message != NULL", "syntax.c", 31, __extension__ __PRETTY_FUNCTION__); }));
    if (message == ((void *)0))
 return;
    printf("\n>>>");
    printf("syntax error at line %d:%s", lineno, message);
    ++syntax_error;
}

variable_types:
message
char *


match

decompiled_code:
int __fastcall match(int a1)
{
int result; // eax

if ( token == a1 )
{
result = getToken();
token = result;
}
else
{
syntaxError("unexpected token-> ");
printToken((unsigned int)token, &tokenString);
result = putchar(9);
}
return result;
}

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

if ( token == a1 )
{
result = getToken();
token = result;
}
else
{
func0("unexpected token-> ");
printToken((unsigned int)token, &tokenString);
result = putchar(9);
}
return result;
}

original_code:
void match(TokenType expected)
{
    if (token == expected)
    {
 token = getToken();
    }
    else
    {
 syntaxError("unexpected token-> ");
 printToken(token, tokenString);
 printf("	");
    }
}

canonical_original_code:
void match(enum TokenType expected)
{
    if (token == expected)
    {
 token = getToken();
    }
    else
    {
 syntaxError("unexpected token-> ");
 printToken(token, tokenString);
 printf("	");
    }
}

variable_types: enum TokenType { ENDFILE=0, ERROR=1, PROGRAM_K=2, CONST_K=3, VAR_K=4, PROCEDURE_K=5, BEGIN_K=6, END_K=7, IF_K=8, WHILE_K=9, CALL_K=10, DO_K=11, ELSE_K=12, THEN_K=13, WRITE_K=14, ODD_K=15, READ_K=16, NUM=17, ID=18, ASSIGN=19, EQ=20, LT=21, GT=22, PLUS=23, MINUS=24, TIMES=25, OVER=26, LPAREN=27, RPAREN=28, SEMI=29, COMM=30, LTEQ=31, GTEQ=32, NOEQ=33 }


Const

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

result = token;
if ( token )
{
if ( position(&tokenString) )
syntaxError(byte_D3D);
enter(3LL, &tokenString);
match(18);
match(19);
*(_DWORD *)(currentNodePtr + 52LL) = atoi(&tokenString);
result = match(17);
}
return result;
}

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

result = token;
if ( token )
{
if ( position(&tokenString) )
func0(byte_D3D);
enter(3LL, &tokenString);
func1(18);
func1(19);
*(_DWORD *)(currentNodePtr + 52LL) = atoi(&tokenString);
result = func1(17);
}
return result;
}

original_code:
void Const(void)
{
    if (token == ENDFILE)
    {
 return;
    }
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("常量名已经被使用");
    }
    enter(CONSTANT, tokenString);
    match(ID);
    match(ASSIGN);
    currentNodePtr->table.val = atoi(tokenString);
    match(NUM);
}

canonical_original_code:
void Const()
{
    if (token == ENDFILE)
    {
 return;
    }
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("常量名已经被使用");
    }
    enter(CONSTANT, tokenString);
    match(ID);
    match(ASSIGN);
    currentNodePtr->table.val = atoi(tokenString);
    match(NUM);
}


condecl

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

result = token;
if ( token )
{
match(3);
Const();
while ( token == 30 )
{
match(30);
Const();
}
result = match(29);
}
return result;
}

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

result = token;
if ( token )
{
func1(3);
func2();
while ( token == 30 )
{
func1(30);
func2();
}
result = func1(29);
}
return result;
}

original_code:
void condecl(void)
{
    if (token == ENDFILE)
    {
 return;
    }
    match(CONST_K);
    Const();
    while (token == COMM)
    {
 match(COMM);
 Const();
    }
    match(SEMI);
}

canonical_original_code:
void condecl()
{
    if (token == ENDFILE)
    {
 return;
    }
    match(CONST_K);
    Const();
    while (token == COMM)
    {
 match(COMM);
 Const();
    }
    match(SEMI);
}


vardecl

decompiled_code:
int vardecl()
{
int result; // eax
int i; // edi

result = token;
if ( token )
{
for ( i = 4; ; i = 30 )
{
match(i);
if ( position(&tokenString) )
syntaxError(byte_D56);
enter(2LL, &tokenString);
++numVar;
match(18);
if ( token != 30 )
break;
}
result = match(29);
}
return result;
}

canonical_decompiled_code:
int func4()
{
int result; // eax
int i; // edi

result = token;
if ( token )
{
for ( i = 4; ; i = 30 )
{
func1(i);
if ( position(&tokenString) )
func0(byte_D56);
enter(2LL, &tokenString);
++numVar;
func1(18);
if ( token != 30 )
break;
}
result = func1(29);
}
return result;
}

original_code:
void vardecl(void)
{
    if (token == ENDFILE)
    {
 return;
    }
    match(VAR_K);
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("变量名已经被使用");
    }
    enter(VARIABLE, tokenString);
    ++numVar;
    match(ID);
    while (token == COMM)
    {
 match(COMM);
 if (position(tokenString) != ((void *)0))
 {
     syntaxError("变量名已经被使用");
 }
 enter(VARIABLE, tokenString);
 ++numVar;
 match(ID);
    }
    match(SEMI);
}

canonical_original_code:
void vardecl()
{
    if (token == ENDFILE)
    {
 return;
    }
    match(VAR_K);
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("变量名已经被使用");
    }
    enter(VARIABLE, tokenString);
    ++numVar;
    match(ID);
    while (token == COMM)
    {
 match(COMM);
 if (position(tokenString) != ((void *)0))
 {
     syntaxError("变量名已经被使用");
 }
 enter(VARIABLE, tokenString);
 ++numVar;
 match(ID);
    }
    match(SEMI);
}


lop

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

result = token;
if ( token )
{
switch ( token )
{
case 20:
result = match(20);
break;
case 33:
result = match(33);
break;
case 21:
result = match(21);
break;
case 31:
result = match(31);
break;
case 22:
result = match(22);
break;
case 32:
result = match(32);
break;
}
}
return result;
}

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

result = token;
if ( token )
{
switch ( token )
{
case 20:
result = func1(20);
break;
case 33:
result = func1(33);
break;
case 21:
result = func1(21);
break;
case 31:
result = func1(31);
break;
case 22:
result = func1(22);
break;
case 32:
result = func1(32);
break;
}
}
return result;
}

original_code:
void lop(void)
{
    if (token == ENDFILE)
    {
 return;
    }
    if (token == EQ)
    {
 match(EQ);
    }
    else if (token == NOEQ)
    {
 match(NOEQ);
    }
    else if (token == LT)
    {
 match(LT);
    }
    else if (token == LTEQ)
    {
 match(LTEQ);
    }
    else if (token == GT)
    {
 match(GT);
    }
    else if (token == GTEQ)
    {
 match(GTEQ);
    }
}

canonical_original_code:
void lop()
{
    if (token == ENDFILE)
    {
 return;
    }
    if (token == EQ)
    {
 match(EQ);
    }
    else if (token == NOEQ)
    {
 match(NOEQ);
    }
    else if (token == LT)
    {
 match(LT);
    }
    else if (token == LTEQ)
    {
 match(LTEQ);
    }
    else if (token == GT)
    {
 match(GT);
    }
    else if (token == GTEQ)
    {
 match(GTEQ);
    }
}


aop

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

result = token;
if ( token )
{
if ( token == 23 )
{
result = match(23);
}
else if ( token == 24 )
{
result = match(24);
}
}
return result;
}

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

result = token;
if ( token )
{
if ( token == 23 )
{
result = func1(23);
}
else if ( token == 24 )
{
result = func1(24);
}
}
return result;
}

original_code:
void aop(void)
{
    if (token == ENDFILE)
    {
 return;
    }
    if (token == PLUS)
    {
 match(PLUS);
    }
    else if (token == MINUS)
    {
 match(MINUS);
    }
}

canonical_original_code:
void aop()
{
    if (token == ENDFILE)
    {
 return;
    }
    if (token == PLUS)
    {
 match(PLUS);
    }
    else if (token == MINUS)
    {
 match(MINUS);
    }
}


mop

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

result = token;
if ( token )
{
if ( token == 25 )
{
result = match(25);
}
else if ( token == 26 )
{
result = match(26);
}
}
return result;
}

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

result = token;
if ( token )
{
if ( token == 25 )
{
result = func1(25);
}
else if ( token == 26 )
{
result = func1(26);
}
}
return result;
}

original_code:
void mop(void)
{
    if (token == ENDFILE)
    {
 return;
    }
    if (token == TIMES)
    {
 match(TIMES);
    }
    else if (token == OVER)
    {
 match(OVER);
    }
}

canonical_original_code:
void mop()
{
    if (token == ENDFILE)
    {
 return;
    }
    if (token == TIMES)
    {
 match(TIMES);
    }
    else if (token == OVER)
    {
 match(OVER);
    }
}


term

decompiled_code:
__int64 term()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)token;
if ( token )
{
factor();
while ( 1 )
{
v1 = token;
result = (unsigned int)(token - 25);
if ( (unsigned int)result > 1 )
break;
while ( 1 )
{
mop();
factor();
if ( v1 == 25 )
break;
gen(1LL, 0LL, 5LL);
v1 = token;
result = (unsigned int)(token - 25);
if ( (unsigned int)result > 1 )
return result;
}
gen(1LL, 0LL, 4LL);
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)token;
if ( token )
{
func17();
while ( 1 )
{
v1 = token;
result = (unsigned int)(token - 25);
if ( (unsigned int)result > 1 )
break;
while ( 1 )
{
func7();
func17();
if ( v1 == 25 )
break;
gen(1LL, 0LL, 5LL);
v1 = token;
result = (unsigned int)(token - 25);
if ( (unsigned int)result > 1 )
return result;
}
gen(1LL, 0LL, 4LL);
}
}
return result;
}

original_code:
void term(void)
{
    TokenType temp;
    if (token == ENDFILE)
    {
 return;
    }
    factor();
    while (token == TIMES || token == OVER)
    {
 temp = token;
 mop();
 factor();
 if (temp == TIMES)
 {
     gen(OPR, 0, 4);
 }
 else if (temp == OVER)
 {
     gen(OPR, 0, 5);
 }
    }
}

canonical_original_code:
void term()
{
    enum TokenType temp;
    if (token == ENDFILE)
    {
 return;
    }
    factor();
    while (token == TIMES || token == OVER)
    {
 temp = token;
 mop();
 factor();
 if (temp == TIMES)
 {
     gen(OPR, 0, 4);
 }
 else if (temp == OVER)
 {
     gen(OPR, 0, 5);
 }
    }
}

user_defined_types: enum TokenType { ENDFILE=0, ERROR=1, PROGRAM_K=2, CONST_K=3, VAR_K=4, PROCEDURE_K=5, BEGIN_K=6, END_K=7, IF_K=8, WHILE_K=9, CALL_K=10, DO_K=11, ELSE_K=12, THEN_K=13, WRITE_K=14, ODD_K=15, READ_K=16, NUM=17, ID=18, ASSIGN=19, EQ=20, LT=21, GT=22, PLUS=23, MINUS=24, TIMES=25, OVER=26, LPAREN=27, RPAREN=28, SEMI=29, COMM=30, LTEQ=31, GTEQ=32, NOEQ=33 }


Exp

decompiled_code:
__int64 Exp()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)token;
if ( token )
{
if ( token == 23 )
{
match(23);
}
else if ( token == 24 )
{
match(24);
}
term();
while ( 1 )
{
v1 = token;
result = (unsigned int)(token - 23);
if ( (unsigned int)result > 1 )
break;
while ( 1 )
{
aop();
term();
if ( v1 == 23 )
break;
gen(1LL, 0LL, 3LL);
v1 = token;
result = (unsigned int)(token - 23);
if ( (unsigned int)result > 1 )
return result;
}
gen(1LL, 0LL, 2LL);
}
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)token;
if ( token )
{
if ( token == 23 )
{
func1(23);
}
else if ( token == 24 )
{
func1(24);
}
func8();
while ( 1 )
{
v1 = token;
result = (unsigned int)(token - 23);
if ( (unsigned int)result > 1 )
break;
while ( 1 )
{
func6();
func8();
if ( v1 == 23 )
break;
gen(1LL, 0LL, 3LL);
v1 = token;
result = (unsigned int)(token - 23);
if ( (unsigned int)result > 1 )
return result;
}
gen(1LL, 0LL, 2LL);
}
}
return result;
}

original_code:
void Exp(void)
{
    TokenType temp;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == PLUS)
    {
 match(PLUS);
    }
    else if (token == MINUS)
    {
 match(MINUS);
    }
    term();
    while (token == PLUS || token == MINUS)
    {
 temp = token;
 aop();
 term();
 if (temp == PLUS)
 {
     gen(OPR, 0, 2);
 }
 else if (temp == MINUS)
 {
     gen(OPR, 0, 3);
 }
    }
}

canonical_original_code:
void Exp()
{
    enum TokenType temp;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == PLUS)
    {
 match(PLUS);
    }
    else if (token == MINUS)
    {
 match(MINUS);
    }
    term();
    while (token == PLUS || token == MINUS)
    {
 temp = token;
 aop();
 term();
 if (temp == PLUS)
 {
     gen(OPR, 0, 2);
 }
 else if (temp == MINUS)
 {
     gen(OPR, 0, 3);
 }
    }
}


lexp

decompiled_code:
__int64 lexp()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)token;
if ( token )
{
if ( token == 15 )
{
match(15);
Exp();
result = gen(1LL, 0LL, 6LL);
}
else
{
Exp();
v1 = token;
lop();
result = Exp();
switch ( v1 )
{
case 20:
result = gen(1LL, 0LL, 8LL);
break;
case 33:
result = gen(1LL, 0LL, 9LL);
break;
case 21:
result = gen(1LL, 0LL, 10LL);
break;
case 31:
result = gen(1LL, 0LL, 13LL);
break;
case 32:
result = gen(1LL, 0LL, 11LL);
break;
case 22:
result = gen(1LL, 0LL, 12LL);
break;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)token;
if ( token )
{
if ( token == 15 )
{
func1(15);
func9();
result = gen(1LL, 0LL, 6LL);
}
else
{
func9();
v1 = token;
func5();
result = func9();
switch ( v1 )
{
case 20:
result = gen(1LL, 0LL, 8LL);
break;
case 33:
result = gen(1LL, 0LL, 9LL);
break;
case 21:
result = gen(1LL, 0LL, 10LL);
break;
case 31:
result = gen(1LL, 0LL, 13LL);
break;
case 32:
result = gen(1LL, 0LL, 11LL);
break;
case 22:
result = gen(1LL, 0LL, 12LL);
break;
}
}
}
return result;
}

original_code:
void lexp(void)
{
    TokenType temp;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == ODD_K)
    {
 match(ODD_K);
 Exp();
 gen(OPR, 0, 6);
    }
    else
    {
 Exp();
 temp = token;
 lop();
 Exp();
 if (temp == EQ)
 {
     gen(OPR, 0, 8);
 }
 else if (temp == NOEQ)
 {
     gen(OPR, 0, 9);
 }
 else if (temp == LT)
 {
     gen(OPR, 0, 10);
 }
 else if (temp == LTEQ)
 {
     gen(OPR, 0, 13);
 }
 else if (temp == GTEQ)
 {
     gen(OPR, 0, 11);
 }
 else if (temp == GT)
 {
     gen(OPR, 0, 12);
 }
    }
}

canonical_original_code:
void lexp()
{
    enum TokenType temp;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == ODD_K)
    {
 match(ODD_K);
 Exp();
 gen(OPR, 0, 6);
    }
    else
    {
 Exp();
 temp = token;
 lop();
 Exp();
 if (temp == EQ)
 {
     gen(OPR, 0, 8);
 }
 else if (temp == NOEQ)
 {
     gen(OPR, 0, 9);
 }
 else if (temp == LT)
 {
     gen(OPR, 0, 10);
 }
 else if (temp == LTEQ)
 {
     gen(OPR, 0, 13);
 }
 else if (temp == GTEQ)
 {
     gen(OPR, 0, 11);
 }
 else if (temp == GT)
 {
     gen(OPR, 0, 12);
 }
    }
}


statement

decompiled_code:
int statement()
{
__int64 v0; // rax
int v1; // ebx
bool v2; // zf
__int64 v3; // rbx
unsigned int v4; // er12
int v5; // ebx
__int64 v6; // rax
int i; // edi
__int64 v8; // rax

LODWORD(v0) = token;
if ( token )
{
while ( 1 )
{
if ( (_DWORD)v0 == 18 )
{
v3 = position(&tokenString);
match(18);
match(19);
Exp();
LODWORD(v0) = gen(3LL, abs32(*(_DWORD *)(v3 + 48) - level), *(unsigned int *)(v3 + 56));
return v0;
}
if ( (_DWORD)v0 != 8 )
break;
match(8);
lexp();
match(13);
gen(7LL, 0LL, 0LL);
v1 = dword_10D8;
statement();
v2 = token == 12;
v0 = code + 12LL * v1;
*(_DWORD *)(v0 + 8) = dword_10D8 + 1;
if ( v2 )
{
match(12);
LODWORD(v0) = token;
if ( token )
continue;
}
return v0;
}
if ( (_DWORD)v0 == 9 )
{
match(9);
v4 = dword_10D8 + 1;
lexp();
gen(7LL, 0LL, 0LL);
v5 = dword_10D8;
match(11);
statement();
gen(6LL, 0LL, v4);
v0 = code + 12LL * v5;
*(_DWORD *)(v0 + 8) = dword_10D8 + 1;
return v0;
}
if ( (_DWORD)v0 != 10 )
{
switch ( (_DWORD)v0 )
{
case 6:
tag = 1;
LODWORD(v0) = body();
tag = 0;
return v0;
case 0x10:
match(16);
match(27);
gen(1LL, 0LL, 16LL);
v8 = position(&tokenString);
if ( !v8 )
{
syntaxError(byte_D8B);
exit(2);
}
gen(8LL, abs32(*(_DWORD *)(v8 + 48) - level), *(unsigned int *)(v8 + 56));
match(18);
while ( token == 30 )
{
match(30);
match(18);
}
break;
case 0xE:
match(14);
for ( i = 27; ; i = 30 )
{
match(i);
Exp();
gen(9LL, 0LL, 0LL);
gen(1LL, 0LL, 15LL);
if ( token != 30 )
break;
}
break;
default:
syntaxError("unexpected token-> ");
printToken((unsigned int)token, &tokenString);
LODWORD(v0) = getToken();
token = v0;
return v0;
}
LABEL_19:
LODWORD(v0) = match(28);
return v0;
}
match(10);
v6 = position(&tokenString);
if ( !v6 )
{
syntaxError(byte_D6F);
exit(2);
}
gen(4LL, abs32(*(_DWORD *)(v6 + 48) - level), *(unsigned int *)(v6 + 56));
LODWORD(v0) = match(18);
if ( token == 27 )
{
match(27);
Exp();
while ( token == 30 )
{
match(30);
Exp();
}
goto LABEL_19;
}
}
return v0;
}

canonical_decompiled_code:
int func11()
{
__int64 v0; // rax
int v1; // ebx
bool v2; // zf
__int64 v3; // rbx
unsigned int v4; // er12
int v5; // ebx
__int64 v6; // rax
int i; // edi
__int64 v8; // rax

LODWORD(v0) = token;
if ( token )
{
while ( 1 )
{
if ( (_DWORD)v0 == 18 )
{
v3 = position(&tokenString);
func1(18);
func1(19);
func9();
LODWORD(v0) = gen(3LL, abs32(*(_DWORD *)(v3 + 48) - level), *(unsigned int *)(v3 + 56));
return v0;
}
if ( (_DWORD)v0 != 8 )
break;
func1(8);
func10();
func1(13);
gen(7LL, 0LL, 0LL);
v1 = dword_10D8;
func11();
v2 = token == 12;
v0 = code + 12LL * v1;
*(_DWORD *)(v0 + 8) = dword_10D8 + 1;
if ( v2 )
{
func1(12);
LODWORD(v0) = token;
if ( token )
continue;
}
return v0;
}
if ( (_DWORD)v0 == 9 )
{
func1(9);
v4 = dword_10D8 + 1;
func10();
gen(7LL, 0LL, 0LL);
v5 = dword_10D8;
func1(11);
func11();
gen(6LL, 0LL, v4);
v0 = code + 12LL * v5;
*(_DWORD *)(v0 + 8) = dword_10D8 + 1;
return v0;
}
if ( (_DWORD)v0 != 10 )
{
switch ( (_DWORD)v0 )
{
case 6:
tag = 1;
LODWORD(v0) = func12();
tag = 0;
return v0;
case 0x10:
func1(16);
func1(27);
gen(1LL, 0LL, 16LL);
v8 = position(&tokenString);
if ( !v8 )
{
func0(byte_D8B);
exit(2);
}
gen(8LL, abs32(*(_DWORD *)(v8 + 48) - level), *(unsigned int *)(v8 + 56));
func1(18);
while ( token == 30 )
{
func1(30);
func1(18);
}
break;
case 0xE:
func1(14);
for ( i = 27; ; i = 30 )
{
func1(i);
func9();
gen(9LL, 0LL, 0LL);
gen(1LL, 0LL, 15LL);
if ( token != 30 )
break;
}
break;
default:
func0("unexpected token-> ");
printToken((unsigned int)token, &tokenString);
LODWORD(v0) = getToken();
token = v0;
return v0;
}
LABEL_19:
LODWORD(v0) = func1(28);
return v0;
}
func1(10);
v6 = position(&tokenString);
if ( !v6 )
{
func0(byte_D6F);
exit(2);
}
gen(4LL, abs32(*(_DWORD *)(v6 + 48) - level), *(unsigned int *)(v6 + 56));
LODWORD(v0) = func1(18);
if ( token == 27 )
{
func1(27);
func9();
while ( token == 30 )
{
func1(30);
func9();
}
goto LABEL_19;
}
}
return v0;
}

original_code:
void statement(void)
{
    int cx0, cx1;
    struct BSTNode *index;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == ID)
    {
 index = position(tokenString);
 match(ID);
 match(ASSIGN);
 Exp();
 gen(STO, abs(index->table.lev - level), index->table.addr);
    }
    else if (token == IF_K)
    {
 match(IF_K);
 lexp();
 match(THEN_K);
 gen(JPC, 0, 0);
 cx0 = cx;
 statement();
 code[cx0].offset = cx + 1;
 if (token == ELSE_K)
 {
     match(ELSE_K);
     statement();
 }
    }
    else if (token == WHILE_K)
    {
 match(WHILE_K);
 cx1 = cx + 1;
 lexp();
 gen(JPC, 0, 0);
 cx0 = cx;
 match(DO_K);
 statement();
 gen(JMP, 0, cx1);
 code[cx0].offset = cx + 1;
    }
    else if (token == CALL_K)
    {
 match(CALL_K);
 index = position(tokenString);
 if (index == ((void *)0))
 {
     syntaxError("当前过程名没有定义");
     exit(2);
 }
 gen(CAL, abs(index->table.lev - level), index->table.addr);
 match(ID);
 if (token == LPAREN)
 {
     match(LPAREN);
     Exp();
     while (token == COMM)
     {
  match(COMM);
  Exp();
     }
     match(RPAREN);
 }
    }
    else if (token == BEGIN_K)
    {
 tag = 1;
 body();
 tag = 0;
    }
    else if (token == READ_K)
    {
 match(READ_K);
 match(LPAREN);
 gen(OPR, 0, 16);
 index = position(tokenString);
 if (index == ((void *)0))
 {
     syntaxError("当前变量名没有定义");
     exit(2);
 }
 gen(RED, abs(index->table.lev - level), index->table.addr);
 match(ID);
 while (token == COMM)
 {
     match(COMM);
     match(ID);
 }
 match(RPAREN);
    }
    else if (token == WRITE_K)
    {
 match(WRITE_K);
 match(LPAREN);
 Exp();
 gen(WRT, 0, 0);
 gen(OPR, 0, 15);
 while (token == COMM)
 {
     match(COMM);
     Exp();
     gen(WRT, 0, 0);
     gen(OPR, 0, 15);
 }
 match(RPAREN);
    }
    else if (token != ENDFILE)
    {
 syntaxError("unexpected token-> ");
 printToken(token, tokenString);
 token = getToken();
    }
}

canonical_original_code:
void statement()
{
    int cx0; int cx1;
    struct BSTNode *index;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == ID)
    {
 index = position(tokenString);
 match(ID);
 match(ASSIGN);
 Exp();
 gen(STO, abs(index->table.lev - level), index->table.addr);
    }
    else if (token == IF_K)
    {
 match(IF_K);
 lexp();
 match(THEN_K);
 gen(JPC, 0, 0);
 cx0 = cx;
 statement();
 code[cx0].offset = cx + 1;
 if (token == ELSE_K)
 {
     match(ELSE_K);
     statement();
 }
    }
    else if (token == WHILE_K)
    {
 match(WHILE_K);
 cx1 = cx + 1;
 lexp();
 gen(JPC, 0, 0);
 cx0 = cx;
 match(DO_K);
 statement();
 gen(JMP, 0, cx1);
 code[cx0].offset = cx + 1;
    }
    else if (token == CALL_K)
    {
 match(CALL_K);
 index = position(tokenString);
 if (index == ((void *)0))
 {
     syntaxError("当前过程名没有定义");
     exit(2);
 }
 gen(CAL, abs(index->table.lev - level), index->table.addr);
 match(ID);
 if (token == LPAREN)
 {
     match(LPAREN);
     Exp();
     while (token == COMM)
     {
  match(COMM);
  Exp();
     }
     match(RPAREN);
 }
    }
    else if (token == BEGIN_K)
    {
 tag = 1;
 body();
 tag = 0;
    }
    else if (token == READ_K)
    {
 match(READ_K);
 match(LPAREN);
 gen(OPR, 0, 16);
 index = position(tokenString);
 if (index == ((void *)0))
 {
     syntaxError("当前变量名没有定义");
     exit(2);
 }
 gen(RED, abs(index->table.lev - level), index->table.addr);
 match(ID);
 while (token == COMM)
 {
     match(COMM);
     match(ID);
 }
 match(RPAREN);
    }
    else if (token == WRITE_K)
    {
 match(WRITE_K);
 match(LPAREN);
 Exp();
 gen(WRT, 0, 0);
 gen(OPR, 0, 15);
 while (token == COMM)
 {
     match(COMM);
     Exp();
     gen(WRT, 0, 0);
     gen(OPR, 0, 15);
 }
 match(RPAREN);
    }
    else if (token != ENDFILE)
    {
 syntaxError("unexpected token-> ");
 printToken(token, tokenString);
 token = getToken();
    }
}

variable_types: struct BSTNode { struct symbolTable { char name[-1]; enum TypeInSymbolTable { MAINPROCEDURE=0, PROCEDURE=1, VARIABLE=2, CONSTANT=3 } kind; int lev; int val; int addr; int size; } table; int bf; struct BSTNode *lchild; struct BSTNode *rchild; struct BSTNode *next; struct BSTNode *prev; } *

user_defined_types: struct BSTNode { struct symbolTable table; int bf; struct BSTNode *lchild; struct BSTNode *rchild; struct BSTNode *next; struct BSTNode *prev; }

user_defined_types: struct symbolTable { char name[-1]; enum TypeInSymbolTable kind; int lev; int val; int addr; int size; }


body

decompiled_code:
void body()
{
__int64 v0; // rax
__int64 v1; // rdx

if ( token )
{
match(6);
if ( !tag )
{
gen(5LL, 0LL, *(unsigned int *)(currentProcAddr + 60LL));
v0 = currentProcAddr;
*(_DWORD *)(currentProcAddr + 56LL) = dword_10D8;
v1 = *(_QWORD *)(v0 + 88);
if ( v1 )
{
if ( *(_DWORD *)(v0 + 44) )
gen(4LL, abs32(level - *(_DWORD *)(v1 + 48)), *(unsigned int *)(v1 + 56));
}
}
while ( 1 )
{
statement();
if ( token != 29 )
break;
match(29);
}
match(7);
if ( !tag )
{
--level;
gen(1LL, 0LL, 0LL);
}
}
}

canonical_decompiled_code:
void func12()
{
__int64 v0; // rax
__int64 v1; // rdx

if ( token )
{
func1(6);
if ( !tag )
{
gen(5LL, 0LL, *(unsigned int *)(currentProcAddr + 60LL));
v0 = currentProcAddr;
*(_DWORD *)(currentProcAddr + 56LL) = dword_10D8;
v1 = *(_QWORD *)(v0 + 88);
if ( v1 )
{
if ( *(_DWORD *)(v0 + 44) )
gen(4LL, abs32(level - *(_DWORD *)(v1 + 48)), *(unsigned int *)(v1 + 56));
}
}
while ( 1 )
{
func11();
if ( token != 29 )
break;
func1(29);
}
func1(7);
if ( !tag )
{
--level;
gen(1LL, 0LL, 0LL);
}
}
}

original_code:
void body(void)
{
    struct BSTNode * temp;
    if (token == ENDFILE)
    {
 return;
    }
    match(BEGIN_K);
    if (tag == 0)
    {
 gen(INT, 0, currentProcAddr->table.size);
 currentProcAddr->table.addr = cx;
        temp = currentProcAddr->next;
 if (temp != ((void *)0) && currentProcAddr->table.kind != MAINPROCEDURE)
 {
     gen(CAL, abs(level - temp->table.lev), temp->table.addr);
 }
    }
    statement();
    while (token == SEMI)
    {
 match(SEMI);
 statement();
    }
    match(END_K);
    if (tag == 0)
    {
 --level;
    }
    if (tag == 0)
    {
 gen(OPR, 0, 0);
    }
}

canonical_original_code:
void body()
{
    struct BSTNode *temp;
    if (token == ENDFILE)
    {
 return;
    }
    match(BEGIN_K);
    if (tag == 0)
    {
 gen(INT, 0, currentProcAddr->table.size);
 currentProcAddr->table.addr = cx;
        temp = currentProcAddr->next;
 if (temp != ((void *)0) && currentProcAddr->table.kind != MAINPROCEDURE)
 {
     gen(CAL, abs(level - temp->table.lev), temp->table.addr);
 }
    }
    statement();
    while (token == SEMI)
    {
 match(SEMI);
 statement();
    }
    match(END_K);
    if (tag == 0)
    {
 --level;
    }
    if (tag == 0)
    {
 gen(OPR, 0, 0);
    }
}

user_defined_types: enum TypeInSymbolTable { MAINPROCEDURE=0, PROCEDURE=1, VARIABLE=2, CONSTANT=3 }


block

decompiled_code:
__int64 block()
{
__int64 result; // rax
int v1; // ebx
int v2; // esi

gen(6LL, 0LL, 0LL);
result = (unsigned int)token;
if ( !token )
return result;
v1 = dword_10D8;
if ( token == 3 )
{
condecl();
LODWORD(result) = token;
if ( token != 4 )
goto LABEL_4;
LABEL_9:
vardecl();
LODWORD(result) = token;
goto LABEL_4;
}
if ( token == 4 )
goto LABEL_9;
LABEL_4:
v2 = numVar;
numVar = 0;
*(_DWORD *)(currentProcAddr + 60LL) = v2 + 3;
if ( (_DWORD)result == 5 )
{
procNest = 1;
proc();
}
*(_DWORD *)(code + 12LL * v1 + 8) = dword_10D8 + 1;
body();
result = *(_QWORD *)(currentProcAddr + 96LL);
currentProcAddr = result;
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 result; // rax
int v1; // ebx
int v2; // esi

gen(6LL, 0LL, 0LL);
result = (unsigned int)token;
if ( !token )
return result;
v1 = dword_10D8;
if ( token == 3 )
{
func3();
LODWORD(result) = token;
if ( token != 4 )
goto LABEL_4;
LABEL_9:
func4();
LODWORD(result) = token;
goto LABEL_4;
}
if ( token == 4 )
goto LABEL_9;
LABEL_4:
v2 = numVar;
numVar = 0;
*(_DWORD *)(currentProcAddr + 60LL) = v2 + 3;
if ( (_DWORD)result == 5 )
{
procNest = 1;
func16();
}
*(_DWORD *)(code + 12LL * v1 + 8) = dword_10D8 + 1;
func12();
result = *(_QWORD *)(currentProcAddr + 96LL);
currentProcAddr = result;
return result;
}

original_code:
void block(void)
{
    int cx0;
    int tempAddr;
    gen(JMP, 0, 0);
    cx0 = cx;
    if (token == ENDFILE)
 return;
    if (token == CONST_K)
    {
 condecl();
    }
    if (token == VAR_K)
    {
 vardecl();
    }
    currentProcAddr->table.size = numVar + 3;
    numVar = 0;
    if (token == PROCEDURE_K)
    {
 procNest = 1;
 proc();
    }
    code[cx0].offset = cx + 1;
    body();
    currentProcAddr = currentProcAddr->prev;
}

canonical_original_code:
void block()
{
    int cx0;
    int tempAddr;
    gen(JMP, 0, 0);
    cx0 = cx;
    if (token == ENDFILE)
 return;
    if (token == CONST_K)
    {
 condecl();
    }
    if (token == VAR_K)
    {
 vardecl();
    }
    currentProcAddr->table.size = numVar + 3;
    numVar = 0;
    if (token == PROCEDURE_K)
    {
 procNest = 1;
 proc();
    }
    code[cx0].offset = cx + 1;
    body();
    currentProcAddr = currentProcAddr->prev;
}

variable_types: tempAddr int


prog

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

result = getToken();
token = result;
if ( (_DWORD)result )
{
match(2);
if ( position(&tokenString) )
syntaxError(byte_DA7);
enter(0LL, &tokenString);
match(18);
match(29);
result = block();
}
return result;
}

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

result = getToken();
token = result;
if ( (_DWORD)result )
{
func1(2);
if ( position(&tokenString) )
func0(byte_DA7);
enter(0LL, &tokenString);
func1(18);
func1(29);
result = func13();
}
return result;
}

original_code:
void prog(void)
{
    token = getToken();
    if (token == ENDFILE)
    {
 return;
    }
    match(PROGRAM_K);
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("过程名字已经被使用");
    }
    enter(MAINPROCEDURE, tokenString);
    match(ID);
    match(SEMI);
    block();
}

canonical_original_code:
void prog()
{
    token = getToken();
    if (token == ENDFILE)
    {
 return;
    }
    match(PROGRAM_K);
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("过程名字已经被使用");
    }
    enter(MAINPROCEDURE, tokenString);
    match(ID);
    match(SEMI);
    block();
}


syntaxAnalyze

decompiled_code:
// attributes: thunk
__int64 syntaxAnalyze()
{
return prog();
}

canonical_decompiled_code:
__int64 func15()
{
return func14();
}

original_code:
void syntaxAnalyze(void)
{
    prog();
}

canonical_original_code:
void syntaxAnalyze()
{
    prog();
}


proc

decompiled_code:
__int64 proc()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rax
int i; // edi

result = (unsigned int)token;
if ( token )
{
match(5);
if ( position(&tokenString) )
syntaxError(byte_DC3);
++level;
v1 = currentProcAddr;
enter(1LL, &tokenString);
if ( procNest == 1 )
{
v2 = currentProcAddr;
procNest = 0;
*(_QWORD *)(v1 + 88) = currentProcAddr;
*(_QWORD *)(v2 + 96) = v1;
}
match(18);
for ( i = 27; ; i = 30 )
{
match(i);
match(18);
if ( token != 30 )
break;
}
match(28);
match(29);
result = (unsigned int)token;
if ( (unsigned int)(token - 3) <= 3 )
{
block();
result = (unsigned int)token;
}
if ( (_DWORD)result == 29 )
{
do
{
match(29);
result = proc();
}
while ( token == 29 );
}
}
return result;
}

canonical_decompiled_code:
__int64 func16()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rax
int i; // edi

result = (unsigned int)token;
if ( token )
{
func1(5);
if ( position(&tokenString) )
func0(byte_DC3);
++level;
v1 = currentProcAddr;
enter(1LL, &tokenString);
if ( procNest == 1 )
{
v2 = currentProcAddr;
procNest = 0;
*(_QWORD *)(v1 + 88) = currentProcAddr;
*(_QWORD *)(v2 + 96) = v1;
}
func1(18);
for ( i = 27; ; i = 30 )
{
func1(i);
func1(18);
if ( token != 30 )
break;
}
func1(28);
func1(29);
result = (unsigned int)token;
if ( (unsigned int)(token - 3) <= 3 )
{
func13();
result = (unsigned int)token;
}
if ( (_DWORD)result == 29 )
{
do
{
func1(29);
result = func16();
}
while ( token == 29 );
}
}
return result;
}

original_code:
void proc(void)
{
    struct BSTNode * tempAddr;
    if (token == ENDFILE)
    {
 return;
    }
    match(PROCEDURE_K);
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("过程名已经被使用");
    }
    ++level;
    tempAddr = currentProcAddr;
    enter(PROCEDURE, tokenString);
    if (procNest == 1)
    {
 tempAddr->next = currentProcAddr;
 currentProcAddr->prev = tempAddr;
 procNest = 0;
    }
    match(ID);
    match(LPAREN);
    match(ID);
    while (token == COMM)
    {
 match(COMM);
 match(ID);
    }
    match(RPAREN);
    match(SEMI);
    if (token == VAR_K || token == CONST_K ||
       token == PROCEDURE_K || token == BEGIN_K)
    {
 block();
    }
    while (token == SEMI && token != ENDFILE)
    {
 match(SEMI);
 proc();
    }
}

canonical_original_code:
void proc()
{
    struct BSTNode *tempAddr;
    if (token == ENDFILE)
    {
 return;
    }
    match(PROCEDURE_K);
    if (position(tokenString) != ((void *)0))
    {
 syntaxError("过程名已经被使用");
    }
    ++level;
    tempAddr = currentProcAddr;
    enter(PROCEDURE, tokenString);
    if (procNest == 1)
    {
 tempAddr->next = currentProcAddr;
 currentProcAddr->prev = tempAddr;
 procNest = 0;
    }
    match(ID);
    match(LPAREN);
    match(ID);
    while (token == COMM)
    {
 match(COMM);
 match(ID);
    }
    match(RPAREN);
    match(SEMI);
    if (token == VAR_K || token == CONST_K ||
       token == PROCEDURE_K || token == BEGIN_K)
    {
 block();
    }
    while (token == SEMI && token != ENDFILE)
    {
 match(SEMI);
 proc();
    }
}


factor

decompiled_code:
int factor()
{
int result; // eax
unsigned int v1; // eax
_DWORD *v2; // rax
int v3; // edx

result = token;
if ( token )
{
switch ( token )
{
case 18:
v2 = (_DWORD *)position(&tokenString);
if ( !v2 )
{
syntaxError(byte_D8B);
exit(2);
}
v3 = v2[11];
if ( v3 == 3 )
{
gen(0LL, 0LL, (unsigned int)v2[13]);
}
else if ( v3 == 2 )
{
gen(2LL, abs32(v2[12] - level), (unsigned int)v2[14]);
}
result = match(18);
break;
case 17:
v1 = atoi(&tokenString);
gen(0LL, 0LL, v1);
result = match(17);
break;
case 27:
match(27);
Exp();
result = match(28);
break;
}
}
return result;
}

canonical_decompiled_code:
int func17()
{
int result; // eax
unsigned int v1; // eax
_DWORD *v2; // rax
int v3; // edx

result = token;
if ( token )
{
switch ( token )
{
case 18:
v2 = (_DWORD *)position(&tokenString);
if ( !v2 )
{
func0(byte_D8B);
exit(2);
}
v3 = v2[11];
if ( v3 == 3 )
{
gen(0LL, 0LL, (unsigned int)v2[13]);
}
else if ( v3 == 2 )
{
gen(2LL, abs32(v2[12] - level), (unsigned int)v2[14]);
}
result = func1(18);
break;
case 17:
v1 = atoi(&tokenString);
gen(0LL, 0LL, v1);
result = func1(17);
break;
case 27:
func1(27);
func9();
result = func1(28);
break;
}
}
return result;
}

original_code:
void factor(void)
{
    struct BSTNode* index;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == ID)
    {
 index = position(tokenString);
 if (index == ((void *)0))
 {
     syntaxError("当前变量名没有定义");
     exit(2);
 }
 if (index->table.kind == CONSTANT)
 {
     gen(LIT, 0, index->table.val);
 }
 else if (index->table.kind == VARIABLE)
 {
     gen(LOD, abs(index->table.lev - level), index->table.addr);
 }
 match(ID);
    }
    else if (token == NUM)
    {
 gen(LIT, 0, atoi(tokenString));
 match(NUM);
    }
    else if (token == LPAREN)
    {
 match(LPAREN);
 Exp();
 match(RPAREN);
    }
}

canonical_original_code:
void factor()
{
    struct BSTNode *index;
    if (token == ENDFILE)
    {
 return;
    }
    if (token == ID)
    {
 index = position(tokenString);
 if (index == ((void *)0))
 {
     syntaxError("当前变量名没有定义");
     exit(2);
 }
 if (index->table.kind == CONSTANT)
 {
     gen(LIT, 0, index->table.val);
 }
 else if (index->table.kind == VARIABLE)
 {
     gen(LOD, abs(index->table.lev - level), index->table.addr);
 }
 match(ID);
    }
    else if (token == NUM)
    {
 gen(LIT, 0, atoi(tokenString));
 match(NUM);
    }
    else if (token == LPAREN)
    {
 match(LPAREN);
 Exp();
 match(RPAREN);
    }
}


base

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

result = currentProcBase;
if ( a1 > 0 )
{
do
{
result = runStack[result];
--a1;
}
while ( a1 );
}
return result;
}

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

result = currentProcBase;
if ( a1 > 0 )
{
do
{
result = runStack[result];
--a1;
}
while ( a1 );
}
return result;
}

original_code:
int base(int l)
{
    int b1;
    b1 = currentProcBase;
    while (l > 0)
    {
 b1 = runStack[b1];
 l = l -1;
    }
    return b1;
}

variable_types: l int


InterpretRun

decompiled_code:
__int64 InterpretRun()
{
__int64 result; // rax
int v1; // ecx
_DWORD *v2; // rdx
int v3; // eax
__int64 v4; // rdx
int v5; // esi
int v6; // eax
__int64 v7; // rdx
int v8; // er8
int v9; // eax
int v10; // edx
int v11; // eax
int v12; // er8
int v13; // edx
int v14; // edx
__int64 v15; // rax
bool v16; // sf
bool v17; // of
unsigned __int8 v18; // dl
int v19; // edx
int v20; // edx
bool v21; // zf
int v22; // edx
int v23; // edx
int v24; // edx
int v25; // edi
int v26; // eax
int v27; // edx
int v28; // edx
int v29; // edx
unsigned int v30[3]; // [rsp+0h] [rbp-Ch] BYREF

result = (unsigned int)instruction;
v1 = dword_1758;
if ( instruction <= dword_1758 )
{
do
{
v2 = (_DWORD *)(code + 12LL * (int)result);
switch ( *v2 )
{
case 0:
v10 = v2[2];
v9 = ++topOfRunStack;
goto LABEL_9;
case 1:
switch ( v2[2] )
{
case 0:
topOfRunStack = currentProcBase - 1;
result = (unsigned int)(v1 + 1);
if ( pc != v1 )
result = (unsigned int)runStack[currentProcBase + 2];
pc = result;
currentProcBase = runStack[currentProcBase + 1];
goto LABEL_6;
case 1:
runStack[topOfRunStack] = -runStack[topOfRunStack];
result = (unsigned int)++pc;
goto LABEL_6;
case 2:
v29 = runStack[topOfRunStack--];
runStack[topOfRunStack] += v29;
v30[0] = v29;
result = (unsigned int)++pc;
goto LABEL_6;
case 3:
v28 = runStack[topOfRunStack--];
runStack[topOfRunStack] -= v28;
v30[0] = v28;
result = (unsigned int)++pc;
goto LABEL_6;
case 4:
v27 = runStack[topOfRunStack--];
v30[0] = v27;
runStack[topOfRunStack] *= v27;
result = (unsigned int)++pc;
goto LABEL_6;
case 5:
v25 = runStack[topOfRunStack--];
v26 = runStack[topOfRunStack];
v30[0] = v25;
runStack[topOfRunStack] = v26 / v25;
result = (unsigned int)++pc;
goto LABEL_6;
case 6:
runStack[topOfRunStack] = (runStack[topOfRunStack] & 1) == 0;
result = (unsigned int)++pc;
goto LABEL_6;
case 7:
goto LABEL_10;
case 8:
v24 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v21 = runStack[topOfRunStack] == v24;
v30[0] = v24;
v18 = v21;
goto LABEL_24;
case 9:
v23 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v21 = runStack[topOfRunStack] == v23;
v30[0] = v23;
v18 = !v21;
goto LABEL_24;
case 0xA:
v22 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v22, runStack[topOfRunStack]);
v21 = v22 == runStack[topOfRunStack];
v16 = v22 - runStack[topOfRunStack] < 0;
v30[0] = v22;
v18 = !(v16 ^ v17 | v21);
goto LABEL_24;
case 0xB:
v20 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v20, runStack[topOfRunStack]);
v21 = v20 == runStack[topOfRunStack];
v16 = v20 - runStack[topOfRunStack] < 0;
v30[0] = v20;
v18 = v16 ^ v17 | v21;
goto LABEL_24;
case 0xC:
v19 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v19, runStack[topOfRunStack]);
v16 = v19 - runStack[topOfRunStack] < 0;
v30[0] = v19;
v18 = v16 ^ v17;
goto LABEL_24;
case 0xD:
v14 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v14, runStack[topOfRunStack]);
v16 = v14 - runStack[topOfRunStack] < 0;
v30[0] = v14;
v18 = v16 == v17;
LABEL_24:
runStack[v15] = v18;
result = (unsigned int)++pc;
break;
case 0xE:
v13 = runStack[topOfRunStack--];
v30[0] = v13;
printf("Output a number: ");
printf("%d", v30[0]);
v1 = dword_1758;
result = (unsigned int)++pc;
break;
case 0xF:
putchar(10);
v1 = dword_1758;
result = (unsigned int)++pc;
break;
case 0x10:
printf("Please input a number: ");
_isoc99_scanf("%d", v30);
v1 = dword_1758;
runStack[++topOfRunStack] = v30[0];
result = (unsigned int)++pc;
break;
default:
goto LABEL_19;
}
break;
case 2:
v6 = base(v2[1]);
v8 = *(_DWORD *)(v7 + 8) + v6;
v9 = topOfRunStack + 1;
v10 = runStack[v8];
++topOfRunStack;
LABEL_9:
runStack[v9] = v10;
LABEL_10:
result = (unsigned int)++pc;
break;
case 3:
case 8:
v3 = base(v2[1]);
v5 = topOfRunStack;
runStack[*(_DWORD *)(v4 + 8) + v3] = runStack[topOfRunStack];
goto LABEL_4;
case 4:
v11 = topOfRunStack;
v12 = currentProcBase;
currentProcBase = topOfRunStack + 1;
runStack[topOfRunStack + 1] = v12;
runStack[v11 + 2] = v12;
runStack[v11 + 3] = pc + 1;
result = (unsigned int)v2[2];
pc = v2[2];
break;
case 5:
topOfRunStack += v2[2];
result = (unsigned int)++pc;
break;
case 6:
result = (unsigned int)v2[2];
pc = v2[2];
break;
case 7:
v5 = topOfRunStack;
if ( runStack[topOfRunStack] )
LABEL_4:
result = (unsigned int)(pc + 1);
else
result = (unsigned int)v2[2];
pc = result;
topOfRunStack = v5 - 1;
break;
case 9:
printf("Output a number: ");
printf("%d", (unsigned int)runStack[topOfRunStack]);
--topOfRunStack;
v1 = dword_1758;
result = (unsigned int)++pc;
break;
default:
LABEL_19:
result = (unsigned int)pc;
break;
}
LABEL_6:
instruction = result;
}
while ( v1 >= (int)result );
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
int v1; // ecx
_DWORD *v2; // rdx
int v3; // eax
__int64 v4; // rdx
int v5; // esi
int v6; // eax
__int64 v7; // rdx
int v8; // er8
int v9; // eax
int v10; // edx
int v11; // eax
int v12; // er8
int v13; // edx
int v14; // edx
__int64 v15; // rax
bool v16; // sf
bool v17; // of
unsigned __int8 v18; // dl
int v19; // edx
int v20; // edx
bool v21; // zf
int v22; // edx
int v23; // edx
int v24; // edx
int v25; // edi
int v26; // eax
int v27; // edx
int v28; // edx
int v29; // edx
unsigned int v30[3]; // [rsp+0h] [rbp-Ch] BYREF

result = (unsigned int)instruction;
v1 = dword_1758;
if ( instruction <= dword_1758 )
{
do
{
v2 = (_DWORD *)(code + 12LL * (int)result);
switch ( *v2 )
{
case 0:
v10 = v2[2];
v9 = ++topOfRunStack;
goto LABEL_9;
case 1:
switch ( v2[2] )
{
case 0:
topOfRunStack = currentProcBase - 1;
result = (unsigned int)(v1 + 1);
if ( pc != v1 )
result = (unsigned int)runStack[currentProcBase + 2];
pc = result;
currentProcBase = runStack[currentProcBase + 1];
goto LABEL_6;
case 1:
runStack[topOfRunStack] = -runStack[topOfRunStack];
result = (unsigned int)++pc;
goto LABEL_6;
case 2:
v29 = runStack[topOfRunStack--];
runStack[topOfRunStack] += v29;
v30[0] = v29;
result = (unsigned int)++pc;
goto LABEL_6;
case 3:
v28 = runStack[topOfRunStack--];
runStack[topOfRunStack] -= v28;
v30[0] = v28;
result = (unsigned int)++pc;
goto LABEL_6;
case 4:
v27 = runStack[topOfRunStack--];
v30[0] = v27;
runStack[topOfRunStack] *= v27;
result = (unsigned int)++pc;
goto LABEL_6;
case 5:
v25 = runStack[topOfRunStack--];
v26 = runStack[topOfRunStack];
v30[0] = v25;
runStack[topOfRunStack] = v26 / v25;
result = (unsigned int)++pc;
goto LABEL_6;
case 6:
runStack[topOfRunStack] = (runStack[topOfRunStack] & 1) == 0;
result = (unsigned int)++pc;
goto LABEL_6;
case 7:
goto LABEL_10;
case 8:
v24 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v21 = runStack[topOfRunStack] == v24;
v30[0] = v24;
v18 = v21;
goto LABEL_24;
case 9:
v23 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v21 = runStack[topOfRunStack] == v23;
v30[0] = v23;
v18 = !v21;
goto LABEL_24;
case 0xA:
v22 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v22, runStack[topOfRunStack]);
v21 = v22 == runStack[topOfRunStack];
v16 = v22 - runStack[topOfRunStack] < 0;
v30[0] = v22;
v18 = !(v16 ^ v17 | v21);
goto LABEL_24;
case 0xB:
v20 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v20, runStack[topOfRunStack]);
v21 = v20 == runStack[topOfRunStack];
v16 = v20 - runStack[topOfRunStack] < 0;
v30[0] = v20;
v18 = v16 ^ v17 | v21;
goto LABEL_24;
case 0xC:
v19 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v19, runStack[topOfRunStack]);
v16 = v19 - runStack[topOfRunStack] < 0;
v30[0] = v19;
v18 = v16 ^ v17;
goto LABEL_24;
case 0xD:
v14 = runStack[topOfRunStack--];
v15 = topOfRunStack;
v17 = __OFSUB__(v14, runStack[topOfRunStack]);
v16 = v14 - runStack[topOfRunStack] < 0;
v30[0] = v14;
v18 = v16 == v17;
LABEL_24:
runStack[v15] = v18;
result = (unsigned int)++pc;
break;
case 0xE:
v13 = runStack[topOfRunStack--];
v30[0] = v13;
printf("Output a number: ");
printf("%d", v30[0]);
v1 = dword_1758;
result = (unsigned int)++pc;
break;
case 0xF:
putchar(10);
v1 = dword_1758;
result = (unsigned int)++pc;
break;
case 0x10:
printf("Please input a number: ");
_isoc99_scanf("%d", v30);
v1 = dword_1758;
runStack[++topOfRunStack] = v30[0];
result = (unsigned int)++pc;
break;
default:
goto LABEL_19;
}
break;
case 2:
v6 = func0(v2[1]);
v8 = *(_DWORD *)(v7 + 8) + v6;
v9 = topOfRunStack + 1;
v10 = runStack[v8];
++topOfRunStack;
LABEL_9:
runStack[v9] = v10;
LABEL_10:
result = (unsigned int)++pc;
break;
case 3:
case 8:
v3 = func0(v2[1]);
v5 = topOfRunStack;
runStack[*(_DWORD *)(v4 + 8) + v3] = runStack[topOfRunStack];
goto LABEL_4;
case 4:
v11 = topOfRunStack;
v12 = currentProcBase;
currentProcBase = topOfRunStack + 1;
runStack[topOfRunStack + 1] = v12;
runStack[v11 + 2] = v12;
runStack[v11 + 3] = pc + 1;
result = (unsigned int)v2[2];
pc = v2[2];
break;
case 5:
topOfRunStack += v2[2];
result = (unsigned int)++pc;
break;
case 6:
result = (unsigned int)v2[2];
pc = v2[2];
break;
case 7:
v5 = topOfRunStack;
if ( runStack[topOfRunStack] )
LABEL_4:
result = (unsigned int)(pc + 1);
else
result = (unsigned int)v2[2];
pc = result;
topOfRunStack = v5 - 1;
break;
case 9:
printf("Output a number: ");
printf("%d", (unsigned int)runStack[topOfRunStack]);
--topOfRunStack;
v1 = dword_1758;
result = (unsigned int)++pc;
break;
default:
LABEL_19:
result = (unsigned int)pc;
break;
}
LABEL_6:
instruction = result;
}
while ( v1 >= (int)result );
}
return result;
}

original_code:
void InterpretRun()
{
    int temp1, temp2, baseAddr;
    while (instruction <= cx)
    {
 switch (code[instruction].cmd)
 {
 case LIT:
      topOfRunStack = topOfRunStack + 1;
      runStack[topOfRunStack] = code[instruction].offset;
      ++pc;
      break;
 case OPR:
      switch (code[instruction].offset)
      {
      case 0:
           topOfRunStack = currentProcBase - 1;
    if (pc == cx)
        pc = cx + 1;
    else
    {
        pc = runStack[topOfRunStack + 3];
    }
    currentProcBase = runStack[topOfRunStack + 2];
    break;
      case 1:
           runStack[topOfRunStack] = 0 - runStack[topOfRunStack];
    ++pc;
    break;
      case 2:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp1 + temp2;
    ++pc;
    break;
      case 3:
         temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp2 - temp1;
    ++pc;
    break;
      case 4:
         temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp1 * temp2;
    ++pc;
    break;
      case 5:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp2 / temp1;
    ++pc;
    break;
      case 6:
           if(runStack[topOfRunStack] % 2 == 0)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 7:
           ++pc;
    break;
      case 8:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp1 == temp2)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 9:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp1 != temp2)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 10:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 < temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 11:
         temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 >= temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 12:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 > temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 13:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 <= temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 14:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    printf("Output a number: ");
    printf("%d", temp1);
    ++pc;
    break;
      case 15:
         printf("\n");
    ++pc;
    break;
      case 16:
         printf("Please input a number: ");
    scanf("%d", &temp1);
    ++topOfRunStack;
    runStack[topOfRunStack] = temp1;
    ++pc;
    break;
      default:
           break;
      }
      break;
 case LOD:
      baseAddr = base(code[instruction].lev);
      ++topOfRunStack;
      runStack[topOfRunStack] = runStack[baseAddr + code[instruction].offset];
      ++pc;
      break;
 case STO:
      baseAddr = base(code[instruction].lev);
      runStack[baseAddr + code[instruction].offset] = runStack[topOfRunStack];
      ++pc;
      --topOfRunStack;
      break;
 case CAL:
      runStack[topOfRunStack + 1] = currentProcBase;
      runStack[topOfRunStack + 2] = currentProcBase;
      runStack[topOfRunStack + 3] = pc + 1;
      currentProcBase = topOfRunStack + 1;
      pc = code[instruction].offset;
      break;
 case INT:
      topOfRunStack += code[instruction].offset;
      ++pc;
      break;
 case JMP:
      pc = code[instruction].offset;
      break;
 case JPC:
      if (runStack[topOfRunStack] == 0)
      {
   pc = code[instruction].offset;
      }
      else
      {
   ++pc;
      }
      --topOfRunStack;
      break;
 case RED:
      baseAddr = base(code[instruction].lev);
      runStack[baseAddr + code[instruction].offset] = runStack[topOfRunStack];
      ++pc;
      --topOfRunStack;
      break;
 case WRT:
      printf("Output a number: ");
      printf("%d", runStack[topOfRunStack]);
      ++pc;
      --topOfRunStack;
      break;
 default:
      break;
 }
 instruction = pc;
    }
}

canonical_original_code:
void InterpretRun()
{
    int temp1; int temp2; int baseAddr;
    while (instruction <= cx)
    {
 switch (code[instruction].cmd)
 {
 case LIT:
      topOfRunStack = topOfRunStack + 1;
      runStack[topOfRunStack] = code[instruction].offset;
      ++pc;
      break;
 case OPR:
      switch (code[instruction].offset)
      {
      case 0:
           topOfRunStack = currentProcBase - 1;
    if (pc == cx)
        pc = cx + 1;
    else
    {
        pc = runStack[topOfRunStack + 3];
    }
    currentProcBase = runStack[topOfRunStack + 2];
    break;
      case 1:
           runStack[topOfRunStack] = 0 - runStack[topOfRunStack];
    ++pc;
    break;
      case 2:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp1 + temp2;
    ++pc;
    break;
      case 3:
         temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp2 - temp1;
    ++pc;
    break;
      case 4:
         temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp1 * temp2;
    ++pc;
    break;
      case 5:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    runStack[topOfRunStack] = temp2 / temp1;
    ++pc;
    break;
      case 6:
           if(runStack[topOfRunStack] % 2 == 0)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 7:
           ++pc;
    break;
      case 8:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp1 == temp2)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 9:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp1 != temp2)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 10:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 < temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 11:
         temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 >= temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 12:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 > temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 13:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    temp2 = runStack[topOfRunStack];
    if (temp2 <= temp1)
    {
        runStack[topOfRunStack] = 1;
    }
    else
    {
        runStack[topOfRunStack] = 0;
    }
    ++pc;
    break;
      case 14:
           temp1 = runStack[topOfRunStack];
    --topOfRunStack;
    printf("Output a number: ");
    printf("%d", temp1);
    ++pc;
    break;
      case 15:
         printf("\n");
    ++pc;
    break;
      case 16:
         printf("Please input a number: ");
    scanf("%d", &temp1);
    ++topOfRunStack;
    runStack[topOfRunStack] = temp1;
    ++pc;
    break;
      default:
           break;
      }
      break;
 case LOD:
      baseAddr = base(code[instruction].lev);
      ++topOfRunStack;
      runStack[topOfRunStack] = runStack[baseAddr + code[instruction].offset];
      ++pc;
      break;
 case STO:
      baseAddr = base(code[instruction].lev);
      runStack[baseAddr + code[instruction].offset] = runStack[topOfRunStack];
      ++pc;
      --topOfRunStack;
      break;
 case CAL:
      runStack[topOfRunStack + 1] = currentProcBase;
      runStack[topOfRunStack + 2] = currentProcBase;
      runStack[topOfRunStack + 3] = pc + 1;
      currentProcBase = topOfRunStack + 1;
      pc = code[instruction].offset;
      break;
 case INT:
      topOfRunStack += code[instruction].offset;
      ++pc;
      break;
 case JMP:
      pc = code[instruction].offset;
      break;
 case JPC:
      if (runStack[topOfRunStack] == 0)
      {
   pc = code[instruction].offset;
      }
      else
      {
   ++pc;
      }
      --topOfRunStack;
      break;
 case RED:
      baseAddr = base(code[instruction].lev);
      runStack[baseAddr + code[instruction].offset] = runStack[topOfRunStack];
      ++pc;
      --topOfRunStack;
      break;
 case WRT:
      printf("Output a number: ");
      printf("%d", runStack[topOfRunStack]);
      ++pc;
      --topOfRunStack;
      break;
 default:
      break;
 }
 instruction = pc;
    }
}

variable_types: baseAddr int