accept

decompiled_code:
__int64 __fastcall accept(int a1)
{
return accept_where(a1, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1)
{
return func14(a1, 0LL);
}

original_code:
int accept(enum token t)
{
 return accept_where(t, ((void *)0));
}


repo: bobrippling/ucc-c-compiler

decompiled_code:
__int64 __fastcall curtok_in_list(unsigned int *a1)
{
_DWORD *v1; // rdx
unsigned int v2; // eax

do
{
v2 = *a1;
if ( *a1 > 0x2F )
{
v1 = (_DWORD *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v1 + 2;
}
else
{
v1 = (_DWORD *)(*((_QWORD *)a1 + 2) + v2);
*a1 = v2 + 8;
}
if ( *v1 == 102 )
return 0LL;
}
while ( curtok != *v1 );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int *a1)
{
_DWORD *v1; // rdx
unsigned int v2; // eax

do
{
v2 = *a1;
if ( *a1 > 0x2F )
{
v1 = (_DWORD *)*((_QWORD *)a1 + 1);
*((_QWORD *)a1 + 1) = v1 + 2;
}
else
{
v1 = (_DWORD *)(*((_QWORD *)a1 + 2) + v2);
*a1 = v2 + 8;
}
if ( *v1 == 102 )
return 0LL;
}
while ( curtok != *v1 );
return 1LL;
}

original_code:
int curtok_in_list(va_list l)
{
 enum token t;
 while((enum token)(t = __builtin_va_arg(l,int)) != token_unknown)
  if(curtok == t)
   return 1;
 return 0;
}

canonical_original_code:
int curtok_in_list(__builtin_va_list l)
{
 enum token t;
 while((enum token)(t = __builtin_va_arg(l,int)) != token_unknown)
  if(curtok == t)
   return 1;
 return 0;
}

variable_types: enum token { token_do=0, token_if=1, token_else=2, token_while=3, token_for=4, token_break=5, token_continue=6, token_return=7, token_switch=8, token_case=9, token_default=10, token_goto=11, token__Generic=12, token_sizeof=13, token_typeof=14, token___auto_type=15, token__Static_assert=16, token_asm=17, token_attribute=18, token___extension__=19, token___label__=20, token_identifier=21, token_integer=22, token_floater=23, token_character=24, token_elipsis=25, token_string=26, token_void=27, token_char=28, token_short=29, token_int=30, token_long=31, token_float=32, token_double=33, token__Bool=34, token___builtin_va_list=35, token_inline=36, token__Noreturn=37, token_const=38, token_volatile=39, token_restrict=40, token_signed=41, token_unsigned=42, token_auto=43, token_static=44, token_extern=45, token_register=46, token__Alignof=47, token___alignof=48, token__Alignas=49, token_typedef=50, token_struct=51, token_union=52, token_enum=53, token_open_paren=54, token_open_block=55, token_open_square=56, token_close_paren=57, token_close_block=58, token_close_square=59, token_comma=60, token_semicolon=61, token_colon=62, token_question=63, token_plus=64, token_plus_assign=65, token_minus=66, token_minus_assign=67, token_multiply=68, token_multiply_assign=69, token_divide=70, token_divide_assign=71, token_modulus=72, token_modulus_assign=73, token_not=74, token_not_assign=75, token_bnot=76, token_bnot_assign=77, token_and=78, token_and_assign=79, token_or=80, token_or_assign=81, token_xor=82, token_xor_assign=83, token_shiftl=84, token_shiftl_assign=85, token_shiftr=86, token_shiftr_assign=87, token_increment=88, token_decrement=89, token_assign=90, token_dot=91, token_ptr=92, token_eq=93, token_le=94, token_lt=95, token_ge=96, token_gt=97, token_ne=98, token_andsc=99, token_orsc=100, token_eof=101, token_unknown=102 }

return_type: int


decompiled_code:
const char *str_stmt_continue()
{
return "continue";
}

canonical_decompiled_code:
const char *func0()
{
return "continue";
}

original_code:
const char *str_stmt_continue(void)
{
 return "continue";
}

return_type: char *


decompiled_code:
const char *str_expr_addr()
{
return "address-of";
}

canonical_decompiled_code:
const char *func0()
{
return "address-of";
}

original_code:
const char *str_expr_addr(void)
{
 return "address-of";
}


decompiled_code:
char *__fastcall str_spc_skip(char *a1)
{
const unsigned __int16 *v2; // rdx

v2 = *_ctype_b_loc();
while ( (v2[*a1] & 0x2000) != 0 )
++a1;
return a1;
}

canonical_decompiled_code:
char *__fastcall func0(char *a1)
{
const unsigned __int16 *v2; // rdx

v2 = *_ctype_b_loc();
while ( (v2[*a1] & 0x2000) != 0 )
++a1;
return a1;
}

original_code:
char *str_spc_skip(const char *s)
{
 for(; ((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISspace); s++);
 return (char *)s;
}

canonical_original_code:
char *str_spc_skip(char *s)
{
 for(; ((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISspace); s++);
 return (char *)s;
}

variable_types:
s
char *


decompiled_code:
_BOOL8 __fastcall str_endswith(const char *a1, const char *a2)
{
size_t v2; // rbp
size_t v3; // rax
_BOOL4 v4; // edx

v2 = strlen(a1);
v3 = strlen(a2);
v4 = 0;
if ( v2 >= v3 )
v4 = strcmp(&a1[v2 - v3], a2) == 0;
return v4;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const char *a1, const char *a2)
{
size_t v2; // rbp
size_t v3; // rax
_BOOL4 v4; // edx

v2 = strlen(a1);
v3 = strlen(a2);
v4 = 0;
if ( v2 >= v3 )
v4 = strcmp(&a1[v2 - v3], a2) == 0;
return v4;
}

original_code:
int str_endswith(const char *haystack, const char *needle)
{
 size_t h_l = strlen(haystack);
 size_t n_l = strlen(needle);
 if(n_l > h_l)
  return 0;
 return !strcmp(haystack + h_l - n_l, needle);
}

canonical_original_code:
int str_endswith(char *haystack, char *needle)
{
 unsigned long h_l = strlen(haystack);
 unsigned long n_l = strlen(needle);
 if(n_l > h_l)
  return 0;
 return !strcmp(haystack + h_l - n_l, needle);
}

variable_types:
haystack
char *

variable_types:
needle
char *


xsnprintf

decompiled_code:
int xsnprintf(char *a1, size_t a2, const char *a3, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a3);
result = vsnprintf(a1, a2, a3, arg);
if ( result < 0 || result >= (int)a2 )
{
fwrite("snprintf() overflow\n", 1uLL, 0x14uLL, stderr);
abort();
}
return result;
}

canonical_decompiled_code:
int func2(char *a1, size_t a2, const char *a3, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a3);
result = vsnprintf(a1, a2, a3, arg);
if ( result < 0 || result >= (int)a2 )
{
fwrite("snprintf() overflow\n", 1uLL, 0x14uLL, stderr);
abort();
}
return result;
}

original_code:
int xsnprintf(char *buf, size_t len, const char *fmt, ...)
{
 va_list l;
 int desired_space;
 __builtin_va_start(l,fmt);
 desired_space = vsnprintf(buf, len, fmt, l);
 __builtin_va_end(l);
 if(desired_space < 0 || desired_space >= (int)len){
  fprintf(stderr, "snprintf() overflow\n");
  abort();
 }
 return desired_space;
}

canonical_original_code:
int xsnprintf(char *buf, unsigned long len, char *fmt, ...)
{
 __builtin_va_list l;
 int desired_space;
 __builtin_va_start(l,fmt);
 desired_space = vsnprintf(buf, len, fmt, l);
 __builtin_va_end(l);
 if(desired_space < 0 || desired_space >= (int)len){
  fprintf(stderr, "snprintf() overflow\n");
  abort();
 }
 return desired_space;
}

variable_types:
buf
char *

variable_types:
len
unsigned long

variable_types:
fmt
char *


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

*(_QWORD *)a2 = &section_names[10 * *(unsigned int *)(a1 + 8)];
*(_QWORD *)(a2 + 8) = asconfig[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 16) = dwarf_link_stmt_list[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 20) = ld_indirect_call_via_plts[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 24) = alias_variables[*(unsigned int *)(a1 + 8)];
result = (unsigned int)dtor_via_ctor_atexit[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 28) = result;
return result;
}

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

*(_QWORD *)a2 = &section_names[10 * *(unsigned int *)(a1 + 8)];
*(_QWORD *)(a2 + 8) = asconfig[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 16) = dwarf_link_stmt_list[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 20) = ld_indirect_call_via_plts[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 24) = alias_variables[*(unsigned int *)(a1 + 8)];
result = (unsigned int)dtor_via_ctor_atexit[*(unsigned int *)(a1 + 8)];
*(_DWORD *)(a2 + 28) = result;
return result;
}

original_code:
void target_details_from_triple(const struct triple *triple, struct target_details *details)
{
 details->section_names = &section_names[triple->sys];
 details->as = asconfig[triple->sys];
 details->dwarf_link_stmt_list = dwarf_link_stmt_list[triple->sys];
 details->ld_indirect_call_via_plt = ld_indirect_call_via_plts[triple->sys];
 details->alias_variables = alias_variables[triple->sys];
 details->dtor_via_ctor_atexit = dtor_via_ctor_atexit[triple->sys];
}

canonical_original_code:
void target_details_from_triple(struct triple *triple, struct target_details *details)
{
 details->section_names = &section_names[triple->sys];
 details->as = asconfig[triple->sys];
 details->dwarf_link_stmt_list = dwarf_link_stmt_list[triple->sys];
 details->ld_indirect_call_via_plt = ld_indirect_call_via_plts[triple->sys];
 details->alias_variables = alias_variables[triple->sys];
 details->dtor_via_ctor_atexit = dtor_via_ctor_atexit[triple->sys];
}

variable_types: struct triple { enum arch { ARCH_x86_64=0, ARCH_i386=1 } arch; enum vendor { VENDOR_pc=0, VENDOR_apple=1 } vendor; enum sys { SYS_linux=0, SYS_freebsd=1, SYS_darwin=2, SYS_cygwin=3 } sys; enum abi { ABI_gnu=0, ABI_macho=1, ABI_elf=2 } abi; } *

variable_types: struct target_details { struct target_section_names { char *section_name_text; char *section_name_data; char *section_name_bss; char *section_name_rodata; char *section_name_relro; char *section_name_ctors; char *section_name_dtors; char *section_name_dbg_abbrev; char *section_name_dbg_info; char *section_name_dbg_line; } *section_names; struct target_as { struct { char *weak; char *visibility_hidden; char *no_dead_strip; } directives; char *privatelbl_prefix; int supports_visibility_protected; int supports_local_common; int stack_protector_via_tls; int supports_type_and_size; int supports_section_flags; int expr_inline; } *as; int dwarf_link_stmt_list; int ld_indirect_call_via_plt; int alias_variables; int dtor_via_ctor_atexit; } *

return_type: void

user_defined_types: struct triple { enum arch arch; enum vendor vendor; enum sys sys; enum abi abi; }

user_defined_types: struct target_details { struct target_section_names *section_names; struct target_as *as; int dwarf_link_stmt_list; int ld_indirect_call_via_plt; int alias_variables; int dtor_via_ctor_atexit; }


decompiled_code:
_BOOL8 __fastcall should_use_libc(unsigned __int64 a1)
{
if ( cc1_fopt[2] )
return 0LL;
if ( cc1_mstringop_strategy == 1 )
return 0LL;
if ( cc1_mstringop_strategy == 2 )
return cc1_mstringop_threshold <= a1;
if ( cc1_mstringop_strategy )
_assert_fail("0 && \"unreachable\"", "out/mem.c", 0x2Cu, "should_use_libc");
return 1LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned __int64 a1)
{
if ( cc1_fopt[2] )
return 0LL;
if ( cc1_mstringop_strategy == 1 )
return 0LL;
if ( cc1_mstringop_strategy == 2 )
return cc1_mstringop_threshold <= a1;
if ( cc1_mstringop_strategy )
_assert_fail("0 && \"unreachable\"", "out/mem.c", 0x2Cu, "should_use_libc");
return 1LL;
}

original_code:
static int should_use_libc(unsigned long nbytes)
{
 if(cc1_fopt.freestanding)
  return 0;
 switch(cc1_mstringop_strategy){
  case STRINGOP_STRATEGY_LIBCALL:
   return 1;
  case STRINGOP_STRATEGY_LOOP:
   return 0;
  case STRINGOP_STRATEGY_THRESHOLD:
   return nbytes >= cc1_mstringop_threshold;
 }
 ((0 && "unreachable") ? (void) (0) : __assert_fail ("0 && \"unreachable\"", "out/mem.c", 44, __extension__ __PRETTY_FUNCTION__));
}

variable_types:
nbytes
unsigned long


decompiled_code:
int __fastcall ice_msg(const char *a1, const char *a2, unsigned int a3, const char *a4, const char *a5, void *a6)
{
__int64 v10; // rax
const char *v11; // rax

v10 = default_where(0LL);
v11 = (const char *)where_str(v10);
fprintf(stderr, "%s: %s %s:%d (%s): ", v11, a1, a2, a3, a4);
vfprintf(stderr, a5, a6);
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func0(const char *a1, const char *a2, unsigned int a3, const char *a4, const char *a5, void *a6)
{
__int64 v10; // rax
const char *v11; // rax

v10 = default_where(0LL);
v11 = (const char *)where_str(v10);
fprintf(stderr, "%s: %s %s:%d (%s): ", v11, a1, a2, a3, a4);
vfprintf(stderr, a5, a6);
return fputc(10, stderr);
}

original_code:
static void ice_msg(const char *pre,
  const char *f, int line, const char *fn, const char *fmt, va_list l)
{
 const struct where *w = default_where(((void *)0));
 fprintf(stderr, "%s: %s %s:%d (%s): ",
   where_str(w), pre, f, line, fn);
 vfprintf(stderr, fmt, l);
 fputc('\n', stderr);
}

canonical_original_code:
static void ice_msg(char *pre, char *f, int line, char *fn, char *fmt, __builtin_va_list l)
{
 struct where *w = default_where(((void *)0));
 fprintf(stderr, "%s: %s %s:%d (%s): ",
   where_str(w), pre, f, line, fn);
 vfprintf(stderr, fmt, l);
 fputc('\n', stderr);
}

variable_types:
pre
char *

variable_types:
f
char *

variable_types: line int

variable_types:
fn
char *

variable_types: struct where { char *fname; unsigned int line; unsigned short chr; unsigned char is_sysh; } *


icw

decompiled_code:
int icw(const char *a1, unsigned int a2, const char *a3, const char *a4, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a4);
return ice_msg("ICW", a1, a2, a3, a4, va);
}

canonical_decompiled_code:
int func2(const char *a1, unsigned int a2, const char *a3, const char *a4, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a4);
return func0("ICW", a1, a2, a3, a4, va);
}

original_code:
void icw(const char *f, int line, const char *fn, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICW", f, line, fn, fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void icw(char *f, int line, char *fn, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICW", f, line, fn, fmt, l);
 __builtin_va_end(l);
}


udirname

decompiled_code:
__int64 __fastcall udirname(const char *a1)
{
char *v1; // rax
char *v2; // rbx
__int64 result; // rax

v1 = strrchr(a1, 47);
if ( !v1 )
return ustrdup("./");
v2 = v1;
result = ustrdup(a1);
*(_BYTE *)(result + v2 - a1) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
char *v1; // rax
char *v2; // rbx
__int64 result; // rax

v1 = strrchr(a1, 47);
if ( !v1 )
return ustrdup("./");
v2 = v1;
result = ustrdup(a1);
*(_BYTE *)(result + v2 - a1) = 0;
return result;
}

original_code:
char *udirname(const char *f)
{
 const char *fin;
 fin = strrchr(f, '/');
 if(fin){
  char *dup = ustrdup(f);
  dup[fin - f] = '\0';
  return dup;
 }else{
  return ustrdup("./");
 }
}

canonical_original_code:
char *udirname(char *f)
{
 char *fin;
 fin = strrchr(f, '/');
 if(fin){
  char *dup = ustrdup(f);
  dup[fin - f] = '\0';
  return dup;
 }else{
  return ustrdup("./");
 }
}

variable_types:
fin
char *

variable_types:
dup
char *


decompiled_code:
char *__fastcall ext_replace(char *src, char *s)
{
char *v2; // rax
char *v3; // rbx
size_t v4; // r12
size_t v5; // rax
char *v6; // r12

v2 = strrchr(src, 46);
if ( !v2 )
return (char *)ustrdup(src);
v3 = v2;
v4 = strlen(s);
v5 = strlen(src);
v6 = (char *)umalloc(v4 + v5);
strcpy(v6, src);
sprintf(&v6[v3 - src], ".%s", s);
return v6;
}

canonical_decompiled_code:
char *__fastcall func4(char *src, char *s)
{
char *v2; // rax
char *v3; // rbx
size_t v4; // r12
size_t v5; // rax
char *v6; // r12

v2 = strrchr(src, 46);
if ( !v2 )
return (char *)ustrdup(src);
v3 = v2;
v4 = strlen(s);
v5 = strlen(src);
v6 = (char *)umalloc(v4 + v5);
strcpy(v6, src);
sprintf(&v6[v3 - src], ".%s", s);
return v6;
}

original_code:
char *ext_replace(const char *str, const char *ext)
{
 char *dot;
 dot = strrchr(str, '.');
 if(dot){
  char *dup;
  dup = umalloc(strlen(ext) + strlen(str));
  strcpy(dup, str);
  sprintf(dup + (dot - str), ".%s", ext);
  return dup;
 }else{
  return ustrdup(str);
 }
}

canonical_original_code:
char *ext_replace(char *str, char *ext)
{
 char *dot;
 dot = strrchr(str, '.');
 if(dot){
  char *dup;
  dup = umalloc(strlen(ext) + strlen(str));
  strcpy(dup, str);
  sprintf(dup + (dot - str), ".%s", ext);
  return dup;
 }else{
  return ustrdup(str);
 }
}

variable_types:
str
char *

variable_types:
ext
char *

variable_types:
dot
char *


ice

decompiled_code:
void __noreturn ice(const char *a1, unsigned int a2, const char *a3, const char *a4, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a4);
ice_msg("ICE", a1, a2, a3, a4, va);
abort();
}

canonical_decompiled_code:
void __noreturn func1(const char *a1, unsigned int a2, const char *a3, const char *a4, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a4);
func0("ICE", a1, a2, a3, a4, va);
abort();
}

original_code:
void ice(const char *f, int line, const char *fn, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICE", f, line, fn, fmt, l);
 __builtin_va_end(l);
 abort();
}

canonical_original_code:
void ice(char *f, int line, char *fn, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICE", f, line, fn, fmt, l);
 __builtin_va_end(l);
 abort();
}


decompiled_code:
__int64 __fastcall decl_cmp_ctor_pri(_QWORD *a1, __int64 *a2)
{
return decl_cmp_ctor_dtor_pri(a1, a2, 0x13u);
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, __int64 *a2)
{
return func0(a1, a2, 0x13u);
}

original_code:
static int decl_cmp_ctor_pri(const void *a, const void *b)
{
 return decl_cmp_ctor_dtor_pri(a, b, attr_constructor);
}

canonical_original_code:
static int decl_cmp_ctor_pri(void *a, void *b)
{
 return decl_cmp_ctor_dtor_pri(a, b, attr_constructor);
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
__int64 __fastcall decl_cmp_dtor_pri(_QWORD *a1, __int64 *a2)
{
return decl_cmp_ctor_dtor_pri(a1, a2, 0x14u);
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 *a2)
{
return func0(a1, a2, 0x14u);
}

original_code:
static int decl_cmp_dtor_pri(const void *a, const void *b)
{
 return decl_cmp_ctor_dtor_pri(a, b, attr_destructor);
}

canonical_original_code:
static int decl_cmp_dtor_pri(void *a, void *b)
{
 return decl_cmp_ctor_dtor_pri(a, b, attr_destructor);
}


decompiled_code:
const char *str_expr_assign_compound()
{
return "compound-assignment";
}

canonical_decompiled_code:
const char *func0()
{
return "compound-assignment";
}

original_code:
const char *str_expr_assign_compound(void)
{
 return "compound-assignment";
}


decompiled_code:
__int64 __fastcall in_array(char *s1, const char **a2)
{
const char **v2; // rbx
const char *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 0LL;
while ( strcmp(s1, v3) )
{
v3 = *++v2;
if ( !*v2 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, const char **a2)
{
const char **v2; // rbx
const char *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 0LL;
while ( strcmp(s1, v3) )
{
v3 = *++v2;
if ( !*v2 )
return 0LL;
}
return 1LL;
}

original_code:
static int in_array(const char *needle, const char *haystack[])
{
 const char **i;
 for(i = haystack; *i; i++)
  if(!strcmp(needle, *i))
   return 1;
 return 0;
}

canonical_original_code:
static int in_array(char *needle, char *haystack[])
{
 char **i;
 for(i = haystack; *i; i++)
  if(!strcmp(needle, *i))
   return 1;
 return 0;
}

variable_types:
needle
char *

variable_types:
haystack
char *[]

variable_types:
i
char **


decompiled_code:
__int64 __fastcall warning_owner(char *a1)
{
char *v1; // rbx
unsigned int v2; // ebp
int v3; // edx

v1 = a1;
if ( !memcmp(a1, &unk_8F1, 3uLL) )
v1 += 3;
if ( !memcmp(v1, "error=", 6uLL) )
{
v1 += 6;
v2 = 2;
if ( !strcmp(v1, "all") )
return v2;
v3 = 1;
}
else
{
v2 = 3;
v3 = 0;
if ( !strcmp(v1, "all") )
return v2;
}
v2 = 3 - v3;
if ( strcmp(v1, "everything") )
{
v2 = 2;
if ( strcmp(v1, "extra") )
{
if ( strcmp(v1, "error") && *v1 && strcmp(v1, "gnu") )
{
v2 = 0;
if ( !v3 )
v2 = in_array(v1, (const char **)wcpp) != 0;
if ( (unsigned int)in_array(v1, (const char **)wcc1) )
v2 |= 2u;
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1)
{
char *v1; // rbx
unsigned int v2; // ebp
int v3; // edx

v1 = a1;
if ( !memcmp(a1, &unk_8F1, 3uLL) )
v1 += 3;
if ( !memcmp(v1, "error=", 6uLL) )
{
v1 += 6;
v2 = 2;
if ( !strcmp(v1, "all") )
return v2;
v3 = 1;
}
else
{
v2 = 3;
v3 = 0;
if ( !strcmp(v1, "all") )
return v2;
}
v2 = 3 - v3;
if ( strcmp(v1, "everything") )
{
v2 = 2;
if ( strcmp(v1, "extra") )
{
if ( strcmp(v1, "error") && *v1 && strcmp(v1, "gnu") )
{
v2 = 0;
if ( !v3 )
v2 = func0(v1, (const char **)wcpp) != 0;
if ( (unsigned int)func0(v1, (const char **)wcc1) )
v2 |= 2u;
}
}
}
return v2;
}

original_code:
enum warning_owner warning_owner(const char *arg)
{
 enum warning_owner owner = 0;
 int is_werror = 0;
 if(!strncmp(arg, "no-", 3))
  arg += 3;
 if(!strncmp(arg, "error=", 6)){
  is_werror = 1;
  arg += 6;
 }
 if(!strcmp(arg, "all")
 || !strcmp(arg, "everything"))
 {
  return W_OWNER_CC1 | (is_werror ? 0 : W_OWNER_CPP);
 }
 if(!strcmp(arg, "extra")
 || !strcmp(arg, "error")
 || !*arg )
 {
  return W_OWNER_CC1;
 }
 if(!strcmp(arg, "gnu"))
  return W_OWNER_CC1;
 if(!is_werror && in_array(arg, wcpp))
  owner |= W_OWNER_CPP;
 if(in_array(arg, wcc1))
  owner |= W_OWNER_CC1;
 return owner;
}

canonical_original_code:
enum warning_owner warning_owner(char *arg)
{
 enum warning_owner owner = 0;
 int is_werror = 0;
 if(!strncmp(arg, "no-", 3))
  arg += 3;
 if(!strncmp(arg, "error=", 6)){
  is_werror = 1;
  arg += 6;
 }
 if(!strcmp(arg, "all")
 || !strcmp(arg, "everything"))
 {
  return W_OWNER_CC1 | (is_werror ? 0 : W_OWNER_CPP);
 }
 if(!strcmp(arg, "extra")
 || !strcmp(arg, "error")
 || !*arg )
 {
  return W_OWNER_CC1;
 }
 if(!strcmp(arg, "gnu"))
  return W_OWNER_CC1;
 if(!is_werror && in_array(arg, wcpp))
  owner |= W_OWNER_CPP;
 if(in_array(arg, wcc1))
  owner |= W_OWNER_CC1;
 return owner;
}

variable_types:
arg
char *

variable_types: enum warning_owner { W_OWNER_CPP=expr, W_OWNER_CC1=expr }


decompiled_code:
const char *str_expr_deref()
{
return "dereference";
}

canonical_decompiled_code:
const char *func0()
{
return "dereference";
}

original_code:
const char *str_expr_deref(void)
{
 return "dereference";
}


decompiled_code:
void *str_stmt_if()
{
return &unk_3C0;
}

canonical_decompiled_code:
void *func1()
{
return &unk_3C0;
}

original_code:
const char *str_stmt_if(void)
{
 return "if";
}

canonical_original_code:
char *str_stmt_if()
{
 return "if";
}


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

result = umalloc(32LL);
*(_DWORD *)result = 1;
*(_QWORD *)(result + 8) = out_dbg_label_free;
*(_QWORD *)(result + 16) = a1;
return result;
}

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

result = umalloc(32LL);
*(_DWORD *)result = 1;
*(_QWORD *)(result + 8) = out_dbg_label_free;
*(_QWORD *)(result + 16) = a1;
return result;
}

original_code:
static struct out_dbg_lbl *dbg_lbl_new(char *strlbl)
{
 struct out_dbg_lbl *lbl = umalloc(sizeof *lbl);
 (lbl)->rc.retains = 1, (lbl)->rc.pfree = (retain_free_f *)(&out_dbg_label_free);
 lbl->lbl = strlbl;
 return lbl;
}

canonical_original_code:
static struct out_dbg_lbl *dbg_lbl_new(char *strlbl)
{
 struct out_dbg_lbl *lbl = umalloc(sizeof *lbl);
 (lbl)->rc.retains = 1, (lbl)->rc.pfree = (void (*)(void *))(&out_dbg_label_free);
 lbl->lbl = strlbl;
 return lbl;
}

variable_types:
strlbl
char *

variable_types: struct out_dbg_lbl { struct retain { unsigned int retains; void (*pfree)(void *); } rc; char *lbl; int emitted; } *

user_defined_types: struct out_dbg_lbl { struct retain rc; char *lbl; int emitted; }


decompiled_code:
void __fastcall out_dbg_label_free(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
static void out_dbg_label_free(struct out_dbg_lbl *lbl)
{
 free(lbl->lbl);
 free(lbl);
}

user_defined_types: struct retain { unsigned int retains; void (*pfree)(void *); }


decompiled_code:
__int64 __fastcall out_dbg_label_emitted(__int64 a1, _QWORD *a2)
{
if ( a2 )
*a2 = *(_QWORD *)(a1 + 16);
return *(unsigned int *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _QWORD *a2)
{
if ( a2 )
*a2 = *(_QWORD *)(a1 + 16);
return *(unsigned int *)(a1 + 24);
}

original_code:
int out_dbg_label_emitted(struct out_dbg_lbl *lbl, const char **out_lbl)
{
 if(out_lbl)
  *out_lbl = lbl->lbl;
 return lbl->emitted;
}

canonical_original_code:
int out_dbg_label_emitted(struct out_dbg_lbl *lbl, char **out_lbl)
{
 if(out_lbl)
  *out_lbl = lbl->lbl;
 return lbl->emitted;
}


decompiled_code:
_BOOL8 __fastcall out_dbg_label_shouldemit(__int64 a1, _QWORD *a2)
{
return (unsigned int)out_dbg_label_emitted(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1, _QWORD *a2)
{
return (unsigned int)func5(a1, a2) == 0;
}

original_code:
int out_dbg_label_shouldemit(struct out_dbg_lbl *lbl, const char **out_lbl)
{
 return !out_dbg_label_emitted(lbl, out_lbl);
}

canonical_original_code:
int out_dbg_label_shouldemit(struct out_dbg_lbl *lbl, char **out_lbl)
{
 return !out_dbg_label_emitted(lbl, out_lbl);
}


decompiled_code:
__int64 __fastcall emit_lbl(__int64 a1, __int64 a2)
{
__int64 result; // rax
bool v3; // zf

result = out_dbg_label_shouldemit(a1, 0LL);
if ( (_DWORD)result )
{
asm_out_section(a2, "%s:\n", *(const char **)(a1 + 16));
*(_DWORD *)(a1 + 24) = 1;
}
else if ( !a1 )
{
return result;
}
v3 = *(_DWORD *)a1 == 1;
result = (unsigned int)(*(_DWORD *)a1 - 1);
*(_DWORD *)a1 = result;
if ( v3 )
result = (*(__int64 (__fastcall **)(__int64))(a1 + 8))(a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 result; // rax
bool v3; // zf

result = func6(a1, 0LL);
if ( (_DWORD)result )
{
asm_out_section(a2, "%s:\n", *(const char **)(a1 + 16));
*(_DWORD *)(a1 + 24) = 1;
}
else if ( !a1 )
{
return result;
}
v3 = *(_DWORD *)a1 == 1;
result = (unsigned int)(*(_DWORD *)a1 - 1);
*(_DWORD *)a1 = result;
if ( v3 )
result = (*(__int64 (__fastcall **)(__int64))(a1 + 8))(a1);
return result;
}

original_code:
static void emit_lbl(struct out_dbg_lbl *lbl, const struct section *sec)
{
 if(out_dbg_label_shouldemit(lbl, ((void *)0))){
  asm_out_section(sec, "%s:\n", lbl->lbl);
  lbl->emitted = 1;
 }
 do{ if(lbl && --(lbl)->rc.retains == 0) (lbl)->rc.pfree(lbl); }while(0);
}

canonical_original_code:
static void emit_lbl(struct out_dbg_lbl *lbl, struct section *sec)
{
 if(out_dbg_label_shouldemit(lbl, ((void *)0))){
  asm_out_section(sec, "%s:\n", lbl->lbl);
  lbl->emitted = 1;
 }
 do{ if(lbl && --(lbl)->rc.retains == 0) (lbl)->rc.pfree(lbl); }while(0);
}

variable_types: struct section { char *name; int builtin; enum section_flags { SECTION_FLAG_EXECUTABLE=expr, SECTION_FLAG_RO=expr } flags; } *

user_defined_types: struct section { char *name; int builtin; enum section_flags flags; }


decompiled_code:
const char *str_expr_comma()
{
return "comma";
}

canonical_decompiled_code:
const char *func0()
{
return "comma";
}

original_code:
const char *str_expr_comma(void)
{
 return "comma";
}


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

for ( result = (unsigned __int8)*a1; (_BYTE)result; result = (unsigned __int8)*a1 )
{
if ( (_BYTE)result == 46 )
*a1 = 95;
++a1;
}
return result;
}

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

for ( result = (unsigned __int8)*a1; (_BYTE)result; result = (unsigned __int8)*a1 )
{
if ( (_BYTE)result == 46 )
*a1 = 95;
++a1;
}
return result;
}

original_code:
static void dot_replace(char *lbl)
{
 for(; *lbl; lbl++)
  if(*lbl == '.')
   *lbl = '_';
}

variable_types:
lbl
char *


decompiled_code:
void __fastcall dot_emit(__int64 a1, __int64 a2)
{
_BYTE *v2; // rbp
_BYTE *v3; // rbx

v2 = (_BYTE *)((__int64 (*)(void))ustrdup)();
v3 = (_BYTE *)ustrdup(a2);
dot_replace(v2);
dot_replace(v3);
fprintf(stderr, "%s -> %s;\n", v2, v3);
free(v2);
free(v3);
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, __int64 a2)
{
_BYTE *v2; // rbp
_BYTE *v3; // rbx

v2 = (_BYTE *)((__int64 (*)(void))ustrdup)();
v3 = (_BYTE *)ustrdup(a2);
func0(v2);
func0(v3);
fprintf(stderr, "%s -> %s;\n", v2, v3);
free(v2);
free(v3);
}

original_code:
static void dot_emit(const char *from, const char *to)
{
 char *from_ = ustrdup(from);
 char *to_ = ustrdup(to);
 dot_replace(from_);
 dot_replace(to_);
 fprintf(stderr, "%s -> %s;\n", from_, to_);
 free(from_);
 free(to_);
}

canonical_original_code:
static void dot_emit(char *from, char *to)
{
 char *from_ = ustrdup(from);
 char *to_ = ustrdup(to);
 dot_replace(from_);
 dot_replace(to_);
 fprintf(stderr, "%s -> %s;\n", from_, to_);
 free(from_);
 free(to_);
}

variable_types:
from
char *

variable_types:
to
char *


decompiled_code:
const char *__fastcall v_store_to_str(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "V_CONST_I";
break;
case 1:
result = "V_REG";
break;
case 2:
result = "V_SPILT";
break;
case 3:
result = "V_REGOFF";
break;
case 4:
result = "V_LBL";
break;
case 5:
result = "V_CONST_F";
break;
case 6:
result = "V_FLAG";
break;
default:
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func2(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "V_CONST_I";
break;
case 1:
result = "V_REG";
break;
case 2:
result = "V_SPILT";
break;
case 3:
result = "V_REGOFF";
break;
case 4:
result = "V_LBL";
break;
case 5:
result = "V_CONST_F";
break;
case 6:
result = "V_FLAG";
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
const char *v_store_to_str(enum out_val_store store)
{
 switch(store){
  case V_CONST_I: return "V_CONST_I";
  case V_REG: return "V_REG";
  case V_REGOFF: return "V_REGOFF";
  case V_SPILT: return "V_SPILT";
  case V_LBL: return "V_LBL";
  case V_CONST_F: return "V_CONST_F";
  case V_FLAG: return "V_FLAG";
 }
 return ((void *)0);
}

variable_types: enum out_val_store { V_CONST_I=0, V_REG=1, V_SPILT=2, V_REGOFF=3, V_LBL=4, V_CONST_F=5, V_FLAG=6 }


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

result = 0LL;
if ( *(_WORD *)a1 == *(_WORD *)a2 )
result = *(_BYTE *)(a1 + 2) == *(_BYTE *)(a2 + 2);
return result;
}

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

result = 0LL;
if ( *(_WORD *)a1 == *(_WORD *)a2 )
result = *(_BYTE *)(a1 + 2) == *(_BYTE *)(a2 + 2);
return result;
}

original_code:
int vreg_eq(const struct vreg *a, const struct vreg *b)
{
 return a->idx == b->idx && a->is_float == b->is_float;
}

canonical_original_code:
int vreg_eq(struct vreg *a, struct vreg *b)
{
 return a->idx == b->idx && a->is_float == b->is_float;
}

variable_types: struct vreg { unsigned short idx; unsigned char is_float; } *

variable_types:
b
struct vreg *


decompiled_code:
_BOOL8 __fastcall increment_str(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax

v2 = *a1 + 1;
*a1 = v2;
return v2 < a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax

v2 = *a1 + 1;
*a1 = v2;
return v2 < a2;
}

original_code:
static int increment_str(size_t *i, size_t len)
{
 return ++*i < len;
}

canonical_original_code:
static int increment_str(unsigned long *i, unsigned long len)
{
 return ++*i < len;
}

variable_types:
i
unsigned long *

variable_types:
len
unsigned long


decompiled_code:
_BOOL8 __fastcall parse_digit(__int64 a1, unsigned __int64 *a2, unsigned __int64 a3, _DWORD *a4)
{
const unsigned __int16 **v5; // r13
_BOOL8 result; // rax

if ( *(_BYTE *)(a1 + *a2) == 42 )
{
*a4 = 1;
result = increment_str(a2, a3);
}
else
{
v5 = _ctype_b_loc();
while ( ((*v5)[*(char *)(a1 + *a2)] & 0x800) != 0 )
{
result = increment_str(a2, a3);
if ( !result )
return result;
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1, unsigned __int64 *a2, unsigned __int64 a3, _DWORD *a4)
{
const unsigned __int16 **v5; // r13
_BOOL8 result; // rax

if ( *(_BYTE *)(a1 + *a2) == 42 )
{
*a4 = 1;
result = func0(a2, a3);
}
else
{
v5 = _ctype_b_loc();
while ( ((*v5)[*(char *)(a1 + *a2)] & 0x800) != 0 )
{
result = func0(a2, a3);
if ( !result )
return result;
}
result = 1LL;
}
return result;
}

original_code:
static int parse_digit(const char *fmt, size_t *const i, size_t const len, int *const got_asterisk)
{
 if(fmt[*i] == '*'){
  *got_asterisk = 1;
  return increment_str(i, len);
 }
 while(((*__ctype_b_loc ())[(int) ((fmt[*i]))] & (unsigned short int) _ISdigit)){
  if(!increment_str(i, len))
   return 0;
 }
 return 1;
}

canonical_original_code:
static int parse_digit(char *fmt, unsigned long *i, unsigned long len, int *got_asterisk)
{
 if(fmt[*i] == '*'){
  *got_asterisk = 1;
  return increment_str(i, len);
 }
 while(((*__ctype_b_loc ())[(int) ((fmt[*i]))] & (unsigned short) _ISdigit)){
  if(!increment_str(i, len))
   return 0;
 }
 return 1;
}

variable_types:
fmt
char *


stylef

decompiled_code:
__int64 stylef(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-E0h] BYREF
__int64 v3; // [rsp+20h] [rbp-C8h] BYREF
int v4; // [rsp+28h] [rbp-C0h]
int v5; // [rsp+2Ch] [rbp-BCh]

va_start(va, a1);
v3 = 0LL;
v4 = 0;
v5 = -1;
return asm_out_sectionv(&v3, a1, va);
}

canonical_decompiled_code:
__int64 func0(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-E0h] BYREF
__int64 v3; // [rsp+20h] [rbp-C8h] BYREF
int v4; // [rsp+28h] [rbp-C0h]
int v5; // [rsp+2Ch] [rbp-BCh]

va_start(va, a1);
v3 = 0LL;
v4 = 0;
v5 = -1;
return asm_out_sectionv(&v3, a1, va);
}

original_code:
void stylef(const char *fmt, ...)
{
 struct section sec = { ((void *)0), SECTION_TEXT, -1 };
 va_list l;
 __builtin_va_start(l,fmt);
 asm_out_sectionv(&sec, fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void stylef(char *fmt, ...)
{
 struct section sec = { ((void *)0), SECTION_TEXT, -1 };
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 asm_out_sectionv(&sec, fmt, l);
 __builtin_va_end(l);
}

variable_types: struct section { char *name; int builtin; enum section_flags { SECTION_FLAG_EXECUTABLE=expr, SECTION_FLAG_RO=expr } flags; }


decompiled_code:
__int64 __fastcall pack_to_align(__int64 a1, unsigned int a2)
{
if ( !a2 )
_assert_fail("align > 0", "pack.c", 0xAu, "pack_to_align");
return -a2 & (a1 + a2 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2)
{
if ( !a2 )
_assert_fail("align > 0", "pack.c", 0xAu, "pack_to_align");
return -a2 & (a1 + a2 - 1);
}

original_code:
pack_t pack_to_align(pack_t sz, unsigned align)
{
 ((align > 0) ? (void) (0) : __assert_fail ("align > 0", "pack.c", 10, __extension__ __PRETTY_FUNCTION__));
 return (sz + align - 1) & -align;
}

canonical_original_code:
unsigned long pack_to_align(unsigned long sz, unsigned int align)
{
 ((align > 0) ? (void) (0) : __assert_fail ("align > 0", "pack.c", 10, __extension__ __PRETTY_FUNCTION__));
 return (sz + align - 1) & -align;
}

variable_types:
sz
unsigned long

variable_types:
align
unsigned int

return_type: unsigned long


decompiled_code:
__int64 __fastcall pack_to_word(__int64 a1)
{
if ( !pws_0 )
pws_0 = platform_word_size();
return pack_to_align(a1, pws_0);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
if ( !pws_0 )
pws_0 = platform_word_size();
return func0(a1, pws_0);
}

original_code:
pack_t pack_to_word(pack_t o)
{
 static unsigned pws;
 if(!pws)
  pws = platform_word_size();
 return pack_to_align(o, pws);
}

canonical_original_code:
unsigned long pack_to_word(unsigned long o)
{
 static unsigned int pws;
 if(!pws)
  pws = platform_word_size();
 return pack_to_align(o, pws);
}

variable_types:
o
unsigned long

variable_types:
pws
unsigned int


rtrim

decompiled_code:
size_t __fastcall rtrim(const char *a1)
{
size_t result; // rax
size_t i; // rbx

result = strlen(a1);
for ( i = result; i; --i )
{
result = (size_t)*_ctype_b_loc();
if ( (*(_BYTE *)(result + 2LL * a1[i - 1] + 1) & 0x20) == 0 )
break;
}
a1[i] = 0;
return result;
}

canonical_decompiled_code:
size_t __fastcall func1(const char *a1)
{
size_t result; // rax
size_t i; // rbx

result = strlen(a1);
for ( i = result; i; --i )
{
result = (size_t)*_ctype_b_loc();
if ( (*(_BYTE *)(result + 2LL * a1[i - 1] + 1) & 0x20) == 0 )
break;
}
a1[i] = 0;
return result;
}

original_code:
void rtrim(char *s)
{
 size_t l = strlen(s);
 while(l > 0 && ((*__ctype_b_loc ())[(int) ((s[l-1]))] & (unsigned short int) _ISspace))
  l--;
 s[l] = '\0';
}

canonical_original_code:
void rtrim(char *s)
{
 unsigned long l = strlen(s);
 while(l > 0 && ((*__ctype_b_loc ())[(int) ((s[l-1]))] & (unsigned short) _ISspace))
  l--;
 s[l] = '\0';
}

variable_types:
s
char *

variable_types:
l
unsigned long


decompiled_code:
const char *str_stmt_goto()
{
return "goto";
}

canonical_decompiled_code:
const char *func1()
{
return "goto";
}

original_code:
const char *str_stmt_goto(void)
{
 return "goto";
}


decompiled_code:
const char *str_expr__Generic()
{
return "_Generic";
}

canonical_decompiled_code:
const char *func0()
{
return "_Generic";
}

original_code:
const char *str_expr__Generic(void)
{
 return "_Generic";
}


decompiled_code:
const char *str_expr_sizeof()
{
return "sizeof/typeof/alignof";
}

canonical_decompiled_code:
const char *func1()
{
return "sizeof/typeof/alignof";
}

original_code:
const char *str_expr_sizeof(void)
{
 return "sizeof/typeof/alignof";
}


decompiled_code:
const char *str_stmt_switch()
{
return "switch";
}

canonical_decompiled_code:
const char *func4()
{
return "switch";
}

original_code:
const char *str_stmt_switch(void)
{
 return "switch";
}


decompiled_code:
const char *str_stmt_expr()
{
return "expression";
}

canonical_decompiled_code:
const char *func2()
{
return "expression";
}

original_code:
const char *str_stmt_expr(void)
{
 return "expression";
}


decompiled_code:
const char *str_stmt_default()
{
return "default";
}

canonical_decompiled_code:
const char *func0()
{
return "default";
}

original_code:
const char *str_stmt_default(void)
{
 return "default";
}


decompiled_code:
void *str_stmt_for()
{
return &unk_440;
}

canonical_decompiled_code:
void *func2()
{
return &unk_440;
}

original_code:
const char *str_stmt_for(void)
{
 return "for";
}

canonical_original_code:
char *str_stmt_for()
{
 return "for";
}


decompiled_code:
const char *str_expr_block()
{
return "block";
}

canonical_decompiled_code:
const char *func0()
{
return "block";
}

original_code:
const char *str_expr_block(void)
{
 return "block";
}


decompiled_code:
const char *str_expr_compound_lit()
{
return "compound-lit";
}

canonical_decompiled_code:
const char *func0()
{
return "compound-lit";
}

original_code:
const char *str_expr_compound_lit(void)
{
 return "compound-lit";
}


decompiled_code:
const char *str_expr_identifier()
{
return "identifier";
}

canonical_decompiled_code:
const char *func0()
{
return "identifier";
}

original_code:
const char *str_expr_identifier(void)
{
 return "identifier";
}


decompiled_code:
const char *str_stmt_noop()
{
return "noop";
}

canonical_decompiled_code:
const char *func0()
{
return "noop";
}

original_code:
const char *str_stmt_noop(void)
{
 return "noop";
}


test

decompiled_code:
int __fastcall test(int a1, const char *a2)
{
int result; // eax

if ( !a1 )
{
ec = 1;
result = fprintf(stderr, "test failed: %s\n", a2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(int a1, const char *a2)
{
int result; // eax

if ( !a1 )
{
ec = 1;
result = fprintf(stderr, "test failed: %s\n", a2);
}
return result;
}

original_code:
static void test(int cond, const char *expr, int line)
{
 if(!cond){
  ec = 1;
  fprintf(stderr, "%s:%d: test failed: %s\n", "test.c", line, expr);
 }
}

canonical_original_code:
static void test(int cond, char *expr, int line)
{
 if(!cond){
  ec = 1;
  fprintf(stderr, "%s:%d: test failed: %s\n", "test.c", line, expr);
 }
}

variable_types: cond int

variable_types:
expr
char *

variable_types: line int


icw

decompiled_code:
int icw(const char *a1, unsigned int a2, const char *a3, const char *a4, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a4);
fprintf(stderr, "%s:%d: %s: ", a1, a2, a3);
vfprintf(stderr, a4, arg);
result = fputc(10, stderr);
ec = 1;
return result;
}

canonical_decompiled_code:
int func8(const char *a1, unsigned int a2, const char *a3, const char *a4, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a4);
fprintf(stderr, "%s:%d: %s: ", a1, a2, a3);
vfprintf(stderr, a4, arg);
result = fputc(10, stderr);
ec = 1;
return result;
}

original_code:
void icw(const char *f, int line, const char *fn, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICW", f, line, fn, fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void icw(char *f, int line, char *fn, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICW", f, line, fn, fmt, l);
 __builtin_va_end(l);
}

variable_types:
f
char *

variable_types:
fn
char *


ice

decompiled_code:
void __fastcall __noreturn ice(const char *a1, unsigned int a2, const char *a3)
{
fprintf(stderr, "%s:%d: ice: %s\n", a1, a2, a3);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(const char *a1, unsigned int a2, const char *a3)
{
fprintf(stderr, "%s:%d: ice: %s\n", a1, a2, a3);
exit(1);
}

original_code:
void ice(const char *f, int line, const char *fn, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICE", f, line, fn, fmt, l);
 __builtin_va_end(l);
 abort();
}

canonical_original_code:
void ice(char *f, int line, char *fn, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 ice_msg("ICE", f, line, fn, fmt, l);
 __builtin_va_end(l);
 abort();
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
test_dynmap(argc, argv, envp);
test_dynarray();
test_canon_all();
test_math();
test_str();
return ec;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func11(argc, argv, envp);
func2();
func4();
func5();
func6();
return ec;
}

original_code:
int main(void)
{
 cc1_type_nav = type_nav_init();
 test_quals();
 test_decl_interposability();
 test_decl_needs_GOTPLT();
 test_warnings();
 test_out_out();
 return ec;
}

canonical_original_code:
int main()
{
 cc1_type_nav = type_nav_init();
 test_quals();
 test_decl_interposability();
 test_decl_needs_GOTPLT();
 test_warnings();
 test_out_out();
 return ec;
}


decompiled_code:
const char *__fastcall sanitize_opt_add(const char *a1, const char *a2)
{
const char *result; // rax

result = a2;
if ( !strcmp(a2, "undefined") )
{
cc1_sanitize = -1537;
}
else if ( !strcmp(a2, "shift") )
{
cc1_sanitize |= 1u;
}
else if ( !strcmp(a2, "shift-exponent") )
{
cc1_sanitize |= 1u;
}
else if ( !strcmp(a2, "vla-bound") )
{
cc1_sanitize |= 2u;
}
else if ( !strcmp(a2, "signed-integer-overflow") )
{
cc1_sanitize |= 4u;
}
else if ( !strcmp(a2, "bounds") )
{
cc1_sanitize |= 8u;
}
else if ( !strcmp(a2, "nonnull-attribute") )
{
cc1_sanitize |= 0x10u;
}
else if ( !strcmp(a2, "integer-divide-by-zero") )
{
cc1_sanitize |= 0x20u;
}
else if ( !strcmp(a2, "unreachable") )
{
cc1_sanitize |= 0x40u;
}
else if ( !strcmp(a2, "null") )
{
cc1_sanitize |= 0x80u;
}
else if ( !strcmp(a2, "alignment") )
{
cc1_sanitize |= 0x100u;
}
else if ( !strcmp(a2, "float-divide-by-zero") )
{
cc1_sanitize |= 0x200u;
}
else if ( !strcmp(a2, "float-cast-overflow") )
{
cc1_sanitize |= 0x400u;
}
else if ( !strcmp(a2, "returns-nonnull-attribute") )
{
cc1_sanitize |= 0x800u;
}
else if ( !strcmp(a2, "bool") )
{
cc1_sanitize |= 0x1000u;
}
else
{
if ( strcmp(a2, "pointer-overflow") )
{
fprintf(stderr, "%s: unknown sanitize option '%s'\n", a1, a2);
exit(1);
}
cc1_sanitize |= 0x2000u;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(const char *a1, const char *a2)
{
const char *result; // rax

result = a2;
if ( !strcmp(a2, "undefined") )
{
cc1_sanitize = -1537;
}
else if ( !strcmp(a2, "shift") )
{
cc1_sanitize |= 1u;
}
else if ( !strcmp(a2, "shift-exponent") )
{
cc1_sanitize |= 1u;
}
else if ( !strcmp(a2, "vla-bound") )
{
cc1_sanitize |= 2u;
}
else if ( !strcmp(a2, "signed-integer-overflow") )
{
cc1_sanitize |= 4u;
}
else if ( !strcmp(a2, "bounds") )
{
cc1_sanitize |= 8u;
}
else if ( !strcmp(a2, "nonnull-attribute") )
{
cc1_sanitize |= 0x10u;
}
else if ( !strcmp(a2, "integer-divide-by-zero") )
{
cc1_sanitize |= 0x20u;
}
else if ( !strcmp(a2, "unreachable") )
{
cc1_sanitize |= 0x40u;
}
else if ( !strcmp(a2, "null") )
{
cc1_sanitize |= 0x80u;
}
else if ( !strcmp(a2, "alignment") )
{
cc1_sanitize |= 0x100u;
}
else if ( !strcmp(a2, "float-divide-by-zero") )
{
cc1_sanitize |= 0x200u;
}
else if ( !strcmp(a2, "float-cast-overflow") )
{
cc1_sanitize |= 0x400u;
}
else if ( !strcmp(a2, "returns-nonnull-attribute") )
{
cc1_sanitize |= 0x800u;
}
else if ( !strcmp(a2, "bool") )
{
cc1_sanitize |= 0x1000u;
}
else
{
if ( strcmp(a2, "pointer-overflow") )
{
fprintf(stderr, "%s: unknown sanitize option '%s'\n", a1, a2);
exit(1);
}
cc1_sanitize |= 0x2000u;
}
return result;
}

original_code:
void sanitize_opt_add(const char *argv0, const char *san)
{
 if(!strcmp(san, "undefined")){
  cc1_sanitize |= ~0u;
  cc1_sanitize &= ~(SAN_FLOAT_DIVIDE_BY_ZERO | SAN_FLOAT_CAST_OVERFLOW);
  return;
 }else if(!strcmp(san, "shift")){
  cc1_sanitize |= SAN_SHIFT_EXPONENT;
  return;
 }
 if(!strcmp(san, "shift-exponent")){ cc1_sanitize |= SAN_SHIFT_EXPONENT; return; } if(!strcmp(san, "vla-bound")){ cc1_sanitize |= SAN_VLA_BOUND; return; } if(!strcmp(san, "signed-integer-overflow")){ cc1_sanitize |= SAN_SIGNED_INTEGER_OVERFLOW; return; } if(!strcmp(san, "bounds")){ cc1_sanitize |= SAN_BOUNDS; return; } if(!strcmp(san, "nonnull-attribute")){ cc1_sanitize |= SAN_NONNULL_ATTRIBUTE; return; } if(!strcmp(san, "integer-divide-by-zero")){ cc1_sanitize |= SAN_INTEGER_DIVIDE_BY_ZERO; return; } if(!strcmp(san, "unreachable")){ cc1_sanitize |= SAN_UNREACHABLE; return; } if(!strcmp(san, "null")){ cc1_sanitize |= SAN_NULL; return; } if(!strcmp(san, "alignment")){ cc1_sanitize |= SAN_ALIGNMENT; return; } if(!strcmp(san, "float-divide-by-zero")){ cc1_sanitize |= SAN_FLOAT_DIVIDE_BY_ZERO; return; } if(!strcmp(san, "float-cast-overflow")){ cc1_sanitize |= SAN_FLOAT_CAST_OVERFLOW; return; } if(!strcmp(san, "returns-nonnull-attribute")){ cc1_sanitize |= SAN_RETURNS_NONNULL_ATTRIBUTE; return; } if(!strcmp(san, "bool")){ cc1_sanitize |= SAN_BOOL; return; } if(!strcmp(san, "pointer-overflow")){ cc1_sanitize |= SAN_POINTER_OVERFLOW; return; }
 fprintf(stderr, "%s: unknown sanitize option '%s'\n", argv0, san);
 exit(1);
}

canonical_original_code:
void sanitize_opt_add(char *argv0, char *san)
{
 if(!strcmp(san, "undefined")){
  cc1_sanitize |= ~0u;
  cc1_sanitize &= ~(SAN_FLOAT_DIVIDE_BY_ZERO | SAN_FLOAT_CAST_OVERFLOW);
  return;
 }else if(!strcmp(san, "shift")){
  cc1_sanitize |= SAN_SHIFT_EXPONENT;
  return;
 }
 if(!strcmp(san, "shift-exponent")){ cc1_sanitize |= SAN_SHIFT_EXPONENT; return; } if(!strcmp(san, "vla-bound")){ cc1_sanitize |= SAN_VLA_BOUND; return; } if(!strcmp(san, "signed-integer-overflow")){ cc1_sanitize |= SAN_SIGNED_INTEGER_OVERFLOW; return; } if(!strcmp(san, "bounds")){ cc1_sanitize |= SAN_BOUNDS; return; } if(!strcmp(san, "nonnull-attribute")){ cc1_sanitize |= SAN_NONNULL_ATTRIBUTE; return; } if(!strcmp(san, "integer-divide-by-zero")){ cc1_sanitize |= SAN_INTEGER_DIVIDE_BY_ZERO; return; } if(!strcmp(san, "unreachable")){ cc1_sanitize |= SAN_UNREACHABLE; return; } if(!strcmp(san, "null")){ cc1_sanitize |= SAN_NULL; return; } if(!strcmp(san, "alignment")){ cc1_sanitize |= SAN_ALIGNMENT; return; } if(!strcmp(san, "float-divide-by-zero")){ cc1_sanitize |= SAN_FLOAT_DIVIDE_BY_ZERO; return; } if(!strcmp(san, "float-cast-overflow")){ cc1_sanitize |= SAN_FLOAT_CAST_OVERFLOW; return; } if(!strcmp(san, "returns-nonnull-attribute")){ cc1_sanitize |= SAN_RETURNS_NONNULL_ATTRIBUTE; return; } if(!strcmp(san, "bool")){ cc1_sanitize |= SAN_BOOL; return; } if(!strcmp(san, "pointer-overflow")){ cc1_sanitize |= SAN_POINTER_OVERFLOW; return; }
 fprintf(stderr, "%s: unknown sanitize option '%s'\n", argv0, san);
 exit(1);
}

variable_types:
san
char *


decompiled_code:
char __fastcall sanitize_opt_set_error(const char *a1, const char *a2)
{
const char *v3; // rbx
_BYTE *v4; // rax
bool v5; // cf
bool v6; // zf
const char *v7; // rdi
__int64 v8; // rcx

v3 = a2;
free(cc1_sanitize_handler_fn);
cc1_sanitize_handler_fn = 0LL;
LOBYTE(v4) = strcmp(a2, "trap") != 0;
v5 = 0;
v6 = (_BYTE)v4 == 0;
if ( (_BYTE)v4 )
{
v7 = "call=";
v8 = 5LL;
do
{
if ( !v8 )
break;
v5 = *a2 < (unsigned int)*v7;
v6 = *a2++ == *v7++;
--v8;
}
while ( v6 );
if ( (!v5 && !v6) != v5 )
{
fprintf(stderr, "%s: unknown sanitize handler '%s'\n", a1, v3);
exit(1);
}
v4 = (_BYTE *)ustrdup(v3 + 5, a2);
cc1_sanitize_handler_fn = v4;
if ( !*v4 )
{
fprintf(stderr, "%s: empty sanitize function handler\n", a1);
exit(1);
}
}
return (char)v4;
}

canonical_decompiled_code:
char __fastcall func1(const char *a1, const char *a2)
{
const char *v3; // rbx
_BYTE *v4; // rax
bool v5; // cf
bool v6; // zf
const char *v7; // rdi
__int64 v8; // rcx

v3 = a2;
free(cc1_sanitize_handler_fn);
cc1_sanitize_handler_fn = 0LL;
LOBYTE(v4) = strcmp(a2, "trap") != 0;
v5 = 0;
v6 = (_BYTE)v4 == 0;
if ( (_BYTE)v4 )
{
v7 = "call=";
v8 = 5LL;
do
{
if ( !v8 )
break;
v5 = *a2 < (unsigned int)*v7;
v6 = *a2++ == *v7++;
--v8;
}
while ( v6 );
if ( (!v5 && !v6) != v5 )
{
fprintf(stderr, "%s: unknown sanitize handler '%s'\n", a1, v3);
exit(1);
}
v4 = (_BYTE *)ustrdup(v3 + 5, a2);
cc1_sanitize_handler_fn = v4;
if ( !*v4 )
{
fprintf(stderr, "%s: empty sanitize function handler\n", a1);
exit(1);
}
}
return (char)v4;
}

original_code:
void sanitize_opt_set_error(const char *argv0, const char *handler)
{
 free(cc1_sanitize_handler_fn);
 cc1_sanitize_handler_fn = ((void *)0);
 if(!strcmp(handler, "trap")){
 }else if(!strncmp(handler, "call=", 5)){
  cc1_sanitize_handler_fn = ustrdup(handler + 5);
  if(!*cc1_sanitize_handler_fn){
   fprintf(stderr, "%s: empty sanitize function handler\n", argv0);
   exit(1);
  }
 }else{
  fprintf(stderr, "%s: unknown sanitize handler '%s'\n", argv0, handler);
  exit(1);
 }
}

canonical_original_code:
void sanitize_opt_set_error(char *argv0, char *handler)
{
 free(cc1_sanitize_handler_fn);
 cc1_sanitize_handler_fn = ((void *)0);
 if(!strcmp(handler, "trap")){
 }else if(!strncmp(handler, "call=", 5)){
  cc1_sanitize_handler_fn = ustrdup(handler + 5);
  if(!*cc1_sanitize_handler_fn){
   fprintf(stderr, "%s: empty sanitize function handler\n", argv0);
   exit(1);
  }
 }else{
  fprintf(stderr, "%s: unknown sanitize handler '%s'\n", argv0, handler);
  exit(1);
 }
}

variable_types:
handler
char *


decompiled_code:
void sanitize_opt_off()
{
cc1_sanitize = 0;
cc1_fopt[48] = 0;
}

canonical_decompiled_code:
void func2()
{
cc1_sanitize = 0;
cc1_fopt[48] = 0;
}

original_code:
void sanitize_opt_off(void)
{
 cc1_sanitize = 0;
 cc1_fopt.trapv = 0;
}

canonical_original_code:
void sanitize_opt_off()
{
 cc1_sanitize = 0;
 cc1_fopt.trapv = 0;
}


decompiled_code:
__int64 __fastcall sanitize_enabled(unsigned int a1, char a2)
{
__int64 result; // rax

if ( a1 == 128 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
return cc1_sanitize & a1;
}
if ( a1 > 0x80 )
{
if ( a1 == 2048 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
else if ( a1 <= 0x800 )
{
switch ( a1 )
{
case 0x200u:
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
break;
case 0x400u:
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
break;
case 0x100u:
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
break;
}
}
else if ( a1 == 4096 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
else if ( a1 == 0x2000 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
return cc1_sanitize & a1;
}
if ( a1 > 0x20 )
{
if ( a1 == 64 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
return cc1_sanitize & a1;
}
if ( !a1 )
return cc1_sanitize & a1;
switch ( a1 )
{
case 1u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 2u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 4u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 8u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 0x10u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 0x20u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
default:
return cc1_sanitize & a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, char a2)
{
__int64 result; // rax

if ( a1 == 128 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
return cc1_sanitize & a1;
}
if ( a1 > 0x80 )
{
if ( a1 == 2048 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
else if ( a1 <= 0x800 )
{
switch ( a1 )
{
case 0x200u:
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
break;
case 0x400u:
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
break;
case 0x100u:
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
break;
}
}
else if ( a1 == 4096 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
else if ( a1 == 0x2000 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
return cc1_sanitize & a1;
}
if ( a1 > 0x20 )
{
if ( a1 == 64 )
{
result = 0LL;
if ( (a2 & 1) != 0 )
return result;
}
return cc1_sanitize & a1;
}
if ( !a1 )
return cc1_sanitize & a1;
switch ( a1 )
{
case 1u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 2u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 4u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 8u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 0x10u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
case 0x20u:
result = 0LL;
if ( (a2 & 1) == 0 )
return cc1_sanitize & a1;
break;
default:
return cc1_sanitize & a1;
}
return result;
}

original_code:
int sanitize_enabled(enum san_opts opt, enum no_sanitize disabled)
{
 switch(opt){
 case SAN_SHIFT_EXPONENT: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_VLA_BOUND: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_SIGNED_INTEGER_OVERFLOW: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_BOUNDS: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_NONNULL_ATTRIBUTE: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_INTEGER_DIVIDE_BY_ZERO: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_UNREACHABLE: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_NULL: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_ALIGNMENT: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_FLOAT_DIVIDE_BY_ZERO: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_FLOAT_CAST_OVERFLOW: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_RETURNS_NONNULL_ATTRIBUTE: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_BOOL: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break; case SAN_POINTER_OVERFLOW: if(disabled & (NO_SANITIZE_UNDEFINED)) return 0; break;
 }
 return cc1_sanitize & opt;
}

variable_types: enum san_opts { SAN_SHIFT_EXPONENT=expr, SAN_VLA_BOUND=expr, SAN_SIGNED_INTEGER_OVERFLOW=expr, SAN_BOUNDS=expr, SAN_NONNULL_ATTRIBUTE=expr, SAN_INTEGER_DIVIDE_BY_ZERO=expr, SAN_UNREACHABLE=expr, SAN_NULL=expr, SAN_ALIGNMENT=expr, SAN_FLOAT_DIVIDE_BY_ZERO=expr, SAN_FLOAT_CAST_OVERFLOW=expr, SAN_RETURNS_NONNULL_ATTRIBUTE=expr, SAN_BOOL=expr, SAN_POINTER_OVERFLOW=expr }

variable_types: enum no_sanitize { NO_SANITIZE_UNDEFINED=expr }


decompiled_code:
void *str_stmt_do()
{
return &unk_1D6;
}

canonical_decompiled_code:
void *func1()
{
return &unk_1D6;
}

original_code:
const char *str_stmt_do(void)
{
 return "do";
}

canonical_original_code:
char *str_stmt_do()
{
 return "do";
}


decompiled_code:
void __fastcall align_sz(unsigned int *a1, unsigned int a2)
{
unsigned int v3; // edi

v3 = *a1;
if ( v3 < a2 )
*a1 = pack_to_align(v3);
}

canonical_decompiled_code:
void __fastcall func0(unsigned int *a1, unsigned int a2)
{
unsigned int v3; // edi

v3 = *a1;
if ( v3 < a2 )
*a1 = pack_to_align(v3);
}

original_code:
static void align_sz(unsigned *psz, unsigned align)
{
 if(align > *psz)
  *psz = pack_to_align(*psz, align);
}

canonical_original_code:
static void align_sz(unsigned int *psz, unsigned int align)
{
 if(align > *psz)
  *psz = pack_to_align(*psz, align);
}

variable_types:
psz
unsigned int *


decompiled_code:
__int64 test_rtrim()
{
__int64 result; // rax
__int64 v1[5]; // [rsp+0h] [rbp-28h] BYREF

v1[1] = 32LL;
v1[2] = 0LL;
v1[3] = 0LL;
v1[0] = 0x2020333231636261LL;
rtrim(v1);
if ( strcmp((const char *)v1, "abc123") )
_assert_fail("!strcmp(buf, \"abc123\")", "test.c", 0x18u, "test_rtrim");
LODWORD(v1[0]) = 2105376;
rtrim(v1);
if ( LOBYTE(v1[0]) )
_assert_fail("!strcmp(buf, \"\")", "test.c", 0x1Cu, "test_rtrim");
LOBYTE(v1[0]) = 0;
result = rtrim(v1);
if ( LOBYTE(v1[0]) )
_assert_fail("!strcmp(buf, \"\")", "test.c", 0x20u, "test_rtrim");
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
__int64 v1[5]; // [rsp+0h] [rbp-28h] BYREF

v1[1] = 32LL;
v1[2] = 0LL;
v1[3] = 0LL;
v1[0] = 0x2020333231636261LL;
rtrim(v1);
if ( strcmp((const char *)v1, "abc123") )
_assert_fail("!strcmp(buf, \"abc123\")", "test.c", 0x18u, "test_rtrim");
LODWORD(v1[0]) = 2105376;
rtrim(v1);
if ( LOBYTE(v1[0]) )
_assert_fail("!strcmp(buf, \"\")", "test.c", 0x1Cu, "test_rtrim");
LOBYTE(v1[0]) = 0;
result = rtrim(v1);
if ( LOBYTE(v1[0]) )
_assert_fail("!strcmp(buf, \"\")", "test.c", 0x20u, "test_rtrim");
return result;
}

original_code:
static void test_rtrim(void)
{
 char buf[32] = { 0 };
 strcpy(buf, "abc123   ");
 rtrim(buf);
 ((!strcmp(buf, "abc123")) ? (void) (0) : __assert_fail ("!strcmp(buf, \"abc123\")", "test.c", 24, __extension__ __PRETTY_FUNCTION__));
 strcpy(buf, "   ");
 rtrim(buf);
 ((!strcmp(buf, "")) ? (void) (0) : __assert_fail ("!strcmp(buf, \"\")", "test.c", 28, __extension__ __PRETTY_FUNCTION__));
 strcpy(buf, "");
 rtrim(buf);
 ((!strcmp(buf, "")) ? (void) (0) : __assert_fail ("!strcmp(buf, \"\")", "test.c", 32, __extension__ __PRETTY_FUNCTION__));
}

canonical_original_code:
static void test_rtrim()
{
 char buf[32] = { 0 };
 strcpy(buf, "abc123   ");
 rtrim(buf);
 ((!strcmp(buf, "abc123")) ? (void) (0) : __assert_fail ("!strcmp(buf, \"abc123\")", "test.c", 24, __extension__ __PRETTY_FUNCTION__));
 strcpy(buf, "   ");
 rtrim(buf);
 ((!strcmp(buf, "")) ? (void) (0) : __assert_fail ("!strcmp(buf, \"\")", "test.c", 28, __extension__ __PRETTY_FUNCTION__));
 strcpy(buf, "");
 rtrim(buf);
 ((!strcmp(buf, "")) ? (void) (0) : __assert_fail ("!strcmp(buf, \"\")", "test.c", 32, __extension__ __PRETTY_FUNCTION__));
}

variable_types:
buf
char [32]


ice

decompiled_code:
void __noreturn ice()
{
abort();
}

canonical_decompiled_code:
void __noreturn func1()
{
abort();
}

original_code:
void ice(const char *f, int line, const char *fn, const char *fmt, ...)
{
 (void)f;
 (void)line;
 (void)fn;
 (void)fmt;
 abort();
}

canonical_original_code:
void ice(char *f, int line, char *fn, char *fmt, ...)
{
 (void)f;
 (void)line;
 (void)fn;
 (void)fmt;
 abort();
}

variable_types:
fmt
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
test_rtrim(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func0(argc, argv, envp);
return 0;
}

original_code:
int main(void)
{
 test_rtrim();
 return 0;
}

canonical_original_code:
int main()
{
 test_rtrim();
 return 0;
}


decompiled_code:
void __fastcall expr_free_abi(void *a1)
{
expr_free(a1);
}

canonical_decompiled_code:
void __fastcall func3(void *a1)
{
func2(a1);
}

original_code:
void expr_free_abi(void *e)
{
 expr_free(e);
}

variable_types:
e
void *


decompiled_code:
const char *str_expr_stmt()
{
return "statement";
}

canonical_decompiled_code:
const char *func0()
{
return "statement";
}

original_code:
const char *str_expr_stmt(void)
{
 return "statement";
}


decompiled_code:
__int64 __fastcall leb128_length(__int64 a1, int a2)
{
__int64 v2; // rax
bool v3; // dl
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // rdx
bool v7; // cl
unsigned __int64 v8; // rdi

if ( a2 )
{
v2 = a1 & 0x40;
v3 = (a1 & 0x40) != 0;
v4 = a1 >> 7;
if ( v4 | v2 )
{
if ( v4 == -1 && v3 )
{
result = 1LL;
}
else
{
LODWORD(result) = 1;
do
{
result = (unsigned int)(result + 1);
v6 = v4 & 0x40;
v7 = (v4 & 0x40) != 0;
v4 >>= 7;
}
while ( v4 | v6 && (v4 != -1 || !v7) );
}
}
else
{
result = 1LL;
}
}
else
{
v8 = (unsigned __int64)a1 >> 7;
if ( v8 )
{
LODWORD(result) = 1;
do
{
result = (unsigned int)(result + 1);
v8 >>= 7;
}
while ( v8 );
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
__int64 v2; // rax
bool v3; // dl
__int64 v4; // rdi
__int64 result; // rax
__int64 v6; // rdx
bool v7; // cl
unsigned __int64 v8; // rdi

if ( a2 )
{
v2 = a1 & 0x40;
v3 = (a1 & 0x40) != 0;
v4 = a1 >> 7;
if ( v4 | v2 )
{
if ( v4 == -1 && v3 )
{
result = 1LL;
}
else
{
LODWORD(result) = 1;
do
{
result = (unsigned int)(result + 1);
v6 = v4 & 0x40;
v7 = (v4 & 0x40) != 0;
v4 >>= 7;
}
while ( v4 | v6 && (v4 != -1 || !v7) );
}
}
else
{
result = 1LL;
}
}
else
{
v8 = (unsigned __int64)a1 >> 7;
if ( v8 )
{
LODWORD(result) = 1;
do
{
result = (unsigned int)(result + 1);
v8 >>= 7;
}
while ( v8 );
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
unsigned leb128_length(unsigned long long value, int is_signed)
{
 unsigned len = 1;
 if(is_signed){
  signed long long sv = value;
  for(;;){
   int sign_bit_set = !!(sv & 0x40);
   sv >>= 7;
   if((sv == 0 && !sign_bit_set)
   || (sv == -1 && sign_bit_set))
   {
    break;
   }
   len++;
  }
 }else{
  for(;;){
   value >>= 7;
   if(!value)
    break;
   len++;
  }
 }
 return len;
}

canonical_original_code:
unsigned int leb128_length(unsigned long long value, int is_signed)
{
 unsigned int len = 1;
 if(is_signed){
  long long sv = value;
  for(;;){
   int sign_bit_set = !!(sv & 0x40);
   sv >>= 7;
   if((sv == 0 && !sign_bit_set)
   || (sv == -1 && sign_bit_set))
   {
    break;
   }
   len++;
  }
 }else{
  for(;;){
   value >>= 7;
   if(!value)
    break;
   len++;
  }
 }
 return len;
}

variable_types:
value
unsigned long long

variable_types:
len
unsigned int

variable_types:
sv
long long

return_type: unsigned int


decompiled_code:
const char *str_stmt_while()
{
return "while";
}

canonical_decompiled_code:
const char *func1()
{
return "while";
}

original_code:
const char *str_stmt_while(void)
{
 return "while";
}


decompiled_code:
const char *str_stmt_label()
{
return "label";
}

canonical_decompiled_code:
const char *func1()
{
return "label";
}

original_code:
const char *str_stmt_label(void)
{
 return "label";
}


decompiled_code:
const char *str_stmt_return()
{
return "return";
}

canonical_decompiled_code:
const char *func0()
{
return "return";
}

original_code:
const char *str_stmt_return(void)
{
 return "return";
}


decompiled_code:
const char *str_expr_assign()
{
return "assignment";
}

canonical_decompiled_code:
const char *func0()
{
return "assignment";
}

original_code:
const char *str_expr_assign(void)
{
 return "assignment";
}


picfilter

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

result = a1;
if ( !cc1_fopt[19] )
result = 0LL;
return result;
}

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

result = a1;
if ( !cc1_fopt[19] )
result = 0LL;
return result;
}

original_code:
static enum out_pic_type picfilter(enum out_pic_type flags)
{
 return ((&cc1_fopt)->pic || (&cc1_fopt)->pie) ? flags : OUT_LBL_NOPIC;
}

variable_types: enum out_pic_type { OUT_LBL_NOPIC=0, OUT_LBL_PIC=expr, OUT_LBL_PICLOCAL=expr }


decompiled_code:
const char *__fastcall sym_to_str(int a1)
{
const char *result; // rax

result = "local";
if ( a1 != 1 )
{
result = "arg";
if ( a1 != 2 )
{
result = "global";
if ( a1 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func17(int a1)
{
const char *result; // rax

result = "local";
if ( a1 != 1 )
{
result = "arg";
if ( a1 != 2 )
{
result = "global";
if ( a1 )
result = 0LL;
}
}
return result;
}

original_code:
const char *sym_to_str(enum sym_type t)
{
 switch(t){
  case sym_local: return "local";
  case sym_arg: return "arg";
  case sym_global: return "global";
 }
 return ((void *)0);
}

variable_types: enum sym_type { sym_global=0, sym_local=1, sym_arg=2 }


repo: bobrippling/uvi

decompiled_code:
char *__fastcall file_generic(const char *a1)
{
char *v1; // rcx

v1 = getenv("HOME");
if ( !v1 )
v1 = (char *)&unk_180;
snprintf(fname_0, 0x100uLL, "%s/.uvi%s", v1, a1);
return fname_0;
}

canonical_decompiled_code:
char *__fastcall func0(const char *a1)
{
char *v1; // rcx

v1 = getenv("HOME");
if ( !v1 )
v1 = (char *)&unk_180;
snprintf(fname_0, 0x100uLL, "%s/.uvi%s", v1, a1);
return fname_0;
}

original_code:
static const char *file_generic(const char *suffix)
{
 static char fname[256];
 const char *home = getenv("HOME");
 if(!home)
  home = "";
 snprintf(fname, sizeof fname, "%s/.uvi%s", home, suffix);
 return fname;
}

canonical_original_code:
static char *file_generic(char *suffix)
{
 static char fname[256];
 char *home = getenv("HOME");
 if(!home)
  home = "";
 snprintf(fname, sizeof fname, "%s/.uvi%s", home, suffix);
 return fname;
}

variable_types:
suffix
char *

variable_types:
fname
char [256]

variable_types:
home
char *


decompiled_code:
char *file_rc()
{
return file_generic("rc");
}

canonical_decompiled_code:
char *func1()
{
return func0("rc");
}

original_code:
const char *file_rc(void)
{
 return file_generic("rc");
}


decompiled_code:
char *file_info()
{
return file_generic("info");
}

canonical_decompiled_code:
char *func2()
{
return func0("info");
}

original_code:
const char *file_info(void)
{
 return file_generic("info");
}


decompiled_code:
FILE *input_reopen()
{
FILE *result; // rax
int *v1; // rax
char *v2; // rax

fclose(stdin);
result = fopen("/dev/tty", "r");
stdin = result;
if ( !result )
{
gui_term();
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, "uvi: freopen(\"/dev/tty\", \"r\", stdin) = %s\n", v2);
exit(1);
}
return result;
}

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

fclose(stdin);
result = fopen("/dev/tty", "r");
stdin = result;
if ( !result )
{
gui_term();
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, "uvi: freopen(\"/dev/tty\", \"r\", stdin) = %s\n", v2);
exit(1);
}
return result;
}

original_code:
void input_reopen()
{
 fclose(stdin);
 stdin = fopen("/dev/tty", "r");
 if(!stdin){
  gui_term();
  fprintf(stderr, "uvi: freopen(\"/dev/tty\", \"r\", stdin) = %s\n", strerror((*__errno_location ())));
  exit(1);
 }
}


decompiled_code:
int chomp_line()
{
int v0; // ebx
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

tcgetattr(0, &v2);
v2.c_cc[6] = 1;
v2.c_lflag &= 0xFFFFFFF5;
tcsetattr(0, 0, &v2);
v0 = getchar();
v2.c_cc[6] = 0;
v2.c_lflag |= 0xAu;
tcsetattr(0, 0, &v2);
return ungetch(v0);
}

canonical_decompiled_code:
int func1()
{
int v0; // ebx
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

tcgetattr(0, &v2);
v2.c_cc[6] = 1;
v2.c_lflag &= 0xFFFFFFF5;
tcsetattr(0, 0, &v2);
v0 = getchar();
v2.c_cc[6] = 0;
v2.c_lflag |= 0xAu;
tcsetattr(0, 0, &v2);
return ungetch(v0);
}

original_code:
void chomp_line()
{
 int c;
 struct termios attr;
 tcgetattr(0, &attr);
 attr.c_cc[6] = sizeof(char);
 attr.c_lflag &= ~(0000002 | 0000010);
 tcsetattr(0, 0, &attr);
 c = getchar();
 attr.c_cc[6] = 0;
 attr.c_lflag |= 0000002 | 0000010;
 tcsetattr(0, 0, &attr);
 ungetch(c);
}

variable_types: c int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
__int64 buffer_new_empty()
{
_BYTE *v0; // rax

v0 = (_BYTE *)umalloc(1LL);
*v0 = 0;
return buffer_new(v0);
}

canonical_decompiled_code:
__int64 func2()
{
_BYTE *v0; // rax

v0 = (_BYTE *)umalloc(1LL);
*v0 = 0;
return func1(v0);
}

canonical_original_code:
struct buffer_t *buffer_new_empty()
{
 char *s = umalloc(sizeof(char));
 *s = '\0';
 return buffer_new(s);
}

variable_types:
s
char *

return_type: struct buffer_t { struct list { void *data; struct list *next; } *lines; char *fname; int readonly; int modified; int eol; int crlf; int dirty; int nlines; int touched_fs; long opentime; } *

user_defined_types: struct buffer_t { struct list *lines; char *fname; int readonly; int modified; int eol; int crlf; int dirty; int nlines; int touched_fs; long opentime; }


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

free(*(void **)(a1 + 8));
if ( a2 )
{
v2 = strlen(a2);
v3 = (char *)umalloc(v2 + 1);
*(_QWORD *)(a1 + 8) = v3;
strcpy(v3, a2);
}
else
{
*(_QWORD *)(a1 + 8) = 0LL;
}
}

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

free(*(void **)(a1 + 8));
if ( a2 )
{
v2 = strlen(a2);
v3 = (char *)umalloc(v2 + 1);
*(_QWORD *)(a1 + 8) = v3;
strcpy(v3, a2);
}
else
{
*(_QWORD *)(a1 + 8) = 0LL;
}
}

original_code:
void buffer_setfilename(buffer_t *b, const char *s)
{
 free(b->fname);
 if(s){
  b->fname = umalloc(strlen(s) + 1);
  strcpy(b->fname, s);
 }else
  b->fname = ((void *)0);
}

canonical_original_code:
void buffer_setfilename(struct buffer_t *b, char *s)
{
 free(b->fname);
 if(s){
  b->fname = umalloc(strlen(s) + 1);
  strcpy(b->fname, s);
 }else
  b->fname = ((void *)0);
}

variable_types: struct buffer_t { struct list { void *data; struct list *next; } *lines; char *fname; int readonly; int modified; int eol; int crlf; int dirty; int nlines; int touched_fs; long opentime; } *


decompiled_code:
_BOOL8 __fastcall is_crlf(__int64 *a1)
{
__int64 v1; // rbp
_BOOL8 result; // rax
const char *v3; // rbx

v1 = *a1;
result = 1LL;
if ( *a1 )
{
while ( 1 )
{
v3 = *(const char **)v1;
if ( !*(_QWORD *)v1 )
return 1LL;
if ( !*v3 )
return 0LL;
if ( v3[strlen(*(const char **)v1) - 1] != 13 )
break;
v1 = *(_QWORD *)(v1 + 8);
if ( !v1 )
return 1LL;
}
result = 0LL;
if ( !*(_QWORD *)(v1 + 8) )
result = *(_QWORD *)(v1 + 16) != 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 *a1)
{
__int64 v1; // rbp
_BOOL8 result; // rax
const char *v3; // rbx

v1 = *a1;
result = 1LL;
if ( *a1 )
{
while ( 1 )
{
v3 = *(const char **)v1;
if ( !*(_QWORD *)v1 )
return 1LL;
if ( !*v3 )
return 0LL;
if ( v3[strlen(*(const char **)v1) - 1] != 13 )
break;
v1 = *(_QWORD *)(v1 + 8);
if ( !v1 )
return 1LL;
}
result = 0LL;
if ( !*(_QWORD *)(v1 + 8) )
result = *(_QWORD *)(v1 + 16) != 0LL;
}
return result;
}

original_code:
int is_crlf(buffer_t *b)
{
 struct list *l;
 for(l = b->lines; l && l->data; l = l->next){
  char *s = l->data;
  if(!*s)
   return 0;
  if(s[strlen(s)-1] != '\r'){
   if(l->next)
    return 0;
   else
    return !!l->prev;
  }
 }
 return 1;
}

canonical_original_code:
int is_crlf(struct buffer_t *b)
{
 struct list *l;
 for(l = b->lines; l && l->data; l = l->next){
  char *s = l->data;
  if(!*s)
   return 0;
  if(s[strlen(s)-1] != '\r'){
   if(l->next)
    return 0;
   else
    return !!l->prev;
  }
 }
 return 1;
}

variable_types: struct list { void *data; struct list *next; } *


decompiled_code:
__int64 __fastcall buffer_write(_QWORD *a1)
{
__int64 v1; // rax

v1 = list_gethead(*a1);
return buffer_write_list((__int64)a1, v1);
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1)
{
__int64 v1; // rax

v1 = list_gethead(*a1);
return func5((__int64)a1, v1);
}

original_code:
int buffer_write(buffer_t *b)
{
 return buffer_write_list(b, list_gethead(b->lines));
}

canonical_original_code:
int buffer_write(struct buffer_t *b)
{
 return buffer_write_list(b, list_gethead(b->lines));
}

user_defined_types: struct list { void *data; struct list *next; }


decompiled_code:
void __fastcall buffer_free_nolist(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void buffer_free_nolist(buffer_t *b)
{
 if(b){
  free(b->fname);
  free(b);
 }
}

canonical_original_code:
void buffer_free_nolist(struct buffer_t *b)
{
 if(b){
  free(b->fname);
  free(b);
 }
}


decompiled_code:
void __fastcall buffer_free(void *ptr)
{
if ( ptr )
{
list_free(*(_QWORD *)ptr, &free);
buffer_free_nolist(ptr);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
if ( ptr )
{
list_free(*(_QWORD *)ptr, &free);
func7(ptr);
}
}

original_code:
void buffer_free(buffer_t *b)
{
 if(b){
  list_free(b->lines, free);
  buffer_free_nolist(b);
 }
}

canonical_original_code:
void buffer_free(struct buffer_t *b)
{
 if(b){
  list_free(b->lines, free);
  buffer_free_nolist(b);
 }
}


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

result = list_free(*(_QWORD *)a1, &free);
*(_QWORD *)a1 = a2;
*(_DWORD *)(a1 + 32) = 1;
return result;
}

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

result = list_free(*(_QWORD *)a1, &free);
*(_QWORD *)a1 = a2;
*(_DWORD *)(a1 + 32) = 1;
return result;
}

original_code:
void buffer_replace(buffer_t *b, struct list *l)
{
 list_free(b->lines, free);
 b->lines = l;
 b->dirty = 1;
}

canonical_original_code:
void buffer_replace(struct buffer_t *b, struct list *l)
{
 list_free(b->lines, free);
 b->lines = l;
 b->dirty = 1;
}

variable_types:
l
struct list *


decompiled_code:
__int64 __fastcall buffer_nchars(_QWORD *a1)
{
const char **v1; // rax
const char **v2; // rbx
unsigned int v3; // ebp

v1 = (const char **)list_gethead(*a1);
if ( !*v1 )
return 1;
v2 = v1;
v3 = 0;
do
{
v3 += strlen(*v2);
v2 = (const char **)v2[1];
}
while ( v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1)
{
const char **v1; // rax
const char **v2; // rbx
unsigned int v3; // ebp

v1 = (const char **)list_gethead(*a1);
if ( !*v1 )
return 1;
v2 = v1;
v3 = 0;
do
{
v3 += strlen(*v2);
v2 = (const char **)v2[1];
}
while ( v2 );
return v3;
}

original_code:
int buffer_nchars(buffer_t *b)
{
 struct list *l = list_gethead(b->lines);
 int chars = 0;
 if(!l->data)
  return 1;
 while(l){
  chars += strlen(l->data);
  l = l->next;
 }
 return chars;
}

canonical_original_code:
int buffer_nchars(struct buffer_t *b)
{
 struct list *l = list_gethead(b->lines);
 int chars = 0;
 if(!l->data)
  return 1;
 while(l){
  chars += strlen(l->data);
  l = l->next;
 }
 return chars;
}

variable_types: chars int


decompiled_code:
__int64 __fastcall buffer_nlines(__int64 a1)
{
if ( *(_DWORD *)(a1 + 32) )
{
*(_DWORD *)(a1 + 36) = list_count(*(_QWORD *)a1);
*(_DWORD *)(a1 + 32) = 0;
}
return *(unsigned int *)(a1 + 36);
}

original_code:
int buffer_nlines(buffer_t *b)
{
 if(b->dirty){
  b->nlines = list_count(b->lines);
  b->dirty = 0;
 }
 return b->nlines;
}

canonical_original_code:
int buffer_nlines(struct buffer_t *b)
{
 if(b->dirty){
  b->nlines = list_count(b->lines);
  b->dirty = 0;
 }
 return b->nlines;
}


original_code:
struct list *buffer_extract_range(buffer_t *buffer, struct range *rng)
{
 struct list *l, *newpos, *extracted;
 l = list_getindex(buffer->lines, rng->start);
 extracted = list_extract_range(&l, rng->end - rng->start + 1);
 newpos = l;
 if(!(l = list_getindex(newpos, rng->start)))
  l = list_gettail(newpos);
 buffer->lines = l = list_gethead(l);
 if(!l->data){
  l->data = umalloc(sizeof(char));
  *(char *)l->data = '\0';
 }
 buffer->dirty = 1;
 return extracted;
}

canonical_original_code:
struct list *buffer_extract_range(struct buffer_t *buffer, struct range *rng)
{
 struct list *l; struct list *newpos; struct list *extracted;
 l = list_getindex(buffer->lines, rng->start);
 extracted = list_extract_range(&l, rng->end - rng->start + 1);
 newpos = l;
 if(!(l = list_getindex(newpos, rng->start)))
  l = list_gettail(newpos);
 buffer->lines = l = list_gethead(l);
 if(!l->data){
  l->data = umalloc(sizeof(char));
  *(char *)l->data = '\0';
 }
 buffer->dirty = 1;
 return extracted;
}

variable_types: struct buffer_t { struct list *lines; char *fname; int readonly; int modified; int eol; int crlf; int dirty; int nlines; int touched_fs; long opentime; } *

variable_types:
rng
struct range { int start; } *

return_type: struct list { void *data; struct list *next; } *


decompiled_code:
__int64 __fastcall buffer_remove_range(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax

v2 = buffer_extract_range(a1, a2);
return list_free(v2, &free);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax

v2 = func13(a1, a2);
return list_free(v2, &free);
}

original_code:
void buffer_remove_range(buffer_t *buffer, struct range *rng)
{
 list_free(buffer_extract_range(buffer, rng), free);
}

canonical_original_code:
void buffer_remove_range(struct buffer_t *buffer, struct range *rng)
{
 list_free(buffer_extract_range(buffer, rng), free);
}


decompiled_code:
_BOOL8 __fastcall buffer_file_exists(__int64 a1)
{
const char *v1; // rdi
_BOOL8 result; // rax

v1 = *(const char **)(a1 + 8);
result = 0LL;
if ( v1 )
result = access(v1, 0) == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(__int64 a1)
{
const char *v1; // rdi
_BOOL8 result; // rax

v1 = *(const char **)(a1 + 8);
result = 0LL;
if ( v1 )
result = access(v1, 0) == 0;
return result;
}

original_code:
int buffer_file_exists(buffer_t *b)
{
 return (!!(b)->fname) && access(((b)->fname ? (b)->fname : "(no name)"), 0) == 0;
}

canonical_original_code:
int buffer_file_exists(struct buffer_t *b)
{
 return (!!(b)->fname) && access(((b)->fname ? (b)->fname : "(no name)"), 0) == 0;
}


decompiled_code:
_BOOL8 __fastcall buffer_external_modified(__int64 a1)
{
const char *v2; // rdi
_BOOL8 result; // rax
int v4; // edx
struct stat v5; // [rsp+0h] [rbp-98h] BYREF

v2 = *(const char **)(a1 + 8);
result = 0LL;
if ( v2 )
{
v4 = stat(v2, &v5);
result = 0LL;
if ( !v4 )
result = v5.st_ctim.tv_sec > *(_QWORD *)(a1 + 48);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func17(__int64 a1)
{
const char *v2; // rdi
_BOOL8 result; // rax
int v4; // edx
struct stat v5; // [rsp+0h] [rbp-98h] BYREF

v2 = *(const char **)(a1 + 8);
result = 0LL;
if ( v2 )
{
v4 = stat(v2, &v5);
result = 0LL;
if ( !v4 )
result = v5.st_ctim.tv_sec > *(_QWORD *)(a1 + 48);
}
return result;
}

original_code:
int buffer_external_modified(buffer_t *b)
{
 struct stat st;
 if(!(!!(b)->fname))
  return 0;
 if(stat(((b)->fname ? (b)->fname : "(no name)"), &st))
  return 0;
 return st.st_ctim.tv_sec > ((b)->opentime);
}

canonical_original_code:
int buffer_external_modified(struct buffer_t *b)
{
 struct stat st;
 if(!(!!(b)->fname))
  return 0;
 if(stat(((b)->fname ? (b)->fname : "(no name)"), &st))
  return 0;
 return st.st_ctim.tv_sec > ((b)->opentime);
}

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

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


decompiled_code:
void __fastcall macro_set(char a1, __int64 a2)
{
int v2; // ebx
void *v3; // rdi

v2 = a1 - 97;
v3 = (void *)macros[v2];
if ( v3 )
free(v3);
macros[v2] = a2;
}

canonical_decompiled_code:
void __fastcall func0(char a1, __int64 a2)
{
int v2; // ebx
void *v3; // rdi

v2 = a1 - 97;
v3 = (void *)macros[v2];
if ( v3 )
free(v3);
macros[v2] = a2;
}

original_code:
void macro_set(char c, char *s)
{
 int i = c - 'a';
 if(macros[i])
  free(macros[i]);
 macros[i] = s;
}

variable_types: c char

variable_types: i int


decompiled_code:
void __fastcall macro_play(char a1)
{
__int64 v1; // rdi
__int64 v2; // rbx

v1 = a1 - 97;
v2 = macros[v1];
if ( v2 )
{
if ( *(_BYTE *)(v2 + (int)(strlen((const char *)macros[v1]) - 1)) != 27 )
gui_ungetch(27LL);
gui_queue(v2);
}
}

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

v1 = a1 - 97;
v2 = macros[v1];
if ( v2 )
{
if ( *(_BYTE *)(v2 + (int)(strlen((const char *)macros[v1]) - 1)) != 27 )
gui_ungetch(27LL);
gui_queue(v2);
}
}

original_code:
void macro_play(char c)
{
 const char *iter = macros[c - 'a'];
 if(iter){
  int last = strlen(iter) - 1;
  if(iter[last] != '\x1b')
   gui_ungetch('\x1b');
  gui_queue(iter);
 }
}

canonical_original_code:
void macro_play(char c)
{
 char *iter = macros[c - 'a'];
 if(iter){
  int last = strlen(iter) - 1;
  if(iter[last] != '\x1b')
   gui_ungetch('\x1b');
  gui_queue(iter);
 }
}

variable_types:
iter
char *

variable_types: last int


decompiled_code:
_BOOL8 __fastcall macro_char_valid(int a1)
{
return (unsigned int)(a1 - 97) <= 0x19;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(int a1)
{
return (unsigned int)(a1 - 97) <= 0x19;
}

original_code:
int macro_char_valid(int c)
{
 return 'a' <= c && c <= 'z';
}


decompiled_code:
void __fastcall map_free(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void map_free(void *p)
{
 free(((struct map *)p)->cmd);
 free(p);
}

variable_types:
p
void *


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

v2 = umalloc(16LL);
*(_BYTE *)v2 = a1;
v3 = ustrdup(a2);
*(_QWORD *)(v2 + 8) = v3;
str_escape(v3);
return list_append(maps, v2);
}

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

v2 = umalloc(16LL);
*(_BYTE *)v2 = a1;
v3 = ustrdup(a2);
*(_QWORD *)(v2 + 8) = v3;
str_escape(v3);
return list_append(maps, v2);
}

original_code:
void map_add(char c, const char *cmd)
{
 struct map *m = umalloc(sizeof *m);
 m->c = c;
 m->cmd = ustrdup(cmd);
 str_escape(m->cmd);
 list_append(maps, m);
}

canonical_original_code:
void map_add(char c, char *cmd)
{
 struct map *m = umalloc(sizeof *m);
 m->c = c;
 m->cmd = ustrdup(cmd);
 str_escape(m->cmd);
 list_append(maps, m);
}

variable_types:
cmd
char *

variable_types:
m
struct map { char c; char *cmd; } *


map

decompiled_code:
char *__fastcall map(__int64 a1, __int64 a2)
{
char *result; // rax
unsigned int v3; // ebp
__int64 v4; // rbx
__int64 i; // rcx
__int64 v6; // rdx

result = (char *)gui_getch(0LL);
v3 = (unsigned int)result;
v4 = maps;
for ( i = 0LL; v4; v4 = *(_QWORD *)(v4 + 8) )
{
result = *(char **)v4;
if ( !*(_QWORD *)v4 )
break;
v6 = (unsigned int)*result;
if ( (_DWORD)v6 == v3 )
{
result = (char *)gui_queue(*((_QWORD *)result + 1), a2, v6, i);
i = 1LL;
}
}
if ( !(_DWORD)i && v3 != 27 )
result = (char *)gui_status(1LL, "map %c not defined", v3);
return result;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1, __int64 a2)
{
char *result; // rax
unsigned int v3; // ebp
__int64 v4; // rbx
__int64 i; // rcx
__int64 v6; // rdx

result = (char *)gui_getch(0LL);
v3 = (unsigned int)result;
v4 = maps;
for ( i = 0LL; v4; v4 = *(_QWORD *)(v4 + 8) )
{
result = *(char **)v4;
if ( !*(_QWORD *)v4 )
break;
v6 = (unsigned int)*result;
if ( (_DWORD)v6 == v3 )
{
result = (char *)gui_queue(*((_QWORD *)result + 1), a2, v6, i);
i = 1LL;
}
}
if ( !(_DWORD)i && v3 != 27 )
result = (char *)gui_status(1LL, "map %c not defined", v3);
return result;
}

original_code:
void map()
{
 struct list *l;
 int found = 0;
 int c = gui_getch(GETCH_COOKED);
 for(l = maps; l && l->data; l = l->next){
  struct map *m = l->data;
  if(m->c == c){
   gui_queue(m->cmd);
   found = 1;
  }
 }
 if(!found && c != (('[') & 037))
  gui_status(GUI_ERR, "map %c not defined", c);
}

variable_types: found int

variable_types: c int


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

result = list_new(0LL);
maps = result;
return result;
}

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

result = list_new(0LL);
maps = result;
return result;
}

original_code:
void map_init()
{
 maps = list_new(((void *)0));
}


decompiled_code:
__int64 map_term()
{
return list_free(maps, map_free);
}

canonical_decompiled_code:
__int64 func4()
{
return list_free(maps, map_free);
}

original_code:
void map_term()
{
 list_free(maps, map_free);
}


decompiled_code:
__int64 map_getall()
{
return maps;
}

canonical_decompiled_code:
__int64 func5()
{
return maps;
}

original_code:
struct list *map_getall()
{
 return maps;
}


decompiled_code:
__int64 buffers_array()
{
return fnames;
}

canonical_decompiled_code:
__int64 func1()
{
return fnames;
}

original_code:
struct old_buffer **buffers_array()
{
 return fnames;
}

return_type: struct old_buffer { char *fname; int last_y; int read; } **


decompiled_code:
__int64 buffers_idx()
{
return (unsigned int)current;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)current;
}

original_code:
int buffers_idx()
{
 return current;
}

canonical_original_code:
int buffers_idx()
{
 return current;
}


decompiled_code:
__int64 buffers_count()
{
return (unsigned int)count;
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)count;
}

original_code:
int buffers_count()
{
 return count;
}

canonical_original_code:
int buffers_count()
{
 return count;
}


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

if ( last == -1 )
result = 0LL;
else
result = **(_QWORD **)(fnames + 8LL * last);
return result;
}

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

if ( last == -1 )
result = 0LL;
else
result = **(_QWORD **)(fnames + 8LL * last);
return result;
}

original_code:
const char *buffers_alternate(void)
{
 if(last == -1)
  return ((void *)0);
 return fnames[last]->fname;
}

canonical_original_code:
char *buffers_alternate()
{
 if(last == -1)
  return ((void *)0);
 return fnames[last]->fname;
}


decompiled_code:
__int64 buffers_alternate_idx()
{
return (unsigned int)last;
}

canonical_decompiled_code:
__int64 func6()
{
return (unsigned int)last;
}

original_code:
int buffers_alternate_idx()
{
 return last;
}


decompiled_code:
__int64 buffers_save_pos()
{
__int64 result; // rax
__int64 v1; // rbx

result = (unsigned int)current;
if ( current >= 0 && current < count )
{
v1 = *(_QWORD *)(fnames + 8LL * current);
result = gui_y();
*(_DWORD *)(v1 + 8) = result;
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
__int64 v1; // rbx

result = (unsigned int)current;
if ( current >= 0 && current < count )
{
v1 = *(_QWORD *)(fnames + 8LL * current);
result = gui_y();
*(_DWORD *)(v1 + 8) = result;
}
return result;
}

original_code:
void buffers_save_pos()
{
 if(0 <= current && current < count)
  fnames[current]->last_y = gui_y();
}


decompiled_code:
__int64 __fastcall buffers_goto(int a1)
{
__int64 result; // rax
int v2; // ebp
__int64 v3; // rax

result = 1LL;
if ( a1 >= 0 && count > a1 )
{
v2 = current;
if ( current != a1 )
buffers_save_pos();
last = current;
current = a1;
if ( current_buf )
buffer_free();
current_buf = buffers_readfname(**(const char ***)(fnames + 8LL * current));
if ( arg_ro )
*(_DWORD *)(buffers_current() + 16) = 1;
v3 = fnames + 8LL * a1;
*(_DWORD *)(*(_QWORD *)v3 + 12LL) = 1;
gui_move(*(unsigned int *)(*(_QWORD *)v3 + 8LL), 0LL);
result = 0LL;
if ( v2 != a1 )
{
gui_scrollclear = 0;
gui_scroll(6LL);
gui_scrollclear = 1;
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
__int64 result; // rax
int v2; // ebp
__int64 v3; // rax

result = 1LL;
if ( a1 >= 0 && count > a1 )
{
v2 = current;
if ( current != a1 )
func7();
last = current;
current = a1;
if ( current_buf )
buffer_free();
current_buf = func0(**(const char ***)(fnames + 8LL * current));
if ( arg_ro )
*(_DWORD *)(func3() + 16) = 1;
v3 = fnames + 8LL * a1;
*(_DWORD *)(*(_QWORD *)v3 + 12LL) = 1;
gui_move(*(unsigned int *)(*(_QWORD *)v3 + 8LL), 0LL);
result = 0LL;
if ( v2 != a1 )
{
gui_scrollclear = 0;
gui_scroll(6LL);
gui_scrollclear = 1;
result = 0LL;
}
}
return result;
}

original_code:
int buffers_goto(int n)
{
 extern int gui_scrollclear;
 int loadpos;
 if(n < 0 || n >= count)
  return 1;
 if((loadpos = current != n))
  buffers_save_pos();
 last = current;
 current = n;
 if(current_buf)
  buffer_free(current_buf);
 current_buf = buffers_readfname(fnames[current]->fname);
 if(arg_ro)
  ((buffers_current())->readonly) = 1;
 fnames[n]->read = 1;
 gui_move(fnames[n]->last_y, 0);
 if(loadpos){
  gui_scrollclear = 0;
  gui_scroll(CURSOR_MIDDLE);
  gui_scrollclear = 1;
 }
 return 0;
}

variable_types: n int

variable_types: loadpos int


decompiled_code:
__int64 __fastcall buffers_init(int a1, const char **a2, int a3)
{
int v3; // ebx
const char **v4; // r14
_QWORD *v6; // rax
__int64 v7; // r13
__int64 result; // rax
const char *v9; // rbp
const char **v10; // rbx
_QWORD *v11; // rbp
int v12; // [rsp+8h] [rbp-40h]
int v13; // [rsp+Ch] [rbp-3Ch]

v3 = a1;
v4 = a2;
v13 = 0;
if ( a1 > 0 && !strcmp(*a2, "-") )
{
v3 = a1 - 1;
v4 = a2 + 1;
fwrite("uvi: reading from stdin\n", 1uLL, 0x18uLL, stderr);
v13 = 1;
}
count = v3;
arg_ro = a3;
v6 = (_QWORD *)umalloc(8LL * (v3 + 1));
fnames = (__int64)v6;
v7 = 0LL;
v12 = 0;
if ( count <= 0 )
{
count = 0;
*v6 = 0LL;
current = -1;
if ( !v13 )
{
LABEL_6:
result = buffer_new_empty();
current_buf = result;
return result;
}
goto LABEL_16;
}
do
{
if ( (int)v7 <= 0 )
{
LABEL_12:
v11 = (_QWORD *)(fnames + 8LL * v12);
*v11 = new_old_buf((__int64)v4[v7]);
++v12;
}
else
{
v9 = v4[v7];
v10 = v4;
while ( strcmp(v9, *v10) )
{
if ( ++v10 == &v4[(unsigned int)(v7 - 1) + 1] )
goto LABEL_12;
}
}
++v7;
}
while ( count > (int)v7 );
count = v12;
*(_QWORD *)(fnames + 8LL * v12) = 0LL;
current = -(v12 <= 0);
if ( v13 )
{
LABEL_16:
current_buf = (__int64)buffers_readfile((__int64)stdin, "-", 1);
*(_DWORD *)(current_buf + 20) = 1;
result = input_reopen();
current = -1;
return result;
}
if ( v12 <= 0 )
goto LABEL_6;
return buffers_goto(0);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, const char **a2, int a3)
{
int v3; // ebx
const char **v4; // r14
_QWORD *v6; // rax
__int64 v7; // r13
__int64 result; // rax
const char *v9; // rbp
const char **v10; // rbx
_QWORD *v11; // rbp
int v12; // [rsp+8h] [rbp-40h]
int v13; // [rsp+Ch] [rbp-3Ch]

v3 = a1;
v4 = a2;
v13 = 0;
if ( a1 > 0 && !strcmp(*a2, "-") )
{
v3 = a1 - 1;
v4 = a2 + 1;
fwrite("uvi: reading from stdin\n", 1uLL, 0x18uLL, stderr);
v13 = 1;
}
count = v3;
arg_ro = a3;
v6 = (_QWORD *)umalloc(8LL * (v3 + 1));
fnames = (__int64)v6;
v7 = 0LL;
v12 = 0;
if ( count <= 0 )
{
count = 0;
*v6 = 0LL;
current = -1;
if ( !v13 )
{
LABEL_6:
result = buffer_new_empty();
current_buf = result;
return result;
}
goto LABEL_16;
}
do
{
if ( (int)v7 <= 0 )
{
LABEL_12:
v11 = (_QWORD *)(fnames + 8LL * v12);
*v11 = new_old_buf((__int64)v4[v7]);
++v12;
}
else
{
v9 = v4[v7];
v10 = v4;
while ( strcmp(v9, *v10) )
{
if ( ++v10 == &v4[(unsigned int)(v7 - 1) + 1] )
goto LABEL_12;
}
}
++v7;
}
while ( count > (int)v7 );
count = v12;
*(_QWORD *)(fnames + 8LL * v12) = 0LL;
current = -(v12 <= 0);
if ( v13 )
{
LABEL_16:
current_buf = (__int64)buffers_readfile((__int64)stdin, "-", 1);
*(_DWORD *)(current_buf + 20) = 1;
result = input_reopen();
current = -1;
return result;
}
if ( v12 <= 0 )
goto LABEL_6;
return func8(0);
}

original_code:
void buffers_init(int argc, const char **argv, int ro)
{
 int i, bufidx;
 int read_stdin = 0;
 if(argc > 0 && !strcmp(argv[0], "-")){
  argc--;
  argv++;
  read_stdin = 1;
  fputs("uvi: reading from stdin\n", stderr);
 }
 count = argc;
 arg_ro = ro;
 fnames = umalloc((count + 1) * sizeof *fnames);
 bufidx = 0;
 for(i = 0; i < count; i++){
  int j, found = 0;
  for(j = 0; j < i; j++)
   if(!strcmp(argv[i], argv[j])){
    found = 1;
    break;
   }
  if(!found)
   fnames[bufidx++] = new_old_buf(argv[i]);
 }
 fnames[count = bufidx] = ((void *)0);
 current = count > 0 ? 0 : -1;
 if(read_stdin){
  current_buf = buffers_readfile(stdin, "-", 1);
  ((current_buf)->modified) = 1;
  input_reopen();
  current = -1;
 }else if(count > 0){
  buffers_goto(0);
 }else{
  current_buf = buffer_new_empty();
 }
}

canonical_original_code:
void buffers_init(int argc, char **argv, int ro)
{
 int i; int bufidx;
 int read_stdin = 0;
 if(argc > 0 && !strcmp(argv[0], "-")){
  argc--;
  argv++;
  read_stdin = 1;
  fputs("uvi: reading from stdin\n", stderr);
 }
 count = argc;
 arg_ro = ro;
 fnames = umalloc((count + 1) * sizeof *fnames);
 bufidx = 0;
 for(i = 0; i < count; i++){
  int j; int found = 0;
  for(j = 0; j < i; j++)
   if(!strcmp(argv[i], argv[j])){
    found = 1;
    break;
   }
  if(!found)
   fnames[bufidx++] = new_old_buf(argv[i]);
 }
 fnames[count = bufidx] = ((void *)0);
 current = count > 0 ? 0 : -1;
 if(read_stdin){
  current_buf = buffers_readfile(stdin, "-", 1);
  ((current_buf)->modified) = 1;
  input_reopen();
  current = -1;
 }else if(count > 0){
  buffers_goto(0);
 }else{
  current_buf = buffer_new_empty();
 }
}

variable_types: argc int

variable_types:
argv
char **

variable_types: ro int

variable_types: bufidx int

variable_types: j int


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

if ( current == -1 )
result = buffers_goto(0);
else
result = buffers_goto(a1 + current);
return result;
}

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

if ( current == -1 )
result = func8(0);
else
result = func8(a1 + current);
return result;
}

original_code:
int buffers_next(int n)
{
 if(current == -1)
  return buffers_goto(0);
 return buffers_goto(current + n);
}


decompiled_code:
__int64 __fastcall buffers_del(int a1)
{
__int64 result; // rax
int v2; // er12
__int64 v3; // r13
void ***v4; // rbx
void ***v5; // rax

result = 1LL;
if ( a1 >= 0 )
{
v2 = count;
if ( count > a1 )
{
v3 = fnames;
v4 = (void ***)(fnames + 8LL * a1);
free(**v4);
free(*v4);
if ( last == a1 )
last = -1;
v5 = v4;
do
{
*v5 = v5[1];
++v5;
}
while ( v5 != (void ***)(v3 + 8 * (a1 + (unsigned __int64)(unsigned int)(v2 - 1 - a1)) + 8) );
count = v2 - 1;
if ( current == a1 )
{
current = -1;
result = 0LL;
}
else
{
result = 0LL;
if ( current > a1 )
--current;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1)
{
__int64 result; // rax
int v2; // er12
__int64 v3; // r13
void ***v4; // rbx
void ***v5; // rax

result = 1LL;
if ( a1 >= 0 )
{
v2 = count;
if ( count > a1 )
{
v3 = fnames;
v4 = (void ***)(fnames + 8LL * a1);
free(**v4);
free(*v4);
if ( last == a1 )
last = -1;
v5 = v4;
do
{
*v5 = v5[1];
++v5;
}
while ( v5 != (void ***)(v3 + 8 * (a1 + (unsigned __int64)(unsigned int)(v2 - 1 - a1)) + 8) );
count = v2 - 1;
if ( current == a1 )
{
current = -1;
result = 0LL;
}
else
{
result = 0LL;
if ( current > a1 )
--current;
}
}
}
return result;
}

original_code:
int buffers_del(int n)
{
 int i;
 if(n < 0 || n >= count)
  return 1;
 free(fnames[n]->fname);
 free(fnames[n]);
 if(last == n)
  last = -1;
 for(i = n; i < count; i++)
  fnames[i] = fnames[i + 1];
 count--;
 if(current == n)
  current = -1;
 else if(current > n)
  current--;
 return 0;
}


decompiled_code:
__int64 buffers_first_unread()
{
__int64 v0; // rax
unsigned int v1; // esi

if ( count <= 0 )
return (unsigned int)-1;
v0 = 0LL;
while ( 1 )
{
v1 = v0;
if ( !*(_DWORD *)(*(_QWORD *)(fnames + 8 * v0) + 12LL) )
break;
if ( ++v0 == count )
return (unsigned int)-1;
}
return v1;
}

canonical_decompiled_code:
__int64 func12()
{
__int64 v0; // rax
unsigned int v1; // esi

if ( count <= 0 )
return (unsigned int)-1;
v0 = 0LL;
while ( 1 )
{
v1 = v0;
if ( !*(_DWORD *)(*(_QWORD *)(fnames + 8 * v0) + 12LL) )
break;
if ( ++v0 == count )
return (unsigned int)-1;
}
return v1;
}

original_code:
int buffers_first_unread()
{
 int i;
 for(i = 0; i < count; i++)
  if(!fnames[i]->read)
   return i;
 return -1;
}


decompiled_code:
_BOOL8 buffers_unread()
{
return (unsigned int)buffers_first_unread() != -1;
}

canonical_decompiled_code:
_BOOL8 func13()
{
return (unsigned int)func12() != -1;
}

original_code:
int buffers_unread()
{
 return buffers_first_unread() != -1;
}


decompiled_code:
__int64 __fastcall buffers_find(char *s2)
{
__int64 v1; // r12
const char **v2; // rax
__int64 v3; // rbx
unsigned int v4; // er13

v1 = fnames;
v2 = *(const char ***)fnames;
if ( !*(_QWORD *)fnames )
return (unsigned int)-1;
v3 = 0LL;
while ( 1 )
{
v4 = v3;
if ( !strcmp(*v2, s2) )
break;
++v3;
v2 = *(const char ***)(v1 + 8 * v3);
if ( !v2 )
return (unsigned int)-1;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func14(char *s2)
{
__int64 v1; // r12
const char **v2; // rax
__int64 v3; // rbx
unsigned int v4; // er13

v1 = fnames;
v2 = *(const char ***)fnames;
if ( !*(_QWORD *)fnames )
return (unsigned int)-1;
v3 = 0LL;
while ( 1 )
{
v4 = v3;
if ( !strcmp(*v2, s2) )
break;
++v3;
v2 = *(const char ***)(v1 + 8 * v3);
if ( !v2 )
return (unsigned int)-1;
}
return v4;
}

original_code:
int buffers_find(const char *fname)
{
 struct old_buffer **iter;
 int i;
 for(i = 0, iter = fnames; *iter; iter++, i++)
  if(!strcmp((*iter)->fname, fname))
   return i;
 return -1;
}

canonical_original_code:
int buffers_find(char *fname)
{
 struct old_buffer **iter;
 int i;
 for(i = 0, iter = fnames; *iter; iter++, i++)
  if(!strcmp((*iter)->fname, fname))
   return i;
 return -1;
}

variable_types:
fname
char *

variable_types: struct old_buffer { char *fname; int last_y; int read; } **


decompiled_code:
__int64 __fastcall buffers_add(char *a1)
{
unsigned int v1; // ebx
_QWORD *v3; // rbp

v1 = buffers_find(a1);
if ( v1 == -1 )
{
v1 = count++;
fnames = urealloc(fnames, 8LL * (int)(v1 + 2));
v3 = (_QWORD *)(fnames + 8LL * (int)(v1 + 2) - 16);
*v3 = new_old_buf((__int64)a1);
*(_QWORD *)(fnames + 8LL * count) = 0LL;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func15(char *a1)
{
unsigned int v1; // ebx
_QWORD *v3; // rbp

v1 = func14(a1);
if ( v1 == -1 )
{
v1 = count++;
fnames = urealloc(fnames, 8LL * (int)(v1 + 2));
v3 = (_QWORD *)(fnames + 8LL * (int)(v1 + 2) - 16);
*v3 = new_old_buf((__int64)a1);
*(_QWORD *)(fnames + 8LL * count) = 0LL;
}
return v1;
}

original_code:
int buffers_add(const char *fname)
{
 int i;
 if((i = buffers_find(fname)) != -1)
  return i;
 i = count++;
 fnames = urealloc(fnames, (count + 1) * sizeof *fnames);
 fnames[i] = new_old_buf(fname);
 fnames[count] = ((void *)0);
 return i;
}

canonical_original_code:
int buffers_add(char *fname)
{
 int i;
 if((i = buffers_find(fname)) != -1)
  return i;
 i = count++;
 fnames = urealloc(fnames, (count + 1) * sizeof *fnames);
 fnames[i] = new_old_buf(fname);
 fnames[count] = ((void *)0);
 return i;
}

variable_types: i int