main

repo: vivien/blink

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // eax
int result; // eax
const char **v6; // rbx
__int64 v7; // rsi
const char *v8; // rdx
const char **v9; // rbx
const char *v10; // rdi
int v11; // ebp
int v12; // ebx
const char *v13; // r14
__int64 v14; // r12
int v15; // ebx
char *v16; // rax
int v17; // ecx
char v18; // si
char v19; // dl
unsigned int v20; // eax
int v21; // eax
int v22; // eax
int v23; // ebx
int v24; // eax
int v25; // ebx
int v26; // eax
__int64 buf; // [rsp+7h] [rbp-31h] BYREF
char v28; // [rsp+Fh] [rbp-29h]

buf = 1LL;
v28 = 0;
v4 = getopt(argc, (char *const *)argv, "hc");
switch ( v4 )
{
case -1:
v11 = _bss_start;
v12 = argc - _bss_start;
if ( argc == _bss_start || (v13 = argv[_bss_start], v14 = _bss_start, strlen(v13) != 1) )
{
fwrite("Put colors! Try 'blink -h' for more information.\n", 1uLL, 0x31uLL, stderr);
return 1;
}
v15 = v12 - 1;
v16 = (char *)&unk_402444;
v17 = 0;
_bss_start = v11 + 1;
v18 = *v13;
v19 = 99;
BYTE1(buf) = *v13;
do
{
if ( v18 == v19 && *(_DWORD *)v16 != v15 )
{
fprintf(stderr, "%s\n%s\n", (&off_402450)[3 * v17], off_402448[3 * v17]);
return 1;
}
v19 = v16[20];
v16 += 24;
++v17;
}
while ( v19 );
if ( v18 == 99 )
goto LABEL_25;
if ( v18 > 99 )
{
if ( v18 == 110 )
goto LABEL_27;
if ( v18 == 112 )
{
v23 = atoi(argv[v14 + 1]);
v24 = atoi(argv[v14 + 2]);
BYTE2(buf) = v23 != 0;
if ( v24 > 11 )
v24 = 11;
if ( v24 < 0 )
LOBYTE(v24) = 0;
BYTE3(buf) = v24;
return write(1, &buf, 9uLL) != 9;
}
}
else
{
if ( v18 == 68 )
{
v25 = atoi(argv[v14 + 1]);
v26 = parse_duration(argv[v14 + 2]);
if ( v26 >= 0 )
{
BYTE2(buf) = v25 != 0;
*(_WORD *)((char *)&buf + 3) = __ROL2__(v26, 8);
return write(1, &buf, 9uLL) != 9;
}
goto LABEL_41;
}
if ( v18 == 80 )
{
v20 = atoi(argv[v14 + 3]);
if ( v20 > 0xB )
{
fprintf(stderr, "invalid position %d\n", v20);
return 1;
}
HIBYTE(buf) = v20;
LABEL_25:
v21 = parse_duration(argv[v14 + 2]);
if ( v21 >= 0 )
{
*(_WORD *)((char *)&buf + 5) = __ROL2__(v21, 8);
LABEL_27:
v22 = parse_color((char *)argv[_bss_start]);
if ( v22 < 0 )
{
fwrite("invalid color\n", 1uLL, 0xEuLL, stderr);
return 1;
}
*(_WORD *)((char *)&buf + 3) = __ROL2__(v22, 8);
BYTE2(buf) = BYTE2(v22);
return write(1, &buf, 9uLL) != 9;
}
LABEL_41:
fwrite("invalid duration\n", 1uLL, 0x11uLL, stderr);
return 1;
}
}
fprintf(stderr, "unknown command '%c'. Try 'blink -h' for help.\n", (unsigned int)v18);
return 1;
case 99:
v9 = (const char **)&off_4023D0;
v10 = "blue";
do
{
puts(v10);
v10 = *v9;
v9 += 2;
}
while ( v10 );
result = 0;
break;
case 104:
v6 = (const char **)&off_402450;
puts(
"Usage: blink [OPTIONS] COMMAND [FIELD...]\n"
"Options:\n"
"\t-h\tprint this help message\n"
"\t-c\tlist defined colors\n"
"Commands:");
v7 = 99LL;
do
{
v8 = *v6;
v6 += 3;
printf("\t%c\t%s\n", v7, v8);
v7 = (unsigned int)*((char *)v6 - 16);
}
while ( *((_BYTE *)v6 - 16) );
result = 0;
break;
default:
fwrite("Options:\n\t-h\tprint this help message\n\t-c\tlist defined colors\n", 1uLL, 0x3DuLL, stderr);
result = 1;
break;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // eax
int result; // eax
const char **v6; // rbx
__int64 v7; // rsi
const char *v8; // rdx
const char **v9; // rbx
const char *v10; // rdi
int v11; // ebp
int v12; // ebx
const char *v13; // r14
__int64 v14; // r12
int v15; // ebx
char *v16; // rax
int v17; // ecx
char v18; // si
char v19; // dl
unsigned int v20; // eax
int v21; // eax
int v22; // eax
int v23; // ebx
int v24; // eax
int v25; // ebx
int v26; // eax
__int64 buf; // [rsp+7h] [rbp-31h] BYREF
char v28; // [rsp+Fh] [rbp-29h]

buf = 1LL;
v28 = 0;
v4 = getopt(argc, (char *const *)argv, "hc");
switch ( v4 )
{
case -1:
v11 = _bss_start;
v12 = argc - _bss_start;
if ( argc == _bss_start || (v13 = argv[_bss_start], v14 = _bss_start, strlen(v13) != 1) )
{
fwrite("Put colors! Try 'blink -h' for more information.\n", 1uLL, 0x31uLL, stderr);
return 1;
}
v15 = v12 - 1;
v16 = (char *)&unk_402444;
v17 = 0;
_bss_start = v11 + 1;
v18 = *v13;
v19 = 99;
BYTE1(buf) = *v13;
do
{
if ( v18 == v19 && *(_DWORD *)v16 != v15 )
{
fprintf(stderr, "%s\n%s\n", (&off_402450)[3 * v17], off_402448[3 * v17]);
return 1;
}
v19 = v16[20];
v16 += 24;
++v17;
}
while ( v19 );
if ( v18 == 99 )
goto LABEL_25;
if ( v18 > 99 )
{
if ( v18 == 110 )
goto LABEL_27;
if ( v18 == 112 )
{
v23 = atoi(argv[v14 + 1]);
v24 = atoi(argv[v14 + 2]);
BYTE2(buf) = v23 != 0;
if ( v24 > 11 )
v24 = 11;
if ( v24 < 0 )
LOBYTE(v24) = 0;
BYTE3(buf) = v24;
return write(1, &buf, 9uLL) != 9;
}
}
else
{
if ( v18 == 68 )
{
v25 = atoi(argv[v14 + 1]);
v26 = func8(argv[v14 + 2]);
if ( v26 >= 0 )
{
BYTE2(buf) = v25 != 0;
*(_WORD *)((char *)&buf + 3) = __ROL2__(v26, 8);
return write(1, &buf, 9uLL) != 9;
}
goto LABEL_41;
}
if ( v18 == 80 )
{
v20 = atoi(argv[v14 + 3]);
if ( v20 > 0xB )
{
fprintf(stderr, "invalid position %d\n", v20);
return 1;
}
HIBYTE(buf) = v20;
LABEL_25:
v21 = func8(argv[v14 + 2]);
if ( v21 >= 0 )
{
*(_WORD *)((char *)&buf + 5) = __ROL2__(v21, 8);
LABEL_27:
v22 = func7((char *)argv[_bss_start]);
if ( v22 < 0 )
{
fwrite("invalid color\n", 1uLL, 0xEuLL, stderr);
return 1;
}
*(_WORD *)((char *)&buf + 3) = __ROL2__(v22, 8);
BYTE2(buf) = BYTE2(v22);
return write(1, &buf, 9uLL) != 9;
}
LABEL_41:
fwrite("invalid duration\n", 1uLL, 0x11uLL, stderr);
return 1;
}
}
fprintf(stderr, "unknown command '%c'. Try 'blink -h' for help.\n", (unsigned int)v18);
return 1;
case 99:
v9 = (const char **)&off_4023D0;
v10 = "blue";
do
{
puts(v10);
v10 = *v9;
v9 += 2;
}
while ( v10 );
result = 0;
break;
case 104:
v6 = (const char **)&off_402450;
puts(
"Usage: blink [OPTIONS] COMMAND [FIELD...]\n"
"Options:\n"
"\t-h\tprint this help message\n"
"\t-c\tlist defined colors\n"
"Commands:");
v7 = 99LL;
do
{
v8 = *v6;
v6 += 3;
printf("\t%c\t%s\n", v7, v8);
v7 = (unsigned int)*((char *)v6 - 16);
}
while ( *((_BYTE *)v6 - 16) );
result = 0;
break;
default:
fwrite("Options:\n\t-h\tprint this help message\n\t-c\tlist defined colors\n", 1uLL, 0x3DuLL, stderr);
result = 1;
break;
}
return result;
}

original_code:
int
main(int argc, char *argv[]) {
 char buf[9] = { 1, 0, 0, 0, 0, 0, 0, 0, 0 };
 unsigned int argr;
 int rgb, duration, play, position;
 char cmd;
 int i;
 int c;
 while (c = getopt(argc, argv, "hc"), c != -1) {
  switch (c) {
  case 'h':
   printf("Usage: blink [OPTIONS] COMMAND [FIELD...]" "\n" "Options:\n" "\t-h\tprint this help message\n" "\t-c\tlist defined colors" "\nCommands:\n");
   for (i = 0; commands[i].cmd; ++i)
    printf("\t%c\t%s\n", commands[i].cmd,
      commands[i].desc);
   return 0;
  case 'c':
   for (i = 0; colors[i].name; ++i)
    printf("%s\n", colors[i].name);
   return 0;
  default:
   fprintf(stderr, "Options:\n" "\t-h\tprint this help message\n" "\t-c\tlist defined colors" "\n");
   return 1;
  }
 }
 if (argr = argc - optind, argr == 0 || strlen(argv[optind]) != 1) {
  fprintf(stderr, "Put colors! Try 'blink -h' for more information." "\n");
  return 1;
 }
 argr--;
 cmd = *argv[optind++];
 do { } while (0);
 buf[1] = cmd;
 for (i = 0; commands[i].cmd; ++i) {
  if (cmd == commands[i].cmd) {
   if (argr != commands[i].argc) {
    fprintf(stderr, "%s\n%s" "\n", commands[i].desc, commands[i].usage);
    return 1;
   }
  }
 }
 switch (cmd) {
 case 'P':
  position = atoi(argv[optind + 2]);
  if (position < 0 || position > 11) {
   fprintf(stderr, "invalid position %d" "\n", position);
   return 1;
  }
  buf[7] = position;
 case 'c':
  duration = parse_duration(argv[optind + 1]);
  if (duration < 0) {
   fprintf(stderr, "invalid duration" "\n");
   return 1;
  }
  buf[5] = duration >> 8;
  buf[6] = duration & 0xff;
 case 'n':
  rgb = parse_color(argv[optind]);
  if (rgb < 0) {
   fprintf(stderr, "invalid color" "\n");
   return 1;
  }
  buf[2] = ((rgb & 0xFF0000) >> 16);
  buf[3] = ((rgb & 0x00FF00) >> 8);
  buf[4] = ((rgb & 0x0000FF) >> 0);
  break;
 case 'p':
  play = atoi(argv[optind]);
  position = atoi(argv[optind + 1]);
  buf[2] = !!play;
  buf[3] = (((0)) > ((((11)) < ((position)) ? ((11)) : ((position)))) ? ((0)) : ((((11)) < ((position)) ? ((11)) : ((position)))));
  break;
 case 'D':
  play = atoi(argv[optind]);
  duration = parse_duration(argv[optind + 1]);
  if (duration < 0) {
   fprintf(stderr, "invalid duration" "\n");
   return 1;
  }
  buf[2] = !!play;
  buf[3] = duration >> 8;
  buf[4] = duration & 0xff;
  break;
 default:
  fprintf(stderr, "unknown command '%c'. Try 'blink -h' for help." "\n", cmd);
  return 1;
 }
 do { } while (0);
 return write(1, buf, 9) != 9 ? 1 : 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 char buf[9] = { 1, 0, 0, 0, 0, 0, 0, 0, 0 };
 unsigned int argr;
 int rgb; int duration; int play; int position;
 char cmd;
 int i;
 int c;
 while (c = getopt(argc, argv, "hc"), c != -1) {
  switch (c) {
  case 'h':
   printf("Usage: blink [OPTIONS] COMMAND [FIELD...]" "\n" "Options:\n" "\t-h\tprint this help message\n" "\t-c\tlist defined colors" "\nCommands:\n");
   for (i = 0; commands[i].cmd; ++i)
    printf("\t%c\t%s\n", commands[i].cmd,
      commands[i].desc);
   return 0;
  case 'c':
   for (i = 0; colors[i].name; ++i)
    printf("%s\n", colors[i].name);
   return 0;
  default:
   fprintf(stderr, "Options:\n" "\t-h\tprint this help message\n" "\t-c\tlist defined colors" "\n");
   return 1;
  }
 }
 if (argr = argc - optind, argr == 0 || strlen(argv[optind]) != 1) {
  fprintf(stderr, "Put colors! Try 'blink -h' for more information." "\n");
  return 1;
 }
 argr--;
 cmd = *argv[optind++];
 do { } while (0);
 buf[1] = cmd;
 for (i = 0; commands[i].cmd; ++i) {
  if (cmd == commands[i].cmd) {
   if (argr != commands[i].argc) {
    fprintf(stderr, "%s\n%s" "\n", commands[i].desc, commands[i].usage);
    return 1;
   }
  }
 }
 switch (cmd) {
 case 'P':
  position = atoi(argv[optind + 2]);
  if (position < 0 || position > 11) {
   fprintf(stderr, "invalid position %d" "\n", position);
   return 1;
  }
  buf[7] = position;
 case 'c':
  duration = parse_duration(argv[optind + 1]);
  if (duration < 0) {
   fprintf(stderr, "invalid duration" "\n");
   return 1;
  }
  buf[5] = duration >> 8;
  buf[6] = duration & 0xff;
 case 'n':
  rgb = parse_color(argv[optind]);
  if (rgb < 0) {
   fprintf(stderr, "invalid color" "\n");
   return 1;
  }
  buf[2] = ((rgb & 0xFF0000) >> 16);
  buf[3] = ((rgb & 0x00FF00) >> 8);
  buf[4] = ((rgb & 0x0000FF) >> 0);
  break;
 case 'p':
  play = atoi(argv[optind]);
  position = atoi(argv[optind + 1]);
  buf[2] = !!play;
  buf[3] = (((0)) > ((((11)) < ((position)) ? ((11)) : ((position)))) ? ((0)) : ((((11)) < ((position)) ? ((11)) : ((position)))));
  break;
 case 'D':
  play = atoi(argv[optind]);
  duration = parse_duration(argv[optind + 1]);
  if (duration < 0) {
   fprintf(stderr, "invalid duration" "\n");
   return 1;
  }
  buf[2] = !!play;
  buf[3] = duration >> 8;
  buf[4] = duration & 0xff;
  break;
 default:
  fprintf(stderr, "unknown command '%c'. Try 'blink -h' for help." "\n", cmd);
  return 1;
 }
 do { } while (0);
 return write(1, buf, 9) != 9 ? 1 : 0;
}

variable_types: argc int

variable_types:
buf
char [9]

variable_types:
argr
unsigned int

variable_types: rgb int

variable_types: duration int

variable_types: play int

variable_types: position int

variable_types: cmd char

variable_types: c int


decompiled_code:
unsigned __int64 __fastcall parse_color(char *nptr)
{
const char *v2; // rdi
__int64 v3; // rbx
unsigned __int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v2 = "blue";
v3 = 0LL;
do
{
if ( !strcmp(v2, nptr) )
return (unsigned int)dword_4023C8[4 * (int)v3];
++v3;
v2 = (&colors)[2 * v3];
}
while ( v2 );
result = strtoul(nptr, &endptr, 16);
if ( result > 0xFFFFFF || !*nptr )
return 0xFFFFFFFFLL;
if ( *endptr )
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(char *nptr)
{
const char *v2; // rdi
__int64 v3; // rbx
unsigned __int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v2 = "blue";
v3 = 0LL;
do
{
if ( !strcmp(v2, nptr) )
return (unsigned int)dword_4023C8[4 * (int)v3];
++v3;
v2 = (&colors)[2 * v3];
}
while ( v2 );
result = strtoul(nptr, &endptr, 16);
if ( result > 0xFFFFFF || !*nptr )
return 0xFFFFFFFFLL;
if ( *endptr )
result = 0xFFFFFFFFLL;
return result;
}

original_code:
static int
parse_color(const char *color)
{
 unsigned long int value;
 char *end;
 int i;
 for (i = 0; colors[i].name; ++i) {
  if (strcmp(colors[i].name, color) == 0) {
   do { } while (0);
   return colors[i].value;
  }
 }
 value = strtoul(color, &end, 16);
 if (value > 0xFFFFFF)
  return -1;
 if (*color != '\0' && *end == '\0')
  return value;
 return -1;
}

canonical_original_code:
static int parse_color(char *color)
{
 unsigned long value;
 char *end;
 int i;
 for (i = 0; colors[i].name; ++i) {
  if (strcmp(colors[i].name, color) == 0) {
   do { } while (0);
   return colors[i].value;
  }
 }
 value = strtoul(color, &end, 16);
 if (value > 0xFFFFFF)
  return -1;
 if (*color != '\0' && *end == '\0')
  return value;
 return -1;
}

variable_types:
color
char *

variable_types:
value
unsigned long

variable_types:
end
char *

variable_types: i int

return_type: int


decompiled_code:
__int64 __fastcall parse_duration(const char *a1)
{
float v1; // xmm0_4
float v2; // xmm0_4
__int64 result; // rax
float v4; // [rsp+Ch] [rbp-1Ch]
char *endptr; // [rsp+18h] [rbp-10h] BYREF

v1 = strtof(a1, &endptr);
if ( *a1 && !*endptr )
{
result = (unsigned int)(int)v1;
if ( (int)result > 0xFFFF )
result = 0xFFFFLL;
if ( (int)result < 0 )
result = 0xFFFFFFFFLL;
}
else
{
if ( *endptr == 115 && !endptr[1] )
{
v2 = v1 * 100.0;
result = 0xFFFFLL;
if ( v2 > 65535.0 )
return result;
goto LABEL_6;
}
v4 = v1;
if ( strcmp(endptr, "ms") )
return 0xFFFFFFFFLL;
v2 = v1 / 10.0;
result = 0xFFFFLL;
if ( (float)(v4 / 10.0) <= 65535.0 )
{
LABEL_6:
result = 0xFFFFFFFFLL;
if ( v2 >= -1.0 )
result = (unsigned int)(int)v2;
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
float v1; // xmm0_4
float v2; // xmm0_4
__int64 result; // rax
float v4; // [rsp+Ch] [rbp-1Ch]
char *endptr; // [rsp+18h] [rbp-10h] BYREF

v1 = strtof(a1, &endptr);
if ( *a1 && !*endptr )
{
result = (unsigned int)(int)v1;
if ( (int)result > 0xFFFF )
result = 0xFFFFLL;
if ( (int)result < 0 )
result = 0xFFFFFFFFLL;
}
else
{
if ( *endptr == 115 && !endptr[1] )
{
v2 = v1 * 100.0;
result = 0xFFFFLL;
if ( v2 > 65535.0 )
return result;
goto LABEL_6;
}
v4 = v1;
if ( strcmp(endptr, "ms") )
return 0xFFFFFFFFLL;
v2 = v1 / 10.0;
result = 0xFFFFLL;
if ( (float)(v4 / 10.0) <= 65535.0 )
{
LABEL_6:
result = 0xFFFFFFFFLL;
if ( v2 >= -1.0 )
result = (unsigned int)(int)v2;
return result;
}
}
return result;
}

variable_types:
duration
char *

variable_types: value float


repo: vladak/aclcheck

decompiled_code:
size_t __fastcall print_usage(const char *a1)
{
fprintf(stdout, "usage: %s [-v] <aclfile>\n", a1);
return fwrite("-v\tdebug flag, can be multiplied\n", 1uLL, 0x21uLL, stdout);
}

canonical_decompiled_code:
size_t __fastcall func0(const char *a1)
{
fprintf(stdout, "usage: %s [-v] <aclfile>\n", a1);
return fwrite("-v\tdebug flag, can be multiplied\n", 1uLL, 0x21uLL, stdout);
}

original_code:
void print_usage(char *progname) {
    fprintf(stdout, "usage: %s [-v] <aclfile>\n", progname);
    fprintf(stdout, "-v\tdebug flag, can be multiplied\n");
}

variable_types:
progname
char *

return_type: void


canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r12
int v4; // eax

v3 = *argv;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "v");
if ( v4 == -1 )
break;
if ( v4 != 118 )
goto LABEL_8;
++debug_level;
}
if ( argc - optind != 1 )
{
LABEL_8:
print_usage(v3);
exit(1);
}
if ( !(unsigned int)load_config(argv[optind]) )
{
debug(0xFFFFFFFFLL, "aclcheck", "cannot parse config file");
exit(1);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r12
int v4; // eax

v3 = *argv;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "v");
if ( v4 == -1 )
break;
if ( v4 != 118 )
goto LABEL_8;
++debug_level;
}
if ( argc - optind != 1 )
{
LABEL_8:
func0(v3);
exit(1);
}
if ( !(unsigned int)load_config(argv[optind]) )
{
debug(0xFFFFFFFFLL, "aclcheck", "cannot parse config file");
exit(1);
}
return 0;
}

original_code:
int main(int argc, char**argv){
  int ch;
  char *progname;
  extern int optind;
  progname = argv[0];
  while ((ch = getopt(argc, argv, "v")) != -1) {
    switch (ch) {
      case 'v':
        debug_level++;
        break;
      default:
 print_usage(progname);
 exit(1);
    }
  }
  argc -= optind;
  argv += optind;
  if (argc != 1){
    print_usage(progname);
    exit(1);
  }
  if (!(load_config(argv[0]))) {
    debug(ERROR, "aclcheck", "cannot parse config file");
    exit(1);
  }
  return(0);
}

canonical_original_code:
int main(int argc, char **argv){
  int ch;
  char *progname;
  extern int optind;
  progname = argv[0];
  while ((ch = getopt(argc, argv, "v")) != -1) {
    switch (ch) {
      case 'v':
        debug_level++;
        break;
      default:
 print_usage(progname);
 exit(1);
    }
  }
  argc -= optind;
  argv += optind;
  if (argc != 1){
    print_usage(progname);
    exit(1);
  }
  if (!(load_config(argv[0]))) {
    debug(ERROR, "aclcheck", "cannot parse config file");
    exit(1);
  }
  return(0);
}

variable_types:
argv
char **

variable_types: ch int

variable_types: optind int


decompiled_code:
_BOOL8 __fastcall valid_portnr(unsigned int a1)
{
return a1 <= 0xFFFF;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned int a1)
{
return a1 <= 0xFFFF;
}

original_code:
int valid_portnr(int portnr) {
  if ((portnr >= 0) && (portnr <= 65535))
    return(1);
  return(0);
}

variable_types: portnr int


decompiled_code:
__int64 __fastcall valid_ipaddr(int a1, const char *a2, unsigned int a3)
{
int v4; // eax
struct addrinfo *v5; // rdi
unsigned int v6; // er12
struct addrinfo *v7; // rax
int v8; // edx
int v10; // eax
char s[5]; // [rsp+3h] [rbp-55h] BYREF
struct addrinfo *pai; // [rsp+8h] [rbp-50h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-48h] BYREF

if ( a3 == -1 )
{
req.ai_family = a1;
*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_next = 0LL;
req.ai_socktype = 1;
req.ai_flags = 1;
*(_OWORD *)&req.ai_addr = 0LL;
v4 = getaddrinfo(a2, 0LL, &req, &pai);
v5 = pai;
v6 = v4;
if ( !v4 )
{
LABEL_3:
if ( v5 )
{
v7 = v5;
v8 = v5->ai_family;
if ( v8 == 2 )
goto LABEL_11;
LABEL_5:
if ( v8 == 10 )
{
if ( a1 == 10 )
return 1;
while ( 1 )
{
v7 = v7->ai_next;
if ( !v7 )
break;
v8 = v7->ai_family;
if ( v8 != 2 )
goto LABEL_5;
LABEL_11:
if ( a1 == 2 )
return 1;
}
}
}
freeaddrinfo(v5);
return v6;
}
}
else
{
snprintf(s, 5uLL, "%d", a3);
req.ai_family = a1;
*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_socktype = 1;
req.ai_next = 0LL;
req.ai_flags = 1;
*(_OWORD *)&req.ai_addr = 0LL;
v10 = getaddrinfo(a2, s, &req, &pai);
v5 = pai;
v6 = v10;
if ( !v10 )
goto LABEL_3;
}
freeaddrinfo(v5);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, const char *a2, unsigned int a3)
{
int v4; // eax
struct addrinfo *v5; // rdi
unsigned int v6; // er12
struct addrinfo *v7; // rax
int v8; // edx
int v10; // eax
char s[5]; // [rsp+3h] [rbp-55h] BYREF
struct addrinfo *pai; // [rsp+8h] [rbp-50h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-48h] BYREF

if ( a3 == -1 )
{
req.ai_family = a1;
*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_next = 0LL;
req.ai_socktype = 1;
req.ai_flags = 1;
*(_OWORD *)&req.ai_addr = 0LL;
v4 = getaddrinfo(a2, 0LL, &req, &pai);
v5 = pai;
v6 = v4;
if ( !v4 )
{
LABEL_3:
if ( v5 )
{
v7 = v5;
v8 = v5->ai_family;
if ( v8 == 2 )
goto LABEL_11;
LABEL_5:
if ( v8 == 10 )
{
if ( a1 == 10 )
return 1;
while ( 1 )
{
v7 = v7->ai_next;
if ( !v7 )
break;
v8 = v7->ai_family;
if ( v8 != 2 )
goto LABEL_5;
LABEL_11:
if ( a1 == 2 )
return 1;
}
}
}
freeaddrinfo(v5);
return v6;
}
}
else
{
snprintf(s, 5uLL, "%d", a3);
req.ai_family = a1;
*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_socktype = 1;
req.ai_next = 0LL;
req.ai_flags = 1;
*(_OWORD *)&req.ai_addr = 0LL;
v10 = getaddrinfo(a2, s, &req, &pai);
v5 = pai;
v6 = v10;
if ( !v10 )
goto LABEL_3;
}
freeaddrinfo(v5);
return 0LL;
}

original_code:
int valid_ipaddr(int pf, char *ipstr, int portnr) {
  struct addrinfo hints, *restmp, *res0;
  char portstr[5];
  int error;
  if (portnr != -1)
    snprintf(portstr, sizeof(portstr), "%d", portnr);
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = pf;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = 0x0001;
  if (portnr == -1)
    error = getaddrinfo(ipstr, ((void *)0), &hints, &res0);
  else
    error = getaddrinfo(ipstr, portstr, &hints, &res0);
  if (error) {
    freeaddrinfo(res0);
    return(0);
  }
  for (restmp = res0; restmp; restmp = restmp->ai_next) {
    switch (restmp->ai_family) {
 case 2:
  if (pf == 2)
    return(1);
  break;
 case 10:
  if (pf == 10)
    return(1);
  break;
 default:
  freeaddrinfo(res0);
  return(0);
    }
  }
  freeaddrinfo(res0);
  return(0);
}

canonical_original_code:
int valid_ipaddr(int pf, char *ipstr, int portnr) {
  struct addrinfo hints; struct addrinfo *restmp; struct addrinfo *res0;
  char portstr[5];
  int error;
  if (portnr != -1)
    snprintf(portstr, sizeof(portstr), "%d", portnr);
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = pf;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = 0x0001;
  if (portnr == -1)
    error = getaddrinfo(ipstr, ((void *)0), &hints, &res0);
  else
    error = getaddrinfo(ipstr, portstr, &hints, &res0);
  if (error) {
    freeaddrinfo(res0);
    return(0);
  }
  for (restmp = res0; restmp; restmp = restmp->ai_next) {
    switch (restmp->ai_family) {
 case 2:
  if (pf == 2)
    return(1);
  break;
 case 10:
  if (pf == 10)
    return(1);
  break;
 default:
  freeaddrinfo(res0);
  return(0);
    }
  }
  freeaddrinfo(res0);
  return(0);
}

variable_types: pf int

variable_types:
ipstr
char *

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

variable_types:
portstr
char [5]

variable_types: error int

user_defined_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }


yyerror

decompiled_code:
__int64 yyerror(char *format, ...)
{
__int64 v1; // rdx
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
errors = 1;
vfprintf(stderr, format, arg);
v1 = lex_line;
if ( !acl_line )
acl_line = lex_line;
if ( state != -1 && lex_line > acl_line )
v1 = acl_line;
fprintf(stderr, " [on line %d]", v1);
if ( state == -1 )
fputc(10, stderr);
else
fprintf(stderr, " (%s ?)\n", &states[40 * state + 40]);
return 0LL;
}

canonical_decompiled_code:
__int64 func2(char *format, ...)
{
__int64 v1; // rdx
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
errors = 1;
vfprintf(stderr, format, arg);
v1 = lex_line;
if ( !acl_line )
acl_line = lex_line;
if ( state != -1 && lex_line > acl_line )
v1 = acl_line;
fprintf(stderr, " [on line %d]", v1);
if ( state == -1 )
fputc(10, stderr);
else
fprintf(stderr, " (%s ?)\n", &states[40 * state + 40]);
return 0LL;
}

original_code:
int yyerror(char *fmt, ...)
{
        va_list ap;
 int line;
        errors = 1;
        __builtin_va_start(ap,fmt);
        vfprintf(stderr, fmt, ap);
 if (acl_line == 0)
   acl_line = lex_line;
 if (state == -1)
   line = lex_line;
 else
   line = lex_line > acl_line ? acl_line : lex_line;
        fprintf(stderr, " [on line %d]", line);
 if (state != -1)
    fprintf(stderr, " (%s ?)\n", states[state + 1]);
 else
   fprintf(stderr, "\n");
        __builtin_va_end(ap);
        return (0);
}

canonical_original_code:
int yyerror(char *fmt, ...)
{
        __builtin_va_list ap;
 int line;
        errors = 1;
        __builtin_va_start(ap,fmt);
        vfprintf(stderr, fmt, ap);
 if (acl_line == 0)
   acl_line = lex_line;
 if (state == -1)
   line = lex_line;
 else
   line = lex_line > acl_line ? acl_line : lex_line;
        fprintf(stderr, " [on line %d]", line);
 if (state != -1)
    fprintf(stderr, " (%s ?)\n", states[state + 1]);
 else
   fprintf(stderr, "\n");
        __builtin_va_end(ap);
        return (0);
}

variable_types:
fmt
char *

variable_types: line int


debug

decompiled_code:
int debug(int a1, const char *a2, const char *a3, ...)
{
int result; // eax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a3);
result = (int)va[0].reg_save_area;
if ( a1 == -2 )
{
debug_print(stderr, a2, va, a3);
exit(1);
}
if ( a1 == -1 )
{
result = debug_level;
if ( debug_level <= 0 )
return result;
return debug_print(stderr, a2, va, a3);
}
if ( debug_level >= a1 )
return debug_print(stderr, a2, va, a3);
return result;
}

canonical_decompiled_code:
int func4(int a1, const char *a2, const char *a3, ...)
{
int result; // eax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a3);
result = (int)va[0].reg_save_area;
if ( a1 == -2 )
{
func3(stderr, a2, va, a3);
exit(1);
}
if ( a1 == -1 )
{
result = debug_level;
if ( debug_level <= 0 )
return result;
return func3(stderr, a2, va, a3);
}
if ( debug_level >= a1 )
return func3(stderr, a2, va, a3);
return result;
}

original_code:
void debug(logprio prio, char *name, const char *fmt, ...){
  va_list ap;
  __builtin_va_start(ap,fmt);
  switch(prio){
        case ERROR:
  if (debug_level > 0)
                  debug_print(stderr, name, ap, fmt);
                break;
        case FATAL:
                debug_print(stderr, name, ap, fmt);
                exit(1);
                break;
        default:
                if ((int)prio <= debug_level){
                  debug_print(stderr, name, ap, fmt);
                }
                break;
  }
  __builtin_va_end(ap);
}

canonical_original_code:
void debug(enum logprio prio, char *name, char *fmt, ...){
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  switch(prio){
        case ERROR:
  if (debug_level > 0)
                  debug_print(stderr, name, ap, fmt);
                break;
        case FATAL:
                debug_print(stderr, name, ap, fmt);
                exit(1);
                break;
        default:
                if ((int)prio <= debug_level){
                  debug_print(stderr, name, ap, fmt);
                }
                break;
  }
  __builtin_va_end(ap);
}

variable_types: enum logprio { INFO=-3, ERROR=-1, FATAL=-2, DEBUG1=1, DEBUG2=2, DEBUG3=3, DEBUG4=4 }

variable_types:
name
char *


decompiled_code:
__int64 check_servname()
{
return 1LL;
}

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

original_code:
int check_servname(char *servname) {
  return(1);
}

variable_types:
servname
char *


repo: vlnk/isima

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

*(_DWORD *)a1 = a2;
*(_DWORD *)(a1 + 4) = -1;
v2 = malloc(8LL * a2);
*(_QWORD *)(a1 + 8) = v2;
return v2 == 0LL;
}

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

*(_DWORD *)a1 = a2;
*(_DWORD *)(a1 + 4) = -1;
v2 = malloc(8LL * a2);
*(_QWORD *)(a1 + 8) = v2;
return v2 == 0LL;
}

original_code:
int init_lifo(lifo_t * p, int t_max)
{
    int err = 1;
    p->t_max = t_max;
    p->taille = -1;
    p->tab = (type_t*)malloc(t_max*sizeof(type_t));
    if (p->tab)
    {
        err = 0;
    }
    return err;
}

canonical_original_code:
int init_lifo(struct lifo *p, int t_max)
{
    int err = 1;
    p->t_max = t_max;
    p->taille = -1;
    p->tab = (char *)malloc(t_max*sizeof(type_t));
    if (p->tab)
    {
        err = 0;
    }
    return err;
}

variable_types: struct lifo { int t_max; int taille; char *tab; } *

variable_types: err int


decompiled_code:
__int64 __fastcall lifo_vide(__int64 a1)
{
return *(_DWORD *)(a1 + 4) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(_DWORD *)(a1 + 4) >> 31;
}

original_code:
int lifo_vide(lifo_t* p)
{
    int ret = 0;
    if (p->taille < 0)
    {
        ret = 1;
    }
    return ret;
}

canonical_original_code:
int lifo_vide(struct lifo *p)
{
    int ret = 0;
    if (p->taille < 0)
    {
        ret = 1;
    }
    return ret;
}

variable_types: ret int

user_defined_types: struct lifo { int t_max; int taille; char *tab; }


depiler

decompiled_code:
__int64 __fastcall depiler(__int64 a1)
{
__int64 v1; // r8

if ( !(unsigned int)lifo_vide(a1) )
v1 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * (int)(*(_DWORD *)(a1 + 4))--);
return v1;
}

original_code:
type_t depiler(lifo_t * p)
{
    type_t val;
    if (!lifo_vide(p))
    {
        val=p->tab[p->taille];
        p->taille--;
    }
    return val;
}

canonical_original_code:
char depiler(struct lifo *p)
{
    char val;
    if (!lifo_vide(p))
    {
        val=p->tab[p->taille];
        p->taille--;
    }
    return val;
}

variable_types: val char

return_type: char


decompiled_code:
_BOOL8 __fastcall lifo_pleine(_DWORD *a1)
{
return a1[1] == *a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(_DWORD *a1)
{
return a1[1] == *a1;
}

original_code:
int lifo_pleine(lifo_t* p)
{
    int ret = 0;
    if (p->taille == p->t_max)
    {
        ret = 1;
    }
    return ret;
}

canonical_original_code:
int lifo_pleine(struct lifo *p)
{
    int ret = 0;
    if (p->taille == p->t_max)
    {
        ret = 1;
    }
    return ret;
}


construction

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

v2 = malloc(0x18uLL);
*a2 = v2;
if ( !v2 )
return 1LL;
*(_BYTE *)v2 = a1;
v2[1] = 0LL;
v2[2] = 0LL;
return 0LL;
}

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

v2 = malloc(0x18uLL);
*a2 = v2;
if ( !v2 )
return 1LL;
*(_BYTE *)v2 = a1;
v2[1] = 0LL;
v2[2] = 0LL;
return 0LL;
}

original_code:
int construction(char val, abr_t ** a)
{
    int err = 1;
    *a = (abr_t *)malloc(sizeof(abr_t));
    if (*a)
    {
        err = 0;
        (*a)->val = val;
        (*a)->fils = ((void *)0);
        (*a)->frere = ((void *)0);
    }
    return err;
}

canonical_original_code:
int construction(char val, struct abr **a)
{
    int err = 1;
    *a = (struct abr *)malloc(sizeof(abr_t));
    if (*a)
    {
        err = 0;
        (*a)->val = val;
        (*a)->fils = ((void *)0);
        (*a)->frere = ((void *)0);
    }
    return err;
}

variable_types: struct abr { char val; struct abr *fils; struct abr *frere; } **


decompiled_code:
__int64 __fastcall lecture_abr(_BYTE *a1, _QWORD *a2)
{
_QWORD *v3; // rbx
void *v4; // r12
unsigned int v5; // eax
unsigned int v6; // er13
char v8; // di
int v9; // er15
int v10; // er14
char v11; // di
__int64 v12; // rax
bool v13; // zf
int i; // [rsp+Ch] [rbp-3Ch]

v3 = a2;
v4 = malloc(0x10uLL);
if ( init_lifo((__int64)v4, 50) )
puts("Erreur : pile non initialisee !");
v5 = verif_chaine(a1);
v6 = v5;
if ( *a1 == 40 )
{
if ( v5 )
goto LABEL_6;
v8 = a1[1];
if ( a1[1] == 41 )
goto LABEL_6;
v9 = 2;
construction(v8, a2);
for ( i = 1; ; ++i )
{
while ( 1 )
{
v10 = v9 + 1;
v11 = a1[v9];
if ( v11 != 41 )
break;
v12 = depiler((__int64)v4);
v13 = i-- == 1;
v3 = (_QWORD *)v12;
if ( v13 )
goto LABEL_6;
LABEL_14:
++v9;
}
if ( v11 == 44 )
goto LABEL_14;
if ( v11 != 40 )
{
v3 = (_QWORD *)(*v3 + 16LL);
construction(v11, v3);
goto LABEL_14;
}
v9 += 2;
empiler((__int64)v4, (__int64)v3);
v3 = (_QWORD *)(*v3 + 8LL);
construction(a1[v10], v3);
}
}
if ( !v5 )
{
v6 = 1;
puts("Parametre incorrect : il manque la 1ere parenthese !");
}
LABEL_6:
free_lifo(v4);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func15(_BYTE *a1, _QWORD *a2)
{
_QWORD *v3; // rbx
void *v4; // r12
unsigned int v5; // eax
unsigned int v6; // er13
char v8; // di
int v9; // er15
int v10; // er14
char v11; // di
__int64 v12; // rax
bool v13; // zf
int i; // [rsp+Ch] [rbp-3Ch]

v3 = a2;
v4 = malloc(0x10uLL);
if ( func8((__int64)v4, 50) )
puts("Erreur : pile non initialisee !");
v5 = func19(a1);
v6 = v5;
if ( *a1 == 40 )
{
if ( v5 )
goto LABEL_6;
v8 = a1[1];
if ( a1[1] == 41 )
goto LABEL_6;
v9 = 2;
func14(v8, a2);
for ( i = 1; ; ++i )
{
while ( 1 )
{
v10 = v9 + 1;
v11 = a1[v9];
if ( v11 != 41 )
break;
v12 = func10((__int64)v4);
v13 = i-- == 1;
v3 = (_QWORD *)v12;
if ( v13 )
goto LABEL_6;
LABEL_14:
++v9;
}
if ( v11 == 44 )
goto LABEL_14;
if ( v11 != 40 )
{
v3 = (_QWORD *)(*v3 + 16LL);
func14(v11, v3);
goto LABEL_14;
}
v9 += 2;
func7((__int64)v4, (__int64)v3);
v3 = (_QWORD *)(*v3 + 8LL);
func14(a1[v10], v3);
}
}
if ( !v5 )
{
v6 = 1;
puts("Parametre incorrect : il manque la 1ere parenthese !");
}
LABEL_6:
func12(v4);
return v6;
}

original_code:
int lecture_abr(char * ch, abr_t ** r)
{
    lifo_t * p = (lifo_t *)malloc(sizeof(lifo_t));
    abr_t ** cour = r;
    int compt = 0;
    int compt_parenthese = 0;
    int err = 0;
    err = init_lifo(p,50);
    if (err)
    {
        printf("Erreur : pile non initialisee !\n");
    }
    err = verif_chaine(ch);
    if (ch[compt] != '(' && ! err)
    {
        printf("Parametre incorrect : il manque la 1ere parenthese !\n");
        err = 1;
    }
    else if (! err)
    {
        compt_parenthese++;
        compt++;
        if (ch[compt] != ')')
        {
            construction(ch[compt],cour);
            compt++;
            *r = *cour;
        }
        else
        {
            cour = ((void *)0);
            compt_parenthese--;
        }
        while ((compt_parenthese > 0) && (! err))
        {
            switch(ch[compt])
            {
                case '(':
                    empiler(p,cour);
                    compt++;
                    compt_parenthese++;
                    cour = &(*cour)->fils;
                    construction(ch[compt],cour);
                    compt++;
                    break;
                case ')':
                    if (compt_parenthese > 0)
                    cour = depiler(p);
                    compt++;
                    compt_parenthese--;
                    break;
                case ',':
                    compt++;
                    break;
                default:
                    cour = &(*cour)->frere;
                    construction(ch[compt],cour);
                    compt++;
            }
        }
    }
    free_lifo(p);
    return err;
}

canonical_original_code:
int lecture_abr(char *ch, struct abr **r)
{
    struct lifo *p = (lifo_t *)malloc(sizeof(lifo_t));
    struct abr **cour = r;
    int compt = 0;
    int compt_parenthese = 0;
    int err = 0;
    err = init_lifo(p,50);
    if (err)
    {
        printf("Erreur : pile non initialisee !\n");
    }
    err = verif_chaine(ch);
    if (ch[compt] != '(' && ! err)
    {
        printf("Parametre incorrect : il manque la 1ere parenthese !\n");
        err = 1;
    }
    else if (! err)
    {
        compt_parenthese++;
        compt++;
        if (ch[compt] != ')')
        {
            construction(ch[compt],cour);
            compt++;
            *r = *cour;
        }
        else
        {
            cour = ((void *)0);
            compt_parenthese--;
        }
        while ((compt_parenthese > 0) && (! err))
        {
            switch(ch[compt])
            {
                case '(':
                    empiler(p,cour);
                    compt++;
                    compt_parenthese++;
                    cour = &(*cour)->fils;
                    construction(ch[compt],cour);
                    compt++;
                    break;
                case ')':
                    if (compt_parenthese > 0)
                    cour = depiler(p);
                    compt++;
                    compt_parenthese--;
                    break;
                case ',':
                    compt++;
                    break;
                default:
                    cour = &(*cour)->frere;
                    construction(ch[compt],cour);
                    compt++;
            }
        }
    }
    free_lifo(p);
    return err;
}

variable_types:
ch
char *

variable_types: struct lifo { int t_max; int taille; struct abr { char val; struct abr *fils; struct abr *frere; } ***tab; } *

variable_types: compt int

user_defined_types: struct lifo { int t_max; int taille; struct abr ***tab; }


decompiled_code:
_BOOL8 __fastcall liberation_abr(__int64 a1)
{
void *v2; // rbp
_BOOL4 v3; // er13
bool v4; // zf
void **v5; // r12
char *v6; // rax

v2 = malloc(0x10uLL);
v3 = init_lifo((__int64)v2, 50);
if ( v3 )
printf("Erreur : pile non initialisee !");
while ( 1 )
{
if ( *(_QWORD *)a1 )
{
do
{
empiler((__int64)v2, a1);
v4 = *(_QWORD *)(*(_QWORD *)a1 + 8LL) == 0LL;
a1 = *(_QWORD *)a1 + 8LL;
}
while ( !v4 );
}
if ( (unsigned int)lifo_vide((__int64)v2) )
break;
v5 = (void **)depiler((__int64)v2);
v6 = (char *)*v5;
if ( *((_QWORD *)*v5 + 2) )
{
empiler((__int64)v2, (__int64)v5);
a1 = (__int64)*v5 + 16;
}
else
{
a1 = (__int64)(v6 + 16);
printf("free(%c)\n", (unsigned int)*v6);
fflush(_bss_start);
free(*v5);
*v5 = 0LL;
}
}
free_lifo(v2);
return v3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(__int64 a1)
{
void *v2; // rbp
_BOOL4 v3; // er13
bool v4; // zf
void **v5; // r12
char *v6; // rax

v2 = malloc(0x10uLL);
v3 = func8((__int64)v2, 50);
if ( v3 )
printf("Erreur : pile non initialisee !");
while ( 1 )
{
if ( *(_QWORD *)a1 )
{
do
{
func7((__int64)v2, a1);
v4 = *(_QWORD *)(*(_QWORD *)a1 + 8LL) == 0LL;
a1 = *(_QWORD *)a1 + 8LL;
}
while ( !v4 );
}
if ( (unsigned int)func9((__int64)v2) )
break;
v5 = (void **)func10((__int64)v2);
v6 = (char *)*v5;
if ( *((_QWORD *)*v5 + 2) )
{
func7((__int64)v2, (__int64)v5);
a1 = (__int64)*v5 + 16;
}
else
{
a1 = (__int64)(v6 + 16);
printf("free(%c)\n", (unsigned int)*v6);
fflush(_bss_start);
free(*v5);
*v5 = 0LL;
}
}
func12(v2);
return v3;
}

original_code:
int liberation_abr(abr_t ** r)
{
    lifo_t * p = (lifo_t *)malloc(sizeof(lifo_t));
    abr_t ** cour = r;
    abr_t ** tmp = ((void *)0);
    int fin = 0;
    int err = 0;
    err = init_lifo(p,50);
    if (err)
    {
        printf("Erreur : pile non initialisee !");
    }
    while ((! fin))
    {
        while (*cour)
        {
            empiler(p,cour);
            cour = &(*cour)->fils;
        }
        if (! lifo_vide(p))
        {
            cour = depiler(p);
            tmp = cour;
            if ((*cour)->frere)
            {
                empiler(p,cour);
                cour = &(*cour)->frere;
            }
            else
            {
                cour = &(*cour)->frere;
                printf("free(%c)\n",(*tmp)->val);
                fflush(stdout);
                free(*tmp);
                *tmp = ((void *)0);
            }
        }
        else
        {
            fin = 1;
        }
    }
    free_lifo(p);
    return err;
}

canonical_original_code:
int liberation_abr(struct abr **r)
{
    struct lifo *p = (lifo_t *)malloc(sizeof(lifo_t));
    struct abr **cour = r;
    struct abr **tmp = ((void *)0);
    int fin = 0;
    int err = 0;
    err = init_lifo(p,50);
    if (err)
    {
        printf("Erreur : pile non initialisee !");
    }
    while ((! fin))
    {
        while (*cour)
        {
            empiler(p,cour);
            cour = &(*cour)->fils;
        }
        if (! lifo_vide(p))
        {
            cour = depiler(p);
            tmp = cour;
            if ((*cour)->frere)
            {
                empiler(p,cour);
                cour = &(*cour)->frere;
            }
            else
            {
                cour = &(*cour)->frere;
                printf("free(%c)\n",(*tmp)->val);
                fflush(stdout);
                free(*tmp);
                *tmp = ((void *)0);
            }
        }
        else
        {
            fin = 1;
        }
    }
    free_lifo(p);
    return err;
}

variable_types: fin int

user_defined_types: struct abr { char val; struct abr *fils; struct abr *frere; }


decompiled_code:
_BOOL8 __fastcall affichage_abr(__int64 a1)
{
void *v2; // rbp
_BOOL4 v3; // er12
int v4; // eax
_BYTE *v5; // rax
bool v6; // zf
int v7; // er8

v2 = malloc(0x10uLL);
v3 = init_lifo((__int64)v2, 50);
if ( v3 )
printf("Erreur : pile non initialisee !");
LABEL_3:
v4 = 0;
while ( !(v3 | v4) )
{
if ( *(_QWORD *)a1 )
{
do
{
while ( 1 )
{
empiler((__int64)v2, a1);
v5 = *(_BYTE **)a1;
if ( (unsigned __int8)(**(_BYTE **)a1 - 65) <= 0x19u )
break;
a1 = (__int64)(v5 + 8);
if ( !*((_QWORD *)v5 + 1) )
goto LABEL_10;
}
afficher_lifo((__int64)v2);
v6 = *(_QWORD *)(*(_QWORD *)a1 + 8LL) == 0LL;
a1 = *(_QWORD *)a1 + 8LL;
}
while ( !v6 );
}
LABEL_10:
v7 = lifo_vide((__int64)v2);
v4 = 1;
if ( !v7 )
{
a1 = *(_QWORD *)depiler((__int64)v2) + 16LL;
goto LABEL_3;
}
}
free_lifo(v2);
return v3;
}

original_code:
int affichage_abr(abr_t ** r)
{
    lifo_t * p = (lifo_t *)malloc(sizeof(lifo_t));
    abr_t ** cour = r;
    int fin = 0;
    int err = 0;
    err = init_lifo(p,50);
    if (err)
    {
        printf("Erreur : pile non initialisee !");
    }
    while ((! fin) && (! err))
    {
        while (*cour)
        {
            empiler(p,cour);
            if (((*cour)->val > 64) && ((*cour)->val < 91))
            {
                afficher_lifo(p);
            }
            cour = &(*cour)->fils;
        }
        if (! lifo_vide(p))
        {
            cour = depiler(p);
            cour = &(*cour)->frere;
        }
        else
        {
            fin = 1;
        }
    }
    free_lifo(p);
    return err;
}

canonical_original_code:
int affichage_abr(struct abr **r)
{
    struct lifo *p = (lifo_t *)malloc(sizeof(lifo_t));
    struct abr **cour = r;
    int fin = 0;
    int err = 0;
    err = init_lifo(p,50);
    if (err)
    {
        printf("Erreur : pile non initialisee !");
    }
    while ((! fin) && (! err))
    {
        while (*cour)
        {
            empiler(p,cour);
            if (((*cour)->val > 64) && ((*cour)->val < 91))
            {
                afficher_lifo(p);
            }
            cour = &(*cour)->fils;
        }
        if (! lifo_vide(p))
        {
            cour = depiler(p);
            cour = &(*cour)->frere;
        }
        else
        {
            fin = 1;
        }
    }
    free_lifo(p);
    return err;
}


decompiled_code:
__int64 __fastcall insertion_abr(_QWORD *a1, char *a2)
{
__int64 v2; // rbx
__int64 v5; // rsi
int v6; // er13
_BYTE *v7; // r12
const __int32_t **v8; // rax
const __int32_t **v10; // rax

v2 = *a2;
if ( (_BYTE)v2 )
{
v5 = 0LL;
v6 = 0;
while ( 1 )
{
v7 = (_BYTE *)*a1;
if ( !*a1 )
break;
if ( (char)v2 % 32 == (char)*v7 % 32 )
{
if ( a2[v5 + 1] )
a1 = v7 + 8;
else
*v7 = (*__ctype_toupper_loc())[v2];
LABEL_11:
v5 = ++v6;
v2 = a2[v6];
if ( !(_BYTE)v2 )
return 0LL;
}
else
{
if ( (char)v2 % 32 <= (char)*v7 % 32 )
{
if ( a2[v5 + 1] )
{
construction(v2, a1);
}
else
{
v10 = __ctype_toupper_loc();
construction((*v10)[v2], a1);
}
++v6;
*(_QWORD *)(*a1 + 16LL) = v7;
a1 = (_QWORD *)(*a1 + 8LL);
}
else
{
a1 = v7 + 16;
}
v5 = v6;
v2 = a2[v6];
if ( !(_BYTE)v2 )
return 0LL;
}
}
if ( a2[v5 + 1] )
{
construction(v2, a1);
}
else
{
v8 = __ctype_toupper_loc();
construction((*v8)[v2], a1);
}
a1 = (_QWORD *)(*a1 + 8LL);
goto LABEL_11;
}
return 0LL;
}

original_code:
int insertion_abr(abr_t ** r, char * ch)
{
    abr_t ** prec = r;
    int err = 0;
    int i = 0;
    abr_t * tmp = ((void *)0);
    char char_ch;
    char char_abr;
    while(ch[i] != '\0')
    {
        if (*prec)
        {
            char_ch = ch[i] % 32;
            char_abr = (*prec)->val % 32;
            if (char_abr == char_ch)
            {
                if(ch[i+1] == '\0')
                {
                    (*prec)->val=toupper(ch[i]);
                }
                else
                {
                    prec = &(*prec)->fils;
                }
                i++;
            }
            else if (char_abr < char_ch)
            {
                prec = &(*prec)->frere;
            }
            else
            {
                tmp = *prec;
                if(ch[i+1] == '\0')
                {
                    construction(toupper(ch[i]),prec);
                }
                else
                {
                    construction(ch[i],prec);
                }
                (*prec)->frere = tmp;
                prec = &(*prec)->fils;
                i++;
            }
        }
        else
        {
            if(ch[i+1] == '\0')
            {
                construction(toupper(ch[i]),prec);
            }
            else
            {
                construction(ch[i],prec);
            }
            prec = &(*prec)->fils;
            i++;
        }
    }
    return err;
}

canonical_original_code:
int insertion_abr(struct abr **r, char *ch)
{
    struct abr **prec = r;
    int err = 0;
    int i = 0;
    struct abr *tmp = ((void *)0);
    char char_ch;
    char char_abr;
    while(ch[i] != '\0')
    {
        if (*prec)
        {
            char_ch = ch[i] % 32;
            char_abr = (*prec)->val % 32;
            if (char_abr == char_ch)
            {
                if(ch[i+1] == '\0')
                {
                    (*prec)->val=toupper(ch[i]);
                }
                else
                {
                    prec = &(*prec)->fils;
                }
                i++;
            }
            else if (char_abr < char_ch)
            {
                prec = &(*prec)->frere;
            }
            else
            {
                tmp = *prec;
                if(ch[i+1] == '\0')
                {
                    construction(toupper(ch[i]),prec);
                }
                else
                {
                    construction(ch[i],prec);
                }
                (*prec)->frere = tmp;
                prec = &(*prec)->fils;
                i++;
            }
        }
        else
        {
            if(ch[i+1] == '\0')
            {
                construction(toupper(ch[i]),prec);
            }
            else
            {
                construction(ch[i],prec);
            }
            prec = &(*prec)->fils;
            i++;
        }
    }
    return err;
}

variable_types: i int

variable_types: struct abr { char val; struct abr *fils; struct abr *frere; } *


decompiled_code:
__int64 __fastcall verif_chaine(const char *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
const unsigned __int16 **v3; // rax
int v4; // edx
unsigned int v5; // esi
const unsigned __int16 *v6; // rcx
__int64 v7; // rax
__int64 result; // rax
int v9; // edx

a1[strlen(a1) - 1] = 0;
v1 = *a1;
v2 = a1[1];
if ( (_BYTE)v1 == 40 )
{
if ( (_BYTE)v2 == 41 )
{
result = 0LL;
if ( !a1[2] )
return result;
}
else if ( !(_BYTE)v2 )
{
return 0LL;
}
}
else if ( !(_BYTE)v2 )
{
if ( (_BYTE)v1 != 41 )
return 0LL;
goto LABEL_11;
}
v3 = __ctype_b_loc();
v4 = 1;
v5 = 0;
v6 = *v3;
while ( 1 )
{
LODWORD(v7) = v4 - 1;
if ( (_BYTE)v1 == 41 )
break;
if ( (_BYTE)v1 == 44 )
{
if ( (v6[v2] & 0x400) == 0 )
goto LABEL_10;
}
else if ( (_BYTE)v1 == 40 )
{
if ( (v6[(char)v2] & 0x400) == 0 && (_BYTE)v2 != 40 )
goto LABEL_10;
++v5;
}
else if ( (v6[v1] & 0x400) == 0 || (unsigned __int8)(v2 - 40) > 1u && (_BYTE)v2 != 44 )
{
goto LABEL_10;
}
LABEL_15:
v7 = v4++;
v2 = a1[v7 + 1];
v1 = a1[v7];
if ( !(_BYTE)v2 )
{
v9 = 0;
goto LABEL_17;
}
}
if ( (v6[(char)v2] & 0x400) != 0 || (_BYTE)v2 == 41 )
{
--v5;
goto LABEL_15;
}
LABEL_10:
v7 = (int)v7;
if ( a1[(int)v7 + 1] )
goto LABEL_11;
v9 = 1;
LABEL_17:
if ( a1[v7] == 41 )
--v5;
result = v9 | v5;
if ( (_DWORD)result )
{
LABEL_11:
puts("Ecriture parenthesee incorrecte !");
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(const char *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
const unsigned __int16 **v3; // rax
int v4; // edx
unsigned int v5; // esi
const unsigned __int16 *v6; // rcx
__int64 v7; // rax
__int64 result; // rax
int v9; // edx

a1[strlen(a1) - 1] = 0;
v1 = *a1;
v2 = a1[1];
if ( (_BYTE)v1 == 40 )
{
if ( (_BYTE)v2 == 41 )
{
result = 0LL;
if ( !a1[2] )
return result;
}
else if ( !(_BYTE)v2 )
{
return 0LL;
}
}
else if ( !(_BYTE)v2 )
{
if ( (_BYTE)v1 != 41 )
return 0LL;
goto LABEL_11;
}
v3 = __ctype_b_loc();
v4 = 1;
v5 = 0;
v6 = *v3;
while ( 1 )
{
LODWORD(v7) = v4 - 1;
if ( (_BYTE)v1 == 41 )
break;
if ( (_BYTE)v1 == 44 )
{
if ( (v6[v2] & 0x400) == 0 )
goto LABEL_10;
}
else if ( (_BYTE)v1 == 40 )
{
if ( (v6[(char)v2] & 0x400) == 0 && (_BYTE)v2 != 40 )
goto LABEL_10;
++v5;
}
else if ( (v6[v1] & 0x400) == 0 || (unsigned __int8)(v2 - 40) > 1u && (_BYTE)v2 != 44 )
{
goto LABEL_10;
}
LABEL_15:
v7 = v4++;
v2 = a1[v7 + 1];
v1 = a1[v7];
if ( !(_BYTE)v2 )
{
v9 = 0;
goto LABEL_17;
}
}
if ( (v6[(char)v2] & 0x400) != 0 || (_BYTE)v2 == 41 )
{
--v5;
goto LABEL_15;
}
LABEL_10:
v7 = (int)v7;
if ( a1[(int)v7 + 1] )
goto LABEL_11;
v9 = 1;
LABEL_17:
if ( a1[v7] == 41 )
--v5;
result = v9 | v5;
if ( (_DWORD)result )
{
LABEL_11:
puts("Ecriture parenthesee incorrecte !");
result = 1LL;
}
return result;
}

original_code:
int verif_chaine(char * ch)
{
    int compt = 0;
    int compt_parenthese = 0;
    int err = 0;
    int abr_vide = 0;
    ch[strlen(ch) - 1] = '\0';
    if (ch[compt] == '(' && ch[compt + 1] == ')' && ch[compt + 2] == '\0')
    {
        abr_vide = 1;
    }
    while (ch[compt + 1] != '\0' && ! err && ! abr_vide)
    {
        switch(ch[compt])
        {
            case '(':
                if(((*__ctype_b_loc ())[(int) ((ch[compt + 1]))] & (unsigned short int) _ISalpha) || ch[compt + 1] == '(')
                {
                    compt_parenthese++;
                    compt++;
                }
                else
                {
                    err = 1;
                }
                break;
            case ')':
                if(((*__ctype_b_loc ())[(int) ((ch[compt + 1]))] & (unsigned short int) _ISalpha) || ch[compt + 1] == ')')
                {
                    compt_parenthese--;
                    compt++;
                }
                else
                {
                    err = 1;
                }
                break;
            case ',':
                if(((*__ctype_b_loc ())[(int) ((ch[compt + 1]))] & (unsigned short int) _ISalpha))
                {
                    compt++;
                }
                else
                {
                    err = 1;
                }
                break;
            default:
                if(((*__ctype_b_loc ())[(int) ((ch[compt]))] & (unsigned short int) _ISalpha))
                {
                    if(ch[compt + 1] == ')' || ch[compt + 1] == '(' || ch[compt + 1] == ',')
                    {
                        compt++;
                    }
                    else
                    {
                        err = 1;
                    }
                }
                else
                {
                    err = 1;
                }
        }
    }
    if (ch[compt] == ')')
    {
        compt_parenthese--;
    }
    if (compt_parenthese != 0)
    {
        err = 1;
    }
    if (err)
    {
        printf("Ecriture parenthesee incorrecte !\n");
    }
    return err;
}

canonical_original_code:
int verif_chaine(char *ch)
{
    int compt = 0;
    int compt_parenthese = 0;
    int err = 0;
    int abr_vide = 0;
    ch[strlen(ch) - 1] = '\0';
    if (ch[compt] == '(' && ch[compt + 1] == ')' && ch[compt + 2] == '\0')
    {
        abr_vide = 1;
    }
    while (ch[compt + 1] != '\0' && ! err && ! abr_vide)
    {
        switch(ch[compt])
        {
            case '(':
                if(((*__ctype_b_loc ())[(int) ((ch[compt + 1]))] & (unsigned short) _ISalpha) || ch[compt + 1] == '(')
                {
                    compt_parenthese++;
                    compt++;
                }
                else
                {
                    err = 1;
                }
                break;
            case ')':
                if(((*__ctype_b_loc ())[(int) ((ch[compt + 1]))] & (unsigned short) _ISalpha) || ch[compt + 1] == ')')
                {
                    compt_parenthese--;
                    compt++;
                }
                else
                {
                    err = 1;
                }
                break;
            case ',':
                if(((*__ctype_b_loc ())[(int) ((ch[compt + 1]))] & (unsigned short) _ISalpha))
                {
                    compt++;
                }
                else
                {
                    err = 1;
                }
                break;
            default:
                if(((*__ctype_b_loc ())[(int) ((ch[compt]))] & (unsigned short) _ISalpha))
                {
                    if(ch[compt + 1] == ')' || ch[compt + 1] == '(' || ch[compt + 1] == ',')
                    {
                        compt++;
                    }
                    else
                    {
                        err = 1;
                    }
                }
                else
                {
                    err = 1;
                }
        }
    }
    if (ch[compt] == ')')
    {
        compt_parenthese--;
    }
    if (compt_parenthese != 0)
    {
        err = 1;
    }
    if (err)
    {
        printf("Ecriture parenthesee incorrecte !\n");
    }
    return err;
}


decompiled_code:
__int64 __fastcall verif_argument(char *a1)
{
__int64 v1; // rbx
char *v2; // rdi
const unsigned __int16 *v3; // rax

v1 = *a1;
if ( !(_BYTE)v1 )
return 0LL;
v2 = a1 + 1;
v3 = *__ctype_b_loc();
while ( (v3[v1] & 0x400) != 0 )
{
v1 = *v2++;
if ( !(_BYTE)v1 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func20(char *a1)
{
__int64 v1; // rbx
char *v2; // rdi
const unsigned __int16 *v3; // rax

v1 = *a1;
if ( !(_BYTE)v1 )
return 0LL;
v2 = a1 + 1;
v3 = *__ctype_b_loc();
while ( (v3[v1] & 0x400) != 0 )
{
v1 = *v2++;
if ( !(_BYTE)v1 )
return 0LL;
}
return 1LL;
}

original_code:
int verif_argument(char * ch)
{
    int compt = 0;
    int err = 0;
    while(ch[compt] != '\0' && ! err)
    {
        if (! ((*__ctype_b_loc ())[(int) ((ch[compt]))] & (unsigned short int) _ISalpha))
        {
            err = 1;
        }
        compt++;
    }
    return err;
}

canonical_original_code:
int verif_argument(char *ch)
{
    int compt = 0;
    int err = 0;
    while(ch[compt] != '\0' && ! err)
    {
        if (! ((*__ctype_b_loc ())[(int) ((ch[compt]))] & (unsigned short) _ISalpha))
        {
            err = 1;
        }
        compt++;
    }
    return err;
}


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

*(_DWORD *)a1 = a2;
*(_DWORD *)(a1 + 4) = -1;
v2 = malloc(a2);
*(_QWORD *)(a1 + 8) = v2;
return v2 == 0LL;
}

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

*(_DWORD *)a1 = a2;
*(_DWORD *)(a1 + 4) = -1;
v2 = malloc(a2);
*(_QWORD *)(a1 + 8) = v2;
return v2 == 0LL;
}


depiler

decompiled_code:
__int64 __fastcall depiler(__int64 a1)
{
unsigned int v1; // er8

if ( !(unsigned int)lifo_vide(a1) )
v1 = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + (int)(*(_DWORD *)(a1 + 4))--);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
unsigned int v1; // er8

if ( !(unsigned int)func9(a1) )
v1 = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + (int)(*(_DWORD *)(a1 + 4))--);
return v1;
}


decompiled_code:
int __fastcall inversion_pile(unsigned int *a1)
{
void *v1; // r12
char v3; // al
char v4; // al

v1 = malloc(0x18uLL);
if ( !(unsigned int)init_fifo(v1, *a1) )
{
puts("Pile a inverser :");
afficher_lifo((__int64)a1);
while ( !(unsigned int)lifo_vide((__int64)a1) )
{
v3 = depiler((__int64)a1);
enfiler(v1, (unsigned int)v3);
}
puts("Etat de la file :");
afficher_fifo(v1);
while ( !(unsigned int)fifo_vide(v1) )
{
v4 = defiler(v1);
empiler((__int64)a1, v4);
}
free_fifo(v1);
}
puts("Pile inversee :");
return afficher_lifo((__int64)a1);
}

canonical_decompiled_code:
int __fastcall func14(unsigned int *a1)
{
void *v1; // r12
char v3; // al
char v4; // al

v1 = malloc(0x18uLL);
if ( !(unsigned int)func16(v1, *a1) )
{
puts("Pile a inverser :");
func13((__int64)a1);
while ( !(unsigned int)func9((__int64)a1) )
{
v3 = func10((__int64)a1);
func20(v1, (unsigned int)v3);
}
puts("Etat de la file :");
func22(v1);
while ( !(unsigned int)func17(v1) )
{
v4 = func18(v1);
func7((__int64)a1, v4);
}
func21(v1);
}
puts("Pile inversee :");
return func13((__int64)a1);
}

original_code:
void inversion_pile(lifo_t * p)
{
    fifo_t * f = ((void *)0);
    type_t tmp;
    int err;
    f = (fifo_t *)malloc(sizeof(fifo_t));
    err = init_fifo(f,p->t_max);
    if (! err)
    {
        printf("Pile a inverser :\n");
        afficher_lifo(p);
        while (!lifo_vide(p))
        {
            tmp = depiler(p);
            enfiler(f,tmp);
        }
        printf("Etat de la file :\n");
        afficher_fifo(f);
        while (! fifo_vide(f))
        {
            tmp = defiler(f);
            empiler(p,tmp);
        }
        free_fifo(f);
    }
    printf("Pile inversee :\n");
    afficher_lifo(p);
}

canonical_original_code:
void inversion_pile(struct lifo *p)
{
    struct fifo *f = ((void *)0);
    char tmp;
    int err;
    f = (struct fifo *)malloc(sizeof(fifo_t));
    err = init_fifo(f,p->t_max);
    if (! err)
    {
        printf("Pile a inverser :\n");
        afficher_lifo(p);
        while (!lifo_vide(p))
        {
            tmp = depiler(p);
            enfiler(f,tmp);
        }
        printf("Etat de la file :\n");
        afficher_fifo(f);
        while (! fifo_vide(f))
        {
            tmp = defiler(f);
            empiler(p,tmp);
        }
        free_fifo(f);
    }
    printf("Pile inversee :\n");
    afficher_lifo(p);
}

variable_types: struct fifo { int t_max; int in; int out; char *tab; } *

variable_types: tmp char


decompiled_code:
__int64 __fastcall lecture_pile(__int64 a1, char *a2)
{
char v2; // si
__int64 result; // rax
char *v4; // rcx

v2 = *a2;
if ( v2 )
{
do
{
result = empiler(a1, v2);
v2 = *v4;
}
while ( *v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, char *a2)
{
char v2; // si
__int64 result; // rax
char *v4; // rcx

v2 = *a2;
if ( v2 )
{
do
{
result = func7(a1, v2);
v2 = *v4;
}
while ( *v4 );
}
return result;
}

original_code:
void lecture_pile(lifo_t * p, char * ch)
{
    int compt = 0;
    while (ch[compt] != '\0')
    {
        empiler(p,ch[compt]);
        compt++;
    }
}

canonical_original_code:
void lecture_pile(struct lifo *p, char *ch)
{
    int compt = 0;
    while (ch[compt] != '\0')
    {
        empiler(p,ch[compt]);
        compt++;
    }
}


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

*(_DWORD *)a1 = a2;
v2 = malloc(a2);
*(_QWORD *)(a1 + 16) = v2;
if ( !v2 )
return 1LL;
*(_QWORD *)(a1 + 4) = 0LL;
return 0LL;
}

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

*(_DWORD *)a1 = a2;
v2 = malloc(a2);
*(_QWORD *)(a1 + 16) = v2;
if ( !v2 )
return 1LL;
*(_QWORD *)(a1 + 4) = 0LL;
return 0LL;
}

original_code:
int init_fifo(fifo_t * f, int t_max)
{
    int err = 1;
    f->t_max = t_max;
    f->tab = (type_t*)malloc(t_max*sizeof(type_t));
    if (f->tab)
    {
        f->in = 0;
        f->out = 0;
        err = 0;
    }
    return err;
}

canonical_original_code:
int init_fifo(struct fifo *f, int t_max)
{
    int err = 1;
    f->t_max = t_max;
    f->tab = (char *)malloc(t_max*sizeof(type_t));
    if (f->tab)
    {
        f->in = 0;
        f->out = 0;
        err = 0;
    }
    return err;
}

user_defined_types: struct fifo { int t_max; int in; int out; char *tab; }


decompiled_code:
_BOOL8 __fastcall fifo_vide(__int64 a1)
{
return *(_DWORD *)(a1 + 4) == *(_DWORD *)(a1 + 8);
}

canonical_decompiled_code:
_BOOL8 __fastcall func17(__int64 a1)
{
return *(_DWORD *)(a1 + 4) == *(_DWORD *)(a1 + 8);
}

original_code:
int fifo_vide(fifo_t * f)
{
    int ret = 0;
    if ((f->in - f->out) == 0)
    {
        ret = 1;
    }
    return ret;
}

canonical_original_code:
int fifo_vide(struct fifo *f)
{
    int ret = 0;
    if ((f->in - f->out) == 0)
    {
        ret = 1;
    }
    return ret;
}


defiler

original_code:
type_t defiler(fifo_t * f)
{
    type_t val;
    if (!fifo_vide(f))
    {
        f->out++;
        val = f->tab[f->out % f->t_max];
    }
    return val;
}

canonical_original_code:
char defiler(struct fifo *f)
{
    char val;
    if (!fifo_vide(f))
    {
        f->out++;
        val = f->tab[f->out % f->t_max];
    }
    return val;
}


decompiled_code:
_BOOL8 __fastcall fifo_pleine(_DWORD *a1)
{
return a1[1] - a1[2] == *a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func19(_DWORD *a1)
{
return a1[1] - a1[2] == *a1;
}

original_code:
int fifo_pleine(fifo_t * f)
{
    int ret = 0;
    if ((f->in - f->out) == f->t_max)
    {
        ret = 1;
    }
    return ret;
}

canonical_original_code:
int fifo_pleine(struct fifo *f)
{
    int ret = 0;
    if ((f->in - f->out) == f->t_max)
    {
        ret = 1;
    }
    return ret;
}


enfiler

original_code:
int enfiler(fifo_t * f, type_t val)
{
    int err = 1;
    if (! fifo_pleine(f))
    {
        f->in++;
        f->tab[f->in % f->t_max] = val;
        err = 0;
    }
    return err;
}

canonical_original_code:
int enfiler(struct fifo *f, char val)
{
    int err = 1;
    if (! fifo_pleine(f))
    {
        f->in++;
        f->tab[f->in % f->t_max] = val;
        err = 0;
    }
    return err;
}


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

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

original_code:
void free_fifo(fifo_t* f)
{
    free(f->tab);
    free(f);
}

canonical_original_code:
void free_fifo(struct fifo *f)
{
    free(f->tab);
    free(f);
}


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

v1 = *(_DWORD *)(a1 + 8);
v2 = *(_DWORD *)(a1 + 4) - v1;
if ( v2 > 0 )
{
v3 = v1 + 1;
do
{
printf("%c\n", (unsigned int)*(char *)(*(_QWORD *)(a1 + 16) + v3));
v3 = (v3 + 1) % *(_DWORD *)a1;
--v2;
}
while ( v2 );
}
return putchar(10);
}

original_code:
void afficher_fifo(fifo_t * f)
{
    int cour = f->out + 1;
    int nb = f->in - f->out;
    while (nb > 0)
    {
        printf("%c\n",f->tab[cour]);
        cour++;
        cour = cour % f->t_max;
        nb--;
    }
    printf("\n");
}

canonical_original_code:
void afficher_fifo(struct fifo *f)
{
    int cour = f->out + 1;
    int nb = f->in - f->out;
    while (nb > 0)
    {
        printf("%c\n",f->tab[cour]);
        cour++;
        cour = cour % f->t_max;
        nb--;
    }
    printf("\n");
}

variable_types: cour int

variable_types: nb int


SuppressionAct

decompiled_code:
void __fastcall SuppressionAct(_QWORD **a1)
{
_QWORD *v1; // r8

v1 = *a1;
if ( *a1 )
{
*a1 = (_QWORD *)v1[2];
free(v1);
}
else
{
puts("Erreur");
}
}

canonical_decompiled_code:
void __fastcall func0(_QWORD **a1)
{
_QWORD *v1; // r8

v1 = *a1;
if ( *a1 )
{
*a1 = (_QWORD *)v1[2];
free(v1);
}
else
{
puts("Erreur");
}
}

original_code:
void SuppressionAct(action_t ** prec)
{
    action_t * tmp = *prec;
    if (*prec == ((void *)0))
    {
        printf("Erreur\n");
    }
    else
    {
        *prec = ((**prec).suiv);
        free(tmp);
    }
}

canonical_original_code:
void SuppressionAct(struct struct2 **prec)
{
    struct struct2 *tmp = *prec;
    if (*prec == ((void *)0))
    {
        printf("Erreur\n");
    }
    else
    {
        *prec = ((**prec).suiv);
        free(tmp);
    }
}

variable_types: struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } **


SuppressionSem

decompiled_code:
void __fastcall SuppressionSem(_QWORD **a1)
{
_QWORD *v1; // r8

v1 = *a1;
if ( *a1 )
{
*a1 = (_QWORD *)v1[2];
free(v1);
}
else
{
puts("Erreur");
}
}

canonical_decompiled_code:
void __fastcall func1(_QWORD **a1)
{
_QWORD *v1; // r8

v1 = *a1;
if ( *a1 )
{
*a1 = (_QWORD *)v1[2];
free(v1);
}
else
{
puts("Erreur");
}
}

original_code:
void SuppressionSem(semaine_t ** prec)
{
    semaine_t * tmp = *prec;
    if (*prec == ((void *)0))
    {
        printf("Erreur\n");
    }
    else
    {
        *prec = (**prec).suiv;
        free(tmp);
    }
}

canonical_original_code:
void SuppressionSem(struct struct1 **prec)
{
    struct struct1 *tmp = *prec;
    if (*prec == ((void *)0))
    {
        printf("Erreur\n");
    }
    else
    {
        *prec = (**prec).suiv;
        free(tmp);
    }
}

variable_types: struct struct1 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct1 *suiv; } **

user_defined_types: struct struct1 { char chaine_sem[7]; struct struct2 *action_s; struct struct1 *suiv; }


initialiserJoueur

decompiled_code:
void *__fastcall initialiserJoueur(void **a1, int a2)
{
__int64 v2; // r12
void **v3; // rbx
void *v4; // rdi
void *result; // rax

if ( a2 > 0 )
{
v2 = (__int64)&a1[(unsigned int)(a2 - 1) + 1];
v3 = a1;
do
{
v4 = *v3++;
result = memset(v4, 255, 4LL * (unsigned int)a2);
}
while ( v3 != (void **)v2 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(void **a1, int a2)
{
__int64 v2; // r12
void **v3; // rbx
void *v4; // rdi
void *result; // rax

if ( a2 > 0 )
{
v2 = (__int64)&a1[(unsigned int)(a2 - 1) + 1];
v3 = a1;
do
{
v4 = *v3++;
result = memset(v4, 255, 4LL * (unsigned int)a2);
}
while ( v3 != (void **)v2 );
}
return result;
}

original_code:
void initialiserJoueur(int ** mat_t, int taille_t)
{
    int i=0,j=0;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            mat_t[i][j] = -1;
        }
    }
}

canonical_original_code:
void initialiserJoueur(int **mat_t, int taille_t)
{
    int i = 0; int j = 0;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            mat_t[i][j] = -1;
        }
    }
}

variable_types: j int


initialiserJeu

decompiled_code:
void *__fastcall initialiserJeu(void **a1, int a2)
{
__int64 v2; // r12
void **v3; // rbx
void *v4; // rdi
void *result; // rax

if ( a2 > 0 )
{
v2 = (__int64)&a1[(unsigned int)(a2 - 1) + 1];
v3 = a1;
do
{
v4 = *v3++;
result = memset(v4, 0, 4LL * (unsigned int)a2);
}
while ( v3 != (void **)v2 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(void **a1, int a2)
{
__int64 v2; // r12
void **v3; // rbx
void *v4; // rdi
void *result; // rax

if ( a2 > 0 )
{
v2 = (__int64)&a1[(unsigned int)(a2 - 1) + 1];
v3 = a1;
do
{
v4 = *v3++;
result = memset(v4, 0, 4LL * (unsigned int)a2);
}
while ( v3 != (void **)v2 );
}
return result;
}

original_code:
void initialiserJeu(int ** mat, int taille_t)
{
    int i=0,j=0;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            mat[i][j] = 0;
        }
    }
}

canonical_original_code:
void initialiserJeu(int **mat, int taille_t)
{
    int i = 0; int j = 0;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            mat[i][j] = 0;
        }
    }
}

variable_types:
mat
int **


placerBombe

decompiled_code:
void __fastcall placerBombe(__int64 a1, int a2, int a3, unsigned int a4)
{
int i; // er14
__int64 v6; // rbp

srand(a4);
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
{
v6 = rand() % a3;
*(_DWORD *)(*(_QWORD *)(a1 + 8 * v6) + 4LL * (rand() % a3)) = 100;
}
}
}

original_code:
void placerBombe(int ** mat,int nb_bombe, int taille_t, int germe)
{
    int i=0,j=0,k=0;
    srand(germe);
    for(k=0;k<nb_bombe;k++)
    {
        i = rand()%taille_t;
        j = rand()%taille_t;
        mat[i][j] = 100;
    }
}

canonical_original_code:
void placerBombe(int **mat, int nb_bombe, int taille_t, int germe)
{
    int i = 0; int j = 0; int k = 0;
    srand(germe);
    for(k=0;k<nb_bombe;k++)
    {
        i = rand()%taille_t;
        j = rand()%taille_t;
        mat[i][j] = 100;
    }
}

variable_types: germe int

variable_types: k int


fin

original_code:
int fin(int ** mat,int ** mat_t,int taille_t)
{
    int i=0,j=0;
    int verif = 1;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            if (mat[i][j]/100 != mat_t[i][j]/100)
            {
                verif = 0;
                break;
            }
        }
    }
    return verif;
}

canonical_original_code:
int fin(int **mat, int **mat_t, int taille_t)
{
    int i = 0; int j = 0;
    int verif = 1;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            if (mat[i][j]/100 != mat_t[i][j]/100)
            {
                verif = 0;
                break;
            }
        }
    }
    return verif;
}

variable_types: verif int


affichage

decompiled_code:
int __fastcall affichage(const char **a1, int a2)
{
const char **v2; // r13
int v3; // er12
int v4; // ebx
const char *v5; // rsi
int i; // ebp
int v7; // ebp
int v8; // ebp
int v9; // ebp
int result; // eax
const char *v11; // rdi

if ( !a1 )
return puts("Il n'y a aucune fiche !");
v2 = a1;
v3 = a2 - 1;
v4 = a2;
v5 = *a1;
if ( !*a1 )
return puts("Il n'y a aucune fiche !");
while ( 1 )
{
if ( v4 <= 0 )
{
printf("[nom : %s]\n", v5);
printf("[prenom : %s]\n", v2[1]);
printf("[login : %s]\n", v2[2]);
}
else
{
for ( i = 0; i != v4; ++i )
{
while ( v3 != i )
{
++i;
printf("| ");
if ( i == v4 )
goto LABEL_8;
}
printf("|--> ");
}
LABEL_8:
v7 = 0;
printf("[nom : %s]\n", *v2);
do
{
++v7;
printf("| ");
}
while ( v7 != v4 );
v8 = 0;
printf("[prenom : %s]\n", v2[1]);
do
{
++v8;
printf("| ");
}
while ( v8 != v4 );
v9 = 0;
printf("[login : %s]\n", v2[2]);
do
{
++v9;
printf("| ");
}
while ( v9 != v4 );
}
result = printf("[mot de passe : %s]\n", v2[3]);
v11 = v2[4];
if ( v11 )
result = affichage(v11, (unsigned int)(v4 + 1));
v2 = (const char **)v2[5];
++v3;
if ( !v2 )
return result;
v5 = *v2;
++v4;
if ( !*v2 )
return puts("Il n'y a aucune fiche !");
}
}

canonical_decompiled_code:
int __fastcall func0(const char **a1, int a2)
{
const char **v2; // r13
int v3; // er12
int v4; // ebx
const char *v5; // rsi
int i; // ebp
int v7; // ebp
int v8; // ebp
int v9; // ebp
int result; // eax
const char *v11; // rdi

if ( !a1 )
return puts("Il n'y a aucune fiche !");
v2 = a1;
v3 = a2 - 1;
v4 = a2;
v5 = *a1;
if ( !*a1 )
return puts("Il n'y a aucune fiche !");
while ( 1 )
{
if ( v4 <= 0 )
{
printf("[nom : %s]\n", v5);
printf("[prenom : %s]\n", v2[1]);
printf("[login : %s]\n", v2[2]);
}
else
{
for ( i = 0; i != v4; ++i )
{
while ( v3 != i )
{
++i;
printf("| ");
if ( i == v4 )
goto LABEL_8;
}
printf("|--> ");
}
LABEL_8:
v7 = 0;
printf("[nom : %s]\n", *v2);
do
{
++v7;
printf("| ");
}
while ( v7 != v4 );
v8 = 0;
printf("[prenom : %s]\n", v2[1]);
do
{
++v8;
printf("| ");
}
while ( v8 != v4 );
v9 = 0;
printf("[login : %s]\n", v2[2]);
do
{
++v9;
printf("| ");
}
while ( v9 != v4 );
}
result = printf("[mot de passe : %s]\n", v2[3]);
v11 = v2[4];
if ( v11 )
result = func0(v11, (unsigned int)(v4 + 1));
v2 = (const char **)v2[5];
++v3;
if ( !v2 )
return result;
v5 = *v2;
++v4;
if ( !*v2 )
return puts("Il n'y a aucune fiche !");
}
}

original_code:
void affichage (noeud_t * r, int prof)
{
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        int i = 0;
        for (i=0; i<prof; i++)
        {
            if (i != prof - 1)
            {
                printf("|    ");
            }
            else
            {
                printf("|--> ");
            }
        }
        printf("[nom : %s]\n",(*r).nom);
        for (i=0; i<prof; i++)
        {
            printf("|    ");
        }
        printf("[prenom : %s]\n",(*r).prenom);
        for (i=0; i<prof; i++)
        {
            printf("|    ");
        }
        printf("[login : %s]\n",(*r).login);
        for (i=0; i<prof; i++)
        {
            printf("|    ");
        }
        printf("[mot de passe : %s]\n",(*r).mdp);
        if ((*r).g)
        {
            affichage((*r).g,prof + 1);
        }
        if ((*r).d)
        {
            affichage((*r).d,prof + 1);
        }
    }
    else
    {
        printf("Il n'y a aucune fiche !\n");
    }
}

canonical_original_code:
void affichage(struct noeud *r, int prof)
{
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        int i = 0;
        for (i=0; i<prof; i++)
        {
            if (i != prof - 1)
            {
                printf("|    ");
            }
            else
            {
                printf("|--> ");
            }
        }
        printf("[nom : %s]\n",(*r).nom);
        for (i=0; i<prof; i++)
        {
            printf("|    ");
        }
        printf("[prenom : %s]\n",(*r).prenom);
        for (i=0; i<prof; i++)
        {
            printf("|    ");
        }
        printf("[login : %s]\n",(*r).login);
        for (i=0; i<prof; i++)
        {
            printf("|    ");
        }
        printf("[mot de passe : %s]\n",(*r).mdp);
        if ((*r).g)
        {
            affichage((*r).g,prof + 1);
        }
        if ((*r).d)
        {
            affichage((*r).d,prof + 1);
        }
    }
    else
    {
        printf("Il n'y a aucune fiche !\n");
    }
}

variable_types: struct noeud { char *nom; char *prenom; char *login; char *mdp; struct noeud *g; struct noeud *d; } *

variable_types: prof int


liberation

original_code:
void liberation (noeud_t ** pracine)
{
    noeud_t ** cour = pracine;
    if ((cour != ((void *)0)) && (*cour != ((void *)0)) && ((**cour).nom != ((void *)0)))
    {
        if ((**cour).g != ((void *)0))
        {
            liberation(&(**cour).g);
        }
        if ((**cour).d != ((void *)0))
        {
            liberation(&(**cour).d);
        }
        free((**cour).nom);
        free((**cour).prenom);
        free((**cour).login);
        free((**cour).mdp);
    }
}

canonical_original_code:
void liberation(struct noeud **pracine)
{
    struct noeud **cour = pracine;
    if ((cour != ((void *)0)) && (*cour != ((void *)0)) && ((**cour).nom != ((void *)0)))
    {
        if ((**cour).g != ((void *)0))
        {
            liberation(&(**cour).g);
        }
        if ((**cour).d != ((void *)0))
        {
            liberation(&(**cour).d);
        }
        free((**cour).nom);
        free((**cour).prenom);
        free((**cour).login);
        free((**cour).mdp);
    }
}

variable_types: struct noeud { char *nom; char *prenom; char *login; char *mdp; struct noeud *g; struct noeud *d; } **


inserer

decompiled_code:
void __fastcall inserer(_QWORD *a1, const char **a2)
{
const char ***v2; // rax
const char **v3; // rbp
int v4; // eax
const char **v5; // rdx
const char ***v6; // rbp

if ( a2 )
{
v2 = (const char ***)recherche(a1, a2);
v3 = *v2;
if ( *v2 && *v3 )
{
v4 = strcmp(*v3, *a2);
if ( v4 || (v4 = strcmp(v3[1], a2[1])) != 0 )
{
v5 = v3 + 4;
v6 = (const char ***)(v3 + 5);
if ( v4 > 0 )
v6 = (const char ***)v5;
*v6 = a2;
}
else
{
puts(aCetUtilisateur);
}
}
else
{
*v2 = a2;
}
}
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1, const char **a2)
{
const char ***v2; // rax
const char **v3; // rbp
int v4; // eax
const char **v5; // rdx
const char ***v6; // rbp

if ( a2 )
{
v2 = (const char ***)recherche(a1, a2);
v3 = *v2;
if ( *v2 && *v3 )
{
v4 = strcmp(*v3, *a2);
if ( v4 || (v4 = strcmp(v3[1], a2[1])) != 0 )
{
v5 = v3 + 4;
v6 = (const char ***)(v3 + 5);
if ( v4 > 0 )
v6 = (const char ***)v5;
*v6 = a2;
}
else
{
puts(aCetUtilisateur);
}
}
else
{
*v2 = a2;
}
}
}

original_code:
void inserer (noeud_t ** pracine, noeud_t * saisie_t)
{
    noeud_t ** cour;
    int comp_nom = 0;
    int comp_prenom = 0;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        if (((*cour) == ((void *)0)) || ((**cour).nom == ((void *)0)))
        {
            *cour = saisie_t;
        }
        else
        {
            comp_nom = strcmp((**cour).nom,(*saisie_t).nom);
            comp_prenom = strcmp((**cour).prenom,(*saisie_t).prenom);
            if (comp_nom == 0)
            {
                if (comp_prenom == 0)
                {
                    printf("Cet utilisateur est déjà inscrit !\n");
                    cour = ((void *)0);
                }
                else if (comp_prenom > 0)
                {
                    cour = &(**cour).g;
                }
                else
                {
                    cour = &(**cour).d;
                }
            }
            else if (comp_nom > 0)
            {
                cour = &(**cour).g;
            }
            else
            {
                cour = &(**cour).d;
            }
            if (cour != ((void *)0))
            {
                *cour = saisie_t;
            }
        }
    }
}

canonical_original_code:
void inserer(struct noeud **pracine, struct noeud *saisie_t)
{
    struct noeud **cour;
    int comp_nom = 0;
    int comp_prenom = 0;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        if (((*cour) == ((void *)0)) || ((**cour).nom == ((void *)0)))
        {
            *cour = saisie_t;
        }
        else
        {
            comp_nom = strcmp((**cour).nom,(*saisie_t).nom);
            comp_prenom = strcmp((**cour).prenom,(*saisie_t).prenom);
            if (comp_nom == 0)
            {
                if (comp_prenom == 0)
                {
                    printf("Cet utilisateur est déjà inscrit !\n");
                    cour = ((void *)0);
                }
                else if (comp_prenom > 0)
                {
                    cour = &(**cour).g;
                }
                else
                {
                    cour = &(**cour).d;
                }
            }
            else if (comp_nom > 0)
            {
                cour = &(**cour).g;
            }
            else
            {
                cour = &(**cour).d;
            }
            if (cour != ((void *)0))
            {
                *cour = saisie_t;
            }
        }
    }
}

user_defined_types: struct noeud { char *nom; char *prenom; char *login; char *mdp; struct noeud *g; struct noeud *d; }


supprAux

decompiled_code:
__int64 __fastcall supprAux(_QWORD *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( a2 )
{
v2 = a2;
do
{
inserer(a1, (const char **)v2);
result = supprAux(a1, *(_QWORD *)(v2 + 40));
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( a2 )
{
v2 = a2;
do
{
func3(a1, (const char **)v2);
result = func4(a1, *(_QWORD *)(v2 + 40));
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
return result;
}

original_code:
void supprAux (noeud_t ** pracine, noeud_t * r)
{
    if (r != ((void *)0))
    {
        inserer(pracine,r);
        supprAux(pracine,(*r).d);
        supprAux(pracine,(*r).g);
    }
}

canonical_original_code:
void supprAux(struct noeud **pracine, struct noeud *r)
{
    if (r != ((void *)0))
    {
        inserer(pracine,r);
        supprAux(pracine,(*r).d);
        supprAux(pracine,(*r).g);
    }
}

variable_types:
r
struct noeud *


suppression

decompiled_code:
void __fastcall suppression(_QWORD *a1, const char **a2)
{
void **v2; // rbp
void *v3; // r13
char *v4; // r14
__int64 v5; // r15
__int64 v6; // r13

if ( a2 )
{
v2 = (void **)recherche(a1, a2);
free(a2);
v3 = *v2;
if ( *v2 )
{
v4 = *(char **)v3;
if ( *(_QWORD *)v3 )
{
if ( !strcmp(*(const char **)v3, *a2) && !strcmp(*((const char **)v3 + 1), a2[1]) )
{
v5 = *((_QWORD *)v3 + 5);
v6 = *((_QWORD *)v3 + 4);
free(v4);
free(*((void **)*v2 + 1));
free(*((void **)*v2 + 2));
free(*((void **)*v2 + 3));
free(*v2);
*v2 = 0LL;
supprAux(a1, v5);
supprAux(a1, v6);
}
else
{
puts("Cette fiche n'existe pas !");
}
}
}
}
}

original_code:
void suppression (noeud_t ** pracine, noeud_t * saisie_t)
{
    noeud_t ** cour;
    noeud_t * dracine;
    noeud_t * gracine;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        free(saisie_t);
        if ((*cour != ((void *)0)) && ((**cour).nom != ((void *)0)))
        {
            if ((strcmp((**cour).nom,(*saisie_t).nom) == 0) && (strcmp((**cour).prenom,(*saisie_t).prenom) == 0))
            {
                dracine = (**cour).d;
                gracine = (**cour).g;
                free((**cour).nom);
                free((**cour).prenom);
                free((**cour).login);
                free((**cour).mdp);
                free(*cour);
                *cour = ((void *)0);
                supprAux(pracine,dracine);
                supprAux(pracine,gracine);
            }
            else
            {
                printf("Cette fiche n'existe pas !\n");
            }
        }
    }
}

canonical_original_code:
void suppression(struct noeud **pracine, struct noeud *saisie_t)
{
    struct noeud **cour;
    struct noeud *dracine;
    struct noeud *gracine;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        free(saisie_t);
        if ((*cour != ((void *)0)) && ((**cour).nom != ((void *)0)))
        {
            if ((strcmp((**cour).nom,(*saisie_t).nom) == 0) && (strcmp((**cour).prenom,(*saisie_t).prenom) == 0))
            {
                dracine = (**cour).d;
                gracine = (**cour).g;
                free((**cour).nom);
                free((**cour).prenom);
                free((**cour).login);
                free((**cour).mdp);
                free(*cour);
                *cour = ((void *)0);
                supprAux(pracine,dracine);
                supprAux(pracine,gracine);
            }
            else
            {
                printf("Cette fiche n'existe pas !\n");
            }
        }
    }
}


miseAJour

decompiled_code:
void __fastcall miseAJour(_QWORD *a1, const char **a2)
{
const char ***v2; // rbx
const char **v3; // rax
char *v4; // r13
const char *v5; // r14
char v6[41]; // [rsp+1h] [rbp-29h] BYREF

if ( a2 )
{
v2 = (const char ***)recherche(a1, a2);
v3 = *v2;
if ( *v2 && (v4 = (char *)*v3) != 0LL && (v5 = *a2, !strcmp(*v3, *a2)) )
{
strcpy(v4, v5);
strcpy((char *)(*v2)[1], a2[1]);
strcpy((char *)(*v2)[2], a2[2]);
strcpy((char *)(*v2)[3], a2[3]);
}
else
{
puts(aLaFiche);
printf(aVoulezVousEnIn);
fflush(stdout);
scanf("%c%*c", v6);
if ( (v6[0] & 0xDF) == 79 )
inserer(a1, a2);
}
}
}

canonical_decompiled_code:
void __fastcall func6(_QWORD *a1, const char **a2)
{
const char ***v2; // rbx
const char **v3; // rax
char *v4; // r13
const char *v5; // r14
char v6[41]; // [rsp+1h] [rbp-29h] BYREF

if ( a2 )
{
v2 = (const char ***)recherche(a1, a2);
v3 = *v2;
if ( *v2 && (v4 = (char *)*v3) != 0LL && (v5 = *a2, !strcmp(*v3, *a2)) )
{
strcpy(v4, v5);
strcpy((char *)(*v2)[1], a2[1]);
strcpy((char *)(*v2)[2], a2[2]);
strcpy((char *)(*v2)[3], a2[3]);
}
else
{
puts(aLaFiche);
printf(aVoulezVousEnIn);
fflush(stdout);
scanf("%c%*c", v6);
if ( (v6[0] & 0xDF) == 79 )
func3(a1, a2);
}
}
}

original_code:
void miseAJour (noeud_t ** pracine, noeud_t * saisie_t)
{
    noeud_t ** cour;
    char choix_t;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        if (((*cour) == ((void *)0)) || ((**cour).nom == ((void *)0)) || ((strcmp((**cour).nom,(*saisie_t).nom)) != 0))
        {
            printf("La fiche à mettre à jour n'existe pas !\n");
            printf("Voulez-vous en insérer une nouvelle ? ([O]ui/[N]on) ");
            fflush(stdout);
            scanf("%c%*c",&choix_t);
            if ((choix_t == 'O') || (choix_t == 'o'))
            {
                inserer(pracine,saisie_t);
            }
        }
        else
        {
            strcpy((**cour).nom,(*saisie_t).nom);
            strcpy((**cour).prenom,(*saisie_t).prenom);
            strcpy((**cour).login,(*saisie_t).login);
            strcpy((**cour).mdp,(*saisie_t).mdp);
        }
    }
}

canonical_original_code:
void miseAJour(struct noeud **pracine, struct noeud *saisie_t)
{
    struct noeud **cour;
    char choix_t;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        if (((*cour) == ((void *)0)) || ((**cour).nom == ((void *)0)) || ((strcmp((**cour).nom,(*saisie_t).nom)) != 0))
        {
            printf("La fiche à mettre à jour n'existe pas !\n");
            printf("Voulez-vous en insérer une nouvelle ? ([O]ui/[N]on) ");
            fflush(stdout);
            scanf("%c%*c",&choix_t);
            if ((choix_t == 'O') || (choix_t == 'o'))
            {
                inserer(pracine,saisie_t);
            }
        }
        else
        {
            strcpy((**cour).nom,(*saisie_t).nom);
            strcpy((**cour).prenom,(*saisie_t).prenom);
            strcpy((**cour).login,(*saisie_t).login);
            strcpy((**cour).mdp,(*saisie_t).mdp);
        }
    }
}


rechercheNom

decompiled_code:
void __fastcall rechercheNom(__int64 a1, const char *a2)
{
__int64 v2; // rbx
const char *v3; // rbp

if ( a1 )
{
v2 = a1;
do
{
v3 = *(const char **)v2;
if ( !*(_QWORD *)v2 )
break;
if ( !strcmp(*(const char **)v2, a2) )
{
printf("[nom : %s]\n", v3);
printf("[prenom : %s]\n", *(const char **)(v2 + 8));
printf("[login : %s]\n", *(const char **)(v2 + 16));
printf("[mdp : %s]\n", *(const char **)(v2 + 24));
putchar(10);
}
rechercheNom(*(_QWORD *)(v2 + 40), a2);
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, const char *a2)
{
__int64 v2; // rbx
const char *v3; // rbp

if ( a1 )
{
v2 = a1;
do
{
v3 = *(const char **)v2;
if ( !*(_QWORD *)v2 )
break;
if ( !strcmp(*(const char **)v2, a2) )
{
printf("[nom : %s]\n", v3);
printf("[prenom : %s]\n", *(const char **)(v2 + 8));
printf("[login : %s]\n", *(const char **)(v2 + 16));
printf("[mdp : %s]\n", *(const char **)(v2 + 24));
putchar(10);
}
func7(*(_QWORD *)(v2 + 40), a2);
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
}

original_code:
void rechercheNom (noeud_t * r,char * nom_t)
{
    int comp_nom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_nom = strcmp((*r).nom,nom_t);
        if (comp_nom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        rechercheNom((*r).d,nom_t);
        rechercheNom((*r).g,nom_t);
    }
}

canonical_original_code:
void rechercheNom(struct noeud *r, char *nom_t)
{
    int comp_nom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_nom = strcmp((*r).nom,nom_t);
        if (comp_nom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        rechercheNom((*r).d,nom_t);
        rechercheNom((*r).g,nom_t);
    }
}


recherchePrenom

decompiled_code:
void __fastcall recherchePrenom(__int64 a1, const char *a2)
{
__int64 v2; // rbx
const char *v3; // r12

if ( a1 )
{
v2 = a1;
do
{
v3 = *(const char **)v2;
if ( !*(_QWORD *)v2 )
break;
if ( !strcmp(*(const char **)(v2 + 8), a2) )
{
printf("[nom : %s]\n", v3);
printf("[prenom : %s]\n", *(const char **)(v2 + 8));
printf("[login : %s]\n", *(const char **)(v2 + 16));
printf("[mdp : %s]\n", *(const char **)(v2 + 24));
putchar(10);
}
recherchePrenom(*(_QWORD *)(v2 + 40), a2);
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, const char *a2)
{
__int64 v2; // rbx
const char *v3; // r12

if ( a1 )
{
v2 = a1;
do
{
v3 = *(const char **)v2;
if ( !*(_QWORD *)v2 )
break;
if ( !strcmp(*(const char **)(v2 + 8), a2) )
{
printf("[nom : %s]\n", v3);
printf("[prenom : %s]\n", *(const char **)(v2 + 8));
printf("[login : %s]\n", *(const char **)(v2 + 16));
printf("[mdp : %s]\n", *(const char **)(v2 + 24));
putchar(10);
}
func8(*(_QWORD *)(v2 + 40), a2);
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
}

original_code:
void recherchePrenom (noeud_t * r, char * prenom_t)
{
    int comp_prenom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_prenom = strcmp((*r).prenom,prenom_t);
        if (comp_prenom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        recherchePrenom((*r).d,prenom_t);
        recherchePrenom((*r).g,prenom_t);
    }
}

canonical_original_code:
void recherchePrenom(struct noeud *r, char *prenom_t)
{
    int comp_prenom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_prenom = strcmp((*r).prenom,prenom_t);
        if (comp_prenom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        recherchePrenom((*r).d,prenom_t);
        recherchePrenom((*r).g,prenom_t);
    }
}


original_code:
void affiche_menu ()
{
    printf("\n");
    printf("#-------------------------------#\n");
    printf("#      Gestion de fichiers      #\n");
    printf("#                               #\n");
    printf("# 0 -> Quitter                  #\n");
    printf("# 1 -> Affichage                #\n");
    printf("# 2 -> Insertion/Mise a jour    #\n");
    printf("# 3 -> Suppression              #\n");
    printf("# 4 -> Recherche                #\n");
    printf("# 5 -> Ecriture                 #\n");
    printf("# 6 -> Lecture                  #\n");
    printf("# 7 -> Liberation               #\n");
    printf("#-------------------------------#\n");
    printf("\n");
}

canonical_original_code:
void affiche_menu()
{
    printf("\n");
    printf("#-------------------------------#\n");
    printf("#      Gestion de fichiers      #\n");
    printf("#                               #\n");
    printf("# 0 -> Quitter                  #\n");
    printf("# 1 -> Affichage                #\n");
    printf("# 2 -> Insertion/Mise a jour    #\n");
    printf("# 3 -> Suppression              #\n");
    printf("# 4 -> Recherche                #\n");
    printf("# 5 -> Ecriture                 #\n");
    printf("# 6 -> Lecture                  #\n");
    printf("# 7 -> Liberation               #\n");
    printf("#-------------------------------#\n");
    printf("\n");
}


saisie

decompiled_code:
char **saisie()
{
char **v0; // rax
char **v1; // r12
size_t v2; // rax
bool v3; // zf
char *v4; // rax
char *v5; // r15
char *v6; // rax
char *v7; // r14
char *v8; // rax
char *v9; // r13
char *v10; // rax
char *v11; // rbp
char v13; // [rsp+1h] [rbp-A9h]
char v14[32]; // [rsp+2h] [rbp-A8h] BYREF
char s[32]; // [rsp+22h] [rbp-88h] BYREF
char src[32]; // [rsp+42h] [rbp-68h] BYREF
char v17[72]; // [rsp+62h] [rbp-48h] BYREF

v0 = (char **)malloc(0x30uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
v0[5] = 0LL;
v0[4] = 0LL;
printf("Quel nom ? ");
fflush(stdout);
fgets(v14, 32, stdin);
*(&v13 + strlen(v14)) = 0;
printf(aQuelPr);
fflush(stdout);
fgets(s, 32, stdin);
v14[strlen(s) + 31] = 0;
printf("Quel login ? ");
fflush(stdout);
fgets(src, 32, stdin);
s[strlen(src) + 31] = 0;
printf("Quel mot de passe ? ");
fflush(stdout);
fgets(v17, 32, stdin);
v2 = strlen(v17);
v3 = s[0] == 0;
src[v2 + 31] = 0;
if ( v3 || !v14[0] )
{
v1 = 0LL;
puts(::s);
}
else
{
v4 = (char *)malloc(0x20uLL);
*v1 = v4;
v5 = v4;
v6 = (char *)malloc(0x20uLL);
v1[1] = v6;
v7 = v6;
v8 = (char *)malloc(0x20uLL);
v1[2] = v8;
v9 = v8;
v10 = (char *)malloc(0x20uLL);
v1[3] = v10;
v11 = v10;
if ( v9 == 0LL || v7 == 0LL || v5 == 0LL || !v10 )
{
puts("Allocation impossible !");
}
else
{
strcpy(v5, v14);
strcpy(v7, s);
strcpy(v9, src);
strcpy(v11, v17);
v1[4] = 0LL;
v1[5] = 0LL;
}
}
}
else
{
puts(aLAlloctionA);
}
return v1;
}

canonical_decompiled_code:
char **func2()
{
char **v0; // rax
char **v1; // r12
size_t v2; // rax
bool v3; // zf
char *v4; // rax
char *v5; // r15
char *v6; // rax
char *v7; // r14
char *v8; // rax
char *v9; // r13
char *v10; // rax
char *v11; // rbp
char v13; // [rsp+1h] [rbp-A9h]
char v14[32]; // [rsp+2h] [rbp-A8h] BYREF
char s[32]; // [rsp+22h] [rbp-88h] BYREF
char src[32]; // [rsp+42h] [rbp-68h] BYREF
char v17[72]; // [rsp+62h] [rbp-48h] BYREF

v0 = (char **)malloc(0x30uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
v0[5] = 0LL;
v0[4] = 0LL;
printf("Quel nom ? ");
fflush(stdout);
fgets(v14, 32, stdin);
*(&v13 + strlen(v14)) = 0;
printf(aQuelPr);
fflush(stdout);
fgets(s, 32, stdin);
v14[strlen(s) + 31] = 0;
printf("Quel login ? ");
fflush(stdout);
fgets(src, 32, stdin);
s[strlen(src) + 31] = 0;
printf("Quel mot de passe ? ");
fflush(stdout);
fgets(v17, 32, stdin);
v2 = strlen(v17);
v3 = s[0] == 0;
src[v2 + 31] = 0;
if ( v3 || !v14[0] )
{
v1 = 0LL;
puts(::s);
}
else
{
v4 = (char *)malloc(0x20uLL);
*v1 = v4;
v5 = v4;
v6 = (char *)malloc(0x20uLL);
v1[1] = v6;
v7 = v6;
v8 = (char *)malloc(0x20uLL);
v1[2] = v8;
v9 = v8;
v10 = (char *)malloc(0x20uLL);
v1[3] = v10;
v11 = v10;
if ( v9 == 0LL || v7 == 0LL || v5 == 0LL || !v10 )
{
puts("Allocation impossible !");
}
else
{
strcpy(v5, v14);
strcpy(v7, s);
strcpy(v9, src);
strcpy(v11, v17);
v1[4] = 0LL;
v1[5] = 0LL;
}
}
}
else
{
puts(aLAlloctionA);
}
return v1;
}

original_code:
noeud_t * saisie ()
{
    noeud_t * saisie_t;
    char nom[32];
    char prenom[32];
    char login[32];
    char mdp[32];
    saisie_t = (noeud_t *) malloc(sizeof(noeud_t));
    if (saisie_t == ((void *)0))
    {
        printf("L'alloction a échoué !\n");
    }
    else
    {
        (*saisie_t).nom = ((void *)0);
        (*saisie_t).prenom = ((void *)0);
        (*saisie_t).d = ((void *)0);
        (*saisie_t).g = ((void *)0);
        printf("Quel nom ? ");
        fflush(stdout);
        fgets(nom, 32, stdin);
        nom[strlen(nom) - 1] = '\0';
        printf("Quel prénom ? ");
        fflush(stdout);
        fgets(prenom, 32, stdin);
        prenom[strlen(prenom) - 1] = '\0';
        printf("Quel login ? ");
        fflush(stdout);
        fgets(login, 32, stdin);
        login[strlen(login) - 1] = '\0';
        printf("Quel mot de passe ? ");
        fflush(stdout);
        fgets(mdp, 32, stdin);
        mdp[strlen(mdp) - 1] = '\0';
        if ((strcmp(prenom,"\0") != 0) && (strcmp(nom,"\0") != 0))
        {
            (*saisie_t).nom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).prenom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).login = (char *) malloc(sizeof(char)*32);
            (*saisie_t).mdp = (char *) malloc(sizeof(char)*32);
            if (((*saisie_t).nom == ((void *)0)) || ((*saisie_t).prenom == ((void *)0)) || ((*saisie_t).login == ((void *)0)) || ((*saisie_t).mdp == ((void *)0)))
            {
                printf("Allocation impossible !\n");
            }
            else
            {
                strcpy((*saisie_t).nom,nom);
                strcpy((*saisie_t).prenom,prenom);
                strcpy((*saisie_t).login,login);
                strcpy((*saisie_t).mdp,mdp);
                (*saisie_t).g = ((void *)0);
                (*saisie_t).d = ((void *)0);
            }
        }
        else
        {
            printf("Fiche incomplète !\n");
            saisie_t = ((void *)0);
        }
    }
    return saisie_t;
}

canonical_original_code:
struct noeud *saisie()
{
    struct noeud *saisie_t;
    char nom[32];
    char prenom[32];
    char login[32];
    char mdp[32];
    saisie_t = (struct noeud *) malloc(sizeof(noeud_t));
    if (saisie_t == ((void *)0))
    {
        printf("L'alloction a échoué !\n");
    }
    else
    {
        (*saisie_t).nom = ((void *)0);
        (*saisie_t).prenom = ((void *)0);
        (*saisie_t).d = ((void *)0);
        (*saisie_t).g = ((void *)0);
        printf("Quel nom ? ");
        fflush(stdout);
        fgets(nom, 32, stdin);
        nom[strlen(nom) - 1] = '\0';
        printf("Quel prénom ? ");
        fflush(stdout);
        fgets(prenom, 32, stdin);
        prenom[strlen(prenom) - 1] = '\0';
        printf("Quel login ? ");
        fflush(stdout);
        fgets(login, 32, stdin);
        login[strlen(login) - 1] = '\0';
        printf("Quel mot de passe ? ");
        fflush(stdout);
        fgets(mdp, 32, stdin);
        mdp[strlen(mdp) - 1] = '\0';
        if ((strcmp(prenom,"\0") != 0) && (strcmp(nom,"\0") != 0))
        {
            (*saisie_t).nom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).prenom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).login = (char *) malloc(sizeof(char)*32);
            (*saisie_t).mdp = (char *) malloc(sizeof(char)*32);
            if (((*saisie_t).nom == ((void *)0)) || ((*saisie_t).prenom == ((void *)0)) || ((*saisie_t).login == ((void *)0)) || ((*saisie_t).mdp == ((void *)0)))
            {
                printf("Allocation impossible !\n");
            }
            else
            {
                strcpy((*saisie_t).nom,nom);
                strcpy((*saisie_t).prenom,prenom);
                strcpy((*saisie_t).login,login);
                strcpy((*saisie_t).mdp,mdp);
                (*saisie_t).g = ((void *)0);
                (*saisie_t).d = ((void *)0);
            }
        }
        else
        {
            printf("Fiche incomplète !\n");
            saisie_t = ((void *)0);
        }
    }
    return saisie_t;
}

variable_types:
nom
char [32]

variable_types:
prenom
char [32]

variable_types:
login
char [32]

variable_types:
mdp
char [32]

return_type: struct noeud { char *nom; char *prenom; char *login; char *mdp; struct noeud *g; struct noeud *d; } *


InsertionBil

original_code:
bilatere_t ** InsertionBil(bilatere_t ** b, bilatere_t * elt)
{
    elt->suiv = (**b).suiv;
    elt->prec = *b;
    (*b)->suiv->prec = elt;
    (*b)->suiv = elt;
    return &(**b).suiv;
}

canonical_original_code:
struct struct4 **InsertionBil(struct struct4 **b, struct struct4 *elt)
{
    elt->suiv = (**b).suiv;
    elt->prec = *b;
    (*b)->suiv->prec = elt;
    (*b)->suiv = elt;
    return &(**b).suiv;
}

variable_types:
b
struct struct4 **

variable_types:
elt
struct struct4 *

return_type: struct struct4 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct4 *prec; struct struct4 *suiv; } **

user_defined_types: struct struct4 { char chaine_sem[7]; struct struct2 *action_s; struct struct4 *prec; struct struct4 *suiv; }