decompiled_code:
void *memory_init()
{
void *result; // rax

the_cons_cells = (__int64)malloc(0x800000uLL);
if ( !the_cons_cells )
{
puts("Error: malloc error. -- INITIAL.");
exit(-1);
}
result = malloc(0x800000uLL);
free_cons_cells = (__int64)result;
if ( !result )
{
puts("Error: malloc error. -- INITIAL.");
exit(-1);
}
return result;
}

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

the_cons_cells = (__int64)malloc(0x800000uLL);
if ( !the_cons_cells )
{
puts("Error: malloc error. -- INITIAL.");
exit(-1);
}
result = malloc(0x800000uLL);
free_cons_cells = (__int64)result;
if ( !result )
{
puts("Error: malloc error. -- INITIAL.");
exit(-1);
}
return result;
}

original_code:
void memory_init(void)
{
    the_cons_cells = (struct cons_cell *)malloc(sizeof(struct cons_cell) * 0x100000);
 if (the_cons_cells == ((void *)0)){
  printf("Error: malloc error. -- INITIAL.\n");
  exit(-1);
 }
 free_cons_cells = (struct cons_cell *)malloc(sizeof(struct cons_cell) * 0x100000);
 if (free_cons_cells == ((void *)0)){
  printf("Error: malloc error. -- INITIAL.\n");
  exit(-1);
 }
}

canonical_original_code:
void memory_init()
{
    the_cons_cells = (struct cons_cell *)malloc(sizeof(struct cons_cell) * 0x100000);
 if (the_cons_cells == ((void *)0)){
  printf("Error: malloc error. -- INITIAL.\n");
  exit(-1);
 }
 free_cons_cells = (struct cons_cell *)malloc(sizeof(struct cons_cell) * 0x100000);
 if (free_cons_cells == ((void *)0)){
  printf("Error: malloc error. -- INITIAL.\n");
  exit(-1);
 }
}

user_defined_types: struct cons_cell { unsigned int car; unsigned int cdr; }


decompiled_code:
_BOOL8 __fastcall memory_enough(int a1)
{
return (unsigned int)(free_point + a1) <= 0xFFFFF;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(int a1)
{
return (unsigned int)(free_point + a1) <= 0xFFFFF;
}

original_code:
int memory_enough(int k)
{
 return (free_point + k) < 0x100000;
}

variable_types: k int

return_type: int


car

decompiled_code:
__int64 __fastcall car(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1);
}

original_code:
uint car(cellpoint cp)
{
    return the_cons_cells[cp].car;
}

canonical_original_code:
unsigned int car(unsigned int cp)
{
    return the_cons_cells[cp].car;
}

variable_types:
cp
unsigned int

return_type: unsigned int


cdr

decompiled_code:
__int64 __fastcall cdr(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1 + 4);
}

original_code:
uint cdr(cellpoint cp)
{
    return the_cons_cells[cp].cdr;
}

canonical_original_code:
unsigned int cdr(unsigned int cp)
{
    return the_cons_cells[cp].cdr;
}


decompiled_code:
__int64 __fastcall car_set(unsigned int a1, int a2)
{
__int64 result; // rax

result = the_cons_cells;
*(_DWORD *)(the_cons_cells + 8LL * a1) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, int a2)
{
__int64 result; // rax

result = the_cons_cells;
*(_DWORD *)(the_cons_cells + 8LL * a1) = a2;
return result;
}

original_code:
void car_set(cellpoint cp, uint ele)
{
 the_cons_cells[cp].car = ele;
}

canonical_original_code:
void car_set(unsigned int cp, unsigned int ele)
{
 the_cons_cells[cp].car = ele;
}

variable_types:
ele
unsigned int

return_type: void


decompiled_code:
__int64 __fastcall cdr_set(unsigned int a1, int a2)
{
__int64 result; // rax

result = the_cons_cells;
*(_DWORD *)(the_cons_cells + 8LL * a1 + 4) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, int a2)
{
__int64 result; // rax

result = the_cons_cells;
*(_DWORD *)(the_cons_cells + 8LL * a1 + 4) = a2;
return result;
}

original_code:
void cdr_set(cellpoint cp, uint ele)
{
 the_cons_cells[cp].cdr = ele;
}

canonical_original_code:
void cdr_set(unsigned int cp, unsigned int ele)
{
 the_cons_cells[cp].cdr = ele;
}


cons

decompiled_code:
__int64 __fastcall cons(int a1, int a2)
{
int v2; // ebp
int v3; // ebx
__int64 result; // rax
unsigned int v5; // ebx

v2 = a1;
v3 = a2;
if ( !memory_enough(1) )
{
car_set(allocons, a1);
cdr_set(allocons, a2);
garbage_collection();
v5 = allocons;
v2 = car(allocons);
v3 = cdr(v5);
}
*(_DWORD *)(the_cons_cells + 8LL * (unsigned int)free_point) = v2;
result = (unsigned int)free_point;
*(_DWORD *)(the_cons_cells + 8LL * (unsigned int)free_point + 4) = v3;
free_point = result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2)
{
int v2; // ebp
int v3; // ebx
__int64 result; // rax
unsigned int v5; // ebx

v2 = a1;
v3 = a2;
if ( !func1(1) )
{
func4(allocons, a1);
func5(allocons, a2);
garbage_collection();
v5 = allocons;
v2 = func2(allocons);
v3 = func3(v5);
}
*(_DWORD *)(the_cons_cells + 8LL * (unsigned int)free_point) = v2;
result = (unsigned int)free_point;
*(_DWORD *)(the_cons_cells + 8LL * (unsigned int)free_point + 4) = v3;
free_point = result + 1;
return result;
}

original_code:
cellpoint cons(uint addr, uint decre)
{
    if(!memory_enough(1)){
  car_set(allocons, addr);
  cdr_set(allocons, decre);
        garbage_collection();
  addr = car(allocons);
  decre = cdr(allocons);
    }
 the_cons_cells[free_point].car = addr;
 the_cons_cells[free_point].cdr = decre;
    return free_point++;
}

canonical_original_code:
unsigned int cons(unsigned int addr, unsigned int decre)
{
    if(!memory_enough(1)){
  car_set(allocons, addr);
  cdr_set(allocons, decre);
        garbage_collection();
  addr = car(allocons);
  decre = cdr(allocons);
    }
 the_cons_cells[free_point].car = addr;
 the_cons_cells[free_point].cdr = decre;
    return free_point++;
}

variable_types:
addr
unsigned int

variable_types:
decre
unsigned int


decompiled_code:
__int64 __fastcall vector_pred_proc(unsigned int a1)
{
unsigned int v1; // eax

check_arglst_len_eq("vector?", 1LL, a1);
v1 = car(a1);
return is_vector(v1);
}

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

check_arglst_len_eq("vector?", 1LL, a1);
v1 = car(a1);
return is_vector(v1);
}

original_code:
cellpoint vector_pred_proc(cellpoint arglst)
{
 check_arglst_len_eq("vector?", 1, arglst);
 return is_vector(car(arglst));
}

canonical_original_code:
unsigned int vector_pred_proc(unsigned int arglst)
{
 check_arglst_len_eq("vector?", 1, arglst);
 return is_vector(car(arglst));
}

variable_types:
arglst
unsigned int


decompiled_code:
__int64 __fastcall make_vector_proc(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // ebp
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v8; // eax

args_push();
v1 = list_len();
v2 = get_integer(v1);
if ( v2 == 1 )
{
reg = 0;
}
else if ( v2 == 2 )
{
v8 = cdr(a1);
reg = car(v8);
}
else
{
printf("Error: procedure \"make-vector\" expects one or two arguments, but given %d.\n", v2);
error_handler();
}
v3 = car(a1);
check_arg_type("make-vector", "first", v3, 2LL);
v4 = reg;
v5 = car(a1);
v6 = get_integer(v5);
return make_vector(v6, v4);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // ebp
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v8; // eax

args_push();
v1 = list_len();
v2 = get_integer(v1);
if ( v2 == 1 )
{
reg = 0;
}
else if ( v2 == 2 )
{
v8 = cdr(a1);
reg = car(v8);
}
else
{
printf("Error: procedure \"make-vector\" expects one or two arguments, but given %d.\n", v2);
error_handler();
}
v3 = car(a1);
check_arg_type("make-vector", "first", v3, 2LL);
v4 = reg;
v5 = car(a1);
v6 = get_integer(v5);
return make_vector(v6, v4);
}

original_code:
cellpoint make_vector_proc(cellpoint arglst)
{
 int len;
 args_push(arglst);
 len = get_integer(list_len());
 if (len == 1){
  reg = 0;
 }else if (len == 2){
  reg = car(cdr(arglst));
 }else {
  printf("Error: procedure \"make-vector\" expects one or two arguments, but given %d.\n", len);
  error_handler();
 }
 check_arg_type("make-vector", "first", car(arglst), 2);
 return make_vector(get_integer(car(arglst)), reg);
}

canonical_original_code:
unsigned int make_vector_proc(unsigned int arglst)
{
 int len;
 args_push(arglst);
 len = get_integer(list_len());
 if (len == 1){
  reg = 0;
 }else if (len == 2){
  reg = car(cdr(arglst));
 }else {
  printf("Error: procedure \"make-vector\" expects one or two arguments, but given %d.\n", len);
  error_handler();
 }
 check_arg_type("make-vector", "first", car(arglst), 2);
 return make_vector(get_integer(car(arglst)), reg);
}

variable_types: len int


decompiled_code:
__int64 vector_proc()
{
args_push();
return vector();
}

canonical_decompiled_code:
__int64 func2()
{
args_push();
return vector();
}

original_code:
cellpoint vector_proc(cellpoint arglst)
{
 args_push(arglst);
 return vector();
}

canonical_original_code:
unsigned int vector_proc(unsigned int arglst)
{
 args_push(arglst);
 return vector();
}


decompiled_code:
__int64 __fastcall vector_length_proc(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax

check_arglst_len_eq("vector-length", 1LL, a1);
v1 = car(a1);
check_arg_type("vector-length", "first", v1, 6LL);
v2 = car(a1);
v3 = vector_len(v2);
return make_integer(v3);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax

check_arglst_len_eq("vector-length", 1LL, a1);
v1 = car(a1);
check_arg_type("vector-length", "first", v1, 6LL);
v2 = car(a1);
v3 = vector_len(v2);
return make_integer(v3);
}

original_code:
cellpoint vector_length_proc(cellpoint arglst)
{
 check_arglst_len_eq("vector-length", 1, arglst);
 check_arg_type("vector-length", "first", car(arglst), 6);
 return make_integer(vector_len(car(arglst)));
}

canonical_original_code:
unsigned int vector_length_proc(unsigned int arglst)
{
 check_arglst_len_eq("vector-length", 1, arglst);
 check_arg_type("vector-length", "first", car(arglst), 6);
 return make_integer(vector_len(car(arglst)));
}


decompiled_code:
__int64 __fastcall vector_ref_proc(unsigned int a1)
{
unsigned int v1; // ebp
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v4; // eax

check_arglst_len_eq("vector-ref", 2LL, a1);
v1 = car(a1);
v2 = cdr(a1);
v3 = car(v2);
check_arg_type("vector-ref", "first", v1, 6LL);
check_arg_type("vector-ref", "first", v3, 2LL);
v4 = get_integer(v3);
return vector_ref(v1, v4);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
unsigned int v1; // ebp
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v4; // eax

check_arglst_len_eq("vector-ref", 2LL, a1);
v1 = car(a1);
v2 = cdr(a1);
v3 = car(v2);
check_arg_type("vector-ref", "first", v1, 6LL);
check_arg_type("vector-ref", "first", v3, 2LL);
v4 = get_integer(v3);
return vector_ref(v1, v4);
}

original_code:
cellpoint vector_ref_proc(cellpoint arglst)
{
 check_arglst_len_eq("vector-ref", 2, arglst);
 cellpoint farg = car(arglst);
 cellpoint sarg = car(cdr(arglst));
 check_arg_type("vector-ref", "first", farg, 6);
 check_arg_type("vector-ref", "first", sarg, 2);
 return vector_ref(farg, get_integer(sarg));
}

canonical_original_code:
unsigned int vector_ref_proc(unsigned int arglst)
{
 check_arglst_len_eq("vector-ref", 2, arglst);
 unsigned int farg = car(arglst);
 unsigned int sarg = car(cdr(arglst));
 check_arg_type("vector-ref", "first", farg, 6);
 check_arg_type("vector-ref", "first", sarg, 2);
 return vector_ref(farg, get_integer(sarg));
}

variable_types:
farg
unsigned int

variable_types:
sarg
unsigned int


decompiled_code:
__int64 __fastcall vector_set_proc(unsigned int a1)
{
unsigned int v1; // ebp
unsigned int v2; // eax
unsigned int v3; // er12
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // ebx
unsigned int v7; // eax

check_arglst_len_eq("vector-set!", 3LL, a1);
v1 = car(a1);
v2 = cdr(a1);
v3 = car(v2);
v4 = cdr(a1);
v5 = cdr(v4);
v6 = car(v5);
check_arg_type("vector-set!", "first", v1, 6LL);
check_arg_type("vector-set!", "second", v3, 2LL);
v7 = get_integer(v3);
vector_set(v1, v7, v6);
return make_symbol("ok");
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1)
{
unsigned int v1; // ebp
unsigned int v2; // eax
unsigned int v3; // er12
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // ebx
unsigned int v7; // eax

check_arglst_len_eq("vector-set!", 3LL, a1);
v1 = car(a1);
v2 = cdr(a1);
v3 = car(v2);
v4 = cdr(a1);
v5 = cdr(v4);
v6 = car(v5);
check_arg_type("vector-set!", "first", v1, 6LL);
check_arg_type("vector-set!", "second", v3, 2LL);
v7 = get_integer(v3);
vector_set(v1, v7, v6);
return make_symbol("ok");
}

original_code:
cellpoint vector_set_proc(cellpoint arglst)
{
 check_arglst_len_eq("vector-set!", 3, arglst);
 cellpoint farg = car(arglst);
 cellpoint sarg = car(cdr(arglst));
 cellpoint targ = car(cdr(cdr(arglst)));
 check_arg_type("vector-set!", "first", farg, 6);
 check_arg_type("vector-set!", "second", sarg, 2);
 vector_set(farg, get_integer(sarg), targ);
 return make_symbol("ok");
}

canonical_original_code:
unsigned int vector_set_proc(unsigned int arglst)
{
 check_arglst_len_eq("vector-set!", 3, arglst);
 unsigned int farg = car(arglst);
 unsigned int sarg = car(cdr(arglst));
 unsigned int targ = car(cdr(cdr(arglst)));
 check_arg_type("vector-set!", "first", farg, 6);
 check_arg_type("vector-set!", "second", sarg, 2);
 vector_set(farg, get_integer(sarg), targ);
 return make_symbol("ok");
}

variable_types:
targ
unsigned int


decompiled_code:
__int64 __fastcall vector_2_list_proc(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax

check_arglst_len_eq("vector->list", 1LL, a1);
v1 = car(a1);
check_arg_type("vector->list", "first", v1, 6LL);
v2 = car(a1);
args_push(v2);
return vector_2_list();
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax

check_arglst_len_eq("vector->list", 1LL, a1);
v1 = car(a1);
check_arg_type("vector->list", "first", v1, 6LL);
v2 = car(a1);
args_push(v2);
return vector_2_list();
}

original_code:
cellpoint vector_2_list_proc(cellpoint arglst)
{
 check_arglst_len_eq("vector->list", 1, arglst);
 check_arg_type("vector->list", "first", car(arglst), 6);
 args_push(car(arglst));
 return vector_2_list();
}

canonical_original_code:
unsigned int vector_2_list_proc(unsigned int arglst)
{
 check_arglst_len_eq("vector->list", 1, arglst);
 check_arg_type("vector->list", "first", car(arglst), 6);
 args_push(car(arglst));
 return vector_2_list();
}


decompiled_code:
__int64 __fastcall list_2_vector_proc(unsigned int a1)
{
unsigned int v1; // eax
__int64 v2; // rdi

check_arglst_len_eq("list->vector", 1LL, a1);
v1 = car(a1);
check_arg_type("list->vector", "first", v1, 8LL);
v2 = (unsigned int)car(a1);
args_push(v2);
return list_2_vector();
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
unsigned int v1; // eax
__int64 v2; // rdi

check_arglst_len_eq("list->vector", 1LL, a1);
v1 = car(a1);
check_arg_type("list->vector", "first", v1, 8LL);
v2 = (unsigned int)car(a1);
args_push(v2);
return list_2_vector();
}

original_code:
cellpoint list_2_vector_proc(cellpoint arglst)
{
 check_arglst_len_eq("list->vector", 1, arglst);
 check_arg_type("list->vector", "first", car(arglst), 8);
 args_push(car(arglst));
 return list_2_vector();
}

canonical_original_code:
unsigned int list_2_vector_proc(unsigned int arglst)
{
 check_arglst_len_eq("list->vector", 1, arglst);
 check_arg_type("list->vector", "first", car(arglst), 8);
 args_push(car(arglst));
 return list_2_vector();
}


decompiled_code:
__int64 __fastcall vector_fill_proc(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rdi

check_arglst_len_eq("vector-fill!", 2LL, a1);
v1 = car(a1);
check_arg_type("vector-fill!", "first", v1, 6LL);
v2 = cdr(a1);
v3 = car(v2);
args_push(v3);
v4 = (unsigned int)car(a1);
args_push(v4);
vector_fill();
return make_symbol("ok");
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rdi

check_arglst_len_eq("vector-fill!", 2LL, a1);
v1 = car(a1);
check_arg_type("vector-fill!", "first", v1, 6LL);
v2 = cdr(a1);
v3 = car(v2);
args_push(v3);
v4 = (unsigned int)car(a1);
args_push(v4);
vector_fill();
return make_symbol("ok");
}

original_code:
cellpoint vector_fill_proc(cellpoint arglst)
{
 check_arglst_len_eq("vector-fill!", 2, arglst);
 check_arg_type("vector-fill!", "first", car(arglst), 6);
 args_push(car(cdr(arglst)));
 args_push(car(arglst));
 vector_fill();
 return make_symbol("ok");
}

canonical_original_code:
unsigned int vector_fill_proc(unsigned int arglst)
{
 check_arglst_len_eq("vector-fill!", 2, arglst);
 check_arg_type("vector-fill!", "first", car(arglst), 6);
 args_push(car(cdr(arglst)));
 args_push(car(arglst));
 vector_fill();
 return make_symbol("ok");
}


decompiled_code:
__int64 make_frame()
{
unsigned int v0; // ebx
unsigned int v1; // eax

v0 = args_ref(2LL);
v1 = args_ref(1LL);
reg = cons(v1, v0);
args_pop(2LL);
return reg;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // ebx
unsigned int v1; // eax

v0 = args_ref(2LL);
v1 = args_ref(1LL);
reg = cons(v1, v0);
args_pop(2LL);
return reg;
}

original_code:
static cellpoint make_frame(void)
{
 reg = cons(args_ref(1), args_ref(2));
 args_pop(2);
 return reg;
}

canonical_original_code:
static unsigned int make_frame()
{
 reg = cons(args_ref(1), args_ref(2));
 args_pop(2);
 return reg;
}


decompiled_code:
__int64 frame_variables()
{
unsigned int v0; // eax

v0 = args_ref(1LL);
reg = car(v0);
args_pop(1LL);
return reg;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // eax

v0 = args_ref(1LL);
reg = car(v0);
args_pop(1LL);
return reg;
}

original_code:
static cellpoint frame_variables(void)
{
 reg = car(args_ref(1));
 args_pop(1);
 return reg;
}

canonical_original_code:
static unsigned int frame_variables()
{
 reg = car(args_ref(1));
 args_pop(1);
 return reg;
}


decompiled_code:
__int64 frame_values()
{
unsigned int v0; // eax

v0 = args_ref(1LL);
reg = cdr(v0);
args_pop(1LL);
return reg;
}

canonical_decompiled_code:
__int64 func3()
{
unsigned int v0; // eax

v0 = args_ref(1LL);
reg = cdr(v0);
args_pop(1LL);
return reg;
}

original_code:
static cellpoint frame_values(void)
{
 reg = cdr(args_ref(1));
 args_pop(1);
 return reg;
}

canonical_original_code:
static unsigned int frame_values()
{
 reg = cdr(args_ref(1));
 args_pop(1);
 return reg;
}


decompiled_code:
__int64 prim_proc_names()
{
char **v0; // rbx
unsigned int v1; // er12
unsigned int v2; // eax
__int64 result; // rax
char **v4; // rdx

reg = 0;
v0 = &off_13A0;
do
{
v1 = reg;
v2 = make_symbol(*v0);
result = cons(v2, v1);
reg = result;
v4 = v0;
v0 -= 2;
}
while ( v4 != &pparray );
return result;
}

canonical_decompiled_code:
__int64 func6()
{
char **v0; // rbx
unsigned int v1; // er12
unsigned int v2; // eax
__int64 result; // rax
char **v4; // rdx

reg = 0;
v0 = &off_13A0;
do
{
v1 = reg;
v2 = make_symbol(*v0);
result = cons(v2, v1);
reg = result;
v4 = v0;
v0 -= 2;
}
while ( v4 != &pparray );
return result;
}

original_code:
static cellpoint prim_proc_names(void)
{
 int len = sizeof(pparray) / sizeof(struct prim_proc_pair);
 int i;
 reg = 0;
 for (i=len-1; i >= 0; --i){
  reg = cons(make_symbol(pparray[i].name), reg);
 }
 return reg;
}

canonical_original_code:
static unsigned int prim_proc_names()
{
 int len = sizeof(pparray) / sizeof(struct prim_proc_pair);
 int i;
 reg = 0;
 for (i=len-1; i >= 0; --i){
  reg = cons(make_symbol(pparray[i].name), reg);
 }
 return reg;
}

variable_types: i int


decompiled_code:
__int64 prim_proc_objs()
{
char **v0; // rbx
char **v1; // rbp
char *v2; // r13
unsigned int v3; // eax
unsigned int v4; // eax
__int64 result; // rax

reg = 0;
v0 = &off_13A0;
do
{
stack_push(&vars_stack, reg);
v1 = v0;
v2 = v0[1];
v3 = make_symbol(*v0);
reg = make_prim_proc(v3, v2);
v4 = stack_pop(&vars_stack);
result = cons(reg, v4);
reg = result;
v0 -= 2;
}
while ( v1 != &pparray );
return result;
}

canonical_decompiled_code:
__int64 func7()
{
char **v0; // rbx
char **v1; // rbp
char *v2; // r13
unsigned int v3; // eax
unsigned int v4; // eax
__int64 result; // rax

reg = 0;
v0 = &off_13A0;
do
{
stack_push(&vars_stack, reg);
v1 = v0;
v2 = v0[1];
v3 = make_symbol(*v0);
reg = make_prim_proc(v3, v2);
v4 = stack_pop(&vars_stack);
result = cons(reg, v4);
reg = result;
v0 -= 2;
}
while ( v1 != &pparray );
return result;
}

original_code:
static cellpoint prim_proc_objs(void)
{
 int len = sizeof(pparray) / sizeof(struct prim_proc_pair);
 int i;
 reg = 0;
 for (i = len-1; i >= 0; --i){
  stack_push(&vars_stack, reg);
  reg = make_prim_proc(make_symbol(pparray[i].name), pparray[i].func);
  reg = cons(reg, stack_pop(&vars_stack));
 }
 return reg;
}

canonical_original_code:
static unsigned int prim_proc_objs()
{
 int len = sizeof(pparray) / sizeof(struct prim_proc_pair);
 int i;
 reg = 0;
 for (i = len-1; i >= 0; --i){
  stack_push(&vars_stack, reg);
  reg = make_prim_proc(make_symbol(pparray[i].name), pparray[i].func);
  reg = cons(reg, stack_pop(&vars_stack));
 }
 return reg;
}


decompiled_code:
__int64 extend_env()
{
unsigned int v0; // eax
unsigned int v1; // ebx
__int64 v2; // rdi
unsigned int v3; // eax
unsigned int v5; // eax
unsigned int v6; // eax

v0 = args_ref(1LL);
args_push(v0);
reg = list_len();
v1 = get_integer(reg);
v2 = (unsigned int)args_ref(2LL);
args_push(v2);
reg = list_len();
v3 = get_integer(reg);
if ( v1 == v3 )
{
reg = args_ref(1LL);
v5 = args_ref(2LL);
args_push(v5);
args_push(reg);
reg = make_frame();
v6 = args_ref(3LL);
reg = cons(reg, v6);
}
else
{
printf("Error: the length of vars(%d) not equal the lengths of vals(%d). --EXTEND_ENV\n", v1, v3);
error_handler();
}
args_pop(3LL);
return reg;
}

canonical_decompiled_code:
__int64 func8()
{
unsigned int v0; // eax
unsigned int v1; // ebx
__int64 v2; // rdi
unsigned int v3; // eax
unsigned int v5; // eax
unsigned int v6; // eax

v0 = args_ref(1LL);
args_push(v0);
reg = list_len();
v1 = get_integer(reg);
v2 = (unsigned int)args_ref(2LL);
args_push(v2);
reg = list_len();
v3 = get_integer(reg);
if ( v1 == v3 )
{
reg = args_ref(1LL);
v5 = args_ref(2LL);
args_push(v5);
args_push(reg);
reg = func0();
v6 = args_ref(3LL);
reg = cons(reg, v6);
}
else
{
printf("Error: the length of vars(%d) not equal the lengths of vals(%d). --EXTEND_ENV\n", v1, v3);
error_handler();
}
args_pop(3LL);
return reg;
}

original_code:
cellpoint extend_env(void)
{
 int len1, len2;
 args_push(args_ref(1));
 reg = list_len();
 len1 = get_integer(reg);
 args_push(args_ref(2));
 reg = list_len();
 len2 = get_integer(reg);
 if (len1 != len2){
  printf("Error: the length of vars(%d) not equal the lengths of vals(%d). --EXTEND_ENV\n", len1, len2);
  error_handler();
 }else {
  reg = args_ref(1);
  args_push(args_ref(2));
  args_push(reg);
  reg = make_frame();
  reg = cons(reg, args_ref(3));
 }
 args_pop(3);
 return reg;
}

canonical_original_code:
unsigned int extend_env()
{
 int len1; int len2;
 args_push(args_ref(1));
 reg = list_len();
 len1 = get_integer(reg);
 args_push(args_ref(2));
 reg = list_len();
 len2 = get_integer(reg);
 if (len1 != len2){
  printf("Error: the length of vars(%d) not equal the lengths of vals(%d). --EXTEND_ENV\n", len1, len2);
  error_handler();
 }else {
  reg = args_ref(1);
  args_push(args_ref(2));
  args_push(reg);
  reg = make_frame();
  reg = cons(reg, args_ref(3));
 }
 args_pop(3);
 return reg;
}


decompiled_code:
__int64 lookup_var_val()
{
__int64 v0; // rsi
unsigned int v1; // ebx
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
__int64 v6; // rsi
unsigned int v7; // eax
unsigned int v8; // eax
__int64 v9; // rdi
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
__int64 v13; // rdi
unsigned int v14; // eax
unsigned int v16; // eax

v0 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v0);
while ( 1 )
{
v1 = stack_top(&vars_stack);
if ( !v1 )
{
printf("Error: unknown variables ");
v16 = args_ref(1LL);
display(v16);
newline();
error_handler();
args_pop(2LL);
return v1;
}
v2 = stack_top(&vars_stack);
args_push(v2);
reg = first_frame();
stack_push(&vars_stack, reg);
v3 = stack_top(&vars_stack);
args_push(v3);
reg = frame_values();
v4 = stack_pop(&vars_stack);
args_push(v4);
stack_push(&vars_stack, reg);
v5 = frame_variables();
v6 = v5;
reg = v5;
if ( v5 )
break;
LABEL_6:
stack_pop(&vars_stack);
v13 = (unsigned int)stack_pop(&vars_stack);
args_push(v13);
reg = enclosing_env(v13, v6);
stack_push(&vars_stack, reg);
}
while ( 1 )
{
stack_push(&vars_stack, v6);
v7 = args_ref(1LL);
args_push(v7);
v8 = stack_top(&vars_stack);
v9 = (unsigned int)car(v8);
args_push(v9);
reg = eq();
if ( (unsigned int)is_true(reg) )
break;
v10 = stack_pop(&vars_stack);
reg = cdr(v10);
v11 = stack_pop(&vars_stack);
v12 = cdr(v11);
stack_push(&vars_stack, v12);
v6 = reg;
if ( !reg )
goto LABEL_6;
}
stack_pop(&vars_stack);
v14 = stack_pop(&vars_stack);
reg = car(v14);
stack_pop(&vars_stack);
args_pop(2LL);
return (unsigned int)reg;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rsi
unsigned int v1; // ebx
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
__int64 v6; // rsi
unsigned int v7; // eax
unsigned int v8; // eax
__int64 v9; // rdi
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
__int64 v13; // rdi
unsigned int v14; // eax
unsigned int v16; // eax

v0 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v0);
while ( 1 )
{
v1 = stack_top(&vars_stack);
if ( !v1 )
{
printf("Error: unknown variables ");
v16 = args_ref(1LL);
display(v16);
newline();
error_handler();
args_pop(2LL);
return v1;
}
v2 = stack_top(&vars_stack);
args_push(v2);
reg = func1();
stack_push(&vars_stack, reg);
v3 = stack_top(&vars_stack);
args_push(v3);
reg = func3();
v4 = stack_pop(&vars_stack);
args_push(v4);
stack_push(&vars_stack, reg);
v5 = func2();
v6 = v5;
reg = v5;
if ( v5 )
break;
LABEL_6:
stack_pop(&vars_stack);
v13 = (unsigned int)stack_pop(&vars_stack);
args_push(v13);
reg = func4(v13, v6);
stack_push(&vars_stack, reg);
}
while ( 1 )
{
stack_push(&vars_stack, v6);
v7 = args_ref(1LL);
args_push(v7);
v8 = stack_top(&vars_stack);
v9 = (unsigned int)car(v8);
args_push(v9);
reg = eq();
if ( (unsigned int)is_true(reg) )
break;
v10 = stack_pop(&vars_stack);
reg = cdr(v10);
v11 = stack_pop(&vars_stack);
v12 = cdr(v11);
stack_push(&vars_stack, v12);
v6 = reg;
if ( !reg )
goto LABEL_6;
}
stack_pop(&vars_stack);
v14 = stack_pop(&vars_stack);
reg = car(v14);
stack_pop(&vars_stack);
args_pop(2LL);
return (unsigned int)reg;
}

original_code:
cellpoint lookup_var_val(void)
{
 stack_push(&vars_stack, args_ref(2));
 while (stack_top(&vars_stack) != the_empty_env){
  args_push(stack_top(&vars_stack));
  reg = first_frame();
  stack_push(&vars_stack, reg);
  args_push(stack_top(&vars_stack));
  reg = frame_values();
  args_push(stack_pop(&vars_stack));
  stack_push(&vars_stack, reg);
  reg = frame_variables();
  while (reg != 0){
   stack_push(&vars_stack, reg);
   args_push(args_ref(1));
   args_push(car(stack_top(&vars_stack)));
   reg = eq();
   if (is_true(reg)){
    stack_pop(&vars_stack);
    reg = car(stack_pop(&vars_stack));
    stack_pop(&vars_stack);
    args_pop(2);
    return reg;
   }
   reg = cdr(stack_pop(&vars_stack));
   stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
  }
  stack_pop(&vars_stack);
  args_push(stack_pop(&vars_stack));
  reg = enclosing_env();
  stack_push(&vars_stack, reg);
 }
 printf("Error: unknown variables ");
 display(args_ref(1));
 newline();
 error_handler();
 args_pop(2);
 return 0;
}

canonical_original_code:
unsigned int lookup_var_val()
{
 stack_push(&vars_stack, args_ref(2));
 while (stack_top(&vars_stack) != the_empty_env){
  args_push(stack_top(&vars_stack));
  reg = first_frame();
  stack_push(&vars_stack, reg);
  args_push(stack_top(&vars_stack));
  reg = frame_values();
  args_push(stack_pop(&vars_stack));
  stack_push(&vars_stack, reg);
  reg = frame_variables();
  while (reg != 0){
   stack_push(&vars_stack, reg);
   args_push(args_ref(1));
   args_push(car(stack_top(&vars_stack)));
   reg = eq();
   if (is_true(reg)){
    stack_pop(&vars_stack);
    reg = car(stack_pop(&vars_stack));
    stack_pop(&vars_stack);
    args_pop(2);
    return reg;
   }
   reg = cdr(stack_pop(&vars_stack));
   stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
  }
  stack_pop(&vars_stack);
  args_push(stack_pop(&vars_stack));
  reg = enclosing_env();
  stack_push(&vars_stack, reg);
 }
 printf("Error: unknown variables ");
 display(args_ref(1));
 newline();
 error_handler();
 args_pop(2);
 return 0;
}


decompiled_code:
__int64 define_var()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rsi
unsigned int v5; // eax
unsigned int v6; // eax
__int64 v7; // rdi
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
__int64 v11; // rdi
unsigned int v12; // eax
__int64 v13; // rsi
unsigned int v14; // eax
__int64 v15; // rdi
unsigned int v16; // eax
unsigned int v17; // eax
__int64 result; // rax
unsigned int v19; // eax
__int64 v20; // rdi
unsigned int v21; // eax
unsigned int v22; // eax

v0 = args_ref(3LL);
args_push(v0);
reg = ((__int64 (*)(void))first_frame)();
stack_push(&vars_stack, reg);
v1 = stack_top(&vars_stack);
args_push(v1);
reg = frame_values();
v2 = stack_pop(&vars_stack);
args_push(v2);
stack_push(&vars_stack, reg);
v3 = frame_variables();
v4 = v3;
reg = v3;
if ( v3 )
{
while ( 1 )
{
stack_push(&vars_stack, v4);
v5 = args_ref(1LL);
args_push(v5);
v6 = stack_top(&vars_stack);
v7 = (unsigned int)car(v6);
args_push(v7);
reg = eq();
if ( (unsigned int)is_true(reg) )
break;
v8 = stack_pop(&vars_stack);
reg = cdr(v8);
v9 = stack_pop(&vars_stack);
v10 = cdr(v9);
stack_push(&vars_stack, v10);
v4 = reg;
if ( !reg )
goto LABEL_4;
}
stack_pop(&vars_stack);
reg = stack_pop(&vars_stack);
v19 = args_ref(2LL);
car_set(reg, v19);
result = args_pop(3LL);
}
else
{
LABEL_4:
stack_pop(&vars_stack);
v11 = (unsigned int)args_ref(3LL);
args_push(v11);
reg = first_frame(v11, v4);
v12 = args_ref(1LL);
stack_push(&vars_stack, v12);
v13 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v13);
args_push(reg);
v14 = stack_pop(&vars_stack);
args_push(v14);
v15 = (unsigned int)stack_pop(&vars_stack);
args_push(v15);
add_binding_to_frame();
v16 = args_ref(2LL);
v17 = is_compound_proc(v16);
if ( (unsigned int)is_true(v17) )
{
v20 = (unsigned int)args_ref(2LL);
args_push(v20);
reg = procedure_name();
v21 = is_null(reg);
if ( (unsigned int)is_true(v21) )
{
reg = args_ref(2LL);
v22 = args_ref(1LL);
args_push(v22);
args_push(reg);
procedure_name_set();
}
}
result = args_pop(3LL);
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rsi
unsigned int v5; // eax
unsigned int v6; // eax
__int64 v7; // rdi
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
__int64 v11; // rdi
unsigned int v12; // eax
__int64 v13; // rsi
unsigned int v14; // eax
__int64 v15; // rdi
unsigned int v16; // eax
unsigned int v17; // eax
__int64 result; // rax
unsigned int v19; // eax
__int64 v20; // rdi
unsigned int v21; // eax
unsigned int v22; // eax

v0 = args_ref(3LL);
args_push(v0);
reg = ((__int64 (*)(void))first_frame)();
stack_push(&vars_stack, reg);
v1 = stack_top(&vars_stack);
args_push(v1);
reg = func3();
v2 = stack_pop(&vars_stack);
args_push(v2);
stack_push(&vars_stack, reg);
v3 = func2();
v4 = v3;
reg = v3;
if ( v3 )
{
while ( 1 )
{
stack_push(&vars_stack, v4);
v5 = args_ref(1LL);
args_push(v5);
v6 = stack_top(&vars_stack);
v7 = (unsigned int)car(v6);
args_push(v7);
reg = eq();
if ( (unsigned int)is_true(reg) )
break;
v8 = stack_pop(&vars_stack);
reg = cdr(v8);
v9 = stack_pop(&vars_stack);
v10 = cdr(v9);
stack_push(&vars_stack, v10);
v4 = reg;
if ( !reg )
goto LABEL_4;
}
stack_pop(&vars_stack);
reg = stack_pop(&vars_stack);
v19 = args_ref(2LL);
car_set(reg, v19);
result = args_pop(3LL);
}
else
{
LABEL_4:
stack_pop(&vars_stack);
v11 = (unsigned int)args_ref(3LL);
args_push(v11);
reg = func1(v11, v4);
v12 = args_ref(1LL);
stack_push(&vars_stack, v12);
v13 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v13);
args_push(reg);
v14 = stack_pop(&vars_stack);
args_push(v14);
v15 = (unsigned int)stack_pop(&vars_stack);
args_push(v15);
func5();
v16 = args_ref(2LL);
v17 = is_compound_proc(v16);
if ( (unsigned int)is_true(v17) )
{
v20 = (unsigned int)args_ref(2LL);
args_push(v20);
reg = procedure_name();
v21 = is_null(reg);
if ( (unsigned int)is_true(v21) )
{
reg = args_ref(2LL);
v22 = args_ref(1LL);
args_push(v22);
args_push(reg);
procedure_name_set();
}
}
result = args_pop(3LL);
}
return result;
}

original_code:
void define_var(void)
{
 args_push(args_ref(3));
 reg = first_frame();
 stack_push(&vars_stack, reg);
 args_push(stack_top(&vars_stack));
 reg = frame_values();
 args_push(stack_pop(&vars_stack));
 stack_push(&vars_stack, reg);
 reg = frame_variables();
 while (reg != 0){
  stack_push(&vars_stack, reg);
  args_push(args_ref(1));
  args_push(car(stack_top(&vars_stack)));
  reg = eq();
  if (is_true(reg)){
   stack_pop(&vars_stack);
   reg = stack_pop(&vars_stack);
   car_set(reg, args_ref(2));
   args_pop(3);
   return;
  }
  reg = cdr(stack_pop(&vars_stack));
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
 }
 stack_pop(&vars_stack);
 args_push(args_ref(3));
 reg = first_frame();
 stack_push(&vars_stack, args_ref(1));
 stack_push(&vars_stack, args_ref(2));
 args_push(reg);
 args_push(stack_pop(&vars_stack));
 args_push(stack_pop(&vars_stack));
 add_binding_to_frame();
 if (is_true(is_compound_proc(args_ref(2)))){
  args_push(args_ref(2));
  reg = procedure_name();
  if (is_true(is_null(reg))){
   reg = args_ref(2);
   args_push(args_ref(1));
   args_push(reg);
   procedure_name_set();
  }
 }
 args_pop(3);
}

canonical_original_code:
void define_var()
{
 args_push(args_ref(3));
 reg = first_frame();
 stack_push(&vars_stack, reg);
 args_push(stack_top(&vars_stack));
 reg = frame_values();
 args_push(stack_pop(&vars_stack));
 stack_push(&vars_stack, reg);
 reg = frame_variables();
 while (reg != 0){
  stack_push(&vars_stack, reg);
  args_push(args_ref(1));
  args_push(car(stack_top(&vars_stack)));
  reg = eq();
  if (is_true(reg)){
   stack_pop(&vars_stack);
   reg = stack_pop(&vars_stack);
   car_set(reg, args_ref(2));
   args_pop(3);
   return;
  }
  reg = cdr(stack_pop(&vars_stack));
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
 }
 stack_pop(&vars_stack);
 args_push(args_ref(3));
 reg = first_frame();
 stack_push(&vars_stack, args_ref(1));
 stack_push(&vars_stack, args_ref(2));
 args_push(reg);
 args_push(stack_pop(&vars_stack));
 args_push(stack_pop(&vars_stack));
 add_binding_to_frame();
 if (is_true(is_compound_proc(args_ref(2)))){
  args_push(args_ref(2));
  reg = procedure_name();
  if (is_true(is_null(reg))){
   reg = args_ref(2);
   args_push(args_ref(1));
   args_push(reg);
   procedure_name_set();
  }
 }
 args_pop(3);
}


decompiled_code:
__int64 set_var_val()
{
__int64 v0; // rsi
__int64 v1; // rdi
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
__int64 v5; // rsi
unsigned int v6; // eax
unsigned int v7; // eax
__int64 v8; // rdi
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
__int64 v12; // rdi
unsigned int v13; // eax
unsigned int v14; // eax
__int64 v16; // rdi

v0 = (unsigned int)args_ref(3LL);
stack_push(&vars_stack, v0);
while ( 1 )
{
if ( !(unsigned int)stack_top(&vars_stack) )
{
printf("Error: unknown variable ");
v16 = (unsigned int)args_ref(1LL);
display(v16);
newline();
error_handler();
stack_pop(&vars_stack);
return args_pop(3LL);
}
v1 = (unsigned int)stack_top(&vars_stack);
args_push(v1);
reg = first_frame(v1, v0);
stack_push(&vars_stack, reg);
v2 = stack_top(&vars_stack);
args_push(v2);
reg = frame_values();
v3 = stack_pop(&vars_stack);
args_push(v3);
stack_push(&vars_stack, reg);
v4 = frame_variables();
v5 = v4;
reg = v4;
if ( v4 )
break;
LABEL_6:
stack_pop(&vars_stack);
v12 = (unsigned int)stack_pop(&vars_stack);
args_push(v12);
v13 = enclosing_env(v12, v5);
v0 = v13;
reg = v13;
stack_push(&vars_stack, v13);
}
while ( 1 )
{
stack_push(&vars_stack, v5);
v6 = args_ref(1LL);
args_push(v6);
v7 = stack_top(&vars_stack);
v8 = (unsigned int)car(v7);
args_push(v8);
reg = eq();
if ( (unsigned int)is_true(reg) )
break;
v9 = stack_pop(&vars_stack);
reg = cdr(v9);
v10 = stack_pop(&vars_stack);
v11 = cdr(v10);
stack_push(&vars_stack, v11);
v5 = reg;
if ( !reg )
goto LABEL_6;
}
stack_pop(&vars_stack);
reg = stack_pop(&vars_stack);
v14 = args_ref(2LL);
car_set(reg, v14);
stack_pop(&vars_stack);
return args_pop(3LL);
}

canonical_decompiled_code:
__int64 func11()
{
__int64 v0; // rsi
__int64 v1; // rdi
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
__int64 v5; // rsi
unsigned int v6; // eax
unsigned int v7; // eax
__int64 v8; // rdi
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
__int64 v12; // rdi
unsigned int v13; // eax
unsigned int v14; // eax
__int64 v16; // rdi

v0 = (unsigned int)args_ref(3LL);
stack_push(&vars_stack, v0);
while ( 1 )
{
if ( !(unsigned int)stack_top(&vars_stack) )
{
printf("Error: unknown variable ");
v16 = (unsigned int)args_ref(1LL);
display(v16);
newline();
error_handler();
stack_pop(&vars_stack);
return args_pop(3LL);
}
v1 = (unsigned int)stack_top(&vars_stack);
args_push(v1);
reg = func1(v1, v0);
stack_push(&vars_stack, reg);
v2 = stack_top(&vars_stack);
args_push(v2);
reg = func3();
v3 = stack_pop(&vars_stack);
args_push(v3);
stack_push(&vars_stack, reg);
v4 = func2();
v5 = v4;
reg = v4;
if ( v4 )
break;
LABEL_6:
stack_pop(&vars_stack);
v12 = (unsigned int)stack_pop(&vars_stack);
args_push(v12);
v13 = func4(v12, v5);
v0 = v13;
reg = v13;
stack_push(&vars_stack, v13);
}
while ( 1 )
{
stack_push(&vars_stack, v5);
v6 = args_ref(1LL);
args_push(v6);
v7 = stack_top(&vars_stack);
v8 = (unsigned int)car(v7);
args_push(v8);
reg = eq();
if ( (unsigned int)is_true(reg) )
break;
v9 = stack_pop(&vars_stack);
reg = cdr(v9);
v10 = stack_pop(&vars_stack);
v11 = cdr(v10);
stack_push(&vars_stack, v11);
v5 = reg;
if ( !reg )
goto LABEL_6;
}
stack_pop(&vars_stack);
reg = stack_pop(&vars_stack);
v14 = args_ref(2LL);
car_set(reg, v14);
stack_pop(&vars_stack);
return args_pop(3LL);
}

original_code:
void set_var_val(void)
{
 stack_push(&vars_stack, args_ref(3));
 while (stack_top(&vars_stack) != the_empty_env){
  args_push(stack_top(&vars_stack));
  reg = first_frame();
  stack_push(&vars_stack, reg);
  args_push(stack_top(&vars_stack));
  reg = frame_values();
  args_push(stack_pop(&vars_stack));
  stack_push(&vars_stack, reg);
  reg = frame_variables();
  while (reg != 0){
   stack_push(&vars_stack, reg);
   args_push(args_ref(1));
   args_push(car(stack_top(&vars_stack)));
   reg = eq();
   if (is_true(reg)){
    stack_pop(&vars_stack);
    reg = stack_pop(&vars_stack);
    car_set(reg, args_ref(2));
    stack_pop(&vars_stack);
    args_pop(3);
    return;
   }
   reg = cdr(stack_pop(&vars_stack));
   stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
  }
  stack_pop(&vars_stack);
  args_push(stack_pop(&vars_stack));
  reg = enclosing_env();
  stack_push(&vars_stack, reg);
 }
 printf("Error: unknown variable ");
 display(args_ref(1));
 newline();
 error_handler();
 stack_pop(&vars_stack);
 args_pop(3);
}

canonical_original_code:
void set_var_val()
{
 stack_push(&vars_stack, args_ref(3));
 while (stack_top(&vars_stack) != the_empty_env){
  args_push(stack_top(&vars_stack));
  reg = first_frame();
  stack_push(&vars_stack, reg);
  args_push(stack_top(&vars_stack));
  reg = frame_values();
  args_push(stack_pop(&vars_stack));
  stack_push(&vars_stack, reg);
  reg = frame_variables();
  while (reg != 0){
   stack_push(&vars_stack, reg);
   args_push(args_ref(1));
   args_push(car(stack_top(&vars_stack)));
   reg = eq();
   if (is_true(reg)){
    stack_pop(&vars_stack);
    reg = stack_pop(&vars_stack);
    car_set(reg, args_ref(2));
    stack_pop(&vars_stack);
    args_pop(3);
    return;
   }
   reg = cdr(stack_pop(&vars_stack));
   stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
  }
  stack_pop(&vars_stack);
  args_push(stack_pop(&vars_stack));
  reg = enclosing_env();
  stack_push(&vars_stack, reg);
 }
 printf("Error: unknown variable ");
 display(args_ref(1));
 newline();
 error_handler();
 stack_pop(&vars_stack);
 args_pop(3);
}


decompiled_code:
__int64 setup_environment()
{
unsigned int v0; // eax
__int64 v1; // rdi
__int64 result; // rax

args_push(0LL);
v0 = prim_proc_objs();
args_push(v0);
v1 = (unsigned int)prim_proc_names();
args_push(v1);
result = extend_env();
reg = result;
return result;
}

canonical_decompiled_code:
__int64 func12()
{
unsigned int v0; // eax
__int64 v1; // rdi
__int64 result; // rax

args_push(0LL);
v0 = func7();
args_push(v0);
v1 = (unsigned int)func6();
args_push(v1);
result = func8();
reg = result;
return result;
}

original_code:
cellpoint setup_environment(void)
{
 args_push(the_empty_env);
 args_push(prim_proc_objs());
 args_push(prim_proc_names());
 reg = extend_env();
 return reg;
}

canonical_original_code:
unsigned int setup_environment()
{
 args_push(the_empty_env);
 args_push(prim_proc_objs());
 args_push(prim_proc_names());
 reg = extend_env();
 return reg;
}


decompiled_code:
__int64 __fastcall is_list(unsigned int a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
bool v7; // zf

v1 = a1;
v2 = ((__int64 (*)(void))is_null)();
if ( (unsigned int)is_true(v2) )
return a_true;
v4 = is_pair(a1);
if ( !(unsigned int)is_true(v4) )
return a_false;
while ( 1 )
{
v5 = is_pair(v1);
if ( !(unsigned int)is_true(v5) )
break;
v1 = cdr(v1);
}
v6 = is_null(v1);
v7 = (unsigned int)is_true(v6) == 0;
result = a_true;
if ( v7 )
result = a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 result; // rax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
bool v7; // zf

v1 = a1;
v2 = ((__int64 (*)(void))is_null)();
if ( (unsigned int)is_true(v2) )
return a_true;
v4 = is_pair(a1);
if ( !(unsigned int)is_true(v4) )
return a_false;
while ( 1 )
{
v5 = is_pair(v1);
if ( !(unsigned int)is_true(v5) )
break;
v1 = cdr(v1);
}
v6 = is_null(v1);
v7 = (unsigned int)is_true(v6) == 0;
result = a_true;
if ( v7 )
result = a_false;
return result;
}

original_code:
cellpoint is_list(cellpoint point)
{
    if (is_true(is_null(point))){
        return a_true;
    }else if (is_true(is_pair(point))){
  while (is_true(is_pair(point))){
   point = cdr(point);
  }
  if (is_true(is_null(point))){
   return a_true;
  }else {
   return a_false;
  }
 }else {
        return a_false;
    }
}

canonical_original_code:
unsigned int is_list(unsigned int point)
{
    if (is_true(is_null(point))){
        return a_true;
    }else if (is_true(is_pair(point))){
  while (is_true(is_pair(point))){
   point = cdr(point);
  }
  if (is_true(is_null(point))){
   return a_true;
  }else {
   return a_false;
  }
 }else {
        return a_false;
    }
}

variable_types:
point
unsigned int


decompiled_code:
__int64 list_eq()
{
int v0; // ebx
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
__int64 result; // rax
unsigned int v12; // eax
unsigned int v13; // eax
int v14; // eax
unsigned int v15; // eax

v0 = args_ref(1LL);
if ( v0 == (unsigned int)args_ref(2LL) )
{
args_pop(2LL);
result = a_true;
}
else
{
v1 = args_ref(1LL);
stack_push(&vars_stack, v1);
reg = args_ref(2LL);
while ( 1 )
{
v2 = stack_top(&vars_stack);
v3 = is_null(v2);
if ( !(unsigned int)is_false(v3) )
break;
v4 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v4) )
break;
v5 = car((unsigned int)reg);
args_push(v5);
v6 = stack_top(&vars_stack);
v7 = car(v6);
args_push(v7);
stack_push(&vars_stack, (unsigned int)reg);
reg = equal();
if ( (unsigned int)is_false((unsigned int)reg) )
{
reg = stack_pop(&vars_stack);
break;
}
v8 = stack_pop(&vars_stack);
reg = cdr(v8);
v9 = stack_pop(&vars_stack);
v10 = cdr(v9);
stack_push(&vars_stack, v10);
}
v12 = stack_pop(&vars_stack);
v13 = is_null(v12);
if ( (unsigned int)is_true(v13) && (v15 = is_null((unsigned int)reg), (unsigned int)is_true(v15)) )
v14 = a_true;
else
v14 = a_false;
reg = v14;
args_pop(2LL);
result = (unsigned int)reg;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // ebx
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
__int64 result; // rax
unsigned int v12; // eax
unsigned int v13; // eax
int v14; // eax
unsigned int v15; // eax

v0 = args_ref(1LL);
if ( v0 == (unsigned int)args_ref(2LL) )
{
args_pop(2LL);
result = a_true;
}
else
{
v1 = args_ref(1LL);
stack_push(&vars_stack, v1);
reg = args_ref(2LL);
while ( 1 )
{
v2 = stack_top(&vars_stack);
v3 = is_null(v2);
if ( !(unsigned int)is_false(v3) )
break;
v4 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v4) )
break;
v5 = car((unsigned int)reg);
args_push(v5);
v6 = stack_top(&vars_stack);
v7 = car(v6);
args_push(v7);
stack_push(&vars_stack, (unsigned int)reg);
reg = equal();
if ( (unsigned int)is_false((unsigned int)reg) )
{
reg = stack_pop(&vars_stack);
break;
}
v8 = stack_pop(&vars_stack);
reg = cdr(v8);
v9 = stack_pop(&vars_stack);
v10 = cdr(v9);
stack_push(&vars_stack, v10);
}
v12 = stack_pop(&vars_stack);
v13 = is_null(v12);
if ( (unsigned int)is_true(v13) && (v15 = is_null((unsigned int)reg), (unsigned int)is_true(v15)) )
v14 = a_true;
else
v14 = a_false;
reg = v14;
args_pop(2LL);
result = (unsigned int)reg;
}
return result;
}

original_code:
cellpoint list_eq(void)
{
    if (args_ref(1) == args_ref(2)){
  args_pop(2);
        return a_true;
    }
 stack_push(&vars_stack, args_ref(1));
 reg = args_ref(2);
    while (is_false(is_null(stack_top(&vars_stack))) &&
     is_false(is_null(reg))){
  args_push(car(reg));
  args_push(car(stack_top(&vars_stack)));
  stack_push(&vars_stack, reg);
  reg = equal();
        if (is_false(reg)){
   reg = stack_pop(&vars_stack);
   break;
        }
        reg = cdr(stack_pop(&vars_stack));
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
    }
    if (is_true(is_null(stack_pop(&vars_stack))) &&
  is_true(is_null(reg))){
  reg = a_true;
    }else {
  reg = a_false;
    }
 args_pop(2);
 return reg;
}

canonical_original_code:
unsigned int list_eq()
{
    if (args_ref(1) == args_ref(2)){
  args_pop(2);
        return a_true;
    }
 stack_push(&vars_stack, args_ref(1));
 reg = args_ref(2);
    while (is_false(is_null(stack_top(&vars_stack))) &&
     is_false(is_null(reg))){
  args_push(car(reg));
  args_push(car(stack_top(&vars_stack)));
  stack_push(&vars_stack, reg);
  reg = equal();
        if (is_false(reg)){
   reg = stack_pop(&vars_stack);
   break;
        }
        reg = cdr(stack_pop(&vars_stack));
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
    }
    if (is_true(is_null(stack_pop(&vars_stack))) &&
  is_true(is_null(reg))){
  reg = a_true;
    }else {
  reg = a_false;
    }
 args_pop(2);
 return reg;
}


decompiled_code:
__int64 list_len()
{
unsigned int i; // ebx
unsigned int v1; // eax

reg = args_ref(1LL);
for ( i = 0; ; ++i )
{
v1 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v1) )
break;
reg = cdr((unsigned int)reg);
}
args_pop(1LL);
return make_integer(i);
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int i; // ebx
unsigned int v1; // eax

reg = args_ref(1LL);
for ( i = 0; ; ++i )
{
v1 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v1) )
break;
reg = cdr((unsigned int)reg);
}
args_pop(1LL);
return make_integer(i);
}

original_code:
cellpoint list_len(void)
{
    int len = 0;
 reg = args_ref(1);
 while (is_false(is_null(reg))){
  ++len;
  reg = cdr(reg);
 }
 args_pop(1);
    return make_integer(len);
}

canonical_original_code:
unsigned int list_len()
{
    int len = 0;
 reg = args_ref(1);
 while (is_false(is_null(reg))){
  ++len;
  reg = cdr(reg);
 }
 args_pop(1);
    return make_integer(len);
}


reverse

decompiled_code:
__int64 reverse()
{
unsigned int v0; // ebx
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax

stack_push(&vars_stack, 0LL);
for ( reg = args_ref(1LL); ; reg = cdr((unsigned int)reg) )
{
v3 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v3) )
break;
v0 = stack_pop(&vars_stack);
v1 = car((unsigned int)reg);
v2 = cons(v1, v0);
stack_push(&vars_stack, v2);
}
reg = stack_pop(&vars_stack);
args_pop(1LL);
return (unsigned int)reg;
}

canonical_decompiled_code:
__int64 func3()
{
unsigned int v0; // ebx
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax

stack_push(&vars_stack, 0LL);
for ( reg = args_ref(1LL); ; reg = cdr((unsigned int)reg) )
{
v3 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v3) )
break;
v0 = stack_pop(&vars_stack);
v1 = car((unsigned int)reg);
v2 = cons(v1, v0);
stack_push(&vars_stack, v2);
}
reg = stack_pop(&vars_stack);
args_pop(1LL);
return (unsigned int)reg;
}

original_code:
cellpoint reverse(void)
{
 stack_push(&vars_stack, 0);
 reg = args_ref(1);
 while (is_false(is_null(reg))){
  stack_push(&vars_stack, cons(car(reg), stack_pop(&vars_stack)));
  reg = cdr(reg);
 }
 reg = stack_pop(&vars_stack);
 args_pop(1);
 return reg;
}

canonical_original_code:
unsigned int reverse()
{
 stack_push(&vars_stack, 0);
 reg = args_ref(1);
 while (is_false(is_null(reg))){
  stack_push(&vars_stack, cons(car(reg), stack_pop(&vars_stack)));
  reg = cdr(reg);
 }
 reg = stack_pop(&vars_stack);
 args_pop(1);
 return reg;
}


list

decompiled_code:
__int64 list()
{
unsigned int v0; // ebx
unsigned int v1; // eax
__int64 v2; // rsi
unsigned int v3; // eax

reg = args_ref(1LL);
stack_push(&vars_stack, 0LL);
while ( 1 )
{
v3 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v3) )
break;
v0 = stack_pop(&vars_stack);
v1 = car((unsigned int)reg);
v2 = (unsigned int)cons(v1, v0);
stack_push(&vars_stack, v2);
reg = cdr((unsigned int)reg);
}
reg = stack_pop(&vars_stack);
args_push((unsigned int)reg);
reg = reverse();
args_pop(1LL);
return (unsigned int)reg;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int v0; // ebx
unsigned int v1; // eax
__int64 v2; // rsi
unsigned int v3; // eax

reg = args_ref(1LL);
stack_push(&vars_stack, 0LL);
while ( 1 )
{
v3 = is_null((unsigned int)reg);
if ( !(unsigned int)is_false(v3) )
break;
v0 = stack_pop(&vars_stack);
v1 = car((unsigned int)reg);
v2 = (unsigned int)cons(v1, v0);
stack_push(&vars_stack, v2);
reg = cdr((unsigned int)reg);
}
reg = stack_pop(&vars_stack);
args_push((unsigned int)reg);
reg = func3();
args_pop(1LL);
return (unsigned int)reg;
}

original_code:
cellpoint list(void)
{
 reg = args_ref(1);
 stack_push(&vars_stack, 0);
 while (is_false(is_null(reg))){
  stack_push(&vars_stack, cons(car(reg), stack_pop(&vars_stack)));
  reg = cdr(reg);
 }
 reg = stack_pop(&vars_stack);
 args_push(reg);
 reg = reverse();
 args_pop(1);
 return reg;
}

canonical_original_code:
unsigned int list()
{
 reg = args_ref(1);
 stack_push(&vars_stack, 0);
 while (is_false(is_null(reg))){
  stack_push(&vars_stack, cons(car(reg), stack_pop(&vars_stack)));
  reg = cdr(reg);
 }
 reg = stack_pop(&vars_stack);
 args_push(reg);
 reg = reverse();
 args_pop(1);
 return reg;
}


append

decompiled_code:
__int64 __fastcall append(__int64 a1, const void *a2)
{
unsigned int v2; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
__int64 v10; // rdi
size_t v11; // rdx
unsigned int v12; // ebx
unsigned int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax
unsigned int v16; // eax
unsigned int v17; // eax
unsigned int v18; // eax

reg = args_ref(1LL);
v2 = is_null((unsigned int)reg);
if ( (unsigned int)is_true(v2) )
{
reg = args_ref(1LL);
LABEL_3:
args_pop(1LL);
return (unsigned int)reg;
}
v4 = cdr((unsigned int)reg);
v5 = is_null(v4);
if ( (unsigned int)is_true(v5) )
{
v6 = args_ref(1LL);
reg = car(v6);
goto LABEL_3;
}
v7 = args_ref(1LL);
reg = car(v7);
v8 = is_list(reg);
if ( !(unsigned int)is_false(v8) )
{
args_push((unsigned int)reg);
reg = reverse();
stack_push(&vars_stack, (unsigned int)reg);
v9 = args_ref(1LL);
v10 = (unsigned int)cdr(v9);
args_push(v10);
reg = append();
while ( 1 )
{
v17 = stack_top(&vars_stack);
v18 = is_null(v17);
if ( !(unsigned int)is_false(v18) )
break;
v12 = reg;
v13 = stack_top(&vars_stack);
v14 = car(v13);
reg = cons(v14, v12);
v15 = stack_pop(&vars_stack);
v16 = cdr(v15);
stack_push(&vars_stack, v16);
}
stack_pop(&vars_stack);
goto LABEL_3;
}
printf("Error: procedure \"append\" requires its arguments must be a list. but give a argument ");
write(reg, a2, v11);
error_handler();
args_pop(1LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const void *a2)
{
unsigned int v2; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
__int64 v10; // rdi
size_t v11; // rdx
unsigned int v12; // ebx
unsigned int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax
unsigned int v16; // eax
unsigned int v17; // eax
unsigned int v18; // eax

reg = args_ref(1LL);
v2 = is_null((unsigned int)reg);
if ( (unsigned int)is_true(v2) )
{
reg = args_ref(1LL);
LABEL_3:
args_pop(1LL);
return (unsigned int)reg;
}
v4 = cdr((unsigned int)reg);
v5 = is_null(v4);
if ( (unsigned int)is_true(v5) )
{
v6 = args_ref(1LL);
reg = car(v6);
goto LABEL_3;
}
v7 = args_ref(1LL);
reg = car(v7);
v8 = func0(reg);
if ( !(unsigned int)is_false(v8) )
{
args_push((unsigned int)reg);
reg = func3();
stack_push(&vars_stack, (unsigned int)reg);
v9 = args_ref(1LL);
v10 = (unsigned int)cdr(v9);
args_push(v10);
reg = func5();
while ( 1 )
{
v17 = stack_top(&vars_stack);
v18 = is_null(v17);
if ( !(unsigned int)is_false(v18) )
break;
v12 = reg;
v13 = stack_top(&vars_stack);
v14 = car(v13);
reg = cons(v14, v12);
v15 = stack_pop(&vars_stack);
v16 = cdr(v15);
stack_push(&vars_stack, v16);
}
stack_pop(&vars_stack);
goto LABEL_3;
}
printf("Error: procedure \"append\" requires its arguments must be a list. but give a argument ");
write(reg, a2, v11);
error_handler();
args_pop(1LL);
return 0LL;
}

original_code:
cellpoint append(void)
{
 reg = args_ref(1);
 if (is_true(is_null(reg))){
  reg = args_ref(1);
 }else if (is_true(is_null(cdr(reg)))){
  reg = car(args_ref(1));
 }else {
  reg = car(args_ref(1));
  if (is_false(is_list(reg))){
   printf("Error: procedure \"append\" requires its arguments must be a list. but give a argument ");
   write(reg);
   error_handler();
   args_pop(1);
   return 0;
  }
  args_push(reg);
  reg = reverse();
  stack_push(&vars_stack, reg);
  args_push(cdr(args_ref(1)));
  reg = append();
  while (is_false(is_null(stack_top(&vars_stack)))){
   reg = cons(car(stack_top(&vars_stack)), reg);
   stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
  }
  stack_pop(&vars_stack);
 }
 args_pop(1);
 return reg;
}

canonical_original_code:
unsigned int append()
{
 reg = args_ref(1);
 if (is_true(is_null(reg))){
  reg = args_ref(1);
 }else if (is_true(is_null(cdr(reg)))){
  reg = car(args_ref(1));
 }else {
  reg = car(args_ref(1));
  if (is_false(is_list(reg))){
   printf("Error: procedure \"append\" requires its arguments must be a list. but give a argument ");
   write(reg);
   error_handler();
   args_pop(1);
   return 0;
  }
  args_push(reg);
  reg = reverse();
  stack_push(&vars_stack, reg);
  args_push(cdr(args_ref(1)));
  reg = append();
  while (is_false(is_null(stack_top(&vars_stack)))){
   reg = cons(car(stack_top(&vars_stack)), reg);
   stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
  }
  stack_pop(&vars_stack);
 }
 args_pop(1);
 return reg;
}


decompiled_code:
__int64 list_tail()
{
unsigned int v0; // eax
int v1; // ebx
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax

v0 = args_ref(2LL);
v1 = get_integer(v0);
reg = args_ref(1LL);
if ( v1 > 0 )
{
do
{
v3 = is_null((unsigned int)reg);
if ( (unsigned int)is_true(v3) )
{
v4 = args_ref(2LL);
v5 = get_integer(v4);
printf("Error:the parameter list has fewer than %d elements. --LIST-TAIL\n", v5);
error_handler();
}
reg = cdr((unsigned int)reg);
--v1;
}
while ( v1 );
}
args_pop(2LL);
return (unsigned int)reg;
}

canonical_decompiled_code:
__int64 func6()
{
unsigned int v0; // eax
int v1; // ebx
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax

v0 = args_ref(2LL);
v1 = get_integer(v0);
reg = args_ref(1LL);
if ( v1 > 0 )
{
do
{
v3 = is_null((unsigned int)reg);
if ( (unsigned int)is_true(v3) )
{
v4 = args_ref(2LL);
v5 = get_integer(v4);
printf("Error:the parameter list has fewer than %d elements. --LIST-TAIL\n", v5);
error_handler();
}
reg = cdr((unsigned int)reg);
--v1;
}
while ( v1 );
}
args_pop(2LL);
return (unsigned int)reg;
}

original_code:
cellpoint list_tail(void)
{
    int count = get_integer(args_ref(2));
 reg = args_ref(1);
    while (count > 0){
        if (is_true(is_null(reg))){
            printf("Error:the parameter list has fewer than %d elements. --LIST-TAIL\n", get_integer(args_ref(2)));
   error_handler();
        }
  reg = cdr(reg);
        --count;
    }
 args_pop(2);
    return reg;
}

canonical_original_code:
unsigned int list_tail()
{
    int count = get_integer(args_ref(2));
 reg = args_ref(1);
    while (count > 0){
        if (is_true(is_null(reg))){
            printf("Error:the parameter list has fewer than %d elements. --LIST-TAIL\n", get_integer(args_ref(2)));
   error_handler();
        }
  reg = cdr(reg);
        --count;
    }
 args_pop(2);
    return reg;
}

variable_types: count int


decompiled_code:
__int64 list_ref()
{
unsigned int v0; // eax
int v1; // ebx
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax

v0 = args_ref(2LL);
v1 = get_integer(v0);
reg = args_ref(1LL);
if ( v1 > 0 )
{
do
{
v3 = is_null((unsigned int)reg);
if ( (unsigned int)is_true(v3) )
{
v4 = args_ref(2LL);
v5 = get_integer(v4);
printf("Error:the parameter list has fewer than %d elements. --LIST-REF\n", v5);
error_handler();
}
reg = cdr((unsigned int)reg);
--v1;
}
while ( v1 );
}
args_pop(2LL);
return car((unsigned int)reg);
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // eax
int v1; // ebx
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax

v0 = args_ref(2LL);
v1 = get_integer(v0);
reg = args_ref(1LL);
if ( v1 > 0 )
{
do
{
v3 = is_null((unsigned int)reg);
if ( (unsigned int)is_true(v3) )
{
v4 = args_ref(2LL);
v5 = get_integer(v4);
printf("Error:the parameter list has fewer than %d elements. --LIST-REF\n", v5);
error_handler();
}
reg = cdr((unsigned int)reg);
--v1;
}
while ( v1 );
}
args_pop(2LL);
return car((unsigned int)reg);
}

original_code:
cellpoint list_ref(void)
{
    int count = get_integer(args_ref(2));
 reg = args_ref(1);
    while (count > 0){
        if (is_true(is_null(reg))){
            printf("Error:the parameter list has fewer than %d elements. --LIST-REF\n", get_integer(args_ref(2)));
   error_handler();
        }
        reg = cdr(reg);
        --count;
    }
 args_pop(2);
    return car(reg);
}

canonical_original_code:
unsigned int list_ref()
{
    int count = get_integer(args_ref(2));
 reg = args_ref(1);
    while (count > 0){
        if (is_true(is_null(reg))){
            printf("Error:the parameter list has fewer than %d elements. --LIST-REF\n", get_integer(args_ref(2)));
   error_handler();
        }
        reg = cdr(reg);
        --count;
    }
 args_pop(2);
    return car(reg);
}


member

decompiled_code:
__int64 __fastcall member(__int64 (*a1)(void))
{
__int64 v1; // rsi
unsigned int v2; // eax
__int64 v3; // rsi
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax

v1 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v1);
while ( 1 )
{
v4 = stack_top(&vars_stack);
v5 = is_null(v4);
if ( !(unsigned int)is_false(v5) )
break;
reg = args_ref(1LL);
v6 = stack_top(&vars_stack);
v7 = car(v6);
args_push(v7);
args_push((unsigned int)reg);
reg = a1();
if ( (unsigned int)is_true((unsigned int)reg) )
{
args_pop(2LL);
return stack_pop(&vars_stack);
}
v2 = stack_pop(&vars_stack);
v3 = (unsigned int)cdr(v2);
stack_push(&vars_stack, v3);
}
stack_pop(&vars_stack);
args_pop(2LL);
return a_false;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 (*a1)(void))
{
__int64 v1; // rsi
unsigned int v2; // eax
__int64 v3; // rsi
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax

v1 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v1);
while ( 1 )
{
v4 = stack_top(&vars_stack);
v5 = is_null(v4);
if ( !(unsigned int)is_false(v5) )
break;
reg = args_ref(1LL);
v6 = stack_top(&vars_stack);
v7 = car(v6);
args_push(v7);
args_push((unsigned int)reg);
reg = a1();
if ( (unsigned int)is_true((unsigned int)reg) )
{
args_pop(2LL);
return stack_pop(&vars_stack);
}
v2 = stack_pop(&vars_stack);
v3 = (unsigned int)cdr(v2);
stack_push(&vars_stack, v3);
}
stack_pop(&vars_stack);
args_pop(2LL);
return a_false;
}

original_code:
cellpoint member(cellpoint (*eqfunc)(void))
{
 stack_push(&vars_stack, args_ref(2));
 while (is_false(is_null(stack_top(&vars_stack)))){
  reg = args_ref(1);
  args_push(car(stack_top(&vars_stack)));
  args_push(reg);
  reg = eqfunc();
  if (is_true(reg)){
   args_pop(2);
   return stack_pop(&vars_stack);
  }
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
 }
 stack_pop(&vars_stack);
 args_pop(2);
 return a_false;
}

canonical_original_code:
unsigned int member(unsigned int (*eqfunc)())
{
 stack_push(&vars_stack, args_ref(2));
 while (is_false(is_null(stack_top(&vars_stack)))){
  reg = args_ref(1);
  args_push(car(stack_top(&vars_stack)));
  args_push(reg);
  reg = eqfunc();
  if (is_true(reg)){
   args_pop(2);
   return stack_pop(&vars_stack);
  }
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
 }
 stack_pop(&vars_stack);
 args_pop(2);
 return a_false;
}

variable_types:
eqfunc
unsigned int (*)()


assoc

decompiled_code:
__int64 __fastcall assoc(__int64 (*a1)(void))
{
__int64 v1; // rsi
unsigned int v2; // eax
__int64 v3; // rsi
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax

v1 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v1);
while ( 1 )
{
v4 = stack_top(&vars_stack);
v5 = is_null(v4);
if ( !(unsigned int)is_false(v5) )
break;
reg = args_ref(1LL);
v6 = stack_top(&vars_stack);
v7 = car(v6);
v8 = car(v7);
args_push(v8);
args_push((unsigned int)reg);
reg = a1();
if ( (unsigned int)is_true((unsigned int)reg) )
{
args_pop(2LL);
v9 = stack_pop(&vars_stack);
return car(v9);
}
v2 = stack_pop(&vars_stack);
v3 = (unsigned int)cdr(v2);
stack_push(&vars_stack, v3);
}
stack_pop(&vars_stack);
args_pop(2LL);
return a_false;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 (*a1)(void))
{
__int64 v1; // rsi
unsigned int v2; // eax
__int64 v3; // rsi
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax

v1 = (unsigned int)args_ref(2LL);
stack_push(&vars_stack, v1);
while ( 1 )
{
v4 = stack_top(&vars_stack);
v5 = is_null(v4);
if ( !(unsigned int)is_false(v5) )
break;
reg = args_ref(1LL);
v6 = stack_top(&vars_stack);
v7 = car(v6);
v8 = car(v7);
args_push(v8);
args_push((unsigned int)reg);
reg = a1();
if ( (unsigned int)is_true((unsigned int)reg) )
{
args_pop(2LL);
v9 = stack_pop(&vars_stack);
return car(v9);
}
v2 = stack_pop(&vars_stack);
v3 = (unsigned int)cdr(v2);
stack_push(&vars_stack, v3);
}
stack_pop(&vars_stack);
args_pop(2LL);
return a_false;
}

original_code:
cellpoint assoc(cellpoint (*eqfunc)(void))
{
 stack_push(&vars_stack, args_ref(2));
 while (is_false(is_null(stack_top(&vars_stack)))){
  reg = args_ref(1);
  args_push(car(car(stack_top(&vars_stack))));
  args_push(reg);
  reg = eqfunc();
  if (is_true(reg)){
   args_pop(2);
   return car(stack_pop(&vars_stack));
  }
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
 }
 stack_pop(&vars_stack);
 args_pop(2);
 return a_false;
}

canonical_original_code:
unsigned int assoc(unsigned int (*eqfunc)())
{
 stack_push(&vars_stack, args_ref(2));
 while (is_false(is_null(stack_top(&vars_stack)))){
  reg = args_ref(1);
  args_push(car(car(stack_top(&vars_stack))));
  args_push(reg);
  reg = eqfunc();
  if (is_true(reg)){
   args_pop(2);
   return car(stack_pop(&vars_stack));
  }
  stack_push(&vars_stack, cdr(stack_pop(&vars_stack)));
 }
 stack_pop(&vars_stack);
 args_pop(2);
 return a_false;
}


decompiled_code:
__int64 __fastcall combine_args(unsigned int a1, const void *a2)
{
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rbx
unsigned int v5; // eax
size_t v6; // rdx
unsigned int v7; // eax
unsigned int v8; // ebp
unsigned int v9; // eax

v2 = ((__int64 (*)(void))cdr)();
v3 = is_null(v2);
if ( (unsigned int)is_true(v3) )
{
v4 = (unsigned int)car(a1);
v5 = is_list(v4);
if ( (unsigned int)is_false(v5) )
{
printf("Error: the procedure \"apply\" expects the last argument must be a list, but given: ");
write(v4, a2, v6);
newline();
error_handler();
}
}
else
{
v7 = cdr(a1);
v8 = combine_args(v7);
v9 = car(a1);
LODWORD(v4) = cons(v9, v8);
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, const void *a2)
{
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rbx
unsigned int v5; // eax
size_t v6; // rdx
unsigned int v7; // eax
unsigned int v8; // ebp
unsigned int v9; // eax

v2 = ((__int64 (*)(void))cdr)();
v3 = is_null(v2);
if ( (unsigned int)is_true(v3) )
{
v4 = (unsigned int)car(a1);
v5 = is_list(v4);
if ( (unsigned int)is_false(v5) )
{
printf("Error: the procedure \"apply\" expects the last argument must be a list, but given: ");
write(v4, a2, v6);
newline();
error_handler();
}
}
else
{
v7 = cdr(a1);
v8 = func0(v7);
v9 = car(a1);
LODWORD(v4) = cons(v9, v8);
}
return (unsigned int)v4;
}

original_code:
static cellpoint combine_args(cellpoint arglst)
{
 if (is_true(is_null(cdr(arglst)))){
  cellpoint last_arg = car(arglst);
  if (is_false(is_list(last_arg))){
   printf("Error: the procedure \"apply\" expects the last argument must be a list, but given: ");
   write(last_arg);
   newline();
   error_handler();
  }
  return last_arg;
 }else {
  return cons(car(arglst), combine_args(cdr(arglst)));
 }
}

canonical_original_code:
static unsigned int combine_args(unsigned int arglst)
{
 if (is_true(is_null(cdr(arglst)))){
  unsigned int last_arg = car(arglst);
  if (is_false(is_list(last_arg))){
   printf("Error: the procedure \"apply\" expects the last argument must be a list, but given: ");
   write(last_arg);
   newline();
   error_handler();
  }
  return last_arg;
 }else {
  return cons(car(arglst), combine_args(cdr(arglst)));
 }
}


decompiled_code:
__int64 __fastcall proc_pred_proc(unsigned int a1)
{
unsigned int v1; // eax

check_arglst_len_eq("procedure?", 1LL, a1);
v1 = car(a1);
return is_procedure(v1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
unsigned int v1; // eax

check_arglst_len_eq("procedure?", 1LL, a1);
v1 = car(a1);
return is_procedure(v1);
}

original_code:
cellpoint proc_pred_proc(cellpoint arglst)
{
 check_arglst_len_eq("procedure?", 1, arglst);
 return is_procedure(car(arglst));
}

canonical_original_code:
unsigned int proc_pred_proc(unsigned int arglst)
{
 check_arglst_len_eq("procedure?", 1, arglst);
 return is_procedure(car(arglst));
}


decompiled_code:
__int64 __fastcall apply_proc(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax

((void (*)(void))args_push)();
v1 = list_len();
if ( (int)get_integer(v1) <= 1 )
{
puts("Error: the procedure \"apply\" expects at least 2 arguments.");
error_handler();
}
v2 = car(a1);
check_arg_type("apply", "first", v2, 9LL);
args_push(a_false);
v3 = cdr(a1);
v4 = combine_args(v3, "first");
args_push(v4);
v5 = car(a1);
args_push(v5);
return apply();
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax

((void (*)(void))args_push)();
v1 = list_len();
if ( (int)get_integer(v1) <= 1 )
{
puts("Error: the procedure \"apply\" expects at least 2 arguments.");
error_handler();
}
v2 = car(a1);
check_arg_type("apply", "first", v2, 9LL);
args_push(a_false);
v3 = cdr(a1);
v4 = func0(v3, "first");
args_push(v4);
v5 = car(a1);
args_push(v5);
return apply();
}

original_code:
cellpoint apply_proc(cellpoint arglst)
{
 int len;
 args_push(arglst);
 len = get_integer(list_len());
 if (len < 2){
  printf("Error: the procedure \"apply\" expects at least 2 arguments.\n");
  error_handler();
 }
 check_arg_type("apply", "first", car(arglst), 9);
 args_push(a_false);
 args_push(combine_args(cdr(arglst)));
 args_push(car(arglst));
 return apply();
}

canonical_original_code:
unsigned int apply_proc(unsigned int arglst)
{
 int len;
 args_push(arglst);
 len = get_integer(list_len());
 if (len < 2){
  printf("Error: the procedure \"apply\" expects at least 2 arguments.\n");
  error_handler();
 }
 check_arg_type("apply", "first", car(arglst), 9);
 args_push(a_false);
 args_push(combine_args(cdr(arglst)));
 args_push(car(arglst));
 return apply();
}


decompiled_code:
__int64 read_sexp()
{
return read_parse(&ibuffer, &scan);
}

canonical_decompiled_code:
__int64 func0()
{
return read_parse(&ibuffer, &scan);
}

original_code:
static cellpoint read_sexp(void)
{
    return read_parse(ibuffer, &scan);
}

canonical_original_code:
static unsigned int read_sexp()
{
    return read_parse(ibuffer, &scan);
}


decompiled_code:
void __noreturn driver_loop()
{
size_t v0; // rdx

initial();
puts("initialed.");
while ( 1 )
{
if ( setjmp(jump_buffer) )
{
vars_init();
}
else
{
printf("\n%s\n", ";;;CSchemer input: ");
reg = read_sexp();
args_push(a_false);
args_push((unsigned int)reg);
reg = eval();
printf("\n%s\n", ";;;CSchemer output: ");
write(reg, ";;;CSchemer output: ", v0);
newline();
}
}
}

canonical_decompiled_code:
void __noreturn func1()
{
size_t v0; // rdx

initial();
puts("initialed.");
while ( 1 )
{
if ( setjmp(jump_buffer) )
{
vars_init();
}
else
{
printf("\n%s\n", ";;;CSchemer input: ");
reg = func0();
args_push(a_false);
args_push((unsigned int)reg);
reg = eval();
printf("\n%s\n", ";;;CSchemer output: ");
write(reg, ";;;CSchemer output: ", v0);
newline();
}
}
}

original_code:
void driver_loop(void)
{
 initial();
 printf("initialed.\n");
 while (1){
  if (_setjmp (jump_buffer) == 0){
   printf("\n%s\n", input_prompt);
   reg = read_sexp();
   args_push(a_false);
   args_push(reg);
   reg = eval();
   printf("\n%s\n", output_prompt);
   write(reg);
   newline();
  }else {
   vars_init();
  }
 }
}

canonical_original_code:
void driver_loop()
{
 initial();
 printf("initialed.\n");
 while (1){
  if (_setjmp (jump_buffer) == 0){
   printf("\n%s\n", input_prompt);
   reg = read_sexp();
   args_push(a_false);
   args_push(reg);
   reg = eval();
   printf("\n%s\n", output_prompt);
   write(reg);
   newline();
  }else {
   vars_init();
  }
 }
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("Hello CSchemer");
driver_loop("Hello CSchemer", argv);
return 0;
}

original_code:
int main()
{
    printf("Hello CSchemer\n");
 driver_loop();
    return 0;
}


decompiled_code:
__int64 __fastcall boolean_pred_proc(unsigned int a1)
{
unsigned int v1; // eax

check_arglst_len_eq("boolean?", 1LL, a1);
v1 = car(a1);
return is_boolean(v1);
}

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

check_arglst_len_eq("boolean?", 1LL, a1);
v1 = car(a1);
return is_boolean(v1);
}

original_code:
cellpoint boolean_pred_proc(cellpoint arglst)
{
    check_arglst_len_eq("boolean?",1,arglst);
    return is_boolean(car(arglst));
}

canonical_original_code:
unsigned int boolean_pred_proc(unsigned int arglst)
{
    check_arglst_len_eq("boolean?",1,arglst);
    return is_boolean(car(arglst));
}


decompiled_code:
__int64 __fastcall boolean_not_proc(unsigned int a1)
{
unsigned int v1; // eax

check_arglst_len_eq("not", 1LL, a1);
v1 = car(a1);
args_push(v1);
return boolean_not();
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
unsigned int v1; // eax

check_arglst_len_eq("not", 1LL, a1);
v1 = car(a1);
args_push(v1);
return boolean_not();
}

original_code:
cellpoint boolean_not_proc(cellpoint arglst)
{
 check_arglst_len_eq("not", 1, arglst);
 args_push(car(arglst));
    return boolean_not();
}

canonical_original_code:
unsigned int boolean_not_proc(unsigned int arglst)
{
 check_arglst_len_eq("not", 1, arglst);
 args_push(car(arglst));
    return boolean_not();
}


repo: lightcaster/fslib

decompiled_code:
__int64 __fastcall fnv32(const char *a1)
{
size_t v1; // rsi
unsigned int v2; // edx
__int64 result; // rax

v1 = strlen(a1);
v2 = 0;
LODWORD(result) = -2128831035;
while ( v2 < v1 )
LODWORD(result) = 16777619 * (a1[v2++] ^ (unsigned int)result);
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
size_t v1; // rsi
unsigned int v2; // edx
__int64 result; // rax

v1 = strlen(a1);
v2 = 0;
LODWORD(result) = -2128831035;
while ( v2 < v1 )
LODWORD(result) = 16777619 * (a1[v2++] ^ (unsigned int)result);
return (unsigned int)result;
}

original_code:
static size_t fnv32(void * str) {
    const char * s = str;
    uint32_t hsh = 2166136261U, i;
    for(i = 0; i < strlen(s); i++) {
        hsh = hsh ^ (s[i]);
        hsh = hsh * 16777619;
    }
    return hsh;
}

canonical_original_code:
static unsigned long fnv32(void *str) {
    char *s = str;
    unsigned int hsh = 2166136261U; unsigned int i;
    for(i = 0; i < strlen(s); i++) {
        hsh = hsh ^ (s[i]);
        hsh = hsh * 16777619;
    }
    return hsh;
}

variable_types:
str
void *

variable_types:
s
char *

variable_types:
hsh
unsigned int

variable_types:
i
unsigned int

return_type: unsigned long


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

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

original_code:
static int str_cmp(void * a, void * b) {
    return strcmp((const char *)a, (const char *)b) == 0 ? 1: 0;
}

canonical_original_code:
static int str_cmp(void *a, void *b) {
    return strcmp((char *)a, (char *)b) == 0 ? 1: 0;
}

variable_types:
a
void *

variable_types:
b
void *


original_code:
struct _symt * symt_create() {
    struct _symt * st = malloc(sizeof(struct _symt));
    st->rev = ((void *)0);
    st->sym = malloc(1024 * sizeof(char *));
    st->n_items = 0;
    st->n_max = 1024;
    for(size_t i=0; i < st->n_max; ++i)
        st->sym[i] = ((void *)0);
    return st;
}

canonical_original_code:
struct _symt *symt_create() {
    struct _symt *st = malloc(sizeof(struct _symt));
    st->rev = ((void *)0);
    st->sym = malloc(1024 * sizeof(char *));
    st->n_items = 0;
    st->n_max = 1024;
    for(unsigned long i = 0; i < st->n_max; ++i)
        st->sym[i] = ((void *)0);
    return st;
}

variable_types: struct _symt { unsigned long n_items; unsigned long n_max; char **sym; struct _hash { struct _bucket { struct _bitem { void *key; void *value; struct _bitem *next; } *head; struct _bitem *tail; } *buckets; unsigned long item_size; unsigned long key_size; unsigned long size; unsigned long n_items; unsigned long (*hash_f)(void *key); int (*cmp_f)(void *key_a, void *key_b); } *rev; } *

variable_types:
i
unsigned long

user_defined_types: struct _symt { unsigned long n_items; unsigned long n_max; char **sym; struct _hash *rev; }

user_defined_types: struct _hash { struct _bucket *buckets; unsigned long item_size; unsigned long key_size; unsigned long size; unsigned long n_items; unsigned long (*hash_f)(void *key); int (*cmp_f)(void *key_a, void *key_b); }

user_defined_types: struct _bucket { struct _bitem *head; struct _bitem *tail; }


decompiled_code:
void __fastcall symt_remove(void *ptr)
{
unsigned __int64 v2; // rbx
void *v3; // rdi

if ( *((_QWORD *)ptr + 1) )
{
v2 = 0LL;
do
{
v3 = *(void **)(*((_QWORD *)ptr + 2) + 8 * v2);
if ( v3 )
free(v3);
++v2;
}
while ( *((_QWORD *)ptr + 1) > v2 );
}
if ( *((_QWORD *)ptr + 3) )
hash_remove();
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
unsigned __int64 v2; // rbx
void *v3; // rdi

if ( *((_QWORD *)ptr + 1) )
{
v2 = 0LL;
do
{
v3 = *(void **)(*((_QWORD *)ptr + 2) + 8 * v2);
if ( v3 )
free(v3);
++v2;
}
while ( *((_QWORD *)ptr + 1) > v2 );
}
if ( *((_QWORD *)ptr + 3) )
hash_remove();
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void symt_remove(struct _symt * st) {
    for(size_t i=0; i < st->n_max; ++i)
        if(st->sym[i] != ((void *)0))
            free(st->sym[i]);
    if (st->rev != ((void *)0))
        hash_remove(st->rev);
    free(st->sym);
    free(st);
}

canonical_original_code:
void symt_remove(struct _symt *st) {
    for(unsigned long i = 0; i < st->n_max; ++i)
        if(st->sym[i] != ((void *)0))
            free(st->sym[i]);
    if (st->rev != ((void *)0))
        hash_remove(st->rev);
    free(st->sym);
    free(st);
}

user_defined_types: struct _bitem { void *key; void *value; struct _bitem *next; }


decompiled_code:
__int64 __fastcall symt_add(_QWORD *a1, unsigned __int64 a2, const char *a3)
{
unsigned __int64 v4; // rbx
void *v5; // rdi
unsigned __int64 v8; // rax
unsigned __int64 v9; // rsi
size_t v10; // rax
char *v11; // rbx

v4 = a1[1];
v5 = (void *)a1[2];
if ( !v5 )
_assert_fail("st->sym != NULL", "src/symt.c", 0x7Du, "symt_add");
if ( !v4 )
_assert_fail("st->n_max != 0", "src/symt.c", 0x7Eu, "symt_add");
v8 = v4;
if ( v4 <= a2 )
{
do
{
v9 = v8;
v8 *= 2LL;
}
while ( v8 <= a2 );
a1[1] = v8;
if ( v8 > v4 )
{
for ( a1[2] = realloc(v5, 16 * v9); a1[1] > v4; ++v4 )
*(_QWORD *)(a1[2] + 8 * v4) = 0LL;
}
}
v10 = strlen(a3);
v11 = (char *)malloc(v10 + 1);
strcpy(v11, a3);
*(_QWORD *)(a1[2] + 8 * a2) = v11;
++*a1;
return *(_QWORD *)(a1[2] + 8 * a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, unsigned __int64 a2, const char *a3)
{
unsigned __int64 v4; // rbx
void *v5; // rdi
unsigned __int64 v8; // rax
unsigned __int64 v9; // rsi
size_t v10; // rax
char *v11; // rbx

v4 = a1[1];
v5 = (void *)a1[2];
if ( !v5 )
_assert_fail("st->sym != NULL", "src/symt.c", 0x7Du, "symt_add");
if ( !v4 )
_assert_fail("st->n_max != 0", "src/symt.c", 0x7Eu, "symt_add");
v8 = v4;
if ( v4 <= a2 )
{
do
{
v9 = v8;
v8 *= 2LL;
}
while ( v8 <= a2 );
a1[1] = v8;
if ( v8 > v4 )
{
for ( a1[2] = realloc(v5, 16 * v9); a1[1] > v4; ++v4 )
*(_QWORD *)(a1[2] + 8 * v4) = 0LL;
}
}
v10 = strlen(a3);
v11 = (char *)malloc(v10 + 1);
strcpy(v11, a3);
*(_QWORD *)(a1[2] + 8 * a2) = v11;
++*a1;
return *(_QWORD *)(a1[2] + 8 * a2);
}

original_code:
char * symt_add(
                        struct _symt * st,
                        size_t id,
                        const char * token) {
    size_t s = st->n_max;
    char ** p;
    ((st->sym != ((void *)0)) ? (void) (0) : __assert_fail ("st->sym != NULL", "src/symt.c", 125, __extension__ __PRETTY_FUNCTION__));
    ((st->n_max != 0) ? (void) (0) : __assert_fail ("st->n_max != 0", "src/symt.c", 126, __extension__ __PRETTY_FUNCTION__));
    while (st->n_max <= id) {
        st->n_max *= 2;
    }
    if( st->n_max > s) {
        p = realloc(st->sym, st->n_max * sizeof(char *));
        st->sym = p;
    }
    for(size_t i = s; i < st->n_max; ++i)
        st->sym[i] = ((void *)0);
    char * t = malloc(strlen(token) + 1);
    strcpy(t, token);
    st->sym[id] = t;
    ++st->n_items;
    return st->sym[id];
}

canonical_original_code:
char *symt_add(struct _symt *st, unsigned long id, char *token) {
    unsigned long s = st->n_max;
    char **p;
    ((st->sym != ((void *)0)) ? (void) (0) : __assert_fail ("st->sym != NULL", "src/symt.c", 125, __extension__ __PRETTY_FUNCTION__));
    ((st->n_max != 0) ? (void) (0) : __assert_fail ("st->n_max != 0", "src/symt.c", 126, __extension__ __PRETTY_FUNCTION__));
    while (st->n_max <= id) {
        st->n_max *= 2;
    }
    if( st->n_max > s) {
        p = realloc(st->sym, st->n_max * sizeof(char *));
        st->sym = p;
    }
    for(unsigned long i = s; i < st->n_max; ++i)
        st->sym[i] = ((void *)0);
    char *t = malloc(strlen(token) + 1);
    strcpy(t, token);
    st->sym[id] = t;
    ++st->n_items;
    return st->sym[id];
}

variable_types:
id
unsigned long

variable_types:
token
char *

variable_types:
s
unsigned long

variable_types:
p
char **

variable_types:
t
char *

return_type: char *


decompiled_code:
int __fastcall symt_print(__int64 a1)
{
unsigned __int64 v1; // rbx
__int64 v2; // rax
const char *v3; // rsi

if ( *(_QWORD *)(a1 + 8) )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(a1 + 16);
v3 = *(const char **)(v2 + 8 * v1);
if ( v3 )
LODWORD(v2) = printf("%s\t%zd\n", v3, v1);
++v1;
}
while ( *(_QWORD *)(a1 + 8) > v1 );
}
return v2;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
unsigned __int64 v1; // rbx
__int64 v2; // rax
const char *v3; // rsi

if ( *(_QWORD *)(a1 + 8) )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(a1 + 16);
v3 = *(const char **)(v2 + 8 * v1);
if ( v3 )
LODWORD(v2) = printf("%s\t%zd\n", v3, v1);
++v1;
}
while ( *(_QWORD *)(a1 + 8) > v1 );
}
return v2;
}

original_code:
void symt_print(struct _symt * st) {
    for(size_t i=0; i < st->n_max; ++i) {
        if ( st->sym[i] != ((void *)0) )
            printf("%s\t%zd\n", st->sym[i], i);
    }
}

canonical_original_code:
void symt_print(struct _symt *st) {
    for(unsigned long i = 0; i < st->n_max; ++i) {
        if ( st->sym[i] != ((void *)0) )
            printf("%s\t%zd\n", st->sym[i], i);
    }
}


decompiled_code:
__int64 __fastcall symt_reverse(_QWORD *a1)
{
unsigned __int64 v1; // rax
const char *v3; // rsi
unsigned __int64 v4; // [rsp+8h] [rbp-410h] BYREF
char dest[8]; // [rsp+10h] [rbp-408h] BYREF
__int64 v6; // [rsp+18h] [rbp-400h]
char v7[1008]; // [rsp+20h] [rbp-3F8h] BYREF

if ( a1[3] )
hash_remove();
a1[3] = hash_create(fnv32, str_cmp, 1024LL, 8LL, 2LL * *a1);
*(_QWORD *)dest = 0LL;
v6 = 0LL;
v1 = 0LL;
memset(v7, 0, sizeof(v7));
v4 = 0LL;
if ( a1[1] )
{
do
{
v3 = *(const char **)(a1[2] + 8 * v1);
if ( v3 )
{
strncpy(dest, v3, 0x3FFuLL);
hash_add(a1[3], dest, &v4);
}
v1 = v4 + 1;
v4 = v1;
}
while ( v1 < a1[1] );
}
return a1[3];
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1)
{
unsigned __int64 v1; // rax
const char *v3; // rsi
unsigned __int64 v4; // [rsp+8h] [rbp-410h] BYREF
char dest[8]; // [rsp+10h] [rbp-408h] BYREF
__int64 v6; // [rsp+18h] [rbp-400h]
char v7[1008]; // [rsp+20h] [rbp-3F8h] BYREF

if ( a1[3] )
hash_remove();
a1[3] = hash_create(fnv32, str_cmp, 1024LL, 8LL, 2LL * *a1);
*(_QWORD *)dest = 0LL;
v6 = 0LL;
v1 = 0LL;
memset(v7, 0, sizeof(v7));
v4 = 0LL;
if ( a1[1] )
{
do
{
v3 = *(const char **)(a1[2] + 8 * v1);
if ( v3 )
{
strncpy(dest, v3, 0x3FFuLL);
hash_add(a1[3], dest, &v4);
}
v1 = v4 + 1;
v4 = v1;
}
while ( v1 < a1[1] );
}
return a1[3];
}

original_code:
struct _hash * symt_reverse(struct _symt * st) {
    if(st->rev != ((void *)0))
        hash_remove(st->rev);
    st->rev = hash_create(
                    fnv32,
                    str_cmp,
                    1024,
                    sizeof(size_t),
                    st->n_items * 2);
    char token[1024] = {0};
    for(size_t i=0; i < st->n_max; ++i) {
        if ( st->sym[i] != ((void *)0) ) {
            strncpy(token, st->sym[i], 1024 - 1);
            hash_add(st->rev, token, &i);
        }
    }
    return st->rev;
}

canonical_original_code:
struct _hash *symt_reverse(struct _symt *st) {
    if(st->rev != ((void *)0))
        hash_remove(st->rev);
    st->rev = hash_create(
                    fnv32,
                    str_cmp,
                    1024,
                    sizeof(unsigned long),
                    st->n_items * 2);
    char token[1024] = {0};
    for(unsigned long i = 0; i < st->n_max; ++i) {
        if ( st->sym[i] != ((void *)0) ) {
            strncpy(token, st->sym[i], 1024 - 1);
            hash_add(st->rev, token, &i);
        }
    }
    return st->rev;
}

variable_types: struct _symt { unsigned long n_items; unsigned long n_max; char **sym; struct _hash *rev; } *

variable_types:
token
char [1024]

return_type: struct _hash { struct _bucket { struct _bitem { void *key; void *value; struct _bitem *next; } *head; struct _bitem *tail; } *buckets; unsigned long item_size; unsigned long key_size; unsigned long size; unsigned long n_items; unsigned long (*hash_f)(void *key); int (*cmp_f)(void *key_a, void *key_b); } *


decompiled_code:
__int64 __fastcall symt_getr(_QWORD *a1, __int64 a2)
{
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

v3[0] = -1LL;
if ( !a1[3] )
symt_reverse(a1);
hash_get(a1[3], a2, v3);
return v3[0];
}

original_code:
size_t symt_getr(struct _symt * st, char * token) {
    size_t id = -1;
    if (st->rev == ((void *)0))
       symt_reverse(st);
    hash_get(st->rev, token, &id);
    return id;
}

canonical_original_code:
unsigned long symt_getr(struct _symt *st, char *token) {
    unsigned long id = -1;
    if (st->rev == ((void *)0))
       symt_reverse(st);
    hash_get(st->rev, token, &id);
    return id;
}


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

if ( *a1 < a2 )
result = 0LL;
else
result = *(_QWORD *)(a1[2] + 8 * a2);
return result;
}

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

if ( *a1 < a2 )
result = 0LL;
else
result = *(_QWORD *)(a1[2] + 8 * a2);
return result;
}

original_code:
char * symt_get(struct _symt * st, size_t id) {
    if ( id > st->n_items )
        return ((void *)0);
    return st->sym[id];
}

canonical_original_code:
char *symt_get(struct _symt *st, unsigned long id) {
    if ( id > st->n_items )
        return ((void *)0);
    return st->sym[id];
}


decompiled_code:
__int64 __fastcall hash_pair(unsigned int *a1)
{
return 31 * (*a1 + 527LL) + a1[1];
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1)
{
return 31 * (*a1 + 527LL) + a1[1];
}

original_code:
static size_t hash_pair(void * p) {
    size_t hash = 17;
    hash = hash*31 + ((struct _spair *)p)->a;
    hash = hash*31 + ((struct _spair *)p)->b;
    return hash;
}

canonical_original_code:
static unsigned long hash_pair(void *p) {
    unsigned long hash = 17;
    hash = hash*31 + ((struct _spair *)p)->a;
    hash = hash*31 + ((struct _spair *)p)->b;
    return hash;
}

variable_types:
p
void *

variable_types:
hash
unsigned long

user_defined_types: struct _spair { unsigned int a; unsigned int b; }


decompiled_code:
_BOOL8 __fastcall cmp_pair(const void *a1, const void *a2)
{
return memcmp(a1, a2, 8uLL) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const void *a1, const void *a2)
{
return memcmp(a1, a2, 8uLL) == 0;
}

original_code:
static int cmp_pair(void * a, void * b) {
    return memcmp(a, b, sizeof(struct _spair)) == 0 ? 1 : 0;
}

canonical_original_code:
static int cmp_pair(void *a, void *b) {
    return memcmp(a, b, sizeof(struct _spair)) == 0 ? 1 : 0;
}


original_code:
void match_arcs(
                    const struct _fst * fst_a,
                    const struct _fst * fst_b,
                    const struct _spair * pair,
                    struct _sr * sr,
                    struct _queue * mq)
{
    struct _state * state_a = &fst_a->states[pair->a];
    struct _state * state_b = &fst_b->states[pair->b];
    int osort = fst_a->flags & 0x02;
    int isort = fst_b->flags & 0x01;
    size_t asize = sizeof(struct _arc);
    uint32_t m = state_a->n_arcs + 1;
    uint32_t n = state_b->n_arcs + 1;
    struct _arc * arcs_a = malloc(asize * m);
    struct _arc * arcs_b = malloc(asize * n);
    memcpy(arcs_a + 1, state_a->arcs, asize * (m-1));
    memcpy(arcs_b + 1, state_b->arcs, asize * (n-1));
    struct _arc loop_arc_a = {
            .state = pair->a,
            .ilabel = 0,
            .olabel = 0,
            .weight = sr->one
    };
    struct _arc loop_arc_b = {
            .state = pair->b,
            .ilabel = 0,
            .olabel = 0,
            .weight = sr->one
    };
    arcs_a[0] = loop_arc_a;
    arcs_b[0] = loop_arc_b;
    if (isort && osort)
        match_full_sorted(arcs_a, arcs_b, m, n, mq);
    else
        if (isort || osort) {
            if (isort) {
                match_half_sorted(arcs_a, arcs_b, m, n, mq);
            } else {
                match_half_sorted_rev(arcs_a, arcs_b, m, n, mq);
            }
        } else {
            match_unsorted(arcs_a, arcs_b, m, n, mq);
        }
    free(arcs_a);
    free(arcs_b);
}

canonical_original_code:
void match_arcs(struct _fst *fst_a, struct _fst *fst_b, struct _spair *pair, struct _sr *sr, struct _queue *mq)
{
    struct _state *state_a = &fst_a->states[pair->a];
    struct _state *state_b = &fst_b->states[pair->b];
    int osort = fst_a->flags & 0x02;
    int isort = fst_b->flags & 0x01;
    unsigned long asize = sizeof(struct _arc);
    unsigned int m = state_a->n_arcs + 1;
    unsigned int n = state_b->n_arcs + 1;
    struct _arc *arcs_a = malloc(asize * m);
    struct _arc *arcs_b = malloc(asize * n);
    memcpy(arcs_a + 1, state_a->arcs, asize * (m-1));
    memcpy(arcs_b + 1, state_b->arcs, asize * (n-1));
    struct _arc loop_arc_a = {
            .state = pair->a,
            .ilabel = 0,
            .olabel = 0,
            .weight = sr->one
    };
    struct _arc loop_arc_b = {
            .state = pair->b,
            .ilabel = 0,
            .olabel = 0,
            .weight = sr->one
    };
    arcs_a[0] = loop_arc_a;
    arcs_b[0] = loop_arc_b;
    if (isort && osort)
        match_full_sorted(arcs_a, arcs_b, m, n, mq);
    else
        if (isort || osort) {
            if (isort) {
                match_half_sorted(arcs_a, arcs_b, m, n, mq);
            } else {
                match_half_sorted_rev(arcs_a, arcs_b, m, n, mq);
            }
        } else {
            match_unsorted(arcs_a, arcs_b, m, n, mq);
        }
    free(arcs_a);
    free(arcs_b);
}

variable_types: struct _fst { unsigned int start; unsigned int n_states; unsigned int n_max; unsigned char sr_type; unsigned char flags; struct _state { unsigned int n_arcs; unsigned int n_max; float weight; int final; struct _arc { unsigned int state; float weight; unsigned int ilabel; unsigned int olabel; } *arcs; } *states; } *

variable_types: struct _spair { unsigned int a; unsigned int b; } *

variable_types: struct _sr { float (*sum)(float a, float b); float (*prod)(float a, float b); float zero; float one; } *

variable_types: struct _queue { struct _qnode { struct _qnode *next; char item[1]; } *head; struct _qnode *tail; unsigned long item_size; unsigned long n_items; } *

variable_types: osort int

variable_types: isort int

variable_types:
asize
unsigned long

variable_types:
m
unsigned int

variable_types:
n
unsigned int

user_defined_types: struct _fst { unsigned int start; unsigned int n_states; unsigned int n_max; unsigned char sr_type; unsigned char flags; struct _state *states; }

user_defined_types: struct _queue { struct _qnode *head; struct _qnode *tail; unsigned long item_size; unsigned long n_items; }

user_defined_types: struct _state { unsigned int n_arcs; unsigned int n_max; float weight; int final; struct _arc *arcs; }