decompiled_code:
__int64 __fastcall ft_setenv(__int64 a1, __int64 *a2)
{
__int64 *v2; // r12
__int64 v3; // rax
_QWORD *v4; // rax
__int64 result; // rax
__int64 v6; // rbx
__int64 v7; // rdi

v2 = *(__int64 **)(a1 + 16);
if ( v2 )
{
v3 = v2[2];
if ( v3 && *(_QWORD *)(v3 + 16) )
{
result = ft_error_msg("setenv: Too many arguments.", &unk_355);
}
else if ( (unsigned int)ft_find(*v2, &unk_353)
|| (v4 = (_QWORD *)v2[2]) != 0LL && (unsigned int)ft_find(*v4, &unk_353) )
{
result = ft_error_msg("setenv: Avoid the character '='", &unk_355);
}
else
{
result = ft_replace_or_add(v2, a2);
}
}
else
{
v6 = 8LL;
if ( *(_QWORD *)*a2 )
{
do
{
ft_putendl();
v7 = *(_QWORD *)(*a2 + v6);
v6 += 8LL;
}
while ( v7 );
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 *a2)
{
__int64 *v2; // r12
__int64 v3; // rax
_QWORD *v4; // rax
__int64 result; // rax
__int64 v6; // rbx
__int64 v7; // rdi

v2 = *(__int64 **)(a1 + 16);
if ( v2 )
{
v3 = v2[2];
if ( v3 && *(_QWORD *)(v3 + 16) )
{
result = ft_error_msg("setenv: Too many arguments.", &unk_355);
}
else if ( (unsigned int)ft_find(*v2, &unk_353)
|| (v4 = (_QWORD *)v2[2]) != 0LL && (unsigned int)ft_find(*v4, &unk_353) )
{
result = ft_error_msg("setenv: Avoid the character '='", &unk_355);
}
else
{
result = func2(v2, a2);
}
}
else
{
v6 = 8LL;
if ( *(_QWORD *)*a2 )
{
do
{
ft_putendl();
v7 = *(_QWORD *)(*a2 + v6);
v6 += 8LL;
}
while ( v7 );
}
result = 0LL;
}
return result;
}

original_code:
int ft_setenv(t_p *p, char ***env)
{
 t_p *move;
 int i;
 move = p->next;
 if (!move)
 {
  i = -1;
  while ((*env)[++i])
   ft_putendl((*env)[i]);
  return (0);
 }
 if (move->next && move->next->next)
  return (ft_error_msg("setenv: Too many arguments.", ""));
 if (ft_find(move->tok, "=")
  || (move->next && ft_find(move->next->tok, "=")))
  return (ft_error_msg("setenv: Avoid the character '='", ""));
 return (ft_replace_or_add(move, env));
}

canonical_original_code:
int ft_setenv(struct s_p *p, char ***env)
{
 struct s_p *move;
 int i;
 move = p->next;
 if (!move)
 {
  i = -1;
  while ((*env)[++i])
   ft_putendl((*env)[i]);
  return (0);
 }
 if (move->next && move->next->next)
  return (ft_error_msg("setenv: Too many arguments.", ""));
 if (ft_find(move->tok, "=")
  || (move->next && ft_find(move->next->tok, "=")))
  return (ft_error_msg("setenv: Avoid the character '='", ""));
 return (ft_replace_or_add(move, env));
}


original_code:
static int ft_s_w_m(char const *s, int i)
{
 int m;
 m = 0;
 while (*(s + i) && *(s + i) != ' ' && *(s + i) != 't')
 {
  ++i;
  ++m;
 }
 return (m);
}

variable_types:
s
char *

variable_types: i int

variable_types: m int

return_type: int


original_code:
char **ft_strsplim(char const *s)
{
 char **s3;
 int i;
 int k;
 if (!(s3 = (char **)gmalloc(sizeof(char *) * (ft_wc_w_m(s) + 1))))
  return (((void *)0));
 i = 0;
 k = 0;
 while (*(s + i))
 {
  while ((*(s + i) == ' ' || *(s + i) == '\t') && *(s + i))
   ++i;
  if (*(s + i))
  {
   if (!(s3[k] = (char *)gmalloc(sizeof(char) * (ft_s_w_m(s, i) + 1))))
    return (((void *)0));
   s3[k] = ft_fill_m(s3[k], &i, s);
   ++k;
  }
 }
 if (!(s3[k] = (char *)gmalloc(sizeof(char) * (1 + 1))))
  return (((void *)0));
 *(s3 + k) = '\0';
 return (s3);
}

variable_types: k int

return_type: char **


decompiled_code:
__int64 __fastcall ft_win_now(__int64 a1)
{
_DWORD *v1; // rax
_DWORD *v2; // rdx

v1 = *(_DWORD **)(a1 + 8);
v2 = v1 + 4;
while ( *v1 != 4 )
{
if ( ++v1 == v2 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
_DWORD *v1; // rax
_DWORD *v2; // rdx

v1 = *(_DWORD **)(a1 + 8);
v2 = v1 + 4;
while ( *v1 != 4 )
{
if ( ++v1 == v2 )
return 0LL;
}
return 1LL;
}

original_code:
static int ft_win_now(t_s *s)
{
 int k;
 k = 0;
 while (k < 4)
 {
  if ((*s).save[k] == 4)
   return (1);
  ++k;
 }
 return (0);
}

canonical_original_code:
static int ft_win_now(struct s_s *s)
{
 int k;
 k = 0;
 while (k < 4)
 {
  if ((*s).save[k] == 4)
   return (1);
  ++k;
 }
 return (0);
}

variable_types: struct s_s { int *choices; int *save; char symb1; char symb2; int keep; } *


decompiled_code:
__int64 __fastcall ft_compute_mixed_value(_DWORD *a1)
{
return (unsigned int)(26 * *a1 + 15 * a1[1] + 10 * (a1[2] + a1[3]));
}

original_code:
static int ft_compute_mixed_value(int *save)
{
 return (26 * save[0] + 15 * save[1] + 10 * (save[2] + save[3]));
}

variable_types:
save
int *


original_code:
static void ft_fill_save_board(t_all a, t_s *s)
{
 (*s).choices[a.i] = 0;
 ft_reset_save_board(&((*s).save));
 (*s).save[0] = ft_find_nb_for_row(a, *s);
 (*s).save[1] = ft_find_nb_for_column(a, *s);
 (*s).save[2] = ft_find_nb_for_diag_up_left(a, *s);
 (*s).save[3] = ft_find_nb_for_diag_up_right(a, *s);
}

canonical_original_code:
static void ft_fill_save_board(struct s_all a, struct s_s *s)
{
 (*s).choices[a.i] = 0;
 ft_reset_save_board(&((*s).save));
 (*s).save[0] = ft_find_nb_for_row(a, *s);
 (*s).save[1] = ft_find_nb_for_column(a, *s);
 (*s).save[2] = ft_find_nb_for_diag_up_left(a, *s);
 (*s).save[3] = ft_find_nb_for_diag_up_right(a, *s);
}

variable_types: struct s_all { char **grid; int li; int co; int i; int j; }

return_type: void

user_defined_types: struct s_s { int *choices; int *save; char symb1; char symb2; int keep; }


original_code:
int ft_update_grid_of_choices(t_all a, t_s *me, t_s *you)
{
 int i;
 int j;
 int max;
 max = 0;
 i = 0;
 while (a.grid[i])
 {
  j = 0;
  while (a.grid[i][j] && a.grid[i][j + 1] && a.grid[i][j + 1] == '.')
   ++j;
  a.i = i;
  a.j = j;
  ft_number_of_awesomeness(a, me, you);
  if ((*me).choices[i] > max)
  {
   max = (*me).choices[i];
   (*me).keep = i;
  }
  ++i;
 }
 return (0);
}

canonical_original_code:
int ft_update_grid_of_choices(struct s_all a, struct s_s *me, struct s_s *you)
{
 int i;
 int j;
 int max;
 max = 0;
 i = 0;
 while (a.grid[i])
 {
  j = 0;
  while (a.grid[i][j] && a.grid[i][j + 1] && a.grid[i][j + 1] == '.')
   ++j;
  a.i = i;
  a.j = j;
  ft_number_of_awesomeness(a, me, you);
  if ((*me).choices[i] > max)
  {
   max = (*me).choices[i];
   (*me).keep = i;
  }
  ++i;
 }
 return (0);
}

variable_types:
you
struct s_s *

variable_types: j int

variable_types: max int

user_defined_types: struct s_all { char **grid; int li; int co; int i; int j; }


decompiled_code:
__int64 __fastcall ft_return_last_rep(__int64 **a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rdi
char *v6; // r13

v3 = 0LL;
v4 = **a1;
if ( !v4 )
return ft_error_msg(": No such file or directory", &unk_4C6);
while ( (unsigned int)ft_strncmp(v4, "OLDPWD=", 7LL) )
{
v4 = (*a1)[++v3];
if ( !v4 )
return ft_error_msg(": No such file or directory", &unk_4C6);
}
v5 = (*a1)[v3];
if ( !v5 || chdir((const char *)(v5 + 7)) == -1 )
return ft_error_msg(": No such file or directory", &unk_4C6);
v6 = getcwd(0LL, 0LL);
ft_change_value_variable("PWD=", v6, a1);
ft_change_value_variable("PWD=", v6, a1 + 1);
ft_change_value_variable("OLDPWD=", a2, a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 **a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rdi
char *v6; // r13

v3 = 0LL;
v4 = **a1;
if ( !v4 )
return ft_error_msg(": No such file or directory", &unk_4C6);
while ( (unsigned int)ft_strncmp(v4, "OLDPWD=", 7LL) )
{
v4 = (*a1)[++v3];
if ( !v4 )
return ft_error_msg(": No such file or directory", &unk_4C6);
}
v5 = (*a1)[v3];
if ( !v5 || chdir((const char *)(v5 + 7)) == -1 )
return ft_error_msg(": No such file or directory", &unk_4C6);
v6 = getcwd(0LL, 0LL);
ft_change_value_variable("PWD=", v6, a1);
ft_change_value_variable("PWD=", v6, a1 + 1);
ft_change_value_variable("OLDPWD=", a2, a1);
return 0LL;
}

original_code:
int ft_return_last_rep(t_env *e, char *old_pwd)
{
 int i;
 char *pwd;
 pwd = ((void *)0);
 i = 0;
 while (e->env[i] && ft_strncmp(e->env[i], "OLDPWD=", 7))
  ++i;
 if (!(e->env[i]) || (chdir(&(e->env[i][7])) == -1))
  return (ft_error_msg(": No such file or directory", ""));
 pwd = getcwd(pwd, 0);
 ft_change_value_variable("PWD=", pwd, &(e->env));
 ft_change_value_variable("PWD=", pwd, &(e->env_s));
 ft_change_value_variable("OLDPWD=", old_pwd, &(e->env));
 return (0);
}

canonical_original_code:
int ft_return_last_rep(struct s_env *e, char *old_pwd)
{
 int i;
 char *pwd;
 pwd = ((void *)0);
 i = 0;
 while (e->env[i] && ft_strncmp(e->env[i], "OLDPWD=", 7))
  ++i;
 if (!(e->env[i]) || (chdir(&(e->env[i][7])) == -1))
  return (ft_error_msg(": No such file or directory", ""));
 pwd = getcwd(pwd, 0);
 ft_change_value_variable("PWD=", pwd, &(e->env));
 ft_change_value_variable("PWD=", pwd, &(e->env_s));
 ft_change_value_variable("OLDPWD=", old_pwd, &(e->env));
 return (0);
}

variable_types: struct s_env { char **env; char **env_s; char **envc; } *

variable_types:
pwd
char *


decompiled_code:
__int64 __fastcall ft_return_home(__int64 **a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rdi
int v6; // eax
const char *v7; // rdi
char *v8; // r13

v3 = 0LL;
v4 = **a1;
if ( !v4 )
goto LABEL_8;
while ( (unsigned int)ft_strncmp(v4, "HOME=", 5LL) )
{
v4 = (*a1)[++v3];
if ( !v4 )
goto LABEL_8;
}
v5 = (*a1)[v3];
if ( v5 )
{
v6 = chdir((const char *)(v5 + 5));
v7 = "cd: Can't change to home directory";
if ( v6 != -1 )
{
v8 = getcwd(0LL, 0LL);
ft_change_value_variable("PWD=", v8, a1);
ft_change_value_variable("PWD=", v8, a1 + 1);
ft_change_value_variable("OLDPWD=", a2, a1);
return 0LL;
}
}
else
{
LABEL_8:
v7 = "cd: No home directory";
}
return ft_error_msg(v7, &unk_4C6);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 **a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rdi
int v6; // eax
const char *v7; // rdi
char *v8; // r13

v3 = 0LL;
v4 = **a1;
if ( !v4 )
goto LABEL_8;
while ( (unsigned int)ft_strncmp(v4, "HOME=", 5LL) )
{
v4 = (*a1)[++v3];
if ( !v4 )
goto LABEL_8;
}
v5 = (*a1)[v3];
if ( v5 )
{
v6 = chdir((const char *)(v5 + 5));
v7 = "cd: Can't change to home directory";
if ( v6 != -1 )
{
v8 = getcwd(0LL, 0LL);
ft_change_value_variable("PWD=", v8, a1);
ft_change_value_variable("PWD=", v8, a1 + 1);
ft_change_value_variable("OLDPWD=", a2, a1);
return 0LL;
}
}
else
{
LABEL_8:
v7 = "cd: No home directory";
}
return ft_error_msg(v7, &unk_4C6);
}

original_code:
int ft_return_home(t_env *e, char *old_pwd)
{
 char *pwd;
 int i;
 pwd = ((void *)0);
 i = 0;
 while (e->env[i] && ft_strncmp(e->env[i], "HOME=", 5))
  ++i;
 if (!(e->env[i]))
  return (ft_error_msg("cd: No home directory", ""));
 if (chdir(&(e->env[i][5])) == -1)
  return (ft_error_msg("cd: Can't change to home directory", ""));
 pwd = getcwd(pwd, 0);
 ft_change_value_variable("PWD=", pwd, &(e->env));
 ft_change_value_variable("PWD=", pwd, &(e->env_s));
 ft_change_value_variable("OLDPWD=", old_pwd, &(e->env));
 return (0);
}

canonical_original_code:
int ft_return_home(struct s_env *e, char *old_pwd)
{
 char *pwd;
 int i;
 pwd = ((void *)0);
 i = 0;
 while (e->env[i] && ft_strncmp(e->env[i], "HOME=", 5))
  ++i;
 if (!(e->env[i]))
  return (ft_error_msg("cd: No home directory", ""));
 if (chdir(&(e->env[i][5])) == -1)
  return (ft_error_msg("cd: Can't change to home directory", ""));
 pwd = getcwd(pwd, 0);
 ft_change_value_variable("PWD=", pwd, &(e->env));
 ft_change_value_variable("PWD=", pwd, &(e->env_s));
 ft_change_value_variable("OLDPWD=", old_pwd, &(e->env));
 return (0);
}

user_defined_types: struct s_env { char **env; char **env_s; char **envc; }


decompiled_code:
__int64 __fastcall ft_change_pwd(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v4; // rax
__int64 v5; // rbp

v2 = (int)(ft_strlen(a2) - 1);
if ( (int)v2 < 0 )
return a2;
while ( *(_BYTE *)(a2 + v2) != 47 )
{
if ( (_DWORD)--v2 == -1 )
return a2;
}
if ( (int)v2 <= 0 )
return a2;
v4 = ft_strsub(a2, 0LL, (int)v2 + 1);
v5 = ft_strjoin(v4, a1);
gfree(a2);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v4; // rax
__int64 v5; // rbp

v2 = (int)(ft_strlen(a2) - 1);
if ( (int)v2 < 0 )
return a2;
while ( *(_BYTE *)(a2 + v2) != 47 )
{
if ( (_DWORD)--v2 == -1 )
return a2;
}
if ( (int)v2 <= 0 )
return a2;
v4 = ft_strsub(a2, 0LL, (int)v2 + 1);
v5 = ft_strjoin(v4, a1);
gfree(a2);
return v5;
}

original_code:
char *ft_change_pwd(char *rep, char *old_pwd)
{
 int len;
 char *new_pwd;
 new_pwd = ((void *)0);
 len = ft_strlen(old_pwd) - 1;
 if (len < 0)
  return (old_pwd);
 while (len >= 0 && old_pwd[len] != '/')
  --len;
 if (len <= 0)
  return (old_pwd);
 new_pwd = ft_strjoin(ft_strsub(old_pwd, 0, len + 1), rep);
 gfree(old_pwd);
 return (new_pwd);
}

variable_types:
rep
char *

variable_types: len int

return_type: char *


decompiled_code:
__int64 __fastcall ft_go_to_rep(char *file, __int64 a2, __int64 a3, int a4)
{
__int64 v6; // rax
struct stat *v7; // r15
int v8; // ebx
int v9; // eax
const char *v10; // rsi
char *v12; // rax
__int64 v13; // r15

v6 = gmalloc(144LL);
if ( !v6 )
return 0xFFFFFFFFLL;
v7 = (struct stat *)v6;
v8 = chdir(file);
v9 = lstat(file, v7);
if ( v8 == -1 && !v9 )
{
v10 = ": Permission denied";
if ( (v7->st_mode & 0xE000) == 0 )
v10 = ": Not a directory";
return ft_error_msg(file, v10);
}
if ( (v9 & v8) == -1 )
{
v10 = ": No such file or directory";
return ft_error_msg(file, v10);
}
v12 = getcwd(0LL, 0LL);
v13 = (__int64)v12;
if ( *file != 46 && !a4 )
v13 = ft_change_pwd((__int64)file, (__int64)v12);
ft_change_value_variable("PWD=", v13, a2);
ft_change_value_variable("PWD=", v13, a2 + 8);
ft_change_value_variable("OLDPWD=", a3, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *file, __int64 a2, __int64 a3, int a4)
{
__int64 v6; // rax
struct stat *v7; // r15
int v8; // ebx
int v9; // eax
const char *v10; // rsi
char *v12; // rax
__int64 v13; // r15

v6 = gmalloc(144LL);
if ( !v6 )
return 0xFFFFFFFFLL;
v7 = (struct stat *)v6;
v8 = chdir(file);
v9 = lstat(file, v7);
if ( v8 == -1 && !v9 )
{
v10 = ": Permission denied";
if ( (v7->st_mode & 0xE000) == 0 )
v10 = ": Not a directory";
return ft_error_msg(file, v10);
}
if ( (v9 & v8) == -1 )
{
v10 = ": No such file or directory";
return ft_error_msg(file, v10);
}
v12 = getcwd(0LL, 0LL);
v13 = (__int64)v12;
if ( *file != 46 && !a4 )
v13 = func2((__int64)file, (__int64)v12);
ft_change_value_variable("PWD=", v13, a2);
ft_change_value_variable("PWD=", v13, a2 + 8);
ft_change_value_variable("OLDPWD=", a3, a2);
return 0LL;
}

original_code:
int ft_go_to_rep(char *rep, t_env *e, char *old_pwd, int flag)
{
 char *pwd;
 struct stat *buf;
 int value1;
 int value2;
 pwd = ((void *)0);
 if (!(buf = (struct stat *)gmalloc(sizeof(*buf))))
  return (-1);
 value1 = chdir(rep);
 value2 = lstat(rep, buf);
 if (value1 == -1 && value2 == 0
  && (buf->st_mode & 0040000 || buf->st_mode & 0120000))
  return (ft_error_msg(rep, ": Permission denied"));
 else if (value1 == -1 && value2 == 0)
  return (ft_error_msg(rep, ": Not a directory"));
 else if (value1 == -1 && value2 == -1)
  return (ft_error_msg(rep, ": No such file or directory"));
 pwd = getcwd(pwd, 0);
 if (rep[0] != '.' && flag == 0)
  pwd = ft_change_pwd(rep, pwd);
 ft_change_value_variable("PWD=", pwd, &(e->env));
 ft_change_value_variable("PWD=", pwd, &(e->env_s));
 ft_change_value_variable("OLDPWD=", old_pwd, &(e->env));
 return (0);
}

canonical_original_code:
int ft_go_to_rep(char *rep, struct s_env *e, char *old_pwd, int flag)
{
 char *pwd;
 struct stat *buf;
 int value1;
 int value2;
 pwd = ((void *)0);
 if (!(buf = (struct stat *)gmalloc(sizeof(*buf))))
  return (-1);
 value1 = chdir(rep);
 value2 = lstat(rep, buf);
 if (value1 == -1 && value2 == 0
  && (buf->st_mode & 0040000 || buf->st_mode & 0120000))
  return (ft_error_msg(rep, ": Permission denied"));
 else if (value1 == -1 && value2 == 0)
  return (ft_error_msg(rep, ": Not a directory"));
 else if (value1 == -1 && value2 == -1)
  return (ft_error_msg(rep, ": No such file or directory"));
 pwd = getcwd(pwd, 0);
 if (rep[0] != '.' && flag == 0)
  pwd = ft_change_pwd(rep, pwd);
 ft_change_value_variable("PWD=", pwd, &(e->env));
 ft_change_value_variable("PWD=", pwd, &(e->env_s));
 ft_change_value_variable("OLDPWD=", old_pwd, &(e->env));
 return (0);
}

variable_types: flag int

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

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


original_code:
int ft_cd(t_p *p, t_env *e)
{
 int value;
 char *buf;
 value = 0;
 buf = ((void *)0);
 buf = getcwd(buf, 0);
 if (!p->next
  || (p->next && !ft_strcmp(p->next->tok, "-P") && !p->next->next))
  value = ft_return_home(e, buf);
 else if ((p->next->next && p->next->tok[0] != '-')
   || (p->next->next && p->next->next->next))
  value = ft_error_msg("cd: Too many arguments", "");
 else if (!ft_strcmp(p->next->tok, "-"))
  value = ft_return_last_rep(e, buf);
 else if (!ft_strcmp(p->next->tok, "-P"))
  value = ft_go_to_rep(p->next->next->tok, e, buf, 1);
 else if (!ft_strcmp(p->next->tok, "-L"))
  value = ft_go_to_rep(p->next->next->tok, e, buf, 0);
 else if (p->next->tok[0] == '-')
  value = ft_error_msg("Usage: cd [-L|-P][dir]", "");
 else
  value = ft_go_to_rep(p->next->tok, e, buf, 0);
 free(buf);
 return (value);
}

canonical_original_code:
int ft_cd(struct s_p *p, struct s_env *e)
{
 int value;
 char *buf;
 value = 0;
 buf = ((void *)0);
 buf = getcwd(buf, 0);
 if (!p->next
  || (p->next && !ft_strcmp(p->next->tok, "-P") && !p->next->next))
  value = ft_return_home(e, buf);
 else if ((p->next->next && p->next->tok[0] != '-')
   || (p->next->next && p->next->next->next))
  value = ft_error_msg("cd: Too many arguments", "");
 else if (!ft_strcmp(p->next->tok, "-"))
  value = ft_return_last_rep(e, buf);
 else if (!ft_strcmp(p->next->tok, "-P"))
  value = ft_go_to_rep(p->next->next->tok, e, buf, 1);
 else if (!ft_strcmp(p->next->tok, "-L"))
  value = ft_go_to_rep(p->next->next->tok, e, buf, 0);
 else if (p->next->tok[0] == '-')
  value = ft_error_msg("Usage: cd [-L|-P][dir]", "");
 else
  value = ft_go_to_rep(p->next->tok, e, buf, 0);
 free(buf);
 return (value);
}

variable_types: struct s_p { char *tok; int type; struct s_p *next; struct s_p *prev; } *

variable_types: value int

variable_types:
buf
char *


decompiled_code:
__int64 __fastcall ft_save_new_map(void *a1, int *a2)
{
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rdi
int v6; // eax
__int64 v7; // rdi
__int64 v8; // r12
void *v9; // rax
__int64 v10; // rbx
_QWORD *v11; // r12
void *ptr[4]; // [rsp+8h] [rbp-20h] BYREF

ptr[0] = a1;
v2 = ft_strsplit(a1, 32LL);
v3 = ft_strlen(*(_QWORD *)(v2 + 16));
v4 = ft_strsub(*(_QWORD *)(v2 + 16), 0LL, v3 - 1);
v5 = *(_QWORD *)(v2 + 8);
*(_QWORD *)(v2 + 16) = v4;
v6 = ft_atoi(v5);
v7 = *(_QWORD *)(v2 + 16);
*a2 = v6;
a2[1] = ft_atoi(v7);
ft_free_chtab(v2);
free(ptr[0]);
get_next_line(0LL, ptr);
free(ptr[0]);
v8 = *a2;
v9 = malloc(8 * v8);
*((_QWORD *)a2 + 1) = v9;
if ( !v9 )
return 0xFFFFFFFFLL;
v10 = 0LL;
if ( (int)v8 > 0 )
{
do
{
if ( !(unsigned int)get_next_line(0LL, ptr) )
break;
v11 = (_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v10++);
*v11 = ft_strdup((char *)ptr[0] + 4);
free(ptr[0]);
}
while ( *a2 > (int)v10 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *a1, int *a2)
{
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rdi
int v6; // eax
__int64 v7; // rdi
__int64 v8; // r12
void *v9; // rax
__int64 v10; // rbx
_QWORD *v11; // r12
void *ptr[4]; // [rsp+8h] [rbp-20h] BYREF

ptr[0] = a1;
v2 = ft_strsplit(a1, 32LL);
v3 = ft_strlen(*(_QWORD *)(v2 + 16));
v4 = ft_strsub(*(_QWORD *)(v2 + 16), 0LL, v3 - 1);
v5 = *(_QWORD *)(v2 + 8);
*(_QWORD *)(v2 + 16) = v4;
v6 = ft_atoi(v5);
v7 = *(_QWORD *)(v2 + 16);
*a2 = v6;
a2[1] = ft_atoi(v7);
ft_free_chtab(v2);
free(ptr[0]);
get_next_line(0LL, ptr);
free(ptr[0]);
v8 = *a2;
v9 = malloc(8 * v8);
*((_QWORD *)a2 + 1) = v9;
if ( !v9 )
return 0xFFFFFFFFLL;
v10 = 0LL;
if ( (int)v8 > 0 )
{
do
{
if ( !(unsigned int)get_next_line(0LL, ptr) )
break;
v11 = (_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v10++);
*v11 = ft_strdup((char *)ptr[0] + 4);
free(ptr[0]);
}
while ( *a2 > (int)v10 );
}
return 0LL;
}

original_code:
int ft_save_new_map(char *line, t_m *m)
{
 int i;
 char **map_info;
 map_info = ft_strsplit(line, ' ');
 map_info[2] = ft_strsub(map_info[2], 0, ft_strlen(map_info[2]) - 1);
 m->li = ft_atoi(map_info[1]);
 m->co = ft_atoi(map_info[2]);
 ft_free_chtab(map_info);
 free((void *)line);
 get_next_line(0, &line);
 free((void *)line);
 if (!(m->all = (char **)malloc(sizeof(char *) * (m->li))))
  return (-1);
 i = 0;
 while (i < m->li && get_next_line(0, &line))
 {
  m->all[i] = ft_strdup(line + 4);
  free((void *)line);
  ++i;
 }
 return (0);
}

canonical_original_code:
int ft_save_new_map(char *line, struct s_m *m)
{
 int i;
 char **map_info;
 map_info = ft_strsplit(line, ' ');
 map_info[2] = ft_strsub(map_info[2], 0, ft_strlen(map_info[2]) - 1);
 m->li = ft_atoi(map_info[1]);
 m->co = ft_atoi(map_info[2]);
 ft_free_chtab(map_info);
 free((void *)line);
 get_next_line(0, &line);
 free((void *)line);
 if (!(m->all = (char **)malloc(sizeof(char *) * (m->li))))
  return (-1);
 i = 0;
 while (i < m->li && get_next_line(0, &line))
 {
  m->all[i] = ft_strdup(line + 4);
  free((void *)line);
  ++i;
 }
 return (0);
}

variable_types:
line
char *

variable_types: struct s_m { int li; int co; char **all; int gli; int gco; int x; int y; } *

variable_types: i int


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

result = 0LL;
a1[12] = LC0;
a1[13] = LC0;
a1[14] = LC0;
*a2 = -1LL;
return result;
}

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

result = 0LL;
a1[12] = LC0;
a1[13] = LC0;
a1[14] = LC0;
*a2 = -1LL;
return result;
}

variable_types: struct s_r { struct s_v { double x; double y; double z; } o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c { int b; int g; int r; } color; int hit_i; int hit_j; } *

variable_types:
save
struct s_save { int i; int j; } *

user_defined_types: struct s_r { struct s_v o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c color; int hit_i; int hit_j; }


original_code:
t_c ft_trace(t_obj obj, t_r *r, t_save *save)
{
 int i;
 int j;
 t_c color;
 ft_init_save_and_ray(r, save);
 i = -1;
 while (++i < 6)
 {
  j = -1;
  while (++j < obj.nb[i])
  {
   if (obj.intersect[i](r, (obj.type)[i][j]) == 0 && r->t0 < r->tnear)
   {
    r->tnear = r->t0;
    save->i = i;
    save->j = j;
   }
  }
 }
 if (save->i == -1)
  return (obj.bg_clr);
 r->hit_i = save->i;
 r->hit_j = save->j;
 obj.treatment[save->i]((obj.type)[save->i][save->j], &color, &obj, r);
 return (color);
}

canonical_original_code:
struct s_c ft_trace(struct s_obj obj, struct s_r *r, struct s_save *save)
{
 int i;
 int j;
 struct s_c color;
 ft_init_save_and_ray(r, save);
 i = -1;
 while (++i < 6)
 {
  j = -1;
  while (++j < obj.nb[i])
  {
   if (obj.intersect[i](r, (obj.type)[i][j]) == 0 && r->t0 < r->tnear)
   {
    r->tnear = r->t0;
    save->i = i;
    save->j = j;
   }
  }
 }
 if (save->i == -1)
  return (obj.bg_clr);
 r->hit_i = save->i;
 r->hit_j = save->j;
 obj.treatment[save->i]((obj.type)[save->i][save->j], &color, &obj, r);
 return (color);
}

variable_types: struct s_obj { int depth; struct s_c **pixel; void ***type; int *nb; int (*intersect[6])(struct s_r { struct s_v { double x; double y; double z; } o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c color; int hit_i; int hit_j; } *, void *); int (*treatment[6])(void *, struct s_c *, struct s_obj *, struct s_r *r); struct s_c bg_clr; }

variable_types:
r
struct s_r *

variable_types:
color
struct s_c { int b; int g; int r; }

return_type: struct s_c { int b; int g; int r; }

user_defined_types: struct s_obj { int depth; struct s_c **pixel; void ***type; int *nb; int (*intersect[6])(struct s_r *, void *); int (*treatment[6])(void *, struct s_c *, struct s_obj *, struct s_r *r); struct s_c bg_clr; }


decompiled_code:
__int64 ft_init_ray()
{
ft_init_vect(0.0, 0.0);
ft_init_vect(0.0, 0.0);
ft_init_vect(0.0, 0.0);
return ft_init_vect(0.0, 0.0);
}

original_code:
void ft_init_ray(t_r *r)
{
 ft_init_vect(&r->o_w, 0, 0, 0);
 ft_init_vect(&r->d_w, 0, 0, 0);
 ft_init_vect(&r->p_hit, 0, 0, 0);
 ft_init_vect(&r->n_hit, 0, 0, 0);
}

canonical_original_code:
void ft_init_ray(struct s_r *r)
{
 ft_init_vect(&r->o_w, 0, 0, 0);
 ft_init_vect(&r->d_w, 0, 0, 0);
 ft_init_vect(&r->p_hit, 0, 0, 0);
 ft_init_vect(&r->n_hit, 0, 0, 0);
}

user_defined_types: struct s_v { double x; double y; double z; }


raytracer

original_code:
int raytracer(t_obj *obj, t_cam cam)
{
 int i;
 int j;
 t_r r;
 double **c2w;
 t_save save;
 if (!(c2w = ft_init_matrix(&cam.b.vx, &cam.b.vy, &cam.b.vz)))
  return (-1);
 ft_init_ray(&r);
 r.o_w = cam.ro;
 j = -1;
 while (++j < (1200.0))
 {
  i = -1;
  while (++i < (2400.0))
  {
   obj->depth = 0;
   ft_find_pixel_pos_on_screen(&cam.rp, i, j);
   ft_mult_vect_by_matrix(&r.d_w, c2w, cam.rp);
   ft_vect_difference(&r.d_w, r.d_w, r.o_w);
   ft_normalize_vect(&r.d_w);
   obj->pixel[j][i] = ft_trace(*obj, &r, &save);
  }
 }
 return (0);
}

canonical_original_code:
int raytracer(struct s_obj *obj, struct s_cam cam)
{
 int i;
 int j;
 struct s_r r;
 double **c2w;
 struct s_save save;
 if (!(c2w = ft_init_matrix(&cam.b.vx, &cam.b.vy, &cam.b.vz)))
  return (-1);
 ft_init_ray(&r);
 r.o_w = cam.ro;
 j = -1;
 while (++j < (1200.0))
 {
  i = -1;
  while (++i < (2400.0))
  {
   obj->depth = 0;
   ft_find_pixel_pos_on_screen(&cam.rp, i, j);
   ft_mult_vect_by_matrix(&r.d_w, c2w, cam.rp);
   ft_vect_difference(&r.d_w, r.d_w, r.o_w);
   ft_normalize_vect(&r.d_w);
   obj->pixel[j][i] = ft_trace(*obj, &r, &save);
  }
 }
 return (0);
}

variable_types: struct s_obj { int depth; struct s_c { int b; int g; int r; } **pixel; void ***type; int *nb; int (*intersect[6])(struct s_r { struct s_v { double x; double y; double z; } o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c color; int hit_i; int hit_j; } *, void *); int (*treatment[6])(void *, struct s_c *, struct s_obj *, struct s_r *r); struct s_c bg_clr; } *

variable_types: struct s_cam { struct s_b { struct s_v vx; struct s_v vy; struct s_v vz; } b; struct s_v trans; struct s_v ro; struct s_v rp; }

variable_types: j int

variable_types: struct s_r { struct s_v { double x; double y; double z; } o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c { int b; int g; int r; } color; int hit_i; int hit_j; }

variable_types:
save
struct s_save { int i; int j; }

user_defined_types: struct s_cam { struct s_b b; struct s_v trans; struct s_v ro; struct s_v rp; }


decompiled_code:
__int64 __fastcall ft_is_no_quote(char *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1;
if ( *a1 == 124 )
return (unsigned int)(a1[1] != 124) + 6;
if ( v1 == 38 )
{
result = 11LL;
if ( a1[1] == 38 )
result = 5LL;
}
else if ( v1 == 62 )
{
result = (unsigned int)(a1[1] == 62) + 8;
}
else
{
result = 4LL;
if ( v1 != 59 )
{
result = 10LL;
if ( v1 != 60 )
{
result = 14LL;
if ( v1 != 32 )
{
result = 15LL;
if ( v1 != 40 )
result = 5 * (unsigned int)(v1 == 41) + 11;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1;
if ( *a1 == 124 )
return (unsigned int)(a1[1] != 124) + 6;
if ( v1 == 38 )
{
result = 11LL;
if ( a1[1] == 38 )
result = 5LL;
}
else if ( v1 == 62 )
{
result = (unsigned int)(a1[1] == 62) + 8;
}
else
{
result = 4LL;
if ( v1 != 59 )
{
result = 10LL;
if ( v1 != 60 )
{
result = 14LL;
if ( v1 != 32 )
{
result = 15LL;
if ( v1 != 40 )
result = 5 * (unsigned int)(v1 == 41) + 11;
}
}
}
}
return result;
}


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

if ( *a2 == 1 )
{
result = 11LL;
if ( *a1 == 39 )
{
*a2 = 0;
result = 2LL;
}
}
else if ( *a2 == 2 )
{
result = 11LL;
if ( *a1 == 34 )
{
*a2 = 0;
result = 3LL;
}
}
else if ( *a1 == 39 )
{
*a2 = 1;
result = 2LL;
}
else
{
result = 0LL;
if ( *a1 == 34 )
{
*a2 = 2;
result = 3LL;
}
}
return result;
}

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

if ( *a2 == 1 )
{
result = 11LL;
if ( *a1 == 39 )
{
*a2 = 0;
result = 2LL;
}
}
else if ( *a2 == 2 )
{
result = 11LL;
if ( *a1 == 34 )
{
*a2 = 0;
result = 3LL;
}
}
else if ( *a1 == 39 )
{
*a2 = 1;
result = 2LL;
}
else
{
result = 0LL;
if ( *a1 == 34 )
{
*a2 = 2;
result = 3LL;
}
}
return result;
}

original_code:
static int ft_is_quote(char *line, int *ind)
{
 if (*ind == 1 && *line == '\'')
 {
  *ind = 0;
  return (2);
 }
 if (*ind == 2 && *line == '\"')
 {
  *ind = 0;
  return (3);
 }
 if (*ind == 1 || *ind == 2)
  return (11);
 if (*line == '\'')
 {
  *ind = 1;
  return (2);
 }
 if (*line == '\"')
 {
  *ind = 2;
  return (3);
 }
 return (0);
}

variable_types:
ind
int *


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

if ( *a3 == 1 )
{
*a3 = 0;
result = 11LL;
}
else
{
if ( *a1 == 92 )
*a3 = 1;
result = ft_is_quote(a1, a2);
if ( !(_DWORD)result )
result = ft_is_no_quote(a1);
}
return result;
}

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

if ( *a3 == 1 )
{
*a3 = 0;
result = 11LL;
}
else
{
if ( *a1 == 92 )
*a3 = 1;
result = func1(a1, a2);
if ( !(_DWORD)result )
result = func0(a1);
}
return result;
}

original_code:
static int ft_is_operand(char *line, int *ind, int *type_bs)
{
 int type;
 if (*type_bs == 1)
 {
  *type_bs = 0;
  return (11);
 }
 if (*line == '\\')
  *type_bs = 1;
 if ((type = ft_is_quote(line, ind)))
  return (type);
 type = ft_is_no_quote(line);
 return (type);
}

variable_types: type int


decompiled_code:
__int64 __fastcall ft_word_size_before_ope(char *a1, _DWORD *a2)
{
unsigned int v2; // er8
bool v3; // zf
int v4; // eax
_DWORD *v5; // rcx
int v7; // [rsp+Ch] [rbp-4h] BYREF

v2 = 0;
v3 = *a1 == 0;
v7 = 0;
if ( !v3 )
{
do
{
v4 = ft_is_operand(a1, a2, &v7);
*v5 = v4;
if ( v4 != 11 )
break;
++a1;
++v2;
}
while ( *a1 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, _DWORD *a2)
{
unsigned int v2; // er8
bool v3; // zf
int v4; // eax
_DWORD *v5; // rcx
int v7; // [rsp+Ch] [rbp-4h] BYREF

v2 = 0;
v3 = *a1 == 0;
v7 = 0;
if ( !v3 )
{
do
{
v4 = func2(a1, a2, &v7);
*v5 = v4;
if ( v4 != 11 )
break;
++a1;
++v2;
}
while ( *a1 );
}
return v2;
}

original_code:
int ft_word_size_before_ope(char *line, int *ind, int *type)
{
 int i;
 int type_bs;
 type_bs = 0;
 i = 0;
 while (*(line + i)
   && (*type = ft_is_operand(line + i, ind, &type_bs)) == 11)
  ++i;
 return (i);
}

variable_types:
type
int *


decompiled_code:
__int64 __fastcall c_calld(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // r13

if ( !(unsigned int)ft_strcmp(a1, "join") )
v3 = ft_strjoin(a2, a3);
gfree(a2);
gfree(a3);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // r13

if ( !(unsigned int)ft_strcmp(a1, "join") )
v3 = ft_strjoin(a2, a3);
gfree(a2);
gfree(a3);
return v3;
}

original_code:
void *c_calld(char *str, char *s1, char *s2)
{
 void *s3;
 if (!(ft_strcmp(str, "join")))
  s3 = ft_strjoin(s1, s2);
 gfree(s1);
 gfree(s2);
 return (s3);
}

variable_types:
str
char *

return_type: void *


decompiled_code:
// attributes: thunk
__int64 ft_run_big_part()
{
return ft_run_small_part();
}

canonical_decompiled_code:
__int64 func0()
{
return ft_run_small_part();
}

original_code:
char **ft_run_big_part(char *line, char **env)
{
 int a;
 a = 0;
 if (a != 0)
 {
  if (!ft_check_pipe(line))
  {
   if (!(env = ft_run_the_pipe(line, env)))
    return (((void *)0));
  }
  else
  {
   if (!(env = ft_run_middle_part_1(line, env)))
    return (((void *)0));
  }
 }
 if (!(env = ft_run_small_part(line, env)))
  return (((void *)0));
 return (env);
}

variable_types:
line
char *

variable_types:
env
char **

variable_types: a int


original_code:
static int ft_check_key(char *b, t_sl **l, t_save *s, t_hl **hl)
{
 int do_it;
 struct winsize w;
 int old_line;
 do_it = 1;
 ioctl(0, 0x5413, &w);
 if ((s->co = w.ws_col) == 0)
 {
  s->cursor_l = -1;
  return (ft_error_msg("Put valid entry", ""));
 }
 old_line = (4 + s->cursor_l) / s->co;
 if (ft_is_key_enter(b))
 {
  s->cursor_l = -1;
  return (0);
 }
 if (((do_it = ft_put_or_del_char(b, l, s, hl)) == -1)
  || (do_it && (do_it = ft_short_mv(b, l, &(s->cursor_l), s->co)) == -1)
  || (do_it && (do_it = ft_fast_move(b, l, &(s->cursor_l))) == -1)
  || (do_it && (do_it = ft_historic(b, l, s, hl)) == -1)
  || (do_it && (do_it = ft_cut_copy_or_paste(b, l, s)) == -1))
  return (-1);
 ft_print(*l, s, old_line);
 return (0);
}

canonical_original_code:
static int ft_check_key(char *b, struct s_sl **l, struct s_save *s, struct s_hl **hl)
{
 int do_it;
 struct winsize w;
 int old_line;
 do_it = 1;
 ioctl(0, 0x5413, &w);
 if ((s->co = w.ws_col) == 0)
 {
  s->cursor_l = -1;
  return (ft_error_msg("Put valid entry", ""));
 }
 old_line = (4 + s->cursor_l) / s->co;
 if (ft_is_key_enter(b))
 {
  s->cursor_l = -1;
  return (0);
 }
 if (((do_it = ft_put_or_del_char(b, l, s, hl)) == -1)
  || (do_it && (do_it = ft_short_mv(b, l, &(s->cursor_l), s->co)) == -1)
  || (do_it && (do_it = ft_fast_move(b, l, &(s->cursor_l))) == -1)
  || (do_it && (do_it = ft_historic(b, l, s, hl)) == -1)
  || (do_it && (do_it = ft_cut_copy_or_paste(b, l, s)) == -1))
  return (-1);
 ft_print(*l, s, old_line);
 return (0);
}

variable_types:
b
char *

variable_types: struct s_sl { char c; struct s_sl *next; struct s_sl *prev; } **

variable_types: struct s_save { int cursor_l; int cursor_hl; int co; struct s_sl *copy; } *

variable_types: struct s_hl { struct s_sl *hist; struct s_hl *next; struct s_hl *prev; } **

variable_types: struct winsize { unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; unsigned short ws_ypixel; }


decompiled_code:
__int64 __fastcall ft_put_or_del_char(char *a1, _QWORD *a2, int *a3, __int64 *a4)
{
__int64 v6; // rdi
int v8; // er14
__int64 result; // rax
__int64 v10; // rax
__int64 v11; // rax

v6 = (unsigned int)*a1;
v8 = *a3;
if ( (unsigned __int8)(v6 - 32) > 0x5Eu || a1[1] )
{
if ( v8 <= 0 )
goto LABEL_6;
if ( !(unsigned int)ft_is_key_del_left(a1) )
{
v8 = *a3;
LABEL_6:
if ( (int)ft_slist_len(*a2) <= v8 || !(unsigned int)ft_is_key_del_right(a1) )
return 1LL;
ft_list_del_elem(a2);
if ( !a3[1] )
return 0LL;
goto LABEL_15;
}
--*a3;
ft_list_del_elem(a2);
}
else
{
result = ft_list_put_elem(v6, a2, (unsigned int)v8);
if ( (_DWORD)result == -1 )
return result;
++*a3;
}
if ( !a3[1] )
return 0LL;
LABEL_15:
v10 = *a4;
a3[1] = 0;
v11 = *(_QWORD *)(v10 + 16);
if ( !v11 )
return 0LL;
do
{
*a4 = v11;
v11 = *(_QWORD *)(v11 + 16);
}
while ( v11 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, _QWORD *a2, int *a3, __int64 *a4)
{
__int64 v6; // rdi
int v8; // er14
__int64 result; // rax
__int64 v10; // rax
__int64 v11; // rax

v6 = (unsigned int)*a1;
v8 = *a3;
if ( (unsigned __int8)(v6 - 32) > 0x5Eu || a1[1] )
{
if ( v8 <= 0 )
goto LABEL_6;
if ( !(unsigned int)ft_is_key_del_left(a1) )
{
v8 = *a3;
LABEL_6:
if ( (int)ft_slist_len(*a2) <= v8 || !(unsigned int)ft_is_key_del_right(a1) )
return 1LL;
ft_list_del_elem(a2);
if ( !a3[1] )
return 0LL;
goto LABEL_15;
}
--*a3;
ft_list_del_elem(a2);
}
else
{
result = ft_list_put_elem(v6, a2, (unsigned int)v8);
if ( (_DWORD)result == -1 )
return result;
++*a3;
}
if ( !a3[1] )
return 0LL;
LABEL_15:
v10 = *a4;
a3[1] = 0;
v11 = *(_QWORD *)(v10 + 16);
if ( !v11 )
return 0LL;
do
{
*a4 = v11;
v11 = *(_QWORD *)(v11 + 16);
}
while ( v11 );
return 0LL;
}

original_code:
static int ft_put_or_del_char(char *buf, t_sl **l, t_save *s, t_hl **hl)
{
 if (buf[0] >= ' ' && buf[0] <= '~' && buf[1] == 0)
 {
  if (ft_list_put_elem(buf[0], l, s->cursor_l) == -1)
   return (-1);
  ++(s->cursor_l);
 }
 else if (s->cursor_l > 0 && ft_is_key_del_left(buf))
 {
  --(s->cursor_l);
  ft_list_del_elem(l, s->cursor_l);
 }
 else if (s->cursor_l < ft_slist_len(*l) && ft_is_key_del_right(buf))
  ft_list_del_elem(l, s->cursor_l);
 else
  return (1);
 if (s->cursor_hl)
 {
  s->cursor_hl = 0;
  while ((*hl)->prev)
   *hl = (*hl)->prev;
 }
 return (0);
}

canonical_original_code:
static int ft_put_or_del_char(char *buf, struct s_sl **l, struct s_save *s, struct s_hl **hl)
{
 if (buf[0] >= ' ' && buf[0] <= '~' && buf[1] == 0)
 {
  if (ft_list_put_elem(buf[0], l, s->cursor_l) == -1)
   return (-1);
  ++(s->cursor_l);
 }
 else if (s->cursor_l > 0 && ft_is_key_del_left(buf))
 {
  --(s->cursor_l);
  ft_list_del_elem(l, s->cursor_l);
 }
 else if (s->cursor_l < ft_slist_len(*l) && ft_is_key_del_right(buf))
  ft_list_del_elem(l, s->cursor_l);
 else
  return (1);
 if (s->cursor_hl)
 {
  s->cursor_hl = 0;
  while ((*hl)->prev)
   *hl = (*hl)->prev;
 }
 return (0);
}

variable_types:
buf
char *

user_defined_types: struct s_save { int cursor_l; int cursor_hl; int co; struct s_sl *copy; }

user_defined_types: struct s_sl { char c; struct s_sl *next; struct s_sl *prev; }

user_defined_types: struct s_hl { struct s_sl *hist; struct s_hl *next; struct s_hl *prev; }


decompiled_code:
__int64 __fastcall ft_putc(char a1)
{
ft_putchar_fd((unsigned int)a1, 1LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char a1)
{
ft_putchar_fd((unsigned int)a1, 1LL);
return 0LL;
}

original_code:
int ft_putc(int c)
{
 ft_putchar_fd((char)c, 1);
 return (0);
}

variable_types: c int


decompiled_code:
__int64 __fastcall ft_save_line(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // [rsp+8h] [rbp-50h] BYREF
char buf[7]; // [rsp+11h] [rbp-47h] BYREF
__int64 v6; // [rsp+18h] [rbp-40h] BYREF
__int64 v7; // [rsp+20h] [rbp-38h] BYREF
int v8; // [rsp+28h] [rbp-30h]
__int64 v9; // [rsp+30h] [rbp-28h]

v4 = a3;
v6 = 0LL;
v9 = 0LL;
v7 = 0LL;
ft_putstr("_$> ");
while ( 1 )
{
if ( (_DWORD)v7 == -1 )
{
LODWORD(v7) = ft_slist_len(v6);
ft_print(v6, &v7, (unsigned int)(((int)v7 + 4) / v8));
if ( (unsigned int)ft_put_in_hist(a1, v6) != -1 )
return (unsigned int)-((unsigned int)ft_do_line(a2, v6) == -1);
return 0xFFFFFFFFLL;
}
ft_bzero(buf, 7LL);
if ( read(0, buf, 6uLL) == -1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)ft_is_key_ctrl_d(buf) )
break;
if ( (unsigned int)ft_check_key(buf, &v6, (int *)&v7, &v4) )
return 0xFFFFFFFFLL;
}
return 4294967294LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // [rsp+8h] [rbp-50h] BYREF
char buf[7]; // [rsp+11h] [rbp-47h] BYREF
__int64 v6; // [rsp+18h] [rbp-40h] BYREF
__int64 v7; // [rsp+20h] [rbp-38h] BYREF
int v8; // [rsp+28h] [rbp-30h]
__int64 v9; // [rsp+30h] [rbp-28h]

v4 = a3;
v6 = 0LL;
v9 = 0LL;
v7 = 0LL;
ft_putstr("_$> ");
while ( 1 )
{
if ( (_DWORD)v7 == -1 )
{
LODWORD(v7) = ft_slist_len(v6);
ft_print(v6, &v7, (unsigned int)(((int)v7 + 4) / v8));
if ( (unsigned int)ft_put_in_hist(a1, v6) != -1 )
return (unsigned int)-((unsigned int)ft_do_line(a2, v6) == -1);
return 0xFFFFFFFFLL;
}
ft_bzero(buf, 7LL);
if ( read(0, buf, 6uLL) == -1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)ft_is_key_ctrl_d(buf) )
break;
if ( (unsigned int)func2(buf, &v6, (int *)&v7, &v4) )
return 0xFFFFFFFFLL;
}
return 4294967294LL;
}

original_code:
int ft_save_line(t_hl **hlist, char **line, t_hl *move)
{
 char buf[6 + 1];
 t_save save;
 t_sl *list;
 list = ((void *)0);
 save.copy = ((void *)0);
 save.cursor_l = 0;
 save.cursor_hl = 0;
 ft_putstr("_$> ");
 while (save.cursor_l != -1)
 {
  ft_bzero(buf, 6 + 1);
  if (read(0, buf, 6) == -1)
   return (-1);
  if (ft_is_key_ctrl_d(buf))
   return (-2);
  if (ft_check_key(buf, &list, &save, &move))
   return (-1);
 }
 save.cursor_l = ft_slist_len(list);
 ft_print(list, &save, (4 + save.cursor_l) / save.co);
 if ((ft_put_in_hist(hlist, list) == -1) || (ft_do_line(line, list)) == -1)
  return (-1);
 return (0);
}

canonical_original_code:
int ft_save_line(struct s_hl **hlist, char **line, struct s_hl *move)
{
 char buf[-1];
 struct s_save save;
 struct s_sl *list;
 list = ((void *)0);
 save.copy = ((void *)0);
 save.cursor_l = 0;
 save.cursor_hl = 0;
 ft_putstr("_$> ");
 while (save.cursor_l != -1)
 {
  ft_bzero(buf, 6 + 1);
  if (read(0, buf, 6) == -1)
   return (-1);
  if (ft_is_key_ctrl_d(buf))
   return (-2);
  if (ft_check_key(buf, &list, &save, &move))
   return (-1);
 }
 save.cursor_l = ft_slist_len(list);
 ft_print(list, &save, (4 + save.cursor_l) / save.co);
 if ((ft_put_in_hist(hlist, list) == -1) || (ft_do_line(line, list)) == -1)
  return (-1);
 return (0);
}

variable_types: struct s_hl { struct s_sl { char c; struct s_sl *next; struct s_sl *prev; } *hist; struct s_hl *next; struct s_hl *prev; } **

variable_types:
line
char **

variable_types:
move
struct s_hl *

variable_types:
buf
char [-1]

variable_types: struct s_save { int cursor_l; int cursor_hl; int co; struct s_sl { char c; struct s_sl *next; struct s_sl *prev; } *copy; }


decompiled_code:
void __fastcall ft_init_vect(double *a1, double a2, double a3, double a4)
{
*a1 = a2;
a1[1] = a3;
a1[2] = a4;
}

canonical_decompiled_code:
void __fastcall func0(double *a1, double a2, double a3, double a4)
{
*a1 = a2;
a1[1] = a3;
a1[2] = a4;
}

original_code:
void ft_init_vect(t_v *vect, double x, double y, double z)
{
 vect->x = x;
 vect->y = y;
 vect->z = z;
}

canonical_original_code:
void ft_init_vect(struct s_v *vect, double x, double y, double z)
{
 vect->x = x;
 vect->y = y;
 vect->z = z;
}

variable_types: struct s_v { double x; double y; double z; } *

variable_types: x double

variable_types: y double

variable_types: z double


original_code:
void ft_vect_opposite(t_v *vect, t_v v1)
{
 vect->x = -v1.x;
 vect->y = -v1.y;
 vect->z = -v1.z;
}

canonical_original_code:
void ft_vect_opposite(struct s_v *vect, struct s_v v1)
{
 vect->x = -v1.x;
 vect->y = -v1.y;
 vect->z = -v1.z;
}


decompiled_code:
void __fastcall ft_vect_sum(double *a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14, double a15)
{
*a1 = a10 + a13;
a1[1] = a11 + a14;
a1[2] = a12 + a15;
}

canonical_decompiled_code:
void __fastcall func2(double *a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14, double a15)
{
*a1 = a10 + a13;
a1[1] = a11 + a14;
a1[2] = a12 + a15;
}

original_code:
void ft_vect_sum(t_v *vect, t_v v1, t_v v2)
{
 vect->x = v1.x + v2.x;
 vect->y = v1.y + v2.y;
 vect->z = v1.z + v2.z;
}

canonical_original_code:
void ft_vect_sum(struct s_v *vect, struct s_v v1, struct s_v v2)
{
 vect->x = v1.x + v2.x;
 vect->y = v1.y + v2.y;
 vect->z = v1.z + v2.z;
}


decompiled_code:
void __fastcall ft_mult_vect_by_nb(double *a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12)
{
*a1 = a10 * a2;
a1[1] = a11 * a2;
a1[2] = a2 * a12;
}

canonical_decompiled_code:
void __fastcall func3(double *a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12)
{
*a1 = a10 * a2;
a1[1] = a11 * a2;
a1[2] = a2 * a12;
}

original_code:
void ft_mult_vect_by_nb(t_v *vect, t_v v1, double scalar)
{
 vect->x = v1.x * scalar;
 vect->y = v1.y * scalar;
 vect->z = v1.z * scalar;
}

canonical_original_code:
void ft_mult_vect_by_nb(struct s_v *vect, struct s_v v1, double scalar)
{
 vect->x = v1.x * scalar;
 vect->y = v1.y * scalar;
 vect->z = v1.z * scalar;
}

variable_types: scalar double


decompiled_code:
const char *__fastcall ft_command_exist(__int64 a1, __int64 *a2)
{
const char **v2; // r13
_QWORD *v3; // rbx
struct stat *v4; // rax
struct stat *v5; // rbp
__int64 v6; // rdi
__int64 v7; // rax
__int64 v8; // rax
const char *v9; // r12

v2 = (const char **)ft_strsplit(a1, 32LL);
v3 = (_QWORD *)ft_find_paths_in_env(a2);
v4 = (struct stat *)malloc(0x90uLL);
if ( v4 )
{
v5 = v4;
if ( *v3 )
{
do
{
v7 = ft_strlen();
if ( !malloc(v7 + 1) )
break;
v8 = ft_strjoin(*v3, "/");
v9 = (const char *)ft_strjoin(v8, *v2);
if ( !lstat(v9, v5) )
return v9;
if ( !lstat(*v2, v5) )
return *v2;
v6 = v3[1];
++v3;
}
while ( v6 );
}
}
return 0LL;
}

canonical_decompiled_code:
const char *__fastcall func2(__int64 a1, __int64 *a2)
{
const char **v2; // r13
_QWORD *v3; // rbx
struct stat *v4; // rax
struct stat *v5; // rbp
__int64 v6; // rdi
__int64 v7; // rax
__int64 v8; // rax
const char *v9; // r12

v2 = (const char **)ft_strsplit(a1, 32LL);
v3 = (_QWORD *)func1(a2);
v4 = (struct stat *)malloc(0x90uLL);
if ( v4 )
{
v5 = v4;
if ( *v3 )
{
do
{
v7 = ft_strlen();
if ( !malloc(v7 + 1) )
break;
v8 = ft_strjoin(*v3, "/");
v9 = (const char *)ft_strjoin(v8, *v2);
if ( !lstat(v9, v5) )
return v9;
if ( !lstat(*v2, v5) )
return *v2;
v6 = v3[1];
++v3;
}
while ( v6 );
}
}
return 0LL;
}

original_code:
static char *ft_command_exist(char *com, char **env)
{
 int i;
 char *str;
 char **all_paths;
 char **command;
 struct stat *buf;
 command = ft_strsplit(com, ' ');
 all_paths = ft_find_paths_in_env(env);
 i = 0;
 if (!(buf = (struct stat *)malloc(sizeof(*buf))))
  return (((void *)0));
 while (all_paths[i])
 {
  if (!(str = (char *)malloc(sizeof(*str) * ft_strlen(all_paths[i]) + 1)))
   return (((void *)0));
  str = ft_strjoin(all_paths[i], "/");
  str = ft_strjoin(str, command[0]);
  if (lstat(str, buf) == 0)
   return (str);
  else if (lstat(command[0], buf) == 0)
   return (command[0]);
  i++;
 }
 return (((void *)0));
}

variable_types:
com
char *

variable_types:
env
char **

variable_types: i int

variable_types:
str
char *

variable_types:
command
char **

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


original_code:
int ft_init_struct(char **av, char **env, t_pipex *pipex, t_fd *fd)
{
 pipex->file1 = ft_file_exist(av[1]);
 if (!(pipex->file2 = (char *)malloc(sizeof(char *) * ft_strlen(av[4]) + 1)))
 {
  ft_putendl("Error");
  return (-1);
 }
 ft_strcpy(pipex->file2, av[4]);
 pipex->cmd1 = ft_command_exist(av[2], env);
 pipex->cmd2 = ft_command_exist(av[3], env);
 fd->fd1 = open(pipex->file1, 00);
 fd->fd2 = open(pipex->file2, 02 | 0100 | 01000, 0400
     | 0200 | 0100);
 if (fd->fd1 == -1 || fd->fd2 == -1 || !pipex->file1
  || !pipex->cmd1 || !pipex->cmd2)
 {
  ft_putendl("Error");
  return (-1);
 }
 return (1);
}

canonical_original_code:
int ft_init_struct(char **av, char **env, struct s_pipex *pipex, struct s_fd *fd)
{
 pipex->file1 = ft_file_exist(av[1]);
 if (!(pipex->file2 = (char *)malloc(sizeof(char *) * ft_strlen(av[4]) + 1)))
 {
  ft_putendl("Error");
  return (-1);
 }
 ft_strcpy(pipex->file2, av[4]);
 pipex->cmd1 = ft_command_exist(av[2], env);
 pipex->cmd2 = ft_command_exist(av[3], env);
 fd->fd1 = open(pipex->file1, 00);
 fd->fd2 = open(pipex->file2, 02 | 0100 | 01000, 0400
     | 0200 | 0100);
 if (fd->fd1 == -1 || fd->fd2 == -1 || !pipex->file1
  || !pipex->cmd1 || !pipex->cmd2)
 {
  ft_putendl("Error");
  return (-1);
 }
 return (1);
}

variable_types:
av
char **

variable_types: struct s_pipex { char *file1; char *cmd1; char *file2; char *cmd2; } *

variable_types: struct s_fd { int fd1; int fd2; int fd_tmp; } *


decompiled_code:
__int64 __fastcall ft_find_paths_in_env(__int64 *a1)
{
__int64 v1; // r12
__int64 *v2; // rbx
__int64 v3; // rdi
__int64 v4; // rax
__int64 v5; // rax

v2 = a1;
v3 = *a1;
if ( v3 )
{
do
{
while ( (unsigned int)ft_strncmp(v3, "PATH=", 5LL) )
{
v3 = v2[1];
++v2;
if ( !v3 )
return v1;
}
v4 = *v2++;
v5 = ft_strsplit(v4 + 5, 58LL);
v3 = *v2;
v1 = v5;
}
while ( *v2 );
}
return v1;
}

original_code:
static char **ft_find_paths_in_env(char **env)
{
 int i;
 char **all_paths;
 i = 0;
 while (env[i])
 {
  if (ft_strncmp(env[i], "PATH=", 5) == 0)
   all_paths = ft_strsplit(&env[i][5], ':');
  i++;
 }
 return (all_paths);
}


decompiled_code:
__int64 __fastcall ft_intersect_a_box(double *a1, double *a2)
{
__int64 v2; // r8
__int64 v3; // r9
__int64 v4; // r8
__int64 v5; // r9
__int64 v6; // r8
double v7; // xmm2_8
double v8; // xmm1_8
__int64 result; // rax
double v10; // [rsp+0h] [rbp-20h] BYREF
double v11; // [rsp+8h] [rbp-18h] BYREF
double v12; // [rsp+10h] [rbp-10h] BYREF
double v13; // [rsp+18h] [rbp-8h] BYREF

ft_find_x_box(a1, a2, (__int64 *)&v10, (__int64 *)&v11);
ft_find_y_box(v2, v3, (__int64 *)&v12, (__int64 *)&v13);
if ( v12 > v11 )
return 0xFFFFFFFFLL;
if ( v10 > v13 )
return 0xFFFFFFFFLL;
v10 = fmax(v12, v10);
v11 = fmin(v13, v11);
ft_find_z_box(v4, v5, (__int64 *)&v12, (__int64 *)&v13);
v7 = v11;
if ( v12 > v11 )
return 0xFFFFFFFFLL;
v8 = v13;
if ( v10 > v13 )
return 0xFFFFFFFFLL;
result = 0LL;
*(double *)(v6 + 96) = fmax(v12, v10);
*(double *)(v6 + 104) = fmin(v8, v7);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(double *a1, double *a2)
{
__int64 v2; // r8
__int64 v3; // r9
__int64 v4; // r8
__int64 v5; // r9
__int64 v6; // r8
double v7; // xmm2_8
double v8; // xmm1_8
__int64 result; // rax
double v10; // [rsp+0h] [rbp-20h] BYREF
double v11; // [rsp+8h] [rbp-18h] BYREF
double v12; // [rsp+10h] [rbp-10h] BYREF
double v13; // [rsp+18h] [rbp-8h] BYREF

func1(a1, a2, (__int64 *)&v10, (__int64 *)&v11);
func2(v2, v3, (__int64 *)&v12, (__int64 *)&v13);
if ( v12 > v11 )
return 0xFFFFFFFFLL;
if ( v10 > v13 )
return 0xFFFFFFFFLL;
v10 = fmax(v12, v10);
v11 = fmin(v13, v11);
func3(v4, v5, (__int64 *)&v12, (__int64 *)&v13);
v7 = v11;
if ( v12 > v11 )
return 0xFFFFFFFFLL;
v8 = v13;
if ( v10 > v13 )
return 0xFFFFFFFFLL;
result = 0LL;
*(double *)(v6 + 96) = fmax(v12, v10);
*(double *)(v6 + 104) = fmin(v8, v7);
return result;
}

original_code:
int ft_intersect_a_box(t_r *r, void *data)
{
 double tmin;
 double tmax;
 double tmp1;
 double tmp2;
 t_box *box;
 box = (t_box *)data;
 ft_find_x_box(r, box, &tmin, &tmax);
 ft_find_y_box(r, box, &tmp1, &tmp2);
 if (tmp1 > tmax || tmin > tmp2)
  return (-1);
 tmin = (tmp1 > tmin) ? tmp1 : tmin;
 tmax = (tmp2 < tmax) ? tmp2 : tmax;
 ft_find_z_box(r, box, &tmp1, &tmp2);
 if (tmp1 > tmax || tmin > tmp2)
  return (-1);
 tmin = (tmp1 > tmin) ? tmp1 : tmin;
 tmax = (tmp2 < tmax) ? tmp2 : tmax;
 r->t0 = tmin;
 r->t1 = tmax;
 return (0);
}

canonical_original_code:
int ft_intersect_a_box(struct s_r *r, void *data)
{
 double tmin;
 double tmax;
 double tmp1;
 double tmp2;
 struct s_box *box;
 box = (struct s_box *)data;
 ft_find_x_box(r, box, &tmin, &tmax);
 ft_find_y_box(r, box, &tmp1, &tmp2);
 if (tmp1 > tmax || tmin > tmp2)
  return (-1);
 tmin = (tmp1 > tmin) ? tmp1 : tmin;
 tmax = (tmp2 < tmax) ? tmp2 : tmax;
 ft_find_z_box(r, box, &tmp1, &tmp2);
 if (tmp1 > tmax || tmin > tmp2)
  return (-1);
 tmin = (tmp1 > tmin) ? tmp1 : tmin;
 tmax = (tmp2 < tmax) ? tmp2 : tmax;
 r->t0 = tmin;
 r->t1 = tmax;
 return (0);
}

variable_types: struct s_r { struct s_v { double x; double y; double z; } o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c { int b; int g; int r; } color; int hit_i; int hit_j; } *

variable_types:
data
void *

variable_types: tmin double

variable_types: tmax double

variable_types: struct s_box { double xmin; double xmax; double ymin; double ymax; double zmin; double zmax; struct s_c { int b; int g; int r; } sf; } *

user_defined_types: struct s_box { double xmin; double xmax; double ymin; double ymax; double zmin; double zmax; struct s_c sf; }


original_code:
int ft_draw(t_mlx *mlx)
{
 int i;
 int j;
 j = 0;
 while (j < (1200.0))
 {
  i = 0;
  while (i < (2400.0))
  {
   mlx->i.data[0 + i * 4 + j * mlx->i.sl] = (mlx->obj.pixel[j][i]).b;
   mlx->i.data[1 + i * 4 + j * mlx->i.sl] = (mlx->obj.pixel[j][i]).g;
   mlx->i.data[2 + i * 4 + j * mlx->i.sl] = (mlx->obj.pixel[j][i]).r;
   ++i;
  }
  ++j;
 }
 return (0);
}

canonical_original_code:
int ft_draw(struct s_mlx *mlx)
{
 int i;
 int j;
 j = 0;
 while (j < (1200.0))
 {
  i = 0;
  while (i < (2400.0))
  {
   mlx->i.data[0 + i * 4 + j * mlx->i.sl] = (mlx->obj.pixel[j][i]).b;
   mlx->i.data[1 + i * 4 + j * mlx->i.sl] = (mlx->obj.pixel[j][i]).g;
   mlx->i.data[2 + i * 4 + j * mlx->i.sl] = (mlx->obj.pixel[j][i]).r;
   ++i;
  }
  ++j;
 }
 return (0);
}

variable_types: struct s_mlx { void *mlx; void *win; void *img; struct s_img { char *data; int bpp; int sl; int endian; } i; struct s_obj { int depth; struct s_c { int b; int g; int r; } **pixel; void ***type; int *nb; int (*intersect[6])(struct s_r { struct s_v { double x; double y; double z; } o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c color; int hit_i; int hit_j; } *, void *); int (*treatment[6])(void *, struct s_c *, struct s_obj *, struct s_r *r); struct s_c bg_clr; } obj; } *

variable_types: j int

user_defined_types: struct s_mlx { void *mlx; void *win; void *img; struct s_img i; struct s_obj obj; }


decompiled_code:
__int64 __fastcall ft_putbase(unsigned int a1, __int64 a2)
{
unsigned __int64 v2; // rcx
unsigned __int64 v3; // r12
__int64 v4; // rbx

v2 = ft_strlen(a2);
if ( a1 <= v2 )
return ft_putchar((unsigned int)*(char *)(a2 + a1 % v2));
v3 = a1 % v2;
v4 = ft_putbase((unsigned int)(a1 / v2), a2);
ft_putchar((unsigned int)*(char *)(a2 + v3));
return v4 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 a2)
{
unsigned __int64 v2; // rcx
unsigned __int64 v3; // r12
__int64 v4; // rbx

v2 = ft_strlen(a2);
if ( a1 <= v2 )
return ft_putchar((unsigned int)*(char *)(a2 + a1 % v2));
v3 = a1 % v2;
v4 = func0((unsigned int)(a1 / v2), a2);
ft_putchar((unsigned int)*(char *)(a2 + v3));
return v4 + 1;
}

original_code:
ssize_t ft_putbase(unsigned int n, char *base)
{
 ssize_t i;
 size_t len;
 i = 0;
 len = ft_strlen(base);
 if (n <= len)
 {
  i += ft_putchar(*(base + n % len));
  return (i);
 }
 else
 {
  i += ft_putbase(n / len, base);
  ft_putchar(*(base + n % len));
 }
 return (i + 1);
}

canonical_original_code:
long ft_putbase(unsigned int n, char *base)
{
 long i;
 unsigned long len;
 i = 0;
 len = ft_strlen(base);
 if (n <= len)
 {
  i += ft_putchar(*(base + n % len));
  return (i);
 }
 else
 {
  i += ft_putbase(n / len, base);
  ft_putchar(*(base + n % len));
 }
 return (i + 1);
}

variable_types:
n
unsigned int

variable_types:
base
char *

variable_types: i long

variable_types:
len
unsigned long

return_type: long


decompiled_code:
__int64 __fastcall ft_check_if_type_to_split(__int64 a1, int a2)
{
__int64 result; // rax
int v3; // ecx
int v4; // edx

result = a1;
if ( a1 )
{
v3 = 0;
do
{
while ( 1 )
{
v4 = *(_DWORD *)(result + 8);
if ( v4 != 15 )
break;
result = *(_QWORD *)(result + 16);
++v3;
if ( !result )
return result;
}
if ( v4 == 16 )
{
--v3;
}
else if ( !v3 && v4 == a2 )
{
return result;
}
result = *(_QWORD *)(result + 16);
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
__int64 result; // rax
int v3; // ecx
int v4; // edx

result = a1;
if ( a1 )
{
v3 = 0;
do
{
while ( 1 )
{
v4 = *(_DWORD *)(result + 8);
if ( v4 != 15 )
break;
result = *(_QWORD *)(result + 16);
++v3;
if ( !result )
return result;
}
if ( v4 == 16 )
{
--v3;
}
else if ( !v3 && v4 == a2 )
{
return result;
}
result = *(_QWORD *)(result + 16);
}
while ( result );
}
return result;
}

original_code:
static t_p *ft_check_if_type_to_split(t_p *p, int type)
{
 t_p *move;
 int ind_pth;
 move = p;
 ind_pth = 0;
 while (move)
 {
  if (move->type == 15)
   ++ind_pth;
  else if (move->type == 16)
   --ind_pth;
  else if (ind_pth == 0 && move->type == type)
   return (move);
  move = move->next;
 }
 return (move);
}

canonical_original_code:
static struct s_p *ft_check_if_type_to_split(struct s_p *p, int type)
{
 struct s_p *move;
 int ind_pth;
 move = p;
 ind_pth = 0;
 while (move)
 {
  if (move->type == 15)
   ++ind_pth;
  else if (move->type == 16)
   --ind_pth;
  else if (ind_pth == 0 && move->type == type)
   return (move);
  move = move->next;
 }
 return (move);
}

variable_types:
p
struct s_p *

variable_types: type int

variable_types: struct s_p { char *tok; int type; struct s_p *next; struct s_p *prev; } *


decompiled_code:
__int64 __fastcall ft_find_priority_between_or_and_and(__int64 *a1)
{
__int64 result; // rax
int v2; // ecx
int v3; // edx

result = *a1;
if ( *a1 )
{
v2 = 0;
do
{
while ( 1 )
{
v3 = *(_DWORD *)(result + 8);
if ( v3 != 15 )
break;
result = *(_QWORD *)(result + 16);
++v2;
*a1 = result;
if ( !result )
return result;
}
if ( v3 == 16 )
{
--v2;
}
else if ( !v2 && (unsigned int)(v3 - 5) <= 1 )
{
return result;
}
result = *(_QWORD *)(result + 16);
*a1 = result;
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1)
{
__int64 result; // rax
int v2; // ecx
int v3; // edx

result = *a1;
if ( *a1 )
{
v2 = 0;
do
{
while ( 1 )
{
v3 = *(_DWORD *)(result + 8);
if ( v3 != 15 )
break;
result = *(_QWORD *)(result + 16);
++v2;
*a1 = result;
if ( !result )
return result;
}
if ( v3 == 16 )
{
--v2;
}
else if ( !v2 && (unsigned int)(v3 - 5) <= 1 )
{
return result;
}
result = *(_QWORD *)(result + 16);
*a1 = result;
}
while ( result );
}
return result;
}

original_code:
static void ft_find_priority_between_or_and_and(t_p **keep)
{
 int ind_pth;
 ind_pth = 0;
 while (*keep)
 {
  if ((*keep)->type == 15)
   ++ind_pth;
  else if ((*keep)->type == 16)
   --ind_pth;
  else if (ind_pth == 0
    && ((*keep)->type == 5 || (*keep)->type == 6))
   break ;
  *keep = (*keep)->next;
 }
}

canonical_original_code:
static void ft_find_priority_between_or_and_and(struct s_p **keep)
{
 int ind_pth;
 ind_pth = 0;
 while (*keep)
 {
  if ((*keep)->type == 15)
   ++ind_pth;
  else if ((*keep)->type == 16)
   --ind_pth;
  else if (ind_pth == 0
    && ((*keep)->type == 5 || (*keep)->type == 6))
   break ;
  *keep = (*keep)->next;
 }
}

variable_types: struct s_p { char *tok; int type; struct s_p *next; struct s_p *prev; } **


decompiled_code:
__int64 __fastcall ft_find_priority_between_all_the_redir(__int64 *a1)
{
__int64 result; // rax
int v2; // ecx
int v3; // edx

result = *a1;
if ( *a1 )
{
v2 = 0;
do
{
while ( 1 )
{
v3 = *(_DWORD *)(result + 8);
if ( v3 != 15 )
break;
result = *(_QWORD *)(result + 16);
++v2;
*a1 = result;
if ( !result )
return result;
}
if ( v3 == 16 )
{
--v2;
}
else if ( !v2 && (unsigned int)(v3 - 8) <= 2 )
{
return result;
}
result = *(_QWORD *)(result + 16);
*a1 = result;
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1)
{
__int64 result; // rax
int v2; // ecx
int v3; // edx

result = *a1;
if ( *a1 )
{
v2 = 0;
do
{
while ( 1 )
{
v3 = *(_DWORD *)(result + 8);
if ( v3 != 15 )
break;
result = *(_QWORD *)(result + 16);
++v2;
*a1 = result;
if ( !result )
return result;
}
if ( v3 == 16 )
{
--v2;
}
else if ( !v2 && (unsigned int)(v3 - 8) <= 2 )
{
return result;
}
result = *(_QWORD *)(result + 16);
*a1 = result;
}
while ( result );
}
return result;
}

original_code:
static void ft_find_priority_between_all_the_redir(t_p **keep)
{
 int ind_pth;
 ind_pth = 0;
 while (*keep)
 {
  if ((*keep)->type == 15)
   ++ind_pth;
  else if ((*keep)->type == 16)
   --ind_pth;
  else if (ind_pth == 0 && ((*keep)->type == 8
         || (*keep)->type == 9
         || (*keep)->type == 10))
   break ;
  *keep = (*keep)->next;
 }
}

canonical_original_code:
static void ft_find_priority_between_all_the_redir(struct s_p **keep)
{
 int ind_pth;
 ind_pth = 0;
 while (*keep)
 {
  if ((*keep)->type == 15)
   ++ind_pth;
  else if ((*keep)->type == 16)
   --ind_pth;
  else if (ind_pth == 0 && ((*keep)->type == 8
         || (*keep)->type == 9
         || (*keep)->type == 10))
   break ;
  *keep = (*keep)->next;
 }
}

user_defined_types: struct s_p { char *tok; int type; struct s_p *next; struct s_p *prev; }


decompiled_code:
__int64 __fastcall ft_find_priority_operand(__int64 *a1)
{
__int64 v1; // rdi
__int64 result; // rax
__int64 *v3; // r8
int *v4; // r9
int v5; // edx

v1 = *a1;
result = ft_check_if_type_to_split(v1, 4);
if ( result
|| (result = ft_check_if_type_to_split(v1, 6)) != 0
|| (result = ft_check_if_type_to_split(v1, 5)) != 0
|| (result = ft_check_if_type_to_split(v1, 7)) != 0
|| (result = ft_check_if_type_to_split(v1, 8)) != 0
|| (result = ft_check_if_type_to_split(v1, 9)) != 0
|| (result = ft_check_if_type_to_split(v1, 10)) != 0 )
{
v5 = *(_DWORD *)(result + 8);
*v4 = v5;
}
else
{
v5 = *v4;
}
if ( v5 == 6 )
return ft_find_priority_between_or_and_and(v3);
if ( (unsigned int)(v5 - 8) <= 1 )
return ft_find_priority_between_all_the_redir(v3);
if ( v5 )
*v3 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1)
{
__int64 v1; // rdi
__int64 result; // rax
__int64 *v3; // r8
int *v4; // r9
int v5; // edx

v1 = *a1;
result = func0(v1, 4);
if ( result
|| (result = func0(v1, 6)) != 0
|| (result = func0(v1, 5)) != 0
|| (result = func0(v1, 7)) != 0
|| (result = func0(v1, 8)) != 0
|| (result = func0(v1, 9)) != 0
|| (result = func0(v1, 10)) != 0 )
{
v5 = *(_DWORD *)(result + 8);
*v4 = v5;
}
else
{
v5 = *v4;
}
if ( v5 == 6 )
return func1(v3);
if ( (unsigned int)(v5 - 8) <= 1 )
return func2(v3);
if ( v5 )
*v3 = result;
return result;
}

original_code:
void ft_find_priority_operand(t_p **keep, int *type)
{
 t_p *move;
 if ((move = ft_check_if_type_to_split(*keep, 4))
  || (move = ft_check_if_type_to_split(*keep, 6))
  || (move = ft_check_if_type_to_split(*keep, 5))
  || (move = ft_check_if_type_to_split(*keep, 7))
  || (move = ft_check_if_type_to_split(*keep, 8))
  || (move = ft_check_if_type_to_split(*keep, 9))
  || (move = ft_check_if_type_to_split(*keep, 10)))
  *type = move->type;
 if (*type == 6)
  ft_find_priority_between_or_and_and(keep);
 else if (*type == 8 || *type == 9)
  ft_find_priority_between_all_the_redir(keep);
 else if (*type)
  *keep = move;
}

canonical_original_code:
void ft_find_priority_operand(struct s_p **keep, int *type)
{
 struct s_p *move;
 if ((move = ft_check_if_type_to_split(*keep, 4))
  || (move = ft_check_if_type_to_split(*keep, 6))
  || (move = ft_check_if_type_to_split(*keep, 5))
  || (move = ft_check_if_type_to_split(*keep, 7))
  || (move = ft_check_if_type_to_split(*keep, 8))
  || (move = ft_check_if_type_to_split(*keep, 9))
  || (move = ft_check_if_type_to_split(*keep, 10)))
  *type = move->type;
 if (*type == 6)
  ft_find_priority_between_or_and_and(keep);
 else if (*type == 8 || *type == 9)
  ft_find_priority_between_all_the_redir(keep);
 else if (*type)
  *keep = move;
}

variable_types:
type
int *


decompiled_code:
__int64 __fastcall ft_perform_redir(_QWORD *a1, __int64 a2, __int64 a3)
{
const char ***v3; // rax
const char **v4; // rcx
int v5; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax

v3 = (const char ***)a1[3];
if ( !v3[2] && !v3[3] )
{
v4 = *v3;
if ( !(*v3)[2] )
{
v5 = *(_DWORD *)(*a1 + 8LL);
if ( v5 == 8 )
{
v8 = open(*v4, 577, 420LL);
a3 = v8;
if ( v8 == -1 )
return ft_error_msg(**(_QWORD **)a1[3], ": open impossible", a3);
v5 = *(_DWORD *)(*a1 + 8LL);
if ( v5 != 10 )
goto LABEL_6;
}
else if ( v5 != 10 )
{
LABEL_6:
if ( v5 != 9 || (v7 = open(**(const char ***)a1[3], 1025), a3 = v7, v7 != -1) )
{
ft_exe_redir_isra_0(a1, a2, a3);
return *(unsigned int *)ft_value();
}
return ft_error_msg(**(_QWORD **)a1[3], ": open impossible", a3);
}
v9 = open(**(const char ***)a1[3], 0);
a3 = v9;
if ( v9 != -1 )
{
v5 = *(_DWORD *)(*a1 + 8LL);
goto LABEL_6;
}
return ft_error_msg(**(_QWORD **)a1[3], ": open impossible", a3);
}
}
ft_putendl_fd("Invalid null command", 2LL);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, __int64 a2, __int64 a3)
{
const char ***v3; // rax
const char **v4; // rcx
int v5; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax

v3 = (const char ***)a1[3];
if ( !v3[2] && !v3[3] )
{
v4 = *v3;
if ( !(*v3)[2] )
{
v5 = *(_DWORD *)(*a1 + 8LL);
if ( v5 == 8 )
{
v8 = open(*v4, 577, 420LL);
a3 = v8;
if ( v8 == -1 )
return ft_error_msg(**(_QWORD **)a1[3], ": open impossible", a3);
v5 = *(_DWORD *)(*a1 + 8LL);
if ( v5 != 10 )
goto LABEL_6;
}
else if ( v5 != 10 )
{
LABEL_6:
if ( v5 != 9 || (v7 = open(**(const char ***)a1[3], 1025), a3 = v7, v7 != -1) )
{
func0(a1, a2, a3);
return *(unsigned int *)ft_value();
}
return ft_error_msg(**(_QWORD **)a1[3], ": open impossible", a3);
}
v9 = open(**(const char ***)a1[3], 0);
a3 = v9;
if ( v9 != -1 )
{
v5 = *(_DWORD *)(*a1 + 8LL);
goto LABEL_6;
}
return ft_error_msg(**(_QWORD **)a1[3], ": open impossible", a3);
}
}
ft_putendl_fd("Invalid null command", 2LL);
return 0xFFFFFFFFLL;
}

original_code:
int ft_perform_redir(t_tree *t, t_env *e)
{
 int fd;
 int value;
 value = 0;
 if (t->ri->le || t->ri->ri || t->ri->p->next)
 {
  ft_putendl_fd("Invalid null command", 2);
  return (-1);
 }
 if (t->p->type == 8
  && ((fd = open(t->ri->p->tok,
      01 | 0100 | 01000, 0644)) == -1))
  return (ft_error_msg(t->ri->p->tok, ": open impossible"));
 else if (t->p->type == 10
   && ((fd = open(t->ri->p->tok, 00)) == -1))
  return (ft_error_msg(t->ri->p->tok, ": open impossible"));
 else if (t->p->type == 9
   && (fd = open(t->ri->p->tok, 02000 | 01)) == -1)
  return (ft_error_msg(t->ri->p->tok, ": open impossible"));
 ft_exe_redir(t, e, fd);
 value = *ft_value();
 return (value);
}

canonical_original_code:
int ft_perform_redir(struct s_tree *t, struct s_env *e)
{
 int fd;
 int value;
 value = 0;
 if (t->ri->le || t->ri->ri || t->ri->p->next)
 {
  ft_putendl_fd("Invalid null command", 2);
  return (-1);
 }
 if (t->p->type == 8
  && ((fd = open(t->ri->p->tok,
      01 | 0100 | 01000, 0644)) == -1))
  return (ft_error_msg(t->ri->p->tok, ": open impossible"));
 else if (t->p->type == 10
   && ((fd = open(t->ri->p->tok, 00)) == -1))
  return (ft_error_msg(t->ri->p->tok, ": open impossible"));
 else if (t->p->type == 9
   && (fd = open(t->ri->p->tok, 02000 | 01)) == -1)
  return (ft_error_msg(t->ri->p->tok, ": open impossible"));
 ft_exe_redir(t, e, fd);
 value = *ft_value();
 return (value);
}

variable_types: struct s_tree { struct s_p { char *tok; int type; struct s_p *next; struct s_p *prev; } *p; struct s_tree *fa; struct s_tree *le; struct s_tree *ri; } *

variable_types: struct s_env { char **env; char **env_s; char **envc; } *

variable_types: fd int

variable_types: value int

user_defined_types: struct s_tree { struct s_p *p; struct s_tree *fa; struct s_tree *le; struct s_tree *ri; }


decompiled_code:
__int64 __fastcall ft_perform_pipe2(__int64 a1, __int64 a2)
{
__int64 v2; // r12
_DWORD *v3; // rbx
int pipedes[2]; // [rsp+8h] [rbp-20h] BYREF

pipe(pipedes);
if ( fork() )
{
dup2(pipedes[1], 1);
close(pipedes[0]);
v2 = *(_QWORD *)(a1 + 16);
}
else
{
dup2(pipedes[0], 0);
close(pipedes[1]);
v2 = *(_QWORD *)(a1 + 24);
}
v3 = (_DWORD *)ft_value();
*v3 = ft_execute_all(v2, a2);
return *(unsigned int *)ft_value();
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // r12
_DWORD *v3; // rbx
int pipedes[2]; // [rsp+8h] [rbp-20h] BYREF

pipe(pipedes);
if ( fork() )
{
dup2(pipedes[1], 1);
close(pipedes[0]);
v2 = *(_QWORD *)(a1 + 16);
}
else
{
dup2(pipedes[0], 0);
close(pipedes[1]);
v2 = *(_QWORD *)(a1 + 24);
}
v3 = (_DWORD *)ft_value();
*v3 = ft_execute_all(v2, a2);
return *(unsigned int *)ft_value();
}

original_code:
int ft_perform_pipe2(t_tree *t, t_env *e)
{
 int fd_pipe[2];
 pid_t father;
 int value;
 value = 0;
 pipe(fd_pipe);
 father = fork();
 if (father == 0)
 {
  dup2(fd_pipe[0], 0);
  close(fd_pipe[1]);
  *ft_value() = ft_execute_all(t->ri, e);
 }
 else
 {
  dup2(fd_pipe[1], 1);
  close(fd_pipe[0]);
  *ft_value() = ft_execute_all(t->le, e);
 }
 value = *ft_value();
 return (value);
}

canonical_original_code:
int ft_perform_pipe2(struct s_tree *t, struct s_env *e)
{
 int fd_pipe[2];
 int father;
 int value;
 value = 0;
 pipe(fd_pipe);
 father = fork();
 if (father == 0)
 {
  dup2(fd_pipe[0], 0);
  close(fd_pipe[1]);
  *ft_value() = ft_execute_all(t->ri, e);
 }
 else
 {
  dup2(fd_pipe[1], 1);
  close(fd_pipe[0]);
  *ft_value() = ft_execute_all(t->le, e);
 }
 value = *ft_value();
 return (value);
}

variable_types: father int


decompiled_code:
__int64 __fastcall ft_perform_pipe(__int64 a1, __int64 a2)
{
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

LODWORD(stat_loc.__uptr) = fork();
if ( SLODWORD(stat_loc.__uptr) <= 0 )
{
ft_perform_pipe2(a1, a2);
exit(1);
}
wait((__WAIT_STATUS)&stat_loc);
return *(unsigned int *)ft_value();
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

LODWORD(stat_loc.__uptr) = fork();
if ( SLODWORD(stat_loc.__uptr) <= 0 )
{
func2(a1, a2);
exit(1);
}
wait((__WAIT_STATUS)&stat_loc);
return *(unsigned int *)ft_value();
}

original_code:
int ft_perform_pipe(t_tree *t, t_env *e)
{
 pid_t father;
 int value;
 value = 0;
 father = fork();
 if (father > 0)
  wait(&father);
 else
 {
  value = ft_perform_pipe2(t, e);
  exit(1);
 }
 value = *ft_value();
 return (value);
}

canonical_original_code:
int ft_perform_pipe(struct s_tree *t, struct s_env *e)
{
 int father;
 int value;
 value = 0;
 father = fork();
 if (father > 0)
  wait(&father);
 else
 {
  value = ft_perform_pipe2(t, e);
  exit(1);
 }
 value = *ft_value();
 return (value);
}


decompiled_code:
unsigned __int64 ft_printf(__int64 a1, ...)
{
unsigned __int64 *v1; // rax
unsigned __int64 *v2; // rbx
unsigned __int64 v3; // rax
unsigned __int64 v4; // rdx
unsigned __int64 i; // rsi
unsigned __int64 v6; // rdx
gcc_va_list va; // [rsp+8h] [rbp-E0h] BYREF

v1 = (unsigned __int64 *)malloc(0x20uLL);
v2 = v1;
if ( !v1 )
return 0LL;
*v1 = 0LL;
v1[1] = 0LL;
v3 = ft_strlen(a1);
v4 = *v2;
v2[3] = 0LL;
va_start(va, a1);
v2[2] = v3;
if ( v3 > v4 )
{
for ( i = v2[1]; ; i = v4 )
{
if ( v3 > v4 )
{
do
{
if ( *(_BYTE *)(a1 + v4) == 37 )
break;
*v2 = ++v4;
}
while ( v4 != v3 );
}
v2[3] += write(1, (const void *)(a1 + i), v4 - i);
v6 = *v2 + 1;
v3 = v2[2];
*v2 = v6;
if ( v6 < v3 )
{
ft_all_opt(a1, (unsigned int *)va, v2);
v3 = v2[2];
v4 = *v2 + 1;
*v2 = v4;
v2[1] = v4;
if ( v4 >= v3 )
return v2[3];
}
else
{
v4 = v6 + 1;
*v2 = v4;
v2[1] = v4;
if ( v4 >= v3 )
return v2[3];
}
}
}
return v2[3];
}

original_code:
ssize_t ft_printf(const char *format, ...)
{
 t_struct *info;
 va_list ap;
 if (!(info = (t_struct *)malloc(sizeof(t_struct))))
  return (0);
 info->i = 0;
 info->j = 0;
 info->len = ft_strlen(format);
 info->tot = 0;
 __builtin_va_start(ap,format);
 while (info->i < info->len)
 {
  while (info->i < info->len && *(format + info->i) != '%')
   info->i++;
  info->tot += write(1, format + info->j, info->i - info->j);
  info->i++;
  if (info->i < info->len)
   ft_all_opt(format, ap, info);
  info->i++;
  info->j = info->i;
 }
 __builtin_va_end(ap);
 return (info->tot);
}

canonical_original_code:
long ft_printf(char *format, ...)
{
 struct s_struct *info;
 __builtin_va_list ap;
 if (!(info = (struct s_struct *)malloc(sizeof(t_struct))))
  return (0);
 info->i = 0;
 info->j = 0;
 info->len = ft_strlen(format);
 info->tot = 0;
 __builtin_va_start(ap,format);
 while (info->i < info->len)
 {
  while (info->i < info->len && *(format + info->i) != '%')
   info->i++;
  info->tot += write(1, format + info->j, info->i - info->j);
  info->i++;
  if (info->i < info->len)
   ft_all_opt(format, ap, info);
  info->i++;
  info->j = info->i;
 }
 __builtin_va_end(ap);
 return (info->tot);
}

variable_types:
format
char *

variable_types: struct s_struct { unsigned long i; unsigned long j; unsigned long len; long tot; } *


decompiled_code:
__int64 __fastcall ft_find_home(__int64 *a1)
{
__int64 *v1; // rbx
__int64 v2; // rdi

v1 = a1;
v2 = *a1;
if ( v2 )
{
while ( (unsigned int)ft_strncmp(v2, "HOME=", 5LL) )
{
v2 = v1[1];
++v1;
if ( !v2 )
return v2 + 5;
}
v2 = *v1;
}
return v2 + 5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 *v1; // rbx
__int64 v2; // rdi

v1 = a1;
v2 = *a1;
if ( v2 )
{
while ( (unsigned int)ft_strncmp(v2, "HOME=", 5LL) )
{
v2 = v1[1];
++v1;
if ( !v2 )
return v2 + 5;
}
v2 = *v1;
}
return v2 + 5;
}

original_code:
static char *ft_find_home(char **env)
{
 int i;
 i = 0;
 while (env[i] && ft_strncmp(env[i], "HOME=", 5) != 0)
  ++i;
 return (env[i] + 5);
}

variable_types:
env
char **

variable_types: i int


decompiled_code:
__int64 __fastcall ft_find_oldpwd(__int64 *a1)
{
__int64 *v1; // rbx
__int64 v2; // rdi

v1 = a1;
v2 = *a1;
if ( v2 )
{
while ( (unsigned int)ft_strncmp(v2, "OLDPWD=", 7LL) )
{
v2 = v1[1];
++v1;
if ( !v2 )
return v2 + 7;
}
v2 = *v1;
}
return v2 + 7;
}

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

v1 = a1;
v2 = *a1;
if ( v2 )
{
while ( (unsigned int)ft_strncmp(v2, "OLDPWD=", 7LL) )
{
v2 = v1[1];
++v1;
if ( !v2 )
return v2 + 7;
}
v2 = *v1;
}
return v2 + 7;
}

original_code:
static char *ft_find_oldpwd(char **env)
{
 int i;
 i = 0;
 while (env[i] && ft_strncmp(env[i], "OLDPWD=", 7) != 0)
  ++i;
 return (env[i] + 7);
}


decompiled_code:
int __fastcall ft_cd_2(__int64 a1, __int64 *a2, _DWORD *a3)
{
__int64 v5; // rdi
int result; // eax
const char *v7; // rax
const char *v8; // rax

v5 = *(_QWORD *)(a1 + 8);
if ( !v5 )
{
v8 = (const char *)ft_find_home(a2);
result = chdir(v8);
if ( result == -1 )
result = ft_putendl_fd("cd: error going to home directory", 2LL);
goto LABEL_6;
}
if ( *(_QWORD *)(a1 + 16) )
return ft_putendl("cd: too many arguments");
if ( !(unsigned int)ft_strcmp(v5, "-") )
{
v7 = (const char *)ft_find_oldpwd(a2);
result = chdir(v7);
if ( result == -1 )
result = ft_putendl_fd("cd: error going to last directory", 2LL);
goto LABEL_6;
}
result = chdir(*(const char **)(a1 + 8));
if ( !result )
{
LABEL_6:
*a3 = 1;
return result;
}
return ft_putendl("cd: not a directory");
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 *a2, _DWORD *a3)
{
__int64 v5; // rdi
int result; // eax
const char *v7; // rax
const char *v8; // rax

v5 = *(_QWORD *)(a1 + 8);
if ( !v5 )
{
v8 = (const char *)func0(a2);
result = chdir(v8);
if ( result == -1 )
result = ft_putendl_fd("cd: error going to home directory", 2LL);
goto LABEL_6;
}
if ( *(_QWORD *)(a1 + 16) )
return ft_putendl("cd: too many arguments");
if ( !(unsigned int)ft_strcmp(v5, "-") )
{
v7 = (const char *)func1(a2);
result = chdir(v7);
if ( result == -1 )
result = ft_putendl_fd("cd: error going to last directory", 2LL);
goto LABEL_6;
}
result = chdir(*(const char **)(a1 + 8));
if ( !result )
{
LABEL_6:
*a3 = 1;
return result;
}
return ft_putendl("cd: not a directory");
}

original_code:
static void ft_cd_2(char **all, char **env, int *success)
{
 if (!all[1])
 {
  if (chdir(ft_find_home(env)) == -1)
   ft_putendl_fd("cd: error going to home directory", 2);
  *success = 1;
 }
 else if (all[2])
  ft_putendl("cd: too many arguments");
 else if (!ft_strcmp(all[1], "-"))
 {
  if (chdir(ft_find_oldpwd(env)) == -1)
   ft_putendl_fd("cd: error going to last directory", 2);
  *success = 1;
 }
 else if (!chdir(all[1]))
  *success = 1;
 else
  ft_putendl("cd: not a directory");
}

variable_types:
all
char **

variable_types:
success
int *


decompiled_code:
__int64 __fastcall ft_cd(__int64 a1, __int64 *a2)
{
char *v2; // rax
char *v3; // rbp
char *v4; // r14
__int64 v6; // r12
char *v7; // rax
int v8[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v8[0] = 0;
v2 = (char *)gmalloc(1025LL);
if ( !v2 )
return 0LL;
v3 = v2;
v4 = getcwd(v2, 0x400uLL);
ft_cd_2(a1, a2, v8);
if ( v8[0] != 1 )
return (__int64)a2;
v6 = ft_change_env("OLDPWD", v4, a2);
if ( !v6 )
return 0LL;
v7 = getcwd(v3, 0x400uLL);
return ft_change_env("PWD", v7, v6);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 *a2)
{
char *v2; // rax
char *v3; // rbp
char *v4; // r14
__int64 v6; // r12
char *v7; // rax
int v8[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v8[0] = 0;
v2 = (char *)gmalloc(1025LL);
if ( !v2 )
return 0LL;
v3 = v2;
v4 = getcwd(v2, 0x400uLL);
func2(a1, a2, v8);
if ( v8[0] != 1 )
return (__int64)a2;
v6 = ft_change_env("OLDPWD", v4, a2);
if ( !v6 )
return 0LL;
v7 = getcwd(v3, 0x400uLL);
return ft_change_env("PWD", v7, v6);
}

original_code:
char **ft_cd(char **all, char **env)
{
 char *cur_dir;
 char *buf;
 int success;
 success = 0;
 if (!(buf = (char *)gmalloc(sizeof(char) * (1024 + 1))))
  return (((void *)0));
 cur_dir = getcwd(buf, 1024);
 ft_cd_2(all, env, &success);
 if (success == 1)
 {
  if (!(env = ft_change_env("OLDPWD", cur_dir, env)))
   return (((void *)0));
  if (!(env = ft_change_env("PWD", getcwd(buf, 1024), env)))
   return (((void *)0));
 }
 return (env);
}

variable_types:
buf
char *

variable_types: success int


decompiled_code:
__int64 __fastcall ft_simple_left_redir(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // er13
__pid_t v6; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = ft_ts_to_str();
if ( !ft_strparse(v4) )
return 0LL;
v5 = open(a2, 0);
if ( v5 == -1 )
ft_putendl("file open failed or file does not exist");
v6 = fork();
LODWORD(stat_loc.__uptr) = v6;
if ( v6 <= 0 )
{
if ( v6 )
return a3;
dup2(v5, 0);
if ( ft_run_small_part(v4, a3) )
exit(-1);
return 0LL;
}
wait((__WAIT_STATUS)&stat_loc);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // er13
__pid_t v6; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = ft_ts_to_str();
if ( !ft_strparse(v4) )
return 0LL;
v5 = open(a2, 0);
if ( v5 == -1 )
ft_putendl("file open failed or file does not exist");
v6 = fork();
LODWORD(stat_loc.__uptr) = v6;
if ( v6 <= 0 )
{
if ( v6 )
return a3;
dup2(v5, 0);
if ( ft_run_small_part(v4, a3) )
exit(-1);
return 0LL;
}
wait((__WAIT_STATUS)&stat_loc);
return a3;
}

original_code:
char **ft_simple_left_redir(char **cmd, char *file, char **env)
{
 int father;
 int fd;
 char *line;
 char **all;
 line = ft_ts_to_str(cmd);
 if (!(all = ft_strparse(line)))
  return (((void *)0));
 if ((fd = open(file, 00)) == -1)
  ft_putendl("file open failed or file does not exist");
 if ((father = fork()) > 0)
 {
  wait(&father);
  return (env);
 }
 if (father == 0)
 {
  dup2(fd, 0);
  if (!(env = ft_run_small_part(line, env)))
   return (((void *)0));
  exit(-1);
 }
 return (env);
}

variable_types:
cmd
char **

variable_types:
file
char *

variable_types:
line
char *


decompiled_code:
__int64 __fastcall ft_simple_right_redir(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // er13
__pid_t v6; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = ft_ts_to_str();
if ( !ft_strparse(v4) )
return 0LL;
v5 = open(a2, 578, 384LL);
if ( v5 == -1 )
ft_putendl("file open failed");
v6 = fork();
LODWORD(stat_loc.__uptr) = v6;
if ( v6 <= 0 )
{
if ( v6 )
return a3;
dup2(v5, 1);
if ( ft_run_small_part(v4, a3) )
exit(-1);
return 0LL;
}
wait((__WAIT_STATUS)&stat_loc);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // er13
__pid_t v6; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = ft_ts_to_str();
if ( !ft_strparse(v4) )
return 0LL;
v5 = open(a2, 578, 384LL);
if ( v5 == -1 )
ft_putendl("file open failed");
v6 = fork();
LODWORD(stat_loc.__uptr) = v6;
if ( v6 <= 0 )
{
if ( v6 )
return a3;
dup2(v5, 1);
if ( ft_run_small_part(v4, a3) )
exit(-1);
return 0LL;
}
wait((__WAIT_STATUS)&stat_loc);
return a3;
}

original_code:
char **ft_simple_right_redir(char **cmd, char *file, char **env)
{
 pid_t father;
 int fd;
 char *line;
 char **all;
 line = ft_ts_to_str(cmd);
 if (!(all = ft_strparse(line)))
  return (((void *)0));
 if ((fd = open(file, 02 | 0100 | 01000, 0400
     | 0200 | 0400)) == -1)
  ft_putendl("file open failed");
 if ((father = fork()) > 0)
 {
  wait(&father);
  return (env);
 }
 if (father == 0)
 {
  dup2(fd, 1);
  if (!(env = ft_run_small_part(line, env)))
   return (((void *)0));
  exit(-1);
 }
 return (env);
}

canonical_original_code:
char **ft_simple_right_redir(char **cmd, char *file, char **env)
{
 int father;
 int fd;
 char *line;
 char **all;
 line = ft_ts_to_str(cmd);
 if (!(all = ft_strparse(line)))
  return (((void *)0));
 if ((fd = open(file, 02 | 0100 | 01000, 0400
     | 0200 | 0400)) == -1)
  ft_putendl("file open failed");
 if ((father = fork()) > 0)
 {
  wait(&father);
  return (env);
 }
 if (father == 0)
 {
  dup2(fd, 1);
  if (!(env = ft_run_small_part(line, env)))
   return (((void *)0));
  exit(-1);
 }
 return (env);
}


decompiled_code:
__int64 __fastcall ft_double_right_redir(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // er13
__pid_t v6; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = ft_ts_to_str();
if ( !ft_strparse(v4) )
return 0LL;
v5 = open(a2, 1090, 384LL);
if ( v5 == -1 )
ft_putendl("file open failed");
v6 = fork();
LODWORD(stat_loc.__uptr) = v6;
if ( v6 <= 0 )
{
if ( v6 )
return a3;
dup2(v5, 1);
if ( ft_run_small_part(v4, a3) )
exit(-1);
return 0LL;
}
wait((__WAIT_STATUS)&stat_loc);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rbp
int v5; // er13
__pid_t v6; // eax
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = ft_ts_to_str();
if ( !ft_strparse(v4) )
return 0LL;
v5 = open(a2, 1090, 384LL);
if ( v5 == -1 )
ft_putendl("file open failed");
v6 = fork();
LODWORD(stat_loc.__uptr) = v6;
if ( v6 <= 0 )
{
if ( v6 )
return a3;
dup2(v5, 1);
if ( ft_run_small_part(v4, a3) )
exit(-1);
return 0LL;
}
wait((__WAIT_STATUS)&stat_loc);
return a3;
}

original_code:
char **ft_double_right_redir(char **cmd, char *file, char **env)
{
 pid_t father;
 int fd;
 char *line;
 char **all;
 line = ft_ts_to_str(cmd);
 if (!(all = ft_strparse(line)))
  return (((void *)0));
 if ((fd = open(file, 02 | 0100 | 02000, 0400
     | 0200 | 0400)) == -1)
  ft_putendl("file open failed");
 if ((father = fork()) > 0)
 {
  wait(&father);
  return (env);
 }
 if (father == 0)
 {
  dup2(fd, 1);
  if (!(env = ft_run_small_part(line, env)))
   return (((void *)0));
  exit(-1);
 }
 return (env);
}

canonical_original_code:
char **ft_double_right_redir(char **cmd, char *file, char **env)
{
 int father;
 int fd;
 char *line;
 char **all;
 line = ft_ts_to_str(cmd);
 if (!(all = ft_strparse(line)))
  return (((void *)0));
 if ((fd = open(file, 02 | 0100 | 02000, 0400
     | 0200 | 0400)) == -1)
  ft_putendl("file open failed");
 if ((father = fork()) > 0)
 {
  wait(&father);
  return (env);
 }
 if (father == 0)
 {
  dup2(fd, 1);
  if (!(env = ft_run_small_part(line, env)))
   return (((void *)0));
  exit(-1);
 }
 return (env);
}


decompiled_code:
__int64 __fastcall ft_swap_r(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx
__int64 result; // rax

if ( !a1 )
return 0LL;
v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
*(_QWORD *)(v2 + 8) = a1;
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 8) = 0LL;
return result;
}

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

if ( !a1 )
return 0LL;
v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
*(_QWORD *)(v2 + 8) = a1;
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 8) = 0LL;
return result;
}

original_code:
t_lst *ft_swap_r(t_lst *list)
{
 t_lst *tmp;
 if (!list || !list->next)
  return (list);
 tmp = list;
 while (list->next)
  list = list->next;
 list->next = tmp;
 tmp = tmp->next;
 list->next->next = ((void *)0);
 return (tmp);
}

canonical_original_code:
struct s_lst *ft_swap_r(struct s_lst *list)
{
 struct s_lst *tmp;
 if (!list || !list->next)
  return (list);
 tmp = list;
 while (list->next)
  list = list->next;
 list->next = tmp;
 tmp = tmp->next;
 list->next->next = ((void *)0);
 return (tmp);
}

variable_types:
list
struct s_lst *

variable_types: struct s_lst { int nb; struct s_lst *next; } *


decompiled_code:
__int64 __fastcall ft_swap_rr(__int64 a1)
{
__int64 v1; // rax
__int64 i; // rdx
__int64 v3; // r8
__int64 result; // rax

if ( !a1 )
return 0LL;
v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return a1;
for ( i = a1; ; i = v3 )
{
v3 = v1;
v1 = *(_QWORD *)(v1 + 8);
if ( !v1 )
break;
}
*(_QWORD *)(v3 + 8) = a1;
result = v3;
*(_QWORD *)(i + 8) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rax
__int64 i; // rdx
__int64 v3; // r8
__int64 result; // rax

if ( !a1 )
return 0LL;
v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return a1;
for ( i = a1; ; i = v3 )
{
v3 = v1;
v1 = *(_QWORD *)(v1 + 8);
if ( !v1 )
break;
}
*(_QWORD *)(v3 + 8) = a1;
result = v3;
*(_QWORD *)(i + 8) = 0LL;
return result;
}

original_code:
t_lst *ft_swap_rr(t_lst *list)
{
 t_lst *tmp;
 t_lst *tmp2;
 if (!list || !list->next)
  return (list);
 tmp = list;
 while (list->next->next)
  list = list->next;
 tmp2 = list;
 list = list->next;
 list->next = tmp;
 tmp2->next = ((void *)0);
 return (list);
}

canonical_original_code:
struct s_lst *ft_swap_rr(struct s_lst *list)
{
 struct s_lst *tmp;
 struct s_lst *tmp2;
 if (!list || !list->next)
  return (list);
 tmp = list;
 while (list->next->next)
  list = list->next;
 tmp2 = list;
 list = list->next;
 list->next = tmp;
 tmp2->next = ((void *)0);
 return (list);
}

return_type: struct s_lst { int nb; struct s_lst *next; } *


decompiled_code:
__int64 __fastcall ft_intersect_a_plane(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
double v6; // xmm0_8
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // r8
__int64 v10; // r9
double v11; // xmm0_8
__int64 v13; // [rsp+10h] [rbp-38h] BYREF

v6 = ft_dot_product(a1, a2, a3, a4, a5, a6);
if ( COERCE_DOUBLE(*(_QWORD *)&v6 & LC0) < 0.000001 )
return 0xFFFFFFFFLL;
ft_vect_difference(&v13);
v11 = ft_dot_product(&v13, a2, v7, v8, v9, v10) / v6;
*(_QWORD *)(a1 + 104) = LC2;
*(double *)(a1 + 96) = v11;
return (unsigned int)-(v11 <= 0.0);
}

original_code:
int ft_intersect_a_plane(t_r *r, void *data)
{
 t_v o_to_c;
 double denom;
 t_pla *pla;
 pla = (t_pla *)data;
 denom = ft_dot_product(r->d_w, pla->n);
 if (fabs(denom) < (0.000001))
  return (-1);
 ft_vect_difference(&o_to_c, pla->c, r->o_w);
 r->t0 = ft_dot_product(pla->n, o_to_c) / denom;
 r->t1 = (1000000000.0);
 if (r->t0 > 0)
  return (0);
 return (-1);
}

canonical_original_code:
int ft_intersect_a_plane(struct s_r *r, void *data)
{
 struct s_v o_to_c;
 double denom;
 struct s_pla *pla;
 pla = (struct s_pla *)data;
 denom = ft_dot_product(r->d_w, pla->n);
 if (fabs(denom) < (0.000001))
  return (-1);
 ft_vect_difference(&o_to_c, pla->c, r->o_w);
 r->t0 = ft_dot_product(pla->n, o_to_c) / denom;
 r->t1 = (1000000000.0);
 if (r->t0 > 0)
  return (0);
 return (-1);
}

variable_types: struct s_r { struct s_v { double x; double y; double z; } o_w; struct s_v d_w; struct s_v p_hit; struct s_v n_hit; double t0; double t1; double tnear; struct s_c { int b; int g; int r; } color; int hit_i; int hit_j; } *

variable_types:
data
void *

variable_types: denom double

variable_types: struct s_pla { struct s_v { double x; double y; double z; } c; struct s_v n; struct s_c { int b; int g; int r; } sf; } *

user_defined_types: struct s_pla { struct s_v c; struct s_v n; struct s_c sf; }


decompiled_code:
char *__fastcall ft_not_need_variable_env_path(char *file)
{
struct stat *v1; // rax
struct stat *v2; // r12
struct stat *v4; // rdi

v1 = (struct stat *)gmalloc(144LL);
v2 = v1;
if ( v1 )
{
if ( !lstat(file, v1) && (v2->st_mode & 0x4040) == 64 && (*file == 47 || *file == 46 && file[1] == 47) )
{
gfree(v2);
return file;
}
v4 = v2;
v2 = 0LL;
gfree(v4);
}
return (char *)v2;
}

canonical_decompiled_code:
char *__fastcall func0(char *file)
{
struct stat *v1; // rax
struct stat *v2; // r12
struct stat *v4; // rdi

v1 = (struct stat *)gmalloc(144LL);
v2 = v1;
if ( v1 )
{
if ( !lstat(file, v1) && (v2->st_mode & 0x4040) == 64 && (*file == 47 || *file == 46 && file[1] == 47) )
{
gfree(v2);
return file;
}
v4 = v2;
v2 = 0LL;
gfree(v4);
}
return (char *)v2;
}

original_code:
char *ft_not_need_variable_env_path(char *cmd)
{
 struct stat *buf;
 if (!(buf = (struct stat *)gmalloc(sizeof(*buf))))
  return (((void *)0));
 if (lstat(cmd, buf) == 0
  && buf->st_mode & 0100 && !(buf->st_mode & 0040000)
  && (cmd[0] == '/' || (cmd[0] == '.' && cmd[1] == '/')))
 {
  gfree(buf);
  return (cmd);
 }
 gfree(buf);
 return (((void *)0));
}

variable_types:
cmd
char *

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


decompiled_code:
char *__fastcall ft_find_the_path(char *a1, _QWORD *a2)
{
char *v3; // r14
__int64 v5; // rbp
__int64 v6; // rax
const char *v7; // r12

v3 = ft_not_need_variable_env_path(a1);
if ( !v3 )
{
while ( *a2 )
{
v5 = gmalloc(144LL);
if ( !v5 )
break;
v6 = ft_strjoin(*a2, &unk_335);
v7 = (const char *)ft_strjoin(v6, a1);
if ( !lstat(v7, (struct stat *)v5) && (*(_BYTE *)(v5 + 24) & 0x40) != 0 )
{
gfree(v5);
return (char *)v7;
}
++a2;
gfree(v7);
gfree(v5);
}
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func1(char *a1, _QWORD *a2)
{
char *v3; // r14
__int64 v5; // rbp
__int64 v6; // rax
const char *v7; // r12

v3 = func0(a1);
if ( !v3 )
{
while ( *a2 )
{
v5 = gmalloc(144LL);
if ( !v5 )
break;
v6 = ft_strjoin(*a2, &unk_335);
v7 = (const char *)ft_strjoin(v6, a1);
if ( !lstat(v7, (struct stat *)v5) && (*(_BYTE *)(v5 + 24) & 0x40) != 0 )
{
gfree(v5);
return (char *)v7;
}
++a2;
gfree(v7);
gfree(v5);
}
}
return v3;
}

original_code:
char *ft_find_the_path(char *cmd, char **paths)
{
 char *good_path;
 struct stat *buf;
 int i;
 good_path = ((void *)0);
 buf = ((void *)0);
 if ((good_path = ft_not_need_variable_env_path(cmd)))
  return (good_path);
 i = -1;
 while (paths[++i])
 {
  if (!(buf = (struct stat *)gmalloc(sizeof(*buf))))
   return (((void *)0));
  good_path = ft_strjoin(ft_strjoin(paths[i], "/"), cmd);
  if (lstat(good_path, buf) == 0 && buf->st_mode & 0100)
  {
   gfree(buf);
   return (good_path);
  }
  gfree(good_path);
  gfree(buf);
 }
 return (((void *)0));
}

variable_types:
paths
char **

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
__int64 __fastcall ft_perform_exe(char **a1, __int64 **a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rdi
_QWORD *v6; // r14
char *v7; // rax
char *v8; // r13
unsigned int v9; // er12
__int64 result; // rax

v3 = 0LL;
v4 = **a2;
if ( !v4 )
goto LABEL_9;
while ( (unsigned int)ft_strncmp(v4, "PATH=", 5LL) )
{
v4 = (*a2)[++v3];
if ( !v4 )
goto LABEL_9;
}
v5 = (*a2)[v3];
if ( v5 )
v6 = (_QWORD *)ft_strsplit(v5 + 5, 58LL);
else
LABEL_9:
v6 = (_QWORD *)ft_strsplit(*a2[1] + 5, 58LL);
v7 = ft_find_the_path(*a1, v6);
v8 = v7;
if ( v7 )
{
v9 = ft_exe_the_cmd(a1, v7, *a2);
gfree(v8);
ft_free_char2(v6);
result = v9;
}
else
{
ft_free_char2(v6);
result = ft_error_msg(*a1, ": Command not found");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char **a1, __int64 **a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rdi
_QWORD *v6; // r14
char *v7; // rax
char *v8; // r13
unsigned int v9; // er12
__int64 result; // rax

v3 = 0LL;
v4 = **a2;
if ( !v4 )
goto LABEL_9;
while ( (unsigned int)ft_strncmp(v4, "PATH=", 5LL) )
{
v4 = (*a2)[++v3];
if ( !v4 )
goto LABEL_9;
}
v5 = (*a2)[v3];
if ( v5 )
v6 = (_QWORD *)ft_strsplit(v5 + 5, 58LL);
else
LABEL_9:
v6 = (_QWORD *)ft_strsplit(*a2[1] + 5, 58LL);
v7 = func1(*a1, v6);
v8 = v7;
if ( v7 )
{
v9 = ft_exe_the_cmd(a1, v7, *a2);
gfree(v8);
ft_free_char2(v6);
result = v9;
}
else
{
ft_free_char2(v6);
result = ft_error_msg(*a1, ": Command not found");
}
return result;
}

original_code:
int ft_perform_exe(t_p *p, t_env *e)
{
 char **paths;
 char *good_path;
 int i;
 int value;
 i = 0;
 value = 0;
 while (e->env[i] && ft_strncmp(e->env[i], "PATH=", 5))
  ++i;
 if (!e->env[i])
  paths = ft_strsplit(&(e->env_s[0][5]), ':');
 else
  paths = ft_strsplit(&(e->env[i][5]), ':');
 if (!(good_path = ft_find_the_path(p->tok, paths)))
 {
  ft_free_char2(paths);
  return (ft_error_msg(p->tok, ": Command not found"));
 }
 value = ft_exe_the_cmd(p, good_path, e->env);
 gfree(good_path);
 ft_free_char2(paths);
 return (value);
}

canonical_original_code:
int ft_perform_exe(struct s_p *p, struct s_env *e)
{
 char **paths;
 char *good_path;
 int i;
 int value;
 i = 0;
 value = 0;
 while (e->env[i] && ft_strncmp(e->env[i], "PATH=", 5))
  ++i;
 if (!e->env[i])
  paths = ft_strsplit(&(e->env_s[0][5]), ':');
 else
  paths = ft_strsplit(&(e->env[i][5]), ':');
 if (!(good_path = ft_find_the_path(p->tok, paths)))
 {
  ft_free_char2(paths);
  return (ft_error_msg(p->tok, ": Command not found"));
 }
 value = ft_exe_the_cmd(p, good_path, e->env);
 gfree(good_path);
 ft_free_char2(paths);
 return (value);
}

variable_types: struct s_p { char *tok; int type; struct s_p *next; struct s_p *prev; } *

variable_types: struct s_env { char **env; char **env_s; char **envc; } *

variable_types: i int

variable_types: value int


decompiled_code:
__int64 __fastcall ft_perform_cmd(char ***a1, __int64 **a2)
{
__int64 result; // rax
int v3; // eax
char **v4; // rdi

if ( !(unsigned int)ft_strcmp(**a1, "exit") )
return ft_exit(*a1);
if ( (unsigned int)ft_strcmp(**a1, "echo") )
{
if ( (unsigned int)ft_strcmp(**a1, "cd") )
{
if ( (unsigned int)ft_strcmp(**a1, "env") )
{
if ( (unsigned int)ft_strcmp(**a1, "unsetenv") )
{
v3 = ft_strcmp(**a1, "setenv");
v4 = *a1;
if ( v3 )
result = ft_perform_exe(v4, a2);
else
result = ft_setenv(v4, a2);
}
else
{
result = ft_unsetenv(*a1, a2);
}
}
else
{
result = ft_env(*a1, a2);
}
}
else
{
result = ft_cd(*a1, a2);
}
}
else
{
ft_echo(*a1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char ***a1, __int64 **a2)
{
__int64 result; // rax
int v3; // eax
char **v4; // rdi

if ( !(unsigned int)ft_strcmp(**a1, "exit") )
return ft_exit(*a1);
if ( (unsigned int)ft_strcmp(**a1, "echo") )
{
if ( (unsigned int)ft_strcmp(**a1, "cd") )
{
if ( (unsigned int)ft_strcmp(**a1, "env") )
{
if ( (unsigned int)ft_strcmp(**a1, "unsetenv") )
{
v3 = ft_strcmp(**a1, "setenv");
v4 = *a1;
if ( v3 )
result = func2(v4, a2);
else
result = ft_setenv(v4, a2);
}
else
{
result = ft_unsetenv(*a1, a2);
}
}
else
{
result = ft_env(*a1, a2);
}
}
else
{
result = ft_cd(*a1, a2);
}
}
else
{
ft_echo(*a1);
result = 0LL;
}
return result;
}

original_code:
int ft_perform_cmd(t_tree *t, t_env *e)
{
 int value;
 value = 0;
 if (!ft_strcmp(t->p->tok, "exit"))
  value = ft_exit(t->p);
 else if (!ft_strcmp(t->p->tok, "echo"))
  ft_echo(t->p);
 else if (!(ft_strcmp(t->p->tok, "cd")))
  value = ft_cd(t->p, e);
 else if (!(ft_strcmp(t->p->tok, "env")))
  value = ft_env(t->p, e);
 else if (!(ft_strcmp(t->p->tok, "unsetenv")))
  value = ft_unsetenv(t->p, &(e->env));
 else if (!(ft_strcmp(t->p->tok, "setenv")))
  value = ft_setenv(t->p, &(e->env));
 else
  value = ft_perform_exe(t->p, e);
 return (value);
}

canonical_original_code:
int ft_perform_cmd(struct s_tree *t, struct s_env *e)
{
 int value;
 value = 0;
 if (!ft_strcmp(t->p->tok, "exit"))
  value = ft_exit(t->p);
 else if (!ft_strcmp(t->p->tok, "echo"))
  ft_echo(t->p);
 else if (!(ft_strcmp(t->p->tok, "cd")))
  value = ft_cd(t->p, e);
 else if (!(ft_strcmp(t->p->tok, "env")))
  value = ft_env(t->p, e);
 else if (!(ft_strcmp(t->p->tok, "unsetenv")))
  value = ft_unsetenv(t->p, &(e->env));
 else if (!(ft_strcmp(t->p->tok, "setenv")))
  value = ft_setenv(t->p, &(e->env));
 else
  value = ft_perform_exe(t->p, e);
 return (value);
}

variable_types: struct s_tree { struct s_p { char *tok; int type; struct s_p *next; struct s_p *prev; } *p; struct s_tree *fa; struct s_tree *le; struct s_tree *ri; } *


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

v2 = *(__int64 **)(a1 + 16);
if ( v2 )
{
do
{
while ( (unsigned int)ft_find(*v2, "=") )
v2 = (__int64 *)v2[2];
ft_del_var(*v2, a2);
v2 = (__int64 *)v2[2];
}
while ( v2 );
result = 0LL;
}
else
{
ft_putendl_fd("unsetenv: Too few arguments", 2LL);
result = 0LL;
}
return result;
}

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

v2 = *(__int64 **)(a1 + 16);
if ( v2 )
{
do
{
while ( (unsigned int)ft_find(*v2, "=") )
v2 = (__int64 *)v2[2];
ft_del_var(*v2, a2);
v2 = (__int64 *)v2[2];
}
while ( v2 );
result = 0LL;
}
else
{
ft_putendl_fd("unsetenv: Too few arguments", 2LL);
result = 0LL;
}
return result;
}

original_code:
int ft_unsetenv(t_p *p, char ***env)
{
 t_p *move;
 move = p->next;
 if (!move)
  ft_putendl_fd("unsetenv: Too few arguments", 2);
 while (move)
 {
  while (ft_find(move->tok, "="))
   move = move->next;
  if (move)
   ft_del_var(move->tok, env);
  move = move->next;
 }
 return (0);
}

canonical_original_code:
int ft_unsetenv(struct s_p *p, char ***env)
{
 struct s_p *move;
 move = p->next;
 if (!move)
  ft_putendl_fd("unsetenv: Too few arguments", 2);
 while (move)
 {
  while (ft_find(move->tok, "="))
   move = move->next;
  if (move)
   ft_del_var(move->tok, env);
  move = move->next;
 }
 return (0);
}

variable_types:
env
char ***