decompiled_code:
__int64 __fastcall new_proc(__int64 *a1, __int64 a2, int a3)
{
char *v4; // rax
char *v5; // rbx
__int64 v6; // rax

v4 = (char *)malloc(0x60uLL);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = v4;
write_long_to_mem(a2, v4 + 3, 4LL);
*((_DWORD *)v5 + 16) = a3;
*(_QWORD *)(v5 + 76) = 0xFFFFFFFFLL;
v6 = *a1;
*((_DWORD *)v5 + 17) = 0;
*a1 = (__int64)v5;
*((_QWORD *)v5 + 11) = v6;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, __int64 a2, int a3)
{
char *v4; // rax
char *v5; // rbx
__int64 v6; // rax

v4 = (char *)malloc(0x60uLL);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = v4;
write_long_to_mem(a2, v4 + 3, 4LL);
*((_DWORD *)v5 + 16) = a3;
*(_QWORD *)(v5 + 76) = 0xFFFFFFFFLL;
v6 = *a1;
*((_DWORD *)v5 + 17) = 0;
*a1 = (__int64)v5;
*((_QWORD *)v5 + 11) = v6;
return 0LL;
}

original_code:
int new_proc(t_proc **bgn_lst, long r1, int pc)
{
 t_proc *new;
 if ((new = (t_proc *)malloc(sizeof(t_proc))) == ((void *)0))
  return (-1);
 write_long_to_mem(r1, new->reg + 4 - 1, 4);
 new->pc = pc;
 new->carry = 0;
 new->cycle_to_exec = -1;
 new->nbr_live = 0;
 new->next = *bgn_lst;
 *bgn_lst = new;
 return (0);
}

canonical_original_code:
int new_proc(struct s_proc **bgn_lst, long r1, int pc)
{
 struct s_proc *new;
 if ((new = (struct s_proc *)malloc(sizeof(t_proc))) == ((void *)0))
  return (-1);
 write_long_to_mem(r1, new->reg + 4 - 1, 4);
 new->pc = pc;
 new->carry = 0;
 new->cycle_to_exec = -1;
 new->nbr_live = 0;
 new->next = *bgn_lst;
 *bgn_lst = new;
 return (0);
}

variable_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; } **

variable_types: pc int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
_QWORD *v5; // rax
_QWORD *v6; // rbp
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v7[0] = 0LL;
lexer_parser(v7, argv, envp);
if ( !v7[0] )
prt_err_usage();
v3 = lex_checksyntax();
if ( v3 )
return 0;
v5 = set_data(v7[0]);
v6 = v5;
if ( !v5 )
return prt_err("corewar: set_data: Malloc error.", &unk_142);
if ( (unsigned int)load_heroes(v5, v7[0], v5[512]) == -1 )
return 1;
cycling_machine(v6);
return v3;
}

original_code:
int main(int ac, char **ag)
{
 t_lex *lex;
 t_dat *d;
 (void)ac;
 lex = ((void *)0);
 lexer_parser(&lex, ag);
 if (lex == ((void *)0))
  prt_err_usage();
 if (lex_checksyntax(lex) == 0)
 {
  if ((d = set_data(lex)) == ((void *)0))
   return (prt_err("corewar: set_data: Malloc error.", ""));
  if (load_heroes(d, lex, d->bgn_lst) == -1)
   return (1);
  cycling_machine(d);
 }
 return (0);
}

canonical_original_code:
int main(int ac, char **ag)
{
 struct s_lex *lex;
 struct s_dat *d;
 (void)ac;
 lex = ((void *)0);
 lexer_parser(&lex, ag);
 if (lex == ((void *)0))
  prt_err_usage();
 if (lex_checksyntax(lex) == 0)
 {
  if ((d = set_data(lex)) == ((void *)0))
   return (prt_err("corewar: set_data: Malloc error.", ""));
  if (load_heroes(d, lex, d->bgn_lst) == -1)
   return (1);
  cycling_machine(d);
 }
 return (0);
}

variable_types: ac int

variable_types:
ag
char **

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: 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; } *

return_type: int

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

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; }


original_code:
void f_sub(t_dat *dat, t_proc *proc)
{
 long i;
 long j;
 long k;
 i = (int)get_val(dat->arena, proc->pc + 2, ((16 / 256) + 1));
 j = (int)get_val(dat->arena, proc->pc + 3, ((16 / 256) + 1));
 k = (int)get_val(dat->arena, proc->pc + 4, ((16 / 256) + 1));
 if (i > 0 && i <= 16 && j > 0 && j <= 16)
 {
  if (k > 0 && k <= 16)
  {
   i = (int)get_val(proc->reg + ((i - 1) * 4), 0, 4);
   j = (int)get_val(proc->reg + ((j - 1) * 4), 0, 4);
   if (dat->verbose)
    ft_printf("sub: value %ld - value %ld -> reg%ld\n", i, j, k);
   i -= j;
   write_long_to_mem(i, (proc->reg + ((k * 4) - 1)), 4);
   proc->carry = (i == 0 ? 1 : 0);
  }
 }
 move_pc(proc, 4);
}

canonical_original_code:
void f_sub(struct s_dat *dat, struct s_proc *proc)
{
 long i;
 long j;
 long k;
 i = (int)get_val(dat->arena, proc->pc + 2, ((16 / 256) + 1));
 j = (int)get_val(dat->arena, proc->pc + 3, ((16 / 256) + 1));
 k = (int)get_val(dat->arena, proc->pc + 4, ((16 / 256) + 1));
 if (i > 0 && i <= 16 && j > 0 && j <= 16)
 {
  if (k > 0 && k <= 16)
  {
   i = (int)get_val(proc->reg + ((i - 1) * 4), 0, 4);
   j = (int)get_val(proc->reg + ((j - 1) * 4), 0, 4);
   if (dat->verbose)
    ft_printf("sub: value %ld - value %ld -> reg%ld\n", i, j, k);
   i -= j;
   write_long_to_mem(i, (proc->reg + ((k * 4) - 1)), 4);
   proc->carry = (i == 0 ? 1 : 0);
  }
 }
 move_pc(proc, 4);
}

variable_types:
proc
struct s_proc *

variable_types: i long

variable_types: j long

variable_types: k long

return_type: void

user_defined_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; }


decompiled_code:
void __fastcall free_proc_lst(void *ptr)
{
_QWORD *v2; // rdi

v2 = *(_QWORD **)ptr;
if ( v2 )
{
do
{
*(_QWORD *)ptr = v2[11];
free(v2);
v2 = *(_QWORD **)ptr;
}
while ( *(_QWORD *)ptr );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
_QWORD *v2; // rdi

v2 = *(_QWORD **)ptr;
if ( v2 )
{
do
{
*(_QWORD *)ptr = v2[11];
free(v2);
v2 = *(_QWORD **)ptr;
}
while ( *(_QWORD *)ptr );
}
free(ptr);
}

original_code:
void free_proc_lst(t_proc **lst)
{
 t_proc *tmp;
 t_proc **tmp2;
 tmp2 = lst;
 while (*lst)
 {
  tmp = *lst;
  *lst = (*lst)->next;
  free(tmp);
 }
 free(tmp2);
}

canonical_original_code:
void free_proc_lst(struct s_proc **lst)
{
 struct s_proc *tmp;
 struct s_proc **tmp2;
 tmp2 = lst;
 while (*lst)
 {
  tmp = *lst;
  *lst = (*lst)->next;
  free(tmp);
 }
 free(tmp2);
}

variable_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; } *


decompiled_code:
void __fastcall free_hero_lst(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

if ( ptr )
{
v1 = (void **)ptr;
do
{
v2 = v1;
v1 = (void **)v1[3];
free(*v2);
free(v2[1]);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

if ( ptr )
{
v1 = (void **)ptr;
do
{
v2 = v1;
v1 = (void **)v1[3];
free(*v2);
free(v2[1]);
free(v2);
}
while ( v1 );
}
}

original_code:
void free_hero_lst(t_hero *lst)
{
 t_hero *tmp;
 while (lst)
 {
  tmp = lst;
  lst = lst->next;
  free(tmp->buf);
  free(tmp->name);
  free(tmp);
 }
}

canonical_original_code:
void free_hero_lst(struct s_hero *lst)
{
 struct s_hero *tmp;
 while (lst)
 {
  tmp = lst;
  lst = lst->next;
  free(tmp->buf);
  free(tmp->name);
  free(tmp);
 }
}

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


decompiled_code:
void __fastcall free_data(void *ptr)
{
free_proc_lst(*((void **)ptr + 512));
free_hero_lst(*((void **)ptr + 513));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
func0(*((void **)ptr + 512));
func1(*((void **)ptr + 513));
free(ptr);
}

original_code:
void free_data(t_dat *d)
{
 free_proc_lst(d->bgn_lst);
 free_hero_lst(d->hero_lst);
 free(d);
}

canonical_original_code:
void free_data(struct s_dat *d)
{
 free_proc_lst(d->bgn_lst);
 free_hero_lst(d->hero_lst);
 free(d);
}


decompiled_code:
__int64 __fastcall pri_print_live_params_values(__int64 a1, int *a2)
{
int v3; // eax
int v4; // edi
__int64 result; // rax
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3 = swa_swap_char_by_params(*(_QWORD *)(a1 + 8), 4LL, 0LL);
v4 = *a2;
buf[0] = v3;
write(v4, buf, 4uLL);
result = *(_QWORD *)(a1 + 16);
a2[2] += 4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int *a2)
{
int v3; // eax
int v4; // edi
__int64 result; // rax
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3 = swa_swap_char_by_params(*(_QWORD *)(a1 + 8), 4LL, 0LL);
v4 = *a2;
buf[0] = v3;
write(v4, buf, 4uLL);
result = *(_QWORD *)(a1 + 16);
a2[2] += 4;
return result;
}

original_code:
t_lexer *pri_print_live_params_values(t_lexer *lexer, t_adr *adr)
{
 int i;
 i = swa_swap_char_by_params(lexer->value, 4, 0);
 write(adr->fd, &i, 4);
 adr->currentpos += 4;
 lexer = lexer->next;
 return (lexer);
}

canonical_original_code:
struct s_lexer *pri_print_live_params_values(struct s_lexer *lexer, struct s_adr *adr)
{
 int i;
 i = swa_swap_char_by_params(lexer->value, 4, 0);
 write(adr->fd, &i, 4);
 adr->currentpos += 4;
 lexer = lexer->next;
 return (lexer);
}

variable_types:
lexer
struct s_lexer *

variable_types: struct s_adr { int fd; int linepos; int currentpos; int onlive; int getindex; int index; } *

variable_types: i int

return_type: 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; }


decompiled_code:
__int64 __fastcall ft_strncpy(__int64 a1, char *a2, unsigned __int64 a3)
{
char v4; // al
unsigned __int64 i; // rdi

v4 = *a2;
for ( i = 0LL; a3 > i; v4 = a2[i] )
{
if ( !v4 )
break;
*(_BYTE *)(a1 + i++) = v4;
}
if ( a3 + 1 != i && a3 > i )
memset((void *)(a1 + i), 0, a3 - i);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, char *a2, unsigned __int64 a3)
{
char v4; // al
unsigned __int64 i; // rdi

v4 = *a2;
for ( i = 0LL; a3 > i; v4 = a2[i] )
{
if ( !v4 )
break;
*(_BYTE *)(a1 + i++) = v4;
}
if ( a3 + 1 != i && a3 > i )
memset((void *)(a1 + i), 0, a3 - i);
return a1;
}

original_code:
char *ft_strncpy(char *str, const char *str3, size_t l)
{
 size_t i;
 i = 0;
 while (str3[i] != '\0' && i < l)
 {
  str[i] = str3[i];
  i++;
 }
 if (i != (l + 1))
 {
  while (i < l)
  {
   str[i] = '\0';
   i++;
  }
 }
 return (str);
}

canonical_original_code:
char *ft_strncpy(char *str, char *str3, unsigned long l)
{
 unsigned long i;
 i = 0;
 while (str3[i] != '\0' && i < l)
 {
  str[i] = str3[i];
  i++;
 }
 if (i != (l + 1))
 {
  while (i < l)
  {
   str[i] = '\0';
   i++;
  }
 }
 return (str);
}

variable_types:
str
char *

variable_types:
l
unsigned long

variable_types:
i
unsigned long

return_type: char *


original_code:
t_list *ft_lpb(t_list *lnk, t_list *new)
{
 t_list *save;
 save = lnk;
 if (lnk == ((void *)0))
  return (new);
 while (lnk->next != ((void *)0))
 {
  lnk = lnk->next;
 }
 lnk->next = new;
 return (save);
}

canonical_original_code:
struct s_list *ft_lpb(struct s_list *lnk, struct s_list *new)
{
 struct s_list *save;
 save = lnk;
 if (lnk == ((void *)0))
  return (new);
 while (lnk->next != ((void *)0))
 {
  lnk = lnk->next;
 }
 lnk->next = new;
 return (save);
}

variable_types:
lnk
struct s_list *

variable_types:
new
struct s_list *

variable_types: struct s_list { void *content; unsigned long content_size; struct s_list *next; } *


decompiled_code:
int __fastcall ft_not_builtins_fd_left(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int result; // eax
_QWORD *v7; // rax
int v8; // er14
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

result = fork();
if ( result > 0 )
return waitpid(-1, stat_loc, 0);
if ( !result )
{
v7 = (_QWORD *)ft_strsplit(*(_QWORD *)(a4 + 32), 32LL);
v8 = open_file(*v7);
if ( v8 == -1 )
ft_error_exit("{f_n_b_f_l} An error occurred while opening file");
dup2(v8, 0);
close(v8);
result = ft_execute(a1, a2, a3);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int result; // eax
_QWORD *v7; // rax
int v8; // er14
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

result = fork();
if ( result > 0 )
return waitpid(-1, stat_loc, 0);
if ( !result )
{
v7 = (_QWORD *)ft_strsplit(*(_QWORD *)(a4 + 32), 32LL);
v8 = open_file(*v7);
if ( v8 == -1 )
ft_error_exit("{f_n_b_f_l} An error occurred while opening file");
dup2(v8, 0);
close(v8);
result = ft_execute(a1, a2, a3);
}
return result;
}

original_code:
void ft_not_builtins_fd_left(char **p, char **arg, char ***env, t_ast *ast)
{
 int status;
 int i;
 int fildes;
 char **cmd;
 if ((i = fork()) > 0)
  waitpid(-1, &status, 1 & 2);
 else if (i == 0)
 {
  cmd = ft_strsplit(ast->right, ' ');
  if ((fildes = open_file(cmd[0])) == -1)
   ft_error_exit("{f_n_b_f_l} An error occurred while opening file");
  dup2(fildes, 0);
  close(fildes);
  ft_execute(p, arg, env);
 }
}

canonical_original_code:
void ft_not_builtins_fd_left(char **p, char **arg, char ***env, struct s_ast *ast)
{
 int status;
 int i;
 int fildes;
 char **cmd;
 if ((i = fork()) > 0)
  waitpid(-1, &status, 1 & 2);
 else if (i == 0)
 {
  cmd = ft_strsplit(ast->right, ' ');
  if ((fildes = open_file(cmd[0])) == -1)
   ft_error_exit("{f_n_b_f_l} An error occurred while opening file");
  dup2(fildes, 0);
  close(fildes);
  ft_execute(p, arg, env);
 }
}

variable_types:
p
char **

variable_types:
arg
char **

variable_types:
env
char ***

variable_types: struct s_ast { 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_ast *parent; struct s_ast *leftcmd; char *left; char *right; int fd[2]; } *

variable_types: status int

variable_types: fildes int

variable_types:
cmd
char **

user_defined_types: struct s_ast { enum e_type type; struct s_ast *parent; struct s_ast *leftcmd; char *left; char *right; int fd[2]; }


decompiled_code:
int __fastcall ft_not_fd_right_append(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int result; // eax
_QWORD *v7; // rax
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

result = fork();
if ( result > 0 )
return waitpid(-1, stat_loc, 0);
if ( !result )
{
v7 = (_QWORD *)ft_strsplit(*(_QWORD *)(a4 + 32), 32LL);
result = append_file(*v7);
if ( result != -1 )
{
dup2(result, 1);
result = ft_execute(a1, a2, a3);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int result; // eax
_QWORD *v7; // rax
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

result = fork();
if ( result > 0 )
return waitpid(-1, stat_loc, 0);
if ( !result )
{
v7 = (_QWORD *)ft_strsplit(*(_QWORD *)(a4 + 32), 32LL);
result = append_file(*v7);
if ( result != -1 )
{
dup2(result, 1);
result = ft_execute(a1, a2, a3);
}
}
return result;
}

original_code:
void ft_not_fd_right_append(char **path, char **arg, char ***env, t_ast *ast)
{
 int status;
 int i;
 int fildes;
 char **cmd;
 if ((i = fork()) > 0)
  waitpid(-1, &status, 1 & 2);
 else if (i == 0)
 {
  cmd = ft_strsplit(ast->right, ' ');
  if ((fildes = append_file(cmd[0])) == -1)
   return ;
  dup2(fildes, 1);
  ft_execute(path, arg, env);
 }
}

canonical_original_code:
void ft_not_fd_right_append(char **path, char **arg, char ***env, struct s_ast *ast)
{
 int status;
 int i;
 int fildes;
 char **cmd;
 if ((i = fork()) > 0)
  waitpid(-1, &status, 1 & 2);
 else if (i == 0)
 {
  cmd = ft_strsplit(ast->right, ' ');
  if ((fildes = append_file(cmd[0])) == -1)
   return ;
  dup2(fildes, 1);
  ft_execute(path, arg, env);
 }
}

variable_types:
path
char **

user_defined_types: enum e_type { QUOTE=0, LREDIR=1, RREDIR=2, LAREDIR=3, RAREDIR=4, PIPE=5, SEMICOLON=6, WHITESPACE=7, STDCHAR=8, ENDOFLINE=9 }


decompiled_code:
int __fastcall ft_not_builtins_fd_right(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int result; // eax
_QWORD *v7; // rax
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

result = fork();
if ( result > 0 )
return waitpid(-1, stat_loc, 0);
if ( !result )
{
v7 = (_QWORD *)ft_strsplit(*(_QWORD *)(a4 + 32), 32LL);
result = create_file(*v7);
if ( result != -1 )
{
dup2(result, 1);
result = ft_execute(a1, a2, a3);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int result; // eax
_QWORD *v7; // rax
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

result = fork();
if ( result > 0 )
return waitpid(-1, stat_loc, 0);
if ( !result )
{
v7 = (_QWORD *)ft_strsplit(*(_QWORD *)(a4 + 32), 32LL);
result = create_file(*v7);
if ( result != -1 )
{
dup2(result, 1);
result = ft_execute(a1, a2, a3);
}
}
return result;
}

original_code:
void ft_not_builtins_fd_right(char **p, char **arg, char ***env, t_ast *ast)
{
 int status;
 int i;
 int fildes;
 char **cmd;
 if ((i = fork()) > 0)
  waitpid(-1, &status, 1 & 2);
 else if (i == 0)
 {
  cmd = ft_strsplit(ast->right, ' ');
  if ((fildes = create_file(cmd[0])) == -1)
   return ;
  dup2(fildes, 1);
  ft_execute(p, arg, env);
 }
}

canonical_original_code:
void ft_not_builtins_fd_right(char **p, char **arg, char ***env, struct s_ast *ast)
{
 int status;
 int i;
 int fildes;
 char **cmd;
 if ((i = fork()) > 0)
  waitpid(-1, &status, 1 & 2);
 else if (i == 0)
 {
  cmd = ft_strsplit(ast->right, ' ');
  if ((fildes = create_file(cmd[0])) == -1)
   return ;
  dup2(fildes, 1);
  ft_execute(p, arg, env);
 }
}


decompiled_code:
__int64 __fastcall print_tree(const char **a1)
{
const char **v1; // rbx
__int64 result; // rax
unsigned int *i; // rbx

do
{
v1 = a1;
a1 = (const char **)a1[2];
}
while ( a1 );
result = ft_printf("%s | %d | %s\n", v1[3], *(unsigned int *)v1, v1[4]);
for ( i = (unsigned int *)v1[1]; i; i = (unsigned int *)*((_QWORD *)i + 1) )
result = ft_printf("%p | %d | %s\n", *((const void **)i + 2), *i, *((const char **)i + 4));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char **a1)
{
const char **v1; // rbx
__int64 result; // rax
unsigned int *i; // rbx

do
{
v1 = a1;
a1 = (const char **)a1[2];
}
while ( a1 );
result = ft_printf("%s | %d | %s\n", v1[3], *(unsigned int *)v1, v1[4]);
for ( i = (unsigned int *)v1[1]; i; i = (unsigned int *)*((_QWORD *)i + 1) )
result = ft_printf("%p | %d | %s\n", *((const void **)i + 2), *i, *((const char **)i + 4));
return result;
}

original_code:
void print_tree(t_ast *ast)
{
 while (ast->leftcmd != ((void *)0))
  ast = ast->leftcmd;
 ft_printf("%s | %d | %s\n", ast->left, ast->type, ast->right);
 while (ast != ((void *)0))
 {
  ast = ast->parent;
  if (ast != ((void *)0))
   ft_printf("%p | %d | %s\n", ast->leftcmd, ast->type, ast->right);
 }
}

canonical_original_code:
void print_tree(struct s_ast *ast)
{
 while (ast->leftcmd != ((void *)0))
  ast = ast->leftcmd;
 ft_printf("%s | %d | %s\n", ast->left, ast->type, ast->right);
 while (ast != ((void *)0))
 {
  ast = ast->parent;
  if (ast != ((void *)0))
   ft_printf("%p | %d | %s\n", ast->leftcmd, ast->type, ast->right);
 }
}


decompiled_code:
__int64 __fastcall do_more_shit(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 *v4; // rax
__int64 v5; // rdi
_QWORD *v6; // rbx
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

while ( 1 )
{
create_prompt(a1);
result = get_next_line(0LL, v7);
if ( (int)result <= 0 )
break;
v4 = (__int64 *)ft_strsplit(v7[0], 59LL);
v5 = *v4;
if ( *v4 )
{
v6 = v4 + 1;
do
{
++v6;
start_commands(v5, a1, a2);
v5 = *(v6 - 1);
}
while ( v5 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 *v4; // rax
__int64 v5; // rdi
_QWORD *v6; // rbx
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

while ( 1 )
{
create_prompt(a1);
result = get_next_line(0LL, v7);
if ( (int)result <= 0 )
break;
v4 = (__int64 *)ft_strsplit(v7[0], 59LL);
v5 = *v4;
if ( *v4 )
{
v6 = v4 + 1;
do
{
++v6;
start_commands(v5, a1, a2);
v5 = *(v6 - 1);
}
while ( v5 );
}
}
return result;
}

original_code:
void do_more_shit(char **env, char **path)
{
 int ret;
 int i;
 char *line;
 char **commands;
 while (create_prompt(env), (ret = get_next_line(0, &line)) > 0)
 {
  i = 0;
  commands = ft_strsplit(line, ';');
  while (commands[i] != ((void *)0))
  {
   start_commands(commands[i], env, path);
   i++;
  }
 }
}

variable_types:
env
char **

variable_types: ret int

variable_types:
line
char *

variable_types:
commands
char **


canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v4; // [rsp+0h] [rbp-38h] BYREF
__int64 v5; // [rsp+8h] [rbp-30h]

get_params(a1, a2, &v4, 4LL);
v2 = v5;
if ( (unsigned __int64)(v5 - 1) <= 0xF )
{
if ( *(_DWORD *)(a1 + 4136) )
{
ft_printf("ld: value %d -> reg%ld\n", (unsigned int)v4);
v2 = v5;
}
write_long_to_mem(v4, a2 + 4 * v2 - 1, 4LL);
*(_DWORD *)(a2 + 68) = v4 == 0;
}
return move_pc(a2, 4LL);
}

original_code:
void f_ld(t_dat *dat, t_proc *proc)
{
 long vals[3];
 get_params(dat, proc, vals, 4);
 if (vals[1] > 0 && vals[1] <= 16)
 {
  if (dat->verbose)
   ft_printf("ld: value %d -> reg%ld\n", (int)vals[0], vals[1]);
  write_long_to_mem(vals[0], proc->reg + ((vals[1]) * 4) - 1,
      4);
  if (vals[0] == 0)
   proc->carry = 1;
  else
   proc->carry = 0;
 }
 move_pc(proc, 4);
}

canonical_original_code:
void f_ld(struct s_dat *dat, struct s_proc *proc)
{
 long vals[3];
 get_params(dat, proc, vals, 4);
 if (vals[1] > 0 && vals[1] <= 16)
 {
  if (dat->verbose)
   ft_printf("ld: value %d -> reg%ld\n", (int)vals[0], vals[1]);
  write_long_to_mem(vals[0], proc->reg + ((vals[1]) * 4) - 1,
      4);
  if (vals[0] == 0)
   proc->carry = 1;
  else
   proc->carry = 0;
 }
 move_pc(proc, 4);
}

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:
proc
struct s_proc *

variable_types:
vals
long [3]


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

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

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

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
t_recurs *ft_create_tree(t_recurs *recurs)
{
 recurs = (t_recurs*)malloc(sizeof(t_recurs));
 recurs->content = ((void *)0);
 recurs->dirlist = ((void *)0);
 return (recurs);
}

canonical_original_code:
struct s_list5 *ft_create_tree(struct s_list5 *recurs)
{
 recurs = (struct s_list5 *)malloc(sizeof(t_recurs));
 recurs->content = ((void *)0);
 recurs->dirlist = ((void *)0);
 return (recurs);
}

variable_types:
recurs
struct s_list5 *

return_type: struct s_list5 { struct s_list2 { char *right; char *owner; char *group; char *name; char *time; char *link; char *size; char *major; char *minor; int blk; long timestamp; struct s_list2 *next; struct s_list2 *prev; } *content; struct s_list2 *dirlist; } *

user_defined_types: struct s_list5 { struct s_list2 *content; struct s_list2 *dirlist; }


decompiled_code:
__int64 __fastcall ft_print_error_permission(__int64 a1)
{
__int64 v1; // r12
int v2; // eax
__int64 v3; // rbp

v1 = ft_strlen();
v2 = ft_strirchr(a1, 47LL);
v3 = ft_strsub(a1, (unsigned int)(v2 + 1), v1);
ft_putstr_fd("ft_ls: ", 2LL);
ft_putstr_fd(v3, 2LL);
return ft_putendl_fd(": Permission denied", 2LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // r12
int v2; // eax
__int64 v3; // rbp

v1 = ft_strlen();
v2 = ft_strirchr(a1, 47LL);
v3 = ft_strsub(a1, (unsigned int)(v2 + 1), v1);
ft_putstr_fd("ft_ls: ", 2LL);
ft_putstr_fd(v3, 2LL);
return ft_putendl_fd(": Permission denied", 2LL);
}

original_code:
void ft_print_error_permission(char *dir)
{
 dir = ft_strsub(dir, (ft_strirchr(dir, '/') + 1), ft_strlen(dir));
 ft_putstr_fd("ft_ls: ", 2);
 ft_putstr_fd(dir, 2);
 ft_putendl_fd(": Permission denied", 2);
}

variable_types:
dir
char *


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

result = (int)ft_strirchr(a1, 47LL);
if ( *(_BYTE *)(a1 + (int)result + 1) != 46 || *(_DWORD *)(a2 + 4) )
{
result = *(unsigned int *)(a2 + 20);
if ( (_DWORD)result )
{
ft_putendl(&unk_327);
ft_putstr(a1);
result = ft_putendl(":");
}
*(_DWORD *)(a2 + 20) = 1;
}
return result;
}

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

result = (int)ft_strirchr(a1, 47LL);
if ( *(_BYTE *)(a1 + (int)result + 1) != 46 || *(_DWORD *)(a2 + 4) )
{
result = *(unsigned int *)(a2 + 20);
if ( (_DWORD)result )
{
ft_putendl(&unk_327);
ft_putstr(a1);
result = ft_putendl(":");
}
*(_DWORD *)(a2 + 20) = 1;
}
return result;
}

original_code:
void ft_print_dir_name(char *dir, t_params *p)
{
 int i;
 i = ft_strirchr(dir, '/');
 if (dir[i + 1] == '.' && p->a == 0)
  ;
 else
 {
  if (p->round != 0)
  {
   ft_putendl("");
   ft_putstr(dir);
   ft_putendl(":");
  }
  p->round = 1;
 }
}

canonical_original_code:
void ft_print_dir_name(char *dir, struct s_list4 *p)
{
 int i;
 i = ft_strirchr(dir, '/');
 if (dir[i + 1] == '.' && p->a == 0)
  ;
 else
 {
  if (p->round != 0)
  {
   ft_putendl("");
   ft_putstr(dir);
   ft_putendl(":");
  }
  p->round = 1;
 }
}

variable_types: struct s_list4 { int l; int a; int r; int R; int t; int round; } *

variable_types: i int


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

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

original_code:
t_arg *ft_arg_list_push_back(t_arg *lnk, t_arg *new)
{
 t_arg *save;
 save = lnk;
 if (lnk == ((void *)0))
  return (new);
 while (lnk->next)
  lnk = lnk->next;
 lnk->next = new;
 return (save);
}

canonical_original_code:
struct s_arg *ft_arg_list_push_back(struct s_arg *lnk, struct s_arg *new)
{
 struct s_arg *save;
 save = lnk;
 if (lnk == ((void *)0))
  return (new);
 while (lnk->next)
  lnk = lnk->next;
 lnk->next = new;
 return (save);
}

variable_types:
lnk
struct s_arg *

variable_types:
new
struct s_arg *

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


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

result = malloc(0x28uLL);
*result = 0LL;
result[3] = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[4] = 0LL;
return result;
}

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

result = malloc(0x28uLL);
*result = 0LL;
result[3] = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[4] = 0LL;
return result;
}

original_code:
t_arg *ft_build_arg_empty(t_arg *lnk)
{
 lnk = (t_arg*)malloc(sizeof(t_arg));
 lnk->str = ((void *)0);
 lnk->ps = 0;
 lnk->i = 0;
 lnk->ull = 0;
 lnk->next = ((void *)0);
 return (lnk);
}

canonical_original_code:
struct s_arg *ft_build_arg_empty(struct s_arg *lnk)
{
 lnk = (struct s_arg *)malloc(sizeof(t_arg));
 lnk->str = ((void *)0);
 lnk->ps = 0;
 lnk->i = 0;
 lnk->ull = 0;
 lnk->next = ((void *)0);
 return (lnk);
}

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


decompiled_code:
void __fastcall ft_strclr(_BYTE *a1)
{
while ( *a1 )
*a1++ = 0;
}

canonical_decompiled_code:
void __fastcall func0(_BYTE *a1)
{
while ( *a1 )
*a1++ = 0;
}

variable_types:
s
char *


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

result = a4 / a3;
*a1 = a4 % a3;
*a2 = a4 / a3;
return result;
}

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

result = a4 / a3;
*a1 = a4 % a3;
*a2 = a4 / a3;
return result;
}

original_code:
static void set_mod_and_div(t_ul *mod, t_ul *div, t_ul base, t_ul n)
{
 *mod = n % base;
 *div = n / base;
}

canonical_original_code:
static void set_mod_and_div(unsigned long *mod, unsigned long *div, unsigned long base, unsigned long n)
{
 *mod = n % base;
 *div = n / base;
}

variable_types:
mod
unsigned long *

variable_types:
div
unsigned long *

variable_types:
base
unsigned long

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall count_nbr(unsigned __int64 a1)
{
unsigned __int64 v1; // rdx
__int64 v2; // r8
unsigned __int64 v3; // rcx

v1 = a1;
v2 = 1LL;
if ( a1 > 9 )
{
do
{
v3 = v1;
++v2;
v1 /= 0xAuLL;
}
while ( v3 > 0x63 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1)
{
unsigned __int64 v1; // rdx
__int64 v2; // r8
unsigned __int64 v3; // rcx

v1 = a1;
v2 = 1LL;
if ( a1 > 9 )
{
do
{
v3 = v1;
++v2;
v1 /= 0xAuLL;
}
while ( v3 > 0x63 );
}
return v2;
}

original_code:
static t_ul count_nbr(t_ul n)
{
 t_ul count;
 count = 1;
 while (n / 10 > 0)
 {
  n /= 10;
  count++;
 }
 return (count);
}

canonical_original_code:
static unsigned long count_nbr(unsigned long n)
{
 unsigned long count;
 count = 1;
 while (n / 10 > 0)
 {
  n /= 10;
  count++;
 }
 return (count);
}

variable_types:
count
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall prt_err_null(__int64 a1, _BYTE *a2)
{
write(2, "corewar: ", 0x10uLL);
ft_putstr_fd(a1, 2LL);
write(2, ": ", 2uLL);
if ( *a2 )
{
ft_putstr_fd(a2, 2LL);
write(2, ": ", 2uLL);
}
perror(0LL);
write(2, "\n", 1uLL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _BYTE *a2)
{
write(2, "corewar: ", 0x10uLL);
ft_putstr_fd(a1, 2LL);
write(2, ": ", 2uLL);
if ( *a2 )
{
ft_putstr_fd(a2, 2LL);
write(2, ": ", 2uLL);
}
perror(0LL);
write(2, "\n", 1uLL);
return 0LL;
}

original_code:
void *prt_err_null(char *function, char *add)
{
 write(2, "corewar: ", 16);
 ft_putstr_fd(function, 2);
 write(2, ": ", 2);
 if (add[0] != 0)
 {
  ft_putstr_fd(add, 2);
  write(2, ": ", 2);
 }
 perror(((void *)0));
 write(2, "\n", 1);
 return (((void *)0));
}

variable_types:
function
char *

variable_types:
add
char *

return_type: void *


decompiled_code:
__int64 __fastcall prt_err(__int64 a1, _BYTE *a2)
{
write(2, "corewar: ", 0x10uLL);
ft_putstr_fd(a1, 2LL);
write(2, ": ", 2uLL);
if ( *a2 )
{
ft_putstr_fd(a2, 2LL);
write(2, ": ", 2uLL);
}
perror(0LL);
write(2, "\n", 1uLL);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _BYTE *a2)
{
write(2, "corewar: ", 0x10uLL);
ft_putstr_fd(a1, 2LL);
write(2, ": ", 2uLL);
if ( *a2 )
{
ft_putstr_fd(a2, 2LL);
write(2, ": ", 2uLL);
}
perror(0LL);
write(2, "\n", 1uLL);
return 0xFFFFFFFFLL;
}

original_code:
int prt_err(char *function, char *add)
{
 write(2, "corewar: ", 16);
 ft_putstr_fd(function, 2);
 write(2, ": ", 2);
 if (add[0] != 0)
 {
  ft_putstr_fd(add, 2);
  write(2, ": ", 2);
 }
 perror(((void *)0));
 write(2, "\n", 1);
 return (-1);
}


decompiled_code:
__int64 __fastcall ft_count_length(__int64 a1, char a2, int *a3)
{
__int64 v4; // rax
char v5; // dl
unsigned int v6; // er8
__int64 v7; // rax
char v8; // dl

v4 = *a3;
v5 = *(_BYTE *)(a1 + v4);
if ( !v5 || v5 == a2 )
return 0LL;
v6 = 0;
v7 = (int)v4 + 1;
do
{
*a3 = v7;
v8 = *(_BYTE *)(a1 + v7);
++v6;
++v7;
}
while ( v8 && v8 != a2 );
return v6;
}

original_code:
int ft_count_length(const char *s, char c, int *i)
{
 int j;
 j = 0;
 while (s[*i] != c && s[*i] != '\0')
 {
  *i += 1;
  j++;
 }
 return (j);
}

canonical_original_code:
int ft_count_length(char *s, char c, int *i)
{
 int j;
 j = 0;
 while (s[*i] != c && s[*i] != '\0')
 {
  *i += 1;
  j++;
 }
 return (j);
}

variable_types: c char

variable_types:
i
int *

variable_types: j int


decompiled_code:
__int64 __fastcall ft_modifier_options(__int64 a1, __int64 a2, int a3)
{
__int64 v5; // rsi
_BYTE *v6; // rcx
__int64 v7; // rdi
__int64 v8; // rdx
int v9; // ebx
int v10; // ebp
unsigned __int64 v11; // rax
__int64 v12; // rax

v5 = a3;
v6 = (_BYTE *)(a1 + a3);
if ( (unsigned __int8)(*v6 - 76) <= 0x2Eu )
{
v7 = 0x412150000001LL;
if ( _bittest64(&v7, (unsigned int)(unsigned __int8)*v6 - 76) )
{
v8 = 1LL;
do
{
v9 = v8;
v10 = v5 + v8;
v11 = (unsigned int)(unsigned __int8)v6[v8] - 76;
if ( (unsigned __int8)(v6[v8] - 76) > 0x2Eu )
break;
++v8;
}
while ( _bittest64(&v7, v11) );
v12 = ft_strsub(a1, v5, v9);
*(_DWORD *)(a2 + 44) += v9;
LODWORD(v5) = v10;
*(_QWORD *)(a2 + 32) = v12;
}
}
return ft_converter_options(a1, a2, (unsigned int)v5);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v5; // rsi
_BYTE *v6; // rcx
__int64 v7; // rdi
__int64 v8; // rdx
int v9; // ebx
int v10; // ebp
unsigned __int64 v11; // rax
__int64 v12; // rax

v5 = a3;
v6 = (_BYTE *)(a1 + a3);
if ( (unsigned __int8)(*v6 - 76) <= 0x2Eu )
{
v7 = 0x412150000001LL;
if ( _bittest64(&v7, (unsigned int)(unsigned __int8)*v6 - 76) )
{
v8 = 1LL;
do
{
v9 = v8;
v10 = v5 + v8;
v11 = (unsigned int)(unsigned __int8)v6[v8] - 76;
if ( (unsigned __int8)(v6[v8] - 76) > 0x2Eu )
break;
++v8;
}
while ( _bittest64(&v7, v11) );
v12 = ft_strsub(a1, v5, v9);
*(_DWORD *)(a2 + 44) += v9;
LODWORD(v5) = v10;
*(_QWORD *)(a2 + 32) = v12;
}
}
return ft_converter_options(a1, a2, (unsigned int)v5);
}

original_code:
int ft_modifier_options(char *str, t_op *op, int i)
{
 int j;
 j = 0;
 if (str[i + j] == 'h' || str[i + j] == 'l' || str[i + j] == 'j' || str[i + j] == 't' || str[i + j] == 'z' || str[i + j] == 'q' || str[i + j] == 'L')
 {
  while (str[i + j] == 'h' || str[i + j] == 'l' || str[i + j] == 'j' || str[i + j] == 't' || str[i + j] == 'z' || str[i + j] == 'q' || str[i + j] == 'L')
   j++;
  op->mod = ft_strsub(str, i, j);
  i += j;
  op->arg_size += j;
 }
 i = ft_converter_options(str, op, i);
 return (i);
}

canonical_original_code:
int ft_modifier_options(char *str, struct s_option *op, int i)
{
 int j;
 j = 0;
 if (str[i + j] == 'h' || str[i + j] == 'l' || str[i + j] == 'j' || str[i + j] == 't' || str[i + j] == 'z' || str[i + j] == 'q' || str[i + j] == 'L')
 {
  while (str[i + j] == 'h' || str[i + j] == 'l' || str[i + j] == 'j' || str[i + j] == 't' || str[i + j] == 'z' || str[i + j] == 'q' || str[i + j] == 'L')
   j++;
  op->mod = ft_strsub(str, i, j);
  i += j;
  op->arg_size += j;
 }
 i = ft_converter_options(str, op, i);
 return (i);
}

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; } *


original_code:
int ft_precision_options(char *str, t_op *op, int i)
{
 int j;
 j = 0;
 if (str[i] == '.')
 {
  i++;
  while (str[i + j] >= '0' && str[i + j] <= '9')
   j++;
  op->precision = ft_atoi(ft_strsub(str, i, j));
  i += j;
  op->arg_size += j;
 }
 i = ft_modifier_options(str, op, i);
 return (i);
}

canonical_original_code:
int ft_precision_options(char *str, struct s_option *op, int i)
{
 int j;
 j = 0;
 if (str[i] == '.')
 {
  i++;
  while (str[i + j] >= '0' && str[i + j] <= '9')
   j++;
  op->precision = ft_atoi(ft_strsub(str, i, j));
  i += j;
  op->arg_size += j;
 }
 i = ft_modifier_options(str, op, i);
 return (i);
}

variable_types: i int

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; }


original_code:
int ft_width_options(char *str, t_op *op, int i)
{
 int j;
 j = 0;
 if (str[i] == '*')
 {
  op->starwidth = '*';
  op->arg_size += 1;
  i += 1;
 }
 if (str[i + j] >= '1' && str[i + j] <= '9')
 {
  while (str[i + j] >= '0' && str[i + j] <= '9')
   j++;
  op->min_width = ft_atoi(ft_strsub(str, i, j));
  i += j;
  op->arg_size += j;
 }
 i = ft_precision_options(str, op, i);
 return (i);
}

canonical_original_code:
int ft_width_options(char *str, struct s_option *op, int i)
{
 int j;
 j = 0;
 if (str[i] == '*')
 {
  op->starwidth = '*';
  op->arg_size += 1;
  i += 1;
 }
 if (str[i + j] >= '1' && str[i + j] <= '9')
 {
  while (str[i + j] >= '0' && str[i + j] <= '9')
   j++;
  op->min_width = ft_atoi(ft_strsub(str, i, j));
  i += j;
  op->arg_size += j;
 }
 i = ft_precision_options(str, op, i);
 return (i);
}


decompiled_code:
__int64 __fastcall ft_flag_options(__int64 a1, __int64 a2, int a3)
{
__int64 v5; // rsi
unsigned __int8 *v6; // rcx
unsigned __int64 v7; // rax
__int64 v8; // rdi
__int64 v9; // rax
unsigned __int64 v10; // rdx
int v11; // ebx
int v12; // ebp
__int64 v13; // rax

v5 = a3;
v6 = (unsigned __int8 *)(a1 + a3);
v7 = *v6;
if ( (unsigned __int8)v7 <= 0x30u )
{
v8 = 0x1288900000000LL;
if ( _bittest64(&v8, v7) )
{
v9 = 1LL;
do
{
v10 = v6[v9];
v11 = v9;
v12 = v5 + v9;
if ( (unsigned __int8)v10 > 0x30u )
break;
++v9;
}
while ( _bittest64(&v8, v10) );
v13 = ft_strsub(a1, v5, v11);
*(_DWORD *)(a2 + 44) += v11;
LODWORD(v5) = v12;
*(_QWORD *)(a2 + 8) = v13;
}
}
return ft_width_options(a1, a2, v5);
}

canonical_original_code:
int ft_flag_options(char *str, struct s_option *op, int i)
{
 int j;
 j = 0;
 if (str[i + j] == '#' || str[i + j] == '0' || str[i + j] == '-' || str[i + j] == ' ' || str[i + j] == '+' || str[i + j] == '\'')
 {
  while (str[i + j] == '#' || str[i + j] == '0' || str[i + j] == '-' || str[i + j] == ' ' || str[i + j] == '+' || str[i + j] == '\'')
   j++;
  op->flag = ft_strsub(str, i, j);
  i += j;
  op->arg_size += j;
 }
 i = ft_width_options(str, op, i);
 return (i);
}


decompiled_code:
__int64 __fastcall ft_field_options(__int64 a1, _DWORD *a2, int a3)
{
unsigned int v4; // er8
_BYTE *v5; // rsi
__int64 v6; // rax
char v7; // dl
int v8; // er13
int v9; // ebx
__int64 v11; // rax
int v12; // eax

v4 = a3;
v5 = (_BYTE *)(a1 + a3);
if ( (unsigned __int8)(*v5 - 49) <= 8u )
{
v6 = 1LL;
do
{
v7 = v5[v6];
v8 = v6;
v9 = v4 + v6++;
}
while ( (unsigned __int8)(v7 - 48) <= 9u );
if ( v7 != 36 )
return ft_width_options(a1, (__int64)a2, v4);
v11 = ft_strsub(a1, v4, v8);
v12 = ft_atoi(v11);
a2[11] += v8;
a3 = v9 + 1;
*a2 = v12;
}
return ft_flag_options(a1, (__int64)a2, a3);
}

original_code:
int ft_field_options(char *str, t_op *op, int i)
{
 int j;
 j = 0;
 if (str[i + j] >= '1' && str[i + j] <= '9')
 {
  while (str[i + j] >= '0' && str[i + j] <= '9')
   j++;
  if (str[i + j] == '$')
  {
   op->field = ft_atoi(ft_strsub(str, i, j));
   i += j;
   op->arg_size += j;
   i = ft_flag_options(str, op, i + 1);
  }
  else
   i = ft_width_options(str, op, i);
 }
 else
  i = ft_flag_options(str, op, i);
 return (i);
}

canonical_original_code:
int ft_field_options(char *str, struct s_option *op, int i)
{
 int j;
 j = 0;
 if (str[i + j] >= '1' && str[i + j] <= '9')
 {
  while (str[i + j] >= '0' && str[i + j] <= '9')
   j++;
  if (str[i + j] == '$')
  {
   op->field = ft_atoi(ft_strsub(str, i, j));
   i += j;
   op->arg_size += j;
   i = ft_flag_options(str, op, i + 1);
  }
  else
   i = ft_width_options(str, op, i);
 }
 else
  i = ft_flag_options(str, op, i);
 return (i);
}


decompiled_code:
__int64 __fastcall f_lldi(__int64 a1, __int64 a2)
{
int v2; // eax
int v4; // eax
__int64 v5; // r12
_BYTE v6[16]; // [rsp+0h] [rbp-38h] BYREF
__int64 v7; // [rsp+10h] [rbp-28h]

get_params(a1, a2, v6, 2LL);
v2 = get_addr(a2, v6);
if ( v2 != -1 && (unsigned __int64)(v7 - 1) <= 0xF )
{
v4 = get_true_val(v2, 0LL, 2LL);
v5 = get_val(a1, (unsigned int)(v4 + *(_DWORD *)(a2 + 64)), 4LL);
if ( *(_DWORD *)(a1 + 4136) )
ft_printf("lldi: value %ld -> reg%ld\n", v5, v7);
write_long_to_mem(v5, a2 + 4 * v7 - 1, 4LL);
*(_DWORD *)(a2 + 68) = v5 == 0;
}
return move_pc(a2, 2LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
int v2; // eax
int v4; // eax
__int64 v5; // r12
_BYTE v6[16]; // [rsp+0h] [rbp-38h] BYREF
__int64 v7; // [rsp+10h] [rbp-28h]

get_params(a1, a2, v6, 2LL);
v2 = get_addr(a2, v6);
if ( v2 != -1 && (unsigned __int64)(v7 - 1) <= 0xF )
{
v4 = get_true_val(v2, 0LL, 2LL);
v5 = get_val(a1, (unsigned int)(v4 + *(_DWORD *)(a2 + 64)), 4LL);
if ( *(_DWORD *)(a1 + 4136) )
ft_printf("lldi: value %ld -> reg%ld\n", v5, v7);
write_long_to_mem(v5, a2 + 4 * v7 - 1, 4LL);
*(_DWORD *)(a2 + 68) = v5 == 0;
}
return move_pc(a2, 2LL);
}

original_code:
void f_lldi(t_dat *dat, t_proc *proc)
{
 long vals[3];
 long val;
 get_params(dat, proc, vals, 2);
 if (((val = get_addr(proc, vals)) != -1)
  && vals[2] > 0 && vals[2] <= 16)
 {
  val = get_true_val(val, 0, 2);
  val = get_val(dat->arena, proc->pc + val, 4);
  if (dat->verbose)
   ft_printf("lldi: value %ld -> reg%ld\n", val, vals[2]);
  write_long_to_mem(val, proc->reg + (vals[2] * 4) - 1, 4);
  proc->carry = (val == 0 ? 1 : 0);
 }
 move_pc(proc, 2);
}

canonical_original_code:
void f_lldi(struct s_dat *dat, struct s_proc *proc)
{
 long vals[3];
 long val;
 get_params(dat, proc, vals, 2);
 if (((val = get_addr(proc, vals)) != -1)
  && vals[2] > 0 && vals[2] <= 16)
 {
  val = get_true_val(val, 0, 2);
  val = get_val(dat->arena, proc->pc + val, 4);
  if (dat->verbose)
   ft_printf("lldi: value %ld -> reg%ld\n", val, vals[2]);
  write_long_to_mem(val, proc->reg + (vals[2] * 4) - 1, 4);
  proc->carry = (val == 0 ? 1 : 0);
 }
 move_pc(proc, 2);
}

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:
proc
struct s_proc *

variable_types:
vals
long [3]

variable_types: val long


original_code:
t_obj *plane_data(t_obj *lst, char **tab, char *buf)
{
 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) || tab[6] == ((void *)0) || tab[7] == ((void *)0)
  || tab[8] == ((void *)0))
  file_error("Parser error in scene file near : ", buf);
 lst->pos = new_vect(ft_atof(tab[0]), ft_atof(tab[1]), ft_atof(tab[2]));
 lst->nor = new_vect(ft_atof(tab[3]), ft_atof(tab[4]), ft_atof(tab[5]));
 norm_vect(lst->nor);
 lst->r = ft_atoi(tab[6]);
 lst->g = ft_atoi(tab[7]);
 lst->b = ft_atoi(tab[8]);
 return (lst);
}

canonical_original_code:
struct s_obj *plane_data(struct s_obj *lst, char **tab, char *buf)
{
 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) || tab[6] == ((void *)0) || tab[7] == ((void *)0)
  || tab[8] == ((void *)0))
  file_error("Parser error in scene file near : ", buf);
 lst->pos = new_vect(ft_atof(tab[0]), ft_atof(tab[1]), ft_atof(tab[2]));
 lst->nor = new_vect(ft_atof(tab[3]), ft_atof(tab[4]), ft_atof(tab[5]));
 norm_vect(lst->nor);
 lst->r = ft_atoi(tab[6]);
 lst->g = ft_atoi(tab[7]);
 lst->b = ft_atoi(tab[8]);
 return (lst);
}

variable_types:
lst
struct s_obj *

variable_types:
tab
char **

variable_types:
buf
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; } *

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:
_BOOL8 ft_strnequ()
{
return (unsigned int)ft_strncmp() == 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return (unsigned int)ft_strncmp() == 0;
}

original_code:
int ft_strnequ(char const *s1, char const *s2, size_t n)
{
 if (ft_strncmp(s1, s2, n) == 0)
  return (1);
 else
  return (0);
}

canonical_original_code:
int ft_strnequ(char *s1, char *s2, unsigned long n)
{
 if (ft_strncmp(s1, s2, n) == 0)
  return (1);
 else
  return (0);
}

variable_types:
n
unsigned long


decompiled_code:
void __fastcall ft_strdel(void **a1)
{
free(*a1);
*a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func0(void **a1)
{
free(*a1);
*a1 = 0LL;
}

original_code:
void ft_strdel(char **as)
{
 free(*as);
 *as = ((void *)0);
}

variable_types:
as
char **


decompiled_code:
__int64 __fastcall ft_striter(_BYTE *a1, __int64 (__fastcall *a2)(_BYTE *))
{
_BYTE *v2; // rbx
_BYTE *v3; // rdi
__int64 result; // rax

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

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

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

original_code:
void ft_striter(char *s, void (*f)(char*))
{
 while (*s != '\0')
 {
  (*f)(s);
  s++;
 }
}

canonical_original_code:
void ft_striter(char *s, void (*f)(char *))
{
 while (*s != '\0')
 {
  (*f)(s);
  s++;
 }
}

variable_types:
s
char *

variable_types:
f
void (*)(char *)


decompiled_code:
__int64 __fastcall ft_sortlstcount(__int64 a1)
{
unsigned int i; // er8
__int64 v2; // rax

i = 0;
if ( a1 )
{
v2 = *(_QWORD *)(a1 + 8);
for ( i = 1; v2; ++i )
v2 = *(_QWORD *)(v2 + 8);
}
return i;
}

original_code:
int ft_sortlstcount(t_sort *lst)
{
    int i;
    i = 0;
    if (lst != ((void *)0))
    {
        i = 1;
        while (lst->next)
        {
            lst = lst->next;
            i++;
        }
    }
    return (i);
}

canonical_original_code:
int ft_sortlstcount(struct s_list_arg *lst)
{
    int i;
    i = 0;
    if (lst != ((void *)0))
    {
        i = 1;
        while (lst->next)
        {
            lst = lst->next;
            i++;
        }
    }
    return (i);
}

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


decompiled_code:
void *__fastcall ft_strglue(_QWORD *a1, char a2)
{
unsigned int v2; // er15
void *v3; // r12
__int64 v4; // rbx
void *v5; // rbp
__int64 v6; // rsi
__int64 v7; // r14
int v9; // [rsp+Ch] [rbp-3Ch]

v2 = a2;
v3 = (void *)ft_strdup(&unk_B7);
v9 = ft_countsplit(a1);
if ( !*a1 )
return v3;
v4 = 0LL;
while ( 1 )
{
v5 = (void *)((int)v4 > 0 && v9 > (int)v4 ? ft_strjoinc(v3, v2) : ft_strdup(&unk_B7));
v6 = a1[v4++];
v7 = ft_strjoin(v5, v6);
free(v3);
free(v5);
if ( !a1[v4] )
break;
v3 = (void *)v7;
}
return (void *)v7;
}

canonical_decompiled_code:
void *__fastcall func0(_QWORD *a1, char a2)
{
unsigned int v2; // er15
void *v3; // r12
__int64 v4; // rbx
void *v5; // rbp
__int64 v6; // rsi
__int64 v7; // r14
int v9; // [rsp+Ch] [rbp-3Ch]

v2 = a2;
v3 = (void *)ft_strdup(&unk_B7);
v9 = ft_countsplit(a1);
if ( !*a1 )
return v3;
v4 = 0LL;
while ( 1 )
{
v5 = (void *)((int)v4 > 0 && v9 > (int)v4 ? ft_strjoinc(v3, v2) : ft_strdup(&unk_B7));
v6 = a1[v4++];
v7 = ft_strjoin(v5, v6);
free(v3);
free(v5);
if ( !a1[v4] )
break;
v3 = (void *)v7;
}
return (void *)v7;
}

original_code:
char *ft_strglue(char **split, char glue)
{
 int i;
 int nb_split;
 char *out;
 char *tmp;
 char *tmp2;
 i = 0;
 out = ft_strdup("");
 nb_split = ft_countsplit(split);
 while (split[i])
 {
  tmp = (i > 0 && i < nb_split ? ft_strjoinc(out, glue) : ft_strdup(""));
  tmp2 = ft_strjoin(tmp, split[i]);
  i++;
  free(out);
  free(tmp);
  out = tmp2;
 }
 return (out);
}

variable_types:
split
char **

variable_types: glue char

variable_types:
out
char *

variable_types:
tmp
char *


decompiled_code:
ssize_t __fastcall ft_putstrendl(void *buf)
{
__int64 v1; // rax
size_t v2; // rdx

if ( *(_BYTE *)buf )
{
v1 = 1LL;
do
v2 = v1++;
while ( *((char *)buf + v1 - 1) );
}
else
{
v2 = 0LL;
}
write(1, buf, v2);
return write(1, &unk_56, 1uLL);
}

canonical_decompiled_code:
ssize_t __fastcall func0(void *buf)
{
__int64 v1; // rax
size_t v2; // rdx

if ( *(_BYTE *)buf )
{
v1 = 1LL;
do
v2 = v1++;
while ( *((char *)buf + v1 - 1) );
}
else
{
v2 = 0LL;
}
write(1, buf, v2);
return write(1, &unk_56, 1uLL);
}

original_code:
void ft_putstrendl(char const *c)
{
 int i;
 i = 0;
 while (c[i] != '\0')
  i++;
 write(1, c, i);
 write(1, "\n", 1);
}

canonical_original_code:
void ft_putstrendl(char *c)
{
 int i;
 i = 0;
 while (c[i] != '\0')
  i++;
 write(1, c, i);
 write(1, "\n", 1);
}

variable_types:
c
char *

variable_types: i int


decompiled_code:
float *__fastcall matrix_sub_by_val(float *a1, float a2)
{
float *v2; // rax
double v3; // xmm3_8
float *v4; // r12
float v5; // xmm1_4
float v6; // xmm2_4
float v7; // xmm0_4
float *result; // rax

v2 = (float *)malloc(0x10uLL);
*(_QWORD *)&v3 = *(unsigned int *)a1;
v4 = v2;
*(float *)&v3 = *(float *)&v3 - a2;
v5 = a1[1] - a2;
v6 = a1[2] - a2;
*v2 = *(float *)&v3;
v2[1] = v5;
v2[2] = v6;
v7 = find_magnitude(v3);
result = v4;
v4[3] = v7;
return result;
}

canonical_decompiled_code:
float *__fastcall func0(float *a1, float a2)
{
float *v2; // rax
double v3; // xmm3_8
float *v4; // r12
float v5; // xmm1_4
float v6; // xmm2_4
float v7; // xmm0_4
float *result; // rax

v2 = (float *)malloc(0x10uLL);
*(_QWORD *)&v3 = *(unsigned int *)a1;
v4 = v2;
*(float *)&v3 = *(float *)&v3 - a2;
v5 = a1[1] - a2;
v6 = a1[2] - a2;
*v2 = *(float *)&v3;
v2[1] = v5;
v2[2] = v6;
v7 = find_magnitude(v3);
result = v4;
v4[3] = v7;
return result;
}

original_code:
t_vect *matrix_sub_by_val(t_vect *m1, t_type f)
{
 t_vect *m2;
 m2 = (t_vect*)malloc(sizeof(t_vect));
 m2->x = m1->x - f;
 m2->y = m1->y - f;
 m2->z = m1->z - f;
 m2->l = find_magnitude(m2->x, m2->y, m2->z);
 return (m2);
}

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

variable_types: f float

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


decompiled_code:
__int64 __fastcall expose_hook(_QWORD *a1)
{
calc_rays(a1[1], *a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
calc_rays(a1[1], *a1);
return 0LL;
}

original_code:
int expose_hook(t_all *all)
{
 calc_rays(all->cam, all->lst);
 return (0);
}

canonical_original_code:
int expose_hook(struct s_all *all)
{
 calc_rays(all->cam, all->lst);
 return (0);
}

variable_types: struct s_all { 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; } *lst; 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; } *cam; struct s_mlx { void *mlx; void *win; } *mlx; } *

user_defined_types: struct s_all { struct s_obj *lst; struct s_cam *cam; struct s_mlx *mlx; }


decompiled_code:
__int64 __fastcall ft_strtrim(_BYTE *a1)
{
__int64 v1; // rax
_BYTE *v2; // rax
_BYTE *v3; // rax
_BYTE *v4; // rax
__int64 v5; // r12
__int64 result; // rax

v1 = ft_strlen();
if ( ft_strnew(v1 + 1)
&& (v2 = ft_afterwhites(a1),
v3 = (_BYTE *)ft_strrev(v2),
v4 = ft_afterwhites(v3),
v5 = ft_strrev(v4),
(unsigned int)ft_strcmp(v5, &unk_A0)) )
{
result = v5;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
__int64 v1; // rax
_BYTE *v2; // rax
_BYTE *v3; // rax
_BYTE *v4; // rax
__int64 v5; // r12
__int64 result; // rax

v1 = ft_strlen();
if ( ft_strnew(v1 + 1)
&& (v2 = ft_afterwhites(a1),
v3 = (_BYTE *)ft_strrev(v2),
v4 = ft_afterwhites(v3),
v5 = ft_strrev(v4),
(unsigned int)ft_strcmp(v5, &unk_A0)) )
{
result = v5;
}
else
{
result = 0LL;
}
return result;
}

original_code:
char *ft_strtrim(char const *s)
{
 char *ret;
 ret = ft_strnew(ft_strlen(s) + 1);
 if (!ret)
  return (((void *)0));
 ret = (char *) s;
 ret = ft_afterwhites(ret);
 ret = ft_strrev(ret);
 ret = ft_afterwhites(ret);
 ret = ft_strrev(ret);
 if (ft_strcmp(ret, "") == 0)
  return (((void *)0));
 return (ret);
}

canonical_original_code:
char *ft_strtrim(char *s)
{
 char *ret;
 ret = ft_strnew(ft_strlen(s) + 1);
 if (!ret)
  return (((void *)0));
 ret = (char *) s;
 ret = ft_afterwhites(ret);
 ret = ft_strrev(ret);
 ret = ft_afterwhites(ret);
 ret = ft_strrev(ret);
 if (ft_strcmp(ret, "") == 0)
  return (((void *)0));
 return (ret);
}

variable_types:
ret
char *


decompiled_code:
__int64 __fastcall lex_error(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx

v3 = a3;
ft_putstr_fd("Error at line ", 2LL);
ft_putnbr_fd(a2, 2LL);
ft_putstr_fd(" : ", 2LL);
ft_putstr_fd(*(_QWORD *)(a1 + 8 * v3), 2LL);
ft_putendl_fd(" is sooooooooooooooooo wrong.", 2LL);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx

v3 = a3;
ft_putstr_fd("Error at line ", 2LL);
ft_putnbr_fd(a2, 2LL);
ft_putstr_fd(" : ", 2LL);
ft_putstr_fd(*(_QWORD *)(a1 + 8 * v3), 2LL);
ft_putendl_fd(" is sooooooooooooooooo wrong.", 2LL);
return 0xFFFFFFFFLL;
}

original_code:
int lex_error(char **tab, int i, int j)
{
 ft_putstr_fd("Error at line ", 2);
 ft_putnbr_fd(i, 2);
 ft_putstr_fd(" : ", 2);
 ft_putstr_fd(tab[j], 2);
 ft_putendl_fd(" is sooooooooooooooooo wrong.", 2);
 return (-1);
}

variable_types:
tab
char **

variable_types: j int


decompiled_code:
ssize_t __fastcall ft_putchar_fd(char a1, int a2)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
return write(a2, buf, 1uLL);
}

canonical_decompiled_code:
ssize_t __fastcall func0(char a1, int a2)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
return write(a2, buf, 1uLL);
}

original_code:
void ft_putchar_fd(char c, int fd)
{
 write(fd, &c, 1);
}

variable_types: c char

variable_types: fd int


original_code:
t_list *ft_lst_push_back(t_list *lnk, t_list *new)
{
 t_list *save;
 save = lnk;
 if (lnk == ((void *)0))
  return (new);
 while (lnk->next != ((void *)0))
 {
  lnk = lnk->next;
 }
 lnk->next = new;
 return (save);
}

canonical_original_code:
struct s_list *ft_lst_push_back(struct s_list *lnk, struct s_list *new)
{
 struct s_list *save;
 save = lnk;
 if (lnk == ((void *)0))
  return (new);
 while (lnk->next != ((void *)0))
 {
  lnk = lnk->next;
 }
 lnk->next = new;
 return (save);
}

variable_types:
lnk
struct s_list *

variable_types:
new
struct s_list *

variable_types: struct s_list { void *content; unsigned long content_size; struct s_list *next; } *


decompiled_code:
__int64 __fastcall cmd_create(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rax
__int64 result; // rax

v1 = ft_memalloc(24LL);
if ( !v1 )
impossible_malloc("t_cmd in cmd_create");
v2 = ft_strdup(a1);
*(_QWORD *)(v1 + 16) = 0LL;
*(_QWORD *)v1 = v2;
result = v1;
*(_DWORD *)(v1 + 12) = -1;
return result;
}

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

v1 = ft_memalloc(24LL);
if ( !v1 )
impossible_malloc("t_cmd in cmd_create");
v2 = ft_strdup(a1);
*(_QWORD *)(v1 + 16) = 0LL;
*(_QWORD *)v1 = v2;
result = v1;
*(_DWORD *)(v1 + 12) = -1;
return result;
}

original_code:
t_cmd *cmd_create(char *name)
{
 t_cmd *out;
 if ((out = (t_cmd *)ft_memalloc(sizeof(t_cmd))) == ((void *)0))
  impossible_malloc("t_cmd in cmd_create");
 out->cmd = ft_strdup(name);
 out->next = ((void *)0);
 out->size = -1;
 return (out);
}

canonical_original_code:
struct s_cmd *cmd_create(char *name)
{
 struct s_cmd *out;
 if ((out = (struct s_cmd *)ft_memalloc(sizeof(t_cmd))) == ((void *)0))
  impossible_malloc("t_cmd in cmd_create");
 out->cmd = ft_strdup(name);
 out->next = ((void *)0);
 out->size = -1;
 return (out);
}

variable_types:
name
char *

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


original_code:
int cmd_findsize(t_cmd *cmd, t_lexer **lexed)
{
 int out;
 out = 0;
 if (cmd->has_encoding == 1)
  out += 1;
 while (*lexed != ((void *)0) && (*lexed)->token != ENDOFLINE)
 {
  if (((*lexed)->token == DIR) || ((*lexed)->token == DIR_LAB))
   out += ((cmd->is_idx == 1) ? 2 : 4);
  else if ((*lexed)->token == OP)
   out += 1;
  else if (((*lexed)->token == IND) || ((*lexed)->token == IND_LAB))
   out += 2;
  else
   out += ((16 / 256) + 1);
  *lexed = (*lexed)->next;
 }
 return (out);
}

canonical_original_code:
int cmd_findsize(struct s_cmd *cmd, struct s_lexer **lexed)
{
 int out;
 out = 0;
 if (cmd->has_encoding == 1)
  out += 1;
 while (*lexed != ((void *)0) && (*lexed)->token != ENDOFLINE)
 {
  if (((*lexed)->token == DIR) || ((*lexed)->token == DIR_LAB))
   out += ((cmd->is_idx == 1) ? 2 : 4);
  else if ((*lexed)->token == OP)
   out += 1;
  else if (((*lexed)->token == IND) || ((*lexed)->token == IND_LAB))
   out += 2;
  else
   out += ((16 / 256) + 1);
  *lexed = (*lexed)->next;
 }
 return (out);
}

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; } **

variable_types: out int

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


decompiled_code:
__int64 __fastcall fill_buf(int fd, void **a2, char *a3)
{
unsigned int v4; // eax
__int64 v5; // rbx
__int64 v6; // rbx
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v10; // r12

while ( 1 )
{
LODWORD(result) = read(fd, a3, 0x5F5E100uLL);
if ( (int)result <= 0 )
return (unsigned int)result;
v4 = ft_strichr(a3, 10LL, v8, v9, (unsigned int)result);
v5 = (int)v4;
if ( v4 != -1 )
break;
v6 = ft_strjoin(*a2, a3);
free(*a2);
*a2 = (void *)v6;
}
v10 = ft_strnjoin(*a2, a3, v4);
free(*a2);
*a2 = (void *)v10;
ft_strcpy(a3, &a3[v5 + 1]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int fd, void **a2, char *a3)
{
unsigned int v4; // eax
__int64 v5; // rbx
__int64 v6; // rbx
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v10; // r12

while ( 1 )
{
LODWORD(result) = read(fd, a3, 0x5F5E100uLL);
if ( (int)result <= 0 )
return (unsigned int)result;
v4 = ft_strichr(a3, 10LL, v8, v9, (unsigned int)result);
v5 = (int)v4;
if ( v4 != -1 )
break;
v6 = ft_strjoin(*a2, a3);
free(*a2);
*a2 = (void *)v6;
}
v10 = ft_strnjoin(*a2, a3, v4);
free(*a2);
*a2 = (void *)v10;
ft_strcpy(a3, &a3[v5 + 1]);
return 1LL;
}

original_code:
static int fill_buf(int const fd, char **line, char *buf)
{
 int i;
 int res;
 char *tmp;
 while ((res = read(fd, buf, 100000000)) > 0)
 {
  if (res == -1)
   return (-1);
  i = ft_strichr(buf, '\n');
  if (i == -1)
  {
   tmp = ft_strjoin(*line, buf);
   free(*line);
   *line = tmp;
  }
  else
  {
   tmp = ft_strnjoin(*line, buf, i);
   free(*line);
   *line = tmp;
   ft_strcpy(buf, buf + i + 1);
   return (1);
  }
 }
 return (res);
}

canonical_original_code:
static int fill_buf(int fd, char **line, char *buf)
{
 int i;
 int res;
 char *tmp;
 while ((res = read(fd, buf, 100000000)) > 0)
 {
  if (res == -1)
   return (-1);
  i = ft_strichr(buf, '\n');
  if (i == -1)
  {
   tmp = ft_strjoin(*line, buf);
   free(*line);
   *line = tmp;
  }
  else
  {
   tmp = ft_strnjoin(*line, buf, i);
   free(*line);
   *line = tmp;
   ft_strcpy(buf, buf + i + 1);
   return (1);
  }
 }
 return (res);
}

variable_types:
line
char **

variable_types:
buf
char *

variable_types: res int

variable_types:
tmp
char *


decompiled_code:
int __fastcall append_file(char *file)
{
int result; // eax

if ( access(file, 0) )
{
result = open(file, 65, 420LL);
if ( result == -1 )
{
ft_error("{append_file} Unable to create this file");
result = -1;
}
}
else if ( access(file, 2) )
{
ft_error("{append_file} Access denied");
result = -1;
}
else
{
result = open(file, 1025);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(char *file)
{
int result; // eax

if ( access(file, 0) )
{
result = open(file, 65, 420LL);
if ( result == -1 )
{
ft_error("{append_file} Unable to create this file");
result = -1;
}
}
else if ( access(file, 2) )
{
ft_error("{append_file} Access denied");
result = -1;
}
else
{
result = open(file, 1025);
}
return result;
}

original_code:
int append_file(char *file)
{
 int fd;
 int retf;
 int retw;
 if ((retf = access(file, 0)) == 0)
 {
  if ((retw = access(file, 2)) == 0)
  {
   fd = open(file, 02000 | 01);
   return (fd);
  }
  else
  {
   ft_error("{append_file} Access denied");
   return (-1);
  }
 }
 if ((fd = open(file, 0100 | 01, 0644)) == -1)
 {
  ft_error("{append_file} Unable to create this file");
  return (-1);
 }
 return (fd);
}

variable_types:
file
char *

variable_types: retf int

variable_types: retw int


decompiled_code:
__int64 __fastcall exec_pipe_commands(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int pipedes[2]; // [rsp+8h] [rbp-30h] BYREF

if ( pipe(pipedes) != -1 )
{
if ( !fork() )
{
close(pipedes[0]);
dup2(pipedes[1], 1);
ft_execute(a4, a1, a3);
close(pipedes[1]);
exit(0);
}
wait(0LL);
close(pipedes[1]);
dup2(pipedes[0], 0);
ft_execute(a4, a2, a3);
close(pipedes[0]);
exit(0);
}
return ft_error("pipe error");
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int pipedes[2]; // [rsp+8h] [rbp-30h] BYREF

if ( pipe(pipedes) != -1 )
{
if ( !fork() )
{
close(pipedes[0]);
dup2(pipedes[1], 1);
ft_execute(a4, a1, a3);
close(pipedes[1]);
exit(0);
}
wait(0LL);
close(pipedes[1]);
dup2(pipedes[0], 0);
ft_execute(a4, a2, a3);
close(pipedes[0]);
exit(0);
}
return ft_error("pipe error");
}

original_code:
void exec_pipe_commands(char **cmd, char **cmd2, char ***env, char **path)
{
 int fd[2];
 if (pipe(fd) == -1)
 {
  ft_error("pipe error");
  return ;
 }
 if (!fork())
 {
  close(fd[0]);
  dup2(fd[1], 1);
  ft_execute(path, cmd, env);
  close(fd[1]);
  exit(0);
 }
 else
 {
  wait(0);
  close(fd[1]);
  dup2(fd[0], 0);
  ft_execute(path, cmd2, env);
  close(fd[0]);
 }
 exit(0);
}

variable_types:
cmd
char **

variable_types:
env
char ***

variable_types:
path
char **

variable_types:
fd
int [2]


decompiled_code:
_BOOL8 __fastcall ft_star(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // r12
__int64 v3; // rbp
char v4; // dl
char v5; // al
_BOOL8 result; // rax
int v7; // er8

v2 = a1;
v3 = a2 + 1;
v4 = *a1;
while ( 1 )
{
v5 = *(_BYTE *)(v3 - 1);
if ( v4 )
break;
if ( !v5 )
return 1LL;
if ( v5 != 42 )
return 0LL;
LABEL_5:
++v3;
}
if ( v5 != 42 )
{
if ( v4 != v5 )
return 0LL;
v4 = *++v2;
goto LABEL_5;
}
v7 = ft_star(v2 + 1, v3 - 1);
result = 1LL;
if ( !v7 )
result = (unsigned int)ft_star(v2, v3) != 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // r12
__int64 v3; // rbp
char v4; // dl
char v5; // al
_BOOL8 result; // rax
int v7; // er8

v2 = a1;
v3 = a2 + 1;
v4 = *a1;
while ( 1 )
{
v5 = *(_BYTE *)(v3 - 1);
if ( v4 )
break;
if ( !v5 )
return 1LL;
if ( v5 != 42 )
return 0LL;
LABEL_5:
++v3;
}
if ( v5 != 42 )
{
if ( v4 != v5 )
return 0LL;
v4 = *++v2;
goto LABEL_5;
}
v7 = func0(v2 + 1, v3 - 1);
result = 1LL;
if ( !v7 )
result = (unsigned int)func0(v2, v3) != 0;
return result;
}

original_code:
int ft_star(const char *s1, const char *s2)
{
 if (!*s1 && !*s2)
  return (1);
 else if (!*s1 && *s2 == '*')
  return (ft_star(s1, s2 + 1));
 else if (*s1 && *s2 == '*')
  return ((ft_star(s1 + 1, s2)) || (ft_star(s1, s2 + 1)));
 else if (*s1 == *s2)
  return (ft_star(s1 + 1, s2 + 1));
 return (0);
}


decompiled_code:
__int64 __fastcall ft_compare_cd_operation(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 v5; // rbx
__int64 result; // rax
__int64 v7[7]; // [rsp+10h] [rbp-38h]

v7[0] = (__int64)&ft_slash;
v7[1] = (__int64)&ft_dot;
v7[2] = (__int64)&ft_tild;
v7[3] = (__int64)&ft_other;
if ( a1 )
{
v5 = a4;
if ( (unsigned int)ft_strncmp(a1, *(_QWORD *)(a2 + 8LL * a4), 1LL) )
{
result = 1LL;
}
else
{
((void (__fastcall *)(__int64, __int64))v7[v5])(a3, a1);
result = 0LL;
}
}
else
{
ft_null(a3, 0LL);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 v5; // rbx
__int64 result; // rax
__int64 v7[7]; // [rsp+10h] [rbp-38h]

v7[0] = (__int64)&ft_slash;
v7[1] = (__int64)&ft_dot;
v7[2] = (__int64)&ft_tild;
v7[3] = (__int64)&ft_other;
if ( a1 )
{
v5 = a4;
if ( (unsigned int)ft_strncmp(a1, *(_QWORD *)(a2 + 8LL * a4), 1LL) )
{
result = 1LL;
}
else
{
((void (__fastcall *)(__int64, __int64))v7[v5])(a3, a1);
result = 0LL;
}
}
else
{
ft_null(a3, 0LL);
result = 0LL;
}
return result;
}

original_code:
int ft_compare_cd_operation(char *arg, char **lib_cd, char ***env, int j)
{
 int k;
 t_cd *cd[4] = {ft_slash, ft_dot, ft_tild, ft_other};
 k = 1;
 if (arg == ((void *)0))
 {
  ft_null(env, arg);
  k--;
 }
 else
 {
  if (ft_strncmp(arg, lib_cd[j], 1) == 0)
  {
   cd[j](env, arg);
   k--;
  }
 }
 return (k);
}

canonical_original_code:
int ft_compare_cd_operation(char *arg, char **lib_cd, char ***env, int j)
{
 int k;
 void (*cd[4])(char ***, char *) = {ft_slash, ft_dot, ft_tild, ft_other};
 k = 1;
 if (arg == ((void *)0))
 {
  ft_null(env, arg);
  k--;
 }
 else
 {
  if (ft_strncmp(arg, lib_cd[j], 1) == 0)
  {
   cd[j](env, arg);
   k--;
  }
 }
 return (k);
}

variable_types:
arg
char *

variable_types: j int

variable_types: k int

variable_types:
cd
void (*[4])(char ***, char *)


decompiled_code:
void __fastcall for_a_better_setenv(__int64 a1, _QWORD *a2, int a3)
{
__int64 v3; // r13
void *v4; // r12
__int64 v5; // rax
_QWORD *v6; // r13
void *v7; // rbp

v3 = 8LL * a3;
free(*(void **)(*a2 + v3));
v4 = (void *)ft_strjoin(&unk_9A, *(_QWORD *)(a1 + 16));
v5 = ft_strjoin(*(_QWORD *)(a1 + 8), v4);
v6 = (_QWORD *)(*a2 + v3);
v7 = (void *)v5;
*v6 = ft_strdup(v5);
free(v4);
free(v7);
}

original_code:
void for_a_better_setenv(char **arg, char ***env, int i)
{
 char *tmp;
 char *tmp2;
 free((*env)[i]);
 tmp = ft_strjoin("=", arg[2]);
 tmp2 = ft_strjoin(arg[1], tmp);
 (*env)[i] = ft_strdup(tmp2);
 free(tmp);
 free(tmp2);
}

variable_types:
arg
char **

variable_types: i int


decompiled_code:
void __fastcall for_a_better_other(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void for_a_better_other(char **cmd)
{
 free(cmd[1]);
 free(cmd[2]);
 free(cmd[3]);
 free(cmd);
}


original_code:
void f_xor(t_dat *dat, t_proc *proc)
{
 long params[3];
 long res;
 short tp[2];
 t_uc *dest;
 get_params(dat, proc, params, 4);
 tp[0] = ((proc->params >> (3 * 2)) % 4);
 tp[1] = ((proc->params >> ((3 - 1) * 2)) % 4);
 if (isreg(params[2]))
 {
  if (tp[0] == 1 && isreg(params[0]))
   params[0] = get_val(proc->reg + ((params[0] - 1) * 4), 0, 4);
  if (tp[1] == 1 && isreg(params[1]))
   params[1] = get_val(proc->reg + ((params[1] - 1) * 4), 0, 4);
  res = params[0] ^ params[1];
  if (dat->verbose)
   handle_verbose(params);
  dest = proc->reg + ((params[2] * 4) - 1);
  write_long_to_mem(res, dest, 4);
  proc->carry = (res == 0 ? 1 : 0);
 }
 move_pc(proc, 4);
}

canonical_original_code:
void f_xor(struct s_dat *dat, struct s_proc *proc)
{
 long params[3];
 long res;
 short tp[2];
 unsigned char *dest;
 get_params(dat, proc, params, 4);
 tp[0] = ((proc->params >> (3 * 2)) % 4);
 tp[1] = ((proc->params >> ((3 - 1) * 2)) % 4);
 if (isreg(params[2]))
 {
  if (tp[0] == 1 && isreg(params[0]))
   params[0] = get_val(proc->reg + ((params[0] - 1) * 4), 0, 4);
  if (tp[1] == 1 && isreg(params[1]))
   params[1] = get_val(proc->reg + ((params[1] - 1) * 4), 0, 4);
  res = params[0] ^ params[1];
  if (dat->verbose)
   handle_verbose(params);
  dest = proc->reg + ((params[2] * 4) - 1);
  write_long_to_mem(res, dest, 4);
  proc->carry = (res == 0 ? 1 : 0);
 }
 move_pc(proc, 4);
}

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:
proc
struct s_proc *

variable_types:
params
long [3]

variable_types: res long

variable_types:
tp
short [2]

variable_types:
dest
unsigned char *


decompiled_code:
__int64 __fastcall handle_verbose(_QWORD *a1)
{
return ft_printf("xor: value %ld | value %ld -> reg%ld\n", *a1, a1[1], a1[2]);
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
return ft_printf("xor: value %ld | value %ld -> reg%ld\n", *a1, a1[1], a1[2]);
}

original_code:
static void handle_verbose(long params[3])
{
 ft_printf("xor: value %ld | value %ld -> reg%ld\n" , params[0], params[1], params[2]);
}


decompiled_code:
__int64 __fastcall build_color(int a1, int a2, int a3)
{
return (unsigned int)((a2 << 8) + (a1 << 16) + a3);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2, int a3)
{
return (unsigned int)((a2 << 8) + (a1 << 16) + a3);
}

original_code:
int build_color(int r, int g, int b)
{
 int color;
 color = 0;
 color = (0 << 24) + (r << 16) + (g << 8) + b;
 return (color);
}

variable_types: r int

variable_types: g int

variable_types: b int

variable_types: color int


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

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

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

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

original_code:
t_params *ft_build_params_struct(t_params *p)
{
 p = (t_params*)malloc(sizeof(t_params));
 p->l = 0;
 p->a = 0;
 p->r = 0;
 p->R = 0;
 p->t = 0;
 p->round = 0;
 return (p);
}

canonical_original_code:
struct s_list4 *ft_build_params_struct(struct s_list4 *p)
{
 p = (struct s_list4 *)malloc(sizeof(t_params));
 p->l = 0;
 p->a = 0;
 p->r = 0;
 p->R = 0;
 p->t = 0;
 p->round = 0;
 return (p);
}

variable_types:
p
struct s_list4 *

return_type: struct s_list4 { int l; int a; int r; int R; int t; int round; } *


decompiled_code:
__int64 __fastcall ft_test_type(__int64 a1, int *a2, unsigned int a3)
{
__int64 v5; // rax
const char *i; // rdi
struct stat v8; // [rsp+0h] [rbp-138h] BYREF
struct stat v9; // [rsp+90h] [rbp-A8h] BYREF

v5 = *a2;
for ( i = *(const char **)(a1 + 8 * v5); i; i = *(const char **)(a1 + 8LL * (int)v5) )
{
if ( !*(_QWORD *)(a1 + 8 * v5 + 8) )
break;
stat(i, &v8);
stat(*(const char **)(a1 + 8LL * *a2 + 8), &v9);
if ( (unsigned __int8)((v8.st_mode & 0xF000) == 0x8000) < (unsigned __int8)((v9.st_mode & 0xF000) == 0x8000) )
{
a3 = 1;
ft_switch_elem((__int64 *)(a1 + 8LL * *a2), (__int64 *)(a1 + 8LL * *a2 + 8));
}
LODWORD(v5) = *a2 + 1;
*a2 = v5;
v5 = (int)v5;
}
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int *a2, unsigned int a3)
{
__int64 v5; // rax
const char *i; // rdi
struct stat v8; // [rsp+0h] [rbp-138h] BYREF
struct stat v9; // [rsp+90h] [rbp-A8h] BYREF

v5 = *a2;
for ( i = *(const char **)(a1 + 8 * v5); i; i = *(const char **)(a1 + 8LL * (int)v5) )
{
if ( !*(_QWORD *)(a1 + 8 * v5 + 8) )
break;
stat(i, &v8);
stat(*(const char **)(a1 + 8LL * *a2 + 8), &v9);
if ( (unsigned __int8)((v8.st_mode & 0xF000) == 0x8000) < (unsigned __int8)((v9.st_mode & 0xF000) == 0x8000) )
{
a3 = 1;
func2((__int64 *)(a1 + 8LL * *a2), (__int64 *)(a1 + 8LL * *a2 + 8));
}
LODWORD(v5) = *a2 + 1;
*a2 = v5;
v5 = (int)v5;
}
return a3;
}

original_code:
int ft_test_type(char **argv, int *i, int cnt)
{
 t_stat stats;
 t_stat stats2;
 while (argv[*i] && argv[*i + 1])
 {
  stat(argv[*i], &stats);
  stat(argv[*i + 1], &stats2);
  if (((((stats.st_mode)) & 0170000) == (0100000)) < ((((stats2.st_mode)) & 0170000) == (0100000)))
  {
   ft_switch_elem(&argv[*i], &argv[*i + 1]);
   cnt = 1;
  }
  *i += 1;
 }
 return (cnt);
}

canonical_original_code:
int ft_test_type(char **argv, int *i, int cnt)
{
 struct stat stats;
 struct stat stats2;
 while (argv[*i] && argv[*i + 1])
 {
  stat(argv[*i], &stats);
  stat(argv[*i + 1], &stats2);
  if (((((stats.st_mode)) & 0170000) == (0100000)) < ((((stats2.st_mode)) & 0170000) == (0100000)))
  {
   ft_switch_elem(&argv[*i], &argv[*i + 1]);
   cnt = 1;
  }
  *i += 1;
 }
 return (cnt);
}

variable_types:
argv
char **

variable_types:
i
int *

variable_types: cnt int

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


original_code:
void f_ldi_exec(t_dat *dat, t_proc *proc, short type[2], long vals[3])
{
 type[0] = (type[0] == 2 ? 2 : 4);
 type[1] = (type[1] == 2 ? 2 : 4);
 vals[0] = get_true_val(vals[0], 0, type[0]);
 vals[1] = get_true_val(vals[1], 0, type[1]);
 vals[0] = (vals[0] + vals[1]) % (4*1024);
 vals[0] = get_val(dat->arena, proc->pc + vals[0], 4);
 if (dat->verbose)
  ft_printf("ldi: value %d -> reg%ld\n", (int)vals[0], vals[2]);
 write_long_to_mem(vals[0], proc->reg + (vals[2] * 4) - 1, 4);
}

canonical_original_code:
void f_ldi_exec(struct s_dat *dat, struct s_proc *proc, short type[2], long vals[3])
{
 type[0] = (type[0] == 2 ? 2 : 4);
 type[1] = (type[1] == 2 ? 2 : 4);
 vals[0] = get_true_val(vals[0], 0, type[0]);
 vals[1] = get_true_val(vals[1], 0, type[1]);
 vals[0] = (vals[0] + vals[1]) % (4*1024);
 vals[0] = get_val(dat->arena, proc->pc + vals[0], 4);
 if (dat->verbose)
  ft_printf("ldi: value %d -> reg%ld\n", (int)vals[0], vals[2]);
 write_long_to_mem(vals[0], proc->reg + (vals[2] * 4) - 1, 4);
}

variable_types:
type
short [2]

variable_types:
vals
long [3]


original_code:
void f_ldi(t_dat *dat, t_proc *proc)
{
 long vals[3];
 short type[2];
 int err;
 err = 0;
 type[0] = ((proc->params >> 6) % 4);
 type[1] = ((proc->params >> 4) % 4);
 get_params(dat, proc, vals, 2);
 if (vals[2] > 0 && vals[2] <= 16)
 {
  if (type[0] == 1 && vals[0] > 0 && vals[0] <= 16)
   vals[0] = get_val(proc->reg + ((vals[0] - 1) * 4), 0, 4);
  else if (type[0] == 1)
   err = 1;
  if (type[1] == 1 && vals[1] > 0 && vals[1] <= 16)
   vals[1] = get_val(proc->reg + ((vals[1] - 1) * 4), 0, 4);
  else if (type[1] == 1)
   err = 1;
  if (!err)
   f_ldi_exec(dat, proc, type, vals);
 }
 move_pc(proc, 2);
}

canonical_original_code:
void f_ldi(struct s_dat *dat, struct s_proc *proc)
{
 long vals[3];
 short type[2];
 int err;
 err = 0;
 type[0] = ((proc->params >> 6) % 4);
 type[1] = ((proc->params >> 4) % 4);
 get_params(dat, proc, vals, 2);
 if (vals[2] > 0 && vals[2] <= 16)
 {
  if (type[0] == 1 && vals[0] > 0 && vals[0] <= 16)
   vals[0] = get_val(proc->reg + ((vals[0] - 1) * 4), 0, 4);
  else if (type[0] == 1)
   err = 1;
  if (type[1] == 1 && vals[1] > 0 && vals[1] <= 16)
   vals[1] = get_val(proc->reg + ((vals[1] - 1) * 4), 0, 4);
  else if (type[1] == 1)
   err = 1;
  if (!err)
   f_ldi_exec(dat, proc, type, vals);
 }
 move_pc(proc, 2);
}

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: err int


decompiled_code:
__int64 __fastcall ft_to_get_under_25_lines_1(_DWORD *a1)
{
__int64 result; // rax
char *v2; // rax

for ( result = (unsigned int)*a1; (int)result > 0; *a1 = result )
{
v2 = tgetstr("le", 0LL);
tputs(v2, 1, (int (*)(int))&out);
result = (unsigned int)(*a1 - 1);
}
return result;
}

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

for ( result = (unsigned int)*a1; (int)result > 0; *a1 = result )
{
v2 = tgetstr("le", 0LL);
tputs(v2, 1, (int (*)(int))&out);
result = (unsigned int)(*a1 - 1);
}
return result;
}

original_code:
void ft_to_get_under_25_lines_1(t_print *print)
{
 while (print->pos > 0)
 {
  tputs(tgetstr("le", ((void *)0)), 1, out);
  print->pos -= 1;
 }
}

canonical_original_code:
void ft_to_get_under_25_lines_1(struct s_print *print)
{
 while (print->pos > 0)
 {
  tputs(tgetstr("le", ((void *)0)), 1, out);
  print->pos -= 1;
 }
}

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:
void __fastcall ft_to_get_under_25_lines_2(int *a1, int a2, int a3)
{
int v3; // ebp
char *v4; // rax
int v5; // eax

v3 = a2 + a3;
if ( *a1 < a2 + a3 )
{
do
{
v4 = tgetstr("nd", 0LL);
tputs(v4, 1, (int (*)(int))&out);
v5 = *a1 - 1;
*a1 = v5;
}
while ( v5 < v3 );
}
}

canonical_decompiled_code:
void __fastcall func1(int *a1, int a2, int a3)
{
int v3; // ebp
char *v4; // rax
int v5; // eax

v3 = a2 + a3;
if ( *a1 < a2 + a3 )
{
do
{
v4 = tgetstr("nd", 0LL);
tputs(v4, 1, (int (*)(int))&out);
v5 = *a1 - 1;
*a1 = v5;
}
while ( v5 < v3 );
}
}

original_code:
void ft_to_get_under_25_lines_2(t_print *print, int i, int j)
{
 while (print->pos < (i + j))
    {
        tputs(tgetstr("nd", ((void *)0)), 1, out);
        print->pos -= 1;
    }
}

canonical_original_code:
void ft_to_get_under_25_lines_2(struct s_print *print, int i, int j)
{
 while (print->pos < (i + j))
    {
        tputs(tgetstr("nd", ((void *)0)), 1, out);
        print->pos -= 1;
    }
}

variable_types: i int

variable_types: j int

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


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

v2 = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + 1), 4LL);
result = *(_QWORD *)(a1 + 4104);
++*(_DWORD *)(a2 + 80);
if ( result )
{
while ( *(_DWORD *)(result + 16) != v2 )
{
result = *(_QWORD *)(result + 24);
if ( !result )
goto LABEL_6;
}
result = ft_printf("un processus dit que le joueur %d(%s) est en vie\n", v2, *(const char **)(result + 8));
*(_DWORD *)(a1 + 4132) = v2;
}
LABEL_6:
*(_DWORD *)(a2 + 64) += 5;
return result;
}

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

v2 = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + 1), 4LL);
result = *(_QWORD *)(a1 + 4104);
++*(_DWORD *)(a2 + 80);
if ( result )
{
while ( *(_DWORD *)(result + 16) != v2 )
{
result = *(_QWORD *)(result + 24);
if ( !result )
goto LABEL_6;
}
result = ft_printf("un processus dit que le joueur %d(%s) est en vie\n", v2, *(const char **)(result + 8));
*(_DWORD *)(a1 + 4132) = v2;
}
LABEL_6:
*(_DWORD *)(a2 + 64) += 5;
return result;
}

original_code:
void f_live(t_dat *dat, t_proc *proc)
{
 long i;
 t_hero *save;
 i = get_val(dat->arena, proc->pc + 1, 4);
 save = dat->hero_lst;
 proc->nbr_live += 1;
 while (save != ((void *)0))
 {
  if (save->hero_num == (int)i)
  {
   ft_printf("un processus dit que le joueur %d(%s) est en vie\n", save->hero_num, save->name);
   dat->last_player_alive = (int)i;
   break ;
  }
  save = save->next;
 }
 proc->pc += 5;
}

canonical_original_code:
void f_live(struct s_dat *dat, struct s_proc *proc)
{
 long i;
 struct s_hero *save;
 i = get_val(dat->arena, proc->pc + 1, 4);
 save = dat->hero_lst;
 proc->nbr_live += 1;
 while (save != ((void *)0))
 {
  if (save->hero_num == (int)i)
  {
   ft_printf("un processus dit que le joueur %d(%s) est en vie\n", save->hero_num, save->name);
   dat->last_player_alive = (int)i;
   break ;
  }
  save = save->next;
 }
 proc->pc += 5;
}

variable_types:
proc
struct s_proc *

variable_types: i long

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


decompiled_code:
ssize_t __fastcall ft_putqstr(void *buf)
{
__int64 v1; // rax
size_t v2; // rdx

if ( !*(_BYTE *)buf )
return write(1, buf, 0LL);
v1 = 1LL;
do
v2 = v1++;
while ( *((char *)buf + v1 - 1) );
return write(1, buf, v2);
}

canonical_decompiled_code:
ssize_t __fastcall func0(void *buf)
{
__int64 v1; // rax
size_t v2; // rdx

if ( !*(_BYTE *)buf )
return write(1, buf, 0LL);
v1 = 1LL;
do
v2 = v1++;
while ( *((char *)buf + v1 - 1) );
return write(1, buf, v2);
}

original_code:
void ft_putqstr(const char *s)
{
 int i;
 i = 0;
 while (s[i] != '\0')
  i++;
 write(1, s, i);
}

canonical_original_code:
void ft_putqstr(char *s)
{
 int i;
 i = 0;
 while (s[i] != '\0')
  i++;
 write(1, s, i);
}

variable_types:
s
char *


decompiled_code:
__int64 __fastcall ft_memccpy(__int64 a1, __int64 a2, unsigned __int8 a3, __int64 a4)
{
__int64 v5; // rax
int v6; // esi
int v7; // edx

v5 = 0LL;
v6 = a3;
if ( !a4 )
return 0LL;
while ( 1 )
{
v7 = *(char *)(a2 + v5);
*(_BYTE *)(a1 + v5) = *(_BYTE *)(a2 + v5);
if ( v7 == v6 )
break;
if ( a4 == ++v5 )
return 0LL;
}
return a1 + v5 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, unsigned __int8 a3, __int64 a4)
{
__int64 v5; // rax
int v6; // esi
int v7; // edx

v5 = 0LL;
v6 = a3;
if ( !a4 )
return 0LL;
while ( 1 )
{
v7 = *(char *)(a2 + v5);
*(_BYTE *)(a1 + v5) = *(_BYTE *)(a2 + v5);
if ( v7 == v6 )
break;
if ( a4 == ++v5 )
return 0LL;
}
return a1 + v5 + 1;
}

original_code:
void *ft_memccpy(void *s1, const void *s2, int c, size_t n)
{
 unsigned char ch;
 int i;
 char *tmp;
 char *tmp2;
 i = 0;
 tmp = (char*)s1;
 tmp2 = (char*)s2;
 ch = (unsigned char)c;
 while (i < n)
 {
  tmp[i] = tmp2[i];
  if (tmp2[i] == ch)
   return (s1 + i + 1);
  i++;
 }
 return (((void *)0));
}

canonical_original_code:
void *ft_memccpy(void *s1, void *s2, int c, unsigned long n)
{
 unsigned char ch;
 int i;
 char *tmp;
 char *tmp2;
 i = 0;
 tmp = (char *)s1;
 tmp2 = (char *)s2;
 ch = (unsigned char)c;
 while (i < n)
 {
  tmp[i] = tmp2[i];
  if (tmp2[i] == ch)
   return (s1 + i + 1);
  i++;
 }
 return (((void *)0));
}

variable_types: c int

variable_types:
n
unsigned long

variable_types:
ch
unsigned char

variable_types:
tmp
char *


decompiled_code:
void __fastcall ft_memdel(void **a1)
{
free(*a1);
*a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func0(void **a1)
{
free(*a1);
*a1 = 0LL;
}

original_code:
void ft_memdel(void **ap)
{
 free(*ap);
 *ap = ((void *)0);
}

variable_types:
ap
void **


decompiled_code:
__int64 __fastcall ft_toupper(unsigned int a1)
{
__int64 result; // rax

result = a1;
if ( a1 - 97 < 0x1A )
result = a1 - 32;
return result;
}

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

result = a1;
if ( a1 - 97 < 0x1A )
result = a1 - 32;
return result;
}

original_code:
int ft_toupper(int c)
{
 if (c >= 97 && c <= 122)
  c -= 32;
 return (c);
}


decompiled_code:
__int64 __fastcall ft_place_zeros(__int64 a1, __int64 a2, int a3)
{
int v3; // ebx
__int64 result; // rax

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v3 = a3;
do
{
++v3;
result = ft_putchar(48LL);
++*(_QWORD *)(a2 + 24);
}
while ( *(_DWORD *)(a1 + 20) > v3 );
}
return result;
}

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

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v3 = a3;
do
{
++v3;
result = ft_putchar(48LL);
++*(_QWORD *)(a2 + 24);
}
while ( *(_DWORD *)(a1 + 20) > v3 );
}
return result;
}

original_code:
void ft_place_zeros(t_op *op, t_arg *lnk, int l)
{
 if (l < op->min_width)
 {
  while (l < op->min_width)
  {
   ft_putchar('0');
   lnk->ps += 1;
   l++;
  }
 }
}

canonical_original_code:
void ft_place_zeros(struct s_option *op, struct s_arg *lnk, int l)
{
 if (l < op->min_width)
 {
  while (l < op->min_width)
  {
   ft_putchar('0');
   lnk->ps += 1;
   l++;
  }
 }
}

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; } *

variable_types: l int


decompiled_code:
__int64 __fastcall ft_place_spaces(__int64 a1, __int64 a2, int a3)
{
int v3; // ebx
__int64 result; // rax

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v3 = a3;
do
{
++v3;
result = ft_putchar(32LL);
++*(_QWORD *)(a2 + 24);
}
while ( *(_DWORD *)(a1 + 20) > v3 );
}
return result;
}

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

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v3 = a3;
do
{
++v3;
result = ft_putchar(32LL);
++*(_QWORD *)(a2 + 24);
}
while ( *(_DWORD *)(a1 + 20) > v3 );
}
return result;
}

original_code:
void ft_place_spaces(t_op *op, t_arg *lnk, int l)
{
 if (l < op->min_width)
 {
  while (l < op->min_width)
  {
   ft_putchar(' ');
   lnk->ps += 1;
   l++;
  }
 }
}

canonical_original_code:
void ft_place_spaces(struct s_option *op, struct s_arg *lnk, int l)
{
 if (l < op->min_width)
 {
  while (l < op->min_width)
  {
   ft_putchar(' ');
   lnk->ps += 1;
   l++;
  }
 }
}

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


original_code:
void f_add(t_dat *dat, t_proc *proc)
{
 long i;
 long j;
 long k;
 i = (int)get_val(dat->arena, proc->pc + 2, ((16 / 256) + 1));
 j = (int)get_val(dat->arena, proc->pc + 3, ((16 / 256) + 1));
 k = (int)get_val(dat->arena, proc->pc + 4, ((16 / 256) + 1));
 if (i > 0 && i <= 16 && j > 0 && j <= 16)
 {
  if (k > 0 && k <= 16)
  {
   i = (int)get_val(proc->reg + ((i - 1) * 4), 0, 4);
   j = (int)get_val(proc->reg + ((j - 1) * 4), 0, 4);
   if (dat->verbose)
    ft_printf("add: value %ld + value %ld -> reg%ld\n", i, j, k);
   i = i + j;
   write_long_to_mem(i, (proc->reg + ((k * 4) - 1)), 4);
   proc->carry = (i == 0 ? 1 : 0);
  }
 }
 move_pc(proc, 4);
}

canonical_original_code:
void f_add(struct s_dat *dat, struct s_proc *proc)
{
 long i;
 long j;
 long k;
 i = (int)get_val(dat->arena, proc->pc + 2, ((16 / 256) + 1));
 j = (int)get_val(dat->arena, proc->pc + 3, ((16 / 256) + 1));
 k = (int)get_val(dat->arena, proc->pc + 4, ((16 / 256) + 1));
 if (i > 0 && i <= 16 && j > 0 && j <= 16)
 {
  if (k > 0 && k <= 16)
  {
   i = (int)get_val(proc->reg + ((i - 1) * 4), 0, 4);
   j = (int)get_val(proc->reg + ((j - 1) * 4), 0, 4);
   if (dat->verbose)
    ft_printf("add: value %ld + value %ld -> reg%ld\n", i, j, k);
   i = i + j;
   write_long_to_mem(i, (proc->reg + ((k * 4) - 1)), 4);
   proc->carry = (i == 0 ? 1 : 0);
  }
 }
 move_pc(proc, 4);
}

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: j long

variable_types: k long


decompiled_code:
__int64 __fastcall ft_power(int a1)
{
__int64 result; // rax
int v2; // edx

if ( !a1 )
return 1LL;
if ( a1 == 1 )
return 10LL;
LODWORD(result) = 1;
while ( 1 )
{
v2 = result;
result = (unsigned int)(10 * result);
if ( !--a1 )
break;
if ( a1 == 1 )
return (unsigned int)(100 * v2);
}
return result;
}

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

if ( !a1 )
return 1LL;
if ( a1 == 1 )
return 10LL;
LODWORD(result) = 1;
while ( 1 )
{
v2 = result;
result = (unsigned int)(10 * result);
if ( !--a1 )
break;
if ( a1 == 1 )
return (unsigned int)(100 * v2);
}
return result;
}

original_code:
static int ft_power(int n)
{
 if (n == 0)
  return (1);
 if (n == 1)
  return (10);
 else
  return (10 * ft_power(n - 1));
}

variable_types: n int


decompiled_code:
// attributes: thunk
__int64 __fastcall add_s_func(__int64 a1)
{
return add_basic(a1);
}

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

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

canonical_original_code:
void add_s_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(115LL, basic_s_conv);
return add_conv(a1, v1);
}

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

v1 = create_conv(115LL, basic_s_conv);
return add_conv(a1, v1);
}

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

canonical_original_code:
static void add_basic(struct s_conv **list)
{
 add_conv(list, create_conv('s', basic_s_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 count_nbr(__int64 a1)
{
__int64 v1; // rdx
int v2; // edi
unsigned int v3; // er8
__int64 v4; // rcx
unsigned int v5; // eax
unsigned int v6; // eax

v1 = a1;
if ( a1 < 0 )
{
if ( a1 >= -9 )
return 2;
v1 = -a1;
v2 = 1;
}
else
{
v2 = 0;
v3 = 1;
if ( v1 <= 9 )
return v3;
}
v3 = 1;
do
{
v4 = v1;
v5 = v3++;
v1 /= 0xAuLL;
}
while ( v4 > 99 );
v6 = v5 + 2;
if ( v2 )
v3 = v6;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rdx
int v2; // edi
unsigned int v3; // er8
__int64 v4; // rcx
unsigned int v5; // eax
unsigned int v6; // eax

v1 = a1;
if ( a1 < 0 )
{
if ( a1 >= -9 )
return 2;
v1 = -a1;
v2 = 1;
}
else
{
v2 = 0;
v3 = 1;
if ( v1 <= 9 )
return v3;
}
v3 = 1;
do
{
v4 = v1;
v5 = v3++;
v1 /= 0xAuLL;
}
while ( v4 > 99 );
v6 = v5 + 2;
if ( v2 )
v3 = v6;
return v3;
}

original_code:
static unsigned int count_nbr(long n)
{
 unsigned int count;
 unsigned int i;
 count = 1;
 i = 0;
 if (n < 0)
 {
  n *= -1;
  i++;
 }
 while (n / 10 > 0)
 {
  n /= 10;
  count++;
 }
 if (i > 0)
  return (count + 1);
 return (count);
}

variable_types: n long

variable_types:
count
unsigned int

variable_types:
i
unsigned int

return_type: unsigned int


original_code:
void mod_path(char **path)
{
 int i;
 char *tmp;
 i = 0;
 while (path[i] != ((void *)0))
 {
  tmp = ft_strjoin(path[i], "/");
  free(path[i]);
  path[i] = tmp;
  i++;
 }
}

variable_types:
path
char **

variable_types: i int


repo: SunUnicorn/Compression

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
_BYTE v4[16360]; // [rsp+0h] [rbp-3FE8h] BYREF

if ( argc == 2 )
{
make_tree(v4, "data/stat.jpg", envp);
huffman_codes(v4);
compress_file(v4, "data/stat.jpg");
result = 0;
}
else
{
puts("You must write name of a file as argument");
result = 1;
}
return result;
}

original_code:
int main(int argc, char **argv){
  if(argc != 2){
  printf("You must write name of a file as argument\n");
  return 1;
  }
 NODE array[511];
    make_tree(array, "data/stat.jpg");
    huffman_codes(array);
    compress_file(array, "data/stat.jpg");
 return 0;
}

canonical_original_code:
int main(int argc, char **argv){
  if(argc != 2){
  printf("You must write name of a file as argument\n");
  return 1;
  }
 struct node array[511];
    make_tree(array, "data/stat.jpg");
    huffman_codes(array);
    compress_file(array, "data/stat.jpg");
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct node { unsigned int number; unsigned short code; struct node *right; struct node *left; char sign; } [511]


original_code:
static int array_min_value(NODE *array, int border){
  int i, j = 511;
  unsigned int tmp = 4294967295;
    for(i = 0; i < border; i++)
      if(array[i].sign && array[i].number <= tmp){
      tmp = array[i].number;
      j = i;
      }
    if(j != 511)
    array[j].sign = 0;
  return j;
}

canonical_original_code:
static int array_min_value(struct node *array, int border){
  int i; int j = 511;
  unsigned int tmp = 4294967295;
    for(i = 0; i < border; i++)
      if(array[i].sign && array[i].number <= tmp){
      tmp = array[i].number;
      j = i;
      }
    if(j != 511)
    array[j].sign = 0;
  return j;
}

variable_types: struct node { unsigned int number; unsigned short code; struct node *right; struct node *left; char sign; } *

variable_types: border int

variable_types: j int

variable_types:
tmp
unsigned int


decompiled_code:
__int64 __fastcall display_tree(unsigned int *a1)
{
unsigned int v1; // ebp
const void *v3; // r9
const void *v4; // r8
__int64 v5; // rsi
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // rax
__int64 result; // rax
__int64 v10; // [rsp-10h] [rbp-28h]
const void *v11; // [rsp-8h] [rbp-20h]

v1 = 0;
do
{
v3 = (const void *)*((_QWORD *)a1 + 2);
v4 = (const void *)*((_QWORD *)a1 + 1);
v5 = v1;
v6 = *((unsigned __int16 *)a1 + 2);
v7 = *a1;
v11 = a1;
++v1;
v8 = (unsigned int)*((char *)a1 + 24);
a1 += 8;
printf(
"i: %d\n"
" unsigned int number: %d\n"
" unsigned short int code: %d\n"
" struct node *right: %p\n"
" struct node *left: %p\n"
" char sign: %d\n"
" own address: %p\n"
"\n"
" ",
v5,
v7,
v6,
v4,
v3,
v8,
v11);
result = v10;
}
while ( v1 != 511 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1)
{
unsigned int v1; // ebp
const void *v3; // r9
const void *v4; // r8
__int64 v5; // rsi
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // rax
__int64 result; // rax
__int64 v10; // [rsp-10h] [rbp-28h]
const void *v11; // [rsp-8h] [rbp-20h]

v1 = 0;
do
{
v3 = (const void *)*((_QWORD *)a1 + 2);
v4 = (const void *)*((_QWORD *)a1 + 1);
v5 = v1;
v6 = *((unsigned __int16 *)a1 + 2);
v7 = *a1;
v11 = a1;
++v1;
v8 = (unsigned int)*((char *)a1 + 24);
a1 += 8;
printf(
"i: %d\n"
" unsigned int number: %d\n"
" unsigned short int code: %d\n"
" struct node *right: %p\n"
" struct node *left: %p\n"
" char sign: %d\n"
" own address: %p\n"
"\n"
" ",
v5,
v7,
v6,
v4,
v3,
v8,
v11);
result = v10;
}
while ( v1 != 511 );
return result;
}

original_code:
void display_tree(NODE *array){
  int i;
    for(i = 0; i < 511; i++)
    printf( "i: %d\n unsigned int number: %d\n unsigned short int code: %d\n struct node *right: %p\n struct node *left: %p\n char sign: %d\n own address: %p\n\n ", i, array[i].number, array[i].code, array[i].right, array[i].left, array[i].sign, array + i );
}

canonical_original_code:
void display_tree(struct node *array){
  int i;
    for(i = 0; i < 511; i++)
    printf( "i: %d\n unsigned int number: %d\n unsigned short int code: %d\n struct node *right: %p\n struct node *left: %p\n char sign: %d\n own address: %p\n\n ", i, array[i].number, array[i].code, array[i].right, array[i].left, array[i].sign, array + i );
}

user_defined_types: struct node { unsigned int number; unsigned short code; struct node *right; struct node *left; char sign; }


S

decompiled_code:
// attributes: thunk
int S(const char *s)
{
return puts(s);
}

canonical_decompiled_code:
int func1(const char *s)
{
return puts(s);
}

original_code:
void S(char *message){
printf("%s\n", message);
}

variable_types:
message
char *


decompiled_code:
__int64 __fastcall find_tree_root(__int64 a1)
{
__int64 v1; // rdi
__int64 result; // rax

if ( *(_QWORD *)(a1 + 16328) )
return a1 + 16320;
v1 = a1 + 16288;
do
{
result = v1;
v1 -= 32LL;
}
while ( !*(_QWORD *)(v1 + 40) );
return result;
}

original_code:
static NODE *find_tree_root(NODE *array){
  int i = 511 - 1;
    while(array[i].right == ((void *)0))
    i--;
  return array + i;
}

canonical_original_code:
static struct node *find_tree_root(struct node *array){
  int i = 511 - 1;
    while(array[i].right == ((void *)0))
    i--;
  return array + i;
}

variable_types:
array
struct node *

return_type: struct node { unsigned int number; unsigned short code; struct node *right; struct node *left; char sign; } *


original_code:
static void recursive_huffman_codes(NODE *array){
  (*((*array).left)).code = (*array).code << 1;
  (*((*array).right)).code = (*array).code << 1;
  (*((*array).right)).code = ((*array).code << 1) + 1;
  if((*((*array).left)).left != ((void *)0))
  recursive_huffman_codes((*array).left);
  if((*((*array).right)).left != ((void *)0))
  recursive_huffman_codes((*array).right);
}

canonical_original_code:
static void recursive_huffman_codes(struct node *array){
  (*((*array).left)).code = (*array).code << 1;
  (*((*array).right)).code = (*array).code << 1;
  (*((*array).right)).code = ((*array).code << 1) + 1;
  if((*((*array).left)).left != ((void *)0))
  recursive_huffman_codes((*array).left);
  if((*((*array).right)).left != ((void *)0))
  recursive_huffman_codes((*array).right);
}


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

v1 = find_tree_root(a1);
return recursive_huffman_codes(v1);
}

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

v1 = func0(a1);
return func1(v1);
}

original_code:
void huffman_codes(NODE *array){
  NODE *root = find_tree_root(array);
  recursive_huffman_codes(root);
}

canonical_original_code:
void huffman_codes(struct node *array){
  struct node *root = find_tree_root(array);
  recursive_huffman_codes(root);
}


preServerThread

repo: SunnyBingoMe/chat

decompiled_code:
void *__fastcall preServerThread(void *a1)
{
serverThread((unsigned int)dConnection);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1)
{
serverThread((unsigned int)dConnection);
return 0LL;
}

original_code:
void *preServerThread(void * ttt){
 serverThread(dConnection);
 return (((void *)0));
}

canonical_original_code:
void *preServerThread(void *ttt){
 serverThread(dConnection);
 return (((void *)0));
}

variable_types:
ttt
void *