decompiled_code:
__int64 __fastcall super_exp(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rbx
int *v5; // r14
__int64 v6; // r12
__int64 v7; // r13
__int64 v8; // r12
__int64 v9; // rbx
__int64 v10; // rsi
_QWORD *v11; // rax
_QWORD *v12; // rbp
__int64 v13; // rdi
__int64 v14; // rax
__int64 v15; // [rsp+8h] [rbp-840h]
__int64 v16; // [rsp+10h] [rbp-838h] BYREF
__int64 v17; // [rsp+18h] [rbp-830h] BYREF
__int64 v18[261]; // [rsp+20h] [rbp-828h] BYREF

v17 = a1;
v16 = a2;
unpack(&v17, &v16, 1LL);
result = v17;
switch ( *(_DWORD *)v17 )
{
case 0:
return result;
case 1:
if ( v16 == param_frame )
{
v15 = new_typevar(*(_QWORD *)(v16 + 16));
bind(v17, v16, v15);
result = v15;
}
else
{
result = seal(v17);
}
break;
case 2:
v14 = super_exp(*(_QWORD *)(v17 + 8), v16);
result = mk_power(v14);
break;
case 3:
v3 = *(unsigned int *)(v17 + 8);
if ( (int)v3 > 256 )
{
panic("super_expand - too many fields");
result = v17;
v3 = *(unsigned int *)(v17 + 8);
}
if ( (int)v3 > 0 )
{
v4 = 0LL;
do
{
v18[v4] = super_exp(*(_QWORD *)(*(_QWORD *)(result + 16) + 8 * v4), v16);
result = v17;
++v4;
v3 = *(unsigned int *)(v17 + 8);
}
while ( (int)v3 > (int)v4 );
}
result = mk_cproduct(v3, v18);
break;
case 4:
v5 = *(int **)(v17 + 8);
v6 = *v5;
v7 = alloc_schema((unsigned int)*v5);
if ( (int)v6 > 0 )
{
v8 = 16 * v6;
v9 = 0LL;
do
{
v10 = v16;
v11 = (_QWORD *)(v9 + *((_QWORD *)v5 + 1));
v12 = (_QWORD *)(v9 + *(_QWORD *)(v7 + 8));
v9 += 16LL;
v13 = v11[1];
*v12 = *v11;
v12[1] = super_exp(v13, v10);
}
while ( v8 != v9 );
}
result = mk_sproduct(v7);
break;
default:
bad_tag("super_exp");
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rbx
int *v5; // r14
__int64 v6; // r12
__int64 v7; // r13
__int64 v8; // r12
__int64 v9; // rbx
__int64 v10; // rsi
_QWORD *v11; // rax
_QWORD *v12; // rbp
__int64 v13; // rdi
__int64 v14; // rax
__int64 v15; // [rsp+8h] [rbp-840h]
__int64 v16; // [rsp+10h] [rbp-838h] BYREF
__int64 v17; // [rsp+18h] [rbp-830h] BYREF
__int64 v18[261]; // [rsp+20h] [rbp-828h] BYREF

v17 = a1;
v16 = a2;
unpack(&v17, &v16, 1LL);
result = v17;
switch ( *(_DWORD *)v17 )
{
case 0:
return result;
case 1:
if ( v16 == param_frame )
{
v15 = new_typevar(*(_QWORD *)(v16 + 16));
func1(v17, v16, v15);
result = v15;
}
else
{
result = seal(v17);
}
break;
case 2:
v14 = func2(*(_QWORD *)(v17 + 8), v16);
result = mk_power(v14);
break;
case 3:
v3 = *(unsigned int *)(v17 + 8);
if ( (int)v3 > 256 )
{
panic("super_expand - too many fields");
result = v17;
v3 = *(unsigned int *)(v17 + 8);
}
if ( (int)v3 > 0 )
{
v4 = 0LL;
do
{
v18[v4] = func2(*(_QWORD *)(*(_QWORD *)(result + 16) + 8 * v4), v16);
result = v17;
++v4;
v3 = *(unsigned int *)(v17 + 8);
}
while ( (int)v3 > (int)v4 );
}
result = mk_cproduct(v3, v18);
break;
case 4:
v5 = *(int **)(v17 + 8);
v6 = *v5;
v7 = alloc_schema((unsigned int)*v5);
if ( (int)v6 > 0 )
{
v8 = 16 * v6;
v9 = 0LL;
do
{
v10 = v16;
v11 = (_QWORD *)(v9 + *((_QWORD *)v5 + 1));
v12 = (_QWORD *)(v9 + *(_QWORD *)(v7 + 8));
v9 += 16LL;
v13 = v11[1];
*v12 = *v11;
v12[1] = func2(v13, v10);
}
while ( v8 != v9 );
}
result = mk_sproduct(v7);
break;
default:
bad_tag("super_exp");
result = 0LL;
break;
}
return result;
}

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


repo: thedotcomchase/Hot-Fuzz

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

variable_types:
t
struct type *

variable_types:
f
struct frame *

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

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


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: i int

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]


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

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

return_type: int


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

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

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

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

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

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 blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; }


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

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

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


dump

decompiled_code:
int __fastcall dump(int *a1, int a2)
{
int *v2; // rbx
int v3; // edi
__int64 v5; // rsi
__int64 v6; // rdi
unsigned int v7; // er13
__int64 v8; // rbp
const char *v9; // rax
__int64 v10; // rdi

if ( !a1 )
return printf("()");
v2 = a1;
v3 = *a1;
if ( v3 == 356 )
{
printf("(REF %d ", (unsigned int)v2[2]);
dump(**((_QWORD **)v2 + 2), 0LL);
v5 = (unsigned int)(a2 + 1);
v6 = *(_QWORD *)(*((_QWORD *)v2 + 2) + 8LL);
goto LABEL_15;
}
if ( v3 > 356 )
{
if ( v3 != 358 )
{
if ( v3 != 363 )
{
LABEL_18:
v7 = v2[2];
v8 = 0LL;
v9 = (const char *)name_of_tag();
printf("(%s %d", v9, v7);
if ( v2[1] > 0 )
{
do
{
v10 = *(_QWORD *)(*((_QWORD *)v2 + 2) + 8 * v8++);
in_dump(v10, (unsigned int)(a2 + 1));
}
while ( v2[1] > (int)v8 );
}
return putchar(41);
}
printf("(LIST");
do
{
in_dump(**((_QWORD **)v2 + 2), (unsigned int)(a2 + 1));
v2 = *(int **)(*((_QWORD *)v2 + 2) + 8LL);
}
while ( v2 );
return putchar(41);
}
printf("(SREF %d ", (unsigned int)v2[2]);
dump(**((_QWORD **)v2 + 2), 0LL);
putchar(32);
dump(*(_QWORD *)(*((_QWORD *)v2 + 2) + 8LL), 0LL);
dump_list(*(_QWORD *)(*((_QWORD *)v2 + 2) + 16LL), (unsigned int)(a2 + 1));
v5 = (unsigned int)(a2 + 1);
v6 = *(_QWORD *)(*((_QWORD *)v2 + 2) + 24LL);
LABEL_15:
dump_list(v6, v5);
return putchar(41);
}
if ( v3 != 308 )
{
if ( v3 == 348 )
return printf(
"(NAME \"%s\" \"%s\")",
*(const char **)(*((_QWORD *)v2 + 1) + 8LL),
*(const char **)(*((_QWORD *)v2 + 2) + 8LL));
if ( v3 == 294 )
return printf("(NUMBER %d \"%s\")", (unsigned int)v2[2], **((const char ***)v2 + 2));
goto LABEL_18;
}
return printf("\"%s\"", *((const char **)v2 + 1));
}

original_code:
static void dump(tree t, int indent)
{
     int i; tree u;
     if (t == ((tree) ((void *)0))) {
   printf("()");
   return;
     }
     switch (t->x_kind) {
     case 363:
   printf("(LIST");
   for (u = t; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
        in_dump((u)->x_slot[0], indent+1);
   printf(")");
   break;
     case 308:
   printf("\"%s\"", ((tok) t)->l_chars);
   break;
     case 348:
   printf("(NAME \"%s\" \"%s\")",
   ((sym) t)->s_basename->l_chars,
   ((sym) t)->s_decor->l_chars);
   break;
     case 356:
   printf("(REF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   dump_list(t->x_slot[1], indent+1);
   printf(")");
   break;
     case 358:
   printf("(SREF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   printf(" ");
   dump(t->x_slot[1], 0);
   dump_list(t->x_slot[2], indent+1);
   dump_list(t->x_slot[3], indent+1);
   printf(")");
   break;
     case 294:
   printf("(NUMBER %d \"%s\")", t->x_loc, (char *) t->x_slot[0]);
   break;
     default:
   printf("(%s %d", name_of_tag(t->x_kind), t->x_loc);
   for (i = 0; i < t->x_arity; i++)
        in_dump(t->x_slot[i], indent+1);
   printf(")");
     }
}

canonical_original_code:
static void dump(struct blob *t, int indent)
{
     int i; struct blob *u;
     if (t == ((tree) ((void *)0))) {
   printf("()");
   return;
     }
     switch (t->x_kind) {
     case 363:
   printf("(LIST");
   for (u = t; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
        in_dump((u)->x_slot[0], indent+1);
   printf(")");
   break;
     case 308:
   printf("\"%s\"", ((struct tok *) t)->l_chars);
   break;
     case 348:
   printf("(NAME \"%s\" \"%s\")",
   ((struct sym *) t)->s_basename->l_chars,
   ((struct sym *) t)->s_decor->l_chars);
   break;
     case 356:
   printf("(REF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   dump_list(t->x_slot[1], indent+1);
   printf(")");
   break;
     case 358:
   printf("(SREF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   printf(" ");
   dump(t->x_slot[1], 0);
   dump_list(t->x_slot[2], indent+1);
   dump_list(t->x_slot[3], indent+1);
   printf(")");
   break;
     case 294:
   printf("(NUMBER %d \"%s\")", t->x_loc, (char *) t->x_slot[0]);
   break;
     default:
   printf("(%s %d", name_of_tag(t->x_kind), t->x_loc);
   for (i = 0; i < t->x_arity; i++)
        in_dump(t->x_slot[i], indent+1);
   printf(")");
     }
}

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

variable_types: indent int

return_type: void


decompiled_code:
int __fastcall in_dump(int *a1, int a2)
{
printf("\n%*s", 2 * a2, (const char *)&unk_2D5);
return dump(a1, a2);
}

canonical_decompiled_code:
int __fastcall func1(int *a1, int a2)
{
printf("\n%*s", 2 * a2, (const char *)&unk_2D5);
return func0(a1, a2);
}

original_code:
static void in_dump(tree t, int indent)
{
     printf("\n%*s", 2*indent, "");
     dump(t, indent);
}

canonical_original_code:
static void in_dump(struct blob *t, int indent)
{
     printf("\n%*s", 2*indent, "");
     dump(t, indent);
}


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

if ( a1 )
result = in_dump(a1, a2);
else
result = printf(" ()");
return result;
}

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

if ( a1 )
result = func1(a1, a2);
else
result = printf(" ()");
return result;
}

original_code:
static void dump_list(tree t, int indent)
{
     if (t == ((tree) ((void *)0)))
   printf(" ()");
     else
   in_dump(t, indent);
}

canonical_original_code:
static void dump_list(struct blob *t, int indent)
{
     if (t == ((tree) ((void *)0)))
   printf(" ()");
     else
   in_dump(t, indent);
}


decompiled_code:
int __fastcall dump_tree(int *a1)
{
dump(a1, 0);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func3(int *a1)
{
func0(a1, 0);
return putchar(10);
}

original_code:
void dump_tree(tree t)
{
     dump(t, 0);
     printf("\n");
}

canonical_original_code:
void dump_tree(struct blob *t)
{
     dump(t, 0);
     printf("\n");
}


decompiled_code:
__int64 parse_record()
{
char *v0; // rax
_QWORD *v1; // rax
char v2; // bl
__int64 result; // rax
_BYTE *v4; // rax
_BYTE *v5; // rdx
bool v6; // zf
char *v7; // rax
_QWORD *v8; // rax

++cursor;
v0 = (char *)get_field(":(*+-!>}");
v1 = lookup(v0);
v2 = peek;
record = (__int64)v1;
if ( peek == 58 )
{
v7 = (char *)get_field("(*+-!>}");
v8 = lookup(v7);
v2 = peek;
*(&record + 1) = (__int64)v8;
}
else
{
*(&record + 1) = 0LL;
}
if ( v2 != 40 )
{
*(&record + 2) = 0LL;
*((_DWORD *)&record + 12) = v2 == 42;
if ( v2 != 42 )
goto LABEL_5;
goto LABEL_13;
}
v4 = (_BYTE *)cursor;
*(&record + 2) = cursor;
do
{
do
{
v5 = v4++;
cursor = v4;
}
while ( *(v4 - 1) != 36 );
}
while ( *v4 != 41 );
cursor = v5 + 2;
v5[1] = 0;
get_field("*+-!>}");
v2 = peek;
v6 = peek == 42;
*((_DWORD *)&record + 12) = peek == 42;
if ( v6 )
{
LABEL_13:
get_field("+-!>}");
v2 = peek;
}
LABEL_5:
if ( strchr("+-!>", v2) )
{
*((_BYTE *)&record + 24) = v2;
*(&record + 4) = get_field("}");
}
else
{
*((_BYTE *)&record + 24) = 32;
}
++cursor;
result = get_field("}");
*(&record + 5) = result;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
char *v0; // rax
_QWORD *v1; // rax
char v2; // bl
__int64 result; // rax
_BYTE *v4; // rax
_BYTE *v5; // rdx
bool v6; // zf
char *v7; // rax
_QWORD *v8; // rax

++cursor;
v0 = (char *)get_field(":(*+-!>}");
v1 = lookup(v0);
v2 = peek;
record = (__int64)v1;
if ( peek == 58 )
{
v7 = (char *)get_field("(*+-!>}");
v8 = lookup(v7);
v2 = peek;
*(&record + 1) = (__int64)v8;
}
else
{
*(&record + 1) = 0LL;
}
if ( v2 != 40 )
{
*(&record + 2) = 0LL;
*((_DWORD *)&record + 12) = v2 == 42;
if ( v2 != 42 )
goto LABEL_5;
goto LABEL_13;
}
v4 = (_BYTE *)cursor;
*(&record + 2) = cursor;
do
{
do
{
v5 = v4++;
cursor = v4;
}
while ( *(v4 - 1) != 36 );
}
while ( *v4 != 41 );
cursor = v5 + 2;
v5[1] = 0;
get_field("*+-!>}");
v2 = peek;
v6 = peek == 42;
*((_DWORD *)&record + 12) = peek == 42;
if ( v6 )
{
LABEL_13:
get_field("+-!>}");
v2 = peek;
}
LABEL_5:
if ( strchr("+-!>", v2) )
{
*((_BYTE *)&record + 24) = v2;
*(&record + 4) = get_field("}");
}
else
{
*((_BYTE *)&record + 24) = 32;
}
++cursor;
result = get_field("}");
*(&record + 5) = result;
return result;
}

original_code:
void parse_record(void)
{
     cursor++;
     record.main = lookup(get_field(":(*+-!>}"));
     if (peek == ':')
   record.sub = lookup(get_field("(*+-!>}"));
     else
   record.sub = ((void *)0);
     if (peek != '(')
   record.symbol = ((void *)0);
     else {
   record.symbol = cursor;
   do
        cursor++;
   while (cursor[-1] != '$' || *cursor != ')');
   *cursor++ = '\0';
   get_field("*+-!>}");
     }
     record.star = (peek == '*');
     if (record.star)
   get_field("+-!>}");
     if (strchr("+-!>", peek)) {
   record.flag = peek;
   record.see_also = get_field("}");
     }
     else
   record.flag = ' ';
     cursor++;
     record.page = get_field("}");
}

canonical_original_code:
void parse_record()
{
     cursor++;
     record.main = lookup(get_field(":(*+-!>}"));
     if (peek == ':')
   record.sub = lookup(get_field("(*+-!>}"));
     else
   record.sub = ((void *)0);
     if (peek != '(')
   record.symbol = ((void *)0);
     else {
   record.symbol = cursor;
   do
        cursor++;
   while (cursor[-1] != '$' || *cursor != ')');
   *cursor++ = '\0';
   get_field("*+-!>}");
     }
     record.star = (peek == '*');
     if (record.star)
   get_field("+-!>}");
     if (strchr("+-!>", peek)) {
   record.flag = peek;
   record.see_also = get_field("}");
     }
     else
   record.flag = ' ';
     cursor++;
     record.page = get_field("}");
}


original_code:
void print_range(char *start, char *end)
{
     int j = 0;
     if (strlen(start) == strlen(end))
   while (start[j] == end[j]) j++;
     if (j > 0 && start[j+1] == '\0' && start[j-1] == '1') j--;
     if (strspn(&start[j], "0") == strlen(&start[j]))
   while (start[j] == '0') j--;
     printf(", %s--%s", start, &end[j]);
}

variable_types:
start
char *

variable_types:
end
char *

variable_types: j int


textout

decompiled_code:
int __fastcall textout(const char *a1, char *a2)
{
_BYTE *v2; // rbp
int result; // eax
int i; // edi
_BYTE *v5; // rbx
int v6; // edi

v2 = a2;
result = printf("%s ", a1);
for ( i = *a2; (_BYTE)i; i = (char)*++v2 )
{
while ( 1 )
{
v5 = v2 + 1;
if ( (_BYTE)i != 124 )
break;
printf("\\verb:");
v6 = (char)v2[1];
if ( v2[1] != 124 && (_BYTE)v6 )
{
do
{
putchar(v6);
v6 = (char)*++v5;
}
while ( (_BYTE)v6 && (_BYTE)v6 != 124 );
}
result = putchar(58);
if ( *v5 )
{
i = (char)v5[1];
v2 = v5 + 1;
if ( v5[1] )
continue;
}
return result;
}
result = putchar(i);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(const char *a1, char *a2)
{
_BYTE *v2; // rbp
int result; // eax
int i; // edi
_BYTE *v5; // rbx
int v6; // edi

v2 = a2;
result = printf("%s ", a1);
for ( i = *a2; (_BYTE)i; i = (char)*++v2 )
{
while ( 1 )
{
v5 = v2 + 1;
if ( (_BYTE)i != 124 )
break;
printf("\\verb:");
v6 = (char)v2[1];
if ( v2[1] != 124 && (_BYTE)v6 )
{
do
{
putchar(v6);
v6 = (char)*++v5;
}
while ( (_BYTE)v6 && (_BYTE)v6 != 124 );
}
result = putchar(58);
if ( *v5 )
{
i = (char)v5[1];
v2 = v5 + 1;
if ( v5[1] )
continue;
}
return result;
}
result = putchar(i);
}
return result;
}

original_code:
void textout(char *tag, char *txt)
{
     char *s;
     printf("%s ", tag);
     for (s = txt; *s != '\0'; s++) {
   if (*s != '|')
        putchar(*s);
   else {
        printf("\\verb:");
        for (s++; *s != '\0' && *s != '|'; s++)
      putchar(*s);
        putchar(':');
        if (*s == '\0') s--;
   }
     }
}

variable_types:
tag
char *

variable_types:
txt
char *

variable_types:
s
char *


initial

decompiled_code:
__int64 __fastcall initial(char *a1)
{
__int64 v1; // r12
char *v2; // rbx
const unsigned __int16 *v3; // rdx
__int64 v4; // rax
unsigned __int16 v5; // cx
char v6; // bp
__int64 result; // rax

v1 = *a1;
v2 = a1;
v3 = *_ctype_b_loc();
v4 = v1;
v5 = v3[v1];
if ( (v1 & 0xDF) != 0 )
{
while ( 1 )
{
v1 = v4;
if ( (v3[v4] & 0x400) != 0 )
return LOBYTE((*_ctype_tolower_loc())[v1]);
v6 = *++v2;
if ( (v6 & 0xDF) == 0 )
{
v1 = v6;
v5 = v3[v6];
break;
}
v4 = v6;
}
}
result = 33LL;
if ( (v5 & 0x400) != 0 )
return LOBYTE((*_ctype_tolower_loc())[v1]);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char *a1)
{
__int64 v1; // r12
char *v2; // rbx
const unsigned __int16 *v3; // rdx
__int64 v4; // rax
unsigned __int16 v5; // cx
char v6; // bp
__int64 result; // rax

v1 = *a1;
v2 = a1;
v3 = *_ctype_b_loc();
v4 = v1;
v5 = v3[v1];
if ( (v1 & 0xDF) != 0 )
{
while ( 1 )
{
v1 = v4;
if ( (v3[v4] & 0x400) != 0 )
return LOBYTE((*_ctype_tolower_loc())[v1]);
v6 = *++v2;
if ( (v6 & 0xDF) == 0 )
{
v1 = v6;
v5 = v3[v6];
break;
}
v4 = v6;
}
}
result = 33LL;
if ( (v5 & 0x400) != 0 )
return LOBYTE((*_ctype_tolower_loc())[v1]);
return result;
}

original_code:
char initial(char *s)
{
     while (*s != '\0' && *s != ' ' && !((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISalpha)) s++;
     return (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISalpha) ? tolower(*s) : '!');
}

canonical_original_code:
char initial(char *s)
{
     while (*s != '\0' && *s != ' ' && !((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISalpha)) s++;
     return (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISalpha) ? tolower(*s) : '!');
}

return_type: char


decompiled_code:
int make_index()
{
__int64 v0; // r12
__int64 v1; // rbp
char i; // r13
char v3; // al
char v4; // bl

puts("\\begin{theindex}");
if ( n_items > 0 )
{
v0 = item_table[0];
v1 = 1LL;
for ( i = initial(*(char **)item_table[0]); ; i = v4 )
{
do_item(*(_QWORD **)(v0 + 8));
if ( n_items <= (int)v1 )
break;
v0 = item_table[v1];
v3 = initial(*(char **)v0);
v4 = v3;
if ( v3 != i && i != 38 )
{
printf("\\indexspace %% %c\n", (unsigned int)v3);
v0 = item_table[v1];
}
++v1;
}
}
return puts("\\end{theindex}");
}

canonical_decompiled_code:
int func11()
{
__int64 v0; // r12
__int64 v1; // rbp
char i; // r13
char v3; // al
char v4; // bl

puts("\\begin{theindex}");
if ( n_items > 0 )
{
v0 = item_table[0];
v1 = 1LL;
for ( i = func10(*(char **)item_table[0]); ; i = v4 )
{
func9(*(_QWORD **)(v0 + 8));
if ( n_items <= (int)v1 )
break;
v0 = item_table[v1];
v3 = func10(*(char **)v0);
v4 = v3;
if ( v3 != i && i != 38 )
{
printf("\\indexspace %% %c\n", (unsigned int)v3);
v0 = item_table[v1];
}
++v1;
}
}
return puts("\\end{theindex}");
}

original_code:
void make_index(void)
{
     int i;
     char init = '&', new_init;
     printf("\\begin{theindex}\n");
     for (i = 0; i < n_items; i++) {
   new_init = initial(item_table[i]->text);
   if (new_init != init && init != '&')
        printf("\\indexspace %% %c\n", new_init);
   init = new_init;
   do_item(item_table[i]->entry);
     }
     printf("\\end{theindex}\n");
}

canonical_original_code:
void make_index()
{
     int i;
     char init = '&'; char new_init;
     printf("\\begin{theindex}\n");
     for (i = 0; i < n_items; i++) {
   new_init = initial(item_table[i]->text);
   if (new_init != init && init != '&')
        printf("\\indexspace %% %c\n", new_init);
   init = new_init;
   do_item(item_table[i]->entry);
     }
     printf("\\end{theindex}\n");
}

variable_types: init char


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
setup_and_read(argc, argv, envp);
qsort(item_table, n_items, 8uLL, (__compar_fn_t)item_compare);
make_index();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
setup_and_read(argc, argv, envp);
qsort(item_table, n_items, 8uLL, (__compar_fn_t)item_compare);
func11();
return 0;
}

original_code:
int main(int argc, char *argv[])
{
     setup_and_read(argc, argv);
     qsort(item_table, n_items, sizeof(token), (compare_fun) item_compare);
     make_index();
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     setup_and_read(argc, argv);
     qsort(item_table, n_items, sizeof(token), (int (*)(void *, void *)) item_compare);
     make_index();
     return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


panic

decompiled_code:
void __noreturn panic(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
grind(stderr, "\nPanic: ");
do_grind(stderr, a1, va);
grind(stderr, "\n");
fflush(stderr);
abort();
}

canonical_decompiled_code:
void __noreturn func0(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
grind(stderr, "\nPanic: ");
do_grind(stderr, a1, va);
grind(stderr, "\n");
fflush(stderr);
abort();
}

original_code:
void panic(char *fmt, ...)
{
     va_list a;
     grind(stderr, "\nPanic: ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
     abort();
}

canonical_original_code:
void panic(char *fmt, ...)
{
     __builtin_va_list a;
     grind(stderr, "\nPanic: ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
     abort();
}

variable_types:
fmt
char *


decompiled_code:
int tc_e_etc(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

if ( !in_error )
panic((__int64)"tc_e_etc");
grind(stderr, "> ");
va_start(va, a1);
do_grind(stderr, a1, va);
grind(stderr, "\n");
return fflush(stderr);
}

canonical_decompiled_code:
int func1(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

if ( !in_error )
func0((__int64)"tc_e_etc");
grind(stderr, "> ");
va_start(va, a1);
do_grind(stderr, a1, va);
grind(stderr, "\n");
return fflush(stderr);
}

original_code:
void tc_e_etc(char *fmt, ...)
{
     va_list a;
     if (! in_error) panic("tc_e_etc");
     grind(stderr, "> ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
}

canonical_original_code:
void tc_e_etc(char *fmt, ...)
{
     __builtin_va_list a;
     if (! in_error) panic("tc_e_etc");
     grind(stderr, "> ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
}


decompiled_code:
int tc_e_end()
{
if ( !in_error )
panic((__int64)"tc_e_end");
in_error = 0;
grind(stderr, "\n");
return fflush(stderr);
}

canonical_decompiled_code:
int func2()
{
if ( !in_error )
func0((__int64)"tc_e_end");
in_error = 0;
grind(stderr, "\n");
return fflush(stderr);
}

original_code:
void tc_e_end(void)
{
     if (! in_error) panic("tc_e_end");
     in_error = 0;
     grind(stderr, "\n");
     fflush(stderr);
}

canonical_original_code:
void tc_e_end()
{
     if (! in_error) panic("tc_e_end");
     in_error = 0;
     grind(stderr, "\n");
     fflush(stderr);
}


decompiled_code:
__int64 __fastcall report_error(int a1, unsigned int a2, const char *a3, __int64 a4)
{
struct _IO_FILE *v4; // rbp
const unsigned __int16 **v6; // rax
__int64 v7; // r14
char v9[168]; // [rsp+0h] [rbp-A8h] BYREF

if ( in_error )
panic((__int64)"report_error");
v4 = stderr;
in_error = 1;
if ( a1 != 3 )
{
++n_errors;
if ( n_errors > 99 )
{
fwrite("fuzz: too many errors - giving up\n", 1uLL, 0x22uLL, stderr);
fflush(stderr);
exit(1);
}
}
strcpy(v9, a3);
v6 = _ctype_b_loc();
v7 = v9[0];
if ( ((*v6)[v9[0]] & 0x200) != 0 )
v9[0] = (*_ctype_toupper_loc())[v7];
grind(v4, "\"%s\", line %d: ", file_name, a2);
if ( a1 == 3 )
{
grind(stderr, "Warning - ");
do_grind(stderr, v9, a4);
}
else
{
do_grind(stderr, v9, a4);
if ( a1 == 1 )
{
if ( yychar )
{
if ( yychar == 292 )
{
grind(stderr, " at \"\\\\\" or \"\\also\"");
}
else if ( *yytext )
{
grind(stderr, " at symbol \"%s\"", yytext);
}
}
else
{
grind(stderr, " at end of file");
}
}
}
return grind(stderr, "\n");
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, unsigned int a2, const char *a3, __int64 a4)
{
struct _IO_FILE *v4; // rbp
const unsigned __int16 **v6; // rax
__int64 v7; // r14
char v9[168]; // [rsp+0h] [rbp-A8h] BYREF

if ( in_error )
func0((__int64)"report_error");
v4 = stderr;
in_error = 1;
if ( a1 != 3 )
{
++n_errors;
if ( n_errors > 99 )
{
fwrite("fuzz: too many errors - giving up\n", 1uLL, 0x22uLL, stderr);
fflush(stderr);
exit(1);
}
}
strcpy(v9, a3);
v6 = _ctype_b_loc();
v7 = v9[0];
if ( ((*v6)[v9[0]] & 0x200) != 0 )
v9[0] = (*_ctype_toupper_loc())[v7];
grind(v4, "\"%s\", line %d: ", file_name, a2);
if ( a1 == 3 )
{
grind(stderr, "Warning - ");
do_grind(stderr, v9, a4);
}
else
{
do_grind(stderr, v9, a4);
if ( a1 == 1 )
{
if ( yychar )
{
if ( yychar == 292 )
{
grind(stderr, " at \"\\\\\" or \"\\also\"");
}
else if ( *yytext )
{
grind(stderr, " at symbol \"%s\"", yytext);
}
}
else
{
grind(stderr, " at end of file");
}
}
}
return grind(stderr, "\n");
}

original_code:
static void report_error(int kind, int line, char *fmt, va_list *a)
{
     char buf[128];
     if (in_error) panic("report_error");
     in_error = 1;
     if (kind != 3 && ++n_errors >= 100) {
   fprintf(stderr, "fuzz: too many errors - giving up\n");
   fflush(stderr);
   exit(1);
     }
     strcpy(buf, fmt);
     if (((*__ctype_b_loc ())[(int) ((buf[0]))] & (unsigned short int) _ISlower))
   buf[0] = toupper(buf[0]);
     grind(stderr, "\"%s\", line %d: ", file_name, line);
     if (kind == 3)
          grind(stderr, "Warning - ");
     do_grind(stderr, buf, a);
     if (kind == 1) {
          if (yychar == 0)
               grind(stderr, " at end of file");
          else if (yychar == 292)
               grind(stderr, " at \"\\\\\" or \"\\also\"");
          else if (yytext[0] != '\0')
          grind(stderr, " at symbol \"%s\"", yytext);
     }
     grind(stderr, "\n");
}

canonical_original_code:
static void report_error(int kind, int line, char *fmt, __builtin_va_list *a)
{
     char buf[128];
     if (in_error) panic("report_error");
     in_error = 1;
     if (kind != 3 && ++n_errors >= 100) {
   fprintf(stderr, "fuzz: too many errors - giving up\n");
   fflush(stderr);
   exit(1);
     }
     strcpy(buf, fmt);
     if (((*__ctype_b_loc ())[(int) ((buf[0]))] & (unsigned short) _ISlower))
   buf[0] = toupper(buf[0]);
     grind(stderr, "\"%s\", line %d: ", file_name, line);
     if (kind == 3)
          grind(stderr, "Warning - ");
     do_grind(stderr, buf, a);
     if (kind == 1) {
          if (yychar == 0)
               grind(stderr, " at end of file");
          else if (yychar == 292)
               grind(stderr, " at \"\\\\\" or \"\\also\"");
          else if (yytext[0] != '\0')
          grind(stderr, " at symbol \"%s\"", yytext);
     }
     grind(stderr, "\n");
}

variable_types: kind int

variable_types: line int

variable_types:
a
__builtin_va_list *

variable_types:
buf
char [128]


yyerror

decompiled_code:
int yyerror(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
report_error(1, yylloc, a1, (__int64)va);
return tc_e_end();
}

canonical_decompiled_code:
int func4(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func3(1, yylloc, a1, (__int64)va);
return func2();
}

original_code:
void yyerror(char *fmt, ...)
{
     va_list a;
     extern YYLTYPE yylloc;
     __builtin_va_start(a,fmt);
     report_error(1, yylloc.first_line, fmt, &a);
     __builtin_va_end(a);
     tc_e_end();
}

canonical_original_code:
void yyerror(char *fmt, ...)
{
     __builtin_va_list a;
     extern struct YYLTYPE yylloc;
     __builtin_va_start(a,fmt);
     report_error(1, yylloc.first_line, fmt, &a);
     __builtin_va_end(a);
     tc_e_end();
}

variable_types: struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; }


decompiled_code:
__int64 tc_error(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return report_error(2, a1, a2, (__int64)va);
}

canonical_decompiled_code:
__int64 func5(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return func3(2, a1, a2, (__int64)va);
}

original_code:
void tc_error(int loc, char *fmt, ...)
{
     va_list a;
     __builtin_va_start(a,fmt);
     report_error(2, loc, fmt, &a);
     __builtin_va_end(a);
}

canonical_original_code:
void tc_error(int loc, char *fmt, ...)
{
     __builtin_va_list a;
     __builtin_va_start(a,fmt);
     report_error(2, loc, fmt, &a);
     __builtin_va_end(a);
}

variable_types: loc int


decompiled_code:
__int64 tc_warn(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return report_error(3, a1, a2, (__int64)va);
}

canonical_decompiled_code:
__int64 func6(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return func3(3, a1, a2, (__int64)va);
}

original_code:
void tc_warn(int loc, char *fmt, ...)
{
     va_list a;
     __builtin_va_start(a,fmt);
     report_error(3, loc, fmt, &a);
     __builtin_va_end(a);
}

canonical_original_code:
void tc_warn(int loc, char *fmt, ...)
{
     __builtin_va_list a;
     __builtin_va_start(a,fmt);
     report_error(3, loc, fmt, &a);
     __builtin_va_end(a);
}


decompiled_code:
void __fastcall __noreturn bad_tag(const char *a1, __int64 a2)
{
panic((__int64)"bad tag %d in %s", a2, a1);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(const char *a1, __int64 a2)
{
func0((__int64)"bad tag %d in %s", a2, a1);
}

original_code:
void bad_tag(char *s, int v)
{
     panic("bad tag %d in %s", v, s);
}

variable_types: v int


decompiled_code:
void __noreturn debug_help()
{
fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
fprintf(stderr, "%s\n", " Lisp dump, Prelude, Scribble on freed storage,");
fprintf(stderr, "%s\n", " Type storage, Unification, Version, Yacc parser");
exit(2);
}

canonical_decompiled_code:
void __noreturn func0()
{
fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
fprintf(stderr, "%s\n", " Lisp dump, Prelude, Scribble on freed storage,");
fprintf(stderr, "%s\n", " Type storage, Unification, Version, Yacc parser");
exit(2);
}

original_code:
static void debug_help(void)
{
     (void) fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
     (void) fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
     (void) fprintf(stderr, "%s\n", "       Lisp dump, Prelude, Scribble on freed storage,");
     (void) fprintf(stderr, "%s\n", "       Type storage, Unification, Version, Yacc parser");
     exit(2);
}

canonical_original_code:
static void debug_help()
{
     (void) fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
     (void) fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
     (void) fprintf(stderr, "%s\n", "       Lisp dump, Prelude, Scribble on freed storage,");
     (void) fprintf(stderr, "%s\n", "       Type storage, Unification, Version, Yacc parser");
     exit(2);
}


decompiled_code:
__int64 __fastcall do_flags(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // er14
__int64 v4; // r13
unsigned __int8 *v5; // rdx
char v6; // bp
char *v7; // rax
int v8; // ebx
_BYTE *v9; // r12
const unsigned __int16 *v10; // rdx

result = *(unsigned __int8 *)(a1 + 1);
v3 = argc;
v4 = argv;
if ( (_BYTE)result )
{
v5 = (unsigned __int8 *)(a1 + 1);
v6 = 0;
while ( 2 )
{
result = (unsigned __int8)(result - 68);
switch ( (char)result )
{
case 0:
v8 = (char)v5[1];
v9 = v5 + 1;
if ( v5[1] )
{
v10 = *_ctype_b_loc();
do
{
result = (char)v8;
if ( (v10[(char)v8] & 0x200) == 0 )
{
if ( v6 )
{
argc = v3;
argv = v4;
}
debug_help();
}
++v9;
++dcode[v8 - 97];
v8 = (char)*v9;
}
while ( *v9 );
}
goto LABEL_6;
case 29:
++aflag;
result = *++v5;
goto LABEL_5;
case 32:
++dflag;
result = *++v5;
goto LABEL_5;
case 37:
++iflag;
result = *++v5;
goto LABEL_5;
case 40:
++lflag;
result = *++v5;
goto LABEL_5;
case 44:
if ( !--v3 )
{
argc = 0;
if ( v6 )
argv = v4;
LABEL_25:
usage(a1, a2, v5);
}
v7 = *(char **)(v4 + 8);
++pflag;
++v5;
v4 += 8LL;
v6 = 1;
prelude = v7;
result = *v5;
LABEL_5:
if ( (_BYTE)result )
continue;
LABEL_6:
if ( v6 )
{
argc = v3;
argv = v4;
}
break;
case 45:
++qflag;
result = *++v5;
goto LABEL_5;
case 47:
++sflag;
result = *++v5;
goto LABEL_5;
case 48:
++tflag;
result = *++v5;
goto LABEL_5;
case 50:
++vflag;
result = *++v5;
goto LABEL_5;
default:
if ( v6 )
{
argc = v3;
argv = v4;
}
goto LABEL_25;
}
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // er14
__int64 v4; // r13
unsigned __int8 *v5; // rdx
char v6; // bp
char *v7; // rax
int v8; // ebx
_BYTE *v9; // r12
const unsigned __int16 *v10; // rdx

result = *(unsigned __int8 *)(a1 + 1);
v3 = argc;
v4 = argv;
if ( (_BYTE)result )
{
v5 = (unsigned __int8 *)(a1 + 1);
v6 = 0;
while ( 2 )
{
result = (unsigned __int8)(result - 68);
switch ( (char)result )
{
case 0:
v8 = (char)v5[1];
v9 = v5 + 1;
if ( v5[1] )
{
v10 = *_ctype_b_loc();
do
{
result = (char)v8;
if ( (v10[(char)v8] & 0x200) == 0 )
{
if ( v6 )
{
argc = v3;
argv = v4;
}
func0();
}
++v9;
++dcode[v8 - 97];
v8 = (char)*v9;
}
while ( *v9 );
}
goto LABEL_6;
case 29:
++aflag;
result = *++v5;
goto LABEL_5;
case 32:
++dflag;
result = *++v5;
goto LABEL_5;
case 37:
++iflag;
result = *++v5;
goto LABEL_5;
case 40:
++lflag;
result = *++v5;
goto LABEL_5;
case 44:
if ( !--v3 )
{
argc = 0;
if ( v6 )
argv = v4;
LABEL_25:
func1(a1, a2, v5);
}
v7 = *(char **)(v4 + 8);
++pflag;
++v5;
v4 += 8LL;
v6 = 1;
prelude = v7;
result = *v5;
LABEL_5:
if ( (_BYTE)result )
continue;
LABEL_6:
if ( v6 )
{
argc = v3;
argv = v4;
}
break;
case 45:
++qflag;
result = *++v5;
goto LABEL_5;
case 47:
++sflag;
result = *++v5;
goto LABEL_5;
case 48:
++tflag;
result = *++v5;
goto LABEL_5;
case 50:
++vflag;
result = *++v5;
goto LABEL_5;
default:
if ( v6 )
{
argc = v3;
argv = v4;
}
goto LABEL_25;
}
break;
}
}
return result;
}

original_code:
static void do_flags(char *flags)
{
     char *s;
     for (s = flags+1; *s != '\0'; s++)
          switch (*s) {
          case 'a': aflag++; break;
   case 'd': dflag++; break;
   case 'l': lflag++; break;
          case 'q': qflag++; break;
          case 's': sflag++; break;
          case 't': tflag++; break;
          case 'v': vflag++; break;
          case 'i': iflag++; break;
          case 'p':
               if (--argc == 0) usage();
               pflag++;
               prelude = *++argv;
               break;
          case 'D':
               for (s++; *s != '\0'; s++)
                    if (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISlower))
                         dcode[*s - 'a']++;
                    else
                         debug_help();
               s--;
               break;
          default: usage();
          }
}

canonical_original_code:
static void do_flags(char *flags)
{
     char *s;
     for (s = flags+1; *s != '\0'; s++)
          switch (*s) {
          case 'a': aflag++; break;
   case 'd': dflag++; break;
   case 'l': lflag++; break;
          case 'q': qflag++; break;
          case 's': sflag++; break;
          case 't': tflag++; break;
          case 'v': vflag++; break;
          case 'i': iflag++; break;
          case 'p':
               if (--argc == 0) usage();
               pflag++;
               prelude = *++argv;
               break;
          case 'D':
               for (s++; *s != '\0'; s++)
                    if (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISlower))
                         dcode[*s - 'a']++;
                    else
                         debug_help();
               s--;
               break;
          default: usage();
          }
}

variable_types:
flags
char *


decompiled_code:
char *__fastcall perm_copy(char *src)
{
int v1; // eax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)perm_alloc((unsigned int)(v1 + 1));
return strcpy(v2, src);
}

canonical_decompiled_code:
char *__fastcall func3(char *src)
{
int v1; // eax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)perm_alloc((unsigned int)(v1 + 1));
return strcpy(v2, src);
}

original_code:
static char *perm_copy(char *s)
{
     char *t = (char *) perm_alloc(strlen(s)+1);
     strcpy(t, s);
     return t;
}

variable_types:
t
char *

return_type: char *


decompiled_code:
char *open_prelude()
{
char *v0; // rbp
char *result; // rax

if ( (pflag || (v0 = getenv(envname)) == 0LL) && (v0 = prelude) == 0LL || (yyin = fopen(v0, "r")) == 0LL )
{
fprintf(stderr, "fuzz: can't read prelude file %s\n", v0);
exit(2);
}
result = perm_copy(v0);
file_name = (__int64)result;
return result;
}

canonical_decompiled_code:
char *func4()
{
char *v0; // rbp
char *result; // rax

if ( (pflag || (v0 = getenv(envname)) == 0LL) && (v0 = prelude) == 0LL || (yyin = fopen(v0, "r")) == 0LL )
{
fprintf(stderr, "fuzz: can't read prelude file %s\n", v0);
exit(2);
}
result = func3(v0);
file_name = (__int64)result;
return result;
}

original_code:
static void open_prelude(void)
{
     char *fn;
     extern char *envname;
     extern char *getenv();
     if (pflag)
   fn = prelude;
     else {
   fn = getenv(envname);
   if (fn == ((void *)0)) {
        fn = prelude;
   }
     }
     if (fn == ((void *)0) || (yyin = fopen(fn, "r")) == ((void *)0)) {
   (void) fprintf(stderr, "fuzz: can't read prelude file %s\n", fn);
   exit(2);
     }
     file_name = perm_copy(fn);
}

canonical_original_code:
static void open_prelude()
{
     char *fn;
     extern char *envname;
     extern char *getenv();
     if (pflag)
   fn = prelude;
     else {
   fn = getenv(envname);
   if (fn == ((void *)0)) {
        fn = prelude;
   }
     }
     if (fn == ((void *)0) || (yyin = fopen(fn, "r")) == ((void *)0)) {
   (void) fprintf(stderr, "fuzz: can't read prelude file %s\n", fn);
   exit(2);
     }
     file_name = perm_copy(fn);
}

variable_types:
fn
char *

variable_types:
envname
char *

variable_types:
getenv
char *()


decompiled_code:
__int64 read_a_file()
{
int v0; // eax

line_count = 1;
v0 = debugging;
yylloc = 1;
if ( debugging )
v0 = dcode[24] != 0;
yydebug = v0;
return yyparse();
}

canonical_decompiled_code:
__int64 func6()
{
int v0; // eax

line_count = 1;
v0 = debugging;
yylloc = 1;
if ( debugging )
v0 = dcode[24] != 0;
yydebug = v0;
return yyparse();
}

original_code:
static void read_a_file(void)
{
     yylloc = line_count = 1;
     yydebug = (debugging && dcode['y' - 'a']);
     yyparse();
}

canonical_original_code:
static void read_a_file()
{
     yylloc = line_count = 1;
     yydebug = (debugging && dcode['y' - 'a']);
     yyparse();
}


usage

decompiled_code:
void __noreturn usage()
{
fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
fprintf(stderr, "%s\n", "Flags: -a Don't use type abbreviations");
fprintf(stderr, "%s\n", " -d Allow use before definition");
fprintf(stderr, "%s\n", " -l Lisp-style echoing of input");
fprintf(stderr, "%s\n", " -p file Use <file> in place of standard prelude");
fprintf(stderr, "%s\n", " -q Assume quantifiers for undeclared variables");
fprintf(stderr, "%s\n", " -s Syntax check only");
fprintf(stderr, "%s\n", " -t Report types of global definitions");
fprintf(stderr, "%s\n", " -v Echo input as it is parsed");
exit(2);
}

canonical_decompiled_code:
void __noreturn func1()
{
fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
fprintf(stderr, "%s\n", "Flags: -a Don't use type abbreviations");
fprintf(stderr, "%s\n", " -d Allow use before definition");
fprintf(stderr, "%s\n", " -l Lisp-style echoing of input");
fprintf(stderr, "%s\n", " -p file Use <file> in place of standard prelude");
fprintf(stderr, "%s\n", " -q Assume quantifiers for undeclared variables");
fprintf(stderr, "%s\n", " -s Syntax check only");
fprintf(stderr, "%s\n", " -t Report types of global definitions");
fprintf(stderr, "%s\n", " -v Echo input as it is parsed");
exit(2);
}

original_code:
static void usage(void)
{
     (void) fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
     (void) fprintf(stderr, "%s\n", "Flags: -a       Don't use type abbreviations");
     (void) fprintf(stderr, "%s\n", "       -d       Allow use before definition");
     (void) fprintf(stderr, "%s\n", "       -l       Lisp-style echoing of input");
     (void) fprintf(stderr, "%s\n", "       -p file  Use <file> in place of standard prelude");
     (void) fprintf(stderr, "%s\n", "       -q       Assume quantifiers for undeclared variables");
     (void) fprintf(stderr, "%s\n", "       -s       Syntax check only");
     (void) fprintf(stderr, "%s\n", "       -t       Report types of global definitions");
     (void) fprintf(stderr, "%s\n", "       -v       Echo input as it is parsed");
     exit(2);
}

canonical_original_code:
static void usage()
{
     (void) fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
     (void) fprintf(stderr, "%s\n", "Flags: -a       Don't use type abbreviations");
     (void) fprintf(stderr, "%s\n", "       -d       Allow use before definition");
     (void) fprintf(stderr, "%s\n", "       -l       Lisp-style echoing of input");
     (void) fprintf(stderr, "%s\n", "       -p file  Use <file> in place of standard prelude");
     (void) fprintf(stderr, "%s\n", "       -q       Assume quantifiers for undeclared variables");
     (void) fprintf(stderr, "%s\n", "       -s       Syntax check only");
     (void) fprintf(stderr, "%s\n", "       -t       Report types of global definitions");
     (void) fprintf(stderr, "%s\n", "       -v       Echo input as it is parsed");
     exit(2);
}


main

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
char **v4; // rbp
__int64 v5; // rbx
char *v6; // rdi

v3 = argc - 1;
::argv = (__int64)argv;
::argc = argc - 1;
if ( argc - 1 > 0 )
{
while ( 1 )
{
*(_QWORD *)&argc = argv[1];
::argv = (__int64)(argv + 1);
if ( **(_BYTE **)&argc != 45 )
break;
do_flags(*(__int64 *)&argc, (__int64)argv);
v3 = ::argc - 1;
::argc = v3;
if ( v3 <= 0 )
break;
argv = (const char **)::argv;
}
}
v4 = (char **)::argv;
if ( dcode[21] )
{
argv = (const char **)"%s\n%s\n%s\n";
fprintf(stderr, "%s\n%s\n%s\n", fuzz_banner, fuzz_rcsid, fuzz_copyright);
*(_QWORD *)&argc = stderr;
fflush(stderr);
}
debugging = dcode[15];
init_sym(*(_QWORD *)&argc, argv, envp);
init_type();
init_dict();
open_prelude();
read_a_file();
if ( dflag )
{
check_file();
clear_temp(0LL);
}
debugging = 1;
if ( v3 )
{
if ( v3 > 0 )
{
v5 = (__int64)&v4[(unsigned int)(v3 - 1) + 1];
do
{
v6 = *v4++;
reopen_input(v6);
yyrestart(yyin);
read_a_file();
}
while ( v4 != (char **)v5 );
}
}
else
{
file_name = (__int64)"standard input";
yyrestart(stdin);
read_a_file();
}
if ( dflag )
{
check_file();
clear_temp(0LL);
}
if ( dcode[7] )
dump_hash();
return n_errors > 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
char **v4; // rbp
__int64 v5; // rbx
char *v6; // rdi

v3 = argc - 1;
::argv = (__int64)argv;
::argc = argc - 1;
if ( argc - 1 > 0 )
{
while ( 1 )
{
*(_QWORD *)&argc = argv[1];
::argv = (__int64)(argv + 1);
if ( **(_BYTE **)&argc != 45 )
break;
func2(*(__int64 *)&argc, (__int64)argv);
v3 = ::argc - 1;
::argc = v3;
if ( v3 <= 0 )
break;
argv = (const char **)::argv;
}
}
v4 = (char **)::argv;
if ( dcode[21] )
{
argv = (const char **)"%s\n%s\n%s\n";
fprintf(stderr, "%s\n%s\n%s\n", fuzz_banner, fuzz_rcsid, fuzz_copyright);
*(_QWORD *)&argc = stderr;
fflush(stderr);
}
debugging = dcode[15];
init_sym(*(_QWORD *)&argc, argv, envp);
init_type();
init_dict();
func4();
func6();
if ( dflag )
{
check_file();
clear_temp(0LL);
}
debugging = 1;
if ( v3 )
{
if ( v3 > 0 )
{
v5 = (__int64)&v4[(unsigned int)(v3 - 1) + 1];
do
{
v6 = *v4++;
func5(v6);
yyrestart(yyin);
func6();
}
while ( v4 != (char **)v5 );
}
}
else
{
file_name = (__int64)"standard input";
yyrestart(stdin);
func6();
}
if ( dflag )
{
check_file();
clear_temp(0LL);
}
if ( dcode[7] )
dump_hash();
return n_errors > 0;
}

original_code:
int main(int ac, char **av)
{
     int i, n_files;
     char **files;
     argc = ac; argv = av;
     while (--argc > 0 && (*++argv)[0] == '-')
          do_flags(*argv);
     files = argv;
     n_files = argc;
     if (dcode['v' - 'a']) {
   fprintf(stderr, "%s\n%s\n%s\n",
    fuzz_banner, fuzz_rcsid, fuzz_copyright);
   fflush(stderr);
     }
     debugging = dcode['p' - 'a'];
     init_sym();
     init_type();
     init_dict();
     open_prelude();
     read_a_file();
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     debugging = 1;
     if (n_files == 0) {
   file_name = "standard input";
   yyrestart(stdin);
   read_a_file();
     }
     else {
   for (i = 0; i < n_files; i++) {
        reopen_input(files[i]);
        yyrestart(yyin);
        read_a_file();
   }
     }
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     if (dcode['h' - 'a'])
   dump_hash();
     return (n_errors > 0 ? 1 : 0);
}

canonical_original_code:
int main(int ac, char **av)
{
     int i; int n_files;
     char **files;
     argc = ac; argv = av;
     while (--argc > 0 && (*++argv)[0] == '-')
          do_flags(*argv);
     files = argv;
     n_files = argc;
     if (dcode['v' - 'a']) {
   fprintf(stderr, "%s\n%s\n%s\n",
    fuzz_banner, fuzz_rcsid, fuzz_copyright);
   fflush(stderr);
     }
     debugging = dcode['p' - 'a'];
     init_sym();
     init_type();
     init_dict();
     open_prelude();
     read_a_file();
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     debugging = 1;
     if (n_files == 0) {
   file_name = "standard input";
   yyrestart(stdin);
   read_a_file();
     }
     else {
   for (i = 0; i < n_files; i++) {
        reopen_input(files[i]);
        yyrestart(yyin);
        read_a_file();
   }
     }
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     if (dcode['h' - 'a'])
   dump_hash();
     return (n_errors > 0 ? 1 : 0);
}

variable_types: ac int

variable_types:
av
char **

variable_types: i int

variable_types:
files
char **


decompiled_code:
void check_current_addr()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void check_current_addr(uassembler* uasm)
{
}

canonical_original_code:
void check_current_addr(struct uassembler *uasm)
{
}

variable_types: struct uassembler { struct bin_table { struct bin_table_collumn_description { char *name; int width; int active_high; int index; } *collumn_descriptions; struct bin_table_cell { unsigned int value; unsigned int is_known; } *cells; int collumns; int rows; int print_on_error; int exit_on_error; } table; char *next_addr_collumn_name; char *nextsel_collumn_name; int rom_addr_with; int opcode_width; int addr_fetch; int addr_free; int addr_reset; struct addresses4_t { int addresses[4]; int len; } current_addresses; int current_at_op_entry; } *

user_defined_types: struct uassembler { struct bin_table table; char *next_addr_collumn_name; char *nextsel_collumn_name; int rom_addr_with; int opcode_width; int addr_fetch; int addr_free; int addr_reset; struct addresses4_t current_addresses; int current_at_op_entry; }

user_defined_types: struct bin_table { struct bin_table_collumn_description *collumn_descriptions; struct bin_table_cell *cells; int collumns; int rows; int print_on_error; int exit_on_error; }


decompiled_code:
__int64 __fastcall set_field(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
unsigned int v5; // er12
__int64 v6; // rbp
__int64 v7; // rdx

result = bin_table_collumn_by_name();
if ( *(int *)(a1 + 84) > 0 )
{
v5 = result;
v6 = 0LL;
do
{
v7 = *(unsigned int *)(a1 + 4 * v6++ + 68);
result = bin_table_set_cell_value(a1, v5, v7, a3);
}
while ( *(_DWORD *)(a1 + 84) > (int)v6 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
unsigned int v5; // er12
__int64 v6; // rbp
__int64 v7; // rdx

result = bin_table_collumn_by_name();
if ( *(int *)(a1 + 84) > 0 )
{
v5 = result;
v6 = 0LL;
do
{
v7 = *(unsigned int *)(a1 + 4 * v6++ + 68);
result = bin_table_set_cell_value(a1, v5, v7, a3);
}
while ( *(_DWORD *)(a1 + 84) > (int)v6 );
}
return result;
}

original_code:
void set_field(uassembler* uasm, const char* field_name, int value)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 int n = 0;
 for(n = 0; n < uasm->current_addresses.len; ++n)
 {
  bin_table_set_cell_value(&(uasm->table), field_index,
    uasm->current_addresses.addresses[n], value);
 }
}

canonical_original_code:
void set_field(struct uassembler *uasm, char *field_name, int value)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 int n = 0;
 for(n = 0; n < uasm->current_addresses.len; ++n)
 {
  bin_table_set_cell_value(&(uasm->table), field_index,
    uasm->current_addresses.addresses[n], value);
 }
}

variable_types: value int

variable_types: n int

user_defined_types: struct addresses4_t { int addresses[4]; int len; }

user_defined_types: struct bin_table_collumn_description { char *name; int width; int active_high; int index; }

user_defined_types: struct bin_table_cell { unsigned int value; unsigned int is_known; }


decompiled_code:
__int64 __fastcall assert_signal(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax

v2 = *a1 + 24LL * (int)bin_table_collumn_by_name();
if ( *(_DWORD *)(v2 + 8) != 1 )
{
fwrite("error: want to assert signal with width not equal to 1\n", 1uLL, 0x37uLL, stderr);
print_state((__int64)a1, stderr);
exit(1);
}
return set_field((__int64)a1, a2, *(_DWORD *)(v2 + 12) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax

v2 = *a1 + 24LL * (int)bin_table_collumn_by_name();
if ( *(_DWORD *)(v2 + 8) != 1 )
{
fwrite("error: want to assert signal with width not equal to 1\n", 1uLL, 0x37uLL, stderr);
func0((__int64)a1, stderr);
exit(1);
}
return func2((__int64)a1, a2, *(_DWORD *)(v2 + 12) != 0);
}

original_code:
void assert_signal(uassembler* uasm, const char* field_name)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 if(uasm->table.collumn_descriptions[field_index].width != 1)
 {
  fprintf(stderr, "error: want to assert signal with width not equal to 1\n");
  print_state(uasm, stderr);
  exit(1);
 }
 int value = uasm->table.collumn_descriptions[field_index].active_high ? 1 : 0;
 set_field(uasm, field_name, value);
}

canonical_original_code:
void assert_signal(struct uassembler *uasm, char *field_name)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 if(uasm->table.collumn_descriptions[field_index].width != 1)
 {
  fprintf(stderr, "error: want to assert signal with width not equal to 1\n");
  print_state(uasm, stderr);
  exit(1);
 }
 int value = uasm->table.collumn_descriptions[field_index].active_high ? 1 : 0;
 set_field(uasm, field_name, value);
}


original_code:
void set_default(uassembler* uasm)
{
 check_current_addr(uasm);
 int n;
 for(n = 0; n < uasm->table.collumns; n++)
 {
  if(uasm->table.collumn_descriptions[n].active_high)
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name ,0);
  }
  else
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name , (1 << uasm->table.collumn_descriptions[n].width) - 1);
  }
 }
}

canonical_original_code:
void set_default(struct uassembler *uasm)
{
 check_current_addr(uasm);
 int n;
 for(n = 0; n < uasm->table.collumns; n++)
 {
  if(uasm->table.collumn_descriptions[n].active_high)
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name ,0);
  }
  else
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name , (1 << uasm->table.collumn_descriptions[n].width) - 1);
  }
 }
}


decompiled_code:
__int64 __fastcall set_next_hardcoded(__int64 a1, unsigned int a2)
{
set_field(a1, *(_QWORD *)(a1 + 40), 0);
return set_field(a1, *(_QWORD *)(a1 + 32), a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int a2)
{
func2(a1, *(_QWORD *)(a1 + 40), 0);
return func2(a1, *(_QWORD *)(a1 + 32), a2);
}

original_code:
void set_next_hardcoded(uassembler* uasm, int addr)
{
 set_field(uasm, uasm->nextsel_collumn_name, 0);
 set_field(uasm, uasm->next_addr_collumn_name, addr);
}

canonical_original_code:
void set_next_hardcoded(struct uassembler *uasm, int addr)
{
 set_field(uasm, uasm->nextsel_collumn_name, 0);
 set_field(uasm, uasm->next_addr_collumn_name, addr);
}

variable_types: addr int


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

if ( a2 == 2 )
return set_field(a1, *(_QWORD *)(a1 + 40), 1u);
if ( a2 > 2 )
{
if ( a2 != 3 )
{
fwrite("error: unkown next_sel\n", 1uLL, 0x17uLL, stderr);
print_state(a1, stderr);
exit(1);
}
result = *(unsigned int *)(a1 + 84);
if ( (int)result > 0 )
result = set_next_hardcoded(a1, *(_DWORD *)(a1 + 68));
}
else if ( a2 )
{
result = set_next_hardcoded(a1, *(_DWORD *)(a1 + 60));
}
else
{
result = set_next_hardcoded(a1, *(_DWORD *)(a1 + 56));
}
return result;
}

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

if ( a2 == 2 )
return func2(a1, *(_QWORD *)(a1 + 40), 1u);
if ( a2 > 2 )
{
if ( a2 != 3 )
{
fwrite("error: unkown next_sel\n", 1uLL, 0x17uLL, stderr);
func0(a1, stderr);
exit(1);
}
result = *(unsigned int *)(a1 + 84);
if ( (int)result > 0 )
result = func5(a1, *(_DWORD *)(a1 + 68));
}
else if ( a2 )
{
result = func5(a1, *(_DWORD *)(a1 + 60));
}
else
{
result = func5(a1, *(_DWORD *)(a1 + 56));
}
return result;
}

original_code:
void set_next(uassembler* uasm, next_sel nxt)
{
 check_current_addr(uasm);
 switch(nxt)
 {
  case next_sel_fetch:
   set_next_hardcoded(uasm, uasm->addr_fetch);
  break;
  case next_sel_next_free:
   set_next_hardcoded(uasm, uasm->addr_free);
  break;
  case next_sel_op_entry:
   set_field(uasm, uasm->nextsel_collumn_name, 1);
  break;
  case next_sel_current: {
   if(uasm->current_addresses.len > 0) {
    set_next_hardcoded(uasm, uasm->current_addresses.addresses[0]);
   }
  }
  break;
  default:
   fprintf(stderr, "error: unkown next_sel\n");
   print_state(uasm, stderr);
   exit(1);
  break;
 }
}

canonical_original_code:
void set_next(struct uassembler *uasm, enum next_sel nxt)
{
 check_current_addr(uasm);
 switch(nxt)
 {
  case next_sel_fetch:
   set_next_hardcoded(uasm, uasm->addr_fetch);
  break;
  case next_sel_next_free:
   set_next_hardcoded(uasm, uasm->addr_free);
  break;
  case next_sel_op_entry:
   set_field(uasm, uasm->nextsel_collumn_name, 1);
  break;
  case next_sel_current: {
   if(uasm->current_addresses.len > 0) {
    set_next_hardcoded(uasm, uasm->current_addresses.addresses[0]);
   }
  }
  break;
  default:
   fprintf(stderr, "error: unkown next_sel\n");
   print_state(uasm, stderr);
   exit(1);
  break;
 }
}

variable_types: enum next_sel { next_sel_fetch=0, next_sel_next_free=1, next_sel_op_entry=2, next_sel_current=3 }


decompiled_code:
void __fastcall goto_address(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 84) = 1;
*(_DWORD *)(a1 + 68) = a2;
set_default(a1);
}

original_code:
void goto_address(uassembler* uasm, int address)
{
 uasm->current_addresses.len = 1;
 uasm->current_addresses.addresses[0] = address;
 set_default(uasm);
}

canonical_original_code:
void goto_address(struct uassembler *uasm, int address)
{
 uasm->current_addresses.len = 1;
 uasm->current_addresses.addresses[0] = address;
 set_default(uasm);
}

variable_types: address int


decompiled_code:
void __fastcall goto_reset(__int64 a1)
{
*(_DWORD *)(a1 + 88) = 0;
goto_address(a1, *(_DWORD *)(a1 + 64));
}

original_code:
void goto_reset(uassembler* uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_reset);
}

canonical_original_code:
void goto_reset(struct uassembler *uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_reset);
}


decompiled_code:
void __fastcall goto_fetch(__int64 a1)
{
*(_DWORD *)(a1 + 88) = 0;
goto_address(a1, *(_DWORD *)(a1 + 56));
}

original_code:
void goto_fetch(uassembler* uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_fetch);
}

canonical_original_code:
void goto_fetch(struct uassembler *uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_fetch);
}


decompiled_code:
__int64 __fastcall goto_next_free(__int64 a1)
{
int v1; // esi
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 60);
*(_DWORD *)(a1 + 88) = 0;
goto_address(a1, v1);
result = *(unsigned int *)(a1 + 60);
*(_DWORD *)(a1 + 60) = result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
int v1; // esi
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 60);
*(_DWORD *)(a1 + 88) = 0;
func7(a1, v1);
result = *(unsigned int *)(a1 + 60);
*(_DWORD *)(a1 + 60) = result + 1;
return result;
}

original_code:
int goto_next_free(uassembler* uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_free);
 int result = uasm->addr_free;
 uasm->addr_free++;
 return result;
}

canonical_original_code:
int goto_next_free(struct uassembler *uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_free);
 int result = uasm->addr_free;
 uasm->addr_free++;
 return result;
}

variable_types: result int


decompiled_code:
void __fastcall goto_op_entry(__int64 a1, int a2, char a3)
{
__m128i v3; // xmm0
__m128i v4; // [rsp+0h] [rbp-28h] BYREF
int v5; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
print_state(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v4, a1, a2, a3, 0);
v3 = _mm_loadu_si128(&v4);
*(_DWORD *)(a1 + 84) = v5;
*(__m128i *)(a1 + 68) = v3;
set_default(a1);
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1, int a2, char a3)
{
__m128i v3; // xmm0
__m128i v4; // [rsp+0h] [rbp-28h] BYREF
int v5; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
func0(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v4, a1, a2, a3, 0);
v3 = _mm_loadu_si128(&v4);
*(_DWORD *)(a1 + 84) = v5;
*(__m128i *)(a1 + 68) = v3;
func4(a1);
}

original_code:
void goto_op_entry(uassembler* uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 0);
 set_default(uasm);
}

canonical_original_code:
void goto_op_entry(struct uassembler *uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 0);
 set_default(uasm);
}

variable_types: opcode int


decompiled_code:
void __fastcall goto_inspect_cpu_entry(__int64 a1, int a2, char a3)
{
__m128i v3; // xmm0
__m128i v4; // [rsp+0h] [rbp-28h] BYREF
int v5; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
print_state(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v4, a1, a2, a3, 1);
v3 = _mm_loadu_si128(&v4);
*(_DWORD *)(a1 + 84) = v5;
*(__m128i *)(a1 + 68) = v3;
set_default(a1);
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, int a2, char a3)
{
__m128i v3; // xmm0
__m128i v4; // [rsp+0h] [rbp-28h] BYREF
int v5; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
func0(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v4, a1, a2, a3, 1);
v3 = _mm_loadu_si128(&v4);
*(_DWORD *)(a1 + 84) = v5;
*(__m128i *)(a1 + 68) = v3;
func4(a1);
}

original_code:
void goto_inspect_cpu_entry(uassembler* uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 1);
 set_default(uasm);
}

canonical_original_code:
void goto_inspect_cpu_entry(struct uassembler *uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 1);
 set_default(uasm);
}


decompiled_code:
__int64 __fastcall uassembler_init(__int64 a1, __int64 a2, __int64 a3, int a4, __int64 a5, __int64 a6, int a7, unsigned int a8)
{
char v11; // cl
__int64 result; // rax
__int64 v13; // [rsp-8h] [rbp-48h]

bin_table_new(a1, a2, a3, (unsigned int)(1 << a4), a8, 1LL, 1LL);
v11 = a7 + 3;
result = v13;
*(_QWORD *)(a1 + 32) = a5;
*(_QWORD *)(a1 + 40) = a6;
*(_DWORD *)(a1 + 52) = a7;
if ( a7 + 3 >= a4 )
{
fwrite("error: uassembler initialized with a too small address width", 1uLL, 0x3CuLL, stderr);
exit(1);
}
*(_DWORD *)(a1 + 48) = a4;
*(_DWORD *)(a1 + 56) = 1 << v11;
*(_QWORD *)(a1 + 60) = (unsigned int)((1 << v11) + 1);
*(_QWORD *)(a1 + 84) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, __int64 a3, int a4, __int64 a5, __int64 a6, int a7, unsigned int a8)
{
char v11; // cl
__int64 result; // rax
__int64 v13; // [rsp-8h] [rbp-48h]

bin_table_new(a1, a2, a3, (unsigned int)(1 << a4), a8, 1LL, 1LL);
v11 = a7 + 3;
result = v13;
*(_QWORD *)(a1 + 32) = a5;
*(_QWORD *)(a1 + 40) = a6;
*(_DWORD *)(a1 + 52) = a7;
if ( a7 + 3 >= a4 )
{
fwrite("error: uassembler initialized with a too small address width", 1uLL, 0x3CuLL, stderr);
exit(1);
}
*(_DWORD *)(a1 + 48) = a4;
*(_DWORD *)(a1 + 56) = 1 << v11;
*(_QWORD *)(a1 + 60) = (unsigned int)((1 << v11) + 1);
*(_QWORD *)(a1 + 84) = 0LL;
return result;
}

original_code:
void uassembler_init(uassembler* uasm, bin_table_collumn_description* field_descriptions, int number_of_fields,
  int rom_addr_with, char* next_addr_collumn_name, char* nextsel_addr_collumn_name,
  int opcode_width, int urom_width)
{
 bin_table_new(&(uasm->table), field_descriptions, number_of_fields, 1 << rom_addr_with, urom_width, 1, 1);
 uasm->next_addr_collumn_name = next_addr_collumn_name;
 uasm->nextsel_collumn_name = nextsel_addr_collumn_name;
 uasm->opcode_width = opcode_width;
 if(rom_addr_with <= opcode_width + 3)
 {
  fprintf(stderr, "error: uassembler initialized with a too small address width");
  exit(1);
 }
 uasm->rom_addr_with = rom_addr_with;
 uasm->addr_fetch = 1 << (opcode_width + 3);
 uasm->current_addresses.len = 0;
 uasm->addr_reset = 0;
 uasm->addr_free = uasm->addr_fetch + 1;
 uasm->current_at_op_entry = 0;
}

canonical_original_code:
void uassembler_init(struct uassembler *uasm, struct bin_table_collumn_description *field_descriptions, int number_of_fields, int rom_addr_with, char *next_addr_collumn_name, char *nextsel_addr_collumn_name, int opcode_width, int urom_width)
{
 bin_table_new(&(uasm->table), field_descriptions, number_of_fields, 1 << rom_addr_with, urom_width, 1, 1);
 uasm->next_addr_collumn_name = next_addr_collumn_name;
 uasm->nextsel_collumn_name = nextsel_addr_collumn_name;
 uasm->opcode_width = opcode_width;
 if(rom_addr_with <= opcode_width + 3)
 {
  fprintf(stderr, "error: uassembler initialized with a too small address width");
  exit(1);
 }
 uasm->rom_addr_with = rom_addr_with;
 uasm->addr_fetch = 1 << (opcode_width + 3);
 uasm->current_addresses.len = 0;
 uasm->addr_reset = 0;
 uasm->addr_free = uasm->addr_fetch + 1;
 uasm->current_at_op_entry = 0;
}


decompiled_code:
__int64 __fastcall print_verilog(__int64 a1, unsigned int a2)
{
return bin_table_print_binverilog(a1, stdout, a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, unsigned int a2)
{
return bin_table_print_binverilog(a1, stdout, a2);
}

original_code:
void print_verilog(uassembler* uasm, int comments)
{
 bin_table_print_binverilog(&uasm->table, stdout, comments);
}

canonical_original_code:
void print_verilog(struct uassembler *uasm, int comments)
{
 bin_table_print_binverilog(&uasm->table, stdout, comments);
}

variable_types: comments int


decompiled_code:
int __fastcall print_str(const char *a1)
{
return fputs(a1, _bss_start);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1)
{
return fputs(a1, _bss_start);
}

original_code:
void print_str(const char* str)
{
 fputs(str, stdout);
}

canonical_original_code:
void print_str(char *str)
{
 fputs(str, stdout);
}

variable_types:
str
char *


decompiled_code:
int __fastcall print_char(unsigned __int16 a1)
{
return putchar(a1);
}

canonical_decompiled_code:
int __fastcall func8(unsigned __int16 a1)
{
return putchar(a1);
}

original_code:
void print_char(uint16_t ch)
{
 putchar(ch);
}

canonical_original_code:
void print_char(unsigned short ch)
{
 putchar(ch);
}

variable_types:
ch
unsigned short


decompiled_code:
int __fastcall print_hex8(unsigned __int16 a1)
{
return printf("%02X", a1);
}

canonical_decompiled_code:
int __fastcall func9(unsigned __int16 a1)
{
return printf("%02X", a1);
}

original_code:
void print_hex8(uint16_t x)
{
 printf("%02X", x);
}

canonical_original_code:
void print_hex8(unsigned short x)
{
 printf("%02X", x);
}

variable_types:
x
unsigned short


decompiled_code:
int __fastcall print_hex16(unsigned __int16 a1)
{
return printf("%04X", a1);
}

canonical_decompiled_code:
int __fastcall func10(unsigned __int16 a1)
{
return printf("%04X", a1);
}

original_code:
void print_hex16(uint16_t x)
{
 printf("%04X", x);
}

canonical_original_code:
void print_hex16(unsigned short x)
{
 printf("%04X", x);
}