decompiled_code:
__int64 __fastcall args_next_fname(char a1)
{
__int64 v1; // rdx

if ( !remaining_fnames )
return remaining_fnames;
v1 = *(_QWORD *)remaining_fnames;
if ( *(_QWORD *)remaining_fnames && a1 )
remaining_fnames += 8LL;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
__int64 v1; // rdx

if ( !remaining_fnames )
return remaining_fnames;
v1 = *(_QWORD *)remaining_fnames;
if ( *(_QWORD *)remaining_fnames && a1 )
remaining_fnames += 8LL;
return v1;
}

original_code:
char *args_next_fname(_Bool pop)
{
 char *fname = remaining_fnames ? *remaining_fnames : ((void *)0);
 if(pop && fname)
  remaining_fnames++;
 return fname;
}


main

canonical_name: main

repo: bobrippling/tim

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v3; // cf
bool v4; // zf
unsigned int v5; // er13
const char ***v6; // r12
unsigned int v7; // er14
int v8; // ebp
unsigned __int8 *v9; // rbx
unsigned __int8 *i; // rax
const char **v11; // rbx
__int64 v12; // rcx
char v13; // al
bool v14; // cf
bool v15; // zf
__int64 v16; // rcx
int v17; // ebx
const char **v19; // [rsp+8h] [rbp-50h]
unsigned int v20[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v19 = argv;
v20[0] = 0;
v3 = argc == 0;
v4 = argc == 1;
if ( argc > 1 )
{
v5 = argc;
v6 = (const char ***)(argv + 1);
v7 = 0;
v8 = 1;
while ( 1 )
{
v11 = *v6;
*(_QWORD *)&argc = &unk_178;
v12 = 3LL;
argv = *v6;
do
{
if ( !v12 )
break;
v3 = *(_BYTE *)argv < **(_BYTE **)&argc;
v4 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v12;
}
while ( v4 );
v13 = (!v3 && !v4) - v3;
v14 = 0;
v15 = v13 == 0;
if ( v13 )
{
*(_QWORD *)&argc = &unk_17B;
v16 = 3LL;
argv = *v6;
do
{
if ( !v16 )
break;
v14 = *(_BYTE *)argv < **(_BYTE **)&argc;
v15 = *(_BYTE *)argv == **(_BYTE **)&argc;
argv = (const char **)((char *)argv + 1);
++*(_QWORD *)&argc;
--v16;
}
while ( v15 );
if ( (!v14 && !v15) == v14 )
{
v7 = 2;
}
else
{
if ( *(_BYTE *)v11 != 43 )
goto LABEL_23;
v9 = (unsigned __int8 *)v11 + 1;
argv = (const char **)*_ctype_b_loc();
for ( i = v9; ; ++i )
{
envp = (const char **)*i;
if ( (*((_BYTE *)argv + 2 * (char)envp + 1) & 8) == 0 )
break;
}
if ( (_BYTE)envp )
goto LABEL_23;
argv = (const char **)&unk_17E;
*(_QWORD *)&argc = v9;
if ( (unsigned int)_isoc99_sscanf(v9, &unk_17E, v20) != 1 )
goto LABEL_23;
if ( v20[0] )
--v20[0];
}
}
else
{
v7 = 1;
}
++v8;
++v6;
v3 = v5 < v8;
v4 = v5 == v8;
if ( v5 == v8 )
goto LABEL_23;
}
}
v7 = 0;
v8 = 1;
LABEL_23:
remaining_fnames = (__int64)&v19[v8];
ui_init(*(_QWORD *)&argc, argv, envp);
tabs_init(v7, v20[0]);
v17 = ui_main();
ui_term();
tabs_term();
return v17;
}

original_code:
int main(int argc, char **argv)
{
 int i;
 unsigned offset = 0;
 enum init_args initargs = INIT_NONE;
 for(i = 1; i < argc; i++){
  if(!strcmp(argv[i], "-O")){
   initargs = INIT_VALL;
  }else if(!strcmp(argv[i], "-o")){
   initargs = INIT_HALL;
  }else if(*argv[i] == '+'){
   char *p = argv[i] + 1;
   while(((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISdigit))
    p++;
   if(*p == '\0' && sscanf(argv[i]+1, "%u", &offset) == 1){
    if(offset > 0)
     offset--;
   }else{
    break;
   }
  }else{
   break;
  }
 }
 remaining_fnames = argv + i;
 ui_init();
 tabs_init(initargs, offset);
 int r = ui_main();
 ui_term();
 tabs_term();
 return r;
}

canonical_original_code:
int main(int argc, char **argv)
{
 int i;
 unsigned int offset = 0;
 enum init_args initargs = INIT_NONE;
 for(i = 1; i < argc; i++){
  if(!strcmp(argv[i], "-O")){
   initargs = INIT_VALL;
  }else if(!strcmp(argv[i], "-o")){
   initargs = INIT_HALL;
  }else if(*argv[i] == '+'){
   char *p = argv[i] + 1;
   while(((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISdigit))
    p++;
   if(*p == '\0' && sscanf(argv[i]+1, "%u", &offset) == 1){
    if(offset > 0)
     offset--;
   }else{
    break;
   }
  }else{
   break;
  }
 }
 remaining_fnames = argv + i;
 ui_init();
 tabs_init(initargs, offset);
 int r = ui_main();
 ui_term();
 tabs_term();
 return r;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int

variable_types:
offset
unsigned int

variable_types: enum init_args { INIT_NONE=0, INIT_VALL=1, INIT_HALL=2 }

variable_types:
p
char *

variable_types: r int

return_type: int


decompiled_code:
__int64 __fastcall word_state(_QWORD *a1, int a2, char a3)
{
__int64 result; // rax
char v5; // bp
unsigned __int16 v6; // dx

if ( !a1 )
return 0LL;
result = 0LL;
if ( a2 >= 0 )
{
result = 0LL;
if ( (unsigned __int64)(unsigned int)a2 < a1[1] )
{
v5 = *(_BYTE *)(*a1 + a2);
v6 = (*_ctype_b_loc())[v5];
result = 1LL;
if ( (v6 & 0x2000) == 0 )
{
result = 2LL;
if ( !a3 )
{
if ( (v6 & 8) != 0 || (result = 4LL, v5 == 95) )
result = 2LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, int a2, char a3)
{
__int64 result; // rax
char v5; // bp
unsigned __int16 v6; // dx

if ( !a1 )
return 0LL;
result = 0LL;
if ( a2 >= 0 )
{
result = 0LL;
if ( (unsigned __int64)(unsigned int)a2 < a1[1] )
{
v5 = *(_BYTE *)(*a1 + a2);
v6 = (*_ctype_b_loc())[v5];
result = 1LL;
if ( (v6 & 0x2000) == 0 )
{
result = 2LL;
if ( !a3 )
{
if ( (v6 & 8) != 0 || (result = 4LL, v5 == 95) )
result = 2LL;
}
}
}
}
return result;
}

original_code:
enum word_state word_state(
  const list_t *l, int x, _Bool big_words)
{
 if(l && 0 <= x && (unsigned)x < l->len_line){
  const char ch = l->line[x];
  if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace))
   return W_SPACE;
  else if(big_words)
   return W_KEYWORD;
  else if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalnum) || ch == '_')
   return W_KEYWORD;
  return W_NON_KWORD;
 }
 return W_NONE;
}

canonical_original_code:
enum word_state word_state(struct list_ *l, int x, _Bool big_words)
{
 if(l && 0 <= x && (unsigned int)x < l->len_line){
  char ch = l->line[x];
  if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISspace))
   return W_SPACE;
  else if(big_words)
   return W_KEYWORD;
  else if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalnum) || ch == '_')
   return W_KEYWORD;
  return W_NON_KWORD;
 }
 return W_NONE;
}

variable_types: struct list_ { char *line; unsigned long len_line; struct list_ *next; int flag; } *

variable_types: x int

variable_types: ch char

return_type: enum word_state { W_NONE=0, W_SPACE=expr, W_KEYWORD=expr, W_NON_KWORD=expr }


decompiled_code:
__int64 __fastcall word_seek_to_end(_QWORD *a1, int a2, int *a3, char a4)
{
__int64 result; // rax
int v7; // er12
int v8; // ebx

result = word_state(a1, *a3, a4);
v7 = result;
if ( (_DWORD)result )
{
while ( 1 )
{
v8 = *a3 + a2;
result = word_state(a1, v8, a4);
if ( (_DWORD)result != v7 )
break;
*a3 = v8;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, int a2, int *a3, char a4)
{
__int64 result; // rax
int v7; // er12
int v8; // ebx

result = func0(a1, *a3, a4);
v7 = result;
if ( (_DWORD)result )
{
while ( 1 )
{
v8 = *a3 + a2;
result = func0(a1, v8, a4);
if ( (_DWORD)result != v7 )
break;
*a3 = v8;
}
}
return result;
}

original_code:
void word_seek_to_end(list_t *l, int dir, point_t *to, _Bool big_words)
{
 const enum word_state st = word_state(l, to->x, big_words);
 if(st != W_NONE)
  while(word_state(l, to->x + dir, big_words) == st)
   to->x += dir;
}

canonical_original_code:
void word_seek_to_end(struct list_ *l, int dir, struct point *to, _Bool big_words)
{
 enum word_state st = word_state(l, to->x, big_words);
 if(st != W_NONE)
  while(word_state(l, to->x + dir, big_words) == st)
   to->x += dir;
}

variable_types: dir int

variable_types:
to
struct point { int x; } *

variable_types: enum word_state { W_NONE=0, W_SPACE=expr, W_KEYWORD=expr, W_NON_KWORD=expr }

return_type: void

user_defined_types: struct list_ { char *line; unsigned long len_line; struct list_ *next; int flag; }


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

result = (_QWORD *)tabs_cur();
if ( result )
result = (_QWORD *)*result;
return result;
}

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

result = (_QWORD *)tabs_cur();
if ( result )
result = (_QWORD *)*result;
return result;
}

original_code:
window *windows_cur()
{
 tab *t = tabs_cur();
 return t ? t->win : ((void *)0);
}

canonical_original_code:
struct window *windows_cur()
{
 struct tab *t = tabs_cur();
 return t ? t->win : ((void *)0);
}

variable_types: struct tab { struct window { struct buffer { struct retain { int rcount; } retains; struct list_ { char *line; unsigned long len_line; struct list_ *next; int flag; } *head; struct { struct point { int x; } npos; enum buf_mode { UI_NORMAL=expr, UI_INSERT=expr, UI_INSERT_COL=expr, UI_VISUAL_CHAR=expr, UI_VISUAL_COL=expr, UI_VISUAL_LN=expr } mode; } prev_visual; struct point prev_insert; char *fname; _Bool eol; _Bool modified; long mtime; unsigned int col_insert_height; } *buf; struct point ui_start; struct rect { int x; } screen_coord; struct point ui_npos; struct point ui_vpos; struct point *ui_pos; struct point ui_paren; enum buf_mode { UI_NORMAL=expr, UI_INSERT=expr, UI_INSERT_COL=expr, UI_VISUAL_CHAR=expr, UI_VISUAL_COL=expr, UI_VISUAL_LN=expr } ui_mode; struct { struct window *left; } neighbours; } *win; struct tab *next; } *

user_defined_types: struct tab { struct window *win; struct tab *next; }

user_defined_types: struct window { struct buffer *buf; struct point ui_start; struct rect screen_coord; struct point ui_npos; struct point ui_vpos; struct point *ui_pos; struct point ui_paren; enum buf_mode ui_mode; struct { struct window *left; } neighbours; }

user_defined_types: struct buffer { struct retain retains; struct list_ *head; struct { struct point npos; enum buf_mode mode; } prev_visual; struct point prev_insert; char *fname; _Bool eol; _Bool modified; long mtime; unsigned int col_insert_height; }


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

v1 = tabs_cur();
return tab_set_focus(v1, a1);
}

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

v1 = tabs_cur();
return tab_set_focus(v1, a1);
}

original_code:
void windows_set_cur(window *new)
{
 tab_set_focus(tabs_cur(), new);
}

canonical_original_code:
void windows_set_cur(struct window *new)
{
 tab_set_focus(tabs_cur(), new);
}

variable_types: struct window { struct buffer { struct retain { int rcount; } retains; struct list_ { char *line; unsigned long len_line; struct list_ *next; int flag; } *head; struct { struct point { int x; } npos; enum buf_mode { UI_NORMAL=expr, UI_INSERT=expr, UI_INSERT_COL=expr, UI_VISUAL_CHAR=expr, UI_VISUAL_COL=expr, UI_VISUAL_LN=expr } mode; } prev_visual; struct point prev_insert; char *fname; _Bool eol; _Bool modified; long mtime; unsigned int col_insert_height; } *buf; struct point ui_start; struct rect { int x; } screen_coord; struct point ui_npos; struct point ui_vpos; struct point *ui_pos; struct point ui_paren; enum buf_mode { UI_NORMAL=expr, UI_INSERT=expr, UI_INSERT_COL=expr, UI_VISUAL_CHAR=expr, UI_VISUAL_COL=expr, UI_VISUAL_LN=expr } ui_mode; struct { struct window *left; } neighbours; } *


decompiled_code:
int shellout_wait_ret()
{
int result; // eax

fwrite("enter to continue...", 1uLL, 0x14uLL, stderr);
do
result = getchar();
while ( result != -1 && result != 10 );
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax

fwrite("enter to continue...", 1uLL, 0x14uLL, stderr);
do
result = getchar();
while ( result != -1 && result != 10 );
return result;
}

original_code:
void shellout_wait_ret(void)
{
  fprintf(stderr, "enter to continue...");
  for(;;){
   int c = getchar();
   if(c == (-1) || c == '\n')
    break;
  }
}

canonical_original_code:
void shellout_wait_ret()
{
  fprintf(stderr, "enter to continue...");
  for(;;){
   int c = getchar();
   if(c == (-1) || c == '\n')
    break;
  }
}

variable_types: c int


shellout

decompiled_code:
__int64 __fastcall shellout(char *command)
{
char *v1; // rbx
unsigned int v2; // ebx

v1 = command;
if ( !command )
{
v1 = getenv("SHELL");
if ( !v1 )
v1 = "sh";
}
ui_term();
v2 = system(v1);
shellout_wait_ret();
ui_init();
return v2;
}

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

v1 = command;
if ( !command )
{
v1 = getenv("SHELL");
if ( !v1 )
v1 = "sh";
}
ui_term();
v2 = system(v1);
func0();
ui_init();
return v2;
}

original_code:
int shellout(const char *cmd)
{
 const char *shcmd;
 int r;
 if(cmd){
  shcmd = cmd;
 }else{
  const char *shell = getenv("SHELL");
  if(!shell)
   shell = "sh";
  shcmd = shell;
 }
 ui_term();
 r = system(shcmd);
 shellout_wait_ret();
 ui_init();
 return r;
}

canonical_original_code:
int shellout(char *cmd)
{
 char *shcmd;
 int r;
 if(cmd){
  shcmd = cmd;
 }else{
  char *shell = getenv("SHELL");
  if(!shell)
   shell = "sh";
  shcmd = shell;
 }
 ui_term();
 r = system(shcmd);
 shellout_wait_ret();
 ui_init();
 return r;
}

variable_types:
cmd
char *

variable_types:
shcmd
char *

variable_types:
shell
char *


original_code:
_Bool region_contains(const region_t *re, int x, int y)
{
 region_t sorted = *re;
 point_sort_full(&sorted.begin, &sorted.end);
 const struct
 {
  _Bool x, y;
 } in = {
  sorted.begin.x <= x && x <= sorted.end.x,
  sorted.begin.y <= y && y <= sorted.end.y
 };
 switch(re->type){
  case REGION_LINE:
   return in.y;
  case REGION_COL:
   return in.y && in.x;
  case REGION_CHAR:
   if(!in.y)
    return 0;
   if(re->begin.y == re->end.y)
    return in.x;
   sorted = *re;
   point_sort_y(&sorted.begin, &sorted.end);
   if(y == sorted.begin.y)
    return x >= sorted.begin.x;
   if(y == sorted.end.y)
    return x <= sorted.end.x;
   return 1;
 }
 return 0;
}

canonical_original_code:
_Bool region_contains(struct region *re, int x, int y)
{
 struct region sorted = *re;
 point_sort_full(&sorted.begin, &sorted.end);
 struct { _Bool x; } in = {
  sorted.begin.x <= x && x <= sorted.end.x,
  sorted.begin.y <= y && y <= sorted.end.y
 };
 switch(re->type){
  case REGION_LINE:
   return in.y;
  case REGION_COL:
   return in.y && in.x;
  case REGION_CHAR:
   if(!in.y)
    return 0;
   if(re->begin.y == re->end.y)
    return in.x;
   sorted = *re;
   point_sort_y(&sorted.begin, &sorted.end);
   if(y == sorted.begin.y)
    return x >= sorted.begin.x;
   if(y == sorted.end.y)
    return x <= sorted.end.x;
   return 1;
 }
 return 0;
}

variable_types: struct region { struct point { int x; } begin; enum region_type { REGION_CHAR=0, REGION_COL=1, REGION_LINE=2 } type; } *

variable_types: y int

variable_types:
in
struct { _Bool x; }

user_defined_types: struct region { struct point begin; enum region_type type; }


decompiled_code:
void __fastcall prompt_ctrl_r(_QWORD *a1, unsigned __int64 *a2, _QWORD *a3)
{
int v5; // eax
__int64 v6; // rax
char *v7; // rbp
char v8; // r15
size_t v9; // r14
unsigned __int64 v10; // rsi
__int64 v11; // rax
_QWORD *v12; // rax
char v13; // [rsp+7h] [rbp-41h] BYREF
unsigned int v14; // [rsp+8h] [rbp-40h] BYREF
unsigned int v15[15]; // [rsp+Ch] [rbp-3Ch] BYREF

nc_get_yx(v15, &v14);
nc_addch(34LL);
nc_set_yx(v15[0], v14);
v5 = io_getch(1LL, &v13, 1LL);
switch ( v5 )
{
case 23:
v11 = windows_cur();
v7 = (char *)window_current_word(v11);
v8 = 1;
break;
case 37:
v12 = (_QWORD *)windows_cur();
v7 = (char *)buffer_fname(*v12);
v8 = 0;
break;
case 6:
v6 = windows_cur();
v7 = (char *)window_current_fname(v6);
v8 = 1;
break;
default:
LABEL_4:
nc_clrtoeol();
return;
}
if ( !v7 )
goto LABEL_4;
v9 = strlen(v7);
v10 = v9 + *a3 + 1;
if ( v10 >= *a2 )
{
*a2 = v10;
*a1 = urealloc(*a1);
}
memcpy((void *)(*a1 + *a3), v7, v9 + 1);
*a3 += v9;
if ( v8 )
free(v7);
}

canonical_decompiled_code:
void __fastcall func0(_QWORD *a1, unsigned __int64 *a2, _QWORD *a3)
{
int v5; // eax
__int64 v6; // rax
char *v7; // rbp
char v8; // r15
size_t v9; // r14
unsigned __int64 v10; // rsi
__int64 v11; // rax
_QWORD *v12; // rax
char v13; // [rsp+7h] [rbp-41h] BYREF
unsigned int v14; // [rsp+8h] [rbp-40h] BYREF
unsigned int v15[15]; // [rsp+Ch] [rbp-3Ch] BYREF

nc_get_yx(v15, &v14);
nc_addch(34LL);
nc_set_yx(v15[0], v14);
v5 = io_getch(1LL, &v13, 1LL);
switch ( v5 )
{
case 23:
v11 = windows_cur();
v7 = (char *)window_current_word(v11);
v8 = 1;
break;
case 37:
v12 = (_QWORD *)windows_cur();
v7 = (char *)buffer_fname(*v12);
v8 = 0;
break;
case 6:
v6 = windows_cur();
v7 = (char *)window_current_fname(v6);
v8 = 1;
break;
default:
LABEL_4:
nc_clrtoeol();
return;
}
if ( !v7 )
goto LABEL_4;
v9 = strlen(v7);
v10 = v9 + *a3 + 1;
if ( v10 >= *a2 )
{
*a2 = v10;
*a1 = urealloc(*a1);
}
memcpy((void *)(*a1 + *a3), v7, v9 + 1);
*a3 += v9;
if ( v8 )
free(v7);
}

original_code:
static void prompt_ctrl_r(char **const buf, size_t *const len, size_t *const i)
{
 int y, x;
 nc_get_yx(&y, &x);
 nc_addch('"');
 nc_set_yx(y, x);
 _Bool wasraw;
 int ch = io_getch(IO_NOMAP, &wasraw, 1);
 char *to_insert = ((void *)0);
 _Bool free_to_insert = 1;
 switch(ch){
  case (('f') & 037):
   to_insert = window_current_fname(windows_cur());
   break;
  case (('w') & 037):
   to_insert = window_current_word(windows_cur());
   break;
  case '%':
   to_insert = (char *)buffer_fname(windows_cur()->buf);
   free_to_insert = 0;
   break;
  default:
   goto cancel;
 }
 if(!to_insert)
  goto cancel;
 size_t to_insert_len = strlen(to_insert);
 if(*i + to_insert_len + 1 >= *len){
  *len = *i + to_insert_len + 1;
  *buf = urealloc(*buf, *len);
 }
 memcpy(*buf + *i, to_insert, to_insert_len + 1);
 *i += to_insert_len;
 if(free_to_insert)
  free(to_insert);
 return;
cancel:
 nc_clrtoeol();
}

canonical_original_code:
static void prompt_ctrl_r(char **buf, unsigned long *len, unsigned long *i)
{
 int y; int x;
 nc_get_yx(&y, &x);
 nc_addch('"');
 nc_set_yx(y, x);
 _Bool wasraw;
 int ch = io_getch(IO_NOMAP, &wasraw, 1);
 char *to_insert = ((void *)0);
 _Bool free_to_insert = 1;
 switch(ch){
  case (('f') & 037):
   to_insert = window_current_fname(windows_cur());
   break;
  case (('w') & 037):
   to_insert = window_current_word(windows_cur());
   break;
  case '%':
   to_insert = (char *)buffer_fname(windows_cur()->buf);
   free_to_insert = 0;
   break;
  default:
   goto cancel;
 }
 if(!to_insert)
  goto cancel;
 unsigned long to_insert_len = strlen(to_insert);
 if(*i + to_insert_len + 1 >= *len){
  *len = *i + to_insert_len + 1;
  *buf = urealloc(*buf, *len);
 }
 memcpy(*buf + *i, to_insert, to_insert_len + 1);
 *i += to_insert_len;
 if(free_to_insert)
  free(to_insert);
 return;
cancel:
 nc_clrtoeol();
}

variable_types:
buf
char **

variable_types:
len
unsigned long *

variable_types:
i
unsigned long *

variable_types: ch int


yesno

decompiled_code:
bool yesno(__int64 a1, ...)
{
int v1; // eax
int v2; // ebx
char v4; // [rsp+Fh] [rbp-D9h] BYREF
gcc_va_list va; // [rsp+10h] [rbp-D8h] BYREF
unsigned int v6; // [rsp+28h] [rbp-C0h] BYREF
unsigned int v7; // [rsp+2Ch] [rbp-BCh] BYREF

va_start(va, a1);
nc_get_yx(&v7, &v6);
v1 = nc_LINES();
nc_set_yx((unsigned int)(v1 - 1), 0LL);
nc_vprintf(a1, va);
v2 = io_getch(1LL, &v4, 1LL);
nc_set_yx(v7, v6);
return tolower(v2) == 121;
}

canonical_decompiled_code:
bool func2(__int64 a1, ...)
{
int v1; // eax
int v2; // ebx
char v4; // [rsp+Fh] [rbp-D9h] BYREF
gcc_va_list va; // [rsp+10h] [rbp-D8h] BYREF
unsigned int v6; // [rsp+28h] [rbp-C0h] BYREF
unsigned int v7; // [rsp+2Ch] [rbp-BCh] BYREF

va_start(va, a1);
nc_get_yx(&v7, &v6);
v1 = nc_LINES();
nc_set_yx((unsigned int)(v1 - 1), 0LL);
nc_vprintf(a1, va);
v2 = io_getch(1LL, &v4, 1LL);
nc_set_yx(v7, v6);
return tolower(v2) == 121;
}

original_code:
_Bool yesno(const char *fmt, ...)
{
 int y, x;
 nc_get_yx(&y, &x);
 nc_set_yx(nc_LINES() - 1, 0);
 va_list l;
 __builtin_va_start(l,fmt);
 nc_vprintf(fmt, l);
 __builtin_va_end(l);
 _Bool wasraw;
 int ch = io_getch(IO_NOMAP, &wasraw, 1);
 nc_set_yx(y, x);
 return tolower(ch) == 'y';
}

canonical_original_code:
_Bool yesno(char *fmt, ...)
{
 int y; int x;
 nc_get_yx(&y, &x);
 nc_set_yx(nc_LINES() - 1, 0);
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 nc_vprintf(fmt, l);
 __builtin_va_end(l);
 _Bool wasraw;
 int ch = io_getch(IO_NOMAP, &wasraw, 1);
 nc_set_yx(y, x);
 return tolower(ch) == 'y';
}

variable_types:
fmt
char *

variable_types: x int


decompiled_code:
void __fastcall ctag_free(void **a1)
{
free(*a1);
free(a1[1]);
*a1 = 0LL;
a1[1] = 0LL;
}

canonical_decompiled_code:
void __fastcall func1(void **a1)
{
free(*a1);
free(a1[1]);
*a1 = 0LL;
a1[1] = 0LL;
}

original_code:
void ctag_free(struct ctag_result *r)
{
 free(r->fname);
 free(r->line);
 memset(r, 0, sizeof *r);
}

variable_types: struct ctag_result { char *fname; char *line; } *


decompiled_code:
__int64 __fastcall release_nochk(_DWORD *a1, __int64 (*a2)(void))
{
bool v2; // zf
__int64 result; // rax

v2 = *a1 == 1;
result = (unsigned int)(*a1 - 1);
*a1 = result;
if ( v2 )
result = a2();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1, __int64 (*a2)(void))
{
bool v2; // zf
__int64 result; // rax

v2 = *a1 == 1;
result = (unsigned int)(*a1 - 1);
*a1 = result;
if ( v2 )
result = a2();
return result;
}

original_code:
void release_nochk(struct retain *r, void (*fn)(void *))
{
 if(--r->rcount == 0)
  fn(r);
}

variable_types:
r
struct retain { int rcount; } *

variable_types:
fn
void (*)(void *)


repo: bobrippling/ucc-c-compiler

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

switch ( a1 )
{
case 0:
result = (const char *)&unk_193;
break;
case 1:
result = "/";
break;
case 2:
result = (const char *)&unk_199;
break;
case 3:
result = (const char *)&unk_195;
break;
case 4:
result = (const char *)&unk_197;
break;
case 5:
result = (const char *)&unk_1AD;
break;
case 6:
result = (const char *)&unk_1AB;
break;
case 7:
result = (const char *)&unk_1AF;
break;
case 8:
result = (const char *)&unk_1B1;
break;
case 9:
result = (const char *)&unk_1B4;
break;
case 10:
result = (const char *)&unk_1BB;
break;
case 11:
result = (const char *)&unk_1BE;
break;
case 12:
result = (const char *)&unk_1B7;
break;
case 13:
result = (const char *)&unk_1B9;
break;
case 14:
result = (const char *)&unk_19B;
break;
case 15:
result = (const char *)&unk_19E;
break;
case 16:
result = (const char *)&unk_1A1;
break;
case 17:
result = (const char *)&unk_1A4;
break;
case 18:
result = (const char *)&unk_1A6;
break;
case 19:
result = (const char *)&unk_1A9;
break;
case 20:
result = "SIGNBIT";
break;
case 21:
result = "NOSIGNBIT";
break;
case 22:
result = "unknown";
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = (const char *)&unk_193;
break;
case 1:
result = "/";
break;
case 2:
result = (const char *)&unk_199;
break;
case 3:
result = (const char *)&unk_195;
break;
case 4:
result = (const char *)&unk_197;
break;
case 5:
result = (const char *)&unk_1AD;
break;
case 6:
result = (const char *)&unk_1AB;
break;
case 7:
result = (const char *)&unk_1AF;
break;
case 8:
result = (const char *)&unk_1B1;
break;
case 9:
result = (const char *)&unk_1B4;
break;
case 10:
result = (const char *)&unk_1BB;
break;
case 11:
result = (const char *)&unk_1BE;
break;
case 12:
result = (const char *)&unk_1B7;
break;
case 13:
result = (const char *)&unk_1B9;
break;
case 14:
result = (const char *)&unk_19B;
break;
case 15:
result = (const char *)&unk_19E;
break;
case 16:
result = (const char *)&unk_1A1;
break;
case 17:
result = (const char *)&unk_1A4;
break;
case 18:
result = (const char *)&unk_1A6;
break;
case 19:
result = (const char *)&unk_1A9;
break;
case 20:
result = "SIGNBIT";
break;
case 21:
result = "NOSIGNBIT";
break;
case 22:
result = "unknown";
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
const char *op_to_str(const enum op_type o)
{
 switch(o){
  case op_multiply: return "*";
  case op_divide: return "/";
  case op_plus: return "+";
  case op_minus: return "-";
  case op_modulus: return "%";
  case op_eq: return "==";
  case op_ne: return "!=";
  case op_le: return "<=";
  case op_lt: return "<";
  case op_ge: return ">=";
  case op_gt: return ">";
  case op_or: return "|";
  case op_xor: return "^";
  case op_and: return "&";
  case op_orsc: return "||";
  case op_andsc: return "&&";
  case op_not: return "!";
  case op_bnot: return "~";
  case op_shiftl: return "<<";
  case op_shiftr: return ">>";
  case op_signbit: return "SIGNBIT";
  case op_no_signbit: return "NOSIGNBIT";
  case op_unknown: return "unknown";
 }
 return ((void *)0);
}

canonical_original_code:
char *op_to_str(enum op_type o)
{
 switch(o){
  case op_multiply: return "*";
  case op_divide: return "/";
  case op_plus: return "+";
  case op_minus: return "-";
  case op_modulus: return "%";
  case op_eq: return "==";
  case op_ne: return "!=";
  case op_le: return "<=";
  case op_lt: return "<";
  case op_ge: return ">=";
  case op_gt: return ">";
  case op_or: return "|";
  case op_xor: return "^";
  case op_and: return "&";
  case op_orsc: return "||";
  case op_andsc: return "&&";
  case op_not: return "!";
  case op_bnot: return "~";
  case op_shiftl: return "<<";
  case op_shiftr: return ">>";
  case op_signbit: return "SIGNBIT";
  case op_no_signbit: return "NOSIGNBIT";
  case op_unknown: return "unknown";
 }
 return ((void *)0);
}

variable_types: enum op_type { op_multiply=0, op_divide=1, op_modulus=2, op_plus=3, op_minus=4, op_xor=5, op_or=6, op_and=7, op_orsc=8, op_andsc=9, op_shiftl=10, op_shiftr=11, op_not=12, op_bnot=13, op_eq=14, op_ne=15, op_le=16, op_lt=17, op_ge=18, op_gt=19, op_signbit=20, op_no_signbit=21, op_unknown=22 }

return_type: char *


decompiled_code:
_BOOL8 __fastcall op_can_compound(unsigned int a1)
{
_BOOL8 result; // rax

result = 1LL;
if ( a1 > 7 )
result = a1 - 10 <= 3;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned int a1)
{
_BOOL8 result; // rax

result = 1LL;
if ( a1 > 7 )
result = a1 - 10 <= 3;
return result;
}

original_code:
int op_can_compound(enum op_type o)
{
 switch(o){
  case op_plus:
  case op_minus:
  case op_multiply:
  case op_divide:
  case op_modulus:
  case op_not:
  case op_bnot:
  case op_and:
  case op_or:
  case op_xor:
  case op_shiftl:
  case op_shiftr:
   return 1;
  default:
   break;
 }
 return 0;
}

user_defined_types: enum op_type { op_multiply=0, op_divide=1, op_modulus=2, op_plus=3, op_minus=4, op_xor=5, op_or=6, op_and=7, op_orsc=8, op_andsc=9, op_shiftl=10, op_shiftr=11, op_not=12, op_bnot=13, op_eq=14, op_ne=15, op_le=16, op_lt=17, op_ge=18, op_gt=19, op_signbit=20, op_no_signbit=21, op_unknown=22 }


decompiled_code:
_BOOL8 __fastcall op_can_float(unsigned int a1)
{
_BOOL8 result; // rax

if ( a1 > 0xD )
result = 1LL;
else
result = ((1LL << a1) & 0x2CE4) == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(unsigned int a1)
{
_BOOL8 result; // rax

if ( a1 > 0xD )
result = 1LL;
else
result = ((1LL << a1) & 0x2CE4) == 0;
return result;
}

original_code:
int op_can_float(enum op_type o)
{
 switch(o){
  case op_modulus:
  case op_xor:
  case op_or:
  case op_and:
  case op_shiftl:
  case op_shiftr:
  case op_bnot:
   return 0;
  default:
   return 1;
 }
}


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

switch ( a1 )
{
case 0:
case 3:
case 5:
case 6:
case 7:
case 14:
case 15:
case 20:
case 21:
result = 1LL;
break;
case 22:
_assert_fail("0", "op.c", 0x5Au, "op_is_commutative");
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
case 3:
case 5:
case 6:
case 7:
case 14:
case 15:
case 20:
case 21:
result = 1LL;
break;
case 22:
_assert_fail("0", "op.c", 0x5Au, "op_is_commutative");
default:
result = 0LL;
break;
}
return result;
}

original_code:
int op_is_commutative(enum op_type o)
{
 switch(o){
  case op_multiply:
  case op_plus:
  case op_xor:
  case op_or:
  case op_and:
  case op_eq:
  case op_ne:
  case op_signbit:
  case op_no_signbit:
   return 1;
  case op_unknown:
   ((0) ? (void) (0) : __assert_fail ("0", "op.c", 90, __extension__ __PRETTY_FUNCTION__));
  case op_minus:
  case op_divide:
  case op_modulus:
  case op_orsc:
  case op_andsc:
  case op_shiftl:
  case op_shiftr:
  case op_le:
  case op_lt:
  case op_ge:
  case op_gt:
  case op_not:
  case op_bnot:
   break;
 }
 return 0;
}


decompiled_code:
_BOOL8 __fastcall op_is_comparison(int a1)
{
return (unsigned int)(a1 - 14) <= 5;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(int a1)
{
return (unsigned int)(a1 - 14) <= 5;
}

original_code:
int op_is_comparison(enum op_type o)
{
 switch(o){
  case op_eq:
  case op_ne:
  case op_le:
  case op_lt:
  case op_ge:
  case op_gt:
   return 1;
  default:
   break;
 }
 return 0;
}


decompiled_code:
_BOOL8 __fastcall op_is_shortcircuit(int a1)
{
return (unsigned int)(a1 - 8) <= 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(int a1)
{
return (unsigned int)(a1 - 8) <= 1;
}

original_code:
int op_is_shortcircuit(enum op_type o)
{
 switch(o){
  case op_andsc:
  case op_orsc:
   return 1;
  default:
   return 0;
 }
}


decompiled_code:
_BOOL8 __fastcall op_returns_bool(int a1)
{
_BOOL8 result; // rax
_BOOL4 v2; // edx

result = 1LL;
if ( a1 != 12 )
{
v2 = op_is_comparison(a1);
result = 1LL;
if ( !v2 )
result = op_is_shortcircuit(a1);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(int a1)
{
_BOOL8 result; // rax
_BOOL4 v2; // edx

result = 1LL;
if ( a1 != 12 )
{
v2 = func4(a1);
result = 1LL;
if ( !v2 )
result = func5(a1);
}
return result;
}

original_code:
int op_returns_bool(enum op_type o)
{
 return o == op_not || op_is_comparison(o) || op_is_shortcircuit(o);
}


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

switch ( a1 )
{
case 0:
case 3:
case 6:
case 10:
result = 1LL;
break;
case 1:
case 2:
case 4:
case 5:
case 7:
case 8:
case 9:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
result = 0LL;
break;
default:
_assert_fail("0", "op.c", 0xB2u, "op_increases");
}
return result;
}

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

switch ( a1 )
{
case 0:
case 3:
case 6:
case 10:
result = 1LL;
break;
case 1:
case 2:
case 4:
case 5:
case 7:
case 8:
case 9:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
result = 0LL;
break;
default:
_assert_fail("0", "op.c", 0xB2u, "op_increases");
}
return result;
}

original_code:
int op_increases(enum op_type o)
{
 switch(o){
  case op_unknown:
   break;
  case op_multiply:
  case op_plus:
  case op_or:
  case op_shiftl:
   return 1;
  case op_divide:
  case op_modulus:
  case op_minus:
  case op_shiftr:
  case op_and:
   return 0;
  case op_xor:
  case op_orsc:
  case op_andsc:
  case op_not:
  case op_bnot:
  case op_eq:
  case op_ne:
  case op_le:
  case op_lt:
  case op_ge:
  case op_gt:
  case op_signbit:
  case op_no_signbit:
   return 0;
 }
 ((0) ? (void) (0) : __assert_fail ("0", "op.c", 178, __extension__ __PRETTY_FUNCTION__));
 return 0;
}


decompiled_code:
__int64 __fastcall integral_truncate_bits(__int64 a1, unsigned int a2, __int64 *a3)
{
__int64 v3; // rax
__int64 result; // rax

v3 = -1LL;
if ( a2 <= 0x3F )
v3 = ~(-1LL << a2);
result = a1 & v3;
if ( !cc1_fopt[25] )
goto LABEL_8;
switch ( a2 )
{
case 8u:
if ( a3 )
*a3 = (char)a1;
result = (unsigned __int8)a1;
break;
case 0x10u:
if ( a3 )
*a3 = (__int16)a1;
result = (unsigned __int16)a1;
break;
case 0x20u:
if ( a3 )
*a3 = (int)a1;
result = (unsigned int)a1;
break;
case 0x40u:
result = a1;
if ( a3 )
*a3 = a1;
break;
default:
LABEL_8:
if ( a3 )
*a3 = a1 << (64 - (unsigned __int8)a2) >> (64 - (unsigned __int8)a2);
return result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2, __int64 *a3)
{
__int64 v3; // rax
__int64 result; // rax

v3 = -1LL;
if ( a2 <= 0x3F )
v3 = ~(-1LL << a2);
result = a1 & v3;
if ( !cc1_fopt[25] )
goto LABEL_8;
switch ( a2 )
{
case 8u:
if ( a3 )
*a3 = (char)a1;
result = (unsigned __int8)a1;
break;
case 0x10u:
if ( a3 )
*a3 = (__int16)a1;
result = (unsigned __int16)a1;
break;
case 0x20u:
if ( a3 )
*a3 = (int)a1;
result = (unsigned int)a1;
break;
case 0x40u:
result = a1;
if ( a3 )
*a3 = a1;
break;
default:
LABEL_8:
if ( a3 )
*a3 = a1 << (64 - (unsigned __int8)a2) >> (64 - (unsigned __int8)a2);
return result;
}
return result;
}

original_code:
integral_t integral_truncate_bits(
  integral_t val, unsigned bits,
  sintegral_t *signed_iv)
{
 integral_t pos_mask = bits < (sizeof(integral_t) * 8)
  ? ~(-1ULL << bits)
  : -1ULL;
 integral_t truncated = val & pos_mask;
 if(cc1_fopt.cast_w_builtin_types){
  if(bits == sizeof(char) * 8){ if(signed_iv) *signed_iv = (signed char)val; return (unsigned char)val; };
  if(bits == sizeof(short) * 8){ if(signed_iv) *signed_iv = (signed short)val; return (unsigned short)val; };
  if(bits == sizeof(int) * 8){ if(signed_iv) *signed_iv = (signed int)val; return (unsigned int)val; };
  if(bits == sizeof(long) * 8){ if(signed_iv) *signed_iv = (signed long)val; return (unsigned long)val; };
  if(bits == sizeof(long long) * 8){ if(signed_iv) *signed_iv = (signed long long)val; return (unsigned long long)val; };
 }
 if(signed_iv){
  const unsigned shamt = 8 * sizeof(val) - bits;
  *signed_iv = ((sintegral_t)val << shamt) >> shamt;
 }
 return truncated;
}

canonical_original_code:
unsigned long long integral_truncate_bits(unsigned long long val, unsigned int bits, long long *signed_iv)
{
 unsigned long long pos_mask = bits < (sizeof(integral_t) * 8)
  ? ~(-1ULL << bits)
  : -1ULL;
 unsigned long long truncated = val & pos_mask;
 if(cc1_fopt.cast_w_builtin_types){
  if(bits == sizeof(char) * 8){ if(signed_iv) *signed_iv = (char)val; return (unsigned char)val; };
  if(bits == sizeof(short) * 8){ if(signed_iv) *signed_iv = (short)val; return (unsigned short)val; };
  if(bits == sizeof(int) * 8){ if(signed_iv) *signed_iv = (int)val; return (unsigned int)val; };
  if(bits == sizeof(long) * 8){ if(signed_iv) *signed_iv = (long)val; return (unsigned long)val; };
  if(bits == sizeof(long long) * 8){ if(signed_iv) *signed_iv = (long long)val; return (unsigned long long)val; };
 }
 if(signed_iv){
  unsigned int shamt = 8 * sizeof(val) - bits;
  *signed_iv = ((long long)val << shamt) >> shamt;
 }
 return truncated;
}

variable_types:
val
unsigned long long

variable_types:
bits
unsigned int

variable_types:
truncated
unsigned long long

variable_types:
shamt
unsigned int

return_type: unsigned long long


decompiled_code:
__int64 __fastcall integral_truncate(__int64 a1, int a2, __int64 *a3)
{
return integral_truncate_bits(a1, 8 * a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, __int64 *a3)
{
return func1(a1, 8 * a2, a3);
}

original_code:
integral_t integral_truncate(
  integral_t val, unsigned bytes,
  sintegral_t *sign_extended)
{
 return integral_truncate_bits(
   val, bytes * 8,
   sign_extended);
}

canonical_original_code:
unsigned long long integral_truncate(unsigned long long val, unsigned int bytes, long long *sign_extended)
{
 return integral_truncate_bits(
   val, bytes * 8,
   sign_extended);
}

variable_types:
bytes
unsigned int


decompiled_code:
__int64 __fastcall dbg_add_file(const char ***a1, const char *a2)
{
const char **v2; // rbx
unsigned int v3; // ebp
const char ***v4; // r13
const char **v5; // rax
size_t v6; // rax
char *v7; // rbx
_BYTE v9[72]; // [rsp+0h] [rbp-48h] BYREF

v2 = *a1;
if ( *a1 )
{
v3 = 1;
while ( strcmp(a2, *v2) )
{
++v3;
if ( !v2[1] )
{
v4 = (const char ***)(v2 + 1);
goto LABEL_7;
}
v2 = (const char **)v2[1];
}
}
else
{
v4 = a1;
v3 = 1;
LABEL_7:
v5 = (const char **)umalloc(16LL);
*v4 = v5;
*v5 = a2;
v6 = strlen(a2);
cstring_init(v9, 1LL, a2, v6, 0LL);
v7 = (char *)str_add_escape(v9);
xfprintf(cc1_output[2], ".file %u \"%s\"\n", v3, v7);
cstring_deinit(v9);
free(v7);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char ***a1, const char *a2)
{
const char **v2; // rbx
unsigned int v3; // ebp
const char ***v4; // r13
const char **v5; // rax
size_t v6; // rax
char *v7; // rbx
_BYTE v9[72]; // [rsp+0h] [rbp-48h] BYREF

v2 = *a1;
if ( *a1 )
{
v3 = 1;
while ( strcmp(a2, *v2) )
{
++v3;
if ( !v2[1] )
{
v4 = (const char ***)(v2 + 1);
goto LABEL_7;
}
v2 = (const char **)v2[1];
}
}
else
{
v4 = a1;
v3 = 1;
LABEL_7:
v5 = (const char **)umalloc(16LL);
*v4 = v5;
*v5 = a2;
v6 = strlen(a2);
cstring_init(v9, 1LL, a2, v6, 0LL);
v7 = (char *)str_add_escape(v9);
xfprintf(cc1_output[2], ".file %u \"%s\"\n", v3, v7);
cstring_deinit(v9);
free(v7);
}
return v3;
}

original_code:
unsigned dbg_add_file(struct out_dbg_filelist **files, const char *nam)
{
 struct out_dbg_filelist **p;
 unsigned i = 1;
 struct cstring local;
 char *esc;
 for(p = files; *p; p = &(*p)->next, i++)
  if(!strcmp(nam, (*p)->fname))
   return i;
 *p = umalloc(sizeof **p);
 (*p)->fname = nam;
 cstring_init(&local, CSTRING_ASCII, nam, strlen(nam), 0);
 esc = str_add_escape(&local);
 xfprintf(cc1_output.file, ".file %u \"%s\"\n", i, esc);
 cstring_deinit(&local);
 free(esc);
 return i;
}

canonical_original_code:
unsigned int dbg_add_file(struct out_dbg_filelist **files, char *nam)
{
 struct out_dbg_filelist **p;
 unsigned int i = 1;
 struct cstring local;
 char *esc;
 for(p = files; *p; p = &(*p)->next, i++)
  if(!strcmp(nam, (*p)->fname))
   return i;
 *p = umalloc(sizeof **p);
 (*p)->fname = nam;
 cstring_init(&local, CSTRING_ASCII, nam, strlen(nam), 0);
 esc = str_add_escape(&local);
 xfprintf(cc1_output.file, ".file %u \"%s\"\n", i, esc);
 cstring_deinit(&local);
 free(esc);
 return i;
}

variable_types: struct out_dbg_filelist { char *fname; struct out_dbg_filelist *next; } **

variable_types:
nam
char *

variable_types:
i
unsigned int

variable_types: struct cstring { union { char *ascii; int *wides; } bits; unsigned long count; enum cstring_type { CSTRING_RAW=0, CSTRING_ASCII=1, CSTRING_WIDE=2 } type; }

variable_types:
esc
char *

return_type: unsigned int

user_defined_types: struct cstring { union { char *ascii; int *wides; } bits; unsigned long count; enum cstring_type type; }


decompiled_code:
char *__fastcall vwarn_colour(unsigned int a1)
{
int v1; // eax

if ( a1 == 2 )
{
v1 = 1;
}
else if ( a1 > 2 )
{
v1 = 0;
if ( a1 == 3 )
v1 = 7;
}
else
{
v1 = (a1 == 0) + 3;
}
return colour_strs[v1];
}

canonical_decompiled_code:
char *__fastcall func0(unsigned int a1)
{
int v1; // eax

if ( a1 == 2 )
{
v1 = 1;
}
else if ( a1 > 2 )
{
v1 = 0;
if ( a1 == 3 )
v1 = 7;
}
else
{
v1 = (a1 == 0) + 3;
}
return colour_strs[v1];
}

original_code:
static const char *vwarn_colour(enum warn_type ty)
{
 int i = 0;
 switch(ty){
  case VWARN_ERR: i = colour_err; break;
  case VWARN_WARN: i = colour_warn; break;
  case VWARN_NOTE: i = colour_note; break;
  case VWARN_OTHER: i = colour_other; break;
 }
 return colour_strs[i];
}

canonical_original_code:
static char *vwarn_colour(enum warn_type ty)
{
 int i = 0;
 switch(ty){
  case VWARN_ERR: i = colour_err; break;
  case VWARN_WARN: i = colour_warn; break;
  case VWARN_NOTE: i = colour_note; break;
  case VWARN_OTHER: i = colour_other; break;
 }
 return colour_strs[i];
}

variable_types: enum warn_type { VWARN_NOTE=0, VWARN_WARN=1, VWARN_ERR=2, VWARN_OTHER=3 }

variable_types: i int


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

if ( a1 == 2 )
return "error";
if ( a1 > 2 )
{
result = "other";
if ( a1 != 3 )
result = 0LL;
}
else
{
result = "warning";
if ( !a1 )
result = "note";
}
return result;
}

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

if ( a1 == 2 )
return "error";
if ( a1 > 2 )
{
result = "other";
if ( a1 != 3 )
result = 0LL;
}
else
{
result = "warning";
if ( !a1 )
result = "note";
}
return result;
}

original_code:
static const char *vwarn_str(enum warn_type ty)
{
 switch(ty){
  case VWARN_ERR: return "error";
  case VWARN_WARN: return "warning";
  case VWARN_NOTE: return "note";
  case VWARN_OTHER: return "other";
 }
 return ((void *)0);
}

canonical_original_code:
static char *vwarn_str(enum warn_type ty)
{
 switch(ty){
  case VWARN_ERR: return "error";
  case VWARN_WARN: return "warning";
  case VWARN_NOTE: return "note";
  case VWARN_OTHER: return "other";
 }
 return ((void *)0);
}

user_defined_types: enum warn_type { VWARN_NOTE=0, VWARN_WARN=1, VWARN_ERR=2, VWARN_OTHER=3 }


decompiled_code:
int __fastcall warn_show_line_part(const char *a1, int a2, unsigned int a3)
{
const char *v3; // rbp
int v4; // er12
int v6; // ebx
int v7; // eax
int v8; // ebx
int v9; // ecx
const char *v10; // r8
int v11; // edx
int v12; // eax
int v13; // ebp
int v14; // ebp
int v15; // ebx

v3 = a1;
v4 = a2;
v6 = warning_length;
if ( warning_length <= 0 )
{
v8 = 0x7FFFFFFF;
LABEL_20:
v10 = (const char *)&unk_715;
goto LABEL_21;
}
v7 = strlen(a1);
v8 = v6 - 10;
if ( v8 <= 0 )
v8 = 1;
if ( v8 >= v7 )
goto LABEL_20;
if ( v8 > a2 )
{
v11 = 0;
}
else
{
v9 = a2 - v8 / 2;
v3 = &a1[v9];
v4 = v8 / 2;
if ( v8 >= v7 - v9 )
{
v10 = (const char *)&unk_715;
LABEL_11:
fprintf(stderr, " %s\"%s\"%s\n", "...", v3, v10);
v12 = v4 + 3;
v13 = 3;
goto LABEL_12;
}
v11 = 1;
}
v3[v8] = 0;
v10 = "...";
if ( v11 )
goto LABEL_11;
LABEL_21:
fprintf(stderr, " %s\"%s\"%s\n", (const char *)&unk_715, v3, v10);
v12 = v4 + 3;
v13 = 0;
LABEL_12:
v14 = v12 + v13;
if ( v14 > 0 )
{
do
{
fputc(32, stderr);
--v14;
}
while ( v14 );
}
fputc(94, stderr);
v15 = v8 - v4;
if ( v15 > a3 )
v15 = a3;
if ( v15 > 1 )
{
do
{
fputc(126, stderr);
--v15;
}
while ( v15 != 1 );
}
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func2(const char *a1, int a2, unsigned int a3)
{
const char *v3; // rbp
int v4; // er12
int v6; // ebx
int v7; // eax
int v8; // ebx
int v9; // ecx
const char *v10; // r8
int v11; // edx
int v12; // eax
int v13; // ebp
int v14; // ebp
int v15; // ebx

v3 = a1;
v4 = a2;
v6 = warning_length;
if ( warning_length <= 0 )
{
v8 = 0x7FFFFFFF;
LABEL_20:
v10 = (const char *)&unk_715;
goto LABEL_21;
}
v7 = strlen(a1);
v8 = v6 - 10;
if ( v8 <= 0 )
v8 = 1;
if ( v8 >= v7 )
goto LABEL_20;
if ( v8 > a2 )
{
v11 = 0;
}
else
{
v9 = a2 - v8 / 2;
v3 = &a1[v9];
v4 = v8 / 2;
if ( v8 >= v7 - v9 )
{
v10 = (const char *)&unk_715;
LABEL_11:
fprintf(stderr, " %s\"%s\"%s\n", "...", v3, v10);
v12 = v4 + 3;
v13 = 3;
goto LABEL_12;
}
v11 = 1;
}
v3[v8] = 0;
v10 = "...";
if ( v11 )
goto LABEL_11;
LABEL_21:
fprintf(stderr, " %s\"%s\"%s\n", (const char *)&unk_715, v3, v10);
v12 = v4 + 3;
v13 = 0;
LABEL_12:
v14 = v12 + v13;
if ( v14 > 0 )
{
do
{
fputc(32, stderr);
--v14;
}
while ( v14 );
}
fputc(94, stderr);
v15 = v8 - v4;
if ( v15 > a3 )
v15 = a3;
if ( v15 > 1 )
{
do
{
fputc(126, stderr);
--v15;
}
while ( v15 != 1 );
}
return fputc(10, stderr);
}

original_code:
static void warn_show_line_part(char *line, int pos, unsigned wlen)
{
 int len = strlen(line);
 int i;
 struct { int start, end; } dotdot = { 0, 0 };
 int warning_length_normalise = 0x7fffffff;
 if(warning_length > 0){
  warning_length_normalise = warning_length - 10;
  if(warning_length_normalise <= 0)
   warning_length_normalise = 1;
  if(len > warning_length_normalise){
   if(pos >= warning_length_normalise){
    dotdot.start = 1;
    line += pos - warning_length_normalise / 2;
    len -= pos - warning_length_normalise / 2;
    pos = warning_length_normalise / 2;
   }
   if(len > warning_length_normalise){
    dotdot.end = 1;
    line[warning_length_normalise] = '\0';
   }
  }
 }
 fprintf(stderr, "  %s\"%s\"%s\n",
   dotdot.start ? "..." : "",
   line,
   dotdot.end ? "..." : "");
 for(i = pos + 3 + (dotdot.start ? 3 : 0); i > 0; i--)
  fputc(' ', stderr);
 fputc('^', stderr);
 for(i = ((wlen) > ((unsigned)(warning_length_normalise - pos)) ? ((unsigned)(warning_length_normalise - pos)) : (wlen));
   i > 1;
   i--)
  fputc('~', stderr);
 fputc('\n', stderr);
}

canonical_original_code:
static void warn_show_line_part(char *line, int pos, unsigned int wlen)
{
 int len = strlen(line);
 int i;
 struct { int start; } dotdot = { 0, 0 };
 int warning_length_normalise = 0x7fffffff;
 if(warning_length > 0){
  warning_length_normalise = warning_length - 10;
  if(warning_length_normalise <= 0)
   warning_length_normalise = 1;
  if(len > warning_length_normalise){
   if(pos >= warning_length_normalise){
    dotdot.start = 1;
    line += pos - warning_length_normalise / 2;
    len -= pos - warning_length_normalise / 2;
    pos = warning_length_normalise / 2;
   }
   if(len > warning_length_normalise){
    dotdot.end = 1;
    line[warning_length_normalise] = '\0';
   }
  }
 }
 fprintf(stderr, "  %s\"%s\"%s\n",
   dotdot.start ? "..." : "",
   line,
   dotdot.end ? "..." : "");
 for(i = pos + 3 + (dotdot.start ? 3 : 0); i > 0; i--)
  fputc(' ', stderr);
 fputc('^', stderr);
 for(i = ((wlen) > ((unsigned int)(warning_length_normalise - pos)) ? ((unsigned int)(warning_length_normalise - pos)) : (wlen));
   i > 1;
   i--)
  fputc('~', stderr);
 fputc('\n', stderr);
}

variable_types:
line
char *

variable_types: pos int

variable_types:
wlen
unsigned int

variable_types: len int

variable_types:
dotdot
struct { int start; }


decompiled_code:
void __fastcall warn_show_line(__int64 a1)
{
char *v2; // rbp
char v3; // al
char *v4; // rdx
const char *v5; // rdi

if ( show_current_line && *(_QWORD *)(a1 + 8) )
{
v2 = (char *)ustrdup();
if ( !buffed_0 )
{
setvbuf(stderr, 0LL, 1, 0LL);
buffed_0 = 1;
}
v3 = *v2;
if ( *v2 )
{
v4 = v2;
v5 = 0LL;
do
{
if ( v3 == 9 )
{
*v4 = 32;
}
else if ( v3 != 32 && !v5 )
{
v5 = v4;
}
v3 = *++v4;
}
while ( *v4 );
if ( !v5 )
v5 = v2;
}
else
{
v5 = v2;
}
warn_show_line_part(v5, *(unsigned __int16 *)(a1 + 20) - ((_DWORD)v5 - (_DWORD)v2), *(unsigned __int16 *)(a1 + 22));
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
char *v2; // rbp
char v3; // al
char *v4; // rdx
const char *v5; // rdi

if ( show_current_line && *(_QWORD *)(a1 + 8) )
{
v2 = (char *)ustrdup();
if ( !buffed_0 )
{
setvbuf(stderr, 0LL, 1, 0LL);
buffed_0 = 1;
}
v3 = *v2;
if ( *v2 )
{
v4 = v2;
v5 = 0LL;
do
{
if ( v3 == 9 )
{
*v4 = 32;
}
else if ( v3 != 32 && !v5 )
{
v5 = v4;
}
v3 = *++v4;
}
while ( *v4 );
if ( !v5 )
v5 = v2;
}
else
{
v5 = v2;
}
func2(v5, *(unsigned __int16 *)(a1 + 20) - ((_DWORD)v5 - (_DWORD)v2), *(unsigned __int16 *)(a1 + 22));
free(v2);
}
}

original_code:
static void warn_show_line(const struct where *w)
{
 extern int show_current_line;
 if(show_current_line && w->line_str){
  static int buffed = 0;
  char *line = ustrdup(w->line_str);
  char *p, *nonblank;
  if(!buffed){
   setvbuf(stderr, ((void *)0), 1, 0);
   buffed = 1;
  }
  nonblank = ((void *)0);
  for(p = line; *p; p++)
   switch(*p){
    case '\t':
     *p = ' ';
    case ' ':
     break;
    default:
     if(!nonblank)
      nonblank = p;
   }
  if(!nonblank)
   nonblank = line;
  warn_show_line_part(nonblank, w->chr - (nonblank - line), w->len);
  free(line);
 }
}

canonical_original_code:
static void warn_show_line(struct where *w)
{
 extern int show_current_line;
 if(show_current_line && w->line_str){
  static int buffed = 0;
  char *line = ustrdup(w->line_str);
  char *p; char *nonblank;
  if(!buffed){
   setvbuf(stderr, ((void *)0), 1, 0);
   buffed = 1;
  }
  nonblank = ((void *)0);
  for(p = line; *p; p++)
   switch(*p){
    case '\t':
     *p = ' ';
    case ' ':
     break;
    default:
     if(!nonblank)
      nonblank = p;
   }
  if(!nonblank)
   nonblank = line;
  warn_show_line_part(nonblank, w->chr - (nonblank - line), w->len);
  free(line);
 }
}

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

variable_types: buffed int

variable_types:
p
char *

variable_types:
nonblank
char *


decompiled_code:
void __fastcall warn_colour(int a1, unsigned int a2)
{
char *v2; // rax

if ( is_tty_1 == 2 )
is_tty_1 = colour_enabled(2LL);
if ( is_tty_1 )
{
if ( a1 )
{
v2 = vwarn_colour(a2);
fputs(v2, stderr);
}
else
{
fwrite("\x1B[m", 1uLL, 3uLL, stderr);
}
}
}

canonical_decompiled_code:
void __fastcall func4(int a1, unsigned int a2)
{
char *v2; // rax

if ( is_tty_1 == 2 )
is_tty_1 = colour_enabled(2LL);
if ( is_tty_1 )
{
if ( a1 )
{
v2 = func0(a2);
fputs(v2, stderr);
}
else
{
fwrite("\x1B[m", 1uLL, 3uLL, stderr);
}
}
}

original_code:
void warn_colour(int on, enum warn_type ty)
{
 static enum { f = 0, t = 1, need_init = 2 } is_tty = need_init;
 if(is_tty == need_init)
  is_tty = colour_enabled(2);
 if(is_tty){
  if(on)
   fputs(vwarn_colour(ty), stderr);
  else
   fprintf(stderr, "\033[m");
 }
}

canonical_original_code:
void warn_colour(int on, enum warn_type ty)
{
 static enum { f=0, t=1, need_init=2 } is_tty = need_init;
 if(is_tty == need_init)
  is_tty = colour_enabled(2);
 if(is_tty){
  if(on)
   fputs(vwarn_colour(ty), stderr);
  else
   fprintf(stderr, "\033[m");
 }
}

variable_types: on int


vwarn

decompiled_code:
void __fastcall vwarn(__int64 a1, unsigned int a2, const char *a3, void *a4)
{
__int64 v6; // r12
const char *v7; // rax
const char *v8; // rax

include_bt(stderr);
v6 = default_where(a1);
warn_colour(1, 3u);
v7 = (const char *)where_str(v6);
fprintf(stderr, "%s: ", v7);
warn_colour(1, a2);
v8 = vwarn_str(a2);
fprintf(stderr, "%s: ", v8);
warn_colour(0, a2);
vfprintf(stderr, a3, a4);
++warning_count;
if ( *a3 && a3[strlen(a3) - 1] == 58 )
{
fputc(32, stderr);
perror(0LL);
}
else
{
fputc(10, stderr);
}
warn_show_line(v6);
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, unsigned int a2, const char *a3, void *a4)
{
__int64 v6; // r12
const char *v7; // rax
const char *v8; // rax

include_bt(stderr);
v6 = default_where(a1);
func4(1, 3u);
v7 = (const char *)where_str(v6);
fprintf(stderr, "%s: ", v7);
func4(1, a2);
v8 = func1(a2);
fprintf(stderr, "%s: ", v8);
func4(0, a2);
vfprintf(stderr, a3, a4);
++warning_count;
if ( *a3 && a3[strlen(a3) - 1] == 58 )
{
fputc(32, stderr);
perror(0LL);
}
else
{
fputc(10, stderr);
}
func3(v6);
}

original_code:
void vwarn(const struct where *w, enum warn_type ty,
  const char *fmt, va_list l)
{
 include_bt(stderr);
 w = default_where(w);
 warn_colour(1, VWARN_OTHER);
 fprintf(stderr, "%s: ", where_str(w));
 warn_colour(1, ty);
 fprintf(stderr, "%s: ", vwarn_str(ty));
 warn_colour(0, ty);
 vfprintf(stderr, fmt, l);
 warning_count++;
 if(*fmt && fmt[strlen(fmt)-1] == ':'){
  fputc(' ', stderr);
  perror(((void *)0));
 }else{
  fputc('\n', stderr);
 }
 warn_show_line(w);
}

canonical_original_code:
void vwarn(struct where *w, enum warn_type ty, char *fmt, __builtin_va_list l)
{
 include_bt(stderr);
 w = default_where(w);
 warn_colour(1, VWARN_OTHER);
 fprintf(stderr, "%s: ", where_str(w));
 warn_colour(1, ty);
 fprintf(stderr, "%s: ", vwarn_str(ty));
 warn_colour(0, ty);
 vfprintf(stderr, fmt, l);
 warning_count++;
 if(*fmt && fmt[strlen(fmt)-1] == ':'){
  fputc(' ', stderr);
  perror(((void *)0));
 }else{
  fputc('\n', stderr);
 }
 warn_show_line(w);
}

variable_types:
fmt
char *

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


decompiled_code:
void warn_at_print_error(__int64 a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
vwarn(a1, 2u, a2, va);
}

canonical_decompiled_code:
void func6(__int64 a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
func5(a1, 2u, a2, va);
}

original_code:
void warn_at_print_error(const struct where *w, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 vwarn(w, VWARN_ERR, fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void warn_at_print_error(struct where *w, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 vwarn(w, VWARN_ERR, fmt, l);
 __builtin_va_end(l);
}


vdie

decompiled_code:
void __fastcall __noreturn vdie(__int64 a1, const char *a2, void *a3)
{
vwarn(a1, 2u, a2, a3);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(__int64 a1, const char *a2, void *a3)
{
func5(a1, 2u, a2, a3);
exit(1);
}

original_code:
void vdie(const struct where *w, const char *fmt, va_list l)
{
 vwarn(w, VWARN_ERR, fmt, l);
 exit(1);
}

canonical_original_code:
void vdie(struct where *w, char *fmt, __builtin_va_list l)
{
 vwarn(w, VWARN_ERR, fmt, l);
 exit(1);
}


decompiled_code:
void note_at(__int64 a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
vwarn(a1, 0, a2, va);
}

canonical_decompiled_code:
void func8(__int64 a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
func5(a1, 0, a2, va);
}

original_code:
void note_at(const struct where *w, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 vwarn(w, VWARN_NOTE, fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void note_at(struct where *w, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 vwarn(w, VWARN_NOTE, fmt, l);
 __builtin_va_end(l);
}


decompiled_code:
void warn_at(__int64 a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
vwarn(a1, 1u, a2, va);
}

canonical_decompiled_code:
void func9(__int64 a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
func5(a1, 1u, a2, va);
}

original_code:
void warn_at(const struct where *w, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 vwarn(w, VWARN_WARN, fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void warn_at(struct where *w, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 vwarn(w, VWARN_WARN, fmt, l);
 __builtin_va_end(l);
}


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

va_start(va, a2);
vdie(a1, a2, va);
}

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

va_start(va, a2);
func7(a1, a2, va);
}

original_code:
void die_at(const struct where *w, const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 vdie(w, fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void die_at(struct where *w, char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 vdie(w, fmt, l);
 __builtin_va_end(l);
}


die

decompiled_code:
void __noreturn die(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
vdie(0LL, a1, va);
}

canonical_decompiled_code:
void __noreturn func11(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func7(0LL, a1, va);
}

original_code:
void die(const char *fmt, ...)
{
 va_list l;
 __builtin_va_start(l,fmt);
 vdie(((void *)0), fmt, l);
 __builtin_va_end(l);
}

canonical_original_code:
void die(char *fmt, ...)
{
 __builtin_va_list l;
 __builtin_va_start(l,fmt);
 vdie(((void *)0), fmt, l);
 __builtin_va_end(l);
}


decompiled_code:
char *__fastcall where_str_r(char *a1, __int64 a2)
{
snprintf(
a1,
0x80uLL,
"%s:%d:%d",
*(const char **)a2,
*(unsigned int *)(a2 + 16),
(unsigned int)*(unsigned __int16 *)(a2 + 20) + 1);
return a1;
}

canonical_decompiled_code:
char *__fastcall func0(char *a1, __int64 a2)
{
snprintf(
a1,
0x80uLL,
"%s:%d:%d",
*(const char **)a2,
*(unsigned int *)(a2 + 16),
(unsigned int)*(unsigned __int16 *)(a2 + 20) + 1);
return a1;
}

original_code:
const char *where_str_r(char buf[128], const struct where *w)
{
 snprintf(buf, 128, "%s:%d:%d", w->fname, w->line, w->chr + 1);
 return buf;
}

canonical_original_code:
char *where_str_r(char buf[128], struct where *w)
{
 snprintf(buf, 128, "%s:%d:%d", w->fname, w->line, w->chr + 1);
 return buf;
}

variable_types:
buf
char [128]


decompiled_code:
char *__fastcall where_str(__int64 a1)
{
return where_str_r(buf_1, a1);
}

canonical_decompiled_code:
char *__fastcall func1(__int64 a1)
{
return func0(buf_1, a1);
}

original_code:
const char *where_str(const struct where *w)
{
 static char buf[128];
 return where_str_r(buf, w);
}

canonical_original_code:
char *where_str(struct where *w)
{
 static char buf[128];
 return where_str_r(buf, w);
}


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

*(_QWORD *)a1 = current_fname;
*(_DWORD *)(a1 + 16) = loc_tok;
*(_WORD *)(a1 + 20) = *((_DWORD *)&loc_tok + 1);
result = current_line_str;
*(_QWORD *)(a1 + 8) = current_line_str;
*(_WORD *)(a1 + 22) = 0;
*(_BYTE *)(a1 + 24) = 0;
return result;
}

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

*(_QWORD *)a1 = current_fname;
*(_DWORD *)(a1 + 16) = loc_tok;
*(_WORD *)(a1 + 20) = *((_DWORD *)&loc_tok + 1);
result = current_line_str;
*(_QWORD *)(a1 + 8) = current_line_str;
*(_WORD *)(a1 + 22) = 0;
*(_BYTE *)(a1 + 24) = 0;
return result;
}

original_code:
void where_current(where *w)
{
 extern struct loc loc_tok;
 extern const char *current_fname, *current_line_str;
 w->fname = current_fname;
 w->line = loc_tok.line;
 w->chr = loc_tok.chr;
 w->line_str = current_line_str;
 w->len = 0;
 w->is_sysh = 0;
}

canonical_original_code:
void where_current(struct where *w)
{
 extern struct loc loc_tok;
 extern char *current_fname; extern char *current_line_str;
 w->fname = current_fname;
 w->line = loc_tok.line;
 w->chr = loc_tok.chr;
 w->line_str = current_line_str;
 w->len = 0;
 w->is_sysh = 0;
}


decompiled_code:
_BOOL8 __fastcall where_equal(const void *a1, const void *a2)
{
return memcmp(a1, a2, 0x20uLL) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(const void *a1, const void *a2)
{
return memcmp(a1, a2, 0x20uLL) == 0;
}

original_code:
int where_equal(where *a, where *b)
{
 return memcmp(a, b, sizeof *a) == 0;
}

canonical_original_code:
int where_equal(struct where *a, struct where *b)
{
 return memcmp(a, b, sizeof *a) == 0;
}

variable_types:
b
struct where *


decompiled_code:
_BOOL8 __fastcall has_builtin(char *s2)
{
_BOOL4 v1; // edx

v1 = 1;
if ( strcmp("__builtin_offsetof", s2)
&& strcmp("__builtin_unreachable", s2)
&& strcmp("__builtin_trap", s2)
&& strcmp("__builtin_debugtrap", s2)
&& strcmp("__builtin_types_compatible_p", s2)
&& strcmp("__builtin_constant_p", s2)
&& strcmp("__builtin_frame_address", s2)
&& strcmp("__builtin_return_address", s2)
&& strcmp("__builtin_extract_return_addr", s2)
&& strcmp("__builtin_expect", s2)
&& strcmp("__builtin_is_signed", s2)
&& strcmp("__builtin_nan", s2)
&& strcmp("__builtin_nanf", s2)
&& strcmp("__builtin_nanl", s2)
&& strcmp("__builtin_choose_expr", s2)
&& strcmp("__builtin_has_attribute", s2)
&& strcmp("__builtin_add_overflow", s2) )
{
if ( !strcmp("__builtin_sub_overflow", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_mul_overflow", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_va_start", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_va_arg", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_va_end", s2) )
{
v1 = 1;
}
else
{
v1 = strcmp("__builtin_va_copy", s2) == 0;
}
}
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *s2)
{
_BOOL4 v1; // edx

v1 = 1;
if ( strcmp("__builtin_offsetof", s2)
&& strcmp("__builtin_unreachable", s2)
&& strcmp("__builtin_trap", s2)
&& strcmp("__builtin_debugtrap", s2)
&& strcmp("__builtin_types_compatible_p", s2)
&& strcmp("__builtin_constant_p", s2)
&& strcmp("__builtin_frame_address", s2)
&& strcmp("__builtin_return_address", s2)
&& strcmp("__builtin_extract_return_addr", s2)
&& strcmp("__builtin_expect", s2)
&& strcmp("__builtin_is_signed", s2)
&& strcmp("__builtin_nan", s2)
&& strcmp("__builtin_nanf", s2)
&& strcmp("__builtin_nanl", s2)
&& strcmp("__builtin_choose_expr", s2)
&& strcmp("__builtin_has_attribute", s2)
&& strcmp("__builtin_add_overflow", s2) )
{
if ( !strcmp("__builtin_sub_overflow", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_mul_overflow", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_va_start", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_va_arg", s2) )
{
v1 = 1;
}
else if ( !strcmp("__builtin_va_end", s2) )
{
v1 = 1;
}
else
{
v1 = strcmp("__builtin_va_copy", s2) == 0;
}
}
return v1;
}

original_code:
static int has_builtin(const char *nam)
{
 if(!strcmp("__builtin_" "offsetof", nam)) return 1; if(!strcmp("__builtin_" "unreachable", nam)) return 1; if(!strcmp("__builtin_" "trap", nam)) return 1; if(!strcmp("__builtin_" "debugtrap", nam)) return 1; if(!strcmp("__builtin_" "types_compatible_p", nam)) return 1; if(!strcmp("__builtin_" "constant_p", nam)) return 1; if(!strcmp("__builtin_" "frame_address", nam)) return 1; if(!strcmp("__builtin_" "return_address", nam)) return 1; if(!strcmp("__builtin_" "extract_return_addr", nam)) return 1; if(!strcmp("__builtin_" "expect", nam)) return 1; if(!strcmp("__builtin_" "is_signed", nam)) return 1; if(!strcmp("__builtin_" "nan", nam)) return 1; if(!strcmp("__builtin_" "nanf", nam)) return 1; if(!strcmp("__builtin_" "nanl", nam)) return 1; if(!strcmp("__builtin_" "choose_expr", nam)) return 1; if(!strcmp("__builtin_" "has_attribute", nam)) return 1; if(!strcmp("__builtin_" "add_overflow", nam)) return 1; if(!strcmp("__builtin_" "sub_overflow", nam)) return 1; if(!strcmp("__builtin_" "mul_overflow", nam)) return 1; if(!strcmp("__builtin_" "va_start", nam)) return 1; if(!strcmp("__builtin_" "va_arg", nam)) return 1; if(!strcmp("__builtin_" "va_end", nam)) return 1; if(!strcmp("__builtin_" "va_copy", nam)) return 1;
 return 0;
}

canonical_original_code:
static int has_builtin(char *nam)
{
 if(!strcmp("__builtin_" "offsetof", nam)) return 1; if(!strcmp("__builtin_" "unreachable", nam)) return 1; if(!strcmp("__builtin_" "trap", nam)) return 1; if(!strcmp("__builtin_" "debugtrap", nam)) return 1; if(!strcmp("__builtin_" "types_compatible_p", nam)) return 1; if(!strcmp("__builtin_" "constant_p", nam)) return 1; if(!strcmp("__builtin_" "frame_address", nam)) return 1; if(!strcmp("__builtin_" "return_address", nam)) return 1; if(!strcmp("__builtin_" "extract_return_addr", nam)) return 1; if(!strcmp("__builtin_" "expect", nam)) return 1; if(!strcmp("__builtin_" "is_signed", nam)) return 1; if(!strcmp("__builtin_" "nan", nam)) return 1; if(!strcmp("__builtin_" "nanf", nam)) return 1; if(!strcmp("__builtin_" "nanl", nam)) return 1; if(!strcmp("__builtin_" "choose_expr", nam)) return 1; if(!strcmp("__builtin_" "has_attribute", nam)) return 1; if(!strcmp("__builtin_" "add_overflow", nam)) return 1; if(!strcmp("__builtin_" "sub_overflow", nam)) return 1; if(!strcmp("__builtin_" "mul_overflow", nam)) return 1; if(!strcmp("__builtin_" "va_start", nam)) return 1; if(!strcmp("__builtin_" "va_arg", nam)) return 1; if(!strcmp("__builtin_" "va_end", nam)) return 1; if(!strcmp("__builtin_" "va_copy", nam)) return 1;
 return 0;
}

variable_types:
nam
char *


decompiled_code:
_BOOL8 __fastcall has_attribute(char *s2)
{
_BOOL4 v1; // edx

v1 = 1;
if ( strcmp(s2, "format")
&& strcmp("__format__", s2)
&& strcmp(s2, "unused")
&& strcmp("__unused__", s2)
&& strcmp(s2, "used")
&& strcmp("__used__", s2)
&& strcmp(s2, "warn_unused")
&& strcmp("__warn_unused__", s2)
&& strcmp(s2, "section")
&& strcmp("__section__", s2)
&& strcmp(s2, "enum_bitmask")
&& strcmp("__enum_bitmask__", s2)
&& strcmp(s2, "flag_enum")
&& strcmp("__flag_enum__", s2)
&& strcmp(s2, "noreturn")
&& strcmp("__noreturn__", s2)
&& strcmp(s2, "noderef") )
{
if ( !strcmp("__noderef__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "nonnull") )
{
v1 = 1;
}
else if ( !strcmp("__nonnull__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "returns_nonnull") )
{
v1 = 1;
}
else if ( !strcmp("__returns_nonnull__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "packed") )
{
v1 = 1;
}
else if ( !strcmp("__packed__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "sentinel") )
{
v1 = 1;
}
else if ( !strcmp("__sentinel__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "aligned") )
{
v1 = 1;
}
else if ( !strcmp("__aligned__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "weak") )
{
v1 = 1;
}
else if ( !strcmp("__weak__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "alias") )
{
v1 = 1;
}
else if ( !strcmp("__alias__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "cleanup") )
{
v1 = 1;
}
else if ( !strcmp("__cleanup__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "always_inline") )
{
v1 = 1;
}
else if ( !strcmp("__always_inline__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "noinline") )
{
v1 = 1;
}
else if ( !strcmp("__noinline__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "flatten") )
{
v1 = 1;
}
else if ( !strcmp("__flatten__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "constructor") )
{
v1 = 1;
}
else if ( !strcmp("__constructor__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "destructor") )
{
v1 = 1;
}
else if ( !strcmp("__destructor__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "visibility") )
{
v1 = 1;
}
else if ( !strcmp("__visibility__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "stack_protect") )
{
v1 = 1;
}
else if ( !strcmp("__stack_protect__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "no_stack_protector") )
{
v1 = 1;
}
else if ( !strcmp("__no_stack_protector__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "no_sanitize") )
{
v1 = 1;
}
else if ( !strcmp("__no_sanitize__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "fallthrough") )
{
v1 = 1;
}
else if ( !strcmp("__fallthrough__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "designated_init") )
{
v1 = 1;
}
else if ( !strcmp("__designated_init__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "__ucc_debug") )
{
v1 = 1;
}
else if ( !strcmp("____ucc_debug__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "__cdecl") )
{
v1 = 1;
}
else if ( !strcmp("____cdecl__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "warn_unused_result") )
{
v1 = 1;
}
else if ( !strcmp("__warn_unused_result__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "cdecl") )
{
v1 = 1;
}
else if ( !strcmp("__cdecl__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "stdcall") )
{
v1 = 1;
}
else if ( !strcmp("__stdcall__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "fastcall") )
{
v1 = 1;
}
else if ( !strcmp("__fastcall__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "no_sanitize_undefined") )
{
v1 = 1;
}
else
{
v1 = strcmp("__no_sanitize_undefined__", s2) == 0;
}
}
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(char *s2)
{
_BOOL4 v1; // edx

v1 = 1;
if ( strcmp(s2, "format")
&& strcmp("__format__", s2)
&& strcmp(s2, "unused")
&& strcmp("__unused__", s2)
&& strcmp(s2, "used")
&& strcmp("__used__", s2)
&& strcmp(s2, "warn_unused")
&& strcmp("__warn_unused__", s2)
&& strcmp(s2, "section")
&& strcmp("__section__", s2)
&& strcmp(s2, "enum_bitmask")
&& strcmp("__enum_bitmask__", s2)
&& strcmp(s2, "flag_enum")
&& strcmp("__flag_enum__", s2)
&& strcmp(s2, "noreturn")
&& strcmp("__noreturn__", s2)
&& strcmp(s2, "noderef") )
{
if ( !strcmp("__noderef__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "nonnull") )
{
v1 = 1;
}
else if ( !strcmp("__nonnull__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "returns_nonnull") )
{
v1 = 1;
}
else if ( !strcmp("__returns_nonnull__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "packed") )
{
v1 = 1;
}
else if ( !strcmp("__packed__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "sentinel") )
{
v1 = 1;
}
else if ( !strcmp("__sentinel__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "aligned") )
{
v1 = 1;
}
else if ( !strcmp("__aligned__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "weak") )
{
v1 = 1;
}
else if ( !strcmp("__weak__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "alias") )
{
v1 = 1;
}
else if ( !strcmp("__alias__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "cleanup") )
{
v1 = 1;
}
else if ( !strcmp("__cleanup__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "always_inline") )
{
v1 = 1;
}
else if ( !strcmp("__always_inline__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "noinline") )
{
v1 = 1;
}
else if ( !strcmp("__noinline__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "flatten") )
{
v1 = 1;
}
else if ( !strcmp("__flatten__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "constructor") )
{
v1 = 1;
}
else if ( !strcmp("__constructor__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "destructor") )
{
v1 = 1;
}
else if ( !strcmp("__destructor__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "visibility") )
{
v1 = 1;
}
else if ( !strcmp("__visibility__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "stack_protect") )
{
v1 = 1;
}
else if ( !strcmp("__stack_protect__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "no_stack_protector") )
{
v1 = 1;
}
else if ( !strcmp("__no_stack_protector__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "no_sanitize") )
{
v1 = 1;
}
else if ( !strcmp("__no_sanitize__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "fallthrough") )
{
v1 = 1;
}
else if ( !strcmp("__fallthrough__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "designated_init") )
{
v1 = 1;
}
else if ( !strcmp("__designated_init__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "__ucc_debug") )
{
v1 = 1;
}
else if ( !strcmp("____ucc_debug__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "__cdecl") )
{
v1 = 1;
}
else if ( !strcmp("____cdecl__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "warn_unused_result") )
{
v1 = 1;
}
else if ( !strcmp("__warn_unused_result__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "cdecl") )
{
v1 = 1;
}
else if ( !strcmp("__cdecl__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "stdcall") )
{
v1 = 1;
}
else if ( !strcmp("__stdcall__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "fastcall") )
{
v1 = 1;
}
else if ( !strcmp("__fastcall__", s2) )
{
v1 = 1;
}
else if ( !strcmp(s2, "no_sanitize_undefined") )
{
v1 = 1;
}
else
{
v1 = strcmp("__no_sanitize_undefined__", s2) == 0;
}
}
return v1;
}

original_code:
static int has_attribute(const char *nam)
{
 if(!strcmp(nam, "format") || !strcmp("__" "format" "__", nam)) return 1; if(!strcmp(nam, "unused") || !strcmp("__" "unused" "__", nam)) return 1; if(!strcmp(nam, "used") || !strcmp("__" "used" "__", nam)) return 1; if(!strcmp(nam, "warn_unused") || !strcmp("__" "warn_unused" "__", nam)) return 1; if(!strcmp(nam, "section") || !strcmp("__" "section" "__", nam)) return 1; if(!strcmp(nam, "enum_bitmask") || !strcmp("__" "enum_bitmask" "__", nam)) return 1; if(!strcmp(nam, "flag_enum") || !strcmp("__" "flag_enum" "__", nam)) return 1; if(!strcmp(nam, "noreturn") || !strcmp("__" "noreturn" "__", nam)) return 1; if(!strcmp(nam, "noderef") || !strcmp("__" "noderef" "__", nam)) return 1; if(!strcmp(nam, "nonnull") || !strcmp("__" "nonnull" "__", nam)) return 1; if(!strcmp(nam, "returns_nonnull") || !strcmp("__" "returns_nonnull" "__", nam)) return 1; if(!strcmp(nam, "packed") || !strcmp("__" "packed" "__", nam)) return 1; if(!strcmp(nam, "sentinel") || !strcmp("__" "sentinel" "__", nam)) return 1; if(!strcmp(nam, "aligned") || !strcmp("__" "aligned" "__", nam)) return 1; if(!strcmp(nam, "weak") || !strcmp("__" "weak" "__", nam)) return 1; if(!strcmp(nam, "alias") || !strcmp("__" "alias" "__", nam)) return 1; if(!strcmp(nam, "cleanup") || !strcmp("__" "cleanup" "__", nam)) return 1; if(!strcmp(nam, "always_inline") || !strcmp("__" "always_inline" "__", nam)) return 1; if(!strcmp(nam, "noinline") || !strcmp("__" "noinline" "__", nam)) return 1; if(!strcmp(nam, "flatten") || !strcmp("__" "flatten" "__", nam)) return 1; if(!strcmp(nam, "constructor") || !strcmp("__" "constructor" "__", nam)) return 1; if(!strcmp(nam, "destructor") || !strcmp("__" "destructor" "__", nam)) return 1; if(!strcmp(nam, "visibility") || !strcmp("__" "visibility" "__", nam)) return 1; if(!strcmp(nam, "stack_protect") || !strcmp("__" "stack_protect" "__", nam)) return 1; if(!strcmp(nam, "no_stack_protector") || !strcmp("__" "no_stack_protector" "__", nam)) return 1; if(!strcmp(nam, "no_sanitize") || !strcmp("__" "no_sanitize" "__", nam)) return 1; if(!strcmp(nam, "fallthrough") || !strcmp("__" "fallthrough" "__", nam)) return 1; if(!strcmp(nam, "designated_init") || !strcmp("__" "designated_init" "__", nam)) return 1; if(!strcmp(nam, "__ucc_debug") || !strcmp("__" "__ucc_debug" "__", nam)) return 1; if(!strcmp(nam, "__cdecl") || !strcmp("__" "__cdecl" "__", nam)) return 1; if(!strcmp(nam, "warn_unused_result") || !strcmp("__" "warn_unused_result" "__", nam)) return 1; if(!strcmp(nam, "cdecl") || !strcmp("__" "cdecl" "__", nam)) return 1; if(!strcmp(nam, "stdcall") || !strcmp("__" "stdcall" "__", nam)) return 1; if(!strcmp(nam, "fastcall") || !strcmp("__" "fastcall" "__", nam)) return 1; if(!strcmp(nam, "no_sanitize_undefined") || !strcmp("__" "no_sanitize_undefined" "__", nam)) return 1;
 return 0;
}

canonical_original_code:
static int has_attribute(char *nam)
{
 if(!strcmp(nam, "format") || !strcmp("__" "format" "__", nam)) return 1; if(!strcmp(nam, "unused") || !strcmp("__" "unused" "__", nam)) return 1; if(!strcmp(nam, "used") || !strcmp("__" "used" "__", nam)) return 1; if(!strcmp(nam, "warn_unused") || !strcmp("__" "warn_unused" "__", nam)) return 1; if(!strcmp(nam, "section") || !strcmp("__" "section" "__", nam)) return 1; if(!strcmp(nam, "enum_bitmask") || !strcmp("__" "enum_bitmask" "__", nam)) return 1; if(!strcmp(nam, "flag_enum") || !strcmp("__" "flag_enum" "__", nam)) return 1; if(!strcmp(nam, "noreturn") || !strcmp("__" "noreturn" "__", nam)) return 1; if(!strcmp(nam, "noderef") || !strcmp("__" "noderef" "__", nam)) return 1; if(!strcmp(nam, "nonnull") || !strcmp("__" "nonnull" "__", nam)) return 1; if(!strcmp(nam, "returns_nonnull") || !strcmp("__" "returns_nonnull" "__", nam)) return 1; if(!strcmp(nam, "packed") || !strcmp("__" "packed" "__", nam)) return 1; if(!strcmp(nam, "sentinel") || !strcmp("__" "sentinel" "__", nam)) return 1; if(!strcmp(nam, "aligned") || !strcmp("__" "aligned" "__", nam)) return 1; if(!strcmp(nam, "weak") || !strcmp("__" "weak" "__", nam)) return 1; if(!strcmp(nam, "alias") || !strcmp("__" "alias" "__", nam)) return 1; if(!strcmp(nam, "cleanup") || !strcmp("__" "cleanup" "__", nam)) return 1; if(!strcmp(nam, "always_inline") || !strcmp("__" "always_inline" "__", nam)) return 1; if(!strcmp(nam, "noinline") || !strcmp("__" "noinline" "__", nam)) return 1; if(!strcmp(nam, "flatten") || !strcmp("__" "flatten" "__", nam)) return 1; if(!strcmp(nam, "constructor") || !strcmp("__" "constructor" "__", nam)) return 1; if(!strcmp(nam, "destructor") || !strcmp("__" "destructor" "__", nam)) return 1; if(!strcmp(nam, "visibility") || !strcmp("__" "visibility" "__", nam)) return 1; if(!strcmp(nam, "stack_protect") || !strcmp("__" "stack_protect" "__", nam)) return 1; if(!strcmp(nam, "no_stack_protector") || !strcmp("__" "no_stack_protector" "__", nam)) return 1; if(!strcmp(nam, "no_sanitize") || !strcmp("__" "no_sanitize" "__", nam)) return 1; if(!strcmp(nam, "fallthrough") || !strcmp("__" "fallthrough" "__", nam)) return 1; if(!strcmp(nam, "designated_init") || !strcmp("__" "designated_init" "__", nam)) return 1; if(!strcmp(nam, "__ucc_debug") || !strcmp("__" "__ucc_debug" "__", nam)) return 1; if(!strcmp(nam, "__cdecl") || !strcmp("__" "__cdecl" "__", nam)) return 1; if(!strcmp(nam, "warn_unused_result") || !strcmp("__" "warn_unused_result" "__", nam)) return 1; if(!strcmp(nam, "cdecl") || !strcmp("__" "cdecl" "__", nam)) return 1; if(!strcmp(nam, "stdcall") || !strcmp("__" "stdcall" "__", nam)) return 1; if(!strcmp(nam, "fastcall") || !strcmp("__" "fastcall" "__", nam)) return 1; if(!strcmp(nam, "no_sanitize_undefined") || !strcmp("__" "no_sanitize_undefined" "__", nam)) return 1;
 return 0;
}


decompiled_code:
__int64 __fastcall has_extension(char *a1)
{
return has_feat_ext(a1, 1);
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1)
{
return func2(a1, 1);
}

original_code:
static int has_extension(const char *nam)
{
 return has_feat_ext(nam, 1);
}

canonical_original_code:
static int has_extension(char *nam)
{
 return has_feat_ext(nam, 1);
}


decompiled_code:
__int64 __fastcall has_feature(char *a1)
{
return has_feat_ext(a1, 0);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
return func2(a1, 0);
}

original_code:
static int has_feature(const char *nam)
{
 return has_feat_ext(nam, 0);
}

canonical_original_code:
static int has_feature(char *nam)
{
 return has_feat_ext(nam, 0);
}


decompiled_code:
__int64 __fastcall has_func(const char *a1, __int64 a2)
{
const char *v2; // rbp
char **v4; // rbx
const char *v5; // rdi

v2 = a1;
if ( !memcmp(a1, "__has_", 6uLL) )
v2 += 6;
v4 = &has_tbl;
v5 = "feature";
while ( strcmp(v5, v2) )
{
v4 += 2;
v5 = *v4;
if ( !*v4 )
return 0xFFFFFFFFLL;
}
return ((__int64 (__fastcall *)(__int64))v4[1])(a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, __int64 a2)
{
const char *v2; // rbp
char **v4; // rbx
const char *v5; // rdi

v2 = a1;
if ( !memcmp(a1, "__has_", 6uLL) )
v2 += 6;
v4 = &has_tbl;
v5 = "feature";
while ( strcmp(v5, v2) )
{
v4 += 2;
v5 = *v4;
if ( !*v4 )
return 0xFFFFFFFFLL;
}
return ((__int64 (__fastcall *)(__int64))v4[1])(a2);
}

original_code:
int has_func(const char *fn, const char *arg1)
{
 const struct has_tbl *p;
 if(!strncmp(fn, "__has_", 6))
  fn += 6;
 for(p = has_tbl; p->nam; p++)
  if(!strcmp(p->nam, fn))
   return p->handler(arg1);
 return -1;
}

canonical_original_code:
int has_func(char *fn, char *arg1)
{
 struct has_tbl *p;
 if(!strncmp(fn, "__has_", 6))
  fn += 6;
 for(p = has_tbl; p->nam; p++)
  if(!strcmp(p->nam, fn))
   return p->handler(arg1);
 return -1;
}

variable_types:
fn
char *

variable_types: struct has_tbl { char *nam; int (*handler)(char *nam); } *


bname

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

result = strrchr(a1, 47);
if ( result )
result[1] = 0;
return result;
}

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

result = strrchr(a1, 47);
if ( result )
result[1] = 0;
return result;
}

original_code:
static void bname(char *path)
{
 char *p = strrchr(path, '/');
 if(p)
  p[1] = '\0';
}

variable_types:
path
char *


decompiled_code:
char *__fastcall path_prepend(const char *a1, const char *a2)
{
size_t v2; // rbx
size_t v3; // rax
char *v4; // rbx

v2 = strlen(a1);
v3 = strlen(a2);
v4 = (char *)umalloc(v2 + v3 + 2);
sprintf(v4, "%s/%s", a1, a2);
return v4;
}

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

v2 = strlen(a1);
v3 = strlen(a2);
v4 = (char *)umalloc(v2 + v3 + 2);
sprintf(v4, "%s/%s", a1, a2);
return v4;
}

original_code:
static char *path_prepend(const char *pre, const char *path)
{
 char *buf = umalloc(strlen(pre) + strlen(path) + 2);
 sprintf(buf, "%s/%s", pre, path);
 return buf;
}

canonical_original_code:
static char *path_prepend(char *pre, char *path)
{
 char *buf = umalloc(strlen(pre) + strlen(path) + 2);
 sprintf(buf, "%s/%s", pre, path);
 return buf;
}

variable_types:
pre
char *

variable_types:
buf
char *


decompiled_code:
char *dirname_ucc()
{
ssize_t v1; // rax
char *v2; // rbx
char v3[1032]; // [rsp+0h] [rbp-408h] BYREF

if ( where_0 )
return &where_0;
v1 = readlink(argv0, v3, 0x400uLL);
if ( v1 == -1 )
{
snprintf(&where_0, 0x400uLL, "%s", argv0);
}
else
{
v3[v1] = 0;
v2 = (char *)ustrdup(argv0);
bname(v2);
snprintf(&where_0, 0x400uLL, "%s/%s", v2, v3);
free(v2);
}
bname(&where_0);
return &where_0;
}

canonical_decompiled_code:
char *func2()
{
ssize_t v1; // rax
char *v2; // rbx
char v3[1032]; // [rsp+0h] [rbp-408h] BYREF

if ( where_0 )
return &where_0;
v1 = readlink(argv0, v3, 0x400uLL);
if ( v1 == -1 )
{
snprintf(&where_0, 0x400uLL, "%s", argv0);
}
else
{
v3[v1] = 0;
v2 = (char *)ustrdup(argv0);
func0(v2);
snprintf(&where_0, 0x400uLL, "%s/%s", v2, v3);
free(v2);
}
func0(&where_0);
return &where_0;
}

original_code:
char *dirname_ucc(void)
{
 static char where[1024];
 if(!where[0]){
  char link[1024];
  ssize_t nb;
  if((nb = readlink(argv0, link, sizeof link)) == -1){
   snprintf(where, sizeof where, "%s", argv0);
  }else{
   char *argv_dup;
   link[nb] = '\0';
   argv_dup = ustrdup(argv0);
   bname(argv_dup);
   snprintf(where, sizeof where, "%s/%s", argv_dup, link);
   free(argv_dup);
  }
  bname(where);
 }
 return where;
}

canonical_original_code:
char *dirname_ucc()
{
 static char where[1024];
 if(!where[0]){
  char link[1024];
  long nb;
  if((nb = readlink(argv0, link, sizeof link)) == -1){
   snprintf(where, sizeof where, "%s", argv0);
  }else{
   char *argv_dup;
   link[nb] = '\0';
   argv_dup = ustrdup(argv0);
   bname(argv_dup);
   snprintf(where, sizeof where, "%s/%s", argv_dup, link);
   free(argv_dup);
  }
  bname(where);
 }
 return where;
}

variable_types:
where
char [1024]

variable_types:
link
char [1024]

variable_types: nb long


decompiled_code:
char *__fastcall path_prepend_relative_nofree(const char *a1)
{
char *v1; // rax

v1 = dirname_ucc();
return path_prepend(v1, a1);
}

canonical_decompiled_code:
char *__fastcall func3(const char *a1)
{
char *v1; // rax

v1 = func2();
return func1(v1, a1);
}

original_code:
static char *path_prepend_relative_nofree(const char *path)
{
 return path_prepend(dirname_ucc(), path);
}

canonical_original_code:
static char *path_prepend_relative_nofree(char *path)
{
 return path_prepend(dirname_ucc(), path);
}


decompiled_code:
char *__fastcall path_prepend_relative(void *ptr)
{
char *v1; // rbp

v1 = path_prepend_relative_nofree((const char *)ptr);
free(ptr);
return v1;
}

canonical_decompiled_code:
char *__fastcall func4(void *ptr)
{
char *v1; // rbp

v1 = func3((const char *)ptr);
free(ptr);
return v1;
}

original_code:
char *path_prepend_relative(char *path)
{
 char *r = path_prepend_relative_nofree(path);
 free(path);
 return r;
}

variable_types:
r
char *


decompiled_code:
char *__fastcall cmdpath_resolve(const char **a1, int (***a2)(const char *file, char *const argv[]))
{
int v2; // eax
char *result; // rax

v2 = *((_DWORD *)a1 + 2);
if ( v2 == 1 )
{
if ( a2 )
*a2 = &execvp;
result = (char *)ustrdup(*a1);
}
else if ( v2 == 2 )
{
if ( a2 )
*a2 = &execv;
result = path_prepend(Bprefix, *a1);
}
else if ( v2 )
{
result = 0LL;
}
else
{
if ( a2 )
*a2 = &execv;
result = path_prepend_relative_nofree(*a1);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func5(const char **a1, int (***a2)(const char *file, char *const argv[]))
{
int v2; // eax
char *result; // rax

v2 = *((_DWORD *)a1 + 2);
if ( v2 == 1 )
{
if ( a2 )
*a2 = &execvp;
result = (char *)ustrdup(*a1);
}
else if ( v2 == 2 )
{
if ( a2 )
*a2 = &execv;
result = func1(Bprefix, *a1);
}
else if ( v2 )
{
result = 0LL;
}
else
{
if ( a2 )
*a2 = &execv;
result = func3(*a1);
}
return result;
}

original_code:
char *cmdpath_resolve(const struct cmdpath *p, cmdpath_exec_fn **fn)
{
 switch(p->type){
  case USE_PATH:
   if(fn) *fn = execvp;
   return ustrdup(p->path);
  case RELATIVE_TO_UCC:
   if(fn) *fn = execv;
   return path_prepend_relative_nofree(p->path);
  case FROM_Bprefix:
   if(fn) *fn = execv;
   return path_prepend(Bprefix, p->path);
 }
 return ((void *)0);
}

canonical_original_code:
char *cmdpath_resolve(struct cmdpath *p, int (**fn)(char *, char *[]))
{
 switch(p->type){
  case USE_PATH:
   if(fn) *fn = execvp;
   return ustrdup(p->path);
  case RELATIVE_TO_UCC:
   if(fn) *fn = execv;
   return path_prepend_relative_nofree(p->path);
  case FROM_Bprefix:
   if(fn) *fn = execv;
   return path_prepend(Bprefix, p->path);
 }
 return ((void *)0);
}

variable_types: struct cmdpath { char *path; enum cmdpath_type { RELATIVE_TO_UCC=0, USE_PATH=1, FROM_Bprefix=2 } type; } *

variable_types:
fn
int (**)(char *, char *[])

user_defined_types: struct cmdpath { char *path; enum cmdpath_type type; }


decompiled_code:
void __fastcall cmdpath_initrelative(__int64 a1, __int64 a2, __int64 a3)
{
if ( Bprefix )
{
*(_QWORD *)a1 = a2;
*(_DWORD *)(a1 + 8) = 2;
}
else
{
*(_QWORD *)a1 = a3;
*(_DWORD *)(a1 + 8) = 0;
}
}

original_code:
void cmdpath_initrelative(
  struct cmdpath *p,
  const char *bprefix,
  const char *ucc_relative)
{
 if(Bprefix){
  p->path = bprefix;
  p->type = FROM_Bprefix;
 }else{
  p->path = ucc_relative;
  p->type = RELATIVE_TO_UCC;
 }
}

canonical_original_code:
void cmdpath_initrelative(struct cmdpath *p, char *bprefix, char *ucc_relative)
{
 if(Bprefix){
  p->path = bprefix;
  p->type = FROM_Bprefix;
 }else{
  p->path = ucc_relative;
  p->type = RELATIVE_TO_UCC;
 }
}

variable_types:
bprefix
char *

user_defined_types: enum cmdpath_type { RELATIVE_TO_UCC=0, USE_PATH=1, FROM_Bprefix=2 }


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

result = "$PATH-search";
if ( a1 != 1 )
{
result = "Bprefix-relative";
if ( a1 != 2 )
{
result = "ucc-relative";
if ( a1 )
result = 0LL;
}
}
return result;
}

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

result = "$PATH-search";
if ( a1 != 1 )
{
result = "Bprefix-relative";
if ( a1 != 2 )
{
result = "ucc-relative";
if ( a1 )
result = 0LL;
}
}
return result;
}

original_code:
const char *cmdpath_type(enum cmdpath_type t)
{
 switch(t){
  case RELATIVE_TO_UCC: return "ucc-relative";
  case USE_PATH: return "$PATH-search";
  case FROM_Bprefix: return "Bprefix-relative";
 }
 return ((void *)0);
}

variable_types: enum cmdpath_type { RELATIVE_TO_UCC=0, USE_PATH=1, FROM_Bprefix=2 }


decompiled_code:
__int64 __fastcall tmpfile_prefix_out(const char *a1, char **a2)
{
char *v3; // rsi
char *v4; // rbx
int v5; // ebp

v3 = getenv("TMPDIR");
if ( !v3 )
v3 = "/tmp";
v4 = (char *)ustrprintf("%s/%sXXXXXX", v3, a1);
v5 = mkstemp(v4);
if ( v5 < 0 )
{
free(v4);
v4 = 0LL;
}
if ( a2 )
*a2 = v4;
else
free(v4);
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, char **a2)
{
char *v3; // rsi
char *v4; // rbx
int v5; // ebp

v3 = getenv("TMPDIR");
if ( !v3 )
v3 = "/tmp";
v4 = (char *)ustrprintf("%s/%sXXXXXX", v3, a1);
v5 = mkstemp(v4);
if ( v5 < 0 )
{
free(v4);
v4 = 0LL;
}
if ( a2 )
*a2 = v4;
else
free(v4);
return (unsigned int)v5;
}

original_code:
int tmpfile_prefix_out(const char *prefix, char **const fname)
{
 char *tmppath;
 int fd;
 char *tmpdir = getenv("TMPDIR");
 if(!tmpdir)
  tmpdir = "/tmp";
 tmppath = ustrprintf("%s/%sXXXXXX", tmpdir, prefix);
 fd = mkstemp(tmppath);
 if(fd < 0){
  free(tmppath);
  tmppath = ((void *)0);
 }
 if(fname)
  *fname = tmppath;
 else
  free(tmppath);
 return fd;
}

canonical_original_code:
int tmpfile_prefix_out(char *prefix, char **fname)
{
 char *tmppath;
 int fd;
 char *tmpdir = getenv("TMPDIR");
 if(!tmpdir)
  tmpdir = "/tmp";
 tmppath = ustrprintf("%s/%sXXXXXX", tmpdir, prefix);
 fd = mkstemp(tmppath);
 if(fd < 0){
  free(tmppath);
  tmppath = ((void *)0);
 }
 if(fname)
  *fname = tmppath;
 else
  free(tmppath);
 return fd;
}

variable_types:
prefix
char *

variable_types:
fname
char **

variable_types:
tmppath
char *

variable_types: fd int

variable_types:
tmpdir
char *


decompiled_code:
__int64 __fastcall out_label_bblock(__int64 a1)
{
__int64 v1; // rbx

v1 = umalloc(16LL);
xsnprintf(v1, 16LL, "%sblk.%lu", *(const char **)(cc1_target_details[1] + 24LL), a1);
return v1;
}

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

v1 = umalloc(16LL);
xsnprintf(v1, 16LL, "%sblk.%lu", *(const char **)(cc1_target_details[1] + 24LL), a1);
return v1;
}

original_code:
char *out_label_bblock(unsigned long n)
{
 char *buf = umalloc(16);
 xsnprintf(buf, 16, "%sblk.%lu", cc1_target_details.as->privatelbl_prefix, (unsigned long)n);
 return buf;
}

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall out_label_block(const char *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // r8

v1 = (int)(strlen(a1) + 16);
v2 = umalloc(v1);
v3 = (unsigned int)block_last++;
xsnprintf(v2, v1, "%s.block_%d", a1, v3);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // r8

v1 = (int)(strlen(a1) + 16);
v2 = umalloc(v1);
v3 = (unsigned int)block_last++;
xsnprintf(v2, v1, "%s.block_%d", a1, v3);
return v2;
}

original_code:
char *out_label_block(const char *funcsp)
{
 int len;
 char *ret;
 len = strlen(funcsp) + 16;
 ret = umalloc(len);
 xsnprintf(ret, len, "%s.block_%d", funcsp, block_last++);
 return ret;
}

canonical_original_code:
char *out_label_block(char *funcsp)
{
 int len;
 char *ret;
 len = strlen(funcsp) + 16;
 ret = umalloc(len);
 xsnprintf(ret, len, "%s.block_%d", funcsp, block_last++);
 return ret;
}

variable_types:
funcsp
char *

variable_types: len int

variable_types:
ret
char *


decompiled_code:
__int64 __fastcall out_label_code(const char *a1)
{
int v1; // ebx
__int64 v2; // rbp
__int64 v3; // r9

v1 = strlen(a1);
v2 = umalloc(v1 + 11);
v3 = (unsigned int)label_last++;
xsnprintf(v2, v1 + 10, "%s%s.%d", *(const char **)(cc1_target_details[1] + 24LL), a1, v3);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
int v1; // ebx
__int64 v2; // rbp
__int64 v3; // r9

v1 = strlen(a1);
v2 = umalloc(v1 + 11);
v3 = (unsigned int)label_last++;
xsnprintf(v2, v1 + 10, "%s%s.%d", *(const char **)(cc1_target_details[1] + 24LL), a1, v3);
return v2;
}

original_code:
char *out_label_code(const char *fmt)
{
 int len;
 char *ret;
 len = strlen(fmt) + 10;
 ret = umalloc(len + 1);
 xsnprintf(ret, len, "%s%s.%d", cc1_target_details.as->privatelbl_prefix, fmt, label_last++);
 return ret;
}

canonical_original_code:
char *out_label_code(char *fmt)
{
 int len;
 char *ret;
 len = strlen(fmt) + 10;
 ret = umalloc(len + 1);
 xsnprintf(ret, len, "%s%s.%d", cc1_target_details.as->privatelbl_prefix, fmt, label_last++);
 return ret;
}

variable_types:
fmt
char *


decompiled_code:
__int64 __fastcall out_label_data_store(unsigned int a1)
{
__int64 v1; // rbp
const char *v2; // rcx
__int64 v3; // r8

v1 = umalloc(16LL);
if ( a1 == 2 )
{
v2 = "data";
}
else if ( a1 > 2 )
{
v2 = 0LL;
if ( a1 == 3 )
v2 = "float";
}
else
{
v2 = "wstr";
if ( !a1 )
v2 = "str";
}
v3 = (unsigned int)str_last++;
xsnprintf(v1, 16LL, "%s.%d", v2, v3);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
__int64 v1; // rbp
const char *v2; // rcx
__int64 v3; // r8

v1 = umalloc(16LL);
if ( a1 == 2 )
{
v2 = "data";
}
else if ( a1 > 2 )
{
v2 = 0LL;
if ( a1 == 3 )
v2 = "float";
}
else
{
v2 = "wstr";
if ( !a1 )
v2 = "str";
}
v3 = (unsigned int)str_last++;
xsnprintf(v1, 16LL, "%s.%d", v2, v3);
return v1;
}

original_code:
char *out_label_data_store(enum out_label_store ty)
{
 char *ret = umalloc(16);
 const char *pre;
 switch(ty){
  case STORE_P_CHAR: pre = "str"; break;
  case STORE_P_WCHAR: pre = "wstr"; break;
  case STORE_COMP_LIT: pre = "data"; break;
  case STORE_FLOAT: pre = "float"; break;
 }
 xsnprintf(ret, 16, "%s.%d", pre, str_last++);
 return ret;
}

canonical_original_code:
char *out_label_data_store(enum out_label_store ty)
{
 char *ret = umalloc(16);
 char *pre;
 switch(ty){
  case STORE_P_CHAR: pre = "str"; break;
  case STORE_P_WCHAR: pre = "wstr"; break;
  case STORE_COMP_LIT: pre = "data"; break;
  case STORE_FLOAT: pre = "float"; break;
 }
 xsnprintf(ret, 16, "%s.%d", pre, str_last++);
 return ret;
}

variable_types: enum out_label_store { STORE_P_CHAR=0, STORE_P_WCHAR=1, STORE_COMP_LIT=2, STORE_FLOAT=3 }

variable_types:
pre
char *


decompiled_code:
__int64 __fastcall out_label_static_local(const char *a1, const char *a2)
{
int v2; // er12
__int64 v3; // r13
__int64 v4; // r12
__int64 v5; // r8
__int64 result; // rax

if ( a1 )
{
v2 = strlen(a1);
v3 = (int)(v2 + strlen(a2) + 16);
v4 = umalloc(v3);
v5 = (unsigned int)static_last++;
xsnprintf(v4, v3, "%s.static%d_%s", a1, v5, a2);
result = v4;
}
else
{
ice("out/lbl.c", 70LL, "out_label_static_local", "no spel for %s", "out_label_static_local");
result = out_label_goto();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, const char *a2)
{
int v2; // er12
__int64 v3; // r13
__int64 v4; // r12
__int64 v5; // r8
__int64 result; // rax

if ( a1 )
{
v2 = strlen(a1);
v3 = (int)(v2 + strlen(a2) + 16);
v4 = umalloc(v3);
v5 = (unsigned int)static_last++;
xsnprintf(v4, v3, "%s.static%d_%s", a1, v5, a2);
result = v4;
}
else
{
ice("out/lbl.c", 70LL, "out_label_static_local", "no spel for %s", "out_label_static_local");
result = func5();
}
return result;
}

original_code:
char *out_label_static_local(const char *funcsp, const char *spel)
{
 char *ret;
 int len;
 do if(!(funcsp)) ice("out/lbl.c", 70, __func__, "no spel for %s", __func__); while(0);
 len = strlen(funcsp) + strlen(spel) + 16;
 ret = umalloc(len);
 xsnprintf(ret, len, "%s.static%d_%s", funcsp, static_last++, spel);
 return ret;
}

canonical_original_code:
char *out_label_static_local(char *funcsp, char *spel)
{
 char *ret;
 int len;
 do if(!(funcsp)) ice("out/lbl.c", 70, __func__, "no spel for %s", __func__); while(0);
 len = strlen(funcsp) + strlen(spel) + 16;
 ret = umalloc(len);
 xsnprintf(ret, len, "%s.static%d_%s", funcsp, static_last++, spel);
 return ret;
}

variable_types:
spel
char *


decompiled_code:
__int64 __fastcall out_label_goto(const char *a1, const char *a2)
{
int v2; // ebx
__int64 v3; // rbp
__int64 v4; // rbx

v2 = strlen(a1);
v3 = (int)(v2 + strlen(a2) + 6);
v4 = umalloc(v3);
xsnprintf(v4, v3, "%s%s.%s", *(const char **)(cc1_target_details[1] + 24LL), a1, a2);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, const char *a2)
{
int v2; // ebx
__int64 v3; // rbp
__int64 v4; // rbx

v2 = strlen(a1);
v3 = (int)(v2 + strlen(a2) + 6);
v4 = umalloc(v3);
xsnprintf(v4, v3, "%s%s.%s", *(const char **)(cc1_target_details[1] + 24LL), a1, a2);
return v4;
}

original_code:
char *out_label_goto(char *func, char *lbl)
{
 int len = strlen(func) + strlen(lbl) + 6;
 char *ret = umalloc(len);
 xsnprintf(ret, len, "%s%s.%s", cc1_target_details.as->privatelbl_prefix, func, lbl);
 return ret;
}

variable_types:
func
char *

variable_types:
lbl
char *


decompiled_code:
__int64 __fastcall out_label_case(int a1, int a2)
{
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rbp
const char *v6; // rax
const char *v7; // rcx

v2 = (unsigned int)a2;
v3 = umalloc(47LL);
v4 = v3;
if ( a1 == 1 )
{
xsnprintf(v3, 47LL, "%scase_%d_default", *(const char **)(cc1_target_details[1] + 24LL), (unsigned int)switch_last);
}
else if ( (a1 & 0xFFFFFFFD) == 0 )
{
v6 = (const char *)&unk_41B;
if ( a2 < 0 )
{
v2 = (unsigned int)-a2;
v6 = "m";
}
v7 = "_rng";
if ( a1 != 2 )
v7 = (const char *)&unk_41B;
xsnprintf(
v4,
47LL,
"%scase%s_%d_%s%d",
v7,
*(const char **)(cc1_target_details[1] + 24LL),
(unsigned int)switch_last,
v6,
v2);
}
++switch_last;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2)
{
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rbp
const char *v6; // rax
const char *v7; // rcx

v2 = (unsigned int)a2;
v3 = umalloc(47LL);
v4 = v3;
if ( a1 == 1 )
{
xsnprintf(v3, 47LL, "%scase_%d_default", *(const char **)(cc1_target_details[1] + 24LL), (unsigned int)switch_last);
}
else if ( (a1 & 0xFFFFFFFD) == 0 )
{
v6 = (const char *)&unk_41B;
if ( a2 < 0 )
{
v2 = (unsigned int)-a2;
v6 = "m";
}
v7 = "_rng";
if ( a1 != 2 )
v7 = (const char *)&unk_41B;
xsnprintf(
v4,
47LL,
"%scase%s_%d_%s%d",
v7,
*(const char **)(cc1_target_details[1] + 24LL),
(unsigned int)switch_last,
v6,
v2);
}
++switch_last;
return v4;
}

original_code:
char *out_label_case(enum out_label_type lbltype, int val)
{
 int len;
 char *ret = umalloc(len = 15 + 32);
 switch(lbltype){
  case CASE_DEF:
   xsnprintf(ret, len, "%scase_%d_default", cc1_target_details.as->privatelbl_prefix, switch_last);
   break;
  case CASE_CASE:
  case CASE_RANGE:
  {
   const char *extra = "";
   if(val < 0){
    val = -val;
    extra = "m";
   }
   xsnprintf(ret, len, "%scase%s_%d_%s%d", lbltype == CASE_RANGE ? "_rng" : "", cc1_target_details.as->privatelbl_prefix, switch_last, extra, val);
   break;
  }
 }
 switch_last++;
 return ret;
}

canonical_original_code:
char *out_label_case(enum out_label_type lbltype, int val)
{
 int len;
 char *ret = umalloc(len = 15 + 32);
 switch(lbltype){
  case CASE_DEF:
   xsnprintf(ret, len, "%scase_%d_default", cc1_target_details.as->privatelbl_prefix, switch_last);
   break;
  case CASE_CASE:
  case CASE_RANGE:
  {
   char *extra = "";
   if(val < 0){
    val = -val;
    extra = "m";
   }
   xsnprintf(ret, len, "%scase%s_%d_%s%d", lbltype == CASE_RANGE ? "_rng" : "", cc1_target_details.as->privatelbl_prefix, switch_last, extra, val);
   break;
  }
 }
 switch_last++;
 return ret;
}

variable_types: enum out_label_type { CASE_CASE=0, CASE_DEF=1, CASE_RANGE=2 }

variable_types: val int

variable_types:
extra
char *


decompiled_code:
__int64 __fastcall out_label_flow(const char *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // r9

v1 = (int)(strlen(a1) + 16);
v2 = umalloc(v1);
v3 = (unsigned int)flow_last++;
xsnprintf(v2, v1, "%sflow_%s_%d", *(const char **)(cc1_target_details[1] + 24LL), a1, v3);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // r9

v1 = (int)(strlen(a1) + 16);
v2 = umalloc(v1);
v3 = (unsigned int)flow_last++;
xsnprintf(v2, v1, "%sflow_%s_%d", *(const char **)(cc1_target_details[1] + 24LL), a1, v3);
return v2;
}

original_code:
char *out_label_flow(const char *fmt)
{
 int len = 16 + strlen(fmt);
 char *ret = umalloc(len);
 xsnprintf(ret, len, "%sflow_%s_%d", cc1_target_details.as->privatelbl_prefix, fmt, flow_last++);
 return ret;
}

canonical_original_code:
char *out_label_flow(char *fmt)
{
 int len = 16 + strlen(fmt);
 char *ret = umalloc(len);
 xsnprintf(ret, len, "%sflow_%s_%d", cc1_target_details.as->privatelbl_prefix, fmt, flow_last++);
 return ret;
}


decompiled_code:
__int64 __fastcall out_dbg_func_end(const char *a1)
{
return ustrprintf("%sfuncend_%s", *(const char **)(cc1_target_details[1] + 24LL), a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
return ustrprintf("%sfuncend_%s", *(const char **)(cc1_target_details[1] + 24LL), a1);
}

original_code:
char *out_dbg_func_end(const char *fn)
{
 return ustrprintf("%sfuncend_%s", cc1_target_details.as->privatelbl_prefix, fn);
}

canonical_original_code:
char *out_dbg_func_end(char *fn)
{
 return ustrprintf("%sfuncend_%s", cc1_target_details.as->privatelbl_prefix, fn);
}

variable_types:
fn
char *


variable_types: c int

variable_types:
escapechars
struct { char from; } []

variable_types:
i
unsigned int


decompiled_code:
_BOOL8 __fastcall inc_and_chk(unsigned __int64 *a1, unsigned int a2, unsigned int a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v4; // rsi
unsigned __int64 v5; // rdx

v3 = *a1;
v4 = *a1 * a2;
v5 = v4 + a3;
*a1 = v5;
if ( v4 > v5 )
v4 = v5;
return v3 > v4;
}

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

v3 = *a1;
v4 = *a1 * a2;
v5 = v4 + a3;
*a1 = v5;
if ( v4 > v5 )
v4 = v5;
return v3 > v4;
}

original_code:
static int inc_and_chk(unsigned long long *const val, unsigned base, unsigned inc)
{
 const unsigned long long new = *val * base + inc;
 int of = new < *val || *val * base < *val;
 *val = new;
 return of;
}

canonical_original_code:
static int inc_and_chk(unsigned long long *val, unsigned int base, unsigned int inc)
{
 unsigned long long new = *val * base + inc;
 int of = new < *val || *val * base < *val;
 *val = new;
 return of;
}

variable_types:
val
unsigned long long *

variable_types:
base
unsigned int

variable_types:
inc
unsigned int

variable_types:
new
unsigned long long

variable_types: of int


isbdigit

decompiled_code:
_BOOL8 __fastcall isbdigit(int a1)
{
return (unsigned int)(a1 - 48) <= 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(int a1)
{
return (unsigned int)(a1 - 48) <= 1;
}

original_code:
static int isbdigit(int c)
{
 return c == '0' || c == '1';
}


isodigit

decompiled_code:
_BOOL8 __fastcall isodigit(int a1)
{
return (unsigned int)(a1 - 48) <= 7;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(int a1)
{
return (unsigned int)(a1 - 48) <= 7;
}

original_code:
static int isodigit(int c)
{
 return '0' <= c && c < '8';
}