decompiled_code:
void __fastcall ibuf_rewind(__int64 a1)
{
*(_DWORD *)(a1 + 4) = 0;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
*(_DWORD *)(a1 + 4) = 0;
}

original_code:
void ibuf_rewind(Ibuffer ibuf)
{
  ibuf->read_position = 0;
}

canonical_original_code:
void ibuf_rewind(struct ibuffer *ibuf)
{
  ibuf->read_position = 0;
}


repo: jessealama/ladr

original_code:
int ibuf_read(Ibuffer ibuf)
{
  if (ibuf->read_position >= ibuf->write_position)
    return (-0x7fffffff - 1);
  else {
    int i = ibuf->buf[ibuf->read_position];
    ibuf->read_position++;
    return i;
  }
}

canonical_original_code:
int ibuf_read(struct ibuffer *ibuf)
{
  if (ibuf->read_position >= ibuf->write_position)
    return (-0x7fffffff - 1);
  else {
    int i = ibuf->buf[ibuf->read_position];
    ibuf->read_position++;
    return i;
  }
}

variable_types: struct ibuffer { int write_position; int read_position; int size; int *buf; } *

variable_types: i int

return_type: int


decompiled_code:
__int64 __fastcall ibuf_xread(__int64 a1)
{
int v1; // eax
unsigned int v2; // er8

v1 = *(_DWORD *)(a1 + 4);
if ( v1 >= *(_DWORD *)a1 )
{
fatal_error("ibuf_xread: end of buffer");
v1 = *(_DWORD *)(a1 + 4);
}
v2 = *(_DWORD *)(*(_QWORD *)(a1 + 16) + 4LL * v1);
*(_DWORD *)(a1 + 4) = v1 + 1;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int v1; // eax
unsigned int v2; // er8

v1 = *(_DWORD *)(a1 + 4);
if ( v1 >= *(_DWORD *)a1 )
{
fatal_error("ibuf_xread: end of buffer");
v1 = *(_DWORD *)(a1 + 4);
}
v2 = *(_DWORD *)(*(_QWORD *)(a1 + 16) + 4LL * v1);
*(_DWORD *)(a1 + 4) = v1 + 1;
return v2;
}

original_code:
int ibuf_xread(Ibuffer ibuf)
{
  int i;
  if (ibuf->read_position >= ibuf->write_position)
    fatal_error("ibuf_xread: end of buffer");
  i = ibuf->buf[ibuf->read_position];
  ibuf->read_position++;
  return i;
}

canonical_original_code:
int ibuf_xread(struct ibuffer *ibuf)
{
  int i;
  if (ibuf->read_position >= ibuf->write_position)
    fatal_error("ibuf_xread: end of buffer");
  i = ibuf->buf[ibuf->read_position];
  ibuf->read_position++;
  return i;
}

user_defined_types: struct ibuffer { int write_position; int read_position; int size; int *buf; }


decompiled_code:
__int64 __fastcall ibuf_length(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int *a1)
{
return *a1;
}

original_code:
int ibuf_length(Ibuffer ibuf)
{
  return ibuf->write_position;
}

canonical_original_code:
int ibuf_length(struct ibuffer *ibuf)
{
  return ibuf->write_position;
}


decompiled_code:
__int64 __fastcall ibuf_buffer(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
int *ibuf_buffer(Ibuffer ibuf)
{
  return ibuf->buf;
}

canonical_original_code:
int *ibuf_buffer(struct ibuffer *ibuf)
{
  return ibuf->buf;
}

return_type: int *


decompiled_code:
int __fastcall p_ibuf(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // rsi
unsigned int v3; // eax

v1 = ibuf_read(a1);
if ( v1 != 0x80000000 )
{
v2 = v1;
do
{
printf("%d ", v2);
v3 = ibuf_read(a1);
v2 = v3;
}
while ( v3 != 0x80000000 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // rsi
unsigned int v3; // eax

v1 = func5(a1);
if ( v1 != 0x80000000 )
{
v2 = v1;
do
{
printf("%d ", v2);
v3 = func5(a1);
v2 = v3;
}
while ( v3 != 0x80000000 );
}
return putchar(10);
}

original_code:
void p_ibuf(Ibuffer ibuf)
{
  int i = ibuf_read(ibuf);
  while (i != (-0x7fffffff - 1)) {
    printf("%d ", i);
    i = ibuf_read(ibuf);
  }
  printf("\n");
}

canonical_original_code:
void p_ibuf(struct ibuffer *ibuf)
{
  int i = ibuf_read(ibuf);
  while (i != (-0x7fffffff - 1)) {
    printf("%d ", i);
    i = ibuf_read(ibuf);
  }
  printf("\n");
}

return_type: void


decompiled_code:
__int64 __fastcall can_compare(int *a1, int *a2, int a3)
{
int v3; // eax
int v4; // ecx
__int64 result; // rax

if ( *a1 >= 0 || *a2 >= 0 )
return term_compare_vcp();
v3 = -*a1;
v4 = -*a2;
if ( v3 == a3 )
{
if ( v3 == v4 )
return term_compare_vcp();
result = 3LL;
}
else
{
if ( a3 != v4 )
return term_compare_vcp();
result = 2LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, int *a2, int a3)
{
int v3; // eax
int v4; // ecx
__int64 result; // rax

if ( *a1 >= 0 || *a2 >= 0 )
return term_compare_vcp();
v3 = -*a1;
v4 = -*a2;
if ( v3 == a3 )
{
if ( v3 == v4 )
return term_compare_vcp();
result = 3LL;
}
else
{
if ( a3 != v4 )
return term_compare_vcp();
result = 2LL;
}
return result;
}

original_code:
static
Ordertype can_compare(Term a, Term b, int sn)
{
  if (((a)->private_symbol >= 0) || ((b)->private_symbol >= 0))
    return term_compare_vcp(a, b);
  else if ((-((a)->private_symbol)) == sn && (-((b)->private_symbol)) == sn)
    return term_compare_vcp(a, b);
  else if ((-((a)->private_symbol)) == sn)
    return GREATER_THAN;
  else if ((-((b)->private_symbol)) == sn)
    return LESS_THAN;
  else
    return term_compare_vcp(a, b);
}

canonical_original_code:
static enum Ordertype can_compare(struct term *a, struct term *b, int sn)
{
  if (((a)->private_symbol >= 0) || ((b)->private_symbol >= 0))
    return term_compare_vcp(a, b);
  else if ((-((a)->private_symbol)) == sn && (-((b)->private_symbol)) == sn)
    return term_compare_vcp(a, b);
  else if ((-((a)->private_symbol)) == sn)
    return GREATER_THAN;
  else if ((-((b)->private_symbol)) == sn)
    return LESS_THAN;
  else
    return term_compare_vcp(a, b);
}

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:
b
struct term *

variable_types: sn int

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


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

if ( *a1 < 0 && *a2 < 0 )
result = *a1 == *a2;
else
result = term_ident();
return result;
}

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

if ( *a1 < 0 && *a2 < 0 )
result = *a1 == *a2;
else
result = term_ident();
return result;
}

original_code:
BOOL same_top(Term t1, Term t2)
{
  if (((t1)->private_symbol >= 0) || ((t2)->private_symbol >= 0))
    return term_ident(t1, t2);
  else
    return (-((t1)->private_symbol)) == (-((t2)->private_symbol));
}

canonical_original_code:
enum BOOL same_top(struct term *t1, struct term *t2)
{
  if (((t1)->private_symbol >= 0) || ((t2)->private_symbol >= 0))
    return term_ident(t1, t2);
  else
    return (-((t1)->private_symbol)) == (-((t2)->private_symbol));
}

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

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


canon

original_code:
static
Term canon(Term t, int flag)
{
  if (term_flag(t, flag))
    return t;
  else if (((t)->private_symbol >= 0))
    return t;
  else {
    int sn = (-((t)->private_symbol));
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = canon(((t)->args[i]), flag);
    if (ilist_member(AC_symbols, sn)) {
      Term a = ((t)->args[0]);
      Term b = ((t)->args[1]);
      if (same_top(t, b) && can_compare(a, ((b)->args[0]), sn) == GREATER_THAN) {
 Term b0 = ((b)->args[0]);
 ((t)->args[0]) = b0;
 ((b)->args[0]) = a;
 term_flag_clear(b, flag);
 ((t)->args[1]) = canon(b, flag);
 t = canon(t, flag);
      }
      else if (can_compare(a, b, sn) == GREATER_THAN) {
 ((t)->args[0]) = b;
 ((t)->args[1]) = a;
 t = canon(t, flag);
      }
    }
    else if (ilist_member(C_symbols, sn)) {
      Term a = ((t)->args[0]);
      Term b = ((t)->args[1]);
      if (can_compare(a, b, sn) == GREATER_THAN) {
 ((t)->args[0]) = b;
 ((t)->args[1]) = a;
      }
    }
    term_flag_set(t, flag);
    return t;
  }
}

canonical_original_code:
static struct term *canon(struct term *t, int flag)
{
  if (term_flag(t, flag))
    return t;
  else if (((t)->private_symbol >= 0))
    return t;
  else {
    int sn = (-((t)->private_symbol));
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = canon(((t)->args[i]), flag);
    if (ilist_member(AC_symbols, sn)) {
      struct term *a = ((t)->args[0]);
      struct term *b = ((t)->args[1]);
      if (same_top(t, b) && can_compare(a, ((b)->args[0]), sn) == GREATER_THAN) {
 struct term *b0 = ((b)->args[0]);
 ((t)->args[0]) = b0;
 ((b)->args[0]) = a;
 term_flag_clear(b, flag);
 ((t)->args[1]) = canon(b, flag);
 t = canon(t, flag);
      }
      else if (can_compare(a, b, sn) == GREATER_THAN) {
 ((t)->args[0]) = b;
 ((t)->args[1]) = a;
 t = canon(t, flag);
      }
    }
    else if (ilist_member(C_symbols, sn)) {
      struct term *a = ((t)->args[0]);
      struct term *b = ((t)->args[1]);
      if (can_compare(a, b, sn) == GREATER_THAN) {
 ((t)->args[0]) = b;
 ((t)->args[1]) = a;
      }
    }
    term_flag_set(t, flag);
    return t;
  }
}

variable_types:
t
struct term *

variable_types: flag int

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


commutativity

decompiled_code:
__int64 __fastcall commutativity(__int64 a1)
{
int **v1; // rax
int *v2; // rbx
__int64 result; // rax
int *v4; // rbp
int **v5; // rdx
int v6; // eax
int *v7; // r12
__int64 *v8; // rax
__int64 v9; // rbp

if ( !(unsigned int)eq_term() )
goto LABEL_3;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
goto LABEL_3;
v4 = v1[1];
if ( (unsigned int)same_top(*v1, v4)
&& (v5 = (int **)*((_QWORD *)v2 + 1), v6 = **v5, v6 >= 0)
&& (v7 = v5[1], v6 != *v7)
&& *v7 >= 0
&& (v8 = (__int64 *)*((_QWORD *)v4 + 1), v9 = *v8, (unsigned int)term_ident(*v5, v8[1]))
&& (unsigned int)term_ident(v7, v9) )
{
result = (unsigned int)-*v2;
}
else
{
LABEL_3:
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int **v1; // rax
int *v2; // rbx
__int64 result; // rax
int *v4; // rbp
int **v5; // rdx
int v6; // eax
int *v7; // r12
__int64 *v8; // rax
__int64 v9; // rbp

if ( !(unsigned int)eq_term() )
goto LABEL_3;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
goto LABEL_3;
v4 = v1[1];
if ( (unsigned int)func1(*v1, v4)
&& (v5 = (int **)*((_QWORD *)v2 + 1), v6 = **v5, v6 >= 0)
&& (v7 = v5[1], v6 != *v7)
&& *v7 >= 0
&& (v8 = (__int64 *)*((_QWORD *)v4 + 1), v9 = *v8, (unsigned int)term_ident(*v5, v8[1]))
&& (unsigned int)term_ident(v7, v9) )
{
result = (unsigned int)-*v2;
}
else
{
LABEL_3:
result = 0LL;
}
return result;
}

original_code:
int commutativity(Term atom)
{
  if (eq_term(atom)) {
    Term alpha = ((atom)->args[0]);
    Term beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 && same_top(alpha, beta)) {
      Term a = ((alpha)->args[0]);
      Term b = ((alpha)->args[1]);
      Term c = ((beta)->args[0]);
      Term d = ((beta)->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   term_ident(a,d) && term_ident(b,c))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}

canonical_original_code:
int commutativity(struct term *atom)
{
  if (eq_term(atom)) {
    struct term *alpha = ((atom)->args[0]);
    struct term *beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 && same_top(alpha, beta)) {
      struct term *a = ((alpha)->args[0]);
      struct term *b = ((alpha)->args[1]);
      struct term *c = ((beta)->args[0]);
      struct term *d = ((beta)->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   term_ident(a,d) && term_ident(b,c))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}


associativity

decompiled_code:
__int64 __fastcall associativity(__int64 a1)
{
int **v1; // rax
int *v2; // rbx
__int64 result; // rax
int *v4; // rbp
_QWORD *v5; // rcx
int **v6; // rax
int *v7; // rdi
int v8; // edx
int *v9; // r13
_DWORD *v10; // r12
_QWORD *v11; // rax
__int64 *v12; // rdx
__int64 v13; // r14
__int64 v14; // rbp

if ( !(unsigned int)eq_term() )
goto LABEL_3;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
goto LABEL_3;
v4 = v1[1];
if ( !(unsigned int)same_top(*v1, v4) )
goto LABEL_3;
if ( !(unsigned int)same_top(v2, **((int ***)v2 + 1)) )
goto LABEL_3;
if ( !(unsigned int)same_top(v2, *(int **)(*((_QWORD *)v4 + 1) + 8LL)) )
goto LABEL_3;
v5 = (_QWORD *)*((_QWORD *)v2 + 1);
v6 = *(int ***)(*v5 + 8LL);
v7 = *v6;
v8 = **v6;
if ( v8 < 0 )
goto LABEL_3;
v9 = v6[1];
if ( *v9 >= 0
&& (v10 = (_DWORD *)v5[1], *v10 >= 0 && v8 != *v9 && *v9 != *v10)
&& v8 != *v10
&& (v11 = (_QWORD *)*((_QWORD *)v4 + 1),
v12 = *(__int64 **)(v11[1] + 8LL),
v13 = *v12,
v14 = v12[1],
(unsigned int)term_ident(v7, *v11))
&& (unsigned int)term_ident(v9, v13)
&& (unsigned int)term_ident(v10, v14) )
{
result = (unsigned int)-*v2;
}
else
{
LABEL_3:
result = 0LL;
}
return result;
}

original_code:
int associativity(Term atom)
{
  if (eq_term(atom)) {
    Term alpha = ((atom)->args[0]);
    Term beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[0])) &&
 same_top(alpha, ((beta)->args[1]))) {
      Term a = ((((alpha)->args[0]))->args[0]);
      Term b = ((((alpha)->args[0]))->args[1]);
      Term c = ((alpha)->args[1]);
      Term d = ((beta)->args[0]);
      Term e = ((((beta)->args[1]))->args[0]);
      Term f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   term_ident(a,d) && term_ident(b,e) && term_ident(c,f))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}

canonical_original_code:
int associativity(struct term *atom)
{
  if (eq_term(atom)) {
    struct term *alpha = ((atom)->args[0]);
    struct term *beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[0])) &&
 same_top(alpha, ((beta)->args[1]))) {
      struct term *a = ((((alpha)->args[0]))->args[0]);
      struct term *b = ((((alpha)->args[0]))->args[1]);
      struct term *c = ((alpha)->args[1]);
      struct term *d = ((beta)->args[0]);
      struct term *e = ((((beta)->args[1]))->args[0]);
      struct term *f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   term_ident(a,d) && term_ident(b,e) && term_ident(c,f))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}


decompiled_code:
__int64 __fastcall c_associativity(__int64 a1)
{
int **v1; // rax
int *v2; // rbx
__int64 result; // rax
int *v4; // rbp
__int64 v5; // rax
int *v6; // rdi
int v7; // edx
__int64 v8; // rcx
int *v9; // r13
int v10; // eax
_DWORD *v11; // r12
__int64 *v12; // rax
__int64 v13; // r14
_QWORD *v14; // rax
__int64 v15; // rbp

if ( !(unsigned int)eq_term() )
goto LABEL_3;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
goto LABEL_3;
v4 = v1[1];
if ( !(unsigned int)same_top(*v1, v4) )
goto LABEL_3;
if ( !(unsigned int)same_top(v2, *(int **)(*((_QWORD *)v2 + 1) + 8LL)) )
goto LABEL_3;
if ( !(unsigned int)same_top(v2, *(int **)(*((_QWORD *)v4 + 1) + 8LL)) )
goto LABEL_3;
v5 = *((_QWORD *)v2 + 1);
v6 = *(int **)v5;
v7 = **(_DWORD **)v5;
if ( v7 < 0 )
goto LABEL_3;
v8 = *(_QWORD *)(*(_QWORD *)(v5 + 8) + 8LL);
v9 = *(int **)v8;
v10 = **(_DWORD **)v8;
if ( v10 < 0 )
goto LABEL_3;
v11 = *(_DWORD **)(v8 + 8);
if ( v10 != *v11
&& *v11 >= 0
&& v7 != v10
&& v7 != *v11
&& (v12 = (__int64 *)*((_QWORD *)v4 + 1),
v13 = *v12,
v14 = *(_QWORD **)(v12[1] + 8),
v15 = v14[1],
(unsigned int)term_ident(v6, *v14))
&& (unsigned int)term_ident(v9, v13)
&& (unsigned int)term_ident(v11, v15) )
{
result = (unsigned int)-*v2;
}
else
{
LABEL_3:
result = 0LL;
}
return result;
}

original_code:
int c_associativity(Term atom)
{
  if (eq_term(atom)) {
    Term alpha = ((atom)->args[0]);
    Term beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[1])) &&
 same_top(alpha, ((beta)->args[1]))) {
      Term a = ((alpha)->args[0]);
      Term b = ((((alpha)->args[1]))->args[0]);
      Term c = ((((alpha)->args[1]))->args[1]);
      Term d = ((beta)->args[0]);
      Term e = ((((beta)->args[1]))->args[0]);
      Term f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   term_ident(a,e) && term_ident(b,d) && term_ident(c,f))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}

canonical_original_code:
int c_associativity(struct term *atom)
{
  if (eq_term(atom)) {
    struct term *alpha = ((atom)->args[0]);
    struct term *beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[1])) &&
 same_top(alpha, ((beta)->args[1]))) {
      struct term *a = ((alpha)->args[0]);
      struct term *b = ((((alpha)->args[1]))->args[0]);
      struct term *c = ((((alpha)->args[1]))->args[1]);
      struct term *d = ((beta)->args[0]);
      struct term *e = ((((beta)->args[1]))->args[0]);
      struct term *f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   term_ident(a,e) && term_ident(b,d) && term_ident(c,f))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}


decompiled_code:
__int64 __fastcall cac_redundant_atom(__int64 a1)
{
int **v1; // rax
int v2; // edx
int v3; // eax
int v5; // ebp
unsigned int v6; // ebp
__int64 v7; // r12
__int64 v8; // r13
__int64 v9; // r12
__int64 v10; // r13
unsigned int v11; // [rsp+Ch] [rbp-2Ch]

if ( !(unsigned int)eq_term() )
return 0LL;
v1 = *(int ***)(a1 + 8);
v2 = **v1;
if ( v2 >= 0 )
return 0LL;
v3 = *v1[1];
if ( v3 >= 0 )
return 0LL;
if ( v2 != v3 )
return 0LL;
v5 = ((__int64 (*)(void))symbol_count)();
if ( v5 != (unsigned int)symbol_count(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL))
|| (unsigned int)commutativity(a1)
|| (unsigned int)associativity(a1)
|| (unsigned int)c_associativity(a1) )
{
return 0LL;
}
v6 = claim_term_flag();
v7 = copy_term(**(_QWORD **)(a1 + 8));
v8 = copy_term(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
v9 = canon(v7, v6);
v10 = canon(v8, v6);
v11 = term_ident(v9, v10);
zap_term(v9);
zap_term(v10);
release_term_flag(v6);
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int **v1; // rax
int v2; // edx
int v3; // eax
int v5; // ebp
unsigned int v6; // ebp
__int64 v7; // r12
__int64 v8; // r13
__int64 v9; // r12
__int64 v10; // r13
unsigned int v11; // [rsp+Ch] [rbp-2Ch]

if ( !(unsigned int)eq_term() )
return 0LL;
v1 = *(int ***)(a1 + 8);
v2 = **v1;
if ( v2 >= 0 )
return 0LL;
v3 = *v1[1];
if ( v3 >= 0 )
return 0LL;
if ( v2 != v3 )
return 0LL;
v5 = ((__int64 (*)(void))symbol_count)();
if ( v5 != (unsigned int)symbol_count(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL))
|| (unsigned int)func3(a1)
|| (unsigned int)func4(a1)
|| (unsigned int)func5(a1) )
{
return 0LL;
}
v6 = claim_term_flag();
v7 = copy_term(**(_QWORD **)(a1 + 8));
v8 = copy_term(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
v9 = func2(v7, v6);
v10 = func2(v8, v6);
v11 = term_ident(v9, v10);
zap_term(v9);
zap_term(v10);
release_term_flag(v6);
return v11;
}

original_code:
static
BOOL cac_redundant_atom(Term atom)
{
  if (!eq_term(atom))
    return FALSE;
  else if (((((atom)->args[0]))->private_symbol >= 0) || ((((atom)->args[1]))->private_symbol >= 0))
    return FALSE;
  else if ((-((((atom)->args[0]))->private_symbol)) != (-((((atom)->args[1]))->private_symbol)))
    return FALSE;
  else if (symbol_count(((atom)->args[0])) != symbol_count(((atom)->args[1])))
    return FALSE;
  else if (commutativity(atom))
    return FALSE;
  else if (associativity(atom))
    return FALSE;
  else if (c_associativity(atom))
    return FALSE;
  else {
    int flag = claim_term_flag();
    BOOL cac_redund;
    Term a = copy_term(((atom)->args[0]));
    Term b = copy_term(((atom)->args[1]));
    a = canon(a, flag);
    b = canon(b, flag);
    cac_redund = term_ident(a,b);
    zap_term(a);
    zap_term(b);
    release_term_flag(flag);
    return cac_redund;
  }
}

canonical_original_code:
static enum BOOL cac_redundant_atom(struct term *atom)
{
  if (!eq_term(atom))
    return FALSE;
  else if (((((atom)->args[0]))->private_symbol >= 0) || ((((atom)->args[1]))->private_symbol >= 0))
    return FALSE;
  else if ((-((((atom)->args[0]))->private_symbol)) != (-((((atom)->args[1]))->private_symbol)))
    return FALSE;
  else if (symbol_count(((atom)->args[0])) != symbol_count(((atom)->args[1])))
    return FALSE;
  else if (commutativity(atom))
    return FALSE;
  else if (associativity(atom))
    return FALSE;
  else if (c_associativity(atom))
    return FALSE;
  else {
    int flag = claim_term_flag();
    enum BOOL cac_redund;
    struct term *a = copy_term(((atom)->args[0]));
    struct term *b = copy_term(((atom)->args[1]));
    a = canon(a, flag);
    b = canon(b, flag);
    cac_redund = term_ident(a,b);
    zap_term(a);
    zap_term(b);
    release_term_flag(flag);
    return cac_redund;
  }
}


decompiled_code:
__int64 __fastcall associativity3(__int64 a1)
{
int **v1; // rax
int *v2; // r14
int *v4; // r12
_QWORD *v5; // rsi
int **v6; // rax
int *v7; // r15
int v8; // ecx
int *v9; // rbx
_DWORD *v10; // rbp
__int64 *v11; // rax
__int64 v12; // r12
__int64 *v13; // rax
__int64 v14; // r13
_BOOL4 v15; // eax
__int64 v16; // [rsp+0h] [rbp-48h]
_BOOL4 v17; // [rsp+Ch] [rbp-3Ch]
int v18; // [rsp+Ch] [rbp-3Ch]

if ( !(unsigned int)eq_term() )
return 0LL;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
return 0LL;
v4 = v1[1];
if ( !(unsigned int)same_top(*v1, v4) )
return 0LL;
if ( !(unsigned int)same_top(v2, **((int ***)v2 + 1)) )
return 0LL;
if ( !(unsigned int)same_top(v2, *(int **)(*((_QWORD *)v4 + 1) + 8LL)) )
return 0LL;
v5 = (_QWORD *)*((_QWORD *)v2 + 1);
v6 = *(int ***)(*v5 + 8LL);
v7 = *v6;
v8 = **v6;
if ( v8 < 0 )
return 0LL;
v9 = v6[1];
if ( *v9 < 0 )
return 0LL;
v10 = (_DWORD *)v5[1];
if ( *v10 < 0 || v8 == *v9 || *v9 == *v10 || v8 == *v10 )
return 0LL;
v11 = (__int64 *)*((_QWORD *)v4 + 1);
v12 = *v11;
v13 = *(__int64 **)(v11[1] + 8);
v14 = v13[1];
v16 = *v13;
if ( (unsigned int)term_ident(v7, v12) && (unsigned int)term_ident(v9, v16) )
v17 = term_ident(v10, v14) != 0;
else
v17 = 0;
if ( (unsigned int)term_ident(v7, v12) && (unsigned int)term_ident(v9, v14) )
v15 = term_ident(v10, v16) != 0;
else
v15 = 0;
v18 = v17 || v15;
if ( (unsigned int)term_ident(v7, v16) && (unsigned int)term_ident(v9, v12) && (unsigned int)term_ident(v10, v14) )
{
if ( !(unsigned int)term_ident(v7, v14) || !(unsigned int)term_ident(v9, v12) )
return (unsigned int)-*v2;
v18 = 1;
}
else if ( !(unsigned int)term_ident(v7, v14) || !(unsigned int)term_ident(v9, v12) )
{
goto LABEL_17;
}
if ( (unsigned int)term_ident(v10, v16) )
return (unsigned int)-*v2;
LABEL_17:
if ( !v18 )
return 0LL;
return (unsigned int)-*v2;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
int **v1; // rax
int *v2; // r14
int *v4; // r12
_QWORD *v5; // rsi
int **v6; // rax
int *v7; // r15
int v8; // ecx
int *v9; // rbx
_DWORD *v10; // rbp
__int64 *v11; // rax
__int64 v12; // r12
__int64 *v13; // rax
__int64 v14; // r13
_BOOL4 v15; // eax
__int64 v16; // [rsp+0h] [rbp-48h]
_BOOL4 v17; // [rsp+Ch] [rbp-3Ch]
int v18; // [rsp+Ch] [rbp-3Ch]

if ( !(unsigned int)eq_term() )
return 0LL;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
return 0LL;
v4 = v1[1];
if ( !(unsigned int)func1(*v1, v4) )
return 0LL;
if ( !(unsigned int)func1(v2, **((int ***)v2 + 1)) )
return 0LL;
if ( !(unsigned int)func1(v2, *(int **)(*((_QWORD *)v4 + 1) + 8LL)) )
return 0LL;
v5 = (_QWORD *)*((_QWORD *)v2 + 1);
v6 = *(int ***)(*v5 + 8LL);
v7 = *v6;
v8 = **v6;
if ( v8 < 0 )
return 0LL;
v9 = v6[1];
if ( *v9 < 0 )
return 0LL;
v10 = (_DWORD *)v5[1];
if ( *v10 < 0 || v8 == *v9 || *v9 == *v10 || v8 == *v10 )
return 0LL;
v11 = (__int64 *)*((_QWORD *)v4 + 1);
v12 = *v11;
v13 = *(__int64 **)(v11[1] + 8);
v14 = v13[1];
v16 = *v13;
if ( (unsigned int)term_ident(v7, v12) && (unsigned int)term_ident(v9, v16) )
v17 = term_ident(v10, v14) != 0;
else
v17 = 0;
if ( (unsigned int)term_ident(v7, v12) && (unsigned int)term_ident(v9, v14) )
v15 = term_ident(v10, v16) != 0;
else
v15 = 0;
v18 = v17 || v15;
if ( (unsigned int)term_ident(v7, v16) && (unsigned int)term_ident(v9, v12) && (unsigned int)term_ident(v10, v14) )
{
if ( !(unsigned int)term_ident(v7, v14) || !(unsigned int)term_ident(v9, v12) )
return (unsigned int)-*v2;
v18 = 1;
}
else if ( !(unsigned int)term_ident(v7, v14) || !(unsigned int)term_ident(v9, v12) )
{
goto LABEL_17;
}
if ( (unsigned int)term_ident(v10, v16) )
return (unsigned int)-*v2;
LABEL_17:
if ( !v18 )
return 0LL;
return (unsigned int)-*v2;
}

original_code:
int associativity3(Term atom)
{
  if (eq_term(atom)) {
    Term alpha = ((atom)->args[0]);
    Term beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[0])) &&
 same_top(alpha, ((beta)->args[1]))) {
      Term a = ((((alpha)->args[0]))->args[0]);
      Term b = ((((alpha)->args[0]))->args[1]);
      Term c = ((alpha)->args[1]);
      Term d = ((beta)->args[0]);
      Term e = ((((beta)->args[1]))->args[0]);
      Term f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   ((term_ident(a,d) && term_ident(b,e) && term_ident(c,f)) |
    (term_ident(a,d) && term_ident(b,f) && term_ident(c,e)) |
    (term_ident(a,e) && term_ident(b,d) && term_ident(c,f)) |
    (term_ident(a,f) && term_ident(b,d) && term_ident(c,e))
    )
   )
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}

canonical_original_code:
int associativity3(struct term *atom)
{
  if (eq_term(atom)) {
    struct term *alpha = ((atom)->args[0]);
    struct term *beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[0])) &&
 same_top(alpha, ((beta)->args[1]))) {
      struct term *a = ((((alpha)->args[0]))->args[0]);
      struct term *b = ((((alpha)->args[0]))->args[1]);
      struct term *c = ((alpha)->args[1]);
      struct term *d = ((beta)->args[0]);
      struct term *e = ((((beta)->args[1]))->args[0]);
      struct term *f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   ((term_ident(a,d) && term_ident(b,e) && term_ident(c,f)) |
    (term_ident(a,d) && term_ident(b,f) && term_ident(c,e)) |
    (term_ident(a,e) && term_ident(b,d) && term_ident(c,f)) |
    (term_ident(a,f) && term_ident(b,d) && term_ident(c,e))
    )
   )
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}


decompiled_code:
__int64 __fastcall associativity4(__int64 a1)
{
int **v1; // rax
int *v2; // r14
int *v4; // rbx
__int64 v5; // rax
int *v6; // rbp
int v7; // ecx
__int64 v8; // rsi
int *v9; // r12
int v10; // eax
_DWORD *v11; // r13
__int64 *v12; // rax
__int64 v13; // r15
__int64 *v14; // rax
__int64 v15; // rbx
_BOOL4 v16; // eax
__int64 v17; // [rsp+0h] [rbp-48h]
_BOOL4 v18; // [rsp+Ch] [rbp-3Ch]
int v19; // [rsp+Ch] [rbp-3Ch]

if ( !(unsigned int)eq_term() )
return 0LL;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
return 0LL;
v4 = v1[1];
if ( !(unsigned int)same_top(*v1, v4) )
return 0LL;
if ( !(unsigned int)same_top(v2, *(int **)(*((_QWORD *)v2 + 1) + 8LL)) )
return 0LL;
if ( !(unsigned int)same_top(v2, *(int **)(*((_QWORD *)v4 + 1) + 8LL)) )
return 0LL;
v5 = *((_QWORD *)v2 + 1);
v6 = *(int **)v5;
v7 = **(_DWORD **)v5;
if ( v7 < 0 )
return 0LL;
v8 = *(_QWORD *)(*(_QWORD *)(v5 + 8) + 8LL);
v9 = *(int **)v8;
v10 = **(_DWORD **)v8;
if ( v10 < 0 )
return 0LL;
v11 = *(_DWORD **)(v8 + 8);
if ( v10 == *v11 || *v11 < 0 || v7 == v10 || v7 == *v11 )
return 0LL;
v12 = (__int64 *)*((_QWORD *)v4 + 1);
v13 = *v12;
v14 = *(__int64 **)(v12[1] + 8);
v15 = *v14;
v17 = v14[1];
if ( (unsigned int)term_ident(v13, v9) && (unsigned int)term_ident(v15, v6) )
v18 = term_ident(v17, v11) != 0;
else
v18 = 0;
if ( (unsigned int)term_ident(v13, v9) && (unsigned int)term_ident(v15, v11) )
v16 = term_ident(v17, v6) != 0;
else
v16 = 0;
v19 = v18 || v16;
if ( (unsigned int)term_ident(v13, v11) && (unsigned int)term_ident(v15, v6) && (unsigned int)term_ident(v17, v9) )
{
if ( !(unsigned int)term_ident(v13, v11) || !(unsigned int)term_ident(v15, v9) )
return (unsigned int)-*v2;
v19 = 1;
}
else if ( !(unsigned int)term_ident(v13, v11) || !(unsigned int)term_ident(v15, v9) )
{
goto LABEL_17;
}
if ( (unsigned int)term_ident(v17, v6) )
return (unsigned int)-*v2;
LABEL_17:
if ( !v19 )
return 0LL;
return (unsigned int)-*v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
int **v1; // rax
int *v2; // r14
int *v4; // rbx
__int64 v5; // rax
int *v6; // rbp
int v7; // ecx
__int64 v8; // rsi
int *v9; // r12
int v10; // eax
_DWORD *v11; // r13
__int64 *v12; // rax
__int64 v13; // r15
__int64 *v14; // rax
__int64 v15; // rbx
_BOOL4 v16; // eax
__int64 v17; // [rsp+0h] [rbp-48h]
_BOOL4 v18; // [rsp+Ch] [rbp-3Ch]
int v19; // [rsp+Ch] [rbp-3Ch]

if ( !(unsigned int)eq_term() )
return 0LL;
v1 = *(int ***)(a1 + 8);
v2 = *v1;
if ( *((_BYTE *)*v1 + 4) != 2 )
return 0LL;
v4 = v1[1];
if ( !(unsigned int)func1(*v1, v4) )
return 0LL;
if ( !(unsigned int)func1(v2, *(int **)(*((_QWORD *)v2 + 1) + 8LL)) )
return 0LL;
if ( !(unsigned int)func1(v2, *(int **)(*((_QWORD *)v4 + 1) + 8LL)) )
return 0LL;
v5 = *((_QWORD *)v2 + 1);
v6 = *(int **)v5;
v7 = **(_DWORD **)v5;
if ( v7 < 0 )
return 0LL;
v8 = *(_QWORD *)(*(_QWORD *)(v5 + 8) + 8LL);
v9 = *(int **)v8;
v10 = **(_DWORD **)v8;
if ( v10 < 0 )
return 0LL;
v11 = *(_DWORD **)(v8 + 8);
if ( v10 == *v11 || *v11 < 0 || v7 == v10 || v7 == *v11 )
return 0LL;
v12 = (__int64 *)*((_QWORD *)v4 + 1);
v13 = *v12;
v14 = *(__int64 **)(v12[1] + 8);
v15 = *v14;
v17 = v14[1];
if ( (unsigned int)term_ident(v13, v9) && (unsigned int)term_ident(v15, v6) )
v18 = term_ident(v17, v11) != 0;
else
v18 = 0;
if ( (unsigned int)term_ident(v13, v9) && (unsigned int)term_ident(v15, v11) )
v16 = term_ident(v17, v6) != 0;
else
v16 = 0;
v19 = v18 || v16;
if ( (unsigned int)term_ident(v13, v11) && (unsigned int)term_ident(v15, v6) && (unsigned int)term_ident(v17, v9) )
{
if ( !(unsigned int)term_ident(v13, v11) || !(unsigned int)term_ident(v15, v9) )
return (unsigned int)-*v2;
v19 = 1;
}
else if ( !(unsigned int)term_ident(v13, v11) || !(unsigned int)term_ident(v15, v9) )
{
goto LABEL_17;
}
if ( (unsigned int)term_ident(v17, v6) )
return (unsigned int)-*v2;
LABEL_17:
if ( !v19 )
return 0LL;
return (unsigned int)-*v2;
}

original_code:
int associativity4(Term atom)
{
  if (eq_term(atom)) {
    Term alpha = ((atom)->args[0]);
    Term beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[1])) &&
 same_top(alpha, ((beta)->args[1]))) {
      Term a = ((alpha)->args[0]);
      Term b = ((((alpha)->args[1]))->args[0]);
      Term c = ((((alpha)->args[1]))->args[1]);
      Term d = ((beta)->args[0]);
      Term e = ((((beta)->args[1]))->args[0]);
      Term f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   ((term_ident(d,b) && term_ident(e,a) && term_ident(f,c)) |
    (term_ident(d,b) && term_ident(e,c) && term_ident(f,a)) |
    (term_ident(d,c) && term_ident(e,a) && term_ident(f,b)) |
    (term_ident(d,c) && term_ident(e,b) && term_ident(f,a))))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}

canonical_original_code:
int associativity4(struct term *atom)
{
  if (eq_term(atom)) {
    struct term *alpha = ((atom)->args[0]);
    struct term *beta = ((atom)->args[1]);
    if (((alpha)->arity) == 2 &&
 same_top(alpha, beta) &&
 same_top(alpha, ((alpha)->args[1])) &&
 same_top(alpha, ((beta)->args[1]))) {
      struct term *a = ((alpha)->args[0]);
      struct term *b = ((((alpha)->args[1]))->args[0]);
      struct term *c = ((((alpha)->args[1]))->args[1]);
      struct term *d = ((beta)->args[0]);
      struct term *e = ((((beta)->args[1]))->args[0]);
      struct term *f = ((((beta)->args[1]))->args[1]);
      if (((a)->private_symbol >= 0) && ((b)->private_symbol >= 0) && ((c)->private_symbol >= 0) &&
   ((a)->private_symbol) != ((b)->private_symbol) &&
   ((b)->private_symbol) != ((c)->private_symbol) &&
   ((a)->private_symbol) != ((c)->private_symbol) &&
   ((term_ident(d,b) && term_ident(e,a) && term_ident(f,c)) |
    (term_ident(d,b) && term_ident(e,c) && term_ident(f,a)) |
    (term_ident(d,c) && term_ident(e,a) && term_ident(f,b)) |
    (term_ident(d,c) && term_ident(e,b) && term_ident(f,a))))
 return (-((alpha)->private_symbol));
    }
  }
  return 0;
}


decompiled_code:
__int64 __fastcall cac_tautology(__int64 a1)
{
if ( !C_symbols )
return 0LL;
do
{
if ( !a1 )
break;
if ( *(_DWORD *)a1 && (unsigned int)cac_redundant_atom(*(_QWORD *)(a1 + 8)) )
return 1LL;
a1 = *(_QWORD *)(a1 + 16);
}
while ( C_symbols );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
if ( !C_symbols )
return 0LL;
do
{
if ( !a1 )
break;
if ( *(_DWORD *)a1 && (unsigned int)func6(*(_QWORD *)(a1 + 8)) )
return 1LL;
a1 = *(_QWORD *)(a1 + 16);
}
while ( C_symbols );
return 0LL;
}

original_code:
BOOL cac_tautology(Literals lits)
{
  if (C_symbols == ((void *)0))
    return FALSE;
  else if (lits == ((void *)0))
    return FALSE;
  else if (lits->sign && cac_redundant_atom(lits->atom))
    return TRUE;
  else
    return cac_tautology(lits->next);
}

canonical_original_code:
enum BOOL cac_tautology(struct literals *lits)
{
  if (C_symbols == ((void *)0))
    return FALSE;
  else if (lits == ((void *)0))
    return FALSE;
  else if (lits->sign && cac_redundant_atom(lits->atom))
    return TRUE;
  else
    return cac_tautology(lits->next);
}

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

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


decompiled_code:
__int64 __fastcall lex_rewritable(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v5; // rbp
unsigned int v6; // er12

v5 = apply(a3);
v6 = term_greater(a1, v5, a4);
zap_term(v5);
return v6;
}

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

v5 = apply(a3);
v6 = term_greater(a1, v5, a4);
zap_term(v5);
return v6;
}

original_code:
static
BOOL lex_rewritable(Term subject, Context subst, Term gen,
      BOOL lex_order_vars)
{
  Term instance = apply(gen, subst);
  BOOL result = term_greater(subject, instance, lex_order_vars);
  zap_term(instance);
  return result;
}

canonical_original_code:
static enum BOOL lex_rewritable(struct term *subject, struct context *subst, struct term *gen, enum BOOL lex_order_vars)
{
  struct term *instance = apply(gen, subst);
  enum BOOL result = term_greater(subject, instance, lex_order_vars);
  zap_term(instance);
  return result;
}

variable_types: struct context { struct term *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; } *

variable_types:
gen
struct term *

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


decompiled_code:
__int64 __fastcall claim_term_flag(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // r8

result = 0LL;
while ( 1 )
{
v5 = (unsigned int)bits_in_use[result];
v6 = (unsigned int)result;
if ( !(_DWORD)v5 )
break;
if ( ++result == 8 )
{
fatal_error("claim_term_flag, no more flags are available", a2, v5, a4, v6);
return 0xFFFFFFFFLL;
}
}
bits_in_use[(int)result] = 1;
return (unsigned int)result;
}

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

result = 0LL;
while ( 1 )
{
v5 = (unsigned int)bits_in_use[result];
v6 = (unsigned int)result;
if ( !(_DWORD)v5 )
break;
if ( ++result == 8 )
{
fatal_error("claim_term_flag, no more flags are available", a2, v5, a4, v6);
return 0xFFFFFFFFLL;
}
}
bits_in_use[(int)result] = 1;
return (unsigned int)result;
}

original_code:
int claim_term_flag()
{
  int i = 0;
  while (i < (sizeof(unsigned char) * 8) && bits_in_use[i])
    i++;
  if (i < (sizeof(unsigned char) * 8)) {
    bits_in_use[i] = 1;
    return i;
  }
  else {
    fatal_error("claim_term_flag, no more flags are available");
    return -1;
  }
}


decompiled_code:
void __fastcall release_term_flag(int a1)
{
bits_in_use[a1] = 0;
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
bits_in_use[a1] = 0;
}

original_code:
void release_term_flag(int bit)
{
  bits_in_use[bit] = 0;
}

variable_types: bit int


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

if ( a2 <= 7 )
{
result = (unsigned int)(1 << a2);
*(_BYTE *)(a1 + 5) |= result;
}
return result;
}

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

if ( a2 <= 7 )
{
result = (unsigned int)(1 << a2);
*(_BYTE *)(a1 + 5) |= result;
}
return result;
}

original_code:
void term_flag_set(Term t, int flag)
{
  if (flag >= 0 && flag < (sizeof(unsigned char) * 8))
    (t->private_flags = (t->private_flags) | (1 << flag));
}

canonical_original_code:
void term_flag_set(struct term *t, int flag)
{
  if (flag >= 0 && flag < (sizeof(unsigned char) * 8))
    (t->private_flags = (t->private_flags) | (1 << flag));
}


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

if ( a2 <= 7 )
{
result = (unsigned int)__ROL4__(-2, a2);
*(_BYTE *)(a1 + 5) &= result;
}
return result;
}

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

if ( a2 <= 7 )
{
result = (unsigned int)__ROL4__(-2, a2);
*(_BYTE *)(a1 + 5) &= result;
}
return result;
}

original_code:
void term_flag_clear(Term t, int flag)
{
  if (flag >= 0 && flag < (sizeof(unsigned char) * 8))
    (t->private_flags = (t->private_flags) & ~(1 << flag));
}

canonical_original_code:
void term_flag_clear(struct term *t, int flag)
{
  if (flag >= 0 && flag < (sizeof(unsigned char) * 8))
    (t->private_flags = (t->private_flags) & ~(1 << flag));
}


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

result = 0LL;
if ( a2 <= 7 )
result = ((int)*(unsigned __int8 *)(a1 + 5) >> a2) & 1;
return result;
}

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

result = 0LL;
if ( a2 <= 7 )
result = ((int)*(unsigned __int8 *)(a1 + 5) >> a2) & 1;
return result;
}

original_code:
BOOL term_flag(Term t, int flag)
{
  if (flag < 0 || flag >= (sizeof(unsigned char) * 8))
    return FALSE;
  else if ((t->private_flags & 1 << flag))
    return TRUE;
  else
    return FALSE;
}

canonical_original_code:
enum BOOL term_flag(struct term *t, int flag)
{
  if (flag < 0 || flag >= (sizeof(unsigned char) * 8))
    return FALSE;
  else if ((t->private_flags & 1 << flag))
    return TRUE;
  else
    return FALSE;
}


decompiled_code:
__int64 term_flags()
{
return 8LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 8LL;
}

original_code:
int term_flags()
{
  return (sizeof(unsigned char) * 8);
}


original_code:
Term copy_term_with_flags(Term t)
{
  Term t2;
  if (((t)->private_symbol >= 0))
    t2 = get_variable_term(((t)->private_symbol));
  else {
    int i;
    t2 = get_rigid_term_like(t);
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = copy_term_with_flags(((t)->args[i]));
  }
  t2->private_flags = t->private_flags;
  return t2;
}

canonical_original_code:
struct term *copy_term_with_flags(struct term *t)
{
  struct term *t2;
  if (((t)->private_symbol >= 0))
    t2 = get_variable_term(((t)->private_symbol));
  else {
    int i;
    t2 = get_rigid_term_like(t);
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = copy_term_with_flags(((t)->args[i]));
  }
  t2->private_flags = t->private_flags;
  return t2;
}


decompiled_code:
__int64 __fastcall copy_term_with_flag(__int64 a1, unsigned int a2)
{
__int64 v3; // r12
__int64 v5; // rbx
_QWORD *v6; // r14
__int64 v7; // rdi

if ( *(int *)a1 < 0 )
{
v3 = get_rigid_term_like(a1);
if ( *(_BYTE *)(a1 + 4) )
{
v5 = 0LL;
do
{
v6 = (_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * v5);
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v5++);
*v6 = copy_term_with_flag(v7, a2);
}
while ( *(unsigned __int8 *)(a1 + 4) > (int)v5 );
if ( !(unsigned int)term_flag(a1, a2) )
return v3;
goto LABEL_9;
}
}
else
{
v3 = get_variable_term();
}
if ( !(unsigned int)term_flag(a1, a2) )
return v3;
LABEL_9:
term_flag_set(v3, a2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2)
{
__int64 v3; // r12
__int64 v5; // rbx
_QWORD *v6; // r14
__int64 v7; // rdi

if ( *(int *)a1 < 0 )
{
v3 = get_rigid_term_like(a1);
if ( *(_BYTE *)(a1 + 4) )
{
v5 = 0LL;
do
{
v6 = (_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * v5);
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v5++);
*v6 = func7(v7, a2);
}
while ( *(unsigned __int8 *)(a1 + 4) > (int)v5 );
if ( !(unsigned int)func4(a1, a2) )
return v3;
goto LABEL_9;
}
}
else
{
v3 = get_variable_term();
}
if ( !(unsigned int)func4(a1, a2) )
return v3;
LABEL_9:
func2(v3, a2);
return v3;
}

original_code:
Term copy_term_with_flag(Term t, int flag)
{
  Term t2;
  if (((t)->private_symbol >= 0))
    t2 = get_variable_term(((t)->private_symbol));
  else {
    int i;
    t2 = get_rigid_term_like(t);
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = copy_term_with_flag(((t)->args[i]), flag);
  }
  if (term_flag(t, flag))
    term_flag_set(t2, flag);
  return t2;
}

canonical_original_code:
struct term *copy_term_with_flag(struct term *t, int flag)
{
  struct term *t2;
  if (((t)->private_symbol >= 0))
    t2 = get_variable_term(((t)->private_symbol));
  else {
    int i;
    t2 = get_rigid_term_like(t);
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = copy_term_with_flag(((t)->args[i]), flag);
  }
  if (term_flag(t, flag))
    term_flag_set(t2, flag);
  return t2;
}


decompiled_code:
__int64 __fastcall term_flag_clear_recursively(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // rdi

result = term_flag_clear(a1, a2);
if ( *(_BYTE *)(a1 + 4) )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v4++);
term_flag_clear_recursively(v5, a2);
result = *(unsigned __int8 *)(a1 + 4);
}
while ( (int)result > (int)v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // rdi

result = func3(a1, a2);
if ( *(_BYTE *)(a1 + 4) )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v4++);
func8(v5, a2);
result = *(unsigned __int8 *)(a1 + 4);
}
while ( (int)result > (int)v4 );
}
return result;
}

original_code:
void term_flag_clear_recursively(Term t, int flag)
{
  int i;
  term_flag_clear(t, flag);
  for (i = 0; i < ((t)->arity); i++)
    term_flag_clear_recursively(((t)->args[i]), flag);
}

canonical_original_code:
void term_flag_clear_recursively(struct term *t, int flag)
{
  int i;
  term_flag_clear(t, flag);
  for (i = 0; i < ((t)->arity); i++)
    term_flag_clear_recursively(((t)->args[i]), flag);
}


decompiled_code:
__int64 get_fatal_exit_code()
{
return (unsigned int)Fatal_exit_code;
}

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

original_code:
int get_fatal_exit_code()
{
  return Fatal_exit_code;
}


decompiled_code:
void __fastcall set_fatal_exit_code(int a1)
{
Fatal_exit_code = a1;
}

canonical_decompiled_code:
void __fastcall func2(int a1)
{
Fatal_exit_code = a1;
}

original_code:
void set_fatal_exit_code(int exit_code)
{
  Fatal_exit_code = exit_code;
}


decompiled_code:
void __fastcall __noreturn fatal_error(const char *a1)
{
fprintf(stdout, "\nFatal error: %s\n\n", a1);
fprintf(stderr, "\nFatal error: %s\n\n", a1);
exit(Fatal_exit_code);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(const char *a1)
{
fprintf(stdout, "\nFatal error: %s\n\n", a1);
fprintf(stderr, "\nFatal error: %s\n\n", a1);
exit(Fatal_exit_code);
}

original_code:
void fatal_error(char *message)
{
  fprintf(stdout, "\nFatal error:  %s\n\n", message);
  fprintf(stderr, "\nFatal error:  %s\n\n", message);
  exit(Fatal_exit_code);
}

variable_types:
message
char *


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

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

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

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

original_code:
Discrim get_discrim(void)
{
  Discrim p = get_cmem(((sizeof(struct discrim))%(sizeof(void *)) == 0 ? (sizeof(struct discrim))/(sizeof(void *)) : (sizeof(struct discrim))/(sizeof(void *)) + 1));
  Discrim_gets++;
  return(p);
}

canonical_original_code:
struct discrim *get_discrim()
{
  struct discrim *p = get_cmem(((sizeof(struct discrim))%(sizeof(void *)) == 0 ? (sizeof(struct discrim))/(sizeof(void *)) : (sizeof(struct discrim))/(sizeof(void *)) + 1));
  Discrim_gets++;
  return(p);
}

variable_types: struct discrim { struct discrim *next; union { struct discrim *kids; struct plist { void *v; struct plist *next; } *data; } u; short symbol; char type; } *

user_defined_types: struct discrim { struct discrim *next; union { struct discrim *kids; struct plist *data; } u; short symbol; char type; }


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

result = free_mem(a1, 3LL);
++Discrim_frees;
return result;
}

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

result = free_mem(a1, 3LL);
++Discrim_frees;
return result;
}

original_code:
void free_discrim(Discrim p)
{
  free_mem(p, ((sizeof(struct discrim))%(sizeof(void *)) == 0 ? (sizeof(struct discrim))/(sizeof(void *)) : (sizeof(struct discrim))/(sizeof(void *)) + 1));
  Discrim_frees++;
}

canonical_original_code:
void free_discrim(struct discrim *p)
{
  free_mem(p, ((sizeof(struct discrim))%(sizeof(void *)) == 0 ? (sizeof(struct discrim))/(sizeof(void *)) : (sizeof(struct discrim))/(sizeof(void *)) + 1));
  Discrim_frees++;
}

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


decompiled_code:
__int64 __fastcall zap_discrim_tree(__int64 a1, int a2)
{
__int64 *v2; // rbp
char v4; // al
int v5; // esi
__int64 *v6; // r13

v2 = *(__int64 **)(a1 + 8);
if ( a2 )
{
if ( v2 )
{
while ( 1 )
{
v4 = *((_BYTE *)v2 + 18);
if ( (unsigned __int8)(v4 - 2) > 1u && v4 )
v5 = a2 + sn_to_arity((unsigned int)*((__int16 *)v2 + 8));
else
v5 = a2;
v6 = (__int64 *)*v2;
zap_discrim_tree(v2, (unsigned int)(v5 - 1));
if ( !v6 )
break;
v2 = v6;
}
}
}
else
{
zap_plist(*(_QWORD *)(a1 + 8));
}
return free_discrim(a1);
}

original_code:
static
void zap_discrim_tree(Discrim d, int n)
{
  if (n == 0) {
    zap_plist(d->u.data);
  }
  else {
    int arity;
    Discrim k, prev;
    k = d->u.kids;
    while (k != ((void *)0)) {
      if (k->type == AC_ARG_TYPE || k->type == AC_NV_ARG_TYPE)
 arity = 0;
      else if (((k)->type == DVARIABLE))
 arity = 0;
      else
 arity = sn_to_arity(k->symbol);
      prev = k;
      k = k->next;
      zap_discrim_tree(prev, n+arity-1);
    }
  }
  free_discrim(d);
}

canonical_original_code:
static void zap_discrim_tree(struct discrim *d, int n)
{
  if (n == 0) {
    zap_plist(d->u.data);
  }
  else {
    int arity;
    struct discrim *k; struct discrim *prev;
    k = d->u.kids;
    while (k != ((void *)0)) {
      if (k->type == AC_ARG_TYPE || k->type == AC_NV_ARG_TYPE)
 arity = 0;
      else if (((k)->type == DVARIABLE))
 arity = 0;
      else
 arity = sn_to_arity(k->symbol);
      prev = k;
      k = k->next;
      zap_discrim_tree(prev, n+arity-1);
    }
  }
  free_discrim(d);
}

variable_types: n int

variable_types: arity int


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

result = get_mem(4LL);
++Discrim_pos_gets;
return result;
}

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

result = get_mem(4LL);
++Discrim_pos_gets;
return result;
}

original_code:
Discrim_pos get_discrim_pos(void)
{
  Discrim_pos p = get_mem(((sizeof(struct discrim_pos))%(sizeof(void *)) == 0 ? (sizeof(struct discrim_pos))/(sizeof(void *)) : (sizeof(struct discrim_pos))/(sizeof(void *)) + 1));
  Discrim_pos_gets++;
  return(p);
}

canonical_original_code:
struct discrim_pos *get_discrim_pos()
{
  struct discrim_pos *p = get_mem(((sizeof(struct discrim_pos))%(sizeof(void *)) == 0 ? (sizeof(struct discrim_pos))/(sizeof(void *)) : (sizeof(struct discrim_pos))/(sizeof(void *)) + 1));
  Discrim_pos_gets++;
  return(p);
}

variable_types: struct discrim_pos { void *query; struct context { struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; } *subst; struct plist { void *v; struct plist *next; } *data; void *backtrack; } *

user_defined_types: struct discrim_pos { void *query; struct context *subst; struct plist *data; void *backtrack; }

user_defined_types: struct context { struct term *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; }


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

result = free_mem(a1, 4LL);
++Discrim_pos_frees;
return result;
}

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

result = free_mem(a1, 4LL);
++Discrim_pos_frees;
return result;
}

original_code:
void free_discrim_pos(Discrim_pos p)
{
  free_mem(p, ((sizeof(struct discrim_pos))%(sizeof(void *)) == 0 ? (sizeof(struct discrim_pos))/(sizeof(void *)) : (sizeof(struct discrim_pos))/(sizeof(void *)) + 1));
  Discrim_pos_frees++;
}

canonical_original_code:
void free_discrim_pos(struct discrim_pos *p)
{
  free_mem(p, ((sizeof(struct discrim_pos))%(sizeof(void *)) == 0 ? (sizeof(struct discrim_pos))/(sizeof(void *)) : (sizeof(struct discrim_pos))/(sizeof(void *)) + 1));
  Discrim_pos_frees++;
}


decompiled_code:
int p_discrim_mem()
{
return fprint_discrim_mem(stdout, 1);
}

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

original_code:
void p_discrim_mem(void)
{
  fprint_discrim_mem(stdout, TRUE);
}

canonical_original_code:
void p_discrim_mem()
{
  fprint_discrim_mem(stdout, TRUE);
}


decompiled_code:
// attributes: thunk
__int64 discrim_init()
{
return get_discrim();
}

canonical_decompiled_code:
__int64 func7()
{
return func0();
}

original_code:
Discrim discrim_init(void)
{
  return get_discrim();
}

canonical_original_code:
struct discrim *discrim_init()
{
  return get_discrim();
}

return_type: struct discrim { struct discrim *next; union { struct discrim *kids; struct plist { void *v; struct plist *next; } *data; } u; short symbol; char type; } *


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

if ( *(_QWORD *)(a1 + 8) )
result = fatal_error("discrim_dealloc, nonempty index.");
else
result = free_discrim(a1);
return result;
}

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

if ( *(_QWORD *)(a1 + 8) )
result = fatal_error("discrim_dealloc, nonempty index.");
else
result = func1(a1);
return result;
}

original_code:
void discrim_dealloc(Discrim d)
{
  if (d->u.kids) {
    fatal_error("discrim_dealloc, nonempty index.");
  }
  else
    free_discrim(d);
}

canonical_original_code:
void discrim_dealloc(struct discrim *d)
{
  if (d->u.kids) {
    fatal_error("discrim_dealloc, nonempty index.");
  }
  else
    free_discrim(d);
}


decompiled_code:
__int64 __fastcall destroy_discrim_tree(__int64 a1)
{
return zap_discrim_tree(a1, 1);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return func2(a1, 1);
}

original_code:
void destroy_discrim_tree(Discrim d)
{
  zap_discrim_tree(d, 1);
}

canonical_original_code:
void destroy_discrim_tree(struct discrim *d)
{
  zap_discrim_tree(d, 1);
}


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

result = 1LL;
if ( a1 )
result = *(_QWORD *)(a1 + 8) == 0LL;
return result;
}

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

result = 1LL;
if ( a1 )
result = *(_QWORD *)(a1 + 8) == 0LL;
return result;
}

original_code:
BOOL discrim_empty(Discrim d)
{
  return (d == ((void *)0) ? TRUE : (d->u.kids == ((void *)0) ? TRUE : FALSE));
}

canonical_original_code:
enum BOOL discrim_empty(struct discrim *d)
{
  return (d == ((void *)0) ? TRUE : (d->u.kids == ((void *)0) ? TRUE : FALSE));
}


decompiled_code:
__int64 __fastcall num_crossed(int a1)
{
_QWORD *v1; // rbx
int v2; // eax
int v3; // edx
unsigned int v4; // er8
_QWORD *v5; // rax
__int64 v6; // rdx

v1 = *(_QWORD **)(Cells + 56LL * a1 + 32);
v2 = id_to_domain_size();
if ( v2 <= 0 )
return 0LL;
v3 = v2;
v4 = 0;
v5 = v1;
v6 = (__int64)&v1[(unsigned int)(v3 - 1) + 1];
do
v4 += *v5++ == 0LL;
while ( v5 != (_QWORD *)v6 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
_QWORD *v1; // rbx
int v2; // eax
int v3; // edx
unsigned int v4; // er8
_QWORD *v5; // rax
__int64 v6; // rdx

v1 = *(_QWORD **)(Cells + 56LL * a1 + 32);
v2 = id_to_domain_size();
if ( v2 <= 0 )
return 0LL;
v3 = v2;
v4 = 0;
v5 = v1;
v6 = (__int64)&v1[(unsigned int)(v3 - 1) + 1];
do
v4 += *v5++ == 0LL;
while ( v5 != (_QWORD *)v6 );
return v4;
}

original_code:
static
int num_crossed(int id)
{
  Term *p = Cells[id].possible;
  int n = 0;
  int i;
  int ds = id_to_domain_size(id);
  for (i = 0; i < ds; i++)
    if (p[i] == ((void *)0))
      n++;
  return n;
}

canonical_original_code:
static int num_crossed(int id)
{
  struct term **p = Cells[id].possible;
  int n = 0;
  int i;
  int ds = id_to_domain_size(id);
  for (i = 0; i < ds; i++)
    if (p[i] == ((void *)0))
      n++;
  return n;
}

variable_types: id int

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


decompiled_code:
__int64 __fastcall selection_measure(unsigned int a1, int *a2, unsigned int *a3)
{
int v4; // eax
__int64 result; // rax

v4 = parm(*(unsigned int *)(Opt + 96LL));
if ( v4 == 3 )
{
result = num_contradictions(a1, *a2);
goto LABEL_6;
}
if ( v4 > 3 )
{
if ( v4 == 4 )
{
result = num_crossed(a1);
goto LABEL_6;
}
goto LABEL_12;
}
if ( v4 != 1 )
{
if ( v4 == 2 )
{
result = num_propagations(a1);
goto LABEL_6;
}
LABEL_12:
fatal_error("selection_measure: bad selection measure");
result = 0LL;
goto LABEL_6;
}
result = num_occurrences(a1);
LABEL_6:
if ( *a2 < (int)result )
{
*a2 = result;
*a3 = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, int *a2, unsigned int *a3)
{
int v4; // eax
__int64 result; // rax

v4 = parm(*(unsigned int *)(Opt + 96LL));
if ( v4 == 3 )
{
result = func3(a1, *a2);
goto LABEL_6;
}
if ( v4 > 3 )
{
if ( v4 == 4 )
{
result = func1(a1);
goto LABEL_6;
}
goto LABEL_12;
}
if ( v4 != 1 )
{
if ( v4 == 2 )
{
result = func2(a1);
goto LABEL_6;
}
LABEL_12:
fatal_error("selection_measure: bad selection measure");
result = 0LL;
goto LABEL_6;
}
result = func0(a1);
LABEL_6:
if ( *a2 < (int)result )
{
*a2 = result;
*a3 = a1;
}
return result;
}

original_code:
static
void selection_measure(int id, int *max, int *max_id)
{
  int n = 0;
  switch (parm(Opt->selection_measure)) {
  case 1: n = num_occurrences(id); break;
  case 2: n = num_propagations(id); break;
  case 3: n = num_contradictions(id, *max); break;
  case 4: n = num_crossed(id); break;
  default: fatal_error("selection_measure: bad selection measure");
  }
  if (n > *max) {
    *max = n;
    *max_id = id;
  }
}

variable_types:
max
int *


decompiled_code:
__int64 __fastcall select_linear(int a1, int a2)
{
int v2; // ebx
__int64 v3; // rdx
__int64 result; // rax
__int64 v5; // rbp
unsigned int v6; // edi
unsigned int v7; // [rsp+8h] [rbp-20h] BYREF
int v8[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = a1;
if ( !(unsigned int)parm(*(unsigned int *)(Opt + 96LL)) )
{
if ( a1 <= a2 )
{
v3 = Cells + 56LL * a1;
result = (unsigned int)a1;
while ( *(_QWORD *)(v3 + 16) )
{
result = (unsigned int)(result + 1);
v3 += 56LL;
if ( a2 < (int)result )
return 0xFFFFFFFFLL;
}
return result;
}
return 0xFFFFFFFFLL;
}
v7 = -1;
v8[0] = -1;
if ( a1 > a2 )
return 0xFFFFFFFFLL;
v5 = 56LL * a1;
do
{
while ( *(_QWORD *)(Cells + v5 + 16) )
{
++v2;
v5 += 56LL;
if ( a2 < v2 )
return v7;
}
v6 = v2++;
selection_measure(v6, v8, &v7);
v5 += 56LL;
}
while ( a2 >= v2 );
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2)
{
int v2; // ebx
__int64 v3; // rdx
__int64 result; // rax
__int64 v5; // rbp
unsigned int v6; // edi
unsigned int v7; // [rsp+8h] [rbp-20h] BYREF
int v8[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = a1;
if ( !(unsigned int)parm(*(unsigned int *)(Opt + 96LL)) )
{
if ( a1 <= a2 )
{
v3 = Cells + 56LL * a1;
result = (unsigned int)a1;
while ( *(_QWORD *)(v3 + 16) )
{
result = (unsigned int)(result + 1);
v3 += 56LL;
if ( a2 < (int)result )
return 0xFFFFFFFFLL;
}
return result;
}
return 0xFFFFFFFFLL;
}
v7 = -1;
v8[0] = -1;
if ( a1 > a2 )
return 0xFFFFFFFFLL;
v5 = 56LL * a1;
do
{
while ( *(_QWORD *)(Cells + v5 + 16) )
{
++v2;
v5 += 56LL;
if ( a2 < v2 )
return v7;
}
v6 = v2++;
func4(v6, v8, &v7);
v5 += 56LL;
}
while ( a2 >= v2 );
return v7;
}

original_code:
int select_linear(int min_id, int max_id)
{
  if (parm(Opt->selection_measure) == 0) {
    int i = min_id;
    while (i <= max_id && Cells[i].value != ((void *)0))
      i++;
    return (i > max_id ? -1 : i);
  }
  else {
    int id_of_max = -1;
    int max = -1;
    int i;
    for (i = min_id; i <= max_id; i++) {
      if (Cells[i].value == ((void *)0)) {
 selection_measure(i, &max, &id_of_max);
      }
    }
    return id_of_max;
  }
}

variable_types: i int

variable_types: max int


decompiled_code:
__int64 __fastcall select_concentric(__int64 a1, int a2)
{
__int64 v2; // rax
int v3; // ebx
__int64 v4; // rdx
int v5; // er13
__int64 i; // rbp
int v8; // [rsp+0h] [rbp-30h] BYREF
unsigned int v9[11]; // [rsp+4h] [rbp-2Ch] BYREF

if ( (int)a1 > a2 )
return 0xFFFFFFFFLL;
a1 = (int)a1;
do
{
v2 = *(_QWORD *)(Ordered_cells + 8 * a1);
v3 = a1;
v4 = *(_QWORD *)(v2 + 16);
if ( !v4 )
{
v8 = -1;
v5 = *(_DWORD *)(v2 + 40);
v9[0] = -1;
for ( i = 8LL * (int)a1 + 8; ; i += 8LL )
{
if ( v4 )
{
if ( a2 < ++v3 )
return v9[0];
}
else
{
++v3;
selection_measure(*(_DWORD *)v2, &v8, v9);
if ( a2 < v3 )
return v9[0];
}
v2 = *(_QWORD *)(Ordered_cells + i);
if ( *(_DWORD *)(v2 + 40) > v5 )
return v9[0];
v4 = *(_QWORD *)(v2 + 16);
}
}
++a1;
}
while ( a2 >= (int)a1 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int a2)
{
__int64 v2; // rax
int v3; // ebx
__int64 v4; // rdx
int v5; // er13
__int64 i; // rbp
int v8; // [rsp+0h] [rbp-30h] BYREF
unsigned int v9[11]; // [rsp+4h] [rbp-2Ch] BYREF

if ( (int)a1 > a2 )
return 0xFFFFFFFFLL;
a1 = (int)a1;
do
{
v2 = *(_QWORD *)(Ordered_cells + 8 * a1);
v3 = a1;
v4 = *(_QWORD *)(v2 + 16);
if ( !v4 )
{
v8 = -1;
v5 = *(_DWORD *)(v2 + 40);
v9[0] = -1;
for ( i = 8LL * (int)a1 + 8; ; i += 8LL )
{
if ( v4 )
{
if ( a2 < ++v3 )
return v9[0];
}
else
{
++v3;
func4(*(_DWORD *)v2, &v8, v9);
if ( a2 < v3 )
return v9[0];
}
v2 = *(_QWORD *)(Ordered_cells + i);
if ( *(_DWORD *)(v2 + 40) > v5 )
return v9[0];
v4 = *(_QWORD *)(v2 + 16);
}
}
++a1;
}
while ( a2 >= (int)a1 );
return 0xFFFFFFFFLL;
}

original_code:
int select_concentric(int min_id, int max_id)
{
  int i = min_id;
  while (i <= max_id && Ordered_cells[i]->value != ((void *)0))
    i++;
  if (i > max_id)
    return -1;
  else {
    int n = Ordered_cells[i]->max_index;
    int max_val = -1;
    int id_of_max = -1;
    while (i <= max_id && Ordered_cells[i]->max_index <= n) {
      if (Ordered_cells[i]->value == ((void *)0))
 selection_measure(Ordered_cells[i]->id, &max_val, &id_of_max);
      i++;
    }
    return id_of_max;
  }
}


decompiled_code:
__int64 __fastcall select_cell(int a1)
{
int v1; // eax
int v2; // er12
int v3; // eax

v1 = parm(*(unsigned int *)(Opt + 92LL));
if ( v1 == 1 )
{
v2 = select_concentric(0LL, First_skolem_cell - 1);
}
else if ( v1 == 2 )
{
v2 = select_concentric_band(0, First_skolem_cell - 1, a1);
}
else
{
if ( v1 )
{
v2 = -1;
fatal_error("bad selection order");
goto LABEL_5;
}
v2 = select_linear(0, First_skolem_cell - 1);
}
if ( v2 >= 0 )
return (unsigned int)v2;
LABEL_5:
v3 = parm(*(unsigned int *)(Opt + 92LL));
switch ( v3 )
{
case 1:
return select_concentric(First_skolem_cell, Number_of_cells - 1);
case 2:
return select_concentric_band(First_skolem_cell, Number_of_cells - 1, a1);
case 0:
return select_linear(First_skolem_cell, Number_of_cells - 1);
}
fatal_error("bad selection order");
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
int v1; // eax
int v2; // er12
int v3; // eax

v1 = parm(*(unsigned int *)(Opt + 92LL));
if ( v1 == 1 )
{
v2 = func6(0LL, First_skolem_cell - 1);
}
else if ( v1 == 2 )
{
v2 = func7(0, First_skolem_cell - 1, a1);
}
else
{
if ( v1 )
{
v2 = -1;
fatal_error("bad selection order");
goto LABEL_5;
}
v2 = func5(0, First_skolem_cell - 1);
}
if ( v2 >= 0 )
return (unsigned int)v2;
LABEL_5:
v3 = parm(*(unsigned int *)(Opt + 92LL));
switch ( v3 )
{
case 1:
return func6(First_skolem_cell, Number_of_cells - 1);
case 2:
return func7(First_skolem_cell, Number_of_cells - 1, a1);
case 0:
return func5(First_skolem_cell, Number_of_cells - 1);
}
fatal_error("bad selection order");
return (unsigned int)v2;
}

original_code:
int select_cell(int max_constrained)
{
  int id = -1;
  switch (parm(Opt->selection_order)) {
  case 0: id = select_linear(0, First_skolem_cell-1); break;
  case 1: id = select_concentric(0, First_skolem_cell-1); break;
  case 2: id = select_concentric_band(0, First_skolem_cell-1, max_constrained); break;
  default: fatal_error("bad selection order");
  }
  if (id >= 0)
    return id;
  switch (parm(Opt->selection_order)) {
  case 0: id = select_linear(First_skolem_cell, Number_of_cells-1); break;
  case 1: id = select_concentric(First_skolem_cell, Number_of_cells-1); break;
  case 2: id = select_concentric_band(First_skolem_cell, Number_of_cells-1, max_constrained); break;
  default: fatal_error("bad selection order");
  }
  return id;
}


decompiled_code:
__int64 __fastcall num_occurrences(int a1)
{
unsigned int v1; // er8
__int64 i; // rax

v1 = 0;
for ( i = *(_QWORD *)(Cells + 56LL * a1 + 24); i; ++v1 )
i = *(_QWORD *)(i + 24);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
unsigned int v1; // er8
__int64 i; // rax

v1 = 0;
for ( i = *(_QWORD *)(Cells + 56LL * a1 + 24); i; ++v1 )
i = *(_QWORD *)(i + 24);
return v1;
}

original_code:
static
int num_occurrences(int id)
{
  Term t;
  int n = 0;
  for (t = Cells[id].occurrences; t != ((void *)0); t = t->u.vp)
    n++;
  return n;
}

canonical_original_code:
static int num_occurrences(int id)
{
  struct term *t;
  int n = 0;
  for (t = Cells[id].occurrences; t != ((void *)0); t = t->u.vp)
    n++;
  return n;
}

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 init_basic_paramod()
{
__int64 result; // rax

if ( Nonbasic_flag != -1 )
fatal_error("init_basic_paramod, called more than once");
result = claim_term_flag();
Nonbasic_flag = result;
return result;
}

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

if ( Nonbasic_flag != -1 )
fatal_error("init_basic_paramod, called more than once");
result = claim_term_flag();
Nonbasic_flag = result;
return result;
}

original_code:
void init_basic_paramod(void)
{
  if (Nonbasic_flag != -1)
    fatal_error("init_basic_paramod, called more than once");
  Nonbasic_flag = claim_term_flag();
}

canonical_original_code:
void init_basic_paramod()
{
  if (Nonbasic_flag != -1)
    fatal_error("init_basic_paramod, called more than once");
  Nonbasic_flag = claim_term_flag();
}


decompiled_code:
void __fastcall set_basic_paramod(int a1)
{
Basic_paramodulation = a1;
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
Basic_paramodulation = a1;
}

original_code:
void set_basic_paramod(BOOL flag)
{
  Basic_paramodulation = flag;
}

canonical_original_code:
void set_basic_paramod(enum BOOL flag)
{
  Basic_paramodulation = flag;
}

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


decompiled_code:
__int64 basic_paramod()
{
return (unsigned int)Basic_paramodulation;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)Basic_paramodulation;
}

original_code:
BOOL basic_paramod(void)
{
  return Basic_paramodulation;
}

canonical_original_code:
enum BOOL basic_paramod()
{
  return Basic_paramodulation;
}


decompiled_code:
__int64 __fastcall mark_term_nonbasic(__int64 a1)
{
if ( Nonbasic_flag == -1 )
fatal_error("mark_term_nonbasic: init_basic() was not called");
return term_flag_set(a1, (unsigned int)Nonbasic_flag);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
if ( Nonbasic_flag == -1 )
fatal_error("mark_term_nonbasic: init_basic() was not called");
return term_flag_set(a1, (unsigned int)Nonbasic_flag);
}

original_code:
void mark_term_nonbasic(Term t)
{
  if (Nonbasic_flag == -1)
    fatal_error("mark_term_nonbasic: init_basic() was not called");
  term_flag_set(t, Nonbasic_flag);
}

canonical_original_code:
void mark_term_nonbasic(struct term *t)
{
  if (Nonbasic_flag == -1)
    fatal_error("mark_term_nonbasic: init_basic() was not called");
  term_flag_set(t, Nonbasic_flag);
}


decompiled_code:
__int64 __fastcall mark_all_nonbasic(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // rbp
__int64 v4; // rdi

result = *a1;
if ( (int)result < 0 )
{
result = mark_term_nonbasic((__int64)a1);
if ( *((_BYTE *)a1 + 4) )
{
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3++);
mark_all_nonbasic(v4);
result = *((unsigned __int8 *)a1 + 4);
}
while ( (int)result > (int)v3 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // rbp
__int64 v4; // rdi

result = *a1;
if ( (int)result < 0 )
{
result = func3((__int64)a1);
if ( *((_BYTE *)a1 + 4) )
{
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3++);
func4(v4);
result = *((unsigned __int8 *)a1 + 4);
}
while ( (int)result > (int)v3 );
}
}
return result;
}

original_code:
void mark_all_nonbasic(Term t)
{
  if (!((t)->private_symbol >= 0)) {
    int i;
    mark_term_nonbasic(t);
    for (i = 0; i < ((t)->arity); i++)
      mark_all_nonbasic(((t)->args[i]));
  }
}

canonical_original_code:
void mark_all_nonbasic(struct term *t)
{
  if (!((t)->private_symbol >= 0)) {
    int i;
    mark_term_nonbasic(t);
    for (i = 0; i < ((t)->arity); i++)
      mark_all_nonbasic(((t)->args[i]));
  }
}


decompiled_code:
__int64 __fastcall nonbasic_term(__int64 a1)
{
return term_flag(a1, (unsigned int)Nonbasic_flag);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return term_flag(a1, (unsigned int)Nonbasic_flag);
}

original_code:
BOOL nonbasic_term(Term t)
{
  return term_flag(t, Nonbasic_flag);
}

canonical_original_code:
enum BOOL nonbasic_term(struct term *t)
{
  return term_flag(t, Nonbasic_flag);
}


decompiled_code:
_BOOL8 __fastcall basic_term(__int64 a1)
{
return (unsigned int)term_flag(a1, (unsigned int)Nonbasic_flag) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1)
{
return (unsigned int)term_flag(a1, (unsigned int)Nonbasic_flag) == 0;
}

original_code:
BOOL basic_term(Term t)
{
  return !term_flag(t, Nonbasic_flag);
}

canonical_original_code:
enum BOOL basic_term(struct term *t)
{
  return !term_flag(t, Nonbasic_flag);
}


decompiled_code:
__int64 nonbasic_flag()
{
return (unsigned int)Nonbasic_flag;
}

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

original_code:
int nonbasic_flag(void)
{
  return Nonbasic_flag;
}

canonical_original_code:
int nonbasic_flag()
{
  return Nonbasic_flag;
}


decompiled_code:
__int64 __fastcall apply_basic(int *a1, __int64 a2)
{
int *v2; // r13
int *v3; // r12
__int64 v4; // rbx
int v5; // edi
__int64 v6; // r14
__int64 v7; // rbp
_QWORD *v8; // r15
__int64 v9; // rdi
__int64 v11; // rdi

v2 = a1;
v3 = a1;
v4 = a2;
if ( a2 )
{
while ( 1 )
{
v5 = *v3;
if ( *v3 < 0 )
break;
v3 = *(int **)(v4 + 8LL * v5);
if ( !v3 )
{
v11 = (unsigned int)(100 * *(_DWORD *)(v4 + 1600) + v5);
return get_variable_term(v11);
}
v4 = *(_QWORD *)(v4 + 8LL * v5 + 800);
if ( !v4 )
goto LABEL_14;
}
}
else
{
LABEL_14:
v11 = (unsigned int)*v3;
v4 = 0LL;
if ( (int)v11 >= 0 )
return get_variable_term(v11);
}
v6 = get_rigid_term_like(v3);
if ( *((_BYTE *)v3 + 4) )
{
v7 = 0LL;
do
{
v8 = (_QWORD *)(*(_QWORD *)(v6 + 8) + 8 * v7);
v9 = *(_QWORD *)(*((_QWORD *)v3 + 1) + 8 * v7++);
*v8 = apply_basic(v9, v4);
}
while ( *((unsigned __int8 *)v3 + 4) > (int)v7 );
}
if ( *v2 < 0 )
{
if ( (unsigned int)nonbasic_term((__int64)v3) )
mark_term_nonbasic(v6);
}
else
{
mark_all_nonbasic((unsigned int *)v6);
}
return v6;
}

original_code:
Term apply_basic(Term t, Context c)
{
  Term raw = t;
  { int i; while (c!=((void *)0) && ((t)->private_symbol >= 0) && c->terms[i=((t)->private_symbol)]) { t = c->terms[i]; c = c->contexts[i]; } }
  if (((t)->private_symbol >= 0)) {
    if (!c)
      return get_variable_term(((t)->private_symbol));
    else
      return get_variable_term(c->multiplier * 100 + ((t)->private_symbol));
  }
  else {
    Term t2 = get_rigid_term_like(t);
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = apply_basic(((t)->args[i]), c);
    if (((raw)->private_symbol >= 0))
      mark_all_nonbasic(t2);
    else if (nonbasic_term(t))
      mark_term_nonbasic(t2);
    return t2;
  }
}

canonical_original_code:
struct term *apply_basic(struct term *t, struct context *c)
{
  struct term *raw = t;
  { int i; while (c!=((void *)0) && ((t)->private_symbol >= 0) && c->terms[i=((t)->private_symbol)]) { t = c->terms[i]; c = c->contexts[i]; } }
  if (((t)->private_symbol >= 0)) {
    if (!c)
      return get_variable_term(((t)->private_symbol));
    else
      return get_variable_term(c->multiplier * 100 + ((t)->private_symbol));
  }
  else {
    struct term *t2 = get_rigid_term_like(t);
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = apply_basic(((t)->args[i]), c);
    if (((raw)->private_symbol >= 0))
      mark_all_nonbasic(t2);
    else if (nonbasic_term(t))
      mark_term_nonbasic(t2);
    return t2;
  }
}

variable_types:
t
struct term *

variable_types: struct context { struct term *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; } *


original_code:
Term apply_basic_substitute(Term t, Term beta, Context c_from,
       Term into_term, Context c_into)
{
  if (t == into_term)
    return apply_basic(beta, c_from);
  else if (((t)->private_symbol >= 0))
    return apply_basic(t, c_into);
  else {
    int i;
    Term t2 = get_rigid_term_like(t);
    if (nonbasic_term(t))
      mark_term_nonbasic(t2);
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = apply_basic_substitute(((t)->args[i]), beta, c_from,
        into_term, c_into);
    return t2;
  }
}

canonical_original_code:
struct term *apply_basic_substitute(struct term *t, struct term *beta, struct context *c_from, struct term *into_term, struct context *c_into)
{
  if (t == into_term)
    return apply_basic(beta, c_from);
  else if (((t)->private_symbol >= 0))
    return apply_basic(t, c_into);
  else {
    int i;
    struct term *t2 = get_rigid_term_like(t);
    if (nonbasic_term(t))
      mark_term_nonbasic(t2);
    for (i = 0; i < ((t)->arity); i++)
      ((t2)->args[i]) = apply_basic_substitute(((t)->args[i]), beta, c_from,
        into_term, c_into);
    return t2;
  }
}

variable_types:
beta
struct term *


decompiled_code:
__int64 __fastcall clear_all_nonbasic_marks(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // rbp
__int64 v4; // rdi

result = *a1;
if ( (int)result < 0 )
{
result = term_flag_clear(a1, (unsigned int)Nonbasic_flag);
if ( *((_BYTE *)a1 + 4) )
{
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3++);
clear_all_nonbasic_marks(v4);
result = *((unsigned __int8 *)a1 + 4);
}
while ( (int)result > (int)v3 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // rbp
__int64 v4; // rdi

result = *a1;
if ( (int)result < 0 )
{
result = term_flag_clear(a1, (unsigned int)Nonbasic_flag);
if ( *((_BYTE *)a1 + 4) )
{
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3++);
func10(v4);
result = *((unsigned __int8 *)a1 + 4);
}
while ( (int)result > (int)v3 );
}
}
return result;
}

original_code:
void clear_all_nonbasic_marks(Term t)
{
  if (!((t)->private_symbol >= 0)) {
    int i;
    term_flag_clear(t, Nonbasic_flag);
    for (i = 0; i < ((t)->arity); i++)
      clear_all_nonbasic_marks(((t)->args[i]));
  }
}

canonical_original_code:
void clear_all_nonbasic_marks(struct term *t)
{
  if (!((t)->private_symbol >= 0)) {
    int i;
    term_flag_clear(t, Nonbasic_flag);
    for (i = 0; i < ((t)->arity); i++)
      clear_all_nonbasic_marks(((t)->args[i]));
  }
}


decompiled_code:
int __fastcall p_term_basic(unsigned int *a1)
{
__int64 v1; // rsi
__int64 v3; // rbp
int v4; // eax

v1 = *a1;
if ( (int)v1 < 0 )
{
if ( basic_term((__int64)a1) )
putchar(35);
fprint_sym(stdout, -*a1);
if ( (*a1 & 0x80000000) != 0 && *((_BYTE *)a1 + 4) )
{
v3 = 0LL;
putchar(40);
if ( *((_BYTE *)a1 + 4) )
{
do
{
p_term_basic(*(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3));
v4 = *((unsigned __int8 *)a1 + 4);
if ( v4 - 1 > (int)v3 )
{
putchar(44);
v4 = *((unsigned __int8 *)a1 + 4);
}
++v3;
}
while ( v4 > (int)v3 );
}
putchar(41);
}
}
else
{
printf("v%d", v1);
}
return fflush(stdout);
}

original_code:
void p_term_basic(Term t)
{
  if (((t)->private_symbol >= 0))
    printf("v%d", ((t)->private_symbol));
  else {
    if (basic_term(t))
      printf("#");
    fprint_sym(stdout, (-((t)->private_symbol)));
    if (((t)->private_symbol < 0 && (t)->arity > 0)) {
      int i;
      printf("(");
      for (i = 0; i < ((t)->arity); i++) {
 p_term_basic(((t)->args[i]));
 if (i < ((t)->arity)-1)
   printf(",");
      }
      printf(")");
    }
  }
  fflush(stdout);
}

canonical_original_code:
void p_term_basic(struct term *t)
{
  if (((t)->private_symbol >= 0))
    printf("v%d", ((t)->private_symbol));
  else {
    if (basic_term(t))
      printf("#");
    fprint_sym(stdout, (-((t)->private_symbol)));
    if (((t)->private_symbol < 0 && (t)->arity > 0)) {
      int i;
      printf("(");
      for (i = 0; i < ((t)->arity); i++) {
 p_term_basic(((t)->args[i]));
 if (i < ((t)->arity)-1)
   printf(",");
      }
      printf(")");
    }
  }
  fflush(stdout);
}


decompiled_code:
_BOOL8 __fastcall str_ident(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_original_code:
enum BOOL str_ident(char *s, char *t)
{
  return strcmp(s, t) == 0;
}

variable_types:
s
char *

variable_types:
t
char *


decompiled_code:
void *__fastcall new_str_copy(void *src)
{
size_t v1; // r12
void *v2; // rax

v1 = strlen((const char *)src) + 1;
v2 = malloc(v1);
return memcpy(v2, src, v1);
}

canonical_decompiled_code:
void *__fastcall func1(void *src)
{
size_t v1; // r12
void *v2; // rax

v1 = strlen((const char *)src) + 1;
v2 = malloc(v1);
return memcpy(v2, src, v1);
}

original_code:
char *new_str_copy(char *str)
{
  char *p = malloc(strlen(str)+1);
  strcpy(p, str);
  return p;
}

variable_types:
str
char *

variable_types:
p
char *

return_type: char *


decompiled_code:
__int64 __fastcall string_member(const char *a1, const char **a2, int a3)
{
__int64 v3; // r12
const char **v4; // rbx

if ( a3 <= 0 )
return 0LL;
v3 = (__int64)&a2[(unsigned int)(a3 - 1) + 1];
v4 = a2;
while ( !a1 || !*v4 || !str_ident(a1, *v4) )
{
if ( ++v4 == (const char **)v3 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, const char **a2, int a3)
{
__int64 v3; // r12
const char **v4; // rbx

if ( a3 <= 0 )
return 0LL;
v3 = (__int64)&a2[(unsigned int)(a3 - 1) + 1];
v4 = a2;
while ( !a1 || !*v4 || !func0(a1, *v4) )
{
if ( ++v4 == (const char **)v3 )
return 0LL;
}
return 1LL;
}

canonical_original_code:
enum BOOL string_member(char *string, char **strings, int n)
{
  int i;
  for (i = 0; i < n; i++)
    if (string && strings[i] && str_ident(string, strings[i]))
      return TRUE;
  return FALSE;
}

variable_types:
string
char *

variable_types:
strings
char **

variable_types: n int


decompiled_code:
__int64 __fastcall which_string_member(const char *a1, __int64 a2, int a3)
{
__int64 v3; // rbp
__int64 v4; // rbx

if ( a3 <= 1 )
return 0xFFFFFFFFLL;
v3 = a3;
v4 = 1LL;
while ( !str_ident(*(const char **)(a2 + 8 * v4), a1) )
{
if ( ++v4 == v3 )
return 0xFFFFFFFFLL;
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, __int64 a2, int a3)
{
__int64 v3; // rbp
__int64 v4; // rbx

if ( a3 <= 1 )
return 0xFFFFFFFFLL;
v3 = a3;
v4 = 1LL;
while ( !func0(*(const char **)(a2 + 8 * v4), a1) )
{
if ( ++v4 == v3 )
return 0xFFFFFFFFLL;
}
return (unsigned int)v4;
}

original_code:
int which_string_member(char *string, char **strings, int n)
{
  int i;
  for (i = 1; i < n; i++)
    if (str_ident(strings[i], string))
      return i;
  return -1;
}


decompiled_code:
__int64 __fastcall initial_substring(char *a1, __int64 a2)
{
char v2; // dl
__int64 v3; // rax
char v4; // cl

v2 = *a1;
v3 = 0LL;
if ( !*a1 )
return 1LL;
while ( 1 )
{
v4 = *(_BYTE *)(a2 + v3);
if ( v4 != v2 || !v4 )
break;
v2 = a1[++v3];
if ( !v2 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, __int64 a2)
{
char v2; // dl
__int64 v3; // rax
char v4; // cl

v2 = *a1;
v3 = 0LL;
if ( !*a1 )
return 1LL;
while ( 1 )
{
v4 = *(_BYTE *)(a2 + v3);
if ( v4 != v2 || !v4 )
break;
v2 = a1[++v3];
if ( !v2 )
return 1LL;
}
return 0LL;
}

canonical_original_code:
enum BOOL initial_substring(char *x, char *y)
{
  while (*x && *y && *x == *y) {
    x++; y++;
  }
  return *x == '\0';
}

variable_types:
x
char *

variable_types:
y
char *


substring

decompiled_code:
__int64 __fastcall substring(char *a1, _BYTE *a2)
{
__int64 result; // rax

while ( 1 )
{
result = initial_substring(a1, (__int64)a2);
if ( !*a2 || (_DWORD)result )
break;
++a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, _BYTE *a2)
{
__int64 result; // rax

while ( 1 )
{
result = func4(a1, (__int64)a2);
if ( !*a2 || (_DWORD)result )
break;
++a2;
}
return result;
}

original_code:
BOOL substring(char *x, char *y)
{
  BOOL found = initial_substring(x,y);
  while (*y && !found) {
    y++;
    found = initial_substring(x,y);
  }
  return found;
}

canonical_original_code:
enum BOOL substring(char *x, char *y)
{
  enum BOOL found = initial_substring(x,y);
  while (*y && !found) {
    y++;
    found = initial_substring(x,y);
  }
  return found;
}

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


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

if ( (int)a2 < (int)a3 )
{
a2 = (int)a2;
a3 = (int)a3;
do
{
result = *(unsigned __int8 *)(a1 + a2);
*(_BYTE *)(a1 + a2++) = *(_BYTE *)(a1 + a3);
*(_BYTE *)(a1 + a3--) = result;
}
while ( (int)a2 < (int)a3 );
}
return result;
}

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

if ( (int)a2 < (int)a3 )
{
a2 = (int)a2;
a3 = (int)a3;
do
{
result = *(unsigned __int8 *)(a1 + a2);
*(_BYTE *)(a1 + a2++) = *(_BYTE *)(a1 + a3);
*(_BYTE *)(a1 + a3--) = result;
}
while ( (int)a2 < (int)a3 );
}
return result;
}

original_code:
void reverse_chars(char *s, int start, int end)
{
  if (start < end) {
    char c = s[start]; s[start] = s[end]; s[end] = c;
    reverse_chars(s, start+1, end-1);
  }
}

variable_types: start int

variable_types: end int

variable_types: c char


decompiled_code:
__int64 __fastcall char_occurrences(const char *a1, unsigned __int8 a2)
{
const char *v2; // rcx
__int64 result; // rax
_BOOL4 v4; // edx

v2 = &a1[strlen(a1)];
result = 0LL;
while ( a1 != v2 )
{
v4 = *a1++ == a2;
result = (unsigned int)(v4 + result);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, unsigned __int8 a2)
{
const char *v2; // rcx
__int64 result; // rax
_BOOL4 v4; // edx

v2 = &a1[strlen(a1)];
result = 0LL;
while ( a1 != v2 )
{
v4 = *a1++ == a2;
result = (unsigned int)(v4 + result);
}
return result;
}

original_code:
int char_occurrences(char *s, char c)
{
  int n = 0;
  int i;
  for (i = 0; i < strlen(s); i++) {
    if (s[i] == c)
      n++;
  }
  return n;
}

variable_types: i int


decompiled_code:
_BOOL8 __fastcall str_to_int(const char *a1, _DWORD *a2)
{
char *endptr; // [rsp+8h] [rbp-10h] BYREF

*a2 = strtol(a1, &endptr, 10);
return *endptr == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(const char *a1, _DWORD *a2)
{
char *endptr; // [rsp+8h] [rbp-10h] BYREF

*a2 = strtol(a1, &endptr, 10);
return *endptr == 0;
}

canonical_original_code:
enum BOOL str_to_int(char *str, int *ip)
{
  char *end;
  *ip = strtol(str, &end, 10);
  if (*end != '\0')
    return FALSE;
  else
    return TRUE;
}

variable_types:
ip
int *

variable_types:
end
char *


decompiled_code:
__int64 __fastcall natural_string(const char *a1)
{
__int64 result; // rax
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !str_to_int(a1, v2) )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( (v2[0] & 0x80000000) == 0 )
result = v2[0];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
__int64 result; // rax
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !func8(a1, v2) )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( (v2[0] & 0x80000000) == 0 )
result = v2[0];
return result;
}

original_code:
int natural_string(char *str)
{
  int i;
  if (!str_to_int(str, &i))
    return -1;
  else if (i < 0)
    return -1;
  else
    return i;
}


decompiled_code:
char *__fastcall int_to_str(unsigned int a1, char *a2, int a3)
{
if ( a3 <= snprintf(a2, a3, "%d", a1) )
fatal_error("float_to_str, string too small");
return a2;
}

canonical_decompiled_code:
char *__fastcall func10(unsigned int a1, char *a2, int a3)
{
if ( a3 <= snprintf(a2, a3, "%d", a1) )
fatal_error("float_to_str, string too small");
return a2;
}

original_code:
char *int_to_str(int n, char *s, int size)
{
  int used = snprintf(s, size, "%d", n);
  if (used >= size)
    fatal_error("float_to_str, string too small");
  return s;
}

variable_types: size int

variable_types: used int


decompiled_code:
_BOOL8 __fastcall str_to_double(__int64 a1, double *a2)
{
_BOOL8 result; // rax
double v3; // xmm0_8
char *v4; // rax
char *endptr; // [rsp+0h] [rbp-10h] BYREF

result = 0LL;
if ( *(_BYTE *)a1 == 34 && *(_BYTE *)(a1 + 1) != 34 )
{
v3 = strtod((const char *)(a1 + 1), &endptr);
v4 = endptr;
*a2 = v3;
result = *v4 == 34;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(__int64 a1, double *a2)
{
_BOOL8 result; // rax
double v3; // xmm0_8
char *v4; // rax
char *endptr; // [rsp+0h] [rbp-10h] BYREF

result = 0LL;
if ( *(_BYTE *)a1 == 34 && *(_BYTE *)(a1 + 1) != 34 )
{
v3 = strtod((const char *)(a1 + 1), &endptr);
v4 = endptr;
*a2 = v3;
result = *v4 == 34;
}
return result;
}

canonical_original_code:
enum BOOL str_to_double(char *s, double *dp)
{
  char *end;
  double f;
  if (*s != '\"')
    return(FALSE);
  else if (*(s+1) == '\"')
    return(FALSE);
  else {
    f = strtod(s+1, &end);
    *dp = f;
    return (*end == '\"');
  }
}

variable_types:
s
char *

variable_types:
dp
double *

variable_types: f double


decompiled_code:
char *__fastcall double_to_str(char *s, int a2, double a3)
{
int v3; // eax
__int64 v4; // rbp
char *result; // rax

if ( a2 <= snprintf(s, a2, "%.3f", a3) )
{
fatal_error("double_to_str, string too small");
result = 0LL;
}
else
{
v3 = strlen(s);
v4 = v3;
if ( v3 > 0 )
memmove(s + 1, &s[v3 - 1LL - (v3 - 1)], v3);
*s = 34;
result = s;
s[v4 + 1] = 34;
s[v4 + 2] = 0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func12(char *s, int a2, double a3)
{
int v3; // eax
__int64 v4; // rbp
char *result; // rax

if ( a2 <= snprintf(s, a2, "%.3f", a3) )
{
fatal_error("double_to_str, string too small");
result = 0LL;
}
else
{
v3 = strlen(s);
v4 = v3;
if ( v3 > 0 )
memmove(s + 1, &s[v3 - 1LL - (v3 - 1)], v3);
*s = 34;
result = s;
s[v4 + 1] = 34;
s[v4 + 2] = 0;
}
return result;
}

original_code:
char *double_to_str(double d,
      char *s,
      int size)
{
  int used = snprintf(s, size, Float_format, d);
  if (used >= size) {
    fatal_error("double_to_str, string too small");
    return ((void *)0);
  }
  else {
    int i;
    int n = strlen(s);
    for (i=n; i>0; i--)
      s[i] = s[i-1];
    s[0] = '\"';
    s[n+1] = '\"';
    s[n+2] = '\0';
    return s;
  }
}

variable_types: d double


decompiled_code:
__int64 __fastcall string_of_repeated(char a1, const char *a2)
{
const char *v2; // rax

v2 = &a2[strlen(a2)];
do
{
if ( a2 == v2 )
return 1LL;
++a2;
}
while ( *(a2 - 1) == a1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(char a1, const char *a2)
{
const char *v2; // rax

v2 = &a2[strlen(a2)];
do
{
if ( a2 == v2 )
return 1LL;
++a2;
}
while ( *(a2 - 1) == a1 );
return 0LL;
}

canonical_original_code:
enum BOOL string_of_repeated(char c, char *s)
{
  int i;
  for (i = 0; i < strlen(s); i++)
    if (s[i] != c)
      return FALSE;
  return TRUE;
}


decompiled_code:
int __fastcall command_line_parm(unsigned int a1, const char *a2)
{
__int64 v2; // r12
const char *v3; // rax

v2 = (unsigned int)atoi(a2);
assign_parm(a1, v2, 1LL);
v3 = (const char *)parm_id_to_str(a1);
return printf("\n%% From the command line: assign(%s, %d).\n", v3, (unsigned int)v2);
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1, const char *a2)
{
__int64 v2; // r12
const char *v3; // rax

v2 = (unsigned int)atoi(a2);
assign_parm(a1, v2, 1LL);
v3 = (const char *)parm_id_to_str(a1);
return printf("\n%% From the command line: assign(%s, %d).\n", v3, (unsigned int)v2);
}

original_code:
static
void command_line_parm(int id, char *optarg)
{
  int n = atoi(optarg);
  assign_parm(id, n, TRUE);
  printf("\n%% From the command line: assign(%s, %d).\n", parm_id_to_str(id),n);
}

variable_types: id int

variable_types:
optarg
char *


decompiled_code:
int __fastcall command_line_flag(unsigned int a1, __int64 a2)
{
const char *v2; // rax
int result; // eax
const char *v4; // rax

if ( a2 && !(unsigned int)str_ident(a2, "1") )
{
if ( (unsigned int)str_ident(a2, "0") )
{
clear_flag(a1, 1LL);
v4 = (const char *)flag_id_to_str(a1);
result = printf("\n%% From the command line: clear(%s).\n", v4);
}
else
{
result = fatal_error("Command-line flag must have 0 or 1 as the value");
}
}
else
{
set_flag(a1, 1LL);
v2 = (const char *)flag_id_to_str(a1);
result = printf("\n%% From the command line: set(%s).\n", v2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1, __int64 a2)
{
const char *v2; // rax
int result; // eax
const char *v4; // rax

if ( a2 && !(unsigned int)str_ident(a2, "1") )
{
if ( (unsigned int)str_ident(a2, "0") )
{
clear_flag(a1, 1LL);
v4 = (const char *)flag_id_to_str(a1);
result = printf("\n%% From the command line: clear(%s).\n", v4);
}
else
{
result = fatal_error("Command-line flag must have 0 or 1 as the value");
}
}
else
{
set_flag(a1, 1LL);
v2 = (const char *)flag_id_to_str(a1);
result = printf("\n%% From the command line: set(%s).\n", v2);
}
return result;
}

original_code:
static
void command_line_flag(int id, char *optarg)
{
  if (!optarg || str_ident(optarg, "1")) {
    set_flag(id, TRUE);
    printf("\n%% From the command line: set(%s).\n", flag_id_to_str(id));
  }
  else if (str_ident(optarg, "0")) {
    clear_flag(id, TRUE);
    printf("\n%% From the command line: clear(%s).\n", flag_id_to_str(id));
  }
  else
    fatal_error("Command-line flag must have 0 or 1 as the value");
}


decompiled_code:
__int64 __fastcall member_args(int a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rbx

if ( a1 <= 1 )
return 0LL;
v4 = (_QWORD *)(a2 + 8);
do
{
if ( (unsigned int)str_ident(*v4, a3) )
return 1LL;
++v4;
}
while ( v4 != (_QWORD *)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rbx

if ( a1 <= 1 )
return 0LL;
v4 = (_QWORD *)(a2 + 8);
do
{
if ( (unsigned int)str_ident(*v4, a3) )
return 1LL;
++v4;
}
while ( v4 != (_QWORD *)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
return 0LL;
}

canonical_original_code:
enum BOOL member_args(int argc, char **argv, char *str)
{
  int i;
  for (i = 1; i < argc; i++)
    if (str_ident(argv[i], str))
      return TRUE;
  return FALSE;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
str
char *


decompiled_code:
int __fastcall process_command_line_args(int argc, char **argv, unsigned int *a3)
{
int result; // eax

while ( 1 )
{
result = getopt(argc, argv, "n:N:m:t:s:b:O:M:p:P:v:L:G:H:I:J:K:T:R:i:q:Q:S:cf:g");
if ( result == -1 )
return result;
switch ( result )
{
case 'G':
command_line_flag(a3[4], (__int64)optarg);
break;
case 'H':
command_line_flag(a3[5], (__int64)optarg);
break;
case 'I':
command_line_flag(a3[6], (__int64)optarg);
break;
case 'J':
command_line_flag(a3[7], (__int64)optarg);
break;
case 'K':
command_line_flag(a3[8], (__int64)optarg);
break;
case 'L':
command_line_flag(a3[2], (__int64)optarg);
break;
case 'M':
command_line_parm(a3[24], optarg);
break;
case 'N':
command_line_parm(a3[19], optarg);
break;
case 'O':
command_line_parm(a3[23], optarg);
break;
case 'P':
command_line_flag(*a3, (__int64)optarg);
break;
case 'Q':
command_line_flag(a3[14], (__int64)optarg);
break;
case 'R':
command_line_flag(a3[10], (__int64)optarg);
break;
case 'S':
command_line_flag(a3[15], (__int64)optarg);
break;
case 'T':
command_line_flag(a3[3], (__int64)optarg);
break;
case 'b':
command_line_parm(a3[27], optarg);
break;
case 'c':
case 'f':
case 'g':
continue;
case 'i':
command_line_parm(a3[21], optarg);
break;
case 'm':
command_line_parm(a3[22], optarg);
break;
case 'n':
command_line_parm(a3[17], optarg);
break;
case 'p':
command_line_flag(a3[1], (__int64)optarg);
break;
case 'q':
command_line_flag(a3[13], (__int64)optarg);
break;
case 's':
command_line_parm(a3[26], optarg);
break;
case 't':
command_line_parm(a3[25], optarg);
break;
case 'v':
command_line_flag(a3[9], (__int64)optarg);
break;
default:
usage_message(stderr, a3);
fatal_error("unrecognized command-line option or missing value (flags take 0 or 1)");
break;
}
}
}

canonical_decompiled_code:
int __fastcall func4(int argc, char **argv, unsigned int *a3)
{
int result; // eax

while ( 1 )
{
result = getopt(argc, argv, "n:N:m:t:s:b:O:M:p:P:v:L:G:H:I:J:K:T:R:i:q:Q:S:cf:g");
if ( result == -1 )
return result;
switch ( result )
{
case 'G':
func1(a3[4], (__int64)optarg);
break;
case 'H':
func1(a3[5], (__int64)optarg);
break;
case 'I':
func1(a3[6], (__int64)optarg);
break;
case 'J':
func1(a3[7], (__int64)optarg);
break;
case 'K':
func1(a3[8], (__int64)optarg);
break;
case 'L':
func1(a3[2], (__int64)optarg);
break;
case 'M':
func0(a3[24], optarg);
break;
case 'N':
func0(a3[19], optarg);
break;
case 'O':
func0(a3[23], optarg);
break;
case 'P':
func1(*a3, (__int64)optarg);
break;
case 'Q':
func1(a3[14], (__int64)optarg);
break;
case 'R':
func1(a3[10], (__int64)optarg);
break;
case 'S':
func1(a3[15], (__int64)optarg);
break;
case 'T':
func1(a3[3], (__int64)optarg);
break;
case 'b':
func0(a3[27], optarg);
break;
case 'c':
case 'f':
case 'g':
continue;
case 'i':
func0(a3[21], optarg);
break;
case 'm':
func0(a3[22], optarg);
break;
case 'n':
func0(a3[17], optarg);
break;
case 'p':
func1(a3[1], (__int64)optarg);
break;
case 'q':
func1(a3[13], (__int64)optarg);
break;
case 's':
func0(a3[26], optarg);
break;
case 't':
func0(a3[25], optarg);
break;
case 'v':
func1(a3[9], (__int64)optarg);
break;
default:
func3(stderr, a3);
fatal_error("unrecognized command-line option or missing value (flags take 0 or 1)");
break;
}
}
}

original_code:
void process_command_line_args(int argc, char **argv,
          Mace_options opt)
{
  extern char *optarg;
  int c;
  while ((c = getopt(argc, argv,
      "n:N:m:t:s:b:O:M:p:P:v:L:G:H:I:J:K:T:R:i:q:Q:S:cf:g")) != (-1)) {
    switch (c) {
    case 'n':
      command_line_parm(opt->domain_size, optarg);
      break;
    case 'N':
      command_line_parm(opt->end_size, optarg);
      break;
    case 'm':
      command_line_parm(opt->max_models, optarg);
      break;
    case 't':
      command_line_parm(opt->max_seconds, optarg);
      break;
    case 's':
      command_line_parm(opt->max_seconds_per, optarg);
      break;
    case 'b':
      command_line_parm(opt->max_megs, optarg);
      break;
    case 'O':
      command_line_parm(opt->selection_order, optarg);
      break;
    case 'M':
      command_line_parm(opt->selection_measure, optarg);
      break;
    case 'P':
      command_line_flag(opt->print_models, optarg);
      break;
    case 'p':
      command_line_flag(opt->print_models_tabular, optarg);
      break;
    case 'v':
      command_line_flag(opt->verbose, optarg);
      break;
    case 'L':
      command_line_flag(opt->lnh, optarg);
      break;
    case 'G':
      command_line_flag(opt->negprop, optarg);
      break;
    case 'H':
      command_line_flag(opt->neg_assign, optarg);
      break;
    case 'I':
      command_line_flag(opt->neg_assign_near, optarg);
      break;
    case 'J':
      command_line_flag(opt->neg_elim, optarg);
      break;
    case 'K':
      command_line_flag(opt->neg_elim_near, optarg);
      break;
    case 'T':
      command_line_flag(opt->trace, optarg);
      break;
    case 'R':
      command_line_flag(opt->integer_ring, optarg);
      break;
    case 'i':
      command_line_parm(opt->increment, optarg);
      break;
    case 'q':
      command_line_flag(opt->iterate_primes, optarg);
      break;
    case 'Q':
      command_line_flag(opt->iterate_nonprimes, optarg);
      break;
    case 'S':
      command_line_flag(opt->skolems_last, optarg);
      break;
    case 'c':
    case 'f':
    case 'g':
      break;
    case '?':
    default:
      usage_message(stderr, opt);
      fatal_error("unrecognized command-line option or missing value (flags take 0 or 1)");
    }
  }
}

canonical_original_code:
void process_command_line_args(int argc, char **argv, struct mace_options *opt)
{
  extern char *optarg;
  int c;
  while ((c = getopt(argc, argv,
      "n:N:m:t:s:b:O:M:p:P:v:L:G:H:I:J:K:T:R:i:q:Q:S:cf:g")) != (-1)) {
    switch (c) {
    case 'n':
      command_line_parm(opt->domain_size, optarg);
      break;
    case 'N':
      command_line_parm(opt->end_size, optarg);
      break;
    case 'm':
      command_line_parm(opt->max_models, optarg);
      break;
    case 't':
      command_line_parm(opt->max_seconds, optarg);
      break;
    case 's':
      command_line_parm(opt->max_seconds_per, optarg);
      break;
    case 'b':
      command_line_parm(opt->max_megs, optarg);
      break;
    case 'O':
      command_line_parm(opt->selection_order, optarg);
      break;
    case 'M':
      command_line_parm(opt->selection_measure, optarg);
      break;
    case 'P':
      command_line_flag(opt->print_models, optarg);
      break;
    case 'p':
      command_line_flag(opt->print_models_tabular, optarg);
      break;
    case 'v':
      command_line_flag(opt->verbose, optarg);
      break;
    case 'L':
      command_line_flag(opt->lnh, optarg);
      break;
    case 'G':
      command_line_flag(opt->negprop, optarg);
      break;
    case 'H':
      command_line_flag(opt->neg_assign, optarg);
      break;
    case 'I':
      command_line_flag(opt->neg_assign_near, optarg);
      break;
    case 'J':
      command_line_flag(opt->neg_elim, optarg);
      break;
    case 'K':
      command_line_flag(opt->neg_elim_near, optarg);
      break;
    case 'T':
      command_line_flag(opt->trace, optarg);
      break;
    case 'R':
      command_line_flag(opt->integer_ring, optarg);
      break;
    case 'i':
      command_line_parm(opt->increment, optarg);
      break;
    case 'q':
      command_line_flag(opt->iterate_primes, optarg);
      break;
    case 'Q':
      command_line_flag(opt->iterate_nonprimes, optarg);
      break;
    case 'S':
      command_line_flag(opt->skolems_last, optarg);
      break;
    case 'c':
    case 'f':
    case 'g':
      break;
    case '?':
    default:
      usage_message(stderr, opt);
      fatal_error("unrecognized command-line option or missing value (flags take 0 or 1)");
    }
  }
}

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

variable_types: c int