decompiled_code:
__int64 __fastcall fileroute_tread(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // r12
__int64 v5; // rax
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // r14
__int64 v9; // r9
__int64 v10; // rdi
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rdx
__int64 v21; // rdi
__int64 v22; // rax

v3 = route_tread(a1, 0LL);
if ( v3
&& (unsigned int)(a2 - 1) > 1
&& a2 != 8
&& (int)table_ncols(v3) <= 2
&& (unsigned int)table_hascol(v3, "data") )
{
table_first(v3);
v5 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v5, "myhabitat/fileroute.c", 56LL, "fileroute_tread");
v7 = table_create();
v8 = v7;
switch ( a2 )
{
case 0:
if ( (unsigned int)table_scan(v7, v6, "\t", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 115LL, "fileroute_tread");
v15 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v15, "myhabitat/fileroute.c", 116LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, "\t", 0LL, 1LL, 0LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 121LL, "fileroute_tread");
v16 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v16, "myhabitat/fileroute.c", 122LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, ",", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 127LL, "fileroute_tread");
v17 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v17, "myhabitat/fileroute.c", 128LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, ",", 0LL, 1LL, 0LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 133LL, "fileroute_tread");
v18 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v18, "myhabitat/fileroute.c", 134LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, "|", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 139LL, "fileroute_tread");
v19 = table_getcurrentcell(v3, "data");
v20 = 140LL;
v21 = v19;
goto LABEL_26;
case 3:
if ( (unsigned int)table_scan(v7, v6, ",", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 65LL, "fileroute_tread");
v14 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v14, "myhabitat/fileroute.c", 66LL, "fileroute_tread");
v2 = table_scan(v8, v6, ",", 0LL, 1LL, 0LL);
break;
case 4:
if ( (unsigned int)table_scan(v7, v6, "\t", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 76LL, "fileroute_tread");
v12 = table_getcurrentcell(v3, "data");
v13 = nm_nstrdup(v12, "myhabitat/fileroute.c", 77LL, "fileroute_tread");
v9 = 0LL;
v6 = v13;
LABEL_9:
v2 = table_scan(v8, v6, "\t", 0LL, 1LL, v9);
break;
case 5:
if ( (unsigned int)table_scan(v7, v6, " ", 1LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 87LL, "fileroute_tread");
v11 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v11, "myhabitat/fileroute.c", 88LL, "fileroute_tread");
v2 = table_scan(v8, v6, " ", 1LL, 1LL, 0LL);
break;
case 6:
if ( (unsigned int)table_scan(v7, v6, "|", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 99LL, "fileroute_tread");
v22 = table_getcurrentcell(v3, "data");
v20 = 100LL;
v21 = v22;
LABEL_26:
v6 = nm_nstrdup(v21, "myhabitat/fileroute.c", v20, "fileroute_tread");
v2 = table_scan(v8, v6, "|", 0LL, 1LL, 0LL);
break;
case 7:
v9 = 1LL;
goto LABEL_9;
default:
break;
}
if ( v2 == -1 )
{
table_destroy(v8);
nm_nfree(v6, "myhabitat/fileroute.c", 152LL, "fileroute_tread");
}
else
{
LABEL_13:
v10 = v3;
v3 = v8;
table_destroy(v10);
table_freeondestroy(v8, v6);
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // r12
__int64 v5; // rax
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // r14
__int64 v9; // r9
__int64 v10; // rdi
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rdx
__int64 v21; // rdi
__int64 v22; // rax

v3 = route_tread(a1, 0LL);
if ( v3
&& (unsigned int)(a2 - 1) > 1
&& a2 != 8
&& (int)table_ncols(v3) <= 2
&& (unsigned int)table_hascol(v3, "data") )
{
table_first(v3);
v5 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v5, "myhabitat/fileroute.c", 56LL, "fileroute_tread");
v7 = table_create();
v8 = v7;
switch ( a2 )
{
case 0:
if ( (unsigned int)table_scan(v7, v6, "\t", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 115LL, "fileroute_tread");
v15 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v15, "myhabitat/fileroute.c", 116LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, "\t", 0LL, 1LL, 0LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 121LL, "fileroute_tread");
v16 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v16, "myhabitat/fileroute.c", 122LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, ",", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 127LL, "fileroute_tread");
v17 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v17, "myhabitat/fileroute.c", 128LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, ",", 0LL, 1LL, 0LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 133LL, "fileroute_tread");
v18 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v18, "myhabitat/fileroute.c", 134LL, "fileroute_tread");
if ( (unsigned int)table_scan(v8, v6, "|", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 139LL, "fileroute_tread");
v19 = table_getcurrentcell(v3, "data");
v20 = 140LL;
v21 = v19;
goto LABEL_26;
case 3:
if ( (unsigned int)table_scan(v7, v6, ",", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 65LL, "fileroute_tread");
v14 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v14, "myhabitat/fileroute.c", 66LL, "fileroute_tread");
v2 = table_scan(v8, v6, ",", 0LL, 1LL, 0LL);
break;
case 4:
if ( (unsigned int)table_scan(v7, v6, "\t", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 76LL, "fileroute_tread");
v12 = table_getcurrentcell(v3, "data");
v13 = nm_nstrdup(v12, "myhabitat/fileroute.c", 77LL, "fileroute_tread");
v9 = 0LL;
v6 = v13;
LABEL_9:
v2 = table_scan(v8, v6, "\t", 0LL, 1LL, v9);
break;
case 5:
if ( (unsigned int)table_scan(v7, v6, " ", 1LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 87LL, "fileroute_tread");
v11 = table_getcurrentcell(v3, "data");
v6 = nm_nstrdup(v11, "myhabitat/fileroute.c", 88LL, "fileroute_tread");
v2 = table_scan(v8, v6, " ", 1LL, 1LL, 0LL);
break;
case 6:
if ( (unsigned int)table_scan(v7, v6, "|", 0LL, 1LL, 1LL) != -1 )
goto LABEL_13;
nm_nfree(v6, "myhabitat/fileroute.c", 99LL, "fileroute_tread");
v22 = table_getcurrentcell(v3, "data");
v20 = 100LL;
v21 = v22;
LABEL_26:
v6 = nm_nstrdup(v21, "myhabitat/fileroute.c", v20, "fileroute_tread");
v2 = table_scan(v8, v6, "|", 0LL, 1LL, 0LL);
break;
case 7:
v9 = 1LL;
goto LABEL_9;
default:
break;
}
if ( v2 == -1 )
{
table_destroy(v8);
nm_nfree(v6, "myhabitat/fileroute.c", 152LL, "fileroute_tread");
}
else
{
LABEL_13:
v10 = v3;
v3 = v8;
table_destroy(v10);
table_freeondestroy(v8, v6);
}
}
return v3;
}

original_code:
TABLE fileroute_tread(char *purl, FILEROUTE_TYPE type)
{
     TABLE tab;
     tab = route_tread(purl, ((void *)0));
     if ( ! tab )
          return ((void *)0);
     if ( type == FILEROUTE_TYPE_RS ||
   type == FILEROUTE_TYPE_GRS )
       return tab;
     if ( type == FILEROUTE_TYPE_TEXT )
       return tab;
     if (table_ncols(tab) <= 2 && table_hascol(tab, "data")) {
          char *buf;
   TABLE newtab;
   int r;
   table_first(tab);
   buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",56,__PRETTY_FUNCTION__);
   newtab = table_create();
   switch (type) {
   case FILEROUTE_TYPE_CSV:
        r = table_scan(newtab, buf, ",", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",65,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",66,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, ",", 0,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_TSV:
        r = table_scan(newtab, buf, "\t", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",76,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",77,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "\t", 0,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_SSV:
        r = table_scan(newtab, buf, " ", 1,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",87,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",88,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, " ", 1,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_PSV:
        r = table_scan(newtab, buf, "|", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",99,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",100,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "|", 0,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_FHA:
        r = table_scan(newtab, buf, "\t", 0,
         1, 1);
        break;
   case FILEROUTE_TYPE_UNKNOWN:
        r = table_scan(newtab, buf, "\t", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",115,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",116,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "\t", 0,
       1, 0);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",121,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",122,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, ",", 0,
       1, 1);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",127,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",128,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, ",", 0,
       1, 0);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",133,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",134,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "|", 0,
       1, 1);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",139,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",140,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "|", 0,
       1, 0);
        }
        break;
   default:
        break;
   }
   if (r == -1) {
        table_destroy(newtab);
        nm_nfree(buf,"myhabitat/fileroute.c",152,__PRETTY_FUNCTION__);
        return tab;
   }
   table_destroy(tab);
   table_freeondestroy(newtab, buf);
   return newtab;
     } else {
          return tab;
     }
}

canonical_original_code:
struct table_info *fileroute_tread(char *purl, enum fileroute_file_type type)
{
     struct table_info *tab;
     tab = route_tread(purl, ((void *)0));
     if ( ! tab )
          return ((void *)0);
     if ( type == FILEROUTE_TYPE_RS ||
   type == FILEROUTE_TYPE_GRS )
       return tab;
     if ( type == FILEROUTE_TYPE_TEXT )
       return tab;
     if (table_ncols(tab) <= 2 && table_hascol(tab, "data")) {
          char *buf;
   struct table_info *newtab;
   int r;
   table_first(tab);
   buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",56,__PRETTY_FUNCTION__);
   newtab = table_create();
   switch (type) {
   case FILEROUTE_TYPE_CSV:
        r = table_scan(newtab, buf, ",", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",65,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",66,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, ",", 0,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_TSV:
        r = table_scan(newtab, buf, "\t", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",76,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",77,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "\t", 0,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_SSV:
        r = table_scan(newtab, buf, " ", 1,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",87,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",88,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, " ", 1,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_PSV:
        r = table_scan(newtab, buf, "|", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",99,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",100,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "|", 0,
       1, 0);
        }
        break;
   case FILEROUTE_TYPE_FHA:
        r = table_scan(newtab, buf, "\t", 0,
         1, 1);
        break;
   case FILEROUTE_TYPE_UNKNOWN:
        r = table_scan(newtab, buf, "\t", 0,
         1, 1);
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",115,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",116,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "\t", 0,
       1, 0);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",121,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",122,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, ",", 0,
       1, 1);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",127,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",128,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, ",", 0,
       1, 0);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",133,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",134,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "|", 0,
       1, 1);
        }
        if (r == -1) {
      nm_nfree(buf,"myhabitat/fileroute.c",139,__PRETTY_FUNCTION__);
      buf = nm_nstrdup(table_getcurrentcell(tab, "data"),"myhabitat/fileroute.c",140,__PRETTY_FUNCTION__);
      r = table_scan(newtab, buf, "|", 0,
       1, 0);
        }
        break;
   default:
        break;
   }
   if (r == -1) {
        table_destroy(newtab);
        nm_nfree(buf,"myhabitat/fileroute.c",152,__PRETTY_FUNCTION__);
        return tab;
   }
   table_destroy(tab);
   table_freeondestroy(newtab, buf);
   return newtab;
     } else {
          return tab;
     }
}

variable_types:
purl
char *

variable_types: enum fileroute_file_type { FILEROUTE_TYPE_UNKNOWN=0, FILEROUTE_TYPE_GRS=1, FILEROUTE_TYPE_RS=2, FILEROUTE_TYPE_CSV=3, FILEROUTE_TYPE_TSV=4, FILEROUTE_TYPE_SSV=5, FILEROUTE_TYPE_PSV=6, FILEROUTE_TYPE_FHA=7, FILEROUTE_TYPE_TEXT=8 }

variable_types: struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *


repo: SystemGarden/habitat

decompiled_code:
void uiedit_fini()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void uiedit_fini() {
}

canonical_original_code:
void uiedit_fini() {
}

return_type: void


icomp

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

result = 0LL;
if ( a1 != a2 )
result = 2 * (unsigned int)(a1 <= a2) - 1;
return result;
}

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

result = 0LL;
if ( a1 != a2 )
result = 2 * (unsigned int)(a1 <= a2) - 1;
return result;
}

original_code:
int icomp(char *i, char *j)
{
  int I, J;
  I = (int) i;
  J = (int) j;
  if (I == J) return 0;
  if (I > J) return -1; else return 1;
}

canonical_original_code:
int icomp(char *i, char *j)
{
  int I; int J;
  I = (int) i;
  J = (int) j;
  if (I == J) return 0;
  if (I > J) return -1; else return 1;
}

variable_types:
i
char *

variable_types:
j
char *

variable_types: I int

variable_types: J int

return_type: int


deplaceBoule

original_code:
int deplaceBoule(Plateau *p, int *depart, int *arrivee){
  p->tableau[arrivee[0]][arrivee[1]] = p->tableau[depart[0]][depart[1]];
  p->tableau[depart[0]][depart[1]] = '.';
  return 0;
}

canonical_original_code:
int deplaceBoule(struct Plateau *p, int *depart, int *arrivee){
  p->tableau[arrivee[0]][arrivee[1]] = p->tableau[depart[0]][depart[1]];
  p->tableau[depart[0]][depart[1]] = '.';
  return 0;
}

variable_types: struct Plateau { char **tableau; int billesBlachesperdues; int billesNoiresperdues; char JoueurSuivant; int typeBlanc; int typeNoir; } *

variable_types:
depart
int *

variable_types:
arrivee
int *


coordonneesValides

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

switch ( a1 )
{
case 0:
case 8:
result = (unsigned int)-(a2 > 4);
break;
case 1:
case 7:
result = (unsigned int)-(a2 > 5);
break;
case 2:
case 6:
result = (unsigned int)-(a2 > 6);
break;
case 3:
case 5:
result = (unsigned int)-(a2 > 7);
break;
case 4:
result = (unsigned int)-(a2 > 8);
break;
default:
JUMPOUT(0xD5ELL);
}
return result;
}

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

switch ( a1 )
{
case 0:
case 8:
result = (unsigned int)-(a2 > 4);
break;
case 1:
case 7:
result = (unsigned int)-(a2 > 5);
break;
case 2:
case 6:
result = (unsigned int)-(a2 > 6);
break;
case 3:
case 5:
result = (unsigned int)-(a2 > 7);
break;
case 4:
result = (unsigned int)-(a2 > 8);
break;
default:
JUMPOUT(0xD5ELL);
}
return result;
}

original_code:
int coordonneesValides(int coorA, int coorB){
 switch (coorA){
  case 0:
  case 8:
   if (coorB < 5 && coorB>=0)return 0;
   break;
  case 1:
  case 7:
   if (coorB < 6 && coorB>=0)return 0;
   break;
  case 2:
  case 6:
   if (coorB < 7 && coorB>=0)return 0;
   break;
  case 3:
  case 5:
   if (coorB < 8 && coorB>=0)return 0;
   break;
  case 4:
   if (coorB < 9 && coorB>=0)return 0;
   break;
 }
 return -1;
}

variable_types: coorA int

variable_types: coorB int


caseSuivant

original_code:
int* caseSuivant(Plateau *p, int *coor, int direction){
 int *casuiv = malloc((sizeof(int)*2));
 casuiv[0] = -1;
 casuiv[1] = -1;
 switch(coor[0]){
   case 0:
   case 1:
   case 2:
   case 3:
    switch(direction){
     case 0:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1]+1;
      break;
     case 1:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1];
      break;
     case 2:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]-1;
       break;
     case 3:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1]-1;
      break;
     case 4:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1];
      break;
     case 5:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]+1;
      break;
     default :
      return ((void *)0);
    }
    break;
   case 4:
    switch(direction){
     case 0:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1];
      break;
     case 1:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1]-1;
      break;
     case 2:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]-1;
       break;
     case 3:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1]-1;
      break;
     case 4:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1];
      break;
     case 5:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]+1;
      break;
    }
    break;
   case 5:
   case 6:
   case 7:
   case 8:
    switch(direction){
     case 0:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1];
      break;
     case 1:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1]-1;
      break;
     case 2:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]-1;
       break;
     case 3:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1];
      break;
     case 4:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1]+1;
      break;
     case 5:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]+1;
      break;
    }
    break;
  }
  if (casuiv[0] != -1 && casuiv[1] != -1){
   if(coordonneesValides(casuiv[0], casuiv[1])!=-1){
    return casuiv;
   }
   else return ((void *)0);
  }
  else return ((void *)0);
}

canonical_original_code:
int *caseSuivant(struct Plateau *p, int *coor, int direction){
 int *casuiv = malloc((sizeof(int)*2));
 casuiv[0] = -1;
 casuiv[1] = -1;
 switch(coor[0]){
   case 0:
   case 1:
   case 2:
   case 3:
    switch(direction){
     case 0:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1]+1;
      break;
     case 1:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1];
      break;
     case 2:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]-1;
       break;
     case 3:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1]-1;
      break;
     case 4:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1];
      break;
     case 5:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]+1;
      break;
     default :
      return ((void *)0);
    }
    break;
   case 4:
    switch(direction){
     case 0:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1];
      break;
     case 1:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1]-1;
      break;
     case 2:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]-1;
       break;
     case 3:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1]-1;
      break;
     case 4:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1];
      break;
     case 5:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]+1;
      break;
    }
    break;
   case 5:
   case 6:
   case 7:
   case 8:
    switch(direction){
     case 0:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1];
      break;
     case 1:
      casuiv[0] = coor[0]+1;
      casuiv[1] = coor[1]-1;
      break;
     case 2:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]-1;
       break;
     case 3:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1];
      break;
     case 4:
      casuiv[0] = coor[0]-1;
      casuiv[1] = coor[1]+1;
      break;
     case 5:
      casuiv[0] = coor[0];
      casuiv[1] = coor[1]+1;
      break;
    }
    break;
  }
  if (casuiv[0] != -1 && casuiv[1] != -1){
   if(coordonneesValides(casuiv[0], casuiv[1])!=-1){
    return casuiv;
   }
   else return ((void *)0);
  }
  else return ((void *)0);
}

variable_types:
coor
int *

variable_types: direction int

variable_types:
casuiv
int *

return_type: int *

user_defined_types: struct Plateau { char **tableau; int billesBlachesperdues; int billesNoiresperdues; char JoueurSuivant; int typeBlanc; int typeNoir; }


direction

decompiled_code:
__int64 __fastcall direction(int *a1, unsigned int *a2)
{
int v2; // edx
__int64 result; // rax
int v4; // ecx
unsigned int v5; // edx
unsigned int v6; // eax
int v7; // er8
int v8; // eax
int v9; // ecx
unsigned int v10; // edx
int v11; // edx
unsigned int v12; // ecx
int v13; // ecx
unsigned int v14; // er10
int v15; // eax
unsigned int v16; // edx
int v17; // er9
unsigned int v18; // er8
bool v19; // zf

v2 = *a1;
if ( *a1 == 4 )
{
result = *a2;
switch ( (_DWORD)result )
{
case 5:
v11 = a1[1];
v12 = a2[1];
result = 0LL;
if ( v11 != v12 )
result = 2 * (unsigned int)(v12 == v11 - 1) - 1;
break;
case 4:
goto LABEL_32;
case 3:
v9 = a1[1];
v10 = a2[1];
if ( v9 - 1 != v10 )
result = 5 * (unsigned int)(v9 == v10) - 1;
break;
default:
return 0xFFFFFFFFLL;
}
}
else
{
if ( v2 <= 4 )
{
result = 0xFFFFFFFFLL;
if ( (unsigned int)v2 > 3 )
return result;
v4 = *a2;
if ( v2 + 1 == *a2 )
{
v17 = a1[1];
v18 = a2[1];
result = 0LL;
if ( v17 + 1 == v18 )
return result;
result = 1LL;
if ( v17 == v18 )
return result;
}
if ( v2 != v4 )
{
if ( v4 == v2 - 1 )
{
v5 = a1[1];
v6 = a2[1];
if ( v5 - 1 == v6 )
return 3LL;
return 5 * (unsigned int)(v5 == v6) - 1;
}
return 0xFFFFFFFFLL;
}
goto LABEL_32;
}
result = 0xFFFFFFFFLL;
if ( (unsigned int)(v2 - 5) > 3 )
return result;
v7 = *a2;
if ( v2 + 1 != *a2 )
{
if ( v2 != v7 )
goto LABEL_12;
LABEL_32:
v15 = a1[1];
v16 = a2[1];
if ( v15 - 1 == v16 )
return 2LL;
goto LABEL_33;
}
v13 = a1[1];
v14 = a2[1];
result = 0LL;
if ( v13 != v14 )
{
result = 1LL;
if ( v14 != v13 - 1 )
{
if ( v2 == v2 + 1 )
{
v15 = a1[1];
v16 = a2[1];
LABEL_33:
v19 = v16 == v15 + 1;
result = 5LL;
if ( !v19 )
result = 0xFFFFFFFFLL;
return result;
}
LABEL_12:
if ( v7 == v2 - 1 )
{
v8 = a1[1];
v5 = a2[1];
if ( v8 == v5 )
return 3LL;
v6 = v8 + 1;
return 5 * (unsigned int)(v5 == v6) - 1;
}
return 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, unsigned int *a2)
{
int v2; // edx
__int64 result; // rax
int v4; // ecx
unsigned int v5; // edx
unsigned int v6; // eax
int v7; // er8
int v8; // eax
int v9; // ecx
unsigned int v10; // edx
int v11; // edx
unsigned int v12; // ecx
int v13; // ecx
unsigned int v14; // er10
int v15; // eax
unsigned int v16; // edx
int v17; // er9
unsigned int v18; // er8
bool v19; // zf

v2 = *a1;
if ( *a1 == 4 )
{
result = *a2;
switch ( (_DWORD)result )
{
case 5:
v11 = a1[1];
v12 = a2[1];
result = 0LL;
if ( v11 != v12 )
result = 2 * (unsigned int)(v12 == v11 - 1) - 1;
break;
case 4:
goto LABEL_32;
case 3:
v9 = a1[1];
v10 = a2[1];
if ( v9 - 1 != v10 )
result = 5 * (unsigned int)(v9 == v10) - 1;
break;
default:
return 0xFFFFFFFFLL;
}
}
else
{
if ( v2 <= 4 )
{
result = 0xFFFFFFFFLL;
if ( (unsigned int)v2 > 3 )
return result;
v4 = *a2;
if ( v2 + 1 == *a2 )
{
v17 = a1[1];
v18 = a2[1];
result = 0LL;
if ( v17 + 1 == v18 )
return result;
result = 1LL;
if ( v17 == v18 )
return result;
}
if ( v2 != v4 )
{
if ( v4 == v2 - 1 )
{
v5 = a1[1];
v6 = a2[1];
if ( v5 - 1 == v6 )
return 3LL;
return 5 * (unsigned int)(v5 == v6) - 1;
}
return 0xFFFFFFFFLL;
}
goto LABEL_32;
}
result = 0xFFFFFFFFLL;
if ( (unsigned int)(v2 - 5) > 3 )
return result;
v7 = *a2;
if ( v2 + 1 != *a2 )
{
if ( v2 != v7 )
goto LABEL_12;
LABEL_32:
v15 = a1[1];
v16 = a2[1];
if ( v15 - 1 == v16 )
return 2LL;
goto LABEL_33;
}
v13 = a1[1];
v14 = a2[1];
result = 0LL;
if ( v13 != v14 )
{
result = 1LL;
if ( v14 != v13 - 1 )
{
if ( v2 == v2 + 1 )
{
v15 = a1[1];
v16 = a2[1];
LABEL_33:
v19 = v16 == v15 + 1;
result = 5LL;
if ( !v19 )
result = 0xFFFFFFFFLL;
return result;
}
LABEL_12:
if ( v7 == v2 - 1 )
{
v8 = a1[1];
v5 = a2[1];
if ( v8 == v5 )
return 3LL;
v6 = v8 + 1;
return 5 * (unsigned int)(v5 == v6) - 1;
}
return 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int direction(int *depart, int *arrivee){
 switch(depart[0]){
  case 0 :
  case 1 :
  case 2 :
  case 3 :
   if (depart[0]+1==arrivee[0] && depart[1]+1==arrivee[1]){
    return 0;
   }
   else if (depart[0]+1==arrivee[0] && depart[1]==arrivee[1]){
    return 1;
   }
   else if (depart[0]==arrivee[0] && depart[1]-1==arrivee[1]){
    return 2;
   }
   else if (depart[0]-1==arrivee[0] && depart[1]-1==arrivee[1]){
    return 3;
   }
   else if (depart[0]-1==arrivee[0] && depart[1]==arrivee[1]){
    return 4;
   }
   else if (depart[0]==arrivee[0] && depart[1]+1==arrivee[1]){
    return 5;
   }
   break;
  case 4 :
   if (depart[0]+1==arrivee[0] && depart[1]==arrivee[1]){
    return 0;
   }
   else if (depart[0]+1==arrivee[0] && depart[1]-1==arrivee[1]){
    return 1;
   }
   else if (depart[0]==arrivee[0] && depart[1]-1==arrivee[1]){
    return 2;
   }
   else if (depart[0]-1==arrivee[0] && depart[1]-1==arrivee[1]){
    return 3;
   }
   else if (depart[0]-1==arrivee[0] && depart[1]==arrivee[1]){
    return 4;
   }
   else if (depart[0]==arrivee[0] && depart[1]+1==arrivee[1]){
    return 5;
   }
   break;
  case 5 :
  case 6 :
  case 7 :
  case 8 :
   if (depart[0]+1==arrivee[0] && depart[1]==arrivee[1]){
    return 0;
   }
   else if (depart[0]+1==arrivee[0] && depart[1]-1==arrivee[1]){
    return 1;
   }
   else if (depart[0]==arrivee[0] && depart[1]-1==arrivee[1]){
    return 2;
   }
   else if (depart[0]-1==arrivee[0] && depart[1]==arrivee[1]){
    return 3;
   }
   else if (depart[0]-1==arrivee[0] && depart[1]+1==arrivee[1]){
    return 4;
   }
   else if (depart[0]==arrivee[0] && depart[1]+1==arrivee[1]){
    return 5;
   }
   break;
   break;
 }
 return -1;
}


nbBouleDeplace

original_code:
int nbBouleDeplace(Plateau *p, int **coor){
 if (coor[0][0]==2){
  return 1;
 }else {
  int dirBoules = direction(coor[1],coor[3]);
  int *caseSuivBoules = caseSuivant(p,coor[1], dirBoules);
  if (dirBoules!=-1 ){
   if(caseSuivBoules[0] == coor[2][0] && caseSuivBoules[1] == coor[2][1]){
    return 2;
   }
   else return 3;
  }
  return -1;
 }
}

canonical_original_code:
int nbBouleDeplace(struct Plateau *p, int **coor){
 if (coor[0][0]==2){
  return 1;
 }else {
  int dirBoules = direction(coor[1],coor[3]);
  int *caseSuivBoules = caseSuivant(p,coor[1], dirBoules);
  if (dirBoules!=-1 ){
   if(caseSuivBoules[0] == coor[2][0] && caseSuivBoules[1] == coor[2][1]){
    return 2;
   }
   else return 3;
  }
  return -1;
 }
}

variable_types:
coor
int **

variable_types: dirBoules int

variable_types:
caseSuivBoules
int *


directionTroisBoules

decompiled_code:
__int64 __fastcall directionTroisBoules(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
_QWORD *v3; // r12
unsigned int v4; // er14
int *v5; // rax

v2 = 0LL;
v3 = malloc(0x18uLL);
while ( 1 )
{
v4 = v2;
v5 = (int *)caseSuivant(a2, *(int **)(a1 + 8), v2);
v3[v2] = v5;
if ( v5 )
{
if ( (unsigned int)direction(v5, *(unsigned int **)(a1 + 16)) != -1 )
break;
}
if ( ++v2 == 6 )
return (unsigned int)-1;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
_QWORD *v3; // r12
unsigned int v4; // er14
int *v5; // rax

v2 = 0LL;
v3 = malloc(0x18uLL);
while ( 1 )
{
v4 = v2;
v5 = (int *)func2(a2, *(int **)(a1 + 8), v2);
v3[v2] = v5;
if ( v5 )
{
if ( (unsigned int)func3(v5, *(unsigned int **)(a1 + 16)) != -1 )
break;
}
if ( ++v2 == 6 )
return (unsigned int)-1;
}
return v4;
}

original_code:
int directionTroisBoules(int ** coor,Plateau *p){
 int ** dirrectionPossible = malloc(sizeof(int)*6);
 int i;
 for (i = 0; i < 6; i++){
  dirrectionPossible[i] = malloc(sizeof(int)*2);
  dirrectionPossible[i] = caseSuivant(p, coor[1], i);
  if(dirrectionPossible[i]!= ((void *)0) && direction(dirrectionPossible[i],coor[2]) != -1){
   return i;
  }
 }
 return -1;
}

canonical_original_code:
int directionTroisBoules(int **coor, struct Plateau *p){
 int **dirrectionPossible = malloc(sizeof(int)*6);
 int i;
 for (i = 0; i < 6; i++){
  dirrectionPossible[i] = malloc(sizeof(int)*2);
  dirrectionPossible[i] = caseSuivant(p, coor[1], i);
  if(dirrectionPossible[i]!= ((void *)0) && direction(dirrectionPossible[i],coor[2]) != -1){
   return i;
  }
 }
 return -1;
}

variable_types:
dirrectionPossible
int **

variable_types: i int


deplacement

decompiled_code:
__int64 __fastcall deplacement(__int64 a1, _QWORD *a2, char a3, unsigned int a4)
{
int v6; // eax
unsigned int v7; // er13
unsigned int *v9; // r15
int *v10; // r14
int v11; // er13
_DWORD *v12; // rax
_QWORD *v13; // r14
_DWORD *v14; // rax
__int64 v15; // rcx
__int64 v16; // rdx
_QWORD *v17; // rsi
int *v18; // r14
int v19; // edx
int *v20; // rsi
int *v21; // rax
int *v22; // r14
int *v23; // rdx
char v24; // r15
_QWORD *v25; // r13
_DWORD *v26; // rax
_DWORD *v27; // rdx
void *v28; // rdi
int v29; // er13
int v30; // eax
_DWORD *v31; // rax
int *v32; // rsi
__int64 v33; // rax
_QWORD *v34; // r14
_DWORD *v35; // rax
_DWORD *v36; // r15
void *v37; // rax
int *v38; // rax
_QWORD *v39; // r15
_DWORD *v40; // rax
int *v41; // rsi
int *v42; // rax
int *v43; // rax
int *v44; // r14
char v45; // al
int *v46; // rax
int *v47; // r15
char v48; // al
int *v49; // rax
int *v50; // rdx
int *v51; // rsi
int *v52; // rsi
int *v53; // rdx
int v54; // edx
int *v55; // rax
int *v56; // rax
int *v57; // r13
char v58; // al
int *v59; // rax
int *v60; // rsi
int *v61; // rdx
int *v62; // rax
unsigned int v64; // [rsp+8h] [rbp-50h]
_QWORD *v65; // [rsp+8h] [rbp-50h]
_DWORD *v66; // [rsp+8h] [rbp-50h]
_QWORD *v67; // [rsp+8h] [rbp-50h]
_DWORD *v68; // [rsp+8h] [rbp-50h]
unsigned int *v69; // [rsp+10h] [rbp-48h]
_QWORD *v70; // [rsp+10h] [rbp-48h]
int v71; // [rsp+10h] [rbp-48h]
_QWORD *v72; // [rsp+18h] [rbp-40h]

v6 = nbBouleDeplace(a1, (__int64)a2);
if ( v6 == 2 )
{
v9 = (unsigned int *)a2[2];
v10 = (int *)a2[1];
v64 = direction(v10, v9);
v69 = (unsigned int *)a2[3];
v11 = direction(v10, v69);
if ( v11 == -1 || v64 == -1 )
goto LABEL_58;
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * (int)*v9) + (int)v9[1]) != a3 )
{
if ( a4 != 1 )
{
v7 = -1;
puts(aLes2Boules);
return v7;
}
return (unsigned int)-1;
}
if ( v64 != v11 )
{
v65 = malloc(0x18uLL);
v12 = malloc(4uLL);
*v12 = 2;
v65[1] = v10;
v65[2] = v69;
*v65 = v12;
v70 = v65;
v13 = malloc(0x18uLL);
v14 = malloc(4uLL);
*v13 = v14;
v66 = v14;
v13[2] = malloc(8uLL);
*v66 = 2;
v13[1] = v9;
v13[2] = caseSuivant(a1, (int *)v9, v11);
deplacement(a1, v70, (unsigned int)a3, a4);
v15 = a4;
v16 = (unsigned int)a3;
v17 = v13;
LABEL_19:
v7 = 0;
deplacement(a1, v17, v16, v15);
free(a2);
return v7;
}
v56 = (int *)caseSuivant(a1, (int *)v9, v64);
v57 = v56;
if ( !v56 )
{
if ( a4 != 1 )
{
v7 = -1;
puts(aCaseArriv_1);
return v7;
}
return (unsigned int)-1;
}
v20 = (int *)*v56;
v23 = (int *)v64;
v58 = *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * (_QWORD)v20) + v56[1]);
if ( v58 == 46 )
{
if ( a4 == 1 )
goto LABEL_42;
v60 = (int *)a2[2];
v61 = v57;
}
else
{
if ( v58 == a3 )
{
a2[2] = v57;
v7 = 0;
deplacement(a1, a2, (unsigned int)v58, a4);
return v7;
}
v20 = v57;
v59 = (int *)caseSuivant(a1, v57, v64);
v23 = v59;
if ( !v59 )
{
if ( a4 == 1 )
goto LABEL_42;
deplaceBoule((_QWORD *)a1, (int *)a2[2], v57);
deplaceBoule((_QWORD *)a1, (int *)a2[1], (int *)a2[2]);
if ( a3 == 66 )
goto LABEL_55;
goto LABEL_52;
}
v20 = (int *)*v59;
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * (_QWORD)v20) + v59[1]) != 46 )
{
if ( a4 != 1 )
{
v7 = -1;
puts("Case apres la bille adverse non vide deplacement 2 boules ");
return v7;
}
return (unsigned int)-1;
}
if ( a4 == 1 )
goto LABEL_42;
deplaceBoule((_QWORD *)a1, v57, v59);
v60 = (int *)a2[2];
v61 = v57;
}
deplaceBoule((_QWORD *)a1, v60, v61);
v7 = 0;
deplaceBoule((_QWORD *)a1, (int *)a2[1], (int *)a2[2]);
return v7;
}
if ( v6 == 3 )
{
v29 = direction((int *)a2[1], (unsigned int *)a2[3]);
v30 = directionTroisBoules((__int64)a2, a1);
if ( v30 == -1 || v29 == -1 )
{
if ( a4 != 1 )
{
v7 = -1;
puts(aDeplacementImp_0);
return v7;
}
return (unsigned int)-1;
}
if ( v29 != v30 )
{
v71 = v30;
v67 = malloc(0x18uLL);
v31 = malloc(4uLL);
v32 = (int *)a2[1];
*v31 = 2;
*v67 = v31;
v33 = a2[3];
v67[1] = v32;
v67[2] = v33;
v72 = v67;
v34 = malloc(0x18uLL);
v35 = malloc(4uLL);
*v34 = v35;
v36 = v35;
v34[1] = malloc(8uLL);
v37 = malloc(8uLL);
*v36 = 2;
v34[2] = v37;
v38 = (int *)caseSuivant(a1, v32, v71);
v34[1] = v38;
v34[2] = caseSuivant(a1, v38, v29);
v39 = malloc(0x18uLL);
v40 = malloc(4uLL);
*v39 = v40;
v68 = v40;
v39[1] = malloc(8uLL);
v39[2] = malloc(8uLL);
v41 = (int *)v34[1];
*v68 = 2;
v42 = (int *)caseSuivant(a1, v41, v71);
v39[1] = v42;
v39[2] = caseSuivant(a1, v42, v29);
deplacement(a1, v39, (unsigned int)a3, a4);
deplacement(a1, v34, (unsigned int)a3, a4);
v15 = a4;
v16 = (unsigned int)a3;
v17 = v72;
goto LABEL_19;
}
v20 = (int *)a2[2];
v43 = (int *)caseSuivant(a1, v20, v29);
v44 = v43;
if ( !v43 )
goto LABEL_69;
v23 = *(int **)(*(_QWORD *)a1 + 8LL * *v43);
v45 = *((_BYTE *)v23 + v43[1]);
if ( v45 == 46 )
{
if ( a4 == 1 )
goto LABEL_42;
v52 = (int *)a2[2];
v53 = v44;
LABEL_31:
deplaceBoule((_QWORD *)a1, v52, v53);
v54 = v29;
v7 = 0;
v55 = (int *)caseSuivant(a1, (int *)a2[1], v54);
deplaceBoule((_QWORD *)a1, v55, (int *)a2[2]);
deplaceBoule((_QWORD *)a1, (int *)a2[1], (int *)a2[3]);
return v7;
}
if ( v45 == a3 )
{
if ( a4 != 1 )
{
v7 = -1;
puts("Case suivante est de la meme couleur deplacment 3 boules max");
return v7;
}
return (unsigned int)-1;
}
v20 = v44;
v46 = (int *)caseSuivant(a1, v44, v29);
v47 = v46;
if ( !v46 )
{
LABEL_69:
if ( a4 != 1 )
{
v7 = -1;
puts(aCaseArriv_0);
return v7;
}
return (unsigned int)-1;
}
v23 = *(int **)(*(_QWORD *)a1 + 8LL * *v46);
v48 = *((_BYTE *)v23 + v46[1]);
if ( v48 == 46 )
{
if ( a4 == 1 )
goto LABEL_42;
v50 = v47;
v51 = v44;
LABEL_30:
deplaceBoule((_QWORD *)a1, v51, v50);
v52 = (int *)a2[2];
v53 = v44;
goto LABEL_31;
}
if ( v48 == a3 )
{
if ( a4 != 1 )
{
v7 = -1;
puts("Case apres la bille adverse non vide deplacement 3 boules ");
return v7;
}
return (unsigned int)-1;
}
v20 = v47;
v49 = (int *)caseSuivant(a1, v47, v29);
v23 = v49;
if ( v49 )
{
v20 = (int *)*v49;
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * (_QWORD)v20) + v49[1]) != 46 )
{
if ( a4 != 1 )
{
v7 = -1;
puts("Case apres 2 billes adverse non vide deplacement 3 boules ");
return v7;
}
return (unsigned int)-1;
}
if ( a4 == 1 )
goto LABEL_42;
deplaceBoule((_QWORD *)a1, v47, v49);
v50 = v47;
v51 = v44;
goto LABEL_30;
}
if ( a4 == 1 )
goto LABEL_42;
deplaceBoule((_QWORD *)a1, v44, v47);
deplaceBoule((_QWORD *)a1, (int *)a2[2], v44);
v62 = (int *)caseSuivant(a1, (int *)a2[1], v29);
deplaceBoule((_QWORD *)a1, v62, (int *)a2[2]);
deplaceBoule((_QWORD *)a1, (int *)a2[1], (int *)a2[3]);
if ( a3 == 66 )
{
LABEL_55:
++*(_DWORD *)(a1 + 12);
return 0;
}
LABEL_52:
++*(_DWORD *)(a1 + 8);
return 0;
}
v7 = -1;
if ( v6 == 1 )
{
v18 = (int *)a2[1];
v19 = direction(v18, (unsigned int *)a2[2]);
if ( v19 != -1 )
{
v20 = v18;
v21 = (int *)caseSuivant(a1, v18, v19);
v22 = v21;
if ( !v21 )
{
if ( a4 != 1 )
{
puts(aCaseArriv);
return v7;
}
return (unsigned int)-1;
}
v23 = *(int **)(*(_QWORD *)a1 + 8LL * *v21);
v24 = *((_BYTE *)v23 + v21[1]);
if ( v24 != 46 )
{
if ( v24 == a3 )
{
v25 = malloc(0x20uLL);
v26 = malloc(4uLL);
v27 = (_DWORD *)*a2;
*v25 = v26;
LODWORD(v27) = *v27;
v25[2] = v22;
*v26 = (_DWORD)v27 + 1;
v25[1] = a2[1];
v25[3] = a2[2];
deplacement(a1, v25, (unsigned int)v24, a4);
v28 = v25;
v7 = 0;
free(v28);
return v7;
}
if ( a4 != 1 )
{
puts(s);
return v7;
}
return (unsigned int)-1;
}
if ( a4 != 1 )
{
v7 = 0;
deplaceBoule((_QWORD *)a1, (int *)a2[1], v21);
return v7;
}
LABEL_42:
v7 = 0;
addToList(a2, v20, v23);
return v7;
}
LABEL_58:
if ( a4 != 1 )
puts("Deplacement impssible cases non adjacente");
return (unsigned int)-1;
}
return v7;
}

original_code:
int deplacement(Plateau *p, int **coor,char couleur, int list){
 int *caseSuivDir;
 int dirBoule, dirDep;
 switch(nbBouleDeplace(p,coor)){
  case 1:
   dirDep = direction(coor[1],coor[2]);
   if(dirDep!=-1){
     caseSuivDir = caseSuivant(p,coor[1], dirDep);
    if(caseSuivDir != ((void *)0)){
     if(p->tableau[caseSuivDir[0]][caseSuivDir[1]] == '.'){
      if (list==1){
       addToList(coor);
      }
      else {
       deplaceBoule(p,coor[1], caseSuivDir);
      }
      return 0;
     }
     else if (p->tableau[caseSuivDir[0]][caseSuivDir[1]] == couleur){
      int ** coordonnee = malloc( sizeof(int *) * 4);
      coordonnee[0] = malloc(sizeof(int) * 1);
      coordonnee[1] = malloc( sizeof(int) * 2);
      coordonnee[2] = malloc( sizeof(int) * 2);
      coordonnee[3] = malloc( sizeof(int) * 2);
      coordonnee[0][0] = coor[0][0]+1;
      coordonnee[1] = coor[1];
      coordonnee[2] = caseSuivDir;
      coordonnee[3] = coor[2];
      deplacement(p,coordonnee,couleur,list);
      free(coordonnee);
     }
     else {
      if (list==1){
      }
      else {
       printf("case arrivé NON VIDE boule adverse (deplace 1 boule)\n");
      }
      return -1;
     }
    }else {
     if (list==1){
     }
     else {
      printf("case arrivé NULL(en dehors du plateau) (deplace 1 boule)\n");
     }
     return -1;
    }
   }else{
    if (list==1){
    }
    else {
     printf("Deplacement impssible cases non adjacente\n");
    }
    return -1;
   }
   break;
  case 2:
   dirBoule = direction(coor[1],coor[2]);
   dirDep = direction(coor[1],coor[3]);
   if (dirDep != -1 && dirBoule!=-1){
    if(couleur != p->tableau[coor[2][0]][coor[2][1]]){
     if (list==1){
     }
     else {
      printf("Les 2 boules à deplacer ne sont pas de la meme couleur\n");
     }
     return -1;
    }
    if (dirDep == dirBoule){
     caseSuivDir = caseSuivant(p,coor[2], dirDep);
     if(caseSuivDir != ((void *)0)){
      if(p->tableau[caseSuivDir[0]][caseSuivDir[1]] == '.'){
       if (list==1){
        addToList(coor);
       }
       else {
        deplaceBoule(p,coor[2], caseSuivDir);
        deplaceBoule(p,coor[1], coor[2]);
       }
      }
      else if (couleur != p->tableau[caseSuivDir[0]][caseSuivDir[1]]){
       int * caseADeplacerD = caseSuivant(p,caseSuivDir, dirDep);
       if (caseADeplacerD != ((void *)0)){
        if(p->tableau[caseADeplacerD[0]][caseADeplacerD[1]] == '.'){
         if (list==1){
          addToList(coor);
         }
         else {
          deplaceBoule(p,caseSuivDir, caseADeplacerD);
          deplaceBoule(p,coor[2], caseSuivDir);
          deplaceBoule(p,coor[1], coor[2]);
         }
        }
        else {
         if (list==1){
         }
         else {
          printf("Case apres la bille adverse non vide deplacement 2 boules \n");
         }
         return -1;
        }
       }
       else{
        if (list==1){
         addToList(coor);
        }
        else {
         deplaceBoule(p,coor[2], caseSuivDir);
         deplaceBoule(p,coor[1], coor[2]);
         if (couleur == 'B'){
          p->billesNoiresperdues++;
         }else{
          p->billesBlachesperdues++;
         }
        }
       }
      }
      else {
       coor[2] = caseSuivDir;
       deplacement(p,coor,couleur,list);
      }
     }else {
      if (list==1){
      }
      else {
       printf("case arrivé NULL(en dehors du plateau) (deplace 2 boule)\n");
      }return -1;
     }
    }
    else{
     int ** boule1, **boule2;
     boule1 = malloc( sizeof(int *) * 3);
     boule1[0] = malloc( sizeof(int) * 1);
     boule1[1] = malloc( sizeof(int) * 2);
     boule1[2] = malloc( sizeof(int) * 2);
     boule1[0][0] = 2;
     boule1[1] = coor[1];
     boule1[2] = coor[3];
     boule2 = malloc( sizeof(int *) * 3);
     boule2[0] = malloc( sizeof(int) * 1);
     boule2[1] = malloc( sizeof(int) * 2);
     boule2[2] = malloc( sizeof(int) * 2);
     boule2[0][0] = 2;
     boule2[1] = coor[2];
     boule2[2] = caseSuivant(p,coor[2], dirDep);
     deplacement(p,boule1,couleur,list );
     deplacement(p,boule2,couleur,list );
     free(coor);
    }
   }else {
    if (list==1){
      }
      else {
       printf("Deplacement impssible cases non adjacente\n");}
    return -1;
   }
   break;
  case 3:
   dirDep = direction(coor[1],coor[3]);
   dirBoule = directionTroisBoules(coor,p);
   if (dirBoule == -1 || dirDep == -1){
    if (list==1){
      }
      else {
       printf("Deplacement impssible cases non adjacente ou boules trop eloigné\n");}
    return -1;
   }
   else if (dirDep == dirBoule){
    caseSuivDir = caseSuivant(p,coor[2], dirDep);
    if(caseSuivDir != ((void *)0)){
     if(p->tableau[caseSuivDir[0]][caseSuivDir[1]] == '.'){
       if (list==1){
        addToList(coor);
       }
       else {
        deplaceBoule(p,coor[2], caseSuivDir);
        caseSuivDir = caseSuivant(p,coor[1], dirDep);
        deplaceBoule(p,caseSuivDir, coor[2]);
        deplaceBoule(p,coor[1], coor[3]);
       }
     }
     else if (p->tableau[caseSuivDir[0]][caseSuivDir[1]] == couleur){
      if (list==1){
      }
      else {
       printf("Case suivante est de la meme couleur deplacment 3 boules max\n");}
      return -1;
     }
     else {
      int *caseSuivDir2 = caseSuivant(p,caseSuivDir, dirDep);
      if(caseSuivDir2 != ((void *)0)){
       if(p->tableau[caseSuivDir2[0]][caseSuivDir2[1]] == '.'){
        if (list==1){
         addToList(coor);
        }
        else {
         deplaceBoule(p,caseSuivDir, caseSuivDir2);
         deplaceBoule(p,coor[2], caseSuivDir);
         caseSuivDir = caseSuivant(p,coor[1], dirDep);
         deplaceBoule(p,caseSuivDir, coor[2]);
         deplaceBoule(p,coor[1], coor[3]);
        }
       }
       else if(p->tableau[caseSuivDir2[0]][caseSuivDir2[1]] == couleur){
        if (list==1){
        }
        else {
         printf("Case apres la bille adverse non vide deplacement 3 boules \n");}
        return -1;
       }
       else {
        int *caseSuivDir3 = caseSuivant(p,caseSuivDir2, dirDep);
        if(caseSuivDir3 != ((void *)0)){
         if(p->tableau[caseSuivDir3[0]][caseSuivDir3[1]] == '.'){
          if (list==1){
           addToList(coor);
          }
          else {
           deplaceBoule(p,caseSuivDir2, caseSuivDir3);
           deplaceBoule(p,caseSuivDir, caseSuivDir2);
           deplaceBoule(p,coor[2], caseSuivDir);
           caseSuivDir = caseSuivant(p,coor[1], dirDep);
           deplaceBoule(p,caseSuivDir, coor[2]);
           deplaceBoule(p,coor[1], coor[3]);
          }
         }
         else {
          if (list==1){
          }
          else {
           printf("Case apres 2 billes adverse non vide deplacement 3 boules \n"); }
          return -1;
         }
        }
        else {
         if (list==1){
          addToList(coor);
         }
         else {
          deplaceBoule(p,caseSuivDir, caseSuivDir2);
          deplaceBoule(p,coor[2], caseSuivDir);
          caseSuivDir = caseSuivant(p,coor[1], dirDep);
          deplaceBoule(p,caseSuivDir, coor[2]);
          deplaceBoule(p,coor[1], coor[3]);
          if (couleur == 'B'){
           p->billesNoiresperdues++;
          }else{
           p->billesBlachesperdues++;
          }
         }
        }
       }
      }
      else {
       if (list==1){
      }
      else {
       printf("case arrivé NULL(en dehors du plateau) (deplace 3 boule)\n");}
       return -1;
      }
     }
    }
    else {
     if (list==1){
      }
      else {
       printf("case arrivé NULL(en dehors du plateau) (deplace 3 boule)\n");}
     return -1;
    }
   }
   else{
    int ** boule1, **boule2, **boule3;
    boule1 = malloc( sizeof(int *) * 3);
    boule1[0] = malloc( sizeof(int) * 1);
    boule1[1] = malloc( sizeof(int) * 2);
    boule1[2] = malloc( sizeof(int) * 2);
    boule1[0][0] = 2;
    boule1[1] = coor[1];
    boule1[2] = coor[3];
    boule2 = malloc( sizeof(int *) * 3);
    boule2[0] = malloc( sizeof(int) * 1);
    boule2[1] = malloc( sizeof(int) * 2);
    boule2[2] = malloc( sizeof(int) * 2);
    boule2[0][0] = 2;
    boule2[1] = caseSuivant(p,coor[1], dirBoule);
    boule2[2] = caseSuivant(p,boule2[1], dirDep);
    boule3 = malloc( sizeof(int *) * 3);
    boule3[0] = malloc( sizeof(int) * 1);
    boule3[1] = malloc( sizeof(int) * 2);
    boule3[2] = malloc( sizeof(int) * 2);
    boule3[0][0] = 2;
    boule3[1] = caseSuivant(p,boule2[1], dirBoule);
    boule3[2] = caseSuivant(p,boule3[1], dirDep);
    deplacement(p,boule3,couleur, list);
    deplacement(p,boule2,couleur,list);
    deplacement(p,boule1,couleur,list);
    free(coor);
   }
   break;
  default :
   return -1;
   break;
 }
 return 0;
}

canonical_original_code:
int deplacement(struct Plateau *p, int **coor, char couleur, int list){
 int *caseSuivDir;
 int dirBoule; int dirDep;
 switch(nbBouleDeplace(p,coor)){
  case 1:
   dirDep = direction(coor[1],coor[2]);
   if(dirDep!=-1){
     caseSuivDir = caseSuivant(p,coor[1], dirDep);
    if(caseSuivDir != ((void *)0)){
     if(p->tableau[caseSuivDir[0]][caseSuivDir[1]] == '.'){
      if (list==1){
       addToList(coor);
      }
      else {
       deplaceBoule(p,coor[1], caseSuivDir);
      }
      return 0;
     }
     else if (p->tableau[caseSuivDir[0]][caseSuivDir[1]] == couleur){
      int **coordonnee = malloc( sizeof(int *) * 4);
      coordonnee[0] = malloc(sizeof(int) * 1);
      coordonnee[1] = malloc( sizeof(int) * 2);
      coordonnee[2] = malloc( sizeof(int) * 2);
      coordonnee[3] = malloc( sizeof(int) * 2);
      coordonnee[0][0] = coor[0][0]+1;
      coordonnee[1] = coor[1];
      coordonnee[2] = caseSuivDir;
      coordonnee[3] = coor[2];
      deplacement(p,coordonnee,couleur,list);
      free(coordonnee);
     }
     else {
      if (list==1){
      }
      else {
       printf("case arrivé NON VIDE boule adverse (deplace 1 boule)\n");
      }
      return -1;
     }
    }else {
     if (list==1){
     }
     else {
      printf("case arrivé NULL(en dehors du plateau) (deplace 1 boule)\n");
     }
     return -1;
    }
   }else{
    if (list==1){
    }
    else {
     printf("Deplacement impssible cases non adjacente\n");
    }
    return -1;
   }
   break;
  case 2:
   dirBoule = direction(coor[1],coor[2]);
   dirDep = direction(coor[1],coor[3]);
   if (dirDep != -1 && dirBoule!=-1){
    if(couleur != p->tableau[coor[2][0]][coor[2][1]]){
     if (list==1){
     }
     else {
      printf("Les 2 boules à deplacer ne sont pas de la meme couleur\n");
     }
     return -1;
    }
    if (dirDep == dirBoule){
     caseSuivDir = caseSuivant(p,coor[2], dirDep);
     if(caseSuivDir != ((void *)0)){
      if(p->tableau[caseSuivDir[0]][caseSuivDir[1]] == '.'){
       if (list==1){
        addToList(coor);
       }
       else {
        deplaceBoule(p,coor[2], caseSuivDir);
        deplaceBoule(p,coor[1], coor[2]);
       }
      }
      else if (couleur != p->tableau[caseSuivDir[0]][caseSuivDir[1]]){
       int *caseADeplacerD = caseSuivant(p,caseSuivDir, dirDep);
       if (caseADeplacerD != ((void *)0)){
        if(p->tableau[caseADeplacerD[0]][caseADeplacerD[1]] == '.'){
         if (list==1){
          addToList(coor);
         }
         else {
          deplaceBoule(p,caseSuivDir, caseADeplacerD);
          deplaceBoule(p,coor[2], caseSuivDir);
          deplaceBoule(p,coor[1], coor[2]);
         }
        }
        else {
         if (list==1){
         }
         else {
          printf("Case apres la bille adverse non vide deplacement 2 boules \n");
         }
         return -1;
        }
       }
       else{
        if (list==1){
         addToList(coor);
        }
        else {
         deplaceBoule(p,coor[2], caseSuivDir);
         deplaceBoule(p,coor[1], coor[2]);
         if (couleur == 'B'){
          p->billesNoiresperdues++;
         }else{
          p->billesBlachesperdues++;
         }
        }
       }
      }
      else {
       coor[2] = caseSuivDir;
       deplacement(p,coor,couleur,list);
      }
     }else {
      if (list==1){
      }
      else {
       printf("case arrivé NULL(en dehors du plateau) (deplace 2 boule)\n");
      }return -1;
     }
    }
    else{
     int **boule1; int **boule2;
     boule1 = malloc( sizeof(int *) * 3);
     boule1[0] = malloc( sizeof(int) * 1);
     boule1[1] = malloc( sizeof(int) * 2);
     boule1[2] = malloc( sizeof(int) * 2);
     boule1[0][0] = 2;
     boule1[1] = coor[1];
     boule1[2] = coor[3];
     boule2 = malloc( sizeof(int *) * 3);
     boule2[0] = malloc( sizeof(int) * 1);
     boule2[1] = malloc( sizeof(int) * 2);
     boule2[2] = malloc( sizeof(int) * 2);
     boule2[0][0] = 2;
     boule2[1] = coor[2];
     boule2[2] = caseSuivant(p,coor[2], dirDep);
     deplacement(p,boule1,couleur,list );
     deplacement(p,boule2,couleur,list );
     free(coor);
    }
   }else {
    if (list==1){
      }
      else {
       printf("Deplacement impssible cases non adjacente\n");}
    return -1;
   }
   break;
  case 3:
   dirDep = direction(coor[1],coor[3]);
   dirBoule = directionTroisBoules(coor,p);
   if (dirBoule == -1 || dirDep == -1){
    if (list==1){
      }
      else {
       printf("Deplacement impssible cases non adjacente ou boules trop eloigné\n");}
    return -1;
   }
   else if (dirDep == dirBoule){
    caseSuivDir = caseSuivant(p,coor[2], dirDep);
    if(caseSuivDir != ((void *)0)){
     if(p->tableau[caseSuivDir[0]][caseSuivDir[1]] == '.'){
       if (list==1){
        addToList(coor);
       }
       else {
        deplaceBoule(p,coor[2], caseSuivDir);
        caseSuivDir = caseSuivant(p,coor[1], dirDep);
        deplaceBoule(p,caseSuivDir, coor[2]);
        deplaceBoule(p,coor[1], coor[3]);
       }
     }
     else if (p->tableau[caseSuivDir[0]][caseSuivDir[1]] == couleur){
      if (list==1){
      }
      else {
       printf("Case suivante est de la meme couleur deplacment 3 boules max\n");}
      return -1;
     }
     else {
      int *caseSuivDir2 = caseSuivant(p,caseSuivDir, dirDep);
      if(caseSuivDir2 != ((void *)0)){
       if(p->tableau[caseSuivDir2[0]][caseSuivDir2[1]] == '.'){
        if (list==1){
         addToList(coor);
        }
        else {
         deplaceBoule(p,caseSuivDir, caseSuivDir2);
         deplaceBoule(p,coor[2], caseSuivDir);
         caseSuivDir = caseSuivant(p,coor[1], dirDep);
         deplaceBoule(p,caseSuivDir, coor[2]);
         deplaceBoule(p,coor[1], coor[3]);
        }
       }
       else if(p->tableau[caseSuivDir2[0]][caseSuivDir2[1]] == couleur){
        if (list==1){
        }
        else {
         printf("Case apres la bille adverse non vide deplacement 3 boules \n");}
        return -1;
       }
       else {
        int *caseSuivDir3 = caseSuivant(p,caseSuivDir2, dirDep);
        if(caseSuivDir3 != ((void *)0)){
         if(p->tableau[caseSuivDir3[0]][caseSuivDir3[1]] == '.'){
          if (list==1){
           addToList(coor);
          }
          else {
           deplaceBoule(p,caseSuivDir2, caseSuivDir3);
           deplaceBoule(p,caseSuivDir, caseSuivDir2);
           deplaceBoule(p,coor[2], caseSuivDir);
           caseSuivDir = caseSuivant(p,coor[1], dirDep);
           deplaceBoule(p,caseSuivDir, coor[2]);
           deplaceBoule(p,coor[1], coor[3]);
          }
         }
         else {
          if (list==1){
          }
          else {
           printf("Case apres 2 billes adverse non vide deplacement 3 boules \n"); }
          return -1;
         }
        }
        else {
         if (list==1){
          addToList(coor);
         }
         else {
          deplaceBoule(p,caseSuivDir, caseSuivDir2);
          deplaceBoule(p,coor[2], caseSuivDir);
          caseSuivDir = caseSuivant(p,coor[1], dirDep);
          deplaceBoule(p,caseSuivDir, coor[2]);
          deplaceBoule(p,coor[1], coor[3]);
          if (couleur == 'B'){
           p->billesNoiresperdues++;
          }else{
           p->billesBlachesperdues++;
          }
         }
        }
       }
      }
      else {
       if (list==1){
      }
      else {
       printf("case arrivé NULL(en dehors du plateau) (deplace 3 boule)\n");}
       return -1;
      }
     }
    }
    else {
     if (list==1){
      }
      else {
       printf("case arrivé NULL(en dehors du plateau) (deplace 3 boule)\n");}
     return -1;
    }
   }
   else{
    int **boule1; int **boule2; int **boule3;
    boule1 = malloc( sizeof(int *) * 3);
    boule1[0] = malloc( sizeof(int) * 1);
    boule1[1] = malloc( sizeof(int) * 2);
    boule1[2] = malloc( sizeof(int) * 2);
    boule1[0][0] = 2;
    boule1[1] = coor[1];
    boule1[2] = coor[3];
    boule2 = malloc( sizeof(int *) * 3);
    boule2[0] = malloc( sizeof(int) * 1);
    boule2[1] = malloc( sizeof(int) * 2);
    boule2[2] = malloc( sizeof(int) * 2);
    boule2[0][0] = 2;
    boule2[1] = caseSuivant(p,coor[1], dirBoule);
    boule2[2] = caseSuivant(p,boule2[1], dirDep);
    boule3 = malloc( sizeof(int *) * 3);
    boule3[0] = malloc( sizeof(int) * 1);
    boule3[1] = malloc( sizeof(int) * 2);
    boule3[2] = malloc( sizeof(int) * 2);
    boule3[0][0] = 2;
    boule3[1] = caseSuivant(p,boule2[1], dirBoule);
    boule3[2] = caseSuivant(p,boule3[1], dirDep);
    deplacement(p,boule3,couleur, list);
    deplacement(p,boule2,couleur,list);
    deplacement(p,boule1,couleur,list);
    free(coor);
   }
   break;
  default :
   return -1;
   break;
 }
 return 0;
}

variable_types: couleur char

variable_types: list int

variable_types:
caseSuivDir
int *

variable_types: dirBoule int

variable_types: dirDep int

variable_types:
coordonnee
int **

variable_types:
caseADeplacerD
int *


gameTest

decompiled_code:
void __fastcall __noreturn gameTest(_QWORD *a1)
{
void *v1; // rbx
__int64 v2; // rax

v1 = malloc(9uLL);
affichagePlateau(a1);
while ( scanf("%s", v1) != -1 )
{
printf("\x1B[2J\x1B[1;1H");
v2 = decoupageCoups(v1);
if ( v2 )
{
deplacement(
a1,
v2,
(unsigned int)*(char *)(*(_QWORD *)(*a1 + 8LL * **(int **)(v2 + 8)) + **(int **)(v2 + 8)),
0LL);
affichagePlateau(a1);
}
else
{
puts("coups invalide");
}
}
sauvegarde(a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(_QWORD *a1)
{
void *v1; // rbx
__int64 v2; // rax

v1 = malloc(9uLL);
affichagePlateau(a1);
while ( scanf("%s", v1) != -1 )
{
printf("\x1B[2J\x1B[1;1H");
v2 = decoupageCoups(v1);
if ( v2 )
{
deplacement(
a1,
v2,
(unsigned int)*(char *)(*(_QWORD *)(*a1 + 8LL * **(int **)(v2 + 8)) + **(int **)(v2 + 8)),
0LL);
affichagePlateau(a1);
}
else
{
puts("coups invalide");
}
}
sauvegarde(a1);
exit(0);
}

original_code:
int gameTest(Plateau *p){
  char *coups = malloc(sizeof(char)*9);
 int **coordonnee;
 affichagePlateau(p);
 while(scanf("%s" ,coups) != (-1)){
  printf("\033[2J\033[1;1H");
  coordonnee = decoupageCoups(coups);
  if (coordonnee != ((void *)0)){
   deplacement(p,coordonnee,p->tableau[coordonnee[1][0]][coordonnee[1][0]],0);
   affichagePlateau(p);
  }
  else printf("coups invalide\n");
 };
 sauvegarde(p);
 exit(0);
}

canonical_original_code:
int gameTest(struct Plateau *p){
  char *coups = malloc(sizeof(char)*9);
 int **coordonnee;
 affichagePlateau(p);
 while(scanf("%s" ,coups) != (-1)){
  printf("\033[2J\033[1;1H");
  coordonnee = decoupageCoups(coups);
  if (coordonnee != ((void *)0)){
   deplacement(p,coordonnee,p->tableau[coordonnee[1][0]][coordonnee[1][0]],0);
   affichagePlateau(p);
  }
  else printf("coups invalide\n");
 };
 sauvegarde(p);
 exit(0);
}

variable_types: struct Plateau { char **tableau; int billesBlachesperdues; int billesNoiresperdues; char JoueurSuivant; int typeBlanc; int typeNoir; } *

variable_types:
coups
char *


gamePIA

decompiled_code:
__int64 __fastcall gamePIA(__int64 a1)
{
const char *v1; // rax
const char *v2; // rbp
__int64 v3; // rsi
int i; // er12
int v5; // eax
__int64 v6; // rax
__int64 v8; // rax
__int64 v9; // r13
__int64 v10; // r13
char v11[41]; // [rsp+Fh] [rbp-29h] BYREF

v1 = (const char *)malloc(9uLL);
LOBYTE(i) = *(_BYTE *)(a1 + 16) == 78;
v2 = v1;
affichagePlateau(a1);
v3 = *(unsigned int *)(a1 + 8);
for ( i = (unsigned __int8)i; (int)v3 <= 5; v3 = *(unsigned int *)(a1 + 8) )
{
v5 = *(_DWORD *)(a1 + 12);
if ( v5 > 5 )
goto LABEL_14;
if ( (i & 1) != 0 )
{
puts("\n\nTOUR NOIR");
if ( *(_DWORD *)(a1 + 24) == 1 )
{
++i;
v9 = play(78LL, a1);
sleep(1u);
deplacement(a1, v9, 78LL, 0LL);
*(_BYTE *)(a1 + 16) = 66;
goto LABEL_12;
}
scanf("%s", v2);
if ( !strcmp(v2, "SAVE") || !strcmp(v2, "save") )
{
sauvegarde(a1);
puts(aContinuer);
scanf("%s", v11);
if ( (v11[0] & 0xDF) != 89 )
return 0xFFFFFFFFLL;
scanf("%s", v2);
}
v8 = decoupageCoups(v2);
if ( !v8 )
{
LABEL_28:
puts(aCoordonn);
goto LABEL_12;
}
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * **(int **)(v8 + 8)) + *(int *)(*(_QWORD *)(v8 + 8) + 4LL)) == 78 )
{
if ( (unsigned int)deplacement(a1, v8, 78LL, 0LL) != -1 )
{
*(_BYTE *)(a1 + 16) = 66;
++i;
}
goto LABEL_12;
}
}
else
{
puts("\n\nTOUR BLANC\n");
if ( *(_DWORD *)(a1 + 20) == 1 )
{
++i;
v10 = play(66LL, a1);
sleep(1u);
deplacement(a1, v10, 66LL, 0LL);
*(_BYTE *)(a1 + 16) = 78;
goto LABEL_12;
}
scanf("%s", v2);
if ( !strcmp(v2, "SAVE") || !strcmp(v2, "save") )
{
sauvegarde(a1);
puts(aContinuer);
scanf("%s", v11);
if ( (v11[0] & 0xDF) != 89 )
return 0xFFFFFFFFLL;
scanf("%s", v2);
}
v6 = decoupageCoups(v2);
if ( !v6 )
goto LABEL_28;
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * **(int **)(v6 + 8)) + *(int *)(*(_QWORD *)(v6 + 8) + 4LL)) == 66 )
{
if ( (unsigned int)deplacement(a1, v6, 66LL, 0LL) != -1 )
{
*(_BYTE *)(a1 + 16) = 78;
++i;
}
goto LABEL_12;
}
}
puts("ERREUR Tu ne peux pas deplacer ce pion");
LABEL_12:
printf("\x1B[2J\x1B[1;1H");
affichagePlateau(a1);
}
v5 = *(_DWORD *)(a1 + 12);
LABEL_14:
if ( v5 == 6 )
{
printf("bille blanche perdu %d\n", v3);
printf("bille Noir perdu %d\n", *(unsigned int *)(a1 + 12));
puts("Blanc gagne");
}
else
{
printf("bille blanche perdu %d\n", v3);
printf("bille Noir perdu %d\n", *(unsigned int *)(a1 + 12));
puts("Noir gagne");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
const char *v1; // rax
const char *v2; // rbp
__int64 v3; // rsi
int i; // er12
int v5; // eax
__int64 v6; // rax
__int64 v8; // rax
__int64 v9; // r13
__int64 v10; // r13
char v11[41]; // [rsp+Fh] [rbp-29h] BYREF

v1 = (const char *)malloc(9uLL);
LOBYTE(i) = *(_BYTE *)(a1 + 16) == 78;
v2 = v1;
affichagePlateau(a1);
v3 = *(unsigned int *)(a1 + 8);
for ( i = (unsigned __int8)i; (int)v3 <= 5; v3 = *(unsigned int *)(a1 + 8) )
{
v5 = *(_DWORD *)(a1 + 12);
if ( v5 > 5 )
goto LABEL_14;
if ( (i & 1) != 0 )
{
puts("\n\nTOUR NOIR");
if ( *(_DWORD *)(a1 + 24) == 1 )
{
++i;
v9 = play(78LL, a1);
sleep(1u);
deplacement(a1, v9, 78LL, 0LL);
*(_BYTE *)(a1 + 16) = 66;
goto LABEL_12;
}
scanf("%s", v2);
if ( !strcmp(v2, "SAVE") || !strcmp(v2, "save") )
{
sauvegarde(a1);
puts(aContinuer);
scanf("%s", v11);
if ( (v11[0] & 0xDF) != 89 )
return 0xFFFFFFFFLL;
scanf("%s", v2);
}
v8 = decoupageCoups(v2);
if ( !v8 )
{
LABEL_28:
puts(aCoordonn);
goto LABEL_12;
}
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * **(int **)(v8 + 8)) + *(int *)(*(_QWORD *)(v8 + 8) + 4LL)) == 78 )
{
if ( (unsigned int)deplacement(a1, v8, 78LL, 0LL) != -1 )
{
*(_BYTE *)(a1 + 16) = 66;
++i;
}
goto LABEL_12;
}
}
else
{
puts("\n\nTOUR BLANC\n");
if ( *(_DWORD *)(a1 + 20) == 1 )
{
++i;
v10 = play(66LL, a1);
sleep(1u);
deplacement(a1, v10, 66LL, 0LL);
*(_BYTE *)(a1 + 16) = 78;
goto LABEL_12;
}
scanf("%s", v2);
if ( !strcmp(v2, "SAVE") || !strcmp(v2, "save") )
{
sauvegarde(a1);
puts(aContinuer);
scanf("%s", v11);
if ( (v11[0] & 0xDF) != 89 )
return 0xFFFFFFFFLL;
scanf("%s", v2);
}
v6 = decoupageCoups(v2);
if ( !v6 )
goto LABEL_28;
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * **(int **)(v6 + 8)) + *(int *)(*(_QWORD *)(v6 + 8) + 4LL)) == 66 )
{
if ( (unsigned int)deplacement(a1, v6, 66LL, 0LL) != -1 )
{
*(_BYTE *)(a1 + 16) = 78;
++i;
}
goto LABEL_12;
}
}
puts("ERREUR Tu ne peux pas deplacer ce pion");
LABEL_12:
printf("\x1B[2J\x1B[1;1H");
affichagePlateau(a1);
}
v5 = *(_DWORD *)(a1 + 12);
LABEL_14:
if ( v5 == 6 )
{
printf("bille blanche perdu %d\n", v3);
printf("bille Noir perdu %d\n", *(unsigned int *)(a1 + 12));
puts("Blanc gagne");
}
else
{
printf("bille blanche perdu %d\n", v3);
printf("bille Noir perdu %d\n", *(unsigned int *)(a1 + 12));
puts("Noir gagne");
}
return 0LL;
}

original_code:
int gamePIA(Plateau *p){
 int tour =0;
 char *coups = malloc(sizeof(char)*9);
 int **coordonnee;
 if (p->JoueurSuivant == 'N'){
  tour=1;
 }
 affichagePlateau(p);
 while(p->billesBlachesperdues < 6 && p->billesNoiresperdues < 6){
  switch(tour%2){
   case 0 :
    printf("\n\nTOUR BLANC\n\n");
    if (p->typeBlanc == 1){
     int ** coor =play('B',p);
                    sleep(1);
        deplacement(p,coor,'B',0);
        p->JoueurSuivant = 'N';
    }
    else {
     scanf("%s" ,coups);
     if ((strcmp(coups,"SAVE")==0)||(strcmp(coups,"save")==0)){
      char continueJouer;
      sauvegarde(p);
      printf("Continuer à jouer ? [Y/n]\n");
      scanf("%s" ,&continueJouer);
      if (continueJouer == 'y' || continueJouer == 'Y'){
       scanf("%s" ,coups);
      }
      else return -1;
     }
     coordonnee = decoupageCoups(coups);
     if (coordonnee != ((void *)0)){
      if(p->tableau[coordonnee[1][0]][coordonnee[1][1]]=='B'){
       if ( deplacement(p,coordonnee,'B',0) !=-1 ){
         p->JoueurSuivant = 'N';
        }
        else {
         tour--;
        }
      }else{
       printf("ERREUR Tu ne peux pas deplacer ce pion\n");
       tour--;
      }
     }
     else{
      printf("coordonnées INVALIDE\n");
      tour--;
     }
    }
    tour++;
    break;
   case 1 :
    printf("\n\nTOUR NOIR\n");
    if (p->typeNoir == 1){
     int ** coor =play('N',p);
     sleep(1);
     deplacement(p,coor,'N',0);
     p->JoueurSuivant = 'B';
    }
    else {
     scanf("%s" ,coups);
     if ((strcmp(coups,"SAVE")==0)||(strcmp(coups,"save")==0)){
      char continueJouer;
      sauvegarde(p);
      printf("Continuer à jouer ? [Y/n]\n");
      scanf("%s" ,&continueJouer);
      if (continueJouer == 'y' || continueJouer == 'Y'){
       scanf("%s" ,coups);
      }
      else return -1;
     }
     coordonnee = decoupageCoups(coups);
     if (coordonnee != ((void *)0)){
      if(p->tableau[coordonnee[1][0]][coordonnee[1][1]]=='N'){
       if ( deplacement(p,coordonnee,'N',0) !=-1 ){
         p->JoueurSuivant = 'B';
        }
        else {
         tour--;
        }
      }else{
       printf("ERREUR Tu ne peux pas deplacer ce pion\n");
       tour--;
      }
     }
     else{
      printf("coordonnées INVALIDE\n");
      tour--;
     }
    }
    tour++;
    break;
  }
  printf("\033[2J\033[1;1H");
  affichagePlateau(p);
 }
 if (p->billesNoiresperdues==6){
  printf("bille blanche perdu %d\n",p->billesBlachesperdues);
  printf("bille Noir perdu %d\n",p->billesNoiresperdues);
  printf("Blanc gagne\n");
 }else{
  printf("bille blanche perdu %d\n",p->billesBlachesperdues);
  printf("bille Noir perdu %d\n",p->billesNoiresperdues);
  printf("Noir gagne\n");
 }
 return 0;
}

canonical_original_code:
int gamePIA(struct Plateau *p){
 int tour = 0;
 char *coups = malloc(sizeof(char)*9);
 int **coordonnee;
 if (p->JoueurSuivant == 'N'){
  tour=1;
 }
 affichagePlateau(p);
 while(p->billesBlachesperdues < 6 && p->billesNoiresperdues < 6){
  switch(tour%2){
   case 0 :
    printf("\n\nTOUR BLANC\n\n");
    if (p->typeBlanc == 1){
     int **coor = play('B',p);
                    sleep(1);
        deplacement(p,coor,'B',0);
        p->JoueurSuivant = 'N';
    }
    else {
     scanf("%s" ,coups);
     if ((strcmp(coups,"SAVE")==0)||(strcmp(coups,"save")==0)){
      char continueJouer;
      sauvegarde(p);
      printf("Continuer à jouer ? [Y/n]\n");
      scanf("%s" ,&continueJouer);
      if (continueJouer == 'y' || continueJouer == 'Y'){
       scanf("%s" ,coups);
      }
      else return -1;
     }
     coordonnee = decoupageCoups(coups);
     if (coordonnee != ((void *)0)){
      if(p->tableau[coordonnee[1][0]][coordonnee[1][1]]=='B'){
       if ( deplacement(p,coordonnee,'B',0) !=-1 ){
         p->JoueurSuivant = 'N';
        }
        else {
         tour--;
        }
      }else{
       printf("ERREUR Tu ne peux pas deplacer ce pion\n");
       tour--;
      }
     }
     else{
      printf("coordonnées INVALIDE\n");
      tour--;
     }
    }
    tour++;
    break;
   case 1 :
    printf("\n\nTOUR NOIR\n");
    if (p->typeNoir == 1){
     int **coor = play('N',p);
     sleep(1);
     deplacement(p,coor,'N',0);
     p->JoueurSuivant = 'B';
    }
    else {
     scanf("%s" ,coups);
     if ((strcmp(coups,"SAVE")==0)||(strcmp(coups,"save")==0)){
      char continueJouer;
      sauvegarde(p);
      printf("Continuer à jouer ? [Y/n]\n");
      scanf("%s" ,&continueJouer);
      if (continueJouer == 'y' || continueJouer == 'Y'){
       scanf("%s" ,coups);
      }
      else return -1;
     }
     coordonnee = decoupageCoups(coups);
     if (coordonnee != ((void *)0)){
      if(p->tableau[coordonnee[1][0]][coordonnee[1][1]]=='N'){
       if ( deplacement(p,coordonnee,'N',0) !=-1 ){
         p->JoueurSuivant = 'B';
        }
        else {
         tour--;
        }
      }else{
       printf("ERREUR Tu ne peux pas deplacer ce pion\n");
       tour--;
      }
     }
     else{
      printf("coordonnées INVALIDE\n");
      tour--;
     }
    }
    tour++;
    break;
  }
  printf("\033[2J\033[1;1H");
  affichagePlateau(p);
 }
 if (p->billesNoiresperdues==6){
  printf("bille blanche perdu %d\n",p->billesBlachesperdues);
  printf("bille Noir perdu %d\n",p->billesNoiresperdues);
  printf("Blanc gagne\n");
 }else{
  printf("bille blanche perdu %d\n",p->billesBlachesperdues);
  printf("bille Noir perdu %d\n",p->billesNoiresperdues);
  printf("Noir gagne\n");
 }
 return 0;
}

variable_types: tour int

variable_types: continueJouer char


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // eax
_BYTE v6[56]; // [rsp+0h] [rbp-38h] BYREF

creationPlateau(v6, argv, envp);
v3 = time(0LL);
srand(v3);
initPlateau(v6);
v4 = optionGlobales(argv, (unsigned int)argc, v6);
if ( v4 == 2 )
{
gameTest(v6);
}
else if ( v4 )
{
puts("ERROR");
}
else
{
gamePIA(v6);
}
return 0;
}

original_code:
int main(int argc, char const *argv[]){
 int mode;
    Plateau p = creationPlateau();
    srand(time(((void *)0)));
    initPlateau(&p);
    mode = optionGlobales(argv,argc,&p);
    if (mode==2){
     gameTest(&p);
    }
    else if (mode ==0){
     gamePIA(&p);
    }
    else{
        printf("ERROR\n");
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
 int mode;
    struct Plateau p = creationPlateau();
    srand(time(((void *)0)));
    initPlateau(&p);
    mode = optionGlobales(argv,argc,&p);
    if (mode==2){
     gameTest(&p);
    }
    else if (mode ==0){
     gamePIA(&p);
    }
    else{
        printf("ERROR\n");
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: mode int

variable_types: struct Plateau { char **tableau; int billesBlachesperdues; int billesNoiresperdues; char JoueurSuivant; int typeBlanc; int typeNoir; }


initPlateau

original_code:
void initPlateau(Plateau *p){
 int j =0, i = 0;
 char car = 'N';
 p->typeBlanc = 2;
 p->typeNoir = 2;
 while (i < 9 ){
  p->tableau[i][j] = car;
        j++;
         switch (i){
    case 0:
     if (j >= 5 ){
      i++;
                   j =0;
     }
     break;
    case 1:
     if (j >= 6 ){
      i++;
                  j =0;
                  car = '.';
                 }
     break;
    case 2:
     if (j >= 7 ){
      i++;
                  j =0;
                  car = '.';
                 }
                 if(j<5 && j>=2)car = 'N';
     else car = '.';
     break;
    case 3:
     if (j >= 8 ){
      i++;
                  j =0;
     }
     break;
    case 4:
     if (j >= 9 ){
      i++;
                  j =0;
                 }
     break;
    case 5:
     if (j >=8 ){
      i++;
                  j =0;
              }
     break;
    case 6:
     if (j >= 7 ){
      i++;
                  j =0;
               car = 'B';
     }
     else if(j<5 && j>=2)car = 'B';
     else car = '.';
     break;
    case 7:
     if (j >= 6 ){
      i++;
                  j =0;
              }
     break;
    case 8:
     if (j >= 5 ){
      i++;
                  j =0;
     }
     break;
   }
    }
}

canonical_original_code:
void initPlateau(struct Plateau *p){
 int j = 0; int i = 0;
 char car = 'N';
 p->typeBlanc = 2;
 p->typeNoir = 2;
 while (i < 9 ){
  p->tableau[i][j] = car;
        j++;
         switch (i){
    case 0:
     if (j >= 5 ){
      i++;
                   j =0;
     }
     break;
    case 1:
     if (j >= 6 ){
      i++;
                  j =0;
                  car = '.';
                 }
     break;
    case 2:
     if (j >= 7 ){
      i++;
                  j =0;
                  car = '.';
                 }
                 if(j<5 && j>=2)car = 'N';
     else car = '.';
     break;
    case 3:
     if (j >= 8 ){
      i++;
                  j =0;
     }
     break;
    case 4:
     if (j >= 9 ){
      i++;
                  j =0;
                 }
     break;
    case 5:
     if (j >=8 ){
      i++;
                  j =0;
              }
     break;
    case 6:
     if (j >= 7 ){
      i++;
                  j =0;
               car = 'B';
     }
     else if(j<5 && j>=2)car = 'B';
     else car = '.';
     break;
    case 7:
     if (j >= 6 ){
      i++;
                  j =0;
              }
     break;
    case 8:
     if (j >= 5 ){
      i++;
                  j =0;
     }
     break;
   }
    }
}

variable_types: j int

variable_types: car char


affichagePlateau

decompiled_code:
int __fastcall affichagePlateau(__int64 a1)
{
int v1; // ebp
__int64 v2; // rax
char v3; // dl
__int64 v4; // r12
int v5; // ebp
char v6; // dl
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // r12
char v10; // dl
__int64 v11; // rax
__int64 v12; // rsi
char v13; // dl
int v14; // ebp
char v15; // dl
__int64 v16; // rax
__int64 v17; // rsi
int v18; // ebp
char v19; // dl
__int64 v20; // rax
__int64 v21; // rsi
int v22; // ebp
char v23; // dl
__int64 v24; // rax
__int64 v25; // rsi
int v26; // ebp
char v27; // dl
__int64 v28; // rax
__int64 v29; // rsi
int v30; // ebp
char v31; // al
__int64 v32; // rdx
__int64 v33; // rsi

v1 = 1;
printf(" -----------\n I / ");
v2 = 0LL;
while ( 1 )
{
printf("%c ", (unsigned int)*(char *)(**(_QWORD **)a1 + v2));
v2 = v1;
if ( v1 > 4 )
break;
while ( 1 )
{
v3 = v1;
v4 = v2 + 1;
++v1;
if ( (v3 & 1) == 0 )
break;
printf("\x1B[44m%c\x1B[0m ", (unsigned int)*(char *)(**(_QWORD **)a1 + v2));
v2 = v4;
if ( v1 > 4 )
goto LABEL_5;
}
}
LABEL_5:
v5 = 1;
printf("\\ \n H / ");
printf("\x1B[44m%c\x1B[0m ", (unsigned int)**(char **)(*(_QWORD *)a1 + 8LL));
while ( 1 )
{
LABEL_6:
if ( v5 > 5 )
{
v5 = 1;
printf("\\ \n G / ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 16LL));
LABEL_11:
while ( v5 <= 6 )
{
while ( 1 )
{
v10 = v5;
v11 = v5++;
v12 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 16LL) + v11);
if ( (v10 & 1) != 0 )
break;
printf("%c ", v12);
if ( v5 > 6 )
goto LABEL_14;
}
printf("\x1B[44m%c\x1B[0m ", v12);
}
LABEL_14:
v5 = 1;
printf(asc_EB0);
printf("\x1B[44m%c\x1B[0m ", (unsigned int)**(char **)(*(_QWORD *)a1 + 24LL));
goto LABEL_15;
}
v6 = v5;
v7 = v5++;
if ( (v6 & 1) == 0 )
break;
printf("%c ", (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL) + v7));
}
v8 = 8LL;
v9 = 1LL;
LABEL_9:
printf("\x1B[44m%c\x1B[0m ", (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + v8) + v7));
switch ( v9 )
{
case 0LL:
case 1LL:
goto LABEL_6;
case 2LL:
goto LABEL_11;
case 3LL:
break;
}
LABEL_15:
while ( v5 <= 7 )
{
v13 = v5;
v7 = v5++;
if ( (v13 & 1) == 0 )
{
v8 = 24LL;
v9 = 3LL;
goto LABEL_9;
}
printf("%c ", (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 24LL) + v7));
}
v14 = 1;
printf(asc_EBA);
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 32LL));
while ( v14 <= 8 )
{
while ( 1 )
{
v15 = v14;
v16 = v14++;
v17 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 32LL) + v16);
if ( (v15 & 1) != 0 )
break;
printf("%c ", v17);
if ( v14 > 8 )
goto LABEL_22;
}
printf("\x1B[44m%c\x1B[0m ", v17);
}
LABEL_22:
v18 = 1;
printf("| \n D \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 40LL));
while ( v18 <= 7 )
{
while ( 1 )
{
v19 = v18;
v20 = v18++;
v21 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 40LL) + v20);
if ( (v19 & 1) != 0 )
break;
printf("%c ", v21);
if ( v18 > 7 )
goto LABEL_26;
}
printf("\x1B[44m%c\x1B[0m ", v21);
}
LABEL_26:
v22 = 1;
printf("/ \n C \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 48LL));
while ( v22 <= 6 )
{
while ( 1 )
{
v23 = v22;
v24 = v22++;
v25 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 48LL) + v24);
if ( (v23 & 1) != 0 )
break;
printf("%c ", v25);
if ( v22 > 6 )
goto LABEL_30;
}
printf("\x1B[44m%c\x1B[0m ", v25);
}
LABEL_30:
v26 = 1;
printf("/ 9\n B \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 56LL));
while ( v26 <= 5 )
{
while ( 1 )
{
v27 = v26;
v28 = v26++;
v29 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 56LL) + v28);
if ( (v27 & 1) != 0 )
break;
printf("%c ", v29);
if ( v26 > 5 )
goto LABEL_34;
}
printf("\x1B[44m%c\x1B[0m ", v29);
}
LABEL_34:
v30 = 1;
printf("/ \x1B[44m8\x1B[0m\n A \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 64LL));
while ( v30 <= 4 )
{
while ( 1 )
{
v31 = v30;
v32 = v30++;
v33 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 64LL) + v32);
if ( (v31 & 1) != 0 )
break;
printf("%c ", v33);
if ( v30 > 4 )
return puts("/ 7\n ----------- \x1B[44m6\x1B[0m\n 1 \x1B[44m2\x1B[0m 3 \x1B[44m4\x1B[0m 5");
}
printf("\x1B[44m%c\x1B[0m ", v33);
}
return puts("/ 7\n ----------- \x1B[44m6\x1B[0m\n 1 \x1B[44m2\x1B[0m 3 \x1B[44m4\x1B[0m 5");
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
int v1; // ebp
__int64 v2; // rax
char v3; // dl
__int64 v4; // r12
int v5; // ebp
char v6; // dl
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // r12
char v10; // dl
__int64 v11; // rax
__int64 v12; // rsi
char v13; // dl
int v14; // ebp
char v15; // dl
__int64 v16; // rax
__int64 v17; // rsi
int v18; // ebp
char v19; // dl
__int64 v20; // rax
__int64 v21; // rsi
int v22; // ebp
char v23; // dl
__int64 v24; // rax
__int64 v25; // rsi
int v26; // ebp
char v27; // dl
__int64 v28; // rax
__int64 v29; // rsi
int v30; // ebp
char v31; // al
__int64 v32; // rdx
__int64 v33; // rsi

v1 = 1;
printf(" -----------\n I / ");
v2 = 0LL;
while ( 1 )
{
printf("%c ", (unsigned int)*(char *)(**(_QWORD **)a1 + v2));
v2 = v1;
if ( v1 > 4 )
break;
while ( 1 )
{
v3 = v1;
v4 = v2 + 1;
++v1;
if ( (v3 & 1) == 0 )
break;
printf("\x1B[44m%c\x1B[0m ", (unsigned int)*(char *)(**(_QWORD **)a1 + v2));
v2 = v4;
if ( v1 > 4 )
goto LABEL_5;
}
}
LABEL_5:
v5 = 1;
printf("\\ \n H / ");
printf("\x1B[44m%c\x1B[0m ", (unsigned int)**(char **)(*(_QWORD *)a1 + 8LL));
while ( 1 )
{
LABEL_6:
if ( v5 > 5 )
{
v5 = 1;
printf("\\ \n G / ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 16LL));
LABEL_11:
while ( v5 <= 6 )
{
while ( 1 )
{
v10 = v5;
v11 = v5++;
v12 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 16LL) + v11);
if ( (v10 & 1) != 0 )
break;
printf("%c ", v12);
if ( v5 > 6 )
goto LABEL_14;
}
printf("\x1B[44m%c\x1B[0m ", v12);
}
LABEL_14:
v5 = 1;
printf(asc_EB0);
printf("\x1B[44m%c\x1B[0m ", (unsigned int)**(char **)(*(_QWORD *)a1 + 24LL));
goto LABEL_15;
}
v6 = v5;
v7 = v5++;
if ( (v6 & 1) == 0 )
break;
printf("%c ", (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL) + v7));
}
v8 = 8LL;
v9 = 1LL;
LABEL_9:
printf("\x1B[44m%c\x1B[0m ", (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + v8) + v7));
switch ( v9 )
{
case 0LL:
case 1LL:
goto LABEL_6;
case 2LL:
goto LABEL_11;
case 3LL:
break;
}
LABEL_15:
while ( v5 <= 7 )
{
v13 = v5;
v7 = v5++;
if ( (v13 & 1) == 0 )
{
v8 = 24LL;
v9 = 3LL;
goto LABEL_9;
}
printf("%c ", (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 24LL) + v7));
}
v14 = 1;
printf(asc_EBA);
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 32LL));
while ( v14 <= 8 )
{
while ( 1 )
{
v15 = v14;
v16 = v14++;
v17 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 32LL) + v16);
if ( (v15 & 1) != 0 )
break;
printf("%c ", v17);
if ( v14 > 8 )
goto LABEL_22;
}
printf("\x1B[44m%c\x1B[0m ", v17);
}
LABEL_22:
v18 = 1;
printf("| \n D \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 40LL));
while ( v18 <= 7 )
{
while ( 1 )
{
v19 = v18;
v20 = v18++;
v21 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 40LL) + v20);
if ( (v19 & 1) != 0 )
break;
printf("%c ", v21);
if ( v18 > 7 )
goto LABEL_26;
}
printf("\x1B[44m%c\x1B[0m ", v21);
}
LABEL_26:
v22 = 1;
printf("/ \n C \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 48LL));
while ( v22 <= 6 )
{
while ( 1 )
{
v23 = v22;
v24 = v22++;
v25 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 48LL) + v24);
if ( (v23 & 1) != 0 )
break;
printf("%c ", v25);
if ( v22 > 6 )
goto LABEL_30;
}
printf("\x1B[44m%c\x1B[0m ", v25);
}
LABEL_30:
v26 = 1;
printf("/ 9\n B \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 56LL));
while ( v26 <= 5 )
{
while ( 1 )
{
v27 = v26;
v28 = v26++;
v29 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 56LL) + v28);
if ( (v27 & 1) != 0 )
break;
printf("%c ", v29);
if ( v26 > 5 )
goto LABEL_34;
}
printf("\x1B[44m%c\x1B[0m ", v29);
}
LABEL_34:
v30 = 1;
printf("/ \x1B[44m8\x1B[0m\n A \\ ");
printf("%c ", (unsigned int)**(char **)(*(_QWORD *)a1 + 64LL));
while ( v30 <= 4 )
{
while ( 1 )
{
v31 = v30;
v32 = v30++;
v33 = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)a1 + 64LL) + v32);
if ( (v31 & 1) != 0 )
break;
printf("%c ", v33);
if ( v30 > 4 )
return puts("/ 7\n ----------- \x1B[44m6\x1B[0m\n 1 \x1B[44m2\x1B[0m 3 \x1B[44m4\x1B[0m 5");
}
printf("\x1B[44m%c\x1B[0m ", v33);
}
return puts("/ 7\n ----------- \x1B[44m6\x1B[0m\n 1 \x1B[44m2\x1B[0m 3 \x1B[44m4\x1B[0m 5");
}

original_code:
void affichagePlateau(Plateau *p){
 int j =0, i = 0;
 int modulo = 0;
 printf("       -----------\n    I / ");
 while (i < 9 ){
  if (modulo == 1){
   printf("\033[44m%c\033[0m ", p->tableau[i][j]);
  }
  else printf("%c ", p->tableau[i][j]);
        j++;
         switch (i){
    case 0:
     if (j >= 5 ){
      i++;
                   j =0;
                   printf("\\ \n   H / ");
                   if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 1:
     if (j >= 6 ){
      i++;
                  j =0;
                 printf("\\ \n  G / ");
                 if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 2:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("\\ \n F / ");
                  if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 3:
     if (j >= 8 ){
      i++;
                  j =0;
                  printf("\\ \nE | ");
                  if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     break;
    case 4:
     if (j >= 9 ){
      i++;
                  j =0;
                  printf("| \n D \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 5:
     if (j >=8 ){
      i++;
                  j =0;
                  printf("/ \n  C \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 6:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("/ 9\n   B \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 7:
     if (j >= 6 ){
      i++;
                  j =0;
                  printf("/ \033[44m8\033[0m\n    A \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 8:
     if (j >= 5 ){
      i++;
                  j =0;
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
   }
    }
 printf("/ 7\n       ----------- \033[44m6\033[0m\n          1 \033[44m2\033[0m 3 \033[44m4\033[0m 5\n");
}

canonical_original_code:
void affichagePlateau(struct Plateau *p){
 int j = 0; int i = 0;
 int modulo = 0;
 printf("       -----------\n    I / ");
 while (i < 9 ){
  if (modulo == 1){
   printf("\033[44m%c\033[0m ", p->tableau[i][j]);
  }
  else printf("%c ", p->tableau[i][j]);
        j++;
         switch (i){
    case 0:
     if (j >= 5 ){
      i++;
                   j =0;
                   printf("\\ \n   H / ");
                   if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 1:
     if (j >= 6 ){
      i++;
                  j =0;
                 printf("\\ \n  G / ");
                 if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 2:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("\\ \n F / ");
                  if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 3:
     if (j >= 8 ){
      i++;
                  j =0;
                  printf("\\ \nE | ");
                  if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     break;
    case 4:
     if (j >= 9 ){
      i++;
                  j =0;
                  printf("| \n D \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 5:
     if (j >=8 ){
      i++;
                  j =0;
                  printf("/ \n  C \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 6:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("/ 9\n   B \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 7:
     if (j >= 6 ){
      i++;
                  j =0;
                  printf("/ \033[44m8\033[0m\n    A \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 8:
     if (j >= 5 ){
      i++;
                  j =0;
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
   }
    }
 printf("/ 7\n       ----------- \033[44m6\033[0m\n          1 \033[44m2\033[0m 3 \033[44m4\033[0m 5\n");
}

variable_types: i int

variable_types: modulo int


affichagePlateauColor

original_code:
void affichagePlateauColor(Plateau *p, int pionX, int pionY){
  int j =0, i = 0;
 int modulo = 0;
 printf("       -----------\n    I / ");
 while (i < 9 ){
  if (modulo == 1 && !(pionX == i && pionY == j)){
   printf("\033[44m%c\033[0m ", p->tableau[i][j]);
  }
  else if (pionX == i && pionY == j){
   printf("\033[42m%c\033[0m ", p->tableau[i][j]);
  }
  else printf("%c ", p->tableau[i][j]);
        j++;
         switch (i){
    case 0:
     if (j >= 5 ){
      i++;
                   j =0;
                   printf("\\ \n   H / ");
                   if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 1:
     if (j >= 6 ){
      i++;
                  j =0;
                 printf("\\ \n  G / ");
                 if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 2:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("\\ \n F / ");
                  if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 3:
     if (j >= 8 ){
      i++;
                  j =0;
                  printf("\\ \nE | ");
                  if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     break;
    case 4:
     if (j >= 9 ){
      i++;
                  j =0;
                  printf("| \n D \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 5:
     if (j >=8 ){
      i++;
                  j =0;
                  printf("/ \n  C \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 6:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("/ 9\n   B \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 7:
     if (j >= 6 ){
      i++;
                  j =0;
                  printf("/ \033[44m8\033[0m\n    A \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 8:
     if (j >= 5 ){
      i++;
                  j =0;
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
   }
    }
 printf("/ 7\n       ----------- \033[44m6\033[0m\n          1 \033[44m2\033[0m 3 \033[44m4\033[0m 5\n");
}

canonical_original_code:
void affichagePlateauColor(struct Plateau *p, int pionX, int pionY){
  int j = 0; int i = 0;
 int modulo = 0;
 printf("       -----------\n    I / ");
 while (i < 9 ){
  if (modulo == 1 && !(pionX == i && pionY == j)){
   printf("\033[44m%c\033[0m ", p->tableau[i][j]);
  }
  else if (pionX == i && pionY == j){
   printf("\033[42m%c\033[0m ", p->tableau[i][j]);
  }
  else printf("%c ", p->tableau[i][j]);
        j++;
         switch (i){
    case 0:
     if (j >= 5 ){
      i++;
                   j =0;
                   printf("\\ \n   H / ");
                   if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 1:
     if (j >= 6 ){
      i++;
                  j =0;
                 printf("\\ \n  G / ");
                 if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 2:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("\\ \n F / ");
                  if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 0) modulo = 0;
                  else modulo = 1;
                 }
     break;
    case 3:
     if (j >= 8 ){
      i++;
                  j =0;
                  printf("\\ \nE | ");
                  if(j%2 == 0) modulo = 0;
                  else modulo = 1;
     }
     else{
      if(j%2 == 1) modulo = 0;
                  else modulo = 1;
     }
     break;
    case 4:
     if (j >= 9 ){
      i++;
                  j =0;
                  printf("| \n D \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 5:
     if (j >=8 ){
      i++;
                  j =0;
                  printf("/ \n  C \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 6:
     if (j >= 7 ){
      i++;
                  j =0;
                  printf("/ 9\n   B \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 7:
     if (j >= 6 ){
      i++;
                  j =0;
                  printf("/ \033[44m8\033[0m\n    A \\ ");
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
    case 8:
     if (j >= 5 ){
      i++;
                  j =0;
     }
     if(j%2 == 0) modulo = 0;
                 else modulo = 1;
     break;
   }
    }
 printf("/ 7\n       ----------- \033[44m6\033[0m\n          1 \033[44m2\033[0m 3 \033[44m4\033[0m 5\n");
}

variable_types: pionX int

variable_types: pionY int


optionGlobales

original_code:
int optionGlobales(char const *option[], int nbArgs, Plateau *p){
  int i;
  for(i = 1; i<nbArgs; i++){
   if((strcmp(option[i],"-N")==0)){
    if((i+1) == nbArgs){
     printf("Argument obligatoire : N\n");
     return 1;
    }
    if ((strcmp("IA",option[i+1])==0)||(strcmp("ia",option[i+1])==0)||(strcmp("robot",option[i+1])==0)){
     p->typeNoir = 1;
    }
    else if((strcmp("human",option[i+1])==0)||(strcmp("h",option[i+1])==0)||(strcmp("H",option[i+1])==0)|| (strcmp("Humain",option[i+1])==0)){
     p->typeNoir = 2;
    }
    else {
     printf("erreur N : \n");
     return 1;
    }
   }
   else if((strcmp(option[i],"-B")==0)){
    if((i+1) == nbArgs){
     printf("Argument obligatoire : B\n");
     return 1;
    }
    if ((strcmp("IA",option[i+1])==0)||(strcmp("ia",option[i+1])==0)||(strcmp("robot",option[i+1])==0)){
     p->typeBlanc = 1;
    }
    else if((strcmp("human",option[i+1])==0)||(strcmp("h",option[i+1])==0)||(strcmp("H",option[i+1])==0)|| (strcmp("Humain",option[i+1])==0)){
     p->typeBlanc = 2;
    }
    else {
     printf("erreur B : \n");
     return 1;
    }
   }
   else if((strcmp(option[i],"-c")==0)){
    if((i+1) == nbArgs){
     printf("Argument obligatoire : C\n");
     return 1;
    }
    else {
     if(fichierConfig(option[i+1], p) != 0) {
      printf("ERREUR fichier config option.c\n");
      exit(-1);
     }
    }
   }
   else if ((strcmp(option[i],"-t")==0)){
    if( nbArgs != 2){
     printf("l'Option -t ne prend ni argument ni autre option\n");
     return 1;
    }
    else{
     return 2;
    }
   }
  }
  return 0;
}

canonical_original_code:
int optionGlobales(char *option[], int nbArgs, struct Plateau *p){
  int i;
  for(i = 1; i<nbArgs; i++){
   if((strcmp(option[i],"-N")==0)){
    if((i+1) == nbArgs){
     printf("Argument obligatoire : N\n");
     return 1;
    }
    if ((strcmp("IA",option[i+1])==0)||(strcmp("ia",option[i+1])==0)||(strcmp("robot",option[i+1])==0)){
     p->typeNoir = 1;
    }
    else if((strcmp("human",option[i+1])==0)||(strcmp("h",option[i+1])==0)||(strcmp("H",option[i+1])==0)|| (strcmp("Humain",option[i+1])==0)){
     p->typeNoir = 2;
    }
    else {
     printf("erreur N : \n");
     return 1;
    }
   }
   else if((strcmp(option[i],"-B")==0)){
    if((i+1) == nbArgs){
     printf("Argument obligatoire : B\n");
     return 1;
    }
    if ((strcmp("IA",option[i+1])==0)||(strcmp("ia",option[i+1])==0)||(strcmp("robot",option[i+1])==0)){
     p->typeBlanc = 1;
    }
    else if((strcmp("human",option[i+1])==0)||(strcmp("h",option[i+1])==0)||(strcmp("H",option[i+1])==0)|| (strcmp("Humain",option[i+1])==0)){
     p->typeBlanc = 2;
    }
    else {
     printf("erreur B : \n");
     return 1;
    }
   }
   else if((strcmp(option[i],"-c")==0)){
    if((i+1) == nbArgs){
     printf("Argument obligatoire : C\n");
     return 1;
    }
    else {
     if(fichierConfig(option[i+1], p) != 0) {
      printf("ERREUR fichier config option.c\n");
      exit(-1);
     }
    }
   }
   else if ((strcmp(option[i],"-t")==0)){
    if( nbArgs != 2){
     printf("l'Option -t ne prend ni argument ni autre option\n");
     return 1;
    }
    else{
     return 2;
    }
   }
  }
  return 0;
}

variable_types:
option
char *[]

variable_types: nbArgs int


IA

original_code:
void IA(Plateau *p, char couleur){
 int i,j,k;
 int * caseSui;
 for(i = 0; i < 9; i++){
        for (j = 0; j < strlen(p->tableau[i]);j++){
         if (p->tableau[i][j]==couleur){
          for (k = 0; k < 6; k++){
           int **coor = malloc(sizeof(int)*3);
           coor[0] = malloc(sizeof(int)*1);
           coor[1] = malloc(sizeof(int)*2);
           coor[2] = malloc(sizeof(int)*2);
           coor[0][0] = 2;
           coor[1][0] = i;
           coor[1][1] = j;
           caseSui = caseSuivant(p,coor[1], k);
           if(caseSui != ((void *)0)){
            coor[2] = caseSui;
            deplacement(p, coor,couleur, 1);
           }
          }
         }
        }
    }
}

canonical_original_code:
void IA(struct Plateau *p, char couleur){
 int i; int j; int k;
 int *caseSui;
 for(i = 0; i < 9; i++){
        for (j = 0; j < strlen(p->tableau[i]);j++){
         if (p->tableau[i][j]==couleur){
          for (k = 0; k < 6; k++){
           int **coor = malloc(sizeof(int)*3);
           coor[0] = malloc(sizeof(int)*1);
           coor[1] = malloc(sizeof(int)*2);
           coor[2] = malloc(sizeof(int)*2);
           coor[0][0] = 2;
           coor[1][0] = i;
           coor[1][1] = j;
           caseSui = caseSuivant(p,coor[1], k);
           if(caseSui != ((void *)0)){
            coor[2] = caseSui;
            deplacement(p, coor,couleur, 1);
           }
          }
         }
        }
    }
}

variable_types: couleur char

variable_types: k int

variable_types:
caseSui
int *

variable_types:
coor
int **


play

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

v2 = malloc(0x50uLL);
tailleDeplacement = 0;
coupsPossibles = v2;
tailleListe = 10;
IA(a2, a1);
return *((_QWORD *)coupsPossibles + rand() % tailleDeplacement);
}

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

v2 = malloc(0x50uLL);
tailleDeplacement = 0;
coupsPossibles = v2;
tailleListe = 10;
func0(a2, a1);
return *((_QWORD *)coupsPossibles + rand() % tailleDeplacement);
}

original_code:
int ** play(char color,Plateau *p){
 int **coorRandom;
 int r;
 coupsPossibles = malloc(sizeof(int**)*10);
 tailleDeplacement=0;
 tailleListe = 10;
 IA(p,color);
 r = rand()%(tailleDeplacement-0) +0;
    coorRandom = coupsPossibles[r];
    return coorRandom;
}

canonical_original_code:
int **play(char color, struct Plateau *p){
 int **coorRandom;
 int r;
 coupsPossibles = malloc(sizeof(int **)*10);
 tailleDeplacement=0;
 tailleListe = 10;
 IA(p,color);
 r = rand()%(tailleDeplacement-0) +0;
    coorRandom = coupsPossibles[r];
    return coorRandom;
}

variable_types: color char

variable_types: struct Plateau { char **tableau; int billesBlachesperdues; int billesNoiresperdues; char JoueurSuivant; int typeBlanc; int typeNoir; } *

variable_types:
coorRandom
int **

variable_types: r int

return_type: int **