decompiled_code:
__int64 exo_III_main()
{
int i; // ebx
__pid_t v1; // ebp
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

for ( i = 0; i != 3; ++i )
{
v1 = fork();
if ( !v1 )
{
printf("i=%d\n", (unsigned int)i);
if ( i <= 0 )
{
i = v1;
LABEL_8:
printf("j=%d \n", (unsigned int)i);
}
else
{
while ( !fork() )
{
if ( ++v1 == i )
goto LABEL_8;
}
wait((__WAIT_STATUS)&stat_loc);
i = v1;
}
exit(i);
}
wait((__WAIT_STATUS)&stat_loc);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func12()
{
int i; // ebx
__pid_t v1; // ebp
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

for ( i = 0; i != 3; ++i )
{
v1 = fork();
if ( !v1 )
{
printf("i=%d\n", (unsigned int)i);
if ( i <= 0 )
{
i = v1;
LABEL_8:
printf("j=%d \n", (unsigned int)i);
}
else
{
while ( !fork() )
{
if ( ++v1 == i )
goto LABEL_8;
}
wait((__WAIT_STATUS)&stat_loc);
i = v1;
}
exit(i);
}
wait((__WAIT_STATUS)&stat_loc);
}
return 0LL;
}

original_code:
int exo_III_main (int arg, char* argv[]) {
  int i, j, p;
  int status;
  for (i=0; i<3 ; i++)
    if ((p=fork ()) == 0) {
      printf ("i=%d\n", i);
      j=0;
      while (j<i && ((p=fork()) == 0))
 j++;
      if (p==0)
 printf("j=%d \n",j);
      else{
 wait(&status);}
      exit(j);
    }
  else{
    wait(&status);
  }
  return (0);
}

canonical_original_code:
int exo_III_main(int arg, char *argv[]) {
  int i; int j; int p;
  int status;
  for (i=0; i<3 ; i++)
    if ((p=fork ()) == 0) {
      printf ("i=%d\n", i);
      j=0;
      while (j<i && ((p=fork()) == 0))
 j++;
      if (p==0)
 printf("j=%d \n",j);
      else{
 wait(&status);}
      exit(j);
    }
  else{
    wait(&status);
  }
  return (0);
}

variable_types: arg int

variable_types:
argv
char *[]

variable_types: j int

variable_types: p int


main

canonical_name: main

repo: nasrallahmounir/Posix

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
exo_II_1(argc, argv, envp);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
func9(argc, argv, envp);
}

original_code:
int main(){
  int i = 0;
  exo_II_1();
}

canonical_original_code:
int main(){
  int i = 0;
  exo_II_1();
}

variable_types: i int

return_type: int


decompiled_code:
__int64 __fastcall cut_down(char *a1, __int64 a2)
{
char *v2; // rax
char *v3; // rbx
__int64 v4; // r12
char *v5; // rax
__int64 result; // rax

v2 = strtok(a1, " \n");
if ( v2 )
{
v3 = v2;
v4 = 1LL;
do
{
v5 = (char *)malloc(0x18uLL);
*(_QWORD *)(a2 + 8 * v4 - 8) = v5;
strcpy(v5, v3);
v3 = strtok(0LL, " \n");
result = (unsigned int)v4++;
}
while ( v3 );
}
else
{
result = 0LL;
}
*(_QWORD *)(a2 + 8LL * (int)result) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *a1, __int64 a2)
{
char *v2; // rax
char *v3; // rbx
__int64 v4; // r12
char *v5; // rax
__int64 result; // rax

v2 = strtok(a1, " \n");
if ( v2 )
{
v3 = v2;
v4 = 1LL;
do
{
v5 = (char *)malloc(0x18uLL);
*(_QWORD *)(a2 + 8 * v4 - 8) = v5;
strcpy(v5, v3);
v3 = strtok(0LL, " \n");
result = (unsigned int)v4++;
}
while ( v3 );
}
else
{
result = 0LL;
}
*(_QWORD *)(a2 + 8LL * (int)result) = 0LL;
return result;
}

original_code:
int cut_down(char *buf, char **cmd) {
  char* s = strtok(buf, " \n");
  int i = 0;
  while (s != ((void *)0)) {
    cmd[i] = (char*) malloc(sizeof(char) * 24);
    strcpy(cmd[i], s);
    s = strtok(((void *)0), " \n");
    i++;
  }
  cmd[i] = ((void *)0);
  return i;
}

canonical_original_code:
int cut_down(char *buf, char **cmd) {
  char *s = strtok(buf, " \n");
  int i = 0;
  while (s != ((void *)0)) {
    cmd[i] = (char *) malloc(sizeof(char) * 24);
    strcpy(cmd[i], s);
    s = strtok(((void *)0), " \n");
    i++;
  }
  cmd[i] = ((void *)0);
  return i;
}

variable_types:
buf
char *

variable_types:
cmd
char **

variable_types:
s
char *


check

original_code:
int check() {
 int i, j, sums[8];
 for (i = 0; i < 8; i++)
  sums[i] = 0;
 for (i = 0; i < 3; i++) {
  for (j = 0; j < 3; j++) {
   sums[i] += magicsq[i][j];
   sums[i+3] += magicsq[j][i];
   if (i == j) sums[6] += magicsq[i][j];
   if ((i+j) == 2) sums[7] += magicsq[i][j];
  }
 }
 int result = 1;
 i = 1;
 while ((i < 8) && (result == 1)) {
  if (sums[0] != sums[i])
   result = 0;
  i++;
 }
 return result;
}

canonical_original_code:
int check() {
 int i; int j; int sums[8];
 for (i = 0; i < 8; i++)
  sums[i] = 0;
 for (i = 0; i < 3; i++) {
  for (j = 0; j < 3; j++) {
   sums[i] += magicsq[i][j];
   sums[i+3] += magicsq[j][i];
   if (i == j) sums[6] += magicsq[i][j];
   if ((i+j) == 2) sums[7] += magicsq[i][j];
  }
 }
 int result = 1;
 i = 1;
 while ((i < 8) && (result == 1)) {
  if (sums[0] != sums[i])
   result = 0;
  i++;
 }
 return result;
}

variable_types:
sums
int [8]

variable_types: result int


display

decompiled_code:
int display()
{
unsigned int *v0; // rbx

v0 = (unsigned int *)magicsq;
do
{
printf(" %d", *v0);
printf(" %d", v0[1]);
printf(" %d", v0[2]);
putchar(10);
v0 += 3;
}
while ( &_bss_start != (_UNKNOWN *)v0 );
return putchar(10);
}

canonical_decompiled_code:
int func8()
{
unsigned int *v0; // rbx

v0 = (unsigned int *)magicsq;
do
{
printf(" %d", *v0);
printf(" %d", v0[1]);
printf(" %d", v0[2]);
putchar(10);
v0 += 3;
}
while ( &_bss_start != (_UNKNOWN *)v0 );
return putchar(10);
}

original_code:
void display() {
 int i, j;
 for (i = 0; i < 3; i++) {
  for (j = 0; j < 3; j++)
   printf("  %d", magicsq[i][j]);
  printf("\n");
 }
 printf("\n");
}

canonical_original_code:
void display() {
 int i; int j;
 for (i = 0; i < 3; i++) {
  for (j = 0; j < 3; j++)
   printf("  %d", magicsq[i][j]);
  printf("\n");
 }
 printf("\n");
}

return_type: void


solve

original_code:
int solve(int x){
  int compute = 0;
  register int i,j;
  register int b,c,d,e;
  magicsq[0][1] = x;
  for(b=0;b<10;b++){
    magicsq[1][0]=b;
    for(c=0;c<10;c++){
      magicsq[1][1]=c;
      for(d=0;d<10;d++){
 magicsq[1][2]=d;
 for(e=0;e<10;e++){
   magicsq[2][1]=e;
   if(check()==1){
     compute++;
     display();
   }
 }
      }
    }
  }
  return compute;
}

canonical_original_code:
int solve(int x){
  int compute = 0;
  register int i; register int j;
  register int b; register int c; register int d; register int e;
  magicsq[0][1] = x;
  for(b=0;b<10;b++){
    magicsq[1][0]=b;
    for(c=0;c<10;c++){
      magicsq[1][1]=c;
      for(d=0;d<10;d++){
 magicsq[1][2]=d;
 for(e=0;e<10;e++){
   magicsq[2][1]=e;
   if(check()==1){
     compute++;
     display();
   }
 }
      }
    }
  }
  return compute;
}

variable_types: x int

variable_types: compute int

variable_types: b int

variable_types: c int

variable_types: d int

variable_types: e int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int i; // ebx
__pid_t v4; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

for ( i = 0; i != 10; ++i )
{
v4 = fork();
if ( v4 == -1 )
{
fprintf(stderr, aErreurLorsDeLA, "src/decoder.c", 95LL);
exit(1);
}
if ( !v4 )
solve(i);
wait((__WAIT_STATUS)&stat_loc);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int i; // ebx
__pid_t v4; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

for ( i = 0; i != 10; ++i )
{
v4 = fork();
if ( v4 == -1 )
{
fprintf(stderr, aErreurLorsDeLA, "src/decoder.c", 95LL);
exit(1);
}
if ( !v4 )
func9(i);
wait((__WAIT_STATUS)&stat_loc);
}
return 0;
}

original_code:
int main(int argc, char **argv)
{
  int i,status;
  pid_t pid;
  int cmpt = 0;
  for(i=0;i<10;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork() -- Fichier : %s Linge : %d \n","src/decoder.c",95);
      exit(1);
    case 0:
      solve(i);
    default:
      wait(&status);
      }
    }
  return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
  int i; int status;
  int pid;
  int cmpt = 0;
  for(i=0;i<10;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork() -- Fichier : %s Linge : %d \n","src/decoder.c",95);
      exit(1);
    case 0:
      solve(i);
    default:
      wait(&status);
      }
    }
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: status int

variable_types: pid int

variable_types: cmpt int


decompiled_code:
int __fastcall handle_sigalrm(unsigned int a1)
{
if ( a1 != 14 )
fprintf(stderr, "Wrong signal: %d\n", a1);
return puts("End of sleep");
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1)
{
if ( a1 != 14 )
fprintf(stderr, "Wrong signal: %d\n", a1);
return puts("End of sleep");
}

original_code:
void handle_sigalrm(int sig) {
  if (sig != 14) {
    fprintf(stderr, "Wrong signal: %d\n", sig);
  }
  printf("End of sleep\n");
}

variable_types: sig int


mysleep

decompiled_code:
int __fastcall mysleep(unsigned int seconds)
{
sigset_t v2; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v3; // [rsp+80h] [rbp-A8h] BYREF

v3.sa_handler = (__sighandler_t)handle_sigalrm;
v3.sa_flags = 0x80000000;
sigfillset(&v3.sa_mask);
sigaction(14, &v3, 0LL);
sigprocmask(0, 0LL, &v2);
sigdelset(&v2, 14);
alarm(seconds);
return sigsuspend(&v2);
}

canonical_decompiled_code:
int __fastcall func8(unsigned int seconds)
{
sigset_t v2; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v3; // [rsp+80h] [rbp-A8h] BYREF

v3.sa_handler = (__sighandler_t)handle_sigalrm;
v3.sa_flags = 0x80000000;
sigfillset(&v3.sa_mask);
sigaction(14, &v3, 0LL);
sigprocmask(0, 0LL, &v2);
sigdelset(&v2, 14);
alarm(seconds);
return sigsuspend(&v2);
}

original_code:
void mysleep(int sec){
  struct sigaction action;
  sigset_t mask;
  action.__sigaction_handler.sa_handler = &handle_sigalrm;
  action.sa_flags = 0x80000000;
  sigfillset(&action.sa_mask);
  sigaction(14, &action, ((void *)0));
  sigprocmask(0, ((void *)0), &mask);
  sigdelset(&mask, 14);
  alarm(sec);
  sigsuspend(&mask);
  return;
}

canonical_original_code:
void mysleep(int sec){
  struct sigaction action;
  struct __sigset_t mask;
  action.__sigaction_handler.sa_handler = &handle_sigalrm;
  action.sa_flags = 0x80000000;
  sigfillset(&action.sa_mask);
  sigaction(14, &action, ((void *)0));
  sigprocmask(0, ((void *)0), &mask);
  sigdelset(&mask, 14);
  alarm(sec);
  sigsuspend(&mask);
  return;
}

variable_types: sec int

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // ebx
struct sigaction v5; // [rsp+0h] [rbp-A8h] BYREF

if ( argc == 2 )
{
v4 = atol(argv[1]);
v5.sa_handler = (__sighandler_t)1;
v5.sa_flags = 0x10000000;
sigfillset(&v5.sa_mask);
sigaction(1, &v5, 0LL);
sigaction(10, &v5, 0LL);
sigaction(9, &v5, 0LL);
sigaction(2, &v5, 0LL);
mysleep(v4);
}
else
{
fwrite("./mysleep seconds ", 1uLL, 0x12uLL, stderr);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // ebx
struct sigaction v5; // [rsp+0h] [rbp-A8h] BYREF

if ( argc == 2 )
{
v4 = atol(argv[1]);
v5.sa_handler = (__sighandler_t)1;
v5.sa_flags = 0x10000000;
sigfillset(&v5.sa_mask);
sigaction(1, &v5, 0LL);
sigaction(10, &v5, 0LL);
sigaction(9, &v5, 0LL);
sigaction(2, &v5, 0LL);
func8(v4);
}
else
{
fwrite("./mysleep seconds ", 1uLL, 0x12uLL, stderr);
}
return 0;
}

original_code:
int main(int argc,char* argv[]) {
  if(argc==2){
    int sec = atol(argv[1]);
    struct sigaction action;
    action.__sigaction_handler.sa_handler = ((__sighandler_t) 1);
    action.sa_flags = 0x10000000;
    sigfillset(&action.sa_mask);
    sigaction(1, &action, ((void *)0));
    sigaction(10, &action, ((void *)0));
    sigaction(9, &action, ((void *)0));
    sigaction(2, &action, ((void *)0));
    mysleep(sec);
  }
  else{
    fprintf(stderr,"./mysleep seconds ");
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  if(argc==2){
    int sec = atol(argv[1]);
    struct sigaction action;
    action.__sigaction_handler.sa_handler = ((void (*)(int)) 1);
    action.sa_flags = 0x10000000;
    sigfillset(&action.sa_mask);
    sigaction(1, &action, ((void *)0));
    sigaction(10, &action, ((void *)0));
    sigaction(9, &action, ((void *)0));
    sigaction(2, &action, ((void *)0));
    mysleep(sec);
  }
  else{
    fprintf(stderr,"./mysleep seconds ");
  }
  return 0;
}

variable_types:
argv
char *[]

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }

user_defined_types: union sigval { int sival_int; void *sival_ptr; }


handler

decompiled_code:
void __fastcall handler(int a1)
{
++global_counter;
++counter[a1];
}

canonical_decompiled_code:
void __fastcall func7(int a1)
{
++global_counter;
++counter[a1];
}

original_code:
void handler(int sig) {
  global_counter++;
  counter[sig]++;
}


decompiled_code:
int print_stat()
{
__int64 i; // rbx
int result; // eax

printf("\nCompteur global : %d \n", (unsigned int)global_counter);
for ( i = 0LL; i != 66; ++i )
result = printf("\nCompteur pour le signal %d : %d \n", (unsigned int)i, (unsigned int)counter[i]);
return result;
}

canonical_decompiled_code:
int func8()
{
__int64 i; // rbx
int result; // eax

printf("\nCompteur global : %d \n", (unsigned int)global_counter);
for ( i = 0LL; i != 66; ++i )
result = printf("\nCompteur pour le signal %d : %d \n", (unsigned int)i, (unsigned int)counter[i]);
return result;
}

original_code:
void print_stat(){
  int i;
  printf("\nCompteur global : %d \n", global_counter);
  for(i=0;i<=(64 + 1);i++){
    printf("\nCompteur pour le signal %d : %d \n",i,counter[i]);
  }
}

variable_types: i int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int i; // ebx

for ( i = 0; i != 66; ++i )
signal(i, handler);
while ( dword_404068 <= 3 )
;
print_stat();
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int i; // ebx

for ( i = 0; i != 66; ++i )
signal(i, handler);
while ( dword_404068 <= 3 )
;
func8();
exit(0);
}

original_code:
int main() {
  int i;
  for(i=0;i<=(64 + 1);i++){
    signal(i,handler);
  }
  while (1) {
    if(counter[2]>=4){
      print_stat();
      exit(0);
    }
  }
  return 0;
}


decompiled_code:
__int64 init_default_global_state()
{
*((_QWORD *)&GlobalState + 21) = stdout;
*((_QWORD *)&GlobalState + 23) = stderr;
return set_output_line_length(*((unsigned int *)&GlobalState + 16));
}

canonical_decompiled_code:
__int64 func0()
{
*((_QWORD *)&GlobalState + 21) = stdout;
*((_QWORD *)&GlobalState + 23) = stderr;
return set_output_line_length(*((unsigned int *)&GlobalState + 16));
}

original_code:
static void
init_default_global_state(void)
{
    GlobalState.outputfile = stdout;
    GlobalState.logfile = stderr;
    set_output_line_length(GlobalState.max_line_length);
}

canonical_original_code:
static void init_default_global_state()
{
    GlobalState.outputfile = stdout;
    GlobalState.logfile = stderr;
    set_output_line_length(GlobalState.max_line_length);
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v5; // ebx
const char *v6; // rsi
const char *v7; // rsi
const char *v8; // rsi
const char *v9; // rsi
__int64 v10; // rdx
const char *v11; // rdi
char v12; // al
__int64 v13; // rcx
__int64 v14; // rdx
const char *v15; // rcx
struct _IO_FILE *v16; // rdi

init_default_global_state(argc, argv, envp);
init_game_header();
init_tag_lists();
init_hashtab();
init_lex_tables();
if ( argc > 1 )
{
v5 = 1;
do
{
v10 = v5;
v11 = argv[v10];
if ( *v11 == 45 )
{
v12 = v11[1];
v13 = (unsigned int)v12;
switch ( v12 )
{
case '#':
case 'E':
case 'b':
case 'w':
v8 = v11 + 2;
if ( v11[2] )
{
++v5;
}
else
{
if ( argc <= v5 + 1 )
{
++v5;
}
else
{
v8 = argv[v10 + 1];
v5 += 2;
}
if ( !*v8 || *v8 == 45 )
{
fprintf(*((FILE **)&GlobalState + 23), "Usage: -%c value\n", (unsigned int)v13);
exit(1);
}
}
goto LABEL_35;
case '-':
v6 = (const char *)&unk_431;
if ( v5 + 1 < argc )
v6 = argv[v10 + 1];
v5 += process_long_form_argument(v11 + 2, v6);
break;
case '7':
case 'C':
case 'D':
case 'F':
case 'M':
case 'N':
case 'P':
case 'S':
case 'U':
case 'V':
case 'W':
case 'Z':
case 'e':
case 'h':
case 'r':
case 's':
process_argument((unsigned int)v13);
++v5;
break;
case '?':
process_argument(104LL);
++v5;
break;
case 'A':
case 'L':
case 'R':
case 'a':
case 'c':
case 'd':
case 'f':
case 'l':
case 'n':
case 'o':
v7 = v11 + 2;
if ( v11[2] )
{
++v5;
}
else
{
if ( argc <= v5 + 1 )
{
++v5;
}
else
{
v7 = argv[v10 + 1];
v5 += 2;
}
if ( !*v7 || *v7 == 45 )
{
fprintf(*((FILE **)&GlobalState + 23), "Usage: -%c filename\n", (unsigned int)v13);
exit(1);
}
}
goto LABEL_35;
case 'T':
process_argument(84LL);
++v5;
break;
case 't':
case 'v':
case 'x':
case 'z':
v9 = v11 + 2;
if ( v11[2] )
{
++v5;
}
else
{
if ( argc <= v5 + 1 )
{
++v5;
}
else
{
v9 = argv[v10 + 1];
v5 += 2;
}
if ( !*v9 || *v9 == 45 )
{
fprintf(*((FILE **)&GlobalState + 23), "Usage: -%cfilename or -%c filename\n", (unsigned int)v13, v13);
exit(1);
}
}
LABEL_35:
process_argument((unsigned int)v13);
break;
default:
fprintf(*((FILE **)&GlobalState + 23), "Unknown flag %s. Use -%c for usage details.\n", argv[v5], 104LL);
exit(1);
}
}
else
{
add_filename_to_source_list(v11, 0LL, v10 * 8);
++v5;
}
}
while ( argc > v5 );
}
init_duplicate_hash_table();
if ( *((_DWORD *)&GlobalState + 12) )
{
if ( !(unsigned int)open_eco_file(*((_QWORD *)&GlobalState + 20)) )
{
fprintf(*((FILE **)&GlobalState + 23), "Unable to open the ECO file %s.\n", *((const char **)&GlobalState + 20));
exit(1);
}
*((_DWORD *)&GlobalState + 13) = 1;
yyparse(2LL);
*((_DWORD *)&GlobalState + 13) = 0;
}
if ( !(unsigned int)open_first_file() )
exit(1);
yyparse(*((unsigned int *)&GlobalState + 38));
clear_duplicate_hash_table();
if ( *((_DWORD *)&GlobalState + 1) )
{
v14 = *((_QWORD *)&GlobalState + 14);
v15 = (const char *)&unk_431;
if ( v14 != 1 )
v15 = (const char *)&unk_432;
fprintf(*((FILE **)&GlobalState + 23), "%lu game%s matched out of %lu.\n", v14, v15, *((_QWORD *)&GlobalState + 13));
}
v16 = (struct _IO_FILE *)*((_QWORD *)&GlobalState + 23);
if ( stderr != v16 && v16 )
fclose(v16);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v5; // ebx
const char *v6; // rsi
const char *v7; // rsi
const char *v8; // rsi
const char *v9; // rsi
__int64 v10; // rdx
const char *v11; // rdi
char v12; // al
__int64 v13; // rcx
__int64 v14; // rdx
const char *v15; // rcx
struct _IO_FILE *v16; // rdi

func0(argc, argv, envp);
init_game_header();
init_tag_lists();
init_hashtab();
init_lex_tables();
if ( argc > 1 )
{
v5 = 1;
do
{
v10 = v5;
v11 = argv[v10];
if ( *v11 == 45 )
{
v12 = v11[1];
v13 = (unsigned int)v12;
switch ( v12 )
{
case '#':
case 'E':
case 'b':
case 'w':
v8 = v11 + 2;
if ( v11[2] )
{
++v5;
}
else
{
if ( argc <= v5 + 1 )
{
++v5;
}
else
{
v8 = argv[v10 + 1];
v5 += 2;
}
if ( !*v8 || *v8 == 45 )
{
fprintf(*((FILE **)&GlobalState + 23), "Usage: -%c value\n", (unsigned int)v13);
exit(1);
}
}
goto LABEL_35;
case '-':
v6 = (const char *)&unk_431;
if ( v5 + 1 < argc )
v6 = argv[v10 + 1];
v5 += process_long_form_argument(v11 + 2, v6);
break;
case '7':
case 'C':
case 'D':
case 'F':
case 'M':
case 'N':
case 'P':
case 'S':
case 'U':
case 'V':
case 'W':
case 'Z':
case 'e':
case 'h':
case 'r':
case 's':
process_argument((unsigned int)v13);
++v5;
break;
case '?':
process_argument(104LL);
++v5;
break;
case 'A':
case 'L':
case 'R':
case 'a':
case 'c':
case 'd':
case 'f':
case 'l':
case 'n':
case 'o':
v7 = v11 + 2;
if ( v11[2] )
{
++v5;
}
else
{
if ( argc <= v5 + 1 )
{
++v5;
}
else
{
v7 = argv[v10 + 1];
v5 += 2;
}
if ( !*v7 || *v7 == 45 )
{
fprintf(*((FILE **)&GlobalState + 23), "Usage: -%c filename\n", (unsigned int)v13);
exit(1);
}
}
goto LABEL_35;
case 'T':
process_argument(84LL);
++v5;
break;
case 't':
case 'v':
case 'x':
case 'z':
v9 = v11 + 2;
if ( v11[2] )
{
++v5;
}
else
{
if ( argc <= v5 + 1 )
{
++v5;
}
else
{
v9 = argv[v10 + 1];
v5 += 2;
}
if ( !*v9 || *v9 == 45 )
{
fprintf(*((FILE **)&GlobalState + 23), "Usage: -%cfilename or -%c filename\n", (unsigned int)v13, v13);
exit(1);
}
}
LABEL_35:
process_argument((unsigned int)v13);
break;
default:
fprintf(*((FILE **)&GlobalState + 23), "Unknown flag %s. Use -%c for usage details.\n", argv[v5], 104LL);
exit(1);
}
}
else
{
add_filename_to_source_list(v11, 0LL, v10 * 8);
++v5;
}
}
while ( argc > v5 );
}
init_duplicate_hash_table();
if ( *((_DWORD *)&GlobalState + 12) )
{
if ( !(unsigned int)open_eco_file(*((_QWORD *)&GlobalState + 20)) )
{
fprintf(*((FILE **)&GlobalState + 23), "Unable to open the ECO file %s.\n", *((const char **)&GlobalState + 20));
exit(1);
}
*((_DWORD *)&GlobalState + 13) = 1;
yyparse(2LL);
*((_DWORD *)&GlobalState + 13) = 0;
}
if ( !(unsigned int)open_first_file() )
exit(1);
yyparse(*((unsigned int *)&GlobalState + 38));
clear_duplicate_hash_table();
if ( *((_DWORD *)&GlobalState + 1) )
{
v14 = *((_QWORD *)&GlobalState + 14);
v15 = (const char *)&unk_431;
if ( v14 != 1 )
v15 = (const char *)&unk_432;
fprintf(*((FILE **)&GlobalState + 23), "%lu game%s matched out of %lu.\n", v14, v15, *((_QWORD *)&GlobalState + 13));
}
v16 = (struct _IO_FILE *)*((_QWORD *)&GlobalState + 23);
if ( stderr != v16 && v16 )
fclose(v16);
return 0;
}

original_code:
int
main(int argc, char *argv[])
{ int argnum;
    init_default_global_state();
    init_game_header();
    init_tag_lists();
    init_hashtab();
    init_lex_tables();
    for(argnum = 1; argnum < argc; ){
        const char *argument = argv[argnum];
        if(argument[0] == '-'){
            switch(argument[1]){
                case SEVEN_TAG_ROSTER_ARGUMENT:
                case DONT_KEEP_COMMENTS_ARGUMENT:
                case DONT_KEEP_DUPLICATES_ARGUMENT:
                case DONT_KEEP_VARIATIONS_ARGUMENT:
                case DONT_KEEP_NAGS_ARGUMENT:
                case DONT_MATCH_PERMUTATIONS_ARGUMENT:
                case CHECK_ONLY_ARGUMENT:
                case KEEP_SILENT_ARGUMENT:
                case USE_SOUNDEX_ARGUMENT:
                case MATCH_CHECKMATE_ARGUMENT:
                case SUPPRESS_ORIGINALS_ARGUMENT:
                case OUTPUT_FEN_STRING_ARGUMENT:
                case USE_VIRTUAL_HASH_TABLE_ARGUMENT:
                    process_argument(argument[1], "");
                    argnum++;
                    break;
                case ALTERNATIVE_HELP_ARGUMENT:
                    process_argument(HELP_ARGUMENT, "");
                    argnum++;
                    break;
                case TAG_EXTRACTION_ARGUMENT:
                    process_argument(argument[1], &(argument[2]));
                    argnum++;
                    break;
                case USE_ECO_FILE_ARGUMENT:
                case OUTPUT_FORMAT_ARGUMENT:
                case HELP_ARGUMENT:
                    process_argument(argument[1], &(argument[2]));
                    argnum++;
                    break;
                case LONG_FORM_ARGUMENT:
                    {
                      int args_processed;
                      const char *possible_associated_value = "";
                      if(argnum + 1 < argc) {
                          possible_associated_value = argv[argnum+1];
                      }
                      args_processed =
                          process_long_form_argument(&argument[2],
                                                     possible_associated_value);
                      argnum += args_processed;
                    }
                    break;
                case FILE_OF_ARGUMENTS_ARGUMENT:
                case APPEND_TO_OUTPUT_FILE_ARGUMENT:
                case CHECK_FILE_ARGUMENT:
                case DUPLICATES_FILE_ARGUMENT:
                case FILE_OF_FILES_ARGUMENT:
                case WRITE_TO_LOG_FILE_ARGUMENT:
                case APPEND_TO_LOG_FILE_ARGUMENT:
                case NON_MATCHING_GAMES_ARGUMENT:
                case WRITE_TO_OUTPUT_FILE_ARGUMENT:
                case TAG_ROSTER_ARGUMENT:
                    {
                        const char argument_letter = argument[1];
                        const char *filename = &(argument[2]);
                        if(*filename == '\0'){
                             argnum++;
                             if(argnum < argc){
                                 filename = argv[argnum];
                                 argnum++;
                             }
                            if((*filename == '\0') || (*filename == '-')){
                                fprintf(GlobalState.logfile,
                                        "Usage: -%c filename\n",
                                        argument_letter);
                                exit(1);
                            }
                        }
                        else {
                            argnum++;
                        }
                        process_argument(argument[1], filename);
                    }
                    break;
                case BOUNDS_ARGUMENT:
                case ECO_OUTPUT_LEVEL_ARGUMENT:
                case LINE_WIDTH_ARGUMENT:
                case GAMES_PER_FILE_ARGUMENT:
                    {
                        const char argument_letter = argument[1];
                        const char *associated_value = &(argument[2]);
                        if(*associated_value == '\0'){
                             argnum++;
                             if(argnum < argc){
                                 associated_value = argv[argnum];
                                 argnum++;
                             }
                            if((*associated_value == '\0') ||
                                       (*associated_value == '-')){
                                fprintf(GlobalState.logfile,
                                        "Usage: -%c value\n",
                                        argument_letter);
                                exit(1);
                            }
                        }
                        else {
                            argnum++;
                        }
                        process_argument(argument[1], associated_value);
                    }
                    break;
                case TAGS_ARGUMENT:
                case MOVES_ARGUMENT:
                case POSITIONS_ARGUMENT:
                case ENDINGS_ARGUMENT:
                    {
                        const char *filename = &(argument[2]);
                        const char argument_letter = argument[1];
                        if(*filename == '\0'){
                             argnum++;
                             if(argnum < argc){
                                 filename = argv[argnum];
                                 argnum++;
                             }
                            if((*filename == '\0') || (*filename == '-')){
                                fprintf(GlobalState.logfile,
                                        "Usage: -%cfilename or -%c filename\n",
                                        argument_letter,argument_letter);
                                exit(1);
                            }
                        }
                        else{
                            argnum++;
                        }
                        process_argument(argument_letter,filename);
                    }
                    break;
                default:
                    fprintf(GlobalState.logfile,
                            "Unknown flag %s. Use -%c for usage details.\n",
                            argument,HELP_ARGUMENT);
                    exit(1);
                    break;
            }
        }
        else{
            add_filename_to_source_list(argument,NORMALFILE);
            argnum++;
        }
    }
    init_duplicate_hash_table();
    if(GlobalState.add_ECO){
        if(open_eco_file(GlobalState.eco_file)){
            GlobalState.parsing_ECO_file = TRUE;
            yyparse(ECOFILE);
            GlobalState.parsing_ECO_file = FALSE;
        }
        else{
            fprintf(GlobalState.logfile,"Unable to open the ECO file %s.\n",
                        GlobalState.eco_file);
            exit(1);
        }
    }
    if(!open_first_file()){
        exit(1);
    }
    yyparse(GlobalState.current_file_type);
    clear_duplicate_hash_table();
    if(GlobalState.verbose){
        fprintf(GlobalState.logfile,"%lu game%s matched out of %lu.\n",
                        GlobalState.num_games_matched,
                        GlobalState.num_games_matched == 1?"":"s",
                        GlobalState.num_games_processed);
    }
    if((GlobalState.logfile != stderr) && (GlobalState.logfile != ((void *)0))){
        (void) fclose(GlobalState.logfile);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{ int argnum;
    init_default_global_state();
    init_game_header();
    init_tag_lists();
    init_hashtab();
    init_lex_tables();
    for(argnum = 1; argnum < argc; ){
        char *argument = argv[argnum];
        if(argument[0] == '-'){
            switch(argument[1]){
                case SEVEN_TAG_ROSTER_ARGUMENT:
                case DONT_KEEP_COMMENTS_ARGUMENT:
                case DONT_KEEP_DUPLICATES_ARGUMENT:
                case DONT_KEEP_VARIATIONS_ARGUMENT:
                case DONT_KEEP_NAGS_ARGUMENT:
                case DONT_MATCH_PERMUTATIONS_ARGUMENT:
                case CHECK_ONLY_ARGUMENT:
                case KEEP_SILENT_ARGUMENT:
                case USE_SOUNDEX_ARGUMENT:
                case MATCH_CHECKMATE_ARGUMENT:
                case SUPPRESS_ORIGINALS_ARGUMENT:
                case OUTPUT_FEN_STRING_ARGUMENT:
                case USE_VIRTUAL_HASH_TABLE_ARGUMENT:
                    process_argument(argument[1], "");
                    argnum++;
                    break;
                case ALTERNATIVE_HELP_ARGUMENT:
                    process_argument(HELP_ARGUMENT, "");
                    argnum++;
                    break;
                case TAG_EXTRACTION_ARGUMENT:
                    process_argument(argument[1], &(argument[2]));
                    argnum++;
                    break;
                case USE_ECO_FILE_ARGUMENT:
                case OUTPUT_FORMAT_ARGUMENT:
                case HELP_ARGUMENT:
                    process_argument(argument[1], &(argument[2]));
                    argnum++;
                    break;
                case LONG_FORM_ARGUMENT:
                    {
                      int args_processed;
                      char *possible_associated_value = "";
                      if(argnum + 1 < argc) {
                          possible_associated_value = argv[argnum+1];
                      }
                      args_processed =
                          process_long_form_argument(&argument[2],
                                                     possible_associated_value);
                      argnum += args_processed;
                    }
                    break;
                case FILE_OF_ARGUMENTS_ARGUMENT:
                case APPEND_TO_OUTPUT_FILE_ARGUMENT:
                case CHECK_FILE_ARGUMENT:
                case DUPLICATES_FILE_ARGUMENT:
                case FILE_OF_FILES_ARGUMENT:
                case WRITE_TO_LOG_FILE_ARGUMENT:
                case APPEND_TO_LOG_FILE_ARGUMENT:
                case NON_MATCHING_GAMES_ARGUMENT:
                case WRITE_TO_OUTPUT_FILE_ARGUMENT:
                case TAG_ROSTER_ARGUMENT:
                    {
                        char argument_letter = argument[1];
                        char *filename = &(argument[2]);
                        if(*filename == '\0'){
                             argnum++;
                             if(argnum < argc){
                                 filename = argv[argnum];
                                 argnum++;
                             }
                            if((*filename == '\0') || (*filename == '-')){
                                fprintf(GlobalState.logfile,
                                        "Usage: -%c filename\n",
                                        argument_letter);
                                exit(1);
                            }
                        }
                        else {
                            argnum++;
                        }
                        process_argument(argument[1], filename);
                    }
                    break;
                case BOUNDS_ARGUMENT:
                case ECO_OUTPUT_LEVEL_ARGUMENT:
                case LINE_WIDTH_ARGUMENT:
                case GAMES_PER_FILE_ARGUMENT:
                    {
                        char argument_letter = argument[1];
                        char *associated_value = &(argument[2]);
                        if(*associated_value == '\0'){
                             argnum++;
                             if(argnum < argc){
                                 associated_value = argv[argnum];
                                 argnum++;
                             }
                            if((*associated_value == '\0') ||
                                       (*associated_value == '-')){
                                fprintf(GlobalState.logfile,
                                        "Usage: -%c value\n",
                                        argument_letter);
                                exit(1);
                            }
                        }
                        else {
                            argnum++;
                        }
                        process_argument(argument[1], associated_value);
                    }
                    break;
                case TAGS_ARGUMENT:
                case MOVES_ARGUMENT:
                case POSITIONS_ARGUMENT:
                case ENDINGS_ARGUMENT:
                    {
                        char *filename = &(argument[2]);
                        char argument_letter = argument[1];
                        if(*filename == '\0'){
                             argnum++;
                             if(argnum < argc){
                                 filename = argv[argnum];
                                 argnum++;
                             }
                            if((*filename == '\0') || (*filename == '-')){
                                fprintf(GlobalState.logfile,
                                        "Usage: -%cfilename or -%c filename\n",
                                        argument_letter,argument_letter);
                                exit(1);
                            }
                        }
                        else{
                            argnum++;
                        }
                        process_argument(argument_letter,filename);
                    }
                    break;
                default:
                    fprintf(GlobalState.logfile,
                            "Unknown flag %s. Use -%c for usage details.\n",
                            argument,HELP_ARGUMENT);
                    exit(1);
                    break;
            }
        }
        else{
            add_filename_to_source_list(argument,NORMALFILE);
            argnum++;
        }
    }
    init_duplicate_hash_table();
    if(GlobalState.add_ECO){
        if(open_eco_file(GlobalState.eco_file)){
            GlobalState.parsing_ECO_file = TRUE;
            yyparse(ECOFILE);
            GlobalState.parsing_ECO_file = FALSE;
        }
        else{
            fprintf(GlobalState.logfile,"Unable to open the ECO file %s.\n",
                        GlobalState.eco_file);
            exit(1);
        }
    }
    if(!open_first_file()){
        exit(1);
    }
    yyparse(GlobalState.current_file_type);
    clear_duplicate_hash_table();
    if(GlobalState.verbose){
        fprintf(GlobalState.logfile,"%lu game%s matched out of %lu.\n",
                        GlobalState.num_games_matched,
                        GlobalState.num_games_matched == 1?"":"s",
                        GlobalState.num_games_processed);
    }
    if((GlobalState.logfile != stderr) && (GlobalState.logfile != ((void *)0))){
        (void) fclose(GlobalState.logfile);
    }
    return 0;
}

variable_types: argnum int

variable_types:
argument
char *

variable_types:
filename
char *


MallocOrDie

decompiled_code:
void *__fastcall MallocOrDie(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
perror("Malloc Or Die");
abort();
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
perror("Malloc Or Die");
abort();
}
return result;
}

original_code:
void *
MallocOrDie(size_t nbytes)
{ void *result;
    result = malloc(nbytes);
    if(result == ((void *)0)){
        perror("Malloc Or Die");
        abort();
    }
    return result;
}

canonical_original_code:
void *MallocOrDie(unsigned long nbytes)
{ void *result;
    result = malloc(nbytes);
    if(result == ((void *)0)){
        perror("Malloc Or Die");
        abort();
    }
    return result;
}

variable_types:
nbytes
unsigned long

variable_types:
result
void *

return_type: void *


ReallocOrDie

decompiled_code:
void *__fastcall ReallocOrDie(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
perror("Realloc Or Die");
abort();
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
perror("Realloc Or Die");
abort();
}
return result;
}

original_code:
void *
ReallocOrDie(void *space,size_t nbytes)
{ void *result;
    result = realloc(space,nbytes);
    if(result == ((void *)0)){
        perror("Realloc Or Die");
        abort();
    }
    return result;
}

canonical_original_code:
void *ReallocOrDie(void *space, unsigned long nbytes)
{ void *result;
    result = realloc(space,nbytes);
    if(result == ((void *)0)){
        perror("Realloc Or Die");
        abort();
    }
    return result;
}

variable_types:
space
void *


decompiled_code:
__int64 __fastcall move_char(char a1)
{
return (a1 == 45) | (unsigned __int8)(((*_ctype_b_loc())[a1] & 0xC00) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1)
{
return (a1 == 45) | (unsigned __int8)(((*_ctype_b_loc())[a1] & 0xC00) != 0);
}

original_code:
static Boolean
move_char(char c)
{
    return (Boolean) ((*__ctype_b_loc ())[(int) (((int) c))] & (unsigned short int) _ISalpha) || ((*__ctype_b_loc ())[(int) (((int) c))] & (unsigned short int) _ISdigit) || (c == '-');
}

canonical_original_code:
static enum Boolean move_char(char c)
{
    return (Boolean) ((*__ctype_b_loc ())[(int) (((int) c))] & (unsigned short) _ISalpha) || ((*__ctype_b_loc ())[(int) (((int) c))] & (unsigned short) _ISdigit) || (c == '-');
}

variable_types: c char

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


decompiled_code:
__int64 __fastcall compose_positional_variation(char *a1)
{
char *v1; // rdi
__int64 v2; // r13
int v3; // ebx
int v4; // ebp
__int64 v5; // r12
char *v6; // rax
char *v7; // rax
const char *v8; // r15
__int64 v9; // rax
unsigned int v11; // eax

v1 = strtok(a1, " ");
v2 = (__int64)v1;
v3 = 0;
if ( !v1 )
goto LABEL_18;
v3 = 0;
v4 = 1;
v5 = 0LL;
v2 = 0LL;
do
{
if ( *v1 == 42 )
break;
v7 = strip_move_number(v1);
v8 = v7;
if ( v7 )
{
v9 = decode_move(v7);
if ( v9 )
{
if ( v5 )
*(_QWORD *)(v5 + 88) = v9;
else
v2 = v9;
*(_QWORD *)(v9 + 88) = 0LL;
v5 = v9;
}
else
{
fprintf(*((FILE **)&GlobalState + 23), "Failed to identify %s\n", v8);
v4 = 0;
}
++v3;
}
v6 = strtok(0LL, " ");
v1 = v6;
if ( !v4 )
break;
}
while ( v6 );
if ( v4 )
{
LABEL_18:
v11 = ((unsigned int)(v3 + 1) >> 1) + 4;
if ( *((_DWORD *)&GlobalState + 24) < v11 )
*((_DWORD *)&GlobalState + 24) = v11;
}
else if ( v2 )
{
free_move_list(v2);
v2 = 0LL;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1)
{
char *v1; // rdi
__int64 v2; // r13
int v3; // ebx
int v4; // ebp
__int64 v5; // r12
char *v6; // rax
char *v7; // rax
const char *v8; // r15
__int64 v9; // rax
unsigned int v11; // eax

v1 = strtok(a1, " ");
v2 = (__int64)v1;
v3 = 0;
if ( !v1 )
goto LABEL_18;
v3 = 0;
v4 = 1;
v5 = 0LL;
v2 = 0LL;
do
{
if ( *v1 == 42 )
break;
v7 = func0(v1);
v8 = v7;
if ( v7 )
{
v9 = decode_move(v7);
if ( v9 )
{
if ( v5 )
*(_QWORD *)(v5 + 88) = v9;
else
v2 = v9;
*(_QWORD *)(v9 + 88) = 0LL;
v5 = v9;
}
else
{
fprintf(*((FILE **)&GlobalState + 23), "Failed to identify %s\n", v8);
v4 = 0;
}
++v3;
}
v6 = strtok(0LL, " ");
v1 = v6;
if ( !v4 )
break;
}
while ( v6 );
if ( v4 )
{
LABEL_18:
v11 = ((unsigned int)(v3 + 1) >> 1) + 4;
if ( *((_DWORD *)&GlobalState + 24) < v11 )
*((_DWORD *)&GlobalState + 24) = v11;
}
else if ( v2 )
{
free_move_list(v2);
v2 = 0LL;
}
return v2;
}

original_code:
static Move *
compose_positional_variation(char *line)
{ char *move;
    Move *head = ((void *)0), *tail = ((void *)0);
    Boolean Ok = TRUE;
    unsigned depth = 0;
    move = strtok(line," ");
    while(Ok && (move != ((void *)0)) && (*move != '*')){
        if((move = strip_move_number(move)) == ((void *)0)){
        }
        else{
            Move *next = decode_move((unsigned char *) move);
            if(next == ((void *)0)){
                fprintf(GlobalState.logfile,"Failed to identify %s\n",move);
                Ok = FALSE;
            }
            else{
                if(tail == ((void *)0)){
                    head = next;
                    tail = next;
                }
                else{
                    tail->next = next;
                    tail = next;
                }
                next->next = ((void *)0);
            }
            depth++;
        }
        move = strtok(((void *)0)," ");
    }
    if(Ok){
        depth = ((depth+1) / 2) + 4;
        if(depth > GlobalState.depth_of_positional_search){
            GlobalState.depth_of_positional_search = depth;
        }
    }
    else{
        if(head != ((void *)0)){
            free_move_list(head);
        }
        head = ((void *)0);
    }
    return head;
}

canonical_original_code:
static struct move *compose_positional_variation(char *line)
{ char *move;
    struct move *head = ((void *)0); struct move *tail = ((void *)0);
    enum Boolean Ok = TRUE;
    unsigned int depth = 0;
    move = strtok(line," ");
    while(Ok && (move != ((void *)0)) && (*move != '*')){
        if((move = strip_move_number(move)) == ((void *)0)){
        }
        else{
            struct move *next = decode_move((unsigned char *) move);
            if(next == ((void *)0)){
                fprintf(GlobalState.logfile,"Failed to identify %s\n",move);
                Ok = FALSE;
            }
            else{
                if(tail == ((void *)0)){
                    head = next;
                    tail = next;
                }
                else{
                    tail->next = next;
                    tail = next;
                }
                next->next = ((void *)0);
            }
            depth++;
        }
        move = strtok(((void *)0)," ");
    }
    if(Ok){
        depth = ((depth+1) / 2) + 4;
        if(depth > GlobalState.depth_of_positional_search){
            GlobalState.depth_of_positional_search = depth;
        }
    }
    else{
        if(head != ((void *)0)){
            free_move_list(head);
        }
        head = ((void *)0);
    }
    return head;
}

variable_types:
line
char *

variable_types:
move
char *

variable_types: struct move { unsigned char move[-1]; enum MoveClass { PAWN_MOVE=0, PAWN_MOVE_WITH_PROMOTION=1, ENPASSANT_PAWN_MOVE=2, PIECE_MOVE=3, KINGSIDE_CASTLE=4, QUEENSIDE_CASTLE=5, UNKNOWN_MOVE=6 } class; char from_col; char from_rank; char to_col; char to_rank; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } piece_to_move; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } captured_piece; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } promoted_piece; enum CheckStatus { NOCHECK=0, CHECK=1, CHECKMATE=2 } check_status; char *epd; struct string_list { char *str; struct string_list *next; } *Nags; struct comment_list { struct string_list *Comment; struct comment_list *next; } *Comment; char *terminating_result; struct variation { struct comment_list *prefix_comment; struct move *moves; struct comment_list *suffix_comment; struct variation *next; } *Variants; struct move *prev; } *

variable_types:
Ok
enum Boolean { FALSE=0, TRUE=1 }

variable_types:
depth
unsigned int

user_defined_types: struct move { unsigned char move[-1]; enum MoveClass class; char from_col; char from_rank; char to_col; char to_rank; enum Piece piece_to_move; enum Piece captured_piece; enum Piece promoted_piece; enum CheckStatus check_status; char *epd; struct string_list *Nags; struct comment_list *Comment; char *terminating_result; struct variation *Variants; struct move *prev; }


decompiled_code:
__int64 __fastcall textual_variation_match(char *haystack, char *needle)
{
char *v2; // rbx
char *v3; // rax
int v4; // er13
size_t v5; // rax
size_t v7; // rax

if ( !haystack )
return 0LL;
v2 = haystack;
while ( 1 )
{
v3 = strstr(v2, needle);
v2 = v3;
if ( !v3 )
return 0LL;
if ( haystack == v3 )
break;
v4 = move_char(*(v3 - 1));
v5 = strlen(needle);
if ( !(unsigned int)move_char(v2[v5]) && !v4 )
return 1LL;
LABEL_4:
while ( (unsigned int)move_char(*v2) )
++v2;
}
v7 = strlen(needle);
if ( (unsigned int)move_char(v2[v7]) )
goto LABEL_4;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *haystack, char *needle)
{
char *v2; // rbx
char *v3; // rax
int v4; // er13
size_t v5; // rax
size_t v7; // rax

if ( !haystack )
return 0LL;
v2 = haystack;
while ( 1 )
{
v3 = strstr(v2, needle);
v2 = v3;
if ( !v3 )
return 0LL;
if ( haystack == v3 )
break;
v4 = func1(*(v3 - 1));
v5 = strlen(needle);
if ( !(unsigned int)func1(v2[v5]) && !v4 )
return 1LL;
LABEL_4:
while ( (unsigned int)func1(*v2) )
++v2;
}
v7 = strlen(needle);
if ( (unsigned int)func1(v2[v7]) )
goto LABEL_4;
return 1LL;
}

original_code:
static Boolean
textual_variation_match(const char *variation_move,const unsigned char *actual_move)
{ const char *match_point;
    Boolean found = FALSE;
    for(match_point = variation_move; !found && (match_point != ((void *)0)); ){
        match_point = strstr(match_point,(const char *) actual_move);
        if(match_point != ((void *)0)){
            found = TRUE;
            if(match_point != variation_move){
                if(move_char(match_point[-1])){
                    found = FALSE;
                }
            }
            if(move_char(match_point[strlen((const char *) actual_move)])){
                found = FALSE;
            }
            if(!found){
                while(move_char(*match_point)){
                    match_point++;
                }
            }
        }
    }
    return found;
}

canonical_original_code:
static enum Boolean textual_variation_match(char *variation_move, unsigned char *actual_move)
{ char *match_point;
    enum Boolean found = FALSE;
    for(match_point = variation_move; !found && (match_point != ((void *)0)); ){
        match_point = strstr(match_point,(char *) actual_move);
        if(match_point != ((void *)0)){
            found = TRUE;
            if(match_point != variation_move){
                if(move_char(match_point[-1])){
                    found = FALSE;
                }
            }
            if(move_char(match_point[strlen((char *) actual_move)])){
                found = FALSE;
            }
            if(!found){
                while(move_char(*match_point)){
                    match_point++;
                }
            }
        }
    }
    return found;
}

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


original_code:
static Boolean
permutation_match(Move *current_game_head, variation_list variation)
{ variant_move *moves_of_the_variation;
    Move *next_move;
    unsigned variant_index = 0;
    Boolean matches = TRUE;
    unsigned matched_moves = 0;
    Boolean white_to_move = TRUE;
    moves_of_the_variation = variation.moves;
    for(variant_index = 0; variant_index < variation.length; variant_index++){
        moves_of_the_variation[variant_index].matched = FALSE;
    }
    next_move = current_game_head;
    if((variation.num_white_disallowed_moves > 0) ||
            (variation.num_black_disallowed_moves > 0)){
        unsigned tested_moves = 0;
        Boolean disallowed_move_found = FALSE;
        while((!disallowed_move_found) && (tested_moves < variation.length) &&
                                        (next_move != ((void *)0))){
            if(white_to_move){
                variant_index = 0;
            }
            else{
                variant_index = 1;
            }
            while((!disallowed_move_found) && (variant_index < variation.length)){
                if((*moves_of_the_variation[variant_index].move ==
                            '!') &&
                   (textual_variation_match(
                      moves_of_the_variation[variant_index].move,next_move->move))){
                    disallowed_move_found = TRUE;
                }
                if(!disallowed_move_found){
                    variant_index += 2;
                }
            }
            if(!disallowed_move_found){
                tested_moves++;
                white_to_move = !white_to_move;
                next_move = next_move->next;
            }
        }
        if(disallowed_move_found){
            matches = FALSE;
        }
        else{
            for(variant_index = 0; variant_index < variation.length; variant_index++){
                if(*moves_of_the_variation[variant_index].move == '!'){
                    moves_of_the_variation[variant_index].matched = TRUE;
                    if((variant_index & 1) == 0){
                        variation.num_white_any_moves++;
                    }
                    else{
                        variation.num_black_any_moves++;
                    }
                }
            }
        }
    }
    next_move = current_game_head;
    white_to_move = TRUE;
    while(matches && (matched_moves < variation.length) && (next_move != ((void *)0))){
        matches = FALSE;
        if(white_to_move){
            variant_index = 0;
        }
        else{
            variant_index = 1;
        }
        while((!matches) && (variant_index < variation.length)){
            if(moves_of_the_variation[variant_index].matched){
            }
            else{
                Boolean this_move_matches = textual_variation_match(
                            moves_of_the_variation[variant_index].move,
                                        next_move->move);
                if(this_move_matches){
                    moves_of_the_variation[variant_index].matched = TRUE;
                    matches = TRUE;
                }
            }
            if(!matches){
                variant_index += 2;
            }
        }
        if(!matches){
            if(white_to_move && (variation.num_white_any_moves > 0)){
                matches = TRUE;
                variation.num_white_any_moves--;
            }
            else if(!white_to_move && (variation.num_black_any_moves > 0)){
                matches = TRUE;
                variation.num_black_any_moves--;
            }
            else{
            }
        }
        if(matches){
            matched_moves++;
            next_move = next_move->next;
            white_to_move = !white_to_move;
        }
    }
    if(matches){
        matches = matched_moves == (variation.length);
    }
    return matches;
}

canonical_original_code:
static enum Boolean permutation_match(struct move *current_game_head, struct variation_list variation)
{ struct variant_move *moves_of_the_variation;
    struct move *next_move;
    unsigned int variant_index = 0;
    enum Boolean matches = TRUE;
    unsigned int matched_moves = 0;
    enum Boolean white_to_move = TRUE;
    moves_of_the_variation = variation.moves;
    for(variant_index = 0; variant_index < variation.length; variant_index++){
        moves_of_the_variation[variant_index].matched = FALSE;
    }
    next_move = current_game_head;
    if((variation.num_white_disallowed_moves > 0) ||
            (variation.num_black_disallowed_moves > 0)){
        unsigned int tested_moves = 0;
        enum Boolean disallowed_move_found = FALSE;
        while((!disallowed_move_found) && (tested_moves < variation.length) &&
                                        (next_move != ((void *)0))){
            if(white_to_move){
                variant_index = 0;
            }
            else{
                variant_index = 1;
            }
            while((!disallowed_move_found) && (variant_index < variation.length)){
                if((*moves_of_the_variation[variant_index].move ==
                            '!') &&
                   (textual_variation_match(
                      moves_of_the_variation[variant_index].move,next_move->move))){
                    disallowed_move_found = TRUE;
                }
                if(!disallowed_move_found){
                    variant_index += 2;
                }
            }
            if(!disallowed_move_found){
                tested_moves++;
                white_to_move = !white_to_move;
                next_move = next_move->next;
            }
        }
        if(disallowed_move_found){
            matches = FALSE;
        }
        else{
            for(variant_index = 0; variant_index < variation.length; variant_index++){
                if(*moves_of_the_variation[variant_index].move == '!'){
                    moves_of_the_variation[variant_index].matched = TRUE;
                    if((variant_index & 1) == 0){
                        variation.num_white_any_moves++;
                    }
                    else{
                        variation.num_black_any_moves++;
                    }
                }
            }
        }
    }
    next_move = current_game_head;
    white_to_move = TRUE;
    while(matches && (matched_moves < variation.length) && (next_move != ((void *)0))){
        matches = FALSE;
        if(white_to_move){
            variant_index = 0;
        }
        else{
            variant_index = 1;
        }
        while((!matches) && (variant_index < variation.length)){
            if(moves_of_the_variation[variant_index].matched){
            }
            else{
                enum Boolean this_move_matches = textual_variation_match(
                            moves_of_the_variation[variant_index].move,
                                        next_move->move);
                if(this_move_matches){
                    moves_of_the_variation[variant_index].matched = TRUE;
                    matches = TRUE;
                }
            }
            if(!matches){
                variant_index += 2;
            }
        }
        if(!matches){
            if(white_to_move && (variation.num_white_any_moves > 0)){
                matches = TRUE;
                variation.num_white_any_moves--;
            }
            else if(!white_to_move && (variation.num_black_any_moves > 0)){
                matches = TRUE;
                variation.num_black_any_moves--;
            }
            else{
            }
        }
        if(matches){
            matched_moves++;
            next_move = next_move->next;
            white_to_move = !white_to_move;
        }
    }
    if(matches){
        matches = matched_moves == (variation.length);
    }
    return matches;
}

variable_types: struct variation_list { struct variant_move { char *move; enum Boolean { FALSE=0, TRUE=1 } matched; } *moves; unsigned int num_white_any_moves; unsigned int num_black_any_moves; unsigned int num_white_disallowed_moves; unsigned int num_black_disallowed_moves; unsigned int length; struct variation_list *next; }

variable_types:
matches
enum Boolean { FALSE=0, TRUE=1 }

user_defined_types: struct variation_list { struct variant_move *moves; unsigned int num_white_any_moves; unsigned int num_black_any_moves; unsigned int num_white_disallowed_moves; unsigned int num_black_disallowed_moves; unsigned int length; struct variation_list *next; }

user_defined_types: struct variant_move { char *move; enum Boolean matched; }

user_defined_types: enum MoveClass { PAWN_MOVE=0, PAWN_MOVE_WITH_PROMOTION=1, ENPASSANT_PAWN_MOVE=2, PIECE_MOVE=3, KINGSIDE_CASTLE=4, QUEENSIDE_CASTLE=5, UNKNOWN_MOVE=6 }

user_defined_types: enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 }

user_defined_types: enum CheckStatus { NOCHECK=0, CHECK=1, CHECKMATE=2 }

user_defined_types: struct string_list { char *str; struct string_list *next; }

user_defined_types: struct comment_list { struct string_list *Comment; struct comment_list *next; }

user_defined_types: struct variation { struct comment_list *prefix_comment; struct move *moves; struct comment_list *suffix_comment; struct variation *next; }


decompiled_code:
__int64 __fastcall add_positional_variation_from_line(char *a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = non_blank_line();
if ( (_DWORD)result )
{
result = compose_positional_variation(a1);
v2 = result;
if ( result )
{
store_hash_value(result, 0LL);
result = free_move_list(v2);
GlobalState[7] = 1;
}
}
return result;
}

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

result = non_blank_line();
if ( (_DWORD)result )
{
result = func2(a1);
v2 = result;
if ( result )
{
store_hash_value(result, 0LL);
result = free_move_list(v2);
GlobalState[7] = 1;
}
}
return result;
}

original_code:
void
add_positional_variation_from_line(char *line)
{
    if(non_blank_line(line)){
        Move *next_variation = compose_positional_variation(line);
        if(next_variation != ((void *)0)){
            store_hash_value(next_variation,(const char *)((void *)0));
            free_move_list(next_variation);
            GlobalState.positional_variations = TRUE;
        }
    }
}

canonical_original_code:
void add_positional_variation_from_line(char *line)
{
    if(non_blank_line(line)){
        struct move *next_variation = compose_positional_variation(line);
        if(next_variation != ((void *)0)){
            store_hash_value(next_variation,(char *)((void *)0));
            free_move_list(next_variation);
            GlobalState.positional_variations = TRUE;
        }
    }
}


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

result = store_hash_value(0LL, a1);
GlobalState[7] = 1;
return result;
}

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

result = store_hash_value(0LL, a1);
GlobalState[7] = 1;
return result;
}

original_code:
void
add_fen_positional_match(const char *fen_string)
{
    store_hash_value((Move *)((void *)0),fen_string);
    GlobalState.positional_variations = TRUE;
}

canonical_original_code:
void add_fen_positional_match(char *fen_string)
{
    store_hash_value((struct move *)((void *)0),fen_string);
    GlobalState.positional_variations = TRUE;
}


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

result = 1LL;
if ( GlobalState[19] )
{
for ( ; a1; a1 = *(_QWORD *)(a1 + 88) )
{
if ( *(_DWORD *)(a1 + 36) == 2 )
break;
}
result = a1 != 0;
}
return result;
}

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

result = 1LL;
if ( GlobalState[19] )
{
for ( ; a1; a1 = *(_QWORD *)(a1 + 88) )
{
if ( *(_DWORD *)(a1 + 36) == 2 )
break;
}
result = a1 != 0;
}
return result;
}

original_code:
Boolean
check_for_only_checkmate(const Move *moves)
{
    if(GlobalState.match_only_checkmate) {
        while(moves != ((void *)0) && moves->check_status != CHECKMATE) {
            moves = moves->next;
        }
        if(moves == ((void *)0)) {
            return FALSE;
        }
        else {
            return TRUE;
        }
    }
    else {
        return TRUE;
    }
}

canonical_original_code:
enum Boolean check_for_only_checkmate(struct move *moves)
{
    if(GlobalState.match_only_checkmate) {
        while(moves != ((void *)0) && moves->check_status != CHECKMATE) {
            moves = moves->next;
        }
        if(moves == ((void *)0)) {
            return FALSE;
        }
        else {
            return TRUE;
        }
    }
    else {
        return TRUE;
    }
}


decompiled_code:
__int64 __fastcall check_for_only_stalemate(__int64 a1, __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // edx

if ( !GlobalState[20] || !a2 )
return 1;
do
{
v2 = a2;
a2 = *(_QWORD *)(a2 + 88);
}
while ( a2 );
v3 = 0;
if ( !*(_DWORD *)(v2 + 36) )
return find_all_moves(a1, *(unsigned int *)(a1 + 576), 0LL) == 0;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // edx

if ( !GlobalState[20] || !a2 )
return 1;
do
{
v2 = a2;
a2 = *(_QWORD *)(a2 + 88);
}
while ( a2 );
v3 = 0;
if ( !*(_DWORD *)(v2 + 36) )
return find_all_moves(a1, *(unsigned int *)(a1 + 576), 0LL) == 0;
return v3;
}

original_code:
Boolean
check_for_only_stalemate(const Board *board, const Move *moves)
{
    if(GlobalState.match_only_stalemate) {
        const Move *move = moves;
        if(move != ((void *)0)) {
            MovePair *available_moves;
            while(move->next != ((void *)0)) {
                move = move->next;
            }
            if(move->check_status != NOCHECK) {
                return FALSE;
            }
            available_moves = find_all_moves(board, board->to_move);
            if(available_moves == ((void *)0)) {
                return TRUE;
            }
            else {
                return FALSE;
            }
        }
        else {
            return TRUE;
        }
    }
    else {
        return TRUE;
    }
}

canonical_original_code:
enum Boolean check_for_only_stalemate(struct Board *board, struct move *moves)
{
    if(GlobalState.match_only_stalemate) {
        struct move *move = moves;
        if(move != ((void *)0)) {
            struct move_pair *available_moves;
            while(move->next != ((void *)0)) {
                move = move->next;
            }
            if(move->check_status != NOCHECK) {
                return FALSE;
            }
            available_moves = find_all_moves(board, board->to_move);
            if(available_moves == ((void *)0)) {
                return TRUE;
            }
            else {
                return FALSE;
            }
        }
        else {
            return TRUE;
        }
    }
    else {
        return TRUE;
    }
}

variable_types: struct Board { enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } board[-1][-1]; enum Colour { BLACK=0, WHITE=1 } to_move; unsigned int move_number; enum Boolean { FALSE=0, TRUE=1 } WKingCastle; enum Boolean { FALSE=0, TRUE=1 } BKingCastle; char WKingCol; char WKingRank; char BKingCol; char BKingRank; enum Boolean { FALSE=0, TRUE=1 } EnPassant; char ep_rank; char ep_col; unsigned long hash_value; unsigned int halfmove_clock; } *

variable_types: struct move_pair { char from_col; char from_rank; char to_col; char to_rank; struct move_pair *next; } *

user_defined_types: struct Board { enum Piece board[-1][-1]; enum Colour to_move; unsigned int move_number; enum Boolean WKingCastle; enum Boolean BKingCastle; char WKingCol; char WKingRank; char BKingCol; char BKingRank; enum Boolean EnPassant; char ep_rank; char ep_col; unsigned long hash_value; unsigned int halfmove_clock; }


decompiled_code:
_BOOL8 __fastcall check_textual_variations(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, char *needle)
{
__int64 *v12; // rbx
_BOOL8 result; // rax

v12 = (__int64 *)games_to_keep;
result = 1LL;
if ( games_to_keep )
{
do
{
if ( GlobalState[6] )
result = permutation_match((__int64)needle, a2, a3, a4, a5, a6, *v12, v12[1], v12[2], v12[3]);
else
result = straight_match(needle, a2, a3, a4, a5, a6, *v12, v12[1], v12[2], v12[3]);
v12 = (__int64 *)v12[4];
}
while ( v12 && !result );
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func12(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, char *needle)
{
__int64 *v12; // rbx
_BOOL8 result; // rax

v12 = (__int64 *)games_to_keep;
result = 1LL;
if ( games_to_keep )
{
do
{
if ( GlobalState[6] )
result = func4((__int64)needle, a2, a3, a4, a5, a6, *v12, v12[1], v12[2], v12[3]);
else
result = func5(needle, a2, a3, a4, a5, a6, *v12, v12[1], v12[2], v12[3]);
v12 = (__int64 *)v12[4];
}
while ( v12 && !result );
}
return result;
}

original_code:
Boolean
check_textual_variations(Game game_details)
{ Boolean wanted = FALSE;
    variation_list *variation;
    if(games_to_keep != ((void *)0)){
        for(variation = games_to_keep; (variation != ((void *)0)) && !wanted;
                    variation = variation->next){
            if(GlobalState.match_permutations){
                wanted = permutation_match(game_details.moves,*variation);
            }
            else{
                wanted = straight_match(game_details.moves,*variation);
            }
        }
    }
    else{
        wanted = TRUE;
    }
    return wanted;
}

canonical_original_code:
enum Boolean check_textual_variations(struct Game game_details)
{ enum Boolean wanted = FALSE;
    struct variation_list *variation;
    if(games_to_keep != ((void *)0)){
        for(variation = games_to_keep; (variation != ((void *)0)) && !wanted;
                    variation = variation->next){
            if(GlobalState.match_permutations){
                wanted = permutation_match(game_details.moves,*variation);
            }
            else{
                wanted = straight_match(game_details.moves,*variation);
            }
        }
    }
    else{
        wanted = TRUE;
    }
    return wanted;
}

variable_types: struct Game { char **tags; int tags_length; struct comment_list { struct string_list { char *str; struct string_list *next; } *Comment; struct comment_list *next; } *prefix_comment; unsigned long final_hash_value; unsigned long cumulative_hash_value; struct move { unsigned char move[-1]; enum MoveClass { PAWN_MOVE=0, PAWN_MOVE_WITH_PROMOTION=1, ENPASSANT_PAWN_MOVE=2, PIECE_MOVE=3, KINGSIDE_CASTLE=4, QUEENSIDE_CASTLE=5, UNKNOWN_MOVE=6 } class; char from_col; char from_rank; char to_col; char to_rank; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } piece_to_move; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } captured_piece; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } promoted_piece; enum CheckStatus { NOCHECK=0, CHECK=1, CHECKMATE=2 } check_status; char *epd; struct string_list *Nags; struct comment_list *Comment; char *terminating_result; struct variation { struct comment_list *prefix_comment; struct move *moves; struct comment_list *suffix_comment; struct variation *next; } *Variants; struct move *prev; } *moves; enum Boolean { FALSE=0, TRUE=1 } moves_checked; enum Boolean { FALSE=0, TRUE=1 } moves_ok; }

variable_types:
wanted
enum Boolean { FALSE=0, TRUE=1 }

variable_types: struct variation_list { struct variant_move { char *move; enum Boolean { FALSE=0, TRUE=1 } matched; } *moves; unsigned int num_white_any_moves; unsigned int num_black_any_moves; unsigned int num_white_disallowed_moves; unsigned int num_black_disallowed_moves; unsigned int length; struct variation_list *next; } *

user_defined_types: struct Game { char **tags; int tags_length; struct comment_list *prefix_comment; unsigned long final_hash_value; unsigned long cumulative_hash_value; struct move *moves; enum Boolean moves_checked; enum Boolean moves_ok; }


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

result = 1LL;
if ( GlobalState[18] )
{
result = 0LL;
if ( GlobalState[32] <= a1 )
result = GlobalState[33] >= a1;
}
return result;
}

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

result = 1LL;
if ( GlobalState[18] )
{
result = 0LL;
if ( GlobalState[32] <= a1 )
result = GlobalState[33] >= a1;
}
return result;
}

original_code:
Boolean
check_move_bounds(unsigned number_of_moves)
{ Boolean in_bounds = TRUE;
    if(GlobalState.check_move_bounds){
         in_bounds = (GlobalState.lower_move_bound <= number_of_moves) &&
                         (number_of_moves <= GlobalState.upper_move_bound);
    }
    return in_bounds;
}

canonical_original_code:
enum Boolean check_move_bounds(unsigned int number_of_moves)
{ enum Boolean in_bounds = TRUE;
    if(GlobalState.check_move_bounds){
         in_bounds = (GlobalState.lower_move_bound <= number_of_moves) &&
                         (number_of_moves <= GlobalState.upper_move_bound);
    }
    return in_bounds;
}


decompiled_code:
_BOOL8 __fastcall comment_line(_BYTE *a1)
{
return *a1 == 37;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(_BYTE *a1)
{
return *a1 == 37;
}

original_code:
Boolean
comment_line(const char *line)
{
    return *line == '%';
}

canonical_original_code:
enum Boolean comment_line(char *line)
{
    return *line == '%';
}


decompiled_code:
_BOOL8 __fastcall non_blank_line(_BYTE *a1)
{
_BOOL4 v1; // er12
_BYTE *v2; // rbp
char v3; // bl
const unsigned __int16 *v4; // rax

v1 = 1;
if ( a1 )
{
v2 = a1;
v1 = comment_line(a1);
if ( v1 )
{
v1 = 1;
}
else
{
v3 = *a1;
if ( *a1 )
{
v4 = *_ctype_b_loc();
while ( (v4[v3] & 0x2000) != 0 )
{
v3 = *++v2;
if ( !*v2 )
{
v1 = 1;
return !v1;
}
}
}
else
{
v1 = 1;
}
}
}
return !v1;
}

original_code:
Boolean
non_blank_line(const char *line)
{ Boolean blank = TRUE;
    if(line != ((void *)0)){
        if(comment_line(line)){
        }
        else{
            while(blank && (*line != '\0')){
                if(!((*__ctype_b_loc ())[(int) (((int) *line))] & (unsigned short int) _ISspace)){
                    blank = FALSE;
                }
                else{
                    line++;
                }
            }
        }
    }
    return !blank;
}

canonical_original_code:
enum Boolean non_blank_line(char *line)
{ enum Boolean blank = TRUE;
    if(line != ((void *)0)){
        if(comment_line(line)){
        }
        else{
            while(blank && (*line != '\0')){
                if(!((*__ctype_b_loc ())[(int) (((int) *line))] & (unsigned short) _ISspace)){
                    blank = FALSE;
                }
                else{
                    line++;
                }
            }
        }
    }
    return !blank;
}

variable_types:
blank
enum Boolean { FALSE=0, TRUE=1 }


decompiled_code:
_BOOL8 __fastcall blank_line(_BYTE *a1)
{
return !non_blank_line(a1);
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(_BYTE *a1)
{
return !func2(a1);
}

original_code:
Boolean
blank_line(const char *line)
{
    return !non_blank_line(line);
}

canonical_original_code:
enum Boolean blank_line(char *line)
{
    return !non_blank_line(line);
}


decompiled_code:
__int64 __fastcall retrieve_virtual_entry(__int64 off, void *ptr)
{
unsigned int v2; // ebx

v2 = 0;
if ( hash_file )
{
v2 = fseek(hash_file, off, 0);
if ( v2 )
{
fprintf(*((FILE **)&GlobalState + 23), "Fseek error to %ld in retrieve_virtual_entry\n", off);
v2 = 0;
}
else if ( fread(ptr, 0x20uLL, 1uLL, hash_file) == 1 )
{
v2 = 1;
}
else
{
fprintf(*((FILE **)&GlobalState + 23), "Fread error from %ld in retrieve_virtual_entry\n", off);
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 off, void *ptr)
{
unsigned int v2; // ebx

v2 = 0;
if ( hash_file )
{
v2 = fseek(hash_file, off, 0);
if ( v2 )
{
fprintf(*((FILE **)&GlobalState + 23), "Fseek error to %ld in retrieve_virtual_entry\n", off);
v2 = 0;
}
else if ( fread(ptr, 0x20uLL, 1uLL, hash_file) == 1 )
{
v2 = 1;
}
else
{
fprintf(*((FILE **)&GlobalState + 23), "Fread error from %ld in retrieve_virtual_entry\n", off);
}
}
return v2;
}

original_code:
static int
retrieve_virtual_entry(long ix,VirtualHashLog *entry)
{
    if(hash_file == ((void *)0)){
        return 0;
    }
    else if(fseek(hash_file,ix,0) != 0){
        fprintf(GlobalState.logfile,
                        "Fseek error to %ld in retrieve_virtual_entry\n",ix);
        return 0;
    }
    else if(fread((void *)entry,sizeof(*entry),1,hash_file) != 1){
        fprintf(GlobalState.logfile,
                        "Fread error from %ld in retrieve_virtual_entry\n",ix);
        return 0;
    }
    else{
        return 1;
    }
}

canonical_original_code:
static int retrieve_virtual_entry(long ix, struct VirtualHashLog *entry)
{
    if(hash_file == ((void *)0)){
        return 0;
    }
    else if(fseek(hash_file,ix,0) != 0){
        fprintf(GlobalState.logfile,
                        "Fseek error to %ld in retrieve_virtual_entry\n",ix);
        return 0;
    }
    else if(fread((void *)entry,sizeof(*entry),1,hash_file) != 1){
        fprintf(GlobalState.logfile,
                        "Fread error from %ld in retrieve_virtual_entry\n",ix);
        return 0;
    }
    else{
        return 1;
    }
}

variable_types: ix long

variable_types: struct VirtualHashLog { unsigned long final_hash_value; int file_number; long next; } *


decompiled_code:
__int64 __fastcall write_virtual_entry(__int64 off, void *ptr)
{
unsigned int v2; // ebx

if ( fseek(hash_file, off, 0) )
{
fprintf(*((FILE **)&GlobalState + 23), "Fseek error to %ld in write_virtual_entry\n", off);
v2 = 0;
}
else
{
v2 = 0;
if ( fwrite(ptr, 0x20uLL, 1uLL, hash_file) == 1 )
v2 = 1;
else
fprintf(*((FILE **)&GlobalState + 23), "Fwrite error from %ld in write_virtual_entry\n", off);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 off, void *ptr)
{
unsigned int v2; // ebx

if ( fseek(hash_file, off, 0) )
{
fprintf(*((FILE **)&GlobalState + 23), "Fseek error to %ld in write_virtual_entry\n", off);
v2 = 0;
}
else
{
v2 = 0;
if ( fwrite(ptr, 0x20uLL, 1uLL, hash_file) == 1 )
v2 = 1;
else
fprintf(*((FILE **)&GlobalState + 23), "Fwrite error from %ld in write_virtual_entry\n", off);
}
return v2;
}

original_code:
static int
write_virtual_entry(long where,const VirtualHashLog *entry)
{
    if(fseek(hash_file,where,0) != 0){
        fprintf(GlobalState.logfile,
                "Fseek error to %ld in write_virtual_entry\n",where);
        return 0;
    }
    else if(fwrite((void *)entry,sizeof(*entry),1,hash_file) != 1){
        fprintf(GlobalState.logfile,
                "Fwrite error from %ld in write_virtual_entry\n",where);
        return 0;
    }
    else{
        return 1;
    }
}

canonical_original_code:
static int write_virtual_entry(long where, struct VirtualHashLog *entry)
{
    if(fseek(hash_file,where,0) != 0){
        fprintf(GlobalState.logfile,
                "Fseek error to %ld in write_virtual_entry\n",where);
        return 0;
    }
    else if(fwrite((void *)entry,sizeof(*entry),1,hash_file) != 1){
        fprintf(GlobalState.logfile,
                "Fwrite error from %ld in write_virtual_entry\n",where);
        return 0;
    }
    else{
        return 1;
    }
}

variable_types: where long

user_defined_types: struct VirtualHashLog { unsigned long final_hash_value; int file_number; long next; }


decompiled_code:
int init_duplicate_hash_table()
{
_QWORD *v0; // rax
_QWORD *v1; // rdx
FILE *v2; // rax
FILE *v3; // rdx

if ( HIDWORD(GlobalState[8]) )
{
v0 = (_QWORD *)MallocOrDie(131056LL);
VirtualLogTable = (__int64)v0;
v1 = v0 + 16382;
do
{
v0[1] = -1LL;
*v0 = -1LL;
v0 += 2;
}
while ( v0 != v1 );
v2 = fopen(VIRTUAL_FILE, "w+b");
hash_file = v2;
if ( !v2 )
LODWORD(v2) = fprintf((FILE *)GlobalState[23], "Unable to open %s\n", VIRTUAL_FILE);
}
else
{
v2 = (FILE *)MallocOrDie(65528LL);
LogTable = (__int64)v2;
v3 = (FILE *)((char *)v2 + 65528);
do
{
*(_QWORD *)&v2->_flags = 0LL;
v2 = (FILE *)((char *)v2 + 8);
}
while ( v2 != v3 );
}
return (int)v2;
}

canonical_decompiled_code:
int func3()
{
_QWORD *v0; // rax
_QWORD *v1; // rdx
FILE *v2; // rax
FILE *v3; // rdx

if ( HIDWORD(GlobalState[8]) )
{
v0 = (_QWORD *)MallocOrDie(131056LL);
VirtualLogTable = (__int64)v0;
v1 = v0 + 16382;
do
{
v0[1] = -1LL;
*v0 = -1LL;
v0 += 2;
}
while ( v0 != v1 );
v2 = fopen(VIRTUAL_FILE, "w+b");
hash_file = v2;
if ( !v2 )
LODWORD(v2) = fprintf((FILE *)GlobalState[23], "Unable to open %s\n", VIRTUAL_FILE);
}
else
{
v2 = (FILE *)MallocOrDie(65528LL);
LogTable = (__int64)v2;
v3 = (FILE *)((char *)v2 + 65528);
do
{
*(_QWORD *)&v2->_flags = 0LL;
v2 = (FILE *)((char *)v2 + 8);
}
while ( v2 != v3 );
}
return (int)v2;
}

original_code:
void
init_duplicate_hash_table(void)
{ int i;
   if(GlobalState.use_virtual_hash_table){
       VirtualLogTable = (LogHeaderEntry *)
            MallocOrDie(8191*sizeof(*VirtualLogTable));
       for(i = 0; i < 8191; i++){
           VirtualLogTable[i].head = VirtualLogTable[i].tail = -1;
       }
       hash_file = fopen(VIRTUAL_FILE,"w+b");
       if(hash_file == ((void *)0)){
           fprintf(GlobalState.logfile,"Unable to open %s\n",
                    VIRTUAL_FILE);
       }
    }
    else{
       LogTable = (HashLog**) MallocOrDie(8191*sizeof(*LogTable));
       for(i = 0; i < 8191; i++){
           LogTable[i] = ((void *)0);
       }
    }
}

canonical_original_code:
void init_duplicate_hash_table()
{ int i;
   if(GlobalState.use_virtual_hash_table){
       VirtualLogTable = (struct LogHeaderEntry *)
            MallocOrDie(8191*sizeof(*VirtualLogTable));
       for(i = 0; i < 8191; i++){
           VirtualLogTable[i].head = VirtualLogTable[i].tail = -1;
       }
       hash_file = fopen(VIRTUAL_FILE,"w+b");
       if(hash_file == ((void *)0)){
           fprintf(GlobalState.logfile,"Unable to open %s\n",
                    VIRTUAL_FILE);
       }
    }
    else{
       LogTable = (struct HashLog **) MallocOrDie(8191*sizeof(*LogTable));
       for(i = 0; i < 8191; i++){
           LogTable[i] = ((void *)0);
       }
    }
}

variable_types: i int

user_defined_types: struct HashLog { unsigned long combined_hash_value; int file_number; struct HashLog *next; }


decompiled_code:
int clear_duplicate_hash_table()
{
int result; // eax

if ( HIDWORD(GlobalState[8]) )
{
if ( hash_file )
{
fclose(hash_file);
result = unlink(VIRTUAL_FILE);
}
}
return result;
}

canonical_decompiled_code:
int func4()
{
int result; // eax

if ( HIDWORD(GlobalState[8]) )
{
if ( hash_file )
{
fclose(hash_file);
result = unlink(VIRTUAL_FILE);
}
}
return result;
}

original_code:
void
clear_duplicate_hash_table(void)
{
   if(GlobalState.use_virtual_hash_table){
      if(hash_file != ((void *)0)){
        (void) fclose(hash_file);
        unlink(VIRTUAL_FILE);
      }
   }
}

canonical_original_code:
void clear_duplicate_hash_table()
{
   if(GlobalState.use_virtual_hash_table){
      if(hash_file != ((void *)0)){
        (void) fclose(hash_file);
        unlink(VIRTUAL_FILE);
      }
   }
}


decompiled_code:
__int64 __fastcall previous_occurance(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, unsigned __int64 a10, __int64 a11)
{
unsigned __int64 v11; // rdx
__int64 result; // rax
__int64 v13; // rbp
__int64 v14; // rax
__int64 v15; // r13
__int64 *v16; // rbp

if ( HIDWORD(GlobalState[8]) )
return previous_virtual_occurance(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
v11 = a10 % 0x1FFF;
if ( *(_QWORD *)((char *)&GlobalState[4] + 4) || (result = GlobalState[24]) != 0 )
{
v13 = 8 * v11;
v14 = *(_QWORD *)(LogTable + 8 * v11);
if ( v14 )
{
while ( *(_QWORD *)v14 != (a11 ^ a10) )
{
v14 = *(_QWORD *)(v14 + 16);
if ( !v14 )
goto LABEL_11;
}
result = input_file_name(*(unsigned int *)(v14 + 8));
}
else
{
LABEL_11:
v15 = MallocOrDie(24LL);
*(_QWORD *)v15 = a11 ^ a10;
*(_DWORD *)(v15 + 8) = current_file_number();
v16 = (__int64 *)(LogTable + v13);
*(_QWORD *)(v15 + 16) = *v16;
*v16 = v15;
result = 0LL;
}
}
return result;
}

original_code:
const char *
previous_occurance(Game game_details)
{
  const char *original_filename = ((void *)0);
  if(GlobalState.use_virtual_hash_table){
    original_filename = previous_virtual_occurance(game_details);
  }
  else{
    unsigned ix = game_details.final_hash_value % 8191;
    HashLog *entry = ((void *)0);
    Boolean duplicate = FALSE;
    if(GlobalState.suppress_duplicates || GlobalState.suppress_originals ||
                GlobalState.duplicate_file != ((void *)0)){
        for(entry = LogTable[ix]; !duplicate && (entry != ((void *)0));
                                        entry = entry->next){
            if(entry->combined_hash_value ==
                        (game_details.final_hash_value ^
                                        game_details.cumulative_hash_value)){
                original_filename = input_file_name(entry->file_number);
                duplicate = TRUE;
            }
        }
        if(!duplicate){
            entry = (HashLog *)MallocOrDie(sizeof(*entry));
            entry->combined_hash_value =
                game_details.final_hash_value ^ game_details.cumulative_hash_value;
            entry->file_number = current_file_number();
            entry->next = LogTable[ix];
            LogTable[ix] = entry;
        }
    }
  }
  return original_filename;
}

canonical_original_code:
char *previous_occurance(struct Game game_details)
{
  char *original_filename = ((void *)0);
  if(GlobalState.use_virtual_hash_table){
    original_filename = previous_virtual_occurance(game_details);
  }
  else{
    unsigned int ix = game_details.final_hash_value % 8191;
    struct HashLog *entry = ((void *)0);
    enum Boolean duplicate = FALSE;
    if(GlobalState.suppress_duplicates || GlobalState.suppress_originals ||
                GlobalState.duplicate_file != ((void *)0)){
        for(entry = LogTable[ix]; !duplicate && (entry != ((void *)0));
                                        entry = entry->next){
            if(entry->combined_hash_value ==
                        (game_details.final_hash_value ^
                                        game_details.cumulative_hash_value)){
                original_filename = input_file_name(entry->file_number);
                duplicate = TRUE;
            }
        }
        if(!duplicate){
            entry = (struct HashLog *)MallocOrDie(sizeof(*entry));
            entry->combined_hash_value =
                game_details.final_hash_value ^ game_details.cumulative_hash_value;
            entry->file_number = current_file_number();
            entry->next = LogTable[ix];
            LogTable[ix] = entry;
        }
    }
  }
  return original_filename;
}

variable_types:
ix
unsigned int

variable_types: struct HashLog { unsigned long combined_hash_value; int file_number; struct HashLog *next; } *

variable_types:
duplicate
enum Boolean { FALSE=0, TRUE=1 }

return_type: char *


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

result = 1LL;
if ( (a1 & 0xDF) != 88 )
result = (a1 == 45) | (unsigned __int8)(a1 == 58);
return result;
}

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

result = 1LL;
if ( (a1 & 0xDF) != 88 )
result = (a1 == 45) | (unsigned __int8)(a1 == 58);
return result;
}

original_code:
static Boolean
is_capture(char c)
{
    return (c == 'x') || (c == 'X') || (c == ':') || (c == '-');
}

canonical_original_code:
static enum Boolean is_capture(char c)
{
    return (c == 'x') || (c == 'X') || (c == ':') || (c == '-');
}

variable_types: c char


decompiled_code:
__int64 __fastcall is_castling_character(char a1)
{
return (a1 == 48) | (unsigned __int8)((a1 & 0xDF) == 79);
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1)
{
return (a1 == 48) | (unsigned __int8)((a1 & 0xDF) == 79);
}

original_code:
static Boolean
is_castling_character(char c)
{
    return (c == 'O') || (c == '0') || (c == 'o');
}

canonical_original_code:
static enum Boolean is_castling_character(char c)
{
    return (c == 'O') || (c == '0') || (c == 'o');
}


decompiled_code:
_BOOL8 __fastcall is_col(char a1)
{
return (unsigned __int8)(a1 - 97) <= 7u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(char a1)
{
return (unsigned __int8)(a1 - 97) <= 7u;
}

canonical_original_code:
enum Boolean is_col(char c)
{
    return (('a') <= c) && (c <= ('a'+8 -1));
}


decompiled_code:
_BOOL8 __fastcall is_rank(char a1)
{
return (unsigned __int8)(a1 - 49) <= 7u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(char a1)
{
return (unsigned __int8)(a1 - 49) <= 7u;
}

canonical_original_code:
enum Boolean is_rank(char c)
{
    return (('1') <= c) && (c <= ('1'+8 -1));
}


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

switch ( *a1 )
{
case 0x42:
case 0x4C:
case 0x91:
result = 4LL;
break;
case 0x44:
case 0x51:
case 0x71:
case 0x94:
result = 6LL;
break;
case 0x4B:
case 0x6B:
result = 7LL;
break;
case 0x4E:
case 0x50:
case 0x53:
case 0x6E:
result = 3LL;
break;
case 0x52:
case 0x54:
case 0x72:
case 0x8B:
result = 5LL;
break;
case 0x8A:
result = 4 * (unsigned int)(a1[1] == 0xE0) + 3;
break;
default:
result = 1LL;
break;
}
return result;
}

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

switch ( *a1 )
{
case 0x42:
case 0x4C:
case 0x91:
result = 4LL;
break;
case 0x44:
case 0x51:
case 0x71:
case 0x94:
result = 6LL;
break;
case 0x4B:
case 0x6B:
result = 7LL;
break;
case 0x4E:
case 0x50:
case 0x53:
case 0x6E:
result = 3LL;
break;
case 0x52:
case 0x54:
case 0x72:
case 0x8B:
result = 5LL;
break;
case 0x8A:
result = 4 * (unsigned int)(a1[1] == 0xE0) + 3;
break;
default:
result = 1LL;
break;
}
return result;
}

original_code:
Piece
is_piece(const unsigned char *move)
{ Piece piece = EMPTY;
    switch(*move){
        case 'K': case 'k':
            piece = KING;
            break;
        case 'Q': case 'q':
        case 'D':
        case (0x0094):
            piece = QUEEN;
            break;
        case 'R': case 'r':
        case 'T':
        case (0x008b):
            piece = ROOK;
            break;
        case 'N': case 'n':
        case 'P':
        case 'S':
            piece = KNIGHT;
            break;
        case 'B':
        case 'L':
        case (0x0091):
            piece = BISHOP;
            break;
        case (0x008a):
            if(((*(move+1)) & 0x00ff) == (0x00e0)){
                piece = KING;
            }
            else{
                piece = KNIGHT;
            }
            break;
    }
    return piece;
}

canonical_original_code:
enum Piece is_piece(unsigned char *move)
{ enum Piece piece = EMPTY;
    switch(*move){
        case 'K': case 'k':
            piece = KING;
            break;
        case 'Q': case 'q':
        case 'D':
        case (0x0094):
            piece = QUEEN;
            break;
        case 'R': case 'r':
        case 'T':
        case (0x008b):
            piece = ROOK;
            break;
        case 'N': case 'n':
        case 'P':
        case 'S':
            piece = KNIGHT;
            break;
        case 'B':
        case 'L':
        case (0x0091):
            piece = BISHOP;
            break;
        case (0x008a):
            if(((*(move+1)) & 0x00ff) == (0x00e0)){
                piece = KING;
            }
            else{
                piece = KNIGHT;
            }
            break;
    }
    return piece;
}

variable_types:
move
unsigned char *

variable_types: enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 }


decompiled_code:
_BOOL8 __fastcall is_check(char a1)
{
return (a1 & 0xF7) == 35;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(char a1)
{
return (a1 & 0xF7) == 35;
}

canonical_original_code:
enum Boolean is_check(char c)
{
    return (c == '+') || (c == '#');
}


decompiled_code:
_QWORD *new_move_structure()
{
_QWORD *result; // rax

result = (_QWORD *)MallocOrDie(96LL);
result[8] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[9] = 0LL;
result[11] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func6()
{
_QWORD *result; // rax

result = (_QWORD *)MallocOrDie(96LL);
result[8] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[9] = 0LL;
result[11] = 0LL;
return result;
}

original_code:
Move *
new_move_structure(void)
{ Move *move = (Move *)MallocOrDie(sizeof(Move));
    move->terminating_result = ((void *)0);
    move->epd = ((void *)0);
    move->Nags = ((void *)0);
    move->Comment = ((void *)0);
    move->Variants = ((void *)0);
    move->next = ((void *)0);
    return move;
}

canonical_original_code:
struct move *new_move_structure()
{ struct move *move = (Move *)MallocOrDie(sizeof(Move));
    move->terminating_result = ((void *)0);
    move->epd = ((void *)0);
    move->Nags = ((void *)0);
    move->Comment = ((void *)0);
    move->Variants = ((void *)0);
    move->next = ((void *)0);
    return move;
}

variable_types: struct move { unsigned char move[-1]; enum MoveClass { PAWN_MOVE=0, PAWN_MOVE_WITH_PROMOTION=1, ENPASSANT_PAWN_MOVE=2, PIECE_MOVE=3, KINGSIDE_CASTLE=4, QUEENSIDE_CASTLE=5, UNKNOWN_MOVE=6 } class; char from_col; char from_rank; char to_col; char to_rank; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } piece_to_move; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } captured_piece; enum Piece { OFF=0, EMPTY=1, PAWN=2, KNIGHT=3, BISHOP=4, ROOK=5, QUEEN=6, KING=7, NUM_PIECE_VALUES=8 } promoted_piece; enum CheckStatus { NOCHECK=0, CHECK=1, CHECKMATE=2 } check_status; char *epd; struct string_list { char *str; struct string_list *next; } *Nags; struct comment_list { struct string_list *Comment; struct comment_list *next; } *Comment; char *terminating_result; struct variation { struct comment_list *prefix_comment; struct move *moves; struct comment_list *suffix_comment; struct variation *next; } *Variants; struct move *prev; } *