power

decompiled_code:
__int64 __fastcall power(char a1, int a2)
{
unsigned int v2; // edi
int v3; // esi
int v4; // edx
int v5; // eax

v2 = a1 - 48;
if ( a2 )
{
if ( a2 <= 0 )
{
v5 = 1;
}
else
{
v3 = a2 + 1;
v4 = 1;
v5 = 1;
do
{
v5 *= 10;
++v4;
}
while ( v4 != v3 );
}
v2 *= v5;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1, int a2)
{
unsigned int v2; // edi
int v3; // esi
int v4; // edx
int v5; // eax

v2 = a1 - 48;
if ( a2 )
{
if ( a2 <= 0 )
{
v5 = 1;
}
else
{
v3 = a2 + 1;
v4 = 1;
v5 = 1;
do
{
v5 *= 10;
++v4;
}
while ( v4 != v3 );
}
v2 *= v5;
}
return v2;
}

original_code:
static int power(char c, int pow)
{
 int out;
 int i;
 int char_value;
 char_value = c - 48;
 out = 1;
 i = 1;
 if (pow == 0)
  return (char_value);
 while (i <= pow)
 {
  out = out * 10;
  i++;
 }
 return (out * char_value);
}

variable_types: pow int


powerize

original_code:
static int powerize(const char *str, int start, int end)
{
 int power_val;
 int out;
 int is_negative;
 power_val = 0;
 out = 0;
 is_negative = (str[start] == '-');
 while (end >= start)
 {
  if (!is_operator(str[end]))
  {
   out += power(str[end], power_val);
   power_val++;
  }
  end--;
 }
 if (is_negative)
  return (out * -1);
 return (out);
}

canonical_original_code:
static int powerize(char *str, int start, int end)
{
 int power_val;
 int out;
 int is_negative;
 power_val = 0;
 out = 0;
 is_negative = (str[start] == '-');
 while (end >= start)
 {
  if (!is_operator(str[end]))
  {
   out += power(str[end], power_val);
   power_val++;
  }
  end--;
 }
 if (is_negative)
  return (out * -1);
 return (out);
}

variable_types:
str
char *

variable_types: start int

variable_types: end int

variable_types: out int

return_type: int


decompiled_code:
__int64 __fastcall is_authorized(char a1)
{
_BYTE *v1; // rax
unsigned int v2; // edx
__int64 v4; // rdx
_BOOL4 v5; // eax

v1 = &authorized_0;
v2 = 0;
do
v2 += *v1++ == (unsigned __int8)a1;
while ( v1 != (_BYTE *)465 );
if ( v2 )
return v2;
if ( (unsigned int)ft_isalpha((unsigned int)a1, 465LL)
|| !(unsigned int)ft_isascii((unsigned int)a1)
|| (v5 = is_operator(a1), v4 = 1LL, !v5) )
{
LODWORD(v4) = ft_isdigit((unsigned int)a1, 465LL, v4) != 0;
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(char a1)
{
_BYTE *v1; // rax
unsigned int v2; // edx
__int64 v4; // rdx
_BOOL4 v5; // eax

v1 = &authorized_0;
v2 = 0;
do
v2 += *v1++ == (unsigned __int8)a1;
while ( v1 != (_BYTE *)465 );
if ( v2 )
return v2;
if ( (unsigned int)ft_isalpha((unsigned int)a1, 465LL)
|| !(unsigned int)ft_isascii((unsigned int)a1)
|| (v5 = func0(a1), v4 = 1LL, !v5) )
{
LODWORD(v4) = ft_isdigit((unsigned int)a1, 465LL, v4) != 0;
}
return (unsigned int)v4;
}

original_code:
static int is_authorized(char c)
{
 static char authorized[6] = {'\n', '\v', '\t', '\r', '\f', ' '};
 int i;
 int valid;
 valid = 0;
 i = 0;
 while (i < 6)
 {
  if (c == authorized[i])
   valid++;
  i++;
 }
 if (!valid)
 {
  valid = (ft_isalpha(c) || !ft_isascii(c) || !is_operator(c));
  if (valid && !ft_isdigit(c))
   valid = 0;
  else
   valid = 1;
 }
 return (valid);
}

variable_types: c char

variable_types:
authorized
char [6]

variable_types: i int

variable_types: valid int


decompiled_code:
__int64 __fastcall ft_atoi(char *a1, __int64 a2)
{
char v3; // di
char *v4; // rbp
int v5; // er12
__int64 result; // rax
unsigned int v7; // ebx
__int64 v8; // rdx
int v9; // ebx
__int64 v10; // rbp

v3 = *a1;
if ( v3 )
{
v4 = a1;
v5 = 0;
while ( 1 )
{
result = is_authorized(v3);
if ( !(_DWORD)result )
break;
v7 = *v4;
if ( is_operator(*v4) || (v9 = ft_isdigit(v7, a2, v8)) != 0 )
{
v10 = v5 + 1;
do
v9 = v10;
while ( (unsigned int)ft_isdigit((unsigned int)a1[v10++], a2, v8) );
goto LABEL_10;
}
++v5;
v3 = *++v4;
if ( !*v4 )
goto LABEL_10;
}
}
else
{
v5 = 0;
v9 = 0;
LABEL_10:
result = powerize((__int64)a1, v5, v9 - 1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, __int64 a2)
{
char v3; // di
char *v4; // rbp
int v5; // er12
__int64 result; // rax
unsigned int v7; // ebx
__int64 v8; // rdx
int v9; // ebx
__int64 v10; // rbp

v3 = *a1;
if ( v3 )
{
v4 = a1;
v5 = 0;
while ( 1 )
{
result = func3(v3);
if ( !(_DWORD)result )
break;
v7 = *v4;
if ( func0(*v4) || (v9 = ft_isdigit(v7, a2, v8)) != 0 )
{
v10 = v5 + 1;
do
v9 = v10;
while ( (unsigned int)ft_isdigit((unsigned int)a1[v10++], a2, v8) );
goto LABEL_10;
}
++v5;
v3 = *++v4;
if ( !*v4 )
goto LABEL_10;
}
}
else
{
v5 = 0;
v9 = 0;
LABEL_10:
result = func2((__int64)a1, v5, v9 - 1);
}
return result;
}

original_code:
int ft_atoi(const char *str)
{
 int i;
 int j;
 int out;
 i = 0;
 j = 0;
 out = 0;
 while (str[i])
 {
  if (!is_authorized(str[i]))
   return (0);
  if (is_operator(str[i]) || ft_isdigit(str[i]))
  {
   j = i + 1;
   while (ft_isdigit(str[j]))
    j++;
   break ;
  }
  i++;
 }
 return (powerize(str, i, (j - 1)));
}

canonical_original_code:
int ft_atoi(char *str)
{
 int i;
 int j;
 int out;
 i = 0;
 j = 0;
 out = 0;
 while (str[i])
 {
  if (!is_authorized(str[i]))
   return (0);
  if (is_operator(str[i]) || ft_isdigit(str[i]))
  {
   j = i + 1;
   while (ft_isdigit(str[j]))
    j++;
   break ;
  }
  i++;
 }
 return (powerize(str, i, (j - 1)));
}

variable_types: j int


decompiled_code:
__int64 __fastcall lab_sanitizelexerlabel(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rbx

v1 = (*(_DWORD *)a1 != 256) + ft_strlen(*(_QWORD *)(a1 + 8)) - 2;
v2 = ft_strnew(v1 + 1);
if ( !v2 )
impossible_malloc("char in lab_sanitizelexerlabel");
ft_memcpy(v2, *(_QWORD *)(a1 + 8) + 2LL, v1);
return v2;
}

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

v1 = (*(_DWORD *)a1 != 256) + ft_strlen(*(_QWORD *)(a1 + 8)) - 2;
v2 = ft_strnew(v1 + 1);
if ( !v2 )
impossible_malloc("char in lab_sanitizelexerlabel");
ft_memcpy(v2, *(_QWORD *)(a1 + 8) + 2LL, v1);
return v2;
}

original_code:
static char *lab_sanitizelexerlabel(t_lexer *lexer)
{
 size_t len;
 char *out;
 len = ft_strlen(lexer->value);
 len = (lexer->token == DIR_LAB ? len - 2 : len - 1);
 if ((out = ft_strnew(len + 1)) == ((void *)0))
  impossible_malloc("char in lab_sanitizelexerlabel");
 ft_memcpy(out, (lexer->value + 2), len);
 return (out);
}

canonical_original_code:
static char *lab_sanitizelexerlabel(struct s_lexer *lexer)
{
 unsigned long len;
 char *out;
 len = ft_strlen(lexer->value);
 len = (lexer->token == DIR_LAB ? len - 2 : len - 1);
 if ((out = ft_strnew(len + 1)) == ((void *)0))
  impossible_malloc("char in lab_sanitizelexerlabel");
 ft_memcpy(out, (lexer->value + 2), len);
 return (out);
}

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

variable_types:
len
unsigned long

variable_types:
out
char *

return_type: char *

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


decompiled_code:
__int64 __fastcall lab_sanitizelabel(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rbp

v1 = ft_strlen(a1);
v2 = ft_strnew(v1);
if ( !v2 )
impossible_malloc("char in lab_sanitizelabel");
ft_memcpy(v2, a1, v1 - 1);
return v2;
}

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

v1 = ft_strlen(a1);
v2 = ft_strnew(v1);
if ( !v2 )
impossible_malloc("char in lab_sanitizelabel");
ft_memcpy(v2, a1, v1 - 1);
return v2;
}

original_code:
static char *lab_sanitizelabel(char *label)
{
 size_t len;
 char *out;
 len = ft_strlen(label);
 if ((out = ft_strnew(len)) == ((void *)0))
  impossible_malloc("char in lab_sanitizelabel");
 ft_memcpy(out, label, len - 1);
 return (out);
}

canonical_original_code:
static char *lab_sanitizelabel(char *label)
{
 unsigned long len;
 char *out;
 len = ft_strlen(label);
 if ((out = ft_strnew(len)) == ((void *)0))
  impossible_malloc("char in lab_sanitizelabel");
 ft_memcpy(out, label, len - 1);
 return (out);
}

variable_types:
label
char *


decompiled_code:
__int64 __fastcall lab_checkexistence(__int64 a1, __int64 *a2)
{
__int64 *v2; // rbx
void *v3; // r13
void *v4; // r12
unsigned int v5; // ebp

v2 = a2;
v3 = (void *)lab_sanitizelexerlabel(a1);
if ( a2 )
{
while ( 1 )
{
v4 = (void *)lab_sanitizelabel(*v2);
v5 = ft_strcmp(v3, v4);
if ( !v5 )
break;
v2 = (__int64 *)v2[2];
if ( !v2 )
goto LABEL_4;
}
free(v4);
free(v3);
}
else
{
LABEL_4:
err_badlabel(v3);
free(v3);
v5 = -1;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 *a2)
{
__int64 *v2; // rbx
void *v3; // r13
void *v4; // r12
unsigned int v5; // ebp

v2 = a2;
v3 = (void *)func0(a1);
if ( a2 )
{
while ( 1 )
{
v4 = (void *)func1(*v2);
v5 = ft_strcmp(v3, v4);
if ( !v5 )
break;
v2 = (__int64 *)v2[2];
if ( !v2 )
goto LABEL_4;
}
free(v4);
free(v3);
}
else
{
LABEL_4:
err_badlabel(v3);
free(v3);
v5 = -1;
}
return v5;
}

original_code:
static int lab_checkexistence(t_lexer *lexer, t_label *label)
{
 t_label *tmp;
 char *lex_label;
 char *lab_label;
 tmp = label;
 lex_label = lab_sanitizelexerlabel(lexer);
 while (tmp)
 {
  lab_label = lab_sanitizelabel(tmp->name);
  if (ft_strcmp(lex_label, lab_label) == 0)
  {
   free(lab_label);
   break ;
  }
  tmp = tmp->next;
 }
 if (tmp == ((void *)0))
 {
  err_badlabel(lex_label);
  free(lex_label);
  return (-1);
 }
 free(lex_label);
 return (0);
}

canonical_original_code:
static int lab_checkexistence(struct s_lexer *lexer, struct s_label *label)
{
 struct s_label *tmp;
 char *lex_label;
 char *lab_label;
 tmp = label;
 lex_label = lab_sanitizelexerlabel(lexer);
 while (tmp)
 {
  lab_label = lab_sanitizelabel(tmp->name);
  if (ft_strcmp(lex_label, lab_label) == 0)
  {
   free(lab_label);
   break ;
  }
  tmp = tmp->next;
 }
 if (tmp == ((void *)0))
 {
  err_badlabel(lex_label);
  free(lex_label);
  return (-1);
 }
 free(lex_label);
 return (0);
}

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

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


decompiled_code:
__int64 __fastcall lab_check(__int64 a1, __int64 *a2)
{
__int64 v2; // rbx

v2 = a1;
if ( !a1 )
return 0LL;
do
{
if ( ((*(_DWORD *)v2 - 256) & 0xFFFFFEFF) == 0 && (unsigned int)lab_checkexistence(v2, a2) )
return 0xFFFFFFFFLL;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 *a2)
{
__int64 v2; // rbx

v2 = a1;
if ( !a1 )
return 0LL;
do
{
if ( ((*(_DWORD *)v2 - 256) & 0xFFFFFEFF) == 0 && (unsigned int)func2(v2, a2) )
return 0xFFFFFFFFLL;
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return 0LL;
}

original_code:
int lab_check(t_lexer *lexer, t_label *label)
{
 while (lexer)
 {
  if (lexer->token == DIR_LAB || lexer->token == IND_LAB)
  {
   if (lab_checkexistence(lexer, label) != 0)
    return (-1);
  }
  lexer = lexer->next;
 }
 return (0);
}

canonical_original_code:
int lab_check(struct s_lexer *lexer, struct s_label *label)
{
 while (lexer)
 {
  if (lexer->token == DIR_LAB || lexer->token == IND_LAB)
  {
   if (lab_checkexistence(lexer, label) != 0)
    return (-1);
  }
  lexer = lexer->next;
 }
 return (0);
}

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


decompiled_code:
ssize_t __fastcall wri_write_direct(__int64 a1, int *a2)
{
ssize_t result; // rax
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a2[4] == 1 )
{
buf[0] = swa_swap_char_by_params(*(_QWORD *)(a1 + 8), 2LL, 0LL);
result = write(*a2, buf, 2uLL);
a2[2] += 2;
}
else
{
buf[0] = swa_swap_char_by_params(*(_QWORD *)(a1 + 8), 4LL, 0LL);
result = write(*a2, buf, 4uLL);
a2[2] += 4;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func0(__int64 a1, int *a2)
{
ssize_t result; // rax
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a2[4] == 1 )
{
buf[0] = swa_swap_char_by_params(*(_QWORD *)(a1 + 8), 2LL, 0LL);
result = write(*a2, buf, 2uLL);
a2[2] += 2;
}
else
{
buf[0] = swa_swap_char_by_params(*(_QWORD *)(a1 + 8), 4LL, 0LL);
result = write(*a2, buf, 4uLL);
a2[2] += 4;
}
return result;
}

original_code:
void wri_write_direct(t_lexer *lexer, t_adr *adr)
{
 int i;
 if (adr->getindex == 1)
 {
  i = swa_swap_char_by_params(lexer->value, 2, 0);
  write(adr->fd, &i, 2);
  adr->currentpos += 2;
 }
 else
 {
  i = swa_swap_char_by_params(lexer->value, 4, 0);
  write(adr->fd, &i, 4);
  adr->currentpos += 4;
 }
}

canonical_original_code:
void wri_write_direct(struct s_lexer *lexer, struct s_adr *adr)
{
 int i;
 if (adr->getindex == 1)
 {
  i = swa_swap_char_by_params(lexer->value, 2, 0);
  write(adr->fd, &i, 2);
  adr->currentpos += 2;
 }
 else
 {
  i = swa_swap_char_by_params(lexer->value, 4, 0);
  write(adr->fd, &i, 4);
  adr->currentpos += 4;
 }
}

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

return_type: void


decompiled_code:
ssize_t __fastcall wri_calc_opcode(int *a1, int *a2)
{
int v2; // eax
char v3; // cl
int v4; // ebx
ssize_t result; // rax
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

++a2[2];
buf[0] = 0;
v2 = *a1;
if ( *a1 == 2048 )
{
v4 = 0;
}
else
{
v3 = 6;
v4 = 0;
do
{
++v4;
switch ( v2 )
{
case 1:
buf[0] += 1 << v3;
break;
case 2:
buf[0] += 3 << v3;
break;
case 4:
case 256:
buf[0] += 2 << v3;
break;
}
a1 = (int *)*((_QWORD *)a1 + 2);
v2 = *a1;
v3 -= 2;
}
while ( *a1 != 2048 );
}
result = write(*a2, buf, 1uLL);
if ( a2[4] == 1 )
a2[5] = v4;
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func1(int *a1, int *a2)
{
int v2; // eax
char v3; // cl
int v4; // ebx
ssize_t result; // rax
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

++a2[2];
buf[0] = 0;
v2 = *a1;
if ( *a1 == 2048 )
{
v4 = 0;
}
else
{
v3 = 6;
v4 = 0;
do
{
++v4;
switch ( v2 )
{
case 1:
buf[0] += 1 << v3;
break;
case 2:
buf[0] += 3 << v3;
break;
case 4:
case 256:
buf[0] += 2 << v3;
break;
}
a1 = (int *)*((_QWORD *)a1 + 2);
v2 = *a1;
v3 -= 2;
}
while ( *a1 != 2048 );
}
result = write(*a2, buf, 1uLL);
if ( a2[4] == 1 )
a2[5] = v4;
return result;
}

original_code:
void wri_calc_opcode(t_lexer *lexer, t_adr *adr, t_label *label)
{
 int i;
 int j;
 int res;
 t_lexer *save;
 adr->currentpos += 1;
 (void)label;
 res = j = 0;
 i = 4;
 save = lexer;
 while (i--, lexer->token != ENDOFLINE)
 {
  j++;
  if (lexer->token == REG)
   res += (1 << (i * 2));
  else if (lexer->token == IND)
   res += (3 << (i * 2));
  else if (lexer->token == DIR || lexer->token == DIR_LAB)
   res += (2 << (i * 2));
  lexer = lexer->next;
 }
 write(adr->fd, &res, 1);
 if (adr->getindex == 1)
  adr->index = j;
}

canonical_original_code:
void wri_calc_opcode(struct s_lexer *lexer, struct s_adr *adr, struct s_label *label)
{
 int i;
 int j;
 int res;
 struct s_lexer *save;
 adr->currentpos += 1;
 (void)label;
 res = j = 0;
 i = 4;
 save = lexer;
 while (i--, lexer->token != ENDOFLINE)
 {
  j++;
  if (lexer->token == REG)
   res += (1 << (i * 2));
  else if (lexer->token == IND)
   res += (3 << (i * 2));
  else if (lexer->token == DIR || lexer->token == DIR_LAB)
   res += (2 << (i * 2));
  lexer = lexer->next;
 }
 write(adr->fd, &res, 1);
 if (adr->getindex == 1)
  adr->index = j;
}

variable_types: res int

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


decompiled_code:
__int64 __fastcall wri_change_name(void **a1)
{
__int64 v1; // rbp
void **v2; // r13
__int64 v3; // r12
__int64 result; // rax

v1 = ft_strsplit(*a1, 47LL);
v2 = (void **)(v1 + 8LL * (int)ft_countsplit(v1) - 8);
v3 = ft_strsplit(*v2, 46LL);
free(*(void **)(v3 + 8));
*(_QWORD *)(v3 + 8) = ft_strdup(&unk_306);
free(*v2);
*v2 = (void *)ft_strglue(v3, 46LL);
free(*a1);
result = ft_strglue(v1, 47LL);
*a1 = (void *)result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(void **a1)
{
__int64 v1; // rbp
void **v2; // r13
__int64 v3; // r12
__int64 result; // rax

v1 = ft_strsplit(*a1, 47LL);
v2 = (void **)(v1 + 8LL * (int)ft_countsplit(v1) - 8);
v3 = ft_strsplit(*v2, 46LL);
free(*(void **)(v3 + 8));
*(_QWORD *)(v3 + 8) = ft_strdup(&unk_306);
free(*v2);
*v2 = (void *)ft_strglue(v3, 46LL);
free(*a1);
result = ft_strglue(v1, 47LL);
*a1 = (void *)result;
return result;
}

original_code:
void wri_change_name(t_start *start)
{
 int i;
 char **path;
 char **filename;
 path = ft_strsplit(start->filename, '/');
 i = ft_countsplit(path);
 filename = ft_strsplit(path[i - 1], '.');
 free(filename[1]);
 filename[1] = ft_strdup("cor");
 free(path[i - 1]);
 path[i - 1] = ft_strglue(filename, '.');
 free(start->filename);
 start->filename = ft_strglue(path, '/');
}

canonical_original_code:
void wri_change_name(struct s_start *start)
{
 int i;
 char **path;
 char **filename;
 path = ft_strsplit(start->filename, '/');
 i = ft_countsplit(path);
 filename = ft_strsplit(path[i - 1], '.');
 free(filename[1]);
 filename[1] = ft_strdup("cor");
 free(path[i - 1]);
 path[i - 1] = ft_strglue(filename, '.');
 free(start->filename);
 start->filename = ft_strglue(path, '/');
}

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

variable_types:
path
char **

variable_types:
filename
char **

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


decompiled_code:
ssize_t __fastcall wri_write_magic_number(int *a1)
{
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = -209458688;
return write(*a1, buf, 4uLL);
}

canonical_decompiled_code:
ssize_t __fastcall func3(int *a1)
{
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = -209458688;
return write(*a1, buf, 4uLL);
}

canonical_original_code:
void wri_write_magic_number(struct s_adr *adr)
{
 int i;
 int swap;
 i = 0xea83f3;
 swap = ((i >> 24) & 0xff)
  | ((i << 8) & 0xff0000)
  | ((i >> 8) & 0xff00)
  | ((i << 24) & 0xff000000);
 write(adr->fd, &swap, 4);
}

variable_types: swap int


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

wri_write_magic_number(a2);
buf[0] = ft_strlen(*(_QWORD *)(a1 + 8));
write(*a2, (const void *)(*(_QWORD *)(a1 + 8) + 1LL), buf[0] - 2);
for ( buf[0] -= 2; buf[0] <= 128; ++buf[0] )
write(*a2, &unk_30A, 1uLL);
for ( ; (buf[0] & 3) != 0; ++buf[0] )
write(*a2, &unk_30A, 1uLL);
buf[0] = swa_swap_int_by_params(*(unsigned int *)(a1 + 24), 4LL);
write(*a2, buf, 4uLL);
buf[0] = ft_strlen(*(_QWORD *)(a1 + 16));
write(*a2, (const void *)(*(_QWORD *)(a1 + 16) + 1LL), buf[0] - 2);
result = (unsigned int)(buf[0] - 2);
for ( buf[0] = result; (int)result <= 2048; buf[0] = result )
{
write(*a2, &unk_30A, 1uLL);
result = (unsigned int)(buf[0] + 1);
}
if ( (buf[0] & 3) != 0 )
{
do
{
write(*a2, &unk_30A, 1uLL);
result = (unsigned int)(buf[0] + 1);
buf[0] = result;
}
while ( (result & 3) != 0 );
}
return result;
}

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

func3(a2);
buf[0] = ft_strlen(*(_QWORD *)(a1 + 8));
write(*a2, (const void *)(*(_QWORD *)(a1 + 8) + 1LL), buf[0] - 2);
for ( buf[0] -= 2; buf[0] <= 128; ++buf[0] )
write(*a2, &unk_30A, 1uLL);
for ( ; (buf[0] & 3) != 0; ++buf[0] )
write(*a2, &unk_30A, 1uLL);
buf[0] = swa_swap_int_by_params(*(unsigned int *)(a1 + 24), 4LL);
write(*a2, buf, 4uLL);
buf[0] = ft_strlen(*(_QWORD *)(a1 + 16));
write(*a2, (const void *)(*(_QWORD *)(a1 + 16) + 1LL), buf[0] - 2);
result = (unsigned int)(buf[0] - 2);
for ( buf[0] = result; (int)result <= 2048; buf[0] = result )
{
write(*a2, &unk_30A, 1uLL);
result = (unsigned int)(buf[0] + 1);
}
if ( (buf[0] & 3) != 0 )
{
do
{
write(*a2, &unk_30A, 1uLL);
result = (unsigned int)(buf[0] + 1);
buf[0] = result;
}
while ( (result & 3) != 0 );
}
return result;
}

original_code:
void wri_write_name_and_comment(t_start *start, t_adr *adr)
{
 int i;
 wri_write_magic_number(adr);
 i = ft_strlen(start->name);
 write(adr->fd, start->name + 1, i - 2);
 i -= 3;
 while (i++, i < (128) + 1)
  write(adr->fd, "\0", 1);
 while ((i % 4) != 0)
 {
  write(adr->fd, "\0", 1);
  i++;
 }
 i = swa_swap_int_by_params(start->prog_size, 4);
 write(adr->fd, &i, 4);
 i = ft_strlen(start->comment);
 write(adr->fd, start->comment + 1, i - 2);
 i -= 3;
 while (i++, i < (2048) + 1)
  write(adr->fd, "\0", 1);
 while ((i % 4) != 0)
 {
  write(adr->fd, "\0", 1);
  i++;
 }
}

canonical_original_code:
void wri_write_name_and_comment(struct s_start *start, struct s_adr *adr)
{
 int i;
 wri_write_magic_number(adr);
 i = ft_strlen(start->name);
 write(adr->fd, start->name + 1, i - 2);
 i -= 3;
 while (i++, i < (128) + 1)
  write(adr->fd, "\0", 1);
 while ((i % 4) != 0)
 {
  write(adr->fd, "\0", 1);
  i++;
 }
 i = swa_swap_int_by_params(start->prog_size, 4);
 write(adr->fd, &i, 4);
 i = ft_strlen(start->comment);
 write(adr->fd, start->comment + 1, i - 2);
 i -= 3;
 while (i++, i < (2048) + 1)
  write(adr->fd, "\0", 1);
 while ((i % 4) != 0)
 {
  write(adr->fd, "\0", 1);
  i++;
 }
}


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

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

original_code:
t_op *ft_list_push_back(t_op *op, t_op *new)
{
 t_op *save;
 save = op;
 if (op == ((void *)0))
  return (new);
 while (op->next != ((void *)0))
  op = op->next;
 op->next = new;
 return (save);
}

canonical_original_code:
struct s_option *ft_list_push_back(struct s_option *op, struct s_option *new)
{
 struct s_option *save;
 save = op;
 if (op == ((void *)0))
  return (new);
 while (op->next != ((void *)0))
  op = op->next;
 op->next = new;
 return (save);
}

variable_types:
op
struct s_option *

variable_types:
new
struct s_option *

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


original_code:
t_op *ft_analyse_str(char *str, t_op *op)
{
 int i;
 int j;
 i = 0;
 j = 0;
 while (str[i] != '\0')
 {
  while (str[i] != '%' && str[i] != '\0')
   i++;
  if (str[i] == '%')
  {
   if (str[i + 1] == '%' || str[i + 1] == 'Z')
    j = 1;
   i += 1;
   op = ft_build_list(op, str, &i, j);
  }
 }
 return (op);
}

canonical_original_code:
struct s_option *ft_analyse_str(char *str, struct s_option *op)
{
 int i;
 int j;
 i = 0;
 j = 0;
 while (str[i] != '\0')
 {
  while (str[i] != '%' && str[i] != '\0')
   i++;
  if (str[i] == '%')
  {
   if (str[i + 1] == '%' || str[i + 1] == 'Z')
    j = 1;
   i += 1;
   op = ft_build_list(op, str, &i, j);
  }
 }
 return (op);
}

variable_types:
str
char *

variable_types: i int

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


variable_types: j int

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


decompiled_code:
__int64 __fastcall lex_iscmd_name(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

if ( (unsigned int)ft_strcmp(a2, ".name") )
return (unsigned int)-1;
v2 = 0;
lex_addlex(a1, a2, 64LL);
return v2;
}

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

if ( (unsigned int)ft_strcmp(a2, ".name") )
return (unsigned int)-1;
v2 = 0;
lex_addlex(a1, a2, 64LL);
return v2;
}

original_code:
int lex_iscmd_name(t_lexer **list, char *word)
{
 int ret;
 ret = ft_strcmp(word, ".name");
 if (!ret)
 {
  lex_addlex(list, word, CMD_NAME);
  return (0);
 }
 return (-1);
}

canonical_original_code:
int lex_iscmd_name(struct s_lexer **list, char *word)
{
 int ret;
 ret = ft_strcmp(word, ".name");
 if (!ret)
 {
  lex_addlex(list, word, CMD_NAME);
  return (0);
 }
 return (-1);
}

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

variable_types:
word
char *

variable_types: ret int


decompiled_code:
__int64 __fastcall lex_iscmd_com(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

if ( (unsigned int)ft_strcmp(a2, ".comment") )
return (unsigned int)-1;
v2 = 0;
lex_addlex(a1, a2, 128LL);
return v2;
}

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

if ( (unsigned int)ft_strcmp(a2, ".comment") )
return (unsigned int)-1;
v2 = 0;
lex_addlex(a1, a2, 128LL);
return v2;
}

original_code:
int lex_iscmd_com(t_lexer **list, char *word)
{
 int ret;
 ret = ft_strcmp(word, ".comment");
 if (!ret)
 {
  lex_addlex(list, word, CMD_COM);
  return (0);
 }
 return (-1);
}

canonical_original_code:
int lex_iscmd_com(struct s_lexer **list, char *word)
{
 int ret;
 ret = ft_strcmp(word, ".comment");
 if (!ret)
 {
  lex_addlex(list, word, CMD_COM);
  return (0);
 }
 return (-1);
}


original_code:
int lex_iscmd(t_lexer **list, char *word)
{
 char *cmd[16] = {"lfork", "sti", "fork", "lld", "ld", "add", "zjmp",
  "sub", "ldi", "or", "st", "aff", "live", "xor", "lldi", "and"};
 int i;
 i = 0;
 while (i < 16)
 {
  if (ft_strcmp(word, cmd[i]) == 0)
  {
   lex_addlex(list, word, OP);
   return (0);
  }
  i++;
 }
 return (-1);
}

canonical_original_code:
int lex_iscmd(struct s_lexer **list, char *word)
{
 char *cmd[16] = {"lfork", "sti", "fork", "lld", "ld", "add", "zjmp",
  "sub", "ldi", "or", "st", "aff", "live", "xor", "lldi", "and"};
 int i;
 i = 0;
 while (i < 16)
 {
  if (ft_strcmp(word, cmd[i]) == 0)
  {
   lex_addlex(list, word, OP);
   return (0);
  }
  i++;
 }
 return (-1);
}

variable_types:
cmd
char *[16]


decompiled_code:
__int64 __fastcall lex_strnum(_BYTE *a1)
{
char *v1; // rdi
char v2; // al

v1 = &a1[*a1 == 45];
v2 = *v1;
if ( !*v1 )
return 0LL;
while ( (unsigned __int8)(v2 - 48) <= 9u )
{
v2 = *++v1;
if ( !*v1 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1)
{
char *v1; // rdi
char v2; // al

v1 = &a1[*a1 == 45];
v2 = *v1;
if ( !*v1 )
return 0LL;
while ( (unsigned __int8)(v2 - 48) <= 9u )
{
v2 = *++v1;
if ( !*v1 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int lex_strnum(char *str)
{
 int i;
 i = 0;
 if (str[i] == '-')
  i++;
 while (str[i])
 {
  if (str[i] < 48 || str[i] > 57)
   return (-1);
  i++;
 }
 return (0);
}


decompiled_code:
__int64 __fastcall lex_isreg(__int64 a1, _BYTE *a2)
{
unsigned int v2; // ebp

if ( *a2 != 114 )
return (unsigned int)-1;
v2 = lex_strnum(a2 + 1);
if ( v2 )
return (unsigned int)-1;
if ( (int)ft_atoi(a2 + 1) < 0 )
return (unsigned int)-1;
if ( (int)ft_atoi(a2 + 1) > 16 )
return (unsigned int)-1;
lex_addlex(a1, a2, 1LL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _BYTE *a2)
{
unsigned int v2; // ebp

if ( *a2 != 114 )
return (unsigned int)-1;
v2 = func3(a2 + 1);
if ( v2 )
return (unsigned int)-1;
if ( (int)ft_atoi(a2 + 1) < 0 )
return (unsigned int)-1;
if ( (int)ft_atoi(a2 + 1) > 16 )
return (unsigned int)-1;
lex_addlex(a1, a2, 1LL);
return v2;
}

original_code:
int lex_isreg(t_lexer **list, char *word)
{
 if (*word == 'r')
 {
  word++;
  if (lex_strnum(word) == 0 && ft_atoi(word) >= 0 && ft_atoi(word) <= 16)
  {
   lex_addlex(list, --word, REG);
   return (0);
  }
 }
 return (-1);
}

canonical_original_code:
int lex_isreg(struct s_lexer **list, char *word)
{
 if (*word == 'r')
 {
  word++;
  if (lex_strnum(word) == 0 && ft_atoi(word) >= 0 && ft_atoi(word) <= 16)
  {
   lex_addlex(list, --word, REG);
   return (0);
  }
 }
 return (-1);
}


decompiled_code:
__int64 __fastcall cpy_to_arena(__int64 a1, __int64 a2, int a3, int a4)
{
__int64 v4; // r13
__int64 v5; // rbx
int v6; // ebp
__int64 result; // rax

if ( a4 > 0 )
{
v4 = a1 + (unsigned int)(a4 - 1) + 1;
v5 = a1;
v6 = a3 - a1;
do
{
result = ft_memcpy(a2 + (v6 + (int)v5) % 4096, v5, 1LL);
++v5;
}
while ( v5 != v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3, int a4)
{
__int64 v4; // r13
__int64 v5; // rbx
int v6; // ebp
__int64 result; // rax

if ( a4 > 0 )
{
v4 = a1 + (unsigned int)(a4 - 1) + 1;
v5 = a1;
v6 = a3 - a1;
do
{
result = ft_memcpy(a2 + (v6 + (int)v5) % 4096, v5, 1LL);
++v5;
}
while ( v5 != v4 );
}
return result;
}

original_code:
void cpy_to_arena(t_uc *reg, t_dat *d, int addr, int size)
{
 int i;
 i = 0;
 while (i < size)
 {
  ft_memcpy(d->arena + ((addr + i) % (4*1024)), reg + i, 1);
  i++;
 }
}

canonical_original_code:
void cpy_to_arena(unsigned char *reg, struct s_dat *d, int addr, int size)
{
 int i;
 i = 0;
 while (i < size)
 {
  ft_memcpy(d->arena + ((addr + i) % (4*1024)), reg + i, 1);
  i++;
 }
}

variable_types:
reg
unsigned char *

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

variable_types: addr int

variable_types: size int

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


isreg

decompiled_code:
_BOOL8 __fastcall isreg(__int64 a1)
{
return (unsigned __int64)(a1 - 1) <= 0xF;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
return (unsigned __int64)(a1 - 1) <= 0xF;
}

original_code:
int isreg(long param)
{
 if (param > 0 && param <= 16)
  return (1);
 return (0);
}

variable_types: param long


original_code:
long get_true_val(long val, int idx, int size)
{
 long tmp;
 tmp = power_256(size);
 if (val > (tmp / 2) && idx == 1)
  val = (4*1024) - ((tmp - val) % ((4*1024) / 8));
 else if (val > (tmp / 2) && idx == 0)
  val = (4*1024) - ((tmp - val) % (4*1024));
 else if (val < (tmp / 2) && idx == 1)
  val = val % ((4*1024) / 8);
 return (val);
}

variable_types: val long

variable_types: idx int

variable_types: tmp long

return_type: long


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

if ( *(_BYTE *)(a1 + 73) >> 6 == 1 )
{
if ( (unsigned __int64)(*(_QWORD *)a2 - 1LL) > 0xF )
return 0xFFFFFFFFLL;
v2 = get_val(a1 + 4LL * *(_QWORD *)a2 - 4, 0LL, 4LL);
}
else
{
v2 = get_true_val(*(_QWORD *)a2, 0, 4u);
}
if ( *(_BYTE *)(a1 + 73) >> 4 != 1 )
return (unsigned int)(*(_DWORD *)(a2 + 8) + v2);
v4 = *(_QWORD *)(a2 + 8);
if ( (unsigned __int64)(v4 - 1) > 0xF )
result = 0xFFFFFFFFLL;
else
result = v2 + (unsigned int)get_val(a1 + 4 * v4 - 4, 0LL, 4LL);
return result;
}

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

if ( *(_BYTE *)(a1 + 73) >> 6 == 1 )
{
if ( (unsigned __int64)(*(_QWORD *)a2 - 1LL) > 0xF )
return 0xFFFFFFFFLL;
v2 = get_val(a1 + 4LL * *(_QWORD *)a2 - 4, 0LL, 4LL);
}
else
{
v2 = func2(*(_QWORD *)a2, 0, 4u);
}
if ( *(_BYTE *)(a1 + 73) >> 4 != 1 )
return (unsigned int)(*(_DWORD *)(a2 + 8) + v2);
v4 = *(_QWORD *)(a2 + 8);
if ( (unsigned __int64)(v4 - 1) > 0xF )
result = 0xFFFFFFFFLL;
else
result = v2 + (unsigned int)get_val(a1 + 4 * v4 - 4, 0LL, 4LL);
return result;
}

original_code:
int get_addr(t_proc *proc, long param_val[3])
{
 int addr;
 if (proc->params >> 6 == 1)
 {
  if (param_val[0] < 1 || param_val[0] > 16)
   return (-1);
  addr = (int)get_val(proc->reg + ((param_val[0] - 1) * 4), 0, 4);
 }
 else
  addr = get_true_val(param_val[0], 0, 4);
 if (((proc->params >> 4) & 0xff) == 1)
 {
  if (param_val[1] < 1 || param_val[1] > 16)
   return (-1);
  addr += (int)get_val(proc->reg + ((param_val[1] - 1) * 4), 0, 4);
 }
 else
  addr += (int)param_val[1];
 return (addr);
}

canonical_original_code:
int get_addr(struct s_proc *proc, long param_val[3])
{
 int addr;
 if (proc->params >> 6 == 1)
 {
  if (param_val[0] < 1 || param_val[0] > 16)
   return (-1);
  addr = (int)get_val(proc->reg + ((param_val[0] - 1) * 4), 0, 4);
 }
 else
  addr = get_true_val(param_val[0], 0, 4);
 if (((proc->params >> 4) & 0xff) == 1)
 {
  if (param_val[1] < 1 || param_val[1] > 16)
   return (-1);
  addr += (int)get_val(proc->reg + ((param_val[1] - 1) * 4), 0, 4);
 }
 else
  addr += (int)param_val[1];
 return (addr);
}

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


decompiled_code:
__int64 __fastcall get_long_params(__int64 a1, __int64 a2, __int64 *a3, unsigned int a4)
{
unsigned int v4; // er13
int v6; // ebx
unsigned int v7; // er12
__int64 result; // rax
int v9; // eax
int v10; // eax

v4 = *(_DWORD *)(a2 + 64) + 2;
v6 = 6;
do
{
result = ((int)*(unsigned __int8 *)(a2 + 73) >> v6) & 3;
v7 = result;
if ( (unsigned int)(result - 1) <= 1 )
{
if ( (_DWORD)result != 1 )
v7 = a4;
result = get_val(a1, v4, v7);
*a3 = result;
v4 += v7;
}
else if ( (_DWORD)result == 3 )
{
v9 = get_val(a1, v4, 2LL);
v10 = get_true_val(v9, 0, 2u);
result = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + v10), 4LL);
*a3 = result;
v4 += 2;
}
++a3;
v6 -= 2;
}
while ( v6 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 *a3, unsigned int a4)
{
unsigned int v4; // er13
int v6; // ebx
unsigned int v7; // er12
__int64 result; // rax
int v9; // eax
int v10; // eax

v4 = *(_DWORD *)(a2 + 64) + 2;
v6 = 6;
do
{
result = ((int)*(unsigned __int8 *)(a2 + 73) >> v6) & 3;
v7 = result;
if ( (unsigned int)(result - 1) <= 1 )
{
if ( (_DWORD)result != 1 )
v7 = a4;
result = get_val(a1, v4, v7);
*a3 = result;
v4 += v7;
}
else if ( (_DWORD)result == 3 )
{
v9 = get_val(a1, v4, 2LL);
v10 = func2(v9, 0, 2u);
result = get_val(a1, (unsigned int)(*(_DWORD *)(a2 + 64) + v10), 4LL);
*a3 = result;
v4 += 2;
}
++a3;
v6 -= 2;
}
while ( v6 );
return result;
}

original_code:
void get_long_params(t_dat *d, t_proc *p, long param_val[3], int dir_s)
{
 int i;
 int addr;
 int tmp;
 int type;
 i = -1;
 addr = p->pc + 2;
 while (++i < 3)
 {
  type = ((p->params >> ((3 - i) * 2)) % 4);
  if (type == 1 || type == 2)
  {
   tmp = (type == 1 ? ((16 / 256) + 1) : dir_s);
   param_val[i] = get_val(d->arena, addr, tmp);
   addr += tmp;
  }
  else if (type == 3)
  {
   type = get_val(d->arena, addr, 2);
   type = get_true_val(type, 0, 2);
   param_val[i] = get_val(d->arena, p->pc + type, 4);
   addr += 2;
  }
 }
}

canonical_original_code:
void get_long_params(struct s_dat *d, struct s_proc *p, long param_val[3], int dir_s)
{
 int i;
 int addr;
 int tmp;
 int type;
 i = -1;
 addr = p->pc + 2;
 while (++i < 3)
 {
  type = ((p->params >> ((3 - i) * 2)) % 4);
  if (type == 1 || type == 2)
  {
   tmp = (type == 1 ? ((16 / 256) + 1) : dir_s);
   param_val[i] = get_val(d->arena, addr, tmp);
   addr += tmp;
  }
  else if (type == 3)
  {
   type = get_val(d->arena, addr, 2);
   type = get_true_val(type, 0, 2);
   param_val[i] = get_val(d->arena, p->pc + type, 4);
   addr += 2;
  }
 }
}

variable_types:
p
struct s_proc *

variable_types: tmp int

variable_types: type int

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

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


decompiled_code:
__int64 __fastcall lex_gettoken(__int64 a1)
{
int v1; // edx
__int64 result; // rax

v1 = ft_strcmp(a1, "-dump");
result = 1LL;
if ( v1 )
result = (unsigned int)ft_strcmp(a1, "-v") == 0 ? 16 : 4;
return result;
}

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

v1 = ft_strcmp(a1, "-dump");
result = 1LL;
if ( v1 )
result = (unsigned int)ft_strcmp(a1, "-v") == 0 ? 16 : 4;
return result;
}

original_code:
static t_tok lex_gettoken(char *ag)
{
 if (ft_strcmp(ag, "-dump") == 0)
  return (DUMP);
 else if (ft_strcmp(ag, "-v") == 0)
  return (VERBOSE);
 else
  return (HERO_NUMB);
}

canonical_original_code:
static enum e_tok lex_gettoken(char *ag)
{
 if (ft_strcmp(ag, "-dump") == 0)
  return (DUMP);
 else if (ft_strcmp(ag, "-v") == 0)
  return (VERBOSE);
 else
  return (HERO_NUMB);
}

variable_types:
ag
char *

return_type: enum e_tok { UNKNOWN=0, DUMP=1, NUMBER=2, HERO_NUMB=4, HERO_FILE=8, VERBOSE=16 }


original_code:
void lexer_parser(t_lex **lex, char **ag)
{
 t_tok tmp2;
 ag++;
 tmp2 = UNKNOWN;
 while (*ag)
 {
  if ((*ag)[0] == '-')
  {
   tmp2 = lex_gettoken(*ag);
   if (tmp2 == VERBOSE)
   {
    lex_pushback(lex, *ag, tmp2);
    tmp2 = UNKNOWN;
   }
  }
  else
  {
   tmp2 = (tmp2 == UNKNOWN ? HERO_FILE : tmp2);
   lex_pushback(lex, *ag, tmp2);
   tmp2 = UNKNOWN;
  }
  ag++;
 }
}

canonical_original_code:
void lexer_parser(struct s_lex **lex, char **ag)
{
 enum e_tok tmp2;
 ag++;
 tmp2 = UNKNOWN;
 while (*ag)
 {
  if ((*ag)[0] == '-')
  {
   tmp2 = lex_gettoken(*ag);
   if (tmp2 == VERBOSE)
   {
    lex_pushback(lex, *ag, tmp2);
    tmp2 = UNKNOWN;
   }
  }
  else
  {
   tmp2 = (tmp2 == UNKNOWN ? HERO_FILE : tmp2);
   lex_pushback(lex, *ag, tmp2);
   tmp2 = UNKNOWN;
  }
  ag++;
 }
}

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

variable_types:
ag
char **

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


decompiled_code:
__int64 __fastcall lex_checksyntax(__int64 a1)
{
__int64 v1; // rbx
int v2; // ebp
_DWORD *v3; // rax

if ( !a1 )
goto LABEL_14;
v1 = a1;
v2 = 0;
do
{
while ( *(_DWORD *)v1 == 4 )
{
v3 = *(_DWORD **)(v1 + 16);
if ( !v3 || *v3 != 8 )
{
ptr_err_heroneeded();
goto LABEL_6;
}
v1 = *(_QWORD *)(v1 + 16);
}
v2 += *(_DWORD *)v1 == 8;
LABEL_6:
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
if ( !v2 )
{
LABEL_14:
ptr_err_scary();
return 0LL;
}
if ( v2 > 4 )
ptr_err_battleroyal();
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbx
int v2; // ebp
_DWORD *v3; // rax

if ( !a1 )
goto LABEL_14;
v1 = a1;
v2 = 0;
do
{
while ( *(_DWORD *)v1 == 4 )
{
v3 = *(_DWORD **)(v1 + 16);
if ( !v3 || *v3 != 8 )
{
ptr_err_heroneeded();
goto LABEL_6;
}
v1 = *(_QWORD *)(v1 + 16);
}
v2 += *(_DWORD *)v1 == 8;
LABEL_6:
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
if ( !v2 )
{
LABEL_14:
ptr_err_scary();
return 0LL;
}
if ( v2 > 4 )
ptr_err_battleroyal();
return 0LL;
}

original_code:
int lex_checksyntax(t_lex *lex)
{
 int nb_hero;
 nb_hero = 0;
 while (lex)
 {
  if (lex->token == HERO_NUMB)
  {
   if (lex->next == ((void *)0) || lex->next->token != HERO_FILE)
    ptr_err_heroneeded();
  }
  else if (lex->token == HERO_FILE)
   nb_hero++;
  lex = lex->next;
 }
 if (nb_hero == 0)
  ptr_err_scary();
 else if (nb_hero > 4)
  ptr_err_battleroyal();
 return (0);
}

canonical_original_code:
int lex_checksyntax(struct s_lex *lex)
{
 int nb_hero;
 nb_hero = 0;
 while (lex)
 {
  if (lex->token == HERO_NUMB)
  {
   if (lex->next == ((void *)0) || lex->next->token != HERO_FILE)
    ptr_err_heroneeded();
  }
  else if (lex->token == HERO_FILE)
   nb_hero++;
  lex = lex->next;
 }
 if (nb_hero == 0)
  ptr_err_scary();
 else if (nb_hero > 4)
  ptr_err_battleroyal();
 return (0);
}

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


decompiled_code:
void __fastcall __noreturn ft_malloc_error(__int64 a1)
{
ft_putstr_fd("Malloc Error: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd("\n", 2LL);
exit(-5);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(__int64 a1)
{
ft_putstr_fd("Malloc Error: ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd("\n", 2LL);
exit(-5);
}

original_code:
void ft_malloc_error(const char *s)
{
 ft_putstr_fd("Malloc Error: ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd("\n", 2);
 exit(-5);
}

canonical_original_code:
void ft_malloc_error(char *s)
{
 ft_putstr_fd("Malloc Error: ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd("\n", 2);
 exit(-5);
}

variable_types:
s
char *


decompiled_code:
void __noreturn ft_lseek_error()
{
ft_putstr_fd("lseek error: unable to return to beginning of file.\n", 2LL);
exit(-6);
}

canonical_decompiled_code:
void __noreturn func1()
{
ft_putstr_fd("lseek error: unable to return to beginning of file.\n", 2LL);
exit(-6);
}

original_code:
void ft_lseek_error(void)
{
 ft_putstr_fd("lseek error: unable to return to beginning of file.\n", 2);
 exit(-6);
}

canonical_original_code:
void ft_lseek_error()
{
 ft_putstr_fd("lseek error: unable to return to beginning of file.\n", 2);
 exit(-6);
}


decompiled_code:
void __noreturn ft_command_error()
{
ft_putstr_fd("Error: Unable to retrieve PATH from environment.", 2LL);
exit(-7);
}

canonical_decompiled_code:
void __noreturn func2()
{
ft_putstr_fd("Error: Unable to retrieve PATH from environment.", 2LL);
exit(-7);
}

original_code:
void ft_command_error(void)
{
 ft_putstr_fd("Error: Unable to retrieve PATH from environment.", 2);
 exit(-7);
}

canonical_original_code:
void ft_command_error()
{
 ft_putstr_fd("Error: Unable to retrieve PATH from environment.", 2);
 exit(-7);
}


decompiled_code:
void __fastcall __noreturn ft_unknown_error(__int64 a1)
{
ft_putstr_fd("An unknown error as appeared in ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(". Exit.\n", 2LL);
exit(-8);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(__int64 a1)
{
ft_putstr_fd("An unknown error as appeared in ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(". Exit.\n", 2LL);
exit(-8);
}

original_code:
void ft_unknown_error(const char *s)
{
 ft_putstr_fd("An unknown error as appeared in ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd(". Exit.\n", 2);
 exit(-8);
}

canonical_original_code:
void ft_unknown_error(char *s)
{
 ft_putstr_fd("An unknown error as appeared in ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd(". Exit.\n", 2);
 exit(-8);
}


decompiled_code:
void __fastcall __noreturn ft_execve_error(__int64 a1)
{
ft_putstr_fd("Execve: An error as occured while tring to execute ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(".\n", 2LL);
exit(-9);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(__int64 a1)
{
ft_putstr_fd("Execve: An error as occured while tring to execute ", 2LL);
ft_putstr_fd(a1, 2LL);
ft_putstr_fd(".\n", 2LL);
exit(-9);
}

original_code:
void ft_execve_error(const char *s)
{
 ft_putstr_fd("Execve: An error as occured while tring to execute ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd(".\n", 2);
 exit(-9);
}

canonical_original_code:
void ft_execve_error(char *s)
{
 ft_putstr_fd("Execve: An error as occured while tring to execute ", 2);
 ft_putstr_fd(s, 2);
 ft_putstr_fd(".\n", 2);
 exit(-9);
}


decompiled_code:
__int64 malloc_struct()
{
if ( !td_0 )
td_0 = (__int64)malloc(0x40uLL);
return td_0;
}

canonical_decompiled_code:
__int64 func0()
{
if ( !td_0 )
td_0 = (__int64)malloc(0x40uLL);
return td_0;
}

original_code:
t_termdata *malloc_struct(void)
{
 static t_termdata *td = ((void *)0);
 if (td == ((void *)0))
  td = (t_termdata*)malloc(sizeof(t_termdata));
 return (td);
}

canonical_original_code:
struct s_termdata *malloc_struct()
{
 static struct s_termdata *td = ((void *)0);
 if (td == ((void *)0))
  td = (struct s_termdata *)malloc(sizeof(t_termdata));
 return (td);
}

variable_types: struct s_termdata { char *termtype; int tty; int wnbr; int padlength; int totalline; int totalarg; int lastline; int wincol; int winline; int poscol; int poslin; char *lineup; char *clear; } *


out

decompiled_code:
__int64 __fastcall out(unsigned int a1)
{
__int64 v1; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
v1 = malloc_struct();
write(*(_DWORD *)(v1 + 8), buf, 1uLL);
return buf[0];
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
__int64 v1; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
v1 = func0();
write(*(_DWORD *)(v1 + 8), buf, 1uLL);
return buf[0];
}

original_code:
int out(int i)
{
 t_termdata *td;
 td = malloc_struct();
 write(td->tty, &i, 1);
 return (i);
}

canonical_original_code:
int out(int i)
{
 struct s_termdata *td;
 td = malloc_struct();
 write(td->tty, &i, 1);
 return (i);
}

variable_types: i int

user_defined_types: struct s_termdata { char *termtype; int tty; int wnbr; int padlength; int totalline; int totalarg; int lastline; int wincol; int winline; int poscol; int poslin; char *lineup; char *clear; }


decompiled_code:
int __fastcall print_selected(unsigned int *a1, _QWORD *a2)
{
char *v3; // rax
char *v4; // rax

if ( *((_DWORD *)a2 + 2) != (int)a1[10] / (int)(a1[4] + 1) + a1[3] * a1[11] + 1 )
return ft_putstr_fd(*a2, a1[2]);
v3 = tgetstr("us", 0LL);
tputs(v3, 1, (int (*)(int))out);
ft_putstr_fd(*a2, a1[2]);
v4 = tgetstr("ue", 0LL);
return tputs(v4, 1, (int (*)(int))out);
}

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

if ( *((_DWORD *)a2 + 2) != (int)a1[10] / (int)(a1[4] + 1) + a1[3] * a1[11] + 1 )
return ft_putstr_fd(*a2, a1[2]);
v3 = tgetstr("us", 0LL);
tputs(v3, 1, (int (*)(int))out);
ft_putstr_fd(*a2, a1[2]);
v4 = tgetstr("ue", 0LL);
return tputs(v4, 1, (int (*)(int))out);
}

original_code:
void print_selected(t_termdata *td, t_select *s)
{
 int select;
 select = (td->poslin * td->wnbr) + (td->poscol / (td->padlength + 1));
 if (s->argnbr == (select + 1))
 {
  tputs(tgetstr("us", ((void *)0)), 1, out);
  ft_putstr_fd(s->arg, td->tty);
  tputs(tgetstr("ue", ((void *)0)), 1, out);
 }
 else
  ft_putstr_fd(s->arg, td->tty);
}

canonical_original_code:
void print_selected(struct s_termdata *td, struct s_select *s)
{
 int select;
 select = (td->poslin * td->wnbr) + (td->poscol / (td->padlength + 1));
 if (s->argnbr == (select + 1))
 {
  tputs(tgetstr("us", ((void *)0)), 1, out);
  ft_putstr_fd(s->arg, td->tty);
  tputs(tgetstr("ue", ((void *)0)), 1, out);
 }
 else
  ft_putstr_fd(s->arg, td->tty);
}

variable_types: struct s_select { char *arg; int argnbr; int poscol; int posline; int selected; struct s_select *next; } *

variable_types: select int


decompiled_code:
int __fastcall print_with_mod(unsigned int *a1, _QWORD *a2)
{
signed int v2; // ebx
int result; // eax
char *v4; // rax
char *v5; // rax

v2 = ft_strlen(*a2);
if ( *((_DWORD *)a2 + 5) % 2 == 1 )
{
v4 = tgetstr("mr", 0LL);
tputs(v4, 1, (int (*)(int))out);
print_selected(a1, a2);
v5 = tgetstr("me", 0LL);
for ( result = tputs(v5, 1, (int (*)(int))out); (int)a1[4] >= v2; ++v2 )
result = ft_putstr_fd(" ", a1[2]);
}
else
{
for ( result = print_selected(a1, a2); (int)a1[4] >= v2; ++v2 )
result = ft_putstr_fd(" ", a1[2]);
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int *a1, _QWORD *a2)
{
signed int v2; // ebx
int result; // eax
char *v4; // rax
char *v5; // rax

v2 = ft_strlen(*a2);
if ( *((_DWORD *)a2 + 5) % 2 == 1 )
{
v4 = tgetstr("mr", 0LL);
tputs(v4, 1, (int (*)(int))out);
func2(a1, a2);
v5 = tgetstr("me", 0LL);
for ( result = tputs(v5, 1, (int (*)(int))out); (int)a1[4] >= v2; ++v2 )
result = ft_putstr_fd(" ", a1[2]);
}
else
{
for ( result = func2(a1, a2); (int)a1[4] >= v2; ++v2 )
result = ft_putstr_fd(" ", a1[2]);
}
return result;
}

original_code:
void print_with_mod(t_termdata *td, t_select *s)
{
 int i;
 i = ft_strlen(s->arg);
 if (s->selected % 2 == 1)
 {
  tputs(tgetstr("mr", ((void *)0)), 1, out);
  print_selected(td, s);
  tputs(tgetstr("me", ((void *)0)), 1, out);
  while (i++, i <= td->padlength + 1)
   ft_putstr_fd(" ", td->tty);
 }
 else
 {
  print_selected(td, s);
  while (i++, i <= td->padlength + 1)
   ft_putstr_fd(" ", td->tty);
 }
}

canonical_original_code:
void print_with_mod(struct s_termdata *td, struct s_select *s)
{
 int i;
 i = ft_strlen(s->arg);
 if (s->selected % 2 == 1)
 {
  tputs(tgetstr("mr", ((void *)0)), 1, out);
  print_selected(td, s);
  tputs(tgetstr("me", ((void *)0)), 1, out);
  while (i++, i <= td->padlength + 1)
   ft_putstr_fd(" ", td->tty);
 }
 else
 {
  print_selected(td, s);
  while (i++, i <= td->padlength + 1)
   ft_putstr_fd(" ", td->tty);
 }
}

user_defined_types: struct s_select { char *arg; int argnbr; int poscol; int posline; int selected; struct s_select *next; }


original_code:
void print_arg_and_count(t_termdata *td, t_select *s, int *line, int *j)
{
 int i;
 while (s != ((void *)0))
 {
  i = -1;
  while (i++, i < td->wnbr && s != ((void *)0))
  {
   print_with_mod(td, s);
   s = s->next;
   if (s != ((void *)0))
    s->poscol = (td->padlength + 1) * i;
   *j += 1;
  }
  *line += 1;
  if (s != ((void *)0))
   s->posline = *line;
  ft_putstr_fd("\n", td->tty);
 }
 td->totalline = *line;
 td->totalarg = *j;
 if ((td->lastline = td->totalarg % td->wnbr) == 0)
  td->lastline = td->wnbr;
}

canonical_original_code:
void print_arg_and_count(struct s_termdata *td, struct s_select *s, int *line, int *j)
{
 int i;
 while (s != ((void *)0))
 {
  i = -1;
  while (i++, i < td->wnbr && s != ((void *)0))
  {
   print_with_mod(td, s);
   s = s->next;
   if (s != ((void *)0))
    s->poscol = (td->padlength + 1) * i;
   *j += 1;
  }
  *line += 1;
  if (s != ((void *)0))
   s->posline = *line;
  ft_putstr_fd("\n", td->tty);
 }
 td->totalline = *line;
 td->totalarg = *j;
 if ((td->lastline = td->totalarg % td->wnbr) == 0)
  td->lastline = td->wnbr;
}

variable_types:
line
int *

variable_types:
j
int *


original_code:
void move_cursor_again(int u, int v, t_termdata *td, t_select *s)
{
 char *move;
 move = tgetstr("cm", ((void *)0));
 if (v < 0)
  v = (td->totalline - 1);
 if (v > (td->totalline - 1))
  v = 0;
 if (v == (td->totalline - 1) && u >= td->lastline * (td->padlength + 1))
 {
  u = 0;
  v = 0;
 }
 td->poscol = u;
 td->poslin = v;
 ft_print_arg(td, s);
 tputs(tgoto(move, u, v), 1, out);
}

canonical_original_code:
void move_cursor_again(int u, int v, struct s_termdata *td, struct s_select *s)
{
 char *move;
 move = tgetstr("cm", ((void *)0));
 if (v < 0)
  v = (td->totalline - 1);
 if (v > (td->totalline - 1))
  v = 0;
 if (v == (td->totalline - 1) && u >= td->lastline * (td->padlength + 1))
 {
  u = 0;
  v = 0;
 }
 td->poscol = u;
 td->poslin = v;
 ft_print_arg(td, s);
 tputs(tgoto(move, u, v), 1, out);
}

variable_types: u int

variable_types: v int

variable_types:
move
char *


original_code:
void move_cursor(int x, int y, t_termdata *td, t_select *s)
{
 int u;
 int v;
 u = td->poscol + ((td->padlength + 1) * x);
 v = td->poslin + y;
 if (v == 0 && u < 0)
 {
  u = (td->lastline - 1) * (td->padlength + 1);
  v = td->totalline - 1;
 }
 if (u < 0)
 {
  u = (td->wnbr - 1) * (td->padlength + 1);
  v -= 1;
 }
 if (u > ((td->wnbr - 1) * (td->padlength + 1)))
 {
  u = 0;
  v += 1;
 }
 move_cursor_again(u, v, td, s);
}

canonical_original_code:
void move_cursor(int x, int y, struct s_termdata *td, struct s_select *s)
{
 int u;
 int v;
 u = td->poscol + ((td->padlength + 1) * x);
 v = td->poslin + y;
 if (v == 0 && u < 0)
 {
  u = (td->lastline - 1) * (td->padlength + 1);
  v = td->totalline - 1;
 }
 if (u < 0)
 {
  u = (td->wnbr - 1) * (td->padlength + 1);
  v -= 1;
 }
 if (u > ((td->wnbr - 1) * (td->padlength + 1)))
 {
  u = 0;
  v += 1;
 }
 move_cursor_again(u, v, td, s);
}

variable_types: x int

variable_types: y int


decompiled_code:
__int64 ft_select()
{
__int64 v0; // rbp
_DWORD *v1; // rbx

v0 = malloc_select();
v1 = (_DWORD *)malloc_struct();
move_cursor(0, 0, v1, v0);
ft_print_arg(v1, v0);
return wait_while_read(v1, v0);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbp
_DWORD *v1; // rbx

v0 = malloc_select();
v1 = (_DWORD *)malloc_struct();
func2(0, 0, v1, v0);
ft_print_arg(v1, v0);
return wait_while_read(v1, v0);
}

original_code:
void ft_select(char **argv)
{
 t_termdata *td;
 t_select *s;
 s = malloc_select(argv);
 td = malloc_struct();
 move_cursor(0, 0, td, s);
 ft_print_arg(td, s);
 wait_while_read(td, s);
}

canonical_original_code:
void ft_select(char **argv)
{
 struct s_termdata *td;
 struct s_select *s;
 s = malloc_select(argv);
 td = malloc_struct();
 move_cursor(0, 0, td, s);
 ft_print_arg(td, s);
 wait_while_read(td, s);
}

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall set_argnb(__int64 *a1, unsigned int a2, __int64 a3)
{
unsigned int v3; // er12
char *v5; // rbx
char *v6; // rax
unsigned int v7; // ebp
char v8; // dl
void *v10; // rbx
__int64 v11; // r12

v3 = a2;
v5 = (char *)(a3 + (int)a2);
if ( !*v5 || *v5 == 36 )
{
v7 = a2;
LABEL_10:
invalid_format();
goto LABEL_7;
}
v6 = (char *)(a3 + (int)a2 + 1);
do
{
v7 = (_DWORD)v6 - a3;
v5 = v6;
v8 = *v6++;
}
while ( v8 && v8 != 36 );
if ( a2 == v7 )
goto LABEL_10;
LABEL_7:
if ( *v5 == 36 )
{
v10 = (void *)ft_strsub(a3, a2, (int)(v7 - a2));
if ( !v10 )
impossible_malloc("arg_nb");
v11 = *a1;
*(_DWORD *)(v11 + 4) = ft_atoi(v10);
free(v10);
v3 = v7;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, unsigned int a2, __int64 a3)
{
unsigned int v3; // er12
char *v5; // rbx
char *v6; // rax
unsigned int v7; // ebp
char v8; // dl
void *v10; // rbx
__int64 v11; // r12

v3 = a2;
v5 = (char *)(a3 + (int)a2);
if ( !*v5 || *v5 == 36 )
{
v7 = a2;
LABEL_10:
invalid_format();
goto LABEL_7;
}
v6 = (char *)(a3 + (int)a2 + 1);
do
{
v7 = (_DWORD)v6 - a3;
v5 = v6;
v8 = *v6++;
}
while ( v8 && v8 != 36 );
if ( a2 == v7 )
goto LABEL_10;
LABEL_7:
if ( *v5 == 36 )
{
v10 = (void *)ft_strsub(a3, a2, (int)(v7 - a2));
if ( !v10 )
impossible_malloc("arg_nb");
v11 = *a1;
*(_DWORD *)(v11 + 4) = ft_atoi(v10);
free(v10);
v3 = v7;
}
return v3;
}

original_code:
int set_argnb(t_format **format, int i, char *s)
{
 int j;
 char *carg_nb;
 j = i;
 while (s[j] && (s[j] != '$'))
  j++;
 if (j == i)
  invalid_format();
 if (s[j] == '$')
 {
  carg_nb = ft_strsub(s, i, (j - i));
  if (carg_nb == ((void *)0))
   impossible_malloc("arg_nb");
  (*format)->arg_nb = ft_atoi(carg_nb);
  free(carg_nb);
  return (j);
 }
 return (i);
}

canonical_original_code:
int set_argnb(struct s_format **format, int i, char *s)
{
 int j;
 char *carg_nb;
 j = i;
 while (s[j] && (s[j] != '$'))
  j++;
 if (j == i)
  invalid_format();
 if (s[j] == '$')
 {
  carg_nb = ft_strsub(s, i, (j - i));
  if (carg_nb == ((void *)0))
   impossible_malloc("arg_nb");
  (*format)->arg_nb = ft_atoi(carg_nb);
  free(carg_nb);
  return (j);
 }
 return (i);
}

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

variable_types: j int

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


decompiled_code:
__int64 __fastcall set_flags(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er13
void *v7; // rbx

v4 = a2;
do
v5 = v4;
while ( ft_strchr("#0- +", (unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == 1 )
invalid_format();
v7 = (void *)ft_strsub(a3, 1LL, (int)(v5 - 1));
if ( !v7 )
impossible_malloc("flag_list");
update_flags(a1, v7);
if ( !*(_QWORD *)(*(_QWORD *)a1 + 8LL) )
impossible_malloc("flag_list2");
free(v7);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er13
void *v7; // rbx

v4 = a2;
do
v5 = v4;
while ( ft_strchr("#0- +", (unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == 1 )
invalid_format();
v7 = (void *)ft_strsub(a3, 1LL, (int)(v5 - 1));
if ( !v7 )
impossible_malloc("flag_list");
update_flags(a1, v7);
if ( !*(_QWORD *)(*(_QWORD *)a1 + 8LL) )
impossible_malloc("flag_list2");
free(v7);
return v5;
}

original_code:
int set_flags(t_format **format, int i, char *s)
{
 char *flag_list;
 while (ft_strchr("#0- +", s[i]) != ((void *)0))
  i++;
 if (i == 1)
  invalid_format();
 flag_list = ft_strsub(s, 1, (i - 1));
 if (!flag_list)
  impossible_malloc("flag_list");
 update_flags(format, flag_list);
 if (!(*format)->f_list)
  impossible_malloc("flag_list2");
 free(flag_list);
 return (i);
}

canonical_original_code:
int set_flags(struct s_format **format, int i, char *s)
{
 char *flag_list;
 while (ft_strchr("#0- +", s[i]) != ((void *)0))
  i++;
 if (i == 1)
  invalid_format();
 flag_list = ft_strsub(s, 1, (i - 1));
 if (!flag_list)
  impossible_malloc("flag_list");
 update_flags(format, flag_list);
 if (!(*format)->f_list)
  impossible_malloc("flag_list2");
 free(flag_list);
 return (i);
}

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


decompiled_code:
__int64 __fastcall set_minwidth(__int64 *a1, unsigned int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er12
void *v7; // rbx
__int64 v8; // rbp

v4 = (int)a2;
do
v5 = v4;
while ( (unsigned int)ft_isdigit((unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == a2 )
invalid_format();
v7 = (void *)ft_strsub(a3, a2, (int)(v5 - a2));
if ( !v7 )
impossible_malloc("min_width");
v8 = *a1;
*(_DWORD *)(v8 + 16) = ft_atoi(v7);
free(v7);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, unsigned int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er12
void *v7; // rbx
__int64 v8; // rbp

v4 = (int)a2;
do
v5 = v4;
while ( (unsigned int)ft_isdigit((unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == a2 )
invalid_format();
v7 = (void *)ft_strsub(a3, a2, (int)(v5 - a2));
if ( !v7 )
impossible_malloc("min_width");
v8 = *a1;
*(_DWORD *)(v8 + 16) = ft_atoi(v7);
free(v7);
return v5;
}

original_code:
int set_minwidth(t_format **format, int i, char *s)
{
 int j;
 char *min_width;
 j = i;
 while (ft_isdigit(s[j]))
  j++;
 if (j == i)
  invalid_format();
 min_width = ft_strsub(s, i, (j - i));
 if (!min_width)
  impossible_malloc("min_width");
 (*format)->m_width = ft_atoi(min_width);
 free(min_width);
 return (j);
}

canonical_original_code:
int set_minwidth(struct s_format **format, int i, char *s)
{
 int j;
 char *min_width;
 j = i;
 while (ft_isdigit(s[j]))
  j++;
 if (j == i)
  invalid_format();
 min_width = ft_strsub(s, i, (j - i));
 if (!min_width)
  impossible_malloc("min_width");
 (*format)->m_width = ft_atoi(min_width);
 free(min_width);
 return (j);
}


decompiled_code:
__int64 __fastcall set_precision(__int64 *a1, unsigned int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er12
void *v7; // rbx
__int64 v8; // rbp

v4 = (int)(a2 + 1);
do
v5 = v4;
while ( (unsigned int)ft_isdigit((unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == a2 + 1 )
invalid_format();
v7 = (void *)ft_strsub(a3, a2, (int)(a2 - v5));
if ( !v7 )
impossible_malloc("precision");
v8 = *a1;
*(_DWORD *)(v8 + 20) = ft_atoi(v7);
free(v7);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, unsigned int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er12
void *v7; // rbx
__int64 v8; // rbp

v4 = (int)(a2 + 1);
do
v5 = v4;
while ( (unsigned int)ft_isdigit((unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == a2 + 1 )
invalid_format();
v7 = (void *)ft_strsub(a3, a2, (int)(a2 - v5));
if ( !v7 )
impossible_malloc("precision");
v8 = *a1;
*(_DWORD *)(v8 + 20) = ft_atoi(v7);
free(v7);
return v5;
}

original_code:
int set_precision(t_format **format, int i, char *s)
{
 int j;
 char *precision;
 j = i + 1;
 while (ft_isdigit(s[j]))
  j++;
 if (j == (i + 1))
  invalid_format();
 precision = ft_strsub(s, i, (i - j));
 if (!precision)
  impossible_malloc("precision");
 (*format)->preci = ft_atoi(precision);
 free(precision);
 return (j);
}

canonical_original_code:
int set_precision(struct s_format **format, int i, char *s)
{
 int j;
 char *precision;
 j = i + 1;
 while (ft_isdigit(s[j]))
  j++;
 if (j == (i + 1))
  invalid_format();
 precision = ft_strsub(s, i, (i - j));
 if (!precision)
  impossible_malloc("precision");
 (*format)->preci = ft_atoi(precision);
 free(precision);
 return (j);
}

variable_types:
precision
char *


decompiled_code:
void __fastcall set_lenmod(__int64 *a1, int a2, __int64 a3)
{
__int64 v4; // rbx
int v5; // er12
void *v7; // rbx
__int64 v8; // rbp

v4 = a2 + 1;
do
v5 = v4;
while ( ft_strchr("hljtzqLv", (unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == a2 + 1 )
invalid_format();
v7 = (void *)ft_strsub(a3, 1LL, a2 - 1);
if ( !v7 )
impossible_malloc("len_mod");
v8 = *a1;
*(_QWORD *)(v8 + 24) = ft_strdup(v7);
if ( !*(_QWORD *)(*a1 + 24) )
impossible_malloc("len_mod2");
free(v7);
}

canonical_decompiled_code:
void __fastcall func4(__int64 *a1, int a2, __int64 a3)
{
__int64 v4; // rbx
int v5; // er12
void *v7; // rbx
__int64 v8; // rbp

v4 = a2 + 1;
do
v5 = v4;
while ( ft_strchr("hljtzqLv", (unsigned int)*(char *)(a3 + v4++)) );
if ( v5 == a2 + 1 )
invalid_format();
v7 = (void *)ft_strsub(a3, 1LL, a2 - 1);
if ( !v7 )
impossible_malloc("len_mod");
v8 = *a1;
*(_QWORD *)(v8 + 24) = ft_strdup(v7);
if ( !*(_QWORD *)(*a1 + 24) )
impossible_malloc("len_mod2");
free(v7);
}

original_code:
void set_lenmod(t_format **format, int i, char *s)
{
 char *len_mod;
 int j;
 j = i + 1;
 while (ft_strchr("hljtzqLv", s[j]) != ((void *)0))
  j++;
 if (j == (i + 1))
  invalid_format();
 len_mod = ft_strsub(s, 1, (i - 1));
 if (!len_mod)
  impossible_malloc("len_mod");
 (*format)->l_mod = ft_strdup(len_mod);
 if (!(*format)->l_mod)
  impossible_malloc("len_mod2");
 free(len_mod);
}

canonical_original_code:
void set_lenmod(struct s_format **format, int i, char *s)
{
 char *len_mod;
 int j;
 j = i + 1;
 while (ft_strchr("hljtzqLv", s[j]) != ((void *)0))
  j++;
 if (j == (i + 1))
  invalid_format();
 len_mod = ft_strsub(s, 1, (i - 1));
 if (!len_mod)
  impossible_malloc("len_mod");
 (*format)->l_mod = ft_strdup(len_mod);
 if (!(*format)->l_mod)
  impossible_malloc("len_mod2");
 free(len_mod);
}


decompiled_code:
void __fastcall remove_first_elem(__int64 a1)
{
void *v1; // rax

v1 = *(void **)a1;
*(_QWORD *)a1 = *(_QWORD *)(*(_QWORD *)a1 + 24LL);
free(v1);
}

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

v1 = *(void **)a1;
*(_QWORD *)a1 = *(_QWORD *)(*(_QWORD *)a1 + 24LL);
free(v1);
}

original_code:
void remove_first_elem(t_select **s)
{
 t_select *prev;
 prev = *s;
 *s = prev->next;
 prev->next = ((void *)0);
 free(prev);
}

canonical_original_code:
void remove_first_elem(struct s_select **s)
{
 struct s_select *prev;
 prev = *s;
 *s = prev->next;
 prev->next = ((void *)0);
 free(prev);
}

variable_types: struct s_select { char *arg; int argnbr; int poscol; int posline; int selected; struct s_select *next; } **


decompiled_code:
__int64 __fastcall delete_arg(_DWORD *a1, __int64 *a2)
{
int v3; // esi

tgetstr("cm", 0LL);
v3 = a1[10] / (a1[4] + 1) + a1[3] * a1[11];
if ( v3 )
remove_any_elem(a2, v3);
else
remove_first_elem((__int64)a2);
rebuild_arg_list(a2);
ft_print_arg(a1, *a2);
return move_cursor(0LL, 0LL, a1, *a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, __int64 *a2)
{
int v3; // esi

tgetstr("cm", 0LL);
v3 = a1[10] / (a1[4] + 1) + a1[3] * a1[11];
if ( v3 )
func0(a2, v3);
else
func1((__int64)a2);
rebuild_arg_list(a2);
ft_print_arg(a1, *a2);
return move_cursor(0LL, 0LL, a1, *a2);
}

original_code:
void delete_arg(t_termdata *td, t_select **s)
{
 int j;
 char *move;
 move = tgetstr("cm", ((void *)0));
 j = (td->poslin * td->wnbr) + (td->poscol / (td->padlength + 1));
 if (j == 0)
  remove_first_elem(s);
 else
  remove_any_elem(s, j);
 rebuild_arg_list(s);
 ft_print_arg(td, (*s));
 move_cursor(0, 0, td, *s);
}

canonical_original_code:
void delete_arg(struct s_termdata *td, struct s_select **s)
{
 int j;
 char *move;
 move = tgetstr("cm", ((void *)0));
 j = (td->poslin * td->wnbr) + (td->poscol / (td->padlength + 1));
 if (j == 0)
  remove_first_elem(s);
 else
  remove_any_elem(s, j);
 rebuild_arg_list(s);
 ft_print_arg(td, (*s));
 move_cursor(0, 0, td, *s);
}


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

result = cmd_create("fork");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 0;
*(_BYTE *)(result + 10) = 1;
*(_DWORD *)(result + 12) = 3;
return result;
}

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

result = cmd_create("fork");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 0;
*(_BYTE *)(result + 10) = 1;
*(_DWORD *)(result + 12) = 3;
return result;
}

original_code:
t_cmd *cmd_createfork(void)
{
 t_cmd *cmd;
 cmd = cmd_create("fork");
 cmd->nb_arg = 1;
 cmd->has_encoding = 0;
 cmd->is_idx = 1;
 cmd->size = 1 + 2;
 return (cmd);
}

canonical_original_code:
struct s_cmd *cmd_createfork()
{
 struct s_cmd *cmd;
 cmd = cmd_create("fork");
 cmd->nb_arg = 1;
 cmd->has_encoding = 0;
 cmd->is_idx = 1;
 cmd->size = 1 + 2;
 return (cmd);
}

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


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

result = cmd_create("aff");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 1;
*(_BYTE *)(result + 10) = 0;
*(_DWORD *)(result + 12) = 3;
return result;
}

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

result = cmd_create("aff");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 1;
*(_BYTE *)(result + 10) = 0;
*(_DWORD *)(result + 12) = 3;
return result;
}

original_code:
t_cmd *cmd_createaff(void)
{
 t_cmd *cmd;
 cmd = cmd_create("aff");
 cmd->nb_arg = 1;
 cmd->has_encoding = 1;
 cmd->is_idx = 0;
 cmd->size = 2 + ((16 / 256) + 1);
 return (cmd);
}

canonical_original_code:
struct s_cmd *cmd_createaff()
{
 struct s_cmd *cmd;
 cmd = cmd_create("aff");
 cmd->nb_arg = 1;
 cmd->has_encoding = 1;
 cmd->is_idx = 0;
 cmd->size = 2 + ((16 / 256) + 1);
 return (cmd);
}

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


decompiled_code:
_BYTE *cmd_createld()
{
_BYTE *result; // rax

result = (_BYTE *)cmd_create("ld");
result[8] = 2;
result[9] = 1;
result[10] = 0;
return result;
}

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

result = (_BYTE *)cmd_create("ld");
result[8] = 2;
result[9] = 1;
result[10] = 0;
return result;
}

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

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

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


decompiled_code:
_BYTE *cmd_createst()
{
_BYTE *result; // rax

result = (_BYTE *)cmd_create("st");
result[8] = 2;
result[9] = 1;
result[10] = 0;
return result;
}

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

result = (_BYTE *)cmd_create("st");
result[8] = 2;
result[9] = 1;
result[10] = 0;
return result;
}

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

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


decompiled_code:
_BYTE *cmd_createand()
{
_BYTE *result; // rax

result = (_BYTE *)cmd_create("and");
result[8] = 3;
result[9] = 1;
result[10] = 0;
return result;
}

canonical_decompiled_code:
_BYTE *func4()
{
_BYTE *result; // rax

result = (_BYTE *)cmd_create("and");
result[8] = 3;
result[9] = 1;
result[10] = 0;
return result;
}

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

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


decompiled_code:
__int64 __fastcall ft_find_arg_count(char *a1)
{
char v1; // al
char *v2; // rdi
unsigned int v3; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = a1 + 1;
v3 = 0;
do
{
if ( v1 == 37 )
v3 += *v2 != 37;
v1 = *v2++;
}
while ( v1 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v1; // al
char *v2; // rdi
unsigned int v3; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = a1 + 1;
v3 = 0;
do
{
if ( v1 == 37 )
v3 += *v2 != 37;
v1 = *v2++;
}
while ( v1 );
return v3;
}

original_code:
int ft_find_arg_count(char *str)
{
 int i;
 int cnt;
 i = 0;
 cnt = 0;
 while (str[i] != '\0')
 {
  if (str[i] == '%' && str[i + 1] != '%')
   cnt += 1;
  i++;
 }
 return (cnt);
}

variable_types:
str
char *

variable_types: cnt int


decompiled_code:
__int64 __fastcall ft_print_char(__int64 a1, _DWORD *a2, int *a3)
{
__int64 result; // rax
char i; // di

result = *a3;
for ( i = *(_BYTE *)(a1 + result); i != 37 && i; i = *(_BYTE *)(a1 + (int)result) )
{
ft_putchar((unsigned int)i);
++*a2;
LODWORD(result) = *a3 + 1;
*a3 = result;
result = (int)result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _DWORD *a2, int *a3)
{
__int64 result; // rax
char i; // di

result = *a3;
for ( i = *(_BYTE *)(a1 + result); i != 37 && i; i = *(_BYTE *)(a1 + (int)result) )
{
ft_putchar((unsigned int)i);
++*a2;
LODWORD(result) = *a3 + 1;
*a3 = result;
result = (int)result;
}
return result;
}

original_code:
void ft_print_char(char *str, int *cnt, int *i)
{
 while (str[*i] != '%' && str[*i] != '\0')
 {
  ft_putchar(str[*i]);
  *cnt += 1;
  *i += 1;
 }
}

variable_types:
cnt
int *

variable_types:
i
int *


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

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

variable_types: i int


decompiled_code:
__int64 __fastcall ft_strcmp(unsigned __int8 *a1, _BYTE *a2)
{
unsigned __int8 i; // al

for ( i = *a1; *a1; i = *a1 )
{
if ( *a2 != i )
break;
if ( !*a2 )
break;
++a1;
++a2;
}
return i - (unsigned int)(unsigned __int8)*a2;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, _BYTE *a2)
{
unsigned __int8 i; // al

for ( i = *a1; *a1; i = *a1 )
{
if ( *a2 != i )
break;
if ( !*a2 )
break;
++a1;
++a2;
}
return i - (unsigned int)(unsigned __int8)*a2;
}

original_code:
int ft_strcmp(const char *str, const char *str2)
{
 unsigned char *_str;
 unsigned char *_str2;
 _str = (unsigned char*) str;
 _str2 = (unsigned char*) str2;
 while (*_str != '\0' && *_str2 != '\0' && *_str == *_str2)
 {
  _str++;
  _str2++;
 }
 return (*_str - *_str2);
}

canonical_original_code:
int ft_strcmp(char *str, char *str2)
{
 unsigned char *_str;
 unsigned char *_str2;
 _str = (unsigned char *) str;
 _str2 = (unsigned char *) str2;
 while (*_str != '\0' && *_str2 != '\0' && *_str == *_str2)
 {
  _str++;
  _str2++;
 }
 return (*_str - *_str2);
}


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

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

variable_types:
lnk
struct s_list2 *

variable_types:
new
struct s_list2 *

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


decompiled_code:
__int64 __fastcall ft_build_dirlist(const char *a1, __int64 a2)
{
void *v2; // rax
__int64 v3; // rax
__int64 v4; // rax

v2 = malloc(0x68uLL);
v3 = ft_lstnew_dir(a1, v2);
v4 = ft_fill_dirstat(v3, a1);
return ft_lst_push_back_dir(a2, v4);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, __int64 a2)
{
void *v2; // rax
__int64 v3; // rax
__int64 v4; // rax

v2 = malloc(0x68uLL);
v3 = ft_lstnew_dir(a1, v2);
v4 = func1(v3, a1);
return ft_lst_push_back_dir(a2, v4);
}

original_code:
t_list2 *ft_build_dirlist(char *str, t_list2 *lnk)
{
 t_list2 *new;
 t_list2 *tmp;
 tmp = (t_list2*)malloc(sizeof(t_list2));
 tmp = ft_lstnew_dir(str, tmp);
 tmp = ft_fill_dirstat(tmp, str);
 new = ft_lst_push_back_dir(lnk, tmp);
 return (new);
}

canonical_original_code:
struct s_list2 *ft_build_dirlist(char *str, struct s_list2 *lnk)
{
 struct s_list2 *new;
 struct s_list2 *tmp;
 tmp = (struct s_list2 *)malloc(sizeof(t_list2));
 tmp = ft_lstnew_dir(str, tmp);
 tmp = ft_fill_dirstat(tmp, str);
 new = ft_lst_push_back_dir(lnk, tmp);
 return (new);
}

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


decompiled_code:
__int64 __fastcall ft_swap_a(unsigned int **a1, _QWORD *a2, const void **a3)
{
unsigned int *v4; // rdx
__int64 v5; // rax

ft_printf("\nSWAP A\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
ft_printf("state = %p\n", *a3);
ft_printf("state val = %p\n", *(const void **)*a3);
ft_printf("lnk = %d\n", **a1);
v4 = *a1;
v5 = *((_QWORD *)*a1 + 1);
*((_QWORD *)v4 + 1) = *(_QWORD *)(v5 + 8);
*(_QWORD *)(v5 + 8) = v4;
*a1 = (unsigned int *)v5;
a3[3] = (const void *)ft_add_operation(a3[3], "sa");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return ft_update_state(a3, *a1, *a2, 0LL);
}

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

ft_printf("\nSWAP A\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
ft_printf("state = %p\n", *a3);
ft_printf("state val = %p\n", *(const void **)*a3);
ft_printf("lnk = %d\n", **a1);
v4 = *a1;
v5 = *((_QWORD *)*a1 + 1);
*((_QWORD *)v4 + 1) = *(_QWORD *)(v5 + 8);
*(_QWORD *)(v5 + 8) = v4;
*a1 = (unsigned int *)v5;
a3[3] = (const void *)ft_add_operation(a3[3], "sa");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return ft_update_state(a3, *a1, *a2, 0LL);
}

original_code:
int ft_swap_a(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op = "sa";
 t_sort *tmp;
 t_sort *tmp2;
 ft_printf("\nSWAP A\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 ft_printf("state = %p\n", (void*)state->list);
 ft_printf("state val = %p\n", (void*)state->list->head);
 ft_printf("lnk = %d\n", (*lnk)->val);
 tmp = (*lnk);
 tmp2 = (*lnk)->next;
 tmp->next = (*lnk)->next->next;
 tmp2->next = tmp;
 (*lnk) = tmp2;
 state->op = ft_add_operation(state->op, op);
 ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
 return (ft_update_state(state, (*lnk), (*lnk_b), 0));
}

canonical_original_code:
int ft_swap_a(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "sa";
 struct s_list_arg *tmp;
 struct s_list_arg *tmp2;
 ft_printf("\nSWAP A\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 ft_printf("state = %p\n", (void *)state->list);
 ft_printf("state val = %p\n", (void *)state->list->head);
 ft_printf("lnk = %d\n", (*lnk)->val);
 tmp = (*lnk);
 tmp2 = (*lnk)->next;
 tmp->next = (*lnk)->next->next;
 tmp2->next = tmp;
 (*lnk) = tmp2;
 state->op = ft_add_operation(state->op, op);
 ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
 return (ft_update_state(state, (*lnk), (*lnk_b), 0));
}

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

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

variable_types:
op
char *

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


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

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

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

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

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

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

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

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


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

ft_printf("\n\nROT A\n\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v4 = *a1;
v5 = *(_QWORD *)(*a1 + 8LL);
if ( v5 )
{
v6 = *(_QWORD *)(*a1 + 8LL);
do
{
*a1 = v6;
v6 = *(_QWORD *)(v6 + 8);
}
while ( v6 );
}
*(_QWORD *)(v4 + 8) = 0LL;
*(_QWORD *)(*a1 + 8LL) = v4;
*a1 = v5;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "ra");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 4LL) != 0;
}

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

ft_printf("\n\nROT A\n\n\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v4 = *a1;
v5 = *(_QWORD *)(*a1 + 8LL);
if ( v5 )
{
v6 = *(_QWORD *)(*a1 + 8LL);
do
{
*a1 = v6;
v6 = *(_QWORD *)(v6 + 8);
}
while ( v6 );
}
*(_QWORD *)(v4 + 8) = 0LL;
*(_QWORD *)(*a1 + 8LL) = v4;
*a1 = v5;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "ra");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 4LL) != 0;
}

original_code:
int ft_rotate_a(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "ra";
 t_sort *tmp;
 t_sort *tmp_move;
 ft_printf("\n\nROT A\n\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 tmp = (*lnk)->next;
 tmp_move = (*lnk);
 while ((*lnk)->next != ((void *)0))
  (*lnk) = (*lnk)->next;
 tmp_move->next = ((void *)0);
 (*lnk)->next = tmp_move;
 (*lnk) = tmp;
    state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 4) == 0)
  return (0);
    return (1);
}

canonical_original_code:
int ft_rotate_a(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "ra";
 struct s_list_arg *tmp;
 struct s_list_arg *tmp_move;
 ft_printf("\n\nROT A\n\n\n");
 ft_printf("PRE-OP\n");
 ft_print_list((*lnk), (*lnk_b));
 tmp = (*lnk)->next;
 tmp_move = (*lnk);
 while ((*lnk)->next != ((void *)0))
  (*lnk) = (*lnk)->next;
 tmp_move->next = ((void *)0);
 (*lnk)->next = tmp_move;
 (*lnk) = tmp;
    state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 4) == 0)
  return (0);
    return (1);
}

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


decompiled_code:
_BOOL8 __fastcall ft_rotate_rev_a(_QWORD *a1, _QWORD *a2, __int64 a3)
{
__int64 i; // rbp
__int64 v5; // rcx
__int64 v6; // rax
__int64 v7; // rdx

ft_printf("ROT REV A\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v5 = *a1;
v6 = *(_QWORD *)(*a1 + 8LL);
if ( v6 )
{
for ( i = *a1; ; i = v7 )
{
*a1 = v6;
v7 = v6;
v6 = *(_QWORD *)(v6 + 8);
if ( !v6 )
break;
}
}
*(_QWORD *)(i + 8) = 0LL;
*(_QWORD *)(*a1 + 8LL) = v5;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rra");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 6LL) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(_QWORD *a1, _QWORD *a2, __int64 a3)
{
__int64 i; // rbp
__int64 v5; // rcx
__int64 v6; // rax
__int64 v7; // rdx

ft_printf("ROT REV A\n");
ft_printf("PRE-OP\n");
ft_print_list(*a1, *a2);
v5 = *a1;
v6 = *(_QWORD *)(*a1 + 8LL);
if ( v6 )
{
for ( i = *a1; ; i = v7 )
{
*a1 = v6;
v7 = v6;
v6 = *(_QWORD *)(v6 + 8);
if ( !v6 )
break;
}
}
*(_QWORD *)(i + 8) = 0LL;
*(_QWORD *)(*a1 + 8LL) = v5;
*(_QWORD *)(a3 + 24) = ft_add_operation(*(_QWORD *)(a3 + 24), "rra");
ft_printf("\nPOST-OP\n");
ft_print_list(*a1, *a2);
return (unsigned int)ft_update_state(a3, *a1, *a2, 6LL) != 0;
}

original_code:
int ft_rotate_rev_a(t_sort **lnk, t_sort **lnk_b, t_state *state)
{
 char *op= "rra";
 t_sort *tmp;
 t_sort *tmp2;
 ft_printf("ROT REV A\n");
 ft_printf("PRE-OP\n");
    ft_print_list((*lnk), (*lnk_b));
 tmp = (*lnk);
 while ((*lnk)->next != ((void *)0))
 {
  tmp2 = (*lnk);
  (*lnk) = (*lnk)->next;
 }
 tmp2->next = ((void *)0);
 (*lnk)->next = tmp;
    state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 6) == 0)
  return (0);
    return (1);
}

canonical_original_code:
int ft_rotate_rev_a(struct s_list_arg **lnk, struct s_list_arg **lnk_b, struct s_state *state)
{
 char *op = "rra";
 struct s_list_arg *tmp;
 struct s_list_arg *tmp2;
 ft_printf("ROT REV A\n");
 ft_printf("PRE-OP\n");
    ft_print_list((*lnk), (*lnk_b));
 tmp = (*lnk);
 while ((*lnk)->next != ((void *)0))
 {
  tmp2 = (*lnk);
  (*lnk) = (*lnk)->next;
 }
 tmp2->next = ((void *)0);
 (*lnk)->next = tmp;
    state->op = ft_add_operation(state->op, op);
    ft_printf("\nPOST-OP\n");
    ft_print_list((*lnk), (*lnk_b));
    if (ft_update_state(state, (*lnk), (*lnk_b), 6) == 0)
  return (0);
    return (1);
}


decompiled_code:
__int64 check_quote()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
int check_quote(t_token *tok)
{
 (void)tok;
 return (0);
}

canonical_original_code:
int check_quote(struct s_token *tok)
{
 (void)tok;
 return (0);
}

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

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


decompiled_code:
__int64 check_semicolon()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 0LL;
}

original_code:
int check_semicolon(t_token *tok)
{
 (void)tok;
 return (0);
}

canonical_original_code:
int check_semicolon(struct s_token *tok)
{
 (void)tok;
 return (0);
}

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


decompiled_code:
__int64 check_whitespace()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0LL;
}

original_code:
int check_whitespace(t_token *tok)
{
 (void)tok;
 return (0);
}

canonical_original_code:
int check_whitespace(struct s_token *tok)
{
 (void)tok;
 return (0);
}


decompiled_code:
__int64 check_stdchar()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 0LL;
}

original_code:
int check_stdchar(t_token *tok)
{
 (void)tok;
 return (0);
}

canonical_original_code:
int check_stdchar(struct s_token *tok)
{
 (void)tok;
 return (0);
}


decompiled_code:
__int64 __fastcall check_endofline(__int64 a1)
{
return (unsigned int)-(*(_QWORD *)(a1 + 16) != 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return (unsigned int)-(*(_QWORD *)(a1 + 16) != 0LL);
}

original_code:
int check_endofline(t_token *tok)
{
 if (tok->next != ((void *)0))
  return (-1);
 return (0);
}

canonical_original_code:
int check_endofline(struct s_token *tok)
{
 if (tok->next != ((void *)0))
  return (-1);
 return (0);
}


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

result = malloc(0x38uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
*((_BYTE *)result + 16) = 0;
*((_DWORD *)result + 5) = 0;
*((_BYTE *)result + 24) = 0;
*((_DWORD *)result + 7) = 0;
result[4] = 0LL;
*((_BYTE *)result + 40) = 0;
result[6] = 0LL;
*((_DWORD *)result + 11) = 1;
return result;
}

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

result = malloc(0x38uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
*((_BYTE *)result + 16) = 0;
*((_DWORD *)result + 5) = 0;
*((_BYTE *)result + 24) = 0;
*((_DWORD *)result + 7) = 0;
result[4] = 0LL;
*((_BYTE *)result + 40) = 0;
result[6] = 0LL;
*((_DWORD *)result + 11) = 1;
return result;
}

original_code:
t_op *ft_build_options_struct_spe(t_op *op)
{
 op = (t_op*)malloc(sizeof(t_op));
 op->field = 0;
 op->flag = ((void *)0);
 op->separator = '\0';
 op->min_width = 0;
 op->starwidth = '\0';
 op->precision = 0;
 op->mod = ((void *)0);
 op->conv = '\0';
 op->next = ((void *)0);
 op->arg_size = 1;
 return (op);
}

canonical_original_code:
struct s_option *ft_build_options_struct_spe(struct s_option *op)
{
 op = (struct s_option *)malloc(sizeof(t_op));
 op->field = 0;
 op->flag = ((void *)0);
 op->separator = '\0';
 op->min_width = 0;
 op->starwidth = '\0';
 op->precision = 0;
 op->mod = ((void *)0);
 op->conv = '\0';
 op->next = ((void *)0);
 op->arg_size = 1;
 return (op);
}

variable_types:
op
struct s_option *


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

result = malloc(0x38uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
*((_BYTE *)result + 16) = 0;
*((_DWORD *)result + 5) = 0;
*((_BYTE *)result + 24) = 0;
*((_DWORD *)result + 7) = 0;
result[4] = 0LL;
*((_BYTE *)result + 40) = 0;
result[6] = 0LL;
*((_DWORD *)result + 11) = 0;
return result;
}

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

result = malloc(0x38uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
*((_BYTE *)result + 16) = 0;
*((_DWORD *)result + 5) = 0;
*((_BYTE *)result + 24) = 0;
*((_DWORD *)result + 7) = 0;
result[4] = 0LL;
*((_BYTE *)result + 40) = 0;
result[6] = 0LL;
*((_DWORD *)result + 11) = 0;
return result;
}

original_code:
t_op *ft_build_options_struct(t_op *op)
{
 op = (t_op*)malloc(sizeof(t_op));
 op->field = 0;
 op->flag = ((void *)0);
 op->separator = '\0';
 op->min_width = 0;
 op->starwidth = '\0';
 op->precision = 0;
 op->mod = ((void *)0);
 op->conv = '\0';
 op->next = ((void *)0);
 op->arg_size = 0;
 return (op);
}

canonical_original_code:
struct s_option *ft_build_options_struct(struct s_option *op)
{
 op = (struct s_option *)malloc(sizeof(t_op));
 op->field = 0;
 op->flag = ((void *)0);
 op->separator = '\0';
 op->min_width = 0;
 op->starwidth = '\0';
 op->precision = 0;
 op->mod = ((void *)0);
 op->conv = '\0';
 op->next = ((void *)0);
 op->arg_size = 0;
 return (op);
}


decompiled_code:
void __noreturn err_usage()
{
ft_putstr_fd("Usage: ./asm file\n", 2LL);
ft_putstr_fd("\tfile: File that you want to compile for war\n", 2LL);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
ft_putstr_fd("Usage: ./asm file\n", 2LL);
ft_putstr_fd("\tfile: File that you want to compile for war\n", 2LL);
exit(1);
}

original_code:
void err_usage(void)
{
 ft_putstr_fd("Usage: ./asm file\n", 2);
 ft_putstr_fd("\tfile: File that you want to compile for war\n", 2);
 exit(1);
}

canonical_original_code:
void err_usage()
{
 ft_putstr_fd("Usage: ./asm file\n", 2);
 ft_putstr_fd("\tfile: File that you want to compile for war\n", 2);
 exit(1);
}


decompiled_code:
__int64 __fastcall err_badlabel(__int64 a1)
{
ft_putstr_fd("label : ", 2LL);
ft_putstr_fd(a1, 2LL);
return ft_putstr_fd(" called but never define\n", 2LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
ft_putstr_fd("label : ", 2LL);
ft_putstr_fd(a1, 2LL);
return ft_putstr_fd(" called but never define\n", 2LL);
}

original_code:
void err_badlabel(char *label)
{
 ft_putstr_fd("label : ", 2);
 ft_putstr_fd(label, 2);
 ft_putstr_fd(" called but never define\n", 2);
}

variable_types:
label
char *


decompiled_code:
__int64 __fastcall basic_d_conv(unsigned int *a1, __int64 a2)
{
unsigned int v2; // eax
_DWORD *v3; // rdx
unsigned int v4; // eax
int *v5; // rdx
size_t v6; // rax
unsigned int v7; // ebx
void *buf; // [rsp+8h] [rbp-10h] BYREF

if ( *(_DWORD *)(a2 + 56) )
{
v2 = *a1;
if ( *a1 > 0x2F )
{
v3 = (_DWORD *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v3 + 2;
}
else
{
v3 = (_DWORD *)(*((_QWORD *)a1 + 2) + v2);
*a1 = v2 + 8;
}
*(_DWORD *)(a2 + 16) = *v3;
}
v4 = *a1;
if ( *a1 > 0x2F )
{
v5 = (int *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v5 + 2;
}
else
{
v5 = (int *)(*((_QWORD *)a1 + 2) + v4);
*a1 = v4 + 8;
}
buf = (void *)ft_stoa(*v5);
apply_flags(&buf, a2);
v6 = ft_strlen(buf);
v7 = v6;
write(1, buf, v6);
free(buf);
return v7;
}

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

if ( *(_DWORD *)(a2 + 56) )
{
v2 = *a1;
if ( *a1 > 0x2F )
{
v3 = (_DWORD *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v3 + 2;
}
else
{
v3 = (_DWORD *)(*((_QWORD *)a1 + 2) + v2);
*a1 = v2 + 8;
}
*(_DWORD *)(a2 + 16) = *v3;
}
v4 = *a1;
if ( *a1 > 0x2F )
{
v5 = (int *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v5 + 2;
}
else
{
v5 = (int *)(*((_QWORD *)a1 + 2) + v4);
*a1 = v4 + 8;
}
buf = (void *)ft_stoa(*v5);
apply_flags(&buf, a2);
v6 = ft_strlen(buf);
v7 = v6;
write(1, buf, v6);
free(buf);
return v7;
}

original_code:
int basic_d_conv(va_list *ap, t_format *format)
{
 int conv;
 char *s;
 size_t len;
 if (format->has_star)
  format->m_width = __builtin_va_arg(*ap,int);
 conv = __builtin_va_arg(*ap,int);
 s = ft_stoa(conv);
 apply_flags(&s, format);
 len = ft_strlen(s);
 write(1, s, len);
 free(s);
 return (len);
}

canonical_original_code:
int basic_d_conv(__builtin_va_list *ap, struct s_format *format)
{
 int conv;
 char *s;
 unsigned long len;
 if (format->has_star)
  format->m_width = __builtin_va_arg(*ap,int);
 conv = __builtin_va_arg(*ap,int);
 s = ft_stoa(conv);
 apply_flags(&s, format);
 len = ft_strlen(s);
 write(1, s, len);
 free(s);
 return (len);
}

variable_types:
ap
__builtin_va_list *

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

variable_types: conv int

variable_types:
s
char *

variable_types:
len
unsigned long


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

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

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

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

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

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


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

v1 = create_conv(100LL, basic_d_conv);
add_conv(a1, v1);
v2 = create_conv(105LL, basic_d_conv);
return add_conv(a1, v2);
}

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

v1 = create_conv(100LL, basic_d_conv);
add_conv(a1, v1);
v2 = create_conv(105LL, basic_d_conv);
return add_conv(a1, v2);
}

original_code:
static void add_basic(t_conv **list)
{
 add_conv(list, create_conv('d', basic_d_conv));
 add_conv(list, create_conv('i', basic_d_conv));
}

canonical_original_code:
static void add_basic(struct s_conv **list)
{
 add_conv(list, create_conv('d', basic_d_conv));
 add_conv(list, create_conv('i', basic_d_conv));
}


decompiled_code:
void __fastcall sta_free(void ***a1)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

v2 = **a1;
if ( v2 )
free(v2);
v3 = (*a1)[1];
if ( v3 )
free(v3);
v4 = (*a1)[2];
if ( v4 )
free(v4);
}

canonical_decompiled_code:
void __fastcall func0(void ***a1)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

v2 = **a1;
if ( v2 )
free(v2);
v3 = (*a1)[1];
if ( v3 )
free(v3);
v4 = (*a1)[2];
if ( v4 )
free(v4);
}

original_code:
void sta_free(t_start **st)
{
 if ((*st)->filename)
  free((*st)->filename);
 if ((*st)->name)
  free((*st)->name);
 if ((*st)->comment)
  free((*st)->comment);
}

canonical_original_code:
void sta_free(struct s_start **st)
{
 if ((*st)->filename)
  free((*st)->filename);
 if ((*st)->name)
  free((*st)->name);
 if ((*st)->comment)
  free((*st)->comment);
}

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

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

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


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

v2 = (_QWORD *)ft_memalloc(40LL);
*a1 = v2;
if ( v2 )
{
*v2 = ft_strdup(a2);
result = 0LL;
}
else
{
ft_putstr_fd("malloc of start failed\n", 2LL);
result = 0xFFFFFFFFLL;
}
return result;
}

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

v2 = (_QWORD *)ft_memalloc(40LL);
*a1 = v2;
if ( v2 )
{
*v2 = ft_strdup(a2);
result = 0LL;
}
else
{
ft_putstr_fd("malloc of start failed\n", 2LL);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int sta_init(t_start **st, char *file)
{
 if ((*st = (t_start *)ft_memalloc(sizeof(t_start))) == ((void *)0))
 {
  ft_putstr_fd("malloc of start failed\n", 2);
  return (-1);
 }
 (*st)->filename = ft_strdup(file);
 return (0);
}

canonical_original_code:
int sta_init(struct s_start **st, char *file)
{
 if ((*st = (struct s_start *)ft_memalloc(sizeof(t_start))) == ((void *)0))
 {
  ft_putstr_fd("malloc of start failed\n", 2);
  return (-1);
 }
 (*st)->filename = ft_strdup(file);
 return (0);
}

variable_types:
file
char *

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


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

result = cmd_create("live");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 0;
*(_BYTE *)(result + 10) = 0;
*(_DWORD *)(result + 12) = 5;
return result;
}

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

result = cmd_create("live");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 0;
*(_BYTE *)(result + 10) = 0;
*(_DWORD *)(result + 12) = 5;
return result;
}

original_code:
t_cmd *cmd_createlive(void)
{
 t_cmd *cmd;
 cmd = cmd_create("live");
 cmd->nb_arg = 1;
 cmd->has_encoding = 0;
 cmd->is_idx = 0;
 cmd->size = 1 + 4;
 return (cmd);
}

canonical_original_code:
struct s_cmd *cmd_createlive()
{
 struct s_cmd *cmd;
 cmd = cmd_create("live");
 cmd->nb_arg = 1;
 cmd->has_encoding = 0;
 cmd->is_idx = 0;
 cmd->size = 1 + 4;
 return (cmd);
}

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


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

result = cmd_create("zjmp");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 0;
*(_BYTE *)(result + 10) = 1;
*(_DWORD *)(result + 12) = 3;
return result;
}

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

result = cmd_create("zjmp");
*(_BYTE *)(result + 8) = 1;
*(_BYTE *)(result + 9) = 0;
*(_BYTE *)(result + 10) = 1;
*(_DWORD *)(result + 12) = 3;
return result;
}

original_code:
t_cmd *cmd_createzjmp(void)
{
 t_cmd *cmd;
 cmd = cmd_create("zjmp");
 cmd->nb_arg = 1;
 cmd->has_encoding = 0;
 cmd->is_idx = 1;
 cmd->size = 1 + 2;
 return (cmd);
}

canonical_original_code:
struct s_cmd *cmd_createzjmp()
{
 struct s_cmd *cmd;
 cmd = cmd_create("zjmp");
 cmd->nb_arg = 1;
 cmd->has_encoding = 0;
 cmd->is_idx = 1;
 cmd->size = 1 + 2;
 return (cmd);
}