decompiled_code:
__int64 __fastcall collect_mace4_syms(__int64 a1, int a2)
{
__int64 v2; // r13
__int64 v3; // rbp
unsigned int *v4; // r14
int v5; // er12
unsigned int v6; // er15
__int64 v7; // rax
int v8; // eax
unsigned int *v9; // rax
unsigned int *v10; // r14
const char *v11; // rax
unsigned int v12; // er15
__int64 v13; // rax
unsigned int *v14; // rax

v2 = fsym_set_in_topforms();
v3 = rsym_set_in_topforms(a1);
lex_order(v2, v3, 0LL, 0LL, &lex_compare_arity_0123);
if ( v2 )
{
v4 = (unsigned int *)v2;
v5 = -1;
while ( 1 )
{
v6 = *v4;
v7 = sn_to_str(*v4);
v8 = natural_string(v7);
if ( v8 >= 0 )
break;
if ( a2 && (unsigned int)arith_op_sn(v6) )
{
LABEL_5:
v4 = (unsigned int *)*((_QWORD *)v4 + 1);
if ( !v4 )
goto LABEL_10;
}
else
{
v9 = insert_mace4_sym(Symbols, v6, 0);
v4 = (unsigned int *)*((_QWORD *)v4 + 1);
Symbols = v9;
if ( !v4 )
goto LABEL_10;
}
}
if ( v5 < v8 )
v5 = v8;
goto LABEL_5;
}
v5 = -1;
LABEL_10:
if ( v3 )
{
v10 = (unsigned int *)v3;
do
{
while ( 1 )
{
v12 = *v10;
v13 = sn_to_str(*v10);
if ( (int)natural_string(v13) < 0 )
break;
v11 = (const char *)sn_to_str(v12);
printf("\nThe bad symbol is: %s\n", v11);
fatal_error("collect_mace4_syms, relation symbol is domain element");
LABEL_13:
v10 = (unsigned int *)*((_QWORD *)v10 + 1);
if ( !v10 )
goto LABEL_19;
}
if ( (unsigned int)is_eq_symbol(v12) || a2 && (unsigned int)arith_rel_sn(v12) )
goto LABEL_13;
v14 = insert_mace4_sym(Symbols, v12, 1u);
v10 = (unsigned int *)*((_QWORD *)v10 + 1);
Symbols = v14;
}
while ( v10 );
}
LABEL_19:
zap_ilist(v2);
zap_ilist(v3);
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
__int64 v2; // r13
__int64 v3; // rbp
unsigned int *v4; // r14
int v5; // er12
unsigned int v6; // er15
__int64 v7; // rax
int v8; // eax
unsigned int *v9; // rax
unsigned int *v10; // r14
const char *v11; // rax
unsigned int v12; // er15
__int64 v13; // rax
unsigned int *v14; // rax

v2 = fsym_set_in_topforms();
v3 = rsym_set_in_topforms(a1);
lex_order(v2, v3, 0LL, 0LL, &lex_compare_arity_0123);
if ( v2 )
{
v4 = (unsigned int *)v2;
v5 = -1;
while ( 1 )
{
v6 = *v4;
v7 = sn_to_str(*v4);
v8 = natural_string(v7);
if ( v8 >= 0 )
break;
if ( a2 && (unsigned int)arith_op_sn(v6) )
{
LABEL_5:
v4 = (unsigned int *)*((_QWORD *)v4 + 1);
if ( !v4 )
goto LABEL_10;
}
else
{
v9 = func1(Symbols, v6, 0);
v4 = (unsigned int *)*((_QWORD *)v4 + 1);
Symbols = v9;
if ( !v4 )
goto LABEL_10;
}
}
if ( v5 < v8 )
v5 = v8;
goto LABEL_5;
}
v5 = -1;
LABEL_10:
if ( v3 )
{
v10 = (unsigned int *)v3;
do
{
while ( 1 )
{
v12 = *v10;
v13 = sn_to_str(*v10);
if ( (int)natural_string(v13) < 0 )
break;
v11 = (const char *)sn_to_str(v12);
printf("\nThe bad symbol is: %s\n", v11);
fatal_error("collect_mace4_syms, relation symbol is domain element");
LABEL_13:
v10 = (unsigned int *)*((_QWORD *)v10 + 1);
if ( !v10 )
goto LABEL_19;
}
if ( (unsigned int)is_eq_symbol(v12) || a2 && (unsigned int)arith_rel_sn(v12) )
goto LABEL_13;
v14 = func1(Symbols, v12, 1u);
v10 = (unsigned int *)*((_QWORD *)v10 + 1);
Symbols = v14;
}
while ( v10 );
}
LABEL_19:
zap_ilist(v2);
zap_ilist(v3);
return (unsigned int)v5;
}

original_code:
int collect_mace4_syms(Plist clauses, BOOL arithmetic)
{
  Ilist fsyms, rsyms, p;
  int max_domain = -1;
  fsyms = fsym_set_in_topforms(clauses);
  rsyms = rsym_set_in_topforms(clauses);
  lex_order(fsyms, rsyms, ((void *)0), ((void *)0), lex_compare_arity_0123);
  for (p = fsyms; p; p = p->next) {
    int sn = p->i;
    int dom = natural_string(sn_to_str(sn));
    if (dom >= 0)
      max_domain = ((dom) > (max_domain) ? dom : max_domain);
    else if (arithmetic && arith_op_sn(sn))
      ;
    else
      Symbols = insert_mace4_sym(Symbols, sn, FUNCTION);
  }
  for (p = rsyms; p; p = p->next) {
    int sn = p->i;
    int dom = natural_string(sn_to_str(sn));
    if (dom >= 0) {
      printf("\nThe bad symbol is: %s\n", sn_to_str(sn));
      fatal_error("collect_mace4_syms, relation symbol is domain element");
    }
    else if (is_eq_symbol(sn) || (arithmetic && arith_rel_sn(sn)))
      ;
    else
      Symbols = insert_mace4_sym(Symbols, sn, RELATION);
  }
  zap_ilist(fsyms);
  zap_ilist(rsyms);
  return max_domain;
}

canonical_original_code:
int collect_mace4_syms(struct plist *clauses, enum BOOL arithmetic)
{
  struct ilist *fsyms; struct ilist *rsyms; struct ilist *p;
  int max_domain = -1;
  fsyms = fsym_set_in_topforms(clauses);
  rsyms = rsym_set_in_topforms(clauses);
  lex_order(fsyms, rsyms, ((void *)0), ((void *)0), lex_compare_arity_0123);
  for (p = fsyms; p; p = p->next) {
    int sn = p->i;
    int dom = natural_string(sn_to_str(sn));
    if (dom >= 0)
      max_domain = ((dom) > (max_domain) ? dom : max_domain);
    else if (arithmetic && arith_op_sn(sn))
      ;
    else
      Symbols = insert_mace4_sym(Symbols, sn, FUNCTION);
  }
  for (p = rsyms; p; p = p->next) {
    int sn = p->i;
    int dom = natural_string(sn_to_str(sn));
    if (dom >= 0) {
      printf("\nThe bad symbol is: %s\n", sn_to_str(sn));
      fatal_error("collect_mace4_syms, relation symbol is domain element");
    }
    else if (is_eq_symbol(sn) || (arithmetic && arith_rel_sn(sn)))
      ;
    else
      Symbols = insert_mace4_sym(Symbols, sn, RELATION);
  }
  zap_ilist(fsyms);
  zap_ilist(rsyms);
  return max_domain;
}

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

variable_types: struct ilist { int i; struct ilist *next; } *

variable_types: dom int


repo: jessealama/ladr

decompiled_code:
void __fastcall p_symbol_data(unsigned int *a1)
{
unsigned int v1; // er12
__int64 v2; // r15
__int64 v3; // r14
unsigned int v4; // ebp
unsigned int v5; // ebx
unsigned int v6; // er13
const char *v7; // rax

if ( a1 )
{
v1 = *a1;
v2 = a1[5];
v3 = a1[3];
v4 = a1[4];
v5 = a1[1];
v6 = a1[2];
v7 = (const char *)sn_to_str(*a1);
printf("%s/%d, sn=%d, mace_sn=%d, base=%d, type=%d, attribute=%d.\n", v7, v6, v1, v5, v4, v3, v2);
}
}

canonical_decompiled_code:
void __fastcall func5(unsigned int *a1)
{
unsigned int v1; // er12
__int64 v2; // r15
__int64 v3; // r14
unsigned int v4; // ebp
unsigned int v5; // ebx
unsigned int v6; // er13
const char *v7; // rax

if ( a1 )
{
v1 = *a1;
v2 = a1[5];
v3 = a1[3];
v4 = a1[4];
v5 = a1[1];
v6 = a1[2];
v7 = (const char *)sn_to_str(*a1);
printf("%s/%d, sn=%d, mace_sn=%d, base=%d, type=%d, attribute=%d.\n", v7, v6, v1, v5, v4, v3, v2);
}
}

original_code:
void p_symbol_data(Symbol_data s)
{
  if (s != ((void *)0))
    printf("%s/%d, sn=%d, mace_sn=%d, base=%d, type=%d, attribute=%d.\n",
    sn_to_str(s->sn), s->arity,
    s->sn, s->mace_sn, s->base, s->type, s->attribute);
}

canonical_original_code:
void p_symbol_data(struct symbol_data *s)
{
  if (s != ((void *)0))
    printf("%s/%d, sn=%d, mace_sn=%d, base=%d, type=%d, attribute=%d.\n",
    sn_to_str(s->sn), s->arity,
    s->sn, s->mace_sn, s->base, s->type, s->attribute);
}

variable_types: struct symbol_data { int sn; int mace_sn; int arity; int type; int base; int attribute; struct symbol_data *next; } *

return_type: void


decompiled_code:
__int64 __fastcall find_symbol_node(int a1)
{
__int64 v1; // rax
__int64 v2; // r8

v1 = Symbols;
v2 = 0LL;
if ( Symbols )
{
while ( *(_DWORD *)(v1 + 16) <= a1 )
{
v2 = v1;
if ( !*(_QWORD *)(v1 + 24) )
break;
v1 = *(_QWORD *)(v1 + 24);
}
}
return v2;
}

original_code:
Symbol_data find_symbol_node(int id)
{
  Symbol_data prev = ((void *)0);
  Symbol_data curr = Symbols;
  while (curr != ((void *)0) && curr->base <= id) {
    prev = curr;
    curr = curr->next;
  }
  return prev;
}

canonical_original_code:
struct symbol_data *find_symbol_node(int id)
{
  struct symbol_data *prev = ((void *)0);
  struct symbol_data *curr = Symbols;
  while (curr != ((void *)0) && curr->base <= id) {
    prev = curr;
    curr = curr->next;
  }
  return prev;
}

variable_types: id int

return_type: struct symbol_data { int sn; int mace_sn; int arity; int type; int base; int attribute; struct symbol_data *next; } *


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

result = 2LL;
if ( *(_DWORD *)(*(_QWORD *)(Cells + 56LL * a1 + 48) + 12LL) != 1 )
result = Domain_size;
return result;
}

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

result = 2LL;
if ( *(_DWORD *)(*(_QWORD *)(Cells + 56LL * a1 + 48) + 12LL) != 1 )
result = Domain_size;
return result;
}

original_code:
int id_to_domain_size(int id)
{
  Symbol_data s = Cells[id].symbol;
  return (s->type == RELATION ? 2 : Domain_size);
}

canonical_original_code:
int id_to_domain_size(int id)
{
  struct symbol_data *s = Cells[id].symbol;
  return (s->type == RELATION ? 2 : Domain_size);
}

return_type: int

user_defined_types: struct symbol_data { int sn; int mace_sn; int arity; int type; int base; int attribute; struct symbol_data *next; }


decompiled_code:
__int64 __fastcall max_index(int a1, __int64 a2)
{
unsigned int v2; // er13
int v3; // edi
int v4; // ebp
int v5; // ebx
int v6; // er12
int v7; // er8
int v8; // eax

v2 = Domain_size;
v3 = a1 - *(_DWORD *)(a2 + 16);
v4 = *(_DWORD *)(a2 + 8) - 1;
if ( v4 < 0 )
return 0xFFFFFFFFLL;
v5 = v3;
v6 = -1;
do
{
v7 = int_power(v2, (unsigned int)v4);
v8 = v5 / v7;
v5 %= v7;
if ( v6 < v8 )
v6 = v8;
}
while ( v4-- != 0 );
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, __int64 a2)
{
unsigned int v2; // er13
int v3; // edi
int v4; // ebp
int v5; // ebx
int v6; // er12
int v7; // er8
int v8; // eax

v2 = Domain_size;
v3 = a1 - *(_DWORD *)(a2 + 16);
v4 = *(_DWORD *)(a2 + 8) - 1;
if ( v4 < 0 )
return 0xFFFFFFFFLL;
v5 = v3;
v6 = -1;
do
{
v7 = int_power(v2, (unsigned int)v4);
v8 = v5 / v7;
v5 %= v7;
if ( v6 < v8 )
v6 = v8;
}
while ( v4-- != 0 );
return (unsigned int)v6;
}

original_code:
int max_index(int id, Symbol_data s)
{
  int max = -1;
  int n = Domain_size;
  int x = id - s->base;
  int i;
  for (i = s->arity - 1; i >= 0; i--) {
    int p = int_power(n, i);
    int e = x / p;
    max = ((e) > (max) ? e : max);
    x = x % p;
  }
  return max;
}

canonical_original_code:
int max_index(int id, struct symbol_data *s)
{
  int max = -1;
  int n = Domain_size;
  int x = id - s->base;
  int i;
  for (i = s->arity - 1; i >= 0; i--) {
    int p = int_power(n, i);
    int e = x / p;
    max = ((e) > (max) ? e : max);
    x = x % p;
  }
  return max;
}

variable_types: max int

variable_types: n int

variable_types: x int

variable_types: i int

variable_types: p int

variable_types: e int


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

for ( result = 0LL; a1; result = (unsigned int)(result + 1) )
a1 = (_QWORD *)*a1;
return result;
}

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

for ( result = 0LL; a1; result = (unsigned int)(result + 1) )
a1 = (_QWORD *)*a1;
return result;
}

original_code:
static
int mlist_length(void **p)
{
  int n;
  for (n = 0; p; p = *p, n++);
  return n;
}

variable_types:
p
void **


palloc

decompiled_code:
void *__fastcall palloc(unsigned __int64 a1)
{
void *result; // rax
int v2; // ebp

if ( !a1 )
return 0LL;
if ( !Block || (result = (void *)Block_pos, Block + 20971520 - Block_pos < a1) )
{
if ( a1 > 0x1400000 )
{
printf("palloc, n=%d\n", (unsigned int)a1);
fatal_error("palloc, request too big; reset MALLOC_MEGS");
result = (void *)Block_pos;
}
else
{
v2 = Malloc_calls + 1;
if ( Max_megs_check && 20 * v2 > Max_megs )
{
if ( Exit_proc )
Exit_proc();
else
fatal_error("palloc, Max_megs parameter exceeded");
result = (void *)Block_pos;
}
else
{
result = malloc(0x1400000uLL);
Malloc_calls = v2;
Block = (__int64)result;
Block_pos = (__int64)result;
if ( !result )
{
fatal_error("palloc, operating system is out of memory");
result = (void *)Block_pos;
}
}
}
}
Bytes_palloced += a1;
Block_pos = (__int64)result + a1;
return result;
}

canonical_decompiled_code:
void *__fastcall func1(unsigned __int64 a1)
{
void *result; // rax
int v2; // ebp

if ( !a1 )
return 0LL;
if ( !Block || (result = (void *)Block_pos, Block + 20971520 - Block_pos < a1) )
{
if ( a1 > 0x1400000 )
{
printf("palloc, n=%d\n", (unsigned int)a1);
fatal_error("palloc, request too big; reset MALLOC_MEGS");
result = (void *)Block_pos;
}
else
{
v2 = Malloc_calls + 1;
if ( Max_megs_check && 20 * v2 > Max_megs )
{
if ( Exit_proc )
Exit_proc();
else
fatal_error("palloc, Max_megs parameter exceeded");
result = (void *)Block_pos;
}
else
{
result = malloc(0x1400000uLL);
Malloc_calls = v2;
Block = (__int64)result;
Block_pos = (__int64)result;
if ( !result )
{
fatal_error("palloc, operating system is out of memory");
result = (void *)Block_pos;
}
}
}
}
Bytes_palloced += a1;
Block_pos = (__int64)result + a1;
return result;
}

original_code:
static
void *palloc(size_t n)
{
  if (n == 0)
    return ((void *)0);
  else {
    void *chunk;
    size_t malloc_bytes = 20*1024*1024;
    if (Block==((void *)0) || Block + malloc_bytes - Block_pos < n) {
      if (n > malloc_bytes) {
 printf("palloc, n=%d\n", (int) n);
 fatal_error("palloc, request too big; reset MALLOC_MEGS");
      }
      else if (Max_megs_check && (Malloc_calls+1)*20 > Max_megs) {
 if (Exit_proc)
   (*Exit_proc)();
 else
   fatal_error("palloc, Max_megs parameter exceeded");
      }
      else {
 Block_pos = Block = malloc(malloc_bytes);
 Malloc_calls++;
 if (Block_pos == ((void *)0))
   fatal_error("palloc, operating system is out of memory");
      }
    }
    chunk = Block_pos;
    Block_pos += n;
    Bytes_palloced += n;
    return(chunk);
  }
}

canonical_original_code:
static void *palloc(unsigned long n)
{
  if (n == 0)
    return ((void *)0);
  else {
    void *chunk;
    unsigned long malloc_bytes = 20*1024*1024;
    if (Block==((void *)0) || Block + malloc_bytes - Block_pos < n) {
      if (n > malloc_bytes) {
 printf("palloc, n=%d\n", (int) n);
 fatal_error("palloc, request too big; reset MALLOC_MEGS");
      }
      else if (Max_megs_check && (Malloc_calls+1)*20 > Max_megs) {
 if (Exit_proc)
   (*Exit_proc)();
 else
   fatal_error("palloc, Max_megs parameter exceeded");
      }
      else {
 Block_pos = Block = malloc(malloc_bytes);
 Malloc_calls++;
 if (Block_pos == ((void *)0))
   fatal_error("palloc, operating system is out of memory");
      }
    }
    chunk = Block_pos;
    Block_pos += n;
    Bytes_palloced += n;
    return(chunk);
  }
}

variable_types:
n
unsigned long

variable_types:
chunk
void *

return_type: void *


decompiled_code:
void __fastcall free_mem(__int64 *a1, unsigned int a2)
{
__int64 v2; // rax

if ( a2 )
{
if ( a2 > 0x1F3 )
{
free(a1);
}
else
{
v2 = M[a2];
M[a2] = (__int64)a1;
*a1 = v2;
}
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 *a1, unsigned int a2)
{
__int64 v2; // rax

if ( a2 )
{
if ( a2 > 0x1F3 )
{
free(a1);
}
else
{
v2 = M[a2];
M[a2] = (__int64)a1;
*a1 = v2;
}
}
}

original_code:
void free_mem(void *q, unsigned n)
{
  if (n == 0)
    ;
  else {
    void **p = q;
    if (n >= 500)
      free(p);
    else {
      *p = M[n];
      M[n] = p;
    }
  }
}

canonical_original_code:
void free_mem(void *q, unsigned int n)
{
  if (n == 0)
    ;
  else {
    void **p = q;
    if (n >= 500)
      free(p);
    else {
      *p = M[n];
      M[n] = p;
    }
  }
}

variable_types:
q
void *

variable_types:
n
unsigned int


decompiled_code:
__int64 megs_malloced()
{
return (unsigned int)(20 * Malloc_calls);
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)(20 * Malloc_calls);
}

original_code:
int megs_malloced(void)
{
  return Malloc_calls * 20;
}

canonical_original_code:
int megs_malloced()
{
  return Malloc_calls * 20;
}


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

result = 0x7FFFFFFFLL;
if ( a1 == -1 )
a1 = 0x7FFFFFFF;
Max_megs = a1;
return result;
}

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

result = 0x7FFFFFFFLL;
if ( a1 == -1 )
a1 = 0x7FFFFFFF;
Max_megs = a1;
return result;
}

original_code:
void set_max_megs(int megs)
{
  Max_megs = (megs == -1 ? 0x7fffffff : megs);
}

variable_types: megs int


decompiled_code:
__int64 bytes_palloced()
{
return (unsigned int)Bytes_palloced;
}

canonical_decompiled_code:
__int64 func7()
{
return (unsigned int)Bytes_palloced;
}

original_code:
int bytes_palloced(void)
{
  return Bytes_palloced;
}

canonical_original_code:
int bytes_palloced()
{
  return Bytes_palloced;
}


decompiled_code:
void *__fastcall tp_alloc(unsigned __int64 a1)
{
if ( (a1 & 7) != 0 )
a1 = (a1 & 0xFFFFFFFFFFFFFFF8LL) + 8;
return palloc(a1);
}

canonical_decompiled_code:
void *__fastcall func8(unsigned __int64 a1)
{
if ( (a1 & 7) != 0 )
a1 = (a1 & 0xFFFFFFFFFFFFFFF8LL) + 8;
return func1(a1);
}

original_code:
void *tp_alloc(size_t n)
{
  if (n % sizeof(void *) != 0) {
    n += (sizeof(void *) - (n % sizeof(void *)));
  }
  return palloc(n);
}

canonical_original_code:
void *tp_alloc(unsigned long n)
{
  if (n % sizeof(void *) != 0) {
    n += (sizeof(void *) - (n % sizeof(void *)));
  }
  return palloc(n);
}


decompiled_code:
__int64 mega_mem_calls()
{
return 4294 * Mem_calls_overflows + Mem_calls / 0xF4240u;
}

canonical_decompiled_code:
__int64 func9()
{
return 4294 * Mem_calls_overflows + Mem_calls / 0xF4240u;
}

original_code:
unsigned mega_mem_calls(void)
{
  return
    (Mem_calls / 1000000) +
    (((0x7fffffff * 2U + 1U) / 1000000) * Mem_calls_overflows);
}

canonical_original_code:
unsigned int mega_mem_calls()
{
  return
    (Mem_calls / 1000000) +
    (((0x7fffffff * 2U + 1U) / 1000000) * Mem_calls_overflows);
}

return_type: unsigned int


decompiled_code:
void disable_max_megs()
{
Max_megs_check = 0;
}

canonical_decompiled_code:
void func10()
{
Max_megs_check = 0;
}

original_code:
void disable_max_megs(void)
{
  Max_megs_check = FALSE;
}

canonical_original_code:
void disable_max_megs()
{
  Max_megs_check = FALSE;
}


decompiled_code:
void enable_max_megs()
{
Max_megs_check = 1;
}

canonical_decompiled_code:
void func11()
{
Max_megs_check = 1;
}

original_code:
void enable_max_megs(void)
{
  Max_megs_check = TRUE;
}

canonical_original_code:
void enable_max_megs()
{
  Max_megs_check = TRUE;
}


decompiled_code:
__int64 __fastcall fill_in_arrays(unsigned int *a1, unsigned int a2, int a3)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // rcx
int v7; // ecx
__int64 v8; // rbp
unsigned int v9; // er12
__int64 v10; // rdi
int v11; // ecx

result = *a1;
if ( (int)result < 0 )
{
result = (unsigned int)-(int)result;
if ( Work_size > (int)result )
{
v5 = 4LL * (int)result;
v6 = v5;
if ( a2 )
{
result = Pos_maxdepth + v5;
++*(_DWORD *)(Pos_occurrences + v6);
v7 = a3;
if ( *(_DWORD *)result >= a3 )
v7 = *(_DWORD *)result;
*(_DWORD *)result = v7;
}
else
{
result = Neg_maxdepth + v5;
++*(_DWORD *)(Neg_occurrences + v6);
v11 = a3;
if ( *(_DWORD *)result >= a3 )
v11 = *(_DWORD *)result;
*(_DWORD *)result = v11;
}
}
v8 = 0LL;
v9 = a3 + 1;
if ( *((_BYTE *)a1 + 4) )
{
do
{
v10 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v8++);
fill_in_arrays(v10, a2, v9);
result = *((unsigned __int8 *)a1 + 4);
}
while ( (int)result > (int)v8 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1, unsigned int a2, int a3)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // rcx
int v7; // ecx
__int64 v8; // rbp
unsigned int v9; // er12
__int64 v10; // rdi
int v11; // ecx

result = *a1;
if ( (int)result < 0 )
{
result = (unsigned int)-(int)result;
if ( Work_size > (int)result )
{
v5 = 4LL * (int)result;
v6 = v5;
if ( a2 )
{
result = Pos_maxdepth + v5;
++*(_DWORD *)(Pos_occurrences + v6);
v7 = a3;
if ( *(_DWORD *)result >= a3 )
v7 = *(_DWORD *)result;
*(_DWORD *)result = v7;
}
else
{
result = Neg_maxdepth + v5;
++*(_DWORD *)(Neg_occurrences + v6);
v11 = a3;
if ( *(_DWORD *)result >= a3 )
v11 = *(_DWORD *)result;
*(_DWORD *)result = v11;
}
}
v8 = 0LL;
v9 = a3 + 1;
if ( *((_BYTE *)a1 + 4) )
{
do
{
v10 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v8++);
func0(v10, a2, v9);
result = *((unsigned __int8 *)a1 + 4);
}
while ( (int)result > (int)v8 );
}
}
return result;
}

original_code:
static
void fill_in_arrays(Term t, BOOL sign, int depth)
{
  if (!((t)->private_symbol >= 0)) {
    int sn = (-((t)->private_symbol));
    int i;
    if (sn >= Work_size) {
      ;
    }
    else if (sign) {
      Pos_occurrences[sn]++;
      Pos_maxdepth[sn] = ((depth) > (Pos_maxdepth[sn]) ? (depth) : (Pos_maxdepth[sn]));
    }
    else {
      Neg_occurrences[sn]++;
      Neg_maxdepth[sn] = ((depth) > (Neg_maxdepth[sn]) ? (depth) : (Neg_maxdepth[sn]));
    }
    for (i = 0; i < ((t)->arity); i++)
      fill_in_arrays(((t)->args[i]), sign, depth+1);
  }
}

canonical_original_code:
static void fill_in_arrays(struct term *t, enum BOOL sign, int depth)
{
  if (!((t)->private_symbol >= 0)) {
    int sn = (-((t)->private_symbol));
    int i;
    if (sn >= Work_size) {
      ;
    }
    else if (sign) {
      Pos_occurrences[sn]++;
      Pos_maxdepth[sn] = ((depth) > (Pos_maxdepth[sn]) ? (depth) : (Pos_maxdepth[sn]));
    }
    else {
      Neg_occurrences[sn]++;
      Neg_maxdepth[sn] = ((depth) > (Neg_maxdepth[sn]) ? (depth) : (Neg_maxdepth[sn]));
    }
    for (i = 0; i < ((t)->arity); i++)
      fill_in_arrays(((t)->args[i]), sign, depth+1);
  }
}

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:
sign
enum BOOL { FALSE=0, TRUE=1 }

variable_types: depth int

variable_types: sn int


decompiled_code:
void *__fastcall init_features(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rax
size_t v5; // rbp
void *result; // rax

Work_size = greatest_symnum() + 1;
v2 = ilist_copy(a1);
v3 = ilist_copy(a2);
v4 = ilist_cat(v3, v2);
v5 = Work_size;
Feature_symbols = v4;
Pos_occurrences = (__int64)calloc(Work_size, 4uLL);
Neg_occurrences = (__int64)calloc(v5, 4uLL);
Pos_maxdepth = (__int64)calloc(v5, 4uLL);
result = calloc(v5, 4uLL);
Neg_maxdepth = (__int64)result;
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rax
size_t v5; // rbp
void *result; // rax

Work_size = greatest_symnum() + 1;
v2 = ilist_copy(a1);
v3 = ilist_copy(a2);
v4 = ilist_cat(v3, v2);
v5 = Work_size;
Feature_symbols = v4;
Pos_occurrences = (__int64)calloc(Work_size, 4uLL);
Neg_occurrences = (__int64)calloc(v5, 4uLL);
Pos_maxdepth = (__int64)calloc(v5, 4uLL);
result = calloc(v5, 4uLL);
Neg_maxdepth = (__int64)result;
return result;
}

original_code:
void init_features(Ilist fsyms, Ilist rsyms)
{
  Work_size = greatest_symnum() + 1;
  Feature_symbols = ilist_cat(ilist_copy(rsyms), ilist_copy(fsyms));
  Pos_occurrences = calloc(Work_size, sizeof(int));
  Neg_occurrences = calloc(Work_size, sizeof(int));
  Pos_maxdepth = calloc(Work_size, sizeof(int));
  Neg_maxdepth = calloc(Work_size, sizeof(int));
}

canonical_original_code:
void init_features(struct ilist *fsyms, struct ilist *rsyms)
{
  Work_size = greatest_symnum() + 1;
  Feature_symbols = ilist_cat(ilist_copy(rsyms), ilist_copy(fsyms));
  Pos_occurrences = calloc(Work_size, sizeof(int));
  Neg_occurrences = calloc(Work_size, sizeof(int));
  Pos_maxdepth = calloc(Work_size, sizeof(int));
  Neg_maxdepth = calloc(Work_size, sizeof(int));
}

variable_types: struct ilist { int i; struct ilist *next; } *

variable_types:
rsyms
struct ilist *


features

decompiled_code:
__int64 __fastcall features(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // eax
__int64 v3; // rbp
unsigned int v4; // eax
__int64 i; // rbp
int *v6; // rbx
__int64 v7; // rax
__int64 v8; // rcx
__int64 v9; // rax
__int64 v10; // rax

v1 = a1;
v2 = positive_literals();
v3 = ilist_prepend(0LL, v2);
v4 = negative_literals(a1);
for ( i = ilist_prepend(v3, v4); v1; v1 = *(_QWORD *)(v1 + 16) )
fill_in_arrays(*(unsigned int **)(v1 + 8), *(_DWORD *)v1, 0);
v6 = (int *)Feature_symbols;
v7 = Pos_occurrences;
if ( Feature_symbols )
{
do
{
v9 = ilist_prepend(i, *(unsigned int *)(v7 + 4LL * *v6));
i = ilist_prepend(v9, *(unsigned int *)(Neg_occurrences + 4LL * *v6));
if ( (unsigned int)function_symbol((unsigned int)*v6) )
{
v10 = ilist_prepend(i, *(unsigned int *)(Pos_maxdepth + 4LL * *v6));
i = ilist_prepend(v10, *(unsigned int *)(Neg_maxdepth + 4LL * *v6));
}
v7 = Pos_occurrences;
*(_DWORD *)(Pos_occurrences + 4LL * *v6) = 0;
*(_DWORD *)(Neg_occurrences + 4LL * *v6) = 0;
*(_DWORD *)(Pos_maxdepth + 4LL * *v6) = 0;
v8 = *v6;
v6 = (int *)*((_QWORD *)v6 + 1);
*(_DWORD *)(Neg_maxdepth + 4 * v8) = 0;
}
while ( v6 );
}
return reverse_ilist(i);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // eax
__int64 v3; // rbp
unsigned int v4; // eax
__int64 i; // rbp
int *v6; // rbx
__int64 v7; // rax
__int64 v8; // rcx
__int64 v9; // rax
__int64 v10; // rax

v1 = a1;
v2 = positive_literals();
v3 = ilist_prepend(0LL, v2);
v4 = negative_literals(a1);
for ( i = ilist_prepend(v3, v4); v1; v1 = *(_QWORD *)(v1 + 16) )
func0(*(unsigned int **)(v1 + 8), *(_DWORD *)v1, 0);
v6 = (int *)Feature_symbols;
v7 = Pos_occurrences;
if ( Feature_symbols )
{
do
{
v9 = ilist_prepend(i, *(unsigned int *)(v7 + 4LL * *v6));
i = ilist_prepend(v9, *(unsigned int *)(Neg_occurrences + 4LL * *v6));
if ( (unsigned int)function_symbol((unsigned int)*v6) )
{
v10 = ilist_prepend(i, *(unsigned int *)(Pos_maxdepth + 4LL * *v6));
i = ilist_prepend(v10, *(unsigned int *)(Neg_maxdepth + 4LL * *v6));
}
v7 = Pos_occurrences;
*(_DWORD *)(Pos_occurrences + 4LL * *v6) = 0;
*(_DWORD *)(Neg_occurrences + 4LL * *v6) = 0;
*(_DWORD *)(Pos_maxdepth + 4LL * *v6) = 0;
v8 = *v6;
v6 = (int *)*((_QWORD *)v6 + 1);
*(_DWORD *)(Neg_maxdepth + 4 * v8) = 0;
}
while ( v6 );
}
return reverse_ilist(i);
}

original_code:
Ilist features(Literals lits)
{
  Ilist f = ((void *)0);
  Ilist p;
  Literals lit;
  f = ilist_prepend(f, positive_literals(lits));
  f = ilist_prepend(f, negative_literals(lits));
  for (lit = lits; lit; lit = lit->next) {
    fill_in_arrays(lit->atom, lit->sign, 0);
  }
  for (p = Feature_symbols; p; p = p->next) {
    f = ilist_prepend(f, Pos_occurrences[p->i]);
    f = ilist_prepend(f, Neg_occurrences[p->i]);
    if (function_symbol(p->i)) {
      f = ilist_prepend(f, Pos_maxdepth[p->i]);
      f = ilist_prepend(f, Neg_maxdepth[p->i]);
    }
    Pos_occurrences[p->i] = 0;
    Neg_occurrences[p->i] = 0;
    Pos_maxdepth[p->i] = 0;
    Neg_maxdepth[p->i] = 0;
  }
  f = reverse_ilist(f);
  return f;
}

canonical_original_code:
struct ilist *features(struct literals *lits)
{
  struct ilist *f = ((void *)0);
  struct ilist *p;
  struct literals *lit;
  f = ilist_prepend(f, positive_literals(lits));
  f = ilist_prepend(f, negative_literals(lits));
  for (lit = lits; lit; lit = lit->next) {
    fill_in_arrays(lit->atom, lit->sign, 0);
  }
  for (p = Feature_symbols; p; p = p->next) {
    f = ilist_prepend(f, Pos_occurrences[p->i]);
    f = ilist_prepend(f, Neg_occurrences[p->i]);
    if (function_symbol(p->i)) {
      f = ilist_prepend(f, Pos_maxdepth[p->i]);
      f = ilist_prepend(f, Neg_maxdepth[p->i]);
    }
    Pos_occurrences[p->i] = 0;
    Neg_occurrences[p->i] = 0;
    Pos_maxdepth[p->i] = 0;
    Neg_maxdepth[p->i] = 0;
  }
  f = reverse_ilist(f);
  return f;
}

variable_types: struct literals { enum BOOL { FALSE=0, TRUE=1 } sign; struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *atom; struct literals *next; } *

return_type: struct ilist { int i; struct ilist *next; } *

user_defined_types: struct literals { enum BOOL sign; struct term *atom; struct literals *next; }


decompiled_code:
__int64 feature_length()
{
unsigned int v0; // er12
unsigned int *v1; // rbx
int v2; // eax
int v3; // er8
unsigned int v4; // eax

v0 = 2;
v1 = (unsigned int *)Feature_symbols;
if ( Feature_symbols )
{
do
{
v2 = function_symbol(*v1);
v1 = (unsigned int *)*((_QWORD *)v1 + 1);
v3 = v2;
v4 = v0 + 2;
v0 += 4;
if ( !v3 )
v0 = v4;
}
while ( v1 );
}
return v0;
}

canonical_decompiled_code:
__int64 func3()
{
unsigned int v0; // er12
unsigned int *v1; // rbx
int v2; // eax
int v3; // er8
unsigned int v4; // eax

v0 = 2;
v1 = (unsigned int *)Feature_symbols;
if ( Feature_symbols )
{
do
{
v2 = function_symbol(*v1);
v1 = (unsigned int *)*((_QWORD *)v1 + 1);
v3 = v2;
v4 = v0 + 2;
v0 += 4;
if ( !v3 )
v0 = v4;
}
while ( v1 );
}
return v0;
}

original_code:
int feature_length(void)
{
  int n = 2;
  Ilist p;
  for (p = Feature_symbols; p; p = p->next) {
    n += 2;
    if (function_symbol(p->i))
      n += 2;
  }
  return n;
}

canonical_original_code:
int feature_length()
{
  int n = 2;
  struct ilist *p;
  for (p = Feature_symbols; p; p = p->next) {
    n += 2;
    if (function_symbol(p->i))
      n += 2;
  }
  return n;
}

variable_types: n int

user_defined_types: struct ilist { int i; struct ilist *next; }


original_code:
BOOL features_less_or_equal(Ilist c, Ilist d)
{
  while (c && d && c->i <= d->i) {
    c = c->next;
    d = d->next;
  }
  return !c && !d;
}

canonical_original_code:
enum BOOL features_less_or_equal(struct ilist *c, struct ilist *d)
{
  while (c && d && c->i <= d->i) {
    c = c->next;
    d = d->next;
  }
  return !c && !d;
}

variable_types:
d
struct ilist *

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


decompiled_code:
int __fastcall p_features(unsigned int *a1)
{
__int64 v1; // rax
unsigned int *v2; // rbp
unsigned int *v3; // rbx
const char *v4; // rax

printf(" pos_lits=%d, neg_lits=%d\n", *a1, **((unsigned int **)a1 + 1));
v1 = *((_QWORD *)a1 + 1);
v2 = (unsigned int *)Feature_symbols;
v3 = *(unsigned int **)(v1 + 8);
if ( Feature_symbols )
{
do
{
v4 = (const char *)sn_to_str(*v2);
printf(" symbol %s: ", v4);
printf("pos_occ=%d, neg_occ=%d", *v3, **((unsigned int **)v3 + 1));
v3 = *(unsigned int **)(*((_QWORD *)v3 + 1) + 8LL);
if ( (unsigned int)function_symbol(*v2) )
{
printf(", pos_max=%d, neg_max=%d", *v3, **((unsigned int **)v3 + 1));
v3 = *(unsigned int **)(*((_QWORD *)v3 + 1) + 8LL);
}
LODWORD(v1) = putchar(10);
v2 = (unsigned int *)*((_QWORD *)v2 + 1);
}
while ( v2 );
}
return v1;
}

canonical_decompiled_code:
int __fastcall func5(unsigned int *a1)
{
__int64 v1; // rax
unsigned int *v2; // rbp
unsigned int *v3; // rbx
const char *v4; // rax

printf(" pos_lits=%d, neg_lits=%d\n", *a1, **((unsigned int **)a1 + 1));
v1 = *((_QWORD *)a1 + 1);
v2 = (unsigned int *)Feature_symbols;
v3 = *(unsigned int **)(v1 + 8);
if ( Feature_symbols )
{
do
{
v4 = (const char *)sn_to_str(*v2);
printf(" symbol %s: ", v4);
printf("pos_occ=%d, neg_occ=%d", *v3, **((unsigned int **)v3 + 1));
v3 = *(unsigned int **)(*((_QWORD *)v3 + 1) + 8LL);
if ( (unsigned int)function_symbol(*v2) )
{
printf(", pos_max=%d, neg_max=%d", *v3, **((unsigned int **)v3 + 1));
v3 = *(unsigned int **)(*((_QWORD *)v3 + 1) + 8LL);
}
LODWORD(v1) = putchar(10);
v2 = (unsigned int *)*((_QWORD *)v2 + 1);
}
while ( v2 );
}
return v1;
}

original_code:
void p_features(Ilist f)
{
  Ilist p;
  printf("  pos_lits=%d, neg_lits=%d\n", f->i, f->next->i);
  f = f->next->next;
  for (p = Feature_symbols; p; p = p->next) {
    printf("  symbol %s: ", sn_to_str(p->i));
    printf("pos_occ=%d, neg_occ=%d", f->i, f->next->i);
    f = f->next->next;
    if (function_symbol(p->i)) {
      printf(", pos_max=%d, neg_max=%d", f->i, f->next->i);
      f = f->next->next;
    }
    printf("\n");
  }
}

canonical_original_code:
void p_features(struct ilist *f)
{
  struct ilist *p;
  printf("  pos_lits=%d, neg_lits=%d\n", f->i, f->next->i);
  f = f->next->next;
  for (p = Feature_symbols; p; p = p->next) {
    printf("  symbol %s: ", sn_to_str(p->i));
    printf("pos_occ=%d, neg_occ=%d", f->i, f->next->i);
    f = f->next->next;
    if (function_symbol(p->i)) {
      printf(", pos_max=%d, neg_max=%d", f->i, f->next->i);
      f = f->next->next;
    }
    printf("\n");
  }
}


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

result = get_cmem(3LL);
++Clock_gets;
return result;
}

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

result = get_cmem(3LL);
++Clock_gets;
return result;
}

original_code:
static
Clock get_clock(void)
{
  Clock p = get_cmem(((sizeof(struct clock))%(sizeof(void *)) == 0 ? (sizeof(struct clock))/(sizeof(void *)) : (sizeof(struct clock))/(sizeof(void *)) + 1));
  Clock_gets++;
  return(p);
}

canonical_original_code:
static struct clock *get_clock()
{
  struct clock *p = get_cmem(((sizeof(struct clock))%(sizeof(void *)) == 0 ? (sizeof(struct clock))/(sizeof(void *)) : (sizeof(struct clock))/(sizeof(void *)) + 1));
  Clock_gets++;
  return(p);
}

variable_types: struct clock { char *name; unsigned int accum_msec; unsigned int curr_msec; int level; } *


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

if ( a1 )
{
result = free_mem(a1, 3LL);
++Clock_frees;
}
return result;
}

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

if ( a1 )
{
result = free_mem(a1, 3LL);
++Clock_frees;
}
return result;
}

original_code:
void free_clock(Clock p)
{
  if (p != ((void *)0)) {
    free_mem(p, ((sizeof(struct clock))%(sizeof(void *)) == 0 ? (sizeof(struct clock))/(sizeof(void *)) : (sizeof(struct clock))/(sizeof(void *)) + 1));
    Clock_frees++;
  }
}

canonical_original_code:
void free_clock(struct clock *p)
{
  if (p != ((void *)0)) {
    free_mem(p, ((sizeof(struct clock))%(sizeof(void *)) == 0 ? (sizeof(struct clock))/(sizeof(void *)) : (sizeof(struct clock))/(sizeof(void *)) + 1));
    Clock_frees++;
  }
}

user_defined_types: struct clock { char *name; unsigned int accum_msec; unsigned int curr_msec; int level; }


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

result = get_clock();
*(_QWORD *)result = a1;
*(_DWORD *)(result + 16) = 0;
*(_DWORD *)(result + 8) = 0;
return result;
}

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

result = func0();
*(_QWORD *)result = a1;
*(_DWORD *)(result + 16) = 0;
*(_DWORD *)(result + 8) = 0;
return result;
}

original_code:
Clock clock_init(char *str)
{
  Clock p = get_clock();
  p->name = str;
  p->level = 0;
  p->accum_msec = 0;
  return p;
}

canonical_original_code:
struct clock *clock_init(char *str)
{
  struct clock *p = get_clock();
  p->name = str;
  p->level = 0;
  p->accum_msec = 0;
  return p;
}

variable_types:
str
char *

return_type: struct clock { char *name; unsigned int accum_msec; unsigned int curr_msec; int level; } *


decompiled_code:
__int64 __fastcall clock_start(__int64 a1)
{
__int64 result; // rax
struct rusage v2; // [rsp+0h] [rbp-98h] BYREF

result = (unsigned int)Clocks_enabled;
if ( Clocks_enabled )
{
result = (unsigned int)(*(_DWORD *)(a1 + 16) + 1);
*(_DWORD *)(a1 + 16) = result;
if ( (_DWORD)result == 1 )
{
getrusage(RUSAGE_SELF, &v2);
++Clock_starts;
result = 0x20C49BA5E353F7CFLL * v2.ru_utime.tv_usec;
*(_DWORD *)(a1 + 12) = 1000 * LODWORD(v2.ru_utime.tv_sec) + SLODWORD(v2.ru_utime.tv_usec) / 1000;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
struct rusage v2; // [rsp+0h] [rbp-98h] BYREF

result = (unsigned int)Clocks_enabled;
if ( Clocks_enabled )
{
result = (unsigned int)(*(_DWORD *)(a1 + 16) + 1);
*(_DWORD *)(a1 + 16) = result;
if ( (_DWORD)result == 1 )
{
getrusage(RUSAGE_SELF, &v2);
++Clock_starts;
result = 0x20C49BA5E353F7CFLL * v2.ru_utime.tv_usec;
*(_DWORD *)(a1 + 12) = 1000 * LODWORD(v2.ru_utime.tv_sec) + SLODWORD(v2.ru_utime.tv_usec) / 1000;
}
}
return result;
}

original_code:
void clock_start(Clock p)
{
  if (Clocks_enabled) {
    p->level++;
    if (p->level == 1) {
      { struct rusage r; getrusage(RUSAGE_SELF, &r); p->curr_msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
      Clock_starts++;
    }
  }
}

canonical_original_code:
void clock_start(struct clock *p)
{
  if (Clocks_enabled) {
    p->level++;
    if (p->level == 1) {
      { struct rusage r; getrusage(RUSAGE_SELF, &r); p->curr_msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
      Clock_starts++;
    }
  }
}

variable_types: struct rusage { struct timeval { long tv_sec; long tv_usec; } ru_utime; struct timeval ru_stime; union { long ru_maxrss; long __ru_maxrss_word; }; union { long ru_ixrss; long __ru_ixrss_word; }; union { long ru_idrss; long __ru_idrss_word; }; union { long ru_isrss; long __ru_isrss_word; }; union { long ru_minflt; long __ru_minflt_word; }; union { long ru_majflt; long __ru_majflt_word; }; union { long ru_nswap; long __ru_nswap_word; }; union { long ru_inblock; long __ru_inblock_word; }; union { long ru_oublock; long __ru_oublock_word; }; union { long ru_msgsnd; long __ru_msgsnd_word; }; union { long ru_msgrcv; long __ru_msgrcv_word; }; union { long ru_nsignals; long __ru_nsignals_word; }; union { long ru_nvcsw; long __ru_nvcsw_word; }; union { long ru_nivcsw; long __ru_nivcsw_word; }; }

user_defined_types: struct rusage { struct timeval ru_utime; struct timeval ru_stime; union { long ru_maxrss; long __ru_maxrss_word; }; union { long ru_ixrss; long __ru_ixrss_word; }; union { long ru_idrss; long __ru_idrss_word; }; union { long ru_isrss; long __ru_isrss_word; }; union { long ru_minflt; long __ru_minflt_word; }; union { long ru_majflt; long __ru_majflt_word; }; union { long ru_nswap; long __ru_nswap_word; }; union { long ru_inblock; long __ru_inblock_word; }; union { long ru_oublock; long __ru_oublock_word; }; union { long ru_msgsnd; long __ru_msgsnd_word; }; union { long ru_msgrcv; long __ru_msgrcv_word; }; union { long ru_nsignals; long __ru_nsignals_word; }; union { long ru_nvcsw; long __ru_nvcsw_word; }; union { long ru_nivcsw; long __ru_nivcsw_word; }; }


decompiled_code:
int __fastcall clock_stop(__int64 a1)
{
int result; // eax
int v2; // eax
struct rusage v3; // [rsp+0h] [rbp-98h] BYREF

result = Clocks_enabled;
if ( Clocks_enabled )
{
v2 = *(_DWORD *)(a1 + 16);
if ( v2 <= 0 )
{
result = fprintf(stderr, "WARNING, clock_stop: clock %s not running.\n", *(const char **)a1);
}
else
{
result = v2 - 1;
*(_DWORD *)(a1 + 16) = result;
if ( !result )
{
getrusage(RUSAGE_SELF, &v3);
result = -481036337 * LODWORD(v3.ru_utime.tv_usec);
*(_DWORD *)(a1 + 8) = *(_DWORD *)(a1 + 8)
+ v3.ru_utime.tv_usec / 1000
+ 1000 * LODWORD(v3.ru_utime.tv_sec)
- *(_DWORD *)(a1 + 12);
}
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
int result; // eax
int v2; // eax
struct rusage v3; // [rsp+0h] [rbp-98h] BYREF

result = Clocks_enabled;
if ( Clocks_enabled )
{
v2 = *(_DWORD *)(a1 + 16);
if ( v2 <= 0 )
{
result = fprintf(stderr, "WARNING, clock_stop: clock %s not running.\n", *(const char **)a1);
}
else
{
result = v2 - 1;
*(_DWORD *)(a1 + 16) = result;
if ( !result )
{
getrusage(RUSAGE_SELF, &v3);
result = -481036337 * LODWORD(v3.ru_utime.tv_usec);
*(_DWORD *)(a1 + 8) = *(_DWORD *)(a1 + 8)
+ v3.ru_utime.tv_usec / 1000
+ 1000 * LODWORD(v3.ru_utime.tv_sec)
- *(_DWORD *)(a1 + 12);
}
}
}
return result;
}

original_code:
void clock_stop(Clock p)
{
  if (Clocks_enabled) {
    if (p->level <= 0)
      fprintf(stderr,"WARNING, clock_stop: clock %s not running.\n",p->name);
    else {
      p->level--;
      if (p->level == 0) {
 unsigned msec;
 { struct rusage r; getrusage(RUSAGE_SELF, &r); msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
 p->accum_msec += msec - p->curr_msec;
      }
    }
  }
}

canonical_original_code:
void clock_stop(struct clock *p)
{
  if (Clocks_enabled) {
    if (p->level <= 0)
      fprintf(stderr,"WARNING, clock_stop: clock %s not running.\n",p->name);
    else {
      p->level--;
      if (p->level == 0) {
 unsigned int msec;
 { struct rusage r; getrusage(RUSAGE_SELF, &r); msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
 p->accum_msec += msec - p->curr_msec;
      }
    }
  }
}

variable_types:
msec
unsigned int

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
__int64 __fastcall clock_milliseconds(_DWORD *a1)
{
unsigned int v1; // er12
struct rusage v3; // [rsp+0h] [rbp-A8h] BYREF

if ( !a1 )
return 0LL;
v1 = a1[2];
if ( !a1[4] )
return v1;
getrusage(RUSAGE_SELF, &v3);
return 1000 * LODWORD(v3.ru_utime.tv_sec) + SLODWORD(v3.ru_utime.tv_usec) / 1000 + v1 - a1[3];
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1)
{
unsigned int v1; // er12
struct rusage v3; // [rsp+0h] [rbp-A8h] BYREF

if ( !a1 )
return 0LL;
v1 = a1[2];
if ( !a1[4] )
return v1;
getrusage(RUSAGE_SELF, &v3);
return 1000 * LODWORD(v3.ru_utime.tv_sec) + SLODWORD(v3.ru_utime.tv_usec) / 1000 + v1 - a1[3];
}

original_code:
unsigned clock_milliseconds(Clock p)
{
  if (p == ((void *)0))
    return 0;
  else {
    int i = p->accum_msec;
    if (p->level == 0)
      return i;
    else {
      int msec;
      { struct rusage r; getrusage(RUSAGE_SELF, &r); msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
      return i + (msec - p->curr_msec);
    }
  }
}

canonical_original_code:
unsigned int clock_milliseconds(struct clock *p)
{
  if (p == ((void *)0))
    return 0;
  else {
    int i = p->accum_msec;
    if (p->level == 0)
      return i;
    else {
      int msec;
      { struct rusage r; getrusage(RUSAGE_SELF, &r); msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
      return i + (msec - p->curr_msec);
    }
  }
}

variable_types: i int

variable_types: msec int


decompiled_code:
double __fastcall clock_seconds(_DWORD *a1)
{
int v1; // ebp
struct rusage v3; // [rsp+0h] [rbp-A8h] BYREF

if ( !a1 )
return 0.0;
v1 = a1[2];
if ( !a1[4] )
return (double)v1 / 1000.0;
getrusage(RUSAGE_SELF, &v3);
return (double)(1000 * LODWORD(v3.ru_utime.tv_sec) + SLODWORD(v3.ru_utime.tv_usec) / 1000 + v1 - a1[3]) / 1000.0;
}

canonical_decompiled_code:
double __fastcall func6(_DWORD *a1)
{
int v1; // ebp
struct rusage v3; // [rsp+0h] [rbp-A8h] BYREF

if ( !a1 )
return 0.0;
v1 = a1[2];
if ( !a1[4] )
return (double)v1 / 1000.0;
getrusage(RUSAGE_SELF, &v3);
return (double)(1000 * LODWORD(v3.ru_utime.tv_sec) + SLODWORD(v3.ru_utime.tv_usec) / 1000 + v1 - a1[3]) / 1000.0;
}

original_code:
double clock_seconds(Clock p)
{
  if (p == ((void *)0))
    return 0.0;
  else {
    int i = p->accum_msec;
    if (p->level == 0)
      return (i / 1000.0);
    else {
      int msec;
      { struct rusage r; getrusage(RUSAGE_SELF, &r); msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
      return (i + (msec - p->curr_msec)) / 1000.0;
    }
  }
}

canonical_original_code:
double clock_seconds(struct clock *p)
{
  if (p == ((void *)0))
    return 0.0;
  else {
    int i = p->accum_msec;
    if (p->level == 0)
      return (i / 1000.0);
    else {
      int msec;
      { struct rusage r; getrusage(RUSAGE_SELF, &r); msec = r.ru_utime.tv_sec * 1000 + r.ru_utime.tv_usec / 1000; };
      return (i + (msec - p->curr_msec)) / 1000.0;
    }
  }
}

return_type: double


decompiled_code:
_BOOL8 __fastcall clock_running(__int64 a1)
{
return *(_DWORD *)(a1 + 16) > 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(__int64 a1)
{
return *(_DWORD *)(a1 + 16) > 0;
}

original_code:
BOOL clock_running(Clock p)
{
  return p->level > 0;
}

canonical_original_code:
enum BOOL clock_running(struct clock *p)
{
  return p->level > 0;
}


original_code:
void clock_reset(Clock p)
{
  if (p != ((void *)0)) {
    p->level = 0;
    p->accum_msec = 0;
  }
}

canonical_original_code:
void clock_reset(struct clock *p)
{
  if (p != ((void *)0)) {
    p->level = 0;
    p->accum_msec = 0;
  }
}


decompiled_code:
char *get_date()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
return asctime(v0);
}

canonical_decompiled_code:
char *func10()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
return asctime(v0);
}

original_code:
char * get_date(void)
{
  time_t i = time(((void *)0));
  return asctime(localtime(&i));
}

canonical_original_code:
char *get_date()
{
  long i = time(((void *)0));
  return asctime(localtime(&i));
}

variable_types: i long

return_type: char *


decompiled_code:
__int64 user_time()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return 1000 * LODWORD(v1.ru_utime.tv_sec) + LODWORD(v1.ru_utime.tv_usec) / 0x3E8;
}

canonical_decompiled_code:
__int64 func11()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return 1000 * LODWORD(v1.ru_utime.tv_sec) + LODWORD(v1.ru_utime.tv_usec) / 0x3E8;
}

original_code:
unsigned user_time()
{
  struct rusage r;
  unsigned sec, usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_utime.tv_sec;
  usec = r.ru_utime.tv_usec;
  return((sec * 1000) + (usec / 1000));
}

canonical_original_code:
unsigned int user_time()
{
  struct rusage r;
  unsigned int sec; unsigned int usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_utime.tv_sec;
  usec = r.ru_utime.tv_usec;
  return((sec * 1000) + (usec / 1000));
}

variable_types:
sec
unsigned int

variable_types:
usec
unsigned int


decompiled_code:
double user_seconds()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return (double)SLODWORD(v1.ru_utime.tv_usec) / 1000000.0 + (double)SLODWORD(v1.ru_utime.tv_sec);
}

canonical_decompiled_code:
double func12()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return (double)SLODWORD(v1.ru_utime.tv_usec) / 1000000.0 + (double)SLODWORD(v1.ru_utime.tv_sec);
}

original_code:
double user_seconds()
{
  struct rusage r;
  unsigned sec, usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_utime.tv_sec;
  usec = r.ru_utime.tv_usec;
  return(sec + (usec / 1000000.0));
}

canonical_original_code:
double user_seconds()
{
  struct rusage r;
  unsigned int sec; unsigned int usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_utime.tv_sec;
  usec = r.ru_utime.tv_usec;
  return(sec + (usec / 1000000.0));
}


decompiled_code:
__int64 system_time()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return 1000 * LODWORD(v1.ru_stime.tv_sec) + LODWORD(v1.ru_stime.tv_usec) / 0x3E8;
}

canonical_decompiled_code:
__int64 func13()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return 1000 * LODWORD(v1.ru_stime.tv_sec) + LODWORD(v1.ru_stime.tv_usec) / 0x3E8;
}

original_code:
unsigned system_time()
{
  struct rusage r;
  unsigned sec, usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_stime.tv_sec;
  usec = r.ru_stime.tv_usec;
  return((sec * 1000) + (usec / 1000));
}

canonical_original_code:
unsigned int system_time()
{
  struct rusage r;
  unsigned int sec; unsigned int usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_stime.tv_sec;
  usec = r.ru_stime.tv_usec;
  return((sec * 1000) + (usec / 1000));
}


decompiled_code:
double system_seconds()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return (double)SLODWORD(v1.ru_stime.tv_usec) / 1000000.0 + (double)SLODWORD(v1.ru_stime.tv_sec);
}

canonical_decompiled_code:
double func14()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
return (double)SLODWORD(v1.ru_stime.tv_usec) / 1000000.0 + (double)SLODWORD(v1.ru_stime.tv_sec);
}

original_code:
double system_seconds()
{
  struct rusage r;
  unsigned sec, usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_stime.tv_sec;
  usec = r.ru_stime.tv_usec;
  return(sec + (usec / 1000000.0));
}

canonical_original_code:
double system_seconds()
{
  struct rusage r;
  unsigned int sec; unsigned int usec;
  getrusage(RUSAGE_SELF, &r);
  sec = r.ru_stime.tv_sec;
  usec = r.ru_stime.tv_usec;
  return(sec + (usec / 1000000.0));
}


decompiled_code:
time_t absolute_wallclock()
{
return time(0LL);
}

canonical_decompiled_code:
time_t func15()
{
return time(0LL);
}

original_code:
unsigned absolute_wallclock(void)
{
  time_t t = time((time_t *) ((void *)0));
  return (unsigned) t;
}

canonical_original_code:
unsigned int absolute_wallclock()
{
  long t = time((time_t *) ((void *)0));
  return (unsigned int) t;
}

variable_types: t long


decompiled_code:
time_t init_wallclock()
{
time_t result; // rax

result = absolute_wallclock();
Wall_start = result;
return result;
}

canonical_decompiled_code:
time_t func16()
{
time_t result; // rax

result = func15();
Wall_start = result;
return result;
}

original_code:
void init_wallclock()
{
  Wall_start = absolute_wallclock();
}


wallclock

decompiled_code:
__int64 wallclock()
{
return (unsigned int)absolute_wallclock() - Wall_start;
}

canonical_decompiled_code:
__int64 func17()
{
return (unsigned int)func15() - Wall_start;
}

original_code:
unsigned wallclock()
{
  return absolute_wallclock() - Wall_start;
}

canonical_original_code:
unsigned int wallclock()
{
  return absolute_wallclock() - Wall_start;
}


decompiled_code:
void disable_clocks()
{
Clocks_enabled = 0;
}

canonical_decompiled_code:
void func18()
{
Clocks_enabled = 0;
}

original_code:
void disable_clocks(void)
{
  Clocks_enabled = FALSE;
}

canonical_original_code:
void disable_clocks()
{
  Clocks_enabled = FALSE;
}


decompiled_code:
void enable_clocks()
{
Clocks_enabled = 1;
}

canonical_decompiled_code:
void func19()
{
Clocks_enabled = 1;
}

original_code:
void enable_clocks(void)
{
  Clocks_enabled = TRUE;
}

canonical_original_code:
void enable_clocks()
{
  Clocks_enabled = TRUE;
}


decompiled_code:
__int64 clocks_enabled()
{
return (unsigned int)Clocks_enabled;
}

canonical_decompiled_code:
__int64 func20()
{
return (unsigned int)Clocks_enabled;
}

original_code:
BOOL clocks_enabled(void)
{
  return Clocks_enabled;
}

canonical_original_code:
enum BOOL clocks_enabled()
{
  return Clocks_enabled;
}


decompiled_code:
__int64 __fastcall random_term(int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
int v11; // esi
int v12; // edx
__int64 v13; // r10
int v15; // eax
__int64 v16; // rcx
__int16 *v17; // rdx
__int64 v18; // rax
int v19; // er9
int v20; // er8
__int64 v21; // rbx
unsigned int v22; // er15
unsigned int v23; // er14
unsigned int v24; // er13
__int64 v25; // r12
__int64 *v26; // rbp
__int64 v27; // rax
int v28; // ecx
int v29; // [rsp+0h] [rbp-88h]
int v30; // [rsp+0h] [rbp-88h]
int v31; // [rsp+4h] [rbp-84h]
int v32; // [rsp+8h] [rbp-80h]
char s[120]; // [rsp+10h] [rbp-78h] BYREF

v29 = a1 + a2;
if ( a6 )
{
v11 = a1 + a2;
v12 = rand() % (int)(a5 + a4 + a3 + v29);
if ( v12 >= a1 )
goto LABEL_3;
return get_variable_term((unsigned int)v12);
}
v11 = a1 + a2;
v12 = rand() % v29;
if ( v12 < a1 )
return get_variable_term((unsigned int)v12);
LABEL_3:
if ( v12 >= v11 )
{
v15 = a3 + v11;
if ( (int)(a3 + v11) > v12 )
{
v32 = 1;
v16 = (unsigned int)(v12 - v11);
v17 = aGfha;
}
else if ( (int)(v15 + a4) <= v12 )
{
v28 = v12;
v32 = 3;
v17 = &aGfha[2];
v16 = v28 - (v15 + a4);
}
else
{
v32 = 2;
v16 = (unsigned int)(v12 - v15);
v17 = &aGfha[1];
}
sprintf(s, "%s%d", (const char *)v17, v16);
v18 = get_rigid_term(s, (unsigned int)v32);
v19 = a6 - 1;
v20 = a5;
v21 = 0LL;
v22 = a4;
v23 = a3;
v24 = a2;
v25 = v18;
do
{
v31 = v19;
v26 = (__int64 *)(*(_QWORD *)(v25 + 8) + 8 * v21);
v30 = v20;
++v21;
v27 = random_term((unsigned int)a1, v24, v23, v22);
v20 = v30;
*v26 = v27;
v19 = v31;
}
while ( v32 > (int)v21 );
v13 = v25;
}
else
{
sprintf(s, "%s%d", (const char *)&aGfha[3], (unsigned int)(v12 - a1));
v13 = get_rigid_term(s, 0LL);
}
return v13;
}

original_code:
Term random_term(int v, int a0, int a1, int a2, int a3,
   int max_depth)
{
  int n, arity, j;
  char *s, symbol[51];
  if (max_depth == 0)
    n = rand() % (v+a0);
  else
    n = rand() % (v+a0+a1+a2+a3);
  if (n < v) {
    arity = -1;
    j = n;
  }
  else if (n < v+a0) {
    arity = 0;
    j = n - v;
  }
  else if (n < v+a0+a1) {
    arity = 1;
    j = n - (v+a0);
  }
  else if (n < v+a0+a1+a2) {
    arity = 2;
    j = n - (v+a0+a1);
  }
  else {
    arity = 3;
    j = n - (v+a0+a1+a2);
  }
  if (arity == -1) {
    return get_variable_term(j);
  }
  else {
    int i;
    Term t;
    switch (arity) {
    case 0: s = "a"; break;
    case 1: s = "g"; break;
    case 2: s = "f"; break;
    case 3: s = "h"; break;
    default: s = "?"; break;
    }
    sprintf(symbol, "%s%d", s, j);
    t = get_rigid_term(symbol, arity);
    for (i = 0; i < arity; i++)
      ((t)->args[i]) = random_term(v, a0, a1, a2, a3, max_depth-1);
    return t;
  }
}

canonical_original_code:
struct term *random_term(int v, int a0, int a1, int a2, int a3, int max_depth)
{
  int n; int arity; int j;
  char *s; char symbol[51];
  if (max_depth == 0)
    n = rand() % (v+a0);
  else
    n = rand() % (v+a0+a1+a2+a3);
  if (n < v) {
    arity = -1;
    j = n;
  }
  else if (n < v+a0) {
    arity = 0;
    j = n - v;
  }
  else if (n < v+a0+a1) {
    arity = 1;
    j = n - (v+a0);
  }
  else if (n < v+a0+a1+a2) {
    arity = 2;
    j = n - (v+a0+a1);
  }
  else {
    arity = 3;
    j = n - (v+a0+a1+a2);
  }
  if (arity == -1) {
    return get_variable_term(j);
  }
  else {
    int i;
    struct term *t;
    switch (arity) {
    case 0: s = "a"; break;
    case 1: s = "g"; break;
    case 2: s = "f"; break;
    case 3: s = "h"; break;
    default: s = "?"; break;
    }
    sprintf(symbol, "%s%d", s, j);
    t = get_rigid_term(symbol, arity);
    for (i = 0; i < arity; i++)
      ((t)->args[i]) = random_term(v, a0, a1, a2, a3, max_depth-1);
    return t;
  }
}

variable_types: v int

variable_types: arity int

variable_types: j int

variable_types:
s
char *

variable_types:
symbol
char [51]

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 *__fastcall random_nonvariable_term(int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
int *i; // rdi

for ( i = (int *)random_term(a1, a2, a3, a4, a5, a6); *i >= 0; i = (int *)random_term(a1, a2, a3, a4, a5, a6) )
zap_term(i);
return i;
}

canonical_decompiled_code:
int *__fastcall func1(int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
int *i; // rdi

for ( i = (int *)func0(a1, a2, a3, a4, a5, a6); *i >= 0; i = (int *)func0(a1, a2, a3, a4, a5, a6) )
zap_term(i);
return i;
}

original_code:
Term random_nonvariable_term(int v, int a0, int a1, int a2, int a3,
        int max_depth)
{
  Term t = random_term(v, a0, a1, a2, a3, max_depth);
  while (((t)->private_symbol >= 0)) {
    zap_term(t);
    t = random_term(v, a0, a1, a2, a3, max_depth);
  }
  return t;
}

canonical_original_code:
struct term *random_nonvariable_term(int v, int a0, int a1, int a2, int a3, int max_depth)
{
  struct term *t = random_term(v, a0, a1, a2, a3, max_depth);
  while (((t)->private_symbol >= 0)) {
    zap_term(t);
    t = random_term(v, a0, a1, a2, a3, max_depth);
  }
  return t;
}

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:
__int64 __fastcall random_complex_term(int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
__int64 i; // rdi

for ( i = random_term(a1, a2, a3, a4, a5, a6);
*(int *)i >= 0 || !*(_BYTE *)(i + 4);
i = random_term(a1, a2, a3, a4, a5, a6) )
{
zap_term(i);
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, unsigned int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
__int64 i; // rdi

for ( i = func0(a1, a2, a3, a4, a5, a6);
*(int *)i >= 0 || !*(_BYTE *)(i + 4);
i = func0(a1, a2, a3, a4, a5, a6) )
{
zap_term(i);
}
return i;
}

original_code:
Term random_complex_term(int v, int a0, int a1, int a2, int a3,
        int max_depth)
{
  Term t = random_term(v, a0, a1, a2, a3, max_depth);
  while (((t)->private_symbol >= 0)|| ((t)->private_symbol < 0 && (t)->arity == 0)) {
    zap_term(t);
    t = random_term(v, a0, a1, a2, a3, max_depth);
  }
  return t;
}

canonical_original_code:
struct term *random_complex_term(int v, int a0, int a1, int a2, int a3, int max_depth)
{
  struct term *t = random_term(v, a0, a1, a2, a3, max_depth);
  while (((t)->private_symbol >= 0)|| ((t)->private_symbol < 0 && (t)->arity == 0)) {
    zap_term(t);
    t = random_term(v, a0, a1, a2, a3, max_depth);
  }
  return t;
}

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


original_code:
Ilist random_path(int length_max, int value_max)
{
  Ilist first, current, new;
  int length = (rand() % length_max) + 1;
  int i, value;
  first = current = ((void *)0);
  for (i = 0; i < length; i++) {
    value = (rand() % value_max) + 1;
    new = get_ilist();
    new->i = value;
    new->next = ((void *)0);
    if (first == ((void *)0))
      first = new;
    else
      current->next = new;
    current = new;
  }
  return first;
}

canonical_original_code:
struct ilist *random_path(int length_max, int value_max)
{
  struct ilist *first; struct ilist *current; struct ilist *new;
  int length = (rand() % length_max) + 1;
  int i; int value;
  first = current = ((void *)0);
  for (i = 0; i < length; i++) {
    value = (rand() % value_max) + 1;
    new = get_ilist();
    new->i = value;
    new->next = ((void *)0);
    if (first == ((void *)0))
      first = new;
    else
      current->next = new;
    current = new;
  }
  return first;
}

variable_types: struct ilist { int i; struct ilist *next; } *

variable_types: length int

variable_types: value int


decompiled_code:
__int64 __fastcall random_op_term(int a1)
{
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r12
__int64 v5; // r13
__int64 v6; // rbp
_QWORD *v7; // r14
__int64 v9; // rbp
__int64 v10; // r13
__int64 v11; // r14
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
int v15; // eax

if ( !initialized_1 )
{
symnum_0[0] = str_to_sn(&aGfha[3], 0LL);
dword_724 = str_to_sn("->", 2LL);
dword_728 = str_to_sn(asc_77C, 2LL);
dword_72C = str_to_sn(&asc_77C[1], 2LL);
dword_730 = str_to_sn(&asc_77C[2], 1LL);
dword_734 = str_to_sn(&asc_77C[3], 2LL);
dword_738 = str_to_sn(&asc_77C[4], 2LL);
dword_73C = str_to_sn(&asc_77C[5], 2LL);
dword_740 = str_to_sn(&asc_77C[6], 1LL);
dword_744 = str_to_sn("$cons", 2LL);
dword_748 = str_to_sn("$nil", 0LL);
dword_74C = str_to_sn("$quantified", 1LL);
v15 = str_to_sn(&aGfha[1], 2LL);
initialized_1 = 1;
dword_750 = v15;
}
if ( !a1 )
return get_rigid_term("b", 0LL);
v1 = (unsigned int)symnum_0[rand() % 13];
v2 = (int)sn_to_arity(v1);
if ( (unsigned int)is_symbol((unsigned int)v1, "$quantified", 1LL) )
{
v4 = get_rigid_term("$quantified", 1LL);
v9 = get_rigid_term("all", 0LL);
v10 = get_rigid_term("x", 0LL);
v11 = random_op_term((unsigned int)(a1 - 1));
v12 = get_nil_term();
v13 = listterm_cons(v11, v12);
v14 = listterm_cons(v10, v13);
**(_QWORD **)(v4 + 8) = listterm_cons(v9, v14);
return v4;
}
v3 = sn_to_str((unsigned int)v1);
v4 = get_rigid_term(v3, (unsigned int)v2);
if ( (int)v2 <= 0 )
return v4;
v5 = 8 * v2;
v6 = 0LL;
do
{
v7 = (_QWORD *)(v6 + *(_QWORD *)(v4 + 8));
v6 += 8LL;
*v7 = random_op_term((unsigned int)(a1 - 1));
}
while ( v6 != v5 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r12
__int64 v5; // r13
__int64 v6; // rbp
_QWORD *v7; // r14
__int64 v9; // rbp
__int64 v10; // r13
__int64 v11; // r14
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
int v15; // eax

if ( !initialized_1 )
{
symnum_0[0] = str_to_sn(&aGfha[3], 0LL);
dword_724 = str_to_sn("->", 2LL);
dword_728 = str_to_sn(asc_77C, 2LL);
dword_72C = str_to_sn(&asc_77C[1], 2LL);
dword_730 = str_to_sn(&asc_77C[2], 1LL);
dword_734 = str_to_sn(&asc_77C[3], 2LL);
dword_738 = str_to_sn(&asc_77C[4], 2LL);
dword_73C = str_to_sn(&asc_77C[5], 2LL);
dword_740 = str_to_sn(&asc_77C[6], 1LL);
dword_744 = str_to_sn("$cons", 2LL);
dword_748 = str_to_sn("$nil", 0LL);
dword_74C = str_to_sn("$quantified", 1LL);
v15 = str_to_sn(&aGfha[1], 2LL);
initialized_1 = 1;
dword_750 = v15;
}
if ( !a1 )
return get_rigid_term("b", 0LL);
v1 = (unsigned int)symnum_0[rand() % 13];
v2 = (int)sn_to_arity(v1);
if ( (unsigned int)is_symbol((unsigned int)v1, "$quantified", 1LL) )
{
v4 = get_rigid_term("$quantified", 1LL);
v9 = get_rigid_term("all", 0LL);
v10 = get_rigid_term("x", 0LL);
v11 = func6((unsigned int)(a1 - 1));
v12 = get_nil_term();
v13 = listterm_cons(v11, v12);
v14 = listterm_cons(v10, v13);
**(_QWORD **)(v4 + 8) = listterm_cons(v9, v14);
return v4;
}
v3 = sn_to_str((unsigned int)v1);
v4 = get_rigid_term(v3, (unsigned int)v2);
if ( (int)v2 <= 0 )
return v4;
v5 = 8 * v2;
v6 = 0LL;
do
{
v7 = (_QWORD *)(v6 + *(_QWORD *)(v4 + 8));
v6 += 8LL;
*v7 = func6((unsigned int)(a1 - 1));
}
while ( v6 != v5 );
return v4;
}

original_code:
Term random_op_term(int depth)
{
  static int initialized = 0;
  static int symnum[13];
  if (!initialized) {
    symnum[0] = str_to_sn("a", 0);
    symnum[1] = str_to_sn("->", 2);
    symnum[2] = str_to_sn("|", 2);
    symnum[3] = str_to_sn("&", 2);
    symnum[4] = str_to_sn("~", 1);
    symnum[5] = str_to_sn("=", 2);
    symnum[6] = str_to_sn("+", 2);
    symnum[7] = str_to_sn("*", 2);
    symnum[8] = str_to_sn("\'", 1);
    symnum[9] = str_to_sn("$cons", 2);
    symnum[10] = str_to_sn("$nil", 0);
    symnum[11] = str_to_sn("$quantified", 1);
    symnum[12] = str_to_sn("f", 2);
    initialized = 1;
  }
  if (depth == 0)
    return get_rigid_term("b", 0);
  else {
    Term t;
    int arity, i, sn;
    sn = symnum[rand() % 13];
    arity = sn_to_arity(sn);
    if (is_symbol(sn, "$quantified", 1)) {
      Term q = get_rigid_term("$quantified", 1);
      Term a = get_rigid_term("all", 0);
      Term x = get_rigid_term("x", 0);
      Term r = random_op_term(depth-1);
      Term t = get_nil_term();
      t = listterm_cons(r, t);
      t = listterm_cons(x, t);
      t = listterm_cons(a, t);
      ((q)->args[0]) = t;
      return q;
    }
    else {
      t = get_rigid_term(sn_to_str(sn), arity);
      for (i = 0; i < arity; i++)
 ((t)->args[i]) = random_op_term(depth-1);
      return t;
    }
  }
}

canonical_original_code:
struct term *random_op_term(int depth)
{
  static int initialized = 0;
  static int symnum[13];
  if (!initialized) {
    symnum[0] = str_to_sn("a", 0);
    symnum[1] = str_to_sn("->", 2);
    symnum[2] = str_to_sn("|", 2);
    symnum[3] = str_to_sn("&", 2);
    symnum[4] = str_to_sn("~", 1);
    symnum[5] = str_to_sn("=", 2);
    symnum[6] = str_to_sn("+", 2);
    symnum[7] = str_to_sn("*", 2);
    symnum[8] = str_to_sn("\'", 1);
    symnum[9] = str_to_sn("$cons", 2);
    symnum[10] = str_to_sn("$nil", 0);
    symnum[11] = str_to_sn("$quantified", 1);
    symnum[12] = str_to_sn("f", 2);
    initialized = 1;
  }
  if (depth == 0)
    return get_rigid_term("b", 0);
  else {
    struct term *t;
    int arity; int i; int sn;
    sn = symnum[rand() % 13];
    arity = sn_to_arity(sn);
    if (is_symbol(sn, "$quantified", 1)) {
      struct term *q = get_rigid_term("$quantified", 1);
      struct term *a = get_rigid_term("all", 0);
      struct term *x = get_rigid_term("x", 0);
      struct term *r = random_op_term(depth-1);
      struct term *t = get_nil_term();
      t = listterm_cons(r, t);
      t = listterm_cons(x, t);
      t = listterm_cons(a, t);
      ((q)->args[0]) = t;
      return q;
    }
    else {
      t = get_rigid_term(sn_to_str(sn), arity);
      for (i = 0; i < arity; i++)
 ((t)->args[i]) = random_op_term(depth-1);
      return t;
    }
  }
}

variable_types: depth int

variable_types: initialized int

variable_types:
symnum
int [13]

variable_types: sn int


original_code:
void random_permutation(int *a, int size)
{
  int n, i, x;
  for (i = 0; i < size; i++)
    a[i] = -1;
  n = 0;
  while (n < size) {
    x = rand() % size;
    if (a[x] == -1)
      a[x] = n++;
    else {
      i = x+1;
      while (i < size && a[i] != -1)
 i++;
      if (i < size)
 a[i] = n++;
      else {
 i = x-1;
 while (i >= 0 && a[i] != -1)
   i--;
 if (i < 0) {
   fatal_error("random_permutation.");
 }
 a[i] = n++;
      }
    }
  }
}

canonical_original_code:
void random_permutation(int *a, int size)
{
  int n; int i; int x;
  for (i = 0; i < size; i++)
    a[i] = -1;
  n = 0;
  while (n < size) {
    x = rand() % size;
    if (a[x] == -1)
      a[x] = n++;
    else {
      i = x+1;
      while (i < size && a[i] != -1)
 i++;
      if (i < size)
 a[i] = n++;
      else {
 i = x-1;
 while (i >= 0 && a[i] != -1)
   i--;
 if (i < 0) {
   fatal_error("random_permutation.");
 }
 a[i] = n++;
      }
    }
  }
}

variable_types:
a
int *

variable_types: size int

variable_types: n int

variable_types: i int

variable_types: x int


flatten

original_code:
void flatten(Term t, Term *a, int *ip)
{
  Term t1;
  int sn, i;
  sn = (-((t)->private_symbol));
  for (i = 0; i < ((t)->arity); i++) {
    t1 = ((t)->args[i]);
    if ((-((t1)->private_symbol)) == sn)
      flatten(t1, a, ip);
    else {
      if (*ip >= 2500) {
 fprint_term(stdout, t);
 fatal_error("flatten, too many arguments.");
      }
      a[*ip] = t1;
      (*ip)++;
    }
  }
}

canonical_original_code:
void flatten(struct term *t, struct term **a, int *ip)
{
  struct term *t1;
  int sn; int i;
  sn = (-((t)->private_symbol));
  for (i = 0; i < ((t)->arity); i++) {
    t1 = ((t)->args[i]);
    if ((-((t1)->private_symbol)) == sn)
      flatten(t1, a, ip);
    else {
      if (*ip >= 2500) {
 fprint_term(stdout, t);
 fatal_error("flatten, too many arguments.");
      }
      a[*ip] = t1;
      (*ip)++;
    }
  }
}

variable_types:
a
struct term **

variable_types:
ip
int *


original_code:
void ac_canonical2(Term t, int bit,
     Ordertype (*term_compare_proc) (Term, Term))
{
  Term args[2500], work[2500];
  Term t1;
  int n, i;
  if (is_assoc_comm((-((t)->private_symbol)))) {
    n = 0;
    flatten(t, args, &n);
    for (i = 0; i < n; i++)
      if (bit == -1 || !term_flag(args[i], bit))
 ac_canonical2(args[i], bit, term_compare_proc);
    merge_sort_recurse((void **) args, (void **) work, 0, n-1,
        (Ordertype (*)(void*,void*)) term_compare_proc);
    right_associate(t);
    for (t1 = t, i = 0; i < n-2; t1 = ((t1)->args[1]), i++) {
      ((t1)->args[0]) = args[i];
      if (bit != -1)
 term_flag_clear(t1, bit);
    }
    ((t1)->args[0]) = args[n-2];
    ((t1)->args[1]) = args[n-1];
  }
  else {
    for (i = 0; i < ((t)->arity); i++)
      ac_canonical2(((t)->args[i]), bit, term_compare_proc);
  }
}

canonical_original_code:
void ac_canonical2(struct term *t, int bit, enum Ordertype (*term_compare_proc)(struct term *, struct term *))
{
  struct term *args[2500]; struct term *work[2500];
  struct term *t1;
  int n; int i;
  if (is_assoc_comm((-((t)->private_symbol)))) {
    n = 0;
    flatten(t, args, &n);
    for (i = 0; i < n; i++)
      if (bit == -1 || !term_flag(args[i], bit))
 ac_canonical2(args[i], bit, term_compare_proc);
    merge_sort_recurse((void **) args, (void **) work, 0, n-1,
        (enum Ordertype (*)(void *, void *)) term_compare_proc);
    right_associate(t);
    for (t1 = t, i = 0; i < n-2; t1 = ((t1)->args[1]), i++) {
      ((t1)->args[0]) = args[i];
      if (bit != -1)
 term_flag_clear(t1, bit);
    }
    ((t1)->args[0]) = args[n-2];
    ((t1)->args[1]) = args[n-1];
  }
  else {
    for (i = 0; i < ((t)->arity); i++)
      ac_canonical2(((t)->args[i]), bit, term_compare_proc);
  }
}

variable_types: bit 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 } (*)(struct term *, struct term *)

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; } *[2500]


decompiled_code:
__int64 __fastcall ac_canonical(__int64 a1, unsigned int a2)
{
return ac_canonical2(a1, a2, (__int64)&term_compare_ncv);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2)
{
return func1(a1, a2, (__int64)&term_compare_ncv);
}

original_code:
void ac_canonical(Term t, int bit)
{
  ac_canonical2(t, bit, term_compare_ncv);
}

canonical_original_code:
void ac_canonical(struct term *t, int bit)
{
  ac_canonical2(t, bit, term_compare_ncv);
}

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:
__int64 __fastcall check_ac_canonical(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12

v1 = copy_term();
ac_canonical(v1, 0xFFFFFFFF);
v2 = term_ident(a1, v1);
zap_term(v1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12

v1 = copy_term();
func2(v1, 0xFFFFFFFF);
v2 = term_ident(a1, v1);
zap_term(v1);
return v2;
}

original_code:
int check_ac_canonical(Term t)
{
  int rc;
  Term t1 = copy_term(t);
  ac_canonical(t1, -1);
  rc = term_ident(t, t1);
  zap_term(t1);
  return(rc);
}

canonical_original_code:
int check_ac_canonical(struct term *t)
{
  int rc;
  struct term *t1 = copy_term(t);
  ac_canonical(t1, -1);
  rc = term_ident(t, t1);
  zap_term(t1);
  return(rc);
}

variable_types: rc int


prime

decompiled_code:
__int64 __fastcall prime(int a1)
{
int *v1; // rax
int v2; // edx
__int64 v3; // rax
__int64 v4; // rax
__int64 result; // rax

if ( !initialized_1 )
{
v1 = (int *)&unk_128;
do
*v1++ = 1;
while ( v1 != &initialized_1 );
v2 = 2;
LODWORD(v3) = 4;
do
{
v3 = (int)v3;
do
{
a_0[v3] = 0;
v3 += v2;
}
while ( (int)v3 <= 999 );
v4 = v2 + 1;
do
v2 = v4++;
while ( !*(_DWORD *)(4 * v4 + 0x11C) );
LODWORD(v3) = v2 * v2;
}
while ( v2 * v2 <= 999 );
initialized_1 = 1;
}
if ( a1 > 1000 )
exit(1);
result = 0LL;
if ( a1 > 1 )
result = (unsigned int)a_0[a1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
int *v1; // rax
int v2; // edx
__int64 v3; // rax
__int64 v4; // rax
__int64 result; // rax

if ( !initialized_1 )
{
v1 = (int *)&unk_128;
do
*v1++ = 1;
while ( v1 != &initialized_1 );
v2 = 2;
LODWORD(v3) = 4;
do
{
v3 = (int)v3;
do
{
a_0[v3] = 0;
v3 += v2;
}
while ( (int)v3 <= 999 );
v4 = v2 + 1;
do
v2 = v4++;
while ( !*(_DWORD *)(4 * v4 + 0x11C) );
LODWORD(v3) = v2 * v2;
}
while ( v2 * v2 <= 999 );
initialized_1 = 1;
}
if ( a1 > 1000 )
exit(1);
result = 0LL;
if ( a1 > 1 )
result = (unsigned int)a_0[a1];
return result;
}

original_code:
BOOL prime(int n)
{
  static BOOL a[1000 +1];
  static BOOL initialized = FALSE;
  if (!initialized) {
    int i, p;
    for (i = 2; i <= 1000; i++)
      a[i] = TRUE;
    p = 2;
    while (p*p < 1000) {
      int j = p*p;
      while (j < 1000) {
 a[j] = FALSE;
 j = j + p;
      }
      do p++; while (a[p] == FALSE);
    }
    initialized = TRUE;
  }
  if (n > 1000)
    exit(1);
  else if (n < 2)
    return FALSE;
  else
    return a[n];
}

canonical_original_code:
enum BOOL prime(int n)
{
  static enum BOOL a[-1];
  static enum BOOL initialized = FALSE;
  if (!initialized) {
    int i; int p;
    for (i = 2; i <= 1000; i++)
      a[i] = TRUE;
    p = 2;
    while (p*p < 1000) {
      int j = p*p;
      while (j < 1000) {
 a[j] = FALSE;
 j = j + p;
      }
      do p++; while (a[p] == FALSE);
    }
    initialized = TRUE;
  }
  if (n > 1000)
    exit(1);
  else if (n < 2)
    return FALSE;
  else
    return a[n];
}

variable_types:
a
enum BOOL { FALSE=0, TRUE=1 } [-1]

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

variable_types: p int

variable_types: j int


original_code:
void random_permutation(int *a, int n)
{
  int i, t, k;
  for (i = 0; i < n; i++)
    a[i] = i;
  for (i = n-1; i >= 0; i--) {
    k = rand() % (i+1);
    t = a[i];
    a[i] = a[k];
    a[k] = t;
  }
}

canonical_original_code:
void random_permutation(int *a, int n)
{
  int i; int t; int k;
  for (i = 0; i < n; i++)
    a[i] = i;
  for (i = n-1; i >= 0; i--) {
    k = rand() % (i+1);
    t = a[i];
    a[i] = a[k];
    a[k] = t;
  }
}

variable_types: t int

variable_types: k int


decompiled_code:
__int64 __fastcall set_of_more_occurrences(_QWORD *a1, int a2, _QWORD *a3, int a4)
{
__int64 v4; // r12
__int64 v5; // r14
__int64 i; // r13
int v8; // ebx
__int64 v11; // [rsp+28h] [rbp-40h]

if ( a2 <= 0 )
return 0LL;
v4 = 0LL;
v11 = 0LL;
do
{
v5 = a1[v4];
if ( !v4 )
goto LABEL_11;
for ( i = 0LL; !(unsigned int)term_ident(v5, a1[i]); ++i )
{
if ( i == (_DWORD)v4 - 1 )
goto LABEL_11;
}
if ( (_DWORD)i == (_DWORD)v4 )
{
LABEL_11:
v8 = num_occurrences(v5, a1, a2);
if ( v8 > (int)num_occurrences(v5, a3, a4) )
v11 = plist_prepend(v11, v5);
}
++v4;
}
while ( v4 != a2 );
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, int a2, _QWORD *a3, int a4)
{
__int64 v4; // r12
__int64 v5; // r14
__int64 i; // r13
int v8; // ebx
__int64 v11; // [rsp+28h] [rbp-40h]

if ( a2 <= 0 )
return 0LL;
v4 = 0LL;
v11 = 0LL;
do
{
v5 = a1[v4];
if ( !v4 )
goto LABEL_11;
for ( i = 0LL; !(unsigned int)term_ident(v5, a1[i]); ++i )
{
if ( i == (_DWORD)v4 - 1 )
goto LABEL_11;
}
if ( (_DWORD)i == (_DWORD)v4 )
{
LABEL_11:
v8 = func0(v5, a1, a2);
if ( v8 > (int)func0(v5, a3, a4) )
v11 = plist_prepend(v11, v5);
}
++v4;
}
while ( v4 != a2 );
return v11;
}

original_code:
static
Plist set_of_more_occurrences(Term a1[], int n1, Term a2[], int n2)
{
  Plist answer = ((void *)0);
  int i, j;
  for (i = 0; i < n1; i++) {
    Term e1 = a1[i];
    for (j = 0; j != i && !term_ident(e1, a1[j]); j++);
    if (i == j && num_occurrences(e1,a1,n1) > num_occurrences(e1,a2,n2))
      answer = plist_prepend(answer, e1);
  }
  return answer;
}

canonical_original_code:
static struct plist *set_of_more_occurrences(struct term *a1[], int n1, struct term *a2[], int n2)
{
  struct plist *answer = ((void *)0);
  int i; int j;
  for (i = 0; i < n1; i++) {
    struct term *e1 = a1[i];
    for (j = 0; j != i && !term_ident(e1, a1[j]); j++);
    if (i == j && num_occurrences(e1,a1,n1) > num_occurrences(e1,a2,n2))
      answer = plist_prepend(answer, e1);
  }
  return answer;
}

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: struct plist { void *v; struct plist *next; } *


decompiled_code:
__int64 __fastcall greater_multiset(_QWORD *a1, int a2, _QWORD *a3, int a4, __int64 (__fastcall *a5)(_QWORD, _QWORD, _QWORD), unsigned int a6)
{
__int64 v10; // r14
__int64 v11; // r15
int v12; // eax
_QWORD *v13; // rbp
_QWORD *v14; // rbx
unsigned int v16; // [rsp+Ch] [rbp-3Ch]

v10 = set_of_more_occurrences(a1, a2, a3, a4);
v11 = set_of_more_occurrences(a3, a4, a1, a2);
v12 = 0;
if ( v10 )
{
v13 = (_QWORD *)v11;
v12 = 1;
if ( v11 )
{
do
{
v14 = (_QWORD *)v10;
do
{
v12 = a5(*v14, *v13, a6);
v14 = (_QWORD *)v14[1];
}
while ( v14 && !v12 );
v13 = (_QWORD *)v13[1];
}
while ( v13 && v12 );
}
}
v16 = v12;
zap_plist(v10);
zap_plist(v11);
return v16;
}

original_code:
BOOL greater_multiset(Term a1[], int n1, Term a2[], int n2,
        BOOL (*comp_proc) (Term, Term, BOOL),
        BOOL lex_order_vars)
{
  Plist s1, s2, p1, p2;
  BOOL ok;
  s1 = set_of_more_occurrences(a1, n1, a2, n2);
  s2 = set_of_more_occurrences(a2, n2, a1, n1);
  if (s1 == ((void *)0))
    ok = FALSE;
  else {
    for (p2 = s2, ok = TRUE; p2 && ok; p2 = p2->next)
      for (p1 = s1, ok = FALSE; p1 && !ok; p1 = p1->next)
 ok = (*comp_proc)(p1->v, p2->v, lex_order_vars);
  }
  zap_plist(s1);
  zap_plist(s2);
  return ok;
}

canonical_original_code:
enum BOOL greater_multiset(struct term *a1[], int n1, struct term *a2[], int n2, enum BOOL (*comp_proc)(struct term *, struct term *, enum BOOL), enum BOOL lex_order_vars)
{
  struct plist *s1; struct plist *s2; struct plist *p1; struct plist *p2;
  enum BOOL ok;
  s1 = set_of_more_occurrences(a1, n1, a2, n2);
  s2 = set_of_more_occurrences(a2, n2, a1, n1);
  if (s1 == ((void *)0))
    ok = FALSE;
  else {
    for (p2 = s2, ok = TRUE; p2 && ok; p2 = p2->next)
      for (p1 = s1, ok = FALSE; p1 && !ok; p1 = p1->next)
 ok = (*comp_proc)(p1->v, p2->v, lex_order_vars);
  }
  zap_plist(s1);
  zap_plist(s2);
  return ok;
}

variable_types: enum BOOL { FALSE=0, TRUE=1 } (*)(struct term *, struct term *, enum BOOL { FALSE=0, TRUE=1 })

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

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


decompiled_code:
__int64 __fastcall num_occurrences(__int64 a1, _QWORD *a2, int a3)
{
_QWORD *v3; // rbx
unsigned int v4; // er12
__int64 v5; // r13

if ( a3 <= 0 )
return 0LL;
v3 = a2;
v4 = 0;
v5 = (__int64)&a2[(unsigned int)(a3 - 1) + 1];
do
v4 -= ((unsigned int)term_ident(*v3++, a1) == 0) - 1;
while ( v3 != (_QWORD *)v5 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _QWORD *a2, int a3)
{
_QWORD *v3; // rbx
unsigned int v4; // er12
__int64 v5; // r13

if ( a3 <= 0 )
return 0LL;
v3 = a2;
v4 = 0;
v5 = (__int64)&a2[(unsigned int)(a3 - 1) + 1];
do
v4 -= ((unsigned int)term_ident(*v3++, a1) == 0) - 1;
while ( v3 != (_QWORD *)v5 );
return v4;
}

original_code:
static
int num_occurrences(Term t, Term a[], int n)
{
  int i, count;
  for (i = 0, count = 0; i < n; i++)
    if (term_ident(a[i], t))
      count++;
  return count;
}

canonical_original_code:
static int num_occurrences(struct term *t, struct term *a[], int n)
{
  int i; int count;
  for (i = 0, count = 0; i < n; i++)
    if (term_ident(a[i], t))
      count++;
  return count;
}

variable_types:
a
struct term *[]

variable_types: n int

variable_types: i int

variable_types: count int


decompiled_code:
_BOOL8 __fastcall evaluable_predicate(int a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( Symbols_size > a1 )
{
result = 1LL;
if ( !*(_QWORD *)(Rules + 8LL * a1) )
result = *(_DWORD *)(Op_codes + 4LL * a1) != 0;
}
return result;
}

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

result = 0LL;
if ( Symbols_size > a1 )
{
result = 1LL;
if ( !*(_QWORD *)(Rules + 8LL * a1) )
result = *(_DWORD *)(Op_codes + 4LL * a1) != 0;
}
return result;
}

canonical_original_code:
enum BOOL evaluable_predicate(int symnum)
{
  if (symnum >= Symbols_size)
    return FALSE;
  else if (Rules[symnum])
    return TRUE;
  else if (Op_codes[symnum])
    return TRUE;
  else
    return FALSE;
}

variable_types: symnum int


decompiled_code:
__int64 __fastcall dollar_eval(__int64 a1)
{
int v1; // eax
__int64 v2; // rsi
__int64 result; // rax
unsigned int v4; // eax
bool v5; // zf
__int64 v6; // rdi
__int64 *v7; // rax
__int64 v8; // rax
__int64 v9; // rdi
int v10; // eax
int v11; // [rsp+0h] [rbp-14h] BYREF
int v12; // [rsp+4h] [rbp-10h] BYREF
int v13[3]; // [rsp+8h] [rbp-Ch] BYREF

if ( *(int *)a1 > 0 )
return 0LL;
v1 = -*(_DWORD *)a1;
if ( v1 >= Symbols_size )
return 0LL;
v2 = *(unsigned int *)(Op_codes + 4LL * v1);
if ( !(_DWORD)v2 )
return 0LL;
switch ( (int)v2 )
{
case 1:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v11 + v13[0]));
case 2:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v13[0] * v11));
case 3:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v11 / v13[0]));
case 4:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v11 % v13[0]));
case 5:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
v9 = (unsigned int)v11;
if ( v13[0] <= v11 )
v9 = (unsigned int)v13[0];
return int_to_term(v9);
case 6:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)v13[0]);
case 7:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11) )
goto LABEL_20;
return int_to_term(abs32(v11));
case 8:
if ( (unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11) )
return int_to_term((unsigned int)-v11);
if ( !(unsigned int)term_to_bool(**(_QWORD **)(a1 + 8), &v12) )
goto LABEL_20;
return bool_to_term(v12 == 0);
case 9:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 < v13[0]);
case 10:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 <= v13[0]);
case 11:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 > v13[0]);
case 12:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 >= v13[0]);
case 13:
v5 = (unsigned int)term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) == 2;
return bool_to_term(v5);
case 14:
v10 = term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
return bool_to_term((unsigned int)(v10 - 1) <= 1);
case 15:
v5 = (unsigned int)term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) == 3;
return bool_to_term(v5);
case 16:
v5 = (term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) & 0xFFFFFFFD) == 1;
return bool_to_term(v5);
case 17:
case 19:
if ( (unsigned int)term_to_bool(**(_QWORD **)(a1 + 8), &v12) )
{
if ( v12 )
goto LABEL_63;
return bool_to_term(0LL);
}
if ( !(unsigned int)term_to_bool(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
goto LABEL_20;
if ( !v13[0] )
return bool_to_term(0LL);
goto LABEL_68;
case 18:
case 20:
if ( (unsigned int)term_to_bool(**(_QWORD **)(a1 + 8), &v12) )
{
if ( v12 )
return bool_to_term(1LL);
LABEL_63:
result = copy_term(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
}
else if ( (unsigned int)term_to_bool(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
if ( v13[0] )
return bool_to_term(1LL);
LABEL_68:
result = copy_term(**(_QWORD **)(a1 + 8));
}
else
{
LABEL_20:
result = 0LL;
}
break;
case 22:
v4 = term_ident(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
return bool_to_term(v4);
case 23:
v5 = (unsigned int)term_ident(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) == 0;
return bool_to_term(v5);
case 24:
return bool_to_term(***(_DWORD ***)(a1 + 8) >= 0);
case 25:
v7 = *(__int64 **)(a1 + 8);
v6 = 0LL;
v8 = *v7;
if ( *(int *)v8 >= 0 )
return bool_to_term(v6);
return bool_to_term(*(_BYTE *)(v8 + 4) == 0);
case 26:
v6 = (unsigned int)ground_term(**(_QWORD **)(a1 + 8));
return bool_to_term(v6);
default:
printf("bad opcode is %d\n", v2);
fatal_error("dollar_eval: bad opcode");
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // eax
__int64 v2; // rsi
__int64 result; // rax
unsigned int v4; // eax
bool v5; // zf
__int64 v6; // rdi
__int64 *v7; // rax
__int64 v8; // rax
__int64 v9; // rdi
int v10; // eax
int v11; // [rsp+0h] [rbp-14h] BYREF
int v12; // [rsp+4h] [rbp-10h] BYREF
int v13[3]; // [rsp+8h] [rbp-Ch] BYREF

if ( *(int *)a1 > 0 )
return 0LL;
v1 = -*(_DWORD *)a1;
if ( v1 >= Symbols_size )
return 0LL;
v2 = *(unsigned int *)(Op_codes + 4LL * v1);
if ( !(_DWORD)v2 )
return 0LL;
switch ( (int)v2 )
{
case 1:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v11 + v13[0]));
case 2:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v13[0] * v11));
case 3:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v11 / v13[0]));
case 4:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)(v11 % v13[0]));
case 5:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
v9 = (unsigned int)v11;
if ( v13[0] <= v11 )
v9 = (unsigned int)v13[0];
return int_to_term(v9);
case 6:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return int_to_term((unsigned int)v13[0]);
case 7:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11) )
goto LABEL_20;
return int_to_term(abs32(v11));
case 8:
if ( (unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11) )
return int_to_term((unsigned int)-v11);
if ( !(unsigned int)term_to_bool(**(_QWORD **)(a1 + 8), &v12) )
goto LABEL_20;
return bool_to_term(v12 == 0);
case 9:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 < v13[0]);
case 10:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 <= v13[0]);
case 11:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 > v13[0]);
case 12:
if ( !(unsigned int)term_to_int(**(_QWORD **)(a1 + 8), &v11)
|| !(unsigned int)term_to_int(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
goto LABEL_20;
}
return bool_to_term(v11 >= v13[0]);
case 13:
v5 = (unsigned int)term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) == 2;
return bool_to_term(v5);
case 14:
v10 = term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
return bool_to_term((unsigned int)(v10 - 1) <= 1);
case 15:
v5 = (unsigned int)term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) == 3;
return bool_to_term(v5);
case 16:
v5 = (term_compare_basic(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) & 0xFFFFFFFD) == 1;
return bool_to_term(v5);
case 17:
case 19:
if ( (unsigned int)term_to_bool(**(_QWORD **)(a1 + 8), &v12) )
{
if ( v12 )
goto LABEL_63;
return bool_to_term(0LL);
}
if ( !(unsigned int)term_to_bool(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
goto LABEL_20;
if ( !v13[0] )
return bool_to_term(0LL);
goto LABEL_68;
case 18:
case 20:
if ( (unsigned int)term_to_bool(**(_QWORD **)(a1 + 8), &v12) )
{
if ( v12 )
return bool_to_term(1LL);
LABEL_63:
result = copy_term(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
}
else if ( (unsigned int)term_to_bool(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL), v13) )
{
if ( v13[0] )
return bool_to_term(1LL);
LABEL_68:
result = copy_term(**(_QWORD **)(a1 + 8));
}
else
{
LABEL_20:
result = 0LL;
}
break;
case 22:
v4 = term_ident(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
return bool_to_term(v4);
case 23:
v5 = (unsigned int)term_ident(**(_QWORD **)(a1 + 8), *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL)) == 0;
return bool_to_term(v5);
case 24:
return bool_to_term(***(_DWORD ***)(a1 + 8) >= 0);
case 25:
v7 = *(__int64 **)(a1 + 8);
v6 = 0LL;
v8 = *v7;
if ( *(int *)v8 >= 0 )
return bool_to_term(v6);
return bool_to_term(*(_BYTE *)(v8 + 4) == 0);
case 26:
v6 = (unsigned int)ground_term(**(_QWORD **)(a1 + 8));
return bool_to_term(v6);
default:
printf("bad opcode is %d\n", v2);
fatal_error("dollar_eval: bad opcode");
return 0LL;
}
return result;
}

original_code:
Term dollar_eval(Term t)
{
  if ((-((t)->private_symbol)) < 0 || (-((t)->private_symbol)) >= Symbols_size)
    return ((void *)0);
  else {
    int op_code = Op_codes[(-((t)->private_symbol))];
    if (op_code == 0)
      return ((void *)0);
    else {
      int i0, i1;
      BOOL b0, b1;
      Term result = ((void *)0);
      switch (op_code) {
      case SUM_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 + i1);
 break;
      case PROD_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 * i1);
 break;
      case DIV_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 / i1);
 break;
      case MOD_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 % i1);
 break;
      case MIN_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 < i1 ? i0 : i1);
 break;
      case MAX_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 > i1 ? i1 : i1);
 break;
      case ABS_OP:
 if (term_to_int(((t)->args[0]), &i0))
   result = int_to_term(i0 >= 0 ? i0 : -i0);
 break;
      case NEG_OP:
 if (term_to_int(((t)->args[0]), &i0))
   result = int_to_term(-i0);
 else if (term_to_bool(((t)->args[0]), &b0))
   result = bool_to_term(!b0);
 break;
      case LT_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 < i1);
 break;
      case LE_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 <= i1);
 break;
      case GT_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 > i1);
 break;
      case GE_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 >= i1);
 break;
      case AND_OP:
      case AND2_OP:
 if (term_to_bool(((t)->args[0]), &b0)) {
   if (b0)
     result = copy_term(((t)->args[1]));
   else
     result = bool_to_term(FALSE);
 }
 else if (term_to_bool(((t)->args[1]), &b1)) {
   if (b1)
     result = copy_term(((t)->args[0]));
   else
     result = bool_to_term(FALSE);
 }
 break;
      case OR_OP:
      case OR2_OP:
 if (term_to_bool(((t)->args[0]), &b0)) {
   if (b0)
     result = bool_to_term(TRUE);
   else
     result = copy_term(((t)->args[1]));
 }
 else if (term_to_bool(((t)->args[1]), &b1)) {
   if (b1)
     result = bool_to_term(TRUE);
   else
     result = copy_term(((t)->args[0]));
 }
 break;
      case ID_OP:
 result = bool_to_term(term_ident(((t)->args[0]), ((t)->args[1])));
 break;
      case NID_OP:
 result = bool_to_term(!term_ident(((t)->args[0]), ((t)->args[1])));
 break;
      case LLT_OP:
 result = bool_to_term(term_compare_basic(((t)->args[0]),((t)->args[1])) == LESS_THAN);
 break;
      case LLE_OP: {
 Ordertype r = term_compare_basic(((t)->args[0]),((t)->args[1]));
 result = bool_to_term(r == LESS_THAN || r == SAME_AS);
 break;
      }
      case LGT_OP:
 result = bool_to_term(term_compare_basic(((t)->args[0]),((t)->args[1])) == GREATER_THAN);
 break;
      case LGE_OP: {
 Ordertype r = term_compare_basic(((t)->args[0]),((t)->args[1]));
 result = bool_to_term(r == GREATER_THAN || r == SAME_AS);
 break;
      }
      case VAR_OP:
 result = bool_to_term(((((t)->args[0]))->private_symbol >= 0));
 break;
      case CONST_OP:
 result = bool_to_term(((((t)->args[0]))->private_symbol < 0 && (((t)->args[0]))->arity == 0));
 break;
      case GROUND_OP:
 result = bool_to_term(ground_term(((t)->args[0])));
 break;
      default:
 printf("bad opcode is %d\n", op_code);
 fatal_error("dollar_eval: bad opcode");
      }
      return result;
    }
  }
}

canonical_original_code:
struct term *dollar_eval(struct term *t)
{
  if ((-((t)->private_symbol)) < 0 || (-((t)->private_symbol)) >= Symbols_size)
    return ((void *)0);
  else {
    int op_code = Op_codes[(-((t)->private_symbol))];
    if (op_code == 0)
      return ((void *)0);
    else {
      int i0; int i1;
      enum BOOL b0; enum BOOL b1;
      struct term *result = ((void *)0);
      switch (op_code) {
      case SUM_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 + i1);
 break;
      case PROD_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 * i1);
 break;
      case DIV_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 / i1);
 break;
      case MOD_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 % i1);
 break;
      case MIN_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 < i1 ? i0 : i1);
 break;
      case MAX_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = int_to_term(i0 > i1 ? i1 : i1);
 break;
      case ABS_OP:
 if (term_to_int(((t)->args[0]), &i0))
   result = int_to_term(i0 >= 0 ? i0 : -i0);
 break;
      case NEG_OP:
 if (term_to_int(((t)->args[0]), &i0))
   result = int_to_term(-i0);
 else if (term_to_bool(((t)->args[0]), &b0))
   result = bool_to_term(!b0);
 break;
      case LT_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 < i1);
 break;
      case LE_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 <= i1);
 break;
      case GT_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 > i1);
 break;
      case GE_OP:
 if (term_to_int(((t)->args[0]), &i0) && term_to_int(((t)->args[1]), &i1))
   result = bool_to_term(i0 >= i1);
 break;
      case AND_OP:
      case AND2_OP:
 if (term_to_bool(((t)->args[0]), &b0)) {
   if (b0)
     result = copy_term(((t)->args[1]));
   else
     result = bool_to_term(FALSE);
 }
 else if (term_to_bool(((t)->args[1]), &b1)) {
   if (b1)
     result = copy_term(((t)->args[0]));
   else
     result = bool_to_term(FALSE);
 }
 break;
      case OR_OP:
      case OR2_OP:
 if (term_to_bool(((t)->args[0]), &b0)) {
   if (b0)
     result = bool_to_term(TRUE);
   else
     result = copy_term(((t)->args[1]));
 }
 else if (term_to_bool(((t)->args[1]), &b1)) {
   if (b1)
     result = bool_to_term(TRUE);
   else
     result = copy_term(((t)->args[0]));
 }
 break;
      case ID_OP:
 result = bool_to_term(term_ident(((t)->args[0]), ((t)->args[1])));
 break;
      case NID_OP:
 result = bool_to_term(!term_ident(((t)->args[0]), ((t)->args[1])));
 break;
      case LLT_OP:
 result = bool_to_term(term_compare_basic(((t)->args[0]),((t)->args[1])) == LESS_THAN);
 break;
      case LLE_OP: {
 enum Ordertype r = term_compare_basic(((t)->args[0]),((t)->args[1]));
 result = bool_to_term(r == LESS_THAN || r == SAME_AS);
 break;
      }
      case LGT_OP:
 result = bool_to_term(term_compare_basic(((t)->args[0]),((t)->args[1])) == GREATER_THAN);
 break;
      case LGE_OP: {
 enum Ordertype r = term_compare_basic(((t)->args[0]),((t)->args[1]));
 result = bool_to_term(r == GREATER_THAN || r == SAME_AS);
 break;
      }
      case VAR_OP:
 result = bool_to_term(((((t)->args[0]))->private_symbol >= 0));
 break;
      case CONST_OP:
 result = bool_to_term(((((t)->args[0]))->private_symbol < 0 && (((t)->args[0]))->arity == 0));
 break;
      case GROUND_OP:
 result = bool_to_term(ground_term(((t)->args[0])));
 break;
      default:
 printf("bad opcode is %d\n", op_code);
 fatal_error("dollar_eval: bad opcode");
      }
      return result;
    }
  }
}

variable_types:
t
struct term *

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