decompiled_code:
int __fastcall execute_command(__int64 a1, const char *a2)
{
size_t v2; // rax
int v3; // ebx
int result; // eax

printf(">> %s\n", a2);
v2 = strlen(a2);
v3 = scpi_execute_command(a1, a2, v2);
result = putchar(10);
if ( v3 == -1 )
{
scpi_queue_error(a1);
result = puts("<< Command not found.");
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1, const char *a2)
{
size_t v2; // rax
int v3; // ebx
int result; // eax

printf(">> %s\n", a2);
v2 = strlen(a2);
v3 = scpi_execute_command(a1, a2, v2);
result = putchar(10);
if ( v3 == -1 )
{
scpi_queue_error(a1);
result = puts("<< Command not found.");
}
return result;
}

original_code:
void execute_command(struct scpi_parser_context* ctx, char* str)
{
 scpi_error_t error;
 printf(">> %s\n", str);
 error = scpi_execute_command(ctx, str, strlen(str));
 putchar('\n');
 if(error == SCPI_COMMAND_NOT_FOUND)
 {
  struct scpi_error notfound_error;
  notfound_error.id = -100;
  notfound_error.description = "Command error;Command not found";
  notfound_error.length = strlen(notfound_error.description);
  scpi_queue_error(ctx, notfound_error);
  printf("<< Command not found.\n");
 }
}

canonical_original_code:
void execute_command(struct scpi_parser_context *ctx, char *str)
{
 enum scpi_error_codes error;
 printf(">> %s\n", str);
 error = scpi_execute_command(ctx, str, strlen(str));
 putchar('\n');
 if(error == SCPI_COMMAND_NOT_FOUND)
 {
  struct scpi_error notfound_error;
  notfound_error.id = -100;
  notfound_error.description = "Command error;Command not found";
  notfound_error.length = strlen(notfound_error.description);
  scpi_queue_error(ctx, notfound_error);
  printf("<< Command not found.\n");
 }
}

variable_types: enum scpi_error_codes { SCPI_SUCCESS=0, SCPI_COMMAND_NOT_FOUND=-1, SCPI_NO_CALLBACK=-2 }

variable_types: struct scpi_error { int id; char *description; unsigned long length; struct scpi_error *next; }


repo: LachlanGunn/oic

decompiled_code:
__int64 __fastcall print_command_tree(__int64 a1, int a2)
{
__int64 v2; // rbp
__int64 result; // rax
int i; // ebx

if ( a1 )
{
v2 = a1;
do
{
if ( *(_QWORD *)v2 )
{
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
putchar(9);
}
fwrite(*(const void **)v2, 1uLL, *(_QWORD *)(v2 + 8), stdout);
putchar(10);
}
result = print_command_tree(*(_QWORD *)(v2 + 40), (unsigned int)(a2 + 1));
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
__int64 v2; // rbp
__int64 result; // rax
int i; // ebx

if ( a1 )
{
v2 = a1;
do
{
if ( *(_QWORD *)v2 )
{
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
putchar(9);
}
fwrite(*(const void **)v2, 1uLL, *(_QWORD *)(v2 + 8), stdout);
putchar(10);
}
result = func7(*(_QWORD *)(v2 + 40), (unsigned int)(a2 + 1));
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
return result;
}

original_code:
void print_command_tree(struct scpi_command* list, int tabs)
{
 while(list != ((void *)0))
 {
  int i;
  if(list->long_name != ((void *)0))
  {
   for(i = 0; i < tabs; i++)
   {
    putchar('\t');
   }
   fwrite(list->long_name, 1, list->long_name_length, stdout);
   putchar('\n');
  }
  print_command_tree(list->children, tabs+1);
  list = list->next;
 }
}

canonical_original_code:
void print_command_tree(struct scpi_command *list, int tabs)
{
 while(list != ((void *)0))
 {
  int i;
  if(list->long_name != ((void *)0))
  {
   for(i = 0; i < tabs; i++)
   {
    putchar('\t');
   }
   fwrite(list->long_name, 1, list->long_name_length, stdout);
   putchar('\n');
  }
  print_command_tree(list->children, tabs+1);
  list = list->next;
 }
}

variable_types: struct scpi_command { char *long_name; unsigned long long_name_length; char *short_name; unsigned long short_name_length; struct scpi_command *next; struct scpi_command *children; enum scpi_error_codes { SCPI_SUCCESS=0, SCPI_COMMAND_NOT_FOUND=-1, SCPI_NO_CALLBACK=-2 } (*callback)(struct scpi_parser_context { struct scpi_command *command_tree; struct scpi_error { int id; char *description; unsigned long length; struct scpi_error *next; } *error_queue_head; struct scpi_error *error_queue_tail; } *, struct scpi_token { unsigned char type; char *value; unsigned long length; struct scpi_token *next; } *); } *

variable_types: tabs int

variable_types: i int

return_type: void

user_defined_types: struct scpi_command { char *long_name; unsigned long long_name_length; char *short_name; unsigned long short_name_length; struct scpi_command *next; struct scpi_command *children; enum scpi_error_codes (*callback)(struct scpi_parser_context *, struct scpi_token *); }

user_defined_types: struct scpi_parser_context { struct scpi_command *command_tree; struct scpi_error *error_queue_head; struct scpi_error *error_queue_tail; }


decompiled_code:
__int64 __fastcall print_single_command(__int64 a1)
{
const void *v2; // rdi

v2 = *(const void **)a1;
if ( v2 )
{
fwrite(v2, 1uLL, *(_QWORD *)(a1 + 8), stdout);
putchar(10);
}
return print_command_tree(*(_QWORD *)(a1 + 40), 1);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
const void *v2; // rdi

v2 = *(const void **)a1;
if ( v2 )
{
fwrite(v2, 1uLL, *(_QWORD *)(a1 + 8), stdout);
putchar(10);
}
return func7(*(_QWORD *)(a1 + 40), 1);
}

original_code:
void print_single_command(struct scpi_command* list)
{
 if(list->long_name != ((void *)0))
 {
  fwrite(list->long_name, 1, list->long_name_length, stdout);
  putchar('\n');
 }
 print_command_tree(list->children, 1);
}

canonical_original_code:
void print_single_command(struct scpi_command *list)
{
 if(list->long_name != ((void *)0))
 {
  fwrite(list->long_name, 1, list->long_name_length, stdout);
  putchar('\n');
 }
 print_command_tree(list->children, 1);
}

user_defined_types: enum scpi_error_codes { SCPI_SUCCESS=0, SCPI_COMMAND_NOT_FOUND=-1, SCPI_NO_CALLBACK=-2 }

user_defined_types: struct scpi_token { unsigned char type; char *value; unsigned long length; struct scpi_token *next; }

user_defined_types: struct scpi_error { int id; char *description; unsigned long length; struct scpi_error *next; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rbp
__int64 v7[7]; // [rsp+10h] [rbp-38h] BYREF

voltage = 0;
voltage_on = 0;
scpi_init(v7, argv, envp);
v3 = scpi_register_command(v7[0], 1LL, "MEASURE", 7LL, "MEAS", 4LL, 0LL);
puts("\nAssembling command tree:\n");
scpi_register_command(v7[0], 0LL, "*IDN?", 5LL, "*IDN?", 5LL, identify);
scpi_register_command(v3, 1LL, "VOLTAGE?", 8LL, "VOLT?", 5LL, measure_callback);
scpi_register_command(v3, 1LL, "FREQUENCY?", 10LL, "FREQ?", 5LL, 0LL);
v4 = scpi_register_command(v3, 0LL, "SOURCE", 6LL, "SOUR", 4LL, 0LL);
scpi_register_command(v4, 1LL, "VOLTAGE", 7LL, "VOLT", 4LL, set_voltage);
v5 = scpi_register_command(v3, 0LL, "OUTPUT", 6LL, "OUTP", 4LL, set_output);
scpi_register_command(v3, 0LL, "OUTPUT?", 7LL, "OUTP?", 5LL, get_output);
scpi_register_command(v5, 1LL, "STATE", 5LL, "STAT", 4LL, set_output);
scpi_register_command(v5, 1LL, "STATE?", 6LL, "STAT?", 5LL, get_output);
print_command_tree(v7[0], 0);
putchar(10);
execute_command((__int64)v7, "*IDN?");
execute_command((__int64)v7, ":MEASURE:VOLTAGE?");
execute_command((__int64)v7, ":SOURCE:VOLTAGE 15kV");
execute_command((__int64)v7, ":MEASURE:VOLTAGE?");
execute_command((__int64)v7, ":OUTPUT:STATE ON");
execute_command((__int64)v7, ":MEASURE:VOLTAGE?");
execute_command((__int64)v7, ":OUTPUT:STATE?");
execute_command((__int64)v7, ":OUTPUT OFF");
execute_command((__int64)v7, ":OUTPUT?");
execute_command((__int64)v7, ":SYSTEM:ERROR?");
execute_command((__int64)v7, ":CAUSE:AN:ERROR");
execute_command((__int64)v7, ":CAUSE:ANOTHER:ERROR");
execute_command((__int64)v7, ":SYSTEM:ERROR?");
execute_command((__int64)v7, ":SYSTEM:ERROR?");
execute_command((__int64)v7, ":SYSTEM:ERROR?");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rbp
__int64 v7[7]; // [rsp+10h] [rbp-38h] BYREF

voltage = 0;
voltage_on = 0;
scpi_init(v7, argv, envp);
v3 = scpi_register_command(v7[0], 1LL, "MEASURE", 7LL, "MEAS", 4LL, 0LL);
puts("\nAssembling command tree:\n");
scpi_register_command(v7[0], 0LL, "*IDN?", 5LL, "*IDN?", 5LL, identify);
scpi_register_command(v3, 1LL, "VOLTAGE?", 8LL, "VOLT?", 5LL, measure_callback);
scpi_register_command(v3, 1LL, "FREQUENCY?", 10LL, "FREQ?", 5LL, 0LL);
v4 = scpi_register_command(v3, 0LL, "SOURCE", 6LL, "SOUR", 4LL, 0LL);
scpi_register_command(v4, 1LL, "VOLTAGE", 7LL, "VOLT", 4LL, set_voltage);
v5 = scpi_register_command(v3, 0LL, "OUTPUT", 6LL, "OUTP", 4LL, set_output);
scpi_register_command(v3, 0LL, "OUTPUT?", 7LL, "OUTP?", 5LL, get_output);
scpi_register_command(v5, 1LL, "STATE", 5LL, "STAT", 4LL, set_output);
scpi_register_command(v5, 1LL, "STATE?", 6LL, "STAT?", 5LL, get_output);
func7(v7[0], 0);
putchar(10);
func6((__int64)v7, "*IDN?");
func6((__int64)v7, ":MEASURE:VOLTAGE?");
func6((__int64)v7, ":SOURCE:VOLTAGE 15kV");
func6((__int64)v7, ":MEASURE:VOLTAGE?");
func6((__int64)v7, ":OUTPUT:STATE ON");
func6((__int64)v7, ":MEASURE:VOLTAGE?");
func6((__int64)v7, ":OUTPUT:STATE?");
func6((__int64)v7, ":OUTPUT OFF");
func6((__int64)v7, ":OUTPUT?");
func6((__int64)v7, ":SYSTEM:ERROR?");
func6((__int64)v7, ":CAUSE:AN:ERROR");
func6((__int64)v7, ":CAUSE:ANOTHER:ERROR");
func6((__int64)v7, ":SYSTEM:ERROR?");
func6((__int64)v7, ":SYSTEM:ERROR?");
func6((__int64)v7, ":SYSTEM:ERROR?");
return 0;
}

original_code:
int main(int argc, char** argv)
{
 struct scpi_parser_context ctx;
 struct scpi_command* measure;
 struct scpi_command* source;
 struct scpi_command* output;
 voltage = 0;
 voltage_on = 0;
 scpi_init(&ctx);
 measure = scpi_register_command(ctx.command_tree, SCPI_CL_CHILD,
          "MEASURE", 7, "MEAS", 4, ((void *)0));
 printf("\nAssembling command tree:\n\n");
 scpi_register_command(ctx.command_tree, SCPI_CL_SAMELEVEL, "*IDN?", 5, "*IDN?", 5, identify);
 scpi_register_command(measure, SCPI_CL_CHILD, "VOLTAGE?", 8, "VOLT?", 5, measure_callback);
 scpi_register_command(measure, SCPI_CL_CHILD, "FREQUENCY?", 10, "FREQ?", 5, ((void *)0));
 source = scpi_register_command(measure, SCPI_CL_SAMELEVEL, "SOURCE", 6, "SOUR", 4, ((void *)0));
 scpi_register_command(source, SCPI_CL_CHILD, "VOLTAGE", 7, "VOLT", 4, set_voltage);
 output = scpi_register_command(measure, SCPI_CL_SAMELEVEL, "OUTPUT", 6, "OUTP", 4, set_output);
 scpi_register_command(measure, SCPI_CL_SAMELEVEL, "OUTPUT?", 7, "OUTP?", 5, get_output);
 scpi_register_command(output, SCPI_CL_CHILD, "STATE", 5, "STAT", 4, set_output);
 scpi_register_command(output, SCPI_CL_CHILD, "STATE?", 6, "STAT?", 5, get_output);
 print_command_tree(ctx.command_tree, 0);
 putchar('\n');
 execute_command(&ctx, "*IDN?");
 execute_command(&ctx, ":MEASURE:VOLTAGE?");
 execute_command(&ctx, ":SOURCE:VOLTAGE 15kV");
 execute_command(&ctx, ":MEASURE:VOLTAGE?");
 execute_command(&ctx, ":OUTPUT:STATE  ON");
 execute_command(&ctx, ":MEASURE:VOLTAGE?");
 execute_command(&ctx, ":OUTPUT:STATE?");
 execute_command(&ctx, ":OUTPUT OFF");
 execute_command(&ctx, ":OUTPUT?");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 execute_command(&ctx, ":CAUSE:AN:ERROR");
 execute_command(&ctx, ":CAUSE:ANOTHER:ERROR");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct scpi_parser_context ctx;
 struct scpi_command *measure;
 struct scpi_command *source;
 struct scpi_command *output;
 voltage = 0;
 voltage_on = 0;
 scpi_init(&ctx);
 measure = scpi_register_command(ctx.command_tree, SCPI_CL_CHILD,
          "MEASURE", 7, "MEAS", 4, ((void *)0));
 printf("\nAssembling command tree:\n\n");
 scpi_register_command(ctx.command_tree, SCPI_CL_SAMELEVEL, "*IDN?", 5, "*IDN?", 5, identify);
 scpi_register_command(measure, SCPI_CL_CHILD, "VOLTAGE?", 8, "VOLT?", 5, measure_callback);
 scpi_register_command(measure, SCPI_CL_CHILD, "FREQUENCY?", 10, "FREQ?", 5, ((void *)0));
 source = scpi_register_command(measure, SCPI_CL_SAMELEVEL, "SOURCE", 6, "SOUR", 4, ((void *)0));
 scpi_register_command(source, SCPI_CL_CHILD, "VOLTAGE", 7, "VOLT", 4, set_voltage);
 output = scpi_register_command(measure, SCPI_CL_SAMELEVEL, "OUTPUT", 6, "OUTP", 4, set_output);
 scpi_register_command(measure, SCPI_CL_SAMELEVEL, "OUTPUT?", 7, "OUTP?", 5, get_output);
 scpi_register_command(output, SCPI_CL_CHILD, "STATE", 5, "STAT", 4, set_output);
 scpi_register_command(output, SCPI_CL_CHILD, "STATE?", 6, "STAT?", 5, get_output);
 print_command_tree(ctx.command_tree, 0);
 putchar('\n');
 execute_command(&ctx, "*IDN?");
 execute_command(&ctx, ":MEASURE:VOLTAGE?");
 execute_command(&ctx, ":SOURCE:VOLTAGE 15kV");
 execute_command(&ctx, ":MEASURE:VOLTAGE?");
 execute_command(&ctx, ":OUTPUT:STATE  ON");
 execute_command(&ctx, ":MEASURE:VOLTAGE?");
 execute_command(&ctx, ":OUTPUT:STATE?");
 execute_command(&ctx, ":OUTPUT OFF");
 execute_command(&ctx, ":OUTPUT?");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 execute_command(&ctx, ":CAUSE:AN:ERROR");
 execute_command(&ctx, ":CAUSE:ANOTHER:ERROR");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 execute_command(&ctx, ":SYSTEM:ERROR?");
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct scpi_parser_context { struct scpi_command { char *long_name; unsigned long long_name_length; char *short_name; unsigned long short_name_length; struct scpi_command *next; struct scpi_command *children; enum scpi_error_codes { SCPI_SUCCESS=0, SCPI_COMMAND_NOT_FOUND=-1, SCPI_NO_CALLBACK=-2 } (*callback)(struct scpi_parser_context *, struct scpi_token { unsigned char type; char *value; unsigned long length; struct scpi_token *next; } *); } *command_tree; struct scpi_error { int id; char *description; unsigned long length; struct scpi_error *next; } *error_queue_head; struct scpi_error *error_queue_tail; }

return_type: int


addFileTower

decompiled_code:
__int64 __fastcall addFileTower(_QWORD *a1, int a2, int a3, __int64 a4, int a5, int a6)
{
_DWORD *v10; // rax
__int64 v11; // rdx
__int64 result; // rax

if ( a1 )
{
v10 = malloc(0x28uLL);
if ( v10 )
{
v10[2] = a3;
v10[3] = a5;
*(_QWORD *)v10 = a4;
v10[4] = a6;
v10[5] = a2;
*((_QWORD *)v10 + 4) = 0LL;
v11 = a1[2];
if ( v11 )
{
*((_QWORD *)v10 + 3) = v11;
*(_QWORD *)(v11 + 32) = v10;
}
else
{
a1[1] = v10;
*((_QWORD *)v10 + 3) = 0LL;
}
a1[2] = v10;
++*a1;
result = 1LL;
}
else
{
fwrite(&unk_FB8, 1uLL, 0x2FuLL, stderr);
result = 0LL;
}
}
else
{
fwrite("Cette liste de tours n'existe pas\n", 1uLL, 0x22uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, int a2, int a3, __int64 a4, int a5, int a6)
{
_DWORD *v10; // rax
__int64 v11; // rdx
__int64 result; // rax

if ( a1 )
{
v10 = malloc(0x28uLL);
if ( v10 )
{
v10[2] = a3;
v10[3] = a5;
*(_QWORD *)v10 = a4;
v10[4] = a6;
v10[5] = a2;
*((_QWORD *)v10 + 4) = 0LL;
v11 = a1[2];
if ( v11 )
{
*((_QWORD *)v10 + 3) = v11;
*(_QWORD *)(v11 + 32) = v10;
}
else
{
a1[1] = v10;
*((_QWORD *)v10 + 3) = 0LL;
}
a1[2] = v10;
++*a1;
result = 1LL;
}
else
{
fwrite(&unk_FB8, 1uLL, 0x2FuLL, stderr);
result = 0LL;
}
}
else
{
fwrite("Cette liste de tours n'existe pas\n", 1uLL, 0x22uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
int addFileTower(LFileTower* p_lfileTower, int power, int rate, char* type_tower, int range, int cost) {
 if (p_lfileTower != ((void *)0)) {
  FileTower* new_fileTower = malloc(sizeof(FileTower));
  if (new_fileTower != ((void *)0)) {
   new_fileTower->rate = rate;
   new_fileTower->range = range;
   new_fileTower->type_tower = type_tower;
   new_fileTower->cost = cost;
   new_fileTower->power = power;
   new_fileTower->p_next = ((void *)0);
   if (p_lfileTower->p_tail == ((void *)0)) {
    p_lfileTower->p_head = new_fileTower;
    new_fileTower->p_prev = ((void *)0);
   }
   else {
    new_fileTower->p_prev = p_lfileTower->p_tail;
    p_lfileTower->p_tail->p_next = new_fileTower;
   }
   p_lfileTower->p_tail = new_fileTower;
   p_lfileTower->length++;
  }
  else {
   fprintf(stderr, "Problème dans la creation de la nouvelle tour\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Cette liste de tours n'existe pas\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int addFileTower(struct struct_lfileTower *p_lfileTower, int power, int rate, char *type_tower, int range, int cost) {
 if (p_lfileTower != ((void *)0)) {
  struct struct_fileTower *new_fileTower = malloc(sizeof(FileTower));
  if (new_fileTower != ((void *)0)) {
   new_fileTower->rate = rate;
   new_fileTower->range = range;
   new_fileTower->type_tower = type_tower;
   new_fileTower->cost = cost;
   new_fileTower->power = power;
   new_fileTower->p_next = ((void *)0);
   if (p_lfileTower->p_tail == ((void *)0)) {
    p_lfileTower->p_head = new_fileTower;
    new_fileTower->p_prev = ((void *)0);
   }
   else {
    new_fileTower->p_prev = p_lfileTower->p_tail;
    p_lfileTower->p_tail->p_next = new_fileTower;
   }
   p_lfileTower->p_tail = new_fileTower;
   p_lfileTower->length++;
  }
  else {
   fprintf(stderr, "Problème dans la creation de la nouvelle tour\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Cette liste de tours n'existe pas\n");
  return 0;
 }
 return 1;
}

variable_types: struct struct_lfileTower { unsigned long length; struct struct_fileTower { char *type_tower; int rate; int range; int cost; int power; struct struct_fileTower *p_prev; struct struct_fileTower *p_next; } *p_head; struct struct_fileTower *p_tail; } *

variable_types: power int

variable_types: rate int

variable_types: range int

variable_types: cost int

user_defined_types: struct struct_lfileTower { unsigned long length; struct struct_fileTower *p_head; struct struct_fileTower *p_tail; }


freeAllFileTower

decompiled_code:
void __fastcall freeAllFileTower(_QWORD *a1)
{
_QWORD *i; // rsi

if ( *a1 )
{
for ( i = (_QWORD *)a1[1]; i; i = (_QWORD *)a1[1] )
a1 = removeFileTower(a1, i);
}
free(a1);
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
_QWORD *i; // rsi

if ( *a1 )
{
for ( i = (_QWORD *)a1[1]; i; i = (_QWORD *)a1[1] )
a1 = removeFileTower(a1, i);
}
free(a1);
}

original_code:
void freeAllFileTower (LFileTower* p_lfileTower) {
 if (p_lfileTower->length != 0) {
  while (p_lfileTower->p_head != ((void *)0)) {
   p_lfileTower = removeFileTower(p_lfileTower, p_lfileTower->p_head);
  }
 }
 free(p_lfileTower);
}

canonical_original_code:
void freeAllFileTower(struct struct_lfileTower *p_lfileTower) {
 if (p_lfileTower->length != 0) {
  while (p_lfileTower->p_head != ((void *)0)) {
   p_lfileTower = removeFileTower(p_lfileTower, p_lfileTower->p_head);
  }
 }
 free(p_lfileTower);
}

user_defined_types: struct struct_fileTower { char *type_tower; int rate; int range; int cost; int power; struct struct_fileTower *p_prev; struct struct_fileTower *p_next; }


ColorRGB

decompiled_code:
__m128i __fastcall ColorRGB(float a1, float a2)
{
__m128i v3; // [rsp+0h] [rbp-14h] BYREF

v3.m128i_i64[0] = __PAIR64__(LODWORD(a2), LODWORD(a1));
return _mm_loadl_epi64(&v3);
}

canonical_decompiled_code:
__m128i __fastcall func0(float a1, float a2)
{
__m128i v3; // [rsp+0h] [rbp-14h] BYREF

v3.m128i_i64[0] = __PAIR64__(LODWORD(a2), LODWORD(a1));
return _mm_loadl_epi64(&v3);
}

original_code:
Color3f ColorRGB(float r, float g, float b) {
 Color3f new_color;
 new_color.r = r;
 new_color.g = g;
 new_color.b = b;
 return new_color;
}

canonical_original_code:
struct struct_color ColorRGB(float r, float g, float b) {
 struct struct_color new_color;
 new_color.r = r;
 new_color.g = g;
 new_color.b = b;
 return new_color;
}

variable_types: r float

variable_types: g float

variable_types: b float

variable_types: struct struct_color { float r; float g; float b; }


max

decompiled_code:
float __fastcall max(float a1, float a2)
{
return fmaxf(a1, a2);
}

canonical_decompiled_code:
float __fastcall func1(float a1, float a2)
{
return fmaxf(a1, a2);
}

original_code:
float max(float limite, float color) {
 if(color < limite)
  return limite;
 else
  return color;
}

variable_types: limite float

variable_types: color float

return_type: float


min

decompiled_code:
float __fastcall min(float a1, float a2)
{
return fminf(a1, a2);
}

canonical_decompiled_code:
float __fastcall func2(float a1, float a2)
{
return fminf(a1, a2);
}

original_code:
float min(float limite, float color) {
 if(color > limite)
  return limite;
 else
  return color;
}


decompiled_code:
__int64 __fastcall convert_f32_to_uc8(float a1)
{
float v1; // xmm1_4

v1 = min(1.0, a1);
return (unsigned int)(int)(float)(max(0.0, v1) * 255.0);
}

canonical_decompiled_code:
__int64 __fastcall func3(float a1)
{
float v1; // xmm1_4

v1 = func2(1.0, a1);
return (unsigned int)(int)(float)(func1(0.0, v1) * 255.0);
}

original_code:
unsigned char convert_f32_to_uc8 (float color) {
 return 255 * max(0, min(1, color));
}

canonical_original_code:
unsigned char convert_f32_to_uc8(float color) {
 return 255 * max(0, min(1, color));
}

return_type: unsigned char


AddColors

decompiled_code:
__m128i __fastcall AddColors(double a1, double a2, double a3)
{
__m128i v4; // [rsp+24h] [rbp-14h] BYREF

*(float *)v4.m128i_i32 = *(float *)&a1 + *(float *)&a3;
*(float *)&v4.m128i_i32[1] = *((float *)&a1 + 1) + *((float *)&a3 + 1);
return _mm_loadl_epi64(&v4);
}

original_code:
Color3f AddColors(Color3f C1, Color3f C2){
 Color3f new_color;
 new_color.r = (C1.r) + (C2.r);
 new_color.g = (C1.g) + (C2.g);
 new_color.b = (C1.b) + (C2.b);
 return new_color;
}

canonical_original_code:
struct struct_color AddColors(struct struct_color C1, struct struct_color C2){
 struct struct_color new_color;
 new_color.r = (C1.r) + (C2.r);
 new_color.g = (C1.g) + (C2.g);
 new_color.b = (C1.b) + (C2.b);
 return new_color;
}

return_type: struct struct_color { float r; float g; float b; }


SubColors

decompiled_code:
__m128i __fastcall SubColors(double a1, double a2, double a3)
{
__m128i v4; // [rsp+24h] [rbp-14h] BYREF

*(float *)v4.m128i_i32 = *(float *)&a1 - *(float *)&a3;
*(float *)&v4.m128i_i32[1] = *((float *)&a1 + 1) - *((float *)&a3 + 1);
return _mm_loadl_epi64(&v4);
}

original_code:
Color3f SubColors(Color3f C1, Color3f C2){
 Color3f new_color;
 new_color.r = (C1.r) - (C2.r);
 new_color.g = (C1.g) - (C2.g);
 new_color.b = (C1.b) - (C2.b);
 return new_color;
}

canonical_original_code:
struct struct_color SubColors(struct struct_color C1, struct struct_color C2){
 struct struct_color new_color;
 new_color.r = (C1.r) - (C2.r);
 new_color.g = (C1.g) - (C2.g);
 new_color.b = (C1.b) - (C2.b);
 return new_color;
}

user_defined_types: struct struct_color { float r; float g; float b; }


MultColors

decompiled_code:
__m128i __fastcall MultColors(double a1, double a2, double a3)
{
__m128i v4; // [rsp+24h] [rbp-14h] BYREF

*(float *)v4.m128i_i32 = *(float *)&a1 * *(float *)&a3;
*(float *)&v4.m128i_i32[1] = *((float *)&a1 + 1) * *((float *)&a3 + 1);
return _mm_loadl_epi64(&v4);
}

original_code:
Color3f MultColors(Color3f C1, Color3f C2){
 Color3f new_color;
 new_color.r = (C1.r) * (C2.r);
 new_color.g = (C1.g) * (C2.g);
 new_color.b = (C1.b) * (C2.b);
 return new_color;
}

canonical_original_code:
struct struct_color MultColors(struct struct_color C1, struct struct_color C2){
 struct struct_color new_color;
 new_color.r = (C1.r) * (C2.r);
 new_color.g = (C1.g) * (C2.g);
 new_color.b = (C1.b) * (C2.b);
 return new_color;
}


DivColors

original_code:
Color3f DivColors(Color3f C1, Color3f C2){
 Color3f new_color;
 if((C2.r) == 0 || (C2.g) == 0 || (C2.b) == 0) {
  printf("Erreur : impossible de diviser par 0");
  return C1;
 }
 new_color.r = (C1.r) / (C2.r);
 new_color.g = (C1.g) / (C2.g);
 new_color.b = (C1.b) / (C2.b);
 return new_color;
}

canonical_original_code:
struct struct_color DivColors(struct struct_color C1, struct struct_color C2){
 struct struct_color new_color;
 if((C2.r) == 0 || (C2.g) == 0 || (C2.b) == 0) {
  printf("Erreur : impossible de diviser par 0");
  return C1;
 }
 new_color.r = (C1.r) / (C2.r);
 new_color.g = (C1.g) / (C2.g);
 new_color.b = (C1.b) / (C2.b);
 return new_color;
}


MultColor

decompiled_code:
__int64 __fastcall MultColor(double a1, double a2, float a3)
{
unsigned int v3; // xmm1_4

*(float *)&v3 = a3 * *((float *)&a1 + 1);
ColorRGB(a3 * *(float *)&a1, a3 * *((float *)&a1 + 1));
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(double a1, double a2, float a3)
{
unsigned int v3; // xmm1_4

*(float *)&v3 = a3 * *((float *)&a1 + 1);
func0(a3 * *(float *)&a1, a3 * *((float *)&a1 + 1));
return v3;
}

original_code:
Color3f MultColor(Color3f c1, float scal) {
    float r = c1.r * scal;
    float g = c1.g * scal;
    float b = c1.b * scal;
    Color3f c = ColorRGB(r, g, b);
    return c;
}

canonical_original_code:
struct struct_color MultColor(struct struct_color c1, float scal) {
    float r = c1.r * scal;
    float g = c1.g * scal;
    float b = c1.b * scal;
    struct struct_color c = ColorRGB(r, g, b);
    return c;
}

variable_types: scal float


DivColor

decompiled_code:
__int64 __fastcall DivColor(double a1, double a2, float a3)
{
float v3; // xmm1_4
float v4; // xmm3_4

if ( a3 == 0.0 )
{
v3 = 0.0;
v4 = 0.0;
}
else
{
v4 = *(float *)&a1 / a3;
v3 = *((float *)&a1 + 1) / a3;
}
ColorRGB(v4, v3);
return LODWORD(v3);
}

canonical_decompiled_code:
__int64 __fastcall func9(double a1, double a2, float a3)
{
float v3; // xmm1_4
float v4; // xmm3_4

if ( a3 == 0.0 )
{
v3 = 0.0;
v4 = 0.0;
}
else
{
v4 = *(float *)&a1 / a3;
v3 = *((float *)&a1 + 1) / a3;
}
func0(v4, v3);
return LODWORD(v3);
}

original_code:
Color3f DivColor(Color3f c1, float scal) {
 float r, g, b;
 if(scal != 0.0) {
  r = c1.r / scal;
 }
    else {
     r = 0.0;
    }
    if(scal != 0.0) {
     g = c1.g / scal;
    }
    else {
     g = 0.0;
    }
    if(scal != 0) {
     b = c1.b / scal;
    }
    else {
     b = 0.0;
    }
    Color3f c = ColorRGB(r, g, b);
    return c;
}

canonical_original_code:
struct struct_color DivColor(struct struct_color c1, float scal) {
 float r; float g; float b;
 if(scal != 0.0) {
  r = c1.r / scal;
 }
    else {
     r = 0.0;
    }
    if(scal != 0.0) {
     g = c1.g / scal;
    }
    else {
     g = 0.0;
    }
    if(scal != 0) {
     b = c1.b / scal;
    }
    else {
     b = 0.0;
    }
    struct struct_color c = ColorRGB(r, g, b);
    return c;
}


decompiled_code:
_QWORD *new_LMonster()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x18uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
v0[2] = 0LL;
}
else
{
fwrite("Erreur lors de l'allocation memoire de la liste de monstres\n", 1uLL, 0x3CuLL, stderr);
}
return v1;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x18uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
v0[2] = 0LL;
}
else
{
fwrite("Erreur lors de l'allocation memoire de la liste de monstres\n", 1uLL, 0x3CuLL, stderr);
}
return v1;
}

original_code:
LMonster* new_LMonster(void) {
 LMonster *p_lmonster = malloc(sizeof(LMonster));
 if (p_lmonster != ((void *)0)) {
  p_lmonster->length = 0;
  p_lmonster->p_head = ((void *)0);
  p_lmonster->p_tail = ((void *)0);
 }
 else {
  fprintf(stderr, "Erreur lors de l'allocation memoire de la liste de monstres\n");
  return ((void *)0);
 }
 return p_lmonster;
}

canonical_original_code:
struct struct_lmonster *new_LMonster() {
 struct struct_lmonster *p_lmonster = malloc(sizeof(LMonster));
 if (p_lmonster != ((void *)0)) {
  p_lmonster->length = 0;
  p_lmonster->p_head = ((void *)0);
  p_lmonster->p_tail = ((void *)0);
 }
 else {
  fprintf(stderr, "Erreur lors de l'allocation memoire de la liste de monstres\n");
  return ((void *)0);
 }
 return p_lmonster;
}

variable_types: struct struct_lmonster { unsigned long length; struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node { float x; float y; struct struct_node *p_next; } *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; } *p_head; struct struct_monster *p_tail; } *

user_defined_types: struct struct_lmonster { unsigned long length; struct struct_monster *p_head; struct struct_monster *p_tail; }

user_defined_types: struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; }


upgrateMonster

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

if ( a1 )
{
a1[13] += 50 * a2;
a1[12] += 50 * a2;
a1[14] += 10 * a2;
a1[15] += 2 * a2;
result = 1LL;
}
else
{
fwrite("Erreur ce monstre n'existe pas\n", 1uLL, 0x1FuLL, stderr);
result = 0LL;
}
return result;
}

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

if ( a1 )
{
a1[13] += 50 * a2;
a1[12] += 50 * a2;
a1[14] += 10 * a2;
a1[15] += 2 * a2;
result = 1LL;
}
else
{
fwrite("Erreur ce monstre n'existe pas\n", 1uLL, 0x1FuLL, stderr);
result = 0LL;
}
return result;
}

original_code:
int upgrateMonster (Monster* monster, int lvl) {
 if(monster != ((void *)0)) {
  monster->pvMax += lvl * 50;
  monster->pv += lvl * 50;
  monster->resistance += lvl * 10;
  monster->points += lvl * 2;
 }
 else {
  fprintf(stderr, "Erreur ce monstre n'existe pas\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int upgrateMonster(struct struct_monster *monster, int lvl) {
 if(monster != ((void *)0)) {
  monster->pvMax += lvl * 50;
  monster->pv += lvl * 50;
  monster->resistance += lvl * 10;
  monster->points += lvl * 2;
 }
 else {
  fprintf(stderr, "Erreur ce monstre n'existe pas\n");
  return 0;
 }
 return 1;
}

variable_types: struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node { float x; float y; struct struct_node *p_next; } *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; } *

variable_types: lvl int


calculErreur

original_code:
void calculErreur(Monster* monster) {
 if(monster->node_prev != ((void *)0) && monster->node_next != ((void *)0)) {
  if(monster->node_prev->x == monster->node_next->x) {
   monster->e = 0;
   if(monster->node_prev->y <= monster->node_next->y)
    monster->sens = 3;
   else
    monster->sens = 1;
  }
  else if(monster->node_prev->y == monster->node_next->y) {
   monster->e = 0;
   if(monster->node_prev->x <= monster->node_next->x)
    monster->sens = 2;
   else
    monster->sens = 4;
  }
  else {
   float dx = (monster->node_next->x) - (monster->node_prev->x);
   float dy = (monster->node_next->y) - (monster->node_prev->y);
   if(dx > 0) {
    if(dy > 0) {
     if(dx >= dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    else {
     if(dx >= -dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    monster->sens = 2;
   }
   else {
    if(dy > 0) {
     if(-dx >= dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    else {
     if(dx <= dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    monster->sens = 4;
   }
  }
 }
 else
  fprintf(stderr, "Erreur sur le pointeur du monstre\n");
}

canonical_original_code:
void calculErreur(struct struct_monster *monster) {
 if(monster->node_prev != ((void *)0) && monster->node_next != ((void *)0)) {
  if(monster->node_prev->x == monster->node_next->x) {
   monster->e = 0;
   if(monster->node_prev->y <= monster->node_next->y)
    monster->sens = 3;
   else
    monster->sens = 1;
  }
  else if(monster->node_prev->y == monster->node_next->y) {
   monster->e = 0;
   if(monster->node_prev->x <= monster->node_next->x)
    monster->sens = 2;
   else
    monster->sens = 4;
  }
  else {
   float dx = (monster->node_next->x) - (monster->node_prev->x);
   float dy = (monster->node_next->y) - (monster->node_prev->y);
   if(dx > 0) {
    if(dy > 0) {
     if(dx >= dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    else {
     if(dx >= -dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    monster->sens = 2;
   }
   else {
    if(dy > 0) {
     if(-dx >= dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    else {
     if(dx <= dy)
      monster->e = (monster->node_next->x) - (monster->node_prev->x);
     else
      monster->e = (monster->node_next->y) - (monster->node_prev->y);
    }
    monster->sens = 4;
   }
  }
 }
 else
  fprintf(stderr, "Erreur sur le pointeur du monstre\n");
}

variable_types: dx float

variable_types: dy float

user_defined_types: struct struct_node { float x; float y; struct struct_node *p_next; }


addMonster

original_code:
int addMonster(LMonster* p_lmonster, int lvl, char* type, int pvMax, int resistance, char* type_tower, int pace, int points, int gain, Node* p_head) {
 if (p_lmonster != ((void *)0)) {
  Monster* new_monster = malloc(sizeof(Monster));
  if (new_monster != ((void *)0)) {
   new_monster->type = type;
   new_monster->pvMax = pvMax;
   new_monster->pv = pvMax;
   new_monster->resistance = resistance;
   new_monster->type_tower = type_tower;
   new_monster->pace = pace;
   new_monster->points = points;
   new_monster->gain = gain;
   new_monster->animation = 0;
   new_monster->x = p_head->x;
   new_monster->y = p_head->y;
   new_monster->node_prev = p_head;
   new_monster->node_next = p_head->p_next;
   upgrateMonster (new_monster, lvl);
   calculErreur(new_monster);
   new_monster->p_next = ((void *)0);
   if (p_lmonster->p_tail == ((void *)0)) {
    p_lmonster->p_head = new_monster;
    new_monster->p_prev = ((void *)0);
   }
   else {
    new_monster->p_prev = p_lmonster->p_tail;
    p_lmonster->p_tail->p_next = new_monster;
   }
   p_lmonster->p_tail = new_monster;
   p_lmonster->length++;
  }
  else {
   fprintf(stderr, "Problème dans la creation du nouveau monstre\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Cette liste de monstres n'existe pas\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int addMonster(struct struct_lmonster *p_lmonster, int lvl, char *type, int pvMax, int resistance, char *type_tower, int pace, int points, int gain, struct struct_node *p_head) {
 if (p_lmonster != ((void *)0)) {
  struct struct_monster *new_monster = malloc(sizeof(Monster));
  if (new_monster != ((void *)0)) {
   new_monster->type = type;
   new_monster->pvMax = pvMax;
   new_monster->pv = pvMax;
   new_monster->resistance = resistance;
   new_monster->type_tower = type_tower;
   new_monster->pace = pace;
   new_monster->points = points;
   new_monster->gain = gain;
   new_monster->animation = 0;
   new_monster->x = p_head->x;
   new_monster->y = p_head->y;
   new_monster->node_prev = p_head;
   new_monster->node_next = p_head->p_next;
   upgrateMonster (new_monster, lvl);
   calculErreur(new_monster);
   new_monster->p_next = ((void *)0);
   if (p_lmonster->p_tail == ((void *)0)) {
    p_lmonster->p_head = new_monster;
    new_monster->p_prev = ((void *)0);
   }
   else {
    new_monster->p_prev = p_lmonster->p_tail;
    p_lmonster->p_tail->p_next = new_monster;
   }
   p_lmonster->p_tail = new_monster;
   p_lmonster->length++;
  }
  else {
   fprintf(stderr, "Problème dans la creation du nouveau monstre\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Cette liste de monstres n'existe pas\n");
  return 0;
 }
 return 1;
}

variable_types:
type
char *

variable_types: pvMax int

variable_types: resistance int

variable_types: pace int

variable_types: points int

variable_types: gain int


moveMonster

original_code:
int moveMonster(LMonster* p_lmonster, Node* p_tail, int k){
 if (p_lmonster != ((void *)0)) {
  Monster *p_tmp = p_lmonster->p_head;
  while(p_tmp != ((void *)0)){
   if(k%(p_tmp->pace) == 0) {
    if(p_tmp->node_prev->x == p_tmp->node_next->x) {
     if(p_tmp->sens == 3)
      (p_tmp->y)++;
     else
      (p_tmp->y)--;
    }
    else if(p_tmp->node_prev->y == p_tmp->node_next->y) {
     if(p_tmp->sens == 2)
      (p_tmp->x)++;
     else
      (p_tmp->x)--;
    }
    else {
     float dx, dy;
     dx = ((p_tmp->node_next->x) - (p_tmp->node_prev->x))*2;
     dy = ((p_tmp->node_next->y) - (p_tmp->node_prev->y))*2;
     if(dx > 0) {
      if(dy > 0) {
       if(dx >= dy) {
        (p_tmp->x)++;
        p_tmp->e -= dy;
        if(p_tmp->e <= 0) {
         (p_tmp->y)++;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)++;
        p_tmp->e -= dx;
        if(p_tmp->e <= 0) {
         (p_tmp->x)++;
         p_tmp->e += dy;
        }
       }
      }
      else {
       if(dx >= -dy){
        (p_tmp->x)++;
        p_tmp->e += dy;
        if(p_tmp->e <= 0) {
         (p_tmp->y)--;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)--;
        p_tmp->e += dx;
        if(p_tmp->e > 0) {
         (p_tmp->x)++;
         p_tmp->e += dy;
        }
       }
      }
     }
     else {
      if(dy > 0) {
       if(-dx >= dy) {
        (p_tmp->x)--;
        p_tmp->e += dy;
        if(p_tmp->e >= 0) {
         (p_tmp->y)++;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)++;
        p_tmp->e += dx;
        if(p_tmp->e <= 0) {
         (p_tmp->x)--;
         p_tmp->e += dy;
        }
       }
      }
      else {
       if(dx <= dy) {
        (p_tmp->x)--;
        p_tmp->e -= dy;
        if(p_tmp->e >= 0) {
         (p_tmp->y)--;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)--;
        p_tmp->e -= dy;
        if(p_tmp->e >= 0) {
         (p_tmp->x)--;
         p_tmp->e += dy;
        }
       }
      }
     }
    }
    if(p_tmp->x == p_tmp->node_next->x && p_tmp->y == p_tmp->node_next->y) {
     if(p_tmp->x == p_tail->x && p_tmp->y == p_tail->y)
      return 2;
     else {
      p_tmp->node_prev = p_tmp->node_next;
      p_tmp->node_next = p_tmp->node_next->p_next;
      calculErreur(p_tmp);
     }
    }
   }
   p_tmp = p_tmp->p_next;
  }
 }
 else {
  fprintf(stderr, "Cette liste de monstres n'existe pas");
  return 0;
 }
 return 1;
}

canonical_original_code:
int moveMonster(struct struct_lmonster *p_lmonster, struct struct_node *p_tail, int k){
 if (p_lmonster != ((void *)0)) {
  struct struct_monster *p_tmp = p_lmonster->p_head;
  while(p_tmp != ((void *)0)){
   if(k%(p_tmp->pace) == 0) {
    if(p_tmp->node_prev->x == p_tmp->node_next->x) {
     if(p_tmp->sens == 3)
      (p_tmp->y)++;
     else
      (p_tmp->y)--;
    }
    else if(p_tmp->node_prev->y == p_tmp->node_next->y) {
     if(p_tmp->sens == 2)
      (p_tmp->x)++;
     else
      (p_tmp->x)--;
    }
    else {
     float dx; float dy;
     dx = ((p_tmp->node_next->x) - (p_tmp->node_prev->x))*2;
     dy = ((p_tmp->node_next->y) - (p_tmp->node_prev->y))*2;
     if(dx > 0) {
      if(dy > 0) {
       if(dx >= dy) {
        (p_tmp->x)++;
        p_tmp->e -= dy;
        if(p_tmp->e <= 0) {
         (p_tmp->y)++;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)++;
        p_tmp->e -= dx;
        if(p_tmp->e <= 0) {
         (p_tmp->x)++;
         p_tmp->e += dy;
        }
       }
      }
      else {
       if(dx >= -dy){
        (p_tmp->x)++;
        p_tmp->e += dy;
        if(p_tmp->e <= 0) {
         (p_tmp->y)--;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)--;
        p_tmp->e += dx;
        if(p_tmp->e > 0) {
         (p_tmp->x)++;
         p_tmp->e += dy;
        }
       }
      }
     }
     else {
      if(dy > 0) {
       if(-dx >= dy) {
        (p_tmp->x)--;
        p_tmp->e += dy;
        if(p_tmp->e >= 0) {
         (p_tmp->y)++;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)++;
        p_tmp->e += dx;
        if(p_tmp->e <= 0) {
         (p_tmp->x)--;
         p_tmp->e += dy;
        }
       }
      }
      else {
       if(dx <= dy) {
        (p_tmp->x)--;
        p_tmp->e -= dy;
        if(p_tmp->e >= 0) {
         (p_tmp->y)--;
         p_tmp->e += dx;
        }
       }
       else {
        (p_tmp->y)--;
        p_tmp->e -= dy;
        if(p_tmp->e >= 0) {
         (p_tmp->x)--;
         p_tmp->e += dy;
        }
       }
      }
     }
    }
    if(p_tmp->x == p_tmp->node_next->x && p_tmp->y == p_tmp->node_next->y) {
     if(p_tmp->x == p_tail->x && p_tmp->y == p_tail->y)
      return 2;
     else {
      p_tmp->node_prev = p_tmp->node_next;
      p_tmp->node_next = p_tmp->node_next->p_next;
      calculErreur(p_tmp);
     }
    }
   }
   p_tmp = p_tmp->p_next;
  }
 }
 else {
  fprintf(stderr, "Cette liste de monstres n'existe pas");
  return 0;
 }
 return 1;
}

variable_types: k int


removeAllMonsters

decompiled_code:
void __fastcall removeAllMonsters(_QWORD *a1)
{
_QWORD *i; // rsi

if ( *a1 )
{
for ( i = (_QWORD *)a1[1]; i; i = (_QWORD *)a1[1] )
a1 = removeMonster(a1, i);
}
}

canonical_decompiled_code:
void __fastcall func5(_QWORD *a1)
{
_QWORD *i; // rsi

if ( *a1 )
{
for ( i = (_QWORD *)a1[1]; i; i = (_QWORD *)a1[1] )
a1 = removeMonster(a1, i);
}
}

original_code:
void removeAllMonsters (LMonster* p_lmonster) {
 if (p_lmonster->length != 0) {
  while (p_lmonster->p_head != ((void *)0)) {
   p_lmonster = removeMonster(p_lmonster, p_lmonster->p_head);
  }
 }
}

canonical_original_code:
void removeAllMonsters(struct struct_lmonster *p_lmonster) {
 if (p_lmonster->length != 0) {
  while (p_lmonster->p_head != ((void *)0)) {
   p_lmonster = removeMonster(p_lmonster, p_lmonster->p_head);
  }
 }
}


freeAllMonsters

decompiled_code:
void __fastcall freeAllMonsters(_QWORD *a1)
{
_QWORD *i; // rsi

if ( *a1 )
{
for ( i = (_QWORD *)a1[1]; i; i = (_QWORD *)a1[1] )
a1 = removeMonster(a1, i);
}
free(a1);
}

canonical_decompiled_code:
void __fastcall func6(_QWORD *a1)
{
_QWORD *i; // rsi

if ( *a1 )
{
for ( i = (_QWORD *)a1[1]; i; i = (_QWORD *)a1[1] )
a1 = removeMonster(a1, i);
}
free(a1);
}

original_code:
void freeAllMonsters (LMonster* p_lmonster) {
 if (p_lmonster->length != 0) {
  while (p_lmonster->p_head != ((void *)0)) {
   p_lmonster = removeMonster(p_lmonster, p_lmonster->p_head);
  }
 }
 free(p_lmonster);
}

canonical_original_code:
void freeAllMonsters(struct struct_lmonster *p_lmonster) {
 if (p_lmonster->length != 0) {
  while (p_lmonster->p_head != ((void *)0)) {
   p_lmonster = removeMonster(p_lmonster, p_lmonster->p_head);
  }
 }
 free(p_lmonster);
}


clickMenuPrincipale

variable_types: x float

variable_types: y float

variable_types:
nbMenu
int *

variable_types:
nbMap
int *

variable_types:
nbTexture
int *


clickMenuTour

original_code:
int clickMenuTour(LTower* p_ltower, LFileTower* p_lfileTower, Interface* interface, float x, float y) {
 if(p_ltower != ((void *)0) && p_lfileTower != ((void *)0) && interface != ((void *)0)) {
  char* type = "None";
  if(x <= 190 && x >= 10 && y <= 120 && y >= 70)
   type = "H";
  else if(x <= 190 && x >= 10 && y <= 175 && y >= 125)
   type = "M";
  if(interface->lvl >= 3) {
   if(x <= 190 && x >= 10 && y <= 230 && y >= 180)
    type = "R";
  }
  if(interface->lvl >= 5) {
   if(x <= 190 && x >= 10 && y <= 285 && y >= 235)
    type = "L";
  }
  if(strcmp("None", type) != 0) {
   FileTower* tmp = p_lfileTower->p_head;
   while(tmp != ((void *)0)) {
    if(strcmp(type, tmp->type_tower) == 0)
     break;
    tmp = tmp->p_next;
   }
   if((interface->money) >= tmp->cost) {
    addTower(p_ltower, tmp->power, tmp->rate, tmp->type_tower, tmp->range, tmp->cost, x, y);
    updateMoney(interface, tmp->cost);
    return 1;
   }
  }
 }
 else {
  fprintf(stderr, "Erreur : liste de tour, liste de fileTour ou interface non alloué\n");
  return 0;
 }
 return 0;
}

canonical_original_code:
int clickMenuTour(struct struct_ltower *p_ltower, struct struct_lfileTower *p_lfileTower, struct struct_interface *interface, float x, float y) {
 if(p_ltower != ((void *)0) && p_lfileTower != ((void *)0) && interface != ((void *)0)) {
  char *type = "None";
  if(x <= 190 && x >= 10 && y <= 120 && y >= 70)
   type = "H";
  else if(x <= 190 && x >= 10 && y <= 175 && y >= 125)
   type = "M";
  if(interface->lvl >= 3) {
   if(x <= 190 && x >= 10 && y <= 230 && y >= 180)
    type = "R";
  }
  if(interface->lvl >= 5) {
   if(x <= 190 && x >= 10 && y <= 285 && y >= 235)
    type = "L";
  }
  if(strcmp("None", type) != 0) {
   struct struct_fileTower *tmp = p_lfileTower->p_head;
   while(tmp != ((void *)0)) {
    if(strcmp(type, tmp->type_tower) == 0)
     break;
    tmp = tmp->p_next;
   }
   if((interface->money) >= tmp->cost) {
    addTower(p_ltower, tmp->power, tmp->rate, tmp->type_tower, tmp->range, tmp->cost, x, y);
    updateMoney(interface, tmp->cost);
    return 1;
   }
  }
 }
 else {
  fprintf(stderr, "Erreur : liste de tour, liste de fileTour ou interface non alloué\n");
  return 0;
 }
 return 0;
}

variable_types: struct struct_ltower { unsigned long length; struct struct_tower { float x; float y; char *type_tower; int lvl; int rate; int compteur; int range; int cost; int power; struct struct_tower *p_prev; struct struct_tower *p_next; } *p_head; struct struct_tower *p_tail; } *

variable_types: struct struct_lfileTower { unsigned long length; struct struct_fileTower { char *type_tower; int rate; int range; int cost; int power; struct struct_fileTower *p_prev; struct struct_fileTower *p_next; } *p_head; struct struct_fileTower *p_tail; } *

variable_types: struct struct_interface { int money; int score; int lvl; int nbMonster; int life; } *

user_defined_types: struct struct_ltower { unsigned long length; struct struct_tower *p_head; struct struct_tower *p_tail; }


clickTourDelete

decompiled_code:
__int64 __fastcall clickTourDelete(__int64 a1, __int64 a2, __int64 a3, _DWORD *a4, unsigned int *a5, float a6, float a7)
{
unsigned int v8; // ebp
__int64 i; // rax

if ( a1 )
{
if ( a3 )
{
v8 = *a5;
if ( *a5 == 1 )
{
if ( a6 <= 190.0 && a6 >= 10.0 && a7 <= 540.0 && a7 >= 490.0 )
{
for ( i = *(_QWORD *)(a2 + 8); i; i = *(_QWORD *)(i + 48) )
{
if ( *(_QWORD *)(i + 16) == a3 )
*(_QWORD *)(i + 16) = 0LL;
}
*a4 += *(_DWORD *)(a3 + 32);
removeTower(a1, a3);
*a5 = 0;
}
}
else
{
v8 = 1;
}
}
else
{
fwrite("Erreur la tour courante\n", 1uLL, 0x18uLL, stderr);
v8 = 0;
}
}
else
{
fwrite("Erreur avec la liste de tours\n", 1uLL, 0x1EuLL, stderr);
v8 = 0;
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, _DWORD *a4, unsigned int *a5, float a6, float a7)
{
unsigned int v8; // ebp
__int64 i; // rax

if ( a1 )
{
if ( a3 )
{
v8 = *a5;
if ( *a5 == 1 )
{
if ( a6 <= 190.0 && a6 >= 10.0 && a7 <= 540.0 && a7 >= 490.0 )
{
for ( i = *(_QWORD *)(a2 + 8); i; i = *(_QWORD *)(i + 48) )
{
if ( *(_QWORD *)(i + 16) == a3 )
*(_QWORD *)(i + 16) = 0LL;
}
*a4 += *(_DWORD *)(a3 + 32);
removeTower(a1, a3);
*a5 = 0;
}
}
else
{
v8 = 1;
}
}
else
{
fwrite("Erreur la tour courante\n", 1uLL, 0x18uLL, stderr);
v8 = 0;
}
}
else
{
fwrite("Erreur avec la liste de tours\n", 1uLL, 0x1EuLL, stderr);
v8 = 0;
}
return v8;
}

original_code:
int clickTourDelete(LTower* p_ltower, LShot* p_lshot, Tower* p_courant, Interface* interface, float x, float y, int* propriete) {
 if(p_ltower != ((void *)0)) {
  if(p_courant != ((void *)0)) {
   if(*propriete == 1) {
    if(x <= 190 && x >= 10 && y <= 540 && y >= 490) {
     Shot* p_tmp = p_lshot->p_head;
     while(p_tmp != ((void *)0)) {
      if(p_tmp->tower == p_courant)
       p_tmp->tower = ((void *)0);
      p_tmp = p_tmp->p_next;
     }
     interface->money += p_courant->cost;
     p_ltower = removeTower(p_ltower, p_courant);
     *propriete = 0;
    }
   }
  }
  else {
   fprintf(stderr, "Erreur la tour courante\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Erreur avec la liste de tours\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int clickTourDelete(struct struct_ltower *p_ltower, struct struct_lshot *p_lshot, struct struct_tower *p_courant, struct struct_interface *interface, float x, float y, int *propriete) {
 if(p_ltower != ((void *)0)) {
  if(p_courant != ((void *)0)) {
   if(*propriete == 1) {
    if(x <= 190 && x >= 10 && y <= 540 && y >= 490) {
     struct struct_shot *p_tmp = p_lshot->p_head;
     while(p_tmp != ((void *)0)) {
      if(p_tmp->tower == p_courant)
       p_tmp->tower = ((void *)0);
      p_tmp = p_tmp->p_next;
     }
     interface->money += p_courant->cost;
     p_ltower = removeTower(p_ltower, p_courant);
     *propriete = 0;
    }
   }
  }
  else {
   fprintf(stderr, "Erreur la tour courante\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Erreur avec la liste de tours\n");
  return 0;
 }
 return 1;
}

variable_types: struct struct_lshot { unsigned long length; struct struct_shot { float x; float y; struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node { float x; float y; struct struct_node *p_next; } *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; } *target; struct struct_tower *tower; int power; char *type_tower; struct struct_shot *p_prev; struct struct_shot *p_next; } *p_head; struct struct_shot *p_tail; } *

variable_types:
propriete
int *

variable_types: struct struct_shot { float x; float y; struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node { float x; float y; struct struct_node *p_next; } *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; } *target; struct struct_tower { float x; float y; char *type_tower; int lvl; int rate; int compteur; int range; int cost; int power; struct struct_tower *p_prev; struct struct_tower *p_next; } *tower; int power; char *type_tower; struct struct_shot *p_prev; struct struct_shot *p_next; } *

user_defined_types: struct struct_lshot { unsigned long length; struct struct_shot *p_head; struct struct_shot *p_tail; }

user_defined_types: struct struct_interface { int money; int score; int lvl; int nbMonster; int life; }

user_defined_types: struct struct_shot { float x; float y; struct struct_monster *target; struct struct_tower *tower; int power; char *type_tower; struct struct_shot *p_prev; struct struct_shot *p_next; }


clickTourUpgrate

decompiled_code:
__int64 __fastcall clickTourUpgrate(__int64 a1, __int64 a2, unsigned int *a3, float a4, float a5)
{
unsigned int v6; // ebp

if ( a2 )
{
if ( a1 )
{
v6 = *a3;
if ( *a3 == 1 )
{
if ( a4 <= 190.0 )
{
if ( a4 >= 10.0 && a5 <= 595.0 && a5 >= 545.0 )
{
upgrateTower();
}
else if ( a4 >= 165.0 )
{
if ( a5 <= 395.0 && a5 >= 372.0 )
{
upgradeRateT();
}
else if ( a5 <= 420.0 && a5 >= 397.0 )
{
upgradeRangeT();
}
else if ( a5 <= 445.0 && a5 >= 422.0 )
{
upgradePowerT();
}
}
}
*a3 = 1;
}
else
{
v6 = 1;
}
}
else
{
fwrite("Erreur la tour courante\n", 1uLL, 0x18uLL, stderr);
v6 = 0;
}
}
else
{
fwrite("Erreur avec l'interface\n", 1uLL, 0x18uLL, stderr);
v6 = 0;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, unsigned int *a3, float a4, float a5)
{
unsigned int v6; // ebp

if ( a2 )
{
if ( a1 )
{
v6 = *a3;
if ( *a3 == 1 )
{
if ( a4 <= 190.0 )
{
if ( a4 >= 10.0 && a5 <= 595.0 && a5 >= 545.0 )
{
upgrateTower();
}
else if ( a4 >= 165.0 )
{
if ( a5 <= 395.0 && a5 >= 372.0 )
{
upgradeRateT();
}
else if ( a5 <= 420.0 && a5 >= 397.0 )
{
upgradeRangeT();
}
else if ( a5 <= 445.0 && a5 >= 422.0 )
{
upgradePowerT();
}
}
}
*a3 = 1;
}
else
{
v6 = 1;
}
}
else
{
fwrite("Erreur la tour courante\n", 1uLL, 0x18uLL, stderr);
v6 = 0;
}
}
else
{
fwrite("Erreur avec l'interface\n", 1uLL, 0x18uLL, stderr);
v6 = 0;
}
return v6;
}

original_code:
int clickTourUpgrate(Tower* p_courant, Interface* interface, float x, float y, int* propriete) {
 if(interface != ((void *)0)) {
  if(p_courant != ((void *)0)) {
   if(*propriete == 1) {
    if(x <= 190 && x >= 10 && y <= 595 && y >= 545)
     upgrateTower(p_courant, interface);
    else if(x <= 190 && x >= 165 && y <= 395 && y >= 372)
     upgradeRateT(p_courant, interface);
    else if(x <= 190 && x >= 165 && y <= 420 && y >= 397)
     upgradeRangeT(p_courant, interface);
    else if(x <= 190 && x >= 165 && y <= 445 && y >= 422)
     upgradePowerT(p_courant, interface);
    *propriete = 1;
   }
  }
  else {
   fprintf(stderr, "Erreur la tour courante\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Erreur avec l'interface\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int clickTourUpgrate(struct struct_tower *p_courant, struct struct_interface *interface, float x, float y, int *propriete) {
 if(interface != ((void *)0)) {
  if(p_courant != ((void *)0)) {
   if(*propriete == 1) {
    if(x <= 190 && x >= 10 && y <= 595 && y >= 545)
     upgrateTower(p_courant, interface);
    else if(x <= 190 && x >= 165 && y <= 395 && y >= 372)
     upgradeRateT(p_courant, interface);
    else if(x <= 190 && x >= 165 && y <= 420 && y >= 397)
     upgradeRangeT(p_courant, interface);
    else if(x <= 190 && x >= 165 && y <= 445 && y >= 422)
     upgradePowerT(p_courant, interface);
    *propriete = 1;
   }
  }
  else {
   fprintf(stderr, "Erreur la tour courante\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Erreur avec l'interface\n");
  return 0;
 }
 return 1;
}

variable_types: struct struct_tower { float x; float y; char *type_tower; int lvl; int rate; int compteur; int range; int cost; int power; struct struct_tower *p_prev; struct struct_tower *p_next; } *


clickTime

variable_types: play int

variable_types:
nbMonster
int *

variable_types:
j
int *


clickAide

decompiled_code:
_BOOL8 __fastcall clickAide(int a1, float a2, float a3)
{
_BOOL8 result; // rax

result = 0LL;
if ( !a1 )
{
if ( a2 > 755.0 )
{
result = 0LL;
}
else if ( a2 < 725.0 )
{
result = 0LL;
}
else if ( a3 > 45.0 )
{
result = 0LL;
}
else
{
result = a3 >= 15.0;
}
}
return result;
}

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

result = 0LL;
if ( !a1 )
{
if ( a2 > 755.0 )
{
result = 0LL;
}
else if ( a2 < 725.0 )
{
result = 0LL;
}
else if ( a3 > 45.0 )
{
result = 0LL;
}
else
{
result = a3 >= 15.0;
}
}
return result;
}

variable_types: aide int


clickTower

decompiled_code:
__int64 __fastcall clickTower(__int64 a1, _DWORD *a2, float a3, float a4)
{
__int64 result; // rax

if ( a1 )
{
result = *(_QWORD *)(a1 + 8);
if ( result )
{
while ( (float)(*(float *)result + 20.0) < a3
|| a3 < (float)(*(float *)result - 20.0)
|| (float)(*(float *)(result + 4) + 20.0) < a4
|| a4 < (float)(*(float *)(result + 4) - 20.0) )
{
result = *(_QWORD *)(result + 48);
if ( !result )
return result;
}
*a2 = 1;
}
}
else
{
fwrite("Erreur : cette liste de tour n'existe pas\n", 1uLL, 0x2AuLL, stderr);
result = 0LL;
}
return result;
}

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

if ( a1 )
{
result = *(_QWORD *)(a1 + 8);
if ( result )
{
while ( (float)(*(float *)result + 20.0) < a3
|| a3 < (float)(*(float *)result - 20.0)
|| (float)(*(float *)(result + 4) + 20.0) < a4
|| a4 < (float)(*(float *)(result + 4) - 20.0) )
{
result = *(_QWORD *)(result + 48);
if ( !result )
return result;
}
*a2 = 1;
}
}
else
{
fwrite("Erreur : cette liste de tour n'existe pas\n", 1uLL, 0x2AuLL, stderr);
result = 0LL;
}
return result;
}

original_code:
Tower* clickTower(LTower* p_ltower, float x, float y, int* propriete) {
 if(p_ltower != ((void *)0)) {
  Tower* p_tmp = p_ltower->p_head;
  while(p_tmp != ((void *)0)) {
   if(x <= (p_tmp->x + 20) && x >= (p_tmp->x - 20) && y <= (p_tmp->y + 20) && y >= (p_tmp->y - 20)) {
    *propriete = 1;
    return p_tmp;
   }
   p_tmp = p_tmp->p_next;
  }
 }
 else {
  fprintf(stderr, "Erreur : cette liste de tour n'existe pas\n");
  return ((void *)0);
 }
 return ((void *)0);
}

canonical_original_code:
struct struct_tower *clickTower(struct struct_ltower *p_ltower, float x, float y, int *propriete) {
 if(p_ltower != ((void *)0)) {
  struct struct_tower *p_tmp = p_ltower->p_head;
  while(p_tmp != ((void *)0)) {
   if(x <= (p_tmp->x + 20) && x >= (p_tmp->x - 20) && y <= (p_tmp->y + 20) && y >= (p_tmp->y - 20)) {
    *propriete = 1;
    return p_tmp;
   }
   p_tmp = p_tmp->p_next;
  }
 }
 else {
  fprintf(stderr, "Erreur : cette liste de tour n'existe pas\n");
  return ((void *)0);
 }
 return ((void *)0);
}

variable_types: struct struct_ltower { unsigned long length; struct struct_tower *p_head; struct struct_tower *p_tail; } *

return_type: struct struct_tower { float x; float y; char *type_tower; int lvl; int rate; int compteur; int range; int cost; int power; struct struct_tower *p_prev; struct struct_tower *p_next; } *


clickMonster

decompiled_code:
__int64 __fastcall clickMonster(__int64 a1, _DWORD *a2, float a3, float a4)
{
__int64 result; // rax

if ( a1 )
{
result = *(_QWORD *)(a1 + 8);
if ( result )
{
while ( (float)(*(float *)result + 20.0) < a3
|| a3 < (float)(*(float *)result - 20.0)
|| (float)(*(float *)(result + 4) + 20.0) < a4
|| a4 < (float)(*(float *)(result + 4) - 20.0) )
{
result = *(_QWORD *)(result + 96);
if ( !result )
return result;
}
*a2 = 2;
}
}
else
{
fwrite("Erreur : cette liste de monstre n'existe pas\n", 1uLL, 0x2DuLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, _DWORD *a2, float a3, float a4)
{
__int64 result; // rax

if ( a1 )
{
result = *(_QWORD *)(a1 + 8);
if ( result )
{
while ( (float)(*(float *)result + 20.0) < a3
|| a3 < (float)(*(float *)result - 20.0)
|| (float)(*(float *)(result + 4) + 20.0) < a4
|| a4 < (float)(*(float *)(result + 4) - 20.0) )
{
result = *(_QWORD *)(result + 96);
if ( !result )
return result;
}
*a2 = 2;
}
}
else
{
fwrite("Erreur : cette liste de monstre n'existe pas\n", 1uLL, 0x2DuLL, stderr);
result = 0LL;
}
return result;
}

original_code:
Monster* clickMonster(LMonster* p_lmonster, float x, float y, int* propriete) {
 if(p_lmonster != ((void *)0)) {
  Monster* p_tmp = p_lmonster->p_head;
  while(p_tmp != ((void *)0)) {
   if(x <= (p_tmp->x + 20) && x >= (p_tmp->x - 20) && y <= (p_tmp->y + 20) && y >= (p_tmp->y - 20)) {
    *propriete = 2;
    return p_tmp;
   }
   p_tmp = p_tmp->p_next;
  }
 }
 else {
  fprintf(stderr, "Erreur : cette liste de monstre n'existe pas\n");
  return ((void *)0);
 }
 return ((void *)0);
}

canonical_original_code:
struct struct_monster *clickMonster(struct struct_lmonster *p_lmonster, float x, float y, int *propriete) {
 if(p_lmonster != ((void *)0)) {
  struct struct_monster *p_tmp = p_lmonster->p_head;
  while(p_tmp != ((void *)0)) {
   if(x <= (p_tmp->x + 20) && x >= (p_tmp->x - 20) && y <= (p_tmp->y + 20) && y >= (p_tmp->y - 20)) {
    *propriete = 2;
    return p_tmp;
   }
   p_tmp = p_tmp->p_next;
  }
 }
 else {
  fprintf(stderr, "Erreur : cette liste de monstre n'existe pas\n");
  return ((void *)0);
 }
 return ((void *)0);
}

variable_types: struct struct_lmonster { unsigned long length; struct struct_monster *p_head; struct struct_monster *p_tail; } *

variable_types: x float

variable_types: struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node { float x; float y; struct struct_node *p_next; } *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; } *


clickTuto

decompiled_code:
__int64 __fastcall clickTuto(__int64 a1, int a2, int a3, int a4, _DWORD *a5, float a6, float a7)
{
__int64 result; // rax

if ( a2 == 6 )
{
*a5 = 1;
result = 0LL;
}
else if ( a6 <= 780.0 && a6 >= 680.0 && a7 <= 141.0 && a7 >= 80.0 )
{
*a5 = 1;
result = 0LL;
}
else
{
switch ( a2 )
{
case 1:
result = 2LL;
break;
case 2:
result = 3LL;
if ( a3 != 1 )
result = 2LL;
break;
case 3:
result = 4LL;
if ( a4 != 1 )
result = 3LL;
break;
case 4:
result = 5LL;
if ( a1 )
result = 4LL;
break;
default:
result = 0LL;
if ( a2 == 5 )
{
result = 6LL;
if ( a1 )
result = 5LL;
}
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2, int a3, int a4, _DWORD *a5, float a6, float a7)
{
__int64 result; // rax

if ( a2 == 6 )
{
*a5 = 1;
result = 0LL;
}
else if ( a6 <= 780.0 && a6 >= 680.0 && a7 <= 141.0 && a7 >= 80.0 )
{
*a5 = 1;
result = 0LL;
}
else
{
switch ( a2 )
{
case 1:
result = 2LL;
break;
case 2:
result = 3LL;
if ( a3 != 1 )
result = 2LL;
break;
case 3:
result = 4LL;
if ( a4 != 1 )
result = 3LL;
break;
case 4:
result = 5LL;
if ( a1 )
result = 4LL;
break;
default:
result = 0LL;
if ( a2 == 5 )
{
result = 6LL;
if ( a1 )
result = 5LL;
}
break;
}
}
return result;
}

original_code:
int clickTuto(Tower* p_courant, float x, float y, int tuto, int testMouse, int testTower, int* tutoend) {
 if(tuto != 6) {
  if(x <= 780 && x >= 680 && y <= 141 && y >= 80) {
   *tutoend = 1;
   return 0;
  }
 }
 if(tuto == 1) {
   return 2;
 }
 else if(tuto == 2) {
  if(testMouse == 1)
   return 3;
  else
   return 2;
 }
 else if(tuto == 3) {
  if(testTower == 1)
   return 4;
  else
   return 3;
 }
 else if(tuto == 4) {
  if(p_courant == ((void *)0))
   return 5;
  else
   return 4;
 }
 else if(tuto == 5){
  if(p_courant == ((void *)0))
   return 6;
  else
   return 5;
 }
 else if(tuto == 6) {
  *tutoend = 1;
  return 0;
 }
 return 0;
}

canonical_original_code:
int clickTuto(struct struct_tower *p_courant, float x, float y, int tuto, int testMouse, int testTower, int *tutoend) {
 if(tuto != 6) {
  if(x <= 780 && x >= 680 && y <= 141 && y >= 80) {
   *tutoend = 1;
   return 0;
  }
 }
 if(tuto == 1) {
   return 2;
 }
 else if(tuto == 2) {
  if(testMouse == 1)
   return 3;
  else
   return 2;
 }
 else if(tuto == 3) {
  if(testTower == 1)
   return 4;
  else
   return 3;
 }
 else if(tuto == 4) {
  if(p_courant == ((void *)0))
   return 5;
  else
   return 4;
 }
 else if(tuto == 5){
  if(p_courant == ((void *)0))
   return 6;
  else
   return 5;
 }
 else if(tuto == 6) {
  *tutoend = 1;
  return 0;
 }
 return 0;
}

variable_types: y float

variable_types: tuto int

variable_types: testMouse int

variable_types: testTower int

variable_types:
tutoend
int *

user_defined_types: struct struct_tower { float x; float y; char *type_tower; int lvl; int rate; int compteur; int range; int cost; int power; struct struct_tower *p_prev; struct struct_tower *p_next; }


mouseInfo

variable_types: propriete int


initAll

decompiled_code:
__int64 __fastcall initAll(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
removeAllShot(a2);
removeAllMonsters(a1);
removeAllTower(a3);
return initInterface(a4);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
removeAllShot(a2);
removeAllMonsters(a1);
removeAllTower(a3);
return initInterface(a4);
}

original_code:
void initAll (LMonster* p_lmonster, LShot* p_lshot, LTower* p_ltower, Interface* interface) {
 removeAllShot(p_lshot);
 removeAllMonsters(p_lmonster);
 removeAllTower(p_ltower);
 initInterface(interface);
}

canonical_original_code:
void initAll(struct struct_lmonster *p_lmonster, struct struct_lshot *p_lshot, struct struct_ltower *p_ltower, struct struct_interface *interface) {
 removeAllShot(p_lshot);
 removeAllMonsters(p_lmonster);
 removeAllTower(p_ltower);
 initInterface(interface);
}

variable_types: struct struct_lmonster { unsigned long length; struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node { float x; float y; struct struct_node *p_next; } *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; } *p_head; struct struct_monster *p_tail; } *

variable_types: struct struct_lshot { unsigned long length; struct struct_shot { float x; float y; struct struct_monster *target; struct struct_tower { float x; float y; char *type_tower; int lvl; int rate; int compteur; int range; int cost; int power; struct struct_tower *p_prev; struct struct_tower *p_next; } *tower; int power; char *type_tower; struct struct_shot *p_prev; struct struct_shot *p_next; } *p_head; struct struct_shot *p_tail; } *

variable_types: struct struct_interface { int money; int score; int lvl; int nbMonster; int life; } *


freeAll

decompiled_code:
__int64 __fastcall freeAll(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
freeAllShot(a2);
freeAllMonsters(a1);
freeAllTower(a3);
freeAllFileTower(a4);
freeMap(a5);
return freeInterface(a6);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
freeAllShot(a2);
freeAllMonsters(a1);
freeAllTower(a3);
freeAllFileTower(a4);
freeMap(a5);
return freeInterface(a6);
}

original_code:
void freeAll (LMonster* p_lmonster, LShot* p_lshot, LTower* p_ltower, LFileTower* p_lfileTower, Map* map, Interface* interface) {
 freeAllShot (p_lshot);
 freeAllMonsters (p_lmonster);
 freeAllTower (p_ltower);
 freeAllFileTower(p_lfileTower);
 freeMap(map);
 freeInterface(interface);
}

canonical_original_code:
void freeAll(struct struct_lmonster *p_lmonster, struct struct_lshot *p_lshot, struct struct_ltower *p_ltower, struct struct_lfileTower *p_lfileTower, struct struct_map *map, struct struct_interface *interface) {
 freeAllShot (p_lshot);
 freeAllMonsters (p_lmonster);
 freeAllTower (p_ltower);
 freeAllFileTower(p_lfileTower);
 freeMap(map);
 freeInterface(interface);
}

variable_types: struct struct_lfileTower { unsigned long length; struct struct_fileTower { char *type_tower; int rate; int range; int cost; int power; struct struct_fileTower *p_prev; struct struct_fileTower *p_next; } *p_head; struct struct_fileTower *p_tail; } *

variable_types: struct struct_map { struct struct_image { char *path; char magicNumber[2]; unsigned int heightImg; unsigned int widthImg; int maxValue; } *img; int energie; struct struct_color { float r; float g; float b; } road; struct struct_color node; struct struct_color construct; struct struct_lnode { unsigned long length; struct struct_node *p_head; struct struct_node *p_tail; } *list_pixels; struct struct_color in; struct struct_color out; int number_node; struct struct_lnode *list_node; } *

user_defined_types: struct struct_map { struct struct_image *img; int energie; struct struct_color road; struct struct_color node; struct struct_color construct; struct struct_lnode *list_pixels; struct struct_color in; struct struct_color out; int number_node; struct struct_lnode *list_node; }


clickExit

decompiled_code:
__int64 __fastcall clickExit(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, float a7, float a8, int a9)
{
__int64 result; // rax

result = 1LL;
if ( !a9 )
{
result = 1LL;
if ( a7 <= 790.0 )
{
result = 1LL;
if ( a7 >= 760.0 )
{
result = 1LL;
if ( a8 <= 45.0 )
{
result = 1LL;
if ( a8 >= 15.0 )
{
freeAll(a1, a2, a3, a4, a5, a6);
result = 0LL;
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, float a7, float a8, int a9)
{
__int64 result; // rax

result = 1LL;
if ( !a9 )
{
result = 1LL;
if ( a7 <= 790.0 )
{
result = 1LL;
if ( a7 >= 760.0 )
{
result = 1LL;
if ( a8 <= 45.0 )
{
result = 1LL;
if ( a8 >= 15.0 )
{
func11(a1, a2, a3, a4, a5, a6);
result = 0LL;
}
}
}
}
}
return result;
}

original_code:
int clickExit(LMonster* p_lmonster, LShot* p_lshot, LTower* p_ltower, LFileTower* p_lfileTower, Map* map, Interface* interface, float x, float y, int aide) {
 if(aide == 0) {
  if(x <= 790 && x >= 760 && y <= 45 && y >= 15) {
   freeAll (p_lmonster, p_lshot, p_ltower, p_lfileTower, map, interface);
   return 0;
  }
 }
 return 1;
}

canonical_original_code:
int clickExit(struct struct_lmonster *p_lmonster, struct struct_lshot *p_lshot, struct struct_ltower *p_ltower, struct struct_lfileTower *p_lfileTower, struct struct_map *map, struct struct_interface *interface, float x, float y, int aide) {
 if(aide == 0) {
  if(x <= 790 && x >= 760 && y <= 45 && y >= 15) {
   freeAll (p_lmonster, p_lshot, p_ltower, p_lfileTower, map, interface);
   return 0;
  }
 }
 return 1;
}

user_defined_types: struct struct_image { char *path; char magicNumber[2]; unsigned int heightImg; unsigned int widthImg; int maxValue; }

user_defined_types: struct struct_lnode { unsigned long length; struct struct_node *p_head; struct struct_node *p_tail; }


newMap

decompiled_code:
void *__fastcall newMap(const char *a1)
{
void *v1; // rax
void *v2; // rbx

if ( a1 )
{
v1 = malloc(0x60uLL);
v2 = v1;
if ( v1 )
{
if ( !(unsigned int)verificationMap((__int64)v1, a1) )
{
fwrite(&unk_12D8, 1uLL, 0x2FuLL, stderr);
v2 = 0LL;
}
}
else
{
fwrite(&unk_1308, 1uLL, 0x34uLL, stderr);
}
}
else
{
fwrite("Erreur : Ce n'est pas le bon chemin\n", 1uLL, 0x24uLL, stderr);
v2 = 0LL;
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func1(const char *a1)
{
void *v1; // rax
void *v2; // rbx

if ( a1 )
{
v1 = malloc(0x60uLL);
v2 = v1;
if ( v1 )
{
if ( !(unsigned int)func0((__int64)v1, a1) )
{
fwrite(&unk_12D8, 1uLL, 0x2FuLL, stderr);
v2 = 0LL;
}
}
else
{
fwrite(&unk_1308, 1uLL, 0x34uLL, stderr);
}
}
else
{
fwrite("Erreur : Ce n'est pas le bon chemin\n", 1uLL, 0x24uLL, stderr);
v2 = 0LL;
}
return v2;
}

original_code:
Map* newMap (char* path) {
 if(path != ((void *)0)) {
  Map* map = malloc(sizeof(Map));
  if(map != ((void *)0)) {
   if(verificationMap(map, path) == 0) {
    fprintf(stderr, "Erreur au moment de la vérification de la map\n");
    return ((void *)0);
   }
   return map;
  }
  else {
   fprintf(stderr, "Erreur au moment de l'allocation mémoire de la map\n");
   return ((void *)0);
  }
 }
 else {
  fprintf(stderr, "Erreur : Ce n'est pas le bon chemin\n");
  return ((void *)0);
 }
 return ((void *)0);
}

canonical_original_code:
struct struct_map *newMap(char *path) {
 if(path != ((void *)0)) {
  struct struct_map *map = malloc(sizeof(Map));
  if(map != ((void *)0)) {
   if(verificationMap(map, path) == 0) {
    fprintf(stderr, "Erreur au moment de la vérification de la map\n");
    return ((void *)0);
   }
   return map;
  }
  else {
   fprintf(stderr, "Erreur au moment de l'allocation mémoire de la map\n");
   return ((void *)0);
  }
 }
 else {
  fprintf(stderr, "Erreur : Ce n'est pas le bon chemin\n");
  return ((void *)0);
 }
 return ((void *)0);
}

variable_types:
path
char *

variable_types: struct struct_map { struct struct_image { char *path; char magicNumber[2]; unsigned int heightImg; unsigned int widthImg; int maxValue; } *img; int energie; struct struct_color { float r; float g; float b; } road; struct struct_color node; struct struct_color construct; struct struct_lnode { unsigned long length; struct struct_node { float x; float y; struct struct_node *p_next; } *p_head; struct struct_node *p_tail; } *list_pixels; struct struct_color in; struct struct_color out; int number_node; struct struct_lnode *list_node; } *


changeColorRoad

original_code:
int changeColorRoad(Image* img, unsigned char* tabPixels, Map* map) {
 int i, j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 255 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 0){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->road).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->road).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->road).b)*255;
   }
  }
 }
 return 1;
}

canonical_original_code:
int changeColorRoad(struct struct_image *img, unsigned char *tabPixels, struct struct_map *map) {
 int i; int j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 255 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 0){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->road).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->road).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->road).b)*255;
   }
  }
 }
 return 1;
}

variable_types: struct struct_image { char *path; char magicNumber[2]; unsigned int heightImg; unsigned int widthImg; int maxValue; } *

variable_types:
tabPixels
unsigned char *

variable_types: struct struct_map { struct struct_image *img; int energie; struct struct_color { float r; float g; float b; } road; struct struct_color node; struct struct_color construct; struct struct_lnode { unsigned long length; struct struct_node { float x; float y; struct struct_node *p_next; } *p_head; struct struct_node *p_tail; } *list_pixels; struct struct_color in; struct struct_color out; int number_node; struct struct_lnode *list_node; } *

variable_types: i int

variable_types: j int


changeColorConstruct

original_code:
int changeColorConstruct(Image* img, unsigned char* tabPixels, Map* map) {
 int i, j;
 if(map->list_pixels != ((void *)0)) {
  for(i=0; i<(img->heightImg); i++) {
   for(j=0; j<(img->widthImg); j++) {
    if(tabPixels[i*(img->widthImg)*3+j*3] == 0 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 255){
     tabPixels[i*(img->widthImg)*3+j*3] = ((map->construct).r)*255;
     tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->construct).g)*255;
     tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->construct).b)*255;
     addNode(map->list_pixels, j + 200, i + 60);
    }
   }
  }
 }
 else {
  fprintf(stderr, "Erreur : problème au moment de l'allocation pour la liste de pixels de la zone constructible\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int changeColorConstruct(struct struct_image *img, unsigned char *tabPixels, struct struct_map *map) {
 int i; int j;
 if(map->list_pixels != ((void *)0)) {
  for(i=0; i<(img->heightImg); i++) {
   for(j=0; j<(img->widthImg); j++) {
    if(tabPixels[i*(img->widthImg)*3+j*3] == 0 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 255){
     tabPixels[i*(img->widthImg)*3+j*3] = ((map->construct).r)*255;
     tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->construct).g)*255;
     tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->construct).b)*255;
     addNode(map->list_pixels, j + 200, i + 60);
    }
   }
  }
 }
 else {
  fprintf(stderr, "Erreur : problème au moment de l'allocation pour la liste de pixels de la zone constructible\n");
  return 0;
 }
 return 1;
}


changeColorNode

original_code:
int changeColorNode(Image* img, unsigned char* tabPixels, Map* map) {
 int i, j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 6 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 255){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->construct).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->construct).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->construct).b)*255;
   }
  }
 }
 return 1;
}

canonical_original_code:
int changeColorNode(struct struct_image *img, unsigned char *tabPixels, struct struct_map *map) {
 int i; int j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 6 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 255){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->construct).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->construct).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->construct).b)*255;
   }
  }
 }
 return 1;
}


changeColorIn

original_code:
int changeColorIn(Image* img, unsigned char* tabPixels, Map* map) {
 int i, j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 255 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 67){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->in).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->in).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->in).b)*255;
   }
  }
 }
 return 1;
}

canonical_original_code:
int changeColorIn(struct struct_image *img, unsigned char *tabPixels, struct struct_map *map) {
 int i; int j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 255 && tabPixels[i*(img->widthImg)*3+j*3+1] == 0 && tabPixels[i*(img->widthImg)*3+j*3+2] == 67){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->in).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->in).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->in).b)*255;
   }
  }
 }
 return 1;
}


changeColorOut

original_code:
int changeColorOut(Image* img, unsigned char* tabPixels, Map* map) {
 int i, j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 255 && tabPixels[i*(img->widthImg)*3+j*3+1] == 252 && tabPixels[i*(img->widthImg)*3+j*3+2] == 0){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->out).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->out).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->out).b)*255;
   }
  }
 }
 return 1;
}

canonical_original_code:
int changeColorOut(struct struct_image *img, unsigned char *tabPixels, struct struct_map *map) {
 int i; int j;
 for(i=0; i<(img->heightImg); i++) {
  for(j=0; j<(img->widthImg); j++) {
   if(tabPixels[i*(img->widthImg)*3+j*3] == 255 && tabPixels[i*(img->widthImg)*3+j*3+1] == 252 && tabPixels[i*(img->widthImg)*3+j*3+2] == 0){
    tabPixels[i*(img->widthImg)*3+j*3] = ((map->out).r)*255;
    tabPixels[i*(img->widthImg)*3+j*3+1] = ((map->out).g)*255;
    tabPixels[i*(img->widthImg)*3+j*3+2] = ((map->out).b)*255;
   }
  }
 }
 return 1;
}


ChangeColor

decompiled_code:
__int64 __fastcall ChangeColor(__int64 a1, __int64 a2, float *a3)
{
changeColorRoad(a1, a2, a3);
changeColorConstruct(a1, a2, (__int64)a3);
changeColorNode(a1, a2, a3);
changeColorIn(a1, a2, a3);
changeColorOut(a1, a2, a3);
return 1LL;
}

original_code:
int ChangeColor(Image* img, unsigned char* tabPixels, Map* map) {
 changeColorRoad(img, tabPixels, map);
 changeColorConstruct(img, tabPixels, map);
 changeColorNode(img, tabPixels, map);
 changeColorIn(img, tabPixels, map);
 changeColorOut(img, tabPixels, map);
 return 1;
}

canonical_original_code:
int ChangeColor(struct struct_image *img, unsigned char *tabPixels, struct struct_map *map) {
 changeColorRoad(img, tabPixels, map);
 changeColorConstruct(img, tabPixels, map);
 changeColorNode(img, tabPixels, map);
 changeColorIn(img, tabPixels, map);
 changeColorOut(img, tabPixels, map);
 return 1;
}


freeMap

decompiled_code:
void __fastcall freeMap(void *ptr)
{
if ( ptr )
{
freeImage(*(_QWORD *)ptr);
freeAllNode(*((_QWORD *)ptr + 6));
freeAllNode(*((_QWORD *)ptr + 11));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
if ( ptr )
{
freeImage(*(_QWORD *)ptr);
freeAllNode(*((_QWORD *)ptr + 6));
freeAllNode(*((_QWORD *)ptr + 11));
free(ptr);
}
}

original_code:
void freeMap (Map* map) {
 if (map != ((void *)0)) {
  freeImage (map->img);
  freeAllNode (map->list_pixels);
  freeAllNode (map->list_node);
  free(map);
 }
}

canonical_original_code:
void freeMap(struct struct_map *map) {
 if (map != ((void *)0)) {
  freeImage (map->img);
  freeAllNode (map->list_pixels);
  freeAllNode (map->list_node);
  free(map);
 }
}


intersectionPointSegment

decompiled_code:
_BOOL8 __fastcall intersectionPointSegment(__m128i a1, __m128i a2, __m128i a3)
{
float v3; // ebx
float v4; // er14
double v5; // xmm0_8
float v6; // eax
__int64 v7; // xmm1_8
float v8; // xmm0_4
float v9; // xmm3_4
float v10; // xmm1_4
float v11; // xmm4_4
_BOOL8 result; // rax
float v13; // [rsp+0h] [rbp-28h]
float v14; // [rsp+4h] [rbp-24h]
float v15; // [rsp+8h] [rbp-20h]

v14 = COERCE_FLOAT(_mm_cvtsi128_si32(a1));
v15 = *(float *)&a1.m128i_i32[1];
v3 = COERCE_FLOAT(_mm_cvtsi128_si32(a2));
v13 = *(float *)&a2.m128i_i32[1];
v4 = COERCE_FLOAT(_mm_cvtsi128_si32(a3));
v5 = Vector(*(double *)a2.m128i_i64, *(double *)a3.m128i_i64);
v6 = *(float *)&v5;
v7 = HIDWORD(*(_QWORD *)&v5);
v8 = 0.0;
if ( *(float *)&v7 != 0.0 )
v8 = v6 / *(float *)&v7;
if ( (float)((float)((float)(v8 * v14) + (float)(v13 - (float)(v3 * v8))) - v15) != 0.0 )
return 0LL;
v9 = fmaxf(v3, v4);
v10 = fminf(v13, *(float *)&a3.m128i_i32[1]);
v11 = fmaxf(v13, *(float *)&a3.m128i_i32[1]);
result = 0LL;
if ( v14 >= fminf(v3, v4) )
{
result = 0LL;
if ( v9 >= v14 )
{
result = 0LL;
if ( v15 >= v10 )
result = v11 >= v15;
}
}
return result;
}

original_code:
int intersectionPointSegment (Point2D point, Point2D A, Point2D B) {
 float a, b;
 Vector2D vector = Vector(A, B);
 if(vector.y != 0)
  a = (vector.x) / (vector.y);
 else
  a = 0;
 b = (A.y) - (A.x)*a;
 if((point.x)*a + b - (point.y) == 0) {
  float xmin = ((A.x) < (B.x)) ? (A.x) : (B.x);
  float xmax = ((A.x) > (B.x)) ? (A.x) : (B.x);
  float ymin = ((A.y) < (B.y)) ? (A.y) : (B.y);
  float ymax = ((A.y) > (B.y)) ? (A.y) : (B.y);
  if(point.x >= xmin && point.x <= xmax && point.y >= ymin && point.y <= ymax)
   return 1;
 }
 return 0;
}

canonical_original_code:
int intersectionPointSegment(struct struct_point point, struct struct_point A, struct struct_point B) {
 float a; float b;
 struct struct_vector vector = Vector(A, B);
 if(vector.y != 0)
  a = (vector.x) / (vector.y);
 else
  a = 0;
 b = (A.y) - (A.x)*a;
 if((point.x)*a + b - (point.y) == 0) {
  float xmin = ((A.x) < (B.x)) ? (A.x) : (B.x);
  float xmax = ((A.x) > (B.x)) ? (A.x) : (B.x);
  float ymin = ((A.y) < (B.y)) ? (A.y) : (B.y);
  float ymax = ((A.y) > (B.y)) ? (A.y) : (B.y);
  if(point.x >= xmin && point.x <= xmax && point.y >= ymin && point.y <= ymax)
   return 1;
 }
 return 0;
}

variable_types: struct struct_point { float x; float y; }

variable_types:
A
struct struct_point

variable_types:
B
struct struct_point

variable_types: a float

variable_types: b float

variable_types: struct struct_vector { float x; float y; }

variable_types: xmin float

variable_types: xmax float

variable_types: ymin float

variable_types: ymax float


intersectionSegments

original_code:
int intersectionSegments (Point2D A1, Point2D B1, Point2D A2, Point2D B2) {
 float a1, b1, a2, b2;
 float x, y;
 Vector2D vector1 = Vector(A1, B1);
 Vector2D vector2 = Vector(A2, B2);
 if(vector1.y != 0)
  a1 = vector1.x / vector1.y;
 else
  a1 = 0;
 if(vector2.y != 0)
  a2 = vector2.x / vector2.y;
 else
  a2 = 0;
 if(a1 != a2) {
  b1 = (A1.y) - (A1.x)*a1;
  b2 = (A2.y) - (A2.x)*a2;
  x = (b1 - b2) / (a2- a1);
  y = a2*x+b2;
  int xmin1 = ((A1.x) < (B1.x)) ? (A1.x) : (B1.x);
  int xmax1 = ((A1.x) > (B1.x)) ? (A1.x) : (B1.x);
  int ymin1 = ((A1.y) < (B1.y)) ? (A1.y) : (B1.y);
  int ymax1 = ((A1.y) > (B1.y)) ? (A1.y) : (B1.y);
  int xmin2 = ((A2.x) < (B2.x)) ? (A2.x) : (B2.x);
  int xmax2 = ((A2.x) > (B2.x)) ? (A2.x) : (B2.x);
  int ymin2 = ((A2.y) < (B2.y)) ? (A2.y) : (B2.y);
  int ymax2 = ((A2.y) > (B2.y)) ? (A2.y) : (B2.y);
  if(x >= xmin1 && x <= xmax1 && y >= ymin1 && y <= ymax1 && x >= xmin2 && x <= xmax2 && y >= ymin2 && y <= ymax2)
   return 1;
 }
 else {
  fprintf(stderr, "Les droites sont parrallèles : Il n'y a pas d'intersection\n");
  return 0;
 }
 return 0;
}

canonical_original_code:
int intersectionSegments(struct struct_point A1, struct struct_point B1, struct struct_point A2, struct struct_point B2) {
 float a1; float b1; float a2; float b2;
 float x; float y;
 struct struct_vector vector1 = Vector(A1, B1);
 struct struct_vector vector2 = Vector(A2, B2);
 if(vector1.y != 0)
  a1 = vector1.x / vector1.y;
 else
  a1 = 0;
 if(vector2.y != 0)
  a2 = vector2.x / vector2.y;
 else
  a2 = 0;
 if(a1 != a2) {
  b1 = (A1.y) - (A1.x)*a1;
  b2 = (A2.y) - (A2.x)*a2;
  x = (b1 - b2) / (a2- a1);
  y = a2*x+b2;
  int xmin1 = ((A1.x) < (B1.x)) ? (A1.x) : (B1.x);
  int xmax1 = ((A1.x) > (B1.x)) ? (A1.x) : (B1.x);
  int ymin1 = ((A1.y) < (B1.y)) ? (A1.y) : (B1.y);
  int ymax1 = ((A1.y) > (B1.y)) ? (A1.y) : (B1.y);
  int xmin2 = ((A2.x) < (B2.x)) ? (A2.x) : (B2.x);
  int xmax2 = ((A2.x) > (B2.x)) ? (A2.x) : (B2.x);
  int ymin2 = ((A2.y) < (B2.y)) ? (A2.y) : (B2.y);
  int ymax2 = ((A2.y) > (B2.y)) ? (A2.y) : (B2.y);
  if(x >= xmin1 && x <= xmax1 && y >= ymin1 && y <= ymax1 && x >= xmin2 && x <= xmax2 && y >= ymin2 && y <= ymax2)
   return 1;
 }
 else {
  fprintf(stderr, "Les droites sont parrallèles : Il n'y a pas d'intersection\n");
  return 0;
 }
 return 0;
}

variable_types: x float

variable_types: y float

user_defined_types: struct struct_point { float x; float y; }

user_defined_types: struct struct_vector { float x; float y; }


intersectionSegmentCercle

original_code:
int intersectionSegmentCercle (Point2D A, Point2D B, Point2D origin, float ray) {
 float a, b;
 Vector2D vector = Vector(A, B);
 if(vector.y != 0)
  a = (vector.x) / (vector.y);
 else
  a = 0;
 b = (A.y) - (A.x)*a;
 float Ad = a*a + 1;
 float Bd = 2*(-(origin.x) + a * (b - origin.y));
 float Cd = ((origin.x)*(origin.x)) + ((b - origin.y)*(b - origin.y)) - ((ray)*(ray));
 float delta = Bd*Bd - 4*Ad*Cd;
 int xmin = ((A.x) < (B.x)) ? (A.x) : (B.x);
 int xmax = ((A.x) > (B.x)) ? (A.x) : (B.x);
 int ymin = ((A.y) < (B.y)) ? (A.y) : (B.y);
 int ymax = ((A.y) > (B.y)) ? (A.y) : (B.y);
 if(delta < 0)
  return 0;
 else if (delta == 0) {
  int x, y;
  x = -Bd/ (2*Ad);
  y = a*x + b;
  if(xmin <= x && xmax >= x && ymin <= y && ymax >= y)
   return 1;
 }
 else {
  int x1, x2, y1, y2, test = 0;
  x1 = (-Bd - sqrt(delta)) / (2*Ad);
  x2 = (-Bd + sqrt(delta)) / (2*Ad);
  y1 = a*x1 + b;
  y2 = a*x2 + b;
  if(xmin <= x1 && xmax >= x1 && ymin <= y1 && ymax >= y1)
   test = 1;
  if(xmin <= x2 && xmax >= x2 && ymin <= y2 && ymax >= y2)
   test = 1;
  if(test == 1)
   return 1;
 }
 return 0;
}

canonical_original_code:
int intersectionSegmentCercle(struct struct_point A, struct struct_point B, struct struct_point origin, float ray) {
 float a; float b;
 struct struct_vector vector = Vector(A, B);
 if(vector.y != 0)
  a = (vector.x) / (vector.y);
 else
  a = 0;
 b = (A.y) - (A.x)*a;
 float Ad = a*a + 1;
 float Bd = 2*(-(origin.x) + a * (b - origin.y));
 float Cd = ((origin.x)*(origin.x)) + ((b - origin.y)*(b - origin.y)) - ((ray)*(ray));
 float delta = Bd*Bd - 4*Ad*Cd;
 int xmin = ((A.x) < (B.x)) ? (A.x) : (B.x);
 int xmax = ((A.x) > (B.x)) ? (A.x) : (B.x);
 int ymin = ((A.y) < (B.y)) ? (A.y) : (B.y);
 int ymax = ((A.y) > (B.y)) ? (A.y) : (B.y);
 if(delta < 0)
  return 0;
 else if (delta == 0) {
  int x; int y;
  x = -Bd/ (2*Ad);
  y = a*x + b;
  if(xmin <= x && xmax >= x && ymin <= y && ymax >= y)
   return 1;
 }
 else {
  int x1; int x2; int y1; int y2; int test = 0;
  x1 = (-Bd - sqrt(delta)) / (2*Ad);
  x2 = (-Bd + sqrt(delta)) / (2*Ad);
  y1 = a*x1 + b;
  y2 = a*x2 + b;
  if(xmin <= x1 && xmax >= x1 && ymin <= y1 && ymax >= y1)
   test = 1;
  if(xmin <= x2 && xmax >= x2 && ymin <= y2 && ymax >= y2)
   test = 1;
  if(test == 1)
   return 1;
 }
 return 0;
}

variable_types:
origin
struct struct_point

variable_types: ray float

variable_types: Ad float

variable_types: Bd float

variable_types: Cd float

variable_types: delta float

variable_types: xmin int

variable_types: xmax int

variable_types: ymin int

variable_types: ymax int

variable_types: x int

variable_types: y int

variable_types: test int


intersectionCarres

decompiled_code:
__int64 __fastcall intersectionCarres(double a1, double a2, double a3, double a4, float a5, float a6)
{
int v6; // esi
int v7; // ecx
int v8; // er8
int v9; // edi
int i; // edx

if ( *(float *)&a2 <= *(float *)&a1 )
v6 = (int)*(float *)&a2;
else
v6 = (int)*(float *)&a1;
if ( *(float *)&a1 <= *(float *)&a2 )
v7 = (int)*(float *)&a2;
else
v7 = (int)*(float *)&a1;
if ( *((float *)&a2 + 1) <= *((float *)&a1 + 1) )
v8 = (int)*((float *)&a2 + 1);
else
v8 = (int)*((float *)&a1 + 1);
if ( *((float *)&a1 + 1) <= *((float *)&a2 + 1) )
v9 = (int)*((float *)&a2 + 1);
else
v9 = (int)*((float *)&a1 + 1);
for ( i = 1; ; ++i )
{
if ( i == 3 )
{
a6 = *((float *)&a4 + 1);
a5 = *(float *)&a4;
goto LABEL_25;
}
if ( i - 1 <= 2 )
{
if ( i == 1 )
{
a6 = *((float *)&a3 + 1);
a5 = *(float *)&a3;
}
else
{
if ( i != 2 )
{
LABEL_17:
if ( (float)v7 < a5 )
goto LABEL_18;
LABEL_26:
if ( a5 < (float)v6 )
goto LABEL_18;
goto LABEL_27;
}
a6 = *((float *)&a4 + 1);
a5 = *(float *)&a3;
}
LABEL_25:
if ( (float)v7 < a5 )
continue;
goto LABEL_26;
}
if ( i != 4 )
goto LABEL_17;
if ( (float)v7 < *(float *)&a4 )
return 0LL;
if ( *(float *)&a4 < (float)v6 )
break;
a6 = *((float *)&a3 + 1);
a5 = *(float *)&a4;
LABEL_27:
if ( (float)v9 >= a6 && a6 >= (float)v8 )
return 1LL;
LABEL_18:
if ( i > 3 )
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(double a1, double a2, double a3, double a4, float a5, float a6)
{
int v6; // esi
int v7; // ecx
int v8; // er8
int v9; // edi
int i; // edx

if ( *(float *)&a2 <= *(float *)&a1 )
v6 = (int)*(float *)&a2;
else
v6 = (int)*(float *)&a1;
if ( *(float *)&a1 <= *(float *)&a2 )
v7 = (int)*(float *)&a2;
else
v7 = (int)*(float *)&a1;
if ( *((float *)&a2 + 1) <= *((float *)&a1 + 1) )
v8 = (int)*((float *)&a2 + 1);
else
v8 = (int)*((float *)&a1 + 1);
if ( *((float *)&a1 + 1) <= *((float *)&a2 + 1) )
v9 = (int)*((float *)&a2 + 1);
else
v9 = (int)*((float *)&a1 + 1);
for ( i = 1; ; ++i )
{
if ( i == 3 )
{
a6 = *((float *)&a4 + 1);
a5 = *(float *)&a4;
goto LABEL_25;
}
if ( i - 1 <= 2 )
{
if ( i == 1 )
{
a6 = *((float *)&a3 + 1);
a5 = *(float *)&a3;
}
else
{
if ( i != 2 )
{
LABEL_17:
if ( (float)v7 < a5 )
goto LABEL_18;
LABEL_26:
if ( a5 < (float)v6 )
goto LABEL_18;
goto LABEL_27;
}
a6 = *((float *)&a4 + 1);
a5 = *(float *)&a3;
}
LABEL_25:
if ( (float)v7 < a5 )
continue;
goto LABEL_26;
}
if ( i != 4 )
goto LABEL_17;
if ( (float)v7 < *(float *)&a4 )
return 0LL;
if ( *(float *)&a4 < (float)v6 )
break;
a6 = *((float *)&a3 + 1);
a5 = *(float *)&a4;
LABEL_27:
if ( (float)v9 >= a6 && a6 >= (float)v8 )
return 1LL;
LABEL_18:
if ( i > 3 )
return 0LL;
}
return 0LL;
}

original_code:
int intersectionCarres (Point2D point1, Point2D point2, Point2D pointC1, Point2D pointC2) {
 int i;
 Point2D point;
 int xmin = ((point1.x) < (point2.x)) ? (point1.x) : (point2.x);
 int xmax = ((point1.x) > (point2.x)) ? (point1.x) : (point2.x);
 int ymin = ((point1.y) < (point2.y)) ? (point1.y) : (point2.y);
 int ymax = ((point1.y) > (point2.y)) ? (point1.y) : (point2.y);
 for(i = 0; i < 4; i++) {
  switch(i) {
   case 0 :
    point.x = pointC1.x; point.y = pointC1.y;
    break;
   case 1 :
    point.x = pointC1.x; point.y = pointC2.y;
    break;
   case 2 :
    point.x = pointC2.x; point.y = pointC2.y;
    break;
   case 3 :
    point.x = pointC2.x; point.y = pointC1.y;
    break;
   default :
    break;
  }
  if(point.x <= xmax && point.x >= xmin && point.y <= ymax && point.y >= ymin)
   return 1;
 }
 return 0;
}

canonical_original_code:
int intersectionCarres(struct struct_point point1, struct struct_point point2, struct struct_point pointC1, struct struct_point pointC2) {
 int i;
 struct struct_point point;
 int xmin = ((point1.x) < (point2.x)) ? (point1.x) : (point2.x);
 int xmax = ((point1.x) > (point2.x)) ? (point1.x) : (point2.x);
 int ymin = ((point1.y) < (point2.y)) ? (point1.y) : (point2.y);
 int ymax = ((point1.y) > (point2.y)) ? (point1.y) : (point2.y);
 for(i = 0; i < 4; i++) {
  switch(i) {
   case 0 :
    point.x = pointC1.x; point.y = pointC1.y;
    break;
   case 1 :
    point.x = pointC1.x; point.y = pointC2.y;
    break;
   case 2 :
    point.x = pointC2.x; point.y = pointC2.y;
    break;
   case 3 :
    point.x = pointC2.x; point.y = pointC1.y;
    break;
   default :
    break;
  }
  if(point.x <= xmax && point.x >= xmin && point.y <= ymax && point.y >= ymin)
   return 1;
 }
 return 0;
}

variable_types: struct struct_point { float x; float y; }

variable_types: i int


intersectionCarreDisque

decompiled_code:
__int64 __fastcall intersectionCarreDisque(__m128i a1, __m128i a2, float a3, double a4, double a5, float a6, float a7)
{
int i; // edx
float v9; // [rsp+0h] [rbp-8h]
float v10; // [rsp+4h] [rbp-4h]

v9 = COERCE_FLOAT(_mm_cvtsi128_si32(a1));
v10 = COERCE_FLOAT(_mm_cvtsi128_si32(a2));
for ( i = 1; ; ++i )
{
if ( i == 3 )
{
a6 = *(float *)&a2.m128i_i32[1];
a7 = v10;
goto LABEL_13;
}
if ( i - 1 > 2 )
break;
if ( i == 1 )
{
a6 = *(float *)&a1.m128i_i32[1];
a7 = v9;
}
else
{
if ( i != 2 )
goto LABEL_4;
a6 = *(float *)&a2.m128i_i32[1];
a7 = v9;
}
LABEL_13:
if ( (float)((float)((float)((float)(a7 - *(float *)&a4) * (float)(a7 - *(float *)&a4))
+ (float)((float)(a6 - *((float *)&a4 + 1)) * (float)(a6 - *((float *)&a4 + 1))))
- (float)(a3 * a3)) <= 0.0 )
return 1LL;
LABEL_7:
;
}
if ( i == 4 )
{
a6 = *(float *)&a1.m128i_i32[1];
a7 = v10;
}
LABEL_4:
if ( (float)((float)((float)((float)(a7 - *(float *)&a4) * (float)(a7 - *(float *)&a4))
+ (float)((float)(a6 - *((float *)&a4 + 1)) * (float)(a6 - *((float *)&a4 + 1))))
- (float)(a3 * a3)) > 0.0 )
{
if ( i > 3 )
return 0LL;
goto LABEL_7;
}
return 1LL;
}

original_code:
int intersectionCarreDisque (Point2D point1, Point2D point2, float rayon, Point2D origin) {
 int i;
 Point2D point;
 for(i = 0; i < 4; i++) {
  switch(i) {
   case 0 :
    point.x = point1.x; point.y = point1.y;
    break;
   case 1 :
    point.x = point1.x; point.y = point2.y;
    break;
   case 2 :
    point.x = point2.x; point.y = point2.y;
    break;
   case 3 :
    point.x = point2.x; point.y = point1.y;
    break;
   default :
    break;
  }
  if(((point.x - origin.x) * (point.x - origin.x)) + ((point.y - origin.y) * (point.y - origin.y)) - (rayon * rayon) <= 0)
   return 1;
 }
 return 0;
}

canonical_original_code:
int intersectionCarreDisque(struct struct_point point1, struct struct_point point2, float rayon, struct struct_point origin) {
 int i;
 struct struct_point point;
 for(i = 0; i < 4; i++) {
  switch(i) {
   case 0 :
    point.x = point1.x; point.y = point1.y;
    break;
   case 1 :
    point.x = point1.x; point.y = point2.y;
    break;
   case 2 :
    point.x = point2.x; point.y = point2.y;
    break;
   case 3 :
    point.x = point2.x; point.y = point1.y;
    break;
   default :
    break;
  }
  if(((point.x - origin.x) * (point.x - origin.x)) + ((point.y - origin.y) * (point.y - origin.y)) - (rayon * rayon) <= 0)
   return 1;
 }
 return 0;
}

variable_types: rayon float


newInterface

decompiled_code:
_DWORD *newInterface()
{
_DWORD *v0; // rax
_DWORD *v1; // rbx

v0 = malloc(0x14uLL);
v1 = v0;
if ( v0 )
{
*v0 = 200;
v0[1] = 0;
v0[2] = 0;
v0[3] = 0;
v0[4] = 3;
}
else
{
fwrite(&unk_1E8, 1uLL, 0x34uLL, stderr);
}
return v1;
}

original_code:
Interface* newInterface (void) {
 Interface* interface = malloc(sizeof(Interface));
 if(interface != ((void *)0)) {
  interface->money = 200;
  interface->score = 0;
  interface->lvl = 0;
  interface->nbMonster = 0;
  interface->life = 3;
 }
 else {
  fprintf(stderr, "Erreur lors de l'allocation mémoire de l'interface\n");
  return ((void *)0);
 }
 return interface;
}

canonical_original_code:
struct struct_interface *newInterface() {
 struct struct_interface *interface = malloc(sizeof(Interface));
 if(interface != ((void *)0)) {
  interface->money = 200;
  interface->score = 0;
  interface->lvl = 0;
  interface->nbMonster = 0;
  interface->life = 3;
 }
 else {
  fprintf(stderr, "Erreur lors de l'allocation mémoire de l'interface\n");
  return ((void *)0);
 }
 return interface;
}

variable_types: struct struct_interface { int money; int score; int lvl; int nbMonster; int life; } *


updateInterface

decompiled_code:
__int64 __fastcall updateInterface(_DWORD *a1, __int64 a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a1 += *(_DWORD *)(a2 + 64);
a1[1] += *(_DWORD *)(a2 + 60);
++a1[3];
result = 1LL;
}
else
{
fwrite("Erreur avec le monstre\n", 1uLL, 0x17uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("Erreur avec l'interface\n", 1uLL, 0x18uLL, stderr);
result = 0LL;
}
return result;
}

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

if ( a1 )
{
if ( a2 )
{
*a1 += *(_DWORD *)(a2 + 64);
a1[1] += *(_DWORD *)(a2 + 60);
++a1[3];
result = 1LL;
}
else
{
fwrite("Erreur avec le monstre\n", 1uLL, 0x17uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("Erreur avec l'interface\n", 1uLL, 0x18uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
int updateInterface(Interface* interface, Monster* monster) {
 if(interface != ((void *)0)) {
  if(monster != ((void *)0)) {
   interface->money += monster->gain;
   interface->score += monster->points;
   interface->nbMonster ++;
  }
  else {
   fprintf(stderr, "Erreur avec le monstre\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Erreur avec l'interface\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int updateInterface(struct struct_interface *interface, struct struct_monster *monster) {
 if(interface != ((void *)0)) {
  if(monster != ((void *)0)) {
   interface->money += monster->gain;
   interface->score += monster->points;
   interface->nbMonster ++;
  }
  else {
   fprintf(stderr, "Erreur avec le monstre\n");
   return 0;
  }
 }
 else {
  fprintf(stderr, "Erreur avec l'interface\n");
  return 0;
 }
 return 1;
}

variable_types: struct struct_monster { float x; float y; float e; int sens; int animation; struct struct_node { float x; float y; struct struct_node *p_next; } *node_prev; struct struct_node *node_next; char *type; int pv; int pvMax; int resistance; int points; int gain; char *type_tower; int pace; struct struct_monster *p_prev; struct struct_monster *p_next; } *


updateLvl

decompiled_code:
__int64 __fastcall updateLvl(_DWORD *a1)
{
int v1; // eax
__int64 result; // rax

if ( a1 )
{
v1 = a1[2] + 1;
a1[2] = v1;
*a1 += 20 * v1;
a1[1] += 5 * v1;
if ( v1 == 5 * (v1 / 5) )
++a1[4];
result = 1LL;
}
else
{
fwrite("Erreur avec l'interface\n", 1uLL, 0x18uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1)
{
int v1; // eax
__int64 result; // rax

if ( a1 )
{
v1 = a1[2] + 1;
a1[2] = v1;
*a1 += 20 * v1;
a1[1] += 5 * v1;
if ( v1 == 5 * (v1 / 5) )
++a1[4];
result = 1LL;
}
else
{
fwrite("Erreur avec l'interface\n", 1uLL, 0x18uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
int updateLvl(Interface* interface) {
 if(interface != ((void *)0)) {
  interface->lvl ++;
  interface->money += (interface->lvl) * 20;
  interface->score += (interface->lvl) * 5;
  if((interface->lvl) % 5 == 0)
   interface->life ++;
 }
 else {
  fprintf(stderr, "Erreur avec l'interface\n");
  return 0;
 }
 return 1;
}

canonical_original_code:
int updateLvl(struct struct_interface *interface) {
 if(interface != ((void *)0)) {
  interface->lvl ++;
  interface->money += (interface->lvl) * 20;
  interface->score += (interface->lvl) * 5;
  if((interface->lvl) % 5 == 0)
   interface->life ++;
 }
 else {
  fprintf(stderr, "Erreur avec l'interface\n");
  return 0;
 }
 return 1;
}