decompiled_code:
__int64 __fastcall str_list(__int64 *a1)
{
_BYTE *v2; // rdi
__int64 i; // rbx
__int64 v4; // rbp
unsigned int v5; // eax
__int64 v6; // rdx
__int64 v7; // rax

v2 = malloc(2uLL);
*v2 = 0;
v2[1] = 0;
for ( i = *a1; i; i = *(_QWORD *)(i + 32) )
{
v4 = str_ezcat(v2, " ");
v5 = eval(*(_QWORD *)(i + 24));
v7 = str_evaltype(v5, v6);
v2 = (_BYTE *)str_ezcat(v4, v7);
}
*v2 = 91;
return str_ezcat(v2, "]");
}

original_code:
char*
str_list(List* list) {
  char* nstr = malloc(sizeof(char) * 2);
  nstr[0] = '\0';
  nstr[1] = '\0';
  AST* ast = list->head;
  while(ast != ((void *)0)) {
    nstr = str_ezcat(nstr, " ");
    evaltype e = eval(ast->left);
    nstr = str_ezcat(nstr, str_evaltype(e));
    ast = ast->right;
  }
  nstr[0] = '[';
  nstr = str_ezcat(nstr, "]");
  return nstr;
}

canonical_original_code:
char *str_list(struct List *list) {
  char *nstr = malloc(sizeof(char) * 2);
  nstr[0] = '\0';
  nstr[1] = '\0';
  struct ast_ *ast = list->head;
  while(ast != ((void *)0)) {
    nstr = str_ezcat(nstr, " ");
    struct evaltype e = eval(ast->left);
    nstr = str_ezcat(nstr, str_evaltype(e));
    ast = ast->right;
  }
  nstr[0] = '[';
  nstr = str_ezcat(nstr, "]");
  return nstr;
}

variable_types: struct List { struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; } e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *head; } *

variable_types: struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List { struct ast_ *head; } *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; } e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *

variable_types: struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List { struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *head; } *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; }


repo: shoenig/YALL

decompiled_code:
char *__fastcall str_evaltype(unsigned int a1, __int64 *a2)
{
char *v2; // rbp

switch ( a1 )
{
case 1u:
v2 = str_int((__int64)a2);
break;
case 2u:
v2 = str_float(*(double *)&a2);
break;
case 3u:
v2 = str_bool((__int16)a2);
break;
case 4u:
v2 = (char *)str_list(a2);
break;
case 5u:
v2 = (char *)str_ref(a2);
break;
default:
v2 = (char *)malloc(0x80uLL);
sprintf(v2, "strERROR (%d)", a1);
break;
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func5(unsigned int a1, __int64 *a2)
{
char *v2; // rbp

switch ( a1 )
{
case 1u:
v2 = func0((__int64)a2);
break;
case 2u:
v2 = func1(*(double *)&a2);
break;
case 3u:
v2 = func2((__int16)a2);
break;
case 4u:
v2 = (char *)func4(a2);
break;
case 5u:
v2 = (char *)func3(a2);
break;
default:
v2 = (char *)malloc(0x80uLL);
sprintf(v2, "strERROR (%d)", a1);
break;
}
return v2;
}

original_code:
char*
str_evaltype(evaltype e) {
  switch(e.type) {
  case ET_INT: return str_int(e.val.i); break;
  case ET_FLOAT: return str_float(e.val.f); break;
  case ET_BOOL: return str_bool(e.val.bool); break;
  case ET_REFERENCE: return str_ref(e.val.str); break;
  case ET_LIST: return str_list(e.val.list); break;
  default: {
    char* tmp = malloc(sizeof(char) * 128);
    sprintf(tmp, "strERROR (%d)", e.type);
    return tmp;
  }
  }
}

canonical_original_code:
char *str_evaltype(struct evaltype e) {
  switch(e.type) {
  case ET_INT: return str_int(e.val.i); break;
  case ET_FLOAT: return str_float(e.val.f); break;
  case ET_BOOL: return str_bool(e.val.bool); break;
  case ET_REFERENCE: return str_ref(e.val.str); break;
  case ET_LIST: return str_list(e.val.list); break;
  default: {
    char *tmp = malloc(sizeof(char) * 128);
    sprintf(tmp, "strERROR (%d)", e.type);
    return tmp;
  }
  }
}

variable_types:
tmp
char *

return_type: char *

user_defined_types: struct evaltype { enum EVALTYPE type; union { long long i; double f; short bool; struct List *list; char *str; enum bif b; enum cmpf t; enum listf lfunc; } val; }

user_defined_types: enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 }

user_defined_types: enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 }

user_defined_types: enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 }

user_defined_types: enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 }

user_defined_types: struct ast_ { enum ASTTYPE nodetype; struct evaltype e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; }

user_defined_types: enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 }


stlen

decompiled_code:
__int64 __fastcall stlen(_BYTE *a1)
{
_BYTE *v1; // rax
int v2; // edx

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

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
_BYTE *v1; // rax
int v2; // edx

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

original_code:
size_t
stlen(char* str) {
  int len = 0;
  for(;*str!='\0';str++)
    len++;
  return len;
}

canonical_original_code:
unsigned long stlen(char *str) {
  int len = 0;
  for(;*str!='\0';str++)
    len++;
  return len;
}

variable_types:
str
char *

variable_types: len int

return_type: unsigned long


htoi

decompiled_code:
__int64 __fastcall htoi(char *a1)
{
char *v1; // rdx
char v2; // cl
unsigned int v3; // esi
__int64 result; // rax
char v5; // al

v1 = &a1[(unsigned int)stlen(a1) - 1];
if ( a1 > v1 )
{
v3 = 0;
LABEL_13:
result = v3;
}
else
{
v2 = 0;
v3 = 0;
while ( 1 )
{
v5 = *v1;
if ( (*v1 & 0xDF) == 88 )
break;
if ( (unsigned __int8)(v5 - 48) > 9u )
{
if ( (unsigned __int8)(v5 - 97) > 5u )
{
if ( (unsigned __int8)(v5 - 65) <= 5u )
v3 += (v5 - 55) << v2;
}
else
{
v3 += (v5 - 87) << v2;
}
}
else
{
v3 += (v5 - 48) << v2;
}
--v1;
v2 += 4;
if ( a1 > v1 )
goto LABEL_13;
}
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1)
{
char *v1; // rdx
char v2; // cl
unsigned int v3; // esi
__int64 result; // rax
char v5; // al

v1 = &a1[(unsigned int)func0(a1) - 1];
if ( a1 > v1 )
{
v3 = 0;
LABEL_13:
result = v3;
}
else
{
v2 = 0;
v3 = 0;
while ( 1 )
{
v5 = *v1;
if ( (*v1 & 0xDF) == 88 )
break;
if ( (unsigned __int8)(v5 - 48) > 9u )
{
if ( (unsigned __int8)(v5 - 97) > 5u )
{
if ( (unsigned __int8)(v5 - 65) <= 5u )
v3 += (v5 - 55) << v2;
}
else
{
v3 += (v5 - 87) << v2;
}
}
else
{
v3 += (v5 - 48) << v2;
}
--v1;
v2 += 4;
if ( a1 > v1 )
goto LABEL_13;
}
result = v3;
}
return result;
}

original_code:
int
htoi(char* hex) {
  unsigned int slen = stlen(hex);
  unsigned int val = 0;
  unsigned int multi = 0;
  char* c;
  for(c = hex+slen-1;c>=hex; c--, multi++) {
    unsigned int pow = 1 << (4*multi);
    if(*c=='x' || *c=='X')
      return val;
    else if((*c>='0') && (*c<='9'))
      val += (*c-'0') * pow;
    else if((*c>='a') && (*c<='f'))
      val += ((*c-'a')+10) * pow;
    else if((*c>='A') && (*c<='F'))
      val += ((*c-'A')+10) * pow;
  }
  return val;
}

canonical_original_code:
int htoi(char *hex) {
  unsigned int slen = stlen(hex);
  unsigned int val = 0;
  unsigned int multi = 0;
  char *c;
  for(c = hex+slen-1;c>=hex; c--, multi++) {
    unsigned int pow = 1 << (4*multi);
    if(*c=='x' || *c=='X')
      return val;
    else if((*c>='0') && (*c<='9'))
      val += (*c-'0') * pow;
    else if((*c>='a') && (*c<='f'))
      val += ((*c-'a')+10) * pow;
    else if((*c>='A') && (*c<='F'))
      val += ((*c-'A')+10) * pow;
  }
  return val;
}

variable_types:
hex
char *

variable_types:
slen
unsigned int

variable_types:
val
unsigned int

variable_types:
multi
unsigned int

variable_types:
c
char *

variable_types:
pow
unsigned int

return_type: int


yyerror

decompiled_code:
int yyerror(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fwrite("error: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
return fputc(10, stderr);
}

canonical_decompiled_code:
int func0(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fwrite("error: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
return fputc(10, stderr);
}

original_code:
void
yyerror(char* s, ...) {
  va_list ap;
  __builtin_va_start(ap,s);
  fprintf(stderr, "error: ");
  vfprintf(stderr, s, ap);
  fprintf(stderr, "\n");
}

canonical_original_code:
void yyerror(char *s, ...) {
  __builtin_va_list ap;
  __builtin_va_start(ap,s);
  fprintf(stderr, "error: ");
  vfprintf(stderr, s, ap);
  fprintf(stderr, "\n");
}

variable_types:
s
char *

return_type: void


crash

decompiled_code:
void __noreturn crash(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
fwrite("FATAL ERROR: ", 1uLL, 0xDuLL, stderr);
vfprintf(stderr, a1, arg);
fputc(10, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func1(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
fwrite("FATAL ERROR: ", 1uLL, 0xDuLL, stderr);
vfprintf(stderr, a1, arg);
fputc(10, stderr);
exit(1);
}

original_code:
void
crash(char* s, ...) {
  va_list ap;
  __builtin_va_start(ap,s);
  fprintf(stderr, "FATAL ERROR: ");
  vfprintf(stderr, s, ap);
  fprintf(stderr, "\n");
  exit(1);
}

canonical_original_code:
void crash(char *s, ...) {
  __builtin_va_list ap;
  __builtin_va_start(ap,s);
  fprintf(stderr, "FATAL ERROR: ");
  vfprintf(stderr, s, ap);
  fprintf(stderr, "\n");
  exit(1);
}


yasrt

decompiled_code:
int yasrt(__int16 a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( !a1 )
{
va_start(arg, a2);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, a2, arg);
result = fputc(10, stderr);
if ( !reading_stdin )
exit(1);
}
return result;
}

canonical_decompiled_code:
int func2(__int16 a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( !a1 )
{
va_start(arg, a2);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, a2, arg);
result = fputc(10, stderr);
if ( !reading_stdin )
exit(1);
}
return result;
}

original_code:
void
yasrt(bool b, char* s, ...) {
  if(!b) {
    va_list ap;
    __builtin_va_start(ap,s);
    fprintf(stderr, "ERROR: ");
    vfprintf(stderr, s, ap);
    fprintf(stderr, "\n");
    if(!reading_stdin)
      exit(1);
  }
}

canonical_original_code:
void yasrt(short b, char *s, ...) {
  if(!b) {
    __builtin_va_list ap;
    __builtin_va_start(ap,s);
    fprintf(stderr, "ERROR: ");
    vfprintf(stderr, s, ap);
    fprintf(stderr, "\n");
    if(!reading_stdin)
      exit(1);
  }
}

variable_types: b short


decompiled_code:
__int64 __fastcall list_dup(unsigned int **a1)
{
_QWORD *v1; // rbx

v1 = malloc(8uLL);
*v1 = list_dup_elem(*a1);
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int **a1)
{
_QWORD *v1; // rbx

v1 = malloc(8uLL);
*v1 = func0(*a1);
return 4LL;
}

original_code:
evaltype
list_dup(List* orig) {
  evaltype ret;
  ret.type = ET_LIST;
  ret.val.list = malloc(sizeof(List));
  ret.val.list->head = _list_dup_elem(orig->head);
  return ret;
}

canonical_original_code:
struct evaltype list_dup(struct List *orig) {
  struct evaltype ret;
  ret.type = ET_LIST;
  ret.val.list = malloc(sizeof(List));
  ret.val.list->head = _list_dup_elem(orig->head);
  return ret;
}

variable_types:
orig
struct List *

return_type: struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List { struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *head; } *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; }


decompiled_code:
__int64 __fastcall list_length(__int64 *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = 0;
do
{
++v2;
v1 = *(_QWORD *)(v1 + 32);
}
while ( v1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = 0;
do
{
++v2;
v1 = *(_QWORD *)(v1 + 32);
}
while ( v1 );
return v2;
}

original_code:
int
list_length(List* list) {
  int size = 0;
  AST* elem_ptr = list->head;
  while(elem_ptr) {
    size++;
    elem_ptr = elem_ptr->right;
  }
  return size;
}

canonical_original_code:
int list_length(struct List *list) {
  int size = 0;
  struct ast_ *elem_ptr = list->head;
  while(elem_ptr) {
    size++;
    elem_ptr = elem_ptr->right;
  }
  return size;
}

variable_types: size int


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

for ( result = 0LL; result != 997; ++result )
table[result] = 0LL;
return result;
}

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

for ( result = 0LL; result != 997; ++result )
table[result] = 0LL;
return result;
}

original_code:
void
smt_init() {
  size_t idx = 0;
  while(idx < 997) {
    table[idx] = ((void *)0);
    idx++;
  }
}

canonical_original_code:
void smt_init() {
  unsigned long idx = 0;
  while(idx < 997) {
    table[idx] = ((void *)0);
    idx++;
  }
}

variable_types:
idx
unsigned long


decompiled_code:
__int64 __fastcall smt_lookup(char *s1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = 0LL;
while ( 1 )
{
v2 = table[v1];
if ( v2 )
{
if ( !strcmp(s1, *(const char **)v2) )
break;
}
if ( ++v1 == 997 )
return 0LL;
}
do
{
result = v2;
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
return result;
}

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

v1 = 0LL;
while ( 1 )
{
v2 = table[v1];
if ( v2 )
{
if ( !strcmp(s1, *(const char **)v2) )
break;
}
if ( ++v1 == 997 )
return 0LL;
}
do
{
result = v2;
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
return result;
}

original_code:
Symbol*
smt_lookup(char* name) {
  size_t idx = 0;
  while(idx < 997) {
    if(table[idx] && strcmp(name, table[idx]->name) == 0) {
      Symbol* sym = table[idx];
      while(sym->next)
        sym = sym->next;
      return sym;
    }
    idx++;
  }
  return ((void *)0);
}

canonical_original_code:
struct sym_ *smt_lookup(char *name) {
  unsigned long idx = 0;
  while(idx < 997) {
    if(table[idx] && strcmp(name, table[idx]->name) == 0) {
      struct sym_ *sym = table[idx];
      while(sym->next)
        sym = sym->next;
      return sym;
    }
    idx++;
  }
  return ((void *)0);
}

variable_types:
name
char *

variable_types: struct sym_ { char *name; struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List { struct ast_ *head; } *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; } e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *ast; short isFunc; struct sym_ *next; } *

user_defined_types: struct sym_ { char *name; struct ast_ *ast; short isFunc; struct sym_ *next; }


decompiled_code:
__int64 __fastcall smt_create_symbol(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
_QWORD *v4; // rbp

v2 = 0LL;
while ( table[v2] )
{
if ( ++v2 == 997 )
return crash("Out of symbol table space");
}
v4 = malloc(0x30uLL);
table[v2] = (__int64)v4;
*v4 = a1;
v4[1] = dup_ast(a2);
result = table[v2];
*(_QWORD *)(result + 24) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
_QWORD *v4; // rbp

v2 = 0LL;
while ( table[v2] )
{
if ( ++v2 == 997 )
return crash("Out of symbol table space");
}
v4 = malloc(0x30uLL);
table[v2] = (__int64)v4;
*v4 = a1;
v4[1] = dup_ast(a2);
result = table[v2];
*(_QWORD *)(result + 24) = 0LL;
return result;
}

original_code:
void
smt_create_symbol(char* name, AST* ast) {
  size_t idx = 0;
  while(idx < 997) {
    if(table[idx] == ((void *)0)) {
      table[idx] = malloc(sizeof(AST));
      table[idx]->name = name;
      table[idx]->ast = dup_ast(ast);
      table[idx]->next = ((void *)0);
      return;
    }
    idx++;
  }
  crash("Out of symbol table space");
}

canonical_original_code:
void smt_create_symbol(char *name, struct ast_ *ast) {
  unsigned long idx = 0;
  while(idx < 997) {
    if(table[idx] == ((void *)0)) {
      table[idx] = malloc(sizeof(AST));
      table[idx]->name = name;
      table[idx]->ast = dup_ast(ast);
      table[idx]->next = ((void *)0);
      return;
    }
    idx++;
  }
  crash("Out of symbol table space");
}

variable_types: struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List { struct ast_ *head; } *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; } e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *


decompiled_code:
__int64 __fastcall smt_with_exit(char *s1)
{
__int64 v1; // rbx
const char **v2; // r12
const char **i; // rax
__int64 result; // rax
const char **v5; // rbp

v1 = 0LL;
while ( 1 )
{
v5 = (const char **)table[v1];
if ( v5 )
{
if ( !strcmp(s1, *v5) )
break;
}
if ( ++v1 == 997 )
{
crash("cannot delete non-existent symbol: %s", s1);
return 0LL;
}
}
v2 = v5;
for ( i = v5; i[3]; i = (const char **)i[3] )
v2 = i;
if ( i == v2 )
{
free(v5);
table[v1] = 0LL;
result = 1LL;
}
else
{
free((void *)v2[3]);
v2[3] = 0LL;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s1)
{
__int64 v1; // rbx
const char **v2; // r12
const char **i; // rax
__int64 result; // rax
const char **v5; // rbp

v1 = 0LL;
while ( 1 )
{
v5 = (const char **)table[v1];
if ( v5 )
{
if ( !strcmp(s1, *v5) )
break;
}
if ( ++v1 == 997 )
{
crash("cannot delete non-existent symbol: %s", s1);
return 0LL;
}
}
v2 = v5;
for ( i = v5; i[3]; i = (const char **)i[3] )
v2 = i;
if ( i == v2 )
{
free(v5);
table[v1] = 0LL;
result = 1LL;
}
else
{
free((void *)v2[3]);
v2[3] = 0LL;
result = 0LL;
}
return result;
}

original_code:
bool
smt_with_exit(char* name) {
  size_t idx = 0;
  while(idx < 997) {
    if(table[idx] && strcmp(name, table[idx]->name) == 0) {
      Symbol* current = table[idx];
      Symbol* trailer = table[idx];
      while(current->next != ((void *)0)) {
        trailer = current;
        current = current->next;
      }
      if(current == trailer) {
        free(table[idx]);
        table[idx] = ((void *)0);
        return 1;
      }
      else {
        free(trailer->next);
        trailer->next = ((void *)0);
        return 0;
      }
    }
    idx++;
  }
  crash("cannot delete non-existent symbol: %s", name);
  return 0;
}

canonical_original_code:
short smt_with_exit(char *name) {
  unsigned long idx = 0;
  while(idx < 997) {
    if(table[idx] && strcmp(name, table[idx]->name) == 0) {
      struct sym_ *current = table[idx];
      struct sym_ *trailer = table[idx];
      while(current->next != ((void *)0)) {
        trailer = current;
        current = current->next;
      }
      if(current == trailer) {
        free(table[idx]);
        table[idx] = ((void *)0);
        return 1;
      }
      else {
        free(trailer->next);
        trailer->next = ((void *)0);
        return 0;
      }
    }
    idx++;
  }
  crash("cannot delete non-existent symbol: %s", name);
  return 0;
}

return_type: short


decompiled_code:
__int64 __fastcall smt_put(char *a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbx
__int64 result; // rax

v2 = smt_lookup(a1);
if ( !v2 )
return smt_create_symbol((__int64)a1, a2);
v3 = v2;
result = dup_ast(a2);
*(_QWORD *)(v3 + 8) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbx
__int64 result; // rax

v2 = func1(a1);
if ( !v2 )
return func2((__int64)a1, a2);
v3 = v2;
result = dup_ast(a2);
*(_QWORD *)(v3 + 8) = result;
return result;
}

original_code:
void
smt_put(char* name, AST* ast) {
  Symbol* sym = smt_lookup(name);
  if(!sym)
    smt_create_symbol(name, ast);
  else
    sym->ast = dup_ast(ast);
}

canonical_original_code:
void smt_put(char *name, struct ast_ *ast) {
  struct sym_ *sym = smt_lookup(name);
  if(!sym)
    smt_create_symbol(name, ast);
  else
    sym->ast = dup_ast(ast);
}


decompiled_code:
__int64 __fastcall smt_del(char *s1)
{
__int64 result; // rax

while ( 1 )
{
result = smt_lookup(s1);
if ( !result )
break;
smt_with_exit(s1);
}
return result;
}

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

while ( 1 )
{
result = func1(s1);
if ( !result )
break;
func4(s1);
}
return result;
}

original_code:
void
smt_del(char* name) {
  while(smt_lookup(name))
    smt_with_exit(name);
}

canonical_original_code:
void smt_del(char *name) {
  while(smt_lookup(name))
    smt_with_exit(name);
}


etdec

decompiled_code:
const char *__fastcall etdec(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 1:
result = "INT";
break;
case 2:
result = "FLOAT";
break;
case 3:
result = "BOOL";
break;
case 4:
result = "LIST";
break;
case 5:
result = "REF";
break;
default:
result = "INVALID";
break;
}
return result;
}

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

switch ( a1 )
{
case 1:
result = "INT";
break;
case 2:
result = "FLOAT";
break;
case 3:
result = "BOOL";
break;
case 4:
result = "LIST";
break;
case 5:
result = "REF";
break;
default:
result = "INVALID";
break;
}
return result;
}

original_code:
const char*
etdec(evaltype e) {
  switch(e.type) {
  case ET_INT: return "INT";
  case ET_FLOAT: return "FLOAT";
  case ET_BOOL: return "BOOL";
  case ET_LIST: return "LIST";
  case ET_REFERENCE: return "REF";
  case ET_INVALID:
  default:
    return "INVALID";
  }
}

canonical_original_code:
char *etdec(struct evaltype e) {
  switch(e.type) {
  case ET_INT: return "INT";
  case ET_FLOAT: return "FLOAT";
  case ET_BOOL: return "BOOL";
  case ET_LIST: return "LIST";
  case ET_REFERENCE: return "REF";
  case ET_INVALID:
  default:
    return "INVALID";
  }
}

variable_types: struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List { struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *head; } *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; }


astdec

decompiled_code:
const char *__fastcall astdec(_DWORD *a1)
{
const char *result; // rax

switch ( *a1 )
{
case 0xB:
result = "INT";
break;
case 0xC:
result = "FLOAT";
break;
case 0xD:
result = "ARITH-NEGATE";
break;
case 0xE:
result = "BOOL";
break;
case 0xF:
result = "LIST";
break;
case 0x10:
result = "LIST-ELEM";
break;
case 0x11:
result = "REF";
break;
case 0x12:
result = "LIST-FUNC";
break;
case 0x13:
result = "BUILTIN-FUNC";
break;
case 0x14:
result = "BOOLEAN-FUNC";
break;
case 0x16:
result = "&";
break;
case 0x17:
result = (const char *)L"|=+-*/";
break;
case 0x18:
result = (const char *)L"=+-*/";
break;
case 0x19:
result = (const char *)L"+-*/";
break;
case 0x1A:
result = (const char *)L"-*/";
break;
case 0x1B:
result = (const char *)L"*/";
break;
case 0x1C:
result = (const char *)L"/";
break;
default:
result = "INVALID";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(_DWORD *a1)
{
const char *result; // rax

switch ( *a1 )
{
case 0xB:
result = "INT";
break;
case 0xC:
result = "FLOAT";
break;
case 0xD:
result = "ARITH-NEGATE";
break;
case 0xE:
result = "BOOL";
break;
case 0xF:
result = "LIST";
break;
case 0x10:
result = "LIST-ELEM";
break;
case 0x11:
result = "REF";
break;
case 0x12:
result = "LIST-FUNC";
break;
case 0x13:
result = "BUILTIN-FUNC";
break;
case 0x14:
result = "BOOLEAN-FUNC";
break;
case 0x16:
result = "&";
break;
case 0x17:
result = (const char *)L"|=+-*/";
break;
case 0x18:
result = (const char *)L"=+-*/";
break;
case 0x19:
result = (const char *)L"+-*/";
break;
case 0x1A:
result = (const char *)L"-*/";
break;
case 0x1B:
result = (const char *)L"*/";
break;
case 0x1C:
result = (const char *)L"/";
break;
default:
result = "INVALID";
break;
}
return result;
}

original_code:
const char*
astdec(AST* ast) {
  switch(ast->nodetype) {
  case AST_INT: return "INT";
  case AST_FLOAT: return "FLOAT";
  case AST_MINUS: return "ARITH-NEGATE";
  case AST_BOOL: return "BOOL";
  case AST_LIST: return "LIST";
  case AST_LIST_ELEMENT: return "LIST-ELEM";
  case AST_REFERENCE: return "REF";
  case AST_LIST_FUNC: return "LIST-FUNC";
  case AST_BUILTIN_FUNC: return "BUILTIN-FUNC";
  case AST_BOOLEAN_FUNC: return "BOOLEAN-FUNC";
  case AST_AMPER: return "&";
  case AST_PIPE: return "|";
  case AST_EQ: return "=";
  case AST_PLUS: return "+";
  case AST_SUB: return "-";
  case AST_MULT: return "*";
  case AST_DIV: return "/";
  case AST_INVALID:
  default:
    return "INVALID";
  }
}

canonical_original_code:
char *astdec(struct ast_ *ast) {
  switch(ast->nodetype) {
  case AST_INT: return "INT";
  case AST_FLOAT: return "FLOAT";
  case AST_MINUS: return "ARITH-NEGATE";
  case AST_BOOL: return "BOOL";
  case AST_LIST: return "LIST";
  case AST_LIST_ELEMENT: return "LIST-ELEM";
  case AST_REFERENCE: return "REF";
  case AST_LIST_FUNC: return "LIST-FUNC";
  case AST_BUILTIN_FUNC: return "BUILTIN-FUNC";
  case AST_BOOLEAN_FUNC: return "BOOLEAN-FUNC";
  case AST_AMPER: return "&";
  case AST_PIPE: return "|";
  case AST_EQ: return "=";
  case AST_PLUS: return "+";
  case AST_SUB: return "-";
  case AST_MULT: return "*";
  case AST_DIV: return "/";
  case AST_INVALID:
  default:
    return "INVALID";
  }
}


original_code:
void
delete_user_func(UserFunc* uf) {
  int i;
  for(i=0; i<uf->argc; i++)
    free(uf->args[i]);
  free(uf->args);
  free(uf->func_name);
  free(uf->func_body);
}

canonical_original_code:
void delete_user_func(struct UserFunc *uf) {
  int i;
  for(i=0; i<uf->argc; i++)
    free(uf->args[i]);
  free(uf->args);
  free(uf->func_name);
  free(uf->func_body);
}

variable_types: struct UserFunc { int argc; char **args; char *func_name; struct ast_ { enum ASTTYPE { AST_INVALID=10, AST_INT=11, AST_FLOAT=12, AST_MINUS=13, AST_BOOL=14, AST_LIST=15, AST_LIST_ELEMENT=16, AST_REFERENCE=17, AST_LIST_FUNC=18, AST_BUILTIN_FUNC=19, AST_BOOLEAN_FUNC=20, AST_CALL_USERFUNC=21, AST_AMPER=22, AST_PIPE=23, AST_EQ=24, AST_PLUS=25, AST_SUB=26, AST_MULT=27, AST_DIV=28 } nodetype; struct evaltype { enum EVALTYPE { ET_INVALID=0, ET_INT=1, ET_FLOAT=2, ET_BOOL=3, ET_LIST=4, ET_REFERENCE=5 } type; union { long long i; double f; short bool; struct List { struct ast_ *head; } *list; char *str; enum bif { B_sqrt=40, B_abs=41, B_log=42, B_log2=43, B_log10=44, B_float=45, B_int=46, B_pow=47, B_fact=48, B_negate=49, B_floor=50, B_ceil=51, B_defint=52, B_deffloat=53, B_defbool=54, B_deflist=55, B_if=56, B_with=57, B_ufunc=58, B_defufunc=59 } b; enum cmpf { T_greater_than=70, T_less_than=71, T_not_equal=72, T_equal=73, T_greater_than_equal=74, T_less_than_equal=75, T_and=76, T_or=77 } t; enum listf { L_empty=80, L_len=81, L_peek=82, L_copy=83, L_pop=84, L_push=85 } lfunc; } val; } e; struct ast_ *left; struct ast_ *right; struct ast_ *aux; } *func_body; } *

variable_types: i int

user_defined_types: struct UserFunc { int argc; char **args; char *func_name; struct ast_ *func_body; }