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

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

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

v2 = a1;
v3 = *a1;
if ( v3 )
{
do
{
if ( !(unsigned int)ft_strncmp(v3, "PATH=", 5LL) )
v1 = ft_strsplit(*v2 + 5LL, 58LL);
v3 = *++v2;
}
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);
}

variable_types: i int


decompiled_code:
const char *__fastcall ft_good_path(char *a1, _QWORD *a2)
{
_BYTE *v2; // r13
const char **v3; // rbp
struct stat *v4; // r12
const char *i; // rbx
__int64 v6; // rax
__int64 v7; // rax

v2 = ft_bin_wanted(a1);
v3 = (const char **)ft_find_paths_in_env(a2);
v4 = (struct stat *)malloc(0x90uLL);
if ( !v4 )
return 0LL;
for ( i = *v3; *v3; i = *v3 )
{
v6 = ft_strlen(i);
i = (const char *)malloc(v6 + 1000);
if ( !i )
break;
v7 = ft_strjoin(*v3, "/");
i = (const char *)ft_strjoin(v7, v2);
if ( !lstat(i, v4) )
break;
++v3;
}
return i;
}

canonical_decompiled_code:
const char *__fastcall func1(char *a1, _QWORD *a2)
{
_BYTE *v2; // r13
const char **v3; // rbp
struct stat *v4; // r12
const char *i; // rbx
__int64 v6; // rax
__int64 v7; // rax

v2 = ft_bin_wanted(a1);
v3 = (const char **)func0(a2);
v4 = (struct stat *)malloc(0x90uLL);
if ( !v4 )
return 0LL;
for ( i = *v3; *v3; i = *v3 )
{
v6 = ft_strlen(i);
i = (const char *)malloc(v6 + 1000);
if ( !i )
break;
v7 = ft_strjoin(*v3, "/");
i = (const char *)ft_strjoin(v7, v2);
if ( !lstat(i, v4) )
break;
++v3;
}
return i;
}

original_code:
static char *ft_good_path(char *line, char **env)
{
 int i;
 char *str;
 char **all_paths;
 char *com_name;
 struct stat *buf;
 com_name = ft_bin_wanted(line);
 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]) + 1000)))
   return (((void *)0));
  str = ft_strjoin(all_paths[i], "/");
  str = ft_strjoin(str, com_name);
  if (lstat(str, buf) == 0)
   return (str);
  i++;
 }
 return (((void *)0));
}

variable_types:
line
char *

variable_types:
env
char **

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

return_type: char *

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


cfree

decompiled_code:
__int64 cfree()
{
return (unsigned int)-((unsigned int)ft_list_mal(0xFFFFFFFFLL, 0LL) == 0);
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)-((unsigned int)ft_list_mal(0xFFFFFFFFLL, 0LL) == 0);
}

original_code:
int cfree(void)
{
 if (!(ft_list_mal(-1, ((void *)0))))
  return (-1);
 return (0);
}

canonical_original_code:
int cfree()
{
 if (!(ft_list_mal(-1, ((void *)0))))
  return (-1);
 return (0);
}

return_type: int


decompiled_code:
__int64 __fastcall ft_verif_num_exit(_BYTE *a1)
{
char *v1; // rbx
char v2; // di

v1 = &a1[*a1 == 45];
v2 = *v1;
if ( !*v1 )
return 0LL;
while ( (unsigned int)ft_isdigit((unsigned int)v2) )
{
v2 = *++v1;
if ( !*v1 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
char *v1; // rbx
char v2; // di

v1 = &a1[*a1 == 45];
v2 = *v1;
if ( !*v1 )
return 0LL;
while ( (unsigned int)ft_isdigit((unsigned int)v2) )
{
v2 = *++v1;
if ( !*v1 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
static int ft_verif_num_exit(char *num)
{
 int i;
 i = 0;
 if (num[i] == '-')
  ++i;
 while (num[i])
 {
  if (!(ft_isdigit((int)num[i])))
   return (-1);
  ++i;
 }
 return (0);
}

variable_types:
num
char *


decompiled_code:
__int64 __fastcall ft_exit(__int64 a1)
{
__int64 v1; // rax
int v3; // ebx

v1 = *(_QWORD *)(a1 + 16);
if ( !v1 )
{
ft_putendl("exit");
exit(0);
}
if ( !*(_QWORD *)(v1 + 16) && (unsigned int)ft_verif_num_exit(*(_BYTE **)v1) != -1 )
{
v3 = ft_atoi(**(_QWORD **)(a1 + 16));
ft_putendl("exit");
exit(v3 % 256);
}
return ft_error_msg("exit: Expression Syntax", &unk_B9);
}

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

v1 = *(_QWORD *)(a1 + 16);
if ( !v1 )
{
ft_putendl("exit");
exit(0);
}
if ( !*(_QWORD *)(v1 + 16) && (unsigned int)func0(*(_BYTE **)v1) != -1 )
{
v3 = ft_atoi(**(_QWORD **)(a1 + 16));
ft_putendl("exit");
exit(v3 % 256);
}
return ft_error_msg("exit: Expression Syntax", &unk_B9);
}

original_code:
int ft_exit(t_p *p)
{
 int status;
 status = 0;
 if (!p->next)
 {
  ft_putendl("exit");
  exit(status);
 }
 else if (p->next->next
   || ((ft_verif_num_exit(p->next->tok)) == -1))
  return (ft_error_msg("exit: Expression Syntax", ""));
 else
 {
  status = ft_atoi(p->next->tok) % 256;
  ft_putendl("exit");
  exit(status);
 }
 return (0);
}

canonical_original_code:
int ft_exit(struct s_p *p)
{
 int status;
 status = 0;
 if (!p->next)
 {
  ft_putendl("exit");
  exit(status);
 }
 else if (p->next->next
   || ((ft_verif_num_exit(p->next->tok)) == -1))
  return (ft_error_msg("exit: Expression Syntax", ""));
 else
 {
  status = ft_atoi(p->next->tok) % 256;
  ft_putendl("exit");
  exit(status);
 }
 return (0);
}

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

variable_types: status int


decompiled_code:
__int64 __fastcall ft_toa_next(unsigned int a1, __int64 a2, unsigned int a3, _BYTE *a4)
{
unsigned int v4; // er15
__int64 v7; // rbp
__int64 v8; // r13

v4 = a3 + 1;
if ( (int)(a3 + 1) > 0 )
{
v7 = a2 + (int)v4;
v8 = a2 + (int)a3 - a3;
do
{
*(_BYTE *)(v7 - 1) = a4[a1 % (unsigned int)ft_strlenn(a4)];
a1 /= (unsigned int)ft_strlenn(a4);
--v7;
}
while ( v7 != v8 );
}
*(_BYTE *)(a2 + (int)v4) = 0;
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, __int64 a2, unsigned int a3, _BYTE *a4)
{
unsigned int v4; // er15
__int64 v7; // rbp
__int64 v8; // r13

v4 = a3 + 1;
if ( (int)(a3 + 1) > 0 )
{
v7 = a2 + (int)v4;
v8 = a2 + (int)a3 - a3;
do
{
*(_BYTE *)(v7 - 1) = a4[a1 % (unsigned int)func0(a4)];
a1 /= (unsigned int)func0(a4);
--v7;
}
while ( v7 != v8 );
}
*(_BYTE *)(a2 + (int)v4) = 0;
return a2;
}

original_code:
static char *ft_toa_next(unsigned int n, char *s, int i, char *base)
{
 int k;
 int j;
 k = 0;
 i++;
 j = i;
 while (i > k)
 {
  *(s + i - 1) = base[n % ft_strlenn(base)];
  n = n / ft_strlenn(base);
  i--;
 }
 *(s + j + k) = '\0';
 return (s);
}

variable_types:
n
unsigned int

variable_types:
s
char *

variable_types:
base
char *

variable_types: k int

variable_types: j int


decompiled_code:
__int64 __fastcall ft_toa(unsigned int a1, _BYTE *a2)
{
_BYTE *v2; // rax
__int64 v3; // r13
unsigned int v4; // ebx
unsigned int v5; // ebp
unsigned int v6; // ecx

v2 = (_BYTE *)gmalloc(120LL);
v3 = (__int64)v2;
if ( v2 )
{
v4 = a1;
v5 = 0;
if ( a1 )
{
while ( 1 )
{
v6 = ft_strlenn(a2);
if ( v6 >= v4 )
break;
++v5;
v4 /= v6;
}
v3 = ft_toa_next(a1, v3, v5, a2);
}
else
{
*v2 = 48;
v2[1] = 0;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, _BYTE *a2)
{
_BYTE *v2; // rax
__int64 v3; // r13
unsigned int v4; // ebx
unsigned int v5; // ebp
unsigned int v6; // ecx

v2 = (_BYTE *)gmalloc(120LL);
v3 = (__int64)v2;
if ( v2 )
{
v4 = a1;
v5 = 0;
if ( a1 )
{
while ( 1 )
{
v6 = func0(a2);
if ( v6 >= v4 )
break;
++v5;
v4 /= v6;
}
v3 = func1(a1, v3, v5, a2);
}
else
{
*v2 = 48;
v2[1] = 0;
}
}
return v3;
}

original_code:
char *ft_toa(unsigned int n, char *base)
{
 char *s;
 int i;
 unsigned int k;
 i = 0;
 k = n;
 if (!(s = (char *)gmalloc(sizeof(*s) * 120)))
  return (((void *)0));
 if (n == 0)
 {
  *s = '0';
  *(s + 1) = '\0';
  return (s);
 }
 while (k > ft_strlenn(base))
 {
  i++;
  k = k / ft_strlenn(base);
 }
 return (ft_toa_next(n, s, i++, base));
}

variable_types:
k
unsigned int


decompiled_code:
__int64 __fastcall ft_strlenn(_BYTE *a1)
{
__int64 result; // rax

if ( !*a1 )
return 0LL;
LODWORD(result) = 0;
do
result = (unsigned int)(result + 1);
while ( a1[(unsigned int)result] );
return result;
}

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

if ( !*a1 )
return 0LL;
LODWORD(result) = 0;
do
result = (unsigned int)(result + 1);
while ( a1[(unsigned int)result] );
return result;
}

original_code:
static unsigned int ft_strlenn(char *base)
{
 unsigned int i;
 i = 0;
 while (*(base + i))
  i++;
 return (i);
}

variable_types:
i
unsigned int

return_type: unsigned int


grealloc

decompiled_code:
__int64 __fastcall grealloc(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbx

v2 = gmalloc(a2);
v3 = v2;
if ( v2 )
{
v3 = ft_strcpy(v2, a1);
gfree(a1);
}
return v3;
}

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

v2 = gmalloc(a2);
v3 = v2;
if ( v2 )
{
v3 = ft_strcpy(v2, a1);
gfree(a1);
}
return v3;
}

original_code:
char *grealloc(char *old, size_t size)
{
 char *new;
 if (!(new = gmalloc(size)))
  return (((void *)0));
 new = ft_strcpy(new, old);
 gfree(old);
 return (new);
}

canonical_original_code:
char *grealloc(char *old, unsigned long size)
{
 char *new;
 if (!(new = gmalloc(size)))
  return (((void *)0));
 new = ft_strcpy(new, old);
 gfree(old);
 return (new);
}

variable_types:
old
char *

variable_types:
size
unsigned long

variable_types:
new
char *


decompiled_code:
__int64 __fastcall ft_create_the_line_of_cmd(_QWORD *a1)
{
__int64 v1; // rax
_QWORD *i; // rbx
__int64 v3; // rax

v1 = ft_strdup(*a1);
for ( i = (_QWORD *)a1[2]; i; i = (_QWORD *)i[2] )
{
v3 = c_calld("join", v1, &unk_E4);
v1 = c_calld("join", v3, *i);
}
return ft_strsplit(v1, 32LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 v1; // rax
_QWORD *i; // rbx
__int64 v3; // rax

v1 = ft_strdup(*a1);
for ( i = (_QWORD *)a1[2]; i; i = (_QWORD *)i[2] )
{
v3 = c_calld("join", v1, &unk_E4);
v1 = c_calld("join", v3, *i);
}
return ft_strsplit(v1, 32LL);
}

original_code:
char **ft_create_the_line_of_cmd(t_p *p)
{
 t_p *move;
 char *line_of_cmd;
 line_of_cmd = ft_strdup(p->tok);
 move = p->next;
 while (move)
 {
  line_of_cmd = c_calld("join", line_of_cmd, " ");
  line_of_cmd = c_calld("join", line_of_cmd, move->tok);
  move = move->next;
 }
 return (ft_strsplit(line_of_cmd, ' '));
}

canonical_original_code:
char **ft_create_the_line_of_cmd(struct s_p *p)
{
 struct s_p *move;
 char *line_of_cmd;
 line_of_cmd = ft_strdup(p->tok);
 move = p->next;
 while (move)
 {
  line_of_cmd = c_calld("join", line_of_cmd, " ");
  line_of_cmd = c_calld("join", line_of_cmd, move->tok);
  move = move->next;
 }
 return (ft_strsplit(line_of_cmd, ' '));
}

return_type: char **

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


decompiled_code:
__int64 __fastcall ft_exe_the_cmd(_QWORD *a1, const char *a2, char *const *a3)
{
char *const *v4; // r12
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-2Ch] BYREF

v4 = (char *const *)ft_create_the_line_of_cmd(a1);
*(_DWORD *)ft_value() = 0;
LODWORD(stat_loc.__uptr) = fork();
if ( SLODWORD(stat_loc.__uptr) <= 0 )
{
execve(a2, v4, a3);
ft_putstr_fd(*a1, 2LL);
ft_putendl_fd(": Command not found", 2LL);
*(_DWORD *)ft_value() = -1;
exit(1);
}
wait((__WAIT_STATUS)&stat_loc);
return *(unsigned int *)ft_value();
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, const char *a2, char *const *a3)
{
char *const *v4; // r12
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-2Ch] BYREF

v4 = (char *const *)func0(a1);
*(_DWORD *)ft_value() = 0;
LODWORD(stat_loc.__uptr) = fork();
if ( SLODWORD(stat_loc.__uptr) <= 0 )
{
execve(a2, v4, a3);
ft_putstr_fd(*a1, 2LL);
ft_putendl_fd(": Command not found", 2LL);
*(_DWORD *)ft_value() = -1;
exit(1);
}
wait((__WAIT_STATUS)&stat_loc);
return *(unsigned int *)ft_value();
}

original_code:
int ft_exe_the_cmd(t_p *p, char *path, char **env)
{
 char **line_of_cmd;
 pid_t father;
 line_of_cmd = ft_create_the_line_of_cmd(p);
 *ft_value() = 0;
 father = fork();
 if (father > 0)
 {
  wait(&father);
  return (*ft_value());
 }
 else
 {
  execve(path, line_of_cmd, env);
  ft_putstr_fd(p->tok, 2);
  ft_putendl_fd(": Command not found", 2);
  *ft_value() = -1;
  exit(1);
 }
 return (*ft_value());
}

canonical_original_code:
int ft_exe_the_cmd(struct s_p *p, char *path, char **env)
{
 char **line_of_cmd;
 int father;
 line_of_cmd = ft_create_the_line_of_cmd(p);
 *ft_value() = 0;
 father = fork();
 if (father > 0)
 {
  wait(&father);
  return (*ft_value());
 }
 else
 {
  execve(path, line_of_cmd, env);
  ft_putstr_fd(p->tok, 2);
  ft_putendl_fd(": Command not found", 2);
  *ft_value() = -1;
  exit(1);
 }
 return (*ft_value());
}

variable_types:
path
char *

variable_types: father int


decompiled_code:
__int64 __fastcall ft_verification(__int64 a1, int a2)
{
char v2; // al
char *v3; // rdx

v2 = *(_BYTE *)(a1 + a2);
if ( !v2 )
return 1LL;
v3 = (char *)(a1 + a2 + 1);
do
{
if ( (unsigned __int8)(v2 - 9) > 1u && v2 != 32 )
return 0LL;
v2 = *v3++;
}
while ( v2 );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
char v2; // al
char *v3; // rdx

v2 = *(_BYTE *)(a1 + a2);
if ( !v2 )
return 1LL;
v3 = (char *)(a1 + a2 + 1);
do
{
if ( (unsigned __int8)(v2 - 9) > 1u && v2 != 32 )
return 0LL;
v2 = *v3++;
}
while ( v2 );
return 1LL;
}

original_code:
static int ft_verification(char const *s, int i)
{
 while (*(s + i))
 {
  if (*(s + i) != ' ' && *(s + i) != '\n' && *(s + i) != '\t')
   return (0);
  i++;
 }
 return (1);
}

canonical_original_code:
static int ft_verification(char *s, int i)
{
 while (*(s + i))
 {
  if (*(s + i) != ' ' && *(s + i) != '\n' && *(s + i) != '\t')
   return (0);
  i++;
 }
 return (1);
}

variable_types: i int


decompiled_code:
__int64 __fastcall ft_save_new_piece(void *a1, int *a2)
{
__int64 v2; // rbx
void *v3; // rax
__int64 v4; // rbx
__int64 result; // rax
_QWORD *v6; // r12
void *ptr; // [rsp+8h] [rbp-20h] BYREF

ptr = a1;
v2 = ft_strsplit(a1, 32LL);
*a2 = ft_atoi(*(_QWORD *)(v2 + 8));
a2[1] = ft_atoi(*(_QWORD *)(v2 + 16));
v3 = malloc(8LL * *a2);
*((_QWORD *)a2 + 1) = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
free(ptr);
v4 = 0LL;
result = 0LL;
if ( *a2 > 0 )
{
while ( 1 )
{
result = get_next_line(0LL, &ptr);
if ( !(_DWORD)result )
break;
v6 = (_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v4);
*v6 = ft_strdup(ptr);
free(ptr);
if ( *a2 <= (int)++v4 )
return 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *a1, int *a2)
{
__int64 v2; // rbx
void *v3; // rax
__int64 v4; // rbx
__int64 result; // rax
_QWORD *v6; // r12
void *ptr; // [rsp+8h] [rbp-20h] BYREF

ptr = a1;
v2 = ft_strsplit(a1, 32LL);
*a2 = ft_atoi(*(_QWORD *)(v2 + 8));
a2[1] = ft_atoi(*(_QWORD *)(v2 + 16));
v3 = malloc(8LL * *a2);
*((_QWORD *)a2 + 1) = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
free(ptr);
v4 = 0LL;
result = 0LL;
if ( *a2 > 0 )
{
while ( 1 )
{
result = get_next_line(0LL, &ptr);
if ( !(_DWORD)result )
break;
v6 = (_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v4);
*v6 = ft_strdup(ptr);
free(ptr);
if ( *a2 <= (int)++v4 )
return 0LL;
}
}
return result;
}

original_code:
int ft_save_new_piece(char *line, t_p *p)
{
 int i;
 char **tmp;
 tmp = ft_strsplit(line, ' ');
 p->li = ft_atoi(tmp[1]);
 p->co = ft_atoi(tmp[2]);
 if (!(p->fig = (char **)malloc(sizeof(char *) * (p->li))))
  return (-1);
 free((void *)line);
 i = 0;
 while (i < p->li && get_next_line(0, &line))
 {
  p->fig[i] = ft_strdup(line);
  free((void *)line);
  ++i;
 }
 return (0);
}

canonical_original_code:
int ft_save_new_piece(char *line, struct s_p *p)
{
 int i;
 char **tmp;
 tmp = ft_strsplit(line, ' ');
 p->li = ft_atoi(tmp[1]);
 p->co = ft_atoi(tmp[2]);
 if (!(p->fig = (char **)malloc(sizeof(char *) * (p->li))))
  return (-1);
 free((void *)line);
 i = 0;
 while (i < p->li && get_next_line(0, &line))
 {
  p->fig[i] = ft_strdup(line);
  free((void *)line);
  ++i;
 }
 return (0);
}

variable_types:
line
char *

variable_types: struct s_p { int li; int co; char **fig; } *

variable_types:
tmp
char **


decompiled_code:
__int64 __fastcall ft_delete_quotes_and_spaces(__int64 *a1, unsigned int a2)
{
unsigned int v2; // ebp
__int64 v3; // rdx
__int64 v5; // rax
int v6; // eax
__int64 v7; // rax
__int64 v8[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = a2;
v3 = *a1;
v8[0] = *a1;
if ( !a2 )
{
if ( !v3 )
return v2;
while ( 1 )
{
v6 = *(_DWORD *)(v3 + 8);
if ( v6 == 14 )
goto LABEL_10;
if ( v6 == 2 )
break;
if ( v6 == 3 )
{
v7 = *(_QWORD *)(v3 + 16);
if ( v7 && *(_DWORD *)(v7 + 8) == 3 )
goto LABEL_19;
LABEL_10:
ft_delete_plist_elem(a1, v8);
goto LABEL_11;
}
if ( (unsigned int)(v6 - 2) <= 1 )
goto LABEL_19;
v8[0] = *(_QWORD *)(v3 + 16);
LABEL_11:
v3 = v8[0];
if ( !v8[0] )
return v2;
}
v5 = *(_QWORD *)(v3 + 16);
if ( v5 && *(_DWORD *)(v5 + 8) == 2 )
{
LABEL_19:
ft_is_empty_string(a1, v8);
goto LABEL_11;
}
goto LABEL_10;
}
ft_putstr_fd("Unmatched ", 2LL);
if ( a2 == 1 )
ft_putendl_fd("'.", 2LL);
else
ft_putendl_fd("\".", 2LL);
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, unsigned int a2)
{
unsigned int v2; // ebp
__int64 v3; // rdx
__int64 v5; // rax
int v6; // eax
__int64 v7; // rax
__int64 v8[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = a2;
v3 = *a1;
v8[0] = *a1;
if ( !a2 )
{
if ( !v3 )
return v2;
while ( 1 )
{
v6 = *(_DWORD *)(v3 + 8);
if ( v6 == 14 )
goto LABEL_10;
if ( v6 == 2 )
break;
if ( v6 == 3 )
{
v7 = *(_QWORD *)(v3 + 16);
if ( v7 && *(_DWORD *)(v7 + 8) == 3 )
goto LABEL_19;
LABEL_10:
func1(a1, v8);
goto LABEL_11;
}
if ( (unsigned int)(v6 - 2) <= 1 )
goto LABEL_19;
v8[0] = *(_QWORD *)(v3 + 16);
LABEL_11:
v3 = v8[0];
if ( !v8[0] )
return v2;
}
v5 = *(_QWORD *)(v3 + 16);
if ( v5 && *(_DWORD *)(v5 + 8) == 2 )
{
LABEL_19:
ft_is_empty_string(a1, v8);
goto LABEL_11;
}
goto LABEL_10;
}
ft_putstr_fd("Unmatched ", 2LL);
if ( a2 == 1 )
ft_putendl_fd("'.", 2LL);
else
ft_putendl_fd("\".", 2LL);
return (unsigned int)-1;
}

original_code:
int ft_delete_quotes_and_spaces(t_p **p, int ind)
{
 t_p *m;
 m = *p;
 if (ind)
 {
  ft_putstr_fd("Unmatched ", 2);
  if (ind == 1)
   ft_putendl_fd("\'.", 2);
  else
   ft_putendl_fd("\".", 2);
  return (-1);
 }
 while (m)
 {
  if (m->type == 14
   || (m->type == 2 && (!m->next || m->next->type != 2))
   || (m->type == 3 && (!m->next || m->next->type != 3)))
   ft_delete_plist_elem(p, &m);
  else if (m->type == 2 || m->type == 3)
   ft_is_empty_string(p, &m);
  else
   m = m->next;
 }
 return (0);
}

canonical_original_code:
int ft_delete_quotes_and_spaces(struct s_p **p, int ind)
{
 struct s_p *m;
 m = *p;
 if (ind)
 {
  ft_putstr_fd("Unmatched ", 2);
  if (ind == 1)
   ft_putendl_fd("\'.", 2);
  else
   ft_putendl_fd("\".", 2);
  return (-1);
 }
 while (m)
 {
  if (m->type == 14
   || (m->type == 2 && (!m->next || m->next->type != 2))
   || (m->type == 3 && (!m->next || m->next->type != 3)))
   ft_delete_plist_elem(p, &m);
  else if (m->type == 2 || m->type == 3)
   ft_is_empty_string(p, &m);
  else
   m = m->next;
 }
 return (0);
}

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

variable_types: ind int


decompiled_code:
__int64 __fastcall ft_treat_a_cylinder(int *a1, __int64 a2, __int64 a3, double *a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12)
{
double *v14; // r14
double v15; // xmm0_8
double v16; // xmm4_8
double v17; // xmm5_8
double v18; // xmm0_8

v14 = a4 + 6;
ft_mult_vect_by_nb(a4 + 6, a4[14]);
v15 = ft_vect_sum(v14);
ft_init_normal((__int64)(a4 + 9), (__int64)a1, v15, a6, a7, a8, v16, v17, a11, a12, a4[6], a4[7], a4[8]);
ft_normalize_vect(a4 + 9);
v18 = ft_hit_light(a4, a3);
ft_init_color(
a2,
(unsigned int)(int)(v18 * (double)a1[8]),
(unsigned int)(int)((double)a1[9] * v18),
(unsigned int)(int)((double)a1[10] * v18));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1, __int64 a2, __int64 a3, double *a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12)
{
double *v14; // r14
double v15; // xmm0_8
double v16; // xmm4_8
double v17; // xmm5_8
double v18; // xmm0_8

v14 = a4 + 6;
ft_mult_vect_by_nb(a4 + 6, a4[14]);
v15 = ft_vect_sum(v14);
func0((__int64)(a4 + 9), (__int64)a1, v15, a6, a7, a8, v16, v17, a11, a12, a4[6], a4[7], a4[8]);
ft_normalize_vect(a4 + 9);
v18 = ft_hit_light(a4, a3);
ft_init_color(
a2,
(unsigned int)(int)(v18 * (double)a1[8]),
(unsigned int)(int)((double)a1[9] * v18),
(unsigned int)(int)((double)a1[10] * v18));
return 0LL;
}

original_code:
int ft_treat_a_cylinder(void *data, t_c *color, t_obj *obj, t_r *r)
{
 t_cyl *cyl;
 double mult;
 cyl = (t_cyl *)data;
 ft_mult_vect_by_nb(&r->p_hit, r->d_w, r->tnear);
 ft_vect_sum(&r->p_hit, r->p_hit, r->o_w);
 ft_init_normal(&r->n_hit, r->p_hit, cyl);
 ft_normalize_vect(&r->n_hit);
 mult = ft_hit_light(r, obj);
 ft_init_color(color, cyl->sf.b * mult, cyl->sf.g * mult, cyl->sf.r * mult);
 return (0);
}

canonical_original_code:
int ft_treat_a_cylinder(void *data, struct s_c *color, struct s_obj *obj, struct s_r *r)
{
 struct s_cyl *cyl;
 double mult;
 cyl = (struct s_cyl *)data;
 ft_mult_vect_by_nb(&r->p_hit, r->d_w, r->tnear);
 ft_vect_sum(&r->p_hit, r->p_hit, r->o_w);
 ft_init_normal(&r->n_hit, r->p_hit, cyl);
 ft_normalize_vect(&r->n_hit);
 mult = ft_hit_light(r, obj);
 ft_init_color(color, cyl->sf.b * mult, cyl->sf.g * mult, cyl->sf.r * mult);
 return (0);
}

variable_types:
data
void *

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

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: struct s_cyl { struct s_v { double x; double y; double z; } c; double r; struct s_c { int b; int g; int r; } sf; char flag; } *

variable_types: mult double

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

user_defined_types: struct s_cyl { struct s_v c; double r; struct s_c sf; char flag; }

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


decompiled_code:
__int64 __fastcall ft_init_normal(__int64 a1, __int64 a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13)
{
__int64 result; // rax

result = *(unsigned __int8 *)(a2 + 44);
switch ( (_BYTE)result )
{
case 'x':
*(_QWORD *)a1 = 0LL;
*(double *)(a1 + 8) = a12 - *(double *)(a2 + 8);
*(double *)(a1 + 16) = a13 - *(double *)(a2 + 16);
break;
case 'y':
*(_QWORD *)(a1 + 8) = 0LL;
*(double *)a1 = a11 - *(double *)a2;
*(double *)(a1 + 16) = a13 - *(double *)(a2 + 16);
break;
case 'z':
*(_QWORD *)(a1 + 16) = 0LL;
*(double *)(a1 + 8) = a12 - *(double *)(a2 + 8);
*(double *)a1 = a11 - *(double *)a2;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13)
{
__int64 result; // rax

result = *(unsigned __int8 *)(a2 + 44);
switch ( (_BYTE)result )
{
case 'x':
*(_QWORD *)a1 = 0LL;
*(double *)(a1 + 8) = a12 - *(double *)(a2 + 8);
*(double *)(a1 + 16) = a13 - *(double *)(a2 + 16);
break;
case 'y':
*(_QWORD *)(a1 + 8) = 0LL;
*(double *)a1 = a11 - *(double *)a2;
*(double *)(a1 + 16) = a13 - *(double *)(a2 + 16);
break;
case 'z':
*(_QWORD *)(a1 + 16) = 0LL;
*(double *)(a1 + 8) = a12 - *(double *)(a2 + 8);
*(double *)a1 = a11 - *(double *)a2;
break;
}
return result;
}

original_code:
static void ft_init_normal(t_v *n_hit, t_v p_hit, t_cyl *cyl)
{
 if (cyl->flag == 'x')
 {
  n_hit->x = 0;
  n_hit->y = p_hit.y - cyl->c.y;
  n_hit->z = p_hit.z - cyl->c.z;
 }
 else if (cyl->flag == 'y')
 {
  n_hit->y = 0;
  n_hit->x = p_hit.x - cyl->c.x;
  n_hit->z = p_hit.z - cyl->c.z;
 }
 else if (cyl->flag == 'z')
 {
  n_hit->z = 0;
  n_hit->y = p_hit.y - cyl->c.y;
  n_hit->x = p_hit.x - cyl->c.x;
 }
}

canonical_original_code:
static void ft_init_normal(struct s_v *n_hit, struct s_v p_hit, struct s_cyl *cyl)
{
 if (cyl->flag == 'x')
 {
  n_hit->x = 0;
  n_hit->y = p_hit.y - cyl->c.y;
  n_hit->z = p_hit.z - cyl->c.z;
 }
 else if (cyl->flag == 'y')
 {
  n_hit->y = 0;
  n_hit->x = p_hit.x - cyl->c.x;
  n_hit->z = p_hit.z - cyl->c.z;
 }
 else if (cyl->flag == 'z')
 {
  n_hit->z = 0;
  n_hit->y = p_hit.y - cyl->c.y;
  n_hit->x = p_hit.x - cyl->c.x;
 }
}

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

variable_types: struct s_cyl { struct s_v c; double r; struct s_c { int b; int g; int r; } sf; char flag; } *

return_type: void


decompiled_code:
__int64 __fastcall ft_echo(__int64 a1)
{
_QWORD *v1; // rbx
int v2; // er12
__int64 result; // rax
int v4; // ebp

v1 = *(_QWORD **)(a1 + 16);
v2 = 0;
if ( !v1 )
return write(1, &unk_8B, 1uLL);
while ( 1 )
{
result = ft_strcmp(*v1, &unk_86);
if ( (_DWORD)result )
break;
++v2;
v1 = (_QWORD *)v1[2];
if ( !v1 )
goto LABEL_4;
}
v4 = 0;
while ( 1 )
{
result = ft_putstr(*v1);
++v4;
v1 = (_QWORD *)v1[2];
if ( !v1 )
break;
if ( v4 )
write(1, &unk_89, 1uLL);
}
LABEL_4:
if ( !v2 )
return write(1, &unk_8B, 1uLL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
_QWORD *v1; // rbx
int v2; // er12
__int64 result; // rax
int v4; // ebp

v1 = *(_QWORD **)(a1 + 16);
v2 = 0;
if ( !v1 )
return write(1, &unk_8B, 1uLL);
while ( 1 )
{
result = ft_strcmp(*v1, &unk_86);
if ( (_DWORD)result )
break;
++v2;
v1 = (_QWORD *)v1[2];
if ( !v1 )
goto LABEL_4;
}
v4 = 0;
while ( 1 )
{
result = ft_putstr(*v1);
++v4;
v1 = (_QWORD *)v1[2];
if ( !v1 )
break;
if ( v4 )
write(1, &unk_89, 1uLL);
}
LABEL_4:
if ( !v2 )
return write(1, &unk_8B, 1uLL);
return result;
}

original_code:
void ft_echo(t_p *p)
{
 t_p *move;
 int space;
 int back_to_line;
 space = 0;
 back_to_line = 0;
 move = p->next;
 if (move)
 {
  while (move && !ft_strcmp(move->tok, "-n"))
  {
   ++back_to_line;
   move = move->next;
  }
 }
 while (move)
 {
  if (space)
   write(1, " ", 1);
  ft_putstr(move->tok);
  ++space;
  move = move->next;
 }
 if (!back_to_line)
  write(1, "\n", 1);
}

canonical_original_code:
void ft_echo(struct s_p *p)
{
 struct s_p *move;
 int space;
 int back_to_line;
 space = 0;
 back_to_line = 0;
 move = p->next;
 if (move)
 {
  while (move && !ft_strcmp(move->tok, "-n"))
  {
   ++back_to_line;
   move = move->next;
  }
 }
 while (move)
 {
  if (space)
   write(1, " ", 1);
  ft_putstr(move->tok);
  ++space;
  move = move->next;
 }
 if (!back_to_line)
  write(1, "\n", 1);
}

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

variable_types: space int


original_code:
int ft_find_nb_for_diag_up_right(t_all a, t_s s)
{
 t_bound b;
 int max;
 int nb;
 max = 0;
 nb = 1;
 ft_find_start_diag_up_right(a, &b);
 while (b.start_li - a.i >= 0)
 {
  ft_find_end_diag_up_right(a, &b);
  if (b.start_li - b.end_li < 3)
   nb = 1;
  else
   nb = ft_space_for_diag_ur(a, b, s);
  if (nb > max)
   max = nb;
  --(b.start_li);
  ++(b.start_co);
 }
 return (max);
}

canonical_original_code:
int ft_find_nb_for_diag_up_right(struct s_all a, struct s_s s)
{
 struct s_bound b;
 int max;
 int nb;
 max = 0;
 nb = 1;
 ft_find_start_diag_up_right(a, &b);
 while (b.start_li - a.i >= 0)
 {
  ft_find_end_diag_up_right(a, &b);
  if (b.start_li - b.end_li < 3)
   nb = 1;
  else
   nb = ft_space_for_diag_ur(a, b, s);
  if (nb > max)
   max = nb;
  --(b.start_li);
  ++(b.start_co);
 }
 return (max);
}

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

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

variable_types: struct s_bound { int start_li; int start_co; int end_li; int end_co; }

variable_types: max int

variable_types: nb int


original_code:
int ft_find_nb_for_diag_up_left(t_all a, t_s s)
{
 t_bound b;
 int max;
 int nb;
 max = 0;
 nb = 1;
 ft_find_start_diag_up_left(a, &b);
 while (a.i - b.start_li >= 0)
 {
  ft_find_end_diag_up_left(a, &b);
  if (b.end_li - b.start_li < 3)
   nb = 1;
  else
   nb = ft_space_for_diag_ul4(a, b, s);
  if (nb > max)
   max = nb;
  ++(b.start_li);
  ++(b.start_co);
 }
 return (max);
}

canonical_original_code:
int ft_find_nb_for_diag_up_left(struct s_all a, struct s_s s)
{
 struct s_bound b;
 int max;
 int nb;
 max = 0;
 nb = 1;
 ft_find_start_diag_up_left(a, &b);
 while (a.i - b.start_li >= 0)
 {
  ft_find_end_diag_up_left(a, &b);
  if (b.end_li - b.start_li < 3)
   nb = 1;
  else
   nb = ft_space_for_diag_ul4(a, b, s);
  if (nb > max)
   max = nb;
  ++(b.start_li);
  ++(b.start_co);
 }
 return (max);
}

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

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

user_defined_types: struct s_bound { int start_li; int start_co; int end_li; int end_co; }


original_code:
double ft_hit_light(t_r *r, t_obj *obj)
{
 int i;
 t_r r_l;
 t_sph *light;
 i = 0;
 while (i < obj->nb[1] && (((t_sph ***)obj->type)[1][i])->em.b == 0)
  ++i;
 if (i == obj->nb[1])
  return (1);
 light = ((t_sph ***)obj->type)[1][i];
 ft_init_vect(&r_l.o_w, light->c.x, light->c.y, light->c.z);
 ft_vect_difference(&r_l.d_w, r->p_hit, r_l.o_w);
 ft_normalize_vect(&r_l.d_w);
 r_l.hit_i = r->hit_i;
 r_l.hit_j = r->hit_j;
 return (ft_hit_or_not(&r_l, obj, i, &r->n_hit));
}

canonical_original_code:
double ft_hit_light(struct s_r *r, struct s_obj *obj)
{
 int i;
 struct s_r r_l;
 struct s_sph *light;
 i = 0;
 while (i < obj->nb[1] && (((struct s_sph ***)obj->type)[1][i])->em.b == 0)
  ++i;
 if (i == obj->nb[1])
  return (1);
 light = ((struct s_sph ***)obj->type)[1][i];
 ft_init_vect(&r_l.o_w, light->c.x, light->c.y, light->c.z);
 ft_vect_difference(&r_l.d_w, r->p_hit, r_l.o_w);
 ft_normalize_vect(&r_l.d_w);
 r_l.hit_i = r->hit_i;
 r_l.hit_j = r->hit_j;
 return (ft_hit_or_not(&r_l, obj, i, &r->n_hit));
}

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

variable_types: i int

variable_types: struct s_sph { struct s_v { double x; double y; double z; } c; double r; struct s_c { int b; int g; int r; } sf; struct s_c em; double trsp; double refl; double ior; } *

return_type: double

user_defined_types: struct s_sph { struct s_v c; double r; struct s_c sf; struct s_c em; double trsp; double refl; double ior; }


original_code:
int ft_intersect_a_cone(t_r *r, void *data)
{
 t_con *con;
 t_r new_r;
 t_v coeff;
 con = (t_con *)data;
 new_r = *r;
 ft_vect_difference(&new_r.o_w, r->o_w, con->c);
 ft_find_coeff(&new_r, &coeff, con);
 if (ft_nearest_solution(coeff.x, coeff.y, coeff.z, &new_r) == -1)
  return (-1);
 if (new_r.t1 < 0)
  return (-1);
 if (new_r.t0 < 0)
  new_r.t0 = new_r.t1;
 r->t0 = new_r.t0;
 r->t1 = new_r.t1;
 return (0);
}

canonical_original_code:
int ft_intersect_a_cone(struct s_r *r, void *data)
{
 struct s_con *con;
 struct s_r new_r;
 struct s_v coeff;
 con = (struct s_con *)data;
 new_r = *r;
 ft_vect_difference(&new_r.o_w, r->o_w, con->c);
 ft_find_coeff(&new_r, &coeff, con);
 if (ft_nearest_solution(coeff.x, coeff.y, coeff.z, &new_r) == -1)
  return (-1);
 if (new_r.t1 < 0)
  return (-1);
 if (new_r.t0 < 0)
  new_r.t0 = new_r.t1;
 r->t0 = new_r.t0;
 r->t1 = new_r.t1;
 return (0);
}

variable_types:
data
void *

variable_types: struct s_con { struct s_v { double x; double y; double z; } c; struct s_c { int b; int g; int r; } sf; char flag; double cst; } *

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

user_defined_types: struct s_con { struct s_v c; struct s_c sf; char flag; double cst; }


original_code:
static void ft_find_coeff(t_r *r, t_v *c, t_con *con)
{
 if (con->flag == 'x')
  ft_init_vect(c, r->d_w.y * r->d_w.y + r->d_w.z * r->d_w.z - con->cst
     * r->d_w.x * r->d_w.x,
     2 * (r->o_w.y * r->d_w.y + r->o_w.z * r->d_w.z - con->cst
      * r->o_w.x * r->d_w.x),
     r->o_w.y * r->o_w.y + r->o_w.z * r->o_w.z - con->cst
     * r->o_w.x * r->o_w.x);
 else if (con->flag == 'y')
  ft_init_vect(c, r->d_w.x * r->d_w.x + r->d_w.z * r->d_w.z - con->cst
     * r->d_w.y * r->d_w.y,
     2 * (r->o_w.x * r->d_w.x + r->o_w.z * r->d_w.z - con->cst
      * r->o_w.y * r->d_w.y),
     r->o_w.x * r->o_w.x + r->o_w.z * r->o_w.z - con->cst
     * r->o_w.y * r->o_w.y);
 else if (con->flag == 'z')
  ft_init_vect(c, r->d_w.y * r->d_w.y + r->d_w.x * r->d_w.x - con->cst
     * r->d_w.z * r->d_w.z,
     2 * (r->o_w.y * r->d_w.y + r->o_w.x * r->d_w.x - con->cst
      * r->o_w.z * r->d_w.z),
     r->o_w.y * r->o_w.y + r->o_w.x * r->o_w.x - con->cst
     * r->o_w.z * r->o_w.z);
}

canonical_original_code:
static void ft_find_coeff(struct s_r *r, struct s_v *c, struct s_con *con)
{
 if (con->flag == 'x')
  ft_init_vect(c, r->d_w.y * r->d_w.y + r->d_w.z * r->d_w.z - con->cst
     * r->d_w.x * r->d_w.x,
     2 * (r->o_w.y * r->d_w.y + r->o_w.z * r->d_w.z - con->cst
      * r->o_w.x * r->d_w.x),
     r->o_w.y * r->o_w.y + r->o_w.z * r->o_w.z - con->cst
     * r->o_w.x * r->o_w.x);
 else if (con->flag == 'y')
  ft_init_vect(c, r->d_w.x * r->d_w.x + r->d_w.z * r->d_w.z - con->cst
     * r->d_w.y * r->d_w.y,
     2 * (r->o_w.x * r->d_w.x + r->o_w.z * r->d_w.z - con->cst
      * r->o_w.y * r->d_w.y),
     r->o_w.x * r->o_w.x + r->o_w.z * r->o_w.z - con->cst
     * r->o_w.y * r->o_w.y);
 else if (con->flag == 'z')
  ft_init_vect(c, r->d_w.y * r->d_w.y + r->d_w.x * r->d_w.x - con->cst
     * r->d_w.z * r->d_w.z,
     2 * (r->o_w.y * r->d_w.y + r->o_w.x * r->d_w.x - con->cst
      * r->o_w.z * r->d_w.z),
     r->o_w.y * r->o_w.y + r->o_w.x * r->o_w.x - con->cst
     * r->o_w.z * r->o_w.z);
}

variable_types:
c
struct s_v *

variable_types: struct s_con { struct s_v c; struct s_c sf; char flag; double cst; } *

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


decompiled_code:
unsigned __int64 __fastcall ft_strlcat(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v4; // rbp
__int64 v5; // rbp
__int64 v6; // rax

if ( ((__int64 (*)(void))ft_strlen)() >= a3 )
return ft_strlen(a2) + a3;
v4 = ft_strlen(a1);
v5 = ft_strlen(a2) + v4;
v6 = ft_strlen(a1);
ft_strncat(a1, a2, a3 - 1 - v6);
return v5;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, __int64 a2, unsigned __int64 a3)
{
__int64 v4; // rbp
__int64 v5; // rbp
__int64 v6; // rax

if ( ((__int64 (*)(void))ft_strlen)() >= a3 )
return ft_strlen(a2) + a3;
v4 = ft_strlen(a1);
v5 = ft_strlen(a2) + v4;
v6 = ft_strlen(a1);
ft_strncat(a1, a2, a3 - 1 - v6);
return v5;
}

original_code:
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
 size_t i;
 if (size > ft_strlen(dst))
 {
  i = ft_strlen(dst) + ft_strlen(src);
  ft_strncat(dst, src, (size - ft_strlen(dst) - 1));
 }
 else
  i = size + ft_strlen(src);
 return (i);
}

canonical_original_code:
unsigned long ft_strlcat(char *dst, char *src, unsigned long size)
{
 unsigned long i;
 if (size > ft_strlen(dst))
 {
  i = ft_strlen(dst) + ft_strlen(src);
  ft_strncat(dst, src, (size - ft_strlen(dst) - 1));
 }
 else
  i = size + ft_strlen(src);
 return (i);
}

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
size
unsigned long

variable_types:
i
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall ft_find_nb_for_column(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, int a10, int a11, __int16 a12)
{
int v12; // esi
__int64 v13; // rax
unsigned int v14; // ecx
char v15; // dl

v12 = HIDWORD(a9) + 3;
if ( HIDWORD(a9) + 3 >= SHIDWORD(a8) )
v12 = HIDWORD(a8) - 1;
if ( v12 < SHIDWORD(a9) )
return 1;
v13 = SHIDWORD(a9);
v14 = 1;
do
{
v15 = *(_BYTE *)(*(_QWORD *)(a7 + 8LL * (int)a9) + v13);
if ( v15 == HIBYTE(a12) )
break;
v14 += v15 == (char)a12;
++v13;
}
while ( v12 >= (int)v13 );
return v14;
}

original_code:
int ft_find_nb_for_column(t_all a, t_s s)
{
 int end;
 int k;
 int nb;
 nb = 1;
 end = (a.j + 3 < a.co ? a.j + 3 : a.co - 1);
 k = a.j;
 while (k <= end)
 {
  if (a.grid[a.i][k] == s.symb2)
   break ;
  if (a.grid[a.i][k] == s.symb1)
   ++nb;
  ++k;
 }
 return (nb);
}

canonical_original_code:
int ft_find_nb_for_column(struct s_all a, struct s_s s)
{
 int end;
 int k;
 int nb;
 nb = 1;
 end = (a.j + 3 < a.co ? a.j + 3 : a.co - 1);
 k = a.j;
 while (k <= end)
 {
  if (a.grid[a.i][k] == s.symb2)
   break ;
  if (a.grid[a.i][k] == s.symb1)
   ++nb;
  ++k;
 }
 return (nb);
}

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

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

variable_types: end int

variable_types: k int


original_code:
void *ft_memset(void *b, int c, size_t len)
{
 unsigned char *d;
 d = (unsigned char *)b;
 while (len--)
  *(d + len) = (unsigned char)c;
 return (b);
}

canonical_original_code:
void *ft_memset(void *b, int c, unsigned long len)
{
 unsigned char *d;
 d = (unsigned char *)b;
 while (len--)
  *(d + len) = (unsigned char)c;
 return (b);
}

variable_types:
b
void *

variable_types: c int

variable_types:
len
unsigned long

variable_types:
d
unsigned char *

return_type: void *


decompiled_code:
__int64 __fastcall ft_put_base(unsigned int a1, _BYTE *a2)
{
unsigned int v2; // eax
unsigned int v4; // eax

v2 = ft_strlenn(a2);
if ( v2 > a1 )
return ft_putchar((unsigned int)(char)a2[a1]);
ft_put_base(a1 / v2, a2, a1 % v2);
v4 = ft_strlenn(a2);
return ft_putchar((unsigned int)(char)a2[a1 % v4]);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, _BYTE *a2)
{
unsigned int v2; // eax
unsigned int v4; // eax

v2 = func0(a2);
if ( v2 > a1 )
return ft_putchar((unsigned int)(char)a2[a1]);
func1(a1 / v2, a2, a1 % v2);
v4 = func0(a2);
return ft_putchar((unsigned int)(char)a2[a1 % v4]);
}

original_code:
void ft_put_base(unsigned int n, char *base)
{
 if (n < ft_strlenn(base))
  ft_putchar(base[n]);
 else
 {
  ft_put_base(n / ft_strlenn(base), base);
  ft_putchar(base[n % ft_strlenn(base)]);
 }
}

variable_types:
n
unsigned int

variable_types:
base
char *


original_code:
unsigned int ft_strlenn(char *base)
{
 unsigned int i;
 i = 0;
 while (*(base + i))
  i++;
 return (i);
}

variable_types:
i
unsigned int


original_code:
int ft_find_nb_for_row(t_all a, t_s s)
{
 int start;
 int end;
 int max;
 int nb;
 max = 0;
 nb = 1;
 start = (a.i - 3 < 0 ? 0 : a.i - 3);
 while (a.i - start >= 0)
 {
  end = (start + 3 < a.li ? start + 3 : a.li - 1);
  if (end - start < 3)
   nb = 1;
  else
   nb = ft_space_for_row4(a, start, end, s);
  if (nb > max)
   max = nb;
  ++start;
 }
 return (max);
}

canonical_original_code:
int ft_find_nb_for_row(struct s_all a, struct s_s s)
{
 int start;
 int end;
 int max;
 int nb;
 max = 0;
 nb = 1;
 start = (a.i - 3 < 0 ? 0 : a.i - 3);
 while (a.i - start >= 0)
 {
  end = (start + 3 < a.li ? start + 3 : a.li - 1);
  if (end - start < 3)
   nb = 1;
  else
   nb = ft_space_for_row4(a, start, end, s);
  if (nb > max)
   max = nb;
  ++start;
 }
 return (max);
}

variable_types: start int

variable_types: max int

variable_types: nb int


gclean

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

v2 = *a1;
while ( v2 )
{
free(*(void **)v2);
v3 = (void *)v2;
v2 = *(_QWORD *)(v2 + 8);
free(v3);
}
*a1 = 0LL;
}

original_code:
void gclean(t_list **list)
{
 t_list *first;
 t_list *tmp;
 first = *list;
 while (first)
 {
  tmp = first;
  free(first->content);
  first = first->next;
  free((void *)tmp);
 }
 *list = ((void *)0);
}

canonical_original_code:
void gclean(struct s_list **list)
{
 struct s_list *first;
 struct s_list *tmp;
 first = *list;
 while (first)
 {
  tmp = first;
  free(first->content);
  first = first->next;
  free((void *)tmp);
 }
 *list = ((void *)0);
}

variable_types: struct s_list { void *content; struct s_list *next; } **


decompiled_code:
__int64 __fastcall ft_in_string(char *a1, char a2)
{
char v2; // al

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( a2 != v2 )
{
v2 = *++a1;
if ( !*a1 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, char a2)
{
char v2; // al

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( a2 != v2 )
{
v2 = *++a1;
if ( !*a1 )
return 0LL;
}
return 1LL;
}

original_code:
int ft_in_string(char *str, char c)
{
 while (*str)
 {
  if (*str == c)
   return (1);
  str++;
 }
 return (0);
}

variable_types:
str
char *

variable_types: c char


repo: jfcalvo/handy

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

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

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

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

original_code:
handy_float handy_point_distance_euclidean(handy_point p1, handy_point p2) {
    return (handy_float) sqrtf(((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)));
}

canonical_original_code:
float handy_point_distance_euclidean(struct handy_point p1, struct handy_point p2) {
    return (float) sqrtf(((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)));
}

return_type: float


decompiled_code:
float __fastcall handy_allograph_distance_dtw(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v4; // er15
char v5; // dl
const char *v6; // rax
const char *v7; // r9
__int64 v8; // r15
__int64 v9; // r13
int v10; // er12
__int64 v11; // r15
bool v12; // r14
float v13; // xmm0_4
__int64 v14; // r13
int v15; // er12
__int64 v16; // r15
bool v17; // r14
float v18; // xmm0_4
int v19; // er13
__int64 v20; // r14
bool v21; // r12
float v22; // xmm0_4
bool v23; // cc
bool v24; // al
__int64 v25; // r15
int v26; // er13
__int64 v27; // r14
bool v28; // r12
float v29; // xmm0_4
bool v30; // al
__int64 v31; // rax
float v33; // [rsp+0h] [rbp-68h]
unsigned int v34; // [rsp+4h] [rbp-64h]
int v35; // [rsp+8h] [rbp-60h]
int v36; // [rsp+8h] [rbp-60h]
float v37; // [rsp+8h] [rbp-60h]
int v38; // [rsp+8h] [rbp-60h]
float v39; // [rsp+8h] [rbp-60h]
unsigned int v40; // [rsp+Ch] [rbp-5Ch]
unsigned int v41; // [rsp+Ch] [rbp-5Ch]
unsigned int v42; // [rsp+Ch] [rbp-5Ch]
bool v43; // [rsp+Ch] [rbp-5Ch]
unsigned int v44; // [rsp+10h] [rbp-58h]
float v45; // [rsp+14h] [rbp-54h]
bool v46; // [rsp+14h] [rbp-54h]
bool v47; // [rsp+14h] [rbp-54h]
float v48; // [rsp+14h] [rbp-54h]
unsigned int v49; // [rsp+18h] [rbp-50h]
unsigned int v50; // [rsp+18h] [rbp-50h]
float v51; // [rsp+18h] [rbp-50h]
unsigned int v52; // [rsp+18h] [rbp-50h]
float v53; // [rsp+1Ch] [rbp-4Ch]
int v54; // [rsp+28h] [rbp-40h]
char v55; // [rsp+2Eh] [rbp-3Ah]
bool v56; // [rsp+2Eh] [rbp-3Ah]
char v57; // [rsp+2Fh] [rbp-39h]

verbose(
0LL,
64LL,
"src/handy_distance.c",
"Calculating Dynamic Time Warping distance between allograph %s and allograph %s",
(const char *)a1,
(const char *)a2);
v34 = *(_DWORD *)(a1 + 512);
v4 = *(_DWORD *)(a2 + 512);
if ( a3 )
{
v33 = *(float *)a3;
v5 = *(_BYTE *)(a3 + 4);
v55 = *(_BYTE *)(a3 + 5);
v57 = *(_BYTE *)(a3 + 6);
v6 = "true";
if ( !v57 )
v6 = "false";
v7 = "true";
if ( !*(_BYTE *)(a3 + 5) )
v7 = "false";
}
else
{
v5 = 0;
v6 = "false";
v55 = 0;
v57 = 0;
v33 = *(float *)&LC3;
v7 = "false";
}
if ( v5 )
{
verbose(
0LL,
98LL,
"src/handy_distance.c",
"DTW Distance Config: c = %f, boundary = %s, monotonicity = %s, symmetry = %s",
v33,
"true",
v7,
v6);
v39 = handy_point_distance_euclidean(
**(double **)(a1 + 520),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a1 + 520) + 8LL)),
**(double **)(a2 + 520))
+ 0.0;
v31 = *(_QWORD *)(a1 + 520) + 12LL * (unsigned int)(*(_DWORD *)(a1 + 512) - 1);
v53 = handy_point_distance_euclidean(
*(double *)v31,
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(v31 + 8)),
*(double *)(*(_QWORD *)(a2 + 520) + 12LL * (unsigned int)(*(_DWORD *)(a2 + 512) - 1)))
+ v39;
--v34;
--v4;
verbose(0LL, 120LL, "src/handy_distance.c", "Matches points: %d, %d (boundary condition: enabled)", 0LL, 0LL);
verbose(
0LL,
121LL,
"src/handy_distance.c",
"Matches points: %d, %d (boundary condition: enabled)",
(unsigned int)(*(_DWORD *)(a1 + 512) - 1),
(unsigned int)(*(_DWORD *)(a2 + 512) - 1));
v54 = 2;
v44 = 1;
}
else
{
verbose(
0LL,
98LL,
"src/handy_distance.c",
"DTW Distance Config: c = %f, boundary = %s, monotonicity = %s, symmetry = %s",
v33,
"false",
v7,
v6);
v53 = 0.0;
v54 = 0;
v44 = 0;
}
if ( v55 )
{
if ( v44 < v34 )
{
v9 = 12LL * v44;
v49 = v44;
v36 = v44;
v41 = v4;
do
{
if ( v41 > v49 )
{
v10 = v49;
v11 = 12LL * v49;
v45 = *(float *)&LC4;
v56 = 0;
do
{
v12 = dtw_continuity_condition(a1, a2, v36, v10, v33);
if ( v12 )
{
v13 = handy_point_distance_euclidean(
*(double *)(*(_QWORD *)(a1 + 520) + v9),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a1 + 520) + v9 + 8)),
*(double *)(*(_QWORD *)(a2 + 520) + v11));
if ( v45 > v13 )
{
v49 = v10;
v45 = v13;
v56 = v12;
}
}
++v10;
v11 += 12LL;
}
while ( v41 != v10 );
if ( v56 )
{
++v54;
v53 = v53 + v45;
}
}
++v36;
v9 += 12LL;
}
while ( v34 != v36 );
v4 = v41;
}
if ( v57 && v44 < v4 )
{
v14 = 12LL * v44;
v42 = v44;
v50 = v4;
do
{
if ( v34 > v42 )
{
v15 = v42;
v16 = 12LL * v42;
v37 = *(float *)&LC4;
v46 = 0;
do
{
v17 = dtw_continuity_condition(a2, a1, v44, v15, v33);
if ( v17 )
{
v18 = handy_point_distance_euclidean(
*(double *)(*(_QWORD *)(a2 + 520) + v14),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a2 + 520) + v14 + 8)),
*(double *)(*(_QWORD *)(a1 + 520) + v16));
if ( v37 > v18 )
{
v42 = v15;
v37 = v18;
v46 = v17;
}
}
++v15;
v16 += 12LL;
}
while ( v34 != v15 );
if ( v46 )
{
++v54;
v53 = v53 + v37;
}
}
++v44;
v14 += 12LL;
}
while ( v50 != v44 );
}
}
else
{
if ( v44 < v34 )
{
v35 = v44;
v40 = v4;
v8 = 12LL * v44;
do
{
if ( v44 < v40 )
{
v20 = 12LL * v44;
v19 = v44;
v47 = 0;
v51 = *(float *)&LC4;
do
{
v21 = dtw_continuity_condition(a1, a2, v35, v19, v33);
if ( v21 )
{
v22 = handy_point_distance_euclidean(
*(double *)(*(_QWORD *)(a1 + 520) + v8),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a1 + 520) + v8 + 8)),
*(double *)(*(_QWORD *)(a2 + 520) + v20));
v23 = v51 <= v22;
v51 = fminf(v22, v51);
v24 = v47;
if ( !v23 )
v24 = v21;
v47 = v24;
}
++v19;
v20 += 12LL;
}
while ( v40 != v19 );
if ( v47 )
{
++v54;
v53 = v53 + v51;
}
}
++v35;
v8 += 12LL;
}
while ( v34 != v35 );
v4 = v40;
}
if ( v57 && v44 < v4 )
{
v38 = v44;
v52 = v4;
v25 = 12LL * v44;
do
{
if ( v44 < v34 )
{
v27 = 12LL * v44;
v26 = v44;
v43 = 0;
v48 = *(float *)&LC4;
do
{
v28 = dtw_continuity_condition(a2, a1, v38, v26, v33);
if ( v28 )
{
v29 = handy_point_distance_euclidean(
*(double *)(*(_QWORD *)(a2 + 520) + v25),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a2 + 520) + v25 + 8)),
*(double *)(*(_QWORD *)(a1 + 520) + v27));
v23 = v48 <= v29;
v48 = fminf(v29, v48);
v30 = v43;
if ( !v23 )
v30 = v28;
v43 = v30;
}
++v26;
v27 += 12LL;
}
while ( v34 != v26 );
if ( v43 )
{
++v54;
v53 = v53 + v48;
}
}
++v38;
v25 += 12LL;
}
while ( v52 != v38 );
}
}
verbose(
0LL,
223LL,
"src/handy_distance.c",
"Number of points matches between allograph %s and allograph %s is: %d",
(const char *)a1,
(const char *)a2,
(unsigned int)v54);
return v53 / (float)v54;
}

canonical_decompiled_code:
float __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v4; // er15
char v5; // dl
const char *v6; // rax
const char *v7; // r9
__int64 v8; // r15
__int64 v9; // r13
int v10; // er12
__int64 v11; // r15
bool v12; // r14
float v13; // xmm0_4
__int64 v14; // r13
int v15; // er12
__int64 v16; // r15
bool v17; // r14
float v18; // xmm0_4
int v19; // er13
__int64 v20; // r14
bool v21; // r12
float v22; // xmm0_4
bool v23; // cc
bool v24; // al
__int64 v25; // r15
int v26; // er13
__int64 v27; // r14
bool v28; // r12
float v29; // xmm0_4
bool v30; // al
__int64 v31; // rax
float v33; // [rsp+0h] [rbp-68h]
unsigned int v34; // [rsp+4h] [rbp-64h]
int v35; // [rsp+8h] [rbp-60h]
int v36; // [rsp+8h] [rbp-60h]
float v37; // [rsp+8h] [rbp-60h]
int v38; // [rsp+8h] [rbp-60h]
float v39; // [rsp+8h] [rbp-60h]
unsigned int v40; // [rsp+Ch] [rbp-5Ch]
unsigned int v41; // [rsp+Ch] [rbp-5Ch]
unsigned int v42; // [rsp+Ch] [rbp-5Ch]
bool v43; // [rsp+Ch] [rbp-5Ch]
unsigned int v44; // [rsp+10h] [rbp-58h]
float v45; // [rsp+14h] [rbp-54h]
bool v46; // [rsp+14h] [rbp-54h]
bool v47; // [rsp+14h] [rbp-54h]
float v48; // [rsp+14h] [rbp-54h]
unsigned int v49; // [rsp+18h] [rbp-50h]
unsigned int v50; // [rsp+18h] [rbp-50h]
float v51; // [rsp+18h] [rbp-50h]
unsigned int v52; // [rsp+18h] [rbp-50h]
float v53; // [rsp+1Ch] [rbp-4Ch]
int v54; // [rsp+28h] [rbp-40h]
char v55; // [rsp+2Eh] [rbp-3Ah]
bool v56; // [rsp+2Eh] [rbp-3Ah]
char v57; // [rsp+2Fh] [rbp-39h]

verbose(
0LL,
64LL,
"src/handy_distance.c",
"Calculating Dynamic Time Warping distance between allograph %s and allograph %s",
(const char *)a1,
(const char *)a2);
v34 = *(_DWORD *)(a1 + 512);
v4 = *(_DWORD *)(a2 + 512);
if ( a3 )
{
v33 = *(float *)a3;
v5 = *(_BYTE *)(a3 + 4);
v55 = *(_BYTE *)(a3 + 5);
v57 = *(_BYTE *)(a3 + 6);
v6 = "true";
if ( !v57 )
v6 = "false";
v7 = "true";
if ( !*(_BYTE *)(a3 + 5) )
v7 = "false";
}
else
{
v5 = 0;
v6 = "false";
v55 = 0;
v57 = 0;
v33 = *(float *)&LC3;
v7 = "false";
}
if ( v5 )
{
verbose(
0LL,
98LL,
"src/handy_distance.c",
"DTW Distance Config: c = %f, boundary = %s, monotonicity = %s, symmetry = %s",
v33,
"true",
v7,
v6);
v39 = func1(
**(double **)(a1 + 520),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a1 + 520) + 8LL)),
**(double **)(a2 + 520))
+ 0.0;
v31 = *(_QWORD *)(a1 + 520) + 12LL * (unsigned int)(*(_DWORD *)(a1 + 512) - 1);
v53 = func1(
*(double *)v31,
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(v31 + 8)),
*(double *)(*(_QWORD *)(a2 + 520) + 12LL * (unsigned int)(*(_DWORD *)(a2 + 512) - 1)))
+ v39;
--v34;
--v4;
verbose(0LL, 120LL, "src/handy_distance.c", "Matches points: %d, %d (boundary condition: enabled)", 0LL, 0LL);
verbose(
0LL,
121LL,
"src/handy_distance.c",
"Matches points: %d, %d (boundary condition: enabled)",
(unsigned int)(*(_DWORD *)(a1 + 512) - 1),
(unsigned int)(*(_DWORD *)(a2 + 512) - 1));
v54 = 2;
v44 = 1;
}
else
{
verbose(
0LL,
98LL,
"src/handy_distance.c",
"DTW Distance Config: c = %f, boundary = %s, monotonicity = %s, symmetry = %s",
v33,
"false",
v7,
v6);
v53 = 0.0;
v54 = 0;
v44 = 0;
}
if ( v55 )
{
if ( v44 < v34 )
{
v9 = 12LL * v44;
v49 = v44;
v36 = v44;
v41 = v4;
do
{
if ( v41 > v49 )
{
v10 = v49;
v11 = 12LL * v49;
v45 = *(float *)&LC4;
v56 = 0;
do
{
v12 = func0(a1, a2, v36, v10, v33);
if ( v12 )
{
v13 = func1(
*(double *)(*(_QWORD *)(a1 + 520) + v9),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a1 + 520) + v9 + 8)),
*(double *)(*(_QWORD *)(a2 + 520) + v11));
if ( v45 > v13 )
{
v49 = v10;
v45 = v13;
v56 = v12;
}
}
++v10;
v11 += 12LL;
}
while ( v41 != v10 );
if ( v56 )
{
++v54;
v53 = v53 + v45;
}
}
++v36;
v9 += 12LL;
}
while ( v34 != v36 );
v4 = v41;
}
if ( v57 && v44 < v4 )
{
v14 = 12LL * v44;
v42 = v44;
v50 = v4;
do
{
if ( v34 > v42 )
{
v15 = v42;
v16 = 12LL * v42;
v37 = *(float *)&LC4;
v46 = 0;
do
{
v17 = func0(a2, a1, v44, v15, v33);
if ( v17 )
{
v18 = func1(
*(double *)(*(_QWORD *)(a2 + 520) + v14),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a2 + 520) + v14 + 8)),
*(double *)(*(_QWORD *)(a1 + 520) + v16));
if ( v37 > v18 )
{
v42 = v15;
v37 = v18;
v46 = v17;
}
}
++v15;
v16 += 12LL;
}
while ( v34 != v15 );
if ( v46 )
{
++v54;
v53 = v53 + v37;
}
}
++v44;
v14 += 12LL;
}
while ( v50 != v44 );
}
}
else
{
if ( v44 < v34 )
{
v35 = v44;
v40 = v4;
v8 = 12LL * v44;
do
{
if ( v44 < v40 )
{
v20 = 12LL * v44;
v19 = v44;
v47 = 0;
v51 = *(float *)&LC4;
do
{
v21 = func0(a1, a2, v35, v19, v33);
if ( v21 )
{
v22 = func1(
*(double *)(*(_QWORD *)(a1 + 520) + v8),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a1 + 520) + v8 + 8)),
*(double *)(*(_QWORD *)(a2 + 520) + v20));
v23 = v51 <= v22;
v51 = fminf(v22, v51);
v24 = v47;
if ( !v23 )
v24 = v21;
v47 = v24;
}
++v19;
v20 += 12LL;
}
while ( v40 != v19 );
if ( v47 )
{
++v54;
v53 = v53 + v51;
}
}
++v35;
v8 += 12LL;
}
while ( v34 != v35 );
v4 = v40;
}
if ( v57 && v44 < v4 )
{
v38 = v44;
v52 = v4;
v25 = 12LL * v44;
do
{
if ( v44 < v34 )
{
v27 = 12LL * v44;
v26 = v44;
v43 = 0;
v48 = *(float *)&LC4;
do
{
v28 = func0(a2, a1, v38, v26, v33);
if ( v28 )
{
v29 = func1(
*(double *)(*(_QWORD *)(a2 + 520) + v25),
COERCE_DOUBLE((unsigned __int64)*(_DWORD *)(*(_QWORD *)(a2 + 520) + v25 + 8)),
*(double *)(*(_QWORD *)(a1 + 520) + v27));
v23 = v48 <= v29;
v48 = fminf(v29, v48);
v30 = v43;
if ( !v23 )
v30 = v28;
v43 = v30;
}
++v26;
v27 += 12LL;
}
while ( v34 != v26 );
if ( v43 )
{
++v54;
v53 = v53 + v48;
}
}
++v38;
v25 += 12LL;
}
while ( v52 != v38 );
}
}
verbose(
0LL,
223LL,
"src/handy_distance.c",
"Number of points matches between allograph %s and allograph %s is: %d",
(const char *)a1,
(const char *)a2,
(unsigned int)v54);
return v53 / (float)v54;
}

original_code:
handy_float handy_allograph_distance_dtw(handy_allograph* a1, handy_allograph* a2, handy_distance_config* config) {
    verbose(INFO, 64, "src/handy_distance.c", "Calculating Dynamic Time Warping distance between allograph %s and allograph %s", a1->symbol, a2->symbol);
    handy_bool boundary = 0;
    handy_bool monotonicity = 0;
    handy_bool symmetry = 0;
    handy_bool match;
    handy_uint i = 0, j = 0;
    handy_uint start_i = 0, start_j = 0;
    handy_uint number_of_matches = 0;
    handy_uint a1_num_points = a1->num_points;
    handy_uint a2_num_points = a2->num_points;
    handy_float distance = 0.0;
    handy_float temp_distance;
    handy_float smallest_distance;
    handy_float c = 0.13;
    if(config != ((void *)0)) {
        c = config->c;
        boundary = config->boundary;
        monotonicity = config->monotonicity;
        symmetry = config->symmetry;
    }
    verbose(INFO, 98, "src/handy_distance.c", "DTW Distance Config: c = %f, boundary = %s, monotonicity = %s, symmetry = %s", c, boundary == 1 ? "true": "false" , monotonicity == 1 ? "true": "false", symmetry == 1 ? "true": "false");
    if(boundary == 1) {
        distance += handy_point_distance_euclidean(a1->points[0], a2->points[0]);
        distance += handy_point_distance_euclidean(a1->points[a1->num_points - 1],
                                                   a2->points[a2->num_points - 1]);
        start_i = 1;
        start_j = 1;
        a1_num_points--;
        a2_num_points--;
        number_of_matches += 2;
        verbose(INFO, 120, "src/handy_distance.c", "Matches points: %d, %d (boundary condition: enabled)", 0, 0);
        verbose(INFO, 121, "src/handy_distance.c", "Matches points: %d, %d (boundary condition: enabled)", a1->num_points - 1, a2->num_points - 1);
    }
    if(monotonicity) {
        handy_uint next_j = start_j;
        for(i = start_j; i < a1_num_points; i++) {
            match = 0;
            smallest_distance = 1000000;
            for(j = next_j; j < a2_num_points; j++) {
                if(_dtw_continuity_condition(a1, a2, i, j, c)) {
                    temp_distance = handy_point_distance_euclidean(a1->points[i], a2->points[j]);
                    if(temp_distance < smallest_distance) {
                        match = 1;
                        next_j = j;
                        smallest_distance = temp_distance;
                    }
                }
            }
            if(match) {
                number_of_matches++;
                distance += smallest_distance;
            }
        }
        if(symmetry) {
            handy_uint next_i = start_i;
            for(j = start_j; j < a2_num_points; j++) {
                match = 0;
                smallest_distance = 1000000;
                for(i = next_i; i < a1_num_points; i++) {
                    if(_dtw_continuity_condition(a2, a1, j, i, c)) {
                        temp_distance = handy_point_distance_euclidean(a2->points[j], a1->points[i]);
                        if(temp_distance < smallest_distance) {
                            match = 1;
                            next_i = i;
                            smallest_distance = temp_distance;
                        }
                    }
                }
                if(match) {
                    number_of_matches++;
                    distance += smallest_distance;
                }
            }
        }
    } else {
        for(i = start_i; i < a1_num_points; i++) {
            match = 0;
            smallest_distance = 1000000;
            for(j = start_j; j < a2_num_points; j++) {
                if(_dtw_continuity_condition(a1, a2, i, j, c)) {
                    temp_distance = handy_point_distance_euclidean(a1->points[i], a2->points[j]);
                    if(temp_distance < smallest_distance) {
                        match = 1;
                        smallest_distance = temp_distance;
                    }
                }
            }
            if(match) {
                number_of_matches++;
                distance += smallest_distance;
            }
        }
        if(symmetry) {
            for(j = start_j; j < a2_num_points; j++) {
                match = 0;
                smallest_distance = 1000000;
                for(i = start_i; i < a1_num_points; i++) {
                    if(_dtw_continuity_condition(a2, a1, j, i, c)) {
                        temp_distance = handy_point_distance_euclidean(a2->points[j], a1->points[i]);
                        if(temp_distance < smallest_distance) {
                            match = 1;
                            smallest_distance = temp_distance;
                        }
                    }
                }
                if(match) {
                    number_of_matches++;
                    distance += smallest_distance;
                }
            }
        }
    }
    verbose(INFO, 223, "src/handy_distance.c", "Number of points matches between allograph %s and allograph %s is: %d", a1->symbol, a2->symbol, number_of_matches);
    distance = ((handy_float) distance / (handy_float) number_of_matches);
    return distance;
}

canonical_original_code:
float handy_allograph_distance_dtw(struct handy_allograph *a1, struct handy_allograph *a2, struct handy_distance_config *config) {
    verbose(INFO, 64, "src/handy_distance.c", "Calculating Dynamic Time Warping distance between allograph %s and allograph %s", a1->symbol, a2->symbol);
    _Bool boundary = 0;
    _Bool monotonicity = 0;
    _Bool symmetry = 0;
    _Bool match;
    unsigned int i = 0; unsigned int j = 0;
    unsigned int start_i = 0; unsigned int start_j = 0;
    unsigned int number_of_matches = 0;
    unsigned int a1_num_points = a1->num_points;
    unsigned int a2_num_points = a2->num_points;
    float distance = 0.0;
    float temp_distance;
    float smallest_distance;
    float c = 0.13;
    if(config != ((void *)0)) {
        c = config->c;
        boundary = config->boundary;
        monotonicity = config->monotonicity;
        symmetry = config->symmetry;
    }
    verbose(INFO, 98, "src/handy_distance.c", "DTW Distance Config: c = %f, boundary = %s, monotonicity = %s, symmetry = %s", c, boundary == 1 ? "true": "false" , monotonicity == 1 ? "true": "false", symmetry == 1 ? "true": "false");
    if(boundary == 1) {
        distance += handy_point_distance_euclidean(a1->points[0], a2->points[0]);
        distance += handy_point_distance_euclidean(a1->points[a1->num_points - 1],
                                                   a2->points[a2->num_points - 1]);
        start_i = 1;
        start_j = 1;
        a1_num_points--;
        a2_num_points--;
        number_of_matches += 2;
        verbose(INFO, 120, "src/handy_distance.c", "Matches points: %d, %d (boundary condition: enabled)", 0, 0);
        verbose(INFO, 121, "src/handy_distance.c", "Matches points: %d, %d (boundary condition: enabled)", a1->num_points - 1, a2->num_points - 1);
    }
    if(monotonicity) {
        unsigned int next_j = start_j;
        for(i = start_j; i < a1_num_points; i++) {
            match = 0;
            smallest_distance = 1000000;
            for(j = next_j; j < a2_num_points; j++) {
                if(_dtw_continuity_condition(a1, a2, i, j, c)) {
                    temp_distance = handy_point_distance_euclidean(a1->points[i], a2->points[j]);
                    if(temp_distance < smallest_distance) {
                        match = 1;
                        next_j = j;
                        smallest_distance = temp_distance;
                    }
                }
            }
            if(match) {
                number_of_matches++;
                distance += smallest_distance;
            }
        }
        if(symmetry) {
            unsigned int next_i = start_i;
            for(j = start_j; j < a2_num_points; j++) {
                match = 0;
                smallest_distance = 1000000;
                for(i = next_i; i < a1_num_points; i++) {
                    if(_dtw_continuity_condition(a2, a1, j, i, c)) {
                        temp_distance = handy_point_distance_euclidean(a2->points[j], a1->points[i]);
                        if(temp_distance < smallest_distance) {
                            match = 1;
                            next_i = i;
                            smallest_distance = temp_distance;
                        }
                    }
                }
                if(match) {
                    number_of_matches++;
                    distance += smallest_distance;
                }
            }
        }
    } else {
        for(i = start_i; i < a1_num_points; i++) {
            match = 0;
            smallest_distance = 1000000;
            for(j = start_j; j < a2_num_points; j++) {
                if(_dtw_continuity_condition(a1, a2, i, j, c)) {
                    temp_distance = handy_point_distance_euclidean(a1->points[i], a2->points[j]);
                    if(temp_distance < smallest_distance) {
                        match = 1;
                        smallest_distance = temp_distance;
                    }
                }
            }
            if(match) {
                number_of_matches++;
                distance += smallest_distance;
            }
        }
        if(symmetry) {
            for(j = start_j; j < a2_num_points; j++) {
                match = 0;
                smallest_distance = 1000000;
                for(i = start_i; i < a1_num_points; i++) {
                    if(_dtw_continuity_condition(a2, a1, j, i, c)) {
                        temp_distance = handy_point_distance_euclidean(a2->points[j], a1->points[i]);
                        if(temp_distance < smallest_distance) {
                            match = 1;
                            smallest_distance = temp_distance;
                        }
                    }
                }
                if(match) {
                    number_of_matches++;
                    distance += smallest_distance;
                }
            }
        }
    }
    verbose(INFO, 223, "src/handy_distance.c", "Number of points matches between allograph %s and allograph %s is: %d", a1->symbol, a2->symbol, number_of_matches);
    distance = ((float) distance / (float) number_of_matches);
    return distance;
}

variable_types: struct handy_allograph { char symbol[512]; unsigned int num_points; struct handy_point { float x; } *points; } *

variable_types: struct handy_distance_config { float c; _Bool boundary; _Bool monotonicity; _Bool symmetry; enum handy_distance { HANDY_DISTANCE_DTW=0, HANDY_DISTANCE_EUCLIDEAN=1 } distance; } *

variable_types:
j
unsigned int

variable_types: distance float

variable_types: c float

user_defined_types: struct handy_allograph { char symbol[512]; unsigned int num_points; struct handy_point *points; }

user_defined_types: struct handy_distance_config { float c; _Bool boundary; _Bool monotonicity; _Bool symmetry; enum handy_distance distance; }


decompiled_code:
float __fastcall handy_allograph_distance(__int64 a1, __int64 a2, __int64 a3)
{
float result; // xmm0_4

if ( a1 )
{
if ( a2 )
{
if ( *(_DWORD *)(a3 + 8) )
{
verbose(
2LL,
56LL,
"src/handy_distance.c",
"Not distance method indicated at distance configuration, distance calculation aborted");
result = *(float *)&LC10;
}
else
{
result = handy_allograph_distance_dtw(a1, a2, a3);
}
}
else
{
verbose(2LL, 42LL, "src/handy_distance.c", "Allograph two has not been initiated, distance calculation aborted");
result = *(float *)&LC10;
}
}
else
{
verbose(2LL, 36LL, "src/handy_distance.c", "Allograph one has not been initiated, distance calculation aborted");
result = *(float *)&LC10;
}
return result;
}

canonical_decompiled_code:
float __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
float result; // xmm0_4

if ( a1 )
{
if ( a2 )
{
if ( *(_DWORD *)(a3 + 8) )
{
verbose(
2LL,
56LL,
"src/handy_distance.c",
"Not distance method indicated at distance configuration, distance calculation aborted");
result = *(float *)&LC10;
}
else
{
result = func2(a1, a2, a3);
}
}
else
{
verbose(2LL, 42LL, "src/handy_distance.c", "Allograph two has not been initiated, distance calculation aborted");
result = *(float *)&LC10;
}
}
else
{
verbose(2LL, 36LL, "src/handy_distance.c", "Allograph one has not been initiated, distance calculation aborted");
result = *(float *)&LC10;
}
return result;
}

original_code:
handy_float handy_allograph_distance(handy_allograph* a1, handy_allograph* a2, handy_distance_config* config) {
    if(a1 == ((void *)0)) {
        verbose(ERROR, 36, "src/handy_distance.c", "Allograph one has not been initiated, distance calculation aborted");
        return (handy_float) -1.0;
    }
    if(a2 == ((void *)0)) {
        verbose(ERROR, 42, "src/handy_distance.c", "Allograph two has not been initiated, distance calculation aborted");
        return (handy_float) -1.0;
    }
    switch(config->distance) {
        case HANDY_DISTANCE_DTW:
            return handy_allograph_distance_dtw(a1, a2, config);
            break;
        default:
            verbose(ERROR, 56, "src/handy_distance.c", "Not distance method indicated at distance configuration, distance calculation aborted");
            return (handy_float) -1.0;
            break;
    }
}

canonical_original_code:
float handy_allograph_distance(struct handy_allograph *a1, struct handy_allograph *a2, struct handy_distance_config *config) {
    if(a1 == ((void *)0)) {
        verbose(ERROR, 36, "src/handy_distance.c", "Allograph one has not been initiated, distance calculation aborted");
        return (handy_float) -1.0;
    }
    if(a2 == ((void *)0)) {
        verbose(ERROR, 42, "src/handy_distance.c", "Allograph two has not been initiated, distance calculation aborted");
        return (handy_float) -1.0;
    }
    switch(config->distance) {
        case HANDY_DISTANCE_DTW:
            return handy_allograph_distance_dtw(a1, a2, config);
            break;
        default:
            verbose(ERROR, 56, "src/handy_distance.c", "Not distance method indicated at distance configuration, distance calculation aborted");
            return (handy_float) -1.0;
            break;
    }
}

user_defined_types: enum handy_distance { HANDY_DISTANCE_DTW=0, HANDY_DISTANCE_EUCLIDEAN=1 }


decompiled_code:
float __fastcall handy_point_distance(int a1, double a2, double a3, double a4)
{
float result; // xmm0_4

if ( a1 == 1 )
result = handy_point_distance_euclidean(a2, a3, a4);
else
result = handy_point_distance_euclidean(a2, COERCE_DOUBLE((unsigned __int64)LODWORD(a3)), a4);
return result;
}

canonical_decompiled_code:
float __fastcall func4(int a1, double a2, double a3, double a4)
{
float result; // xmm0_4

if ( a1 == 1 )
result = func1(a2, a3, a4);
else
result = func1(a2, COERCE_DOUBLE((unsigned __int64)LODWORD(a3)), a4);
return result;
}

original_code:
handy_float handy_point_distance(handy_point p1, handy_point p2, handy_distance distance) {
    switch(distance) {
        case HANDY_DISTANCE_EUCLIDEAN:
            return handy_point_distance_euclidean(p1, p2);
            break;
        default:
          return handy_point_distance_euclidean(p1, p2);
          break;
    }
}

canonical_original_code:
float handy_point_distance(struct handy_point p1, struct handy_point p2, enum handy_distance distance) {
    switch(distance) {
        case HANDY_DISTANCE_EUCLIDEAN:
            return handy_point_distance_euclidean(p1, p2);
            break;
        default:
          return handy_point_distance_euclidean(p1, p2);
          break;
    }
}

variable_types: enum handy_distance { HANDY_DISTANCE_DTW=0, HANDY_DISTANCE_EUCLIDEAN=1 }


decompiled_code:
double __fastcall handy_point_angle(double a1, double a2, double a3)
{
float v3; // ebp
float v4; // er13
double result; // xmm0_8
double v6; // xmm1_8
double v7; // xmm1_8

v3 = *(float *)&a1;
v4 = *((float *)&a1 + 1);
result = COERCE_FLOAT(COERCE_UNSIGNED_INT(atanf((float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)) / (float)(*(float *)&a1 - *(float *)&a3))) & LC14)
* 180.0
/ 3.141592653589793;
*(float *)&result = result;
if ( *(float *)&a3 >= v3 && v4 >= *((float *)&a3 + 1) )
{
if ( v4 == *((float *)&a3 + 1) && v3 == *(float *)&a3 )
result = 0.0;
return result;
}
if ( v3 > *(float *)&a3 )
{
if ( v4 >= *((float *)&a3 + 1) )
{
*(_QWORD *)&v6 = (unsigned int)LC17;
*(float *)&v6 = 180.0 - *(float *)&result;
return v6;
}
LABEL_14:
if ( *((float *)&a3 + 1) > v4 )
{
*(float *)&result = *(float *)&result + 180.0;
return result;
}
goto LABEL_10;
}
if ( v3 >= *(float *)&a3 )
goto LABEL_14;
LABEL_10:
if ( *(float *)&a3 <= v3 || *((float *)&a3 + 1) <= v4 )
{
verbose(
2LL,
302LL,
"src/handy_distance.c",
"No valid quadrant found for point (x: %f, y: %f)",
*(float *)&a3,
*((float *)&a3 + 1));
result = 0.0;
}
else
{
*(_QWORD *)&v7 = (unsigned int)LC18;
*(float *)&v7 = 360.0 - *(float *)&result;
result = v7;
}
return result;
}

canonical_decompiled_code:
double __fastcall func5(double a1, double a2, double a3)
{
float v3; // ebp
float v4; // er13
double result; // xmm0_8
double v6; // xmm1_8
double v7; // xmm1_8

v3 = *(float *)&a1;
v4 = *((float *)&a1 + 1);
result = COERCE_FLOAT(COERCE_UNSIGNED_INT(atanf((float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)) / (float)(*(float *)&a1 - *(float *)&a3))) & LC14)
* 180.0
/ 3.141592653589793;
*(float *)&result = result;
if ( *(float *)&a3 >= v3 && v4 >= *((float *)&a3 + 1) )
{
if ( v4 == *((float *)&a3 + 1) && v3 == *(float *)&a3 )
result = 0.0;
return result;
}
if ( v3 > *(float *)&a3 )
{
if ( v4 >= *((float *)&a3 + 1) )
{
*(_QWORD *)&v6 = (unsigned int)LC17;
*(float *)&v6 = 180.0 - *(float *)&result;
return v6;
}
LABEL_14:
if ( *((float *)&a3 + 1) > v4 )
{
*(float *)&result = *(float *)&result + 180.0;
return result;
}
goto LABEL_10;
}
if ( v3 >= *(float *)&a3 )
goto LABEL_14;
LABEL_10:
if ( *(float *)&a3 <= v3 || *((float *)&a3 + 1) <= v4 )
{
verbose(
2LL,
302LL,
"src/handy_distance.c",
"No valid quadrant found for point (x: %f, y: %f)",
*(float *)&a3,
*((float *)&a3 + 1));
result = 0.0;
}
else
{
*(_QWORD *)&v7 = (unsigned int)LC18;
*(float *)&v7 = 360.0 - *(float *)&result;
result = v7;
}
return result;
}

original_code:
handy_float handy_point_angle(handy_point p1, handy_point p2) {
    handy_float angle;
    angle = (handy_float) fabsf(atanf((p1.y - p2.y) / (p1.x - p2.x))) * 180.0/3.14159265358979323846;
    if(p2.x >= p1.x && p2.y <= p1.y) {
        if(p2.x == p1.x && p2.y == p1.y) {
            return 0.0;
        }
    } else if(p2.x < p1.x && p2.y <= p1.y) {
        angle = 180.0 - angle;
    } else if(p2.x <= p1.x && p2.y > p1.y) {
        angle = 180.0 + angle;
    } else if(p2.x > p1.x && p2.y > p1.y) {
        angle = 360.0 - angle;
    } else {
        verbose(ERROR, 302, "src/handy_distance.c", "No valid quadrant found for point (x: %f, y: %f)", p2.x, p2.y);
        return 0.0;
    }
    return angle;
}

canonical_original_code:
float handy_point_angle(struct handy_point p1, struct handy_point p2) {
    float angle;
    angle = (float) fabsf(atanf((p1.y - p2.y) / (p1.x - p2.x))) * 180.0/3.14159265358979323846;
    if(p2.x >= p1.x && p2.y <= p1.y) {
        if(p2.x == p1.x && p2.y == p1.y) {
            return 0.0;
        }
    } else if(p2.x < p1.x && p2.y <= p1.y) {
        angle = 180.0 - angle;
    } else if(p2.x <= p1.x && p2.y > p1.y) {
        angle = 180.0 + angle;
    } else if(p2.x > p1.x && p2.y > p1.y) {
        angle = 360.0 - angle;
    } else {
        verbose(ERROR, 302, "src/handy_distance.c", "No valid quadrant found for point (x: %f, y: %f)", p2.x, p2.y);
        return 0.0;
    }
    return angle;
}

variable_types: angle float


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

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

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

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

original_code:
handy_collection* handy_collection_new() {
    handy_collection* collection = (handy_collection*) malloc(sizeof(handy_collection));
    if(collection == ((void *)0)) {
        return ((void *)0);
    } else {
        collection->num_allographs = 0;
        collection->allographs = ((void *)0);
        return collection;
    }
}

canonical_original_code:
struct handy_collection *handy_collection_new() {
    struct handy_collection *collection = (handy_collection*) malloc(sizeof(handy_collection));
    if(collection == ((void *)0)) {
        return ((void *)0);
    } else {
        collection->num_allographs = 0;
        collection->allographs = ((void *)0);
        return collection;
    }
}

variable_types: struct handy_collection { unsigned int num_allographs; struct handy_allograph { char symbol[512]; unsigned int num_points; struct handy_point { float x; } *points; } *allographs; } *

user_defined_types: struct handy_collection { unsigned int num_allographs; struct handy_allograph *allographs; }


decompiled_code:
void __fastcall handy_collection_free(void *ptr)
{
unsigned int v1; // er13
__int64 v2; // r12
unsigned int v3; // ebx

verbose(0LL, 48LL, "src/handy_collection.c", "Removing collection from memory");
if ( ptr )
{
if ( *((_QWORD *)ptr + 1) )
{
verbose(0LL, 51LL, "src/handy_collection.c", "Removing allographs from collection");
v1 = *(_DWORD *)ptr;
if ( *(_DWORD *)ptr )
{
v2 = 0LL;
v3 = 0;
do
{
verbose(0LL, 55LL, "src/handy_collection.c", "Removing points of allograph %d of %d from collection", v3, v1);
free(*(void **)(*((_QWORD *)ptr + 1) + v2 + 520));
++v3;
v2 += 528LL;
}
while ( v3 != v1 );
}
}
verbose(0LL, 60LL, "src/handy_collection.c", "Removing collection allographs");
free(*((void **)ptr + 1));
verbose(0LL, 63LL, "src/handy_collection.c", "Removing collection structure");
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
unsigned int v1; // er13
__int64 v2; // r12
unsigned int v3; // ebx

verbose(0LL, 48LL, "src/handy_collection.c", "Removing collection from memory");
if ( ptr )
{
if ( *((_QWORD *)ptr + 1) )
{
verbose(0LL, 51LL, "src/handy_collection.c", "Removing allographs from collection");
v1 = *(_DWORD *)ptr;
if ( *(_DWORD *)ptr )
{
v2 = 0LL;
v3 = 0;
do
{
verbose(0LL, 55LL, "src/handy_collection.c", "Removing points of allograph %d of %d from collection", v3, v1);
free(*(void **)(*((_QWORD *)ptr + 1) + v2 + 520));
++v3;
v2 += 528LL;
}
while ( v3 != v1 );
}
}
verbose(0LL, 60LL, "src/handy_collection.c", "Removing collection allographs");
free(*((void **)ptr + 1));
verbose(0LL, 63LL, "src/handy_collection.c", "Removing collection structure");
free(ptr);
}
}

original_code:
void handy_collection_free(handy_collection* collection) {
    verbose(INFO, 48, "src/handy_collection.c", "Removing collection from memory");
    if(collection != ((void *)0)) {
        if(collection->allographs != ((void *)0)) {
            verbose(INFO, 51, "src/handy_collection.c", "Removing allographs from collection");
            int i = 0;
            unsigned int num_allographs = collection->num_allographs;
            for(i = 0; i < num_allographs; i++) {
                verbose(INFO, 55, "src/handy_collection.c", "Removing points of allograph %d of %d from collection", i, num_allographs);
                free(collection->allographs[i].points);
            }
        }
        verbose(INFO, 60, "src/handy_collection.c", "Removing collection allographs");
        free(collection->allographs);
        verbose(INFO, 63, "src/handy_collection.c", "Removing collection structure");
        free(collection);
    }
}

canonical_original_code:
void handy_collection_free(struct handy_collection *collection) {
    verbose(INFO, 48, "src/handy_collection.c", "Removing collection from memory");
    if(collection != ((void *)0)) {
        if(collection->allographs != ((void *)0)) {
            verbose(INFO, 51, "src/handy_collection.c", "Removing allographs from collection");
            int i = 0;
            unsigned int num_allographs = collection->num_allographs;
            for(i = 0; i < num_allographs; i++) {
                verbose(INFO, 55, "src/handy_collection.c", "Removing points of allograph %d of %d from collection", i, num_allographs);
                free(collection->allographs[i].points);
            }
        }
        verbose(INFO, 60, "src/handy_collection.c", "Removing collection allographs");
        free(collection->allographs);
        verbose(INFO, 63, "src/handy_collection.c", "Removing collection structure");
        free(collection);
    }
}

variable_types: i int


decompiled_code:
__int64 __fastcall handy_collection_add_allograph(unsigned int *a1, __int64 a2)
{
unsigned int v3; // esi
char *v4; // rax
__int64 result; // rax

if ( *(_DWORD *)(a2 + 512) )
{
v3 = *a1 + 1;
*a1 = v3;
v4 = (char *)realloc(*((void **)a1 + 1), 528LL * v3);
if ( v4 )
{
*((_QWORD *)a1 + 1) = v4;
handy_allograph_copy(&v4[528 * *a1 - 528], a2);
verbose(0LL, 82LL, "src/handy_collection.c", "Added allograph to collection, number of allographs %d", *a1);
result = 1LL;
}
else
{
verbose(2LL, 76LL, "src/handy_collection.c", "Reallocating memory space for new allographs in the collection");
result = 0LL;
}
}
else
{
verbose(1LL, 86LL, "src/handy_collection.c", "Trying to add an empty allograph to a collection");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1, __int64 a2)
{
unsigned int v3; // esi
char *v4; // rax
__int64 result; // rax

if ( *(_DWORD *)(a2 + 512) )
{
v3 = *a1 + 1;
*a1 = v3;
v4 = (char *)realloc(*((void **)a1 + 1), 528LL * v3);
if ( v4 )
{
*((_QWORD *)a1 + 1) = v4;
handy_allograph_copy(&v4[528 * *a1 - 528], a2);
verbose(0LL, 82LL, "src/handy_collection.c", "Added allograph to collection, number of allographs %d", *a1);
result = 1LL;
}
else
{
verbose(2LL, 76LL, "src/handy_collection.c", "Reallocating memory space for new allographs in the collection");
result = 0LL;
}
}
else
{
verbose(1LL, 86LL, "src/handy_collection.c", "Trying to add an empty allograph to a collection");
result = 0LL;
}
return result;
}

original_code:
int handy_collection_add_allograph(handy_collection* collection, handy_allograph* allograph) {
    handy_allograph* allographs = ((void *)0);
    if(allograph->num_points > 0) {
        collection->num_allographs++;
        allographs = (handy_allograph*) realloc(collection->allographs, sizeof(handy_allograph) * collection->num_allographs);
        if(allographs == ((void *)0)) {
            verbose(ERROR, 76, "src/handy_collection.c", "Reallocating memory space for new allographs in the collection");
            return 0;
        } else {
            collection->allographs = allographs;
            handy_allograph_copy(&collection->allographs[collection->num_allographs -1], allograph);
            verbose(INFO, 82, "src/handy_collection.c", "Added allograph to collection, number of allographs %d", collection->num_allographs);
            return 1;
        }
    } else {
        verbose(WARNING, 86, "src/handy_collection.c", "Trying to add an empty allograph to a collection");
        return 0;
    }
}

canonical_original_code:
int handy_collection_add_allograph(struct handy_collection *collection, struct handy_allograph *allograph) {
    struct handy_allograph *allographs = ((void *)0);
    if(allograph->num_points > 0) {
        collection->num_allographs++;
        allographs = (struct handy_allograph *) realloc(collection->allographs, sizeof(handy_allograph) * collection->num_allographs);
        if(allographs == ((void *)0)) {
            verbose(ERROR, 76, "src/handy_collection.c", "Reallocating memory space for new allographs in the collection");
            return 0;
        } else {
            collection->allographs = allographs;
            handy_allograph_copy(&collection->allographs[collection->num_allographs -1], allograph);
            verbose(INFO, 82, "src/handy_collection.c", "Added allograph to collection, number of allographs %d", collection->num_allographs);
            return 1;
        }
    } else {
        verbose(WARNING, 86, "src/handy_collection.c", "Trying to add an empty allograph to a collection");
        return 0;
    }
}

variable_types:
allograph
struct handy_allograph *


decompiled_code:
_DWORD *handy_allograph_new()
{
_DWORD *result; // rax

result = malloc(0x210uLL);
if ( result )
{
*(_BYTE *)result = 0;
result[128] = 0;
*((_QWORD *)result + 65) = 0LL;
}
return result;
}

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

result = malloc(0x210uLL);
if ( result )
{
*(_BYTE *)result = 0;
result[128] = 0;
*((_QWORD *)result + 65) = 0LL;
}
return result;
}

original_code:
handy_allograph* handy_allograph_new() {
 handy_allograph* allograph = (handy_allograph*) malloc(sizeof(handy_allograph));
 if(allograph == ((void *)0)) {
        return ((void *)0);
    } else {
        allograph->symbol[0] = '\0';
        allograph->num_points = 0;
        allograph->points = ((void *)0);
        return allograph;
    }
}

canonical_original_code:
struct handy_allograph *handy_allograph_new() {
 struct handy_allograph *allograph = (handy_allograph*) malloc(sizeof(handy_allograph));
 if(allograph == ((void *)0)) {
        return ((void *)0);
    } else {
        allograph->symbol[0] = '\0';
        allograph->num_points = 0;
        allograph->points = ((void *)0);
        return allograph;
    }
}

return_type: struct handy_allograph { char symbol[512]; unsigned int num_points; struct handy_point { float x; } *points; } *


decompiled_code:
void __fastcall handy_allograph_free(void *ptr)
{
verbose(0LL, 82LL, "src/handy_allograph.c", "Removing allograph from memory");
if ( ptr )
{
if ( *((_QWORD *)ptr + 65) )
{
verbose(0LL, 85LL, "src/handy_allograph.c", "Removing points from memory");
free(*((void **)ptr + 65));
*((_QWORD *)ptr + 65) = 0LL;
}
verbose(0LL, 90LL, "src/handy_allograph.c", "Removing allograph structure");
free(ptr);
}
else
{
verbose(1LL, 93LL, "src/handy_allograph.c", "Allograph has not been initiated, free not have effect");
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
verbose(0LL, 82LL, "src/handy_allograph.c", "Removing allograph from memory");
if ( ptr )
{
if ( *((_QWORD *)ptr + 65) )
{
verbose(0LL, 85LL, "src/handy_allograph.c", "Removing points from memory");
free(*((void **)ptr + 65));
*((_QWORD *)ptr + 65) = 0LL;
}
verbose(0LL, 90LL, "src/handy_allograph.c", "Removing allograph structure");
free(ptr);
}
else
{
verbose(1LL, 93LL, "src/handy_allograph.c", "Allograph has not been initiated, free not have effect");
}
}

original_code:
void handy_allograph_free(handy_allograph* allograph) {
    verbose(INFO, 82, "src/handy_allograph.c", "Removing allograph from memory");
    if(allograph != ((void *)0)) {
        if(allograph->points != ((void *)0)) {
            verbose(INFO, 85, "src/handy_allograph.c", "Removing points from memory");
            free(allograph->points);
            allograph->points = ((void *)0);
        }
        verbose(INFO, 90, "src/handy_allograph.c", "Removing allograph structure");
        free(allograph);
    } else {
        verbose(WARNING, 93, "src/handy_allograph.c", "Allograph has not been initiated, free not have effect");
    }
}

canonical_original_code:
void handy_allograph_free(struct handy_allograph *allograph) {
    verbose(INFO, 82, "src/handy_allograph.c", "Removing allograph from memory");
    if(allograph != ((void *)0)) {
        if(allograph->points != ((void *)0)) {
            verbose(INFO, 85, "src/handy_allograph.c", "Removing points from memory");
            free(allograph->points);
            allograph->points = ((void *)0);
        }
        verbose(INFO, 90, "src/handy_allograph.c", "Removing allograph structure");
        free(allograph);
    } else {
        verbose(WARNING, 93, "src/handy_allograph.c", "Allograph has not been initiated, free not have effect");
    }
}


decompiled_code:
__int64 __fastcall handy_allograph_add_point(__int64 a1, double a2, float a3)
{
unsigned int v3; // eax
char *v4; // rax
float *v5; // rax
__int64 result; // rax

v3 = *(_DWORD *)(a1 + 512) + 1;
*(_DWORD *)(a1 + 512) = v3;
v4 = (char *)realloc(*(void **)(a1 + 520), 12LL * v3);
if ( v4 )
{
*(_QWORD *)(a1 + 520) = v4;
v5 = (float *)&v4[12 * (*(_DWORD *)(a1 + 512) - 1)];
*(double *)v5 = a2;
v5[2] = a3;
verbose(
0LL,
109LL,
"src/handy_allograph.c",
"Added point %f, %f to the allograph, number of points: %d",
*(float *)&a2,
*((float *)&a2 + 1),
*(unsigned int *)(a1 + 512));
result = 1LL;
}
else
{
verbose(
2LL,
104LL,
"src/handy_allograph.c",
"Reallocating memory space for new points: %f, %f",
*(float *)&a2,
*((float *)&a2 + 1));
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, double a2, float a3)
{
unsigned int v3; // eax
char *v4; // rax
float *v5; // rax
__int64 result; // rax

v3 = *(_DWORD *)(a1 + 512) + 1;
*(_DWORD *)(a1 + 512) = v3;
v4 = (char *)realloc(*(void **)(a1 + 520), 12LL * v3);
if ( v4 )
{
*(_QWORD *)(a1 + 520) = v4;
v5 = (float *)&v4[12 * (*(_DWORD *)(a1 + 512) - 1)];
*(double *)v5 = a2;
v5[2] = a3;
verbose(
0LL,
109LL,
"src/handy_allograph.c",
"Added point %f, %f to the allograph, number of points: %d",
*(float *)&a2,
*((float *)&a2 + 1),
*(unsigned int *)(a1 + 512));
result = 1LL;
}
else
{
verbose(
2LL,
104LL,
"src/handy_allograph.c",
"Reallocating memory space for new points: %f, %f",
*(float *)&a2,
*((float *)&a2 + 1));
result = 0LL;
}
return result;
}

original_code:
int handy_allograph_add_point(handy_allograph* allograph, handy_point point) {
 handy_point* points = ((void *)0);
 allograph->num_points++;
 points = (handy_point*) realloc(allograph->points, sizeof(handy_point) * allograph->num_points);
 if(points == ((void *)0)) {
  verbose(ERROR, 104, "src/handy_allograph.c", "Reallocating memory space for new points: %f, %f", point.x, point.y);
  return 0;
 } else {
  allograph->points = points;
  allograph->points[allograph->num_points - 1] = point;
  verbose(INFO, 109, "src/handy_allograph.c", "Added point %f, %f to the allograph, number of points: %d", point.x, point.y, allograph->num_points);
  return 1;
 }
}

canonical_original_code:
int handy_allograph_add_point(struct handy_allograph *allograph, struct handy_point point) {
 struct handy_point *points = ((void *)0);
 allograph->num_points++;
 points = (struct handy_point *) realloc(allograph->points, sizeof(handy_point) * allograph->num_points);
 if(points == ((void *)0)) {
  verbose(ERROR, 104, "src/handy_allograph.c", "Reallocating memory space for new points: %f, %f", point.x, point.y);
  return 0;
 } else {
  allograph->points = points;
  allograph->points[allograph->num_points - 1] = point;
  verbose(INFO, 109, "src/handy_allograph.c", "Added point %f, %f to the allograph, number of points: %d", point.x, point.y, allograph->num_points);
  return 1;
 }
}

variable_types:
point
struct handy_point

variable_types:
points
struct handy_point { float x; } *


decompiled_code:
__int64 __fastcall handy_allograph_set_symbol(char *dest, char *src)
{
__int64 result; // rax

verbose(0LL, 116LL, "src/handy_allograph.c", "Adding symbol %s to allograph", src);
if ( dest )
{
if ( src )
{
strncpy(dest, src, 0x200uLL);
dest[511] = 0;
verbose(0LL, 127LL, "src/handy_allograph.c", "Symbol %s assigned to allograph", src);
result = 1LL;
}
else
{
verbose(2LL, 122LL, "src/handy_allograph.c", "Trying to set a null symbol at allograph");
result = 0LL;
}
}
else
{
verbose(
2LL,
118LL,
"src/handy_allograph.c",
"Impossible to assign symbol %s to allograph, allograph not initiated",
src);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *dest, char *src)
{
__int64 result; // rax

verbose(0LL, 116LL, "src/handy_allograph.c", "Adding symbol %s to allograph", src);
if ( dest )
{
if ( src )
{
strncpy(dest, src, 0x200uLL);
dest[511] = 0;
verbose(0LL, 127LL, "src/handy_allograph.c", "Symbol %s assigned to allograph", src);
result = 1LL;
}
else
{
verbose(2LL, 122LL, "src/handy_allograph.c", "Trying to set a null symbol at allograph");
result = 0LL;
}
}
else
{
verbose(
2LL,
118LL,
"src/handy_allograph.c",
"Impossible to assign symbol %s to allograph, allograph not initiated",
src);
result = 0LL;
}
return result;
}

original_code:
int handy_allograph_set_symbol(handy_allograph* allograph, char* symbol) {
    verbose(INFO, 116, "src/handy_allograph.c", "Adding symbol %s to allograph", symbol);
    if(allograph == ((void *)0)) {
        verbose(ERROR, 118, "src/handy_allograph.c", "Impossible to assign symbol %s to allograph, allograph not initiated", symbol);
        return 0;
    } else {
        if(symbol == ((void *)0)) {
            verbose(ERROR, 122, "src/handy_allograph.c", "Trying to set a null symbol at allograph");
            return 0;
        } else {
            strncpy(allograph->symbol, symbol, 512);
            allograph->symbol[512 - 1] = '\0';
            verbose(INFO, 127, "src/handy_allograph.c", "Symbol %s assigned to allograph", symbol);
            return 1;
        }
    }
}

canonical_original_code:
int handy_allograph_set_symbol(struct handy_allograph *allograph, char *symbol) {
    verbose(INFO, 116, "src/handy_allograph.c", "Adding symbol %s to allograph", symbol);
    if(allograph == ((void *)0)) {
        verbose(ERROR, 118, "src/handy_allograph.c", "Impossible to assign symbol %s to allograph, allograph not initiated", symbol);
        return 0;
    } else {
        if(symbol == ((void *)0)) {
            verbose(ERROR, 122, "src/handy_allograph.c", "Trying to set a null symbol at allograph");
            return 0;
        } else {
            strncpy(allograph->symbol, symbol, 512);
            allograph->symbol[512 - 1] = '\0';
            verbose(INFO, 127, "src/handy_allograph.c", "Symbol %s assigned to allograph", symbol);
            return 1;
        }
    }
}

variable_types:
symbol
char *


decompiled_code:
__int64 __fastcall handy_allograph_copy(char *dest, char *src)
{
unsigned int v3; // eax
__int64 result; // rax
void *v5; // rdi

verbose(0LL, 50LL, "src/handy_allograph.c", "Creating a copy of an allograph");
if ( src )
{
if ( dest )
{
v3 = *((_DWORD *)src + 128);
if ( !v3 )
{
*((_QWORD *)dest + 65) = 0LL;
LABEL_5:
verbose(0LL, 74LL, "src/handy_allograph.c", "Copying other fields of the source allograph");
handy_allograph_set_symbol(dest, src);
*((_DWORD *)dest + 128) = *((_DWORD *)src + 128);
return 1LL;
}
v5 = malloc(12LL * v3);
*((_QWORD *)dest + 65) = v5;
if ( v5 )
{
memcpy(v5, *((const void **)src + 65), 12LL * *((unsigned int *)src + 128));
goto LABEL_5;
}
verbose(2LL, 65LL, "src/handy_allograph.c", "Impossible to allocate memory for new points");
result = 0LL;
}
else
{
verbose(2LL, 58LL, "src/handy_allograph.c", "Destiny allograph to copy is not initiated");
result = 0LL;
}
}
else
{
verbose(2LL, 53LL, "src/handy_allograph.c", "Source allograph to copy is not initiated");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *dest, char *src)
{
unsigned int v3; // eax
__int64 result; // rax
void *v5; // rdi

verbose(0LL, 50LL, "src/handy_allograph.c", "Creating a copy of an allograph");
if ( src )
{
if ( dest )
{
v3 = *((_DWORD *)src + 128);
if ( !v3 )
{
*((_QWORD *)dest + 65) = 0LL;
LABEL_5:
verbose(0LL, 74LL, "src/handy_allograph.c", "Copying other fields of the source allograph");
func3(dest, src);
*((_DWORD *)dest + 128) = *((_DWORD *)src + 128);
return 1LL;
}
v5 = malloc(12LL * v3);
*((_QWORD *)dest + 65) = v5;
if ( v5 )
{
memcpy(v5, *((const void **)src + 65), 12LL * *((unsigned int *)src + 128));
goto LABEL_5;
}
verbose(2LL, 65LL, "src/handy_allograph.c", "Impossible to allocate memory for new points");
result = 0LL;
}
else
{
verbose(2LL, 58LL, "src/handy_allograph.c", "Destiny allograph to copy is not initiated");
result = 0LL;
}
}
else
{
verbose(2LL, 53LL, "src/handy_allograph.c", "Source allograph to copy is not initiated");
result = 0LL;
}
return result;
}

original_code:
int handy_allograph_copy(handy_allograph* dst, handy_allograph* src) {
    verbose(INFO, 50, "src/handy_allograph.c", "Creating a copy of an allograph");
    if(src == ((void *)0)) {
        verbose(ERROR, 53, "src/handy_allograph.c", "Source allograph to copy is not initiated");
        return 0;
    }
    if(dst == ((void *)0)) {
        verbose(ERROR, 58, "src/handy_allograph.c", "Destiny allograph to copy is not initiated");
        return 0;
    }
    if(src->num_points > 0) {
        dst->points = (handy_point*) malloc(sizeof(handy_point) * src->num_points);
        if(dst->points == ((void *)0)) {
            verbose(ERROR, 65, "src/handy_allograph.c", "Impossible to allocate memory for new points");
            return 0;
        } else {
            memcpy(dst->points, src->points, sizeof(handy_point) * src->num_points);
        }
    } else {
        dst->points = ((void *)0);
    }
    verbose(INFO, 74, "src/handy_allograph.c", "Copying other fields of the source allograph");
    handy_allograph_set_symbol(dst, src->symbol);
    dst->num_points = src->num_points;
    return 1;
}

canonical_original_code:
int handy_allograph_copy(struct handy_allograph *dst, struct handy_allograph *src) {
    verbose(INFO, 50, "src/handy_allograph.c", "Creating a copy of an allograph");
    if(src == ((void *)0)) {
        verbose(ERROR, 53, "src/handy_allograph.c", "Source allograph to copy is not initiated");
        return 0;
    }
    if(dst == ((void *)0)) {
        verbose(ERROR, 58, "src/handy_allograph.c", "Destiny allograph to copy is not initiated");
        return 0;
    }
    if(src->num_points > 0) {
        dst->points = (struct handy_point *) malloc(sizeof(handy_point) * src->num_points);
        if(dst->points == ((void *)0)) {
            verbose(ERROR, 65, "src/handy_allograph.c", "Impossible to allocate memory for new points");
            return 0;
        } else {
            memcpy(dst->points, src->points, sizeof(handy_point) * src->num_points);
        }
    } else {
        dst->points = ((void *)0);
    }
    verbose(INFO, 74, "src/handy_allograph.c", "Copying other fields of the source allograph");
    handy_allograph_set_symbol(dst, src->symbol);
    dst->num_points = src->num_points;
    return 1;
}

variable_types:
src
struct handy_allograph *


original_code:
handy_uint handy_allograph_points_contained(handy_allograph* allograph, handy_rect rect) {
  handy_point point;
  handy_uint points_contained = 0;
  handy_float maximum_x, maximum_y;
  maximum_x = rect.origin.x + rect.size.width;
  maximum_y = rect.origin.y + rect.size.height;
  unsigned int i;
  for (i = 0; i < allograph->num_points; i++) {
    point.x = allograph->points[i].x;
    if (point.x >= rect.origin.x && point.x <= maximum_x) {
      point.y = allograph->points[i].y;
      if (point.y >= rect.origin.y && point.y <= maximum_y) {
        points_contained++;
      }
    }
  }
  return points_contained;
}

canonical_original_code:
unsigned int handy_allograph_points_contained(struct handy_allograph *allograph, struct handy_rect rect) {
  struct handy_point point;
  unsigned int points_contained = 0;
  float maximum_x; float maximum_y;
  maximum_x = rect.origin.x + rect.size.width;
  maximum_y = rect.origin.y + rect.size.height;
  unsigned int i;
  for (i = 0; i < allograph->num_points; i++) {
    point.x = allograph->points[i].x;
    if (point.x >= rect.origin.x && point.x <= maximum_x) {
      point.y = allograph->points[i].y;
      if (point.y >= rect.origin.y && point.y <= maximum_y) {
        points_contained++;
      }
    }
  }
  return points_contained;
}

variable_types: struct handy_rect { struct handy_point origin; struct handy_size { float width; } size; }

variable_types:
point
struct handy_point { float x; }

variable_types:
i
unsigned int

user_defined_types: struct handy_rect { struct handy_point origin; struct handy_size size; }