decompiled_code:
__int64 __fastcall ft_sort_params_type(__int64 a1)
{
_BYTE *v1; // rax
__int64 v2; // rax
_BYTE *v3; // rdx
int v4; // ebp
__int64 result; // rax
int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = *(_BYTE **)(a1 + 8);
v6[0] = 1;
if ( *v1 == 45 )
{
v2 = 2LL;
do
{
v3 = *(_BYTE **)(a1 + 8 * v2);
v6[0] = v2;
v4 = v2++;
}
while ( *v3 == 45 );
}
else
{
v4 = 1;
}
do
{
v6[0] = v4;
result = ft_test_type(a1, v6, 0LL);
}
while ( (_DWORD)result == 1 );
return result;
}

original_code:
void ft_sort_params_type(char **argv)
{
 int i;
 int cnt;
 int save;
 i = 1;
 while (argv[i][0] == '-')
  i++;
 save = i;
 cnt = 1;
 while (cnt == 1)
 {
  cnt = 0;
  i = save;
  cnt = ft_test_type(argv, &i, cnt);
 }
}


decompiled_code:
void __fastcall __noreturn ft_error_1(__int64 a1)
{
ft_putendl_fd(a1, 2LL);
exit(-1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(__int64 a1)
{
ft_putendl_fd(a1, 2LL);
exit(-1);
}

original_code:
void ft_error_1(char *s)
{
 ft_putendl_fd(s, 2);
 exit (-1);
}

variable_types:
s
char *

return_type: void


decompiled_code:
void __fastcall __noreturn ft_error_2(__int64 a1, __int64 a2)
{
ft_putstr_fd(a1, 2LL);
ft_putendl_fd(a2, 2LL);
exit(-1);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(__int64 a1, __int64 a2)
{
ft_putstr_fd(a1, 2LL);
ft_putendl_fd(a2, 2LL);
exit(-1);
}

original_code:
void ft_error_2(char *s, char *s2)
{
 ft_putstr_fd(s, 2);
 ft_putendl_fd(s2, 2);
 exit (-1);
}


decompiled_code:
void __fastcall __noreturn ft_error_3(__int64 a1, __int64 a2, __int64 a3)
{
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(a2, 2LL);
ft_putendl_fd(a3, 2LL);
exit(-1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(__int64 a1, __int64 a2, __int64 a3)
{
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(a2, 2LL);
ft_putendl_fd(a3, 2LL);
exit(-1);
}

original_code:
void ft_error_3(char *s, char *s2, char *s3)
{
 ft_putstr_fd(s, 2);
 ft_putstr_fd(s2, 2);
 ft_putendl_fd(s3, 2);
 exit (-1);
}


decompiled_code:
void __fastcall __noreturn ft_error_4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(a2, 2LL);
ft_putstr_fd(a3, 2LL);
ft_putendl_fd(a4, 2LL);
exit(-1);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(a2, 2LL);
ft_putstr_fd(a3, 2LL);
ft_putendl_fd(a4, 2LL);
exit(-1);
}

original_code:
void ft_error_4(char *s, char *s2, char *s3, char *s4)
{
 ft_putstr_fd(s, 2);
 ft_putstr_fd(s2, 2);
 ft_putstr_fd(s3, 2);
 ft_putendl_fd(s4, 2);
 exit (-1);
}


original_code:
void f_or(t_dat *dat, t_proc *proc)
{
 short tp[2];
 long params[3];
 long res;
 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)
   ft_printf("or: value %ld | value %ld -> reg%ld\n", params[0], params[1], params[2]);
  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_or(struct s_dat *dat, struct s_proc *proc)
{
 short tp[2];
 long params[3];
 long res;
 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)
   ft_printf("or: value %ld | value %ld -> reg%ld\n", params[0], params[1], params[2]);
  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:
tp
short [2]

variable_types:
params
long [3]

variable_types: res long

variable_types:
dest
unsigned char *

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


decompiled_code:
int *mai_error()
{
int *result; // rax
int *v1; // rbx
char *v2; // rax

result = _errno_location();
if ( *result )
{
v1 = result;
v2 = strerror(*result);
ft_putstr_fd(v2, 2LL);
exit(*v1);
}
return result;
}

canonical_decompiled_code:
int *func0()
{
int *result; // rax
int *v1; // rbx
char *v2; // rax

result = _errno_location();
if ( *result )
{
v1 = result;
v2 = strerror(*result);
ft_putstr_fd(v2, 2LL);
exit(*v1);
}
return result;
}

original_code:
void mai_error(void)
{
 if ((*__errno_location ()) != 0)
 {
  ft_putstr_fd(strerror((*__errno_location ())), 2);
  exit((*__errno_location ()));
 }
}

canonical_original_code:
void mai_error()
{
 if ((*__errno_location ()) != 0)
 {
  ft_putstr_fd(strerror((*__errno_location ())), 2);
  exit((*__errno_location ()));
 }
}


decompiled_code:
__int64 __fastcall mai_lexer_and_parser(int fd)
{
__int64 v2[2]; // [rsp+8h] [rbp-10h] BYREF

v2[0] = lex_lexer();
if ( !v2[0] )
exit(-1);
close(fd);
if ( (unsigned int)par_parser(v2[0]) )
exit(-2);
par_clear_lst(v2);
par_clear_empty_line(v2);
return v2[0];
}

canonical_decompiled_code:
__int64 __fastcall func1(int fd)
{
__int64 v2[2]; // [rsp+8h] [rbp-10h] BYREF

v2[0] = lex_lexer();
if ( !v2[0] )
exit(-1);
close(fd);
if ( (unsigned int)par_parser(v2[0]) )
exit(-2);
par_clear_lst(v2);
par_clear_empty_line(v2);
return v2[0];
}

original_code:
t_lexer *mai_lexer_and_parser(int fd)
{
 t_lexer *lexed;
 if ((lexed = lex_lexer(fd)) == ((void *)0))
  exit(-1);
 close(fd);
 if (par_parser(lexed) != 0)
  exit(-2);
 par_clear_lst(&lexed);
 par_clear_empty_line(&lexed);
 return (lexed);
}

canonical_original_code:
struct s_lexer *mai_lexer_and_parser(int fd)
{
 struct s_lexer *lexed;
 if ((lexed = lex_lexer(fd)) == ((void *)0))
  exit(-1);
 close(fd);
 if (par_parser(lexed) != 0)
  exit(-2);
 par_clear_lst(&lexed);
 par_clear_empty_line(&lexed);
 return (lexed);
}

variable_types: fd int

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

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


decompiled_code:
__int64 __fastcall mai_labeler_and_encoder(__int64 a1, const char *a2)
{
__int64 v2; // rax
__int64 v3; // rax
__int64 result; // rax
__int64 v5; // [rsp+0h] [rbp-18h] BYREF
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v5 = 0LL;
v6 = 0LL;
if ( (unsigned int)lab_firstpass(a2, a1, &v5, &v6) )
exit(-3);
ft_printf("Assembling %s:\n", a2);
write(1, " ", 8uLL);
v2 = ft_strlen(*(_QWORD *)(v5 + 8));
write(1, (const void *)(*(_QWORD *)(v5 + 8) + 1LL), v2 - 2);
write(1, "\n ", 9uLL);
v3 = ft_strlen(*(_QWORD *)(v5 + 16));
write(1, (const void *)(*(_QWORD *)(v5 + 16) + 1LL), v3 - 2);
write(1, "\n", 1uLL);
result = enc_encoding(v5, v6);
if ( (_DWORD)result )
exit(-4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2)
{
__int64 v2; // rax
__int64 v3; // rax
__int64 result; // rax
__int64 v5; // [rsp+0h] [rbp-18h] BYREF
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v5 = 0LL;
v6 = 0LL;
if ( (unsigned int)lab_firstpass(a2, a1, &v5, &v6) )
exit(-3);
ft_printf("Assembling %s:\n", a2);
write(1, " ", 8uLL);
v2 = ft_strlen(*(_QWORD *)(v5 + 8));
write(1, (const void *)(*(_QWORD *)(v5 + 8) + 1LL), v2 - 2);
write(1, "\n ", 9uLL);
v3 = ft_strlen(*(_QWORD *)(v5 + 16));
write(1, (const void *)(*(_QWORD *)(v5 + 16) + 1LL), v3 - 2);
write(1, "\n", 1uLL);
result = enc_encoding(v5, v6);
if ( (_DWORD)result )
exit(-4);
return result;
}

original_code:
void mai_labeler_and_encoder(t_lexer *lexed, char *av)
{
 t_start *start;
 t_label *label;
 start = ((void *)0);
 label = ((void *)0);
 if (lab_firstpass(av, lexed, &start, &label) != 0)
  exit(-3);
 ft_printf("Assembling %s:\n", av);
 write(1, "          ", 8);
 write(1, start->name + 1, (ft_strlen(start->name) - 2));
 write(1, "\n        ", 9);
 write(1, start->comment + 1, (ft_strlen(start->comment) - 2));
 write(1, "\n", 1);
 if (enc_encoding(start, label) != 0)
  exit(-4);
}

canonical_original_code:
void mai_labeler_and_encoder(struct s_lexer *lexed, char *av)
{
 struct s_start *start;
 struct s_label *label;
 start = ((void *)0);
 label = ((void *)0);
 if (lab_firstpass(av, lexed, &start, &label) != 0)
  exit(-3);
 ft_printf("Assembling %s:\n", av);
 write(1, "          ", 8);
 write(1, start->name + 1, (ft_strlen(start->name) - 2));
 write(1, "\n        ", 9);
 write(1, start->comment + 1, (ft_strlen(start->comment) - 2));
 write(1, "\n", 1);
 if (enc_encoding(start, label) != 0)
  exit(-4);
}

variable_types:
av
char *

variable_types: struct s_start { char *filename; char *name; char *comment; int prog_size; 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; } *lexer; } *

variable_types: struct s_label { char *name; int address; struct s_label *next; } *

user_defined_types: struct s_start { char *filename; char *name; char *comment; int prog_size; struct s_lexer *lexer; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rdi
int *v5; // rbp
int v6; // edi
__int64 v7; // rax

if ( argc <= 1 )
{
err_usage(argc, argv, envp);
}
else
{
v3 = argv + 1;
if ( argv[1] )
{
v4 = argv[1];
v5 = _errno_location();
do
{
*v5 = 0;
v6 = open(v4, 0);
if ( v6 != -1 )
{
v7 = mai_lexer_and_parser(v6);
mai_labeler_and_encoder(v7, *v3);
}
mai_error();
v4 = v3[1];
++v3;
}
while ( v4 );
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rdi
int *v5; // rbp
int v6; // edi
__int64 v7; // rax

if ( argc <= 1 )
{
err_usage(argc, argv, envp);
}
else
{
v3 = argv + 1;
if ( argv[1] )
{
v4 = argv[1];
v5 = _errno_location();
do
{
*v5 = 0;
v6 = open(v4, 0);
if ( v6 != -1 )
{
v7 = func1(v6);
func2(v7, *v3);
}
func0();
v4 = v3[1];
++v3;
}
while ( v4 );
}
}
return 0;
}

original_code:
int main(int ac, char **av)
{
 int fd;
 int i;
 t_lexer *lexed;
 i = 1;
 if (ac < 2)
  err_usage();
 else
 {
  while (av[i] != ((void *)0))
  {
   (*__errno_location ()) = 0;
   if ((fd = open(av[i], 00)) != -1)
   {
    lexed = mai_lexer_and_parser(fd);
    mai_labeler_and_encoder(lexed, av[i]);
   }
   mai_error();
   i++;
  }
 }
 return (0);
}

canonical_original_code:
int main(int ac, char **av)
{
 int fd;
 int i;
 struct s_lexer *lexed;
 i = 1;
 if (ac < 2)
  err_usage();
 else
 {
  while (av[i] != ((void *)0))
  {
   (*__errno_location ()) = 0;
   if ((fd = open(av[i], 00)) != -1)
   {
    lexed = mai_lexer_and_parser(fd);
    mai_labeler_and_encoder(lexed, av[i]);
   }
   mai_error();
   i++;
  }
 }
 return (0);
}

variable_types: ac int

variable_types:
av
char **

variable_types: i int

return_type: int

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


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

result = (_QWORD *)info_0;
if ( !info_0 )
{
result = malloc(0x20uLL);
info_0 = (__int64)result;
*(_DWORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

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

result = (_QWORD *)info_0;
if ( !info_0 )
{
result = malloc(0x20uLL);
info_0 = (__int64)result;
*(_DWORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

original_code:
t_info *info_structs(void)
{
 static t_info *info = ((void *)0);
 if (info == ((void *)0))
 {
  info = (t_info*)malloc(sizeof(t_info));
  info->ant = 0;
  info->start = ((void *)0);
  info->end = ((void *)0);
  return (info);
 }
 else
  return (info);
}

canonical_original_code:
struct s_info *info_structs()
{
 static struct s_info *info = ((void *)0);
 if (info == ((void *)0))
 {
  info = (struct s_info *)malloc(sizeof(t_info));
  info->ant = 0;
  info->start = ((void *)0);
  info->end = ((void *)0);
  return (info);
 }
 else
  return (info);
}

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

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

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


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rbp
__int64 v4; // rsi

v3 = info_structs();
v4 = build_lex_list(argc, argv);
if ( !v4 )
{
ft_error_1("Parse Error at line 0 : . No information");
v4 = 0LL;
}
get_info(v3, v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rbp
__int64 v4; // rsi

v3 = func0();
v4 = build_lex_list(argc, argv);
if ( !v4 )
{
ft_error_1("Parse Error at line 0 : . No information");
v4 = 0LL;
}
get_info(v3, v4);
return 0;
}

original_code:
int main(void)
{
 t_info *info;
 t_tok *tok;
 info = info_structs();
 if ((tok = build_lex_list()) == ((void *)0))
  ft_error_1("Parse Error at line 0 : . No information");
 get_info(info, tok);
 return (0);
}

canonical_original_code:
int main()
{
 struct s_info *info;
 struct s_tok *tok;
 info = info_structs();
 if ((tok = build_lex_list()) == ((void *)0))
  ft_error_1("Parse Error at line 0 : . No information");
 get_info(info, tok);
 return (0);
}

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

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

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


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

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

original_code:
int ft_lstcount(t_list *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_lstcount(struct s_list *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 { void *content; unsigned long content_size; struct s_list *next; } *


decompiled_code:
__int64 __fastcall f_lfork(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r13
__int64 v5; // rcx
__int64 *v6; // rax
__int64 result; // rax

v2 = ft_memalloc(96LL);
if ( !v2 )
impossible_malloc("t_proc in f_lfork");
v3 = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + 1), 2LL);
v4 = get_true_val(v3, 0LL, 2LL);
ft_memcpy(v2, a2, 96LL);
v5 = (v4 + *(int *)(a2 + 64)) % 4096;
*(_QWORD *)(v2 + 76) = 0xFFFFFFFFLL;
v6 = *(__int64 **)(a1 + 4096);
*(_DWORD *)(v2 + 64) = v5;
*(_QWORD *)(v2 + 88) = *v6;
*v6 = v2;
if ( *(_DWORD *)(a1 + 4136) )
ft_printf("lfork: %d bytes from pc %d to pc %d\n", (unsigned int)v4, *(unsigned int *)(a2 + 64), v5);
result = (unsigned int)((*(_DWORD *)(a2 + 64) + 3) % 4096);
*(_DWORD *)(a2 + 64) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r13
__int64 v5; // rcx
__int64 *v6; // rax
__int64 result; // rax

v2 = ft_memalloc(96LL);
if ( !v2 )
impossible_malloc("t_proc in f_lfork");
v3 = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + 1), 2LL);
v4 = get_true_val(v3, 0LL, 2LL);
ft_memcpy(v2, a2, 96LL);
v5 = (v4 + *(int *)(a2 + 64)) % 4096;
*(_QWORD *)(v2 + 76) = 0xFFFFFFFFLL;
v6 = *(__int64 **)(a1 + 4096);
*(_DWORD *)(v2 + 64) = v5;
*(_QWORD *)(v2 + 88) = *v6;
*v6 = v2;
if ( *(_DWORD *)(a1 + 4136) )
ft_printf("lfork: %d bytes from pc %d to pc %d\n", (unsigned int)v4, *(unsigned int *)(a2 + 64), v5);
result = (unsigned int)((*(_DWORD *)(a2 + 64) + 3) % 4096);
*(_DWORD *)(a2 + 64) = result;
return result;
}

original_code:
void f_lfork(t_dat *dat, t_proc *proc)
{
 t_proc *forked;
 long param;
 if ((forked = (t_proc *)ft_memalloc(sizeof(t_proc))) == ((void *)0))
  impossible_malloc("t_proc in f_lfork");
 param = get_val(dat->arena, proc->pc + 1, 2);
 param = get_true_val(param, 0, 2);
 ft_memcpy(forked, proc, sizeof(t_proc));
 forked->pc = (proc->pc + param) % (4*1024);
 forked->cycle_to_exec = -1;
 forked->nbr_live = 0;
 forked->next = *(dat->bgn_lst);
 *(dat->bgn_lst) = forked;
 if (dat->verbose)
  ft_printf("lfork: %d bytes from pc %d to pc %d\n", (int)param, proc->pc, forked->pc);
 proc->pc = (proc->pc + 3) % (4*1024);
}

canonical_original_code:
void f_lfork(struct s_dat *dat, struct s_proc *proc)
{
 struct s_proc *forked;
 long param;
 if ((forked = (struct s_proc *)ft_memalloc(sizeof(t_proc))) == ((void *)0))
  impossible_malloc("t_proc in f_lfork");
 param = get_val(dat->arena, proc->pc + 1, 2);
 param = get_true_val(param, 0, 2);
 ft_memcpy(forked, proc, sizeof(t_proc));
 forked->pc = (proc->pc + param) % (4*1024);
 forked->cycle_to_exec = -1;
 forked->nbr_live = 0;
 forked->next = *(dat->bgn_lst);
 *(dat->bgn_lst) = forked;
 if (dat->verbose)
  ft_printf("lfork: %d bytes from pc %d to pc %d\n", (int)param, proc->pc, forked->pc);
 proc->pc = (proc->pc + 3) % (4*1024);
}

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


decompiled_code:
__int64 __fastcall ft_cd(__int64 a1, __int64 a2)
{
_BYTE *v3; // rdi
int v4; // ebx
__int64 v5; // rcx
__int64 result; // rax
__int64 v7[7]; // [rsp+0h] [rbp-38h] BYREF

v3 = *(_BYTE **)(a2 + 8);
v7[0] = (__int64)&unk_2BD;
v7[1] = (__int64)&unk_2BF;
v7[2] = (__int64)&unk_2C1;
if ( v3 && *v3 == 45 && !v3[1] )
return ft_go_oldpwd(a1);
v4 = 0;
while ( 1 )
{
v5 = (unsigned int)v4++;
result = ft_compare_cd_operation(v3, v7, a1, v5);
if ( v4 > 2 || (_DWORD)result != 1 )
break;
v3 = *(_BYTE **)(a2 + 8);
}
if ( v4 == 3 )
{
if ( *(_QWORD *)(a2 + 8) )
result = ft_other(a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
_BYTE *v3; // rdi
int v4; // ebx
__int64 v5; // rcx
__int64 result; // rax
__int64 v7[7]; // [rsp+0h] [rbp-38h] BYREF

v3 = *(_BYTE **)(a2 + 8);
v7[0] = (__int64)&unk_2BD;
v7[1] = (__int64)&unk_2BF;
v7[2] = (__int64)&unk_2C1;
if ( v3 && *v3 == 45 && !v3[1] )
return ft_go_oldpwd(a1);
v4 = 0;
while ( 1 )
{
v5 = (unsigned int)v4++;
result = ft_compare_cd_operation(v3, v7, a1, v5);
if ( v4 > 2 || (_DWORD)result != 1 )
break;
v3 = *(_BYTE **)(a2 + 8);
}
if ( v4 == 3 )
{
if ( *(_QWORD *)(a2 + 8) )
result = ft_other(a1);
}
return result;
}

original_code:
void ft_cd(char ***env, char **arg)
{
 int i;
 int j;
 int k;
 char *lib_cd[3] = {"/", ".", "~"};
 i = k = 1;
 j = 0;
 if (arg[i] != ((void *)0))
 {
  if (arg[i][0] == '-' && arg[i][1] == '\0')
  {
   ft_go_oldpwd(env);
   k = 0;
  }
 }
 while (j < 3 && k == 1)
 {
  k = ft_compare_cd_operation(arg[i], lib_cd, env, j);
  j++;
 }
 if (j == 3 && arg[i] != ((void *)0))
  ft_other(env, arg[i]);
}

variable_types:
env
char ***

variable_types:
arg
char **

variable_types: j int

variable_types: k int


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

result = malloc(0x14uLL);
if ( !result )
{
impossible_malloc("t_flags");
result = 0LL;
}
*result = 0LL;
result[1] = 0LL;
*((_DWORD *)result + 4) = 0;
return result;
}

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

result = malloc(0x14uLL);
if ( !result )
{
impossible_malloc("t_flags");
result = 0LL;
}
*result = 0LL;
result[1] = 0LL;
*((_DWORD *)result + 4) = 0;
return result;
}

original_code:
t_flags *init_flags(void)
{
 t_flags *out;
 if ((out = (t_flags *) malloc(sizeof(t_flags))) == ((void *)0))
  impossible_malloc("t_flags");
 out->has_hashtag = 0;
 out->has_zero = 0;
 out->has_minus = 0;
 out->has_space = 0;
 out->has_plus = 0;
 return (out);
}

canonical_original_code:
struct s_flags *init_flags()
{
 struct s_flags *out;
 if ((out = (struct s_flags *) malloc(sizeof(t_flags))) == ((void *)0))
  impossible_malloc("t_flags");
 out->has_hashtag = 0;
 out->has_zero = 0;
 out->has_minus = 0;
 out->has_space = 0;
 out->has_plus = 0;
 return (out);
}

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


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

result = (unsigned int)*a2;
if ( (_DWORD)result )
return not_unique_flag((unsigned int)a1);
*a2 = 1;
return result;
}

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

result = (unsigned int)*a2;
if ( (_DWORD)result )
return not_unique_flag((unsigned int)a1);
*a2 = 1;
return result;
}

original_code:
void check_unicity_and_update(char flag, int *val)
{
 if (*val == 0)
  *val = 1;
 else
  not_unique_flag(flag);
}

variable_types: flag char

variable_types:
val
int *


decompiled_code:
__int64 __fastcall update_flags(__int64 *a1, char *a2)
{
__int64 v2; // r12
__int64 result; // rax
char v5; // al

if ( !*(_QWORD *)(*a1 + 8) )
{
v2 = *a1;
*(_QWORD *)(v2 + 8) = init_flags();
}
while ( 1 )
{
result = (unsigned __int8)*a2;
if ( !(_BYTE)result )
return result;
if ( (_BYTE)result == 35 )
check_unicity_and_update(35, *(_DWORD **)(*a1 + 8));
v5 = *a2;
if ( *a2 == 48 )
{
check_unicity_and_update(48, (_DWORD *)(*(_QWORD *)(*a1 + 8) + 4LL));
v5 = *a2;
if ( *a2 != 45 )
{
LABEL_4:
if ( v5 == 32 )
goto LABEL_13;
goto LABEL_5;
}
}
else if ( v5 != 45 )
{
goto LABEL_4;
}
check_unicity_and_update(45, (_DWORD *)(*(_QWORD *)(*a1 + 8) + 8LL));
v5 = *a2;
if ( *a2 == 32 )
{
LABEL_13:
check_unicity_and_update(32, (_DWORD *)(*(_QWORD *)(*a1 + 8) + 12LL));
if ( *a2 != 43 )
goto LABEL_6;
goto LABEL_14;
}
LABEL_5:
if ( v5 != 43 )
goto LABEL_6;
LABEL_14:
check_unicity_and_update(43, (_DWORD *)(*(_QWORD *)(*a1 + 8) + 16LL));
LABEL_6:
++a2;
}
}

original_code:
void update_flags(t_format **format, char *flags)
{
 if (!(*format)->f_list)
  (*format)->f_list = init_flags();
 while (*flags)
 {
  if (*flags == '#')
   check_unicity_and_update(*flags, &((*format)->f_list->has_hashtag));
  if (*flags == '0')
   check_unicity_and_update(*flags, &((*format)->f_list->has_zero));
  if (*flags == '-')
   check_unicity_and_update(*flags, &((*format)->f_list->has_minus));
  if (*flags == ' ')
   check_unicity_and_update(*flags, &((*format)->f_list->has_space));
  if (*flags == '+')
   check_unicity_and_update(*flags, &((*format)->f_list->has_plus));
  flags++;
 }
}

canonical_original_code:
void update_flags(struct s_format **format, char *flags)
{
 if (!(*format)->f_list)
  (*format)->f_list = init_flags();
 while (*flags)
 {
  if (*flags == '#')
   check_unicity_and_update(*flags, &((*format)->f_list->has_hashtag));
  if (*flags == '0')
   check_unicity_and_update(*flags, &((*format)->f_list->has_zero));
  if (*flags == '-')
   check_unicity_and_update(*flags, &((*format)->f_list->has_minus));
  if (*flags == ' ')
   check_unicity_and_update(*flags, &((*format)->f_list->has_space));
  if (*flags == '+')
   check_unicity_and_update(*flags, &((*format)->f_list->has_plus));
  flags++;
 }
}

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

variable_types:
flags
char *

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 ft_putendl()
{
ft_putstr();
return ft_putchar(10LL);
}

canonical_decompiled_code:
__int64 func0()
{
ft_putstr();
return ft_putchar(10LL);
}

original_code:
void ft_putendl(const char *s)
{
 ft_putstr(s);
 ft_putchar('\n');
}

canonical_original_code:
void ft_putendl(char *s)
{
 ft_putstr(s);
 ft_putchar('\n');
}

variable_types:
s
char *


original_code:
void f_st(t_dat *dat, t_proc *proc)
{
 long vals[3];
 long val;
 short type;
 type = ((proc->params >> ((3 - 1) * 2)) % 4);
 get_params(dat, proc, vals, 4);
 if (vals[0] > 0 && vals[0] <= 16)
 {
  if (type == 1)
   ft_memcpy(proc->reg + ((vals[1] - 1) * 4), proc->reg + ((vals[0] - 1) * 4), 4);
  else if (type == 3)
  {
   val = (get_val(dat->arena, proc->pc + 3, 2));
   val = get_true_val(val, 1, 2);
   if (dat->verbose)
    handle_verbose(proc, type, vals, val);
   cpy_to_arena(proc->reg + ((vals[0] - 1) * 4), dat, proc->pc + val, 4);
  }
 }
 move_pc(proc, 4);
}

canonical_original_code:
void f_st(struct s_dat *dat, struct s_proc *proc)
{
 long vals[3];
 long val;
 short type;
 type = ((proc->params >> ((3 - 1) * 2)) % 4);
 get_params(dat, proc, vals, 4);
 if (vals[0] > 0 && vals[0] <= 16)
 {
  if (type == 1)
   ft_memcpy(proc->reg + ((vals[1] - 1) * 4), proc->reg + ((vals[0] - 1) * 4), 4);
  else if (type == 3)
  {
   val = (get_val(dat->arena, proc->pc + 3, 2));
   val = get_true_val(val, 1, 2);
   if (dat->verbose)
    handle_verbose(proc, type, vals, val);
   cpy_to_arena(proc->reg + ((vals[0] - 1) * 4), dat, proc->pc + val, 4);
  }
 }
 move_pc(proc, 4);
}

variable_types:
proc
struct s_proc *

variable_types:
vals
long [3]

variable_types: val long

variable_types: type short

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:
__int64 __fastcall choose_buf(int a1, int **a2)
{
int *v2; // rax
int *v3; // rbx
int v4; // edx
_QWORD *v5; // rax
int *v6; // rax
__int64 result; // rax

v2 = *a2;
if ( *a2 )
{
while ( 1 )
{
v3 = v2;
v2 = (int *)*((_QWORD *)v2 + 2);
v4 = *v3;
if ( !v2 )
break;
if ( v4 == a1 )
goto LABEL_7;
}
if ( v4 != a1 )
{
v5 = new_t_buf(a1);
*((_QWORD *)v3 + 2) = v5;
return v5[1];
}
LABEL_7:
result = *((_QWORD *)v3 + 1);
}
else
{
v6 = (int *)new_t_buf(a1);
*a2 = v6;
result = *((_QWORD *)v6 + 1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int **a2)
{
int *v2; // rax
int *v3; // rbx
int v4; // edx
_QWORD *v5; // rax
int *v6; // rax
__int64 result; // rax

v2 = *a2;
if ( *a2 )
{
while ( 1 )
{
v3 = v2;
v2 = (int *)*((_QWORD *)v2 + 2);
v4 = *v3;
if ( !v2 )
break;
if ( v4 == a1 )
goto LABEL_7;
}
if ( v4 != a1 )
{
v5 = new_t_buf(a1);
*((_QWORD *)v3 + 2) = v5;
return v5[1];
}
LABEL_7:
result = *((_QWORD *)v3 + 1);
}
else
{
v6 = (int *)new_t_buf(a1);
*a2 = v6;
result = *((_QWORD *)v6 + 1);
}
return result;
}

original_code:
static char *choose_buf(int const fd, t_buf **buflst)
{
 t_buf *tmp;
 if (*buflst)
 {
  tmp = *buflst;
  while (tmp->next)
  {
   if (tmp->fd == fd)
    return (tmp->buf);
   else
    tmp = tmp->next;
  }
  if (tmp->fd == fd)
   return (tmp->buf);
  else
   tmp->next = new_t_buf(fd);
  return (tmp->next->buf);
 }
 else
  *buflst = new_t_buf(fd);
 return ((*buflst)->buf);
}

canonical_original_code:
static char *choose_buf(int fd, struct s_buf **buflst)
{
 struct s_buf *tmp;
 if (*buflst)
 {
  tmp = *buflst;
  while (tmp->next)
  {
   if (tmp->fd == fd)
    return (tmp->buf);
   else
    tmp = tmp->next;
  }
  if (tmp->fd == fd)
   return (tmp->buf);
  else
   tmp->next = new_t_buf(fd);
  return (tmp->next->buf);
 }
 else
  *buflst = new_t_buf(fd);
 return ((*buflst)->buf);
}

variable_types: fd int

variable_types: struct s_buf { int fd; char *buf; struct s_buf *next; } **

return_type: char *


decompiled_code:
void __fastcall smart_join(void **a1)
{
void *v1; // rbp

v1 = (void *)ft_strjoin(*a1);
free(*a1);
*a1 = (void *)ft_strdup(v1);
free(v1);
}

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

v1 = (void *)ft_strjoin(*a1);
free(*a1);
*a1 = (void *)ft_strdup(v1);
free(v1);
}

original_code:
void smart_join(char **line, char *prev)
{
 char *tmp;
 tmp = ft_strjoin(*line, prev);
 free(*line);
 *line = ft_strdup(tmp);
 free(tmp);
}

variable_types:
line
char **

variable_types:
prev
char *

variable_types:
tmp
char *


decompiled_code:
__int64 __fastcall check_buff(_BYTE *a1)
{
__int64 result; // rax
char v2; // dl

result = 0LL;
if ( a1 )
{
if ( !*a1 || *a1 == 10 )
{
result = 0LL;
}
else
{
do
v2 = a1[++result];
while ( v2 && v2 != 10 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1)
{
__int64 result; // rax
char v2; // dl

result = 0LL;
if ( a1 )
{
if ( !*a1 || *a1 == 10 )
{
result = 0LL;
}
else
{
do
v2 = a1[++result];
while ( v2 && v2 != 10 );
}
}
return result;
}

original_code:
ssize_t check_buff(char *tmp_buff)
{
 ssize_t i;
 i = 0;
 if (tmp_buff)
 {
  while (tmp_buff[i] && (tmp_buff[i] != '\n'))
   i++;
 }
 return (i);
}

canonical_original_code:
long check_buff(char *tmp_buff)
{
 long i;
 i = 0;
 if (tmp_buff)
 {
  while (tmp_buff[i] && (tmp_buff[i] != '\n'))
   i++;
 }
 return (i);
}

variable_types: i long

return_type: long


decompiled_code:
__int64 __fastcall handle_previous(_BYTE *a1, void **a2, _BYTE *a3)
{
__int64 v3; // r15
__int64 v5; // r14
__int64 v6; // rax
__int64 v7; // r12
__int64 v8; // rax

v3 = 0LL;
*a3 = 0;
if ( a1 )
{
v5 = ft_strlen();
v6 = check_buff(a1);
v7 = v6;
if ( v5 == v6 )
{
smart_join(a2);
}
else
{
ft_strsub(a1, 0LL, v6);
smart_join(a2);
v8 = ft_strsub(a1, (unsigned int)(v7 + 1), v5 - v7);
*a3 = 1;
v3 = v8;
}
}
return v3;
}

original_code:
char *handle_previous(char *prev, char **line, char *end)
{
 ssize_t i;
 ssize_t prev_len;
 *end = 0;
 if (prev)
 {
  prev_len = (ssize_t) ft_strlen(prev);
  i = check_buff(prev);
  if (i == prev_len)
  {
   smart_join(line, prev);
   prev = ((void *)0);
  }
  else
  {
   smart_join(line, ft_strsub(prev, 0, i));
   prev = ft_strsub(prev, (i + 1), (prev_len - i));
   *end = 1;
  }
 }
 return (prev);
}

canonical_original_code:
char *handle_previous(char *prev, char **line, char *end)
{
 long i;
 long prev_len;
 *end = 0;
 if (prev)
 {
  prev_len = (long) ft_strlen(prev);
  i = check_buff(prev);
  if (i == prev_len)
  {
   smart_join(line, prev);
   prev = ((void *)0);
  }
  else
  {
   smart_join(line, ft_strsub(prev, 0, i));
   prev = ft_strsub(prev, (i + 1), (prev_len - i));
   *end = 1;
  }
 }
 return (prev);
}

variable_types:
end
char *


decompiled_code:
__int64 __fastcall read_file(__int64 a1, void **a2, int a3)
{
__int64 v4; // rax
_BYTE *i; // r15
char v6; // al
int v7; // er12
__int64 v8; // rax
__int64 v9; // rbx
__int64 v10; // rdx
_QWORD *v11; // rbp
bool v12; // zf

v4 = ft_strnew(9LL);
if ( v4 )
{
for ( i = (_BYTE *)v4; ; ft_bzero(i, 9LL) )
{
v7 = read(a3, i, 8uLL);
if ( v7 < 0 )
break;
v8 = check_buff(i);
v9 = v8;
if ( v8 != 8 || i[8] == 10 )
{
v6 = i[v8];
if ( v6 == 10 || !v6 )
{
ft_strsub(i, 0LL, v9);
smart_join(a2);
if ( v9 <= 7 )
{
v10 = v7;
v11 = *(_QWORD **)a1;
v12 = v7 == v9;
v7 = 1;
*(_DWORD *)(*(_QWORD *)a1 + 8LL) = v12;
*v11 = ft_strsub(i, v9 + 1, v10 - (v9 + 1));
return (unsigned int)v7;
}
}
}
else
{
smart_join(a2);
}
}
}
else
{
v7 = -1;
}
return (unsigned int)v7;
}

original_code:
int read_file(t_nextline **nline, char **line, int fd)
{
 char *tmp_buff;
 ssize_t i;
 int read_res;
 if ((tmp_buff = ft_strnew(8 + 1)) == ((void *)0))
  return (-1);
 while ((read_res = read(fd, tmp_buff, 8)) >= 0)
 {
  i = check_buff(tmp_buff);
  if ((i == 8) && (tmp_buff[i] != '\n'))
   smart_join(line, tmp_buff);
  else if ((tmp_buff[i] == '\n') || (tmp_buff[i] == '\0'))
  {
   smart_join(line, ft_strsub(tmp_buff, 0, i));
   if (i < 8)
   {
    (*nline)->kill = (i == read_res);
    i += 1;
    (*nline)->prev = ft_strsub(tmp_buff, i, (read_res - i));
    return (1);
   }
  }
  ft_bzero(tmp_buff, 8 + 1);
 }
 return (read_res);
}

canonical_original_code:
int read_file(struct s_nextline **nline, char **line, int fd)
{
 char *tmp_buff;
 long i;
 int read_res;
 if ((tmp_buff = ft_strnew(8 + 1)) == ((void *)0))
  return (-1);
 while ((read_res = read(fd, tmp_buff, 8)) >= 0)
 {
  i = check_buff(tmp_buff);
  if ((i == 8) && (tmp_buff[i] != '\n'))
   smart_join(line, tmp_buff);
  else if ((tmp_buff[i] == '\n') || (tmp_buff[i] == '\0'))
  {
   smart_join(line, ft_strsub(tmp_buff, 0, i));
   if (i < 8)
   {
    (*nline)->kill = (i == read_res);
    i += 1;
    (*nline)->prev = ft_strsub(tmp_buff, i, (read_res - i));
    return (1);
   }
  }
  ft_bzero(tmp_buff, 8 + 1);
 }
 return (read_res);
}

variable_types: struct s_nextline { char *prev; int kill; } **


decompiled_code:
__int64 __fastcall get_next_line(int a1, void **a2)
{
__int64 v2; // rax
__int64 *v3; // rbx
__int64 result; // rax
_DWORD *v5; // rax
char v6[25]; // [rsp+1h] [rbp-19h] BYREF

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !nline_0 )
{
v5 = malloc(0x10uLL);
nline_0 = (__int64)v5;
v5[2] = 0;
*(_QWORD *)v5 = 0LL;
}
v2 = ft_strdup(&unk_2D0);
v3 = (__int64 *)nline_0;
*a2 = (void *)v2;
*v3 = handle_previous((_BYTE *)*v3, a2, v6);
result = 1LL;
if ( !v6[0] )
{
if ( *(_DWORD *)(nline_0 + 8) )
{
*(_DWORD *)(nline_0 + 8) = 0;
result = 0LL;
}
else
{
result = read_file((__int64)&nline_0, a2, a1);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, void **a2)
{
__int64 v2; // rax
__int64 *v3; // rbx
__int64 result; // rax
_DWORD *v5; // rax
char v6[25]; // [rsp+1h] [rbp-19h] BYREF

if ( !a2 )
return 0xFFFFFFFFLL;
if ( !nline_0 )
{
v5 = malloc(0x10uLL);
nline_0 = (__int64)v5;
v5[2] = 0;
*(_QWORD *)v5 = 0LL;
}
v2 = ft_strdup(&unk_2D0);
v3 = (__int64 *)nline_0;
*a2 = (void *)v2;
*v3 = func3((_BYTE *)*v3, a2, v6);
result = 1LL;
if ( !v6[0] )
{
if ( *(_DWORD *)(nline_0 + 8) )
{
*(_DWORD *)(nline_0 + 8) = 0;
result = 0LL;
}
else
{
result = func2((__int64)&nline_0, a2, a1);
}
}
return result;
}

original_code:
int get_next_line(int const fd, char **line)
{
 static t_nextline *nline = 0;
 char end;
 if (!line)
  return (-1);
 if (!nline)
 {
  nline = (t_nextline *) malloc(sizeof(t_nextline));
  nline->kill = 0;
  nline->prev = 0;
 }
 *line = ft_strdup("\0");
 nline->prev = handle_previous(nline->prev, line, &end);
 if (end)
  return (1);
 if (nline->kill)
 {
  nline->kill = 0;
  return (0);
 }
 return (read_file(&nline, line, fd));
}

canonical_original_code:
int get_next_line(int fd, char **line)
{
 static struct s_nextline *nline = 0;
 char end;
 if (!line)
  return (-1);
 if (!nline)
 {
  nline = (struct s_nextline *) malloc(sizeof(t_nextline));
  nline->kill = 0;
  nline->prev = 0;
 }
 *line = ft_strdup("\0");
 nline->prev = handle_previous(nline->prev, line, &end);
 if (end)
  return (1);
 if (nline->kill)
 {
  nline->kill = 0;
  return (0);
 }
 return (read_file(&nline, line, fd));
}

variable_types: struct s_nextline { char *prev; int kill; } *

variable_types: end char


decompiled_code:
__int64 __fastcall check_lredir(_QWORD *a1)
{
__int64 v2; // rdi
int v3; // eax
__int64 v4; // rdi
int v5; // ebp
int v6; // eax
__int64 v8; // rdi
__int64 v9; // [rsp+4h] [rbp-44h] BYREF
int v10; // [rsp+Ch] [rbp-3Ch]
__int64 v11[2]; // [rsp+10h] [rbp-38h] BYREF
int v12; // [rsp+20h] [rbp-28h]

v2 = a1[3];
v11[0] = 0x500000008LL;
v11[1] = 0x600000000LL;
v12 = -1;
v9 = 8LL;
v10 = -1;
if ( !v2 )
{
v8 = a1[2];
if ( v8 )
check_legality(v8, &v9);
goto LABEL_7;
}
v3 = check_legality(v2, v11);
v4 = a1[2];
v5 = v3;
if ( v4 )
{
v6 = check_legality(v4, &v9);
if ( !v5 )
return (unsigned int)-(v6 != 0);
goto LABEL_7;
}
if ( v3 )
{
LABEL_7:
parse_error(*a1);
return 0xFFFFFFFFLL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 v2; // rdi
int v3; // eax
__int64 v4; // rdi
int v5; // ebp
int v6; // eax
__int64 v8; // rdi
__int64 v9; // [rsp+4h] [rbp-44h] BYREF
int v10; // [rsp+Ch] [rbp-3Ch]
__int64 v11[2]; // [rsp+10h] [rbp-38h] BYREF
int v12; // [rsp+20h] [rbp-28h]

v2 = a1[3];
v11[0] = 0x500000008LL;
v11[1] = 0x600000000LL;
v12 = -1;
v9 = 8LL;
v10 = -1;
if ( !v2 )
{
v8 = a1[2];
if ( v8 )
check_legality(v8, &v9);
goto LABEL_7;
}
v3 = check_legality(v2, v11);
v4 = a1[2];
v5 = v3;
if ( v4 )
{
v6 = check_legality(v4, &v9);
if ( !v5 )
return (unsigned int)-(v6 != 0);
goto LABEL_7;
}
if ( v3 )
{
LABEL_7:
parse_error(*a1);
return 0xFFFFFFFFLL;
}
return 0xFFFFFFFFLL;
}

original_code:
int check_lredir(t_token *tok)
{
 int prev[5] = {STDCHAR, PIPE, QUOTE, SEMICOLON, -1};
 int next[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, next);
 else
  j = -1;
 if (i == 0)
 {
  if (j == 0)
   return (0);
 }
 else
  parse_error(tok->val);
 return (-1);
}

canonical_original_code:
int check_lredir(struct s_token *tok)
{
 int prev[5] = {STDCHAR, PIPE, QUOTE, SEMICOLON, -1};
 int next[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, next);
 else
  j = -1;
 if (i == 0)
 {
  if (j == 0)
   return (0);
 }
 else
  parse_error(tok->val);
 return (-1);
}

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

variable_types:
prev
int [5]

variable_types:
next
int [3]

variable_types: i int

variable_types: j int

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


decompiled_code:
__int64 __fastcall check_rredir(_QWORD *a1)
{
int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // [rsp+4h] [rbp-44h] BYREF
int v7; // [rsp+Ch] [rbp-3Ch]
__int64 v8[2]; // [rsp+10h] [rbp-38h] BYREF
int v9; // [rsp+20h] [rbp-28h]

v2 = -1;
v3 = a1[3];
v8[0] = 0x800000006LL;
v8[1] = 0x500000000LL;
v9 = -1;
v6 = 8LL;
v7 = -1;
if ( v3 )
v2 = check_legality(v3, v8);
v4 = a1[2];
if ( !v4 || (result = v2 | (unsigned int)check_legality(v4, &v6), (_DWORD)result) )
{
parse_error(*a1);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // [rsp+4h] [rbp-44h] BYREF
int v7; // [rsp+Ch] [rbp-3Ch]
__int64 v8[2]; // [rsp+10h] [rbp-38h] BYREF
int v9; // [rsp+20h] [rbp-28h]

v2 = -1;
v3 = a1[3];
v8[0] = 0x800000006LL;
v8[1] = 0x500000000LL;
v9 = -1;
v6 = 8LL;
v7 = -1;
if ( v3 )
v2 = check_legality(v3, v8);
v4 = a1[2];
if ( !v4 || (result = v2 | (unsigned int)check_legality(v4, &v6), (_DWORD)result) )
{
parse_error(*a1);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int check_rredir(t_token *tok)
{
 int prev[5] = {SEMICOLON, STDCHAR, QUOTE, PIPE, -1};
 int next[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, next);
 else
  j = -1;
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}

canonical_original_code:
int check_rredir(struct s_token *tok)
{
 int prev[5] = {SEMICOLON, STDCHAR, QUOTE, PIPE, -1};
 int next[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, next);
 else
  j = -1;
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}

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:
__int64 __fastcall check_pipe(_QWORD *a1)
{
int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // [rsp+4h] [rbp-24h] BYREF
int v7; // [rsp+Ch] [rbp-1Ch]

v2 = -1;
v3 = a1[3];
v6 = 8LL;
v7 = -1;
if ( v3 )
v2 = check_legality(v3, &v6);
v4 = a1[2];
if ( !v4 || (result = v2 | (unsigned int)check_legality(v4, &v6), (_DWORD)result) )
{
parse_error(*a1);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // [rsp+4h] [rbp-24h] BYREF
int v7; // [rsp+Ch] [rbp-1Ch]

v2 = -1;
v3 = a1[3];
v6 = 8LL;
v7 = -1;
if ( v3 )
v2 = check_legality(v3, &v6);
v4 = a1[2];
if ( !v4 || (result = v2 | (unsigned int)check_legality(v4, &v6), (_DWORD)result) )
{
parse_error(*a1);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int check_pipe(t_token *tok)
{
 int prev[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, prev);
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}

canonical_original_code:
int check_pipe(struct s_token *tok)
{
 int prev[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, prev);
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}

variable_types:
prev
int [3]


decompiled_code:
// attributes: thunk
__int64 __fastcall check_laredir(_QWORD *a1)
{
return check_pipe(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1)
{
return func2(a1);
}

original_code:
int check_laredir(t_token *tok)
{
 int prev[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, prev);
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}

canonical_original_code:
int check_laredir(struct s_token *tok)
{
 int prev[3] = {STDCHAR, QUOTE, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, prev);
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}


decompiled_code:
__int64 __fastcall check_raredir(_QWORD *a1)
{
int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rdi
__int64 result; // rax
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = -1;
v3 = a1[3];
v6[0] = 0xFFFFFFFF00000008LL;
if ( v3 )
v2 = check_legality(v3, v6);
v4 = a1[2];
if ( !v4 || (result = v2 | (unsigned int)check_legality(v4, v6), (_DWORD)result) )
{
parse_error(*a1);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rdi
__int64 result; // rax
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = -1;
v3 = a1[3];
v6[0] = 0xFFFFFFFF00000008LL;
if ( v3 )
v2 = check_legality(v3, v6);
v4 = a1[2];
if ( !v4 || (result = v2 | (unsigned int)check_legality(v4, v6), (_DWORD)result) )
{
parse_error(*a1);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int check_raredir(t_token *tok)
{
 int prev[2] = {STDCHAR, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, prev);
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}

canonical_original_code:
int check_raredir(struct s_token *tok)
{
 int prev[2] = {STDCHAR, -1};
 int i;
 int j;
 i = j = -1;
 if (tok->prev != ((void *)0))
  i = check_legality(tok->prev, prev);
 if (tok->next != ((void *)0))
  j = check_legality(tok->next, prev);
 if (i == 0 && j == 0)
  return (0);
 else
  parse_error(tok->val);
 return (-1);
}

variable_types:
prev
int [2]


decompiled_code:
__int64 invalid_format()
{
return kill_me("Invalid format");
}

canonical_decompiled_code:
__int64 func0()
{
return kill_me("Invalid format");
}

original_code:
void invalid_format(void)
{
 kill_me("Invalid format");
}

canonical_original_code:
void invalid_format()
{
 kill_me("Invalid format");
}


decompiled_code:
void __fastcall __noreturn not_unique_flag(char a1)
{
char v1[12]; // [rsp+Ch] [rbp-Ch] BYREF

v1[0] = a1;
ft_putstr_fd("This flag is used more than once : [", 2LL);
ft_putstr_fd(v1, 2LL);
ft_putstr_fd("]\n", 2LL);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(char a1)
{
char v1[12]; // [rsp+Ch] [rbp-Ch] BYREF

v1[0] = a1;
ft_putstr_fd("This flag is used more than once : [", 2LL);
ft_putstr_fd(v1, 2LL);
ft_putstr_fd("]\n", 2LL);
exit(1);
}

original_code:
void not_unique_flag(char flag)
{
 ft_putstr_fd("This flag is used more than once : [", 2);
 ft_putstr_fd(&flag, 2);
 ft_putstr_fd("]\n", 2);
 exit(1);
}

variable_types: flag char


decompiled_code:
void __fastcall enc_delete_lists(void *ptr, void *a2, void *a3)
{
void **v5; // rbx
_QWORD *v6; // rbp
void *v7; // rdi
void **v8; // rbp

v5 = (void **)a2;
v6 = (_QWORD *)*((_QWORD *)ptr + 4);
if ( !v6 )
goto LABEL_5;
do
{
v7 = (void *)v6[1];
*((_QWORD *)ptr + 4) = v6[2];
free(v7);
free(v6);
v6 = (_QWORD *)*((_QWORD *)ptr + 4);
}
while ( v6 );
if ( a2 )
{
do
{
v8 = v5;
v5 = (void **)v5[2];
free(*v8);
free(v8);
LABEL_5:
;
}
while ( v5 );
}
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
free(a3);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr, void *a2, void *a3)
{
void **v5; // rbx
_QWORD *v6; // rbp
void *v7; // rdi
void **v8; // rbp

v5 = (void **)a2;
v6 = (_QWORD *)*((_QWORD *)ptr + 4);
if ( !v6 )
goto LABEL_5;
do
{
v7 = (void *)v6[1];
*((_QWORD *)ptr + 4) = v6[2];
free(v7);
free(v6);
v6 = (_QWORD *)*((_QWORD *)ptr + 4);
}
while ( v6 );
if ( a2 )
{
do
{
v8 = v5;
v5 = (void **)v5[2];
free(*v8);
free(v8);
LABEL_5:
;
}
while ( v5 );
}
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
free(a3);
}

original_code:
static void enc_delete_lists(t_start *start, t_label *label, t_adr *adr)
{
 t_label *ltmp;
 t_lexer *tmp;
 while (start->lexer != ((void *)0))
 {
  tmp = start->lexer;
  start->lexer = start->lexer->next;
  free(tmp->value);
  free(tmp);
 }
 while (label != ((void *)0))
 {
  ltmp = label;
  label = label->next;
  free(ltmp->name);
  free(ltmp);
 }
 free(start->filename);
 free(start->name);
 free(start->comment);
 free(start);
 free(adr);
}

canonical_original_code:
static void enc_delete_lists(struct s_start *start, struct s_label *label, struct s_adr *adr)
{
 struct s_label *ltmp;
 struct s_lexer *tmp;
 while (start->lexer != ((void *)0))
 {
  tmp = start->lexer;
  start->lexer = start->lexer->next;
  free(tmp->value);
  free(tmp);
 }
 while (label != ((void *)0))
 {
  ltmp = label;
  label = label->next;
  free(ltmp->name);
  free(ltmp);
 }
 free(start->filename);
 free(start->name);
 free(start->comment);
 free(start);
 free(adr);
}

variable_types: struct s_start { char *filename; char *name; char *comment; int prog_size; 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; } *lexer; } *

variable_types: struct s_label { char *name; int address; struct s_label *next; } *

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


decompiled_code:
void __fastcall enc_find_label_jmp_adrss(__int64 a1, int *a2, __int64 *a3)
{
__int64 *v3; // rbx
__int64 v4; // r12
__int64 v5; // rax
int v6; // edx
int v7; // ecx
__int64 v8; // rdi
int v9; // eax
int v10; // edi
int buf[11]; // [rsp+Ch] [rbp-2Ch] BYREF

buf[0] = 0;
if ( a3 )
{
v3 = a3;
while ( 1 )
{
v4 = *v3;
v5 = ft_strjoinc(*(_QWORD *)(a1 + 8) + 2LL, 58LL);
if ( !(unsigned int)ft_strcmp(v5, v4) )
break;
v3 = (__int64 *)v3[2];
if ( !v3 )
return;
}
v6 = *((_DWORD *)v3 + 2);
v7 = a2[1];
v8 = (unsigned int)(v6 - v7);
if ( v7 > v6 )
v8 = (unsigned int)(v6 + 0x10000 - v7);
buf[0] = v8;
v9 = swa_swap_int_by_params(v8, 2LL);
v10 = *a2;
buf[0] = v9;
write(v10, buf, 2uLL);
a2[2] += 2;
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int *a2, __int64 *a3)
{
__int64 *v3; // rbx
__int64 v4; // r12
__int64 v5; // rax
int v6; // edx
int v7; // ecx
__int64 v8; // rdi
int v9; // eax
int v10; // edi
int buf[11]; // [rsp+Ch] [rbp-2Ch] BYREF

buf[0] = 0;
if ( a3 )
{
v3 = a3;
while ( 1 )
{
v4 = *v3;
v5 = ft_strjoinc(*(_QWORD *)(a1 + 8) + 2LL, 58LL);
if ( !(unsigned int)ft_strcmp(v5, v4) )
break;
v3 = (__int64 *)v3[2];
if ( !v3 )
return;
}
v6 = *((_DWORD *)v3 + 2);
v7 = a2[1];
v8 = (unsigned int)(v6 - v7);
if ( v7 > v6 )
v8 = (unsigned int)(v6 + 0x10000 - v7);
buf[0] = v8;
v9 = swa_swap_int_by_params(v8, 2LL);
v10 = *a2;
buf[0] = v9;
write(v10, buf, 2uLL);
a2[2] += 2;
}
}

original_code:
void enc_find_label_jmp_adrss(t_lexer *lex, t_adr *adr, t_label *lab)
{
 t_label *save;
 int i;
 i = 0;
 save = lab;
 while (lab != ((void *)0))
 {
  if (ft_strcmp(ft_strjoinc(lex->value + 2, ':'), lab->name) == 0)
  {
   if (adr->linepos > lab->address)
    i = 65536 + lab->address - adr->linepos;
   else
    i = lab->address - adr->linepos;
   i = swa_swap_int_by_params(i, 2);
   write(adr->fd, &i, 2);
   adr->currentpos += 2;
   break ;
  }
  lab = lab->next;
 }
 lab = save;
}

canonical_original_code:
void enc_find_label_jmp_adrss(struct s_lexer *lex, struct s_adr *adr, struct s_label *lab)
{
 struct s_label *save;
 int i;
 i = 0;
 save = lab;
 while (lab != ((void *)0))
 {
  if (ft_strcmp(ft_strjoinc(lex->value + 2, ':'), lab->name) == 0)
  {
   if (adr->linepos > lab->address)
    i = 65536 + lab->address - adr->linepos;
   else
    i = lab->address - adr->linepos;
   i = swa_swap_int_by_params(i, 2);
   write(adr->fd, &i, 2);
   adr->currentpos += 2;
   break ;
  }
  lab = lab->next;
 }
 lab = save;
}

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

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

user_defined_types: struct s_label { char *name; int address; struct s_label *next; }


decompiled_code:
__int64 __fastcall enc_encoding(void *ptr, void *a2)
{
int *v3; // rax
const char *v4; // rdi
int *v5; // r12
int v6; // eax
__int64 v7; // rax
_DWORD *i; // rdi

wri_change_name();
v3 = (int *)malloc(0x18uLL);
v4 = *(const char **)ptr;
v3[1] = 0;
v5 = v3;
v6 = open(v4, 577, 420LL);
*v5 = v6;
if ( v6 < 0 )
kill_me("Impossible to create output file");
wri_write_name_and_comment(ptr, v5);
v7 = *((_QWORD *)ptr + 4);
if ( v7 )
{
while ( *(_DWORD *)v7 != 16 )
{
v7 = *(_QWORD *)(v7 + 16);
*((_QWORD *)ptr + 4) = v7;
if ( !v7 )
goto LABEL_9;
}
for ( i = (_DWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
*((_QWORD *)v5 + 1) = 0LL;
*((_QWORD *)v5 + 2) = 0LL;
i = (_DWORD *)*((_QWORD *)enc_fill_file_constprop_0(i, v5, (__int64)a2) + 2);
v5[1] += v5[2];
}
}
LABEL_9:
enc_delete_lists(ptr, a2, v5);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *ptr, void *a2)
{
int *v3; // rax
const char *v4; // rdi
int *v5; // r12
int v6; // eax
__int64 v7; // rax
_DWORD *i; // rdi

wri_change_name();
v3 = (int *)malloc(0x18uLL);
v4 = *(const char **)ptr;
v3[1] = 0;
v5 = v3;
v6 = open(v4, 577, 420LL);
*v5 = v6;
if ( v6 < 0 )
kill_me("Impossible to create output file");
wri_write_name_and_comment(ptr, v5);
v7 = *((_QWORD *)ptr + 4);
if ( v7 )
{
while ( *(_DWORD *)v7 != 16 )
{
v7 = *(_QWORD *)(v7 + 16);
*((_QWORD *)ptr + 4) = v7;
if ( !v7 )
goto LABEL_9;
}
for ( i = (_DWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
*((_QWORD *)v5 + 1) = 0LL;
*((_QWORD *)v5 + 2) = 0LL;
i = (_DWORD *)*((_QWORD *)enc_fill_file_constprop_0(i, v5, (__int64)a2) + 2);
v5[1] += v5[2];
}
}
LABEL_9:
func0(ptr, a2, v5);
return 0LL;
}

original_code:
int enc_encoding(t_start *start, t_label *label)
{
 t_adr *adr;
 wri_change_name(start);
 adr = (t_adr *)malloc(sizeof(t_adr));
 adr->linepos = 0;
 if ((adr->fd = open(start->filename, 0100 | 01000 | 01, 0644)) < 0)
  kill_me("Impossible to create output file");
 wri_write_name_and_comment(start, adr);
 while (start->lexer != ((void *)0) && start->lexer->token != OP)
  start->lexer = start->lexer->next;
 while (start->lexer != ((void *)0))
 {
  adr->currentpos = 0;
  adr->getindex = 0;
  adr->index = 0;
  adr->onlive = 0;
  start->lexer = enc_fill_file(start->lexer, adr, label);
  start->lexer = start->lexer->next;
  adr->linepos += adr->currentpos;
 }
 enc_delete_lists(start, label, adr);
 return (0);
}

canonical_original_code:
int enc_encoding(struct s_start *start, struct s_label *label)
{
 struct s_adr *adr;
 wri_change_name(start);
 adr = (struct s_adr *)malloc(sizeof(t_adr));
 adr->linepos = 0;
 if ((adr->fd = open(start->filename, 0100 | 01000 | 01, 0644)) < 0)
  kill_me("Impossible to create output file");
 wri_write_name_and_comment(start, adr);
 while (start->lexer != ((void *)0) && start->lexer->token != OP)
  start->lexer = start->lexer->next;
 while (start->lexer != ((void *)0))
 {
  adr->currentpos = 0;
  adr->getindex = 0;
  adr->index = 0;
  adr->onlive = 0;
  start->lexer = enc_fill_file(start->lexer, adr, label);
  start->lexer = start->lexer->next;
  adr->linepos += adr->currentpos;
 }
 enc_delete_lists(start, label, adr);
 return (0);
}


decompiled_code:
char *__fastcall ft_memchr(char *a1, unsigned __int8 a2, __int64 a3)
{
__int64 i; // rax

if ( a2 == *a1 )
return a1;
if ( !a3 )
return 0LL;
for ( i = 1LL; a1[i] != a2; ++i )
{
if ( a3 == i )
return 0LL;
}
return &a1[(int)i];
}

canonical_decompiled_code:
char *__fastcall func0(char *a1, unsigned __int8 a2, __int64 a3)
{
__int64 i; // rax

if ( a2 == *a1 )
return a1;
if ( !a3 )
return 0LL;
for ( i = 1LL; a1[i] != a2; ++i )
{
if ( a3 == i )
return 0LL;
}
return &a1[(int)i];
}

original_code:
void *ft_memchr(const void *s, int c, size_t n)
{
 unsigned char ch;
 char *tmp;
 int i;
 i = 0;
 ch = (unsigned char)c;
 tmp = (char*)s;
 while (tmp[i] != ch && n > 0)
 {
  i++;
  n--;
 }
 if (tmp[i] == ch)
 {
  while (i > 0)
  {
   s++;
   i--;
  }
  return ((char*)s);
 }
 else
  return (((void *)0));
}

canonical_original_code:
void *ft_memchr(void *s, int c, unsigned long n)
{
 unsigned char ch;
 char *tmp;
 int i;
 i = 0;
 ch = (unsigned char)c;
 tmp = (char *)s;
 while (tmp[i] != ch && n > 0)
 {
  i++;
  n--;
 }
 if (tmp[i] == ch)
 {
  while (i > 0)
  {
   s++;
   i--;
  }
  return ((char *)s);
 }
 else
  return (((void *)0));
}

variable_types:
s
void *

variable_types: c int

variable_types:
n
unsigned long

variable_types:
ch
unsigned char

variable_types:
tmp
char *

return_type: void *


decompiled_code:
__int64 __fastcall print_format(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rdx

if ( *(_BYTE *)(*(_QWORD *)a1 + 1LL) == 37 )
{
ft_putchar_fd(37LL, 1LL);
*(_QWORD *)a1 += 2LL;
result = 1LL;
}
else
{
if ( !*(_QWORD *)a3 )
kill_me("found an unparsed format ???");
result = print_arg(a2);
v5 = *(_QWORD *)(*(_QWORD *)a3 + 64LL);
*(_QWORD *)a1 += *(_QWORD *)(*(_QWORD *)a3 + 40LL);
*(_QWORD *)a3 = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rdx

if ( *(_BYTE *)(*(_QWORD *)a1 + 1LL) == 37 )
{
ft_putchar_fd(37LL, 1LL);
*(_QWORD *)a1 += 2LL;
result = 1LL;
}
else
{
if ( !*(_QWORD *)a3 )
kill_me("found an unparsed format ???");
result = print_arg(a2);
v5 = *(_QWORD *)(*(_QWORD *)a3 + 64LL);
*(_QWORD *)a1 += *(_QWORD *)(*(_QWORD *)a3 + 40LL);
*(_QWORD *)a3 = v5;
}
return result;
}

original_code:
int print_format(const char **format, va_list *ap, t_format **list)
{
 int printed;
 printed = 0;
 if (*(*format + 1) == '%')
 {
  ft_putchar_fd('%', 1);
  printed++;
  (*format) += 2;
 }
 else
 {
  if (!(*list))
   kill_me("found an unparsed format ???");
  printed = print_arg(ap, *list);
  *format += (*list)->length;
  *list = (*list)->next;
 }
 return (printed);
}

canonical_original_code:
int print_format(char **format, __builtin_va_list *ap, struct s_format **list)
{
 int printed;
 printed = 0;
 if (*(*format + 1) == '%')
 {
  ft_putchar_fd('%', 1);
  printed++;
  (*format) += 2;
 }
 else
 {
  if (!(*list))
   kill_me("found an unparsed format ???");
  printed = print_arg(ap, *list);
  *format += (*list)->length;
  *list = (*list)->next;
 }
 return (printed);
}

variable_types:
format
char **

variable_types:
ap
__builtin_va_list *

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

variable_types: printed int


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

result = *a1;
*(_DWORD *)result = a2;
*(_DWORD *)(result + 4) = -1;
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(result + 16) = 0xFFFFFFFF00000000LL;
*(_QWORD *)(result + 24) = 0LL;
*(_BYTE *)(result + 32) = 0;
*(_QWORD *)(result + 40) = 0LL;
*(_QWORD *)(result + 64) = 0LL;
return result;
}

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

result = *a1;
*(_DWORD *)result = a2;
*(_DWORD *)(result + 4) = -1;
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(result + 16) = 0xFFFFFFFF00000000LL;
*(_QWORD *)(result + 24) = 0LL;
*(_BYTE *)(result + 32) = 0;
*(_QWORD *)(result + 40) = 0LL;
*(_QWORD *)(result + 64) = 0LL;
return result;
}

original_code:
void init_format(t_format **format, int start)
{
 (*format)->arg_nb = -1;
 (*format)->start = start;
 (*format)->f_list = ((void *)0);
 (*format)->m_width = 0;
 (*format)->preci = -1;
 (*format)->l_mod = ((void *)0);
 (*format)->conv = 0;
 (*format)->length = 0;
 (*format)->next = ((void *)0);
}

canonical_original_code:
void init_format(struct s_format **format, int start)
{
 (*format)->arg_nb = -1;
 (*format)->start = start;
 (*format)->f_list = ((void *)0);
 (*format)->m_width = 0;
 (*format)->preci = -1;
 (*format)->l_mod = ((void *)0);
 (*format)->conv = 0;
 (*format)->length = 0;
 (*format)->next = ((void *)0);
}

variable_types: start int

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 parse_format(int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
__int64 v5; // rbx
__int64 v6; // rbx
__int64 v7; // rbx
__int64 v8; // rax
_BYTE *v9; // rbx
int v11; // eax
__int64 v12[6]; // [rsp+8h] [rbp-30h] BYREF

v12[0] = (__int64)malloc(0x48uLL);
if ( !v12[0] )
impossible_malloc("t_format");
LODWORD(v4) = 1;
init_format(v12, a1);
v5 = v12[0];
*(_QWORD *)(v5 + 48) = ft_strdup(a2);
v6 = v12[0];
*(_QWORD *)(v6 + 40) = ft_strlen(a2);
v7 = 1LL;
*(_BYTE *)(v12[0] + 32) = *(_BYTE *)(a2 + *(_QWORD *)(v12[0] + 40) - 1);
v8 = ft_strchr(a2, 42LL);
*(_DWORD *)(v12[0] + 56) = v8 != 0;
if ( (unsigned int)ft_isdigit((unsigned int)*(char *)(a2 + 1)) )
{
v11 = set_argnb(v12, 1LL, a2);
v7 = v11;
LODWORD(v4) = v11;
}
v9 = (_BYTE *)(a2 + v7);
if ( ft_strchr("#0- +", (unsigned int)(char)*v9) )
{
v4 = (int)set_flags(v12, (unsigned int)v4, a2);
v9 = (_BYTE *)(a2 + v4);
}
if ( (unsigned int)ft_isdigit((unsigned int)(char)*v9) )
{
set_minwidth(v12, (unsigned int)v4, a2);
}
else if ( *v9 == 46 )
{
set_precision(v12, (unsigned int)v4, a2);
}
else if ( ft_strchr("hljtzqLv", (unsigned int)(char)*v9) )
{
set_lenmod(v12, (unsigned int)v4, a2);
}
return list_pushback(a3, v12);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
__int64 v5; // rbx
__int64 v6; // rbx
__int64 v7; // rbx
__int64 v8; // rax
_BYTE *v9; // rbx
int v11; // eax
__int64 v12[6]; // [rsp+8h] [rbp-30h] BYREF

v12[0] = (__int64)malloc(0x48uLL);
if ( !v12[0] )
impossible_malloc("t_format");
LODWORD(v4) = 1;
func1(v12, a1);
v5 = v12[0];
*(_QWORD *)(v5 + 48) = ft_strdup(a2);
v6 = v12[0];
*(_QWORD *)(v6 + 40) = ft_strlen(a2);
v7 = 1LL;
*(_BYTE *)(v12[0] + 32) = *(_BYTE *)(a2 + *(_QWORD *)(v12[0] + 40) - 1);
v8 = ft_strchr(a2, 42LL);
*(_DWORD *)(v12[0] + 56) = v8 != 0;
if ( (unsigned int)ft_isdigit((unsigned int)*(char *)(a2 + 1)) )
{
v11 = set_argnb(v12, 1LL, a2);
v7 = v11;
LODWORD(v4) = v11;
}
v9 = (_BYTE *)(a2 + v7);
if ( ft_strchr("#0- +", (unsigned int)(char)*v9) )
{
v4 = (int)set_flags(v12, (unsigned int)v4, a2);
v9 = (_BYTE *)(a2 + v4);
}
if ( (unsigned int)ft_isdigit((unsigned int)(char)*v9) )
{
set_minwidth(v12, (unsigned int)v4, a2);
}
else if ( *v9 == 46 )
{
set_precision(v12, (unsigned int)v4, a2);
}
else if ( ft_strchr("hljtzqLv", (unsigned int)(char)*v9) )
{
set_lenmod(v12, (unsigned int)v4, a2);
}
return list_pushback(a3, v12);
}

original_code:
void parse_format(int start, char *s, t_format **list)
{
 t_format *format;
 int i;
 int j;
 if ((format = (t_format *) malloc(sizeof(t_format))) == ((void *)0))
  impossible_malloc("t_format");
 i = j = 1;
 init_format(&format, start);
 format->format = ft_strdup(s);
 format->length = ft_strlen(s);
 format->conv = s[(format->length - 1)];
 format->has_star = (ft_strchr(s, '*') != ((void *)0) ? 1 : 0);
 if (ft_isdigit(s[i]))
  i = set_argnb(&format, i, s);
 if (ft_strchr("#0- +", s[i]))
  i = set_flags(&format, i, s);
 if (ft_isdigit(s[i]))
  i = set_minwidth(&format, i, s);
 else if (s[i] == '.')
  i = set_precision(&format, i, s);
 else if (ft_strchr("hljtzqLv", s[i]))
  set_lenmod(&format, i, s);
 list_pushback(list, &format);
}

canonical_original_code:
void parse_format(int start, char *s, struct s_format **list)
{
 struct s_format *format;
 int i;
 int j;
 if ((format = (struct s_format *) malloc(sizeof(t_format))) == ((void *)0))
  impossible_malloc("t_format");
 i = j = 1;
 init_format(&format, start);
 format->format = ft_strdup(s);
 format->length = ft_strlen(s);
 format->conv = s[(format->length - 1)];
 format->has_star = (ft_strchr(s, '*') != ((void *)0) ? 1 : 0);
 if (ft_isdigit(s[i]))
  i = set_argnb(&format, i, s);
 if (ft_strchr("#0- +", s[i]))
  i = set_flags(&format, i, s);
 if (ft_isdigit(s[i]))
  i = set_minwidth(&format, i, s);
 else if (s[i] == '.')
  i = set_precision(&format, i, s);
 else if (ft_strchr("hljtzqLv", s[i]))
  set_lenmod(&format, i, s);
 list_pushback(list, &format);
}

variable_types:
s
char *

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

variable_types: i int

variable_types: j int


decompiled_code:
__int64 __fastcall get_format(char *a1, void *a2)
{
char v2; // al
__int64 v4; // rbx
int v5; // er13
int v6; // ebp
__int64 v7; // rdi
__int64 v9; // rdi
char *v10; // r14
__int64 v11; // rdx
__int64 v12[6]; // [rsp+8h] [rbp-30h] BYREF

v2 = *a1;
v12[0] = 0LL;
if ( !v2 )
{
v7 = 0LL;
goto LABEL_6;
}
v4 = 0LL;
while ( 1 )
{
v5 = v4;
v6 = ++v4;
if ( v2 != 37 )
goto LABEL_4;
v9 = (unsigned int)a1[v4];
if ( a1[v4] != 37 )
{
v10 = &a1[v4];
v11 = 2LL;
if ( a1[v4] )
{
do
{
if ( (unsigned int)ft_isalpha(v9, a2, v11) )
break;
v9 = (unsigned int)*++v10;
++v6;
}
while ( (_BYTE)v9 );
v11 = v6 - v5 + 1;
}
a2 = (void *)ft_strsub(a1, (unsigned int)(v4 - 1), v11);
parse_format(v5, (__int64)a2, (__int64)v12);
free(a2);
LABEL_4:
v2 = a1[v4];
if ( !v2 )
break;
}
}
v7 = v12[0];
LABEL_6:
check_for_arg_nb(v7);
return v12[0];
}

original_code:
t_format *get_format(const char *format)
{
 int i;
 int j;
 t_format *list;
 char *found;
 i = 0;
 j = 0;
 list = ((void *)0);
 while (format[i])
 {
  if ((format[i] == '%') && (format[i + 1] != '%'))
  {
   j = i + 1;
   while (format[j] && !ft_isalpha(format[j]))
    j++;
   found = ft_strsub(format, i, (j - i) + 1);
   parse_format(i, found, &list);
   free(found);
  }
  i++;
 }
 check_for_arg_nb(list);
 return (list);
}

canonical_original_code:
struct s_format *get_format(char *format)
{
 int i;
 int j;
 struct s_format *list;
 char *found;
 i = 0;
 j = 0;
 list = ((void *)0);
 while (format[i])
 {
  if ((format[i] == '%') && (format[i + 1] != '%'))
  {
   j = i + 1;
   while (format[j] && !ft_isalpha(format[j]))
    j++;
   found = ft_strsub(format, i, (j - i) + 1);
   parse_format(i, found, &list);
   free(found);
  }
  i++;
 }
 check_for_arg_nb(list);
 return (list);
}

variable_types:
format
char *

variable_types:
found
char *

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


decompiled_code:
__int64 ft_printf(char *a1, void *a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, ...)
{
unsigned int v6; // er12
__int64 v7; // rbp
__int64 i; // rdi
char *v11; // [rsp+8h] [rbp-F0h] BYREF
__int64 v12; // [rsp+10h] [rbp-E8h] BYREF
gcc_va_list va; // [rsp+18h] [rbp-E0h] BYREF
void *v14; // [rsp+38h] [rbp-C0h]
__int64 v15; // [rsp+40h] [rbp-B8h]
__int64 v16; // [rsp+48h] [rbp-B0h]
__int64 v17; // [rsp+50h] [rbp-A8h]
__int64 v18; // [rsp+58h] [rbp-A0h]

va_start(va, a6);
v11 = a1;
v14 = a2;
v15 = a3;
v16 = a4;
v17 = a5;
v18 = a6;
v6 = 0;
va[0].gp_offset = 8;
v12 = get_format(a1, a2);
v7 = v12;
for ( i = (unsigned int)*a1; *v11; i = (unsigned int)*v11 )
{
while ( (_BYTE)i != 37 )
{
++v6;
ft_putchar_fd(i, 1LL);
i = (unsigned int)*++v11;
if ( !*v11 )
goto LABEL_6;
}
v6 += print_format((__int64)&v11, (__int64)va, (__int64)&v12);
}
LABEL_6:
free_format(v7);
return v6;
}

original_code:
int ft_printf(const char *format, ...)
{
 t_format *list;
 int nb_printed;
 va_list ap;
 t_format *save;
 __builtin_va_start(ap,format);
 nb_printed = 0;
 list = get_format(format);
 save = list;
 while (*format)
 {
  if (*format != '%')
  {
   ft_putchar_fd(*format, 1);
   nb_printed++;
   format++;
  }
  else
   nb_printed += print_format(&format, &ap, &list);
 }
 __builtin_va_end(ap);
 free_format(save);
 return (nb_printed);
}

canonical_original_code:
int ft_printf(char *format, ...)
{
 struct s_format *list;
 int nb_printed;
 __builtin_va_list ap;
 struct s_format *save;
 __builtin_va_start(ap,format);
 nb_printed = 0;
 list = get_format(format);
 save = list;
 while (*format)
 {
  if (*format != '%')
  {
   ft_putchar_fd(*format, 1);
   nb_printed++;
   format++;
  }
  else
   nb_printed += print_format(&format, &ap, &list);
 }
 __builtin_va_end(ap);
 free_format(save);
 return (nb_printed);
}


decompiled_code:
__int64 cmd_createor()
{
__int64 result; // rax

result = cmd_create(&unk_A2);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 0;
return result;
}

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

result = cmd_create(&unk_A2);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 0;
return result;
}

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

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

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


decompiled_code:
__int64 cmd_createxor()
{
__int64 result; // rax

result = cmd_create(&unk_A5);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 0;
return result;
}

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

result = cmd_create(&unk_A5);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 0;
return result;
}

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

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

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


decompiled_code:
__int64 cmd_createldi()
{
__int64 result; // rax

result = cmd_create(&unk_A9);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 1;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax

result = cmd_create(&unk_A9);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 1;
return result;
}

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

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

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 cmd_createsti()
{
__int64 result; // rax

result = cmd_create(&unk_AD);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 1;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

result = cmd_create(&unk_AD);
*(_WORD *)(result + 8) = 259;
*(_BYTE *)(result + 10) = 1;
return result;
}

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

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


decompiled_code:
__int64 cmd_createlld()
{
__int64 result; // rax

result = cmd_create(&unk_B1);
*(_WORD *)(result + 8) = 258;
*(_BYTE *)(result + 10) = 0;
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax

result = cmd_create(&unk_B1);
*(_WORD *)(result + 8) = 258;
*(_BYTE *)(result + 10) = 0;
return result;
}

original_code:
t_cmd *cmd_createlld(void)
{
 t_cmd *cmd;
 cmd = cmd_create("lld");
 cmd->nb_arg = 2;
 cmd->has_encoding = 1;
 cmd->is_idx = 0;
 return (cmd);
}

canonical_original_code:
struct s_cmd *cmd_createlld()
{
 struct s_cmd *cmd;
 cmd = cmd_create("lld");
 cmd->nb_arg = 2;
 cmd->has_encoding = 1;
 cmd->is_idx = 0;
 return (cmd);
}


decompiled_code:
void __noreturn prt_err_usage()
{
ft_putstr_fd("Usage :\n", 2LL);
ft_putstr_fd("\t[-dump nbr_cycles] [[-n number] champion1.cor] ...\n", 2LL);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
ft_putstr_fd("Usage :\n", 2LL);
ft_putstr_fd("\t[-dump nbr_cycles] [[-n number] champion1.cor] ...\n", 2LL);
exit(1);
}

original_code:
void prt_err_usage(void)
{
 ft_putstr_fd("Usage :\n", 2);
 ft_putstr_fd("\t[-dump nbr_cycles] [[-n number] champion1.cor] ...\n", 2);
 exit(1);
}

canonical_original_code:
void prt_err_usage()
{
 ft_putstr_fd("Usage :\n", 2);
 ft_putstr_fd("\t[-dump nbr_cycles] [[-n number] champion1.cor] ...\n", 2);
 exit(1);
}


decompiled_code:
void __noreturn ptr_err_heroneeded()
{
ft_putstr_fd("-n option needs to be followed by a hero file\n", 2LL);
prt_err_usage();
}

canonical_decompiled_code:
void __noreturn func1()
{
ft_putstr_fd("-n option needs to be followed by a hero file\n", 2LL);
func0();
}

original_code:
void ptr_err_heroneeded(void)
{
 ft_putstr_fd("-n option needs to be followed by a hero file\n", 2);
 prt_err_usage();
}

canonical_original_code:
void ptr_err_heroneeded()
{
 ft_putstr_fd("-n option needs to be followed by a hero file\n", 2);
 prt_err_usage();
}


decompiled_code:
void __noreturn ptr_err_scary()
{
ft_putstr_fd("Too scared to fight others ? (Need at least 1 hero)\n", 2LL);
prt_err_usage();
}

canonical_decompiled_code:
void __noreturn func2()
{
ft_putstr_fd("Too scared to fight others ? (Need at least 1 hero)\n", 2LL);
func0();
}

original_code:
void ptr_err_scary(void)
{
 ft_putstr_fd("Too scared to fight others ? (Need at least 1 hero)\n", 2);
 prt_err_usage();
}

canonical_original_code:
void ptr_err_scary()
{
 ft_putstr_fd("Too scared to fight others ? (Need at least 1 hero)\n", 2);
 prt_err_usage();
}


decompiled_code:
void __noreturn ptr_err_battleroyal()
{
ft_putstr_fd("This is not SPARTAAAAAA ! (4 heroes max)\n", 2LL);
prt_err_usage();
}

canonical_decompiled_code:
void __noreturn func3()
{
ft_putstr_fd("This is not SPARTAAAAAA ! (4 heroes max)\n", 2LL);
func0();
}

original_code:
void ptr_err_battleroyal(void)
{
 ft_putstr_fd("This is not SPARTAAAAAA ! (4 heroes max)\n", 2);
 prt_err_usage();
}

canonical_original_code:
void ptr_err_battleroyal()
{
 ft_putstr_fd("This is not SPARTAAAAAA ! (4 heroes max)\n", 2);
 prt_err_usage();
}


decompiled_code:
__int64 __fastcall pressed_key_home(_BYTE *a1, __int64 a2)
{
__int64 result; // rax
int v3; // ebp
char *v4; // rax

result = 0LL;
if ( *a1 == 27 && a1[1] == 91 && a1[2] == 72 && !a1[3] )
{
ft_strlen(*(_QWORD *)(a2 + 16));
v3 = *(_DWORD *)a2;
if ( *(int *)a2 > 0 )
{
do
{
v4 = tgetstr("le", 0LL);
tputs(v4, 1, (int (*)(int))&out);
--v3;
}
while ( v3 );
}
*(_DWORD *)a2 = 0;
result = 1LL;
}
return result;
}

original_code:
int pressed_key_home(char *c, t_print *print)
{
 int i;
 int j;
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 72 && c[3] == 0))
  return (0);
 i = ft_strlen(print->line);
 j = i - print->pos;
 i -= j;
 while (i > 0)
 {
  tputs(tgetstr("le", ((void *)0)), 1, out);
  i--;
 }
 print->pos = 0;
 return (1);
}

canonical_original_code:
int pressed_key_home(char *c, struct s_print *print)
{
 int i;
 int j;
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 72 && c[3] == 0))
  return (0);
 i = ft_strlen(print->line);
 j = i - print->pos;
 i -= j;
 while (i > 0)
 {
  tputs(tgetstr("le", ((void *)0)), 1, out);
  i--;
 }
 print->pos = 0;
 return (1);
}

variable_types:
c
char *

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

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


decompiled_code:
__int64 __fastcall pressed_key_end(_BYTE *a1, __int64 a2)
{
__int64 result; // rax
int v3; // ebp
char *v4; // rax

result = 0LL;
if ( *a1 == 27 && a1[1] == 91 && a1[2] == 70 && !a1[3] )
{
v3 = ft_strlen(*(_QWORD *)(a2 + 16)) - *(_DWORD *)a2;
if ( v3 > 0 )
{
do
{
v4 = tgetstr("nd", 0LL);
tputs(v4, 1, (int (*)(int))&out);
--v3;
}
while ( v3 );
}
*(_DWORD *)a2 = ft_strlen(*(_QWORD *)(a2 + 16));
result = 1LL;
}
return result;
}

original_code:
int pressed_key_end(char *c, t_print *print)
{
 int i;
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 70 && c[3] == 0))
  return (0);
 i = ft_strlen(print->line);
 i -= print->pos;
 while (i > 0)
 {
  tputs(tgetstr("nd", ((void *)0)), 1, out);
  i--;
 }
 print->pos = ft_strlen(print->line);
 return (1);
}

canonical_original_code:
int pressed_key_end(char *c, struct s_print *print)
{
 int i;
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 70 && c[3] == 0))
  return (0);
 i = ft_strlen(print->line);
 i -= print->pos;
 while (i > 0)
 {
  tputs(tgetstr("nd", ((void *)0)), 1, out);
  i--;
 }
 print->pos = ft_strlen(print->line);
 return (1);
}

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


decompiled_code:
_BOOL8 __fastcall pressed_key_tab(_BYTE *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == 9 )
result = a1[1] == 0;
return result;
}

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

result = 0LL;
if ( *a1 == 9 )
result = a1[1] == 0;
return result;
}

original_code:
int pressed_key_tab(char *c, t_print *print)
{
 if (!(c[0] == 9 && c[1] == 0))
  return (0);
 (void)print;
 return (1);
}

canonical_original_code:
int pressed_key_tab(char *c, struct s_print *print)
{
 if (!(c[0] == 9 && c[1] == 0))
  return (0);
 (void)print;
 return (1);
}


decompiled_code:
__int64 __fastcall pressed_key_del(_BYTE *a1, int *a2)
{
__int64 result; // rax
int v3; // ebx
int v4; // er8

result = 0LL;
if ( *a1 == 27 && a1[1] == 91 && a1[2] == 51 && a1[3] == 126 && !a1[4] )
{
v3 = *a2;
v4 = ft_strlen(*((_QWORD *)a2 + 2));
result = 1LL;
if ( v3 < v4 )
{
delete_right(a2);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1, int *a2)
{
__int64 result; // rax
int v3; // ebx
int v4; // er8

result = 0LL;
if ( *a1 == 27 && a1[1] == 91 && a1[2] == 51 && a1[3] == 126 && !a1[4] )
{
v3 = *a2;
v4 = ft_strlen(*((_QWORD *)a2 + 2));
result = 1LL;
if ( v3 < v4 )
{
delete_right(a2);
result = 1LL;
}
}
return result;
}

original_code:
int pressed_key_del(char *c, t_print *print)
{
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 51 && c[3] == 126 && c[4] == 0))
  return (0);
 if (print->pos < (int)ft_strlen(print->line))
  delete_right(print);
 return (1);
}

canonical_original_code:
int pressed_key_del(char *c, struct s_print *print)
{
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 51 && c[3] == 126 && c[4] == 0))
  return (0);
 if (print->pos < (int)ft_strlen(print->line))
  delete_right(print);
 return (1);
}


decompiled_code:
__int64 __fastcall ft_print_dev_info(_QWORD *a1)
{
_BYTE *v2; // rdi
__int64 result; // rax

v2 = (_BYTE *)a1[7];
if ( v2 && a1[8] && a1[6] )
{
if ( *v2 == 48 )
{
result = ft_putstr(a1[6]);
}
else
{
ft_putstr(v2);
ft_putstr(&unk_1AB);
result = ft_putstr(a1[8]);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
_BYTE *v2; // rdi
__int64 result; // rax

v2 = (_BYTE *)a1[7];
if ( v2 && a1[8] && a1[6] )
{
if ( *v2 == 48 )
{
result = ft_putstr(a1[6]);
}
else
{
ft_putstr(v2);
ft_putstr(&unk_1AB);
result = ft_putstr(a1[8]);
}
}
return result;
}

original_code:
void ft_print_dev_info(t_list2 *lnk)
{
 if (lnk->major && lnk->minor && lnk->size)
 {
  if (lnk->major[0] != '0')
  {
   ft_putstr(lnk->major);
   ft_putstr(" ");
   ft_putstr(lnk->minor);
  }
  else
   ft_putstr(lnk->size);
 }
}

canonical_original_code:
void ft_print_dev_info(struct s_list2 *lnk)
{
 if (lnk->major && lnk->minor && lnk->size)
 {
  if (lnk->major[0] != '0')
  {
   ft_putstr(lnk->major);
   ft_putstr(" ");
   ft_putstr(lnk->minor);
  }
  else
   ft_putstr(lnk->size);
 }
}

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


decompiled_code:
__int64 __fastcall ft_print_color(__int64 a1)
{
_BYTE *v1; // rax
const char *v3; // rdi

v1 = *(_BYTE **)a1;
v3 = "\x1B[34m";
if ( *v1 != 100 )
{
if ( v1[3] != 120 )
return ft_putendl(*(_QWORD *)(a1 + 24));
v3 = "\x1B[31m";
}
ft_putstr(v3);
ft_putendl(*(_QWORD *)(a1 + 24));
return ft_putstr("\x1B[0m");
}

original_code:
void ft_print_color(t_list2 *lnk)
{
 if (lnk->right[0] == 'd')
 {
  ft_putstr("\033[34m");
  ft_putendl(lnk->name);
  ft_putstr("\033[0m");
 }
 else if(lnk->right[3] == 'x')
 {
  ft_putstr("\033[31m");
  ft_putendl(lnk->name);
  ft_putstr("\033[0m");
 }
 else
  ft_putendl(lnk->name);
}

canonical_original_code:
void ft_print_color(struct s_list2 *lnk)
{
 if (lnk->right[0] == 'd')
 {
  ft_putstr("\033[34m");
  ft_putendl(lnk->name);
  ft_putstr("\033[0m");
 }
 else if(lnk->right[3] == 'x')
 {
  ft_putstr("\033[31m");
  ft_putendl(lnk->name);
  ft_putstr("\033[0m");
 }
 else
  ft_putendl(lnk->name);
}

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


decompiled_code:
__int64 __fastcall ft_print_info(__int64 *a1)
{
__int64 v2; // rdi
__int64 result; // rax

v2 = *a1;
if ( v2 && a1[5] && a1[1] && a1[2] && a1[4] )
{
if ( a1[3] )
{
ft_putstr(v2);
ft_putstr(&unk_1AB);
ft_putstr(a1[5]);
ft_putstr(&unk_1AB);
ft_putstr(a1[1]);
ft_putstr(" ");
ft_putstr(a1[2]);
ft_putstr(" ");
ft_print_dev_info(a1);
ft_putstr(&unk_1AB);
ft_putstr(a1[4]);
ft_putstr(&unk_1AB);
result = ft_print_color((__int64)a1);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1)
{
__int64 v2; // rdi
__int64 result; // rax

v2 = *a1;
if ( v2 && a1[5] && a1[1] && a1[2] && a1[4] )
{
if ( a1[3] )
{
ft_putstr(v2);
ft_putstr(&unk_1AB);
ft_putstr(a1[5]);
ft_putstr(&unk_1AB);
ft_putstr(a1[1]);
ft_putstr(" ");
ft_putstr(a1[2]);
ft_putstr(" ");
func0(a1);
ft_putstr(&unk_1AB);
ft_putstr(a1[4]);
ft_putstr(&unk_1AB);
result = func1((__int64)a1);
}
}
return result;
}

original_code:
void ft_print_info(t_list2 *lnk)
{
 if (lnk->right && lnk->link && lnk->owner && lnk->group && lnk->time
  && lnk->name)
 {
  ft_putstr(lnk->right);
  ft_putstr(" ");
  ft_putstr(lnk->link);
  ft_putstr(" ");
  ft_putstr(lnk->owner);
  ft_putstr("  ");
  ft_putstr(lnk->group);
  ft_putstr("  ");
  ft_print_dev_info(lnk);
  ft_putstr(" ");
  ft_putstr(lnk->time);
  ft_putstr(" ");
  ft_print_color(lnk);
 }
}

canonical_original_code:
void ft_print_info(struct s_list2 *lnk)
{
 if (lnk->right && lnk->link && lnk->owner && lnk->group && lnk->time
  && lnk->name)
 {
  ft_putstr(lnk->right);
  ft_putstr(" ");
  ft_putstr(lnk->link);
  ft_putstr(" ");
  ft_putstr(lnk->owner);
  ft_putstr("  ");
  ft_putstr(lnk->group);
  ft_putstr("  ");
  ft_print_dev_info(lnk);
  ft_putstr(" ");
  ft_putstr(lnk->time);
  ft_putstr(" ");
  ft_print_color(lnk);
 }
}


decompiled_code:
void __fastcall create_prompt3(void *ptr, void *a2, void *a3, unsigned int a4)
{
__int64 v6; // rax
char v7; // dl
unsigned int v8; // er15

if ( *(_BYTE *)a2 == *(_BYTE *)ptr )
{
v6 = 1LL;
do
{
v7 = *((_BYTE *)a2 + v6);
v8 = v6++;
}
while ( v7 == *((char *)ptr + v6 - 1) );
}
else
{
v8 = 0;
}
if ( v8 == (unsigned int)ft_strlen(ptr) )
create_prompt2(a2, a3, v8, a4);
else
a3 = (void *)ft_strcat(a3, a2);
free(ptr);
free(a2);
print_prompt(a3);
free(a3);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr, void *a2, void *a3, unsigned int a4)
{
__int64 v6; // rax
char v7; // dl
unsigned int v8; // er15

if ( *(_BYTE *)a2 == *(_BYTE *)ptr )
{
v6 = 1LL;
do
{
v7 = *((_BYTE *)a2 + v6);
v8 = v6++;
}
while ( v7 == *((char *)ptr + v6 - 1) );
}
else
{
v8 = 0;
}
if ( v8 == (unsigned int)ft_strlen(ptr) )
create_prompt2(a2, a3, v8, a4);
else
a3 = (void *)ft_strcat(a3, a2);
free(ptr);
free(a2);
print_prompt(a3);
free(a3);
}

original_code:
void create_prompt3(char *home, char *pwd, char *prompt, int j)
{
 int i;
 i = 0;
 while (pwd[i] == home[i])
  i++;
 if (i != (int)ft_strlen(home))
  prompt = ft_strcat(prompt, pwd);
 else
  create_prompt2(pwd, prompt, i, j);
 free(home);
 free(pwd);
 print_prompt(prompt);
 free(prompt);
}

variable_types:
home
char *

variable_types:
pwd
char *

variable_types:
prompt
char *


variable_types:
line
char *

variable_types:
i
int *

variable_types:
tok
struct s_token *

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


decompiled_code:
__m128 __fastcall ft_abs_float(__m128 result)
{
if ( result.m128_f32[0] < 0.0 )
result = _mm_xor_ps(result, (__m128)LC1);
return result;
}

canonical_decompiled_code:
__m128 __fastcall func0(__m128 result)
{
if ( result.m128_f32[0] < 0.0 )
result = _mm_xor_ps(result, (__m128)LC1);
return result;
}

original_code:
float ft_abs_float(float x)
{
 float i;
 i = (x < 0 ? x *= -1 : x);
 return (i);
}

variable_types: x float

variable_types: i float

return_type: float


original_code:
t_list2 *ft_sort_time(t_list2 *lnk, t_list2 *tmp, t_list2 *tmp2, t_list2 *flnk)
{
 int cnt;
 cnt = 1;
 if (lnk != ((void *)0) && lnk->next != ((void *)0) )
 {
  while (cnt)
  {
   cnt = 0;
   tmp2 = flnk;
   tmp = flnk->next;
   while (tmp && tmp->next != ((void *)0))
   {
    if ((tmp->timestamp - tmp->next->timestamp) < 0)
    {
     tmp2->next = ft_list_switch(tmp, tmp->next);
     cnt = 1;
    }
    tmp2 = tmp;
    if (tmp->next != ((void *)0))
     tmp = tmp->next;
   }
  }
 }
 return (lnk);
}

canonical_original_code:
struct s_list2 *ft_sort_time(struct s_list2 *lnk, struct s_list2 *tmp, struct s_list2 *tmp2, struct s_list2 *flnk)
{
 int cnt;
 cnt = 1;
 if (lnk != ((void *)0) && lnk->next != ((void *)0) )
 {
  while (cnt)
  {
   cnt = 0;
   tmp2 = flnk;
   tmp = flnk->next;
   while (tmp && tmp->next != ((void *)0))
   {
    if ((tmp->timestamp - tmp->next->timestamp) < 0)
    {
     tmp2->next = ft_list_switch(tmp, tmp->next);
     cnt = 1;
    }
    tmp2 = tmp;
    if (tmp->next != ((void *)0))
     tmp = tmp->next;
   }
  }
 }
 return (lnk);
}

variable_types:
lnk
struct s_list2 *

variable_types:
tmp
struct s_list2 *

variable_types:
flnk
struct s_list2 *

variable_types: cnt int

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


original_code:
t_list2 *ft_sort_r_time(t_list2 *lnk, t_list2 *t1, t_list2 *t2, t_list2 *flnk)
{
 int cnt;
 cnt = 1;
 if (lnk != ((void *)0) && lnk->next != ((void *)0) )
 {
  while (cnt)
  {
   cnt = 0;
   t2 = flnk;
   t1 = flnk->next;
   while (t1->next != ((void *)0))
   {
    if ((t1->timestamp - t1->next->timestamp) > 0)
    {
     t2->next = ft_list_switch(t1, t1->next);
     cnt = 1;
    }
    t2 = t1;
    if (t1->next != ((void *)0))
     t1 = t1->next;
   }
  }
 }
 return (lnk);
}

canonical_original_code:
struct s_list2 *ft_sort_r_time(struct s_list2 *lnk, struct s_list2 *t1, struct s_list2 *t2, struct s_list2 *flnk)
{
 int cnt;
 cnt = 1;
 if (lnk != ((void *)0) && lnk->next != ((void *)0) )
 {
  while (cnt)
  {
   cnt = 0;
   t2 = flnk;
   t1 = flnk->next;
   while (t1->next != ((void *)0))
   {
    if ((t1->timestamp - t1->next->timestamp) > 0)
    {
     t2->next = ft_list_switch(t1, t1->next);
     cnt = 1;
    }
    t2 = t1;
    if (t1->next != ((void *)0))
     t1 = t1->next;
   }
  }
 }
 return (lnk);
}


decompiled_code:
__int64 __fastcall ft_fill_min_val(__int64 a1, char *a2)
{
char v2; // dl
__int64 v3; // rax

v2 = *a2;
if ( *a2 )
{
v3 = 0LL;
do
{
*(_BYTE *)(a1 + v3++) = v2;
v2 = a2[v3];
}
while ( v2 );
}
return a1;
}

original_code:
static char *ft_fill_min_val(char *tmp, char *tmp2)
{
 int i;
 i = 0;
 while (tmp2[i] != '\0')
 {
  tmp[i] = tmp2[i];
  i++;
 }
 return (tmp);
}

variable_types:
tmp
char *

variable_types: i int


original_code:
void f_and(t_dat *dat, t_proc *proc)
{
 short tp[2];
 long params[3];
 long res;
 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)
   ft_printf("and: value %ld & value %ld -> reg%ld\n", params[0], params[1], params[2]);
  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_and(struct s_dat *dat, struct s_proc *proc)
{
 short tp[2];
 long params[3];
 long res;
 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)
   ft_printf("and: value %ld & value %ld -> reg%ld\n", params[0], params[1], params[2]);
  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:
tp
short [2]

variable_types:
params
long [3]

variable_types: res long

variable_types:
dest
unsigned char *

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


putsep

decompiled_code:
__int64 __fastcall putsep(__int64 a1, __int64 a2)
{
*(_BYTE *)(a2 + ft_strlen(a2)) = 44;
return lex_addlex(a1, &unk_13A, 0x4000LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
*(_BYTE *)(a2 + ft_strlen(a2)) = 44;
return lex_addlex(a1, &unk_13A, 0x4000LL);
}

original_code:
static void putsep(t_lexer **list, char *word)
{
 word[ft_strlen(word)] = ',';
 lex_addlex(list, ",", SEP);
}

canonical_original_code:
static void putsep(struct s_lexer **list, char *word)
{
 word[ft_strlen(word)] = ',';
 lex_addlex(list, ",", SEP);
}

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:
word
char *

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


decompiled_code:
__int64 __fastcall lex_tablex(__int64 a1, _BYTE *a2)
{
__int64 v2; // rbp
bool v3; // zf
int v4; // er14
__int64 v5; // rbx
__int64 result; // rax
unsigned int v7; // [rsp+Ch] [rbp-6Ch]
__int64 v8[13]; // [rsp+10h] [rbp-68h]

v2 = (__int64)a2;
v3 = *a2 == 44;
v8[1] = (__int64)&lex_iscmd_com;
v8[2] = (__int64)&lex_iscmd;
v8[3] = (__int64)&lex_isreg;
v8[4] = (__int64)&lex_isdirlab;
v8[5] = (__int64)&lex_isdir;
v8[6] = (__int64)&lex_islab;
v8[7] = (__int64)&lex_isind;
if ( v3 )
{
v2 = (__int64)(a2 + 1);
lex_addlex(a1, &unk_13A, 0x4000LL);
}
v4 = 0;
if ( *(_BYTE *)(v2 + ft_strlen(v2) - 1) == 44 )
{
v4 = 1;
*(_BYTE *)(v2 + ft_strlen(v2) - 1) = 0;
}
v5 = 0LL;
for ( result = lex_iscmd_name(a1, v2);
(_DWORD)result == -1;
result = ((__int64 (__fastcall *)(__int64, __int64))v8[v5])(a1, v2) )
{
if ( ++v5 == 8 )
{
if ( !v4 )
return result;
goto LABEL_10;
}
}
result = 0LL;
if ( v4 )
{
LABEL_10:
v7 = result;
putsep(a1, v2);
result = v7;
}
return result;
}

original_code:
int lex_tablex(t_lexer **list, char *word)
{
 int j;
 int sep;
 int (*funcs[8])(t_lexer **list, char *word) =
  {lex_iscmd_name, lex_iscmd_com, lex_iscmd, lex_isreg,
  lex_isdirlab, lex_isdir, lex_islab, lex_isind};
 j = sep = 0;
 if (word[0] == ',')
 {
  lex_addlex(list, ",", SEP);
  word++;
 }
 if (word[ft_strlen(word) - 1] == ',')
 {
  sep = 1;
  word[ft_strlen(word) - 1] = '\0';
 }
 while (j < 8 && (funcs[j])(list, word) == -1)
  j++;
 if (sep)
  putsep(list, word);
 if (j == 8)
  return (-1);
 return (0);
}

canonical_original_code:
int lex_tablex(struct s_lexer **list, char *word)
{
 int j;
 int sep;
 int (*funcs[8])(struct s_lexer **list, char *word) = {lex_iscmd_name, lex_iscmd_com, lex_iscmd, lex_isreg,
  lex_isdirlab, lex_isdir, lex_islab, lex_isind};
 j = sep = 0;
 if (word[0] == ',')
 {
  lex_addlex(list, ",", SEP);
  word++;
 }
 if (word[ft_strlen(word) - 1] == ',')
 {
  sep = 1;
  word[ft_strlen(word) - 1] = '\0';
 }
 while (j < 8 && (funcs[j])(list, word) == -1)
  j++;
 if (sep)
  putsep(list, word);
 if (j == 8)
  return (-1);
 return (0);
}

variable_types: j int

variable_types: sep int

variable_types: int (*[8])(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; } **list, char *word)


decompiled_code:
void __fastcall free_format(void *ptr)
{
_QWORD *i; // rbp
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
_QWORD *v5; // rbx

if ( ptr )
{
for ( i = ptr; ; i = v5 )
{
v2 = (void *)i[1];
if ( v2 )
free(v2);
v3 = (void *)i[3];
if ( v3 )
free(v3);
v4 = (void *)i[6];
if ( v4 )
free(v4);
v5 = (_QWORD *)i[8];
free(i);
if ( !v5 )
break;
}
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
_QWORD *i; // rbp
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
_QWORD *v5; // rbx

if ( ptr )
{
for ( i = ptr; ; i = v5 )
{
v2 = (void *)i[1];
if ( v2 )
free(v2);
v3 = (void *)i[3];
if ( v3 )
free(v3);
v4 = (void *)i[6];
if ( v4 )
free(v4);
v5 = (_QWORD *)i[8];
free(i);
if ( !v5 )
break;
}
}
}

original_code:
void free_format(t_format *save)
{
 t_format *tmp;
 while (save)
 {
  if (save->f_list)
   free(save->f_list);
  if (save->l_mod)
   free(save->l_mod);
  if (save->format)
   free(save->format);
  tmp = save;
  save = save->next;
  free(tmp);
 }
}

canonical_original_code:
void free_format(struct s_format *save)
{
 struct s_format *tmp;
 while (save)
 {
  if (save->f_list)
   free(save->f_list);
  if (save->l_mod)
   free(save->l_mod);
  if (save->format)
   free(save->format);
  tmp = save;
  save = save->next;
  free(tmp);
 }
}

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


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

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

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

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

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

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

variable_types: fd int

variable_types:
tab
int **

variable_types: n int

variable_types:
tabtmp
int **

return_type: int **


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

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

variable_types:
lst
struct s_obj *

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

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