decompiled_code:
void __fastcall ft_create_pad_part2(__int64 a1, __int64 *a2, unsigned int a3)
{
__int64 v4; // rdi
int v6; // eax
__int64 v7; // rdi
int v8; // eax

v4 = *(_QWORD *)(a1 + 8);
if ( v4 )
{
if ( (unsigned int)ft_strichr(v4, 35LL) != -1
&& (unsigned int)ft_strichr(*(_QWORD *)(a1 + 8), 1LL)
&& *(_QWORD *)(*a2 + 16) )
{
a3 += 2;
}
v6 = *(_DWORD *)(a1 + 20);
if ( v6 > (int)a3 && v6 )
{
v7 = *(_QWORD *)(a1 + 8);
if ( !v7 )
goto LABEL_22;
if ( (unsigned int)ft_strichr(v7, 48LL) != -1 && !*(_BYTE *)(a1 + 24) )
{
ft_place_zeros(a1, *a2, a3);
return;
}
v8 = *(_DWORD *)(a1 + 20);
if ( v8 > (int)a3 )
{
if ( v8 )
{
LABEL_22:
if ( (unsigned int)ft_strichr(*(_QWORD *)(a1 + 8), 48LL) == -1 && !*(_BYTE *)(a1 + 24) )
{
ft_place_spaces(a1, *a2, a3);
return;
}
}
}
}
if ( *(_BYTE *)(a1 + 24) == 42 )
ft_pad_by_star(a1, a2);
}
}

original_code:
void ft_create_pad_part2(t_op *op, t_arg **lnk, int l)
{
 if (op->flag)
 {
  if (ft_strichr(op->flag, '#') != -1 && ft_strichr(op->flag, '0' != -1)
   && (*lnk)->ull != 0)
   l += 2;
  if (op->min_width && l < op->min_width && op->flag
   && ft_strichr(op->flag, '0') != -1 && !op->starwidth)
   ft_place_zeros(op, *lnk, l);
  else if (op->min_width && l < op->min_width
    && ft_strichr(op->flag, '0') == -1 && !op->starwidth)
   ft_place_spaces(op, *lnk, l);
  else if (op->starwidth == '*')
   ft_pad_by_star(op, lnk);
 }
}

canonical_original_code:
void ft_create_pad_part2(struct s_option *op, struct s_arg **lnk, int l)
{
 if (op->flag)
 {
  if (ft_strichr(op->flag, '#') != -1 && ft_strichr(op->flag, '0' != -1)
   && (*lnk)->ull != 0)
   l += 2;
  if (op->min_width && l < op->min_width && op->flag
   && ft_strichr(op->flag, '0') != -1 && !op->starwidth)
   ft_place_zeros(op, *lnk, l);
  else if (op->min_width && l < op->min_width
    && ft_strichr(op->flag, '0') == -1 && !op->starwidth)
   ft_place_spaces(op, *lnk, l);
  else if (op->starwidth == '*')
   ft_pad_by_star(op, lnk);
 }
}


decompiled_code:
void __fastcall free_cmd(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

original_code:
void free_cmd(char **cmd)
{
 int i;
 i = 0;
 while (cmd[i] != ((void *)0))
 {
  free(cmd[i]);
  i++;
 }
 if (cmd != ((void *)0))
  free(cmd);
}

variable_types:
cmd
char **

variable_types: i int

return_type: void


decompiled_code:
__int64 exec_laredir()
{
return ft_error("Double left redirection unsupported");
}

canonical_decompiled_code:
__int64 func2()
{
return ft_error("Double left redirection unsupported");
}

original_code:
void exec_laredir(t_ast *ast, char **env, char **path)
{
 (void)ast;
 (void)env;
 (void)path;
 ft_error("Double left redirection unsupported");
}

canonical_original_code:
void exec_laredir(struct s_ast *ast, char **env, char **path)
{
 (void)ast;
 (void)env;
 (void)path;
 ft_error("Double left redirection unsupported");
}

variable_types: struct s_ast { enum e_type { QUOTE=0, LREDIR=1, RREDIR=2, LAREDIR=3, RAREDIR=4, PIPE=5, SEMICOLON=6, WHITESPACE=7, STDCHAR=8, ENDOFLINE=9 } type; struct s_ast *parent; struct s_ast *leftcmd; char *left; char *right; int fd[2]; } *

variable_types:
env
char **

variable_types:
path
char **

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


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

result = (_QWORD *)f_0;
if ( !f_0 )
{
result = malloc(0x28uLL);
f_0 = (__int64)result;
*result = &exec_lredir;
result[1] = &exec_rredir;
result[2] = &exec_lredir;
result[3] = &exec_raredir;
result[4] = &exec_pipe;
}
return result;
}

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

result = (_QWORD *)f_0;
if ( !f_0 )
{
result = malloc(0x28uLL);
f_0 = (__int64)result;
*result = &exec_lredir;
result[1] = &exec_rredir;
result[2] = &exec_lredir;
result[3] = &exec_raredir;
result[4] = &exec_pipe;
}
return result;
}

original_code:
t_tree *build_f_tab(void)
{
 static t_tree *f = ((void *)0);
 if (f != ((void *)0))
  return (f);
 f = (t_tree*)malloc(sizeof(t_tree) * 5);
 f[0] = exec_lredir;
 f[1] = exec_rredir;
 f[2] = exec_lredir;
 f[3] = exec_raredir;
 f[4] = exec_pipe;
 return (f);
}

canonical_original_code:
void (**build_f_tab())(struct s_ast *, char ***, char **)
{
 static void (**f)(struct s_ast *, char ***, char **) = ((void *)0);
 if (f != ((void *)0))
  return (f);
 f = (void (**)(struct s_ast *, char ***, char **))malloc(sizeof(t_tree) * 5);
 f[0] = exec_lredir;
 f[1] = exec_rredir;
 f[2] = exec_lredir;
 f[3] = exec_raredir;
 f[4] = exec_pipe;
 return (f);
}

variable_types: void (**)(struct s_ast { enum e_type { QUOTE=0, LREDIR=1, RREDIR=2, LAREDIR=3, RAREDIR=4, PIPE=5, SEMICOLON=6, WHITESPACE=7, STDCHAR=8, ENDOFLINE=9 } type; struct s_ast *parent; struct s_ast *leftcmd; char *left; char *right; int fd[2]; } *, char ***, char **)


decompiled_code:
__int64 __fastcall ft_memcmp(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rax
unsigned __int8 v6; // dl
unsigned __int8 v7; // cl

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

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rax
unsigned __int8 v6; // dl
unsigned __int8 v7; // cl

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

original_code:
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
 unsigned char *tmp1;
 unsigned char *tmp2;
 int i;
 i = 0;
 tmp1 = (unsigned char*)s1;
 tmp2 = (unsigned char*)s2;
 while (n > 0)
 {
  if (tmp1[i] != tmp2[i])
   return (tmp1[i] - tmp2[i]);
  n--;
  i++;
 }
 return (0);
}

canonical_original_code:
int ft_memcmp(void *s1, void *s2, unsigned long n)
{
 unsigned char *tmp1;
 unsigned char *tmp2;
 int i;
 i = 0;
 tmp1 = (unsigned char *)s1;
 tmp2 = (unsigned char *)s2;
 while (n > 0)
 {
  if (tmp1[i] != tmp2[i])
   return (tmp1[i] - tmp2[i]);
  n--;
  i++;
 }
 return (0);
}

variable_types:
n
unsigned long

return_type: int


decompiled_code:
__int64 __fastcall f_aff(__int64 a1, __int64 a2)
{
__int64 result; // rax
char buf[25]; // [rsp+Fh] [rbp-19h] BYREF

result = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + 2), 1LL);
if ( (unsigned int)(result - 1) <= 0xF )
{
result = get_val(a2 + 4 * (int)result - 4, 0LL, 4LL) % 256;
buf[0] = result;
if ( *(_DWORD *)(a1 + 4136) )
{
write(1, "aff: ", 5uLL);
write(1, buf, 1uLL);
result = write(1, "\n", 1uLL);
}
}
*(_DWORD *)(a2 + 64) += 3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 result; // rax
char buf[25]; // [rsp+Fh] [rbp-19h] BYREF

result = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + 2), 1LL);
if ( (unsigned int)(result - 1) <= 0xF )
{
result = get_val(a2 + 4 * (int)result - 4, 0LL, 4LL) % 256;
buf[0] = result;
if ( *(_DWORD *)(a1 + 4136) )
{
write(1, "aff: ", 5uLL);
write(1, buf, 1uLL);
result = write(1, "\n", 1uLL);
}
}
*(_DWORD *)(a2 + 64) += 3;
return result;
}

original_code:
void f_aff(t_dat *dat, t_proc *proc)
{
 int reg_nb;
 long val;
 char dsp;
 reg_nb = get_val(dat->arena, proc->pc + 2, ((16 / 256) + 1));
 if (reg_nb > 0 && reg_nb <= 16)
 {
  val = get_val(proc->reg + ((reg_nb - 1) * 4), 0, 4);
  dsp = val % 256;
  if (dat->verbose)
  {
   write(1, "aff: ", 5);
   write(1, &dsp, 1);
   write(1, "\n", 1);
  }
 }
 proc->pc += 3;
}

canonical_original_code:
void f_aff(struct s_dat *dat, struct s_proc *proc)
{
 int reg_nb;
 long val;
 char dsp;
 reg_nb = get_val(dat->arena, proc->pc + 2, ((16 / 256) + 1));
 if (reg_nb > 0 && reg_nb <= 16)
 {
  val = get_val(proc->reg + ((reg_nb - 1) * 4), 0, 4);
  dsp = val % 256;
  if (dat->verbose)
  {
   write(1, "aff: ", 5);
   write(1, &dsp, 1);
   write(1, "\n", 1);
  }
 }
 proc->pc += 3;
}

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

variable_types: dsp 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:
__int64 __fastcall ft_build_arglst_star(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
int v6; // eax
__int64 v7; // rcx
__int64 v8; // rsi

v4 = ft_build_arg_link_int(a3);
v5 = ft_arg_list_push_back(a3, v4);
v6 = *(unsigned __int8 *)(a1 + 40);
if ( (unsigned __int8)(v6 - 99) <= 1u || (_BYTE)v6 == 105 )
{
v8 = ft_build_arg_link_int(v5);
}
else if ( (unsigned __int8)(v6 - 88) <= 0x20u && (v7 = 0x121800001LL, _bittest64(&v7, (unsigned int)(v6 - 88))) )
{
v8 = ft_build_arg_link_uint(v5, a2);
}
else if ( (_BYTE)v6 == 115 )
{
v8 = ft_build_arg_link_charstar(v5, a2);
}
else
{
v8 = ft_build_arg_empty(v5);
}
return ft_arg_list_push_back(v5, v8);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
int v6; // eax
__int64 v7; // rcx
__int64 v8; // rsi

v4 = ft_build_arg_link_int(a3);
v5 = ft_arg_list_push_back(a3, v4);
v6 = *(unsigned __int8 *)(a1 + 40);
if ( (unsigned __int8)(v6 - 99) <= 1u || (_BYTE)v6 == 105 )
{
v8 = ft_build_arg_link_int(v5);
}
else if ( (unsigned __int8)(v6 - 88) <= 0x20u && (v7 = 0x121800001LL, _bittest64(&v7, (unsigned int)(v6 - 88))) )
{
v8 = ft_build_arg_link_uint(v5, a2);
}
else if ( (_BYTE)v6 == 115 )
{
v8 = ft_build_arg_link_charstar(v5, a2);
}
else
{
v8 = ft_build_arg_empty(v5);
}
return ft_arg_list_push_back(v5, v8);
}

original_code:
t_arg *ft_build_arglst_star(t_op *op, va_list *ap, t_arg *lnk)
{
 t_arg *new;
 new = ft_build_arg_link_int(lnk, ap);
 lnk = ft_arg_list_push_back(lnk, new);
 if (op->conv == 'd' || op->conv == 'c' || op->conv == 'i')
  new = ft_build_arg_link_int(lnk, ap);
 else if (op->conv == 'u' || op->conv == 'o' || op->conv == 'x'
   || op->conv == 'X' || op->conv == 'p')
  new = ft_build_arg_link_uint(lnk, ap);
 else if (op->conv == 's')
  new = ft_build_arg_link_charstar(lnk, ap);
 else
  new = ft_build_arg_empty(lnk);
 lnk = ft_arg_list_push_back(lnk, new);
 return (lnk);
}

canonical_original_code:
struct s_arg *ft_build_arglst_star(struct s_option *op, __builtin_va_list *ap, struct s_arg *lnk)
{
 struct s_arg *new;
 new = ft_build_arg_link_int(lnk, ap);
 lnk = ft_arg_list_push_back(lnk, new);
 if (op->conv == 'd' || op->conv == 'c' || op->conv == 'i')
  new = ft_build_arg_link_int(lnk, ap);
 else if (op->conv == 'u' || op->conv == 'o' || op->conv == 'x'
   || op->conv == 'X' || op->conv == 'p')
  new = ft_build_arg_link_uint(lnk, ap);
 else if (op->conv == 's')
  new = ft_build_arg_link_charstar(lnk, ap);
 else
  new = ft_build_arg_empty(lnk);
 lnk = ft_arg_list_push_back(lnk, new);
 return (lnk);
}

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

variable_types:
ap
__builtin_va_list *

variable_types:
lnk
struct s_arg *

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


decompiled_code:
__int64 __fastcall ft_build_no_star(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // eax
__int64 v5; // rcx
__int64 v6; // rsi

v4 = *(unsigned __int8 *)(a1 + 40);
if ( (unsigned __int8)(v4 - 99) <= 1u || (_BYTE)v4 == 105 )
{
v6 = ft_build_arg_link_int(a3);
}
else if ( (unsigned __int8)(v4 - 88) <= 0x20u && (v5 = 0x121800001LL, _bittest64(&v5, (unsigned int)(v4 - 88))) )
{
v6 = ft_build_arg_link_uint(a3, a2);
}
else if ( (_BYTE)v4 == 115 )
{
v6 = ft_build_arg_link_charstar(a3, a2);
}
else
{
v6 = ft_build_arg_empty(a3);
}
return ft_arg_list_push_back(a3, v6);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // eax
__int64 v5; // rcx
__int64 v6; // rsi

v4 = *(unsigned __int8 *)(a1 + 40);
if ( (unsigned __int8)(v4 - 99) <= 1u || (_BYTE)v4 == 105 )
{
v6 = ft_build_arg_link_int(a3);
}
else if ( (unsigned __int8)(v4 - 88) <= 0x20u && (v5 = 0x121800001LL, _bittest64(&v5, (unsigned int)(v4 - 88))) )
{
v6 = ft_build_arg_link_uint(a3, a2);
}
else if ( (_BYTE)v4 == 115 )
{
v6 = ft_build_arg_link_charstar(a3, a2);
}
else
{
v6 = ft_build_arg_empty(a3);
}
return ft_arg_list_push_back(a3, v6);
}

original_code:
t_arg *ft_build_no_star(t_op *op, va_list *ap, t_arg *lnk)
{
 t_arg *new;
 if (op->conv == 'd' || op->conv == 'c' || op->conv == 'i')
  new = ft_build_arg_link_int(lnk, ap);
 else if (op->conv == 'u' || op->conv == 'o' || op->conv == 'x'
   || op->conv == 'X' || op->conv == 'p')
  new = ft_build_arg_link_uint(lnk, ap);
 else if (op->conv == 's')
  new = ft_build_arg_link_charstar(lnk, ap);
 else
  new = ft_build_arg_empty(lnk);
 lnk = ft_arg_list_push_back(lnk, new);
 return (lnk);
}

canonical_original_code:
struct s_arg *ft_build_no_star(struct s_option *op, __builtin_va_list *ap, struct s_arg *lnk)
{
 struct s_arg *new;
 if (op->conv == 'd' || op->conv == 'c' || op->conv == 'i')
  new = ft_build_arg_link_int(lnk, ap);
 else if (op->conv == 'u' || op->conv == 'o' || op->conv == 'x'
   || op->conv == 'X' || op->conv == 'p')
  new = ft_build_arg_link_uint(lnk, ap);
 else if (op->conv == 's')
  new = ft_build_arg_link_charstar(lnk, ap);
 else
  new = ft_build_arg_empty(lnk);
 lnk = ft_arg_list_push_back(lnk, new);
 return (lnk);
}

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

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


original_code:
void ft_move_to_last(t_sort **current, t_sort **last, t_sort **prev)
{
 t_sort *tmp;
 if ((*prev) != ((void *)0))
  (*prev)->next = (*current)->next;
 tmp = (*current)->next;
 (*current)->next = ((void *)0);
 (*last)->next = (*current);
 (*last) = (*current);
 (*current) = tmp;
}

canonical_original_code:
void ft_move_to_last(struct s_list_arg **current, struct s_list_arg **last, struct s_list_arg **prev)
{
 struct s_list_arg *tmp;
 if ((*prev) != ((void *)0))
  (*prev)->next = (*current)->next;
 tmp = (*current)->next;
 (*current)->next = ((void *)0);
 (*last)->next = (*current);
 (*last) = (*current);
 (*current) = tmp;
}

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

variable_types:
last
struct s_list_arg **

variable_types:
prev
struct s_list_arg **


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

do
{
result = a1;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

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

do
{
result = a1;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

original_code:
t_sort *ft_get_last(t_sort *lnk)
{
 t_sort *last;
 t_sort *save;
 save = lnk;
 while (lnk->next != ((void *)0))
  lnk = lnk->next;
 last = lnk;
 lnk = save;
 return (last);
}

canonical_original_code:
struct s_list_arg *ft_get_last(struct s_list_arg *lnk)
{
 struct s_list_arg *last;
 struct s_list_arg *save;
 save = lnk;
 while (lnk->next != ((void *)0))
  lnk = lnk->next;
 last = lnk;
 lnk = save;
 return (last);
}

variable_types:
lnk
struct s_list_arg *

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


original_code:
t_sort *ft_sort_recurs(t_sort *start, t_sort *end)
{
    t_sort *newstart;
    t_sort *newend;
    t_sort *middle;
 t_sort *tmp;
    newstart = newend = ((void *)0);
    if (start == ((void *)0) || start == end)
        return (start);
    middle = ft_separate(start, end, &newstart, &newend);
 if (newstart != middle)
 {
  tmp = newstart;
  while (tmp->next != middle)
   tmp = tmp->next;
  tmp->next = ((void *)0);
  newstart = ft_sort_recurs(newstart, tmp);
  tmp = ft_get_last(newstart);
  tmp->next = middle;
 }
 middle->next = ft_sort_recurs(middle->next, newend);
 return (newstart);
}

canonical_original_code:
struct s_list_arg *ft_sort_recurs(struct s_list_arg *start, struct s_list_arg *end)
{
    struct s_list_arg *newstart;
    struct s_list_arg *newend;
    struct s_list_arg *middle;
 struct s_list_arg *tmp;
    newstart = newend = ((void *)0);
    if (start == ((void *)0) || start == end)
        return (start);
    middle = ft_separate(start, end, &newstart, &newend);
 if (newstart != middle)
 {
  tmp = newstart;
  while (tmp->next != middle)
   tmp = tmp->next;
  tmp->next = ((void *)0);
  newstart = ft_sort_recurs(newstart, tmp);
  tmp = ft_get_last(newstart);
  tmp->next = middle;
 }
 middle->next = ft_sort_recurs(middle->next, newend);
 return (newstart);
}

variable_types:
start
struct s_list_arg *

variable_types:
end
struct s_list_arg *

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


decompiled_code:
__int64 __fastcall ft_sort(__int64 *a1)
{
__int64 v1; // rbp
_DWORD *v2; // rax
__int64 result; // rax

v1 = *a1;
v2 = (_DWORD *)ft_get_last(*a1);
result = ft_sort_recurs(v1, v2);
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1)
{
__int64 v1; // rbp
_DWORD *v2; // rax
__int64 result; // rax

v1 = *a1;
v2 = (_DWORD *)func1(*a1);
result = func2(v1, v2);
*a1 = result;
return result;
}

original_code:
void ft_sort(t_sort **lnk)
{
 (*lnk) = ft_sort_recurs(*lnk, ft_get_last(*lnk));
}

canonical_original_code:
void ft_sort(struct s_list_arg **lnk)
{
 (*lnk) = ft_sort_recurs(*lnk, ft_get_last(*lnk));
}

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


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

result = a2;
*(_QWORD *)(a1 + 88) = *(_QWORD *)(a2 + 88);
*(_QWORD *)(a2 + 88) = a1;
return result;
}

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

result = a2;
*(_QWORD *)(a1 + 88) = *(_QWORD *)(a2 + 88);
*(_QWORD *)(a2 + 88) = a1;
return result;
}

original_code:
t_list2 *ft_list_switch(t_list2 *l1, t_list2 *l2)
{
 l1->next = l2->next;
 l2->next = l1;
 return (l2);
}

canonical_original_code:
struct s_list2 *ft_list_switch(struct s_list2 *l1, struct s_list2 *l2)
{
 l1->next = l2->next;
 l2->next = l1;
 return (l2);
}

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_name(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->next != ((void *)0))
   {
    if (ft_list_elem_cmp(tmp->name, tmp->next->name) > 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_name(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->next != ((void *)0))
   {
    if (ft_list_elem_cmp(tmp->name, tmp->next->name) > 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

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


original_code:
t_list2 *ft_sort_r_name(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 (ft_list_elem_cmp(t1->name, t1->next->name) < 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_name(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 (ft_list_elem_cmp(t1->name, t1->next->name) < 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_sort_list_elem(__int64 a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
__int64 v4; // rbp

v2 = malloc(0x68uLL);
if ( !v2 )
{
ft_putendl_fd("Memory Allocation error.\n", 2LL);
exit(1);
}
v3 = v2;
v2[11] = a1;
if ( a2 )
{
switch ( a2 )
{
case 1:
ft_sort_time(a1, 0LL, 0LL, v2);
break;
case 2:
ft_sort_r_name(a1, 0LL, 0LL, (__int64)v2);
break;
case 3:
ft_sort_r_time(a1, 0LL, 0LL, v2);
break;
}
}
else
{
ft_sort_name(a1, 0LL, 0LL, (__int64)v2);
}
v4 = v3[11];
free(v3);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
__int64 v4; // rbp

v2 = malloc(0x68uLL);
if ( !v2 )
{
ft_putendl_fd("Memory Allocation error.\n", 2LL);
exit(1);
}
v3 = v2;
v2[11] = a1;
if ( a2 )
{
switch ( a2 )
{
case 1:
ft_sort_time(a1, 0LL, 0LL, v2);
break;
case 2:
func3(a1, 0LL, 0LL, (__int64)v2);
break;
case 3:
ft_sort_r_time(a1, 0LL, 0LL, v2);
break;
}
}
else
{
func2(a1, 0LL, 0LL, (__int64)v2);
}
v4 = v3[11];
free(v3);
return v4;
}

original_code:
t_list2 *ft_sort_list_elem(t_list2 *lnk, int i)
{
 t_list2 *tmp;
 t_list2 *tmp2;
 t_list2 *flnk;
 if ((flnk = (t_list2*)malloc(sizeof(t_list2))) == ((void *)0))
 {
  ft_putendl_fd("Memory Allocation error.\n", 2);
  exit (1);
 }
 flnk->next = lnk;
 tmp = ((void *)0);
 tmp2 = ((void *)0);
 if (i == 0)
  lnk = ft_sort_name(lnk, tmp, tmp2, flnk);
 else if (i == 1)
  lnk = ft_sort_time(lnk, tmp, tmp2, flnk);
 else if (i == 2)
  lnk = ft_sort_r_name(lnk, tmp, tmp2, flnk);
 else if (i == 3)
  lnk = ft_sort_r_time(lnk, tmp, tmp2, flnk);
 lnk = flnk->next;
 free(flnk);
 return (lnk);
}

canonical_original_code:
struct s_list2 *ft_sort_list_elem(struct s_list2 *lnk, int i)
{
 struct s_list2 *tmp;
 struct s_list2 *tmp2;
 struct s_list2 *flnk;
 if ((flnk = (struct s_list2 *)malloc(sizeof(t_list2))) == ((void *)0))
 {
  ft_putendl_fd("Memory Allocation error.\n", 2);
  exit (1);
 }
 flnk->next = lnk;
 tmp = ((void *)0);
 tmp2 = ((void *)0);
 if (i == 0)
  lnk = ft_sort_name(lnk, tmp, tmp2, flnk);
 else if (i == 1)
  lnk = ft_sort_time(lnk, tmp, tmp2, flnk);
 else if (i == 2)
  lnk = ft_sort_r_name(lnk, tmp, tmp2, flnk);
 else if (i == 3)
  lnk = ft_sort_r_time(lnk, tmp, tmp2, flnk);
 lnk = flnk->next;
 free(flnk);
 return (lnk);
}

variable_types: i int

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_cut_a(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax
__int64 v6; // rdx
int v7; // ecx

result = a1;
if ( a1 )
{
v6 = a1;
v7 = 1;
do
{
v6 = *(_QWORD *)(v6 + 8);
++v7;
}
while ( v6 );
if ( v7 > 1 )
{
do
{
a5 = result;
result = *(_QWORD *)(result + 8);
LODWORD(v6) = v6 + 1;
}
while ( (int)v6 < v7 / 2 );
}
}
*(_QWORD *)(a5 + 8) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax
__int64 v6; // rdx
int v7; // ecx

result = a1;
if ( a1 )
{
v6 = a1;
v7 = 1;
do
{
v6 = *(_QWORD *)(v6 + 8);
++v7;
}
while ( v6 );
if ( v7 > 1 )
{
do
{
a5 = result;
result = *(_QWORD *)(result + 8);
LODWORD(v6) = v6 + 1;
}
while ( (int)v6 < v7 / 2 );
}
}
*(_QWORD *)(a5 + 8) = 0LL;
return result;
}

original_code:
t_sort *ft_cut_a(t_sort *lnk, t_sort *lnk_b)
{
 int i;
 int j;
 t_sort *save;
 t_sort *tmp;
 i = j = 0;
 save = lnk;
 while (i++, lnk != ((void *)0))
  lnk = lnk->next;
 lnk = save;
 while (j < (i / 2))
 {
  tmp = lnk;
  lnk = lnk->next;
  j++;
 }
 tmp->next = ((void *)0);
 lnk_b = lnk;
 return (lnk_b);
}

canonical_original_code:
struct s_list_arg *ft_cut_a(struct s_list_arg *lnk, struct s_list_arg *lnk_b)
{
 int i;
 int j;
 struct s_list_arg *save;
 struct s_list_arg *tmp;
 i = j = 0;
 save = lnk;
 while (i++, lnk != ((void *)0))
  lnk = lnk->next;
 lnk = save;
 while (j < (i / 2))
 {
  tmp = lnk;
  lnk = lnk->next;
  j++;
 }
 tmp->next = ((void *)0);
 lnk_b = lnk;
 return (lnk_b);
}

variable_types: j int


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

result = 0LL;
if ( a1 != 0 )
{
if ( (_QWORD)a1 && *((_QWORD *)&a1 + 1) )
{
if ( *(_DWORD *)a1 )
{
do
{
if ( *(_DWORD *)a1 != **((_DWORD **)&a1 + 1) )
break;
*(_QWORD *)&a1 = *(_QWORD *)(a1 + 8);
*((_QWORD *)&a1 + 1) = *(_QWORD *)(*((_QWORD *)&a1 + 1) + 8LL);
if ( !(_QWORD)a1 )
break;
}
while ( *((_QWORD *)&a1 + 1) );
return a1 != 0;
}
result = 1LL;
if ( **((_DWORD **)&a1 + 1) )
return a1 != 0;
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
int ft_compare_lists(t_sort *lnk, t_sort *lnk2)
{
 int i;
 t_sort *save;
 t_sort *save2;
 i = -1;
 save = lnk;
 save2 = lnk2;
 if (!lnk && !lnk2)
  return (0);
 if (!lnk || !lnk2)
  return (1);
 else if (!lnk->val && !lnk2->val)
  return (1);
 while (lnk != ((void *)0) && lnk2 != ((void *)0))
 {
  if (lnk->val != lnk2->val)
   break ;
  lnk = lnk->next;
  lnk2 = lnk2->next;
 }
 if (lnk == ((void *)0) && lnk2 == ((void *)0))
  i = 0;
 else
  i = 1;
 lnk = save;
 lnk2 = save2;
 return (i);
}

canonical_original_code:
int ft_compare_lists(struct s_list_arg *lnk, struct s_list_arg *lnk2)
{
 int i;
 struct s_list_arg *save;
 struct s_list_arg *save2;
 i = -1;
 save = lnk;
 save2 = lnk2;
 if (!lnk && !lnk2)
  return (0);
 if (!lnk || !lnk2)
  return (1);
 else if (!lnk->val && !lnk2->val)
  return (1);
 while (lnk != ((void *)0) && lnk2 != ((void *)0))
 {
  if (lnk->val != lnk2->val)
   break ;
  lnk = lnk->next;
  lnk2 = lnk2->next;
 }
 if (lnk == ((void *)0) && lnk2 == ((void *)0))
  i = 0;
 else
  i = 1;
 lnk = save;
 lnk2 = save2;
 return (i);
}


original_code:
void ft_call_f(t_sort *lnk, t_sort *unsort, t_sort *lnk_b, t_state *st)
{
 int i;
 int j;
 t_sort *new;
 t_func *g_funct[11] = {ft_swap_a, ft_swap_b, ft_pick_b_to_a, ft_pick_a_to_b, ft_rotate_a, ft_rotate_b, ft_rotate_rev_a, ft_rotate_rev_b, ft_swap_both, ft_rotate_both, ft_rotate_rev_both};
 i = 0;
 j = 1987987;
 if (st == ((void *)0))
  st = ft_create_state_struct(lnk, new, st);
 while (i < 11)
 {
  ft_printf("J entre souvent ici ?");
  lnk_b = ft_create_empty(lnk_b);
  new = ft_lstmap_unmod(unsort);
  st->op = ((void *)0);
  j = g_funct[i](&new, &lnk_b, st);
  ft_printf("\n\n\n-------------------------------------J = %d----------------------\n\n\n", j);
  if (j == 0)
   break ;
  i++;
 }
}

canonical_original_code:
void ft_call_f(struct s_list_arg *lnk, struct s_list_arg *unsort, struct s_list_arg *lnk_b, struct s_state *st)
{
 int i;
 int j;
 struct s_list_arg *new;
 int (*g_funct[11])(struct s_list_arg **, struct s_list_arg **, struct s_state *) = {ft_swap_a, ft_swap_b, ft_pick_b_to_a, ft_pick_a_to_b, ft_rotate_a, ft_rotate_b, ft_rotate_rev_a, ft_rotate_rev_b, ft_swap_both, ft_rotate_both, ft_rotate_rev_both};
 i = 0;
 j = 1987987;
 if (st == ((void *)0))
  st = ft_create_state_struct(lnk, new, st);
 while (i < 11)
 {
  ft_printf("J entre souvent ici ?");
  lnk_b = ft_create_empty(lnk_b);
  new = ft_lstmap_unmod(unsort);
  st->op = ((void *)0);
  j = g_funct[i](&new, &lnk_b, st);
  ft_printf("\n\n\n-------------------------------------J = %d----------------------\n\n\n", j);
  if (j == 0)
   break ;
  i++;
 }
}

variable_types:
unsort
struct s_list_arg *

variable_types: int (*[11])(struct s_list_arg { int val; struct s_list_arg *next; } **, struct s_list_arg **, struct s_state { struct s_sort { struct s_list_arg *head; struct s_sort *next; } *list; struct s_sort *list_b; struct s_list_arg *obj; char *op; } *)

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


decompiled_code:
__int64 __fastcall basic_c_conv(unsigned int *a1, __int64 a2)
{
unsigned int v2; // eax
int *v3; // rdx
int v4; // ebp
__int64 v5; // rax
size_t v6; // rbx
void *buf; // [rsp+8h] [rbp-20h] BYREF

v2 = *a1;
if ( *a1 > 0x2F )
{
v3 = (int *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v3 + 2;
}
else
{
v3 = (int *)(*((_QWORD *)a1 + 2) + v2);
*a1 = v2 + 8;
}
v4 = *v3;
buf = (void *)ft_strnew(2LL);
if ( !buf )
impossible_malloc("strnew basic_c_conv");
*(_BYTE *)buf = v4;
apply_flags(&buf, a2);
v5 = ft_strlen(buf);
v6 = 1LL;
if ( v5 )
v6 = v5;
write(1, buf, v6);
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1, __int64 a2)
{
unsigned int v2; // eax
int *v3; // rdx
int v4; // ebp
__int64 v5; // rax
size_t v6; // rbx
void *buf; // [rsp+8h] [rbp-20h] BYREF

v2 = *a1;
if ( *a1 > 0x2F )
{
v3 = (int *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v3 + 2;
}
else
{
v3 = (int *)(*((_QWORD *)a1 + 2) + v2);
*a1 = v2 + 8;
}
v4 = *v3;
buf = (void *)ft_strnew(2LL);
if ( !buf )
impossible_malloc("strnew basic_c_conv");
*(_BYTE *)buf = v4;
apply_flags(&buf, a2);
v5 = ft_strlen(buf);
v6 = 1LL;
if ( v5 )
v6 = v5;
write(1, buf, v6);
return (unsigned int)v6;
}

original_code:
int basic_c_conv(va_list *ap, t_format *format)
{
 char conv;
 char *for_flags;
 size_t len;
 size_t len2;
 len = 1;
 conv = (char) __builtin_va_arg(*ap,int);
 for_flags = ft_strnew(2);
 if (!for_flags)
  impossible_malloc("strnew basic_c_conv");
 for_flags[0] = conv;
 apply_flags(&for_flags, format);
 if ((len2 = ft_strlen(for_flags)) > len)
  len = len2;
 write(1, for_flags, len);
 return (len);
}

canonical_original_code:
int basic_c_conv(__builtin_va_list *ap, struct s_format *format)
{
 char conv;
 char *for_flags;
 unsigned long len;
 unsigned long len2;
 len = 1;
 conv = (char) __builtin_va_arg(*ap,int);
 for_flags = ft_strnew(2);
 if (!for_flags)
  impossible_malloc("strnew basic_c_conv");
 for_flags[0] = conv;
 apply_flags(&for_flags, format);
 if ((len2 = ft_strlen(for_flags)) > len)
  len = len2;
 write(1, for_flags, len);
 return (len);
}

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: conv char

variable_types:
len
unsigned long

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


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

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

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

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

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

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


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

v1 = create_conv(99LL, basic_c_conv);
return add_conv(a1, v1);
}

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

v1 = create_conv(99LL, basic_c_conv);
return add_conv(a1, v1);
}

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

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

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


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

do
{
v1 = (void **)ptr;
ptr = (void *)*((_QWORD *)ptr + 2);
}
while ( ptr );
do
{
v2 = v1;
v1 = (void **)v1[3];
free(*v2);
free(v2);
}
while ( v1 );
}

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

do
{
v1 = (void **)ptr;
ptr = (void *)*((_QWORD *)ptr + 2);
}
while ( ptr );
do
{
v2 = v1;
v1 = (void **)v1[3];
free(*v2);
free(v2);
}
while ( v1 );
}

original_code:
void free_tok_list(t_token *tok)
{
 t_token *tmp;
 while (tok->next != ((void *)0))
 {
  tok = tok->next;
 }
 while (tok)
 {
  tmp = tok->prev;
  free(tok->val);
  free(tok);
  tok = tmp;
 }
}

canonical_original_code:
void free_tok_list(struct s_token *tok)
{
 struct s_token *tmp;
 while (tok->next != ((void *)0))
 {
  tok = tok->next;
 }
 while (tok)
 {
  tmp = tok->prev;
  free(tok->val);
  free(tok);
  tok = tmp;
 }
}

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

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


decompiled_code:
void __fastcall free_tree(void *ptr)
{
_QWORD *v1; // rbx
void *v2; // rbp
void *v3; // rdi

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

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

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

original_code:
void free_tree(t_ast *ast)
{
 t_ast *tmp;
 while (ast != ((void *)0))
 {
  tmp = ast->parent;
  if (ast->left != ((void *)0))
   free(ast->left);
  free(ast->right);
  free(ast);
  ast = tmp;
 }
}

canonical_original_code:
void free_tree(struct s_ast *ast)
{
 struct s_ast *tmp;
 while (ast != ((void *)0))
 {
  tmp = ast->parent;
  if (ast->left != ((void *)0))
   free(ast->left);
  free(ast->right);
  free(ast);
  ast = tmp;
 }
}

variable_types: struct s_ast { enum e_type { QUOTE=0, LREDIR=1, RREDIR=2, LAREDIR=3, RAREDIR=4, PIPE=5, SEMICOLON=6, WHITESPACE=7, STDCHAR=8, ENDOFLINE=9 } type; struct s_ast *parent; struct s_ast *leftcmd; char *left; char *right; int fd[2]; } *


decompiled_code:
__int64 __fastcall ft_25_lines(char *a1, float *a2, float *a3, _DWORD *a4)
{
__int64 result; // rax
float v5; // xmm0_4

result = (unsigned int)(*a1 - 48);
a4[1] = result;
if ( (unsigned int)result <= 9 )
{
if ( *a4 == 1 )
*a2 = *a2 / 10.0;
v5 = *a3 * 10.0 + (float)(int)a4[1];
*a3 = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, float *a2, float *a3, _DWORD *a4)
{
__int64 result; // rax
float v5; // xmm0_4

result = (unsigned int)(*a1 - 48);
a4[1] = result;
if ( (unsigned int)result <= 9 )
{
if ( *a4 == 1 )
*a2 = *a2 / 10.0;
v5 = *a3 * 10.0 + (float)(int)a4[1];
*a3 = v5;
}
return result;
}

original_code:
void ft_25_lines(const char *s, float *sign, float *val, int nbr[2])
{
 nbr[1] = *s - '0';
 if (nbr[1] >= 0 && nbr[1] <= 9)
 {
  if (nbr[0] == 1)
   *sign /= 10.0;
  *val = *val * 10.0 + (float)nbr[1];
 };
}

variable_types:
s
char *

variable_types:
sign
float *

variable_types:
val
float *

variable_types:
nbr
int [2]


original_code:
float ft_atof(const char *s)
{
 float val;
 float sign;
 int nbr[2];
 nbr[0] = 0;
 val = 0;
 sign = 1;
 if (*s == '-')
 {
  s++;
  sign = -1;
 };
 while (*s)
 {
  if (*s == '.')
  {
   nbr[0] = 1;
   s++;
   continue ;
  };
  ft_25_lines(s, &sign, &val, nbr);
  s++;
 };
 return (val * sign);
}

canonical_original_code:
float ft_atof(char *s)
{
 float val;
 float sign;
 int nbr[2];
 nbr[0] = 0;
 val = 0;
 sign = 1;
 if (*s == '-')
 {
  s++;
  sign = -1;
 };
 while (*s)
 {
  if (*s == '.')
  {
   nbr[0] = 1;
   s++;
   continue ;
  };
  ft_25_lines(s, &sign, &val, nbr);
  s++;
 };
 return (val * sign);
}

variable_types: val float

variable_types: sign float

return_type: float


original_code:
void f_fork(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_fork");
 param = get_val(dat->arena, proc->pc + 1, 2);
 param = get_true_val(param, 1, 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)
 {
  if (param > ((4*1024) / 2))
   param = param - (4*1024);
  ft_printf("fork: %ld bytes from pc %d to pc %d\n", param, proc->pc, forked->pc);
 }
 proc->pc = (proc->pc + 3) % (4*1024);
}

canonical_original_code:
void f_fork(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_fork");
 param = get_val(dat->arena, proc->pc + 1, 2);
 param = get_true_val(param, 1, 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)
 {
  if (param > ((4*1024) / 2))
   param = param - (4*1024);
  ft_printf("fork: %ld bytes from pc %d to pc %d\n", 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:
proc
struct s_proc *

variable_types: param long


decompiled_code:
__int64 __fastcall create_file(char *file)
{
unsigned int v1; // ebx

if ( access(file, 0) )
{
v1 = open(file, 577, 420LL);
if ( v1 == -1 )
ft_error("{create_file} Unable to create this file");
}
else if ( access(file, 2) )
{
ft_error("{create_file} Access denied");
v1 = -1;
}
else
{
v1 = open(file, 513);
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *file)
{
unsigned int v1; // ebx

if ( access(file, 0) )
{
v1 = open(file, 577, 420LL);
if ( v1 == -1 )
ft_error("{create_file} Unable to create this file");
}
else if ( access(file, 2) )
{
ft_error("{create_file} Access denied");
v1 = -1;
}
else
{
v1 = open(file, 513);
}
return v1;
}

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

variable_types:
file
char *

variable_types: fd int

variable_types: retf int

variable_types: retw int


decompiled_code:
__int64 __fastcall open_file(char *file)
{
unsigned int v1; // ebx

if ( access(file, 0) == -1 )
{
v1 = -1;
ft_error("{open_file} No such file or directory");
}
else
{
v1 = access(file, 4);
if ( v1 == -1 )
ft_error("{open_file} Access denied");
else
v1 = open(file, 0);
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *file)
{
unsigned int v1; // ebx

if ( access(file, 0) == -1 )
{
v1 = -1;
ft_error("{open_file} No such file or directory");
}
else
{
v1 = access(file, 4);
if ( v1 == -1 )
ft_error("{open_file} Access denied");
else
v1 = open(file, 0);
}
return v1;
}

original_code:
int open_file(char *file)
{
 int retf;
 int retr;
 int fd;
 if ((retf = access(file, 0)) != -1)
 {
  if ((retr = access(file, 4)) != -1)
  {
   if ((fd = open(file, 00)) != -1)
    return (fd);
  }
 }
 if (retf == -1)
  ft_error("{open_file} No such file or directory");
 else if (retr == -1)
  ft_error("{open_file} Access denied");
 return (-1);
}

variable_types: retr int


decompiled_code:
__int64 __fastcall handle_command(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax
__int64 v4; // rax

if ( (unsigned int)ft_strcmp(a1, "##start") )
{
if ( (unsigned int)ft_strcmp(a1, "##end") )
v2 = init_tok_list(a2, a1, 5LL);
else
v2 = init_tok_list(a2, a1, 1LL);
result = init_tok_list(v2, "endline", 6LL);
}
else
{
v4 = init_tok_list(a2, a1, 0LL);
result = init_tok_list(v4, "endline", 6LL);
}
return result;
}

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

if ( (unsigned int)ft_strcmp(a1, "##start") )
{
if ( (unsigned int)ft_strcmp(a1, "##end") )
v2 = init_tok_list(a2, a1, 5LL);
else
v2 = init_tok_list(a2, a1, 1LL);
result = init_tok_list(v2, "endline", 6LL);
}
else
{
v4 = init_tok_list(a2, a1, 0LL);
result = init_tok_list(v4, "endline", 6LL);
}
return result;
}

original_code:
t_tok *handle_command(char *line, t_tok *tok)
{
  if (ft_strcmp(line, "##start") == 0)
  {
   tok = init_tok_list(tok, line, START);
   tok = init_tok_list(tok, "endline", ENDLINE);
   return (tok);
  }
  if (ft_strcmp(line, "##end") == 0)
  {
   tok = init_tok_list(tok, line, END);
   tok = init_tok_list(tok, "endline", ENDLINE);
   return (tok);
  }
  else
  {
   tok = init_tok_list(tok, line, IGNORE);
   tok = init_tok_list(tok, "endline", ENDLINE);
   return (tok);
  }
}

canonical_original_code:
struct s_tok *handle_command(char *line, struct s_tok *tok)
{
  if (ft_strcmp(line, "##start") == 0)
  {
   tok = init_tok_list(tok, line, START);
   tok = init_tok_list(tok, "endline", ENDLINE);
   return (tok);
  }
  if (ft_strcmp(line, "##end") == 0)
  {
   tok = init_tok_list(tok, line, END);
   tok = init_tok_list(tok, "endline", ENDLINE);
   return (tok);
  }
  else
  {
   tok = init_tok_list(tok, line, IGNORE);
   tok = init_tok_list(tok, "endline", ENDLINE);
   return (tok);
  }
}

variable_types:
line
char *

variable_types:
tok
struct s_tok *

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


decompiled_code:
__int64 __fastcall build_list_each_line(__int64 a1, char *a2, _DWORD *a3)
{
__int64 v3; // r13
char v5; // si
__int64 result; // rax
char v8; // si
unsigned int v9; // er14
__int64 v10; // rax
char v11; // si
char *v12; // rbx
int v13; // ebp
__int64 v14; // rsi

v3 = a1;
++ln_0;
v5 = *a2;
if ( v5 == 35 )
{
if ( a2[1] == 35 )
result = handle_command((__int64)a2, a1);
else
result = init_tok_list(a1, a2, 2LL);
}
else if ( v5 )
{
if ( (unsigned int)ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", (unsigned int)v5) == -1 )
{
*a3 = 1;
result = a1;
}
else
{
v8 = *a2;
if ( *a2 )
{
v9 = 0;
while ( (unsigned int)ft_strichr(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789",
(unsigned int)v8) != -1 )
{
v11 = a2[v9];
if ( v11 )
{
v12 = &a2[v9 + 1];
v13 = 0;
do
{
if ( (unsigned int)ft_strichr(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789",
(unsigned int)v11) == -1 )
break;
++v13;
v11 = *v12++;
}
while ( v11 );
if ( v13 )
{
v14 = ft_strsub(a2, v9, v13);
v3 = init_tok_list(v3, v14, 3LL);
free_one(v14);
}
}
else
{
v13 = 0;
}
v9 += v13 + 1;
v8 = a2[v9];
if ( !v8 )
goto LABEL_21;
}
v10 = ft_itoa(ln_0);
ft_error_4("Lexing error on line ", v10, " for ", a2);
*a3 = 1;
result = v3;
}
else
{
LABEL_21:
result = init_tok_list(v3, "endline", 6LL);
}
}
}
else
{
*a3 = 1;
result = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char *a2, _DWORD *a3)
{
__int64 v3; // r13
char v5; // si
__int64 result; // rax
char v8; // si
unsigned int v9; // er14
__int64 v10; // rax
char v11; // si
char *v12; // rbx
int v13; // ebp
__int64 v14; // rsi

v3 = a1;
++ln_0;
v5 = *a2;
if ( v5 == 35 )
{
if ( a2[1] == 35 )
result = func0((__int64)a2, a1);
else
result = init_tok_list(a1, a2, 2LL);
}
else if ( v5 )
{
if ( (unsigned int)ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", (unsigned int)v5) == -1 )
{
*a3 = 1;
result = a1;
}
else
{
v8 = *a2;
if ( *a2 )
{
v9 = 0;
while ( (unsigned int)ft_strichr(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789",
(unsigned int)v8) != -1 )
{
v11 = a2[v9];
if ( v11 )
{
v12 = &a2[v9 + 1];
v13 = 0;
do
{
if ( (unsigned int)ft_strichr(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789",
(unsigned int)v11) == -1 )
break;
++v13;
v11 = *v12++;
}
while ( v11 );
if ( v13 )
{
v14 = ft_strsub(a2, v9, v13);
v3 = init_tok_list(v3, v14, 3LL);
free_one(v14);
}
}
else
{
v13 = 0;
}
v9 += v13 + 1;
v8 = a2[v9];
if ( !v8 )
goto LABEL_21;
}
v10 = ft_itoa(ln_0);
ft_error_4("Lexing error on line ", v10, " for ", a2);
*a3 = 1;
result = v3;
}
else
{
LABEL_21:
result = init_tok_list(v3, "endline", 6LL);
}
}
}
else
{
*a3 = 1;
result = a1;
}
return result;
}

original_code:
t_tok *build_list_each_line(t_tok *tok, char *line, int *err)
{
 int i;
 int j;
 char *tokblok;
 static int ln = 0;
 i = j = 0;
 ln += 1;
 if (line[0] == '#' && line[1] == '#')
  return (tok = handle_command(line, tok));
 else if (line[0] == '#' && line[1] != '#')
  return (tok = init_tok_list(tok, line, COMMENT));
 else if (line[0] == '\0')
 {
  *err = 1;
  return (tok);
 }
 else if (ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", line[0]) != -1)
 {
  while (j = 0, line[i] != '\0')
  {
   if (ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", line[i]) == -1)
   {
    ft_error_4("Lexing error on line ", ft_itoa(ln), " for ", line);
    *err = 1;
    return (tok);
   }
   while (line[i + j] != '\0' && ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", line[i + j]) != -1)
    j++;
   if (j != 0)
   {
    tokblok = ft_strsub(line, i, j);
    tok = init_tok_list(tok, tokblok, NAME);
    free_one(tokblok);
   }
   i += j + 1;
  }
  return (tok = init_tok_list(tok, "endline", ENDLINE));
 }
 *err = 1;
 return (tok);
}

canonical_original_code:
struct s_tok *build_list_each_line(struct s_tok *tok, char *line, int *err)
{
 int i;
 int j;
 char *tokblok;
 static int ln = 0;
 i = j = 0;
 ln += 1;
 if (line[0] == '#' && line[1] == '#')
  return (tok = handle_command(line, tok));
 else if (line[0] == '#' && line[1] != '#')
  return (tok = init_tok_list(tok, line, COMMENT));
 else if (line[0] == '\0')
 {
  *err = 1;
  return (tok);
 }
 else if (ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", line[0]) != -1)
 {
  while (j = 0, line[i] != '\0')
  {
   if (ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", line[i]) == -1)
   {
    ft_error_4("Lexing error on line ", ft_itoa(ln), " for ", line);
    *err = 1;
    return (tok);
   }
   while (line[i + j] != '\0' && ft_strichr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ_0123456789", line[i + j]) != -1)
    j++;
   if (j != 0)
   {
    tokblok = ft_strsub(line, i, j);
    tok = init_tok_list(tok, tokblok, NAME);
    free_one(tokblok);
   }
   i += j + 1;
  }
  return (tok = init_tok_list(tok, "endline", ENDLINE));
 }
 *err = 1;
 return (tok);
}

variable_types:
err
int *

variable_types: i int

variable_types: j int

variable_types:
tokblok
char *

variable_types: ln int

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


decompiled_code:
__int64 build_lex_list()
{
__int64 v0; // rbx
char *v2; // [rsp+0h] [rbp-18h] BYREF
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = 0;
v0 = 0LL;
while ( (int)get_next_line(0LL, &v2) > 0 && !v3[0] )
{
v0 = build_list_each_line(v0, v2, v3);
free_one(v2);
}
return v0;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbx
char *v2; // [rsp+0h] [rbp-18h] BYREF
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = 0;
v0 = 0LL;
while ( (int)get_next_line(0LL, &v2) > 0 && !v3[0] )
{
v0 = func1(v0, v2, v3);
free_one(v2);
}
return v0;
}

original_code:
t_tok *build_lex_list(void)
{
 int ret;
 int err;
 char *line;
 t_tok *tok;
 tok = ((void *)0);
 err = 0;
 while ((ret = get_next_line(0, &line)) > 0 && err == 0)
 {
  tok = build_list_each_line(tok, line, &err);
  free_one(line);
 }
 return (tok);
}

canonical_original_code:
struct s_tok *build_lex_list()
{
 int ret;
 int err;
 char *line;
 struct s_tok *tok;
 tok = ((void *)0);
 err = 0;
 while ((ret = get_next_line(0, &line)) > 0 && err == 0)
 {
  tok = build_list_each_line(tok, line, &err);
  free_one(line);
 }
 return (tok);
}

variable_types: ret int

variable_types: err int

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


decompiled_code:
_BOOL8 __fastcall ft_swap_b(_QWORD *a1, _QWORD *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rdx

ft_printf("\nSWAP B\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v4 = *a2;
if ( *a2 )
{
v5 = *(_QWORD *)(v4 + 8);
if ( v5 )
{
*(_QWORD *)(v4 + 8) = *(_QWORD *)(v5 + 8);
*(_QWORD *)(v5 + 8) = v4;
*a2 = v5;
}
}
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "sb");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 1LL) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_QWORD *a1, _QWORD *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rdx

ft_printf("\nSWAP B\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v4 = *a2;
if ( *a2 )
{
v5 = *(_QWORD *)(v4 + 8);
if ( v5 )
{
*(_QWORD *)(v4 + 8) = *(_QWORD *)(v5 + 8);
*(_QWORD *)(v5 + 8) = v4;
*a2 = v5;
}
}
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "sb");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 1LL) != 0;
}

original_code:
int ft_swap_b(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "sb";
 t_sort *tmp;
 t_sort *tmp2;
 ft_printf("\nSWAP B\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 if ((*lnk_b) != ((void *)0) && (*lnk_b)->next != ((void *)0))
 {
  tmp = (*lnk_b);
  tmp2 = (*lnk_b)->next;
  tmp->next = (*lnk_b)->next->next;
  tmp2->next = tmp;
  (*lnk_b) = tmp2;
 }
    state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 1) == 0)
  return (0);
    return (1);
}

canonical_original_code:
int ft_swap_b(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "sb";
 struct s_list_arg *tmp;
 struct s_list_arg *tmp2;
 ft_printf("\nSWAP B\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 if ((*lnk_b) != ((void *)0) && (*lnk_b)->next != ((void *)0))
 {
  tmp = (*lnk_b);
  tmp2 = (*lnk_b)->next;
  tmp->next = (*lnk_b)->next->next;
  tmp2->next = tmp;
  (*lnk_b) = tmp2;
 }
    state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 1) == 0)
  return (0);
    return (1);
}

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

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

variable_types:
op
char *


decompiled_code:
_BOOL8 __fastcall ft_pick_a_to_b(unsigned int **a1, unsigned int **a2, __int64 a3)
{
unsigned int *v4; // r13

ft_printf("\nPICK A TO B\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v4 = (unsigned int *)*((_QWORD *)*a1 + 1);
ft_printf("tmp->val = %d\n", *v4);
*((_QWORD *)*a1 + 1) = *a2;
*a2 = *a1;
*a1 = v4;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "pb");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 3LL) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned int **a1, unsigned int **a2, __int64 a3)
{
unsigned int *v4; // r13

ft_printf("\nPICK A TO B\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v4 = (unsigned int *)*((_QWORD *)*a1 + 1);
ft_printf("tmp->val = %d\n", *v4);
*((_QWORD *)*a1 + 1) = *a2;
*a2 = *a1;
*a1 = v4;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "pb");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 3LL) != 0;
}

original_code:
int ft_pick_a_to_b(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "pb";
 t_sort *tmp;
 ft_printf("\nPICK A TO B\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 if (lnk != ((void *)0))
 {
  tmp = (*lnk)->next;
  ft_printf("tmp->val = %d\n", tmp->val);
  (*lnk)->next = (*lnk_b);
  (*lnk_b) = (*lnk);
  (*lnk) = tmp;
 }
 state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 3) == 0)
  return (0);
    return (1);
}

canonical_original_code:
int ft_pick_a_to_b(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "pb";
 struct s_list_arg *tmp;
 ft_printf("\nPICK A TO B\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 if (lnk != ((void *)0))
 {
  tmp = (*lnk)->next;
  ft_printf("tmp->val = %d\n", tmp->val);
  (*lnk)->next = (*lnk_b);
  (*lnk_b) = (*lnk);
  (*lnk) = tmp;
 }
 state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 3) == 0)
  return (0);
    return (1);
}

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

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


decompiled_code:
_BOOL8 __fastcall ft_rotate_b(_QWORD *a1, const void **a2, __int64 a3)
{
_QWORD *v4; // rdx
_BOOL8 result; // rax
const void *v6; // rcx
_QWORD *v7; // rax

ft_printf("\nROT B\n\n");
ft_printf("lnk_b = %p\n", *a2);
v4 = *a2;
result = 1LL;
if ( *a2 )
{
v6 = (const void *)v4[1];
if ( v6 )
{
v7 = (_QWORD *)v4[1];
do
{
*a2 = v7;
v7 = (_QWORD *)v7[1];
}
while ( v7 );
v4[1] = 0LL;
*((_QWORD *)*a2 + 1) = v4;
*a2 = v6;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rb");
result = (unsigned int)ft_update_state(a3, *a1, *a2, 5LL) != 0;
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(_QWORD *a1, const void **a2, __int64 a3)
{
_QWORD *v4; // rdx
_BOOL8 result; // rax
const void *v6; // rcx
_QWORD *v7; // rax

ft_printf("\nROT B\n\n");
ft_printf("lnk_b = %p\n", *a2);
v4 = *a2;
result = 1LL;
if ( *a2 )
{
v6 = (const void *)v4[1];
if ( v6 )
{
v7 = (_QWORD *)v4[1];
do
{
*a2 = v7;
v7 = (_QWORD *)v7[1];
}
while ( v7 );
v4[1] = 0LL;
*((_QWORD *)*a2 + 1) = v4;
*a2 = v6;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rb");
result = (unsigned int)ft_update_state(a3, *a1, *a2, 5LL) != 0;
}
}
return result;
}

original_code:
int ft_rotate_b(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "rb";
 t_sort *tmp;
 t_sort *tmp_move;
 ft_printf("\nROT B\n\n");
 ft_printf("lnk_b = %p\n", (void*)(*lnk_b));
 if ((*lnk_b) != ((void *)0) && (*lnk_b)->next != ((void *)0))
 {
  tmp = (*lnk_b)->next;
  tmp_move = (*lnk_b);
  while ((*lnk_b)->next != ((void *)0))
   (*lnk_b) = (*lnk_b)->next;
  tmp_move->next = ((void *)0);
  (*lnk_b)->next = tmp_move;
  (*lnk_b) = tmp;
  state->op = ft_add_operation(state->op, op);
  if (ft_update_state(state, (*lnk), (*lnk_b), 5) == 0)
   return (0);
 }
    return (1);
}

canonical_original_code:
int ft_rotate_b(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "rb";
 struct s_list_arg *tmp;
 struct s_list_arg *tmp_move;
 ft_printf("\nROT B\n\n");
 ft_printf("lnk_b = %p\n", (void *)(*lnk_b));
 if ((*lnk_b) != ((void *)0) && (*lnk_b)->next != ((void *)0))
 {
  tmp = (*lnk_b)->next;
  tmp_move = (*lnk_b);
  while ((*lnk_b)->next != ((void *)0))
   (*lnk_b) = (*lnk_b)->next;
  tmp_move->next = ((void *)0);
  (*lnk_b)->next = tmp_move;
  (*lnk_b) = tmp;
  state->op = ft_add_operation(state->op, op);
  if (ft_update_state(state, (*lnk), (*lnk_b), 5) == 0)
   return (0);
 }
    return (1);
}


original_code:
int ft_rotate_rev_b(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "rrb";
 t_sort *tmp;
 t_sort *tmp2;
 ft_printf("ROT REV B\n");
 tmp = (*lnk_b);
 if ((*lnk_b) != ((void *)0) && (*lnk_b)->next != ((void *)0))
 {
  while ((*lnk_b)->next != ((void *)0))
  {
   tmp2 = (*lnk_b);
   (*lnk_b) = (*lnk_b)->next;
  }
  tmp2->next = ((void *)0);
  (*lnk_b)->next = tmp;
  state->op = ft_add_operation(state->op, op);
  if (ft_update_state(state, (*lnk), (*lnk_b), 7) == 0)
   return (0);
 }
    return (1);
}

canonical_original_code:
int ft_rotate_rev_b(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "rrb";
 struct s_list_arg *tmp;
 struct s_list_arg *tmp2;
 ft_printf("ROT REV B\n");
 tmp = (*lnk_b);
 if ((*lnk_b) != ((void *)0) && (*lnk_b)->next != ((void *)0))
 {
  while ((*lnk_b)->next != ((void *)0))
  {
   tmp2 = (*lnk_b);
   (*lnk_b) = (*lnk_b)->next;
  }
  tmp2->next = ((void *)0);
  (*lnk_b)->next = tmp;
  state->op = ft_add_operation(state->op, op);
  if (ft_update_state(state, (*lnk), (*lnk_b), 7) == 0)
   return (0);
 }
    return (1);
}


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

for ( result = 0LL; a1; a1 = *(_QWORD *)(a1 + 64) )
result = (unsigned int)(result + 1);
return result;
}

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

for ( result = 0LL; a1; a1 = *(_QWORD *)(a1 + 64) )
result = (unsigned int)(result + 1);
return result;
}

original_code:
int list_count(t_format *list)
{
 int count;
 count = 0;
 if (list)
 {
  while (list)
  {
   count++;
   list = list->next;
  }
 }
 return (count);
}

canonical_original_code:
int list_count(struct s_format *list)
{
 int count;
 count = 0;
 if (list)
 {
  while (list)
  {
   count++;
   list = list->next;
  }
 }
 return (count);
}

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


decompiled_code:
__int64 __fastcall create_conv(char a1, __int64 a2)
{
__int64 v2; // rbx

v2 = ft_memalloc(24LL);
if ( !v2 )
impossible_malloc("t_conv");
*(_BYTE *)v2 = a1;
*(_QWORD *)(v2 + 8) = a2;
*(_QWORD *)(v2 + 16) = 0LL;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1, __int64 a2)
{
__int64 v2; // rbx

v2 = ft_memalloc(24LL);
if ( !v2 )
impossible_malloc("t_conv");
*(_BYTE *)v2 = a1;
*(_QWORD *)(v2 + 8) = a2;
*(_QWORD *)(v2 + 16) = 0LL;
return v2;
}

original_code:
t_conv *create_conv(char conv, t_func f)
{
 t_conv *elem;
 if ((elem = (t_conv *) ft_memalloc(sizeof(t_conv))) == ((void *)0))
  impossible_malloc("t_conv");
 elem->conv = conv;
 elem->func = f;
 elem->next = ((void *)0);
 return (elem);
}

canonical_original_code:
struct s_conv *create_conv(char conv, int (*f)(__builtin_va_list *, struct s_format *))
{
 struct s_conv *elem;
 if ((elem = (struct s_conv *) ft_memalloc(sizeof(t_conv))) == ((void *)0))
  impossible_malloc("t_conv");
 elem->conv = conv;
 elem->func = f;
 elem->next = ((void *)0);
 return (elem);
}

variable_types: conv char

variable_types: int (*)(__builtin_va_list *, struct s_format *)

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


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

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

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

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

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

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

variable_types:
split
char **

variable_types:
i
unsigned int

return_type: char **


decompiled_code:
__int64 __fastcall ft_strsplit(char *a1, char a2)
{
char *v2; // rbx
unsigned int v3; // er12
_DWORD *v4; // r13
__int64 i; // r12
unsigned int j; // er8
char v8; // al
unsigned int v9; // ecx
unsigned int v10; // edx

v2 = a1;
v3 = count_words(a1, a2);
v4 = get_word_len(v3, a1, a2);
for ( i = build_array(v3, (__int64)v4); *v2 == a2; ++v2 )
;
for ( j = 0; *v2; ++j )
{
v8 = *v2;
if ( a2 != *v2 && v8 )
{
v9 = 0;
do
{
++v2;
v10 = v9++;
*(_BYTE *)(*(_QWORD *)(i + 8LL * j) + v10) = v8;
v8 = *v2;
}
while ( *v2 != a2 && v8 );
}
for ( ; *v2 == a2 && *v2; ++v2 )
;
}
free(v4);
return i;
}

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

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

variable_types:
s
char *

variable_types: c char

variable_types:
j
unsigned int


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

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

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

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

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


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

v1 = create_conv(120LL, basic_x_conv);
add_conv(a1, v1);
v2 = create_conv(112LL, basic_p_conv);
return add_conv(a1, v2);
}

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

v1 = create_conv(120LL, basic_x_conv);
add_conv(a1, v1);
v2 = create_conv(112LL, basic_p_conv);
return add_conv(a1, v2);
}

original_code:
static void add_basic(t_conv **list)
{
 add_conv(list, create_conv('x', basic_x_conv));
 add_conv(list, create_conv('p', basic_p_conv));
}

canonical_original_code:
static void add_basic(struct s_conv **list)
{
 add_conv(list, create_conv('x', basic_x_conv));
 add_conv(list, create_conv('p', basic_p_conv));
}


original_code:
int pressed_key_left(char *c, t_print *print)
{
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 68 && c[3] == 0))
  return (0);
 print->startsel = print->endsel = 0;
 if (print->pos > 0)
 {
  print->ins = 1;
  tputs(tgetstr("le", ((void *)0)), 1, out);
  print->pos -= 1;
 }
 return (1);
}

canonical_original_code:
int pressed_key_left(char *c, struct s_print *print)
{
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 68 && c[3] == 0))
  return (0);
 print->startsel = print->endsel = 0;
 if (print->pos > 0)
 {
  print->ins = 1;
  tputs(tgetstr("le", ((void *)0)), 1, out);
  print->pos -= 1;
 }
 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; }


original_code:
int pressed_key_right(char *c, t_print *print)
{
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 67 && c[3] == 0))
  return (0);
 print->startsel = print->endsel = 0;
 if (print->pos >= 0 && print->pos < (int)ft_strlen(print->line))
 {
  print->ins = 1;
  tputs(tgetstr("nd", ((void *)0)), 1, out);
  print->pos += 1;
 }
 return (1);
}

canonical_original_code:
int pressed_key_right(char *c, struct s_print *print)
{
 if (!(c[0] == 27 && c[1] == 91 && c[2] == 67 && c[3] == 0))
  return (0);
 print->startsel = print->endsel = 0;
 if (print->pos >= 0 && print->pos < (int)ft_strlen(print->line))
 {
  print->ins = 1;
  tputs(tgetstr("nd", ((void *)0)), 1, out);
  print->pos += 1;
 }
 return (1);
}

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


decompiled_code:
void __fastcall check_for_arg_nb(__int64 a1)
{
__int64 v1; // rax
int v2; // ebx

if ( a1 )
{
v1 = a1;
v2 = 0;
do
{
v2 += *(_DWORD *)(v1 + 4) != -1;
v1 = *(_QWORD *)(v1 + 64);
}
while ( v1 );
if ( v2 )
{
if ( (unsigned int)list_count() != v2 )
kill_me("If you are going to use $-Style please use it everywhere.");
}
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
__int64 v1; // rax
int v2; // ebx

if ( a1 )
{
v1 = a1;
v2 = 0;
do
{
v2 += *(_DWORD *)(v1 + 4) != -1;
v1 = *(_QWORD *)(v1 + 64);
}
while ( v1 );
if ( v2 )
{
if ( (unsigned int)list_count() != v2 )
kill_me("If you are going to use $-Style please use it everywhere.");
}
}
}

original_code:
void check_for_arg_nb(t_format *list)
{
 int nb_arg;
 t_format *save;
 nb_arg = 0;
 save = list;
 while (list)
 {
  if (list->arg_nb != -1)
   nb_arg++;
  list = list->next;
 }
 if ((nb_arg != 0) && (list_count(save) != nb_arg))
  kill_me("If you are going to use $-Style please use it everywhere.");
 save = ((void *)0);
}

canonical_original_code:
void check_for_arg_nb(struct s_format *list)
{
 int nb_arg;
 struct s_format *save;
 nb_arg = 0;
 save = list;
 while (list)
 {
  if (list->arg_nb != -1)
   nb_arg++;
  list = list->next;
 }
 if ((nb_arg != 0) && (list_count(save) != nb_arg))
  kill_me("If you are going to use $-Style please use it everywhere.");
 save = ((void *)0);
}


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

ft_putchar_fd((unsigned int)*(char *)(*(_QWORD *)(a1 + 48) + *(_QWORD *)(a1 + 40) - 1LL), 1LL);
result = *(unsigned int *)(a1 + 16);
if ( !(_DWORD)result )
result = 1LL;
return result;
}

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

ft_putchar_fd((unsigned int)*(char *)(*(_QWORD *)(a1 + 48) + *(_QWORD *)(a1 + 40) - 1LL), 1LL);
result = *(unsigned int *)(a1 + 16);
if ( !(_DWORD)result )
result = 1LL;
return result;
}

original_code:
int print_bad_format(t_format *format)
{
 ft_putchar_fd((format->format)[(format->length - 1)], 1);
 if (format->m_width != 0)
  return (format->m_width);
 return (1);
}

canonical_original_code:
int print_bad_format(struct s_format *format)
{
 ft_putchar_fd((format->format)[(format->length - 1)], 1);
 if (format->m_width != 0)
  return (format->m_width);
 return (1);
}


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

v2 = (__int64 (__fastcall *)(__int64, __int64))get_conversion(a2);
if ( v2 )
result = v2(a1, a2);
else
result = print_bad_format(a2);
return result;
}

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

v2 = (__int64 (__fastcall *)(__int64, __int64))get_conversion(a2);
if ( v2 )
result = v2(a1, a2);
else
result = func1(a2);
return result;
}

original_code:
int print_arg(va_list *ap, t_format *list)
{
 t_func f;
 int printed;
 f = get_conversion(list);
 if (!f)
  return (print_bad_format(list));
 printed = (*f)(ap, list);
 return (printed);
}

canonical_original_code:
int print_arg(__builtin_va_list *ap, struct s_format *list)
{
 int (*f)(__builtin_va_list *, struct s_format *);
 int printed;
 f = get_conversion(list);
 if (!f)
  return (print_bad_format(list));
 printed = (*f)(ap, list);
 return (printed);
}

variable_types:
ap
__builtin_va_list *

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

variable_types: printed int


decompiled_code:
_BOOL8 ft_strequ()
{
return (unsigned int)ft_strcmp() == 0;
}

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

original_code:
int ft_strequ(char const *s1, char const *s2)
{
 if (ft_strcmp(s1, s2) == 0)
  return (1);
 else
  return (0);
}

canonical_original_code:
int ft_strequ(char *s1, char *s2)
{
 if (ft_strcmp(s1, s2) == 0)
  return (1);
 else
  return (0);
}


decompiled_code:
_BOOL8 ft_check_var_exist()
{
return ft_getenv() != 0;
}

canonical_decompiled_code:
_BOOL8 func2()
{
return ft_getenv() != 0;
}

original_code:
int ft_check_var_exist(char *varname, char **env)
{
 if (ft_getenv(varname, env) == ((void *)0))
  return (0);
 else
  return (1);
}

variable_types:
varname
char *

variable_types:
env
char **


original_code:
static char *for_sad(char *jn, int *i, int *k)
{
 int j;
 char *tmp;
 char *tmp2;
 j = 0;
 while (jn[*i - 2 - j] != '/' && (*i - 2 - j) > 0)
  j++;
 if ((*i - 2 - j) > -1)
 {
  tmp = ft_strsub(jn, 0, *i - 2 - j);
  tmp2 = ft_strsub(jn, *i + 2, 300);
  free(jn);
  jn = ft_strjoin(tmp, tmp2);
 }
 else
 {
  tmp = ft_strsub(jn, 0, *i);
  tmp2 = ft_strsub(jn, *i + 3, 300);
  free(jn);
  jn = ft_strjoin(tmp, tmp2);
 }
 free(tmp);
 free(tmp2);
 *k += 1;
 return (jn);
}

variable_types:
jn
char *

variable_types:
i
int *

variable_types:
k
int *

variable_types: j int

variable_types:
tmp
char *

return_type: char *


decompiled_code:
__int64 __fastcall ft_striteri(_BYTE *a1, __int64 (__fastcall *a2)(_QWORD, _BYTE *))
{
_BYTE *v2; // rbx
unsigned int v3; // ebp
__int64 result; // rax

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

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

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

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

variable_types:
f
void (*)(unsigned int, char *)

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall ft_execute_or_print_env(__int64 *a1, __int64 a2, int a3, int a4)
{
__int64 result; // rax
const char **v6; // [rsp+8h] [rbp-10h] BYREF

v6 = (const char **)a1;
result = a3;
if ( *(_QWORD *)(a2 + 8LL * a3) )
{
result = (__int64)ft_execute_cmd_from_env((__int64 **)&v6, a2, a3);
++a4;
}
if ( a4 == 1 )
result = ft_print_env(v6);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, __int64 a2, int a3, int a4)
{
__int64 result; // rax
const char **v6; // [rsp+8h] [rbp-10h] BYREF

v6 = (const char **)a1;
result = a3;
if ( *(_QWORD *)(a2 + 8LL * a3) )
{
result = (__int64)ft_execute_cmd_from_env((__int64 **)&v6, a2, a3);
++a4;
}
if ( a4 == 1 )
result = func1(v6);
return result;
}

original_code:
void ft_execute_or_print_env(char **env, char **arg, int i, int j)
{
 if (arg[i] != ((void *)0))
 {
  ft_execute_cmd_from_env(&env, arg, i);
  j++;
 }
 if (j == 1)
  ft_print_env(env);
}

variable_types:
arg
char **

variable_types: i int


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

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

variable_types:
lnk
struct s_list2 *

variable_types:
new
struct s_list2 *

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


original_code:
t_list2 *ft_lstnew_dir(const char *name, t_list2 *tmp)
{
 if (name == 0)
  tmp->name = ((void *)0);
 else
  tmp->name = ft_strdup(name);
 tmp->right = ((void *)0);
 tmp->owner = ((void *)0);
 tmp->group = ((void *)0);
 tmp->time = ((void *)0);
 tmp->link = ((void *)0);
 tmp->size = 0;
 tmp->major = ((void *)0);
 tmp->minor = ((void *)0);
 tmp->blk = 0;
 tmp->timestamp = 0;
 tmp->prev = ((void *)0);
 tmp->next = ((void *)0);
 return (tmp);
}

canonical_original_code:
struct s_list2 *ft_lstnew_dir(char *name, struct s_list2 *tmp)
{
 if (name == 0)
  tmp->name = ((void *)0);
 else
  tmp->name = ft_strdup(name);
 tmp->right = ((void *)0);
 tmp->owner = ((void *)0);
 tmp->group = ((void *)0);
 tmp->time = ((void *)0);
 tmp->link = ((void *)0);
 tmp->size = 0;
 tmp->major = ((void *)0);
 tmp->minor = ((void *)0);
 tmp->blk = 0;
 tmp->timestamp = 0;
 tmp->prev = ((void *)0);
 tmp->next = ((void *)0);
 return (tmp);
}

variable_types:
name
char *

variable_types:
tmp
struct s_list2 *


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

result = ft_isalpha();
if ( (_DWORD)result != 1 )
result = (unsigned int)ft_isdigit(a1) == 1;
return result;
}

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

result = ft_isalpha();
if ( (_DWORD)result != 1 )
result = (unsigned int)ft_isdigit(a1) == 1;
return result;
}

original_code:
int ft_isalnum(int c)
{
 if (ft_isalpha(c) == 1 || ft_isdigit(c) == 1)
  return (1);
 else
  return (0);
}

variable_types: c int


decompiled_code:
__int64 __fastcall ft_strnbchr(char *a1, int a2)
{
char v2; // dl
__int64 v3; // rax
unsigned int v4; // er8

v2 = *a1;
if ( !*a1 || v2 == a2 )
{
v4 = 0;
}
else
{
v3 = 1LL;
do
{
v4 = v3;
v2 = a1[v3++];
}
while ( v2 && v2 != a2 );
}
if ( a2 && !v2 )
v4 = -1;
return v4;
}

original_code:
int ft_strnbchr(const char *str, int c)
{
 char ch;
 int i;
 ch = (char)c;
 i = 0;
 while (str[i] != c && str[i] != '\0')
  i++;
 if (str[i] == '\0' && c != '\0')
  return (-1);
 return (i);
}

canonical_original_code:
int ft_strnbchr(char *str, int c)
{
 char ch;
 int i;
 ch = (char)c;
 i = 0;
 while (str[i] != c && str[i] != '\0')
  i++;
 if (str[i] == '\0' && c != '\0')
  return (-1);
 return (i);
}

variable_types:
str
char *

variable_types: ch char


decompiled_code:
void __fastcall mod_path(void **a1)
{
void **v1; // rbx
void *v2; // rdi
__int64 v3; // rbp

v1 = a1;
v2 = *a1;
if ( v2 )
{
do
{
v3 = ft_strjoin(v2, "/");
free(*v1);
*v1++ = (void *)v3;
v2 = *v1;
}
while ( *v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(void **a1)
{
void **v1; // rbx
void *v2; // rdi
__int64 v3; // rbp

v1 = a1;
v2 = *a1;
if ( v2 )
{
do
{
v3 = ft_strjoin(v2, "/");
free(*v1);
*v1++ = (void *)v3;
v2 = *v1;
}
while ( *v1 );
}
}

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

variable_types:
path
char **


decompiled_code:
void __fastcall __noreturn do_shit(__int64 a1, __int64 a2)
{
const char *v2; // rax
_QWORD *v3; // rax
_QWORD *v4; // rbx
__int64 v5[2]; // [rsp+8h] [rbp-30h] BYREF
__int64 v6[4]; // [rsp+18h] [rbp-20h] BYREF

v5[0] = a1;
while ( 1 )
{
v2 = (const char *)ft_getenv("PWD", v5[0]);
ft_printf("%s > ", v2);
if ( (int)get_next_line(0LL, v6) <= 0 )
break;
v3 = (_QWORD *)ft_strsplit(v6[0], 32LL);
v4 = v3;
if ( *v3 )
{
if ( !(unsigned int)ft_check_builtins((__int64)v5, v3) )
ft_not_builtins(a2, v4, v5);
}
}
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(__int64 a1, __int64 a2)
{
const char *v2; // rax
_QWORD *v3; // rax
_QWORD *v4; // rbx
__int64 v5[2]; // [rsp+8h] [rbp-30h] BYREF
__int64 v6[4]; // [rsp+18h] [rbp-20h] BYREF

v5[0] = a1;
while ( 1 )
{
v2 = (const char *)ft_getenv("PWD", v5[0]);
ft_printf("%s > ", v2);
if ( (int)get_next_line(0LL, v6) <= 0 )
break;
v3 = (_QWORD *)ft_strsplit(v6[0], 32LL);
v4 = v3;
if ( *v3 )
{
if ( !(unsigned int)func0((__int64)v5, v3) )
ft_not_builtins(a2, v4, v5);
}
}
exit(1);
}

original_code:
void do_shit(char **env, char **path)
{
 char **arg;
 char *in;
 int *pid;
 int ret;
 int i;
 pid = ((void *)0);
 while (ft_printf("%s > ", ft_getenv("PWD", env)), (ret = get_next_line(0, &in)) > 0)
 {
  i = 0;
  arg = ft_strsplit(in, ' ');
  if (arg[0] != ((void *)0))
  {
   i = ft_check_builtins(&env, arg);
   if (!i)
    ft_not_builtins(path, arg, &env);
  }
 }
 exit(1);
}

variable_types:
env
char **

variable_types:
in
char *

variable_types:
pid
int *

variable_types: ret int


original_code:
void f_zjmp(t_dat *dat, t_proc *proc)
{
 long val;
 val = get_val(dat->arena, (proc->pc + 1), 2);
 val = get_true_val(val, 1, 2);
 if (proc->carry == 1)
 {
  if (dat->verbose)
   ft_printf("zjmp: %ld bytes from pc %d ", val, proc->pc);
  proc->pc = (proc->pc + val) % (4*1024);
  if (dat->verbose)
   ft_printf("to pc %d [SUCCESS]\n", proc->pc);
 }
 else
 {
  if (dat->verbose)
   ft_printf("zjmp: %ld bytes from pc %d [FAIL]\n", val, proc->pc);
  proc->pc += 3;
  proc->pc = proc->pc % (4*1024);
 }
}

canonical_original_code:
void f_zjmp(struct s_dat *dat, struct s_proc *proc)
{
 long val;
 val = get_val(dat->arena, (proc->pc + 1), 2);
 val = get_true_val(val, 1, 2);
 if (proc->carry == 1)
 {
  if (dat->verbose)
   ft_printf("zjmp: %ld bytes from pc %d ", val, proc->pc);
  proc->pc = (proc->pc + val) % (4*1024);
  if (dat->verbose)
   ft_printf("to pc %d [SUCCESS]\n", proc->pc);
 }
 else
 {
  if (dat->verbose)
   ft_printf("zjmp: %ld bytes from pc %d [FAIL]\n", val, proc->pc);
  proc->pc += 3;
  proc->pc = proc->pc % (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:
proc
struct s_proc *

variable_types: val long


decompiled_code:
void __fastcall free_op_list(void *ptr)
{
_QWORD *v1; // rbx
_QWORD *v2; // rbp
void *v3; // rdi
void *v4; // rdi

v1 = ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[6];
v3 = (void *)v2[1];
if ( v3 )
free(v3);
v4 = (void *)v2[4];
if ( v4 )
free(v4);
free(v2);
}
while ( v1 );
}
}

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

v1 = ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[6];
v3 = (void *)v2[1];
if ( v3 )
free(v3);
v4 = (void *)v2[4];
if ( v4 )
free(v4);
free(v2);
}
while ( v1 );
}
}

original_code:
void free_op_list(t_op *op)
{
 t_op *tmp;
 while (op)
 {
  tmp = op->next;
  if (op->flag != ((void *)0))
   free(op->flag);
  if (op->mod != ((void *)0))
   free(op->mod);
  free(op);
  op = tmp;
 }
}

canonical_original_code:
void free_op_list(struct s_option *op)
{
 struct s_option *tmp;
 while (op)
 {
  tmp = op->next;
  if (op->flag != ((void *)0))
   free(op->flag);
  if (op->mod != ((void *)0))
   free(op->mod);
  free(op);
  op = tmp;
 }
}

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


decompiled_code:
__int64 ft_printf(__int64 a1, ...)
{
unsigned int v1; // er12
void *v2; // rbx
void *v3; // r12
unsigned int v4; // ebp
gcc_va_list va; // [rsp+8h] [rbp-E0h] BYREF

va_start(va, a1);
v1 = ft_find_arg_count(a1);
v2 = (void *)ft_analyse_str(a1, 0LL);
v3 = (void *)ft_build_arglst_conv(v2, va, 0LL, v1);
v4 = ft_print_out(a1, v2, v3);
free_arg_list(v3);
free_op_list(v2);
return v4;
}

canonical_decompiled_code:
__int64 func2(__int64 a1, ...)
{
unsigned int v1; // er12
void *v2; // rbx
void *v3; // r12
unsigned int v4; // ebp
gcc_va_list va; // [rsp+8h] [rbp-E0h] BYREF

va_start(va, a1);
v1 = ft_find_arg_count(a1);
v2 = (void *)ft_analyse_str(a1, 0LL);
v3 = (void *)ft_build_arglst_conv(v2, va, 0LL, v1);
v4 = ft_print_out(a1, v2, v3);
func0(v3);
func1(v2);
return v4;
}

original_code:
int ft_printf(const char *format, ...)
{
 int i;
 int argcnt;
 t_op *op;
 va_list ap;
 t_arg *lnk;
 op = ((void *)0);
 argcnt = ft_find_arg_count((char*)format);
 __builtin_va_start(ap,format);
 op = ft_analyse_str((char*)format, op);
 lnk = ((void *)0);
 lnk = ft_build_arglst_conv(op, &ap, lnk, argcnt);
 i = ft_print_out((char*)format, op, lnk);
 __builtin_va_end(ap);
 free_arg_list(lnk);
 free_op_list(op);
 return (i);
}

canonical_original_code:
int ft_printf(char *format, ...)
{
 int i;
 int argcnt;
 struct s_option *op;
 __builtin_va_list ap;
 struct s_arg *lnk;
 op = ((void *)0);
 argcnt = ft_find_arg_count((char *)format);
 __builtin_va_start(ap,format);
 op = ft_analyse_str((char *)format, op);
 lnk = ((void *)0);
 lnk = ft_build_arglst_conv(op, &ap, lnk, argcnt);
 i = ft_print_out((char *)format, op, lnk);
 __builtin_va_end(ap);
 free_arg_list(lnk);
 free_op_list(op);
 return (i);
}

variable_types:
format
char *

variable_types: i int

variable_types: argcnt int

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


decompiled_code:
void __fastcall __noreturn ft_error_exit(__int64 a1)
{
ft_putstr_fd("Minishell: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(".\n", 2LL);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(__int64 a1)
{
ft_putstr_fd("Minishell: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(".\n", 2LL);
exit(0);
}

original_code:
void ft_error_exit(char *s)
{
 ft_putstr_fd("Minishell: ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd(".\n", 2);
 exit(0);
}

variable_types:
s
char *


decompiled_code:
__int64 __fastcall ft_abs(int a1)
{
return abs32(a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return abs32(a1);
}

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

variable_types: x int


decompiled_code:
__int64 init_convlist()
{
if ( list_0 )
return list_0;
list_0 = (__int64)malloc(0x18uLL);
if ( !list_0 )
impossible_malloc("t_conv");
add_d_func(&list_0);
add_c_func(&list_0);
add_s_func(&list_0);
add_u_func(&list_0);
add_o_func(&list_0);
add_x_func(&list_0);
return list_0;
}

canonical_decompiled_code:
__int64 func0()
{
if ( list_0 )
return list_0;
list_0 = (__int64)malloc(0x18uLL);
if ( !list_0 )
impossible_malloc("t_conv");
add_d_func(&list_0);
add_c_func(&list_0);
add_s_func(&list_0);
add_u_func(&list_0);
add_o_func(&list_0);
add_x_func(&list_0);
return list_0;
}

original_code:
t_conv *init_convlist(void)
{
 static t_conv *list = ((void *)0);
 if (!list)
 {
  if ((list = (t_conv *) malloc(sizeof(t_conv))) == ((void *)0))
   impossible_malloc("t_conv");
  add_d_func(&list);
  add_c_func(&list);
  add_s_func(&list);
  add_u_func(&list);
  add_o_func(&list);
  add_x_func(&list);
 }
 return (list);
}

canonical_original_code:
struct s_conv *init_convlist()
{
 static struct s_conv *list = ((void *)0);
 if (!list)
 {
  if ((list = (struct s_conv *) malloc(sizeof(t_conv))) == ((void *)0))
   impossible_malloc("t_conv");
  add_d_func(&list);
  add_c_func(&list);
  add_s_func(&list);
  add_u_func(&list);
  add_o_func(&list);
  add_x_func(&list);
 }
 return (list);
}

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


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

result = init_convlist();
if ( !result )
return 0LL;
while ( *(_BYTE *)(a1 + 32) != *(_BYTE *)result )
{
result = *(_QWORD *)(result + 16);
if ( !result )
return result;
}
return *(_QWORD *)(result + 8);
}

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

result = func0();
if ( !result )
return 0LL;
while ( *(_BYTE *)(a1 + 32) != *(_BYTE *)result )
{
result = *(_QWORD *)(result + 16);
if ( !result )
return result;
}
return *(_QWORD *)(result + 8);
}

original_code:
t_func get_conversion(t_format *list)
{
 t_conv *conv;
 conv = init_convlist();
 while (conv)
 {
  if (list->conv == conv->conv)
   return (conv->func);
  conv = conv->next;
 }
 return (((void *)0));
}

canonical_original_code:
int (*get_conversion(struct s_format *list))(__builtin_va_list *, struct s_format *)
{
 struct s_conv *conv;
 conv = init_convlist();
 while (conv)
 {
  if (list->conv == conv->conv)
   return (conv->func);
  conv = conv->next;
 }
 return (((void *)0));
}

variable_types:
list
struct s_format *

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


original_code:
void apply_flags(char **s, t_format *format)
{
 t_paddir dir;
 int tmp;
 if (format->f_list)
 {
  if ((format->conv == 'd') || (format->conv == 'i'))
   handle_flags_for_d(s, format);
 }
 else if (format->m_width != 0)
 {
  tmp = format->m_width;
  dir = (format->m_width > 0 ? PAD_LEFT : PAD_RIGHT);
  if (tmp < 0)
   tmp = -tmp;
  ft_strpad2(s, tmp, dir, ' ');
 }
}

canonical_original_code:
void apply_flags(char **s, struct s_format *format)
{
 enum e_paddir dir;
 int tmp;
 if (format->f_list)
 {
  if ((format->conv == 'd') || (format->conv == 'i'))
   handle_flags_for_d(s, format);
 }
 else if (format->m_width != 0)
 {
  tmp = format->m_width;
  dir = (format->m_width > 0 ? PAD_LEFT : PAD_RIGHT);
  if (tmp < 0)
   tmp = -tmp;
  ft_strpad2(s, tmp, dir, ' ');
 }
}

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: enum e_paddir { PAD_LEFT=0, PAD_RIGHT=1 }

variable_types: tmp int


decompiled_code:
__int64 __fastcall ft_deal_with_octal_conversion(__int64 a1, __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax
__int64 v5; // rdi
__int64 v6; // rax
__int64 v7; // rax

v3 = *(_QWORD *)(a1 + 8);
if ( v3 && (unsigned int)ft_strichr(v3, 35LL) != -1 && *(_QWORD *)(a2 + 16) )
ft_putchar(48LL);
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a1 + 32), &unk_2BC, 2LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a1 + 32), &unk_2BF, 1LL) )
{
result = ft_deal_with_oct_spe_conv(a1, a2);
}
else
{
v6 = ft_convert_to_octal(*(unsigned __int16 *)(a2 + 16));
ft_putstr(v6);
v7 = ft_convert_to_octal(*(unsigned __int16 *)(a2 + 16));
result = ft_strlen(v7);
*(_QWORD *)(a2 + 24) += result;
}
}
else
{
result = ft_putchar((unsigned int)*(char *)(a2 + 16));
++*(_QWORD *)(a2 + 24);
}
v5 = *(_QWORD *)(a1 + 8);
if ( v5 )
{
result = ft_strichr(v5, 35LL);
if ( (_DWORD)result != -1 )
{
if ( *(_QWORD *)(a2 + 16) )
++*(_QWORD *)(a2 + 24);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax
__int64 v5; // rdi
__int64 v6; // rax
__int64 v7; // rax

v3 = *(_QWORD *)(a1 + 8);
if ( v3 && (unsigned int)ft_strichr(v3, 35LL) != -1 && *(_QWORD *)(a2 + 16) )
ft_putchar(48LL);
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a1 + 32), &unk_2BC, 2LL) )
{
if ( (unsigned int)ft_strncmp(*(_QWORD *)(a1 + 32), &unk_2BF, 1LL) )
{
result = ft_deal_with_oct_spe_conv(a1, a2);
}
else
{
v6 = ft_convert_to_octal(*(unsigned __int16 *)(a2 + 16));
ft_putstr(v6);
v7 = ft_convert_to_octal(*(unsigned __int16 *)(a2 + 16));
result = ft_strlen(v7);
*(_QWORD *)(a2 + 24) += result;
}
}
else
{
result = ft_putchar((unsigned int)*(char *)(a2 + 16));
++*(_QWORD *)(a2 + 24);
}
v5 = *(_QWORD *)(a1 + 8);
if ( v5 )
{
result = ft_strichr(v5, 35LL);
if ( (_DWORD)result != -1 )
{
if ( *(_QWORD *)(a2 + 16) )
++*(_QWORD *)(a2 + 24);
}
}
return result;
}

original_code:
void ft_deal_with_octal_conversion(t_op *op, t_arg *lnk)
{
 if (op->flag && ft_strichr(op->flag, '#') != -1 && lnk->ull != 0)
  ft_putchar('0');
 if (ft_strncmp(op->mod, "hh", 2) == 0)
 {
  ft_putchar((unsigned char)lnk->ull);
  lnk->ps += 1;
 }
 else if (ft_strncmp(op->mod, "h", 1) == 0)
 {
  ft_putstr(ft_convert_to_octal((unsigned short)lnk->ull));
  lnk->ps += ft_strlen(ft_convert_to_octal((unsigned short)lnk->ull));
 }
 else
  ft_deal_with_oct_spe_conv(op, lnk);
 if (op->flag && ft_strichr(op->flag, '#') != -1 && lnk->ull != 0)
  lnk->ps += 1;
}

canonical_original_code:
void ft_deal_with_octal_conversion(struct s_option *op, struct s_arg *lnk)
{
 if (op->flag && ft_strichr(op->flag, '#') != -1 && lnk->ull != 0)
  ft_putchar('0');
 if (ft_strncmp(op->mod, "hh", 2) == 0)
 {
  ft_putchar((unsigned char)lnk->ull);
  lnk->ps += 1;
 }
 else if (ft_strncmp(op->mod, "h", 1) == 0)
 {
  ft_putstr(ft_convert_to_octal((unsigned short)lnk->ull));
  lnk->ps += ft_strlen(ft_convert_to_octal((unsigned short)lnk->ull));
 }
 else
  ft_deal_with_oct_spe_conv(op, lnk);
 if (op->flag && ft_strichr(op->flag, '#') != -1 && lnk->ull != 0)
  lnk->ps += 1;
}

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


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

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

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

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

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

variable_types: pc int


main

canonical_name: main

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

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

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

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

variable_types: ac int

variable_types:
ag
char **

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

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

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


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

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

variable_types:
proc
struct s_proc *

variable_types: i long

variable_types: j long

variable_types: k long

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

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


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

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

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

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

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

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

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