decompiled_code:
char *__fastcall setup_and_read(int a1, __int64 a2)
{
program = *(_QWORD *)a2;
if ( a1 > 3 )
usage();
if ( a1 > 1 && !freopen(*(const char **)(a2 + 8), "r", stdin) )
{
fprintf(stderr, "%s: can't read %s\n", (const char *)program, *(const char **)(a2 + 8));
exit(1);
}
if ( a1 == 3 && !freopen(*(const char **)(a2 + 16), "w", stdout) )
{
fprintf(stderr, "%s: can't write to %s\n", (const char *)program, *(const char **)(a2 + 16));
exit(1);
}
return load_file();
}

canonical_decompiled_code:
char *__fastcall func4(int a1, __int64 a2)
{
program = *(_QWORD *)a2;
if ( a1 > 3 )
func3();
if ( a1 > 1 && !freopen(*(const char **)(a2 + 8), "r", stdin) )
{
fprintf(stderr, "%s: can't read %s\n", (const char *)program, *(const char **)(a2 + 8));
exit(1);
}
if ( a1 == 3 && !freopen(*(const char **)(a2 + 16), "w", stdout) )
{
fprintf(stderr, "%s: can't write to %s\n", (const char *)program, *(const char **)(a2 + 16));
exit(1);
}
return func1();
}

original_code:
void setup_and_read(int argc, char *argv[])
{
     program = argv[0];
     if (argc > 3)
   usage();
     if (argc >= 2 && freopen(argv[1], "r", stdin) == ((void *)0)) {
   fprintf(stderr, "%s: can't read %s\n", program, argv[1]);
   exit(1);
     }
     if (argc >= 3 && freopen(argv[2], "w", stdout) == ((void *)0)) {
   fprintf(stderr, "%s: can't write to %s\n", program, argv[2]);
   exit(1);
     }
     load_file();
}

variable_types: argc int

variable_types:
argv
char *[]


usage

repo: thedotcomchase/Hot-Fuzz

decompiled_code:
void __noreturn usage()
{
fprintf(stderr, "usage: %s [infile] [outfile]\n", (const char *)program);
exit(2);
}

canonical_decompiled_code:
void __noreturn func3()
{
fprintf(stderr, "usage: %s [infile] [outfile]\n", (const char *)program);
exit(2);
}

original_code:
void usage(void)
{
     fprintf(stderr, "usage: %s [infile] [outfile]\n", program);
     exit(2);
}

canonical_original_code:
void usage()
{
     fprintf(stderr, "usage: %s [infile] [outfile]\n", program);
     exit(2);
}

return_type: void


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

if ( level > 63 )
panic("begin_frame -- Nesting too deep");
result = 4LL * ++level;
stack[result / 2] = 0LL;
dword_1C8[result] = 0;
return result * 4;
}

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

if ( level > 63 )
panic("begin_frame -- Nesting too deep");
result = 4LL * ++level;
stack[result / 2] = 0LL;
dword_1C8[result] = 0;
return result * 4;
}

original_code:
void begin_frame(void)
{
     if (level >= 64)
   panic("begin_frame -- Nesting too deep");
     level++;
     stack[level].b_chain = ((void *)0);
     stack[level].b_mark = 0;
}

canonical_original_code:
void begin_frame()
{
     if (level >= 64)
   panic("begin_frame -- Nesting too deep");
     level++;
     stack[level].b_chain = ((void *)0);
     stack[level].b_mark = 0;
}


decompiled_code:
__int64 end_frame()
{
__int64 result; // rax
__int64 i; // rbx
_QWORD *v2; // rdx
int v3; // ecx

result = 16LL * level;
for ( i = *(__int64 *)((char *)stack + result); i; i = *(_QWORD *)(i + 8) )
{
result = 0LL;
v3 = 0;
if ( *(int *)i > 0 )
{
do
{
v2 = (_QWORD *)(*(_QWORD *)(i + 24) + 8 * result);
if ( !*v2 )
{
*v2 = err_type;
v3 = 1;
}
++result;
}
while ( *(_DWORD *)i > (int)result );
if ( v3 )
{
result = 16LL * level;
if ( !*(int *)((char *)dword_1C8 + result) )
{
tc_error(*(unsigned int *)(*(_QWORD *)(i + 16) + 8LL), "Implicit parameters not completely determined");
tc_e_etc("Expression: %z", *(_QWORD *)(i + 16));
result = tc_e_end();
}
}
}
}
--level;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
__int64 i; // rbx
_QWORD *v2; // rdx
int v3; // ecx

result = 16LL * level;
for ( i = *(__int64 *)((char *)stack + result); i; i = *(_QWORD *)(i + 8) )
{
result = 0LL;
v3 = 0;
if ( *(int *)i > 0 )
{
do
{
v2 = (_QWORD *)(*(_QWORD *)(i + 24) + 8 * result);
if ( !*v2 )
{
*v2 = err_type;
v3 = 1;
}
++result;
}
while ( *(_DWORD *)i > (int)result );
if ( v3 )
{
result = 16LL * level;
if ( !*(int *)((char *)dword_1C8 + result) )
{
tc_error(*(unsigned int *)(*(_QWORD *)(i + 16) + 8LL), "Implicit parameters not completely determined");
tc_e_etc("Expression: %z", *(_QWORD *)(i + 16));
result = tc_e_end();
}
}
}
}
--level;
return result;
}

original_code:
void end_frame(void)
{
     frame p;
     int j;
     for (p = stack[level].b_chain; p != ((void *)0); p = p->f_next) {
   int failed = 0;
   for (j = 0; j < p->f_nvars; j++) {
        if (p->f_var[j] == ((void *)0)) {
      failed = 1;
      p->f_var[j] = err_type;
        }
   }
   if (failed && ! stack[level].b_mark) {
        tc_error(p->f_cxt->x_loc,
   "Implicit parameters not completely determined");
        tc_e_etc("Expression: %z", p->f_cxt);
        tc_e_end();
   }
     }
     level--;
}

canonical_original_code:
void end_frame()
{
     struct frame *p;
     int j;
     for (p = stack[level].b_chain; p != ((void *)0); p = p->f_next) {
   int failed = 0;
   for (j = 0; j < p->f_nvars; j++) {
        if (p->f_var[j] == ((void *)0)) {
      failed = 1;
      p->f_var[j] = err_type;
        }
   }
   if (failed && ! stack[level].b_mark) {
        tc_error(p->f_cxt->x_loc,
   "Implicit parameters not completely determined");
        tc_e_etc("Expression: %z", p->f_cxt);
        tc_e_end();
   }
     }
     level--;
}

variable_types: struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } **f_var; } *

variable_types: j int

variable_types: failed int

user_defined_types: struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; }

user_defined_types: struct type { enum kind_t t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; }

user_defined_types: struct def { enum kind_d d_kind; struct sym *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema *schema_d; } d_u; }

user_defined_types: struct sym { int x_kind; struct tok *s_basename; struct tok *s_decor; struct def *s_glodef; struct para *s_def; struct sym *s_link; }

user_defined_types: struct schema { int z_ncomps; struct compnt *z_comp; }

user_defined_types: struct para { struct blob *p_text; int p_serial; char *p_file; enum mark p_flag; struct para *p_next; }


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

result = 4LL * level;
dword_1C8[result] = 1;
return result * 4;
}

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

result = 4LL * level;
dword_1C8[result] = 1;
return result * 4;
}

original_code:
void mark_error(void)
{
     stack[level].b_mark = 1;
}

canonical_original_code:
void mark_error()
{
     stack[level].b_mark = 1;
}


original_code:
frame mk_frame(int nvars)
{
     if (nvars == 0)
   return ((frame) ((void *)0));
     else {
   frame f = (frame) alloc(sizeof(struct frame));
   int i;
   f->f_nvars = nvars;
   f->f_next = ((void *)0);
   f->f_cxt = ((tree) ((void *)0));
   f->f_var = (type *) alloc(nvars * sizeof(type));
   for (i = 0; i < nvars; i++)
        f->f_var[i] = ((void *)0);
   return f;
     }
}

canonical_original_code:
struct frame *mk_frame(int nvars)
{
     if (nvars == 0)
   return ((frame) ((void *)0));
     else {
   struct frame *f = (frame) alloc(sizeof(struct frame));
   int i;
   f->f_nvars = nvars;
   f->f_next = ((void *)0);
   f->f_cxt = ((tree) ((void *)0));
   f->f_var = (struct type **) alloc(nvars * sizeof(type));
   for (i = 0; i < nvars; i++)
        f->f_var[i] = ((void *)0);
   return f;
     }
}

variable_types: nvars int

variable_types: i int

return_type: struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } **f_var; } *


decompiled_code:
__int64 __fastcall new_frame(int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = mk_frame(a1);
if ( result )
{
*(_QWORD *)(result + 16) = a2;
v3 = 2LL * level;
*(_QWORD *)(result + 8) = stack[v3];
stack[v3] = result;
}
return result;
}

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

result = func3(a1);
if ( result )
{
*(_QWORD *)(result + 16) = a2;
v3 = 2LL * level;
*(_QWORD *)(result + 8) = stack[v3];
stack[v3] = result;
}
return result;
}

original_code:
frame new_frame(int nvars, tree cxt)
{
     frame f = mk_frame(nvars);
     if (f != ((frame) ((void *)0))) {
   f->f_cxt = cxt;
   f->f_next = stack[level].b_chain;
   stack[level].b_chain = f;
     }
     return f;
}

canonical_original_code:
struct frame *new_frame(int nvars, struct blob *cxt)
{
     struct frame *f = mk_frame(nvars);
     if (f != ((frame) ((void *)0))) {
   f->f_cxt = cxt;
   f->f_next = stack[level].b_chain;
   stack[level].b_chain = f;
     }
     return f;
}

variable_types:
cxt
struct blob *

user_defined_types: struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; }

user_defined_types: enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 }

user_defined_types: enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 }

user_defined_types: struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; }

user_defined_types: enum mark { UNTOUCHED=0, BUSY=1, DONE=2 }

user_defined_types: struct compnt { struct sym *z_name; struct type *z_type; }


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

for ( i = a1; i; i = *(_QWORD *)(result + 8) )
{
index_add(**(_QWORD ***)(i + 16), a2);
result = *(_QWORD *)(i + 16);
}
return result;
}

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

for ( i = a1; i; i = *(_QWORD *)(result + 8) )
{
func0(**(_QWORD ***)(i + 16), a2);
result = *(_QWORD *)(i + 16);
}
return result;
}

original_code:
static void index_list(tree t, para p)
{
     tree u;
     for (u = t; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
   index_add((sym) (u)->x_slot[0], p);
}

canonical_original_code:
static void index_list(struct blob *t, struct para *p)
{
     struct blob *u;
     for (u = t; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
   index_add((sym) (u)->x_slot[0], p);
}

variable_types: struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *

variable_types: struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *


decompiled_code:
__int64 __fastcall store_para(int a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
__int64 v4; // rdx

v2 = perm_alloc(40LL);
*(_QWORD *)v2 = a2;
*(_DWORD *)(v2 + 8) = a1;
*(_QWORD *)(v2 + 16) = file_name;
*(_DWORD *)(v2 + 24) = 0;
*(_QWORD *)(v2 + 32) = 0LL;
make_index((unsigned int **)v2);
result = spec_file;
if ( spec_file )
{
do
{
v4 = result;
result = *(_QWORD *)(result + 32);
}
while ( result );
*(_QWORD *)(v4 + 32) = v2;
}
else
{
spec_file = v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
__int64 v4; // rdx

v2 = perm_alloc(40LL);
*(_QWORD *)v2 = a2;
*(_DWORD *)(v2 + 8) = a1;
*(_QWORD *)(v2 + 16) = file_name;
*(_DWORD *)(v2 + 24) = 0;
*(_QWORD *)(v2 + 32) = 0LL;
func2((unsigned int **)v2);
result = spec_file;
if ( spec_file )
{
do
{
v4 = result;
result = *(_QWORD *)(result + 32);
}
while ( result );
*(_QWORD *)(v4 + 32) = v2;
}
else
{
spec_file = v2;
}
return result;
}

original_code:
static void store_para(int n, tree t)
{
     para p = (para) perm_alloc(sizeof(struct para)), q;
     p->p_text = t;
     p->p_serial = n;
     p->p_file = file_name;
     p->p_flag = UNTOUCHED;
     p->p_next = ((void *)0);
     make_index(p);
     if (spec_file == ((void *)0))
   spec_file = p;
     else {
   q = spec_file;
   while (q->p_next != ((void *)0)) q = q->p_next;
   q->p_next = p;
     }
}

canonical_original_code:
static void store_para(int n, struct blob *t)
{
     struct para *p = (para) perm_alloc(sizeof(struct para)); struct para *q;
     p->p_text = t;
     p->p_serial = n;
     p->p_file = file_name;
     p->p_flag = UNTOUCHED;
     p->p_next = ((void *)0);
     make_index(p);
     if (spec_file == ((void *)0))
   spec_file = p;
     else {
   q = spec_file;
   while (q->p_next != ((void *)0)) q = q->p_next;
   q->p_next = p;
     }
}

variable_types: n int

variable_types: struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *


decompiled_code:
void __fastcall check_para(_QWORD *a1, _QWORD *a2)
{
int v3; // esi
__int64 v4; // rbp
int v5; // eax
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // r12
__int64 v9; // r12
__int64 v10; // rbp
__int64 v11; // rcx

if ( a1 )
{
v3 = *((_DWORD *)a1 + 6);
if ( v3 == 1 )
{
v9 = node(2LL, 0LL, 363LL, a2, 0LL);
v10 = 2LL * level_1;
do
{
v11 = *(_QWORD *)(v10 * 8 + 1432);
if ( v11 )
v9 = node(2LL, 0LL, 363LL, v11, v9);
v10 -= 2LL;
}
while ( (_QWORD *)active_0[v10] != a1 );
tc_error(*(unsigned int *)(*a1 + 8LL), "Cyclic dependency involving %n", a2);
tc_e_etc("Cycle: %l//, //", v9);
tc_e_end();
}
else if ( v3 != 2 )
{
if ( v3 )
{
bad_tag("check_para");
}
else
{
v4 = file_name;
if ( level_1 > 63 )
panic("check_para -- Nesting too deep");
v5 = level_1;
v6 = 2LL * level_1;
active_0[v6] = (__int64)a1;
qword_5A8[v6] = (__int64)a2;
level_1 = v5 + 1;
v7 = mark_temp();
v8 = v7;
if ( debugging && dcode[0] )
grind(stdout, "Mark: %x\n", v7);
*((_DWORD *)a1 + 6) = 1;
file_name = a1[2];
if ( debugging )
{
if ( dcode[3] )
grind(stdout, "Processing para %d [level %d]\n", *((unsigned int *)a1 + 2), (unsigned int)level_1);
}
tc_para(*a1);
--level_1;
clear_temp(v8);
*((_DWORD *)a1 + 6) = 2;
*a1 = 0LL;
file_name = v4;
}
}
}
}

canonical_decompiled_code:
void __fastcall func4(_QWORD *a1, _QWORD *a2)
{
int v3; // esi
__int64 v4; // rbp
int v5; // eax
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // r12
__int64 v9; // r12
__int64 v10; // rbp
__int64 v11; // rcx

if ( a1 )
{
v3 = *((_DWORD *)a1 + 6);
if ( v3 == 1 )
{
v9 = node(2LL, 0LL, 363LL, a2, 0LL);
v10 = 2LL * level_1;
do
{
v11 = *(_QWORD *)(v10 * 8 + 1432);
if ( v11 )
v9 = node(2LL, 0LL, 363LL, v11, v9);
v10 -= 2LL;
}
while ( (_QWORD *)active_0[v10] != a1 );
tc_error(*(unsigned int *)(*a1 + 8LL), "Cyclic dependency involving %n", a2);
tc_e_etc("Cycle: %l//, //", v9);
tc_e_end();
}
else if ( v3 != 2 )
{
if ( v3 )
{
bad_tag("check_para");
}
else
{
v4 = file_name;
if ( level_1 > 63 )
panic("check_para -- Nesting too deep");
v5 = level_1;
v6 = 2LL * level_1;
active_0[v6] = (__int64)a1;
qword_5A8[v6] = (__int64)a2;
level_1 = v5 + 1;
v7 = mark_temp();
v8 = v7;
if ( debugging && dcode[0] )
grind(stdout, "Mark: %x\n", v7);
*((_DWORD *)a1 + 6) = 1;
file_name = a1[2];
if ( debugging )
{
if ( dcode[3] )
grind(stdout, "Processing para %d [level %d]\n", *((unsigned int *)a1 + 2), (unsigned int)level_1);
}
tc_para(*a1);
--level_1;
clear_temp(v8);
*((_DWORD *)a1 + 6) = 2;
*a1 = 0LL;
file_name = v4;
}
}
}
}

original_code:
static void check_para(para p, sym cxt)
{
     int i;
     tree c;
     univ mark;
     char *save_file = file_name;
     static int level = 0;
     static context active[64];
     if (p == ((void *)0)) return;
     switch (p->p_flag) {
     case UNTOUCHED:
   if (level >= 64)
        panic("check_para -- Nesting too deep");
   active[level].w_para = p;
   active[level].w_cxt = cxt;
   level++;
   mark = mark_temp();
   if ((debugging && dcode['a' - 'a'])) grind(stdout, "Mark: %x\n", mark);
   p->p_flag = BUSY;
   file_name = p->p_file;
   if ((debugging && dcode['d' - 'a']))
        grind(stdout, "Processing para %d [level %d]\n",
       (int) p->p_serial, level);
   tc_para(p->p_text);
   level--;
   clear_temp(mark);
   p->p_flag = DONE;
   p->p_text = ((void *)0);
   file_name = save_file;
   break;
     case BUSY:
   c = node(2,0,363,(tree) cxt,((tree) ((void *)0))); i = level;
   do {
        i--;
        if (active[i].w_cxt != ((void *)0))
      c = node(2,0,363,(tree) active[i].w_cxt,c);
   } while (active[i].w_para != p);
   tc_error(p->p_text->x_loc,
     "Cyclic dependency involving %n", cxt);
   tc_e_etc("Cycle: %l//, //", c);
   tc_e_end();
   break;
     case DONE:
   break;
     default:
   bad_tag("check_para", (int) p->p_flag);
     }
}

canonical_original_code:
static void check_para(struct para *p, struct sym *cxt)
{
     int i;
     struct blob *c;
     void *mark;
     char *save_file = file_name;
     static int level = 0;
     static struct context active[64];
     if (p == ((void *)0)) return;
     switch (p->p_flag) {
     case UNTOUCHED:
   if (level >= 64)
        panic("check_para -- Nesting too deep");
   active[level].w_para = p;
   active[level].w_cxt = cxt;
   level++;
   mark = mark_temp();
   if ((debugging && dcode['a' - 'a'])) grind(stdout, "Mark: %x\n", mark);
   p->p_flag = BUSY;
   file_name = p->p_file;
   if ((debugging && dcode['d' - 'a']))
        grind(stdout, "Processing para %d [level %d]\n",
       (int) p->p_serial, level);
   tc_para(p->p_text);
   level--;
   clear_temp(mark);
   p->p_flag = DONE;
   p->p_text = ((void *)0);
   file_name = save_file;
   break;
     case BUSY:
   c = node(2,0,363,(struct blob *) cxt,((tree) ((void *)0))); i = level;
   do {
        i--;
        if (active[i].w_cxt != ((void *)0))
      c = node(2,0,363,(struct blob *) active[i].w_cxt,c);
   } while (active[i].w_para != p);
   tc_error(p->p_text->x_loc,
     "Cyclic dependency involving %n", cxt);
   tc_e_etc("Cycle: %l//, //", c);
   tc_e_end();
   break;
     case DONE:
   break;
     default:
   bad_tag("check_para", (int) p->p_flag);
     }
}

variable_types:
mark
void *

variable_types: level int

variable_types: struct context { struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *w_para; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *s_glodef; struct para *s_def; struct sym *s_link; } *w_cxt; } [64]

user_defined_types: struct context { struct para *w_para; struct sym *w_cxt; }


decompiled_code:
int __fastcall do_para(_DWORD *a1)
{
int result; // eax
__int64 v2; // rdx

result = para_count_2;
v2 = (unsigned int)++para_count_2;
if ( vflag && debugging )
{
if ( dcode[3] )
{
grind(stdout, "Paragraph %d:\n", v2);
if ( (unsigned int)(*a1 - 315) <= 1 && (!debugging || !dcode[3]) )
goto LABEL_6;
}
else if ( (unsigned int)(*a1 - 315) <= 1 )
{
LABEL_6:
result = fflush(stdout);
goto LABEL_7;
}
grind(stdout, "%z\n\n", a1);
goto LABEL_6;
}
LABEL_7:
if ( !sflag )
{
if ( dflag )
{
result = store_para(para_count_2, (__int64)a1);
}
else
{
tc_para(a1);
result = clear_temp(0LL);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(_DWORD *a1)
{
int result; // eax
__int64 v2; // rdx

result = para_count_2;
v2 = (unsigned int)++para_count_2;
if ( vflag && debugging )
{
if ( dcode[3] )
{
grind(stdout, "Paragraph %d:\n", v2);
if ( (unsigned int)(*a1 - 315) <= 1 && (!debugging || !dcode[3]) )
goto LABEL_6;
}
else if ( (unsigned int)(*a1 - 315) <= 1 )
{
LABEL_6:
result = fflush(stdout);
goto LABEL_7;
}
grind(stdout, "%z\n\n", a1);
goto LABEL_6;
}
LABEL_7:
if ( !sflag )
{
if ( dflag )
{
result = func3(para_count_2, (__int64)a1);
}
else
{
tc_para(a1);
result = clear_temp(0LL);
}
}
return result;
}

original_code:
void do_para(tree t)
{
     static int para_count = 0;
     para_count++;
     if (vflag && debugging) {
   if ((debugging && dcode['d' - 'a'])) grind(stdout, "Paragraph %d:\n", para_count);
          if ((t->x_kind != 316 && t->x_kind != 315)
       || (debugging && dcode['d' - 'a']))
        grind(stdout, "%z\n\n", t);
   (void) fflush(stdout);
     }
     if (sflag) return;
     if (dflag)
   store_para(para_count, t);
     else {
   tc_para(t);
   clear_temp((univ) ((void *)0));
     }
}

canonical_original_code:
void do_para(struct blob *t)
{
     static int para_count = 0;
     para_count++;
     if (vflag && debugging) {
   if ((debugging && dcode['d' - 'a'])) grind(stdout, "Paragraph %d:\n", para_count);
          if ((t->x_kind != 316 && t->x_kind != 315)
       || (debugging && dcode['d' - 'a']))
        grind(stdout, "%z\n\n", t);
   (void) fflush(stdout);
     }
     if (sflag) return;
     if (dflag)
   store_para(para_count, t);
     else {
   tc_para(t);
   clear_temp((univ) ((void *)0));
     }
}


decompiled_code:
void check_file()
{
_QWORD *v0; // rbx

if ( !sflag )
{
v0 = (_QWORD *)spec_file;
if ( spec_file )
{
do
{
check_para(v0, 0LL);
v0 = (_QWORD *)v0[4];
}
while ( v0 );
}
}
}

canonical_decompiled_code:
void func6()
{
_QWORD *v0; // rbx

if ( !sflag )
{
v0 = (_QWORD *)spec_file;
if ( spec_file )
{
do
{
func4(v0, 0LL);
v0 = (_QWORD *)v0[4];
}
while ( v0 );
}
}
}

original_code:
void check_file(void)
{
     para p;
     if (sflag) return;
     for (p = spec_file; p != ((void *)0); p = p->p_next)
   check_para(p, (sym) ((void *)0));
}

canonical_original_code:
void check_file()
{
     struct para *p;
     if (sflag) return;
     for (p = spec_file; p != ((void *)0); p = p->p_next)
   check_para(p, (sym) ((void *)0));
}


decompiled_code:
__int64 __fastcall global_def(__int64 a1)
{
if ( !*(_QWORD *)(a1 + 24) )
check_para(*(_QWORD **)(a1 + 32), (_QWORD *)a1);
return *(_QWORD *)(a1 + 24);
}

original_code:
def global_def(sym x)
{
     if (x->s_glodef == ((void *)0))
   check_para(x->s_def, x);
     return x->s_glodef;
}

canonical_original_code:
struct def *global_def(struct sym *x)
{
     if (x->s_glodef == ((void *)0))
   check_para(x->s_def, x);
     return x->s_glodef;
}

variable_types:
x
struct sym *

return_type: struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *


decompiled_code:
__int64 __fastcall project_fun(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( a2 )
{
if ( a1 )
check_types(*(_QWORD *)(a1 + 40), *(_QWORD *)(a2 + 40), *(_QWORD *)(a1 + 8), a4, *(unsigned int *)(a4 + 8));
result = push_def(a2, a3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( a2 )
{
if ( a1 )
check_types(*(_QWORD *)(a1 + 40), *(_QWORD *)(a2 + 40), *(_QWORD *)(a1 + 8), a4, *(unsigned int *)(a4 + 8));
result = push_def(a2, a3);
}
return result;
}

original_code:
static void project_fun(def d1, def d2, env v, tree cxt)
{
     if (d2 == ((void *)0)) return;
     if (d1 != ((void *)0))
   check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
        cxt, cxt->x_loc);
     push_def(d2, v);
}

canonical_original_code:
static void project_fun(struct def *d1, struct def *d2, struct env *v, struct blob *cxt)
{
     if (d2 == ((void *)0)) return;
     if (d1 != ((void *)0))
   check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
        cxt, cxt->x_loc);
     push_def(d2, v);
}

variable_types: struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *

variable_types: struct env { struct env *e_next; int e_ndefs; int e_partial; struct def *e_defs; } *


decompiled_code:
__int64 __fastcall implies_fun(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
check_types(*(_QWORD *)(a1 + 40), *(_QWORD *)(a2 + 40), *(_QWORD *)(a1 + 8), a4, *(unsigned int *)(a4 + 8));
*(_QWORD *)(a1 + 40) = super_expand(*(_QWORD *)(a1 + 40), 0LL);
result = push_def(a1, a3);
}
else
{
*(_QWORD *)(a2 + 40) = super_expand(*(_QWORD *)(a2 + 40), 0LL);
result = push_def(a2, a3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
check_types(*(_QWORD *)(a1 + 40), *(_QWORD *)(a2 + 40), *(_QWORD *)(a1 + 8), a4, *(unsigned int *)(a4 + 8));
*(_QWORD *)(a1 + 40) = super_expand(*(_QWORD *)(a1 + 40), 0LL);
result = push_def(a1, a3);
}
else
{
*(_QWORD *)(a2 + 40) = super_expand(*(_QWORD *)(a2 + 40), 0LL);
result = push_def(a2, a3);
}
return result;
}

original_code:
static void implies_fun(def d1, def d2, env v, tree cxt)
{
     if (d1 == ((void *)0)) {
   d2->d_u.type_d = super_expand(d2->d_u.type_d, ((frame) ((void *)0)));
   push_def(d2, v);
     }
     else {
   if (d2 != ((void *)0))
        (void) check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
      cxt, cxt->x_loc);
   d1->d_u.type_d = super_expand(d1->d_u.type_d, ((frame) ((void *)0)));
   push_def(d1, v);
     }
}

canonical_original_code:
static void implies_fun(struct def *d1, struct def *d2, struct env *v, struct blob *cxt)
{
     if (d1 == ((void *)0)) {
   d2->d_u.type_d = super_expand(d2->d_u.type_d, ((frame) ((void *)0)));
   push_def(d2, v);
     }
     else {
   if (d2 != ((void *)0))
        (void) check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
      cxt, cxt->x_loc);
   d1->d_u.type_d = super_expand(d1->d_u.type_d, ((frame) ((void *)0)));
   push_def(d1, v);
     }
}

user_defined_types: struct env { struct env *e_next; int e_ndefs; int e_partial; struct def *e_defs; }


decompiled_code:
__int64 __fastcall and_fun(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
if ( !a1 )
return push_def(a2, a3);
if ( !a2 )
return push_def(a1, a3);
check_types(*(_QWORD *)(a1 + 40), *(_QWORD *)(a2 + 40), *(_QWORD *)(a1 + 8), a4, *(unsigned int *)(a4 + 8));
return push_def(a1, a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
if ( !a1 )
return push_def(a2, a3);
if ( !a2 )
return push_def(a1, a3);
check_types(*(_QWORD *)(a1 + 40), *(_QWORD *)(a2 + 40), *(_QWORD *)(a1 + 8), a4, *(unsigned int *)(a4 + 8));
return push_def(a1, a3);
}

original_code:
static void and_fun(def d1, def d2, env v, tree cxt)
{
     if (d1 == ((void *)0))
   push_def(d2, v);
     else if (d2 == ((void *)0))
   push_def(d1, v);
     else {
   (void) check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
        cxt, cxt->x_loc);
   push_def(d1, v);
     }
}

canonical_original_code:
static void and_fun(struct def *d1, struct def *d2, struct env *v, struct blob *cxt)
{
     if (d1 == ((void *)0))
   push_def(d2, v);
     else if (d2 == ((void *)0))
   push_def(d1, v);
     else {
   (void) check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
        cxt, cxt->x_loc);
   push_def(d1, v);
     }
}


decompiled_code:
__int64 __fastcall or_fun(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
if ( (unsigned int)check_types(
*(_QWORD *)(a1 + 40),
*(_QWORD *)(a2 + 40),
*(_QWORD *)(a1 + 8),
a4,
*(unsigned int *)(a4 + 8)) )
*(_QWORD *)(a1 + 40) = type_union(*(_QWORD *)(a1 + 40), 0LL, *(_QWORD *)(a2 + 40), 0LL);
result = push_def(a1, a3);
}
else
{
*(_QWORD *)(a1 + 40) = super_expand(*(_QWORD *)(a1 + 40), 0LL);
result = push_def(a1, a3);
}
}
else
{
*(_QWORD *)(a2 + 40) = super_expand(*(_QWORD *)(a2 + 40), 0LL);
result = push_def(a2, a3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
if ( (unsigned int)check_types(
*(_QWORD *)(a1 + 40),
*(_QWORD *)(a2 + 40),
*(_QWORD *)(a1 + 8),
a4,
*(unsigned int *)(a4 + 8)) )
*(_QWORD *)(a1 + 40) = type_union(*(_QWORD *)(a1 + 40), 0LL, *(_QWORD *)(a2 + 40), 0LL);
result = push_def(a1, a3);
}
else
{
*(_QWORD *)(a1 + 40) = super_expand(*(_QWORD *)(a1 + 40), 0LL);
result = push_def(a1, a3);
}
}
else
{
*(_QWORD *)(a2 + 40) = super_expand(*(_QWORD *)(a2 + 40), 0LL);
result = push_def(a2, a3);
}
return result;
}

original_code:
static void or_fun(def d1, def d2, env v, tree cxt)
{
     if (d1 == ((void *)0)) {
   d2->d_u.type_d = super_expand(d2->d_u.type_d, ((frame) ((void *)0)));
   push_def(d2, v);
     }
     else if (d2 == ((void *)0)) {
   d1->d_u.type_d = super_expand(d1->d_u.type_d, ((frame) ((void *)0)));
   push_def(d1, v);
     }
     else {
   if (check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
     cxt, cxt->x_loc))
        d1->d_u.type_d = type_union(d1->d_u.type_d, ((frame) ((void *)0)), d2->d_u.type_d, ((frame) ((void *)0)));
   push_def(d1, v);
     }
}

canonical_original_code:
static void or_fun(struct def *d1, struct def *d2, struct env *v, struct blob *cxt)
{
     if (d1 == ((void *)0)) {
   d2->d_u.type_d = super_expand(d2->d_u.type_d, ((frame) ((void *)0)));
   push_def(d2, v);
     }
     else if (d2 == ((void *)0)) {
   d1->d_u.type_d = super_expand(d1->d_u.type_d, ((frame) ((void *)0)));
   push_def(d1, v);
     }
     else {
   if (check_types(d1->d_u.type_d, d2->d_u.type_d, d1->d_name,
     cxt, cxt->x_loc))
        d1->d_u.type_d = type_union(d1->d_u.type_d, ((frame) ((void *)0)), d2->d_u.type_d, ((frame) ((void *)0)));
   push_def(d1, v);
     }
}


original_code:
bool open_sref(tree t, env e, def *d, frame *f)
{
     if ((*d = get_schema((tok) t->x_slot[0], t->x_loc)) == ((void *)0))
   return 0;
     *f = mk_frame((*d)->d_nparams);
     get_params("Schema", mk_symbol((tok) t->x_slot[0], empty),
  t->x_slot[2], e, *f, t->x_loc);
     return 1;
}

canonical_original_code:
int open_sref(struct blob *t, struct env *e, struct def **d, struct frame **f)
{
     if ((*d = get_schema((struct tok *) t->x_slot[0], t->x_loc)) == ((void *)0))
   return 0;
     *f = mk_frame((*d)->d_nparams);
     get_params("Schema", mk_symbol((struct tok *) t->x_slot[0], empty),
  t->x_slot[2], e, *f, t->x_loc);
     return 1;
}

variable_types: struct env { struct env *e_next; int e_ndefs; int e_partial; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *e_defs; } *

variable_types:
d
struct def **

variable_types:
f
struct frame **

return_type: int


decompiled_code:
void __fastcall check_rename(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 i; // r14
_QWORD *v6; // r12
__int64 v7; // rbx

for ( i = a3; i; i = *(_QWORD *)(*(_QWORD *)(i + 16) + 8LL) )
{
v6 = *(_QWORD **)(*(_QWORD *)(**(_QWORD **)(i + 16) + 16LL) + 8LL);
if ( *(int *)a1 <= 0 )
{
LABEL_3:
tc_error(*(unsigned int *)(a4 + 8), "Renamed component %n does not exist", v6);
tc_e_etc("Expression: %z", a4);
tc_e_end();
}
else
{
v7 = 0LL;
while ( v6 != (_QWORD *)paint(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 16 * v7), a2) )
{
if ( *(_DWORD *)a1 <= (int)++v7 )
goto LABEL_3;
}
}
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 i; // r14
_QWORD *v6; // r12
__int64 v7; // rbx

for ( i = a3; i; i = *(_QWORD *)(*(_QWORD *)(i + 16) + 8LL) )
{
v6 = *(_QWORD **)(*(_QWORD *)(**(_QWORD **)(i + 16) + 16LL) + 8LL);
if ( *(int *)a1 <= 0 )
{
LABEL_3:
tc_error(*(unsigned int *)(a4 + 8), "Renamed component %n does not exist", v6);
tc_e_etc("Expression: %z", a4);
tc_e_end();
}
else
{
v7 = 0LL;
while ( v6 != (_QWORD *)paint(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 16 * v7), a2) )
{
if ( *(_DWORD *)a1 <= (int)++v7 )
goto LABEL_3;
}
}
}
}

original_code:
void check_rename(schema s, tok dec, tree rename, tree cxt)
{
     tree r;
     int i;
     for (r = rename; r != ((tree) ((void *)0)); r = (r)->x_slot[1]) {
   sym x = (sym) (r)->x_slot[0]->x_slot[1];
   for (i = 0; i < s->z_ncomps; i++)
        if (paint(s->z_comp[i].z_name, dec) == x)
      goto ok;
   tc_error(cxt->x_loc, "Renamed component %n does not exist", x);
   tc_e_etc("Expression: %z", cxt);
   tc_e_end();
     ok:
   ;
     }
}

canonical_original_code:
void check_rename(struct schema *s, struct tok *dec, struct blob *rename, struct blob *cxt)
{
     struct blob *r;
     int i;
     for (r = rename; r != ((tree) ((void *)0)); r = (r)->x_slot[1]) {
   struct sym *x = (sym) (r)->x_slot[0]->x_slot[1];
   for (i = 0; i < s->z_ncomps; i++)
        if (paint(s->z_comp[i].z_name, dec) == x)
      goto ok;
   tc_error(cxt->x_loc, "Renamed component %n does not exist", x);
   tc_e_etc("Expression: %z", cxt);
   tc_e_end();
     ok:
   ;
     }
}

variable_types: struct schema { int z_ncomps; struct compnt { struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *z_name; struct type *z_type; } *z_comp; } *

variable_types:
dec
struct tok *

variable_types:
rename
struct blob *

variable_types: struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *


original_code:
sym get_rename(sym x, tok dec, tree rename)
{
     tree r;
     sym xx = paint(x, dec);
     for (r = rename; r != ((tree) ((void *)0)); r = (r)->x_slot[1])
   if ((sym) (r)->x_slot[0]->x_slot[1] == xx)
        return ((sym) (r)->x_slot[0]->x_slot[0]);
     return xx;
}

canonical_original_code:
struct sym *get_rename(struct sym *x, struct tok *dec, struct blob *rename)
{
     struct blob *r;
     struct sym *xx = paint(x, dec);
     for (r = rename; r != ((tree) ((void *)0)); r = (r)->x_slot[1])
   if ((sym) (r)->x_slot[0]->x_slot[1] == xx)
        return ((sym) (r)->x_slot[0]->x_slot[0]);
     return xx;
}

return_type: struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *


original_code:
void do_sref(tree t, env e, env v)
{
     tok dec = (tok) t->x_slot[1];
     tree renames = t->x_slot[3];
     def d;
     schema s;
     frame params;
     int i;
     if (t->x_kind != 358) bad_tag("do_sref", t->x_kind);
     if (! open_sref(t, e, &d, &params)) {
   v->e_partial = 1;
   return;
     }
     s = d->d_u.schema_d;
     check_rename(d->d_u.schema_d, dec, renames, t);
     for (i = 0; i < s->z_ncomps; i++)
   merge_def(VAR, get_rename(s->z_comp[i].z_name, dec, renames),
      seal(s->z_comp[i].z_type, params), v, t, t->x_loc);
}

canonical_original_code:
void do_sref(struct blob *t, struct env *e, struct env *v)
{
     struct tok *dec = (tok) t->x_slot[1];
     struct blob *renames = t->x_slot[3];
     struct def *d;
     struct schema *s;
     struct frame *params;
     int i;
     if (t->x_kind != 358) bad_tag("do_sref", t->x_kind);
     if (! open_sref(t, e, &d, &params)) {
   v->e_partial = 1;
   return;
     }
     s = d->d_u.schema_d;
     check_rename(d->d_u.schema_d, dec, renames, t);
     for (i = 0; i < s->z_ncomps; i++)
   merge_def(VAR, get_rename(s->z_comp[i].z_name, dec, renames),
      seal(s->z_comp[i].z_type, params), v, t, t->x_loc);
}

variable_types:
v
struct env *

variable_types: struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym { int x_kind; struct tok *s_basename; struct tok *s_decor; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *

variable_types: struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } **f_var; } *

variable_types: i int


decompiled_code:
__int64 __fastcall tc_sexp(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 j; // rbx
__int64 i; // r12
__int64 v6; // r13
_QWORD *k; // r12

switch ( *(_DWORD *)a1 )
{
case 0x116:
v2 = compose(a1, a2, prime, empty, "sequential composition");
break;
case 0x119:
v2 = tc_sexp(**(_QWORD **)(a1 + 16), a2);
for ( i = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL); i; i = *(_QWORD *)(*(_QWORD *)(i + 16) + 8LL) )
hide_var(**(_QWORD **)(i + 16), 0LL, v2, a1, *(unsigned int *)(a1 + 8));
break;
case 0x128:
v2 = compose(a1, a2, pling, query, "piping");
break;
case 0x12A:
v2 = precond(a1, a2);
break;
case 0x12B:
v2 = binary_sexp(project_fun, a1, a2);
break;
case 0x166:
v2 = new_env(a2);
do_sref(a1, a2, v2);
break;
case 0x168:
v2 = tc_schema(**(_QWORD **)(a1 + 16), a2);
break;
case 0x17B:
v2 = tc_sexp(**(_QWORD **)(a1 + 16), a2);
for ( j = *(_QWORD *)(v2 + 16); j; j = *(_QWORD *)(j + 32) )
*(_QWORD *)(j + 40) = super_expand(*(_QWORD *)(j + 40), 0LL);
break;
case 0x17C:
v2 = binary_sexp(and_fun, a1, a2);
break;
case 0x17D:
v2 = binary_sexp(or_fun, a1, a2);
break;
case 0x17E:
case 0x17F:
v2 = binary_sexp(implies_fun, a1, a2);
break;
case 0x180:
case 0x181:
case 0x182:
v6 = tc_schema(**(_QWORD **)(a1 + 16), a2);
v2 = tc_sexp(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL), a2);
for ( k = *(_QWORD **)(v6 + 16); k; k = (_QWORD *)k[4] )
hide_var(k[1], k[5], v2, a1, *(unsigned int *)(a1 + 8));
break;
default:
bad_tag("get_sexp");
v2 = 0LL;
break;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 j; // rbx
__int64 i; // r12
__int64 v6; // r13
_QWORD *k; // r12

switch ( *(_DWORD *)a1 )
{
case 0x116:
v2 = func10(a1, a2, prime, empty, "sequential composition");
break;
case 0x119:
v2 = func8(**(_QWORD **)(a1 + 16), a2);
for ( i = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL); i; i = *(_QWORD *)(*(_QWORD *)(i + 16) + 8LL) )
hide_var(**(_QWORD **)(i + 16), 0LL, v2, a1, *(unsigned int *)(a1 + 8));
break;
case 0x128:
v2 = func10(a1, a2, pling, query, "piping");
break;
case 0x12A:
v2 = func11(a1, a2);
break;
case 0x12B:
v2 = func9(project_fun, a1, a2);
break;
case 0x166:
v2 = new_env(a2);
func7(a1, a2, v2);
break;
case 0x168:
v2 = tc_schema(**(_QWORD **)(a1 + 16), a2);
break;
case 0x17B:
v2 = func8(**(_QWORD **)(a1 + 16), a2);
for ( j = *(_QWORD *)(v2 + 16); j; j = *(_QWORD *)(j + 32) )
*(_QWORD *)(j + 40) = super_expand(*(_QWORD *)(j + 40), 0LL);
break;
case 0x17C:
v2 = func9(and_fun, a1, a2);
break;
case 0x17D:
v2 = func9(or_fun, a1, a2);
break;
case 0x17E:
case 0x17F:
v2 = func9(implies_fun, a1, a2);
break;
case 0x180:
case 0x181:
case 0x182:
v6 = tc_schema(**(_QWORD **)(a1 + 16), a2);
v2 = func8(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL), a2);
for ( k = *(_QWORD **)(v6 + 16); k; k = (_QWORD *)k[4] )
hide_var(k[1], k[5], v2, a1, *(unsigned int *)(a1 + 8));
break;
default:
bad_tag("get_sexp");
v2 = 0LL;
break;
}
return v2;
}

original_code:
env tc_sexp(tree t, env e)
{
     env e1, e2;
     tree u;
     def d;
     switch (t->x_kind) {
     case 360:
   return tc_schema(t->x_slot[0], e);
     case 358:
   e1 = new_env(e);
   do_sref(t, e, e1);
   return e1;
     case 379:
   e1 = tc_sexp(t->x_slot[0], e);
   for (d = e1->e_defs; d != ((void *)0); d = d->d_next)
        d->d_u.type_d = super_expand(d->d_u.type_d, ((frame) ((void *)0)));
   return e1;
     case 380: return binary_sexp(and_fun, t, e);
     case 381: return binary_sexp(or_fun, t, e);
     case 382: case 383:
      return binary_sexp(implies_fun, t, e);
     case 299: return binary_sexp(project_fun, t, e);
     case 278:
   return compose(t, e, prime, empty, "sequential composition");
     case 296:
   return compose(t, e, pling, query, "piping");
     case 281:
   e1 = tc_sexp(t->x_slot[0], e);
   for (u = t->x_slot[1]; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
        hide_var((sym) (u)->x_slot[0], (type) ((void *)0), e1, t, t->x_loc);
   return e1;
     case 385: case 384: case 386:
   e2 = tc_schema(t->x_slot[0], e);
   e1 = tc_sexp(t->x_slot[1], e);
   for (d = e2->e_defs; d != ((void *)0); d = d->d_next)
        hide_var(d->d_name, d->d_u.type_d, e1, t, t->x_loc);
   return e1;
     case 298:
   return precond(t, e);
     default:
   bad_tag("get_sexp", t->x_kind);
   return ((void *)0);
     }
}

canonical_original_code:
struct env *tc_sexp(struct blob *t, struct env *e)
{
     struct env *e1; struct env *e2;
     struct blob *u;
     struct def *d;
     switch (t->x_kind) {
     case 360:
   return tc_schema(t->x_slot[0], e);
     case 358:
   e1 = new_env(e);
   do_sref(t, e, e1);
   return e1;
     case 379:
   e1 = tc_sexp(t->x_slot[0], e);
   for (d = e1->e_defs; d != ((void *)0); d = d->d_next)
        d->d_u.type_d = super_expand(d->d_u.type_d, ((frame) ((void *)0)));
   return e1;
     case 380: return binary_sexp(and_fun, t, e);
     case 381: return binary_sexp(or_fun, t, e);
     case 382: case 383:
      return binary_sexp(implies_fun, t, e);
     case 299: return binary_sexp(project_fun, t, e);
     case 278:
   return compose(t, e, prime, empty, "sequential composition");
     case 296:
   return compose(t, e, pling, query, "piping");
     case 281:
   e1 = tc_sexp(t->x_slot[0], e);
   for (u = t->x_slot[1]; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
        hide_var((sym) (u)->x_slot[0], (type) ((void *)0), e1, t, t->x_loc);
   return e1;
     case 385: case 384: case 386:
   e2 = tc_schema(t->x_slot[0], e);
   e1 = tc_sexp(t->x_slot[1], e);
   for (d = e2->e_defs; d != ((void *)0); d = d->d_next)
        hide_var(d->d_name, d->d_u.type_d, e1, t, t->x_loc);
   return e1;
     case 298:
   return precond(t, e);
     default:
   bad_tag("get_sexp", t->x_kind);
   return ((void *)0);
     }
}

variable_types:
t
struct blob *

variable_types:
e
struct env *

variable_types: struct env { struct env *e_next; int e_ndefs; int e_partial; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *e_defs; } *


original_code:
static env binary_sexp(mergeop f, tree t, env e)
{
     env e1 = sort_env(tc_sexp(t->x_slot[0], e));
     env e2 = sort_env(tc_sexp(t->x_slot[1], e));
     env ee = new_env(e);
     def d1, d2;
     d1 = pop_def(e1);
     d2 = pop_def(e2);
     while (d1 != ((void *)0) || d2 != ((void *)0)) {
   int c = (d1 == ((void *)0) ? 1 : d2 == ((void *)0) ? -1
     : my_compare(&d1, &d2));
   if (c < 0) {
        (*f)(d1, (def) ((void *)0), ee, t);
        d1 = pop_def(e1);
   }
   else if (c > 0) {
        (*f)((def) ((void *)0), d2, ee, t);
        d2 = pop_def(e2);
   }
   else {
        (*f)(d1, d2, ee, t);
        d1 = pop_def(e1);
        d2 = pop_def(e2);
   }
     }
     return ee;
}

canonical_original_code:
static struct env *binary_sexp(void (*f)(struct def *d1, struct def *d2, struct env *vars, struct blob *cxt), struct blob *t, struct env *e)
{
     struct env *e1 = sort_env(tc_sexp(t->x_slot[0], e));
     struct env *e2 = sort_env(tc_sexp(t->x_slot[1], e));
     struct env *ee = new_env(e);
     struct def *d1; struct def *d2;
     d1 = pop_def(e1);
     d2 = pop_def(e2);
     while (d1 != ((void *)0) || d2 != ((void *)0)) {
   int c = (d1 == ((void *)0) ? 1 : d2 == ((void *)0) ? -1
     : my_compare(&d1, &d2));
   if (c < 0) {
        (*f)(d1, (def) ((void *)0), ee, t);
        d1 = pop_def(e1);
   }
   else if (c > 0) {
        (*f)((def) ((void *)0), d2, ee, t);
        d2 = pop_def(e2);
   }
   else {
        (*f)(d1, d2, ee, t);
        d1 = pop_def(e1);
        d2 = pop_def(e2);
   }
     }
     return ee;
}

variable_types: void (*)(struct def *d1, struct def *d2, struct env *vars, struct blob *cxt)

variable_types: c int

return_type: struct env { struct env *e_next; int e_ndefs; int e_partial; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *e_defs; } *


compose

original_code:
static env compose(tree t, env e, tok ldec, tok rdec, char *kind)
{
     env e1 = tc_sexp(t->x_slot[0], e);
     env e2 = tc_sexp(t->x_slot[1], e);
     env ee = new_env(e);
     def q;
     for (;;) {
   def d = pop_def(e1);
   if (d == ((void *)0))
        break;
   else if (d->d_name->s_decor != ldec)
        push_def(d, ee);
   else {
        sym rname = mk_symbol(d->d_name->s_basename, rdec);
        type rtype = del_var(rname, e2);
        if (rtype == ((void *)0))
      push_def(d, ee);
        else if (! unify(d->d_u.type_d, rtype)) {
      tc_error(t->x_loc, "Type mismatch in %s", kind);
      tc_e_etc("Expression: %z", t);
      tc_e_etc("Type of %n in LHS: %t", d->d_name, d->d_u.type_d);
      tc_e_etc("Type of %n in RHS: %t", rname, rtype);
      tc_e_end();
        }
   }
     }
     for (q = e2->e_defs; q != ((void *)0); q = q->d_next)
   merge_def(VAR, q->d_name, q->d_u.type_d, ee, t, t->x_loc);
     return ee;
}

canonical_original_code:
static struct env *compose(struct blob *t, struct env *e, struct tok *ldec, struct tok *rdec, char *kind)
{
     struct env *e1 = tc_sexp(t->x_slot[0], e);
     struct env *e2 = tc_sexp(t->x_slot[1], e);
     struct env *ee = new_env(e);
     struct def *q;
     for (;;) {
   struct def *d = pop_def(e1);
   if (d == ((void *)0))
        break;
   else if (d->d_name->s_decor != ldec)
        push_def(d, ee);
   else {
        struct sym *rname = mk_symbol(d->d_name->s_basename, rdec);
        struct type *rtype = del_var(rname, e2);
        if (rtype == ((void *)0))
      push_def(d, ee);
        else if (! unify(d->d_u.type_d, rtype)) {
      tc_error(t->x_loc, "Type mismatch in %s", kind);
      tc_e_etc("Expression: %z", t);
      tc_e_etc("Type of %n in LHS: %t", d->d_name, d->d_u.type_d);
      tc_e_etc("Type of %n in RHS: %t", rname, rtype);
      tc_e_end();
        }
   }
     }
     for (q = e2->e_defs; q != ((void *)0); q = q->d_next)
   merge_def(VAR, q->d_name, q->d_u.type_d, ee, t, t->x_loc);
     return ee;
}

variable_types:
ldec
struct tok *

variable_types:
rdec
struct tok *

variable_types:
kind
char *

variable_types: struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *

variable_types: struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *


decompiled_code:
__int64 mark_temp()
{
return qword_4C0;
}

canonical_decompiled_code:
__int64 func1()
{
return qword_4C0;
}

original_code:
univ mark_temp(void)
{
     return (univ) temp_chain.c_free;
}

canonical_original_code:
void *mark_temp()
{
     return (void *) temp_chain.c_free;
}

return_type: void *


decompiled_code:
void begin_perm()
{
current_chain = &perm_chain;
}

canonical_decompiled_code:
void func2()
{
current_chain = &perm_chain;
}

original_code:
void begin_perm(void)
{
     current_chain = &perm_chain;
}


decompiled_code:
void end_perm()
{
current_chain = &temp_chain;
}

canonical_decompiled_code:
void func3()
{
current_chain = &temp_chain;
}

original_code:
void end_perm(void)
{
     current_chain = &temp_chain;
}


decompiled_code:
int alloc_stats()
{
unsigned int v0; // ebp
unsigned int v1; // ebx
unsigned int v2; // eax

v0 = chunk_count((_QWORD **)&free_chain);
v1 = chunk_count((_QWORD **)&temp_chain);
v2 = chunk_count((_QWORD **)&perm_chain);
return printf("Storage stats: perm = %d, temp = %d, free = %d blocks of %d\n", v2, v1, v0, 0x10000LL);
}

canonical_decompiled_code:
int func4()
{
unsigned int v0; // ebp
unsigned int v1; // ebx
unsigned int v2; // eax

v0 = func0((_QWORD **)&free_chain);
v1 = func0((_QWORD **)&temp_chain);
v2 = func0((_QWORD **)&perm_chain);
return printf("Storage stats: perm = %d, temp = %d, free = %d blocks of %d\n", v2, v1, v0, 0x10000LL);
}

original_code:
void alloc_stats(void)
{
     (void) printf(
       "Storage stats: perm = %d, temp = %d, free = %d blocks of %d\n",
       chunk_count(&perm_chain), chunk_count(&temp_chain),
       chunk_count(&free_chain), 65536);
}

canonical_original_code:
void alloc_stats()
{
     (void) printf(
       "Storage stats: perm = %d, temp = %d, free = %d blocks of %d\n",
       chunk_count(&perm_chain), chunk_count(&temp_chain),
       chunk_count(&free_chain), 65536);
}


decompiled_code:
int __fastcall clear_temp(unsigned __int64 a1)
{
_QWORD *v1; // rdx
__int64 v2; // rax
_QWORD *v3; // rax
_QWORD *v4; // rsi

v1 = (_QWORD *)temp_chain;
if ( a1 )
{
while ( a1 <= (unsigned __int64)v1 || a1 > (unsigned __int64)(v1 + 0x2000) )
v1 = (_QWORD *)*v1;
if ( debugging && dcode[18] )
{
if ( v1 )
{
v3 = (_QWORD *)a1;
v4 = v1;
do
{
for ( ; v3 < v4 + 0x2000; ++v3 )
*v3 = 2863311530LL;
v4 = (_QWORD *)*v4;
v3 = v4 + 1;
}
while ( v4 );
goto LABEL_19;
}
LABEL_3:
v2 = temp_chain;
temp_chain = 0LL;
v1 = 0LL;
goto LABEL_20;
}
}
else
{
if ( !debugging || dcode[18] )
goto LABEL_3;
v1 = 0LL;
}
if ( !v1 )
goto LABEL_3;
LABEL_19:
v2 = *v1;
*v1 = 0LL;
LABEL_20:
if ( v2 )
{
if ( free_chain )
*(_QWORD *)qword_498 = v2;
else
free_chain = v2;
LODWORD(v2) = qword_4B8;
qword_498 = qword_4B8;
}
qword_4B8 = (__int64)v1;
qword_4C0 = a1;
if ( debugging && dcode[0] )
LODWORD(v2) = alloc_stats();
return v2;
}

canonical_decompiled_code:
int __fastcall func5(unsigned __int64 a1)
{
_QWORD *v1; // rdx
__int64 v2; // rax
_QWORD *v3; // rax
_QWORD *v4; // rsi

v1 = (_QWORD *)temp_chain;
if ( a1 )
{
while ( a1 <= (unsigned __int64)v1 || a1 > (unsigned __int64)(v1 + 0x2000) )
v1 = (_QWORD *)*v1;
if ( debugging && dcode[18] )
{
if ( v1 )
{
v3 = (_QWORD *)a1;
v4 = v1;
do
{
for ( ; v3 < v4 + 0x2000; ++v3 )
*v3 = 2863311530LL;
v4 = (_QWORD *)*v4;
v3 = v4 + 1;
}
while ( v4 );
goto LABEL_19;
}
LABEL_3:
v2 = temp_chain;
temp_chain = 0LL;
v1 = 0LL;
goto LABEL_20;
}
}
else
{
if ( !debugging || dcode[18] )
goto LABEL_3;
v1 = 0LL;
}
if ( !v1 )
goto LABEL_3;
LABEL_19:
v2 = *v1;
*v1 = 0LL;
LABEL_20:
if ( v2 )
{
if ( free_chain )
*(_QWORD *)qword_498 = v2;
else
free_chain = v2;
LODWORD(v2) = qword_4B8;
qword_498 = qword_4B8;
}
qword_4B8 = (__int64)v1;
qword_4C0 = a1;
if ( debugging && dcode[0] )
LODWORD(v2) = func4();
return v2;
}

original_code:
void clear_temp(univ mark)
{
     chunk *p, *r;
     if (mark == ((void *)0))
   p = ((void *)0);
     else {
   p = temp_chain.c_front;
   while ((addr) mark <= (addr) p
   || (addr) mark > (addr) p + 65536)
        p = p->next;
     }
     if ((debugging && dcode['s' - 'a'])) {
   char *q = mark;
   r = p;
   while (r != ((void *)0)) {
        while (q < (char *) r + 65536) {
      *((long *) q) = 0xaaaaaaaa;
      q = q + sizeof(long);
        }
        r = r->next;
        q = (char *) r + sizeof(chunk);
   }
     }
     if (p == ((void *)0)) {
   r = temp_chain.c_front;
   temp_chain.c_front = ((void *)0);
     }
     else {
   r = p->next;
   p->next = ((void *)0);
     }
     if (r != ((void *)0)) {
   if (free_chain.c_front == ((void *)0))
        free_chain.c_front = r;
   else
        free_chain.c_back->next = r;
   free_chain.c_back = temp_chain.c_back;
     }
     temp_chain.c_back = p;
     temp_chain.c_free = (char *) mark;
   if ((debugging && dcode['a' - 'a']))
        alloc_stats();
}

canonical_original_code:
void clear_temp(void *mark)
{
     struct chunk *p; struct chunk *r;
     if (mark == ((void *)0))
   p = ((void *)0);
     else {
   p = temp_chain.c_front;
   while ((unsigned long) mark <= (unsigned long) p
   || (unsigned long) mark > (unsigned long) p + 65536)
        p = p->next;
     }
     if ((debugging && dcode['s' - 'a'])) {
   char *q = mark;
   r = p;
   while (r != ((void *)0)) {
        while (q < (char *) r + 65536) {
      *((long *) q) = 0xaaaaaaaa;
      q = q + sizeof(long);
        }
        r = r->next;
        q = (char *) r + sizeof(chunk);
   }
     }
     if (p == ((void *)0)) {
   r = temp_chain.c_front;
   temp_chain.c_front = ((void *)0);
     }
     else {
   r = p->next;
   p->next = ((void *)0);
     }
     if (r != ((void *)0)) {
   if (free_chain.c_front == ((void *)0))
        free_chain.c_front = r;
   else
        free_chain.c_back->next = r;
   free_chain.c_back = temp_chain.c_back;
     }
     temp_chain.c_back = p;
     temp_chain.c_free = (char *) mark;
   if ((debugging && dcode['a' - 'a']))
        alloc_stats();
}

variable_types:
mark
void *

variable_types:
p
struct chunk { struct chunk *next; } *

variable_types:
r
struct chunk { struct chunk *next; } *

variable_types:
q
char *


decompiled_code:
void *__fastcall alloc_mem(int a1, int a2, const char *a3)
{
void *v4; // rbx

v4 = malloc(a2 * (__int64)a1);
if ( !v4 )
panic("out of memory in %s", a3);
return v4;
}

canonical_decompiled_code:
void *__fastcall func6(int a1, int a2, const char *a3)
{
void *v4; // rbx

v4 = malloc(a2 * (__int64)a1);
if ( !v4 )
panic("out of memory in %s", a3);
return v4;
}

original_code:
univ alloc_mem(int n_items, int size, char *cxt)
{
     univ p = malloc(n_items * (size_t) size);
     if (p == ((void *)0)) panic("out of memory in %s", cxt);
     return p;
}

canonical_original_code:
void *alloc_mem(int n_items, int size, char *cxt)
{
     void *p = malloc(n_items * (size_t) size);
     if (p == ((void *)0)) panic("out of memory in %s", cxt);
     return p;
}

variable_types: size int

variable_types:
cxt
char *

variable_types:
p
void *


decompiled_code:
__int64 __fastcall u_occur(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r14
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // r14
__int64 v10; // r14
int v11; // ecx
__int64 v12; // rdx

switch ( *(_DWORD *)a3 )
{
case 0:
result = 0LL;
break;
case 1:
v11 = *(_DWORD *)(a3 + 8);
v12 = *(_QWORD *)(*(_QWORD *)(a4 + 24) + 8LL * v11);
if ( v12 )
{
result = u_occur(a1, a2, v12, 0LL);
}
else
{
result = 0LL;
if ( a2 == a4 )
result = *(_DWORD *)(a1 + 8) == v11;
}
break;
case 2:
result = u_occur(a1, a2, *(_QWORD *)(a3 + 8), a4);
break;
case 3:
v10 = 0LL;
result = 0LL;
if ( *(int *)(a3 + 8) > 0 )
{
while ( 1 )
{
result = u_occur(a1, a2, *(_QWORD *)(*(_QWORD *)(a3 + 16) + 8 * v10), a4);
if ( (_DWORD)result )
break;
if ( *(_DWORD *)(a3 + 8) <= (int)++v10 )
return result;
}
result = 1LL;
}
break;
case 4:
v8 = *(_QWORD *)(a3 + 8);
v9 = 0LL;
result = 0LL;
if ( *(int *)v8 > 0 )
{
while ( 1 )
{
result = u_occur(a1, a2, *(_QWORD *)(*(_QWORD *)(v8 + 8) + 16 * v9 + 8), a4);
if ( (_DWORD)result )
break;
v8 = *(_QWORD *)(a3 + 8);
if ( *(_DWORD *)v8 <= (int)++v9 )
return result;
}
result = 1LL;
}
break;
case 5:
result = u_occur(a1, a2, *(_QWORD *)(a3 + 8), *(_QWORD *)(a3 + 16));
break;
case 6:
v6 = 0LL;
if ( *(int *)(*(_QWORD *)(a3 + 8) + 16LL) <= 0 )
{
result = 0LL;
}
else
{
while ( 1 )
{
result = u_occur(a1, a2, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a3 + 16) + 24LL) + 8 * v6), a4);
if ( (_DWORD)result )
break;
if ( *(_DWORD *)(*(_QWORD *)(a3 + 8) + 16LL) <= (int)++v6 )
return result;
}
result = 1LL;
}
break;
default:
bad_tag("u_occur");
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r14
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // r14
__int64 v10; // r14
int v11; // ecx
__int64 v12; // rdx

switch ( *(_DWORD *)a3 )
{
case 0:
result = 0LL;
break;
case 1:
v11 = *(_DWORD *)(a3 + 8);
v12 = *(_QWORD *)(*(_QWORD *)(a4 + 24) + 8LL * v11);
if ( v12 )
{
result = func0(a1, a2, v12, 0LL);
}
else
{
result = 0LL;
if ( a2 == a4 )
result = *(_DWORD *)(a1 + 8) == v11;
}
break;
case 2:
result = func0(a1, a2, *(_QWORD *)(a3 + 8), a4);
break;
case 3:
v10 = 0LL;
result = 0LL;
if ( *(int *)(a3 + 8) > 0 )
{
while ( 1 )
{
result = func0(a1, a2, *(_QWORD *)(*(_QWORD *)(a3 + 16) + 8 * v10), a4);
if ( (_DWORD)result )
break;
if ( *(_DWORD *)(a3 + 8) <= (int)++v10 )
return result;
}
result = 1LL;
}
break;
case 4:
v8 = *(_QWORD *)(a3 + 8);
v9 = 0LL;
result = 0LL;
if ( *(int *)v8 > 0 )
{
while ( 1 )
{
result = func0(a1, a2, *(_QWORD *)(*(_QWORD *)(v8 + 8) + 16 * v9 + 8), a4);
if ( (_DWORD)result )
break;
v8 = *(_QWORD *)(a3 + 8);
if ( *(_DWORD *)v8 <= (int)++v9 )
return result;
}
result = 1LL;
}
break;
case 5:
result = func0(a1, a2, *(_QWORD *)(a3 + 8), *(_QWORD *)(a3 + 16));
break;
case 6:
v6 = 0LL;
if ( *(int *)(*(_QWORD *)(a3 + 8) + 16LL) <= 0 )
{
result = 0LL;
}
else
{
while ( 1 )
{
result = func0(a1, a2, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a3 + 16) + 24LL) + 8 * v6), a4);
if ( (_DWORD)result )
break;
if ( *(_DWORD *)(*(_QWORD *)(a3 + 8) + 16LL) <= (int)++v6 )
return result;
}
result = 1LL;
}
break;
default:
bad_tag("u_occur");
result = 0LL;
break;
}
return result;
}

original_code:
static bool u_occur(type v, frame f1, type t, frame f2)
{
     type w;
     int i;
     switch (t->t_kind) {
     case GIVENT:
   return 0;
     case TYPEVAR:
   if ((w = f2->f_var[t->t_u.typevar_t]) != ((void *)0))
        return u_occur(v, f1, w, ((frame) ((void *)0)));
   else
        return (f1 == f2 && v->t_u.typevar_t == t->t_u.typevar_t);
     case POWERT:
   return u_occur(v, f1, t->t_u.base_t, f2);
     case CPRODUCT:
   for (i = 0; i < t->t_u.cproduct_t.t__nfields; i++)
        if (u_occur(v, f1, t->t_u.cproduct_t.t__field[i], f2))
      return 1;
   return 0;
     case SPRODUCT:
   for (i = 0; i < t->t_u.schema_t->z_ncomps; i++)
        if (u_occur(v, f1, t->t_u.schema_t->z_comp[i].z_type, f2))
      return 1;
   return 0;
     case MOLECULE:
   return u_occur(v, f1, t->t_u.molecule_t.t__mtype, t->t_u.molecule_t.t__mframe);
     case ABBREV:
   for (i = 0; i < t->t_u.abbrev_t.t__def->d_nparams; i++)
        if (u_occur(v, f1, t->t_u.abbrev_t.t__params->f_var[i], f2))
      return 1;
   return 0;
     default:
   bad_tag("u_occur", t->t_kind);
   return 0;
     }
}

canonical_original_code:
static int u_occur(struct type *v, struct frame *f1, struct type *t, struct frame *f2)
{
     struct type *w;
     int i;
     switch (t->t_kind) {
     case GIVENT:
   return 0;
     case TYPEVAR:
   if ((w = f2->f_var[t->t_u.typevar_t]) != ((void *)0))
        return u_occur(v, f1, w, ((frame) ((void *)0)));
   else
        return (f1 == f2 && v->t_u.typevar_t == t->t_u.typevar_t);
     case POWERT:
   return u_occur(v, f1, t->t_u.base_t, f2);
     case CPRODUCT:
   for (i = 0; i < t->t_u.cproduct_t.t__nfields; i++)
        if (u_occur(v, f1, t->t_u.cproduct_t.t__field[i], f2))
      return 1;
   return 0;
     case SPRODUCT:
   for (i = 0; i < t->t_u.schema_t->z_ncomps; i++)
        if (u_occur(v, f1, t->t_u.schema_t->z_comp[i].z_type, f2))
      return 1;
   return 0;
     case MOLECULE:
   return u_occur(v, f1, t->t_u.molecule_t.t__mtype, t->t_u.molecule_t.t__mframe);
     case ABBREV:
   for (i = 0; i < t->t_u.abbrev_t.t__def->d_nparams; i++)
        if (u_occur(v, f1, t->t_u.abbrev_t.t__params->f_var[i], f2))
      return 1;
   return 0;
     default:
   bad_tag("u_occur", t->t_kind);
   return 0;
     }
}

variable_types:
t
struct type *

variable_types: i int


bind

decompiled_code:
__int64 __fastcall bind(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

if ( debugging && dcode[20] )
grind(stdout, "Bind: %x to %t\n", *(_QWORD *)(a2 + 24) + 8LL * *(int *)(a1 + 8), a3);
result = *(_QWORD *)(a2 + 24);
*(_QWORD *)(result + 8LL * *(int *)(a1 + 8)) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

if ( debugging && dcode[20] )
grind(stdout, "Bind: %x to %t\n", *(_QWORD *)(a2 + 24) + 8LL * *(int *)(a1 + 8), a3);
result = *(_QWORD *)(a2 + 24);
*(_QWORD *)(result + 8LL * *(int *)(a1 + 8)) = a3;
return result;
}

original_code:
static void bind(type v, frame f, type t)
{
     if ((debugging && dcode['u' - 'a']))
   (void) grind(stdout, "Bind: %x to %t\n", &f->f_var[v->t_u.typevar_t], t);
     f->f_var[v->t_u.typevar_t] = t;
}

canonical_original_code:
static void bind(struct type *v, struct frame *f, struct type *t)
{
     if ((debugging && dcode['u' - 'a']))
   (void) grind(stdout, "Bind: %x to %t\n", &f->f_var[v->t_u.typevar_t], t);
     f->f_var[v->t_u.typevar_t] = t;
}

variable_types:
f
struct frame *


original_code:
static type super_exp(type t, frame f)
{
     unpack(&t, &f, 1);
     switch (t->t_kind) {
     case GIVENT:
   return t;
     case TYPEVAR:
   if (f != param_frame)
        return seal(t, f);
   else {
        type new = new_typevar(f->f_cxt);
        bind(t, f, new);
        return new;
   }
     case POWERT:
   return mk_power(super_exp(t->t_u.base_t, f));
     case CPRODUCT: {
   type a[256];
   int i;
   if (t->t_u.cproduct_t.t__nfields > 256)
        panic("super_expand - too many fields");
   for (i = 0; i < t->t_u.cproduct_t.t__nfields; i++)
        a[i] = super_exp(t->t_u.cproduct_t.t__field[i], f);
   return mk_cproduct(t->t_u.cproduct_t.t__nfields, a);
     }
     case SPRODUCT: {
   schema s = t->t_u.schema_t;
   int n = s->z_ncomps;
   schema s1 = alloc_schema(n);
   int i;
   for (i = 0; i < n; i++) {
        s1->z_comp[i].z_name = s->z_comp[i].z_name;
        s1->z_comp[i].z_type
      = super_exp(s->z_comp[i].z_type, f);
   }
   return mk_sproduct(s1);
     }
     default:
   bad_tag("super_exp", t->t_kind);
   return ((void *)0);
     }
}

canonical_original_code:
static struct type *super_exp(struct type *t, struct frame *f)
{
     unpack(&t, &f, 1);
     switch (t->t_kind) {
     case GIVENT:
   return t;
     case TYPEVAR:
   if (f != param_frame)
        return seal(t, f);
   else {
        struct type *new = new_typevar(f->f_cxt);
        bind(t, f, new);
        return new;
   }
     case POWERT:
   return mk_power(super_exp(t->t_u.base_t, f));
     case CPRODUCT: {
   struct type *a[256];
   int i;
   if (t->t_u.cproduct_t.t__nfields > 256)
        panic("super_expand - too many fields");
   for (i = 0; i < t->t_u.cproduct_t.t__nfields; i++)
        a[i] = super_exp(t->t_u.cproduct_t.t__field[i], f);
   return mk_cproduct(t->t_u.cproduct_t.t__nfields, a);
     }
     case SPRODUCT: {
   struct schema *s = t->t_u.schema_t;
   int n = s->z_ncomps;
   struct schema *s1 = alloc_schema(n);
   int i;
   for (i = 0; i < n; i++) {
        s1->z_comp[i].z_name = s->z_comp[i].z_name;
        s1->z_comp[i].z_type
      = super_exp(s->z_comp[i].z_type, f);
   }
   return mk_sproduct(s1);
     }
     default:
   bad_tag("super_exp", t->t_kind);
   return ((void *)0);
     }
}

variable_types: struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *[256]

variable_types: struct schema { int z_ncomps; struct compnt { struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *type_d; struct schema *schema_d; } d_u; } *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *z_name; struct type *z_type; } *z_comp; } *

variable_types: n int


decompiled_code:
__int64 __fastcall super_expand(__int64 a1, __int64 a2)
{
param_frame = 0LL;
return super_exp(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
param_frame = 0LL;
return func2(a1, a2);
}

original_code:
type super_expand(type t, frame f)
{
     param_frame = ((frame) ((void *)0));
     return super_exp(t, f);
}

canonical_original_code:
struct type *super_expand(struct type *t, struct frame *f)
{
     param_frame = ((frame) ((void *)0));
     return super_exp(t, f);
}

return_type: struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *


original_code:
type type_union(type t1, frame f1, type t2, frame f2)
{
     if ((debugging && dcode['u' - 'a']))
   grind(stdout, "Union: %t and %t\n", t1, t2);
     unpack(&t1, &f1, 0);
     unpack(&t2, &f2, 0);
     if (t1 == t2 && f1 == f2)
   return seal(t1, f1);
     else if (t1 == err_type || t2 == err_type)
   return err_type;
     else if (t1->t_kind == ABBREV && t2->t_kind == ABBREV
       && t1->t_u.abbrev_t.t__def == t2->t_u.abbrev_t.t__def) {
   frame p1 = t1->t_u.abbrev_t.t__params;
   frame p2 = t2->t_u.abbrev_t.t__params;
   frame pp = mk_frame(((p1) == ((frame) ((void *)0)) ? 0 : (p1)->f_nvars));
   int i;
   for (i = 0; i < ((pp) == ((frame) ((void *)0)) ? 0 : (pp)->f_nvars); i++)
        pp->f_var[i] = type_union(p1->f_var[i], f1,
      p2->f_var[i], f2);
   return mk_abbrev(t1->t_u.abbrev_t.t__def, pp);
     }
     unpack(&t1, &f1, 1);
     unpack(&t2, &f2, 1);
     switch (t1->t_kind) {
     case GIVENT:
   return t1;
     case TYPEVAR:
   return seal(t1, f1);
     case POWERT:
   return mk_power(type_union(t1->t_u.base_t, f1,
         t2->t_u.base_t, f2));
     case CPRODUCT:
   {
        type a[32];
        int i;
        for (i = 0; i < t1->t_u.cproduct_t.t__nfields; i++)
      a[i] = type_union(t1->t_u.cproduct_t.t__field[i], f1,
          t2->t_u.cproduct_t.t__field[i], f2);
        return mk_cproduct(t1->t_u.cproduct_t.t__nfields, a);
   }
     case SPRODUCT:
   {
        schema s1 = t1->t_u.schema_t;
        schema s2 = t2->t_u.schema_t;
        int n = s1->z_ncomps;
        schema ss;
        int i;
        if (s1 == s2 && f1 == f2)
      return seal(t1, f1);
        ss = alloc_schema(n);
        for (i = 0; i < n; i++) {
      ss->z_comp[i].z_name = s1->z_comp[i].z_name;
      ss->z_comp[i].z_type
    = type_union(s1->z_comp[i].z_type, f1,
          s2->z_comp[i].z_type, f2);
        }
        return mk_sproduct(ss);
   }
     default:
   bad_tag("type_union", t1->t_kind);
   return ((void *)0);
     }
}

canonical_original_code:
struct type *type_union(struct type *t1, struct frame *f1, struct type *t2, struct frame *f2)
{
     if ((debugging && dcode['u' - 'a']))
   grind(stdout, "Union: %t and %t\n", t1, t2);
     unpack(&t1, &f1, 0);
     unpack(&t2, &f2, 0);
     if (t1 == t2 && f1 == f2)
   return seal(t1, f1);
     else if (t1 == err_type || t2 == err_type)
   return err_type;
     else if (t1->t_kind == ABBREV && t2->t_kind == ABBREV
       && t1->t_u.abbrev_t.t__def == t2->t_u.abbrev_t.t__def) {
   struct frame *p1 = t1->t_u.abbrev_t.t__params;
   struct frame *p2 = t2->t_u.abbrev_t.t__params;
   struct frame *pp = mk_frame(((p1) == ((frame) ((void *)0)) ? 0 : (p1)->f_nvars));
   int i;
   for (i = 0; i < ((pp) == ((frame) ((void *)0)) ? 0 : (pp)->f_nvars); i++)
        pp->f_var[i] = type_union(p1->f_var[i], f1,
      p2->f_var[i], f2);
   return mk_abbrev(t1->t_u.abbrev_t.t__def, pp);
     }
     unpack(&t1, &f1, 1);
     unpack(&t2, &f2, 1);
     switch (t1->t_kind) {
     case GIVENT:
   return t1;
     case TYPEVAR:
   return seal(t1, f1);
     case POWERT:
   return mk_power(type_union(t1->t_u.base_t, f1,
         t2->t_u.base_t, f2));
     case CPRODUCT:
   {
        struct type *a[32];
        int i;
        for (i = 0; i < t1->t_u.cproduct_t.t__nfields; i++)
      a[i] = type_union(t1->t_u.cproduct_t.t__field[i], f1,
          t2->t_u.cproduct_t.t__field[i], f2);
        return mk_cproduct(t1->t_u.cproduct_t.t__nfields, a);
   }
     case SPRODUCT:
   {
        struct schema *s1 = t1->t_u.schema_t;
        struct schema *s2 = t2->t_u.schema_t;
        int n = s1->z_ncomps;
        struct schema *ss;
        int i;
        if (s1 == s2 && f1 == f2)
      return seal(t1, f1);
        ss = alloc_schema(n);
        for (i = 0; i < n; i++) {
      ss->z_comp[i].z_name = s1->z_comp[i].z_name;
      ss->z_comp[i].z_type
    = type_union(s1->z_comp[i].z_type, f1,
          s2->z_comp[i].z_type, f2);
        }
        return mk_sproduct(ss);
   }
     default:
   bad_tag("type_union", t1->t_kind);
   return ((void *)0);
     }
}

variable_types: struct frame { int f_nvars; struct frame *f_next; struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *f_cxt; struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } **f_var; } *

variable_types: struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *[32]


decompiled_code:
__int64 __fastcall u_varmatch(__int64 a1, __int64 a2, _DWORD *a3, __int64 a4)
{
__int64 v7; // rdi
__int64 result; // rax
__int64 v9; // rax
int v10; // edx
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax

if ( !a2 )
panic("u_varmatch");
v7 = *(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL * *(int *)(a1 + 8));
if ( v7 )
{
result = u_match(v7, 0LL, a3, a4);
if ( (_DWORD)result )
{
result = 1LL;
if ( param_frame == a2 )
{
v9 = type_union(*(_QWORD *)(*(_QWORD *)(a2 + 24) + 8LL * *(int *)(a1 + 8)), 0LL, (__int64)a3, a4);
bind(a1, a2, v9);
result = 1LL;
}
}
}
else if ( *a3 == 1 && *(_QWORD *)(*(_QWORD *)(a4 + 24) + 8LL * (int)a3[2]) )
{
result = u_varmatch(a3, a4, a1, a2);
}
else
{
v10 = u_occur(a1, a2, (__int64)a3, a4);
result = 0LL;
if ( !v10 )
{
if ( param_frame == a2 )
{
v12 = seal(a3);
bind(a1, a2, v12);
result = 1LL;
}
else if ( *a3 == 1 && param_frame == a4 )
{
v13 = seal(a1);
bind((__int64)a3, a4, v13);
result = 1LL;
}
else
{
v11 = super_exp((__int64)a3, a4);
bind(a1, a2, v11);
result = 1LL;
}
}
}
return result;
}

original_code:
static bool u_varmatch(type t1, frame f1, type t2, frame f2)
{
     type u;
     if (f1 == ((frame) ((void *)0)))
   panic("u_varmatch");
     if ((u = f1->f_var[t1->t_u.typevar_t]) != ((void *)0)) {
   if (! u_match(u, ((frame) ((void *)0)), t2, f2))
        return 0;
   if (f1 == param_frame)
        bind(t1, f1, type_union(f1->f_var[t1->t_u.typevar_t], ((frame) ((void *)0)), t2, f2));
   return 1;
     }
     else if (t2->t_kind == TYPEVAR && f2->f_var[t2->t_u.typevar_t] != ((void *)0))
   return u_varmatch(t2, f2, t1, f1);
     else if (u_occur(t1, f1, t2, f2))
   return 0;
     else if (f1 == param_frame)
   bind(t1, f1, seal(t2, f2));
     else if (t2->t_kind == TYPEVAR && f2 == param_frame)
   bind(t2, f2, seal(t1, f1));
     else
   bind(t1, f1, super_exp(t2, f2));
     return 1;
}

canonical_original_code:
static int u_varmatch(struct type *t1, struct frame *f1, struct type *t2, struct frame *f2)
{
     struct type *u;
     if (f1 == ((frame) ((void *)0)))
   panic("u_varmatch");
     if ((u = f1->f_var[t1->t_u.typevar_t]) != ((void *)0)) {
   if (! u_match(u, ((frame) ((void *)0)), t2, f2))
        return 0;
   if (f1 == param_frame)
        bind(t1, f1, type_union(f1->f_var[t1->t_u.typevar_t], ((frame) ((void *)0)), t2, f2));
   return 1;
     }
     else if (t2->t_kind == TYPEVAR && f2->f_var[t2->t_u.typevar_t] != ((void *)0))
   return u_varmatch(t2, f2, t1, f1);
     else if (u_occur(t1, f1, t2, f2))
   return 0;
     else if (f1 == param_frame)
   bind(t1, f1, seal(t2, f2));
     else if (t2->t_kind == TYPEVAR && f2 == param_frame)
   bind(t2, f2, seal(t1, f1));
     else
   bind(t1, f1, super_exp(t2, f2));
     return 1;
}


original_code:
static bool u_match(type t1, frame f1, type t2, frame f2)
{
     schema s1, s2;
     int i;
     if ((debugging && dcode['u' - 'a']) > 1)
   grind(stdout, "Match: %t and %t\n", seal(t1, f1), seal(t2, f2));
     for (;;) {
   if (t1 == t2 && f1 == f2)
        return 1;
   else if (t1 == err_type || t2 == err_type) {
        mark_error();
        return 1;
   }
   else if (t1->t_kind == MOLECULE) {
        f1 = t1->t_u.molecule_t.t__mframe;
        t1 = t1->t_u.molecule_t.t__mtype;
   }
   else if (t2->t_kind == MOLECULE) {
        f2 = t2->t_u.molecule_t.t__mframe;
        t2 = t2->t_u.molecule_t.t__mtype;
   }
   else if (t1->t_kind == TYPEVAR)
        return u_varmatch(t1, f1, t2, f2);
   else if (t2->t_kind == TYPEVAR)
        return u_varmatch(t2, f2, t1, f1);
   else if (t1->t_kind == ABBREV && t2->t_kind == ABBREV
     && t1->t_u.abbrev_t.t__def == t2->t_u.abbrev_t.t__def) {
        for (i = 0; i < t1->t_u.abbrev_t.t__def->d_nparams; i++)
      if (! u_match(t1->t_u.abbrev_t.t__params->f_var[i], f1,
      t2->t_u.abbrev_t.t__params->f_var[i], f2))
    return 0;
        return 1;
   }
   else if (t1->t_kind == ABBREV) {
        t1 = expand(t1, f1);
        f1 = ((frame) ((void *)0));
   }
   else if (t2->t_kind == ABBREV) {
        t2 = expand(t2, f2);
        f2 = ((frame) ((void *)0));
   }
   else if (t1->t_kind != t2->t_kind)
        return 0;
   else switch (t1->t_kind) {
   case GIVENT:
        return (t1->t_u.given_t == t2->t_u.given_t);
   case POWERT:
        return u_match(t1->t_u.base_t, f1, t2->t_u.base_t, f2);
   case CPRODUCT:
        if (t1->t_u.cproduct_t.t__nfields != t2->t_u.cproduct_t.t__nfields)
      return 0;
        for (i = 0; i < t1->t_u.cproduct_t.t__nfields; i++)
      if (! u_match(t1->t_u.cproduct_t.t__field[i], f1,
      t2->t_u.cproduct_t.t__field[i], f2))
    return 0;
        return 1;
   case SPRODUCT:
        s1 = t1->t_u.schema_t; s2 = t2->t_u.schema_t;
        if (s1->z_ncomps != s2->z_ncomps)
      return 0;
        for (i = 0; i < s1->z_ncomps; i++)
      if (s1->z_comp[i].z_name != s2->z_comp[i].z_name
   || ! u_match(s1->z_comp[i].z_type, f1,
         s2->z_comp[i].z_type, f2))
    return 0;
        return 1;
   default:
        bad_tag("u_match", t1->t_kind);
        return 0;
   }
     }
}

canonical_original_code:
static int u_match(struct type *t1, struct frame *f1, struct type *t2, struct frame *f2)
{
     struct schema *s1; struct schema *s2;
     int i;
     if ((debugging && dcode['u' - 'a']) > 1)
   grind(stdout, "Match: %t and %t\n", seal(t1, f1), seal(t2, f2));
     for (;;) {
   if (t1 == t2 && f1 == f2)
        return 1;
   else if (t1 == err_type || t2 == err_type) {
        mark_error();
        return 1;
   }
   else if (t1->t_kind == MOLECULE) {
        f1 = t1->t_u.molecule_t.t__mframe;
        t1 = t1->t_u.molecule_t.t__mtype;
   }
   else if (t2->t_kind == MOLECULE) {
        f2 = t2->t_u.molecule_t.t__mframe;
        t2 = t2->t_u.molecule_t.t__mtype;
   }
   else if (t1->t_kind == TYPEVAR)
        return u_varmatch(t1, f1, t2, f2);
   else if (t2->t_kind == TYPEVAR)
        return u_varmatch(t2, f2, t1, f1);
   else if (t1->t_kind == ABBREV && t2->t_kind == ABBREV
     && t1->t_u.abbrev_t.t__def == t2->t_u.abbrev_t.t__def) {
        for (i = 0; i < t1->t_u.abbrev_t.t__def->d_nparams; i++)
      if (! u_match(t1->t_u.abbrev_t.t__params->f_var[i], f1,
      t2->t_u.abbrev_t.t__params->f_var[i], f2))
    return 0;
        return 1;
   }
   else if (t1->t_kind == ABBREV) {
        t1 = expand(t1, f1);
        f1 = ((frame) ((void *)0));
   }
   else if (t2->t_kind == ABBREV) {
        t2 = expand(t2, f2);
        f2 = ((frame) ((void *)0));
   }
   else if (t1->t_kind != t2->t_kind)
        return 0;
   else switch (t1->t_kind) {
   case GIVENT:
        return (t1->t_u.given_t == t2->t_u.given_t);
   case POWERT:
        return u_match(t1->t_u.base_t, f1, t2->t_u.base_t, f2);
   case CPRODUCT:
        if (t1->t_u.cproduct_t.t__nfields != t2->t_u.cproduct_t.t__nfields)
      return 0;
        for (i = 0; i < t1->t_u.cproduct_t.t__nfields; i++)
      if (! u_match(t1->t_u.cproduct_t.t__field[i], f1,
      t2->t_u.cproduct_t.t__field[i], f2))
    return 0;
        return 1;
   case SPRODUCT:
        s1 = t1->t_u.schema_t; s2 = t2->t_u.schema_t;
        if (s1->z_ncomps != s2->z_ncomps)
      return 0;
        for (i = 0; i < s1->z_ncomps; i++)
      if (s1->z_comp[i].z_name != s2->z_comp[i].z_name
   || ! u_match(s1->z_comp[i].z_type, f1,
         s2->z_comp[i].z_type, f2))
    return 0;
        return 1;
   default:
        bad_tag("u_match", t1->t_kind);
        return 0;
   }
     }
}


decompiled_code:
__int64 __fastcall param_unify(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v4; // ebx

if ( debugging && dcode[20] )
grind(stdout, "Unify: %t and %t\n", a1, a2);
param_frame = a3;
v4 = u_match(a1, 0LL, a2, 0LL);
if ( v4 )
return 1;
mark_error();
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v4; // ebx

if ( debugging && dcode[20] )
grind(stdout, "Unify: %t and %t\n", a1, a2);
param_frame = a3;
v4 = func6(a1, 0LL, a2, 0LL);
if ( v4 )
return 1;
mark_error();
return v4;
}

original_code:
bool param_unify(type t1, type t2, frame param)
{
     if ((debugging && dcode['u' - 'a']))
   grind(stdout, "Unify: %t and %t\n", t1, t2);
     param_frame = param;
     if (! u_match(t1, ((frame) ((void *)0)), t2, ((frame) ((void *)0)))) {
   mark_error();
   return 0;
     }
     return 1;
}

canonical_original_code:
int param_unify(struct type *t1, struct type *t2, struct frame *param)
{
     if ((debugging && dcode['u' - 'a']))
   grind(stdout, "Unify: %t and %t\n", t1, t2);
     param_frame = param;
     if (! u_match(t1, ((frame) ((void *)0)), t2, ((frame) ((void *)0)))) {
   mark_error();
   return 0;
     }
     return 1;
}

variable_types:
param
struct frame *


unify

decompiled_code:
__int64 __fastcall unify(__int64 a1, __int64 a2)
{
return param_unify(a1, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
return func7(a1, a2, 0LL);
}

original_code:
bool unify(type t1, type t2)
{
     return param_unify(t1, t2, ((frame) ((void *)0)));
}

canonical_original_code:
int unify(struct type *t1, struct type *t2)
{
     return param_unify(t1, t2, ((frame) ((void *)0)));
}

variable_types: struct type { enum kind_t { GIVENT=0, TYPEVAR=1, POWERT=2, CPRODUCT=3, SPRODUCT=4, MOLECULE=5, ABBREV=6 } t_kind; union { struct def { enum kind_d { GSET=0, VAR=1, SCHEMA=2, GENCONST=3, DATACONS=4, LETVAR=5 } d_kind; struct sym { int x_kind; struct tok { int x_kind; char *l_chars; int l_value; int l_prio; int l_toknum; char *l_pname; struct sym *l_sym; struct tok *l_link; struct tok *l_prefix; struct tok *l_root; } *s_basename; struct tok *s_decor; struct def *s_glodef; struct para { struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *p_text; int p_serial; char *p_file; enum mark { UNTOUCHED=0, BUSY=1, DONE=2 } p_flag; struct para *p_next; } *s_def; struct sym *s_link; } *d_name; int d_nparams; int d_abbrev; struct def *d_next; union { struct type *type_d; struct schema { int z_ncomps; struct compnt { struct sym *z_name; struct type *z_type; } *z_comp; } *schema_d; } d_u; } *given_t; int typevar_t; struct type *base_t; struct { int t__nfields; struct type **t__field; } cproduct_t; struct schema *schema_t; struct { struct type *t__mtype; struct frame { int f_nvars; struct frame *f_next; struct blob *f_cxt; struct type **f_var; } *t__mframe; } molecule_t; struct { struct def *t__def; struct frame *t__params; } abbrev_t; } t_u; } *