decompiled_code:
__int64 __fastcall make_foreign_b_and(__int64 a1)
{
return node_foreign_new(a1, &foreign_b_and);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return node_foreign_new(a1, &foreign_b_and);
}

original_code: static node_t *make_foreign_b_and (memory_state_t *ms) { return node_foreign_new(ms, foreign_b_and); }

canonical_original_code: static struct node *make_foreign_b_and(struct memory_state *ms) { return node_foreign_new(ms, foreign_b_and); }


decompiled_code:
__int64 __fastcall make_foreign_rem(__int64 a1)
{
return node_foreign_new(a1, &foreign_rem);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return node_foreign_new(a1, &foreign_rem);
}

original_code: static node_t *make_foreign_rem (memory_state_t *ms) { return node_foreign_new(ms, foreign_rem); }

canonical_original_code: static struct node *make_foreign_rem(struct memory_state *ms) { return node_foreign_new(ms, foreign_rem); }

variable_types:
ms
struct memory_state *

return_type: 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; } *

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 make_foreign_div(__int64 a1)
{
return node_foreign_new(a1, &foreign_div);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return node_foreign_new(a1, &foreign_div);
}

original_code: static node_t *make_foreign_div (memory_state_t *ms) { return node_foreign_new(ms, foreign_div); }

canonical_original_code: static struct node *make_foreign_div(struct memory_state *ms) { return node_foreign_new(ms, foreign_div); }

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 make_foreign_mul(__int64 a1)
{
return node_foreign_new(a1, &foreign_mul);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return node_foreign_new(a1, &foreign_mul);
}

original_code: static node_t *make_foreign_mul (memory_state_t *ms) { return node_foreign_new(ms, foreign_mul); }

canonical_original_code: static struct node *make_foreign_mul(struct memory_state *ms) { return node_foreign_new(ms, foreign_mul); }


decompiled_code:
__int64 __fastcall make_foreign_sub(__int64 a1)
{
return node_foreign_new(a1, &foreign_sub);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return node_foreign_new(a1, &foreign_sub);
}

original_code: static node_t *make_foreign_sub (memory_state_t *ms) { return node_foreign_new(ms, foreign_sub); }

canonical_original_code: static struct node *make_foreign_sub(struct memory_state *ms) { return node_foreign_new(ms, foreign_sub); }


decompiled_code:
__int64 __fastcall make_foreign_add(__int64 a1)
{
return node_foreign_new(a1, &foreign_add);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return node_foreign_new(a1, &foreign_add);
}

original_code: static node_t *make_foreign_add (memory_state_t *ms) { return node_foreign_new(ms, foreign_add); }

canonical_original_code: static struct node *make_foreign_add(struct memory_state *ms) { return node_foreign_new(ms, foreign_add); }


decompiled_code:
__int64 __fastcall make_foreign_addc_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_addc_p);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return node_foreign_new(a1, &foreign_addc_p);
}

original_code: static node_t *make_foreign_addc_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_addc_p); }

canonical_original_code: static struct node *make_foreign_addc_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_addc_p); }


decompiled_code:
__int64 __fastcall make_foreign_ugt_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_ugt_p);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
return node_foreign_new(a1, &foreign_ugt_p);
}

original_code: static node_t *make_foreign_ugt_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_ugt_p); }

canonical_original_code: static struct node *make_foreign_ugt_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_ugt_p); }


decompiled_code:
__int64 __fastcall make_foreign_ult_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_ult_p);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
return node_foreign_new(a1, &foreign_ult_p);
}

original_code: static node_t *make_foreign_ult_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_ult_p); }

canonical_original_code: static struct node *make_foreign_ult_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_ult_p); }


decompiled_code:
__int64 __fastcall make_foreign_gt_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_gt_p);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
return node_foreign_new(a1, &foreign_gt_p);
}

original_code: static node_t *make_foreign_gt_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_gt_p); }

canonical_original_code: static struct node *make_foreign_gt_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_gt_p); }


decompiled_code:
__int64 __fastcall make_foreign_lt_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_lt_p);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
return node_foreign_new(a1, &foreign_lt_p);
}

original_code: static node_t *make_foreign_lt_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_lt_p); }

canonical_original_code: static struct node *make_foreign_lt_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_lt_p); }


decompiled_code:
__int64 __fastcall make_foreign_eq_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_eq_p);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
return node_foreign_new(a1, &foreign_eq_p);
}

original_code: static node_t *make_foreign_eq_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_eq_p); }

canonical_original_code: static struct node *make_foreign_eq_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_eq_p); }


decompiled_code:
__int64 __fastcall make_foreign_smeq_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_smeq_p);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return node_foreign_new(a1, &foreign_smeq_p);
}

original_code: static node_t *make_foreign_smeq_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_smeq_p); }

canonical_original_code: static struct node *make_foreign_smeq_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_smeq_p); }


decompiled_code:
__int64 __fastcall make_foreign_cons(__int64 a1)
{
return node_foreign_new(a1, &foreign_cons);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
return node_foreign_new(a1, &foreign_cons);
}

original_code: static node_t *make_foreign_cons (memory_state_t *ms) { return node_foreign_new(ms, foreign_cons); }

canonical_original_code: static struct node *make_foreign_cons(struct memory_state *ms) { return node_foreign_new(ms, foreign_cons); }


decompiled_code:
__int64 __fastcall make_foreign_splsym(__int64 a1)
{
return node_foreign_new(a1, &foreign_splsym);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1)
{
return node_foreign_new(a1, &foreign_splsym);
}

original_code: static node_t *make_foreign_splsym (memory_state_t *ms) { return node_foreign_new(ms, foreign_splsym); }

canonical_original_code: static struct node *make_foreign_splsym(struct memory_state *ms) { return node_foreign_new(ms, foreign_splsym); }


decompiled_code:
__int64 __fastcall make_foreign_mksym(__int64 a1)
{
return node_foreign_new(a1, &foreign_mksym);
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1)
{
return node_foreign_new(a1, &foreign_mksym);
}

original_code: static node_t *make_foreign_mksym (memory_state_t *ms) { return node_foreign_new(ms, foreign_mksym); }

canonical_original_code: static struct node *make_foreign_mksym(struct memory_state *ms) { return node_foreign_new(ms, foreign_mksym); }


decompiled_code:
__int64 __fastcall make_foreign_cdr(__int64 a1)
{
return node_foreign_new(a1, &foreign_cdr);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
return node_foreign_new(a1, &foreign_cdr);
}

original_code: static node_t *make_foreign_cdr (memory_state_t *ms) { return node_foreign_new(ms, foreign_cdr); }

canonical_original_code: static struct node *make_foreign_cdr(struct memory_state *ms) { return node_foreign_new(ms, foreign_cdr); }


decompiled_code:
__int64 __fastcall make_foreign_car(__int64 a1)
{
return node_foreign_new(a1, &foreign_car);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1)
{
return node_foreign_new(a1, &foreign_car);
}

original_code: static node_t *make_foreign_car (memory_state_t *ms) { return node_foreign_new(ms, foreign_car); }

canonical_original_code: static struct node *make_foreign_car(struct memory_state *ms) { return node_foreign_new(ms, foreign_car); }


decompiled_code:
__int64 __fastcall make_foreign_func_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_func_p);
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1)
{
return node_foreign_new(a1, &foreign_func_p);
}

original_code: static node_t *make_foreign_func_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_func_p); }

canonical_original_code: static struct node *make_foreign_func_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_func_p); }


decompiled_code:
__int64 __fastcall make_foreign_cons_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_cons_p);
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 a1)
{
return node_foreign_new(a1, &foreign_cons_p);
}

original_code: static node_t *make_foreign_cons_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_cons_p); }

canonical_original_code: static struct node *make_foreign_cons_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_cons_p); }


decompiled_code:
__int64 __fastcall make_foreign_sym_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_sym_p);
}

canonical_decompiled_code:
__int64 __fastcall func26(__int64 a1)
{
return node_foreign_new(a1, &foreign_sym_p);
}

original_code: static node_t *make_foreign_sym_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_sym_p); }

canonical_original_code: static struct node *make_foreign_sym_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_sym_p); }


decompiled_code:
__int64 __fastcall make_foreign_val_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_val_p);
}

canonical_decompiled_code:
__int64 __fastcall func27(__int64 a1)
{
return node_foreign_new(a1, &foreign_val_p);
}

original_code: static node_t *make_foreign_val_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_val_p); }

canonical_original_code: static struct node *make_foreign_val_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_val_p); }


decompiled_code:
__int64 __fastcall make_foreign_nil_p(__int64 a1)
{
return node_foreign_new(a1, &foreign_nil_p);
}

canonical_decompiled_code:
__int64 __fastcall func28(__int64 a1)
{
return node_foreign_new(a1, &foreign_nil_p);
}

original_code: static node_t *make_foreign_nil_p (memory_state_t *ms) { return node_foreign_new(ms, foreign_nil_p); }

canonical_original_code: static struct node *make_foreign_nil_p(struct memory_state *ms) { return node_foreign_new(ms, foreign_nil_p); }


decompiled_code:
__int64 __fastcall make_special_EVAL(__int64 a1)
{
return node_special_func_new(a1, 7LL);
}

canonical_decompiled_code:
__int64 __fastcall func29(__int64 a1)
{
return node_special_func_new(a1, 7LL);
}

original_code: static node_t *make_special_EVAL (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_EVAL); }

canonical_original_code: static struct node *make_special_EVAL(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_EVAL); }


decompiled_code:
__int64 __fastcall make_special_DEFINED(__int64 a1)
{
return node_special_func_new(a1, 6LL);
}

canonical_decompiled_code:
__int64 __fastcall func30(__int64 a1)
{
return node_special_func_new(a1, 6LL);
}

original_code: static node_t *make_special_DEFINED (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_DEFINED); }

canonical_original_code: static struct node *make_special_DEFINED(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_DEFINED); }


decompiled_code:
__int64 __fastcall make_special_SET(__int64 a1)
{
return node_special_func_new(a1, 5LL);
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 a1)
{
return node_special_func_new(a1, 5LL);
}

original_code: static node_t *make_special_SET (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_SET); }

canonical_original_code: static struct node *make_special_SET(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_SET); }


decompiled_code:
__int64 __fastcall make_special_DEF(__int64 a1)
{
return node_special_func_new(a1, 4LL);
}

canonical_decompiled_code:
__int64 __fastcall func32(__int64 a1)
{
return node_special_func_new(a1, 4LL);
}

original_code: static node_t *make_special_DEF (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_DEF); }

canonical_original_code: static struct node *make_special_DEF(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_DEF); }


decompiled_code:
__int64 __fastcall make_special_MK_CONT(__int64 a1)
{
return node_special_func_new(a1, 3LL);
}

canonical_decompiled_code:
__int64 __fastcall func33(__int64 a1)
{
return node_special_func_new(a1, 3LL);
}

original_code: static node_t *make_special_MK_CONT (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_MK_CONT); }

canonical_original_code: static struct node *make_special_MK_CONT(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_MK_CONT); }


decompiled_code:
__int64 __fastcall make_special_LAMBDA(__int64 a1)
{
return node_special_func_new(a1, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func34(__int64 a1)
{
return node_special_func_new(a1, 1LL);
}

original_code: static node_t *make_special_LAMBDA (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_LAMBDA); }

canonical_original_code: static struct node *make_special_LAMBDA(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_LAMBDA); }


decompiled_code:
__int64 __fastcall make_special_IF(__int64 a1)
{
return node_special_func_new(a1, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func35(__int64 a1)
{
return node_special_func_new(a1, 0LL);
}

original_code: static node_t *make_special_IF (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_IF); }

canonical_original_code: static struct node *make_special_IF(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_IF); }


decompiled_code:
__int64 __fastcall make_special_QUOTE(__int64 a1)
{
return node_special_func_new(a1, 2LL);
}

canonical_decompiled_code:
__int64 __fastcall func36(__int64 a1)
{
return node_special_func_new(a1, 2LL);
}

original_code: static node_t *make_special_QUOTE (memory_state_t *ms) { return node_special_func_new(ms, SPECIAL_QUOTE); }

canonical_original_code: static struct node *make_special_QUOTE(struct memory_state *ms) { return node_special_func_new(ms, SPECIAL_QUOTE); }


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

do
result = memory_gc_iterate(a1);
while ( !(_BYTE)result );
return result;
}

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

do
result = memory_gc_iterate(a1);
while ( !(_BYTE)result );
return result;
}

original_code:
static inline void memory_gc_cycle(memory_state_t *s)
 { while(!memory_gc_iterate(s)); }

canonical_original_code:
static inline void memory_gc_cycle(struct memory_state *s)
 { while(!memory_gc_iterate(s)); }

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; } *

return_type: void


decompiled_code:
bool __fastcall dlnode_is_terminal(__int64 a1)
{
return *(_QWORD *)(a1 + 16) == a1;
}

canonical_decompiled_code:
bool __fastcall func0(__int64 a1)
{
return *(_QWORD *)(a1 + 16) == a1;
}

original_code:
static inline _Bool dlnode_is_terminal(dlnode_t *n)
 { return n == &(n->owner->hdr); }

canonical_original_code:
static inline _Bool dlnode_is_terminal(struct dlnode *n)
 { return n == &(n->owner->hdr); }

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


decompiled_code:
bool __fastcall dlist_is_empty(__int64 a1)
{
return *(_QWORD *)(a1 + 8) == a1;
}

canonical_decompiled_code:
bool __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 8) == a1;
}

original_code:
static inline _Bool dlist_is_empty(dlist_t *l)
 { return l->hdr.next == &(l->hdr); }

canonical_original_code:
static inline _Bool dlist_is_empty(struct dlist *l)
 { return l->hdr.next == &(l->hdr); }

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


decompiled_code:
__int64 __fastcall hdr_to_fmcell(__int64 a1)
{
return a1 - 8;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return a1 - 8;
}

original_code:
static free_mem_cell_t *hdr_to_fmcell(dlnode_t *hdr)
{
 char *base = (char *) hdr - __builtin_offsetof (free_mem_cell_t, u.hdr);
 return (free_mem_cell_t *) base;
}

canonical_original_code:
static struct free_mem_cell_t *hdr_to_fmcell(struct dlnode *hdr)
{
 char *base = (char *) hdr - __builtin_offsetof (free_mem_cell_t, u.hdr);
 return (struct free_mem_cell_t *) base;
}

variable_types:
hdr
struct dlnode *

variable_types:
base
char *

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

user_defined_types: struct free_mem_cell_t { unsigned long len; union { struct dlnode hdr; int data[]; } u; }


decompiled_code:
__int64 __fastcall dlist_insertfirst(__int64 a1, __int64 a2)
{
return dlnode_insert(a1, a2, *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
return dlnode_insert(a1, a2, *(_QWORD *)(a1 + 8));
}

original_code:
static inline void dlist_insertfirst(dlist_t *l, dlnode_t *n)
 { dlnode_insert(&(l->hdr), n, l->hdr.next); }

canonical_original_code:
static inline void dlist_insertfirst(struct dlist *l, struct dlnode *n)
 { dlnode_insert(&(l->hdr), n, l->hdr.next); }

variable_types:
n
struct dlnode *


decompiled_code:
bool __fastcall fmcache_state_reset(__int64 a1)
{
__int64 v1; // rax
void *v2; // rax
bool result; // al

while ( 1 )
{
result = dlist_is_empty(a1);
if ( result )
break;
v1 = dlist_first(a1);
v2 = (void *)dlnode_remove(v1);
free(v2);
}
*(_QWORD *)(a1 + 48) = 0LL;
return result;
}

canonical_decompiled_code:
bool __fastcall func7(__int64 a1)
{
__int64 v1; // rax
void *v2; // rax
bool result; // al

while ( 1 )
{
result = func3(a1);
if ( result )
break;
v1 = func2(a1);
v2 = (void *)dlnode_remove(v1);
free(v2);
}
*(_QWORD *)(a1 + 48) = 0LL;
return result;
}

original_code:
void fmcache_state_reset(fmcache_state_t * state)
{
 dlnode_t *n;
 while(! dlist_is_empty(&(state->free_list))) {
  n = dlnode_remove(dlist_first(&(state->free_list)));
  free(n);
 }
 state->alloc_count = 0;
}

canonical_original_code:
void fmcache_state_reset(struct fmcache_state_t *state)
{
 struct dlnode *n;
 while(! dlist_is_empty(&(state->free_list))) {
  n = dlnode_remove(dlist_first(&(state->free_list)));
  free(n);
 }
 state->alloc_count = 0;
}

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; } *

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:
__int64 __fastcall fmcache_return(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 result; // rax

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

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

v2 = func5(a1) + 8;
dlnode_init(v2);
result = func6(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 func10(__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;
}

return_type: unsigned long


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; }


decompiled_code:
__int64 __fastcall find_keyval(__int64 a1, _QWORD *a2)
{
__int64 v2; // r13
const char *v3; // r12
const char *v4; // rax
int v5; // edx
__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; // edx
__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_241, &unk_23F, 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_241, &unk_23F, 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);
}


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; // ebp
__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; // ebp
__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)
{
return frame_iterate(a1, print_val_cb, a2, 1LL, print_env_cb, a2);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
return frame_iterate(a1, print_val_cb, a2, 1LL, print_env_cb, a2);
}

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, _QWORD *a2)
{
int v2; // eax
__int64 v4; // rax
__int64 v5; // rax

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

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

v2 = token_type(a1[1]);
if ( v2 == 4 )
{
v4 = token_sym(a1[1]);
*a2 = node_symbol_new(*a1, v4);
}
else
{
if ( v2 != 5 )
return 5LL;
v5 = token_lit(a1[1]);
*a2 = node_value_new(*a1, v5);
}
if ( !*a2 )
_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)
{
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v5; // eax
__int64 v6; // [rsp+0h] [rbp-28h] BYREF
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, _QWORD *a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v5; // eax
__int64 v6; // [rsp+0h] [rbp-28h] BYREF
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

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

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)
{
unsigned int v2; // eax
unsigned int v3; // ebx
int v4; // eax
int v5; // eax
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v7[0] = 0LL;
v2 = token_type(a1[1]);
v3 = v2;
if ( v2 > 5 )
{
if ( v2 == 6 )
return 7;
v3 = 6;
}
else
{
if ( v2 > 3 )
{
v3 = parse_atom(a1, v7);
goto LABEL_16;
}
if ( v2 != 1 )
{
v3 = 6;
goto LABEL_10;
}
token_chomp(a1[1]);
v4 = token_type(a1[1]);
if ( v4 != 3 )
{
if ( v4 == 6 )
{
v3 = 3;
goto LABEL_10;
}
if ( v4 == 2 )
{
token_chomp(a1[1]);
v3 = 0;
}
else
{
v3 = parse_list(a1, v7);
v5 = token_type(a1[1]);
if ( v5 != 2 )
{
v3 = (v5 != 6) + 3;
goto LABEL_10;
}
token_chomp(a1[1]);
}
LABEL_16:
*a2 = v7[0];
return v3;
}
}
LABEL_10:
node_droproot(v7[0]);
return v3;
}

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

v7[0] = 0LL;
v2 = token_type(a1[1]);
v3 = v2;
if ( v2 > 5 )
{
if ( v2 == 6 )
return 7;
v3 = 6;
}
else
{
if ( v2 > 3 )
{
v3 = func0(a1, v7);
goto LABEL_16;
}
if ( v2 != 1 )
{
v3 = 6;
goto LABEL_10;
}
token_chomp(a1[1]);
v4 = token_type(a1[1]);
if ( v4 != 3 )
{
if ( v4 == 6 )
{
v3 = 3;
goto LABEL_10;
}
if ( v4 == 2 )
{
token_chomp(a1[1]);
v3 = 0;
}
else
{
v3 = func1(a1, v7);
v5 = token_type(a1[1]);
if ( v5 != 2 )
{
v3 = (v5 != 6) + 3;
goto LABEL_10;
}
token_chomp(a1[1]);
}
LABEL_16:
*a2 = v7[0];
return v3;
}
}
LABEL_10:
node_droproot(v7[0]);
return v3;
}

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; // ebx
__int64 v6; // [rsp+0h] [rbp-38h] BYREF
__int64 v7; // [rsp+8h] [rbp-30h]
__int64 v8[4]; // [rsp+18h] [rbp-20h] BYREF

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

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

v8[0] = 0LL;
v6 = a1;
v7 = a2;
if ( !(unsigned int)token_type(a2) )
token_chomp(v7);
v4 = func2(&v6, v8);
node_handle_update(a3, v8[0]);
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_3E9, 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_3E9, 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 v6; // r13
__int64 v7; // rbx
__int64 v8; // rbp
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

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

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r13
__int64 v7; // rbx
__int64 v8; // rbp
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

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

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; // rbx
__int64 v8; // rbp
__int64 v9; // rsi
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax

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

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

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

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; // rbp
__int64 v3; // r12
__int64 v4; // r14
__int64 v5; // r12
__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; // rbp
__int64 v3; // r12
__int64 v4; // r14
__int64 v5; // r12
__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; // r12
__int64 result; // rax
__int64 v11; // rbx
__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_4:
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_4;
}
}

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; // r12
__int64 result; // rax
__int64 v11; // rbx
__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_4:
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_4;
}
}

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 result; // rax

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

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

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
result = node_droproot(*(_QWORD *)(a1 + 8 * i));
}
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)
{
unsigned int v5; // ebx
void *v7; // rsp
_QWORD *v8; // r12
__int64 v9; // r14
__int64 v10; // rax
void *ptr; // [rsp+0h] [rbp-30h] BYREF
__int64 v12[5]; // [rsp+8h] [rbp-28h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
unsigned int v5; // ebx
void *v7; // rsp
_QWORD *v8; // r12
__int64 v9; // r14
__int64 v10; // rax
void *ptr; // [rsp+0h] [rbp-30h] BYREF
__int64 v12[5]; // [rsp+8h] [rbp-28h] BYREF

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

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 v5; // er14
__int64 i; // r13
__int64 v7; // r12
void *v9; // rsp
int v10; // eax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
unsigned int v14; // er14
unsigned int v15; // er12
char *v16; // rax
unsigned int v17; // er12
char *v18; // rax
unsigned int v19; // er12
char *v20; // rax
__int64 v21; // r15
__int64 v22; // rax
const char *v23; // rax
__int64 v24; // rax
const char *v25; // rax
char v26[8]; // [rsp+0h] [rbp-110h] BYREF
__int64 v27; // [rsp+8h] [rbp-108h]
char v28[64]; // [rsp+10h] [rbp-100h] BYREF
char v29[96]; // [rsp+50h] [rbp-C0h] BYREF
char v30[8]; // [rsp+B0h] [rbp-60h] BYREF
__int64 v31; // [rsp+B8h] [rbp-58h]
__int64 v32; // [rsp+C0h] [rbp-50h]
int errnum; // [rsp+C8h] [rbp-48h]
__int64 v34[7]; // [rsp+D8h] [rbp-38h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
unsigned int v5; // er14
__int64 i; // r13
__int64 v7; // r12
void *v9; // rsp
int v10; // eax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
unsigned int v14; // er14
unsigned int v15; // er12
char *v16; // rax
unsigned int v17; // er12
char *v18; // rax
unsigned int v19; // er12
char *v20; // rax
__int64 v21; // r15
__int64 v22; // rax
const char *v23; // rax
__int64 v24; // rax
const char *v25; // rax
char v26[8]; // [rsp+0h] [rbp-110h] BYREF
__int64 v27; // [rsp+8h] [rbp-108h]
char v28[64]; // [rsp+10h] [rbp-100h] BYREF
char v29[96]; // [rsp+50h] [rbp-C0h] BYREF
char v30[8]; // [rsp+B0h] [rbp-60h] BYREF
__int64 v31; // [rsp+B8h] [rbp-58h]
__int64 v32; // [rsp+C0h] [rbp-50h]
int errnum; // [rsp+C8h] [rbp-48h]
__int64 v34[7]; // [rsp+D8h] [rbp-38h] BYREF

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

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; } *