decompiled_code:
__int64 __fastcall complex4_p2(__int64 a1, __int64 a2, _DWORD *a3)
{
unsigned int v3; // ebx
__int64 v5; // rbp
bool v6; // dl

v3 = 0;
if ( a1 != a2 )
{
if ( *(_BYTE *)(a2 + 4) )
{
v5 = 0LL;
do
{
v3 = complex4_p2(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * v5), a3);
v6 = *(unsigned __int8 *)(a2 + 4) > (int)v5++ + 1;
}
while ( v3 != 0 && v6 );
}
else
{
v3 = 1;
}
complex4_compare(a1, (unsigned int *)a2, a3);
}
return v3;
}

original_code:
static
BOOL complex4_p2(Term s, Term t, int *n)
{
  if (s == t)
    return FALSE;
  else {
    int i;
    BOOL go;
    for (i = 0, go = TRUE; i < ((t)->arity) && go; i++)
      go = complex4_p2(s, ((t)->args[i]), n);
    complex4_compare(s, t, n);
    return go;
  }
}

canonical_original_code:
static enum BOOL complex4_p2(struct term *s, struct term *t, int *n)
{
  if (s == t)
    return FALSE;
  else {
    int i;
    enum BOOL go;
    for (i = 0, go = TRUE; i < ((t)->arity) && go; i++)
      go = complex4_p2(s, ((t)->args[i]), n);
    complex4_compare(s, t, n);
    return go;
  }
}

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

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


repo: jessealama/ladr

original_code:
static
void complex4_p1(Term s, Term t, int *n)
{
  BOOL dummy;
  int i;
  for (i = 0; i < ((s)->arity); i++)
    complex4_p1(((s)->args[i]), t, n);
  dummy = complex4_p2(s, t, n);
}

canonical_original_code:
static void complex4_p1(struct term *s, struct term *t, int *n)
{
  enum BOOL dummy;
  int i;
  for (i = 0; i < ((s)->arity); i++)
    complex4_p1(((s)->args[i]), t, n);
  dummy = complex4_p2(s, t, n);
}

variable_types:
t
struct term *

variable_types:
n
int *

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

variable_types: i int

return_type: void

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


decompiled_code:
int *__fastcall complex4_devar(int *a1, unsigned int a2)
{
int *v2; // rbx
int v3; // edi
__int64 v4; // rbp
_QWORD *v5; // r12
__int64 v7; // rbp

v2 = a1;
v3 = *a1;
if ( v3 >= 0 )
{
v7 = get_rigid_term_dangerously(a2 + v3, 0LL);
free_term(v2);
v2 = (int *)v7;
}
else
{
v4 = 0LL;
if ( *((_BYTE *)v2 + 4) )
{
do
{
v5 = (_QWORD *)(*((_QWORD *)v2 + 1) + 8 * v4);
*v5 = complex4_devar(*v5, a2);
++v4;
}
while ( *((unsigned __int8 *)v2 + 4) > (int)v4 );
}
}
return v2;
}

canonical_decompiled_code:
int *__fastcall func6(int *a1, unsigned int a2)
{
int *v2; // rbx
int v3; // edi
__int64 v4; // rbp
_QWORD *v5; // r12
__int64 v7; // rbp

v2 = a1;
v3 = *a1;
if ( v3 >= 0 )
{
v7 = get_rigid_term_dangerously(a2 + v3, 0LL);
free_term(v2);
v2 = (int *)v7;
}
else
{
v4 = 0LL;
if ( *((_BYTE *)v2 + 4) )
{
do
{
v5 = (_QWORD *)(*((_QWORD *)v2 + 1) + 8 * v4);
*v5 = func6(*v5, a2);
++v4;
}
while ( *((unsigned __int8 *)v2 + 4) > (int)v4 );
}
}
return v2;
}

original_code:
static
Term complex4_devar(Term t, int base)
{
  if (((t)->private_symbol >= 0)) {
    Term new = get_rigid_term_dangerously(base + ((t)->private_symbol), 0);
    free_term(t);
    return new;
  }
  else {
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = complex4_devar(((t)->args[i]), base);
    return t;
  }
}

canonical_original_code:
static struct term *complex4_devar(struct term *t, int base)
{
  if (((t)->private_symbol >= 0)) {
    struct term *new = get_rigid_term_dangerously(base + ((t)->private_symbol), 0);
    free_term(t);
    return new;
  }
  else {
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = complex4_devar(((t)->args[i]), base);
    return t;
  }
}

variable_types: base int

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


decompiled_code:
int *__fastcall complex4_revar(int *a1, unsigned int a2)
{
int *v2; // rbp
int v3; // edi
__int64 v4; // rbx
int v5; // edi
__int64 v6; // rbx
_QWORD *v7; // r12

v2 = a1;
v3 = *a1;
if ( v3 >= 0 )
{
if ( !*((_BYTE *)v2 + 4) )
return v2;
v4 = 0LL;
goto LABEL_7;
}
v4 = 0LL;
if ( *((_BYTE *)v2 + 4) )
{
do
{
LABEL_7:
v7 = (_QWORD *)(*((_QWORD *)v2 + 1) + 8 * v4);
*v7 = complex4_revar(*v7, a2);
++v4;
}
while ( *((unsigned __int8 *)v2 + 4) > (int)v4 );
return v2;
}
v5 = -v3;
if ( v5 >= (int)a2 )
{
v6 = get_variable_term(v5 - a2);
free_term(v2);
v2 = (int *)v6;
}
return v2;
}

canonical_decompiled_code:
int *__fastcall func7(int *a1, unsigned int a2)
{
int *v2; // rbp
int v3; // edi
__int64 v4; // rbx
int v5; // edi
__int64 v6; // rbx
_QWORD *v7; // r12

v2 = a1;
v3 = *a1;
if ( v3 >= 0 )
{
if ( !*((_BYTE *)v2 + 4) )
return v2;
v4 = 0LL;
goto LABEL_7;
}
v4 = 0LL;
if ( *((_BYTE *)v2 + 4) )
{
do
{
LABEL_7:
v7 = (_QWORD *)(*((_QWORD *)v2 + 1) + 8 * v4);
*v7 = func7(*v7, a2);
++v4;
}
while ( *((unsigned __int8 *)v2 + 4) > (int)v4 );
return v2;
}
v5 = -v3;
if ( v5 >= (int)a2 )
{
v6 = get_variable_term(v5 - a2);
free_term(v2);
v2 = (int *)v6;
}
return v2;
}

original_code:
static
Term complex4_revar(Term t, int base)
{
  if (((t)->private_symbol < 0 && (t)->arity == 0) && (-((t)->private_symbol)) >= base) {
    Term var = get_variable_term((-((t)->private_symbol)) - base);
    free_term(t);
    return var;
  }
  else {
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = complex4_revar(((t)->args[i]), base);
    return t;
  }
}

canonical_original_code:
static struct term *complex4_revar(struct term *t, int base)
{
  if (((t)->private_symbol < 0 && (t)->arity == 0) && (-((t)->private_symbol)) >= base) {
    struct term *var = get_variable_term((-((t)->private_symbol)) - base);
    free_term(t);
    return var;
  }
  else {
    int i;
    for (i = 0; i < ((t)->arity); i++)
      ((t)->args[i]) = complex4_revar(((t)->args[i]), base);
    return t;
  }
}


decompiled_code:
double __fastcall clause_complexity(__int64 a1, int a2, int a3)
{
int *v4; // rbx
double v5; // rbp

v4 = (int *)lits_to_term();
v5 = term_complexity(v4, a2, a3);
free_lits_to_term(v4);
return v5;
}

canonical_decompiled_code:
double __fastcall func10(__int64 a1, int a2, int a3)
{
int *v4; // rbx
double v5; // rbp

v4 = (int *)lits_to_term();
v5 = func9(v4, a2, a3);
free_lits_to_term(v4);
return v5;
}

original_code:
double clause_complexity(Literals lits, int func, int adjustment)
{
  Term t = lits_to_term(lits);
  double x = term_complexity(t, func, adjustment);
  free_lits_to_term(t);
  return x;
}

canonical_original_code:
double clause_complexity(struct literals *lits, int func, int adjustment)
{
  struct term *t = lits_to_term(lits);
  double x = term_complexity(t, func, adjustment);
  free_lits_to_term(t);
  return x;
}

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

variable_types: func int

variable_types: adjustment int

variable_types: x double

return_type: double

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


username

decompiled_code:
char *username()
{
__uid_t v0; // eax
struct passwd *v1; // rax
char *v2; // rdx

v0 = getuid();
v1 = getpwuid(v0);
v2 = (char *)&unk_C0;
if ( v1 )
v2 = v1->pw_name;
return v2;
}

canonical_decompiled_code:
char *func0()
{
__uid_t v0; // eax
struct passwd *v1; // rax
char *v2; // rdx

v0 = getuid();
v1 = getpwuid(v0);
v2 = (char *)&unk_C0;
if ( v1 )
v2 = v1->pw_name;
return v2;
}

original_code:
char *username(void)
{
  struct passwd *p;
  p = getpwuid(getuid());
  return(p ? p->pw_name : "???");
}

canonical_original_code:
char *username()
{
  struct passwd *p;
  p = getpwuid(getuid());
  return(p ? p->pw_name : "???");
}

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *

return_type: char *


hostname

decompiled_code:
char *hostname()
{
if ( gethostname(host_0, 0x40uLL) )
strcpy(host_0, "???");
return host_0;
}

canonical_decompiled_code:
char *func1()
{
if ( gethostname(host_0, 0x40uLL) )
strcpy(host_0, "???");
return host_0;
}

original_code:
char *hostname(void)
{
  static char host[64];
  if (gethostname(host, 64) != 0)
    strcpy(host, "???");
  return(host);
}

canonical_original_code:
char *hostname()
{
  static char host[64];
  if (gethostname(host, 64) != 0)
    strcpy(host, "???");
  return(host);
}

variable_types:
host
char [64]


decompiled_code:
__pid_t my_process_id()
{
return getpid();
}

canonical_decompiled_code:
__pid_t func2()
{
return getpid();
}

original_code:
int my_process_id(void)
{
  return getpid();
}

canonical_original_code:
int my_process_id()
{
  return getpid();
}

return_type: int


decompiled_code:
__int64 get_bits()
{
return 64LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 64LL;
}

original_code:
int get_bits(void)
{
  return sizeof(long) == 8 && sizeof(void *) == 8 ? 64 : 32;
}

canonical_original_code:
int get_bits()
{
  return sizeof(long) == 8 && sizeof(void *) == 8 ? 64 : 32;
}


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

result = get_cmem(14LL);
++Chunk_gets;
return result;
}

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

result = get_cmem(14LL);
++Chunk_gets;
return result;
}

original_code:
static
Chunk get_chunk(void)
{
  Chunk p = get_cmem(((sizeof(struct chunk))%(sizeof(void *)) == 0 ? (sizeof(struct chunk))/(sizeof(void *)) : (sizeof(struct chunk))/(sizeof(void *)) + 1));
  Chunk_gets++;
  return(p);
}

canonical_original_code:
static struct chunk *get_chunk()
{
  struct chunk *p = get_cmem(((sizeof(struct chunk))%(sizeof(void *)) == 0 ? (sizeof(struct chunk))/(sizeof(void *)) : (sizeof(struct chunk))/(sizeof(void *)) + 1));
  Chunk_gets++;
  return(p);
}

variable_types: struct chunk { char s[100]; struct chunk *next; } *


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

result = free_mem(a1, 14LL);
++Chunk_frees;
return result;
}

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

result = free_mem(a1, 14LL);
++Chunk_frees;
return result;
}

original_code:
static
void free_chunk(Chunk p)
{
  free_mem(p, ((sizeof(struct chunk))%(sizeof(void *)) == 0 ? (sizeof(struct chunk))/(sizeof(void *)) : (sizeof(struct chunk))/(sizeof(void *)) + 1));
  Chunk_frees++;
}

canonical_original_code:
static void free_chunk(struct chunk *p)
{
  free_mem(p, ((sizeof(struct chunk))%(sizeof(void *)) == 0 ? (sizeof(struct chunk))/(sizeof(void *)) : (sizeof(struct chunk))/(sizeof(void *)) + 1));
  Chunk_frees++;
}

user_defined_types: struct chunk { char s[100]; struct chunk *next; }


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

result = free_mem(a1, 2LL);
++String_buf_frees;
return result;
}

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

result = free_mem(a1, 2LL);
++String_buf_frees;
return result;
}

original_code:
static
void free_string_buf(String_buf p)
{
  free_mem(p, ((sizeof(struct string_buf))%(sizeof(void *)) == 0 ? (sizeof(struct string_buf))/(sizeof(void *)) : (sizeof(struct string_buf))/(sizeof(void *)) + 1));
  String_buf_frees++;
}

canonical_original_code:
static void free_string_buf(struct string_buf *p)
{
  free_mem(p, ((sizeof(struct string_buf))%(sizeof(void *)) == 0 ? (sizeof(struct string_buf))/(sizeof(void *)) : (sizeof(struct string_buf))/(sizeof(void *)) + 1));
  String_buf_frees++;
}

variable_types: struct string_buf { struct chunk { char s[100]; struct chunk *next; } *first; int size; } *

user_defined_types: struct string_buf { struct chunk *first; int size; }


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

result = get_cmem(2LL);
++String_buf_gets;
return result;
}

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

result = get_cmem(2LL);
++String_buf_gets;
return result;
}

original_code:
String_buf get_string_buf(void)
{
  String_buf p = get_cmem(((sizeof(struct string_buf))%(sizeof(void *)) == 0 ? (sizeof(struct string_buf))/(sizeof(void *)) : (sizeof(struct string_buf))/(sizeof(void *)) + 1));
  String_buf_gets++;
  return(p);
}

canonical_original_code:
struct string_buf *get_string_buf()
{
  struct string_buf *p = get_cmem(((sizeof(struct string_buf))%(sizeof(void *)) == 0 ? (sizeof(struct string_buf))/(sizeof(void *)) : (sizeof(struct string_buf))/(sizeof(void *)) + 1));
  String_buf_gets++;
  return(p);
}

return_type: struct string_buf { struct chunk { char s[100]; struct chunk *next; } *first; int size; } *


decompiled_code:
int p_strbuf_mem()
{
return fprint_strbuf_mem(stdout, 1);
}

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

original_code:
void p_strbuf_mem()
{
  fprint_strbuf_mem(stdout, 1);
}


decompiled_code:
int __fastcall p_sb(__int64 *a1)
{
fprint_sb(stdout, a1);
putchar(10);
return fflush(stdout);
}

canonical_decompiled_code:
int __fastcall func7(__int64 *a1)
{
func6(stdout, a1);
putchar(10);
return fflush(stdout);
}

original_code:
void p_sb(String_buf sb)
{
  fprint_sb(stdout, sb);
  printf("\n");
  fflush(stdout);
}

canonical_original_code:
void p_sb(struct string_buf *sb)
{
  fprint_sb(stdout, sb);
  printf("\n");
  fflush(stdout);
}


original_code:
void sb_append(String_buf sb, char *s)
{
  int i;
  int n = sb->size;
  Chunk last = sb->first;
  while (last != ((void *)0) && last->next != ((void *)0))
    last = last->next;
  for (i = 0; s[i] != '\0'; i++) {
    if (n % 100 == 0) {
      Chunk new = get_chunk();
      if (last != ((void *)0))
 last->next = new;
      else
 sb->first = new;
      last = new;
    }
    last->s[n % 100] = s[i];
    n++;
  }
  sb->size = n;
}

canonical_original_code:
void sb_append(struct string_buf *sb, char *s)
{
  int i;
  int n = sb->size;
  struct chunk *last = sb->first;
  while (last != ((void *)0) && last->next != ((void *)0))
    last = last->next;
  for (i = 0; s[i] != '\0'; i++) {
    if (n % 100 == 0) {
      struct chunk *new = get_chunk();
      if (last != ((void *)0))
 last->next = new;
      else
 sb->first = new;
      last = new;
    }
    last->s[n % 100] = s[i];
    n++;
  }
  sb->size = n;
}

variable_types:
s
char *

variable_types: n int


decompiled_code:
__int64 __fastcall init_string_buf(_BYTE *a1)
{
__int64 v1; // rbx

v1 = get_string_buf();
sb_append(v1, a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func9(_BYTE *a1)
{
__int64 v1; // rbx

v1 = func3();
func8(v1, a1);
return v1;
}

original_code:
String_buf init_string_buf(char *s)
{
  String_buf p = get_string_buf();
  sb_append(p, s);
  return(p);
}

canonical_original_code:
struct string_buf *init_string_buf(char *s)
{
  struct string_buf *p = get_string_buf();
  sb_append(p, s);
  return(p);
}


decompiled_code:
__int64 __fastcall sb_append_char(__int64 a1, char a2)
{
int v2; // er12
__int64 i; // rbx
__int64 result; // rax
int v5; // ebp

v2 = *(_DWORD *)(a1 + 8);
for ( i = *(_QWORD *)a1; i; i = *(_QWORD *)(i + 104) )
{
if ( !*(_QWORD *)(i + 104) )
{
result = (unsigned int)(100 * (v2 / 100));
v5 = v2 % 100;
if ( !(v2 % 100) )
{
result = get_chunk();
*(_QWORD *)(i + 104) = result;
i = result;
}
goto LABEL_9;
}
}
result = (unsigned int)(100 * (v2 / 100));
v5 = v2 % 100;
if ( !(v2 % 100) )
{
result = get_chunk();
i = result;
*(_QWORD *)a1 = result;
}
LABEL_9:
*(_BYTE *)(i + v5) = a2;
*(_DWORD *)(a1 + 8) = v2 + 1;
return result;
}

original_code:
void sb_append_char(String_buf sb, char c)
{
  int n = sb->size;
  Chunk last = sb->first;
  while (last != ((void *)0) && last->next != ((void *)0))
    last = last->next;
  if (n % 100 == 0) {
    Chunk new = get_chunk();
    if (last != ((void *)0))
      last->next = new;
    else
      sb->first = new;
    last = new;
  }
  last->s[n % 100] = c;
  n++;
  sb->size = n;
}

canonical_original_code:
void sb_append_char(struct string_buf *sb, char c)
{
  int n = sb->size;
  struct chunk *last = sb->first;
  while (last != ((void *)0) && last->next != ((void *)0))
    last = last->next;
  if (n % 100 == 0) {
    struct chunk *new = get_chunk();
    if (last != ((void *)0))
      last->next = new;
    else
      sb->first = new;
    last = new;
  }
  last->s[n % 100] = c;
  n++;
  sb->size = n;
}

variable_types: c char


decompiled_code:
__int64 __fastcall sb_replace_char(__int64 a1, int a2, char a3)
{
__int64 result; // rax
__int64 v5; // rdx
int v6; // eax

result = a1;
if ( a2 >= 0 && *(_DWORD *)(result + 8) > a2 )
{
v5 = *(_QWORD *)result;
if ( a2 > 99 )
{
v6 = 0;
do
{
v5 = *(_QWORD *)(v5 + 104);
++v6;
}
while ( v6 < a2 / 100 );
}
result = (unsigned int)(100 * (a2 / 100));
*(_BYTE *)(v5 + a2 % 100) = a3;
}
return result;
}

original_code:
void sb_replace_char(String_buf sb, int i, char c)
{
  if (i < 0 || i >= sb->size)
    return;
  else {
    Chunk h = sb->first;
    int j;
    for (j = 0; j < i / 100; j++)
      h = h->next;
    h->s[i % 100] = c;
  }
}

canonical_original_code:
void sb_replace_char(struct string_buf *sb, int i, char c)
{
  if (i < 0 || i >= sb->size)
    return;
  else {
    struct chunk *h = sb->first;
    int j;
    for (j = 0; j < i / 100; j++)
      h = h->next;
    h->s[i % 100] = c;
  }
}

variable_types: j int


original_code:
char sb_char(String_buf sb, int n)
{
  if (n < 0 || n >= sb->size)
    return '\0';
  else {
    Chunk h = sb->first;
    int i;
    for (i = 0; i < n / 100; i++)
      h = h->next;
    return h->s[n % 100];
  }
}

canonical_original_code:
char sb_char(struct string_buf *sb, int n)
{
  if (n < 0 || n >= sb->size)
    return '\0';
  else {
    struct chunk *h = sb->first;
    int i;
    for (i = 0; i < n / 100; i++)
      h = h->next;
    return h->s[n % 100];
  }
}

return_type: char


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

for ( i = 0; ; ++i )
{
result = sb_char(a2, i);
if ( !(_BYTE)result )
break;
sb_append_char(a1, result);
}
return result;
}

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

for ( i = 0; ; ++i )
{
result = func12(a2, i);
if ( !(_BYTE)result )
break;
func10(a1, result);
}
return result;
}

original_code:
void sb_cat_copy(String_buf sb1, String_buf sb2)
{
  int i;
  char c;
  for (i = 0; (c = sb_char(sb2, i)); i++)
    sb_append_char(sb1, c);
}

canonical_original_code:
void sb_cat_copy(struct string_buf *sb1, struct string_buf *sb2)
{
  int i;
  char c;
  for (i = 0; (c = sb_char(sb2, i)); i++)
    sb_append_char(sb1, c);
}


decompiled_code:
__int64 __fastcall zap_string_buf(__int64 *a1)
{
__int64 v2; // rbx
__int64 v3; // rdi

v2 = *a1;
while ( v2 )
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 104);
free_chunk(v3);
}
return free_string_buf((__int64)a1);
}

original_code:
void zap_string_buf(String_buf sb)
{
  Chunk curr, prev;
  curr = sb->first;
  while (curr != ((void *)0)) {
    prev = curr;
    curr = curr->next;
    free_chunk(prev);
  }
  free_string_buf(sb);
}

canonical_original_code:
void zap_string_buf(struct string_buf *sb)
{
  struct chunk *curr; struct chunk *prev;
  curr = sb->first;
  while (curr != ((void *)0)) {
    prev = curr;
    curr = curr->next;
    free_chunk(prev);
  }
  free_string_buf(sb);
}


decompiled_code:
__int64 __fastcall sb_cat(__int64 a1, __int64 *a2)
{
sb_cat_copy(a1, a2);
return zap_string_buf(a2);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 *a2)
{
func13(a1, a2);
return func14(a2);
}

original_code:
void sb_cat(String_buf sb1, String_buf sb2)
{
  sb_cat_copy(sb1, sb2);
  zap_string_buf(sb2);
}

canonical_original_code:
void sb_cat(struct string_buf *sb1, struct string_buf *sb2)
{
  sb_cat_copy(sb1, sb2);
  zap_string_buf(sb2);
}


decompiled_code:
__int64 __fastcall sb_size(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

original_code:
int sb_size(String_buf sb)
{
  return sb->size;
}

canonical_original_code:
int sb_size(struct string_buf *sb)
{
  return sb->size;
}


decompiled_code:
void __fastcall sb_append_int(__int64 a1, unsigned int a2)
{
_BYTE *v2; // rax
__int64 v3; // [rsp+0h] [rbp-28h] BYREF

v2 = (_BYTE *)int_to_str(a2, &v3, 25LL);
sb_append(a1, v2);
}

canonical_decompiled_code:
void __fastcall func17(__int64 a1, unsigned int a2)
{
_BYTE *v2; // rax
__int64 v3; // [rsp+0h] [rbp-28h] BYREF

v2 = (_BYTE *)int_to_str(a2, &v3, 25LL);
func8(a1, v2);
}

original_code:
void sb_append_int(String_buf sb, int i)
{
  char s[25];
  sb_append(sb, int_to_str(i, s, 25));
}

canonical_original_code:
void sb_append_int(struct string_buf *sb, int i)
{
  char s[25];
  sb_append(sb, int_to_str(i, s, 25));
}

variable_types:
s
char [25]


decompiled_code:
__int64 __fastcall nterm_id(__int64 a1)
{
unsigned int v1; // esi
__int64 v2; // rax
int v3; // ecx
int v4; // edx

v1 = *(_DWORD *)(*(_QWORD *)(Sn_to_mace_sn + 8LL * -*(_DWORD *)a1) + 16LL);
LODWORD(v2) = *(unsigned __int8 *)(a1 + 4) - 1;
if ( (int)v2 >= 0 )
{
v2 = (int)v2;
v3 = 1;
do
{
v4 = **(_DWORD **)(*(_QWORD *)(a1 + 8) + 8 * v2);
if ( v4 >= 0 )
v1 += v3 * v4;
v3 *= Domain_size;
--v2;
}
while ( (int)v2 >= 0 );
}
return v1;
}

original_code:
static
int nterm_id(Term t)
{
  int id = Sn_to_mace_sn[(-((t)->private_symbol))]->base;
  int mult = 1;
  int i;
  for (i = ((t)->arity)-1; i >= 0; i--) {
    if (((((t)->args[i]))->private_symbol >= 0))
      id += ((((t)->args[i]))->private_symbol) * mult;
    mult *= Domain_size;
  }
  return id;
}

canonical_original_code:
static int nterm_id(struct term *t)
{
  int id = Sn_to_mace_sn[(-((t)->private_symbol))]->base;
  int mult = 1;
  int i;
  for (i = ((t)->arity)-1; i >= 0; i--) {
    if (((((t)->args[i]))->private_symbol >= 0))
      id += ((((t)->args[i]))->private_symbol) * mult;
    mult *= Domain_size;
  }
  return id;
}

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

variable_types: mult int


decompiled_code:
__int64 __fastcall id2val(int a1)
{
unsigned int *v1; // rax
__int64 result; // rax

v1 = *(unsigned int **)(Cells + 56LL * a1 + 16);
if ( v1 )
result = *v1;
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
unsigned int *v1; // rax
__int64 result; // rax

v1 = *(unsigned int **)(Cells + 56LL * a1 + 16);
if ( v1 )
result = *v1;
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
static int id2val(int id)
{
  return (Cells[id].value == ((void *)0) ? -1 : ((Cells[id].value)->private_symbol));
}


decompiled_code:
// attributes: thunk
__int64 __fastcall f0_val(int a1)
{
return id2val(a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return func0(a1);
}

original_code:
static
int f0_val(int base)
{
  int id = (base);
  return id2val(id);
}

variable_types: base int


decompiled_code:
__int64 __fastcall f1_val(int a1, int a2)
{
return id2val(a2 + a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
return func0(a2 + a1);
}

original_code:
static
int f1_val(int base, int i)
{
  int id = (base) + (i);
  return id2val(id);
}

variable_types: i int


decompiled_code:
__int64 __fastcall f2_val(int a1, int a2, int a3)
{
return id2val(a1 + Domain_size * a2 + a3);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2, int a3)
{
return func0(a1 + Domain_size * a2 + a3);
}

original_code:
static
int f2_val(int base, int i, int j)
{
  int id = (base) + (i)*Domain_size + (j);
  return id2val(id);
}


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

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

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

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

original_code:
static
int eterms_count(Term t)
{
  return (t == ((void *)0) ? 0 : 1 + eterms_count(t->u.vp));
}

canonical_original_code:
static int eterms_count(struct term *t)
{
  return (t == ((void *)0) ? 0 : 1 + eterms_count(t->u.vp));
}


decompiled_code:
void __fastcall p_model(int a1, double a2)
{
int v2; // ebx
unsigned int *v3; // rbp
const char *v4; // r15
const char *v5; // r13
const char *v6; // r14
int m; // er12
int n; // er12
int ii; // er13
const char *v10; // r15
const char *v11; // r14
const char *v12; // r13
int k; // er12
int v14; // eax
int i; // er12
int j; // er12
int jj; // er12
int v18; // eax
int v19; // er14
unsigned int v20; // er15
int l; // er13
__int64 v22; // r12
unsigned int *v23; // rax
const char *v24; // r15
unsigned int v25; // esi
int v26; // eax
const char *v27; // [rsp+0h] [rbp-48h]

v2 = Domain_size;
if ( a1 )
{
print_separator(stdout, "MODEL", 1LL);
user_seconds();
printf("\n%% Model %d at %.2f seconds.\n", Total_models, a2);
v3 = (unsigned int *)Symbols;
if ( !Symbols )
goto LABEL_5;
while ( 1 )
{
LABEL_42:
v24 = (const char *)sn_to_str(*v3);
v27 = v24;
if ( v3[5] != 1 )
{
v25 = v3[2];
if ( v25 )
{
if ( v25 == 1 )
{
if ( v2 > 10 )
{
v10 = (const char *)&unk_E1F;
v11 = "---";
v12 = "%3d";
goto LABEL_23;
}
if ( v2 > 0 )
{
v10 = " -";
v11 = "--";
v12 = "%2d";
do
{
LABEL_23:
printf("\n %s :\n", v27);
printf(" ");
for ( i = 0; i < v2; ++i )
printf(v12, (unsigned int)i);
printf("\n ---");
for ( j = 0; j < v2; ++j )
printf(v11);
printf("\n ");
for ( k = 0; k < v2; ++k )
{
v14 = f1_val(v3[4], k);
if ( v14 < 0 )
printf(v10);
else
printf(v12, (unsigned int)v14);
}
putchar(10);
}
while ( v2 > v2 - 1 + 2 );
goto LABEL_41;
}
}
else
{
if ( v25 != 2 )
{
v19 = int_power(Domain_size);
v20 = variable_style();
set_variable_style(2LL);
if ( v19 > 0 )
{
for ( l = 0; l != v19; ++l )
{
v22 = 56LL * (int)(v3[4] + l);
fwrite_term(stdout, *(_QWORD *)(Cells + v22 + 8));
v23 = *(unsigned int **)(Cells + v22 + 16);
if ( v23 )
printf(" = %d.\n", *v23);
else
puts(" = -.");
}
}
set_variable_style(v20);
goto LABEL_41;
}
if ( v2 > 10 )
{
printf("\n %s :\n", v24);
printf(" |");
v4 = (const char *)&unk_E1F;
v5 = "---";
v6 = "%3d";
LABEL_11:
for ( m = 0; m < v2; ++m )
printf(v6, (unsigned int)m);
printf("\n --+");
for ( n = 0; n < v2; ++n )
printf(v5);
putchar(10);
for ( ii = 0; ii < v2; ++ii )
{
printf("%5d |", (unsigned int)ii);
for ( jj = 0; jj < v2; ++jj )
{
v18 = f2_val(v3[4], ii, jj);
if ( v18 < 0 )
printf(v4);
else
printf(v6, (unsigned int)v18);
}
putchar(10);
}
goto LABEL_41;
}
printf("\n %s :\n", v24);
printf(" |");
if ( v2 > 0 )
{
v4 = " -";
v5 = "--";
v6 = "%2d";
goto LABEL_11;
}
printf("\n --+");
putchar(10);
}
}
else
{
v26 = f0_val(v3[4]);
if ( v26 < 0 )
printf("\n %s : -\n", v24);
else
printf("\n %s : %d\n", v24, (unsigned int)v26);
}
}
LABEL_41:
v3 = (unsigned int *)*((_QWORD *)v3 + 3);
if ( !v3 )
{
if ( !a1 )
return;
LABEL_5:
print_separator(stdout, "end of model", 1LL);
return;
}
}
}
v3 = (unsigned int *)Symbols;
if ( Symbols )
goto LABEL_42;
}

canonical_decompiled_code:
void __fastcall func5(int a1, double a2)
{
int v2; // ebx
unsigned int *v3; // rbp
const char *v4; // r15
const char *v5; // r13
const char *v6; // r14
int m; // er12
int n; // er12
int ii; // er13
const char *v10; // r15
const char *v11; // r14
const char *v12; // r13
int k; // er12
int v14; // eax
int i; // er12
int j; // er12
int jj; // er12
int v18; // eax
int v19; // er14
unsigned int v20; // er15
int l; // er13
__int64 v22; // r12
unsigned int *v23; // rax
const char *v24; // r15
unsigned int v25; // esi
int v26; // eax
const char *v27; // [rsp+0h] [rbp-48h]

v2 = Domain_size;
if ( a1 )
{
print_separator(stdout, "MODEL", 1LL);
user_seconds();
printf("\n%% Model %d at %.2f seconds.\n", Total_models, a2);
v3 = (unsigned int *)Symbols;
if ( !Symbols )
goto LABEL_5;
while ( 1 )
{
LABEL_42:
v24 = (const char *)sn_to_str(*v3);
v27 = v24;
if ( v3[5] != 1 )
{
v25 = v3[2];
if ( v25 )
{
if ( v25 == 1 )
{
if ( v2 > 10 )
{
v10 = (const char *)&unk_E1F;
v11 = "---";
v12 = "%3d";
goto LABEL_23;
}
if ( v2 > 0 )
{
v10 = " -";
v11 = "--";
v12 = "%2d";
do
{
LABEL_23:
printf("\n %s :\n", v27);
printf(" ");
for ( i = 0; i < v2; ++i )
printf(v12, (unsigned int)i);
printf("\n ---");
for ( j = 0; j < v2; ++j )
printf(v11);
printf("\n ");
for ( k = 0; k < v2; ++k )
{
v14 = func2(v3[4], k);
if ( v14 < 0 )
printf(v10);
else
printf(v12, (unsigned int)v14);
}
putchar(10);
}
while ( v2 > v2 - 1 + 2 );
goto LABEL_41;
}
}
else
{
if ( v25 != 2 )
{
v19 = int_power(Domain_size);
v20 = variable_style();
set_variable_style(2LL);
if ( v19 > 0 )
{
for ( l = 0; l != v19; ++l )
{
v22 = 56LL * (int)(v3[4] + l);
fwrite_term(stdout, *(_QWORD *)(Cells + v22 + 8));
v23 = *(unsigned int **)(Cells + v22 + 16);
if ( v23 )
printf(" = %d.\n", *v23);
else
puts(" = -.");
}
}
set_variable_style(v20);
goto LABEL_41;
}
if ( v2 > 10 )
{
printf("\n %s :\n", v24);
printf(" |");
v4 = (const char *)&unk_E1F;
v5 = "---";
v6 = "%3d";
LABEL_11:
for ( m = 0; m < v2; ++m )
printf(v6, (unsigned int)m);
printf("\n --+");
for ( n = 0; n < v2; ++n )
printf(v5);
putchar(10);
for ( ii = 0; ii < v2; ++ii )
{
printf("%5d |", (unsigned int)ii);
for ( jj = 0; jj < v2; ++jj )
{
v18 = func3(v3[4], ii, jj);
if ( v18 < 0 )
printf(v4);
else
printf(v6, (unsigned int)v18);
}
putchar(10);
}
goto LABEL_41;
}
printf("\n %s :\n", v24);
printf(" |");
if ( v2 > 0 )
{
v4 = " -";
v5 = "--";
v6 = "%2d";
goto LABEL_11;
}
printf("\n --+");
putchar(10);
}
}
else
{
v26 = func1(v3[4]);
if ( v26 < 0 )
printf("\n %s : -\n", v24);
else
printf("\n %s : %d\n", v24, (unsigned int)v26);
}
}
LABEL_41:
v3 = (unsigned int *)*((_QWORD *)v3 + 3);
if ( !v3 )
{
if ( !a1 )
return;
LABEL_5:
print_separator(stdout, "end of model", 1LL);
return;
}
}
}
v3 = (unsigned int *)Symbols;
if ( Symbols )
goto LABEL_42;
}

original_code:
void p_model(BOOL print_head)
{
  Symbol_data p;
  int n = Domain_size;
  if (print_head) {
    print_separator(stdout, "MODEL", TRUE);
    printf("\n%% Model %d at %.2f seconds.\n",
    Total_models, user_seconds());
  }
  for (p = Symbols; p != ((void *)0); p = p->next) {
    char *name = sn_to_str(p->sn);
    if (p->attribute != EQUALITY_SYMBOL) {
      if (p->arity == 0) {
 int v = f0_val(p->base);
 if (v < 0)
   printf("\n %s : -\n", name);
 else
   printf("\n %s : %d\n", name, v);
      }
      else if (p->arity == 1) {
 char *s1 = n <= 10 ? "%2d" : "%3d";
 char *s2 = n <= 10 ? "--" : "---";
 char *s3 = n <= 10 ? " -" : "  -";
 int i;
 for (i = 0; i < n; i++) {
   printf("\n %s :\n", name);
   printf("       ");
   for (i = 0; i < n; i++)
     printf(s1, i);
   printf("\n    ---");
   for (i = 0; i < n; i++)
     printf(s2);
   printf("\n       ");
   for (i = 0; i < n; i++) {
     int v = f1_val(p->base, i);
     if (v < 0)
       printf(s3);
     else
       printf(s1, v);
   }
   printf("\n");
 }
      }
      else if (p->arity == 2) {
 char *s1 = n <= 10 ? "%2d" : "%3d";
 char *s2 = n <= 10 ? "--" : "---";
 char *s3 = n <= 10 ? " -" : "  -";
 int i, j;
 printf("\n %s :\n", name);
 printf("      |");
 for (i = 0; i < n; i++)
   printf(s1, i);
 printf("\n    --+");
 for (i = 0; i < n; i++)
   printf(s2);
 printf("\n");
 for (i = 0; i < n; i++) {
   printf("%5d |", i);
   for (j = 0; j < n; j++) {
     int v = f2_val(p->base, i, j);
     if (v < 0)
       printf(s3);
     else
       printf(s1, v);
   }
   printf("\n");
 }
      }
      else {
 int n = int_power(Domain_size, p->arity);
 int i;
 Variable_style save_style = variable_style();
 set_variable_style(INTEGER_STYLE);
 for (i = 0; i < n; i++) {
   int id = p->base + i;
   fwrite_term(stdout, Cells[id].eterm);
   if (Cells[id].value == ((void *)0))
     printf(" = -.\n");
   else
     printf(" = %d.\n", ((Cells[id].value)->private_symbol));
 }
 set_variable_style(save_style);
      }
    }
  }
  if (print_head)
    print_separator(stdout, "end of model", TRUE);
}

canonical_original_code:
void p_model(enum BOOL print_head)
{
  struct symbol_data *p;
  int n = Domain_size;
  if (print_head) {
    print_separator(stdout, "MODEL", TRUE);
    printf("\n%% Model %d at %.2f seconds.\n",
    Total_models, user_seconds());
  }
  for (p = Symbols; p != ((void *)0); p = p->next) {
    char *name = sn_to_str(p->sn);
    if (p->attribute != EQUALITY_SYMBOL) {
      if (p->arity == 0) {
 int v = f0_val(p->base);
 if (v < 0)
   printf("\n %s : -\n", name);
 else
   printf("\n %s : %d\n", name, v);
      }
      else if (p->arity == 1) {
 char *s1 = n <= 10 ? "%2d" : "%3d";
 char *s2 = n <= 10 ? "--" : "---";
 char *s3 = n <= 10 ? " -" : "  -";
 int i;
 for (i = 0; i < n; i++) {
   printf("\n %s :\n", name);
   printf("       ");
   for (i = 0; i < n; i++)
     printf(s1, i);
   printf("\n    ---");
   for (i = 0; i < n; i++)
     printf(s2);
   printf("\n       ");
   for (i = 0; i < n; i++) {
     int v = f1_val(p->base, i);
     if (v < 0)
       printf(s3);
     else
       printf(s1, v);
   }
   printf("\n");
 }
      }
      else if (p->arity == 2) {
 char *s1 = n <= 10 ? "%2d" : "%3d";
 char *s2 = n <= 10 ? "--" : "---";
 char *s3 = n <= 10 ? " -" : "  -";
 int i; int j;
 printf("\n %s :\n", name);
 printf("      |");
 for (i = 0; i < n; i++)
   printf(s1, i);
 printf("\n    --+");
 for (i = 0; i < n; i++)
   printf(s2);
 printf("\n");
 for (i = 0; i < n; i++) {
   printf("%5d |", i);
   for (j = 0; j < n; j++) {
     int v = f2_val(p->base, i, j);
     if (v < 0)
       printf(s3);
     else
       printf(s1, v);
   }
   printf("\n");
 }
      }
      else {
 int n = int_power(Domain_size, p->arity);
 int i;
 enum Variable_style save_style = variable_style();
 set_variable_style(INTEGER_STYLE);
 for (i = 0; i < n; i++) {
   int id = p->base + i;
   fwrite_term(stdout, Cells[id].eterm);
   if (Cells[id].value == ((void *)0))
     printf(" = -.\n");
   else
     printf(" = %d.\n", ((Cells[id].value)->private_symbol));
 }
 set_variable_style(save_style);
      }
    }
  }
  if (print_head)
    print_separator(stdout, "end of model", TRUE);
}

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

variable_types:
name
char *

variable_types: v int

variable_types: enum Variable_style { STANDARD_STYLE=0, PROLOG_STYLE=1, INTEGER_STYLE=2 }


decompiled_code:
__int64 interp_term()
{
__int64 v0; // r15
unsigned int *v1; // rbp
__int64 v2; // rbx
unsigned int v3; // eax
__int64 v5; // rax
__int64 v6; // r12
int v7; // ebx
__int64 v8; // r13
const char *v9; // rdi
unsigned int v10; // eax
__int64 v11; // rax
__int64 v12; // r14
__int64 v13; // rbx
_QWORD *v14; // r12
int v15; // ebx

v0 = get_nil_term();
v1 = (unsigned int *)Symbols;
if ( Symbols )
{
do
{
if ( v1[5] != 1 )
{
v12 = get_rigid_term_dangerously(*v1, v1[2]);
if ( (int)v1[2] > 0 )
{
v13 = 0LL;
do
{
v14 = (_QWORD *)(*(_QWORD *)(v12 + 8) + 8 * v13);
*v14 = get_variable_term((unsigned int)v13++);
}
while ( (int)v1[2] > (int)v13 );
}
v15 = int_power(Domain_size);
v6 = get_nil_term();
v7 = v15 - 1;
if ( v7 >= 0 )
{
do
{
v8 = 56LL * (int)(v1[4] + v7);
if ( !*(_QWORD *)(Cells + v8 + 16) )
fatal_error("interp_term, incomplete interpretation");
v5 = nat_to_term(**(unsigned int **)(Cells + v8 + 16));
v6 = listterm_cons(v5, v6);
--v7;
}
while ( v7 != -1 );
}
v9 = "relation";
if ( !v1[3] )
v9 = "function";
v10 = str_to_sn(v9, 2LL);
v11 = build_binary_term(v10, v12, v6);
v0 = listterm_cons(v11, v0);
}
v1 = (unsigned int *)*((_QWORD *)v1 + 3);
}
while ( v1 );
}
v2 = nat_to_term(Domain_size);
v3 = str_to_sn("interpretation", 2LL);
return build_binary_term(v3, v2, v0);
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // r15
unsigned int *v1; // rbp
__int64 v2; // rbx
unsigned int v3; // eax
__int64 v5; // rax
__int64 v6; // r12
int v7; // ebx
__int64 v8; // r13
const char *v9; // rdi
unsigned int v10; // eax
__int64 v11; // rax
__int64 v12; // r14
__int64 v13; // rbx
_QWORD *v14; // r12
int v15; // ebx

v0 = get_nil_term();
v1 = (unsigned int *)Symbols;
if ( Symbols )
{
do
{
if ( v1[5] != 1 )
{
v12 = get_rigid_term_dangerously(*v1, v1[2]);
if ( (int)v1[2] > 0 )
{
v13 = 0LL;
do
{
v14 = (_QWORD *)(*(_QWORD *)(v12 + 8) + 8 * v13);
*v14 = get_variable_term((unsigned int)v13++);
}
while ( (int)v1[2] > (int)v13 );
}
v15 = int_power(Domain_size);
v6 = get_nil_term();
v7 = v15 - 1;
if ( v7 >= 0 )
{
do
{
v8 = 56LL * (int)(v1[4] + v7);
if ( !*(_QWORD *)(Cells + v8 + 16) )
fatal_error("interp_term, incomplete interpretation");
v5 = nat_to_term(**(unsigned int **)(Cells + v8 + 16));
v6 = listterm_cons(v5, v6);
--v7;
}
while ( v7 != -1 );
}
v9 = "relation";
if ( !v1[3] )
v9 = "function";
v10 = str_to_sn(v9, 2LL);
v11 = build_binary_term(v10, v12, v6);
v0 = listterm_cons(v11, v0);
}
v1 = (unsigned int *)*((_QWORD *)v1 + 3);
}
while ( v1 );
}
v2 = nat_to_term(Domain_size);
v3 = str_to_sn("interpretation", 2LL);
return build_binary_term(v3, v2, v0);
}

original_code:
Term interp_term(void)
{
  Symbol_data s;
  Term symlist = get_nil_term();
  for (s = Symbols; s != ((void *)0); s = s->next) {
    if (s->attribute != EQUALITY_SYMBOL) {
      int i, n;
      Term entry, symterm, tableterm;
      symterm = get_rigid_term_dangerously(s->sn, s->arity);
      for (i = 0; i < s->arity; i++)
 ((symterm)->args[i]) = get_variable_term(i);
      n = int_power(Domain_size, s->arity);
      tableterm = get_nil_term();
      for (i = n-1; i >= 0; i--) {
 int id = s->base + i;
 Term it;
 if (Cells[id].value == ((void *)0))
   fatal_error("interp_term, incomplete interpretation");
 it = nat_to_term(((Cells[id].value)->private_symbol));
 tableterm = listterm_cons(it, tableterm);
      }
      entry = build_binary_term(str_to_sn(s->type == FUNCTION ? "function" : "relation", 2),
    symterm, tableterm);
      symlist = listterm_cons(entry, symlist);
    }
  }
  return build_binary_term(str_to_sn("interpretation", 2),
      nat_to_term(Domain_size),
      symlist);
}

canonical_original_code:
struct term *interp_term()
{
  struct symbol_data *s;
  struct term *symlist = get_nil_term();
  for (s = Symbols; s != ((void *)0); s = s->next) {
    if (s->attribute != EQUALITY_SYMBOL) {
      int i; int n;
      struct term *entry; struct term *symterm; struct term *tableterm;
      symterm = get_rigid_term_dangerously(s->sn, s->arity);
      for (i = 0; i < s->arity; i++)
 ((symterm)->args[i]) = get_variable_term(i);
      n = int_power(Domain_size, s->arity);
      tableterm = get_nil_term();
      for (i = n-1; i >= 0; i--) {
 int id = s->base + i;
 struct term *it;
 if (Cells[id].value == ((void *)0))
   fatal_error("interp_term, incomplete interpretation");
 it = nat_to_term(((Cells[id].value)->private_symbol));
 tableterm = listterm_cons(it, tableterm);
      }
      entry = build_binary_term(str_to_sn(s->type == FUNCTION ? "function" : "relation", 2),
    symterm, tableterm);
      symlist = listterm_cons(entry, symlist);
    }
  }
  return build_binary_term(str_to_sn("interpretation", 2),
      nat_to_term(Domain_size),
      symlist);
}

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


decompiled_code:
int __fastcall p_matom(__int64 a1)
{
int v1; // edx

if ( a1 )
{
v1 = *(unsigned __int8 *)(a1 + 5);
if ( _bittest(&v1, Negation_flag) )
{
if ( Eq_sn + *(_DWORD *)a1 )
{
printf("~(");
fwrite_term(stdout, a1);
putchar(41);
}
else
{
fwrite_term(stdout, **(_QWORD **)(a1 + 8));
printf(" != ");
fwrite_term(stdout, *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
}
}
else
{
fwrite_term(stdout, a1);
}
}
else
{
printf("(NULL)");
}
return puts(".");
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
int v1; // edx

if ( a1 )
{
v1 = *(unsigned __int8 *)(a1 + 5);
if ( _bittest(&v1, Negation_flag) )
{
if ( Eq_sn + *(_DWORD *)a1 )
{
printf("~(");
fwrite_term(stdout, a1);
putchar(41);
}
else
{
fwrite_term(stdout, **(_QWORD **)(a1 + 8));
printf(" != ");
fwrite_term(stdout, *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL));
}
}
else
{
fwrite_term(stdout, a1);
}
}
else
{
printf("(NULL)");
}
return puts(".");
}

original_code:
void p_matom(Term atom)
{
  if (atom == ((void *)0))
    printf("(NULL)");
  else if (!(((atom->private_flags & 1 << Negation_flag))))
    fwrite_term(stdout, atom);
  else if (((-(((Term) atom)->private_symbol)) == Eq_sn)){
    fwrite_term(stdout, ((atom)->args[0]));
    printf(" != ");
    fwrite_term(stdout, ((atom)->args[1]));
  }
  else {
    printf("~(");
    fwrite_term(stdout, atom);
    printf(")");
  }
  printf(".\n");
}

canonical_original_code:
void p_matom(struct term *atom)
{
  if (atom == ((void *)0))
    printf("(NULL)");
  else if (!(((atom->private_flags & 1 << Negation_flag))))
    fwrite_term(stdout, atom);
  else if (((-(((struct term *) atom)->private_symbol)) == Eq_sn)){
    fwrite_term(stdout, ((atom)->args[0]));
    printf(" != ");
    fwrite_term(stdout, ((atom)->args[1]));
  }
  else {
    printf("~(");
    fwrite_term(stdout, atom);
    printf(")");
  }
  printf(".\n");
}


decompiled_code:
int __fastcall p_mclause(__int64 a1)
{
int result; // eax
__int64 v2; // rbx
__int64 v3; // r12
int v4; // edx

result = printf(
"numlits=%d, active=%ld, subsumed=%d: ",
*(unsigned int *)(a1 + 20),
*(_QWORD *)(a1 + 24),
*(unsigned int *)(a1 + 16));
if ( *(int *)(a1 + 20) > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(*(_QWORD *)a1 + 8 * v2);
v4 = *(unsigned __int8 *)(v3 + 5);
if ( _bittest(&v4, Negation_flag) )
{
printf("~(");
fwrite_term(stdout, v3);
putchar(41);
}
else
{
fwrite_term(stdout, *(_QWORD *)(*(_QWORD *)a1 + 8 * v2));
}
if ( *(_DWORD *)(a1 + 20) - 1 <= (int)v2 )
result = puts(".");
else
result = printf(" | ");
++v2;
}
while ( *(_DWORD *)(a1 + 20) > (int)v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
int result; // eax
__int64 v2; // rbx
__int64 v3; // r12
int v4; // edx

result = printf(
"numlits=%d, active=%ld, subsumed=%d: ",
*(unsigned int *)(a1 + 20),
*(_QWORD *)(a1 + 24),
*(unsigned int *)(a1 + 16));
if ( *(int *)(a1 + 20) > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(*(_QWORD *)a1 + 8 * v2);
v4 = *(unsigned __int8 *)(v3 + 5);
if ( _bittest(&v4, Negation_flag) )
{
printf("~(");
fwrite_term(stdout, v3);
putchar(41);
}
else
{
fwrite_term(stdout, *(_QWORD *)(*(_QWORD *)a1 + 8 * v2));
}
if ( *(_DWORD *)(a1 + 20) - 1 <= (int)v2 )
result = puts(".");
else
result = printf(" | ");
++v2;
}
while ( *(_DWORD *)(a1 + 20) > (int)v2 );
}
return result;
}

original_code:
void p_mclause(Mclause c)
{
  int i;
  printf("numlits=%d, active=%ld, subsumed=%d: ",
  c->numlits, c->u.active, c->subsumed);
  for (i = 0; i < c->numlits; i++) {
    Term atom = ((c)->lits[i]);
    if (!(((atom->private_flags & 1 << Negation_flag))))
      fwrite_term(stdout, atom);
    else {
      printf("~(");
      fwrite_term(stdout, atom);
      printf(")");
    }
    if (i < c->numlits-1)
      printf(" | ");
    else
      printf(".\n");
  }
}

canonical_original_code:
void p_mclause(struct mclause *c)
{
  int i;
  printf("numlits=%d, active=%ld, subsumed=%d: ",
  c->numlits, c->u.active, c->subsumed);
  for (i = 0; i < c->numlits; i++) {
    struct term *atom = ((c)->lits[i]);
    if (!(((atom->private_flags & 1 << Negation_flag))))
      fwrite_term(stdout, atom);
    else {
      printf("~(");
      fwrite_term(stdout, atom);
      printf(")");
    }
    if (i < c->numlits-1)
      printf(" | ");
    else
      printf(".\n");
  }
}

variable_types: struct mclause { struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } **lits; struct mclause *next; enum BOOL { FALSE=0, TRUE=1 } subsumed; int numlits; union { long active; void *for_padding_only; } u; } *

user_defined_types: struct mclause { struct term **lits; struct mclause *next; enum BOOL subsumed; int numlits; union { long active; void *for_padding_only; } u; }


decompiled_code:
int p_eterms()
{
int result; // eax
__int64 v1; // r12
unsigned int v2; // ebp
__int64 i; // rbx
__int64 v4; // r13
unsigned int v5; // ebx
__int64 v6; // rsi

result = puts("\n------- Cells --------");
if ( Number_of_cells > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
v4 = *(_QWORD *)(Cells + v1 + 24);
result = eterms_count(v4);
v5 = result;
if ( result > 0 )
{
fwrite_term(stdout, v4);
printf(": %d occ, id=%d, val=", v5, v2);
v6 = *(_QWORD *)(Cells + v1 + 16);
if ( v6 )
fwrite_term(stdout, v6);
else
printf("NULL");
printf(", pvals=");
for ( i = 0LL; (int)id_to_domain_size(v2) > (int)i; ++i )
{
if ( *(_QWORD *)(*(_QWORD *)(Cells + v1 + 32) + 8 * i) )
printf("%2d", (unsigned int)i);
else
printf(" -");
}
result = putchar(10);
}
++v2;
v1 += 56LL;
}
while ( Number_of_cells > (int)v2 );
}
return result;
}

canonical_decompiled_code:
int func10()
{
int result; // eax
__int64 v1; // r12
unsigned int v2; // ebp
__int64 i; // rbx
__int64 v4; // r13
unsigned int v5; // ebx
__int64 v6; // rsi

result = puts("\n------- Cells --------");
if ( Number_of_cells > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
v4 = *(_QWORD *)(Cells + v1 + 24);
result = func4(v4);
v5 = result;
if ( result > 0 )
{
fwrite_term(stdout, v4);
printf(": %d occ, id=%d, val=", v5, v2);
v6 = *(_QWORD *)(Cells + v1 + 16);
if ( v6 )
fwrite_term(stdout, v6);
else
printf("NULL");
printf(", pvals=");
for ( i = 0LL; (int)id_to_domain_size(v2) > (int)i; ++i )
{
if ( *(_QWORD *)(*(_QWORD *)(Cells + v1 + 32) + 8 * i) )
printf("%2d", (unsigned int)i);
else
printf(" -");
}
result = putchar(10);
}
++v2;
v1 += 56LL;
}
while ( Number_of_cells > (int)v2 );
}
return result;
}

original_code:
void p_eterms(void)
{
  int i, j;
  printf("\n------- Cells --------\n");
  for (i = 0; i < Number_of_cells; i++) {
    int n = eterms_count(Cells[i].occurrences);
    if (n > 0) {
      fwrite_term(stdout, Cells[i].occurrences);
      printf(": %d occ, id=%d, val=", n, i);
      if (Cells[i].value == ((void *)0))
 printf("NULL");
      else
 fwrite_term(stdout, Cells[i].value);
      printf(", pvals=");
      for (j = 0; j < id_to_domain_size(i); j++) {
 if (Cells[i].possible[j] == ((void *)0))
   printf(" -");
 else
   printf("%2d", j);
      }
      printf("\n");
    }
  }
}

canonical_original_code:
void p_eterms()
{
  int i; int j;
  printf("\n------- Cells --------\n");
  for (i = 0; i < Number_of_cells; i++) {
    int n = eterms_count(Cells[i].occurrences);
    if (n > 0) {
      fwrite_term(stdout, Cells[i].occurrences);
      printf(": %d occ, id=%d, val=", n, i);
      if (Cells[i].value == ((void *)0))
 printf("NULL");
      else
 fwrite_term(stdout, Cells[i].value);
      printf(", pvals=");
      for (j = 0; j < id_to_domain_size(i); j++) {
 if (Cells[i].possible[j] == ((void *)0))
   printf(" -");
 else
   printf("%2d", j);
      }
      printf("\n");
    }
  }
}


decompiled_code:
__int64 __fastcall p_stats(double a1)
{
print_separator(stdout, "STATISTICS", 1LL);
printf("\nFor domain size %d.\n\n", Domain_size);
clock_seconds(Mace4_clock);
printf("Current CPU time: %.2f seconds ", a1);
user_seconds();
printf("(total CPU time: %.2f seconds).\n", a1);
printf("Ground clauses: seen=%u, kept=%u.\n", Mstats[8], Mstats[9]);
printf(
"Selections=%u, assignments=%u, propagations=%u, current_models=%u.\n",
Mstats[1],
Mstats[2],
Mstats[3],
Mstats[0]);
printf("Rewrite_terms=%u, rewrite_bools=%u, indexes=%u.\n", Mstats[5], Mstats[6], Mstats[7]);
printf("Rules_from_neg_clauses=%u, cross_offs=%d.\n", Mstats[10], Mstats[4]);
return print_separator(stdout, "end of statistics", 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func11(double a1)
{
print_separator(stdout, "STATISTICS", 1LL);
printf("\nFor domain size %d.\n\n", Domain_size);
clock_seconds(Mace4_clock);
printf("Current CPU time: %.2f seconds ", a1);
user_seconds();
printf("(total CPU time: %.2f seconds).\n", a1);
printf("Ground clauses: seen=%u, kept=%u.\n", Mstats[8], Mstats[9]);
printf(
"Selections=%u, assignments=%u, propagations=%u, current_models=%u.\n",
Mstats[1],
Mstats[2],
Mstats[3],
Mstats[0]);
printf("Rewrite_terms=%u, rewrite_bools=%u, indexes=%u.\n", Mstats[5], Mstats[6], Mstats[7]);
printf("Rules_from_neg_clauses=%u, cross_offs=%d.\n", Mstats[10], Mstats[4]);
return print_separator(stdout, "end of statistics", 1LL);
}

original_code:
void p_stats(void)
{
  print_separator(stdout, "STATISTICS", TRUE);
  printf("\nFor domain size %d.\n\n",Domain_size);
  printf("Current CPU time: %.2f seconds ", clock_seconds(Mace4_clock));
  printf("(total CPU time: %.2f seconds).\n",user_seconds());
  printf("Ground clauses: seen=%u, kept=%u.\n",
  Mstats.ground_clauses_seen, Mstats.ground_clauses_kept);
  printf("Selections=%u, assignments=%u, propagations=%u, current_models=%u.\n",
  Mstats.selections, Mstats.assignments, Mstats.propagations, Mstats.current_models);
  printf("Rewrite_terms=%u, rewrite_bools=%u, indexes=%u.\n",
  Mstats.rewrite_terms, Mstats.rewrite_bools, Mstats.indexes);
  printf("Rules_from_neg_clauses=%u, cross_offs=%d.\n",
  Mstats.rules_from_neg, Mstats.cross_offs);
  print_separator(stdout, "end of statistics", TRUE);
}

canonical_original_code:
void p_stats()
{
  print_separator(stdout, "STATISTICS", TRUE);
  printf("\nFor domain size %d.\n\n",Domain_size);
  printf("Current CPU time: %.2f seconds ", clock_seconds(Mace4_clock));
  printf("(total CPU time: %.2f seconds).\n",user_seconds());
  printf("Ground clauses: seen=%u, kept=%u.\n",
  Mstats.ground_clauses_seen, Mstats.ground_clauses_kept);
  printf("Selections=%u, assignments=%u, propagations=%u, current_models=%u.\n",
  Mstats.selections, Mstats.assignments, Mstats.propagations, Mstats.current_models);
  printf("Rewrite_terms=%u, rewrite_bools=%u, indexes=%u.\n",
  Mstats.rewrite_terms, Mstats.rewrite_bools, Mstats.indexes);
  printf("Rules_from_neg_clauses=%u, cross_offs=%d.\n",
  Mstats.rules_from_neg, Mstats.cross_offs);
  print_separator(stdout, "end of statistics", TRUE);
}


decompiled_code:
__int64 p_mem()
{
unsigned int v0; // eax

puts("\n------------- memory usage (for entire run) -------------------");
v0 = megs_malloced();
printf("\nTotal malloced: %d megabytes\n", v0);
fprint_strbuf_mem(stdout, 1LL);
fprint_parse_mem(stdout, 0LL);
fprint_glist_mem(stdout, 0LL);
fprint_term_mem(stdout, 0LL);
fprint_topform_mem(stdout, 0LL);
fprint_clist_mem(stdout, 0LL);
fprint_mclause_mem(stdout, 0LL);
fprint_mstate_mem(stdout, 0LL);
fprint_estack_mem(stdout, 0LL);
return memory_report(stdout);
}

canonical_decompiled_code:
__int64 func12()
{
unsigned int v0; // eax

puts("\n------------- memory usage (for entire run) -------------------");
v0 = megs_malloced();
printf("\nTotal malloced: %d megabytes\n", v0);
fprint_strbuf_mem(stdout, 1LL);
fprint_parse_mem(stdout, 0LL);
fprint_glist_mem(stdout, 0LL);
fprint_term_mem(stdout, 0LL);
fprint_topform_mem(stdout, 0LL);
fprint_clist_mem(stdout, 0LL);
fprint_mclause_mem(stdout, 0LL);
fprint_mstate_mem(stdout, 0LL);
fprint_estack_mem(stdout, 0LL);
return memory_report(stdout);
}

original_code:
void p_mem(void)
{
  printf("\n------------- memory usage (for entire run) -------------------\n");
  printf("\nTotal malloced: %d megabytes\n", megs_malloced());
  fprint_strbuf_mem(stdout, 1);
  fprint_parse_mem(stdout, 0);
  fprint_glist_mem(stdout, 0);
  fprint_term_mem(stdout, 0);
  fprint_topform_mem(stdout, 0);
  fprint_clist_mem(stdout, 0);
  fprint_mclause_mem(stdout, 0);
  fprint_mstate_mem(stdout, 0);
  fprint_estack_mem(stdout, 0);
  memory_report(stdout);
}

canonical_original_code:
void p_mem()
{
  printf("\n------------- memory usage (for entire run) -------------------\n");
  printf("\nTotal malloced: %d megabytes\n", megs_malloced());
  fprint_strbuf_mem(stdout, 1);
  fprint_parse_mem(stdout, 0);
  fprint_glist_mem(stdout, 0);
  fprint_term_mem(stdout, 0);
  fprint_topform_mem(stdout, 0);
  fprint_clist_mem(stdout, 0);
  fprint_mclause_mem(stdout, 0);
  fprint_mstate_mem(stdout, 0);
  fprint_estack_mem(stdout, 0);
  memory_report(stdout);
}


decompiled_code:
void reset_current_stats()
{
Mstats[0] = 0;
Mstats[1] = 0;
Mstats[2] = 0;
Mstats[3] = 0;
Mstats[4] = 0;
Mstats[5] = 0;
Mstats[6] = 0;
Mstats[7] = 0;
Mstats[8] = 0;
Mstats[9] = 0;
Mstats[10] = 0;
Mstats[11] = 0;
Mstats[12] = 0;
Mstats[13] = 0;
Mstats[14] = 0;
Mstats[15] = 0;
Mstats[16] = 0;
Mstats[17] = 0;
Mstats[18] = 0;
Mstats[19] = 0;
Mstats[20] = 0;
Mstats[21] = 0;
Mstats[22] = 0;
}

original_code:
void reset_current_stats(void)
{
  Mstats.current_models = 0;
  Mstats.selections = 0;
  Mstats.assignments = 0;
  Mstats.propagations = 0;
  Mstats.cross_offs = 0;
  Mstats.rewrite_terms = 0;
  Mstats.rewrite_bools = 0;
  Mstats.indexes = 0;
  Mstats.ground_clauses_seen = 0;
  Mstats.ground_clauses_kept = 0;
  Mstats.rules_from_neg = 0;
  Mstats.neg_elim_attempts = 0;
  Mstats.neg_elim_agone = 0;
  Mstats.neg_elim_egone = 0;
  Mstats.neg_assign_attempts = 0;
  Mstats.neg_assign_agone = 0;
  Mstats.neg_assign_egone = 0;
  Mstats.neg_near_assign_attempts = 0;
  Mstats.neg_near_assign_agone = 0;
  Mstats.neg_near_assign_egone = 0;
  Mstats.neg_near_elim_attempts = 0;
  Mstats.neg_near_elim_agone = 0;
  Mstats.neg_near_elim_egone = 0;
}

canonical_original_code:
void reset_current_stats()
{
  Mstats.current_models = 0;
  Mstats.selections = 0;
  Mstats.assignments = 0;
  Mstats.propagations = 0;
  Mstats.cross_offs = 0;
  Mstats.rewrite_terms = 0;
  Mstats.rewrite_bools = 0;
  Mstats.indexes = 0;
  Mstats.ground_clauses_seen = 0;
  Mstats.ground_clauses_kept = 0;
  Mstats.rules_from_neg = 0;
  Mstats.neg_elim_attempts = 0;
  Mstats.neg_elim_agone = 0;
  Mstats.neg_elim_egone = 0;
  Mstats.neg_assign_attempts = 0;
  Mstats.neg_assign_agone = 0;
  Mstats.neg_assign_egone = 0;
  Mstats.neg_near_assign_attempts = 0;
  Mstats.neg_near_assign_agone = 0;
  Mstats.neg_near_assign_egone = 0;
  Mstats.neg_near_elim_attempts = 0;
  Mstats.neg_near_elim_agone = 0;
  Mstats.neg_near_elim_egone = 0;
}


decompiled_code:
__int64 __fastcall char_array_ident(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax

if ( a3 <= 0 )
return 1LL;
v3 = 0LL;
while ( *(_BYTE *)(a1 + v3) == *(_BYTE *)(a2 + v3) )
{
if ( ++v3 == a3 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax

if ( a3 <= 0 )
return 1LL;
v3 = 0LL;
while ( *(_BYTE *)(a1 + v3) == *(_BYTE *)(a2 + v3) )
{
if ( ++v3 == a3 )
return 1LL;
}
return 0LL;
}

original_code:
static
int char_array_ident(char *s, char *t, int n)
{
  int i;
  for (i = 0; i < n; i++)
    if (s[i] != t[i])
      return 0;
  return 1;
}

variable_types:
t
char *


decompiled_code:
__int64 __fastcall char_array_find(__int64 a1, int a2, __int64 a3, int a4)
{
int v5; // ebp
__int64 v6; // rbx
unsigned int v7; // er15

if ( a2 > a4 )
return (unsigned int)-1;
v5 = a4 - a2;
v6 = 0LL;
while ( 1 )
{
v7 = v6;
if ( (unsigned int)char_array_ident(a3 + v6, a1, a2) )
break;
if ( v5 < (int)++v6 )
return (unsigned int)-1;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, __int64 a3, int a4)
{
int v5; // ebp
__int64 v6; // rbx
unsigned int v7; // er15

if ( a2 > a4 )
return (unsigned int)-1;
v5 = a4 - a2;
v6 = 0LL;
while ( 1 )
{
v7 = v6;
if ( (unsigned int)func0(a3 + v6, a1, a2) )
break;
if ( v5 < (int)++v6 )
return (unsigned int)-1;
}
return v7;
}

original_code:
static
int char_array_find(char *b, int nb, char *a, int na)
{
  if (nb <= na) {
    int i;
    for (i = 0; i <= na - nb; i++) {
      if (char_array_ident(a+i, b, nb))
 return i;
    }
  }
  return -1;
}

variable_types:
b
char *

variable_types: nb int

variable_types:
a
char *


original_code:
static
double complexity_1(char *s)
{
  int length = strlen(s);
  int min = 2;
  int index = min;
  int total = 0;
  if (length < 3)
    return 0.0;
  while (index <= length-2) {
    int flen = 0;
    int maxlook = (length - index);
    int window;
    if (maxlook > index)
      maxlook = index;
    for (window = min; window < maxlook+1; window++) {
      char *tocheck = s + index;
      int ind = char_array_find(tocheck, window, s, length);
      if (ind < index)
 flen = window;
    }
    if (flen == 0)
      index += 1;
    else {
      index += flen;
      total += flen;
    }
  }
  return ((double) total) / (length-2);
}

variable_types:
s
char *

variable_types: length int

variable_types: min int

variable_types: index int

variable_types: total int

variable_types: flen int

variable_types: maxlook int

variable_types: window int

variable_types:
tocheck
char *

variable_types: ind int


decompiled_code:
void test1()
{
char *v0; // rbx

v0 = (char *)term_to_string();
complexity_1(v0);
free(v0);
}

canonical_decompiled_code:
void func3()
{
char *v0; // rbx

v0 = (char *)term_to_string();
func2(v0);
free(v0);
}

original_code:
static
double test1(Term t)
{
  char *s = term_to_string(t);
  double c = complexity_1(s);
  free(s);
  return c;
}

canonical_original_code:
static double test1(struct term *t)
{
  char *s = term_to_string(t);
  double c = complexity_1(s);
  free(s);
  return c;
}

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: c double


decompiled_code:
double __fastcall call_weight(__int64 a1)
{
double result; // xmm0_8

if ( (unsigned int)str_ident(a1, "test1") )
{
test1();
}
else
{
fatal_error("call_weight, unknown function");
result = 0.0;
}
return result;
}

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

if ( (unsigned int)str_ident(a1, "test1") )
{
func3();
}
else
{
fatal_error("call_weight, unknown function");
result = 0.0;
}
return result;
}

original_code:
double call_weight(char *func, Term t)
{
  if (str_ident(func, "test1"))
    return test1(t);
  else {
    fatal_error("call_weight, unknown function");
    return 0;
  }
}

canonical_original_code:
double call_weight(char *func, struct term *t)
{
  if (str_ident(func, "test1"))
    return test1(t);
  else {
    fatal_error("call_weight, unknown function");
    return 0;
  }
}

variable_types:
func
char *


decompiled_code:
__int64 demod_attempts()
{
return (unsigned int)Demod_attempts;
}

canonical_decompiled_code:
__int64 func6()
{
return (unsigned int)Demod_attempts;
}

original_code:
int demod_attempts()
{
  return Demod_attempts;
}


decompiled_code:
__int64 demod_rewrites()
{
return (unsigned int)Demod_rewrites;
}

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

original_code:
int demod_rewrites()
{
  return Demod_rewrites;
}


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

if ( Maximal_flag != -1 )
fatal_error("init_maximal, called more than once");
Maximal_flag = claim_term_flag();
Maximal_signed_flag = claim_term_flag();
result = claim_term_flag();
Selected_flag = result;
return result;
}

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

if ( Maximal_flag != -1 )
fatal_error("init_maximal, called more than once");
Maximal_flag = claim_term_flag();
Maximal_signed_flag = claim_term_flag();
result = claim_term_flag();
Selected_flag = result;
return result;
}

original_code:
void init_maximal(void)
{
  if (Maximal_flag != -1)
    fatal_error("init_maximal, called more than once");
  Maximal_flag = claim_term_flag();
  Maximal_signed_flag = claim_term_flag();
  Selected_flag = claim_term_flag();
}

canonical_original_code:
void init_maximal()
{
  if (Maximal_flag != -1)
    fatal_error("init_maximal, called more than once");
  Maximal_flag = claim_term_flag();
  Maximal_signed_flag = claim_term_flag();
  Selected_flag = claim_term_flag();
}


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

v2 = a1;
if ( !a1 )
return 1LL;
do
{
if ( a2 != v2 && (unsigned int)greater_literals(v2, a2) )
return 0LL;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

v2 = a1;
if ( !a1 )
return 1LL;
do
{
if ( a2 != v2 && (unsigned int)func0(v2, a2) )
return 0LL;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 1LL;
}

original_code:
BOOL max_lit_test(Literals lits, Literals lit)
{
  Literals l2 = lits;
  BOOL maximal = TRUE;
  while (l2 && maximal) {
    if (lit != l2 && greater_literals(l2, lit))
      maximal = FALSE;
    else
      l2 = l2->next;
  }
  return maximal;
}

canonical_original_code:
enum BOOL max_lit_test(struct literals *lits, struct literals *lit)
{
  struct literals *l2 = lits;
  enum BOOL maximal = TRUE;
  while (l2 && maximal) {
    if (lit != l2 && greater_literals(l2, lit))
      maximal = FALSE;
    else
      l2 = l2->next;
  }
  return maximal;
}

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

variable_types:
lit
struct literals *

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


decompiled_code:
__int64 __fastcall max_signed_lit_test(__int64 a1, _DWORD *a2)
{
__int64 v2; // rbx

v2 = a1;
if ( !a1 )
return 1LL;
do
{
if ( a2 != (_DWORD *)v2 && *a2 == *(_DWORD *)v2 && (unsigned int)greater_literals(v2, (__int64)a2) )
return 0LL;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _DWORD *a2)
{
__int64 v2; // rbx

v2 = a1;
if ( !a1 )
return 1LL;
do
{
if ( a2 != (_DWORD *)v2 && *a2 == *(_DWORD *)v2 && (unsigned int)func0(v2, (__int64)a2) )
return 0LL;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 1LL;
}

original_code:
BOOL max_signed_lit_test(Literals lits, Literals lit)
{
  Literals l2 = lits;
  BOOL maximal = TRUE;
  while (l2 && maximal) {
    if (lit != l2 && lit->sign == l2->sign && greater_literals(l2, lit))
      maximal = FALSE;
    else
      l2 = l2->next;
  }
  return maximal;
}

canonical_original_code:
enum BOOL max_signed_lit_test(struct literals *lits, struct literals *lit)
{
  struct literals *l2 = lits;
  enum BOOL maximal = TRUE;
  while (l2 && maximal) {
    if (lit != l2 && lit->sign == l2->sign && greater_literals(l2, lit))
      maximal = FALSE;
    else
      l2 = l2->next;
  }
  return maximal;
}


decompiled_code:
void __fastcall mark_maximal_literals(__int64 a1)
{
__int64 v1; // rbx

if ( Maximal_flag == -1 )
fatal_error("mark_maximal_literals, init_maximal() was not called");
if ( a1 )
{
v1 = a1;
do
{
if ( (unsigned int)max_lit_test(a1, v1) )
term_flag_set(*(_QWORD *)(v1 + 8), (unsigned int)Maximal_flag);
if ( (unsigned int)max_signed_lit_test(a1, (_DWORD *)v1) )
term_flag_set(*(_QWORD *)(v1 + 8), (unsigned int)Maximal_signed_flag);
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
__int64 v1; // rbx

if ( Maximal_flag == -1 )
fatal_error("mark_maximal_literals, init_maximal() was not called");
if ( a1 )
{
v1 = a1;
do
{
if ( (unsigned int)func2(a1, v1) )
term_flag_set(*(_QWORD *)(v1 + 8), (unsigned int)Maximal_flag);
if ( (unsigned int)func3(a1, (_DWORD *)v1) )
term_flag_set(*(_QWORD *)(v1 + 8), (unsigned int)Maximal_signed_flag);
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
}
}

original_code:
void mark_maximal_literals(Literals lits)
{
  Literals lit;
  if (Maximal_flag == -1)
    fatal_error("mark_maximal_literals, init_maximal() was not called");
  for (lit = lits; lit; lit = lit->next) {
    if (max_lit_test(lits, lit))
      term_flag_set(lit->atom, Maximal_flag);
    if (max_signed_lit_test(lits, lit))
      term_flag_set(lit->atom, Maximal_signed_flag);
  }
}

canonical_original_code:
void mark_maximal_literals(struct literals *lits)
{
  struct literals *lit;
  if (Maximal_flag == -1)
    fatal_error("mark_maximal_literals, init_maximal() was not called");
  for (lit = lits; lit; lit = lit->next) {
    if (max_lit_test(lits, lit))
      term_flag_set(lit->atom, Maximal_flag);
    if (max_signed_lit_test(lits, lit))
      term_flag_set(lit->atom, Maximal_signed_flag);
  }
}


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

if ( a3 )
result = max_lit_test(a1, a2);
else
result = term_flag(*(_QWORD *)(a2 + 8), (unsigned int)Maximal_flag);
return result;
}

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

if ( a3 )
result = func2(a1, a2);
else
result = term_flag(*(_QWORD *)(a2 + 8), (unsigned int)Maximal_flag);
return result;
}

original_code:
BOOL maximal_literal(Literals lits, Literals lit, int check)
{
  if (check == FLAG_CHECK)
    return term_flag(lit->atom, Maximal_flag);
  else
    return max_lit_test(lits, lit);
}

canonical_original_code:
enum BOOL maximal_literal(struct literals *lits, struct literals *lit, int check)
{
  if (check == FLAG_CHECK)
    return term_flag(lit->atom, Maximal_flag);
  else
    return max_lit_test(lits, lit);
}

variable_types: check int


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

if ( a3 )
result = max_signed_lit_test(a1, (_DWORD *)a2);
else
result = term_flag(*(_QWORD *)(a2 + 8), (unsigned int)Maximal_signed_flag);
return result;
}

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

if ( a3 )
result = func3(a1, (_DWORD *)a2);
else
result = term_flag(*(_QWORD *)(a2 + 8), (unsigned int)Maximal_signed_flag);
return result;
}

original_code:
BOOL maximal_signed_literal(Literals lits, Literals lit, int check)
{
  if (check == FLAG_CHECK)
    return term_flag(lit->atom, Maximal_signed_flag);
  else
    return max_signed_lit_test(lits, lit);
}

canonical_original_code:
enum BOOL maximal_signed_literal(struct literals *lits, struct literals *lit, int check)
{
  if (check == FLAG_CHECK)
    return term_flag(lit->atom, Maximal_signed_flag);
  else
    return max_signed_lit_test(lits, lit);
}


decompiled_code:
__int64 __fastcall number_of_maximal_literals(__int64 a1, int a2)
{
__int64 v2; // rbx
unsigned int v3; // ebp

if ( !a1 )
return 0;
v2 = a1;
v3 = 0;
do
{
v3 -= ((unsigned int)maximal_literal(a1, v2, a2) == 0) - 1;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
__int64 v2; // rbx
unsigned int v3; // ebp

if ( !a1 )
return 0;
v2 = a1;
v3 = 0;
do
{
v3 -= ((unsigned int)func5(a1, v2, a2) == 0) - 1;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return v3;
}

original_code:
int number_of_maximal_literals(Literals lits, int check)
{
  int n = 0;
  Literals lit;
  for (lit = lits; lit; lit = lit->next) {
    if (maximal_literal(lits, lit, check))
      n++;
  }
  return n;
}

canonical_original_code:
int number_of_maximal_literals(struct literals *lits, int check)
{
  int n = 0;
  struct literals *lit;
  for (lit = lits; lit; lit = lit->next) {
    if (maximal_literal(lits, lit, check))
      n++;
  }
  return n;
}

variable_types: n int


decompiled_code:
__int64 __fastcall mark_selected_literal(__int64 a1)
{
return term_flag_set(*(_QWORD *)(a1 + 8), (unsigned int)Selected_flag);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return term_flag_set(*(_QWORD *)(a1 + 8), (unsigned int)Selected_flag);
}

original_code:
void mark_selected_literal(Literals lit)
{
  term_flag_set(lit->atom, Selected_flag);
}

canonical_original_code:
void mark_selected_literal(struct literals *lit)
{
  term_flag_set(lit->atom, Selected_flag);
}


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

if ( Selected_flag == -1 )
fatal_error("mark_selected_literals, init_maximal() was not called");
if ( a1 )
{
v2 = a1;
do
{
if ( !*(_DWORD *)v2
&& ((unsigned int)str_ident(a2, "all_negative")
|| (unsigned int)str_ident(a2, "max_negative") && (unsigned int)maximal_signed_literal(a1, v2, 0)) )
{
mark_selected_literal(v2);
}
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
}
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

if ( Selected_flag == -1 )
fatal_error("mark_selected_literals, init_maximal() was not called");
if ( a1 )
{
v2 = a1;
do
{
if ( !*(_DWORD *)v2
&& ((unsigned int)str_ident(a2, "all_negative")
|| (unsigned int)str_ident(a2, "max_negative") && (unsigned int)func6(a1, v2, 0)) )
{
func8(v2);
}
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
}
}

original_code:
void mark_selected_literals(Literals lits, char *selection)
{
  Literals lit;
  if (Selected_flag == -1)
    fatal_error("mark_selected_literals, init_maximal() was not called");
  for (lit = lits; lit; lit = lit->next) {
    if (!lit->sign) {
      if (str_ident(selection, "all_negative"))
 mark_selected_literal(lit);
      else if (str_ident(selection, "max_negative")) {
 if (maximal_signed_literal(lits, lit, FLAG_CHECK))
   mark_selected_literal(lit);
      }
    }
  }
}

canonical_original_code:
void mark_selected_literals(struct literals *lits, char *selection)
{
  struct literals *lit;
  if (Selected_flag == -1)
    fatal_error("mark_selected_literals, init_maximal() was not called");
  for (lit = lits; lit; lit = lit->next) {
    if (!lit->sign) {
      if (str_ident(selection, "all_negative"))
 mark_selected_literal(lit);
      else if (str_ident(selection, "max_negative")) {
 if (maximal_signed_literal(lits, lit, FLAG_CHECK))
   mark_selected_literal(lit);
      }
    }
  }
}

variable_types:
selection
char *


decompiled_code:
__int64 __fastcall selected_literal(__int64 a1)
{
return term_flag(*(_QWORD *)(a1 + 8), (unsigned int)Selected_flag);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return term_flag(*(_QWORD *)(a1 + 8), (unsigned int)Selected_flag);
}

original_code:
BOOL selected_literal(Literals lit)
{
  return term_flag(lit->atom, Selected_flag);
}

canonical_original_code:
enum BOOL selected_literal(struct literals *lit)
{
  return term_flag(lit->atom, Selected_flag);
}


decompiled_code:
__int64 __fastcall exists_selected_literal(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

v1 = a1;
if ( !a1 )
return 0LL;
while ( 1 )
{
result = selected_literal(v1);
if ( (_DWORD)result )
break;
v1 = *(_QWORD *)(v1 + 16);
if ( !v1 )
return result;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

v1 = a1;
if ( !a1 )
return 0LL;
while ( 1 )
{
result = func10(v1);
if ( (_DWORD)result )
break;
v1 = *(_QWORD *)(v1 + 16);
if ( !v1 )
return result;
}
return 1LL;
}

original_code:
BOOL exists_selected_literal(Literals lits)
{
  Literals lit;
  for (lit = lits; lit; lit = lit->next)
    if (selected_literal(lit))
      return TRUE;
  return FALSE;
}

canonical_original_code:
enum BOOL exists_selected_literal(struct literals *lits)
{
  struct literals *lit;
  for (lit = lits; lit; lit = lit->next)
    if (selected_literal(lit))
      return TRUE;
  return FALSE;
}


decompiled_code:
void __fastcall copy_selected_literal_marks(__int64 a1, __int64 a2)
{
if ( a1 && a2 )
{
copy_selected_literal_marks(*(_QWORD *)(a1 + 16), *(_QWORD *)(a2 + 16));
if ( (unsigned int)selected_literal(a1) )
mark_selected_literal(a2);
}
}

original_code:
void copy_selected_literal_marks(Literals a, Literals b)
{
  if (!a || !b)
    return;
  else {
    copy_selected_literal_marks(a->next, b->next);
    if (selected_literal(a))
      mark_selected_literal(b);
  }
}

canonical_original_code:
void copy_selected_literal_marks(struct literals *a, struct literals *b)
{
  if (!a || !b)
    return;
  else {
    copy_selected_literal_marks(a->next, b->next);
    if (selected_literal(a))
      mark_selected_literal(b);
  }
}

variable_types:
b
struct literals *


original_code:
Ibuffer ibuf_init(void)
{
  Ibuffer ibuf = malloc(sizeof(struct ibuffer));
  ibuf->buf = malloc(40000 * sizeof(int));
  ibuf->size = 40000;
  ibuf->write_position = 0;
  ibuf->read_position = 0;
  return ibuf;
}

canonical_original_code:
struct ibuffer *ibuf_init()
{
  struct ibuffer *ibuf = malloc(sizeof(struct ibuffer));
  ibuf->buf = malloc(40000 * sizeof(int));
  ibuf->size = 40000;
  ibuf->write_position = 0;
  ibuf->read_position = 0;
  return ibuf;
}

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


decompiled_code:
void __fastcall ibuf_free(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void ibuf_free(Ibuffer ibuf)
{
  free(ibuf->buf);
  free(ibuf);
}

canonical_original_code:
void ibuf_free(struct ibuffer *ibuf)
{
  free(ibuf->buf);
  free(ibuf);
}

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


decompiled_code:
__int64 __fastcall ibuf_write(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax
int v5; // er13
_DWORD *v6; // r12
int v7; // ecx
__int64 v8; // rsi
__int64 i; // rax

v3 = *(unsigned int *)(a1 + 8);
if ( *(_DWORD *)a1 >= (int)v3 )
{
v5 = 2 * v3;
printf("ibuf_write, increasing buf size from %d to %d\n", v3, (unsigned int)(2 * v3));
v6 = malloc(8LL * (_DWORD)v3);
v7 = *(_DWORD *)(a1 + 8);
if ( v7 > 0 )
{
v8 = *(_QWORD *)(a1 + 16);
for ( i = 0LL; i != v7; ++i )
v6[i] = *(_DWORD *)(v8 + 4 * i);
}
free(*(void **)(a1 + 16));
*(_QWORD *)(a1 + 16) = v6;
*(_DWORD *)(a1 + 8) = v5;
}
result = *(_QWORD *)(a1 + 16);
*(_DWORD *)(result + 4LL * (int)(*(_DWORD *)a1)++) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax
int v5; // er13
_DWORD *v6; // r12
int v7; // ecx
__int64 v8; // rsi
__int64 i; // rax

v3 = *(unsigned int *)(a1 + 8);
if ( *(_DWORD *)a1 >= (int)v3 )
{
v5 = 2 * v3;
printf("ibuf_write, increasing buf size from %d to %d\n", v3, (unsigned int)(2 * v3));
v6 = malloc(8LL * (_DWORD)v3);
v7 = *(_DWORD *)(a1 + 8);
if ( v7 > 0 )
{
v8 = *(_QWORD *)(a1 + 16);
for ( i = 0LL; i != v7; ++i )
v6[i] = *(_DWORD *)(v8 + 4 * i);
}
free(*(void **)(a1 + 16));
*(_QWORD *)(a1 + 16) = v6;
*(_DWORD *)(a1 + 8) = v5;
}
result = *(_QWORD *)(a1 + 16);
*(_DWORD *)(result + 4LL * (int)(*(_DWORD *)a1)++) = a2;
return result;
}

original_code:
void ibuf_write(Ibuffer ibuf, int i)
{
  if (ibuf->write_position >= ibuf->size) {
    int size2 = ibuf->size * 2;
    int *buf2, i;
    printf("ibuf_write, increasing buf size from %d to %d\n",
    ibuf->size, size2);
    buf2 = malloc(size2 * sizeof(int));
    for (i = 0; i < ibuf->size; i++)
      buf2[i] = ibuf->buf[i];
    free(ibuf->buf);
    ibuf->buf = buf2;
    ibuf->size = size2;
  }
  ibuf->buf[ibuf->write_position] = i;
  ibuf->write_position++;
}

canonical_original_code:
void ibuf_write(struct ibuffer *ibuf, int i)
{
  if (ibuf->write_position >= ibuf->size) {
    int size2 = ibuf->size * 2;
    int *buf2; int i;
    printf("ibuf_write, increasing buf size from %d to %d\n",
    ibuf->size, size2);
    buf2 = malloc(size2 * sizeof(int));
    for (i = 0; i < ibuf->size; i++)
      buf2[i] = ibuf->buf[i];
    free(ibuf->buf);
    ibuf->buf = buf2;
    ibuf->size = size2;
  }
  ibuf->buf[ibuf->write_position] = i;
  ibuf->write_position++;
}

variable_types: i int


decompiled_code:
__int64 __fastcall ibuf_write_block(__int64 a1, int *a2, int a3)
{
int *v3; // rbx
__int64 v4; // r12
__int64 result; // rax

if ( a3 > 0 )
{
v3 = a2;
v4 = (__int64)&a2[a3 - 1 + 1];
do
result = ibuf_write(a1, *v3++);
while ( v3 != (int *)v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int *a2, int a3)
{
int *v3; // rbx
__int64 v4; // r12
__int64 result; // rax

if ( a3 > 0 )
{
v3 = a2;
v4 = (__int64)&a2[a3 - 1 + 1];
do
result = func2(a1, *v3++);
while ( v3 != (int *)v4 );
}
return result;
}

original_code:
void ibuf_write_block(Ibuffer ibuf, int *a, int n)
{
  int i;
  for (i = 0; i < n; i++)
    ibuf_write(ibuf, a[i]);
}

canonical_original_code:
void ibuf_write_block(struct ibuffer *ibuf, int *a, int n)
{
  int i;
  for (i = 0; i < n; i++)
    ibuf_write(ibuf, a[i]);
}

variable_types:
a
int *


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


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


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

if ( *(_DWORD *)(a1 + 4) >= *(_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; // edx

if ( *(_DWORD *)(a1 + 4) >= *(_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;
}


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);
v2 = v1;
if ( v1 != 0x80000000 )
{
do
{
printf("%d ", v2);
v3 = ibuf_read(a1);
v2 = v3;
}
while ( v3 != 0x80000000 );
}
return putchar(10);
}

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

v1 = func5(a1);
v2 = v1;
if ( v1 != 0x80000000 )
{
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");
}


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

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

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

if ( *a1 >= 0 )
return term_compare_vcp();
v3 = *a2;
if ( *a2 >= 0 )
return term_compare_vcp();
if ( a3 + *a1 )
{
result = 2LL;
if ( v3 + a3 )
return term_compare_vcp();
}
else
{
result = 3LL;
if ( !(v3 + a3) )
return term_compare_vcp();
}
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:
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));
}


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


commutativity

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

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


associativity

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


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)
{
unsigned int v1; // ebx
int **v2; // rdx
int v3; // eax
int v4; // edx
int v6; // er12
unsigned int v7; // er12
__int64 v8; // r13
__int64 v9; // rbx
__int64 v10; // r13
__int64 v11; // rsi

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

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
unsigned int v1; // ebx
int **v2; // rdx
int v3; // eax
int v4; // edx
int v6; // er12
unsigned int v7; // er12
__int64 v8; // r13
__int64 v9; // rbx
__int64 v10; // r13
__int64 v11; // rsi

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

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


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


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)
{
int v1; // edx
__int64 result; // rax

if ( !C_symbols )
return 0LL;
if ( !a1 )
return 0LL;
if ( !*(_DWORD *)a1 || (v1 = cac_redundant_atom(*(_QWORD *)(a1 + 8)), result = 1LL, !v1) )
result = cac_tautology(*(_QWORD *)(a1 + 16));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
int v1; // edx
__int64 result; // rax

if ( !C_symbols )
return 0LL;
if ( !a1 )
return 0LL;
if ( !*(_DWORD *)a1 || (v1 = func6(*(_QWORD *)(a1 + 8)), result = 1LL, !v1) )
result = func9(*(_QWORD *)(a1 + 16));
return result;
}

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