decompiled_code:
__int64 __fastcall sio_putchar(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 1LL, do_sio_putchar, a2, a4, 0LL);
}

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

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

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


decompiled_code:
__int64 __fastcall sio_eputchar(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 1LL, do_sio_eputchar, a2, a4, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
return extract_args(a1, 1LL, do_sio_eputchar, a2, a4, 0LL);
}

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

canonical_original_code:
enum eval_err_t sio_eputchar(struct memory_state *ms, struct node *args, struct node *env_handle, struct node **result)
{
 return extract_args(ms, 1, do_sio_eputchar, args, result, ((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; } *

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

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

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


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 }


decompiled_code:
__int64 __fastcall locals_state_set(__int64 a1, _QWORD *a2, __int64 a3)
{
__int64 v3; // rax

v3 = node_value_new(a1, a3);
return node_handle_update(*a2, v3);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2, __int64 a3)
{
__int64 v3; // rax

v3 = node_value_new(a1, a3);
return node_handle_update(*a2, v3);
}

original_code:
static void locals_state_set(memory_state_t *s, node_t **locals, value_t v)
{
 node_handle_update(locals[LOCAL_ID_STATE],
                    node_value_new(s, v));
}

canonical_original_code:
static void locals_state_set(struct memory_state *s, struct node **locals, long v)
{
 node_handle_update(locals[LOCAL_ID_STATE],
                    node_value_new(s, v));
}

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: v long

return_type: void

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 locals_restart_set(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax

v3 = node_blob_new(a1, a3, 0LL, 0LL);
return node_handle_update(*(_QWORD *)(a2 + 8), v3);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax

v3 = node_blob_new(a1, a3, 0LL, 0LL);
return node_handle_update(*(_QWORD *)(a2 + 8), v3);
}

original_code:
static void locals_restart_set(memory_state_t *s, node_t **locals, void *addr)
{
 node_handle_update(locals[LOCAL_ID_RESTART],
                    node_blob_new(s, addr, ((void *)0), 0));
}

canonical_original_code:
static void locals_restart_set(struct memory_state *s, struct node **locals, void *addr)
{
 node_handle_update(locals[LOCAL_ID_RESTART],
                    node_blob_new(s, addr, ((void *)0), 0));
}

variable_types:
addr
void *

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

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

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


decompiled_code:
__int64 __fastcall locals_state_get(_QWORD *a1)
{
__int64 v1; // rax

if ( !node_handle(*a1) )
return 0LL;
v1 = node_handle(*a1);
return node_value(v1);
}

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

if ( !node_handle(*a1) )
return 0LL;
v1 = node_handle(*a1);
return node_value(v1);
}

original_code:
static value_t locals_state_get(node_t **locals)
{
 if(node_handle(locals[LOCAL_ID_STATE])) {
  return node_value(node_handle(locals[LOCAL_ID_STATE]));
 } else {
  return 0;
 }
}

canonical_original_code:
static long locals_state_get(struct node **locals)
{
 if(node_handle(locals[LOCAL_ID_STATE])) {
  return node_value(node_handle(locals[LOCAL_ID_STATE]));
 } else {
  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; } **

return_type: long


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

if ( !node_handle(*(_QWORD *)(a1 + 8)) )
return 0LL;
v1 = node_handle(*(_QWORD *)(a1 + 8));
return node_blob_addr(v1);
}

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

if ( !node_handle(*(_QWORD *)(a1 + 8)) )
return 0LL;
v1 = node_handle(*(_QWORD *)(a1 + 8));
return node_blob_addr(v1);
}

original_code:
static void *locals_restart_get(node_t **locals)
{
 if(node_handle(locals[LOCAL_ID_RESTART])) {
  return node_blob_addr(node_handle(locals[LOCAL_ID_RESTART]));
 } else {
  return ((void *)0);
 }
}

canonical_original_code:
static void *locals_restart_get(struct node **locals)
{
 if(node_handle(locals[LOCAL_ID_RESTART])) {
  return node_blob_addr(node_handle(locals[LOCAL_ID_RESTART]));
 } else {
  return ((void *)0);
 }
}

return_type: void *


decompiled_code:
__int64 __fastcall lambda_bind(__int64 a1, __int64 a2, __int64 a3)
{
__int64 i; // rbp
unsigned int v5; // edi
__int64 result; // rax
__int64 v7; // r14
__int64 v8; // r13
char v9; // r15
__int64 v10[8]; // [rsp+8h] [rbp-40h] BYREF

for ( i = a2; i; a3 = node_cons_cdr(a3) )
{
if ( (unsigned int)node_type(i) == 2 )
{
if ( (unsigned int)node_type(a3) != 2 )
return eval_err(4u);
v7 = node_cons_car(a3);
v8 = node_cons_car(i);
if ( (unsigned int)node_type(v8) != 4 )
return eval_err(9u);
v9 = 0;
}
else
{
if ( (unsigned int)node_type(i) != 4 )
{
v5 = 11;
goto LABEL_5;
}
v7 = a3;
v8 = i;
v9 = 1;
}
if ( (unsigned __int8)environ_keyval_frame(a1, v8, v10) )
node_cons_patch_cdr(v10[0], v7);
else
environ_add(a1, v8, v7);
if ( v9 )
goto LABEL_15;
i = node_cons_cdr(i);
}
v5 = 2;
if ( a3 )
LABEL_5:
result = eval_err(v5);
else
LABEL_15:
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3)
{
__int64 i; // rbp
unsigned int v5; // edi
__int64 result; // rax
__int64 v7; // r14
__int64 v8; // r13
char v9; // r15
__int64 v10[8]; // [rsp+8h] [rbp-40h] BYREF

for ( i = a2; i; a3 = node_cons_cdr(a3) )
{
if ( (unsigned int)node_type(i) == 2 )
{
if ( (unsigned int)node_type(a3) != 2 )
return func0(4u);
v7 = node_cons_car(a3);
v8 = node_cons_car(i);
if ( (unsigned int)node_type(v8) != 4 )
return func0(9u);
v9 = 0;
}
else
{
if ( (unsigned int)node_type(i) != 4 )
{
v5 = 11;
goto LABEL_5;
}
v7 = a3;
v8 = i;
v9 = 1;
}
if ( (unsigned __int8)environ_keyval_frame(a1, v8, v10) )
node_cons_patch_cdr(v10[0], v7);
else
environ_add(a1, v8, v7);
if ( v9 )
goto LABEL_15;
i = node_cons_cdr(i);
}
v5 = 2;
if ( a3 )
LABEL_5:
result = func0(v5);
else
LABEL_15:
result = 0LL;
return result;
}

original_code:
eval_err_t lambda_bind(node_t *env_handle, node_t *vars, node_t *args)
{
 node_t *var_curs = ((void *)0), *arg_curs = ((void *)0);
 node_t *kv, *name, *value;
 _Bool early_term = 0;
 var_curs = vars;
 arg_curs = args;
 while(1) {
  if(! var_curs) {
   if(arg_curs) {
    return eval_err(EVAL_ERR_TOO_MANY_ARGS);
   }
   break;
  } else if(node_type(var_curs) == NODE_CONS) {
   if(node_type(arg_curs) != NODE_CONS) {
    return eval_err(EVAL_ERR_MISSING_ARG);
   }
   value = node_cons_car(arg_curs);
   name = node_cons_car(var_curs);
   if(node_type(name) != NODE_SYMBOL) {
    return eval_err(EVAL_ERR_EXPECTED_SYMBOL);
   }
  } else if(node_type(var_curs) == NODE_SYMBOL) {
   value = arg_curs;
   name = var_curs;
   early_term = 1;
  } else {
   return eval_err(EVAL_ERR_EXPECTED_CONS_SYM);
  }
  if(environ_keyval_frame(env_handle, name, &kv)) {
   node_cons_patch_cdr(kv, value);
  } else {
   environ_add(env_handle, name, value);
  }
  if(early_term) {
   break;
  }
  var_curs = node_cons_cdr(var_curs);
  arg_curs = node_cons_cdr(arg_curs);
 }
 return EVAL_OK;
}

canonical_original_code:
enum eval_err_t lambda_bind(struct node *env_handle, struct node *vars, struct node *args)
{
 struct node *var_curs = ((void *)0); struct node *arg_curs = ((void *)0);
 struct node *kv; struct node *name; struct node *value;
 _Bool early_term = 0;
 var_curs = vars;
 arg_curs = args;
 while(1) {
  if(! var_curs) {
   if(arg_curs) {
    return eval_err(EVAL_ERR_TOO_MANY_ARGS);
   }
   break;
  } else if(node_type(var_curs) == NODE_CONS) {
   if(node_type(arg_curs) != NODE_CONS) {
    return eval_err(EVAL_ERR_MISSING_ARG);
   }
   value = node_cons_car(arg_curs);
   name = node_cons_car(var_curs);
   if(node_type(name) != NODE_SYMBOL) {
    return eval_err(EVAL_ERR_EXPECTED_SYMBOL);
   }
  } else if(node_type(var_curs) == NODE_SYMBOL) {
   value = arg_curs;
   name = var_curs;
   early_term = 1;
  } else {
   return eval_err(EVAL_ERR_EXPECTED_CONS_SYM);
  }
  if(environ_keyval_frame(env_handle, name, &kv)) {
   node_cons_patch_cdr(kv, value);
  } else {
   environ_add(env_handle, name, value);
  }
  if(early_term) {
   break;
  }
  var_curs = node_cons_cdr(var_curs);
  arg_curs = node_cons_cdr(arg_curs);
 }
 return EVAL_OK;
}

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:
vars
struct node *

variable_types:
args
struct node *


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 }


original_code:
eval_err_t extract_args(
 memory_state_t *ms,
 unsigned int n,
 callback_t cb,
 node_t *args,
 node_t **result,
 void *p)
{
 unsigned int i;
 node_t *cursor = args;
 node_t **arglist = __builtin_alloca (n * sizeof(node_t *));
 for(i = 0; i < n; i++) {
  if(node_type(cursor) != NODE_CONS) {
   *result = args;
   return eval_err(EVAL_ERR_EXPECTED_CONS);
  }
  arglist[i] = node_cons_car(cursor);
  cursor = node_cons_cdr(cursor);
 }
 if(cursor) {
  *result = args;
  return eval_err(EVAL_ERR_TOO_MANY_ARGS);
 }
 return cb(ms, arglist, result, p);
}

canonical_original_code:
enum eval_err_t extract_args(struct memory_state *ms, unsigned int n, enum eval_err_t (*cb)(struct memory_state *ms, struct node **args, struct node **result, void *p), struct node *args, struct node **result, void *p)
{
 unsigned int i;
 struct node *cursor = args;
 struct node **arglist = __builtin_alloca (n * sizeof(node_t *));
 for(i = 0; i < n; i++) {
  if(node_type(cursor) != NODE_CONS) {
   *result = args;
   return eval_err(EVAL_ERR_EXPECTED_CONS);
  }
  arglist[i] = node_cons_car(cursor);
  cursor = node_cons_cdr(cursor);
 }
 if(cursor) {
  *result = args;
  return eval_err(EVAL_ERR_TOO_MANY_ARGS);
 }
 return cb(ms, arglist, result, p);
}

variable_types:
n
unsigned int

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 } (*)(struct memory_state *ms, 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; } **args, struct node **result, void *p)

variable_types:
p
void *

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall count_list_len(__int64 a1, _QWORD *a2)
{
__int64 v2; // rbp

*a2 = 0LL;
if ( !a1 )
return 0LL;
v2 = a1;
do
{
if ( (unsigned int)node_type(v2) != 2 )
return 0xFFFFFFFFLL;
++*a2;
v2 = node_cons_cdr(v2);
}
while ( v2 );
return 0LL;
}

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

*a2 = 0LL;
if ( !a1 )
return 0LL;
v2 = a1;
do
{
if ( (unsigned int)node_type(v2) != 2 )
return 0xFFFFFFFFLL;
++*a2;
v2 = node_cons_cdr(v2);
}
while ( v2 );
return 0LL;
}

original_code:
int count_list_len(node_t *cons, size_t *len)
{
 node_t *cursor;
 int status = 0;
 *len = 0;
 for(cursor = cons;
     cursor;
     cursor = node_cons_cdr(cursor)) {
  if(node_type(cursor) != NODE_CONS) {
   status = -1;
   break;
  }
  (*len)++;
 }
 return status;
}

canonical_original_code:
int count_list_len(struct node *cons, unsigned long *len)
{
 struct node *cursor;
 int status = 0;
 *len = 0;
 for(cursor = cons;
     cursor;
     cursor = node_cons_cdr(cursor)) {
  if(node_type(cursor) != NODE_CONS) {
   status = -1;
   break;
  }
  (*len)++;
 }
 return status;
}

variable_types:
len
unsigned long *

variable_types: status int

return_type: int


decompiled_code:
__int64 __fastcall list_to_cstr(__int64 a1, __int64 a2, __int64 a3, _QWORD *a4)
{
__int64 v6; // rbp
__int64 v7; // rbx
__int64 v8; // r12
unsigned __int64 v9; // rax
__int64 result; // rax

if ( a1 )
{
v6 = a1;
v7 = 0LL;
while ( 1 )
{
if ( (unsigned int)node_type(v6) != 2 )
{
result = 0xFFFFFFFFLL;
goto LABEL_9;
}
v8 = node_cons_car(v6);
if ( (unsigned int)node_type(v8) != 5 )
{
result = 4294967294LL;
goto LABEL_9;
}
v9 = node_value(v8);
if ( v9 > 0xFF )
break;
if ( v7 == a3 )
goto LABEL_17;
++v7;
*(_BYTE *)(a2 + v7 - 1) = v9;
v6 = node_cons_cdr(v6);
if ( !v6 )
goto LABEL_13;
}
result = 4294967293LL;
}
else
{
v7 = 0LL;
LABEL_13:
if ( a3 == v7 )
{
LABEL_17:
v7 = a3;
result = 4294967292LL;
}
else
{
*(_BYTE *)(a2 + v7) = 0;
result = 0LL;
++v7;
}
}
LABEL_9:
if ( a4 )
*a4 = v7;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, _QWORD *a4)
{
__int64 v6; // rbp
__int64 v7; // rbx
__int64 v8; // r12
unsigned __int64 v9; // rax
__int64 result; // rax

if ( a1 )
{
v6 = a1;
v7 = 0LL;
while ( 1 )
{
if ( (unsigned int)node_type(v6) != 2 )
{
result = 0xFFFFFFFFLL;
goto LABEL_9;
}
v8 = node_cons_car(v6);
if ( (unsigned int)node_type(v8) != 5 )
{
result = 4294967294LL;
goto LABEL_9;
}
v9 = node_value(v8);
if ( v9 > 0xFF )
break;
if ( v7 == a3 )
goto LABEL_17;
++v7;
*(_BYTE *)(a2 + v7 - 1) = v9;
v6 = node_cons_cdr(v6);
if ( !v6 )
goto LABEL_13;
}
result = 4294967293LL;
}
else
{
v7 = 0LL;
LABEL_13:
if ( a3 == v7 )
{
LABEL_17:
v7 = a3;
result = 4294967292LL;
}
else
{
*(_BYTE *)(a2 + v7) = 0;
result = 0LL;
++v7;
}
}
LABEL_9:
if ( a4 )
*a4 = v7;
return result;
}

original_code:
int list_to_cstr(
 node_t *clist,
 char *strbuf,
 size_t buflen,
 size_t *written)
{
 node_t *cursor;
 node_t *val;
 size_t off;
 int status = 0;
 value_t cval;
 off = 0;
 for(cursor = clist; cursor; cursor = node_cons_cdr(cursor)) {
  if(node_type(cursor) != NODE_CONS) {
   status = -1;
   goto finish;
  }
  val = node_cons_car(cursor);
  if(node_type(val) != NODE_VALUE) {
   status = -2;
   goto finish;
  }
  cval = node_value(val);
  if(cval > (0x7f * 2 + 1) || cval < 0) {
   status = -3;
   goto finish;
  }
  if(off == (buflen)) {
   status = -4;
   goto finish;
  }
  strbuf[off++] = (unsigned char) cval;
 }
 if(off == (buflen)) {
  status = -4;
  goto finish;
 }
 strbuf[off++] = 0;
finish:
 if(written) *written = off;
 return status;
}

canonical_original_code:
int list_to_cstr(struct node *clist, char *strbuf, unsigned long buflen, unsigned long *written)
{
 struct node *cursor;
 struct node *val;
 unsigned long off;
 int status = 0;
 long cval;
 off = 0;
 for(cursor = clist; cursor; cursor = node_cons_cdr(cursor)) {
  if(node_type(cursor) != NODE_CONS) {
   status = -1;
   goto finish;
  }
  val = node_cons_car(cursor);
  if(node_type(val) != NODE_VALUE) {
   status = -2;
   goto finish;
  }
  cval = node_value(val);
  if(cval > (0x7f * 2 + 1) || cval < 0) {
   status = -3;
   goto finish;
  }
  if(off == (buflen)) {
   status = -4;
   goto finish;
  }
  strbuf[off++] = (unsigned char) cval;
 }
 if(off == (buflen)) {
  status = -4;
  goto finish;
 }
 strbuf[off++] = 0;
finish:
 if(written) *written = off;
 return status;
}

variable_types:
strbuf
char *

variable_types:
buflen
unsigned long

variable_types:
written
unsigned long *

variable_types:
off
unsigned long

variable_types: cval long


original_code:
node_t *generate_argv(memory_state_t *ms, int argc, char *argv[])
{
 unsigned int len;
 int i, c;
 node_t *cnode, *lnode, *argv_head;
 argv_head = ((void *)0);
 for(i = argc - 1; i >= 0; i--) {
  len = strlen(argv[i]);
  lnode = ((void *)0);
  for(c = len - 1; c >= 0; c--) {
   cnode = node_value_new(ms, argv[i][c]);
   lnode = node_cons_new(ms, cnode, lnode);
  }
  argv_head = node_cons_new(ms, lnode, argv_head);
 }
 return argv_head;
}

canonical_original_code:
struct node *generate_argv(struct memory_state *ms, int argc, char *argv[])
{
 unsigned int len;
 int i; int c;
 struct node *cnode; struct node *lnode; struct node *argv_head;
 argv_head = ((void *)0);
 for(i = argc - 1; i >= 0; i--) {
  len = strlen(argv[i]);
  lnode = ((void *)0);
  for(c = len - 1; c >= 0; c--) {
   cnode = node_value_new(ms, argv[i][c]);
   lnode = node_cons_new(ms, cnode, lnode);
  }
  argv_head = node_cons_new(ms, lnode, argv_head);
 }
 return argv_head;
}

variable_types:
ms
struct memory_state *

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
len
unsigned int

variable_types: i int

variable_types: c int

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


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

if ( (unsigned __int8)(a1 - 48) <= 9u )
return (unsigned int)(char)(a1 - 48);
if ( (unsigned __int8)(a1 - 65) <= 0x19u )
return (unsigned int)(char)(a1 - 55);
result = (unsigned int)(char)(a1 - 87);
if ( (unsigned __int8)(a1 - 97) >= 0x1Au )
result = 0xFFFFFFFFLL;
return result;
}

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

if ( (unsigned __int8)(a1 - 48) <= 9u )
return (unsigned int)(char)(a1 - 48);
if ( (unsigned __int8)(a1 - 65) <= 0x19u )
return (unsigned int)(char)(a1 - 55);
result = (unsigned int)(char)(a1 - 87);
if ( (unsigned __int8)(a1 - 97) >= 0x1Au )
result = 0xFFFFFFFFLL;
return result;
}

original_code:
static int char_to_num(char c)
{
 if(c >= '0' && c <= '9') return c - '0';
 if(c >= 'A' && c <= 'Z') return c - 'A' + 10;
 if(c >= 'a' && c <= 'z') return c - 'a' + 10;
 return -1;
}

variable_types: c char


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

if ( a1 <= 9 )
return a1 + 48;
result = a1 + 87;
if ( a1 >= 0x24 )
result = 0LL;
return result;
}

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

if ( a1 <= 9 )
return a1 + 48;
result = a1 + 87;
if ( a1 >= 0x24 )
result = 0LL;
return result;
}

original_code:
static char num_to_char(unsigned int n)
{
 if(n < 10) return '0' + n;
 if(n < 36) return 'a' + n - 10;
 return 0;
}

variable_types:
n
unsigned int

return_type: char


decompiled_code:
__int64 __fastcall strtoll_custom(char *a1)
{
char *v1; // rcx
char v2; // di
unsigned int v3; // esi
unsigned int v4; // eax
__int64 v5; // rcx
_QWORD *v6; // r10
char v7; // r11
__int64 v8; // r8
char v10; // di
unsigned int v11; // eax
__int64 v12; // rcx
char *i; // rcx

v1 = a1;
v2 = *a1;
if ( v2 == 45 )
{
v2 = *++v1;
}
else if ( v2 == 43 )
{
v2 = *++v1;
}
v3 = 10;
if ( v2 != 48 )
{
v4 = char_to_num(v2);
v8 = 0LL;
if ( v4 >= 0xA )
goto LABEL_6;
goto LABEL_15;
}
v10 = v1[1];
v3 = 8;
if ( v10 == 120 )
{
v10 = v1[2];
v3 = 16;
}
v11 = char_to_num(v10);
v5 = v12 + 1;
v8 = 0LL;
if ( v11 < v3 )
{
LABEL_15:
for ( i = (char *)(v5 + 1); (unsigned int)char_to_num(*i) < v3; i = (char *)(v5 + 1) )
;
}
LABEL_6:
if ( v6 )
*v6 = v5;
if ( v7 )
v8 = -v8;
return v8;
}

original_code:
long long int strtoll_custom(const char *str, char **end)
{
 long long int val = 0;
 int cval, base;
 _Bool neg = 0;
 if(str[0] == '-') {
  neg = 1;
  str++;
 } else if(str[0] == '+') {
  str++;
 }
 if(str[0] == '0') {
  if(str[1] == 'x') {
   base = 16;
   str++;
  } else {
   base = 8;
  }
  str++;
 } else {
  base = 10;
 }
 if(((cval = char_to_num(*str)) >= 0)
    && (cval < base)) {
  val = cval;
  str++;
 }
 while(((cval = char_to_num(*str)) >= 0)
       && (cval < base)) {
  val = val * base + cval;
  str++;
 }
 if(end) {
  *end = (char *) str;
 }
 if(neg) val = -val;
 return val;
}

canonical_original_code:
long long strtoll_custom(char *str, char **end)
{
 long long val = 0;
 int cval; int base;
 _Bool neg = 0;
 if(str[0] == '-') {
  neg = 1;
  str++;
 } else if(str[0] == '+') {
  str++;
 }
 if(str[0] == '0') {
  if(str[1] == 'x') {
   base = 16;
   str++;
  } else {
   base = 8;
  }
  str++;
 } else {
  base = 10;
 }
 if(((cval = char_to_num(*str)) >= 0)
    && (cval < base)) {
  val = cval;
  str++;
 }
 while(((cval = char_to_num(*str)) >= 0)
       && (cval < base)) {
  val = val * base + cval;
  str++;
 }
 if(end) {
  *end = (char *) str;
 }
 if(neg) val = -val;
 return val;
}

variable_types:
str
char *

variable_types:
end
char **

variable_types:
val
long long

variable_types: cval int

variable_types: base int

return_type: long long


decompiled_code:
__int64 __fastcall strcmp_custom(char *a1, char *a2)
{
int v2; // edx
__int64 result; // rax
int v4; // eax

if ( a1 == a2 )
return 0LL;
v2 = *a1;
LODWORD(result) = *a2;
if ( *a1 )
{
while ( 1 )
{
v4 = *a2;
if ( *a2 != (_BYTE)v2 || !(_BYTE)v4 )
return (unsigned int)(v4 - v2);
v2 = *++a1;
if ( !(_BYTE)v2 )
break;
++a2;
}
LODWORD(result) = a2[1];
}
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char *a1, char *a2)
{
int v2; // edx
__int64 result; // rax
int v4; // eax

if ( a1 == a2 )
return 0LL;
v2 = *a1;
LODWORD(result) = *a2;
if ( *a1 )
{
while ( 1 )
{
v4 = *a2;
if ( *a2 != (_BYTE)v2 || !(_BYTE)v4 )
return (unsigned int)(v4 - v2);
v2 = *++a1;
if ( !(_BYTE)v2 )
break;
++a2;
}
LODWORD(result) = a2[1];
}
return (unsigned int)result;
}

original_code:
int strcmp_custom(const char *s1, const char *s2)
{
 if(s1 == s2) {
  return 0;
 }
 while(*s1 && *s2 && *s1 == *s2){
  s1++;
  s2++;
 }
 return *s2 - *s1;
}

canonical_original_code:
int strcmp_custom(char *s1, char *s2)
{
 if(s1 == s2) {
  return 0;
 }
 while(*s1 && *s2 && *s1 == *s2){
  s1++;
  s2++;
 }
 return *s2 - *s1;
}


decompiled_code:
__int64 __fastcall fdstream_readch(__int64 a1, void *a2)
{
int v2; // eax
bool v3; // sf
__int64 result; // rax

v2 = read(*(_DWORD *)(a1 + 32), a2, 1uLL);
v3 = v2 < 0;
if ( !v2 )
return 0xFFFFFFFFLL;
result = 0LL;
if ( v3 )
result = (unsigned int)*_errno_location();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, void *a2)
{
int v2; // eax
bool v3; // sf
__int64 result; // rax

v2 = read(*(_DWORD *)(a1 + 32), a2, 1uLL);
v3 = v2 < 0;
if ( !v2 )
return 0xFFFFFFFFLL;
result = 0LL;
if ( v3 )
result = (unsigned int)*_errno_location();
return result;
}

original_code:
static int fdstream_readch(void *p, char *ch_out)
{
 unsigned char c;
 int status;
 fdstream_t *fs = (fdstream_t *) p;
 status = read(fs->fd, ch_out, 1);
 if(status == 0) {
  return (-1);
 } else if(status < 0) {
  return (*__errno_location ());
 }
 return 0;
}

canonical_original_code:
static int fdstream_readch(void *p, char *ch_out)
{
 unsigned char c;
 int status;
 struct fdstream_t *fs = (fdstream_t *) p;
 status = read(fs->fd, ch_out, 1);
 if(status == 0) {
  return (-1);
 } else if(status < 0) {
  return (*__errno_location ());
 }
 return 0;
}

variable_types:
p
void *

variable_types:
c
unsigned char

variable_types: status int

variable_types: struct fdstream_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; int fd; } *

user_defined_types: struct fdstream_t { struct stream_t hdr; int fd; }


decompiled_code:
__int64 __fastcall fdstream_writech(__int64 a1, char a2)
{
int v2; // edi
int v3; // er8
__int64 result; // rax
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

v2 = *(_DWORD *)(a1 + 32);
buf[0] = a2;
v3 = write(v2, buf, 1uLL);
result = 0LL;
if ( v3 != 1 )
result = (unsigned int)*_errno_location();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char a2)
{
int v2; // edi
int v3; // er8
__int64 result; // rax
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

v2 = *(_DWORD *)(a1 + 32);
buf[0] = a2;
v3 = write(v2, buf, 1uLL);
result = 0LL;
if ( v3 != 1 )
result = (unsigned int)*_errno_location();
return result;
}

original_code:
static int fdstream_writech(void *p, char ch_in)
{
 int status;
 fdstream_t *fs = (fdstream_t *) p;
 status = write(fs->fd, &ch_in, 1);
 if(status != 1) {
  return (*__errno_location ());
 }
 return 0;
}

canonical_original_code:
static int fdstream_writech(void *p, char ch_in)
{
 int status;
 struct fdstream_t *fs = (fdstream_t *) p;
 status = write(fs->fd, &ch_in, 1);
 if(status != 1) {
  return (*__errno_location ());
 }
 return 0;
}


decompiled_code:
__int64 __fastcall fdstream_init(__int64 a1, int a2)
{
if ( a1 )
{
*(_DWORD *)(a1 + 32) = a2;
stream_init(a1, fdstream_readch, fdstream_writech, a1);
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
if ( a1 )
{
*(_DWORD *)(a1 + 32) = a2;
stream_init(a1, fdstream_readch, fdstream_writech, a1);
}
return a1;
}

original_code:
stream_t *fdstream_init(void *p, int fd)
{
 fdstream_t *fs = (fdstream_t *) p;
 if(fs) {
  fs->fd = fd;
  stream_init(&(fs->hdr), fdstream_readch, fdstream_writech, fs);
 }
 return &(fs->hdr);
}

canonical_original_code:
struct stream_t *fdstream_init(void *p, int fd)
{
 struct fdstream_t *fs = (fdstream_t *) p;
 if(fs) {
  fs->fd = fd;
  stream_init(&(fs->hdr), fdstream_readch, fdstream_writech, fs);
 }
 return &(fs->hdr);
}

variable_types: fd int

return_type: 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:
char *__fastcall eval_err_str(int a1)
{
return eval_err_messages[a1];
}

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

original_code:
char *eval_err_str(eval_err_t err)
{
 return eval_err_messages[err];
}

canonical_original_code:
char *eval_err_str(enum eval_err_t err)
{
 return eval_err_messages[err];
}

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 }

return_type: char *


decompiled_code:
__int64 __fastcall map_file(__int64 a1, const char *a2)
{
int v2; // eax
int v3; // er12
__off_t v4; // rsi
int v5; // er8
void *v6; // rax
__int64 result; // rax
struct stat v8; // [rsp+0h] [rbp-A8h] BYREF

*(_DWORD *)a1 = -1;
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)(a1 + 24) = 0;
v2 = open(a2, 0);
*(_DWORD *)a1 = v2;
if ( v2 < 0 )
{
*(_DWORD *)(a1 + 24) = *_errno_location();
result = 1LL;
}
else
{
v3 = fstat(v2, &v8);
if ( v3 < 0 )
{
*(_DWORD *)(a1 + 24) = *_errno_location();
result = 2LL;
}
else
{
v4 = v8.st_size;
v5 = *(_DWORD *)a1;
*(_QWORD *)(a1 + 16) = v8.st_size;
v6 = mmap(0LL, v4, 1, 2, v5, 0LL);
*(_QWORD *)(a1 + 8) = v6;
if ( v6 == (void *)-1LL )
{
v3 = 3;
*(_DWORD *)(a1 + 24) = *_errno_location();
}
result = (unsigned int)v3;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2)
{
int v2; // eax
int v3; // er12
__off_t v4; // rsi
int v5; // er8
void *v6; // rax
__int64 result; // rax
struct stat v8; // [rsp+0h] [rbp-A8h] BYREF

*(_DWORD *)a1 = -1;
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)(a1 + 24) = 0;
v2 = open(a2, 0);
*(_DWORD *)a1 = v2;
if ( v2 < 0 )
{
*(_DWORD *)(a1 + 24) = *_errno_location();
result = 1LL;
}
else
{
v3 = fstat(v2, &v8);
if ( v3 < 0 )
{
*(_DWORD *)(a1 + 24) = *_errno_location();
result = 2LL;
}
else
{
v4 = v8.st_size;
v5 = *(_DWORD *)a1;
*(_QWORD *)(a1 + 16) = v8.st_size;
v6 = mmap(0LL, v4, 1, 2, v5, 0LL);
*(_QWORD *)(a1 + 8) = v6;
if ( v6 == (void *)-1LL )
{
v3 = 3;
*(_DWORD *)(a1 + 24) = *_errno_location();
}
result = (unsigned int)v3;
}
}
return result;
}

original_code:
int map_file(filemap_info_t *info, char *path)
{
 struct stat sb;
 int status = 0;
 info->fd = -1;
 info->buf = ((void *)0);
 info->len = 0;
 info->err = 0;
 info->fd = open(path, 00);
 if(info->fd < 0) {
  status = 1;
  info->err = (*__errno_location ());
  goto finish;
 }
 status = fstat(info->fd, &sb);
 if(status < 0) {
  status = 2;
  info->err = (*__errno_location ());
  goto finish;
 }
 info->len = sb.st_size;
 info->buf = mmap(((void *)0), info->len, 0x1, 0x02, info->fd, 0);
 if(info->buf == ((void *) -1)) {
  status = 3;
  info->err = (*__errno_location ());
  goto finish;
 }
finish:
 return status;
}

canonical_original_code:
int map_file(struct filemap_info_t *info, char *path)
{
 struct stat sb;
 int status = 0;
 info->fd = -1;
 info->buf = ((void *)0);
 info->len = 0;
 info->err = 0;
 info->fd = open(path, 00);
 if(info->fd < 0) {
  status = 1;
  info->err = (*__errno_location ());
  goto finish;
 }
 status = fstat(info->fd, &sb);
 if(status < 0) {
  status = 2;
  info->err = (*__errno_location ());
  goto finish;
 }
 info->len = sb.st_size;
 info->buf = mmap(((void *)0), info->len, 0x1, 0x02, info->fd, 0);
 if(info->buf == ((void *) -1)) {
  status = 3;
  info->err = (*__errno_location ());
  goto finish;
 }
finish:
 return status;
}

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

variable_types:
path
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }


decompiled_code:
int __fastcall unmap_file(__int64 a1)
{
char *v2; // rdi
int result; // eax

v2 = *(char **)(a1 + 8);
result = (_DWORD)v2 - 1;
if ( (unsigned __int64)(v2 - 1) <= 0xFFFFFFFFFFFFFFFDLL )
result = munmap(v2, *(_QWORD *)(a1 + 16));
if ( *(int *)a1 >= 0 )
result = close(*(_DWORD *)a1);
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
char *v2; // rdi
int result; // eax

v2 = *(char **)(a1 + 8);
result = (_DWORD)v2 - 1;
if ( (unsigned __int64)(v2 - 1) <= 0xFFFFFFFFFFFFFFFDLL )
result = munmap(v2, *(_QWORD *)(a1 + 16));
if ( *(int *)a1 >= 0 )
result = close(*(_DWORD *)a1);
return result;
}

original_code:
void unmap_file(filemap_info_t *info)
{
 if(info->buf != ((void *)0) && info->buf != ((void *) -1)) {
  munmap(info->buf, info->len);
 }
 if(info->fd >= 0) {
  close(info->fd);
 }
}

canonical_original_code:
void unmap_file(struct filemap_info_t *info)
{
 if(info->buf != ((void *)0) && info->buf != ((void *) -1)) {
  munmap(info->buf, info->len);
 }
 if(info->fd >= 0) {
  close(info->fd);
 }
}

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


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

canonical_decompiled_code:
__int64 __fastcall func0(__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); }

variable_types:
ms
struct memory_state *


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

canonical_decompiled_code:
__int64 __fastcall func1(__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 func2(__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 func3(__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 func4(__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 func5(__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 func6(__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 func7(__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 func8(__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; } *


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
return printf("usage: %s <file>\n", a1);
}

canonical_decompiled_code:
int __fastcall func9(const char *a1)
{
return printf("usage: %s <file>\n", a1);
}

original_code:
void usage(char *name)
{
 printf("usage: %s <file>\n", name);
}

variable_types:
name
char *


decompiled_code:
__int64 __fastcall load_wrapper(char *s, _QWORD *a2)
{
char *v2; // rax
char *v3; // r13
char *v4; // rbx
size_t v5; // rbx
void *v6; // rsp
void *v7; // r12
size_t v8; // r13
size_t v9; // rsi
signed __int64 v10; // rbx
void *v11; // rsp
void *v12; // rsp
unsigned __int64 *v13; // rax
unsigned __int64 *v14; // r13
unsigned __int64 v15; // r14
_QWORD *v16; // rbx
_QWORD *v17; // r15
unsigned __int64 v18; // r14
__int64 v19; // rax
_QWORD *v20; // rbx
__int64 result; // rax
char *v22; // rax
char *v23; // rax
_QWORD *v24; // [rsp+0h] [rbp-40h] BYREF
_QWORD *v25; // [rsp+8h] [rbp-38h]

v25 = a2;
v2 = strrchr(s, 47);
v3 = v2 + 1;
if ( !v2 )
v3 = s;
v4 = strchr(v3, 46);
if ( !v4 )
v4 = &s[strlen(s)];
v5 = v4 - v3;
v6 = alloca(v5 + 9);
strncpy((char *)&v24, v3, v5);
*((_BYTE *)&v24 + v5) = 0;
v7 = dlopen(s, 1);
if ( v7 )
{
v8 = v5 + 12;
v9 = v5 + 12;
v10 = 16 * ((v5 + 35) >> 4);
v11 = alloca(v10);
snprintf((char *)&v24, v9, "%s_%s", (const char *)&v24, "data_names");
v24 = dlsym(v7, (const char *)&v24);
if ( v24
&& (v12 = alloca(v10),
snprintf((char *)&v24, v8, "%s_%s", (const char *)&v24, "data_count"),
v13 = (unsigned __int64 *)dlsym(v7, (const char *)&v24),
(v14 = v13) != 0LL) )
{
v15 = *v13;
v16 = malloc(16 * (*v13 + 1));
*v25 = v16;
if ( v16 )
{
if ( v15 )
{
v17 = v24;
v18 = 0LL;
while ( 1 )
{
v19 = v18++;
v17 += 2;
v20 = &v16[2 * v19];
*v20 = *(v17 - 1);
v20[1] = dlsym(v7, (const char *)*(v17 - 2));
if ( *v14 <= v18 )
break;
v16 = (_QWORD *)*v25;
}
v16 = (_QWORD *)(*v25 + 16 * v18);
}
*v16 = 0LL;
result = 0LL;
v16[1] = 0LL;
}
else
{
fwrite("malloc() failed\n", 1uLL, 0x10uLL, stderr);
result = 0xFFFFFFFFLL;
}
}
else
{
v22 = dlerror();
fprintf(stderr, "dlsym(%s) failed: %s\n", (const char *)&v24, v22);
result = 0xFFFFFFFFLL;
}
}
else
{
v23 = dlerror();
fprintf(stderr, "error: dlopen() failed: %s\n", v23);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s, _QWORD *a2)
{
char *v2; // rax
char *v3; // r13
char *v4; // rbx
size_t v5; // rbx
void *v6; // rsp
void *v7; // r12
size_t v8; // r13
size_t v9; // rsi
signed __int64 v10; // rbx
void *v11; // rsp
void *v12; // rsp
unsigned __int64 *v13; // rax
unsigned __int64 *v14; // r13
unsigned __int64 v15; // r14
_QWORD *v16; // rbx
_QWORD *v17; // r15
unsigned __int64 v18; // r14
__int64 v19; // rax
_QWORD *v20; // rbx
__int64 result; // rax
char *v22; // rax
char *v23; // rax
_QWORD *v24; // [rsp+0h] [rbp-40h] BYREF
_QWORD *v25; // [rsp+8h] [rbp-38h]

v25 = a2;
v2 = strrchr(s, 47);
v3 = v2 + 1;
if ( !v2 )
v3 = s;
v4 = strchr(v3, 46);
if ( !v4 )
v4 = &s[strlen(s)];
v5 = v4 - v3;
v6 = alloca(v5 + 9);
strncpy((char *)&v24, v3, v5);
*((_BYTE *)&v24 + v5) = 0;
v7 = dlopen(s, 1);
if ( v7 )
{
v8 = v5 + 12;
v9 = v5 + 12;
v10 = 16 * ((v5 + 35) >> 4);
v11 = alloca(v10);
snprintf((char *)&v24, v9, "%s_%s", (const char *)&v24, "data_names");
v24 = dlsym(v7, (const char *)&v24);
if ( v24
&& (v12 = alloca(v10),
snprintf((char *)&v24, v8, "%s_%s", (const char *)&v24, "data_count"),
v13 = (unsigned __int64 *)dlsym(v7, (const char *)&v24),
(v14 = v13) != 0LL) )
{
v15 = *v13;
v16 = malloc(16 * (*v13 + 1));
*v25 = v16;
if ( v16 )
{
if ( v15 )
{
v17 = v24;
v18 = 0LL;
while ( 1 )
{
v19 = v18++;
v17 += 2;
v20 = &v16[2 * v19];
*v20 = *(v17 - 1);
v20[1] = dlsym(v7, (const char *)*(v17 - 2));
if ( *v14 <= v18 )
break;
v16 = (_QWORD *)*v25;
}
v16 = (_QWORD *)(*v25 + 16 * v18);
}
*v16 = 0LL;
result = 0LL;
v16[1] = 0LL;
}
else
{
fwrite("malloc() failed\n", 1uLL, 0x10uLL, stderr);
result = 0xFFFFFFFFLL;
}
}
else
{
v22 = dlerror();
fprintf(stderr, "dlsym(%s) failed: %s\n", (const char *)&v24, v22);
result = 0xFFFFFFFFLL;
}
}
else
{
v23 = dlerror();
fprintf(stderr, "error: dlopen() failed: %s\n", v23);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int load_wrapper(char *path, ldwrap_ent_t **funs)
{
 void *dl_hdl;
 struct { char *name, *nmemonic; } *fun_names;
 size_t *fun_count;
 size_t i;
 char *names_ident;
 size_t names_ident_len;
 char *count_ident;
 size_t count_ident_len;
 char *name;
 size_t name_len;
 char *start, *end;
 start = strrchr(path, '/');
 if(! start) {
  start = path;
 } else {
  start++;
 }
 end = strchr(start, '.');
 if(!end) {
  end = path + strlen(path);
 }
 name_len = end - start;
 name = __builtin_alloca (name_len + 1);
 strncpy(name, start, end-start);
 name[name_len] = 0;
 dl_hdl = dlopen(path, 0x00001);
 if(! dl_hdl) {
  fprintf(stderr, "error: dlopen() failed: %s\n", dlerror());
  return -1;
 }
 names_ident_len = name_len + strlen(load_wrapper_names_ident) + 2;
 names_ident = __builtin_alloca (names_ident_len);
 snprintf(names_ident, names_ident_len,
          "%s_%s", name, load_wrapper_names_ident);
 fun_names = dlsym(dl_hdl, names_ident);
 if(! fun_names) {
  fprintf(stderr, "dlsym(%s) failed: %s\n",
          names_ident, dlerror());
  return -1;
 }
 count_ident_len = name_len + strlen(load_wrapper_count_ident) + 2;
 count_ident = __builtin_alloca (count_ident_len);
 snprintf(count_ident, count_ident_len,
          "%s_%s", name, load_wrapper_count_ident);
 fun_count = dlsym(dl_hdl, count_ident);
 if(! fun_count) {
  fprintf(stderr, "dlsym(%s) failed: %s\n",
          count_ident, dlerror());
  return -1;
 }
 *funs = malloc((*fun_count + 1) * sizeof((*funs)[0]));
 if(! *funs) {
  fprintf(stderr, "malloc() failed\n");
  return -1;
 }
 for(i = 0; i < *fun_count; i++) {
  (*funs)[i].name = fun_names[i].nmemonic;
  (*funs)[i].fun = dlsym(dl_hdl, fun_names[i].name);
 }
 (*funs)[i].name = ((void *)0);
 (*funs)[i].fun = ((void *)0);
 return 0;
}

canonical_original_code:
int load_wrapper(char *path, struct ldwrap_ent_t **funs)
{
 void *dl_hdl;
 struct { char *name; } *fun_names;
 unsigned long *fun_count;
 unsigned long i;
 char *names_ident;
 unsigned long names_ident_len;
 char *count_ident;
 unsigned long count_ident_len;
 char *name;
 unsigned long name_len;
 char *start; char *end;
 start = strrchr(path, '/');
 if(! start) {
  start = path;
 } else {
  start++;
 }
 end = strchr(start, '.');
 if(!end) {
  end = path + strlen(path);
 }
 name_len = end - start;
 name = __builtin_alloca (name_len + 1);
 strncpy(name, start, end-start);
 name[name_len] = 0;
 dl_hdl = dlopen(path, 0x00001);
 if(! dl_hdl) {
  fprintf(stderr, "error: dlopen() failed: %s\n", dlerror());
  return -1;
 }
 names_ident_len = name_len + strlen(load_wrapper_names_ident) + 2;
 names_ident = __builtin_alloca (names_ident_len);
 snprintf(names_ident, names_ident_len,
          "%s_%s", name, load_wrapper_names_ident);
 fun_names = dlsym(dl_hdl, names_ident);
 if(! fun_names) {
  fprintf(stderr, "dlsym(%s) failed: %s\n",
          names_ident, dlerror());
  return -1;
 }
 count_ident_len = name_len + strlen(load_wrapper_count_ident) + 2;
 count_ident = __builtin_alloca (count_ident_len);
 snprintf(count_ident, count_ident_len,
          "%s_%s", name, load_wrapper_count_ident);
 fun_count = dlsym(dl_hdl, count_ident);
 if(! fun_count) {
  fprintf(stderr, "dlsym(%s) failed: %s\n",
          count_ident, dlerror());
  return -1;
 }
 *funs = malloc((*fun_count + 1) * sizeof((*funs)[0]));
 if(! *funs) {
  fprintf(stderr, "malloc() failed\n");
  return -1;
 }
 for(i = 0; i < *fun_count; i++) {
  (*funs)[i].name = fun_names[i].nmemonic;
  (*funs)[i].fun = dlsym(dl_hdl, fun_names[i].name);
 }
 (*funs)[i].name = ((void *)0);
 (*funs)[i].fun = ((void *)0);
 return 0;
}

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

variable_types:
i
unsigned long

variable_types:
start
char *

variable_types:
end
char *


decompiled_code:
__int64 __fastcall pong_msg_handler(double a1)
{
double v1; // xmm1_8
double v2; // xmm2_8

lo_timetag_now();
++pong_receive_counter;
lo_timetag_diff();
diff = *(_QWORD *)&a1;
v1 = *(double *)&rt_sum + a1;
*(double *)&rt_sum = *(double *)&rt_sum + a1;
if ( ping_send_counter < 0 )
v2 = (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1))
+ (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1));
else
v2 = (double)(int)ping_send_counter;
*(double *)&avg = v1 / v2;
if ( a1 > *(double *)&rt_time_max )
rt_time_max = *(_QWORD *)&a1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(double a1)
{
double v1; // xmm1_8
double v2; // xmm2_8

lo_timetag_now();
++pong_receive_counter;
lo_timetag_diff();
diff = *(_QWORD *)&a1;
v1 = *(double *)&rt_sum + a1;
*(double *)&rt_sum = *(double *)&rt_sum + a1;
if ( ping_send_counter < 0 )
v2 = (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1))
+ (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1));
else
v2 = (double)(int)ping_send_counter;
*(double *)&avg = v1 / v2;
if ( a1 > *(double *)&rt_time_max )
rt_time_max = *(_QWORD *)&a1;
return 0LL;
}

original_code:
int pong_msg_handler(const char *path, const char *types, lo_arg **argv, int argc,
 void *data, void *user_data)
{
 lo_timetag now;
 lo_timetag_now(&now);
 pong_receive_counter++;
 diff=lo_timetag_diff(now,argv[0]->t);
 rt_sum+=diff;
 avg=(double)rt_sum/(double)ping_send_counter;
 if(diff>rt_time_max)
 {
  rt_time_max=diff;
 }
 return 0;
}

canonical_original_code:
int pong_msg_handler(char *path, char *types, union lo_arg **argv, int argc, void *data, void *user_data)
{
 struct lo_timetag now;
 lo_timetag_now(&now);
 pong_receive_counter++;
 diff=lo_timetag_diff(now,argv[0]->t);
 rt_sum+=diff;
 avg=(double)rt_sum/(double)ping_send_counter;
 if(diff>rt_time_max)
 {
  rt_time_max=diff;
 }
 return 0;
}

variable_types:
types
char *

variable_types: union lo_arg { int i; int i32; long h; long i64; float f; float f32; double d; double f64; char s; char S; unsigned char c; unsigned char m[4]; struct lo_timetag { unsigned int sec; unsigned int frac; } t; struct { int size; char data; } blob; } **

variable_types: argc int

variable_types:
data
void *

user_defined_types: union lo_arg { int i; int i32; long h; long i64; float f; float f32; double d; double f64; char s; char S; unsigned char c; unsigned char m[4]; struct lo_timetag t; struct { int size; char data; } blob; }


decompiled_code:
void __noreturn print_help()
{
fwrite("Usage: oscpp [Options] target_host\n", 1uLL, 0x23uLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite(" Display this text: --help\n", 1uLL, 0x30uLL, stderr);
fprintf(stderr, " Local port: (%s) --lport <integer>\n", localPort);
fprintf(stderr, " Remote port: (%s) --rport <integer>\n", sendToPort);
fwrite(" Delay between messages [usec]: (1000) --interval <integer>\n", 1uLL, 0x3FuLL, stderr);
fwrite(" Don't send pings (pong only): (off) --noping\n", 1uLL, 0x32uLL, stderr);
fwrite(" Payload size [bytes]: (0) --size <integer>\n", 1uLL, 0x3BuLL, stderr);
fwrite(" Limit number of sent messages: (inf) --count <integer>\n", 1uLL, 0x3CuLL, stderr);
fwrite("target_host: <string>\n", 1uLL, 0x18uLL, stderr);
fwrite("target_port: <integer>\n\n", 1uLL, 0x1AuLL, stderr);
fwrite("Example: oscpp --interval 100 10.10.10.3 1234\n", 1uLL, 0x2EuLL, stderr);
fwrite("oscpp needs to run on the pinged host to get a reply.\n", 1uLL, 0x36uLL, stderr);
fwrite("See http://github.com/7890/jack_tools/\n\n", 1uLL, 0x28uLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func9()
{
fwrite("Usage: oscpp [Options] target_host\n", 1uLL, 0x23uLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite(" Display this text: --help\n", 1uLL, 0x30uLL, stderr);
fprintf(stderr, " Local port: (%s) --lport <integer>\n", localPort);
fprintf(stderr, " Remote port: (%s) --rport <integer>\n", sendToPort);
fwrite(" Delay between messages [usec]: (1000) --interval <integer>\n", 1uLL, 0x3FuLL, stderr);
fwrite(" Don't send pings (pong only): (off) --noping\n", 1uLL, 0x32uLL, stderr);
fwrite(" Payload size [bytes]: (0) --size <integer>\n", 1uLL, 0x3BuLL, stderr);
fwrite(" Limit number of sent messages: (inf) --count <integer>\n", 1uLL, 0x3CuLL, stderr);
fwrite("target_host: <string>\n", 1uLL, 0x18uLL, stderr);
fwrite("target_port: <integer>\n\n", 1uLL, 0x1AuLL, stderr);
fwrite("Example: oscpp --interval 100 10.10.10.3 1234\n", 1uLL, 0x2EuLL, stderr);
fwrite("oscpp needs to run on the pinged host to get a reply.\n", 1uLL, 0x36uLL, stderr);
fwrite("See http://github.com/7890/jack_tools/\n\n", 1uLL, 0x28uLL, stderr);
exit(1);
}

original_code:
static void print_help (void)
{
 fprintf (stderr, "Usage: oscpp [Options] target_host\n");
 fprintf (stderr, "Options:\n");
 fprintf (stderr, "  Display this text:                     --help\n");
 fprintf (stderr, "  Local port:                    (%s) --lport  <integer>\n",localPort);
 fprintf (stderr, "  Remote port:                   (%s) --rport  <integer>\n",sendToPort);
 fprintf (stderr, "  Delay between messages [usec]:  (1000) --interval  <integer>\n");
 fprintf (stderr, "  Don't send pings (pong only):    (off) --noping\n");
 fprintf (stderr, "  Payload size [bytes]:              (0) --size  <integer>\n");
 fprintf (stderr, "  Limit number of sent messages:   (inf) --count  <integer>\n");
 fprintf (stderr, "target_host:   <string>\n");
 fprintf (stderr, "target_port:   <integer>\n\n");
 fprintf (stderr, "Example: oscpp --interval 100 10.10.10.3 1234\n");
 fprintf (stderr, "oscpp needs to run on the pinged host to get a reply.\n");
 fprintf (stderr, "See http://github.com/7890/jack_tools/\n\n");
 exit (1);
}

canonical_original_code:
static void print_help()
{
 fprintf (stderr, "Usage: oscpp [Options] target_host\n");
 fprintf (stderr, "Options:\n");
 fprintf (stderr, "  Display this text:                     --help\n");
 fprintf (stderr, "  Local port:                    (%s) --lport  <integer>\n",localPort);
 fprintf (stderr, "  Remote port:                   (%s) --rport  <integer>\n",sendToPort);
 fprintf (stderr, "  Delay between messages [usec]:  (1000) --interval  <integer>\n");
 fprintf (stderr, "  Don't send pings (pong only):    (off) --noping\n");
 fprintf (stderr, "  Payload size [bytes]:              (0) --size  <integer>\n");
 fprintf (stderr, "  Limit number of sent messages:   (inf) --count  <integer>\n");
 fprintf (stderr, "target_host:   <string>\n");
 fprintf (stderr, "target_port:   <integer>\n\n");
 fprintf (stderr, "Example: oscpp --interval 100 10.10.10.3 1234\n");
 fprintf (stderr, "oscpp needs to run on the pinged host to get a reply.\n");
 fprintf (stderr, "See http://github.com/7890/jack_tools/\n\n");
 exit (1);
}


decompiled_code:
size_t __fastcall print_header(const char *a1)
{
fprintf(stderr, "\n%s v%.2f\n", a1, 0.1);
return fwrite("(C) 2014 Thomas Brand <tom@trellis.ch>\n", 1uLL, 0x28uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func11(const char *a1)
{
fprintf(stderr, "\n%s v%.2f\n", a1, 0.1);
return fwrite("(C) 2014 Thomas Brand <tom@trellis.ch>\n", 1uLL, 0x28uLL, stderr);
}

original_code:
void print_header (char *prgname)
{
 fprintf (stderr, "\n%s v%.2f\n", prgname,version);
 fprintf (stderr, "(C) 2014 Thomas Brand  <tom@trellis.ch>\n");
}

canonical_original_code:
void print_header(char *prgname)
{
 fprintf (stderr, "\n%s v%.2f\n", prgname,version);
 fprintf (stderr, "(C) 2014 Thomas Brand  <tom@trellis.ch>\n");
}

variable_types:
prgname
char *


decompiled_code:
unsigned __int64 send_ping()
{
unsigned __int64 result; // rax

lo_message_new();
lo_timetag_now();
lo_message_add_timetag();
lo_send_message();
lo_message_free();
result = ping_send_counter + 1;
ping_send_counter = result;
if ( result > ping_send_max )
{
if ( ping_send_max )
shutdown_in_progress = 1;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 func12()
{
unsigned __int64 result; // rax

lo_message_new();
lo_timetag_now();
lo_message_add_timetag();
lo_send_message();
lo_message_free();
result = ping_send_counter + 1;
ping_send_counter = result;
if ( result > ping_send_max )
{
if ( ping_send_max )
shutdown_in_progress = 1;
}
return result;
}

original_code:
void send_ping()
{
 lo_message msg=lo_message_new();
 lo_timetag now;
 lo_timetag_now(&now);
 lo_message_add_timetag(msg,now);
 lo_send_message (loa, "/pi", msg);
 lo_message_free (msg);
 ping_send_counter++;
 if(ping_send_max>0 && ping_send_counter>ping_send_max)
 {
  shutdown_in_progress=1;
 }
}

canonical_original_code:
void send_ping()
{
 void *msg = lo_message_new();
 struct lo_timetag now;
 lo_timetag_now(&now);
 lo_message_add_timetag(msg,now);
 lo_send_message (loa, "/pi", msg);
 lo_message_free (msg);
 ping_send_counter++;
 if(ping_send_max>0 && ping_send_counter>ping_send_max)
 {
  shutdown_in_progress=1;
 }
}

variable_types:
msg
void *

variable_types: struct lo_timetag { unsigned int sec; unsigned int frac; }


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

lo_message_new();
lo_message_add_timetag();
lo_send_message();
result = lo_message_free();
++pong_send_counter;
return result;
}

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

lo_message_new();
lo_message_add_timetag();
lo_send_message();
result = lo_message_free();
++pong_send_counter;
return result;
}

original_code:
void send_pong(lo_timetag tt)
{
 lo_message msg=lo_message_new();
 lo_message_add_timetag(msg,tt);
 lo_send_message (loa, "/po", msg);
 lo_message_free (msg);
 pong_send_counter++;
}

canonical_original_code:
void send_pong(struct lo_timetag tt)
{
 void *msg = lo_message_new();
 lo_message_add_timetag(msg,tt);
 lo_send_message (loa, "/po", msg);
 lo_message_free (msg);
 pong_send_counter++;
}

user_defined_types: struct lo_timetag { unsigned int sec; unsigned int frac; }


decompiled_code:
__int64 __fastcall ping_msg_handler(__int64 a1, __int64 a2, _QWORD **a3)
{
send_pong(**a3);
++ping_receive_counter;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, _QWORD **a3)
{
func13(**a3);
++ping_receive_counter;
return 0LL;
}

original_code:
int ping_msg_handler(const char *path, const char *types, lo_arg **argv, int argc,
 void *data, void *user_data)
{
 send_pong(argv[0]->t);
 ping_receive_counter++;
 return 0;
}

canonical_original_code:
int ping_msg_handler(char *path, char *types, union lo_arg **argv, int argc, void *data, void *user_data)
{
 send_pong(argv[0]->t);
 ping_receive_counter++;
 return 0;
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
int v6; // eax
int longind[7]; // [rsp+Ch] [rbp-1Ch] BYREF

signal(3, signal_handler);
signal(15, signal_handler);
signal(1, signal_handler);
signal(2, signal_handler);
print_header("oscpp - OSC Ping Pong");
if ( argc - _bss_start > 0 )
{
while ( 1 )
{
longind[0] = 0;
v6 = getopt_long(argc, (char *const *)argv, "", &long_options_0, longind);
if ( v6 == -1 )
break;
if ( v6 )
{
switch ( v6 )
{
case 'c':
ping_send_max = atoi(optarg);
continue;
case 'h':
goto LABEL_6;
case 'i':
interval_usec = atoi(optarg);
continue;
case 'l':
localPort = optarg;
continue;
case 'r':
sendToPort = optarg;
continue;
case 's':
puts("not implemented");
continue;
default:
continue;
}
}
if ( !*((_QWORD *)&long_options_0.flag + 4 * longind[0]) )
LABEL_6:
print_help();
}
if ( argc - _bss_start != 1 )
{
fwrite("Wrong arguments, see --help.\n\n", 1uLL, 0x1EuLL, stderr);
exit(1);
}
sendToHost = (char *)argv[_bss_start];
st = lo_server_thread_new();
lo_server_thread_add_method();
lo_server_thread_add_method();
lo_server_thread_start();
lo_timetag_now();
loa = lo_address_new();
fwrite("\nlegend\n\n", 1uLL, 9uLL, stderr);
fwrite("pis: # ping sent por: # pong received\n", 1uLL, 0x2CuLL, stderr);
fwrite("pir: # ping received pos: # pong sent\n", 1uLL, 0x28uLL, stderr);
fwrite("cur: current roundtrip time (of last ping/pong)\n", 1uLL, 0x30uLL, stderr);
fwrite("max: max (peak) rt time avg: average rt time\n", 1uLL, 0x2FuLL, stderr);
fwrite("roundtrip times are indicted in milliseconds\n\n", 1uLL, 0x2EuLL, stderr);
while ( 1 )
{
if ( !__PAIR64__(shutdown_in_progress, noping) )
send_ping(v3, v4, v5, 1000.0);
v3 = *(double *)&diff * 1000.0;
v5 = *(double *)&avg * 1000.0;
v4 = *(double *)&rt_time_max * 1000.0;
fprintf(
stderr,
"\x1B[2K\rpis %lu por %lu pir %lu pos %lu cur %.3f max %.3f avg %.3f [ms]",
ping_send_counter,
pong_receive_counter,
ping_receive_counter,
pong_send_counter,
*(double *)&diff * 1000.0,
*(double *)&rt_time_max * 1000.0,
*(double *)&avg * 1000.0);
usleep(interval_usec);
}
}
fwrite("Missing arguments, see --help.\n\n", 1uLL, 0x20uLL, stderr);
exit(1);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
int v6; // eax
int longind[7]; // [rsp+Ch] [rbp-1Ch] BYREF

signal(3, signal_handler);
signal(15, signal_handler);
signal(1, signal_handler);
signal(2, signal_handler);
func11("oscpp - OSC Ping Pong");
if ( argc - _bss_start > 0 )
{
while ( 1 )
{
longind[0] = 0;
v6 = getopt_long(argc, (char *const *)argv, "", &long_options_0, longind);
if ( v6 == -1 )
break;
if ( v6 )
{
switch ( v6 )
{
case 'c':
ping_send_max = atoi(optarg);
continue;
case 'h':
goto LABEL_6;
case 'i':
interval_usec = atoi(optarg);
continue;
case 'l':
localPort = optarg;
continue;
case 'r':
sendToPort = optarg;
continue;
case 's':
puts("not implemented");
continue;
default:
continue;
}
}
if ( !*((_QWORD *)&long_options_0.flag + 4 * longind[0]) )
LABEL_6:
func9();
}
if ( argc - _bss_start != 1 )
{
fwrite("Wrong arguments, see --help.\n\n", 1uLL, 0x1EuLL, stderr);
exit(1);
}
sendToHost = (char *)argv[_bss_start];
st = lo_server_thread_new();
lo_server_thread_add_method();
lo_server_thread_add_method();
lo_server_thread_start();
lo_timetag_now();
loa = lo_address_new();
fwrite("\nlegend\n\n", 1uLL, 9uLL, stderr);
fwrite("pis: # ping sent por: # pong received\n", 1uLL, 0x2CuLL, stderr);
fwrite("pir: # ping received pos: # pong sent\n", 1uLL, 0x28uLL, stderr);
fwrite("cur: current roundtrip time (of last ping/pong)\n", 1uLL, 0x30uLL, stderr);
fwrite("max: max (peak) rt time avg: average rt time\n", 1uLL, 0x2FuLL, stderr);
fwrite("roundtrip times are indicted in milliseconds\n\n", 1uLL, 0x2EuLL, stderr);
while ( 1 )
{
if ( !__PAIR64__(shutdown_in_progress, noping) )
func12(v3, v4, v5, 1000.0);
v3 = *(double *)&diff * 1000.0;
v5 = *(double *)&avg * 1000.0;
v4 = *(double *)&rt_time_max * 1000.0;
fprintf(
stderr,
"\x1B[2K\rpis %lu por %lu pir %lu pos %lu cur %.3f max %.3f avg %.3f [ms]",
ping_send_counter,
pong_receive_counter,
ping_receive_counter,
pong_send_counter,
*(double *)&diff * 1000.0,
*(double *)&rt_time_max * 1000.0,
*(double *)&avg * 1000.0);
usleep(interval_usec);
}
}
fwrite("Missing arguments, see --help.\n\n", 1uLL, 0x20uLL, stderr);
exit(1);
}

original_code:
int main (int argc, char *argv[])
{
 signal(3, signal_handler);
 signal(15, signal_handler);
 signal(1, signal_handler);
 signal(2, signal_handler);
 static struct option long_options[] =
 {
  {"help", 0, 0, 'h'},
  {"lport", 1, 0, 'l'},
  {"rport", 1, 0, 'r'},
  {"interval", 1, 0, 'i'},
  {"size", 1, 0, 's'},
  {"count", 1, 0, 'c'},
  {"noping", 0, &noping, 1},
  {0, 0, 0, 0}
 };
 print_header("oscpp - OSC Ping Pong");
 if (argc - optind < 1)
 {
  fprintf (stderr, "Missing arguments, see --help.\n\n");
  exit(1);
 }
 int opt;
 while (1)
 {
  int option_index = 0;
  opt = getopt_long (argc, argv, "", long_options, &option_index);
  if (opt == -1)
  {
   break;
  }
  switch (opt)
  {
   case 0:
   if (long_options[option_index].flag != 0)
   {
    break;
   }
   case 'h':
    print_help();
    break;
   case 'l':
    localPort=optarg;
    break;
   case 'r':
    sendToPort=optarg;
    break;
   case 'i':
    interval_usec=atoi(optarg);
    break;
   case 's':
    printf("not implemented\n");
    break;
   case 'c':
    ping_send_max=atoi(optarg);
    break;
   default:
    break;
   }
 }
 if(argc-optind != 1)
 {
  fprintf (stderr, "Wrong arguments, see --help.\n\n");
  exit(1);
 }
 sendToHost=argv[optind];
 st = lo_server_thread_new(localPort, error);
 lo_server_thread_add_method(st, "/pi", "t", ping_msg_handler, ((void *)0));
 lo_server_thread_add_method(st, "/po", "t", pong_msg_handler, ((void *)0));
 lo_server_thread_start(st);
 lo_timetag_now(&start_of_measurement);
 loa = lo_address_new(sendToHost, sendToPort);
 fprintf(stderr, "\nlegend\n\n");
 fprintf(stderr, "pis: # ping sent       por: # pong received\n");
 fprintf(stderr, "pir: # ping received   pos: # pong sent\n");
 fprintf(stderr, "cur: current roundtrip time (of last ping/pong)\n");
 fprintf(stderr, "max: max (peak) rt time   avg: average rt time\n");
 fprintf(stderr, "roundtrip times are indicted in milliseconds\n\n");
 while ( 1==1 )
 {
  if(noping==0 && shutdown_in_progress==0)
  {
   send_ping();
  }
  fprintf(stderr,"\33[2K\rpis %lu por %lu pir %lu pos %lu cur %.3f max %.3f avg %.3f [ms]"
   ,ping_send_counter
   ,pong_receive_counter
   ,ping_receive_counter
   ,pong_send_counter
   ,diff*1000
   ,rt_time_max*1000
   ,avg*1000);
  usleep(interval_usec);
 }
}

canonical_original_code:
int main(int argc, char *argv[])
{
 signal(3, signal_handler);
 signal(15, signal_handler);
 signal(1, signal_handler);
 signal(2, signal_handler);
 static struct option long_options[] = {
  {"help", 0, 0, 'h'},
  {"lport", 1, 0, 'l'},
  {"rport", 1, 0, 'r'},
  {"interval", 1, 0, 'i'},
  {"size", 1, 0, 's'},
  {"count", 1, 0, 'c'},
  {"noping", 0, &noping, 1},
  {0, 0, 0, 0}
 };
 print_header("oscpp - OSC Ping Pong");
 if (argc - optind < 1)
 {
  fprintf (stderr, "Missing arguments, see --help.\n\n");
  exit(1);
 }
 int opt;
 while (1)
 {
  int option_index = 0;
  opt = getopt_long (argc, argv, "", long_options, &option_index);
  if (opt == -1)
  {
   break;
  }
  switch (opt)
  {
   case 0:
   if (long_options[option_index].flag != 0)
   {
    break;
   }
   case 'h':
    print_help();
    break;
   case 'l':
    localPort=optarg;
    break;
   case 'r':
    sendToPort=optarg;
    break;
   case 'i':
    interval_usec=atoi(optarg);
    break;
   case 's':
    printf("not implemented\n");
    break;
   case 'c':
    ping_send_max=atoi(optarg);
    break;
   default:
    break;
   }
 }
 if(argc-optind != 1)
 {
  fprintf (stderr, "Wrong arguments, see --help.\n\n");
  exit(1);
 }
 sendToHost=argv[optind];
 st = lo_server_thread_new(localPort, error);
 lo_server_thread_add_method(st, "/pi", "t", ping_msg_handler, ((void *)0));
 lo_server_thread_add_method(st, "/po", "t", pong_msg_handler, ((void *)0));
 lo_server_thread_start(st);
 lo_timetag_now(&start_of_measurement);
 loa = lo_address_new(sendToHost, sendToPort);
 fprintf(stderr, "\nlegend\n\n");
 fprintf(stderr, "pis: # ping sent       por: # pong received\n");
 fprintf(stderr, "pir: # ping received   pos: # pong sent\n");
 fprintf(stderr, "cur: current roundtrip time (of last ping/pong)\n");
 fprintf(stderr, "max: max (peak) rt time   avg: average rt time\n");
 fprintf(stderr, "roundtrip times are indicted in milliseconds\n\n");
 while ( 1==1 )
 {
  if(noping==0 && shutdown_in_progress==0)
  {
   send_ping();
  }
  fprintf(stderr,"\33[2K\rpis %lu por %lu pir %lu pos %lu cur %.3f max %.3f avg %.3f [ms]"
   ,ping_send_counter
   ,pong_receive_counter
   ,ping_receive_counter
   ,pong_send_counter
   ,diff*1000
   ,rt_time_max*1000
   ,avg*1000);
  usleep(interval_usec);
 }
}

variable_types:
argv
char *[]

variable_types: struct option { char *name; int has_arg; int *flag; int val; } []

variable_types: opt int


error

decompiled_code:
int __fastcall error(unsigned int a1, const char *a2, const char *a3)
{
return fprintf(stderr, "liblo server error %d in path %s: %s\n", a1, a3, a2);
}

canonical_decompiled_code:
int __fastcall func8(unsigned int a1, const char *a2, const char *a3)
{
return fprintf(stderr, "liblo server error %d in path %s: %s\n", a1, a3, a2);
}

original_code:
void error(int num, const char *msg, const char *path)
{
 fprintf(stderr,"liblo server error %d in path %s: %s\n", num, path, msg);
}

canonical_original_code:
void error(int num, char *msg, char *path)
{
 fprintf(stderr,"liblo server error %d in path %s: %s\n", num, path, msg);
}

variable_types: num int

variable_types:
msg
char *

variable_types:
path
char *


decompiled_code:
void __fastcall __noreturn signal_handler(double a1)
{
double v1; // xmm0_8
double v2; // xmm0_8

shutdown_in_progress = 1;
lo_timetag_now();
lo_timetag_diff();
usleep(0x186A0u);
fprintf(stderr, "\n\ntotal running time: %f seconds\n", a1);
fprintf(stderr, "total sent ping messages: %lu\n", ping_send_counter);
fprintf(stderr, "total received pong messages: %lu\n", pong_receive_counter);
if ( ping_send_counter < 0 )
v1 = (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1))
+ (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1));
else
v1 = (double)(int)ping_send_counter;
fprintf(stderr, "pings sent per second: %.3f\n\n", v1 / a1);
fprintf(stderr, "total received ping messages: %lu\n", ping_receive_counter);
fprintf(stderr, "total sent pong messages: %lu\n", pong_send_counter);
if ( pong_send_counter < 0 )
v2 = (double)(int)(pong_send_counter & 1 | ((unsigned __int64)pong_send_counter >> 1))
+ (double)(int)(pong_send_counter & 1 | ((unsigned __int64)pong_send_counter >> 1));
else
v2 = (double)(int)pong_send_counter;
fprintf(stderr, "pongs sent per second: %.3f\n\n", v2 / a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(double a1)
{
double v1; // xmm0_8
double v2; // xmm0_8

shutdown_in_progress = 1;
lo_timetag_now();
lo_timetag_diff();
usleep(0x186A0u);
fprintf(stderr, "\n\ntotal running time: %f seconds\n", a1);
fprintf(stderr, "total sent ping messages: %lu\n", ping_send_counter);
fprintf(stderr, "total received pong messages: %lu\n", pong_receive_counter);
if ( ping_send_counter < 0 )
v1 = (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1))
+ (double)(int)(ping_send_counter & 1 | ((unsigned __int64)ping_send_counter >> 1));
else
v1 = (double)(int)ping_send_counter;
fprintf(stderr, "pings sent per second: %.3f\n\n", v1 / a1);
fprintf(stderr, "total received ping messages: %lu\n", ping_receive_counter);
fprintf(stderr, "total sent pong messages: %lu\n", pong_send_counter);
if ( pong_send_counter < 0 )
v2 = (double)(int)(pong_send_counter & 1 | ((unsigned __int64)pong_send_counter >> 1))
+ (double)(int)(pong_send_counter & 1 | ((unsigned __int64)pong_send_counter >> 1));
else
v2 = (double)(int)pong_send_counter;
fprintf(stderr, "pongs sent per second: %.3f\n\n", v2 / a1);
exit(0);
}

original_code:
static void signal_handler(int sig)
{
 shutdown_in_progress=1;
 lo_timetag_now(&end_of_measurement);
 double start_end_diff=lo_timetag_diff(
  end_of_measurement,
  start_of_measurement
 );
 usleep(100000);
 fprintf(stderr,"\n\ntotal running time: %f seconds\n",start_end_diff);
 fprintf(stderr,"total sent ping messages:     %lu\n",ping_send_counter);
 fprintf(stderr,"total received pong messages: %lu\n",pong_receive_counter);
 fprintf(stderr,"pings sent per second: %.3f\n\n",ping_send_counter/start_end_diff);
 fprintf(stderr,"total received ping messages: %lu\n",ping_receive_counter);
 fprintf(stderr,"total sent pong messages:     %lu\n",pong_send_counter);
 fprintf(stderr,"pongs sent per second: %.3f\n\n",pong_send_counter/start_end_diff);
 exit(0);
}

canonical_original_code:
static void signal_handler(int sig)
{
 shutdown_in_progress=1;
 lo_timetag_now(&end_of_measurement);
 double start_end_diff = lo_timetag_diff(
  end_of_measurement,
  start_of_measurement
 );
 usleep(100000);
 fprintf(stderr,"\n\ntotal running time: %f seconds\n",start_end_diff);
 fprintf(stderr,"total sent ping messages:     %lu\n",ping_send_counter);
 fprintf(stderr,"total received pong messages: %lu\n",pong_receive_counter);
 fprintf(stderr,"pings sent per second: %.3f\n\n",ping_send_counter/start_end_diff);
 fprintf(stderr,"total received ping messages: %lu\n",ping_receive_counter);
 fprintf(stderr,"total sent pong messages:     %lu\n",pong_send_counter);
 fprintf(stderr,"pongs sent per second: %.3f\n\n",pong_send_counter/start_end_diff);
 exit(0);
}

variable_types: sig int


decompiled_code:
__int64 zita_resampler_major_version(void)
{
return 1LL;
}

canonical_decompiled_code:
__int64 func0(void)
{
return 1LL;
}

original_code:
int zita_resampler_major_version (void)
{
    return ZITA_RESAMPLER_MAJOR_VERSION;
}

canonical_original_code:
int zita_resampler_major_version()
{
    return ZITA_RESAMPLER_MAJOR_VERSION;
}


decompiled_code:
__int64 zita_resampler_minor_version(void)
{
return 3LL;
}

canonical_decompiled_code:
__int64 func1(void)
{
return 3LL;
}

original_code:
int zita_resampler_minor_version (void)
{
    return ZITA_RESAMPLER_MINOR_VERSION;
}

canonical_original_code:
int zita_resampler_minor_version()
{
    return ZITA_RESAMPLER_MINOR_VERSION;
}


decompiled_code:
__int64 print_lo_info()
{
unsigned int v1; // [rsp+14h] [rbp-21Ch]
unsigned int v2; // [rsp+18h] [rbp-218h]
unsigned int v3; // [rsp+1Ch] [rbp-214h]
unsigned int v4; // [rsp+20h] [rbp-210h]
unsigned int v5; // [rsp+24h] [rbp-20Ch]
char v6[256]; // [rsp+28h] [rbp-208h] BYREF
char v7[264]; // [rsp+128h] [rbp-108h] BYREF

lo_version();
printf("liblo version string `%s'\n", v7);
printf("liblo version: %d.%d%s\n", v1, v2, v6);
printf("liblo libtool version: %d.%d.%d\n", v3, v4, v5);
printf("liblo MAX_MSG_SIZE: %d\n", 0x8000LL);
printf("liblo MAX_UDP_MSG_SIZE: %d\n", 0xFFFFLL);
printf("liblo LO_DEFAULT_MAX_MSG_SIZE: %d\n", 0xFFFFLL);
putchar(10);
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v1; // [rsp+14h] [rbp-21Ch]
unsigned int v2; // [rsp+18h] [rbp-218h]
unsigned int v3; // [rsp+1Ch] [rbp-214h]
unsigned int v4; // [rsp+20h] [rbp-210h]
unsigned int v5; // [rsp+24h] [rbp-20Ch]
char v6[256]; // [rsp+28h] [rbp-208h] BYREF
char v7[264]; // [rsp+128h] [rbp-108h] BYREF

lo_version();
printf("liblo version string `%s'\n", v7);
printf("liblo version: %d.%d%s\n", v1, v2, v6);
printf("liblo libtool version: %d.%d.%d\n", v3, v4, v5);
printf("liblo MAX_MSG_SIZE: %d\n", 0x8000LL);
printf("liblo MAX_UDP_MSG_SIZE: %d\n", 0xFFFFLL);
printf("liblo LO_DEFAULT_MAX_MSG_SIZE: %d\n", 0xFFFFLL);
putchar(10);
return 0LL;
}

original_code:
int print_lo_info()
{
 int major, minor, lt_maj, lt_min, lt_bug;
 char extra[256];
 char string[256];
 lo_version(string, 256,
      &major, &minor, extra, 256,
      &lt_maj, &lt_min, &lt_bug);
 printf("liblo version string `%s'\n", string);
 printf("liblo version: %d.%d%s\n", major, minor, extra);
 printf("liblo libtool version: %d.%d.%d\n", lt_maj, lt_min, lt_bug);
 printf("liblo MAX_MSG_SIZE: %d\n", 32768);
 printf("liblo MAX_UDP_MSG_SIZE: %d\n", 65535);
 printf("liblo LO_DEFAULT_MAX_MSG_SIZE: %d\n", 65535);
 printf("\n");
 return 0;
 printf("\n");
 return 1;
}

canonical_original_code:
int print_lo_info()
{
 int major; int minor; int lt_maj; int lt_min; int lt_bug;
 char extra[256];
 char string[256];
 lo_version(string, 256,
      &major, &minor, extra, 256,
      &lt_maj, &lt_min, &lt_bug);
 printf("liblo version string `%s'\n", string);
 printf("liblo version: %d.%d%s\n", major, minor, extra);
 printf("liblo libtool version: %d.%d.%d\n", lt_maj, lt_min, lt_bug);
 printf("liblo MAX_MSG_SIZE: %d\n", 32768);
 printf("liblo MAX_UDP_MSG_SIZE: %d\n", 65535);
 printf("liblo LO_DEFAULT_MAX_MSG_SIZE: %d\n", 65535);
 printf("\n");
 return 0;
 printf("\n");
 return 1;
}

variable_types: major int

variable_types: minor int

variable_types:
extra
char [256]

variable_types:
string
char [256]


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
return print_lo_info(argc, argv, envp);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
return func7(argc, argv, envp);
}

original_code:
int main(int argc, char *argv[])
{
 return print_lo_info();
}


decompiled_code:
void jack_error()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
static void jack_error(const char* err)
{
}

canonical_original_code:
static void jack_error(char *err)
{
}

variable_types:
err
char *


decompiled_code:
size_t shutdown_callback()
{
connection_to_jack_down = 1;
return fwrite("JACK server down!\n", 1uLL, 0x12uLL, stderr);
}

canonical_decompiled_code:
size_t func8()
{
connection_to_jack_down = 1;
return fwrite("JACK server down!\n", 1uLL, 0x12uLL, stderr);
}

original_code:
static void shutdown_callback(void *arg)
{
 connection_to_jack_down=1;
 fprintf(stderr, "JACK server down!\n");
}

variable_types:
arg
void *


decompiled_code:
void __noreturn signal_handler()
{
fwrite("signal received, exiting ...\n", 1uLL, 0x1DuLL, stderr);
if ( !connection_to_jack_down )
jack_client_close();
exit(0);
}

canonical_decompiled_code:
void __noreturn func9()
{
fwrite("signal received, exiting ...\n", 1uLL, 0x1DuLL, stderr);
if ( !connection_to_jack_down )
jack_client_close();
exit(0);
}

original_code:
static void signal_handler(int sig)
{
 fprintf(stderr, "signal received, exiting ...\n");
 if(!connection_to_jack_down)
 {
  jack_client_close(client);
 }
 exit(0);
}


process

decompiled_code:
__int64 __fastcall process(int a1)
{
void *v2; // r12
unsigned __int64 v3; // rcx
__int64 i; // rbx
int v5; // eax

if ( !process_enabled )
return 0LL;
buffer_out_midi = jack_port_get_buffer();
jack_midi_clear_buffer();
v2 = (void *)jack_port_get_buffer();
memset(v2, 0, (unsigned int)(4 * a1));
if ( a1 )
{
v3 = frame_counter;
for ( i = 0LL; i != a1; ++i )
{
if ( !(v3 % frames_between_on_off) )
{
fputc(46, stderr);
send_midi_note(channel_counter, pitch_counter, velocity_counter, is_on);
if ( is_on )
{
*((_DWORD *)v2 + i) = 1061997773;
is_on = 0;
}
else
{
*((_DWORD *)v2 + i) = 0;
is_on = 1;
}
if ( ++velocity_counter <= 127 || (velocity_counter = 0, ++pitch_counter, pitch_counter <= 127) )
{
v3 = frame_counter;
}
else
{
pitch_counter = 0;
v3 = frame_counter;
v5 = channel_counter + 1;
if ( channel_counter + 1 >= 16 )
v5 = 0;
channel_counter = v5;
}
}
frame_counter = ++v3;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1)
{
void *v2; // r12
unsigned __int64 v3; // rcx
__int64 i; // rbx
int v5; // eax

if ( !process_enabled )
return 0LL;
buffer_out_midi = jack_port_get_buffer();
jack_midi_clear_buffer();
v2 = (void *)jack_port_get_buffer();
memset(v2, 0, (unsigned int)(4 * a1));
if ( a1 )
{
v3 = frame_counter;
for ( i = 0LL; i != a1; ++i )
{
if ( !(v3 % frames_between_on_off) )
{
fputc(46, stderr);
send_midi_note(channel_counter, pitch_counter, velocity_counter, is_on);
if ( is_on )
{
*((_DWORD *)v2 + i) = 1061997773;
is_on = 0;
}
else
{
*((_DWORD *)v2 + i) = 0;
is_on = 1;
}
if ( ++velocity_counter <= 127 || (velocity_counter = 0, ++pitch_counter, pitch_counter <= 127) )
{
v3 = frame_counter;
}
else
{
pitch_counter = 0;
v3 = frame_counter;
v5 = channel_counter + 1;
if ( channel_counter + 1 >= 16 )
v5 = 0;
channel_counter = v5;
}
}
frame_counter = ++v3;
}
}
return 0LL;
}

original_code:
static int process(jack_nframes_t nframes, void *arg)
{
 if(!process_enabled)
 {
  return 0;
 }
 buffer_out_midi=jack_port_get_buffer(port_out_midi, nframes);
 jack_midi_clear_buffer(buffer_out_midi);
 sample_t *o1;
 o1=(sample_t*)jack_port_get_buffer(ioPortArray[0],nframes);
 memset(o1, 0, nframes*4);
 int k=0;
 for(k=0; k<nframes; k++)
 {
  if(frame_counter % frames_between_on_off==0)
  {
   fprintf(stderr, ".");
   send_midi_note (channel_counter, pitch_counter, velocity_counter, is_on, k);
   if(is_on)
   {
    o1[k]=0.8;
    is_on=0;
   }
   else
   {
    o1[k]=0;
    is_on=1;
   }
   velocity_counter++;
   if(velocity_counter>127)
   {
    velocity_counter=0;
    pitch_counter++;
    if(pitch_counter>127)
    {
     pitch_counter=0;
     channel_counter++;
     if(channel_counter>15)
     {
      channel_counter=0;
     }
    }
   }
  }
  frame_counter++;
 }
 return 0;
}

canonical_original_code:
static int process(unsigned int nframes, void *arg)
{
 if(!process_enabled)
 {
  return 0;
 }
 buffer_out_midi=jack_port_get_buffer(port_out_midi, nframes);
 jack_midi_clear_buffer(buffer_out_midi);
 float *o1;
 o1=(float *)jack_port_get_buffer(ioPortArray[0],nframes);
 memset(o1, 0, nframes*4);
 int k = 0;
 for(k=0; k<nframes; k++)
 {
  if(frame_counter % frames_between_on_off==0)
  {
   fprintf(stderr, ".");
   send_midi_note (channel_counter, pitch_counter, velocity_counter, is_on, k);
   if(is_on)
   {
    o1[k]=0.8;
    is_on=0;
   }
   else
   {
    o1[k]=0;
    is_on=1;
   }
   velocity_counter++;
   if(velocity_counter>127)
   {
    velocity_counter=0;
    pitch_counter++;
    if(pitch_counter>127)
    {
     pitch_counter=0;
     channel_counter++;
     if(channel_counter>15)
     {
      channel_counter=0;
     }
    }
   }
  }
  frame_counter++;
 }
 return 0;
}

variable_types:
nframes
unsigned int

variable_types: k int


decompiled_code:
size_t print_help(void)
{
return fwrite(
"\n"
"commands:\n"
"'CTRL+c' to enter step mode\n"
"in step mode:\n"
"enter a number to process n cycles\n"
"'ENTER' to step one cycle\n"
"'c+ENTER' to continue (leave step mode)\n"
"'CTRL+c+ENTER' to quit\n"
"'h' to show this help\n"
"\n",
1uLL,
0xC8uLL,
stderr);
}

canonical_decompiled_code:
size_t func2(void)
{
return fwrite(
"\n"
"commands:\n"
"'CTRL+c' to enter step mode\n"
"in step mode:\n"
"enter a number to process n cycles\n"
"'ENTER' to step one cycle\n"
"'c+ENTER' to continue (leave step mode)\n"
"'CTRL+c+ENTER' to quit\n"
"'h' to show this help\n"
"\n",
1uLL,
0xC8uLL,
stderr);
}


freewheel

decompiled_code:
int __fastcall freewheel(int a1, void *a2)
{
int result; // eax

is_freewheeling = a1;
if ( a1 )
fputc(10, stderr);
result = fprintf(stderr, "JACK went to freewheel mode %d\n", (unsigned int)is_freewheeling);
process_enabled = 1;
return result;
}

canonical_decompiled_code:
int __fastcall func4(int a1, void *a2)
{
int result; // eax

is_freewheeling = a1;
if ( a1 )
fputc(10, stderr);
result = fprintf(stderr, "JACK went to freewheel mode %d\n", (unsigned int)is_freewheeling);
process_enabled = 1;
return result;
}

original_code:
static void freewheel(int isfw, void *arg)
{
 lo_message reply=lo_message_new();
 if(isfw)
 {
  lo_message_add_int32(reply,1);
 }
 else
 {
  lo_message_add_int32(reply,0);
 }
 lo_send_message(loa, "/oscev/jack/freewheeling", reply);
 lo_message_free(reply);
 fprintf(stderr,"JACK freewhelling %d\n",isfw);
}

canonical_original_code:
static void freewheel(int isfw, void *arg)
{
 void *reply = lo_message_new();
 if(isfw)
 {
  lo_message_add_int32(reply,1);
 }
 else
 {
  lo_message_add_int32(reply,0);
 }
 lo_send_message(loa, "/oscev/jack/freewheeling", reply);
 lo_message_free(reply);
 fprintf(stderr,"JACK freewhelling %d\n",isfw);
}

variable_types: isfw int

variable_types:
reply
void *


process

decompiled_code:
__int64 __fastcall process(unsigned int a1, void *a2)
{
char v3[32]; // [rsp+10h] [rbp-40h] BYREF
char *nptr; // [rsp+30h] [rbp-20h]
unsigned int v5; // [rsp+38h] [rbp-18h]
int v6; // [rsp+3Ch] [rbp-14h]

if ( !process_enabled || shutdown_in_progress )
return 0LL;
++cycle_count;
v5 = WJACK_last_frame_time(client) - frame_time;
frame_time = (unsigned int)WJACK_last_frame_time(client);
if ( is_freewheeling )
{
fprintf(stderr, "# %ld, %ld (+%d) ", cycle_count, frame_time, v5);
if ( (unsigned __int64)run_n_cycles > 1 )
{
fputc(10, stderr);
--run_n_cycles;
return 0LL;
}
v6 = 0;
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(v3);
while ( !v6 )
{
std::getline<char,std::char_traits<char>,std::allocator<char>>(&std::cin, v3);
nptr = (char *)malloc(0x101uLL);
nptr = (char *)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str(v3);
run_n_cycles = atoll(nptr);
if ( run_n_cycles )
{
fprintf(stderr, "running for %ld cycles\n", run_n_cycles);
v6 = 1;
}
else if ( (unsigned int)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::compare(
v3,
&_continue[abi:cxx11]) )
{
if ( (unsigned int)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::compare(
v3,
&_help[abi:cxx11]) )
{
if ( (unsigned int)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::compare(
v3,
&_step[abi:cxx11]) )
fwrite("unknown command, enter 'h' for help.\n", 1uLL, 0x25uLL, stderr);
else
v6 = 1;
}
else
{
print_help();
}
}
else
{
return_to_normal_operation = 1;
process_enabled = 0;
v6 = 1;
}
}
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::~basic_string(v3);
}
else
{
fprintf(stderr, "\r# %d \x1B[0J", cycle_count);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, void *a2)
{
char v3[32]; // [rsp+10h] [rbp-40h] BYREF
char *nptr; // [rsp+30h] [rbp-20h]
unsigned int v5; // [rsp+38h] [rbp-18h]
int v6; // [rsp+3Ch] [rbp-14h]

if ( !process_enabled || shutdown_in_progress )
return 0LL;
++cycle_count;
v5 = WJACK_last_frame_time(client) - frame_time;
frame_time = (unsigned int)WJACK_last_frame_time(client);
if ( is_freewheeling )
{
fprintf(stderr, "# %ld, %ld (+%d) ", cycle_count, frame_time, v5);
if ( (unsigned __int64)run_n_cycles > 1 )
{
fputc(10, stderr);
--run_n_cycles;
return 0LL;
}
v6 = 0;
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(v3);
while ( !v6 )
{
std::getline<char,std::char_traits<char>,std::allocator<char>>(&std::cin, v3);
nptr = (char *)malloc(0x101uLL);
nptr = (char *)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str(v3);
run_n_cycles = atoll(nptr);
if ( run_n_cycles )
{
fprintf(stderr, "running for %ld cycles\n", run_n_cycles);
v6 = 1;
}
else if ( (unsigned int)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::compare(
v3,
&_continue[abi:cxx11]) )
{
if ( (unsigned int)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::compare(
v3,
&_help[abi:cxx11]) )
{
if ( (unsigned int)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::compare(
v3,
&_step[abi:cxx11]) )
fwrite("unknown command, enter 'h' for help.\n", 1uLL, 0x25uLL, stderr);
else
v6 = 1;
}
else
{
func2();
}
}
else
{
return_to_normal_operation = 1;
process_enabled = 0;
v6 = 1;
}
}
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::~basic_string(v3);
}
else
{
fprintf(stderr, "\r# %d \x1B[0J", cycle_count);
}
return 0LL;
}

original_code:
static int process(jack_nframes_t nframes, void *arg)
{
 if(transport_state!=-2)
 {
  transport_state_prev=transport_state;
 }
 transport_state=jack_transport_query(client, ((void *)0));
 if(transport_state!=transport_state_prev)
 {
  lo_message reply=lo_message_new();
  lo_message_add_int32(reply,(int)transport_state);
  lo_send_message(loa, "/oscev/transport", reply);
  lo_message_free(reply);
 }
 return 0;
}

canonical_original_code:
static int process(unsigned int nframes, void *arg)
{
 if(transport_state!=-2)
 {
  transport_state_prev=transport_state;
 }
 transport_state=jack_transport_query(client, ((void *)0));
 if(transport_state!=transport_state_prev)
 {
  void *reply = lo_message_new();
  lo_message_add_int32(reply,(int)transport_state);
  lo_send_message(loa, "/oscev/transport", reply);
  lo_message_free(reply);
 }
 return 0;
}


decompiled_code:
size_t __fastcall print_header(const char *a1)
{
fprintf(stderr, "\n%s v%.2f (format v%.2f)\n", a1, *(float *)&version, *(float *)&format_version);
return fwrite("(C) 2013 - 2014 Thomas Brand <tom@trellis.ch>\n", 1uLL, 0x2FuLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func0(const char *a1)
{
fprintf(stderr, "\n%s v%.2f (format v%.2f)\n", a1, *(float *)&version, *(float *)&format_version);
return fwrite("(C) 2013 - 2014 Thomas Brand <tom@trellis.ch>\n", 1uLL, 0x2FuLL, stderr);
}

original_code:
void print_header (char *prgname)
{
 fprintf (stderr, "\n%s v%.2f\n", prgname,version);
 fprintf (stderr, "(C) 2014 Thomas Brand  <tom@trellis.ch>\n");
}

variable_types:
prgname
char *