decompiled_code:
__int64 try_report_empty_detection()
{
__int64 result; // rax
__int64 v1; // rbx

if ( full_verbose )
{
result = wlog("Rules have been classified as follows:");
if ( nr_of_rules > 0 )
{
v1 = 0LL;
do
result = report_empty_detection_for_rule(*(_QWORD *)(all_rules + 8 * v1++));
while ( nr_of_rules > (int)v1 );
}
}
return result;
}

canonical_decompiled_code:
__int64 func31()
{
__int64 result; // rax
__int64 v1; // rbx

if ( full_verbose )
{
result = wlog("Rules have been classified as follows:");
if ( nr_of_rules > 0 )
{
v1 = 0LL;
do
result = func30(*(_QWORD *)(all_rules + 8 * v1++));
while ( nr_of_rules > (int)v1 );
}
}
return result;
}

original_code:
static void try_report_empty_detection ()
 { int ix;
   if (!full_verbose) return;
   wlog ("Rules have been classified as follows:");
   for (ix = 0; ix < nr_of_rules; ix++)
      report_empty_detection_for_rule (all_rules [ix]);
 }

canonical_original_code:
static void try_report_empty_detection()
 { int ix;
   if (!full_verbose) return;
   wlog ("Rules have been classified as follows:");
   for (ix = 0; ix < nr_of_rules; ix++)
      report_empty_detection_for_rule (all_rules [ix]);
 }


repo: tjordanchat/eag

decompiled_code:
__int64 do_empty_classification()
{
warning("empty detection and rule classification...");
detect_empty_producing_meta_rules();
do_initial_rule_classification();
detect_empty_producing_rules();
determine_user_predicates();
finish_rule_marking();
check_layout_rule();
return try_report_empty_detection();
}

canonical_decompiled_code:
__int64 func32()
{
warning("empty detection and rule classification...");
func20();
func24();
func28();
func14();
func13();
func29();
return func31();
}

original_code:
void do_empty_classification ()
 { warning ("empty detection and rule classification...");
   detect_empty_producing_meta_rules ();
   do_initial_rule_classification ();
   detect_empty_producing_rules ();
   determine_user_predicates ();
   finish_rule_marking ();
   check_layout_rule ();
   try_report_empty_detection ();
 }

canonical_original_code:
void do_empty_classification()
 { warning ("empty detection and rule classification...");
   detect_empty_producing_meta_rules ();
   do_initial_rule_classification ();
   detect_empty_producing_rules ();
   determine_user_predicates ();
   finish_rule_marking ();
   check_layout_rule ();
   try_report_empty_detection ();
 }

return_type: void


decompiled_code:
__int64 pred_makeemptyfield()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v2; // rax
__int64 result; // rax

v0 = new_affix_node("makeemptyfield_af1");
v1 = new_affix_node("makeemptyfield_af2");
*qptr = delayed_makeemptyfield;
v2 = qptr;
*(_QWORD *)(qptr + 8LL) = &make_node_delayed;
*(_QWORD *)(v2 + 16) = v1;
*(_DWORD *)(v2 + 24) = 1;
*(_QWORD *)(v2 + 32) = v0;
*(_DWORD *)(v2 + 40) = 1;
*(_DWORD *)(v2 + 48) = 2;
*(_DWORD *)(v2 + 56) = 0;
*(_DWORD *)(v2 + 64) = alib_modnr << 16;
*(_QWORD *)(v2 + 72) = &make_predicate_node;
qptr = v2 + 72;
make_predicate_node();
qptr -= 80LL;
rfre_value(*(_QWORD *)(v0 + 8));
free_affix_node(v0);
rfre_value(*(_QWORD *)(v1 + 8));
free_affix_node(v1);
result = qptr;
*qptr = pred_makeemptyfield;
qptr += 8LL;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v2; // rax
__int64 result; // rax

v0 = new_affix_node("makeemptyfield_af1");
v1 = new_affix_node("makeemptyfield_af2");
*qptr = delayed_makeemptyfield;
v2 = qptr;
*(_QWORD *)(qptr + 8LL) = &make_node_delayed;
*(_QWORD *)(v2 + 16) = v1;
*(_DWORD *)(v2 + 24) = 1;
*(_QWORD *)(v2 + 32) = v0;
*(_DWORD *)(v2 + 40) = 1;
*(_DWORD *)(v2 + 48) = 2;
*(_DWORD *)(v2 + 56) = 0;
*(_DWORD *)(v2 + 64) = alib_modnr << 16;
*(_QWORD *)(v2 + 72) = &make_predicate_node;
qptr = v2 + 72;
make_predicate_node();
qptr -= 80LL;
rfre_value(*(_QWORD *)(v0 + 8));
free_affix_node(v0);
rfre_value(*(_QWORD *)(v1 + 8));
free_affix_node(v1);
result = qptr;
*qptr = pred_makeemptyfield;
qptr += 8LL;
return result;
}

original_code:
void pred_makeemptyfield ()
 { affix_node af1 = new_affix_node ("makeemptyfield_af1");
   affix_node af2 = new_affix_node ("makeemptyfield_af2");
   qptr -> q = delayed_makeemptyfield; qptr++;
   qptr -> q = make_node_delayed; qptr++;
   qptr -> a = af2; qptr++;
   qptr -> i = 1; qptr++;
   qptr -> a = af1; qptr++;
   qptr -> i = 1; qptr++;
   qptr -> i = 2; qptr++;
   qptr -> i = 0; qptr++;
   qptr -> i = (((alib_modnr) << 16) + (0)); qptr++;
   qptr -> q = make_predicate_node; qptr++;
   (--qptr) -> q();
   qptr -= 10;
   rfre_value (af1 -> val);
   free_affix_node (af1);
   rfre_value (af2 -> val);
   free_affix_node (af2);
   qptr -> q = pred_makeemptyfield; qptr++;
 }

canonical_original_code:
void pred_makeemptyfield()
 { struct affix_rec *af1 = new_affix_node ("makeemptyfield_af1");
   struct affix_rec *af2 = new_affix_node ("makeemptyfield_af2");
   qptr -> q = delayed_makeemptyfield; qptr++;
   qptr -> q = make_node_delayed; qptr++;
   qptr -> a = af2; qptr++;
   qptr -> i = 1; qptr++;
   qptr -> a = af1; qptr++;
   qptr -> i = 1; qptr++;
   qptr -> i = 2; qptr++;
   qptr -> i = 0; qptr++;
   qptr -> i = (((alib_modnr) << 16) + (0)); qptr++;
   qptr -> q = make_predicate_node; qptr++;
   (--qptr) -> q();
   qptr -= 10;
   rfre_value (af1 -> val);
   free_affix_node (af1);
   rfre_value (af2 -> val);
   free_affix_node (af2);
   qptr -> q = pred_makeemptyfield; qptr++;
 }

variable_types: struct affix_rec { char *name; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; void (*mfunc)(); struct link_rec { struct pos_rec { struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec **affs; } *node; struct pos_side_rec { int sill; int tag; union { struct affix_rec *affx; struct { int nr; struct affix_rec **affs; } co; } a; } sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); } *pos; int side; struct link_rec *next; } *links; } *

user_defined_types: struct affix_rec { char *name; struct value_rec *val; void (*mfunc)(); struct link_rec *links; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct link_rec { struct pos_rec *pos; int side; struct link_rec *next; }

user_defined_types: struct pos_rec { struct tree_rec *node; struct pos_side_rec sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); }


original_code:
static void delayed_isempty (pos_node *ps)
 { pos_node ps1 = ps[0];
   pos_node ps2 = ps[1];
   if (!((ps1) -> sides[0].a.affx -> val != ((value) ((void *)0))) || !((ps2) -> sides[0].a.affx -> val != ((value) ((void *)0))))
      (--qptr) -> q();
   else
    { ps1 -> delayed = 0;
      ps2 -> delayed = 0;
      act_isempty (ps1, ps2);
      ps1 -> delayed = 1;
      ps2 -> delayed = 1;
    };
 }

canonical_original_code:
static void delayed_isempty(struct pos_rec **ps)
 { struct pos_rec *ps1 = ps[0];
   struct pos_rec *ps2 = ps[1];
   if (!((ps1) -> sides[0].a.affx -> val != ((value) ((void *)0))) || !((ps2) -> sides[0].a.affx -> val != ((value) ((void *)0))))
      (--qptr) -> q();
   else
    { ps1 -> delayed = 0;
      ps2 -> delayed = 0;
      act_isempty (ps1, ps2);
      ps1 -> delayed = 1;
      ps2 -> delayed = 1;
    };
 }

variable_types: struct pos_rec { struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec **affs; } *node; struct pos_side_rec { int sill; int tag; union { struct affix_rec { char *name; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; void (*mfunc)(); struct link_rec { struct pos_rec *pos; int side; struct link_rec *next; } *links; } *affx; struct { int nr; struct affix_rec **affs; } co; } a; } sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); } **

user_defined_types: struct pos_side_rec { int sill; int tag; union { struct affix_rec *affx; struct { int nr; struct affix_rec **affs; } co; } a; }


original_code:
static void delayed_take (pos_node *ps)
 { pos_node ps1 = ps[0];
   pos_node ps2 = ps[1];
   if (!((ps1) -> sides[0].a.affx -> val != ((value) ((void *)0))) || !((ps2) -> sides[0].a.affx -> val != ((value) ((void *)0))))
      (--qptr) -> q();
   else
    { ps1 -> delayed = 0;
      ps2 -> delayed = 0;
      act_take (ps1, ps2);
      ps1 -> delayed = 1;
      ps2 -> delayed = 1;
    };
 }

canonical_original_code:
static void delayed_take(struct pos_rec **ps)
 { struct pos_rec *ps1 = ps[0];
   struct pos_rec *ps2 = ps[1];
   if (!((ps1) -> sides[0].a.affx -> val != ((value) ((void *)0))) || !((ps2) -> sides[0].a.affx -> val != ((value) ((void *)0))))
      (--qptr) -> q();
   else
    { ps1 -> delayed = 0;
      ps2 -> delayed = 0;
      act_take (ps1, ps2);
      ps1 -> delayed = 1;
      ps2 -> delayed = 1;
    };
 }

variable_types: struct pos_rec { struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec **affs; } *node; struct pos_side_rec { int sill; int tag; union { struct affix_rec { char *name; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; void (*mfunc)(); struct link_rec { struct pos_rec *pos; int side; struct link_rec *next; } *links; } *affx; struct { int nr; struct affix_rec **affs; } co; } a; } sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); } *


original_code:
static void delayed_makeemptyfield (pos_node *ps)
 { pos_node ps1 = ps[0];
   pos_node ps2 = ps[1];
   if (!((ps1) -> sides[0].a.affx -> val != ((value) ((void *)0))) || !((ps2) -> sides[0].a.affx -> val != ((value) ((void *)0)))) (--qptr) -> q();
   else
    { ps1 -> delayed = 0;
      ps2 -> delayed = 0;
      act_makeemptyfield (ps1, ps2);
      ps1 -> delayed = 1;
      ps2 -> delayed = 1;
    };
 }

canonical_original_code:
static void delayed_makeemptyfield(struct pos_rec **ps)
 { struct pos_rec *ps1 = ps[0];
   struct pos_rec *ps2 = ps[1];
   if (!((ps1) -> sides[0].a.affx -> val != ((value) ((void *)0))) || !((ps2) -> sides[0].a.affx -> val != ((value) ((void *)0)))) (--qptr) -> q();
   else
    { ps1 -> delayed = 0;
      ps2 -> delayed = 0;
      act_makeemptyfield (ps1, ps2);
      ps1 -> delayed = 1;
      ps2 -> delayed = 1;
    };
 }

user_defined_types: struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec **affs; }

user_defined_types: struct value_list_rec { int size; int room; struct value_rec **array; }

user_defined_types: struct int_list_rec { int size; int room; int *array; }


decompiled_code:
__int64 semipred_showfield()
{
int i; // ebp
__int64 v1; // rax
__int64 result; // rax
int j; // ebx
int v4; // eax

fwrite("Field:\n", 1uLL, 7uLL, stderr);
for ( i = 0; height > i; ++i )
{
v4 = width;
for ( j = 0; width > j; v4 = width )
{
fputc(*((_BYTE *)field + j + i * v4) == 0 ? 32 : 88, stderr);
++j;
}
fputc(10, stderr);
}
fputc(10, stderr);
*qptr = 0;
v1 = qptr;
*(_DWORD *)(qptr + 8LL) = 0;
*(_DWORD *)(v1 + 16) = (alib_modnr << 16) + 3;
*(_QWORD *)(v1 + 24) = &make_semipredicate_node;
qptr = v1 + 24;
make_semipredicate_node();
result = qptr;
qptr -= 32LL;
*qptr = semipred_showfield;
qptr += 8LL;
return result;
}

canonical_decompiled_code:
__int64 func9()
{
int i; // ebp
__int64 v1; // rax
__int64 result; // rax
int j; // ebx
int v4; // eax

fwrite("Field:\n", 1uLL, 7uLL, stderr);
for ( i = 0; height > i; ++i )
{
v4 = width;
for ( j = 0; width > j; v4 = width )
{
fputc(*((_BYTE *)field + j + i * v4) == 0 ? 32 : 88, stderr);
++j;
}
fputc(10, stderr);
}
fputc(10, stderr);
*qptr = 0;
v1 = qptr;
*(_DWORD *)(qptr + 8LL) = 0;
*(_DWORD *)(v1 + 16) = (alib_modnr << 16) + 3;
*(_QWORD *)(v1 + 24) = &make_semipredicate_node;
qptr = v1 + 24;
make_semipredicate_node();
result = qptr;
qptr -= 32LL;
*qptr = semipred_showfield;
qptr += 8LL;
return result;
}

original_code:
void semipred_showfield ()
 { int i,j;
   fprintf (stderr, "Field:\n");
   for (i = 0; i < height; i++)
      { for (j = 0; j < width; j++)
    fputc ((field [i*width +j])?'X':' ', stderr);
        fputc ('\n', stderr);
      };
   fputc ('\n', stderr);
   qptr -> i = 0; qptr++;
   qptr -> i = 0; qptr++;
   qptr -> i = (((alib_modnr) << 16) + (3)); qptr++;
   qptr -> q = make_semipredicate_node; qptr++;
   (--qptr) -> q();
   qptr -= 4;
   qptr -> q = semipred_showfield; qptr++;
 }

canonical_original_code:
void semipred_showfield()
 { int i; int j;
   fprintf (stderr, "Field:\n");
   for (i = 0; i < height; i++)
      { for (j = 0; j < width; j++)
    fputc ((field [i*width +j])?'X':' ', stderr);
        fputc ('\n', stderr);
      };
   fputc ('\n', stderr);
   qptr -> i = 0; qptr++;
   qptr -> i = 0; qptr++;
   qptr -> i = (((alib_modnr) << 16) + (3)); qptr++;
   qptr -> q = make_semipredicate_node; qptr++;
   (--qptr) -> q();
   qptr -= 4;
   qptr -> q = semipred_showfield; qptr++;
 }

variable_types: i int

variable_types: j int


decompiled_code:
const char *__fastcall alib_name_from_nodenr(unsigned __int16 a1)
{
const char *result; // rax

if ( a1 == 2 )
return "pred_take";
if ( a1 > 2u )
{
if ( a1 != 3 )
goto LABEL_8;
result = "semipred_showfield";
}
else
{
if ( a1 )
{
if ( a1 == 1 )
return "pred_isempty";
LABEL_8:
fprintf(stderr, "strange nodenr %d in alib\n", a1);
exit(4);
}
result = "pred_makeemptyfield";
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func10(unsigned __int16 a1)
{
const char *result; // rax

if ( a1 == 2 )
return "pred_take";
if ( a1 > 2u )
{
if ( a1 != 3 )
goto LABEL_8;
result = "semipred_showfield";
}
else
{
if ( a1 )
{
if ( a1 == 1 )
return "pred_isempty";
LABEL_8:
fprintf(stderr, "strange nodenr %d in alib\n", a1);
exit(4);
}
result = "pred_makeemptyfield";
}
return result;
}

original_code:
char *alib_name_from_nodenr (int nodenr)
 { int lnr = ((nodenr) & 0xffff);
   switch (lnr)
      { case 0: return ("pred_makeemptyfield");
        case 1: return ("pred_isempty");
        case 2: return ("pred_take");
        case 3: return ("semipred_showfield");
        default: fprintf (stderr, "strange nodenr %d in alib\n", lnr);
      };
   exit (4);
 }

canonical_original_code:
char *alib_name_from_nodenr(int nodenr)
 { int lnr = ((nodenr) & 0xffff);
   switch (lnr)
      { case 0: return ("pred_makeemptyfield");
        case 1: return ("pred_isempty");
        case 2: return ("pred_take");
        case 3: return ("semipred_showfield");
        default: fprintf (stderr, "strange nodenr %d in alib\n", lnr);
      };
   exit (4);
 }

variable_types: nodenr int

variable_types: lnr int

return_type: char *


decompiled_code:
void __fastcall init_alib(int a1)
{
alib_modnr = a1;
}

canonical_decompiled_code:
void __fastcall func11(int a1)
{
alib_modnr = a1;
}

original_code:
void init_alib (int modnr)
 { alib_modnr = modnr;
 }

canonical_original_code:
void init_alib(int modnr)
 { alib_modnr = modnr;
 }

variable_types: modnr int


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

result = (unsigned int)(*(_DWORD *)a2 - 1);
if ( *(_DWORD *)a2 - 1 >= 0 )
{
result = (int)result;
while ( 1 )
{
v3 = *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * result);
if ( !*(_DWORD *)(v3 + 24) && *(_QWORD *)(v3 + 48) == layout_rule )
break;
if ( *(_DWORD *)v3 != 2 && (int)--result >= 0 )
continue;
return result;
}
*(_DWORD *)(a1 + 44) = 1;
}
return result;
}

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

result = (unsigned int)(*(_DWORD *)a2 - 1);
if ( *(_DWORD *)a2 - 1 >= 0 )
{
result = (int)result;
while ( 1 )
{
v3 = *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * result);
if ( !*(_DWORD *)(v3 + 24) && *(_QWORD *)(v3 + 48) == layout_rule )
break;
if ( *(_DWORD *)v3 != 2 && (int)--result >= 0 )
continue;
return result;
}
*(_DWORD *)(a1 + 44) = 1;
}
return result;
}

original_code:
static void initial_check_if_alt_ends_in_layout (rule srule,
        member_list mems)
 { int ix;
   for (ix = mems -> size - 1; 0 <= ix; ix--)
      { member m = mems -> array[ix];
        if ((m -> tag == 0) && (m -> u.call.def == layout_rule))
    { srule -> endsinlayout = 1;
      return;
    };
        if (m -> empty == 2) return;
      };
 }

canonical_original_code:
static void initial_check_if_alt_ends_in_layout(struct rule_rec *srule, struct member_list_rec *mems)
 { int ix;
   for (ix = mems -> size - 1; 0 <= ix; ix--)
      { struct member_rec *m = mems -> array[ix];
        if ((m -> tag == 0) && (m -> u.call.def == layout_rule))
    { srule -> endsinlayout = 1;
      return;
    };
        if (m -> empty == 2) return;
      };
 }

variable_types: struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { struct pos_list_rec { int size; int room; struct pos_rec { int kind; struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *ex; int type; struct element_def_rec *lat_repr; } **array; } *display; struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *

variable_types:
mems
struct member_list_rec *

variable_types: ix int

variable_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec { int size; int room; struct pos_rec { int kind; struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *ex; int type; struct element_def_rec *lat_repr; } **array; } *display; struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { struct pos_list_rec *display; struct member_list_rec { int size; int room; struct member_rec **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } *

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

user_defined_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }

user_defined_types: struct element_set_rec { int number; struct element_def_list_rec *defs; }


original_code:
static void initial_analyze_layout_in_rule (rule srule)
 { int ix;
   if (srule -> ext) return;
   if (srule -> kind & (2 | 4)) return;
   if (srule == layout_rule) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      initial_analyze_layout_in_alt (srule, srule -> alts -> array[ix]);
 }

canonical_original_code:
static void initial_analyze_layout_in_rule(struct rule_rec *srule)
 { int ix;
   if (srule -> ext) return;
   if (srule -> kind & (2 | 4)) return;
   if (srule == layout_rule) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      initial_analyze_layout_in_alt (srule, srule -> alts -> array[ix]);
 }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }

user_defined_types: struct cset_rec { int kind; char *str; }

user_defined_types: struct value_list_rec { int size; int room; struct value_rec **array; }

user_defined_types: struct meta_alt_rec { struct expr_rec *e; int number; }

user_defined_types: struct element_def_list_rec { int size; int room; struct element_def_rec **array; }


decompiled_code:
void initial_analyze_layout_in_rules()
{
__int64 v0; // rbx

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
initial_analyze_layout_in_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

canonical_decompiled_code:
void func3()
{
__int64 v0; // rbx

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
func2(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

original_code:
static void initial_analyze_layout_in_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      initial_analyze_layout_in_rule (all_rules[ix]);
 }

canonical_original_code:
static void initial_analyze_layout_in_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      initial_analyze_layout_in_rule (all_rules[ix]);
 }


original_code:
static void check_if_alt_starts_with_layout (rule srule, member_list mems)
 { int ix;
   if (srule -> startswithlayout) return;
   for (ix = 0; ix < mems -> size; ix++)
      { member m = mems -> array[ix];
        if ((m -> tag == 0) &&
     (m -> u.call.def -> startswithlayout))
    { srule -> startswithlayout = 1;
      change = 1;
      return;
    };
        if (m -> empty == 2) return;
      };
 }

canonical_original_code:
static void check_if_alt_starts_with_layout(struct rule_rec *srule, struct member_list_rec *mems)
 { int ix;
   if (srule -> startswithlayout) return;
   for (ix = 0; ix < mems -> size; ix++)
      { struct member_rec *m = mems -> array[ix];
        if ((m -> tag == 0) &&
     (m -> u.call.def -> startswithlayout))
    { srule -> startswithlayout = 1;
      change = 1;
      return;
    };
        if (m -> empty == 2) return;
      };
 }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

user_defined_types: struct int_list_rec { int size; int room; int *array; }


original_code:
static void check_if_alt_ends_in_layout (rule srule, member_list mems)
 { int ix;
   if (srule -> endsinlayout) return;
   for (ix = mems -> size - 1; 0 <= ix; ix--)
      { member m = mems -> array[ix];
        if ((m -> tag == 0) &&
     (m -> u.call.def -> endsinlayout))
    { srule -> endsinlayout = 1;
      change = 1;
      return;
    };
        if (m -> empty == 2) return;
      };
 }

canonical_original_code:
static void check_if_alt_ends_in_layout(struct rule_rec *srule, struct member_list_rec *mems)
 { int ix;
   if (srule -> endsinlayout) return;
   for (ix = mems -> size - 1; 0 <= ix; ix--)
      { struct member_rec *m = mems -> array[ix];
        if ((m -> tag == 0) &&
     (m -> u.call.def -> endsinlayout))
    { srule -> endsinlayout = 1;
      change = 1;
      return;
    };
        if (m -> empty == 2) return;
      };
 }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

user_defined_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }

user_defined_types: struct element_set_rec { int number; struct element_def_list_rec *defs; }


original_code:
static void analyze_layout_for_rule (rule srule)
 { int ix;
   if (srule -> ext) return;
   if (srule -> kind & (2 | 4)) return;
   if (srule == layout_rule) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      analyze_layout_in_alt (srule, srule -> alts -> array[ix]);
 }

canonical_original_code:
static void analyze_layout_for_rule(struct rule_rec *srule)
 { int ix;
   if (srule -> ext) return;
   if (srule -> kind & (2 | 4)) return;
   if (srule == layout_rule) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      analyze_layout_in_alt (srule, srule -> alts -> array[ix]);
 }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

user_defined_types: struct cset_rec { int kind; char *str; }

user_defined_types: struct value_list_rec { int size; int room; struct value_rec **array; }

user_defined_types: struct meta_alt_rec { struct expr_rec *e; int number; }

user_defined_types: struct element_def_list_rec { int size; int room; struct element_def_rec **array; }


decompiled_code:
void analyze_layout_for_rules()
{
__int64 v0; // rbx

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
analyze_layout_for_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

canonical_decompiled_code:
void func8()
{
__int64 v0; // rbx

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
func7(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

original_code:
static void analyze_layout_for_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      analyze_layout_for_rule (all_rules[ix]);
 }

canonical_original_code:
static void analyze_layout_for_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      analyze_layout_for_rule (all_rules[ix]);
 }


decompiled_code:
__int64 __fastcall report_on_layout_for_rule(const char **a1)
{
__int64 result; // rax

if ( *((_DWORD *)a1 + 10) )
result = wlog("rule %s may start with layout", *a1);
if ( *((_DWORD *)a1 + 11) )
result = wlog("rule %s may end with layout", *a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char **a1)
{
__int64 result; // rax

if ( *((_DWORD *)a1 + 10) )
result = wlog("rule %s may start with layout", *a1);
if ( *((_DWORD *)a1 + 11) )
result = wlog("rule %s may end with layout", *a1);
return result;
}

original_code:
static void report_on_layout_for_rule (rule srule)
 { if (srule -> startswithlayout)
      wlog ("rule %s may start with layout", srule -> nonterminal);
   if (srule -> endsinlayout)
      wlog ("rule %s may end with layout", srule -> nonterminal);
 }

canonical_original_code:
static void report_on_layout_for_rule(struct rule_rec *srule)
 { if (srule -> startswithlayout)
      wlog ("rule %s may start with layout", srule -> nonterminal);
   if (srule -> endsinlayout)
      wlog ("rule %s may end with layout", srule -> nonterminal);
 }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }

user_defined_types: struct int_list_rec { int size; int room; int *array; }


decompiled_code:
__int64 report_on_layout()
{
__int64 v0; // rbx
__int64 result; // rax

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = report_on_layout_for_rule(*(const char ***)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 v0; // rbx
__int64 result; // rax

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = func9(*(const char ***)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

original_code:
static void report_on_layout ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      report_on_layout_for_rule (all_rules[ix]);
 }

canonical_original_code:
static void report_on_layout()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      report_on_layout_for_rule (all_rules[ix]);
 }


decompiled_code:
__int64 analyze_layout_in_grammar()
{
unsigned int v0; // ebx
const char *v1; // rdx
__int64 result; // rax

warning("analyzing layout...");
initial_analyze_layout_in_rules();
v0 = 0;
do
{
change = 0;
++v0;
analyze_layout_for_rules();
}
while ( change );
v1 = (const char *)&unk_70E;
if ( v0 != 1 )
v1 = "es";
result = hint("needed %d pass%s for layout analysis", v0, v1);
if ( full_verbose )
{
wlog("dumping layout analysis");
result = report_on_layout();
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
unsigned int v0; // ebx
const char *v1; // rdx
__int64 result; // rax

warning("analyzing layout...");
func3();
v0 = 0;
do
{
change = 0;
++v0;
func8();
}
while ( change );
v1 = (const char *)&unk_70E;
if ( v0 != 1 )
v1 = "es";
result = hint("needed %d pass%s for layout analysis", v0, v1);
if ( full_verbose )
{
wlog("dumping layout analysis");
result = func10();
}
return result;
}

original_code:
static void analyze_layout_in_grammar ()
 { int nrpasses = 0;
   warning ("analyzing layout...");
   initial_analyze_layout_in_rules ();
   do
      { change = 0;
        nrpasses++;
        analyze_layout_for_rules ();
      }
   while (change);
   hint ("needed %d pass%s for layout analysis", nrpasses,
  (nrpasses == 1)?"":"es");
   if (full_verbose)
      { wlog ("dumping layout analysis");
        report_on_layout ();
      };
 }

canonical_original_code:
static void analyze_layout_in_grammar()
 { int nrpasses = 0;
   warning ("analyzing layout...");
   initial_analyze_layout_in_rules ();
   do
      { change = 0;
        nrpasses++;
        analyze_layout_for_rules ();
      }
   while (change);
   hint ("needed %d pass%s for layout analysis", nrpasses,
  (nrpasses == 1)?"":"es");
   if (full_verbose)
      { wlog ("dumping layout analysis");
        report_on_layout ();
      };
 }

variable_types: nrpasses int


original_code:
int is_an_invisible_member (member m)
 { switch (m -> tag)
      { case 0:
    { rule def = m -> u.call.def;
      if (def == layout_rule) return (1);
      if (def -> ext) return (1);
      if (def -> kind & (2 | 4))
   return (1);
      return (0);
    };
        case 1: return (strcmp (m -> u.terminal, "") == 0);
        case 3: return (1);
        default: return (0);
      };
 }

canonical_original_code:
int is_an_invisible_member(struct member_rec *m)
 { switch (m -> tag)
      { case 0:
    { struct rule_rec *def = m -> u.call.def;
      if (def == layout_rule) return (1);
      if (def -> ext) return (1);
      if (def -> kind & (2 | 4))
   return (1);
      return (0);
    };
        case 1: return (strcmp (m -> u.terminal, "") == 0);
        case 3: return (1);
        default: return (0);
      };
 }

return_type: int

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

user_defined_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }

user_defined_types: struct element_set_rec { int number; struct element_def_list_rec *defs; }


decompiled_code:
__int64 __fastcall mark_member_if_followed(__int64 a1, unsigned int *a2, int a3)
{
__int64 result; // rax
__int64 v4; // rcx
__int64 *v5; // rbx
unsigned __int64 v6; // rbp

result = *a2;
if ( a3 < (int)result )
{
v4 = *((_QWORD *)a2 + 1);
v5 = (__int64 *)(v4 + 8LL * a3);
v6 = v4 + 8 * (a3 + (unsigned __int64)(unsigned int)(result - 1 - a3)) + 8;
while ( 1 )
{
result = is_an_invisible_member(*v5);
if ( !(_DWORD)result )
break;
if ( ++v5 == (__int64 *)v6 )
return result;
}
*(_DWORD *)(a1 + 4) = 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, unsigned int *a2, int a3)
{
__int64 result; // rax
__int64 v4; // rcx
__int64 *v5; // rbx
unsigned __int64 v6; // rbp

result = *a2;
if ( a3 < (int)result )
{
v4 = *((_QWORD *)a2 + 1);
v5 = (__int64 *)(v4 + 8LL * a3);
v6 = v4 + 8 * (a3 + (unsigned __int64)(unsigned int)(result - 1 - a3)) + 8;
while ( 1 )
{
result = func12(*v5);
if ( !(_DWORD)result )
break;
if ( ++v5 == (__int64 *)v6 )
return result;
}
*(_DWORD *)(a1 + 4) = 1;
}
return result;
}

original_code:
static void mark_member_if_followed (member m, member_list mems, int from)
 { int k;
   for (k = from; k < mems -> size; k++)
      { if (!is_an_invisible_member (mems -> array[k]))
    { m -> followlayout = 1;
      return;
    };
      };
 }

canonical_original_code:
static void mark_member_if_followed(struct member_rec *m, struct member_list_rec *mems, int from)
 { int k;
   for (k = from; k < mems -> size; k++)
      { if (!is_an_invisible_member (mems -> array[k]))
    { m -> followlayout = 1;
      return;
    };
      };
 }

variable_types: from int

variable_types: k int

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct cset_rec { int kind; char *str; }

user_defined_types: struct value_list_rec { int size; int room; struct value_rec **array; }

user_defined_types: struct meta_alt_rec { struct expr_rec *e; int number; }

user_defined_types: struct element_def_list_rec { int size; int room; struct element_def_rec **array; }


decompiled_code:
__int64 __fastcall determine_layout_insertion_point(__int64 a1, int a2)
{
__int64 v3; // rbp
__int64 v4; // r15
__int64 result; // rax
__int64 v6; // rbx
int v7; // er12
__int64 v8; // r14
__int64 v9; // rdi

v3 = *(_QWORD *)(a1 + 8);
v4 = *(_QWORD *)(v3 + 8LL * a2);
result = is_an_invisible_member(v4);
if ( !(_DWORD)result )
{
if ( !*(_DWORD *)(v4 + 24) && (result = *(_QWORD *)(v4 + 48), *(_DWORD *)(result + 44)) )
{
result = mark_member_if_followed(v4, (unsigned int *)a1, a2 + 1);
}
else
{
LODWORD(v6) = a2 + 1;
v7 = *(_DWORD *)a1;
if ( a2 + 1 < *(_DWORD *)a1 )
{
v8 = layout_rule;
v6 = (int)v6;
while ( 1 )
{
v9 = *(_QWORD *)(v3 + 8 * v6);
if ( !*(_DWORD *)(v9 + 24) )
{
result = *(_QWORD *)(v9 + 48);
if ( result == v8 )
return mark_member_if_followed(v4, (unsigned int *)a1, (int)v6 + 1);
if ( *(_DWORD *)(result + 40) )
break;
}
result = is_an_invisible_member(v9);
if ( (_DWORD)result )
{
if ( v7 > (int)++v6 )
continue;
}
return result;
}
*(_DWORD *)(v4 + 4) = 1;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, int a2)
{
__int64 v3; // rbp
__int64 v4; // r15
__int64 result; // rax
__int64 v6; // rbx
int v7; // er12
__int64 v8; // r14
__int64 v9; // rdi

v3 = *(_QWORD *)(a1 + 8);
v4 = *(_QWORD *)(v3 + 8LL * a2);
result = func12(v4);
if ( !(_DWORD)result )
{
if ( !*(_DWORD *)(v4 + 24) && (result = *(_QWORD *)(v4 + 48), *(_DWORD *)(result + 44)) )
{
result = func13(v4, (unsigned int *)a1, a2 + 1);
}
else
{
LODWORD(v6) = a2 + 1;
v7 = *(_DWORD *)a1;
if ( a2 + 1 < *(_DWORD *)a1 )
{
v8 = layout_rule;
v6 = (int)v6;
while ( 1 )
{
v9 = *(_QWORD *)(v3 + 8 * v6);
if ( !*(_DWORD *)(v9 + 24) )
{
result = *(_QWORD *)(v9 + 48);
if ( result == v8 )
return func13(v4, (unsigned int *)a1, (int)v6 + 1);
if ( *(_DWORD *)(result + 40) )
break;
}
result = func12(v9);
if ( (_DWORD)result )
{
if ( v7 > (int)++v6 )
continue;
}
return result;
}
*(_DWORD *)(v4 + 4) = 1;
}
}
}
return result;
}

original_code:
static void determine_layout_insertion_point (member_list mems, int i)
 { int j;
   member m = mems -> array[i];
   if (is_an_invisible_member (m)) return;
   if ((m -> tag == 0) && (m -> u.call.def -> endsinlayout))
      { mark_member_if_followed (m, mems, i+1);
        return;
      };
   for (j = i + 1; j < mems -> size; j++)
      { member m2 = mems -> array[j];
        if ((((m2) -> tag == 0) && ((m2) -> u.call.def == layout_rule)))
    { mark_member_if_followed (m, mems, j+1);
      return;
    };
        if ((m2 -> tag == 0) &&
     (m2 -> u.call.def -> startswithlayout))
    { m -> followlayout = 1; return; };
        if (!is_an_invisible_member (m2)) return;
      };
 }

canonical_original_code:
static void determine_layout_insertion_point(struct member_list_rec *mems, int i)
 { int j;
   struct member_rec *m = mems -> array[i];
   if (is_an_invisible_member (m)) return;
   if ((m -> tag == 0) && (m -> u.call.def -> endsinlayout))
      { mark_member_if_followed (m, mems, i+1);
        return;
      };
   for (j = i + 1; j < mems -> size; j++)
      { struct member_rec *m2 = mems -> array[j];
        if ((((m2) -> tag == 0) && ((m2) -> u.call.def == layout_rule)))
    { mark_member_if_followed (m, mems, j+1);
      return;
    };
        if ((m2 -> tag == 0) &&
     (m2 -> u.call.def -> startswithlayout))
    { m -> followlayout = 1; return; };
        if (!is_an_invisible_member (m2)) return;
      };
 }

variable_types: struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec { int size; int room; struct pos_rec { int kind; struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *ex; int type; struct element_def_rec *lat_repr; } **array; } *display; struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }


decompiled_code:
void __fastcall determine_layout_insertion_points_in_rule(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx

if ( !*(_DWORD *)(a1 + 28) && (*(_BYTE *)(a1 + 16) & 6) == 0 )
{
v1 = *(_QWORD *)(a1 + 8);
if ( *(int *)v1 > 0 )
{
v2 = 0LL;
do
{
determine_layout_insertion_points_in_alt(*(_QWORD *)(*(_QWORD *)(v1 + 8) + 8 * v2));
v1 = *(_QWORD *)(a1 + 8);
++v2;
}
while ( *(_DWORD *)v1 > (int)v2 );
}
}
}

original_code:
static void determine_layout_insertion_points_in_rule (rule srule)
 { int ix;
   if (srule -> ext) return;
   if (srule -> kind & (2 | 4)) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      determine_layout_insertion_points_in_alt
  (srule -> alts -> array[ix]);
 }

canonical_original_code:
static void determine_layout_insertion_points_in_rule(struct rule_rec *srule)
 { int ix;
   if (srule -> ext) return;
   if (srule -> kind & (2 | 4)) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      determine_layout_insertion_points_in_alt
  (srule -> alts -> array[ix]);
 }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }

user_defined_types: struct int_list_rec { int size; int room; int *array; }

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

user_defined_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }

user_defined_types: struct element_set_rec { int number; struct element_def_list_rec *defs; }


decompiled_code:
void determine_layout_insertion_points_in_rules()
{
__int64 v0; // rbx

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
determine_layout_insertion_points_in_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

canonical_decompiled_code:
void func17()
{
__int64 v0; // rbx

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
func16(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

original_code:
static void determine_layout_insertion_points_in_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      determine_layout_insertion_points_in_rule (all_rules[ix]);
 }

canonical_original_code:
static void determine_layout_insertion_points_in_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      determine_layout_insertion_points_in_rule (all_rules[ix]);
 }


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

result = is_an_invisible_member(a1);
if ( !(_DWORD)result )
{
result = *(unsigned int *)(a1 + 24);
switch ( (_DWORD)result )
{
case 1:
result = output_string(stderr, *(_QWORD *)(a1 + 32));
break;
case 2:
result = wlog("{}");
break;
case 0:
result = wlog(*(const char **)(a1 + 32));
break;
}
}
return result;
}

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

result = func12(a1);
if ( !(_DWORD)result )
{
result = *(unsigned int *)(a1 + 24);
switch ( (_DWORD)result )
{
case 1:
result = output_string(stderr, *(_QWORD *)(a1 + 32));
break;
case 2:
result = wlog("{}");
break;
case 0:
result = wlog(*(const char **)(a1 + 32));
break;
}
}
return result;
}

original_code:
static void dump_member (member m)
 { if (is_an_invisible_member (m)) return;
   switch (m -> tag)
      { case 0: wlog (m -> u.call.nonterminal); break;
        case 1: output_string (stderr, m -> u.terminal);
      break;
        case 2: wlog ("{}");
        default: break;
      };
 }

canonical_original_code:
static void dump_member(struct member_rec *m)
 { if (is_an_invisible_member (m)) return;
   switch (m -> tag)
      { case 0: wlog (m -> u.call.nonterminal); break;
        case 1: output_string (stderr, m -> u.terminal);
      break;
        case 2: wlog ("{}");
        default: break;
      };
 }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct cset_rec { int kind; char *str; }

user_defined_types: struct value_list_rec { int size; int room; struct value_rec **array; }

user_defined_types: struct meta_alt_rec { struct expr_rec *e; int number; }

user_defined_types: struct element_def_list_rec { int size; int room; struct element_def_rec **array; }


decompiled_code:
__int64 __fastcall dump_insertion_points_of_alt(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 result; // rax

if ( a1 && *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1);
result = dump_member(v2);
if ( *(_DWORD *)(v2 + 4) )
result = eprint_log(".");
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 result; // rax

if ( a1 && *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1);
result = func18(v2);
if ( *(_DWORD *)(v2 + 4) )
result = eprint_log(".");
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
return result;
}

original_code:
static void dump_insertion_points_of_alt (member_list mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      { member m = mems -> array[ix];
        dump_member (m);
        if (m -> followlayout) eprint_log (".");
      };
 }

canonical_original_code:
static void dump_insertion_points_of_alt(struct member_list_rec *mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      { struct member_rec *m = mems -> array[ix];
        dump_member (m);
        if (m -> followlayout) eprint_log (".");
      };
 }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }


decompiled_code:
int *dump_insertion_points_of_rules()
{
__int64 v0; // rbx
int *result; // rax

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = dump_insertion_points_of_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

canonical_decompiled_code:
int *func21()
{
__int64 v0; // rbx
int *result; // rax

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = func20(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

original_code:
static void dump_insertion_points_of_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      dump_insertion_points_of_rule (all_rules[ix]);
 }

canonical_original_code:
static void dump_insertion_points_of_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      dump_insertion_points_of_rule (all_rules[ix]);
 }


decompiled_code:
void determine_layout_insertion_points()
{
warning("determining layout insertion points...");
determine_layout_insertion_points_in_rules();
if ( full_verbose )
{
wlog("dumping layout insertion points");
dump_insertion_points_of_rules();
}
}

canonical_decompiled_code:
void func22()
{
warning("determining layout insertion points...");
func17();
if ( full_verbose )
{
wlog("dumping layout insertion points");
func21();
}
}

original_code:
static void determine_layout_insertion_points ()
 { warning ("determining layout insertion points...");
   determine_layout_insertion_points_in_rules ();
   if (full_verbose)
      { wlog ("dumping layout insertion points");
        dump_insertion_points_of_rules ();
      };
 }

canonical_original_code:
static void determine_layout_insertion_points()
 { warning ("determining layout insertion points...");
   determine_layout_insertion_points_in_rules ();
   if (full_verbose)
      { wlog ("dumping layout insertion points");
        dump_insertion_points_of_rules ();
      };
 }


decompiled_code:
void analyze_layout()
{
analyze_layout_in_grammar();
determine_layout_insertion_points();
}

canonical_decompiled_code:
void func23()
{
func11();
func22();
}

original_code:
void analyze_layout ()
 { analyze_layout_in_grammar ();
   determine_layout_insertion_points ();
 }

canonical_original_code:
void analyze_layout()
 { analyze_layout_in_grammar ();
   determine_layout_insertion_points ();
 }


original_code:
static void detect_call_in_member (rule srule, member m)
 { if (m -> tag == 0)
      { int rulenumber = srule -> number;
        rule callee = m -> u.call.def;
        if (!callee -> ext)
           calls_left [callee -> number * nr_of_rules + rulenumber] = 1;
      };
 }

canonical_original_code:
static void detect_call_in_member(struct rule_rec *srule, struct member_rec *m)
 { if (m -> tag == 0)
      { int rulenumber = srule -> number;
        struct rule_rec *callee = m -> u.call.def;
        if (!callee -> ext)
           calls_left [callee -> number * nr_of_rules + rulenumber] = 1;
      };
 }

variable_types:
m
struct member_rec *

variable_types: rulenumber int

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct int_list_rec { int size; int room; int *array; }

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

user_defined_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }

user_defined_types: struct element_set_rec { int number; struct element_def_list_rec *defs; }


decompiled_code:
_DWORD *detect_calls_in_rules()
{
__int64 v0; // rbx
_DWORD *result; // rax

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = detect_calls_in_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

canonical_decompiled_code:
_DWORD *func1()
{
__int64 v0; // rbx
_DWORD *result; // rax

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = detect_calls_in_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

original_code:
static void detect_calls_in_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      detect_calls_in_rule (all_rules[ix]);
 }

canonical_original_code:
static void detect_calls_in_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      detect_calls_in_rule (all_rules[ix]);
 }


decompiled_code:
void try_report_primary_lc_relation()
{
__int64 v0; // r12
int v1; // eax
__int64 v2; // rbx
const char *v3; // r13

if ( full_verbose )
{
warning("Dump of primary lc relation:");
if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
{
v3 = **(const char ***)(all_rules + 8 * v0);
v1 = nr_of_rules;
if ( nr_of_rules > 0 )
{
v2 = 0LL;
do
{
if ( leftc_relation[(int)v2 + (int)v0 * v1] )
warning("rule %s <LC+ rule %s", v3, **(const char ***)(all_rules + 8 * v2));
v1 = nr_of_rules;
++v2;
}
while ( nr_of_rules > (int)v2 );
}
++v0;
}
while ( nr_of_rules > (int)v0 );
}
}
}

canonical_decompiled_code:
void func2()
{
__int64 v0; // r12
int v1; // eax
__int64 v2; // rbx
const char *v3; // r13

if ( full_verbose )
{
warning("Dump of primary lc relation:");
if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
{
v3 = **(const char ***)(all_rules + 8 * v0);
v1 = nr_of_rules;
if ( nr_of_rules > 0 )
{
v2 = 0LL;
do
{
if ( leftc_relation[(int)v2 + (int)v0 * v1] )
warning("rule %s <LC+ rule %s", v3, **(const char ***)(all_rules + 8 * v2));
v1 = nr_of_rules;
++v2;
}
while ( nr_of_rules > (int)v2 );
}
++v0;
}
while ( nr_of_rules > (int)v0 );
}
}
}

original_code:
static void try_report_primary_lc_relation ()
 { int i,j;
   if (!full_verbose) return;
   warning ("Dump of primary lc relation:");
   for (i = 0; i < nr_of_rules; i++)
      { string nont_i = all_rules[i] -> nonterminal;
        for (j = 0; j < nr_of_rules; j++)
    if (leftc_relation [i * nr_of_rules + j])
       { string nont_j = all_rules[j] -> nonterminal;
         warning ("rule %s <LC+ rule %s", nont_i, nont_j);
       };
      };
 }

canonical_original_code:
static void try_report_primary_lc_relation()
 { int i; int j;
   if (!full_verbose) return;
   warning ("Dump of primary lc relation:");
   for (i = 0; i < nr_of_rules; i++)
      { char *nont_i = all_rules[i] -> nonterminal;
        for (j = 0; j < nr_of_rules; j++)
    if (leftc_relation [i * nr_of_rules + j])
       { char *nont_j = all_rules[j] -> nonterminal;
         warning ("rule %s <LC+ rule %s", nont_i, nont_j);
       };
      };
 }


decompiled_code:
__int64 allocate_space_for_mcalls()
{
__int64 result; // rax
__int64 v1; // rsi
int i; // ecx
int j; // edx

result = ckcalloc((unsigned int)(nr_of_meta_rules * nr_of_meta_rules), 1LL);
v1 = result;
mcalls_left = result;
for ( i = 0; nr_of_meta_rules > i; ++i )
{
result = nr_of_meta_rules;
for ( j = 0; nr_of_meta_rules > j; result = nr_of_meta_rules )
{
*(_BYTE *)(v1 + j + i * (int)result) = 0;
++j;
}
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
__int64 v1; // rsi
int i; // ecx
int j; // edx

result = ckcalloc((unsigned int)(nr_of_meta_rules * nr_of_meta_rules), 1LL);
v1 = result;
mcalls_left = result;
for ( i = 0; nr_of_meta_rules > i; ++i )
{
result = nr_of_meta_rules;
for ( j = 0; nr_of_meta_rules > j; result = nr_of_meta_rules )
{
*(_BYTE *)(v1 + j + i * (int)result) = 0;
++j;
}
}
return result;
}

original_code:
static void allocate_space_for_mcalls ()
 { int i,j;
   mcalls_left = (char *) ckcalloc (nr_of_meta_rules * nr_of_meta_rules, sizeof (char));
   for (i=0; i < nr_of_meta_rules; i++)
      for (j=0; j < nr_of_meta_rules; j++)
  mcalls_left[i * nr_of_meta_rules + j] = 0;
 }

canonical_original_code:
static void allocate_space_for_mcalls()
 { int i; int j;
   mcalls_left = (char *) ckcalloc (nr_of_meta_rules * nr_of_meta_rules, sizeof (char));
   for (i=0; i < nr_of_meta_rules; i++)
      for (j=0; j < nr_of_meta_rules; j++)
  mcalls_left[i * nr_of_meta_rules + j] = 0;
 }


decompiled_code:
__int64 allocate_space_for_calls()
{
__int64 result; // rax
__int64 v1; // rsi
int i; // ecx
int j; // edx

result = ckcalloc((unsigned int)(nr_of_rules * nr_of_rules), 1LL);
v1 = result;
calls_left = result;
for ( i = 0; nr_of_rules > i; ++i )
{
result = nr_of_rules;
for ( j = 0; nr_of_rules > j; result = nr_of_rules )
{
*(_BYTE *)(v1 + j + i * (int)result) = 0;
++j;
}
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
__int64 v1; // rsi
int i; // ecx
int j; // edx

result = ckcalloc((unsigned int)(nr_of_rules * nr_of_rules), 1LL);
v1 = result;
calls_left = result;
for ( i = 0; nr_of_rules > i; ++i )
{
result = nr_of_rules;
for ( j = 0; nr_of_rules > j; result = nr_of_rules )
{
*(_BYTE *)(v1 + j + i * (int)result) = 0;
++j;
}
}
return result;
}

original_code:
static void allocate_space_for_calls ()
 { int i,j;
   calls_left = (char *) ckcalloc (nr_of_rules * nr_of_rules, sizeof (char));
   for (i=0; i < nr_of_rules; i++)
      for (j = 0; j < nr_of_rules; j++)
         calls_left[i * nr_of_rules + j] = 0;
 }

canonical_original_code:
static void allocate_space_for_calls()
 { int i; int j;
   calls_left = (char *) ckcalloc (nr_of_rules * nr_of_rules, sizeof (char));
   for (i=0; i < nr_of_rules; i++)
      for (j = 0; j < nr_of_rules; j++)
         calls_left[i * nr_of_rules + j] = 0;
 }


decompiled_code:
__int64 __fastcall detect_lcall_in_affix(__int64 a1, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // rcx
__int64 result; // rax
__int64 v6; // rcx

v3 = *(unsigned int *)(a2 + 40);
switch ( (int)v3 )
{
case 0:
v4 = *(_QWORD *)(a2 + 64);
*(_BYTE *)(mcalls_left + *(_DWORD *)(v4 + 32) + *(_DWORD *)(a1 + 32) * nr_of_meta_rules) = 1;
result = *(_DWORD *)(v4 + 28) == 1;
break;
case 1:
result = **(_BYTE **)(a2 + 48) == 0;
break;
case 2:
result = *(_DWORD *)(a2 + 48) <= 0;
break;
case 3:
result = *(double *)(a2 + 48) <= 0.0;
break;
case 4:
v6 = *(_QWORD *)(a2 + 48);
result = *(_DWORD *)v6 & 4;
if ( (*(_DWORD *)v6 & 4) != 0 )
{
result = 1LL;
}
else if ( (*(_DWORD *)v6 & 8) == 0 )
{
result = **(_BYTE **)(v6 + 8) == 0;
}
break;
case 5:
result = 0LL;
break;
default:
bad_tag(v3, "detect_lcall_in_affix");
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // rcx
__int64 result; // rax
__int64 v6; // rcx

v3 = *(unsigned int *)(a2 + 40);
switch ( (int)v3 )
{
case 0:
v4 = *(_QWORD *)(a2 + 64);
*(_BYTE *)(mcalls_left + *(_DWORD *)(v4 + 32) + *(_DWORD *)(a1 + 32) * nr_of_meta_rules) = 1;
result = *(_DWORD *)(v4 + 28) == 1;
break;
case 1:
result = **(_BYTE **)(a2 + 48) == 0;
break;
case 2:
result = *(_DWORD *)(a2 + 48) <= 0;
break;
case 3:
result = *(double *)(a2 + 48) <= 0.0;
break;
case 4:
v6 = *(_QWORD *)(a2 + 48);
result = *(_DWORD *)v6 & 4;
if ( (*(_DWORD *)v6 & 4) != 0 )
{
result = 1LL;
}
else if ( (*(_DWORD *)v6 & 8) == 0 )
{
result = **(_BYTE **)(v6 + 8) == 0;
}
break;
case 5:
result = 0LL;
break;
default:
bad_tag(v3, "detect_lcall_in_affix");
result = 0LL;
break;
}
return result;
}

original_code:
static int detect_lcall_in_affix (meta_rule mrule, affix a)
 { switch (a -> tag)
      { case 0:
    { meta_rule def = a -> u.var.def;
      int rulenumber = mrule -> number;
      int calleenumber = def -> number;
      mcalls_left [rulenumber * nr_of_meta_rules + calleenumber] = 1;
      return (def -> empty == 1);
    };
        case 1: return (strlen (a -> u.str) == 0);
        case 2: return (a -> u.inum <= 0);
        case 3: return (a -> u.rnum <= 0.0);
        case 4:
    { cset set = a -> u.semi;
      return ((set -> kind & 4) ||
       (!(set -> kind & 8) && (strlen (set -> str) == 0)));
    };
        case 5: return (0);
        default: bad_tag (a -> tag, "detect_lcall_in_affix");
      };
   return (0);
 }

canonical_original_code:
static int detect_lcall_in_affix(struct meta_rule_rec *mrule, struct affix_rec *a)
 { switch (a -> tag)
      { case 0:
    { struct meta_rule_rec *def = a -> u.var.def;
      int rulenumber = mrule -> number;
      int calleenumber = def -> number;
      mcalls_left [rulenumber * nr_of_meta_rules + calleenumber] = 1;
      return (def -> empty == 1);
    };
        case 1: return (strlen (a -> u.str) == 0);
        case 2: return (a -> u.inum <= 0);
        case 3: return (a -> u.rnum <= 0.0);
        case 4:
    { struct cset_rec *set = a -> u.semi;
      return ((set -> kind & 4) ||
       (!(set -> kind & 8) && (strlen (set -> str) == 0)));
    };
        case 5: return (0);
        default: bad_tag (a -> tag, "detect_lcall_in_affix");
      };
   return (0);
 }

variable_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; } *

variable_types:
a
struct affix_rec *

variable_types: calleenumber int

user_defined_types: struct meta_alt_rec { struct expr_rec *e; int number; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }


decompiled_code:
__int64 __fastcall detect_lcalls_in_concat(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = 0LL;
do
{
result = detect_lcall_in_affix(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * v2));
if ( !(_DWORD)result )
break;
++v2;
}
while ( *(_DWORD *)a2 > (int)v2 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = 0LL;
do
{
result = func5(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * v2));
if ( !(_DWORD)result )
break;
++v2;
}
while ( *(_DWORD *)a2 > (int)v2 );
return result;
}

original_code:
static void detect_lcalls_in_concat (meta_rule mrule, affix_list affs)
 { int ix = 0;
   int empty;
   do
      { empty = detect_lcall_in_affix (mrule, affs -> array[ix]);
        ix++;
      }
   while (empty && (ix < affs -> size));
 }

canonical_original_code:
static void detect_lcalls_in_concat(struct meta_rule_rec *mrule, struct affix_list_rec *affs)
 { int ix = 0;
   int empty;
   do
      { empty = detect_lcall_in_affix (mrule, affs -> array[ix]);
        ix++;
      }
   while (empty && (ix < affs -> size));
 }

variable_types:
affs
struct affix_list_rec *

variable_types: empty int

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

user_defined_types: struct cset_rec { int kind; char *str; }

user_defined_types: struct value_list_rec { int size; int room; struct value_rec **array; }

user_defined_types: struct element_def_list_rec { int size; int room; struct element_def_rec **array; }


decompiled_code:
void __fastcall detect_lcalls_in_meta_alt(__int64 a1, __int64 a2)
{
if ( a2 )
{
if ( *(_DWORD *)a2 == 1 )
{
detect_lcall_in_affix(a1, *(_QWORD *)(a2 + 8));
}
else if ( *(_DWORD *)a2 == 3 )
{
detect_lcalls_in_concat(a1, *(_QWORD *)(a2 + 8));
}
else
{
internal_error("detect lcalls in meta alt");
}
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, __int64 a2)
{
if ( a2 )
{
if ( *(_DWORD *)a2 == 1 )
{
func5(a1, *(_QWORD *)(a2 + 8));
}
else if ( *(_DWORD *)a2 == 3 )
{
func6(a1, *(_QWORD *)(a2 + 8));
}
else
{
internal_error("detect lcalls in meta alt");
}
}
}

original_code:
static void detect_lcalls_in_meta_alt (meta_rule mrule, expr e)
 { if (e == ((expr) ((void *)0))) return;
   switch (e -> tag)
      { case 1:
    (void) detect_lcall_in_affix (mrule, e -> u.single);
    break;
        case 3:
    detect_lcalls_in_concat (mrule, e -> u.concat);
           break;
        default:
    internal_error ("detect lcalls in meta alt");
      };
 }

canonical_original_code:
static void detect_lcalls_in_meta_alt(struct meta_rule_rec *mrule, struct expr_rec *e)
 { if (e == ((expr) ((void *)0))) return;
   switch (e -> tag)
      { case 1:
    (void) detect_lcall_in_affix (mrule, e -> u.single);
    break;
        case 3:
    detect_lcalls_in_concat (mrule, e -> u.concat);
           break;
        default:
    internal_error ("detect lcalls in meta alt");
      };
 }

variable_types:
e
struct expr_rec *

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }


decompiled_code:
void __fastcall detect_lcalls_in_meta_alts(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

if ( a2 && *(int *)a2 > 0 )
{
v2 = 0LL;
do
detect_lcalls_in_meta_alt(a1, **(_QWORD **)(*(_QWORD *)(a2 + 8) + 8 * v2++));
while ( *(_DWORD *)a2 > (int)v2 );
}
}

original_code:
static void detect_lcalls_in_meta_alts (meta_rule mrule, meta_alt_list alts)
 { int ix;
   if (alts == ((meta_alt_list) ((void *)0))) return;
   for (ix = 0; ix < alts -> size; ix++)
      detect_lcalls_in_meta_alt (mrule, alts -> array[ix] -> e);
 }

canonical_original_code:
static void detect_lcalls_in_meta_alts(struct meta_rule_rec *mrule, struct meta_alt_list_rec *alts)
 { int ix;
   if (alts == ((meta_alt_list) ((void *)0))) return;
   for (ix = 0; ix < alts -> size; ix++)
      detect_lcalls_in_meta_alt (mrule, alts -> array[ix] -> e);
 }

variable_types:
alts
struct meta_alt_list_rec *


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

if ( !*(_DWORD *)(a1 + 16) )
{
v1 = *(_DWORD *)(a1 + 20);
if ( v1 )
{
if ( (v1 & 0x18) == 0 )
detect_lcalls_in_meta_alts(a1, *(_QWORD *)(a1 + 8));
}
}
}

original_code:
static void detect_lcalls_in_metarule (meta_rule mrule)
 { if (mrule -> ext) return;
   if (mrule -> type == 0) return;
   if (mrule -> type & 16) return;
   if (mrule -> type & 8) return;
   detect_lcalls_in_meta_alts (mrule, mrule -> alts);
 }

canonical_original_code:
static void detect_lcalls_in_metarule(struct meta_rule_rec *mrule)
 { if (mrule -> ext) return;
   if (mrule -> type == 0) return;
   if (mrule -> type & 16) return;
   if (mrule -> type & 8) return;
   detect_lcalls_in_meta_alts (mrule, mrule -> alts);
 }


decompiled_code:
void detect_lcalls_in_metarules()
{
__int64 v0; // rbx

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
detect_lcalls_in_metarule(*(_QWORD *)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
}

canonical_decompiled_code:
void func10()
{
__int64 v0; // rbx

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
func9(*(_QWORD *)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
}

original_code:
static void detect_lcalls_in_metarules ()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      detect_lcalls_in_metarule (all_meta_rules[ix]);
 }

canonical_original_code:
static void detect_lcalls_in_metarules()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      detect_lcalls_in_metarule (all_meta_rules[ix]);
 }


decompiled_code:
char *take_lcalls_closure()
{
char *result; // rax

result = (char *)warshall(nr_of_meta_rules, mcalls_left);
mcalls_left_closure = result;
return result;
}

canonical_decompiled_code:
char *func11()
{
char *result; // rax

result = (char *)warshall(nr_of_meta_rules, mcalls_left);
mcalls_left_closure = result;
return result;
}

original_code:
static void take_lcalls_closure ()
 { mcalls_left_closure = warshall (nr_of_meta_rules, mcalls_left);
 }

canonical_original_code:
static void take_lcalls_closure()
 { mcalls_left_closure = warshall (nr_of_meta_rules, mcalls_left);
 }


decompiled_code:
char *take_calls_closure()
{
char *result; // rax

result = (char *)warshall(nr_of_rules, calls_left);
leftc_relation = result;
return result;
}

canonical_decompiled_code:
char *func12()
{
char *result; // rax

result = (char *)warshall(nr_of_rules, calls_left);
leftc_relation = result;
return result;
}

original_code:
static void take_calls_closure ()
 { leftc_relation = warshall (nr_of_rules, calls_left);
 }

canonical_original_code:
static void take_calls_closure()
 { leftc_relation = warshall (nr_of_rules, calls_left);
 }


decompiled_code:
__int64 complain_on_leftrecursive_meta_rules()
{
__int64 result; // rax
__int64 v1; // rbx
int v2; // ebp
const char *v3; // rdx

result = nr_of_meta_rules;
if ( nr_of_meta_rules > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
if ( mcalls_left_closure[(int)v1 + (int)v1 * (int)result] )
{
error((int)"meta rule %s is left recursive", **(_QWORD **)(all_meta_rules + 8 * v1), mcalls_left_closure);
++v2;
}
result = nr_of_meta_rules;
++v1;
}
while ( nr_of_meta_rules > (int)v1 );
if ( v2 )
{
v3 = "s";
if ( v2 <= 1 )
v3 = (const char *)&unk_694;
result = panic("found %d left recursive meta rule%s", (unsigned int)v2, v3);
}
}
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 result; // rax
__int64 v1; // rbx
int v2; // ebp
const char *v3; // rdx

result = nr_of_meta_rules;
if ( nr_of_meta_rules > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
if ( mcalls_left_closure[(int)v1 + (int)v1 * (int)result] )
{
error((int)"meta rule %s is left recursive", **(_QWORD **)(all_meta_rules + 8 * v1), mcalls_left_closure);
++v2;
}
result = nr_of_meta_rules;
++v1;
}
while ( nr_of_meta_rules > (int)v1 );
if ( v2 )
{
v3 = "s";
if ( v2 <= 1 )
v3 = (const char *)&unk_694;
result = panic("found %d left recursive meta rule%s", (unsigned int)v2, v3);
}
}
return result;
}

original_code:
static void complain_on_leftrecursive_meta_rules ()
 { int ix;
   int leftrecursive = 0;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      if (mcalls_left_closure [ix * nr_of_meta_rules + ix])
  { error ("meta rule %s is left recursive",
    all_meta_rules[ix] -> nonterminal);
    leftrecursive++;
  };
   if (leftrecursive)
      panic ("found %d left recursive meta rule%s", leftrecursive,
      (leftrecursive > 1)?"s":"");
 }

canonical_original_code:
static void complain_on_leftrecursive_meta_rules()
 { int ix;
   int leftrecursive = 0;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      if (mcalls_left_closure [ix * nr_of_meta_rules + ix])
  { error ("meta rule %s is left recursive",
    all_meta_rules[ix] -> nonterminal);
    leftrecursive++;
  };
   if (leftrecursive)
      panic ("found %d left recursive meta rule%s", leftrecursive,
      (leftrecursive > 1)?"s":"");
 }

variable_types: leftrecursive int


decompiled_code:
__int64 complain_on_left_recursive_rules()
{
__int64 result; // rax
__int64 v1; // rbx
int v2; // ebp
const char *v3; // rdx

result = nr_of_rules;
if ( nr_of_rules > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
if ( leftc_relation[(int)v1 + (int)v1 * (int)result] )
{
error((int)"rule %s is left recursive", **(_QWORD **)(all_rules + 8 * v1), leftc_relation);
++v2;
}
result = nr_of_rules;
++v1;
}
while ( nr_of_rules > (int)v1 );
if ( v2 )
{
v3 = "s";
if ( v2 <= 1 )
v3 = (const char *)&unk_694;
result = panic("found %d left recursive rule%s", (unsigned int)v2, v3);
}
}
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 result; // rax
__int64 v1; // rbx
int v2; // ebp
const char *v3; // rdx

result = nr_of_rules;
if ( nr_of_rules > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
if ( leftc_relation[(int)v1 + (int)v1 * (int)result] )
{
error((int)"rule %s is left recursive", **(_QWORD **)(all_rules + 8 * v1), leftc_relation);
++v2;
}
result = nr_of_rules;
++v1;
}
while ( nr_of_rules > (int)v1 );
if ( v2 )
{
v3 = "s";
if ( v2 <= 1 )
v3 = (const char *)&unk_694;
result = panic("found %d left recursive rule%s", (unsigned int)v2, v3);
}
}
return result;
}

original_code:
static void complain_on_left_recursive_rules ()
 { int i;
   int leftrecursive = 0;
   for (i = 0; i < nr_of_rules; i++)
      if (leftc_relation [i * nr_of_rules + i])
         { rule srule = all_rules[i];
           error ("rule %s is left recursive", srule -> nonterminal);
    leftrecursive ++;
  };
   if (leftrecursive)
      panic ("found %d left recursive rule%s", leftrecursive,
      (leftrecursive > 1)?"s":"");
 }

canonical_original_code:
static void complain_on_left_recursive_rules()
 { int i;
   int leftrecursive = 0;
   for (i = 0; i < nr_of_rules; i++)
      if (leftc_relation [i * nr_of_rules + i])
         { struct rule_rec *srule = all_rules[i];
           error ("rule %s is left recursive", srule -> nonterminal);
    leftrecursive ++;
  };
   if (leftrecursive)
      panic ("found %d left recursive rule%s", leftrecursive,
      (leftrecursive > 1)?"s":"");
 }

variable_types: i int

variable_types: struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { struct pos_list_rec { int size; int room; struct pos_rec { int kind; struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *ex; int type; struct element_def_rec *lat_repr; } **array; } *display; struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }


decompiled_code:
void check_recursion()
{
warning("detecting left recursive meta rules...");
allocate_space_for_mcalls();
detect_lcalls_in_metarules();
take_lcalls_closure();
complain_on_leftrecursive_meta_rules();
warning("computing primary leftcorner relation...");
allocate_space_for_calls();
detect_calls_in_rules();
take_calls_closure();
try_report_primary_lc_relation();
if ( topdown )
complain_on_left_recursive_rules();
}

canonical_decompiled_code:
void func15()
{
warning("detecting left recursive meta rules...");
func3();
func10();
func11();
func13();
warning("computing primary leftcorner relation...");
func4();
func1();
func12();
func2();
if ( topdown )
func14();
}

original_code:
void check_recursion ()
 { warning ("detecting left recursive meta rules...");
   allocate_space_for_mcalls ();
   detect_lcalls_in_metarules ();
   take_lcalls_closure ();
   complain_on_leftrecursive_meta_rules ();
   warning ("computing primary leftcorner relation...");
   allocate_space_for_calls ();
   detect_calls_in_rules ();
   take_calls_closure ();
   try_report_primary_lc_relation ();
   if (!topdown) return;
   complain_on_left_recursive_rules ();
 }

canonical_original_code:
void check_recursion()
 { warning ("detecting left recursive meta rules...");
   allocate_space_for_mcalls ();
   detect_lcalls_in_metarules ();
   take_lcalls_closure ();
   complain_on_leftrecursive_meta_rules ();
   warning ("computing primary leftcorner relation...");
   allocate_space_for_calls ();
   detect_calls_in_rules ();
   take_calls_closure ();
   try_report_primary_lc_relation ();
   if (!topdown) return;
   complain_on_left_recursive_rules ();
 }


decompiled_code:
__int64 __fastcall char_in_set(char a1, char *a2)
{
char v2; // al

v2 = *a2;
if ( !*a2 )
return 0LL;
while ( a1 != v2 )
{
v2 = *++a2;
if ( !*a2 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, char *a2)
{
char v2; // al

v2 = *a2;
if ( !*a2 )
return 0LL;
while ( a1 != v2 )
{
v2 = *++a2;
if ( !*a2 )
return 0LL;
}
return 1LL;
}

original_code:
static int char_in_set (char c, char *s)
 { register char *sptr;
   for (sptr = s; *sptr; sptr++)
      if (c == *sptr) return (1);
   return (0);
 }

canonical_original_code:
static int char_in_set(char c, char *s)
 { register char *sptr;
   for (sptr = s; *sptr; sptr++)
      if (c == *sptr) return (1);
   return (0);
 }

variable_types: c char

variable_types:
s
char *

variable_types:
sptr
char *


decompiled_code:
__int64 __fastcall addcharto_set(unsigned __int8 *a1, unsigned __int8 a2)
{
__int64 result; // rax

result = *a1;
if ( (_BYTE)result )
{
while ( a2 != (_BYTE)result )
{
result = *++a1;
if ( !(_BYTE)result )
goto LABEL_4;
}
}
else
{
LABEL_4:
*a1 = a2;
a1[1] = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, unsigned __int8 a2)
{
__int64 result; // rax

result = *a1;
if ( (_BYTE)result )
{
while ( a2 != (_BYTE)result )
{
result = *++a1;
if ( !(_BYTE)result )
goto LABEL_4;
}
}
else
{
LABEL_4:
*a1 = a2;
a1[1] = 0;
}
return result;
}

original_code:
static void addcharto_set (char *dst, char c)
 { char *dptr;
   for (dptr = dst; *dptr; dptr++)
      if (*dptr == c) return;
   *dptr++ = c;
   *dptr = '\0';
 }

canonical_original_code:
static void addcharto_set(char *dst, char c)
 { char *dptr;
   for (dptr = dst; *dptr; dptr++)
      if (*dptr == c) return;
   *dptr++ = c;
   *dptr = '\0';
 }

variable_types:
dst
char *

variable_types:
dptr
char *


decompiled_code:
__int64 __fastcall addto_set(unsigned __int8 *a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // rbx
unsigned __int8 v3; // si
__int64 result; // rax

if ( a2 )
{
v2 = a2;
v3 = *a2;
if ( v3 )
{
do
{
result = addcharto_set(a1, v3);
v3 = *++v2;
}
while ( *v2 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // rbx
unsigned __int8 v3; // si
__int64 result; // rax

if ( a2 )
{
v2 = a2;
v3 = *a2;
if ( v3 )
{
do
{
result = func1(a1, v3);
v3 = *++v2;
}
while ( *v2 );
}
}
return result;
}

original_code:
static void addto_set (char *dst, char *src)
 { char *sptr;
   if (src == ((string) ((void *)0))) return;
   for (sptr = src; *sptr; sptr++)
      addcharto_set (dst, *sptr);
 }

canonical_original_code:
static void addto_set(char *dst, char *src)
 { char *sptr;
   if (src == ((string) ((void *)0))) return;
   for (sptr = src; *sptr; sptr++)
      addcharto_set (dst, *sptr);
 }

variable_types:
src
char *