decompiled_code:
char *ft_get_data()
{
unsigned int v0; // er15
char *v1; // rax
char *v2; // rbx
_DWORD *v3; // rax
size_t v4; // r13
int v5; // er14
_DWORD *v6; // rax
size_t v7; // rbp
char *v8; // r12
__int64 v9; // rax

v0 = open("./map/map.wlf", 0);
v1 = (char *)malloc(8uLL);
if ( !v1 )
exit(1);
v2 = v1;
v3 = get_n_line(v0);
*(_QWORD *)v2 = v3;
if ( v3 )
{
v4 = 8LL;
v5 = 0;
do
{
v7 = v4;
v4 += 8LL;
v8 = v2;
v2 = (char *)malloc(v4);
if ( !v2 )
exit(1);
v9 = 0LL;
if ( v5 >= 0 )
{
do
{
*(_QWORD *)&v2[v9] = *(_QWORD *)&v8[v9];
v9 += 8LL;
}
while ( v9 != v7 );
}
free(v8);
v6 = get_n_line(v0);
*(_QWORD *)&v2[v7] = v6;
++v5;
}
while ( v6 );
}
return v2;
}

canonical_decompiled_code:
char *func0()
{
unsigned int v0; // er15
char *v1; // rax
char *v2; // rbx
_DWORD *v3; // rax
size_t v4; // r13
int v5; // er14
_DWORD *v6; // rax
size_t v7; // rbp
char *v8; // r12
__int64 v9; // rax

v0 = open("./map/map.wlf", 0);
v1 = (char *)malloc(8uLL);
if ( !v1 )
exit(1);
v2 = v1;
v3 = get_n_line(v0);
*(_QWORD *)v2 = v3;
if ( v3 )
{
v4 = 8LL;
v5 = 0;
do
{
v7 = v4;
v4 += 8LL;
v8 = v2;
v2 = (char *)malloc(v4);
if ( !v2 )
exit(1);
v9 = 0LL;
if ( v5 >= 0 )
{
do
{
*(_QWORD *)&v2[v9] = *(_QWORD *)&v8[v9];
v9 += 8LL;
}
while ( v9 != v7 );
}
free(v8);
v6 = get_n_line(v0);
*(_QWORD *)&v2[v7] = v6;
++v5;
}
while ( v6 );
}
return v2;
}

original_code:
int **ft_get_data(void)
{
 int fd;
 int **tab;
 int i;
 int n;
 int **tabtmp;
 i = 0;
 fd = open("./map/map.wlf", 00);
 if (!(tab = (int**)malloc(sizeof(int*))))
  exit (1);
 tab[i] = get_n_line(fd);
 while (tab[i++] != ((void *)0))
 {
  n = -1;
  if (!(tabtmp = (int**)malloc(sizeof(int*) * (i + 1))))
   exit (1);
  while (++n < i)
   tabtmp[n] = tab[n];
  free(tab);
  tab = tabtmp;
  tab[i] = get_n_line(fd);
 }
 return (tab);
}

canonical_original_code:
int **ft_get_data()
{
 int fd;
 int **tab;
 int i;
 int n;
 int **tabtmp;
 i = 0;
 fd = open("./map/map.wlf", 00);
 if (!(tab = (int **)malloc(sizeof(int *))))
  exit (1);
 tab[i] = get_n_line(fd);
 while (tab[i++] != ((void *)0))
 {
  n = -1;
  if (!(tabtmp = (int **)malloc(sizeof(int *) * (i + 1))))
   exit (1);
  while (++n < i)
   tabtmp[n] = tab[n];
  free(tab);
  tab = tabtmp;
  tab[i] = get_n_line(fd);
 }
 return (tab);
}

variable_types: fd int

variable_types:
tab
int **

variable_types: n int

variable_types:
tabtmp
int **

return_type: int **


original_code:
t_obj *lst_push_back(t_obj *lst, t_obj *bgn_lst)
{
 t_obj *save;
 if (!bgn_lst)
  return (lst);
 else
 {
  save = bgn_lst;
  while (save->next != ((void *)0))
   save = save->next;
  save->next = lst;
 }
 return (bgn_lst);
}

canonical_original_code:
struct s_obj *lst_push_back(struct s_obj *lst, struct s_obj *bgn_lst)
{
 struct s_obj *save;
 if (!bgn_lst)
  return (lst);
 else
 {
  save = bgn_lst;
  while (save->next != ((void *)0))
   save = save->next;
  save->next = lst;
 }
 return (bgn_lst);
}

variable_types:
lst
struct s_obj *

variable_types: struct s_obj { enum e_obj_type { CAMERA=0, SPHERE=1, PLANE=2, CONE=3, CYLINDER=4, CUBE=5 } type; struct s_vect { float x; float y; float z; float l; } *pos; struct s_vect *nor; float posx; float posy; float posz; float norx; float nory; float norz; float radius; float height; float width; float depth; struct s_obj *next; int r; int g; int b; } *

user_defined_types: struct s_obj { enum e_obj_type type; struct s_vect *pos; struct s_vect *nor; float posx; float posy; float posz; float norx; float nory; float norz; float radius; float height; float width; float depth; struct s_obj *next; int r; int g; int b; }


decompiled_code:
__int64 __fastcall fill_data(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax
__int64 v4[11]; // [rsp+0h] [rbp-58h]

v4[0] = (__int64)&camera_data;
v4[1] = (__int64)&sphere_data;
v4[2] = (__int64)&plane_data;
v4[3] = (__int64)&cone_data;
v4[4] = (__int64)&cylinder_data;
v4[5] = (__int64)&cube_data;
v4[6] = 0LL;
if ( !a2 )
return 0LL;
v2 = ft_strsplit(a1, 59LL);
return ((__int64 (__fastcall *)(unsigned int *, __int64, __int64))v4[*a2])(a2, v2, a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax
__int64 v4[11]; // [rsp+0h] [rbp-58h]

v4[0] = (__int64)&camera_data;
v4[1] = (__int64)&sphere_data;
v4[2] = (__int64)&plane_data;
v4[3] = (__int64)&cone_data;
v4[4] = (__int64)&cylinder_data;
v4[5] = (__int64)&cube_data;
v4[6] = 0LL;
if ( !a2 )
return 0LL;
v2 = ft_strsplit(a1, 59LL);
return ((__int64 (__fastcall *)(unsigned int *, __int64, __int64))v4[*a2])(a2, v2, a1);
}

original_code:
t_obj *fill_data(char *buf, t_obj *lst)
{
 char **tab;
 ft_data *f[7] = {camera_data, sphere_data, plane_data, cone_data
     , cylinder_data, cube_data, ((void *)0)};
 if (lst == ((void *)0))
  return (((void *)0));
 tab = ft_strsplit(buf, ';');
 lst = f[lst->type](lst, tab, buf);
 return (lst);
}

canonical_original_code:
struct s_obj *fill_data(char *buf, struct s_obj *lst)
{
 char **tab;
 struct s_obj *(*f[7])(struct s_obj *lst, char **tab, char *buf) = {camera_data, sphere_data, plane_data, cone_data
     , cylinder_data, cube_data, ((void *)0)};
 if (lst == ((void *)0))
  return (((void *)0));
 tab = ft_strsplit(buf, ';');
 lst = f[lst->type](lst, tab, buf);
 return (lst);
}

variable_types:
buf
char *

variable_types:
tab
char **

variable_types: struct s_obj { enum e_obj_type { CAMERA=0, SPHERE=1, PLANE=2, CONE=3, CYLINDER=4, CUBE=5 } type; struct s_vect { float x; float y; float z; float l; } *pos; struct s_vect *nor; float posx; float posy; float posz; float norx; float nory; float norz; float radius; float height; float width; float depth; struct s_obj *next; int r; int g; int b; } *(*[7])(struct s_obj *lst, char **tab, char *buf)


decompiled_code:
__int64 __fastcall get_obj_from_file(__int64 a1)
{
unsigned int v1; // ebx
__int64 v2; // r12
unsigned int *v3; // rbp
char v4; // al
void *ptr; // [rsp+8h] [rbp-20h] BYREF

v1 = check_file();
if ( v1 == -1 )
file_error("Can't open file : ", a1);
v2 = 0LL;
v3 = 0LL;
while ( (int)get_next_line(v1, &ptr) > 0 )
{
v4 = *(_BYTE *)ptr;
if ( *(_BYTE *)ptr != 47 && v4 != 42 )
{
if ( v4 == 38 )
{
v3 = build_lnk((__int64)ptr);
}
else if ( (unsigned __int8)(v4 - 48) <= 9u || v4 == 45 )
{
v3 = (unsigned int *)fill_data((__int64)ptr, v3);
v2 = lst_push_back((__int64)v3, v2);
}
}
free(ptr);
ptr = 0LL;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // ebx
__int64 v2; // r12
unsigned int *v3; // rbp
char v4; // al
void *ptr; // [rsp+8h] [rbp-20h] BYREF

v1 = check_file();
if ( v1 == -1 )
file_error("Can't open file : ", a1);
v2 = 0LL;
v3 = 0LL;
while ( (int)get_next_line(v1, &ptr) > 0 )
{
v4 = *(_BYTE *)ptr;
if ( *(_BYTE *)ptr != 47 && v4 != 42 )
{
if ( v4 == 38 )
{
v3 = build_lnk((__int64)ptr);
}
else if ( (unsigned __int8)(v4 - 48) <= 9u || v4 == 45 )
{
v3 = (unsigned int *)func1((__int64)ptr, v3);
v2 = func0((__int64)v3, v2);
}
}
free(ptr);
ptr = 0LL;
}
return v2;
}

original_code:
t_obj *get_obj_from_file(char *file)
{
 int fd;
 char *buf;
 t_obj *lst;
 t_obj *bgn_lst;
 lst = ((void *)0);
 bgn_lst = ((void *)0);
 if ((fd = check_file(file)) == -1)
  file_error("Can't open file : ", file);
 while (get_next_line(fd, &buf) > 0)
 {
  if (buf[0] == '/' || buf[0] == '*')
   ;
  else if (buf[0] == '&')
   lst = build_lnk(buf);
  else if (buf[0] == '-' || (buf[0] >= '0' && buf[0] <= '9'))
  {
   lst = fill_data(buf, lst);
   bgn_lst = lst_push_back(lst, bgn_lst);
  }
  free(buf);
  buf = ((void *)0);
 }
 return (bgn_lst);
}

canonical_original_code:
struct s_obj *get_obj_from_file(char *file)
{
 int fd;
 char *buf;
 struct s_obj *lst;
 struct s_obj *bgn_lst;
 lst = ((void *)0);
 bgn_lst = ((void *)0);
 if ((fd = check_file(file)) == -1)
  file_error("Can't open file : ", file);
 while (get_next_line(fd, &buf) > 0)
 {
  if (buf[0] == '/' || buf[0] == '*')
   ;
  else if (buf[0] == '&')
   lst = build_lnk(buf);
  else if (buf[0] == '-' || (buf[0] >= '0' && buf[0] <= '9'))
  {
   lst = fill_data(buf, lst);
   bgn_lst = lst_push_back(lst, bgn_lst);
  }
  free(buf);
  buf = ((void *)0);
 }
 return (bgn_lst);
}

variable_types:
file
char *

return_type: struct s_obj { enum e_obj_type { CAMERA=0, SPHERE=1, PLANE=2, CONE=3, CYLINDER=4, CUBE=5 } type; struct s_vect { float x; float y; float z; float l; } *pos; struct s_vect *nor; float posx; float posy; float posz; float norx; float nory; float norz; float radius; float height; float width; float depth; struct s_obj *next; int r; int g; int b; } *


decompiled_code:
void __noreturn ft_fork_error()
{
ft_putstr_fd("Error: fork has encountered a problem and can't be executed.", 2LL);
ft_putstr_fd("Exit.\n", 2LL);
exit(-1);
}

canonical_decompiled_code:
void __noreturn func0()
{
ft_putstr_fd("Error: fork has encountered a problem and can't be executed.", 2LL);
ft_putstr_fd("Exit.\n", 2LL);
exit(-1);
}

original_code:
void ft_fork_error(void)
{
 ft_putstr_fd("Error: fork has encountered a problem and can't be executed.", 2);
 ft_putstr_fd("Exit.\n", 2);
 exit(-1);
}

canonical_original_code:
void ft_fork_error()
{
 ft_putstr_fd("Error: fork has encountered a problem and can't be executed.", 2);
 ft_putstr_fd("Exit.\n", 2);
 exit(-1);
}

return_type: void


decompiled_code:
void __fastcall __noreturn ft_right_error(__int64 a1)
{
ft_putstr_fd("Error: Permission denied for ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd("\n", 2LL);
exit(-2);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(__int64 a1)
{
ft_putstr_fd("Error: Permission denied for ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd("\n", 2LL);
exit(-2);
}

original_code:
void ft_right_error(const char *s)
{
 ft_putstr_fd("Error: Permission denied for ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd("\n", 2);
 exit(-2);
}

canonical_original_code:
void ft_right_error(char *s)
{
 ft_putstr_fd("Error: Permission denied for ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd("\n", 2);
 exit(-2);
}

variable_types:
s
char *


decompiled_code:
void __fastcall __noreturn ft_exist_error(__int64 a1)
{
ft_putstr_fd("Error: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(" doesn't exist\n", 2LL);
exit(-3);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(__int64 a1)
{
ft_putstr_fd("Error: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(" doesn't exist\n", 2LL);
exit(-3);
}

original_code:
void ft_exist_error(const char *s)
{
 ft_putstr_fd("Error: ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd(" doesn't exist\n", 2);
 exit(-3);
}

canonical_original_code:
void ft_exist_error(char *s)
{
 ft_putstr_fd("Error: ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd(" doesn't exist\n", 2);
 exit(-3);
}


decompiled_code:
void __fastcall __noreturn ft_arg_error(__int64 a1)
{
ft_putstr_fd("Pipex usage error: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd("\n", 2LL);
ft_putstr_fd("Usage: ./pipex infile command1 command2 outfile\n", 2LL);
exit(-4);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(__int64 a1)
{
ft_putstr_fd("Pipex usage error: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd("\n", 2LL);
ft_putstr_fd("Usage: ./pipex infile command1 command2 outfile\n", 2LL);
exit(-4);
}

original_code:
void ft_arg_error(const char *s)
{
 ft_putstr_fd("Pipex usage error: ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd("\n", 2);
 ft_putstr_fd("Usage: ./pipex infile command1 command2 outfile\n", 2);
 exit(-4);
}

canonical_original_code:
void ft_arg_error(char *s)
{
 ft_putstr_fd("Pipex usage error: ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd("\n", 2);
 ft_putstr_fd("Usage: ./pipex infile command1 command2 outfile\n", 2);
 exit(-4);
}


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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (*(_DWORD *)a1 == 8) + (unsigned int)result;
a1 = *(_QWORD *)(a1 + 16);
}
while ( a1 );
return result;
}

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (*(_DWORD *)a1 == 8) + (unsigned int)result;
a1 = *(_QWORD *)(a1 + 16);
}
while ( a1 );
return result;
}

original_code:
int tot_nb_of_heroes(t_lex *lex)
{
 int count;
 count = 0;
 while (lex)
 {
  if (lex->token == HERO_FILE)
   count++;
  lex = lex->next;
 }
 return (count);
}

canonical_original_code:
int tot_nb_of_heroes(struct s_lex *lex)
{
 int count;
 count = 0;
 while (lex)
 {
  if (lex->token == HERO_FILE)
   count++;
  lex = lex->next;
 }
 return (count);
}

variable_types: struct s_lex { enum e_tok { UNKNOWN=0, DUMP=1, NUMBER=2, HERO_NUMB=4, HERO_FILE=8, VERBOSE=16 } token; char *value; struct s_lex *next; } *

variable_types: count int

return_type: int

user_defined_types: struct s_lex { enum e_tok token; char *value; struct s_lex *next; }


decompiled_code:
__int64 __fastcall next_num_available(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // edx

if ( !a1 )
return 1;
v1 = a1;
v2 = 1;
do
{
while ( *(_DWORD *)(v1 + 16) == v2 )
{
++v2;
v1 = a1;
}
v1 = *(_QWORD *)(v1 + 24);
}
while ( v1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // edx

if ( !a1 )
return 1;
v1 = a1;
v2 = 1;
do
{
while ( *(_DWORD *)(v1 + 16) == v2 )
{
++v2;
v1 = a1;
}
v1 = *(_QWORD *)(v1 + 24);
}
while ( v1 );
return v2;
}

original_code:
int next_num_available(t_hero *lst)
{
 int num_available;
 t_hero *tmp;
 num_available = 1;
 tmp = lst;
 while (tmp)
 {
  if (tmp->hero_num == num_available)
  {
   num_available++;
   tmp = lst;
  }
  else
   tmp = tmp->next;
 }
 return (num_available);
}

canonical_original_code:
int next_num_available(struct s_hero *lst)
{
 int num_available;
 struct s_hero *tmp;
 num_available = 1;
 tmp = lst;
 while (tmp)
 {
  if (tmp->hero_num == num_available)
  {
   num_available++;
   tmp = lst;
  }
  else
   tmp = tmp->next;
 }
 return (num_available);
}

variable_types: struct s_hero { unsigned char *buf; char *name; int hero_num; struct s_hero *next; } *


decompiled_code:
__int64 __fastcall find_prog_size(int fd)
{
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

lseek(fd, 136LL, 0);
read(fd, buf, 4uLL);
return _byteswap_ulong(buf[0]);
}

canonical_decompiled_code:
__int64 __fastcall func2(int fd)
{
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

lseek(fd, 136LL, 0);
read(fd, buf, 4uLL);
return _byteswap_ulong(buf[0]);
}

original_code:
t_ui find_prog_size(int fd)
{
 unsigned int prog_size;
 unsigned char c[4];
 prog_size = sizeof(int) + (128) + 1;
 if ((((128) + 1) % 4) > 0)
  prog_size = prog_size + 4 - (((128) + 1) % 4);
 lseek(fd, prog_size, 0);
 read(fd, c, 4);
 prog_size = (unsigned int)(c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3]);
 return (prog_size);
}

canonical_original_code:
unsigned int find_prog_size(int fd)
{
 unsigned int prog_size;
 unsigned char c[4];
 prog_size = sizeof(int) + (128) + 1;
 if ((((128) + 1) % 4) > 0)
  prog_size = prog_size + 4 - (((128) + 1) % 4);
 lseek(fd, prog_size, 0);
 read(fd, c, 4);
 prog_size = (unsigned int)(c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3]);
 return (prog_size);
}

variable_types:
c
unsigned char [4]

return_type: unsigned int


decompiled_code:
__int64 __fastcall hero_push_back(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = *(_QWORD *)(a1 + 4104);
if ( result )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 24);
}
while ( result );
*(_QWORD *)(v3 + 24) = a2;
}
else
{
*(_QWORD *)(a1 + 4104) = a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = *(_QWORD *)(a1 + 4104);
if ( result )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 24);
}
while ( result );
*(_QWORD *)(v3 + 24) = a2;
}
else
{
*(_QWORD *)(a1 + 4104) = a2;
}
return result;
}

original_code:
void hero_push_back(t_dat *d, t_hero *new)
{
 t_hero *tmp;
 if (d->hero_lst == ((void *)0))
  d->hero_lst = new;
 else
 {
  tmp = d->hero_lst;
  while (tmp->next)
   tmp = tmp->next;
  tmp->next = new;
 }
}

canonical_original_code:
void hero_push_back(struct s_dat *d, struct s_hero *new)
{
 struct s_hero *tmp;
 if (d->hero_lst == ((void *)0))
  d->hero_lst = new;
 else
 {
  tmp = d->hero_lst;
  while (tmp->next)
   tmp = tmp->next;
  tmp->next = new;
 }
}

variable_types: struct s_dat { unsigned char arena[-1]; struct s_proc { unsigned char reg[-1]; int pc; int carry; unsigned char instruct; unsigned char params; int cycle_to_exec; int nbr_live; struct s_proc *next; } **bgn_lst; struct s_hero { unsigned char *buf; char *name; int hero_num; struct s_hero *next; } *hero_lst; int cycle_to_die; int do_we_check; int nb_checks; int current_cycle; int dump; int last_player_alive; int verbose; } *

variable_types:
new
struct s_hero *

user_defined_types: struct s_dat { unsigned char arena[-1]; struct s_proc **bgn_lst; struct s_hero *hero_lst; int cycle_to_die; int do_we_check; int nb_checks; int current_cycle; int dump; int last_player_alive; int verbose; }


decompiled_code:
_BOOL8 __fastcall check_magic_number(int fd)
{
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

lseek(fd, 0LL, 0);
read(fd, buf, 4uLL);
return _byteswap_ulong(buf[0]) == 15369203;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(int fd)
{
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

lseek(fd, 0LL, 0);
read(fd, buf, 4uLL);
return _byteswap_ulong(buf[0]) == 15369203;
}

original_code:
int check_magic_number(int fd)
{
 t_ui magic;
 t_uc c[4];
 lseek(fd, 0, 0);
 read(fd, c, 4);
 magic = (unsigned int)(c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3]);
 return (magic == 0xea83f3);
}

canonical_original_code:
int check_magic_number(int fd)
{
 unsigned int magic;
 unsigned char c[4];
 lseek(fd, 0, 0);
 read(fd, c, 4);
 magic = (unsigned int)(c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3]);
 return (magic == 0xea83f3);
}

variable_types: fd int

variable_types:
magic
unsigned int


decompiled_code:
__int64 __fastcall check_and_fill_ant_nbr(int **a1, _BYTE *a2)
{
int *v2; // rbp
__int64 result; // rax

if ( (unsigned __int8)(*a2 - 48) > 9u )
{
ft_error_2("Error in parsing ant number. ", "First param must be the ant number");
}
else
{
v2 = *a1;
*v2 = ft_atoi(a2);
}
result = (__int64)*a1;
if ( **a1 <= 0 )
result = ft_error_2("Error in parsing ant number. ", "Ant number must be > 0");
return result;
}

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

if ( (unsigned __int8)(*a2 - 48) > 9u )
{
ft_error_2("Error in parsing ant number. ", "First param must be the ant number");
}
else
{
v2 = *a1;
*v2 = ft_atoi(a2);
}
result = (__int64)*a1;
if ( **a1 <= 0 )
result = ft_error_2("Error in parsing ant number. ", "Ant number must be > 0");
return result;
}

original_code:
void check_and_fill_ant_nbr(t_info **info, char *line)
{
 if (line[0] >= '0' && line[0] <= '9')
  (*info)->ant = ft_atoi(line);
 else
  ft_error_2("Error in parsing ant number. "
    , "First param must be the ant number");
 if ((*info)->ant < 1)
  ft_error_2("Error in parsing ant number. ", "Ant number must be > 0");
}

canonical_original_code:
void check_and_fill_ant_nbr(struct s_info **info, char *line)
{
 if (line[0] >= '0' && line[0] <= '9')
  (*info)->ant = ft_atoi(line);
 else
  ft_error_2("Error in parsing ant number. "
    , "First param must be the ant number");
 if ((*info)->ant < 1)
  ft_error_2("Error in parsing ant number. ", "Ant number must be > 0");
}

variable_types: struct s_info { int ant; struct s_room { char *name; int posx; int posy; struct s_pipe { struct s_room *list; struct s_pipe *next; } *pipe; struct s_room *next; } *start; struct s_room *end; struct s_room *list; } **

variable_types:
line
char *

user_defined_types: struct s_info { int ant; struct s_room *start; struct s_room *end; struct s_room *list; }

user_defined_types: struct s_room { char *name; int posx; int posy; struct s_pipe *pipe; struct s_room *next; }


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

result = 0LL;
if ( a1 )
{
while ( *(_DWORD *)a1 != 3 )
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 16);
if ( !a1 )
return result;
}
do
{
if ( *(_DWORD *)a1 == 6 )
break;
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 16);
}
while ( a1 );
}
return result;
}

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

result = 0LL;
if ( a1 )
{
while ( *(_DWORD *)a1 != 3 )
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 16);
if ( !a1 )
return result;
}
do
{
if ( *(_DWORD *)a1 == 6 )
break;
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 16);
}
while ( a1 );
}
return result;
}

original_code:
int find_arg_number(t_tok *tok)
{
 int i;
 i = 0;
 while (tok != ((void *)0) && tok->type != 3)
 {
  i++;
  tok = tok->next;
 }
 while (tok != ((void *)0) && tok->type != 6)
 {
  i++;
  tok = tok->next;
 }
 return (i);
}

canonical_original_code:
int find_arg_number(struct s_tok *tok)
{
 int i;
 i = 0;
 while (tok != ((void *)0) && tok->type != 3)
 {
  i++;
  tok = tok->next;
 }
 while (tok != ((void *)0) && tok->type != 6)
 {
  i++;
  tok = tok->next;
 }
 return (i);
}

variable_types: struct s_tok { enum e_type { START=0, END=1, COMMENT=2, NAME=3, POS=4, IGNORE=5, ENDLINE=6 } type; char *val; struct s_tok *next; } *

variable_types: i int

user_defined_types: struct s_tok { enum e_type type; char *val; struct s_tok *next; }


decompiled_code:
__int64 __fastcall pipe_push_back(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rdx

if ( !a1 )
return a2;
v2 = a1;
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
*(_QWORD *)(v3 + 8) = a2;
return a1;
}

original_code:
t_pipe *pipe_push_back(t_pipe *old, t_pipe *new)
{
 t_pipe *save;
 save = old;
 if (old == ((void *)0))
  return (new);
 while (old->next != ((void *)0))
  old = old->next;
 old->next = new;
 return (save);
}

canonical_original_code:
struct s_pipe *pipe_push_back(struct s_pipe *old, struct s_pipe *new)
{
 struct s_pipe *save;
 save = old;
 if (old == ((void *)0))
  return (new);
 while (old->next != ((void *)0))
  old = old->next;
 old->next = new;
 return (save);
}

variable_types:
old
struct s_pipe *

variable_types:
new
struct s_pipe *

variable_types: struct s_pipe { struct s_room { char *name; int posx; int posy; struct s_pipe *pipe; struct s_room *next; } *list; struct s_pipe *next; } *

user_defined_types: struct s_pipe { struct s_room *list; struct s_pipe *next; }


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

v2 = malloc(0x10uLL);
*v2 = a2;
v2[1] = 0LL;
result = pipe_push_back(*(_QWORD *)(a1 + 16), (__int64)v2);
*(_QWORD *)(a1 + 16) = result;
return result;
}

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

v2 = malloc(0x10uLL);
*v2 = a2;
v2[1] = 0LL;
result = func2(*(_QWORD *)(a1 + 16), (__int64)v2);
*(_QWORD *)(a1 + 16) = result;
return result;
}

original_code:
t_pipe *build_pipe_list(t_room *room, t_room *save)
{
 t_pipe *pipe;
 pipe = (t_pipe*)malloc(sizeof(t_pipe));
 pipe->list = save;
 pipe->next = ((void *)0);
 room->pipe = pipe_push_back(room->pipe, pipe);
 return (room->pipe);
}

canonical_original_code:
struct s_pipe *build_pipe_list(struct s_room *room, struct s_room *save)
{
 struct s_pipe *pipe;
 pipe = (struct s_pipe *)malloc(sizeof(t_pipe));
 pipe->list = save;
 pipe->next = ((void *)0);
 room->pipe = pipe_push_back(room->pipe, pipe);
 return (room->pipe);
}

variable_types:
room
struct s_room *

variable_types:
save
struct s_room *

return_type: struct s_pipe { struct s_room { char *name; int posx; int posy; struct s_pipe *pipe; struct s_room *next; } *list; struct s_pipe *next; } *


original_code:
void get_info(t_info *info, t_tok *tok)
{
 t_tok *save;
 int i;
 t_room *saveroom;
 save = tok, i = -1;
 info->ant = ft_atoi(tok->val);
 tok = tok->next;
 while (tok != ((void *)0))
 {
  if (find_arg_number(tok) == 4)
   info->list = init_room(&tok, info->list);
  else
   tok = tok->next;
 }
 tok = save->next->next;
 while (tok != ((void *)0))
 {
  saveroom = info->list;
  if (find_arg_number(tok) == 3)
  {
   printf("tok = %s\n", tok->val);
   while (saveroom != ((void *)0))
   {
    printf("saveroom = %s\n", saveroom->name);
    if (ft_strcmp(tok->val, saveroom->name) == 0)
    {
     printf("Quand je rentre ici saveroom = %s et tok = %s\n", saveroom->name, tok->val);
     connection_list(save->next->next, saveroom, info->list);
    }
    saveroom = saveroom->next;
   }
  }
  tok = tok->next;
 }
 while (info->list != ((void *)0))
 {
  printf("name = %s\n", info->list->name);
  while (info->list->pipe != ((void *)0))
  {
   printf("pipe = %s\n", info->list->pipe->list->name);
   info->list->pipe = info->list->pipe->next;
  }
  info->list = info->list->next;
 }
}

canonical_original_code:
void get_info(struct s_info *info, struct s_tok *tok)
{
 struct s_tok *save;
 int i;
 struct s_room *saveroom;
 save = tok, i = -1;
 info->ant = ft_atoi(tok->val);
 tok = tok->next;
 while (tok != ((void *)0))
 {
  if (find_arg_number(tok) == 4)
   info->list = init_room(&tok, info->list);
  else
   tok = tok->next;
 }
 tok = save->next->next;
 while (tok != ((void *)0))
 {
  saveroom = info->list;
  if (find_arg_number(tok) == 3)
  {
   printf("tok = %s\n", tok->val);
   while (saveroom != ((void *)0))
   {
    printf("saveroom = %s\n", saveroom->name);
    if (ft_strcmp(tok->val, saveroom->name) == 0)
    {
     printf("Quand je rentre ici saveroom = %s et tok = %s\n", saveroom->name, tok->val);
     connection_list(save->next->next, saveroom, info->list);
    }
    saveroom = saveroom->next;
   }
  }
  tok = tok->next;
 }
 while (info->list != ((void *)0))
 {
  printf("name = %s\n", info->list->name);
  while (info->list->pipe != ((void *)0))
  {
   printf("pipe = %s\n", info->list->pipe->list->name);
   info->list->pipe = info->list->pipe->next;
  }
  info->list = info->list->next;
 }
}

variable_types: struct s_info { int ant; struct s_room { char *name; int posx; int posy; struct s_pipe { struct s_room *list; struct s_pipe *next; } *pipe; struct s_room *next; } *start; struct s_room *end; struct s_room *list; } *

user_defined_types: enum e_type { START=0, END=1, COMMENT=2, NAME=3, POS=4, IGNORE=5, ENDLINE=6 }


original_code:
void fill_orient(t_cam *cam)
{
 cam->frontvect = new_vect((cam->pos->x - cam->dir->x),
       (cam->pos->y - cam->dir->y),
       (cam->pos->z - cam->dir->z));
 norm_vect(cam->frontvect);
 cam->sidevect = new_vect(((cam->frontvect->y * -1.0) - (cam->frontvect->z * 0.0)),
       ((cam->frontvect->z * 0.0) - (cam->frontvect->x * -1.0)),
       ((cam->frontvect->x * 0.0) - (cam->frontvect->y * 0.0)));
 norm_vect(cam->sidevect);
 cam->upvect = new_vect(((cam->sidevect->y * cam->frontvect->z)
       - (cam->sidevect->z * cam->frontvect->y)),
       ((cam->sidevect->z * cam->frontvect->x)
       - (cam->sidevect->x * cam->frontvect->z)),
       ((cam->sidevect->x * cam->frontvect->y)
       - (cam->sidevect->y * cam->frontvect->x)));
 norm_vect(cam->frontvect);
}

canonical_original_code:
void fill_orient(struct s_cam *cam)
{
 cam->frontvect = new_vect((cam->pos->x - cam->dir->x),
       (cam->pos->y - cam->dir->y),
       (cam->pos->z - cam->dir->z));
 norm_vect(cam->frontvect);
 cam->sidevect = new_vect(((cam->frontvect->y * -1.0) - (cam->frontvect->z * 0.0)),
       ((cam->frontvect->z * 0.0) - (cam->frontvect->x * -1.0)),
       ((cam->frontvect->x * 0.0) - (cam->frontvect->y * 0.0)));
 norm_vect(cam->sidevect);
 cam->upvect = new_vect(((cam->sidevect->y * cam->frontvect->z)
       - (cam->sidevect->z * cam->frontvect->y)),
       ((cam->sidevect->z * cam->frontvect->x)
       - (cam->sidevect->x * cam->frontvect->z)),
       ((cam->sidevect->x * cam->frontvect->y)
       - (cam->sidevect->y * cam->frontvect->x)));
 norm_vect(cam->frontvect);
}

variable_types: struct s_cam { struct s_vect { float x; float y; float z; float l; } *pos; struct s_vect *dir; struct s_vect *dirray; struct s_vect *frontvect; struct s_vect *sidevect; struct s_vect *upvect; float t_min; float t_max; float vpwidth; float vpheight; float vpdist; struct s_vect *vpupleftpos; } *

user_defined_types: struct s_cam { struct s_vect *pos; struct s_vect *dir; struct s_vect *dirray; struct s_vect *frontvect; struct s_vect *sidevect; struct s_vect *upvect; float t_min; float t_max; float vpwidth; float vpheight; float vpdist; struct s_vect *vpupleftpos; }


decompiled_code:
__int64 __fastcall find_upleftpos(__int64 a1)
{
void *v1; // r12
void *v2; // rbp
void *v3; // r13
void *v4; // r12
__int64 v5; // rbx

if ( *(float *)&val_3 == 0.0 )
*(float *)&val_3 = 0.5 * *(float *)(a1 + 60);
if ( *(float *)&val2_2 == 0.0 )
*(float *)&val2_2 = 0.5 * *(float *)(a1 + 56);
v1 = (void *)matrix_mul_by_val(*(_QWORD *)(a1 + 40), *(float *)&val_3);
v2 = (void *)matrix_mul_by_val(*(_QWORD *)(a1 + 32), *(float *)&val2_2);
v3 = (void *)matrix_add(*(_QWORD *)(a1 + 24), v1);
free(v1);
v4 = (void *)matrix_add(*(_QWORD *)a1, v3);
free(v3);
v5 = matrix_sub(v4, v2);
free(v4);
free(v2);
norm_vect(v5);
return v5;
}

original_code:
t_vect *find_upleftpos(t_cam *cam)
{
 static t_type val = 0;
 static t_type val2 = 0;
 t_vect *vect1;
 t_vect *vect2;
 t_vect *vect3;
 if (val == 0)
  val = cam->vpheight / 2.0;
 if (val2 == 0)
  val2 = cam->vpwidth / 2.0;
 vect1 = matrix_mul_by_val(cam->upvect, val);
 vect2 = matrix_mul_by_val(cam->sidevect, val2);
 vect3 = matrix_add(cam->frontvect, vect1);
 free(vect1);
 vect1 = matrix_add(cam->pos, vect3);
 free(vect3);
 vect3 = matrix_sub(vect1, vect2);
 free(vect1);
 free(vect2);
 norm_vect(vect3);
 return (vect3);
}

canonical_original_code:
struct s_vect *find_upleftpos(struct s_cam *cam)
{
 static float val = 0;
 static float val2 = 0;
 struct s_vect *vect1;
 struct s_vect *vect2;
 struct s_vect *vect3;
 if (val == 0)
  val = cam->vpheight / 2.0;
 if (val2 == 0)
  val2 = cam->vpwidth / 2.0;
 vect1 = matrix_mul_by_val(cam->upvect, val);
 vect2 = matrix_mul_by_val(cam->sidevect, val2);
 vect3 = matrix_add(cam->frontvect, vect1);
 free(vect1);
 vect1 = matrix_add(cam->pos, vect3);
 free(vect3);
 vect3 = matrix_sub(vect1, vect2);
 free(vect1);
 free(vect2);
 norm_vect(vect3);
 return (vect3);
}

variable_types: struct s_cam { struct s_vect *pos; struct s_vect *dir; struct s_vect *dirray; struct s_vect *frontvect; struct s_vect *sidevect; struct s_vect *upvect; float t_min; float t_max; float vpwidth; float vpheight; float vpdist; struct s_vect *vpupleftpos; } *

variable_types: val float

variable_types: struct s_vect { float x; float y; float z; float l; } *


original_code:
t_cam *create_camera(t_cam *cam, t_vect *pos, t_vect *dir)
{
 cam = (t_cam*)malloc(sizeof(t_cam));
 cam->dirray = (t_vect*)malloc(sizeof(t_vect));
 cam->pos = pos;
 cam->dir = dir;
 norm_vect(cam->dir);
 cam->vpwidth = 0.5;
 cam->vpheight = 0.5;
 cam->vpdist = 1.0;
 fill_orient(cam);
 cam->t_min = 0;
 cam->t_max = 2000000000;
 cam->vpupleftpos = find_upleftpos(cam);
 cam = store_cam(cam);
 return (cam);
}

canonical_original_code:
struct s_cam *create_camera(struct s_cam *cam, struct s_vect *pos, struct s_vect *dir)
{
 cam = (struct s_cam *)malloc(sizeof(t_cam));
 cam->dirray = (struct s_vect *)malloc(sizeof(t_vect));
 cam->pos = pos;
 cam->dir = dir;
 norm_vect(cam->dir);
 cam->vpwidth = 0.5;
 cam->vpheight = 0.5;
 cam->vpdist = 1.0;
 fill_orient(cam);
 cam->t_min = 0;
 cam->t_max = 2000000000;
 cam->vpupleftpos = find_upleftpos(cam);
 cam = store_cam(cam);
 return (cam);
}

variable_types:
cam
struct s_cam *

variable_types:
pos
struct s_vect *

variable_types:
dir
struct s_vect *

return_type: struct s_cam { struct s_vect { float x; float y; float z; float l; } *pos; struct s_vect *dir; struct s_vect *dirray; struct s_vect *frontvect; struct s_vect *sidevect; struct s_vect *upvect; float t_min; float t_max; float vpwidth; float vpheight; float vpdist; struct s_vect *vpupleftpos; } *


decompiled_code:
__int64 __fastcall update_cam_dirray(__int64 a1, float a2, float a3)
{
void *v3; // r12
void *v4; // rbp
void *v5; // r12
__int64 v6; // r13
__int64 v7; // rbx
__int64 v8; // rbx

if ( *(float *)&iincr_1 == 0.0 )
*(float *)&iincr_1 = *(float *)(a1 + 56) / 700.0;
if ( *(float *)&jincr_0 == 0.0 )
*(float *)&jincr_0 = *(float *)(a1 + 60) / 700.0;
v3 = (void *)matrix_mul_by_val(*(_QWORD *)(a1 + 32), *(float *)&iincr_1);
v4 = (void *)matrix_mul_by_val(v3, a2);
free(v3);
v5 = (void *)matrix_mul_by_val(*(_QWORD *)(a1 + 40), *(float *)&jincr_0);
v6 = matrix_mul_by_val(v5, a3);
free(v5);
v7 = matrix_add(*(_QWORD *)(a1 + 72), v4);
free(v4);
v8 = matrix_sub(v7, v6);
norm_vect(v8);
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, float a2, float a3)
{
void *v3; // r12
void *v4; // rbp
void *v5; // r12
__int64 v6; // r13
__int64 v7; // rbx
__int64 v8; // rbx

if ( *(float *)&iincr_1 == 0.0 )
*(float *)&iincr_1 = *(float *)(a1 + 56) / 700.0;
if ( *(float *)&jincr_0 == 0.0 )
*(float *)&jincr_0 = *(float *)(a1 + 60) / 700.0;
v3 = (void *)matrix_mul_by_val(*(_QWORD *)(a1 + 32), *(float *)&iincr_1);
v4 = (void *)matrix_mul_by_val(v3, a2);
free(v3);
v5 = (void *)matrix_mul_by_val(*(_QWORD *)(a1 + 40), *(float *)&jincr_0);
v6 = matrix_mul_by_val(v5, a3);
free(v5);
v7 = matrix_add(*(_QWORD *)(a1 + 72), v4);
free(v4);
v8 = matrix_sub(v7, v6);
norm_vect(v8);
return v8;
}

original_code:
t_vect *update_cam_dirray(t_cam *cam, t_type i, t_type j)
{
 static t_type iincr = 0;
 static t_type jincr = 0;
 t_vect *v4;
 t_vect *v2;
 t_vect *v3;
 if (iincr == 0)
  iincr = cam->vpwidth / (t_type)700;
 if (jincr == 0)
  jincr = cam->vpheight / (t_type)700;
 v2 = matrix_mul_by_val(cam->sidevect, iincr);
 v3 = matrix_mul_by_val(v2, i);
 free(v2);
 v2 = matrix_mul_by_val(cam->upvect, jincr);
 v4 = matrix_mul_by_val(v2, j);
 free(v2);
 v2 = matrix_add(cam->vpupleftpos, v3);
 free(v3);
 v3 = matrix_sub(v2, v4);
 norm_vect(v3);
 return (v3);
}

canonical_original_code:
struct s_vect *update_cam_dirray(struct s_cam *cam, float i, float j)
{
 static float iincr = 0;
 static float jincr = 0;
 struct s_vect *v4;
 struct s_vect *v2;
 struct s_vect *v3;
 if (iincr == 0)
  iincr = cam->vpwidth / (float)700;
 if (jincr == 0)
  jincr = cam->vpheight / (float)700;
 v2 = matrix_mul_by_val(cam->sidevect, iincr);
 v3 = matrix_mul_by_val(v2, i);
 free(v2);
 v2 = matrix_mul_by_val(cam->upvect, jincr);
 v4 = matrix_mul_by_val(v2, j);
 free(v2);
 v2 = matrix_add(cam->vpupleftpos, v3);
 free(v3);
 v3 = matrix_sub(v2, v4);
 norm_vect(v3);
 return (v3);
}

variable_types: i float

variable_types: j float

variable_types: iincr float

variable_types: jincr float

return_type: struct s_vect { float x; float y; float z; float l; } *


decompiled_code:
__int64 __fastcall camera_data(__int64 a1, _QWORD *a2, __int64 a3)
{
float v5; // xmm0_4
__int64 v6; // rbp
float v7; // xmm0_4
__int64 v8; // rax
float v10; // [rsp+8h] [rbp-20h]
float v11; // [rsp+8h] [rbp-20h]
float v12; // [rsp+Ch] [rbp-1Ch]
float v13; // [rsp+Ch] [rbp-1Ch]

if ( !*a2 || !a2[1] || !a2[2] || !a2[3] || !a2[4] || !a2[5] )
file_error("Parser error in scene file near : ", a3);
v10 = ft_atof(a2[2], a3);
v12 = ft_atof(a2[1], a3);
v5 = ft_atof(*a2, a3);
v6 = new_vect(v5, v12, v10);
v11 = ft_atof(a2[5], a3);
v13 = ft_atof(a2[4], a3);
v7 = ft_atof(a2[3], a3);
v8 = new_vect(v7, v13, v11);
create_camera(0LL, v6, v8);
return 0LL;
}

original_code:
t_obj *camera_data(t_obj *lst, char **tab, char *buf)
{
 t_vect *pos;
 t_vect *dir;
 t_cam *cam;
 cam = ((void *)0);
 if (tab[0] == ((void *)0) || tab[1] == ((void *)0) || tab[2] == ((void *)0) || tab[3] == ((void *)0)
  || tab[4] == ((void *)0) || tab[5] == ((void *)0))
  file_error("Parser error in scene file near : ", buf);
 pos = new_vect(ft_atof(tab[0]), ft_atof(tab[1]), ft_atof(tab[2]));
 dir = new_vect(ft_atof(tab[3]), ft_atof(tab[4]), ft_atof(tab[5]));
 cam = create_camera(cam, pos, dir);
 (void)lst;
 return (((void *)0));
}

canonical_original_code:
struct s_obj *camera_data(struct s_obj *lst, char **tab, char *buf)
{
 struct s_vect *pos;
 struct s_vect *dir;
 struct s_cam *cam;
 cam = ((void *)0);
 if (tab[0] == ((void *)0) || tab[1] == ((void *)0) || tab[2] == ((void *)0) || tab[3] == ((void *)0)
  || tab[4] == ((void *)0) || tab[5] == ((void *)0))
  file_error("Parser error in scene file near : ", buf);
 pos = new_vect(ft_atof(tab[0]), ft_atof(tab[1]), ft_atof(tab[2]));
 dir = new_vect(ft_atof(tab[3]), ft_atof(tab[4]), ft_atof(tab[5]));
 cam = create_camera(cam, pos, dir);
 (void)lst;
 return (((void *)0));
}

variable_types:
lst
struct s_obj *

variable_types:
tab
char **

variable_types:
buf
char *

user_defined_types: struct s_vect { float x; float y; float z; float l; }

user_defined_types: enum e_obj_type { CAMERA=0, SPHERE=1, PLANE=2, CONE=3, CYLINDER=4, CUBE=5 }


dump

variable_types: struct s_dat { unsigned char arena[-1]; struct s_proc { unsigned char reg[-1]; int pc; int carry; unsigned char instruct; unsigned char params; int cycle_to_exec; int nbr_live; struct s_proc *next; } **bgn_lst; struct s_hero { unsigned char *buf; char *name; int hero_num; struct s_hero *next; } *hero_lst; int cycle_to_die; int do_we_check; int nb_checks; int current_cycle; int dump; int last_player_alive; int verbose; } *

variable_types: i int

variable_types:
tmp
unsigned char *

variable_types:
c
unsigned char


decompiled_code:
__int64 __fastcall display_winner(__int64 a1)
{
int v1; // edx
__int64 result; // rax
__int64 v3; // rsi

v1 = *(_DWORD *)(a1 + 4132);
if ( v1 == -1 )
return ft_putstr_fd("No player found alive ?\n", 2LL);
result = *(_QWORD *)(a1 + 4104);
if ( result )
{
while ( 1 )
{
v3 = *(unsigned int *)(result + 16);
if ( v1 == (_DWORD)v3 )
break;
result = *(_QWORD *)(result + 24);
if ( !result )
return result;
}
result = ft_printf("Le joueur %d(%s) a gagne\n", v3, *(const char **)(result + 8));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // edx
__int64 result; // rax
__int64 v3; // rsi

v1 = *(_DWORD *)(a1 + 4132);
if ( v1 == -1 )
return ft_putstr_fd("No player found alive ?\n", 2LL);
result = *(_QWORD *)(a1 + 4104);
if ( result )
{
while ( 1 )
{
v3 = *(unsigned int *)(result + 16);
if ( v1 == (_DWORD)v3 )
break;
result = *(_QWORD *)(result + 24);
if ( !result )
return result;
}
result = ft_printf("Le joueur %d(%s) a gagne\n", v3, *(const char **)(result + 8));
}
return result;
}

original_code:
void display_winner(t_dat *d)
{
 t_hero *tmp;
 if (d->last_player_alive != -1)
 {
  tmp = d->hero_lst;
  while (tmp)
  {
   if (tmp->hero_num == d->last_player_alive)
   {
    ft_printf("Le joueur %d(%s) a gagne\n", tmp->hero_num, tmp->name);
    break ;
   }
   tmp = tmp->next;
  }
 }
 else
  ft_putstr_fd("No player found alive ?\n", 2);
}

canonical_original_code:
void display_winner(struct s_dat *d)
{
 struct s_hero *tmp;
 if (d->last_player_alive != -1)
 {
  tmp = d->hero_lst;
  while (tmp)
  {
   if (tmp->hero_num == d->last_player_alive)
   {
    ft_printf("Le joueur %d(%s) a gagne\n", tmp->hero_num, tmp->name);
    break ;
   }
   tmp = tmp->next;
  }
 }
 else
  ft_putstr_fd("No player found alive ?\n", 2);
}

variable_types: struct s_hero { unsigned char *buf; char *name; int hero_num; struct s_hero *next; } *

user_defined_types: struct s_proc { unsigned char reg[-1]; int pc; int carry; unsigned char instruct; unsigned char params; int cycle_to_exec; int nbr_live; struct s_proc *next; }


original_code:
void create_prompt2(char *pwd, char *prompt, int i, int j)
{
 while (j < 100 && pwd[i] != '\0')
 {
  prompt[j + 1] = pwd[i + 1];
  j++;
  i++;
 }
}

variable_types:
pwd
char *

variable_types:
prompt
char *

variable_types: j int


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

result = save_0;
if ( a1 )
{
if ( save_0 )
free(save_0);
save_0 = (void *)ft_strdup(a1);
result = a1;
}
return result;
}

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

result = save_0;
if ( a1 )
{
if ( save_0 )
free(save_0);
save_0 = (void *)ft_strdup(a1);
result = a1;
}
return result;
}

original_code:
char *retrieve_prompt(char *prompt)
{
 static char *save = ((void *)0);
 if (prompt != ((void *)0))
 {
  if (save != ((void *)0))
   free(save);
  save = ft_strdup(prompt);
  return (prompt);
 }
 return (save);
}

variable_types:
save
char *

return_type: char *


decompiled_code:
__int64 __fastcall print_prompt(void *a1)
{
const char *v1; // rbx

v1 = (const char *)retrieve_prompt(a1);
ft_putstr("\x1B[1;35m");
ft_printf("%s > ", v1);
return ft_putstr("\x1B[0m");
}

canonical_decompiled_code:
__int64 __fastcall func3(void *a1)
{
const char *v1; // rbx

v1 = (const char *)func2(a1);
ft_putstr("\x1B[1;35m");
ft_printf("%s > ", v1);
return ft_putstr("\x1B[0m");
}

original_code:
void print_prompt(char *prompt)
{
 prompt = retrieve_prompt(prompt);
 ft_putstr("\033[1;35m");
 ft_printf("%s > ", prompt);
 ft_putstr("\033[0m");
}


decompiled_code:
__int64 __fastcall insert_string(char *a1, __int64 a2)
{
char v3; // di
char *v4; // rbx
__int64 result; // rax

v3 = *a1;
if ( v3 )
{
v4 = a1 + 1;
do
{
result = insert_char((unsigned int)v3, a2);
v3 = *v4++;
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, __int64 a2)
{
char v3; // di
char *v4; // rbx
__int64 result; // rax

v3 = *a1;
if ( v3 )
{
v4 = a1 + 1;
do
{
result = insert_char((unsigned int)v3, a2);
v3 = *v4++;
}
while ( v3 );
}
return result;
}

original_code:
void insert_string(char *c, t_print *print)
{
 int i;
 i = 0;
 while (c[i] != '\0')
 {
  insert_char(c[i], print);
  i++;
 }
}

canonical_original_code:
void insert_string(char *c, struct s_print *print)
{
 int i;
 i = 0;
 while (c[i] != '\0')
 {
  insert_char(c[i], print);
  i++;
 }
}

variable_types:
c
char *

variable_types: struct s_print { int pos; int startsel; int endsel; int ins; int length; char *line; char *select; struct s_history { char *line; struct s_history *prev; struct s_history *next; } *histo; } *

user_defined_types: struct s_print { int pos; int startsel; int endsel; int ins; int length; char *line; char *select; struct s_history *histo; }


decompiled_code:
int __fastcall move_cursor_to_end_of_line(__int64 a1)
{
char *v1; // rax
__int64 v2; // r12
int v3; // ebx
char *v4; // rax
int v5; // ebx
int v6; // ebx
size_t v7; // rax
char *v8; // rax

v1 = tgetstr("ei", 0LL);
tputs(v1, 1, (int (*)(int))&out);
v2 = retrieve_prompt(0LL);
v3 = ft_strlen(*(_QWORD *)(a1 + 24)) - *(_DWORD *)a1;
if ( v3 > 0 )
{
do
{
v4 = tgetstr("nd", 0LL);
tputs(v4, 1, (int (*)(int))&out);
--v3;
}
while ( v3 );
}
v5 = ft_strlen(*(_QWORD *)(a1 + 24));
v6 = v5 + ft_strlen(v2) + 3;
if ( v6 > 0 )
{
do
{
remove_left_symbole();
--v6;
}
while ( v6 );
}
print_prompt(v2);
v7 = ft_strlen(*(_QWORD *)(a1 + 24));
write(1, *(const void **)(a1 + 24), v7);
v8 = tgetstr("cd", 0LL);
return tputs(v8, 1, (int (*)(int))&out);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
char *v1; // rax
__int64 v2; // r12
int v3; // ebx
char *v4; // rax
int v5; // ebx
int v6; // ebx
size_t v7; // rax
char *v8; // rax

v1 = tgetstr("ei", 0LL);
tputs(v1, 1, (int (*)(int))&out);
v2 = retrieve_prompt(0LL);
v3 = ft_strlen(*(_QWORD *)(a1 + 24)) - *(_DWORD *)a1;
if ( v3 > 0 )
{
do
{
v4 = tgetstr("nd", 0LL);
tputs(v4, 1, (int (*)(int))&out);
--v3;
}
while ( v3 );
}
v5 = ft_strlen(*(_QWORD *)(a1 + 24));
v6 = v5 + ft_strlen(v2) + 3;
if ( v6 > 0 )
{
do
{
remove_left_symbole();
--v6;
}
while ( v6 );
}
print_prompt(v2);
v7 = ft_strlen(*(_QWORD *)(a1 + 24));
write(1, *(const void **)(a1 + 24), v7);
v8 = tgetstr("cd", 0LL);
return tputs(v8, 1, (int (*)(int))&out);
}

original_code:
void move_cursor_to_end_of_line(t_print *print)
{
 int i;
 int j;
 char *prompt;
 tputs(tgetstr("ei", ((void *)0)), 1, out);
 prompt = retrieve_prompt(((void *)0));
 j = ft_strlen(print->line) - print->pos + 1;
 while (j--, j > 0)
  tputs(tgetstr("nd", ((void *)0)), 1, out);
 i = ft_strlen(print->line) + ft_strlen(prompt) + 4;
 while (i--, i > 0)
  remove_left_symbole();
 print_prompt(prompt);
 write(1, print->line, ft_strlen(print->line));
 tputs(tgetstr("cd", ((void *)0)), 1, out);
}

canonical_original_code:
void move_cursor_to_end_of_line(struct s_print *print)
{
 int i;
 int j;
 char *prompt;
 tputs(tgetstr("ei", ((void *)0)), 1, out);
 prompt = retrieve_prompt(((void *)0));
 j = ft_strlen(print->line) - print->pos + 1;
 while (j--, j > 0)
  tputs(tgetstr("nd", ((void *)0)), 1, out);
 i = ft_strlen(print->line) + ft_strlen(prompt) + 4;
 while (i--, i > 0)
  remove_left_symbole();
 print_prompt(prompt);
 write(1, print->line, ft_strlen(print->line));
 tputs(tgetstr("cd", ((void *)0)), 1, out);
}

user_defined_types: struct s_history { char *line; struct s_history *prev; struct s_history *next; }


decompiled_code:
__int64 __fastcall check_length_and_realloc(__int64 a1)
{
int v1; // edx
__int64 result; // rax
int v3; // ebp
char *v4; // r12
char v5; // dl

v1 = *(_DWORD *)(a1 + 16);
result = (unsigned int)(v1 % 255);
if ( (int)result > 253 )
{
do
v3 = v1++;
while ( v1 != 255 * (v1 / 255) );
v4 = (char *)ft_strdup(*(_QWORD *)(a1 + 24));
free(*(void **)(a1 + 24));
result = ft_strnew(v3 + 257);
*(_QWORD *)(a1 + 24) = result;
v5 = *v4;
if ( *v4 )
{
result = 0LL;
do
{
*(_BYTE *)(*(_QWORD *)(a1 + 24) + result++) = v5;
v5 = v4[result];
}
while ( v5 );
}
}
++*(_DWORD *)(a1 + 16);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // edx
__int64 result; // rax
int v3; // ebp
char *v4; // r12
char v5; // dl

v1 = *(_DWORD *)(a1 + 16);
result = (unsigned int)(v1 % 255);
if ( (int)result > 253 )
{
do
v3 = v1++;
while ( v1 != 255 * (v1 / 255) );
v4 = (char *)ft_strdup(*(_QWORD *)(a1 + 24));
free(*(void **)(a1 + 24));
result = ft_strnew(v3 + 257);
*(_QWORD *)(a1 + 24) = result;
v5 = *v4;
if ( *v4 )
{
result = 0LL;
do
{
*(_BYTE *)(*(_QWORD *)(a1 + 24) + result++) = v5;
v5 = v4[result];
}
while ( v5 );
}
}
++*(_DWORD *)(a1 + 16);
return result;
}

original_code:
void check_length_and_realloc(t_print *print)
{
 int i;
 int l;
 int m;
 char *tmp;
 i = 0;
 l = print->length % 255;
 m = print->length;
 if (l > 253)
 {
  while (m % 255 != 0)
   m++;
  tmp = ft_strdup(print->line);
  free(print->line);
  print->line = ft_strnew(m + 256);
  while (tmp[i] != '\0')
  {
   print->line[i] = tmp[i];
   i++;
  }
 }
 print->length += 1;
}

canonical_original_code:
void check_length_and_realloc(struct s_print *print)
{
 int i;
 int l;
 int m;
 char *tmp;
 i = 0;
 l = print->length % 255;
 m = print->length;
 if (l > 253)
 {
  while (m % 255 != 0)
   m++;
  tmp = ft_strdup(print->line);
  free(print->line);
  print->line = ft_strnew(m + 256);
  while (tmp[i] != '\0')
  {
   print->line[i] = tmp[i];
   i++;
  }
 }
 print->length += 1;
}

variable_types: l int

variable_types: m int

variable_types:
tmp
char *


decompiled_code:
__int64 __fastcall cpy_history(char *a1)
{
int i; // edi
__int64 v3; // rcx
char v4; // dl
__int64 v5; // rax

for ( i = ft_strlen(a1); i != 255 * (i / 255); ++i )
;
v3 = ft_strnew(i + 1);
v4 = *a1;
if ( *a1 )
{
v5 = 0LL;
do
{
*(_BYTE *)(v3 + v5++) = v4;
v4 = a1[v5];
}
while ( v4 );
}
return v3;
}

original_code:
char *cpy_history(char *histo)
{
 int i;
 int l;
 char *line;
 i = 0;
 line = ((void *)0);
 l = ft_strlen(histo);
 while (l % 255 != 0)
  l++;
 line = ft_strnew(l + 1);
 while (histo[i] != '\0')
 {
  line[i] = histo[i];
  i++;
 }
 return (line);
}

variable_types:
histo
char *

variable_types:
line
char *


decompiled_code:
_BYTE *cmd_createlldi()
{
_BYTE *result; // rax

result = (_BYTE *)cmd_create("lldi");
result[8] = 3;
result[9] = 1;
result[10] = 1;
return result;
}

canonical_decompiled_code:
_BYTE *func0()
{
_BYTE *result; // rax

result = (_BYTE *)cmd_create("lldi");
result[8] = 3;
result[9] = 1;
result[10] = 1;
return result;
}

original_code:
t_cmd *cmd_createlldi(void)
{
 t_cmd *cmd;
 cmd = cmd_create("lldi");
 cmd->nb_arg = 3;
 cmd->has_encoding = 1;
 cmd->is_idx = 1;
 return (cmd);
}

canonical_original_code:
struct s_cmd *cmd_createlldi()
{
 struct s_cmd *cmd;
 cmd = cmd_create("lldi");
 cmd->nb_arg = 3;
 cmd->has_encoding = 1;
 cmd->is_idx = 1;
 return (cmd);
}

variable_types: struct s_cmd { char *cmd; char nb_arg; char has_encoding; char is_idx; int size; struct s_cmd *next; } *


original_code:
t_sort *ft_rotate_a_and_b(t_sort *lnk)
{
    t_sort *tmp;
    t_sort *tmp_move;
    tmp = lnk->next;
    tmp_move = lnk;
    while (lnk->next != ((void *)0))
        lnk = lnk->next;
    tmp_move->next = ((void *)0);
    lnk->next = tmp_move;
    lnk = tmp;
 return (lnk);
}

canonical_original_code:
struct s_list_arg *ft_rotate_a_and_b(struct s_list_arg *lnk)
{
    struct s_list_arg *tmp;
    struct s_list_arg *tmp_move;
    tmp = lnk->next;
    tmp_move = lnk;
    while (lnk->next != ((void *)0))
        lnk = lnk->next;
    tmp_move->next = ((void *)0);
    lnk->next = tmp_move;
    lnk = tmp;
 return (lnk);
}

variable_types:
lnk
struct s_list_arg *

variable_types: struct s_list_arg { int val; struct s_list_arg *next; } *


decompiled_code:
_BOOL8 __fastcall ft_rotate_both(__int64 *a1, __int64 *a2, __int64 a3)
{
__int64 v5; // rdi

ft_printf("\n\nROT BOTH\n\n\n");
v5 = *a1;
if ( v5 )
*a1 = ft_rotate_a_and_b(v5);
if ( *a2 )
*a2 = ft_rotate_a_and_b(*a2);
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rr");
return (unsigned int)ft_update_state(a3, *a1, *a2, 9LL) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 *a1, __int64 *a2, __int64 a3)
{
__int64 v5; // rdi

ft_printf("\n\nROT BOTH\n\n\n");
v5 = *a1;
if ( v5 )
*a1 = func0(v5);
if ( *a2 )
*a2 = func0(*a2);
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rr");
return (unsigned int)ft_update_state(a3, *a1, *a2, 9LL) != 0;
}

original_code:
int ft_rotate_both(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "rr";
 ft_printf("\n\nROT BOTH\n\n\n");
 if ((*lnk))
  (*lnk) = ft_rotate_a_and_b((*lnk));
 if ((*lnk_b))
  (*lnk_b) = ft_rotate_a_and_b((*lnk_b));
 state->op = ft_add_operation(state->op, op);
    if (ft_update_state(state, (*lnk), (*lnk_b), 9) == 0)
        return (0);
    return (1);
}

canonical_original_code:
int ft_rotate_both(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "rr";
 ft_printf("\n\nROT BOTH\n\n\n");
 if ((*lnk))
  (*lnk) = ft_rotate_a_and_b((*lnk));
 if ((*lnk_b))
  (*lnk_b) = ft_rotate_a_and_b((*lnk_b));
 state->op = ft_add_operation(state->op, op);
    if (ft_update_state(state, (*lnk), (*lnk_b), 9) == 0)
        return (0);
    return (1);
}

variable_types: struct s_list_arg { int val; struct s_list_arg *next; } **

variable_types: struct s_state { struct s_sort { struct s_list_arg *head; struct s_sort *next; } *list; struct s_sort *list_b; struct s_list_arg *obj; char *op; } *

variable_types:
op
char *

user_defined_types: struct s_state { struct s_sort *list; struct s_sort *list_b; struct s_list_arg *obj; char *op; }


decompiled_code:
__int64 __fastcall ft_rotate_rev_a_and_b(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

for ( result = a1; *(_QWORD *)(result + 8); result = *(_QWORD *)(result + 8) )
a4 = result;
*(_QWORD *)(a4 + 8) = 0LL;
*(_QWORD *)(result + 8) = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

for ( result = a1; *(_QWORD *)(result + 8); result = *(_QWORD *)(result + 8) )
a4 = result;
*(_QWORD *)(a4 + 8) = 0LL;
*(_QWORD *)(result + 8) = a1;
return result;
}

original_code:
t_sort *ft_rotate_rev_a_and_b(t_sort *lnk)
{
    t_sort *tmp;
    t_sort *tmp2;
    tmp = lnk;
    while (lnk->next != ((void *)0))
    {
        tmp2 = lnk;
        lnk = lnk->next;
    }
    tmp2->next = ((void *)0);
    lnk->next = tmp;
 return (lnk);
}

canonical_original_code:
struct s_list_arg *ft_rotate_rev_a_and_b(struct s_list_arg *lnk)
{
    struct s_list_arg *tmp;
    struct s_list_arg *tmp2;
    tmp = lnk;
    while (lnk->next != ((void *)0))
    {
        tmp2 = lnk;
        lnk = lnk->next;
    }
    tmp2->next = ((void *)0);
    lnk->next = tmp;
 return (lnk);
}

return_type: struct s_list_arg { int val; struct s_list_arg *next; } *


decompiled_code:
_BOOL8 __fastcall ft_rotate_rev_both(__int64 *a1, __int64 *a2, __int64 a3)
{
__int64 v5; // rdx
__int64 v6; // rcx
__int64 v7; // rdi

ft_printf("\n\nROT REV BOTH\n\n\n");
v7 = *a1;
if ( v7 )
*a1 = ft_rotate_rev_a_and_b(v7, (__int64)a2, v5, v6);
if ( *a2 )
*a2 = ft_rotate_rev_a_and_b(*a2, (__int64)a2, v5, v6);
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rrr");
return (unsigned int)ft_update_state(a3, *a1, *a2, 10LL) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 *a1, __int64 *a2, __int64 a3)
{
__int64 v5; // rdx
__int64 v6; // rcx
__int64 v7; // rdi

ft_printf("\n\nROT REV BOTH\n\n\n");
v7 = *a1;
if ( v7 )
*a1 = func2(v7, (__int64)a2, v5, v6);
if ( *a2 )
*a2 = func2(*a2, (__int64)a2, v5, v6);
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rrr");
return (unsigned int)ft_update_state(a3, *a1, *a2, 10LL) != 0;
}

original_code:
int ft_rotate_rev_both(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "rrr";
 ft_printf("\n\nROT REV BOTH\n\n\n");
 if ((*lnk))
  (*lnk) = ft_rotate_rev_a_and_b((*lnk));
 if ((*lnk_b))
  (*lnk_b) = ft_rotate_rev_a_and_b((*lnk_b));
 state->op = ft_add_operation(state->op, op);
    if (ft_update_state(state, (*lnk), (*lnk_b), 10) == 0)
        return (0);
    return (1);
}

canonical_original_code:
int ft_rotate_rev_both(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "rrr";
 ft_printf("\n\nROT REV BOTH\n\n\n");
 if ((*lnk))
  (*lnk) = ft_rotate_rev_a_and_b((*lnk));
 if ((*lnk_b))
  (*lnk_b) = ft_rotate_rev_a_and_b((*lnk_b));
 state->op = ft_add_operation(state->op, op);
    if (ft_update_state(state, (*lnk), (*lnk_b), 10) == 0)
        return (0);
    return (1);
}

user_defined_types: struct s_list_arg { int val; struct s_list_arg *next; }

user_defined_types: struct s_sort { struct s_list_arg *head; struct s_sort *next; }


decompiled_code:
__int64 __fastcall new_hero(int a1, char *a2)
{
void *v2; // rax
void *v3; // rbx
unsigned int v4; // eax
unsigned int v5; // ebp

v2 = malloc(0x20uLL);
if ( !v2 )
return prt_err_null("new_hero: malloc", &unk_2AE);
v3 = v2;
v4 = open(a2, 0);
v5 = v4;
if ( v4 == -1 )
return prt_err_null("new_hero: open", a2);
if ( (unsigned int)find_prog_size(v4) > 0x2AA )
return prt_err_null("new_hero: bad size", a2);
if ( !(unsigned int)check_magic_number(v5) )
return prt_err_null("new_hero: Invalid magic number", a2);
*(_QWORD *)v3 = ft_strnew(682LL);
*((_QWORD *)v3 + 1) = ft_strnew(129LL);
lseek(v5, 4LL, 0);
read(v5, *((void **)v3 + 1), 0x80uLL);
lseek(v5, 2192LL, 0);
read(v5, *(void **)v3, 0x2AAuLL);
close(v5);
*((_DWORD *)v3 + 4) = a1;
*((_QWORD *)v3 + 3) = 0LL;
free(a2);
return (__int64)v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, char *a2)
{
void *v2; // rax
void *v3; // rbx
unsigned int v4; // eax
unsigned int v5; // ebp

v2 = malloc(0x20uLL);
if ( !v2 )
return prt_err_null("new_hero: malloc", &unk_2AE);
v3 = v2;
v4 = open(a2, 0);
v5 = v4;
if ( v4 == -1 )
return prt_err_null("new_hero: open", a2);
if ( (unsigned int)find_prog_size(v4) > 0x2AA )
return prt_err_null("new_hero: bad size", a2);
if ( !(unsigned int)check_magic_number(v5) )
return prt_err_null("new_hero: Invalid magic number", a2);
*(_QWORD *)v3 = ft_strnew(682LL);
*((_QWORD *)v3 + 1) = ft_strnew(129LL);
lseek(v5, 4LL, 0);
read(v5, *((void **)v3 + 1), 0x80uLL);
lseek(v5, 2192LL, 0);
read(v5, *(void **)v3, 0x2AAuLL);
close(v5);
*((_DWORD *)v3 + 4) = a1;
*((_QWORD *)v3 + 3) = 0LL;
free(a2);
return (__int64)v3;
}

original_code:
t_hero *new_hero(int hero_num, char *path)
{
 int fd;
 t_hero *new;
 if ((new = (t_hero *)malloc(sizeof(t_hero))) == ((void *)0))
  return (prt_err_null("new_hero: malloc", ""));
 if ((fd = open(path, 00)) == -1)
  return (prt_err_null("new_hero: open", path));
 if (find_prog_size(fd) > ((4*1024) / 6))
  return (prt_err_null("new_hero: bad size", path));
 if (!check_magic_number(fd))
  return (prt_err_null("new_hero: Invalid magic number", path));
 new->buf = (unsigned char*)ft_strnew(((4*1024) / 6));
 new->name = ft_strnew((128) + 1);
 lseek(fd, 4, 0);
 read(fd, new->name, (128));
 lseek(fd, sizeof(header_t), 0);
 read(fd, new->buf, ((4*1024) / 6));
 close(fd);
 new->hero_num = hero_num;
 new->next = ((void *)0);
 free(path);
 return (new);
}

canonical_original_code:
struct s_hero *new_hero(int hero_num, char *path)
{
 int fd;
 struct s_hero *new;
 if ((new = (struct s_hero *)malloc(sizeof(t_hero))) == ((void *)0))
  return (prt_err_null("new_hero: malloc", ""));
 if ((fd = open(path, 00)) == -1)
  return (prt_err_null("new_hero: open", path));
 if (find_prog_size(fd) > ((4*1024) / 6))
  return (prt_err_null("new_hero: bad size", path));
 if (!check_magic_number(fd))
  return (prt_err_null("new_hero: Invalid magic number", path));
 new->buf = (unsigned char *)ft_strnew(((4*1024) / 6));
 new->name = ft_strnew((128) + 1);
 lseek(fd, 4, 0);
 read(fd, new->name, (128));
 lseek(fd, sizeof(header_t), 0);
 read(fd, new->buf, ((4*1024) / 6));
 close(fd);
 new->hero_num = hero_num;
 new->next = ((void *)0);
 free(path);
 return (new);
}

variable_types:
path
char *

variable_types: fd int

variable_types: struct s_hero { unsigned char *buf; char *name; int hero_num; struct s_hero *next; } *


decompiled_code:
__int64 __fastcall get_hero_lst(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
int v3; // er13
char *v4; // rsi
__int64 v5; // rsi

if ( !a2 )
return 0LL;
v2 = a2;
v3 = -1;
while ( 1 )
{
if ( *(_DWORD *)v2 == 4 )
v3 = ft_atoi(*(_QWORD *)(v2 + 8));
if ( *(_DWORD *)v2 != 8 )
goto LABEL_6;
v4 = (char *)ft_strdup(*(_QWORD *)(v2 + 8));
if ( !v4 )
goto LABEL_6;
v5 = new_hero(v3, v4);
if ( !v5 )
return 0xFFFFFFFFLL;
hero_push_back(a1, v5);
v3 = -1;
LABEL_6:
v2 = *(_QWORD *)(v2 + 16);
if ( !v2 )
return 0LL;
}
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
int v3; // er13
char *v4; // rsi
__int64 v5; // rsi

if ( !a2 )
return 0LL;
v2 = a2;
v3 = -1;
while ( 1 )
{
if ( *(_DWORD *)v2 == 4 )
v3 = ft_atoi(*(_QWORD *)(v2 + 8));
if ( *(_DWORD *)v2 != 8 )
goto LABEL_6;
v4 = (char *)ft_strdup(*(_QWORD *)(v2 + 8));
if ( !v4 )
goto LABEL_6;
v5 = func0(v3, v4);
if ( !v5 )
return 0xFFFFFFFFLL;
hero_push_back(a1, v5);
v3 = -1;
LABEL_6:
v2 = *(_QWORD *)(v2 + 16);
if ( !v2 )
return 0LL;
}
}

original_code:
int get_hero_lst(t_dat *d, t_lex *lex)
{
 int hero_num;
 char *hero_path;
 t_lex *tmp;
 t_hero *tmp_h;
 tmp = lex;
 hero_path = ((void *)0);
 hero_num = -1;
 while (tmp)
 {
  if (tmp->token == HERO_NUMB)
   hero_num = ft_atoi(tmp->value);
  if (tmp->token == HERO_FILE)
   hero_path = ft_strdup(tmp->value);
  if (hero_path != ((void *)0))
  {
   if ((tmp_h = new_hero(hero_num, hero_path)) == ((void *)0))
    return (-1);
   hero_push_back(d, tmp_h);
   hero_num = -1;
   hero_path = ((void *)0);
  }
  tmp = tmp->next;
 }
 return (0);
}

canonical_original_code:
int get_hero_lst(struct s_dat *d, struct s_lex *lex)
{
 int hero_num;
 char *hero_path;
 struct s_lex *tmp;
 struct s_hero *tmp_h;
 tmp = lex;
 hero_path = ((void *)0);
 hero_num = -1;
 while (tmp)
 {
  if (tmp->token == HERO_NUMB)
   hero_num = ft_atoi(tmp->value);
  if (tmp->token == HERO_FILE)
   hero_path = ft_strdup(tmp->value);
  if (hero_path != ((void *)0))
  {
   if ((tmp_h = new_hero(hero_num, hero_path)) == ((void *)0))
    return (-1);
   hero_push_back(d, tmp_h);
   hero_num = -1;
   hero_path = ((void *)0);
  }
  tmp = tmp->next;
 }
 return (0);
}

variable_types: struct s_dat { unsigned char arena[-1]; struct s_proc { unsigned char reg[-1]; int pc; int carry; unsigned char instruct; unsigned char params; int cycle_to_exec; int nbr_live; struct s_proc *next; } **bgn_lst; struct s_hero { unsigned char *buf; char *name; int hero_num; struct s_hero *next; } *hero_lst; int cycle_to_die; int do_we_check; int nb_checks; int current_cycle; int dump; int last_player_alive; int verbose; } *

variable_types: struct s_lex { enum e_tok { UNKNOWN=0, DUMP=1, NUMBER=2, HERO_NUMB=4, HERO_FILE=8, VERBOSE=16 } token; char *value; struct s_lex *next; } *


decompiled_code:
void __fastcall update_hero_num(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)(a1 + 16) == -1 )
*(_DWORD *)(a1 + 16) = next_num_available(*(_QWORD *)(a2 + 4104));
}

original_code:
void update_hero_num(t_hero *tmp, t_dat *d)
{
 if (tmp->hero_num == -1)
  tmp->hero_num = next_num_available(d->hero_lst);
}

canonical_original_code:
void update_hero_num(struct s_hero *tmp, struct s_dat *d)
{
 if (tmp->hero_num == -1)
  tmp->hero_num = next_num_available(d->hero_lst);
}

variable_types: struct s_dat { unsigned char arena[-1]; struct s_proc { unsigned char reg[-1]; int pc; int carry; unsigned char instruct; unsigned char params; int cycle_to_exec; int nbr_live; struct s_proc *next; } **bgn_lst; struct s_hero *hero_lst; int cycle_to_die; int do_we_check; int nb_checks; int current_cycle; int dump; int last_player_alive; int verbose; } *

user_defined_types: struct s_hero { unsigned char *buf; char *name; int hero_num; struct s_hero *next; }


decompiled_code:
__int64 __fastcall load_heroes(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rbx
int i; // er14
__int64 result; // rax
__int64 v7; // rbx
__int64 v8; // r12
unsigned int v9; // ebp

v3 = a2;
for ( i = 4096 / (int)tot_nb_of_heroes(a2); ((*(_DWORD *)v3 - 4) & 0xFFFFFFFB) != 0; v3 = *(_QWORD *)(v3 + 16) )
;
result = get_hero_lst(a1, v3);
if ( (_DWORD)result != -1 )
{
v7 = *(_QWORD *)(a1 + 4104);
if ( v7 )
{
v8 = a1;
v9 = 0;
while ( 1 )
{
update_hero_num(v7, a1);
result = new_proc(a3, *(int *)(v7 + 16), v9);
if ( (_DWORD)result == -1 )
break;
ft_memcpy(v8, *(_QWORD *)v7, 682LL);
v7 = *(_QWORD *)(v7 + 24);
v9 += i;
v8 += i;
if ( !v7 )
return 0LL;
}
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rbx
int i; // er14
__int64 result; // rax
__int64 v7; // rbx
__int64 v8; // r12
unsigned int v9; // ebp

v3 = a2;
for ( i = 4096 / (int)tot_nb_of_heroes(a2); ((*(_DWORD *)v3 - 4) & 0xFFFFFFFB) != 0; v3 = *(_QWORD *)(v3 + 16) )
;
result = func1(a1, v3);
if ( (_DWORD)result != -1 )
{
v7 = *(_QWORD *)(a1 + 4104);
if ( v7 )
{
v8 = a1;
v9 = 0;
while ( 1 )
{
func2(v7, a1);
result = new_proc(a3, *(int *)(v7 + 16), v9);
if ( (_DWORD)result == -1 )
break;
ft_memcpy(v8, *(_QWORD *)v7, 682LL);
v7 = *(_QWORD *)(v7 + 24);
v9 += i;
v8 += i;
if ( !v7 )
return 0LL;
}
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int load_heroes(t_dat *d, t_lex *lex, t_proc **bgn_lst)
{
 int count;
 int mem;
 t_hero *tmp;
 void *addr_to_cpy;
 count = 0;
 mem = (4*1024) / tot_nb_of_heroes(lex);
 while (lex->token != HERO_NUMB && lex->token != HERO_FILE)
  lex = lex->next;
 if (get_hero_lst(d, lex) == -1)
  return (-1);
 tmp = d->hero_lst;
 while (tmp)
 {
  update_hero_num(tmp, d);
  if (new_proc(bgn_lst, (long)tmp->hero_num, mem * count) == -1)
   return (-1);
  addr_to_cpy = d->arena + (mem * count);
  ft_memcpy(addr_to_cpy, tmp->buf, ((4*1024) / 6));
  tmp = tmp->next;
  count++;
 }
 return (0);
}

canonical_original_code:
int load_heroes(struct s_dat *d, struct s_lex *lex, struct s_proc **bgn_lst)
{
 int count;
 int mem;
 struct s_hero *tmp;
 void *addr_to_cpy;
 count = 0;
 mem = (4*1024) / tot_nb_of_heroes(lex);
 while (lex->token != HERO_NUMB && lex->token != HERO_FILE)
  lex = lex->next;
 if (get_hero_lst(d, lex) == -1)
  return (-1);
 tmp = d->hero_lst;
 while (tmp)
 {
  update_hero_num(tmp, d);
  if (new_proc(bgn_lst, (long)tmp->hero_num, mem * count) == -1)
   return (-1);
  addr_to_cpy = d->arena + (mem * count);
  ft_memcpy(addr_to_cpy, tmp->buf, ((4*1024) / 6));
  tmp = tmp->next;
  count++;
 }
 return (0);
}

variable_types: count int

variable_types: mem int

user_defined_types: struct s_lex { enum e_tok token; char *value; struct s_lex *next; }

user_defined_types: enum e_tok { UNKNOWN=0, DUMP=1, NUMBER=2, HERO_NUMB=4, HERO_FILE=8, VERBOSE=16 }


decompiled_code:
__int64 __fastcall build_cmd_line(void *ptr, __int64 a2)
{
void *v2; // rbp
__int64 v3; // rbx

if ( !ptr )
return ft_strdup(a2);
v2 = (void *)ft_strjoin(ptr, &unk_188);
free(ptr);
v3 = ft_strjoin(v2, a2);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *ptr, __int64 a2)
{
void *v2; // rbp
__int64 v3; // rbx

if ( !ptr )
return ft_strdup(a2);
v2 = (void *)ft_strjoin(ptr, &unk_188);
free(ptr);
v3 = ft_strjoin(v2, a2);
free(v2);
return v3;
}

original_code:
char *build_cmd_line(char *cmd, char *val)
{
 char *tmp;
 tmp = ((void *)0);
 if (cmd == ((void *)0))
 {
  cmd = ft_strdup(val);
  return (cmd);
 }
 else
 {
  tmp = ft_strjoin(cmd, " ");
  free(cmd);
  cmd = tmp;
  tmp = ft_strjoin(cmd, val);
  free(cmd);
 }
 return (tmp);
}

variable_types:
cmd
char *

variable_types:
val
char *

variable_types:
tmp
char *


decompiled_code:
void *__fastcall fill_next_command(__int64 *a1, void *a2)
{
void *v3; // rdi
__int64 v4; // rax

v3 = a2;
v4 = *a1;
if ( !*a1 )
return a2;
while ( (*(_DWORD *)(v4 + 8) & 0xFFFFFFF7) == 0 )
{
v3 = (void *)build_cmd_line(v3, *(_QWORD *)v4);
v4 = *(_QWORD *)(*a1 + 16);
*a1 = v4;
if ( !v4 )
return v3;
}
return v3;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 *a1, void *a2)
{
void *v3; // rdi
__int64 v4; // rax

v3 = a2;
v4 = *a1;
if ( !*a1 )
return a2;
while ( (*(_DWORD *)(v4 + 8) & 0xFFFFFFF7) == 0 )
{
v3 = (void *)func0(v3, *(_QWORD *)v4);
v4 = *(_QWORD *)(*a1 + 16);
*a1 = v4;
if ( !v4 )
return v3;
}
return v3;
}

original_code:
char *fill_next_command(t_token **tok, char *cmd)
{
 while ((*tok) && ((*tok)->type == STDCHAR || (*tok)->type == QUOTE))
 {
  cmd = build_cmd_line(cmd, (*tok)->val);
  (*tok) = (*tok)->next;
 }
 return (cmd);
}

canonical_original_code:
char *fill_next_command(struct s_token **tok, char *cmd)
{
 while ((*tok) && ((*tok)->type == STDCHAR || (*tok)->type == QUOTE))
 {
  cmd = build_cmd_line(cmd, (*tok)->val);
  (*tok) = (*tok)->next;
 }
 return (cmd);
}

variable_types: struct s_token { char *val; enum e_type { QUOTE=0, LREDIR=1, RREDIR=2, LAREDIR=3, RAREDIR=4, PIPE=5, SEMICOLON=6, WHITESPACE=7, STDCHAR=8, ENDOFLINE=9 } type; struct s_token *next; struct s_token *prev; } **

user_defined_types: struct s_token { char *val; enum e_type type; struct s_token *next; struct s_token *prev; }


decompiled_code:
__int64 __fastcall add_u_func(__int64 a1)
{
return add_basic(a1);
}

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

original_code:
void add_u_func(t_conv **list)
{
 add_basic(list);
}

canonical_original_code:
void add_u_func(struct s_conv **list)
{
 add_basic(list);
}

variable_types: struct s_conv { char conv; int (*func)(__builtin_va_list *, struct s_format { int start; int arg_nb; struct s_flags { int has_hashtag; int has_zero; int has_minus; int has_space; int has_plus; } *f_list; int m_width; int preci; char *l_mod; char conv; unsigned long length; char *format; int has_star; struct s_format *next; } *); struct s_conv *next; } **

user_defined_types: struct s_conv { char conv; int (*func)(__builtin_va_list *, struct s_format *); struct s_conv *next; }

user_defined_types: struct s_format { int start; int arg_nb; struct s_flags *f_list; int m_width; int preci; char *l_mod; char conv; unsigned long length; char *format; int has_star; struct s_format *next; }


decompiled_code:
__int64 __fastcall add_basic(__int64 a1)
{
__int64 v1; // rax

v1 = create_conv(117LL, basic_u_conv);
return add_conv(a1, v1);
}

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

v1 = create_conv(117LL, basic_u_conv);
return add_conv(a1, v1);
}

original_code:
static void add_basic(t_conv **list)
{
 add_conv(list, create_conv('u', basic_u_conv));
}

canonical_original_code:
static void add_basic(struct s_conv **list)
{
 add_conv(list, create_conv('u', basic_u_conv));
}

user_defined_types: struct s_flags { int has_hashtag; int has_zero; int has_minus; int has_space; int has_plus; }


decompiled_code:
__int64 __fastcall ft_findNumderSplit(_BYTE *a1)
{
unsigned int v1; // edx
_BYTE *v3; // rcx

v1 = 0;
while ( *a1 )
{
if ( (unsigned __int8)(*a1 - 48) <= 9u )
{
++v1;
goto LABEL_8;
}
do
++a1;
while ( (unsigned __int8)(*a1 - 48) > 9u );
++v1;
if ( (unsigned __int8)(*a1 - 48) <= 9u )
{
LABEL_8:
v3 = a1 + 1;
do
a1 = v3++;
while ( (unsigned __int8)(*a1 - 48) <= 9u );
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
unsigned int v1; // edx
_BYTE *v3; // rcx

v1 = 0;
while ( *a1 )
{
if ( (unsigned __int8)(*a1 - 48) <= 9u )
{
++v1;
goto LABEL_8;
}
do
++a1;
while ( (unsigned __int8)(*a1 - 48) > 9u );
++v1;
if ( (unsigned __int8)(*a1 - 48) <= 9u )
{
LABEL_8:
v3 = a1 + 1;
do
a1 = v3++;
while ( (unsigned __int8)(*a1 - 48) <= 9u );
}
}
return v1;
}

variable_types:
s
char *

variable_types: i int

variable_types: n int


decompiled_code:
__int64 __fastcall ft_findLen(_BYTE *a1)
{
__int64 v1; // rax
int v2; // ecx
char v3; // si

if ( (unsigned __int8)(*a1 - 48) > 9u )
{
v2 = 0;
}
else
{
v1 = 1LL;
do
{
v2 = v1;
v3 = a1[v1++];
}
while ( (unsigned __int8)(v3 - 48) <= 9u );
}
return (unsigned int)(v2 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1)
{
__int64 v1; // rax
int v2; // ecx
char v3; // si

if ( (unsigned __int8)(*a1 - 48) > 9u )
{
v2 = 0;
}
else
{
v1 = 1LL;
do
{
v2 = v1;
v3 = a1[v1++];
}
while ( (unsigned __int8)(v3 - 48) <= 9u );
}
return (unsigned int)(v2 + 1);
}

original_code:
static int ft_findLen(const char *s)
{
 int i;
 i = 0;
 while (s[i] != '\0' && (s[i] >= '0' && s[i] <= '9'))
  i++;
 return (i + 1);
}


decompiled_code:
__int64 __fastcall store_history(__int64 a1)
{
if ( !stk_0 )
stk_0 = a1;
return stk_0;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !stk_0 )
stk_0 = a1;
return stk_0;
}

original_code:
t_history *store_history(t_history *lnk, int i)
{
 static t_history *stk = ((void *)0);
 (void)i;
 if (stk == ((void *)0))
  stk = lnk;
 return (stk);
}

canonical_original_code:
struct s_history *store_history(struct s_history *lnk, int i)
{
 static struct s_history *stk = ((void *)0);
 (void)i;
 if (stk == ((void *)0))
  stk = lnk;
 return (stk);
}

variable_types:
lnk
struct s_history *

variable_types: struct s_history { char *line; struct s_history *prev; struct s_history *next; } *


decompiled_code:
const void **__fastcall get_line_from_history(__int64 a1)
{
const void **v1; // rax
const void **v2; // rbx
size_t v3; // rax

v1 = (const void **)store_history(a1);
v2 = v1;
if ( v1 )
{
v3 = ft_strlen(*v1);
write(1, *v2, v3);
v2 = (const void **)*v2;
}
return v2;
}

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

v1 = (const void **)func0(a1);
v2 = v1;
if ( v1 )
{
v3 = ft_strlen(*v1);
write(1, *v2, v3);
v2 = (const void **)*v2;
}
return v2;
}

original_code:
char *get_line_from_history(t_history *lnk, int i)
{
 lnk = store_history(lnk, i);
 if (lnk != ((void *)0))
 {
  write(1, lnk->line, ft_strlen(lnk->line));
  return (lnk->line);
 }
 return (((void *)0));
}

canonical_original_code:
char *get_line_from_history(struct s_history *lnk, int i)
{
 lnk = store_history(lnk, i);
 if (lnk != ((void *)0))
 {
  write(1, lnk->line, ft_strlen(lnk->line));
  return (lnk->line);
 }
 return (((void *)0));
}


decompiled_code:
__int64 __fastcall build_history_list(__int64 a1)
{
__int64 v1; // rax
_BYTE *v2; // r12
__int64 result; // rax
_QWORD *v4; // rbp

v1 = *(_QWORD *)(a1 + 32);
if ( v1 )
{
while ( 1 )
{
v1 = *(_QWORD *)(v1 + 8);
if ( !v1 )
break;
*(_QWORD *)(a1 + 32) = v1;
}
}
v2 = *(_BYTE **)(a1 + 16);
result = (unsigned int)(unsigned __int8)*v2 - 32;
if ( (unsigned __int8)(*v2 - 32) <= 0x5Eu )
{
v4 = malloc(0x18uLL);
*v4 = ft_strdup(v2);
v4[1] = 0LL;
result = *(_QWORD *)(a1 + 32);
if ( result )
{
v4[2] = result;
*(_QWORD *)(result + 8) = v4;
}
else
{
v4[2] = 0LL;
}
*(_QWORD *)(a1 + 32) = v4;
v4[1] = 0LL;
}
return result;
}

original_code:
void build_history_list(t_print *print)
{
 t_history *new;
 while (print->histo && print->histo->prev)
  print->histo = print->histo->prev;
 if (print->line[0] < 32 || print->line[0] > 126)
  return ;
 new = (t_history*)malloc(sizeof(t_history));
 new->line = ft_strdup(print->line);
 new->prev = ((void *)0);
 if (print->histo != ((void *)0))
 {
  new->next = print->histo;
  print->histo->prev = new;
 }
 else
  new->next = ((void *)0);
 print->histo = new;
 print->histo->prev = ((void *)0);
}

canonical_original_code:
void build_history_list(struct s_print *print)
{
 struct s_history *new;
 while (print->histo && print->histo->prev)
  print->histo = print->histo->prev;
 if (print->line[0] < 32 || print->line[0] > 126)
  return ;
 new = (struct s_history *)malloc(sizeof(t_history));
 new->line = ft_strdup(print->line);
 new->prev = ((void *)0);
 if (print->histo != ((void *)0))
 {
  new->next = print->histo;
  print->histo->prev = new;
 }
 else
  new->next = ((void *)0);
 print->histo = new;
 print->histo->prev = ((void *)0);
}

variable_types: struct s_print { int pos; int startsel; int endsel; int ins; char *line; char *select; struct s_history { char *line; struct s_history *prev; struct s_history *next; } *histo; } *

user_defined_types: struct s_print { int pos; int startsel; int endsel; int ins; char *line; char *select; struct s_history *histo; }


decompiled_code:
__int64 __fastcall build_array(unsigned int a1, __int64 a2)
{
__int64 v2; // rbp
__int64 i; // rbx

v2 = ft_memalloc(8LL * a1 + 1);
if ( a1 )
{
for ( i = 0LL; i != a1; ++i )
*(_QWORD *)(v2 + 8 * i) = ft_strnew(*(unsigned int *)(a2 + 4 * i) + 1LL);
}
*(_QWORD *)(v2 + 8LL * a1) = 0LL;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, __int64 a2)
{
__int64 v2; // rbp
__int64 i; // rbx

v2 = ft_memalloc(8LL * a1 + 1);
if ( a1 )
{
for ( i = 0LL; i != a1; ++i )
*(_QWORD *)(v2 + 8 * i) = ft_strnew(*(unsigned int *)(a2 + 4 * i) + 1LL);
}
*(_QWORD *)(v2 + 8LL * a1) = 0LL;
return v2;
}

original_code:
static char **build_array(t_ui w_c, t_ui *word_l)
{
 char **split;
 t_ui i;
 i = 0;
 split = (char **) ft_memalloc(sizeof(char *) * w_c + 1);
 while (i < w_c)
 {
  split[i] = ft_strnew((size_t) word_l[i] + 1);
  i++;
 }
 split[i] = ((void *)0);
 return (split);
}

canonical_original_code:
static char **build_array(unsigned int w_c, unsigned int *word_l)
{
 char **split;
 unsigned int i;
 i = 0;
 split = (char **) ft_memalloc(sizeof(char *) * w_c + 1);
 while (i < w_c)
 {
  split[i] = ft_strnew((unsigned long) word_l[i] + 1);
  i++;
 }
 split[i] = ((void *)0);
 return (split);
}

variable_types:
split
char **

variable_types:
i
unsigned int

return_type: char **


decompiled_code:
__int64 __fastcall ft_strsplitwhite(char *a1)
{
char *v1; // rbx
unsigned int v2; // ebp
_DWORD *v3; // r12
__int64 v4; // rbp
unsigned int i; // er8
char v6; // al
char v7; // al
unsigned int v8; // ecx
unsigned int v9; // edx

v1 = a1;
v2 = count_words(a1);
v3 = get_word_len(v2, a1);
v4 = build_array(v2, (__int64)v3);
if ( *a1 == 32 || *a1 == 9 )
{
do
{
do
++v1;
while ( *v1 == 32 );
}
while ( *v1 == 9 );
}
for ( i = 0; *v1; ++i )
{
v7 = *v1;
if ( (*v1 & 0xDF) != 0 && v7 != 9 )
{
v8 = 0;
do
{
++v1;
v9 = v8++;
*(_BYTE *)(*(_QWORD *)(v4 + 8LL * i) + v9) = v7;
v7 = *v1;
}
while ( (*v1 & 0xDF) != 0 && v7 != 9 );
}
v6 = *v1;
if ( !*v1 )
break;
while ( v6 == 32 || v6 == 9 )
{
v6 = *++v1;
if ( !*v1 )
goto LABEL_17;
}
}
LABEL_17:
free(v3);
return v4;
}

original_code:
char **ft_strsplitwhite(char const *s)
{
 t_ui word_count;
 char **split;
 t_ui *word_len;
 t_ui i;
 t_ui j;
 j = 0;
 i = 0;
 word_count = count_words(s);
 word_len = get_word_len(word_count, s);
 split = build_array(word_count, word_len);
 while (*s == ' ' || *s == '\t')
  s++;
 while (*s)
 {
  while (*s && (*s != ' ') && (*s != '\t'))
   split[i][j++] = *s++;
  j = 0;
  while (*s && ((*s == ' ') || (*s == '\t')))
   s++;
  i++;
 }
 free(word_len);
 return (split);
}

canonical_original_code:
char **ft_strsplitwhite(char *s)
{
 unsigned int word_count;
 char **split;
 unsigned int *word_len;
 unsigned int i;
 unsigned int j;
 j = 0;
 i = 0;
 word_count = count_words(s);
 word_len = get_word_len(word_count, s);
 split = build_array(word_count, word_len);
 while (*s == ' ' || *s == '\t')
  s++;
 while (*s)
 {
  while (*s && (*s != ' ') && (*s != '\t'))
   split[i][j++] = *s++;
  j = 0;
  while (*s && ((*s == ' ') || (*s == '\t')))
   s++;
  i++;
 }
 free(word_len);
 return (split);
}

variable_types:
j
unsigned int


decompiled_code:
float __fastcall find_magnitude(float a1, float a2, float a3)
{
float v3; // xmm0_4
float result; // xmm0_4

v3 = (float)((float)(a1 * a1) + (float)(a2 * a2)) + (float)(a3 * a3);
if ( v3 < 0.0 )
result = sqrtf(v3);
else
result = fsqrt(v3);
return result;
}

canonical_decompiled_code:
float __fastcall func0(float a1, float a2, float a3)
{
float v3; // xmm0_4
float result; // xmm0_4

v3 = (float)((float)(a1 * a1) + (float)(a2 * a2)) + (float)(a3 * a3);
if ( v3 < 0.0 )
result = sqrtf(v3);
else
result = fsqrt(v3);
return result;
}

original_code:
t_type find_magnitude(t_type x, t_type y, t_type z)
{
 t_type l;
 l = (float)sqrt((x * x) + (y * y) + (z * z));
 return (l);
}

canonical_original_code:
float find_magnitude(float x, float y, float z)
{
 float l;
 l = (float)sqrt((x * x) + (y * y) + (z * z));
 return (l);
}

variable_types: x float

variable_types: y float

variable_types: z float

variable_types: l float

return_type: float


decompiled_code:
float *__fastcall new_vect(__m128i a1, __m128i a2, __m128i a3)
{
float v3; // ebp
float v4; // er12
float v5; // er13
float *v6; // rbx

v3 = COERCE_FLOAT(_mm_cvtsi128_si32(a1));
v4 = COERCE_FLOAT(_mm_cvtsi128_si32(a2));
v5 = COERCE_FLOAT(_mm_cvtsi128_si32(a3));
v6 = (float *)malloc(0x10uLL);
*v6 = v3;
v6[1] = v4;
v6[2] = v5;
v6[3] = find_magnitude(v3, v4, v5);
return v6;
}

canonical_decompiled_code:
float *__fastcall func1(__m128i a1, __m128i a2, __m128i a3)
{
float v3; // ebp
float v4; // er12
float v5; // er13
float *v6; // rbx

v3 = COERCE_FLOAT(_mm_cvtsi128_si32(a1));
v4 = COERCE_FLOAT(_mm_cvtsi128_si32(a2));
v5 = COERCE_FLOAT(_mm_cvtsi128_si32(a3));
v6 = (float *)malloc(0x10uLL);
*v6 = v3;
v6[1] = v4;
v6[2] = v5;
v6[3] = func0(v3, v4, v5);
return v6;
}

original_code:
t_vect *new_vect(t_type x, t_type y, t_type z)
{
 t_vect *v;
 v = (t_vect*)malloc(sizeof(t_vect));
 v->x = x;
 v->y = y;
 v->z = z;
 v->l = find_magnitude(x, y, z);
 return (v);
}

canonical_original_code:
struct s_vect *new_vect(float x, float y, float z)
{
 struct s_vect *v;
 v = (struct s_vect *)malloc(sizeof(t_vect));
 v->x = x;
 v->y = y;
 v->z = z;
 v->l = find_magnitude(x, y, z);
 return (v);
}

variable_types: struct s_vect { float x; float y; float z; float l; } *


decompiled_code:
float __fastcall dot_product(float *a1, float *a2)
{
return (float)((float)(*a1 * *a2) + (float)(a1[1] * a2[1])) + (float)(a1[2] * a2[2]);
}

canonical_decompiled_code:
float __fastcall func2(float *a1, float *a2)
{
return (float)((float)(*a1 * *a2) + (float)(a1[1] * a2[1])) + (float)(a1[2] * a2[2]);
}

original_code:
t_type dot_product(t_vect *v1, t_vect *v2)
{
 return ((t_type)((v1->x * v2->x) + (v1->y * v2->y) + (v1->z * v2->z)));
}

canonical_original_code:
float dot_product(struct s_vect *v1, struct s_vect *v2)
{
 return ((t_type)((v1->x * v2->x) + (v1->y * v2->y) + (v1->z * v2->z)));
}


original_code:
t_vect *cross_vect(t_vect *v1, t_vect *v2)
{
 t_vect *v3;
 v3 = (t_vect*)malloc(sizeof(t_vect));
 v3->x = v1->y * v2->z - v1->z * v2->y;
 v3->y = v1->z * v2->x - v1->x * v2->z;
 v3->z = v1->x * v2->y - v1->y * v2->x;
 v3->l = find_magnitude(v3->x, v3->y, v3->z);
 return (v3);
}

canonical_original_code:
struct s_vect *cross_vect(struct s_vect *v1, struct s_vect *v2)
{
 struct s_vect *v3;
 v3 = (struct s_vect *)malloc(sizeof(t_vect));
 v3->x = v1->y * v2->z - v1->z * v2->y;
 v3->y = v1->z * v2->x - v1->x * v2->z;
 v3->z = v1->x * v2->y - v1->y * v2->x;
 v3->l = find_magnitude(v3->x, v3->y, v3->z);
 return (v3);
}


decompiled_code:
void __fastcall revers_insert_mode(__int64 a1)
{
char *v1; // rax

if ( *(_DWORD *)(a1 + 12) )
{
v1 = tgetstr("ei", 0LL);
tputs(v1, 1, out);
*(_DWORD *)(a1 + 12) = 0;
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
char *v1; // rax

if ( *(_DWORD *)(a1 + 12) )
{
v1 = tgetstr("ei", 0LL);
tputs(v1, 1, out);
*(_DWORD *)(a1 + 12) = 0;
}
}

original_code:
void revers_insert_mode(t_print *print)
{
 if (print->ins)
 {
  tputs(tgetstr("ei", ((void *)0)), 1, out);
  print->ins = 0;
 }
}

canonical_original_code:
void revers_insert_mode(struct s_print *print)
{
 if (print->ins)
 {
  tputs(tgetstr("ei", ((void *)0)), 1, out);
  print->ins = 0;
 }
}


decompiled_code:
__int64 malloc_struct()
{
if ( !td_0 )
td_0 = (__int64)malloc(0x40uLL);
return td_0;
}

canonical_decompiled_code:
__int64 func3()
{
if ( !td_0 )
td_0 = (__int64)malloc(0x40uLL);
return td_0;
}

original_code:
t_termdata *malloc_struct(void)
{
 static t_termdata *td = ((void *)0);
 if (td == ((void *)0))
  td = (t_termdata*)malloc(sizeof(t_termdata));
 return (td);
}

canonical_original_code:
struct s_termdata *malloc_struct()
{
 static struct s_termdata *td = ((void *)0);
 if (td == ((void *)0))
  td = (struct s_termdata *)malloc(sizeof(t_termdata));
 return (td);
}

variable_types: struct s_termdata { char *termtype; int tty; int wnbr; int padlength; int totalline; int totalarg; int lastline; int wincol; int winline; int poscol; int poslin; char *lineup; char *clear; } *


out

decompiled_code:
__int64 __fastcall out(unsigned int a1)
{
__int64 v1; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
v1 = malloc_struct();
write(*(_DWORD *)(v1 + 8), buf, 1uLL);
return buf[0];
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
__int64 v1; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
v1 = func3();
write(*(_DWORD *)(v1 + 8), buf, 1uLL);
return buf[0];
}

original_code:
int out(int i)
{
 t_termdata *td;
 td = malloc_struct();
 write(td->tty, &i, 1);
 return (i);
}

canonical_original_code:
int out(int i)
{
 struct s_termdata *td;
 td = malloc_struct();
 write(td->tty, &i, 1);
 return (i);
}

user_defined_types: struct s_termdata { char *termtype; int tty; int wnbr; int padlength; int totalline; int totalarg; int lastline; int wincol; int winline; int poscol; int poslin; char *lineup; char *clear; }


decompiled_code:
char *__fastcall tab_return_table(int a1)
{
return (char *)&tab_0 + 24 * a1;
}

canonical_decompiled_code:
char *__fastcall func0(int a1)
{
return (char *)&tab_0 + 24 * a1;
}

original_code:
t_type *tab_return_table(int op)
{
 static t_type tab[16][6] = {
  {DIR, 0, 0, 0, 0, 0},
  {IND | DIR | DIR_LAB | IND_LAB, SEP, REG, 0, 0, 0},
  {REG, SEP, REG | IND | IND_LAB, 0, 0, 0},
  {REG, SEP, REG, SEP, REG, 0},
  {REG, SEP, REG, SEP, REG, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | IND | DIR
   | DIR_LAB | IND_LAB, SEP, REG, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | IND | DIR
   | DIR_LAB | IND_LAB, SEP, REG, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | IND | DIR
   | DIR_LAB | IND_LAB, SEP, REG, 0},
  {DIR | DIR_LAB, 0, 0, 0, 0, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | DIR
   | DIR_LAB, SEP, REG, 0},
  {REG, SEP, REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG
   | DIR | DIR_LAB, 0},
  {DIR | DIR_LAB, 0, 0, 0, 0, 0},
  {IND | DIR | DIR_LAB | IND_LAB, SEP, REG, 0, 0, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | DIR
   | DIR_LAB, SEP, REG, 0},
  {DIR | DIR_LAB, 0, 0, 0, 0, 0},
  {REG, 0, 0, 0, 0, 0}
 };
 return (tab[op]);
}

canonical_original_code:
enum e_type *tab_return_table(int op)
{
 static enum e_type tab[16][6] = {
  {DIR, 0, 0, 0, 0, 0},
  {IND | DIR | DIR_LAB | IND_LAB, SEP, REG, 0, 0, 0},
  {REG, SEP, REG | IND | IND_LAB, 0, 0, 0},
  {REG, SEP, REG, SEP, REG, 0},
  {REG, SEP, REG, SEP, REG, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | IND | DIR
   | DIR_LAB | IND_LAB, SEP, REG, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | IND | DIR
   | DIR_LAB | IND_LAB, SEP, REG, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | IND | DIR
   | DIR_LAB | IND_LAB, SEP, REG, 0},
  {DIR | DIR_LAB, 0, 0, 0, 0, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | DIR
   | DIR_LAB, SEP, REG, 0},
  {REG, SEP, REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG
   | DIR | DIR_LAB, 0},
  {DIR | DIR_LAB, 0, 0, 0, 0, 0},
  {IND | DIR | DIR_LAB | IND_LAB, SEP, REG, 0, 0, 0},
  {REG | IND | DIR | DIR_LAB | IND_LAB, SEP, REG | DIR
   | DIR_LAB, SEP, REG, 0},
  {DIR | DIR_LAB, 0, 0, 0, 0, 0},
  {REG, 0, 0, 0, 0, 0}
 };
 return (tab[op]);
}

variable_types: op int

return_type: enum e_type { NOTHING=0, REG=1, IND=2, DIR=4, LAB=8, OP=16, CMD=32, CMD_NAME=64, CMD_COM=128, DIR_LAB=256, IND_LAB=512, STR=1024, ENDOFLINE=2048, COM=4096, WHIT=8192, SEP=16384 } *


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

result = 0LL;
if ( *(_DWORD *)a1 != 2048 )
{
if ( *(_DWORD *)a1 == 1024 )
result = (unsigned int)-(**(_DWORD **)(a1 + 16) != 2048);
else
result = 0xFFFFFFFFLL;
}
return result;
}

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

result = 0LL;
if ( *(_DWORD *)a1 != 2048 )
{
if ( *(_DWORD *)a1 == 1024 )
result = (unsigned int)-(**(_DWORD **)(a1 + 16) != 2048);
else
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int tab_check_end(t_lexer *lst)
{
 t_type tab[2] = {STR, ENDOFLINE};
 if (lst->token == tab[1])
  return (0);
 else if (lst->token == tab[0])
 {
  if (lst->next->token == tab[1])
   return (0);
  else
   return (-1);
 }
 else
  return (-1);
}

canonical_original_code:
int tab_check_end(struct s_lexer *lst)
{
 enum e_type tab[2] = {STR, ENDOFLINE};
 if (lst->token == tab[1])
  return (0);
 else if (lst->token == tab[0])
 {
  if (lst->next->token == tab[1])
   return (0);
  else
   return (-1);
 }
 else
  return (-1);
}

variable_types: struct s_lexer { enum e_type { NOTHING=0, REG=1, IND=2, DIR=4, LAB=8, OP=16, CMD=32, CMD_NAME=64, CMD_COM=128, DIR_LAB=256, IND_LAB=512, STR=1024, ENDOFLINE=2048, COM=4096, WHIT=8192, SEP=16384 } token; char *value; struct s_lexer *next; } *

user_defined_types: struct s_lexer { enum e_type token; char *value; struct s_lexer *next; }


original_code:
int tab_get_opcode(t_lexer *lst)
{
 char *tab[17] = {"live", "ld", "st", "add", "sub", "and", "or", "xor"
      , "zjmp", "ldi", "sti", "fork", "lld", "lldi", "lfork"
      , "aff", ((void *)0)};
 int i;
 i = 0;
 while (i < 16 && ft_strcmp(lst->value, tab[i]) != 0)
  ++i;
 return (i);
}

canonical_original_code:
int tab_get_opcode(struct s_lexer *lst)
{
 char *tab[17] = {"live", "ld", "st", "add", "sub", "and", "or", "xor"
      , "zjmp", "ldi", "sti", "fork", "lld", "lldi", "lfork"
      , "aff", ((void *)0)};
 int i;
 i = 0;
 while (i < 16 && ft_strcmp(lst->value, tab[i]) != 0)
  ++i;
 return (i);
}

variable_types:
tab
char *[17]

user_defined_types: enum e_type { NOTHING=0, REG=1, IND=2, DIR=4, LAB=8, OP=16, CMD=32, CMD_NAME=64, CMD_COM=128, DIR_LAB=256, IND_LAB=512, STR=1024, ENDOFLINE=2048, COM=4096, WHIT=8192, SEP=16384 }


decompiled_code:
__int64 __fastcall tab_check_line(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char *v3; // rdx
__int64 v4; // rdi
int v5; // eax
char *v6; // rdx

result = 0LL;
if ( ((*(_DWORD *)a1 - 2048) & 0xFFFFF7FF) != 0 )
{
if ( *(_DWORD *)a1 == 16 )
{
v2 = tab_get_opcode(a1);
v3 = tab_return_table(v2);
v4 = *(_QWORD *)(a1 + 16);
v5 = *(_DWORD *)v3;
if ( *(_DWORD *)v3 )
{
v6 = v3 + 4;
while ( *(_DWORD *)v4 == (*(_DWORD *)v4 & v5) )
{
v4 = *(_QWORD *)(v4 + 16);
v6 += 4;
v5 = *((_DWORD *)v6 - 1);
if ( !v5 )
goto LABEL_7;
}
result = 0xFFFFFFFFLL;
}
else
{
LABEL_7:
result = tab_check_end(v4);
}
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char *v3; // rdx
__int64 v4; // rdi
int v5; // eax
char *v6; // rdx

result = 0LL;
if ( ((*(_DWORD *)a1 - 2048) & 0xFFFFF7FF) != 0 )
{
if ( *(_DWORD *)a1 == 16 )
{
v2 = func2(a1);
v3 = func0(v2);
v4 = *(_QWORD *)(a1 + 16);
v5 = *(_DWORD *)v3;
if ( *(_DWORD *)v3 )
{
v6 = v3 + 4;
while ( *(_DWORD *)v4 == (*(_DWORD *)v4 & v5) )
{
v4 = *(_QWORD *)(v4 + 16);
v6 += 4;
v5 = *((_DWORD *)v6 - 1);
if ( !v5 )
goto LABEL_7;
}
result = 0xFFFFFFFFLL;
}
else
{
LABEL_7:
result = func1(v4);
}
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int tab_check_line(t_lexer *lst)
{
 t_type *tab;
 int i;
 i = -1;
 if ((lst->token == ENDOFLINE) || (lst->token == COM))
  return (0);
 if (lst->token != OP)
  return (-1);
 tab = tab_return_table(tab_get_opcode(lst));
 lst = lst->next;
 while (tab[++ i])
 {
  if ((lst->token & tab[i]) == lst->token)
   lst = lst->next;
  else
   return (-1);
 }
 return (tab_check_end(lst));
}

canonical_original_code:
int tab_check_line(struct s_lexer *lst)
{
 enum e_type *tab;
 int i;
 i = -1;
 if ((lst->token == ENDOFLINE) || (lst->token == COM))
  return (0);
 if (lst->token != OP)
  return (-1);
 tab = tab_return_table(tab_get_opcode(lst));
 lst = lst->next;
 while (tab[++ i])
 {
  if ((lst->token & tab[i]) == lst->token)
   lst = lst->next;
  else
   return (-1);
 }
 return (tab_check_end(lst));
}

variable_types: enum e_type { NOTHING=0, REG=1, IND=2, DIR=4, LAB=8, OP=16, CMD=32, CMD_NAME=64, CMD_COM=128, DIR_LAB=256, IND_LAB=512, STR=1024, ENDOFLINE=2048, COM=4096, WHIT=8192, SEP=16384 } *

variable_types: i int


decompiled_code:
__int64 __fastcall ft_itoa_by_type(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rdi
__int64 result; // rax
int v7; // edx

v5 = *(_QWORD *)(a2 + 32);
if ( !v5 )
return ft_itoa(*(int *)(a3 + 8));
if ( (unsigned int)ft_strncmp(v5, &unk_525, 2LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_528, 1LL) )
{
if ( !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52A, 2LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52D, 1LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52F, 1LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_531, 1LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_533, 1LL)
|| (v7 = ft_strncmp(*(_QWORD *)(a2 + 32), &unk_535, 1LL), result = a1, !v7) )
{
result = ft_itoa(*(_QWORD *)(a3 + 8));
}
}
else
{
result = ft_itoa(*(__int16 *)(a3 + 8));
}
}
else
{
ft_putchar((unsigned int)*(char *)(a3 + 8));
result = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rdi
__int64 result; // rax
int v7; // edx

v5 = *(_QWORD *)(a2 + 32);
if ( !v5 )
return ft_itoa(*(int *)(a3 + 8));
if ( (unsigned int)ft_strncmp(v5, &unk_525, 2LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_528, 1LL) )
{
if ( !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52A, 2LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52D, 1LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52F, 1LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_531, 1LL)
|| !(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_533, 1LL)
|| (v7 = ft_strncmp(*(_QWORD *)(a2 + 32), &unk_535, 1LL), result = a1, !v7) )
{
result = ft_itoa(*(_QWORD *)(a3 + 8));
}
}
else
{
result = ft_itoa(*(__int16 *)(a3 + 8));
}
}
else
{
ft_putchar((unsigned int)*(char *)(a3 + 8));
result = a1;
}
return result;
}

original_code:
char *ft_itoa_by_type(char *str, t_op *op, t_arg *lnk)
{
 if (op->mod)
 {
  if (ft_strncmp(op->mod, "hh", 2) == 0)
   ft_putchar((signed char)lnk->i);
  else if (ft_strncmp(op->mod, "h", 1) == 0)
   str = ft_itoa((short)lnk->i);
  else if (ft_strncmp(op->mod, "ll", 2) == 0
    || ft_strncmp(op->mod, "l", 1) == 0)
   str = ft_itoa((long)lnk->i);
  else if (ft_strncmp(op->mod, "j", 1) == 0)
   str = ft_itoa((intmax_t)lnk->i);
  else if (ft_strncmp(op->mod, "t", 1) == 0)
   str = ft_itoa((ptrdiff_t)lnk->i);
  else if (ft_strncmp(op->mod, "z", 1) == 0)
   str = ft_itoa((size_t)lnk->i);
  else if (ft_strncmp(op->mod, "q", 1) == 0)
   str = ft_itoa((quad_t)lnk->i);
 }
 else
  str = ft_itoa((int)lnk->i);
 return (str);
}

canonical_original_code:
char *ft_itoa_by_type(char *str, struct s_option *op, struct s_arg *lnk)
{
 if (op->mod)
 {
  if (ft_strncmp(op->mod, "hh", 2) == 0)
   ft_putchar((char)lnk->i);
  else if (ft_strncmp(op->mod, "h", 1) == 0)
   str = ft_itoa((short)lnk->i);
  else if (ft_strncmp(op->mod, "ll", 2) == 0
    || ft_strncmp(op->mod, "l", 1) == 0)
   str = ft_itoa((long)lnk->i);
  else if (ft_strncmp(op->mod, "j", 1) == 0)
   str = ft_itoa((long)lnk->i);
  else if (ft_strncmp(op->mod, "t", 1) == 0)
   str = ft_itoa((long)lnk->i);
  else if (ft_strncmp(op->mod, "z", 1) == 0)
   str = ft_itoa((unsigned long)lnk->i);
  else if (ft_strncmp(op->mod, "q", 1) == 0)
   str = ft_itoa((long)lnk->i);
 }
 else
  str = ft_itoa((int)lnk->i);
 return (str);
}

variable_types:
str
char *

variable_types: struct s_option { int field; char *flag; char separator; int min_width; char starwidth; int precision; char *mod; char conv; int arg_size; struct s_option *next; } *

variable_types: struct s_arg { char *str; long i; unsigned long ull; long ps; struct s_arg *next; } *


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

if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_525, 2LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_528, 1LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52A, 2LL)
&& (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52D, 1LL)
&& (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52F, 1LL)
&& (!(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_531, 1LL)
|| (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_533, 1LL)
&& (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_535, 1LL)) )
{
result = ft_uitoa(*(unsigned int *)(a3 + 16));
}
else
{
result = ft_uitoa(*(_QWORD *)(a3 + 16));
}
}
else
{
result = ft_uitoa(*(unsigned __int16 *)(a3 + 16));
}
}
else
{
ft_putchar((unsigned int)*(char *)(a3 + 16));
result = a1;
}
return result;
}

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

if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_525, 2LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_528, 1LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52A, 2LL)
&& (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52D, 1LL)
&& (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_52F, 1LL)
&& (!(unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_531, 1LL)
|| (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_533, 1LL)
&& (unsigned int)ft_strncmp(*(_QWORD *)(a2 + 32), &unk_535, 1LL)) )
{
result = ft_uitoa(*(unsigned int *)(a3 + 16));
}
else
{
result = ft_uitoa(*(_QWORD *)(a3 + 16));
}
}
else
{
result = ft_uitoa(*(unsigned __int16 *)(a3 + 16));
}
}
else
{
ft_putchar((unsigned int)*(char *)(a3 + 16));
result = a1;
}
return result;
}

original_code:
char *ft_itoa_by_utype(char *str, t_op *op, t_arg *lnk)
{
 if (ft_strncmp(op->mod, "hh", 2) == 0)
  ft_putchar((unsigned char)lnk->ull);
 else if (ft_strncmp(op->mod, "h", 1) == 0)
  str = ft_uitoa((unsigned short)lnk->ull);
 else if (ft_strncmp(op->mod, "ll", 2) == 0
   || ft_strncmp(op->mod, "l", 1) == 0)
  str = ft_uitoa((unsigned long)lnk->ull);
 else if (ft_strncmp(op->mod, "j", 1) == 0)
  str = ft_uitoa((uintmax_t)lnk->ull);
 else if (ft_strncmp(op->mod, "t", 1) == 0)
  str = ft_uitoa((unsigned int)lnk->ull);
 else if (ft_strncmp(op->mod, "z", 1) == 0)
  str = ft_uitoa((size_t)lnk->ull);
 else if (ft_strncmp(op->mod, "q", 1) == 0)
  str = ft_uitoa((u_quad_t)lnk->ull);
 else
  str = ft_uitoa((unsigned int)lnk->ull);
 return (str);
}

canonical_original_code:
char *ft_itoa_by_utype(char *str, struct s_option *op, struct s_arg *lnk)
{
 if (ft_strncmp(op->mod, "hh", 2) == 0)
  ft_putchar((unsigned char)lnk->ull);
 else if (ft_strncmp(op->mod, "h", 1) == 0)
  str = ft_uitoa((unsigned short)lnk->ull);
 else if (ft_strncmp(op->mod, "ll", 2) == 0
   || ft_strncmp(op->mod, "l", 1) == 0)
  str = ft_uitoa((unsigned long)lnk->ull);
 else if (ft_strncmp(op->mod, "j", 1) == 0)
  str = ft_uitoa((unsigned long)lnk->ull);
 else if (ft_strncmp(op->mod, "t", 1) == 0)
  str = ft_uitoa((unsigned int)lnk->ull);
 else if (ft_strncmp(op->mod, "z", 1) == 0)
  str = ft_uitoa((unsigned long)lnk->ull);
 else if (ft_strncmp(op->mod, "q", 1) == 0)
  str = ft_uitoa((unsigned long)lnk->ull);
 else
  str = ft_uitoa((unsigned int)lnk->ull);
 return (str);
}

user_defined_types: struct s_option { int field; char *flag; char separator; int min_width; char starwidth; int precision; char *mod; char conv; int arg_size; struct s_option *next; }

user_defined_types: struct s_arg { char *str; long i; unsigned long ull; long ps; struct s_arg *next; }


decompiled_code:
__int64 __fastcall ft_pad_by_star(__int64 a1, __int64 *a2)
{
char v3; // al
int v4; // er15
__int64 v5; // rax
__int64 v6; // rax
int v7; // er12
int v8; // ebx
__int64 v9; // rdi
int v10; // ebx
__int64 v11; // rax
__int64 result; // rax
__int64 v13; // rax
__int64 v14; // rax

v3 = *(_BYTE *)(a1 + 40);
switch ( v3 )
{
case 'd':
case 'i':
v6 = ft_itoa_by_type(0LL, a1, *(_QWORD *)(*a2 + 32));
v4 = ft_strlen(v6);
break;
case 'u':
v13 = ft_itoa_by_utype(0LL, a1, *(_QWORD *)(*a2 + 32));
v4 = ft_strlen(v13);
break;
case 'o':
v14 = ft_convert_to_octal(*(unsigned int *)(*(_QWORD *)(*a2 + 32) + 16LL));
v4 = ft_strlen(v14);
break;
default:
v4 = 0;
if ( (v3 & 0xDF) == 88 )
{
v5 = ft_convert_to_hexa(*(unsigned int *)(*(_QWORD *)(*a2 + 32) + 16LL), (unsigned int)v3);
v4 = ft_strlen(v5);
}
break;
}
v7 = *(_QWORD *)(*a2 + 8);
if ( !v7 )
v7 = *(_DWORD *)(*a2 + 16);
if ( v4 >= v7 )
{
v10 = 0;
}
else
{
v8 = v4;
do
{
v9 = 48LL;
if ( (unsigned int)ft_strichr(*(_QWORD *)(a1 + 8), 48LL) == -1 )
v9 = 32LL;
ft_putchar(v9);
++v8;
}
while ( v7 != v8 );
v10 = v8 - v4;
}
v11 = *(_QWORD *)(*a2 + 32);
if ( v11 )
*a2 = v11;
result = *a2;
*(_QWORD *)(*a2 + 24) = v10;
return result;
}

original_code:
void ft_pad_by_star(t_op *op, t_arg **lnk)
{
 int k;
 int l;
 int o;
 char *str;
 k = o = l = 0;
 str = ((void *)0);
 if (op->conv == 'd' || op->conv == 'i')
  l = ft_strlen(ft_itoa_by_type(str, op, (*lnk)->next));
 else if (op->conv == 'u')
  l = ft_strlen(ft_itoa_by_utype(str, op, (*lnk)->next));
 else if (op->conv == 'o')
  l = ft_strlen(ft_convert_to_octal((unsigned int)(*lnk)->next->ull));
 else if (op->conv == 'x' || op->conv == 'X')
  l = ft_strlen(ft_convert_to_hexa((unsigned int)(*lnk)->next->ull, op->conv));
 k = (((int)(*lnk)->i != 0) ? (int)(*lnk)->i : (int)(*lnk)->ull);
 while (l < k)
 {
  ft_putchar((ft_strichr(op->flag, '0') != -1 ? '0' : ' '));
  o += 1;
  l++;
 }
 if ((*lnk)->next)
  *lnk = (*lnk)->next;
 (*lnk)->ps = o;
}

canonical_original_code:
void ft_pad_by_star(struct s_option *op, struct s_arg **lnk)
{
 int k;
 int l;
 int o;
 char *str;
 k = o = l = 0;
 str = ((void *)0);
 if (op->conv == 'd' || op->conv == 'i')
  l = ft_strlen(ft_itoa_by_type(str, op, (*lnk)->next));
 else if (op->conv == 'u')
  l = ft_strlen(ft_itoa_by_utype(str, op, (*lnk)->next));
 else if (op->conv == 'o')
  l = ft_strlen(ft_convert_to_octal((unsigned int)(*lnk)->next->ull));
 else if (op->conv == 'x' || op->conv == 'X')
  l = ft_strlen(ft_convert_to_hexa((unsigned int)(*lnk)->next->ull, op->conv));
 k = (((int)(*lnk)->i != 0) ? (int)(*lnk)->i : (int)(*lnk)->ull);
 while (l < k)
 {
  ft_putchar((ft_strichr(op->flag, '0') != -1 ? '0' : ' '));
  o += 1;
  l++;
 }
 if ((*lnk)->next)
  *lnk = (*lnk)->next;
 (*lnk)->ps = o;
}

variable_types: struct s_arg { char *str; long i; unsigned long ull; long ps; struct s_arg *next; } **

variable_types: k int

variable_types: l int

variable_types: o int