decompiled_code:
__int64 __fastcall fmcache_return(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 result; // rax

v2 = hdr_to_fmcell(a1) + 8;
dlnode_init(v2);
result = dlist_insertfirst(a2, v2);
++*(_QWORD *)(a2 + 56);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 result; // rax

v2 = func2(a1) + 8;
dlnode_init(v2);
result = func3(a2, v2);
++*(_QWORD *)(a2 + 56);
return result;
}

original_code:
void fmcache_return(void *data, void *fmcache_state)
{
 free_mem_cell_t *fmc = data_to_fmcell(data);
 fmcache_state_t *state = (fmcache_state_t *)fmcache_state;
 dlnode_init(&(fmc->u.hdr));
 dlist_insertfirst(&(state->free_list), &(fmc->u.hdr));
 state->free_count++;
}

canonical_original_code:
void fmcache_return(void *data, void *fmcache_state)
{
 struct free_mem_cell_t *fmc = data_to_fmcell(data);
 struct fmcache_state_t *state = (fmcache_state_t *)fmcache_state;
 dlnode_init(&(fmc->u.hdr));
 dlist_insertfirst(&(state->free_list), &(fmc->u.hdr));
 state->free_count++;
}

variable_types:
data
void *

variable_types: struct free_mem_cell_t { unsigned long len; union { struct dlnode { struct dlnode *prev; struct dlist { struct dlnode hdr; } *owner; } hdr; int data[]; } u; } *


decompiled_code:
__int64 __fastcall fmcache_count(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

original_code:
uintptr_t fmcache_count(fmcache_state_t *state)
{
 return state->alloc_count;
}

canonical_original_code:
unsigned long fmcache_count(struct fmcache_state_t *state)
{
 return state->alloc_count;
}

variable_types: struct fmcache_state_t { struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *alloc_p; unsigned long alloc_count; unsigned long free_count; } *

return_type: unsigned long

user_defined_types: struct fmcache_state_t { struct dlist free_list; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *alloc_p; unsigned long alloc_count; unsigned long free_count; }


decompiled_code:
bool __fastcall environ_find(__int64 a1, __int64 a2, unsigned __int8 a3, _QWORD *a4)
{
int v5; // eax
__int64 v7; // [rsp+0h] [rbp-18h] BYREF
__int64 v8; // [rsp+8h] [rbp-10h]

v7 = a2;
v8 = 0LL;
v5 = ((__int64 (__fastcall *)(__int64, __int64 (__fastcall *)(), __int64 *, _QWORD, _QWORD, _QWORD))frame_iterate)(
a1,
find_keyval,
&v7,
a3,
0LL,
0LL);
if ( a4 )
*a4 = v8;
return v5 != 0;
}

canonical_decompiled_code:
bool __fastcall func0(__int64 a1, __int64 a2, unsigned __int8 a3, _QWORD *a4)
{
int v5; // eax
__int64 v7; // [rsp+0h] [rbp-18h] BYREF
__int64 v8; // [rsp+8h] [rbp-10h]

v7 = a2;
v8 = 0LL;
v5 = ((__int64 (__fastcall *)(__int64, __int64 (__fastcall *)(), __int64 *, _QWORD, _QWORD, _QWORD))frame_iterate)(
a1,
find_keyval,
&v7,
a3,
0LL,
0LL);
if ( a4 )
*a4 = v8;
return v5 != 0;
}

original_code:
static _Bool environ_find(
 node_t *env_handle,
 node_t *key,
 _Bool recursive,
 node_t **keyval)
{
 struct kv_find info = { .key = key, .keyval = ((void *)0) };
 int status;
 status = frame_iterate(env_handle, find_keyval, &info, recursive,
                        ((void *)0), ((void *)0));
 if(keyval) {
  *keyval = info.keyval;
 }
 return status != 0;
}

canonical_original_code:
static _Bool environ_find(struct node *env_handle, struct node *key, _Bool recursive, struct node **keyval)
{
 struct kv_find info = { .key = key, .keyval = ((void *)0) };
 int status;
 status = frame_iterate(env_handle, find_keyval, &info, recursive,
                        ((void *)0), ((void *)0));
 if(keyval) {
  *keyval = info.keyval;
 }
 return status != 0;
}

variable_types:
key
struct node *

variable_types:
keyval
struct node **

variable_types: struct kv_find { struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *key; struct node *keyval; }

variable_types: status int

user_defined_types: struct kv_find { struct node *key; struct node *keyval; }

user_defined_types: struct node { enum nodetype_t type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t (*func)(struct memory_state *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t special; } dat; }

user_defined_types: struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; }


decompiled_code:
__int64 __fastcall find_keyval(__int64 a1, _QWORD *a2)
{
__int64 v2; // r13
const char *v3; // r12
const char *v4; // rax
int v5; // er8
__int64 result; // rax

v2 = node_cons_car();
v3 = (const char *)node_symbol_name(*a2);
v4 = (const char *)node_symbol_name(v2);
v5 = strcmp(v4, v3);
result = 0LL;
if ( !v5 )
{
a2[1] = a1;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2)
{
__int64 v2; // r13
const char *v3; // r12
const char *v4; // rax
int v5; // er8
__int64 result; // rax

v2 = node_cons_car();
v3 = (const char *)node_symbol_name(*a2);
v4 = (const char *)node_symbol_name(v2);
v5 = strcmp(v4, v3);
result = 0LL;
if ( !v5 )
{
a2[1] = a1;
result = 1LL;
}
return result;
}

original_code:
static int find_keyval(node_t *kv, void *p)
{
 struct kv_find *info = (struct kv_find *) p;
 node_t *testkey;
 testkey = node_cons_car(kv);
 if(!strcmp(node_symbol_name(testkey), node_symbol_name(info->key))) {
  info->keyval = kv;
  return 1;
 }
 return 0;
}

canonical_original_code:
static int find_keyval(struct node *kv, void *p)
{
 struct kv_find *info = (struct kv_find *) p;
 struct node *testkey;
 testkey = node_cons_car(kv);
 if(!strcmp(node_symbol_name(testkey), node_symbol_name(info->key))) {
  info->keyval = kv;
  return 1;
 }
 return 0;
}

variable_types:
p
void *

variable_types: struct kv_find { struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *key; struct node *keyval; } *

return_type: int


decompiled_code:
__int64 __fastcall print_env_cb(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v4; // [rsp+0h] [rbp-28h] BYREF

v2 = fmt_ptr(&v4, a1);
stream_put(a2, "env frame @ ", v2, &unk_23F, &unk_23D, 0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v4; // [rsp+0h] [rbp-28h] BYREF

v2 = fmt_ptr(&v4, a1);
stream_put(a2, "env frame @ ", v2, &unk_23F, &unk_23D, 0LL);
return 0LL;
}

original_code:
static int print_env_cb(node_t *env, void *p)
{
 char buf[17];
 stream_t *s = (stream_t *) p;
 _stream_put(s, "env frame @ ", fmt_ptr(buf, env), ":", "\n", ((void *)0));
 return 0;
}

canonical_original_code:
static int print_env_cb(struct node *env, void *p)
{
 char buf[17];
 struct stream_t *s = (stream_t *) p;
 _stream_put(s, "env frame @ ", fmt_ptr(buf, env), ":", "\n", ((void *)0));
 return 0;
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *

variable_types:
buf
char [17]


decompiled_code:
__int64 __fastcall environ_pushframe(__int64 a1)
{
return frame_push(a1, 0LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return frame_push(a1, 0LL, 0LL, 0LL);
}

original_code:
void environ_pushframe(node_t *env_handle)
{
 frame_push(env_handle, ((void *)0), ((void *)0), 0);
}

canonical_original_code:
void environ_pushframe(struct node *env_handle)
{
 frame_push(env_handle, ((void *)0), ((void *)0), 0);
}

return_type: void

user_defined_types: enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 }

user_defined_types: enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 }

user_defined_types: enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 }

user_defined_types: struct dlnode { struct dlnode *prev; struct dlist *owner; }

user_defined_types: struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; }


decompiled_code:
__int64 __fastcall environ_popframe(__int64 a1)
{
return frame_pop(a1, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return frame_pop(a1, 0LL, 0LL);
}

original_code:
void environ_popframe(node_t *env_handle)
{
 frame_pop(env_handle, ((void *)0), 0);
}

canonical_original_code:
void environ_popframe(struct node *env_handle)
{
 frame_pop(env_handle, ((void *)0), 0);
}


decompiled_code:
__int64 __fastcall environ_add(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rax

v4 = data_to_memstate();
v5 = node_cons_new(v4, a2, a3);
return frame_add_elem(a1, v5);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rax

v4 = data_to_memstate();
v5 = node_cons_new(v4, a2, a3);
return frame_add_elem(a1, v5);
}

original_code:
void environ_add(node_t *env_handle, node_t *key, node_t *val)
{
 memory_state_t *ms = data_to_memstate(env_handle);
 frame_add_elem(env_handle, node_cons_new(ms, key, val));
}

canonical_original_code:
void environ_add(struct node *env_handle, struct node *key, struct node *val)
{
 struct memory_state *ms = data_to_memstate(env_handle);
 frame_add_elem(env_handle, node_cons_new(ms, key, val));
}

variable_types:
val
struct node *

variable_types: struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *


decompiled_code:
bool __fastcall environ_keyval_frame(__int64 a1, __int64 a2, _QWORD *a3)
{
return environ_find(a1, a2, 0, a3);
}

canonical_decompiled_code:
bool __fastcall func7(__int64 a1, __int64 a2, _QWORD *a3)
{
return func0(a1, a2, 0, a3);
}

original_code:
_Bool environ_keyval_frame(node_t *env_handle, node_t *key, node_t **keyval)
{
 return environ_find(env_handle, key, 0, keyval);
}

canonical_original_code:
_Bool environ_keyval_frame(struct node *env_handle, struct node *key, struct node **keyval)
{
 return environ_find(env_handle, key, 0, keyval);
}


decompiled_code:
bool __fastcall environ_keyval(__int64 a1, __int64 a2, _QWORD *a3)
{
return environ_find(a1, a2, 1u, a3);
}

canonical_decompiled_code:
bool __fastcall func8(__int64 a1, __int64 a2, _QWORD *a3)
{
return func0(a1, a2, 1u, a3);
}

original_code:
_Bool environ_keyval(node_t *env_handle, node_t *key, node_t **keyval)
{
 return environ_find(env_handle, key, 1, keyval);
}

canonical_original_code:
_Bool environ_keyval(struct node *env_handle, struct node *key, struct node **keyval)
{
 return environ_find(env_handle, key, 1, keyval);
}


decompiled_code:
__int64 __fastcall environ_lookup(__int64 a1, __int64 a2, _QWORD *a3)
{
unsigned int v4; // eax
unsigned int v5; // er12
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

LOBYTE(v4) = environ_find(a1, a2, 1u, v7);
v5 = v4;
if ( a3 )
*a3 = node_cons_cdr(v7[0]);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, _QWORD *a3)
{
unsigned int v4; // eax
unsigned int v5; // er12
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

LOBYTE(v4) = func0(a1, a2, 1u, v7);
v5 = v4;
if ( a3 )
*a3 = node_cons_cdr(v7[0]);
return v5;
}

original_code:
_Bool environ_lookup(node_t *env_handle, node_t *key, node_t **val)
{
 int status;
 node_t *keyval;
 status = environ_find(env_handle, key, 1, &keyval);
 if(val) {
  *val = node_cons_cdr(keyval);
 }
 return status != 0;
}

canonical_original_code:
_Bool environ_lookup(struct node *env_handle, struct node *key, struct node **val)
{
 int status;
 struct node *keyval;
 status = environ_find(env_handle, key, 1, &keyval);
 if(val) {
  *val = node_cons_cdr(keyval);
 }
 return status != 0;
}

variable_types:
val
struct node **


decompiled_code:
__int64 __fastcall environ_print(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7)
{
return frame_iterate(a1, print_val_cb, a2, 1LL, print_env_cb, a2, a7);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7)
{
return frame_iterate(a1, print_val_cb, a2, 1LL, print_env_cb, a2, a7);
}

original_code:
void environ_print(node_t *env_handle, stream_t *stream)
{
 frame_iterate(env_handle,
               print_val_cb, stream, 1,
               print_env_cb, stream);
}

canonical_original_code:
void environ_print(struct node *env_handle, struct stream_t *stream)
{
 frame_iterate(env_handle,
               print_val_cb, stream, 1,
               print_env_cb, stream);
}

variable_types:
stream
struct stream_t *


decompiled_code:
__int64 __fastcall parse_atom(_QWORD *a1, __int64 *a2)
{
int v2; // eax
__int64 v3; // rax
__int64 v4; // rax
__int64 v6; // rax

v2 = token_type(a1[1]);
if ( v2 == 4 )
{
v6 = token_sym(a1[1]);
v4 = node_symbol_new(*a1, v6);
*a2 = v4;
}
else
{
if ( v2 != 5 )
return 5LL;
v3 = token_lit(a1[1]);
v4 = node_value_new(*a1, v3);
*a2 = v4;
}
if ( !v4 )
_assert_fail("*result", "parse.c", 0x1Cu, "parse_atom");
token_chomp(a1[1]);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, __int64 *a2)
{
int v2; // eax
__int64 v3; // rax
__int64 v4; // rax
__int64 v6; // rax

v2 = token_type(a1[1]);
if ( v2 == 4 )
{
v6 = token_sym(a1[1]);
v4 = node_symbol_new(*a1, v6);
*a2 = v4;
}
else
{
if ( v2 != 5 )
return 5LL;
v3 = token_lit(a1[1]);
v4 = node_value_new(*a1, v3);
*a2 = v4;
}
if ( !v4 )
_assert_fail("*result", "parse.c", 0x1Cu, "parse_atom");
token_chomp(a1[1]);
return 0LL;
}

original_code:
static
parse_err_t parse_atom(parse_state_t *state, node_t **result)
{
 switch(token_type(state->ts)) {
 case TOK_SYM:
  *result = node_symbol_new(state->ms, token_sym(state->ts));
  break;
 case TOK_LIT:
  *result = node_value_new(state->ms, token_lit(state->ts));
  break;
 default:
  return PARSE_EXPECTED_ATOM;
 }
 ((*result) ? (void) (0) : __assert_fail ("*result", "parse.c", 28, __extension__ __PRETTY_FUNCTION__));
 token_chomp(state->ts);
 return PARSE_OK;
}

canonical_original_code:
static enum parse_err_t parse_atom(struct parse_state_t *state, struct node **result)
{
 switch(token_type(state->ts)) {
 case TOK_SYM:
  *result = node_symbol_new(state->ms, token_sym(state->ts));
  break;
 case TOK_LIT:
  *result = node_value_new(state->ms, token_lit(state->ts));
  break;
 default:
  return PARSE_EXPECTED_ATOM;
 }
 ((*result) ? (void) (0) : __assert_fail ("*result", "parse.c", 28, __extension__ __PRETTY_FUNCTION__));
 token_chomp(state->ts);
 return PARSE_OK;
}

variable_types: struct parse_state_t { struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *ms; struct tok_state_t { enum toktype_t { TOK_INIT=0, TOK_LPAREN=1, TOK_RPAREN=2, TOK_DOT=3, TOK_SYM=4, TOK_LIT=5, TOK_END=6 } type; _Bool in_string; long stream_off; union { char sym[-1]; long lit; } u; int nextch; struct stream_t *stream; } *ts; } *

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } **

return_type: enum parse_err_t { PARSE_OK=0, PARSE_UNEXPECTED_DOT=1, PARSE_UNEXPECTED_RPAREN=2, PARSE_TOKEN_UNDERFLOW=3, PARSE_EXPECTED_RPAREN=4, PARSE_EXPECTED_ATOM=5, PARSE_EXPECTED_LPAREN_ATOM=6, PARSE_END=7 }

user_defined_types: struct parse_state_t { struct memory_state *ms; struct tok_state_t *ts; }

user_defined_types: struct tok_state_t { enum toktype_t type; _Bool in_string; long stream_off; union { char sym[-1]; long lit; } u; int nextch; struct stream_t *stream; }


decompiled_code:
__int64 __fastcall parse_list(_QWORD *a1, _QWORD *a2)
{
__int64 v3; // rdi
unsigned int v4; // eax
unsigned int v5; // er12
__int64 result; // rax
int v7; // eax
__int64 v8; // [rsp+0h] [rbp-28h] BYREF
__int64 v9[4]; // [rsp+8h] [rbp-20h] BYREF

v3 = a1[1];
v8 = 0LL;
v9[0] = 0LL;
v4 = token_type(v3);
v5 = v4;
switch ( v4 )
{
case 3u:
token_chomp(a1[1]);
v7 = token_type(a1[1]);
if ( v7 == 3 )
return 1;
if ( v7 != 6 )
{
v5 = 2;
if ( v7 != 2 )
v5 = parse_sexpr(a1, a2);
}
return v5;
case 6u:
*a2 = 0LL;
result = 3LL;
break;
case 2u:
*a2 = 0LL;
result = 0LL;
break;
default:
v5 = parse_sexpr(a1, &v8);
if ( !v5 )
{
v5 = parse_list(a1, v9);
if ( v5 )
node_droproot(v9[0]);
else
*a2 = node_cons_new(*a1, v8, v9[0]);
}
return v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, _QWORD *a2)
{
__int64 v3; // rdi
unsigned int v4; // eax
unsigned int v5; // er12
__int64 result; // rax
int v7; // eax
__int64 v8; // [rsp+0h] [rbp-28h] BYREF
__int64 v9[4]; // [rsp+8h] [rbp-20h] BYREF

v3 = a1[1];
v8 = 0LL;
v9[0] = 0LL;
v4 = token_type(v3);
v5 = v4;
switch ( v4 )
{
case 3u:
token_chomp(a1[1]);
v7 = token_type(a1[1]);
if ( v7 == 3 )
return 1;
if ( v7 != 6 )
{
v5 = 2;
if ( v7 != 2 )
v5 = func2(a1, a2);
}
return v5;
case 6u:
*a2 = 0LL;
result = 3LL;
break;
case 2u:
*a2 = 0LL;
result = 0LL;
break;
default:
v5 = func2(a1, &v8);
if ( !v5 )
{
v5 = func1(a1, v9);
if ( v5 )
node_droproot(v9[0]);
else
*a2 = node_cons_new(*a1, v8, v9[0]);
}
return v5;
}
return result;
}

original_code:
static
parse_err_t parse_list(parse_state_t *state, node_t **result)
{
 parse_err_t status = PARSE_OK;
 node_t *child = ((void *)0), *next = ((void *)0);
 switch(token_type(state->ts)) {
 case TOK_END:
  status = PARSE_TOKEN_UNDERFLOW;
  *result = ((void *)0);
  break;
 case TOK_RPAREN:
  *result = ((void *)0);
  break;
 case TOK_DOT:
  token_chomp(state->ts);
  switch(token_type(state->ts)) {
  case TOK_END:
   status = PARSE_TOKEN_UNDERFLOW;
   break;
  case TOK_RPAREN:
   status = PARSE_UNEXPECTED_RPAREN;
   break;
  case TOK_DOT:
   status = PARSE_UNEXPECTED_DOT;
   break;
  default:
   status = parse_sexpr(state, result);
   break;
  }
  break;
 default:
  status = parse_sexpr(state, &child);
  if(status == PARSE_OK) {
   status = parse_list(state, &next);
   if(status == PARSE_OK) {
    *result = node_cons_new(state->ms, child, next);
   } else {
    node_droproot(next);
   }
  }
 }
 return status;
}

canonical_original_code:
static enum parse_err_t parse_list(struct parse_state_t *state, struct node **result)
{
 enum parse_err_t status = PARSE_OK;
 struct node *child = ((void *)0); struct node *next = ((void *)0);
 switch(token_type(state->ts)) {
 case TOK_END:
  status = PARSE_TOKEN_UNDERFLOW;
  *result = ((void *)0);
  break;
 case TOK_RPAREN:
  *result = ((void *)0);
  break;
 case TOK_DOT:
  token_chomp(state->ts);
  switch(token_type(state->ts)) {
  case TOK_END:
   status = PARSE_TOKEN_UNDERFLOW;
   break;
  case TOK_RPAREN:
   status = PARSE_UNEXPECTED_RPAREN;
   break;
  case TOK_DOT:
   status = PARSE_UNEXPECTED_DOT;
   break;
  default:
   status = parse_sexpr(state, result);
   break;
  }
  break;
 default:
  status = parse_sexpr(state, &child);
  if(status == PARSE_OK) {
   status = parse_list(state, &next);
   if(status == PARSE_OK) {
    *result = node_cons_new(state->ms, child, next);
   } else {
    node_droproot(next);
   }
  }
 }
 return status;
}

variable_types: enum parse_err_t { PARSE_OK=0, PARSE_UNEXPECTED_DOT=1, PARSE_UNEXPECTED_RPAREN=2, PARSE_TOKEN_UNDERFLOW=3, PARSE_EXPECTED_RPAREN=4, PARSE_EXPECTED_ATOM=5, PARSE_EXPECTED_LPAREN_ATOM=6, PARSE_END=7 }

user_defined_types: enum toktype_t { TOK_INIT=0, TOK_LPAREN=1, TOK_RPAREN=2, TOK_DOT=3, TOK_SYM=4, TOK_LIT=5, TOK_END=6 }


decompiled_code:
__int64 __fastcall parse_sexpr(_QWORD *a1, _QWORD *a2)
{
__int64 v3; // rdi
unsigned int v4; // eax
unsigned int v5; // er12
int v6; // eax
unsigned int v7; // er12
int v8; // eax
__int64 v10[4]; // [rsp+8h] [rbp-20h] BYREF

v3 = a1[1];
v10[0] = 0LL;
v4 = token_type(v3);
v5 = v4;
if ( v4 > 5 )
{
if ( v4 == 6 )
return 7LL;
goto LABEL_12;
}
if ( v4 > 3 )
{
v7 = parse_atom(a1, v10);
goto LABEL_15;
}
if ( v4 != 1 )
{
LABEL_12:
v5 = 6;
goto LABEL_13;
}
token_chomp(a1[1]);
v6 = token_type(a1[1]);
switch ( v6 )
{
case 3:
goto LABEL_13;
case 6:
LABEL_9:
v5 = 3;
goto LABEL_13;
case 2:
v7 = 0;
token_chomp(a1[1]);
break;
default:
v7 = parse_list(a1, v10);
v8 = token_type(a1[1]);
if ( v8 != 2 )
{
v5 = 4;
if ( v8 == 6 )
goto LABEL_9;
LABEL_13:
node_droproot(v10[0]);
return v5;
}
token_chomp(a1[1]);
break;
}
LABEL_15:
*a2 = v10[0];
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, _QWORD *a2)
{
__int64 v3; // rdi
unsigned int v4; // eax
unsigned int v5; // er12
int v6; // eax
unsigned int v7; // er12
int v8; // eax
__int64 v10[4]; // [rsp+8h] [rbp-20h] BYREF

v3 = a1[1];
v10[0] = 0LL;
v4 = token_type(v3);
v5 = v4;
if ( v4 > 5 )
{
if ( v4 == 6 )
return 7LL;
goto LABEL_12;
}
if ( v4 > 3 )
{
v7 = func0(a1, v10);
goto LABEL_15;
}
if ( v4 != 1 )
{
LABEL_12:
v5 = 6;
goto LABEL_13;
}
token_chomp(a1[1]);
v6 = token_type(a1[1]);
switch ( v6 )
{
case 3:
goto LABEL_13;
case 6:
LABEL_9:
v5 = 3;
goto LABEL_13;
case 2:
v7 = 0;
token_chomp(a1[1]);
break;
default:
v7 = func1(a1, v10);
v8 = token_type(a1[1]);
if ( v8 != 2 )
{
v5 = 4;
if ( v8 == 6 )
goto LABEL_9;
LABEL_13:
node_droproot(v10[0]);
return v5;
}
token_chomp(a1[1]);
break;
}
LABEL_15:
*a2 = v10[0];
return v7;
}

original_code:
static
parse_err_t parse_sexpr(parse_state_t *state, node_t **result)
{
 node_t *ret = ((void *)0);
 parse_err_t status = PARSE_OK;
 switch(token_type(state->ts)) {
 case TOK_END:
  return PARSE_END;
 case TOK_SYM:
 case TOK_LIT:
  status = parse_atom(state, &ret);
  break;
 case TOK_LPAREN:
  token_chomp(state->ts);
  switch(token_type(state->ts)) {
  case TOK_END:
   status = PARSE_TOKEN_UNDERFLOW;
   goto error;
  case TOK_RPAREN:
   token_chomp(state->ts);
   *result = ((void *)0);
   goto tok_lparen_finish;
  case TOK_DOT:
   status = PARSE_UNEXPECTED_DOT;
   goto error;
  default:
   break;
  }
  status = parse_list(state, &ret);
  switch(token_type(state->ts)) {
  case TOK_END:
   status = PARSE_TOKEN_UNDERFLOW;
   goto error;
  case TOK_RPAREN:
   token_chomp(state->ts);
   break;
  default:
   status = PARSE_EXPECTED_RPAREN;
   goto error;
  }
tok_lparen_finish:
  break;
 default:
  status = PARSE_EXPECTED_LPAREN_ATOM;
  goto error;
 }
 *result = ret;
 return status;
error:
 node_droproot(ret);
 return status;
}

canonical_original_code:
static enum parse_err_t parse_sexpr(struct parse_state_t *state, struct node **result)
{
 struct node *ret = ((void *)0);
 enum parse_err_t status = PARSE_OK;
 switch(token_type(state->ts)) {
 case TOK_END:
  return PARSE_END;
 case TOK_SYM:
 case TOK_LIT:
  status = parse_atom(state, &ret);
  break;
 case TOK_LPAREN:
  token_chomp(state->ts);
  switch(token_type(state->ts)) {
  case TOK_END:
   status = PARSE_TOKEN_UNDERFLOW;
   goto error;
  case TOK_RPAREN:
   token_chomp(state->ts);
   *result = ((void *)0);
   goto tok_lparen_finish;
  case TOK_DOT:
   status = PARSE_UNEXPECTED_DOT;
   goto error;
  default:
   break;
  }
  status = parse_list(state, &ret);
  switch(token_type(state->ts)) {
  case TOK_END:
   status = PARSE_TOKEN_UNDERFLOW;
   goto error;
  case TOK_RPAREN:
   token_chomp(state->ts);
   break;
  default:
   status = PARSE_EXPECTED_RPAREN;
   goto error;
  }
tok_lparen_finish:
  break;
 default:
  status = PARSE_EXPECTED_LPAREN_ATOM;
  goto error;
 }
 *result = ret;
 return status;
error:
 node_droproot(ret);
 return status;
}

user_defined_types: enum parse_err_t { PARSE_OK=0, PARSE_UNEXPECTED_DOT=1, PARSE_UNEXPECTED_RPAREN=2, PARSE_TOKEN_UNDERFLOW=3, PARSE_EXPECTED_RPAREN=4, PARSE_EXPECTED_ATOM=5, PARSE_EXPECTED_LPAREN_ATOM=6, PARSE_END=7 }


parse

decompiled_code:
__int64 __fastcall parse(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v4; // er12
__int64 v6; // [rsp+8h] [rbp-30h] BYREF
__int64 v7; // [rsp+10h] [rbp-28h] BYREF
__int64 v8; // [rsp+18h] [rbp-20h]

v6 = 0LL;
v7 = a1;
v8 = a2;
if ( !(unsigned int)token_type(a2) )
token_chomp(v8);
v4 = parse_sexpr(&v7, &v6);
node_handle_update(a3, v6);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v4; // er12
__int64 v6; // [rsp+8h] [rbp-30h] BYREF
__int64 v7; // [rsp+10h] [rbp-28h] BYREF
__int64 v8; // [rsp+18h] [rbp-20h]

v6 = 0LL;
v7 = a1;
v8 = a2;
if ( !(unsigned int)token_type(a2) )
token_chomp(v8);
v4 = func2(&v7, &v6);
node_handle_update(a3, v6);
return v4;
}

original_code:
parse_err_t parse(memory_state_t *ms, tok_state_t *ts, node_t *out_hdl)
{
 parse_err_t status = PARSE_OK;
 node_t *result = ((void *)0);
 parse_state_t state = { .ms = ms, .ts = ts };
 if(token_type(state.ts) == TOK_INIT) {
  token_chomp(state.ts);
 }
 status = parse_sexpr(&state, &result);
 node_handle_update(out_hdl, result);
 return status;
}

canonical_original_code:
enum parse_err_t parse(struct memory_state *ms, struct tok_state_t *ts, struct node *out_hdl)
{
 enum parse_err_t status = PARSE_OK;
 struct node *result = ((void *)0);
 struct parse_state_t state = { .ms = ms, .ts = ts };
 if(token_type(state.ts) == TOK_INIT) {
  token_chomp(state.ts);
 }
 status = parse_sexpr(&state, &result);
 node_handle_update(out_hdl, result);
 return status;
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *

variable_types: struct parse_state_t { struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *ms; struct tok_state_t { enum toktype_t { TOK_INIT=0, TOK_LPAREN=1, TOK_RPAREN=2, TOK_DOT=3, TOK_SYM=4, TOK_LIT=5, TOK_END=6 } type; _Bool in_string; long stream_off; union { char sym[-1]; long lit; } u; int nextch; struct stream_t *stream; } *ts; }


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

result = "unknown error";
if ( a1 <= 7 )
result = parse_err_messages[a1];
return result;
}

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

result = "unknown error";
if ( a1 <= 7 )
result = parse_err_messages[a1];
return result;
}

original_code:
char *parse_err_str(parse_err_t err)
{
 if(err >= sizeof(parse_err_messages) / sizeof(parse_err_messages[0])) {
  return "unknown error";
 }
 return parse_err_messages[err];
}

canonical_original_code:
char *parse_err_str(enum parse_err_t err)
{
 if(err >= sizeof(parse_err_messages) / sizeof(parse_err_messages[0])) {
  return "unknown error";
 }
 return parse_err_messages[err];
}

return_type: char *


decompiled_code:
__int64 __fastcall print_frm_cb(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v4; // [rsp+0h] [rbp-38h] BYREF

v2 = fmt_ptr(&v4, a1);
stream_put(a2, "frame @ ", v2, &unk_43D, 0LL);
node_print_stream(a2, a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v4; // [rsp+0h] [rbp-38h] BYREF

v2 = fmt_ptr(&v4, a1);
stream_put(a2, "frame @ ", v2, &unk_43D, 0LL);
node_print_stream(a2, a1);
return 0LL;
}

original_code:
static int print_frm_cb(node_t *n, void *p)
{
 stream_t *s = (stream_t *) p;
 char buf[17];
 _stream_put(s, "frame @ ", fmt_ptr(buf, n), "\n", ((void *)0));
 node_print_stream(s, n);
 return 0;
}

canonical_original_code:
static int print_frm_cb(struct node *n, void *p)
{
 struct stream_t *s = (stream_t *) p;
 char buf[17];
 _stream_put(s, "frame @ ", fmt_ptr(buf, n), "\n", ((void *)0));
 node_print_stream(s, n);
 return 0;
}

variable_types: struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *


decompiled_code:
__int64 __fastcall frame_push(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // r12
__int64 v7; // r13
__int64 v8; // rbx
__int64 v9; // rax
__int64 v11; // rax
__int64 v12; // rax

v5 = 0LL;
v7 = data_to_memstate();
v8 = a4 - 1;
if ( v8 >= 0 )
{
do
{
v9 = node_handle(*(_QWORD *)(a2 + 8 * v8));
v5 = node_cons_new(v7, v9, v5);
node_handle_update(*(_QWORD *)(a2 + 8 * v8), *(_QWORD *)(a3 + 8 * v8));
}
while ( v8-- != 0 );
}
v11 = node_handle(a1);
v12 = node_cons_new(v7, v5, v11);
return node_handle_update(a1, v12);
}

original_code:
void frame_push(
 node_t *frame_hdl,
 node_t **locals,
 node_t **newvals,
 size_t n)
{
 ssize_t i;
 node_t *cursor = ((void *)0);
 memory_state_t *ms = data_to_memstate(frame_hdl);
 for(i = n - 1; i >= 0; i--) {
  cursor = node_cons_new(ms, node_handle(locals[i]), cursor);
  node_handle_update(locals[i], newvals[i]);
 }
 cursor = node_cons_new(ms, cursor, node_handle(frame_hdl));
 node_handle_update(frame_hdl, cursor);
}

canonical_original_code:
void frame_push(struct node *frame_hdl, struct node **locals, struct node **newvals, unsigned long n)
{
 long i;
 struct node *cursor = ((void *)0);
 struct memory_state *ms = data_to_memstate(frame_hdl);
 for(i = n - 1; i >= 0; i--) {
  cursor = node_cons_new(ms, node_handle(locals[i]), cursor);
  node_handle_update(locals[i], newvals[i]);
 }
 cursor = node_cons_new(ms, cursor, node_handle(frame_hdl));
 node_handle_update(frame_hdl, cursor);
}

variable_types:
locals
struct node **

variable_types:
newvals
struct node **

variable_types:
n
unsigned long

variable_types: i long


decompiled_code:
__int64 __fastcall frame_pop(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // r14
__int64 v9; // rax
__int64 v10; // rdi
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax

v5 = node_handle(a1);
v6 = node_cons_car(v5);
if ( a3 )
{
v7 = v6;
if ( !v6 )
LABEL_7:
_assert_fail("cursor", "frame.c", 0x25u, "frame_pop");
v8 = 0LL;
while ( 1 )
{
v9 = node_cons_car(v7);
v10 = *(_QWORD *)(a2 + 8 * v8++);
node_handle_update(v10, v9);
v11 = node_cons_cdr(v7);
v7 = v11;
if ( a3 == v8 )
break;
if ( !v11 )
goto LABEL_7;
}
}
v12 = node_handle(a1);
v13 = node_cons_cdr(v12);
return node_handle_update(a1, v13);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // r14
__int64 v9; // rax
__int64 v10; // rdi
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax

v5 = node_handle(a1);
v6 = node_cons_car(v5);
if ( a3 )
{
v7 = v6;
if ( !v6 )
LABEL_7:
_assert_fail("cursor", "frame.c", 0x25u, "frame_pop");
v8 = 0LL;
while ( 1 )
{
v9 = node_cons_car(v7);
v10 = *(_QWORD *)(a2 + 8 * v8++);
node_handle_update(v10, v9);
v11 = node_cons_cdr(v7);
v7 = v11;
if ( a3 == v8 )
break;
if ( !v11 )
goto LABEL_7;
}
}
v12 = node_handle(a1);
v13 = node_cons_cdr(v12);
return node_handle_update(a1, v13);
}

original_code:
void frame_pop(
 node_t *frame_hdl,
 node_t **locals,
 size_t n)
{
 size_t i;
 node_t *cursor;
 cursor = node_cons_car(node_handle(frame_hdl));
 for(i = 0; i < n; i++) {
  ((cursor) ? (void) (0) : __assert_fail ("cursor", "frame.c", 37, __extension__ __PRETTY_FUNCTION__));
  node_handle_update(locals[i], node_cons_car(cursor));
  cursor = node_cons_cdr(cursor);
 }
 node_handle_update(frame_hdl, node_cons_cdr(node_handle(frame_hdl)));
}

canonical_original_code:
void frame_pop(struct node *frame_hdl, struct node **locals, unsigned long n)
{
 unsigned long i;
 struct node *cursor;
 cursor = node_cons_car(node_handle(frame_hdl));
 for(i = 0; i < n; i++) {
  ((cursor) ? (void) (0) : __assert_fail ("cursor", "frame.c", 37, __extension__ __PRETTY_FUNCTION__));
  node_handle_update(locals[i], node_cons_car(cursor));
  cursor = node_cons_cdr(cursor);
 }
 node_handle_update(frame_hdl, node_cons_cdr(node_handle(frame_hdl)));
}

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall frame_restore(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
node_handle_update(a1, a4);
return frame_pop(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
node_handle_update(a1, a4);
return func3(a1, a2, a3);
}

original_code:
void frame_restore(
 node_t *frame_hdl,
 node_t **locals,
 size_t n,
 node_t *snapshot)
{
 node_handle_update(frame_hdl, snapshot);
 frame_pop(frame_hdl, locals, n);
}

canonical_original_code:
void frame_restore(struct node *frame_hdl, struct node **locals, unsigned long n, struct node *snapshot)
{
 node_handle_update(frame_hdl, snapshot);
 frame_pop(frame_hdl, locals, n);
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *

variable_types:
snapshot
struct node *


decompiled_code:
__int64 __fastcall frame_add_elem(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // r13
__int64 v4; // r15
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // rax

v2 = data_to_memstate();
v3 = node_handle(a1);
v4 = node_cons_car(v3);
v5 = node_cons_cdr(v3);
v6 = node_cons_new(v2, a2, v4);
v7 = node_cons_new(v2, v6, v5);
return node_handle_update(a1, v7);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // r13
__int64 v4; // r15
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // rax

v2 = data_to_memstate();
v3 = node_handle(a1);
v4 = node_cons_car(v3);
v5 = node_cons_cdr(v3);
v6 = node_cons_new(v2, a2, v4);
v7 = node_cons_new(v2, v6, v5);
return node_handle_update(a1, v7);
}

original_code:
void frame_add_elem(
 node_t *frame_hdl,
 node_t *val)
{
 memory_state_t *ms = data_to_memstate(frame_hdl);
 node_t *oldframe = node_handle(frame_hdl);
 node_t *nextent = node_cons_car(oldframe);
 node_t *nextfrm = node_cons_cdr(oldframe);
 node_t *newent = node_cons_new(ms, val, nextent);
 node_t *newframe = node_cons_new(ms, newent, nextfrm);
 node_handle_update(frame_hdl, newframe);
}

canonical_original_code:
void frame_add_elem(struct node *frame_hdl, struct node *val)
{
 struct memory_state *ms = data_to_memstate(frame_hdl);
 struct node *oldframe = node_handle(frame_hdl);
 struct node *nextent = node_cons_car(oldframe);
 struct node *nextfrm = node_cons_cdr(oldframe);
 struct node *newent = node_cons_new(ms, val, nextent);
 struct node *newframe = node_cons_new(ms, newent, nextfrm);
 node_handle_update(frame_hdl, newframe);
}

variable_types:
val
struct node *


decompiled_code:
__int64 __fastcall frame_iterate(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3, char a4, __int64 (__fastcall *a5)(__int64, __int64), __int64 a6)
{
__int64 v9; // rbp
__int64 result; // rax
__int64 v11; // r14
__int64 v12; // rax

v9 = node_handle(a1);
while ( 1 )
{
if ( !v9 )
return 0LL;
if ( (unsigned int)node_type(v9) != 2 )
_assert_fail("node_type(frame_curs) == NODE_CONS", "frame.c", 0x57u, "frame_iterate");
if ( a5 )
{
result = a5(v9, a6);
if ( (_DWORD)result )
return result;
}
if ( a2 )
{
v11 = node_cons_car(v9);
if ( v11 )
break;
}
LABEL_7:
v9 = node_cons_cdr(v9);
if ( !a4 )
return 0LL;
}
while ( 1 )
{
if ( (unsigned int)node_type(v11) != 2 )
_assert_fail("node_type(var_curs) == NODE_CONS", "frame.c", 0x63u, "frame_iterate");
v12 = node_cons_car(v11);
result = a2(v12, a3);
if ( (_DWORD)result )
return result;
v11 = node_cons_cdr(v11);
if ( !v11 )
goto LABEL_7;
}
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3, char a4, __int64 (__fastcall *a5)(__int64, __int64), __int64 a6)
{
__int64 v9; // rbp
__int64 result; // rax
__int64 v11; // r14
__int64 v12; // rax

v9 = node_handle(a1);
while ( 1 )
{
if ( !v9 )
return 0LL;
if ( (unsigned int)node_type(v9) != 2 )
_assert_fail("node_type(frame_curs) == NODE_CONS", "frame.c", 0x57u, "frame_iterate");
if ( a5 )
{
result = a5(v9, a6);
if ( (_DWORD)result )
return result;
}
if ( a2 )
{
v11 = node_cons_car(v9);
if ( v11 )
break;
}
LABEL_7:
v9 = node_cons_cdr(v9);
if ( !a4 )
return 0LL;
}
while ( 1 )
{
if ( (unsigned int)node_type(v11) != 2 )
_assert_fail("node_type(var_curs) == NODE_CONS", "frame.c", 0x63u, "frame_iterate");
v12 = node_cons_car(v11);
result = a2(v12, a3);
if ( (_DWORD)result )
return result;
v11 = node_cons_cdr(v11);
if ( !v11 )
goto LABEL_7;
}
}

original_code:
int frame_iterate(
 node_t *frame_hdl,
 frm_cb_t e_cb, void *e_p,
 _Bool recursive,
 frm_cb_t f_cb, void *f_p)
{
 node_t *frame_curs, *var_curs, *val;
 int status;
 frame_curs = node_handle(frame_hdl);
restart:
 if(!frame_curs) {
  return 0;
 }
 ((node_type(frame_curs) == NODE_CONS) ? (void) (0) : __assert_fail ("node_type(frame_curs) == NODE_CONS", "frame.c", 87, __extension__ __PRETTY_FUNCTION__));
 if(f_cb) {
  if((status = f_cb(frame_curs, f_p))) {
   return status;
  }
 }
 if(e_cb) {
  for(var_curs = node_cons_car(frame_curs);
      var_curs;
      var_curs = node_cons_cdr(var_curs)) {
   ((node_type(var_curs) == NODE_CONS) ? (void) (0) : __assert_fail ("node_type(var_curs) == NODE_CONS", "frame.c", 99, __extension__ __PRETTY_FUNCTION__));
   val = node_cons_car(var_curs);
   if((status = e_cb(val, e_p))) {
     return status;
   }
  }
 }
 frame_curs = node_cons_cdr(frame_curs);
 if(recursive) {
  goto restart;
 }
 return 0;
}

canonical_original_code:
int frame_iterate(struct node *frame_hdl, int (*e_cb)(struct node *n, void *p), void *e_p, _Bool recursive, int (*f_cb)(struct node *n, void *p), void *f_p)
{
 struct node *frame_curs; struct node *var_curs; struct node *val;
 int status;
 frame_curs = node_handle(frame_hdl);
restart:
 if(!frame_curs) {
  return 0;
 }
 ((node_type(frame_curs) == NODE_CONS) ? (void) (0) : __assert_fail ("node_type(frame_curs) == NODE_CONS", "frame.c", 87, __extension__ __PRETTY_FUNCTION__));
 if(f_cb) {
  if((status = f_cb(frame_curs, f_p))) {
   return status;
  }
 }
 if(e_cb) {
  for(var_curs = node_cons_car(frame_curs);
      var_curs;
      var_curs = node_cons_cdr(var_curs)) {
   ((node_type(var_curs) == NODE_CONS) ? (void) (0) : __assert_fail ("node_type(var_curs) == NODE_CONS", "frame.c", 99, __extension__ __PRETTY_FUNCTION__));
   val = node_cons_car(var_curs);
   if((status = e_cb(val, e_p))) {
     return status;
   }
  }
 }
 frame_curs = node_cons_cdr(frame_curs);
 if(recursive) {
  goto restart;
 }
 return 0;
}

variable_types: status int


decompiled_code:
void __fastcall frame_init(__int64 a1, __int64 a2, __int64 a3)
{
__int64 i; // rbx
__int64 v5; // rax

if ( a3 )
{
for ( i = 0LL; i != a3; ++i )
{
v5 = node_handle_new(a1, 0LL);
*(_QWORD *)(a2 + 8 * i) = node_lockroot(v5);
}
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
__int64 i; // rbx
__int64 v5; // rax

if ( a3 )
{
for ( i = 0LL; i != a3; ++i )
{
v5 = node_handle_new(a1, 0LL);
*(_QWORD *)(a2 + 8 * i) = node_lockroot(v5);
}
}
}

original_code:
void frame_init(
 memory_state_t *ms,
 node_t **locals_arr,
 size_t locals_len)
{
 size_t i;
 for(i = 0; i < locals_len; i++) {
  locals_arr[i] = node_lockroot(node_handle_new(ms, ((void *)0)));
 }
}

canonical_original_code:
void frame_init(struct memory_state *ms, struct node **locals_arr, unsigned long locals_len)
{
 unsigned long i;
 for(i = 0; i < locals_len; i++) {
  locals_arr[i] = node_lockroot(node_handle_new(ms, ((void *)0)));
 }
}

variable_types: struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *


decompiled_code:
__int64 __fastcall frame_deinit(__int64 a1, __int64 a2)
{
__int64 i; // rbx
__int64 v4; // rdi
__int64 result; // rax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
{
v4 = *(_QWORD *)(a1 + 8 * i);
result = node_droproot(v4);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 i; // rbx
__int64 v4; // rdi
__int64 result; // rax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
{
v4 = *(_QWORD *)(a1 + 8 * i);
result = node_droproot(v4);
}
}
return result;
}

original_code:
void frame_deinit(
 node_t **locals,
 size_t n)
{
 size_t i;
 for(i = 0; i < n; i++) {
  node_droproot(locals[i]);
 }
}

canonical_original_code:
void frame_deinit(struct node **locals, unsigned long n)
{
 unsigned long i;
 for(i = 0; i < n; i++) {
  node_droproot(locals[i]);
 }
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } **


decompiled_code:
__int64 __fastcall frame_print_bt(__int64 a1, __int64 a2)
{
return frame_iterate(a1, print_val_cb, a2, 1, print_frm_cb, a2);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
return func6(a1, print_val_cb, a2, 1, print_frm_cb, a2);
}

original_code:
void frame_print_bt(node_t *frame_hdl, stream_t *stream)
{
 frame_iterate(frame_hdl,
               print_val_cb, stream,
               1,
               print_frm_cb, stream);
}

canonical_original_code:
void frame_print_bt(struct node *frame_hdl, struct stream_t *stream)
{
 frame_iterate(frame_hdl,
               print_val_cb, stream,
               1,
               print_frm_cb, stream);
}

variable_types:
stream
struct stream_t *


decompiled_code:
__int64 __fastcall eval_err(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
return a1;
}

original_code: static eval_err_t eval_err(eval_err_t e) { return e; }

canonical_original_code: static enum eval_err_t eval_err(enum eval_err_t e) { return e; }

variable_types: enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 }


loadlibfn

decompiled_code:
__int64 __fastcall loadlibfn(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
__int64 v6; // rdi
unsigned int v7; // eax
_QWORD *v8; // r12
unsigned int v9; // er13
void *v11; // rsp
unsigned int v12; // eax
__int64 v13; // r14
__int64 v14; // rax
__int64 v15; // [rsp+0h] [rbp-30h] BYREF
void *ptr; // [rsp+8h] [rbp-28h] BYREF

v6 = *a2;
ptr = 0LL;
if ( (unsigned int)count_list_len(v6, &v15) )
{
v7 = eval_err(8u);
v8 = ptr;
v9 = v7;
}
else
{
v11 = alloca(v15 + 9);
if ( (unsigned int)list_to_cstr(*a2, &v15, v15 + 1, 0LL) || (unsigned int)load_wrapper(&v15, &ptr) )
{
v12 = eval_err(0xEu);
v8 = ptr;
v9 = v12;
}
else
{
if ( (unsigned int)node_type(a4) != 7 )
_assert_fail("node_type(env_handle) == NODE_HANDLE", "builtin_load.c", 0x32u, "loadlibfn");
v8 = ptr;
if ( ptr )
{
if ( *(_QWORD *)ptr )
{
do
{
v8 += 2;
v13 = node_symbol_new(a1);
v14 = node_foreign_new(a1, *(v8 - 1));
environ_add(a4, v13, v14);
}
while ( *v8 );
v8 = ptr;
}
v9 = 0;
}
else
{
v9 = eval_err(0xEu);
}
}
}
free(v8);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
__int64 v6; // rdi
unsigned int v7; // eax
_QWORD *v8; // r12
unsigned int v9; // er13
void *v11; // rsp
unsigned int v12; // eax
__int64 v13; // r14
__int64 v14; // rax
__int64 v15; // [rsp+0h] [rbp-30h] BYREF
void *ptr; // [rsp+8h] [rbp-28h] BYREF

v6 = *a2;
ptr = 0LL;
if ( (unsigned int)count_list_len(v6, &v15) )
{
v7 = func0(8u);
v8 = ptr;
v9 = v7;
}
else
{
v11 = alloca(v15 + 9);
if ( (unsigned int)list_to_cstr(*a2, &v15, v15 + 1, 0LL) || (unsigned int)load_wrapper(&v15, &ptr) )
{
v12 = func0(0xEu);
v8 = ptr;
v9 = v12;
}
else
{
if ( (unsigned int)node_type(a4) != 7 )
_assert_fail("node_type(env_handle) == NODE_HANDLE", "builtin_load.c", 0x32u, "loadlibfn");
v8 = ptr;
if ( ptr )
{
if ( *(_QWORD *)ptr )
{
do
{
v8 += 2;
v13 = node_symbol_new(a1);
v14 = node_foreign_new(a1, *(v8 - 1));
environ_add(a4, v13, v14);
}
while ( *v8 );
v8 = ptr;
}
v9 = 0;
}
else
{
v9 = func0(0xEu);
}
}
}
free(v8);
return v9;
}

original_code:
static eval_err_t loadlibfn(memory_state_t *ms, node_t **n, node_t **result, void *p)
{
 char *path = ((void *)0);
 size_t len;
 ldwrap_ent_t *ld_funs = ((void *)0), *ld_funs_cursor;
 eval_err_t status = EVAL_OK;
 node_t *cursor, *val;
 node_t *env_handle = (node_t *) p;
 if(count_list_len(n[0], &len) != 0) {
  status = eval_err(EVAL_ERR_EXPECTED_CONS);
  goto cleanup;
 }
 if(!(path = __builtin_alloca (len + 1))) {
  status = eval_err(EVAL_ERR_OUT_OF_MEM);
  goto cleanup;
 }
 if(list_to_cstr(n[0], path, len + 1, ((void *)0))) {
  status = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 if(load_wrapper(path, &ld_funs)) {
  status = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 ((node_type(env_handle) == NODE_HANDLE) ? (void) (0) : __assert_fail ("node_type(env_handle) == NODE_HANDLE", "builtin_load.c", 50, __extension__ __PRETTY_FUNCTION__));
 if(! ld_funs) {
  status = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 for(ld_funs_cursor = ld_funs; ld_funs_cursor->name; ld_funs_cursor++) {
  node_t *name, *val;
  name = node_symbol_new(ms, ld_funs_cursor->name);
  val = node_foreign_new(ms, ld_funs_cursor->fun);
  environ_add(env_handle, name, val);
 }
cleanup:
 free(ld_funs);
 return status;
}

canonical_original_code:
static enum eval_err_t loadlibfn(struct memory_state *ms, struct node **n, struct node **result, void *p)
{
 char *path = ((void *)0);
 unsigned long len;
 struct ldwrap_ent_t *ld_funs = ((void *)0); struct ldwrap_ent_t *ld_funs_cursor;
 enum eval_err_t status = EVAL_OK;
 struct node *cursor; struct node *val;
 struct node *env_handle = (node_t *) p;
 if(count_list_len(n[0], &len) != 0) {
  status = eval_err(EVAL_ERR_EXPECTED_CONS);
  goto cleanup;
 }
 if(!(path = __builtin_alloca (len + 1))) {
  status = eval_err(EVAL_ERR_OUT_OF_MEM);
  goto cleanup;
 }
 if(list_to_cstr(n[0], path, len + 1, ((void *)0))) {
  status = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 if(load_wrapper(path, &ld_funs)) {
  status = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 ((node_type(env_handle) == NODE_HANDLE) ? (void) (0) : __assert_fail ("node_type(env_handle) == NODE_HANDLE", "builtin_load.c", 50, __extension__ __PRETTY_FUNCTION__));
 if(! ld_funs) {
  status = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 for(ld_funs_cursor = ld_funs; ld_funs_cursor->name; ld_funs_cursor++) {
  struct node *name; struct node *val;
  name = node_symbol_new(ms, ld_funs_cursor->name);
  val = node_foreign_new(ms, ld_funs_cursor->fun);
  environ_add(env_handle, name, val);
 }
cleanup:
 free(ld_funs);
 return status;
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } **

variable_types:
result
struct node **

variable_types:
p
void *

variable_types:
path
char *

variable_types:
len
unsigned long

variable_types: struct ldwrap_ent_t { char *name; void *fun; } *


readevalfn

decompiled_code:
__int64 __fastcall readevalfn(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
unsigned int v6; // edi
__int64 i; // r14
__int64 v8; // r15
unsigned int v9; // er12
void *v11; // rsp
int v12; // eax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
unsigned int v16; // er12
unsigned int v17; // ebx
char *v18; // rax
__int64 v19; // r8
const char *v20; // rsi
char *v21; // rcx
unsigned int v22; // ebx
char *v23; // rax
unsigned int v24; // ebx
char *v25; // rax
__int64 v26; // rbx
__int64 v27; // rax
const char *v28; // rax
__int64 v29; // rax
const char *v30; // rax
__int64 v31; // [rsp+0h] [rbp-110h] BYREF
char *v32; // [rsp+8h] [rbp-108h]
__int64 v33; // [rsp+18h] [rbp-F8h] BYREF
char v34[8]; // [rsp+20h] [rbp-F0h] BYREF
__int64 v35; // [rsp+28h] [rbp-E8h]
__int64 v36; // [rsp+30h] [rbp-E0h]
int errnum; // [rsp+38h] [rbp-D8h]
char v38[64]; // [rsp+40h] [rbp-D0h] BYREF
char v39[144]; // [rsp+80h] [rbp-90h] BYREF

v6 = 8;
if ( (unsigned int)count_list_len(*a2, &v33) )
goto LABEL_2;
v11 = alloca(v33 + 9);
if ( (unsigned int)list_to_cstr(*a2, &v31, v33 + 1, 0LL) )
{
v6 = 14;
LABEL_2:
i = 0LL;
v8 = 0LL;
v9 = eval_err(v6);
v32 = v34;
goto LABEL_3;
}
v32 = v34;
v12 = map_file(v34, &v31);
switch ( v12 )
{
case 2:
v24 = errnum;
v25 = strerror(errnum);
v19 = v24;
v20 = "error: canno stat() file %s: %s (errno=%d)\n";
v21 = v25;
goto LABEL_16;
case 3:
v17 = errnum;
v18 = strerror(errnum);
v19 = v17;
v20 = "error: cannot mmap() file %s: %s (errno=%d)\n";
v21 = v18;
LABEL_16:
i = 0LL;
v8 = 0LL;
fprintf(stderr, v20, &v31, v21, v19);
v9 = eval_err(0xEu);
goto LABEL_3;
case 1:
v22 = errnum;
v23 = strerror(errnum);
v19 = v22;
v20 = "error: cannot open() file %s: %s (errno=%d)\n";
v21 = v23;
goto LABEL_16;
}
v13 = bufstream_init(v38, v35, v36);
tok_state_init(v39, v13);
v14 = node_handle_new(a1, 0LL);
v8 = node_lockroot(v14);
v15 = node_handle_new(a1, 0LL);
for ( i = node_lockroot(v15); ; node_handle_update(i, 0LL) )
{
v16 = parse(a1, v39, v8);
if ( v16 == 7 )
{
v9 = 0;
goto LABEL_3;
}
if ( v16 )
{
v31 = tok_state_offset(v39);
v26 = tok_state_linechr(v39);
v27 = tok_state_line(v39);
printf("parse error line %llu char %llu (offset %llu)\n", v27, v26, v31);
v28 = (const char *)parse_err_str(v16);
printf("-- %s\n", v28);
v9 = eval_err(0xEu);
goto LABEL_3;
}
v9 = eval(a1, a4, v8, i);
if ( v9 )
break;
node_handle_update(v8, 0LL);
}
puts("eval error for: ");
v29 = node_handle(i);
node_print_pretty_stream(g_stream_stdout, v29, 0LL);
putchar(10);
v30 = (const char *)eval_err_str(v9);
printf("-- %s\n", v30);
LABEL_3:
node_droproot(v8);
node_droproot(i);
node_droproot(a4);
unmap_file(v32);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
unsigned int v6; // edi
__int64 i; // r14
__int64 v8; // r15
unsigned int v9; // er12
void *v11; // rsp
int v12; // eax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
unsigned int v16; // er12
unsigned int v17; // ebx
char *v18; // rax
__int64 v19; // r8
const char *v20; // rsi
char *v21; // rcx
unsigned int v22; // ebx
char *v23; // rax
unsigned int v24; // ebx
char *v25; // rax
__int64 v26; // rbx
__int64 v27; // rax
const char *v28; // rax
__int64 v29; // rax
const char *v30; // rax
__int64 v31; // [rsp+0h] [rbp-110h] BYREF
char *v32; // [rsp+8h] [rbp-108h]
__int64 v33; // [rsp+18h] [rbp-F8h] BYREF
char v34[8]; // [rsp+20h] [rbp-F0h] BYREF
__int64 v35; // [rsp+28h] [rbp-E8h]
__int64 v36; // [rsp+30h] [rbp-E0h]
int errnum; // [rsp+38h] [rbp-D8h]
char v38[64]; // [rsp+40h] [rbp-D0h] BYREF
char v39[144]; // [rsp+80h] [rbp-90h] BYREF

v6 = 8;
if ( (unsigned int)count_list_len(*a2, &v33) )
goto LABEL_2;
v11 = alloca(v33 + 9);
if ( (unsigned int)list_to_cstr(*a2, &v31, v33 + 1, 0LL) )
{
v6 = 14;
LABEL_2:
i = 0LL;
v8 = 0LL;
v9 = func0(v6);
v32 = v34;
goto LABEL_3;
}
v32 = v34;
v12 = map_file(v34, &v31);
switch ( v12 )
{
case 2:
v24 = errnum;
v25 = strerror(errnum);
v19 = v24;
v20 = "error: canno stat() file %s: %s (errno=%d)\n";
v21 = v25;
goto LABEL_16;
case 3:
v17 = errnum;
v18 = strerror(errnum);
v19 = v17;
v20 = "error: cannot mmap() file %s: %s (errno=%d)\n";
v21 = v18;
LABEL_16:
i = 0LL;
v8 = 0LL;
fprintf(stderr, v20, &v31, v21, v19);
v9 = func0(0xEu);
goto LABEL_3;
case 1:
v22 = errnum;
v23 = strerror(errnum);
v19 = v22;
v20 = "error: cannot open() file %s: %s (errno=%d)\n";
v21 = v23;
goto LABEL_16;
}
v13 = bufstream_init(v38, v35, v36);
tok_state_init(v39, v13);
v14 = node_handle_new(a1, 0LL);
v8 = node_lockroot(v14);
v15 = node_handle_new(a1, 0LL);
for ( i = node_lockroot(v15); ; node_handle_update(i, 0LL) )
{
v16 = parse(a1, v39, v8);
if ( v16 == 7 )
{
v9 = 0;
goto LABEL_3;
}
if ( v16 )
{
v31 = tok_state_offset(v39);
v26 = tok_state_linechr(v39);
v27 = tok_state_line(v39);
printf("parse error line %llu char %llu (offset %llu)\n", v27, v26, v31);
v28 = (const char *)parse_err_str(v16);
printf("-- %s\n", v28);
v9 = func0(0xEu);
goto LABEL_3;
}
v9 = eval(a1, a4, v8, i);
if ( v9 )
break;
node_handle_update(v8, 0LL);
}
puts("eval error for: ");
v29 = node_handle(i);
node_print_pretty_stream(g_stream_stdout, v29, 0LL);
putchar(10);
v30 = (const char *)eval_err_str(v9);
printf("-- %s\n", v30);
LABEL_3:
node_droproot(v8);
node_droproot(i);
node_droproot(a4);
unmap_file(v32);
return v9;
}

original_code:
static eval_err_t readevalfn(memory_state_t *ms, node_t **n, node_t **result, void *p)
{
 char *path = ((void *)0);
 int map_status;
 size_t len;
 node_t *cursor, *val;
 node_t *env_handle = (node_t *) p;
 parse_err_t parse_stat;
 filemap_info_t info;
 stream_t *stream;
 tok_state_t ts;
 bufstream_t bs;
 eval_err_t eval_stat = EVAL_OK;
 node_t *eval_in_hdl = ((void *)0), *eval_out_hdl = ((void *)0);
 if(count_list_len(n[0], &len) != 0) {
  eval_stat = eval_err(EVAL_ERR_EXPECTED_CONS);
  goto cleanup;
 }
 if(!(path = __builtin_alloca (len + 1))) {
  eval_stat = eval_err(EVAL_ERR_OUT_OF_MEM);
  goto cleanup;
 }
 if(list_to_cstr(n[0], path, len + 1, ((void *)0))) {
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 map_status = map_file(&info, path);
 switch(map_status) {
 default: break;
 case 1:
  fprintf(stderr, "error: cannot open() file %s: %s (errno=%d)\n",
          path, strerror(info.err), info.err);
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 case 2:
  fprintf(stderr, "error: canno stat() file %s: %s (errno=%d)\n",
          path, strerror(info.err), info.err);
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 case 3:
  fprintf(stderr, "error: cannot mmap() file %s: %s (errno=%d)\n",
          path, strerror(info.err), info.err);
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 stream = bufstream_init(&bs, info.buf, info.len);
 tok_state_init(&ts, stream);
 eval_in_hdl = node_lockroot(node_handle_new(ms, ((void *)0)));
 eval_out_hdl = node_lockroot(node_handle_new(ms, ((void *)0)));
 while((parse_stat = parse(ms, &ts, eval_in_hdl)) != PARSE_END) {
  if(parse_stat != PARSE_OK) {
   printf("parse error line %llu char %llu (offset %llu)\n",
          (unsigned long long) tok_state_line(&ts),
          (unsigned long long) tok_state_linechr(&ts),
          (unsigned long long) tok_state_offset(&ts));
   printf("-- %s\n", parse_err_str(parse_stat));
   eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
   goto cleanup;
  }
  eval_stat = eval(ms, env_handle, eval_in_hdl, eval_out_hdl);
  if(eval_stat) {
   printf("eval error for: \n");
   node_print_pretty_stream(g_stream_stdout,
                            node_handle(eval_out_hdl), 0);
   printf("\n");
   printf("-- %s\n", eval_err_str(eval_stat));
   goto cleanup;
  }
  node_handle_update(eval_in_hdl, ((void *)0));
  node_handle_update(eval_out_hdl, ((void *)0));
 }
cleanup:
 node_droproot(eval_in_hdl);
 node_droproot(eval_out_hdl);
 node_droproot(env_handle);
 unmap_file(&info);
 return eval_stat;
}

canonical_original_code:
static enum eval_err_t readevalfn(struct memory_state *ms, struct node **n, struct node **result, void *p)
{
 char *path = ((void *)0);
 int map_status;
 unsigned long len;
 struct node *cursor; struct node *val;
 struct node *env_handle = (node_t *) p;
 enum parse_err_t parse_stat;
 struct filemap_info_t info;
 struct stream_t *stream;
 struct tok_state_t ts;
 struct bufstream_t bs;
 enum eval_err_t eval_stat = EVAL_OK;
 struct node *eval_in_hdl = ((void *)0); struct node *eval_out_hdl = ((void *)0);
 if(count_list_len(n[0], &len) != 0) {
  eval_stat = eval_err(EVAL_ERR_EXPECTED_CONS);
  goto cleanup;
 }
 if(!(path = __builtin_alloca (len + 1))) {
  eval_stat = eval_err(EVAL_ERR_OUT_OF_MEM);
  goto cleanup;
 }
 if(list_to_cstr(n[0], path, len + 1, ((void *)0))) {
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 map_status = map_file(&info, path);
 switch(map_status) {
 default: break;
 case 1:
  fprintf(stderr, "error: cannot open() file %s: %s (errno=%d)\n",
          path, strerror(info.err), info.err);
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 case 2:
  fprintf(stderr, "error: canno stat() file %s: %s (errno=%d)\n",
          path, strerror(info.err), info.err);
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 case 3:
  fprintf(stderr, "error: cannot mmap() file %s: %s (errno=%d)\n",
          path, strerror(info.err), info.err);
  eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
  goto cleanup;
 }
 stream = bufstream_init(&bs, info.buf, info.len);
 tok_state_init(&ts, stream);
 eval_in_hdl = node_lockroot(node_handle_new(ms, ((void *)0)));
 eval_out_hdl = node_lockroot(node_handle_new(ms, ((void *)0)));
 while((parse_stat = parse(ms, &ts, eval_in_hdl)) != PARSE_END) {
  if(parse_stat != PARSE_OK) {
   printf("parse error line %llu char %llu (offset %llu)\n",
          (unsigned long long) tok_state_line(&ts),
          (unsigned long long) tok_state_linechr(&ts),
          (unsigned long long) tok_state_offset(&ts));
   printf("-- %s\n", parse_err_str(parse_stat));
   eval_stat = eval_err(EVAL_ERR_FOREIGN_FAILURE);
   goto cleanup;
  }
  eval_stat = eval(ms, env_handle, eval_in_hdl, eval_out_hdl);
  if(eval_stat) {
   printf("eval error for: \n");
   node_print_pretty_stream(g_stream_stdout,
                            node_handle(eval_out_hdl), 0);
   printf("\n");
   printf("-- %s\n", eval_err_str(eval_stat));
   goto cleanup;
  }
  node_handle_update(eval_in_hdl, ((void *)0));
  node_handle_update(eval_out_hdl, ((void *)0));
 }
cleanup:
 node_droproot(eval_in_hdl);
 node_droproot(eval_out_hdl);
 node_droproot(env_handle);
 unmap_file(&info);
 return eval_stat;
}

variable_types: enum parse_err_t { PARSE_OK=0, PARSE_UNEXPECTED_DOT=1, PARSE_UNEXPECTED_RPAREN=2, PARSE_TOKEN_UNDERFLOW=3, PARSE_EXPECTED_RPAREN=4, PARSE_EXPECTED_ATOM=5, PARSE_EXPECTED_LPAREN_ATOM=6, PARSE_END=7 }

variable_types: struct filemap_info_t { int fd; void *buf; unsigned long len; int err; }

variable_types: struct tok_state_t { enum toktype_t { TOK_INIT=0, TOK_LPAREN=1, TOK_RPAREN=2, TOK_DOT=3, TOK_SYM=4, TOK_LIT=5, TOK_END=6 } type; _Bool in_string; long stream_off; union { char sym[-1]; long lit; } u; int nextch; struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream; }

variable_types: struct bufstream_t { struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } hdr; char *buf; unsigned long len; unsigned long roff; }

return_type: enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 }

user_defined_types: struct bufstream_t { struct stream_t hdr; char *buf; unsigned long len; unsigned long roff; }


decompiled_code:
__int64 __fastcall foreign_loadlib(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 1LL, loadlibfn, a2, a4, a3);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 1LL, loadlibfn, a2, a4, a3);
}

original_code:
eval_err_t foreign_loadlib(memory_state_t *ms, node_t *args, node_t *env_handle, node_t **result)
{
 return extract_args(ms, 1, loadlibfn, args, result, env_handle);
}

canonical_original_code:
enum eval_err_t foreign_loadlib(struct memory_state *ms, struct node *args, struct node *env_handle, struct node **result)
{
 return extract_args(ms, 1, loadlibfn, args, result, env_handle);
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *


decompiled_code:
__int64 __fastcall foreign_read_eval(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 1LL, readevalfn, a2, a4, a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 1LL, readevalfn, a2, a4, a3);
}

original_code:
eval_err_t foreign_read_eval(memory_state_t *ms, node_t *args, node_t *env_handle, node_t **result)
{
 return extract_args(ms, 1, readevalfn, args, result, env_handle);
}

canonical_original_code:
enum eval_err_t foreign_read_eval(struct memory_state *ms, struct node *args, struct node *env_handle, struct node **result)
{
 return extract_args(ms, 1, readevalfn, args, result, env_handle);
}


decompiled_code:
void __fastcall dlnode_move(__int64 a1, __int64 a2, _QWORD *a3)
{
__int64 v4; // rdx
_QWORD *v5; // rax
__int64 v6; // rcx
__int64 v7; // rax
_QWORD *v8; // r8
__int64 v9; // rcx
__int64 v10; // rax

if ( *(_QWORD **)(a1 + 8) != a3 )
_assert_fail("newprev->next == newnext", "dlist.c", 0x21u, "dlnode_move");
if ( *a3 != a1 )
_assert_fail("newnext->prev == newprev", "dlist.c", 0x22u, "dlnode_move");
v4 = *(_QWORD *)(a1 + 16);
if ( !v4 )
_assert_fail("newprev->owner", "dlist.c", 0x23u, "dlnode_move");
if ( v4 != a3[2] )
_assert_fail("newprev->owner == newnext->owner", "dlist.c", 0x24u, "dlnode_move");
if ( !*(_QWORD *)(a2 + 16) )
_assert_fail("n->owner", "dlist.c", 0x25u, "dlnode_move");
dlnode_join(*(_QWORD *)a2, *(_QWORD **)(a2 + 8));
dlnode_join(v6, v5);
dlnode_join(v7, v8);
*(_QWORD *)(v10 + 16) = *(_QWORD *)(v9 + 16);
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, __int64 a2, _QWORD *a3)
{
__int64 v4; // rdx
_QWORD *v5; // rax
__int64 v6; // rcx
__int64 v7; // rax
_QWORD *v8; // r8
__int64 v9; // rcx
__int64 v10; // rax

if ( *(_QWORD **)(a1 + 8) != a3 )
_assert_fail("newprev->next == newnext", "dlist.c", 0x21u, "dlnode_move");
if ( *a3 != a1 )
_assert_fail("newnext->prev == newprev", "dlist.c", 0x22u, "dlnode_move");
v4 = *(_QWORD *)(a1 + 16);
if ( !v4 )
_assert_fail("newprev->owner", "dlist.c", 0x23u, "dlnode_move");
if ( v4 != a3[2] )
_assert_fail("newprev->owner == newnext->owner", "dlist.c", 0x24u, "dlnode_move");
if ( !*(_QWORD *)(a2 + 16) )
_assert_fail("n->owner", "dlist.c", 0x25u, "dlnode_move");
func0(*(_QWORD *)a2, *(_QWORD **)(a2 + 8));
func0(v6, v5);
func0(v7, v8);
*(_QWORD *)(v10 + 16) = *(_QWORD *)(v9 + 16);
}

original_code:
void dlnode_move(dlnode_t *newprev, dlnode_t *n, dlnode_t *newnext)
{
 ((newprev->next == newnext) ? (void) (0) : __assert_fail ("newprev->next == newnext", "dlist.c", 33, __extension__ __PRETTY_FUNCTION__));
 ((newnext->prev == newprev) ? (void) (0) : __assert_fail ("newnext->prev == newprev", "dlist.c", 34, __extension__ __PRETTY_FUNCTION__));
 ((newprev->owner) ? (void) (0) : __assert_fail ("newprev->owner", "dlist.c", 35, __extension__ __PRETTY_FUNCTION__));
 ((newprev->owner == newnext->owner) ? (void) (0) : __assert_fail ("newprev->owner == newnext->owner", "dlist.c", 36, __extension__ __PRETTY_FUNCTION__));
 ((n->owner) ? (void) (0) : __assert_fail ("n->owner", "dlist.c", 37, __extension__ __PRETTY_FUNCTION__));
 dlnode_join(n->prev, n->next);
 dlnode_join(newprev, n);
 dlnode_join(n, newnext);
 n->owner = newprev->owner;
}

canonical_original_code:
void dlnode_move(struct dlnode *newprev, struct dlnode *n, struct dlnode *newnext)
{
 ((newprev->next == newnext) ? (void) (0) : __assert_fail ("newprev->next == newnext", "dlist.c", 33, __extension__ __PRETTY_FUNCTION__));
 ((newnext->prev == newprev) ? (void) (0) : __assert_fail ("newnext->prev == newprev", "dlist.c", 34, __extension__ __PRETTY_FUNCTION__));
 ((newprev->owner) ? (void) (0) : __assert_fail ("newprev->owner", "dlist.c", 35, __extension__ __PRETTY_FUNCTION__));
 ((newprev->owner == newnext->owner) ? (void) (0) : __assert_fail ("newprev->owner == newnext->owner", "dlist.c", 36, __extension__ __PRETTY_FUNCTION__));
 ((n->owner) ? (void) (0) : __assert_fail ("n->owner", "dlist.c", 37, __extension__ __PRETTY_FUNCTION__));
 dlnode_join(n->prev, n->next);
 dlnode_join(newprev, n);
 dlnode_join(n, newnext);
 n->owner = newprev->owner;
}

variable_types: struct dlnode { struct dlnode *prev; struct dlist { struct dlnode hdr; } *owner; } *

variable_types:
n
struct dlnode *

variable_types:
newnext
struct dlnode *


decompiled_code:
void __fastcall dlnode_remove(__int64 a1)
{
__int64 v1; // rax

if ( !*(_QWORD *)(a1 + 16) )
_assert_fail("n->owner != NULL", "dlist.c", 0x32u, "dlnode_remove");
dlnode_join(*(_QWORD *)a1, *(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 16) = 0LL;
}

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

if ( !*(_QWORD *)(a1 + 16) )
_assert_fail("n->owner != NULL", "dlist.c", 0x32u, "dlnode_remove");
func0(*(_QWORD *)a1, *(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 16) = 0LL;
}

original_code:
dlnode_t *dlnode_remove(dlnode_t *n)
{
 dlnode_t *n_prev;
 dlnode_t *n_next;
 ((n->owner != ((void *)0)) ? (void) (0) : __assert_fail ("n->owner != NULL", "dlist.c", 50, __extension__ __PRETTY_FUNCTION__));
 dlnode_join(n->prev, n->next);
 n->owner = ((void *)0);
 return n;
}

canonical_original_code:
struct dlnode *dlnode_remove(struct dlnode *n)
{
 struct dlnode *n_prev;
 struct dlnode *n_next;
 ((n->owner != ((void *)0)) ? (void) (0) : __assert_fail ("n->owner != NULL", "dlist.c", 50, __extension__ __PRETTY_FUNCTION__));
 dlnode_join(n->prev, n->next);
 n->owner = ((void *)0);
 return n;
}

return_type: struct dlnode { struct dlnode *prev; struct dlist { struct dlnode hdr; } *owner; } *


decompiled_code:
// attributes: thunk
void *libc_malloc_wrap(size_t size)
{
return malloc(size);
}

canonical_decompiled_code:
void *func0(size_t size)
{
return malloc(size);
}

original_code:
void *libc_malloc_wrap(size_t len, void *priv)
{
 return malloc(len);
}

canonical_original_code:
void *libc_malloc_wrap(unsigned long len, void *priv)
{
 return malloc(len);
}

variable_types:
priv
void *

return_type: void *


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

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

original_code:
void libc_free_wrap(void *mem, void *priv)
{
 free(mem);
}

variable_types:
mem
void *


decompiled_code:
__int64 __fastcall environ_add_builtins(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v6; // r12
__int64 v7; // r15
__int64 v8; // rbp
__int64 v9; // rax

result = data_to_memstate();
if ( a3 )
{
v6 = result;
v7 = 0LL;
do
{
++v7;
v8 = node_symbol_new(v6, *(_QWORD *)a2);
v9 = (*(__int64 (__fastcall **)(__int64))(a2 + 8))(v6);
a2 += 16LL;
result = environ_add(a1, v8, v9);
}
while ( a3 != v7 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v6; // r12
__int64 v7; // r15
__int64 v8; // rbp
__int64 v9; // rax

result = data_to_memstate();
if ( a3 )
{
v6 = result;
v7 = 0LL;
do
{
++v7;
v8 = node_symbol_new(v6, *(_QWORD *)a2);
v9 = (*(__int64 (__fastcall **)(__int64))(a2 + 8))(v6);
a2 += 16LL;
result = environ_add(a1, v8, v9);
}
while ( a3 != v7 );
}
return result;
}

original_code:
void environ_add_builtins(node_t *env_handle,
                          foreign_assoc_t *builtins,
                          size_t num)
{
 size_t i;
 node_t *key, *value;
 memory_state_t *s = data_to_memstate(env_handle);
 for (i = 0; i < num; i++) {
  key = node_symbol_new(s, builtins[i].name);
  value = builtins[i].func(s);
  environ_add(env_handle, key, value);
 }
}

canonical_original_code:
void environ_add_builtins(struct node *env_handle, struct foreign_assoc_t *builtins, unsigned long num)
{
 unsigned long i;
 struct node *key; struct node *value;
 struct memory_state *s = data_to_memstate(env_handle);
 for (i = 0; i < num; i++) {
  key = node_symbol_new(s, builtins[i].name);
  value = builtins[i].func(s);
  environ_add(env_handle, key, value);
 }
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *

variable_types: struct foreign_assoc_t { char *name; struct node *(*func)(struct memory_state *s); } *

variable_types:
num
unsigned long

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall bufstream_readch(_QWORD *a1, _BYTE *a2)
{
__int64 v2; // rax
__int64 v3; // rdx

v2 = a1[6];
if ( v2 == a1[5] )
return 0xFFFFFFFFLL;
v3 = a1[4];
a1[6] = v2 + 1;
*a2 = *(_BYTE *)(v3 + v2);
return 0LL;
}

original_code:
static int bufstream_readch(void *p, char *ch_out)
{
 int ch;
 bufstream_t *bs = (bufstream_t *) p;
 if(bs->roff == bs->len) {
  return (-1);
 }
 *ch_out = bs->buf[bs->roff++];
 return 0;
}

canonical_original_code:
static int bufstream_readch(void *p, char *ch_out)
{
 int ch;
 struct bufstream_t *bs = (bufstream_t *) p;
 if(bs->roff == bs->len) {
  return (-1);
 }
 *ch_out = bs->buf[bs->roff++];
 return 0;
}

variable_types:
p
void *

variable_types: ch int

variable_types: struct bufstream_t { struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } hdr; char *buf; unsigned long len; unsigned long roff; } *


original_code:
stream_t *stream_init(
 void *p,
 stream_getch_fn getch_cb,
 stream_putch_fn putch_cb,
 void *stream_priv)
{
 stream_t *s = (stream_t *) p;
 if(s) {
  s->getch_cb = getch_cb;
  s->putch_cb = putch_cb;
  s->stream_priv = stream_priv;
  s->status = 0;
 }
 return s;
}

canonical_original_code:
struct stream_t *stream_init(void *p, int (*getch_cb)(void *p, char *ch_out), int (*putch_cb)(void *p, char ch_in), void *stream_priv)
{
 struct stream_t *s = (stream_t *) p;
 if(s) {
  s->getch_cb = getch_cb;
  s->putch_cb = putch_cb;
  s->stream_priv = stream_priv;
  s->status = 0;
 }
 return s;
}

variable_types: struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *


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

v1 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 8))(*(_QWORD *)a1);
*(_DWORD *)(a1 + 24) = v1;
return (unsigned int)-(v1 != 0);
}

original_code:
int stream_getch(stream_t *s, char *ch_out)
{
 s->status = s->getch_cb(s->stream_priv, ch_out);
 if(s->status) {
  return -1;
 }
 return 0;
}

canonical_original_code:
int stream_getch(struct stream_t *s, char *ch_out)
{
 s->status = s->getch_cb(s->stream_priv, ch_out);
 if(s->status) {
  return -1;
 }
 return 0;
}


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

v2 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(a1 + 16))(*(_QWORD *)a1, (unsigned int)a2);
*(_DWORD *)(a1 + 24) = v2;
return (unsigned int)-(v2 != 0);
}

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

v2 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(a1 + 16))(*(_QWORD *)a1, (unsigned int)a2);
*(_DWORD *)(a1 + 24) = v2;
return (unsigned int)-(v2 != 0);
}

original_code:
int stream_putch(stream_t *s, char val)
{
 s->status = s->putch_cb(s->stream_priv, val);
 if(s->status) {
  return -1;
 }
 return 0;
}

canonical_original_code:
int stream_putch(struct stream_t *s, char val)
{
 s->status = s->putch_cb(s->stream_priv, val);
 if(s->status) {
  return -1;
 }
 return 0;
}

variable_types: val char


decompiled_code:
__int64 __fastcall stream_putstr(__int64 a1, _BYTE *a2)
{
unsigned int v2; // er12
_BYTE *v3; // rbp
char v4; // si
int v5; // eax

v2 = 0;
v3 = a2;
if ( *a2 )
{
while ( 1 )
{
v5 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 16))(*(_QWORD *)a1);
*(_DWORD *)(a1 + 24) = v5;
if ( v5 < 0 )
break;
v4 = *++v3;
++v2;
if ( !v4 || v2 == 0x7FFFFFFF )
return v2;
}
if ( !v2 )
v2 = -1;
}
return v2;
}

original_code:
int stream_putstr(stream_t *s, char *str)
{
 int status = 0;
 int count = 0;
 while(*str) {
  if(count == 0x7fffffff) {
   break;
  }
  s->status = s->putch_cb(s->stream_priv, *str);
  if(s->status < 0) {
   if(count == 0) {
    count = -1;
   }
   break;
  }
  str++;
  count++;
 }
 return count;
}

canonical_original_code:
int stream_putstr(struct stream_t *s, char *str)
{
 int status = 0;
 int count = 0;
 while(*str) {
  if(count == 0x7fffffff) {
   break;
  }
  s->status = s->putch_cb(s->stream_priv, *str);
  if(s->status < 0) {
   if(count == 0) {
    count = -1;
   }
   break;
  }
  str++;
  count++;
 }
 return count;
}

variable_types:
str
char *

variable_types: status int

variable_types: count int


decompiled_code:
__int64 __fastcall stream_status_set(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

original_code:
int stream_status_set(stream_t *s)
{
 return s->status;
}

canonical_original_code:
int stream_status_set(struct stream_t *s)
{
 return s->status;
}


decompiled_code:
bool __fastcall stream_is_end(__int64 a1)
{
return *(_DWORD *)(a1 + 24) == -1;
}

canonical_decompiled_code:
bool __fastcall func7(__int64 a1)
{
return *(_DWORD *)(a1 + 24) == -1;
}

original_code:
_Bool stream_is_end(stream_t *s)
{
 return s->status == (-1);
}

canonical_original_code:
_Bool stream_is_end(struct stream_t *s)
{
 return s->status == (-1);
}


decompiled_code:
__int64 __fastcall do_sio_getchar(__int64 a1, __int64 a2, _QWORD *a3)
{
int v4; // eax

v4 = getchar();
*a3 = node_value_new(a1, v4);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, _QWORD *a3)
{
int v4; // eax

v4 = getchar();
*a3 = node_value_new(a1, v4);
return 0LL;
}

original_code:
static eval_err_t do_sio_getchar(memory_state_t *ms, node_t **args, node_t **result, void *p)
{
 *result = node_value_new(ms, getchar());
 return EVAL_OK;
}

canonical_original_code:
static enum eval_err_t do_sio_getchar(struct memory_state *ms, struct node **args, struct node **result, void *p)
{
 *result = node_value_new(ms, getchar());
 return EVAL_OK;
}

variable_types: struct memory_state { unsigned long total_alloc; unsigned long total_free; unsigned long long iter_count; unsigned long long cycle_count; unsigned int clean_cycles; unsigned long long skipped_clean_iters; struct dlist { struct dlnode { struct dlnode *prev; struct dlist *owner; } hdr; } free_list; struct dlnode root_sentinel; struct dlist roots_list; struct dlist boundary_list; struct dlist free_pending_list; struct dlist white_list; struct dlist *reachable_listref; struct dlist *unproc_listref; void (*i_cb)(void *data); void (*dl_cb)(void (*cb)(void *link, void *p), void *data, void *p); void (*p_cb)(void *data, struct stream_t { void *stream_priv; int (*getch_cb)(void *p, char *ch_out); int (*putch_cb)(void *p, char ch_in); int status; } *stream); struct { _Bool active; } ms_flags; void *(*mem_alloc)(unsigned long len, void *priv); void (*mem_free)(void *mem, void *priv); void *mem_alloc_priv; } *

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } **

variable_types:
result
struct node **


decompiled_code:
__int64 __fastcall do_sio_putchar(__int64 a1, _QWORD *a2, _QWORD *a3)
{
__int64 v5; // rdi
__int64 result; // rax
int v7; // eax

v5 = node_value(*a2);
result = 12LL;
if ( v5 <= 255 )
{
v7 = putchar(v5);
*a3 = node_value_new(a1, v7);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2, _QWORD *a3)
{
__int64 v5; // rdi
__int64 result; // rax
int v7; // eax

v5 = node_value(*a2);
result = 12LL;
if ( v5 <= 255 )
{
v7 = putchar(v5);
*a3 = node_value_new(a1, v7);
result = 0LL;
}
return result;
}

original_code:
static eval_err_t do_sio_putchar(memory_state_t *ms, node_t **args, node_t **result, void *p)
{
 value_t v = node_value(args[0]);
 if(v >= (0x1 << 8)) {
  return EVAL_ERR_VALUE_BOUNDS;
 }
 *result = node_value_new(ms, putchar(v));
 return EVAL_OK;
}

canonical_original_code:
static enum eval_err_t do_sio_putchar(struct memory_state *ms, struct node **args, struct node **result, void *p)
{
 long v = node_value(args[0]);
 if(v >= (0x1 << 8)) {
  return EVAL_ERR_VALUE_BOUNDS;
 }
 *result = node_value_new(ms, putchar(v));
 return EVAL_OK;
}

variable_types: v long


decompiled_code:
__int64 __fastcall do_sio_eputchar(__int64 a1, _QWORD *a2, _QWORD *a3)
{
__int64 v5; // rdi
__int64 result; // rax
int v7; // eax

v5 = node_value(*a2);
result = 12LL;
if ( v5 <= 255 )
{
v7 = fputc(v5, stderr);
*a3 = node_value_new(a1, v7);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _QWORD *a2, _QWORD *a3)
{
__int64 v5; // rdi
__int64 result; // rax
int v7; // eax

v5 = node_value(*a2);
result = 12LL;
if ( v5 <= 255 )
{
v7 = fputc(v5, stderr);
*a3 = node_value_new(a1, v7);
result = 0LL;
}
return result;
}

original_code:
static eval_err_t do_sio_eputchar(memory_state_t *ms, node_t **args, node_t **result, void *p)
{
 value_t v = node_value(args[0]);
 if(v >= (0x1 << 8)) {
  return EVAL_ERR_VALUE_BOUNDS;
 }
 *result = node_value_new(ms, fputc(v, stderr));
 return EVAL_OK;
}

canonical_original_code:
static enum eval_err_t do_sio_eputchar(struct memory_state *ms, struct node **args, struct node **result, void *p)
{
 long v = node_value(args[0]);
 if(v >= (0x1 << 8)) {
  return EVAL_ERR_VALUE_BOUNDS;
 }
 *result = node_value_new(ms, fputc(v, stderr));
 return EVAL_OK;
}


decompiled_code:
__int64 __fastcall sio_getchar(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 0LL, do_sio_getchar, a2, a4, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 0LL, do_sio_getchar, a2, a4, 0LL);
}

original_code:
eval_err_t sio_getchar(memory_state_t *ms, node_t *args, node_t *env_handle, node_t **result)
{
 return extract_args(ms, 0, do_sio_getchar, args, result, ((void *)0));
}

canonical_original_code:
enum eval_err_t sio_getchar(struct memory_state *ms, struct node *args, struct node *env_handle, struct node **result)
{
 return extract_args(ms, 0, do_sio_getchar, args, result, ((void *)0));
}

variable_types: struct node { enum nodetype_t { NODE_UNINITIALIZED=0, NODE_NIL=1, NODE_CONS=2, NODE_LAMBDA=3, NODE_SYMBOL=4, NODE_VALUE=5, NODE_FOREIGN=6, NODE_HANDLE=7, NODE_CONTINUATION=8, NODE_SPECIAL_FUNC=9, NODE_BLOB=10 } type; union { struct { struct node *car; } cons; struct { struct node *env; } lambda; enum eval_err_t { EVAL_OK=0, EVAL_ERR_UNRESOLVED_SYMBOL=1, EVAL_ERR_TOO_MANY_ARGS=2, EVAL_ERR_TOO_FEW_ARGS=3, EVAL_ERR_MISSING_ARG=4, EVAL_ERR_FUNC_IS_NOT_LAMBDA=5, EVAL_ERR_NONLAMBDA_FUNCALL=6, EVAL_ERR_UNKNOWN_FUNCALL=7, EVAL_ERR_EXPECTED_CONS=8, EVAL_ERR_EXPECTED_SYMBOL=9, EVAL_ERR_EXPECTED_VALUE=10, EVAL_ERR_EXPECTED_CONS_SYM=11, EVAL_ERR_VALUE_BOUNDS=12, EVAL_ERR_OUT_OF_MEM=13, EVAL_ERR_FOREIGN_FAILURE=14 } (*func)(struct memory_state *s, struct node *args, struct node *env_hdl, struct node **result); char name[32]; long value; struct { struct node *link; } handle; struct { struct node *bt; } cont; struct { void *addr; void (*fin)(void *addr); unsigned long sig; } blob; enum special_func_t { SPECIAL_IF=0, SPECIAL_LAMBDA=1, SPECIAL_QUOTE=2, SPECIAL_MK_CONT=3, SPECIAL_DEF=4, SPECIAL_SET=5, SPECIAL_DEFINED=6, SPECIAL_EVAL=7 } special; } dat; } *