original_code:
void merge_sort_recurse(void *a[],
   void *w[],
   int start,
   int end,
   Ordertype (*comp_proc) (void *, void *))
{
  int mid, i, i1, i2, e1, e2;
  if (start < end) {
    mid = (start+end)/2;
    merge_sort_recurse(a, w, start, mid, comp_proc);
    merge_sort_recurse(a, w, mid+1, end, comp_proc);
    i1 = start; e1 = mid;
    i2 = mid+1; e2 = end;
    i = start;
    while (i1 <= e1 && i2 <= e2) {
      if ((*comp_proc)(a[i1], a[i2]) == GREATER_THAN)
 w[i++] = a[i2++];
      else
 w[i++] = a[i1++];
    }
    if (i2 > e2)
      while (i1 <= e1)
 w[i++] = a[i1++];
    else
      while (i2 <= e2)
 w[i++] = a[i2++];
    for (i = start; i <= end; i++)
      a[i] = w[i];
  }
}

canonical_original_code:
void merge_sort_recurse(void *a[], void *w[], int start, int end, enum Ordertype (*comp_proc)(void *, void *))
{
  int mid; int i; int i1; int i2; int e1; int e2;
  if (start < end) {
    mid = (start+end)/2;
    merge_sort_recurse(a, w, start, mid, comp_proc);
    merge_sort_recurse(a, w, mid+1, end, comp_proc);
    i1 = start; e1 = mid;
    i2 = mid+1; e2 = end;
    i = start;
    while (i1 <= e1 && i2 <= e2) {
      if ((*comp_proc)(a[i1], a[i2]) == GREATER_THAN)
 w[i++] = a[i2++];
      else
 w[i++] = a[i1++];
    }
    if (i2 > e2)
      while (i1 <= e1)
 w[i++] = a[i1++];
    else
      while (i2 <= e2)
 w[i++] = a[i2++];
    for (i = start; i <= end; i++)
      a[i] = w[i];
  }
}

variable_types:
a
void *[]

variable_types:
w
void *[]

variable_types: start int

variable_types: end int

variable_types: enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 } (*)(void *, void *)

variable_types: mid int


repo: jessealama/ladr

decompiled_code:
void __fastcall merge_sort(__int64 a1, int a2, unsigned int (__fastcall *a3)(_QWORD, _QWORD))
{
void *v4; // rbp

v4 = malloc(8LL * a2);
merge_sort_recurse(a1, (__int64)v4, 0, a2 - 1, a3);
free(v4);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, int a2, unsigned int (__fastcall *a3)(_QWORD, _QWORD))
{
void *v4; // rbp

v4 = malloc(8LL * a2);
func0(a1, (__int64)v4, 0, a2 - 1, a3);
free(v4);
}

original_code:
void merge_sort(void *a[],
  int n,
  Ordertype (*comp_proc) (void *, void *))
{
  void **work = malloc(n * sizeof(void *));
  merge_sort_recurse((void **) a, work, 0, n-1, comp_proc);
  free(work);
}

canonical_original_code:
void merge_sort(void *a[], int n, enum Ordertype (*comp_proc)(void *, void *))
{
  void **work = malloc(n * sizeof(void *));
  merge_sort_recurse((void **) a, work, 0, n-1, comp_proc);
  free(work);
}

variable_types: n int

variable_types:
work
void **

return_type: void

user_defined_types: enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 }


decompiled_code:
__int64 __fastcall compare_vecs(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // rsi
__int64 v5; // rax
int v6; // ecx
int v7; // edx

if ( a3 <= 0 )
return 1LL;
v4 = (unsigned int)a3;
v5 = 0LL;
while ( 1 )
{
v6 = *(_DWORD *)(a1 + 4 * v5);
v7 = *(_DWORD *)(a2 + 4 * v5);
if ( v6 < v7 )
return 2LL;
if ( v6 > v7 )
break;
if ( ++v5 == v4 )
return 1LL;
}
return 3LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // rsi
__int64 v5; // rax
int v6; // ecx
int v7; // edx

if ( a3 <= 0 )
return 1LL;
v4 = (unsigned int)a3;
v5 = 0LL;
while ( 1 )
{
v6 = *(_DWORD *)(a1 + 4 * v5);
v7 = *(_DWORD *)(a2 + 4 * v5);
if ( v6 < v7 )
return 2LL;
if ( v6 > v7 )
break;
if ( ++v5 == v4 )
return 1LL;
}
return 3LL;
}

canonical_original_code:
enum Ordertype compare_vecs(int *a, int *b, int n)
{
  int i;
  for (i = 0; i < n; i++) {
    if (a[i] < b[i])
      return LESS_THAN;
    else if (a[i] > b[i])
      return GREATER_THAN;
  }
  return SAME_AS;
}

variable_types:
a
int *

variable_types:
b
int *

variable_types: i int

return_type: enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 }


original_code:
void copy_vec(int *a, int *b, int n)
{
  int i;
  for (i = 0; i < n; i++)
    b[i] = a[i];
}


decompiled_code:
int p_flatterm_mem()
{
return fprint_flatterm_mem(stdout, 1);
}

canonical_decompiled_code:
int func3()
{
return func2(stdout, 1);
}

original_code:
void p_flatterm_mem()
{
  fprint_flatterm_mem(stdout, TRUE);
}


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

result = get_mem(6LL);
++Jnode_gets;
return result;
}

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

result = get_mem(6LL);
++Jnode_gets;
return result;
}

original_code:
Jnode get_jnode(void)
{
  Jnode p = get_mem(((sizeof(struct jnode))%(sizeof(void *)) == 0 ? (sizeof(struct jnode))/(sizeof(void *)) : (sizeof(struct jnode))/(sizeof(void *)) + 1));
  Jnode_gets++;
  return(p);
}

canonical_original_code:
struct jnode *get_jnode()
{
  struct jnode *p = get_mem(((sizeof(struct jnode))%(sizeof(void *)) == 0 ? (sizeof(struct jnode))/(sizeof(void *)) : (sizeof(struct jnode))/(sizeof(void *)) + 1));
  Jnode_gets++;
  return(p);
}

variable_types: struct jnode { int type; int id; struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *alpha; struct term *beta; int pos; struct jnode *prev; struct jnode *next; } *

user_defined_types: struct jnode { int type; int id; struct term *alpha; struct term *beta; int pos; struct jnode *prev; struct jnode *next; }


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

result = free_mem(a1, 6LL);
++Jnode_frees;
return result;
}

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

result = free_mem(a1, 6LL);
++Jnode_frees;
return result;
}

original_code:
void free_jnode(Jnode p)
{
  free_mem(p, ((sizeof(struct jnode))%(sizeof(void *)) == 0 ? (sizeof(struct jnode))/(sizeof(void *)) : (sizeof(struct jnode))/(sizeof(void *)) + 1));
  Jnode_frees++;
}

canonical_original_code:
void free_jnode(struct jnode *p)
{
  free_mem(p, ((sizeof(struct jnode))%(sizeof(void *)) == 0 ? (sizeof(struct jnode))/(sizeof(void *)) : (sizeof(struct jnode))/(sizeof(void *)) + 1));
  Jnode_frees++;
}

user_defined_types: struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; }


decompiled_code:
int p_mstate_mem()
{
return fprint_mstate_mem(stdout, 1);
}

canonical_decompiled_code:
int func5()
{
return func4(stdout, 1);
}

original_code:
void p_mstate_mem()
{
  fprint_mstate_mem(stdout, TRUE);
}


decompiled_code:
__int64 next_clause_id()
{
return (unsigned int)++Topform_id_count;
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)++Topform_id_count;
}

original_code:
static
int next_clause_id(void)
{
  return ++Topform_id_count;
}

canonical_original_code:
static int next_clause_id()
{
  return ++Topform_id_count;
}

return_type: int


decompiled_code:
__int64 clause_ids_assigned()
{
return (unsigned int)Topform_id_count;
}

canonical_decompiled_code:
__int64 func1()
{
return (unsigned int)Topform_id_count;
}

original_code:
int clause_ids_assigned(void)
{
  return Topform_id_count;
}

canonical_original_code:
int clause_ids_assigned()
{
  return Topform_id_count;
}


decompiled_code:
int p_clause_id_tab()
{
return fprint_clause_id_tab(stdout);
}

canonical_decompiled_code:
int func5()
{
return func4(stdout);
}

original_code:
void p_clause_id_tab()
{
  fprint_clause_id_tab(stdout);
}


decompiled_code:
__int64 fast_parse()
{
++Pos;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
++Pos;
return 0LL;
}

original_code:
static
Term fast_parse(char *s)
{
  char c = s[Pos++];
  Term t;
  if (c >= 'r' && c <= 'z') {
    switch (c) {
    case 'z': t = get_variable_term(0); break;
    case 'y': t = get_variable_term(1); break;
    case 'x': t = get_variable_term(2); break;
    case 'w': t = get_variable_term(3); break;
    case 'v': t = get_variable_term(4); break;
    case 'u': t = get_variable_term(5); break;
    case 't': t = get_variable_term(6); break;
    case 's': t = get_variable_term(7); break;
    case 'r': t = get_variable_term(8); break;
    default: t = ((void *)0);
    }
    return t;
  }
  else {
    int i;
    if (Symnum[(int) c] == 0) {
      char str[2];
      str[0] = c; str[1] = '\0';
      Symnum[(int) c] = str_to_sn(str, 0);
    }
    t = get_rigid_term_dangerously(Symnum[(int) c], Arity[(int) c]);
    for (i = 0; i < Arity[(int) c]; i++) {
      ((t)->args[i]) = fast_parse(s);
    }
    return t;
  }
}

canonical_original_code:
static struct term *fast_parse(char *s)
{
  char c = s[Pos++];
  struct term *t;
  if (c >= 'r' && c <= 'z') {
    switch (c) {
    case 'z': t = get_variable_term(0); break;
    case 'y': t = get_variable_term(1); break;
    case 'x': t = get_variable_term(2); break;
    case 'w': t = get_variable_term(3); break;
    case 'v': t = get_variable_term(4); break;
    case 'u': t = get_variable_term(5); break;
    case 't': t = get_variable_term(6); break;
    case 's': t = get_variable_term(7); break;
    case 'r': t = get_variable_term(8); break;
    default: t = ((void *)0);
    }
    return t;
  }
  else {
    int i;
    if (Symnum[(int) c] == 0) {
      char str[2];
      str[0] = c; str[1] = '\0';
      Symnum[(int) c] = str_to_sn(str, 0);
    }
    t = get_rigid_term_dangerously(Symnum[(int) c], Arity[(int) c]);
    for (i = 0; i < Arity[(int) c]; i++) {
      ((t)->args[i]) = fast_parse(s);
    }
    return t;
  }
}

variable_types:
s
char *

variable_types: c char

variable_types: struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *

variable_types:
str
char [2]


decompiled_code:
__int64 __fastcall fast_set_symbol(char a1, __int64 a2)
{
__int64 result; // rax
char v3[10]; // [rsp+Eh] [rbp-Ah] BYREF

if ( (unsigned __int8)(a1 - 114) <= 8u )
return fatal_error("fast_set_symbol, r--z are variables and cannot be declared");
v3[0] = a1;
v3[1] = 0;
Arity[a1] = a2;
result = str_to_sn(v3, a2);
Symnum[a1] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1, __int64 a2)
{
__int64 result; // rax
char v3[10]; // [rsp+Eh] [rbp-Ah] BYREF

if ( (unsigned __int8)(a1 - 114) <= 8u )
return fatal_error("fast_set_symbol, r--z are variables and cannot be declared");
v3[0] = a1;
v3[1] = 0;
Arity[a1] = a2;
result = str_to_sn(v3, a2);
Symnum[a1] = result;
return result;
}

original_code:
void fast_set_symbol(char c, int arity)
{
  if (c >= 'r' && c <= 'z') {
    fatal_error("fast_set_symbol, r--z are variables and cannot be declared");
  }
  else {
    char str[2];
    str[0] = c;
    str[1] = '\0';
    Arity[(int) c] = arity;
    Symnum[(int) c] = str_to_sn(str, arity);
  }
}

variable_types: arity int


decompiled_code:
__int64 fast_set_defaults()
{
fast_set_symbol(61, 2LL);
fast_set_symbol(109, 2LL);
fast_set_symbol(106, 2LL);
fast_set_symbol(102, 2LL);
fast_set_symbol(100, 2LL);
fast_set_symbol(42, 2LL);
fast_set_symbol(43, 2LL);
fast_set_symbol(47, 2LL);
fast_set_symbol(99, 1LL);
fast_set_symbol(103, 1LL);
fast_set_symbol(105, 1LL);
fast_set_symbol(45, 1LL);
fast_set_symbol(126, 1LL);
return fast_set_symbol(39, 1LL);
}

original_code:
void fast_set_defaults(void)
{
  fast_set_symbol('=', 2);
  fast_set_symbol('m', 2);
  fast_set_symbol('j', 2);
  fast_set_symbol('f', 2);
  fast_set_symbol('d', 2);
  fast_set_symbol('*', 2);
  fast_set_symbol('+', 2);
  fast_set_symbol('/', 2);
  fast_set_symbol('c', 1);
  fast_set_symbol('g', 1);
  fast_set_symbol('i', 1);
  fast_set_symbol('-', 1);
  fast_set_symbol('~', 1);
  fast_set_symbol('\'', 1);
}

canonical_original_code:
void fast_set_defaults()
{
  fast_set_symbol('=', 2);
  fast_set_symbol('m', 2);
  fast_set_symbol('j', 2);
  fast_set_symbol('f', 2);
  fast_set_symbol('d', 2);
  fast_set_symbol('*', 2);
  fast_set_symbol('+', 2);
  fast_set_symbol('/', 2);
  fast_set_symbol('c', 1);
  fast_set_symbol('g', 1);
  fast_set_symbol('i', 1);
  fast_set_symbol('-', 1);
  fast_set_symbol('~', 1);
  fast_set_symbol('\'', 1);
}


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

result = free_mem(a1, 5LL);
++Clause_eval_frees;
return result;
}

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

result = free_mem(a1, 5LL);
++Clause_eval_frees;
return result;
}

original_code:
static
void free_clause_eval(Clause_eval p)
{
  free_mem(p, ((sizeof(struct clause_eval))%(sizeof(void *)) == 0 ? (sizeof(struct clause_eval))/(sizeof(void *)) : (sizeof(struct clause_eval))/(sizeof(void *)) + 1));
  Clause_eval_frees++;
}

canonical_original_code:
static void free_clause_eval(struct clause_eval *p)
{
  free_mem(p, ((sizeof(struct clause_eval))%(sizeof(void *)) == 0 ? (sizeof(struct clause_eval))/(sizeof(void *)) : (sizeof(struct clause_eval))/(sizeof(void *)) + 1));
  Clause_eval_frees++;
}

variable_types: struct clause_eval { int type; struct clause_eval *left; struct clause_eval *right; enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 } relation; double test_val; } *

user_defined_types: struct clause_eval { int type; struct clause_eval *left; struct clause_eval *right; enum Ordertype relation; double test_val; }


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

result = get_cmem(5LL);
++Clause_eval_gets;
return result;
}

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

result = get_cmem(5LL);
++Clause_eval_gets;
return result;
}

original_code:
static
Clause_eval get_clause_eval(void)
{
  Clause_eval p = get_cmem(((sizeof(struct clause_eval))%(sizeof(void *)) == 0 ? (sizeof(struct clause_eval))/(sizeof(void *)) : (sizeof(struct clause_eval))/(sizeof(void *)) + 1));
  Clause_eval_gets++;
  return(p);
}

canonical_original_code:
static struct clause_eval *get_clause_eval()
{
  struct clause_eval *p = get_cmem(((sizeof(struct clause_eval))%(sizeof(void *)) == 0 ? (sizeof(struct clause_eval))/(sizeof(void *)) : (sizeof(struct clause_eval))/(sizeof(void *)) + 1));
  Clause_eval_gets++;
  return(p);
}

return_type: struct clause_eval { int type; struct clause_eval *left; struct clause_eval *right; enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 } relation; double test_val; } *


decompiled_code:
__int64 __fastcall zap_clause_eval_rule(__int64 a1)
{
if ( *(_DWORD *)a1 <= 1u )
{
zap_clause_eval_rule(*(_QWORD *)(a1 + 8));
zap_clause_eval_rule(*(_QWORD *)(a1 + 16));
}
return free_clause_eval(a1);
}

original_code:
void zap_clause_eval_rule(Clause_eval p)
{
  if (p->type == CL_EVAL_AND || p->type == CL_EVAL_OR) {
    zap_clause_eval_rule(p->left);
    zap_clause_eval_rule(p->right);
  }
  else if (p->type == CL_EVAL_OR)
    zap_clause_eval_rule(p->left);
  free_clause_eval(p);
}

canonical_original_code:
void zap_clause_eval_rule(struct clause_eval *p)
{
  if (p->type == CL_EVAL_AND || p->type == CL_EVAL_OR) {
    zap_clause_eval_rule(p->left);
    zap_clause_eval_rule(p->right);
  }
  else if (p->type == CL_EVAL_OR)
    zap_clause_eval_rule(p->left);
  free_clause_eval(p);
}


decompiled_code:
__int64 __fastcall compile_clause_eval_rule(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
_QWORD *v8; // rax
__int64 v9; // r12
__int64 v10; // r13

v1 = get_clause_eval();
if ( (unsigned int)is_term(a1, asc_8A0, 2LL) )
{
*(_DWORD *)v1 = 0;
v2 = compile_clause_eval_rule(**(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 8) = v2;
if ( v2 )
{
v3 = compile_clause_eval_rule(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
*(_QWORD *)(v1 + 16) = v3;
if ( !v3 )
v1 = 0LL;
}
else
{
v1 = 0LL;
}
}
else if ( (unsigned int)is_term(a1, &asc_8A0[1], 2LL) )
{
*(_DWORD *)v1 = 1;
v5 = compile_clause_eval_rule(**(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 8) = v5;
if ( v5 )
{
v6 = compile_clause_eval_rule(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
*(_QWORD *)(v1 + 16) = v6;
if ( !v6 )
v1 = 0LL;
}
else
{
v1 = 0LL;
}
}
else if ( (unsigned int)is_term(a1, &asc_8A0[2], 1LL) )
{
*(_DWORD *)v1 = 2;
v7 = compile_clause_eval_rule(**(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 8) = v7;
if ( !v7 )
v1 = 0LL;
}
else if ( (unsigned int)is_term(a1, "all", 0LL) )
{
*(_DWORD *)v1 = 3;
}
else if ( (unsigned int)is_term(a1, "positive", 0LL) )
{
*(_DWORD *)v1 = 9;
}
else if ( (unsigned int)is_term(a1, "negative", 0LL) )
{
*(_DWORD *)v1 = 10;
}
else if ( (unsigned int)is_term(a1, "mixed", 0LL) )
{
*(_DWORD *)v1 = 11;
}
else if ( (unsigned int)is_term(a1, "true", 0LL) )
{
*(_DWORD *)v1 = 13;
}
else if ( (unsigned int)is_term(a1, "false", 0LL) )
{
*(_DWORD *)v1 = 14;
}
else if ( (unsigned int)is_term(a1, "has_equality", 0LL) )
{
*(_DWORD *)v1 = 15;
}
else if ( (unsigned int)is_term(a1, "horn", 0LL) )
{
*(_DWORD *)v1 = 16;
}
else if ( (unsigned int)is_term(a1, "definite", 0LL) )
{
*(_DWORD *)v1 = 17;
}
else if ( (unsigned int)is_term(a1, "unit", 0LL) )
{
*(_DWORD *)v1 = 18;
}
else if ( (unsigned int)is_term(a1, "hint", 0LL) )
{
*(_DWORD *)v1 = 12;
}
else if ( (unsigned int)is_term(a1, "initial", 0LL) )
{
*(_DWORD *)v1 = 19;
}
else if ( (unsigned int)is_term(a1, "resolvent", 0LL) )
{
*(_DWORD *)v1 = 20;
}
else if ( (unsigned int)is_term(a1, "hyper_resolvent", 0LL) )
{
*(_DWORD *)v1 = 22;
}
else if ( (unsigned int)is_term(a1, "ur_resolvent", 0LL) )
{
*(_DWORD *)v1 = 21;
}
else if ( (unsigned int)is_term(a1, "factor", 0LL) )
{
*(_DWORD *)v1 = 23;
}
else if ( (unsigned int)is_term(a1, "paramodulant", 0LL) )
{
*(_DWORD *)v1 = 24;
}
else if ( (unsigned int)is_term(a1, "back_demodulant", 0LL) )
{
*(_DWORD *)v1 = 25;
}
else if ( (unsigned int)is_term(a1, "subsumer", 0LL) )
{
*(_DWORD *)v1 = 26;
}
else if ( (unsigned int)is_term(a1, "<", 2LL)
|| (unsigned int)is_term(a1, ">", 2LL)
|| (unsigned int)is_term(a1, "<=", 2LL)
|| (unsigned int)is_term(a1, ">=", 2LL)
|| (unsigned int)is_term(a1, "=", 2LL) )
{
v8 = *(_QWORD **)(a1 + 8);
v9 = *v8;
v10 = v8[1];
if ( (unsigned int)is_term(*v8, "weight", 0LL) )
{
*(_DWORD *)v1 = 27;
}
else if ( (unsigned int)is_term(v9, "variables", 0LL) )
{
*(_DWORD *)v1 = 28;
}
else if ( (unsigned int)is_term(v9, "depth", 0LL) )
{
*(_DWORD *)v1 = 29;
}
else if ( (unsigned int)is_term(v9, "literals", 0LL) )
{
*(_DWORD *)v1 = 30;
}
else
{
if ( !(unsigned int)is_term(v9, "level", 0LL) )
return 0LL;
*(_DWORD *)v1 = 31;
}
if ( (unsigned int)term_to_number(v10, v1 + 32) )
{
if ( (unsigned int)is_term(a1, "<", 2LL) )
{
*(_DWORD *)(v1 + 24) = 2;
}
else if ( (unsigned int)is_term(a1, ">", 2LL) )
{
*(_DWORD *)(v1 + 24) = 3;
}
else if ( (unsigned int)is_term(a1, "<=", 2LL) )
{
*(_DWORD *)(v1 + 24) = 4;
}
else if ( (unsigned int)is_term(a1, ">=", 2LL) )
{
*(_DWORD *)(v1 + 24) = 5;
}
else if ( (unsigned int)is_term(a1, "=", 2LL) )
{
*(_DWORD *)(v1 + 24) = 1;
}
}
else
{
v1 = 0LL;
}
}
else
{
v1 = 0LL;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
_QWORD *v8; // rax
__int64 v9; // r12
__int64 v10; // r13

v1 = func1();
if ( (unsigned int)is_term(a1, asc_8A0, 2LL) )
{
*(_DWORD *)v1 = 0;
v2 = func3(**(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 8) = v2;
if ( v2 )
{
v3 = func3(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
*(_QWORD *)(v1 + 16) = v3;
if ( !v3 )
v1 = 0LL;
}
else
{
v1 = 0LL;
}
}
else if ( (unsigned int)is_term(a1, &asc_8A0[1], 2LL) )
{
*(_DWORD *)v1 = 1;
v5 = func3(**(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 8) = v5;
if ( v5 )
{
v6 = func3(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
*(_QWORD *)(v1 + 16) = v6;
if ( !v6 )
v1 = 0LL;
}
else
{
v1 = 0LL;
}
}
else if ( (unsigned int)is_term(a1, &asc_8A0[2], 1LL) )
{
*(_DWORD *)v1 = 2;
v7 = func3(**(_QWORD **)(a1 + 8));
*(_QWORD *)(v1 + 8) = v7;
if ( !v7 )
v1 = 0LL;
}
else if ( (unsigned int)is_term(a1, "all", 0LL) )
{
*(_DWORD *)v1 = 3;
}
else if ( (unsigned int)is_term(a1, "positive", 0LL) )
{
*(_DWORD *)v1 = 9;
}
else if ( (unsigned int)is_term(a1, "negative", 0LL) )
{
*(_DWORD *)v1 = 10;
}
else if ( (unsigned int)is_term(a1, "mixed", 0LL) )
{
*(_DWORD *)v1 = 11;
}
else if ( (unsigned int)is_term(a1, "true", 0LL) )
{
*(_DWORD *)v1 = 13;
}
else if ( (unsigned int)is_term(a1, "false", 0LL) )
{
*(_DWORD *)v1 = 14;
}
else if ( (unsigned int)is_term(a1, "has_equality", 0LL) )
{
*(_DWORD *)v1 = 15;
}
else if ( (unsigned int)is_term(a1, "horn", 0LL) )
{
*(_DWORD *)v1 = 16;
}
else if ( (unsigned int)is_term(a1, "definite", 0LL) )
{
*(_DWORD *)v1 = 17;
}
else if ( (unsigned int)is_term(a1, "unit", 0LL) )
{
*(_DWORD *)v1 = 18;
}
else if ( (unsigned int)is_term(a1, "hint", 0LL) )
{
*(_DWORD *)v1 = 12;
}
else if ( (unsigned int)is_term(a1, "initial", 0LL) )
{
*(_DWORD *)v1 = 19;
}
else if ( (unsigned int)is_term(a1, "resolvent", 0LL) )
{
*(_DWORD *)v1 = 20;
}
else if ( (unsigned int)is_term(a1, "hyper_resolvent", 0LL) )
{
*(_DWORD *)v1 = 22;
}
else if ( (unsigned int)is_term(a1, "ur_resolvent", 0LL) )
{
*(_DWORD *)v1 = 21;
}
else if ( (unsigned int)is_term(a1, "factor", 0LL) )
{
*(_DWORD *)v1 = 23;
}
else if ( (unsigned int)is_term(a1, "paramodulant", 0LL) )
{
*(_DWORD *)v1 = 24;
}
else if ( (unsigned int)is_term(a1, "back_demodulant", 0LL) )
{
*(_DWORD *)v1 = 25;
}
else if ( (unsigned int)is_term(a1, "subsumer", 0LL) )
{
*(_DWORD *)v1 = 26;
}
else if ( (unsigned int)is_term(a1, "<", 2LL)
|| (unsigned int)is_term(a1, ">", 2LL)
|| (unsigned int)is_term(a1, "<=", 2LL)
|| (unsigned int)is_term(a1, ">=", 2LL)
|| (unsigned int)is_term(a1, "=", 2LL) )
{
v8 = *(_QWORD **)(a1 + 8);
v9 = *v8;
v10 = v8[1];
if ( (unsigned int)is_term(*v8, "weight", 0LL) )
{
*(_DWORD *)v1 = 27;
}
else if ( (unsigned int)is_term(v9, "variables", 0LL) )
{
*(_DWORD *)v1 = 28;
}
else if ( (unsigned int)is_term(v9, "depth", 0LL) )
{
*(_DWORD *)v1 = 29;
}
else if ( (unsigned int)is_term(v9, "literals", 0LL) )
{
*(_DWORD *)v1 = 30;
}
else
{
if ( !(unsigned int)is_term(v9, "level", 0LL) )
return 0LL;
*(_DWORD *)v1 = 31;
}
if ( (unsigned int)term_to_number(v10, v1 + 32) )
{
if ( (unsigned int)is_term(a1, "<", 2LL) )
{
*(_DWORD *)(v1 + 24) = 2;
}
else if ( (unsigned int)is_term(a1, ">", 2LL) )
{
*(_DWORD *)(v1 + 24) = 3;
}
else if ( (unsigned int)is_term(a1, "<=", 2LL) )
{
*(_DWORD *)(v1 + 24) = 4;
}
else if ( (unsigned int)is_term(a1, ">=", 2LL) )
{
*(_DWORD *)(v1 + 24) = 5;
}
else if ( (unsigned int)is_term(a1, "=", 2LL) )
{
*(_DWORD *)(v1 + 24) = 1;
}
}
else
{
v1 = 0LL;
}
}
else
{
v1 = 0LL;
}
return v1;
}

original_code:
Clause_eval compile_clause_eval_rule(Term t)
{
  Clause_eval p = get_clause_eval();
  if (is_term(t, "&", 2)) {
    p->type = CL_EVAL_AND;
    p->left = compile_clause_eval_rule(((t)->args[0]));
    if (p->left == ((void *)0))
      return ((void *)0);
    p->right = compile_clause_eval_rule(((t)->args[1]));
    if (p->right == ((void *)0))
      return ((void *)0);
  }
  else if (is_term(t, "|", 2)) {
    p->type = CL_EVAL_OR;
    p->left = compile_clause_eval_rule(((t)->args[0]));
    if (p->left == ((void *)0))
      return ((void *)0);
    p->right = compile_clause_eval_rule(((t)->args[1]));
    if (p->right == ((void *)0))
      return ((void *)0);
  }
  else if (is_term(t, "-", 1)) {
    p->type = CL_EVAL_NOT;
    p->left = compile_clause_eval_rule(((t)->args[0]));
    if (p->left == ((void *)0))
      return ((void *)0);
  }
  else if (is_term(t, "all", 0))
    p->type = CL_EVAL_ALL;
  else if (is_term(t, "positive", 0))
    p->type = CL_EVAL_POSITIVE;
  else if (is_term(t, "negative", 0))
    p->type = CL_EVAL_NEGATIVE;
  else if (is_term(t, "mixed", 0))
    p->type = CL_EVAL_MIXED;
  else if (is_term(t, "true", 0))
    p->type = CL_EVAL_TRUE;
  else if (is_term(t, "false", 0))
    p->type = CL_EVAL_FALSE;
  else if (is_term(t, "has_equality", 0))
    p->type = CL_EVAL_HAS_EQUALITY;
  else if (is_term(t, "horn", 0))
    p->type = CL_EVAL_HORN;
  else if (is_term(t, "definite", 0))
    p->type = CL_EVAL_DEFINITE;
  else if (is_term(t, "unit", 0))
    p->type = CL_EVAL_UNIT;
  else if (is_term(t, "hint", 0))
    p->type = CL_EVAL_HINT;
  else if (is_term(t, "initial", 0))
    p->type = CL_EVAL_INITIAL;
  else if (is_term(t, "resolvent", 0))
    p->type = CL_EVAL_RESOLVENT;
  else if (is_term(t, "hyper_resolvent", 0))
    p->type = CL_EVAL_HYPER_RESOLVENT;
  else if (is_term(t, "ur_resolvent", 0))
    p->type = CL_EVAL_UR_RESOLVENT;
  else if (is_term(t, "factor", 0))
    p->type = CL_EVAL_FACTOR;
  else if (is_term(t, "paramodulant", 0))
    p->type = CL_EVAL_PARAMODULANT;
  else if (is_term(t, "back_demodulant", 0))
    p->type = CL_EVAL_BACK_DEMODULANT;
  else if (is_term(t, "subsumer", 0))
    p->type = CL_EVAL_SUBSUMER;
  else if (is_term(t, "<", 2) ||
    is_term(t, ">", 2) ||
    is_term(t, "<=", 2) ||
    is_term(t, ">=", 2) ||
    is_term(t, "=", 2)) {
    Term a0 = ((t)->args[0]);
    Term a1 = ((t)->args[1]);
    if (is_term(a0, "weight", 0))
      p->type = CL_EVAL_WEIGHT;
    else if (is_term(a0, "variables", 0))
      p->type = CL_EVAL_VARIABLES;
    else if (is_term(a0, "depth", 0))
      p->type = CL_EVAL_DEPTH;
    else if (is_term(a0, "literals", 0))
      p->type = CL_EVAL_LITERALS;
    else if (is_term(a0, "level", 0))
      p->type = CL_EVAL_LEVEL;
    else
      return ((void *)0);
    if (!term_to_number(a1, &(p->test_val)))
      return ((void *)0);
    if (is_term(t, "<", 2))
      p->relation = LESS_THAN;
    else if (is_term(t, ">", 2))
      p->relation = GREATER_THAN;
    else if (is_term(t, "<=", 2))
      p->relation = LESS_THAN_OR_SAME_AS;
    else if (is_term(t, ">=", 2))
      p->relation = GREATER_THAN_OR_SAME_AS;
    else if (is_term(t, "=", 2))
      p->relation = SAME_AS;
  }
  else
    return ((void *)0);
  return p;
}

canonical_original_code:
struct clause_eval *compile_clause_eval_rule(struct term *t)
{
  struct clause_eval *p = get_clause_eval();
  if (is_term(t, "&", 2)) {
    p->type = CL_EVAL_AND;
    p->left = compile_clause_eval_rule(((t)->args[0]));
    if (p->left == ((void *)0))
      return ((void *)0);
    p->right = compile_clause_eval_rule(((t)->args[1]));
    if (p->right == ((void *)0))
      return ((void *)0);
  }
  else if (is_term(t, "|", 2)) {
    p->type = CL_EVAL_OR;
    p->left = compile_clause_eval_rule(((t)->args[0]));
    if (p->left == ((void *)0))
      return ((void *)0);
    p->right = compile_clause_eval_rule(((t)->args[1]));
    if (p->right == ((void *)0))
      return ((void *)0);
  }
  else if (is_term(t, "-", 1)) {
    p->type = CL_EVAL_NOT;
    p->left = compile_clause_eval_rule(((t)->args[0]));
    if (p->left == ((void *)0))
      return ((void *)0);
  }
  else if (is_term(t, "all", 0))
    p->type = CL_EVAL_ALL;
  else if (is_term(t, "positive", 0))
    p->type = CL_EVAL_POSITIVE;
  else if (is_term(t, "negative", 0))
    p->type = CL_EVAL_NEGATIVE;
  else if (is_term(t, "mixed", 0))
    p->type = CL_EVAL_MIXED;
  else if (is_term(t, "true", 0))
    p->type = CL_EVAL_TRUE;
  else if (is_term(t, "false", 0))
    p->type = CL_EVAL_FALSE;
  else if (is_term(t, "has_equality", 0))
    p->type = CL_EVAL_HAS_EQUALITY;
  else if (is_term(t, "horn", 0))
    p->type = CL_EVAL_HORN;
  else if (is_term(t, "definite", 0))
    p->type = CL_EVAL_DEFINITE;
  else if (is_term(t, "unit", 0))
    p->type = CL_EVAL_UNIT;
  else if (is_term(t, "hint", 0))
    p->type = CL_EVAL_HINT;
  else if (is_term(t, "initial", 0))
    p->type = CL_EVAL_INITIAL;
  else if (is_term(t, "resolvent", 0))
    p->type = CL_EVAL_RESOLVENT;
  else if (is_term(t, "hyper_resolvent", 0))
    p->type = CL_EVAL_HYPER_RESOLVENT;
  else if (is_term(t, "ur_resolvent", 0))
    p->type = CL_EVAL_UR_RESOLVENT;
  else if (is_term(t, "factor", 0))
    p->type = CL_EVAL_FACTOR;
  else if (is_term(t, "paramodulant", 0))
    p->type = CL_EVAL_PARAMODULANT;
  else if (is_term(t, "back_demodulant", 0))
    p->type = CL_EVAL_BACK_DEMODULANT;
  else if (is_term(t, "subsumer", 0))
    p->type = CL_EVAL_SUBSUMER;
  else if (is_term(t, "<", 2) ||
    is_term(t, ">", 2) ||
    is_term(t, "<=", 2) ||
    is_term(t, ">=", 2) ||
    is_term(t, "=", 2)) {
    struct term *a0 = ((t)->args[0]);
    struct term *a1 = ((t)->args[1]);
    if (is_term(a0, "weight", 0))
      p->type = CL_EVAL_WEIGHT;
    else if (is_term(a0, "variables", 0))
      p->type = CL_EVAL_VARIABLES;
    else if (is_term(a0, "depth", 0))
      p->type = CL_EVAL_DEPTH;
    else if (is_term(a0, "literals", 0))
      p->type = CL_EVAL_LITERALS;
    else if (is_term(a0, "level", 0))
      p->type = CL_EVAL_LEVEL;
    else
      return ((void *)0);
    if (!term_to_number(a1, &(p->test_val)))
      return ((void *)0);
    if (is_term(t, "<", 2))
      p->relation = LESS_THAN;
    else if (is_term(t, ">", 2))
      p->relation = GREATER_THAN;
    else if (is_term(t, "<=", 2))
      p->relation = LESS_THAN_OR_SAME_AS;
    else if (is_term(t, ">=", 2))
      p->relation = GREATER_THAN_OR_SAME_AS;
    else if (is_term(t, "=", 2))
      p->relation = SAME_AS;
  }
  else
    return ((void *)0);
  return p;
}


decompiled_code:
__int64 __fastcall rule_contains_semantics(__int64 a1)
{
__int64 result; // rax
int v2; // edx

if ( *(_DWORD *)a1 > 1u )
return (unsigned int)(*(_DWORD *)a1 - 13) <= 1;
v2 = rule_contains_semantics(*(_QWORD *)(a1 + 8));
result = 1LL;
if ( !v2 )
result = (unsigned int)rule_contains_semantics(*(_QWORD *)(a1 + 16)) != 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
int v2; // edx

if ( *(_DWORD *)a1 > 1u )
return (unsigned int)(*(_DWORD *)a1 - 13) <= 1;
v2 = func5(*(_QWORD *)(a1 + 8));
result = 1LL;
if ( !v2 )
result = (unsigned int)func5(*(_QWORD *)(a1 + 16)) != 0;
return result;
}

original_code:
BOOL rule_contains_semantics(Clause_eval p)
{
  if (p->type == CL_EVAL_AND || p->type == CL_EVAL_OR) {
    return (rule_contains_semantics(p->left) ||
     rule_contains_semantics(p->right));
  }
  else if (p->type == CL_EVAL_OR)
    return rule_contains_semantics(p->left);
  else
    return p->type == CL_EVAL_TRUE || p->type == CL_EVAL_FALSE;
}

canonical_original_code:
enum BOOL rule_contains_semantics(struct clause_eval *p)
{
  if (p->type == CL_EVAL_AND || p->type == CL_EVAL_OR) {
    return (rule_contains_semantics(p->left) ||
     rule_contains_semantics(p->right));
  }
  else if (p->type == CL_EVAL_OR)
    return rule_contains_semantics(p->left);
  else
    return p->type == CL_EVAL_TRUE || p->type == CL_EVAL_FALSE;
}

return_type: enum BOOL { FALSE=0, TRUE=1 }


decompiled_code:
__int64 __fastcall sum_indexes(__int64 a1)
{
unsigned __int8 v1; // dl
_DWORD **v2; // rax
__int64 v3; // rsi
unsigned int v4; // edx

v1 = *(_BYTE *)(a1 + 4);
if ( !v1 )
return (unsigned int)-1;
v2 = *(_DWORD ***)(a1 + 8);
v3 = (__int64)&v2[v1];
v4 = 0;
do
v4 += **v2++;
while ( v2 != (_DWORD **)v3 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned __int8 v1; // dl
_DWORD **v2; // rax
__int64 v3; // rsi
unsigned int v4; // edx

v1 = *(_BYTE *)(a1 + 4);
if ( !v1 )
return (unsigned int)-1;
v2 = *(_DWORD ***)(a1 + 8);
v3 = (__int64)&v2[v1];
v4 = 0;
do
v4 += **v2++;
while ( v2 != (_DWORD **)v3 );
return v4;
}

original_code:
static
int sum_indexes(Term t)
{
  if (((t)->arity) == 0)
    return -1;
  else {
    int sum = 0;
    int i;
    for (i = 0; i < ((t)->arity); i++)
      sum += ((((t)->args[i]))->private_symbol);
    return sum;
  }
}

canonical_original_code:
static int sum_indexes(struct term *t)
{
  if (((t)->arity) == 0)
    return -1;
  else {
    int sum = 0;
    int i;
    for (i = 0; i < ((t)->arity); i++)
      sum += ((((t)->args[i]))->private_symbol);
    return sum;
  }
}

variable_types: sum int


decompiled_code:
__int64 __fastcall compare_cells(__int64 a1, __int64 a2)
{
__int64 v3; // rdx
int v4; // eax
int v5; // ecx
__int64 result; // rax
int v7; // esi
int v8; // ecx
int v9; // ecx
int v10; // edx
int v11; // ebp
int v12; // edx

v3 = *(_QWORD *)(a1 + 48);
v4 = *(_DWORD *)(v3 + 20);
if ( v4 == 1 )
{
result = 3LL;
if ( *(_DWORD *)(*(_QWORD *)(a2 + 48) + 20LL) != 1 )
return result;
}
else
{
v5 = *(_DWORD *)(*(_QWORD *)(a2 + 48) + 20LL);
if ( v5 == 1 )
return 2LL;
if ( v4 == 2 && Skolems_last )
{
result = 3LL;
if ( v5 != 2 )
return result;
}
else if ( v4 != 2 )
{
if ( Skolems_last )
{
result = 2LL;
if ( *(_DWORD *)(*(_QWORD *)(a2 + 48) + 20LL) == 2 )
return result;
}
}
}
v7 = *(_DWORD *)(a1 + 40);
v8 = *(_DWORD *)(a2 + 40);
result = 2LL;
if ( v7 >= v8 )
{
result = 3LL;
if ( v7 <= v8 )
{
v9 = *(_DWORD *)(v3 + 4);
v10 = *(_DWORD *)(*(_QWORD *)(a2 + 48) + 4LL);
result = 2LL;
if ( v9 >= v10 )
{
result = 3LL;
if ( v9 <= v10 )
{
v11 = sum_indexes(*(_QWORD *)(a1 + 8));
v12 = sum_indexes(*(_QWORD *)(a2 + 8));
result = 2LL;
if ( v11 >= v12 )
result = 2 * (unsigned int)(v11 > v12) + 1;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v3; // rdx
int v4; // eax
int v5; // ecx
__int64 result; // rax
int v7; // esi
int v8; // ecx
int v9; // ecx
int v10; // edx
int v11; // ebp
int v12; // edx

v3 = *(_QWORD *)(a1 + 48);
v4 = *(_DWORD *)(v3 + 20);
if ( v4 == 1 )
{
result = 3LL;
if ( *(_DWORD *)(*(_QWORD *)(a2 + 48) + 20LL) != 1 )
return result;
}
else
{
v5 = *(_DWORD *)(*(_QWORD *)(a2 + 48) + 20LL);
if ( v5 == 1 )
return 2LL;
if ( v4 == 2 && Skolems_last )
{
result = 3LL;
if ( v5 != 2 )
return result;
}
else if ( v4 != 2 )
{
if ( Skolems_last )
{
result = 2LL;
if ( *(_DWORD *)(*(_QWORD *)(a2 + 48) + 20LL) == 2 )
return result;
}
}
}
v7 = *(_DWORD *)(a1 + 40);
v8 = *(_DWORD *)(a2 + 40);
result = 2LL;
if ( v7 >= v8 )
{
result = 3LL;
if ( v7 <= v8 )
{
v9 = *(_DWORD *)(v3 + 4);
v10 = *(_DWORD *)(*(_QWORD *)(a2 + 48) + 4LL);
result = 2LL;
if ( v9 >= v10 )
{
result = 3LL;
if ( v9 <= v10 )
{
v11 = func0(*(_QWORD *)(a1 + 8));
v12 = func0(*(_QWORD *)(a2 + 8));
result = 2LL;
if ( v11 >= v12 )
result = 2 * (unsigned int)(v11 > v12) + 1;
}
}
}
}
return result;
}

original_code:
static
Ordertype compare_cells(struct cell *a, struct cell *b)
{
  if (a->symbol->attribute == EQUALITY_SYMBOL &&
      b->symbol->attribute != EQUALITY_SYMBOL) return GREATER_THAN;
  else if (a->symbol->attribute != EQUALITY_SYMBOL &&
    b->symbol->attribute == EQUALITY_SYMBOL) return LESS_THAN;
  else if (Skolems_last &&
    a->symbol->attribute == SKOLEM_SYMBOL &&
    b->symbol->attribute != SKOLEM_SYMBOL) return GREATER_THAN;
  else if (Skolems_last &&
    a->symbol->attribute != SKOLEM_SYMBOL &&
    b->symbol->attribute == SKOLEM_SYMBOL) return LESS_THAN;
  else if (a->max_index < b->max_index) return LESS_THAN;
  else if (a->max_index > b->max_index) return GREATER_THAN;
  else if (a->symbol->mace_sn < b->symbol->mace_sn) return LESS_THAN;
  else if (a->symbol->mace_sn > b->symbol->mace_sn) return GREATER_THAN;
  else if (sum_indexes(a->eterm) <
           sum_indexes(b->eterm)) return LESS_THAN;
  else if (sum_indexes(a->eterm) >
           sum_indexes(b->eterm)) return GREATER_THAN;
  else
    return SAME_AS;
}

canonical_original_code:
static enum Ordertype compare_cells(struct cell *a, struct cell *b)
{
  if (a->symbol->attribute == EQUALITY_SYMBOL &&
      b->symbol->attribute != EQUALITY_SYMBOL) return GREATER_THAN;
  else if (a->symbol->attribute != EQUALITY_SYMBOL &&
    b->symbol->attribute == EQUALITY_SYMBOL) return LESS_THAN;
  else if (Skolems_last &&
    a->symbol->attribute == SKOLEM_SYMBOL &&
    b->symbol->attribute != SKOLEM_SYMBOL) return GREATER_THAN;
  else if (Skolems_last &&
    a->symbol->attribute != SKOLEM_SYMBOL &&
    b->symbol->attribute == SKOLEM_SYMBOL) return LESS_THAN;
  else if (a->max_index < b->max_index) return LESS_THAN;
  else if (a->max_index > b->max_index) return GREATER_THAN;
  else if (a->symbol->mace_sn < b->symbol->mace_sn) return LESS_THAN;
  else if (a->symbol->mace_sn > b->symbol->mace_sn) return GREATER_THAN;
  else if (sum_indexes(a->eterm) <
           sum_indexes(b->eterm)) return LESS_THAN;
  else if (sum_indexes(a->eterm) >
           sum_indexes(b->eterm)) return GREATER_THAN;
  else
    return SAME_AS;
}

variable_types: struct cell { int id; struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *eterm; struct term *value; struct term *occurrences; struct term **possible; int max_index; struct symbol_data { int sn; int mace_sn; int arity; int type; int base; int attribute; struct symbol_data *next; } *symbol; } *

variable_types:
b
struct cell *

user_defined_types: struct cell { int id; struct term *eterm; struct term *value; struct term *occurrences; struct term **possible; int max_index; struct symbol_data *symbol; }


decompiled_code:
int __fastcall order_cells(int a1)
{
__int64 v1; // rsi
__int64 v2; // rdx
__int64 v3; // rax
__int64 v4; // rdx
int result; // eax
__int64 v6; // rbx
_DWORD *v7; // rbp

v1 = Number_of_cells;
if ( Number_of_cells > 0 )
{
v2 = 0LL;
v3 = 0LL;
do
{
*(_QWORD *)(Ordered_cells + 8 * v3) = Cells + v2;
v1 = Number_of_cells;
++v3;
v2 += 56LL;
}
while ( Number_of_cells > (int)v3 );
}
merge_sort(Ordered_cells, v1, compare_cells);
if ( Skolems_last )
{
if ( Number_of_cells <= 0 )
{
result = 0;
}
else
{
v4 = Ordered_cells;
result = 0;
while ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)v4 + 48LL) + 20LL) != 2 )
{
++result;
v4 += 8LL;
if ( result == Number_of_cells )
{
result = Number_of_cells;
break;
}
}
}
First_skolem_cell = result;
}
else
{
result = Number_of_cells;
First_skolem_cell = Number_of_cells;
}
if ( a1 )
{
printf("\n%% Cell selection order:\n\n");
if ( Number_of_cells > 0 )
{
v6 = 0LL;
do
{
v7 = *(_DWORD **)(*(_QWORD *)(Ordered_cells + 8 * v6) + 8LL);
if ( !(unsigned int)is_eq_symbol((unsigned int)-*v7) )
fwrite_term_nl(stdout, v7);
++v6;
}
while ( Number_of_cells > (int)v6 );
}
result = fflush(stdout);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
__int64 v1; // rsi
__int64 v2; // rdx
__int64 v3; // rax
__int64 v4; // rdx
int result; // eax
__int64 v6; // rbx
_DWORD *v7; // rbp

v1 = Number_of_cells;
if ( Number_of_cells > 0 )
{
v2 = 0LL;
v3 = 0LL;
do
{
*(_QWORD *)(Ordered_cells + 8 * v3) = Cells + v2;
v1 = Number_of_cells;
++v3;
v2 += 56LL;
}
while ( Number_of_cells > (int)v3 );
}
merge_sort(Ordered_cells, v1, compare_cells);
if ( Skolems_last )
{
if ( Number_of_cells <= 0 )
{
result = 0;
}
else
{
v4 = Ordered_cells;
result = 0;
while ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)v4 + 48LL) + 20LL) != 2 )
{
++result;
v4 += 8LL;
if ( result == Number_of_cells )
{
result = Number_of_cells;
break;
}
}
}
First_skolem_cell = result;
}
else
{
result = Number_of_cells;
First_skolem_cell = Number_of_cells;
}
if ( a1 )
{
printf("\n%% Cell selection order:\n\n");
if ( Number_of_cells > 0 )
{
v6 = 0LL;
do
{
v7 = *(_DWORD **)(*(_QWORD *)(Ordered_cells + 8 * v6) + 8LL);
if ( !(unsigned int)is_eq_symbol((unsigned int)-*v7) )
fwrite_term_nl(stdout, v7);
++v6;
}
while ( Number_of_cells > (int)v6 );
}
result = fflush(stdout);
}
return result;
}

original_code:
void order_cells(BOOL verbose)
{
  int i;
  for (i = 0; i < Number_of_cells; i++)
    Ordered_cells[i] = Cells + i;
  merge_sort((void **) Ordered_cells, Number_of_cells,
             (Ordertype (*) (void*,void*)) compare_cells);
  if (Skolems_last) {
    for (i = 0; i < Number_of_cells; i++)
      if (Ordered_cells[i]->symbol->attribute == SKOLEM_SYMBOL)
 break;
    First_skolem_cell = i;
  }
  else
    First_skolem_cell = Number_of_cells;
  if (verbose) {
    printf("\n%% Cell selection order:\n\n");
    for (i = 0; i < Number_of_cells; i++) {
      Term t = Ordered_cells[i]->eterm;
      if (!is_eq_symbol((-((t)->private_symbol))))
 fwrite_term_nl(stdout, t);
    }
    fflush(stdout);
  }
}

canonical_original_code:
void order_cells(enum BOOL verbose)
{
  int i;
  for (i = 0; i < Number_of_cells; i++)
    Ordered_cells[i] = Cells + i;
  merge_sort((void **) Ordered_cells, Number_of_cells,
             (enum Ordertype (*)(void *, void *)) compare_cells);
  if (Skolems_last) {
    for (i = 0; i < Number_of_cells; i++)
      if (Ordered_cells[i]->symbol->attribute == SKOLEM_SYMBOL)
 break;
    First_skolem_cell = i;
  }
  else
    First_skolem_cell = Number_of_cells;
  if (verbose) {
    printf("\n%% Cell selection order:\n\n");
    for (i = 0; i < Number_of_cells; i++) {
      struct term *t = Ordered_cells[i]->eterm;
      if (!is_eq_symbol((-((t)->private_symbol))))
 fwrite_term_nl(stdout, t);
    }
    fflush(stdout);
  }
}

variable_types:
verbose
enum BOOL { FALSE=0, TRUE=1 }


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

if ( !(unsigned int)lindex_empty(Hints_idx) || !(unsigned int)clist_empty(Redundant_hints) )
puts("ERROR: Hints index not empty!");
lindex_destroy(Hints_idx);
if ( Back_demod_hints )
mindex_destroy(Back_demod_idx);
Hints_idx = 0LL;
result = clist_free(Redundant_hints);
Redundant_hints = 0LL;
return result;
}

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

if ( !(unsigned int)lindex_empty(Hints_idx) || !(unsigned int)clist_empty(Redundant_hints) )
puts("ERROR: Hints index not empty!");
lindex_destroy(Hints_idx);
if ( Back_demod_hints )
mindex_destroy(Back_demod_idx);
Hints_idx = 0LL;
result = clist_free(Redundant_hints);
Redundant_hints = 0LL;
return result;
}

original_code:
void done_with_hints(void)
{
  if (!lindex_empty(Hints_idx) ||
      !clist_empty(Redundant_hints))
    printf("ERROR: Hints index not empty!\n");
  lindex_destroy(Hints_idx);
  if (Back_demod_hints)
    mindex_destroy(Back_demod_idx);
  Hints_idx = ((void *)0);
  clist_free(Redundant_hints);
  Redundant_hints = ((void *)0);
}

canonical_original_code:
void done_with_hints()
{
  if (!lindex_empty(Hints_idx) ||
      !clist_empty(Redundant_hints))
    printf("ERROR: Hints index not empty!\n");
  lindex_destroy(Hints_idx);
  if (Back_demod_hints)
    mindex_destroy(Back_demod_idx);
  Hints_idx = ((void *)0);
  clist_free(Redundant_hints);
  Redundant_hints = ((void *)0);
}


decompiled_code:
__int64 redundant_hints()
{
return clist_length(Redundant_hints);
}

canonical_decompiled_code:
__int64 func4()
{
return clist_length(Redundant_hints);
}

original_code:
int redundant_hints(void)
{
  return clist_length(Redundant_hints);
}

canonical_original_code:
int redundant_hints()
{
  return clist_length(Redundant_hints);
}


decompiled_code:
__int64 __fastcall input_clauses(_QWORD *a1)
{
__int64 v1; // rbp

if ( !a1 )
return 0LL;
v1 = input_clauses(a1[1]);
if ( (unsigned int)has_input_just(*a1) )
v1 = plist_prepend(v1, *a1);
return v1;
}

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

if ( !a1 )
return 0LL;
v1 = func3(a1[1]);
if ( (unsigned int)has_input_just(*a1) )
v1 = plist_prepend(v1, *a1);
return v1;
}

original_code:
Plist input_clauses(Plist a)
{
  if (a == ((void *)0))
    return ((void *)0);
  else {
    Plist c = input_clauses(a->next);
    if (has_input_just(a->v))
      return plist_prepend(c, a->v);
    else
      return c;
  }
}

canonical_original_code:
struct plist *input_clauses(struct plist *a)
{
  if (a == ((void *)0))
    return ((void *)0);
  else {
    struct plist *c = input_clauses(a->next);
    if (has_input_just(a->v))
      return plist_prepend(c, a->v);
    else
      return c;
  }
}

variable_types:
a
struct plist *

variable_types: struct plist { void *v; struct plist *next; } *


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

if ( a1 )
{
delete_clauses(a1[1]);
delete_clause(*a1);
result = free_plist(a1);
}
return result;
}

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

if ( a1 )
{
func8(a1[1]);
func4(*a1);
result = free_plist(a1);
}
return result;
}

original_code:
void delete_clauses(Plist p)
{
  if (p != ((void *)0)) {
    delete_clauses(p->next);
    delete_clause(p->v);
    free_plist(p);
  }
}

canonical_original_code:
void delete_clauses(struct plist *p)
{
  if (p != ((void *)0)) {
    delete_clauses(p->next);
    delete_clause(p->v);
    free_plist(p);
  }
}

user_defined_types: struct plist { void *v; struct plist *next; }


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

result = 2LL;
if ( a1 >= a2 )
result = a2 < a1 ? 3 : 1;
return result;
}

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

result = 2LL;
if ( a1 >= a2 )
result = a2 < a1 ? 3 : 1;
return result;
}

original_code:
static Ordertype ptr_compare(void *i1, void *i2)
{
  return (i1 < i2 ? LESS_THAN : (i1 > i2 ? GREATER_THAN : SAME_AS));
}

canonical_original_code:
static enum Ordertype ptr_compare(void *i1, void *i2)
{
  return (i1 < i2 ? LESS_THAN : (i1 > i2 ? GREATER_THAN : SAME_AS));
}


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
int v4; // er13
int v5; // eax
int *v6; // r14
int *v7; // rbp
__int64 v8; // r12
int v9; // ebx
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rbx
double v13; // rbp
__int64 v14; // rax
int i; // ebp
unsigned int v16; // ebx
double v17; // xmm0_8
int *v18; // rbp
__int64 v19; // r13
int v20; // ebx

if ( argc != 3 )
{
puts("need 2 args: size seed");
exit(0);
}
v4 = atoi(argv[1]);
v5 = atoi(argv[2]);
srand(v5);
v6 = (int *)malloc(4LL * v4);
random_permutation(v6, (unsigned int)v4);
puts("starting insert");
fflush(stdout);
if ( v4 <= 0 )
{
v8 = 0LL;
}
else
{
v7 = v6;
v8 = 0LL;
do
{
v9 = *v7 + 1;
printf("inserting %4d\n", (unsigned int)v9);
v8 = avl_insert(v8, v9, ptr_compare);
avl_check(v8, ptr_compare);
++v7;
}
while ( v7 != &v6[v4 - 1 + 1] );
}
p_avl(v8, 0LL);
puts("finished insert");
fflush(stdout);
v10 = avl_smallest(v8);
printf("smallest item is %d.\n", v10);
v11 = avl_largest(v8);
printf("largest item is %d.\n", v11);
avl_position(v8, *v6 + 1LL, ptr_compare);
printf("position of %d is %.4f.\n", (unsigned int)(*v6 + 1), v3);
if ( v4 > 0 )
{
v12 = 1LL;
do
{
v13 = avl_position(v8, v12, ptr_compare);
v14 = avl_item_at_position(v8);
printf("item %d, position %.12f, item=%d.\n", (unsigned int)v12++, v13, v14);
}
while ( v4 >= (int)v12 );
}
for ( i = 0; i != 101; ++i )
{
v16 = avl_item_at_position(v8);
v17 = avl_position(v8, (int)v16, ptr_compare);
printf("Position %.2f, item %d, position=%.4f.\n", (double)i / 100.0, v16, v17);
}
random_permutation(v6, (unsigned int)v4);
puts("starting delete");
fflush(stdout);
if ( v4 > 0 )
{
v18 = v6;
v19 = (__int64)&v6[v4 - 1 + 1];
do
{
v20 = *v18 + 1;
printf("********************************** Removing %d\n", (unsigned int)v20);
v8 = avl_delete(v8, v20, ptr_compare);
avl_check(v8, ptr_compare);
++v18;
}
while ( (int *)v19 != v18 );
}
p_avl(v8, 0LL);
exit(0);
}

original_code:
int main(int argc, char **argv)
{
  struct mace_options opt;
  Plist clauses;
  Mace_results results;
  BOOL prover_compatability_mode = member_args(argc, argv, "-c");
  init_standard_ladr();
  init_mace_options(&opt);
  init_attrs();
  if (member_args(argc, argv, "help") ||
      member_args(argc, argv, "-help")) {
    usage_message(stderr, &opt);
    exit(1);
  }
  print_banner(argc, argv, "Mace4", "2009-11A", "November 2009", FALSE);
  set_program_name("Mace4");
  signal(2, mace4_sig_handler);
  signal(10, mace4_sig_handler);
  signal(11, mace4_sig_handler);
  clauses = read_mace4_input(argc, argv, prover_compatability_mode, &opt);
  print_separator(stdout, "CLAUSES FOR SEARCH", TRUE);
  fwrite_clause_list(stdout, clauses, "mace4_clauses", CL_FORM_BARE);
  print_separator(stdout, "end of clauses for search", TRUE);
  results = mace4(clauses, &opt);
  mace4_exit(results->return_code);
  exit(0);
}

canonical_original_code:
int main(int argc, char **argv)
{
  struct mace_options opt;
  struct plist *clauses;
  struct mace_results *results;
  enum BOOL prover_compatability_mode = member_args(argc, argv, "-c");
  init_standard_ladr();
  init_mace_options(&opt);
  init_attrs();
  if (member_args(argc, argv, "help") ||
      member_args(argc, argv, "-help")) {
    usage_message(stderr, &opt);
    exit(1);
  }
  print_banner(argc, argv, "Mace4", "2009-11A", "November 2009", FALSE);
  set_program_name("Mace4");
  signal(2, mace4_sig_handler);
  signal(10, mace4_sig_handler);
  signal(11, mace4_sig_handler);
  clauses = read_mace4_input(argc, argv, prover_compatability_mode, &opt);
  print_separator(stdout, "CLAUSES FOR SEARCH", TRUE);
  fwrite_clause_list(stdout, clauses, "mace4_clauses", CL_FORM_BARE);
  print_separator(stdout, "end of clauses for search", TRUE);
  results = mace4(clauses, &opt);
  mace4_exit(results->return_code);
  exit(0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct mace_options { int print_models; int domain_size; int iterate; }

variable_types: struct mace_results { enum BOOL { FALSE=0, TRUE=1 } success; struct plist { void *v; struct plist *next; } *models; double user_seconds; int return_code; } *

user_defined_types: struct mace_results { enum BOOL success; struct plist *models; double user_seconds; int return_code; }


decompiled_code:
__int64 __fastcall uncompress_term(__int64 a1, _DWORD *a2)
{
int v3; // eax
char v4; // di
unsigned int v5; // eax
__int64 v6; // rbp
__int64 v7; // rbx
_QWORD *v8; // r14

v3 = (*a2)++;
v4 = *(_BYTE *)(a1 + v3);
if ( v4 <= 0 )
return get_variable_term((unsigned int)-v4);
v5 = sn_to_arity((unsigned int)v4);
v6 = get_rigid_term_dangerously((unsigned int)v4, v5);
if ( *(_BYTE *)(v6 + 4) )
{
v7 = 0LL;
do
{
v8 = (_QWORD *)(*(_QWORD *)(v6 + 8) + 8 * v7);
*v8 = uncompress_term(a1, a2);
++v7;
}
while ( *(unsigned __int8 *)(v6 + 4) > (int)v7 );
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _DWORD *a2)
{
int v3; // eax
char v4; // di
unsigned int v5; // eax
__int64 v6; // rbp
__int64 v7; // rbx
_QWORD *v8; // r14

v3 = (*a2)++;
v4 = *(_BYTE *)(a1 + v3);
if ( v4 <= 0 )
return get_variable_term((unsigned int)-v4);
v5 = sn_to_arity((unsigned int)v4);
v6 = get_rigid_term_dangerously((unsigned int)v4, v5);
if ( *(_BYTE *)(v6 + 4) )
{
v7 = 0LL;
do
{
v8 = (_QWORD *)(*(_QWORD *)(v6 + 8) + 8 * v7);
*v8 = func1(a1, a2);
++v7;
}
while ( *(unsigned __int8 *)(v6 + 4) > (int)v7 );
}
return v6;
}

original_code:
Term uncompress_term(char *s, int *ip)
{
  char c = s[(*ip)++];
  if (c <= 0)
    return get_variable_term(-c);
  else {
    int arity = sn_to_arity(c);
    Term t = get_rigid_term_dangerously(c, arity);
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = uncompress_term(s, ip);
    return t;
  }
}

canonical_original_code:
struct term *uncompress_term(char *s, int *ip)
{
  char c = s[(*ip)++];
  if (c <= 0)
    return get_variable_term(-c);
  else {
    int arity = sn_to_arity(c);
    struct term *t = get_rigid_term_dangerously(c, arity);
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = uncompress_term(s, ip);
    return t;
  }
}

variable_types:
ip
int *

variable_types: i int

return_type: struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *


decompiled_code:
int p_mindex_mem()
{
return fprint_mindex_mem(stdout, 1);
}

canonical_decompiled_code:
int func10()
{
return func9(stdout, 1);
}

original_code:
void p_mindex_mem()
{
  fprint_mindex_mem(stdout, TRUE);
}


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

if ( !a1 )
return 0LL;
v2 = intersect_clauses(a1[1]);
if ( clause_member_plist(a2, *a1) )
v2 = plist_prepend(v2, *a1);
return v2;
}

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

if ( !a1 )
return 0LL;
v2 = func1(a1[1]);
if ( func0(a2, *a1) )
v2 = plist_prepend(v2, *a1);
return v2;
}

original_code:
Plist intersect_clauses(Plist a, Plist b)
{
  if (a == ((void *)0))
    return ((void *)0);
  else {
    Plist c = intersect_clauses(a->next, b);
    if (clause_member_plist(b, a->v))
      return plist_prepend(c, a->v);
    else
      return c;
  }
}

canonical_original_code:
struct plist *intersect_clauses(struct plist *a, struct plist *b)
{
  if (a == ((void *)0))
    return ((void *)0);
  else {
    struct plist *c = intersect_clauses(a->next, b);
    if (clause_member_plist(b, a->v))
      return plist_prepend(c, a->v);
    else
      return c;
  }
}

variable_types:
b
struct plist *

return_type: struct plist { void *v; struct plist *next; } *


decompiled_code:
int p_lindex_mem()
{
return fprint_lindex_mem(stdout, 1);
}

canonical_decompiled_code:
int func3()
{
return func2(stdout, 1);
}

original_code:
void p_lindex_mem()
{
  fprint_lindex_mem(stdout, TRUE);
}


decompiled_code:
__int64 __fastcall subst_terms(int *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rbp
int v7; // edi
__int64 v8; // rbx
_QWORD *v9; // r12
__int64 v11; // rax
unsigned int v12; // eax
__int64 v13; // rbx

v4 = (__int64)a1;
v7 = *a1;
if ( v7 >= 0 )
{
v8 = 0LL;
if ( !*(_BYTE *)(v4 + 4) )
return v4;
goto LABEL_3;
}
v8 = 0LL;
if ( *(_BYTE *)(v4 + 4) )
{
do
{
LABEL_3:
v9 = (_QWORD *)(*(_QWORD *)(v4 + 8) + 8 * v8);
*v9 = subst_terms(*v9, a2, a3, a4);
++v8;
}
while ( *(unsigned __int8 *)(v4 + 4) > (int)v8 );
return v4;
}
v11 = sn_to_str((unsigned int)-v7);
if ( !(unsigned int)string_member_plist(v11, a4) )
{
v12 = position_of_term_in_tlist(v4, a2);
if ( v12 != -1 )
{
v13 = ith_in_plist(a3, v12);
zap_term(v4);
v4 = copy_term(v13);
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rbp
int v7; // edi
__int64 v8; // rbx
_QWORD *v9; // r12
__int64 v11; // rax
unsigned int v12; // eax
__int64 v13; // rbx

v4 = (__int64)a1;
v7 = *a1;
if ( v7 >= 0 )
{
v8 = 0LL;
if ( !*(_BYTE *)(v4 + 4) )
return v4;
goto LABEL_3;
}
v8 = 0LL;
if ( *(_BYTE *)(v4 + 4) )
{
do
{
LABEL_3:
v9 = (_QWORD *)(*(_QWORD *)(v4 + 8) + 8 * v8);
*v9 = func1(*v9, a2, a3, a4);
++v8;
}
while ( *(unsigned __int8 *)(v4 + 4) > (int)v8 );
return v4;
}
v11 = sn_to_str((unsigned int)-v7);
if ( !(unsigned int)string_member_plist(v11, a4) )
{
v12 = position_of_term_in_tlist(v4, a2);
if ( v12 != -1 )
{
v13 = ith_in_plist(a3, v12);
zap_term(v4);
v4 = copy_term(v13);
}
}
return v4;
}

original_code:
static
Term subst_terms(Term t, Plist vars, Plist terms, Plist qvars)
{
  if (((t)->private_symbol < 0 && (t)->arity == 0)) {
    if (!string_member_plist(sn_to_str((-((t)->private_symbol))), qvars)) {
      int i = position_of_term_in_tlist(t, vars);
      if (i != -1) {
 Term corresponding_term = ith_in_plist(terms, i);
 zap_term(t);
 t = copy_term(corresponding_term);
      }
    }
    return t;
  }
  else {
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = subst_terms(((t)->args[i]), vars, terms, qvars);
    return t;
  }
}

canonical_original_code:
static struct term *subst_terms(struct term *t, struct plist *vars, struct plist *terms, struct plist *qvars)
{
  if (((t)->private_symbol < 0 && (t)->arity == 0)) {
    if (!string_member_plist(sn_to_str((-((t)->private_symbol))), qvars)) {
      int i = position_of_term_in_tlist(t, vars);
      if (i != -1) {
 struct term *corresponding_term = ith_in_plist(terms, i);
 zap_term(t);
 t = copy_term(corresponding_term);
      }
    }
    return t;
  }
  else {
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = subst_terms(((t)->args[i]), vars, terms, qvars);
    return t;
  }
}

variable_types:
t
struct term *

variable_types:
terms
struct plist *

variable_types:
qvars
struct plist *

variable_types: struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *


decompiled_code:
int p_pindex_mem()
{
return fprint_pindex_mem(stdout, 1);
}

canonical_decompiled_code:
int func4()
{
return func3(stdout, 1);
}

original_code:
void p_pindex_mem()
{
  fprint_pindex_mem(stdout, TRUE);
}


decompiled_code:
int __fastcall print_banner(int a1, __int64 a2, char *a3, const char *a4, const char *a5, int a6)
{
unsigned int v10; // eax
const char *v11; // r15
const char *v12; // r13
const char *v13; // rbx
unsigned int v14; // eax
unsigned int v15; // eax
const char *v16; // r15
const char *v17; // r13
const char *v18; // rbx
unsigned int v19; // eax
__int64 v20; // rbx
const char *v21; // rdx

if ( a6 )
{
v15 = get_bits();
printf("%s%s (%d) version %s, %s.\n", "% ", a3, v15, a4, a5);
v16 = (const char *)get_date();
v17 = (const char *)hostname();
v18 = (const char *)username();
v19 = my_process_id();
printf("%sProcess %d was started by %s on %s,\n%s%s", "% ", v19, v18, v17, "% ", v16);
printf("%sThe command was \"", "% ");
if ( a1 <= 0 )
{
puts("\".");
return fflush(stdout);
}
}
else
{
print_separator(stdout, a3, 0);
v10 = get_bits();
printf("%s%s (%d) version %s, %s.\n", (const char *)&unk_2BC, a3, v10, a4, a5);
v11 = (const char *)get_date();
v12 = (const char *)hostname();
v13 = (const char *)username();
v14 = my_process_id();
printf(
"%sProcess %d was started by %s on %s,\n%s%s",
(const char *)&unk_2BC,
v14,
v13,
v12,
(const char *)&unk_2BC,
v11);
printf("%sThe command was \"", (const char *)&unk_2BC);
if ( a1 <= 0 )
{
puts("\".");
LABEL_4:
print_separator(stdout, "end of head", 0);
return fflush(stdout);
}
}
v20 = 0LL;
do
{
v21 = " ";
if ( a1 - 1 <= (int)v20 )
v21 = (const char *)&unk_2BC;
printf("%s%s", *(const char **)(a2 + 8 * v20++), v21);
}
while ( a1 > (int)v20 );
puts("\".");
if ( !a6 )
goto LABEL_4;
return fflush(stdout);
}

canonical_decompiled_code:
int __fastcall func1(int a1, __int64 a2, char *a3, const char *a4, const char *a5, int a6)
{
unsigned int v10; // eax
const char *v11; // r15
const char *v12; // r13
const char *v13; // rbx
unsigned int v14; // eax
unsigned int v15; // eax
const char *v16; // r15
const char *v17; // r13
const char *v18; // rbx
unsigned int v19; // eax
__int64 v20; // rbx
const char *v21; // rdx

if ( a6 )
{
v15 = get_bits();
printf("%s%s (%d) version %s, %s.\n", "% ", a3, v15, a4, a5);
v16 = (const char *)get_date();
v17 = (const char *)hostname();
v18 = (const char *)username();
v19 = my_process_id();
printf("%sProcess %d was started by %s on %s,\n%s%s", "% ", v19, v18, v17, "% ", v16);
printf("%sThe command was \"", "% ");
if ( a1 <= 0 )
{
puts("\".");
return fflush(stdout);
}
}
else
{
func0(stdout, a3, 0);
v10 = get_bits();
printf("%s%s (%d) version %s, %s.\n", (const char *)&unk_2BC, a3, v10, a4, a5);
v11 = (const char *)get_date();
v12 = (const char *)hostname();
v13 = (const char *)username();
v14 = my_process_id();
printf(
"%sProcess %d was started by %s on %s,\n%s%s",
(const char *)&unk_2BC,
v14,
v13,
v12,
(const char *)&unk_2BC,
v11);
printf("%sThe command was \"", (const char *)&unk_2BC);
if ( a1 <= 0 )
{
puts("\".");
LABEL_4:
func0(stdout, "end of head", 0);
return fflush(stdout);
}
}
v20 = 0LL;
do
{
v21 = " ";
if ( a1 - 1 <= (int)v20 )
v21 = (const char *)&unk_2BC;
printf("%s%s", *(const char **)(a2 + 8 * v20++), v21);
}
while ( a1 > (int)v20 );
puts("\".");
if ( !a6 )
goto LABEL_4;
return fflush(stdout);
}

original_code:
void print_banner(int argc, char **argv,
    char *name, char *version, char *date,
    BOOL as_comments)
{
  int i;
  char *com = (as_comments ? "% " : "");
  if (!as_comments)
    print_separator(stdout, name, FALSE);
  printf("%s%s (%d) version %s, %s.\n",
  com, name, get_bits(), version, date);
  printf("%sProcess %d was started by %s on %s,\n%s%s",
  com, my_process_id(), username(), hostname(), com, get_date());
  printf("%sThe command was \"", com);
  for(i = 0; i < argc; i++)
    printf("%s%s", argv[i], (i < argc-1 ? " " : ""));
  printf("\".\n");
  if (!as_comments)
    print_separator(stdout, "end of head", FALSE);
  fflush(stdout);
}

canonical_original_code:
void print_banner(int argc, char **argv, char *name, char *version, char *date, enum BOOL as_comments)
{
  int i;
  char *com = (as_comments ? "% " : "");
  if (!as_comments)
    print_separator(stdout, name, FALSE);
  printf("%s%s (%d) version %s, %s.\n",
  com, name, get_bits(), version, date);
  printf("%sProcess %d was started by %s on %s,\n%s%s",
  com, my_process_id(), username(), hostname(), com, get_date());
  printf("%sThe command was \"", com);
  for(i = 0; i < argc; i++)
    printf("%s%s", argv[i], (i < argc-1 ? " " : ""));
  printf("\".\n");
  if (!as_comments)
    print_separator(stdout, "end of head", FALSE);
  fflush(stdout);
}

variable_types:
name
char *

variable_types:
version
char *

variable_types:
date
char *

variable_types:
com
char *


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

if ( a1 <= 64 )
result = (unsigned int)(a1 - 48);
else
result = (unsigned int)(a1 - 55);
return result;
}

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

if ( a1 <= 64 )
result = (unsigned int)(a1 - 48);
else
result = (unsigned int)(a1 - 55);
return result;
}

original_code:
static unsigned int asc_to_int(char a)
{
 if (a >= 'A')
  return (a - 'A') + 10;
 else
  return a - '0';
}

variable_types: a char

return_type: unsigned int


decompiled_code:
__int64 __fastcall hex_to_int(char *a1)
{
int v1; // ebx

v1 = asc_to_int(*a1);
return 16 * v1 + (unsigned int)asc_to_int(a1[1]);
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1)
{
int v1; // ebx

v1 = func7(*a1);
return 16 * v1 + (unsigned int)func7(a1[1]);
}

original_code:
static unsigned int hex_to_int(const char *h)
{
 return asc_to_int(*h) * 0x10 + asc_to_int(*(h + 1));
}

canonical_original_code:
static unsigned int hex_to_int(char *h)
{
 return asc_to_int(*h) * 0x10 + asc_to_int(*(h + 1));
}

variable_types:
h
char *


decompiled_code:
__int64 __fastcall lhex_to_int(char *a1)
{
int v1; // ebx

v1 = hex_to_int(a1);
return (v1 << 8) + (unsigned int)hex_to_int(a1 + 2);
}

canonical_decompiled_code:
__int64 __fastcall func9(char *a1)
{
int v1; // ebx

v1 = func8(a1);
return (v1 << 8) + (unsigned int)func8(a1 + 2);
}

original_code:
static unsigned int lhex_to_int(const char *h)
{
 return hex_to_int(h) * 0x100 + hex_to_int(h + 2);
}

canonical_original_code:
static unsigned int lhex_to_int(char *h)
{
 return hex_to_int(h) * 0x100 + hex_to_int(h + 2);
}


decompiled_code:
_BOOL8 __fastcall check_sum(__int64 a1, int a2)
{
int v2; // er12
char *v3; // rbx
int v4; // ebp

v2 = hex_to_int((char *)(a1 + a2 - 2));
if ( a2 <= 3 )
{
LOBYTE(v4) = 0;
}
else
{
v3 = (char *)(a1 + 1);
v4 = 0;
do
{
v4 += hex_to_int(v3);
v3 += 2;
}
while ( v3 != (char *)(a1 + 2LL * ((unsigned int)(a2 - 4) >> 1) + 3) );
}
return (unsigned __int8)-(char)v4 == v2;
}

original_code:
static int check_sum(const char *str, int len)
{
 unsigned int sum, cal;
 int i;
 sum = hex_to_int(str + len - 2);
 for (cal = 0, i = 1; i < len - 2; i += 2)
  cal += hex_to_int(str + i);
 cal = 0x100 - cal & 0xFF;
 return sum == cal;
}

canonical_original_code:
static int check_sum(char *str, int len)
{
 unsigned int sum; unsigned int cal;
 int i;
 sum = hex_to_int(str + len - 2);
 for (cal = 0, i = 1; i < len - 2; i += 2)
  cal += hex_to_int(str + i);
 cal = 0x100 - cal & 0xFF;
 return sum == cal;
}

variable_types:
str
char *

variable_types: len int

variable_types:
sum
unsigned int

variable_types:
cal
unsigned int


decompiled_code:
_BOOL8 __fastcall check_hex_line(_BYTE *a1, int a2)
{
_BOOL8 result; // rax

if ( *a1 != 58 )
return 0LL;
result = 0LL;
if ( a2 > 10 )
{
result = check_sum((__int64)a1, a2);
if ( result )
result = 2 * (unsigned int)hex_to_int(a1 + 1) + 11 == a2;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(_BYTE *a1, int a2)
{
_BOOL8 result; // rax

if ( *a1 != 58 )
return 0LL;
result = 0LL;
if ( a2 > 10 )
{
result = func10((__int64)a1, a2);
if ( result )
result = 2 * (unsigned int)func8(a1 + 1) + 11 == a2;
}
return result;
}

original_code:
static int check_hex_line(const char *str, int len)
{
 if ((str[0] != ':') || (len < 11) || !check_sum(str, len) ||
  (hex_to_int(str + 1) * 2 + 11 != len))
  return 0;
 return 1;
}

canonical_original_code:
static int check_hex_line(char *str, int len)
{
 if ((str[0] != ':') || (len < 11) || !check_sum(str, len) ||
  (hex_to_int(str + 1) * 2 + 11 != len))
  return 0;
 return 1;
}


findloc

repo: jezze/gaz

decompiled_code:
__int64 __fastcall findloc(char *s1)
{
unsigned int v1; // ebp
__int64 *i; // rbx

v1 = Locs;
if ( Locs > 1023 )
return 0;
for ( i = &symbols[5 * Locs]; *((_BYTE *)i + 24) == 7 || *s1 != *(_BYTE *)*i || strcmp(s1, (const char *)*i); i += 5 )
{
if ( ++v1 == 1024 )
return 0;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1)
{
unsigned int v1; // ebp
__int64 *i; // rbx

v1 = Locs;
if ( Locs > 1023 )
return 0;
for ( i = &symbols[5 * Locs]; *((_BYTE *)i + 24) == 7 || *s1 != *(_BYTE *)*i || strcmp(s1, (const char *)*i); i += 5 )
{
if ( ++v1 == 1024 )
return 0;
}
return v1;
}

original_code:
static int findloc(char *s)
{
    int i;
    for (i = Locs; i < 1024; i++)
    {
        if (symbols[i].stcl != CMEMBER && *s == *symbols[i].name && !strcmp(s, symbols[i].name))
            return i;
    }
    return 0;
}

variable_types:
s
char *


findglob

decompiled_code:
__int64 __fastcall findglob(char *s1)
{
int v1; // er12
__int64 *v2; // rbx
unsigned int v3; // ebp

v1 = Globs;
if ( Globs <= 0 )
return 0;
v2 = symbols;
v3 = 0;
while ( *((_BYTE *)v2 + 24) == 7 || *s1 != *(_BYTE *)*v2 || strcmp(s1, (const char *)*v2) )
{
++v3;
v2 += 5;
if ( v3 == v1 )
return 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1)
{
int v1; // er12
__int64 *v2; // rbx
unsigned int v3; // ebp

v1 = Globs;
if ( Globs <= 0 )
return 0;
v2 = symbols;
v3 = 0;
while ( *((_BYTE *)v2 + 24) == 7 || *s1 != *(_BYTE *)*v2 || strcmp(s1, (const char *)*v2) )
{
++v3;
v2 += 5;
if ( v3 == v1 )
return 0;
}
return v3;
}

original_code:
static int findglob(char *s)
{
    int i;
    for (i = 0; i < Globs; i++)
    {
        if (symbols[i].stcl != CMEMBER && *s == *symbols[i].name && !strcmp(s, symbols[i].name))
            return i;
    }
    return 0;
}

variable_types: i int


newglob

decompiled_code:
__int64 newglob()
{
int v0; // ebx

v0 = Globs++;
if ( v0 >= Locs )
fatal("too many global symbols");
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // ebx

v0 = Globs++;
if ( v0 >= Locs )
fatal("too many global symbols");
return (unsigned int)v0;
}

original_code:
static int newglob(void)
{
    int p;
    if ((p = Globs++) >= Locs)
        fatal("too many global symbols");
    return p;
}

canonical_original_code:
static int newglob()
{
    int p;
    if ((p = Globs++) >= Locs)
        fatal("too many global symbols");
    return p;
}

variable_types: p int


newloc

decompiled_code:
__int64 newloc()
{
int v0; // ebx

v0 = Locs - 1;
Locs = v0;
if ( v0 <= Globs )
fatal("too many local symbols");
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx

v0 = Locs - 1;
Locs = v0;
if ( v0 <= Globs )
fatal("too many local symbols");
return (unsigned int)v0;
}

original_code:
static int newloc(void)
{
    int p;
    if ((p = --Locs) <= Globs)
        fatal("too many local symbols");
    return p;
}

canonical_original_code:
static int newloc()
{
    int p;
    if ((p = --Locs) <= Globs)
        fatal("too many local symbols");
    return p;
}


redeclare

decompiled_code:
__int64 __fastcall redeclare(int errnum, int a2, const char *a3)
{
unsigned int v3; // ebp

v3 = (unsigned int)a3;
if ( a2 == 3 )
{
if ( (_DWORD)a3 == 6 )
return 3;
if ( (_DWORD)a3 != 3 )
{
error((int)"static symbol redeclared extern: %s", errnum, a3);
return (unsigned int)a2;
}
goto LABEL_16;
}
if ( a2 <= 3 )
{
if ( a2 == 1 )
{
if ( (_DWORD)a3 == 2 )
return 1;
if ( (_DWORD)a3 != 1 )
{
error((int)"extern symbol redeclared static: %s", errnum, a3);
return (unsigned int)a2;
}
}
else if ( a2 == 2 )
{
if ( (unsigned int)((_DWORD)a3 - 1) > 1 )
error((int)"extern symbol redeclared static: %s", errnum, a3);
return v3;
}
LABEL_16:
error((int)"redefined symbol: %s", errnum, a3);
return v3;
}
if ( a2 != 6 )
goto LABEL_16;
if ( (_DWORD)a3 != 3 && (_DWORD)a3 != 6 )
error((int)"static symbol redeclared extern: %s", errnum, a3);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(int errnum, int a2, const char *a3)
{
unsigned int v3; // ebp

v3 = (unsigned int)a3;
if ( a2 == 3 )
{
if ( (_DWORD)a3 == 6 )
return 3;
if ( (_DWORD)a3 != 3 )
{
error((int)"static symbol redeclared extern: %s", errnum, a3);
return (unsigned int)a2;
}
goto LABEL_16;
}
if ( a2 <= 3 )
{
if ( a2 == 1 )
{
if ( (_DWORD)a3 == 2 )
return 1;
if ( (_DWORD)a3 != 1 )
{
error((int)"extern symbol redeclared static: %s", errnum, a3);
return (unsigned int)a2;
}
}
else if ( a2 == 2 )
{
if ( (unsigned int)((_DWORD)a3 - 1) > 1 )
error((int)"extern symbol redeclared static: %s", errnum, a3);
return v3;
}
LABEL_16:
error((int)"redefined symbol: %s", errnum, a3);
return v3;
}
if ( a2 != 6 )
goto LABEL_16;
if ( (_DWORD)a3 != 3 && (_DWORD)a3 != 6 )
error((int)"static symbol redeclared extern: %s", errnum, a3);
return v3;
}

original_code:
static int redeclare(char *name, int oldcls, int newcls)
{
    switch (oldcls)
    {
    case CEXTERN:
        if (newcls != CPUBLIC && newcls != CEXTERN)
            error("extern symbol redeclared static: %s", name);
        return newcls;
    case CPUBLIC:
        if (CEXTERN == newcls)
            return CPUBLIC;
        if (newcls != CPUBLIC)
        {
            error("extern symbol redeclared static: %s", name);
            return CPUBLIC;
        }
        break;
    case CSPROTO:
        if (newcls != CSTATIC && newcls != CSPROTO)
            error("static symbol redeclared extern: %s", name);
        return newcls;
    case CSTATIC:
        if (CSPROTO == newcls)
            return CSTATIC;
        if (newcls != CSTATIC)
        {
            error("static symbol redeclared extern: %s", name);
            return CSTATIC;
        }
        break;
    }
    error("redefined symbol: %s", name);
    return newcls;
}

variable_types: oldcls int

variable_types: newcls int


locname

decompiled_code:
char *__fastcall locname(char *src)
{
int v1; // er12

v1 = strlen(src) + 1;
if ( Nbot + v1 >= Ntop )
fatal("out of space for symbol names");
Ntop -= v1;
return strcpy(&Nlist[Ntop], src);
}

canonical_decompiled_code:
char *__fastcall func5(char *src)
{
int v1; // er12

v1 = strlen(src) + 1;
if ( Nbot + v1 >= Ntop )
fatal("out of space for symbol names");
Ntop -= v1;
return strcpy(&Nlist[Ntop], src);
}

original_code:
static char *locname(char *s)
{
    int k = strlen(s) + 1;
    int p;
    if (Nbot + k >= Ntop)
        fatal("out of space for symbol names");
    Ntop -= k;
    p = Ntop;
    strcpy(&Nlist[p], s);
    return &Nlist[p];
}

variable_types: k int

return_type: char *


findsym

decompiled_code:
__int64 __fastcall findsym(char *s1)
{
__int64 result; // rax

result = findloc(s1);
if ( !(_DWORD)result )
result = findglob(s1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *s1)
{
__int64 result; // rax

result = func0(s1);
if ( !(_DWORD)result )
result = func1(s1);
return result;
}

original_code:
int findsym(char *s)
{
    int y;
    if ((y = findloc(s)) != 0)
        return y;
    return findglob(s);
}

variable_types: y int


findstruct

decompiled_code:
__int64 __fastcall findstruct(char *s1)
{
unsigned int v1; // ebx
__int64 *v2; // rbp
int v3; // er13
__int64 *v4; // rbp

v1 = Locs;
if ( Locs > 1023 )
{
LABEL_8:
v3 = Globs;
if ( Globs <= 0 )
{
v1 = 0;
}
else
{
v4 = symbols;
v1 = 0;
while ( *((_BYTE *)v4 + 12) != 5 || *s1 != *(_BYTE *)*v4 || strcmp(s1, (const char *)*v4) )
{
++v1;
v4 += 5;
if ( v1 == v3 )
return 0;
}
}
}
else
{
v2 = &symbols[5 * Locs];
while ( *((_BYTE *)v2 + 12) != 5 || *s1 != *(_BYTE *)*v2 || strcmp(s1, (const char *)*v2) )
{
++v1;
v2 += 5;
if ( v1 == 1024 )
goto LABEL_8;
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *s1)
{
unsigned int v1; // ebx
__int64 *v2; // rbp
int v3; // er13
__int64 *v4; // rbp

v1 = Locs;
if ( Locs > 1023 )
{
LABEL_8:
v3 = Globs;
if ( Globs <= 0 )
{
v1 = 0;
}
else
{
v4 = symbols;
v1 = 0;
while ( *((_BYTE *)v4 + 12) != 5 || *s1 != *(_BYTE *)*v4 || strcmp(s1, (const char *)*v4) )
{
++v1;
v4 += 5;
if ( v1 == v3 )
return 0;
}
}
}
else
{
v2 = &symbols[5 * Locs];
while ( *((_BYTE *)v2 + 12) != 5 || *s1 != *(_BYTE *)*v2 || strcmp(s1, (const char *)*v2) )
{
++v1;
v2 += 5;
if ( v1 == 1024 )
goto LABEL_8;
}
}
return v1;
}

original_code:
int findstruct(char *s)
{
    int i;
    for (i = Locs; i < 1024; i++)
        if (TSTRUCT == symbols[i].type && *s == *symbols[i].name && !strcmp(s, symbols[i].name))
            return i;
    for (i = 0; i < Globs; i++)
        if (TSTRUCT == symbols[i].type && *s == *symbols[i].name && !strcmp(s, symbols[i].name))
            return i;
    return 0;
}


findmem

decompiled_code:
__int64 __fastcall findmem(int a1, const char *a2)
{
int v2; // ebx
int v3; // er13
int v4; // er14
__int64 *i; // rbp

v2 = a1 + 1;
v3 = Globs;
v4 = Locs;
for ( i = &symbols[5 * a1 + 5]; ; i += 5 )
{
if ( v3 > v2 )
goto LABEL_2;
if ( v2 > 1023 || v4 > v2 )
break;
if ( *((_BYTE *)i + 24) != 7 )
return 0;
LABEL_2:
if ( *a2 == *(_BYTE *)*i && !strcmp(a2, (const char *)*i) )
return (unsigned int)v2;
++v2;
}
return 0;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, const char *a2)
{
int v2; // ebx
int v3; // er13
int v4; // er14
__int64 *i; // rbp

v2 = a1 + 1;
v3 = Globs;
v4 = Locs;
for ( i = &symbols[5 * a1 + 5]; ; i += 5 )
{
if ( v3 > v2 )
goto LABEL_2;
if ( v2 > 1023 || v4 > v2 )
break;
if ( *((_BYTE *)i + 24) != 7 )
return 0;
LABEL_2:
if ( *a2 == *(_BYTE *)*i && !strcmp(a2, (const char *)*i) )
return (unsigned int)v2;
++v2;
}
return 0;
}

original_code:
int findmem(int y, char *s)
{
    y++;
    while (y < Globs || y >= Locs && y < 1024 && CMEMBER == symbols[y].stcl)
    {
        if (*s == *symbols[y].name && !strcmp(s, symbols[y].name))
            return y;
        y++;
    }
    return 0;
}


galloc

decompiled_code:
char *__fastcall galloc(int a1)
{
int v1; // eax

if ( Nbot + a1 >= Ntop )
fatal("out of space for symbol names");
v1 = Nbot;
Nbot += a1;
return &Nlist[v1];
}

canonical_decompiled_code:
char *__fastcall func9(int a1)
{
int v1; // eax

if ( Nbot + a1 >= Ntop )
fatal("out of space for symbol names");
v1 = Nbot;
Nbot += a1;
return &Nlist[v1];
}

original_code:
char *galloc(int k)
{
    int p;
    if (Nbot + k >= Ntop)
        fatal("out of space for symbol names");
    p = Nbot;
    Nbot += k;
    return &Nlist[p];
}


globname

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

v1 = strlen(src);
v2 = galloc(v1 + 1);
return strcpy(v2, src);
}

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

v1 = strlen(src);
v2 = func9(v1 + 1);
return strcpy(v2, src);
}

original_code:
static char *globname(char *s)
{
    char *p = galloc(strlen(s) + 1);
    strcpy(p, s);
    return p;
}

variable_types:
p
char *


clrlocs

decompiled_code:
void clrlocs()
{
Ntop = 0x4000;
Locs = 1024;
}

original_code:
void clrlocs(void)
{
    Ntop = 16384;
    Locs = 1024;
}

canonical_original_code:
void clrlocs()
{
    Ntop = 16384;
    Locs = 1024;
}


objsize

decompiled_code:
__int64 __fastcall objsize(unsigned int a1, int a2, int a3)
{
__int64 result; // rax
int v5; // eax

if ( a1 == 2 )
{
result = arch_intsize();
}
else
{
result = a1;
if ( a1 == 1 )
goto LABEL_12;
if ( a1 - 3 <= 1 )
goto LABEL_19;
if ( a1 == 8 )
goto LABEL_19;
if ( a1 - 5 <= 1 )
goto LABEL_19;
if ( a1 == 9 )
goto LABEL_19;
v5 = a1 & 0xE000;
if ( ((v5 - 24576) & 0xFFFFDFFF) == 0 || ((v5 - 40960) & 0xFFFFDFFF) == 0 )
goto LABEL_19;
if ( ((v5 - 0x2000) & 0xFFFFDFFF) == 0 )
{
result = LODWORD(symbols[5 * (int)(a1 & 0xFFFF1FFF) + 2]);
goto LABEL_12;
}
result = 0LL;
if ( a1 == 10 )
LABEL_19:
result = arch_pointersize();
}
LABEL_12:
if ( (unsigned int)(a2 - 3) <= 1 )
return 0LL;
if ( a2 == 2 )
result = (unsigned int)(a3 * result);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1, int a2, int a3)
{
__int64 result; // rax
int v5; // eax

if ( a1 == 2 )
{
result = arch_intsize();
}
else
{
result = a1;
if ( a1 == 1 )
goto LABEL_12;
if ( a1 - 3 <= 1 )
goto LABEL_19;
if ( a1 == 8 )
goto LABEL_19;
if ( a1 - 5 <= 1 )
goto LABEL_19;
if ( a1 == 9 )
goto LABEL_19;
v5 = a1 & 0xE000;
if ( ((v5 - 24576) & 0xFFFFDFFF) == 0 || ((v5 - 40960) & 0xFFFFDFFF) == 0 )
goto LABEL_19;
if ( ((v5 - 0x2000) & 0xFFFFDFFF) == 0 )
{
result = LODWORD(symbols[5 * (int)(a1 & 0xFFFF1FFF) + 2]);
goto LABEL_12;
}
result = 0LL;
if ( a1 == 10 )
LABEL_19:
result = arch_pointersize();
}
LABEL_12:
if ( (unsigned int)(a2 - 3) <= 1 )
return 0LL;
if ( a2 == 2 )
result = (unsigned int)(a3 * result);
return result;
}

original_code:
int objsize(int prim, int type, int size)
{
    int k = 0;
    int sp = prim & STCMASK;
    if (PINT == prim)
        k = arch_intsize();
    else if (PCHAR == prim)
        k = 1;
    else if (INTPTR == prim || CHARPTR == prim || VOIDPTR == prim)
        k = arch_pointersize();
    else if (INTPP == prim || CHARPP == prim || VOIDPP == prim)
        k = arch_pointersize();
    else if (STCPTR == sp || STCPP == sp)
        k = arch_pointersize();
    else if (UNIPTR == sp || UNIPP == sp)
        k = arch_pointersize();
    else if (PSTRUCT == sp || PUNION == sp)
        k = symbols[prim & ~STCMASK].size;
    else if (FUNPTR == prim)
        k = arch_pointersize();
    if (TFUNCTION == type || TCONSTANT == type)
        return 0;
    if (TARRAY == type)
        k *= size;
    return k;
}

variable_types: prim int

variable_types: type int

variable_types: size int

variable_types: sp int


defglob

decompiled_code:
__int64 __fastcall defglob(__int64 a1, unsigned int a2, int a3, unsigned int a4, unsigned int a5, int a6, int a7)
{
__int64 result; // rax
unsigned int v12; // ebx
__int64 v13; // rax
unsigned int v14; // ebx
__int64 v15; // rax
__int64 v16; // rax
unsigned int v17; // er14
__int64 v18; // rax
unsigned int v19; // er14
__int64 v20; // rax

result = (unsigned int)(a3 - 3);
if ( (unsigned int)result > 1 )
{
result = gendata();
if ( a6 == 1 )
result = genpublic(a1);
if ( !a7 || a3 != 2 )
{
if ( a3 == 2 )
{
if ( (a2 & 0xE000) != 0 )
{
v14 = objsize(a2, 2, a4);
v15 = gsym(a1);
return genbss(v15, v14);
}
if ( a2 == 1 )
{
v16 = gsym(a1);
return genbss(v16, a4);
}
}
else
{
if ( (a2 & 0xE000) != 0 )
{
v12 = objsize(a2, 1, a4);
v13 = gsym(a1);
return genbss(v13, v12);
}
genname(a1);
if ( a2 == 1 )
{
gendefb(a5);
return genalign(1LL);
}
}
if ( a2 == 2 )
{
if ( a3 == 2 )
{
v17 = arch_intsize() * a4;
v18 = gsym(a1);
result = genbss(v18, v17);
}
else
{
result = gendefw(a5);
}
}
else if ( a3 == 2 )
{
v19 = arch_pointersize() * a4;
v20 = gsym(a1);
result = genbss(v20, v19);
}
else
{
result = gendefp(a5);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, unsigned int a2, int a3, unsigned int a4, unsigned int a5, int a6, int a7)
{
__int64 result; // rax
unsigned int v12; // ebx
__int64 v13; // rax
unsigned int v14; // ebx
__int64 v15; // rax
__int64 v16; // rax
unsigned int v17; // er14
__int64 v18; // rax
unsigned int v19; // er14
__int64 v20; // rax

result = (unsigned int)(a3 - 3);
if ( (unsigned int)result > 1 )
{
result = gendata();
if ( a6 == 1 )
result = genpublic(a1);
if ( !a7 || a3 != 2 )
{
if ( a3 == 2 )
{
if ( (a2 & 0xE000) != 0 )
{
v14 = func12(a2, 2, a4);
v15 = gsym(a1);
return genbss(v15, v14);
}
if ( a2 == 1 )
{
v16 = gsym(a1);
return genbss(v16, a4);
}
}
else
{
if ( (a2 & 0xE000) != 0 )
{
v12 = func12(a2, 1, a4);
v13 = gsym(a1);
return genbss(v13, v12);
}
genname(a1);
if ( a2 == 1 )
{
gendefb(a5);
return genalign(1LL);
}
}
if ( a2 == 2 )
{
if ( a3 == 2 )
{
v17 = arch_intsize() * a4;
v18 = gsym(a1);
result = genbss(v18, v17);
}
else
{
result = gendefw(a5);
}
}
else if ( a3 == 2 )
{
v19 = arch_pointersize() * a4;
v20 = gsym(a1);
result = genbss(v20, v19);
}
else
{
result = gendefp(a5);
}
}
}
return result;
}

original_code:
static void defglob(char *name, int prim, int type, int size, int val, int scls, int init)
{
    if (TCONSTANT == type || TFUNCTION == type)
        return;
    gendata();
    if (CPUBLIC == scls)
        genpublic(name);
    if (init && TARRAY == type)
        return;
    if (TARRAY != type && !(prim & STCMASK))
        genname(name);
    if (prim & STCMASK)
    {
        if (TARRAY == type)
            genbss(gsym(name), objsize(prim, TARRAY, size));
        else
            genbss(gsym(name), objsize(prim, TVARIABLE, size));
    }
    else if (PCHAR == prim)
    {
        if (TARRAY == type)
        {
            genbss(gsym(name), size);
        }
        else
        {
            gendefb(val);
            genalign(1);
        }
    }
    else if (PINT == prim)
    {
        if (TARRAY == type)
            genbss(gsym(name), size*arch_intsize());
        else
            gendefw(val);
    }
    else
    {
        if (TARRAY == type)
            genbss(gsym(name), size*arch_pointersize());
        else
            gendefp(val);
    }
}

variable_types:
name
char *

variable_types: val int

variable_types: scls int

variable_types: init int


addglob

decompiled_code:
__int64 __fastcall addglob(char *src, unsigned int a2, int a3, unsigned int a4, unsigned int a5, unsigned int a6, __int64 a7, int a8)
{
unsigned int v11; // eax
unsigned int v12; // ebx
__int64 v13; // rcx
__int64 v16; // [rsp+10h] [rbp-48h]
__int64 v17; // [rsp+18h] [rbp-40h]

v11 = findglob(src);
if ( v11 )
{
v12 = v11;
v17 = 4LL * (int)v11;
v16 = (int)v11;
a4 = redeclare((int)src, SLOBYTE(symbols[5 * (int)v11 + 3]), (const char *)a4);
if ( BYTE4(symbols[v16 + 1 + v17]) == 3 )
{
a7 = symbols[5 * (int)v12 + 4];
if ( LODWORD(symbols[5 * (int)v12 + 1]) != a2 || a3 != 3 )
error((int)"redefinition does not match prior type: %s", (int)src, (const char *)(int)v12);
}
}
else
{
v12 = newglob();
symbols[5 * (int)v12] = (__int64)globname(src);
}
if ( (a4 & 0xFFFFFFFD) == 1 )
defglob((__int64)src, a2, a3, a5, a6, a4, a8);
v13 = 5LL * (int)v12;
LODWORD(symbols[v13 + 1]) = a2;
BYTE4(symbols[v13 + 1]) = a3;
LOBYTE(symbols[v13 + 3]) = a4;
LODWORD(symbols[v13 + 2]) = a5;
HIDWORD(symbols[v13 + 2]) = a6;
symbols[v13 + 4] = a7;
return v12;
}

canonical_decompiled_code:
__int64 __fastcall func14(char *src, unsigned int a2, int a3, unsigned int a4, unsigned int a5, unsigned int a6, __int64 a7, int a8)
{
unsigned int v11; // eax
unsigned int v12; // ebx
__int64 v13; // rcx
__int64 v16; // [rsp+10h] [rbp-48h]
__int64 v17; // [rsp+18h] [rbp-40h]

v11 = func1(src);
if ( v11 )
{
v12 = v11;
v17 = 4LL * (int)v11;
v16 = (int)v11;
a4 = func4((int)src, SLOBYTE(symbols[5 * (int)v11 + 3]), (const char *)a4);
if ( BYTE4(symbols[v16 + 1 + v17]) == 3 )
{
a7 = symbols[5 * (int)v12 + 4];
if ( LODWORD(symbols[5 * (int)v12 + 1]) != a2 || a3 != 3 )
error((int)"redefinition does not match prior type: %s", (int)src, (const char *)(int)v12);
}
}
else
{
v12 = func2();
symbols[5 * (int)v12] = (__int64)func10(src);
}
if ( (a4 & 0xFFFFFFFD) == 1 )
func13((__int64)src, a2, a3, a5, a6, a4, a8);
v13 = 5LL * (int)v12;
LODWORD(symbols[v13 + 1]) = a2;
BYTE4(symbols[v13 + 1]) = a3;
LOBYTE(symbols[v13 + 3]) = a4;
LODWORD(symbols[v13 + 2]) = a5;
HIDWORD(symbols[v13 + 2]) = a6;
symbols[v13 + 4] = a7;
return v12;
}

original_code:
int addglob(char *name, int prim, int type, int scls, int size, int val, char *mtext, int init)
{
    int y;
    if ((y = findglob(name)) != 0)
    {
        scls = redeclare(name, symbols[y].stcl, scls);
        if (TFUNCTION == symbols[y].type)
            mtext = symbols[y].mtext;
    }
    if (0 == y)
    {
        y = newglob();
        symbols[y].name = globname(name);
    }
    else if (TFUNCTION == symbols[y].type)
    {
        if (symbols[y].prims != prim || symbols[y].type != type)
            error("redefinition does not match prior type: %s", name);
    }
    if (CPUBLIC == scls || CSTATIC == scls)
        defglob(name, prim, type, size, val, scls, init);
    symbols[y].prims = prim;
    symbols[y].type = type;
    symbols[y].stcl = scls;
    symbols[y].size = size;
    symbols[y].value = val;
    symbols[y].mtext = mtext;
    return y;
}

variable_types:
mtext
char *


defloc

decompiled_code:
__int64 __fastcall defloc(unsigned int a1, int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
unsigned int v8; // ebx
__int64 v9; // rax
__int64 result; // rax
unsigned int v11; // ebx
__int64 v12; // rax
__int64 v13; // rax
unsigned int v14; // er13
__int64 v15; // rax
unsigned int v16; // er13
__int64 v17; // rax

gendata();
if ( a2 == 2 )
{
if ( (a1 & 0xE000) != 0 )
{
v11 = objsize(a1, 2, a3);
v12 = labname(a4);
return genbss(v12, v11);
}
if ( a1 == 1 )
{
v13 = labname(a4);
return genbss(v13, a3);
}
}
else
{
if ( (a1 & 0xE000) != 0 )
{
v8 = objsize(a1, 1, a3);
v9 = labname(a4);
return genbss(v9, v8);
}
genlab(a4);
if ( a1 == 1 )
{
gendefb(a5);
return genalign(1LL);
}
}
if ( a1 == 2 )
{
if ( a2 == 2 )
{
v14 = arch_intsize() * a3;
v15 = labname(a4);
result = genbss(v15, v14);
}
else
{
result = gendefw(a5);
}
}
else if ( a2 == 2 )
{
v16 = arch_pointersize() * a3;
v17 = labname(a4);
result = genbss(v17, v16);
}
else
{
result = gendefp(a5);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
unsigned int v8; // ebx
__int64 v9; // rax
__int64 result; // rax
unsigned int v11; // ebx
__int64 v12; // rax
__int64 v13; // rax
unsigned int v14; // er13
__int64 v15; // rax
unsigned int v16; // er13
__int64 v17; // rax

gendata();
if ( a2 == 2 )
{
if ( (a1 & 0xE000) != 0 )
{
v11 = func12(a1, 2, a3);
v12 = labname(a4);
return genbss(v12, v11);
}
if ( a1 == 1 )
{
v13 = labname(a4);
return genbss(v13, a3);
}
}
else
{
if ( (a1 & 0xE000) != 0 )
{
v8 = func12(a1, 1, a3);
v9 = labname(a4);
return genbss(v9, v8);
}
genlab(a4);
if ( a1 == 1 )
{
gendefb(a5);
return genalign(1LL);
}
}
if ( a1 == 2 )
{
if ( a2 == 2 )
{
v14 = arch_intsize() * a3;
v15 = labname(a4);
result = genbss(v15, v14);
}
else
{
result = gendefw(a5);
}
}
else if ( a2 == 2 )
{
v16 = arch_pointersize() * a3;
v17 = labname(a4);
result = genbss(v17, v16);
}
else
{
result = gendefp(a5);
}
return result;
}

original_code:
static void defloc(int prim, int type, int size, int val, int init)
{
    gendata();
    if (type != TARRAY && !(prim &STCMASK))
        genlab(val);
    if (prim & STCMASK)
    {
        if (TARRAY == type)
            genbss(labname(val), objsize(prim, TARRAY, size));
        else
            genbss(labname(val), objsize(prim, TVARIABLE, size));
    }
    else if (PCHAR == prim)
    {
        if (TARRAY == type)
        {
            genbss(labname(val), size);
        }
        else
        {
            gendefb(init);
            genalign(1);
        }
    }
    else if (PINT == prim)
    {
        if (TARRAY == type)
            genbss(labname(val), size*arch_intsize());
        else
            gendefw(init);
    }
    else
    {
        if (TARRAY == type)
            genbss(labname(val), size*arch_pointersize());
        else
            gendefp(init);
    }
}


addloc

decompiled_code:
__int64 __fastcall addloc(char *src, unsigned int a2, int a3, int a4, unsigned int a5, unsigned int a6, int a7)
{
const char *v10; // rdx
unsigned int v11; // ebp
char *v12; // rax
__int64 v13; // rcx

if ( (unsigned int)findloc(src) )
error((int)"redefinition of: %s", (int)src, v10);
v11 = newloc();
if ( a4 == 4 )
defloc(a2, a3, a5, a6, a7);
v12 = locname(src);
v13 = 5LL * (int)v11;
symbols[v13] = (__int64)v12;
LODWORD(symbols[v13 + 1]) = a2;
BYTE4(symbols[v13 + 1]) = a3;
LOBYTE(symbols[v13 + 3]) = a4;
LODWORD(symbols[v13 + 2]) = a5;
HIDWORD(symbols[v13 + 2]) = a6;
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func16(char *src, unsigned int a2, int a3, int a4, unsigned int a5, unsigned int a6, int a7)
{
const char *v10; // rdx
unsigned int v11; // ebp
char *v12; // rax
__int64 v13; // rcx

if ( (unsigned int)func0(src) )
error((int)"redefinition of: %s", (int)src, v10);
v11 = func3();
if ( a4 == 4 )
func15(a2, a3, a5, a6, a7);
v12 = func5(src);
v13 = 5LL * (int)v11;
symbols[v13] = (__int64)v12;
LODWORD(symbols[v13 + 1]) = a2;
BYTE4(symbols[v13 + 1]) = a3;
LOBYTE(symbols[v13 + 3]) = a4;
LODWORD(symbols[v13 + 2]) = a5;
HIDWORD(symbols[v13 + 2]) = a6;
return v11;
}

original_code:
int addloc(char *name, int prim, int type, int scls, int size, int val, int init)
{
    int y;
    if (findloc(name))
        error("redefinition of: %s", name);
    y = newloc();
    if (CLSTATC == scls)
        defloc(prim, type, size, val, init);
    symbols[y].name = locname(name);
    symbols[y].prims = prim;
    symbols[y].type = type;
    symbols[y].stcl = scls;
    symbols[y].size = size;
    symbols[y].value = val;
    return y;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
Line = 1;
Putback = 10;
Rejected = -1;
Errors = 0;
Syntoken = 0;
Globs = 0;
Locs = 1024;
Nbot = 0;
Ntop = 0x4000;
Bsp = 0;
Csp = 0;
Q_type = 0;
Q_cmp = 0;
File = (__int64)"(stdin)";
addglob(&unk_E790, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL);
genprelude();
Token = scan();
while ( Token != 71 )
top();
genpostlude();
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    Line = 1;
    Putback = '\n';
    Rejected = -1;
    Errors = 0;
    Syntoken = 0;
    Globs = 0;
    Locs = 1024;
    Nbot = 0;
    Ntop = 16384;
    Bsp = 0;
    Csp = 0;
    Q_type = empty;
    Q_cmp = none;
    File = "(stdin)";
    addglob("", 0, 0, 0, 0, 0, ((void *)0), 0);
    genprelude();
    Token = scan();
    while (XEOF != Token)
        top();
    genpostlude();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


copyname

decompiled_code:
char *__fastcall copyname(char *a1, const char *a2)
{
char *result; // rax

result = strncpy(a1, a2, 0x10uLL);
a1[16] = 0;
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *a1, const char *a2)
{
char *result; // rax

result = strncpy(a1, a2, 0x10uLL);
a1[16] = 0;
return result;
}

original_code:
void copyname(char *name, char *s)
{
    strncpy(name, s, 16);
    name[16] = 0;
}

variable_types:
s
char *


inttype

decompiled_code:
_BOOL8 __fastcall inttype(int a1)
{
return (unsigned int)(a1 - 1) <= 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(int a1)
{
return (unsigned int)(a1 - 1) <= 1;
}

original_code:
int inttype(int p)
{
    return PINT == p || PCHAR == p;
}

variable_types: p int


comptype

decompiled_code:
_BOOL8 __fastcall comptype(__int16 a1)
{
return (((a1 & 0xE000) - 0x2000) & 0xFFFFDFFF) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int16 a1)
{
return (((a1 & 0xE000) - 0x2000) & 0xFFFFDFFF) == 0;
}

original_code:
int comptype(int p)
{
    p &= STCMASK;
    return p == PSTRUCT || p == PUNION;
}


fatal

decompiled_code:
void __fastcall __noreturn fatal(char *a1)
{
error(a1);
error("fatal error, stop");
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(char *a1)
{
func4(a1);
func4("fatal error, stop");
exit(1);
}

original_code:
void fatal(char *s)
{
    error(s, ((void *)0));
    error("fatal error, stop", ((void *)0));
    exit(1);
}


error

decompiled_code:
__int64 __fastcall error(char *format, __int64 a2)
{
__int64 result; // rax

if ( !Syntoken )
{
fprintf(stderr, "error: %s: %d: ", (const char *)File, (unsigned int)Line);
fprintf(stderr, format, a2);
fputc(10, stderr);
result = (unsigned int)(Errors + 1);
Errors = result;
if ( (int)result > 10 )
{
Errors = 0;
fatal("too many errors");
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *format, __int64 a2)
{
__int64 result; // rax

if ( !Syntoken )
{
fprintf(stderr, "error: %s: %d: ", (const char *)File, (unsigned int)Line);
fprintf(stderr, format, a2);
fputc(10, stderr);
result = (unsigned int)(Errors + 1);
Errors = result;
if ( (int)result > 10 )
{
Errors = 0;
func3("too many errors");
}
}
return result;
}

original_code:
void error(char *s, char *a)
{
    if (Syntoken)
        return;
    fprintf(stderr, "error: %s: %d: ", File, Line);
    fprintf(stderr, s, a);
    fprintf(stderr, "\n");
    if (++Errors > 10)
    {
        Errors = 0;
        fatal("too many errors");
    }
}

variable_types:
a
char *


match

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

if ( Token != a1 )
return error("%s expected", a2);
result = scan();
Token = result;
return result;
}

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

if ( Token != a1 )
return func4("%s expected", a2);
result = scan();
Token = result;
return result;
}

original_code:
void match(int t, char *what)
{
    if (Token == t)
    {
        Token = scan();
    }
    else
    {
        error("%s expected", what);
    }
}

variable_types: t int

variable_types:
what
char *


lparen

original_code:
void lparen(void)
{
    match(LPAREN, "'('");
}

canonical_original_code:
void lparen()
{
    match(LPAREN, "'('");
}


rparen

original_code:
void rparen(void)
{
    match(RPAREN, "')'");
}

canonical_original_code:
void rparen()
{
    match(RPAREN, "')'");
}


lbrace

original_code:
void lbrace(void)
{
    match(LBRACE, "'{'");
}

canonical_original_code:
void lbrace()
{
    match(LBRACE, "'{'");
}


rbrace

original_code:
void rbrace(void)
{
    match(RBRACE, "'}'");
}

canonical_original_code:
void rbrace()
{
    match(RBRACE, "'}'");
}


rbrack

original_code:
void rbrack(void)
{
    match(RBRACK, "']'");
}

canonical_original_code:
void rbrack()
{
    match(RBRACK, "']'");
}


semi

original_code:
void semi(void)
{
    match(SEMI, "';'");
}

canonical_original_code:
void semi()
{
    match(SEMI, "';'");
}


colon

original_code:
void colon(void)
{
    match(COLON, "':'");
}

canonical_original_code:
void colon()
{
    match(COLON, "':'");
}


ident

decompiled_code:
__int64 ident()
{
return match(46, (__int64)"identifier");
}

canonical_decompiled_code:
__int64 func13()
{
return func5(46, (__int64)"identifier");
}

original_code:
void ident(void)
{
    match(IDENT, "identifier");
}

canonical_original_code:
void ident()
{
    match(IDENT, "identifier");
}


eofcheck

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

result = 0LL;
if ( Token == 71 )
{
error("missing '}'", 0LL);
result = 1LL;
}
return result;
}

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

result = 0LL;
if ( Token == 71 )
{
func4("missing '}'", 0LL);
result = 1LL;
}
return result;
}

original_code:
int eofcheck(void)
{
    if (XEOF == Token)
    {
        error("missing '}'", ((void *)0));
        return 1;
    }
    return 0;
}

canonical_original_code:
int eofcheck()
{
    if (XEOF == Token)
    {
        error("missing '}'", ((void *)0));
        return 1;
    }
    return 0;
}


cerror

decompiled_code:
__int64 __fastcall cerror(char *format, unsigned int a2)
{
char v3[56]; // [rsp+0h] [rbp-38h] BYREF

if ( isprint(a2) )
sprintf(v3, "'%c' (\\x%x)", a2, a2);
else
sprintf(v3, "\\x%x", a2);
return error(format, (__int64)v3);
}

canonical_decompiled_code:
__int64 __fastcall func15(char *format, unsigned int a2)
{
char v3[56]; // [rsp+0h] [rbp-38h] BYREF

if ( isprint(a2) )
sprintf(v3, "'%c' (\\x%x)", a2, a2);
else
sprintf(v3, "\\x%x", a2);
return func4(format, (__int64)v3);
}

original_code:
void cerror(char *s, int c)
{
    char buf[32];
    if (isprint(c))
        sprintf(buf, "'%c' (\\x%x)", c, c);
    else
        sprintf(buf, "\\x%x", c);
    error(s, buf);
}

variable_types: c int

variable_types:
buf
char [32]


synch

decompiled_code:
__int64 __fastcall synch(unsigned int a1)
{
int v1; // eax
__int64 result; // rax

v1 = scan();
if ( v1 == a1 )
{
result = a1;
}
else
{
if ( v1 == -1 )
LABEL_5:
fatal("error recovery failed");
while ( 1 )
{
result = next();
if ( a1 == (_DWORD)result )
break;
if ( (_DWORD)result == -1 )
goto LABEL_5;
}
}
Syntoken = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1)
{
int v1; // eax
__int64 result; // rax

v1 = scan();
if ( v1 == a1 )
{
result = a1;
}
else
{
if ( v1 == -1 )
LABEL_5:
func3("error recovery failed");
while ( 1 )
{
result = next();
if ( a1 == (_DWORD)result )
break;
if ( (_DWORD)result == -1 )
goto LABEL_5;
}
}
Syntoken = a1;
return result;
}

original_code:
int synch(int syn)
{
    int t = scan();
    while (t != syn)
    {
        if ((-1) == t)
            fatal("error recovery failed");
        t = next();
    }
    Syntoken = syn;
    return t;
}

variable_types: syn int


genraw

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

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

original_code:
void genraw(char *s)
{
    fprintf(stdout, "%s", s);
}


gen

decompiled_code:
int __fastcall gen(const char *a1)
{
return fprintf(stdout, "\t%s\n", a1);
}

canonical_decompiled_code:
int __fastcall func18(const char *a1)
{
return fprintf(stdout, "\t%s\n", a1);
}

original_code:
void gen(char *s)
{
    fprintf(stdout, "\t%s\n", s);
}


ngen

decompiled_code:
int __fastcall ngen(char *format, __int64 a2, unsigned int a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func19(char *format, __int64 a2, unsigned int a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3);
return fputc(10, stdout);
}

original_code:
void ngen(char *s, char *inst, int n)
{
    fputc('\t', stdout);
    fprintf(stdout, s, inst, n);
    fputc('\n', stdout);
}

variable_types:
inst
char *

variable_types: n int


decompiled_code:
int __fastcall ngen2(char *format, __int64 a2, unsigned int a3, unsigned int a4)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3, a4);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func20(char *format, __int64 a2, unsigned int a3, unsigned int a4)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3, a4);
return fputc(10, stdout);
}

original_code:
void ngen2(char *s, char *inst, int n, int a)
{
    fputc('\t', stdout);
    fprintf(stdout, s, inst, n, a);
    fputc('\n', stdout);
}

variable_types: a int


lgen

decompiled_code:
int __fastcall lgen(char *format, __int64 a2, unsigned int a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, 76LL, a3);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func21(char *format, __int64 a2, unsigned int a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, 76LL, a3);
return fputc(10, stdout);
}

original_code:
void lgen(char *s, char *inst, int n) {
    fputc('\t', stdout);
    fprintf(stdout, s, inst, 'L', n);
    fputc('\n', stdout);
}


decompiled_code:
int __fastcall lgen2(char *format, unsigned int a2, unsigned int a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, 76LL, a3);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func22(char *format, unsigned int a2, unsigned int a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, 76LL, a3);
return fputc(10, stdout);
}

original_code:
void lgen2(char *s, int v1, int v2)
{
    fputc('\t', stdout);
    fprintf(stdout, s, v1, 'L', v2);
    fputc('\n', stdout);
}