decompiled_code:
unsigned __int64 __fastcall read_ap_num(__int64 (__fastcall *a1)(_QWORD), char *a2, unsigned int a3, int a4, char **a5, _DWORD *a6)
{
char *v6; // rbx
int i; // eax
unsigned int v11; // edx
char *j; // rax
__int64 v13; // r12
unsigned __int64 v16[8]; // [rsp+18h] [rbp-40h] BYREF

v6 = a2;
v16[0] = 0LL;
*a6 = 0;
for ( i = a1((unsigned int)*a2); i; i = a1((unsigned int)*j) )
{
if ( ((*_ctype_b_loc())[*v6] & 0x800) != 0 )
{
v11 = *v6 - 48;
}
else
{
v13 = *v6;
v11 = (*_ctype_tolower_loc())[v13] - 87;
}
if ( inc_and_chk(v16, a3, v11) )
{
overflow_handle(v6, a5, a1);
*a6 = 1;
while ( (unsigned int)a1((unsigned int)*v6) || *v6 == 95 )
++v6;
break;
}
for ( j = v6 + 1; *j == 95; ++j )
;
if ( a4 > 0 && !--a4 )
{
v6 = j;
break;
}
v6 = j;
}
*a5 = v6;
return v16[0];
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(__int64 (__fastcall *a1)(_QWORD), char *a2, unsigned int a3, int a4, char **a5, _DWORD *a6)
{
char *v6; // rbx
int i; // eax
unsigned int v11; // edx
char *j; // rax
__int64 v13; // r12
unsigned __int64 v16[8]; // [rsp+18h] [rbp-40h] BYREF

v6 = a2;
v16[0] = 0LL;
*a6 = 0;
for ( i = a1((unsigned int)*a2); i; i = a1((unsigned int)*j) )
{
if ( ((*_ctype_b_loc())[*v6] & 0x800) != 0 )
{
v11 = *v6 - 48;
}
else
{
v13 = *v6;
v11 = (*_ctype_tolower_loc())[v13] - 87;
}
if ( func1(v16, a3, v11) )
{
func2(v6, a5, a1);
*a6 = 1;
while ( (unsigned int)a1((unsigned int)*v6) || *v6 == 95 )
++v6;
break;
}
for ( j = v6 + 1; *j == 95; ++j )
;
if ( a4 > 0 && !--a4 )
{
v6 = j;
break;
}
v6 = j;
}
*a5 = v6;
return v16[0];
}

original_code:
static unsigned long long read_ap_num(
  digit_test test, char *s,
  int base, int max_chars,
  char **const end, int *const of)
{
 unsigned long long val = 0;
 int i = 0;
 *of = 0;
 while(test(*s)){
  int dv = ((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISdigit) ? *s - '0' : tolower(*s) - 'a' + 10;
  if(inc_and_chk(&val, base, dv)){
   overflow_handle(s, end, test);
   *of = 1;
   while((test(*s) || *s == '_'))
    s++;
   break;
  }
  s++;
  while(*s == '_')
   s++;
  if(max_chars > 0 && --max_chars == 0)
   break;
  i++;
 }
 *end = s;
 return val;
}

canonical_original_code:
static unsigned long long read_ap_num(int test(int), char *s, int base, int max_chars, char **end, int *of)
{
 unsigned long long val = 0;
 int i = 0;
 *of = 0;
 while(test(*s)){
  int dv = ((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISdigit) ? *s - '0' : tolower(*s) - 'a' + 10;
  if(inc_and_chk(&val, base, dv)){
   overflow_handle(s, end, test);
   *of = 1;
   while((test(*s) || *s == '_'))
    s++;
   break;
  }
  s++;
  while(*s == '_')
   s++;
  if(max_chars > 0 && --max_chars == 0)
   break;
  i++;
 }
 *end = s;
 return val;
}

variable_types:
test
int (int)

variable_types:
s
char *

variable_types: base int

variable_types:
end
char **

variable_types:
of
int *

variable_types:
val
unsigned long long

variable_types: i int

variable_types: dv int


repo: bobrippling/ucc-c-compiler

decompiled_code:
__int64 __fastcall escape_char(char *a1, char *a2, char **a3, int a4, _DWORD *a5, _DWORD *a6, _DWORD *a7)
{
char *v7; // r12
unsigned __int64 v11; // rbp
unsigned int i; // ebx
unsigned int v13; // eax
unsigned int v15; // ecx
unsigned int v16; // ebx
char v17; // dl
char *v19; // [rsp+18h] [rbp-40h] BYREF

if ( !a2 )
_assert_fail("limit", "escape.c", 0xC6u, "escape_char");
v7 = a2;
v11 = 0LL;
for ( i = 0; a2 != a1; ++a1 )
{
v17 = *a1;
if ( !*a1 )
{
if ( !a5 )
{
LABEL_10:
v7 = &a1[-(a2 != a1)];
goto LABEL_11;
}
LABEL_9:
*a5 = v11 > 1;
goto LABEL_10;
}
v13 = v17;
if ( v17 == 92 )
{
if ( a2 == ++a1 )
{
*a7 = 84;
break;
}
v13 = escape_char_1(a1, &v19, a4, a6, a7);
a1 = v19 - 1;
}
if ( a4 )
{
i = v13;
if ( v13 )
*a6 = 7;
goto LABEL_15;
}
v15 = i;
v16 = i << 8;
if ( v16 <= ~v13 )
{
i = v13 + v16;
if ( v15 <= 0xFFFFFF )
goto LABEL_15;
}
else
{
i = v13 + v16;
}
*a6 = 7;
LABEL_15:
++v11;
}
if ( a5 )
goto LABEL_9;
LABEL_11:
*a3 = v7;
return i;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1, char *a2, char **a3, int a4, _DWORD *a5, _DWORD *a6, _DWORD *a7)
{
char *v7; // r12
unsigned __int64 v11; // rbp
unsigned int i; // ebx
unsigned int v13; // eax
unsigned int v15; // ecx
unsigned int v16; // ebx
char v17; // dl
char *v19; // [rsp+18h] [rbp-40h] BYREF

if ( !a2 )
_assert_fail("limit", "escape.c", 0xC6u, "escape_char");
v7 = a2;
v11 = 0LL;
for ( i = 0; a2 != a1; ++a1 )
{
v17 = *a1;
if ( !*a1 )
{
if ( !a5 )
{
LABEL_10:
v7 = &a1[-(a2 != a1)];
goto LABEL_11;
}
LABEL_9:
*a5 = v11 > 1;
goto LABEL_10;
}
v13 = v17;
if ( v17 == 92 )
{
if ( a2 == ++a1 )
{
*a7 = 84;
break;
}
v13 = func7(a1, &v19, a4, a6, a7);
a1 = v19 - 1;
}
if ( a4 )
{
i = v13;
if ( v13 )
*a6 = 7;
goto LABEL_15;
}
v15 = i;
v16 = i << 8;
if ( v16 <= ~v13 )
{
i = v13 + v16;
if ( v15 <= 0xFFFFFF )
goto LABEL_15;
}
else
{
i = v13 + v16;
}
*a6 = 7;
LABEL_15:
++v11;
}
if ( a5 )
goto LABEL_9;
LABEL_11:
*a3 = v7;
return i;
}

original_code:
int escape_char(
  char *start,
  char *limit,
  char **const end,
  int is_wide,
  int *const multi,
  int *const warn,
  int *const err)
{
 int ret = 0;
 char *i;
 size_t n = 0;
 ((limit) ? (void) (0) : __assert_fail ("limit", "escape.c", 198, __extension__ __PRETTY_FUNCTION__));
 for(i = start; i != limit && *i; i++){
  int this;
  if(*i == '\\'){
   char *escfin;
   i++;
   if(i == limit){
    *err = 84;
    break;
   }
   this = escape_char_1(i, &escfin, is_wide, warn, err);
   i = escfin - 1;
  }else{
   this = *i;
  }
  if(is_wide){
   ret = this;
   if(ret)
    *warn = 7;
  }else{
   int of = 0;
   if((unsigned)ret > (0x7fffffff * 2U + 1U) / 256u)
    of = 1;
   ret *= 256u;
   if((unsigned)ret > (0x7fffffff * 2U + 1U) - this)
    of = 1;
   ret += this;
   if(of)
    *warn = 7;
  }
  n++;
 }
 if(multi)
  *multi = n > 1;
 if(i == limit)
  *end = i;
 else
  *end = i - 1;
 return ret;
}

canonical_original_code:
int escape_char(char *start, char *limit, char **end, int is_wide, int *multi, int *warn, int *err)
{
 int ret = 0;
 char *i;
 unsigned long n = 0;
 ((limit) ? (void) (0) : __assert_fail ("limit", "escape.c", 198, __extension__ __PRETTY_FUNCTION__));
 for(i = start; i != limit && *i; i++){
  int this;
  if(*i == '\\'){
   char *escfin;
   i++;
   if(i == limit){
    *err = 84;
    break;
   }
   this = escape_char_1(i, &escfin, is_wide, warn, err);
   i = escfin - 1;
  }else{
   this = *i;
  }
  if(is_wide){
   ret = this;
   if(ret)
    *warn = 7;
  }else{
   int of = 0;
   if((unsigned int)ret > (0x7fffffff * 2U + 1U) / 256u)
    of = 1;
   ret *= 256u;
   if((unsigned int)ret > (0x7fffffff * 2U + 1U) - this)
    of = 1;
   ret += this;
   if(of)
    *warn = 7;
  }
  n++;
 }
 if(multi)
  *multi = n > 1;
 if(i == limit)
  *end = i;
 else
  *end = i - 1;
 return ret;
}

variable_types:
start
char *

variable_types:
limit
char *

variable_types:
multi
int *

variable_types:
warn
int *

variable_types:
err
int *

variable_types: ret int

variable_types:
i
char *

variable_types:
n
unsigned long

variable_types: this int

variable_types:
escfin
char *

variable_types: of int

return_type: int


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

if ( a1 == 2 )
return "decimal";
if ( a1 > 2 )
{
result = "hexadecimal";
if ( a1 != 3 )
result = 0LL;
}
else
{
result = "octal";
if ( !a1 )
result = "binary";
}
return result;
}

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

if ( a1 == 2 )
return "decimal";
if ( a1 > 2 )
{
result = "hexadecimal";
if ( a1 != 3 )
result = 0LL;
}
else
{
result = "octal";
if ( !a1 )
result = "binary";
}
return result;
}

original_code:
const char *base_to_str(enum base b)
{
 switch(b){
  case BIN: return "binary";
  case OCT: return "octal";
  case DEC: return "decimal";
  case HEX: return "hexadecimal";
 }
 return ((void *)0);
}

variable_types: enum base { BIN=0, OCT=1, DEC=2, HEX=3 }

return_type: char *


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

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

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


decompiled_code:
int __fastcall colour_enabled(int fd)
{
int result; // eax
char *v2; // rdx

result = 0;
if ( from_option != 1 )
{
result = 1;
if ( from_option != 2 )
{
v2 = getenv("NO_COLOR");
result = 0;
if ( !v2 )
result = isatty(fd);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(int fd)
{
int result; // eax
char *v2; // rdx

result = 0;
if ( from_option != 1 )
{
result = 1;
if ( from_option != 2 )
{
v2 = getenv("NO_COLOR");
result = 0;
if ( !v2 )
result = isatty(fd);
}
}
return result;
}

original_code:
int colour_enabled(int fd)
{
 switch(from_option){
  case TRI_UNSET:
   break;
  case TRI_FALSE:
   return 0;
  case TRI_TRUE:
   return 1;
 }
 const char *no_color = getenv("NO_COLOR");
 if(no_color)
  return 0;
 return isatty(fd);
}

canonical_original_code:
int colour_enabled(int fd)
{
 switch(from_option){
  case TRI_UNSET:
   break;
  case TRI_FALSE:
   return 0;
  case TRI_TRUE:
   return 1;
 }
 char *no_color = getenv("NO_COLOR");
 if(no_color)
  return 0;
 return isatty(fd);
}

variable_types: fd int


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

result = 1 - ((unsigned int)(a1 == 0) - 1);
from_option = 1 - ((a1 == 0) - 1);
return result;
}

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

result = 1 - ((unsigned int)(a1 == 0) - 1);
from_option = 1 - ((a1 == 0) - 1);
return result;
}

original_code:
void colour_enable(int enable)
{
 from_option = enable ? TRI_TRUE : TRI_FALSE;
}

variable_types: enable int

return_type: void


runner

decompiled_code:
__int64 __fastcall runner(const char **a1, const char **a2, int a3, const char *a4)
{
unsigned int v5; // er14
__pid_t v6; // eax
int v7; // eax
_BYTE *v8; // rdx
char v9; // cl
const char **v10; // rbp
const char *v11; // rsi
signed int v12; // ebx
char v13; // dl
__int64 v14; // rax
unsigned int v15; // ecx
char *v16; // rbp
const char *v17; // rdx
const char **v18; // rbx
int *v19; // rax
char *v20; // rax
__int64 v21; // rdi
int v22; // er12
__int64 v23; // r15
const char *v24; // rax
__int64 v25; // rbx
int v26; // ebx
unsigned int v27; // ebp
int *v28; // rax
char *v29; // rax
__time_t v30; // rdx
__suseconds_t v31; // rcx
__WAIT_STATUS stat_loc; // [rsp+28h] [rbp-60h] BYREF
struct timeval v37; // [rsp+30h] [rbp-58h] BYREF
struct timeval tv; // [rsp+40h] [rbp-48h] BYREF

if ( show )
{
v16 = (char *)cmdpath_resolve(a1, 0LL);
if ( wrapper )
fprintf(stderr, "WRAPPER='%s' ", wrapper);
fprintf(stderr, "%s ", v16);
v17 = *a2;
if ( *a2 )
{
v18 = a2 + 1;
do
{
fprintf(stderr, "%s ", v17);
v17 = *v18++;
}
while ( v17 );
}
fputc(10, stderr);
free(v16);
}
v5 = noop;
if ( noop )
return 0;
if ( time_subcmds && gettimeofday(&tv, 0LL) < 0 )
{
v19 = _errno_location();
v20 = strerror(*v19);
fprintf(stderr, "gettimeofday(): %s\n", v20);
}
v6 = fork();
if ( v6 == -1 )
{
die("fork():");
LABEL_6:
v7 = dynarray_nochk_count(a2);
v8 = (_BYTE *)wrapper;
if ( wrapper )
{
++v7;
v9 = *wrapper;
if ( *wrapper )
{
do
{
v7 += v9 == 44;
v9 = *++v8;
}
while ( *v8 );
}
}
v10 = (const char **)umalloc(8LL * (v7 + 2));
v11 = (const char *)wrapper;
v12 = v5;
if ( wrapper )
{
v13 = *wrapper;
if ( *wrapper )
{
v14 = wrapper + 1LL;
v15 = v5;
do
{
if ( v13 == 44 )
{
*(_BYTE *)(v14 - 1) = 0;
v10[v15] = v11;
v11 = (const char *)v14;
++v15;
}
v21 = v14++;
v13 = *(_BYTE *)(v14 - 1);
}
while ( v13 );
v12 = v15;
if ( v11 != (const char *)v21 )
{
v12 = v15 + 1;
v10[v15] = v11;
}
}
}
v22 = v12 + 1;
v23 = v12;
v10[v12] = (const char *)cmdpath_resolve(a1, &stat_loc);
v24 = *a2;
if ( *a2 )
{
v25 = v12 + 2;
do
{
v22 = v25;
v10[v25++ - 1] = v24;
v24 = (&a2[v25])[-v23 - 2];
}
while ( v24 );
}
v10[v22] = 0LL;
umask(orig_umask);
((void (__fastcall *)(const char *, const char **))stat_loc.__uptr)(*v10, v10);
die("execv(\"%s\"):", *v10);
goto LABEL_30;
}
if ( !v6 )
goto LABEL_6;
LABEL_30:
if ( wait((__WAIT_STATUS)&stat_loc) == -1 )
die("wait()");
if ( time_subcmds && gettimeofday(&v37, 0LL) < 0 )
{
v28 = _errno_location();
v29 = strerror(*v28);
fprintf(stderr, "gettimeofday(): %s\n", v29);
}
v26 = (__int64)stat_loc.__uptr & 0x7F;
if ( ((__int64)stat_loc.__uptr & 0x7F) != 0 || (v27 = BYTE1(stat_loc.__uptr), !BYTE1(stat_loc.__uptr)) )
{
if ( (char)(((__int64)stat_loc.__uptr & 0x7F) + 1) > 1 )
{
fprintf(stderr, "%s caught signal %d\n", *a1, (__int64)stat_loc.__uptr & 0x7F);
if ( a4 )
remove(a4);
exit(v26 + 128);
}
}
else
{
if ( a4 )
remove(a4);
v5 = v27;
if ( !a3 )
die("%s returned %d", *a1, v27);
}
if ( time_subcmds )
{
v30 = v37.tv_sec - tv.tv_sec;
v31 = v37.tv_usec - tv.tv_usec;
if ( v37.tv_usec - tv.tv_usec < 0 )
{
--v30;
v31 += 1000000LL;
}
printf("# %s %ld.%06ld\n", *a1, v30, v31);
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char **a1, const char **a2, int a3, const char *a4)
{
unsigned int v5; // er14
__pid_t v6; // eax
int v7; // eax
_BYTE *v8; // rdx
char v9; // cl
const char **v10; // rbp
const char *v11; // rsi
signed int v12; // ebx
char v13; // dl
__int64 v14; // rax
unsigned int v15; // ecx
char *v16; // rbp
const char *v17; // rdx
const char **v18; // rbx
int *v19; // rax
char *v20; // rax
__int64 v21; // rdi
int v22; // er12
__int64 v23; // r15
const char *v24; // rax
__int64 v25; // rbx
int v26; // ebx
unsigned int v27; // ebp
int *v28; // rax
char *v29; // rax
__time_t v30; // rdx
__suseconds_t v31; // rcx
__WAIT_STATUS stat_loc; // [rsp+28h] [rbp-60h] BYREF
struct timeval v37; // [rsp+30h] [rbp-58h] BYREF
struct timeval tv; // [rsp+40h] [rbp-48h] BYREF

if ( show )
{
v16 = (char *)cmdpath_resolve(a1, 0LL);
if ( wrapper )
fprintf(stderr, "WRAPPER='%s' ", wrapper);
fprintf(stderr, "%s ", v16);
v17 = *a2;
if ( *a2 )
{
v18 = a2 + 1;
do
{
fprintf(stderr, "%s ", v17);
v17 = *v18++;
}
while ( v17 );
}
fputc(10, stderr);
free(v16);
}
v5 = noop;
if ( noop )
return 0;
if ( time_subcmds && gettimeofday(&tv, 0LL) < 0 )
{
v19 = _errno_location();
v20 = strerror(*v19);
fprintf(stderr, "gettimeofday(): %s\n", v20);
}
v6 = fork();
if ( v6 == -1 )
{
die("fork():");
LABEL_6:
v7 = dynarray_nochk_count(a2);
v8 = (_BYTE *)wrapper;
if ( wrapper )
{
++v7;
v9 = *wrapper;
if ( *wrapper )
{
do
{
v7 += v9 == 44;
v9 = *++v8;
}
while ( *v8 );
}
}
v10 = (const char **)umalloc(8LL * (v7 + 2));
v11 = (const char *)wrapper;
v12 = v5;
if ( wrapper )
{
v13 = *wrapper;
if ( *wrapper )
{
v14 = wrapper + 1LL;
v15 = v5;
do
{
if ( v13 == 44 )
{
*(_BYTE *)(v14 - 1) = 0;
v10[v15] = v11;
v11 = (const char *)v14;
++v15;
}
v21 = v14++;
v13 = *(_BYTE *)(v14 - 1);
}
while ( v13 );
v12 = v15;
if ( v11 != (const char *)v21 )
{
v12 = v15 + 1;
v10[v15] = v11;
}
}
}
v22 = v12 + 1;
v23 = v12;
v10[v12] = (const char *)cmdpath_resolve(a1, &stat_loc);
v24 = *a2;
if ( *a2 )
{
v25 = v12 + 2;
do
{
v22 = v25;
v10[v25++ - 1] = v24;
v24 = (&a2[v25])[-v23 - 2];
}
while ( v24 );
}
v10[v22] = 0LL;
umask(orig_umask);
((void (__fastcall *)(const char *, const char **))stat_loc.__uptr)(*v10, v10);
die("execv(\"%s\"):", *v10);
goto LABEL_30;
}
if ( !v6 )
goto LABEL_6;
LABEL_30:
if ( wait((__WAIT_STATUS)&stat_loc) == -1 )
die("wait()");
if ( time_subcmds && gettimeofday(&v37, 0LL) < 0 )
{
v28 = _errno_location();
v29 = strerror(*v28);
fprintf(stderr, "gettimeofday(): %s\n", v29);
}
v26 = (__int64)stat_loc.__uptr & 0x7F;
if ( ((__int64)stat_loc.__uptr & 0x7F) != 0 || (v27 = BYTE1(stat_loc.__uptr), !BYTE1(stat_loc.__uptr)) )
{
if ( (char)(((__int64)stat_loc.__uptr & 0x7F) + 1) > 1 )
{
fprintf(stderr, "%s caught signal %d\n", *a1, (__int64)stat_loc.__uptr & 0x7F);
if ( a4 )
remove(a4);
exit(v26 + 128);
}
}
else
{
if ( a4 )
remove(a4);
v5 = v27;
if ( !a3 )
die("%s returned %d", *a1, v27);
}
if ( time_subcmds )
{
v30 = v37.tv_sec - tv.tv_sec;
v31 = v37.tv_usec - tv.tv_usec;
if ( v37.tv_usec - tv.tv_usec < 0 )
{
--v30;
v31 += 1000000LL;
}
printf("# %s %ld.%06ld\n", *a1, v30, v31);
}
return v5;
}

original_code:
static int runner(struct cmdpath *path, char **args, int return_ec, const char *to_remove)
{
 pid_t pid;
 struct timeval time_start, time_end;
 if(show){
  char *resolved = cmdpath_resolve(path, ((void *)0));
  int i;
  if(wrapper)
   fprintf(stderr, "WRAPPER='%s' ", wrapper);
  fprintf(stderr, "%s ", resolved);
  for(i = 0; args[i]; i++)
   fprintf(stderr, "%s ", args[i]);
  fputc('\n', stderr);
  free(resolved);
 }
 if(noop)
  return 0;
 if(time_subcmds && gettimeofday(&time_start, ((void *)0)) < 0)
  fprintf(stderr, "gettimeofday(): %s\n", strerror((*__errno_location ())));
 pid = fork();
 switch(pid){
  case -1:
   die("fork():");
  case 0:
  {
   int nargs = dynarray_nochk_count((void **)args);
   int i_in = 0, i_out = 0;
   char **argv;
   cmdpath_exec_fn *execfn;
   if(wrapper){
    char *p;
    nargs++;
    for(p = wrapper; *p; p++)
     nargs += *p == ',';
   }
   argv = umalloc((2 + nargs) * sizeof *argv);
   if(wrapper){
    char *p, *last;
    for(p = last = wrapper; *p; p++)
     if(*p == ','){
      *p = '\0';
      argv[i_out++] = last;
      last = p + 1;
     }
    if(last != p)
     argv[i_out++] = last;
   }
   argv[i_out++] = cmdpath_resolve(path, &execfn);
   while(args[i_in])
    argv[i_out++] = args[i_in++];
   argv[i_out++] = ((void *)0);
   umask(orig_umask);
   (*execfn)(argv[0], argv);
   die("execv(\"%s\"):", argv[0]);
  }
  default:
  {
   int status, i;
   if(wait(&status) == -1)
    die("wait()");
   if(time_subcmds && gettimeofday(&time_end, ((void *)0)) < 0)
    fprintf(stderr, "gettimeofday(): %s\n", strerror((*__errno_location ())));
   if((((status) & 0x7f) == 0) && (i = (((status) & 0xff00) >> 8)) != 0){
    if(to_remove)
     remove(to_remove);
    if(!return_ec)
     die("%s returned %d", path->path, i);
   }else if((((signed char) (((status) & 0x7f) + 1) >> 1) > 0)){
    int sig = ((status) & 0x7f);
    fprintf(stderr, "%s caught signal %d\n", path->path, sig);
    if(to_remove)
     remove(to_remove);
    exit(128 + sig);
   }
   if(time_subcmds){
    time_t secdiff = time_end.tv_sec - time_start.tv_sec;
    suseconds_t usecdiff = time_end.tv_usec - time_start.tv_usec;
    if(usecdiff < 0){
     secdiff--;
     usecdiff += 1000000L;
    }
    printf("# %s %ld.%06ld\n", path->path, (long)secdiff, (long)usecdiff);
   }
   return i;
  }
 }
}

canonical_original_code:
static int runner(struct cmdpath *path, char **args, int return_ec, char *to_remove)
{
 int pid;
 struct timeval time_start; struct timeval time_end;
 if(show){
  char *resolved = cmdpath_resolve(path, ((void *)0));
  int i;
  if(wrapper)
   fprintf(stderr, "WRAPPER='%s' ", wrapper);
  fprintf(stderr, "%s ", resolved);
  for(i = 0; args[i]; i++)
   fprintf(stderr, "%s ", args[i]);
  fputc('\n', stderr);
  free(resolved);
 }
 if(noop)
  return 0;
 if(time_subcmds && gettimeofday(&time_start, ((void *)0)) < 0)
  fprintf(stderr, "gettimeofday(): %s\n", strerror((*__errno_location ())));
 pid = fork();
 switch(pid){
  case -1:
   die("fork():");
  case 0:
  {
   int nargs = dynarray_nochk_count((void **)args);
   int i_in = 0; int i_out = 0;
   char **argv;
   int (*execfn)(char *, char *[]);
   if(wrapper){
    char *p;
    nargs++;
    for(p = wrapper; *p; p++)
     nargs += *p == ',';
   }
   argv = umalloc((2 + nargs) * sizeof *argv);
   if(wrapper){
    char *p; char *last;
    for(p = last = wrapper; *p; p++)
     if(*p == ','){
      *p = '\0';
      argv[i_out++] = last;
      last = p + 1;
     }
    if(last != p)
     argv[i_out++] = last;
   }
   argv[i_out++] = cmdpath_resolve(path, &execfn);
   while(args[i_in])
    argv[i_out++] = args[i_in++];
   argv[i_out++] = ((void *)0);
   umask(orig_umask);
   (*execfn)(argv[0], argv);
   die("execv(\"%s\"):", argv[0]);
  }
  default:
  {
   int status; int i;
   if(wait(&status) == -1)
    die("wait()");
   if(time_subcmds && gettimeofday(&time_end, ((void *)0)) < 0)
    fprintf(stderr, "gettimeofday(): %s\n", strerror((*__errno_location ())));
   if((((status) & 0x7f) == 0) && (i = (((status) & 0xff00) >> 8)) != 0){
    if(to_remove)
     remove(to_remove);
    if(!return_ec)
     die("%s returned %d", path->path, i);
   }else if((((char) (((status) & 0x7f) + 1) >> 1) > 0)){
    int sig = ((status) & 0x7f);
    fprintf(stderr, "%s caught signal %d\n", path->path, sig);
    if(to_remove)
     remove(to_remove);
    exit(128 + sig);
   }
   if(time_subcmds){
    long secdiff = time_end.tv_sec - time_start.tv_sec;
    long usecdiff = time_end.tv_usec - time_start.tv_usec;
    if(usecdiff < 0){
     secdiff--;
     usecdiff += 1000000L;
    }
    printf("# %s %ld.%06ld\n", path->path, (long)secdiff, (long)usecdiff);
   }
   return i;
  }
 }
}

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

variable_types:
args
char **

variable_types: pid int

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types:
resolved
char *

variable_types: nargs int

variable_types:
argv
char **

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

variable_types:
p
char *

variable_types:
last
char *

variable_types: status int

variable_types: sig int

variable_types: secdiff long

variable_types: usecdiff long

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


decompiled_code:
void __fastcall ucc_ext_cmds_show(int a1)
{
show = a1;
}

canonical_decompiled_code:
void __fastcall func2(int a1)
{
show = a1;
}

original_code:
void ucc_ext_cmds_show(int s)
{ show = s; }

variable_types: s int


decompiled_code:
void __fastcall ucc_ext_cmds_noop(int a1)
{
noop = a1;
}

canonical_decompiled_code:
void __fastcall func3(int a1)
{
noop = a1;
}

original_code:
void ucc_ext_cmds_noop(int n)
{ noop = n; }

variable_types: n int


execute

decompiled_code:
__int64 __fastcall execute(const char *a1, const char **a2)
{
const char *v3; // [rsp+0h] [rbp-18h] BYREF
int v4; // [rsp+8h] [rbp-10h]

v3 = a1;
v4 = 1;
return runner(&v3, a2, 0, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, const char **a2)
{
const char *v3; // [rsp+0h] [rbp-18h] BYREF
int v4; // [rsp+8h] [rbp-10h]

v3 = a1;
v4 = 1;
return func0(&v3, a2, 0, 0LL);
}

original_code:
void execute(char *path, char **args)
{
 struct cmdpath cmdpath;
 cmdpath.path = path;
 cmdpath.type = USE_PATH;
 runner(&cmdpath, args, 0, ((void *)0));
}

variable_types:
path
char *

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


original_code:
void rename_or_move(char *old, char *new)
{
 int len, i;
 char *cmd, *p;
 char *args[] = {
  "cat", old, ">", new, ((void *)0)
 };
 char *fixed[3];
 struct cmdpath shpath;
 if(!strcmp(old, new))
  return;
 for(i = 0, len = 1; args[i]; i++)
  len += strlen(args[i]) + 1;
 p = cmd = umalloc(len);
 for(i = 0; args[i]; i++)
  p += sprintf(p, "%s ", args[i]);
 fixed[0] = "-c";
 fixed[1] = cmd;
 fixed[2] = ((void *)0);
 shpath.path = "sh";
 shpath.type = USE_PATH;
 runner(&shpath, fixed, 0, new);
 free(cmd);
}

canonical_original_code:
void rename_or_move(char *old, char *new)
{
 int len; int i;
 char *cmd; char *p;
 char *args[] = {
  "cat", old, ">", new, ((void *)0)
 };
 char *fixed[3];
 struct cmdpath shpath;
 if(!strcmp(old, new))
  return;
 for(i = 0, len = 1; args[i]; i++)
  len += strlen(args[i]) + 1;
 p = cmd = umalloc(len);
 for(i = 0; args[i]; i++)
  p += sprintf(p, "%s ", args[i]);
 fixed[0] = "-c";
 fixed[1] = cmd;
 fixed[2] = ((void *)0);
 shpath.path = "sh";
 shpath.type = USE_PATH;
 runner(&shpath, fixed, 0, new);
 free(cmd);
}

variable_types:
old
char *

variable_types:
new
char *

variable_types: len int

variable_types: i int

variable_types:
cmd
char *

variable_types:
args
char *[]

variable_types:
fixed
char *[3]

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


compile

decompiled_code:
__int64 __fastcall compile(__int64 a1, const char *a2, __int64 a3, int a4)
{
const char *v7[7]; // [rsp+0h] [rbp-38h] BYREF

cmdpath_initrelative(v7, "cc1", "../cc1/cc1");
return runner_single_arg(v7, a1, a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2, __int64 a3, int a4)
{
const char *v7[7]; // [rsp+0h] [rbp-38h] BYREF

cmdpath_initrelative(v7, "cc1", "../cc1/cc1");
return func1(v7, a1, a2, a3, a4);
}

original_code:
int compile(char *in, const char *out, char **args, int return_ec)
{
 struct cmdpath cc1path;
 cmdpath_initrelative(&cc1path, "cc1", "../cc1/cc1");
 return runner_single_arg(&cc1path, in, out, args, return_ec);
}

canonical_original_code:
int compile(char *in, char *out, char **args, int return_ec)
{
 struct cmdpath cc1path;
 cmdpath_initrelative(&cc1path, "cc1", "../cc1/cc1");
 return runner_single_arg(&cc1path, in, out, args, return_ec);
}

variable_types:
in
char *

variable_types:
out
char *

variable_types:
args
char **


decompiled_code:
__int64 __fastcall dynarray_nochk_count(_QWORD *a1)
{
__int64 result; // rax

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

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

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

original_code:
size_t dynarray_nochk_count(void **ar)
{
 size_t len = 0;
 if(!ar)
  return 0;
 while(ar[len])
  len++;
 return len;
}

canonical_original_code:
unsigned long dynarray_nochk_count(void **ar)
{
 unsigned long len = 0;
 if(!ar)
  return 0;
 while(ar[len])
  len++;
 return len;
}

variable_types:
ar
void **

variable_types:
len
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall dynarray_nochk_pop(_QWORD **a1)
{
__int64 v1; // r12
char *v2; // rbp
__int64 v3; // rax
char *v4; // rdx

v2 = (char *)*a1;
v3 = dynarray_nochk_count(*a1);
if ( !v3 )
{
ice("dynarray.c", 88LL, "dynarray_nochk_pop", "dynarray_nochk_pop(): empty array");
goto LABEL_5;
}
v4 = &v2[8 * v3 - 8];
v1 = *(_QWORD *)v4;
*(_QWORD *)v4 = 0LL;
if ( v3 == 1 )
{
LABEL_5:
free(v2);
*a1 = 0LL;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD **a1)
{
__int64 v1; // r12
char *v2; // rbp
__int64 v3; // rax
char *v4; // rdx

v2 = (char *)*a1;
v3 = func0(*a1);
if ( !v3 )
{
ice("dynarray.c", 88LL, "dynarray_nochk_pop", "dynarray_nochk_pop(): empty array");
goto LABEL_5;
}
v4 = &v2[8 * v3 - 8];
v1 = *(_QWORD *)v4;
*(_QWORD *)v4 = 0LL;
if ( v3 == 1 )
{
LABEL_5:
free(v2);
*a1 = 0LL;
}
return v1;
}

original_code:
void *dynarray_nochk_pop(void ***par)
{
 void **ar = *par;
 void *r;
 size_t n;
 n = dynarray_nochk_count(ar);
 do if(!(n > 0)) ice("dynarray.c", 88, __func__, "dynarray_nochk_pop(): empty array"); while(0);
 r = ar[n - 1];
 ar[n - 1] = ((void *)0);
 if(n == 1){
  free(ar);
  *par = ((void *)0);
 }
 return r;
}

canonical_original_code:
void *dynarray_nochk_pop(void ***par)
{
 void **ar = *par;
 void *r;
 unsigned long n;
 n = dynarray_nochk_count(ar);
 do if(!(n > 0)) ice("dynarray.c", 88, __func__, "dynarray_nochk_pop(): empty array"); while(0);
 r = ar[n - 1];
 ar[n - 1] = ((void *)0);
 if(n == 1){
  free(ar);
  *par = ((void *)0);
 }
 return r;
}

variable_types:
par
void ***

variable_types:
r
void *

variable_types:
n
unsigned long

return_type: void *


decompiled_code:
void __fastcall dynarray_nochk_free(void **a1, void (*a2)(void))
{
_QWORD *v2; // rbx

v2 = *a1;
if ( *a1 )
{
if ( a2 && *v2 )
{
do
{
a2();
++v2;
}
while ( *v2 );
}
free(*a1);
*a1 = 0LL;
}
}

original_code:
void dynarray_nochk_free(void ***par, void (*f)(void *))
{
 void **ar = *par;
 if(ar){
  if(f)
   while(*ar){
    f(*ar);
    ar++;
   }
  free(*par);
  *par = ((void *)0);
 }
}

variable_types:
f
void (*)(void *)


decompiled_code:
void __fastcall dynarray_nochk_add_tmparray(_QWORD **a1, _QWORD *a2)
{
void *v2; // [rsp+8h] [rbp-10h] BYREF

v2 = a2;
dynarray_nochk_add_array(a1, a2);
dynarray_nochk_free(&v2, 0LL);
}

canonical_decompiled_code:
void __fastcall func9(_QWORD **a1, _QWORD *a2)
{
void *v2; // [rsp+8h] [rbp-10h] BYREF

v2 = a2;
func8(a1, a2);
func7(&v2, 0LL);
}

original_code:
void dynarray_nochk_add_tmparray(void ***par, void **ar2)
{
 dynarray_nochk_add_array(par, ar2);
 dynarray_nochk_free(&ar2, ((void *)0));
}


decompiled_code:
char *__fastcall expand_digraphs(char *a1)
{
char *v1; // r13
const char *v2; // r12
size_t v3; // rax
char *i; // rbx

v1 = (char *)&unk_10E8;
v2 = (const char *)&unk_F0C;
do
{
for ( i = a1; ; memmove(i + 1, i + 2, v3 + 1) )
{
i = strstr(i, v2);
if ( !i )
break;
*i = *v1;
v3 = strlen(i + 2);
}
v1 += 16;
v2 = (const char *)*((_QWORD *)v1 - 1);
}
while ( v2 );
return a1;
}

canonical_decompiled_code:
char *__fastcall func0(char *a1)
{
char *v1; // r13
const char *v2; // r12
size_t v3; // rax
char *i; // rbx

v1 = (char *)&unk_10E8;
v2 = (const char *)&unk_F0C;
do
{
for ( i = a1; ; memmove(i + 1, i + 2, v3 + 1) )
{
i = strstr(i, v2);
if ( !i )
break;
*i = *v1;
v3 = strlen(i + 2);
}
v1 += 16;
v2 = (const char *)*((_QWORD *)v1 - 1);
}
while ( v2 );
return a1;
}

original_code:
static char *expand_digraphs(char *line)
{
 static const struct
 {
  const char *from;
  char to;
 } map[] = {
  { "<:", '[' },
  { ":>", ']' },
  { "<%", '{' },
  { "%>", '}' },
  { "%:", '#' },
  { 0, 0 }
 };
 int i;
 for(i = 0; map[i].from; i++){
  char *pos = line;
  while((pos = strstr(pos, map[i].from))){
   *pos = map[i].to;
   memmove(pos + 1, pos + 2, strlen(pos + 2) + 1);
  }
 }
 return line;
}

canonical_original_code:
static char *expand_digraphs(char *line)
{
 static struct { char *from; char to; } map[] = {
  { "<:", '[' },
  { ":>", ']' },
  { "<%", '{' },
  { "%>", '}' },
  { "%:", '#' },
  { 0, 0 }
 };
 int i;
 for(i = 0; map[i].from; i++){
  char *pos = line;
  while((pos = strstr(pos, map[i].from))){
   *pos = map[i].to;
   memmove(pos + 1, pos + 2, strlen(pos + 2) + 1);
  }
 }
 return line;
}

variable_types:
line
char *

variable_types:
map
struct { char *from; char to; } []

variable_types:
pos
char *


decompiled_code:
char *__fastcall expand_trigraphs(char *haystack)
{
char *v1; // r12
char *i; // rbx
size_t v3; // rax
char *v4; // rax
char *v5; // rdi
char v6; // si
__int64 v7; // rax
char v8; // dl

v1 = haystack;
LABEL_3:
for ( i = haystack; ; memmove(i, v5 + 3, v3 + 1) )
{
v4 = strstr(i, "??");
v5 = v4;
if ( !v4 )
break;
i = v4 + 1;
v6 = v4[2];
v7 = 0LL;
v8 = 40;
while ( v6 != v8 )
{
++v7;
v8 = map_0[2 * v7];
if ( !v8 )
goto LABEL_3;
}
*v5 = byte_10A1[2 * (int)v7];
v3 = strlen(v5 + 3);
}
return v1;
}

canonical_decompiled_code:
char *__fastcall func1(char *haystack)
{
char *v1; // r12
char *i; // rbx
size_t v3; // rax
char *v4; // rax
char *v5; // rdi
char v6; // si
__int64 v7; // rax
char v8; // dl

v1 = haystack;
LABEL_3:
for ( i = haystack; ; memmove(i, v5 + 3, v3 + 1) )
{
v4 = strstr(i, "??");
v5 = v4;
if ( !v4 )
break;
i = v4 + 1;
v6 = v4[2];
v7 = 0LL;
v8 = 40;
while ( v6 != v8 )
{
++v7;
v8 = map_0[2 * v7];
if ( !v8 )
goto LABEL_3;
}
*v5 = byte_10A1[2 * (int)v7];
v3 = strlen(v5 + 3);
}
return v1;
}

original_code:
static char *expand_trigraphs(char *line)
{
 static const struct
 {
  char from, to;
 } map[] = {
  { '(', '[' },
  { ')', ']' },
  { '<', '{' },
  { '>', '}' },
  { '=', '#' },
  { '/', '\\' },
  { '\'', '^' },
  { '!', '|' },
  { '-', '~' },
  { 0, 0 }
 };
 int i;
 char *anchor = line;
 for(;;){
  char *qmark = strstr(anchor, "??");
  if(!qmark)
   break;
  anchor = qmark + 1;
  for(i = 0; map[i].from; i++){
   if(map[i].from == qmark[2]){
    qmark[0] = map[i].to;
    memmove(qmark + 1, qmark + 3, strlen(qmark + 3) + 1);
    break;
   }
  }
 }
 return line;
}

canonical_original_code:
static char *expand_trigraphs(char *line)
{
 static struct { char from; } map[] = {
  { '(', '[' },
  { ')', ']' },
  { '<', '{' },
  { '>', '}' },
  { '=', '#' },
  { '/', '\\' },
  { '\'', '^' },
  { '!', '|' },
  { '-', '~' },
  { 0, 0 }
 };
 int i;
 char *anchor = line;
 for(;;){
  char *qmark = strstr(anchor, "??");
  if(!qmark)
   break;
  anchor = qmark + 1;
  for(i = 0; map[i].from; i++){
   if(map[i].from == qmark[2]){
    qmark[0] = map[i].to;
    memmove(qmark + 1, qmark + 3, strlen(qmark + 3) + 1);
    break;
   }
  }
 }
 return line;
}

variable_types:
map
struct { char from; } []

variable_types:
anchor
char *

variable_types:
qmark
char *


decompiled_code:
char *__fastcall strip_comment(char *s)
{
char *v1; // rbp
char v2; // r12
char v3; // si
char *i; // rbx
char *v5; // rax
__int64 v6; // rax
int v8; // er12

v1 = s;
v2 = *(_BYTE *)str_spc_skip();
if ( strip_in_block == 1 )
{
strip_in_block = 3;
}
else if ( strip_in_block == 2 )
{
strip_in_block = 0;
}
v3 = *s;
if ( *s )
{
for ( i = s; ; i = v5 )
{
if ( (strip_in_block & 0xFFFFFFFD) == 1 )
{
if ( v3 == 42 && i[1] == 47 )
{
strip_in_block = 2;
if ( strip_comments )
goto LABEL_26;
*i++ = 32;
LABEL_10:
*i = 32;
goto LABEL_11;
}
if ( !strip_comments )
goto LABEL_10;
}
else if ( v3 == 34 || v3 == 39 )
{
v6 = str_quotefin2(i + 1, (unsigned int)v3);
if ( v6 )
{
i = (char *)v6;
}
else
{
if ( (*((_BYTE *)&wmode + 1) & 0x10) != 0 )
{
--loc_tok;
warn_at(0LL, "no terminating quote to string");
++loc_tok;
}
i = &i[strlen(i) - 1];
}
}
else if ( v3 == 47 )
{
if ( cpp_std > 1u && i[1] == 47 )
{
if ( strip_comments == 1 )
{
if ( v2 == 35 )
goto LABEL_38;
}
else if ( strip_comments != 2 )
{
if ( strip_comments )
return v1;
LABEL_38:
*i = 0;
return v1;
}
v8 = strlen(s);
v1 = (char *)urealloc1(s, (unsigned int)(v8 + 3));
v1[(_DWORD)i - (_DWORD)s + 1] = 42;
strcpy(&v1[v8], "*/");
return v1;
}
if ( i[1] == 42 )
{
strip_in_block = 1;
if ( strip_comments && (strip_comments != 1 || v2 != 35) )
{
LABEL_26:
v5 = i + 1;
v3 = i[1];
continue;
}
i[1] = 32;
*i++ = 32;
}
}
LABEL_11:
v5 = i + 1;
v3 = i[1];
if ( !v3 )
return v1;
}
}
return v1;
}

canonical_decompiled_code:
char *__fastcall func2(char *s)
{
char *v1; // rbp
char v2; // r12
char v3; // si
char *i; // rbx
char *v5; // rax
__int64 v6; // rax
int v8; // er12

v1 = s;
v2 = *(_BYTE *)str_spc_skip();
if ( strip_in_block == 1 )
{
strip_in_block = 3;
}
else if ( strip_in_block == 2 )
{
strip_in_block = 0;
}
v3 = *s;
if ( *s )
{
for ( i = s; ; i = v5 )
{
if ( (strip_in_block & 0xFFFFFFFD) == 1 )
{
if ( v3 == 42 && i[1] == 47 )
{
strip_in_block = 2;
if ( strip_comments )
goto LABEL_26;
*i++ = 32;
LABEL_10:
*i = 32;
goto LABEL_11;
}
if ( !strip_comments )
goto LABEL_10;
}
else if ( v3 == 34 || v3 == 39 )
{
v6 = str_quotefin2(i + 1, (unsigned int)v3);
if ( v6 )
{
i = (char *)v6;
}
else
{
if ( (*((_BYTE *)&wmode + 1) & 0x10) != 0 )
{
--loc_tok;
warn_at(0LL, "no terminating quote to string");
++loc_tok;
}
i = &i[strlen(i) - 1];
}
}
else if ( v3 == 47 )
{
if ( cpp_std > 1u && i[1] == 47 )
{
if ( strip_comments == 1 )
{
if ( v2 == 35 )
goto LABEL_38;
}
else if ( strip_comments != 2 )
{
if ( strip_comments )
return v1;
LABEL_38:
*i = 0;
return v1;
}
v8 = strlen(s);
v1 = (char *)urealloc1(s, (unsigned int)(v8 + 3));
v1[(_DWORD)i - (_DWORD)s + 1] = 42;
strcpy(&v1[v8], "*/");
return v1;
}
if ( i[1] == 42 )
{
strip_in_block = 1;
if ( strip_comments && (strip_comments != 1 || v2 != 35) )
{
LABEL_26:
v5 = i + 1;
v3 = i[1];
continue;
}
i[1] = 32;
*i++ = 32;
}
}
LABEL_11:
v5 = i + 1;
v3 = i[1];
if ( !v3 )
return v1;
}
}
return v1;
}

original_code:
static char *strip_comment(char *line)
{
 const int is_directive = *str_spc_skip(line) == '#';
 char *s;
 if(strip_in_block == IN_BLOCK_BEGIN)
  strip_in_block = IN_BLOCK_FULL;
 else if(strip_in_block == IN_BLOCK_END)
  strip_in_block = NOT_IN_BLOCK;
 for(s = line; *s; s++){
  if(strip_in_block == IN_BLOCK_FULL || strip_in_block == IN_BLOCK_BEGIN){
   const int clear_comments = (strip_comments == STRIP_ALL);
   if(*s == '*' && s[1] == '/'){
    strip_in_block = IN_BLOCK_END;
    if(clear_comments)
     *s++ = ' ';
   }
   if(clear_comments)
    *s = ' ';
  }else if(*s == '"' || *s == '\''){
   char *end = str_quotefin2(s + 1, *s);
   if(!end){
    do{ if(WQUOTE == 0 || WQUOTE & wmode){ loc_tok.line--; warn_at(((void *)0), "no terminating quote to string"); loc_tok.line++; } }while(0);
    s = strchr(s, '\0') - 1;
   }else{
    s = end;
   }
  }else if(*s == '/'){
   if(cpp_std >= STD_C99 && s[1] == '/'){
    switch(strip_comments){
     case STRIP_EXCEPT_DIRECTIVE:
      if(is_directive)
       goto strip_1line;
     case STRIP_NONE:
     {
      const unsigned pos_slash = s - line;
      const unsigned len = strlen(line);
      line = urealloc1(line, len + 2 + 1);
      s = line + pos_slash;
      s[1] = '*';
      strcpy(line + len, "*/");
      break;
     }
strip_1line:
     case STRIP_ALL:
      *s = '\0';
      break;
    }
    break;
   }else if(s[1] == '*'){
    strip_in_block = IN_BLOCK_BEGIN;
    switch(strip_comments){
     case STRIP_EXCEPT_DIRECTIVE:
      if(!is_directive)
       break;
     case STRIP_ALL:
      *s = s[1] = ' ';
      s++;
     case STRIP_NONE:
      break;
    }
   }
  }
 }
 return line;
}

canonical_original_code:
static char *strip_comment(char *line)
{
 int is_directive = *str_spc_skip(line) == '#';
 char *s;
 if(strip_in_block == IN_BLOCK_BEGIN)
  strip_in_block = IN_BLOCK_FULL;
 else if(strip_in_block == IN_BLOCK_END)
  strip_in_block = NOT_IN_BLOCK;
 for(s = line; *s; s++){
  if(strip_in_block == IN_BLOCK_FULL || strip_in_block == IN_BLOCK_BEGIN){
   int clear_comments = (strip_comments == STRIP_ALL);
   if(*s == '*' && s[1] == '/'){
    strip_in_block = IN_BLOCK_END;
    if(clear_comments)
     *s++ = ' ';
   }
   if(clear_comments)
    *s = ' ';
  }else if(*s == '"' || *s == '\''){
   char *end = str_quotefin2(s + 1, *s);
   if(!end){
    do{ if(WQUOTE == 0 || WQUOTE & wmode){ loc_tok.line--; warn_at(((void *)0), "no terminating quote to string"); loc_tok.line++; } }while(0);
    s = strchr(s, '\0') - 1;
   }else{
    s = end;
   }
  }else if(*s == '/'){
   if(cpp_std >= STD_C99 && s[1] == '/'){
    switch(strip_comments){
     case STRIP_EXCEPT_DIRECTIVE:
      if(is_directive)
       goto strip_1line;
     case STRIP_NONE:
     {
      unsigned int pos_slash = s - line;
      unsigned int len = strlen(line);
      line = urealloc1(line, len + 2 + 1);
      s = line + pos_slash;
      s[1] = '*';
      strcpy(line + len, "*/");
      break;
     }
strip_1line:
     case STRIP_ALL:
      *s = '\0';
      break;
    }
    break;
   }else if(s[1] == '*'){
    strip_in_block = IN_BLOCK_BEGIN;
    switch(strip_comments){
     case STRIP_EXCEPT_DIRECTIVE:
      if(!is_directive)
       break;
     case STRIP_ALL:
      *s = s[1] = ' ';
      s++;
     case STRIP_NONE:
      break;
    }
   }
  }
 }
 return line;
}

variable_types:
s
char *

variable_types:
end
char *

variable_types:
len
unsigned int


decompiled_code:
void *__fastcall filter_macros(void *ptr)
{
_BYTE *v1; // rbp

if ( *(_BYTE *)ptr == 35 )
{
v1 = ptr;
LABEL_8:
parse_directive(v1 + 1);
free(ptr);
return 0LL;
}
v1 = (_BYTE *)str_spc_skip();
if ( *v1 == 35 )
{
if ( *(_BYTE *)ptr != 35 && (wmode & 1) != 0 )
{
--loc_tok;
warn_at(0LL, "'#' for directive isn't in the first column");
++loc_tok;
}
goto LABEL_8;
}
if ( !(unsigned int)parse_should_noop() )
return (void *)eval_expand_macros(ptr);
*(_BYTE *)ptr = 0;
return ptr;
}

canonical_decompiled_code:
void *__fastcall func3(void *ptr)
{
_BYTE *v1; // rbp

if ( *(_BYTE *)ptr == 35 )
{
v1 = ptr;
LABEL_8:
parse_directive(v1 + 1);
free(ptr);
return 0LL;
}
v1 = (_BYTE *)str_spc_skip();
if ( *v1 == 35 )
{
if ( *(_BYTE *)ptr != 35 && (wmode & 1) != 0 )
{
--loc_tok;
warn_at(0LL, "'#' for directive isn't in the first column");
++loc_tok;
}
goto LABEL_8;
}
if ( !(unsigned int)parse_should_noop() )
return (void *)eval_expand_macros(ptr);
*(_BYTE *)ptr = 0;
return ptr;
}

original_code:
static char *filter_macros(char *line)
{
 char *hash = line;
 if(*hash == '#' || *(hash = str_spc_skip(hash)) == '#'){
  if(*line != '#')
   do{ if(WTRADITIONAL == 0 || WTRADITIONAL & wmode){ loc_tok.line--; warn_at(((void *)0), "'#' for directive isn't in the first column"); loc_tok.line++; } }while(0);
  parse_directive(hash + 1);
  free(line);
  return ((void *)0);
 }else{
  if(parse_should_noop())
   *line = '\0';
  else
   line = eval_expand_macros(line);
  return line;
 }
}

variable_types:
hash
char *


decompiled_code:
void __fastcall preproc_emit_line_info(unsigned int a1, const char *a2, int a3)
{
unsigned int v3; // eax
unsigned int v4; // eax
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = a3;
if ( !no_output && option_line_info )
{
printf("# %d \"%s\"", a1, a2);
while ( v5[0] )
{
v3 = extractbottombit(v5);
v4 = log2i(v3);
printf(" %d", v4);
}
putchar(10);
}
}

canonical_decompiled_code:
void __fastcall func5(unsigned int a1, const char *a2, int a3)
{
unsigned int v3; // eax
unsigned int v4; // eax
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = a3;
if ( !no_output && option_line_info )
{
printf("# %d \"%s\"", a1, a2);
while ( v5[0] )
{
v3 = extractbottombit(v5);
v4 = log2i(v3);
printf(" %d", v4);
}
putchar(10);
}
}

original_code:
void preproc_emit_line_info(int lineno, const char *fname, enum lineinfo lineinfo)
{
 unsigned lineinfobits = lineinfo;
 if(no_output || !option_line_info)
  return;
 printf("# %d \"%s\"", lineno, fname);
 while(lineinfobits){
  unsigned bit = extractbottombit(&lineinfobits);
  int n = log2i(bit);
  printf(" %d", n);
 }
 putchar('\n');
}

canonical_original_code:
void preproc_emit_line_info(int lineno, char *fname, enum lineinfo lineinfo)
{
 unsigned int lineinfobits = lineinfo;
 if(no_output || !option_line_info)
  return;
 printf("# %d \"%s\"", lineno, fname);
 while(lineinfobits){
  unsigned int bit = extractbottombit(&lineinfobits);
  int n = log2i(bit);
  printf(" %d", n);
 }
 putchar('\n');
}

variable_types: lineno int

variable_types:
fname
char *

variable_types: enum lineinfo { LINEINFO_START_OF_FILE=expr, LINEINFO_RETURN_TO_FILE=expr, LINEINFO_SYSHEADER=expr }

variable_types:
lineinfobits
unsigned int

variable_types:
bit
unsigned int

variable_types: n int


decompiled_code:
void __fastcall preproc_emit_line_info_top(int a1)
{
preproc_emit_line_info(
file_stack[3 * file_stack_idx + 2],
(const char *)file_stack[3 * file_stack_idx + 1],
a1 | (8 * (HIDWORD(file_stack[3 * file_stack_idx + 2]) != 0)));
}

canonical_decompiled_code:
void __fastcall func6(int a1)
{
func5(
file_stack[3 * file_stack_idx + 2],
(const char *)file_stack[3 * file_stack_idx + 1],
a1 | (8 * (HIDWORD(file_stack[3 * file_stack_idx + 2]) != 0)));
}

original_code:
static void preproc_emit_line_info_top(enum lineinfo lineinfo)
{
 preproc_emit_line_info(
   file_stack[file_stack_idx].line_no,
   file_stack[file_stack_idx].fname,
   lineinfo | (file_stack[file_stack_idx].is_sysh ? LINEINFO_SYSHEADER : 0));
}

user_defined_types: enum lineinfo { LINEINFO_START_OF_FILE=expr, LINEINFO_RETURN_TO_FILE=expr, LINEINFO_SYSHEADER=expr }


decompiled_code:
void preproc_pop()
{
if ( file_stack_idx )
{
free((void *)file_stack[3 * file_stack_idx + 1]);
loc_tok = file_stack[3 * --file_stack_idx + 2];
set_current_fname(file_stack[3 * file_stack_idx + 1]);
preproc_emit_line_info_top(4);
}
else
{
ice("preproc.c", 119LL, "preproc_pop", "file stack idx = 0 on pop()");
read_line();
}
}

canonical_decompiled_code:
void func7()
{
if ( file_stack_idx )
{
free((void *)file_stack[3 * file_stack_idx + 1]);
loc_tok = file_stack[3 * --file_stack_idx + 2];
set_current_fname(file_stack[3 * file_stack_idx + 1]);
func6(4);
}
else
{
ice("preproc.c", 119LL, "preproc_pop", "file stack idx = 0 on pop()");
func8();
}
}

original_code:
static void preproc_pop(void)
{
 if(!file_stack_idx)
  ice("preproc.c", 119, __func__, "file stack idx = 0 on pop()");
 free(file_stack[file_stack_idx].fname);
 file_stack_idx--;
 loc_tok.line = file_stack[file_stack_idx].line_no;
 set_current_fname(file_stack[file_stack_idx].fname);
 preproc_emit_line_info_top(LINEINFO_RETURN_TO_FILE);
}

canonical_original_code:
static void preproc_pop()
{
 if(!file_stack_idx)
  ice("preproc.c", 119, __func__, "file stack idx = 0 on pop()");
 free(file_stack[file_stack_idx].fname);
 file_stack_idx--;
 loc_tok.line = file_stack[file_stack_idx].line_no;
 set_current_fname(file_stack[file_stack_idx].fname);
 preproc_emit_line_info_top(LINEINFO_RETURN_TO_FILE);
}


decompiled_code:
char *__fastcall splice_lines(_DWORD *a1)
{
char *v1; // rax
char *v2; // rbx
char *v3; // rax
char *v4; // rbp
char *v5; // r13
char *v6; // rax
const char *v7; // rax
char *v8; // r13
signed __int64 v9; // rbp
size_t v10; // rax

if ( n_nls_3 )
{
--n_nls_3;
v2 = (char *)ustrdup(&unk_FB8);
}
else
{
v1 = (char *)read_line();
v2 = v1;
if ( v1 )
{
if ( option_trigraphs )
v2 = expand_trigraphs(v1);
v3 = strrchr(v2, 92);
v4 = v3;
if ( v3 )
{
v5 = v3 + 1;
v6 = (char *)str_spc_skip(v3 + 1);
if ( !*v6 )
{
if ( v5 < v6 && (*((_BYTE *)&wmode + 1) & 0x40) != 0 )
{
--loc_tok;
warn_at(0LL, "backslash and newline separated by space");
++loc_tok;
}
v7 = (const char *)splice_lines(a1);
v8 = (char *)v7;
*v4 = 0;
if ( v7 )
{
v9 = v4 - v2;
v10 = strlen(v7);
++n_nls_3;
v2 = (char *)urealloc1(v2, v9 + v10 + 1);
strcpy(&v2[v9], v8);
free(v8);
}
else
{
if ( (*((_BYTE *)&wmode + 1) & 4) != 0 )
{
--loc_tok;
warn_at(0LL, "backslash-escape at eof");
++loc_tok;
}
*a1 = 1;
}
}
}
}
else
{
*a1 = 1;
}
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func9(_DWORD *a1)
{
char *v1; // rax
char *v2; // rbx
char *v3; // rax
char *v4; // rbp
char *v5; // r13
char *v6; // rax
const char *v7; // rax
char *v8; // r13
signed __int64 v9; // rbp
size_t v10; // rax

if ( n_nls_3 )
{
--n_nls_3;
v2 = (char *)ustrdup(&unk_FB8);
}
else
{
v1 = (char *)func8();
v2 = v1;
if ( v1 )
{
if ( option_trigraphs )
v2 = func1(v1);
v3 = strrchr(v2, 92);
v4 = v3;
if ( v3 )
{
v5 = v3 + 1;
v6 = (char *)str_spc_skip(v3 + 1);
if ( !*v6 )
{
if ( v5 < v6 && (*((_BYTE *)&wmode + 1) & 0x40) != 0 )
{
--loc_tok;
warn_at(0LL, "backslash and newline separated by space");
++loc_tok;
}
v7 = (const char *)func9(a1);
v8 = (char *)v7;
*v4 = 0;
if ( v7 )
{
v9 = v4 - v2;
v10 = strlen(v7);
++n_nls_3;
v2 = (char *)urealloc1(v2, v9 + v10 + 1);
strcpy(&v2[v9], v8);
free(v8);
}
else
{
if ( (*((_BYTE *)&wmode + 1) & 4) != 0 )
{
--loc_tok;
warn_at(0LL, "backslash-escape at eof");
++loc_tok;
}
*a1 = 1;
}
}
}
}
else
{
*a1 = 1;
}
}
return v2;
}

original_code:
static char *splice_lines(int *peof)
{
 static int n_nls;
 char *line;
 char *last_backslash;
 int splice = 0;
 if(n_nls){
  n_nls--;
  return ustrdup("");
 }
 line = read_line();
 if(!line){
  *peof = 1;
  return ((void *)0);
 }
 if(option_trigraphs)
  line = expand_trigraphs(line);
 last_backslash = strrchr(line, '\\');
 if(last_backslash){
  char *i;
  i = str_spc_skip(last_backslash + 1);
  if(*i == '\0'){
   splice = 1;
   if(i > last_backslash + 1){
    do{ if(WBACKSLASH_SPACE_NEWLINE == 0 || WBACKSLASH_SPACE_NEWLINE & wmode){ loc_tok.line--; warn_at(((void *)0), "backslash and newline separated by space"); loc_tok.line++; } }while(0);
   }
  }
 }
 if(splice){
  char *next = splice_lines(peof);
  *last_backslash = '\0';
  if(next){
   const size_t this_len = last_backslash - line;
   const size_t next_len = strlen(next);
   n_nls++;
   line = urealloc1(line, this_len + next_len + 1);
   strcpy(line + this_len, next);
   free(next);
  }else{
   do{ if(WFINALESCAPE == 0 || WFINALESCAPE & wmode){ loc_tok.line--; warn_at(((void *)0), "backslash-escape at eof"); loc_tok.line++; } }while(0);
   *peof = 1;
  }
 }
 return line;
}

canonical_original_code:
static char *splice_lines(int *peof)
{
 static int n_nls;
 char *line;
 char *last_backslash;
 int splice = 0;
 if(n_nls){
  n_nls--;
  return ustrdup("");
 }
 line = read_line();
 if(!line){
  *peof = 1;
  return ((void *)0);
 }
 if(option_trigraphs)
  line = expand_trigraphs(line);
 last_backslash = strrchr(line, '\\');
 if(last_backslash){
  char *i;
  i = str_spc_skip(last_backslash + 1);
  if(*i == '\0'){
   splice = 1;
   if(i > last_backslash + 1){
    do{ if(WBACKSLASH_SPACE_NEWLINE == 0 || WBACKSLASH_SPACE_NEWLINE & wmode){ loc_tok.line--; warn_at(((void *)0), "backslash and newline separated by space"); loc_tok.line++; } }while(0);
   }
  }
 }
 if(splice){
  char *next = splice_lines(peof);
  *last_backslash = '\0';
  if(next){
   unsigned long this_len = last_backslash - line;
   unsigned long next_len = strlen(next);
   n_nls++;
   line = urealloc1(line, this_len + next_len + 1);
   strcpy(line + this_len, next);
   free(next);
  }else{
   do{ if(WFINALESCAPE == 0 || WFINALESCAPE & wmode){ loc_tok.line--; warn_at(((void *)0), "backslash-escape at eof"); loc_tok.line++; } }while(0);
   *peof = 1;
  }
 }
 return line;
}

variable_types:
peof
int *

variable_types: splice int

variable_types:
i
char *

variable_types:
next
char *


decompiled_code:
_BOOL8 preproc_in_include()
{
return file_stack_idx > 0;
}

canonical_decompiled_code:
_BOOL8 func10()
{
return file_stack_idx > 0;
}

original_code:
int preproc_in_include(void)
{
 return file_stack_idx > 0;
}

canonical_original_code:
int preproc_in_include()
{
 return file_stack_idx > 0;
}


preprocess

decompiled_code:
__int64 preprocess()
{
char *v0; // rax
char *v1; // rbx
char *v2; // rax
char *v3; // rbx
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = 0;
preproc_push((__int64)stdin, current_fname, 0);
while ( !v5[0] )
{
v0 = splice_lines(v5);
v1 = v0;
if ( !v0 )
break;
debug_push_line(v0);
if ( option_digraphs )
v1 = expand_digraphs(v1);
v2 = strip_comment(v1);
v3 = v2;
if ( (unsigned int)strip_in_block <= 2 )
v3 = (char *)filter_macros(v2);
debug_pop_line();
if ( v3 )
{
if ( !no_output )
puts(v3);
free(v3);
}
}
if ( (strip_in_block & 0xFFFFFFFD) == 1 )
{
--loc_tok;
die_at(0LL, "no terminating block comment");
JUMPOUT(0x8EELL);
}
return parse_end_validate();
}

canonical_decompiled_code:
__int64 func12()
{
char *v0; // rax
char *v1; // rbx
char *v2; // rax
char *v3; // rbx
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = 0;
func11((__int64)stdin, current_fname, 0);
while ( !v5[0] )
{
v0 = func9(v5);
v1 = v0;
if ( !v0 )
break;
debug_push_line(v0);
if ( option_digraphs )
v1 = func0(v1);
v2 = func2(v1);
v3 = v2;
if ( (unsigned int)strip_in_block <= 2 )
v3 = (char *)func3(v2);
debug_pop_line();
if ( v3 )
{
if ( !no_output )
puts(v3);
free(v3);
}
}
if ( (strip_in_block & 0xFFFFFFFD) == 1 )
{
--loc_tok;
die_at(0LL, "no terminating block comment");
JUMPOUT(0x8EELL);
}
return parse_end_validate();
}

original_code:
void preprocess(void)
{
 char *line;
 int eof = 0;
 preproc_push(stdin, current_fname, 0);
 while(!eof && (line = splice_lines(&eof))){
  debug_push_line(line);
  if(option_digraphs)
   line = expand_digraphs(line);
  line = strip_comment(line);
  switch(strip_in_block){
   case NOT_IN_BLOCK:
   case IN_BLOCK_BEGIN:
   case IN_BLOCK_END:
    line = filter_macros(line);
   case IN_BLOCK_FULL:
    break;
  }
  debug_pop_line();
  if(line){
   if(!no_output)
    puts(line);
   free(line);
  }
 }
 switch(strip_in_block){
  case NOT_IN_BLOCK:
  case IN_BLOCK_END:
   break;
  case IN_BLOCK_BEGIN:
  case IN_BLOCK_FULL:
   do{ if(0 == 0 || 0 & wmode){ loc_tok.line--; die_at(((void *)0), "no terminating block comment"); loc_tok.line++; } }while(0);
 }
 parse_end_validate();
}

canonical_original_code:
void preprocess()
{
 char *line;
 int eof = 0;
 preproc_push(stdin, current_fname, 0);
 while(!eof && (line = splice_lines(&eof))){
  debug_push_line(line);
  if(option_digraphs)
   line = expand_digraphs(line);
  line = strip_comment(line);
  switch(strip_in_block){
   case NOT_IN_BLOCK:
   case IN_BLOCK_BEGIN:
   case IN_BLOCK_END:
    line = filter_macros(line);
   case IN_BLOCK_FULL:
    break;
  }
  debug_pop_line();
  if(line){
   if(!no_output)
    puts(line);
   free(line);
  }
 }
 switch(strip_in_block){
  case NOT_IN_BLOCK:
  case IN_BLOCK_END:
   break;
  case IN_BLOCK_BEGIN:
  case IN_BLOCK_FULL:
   do{ if(0 == 0 || 0 & wmode){ loc_tok.line--; die_at(((void *)0), "no terminating block comment"); loc_tok.line++; } }while(0);
 }
 parse_end_validate();
}

variable_types:
line
char *

variable_types: eof int


umalloc

decompiled_code:
void *__fastcall umalloc(size_t size)
{
void *result; // rax

result = calloc(1uLL, size);
if ( !result )
{
ice("alloc.c", 20LL, "umalloc", "calloc %ld bytes:", size);
result = (void *)ucalloc();
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t size)
{
void *result; // rax

result = calloc(1uLL, size);
if ( !result )
{
ice("alloc.c", 20LL, "umalloc", "calloc %ld bytes:", size);
result = (void *)func1();
}
return result;
}

original_code:
void *umalloc(size_t l)
{
 void *p = calloc(1, l);
 if(!p)
  ice("alloc.c", 20, __func__, "calloc %ld bytes:", (long)l);
 return p;
}

canonical_original_code:
void *umalloc(unsigned long l)
{
 void *p = calloc(1, l);
 if(!p)
  ice("alloc.c", 20, __func__, "calloc %ld bytes:", (long)l);
 return p;
}

variable_types:
l
unsigned long

variable_types:
p
void *


ucalloc

decompiled_code:
void *__fastcall ucalloc(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
{
ice("alloc.c", 28LL, "ucalloc", "calloc(%ld, %ld):", a1, a2);
result = (void *)urealloc();
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
{
ice("alloc.c", 28LL, "ucalloc", "calloc(%ld, %ld):", a1, a2);
result = (void *)func2();
}
return result;
}

original_code:
void *ucalloc(size_t n, size_t sz)
{
 void *p = calloc(n, sz);
 if(!p)
  ice("alloc.c", 28, __func__, "calloc(%ld, %ld):", n, sz);
 return p;
}

canonical_original_code:
void *ucalloc(unsigned long n, unsigned long sz)
{
 void *p = calloc(n, sz);
 if(!p)
  ice("alloc.c", 28, __func__, "calloc(%ld, %ld):", n, sz);
 return p;
}

variable_types:
n
unsigned long

variable_types:
sz
unsigned long


urealloc

decompiled_code:
char *__fastcall urealloc(void *a1, size_t a2, __int64 a3)
{
char *v3; // rbp
char *v5; // rax
size_t v6; // rbx

v5 = (char *)realloc(a1, a2);
v6 = a2 - a3;
if ( !v5 )
{
v5 = (char *)ice("alloc.c", 38LL, "urealloc", "realloc %p by %ld bytes:", a1, v6);
goto LABEL_5;
}
v3 = v5;
if ( v6 )
LABEL_5:
memset(&v5[a3], 0, v6);
return v3;
}

canonical_decompiled_code:
char *__fastcall func2(void *a1, size_t a2, __int64 a3)
{
char *v3; // rbp
char *v5; // rax
size_t v6; // rbx

v5 = (char *)realloc(a1, a2);
v6 = a2 - a3;
if ( !v5 )
{
v5 = (char *)ice("alloc.c", 38LL, "urealloc", "realloc %p by %ld bytes:", a1, v6);
goto LABEL_5;
}
v3 = v5;
if ( v6 )
LABEL_5:
memset(&v5[a3], 0, v6);
return v3;
}

original_code:
void *urealloc(void *p, size_t new, size_t old)
{
 void *r = realloc(p, new);
 size_t diff = new - old;
 if(!r)
  ice("alloc.c", 38, __func__, "realloc %p by %ld bytes:", p, (long)diff);
 if(diff > 0)
  memset((char *)r + old, 0, diff);
 return r;
}

canonical_original_code:
void *urealloc(void *p, unsigned long new, unsigned long old)
{
 void *r = realloc(p, new);
 unsigned long diff = new - old;
 if(!r)
  ice("alloc.c", 38, __func__, "realloc %p by %ld bytes:", p, (long)diff);
 if(diff > 0)
  memset((char *)r + old, 0, diff);
 return r;
}

variable_types:
new
unsigned long

variable_types:
old
unsigned long

variable_types:
r
void *

variable_types:
diff
unsigned long


decompiled_code:
void *__fastcall urealloc1(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
ice("alloc.c", 51LL, "urealloc1", "realloc %p by %ld bytes:", a1, a2);
result = (void *)ustrdup("alloc.c");
}
return result;
}

canonical_decompiled_code:
void *__fastcall func3(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
ice("alloc.c", 51LL, "urealloc1", "realloc %p by %ld bytes:", a1, a2);
result = (void *)func4("alloc.c");
}
return result;
}

original_code:
void *urealloc1(void *p, size_t l)
{
 char *r = realloc(p, l);
 if(!r)
  ice("alloc.c", 51, __func__, "realloc %p by %ld bytes:", p, (long)l);
 return r;
}

canonical_original_code:
void *urealloc1(void *p, unsigned long l)
{
 char *r = realloc(p, l);
 if(!r)
  ice("alloc.c", 51, __func__, "realloc %p by %ld bytes:", p, (long)l);
 return r;
}

variable_types:
r
char *


ustrdup

decompiled_code:
char *__fastcall ustrdup(char *src)
{
size_t v1; // rax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)umalloc(v1 + 1);
return strcpy(v2, src);
}

canonical_decompiled_code:
char *__fastcall func4(char *src)
{
size_t v1; // rax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)func0(v1 + 1);
return strcpy(v2, src);
}

original_code:
char *ustrdup(const char *s)
{
 char *r = umalloc(strlen(s) + 1);
 strcpy(r, s);
 return r;
}

canonical_original_code:
char *ustrdup(char *s)
{
 char *r = umalloc(strlen(s) + 1);
 strcpy(r, s);
 return r;
}

variable_types:
s
char *


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

result = a1;
if ( a1 )
result = ustrdup(a1);
return result;
}

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

result = a1;
if ( a1 )
result = func4(a1);
return result;
}

original_code:
char *ustrdup_or_null(const char *s)
{
 return s ? ustrdup(s) : ((void *)0);
}

canonical_original_code:
char *ustrdup_or_null(char *s)
{
 return s ? ustrdup(s) : ((void *)0);
}


decompiled_code:
char *__fastcall ustrdup2(char *src, unsigned __int64 a2)
{
int v2; // ebp
char *v3; // rax

v2 = a2 - (_DWORD)src;
if ( a2 < (unsigned __int64)src )
_assert_fail("b >= a", "alloc.c", 0x47u, "ustrdup2");
v3 = (char *)umalloc(v2 + 1);
return strncpy(v3, src, v2);
}

canonical_decompiled_code:
char *__fastcall func6(char *src, unsigned __int64 a2)
{
int v2; // ebp
char *v3; // rax

v2 = a2 - (_DWORD)src;
if ( a2 < (unsigned __int64)src )
_assert_fail("b >= a", "alloc.c", 0x47u, "ustrdup2");
v3 = (char *)func0(v2 + 1);
return strncpy(v3, src, v2);
}

original_code:
char *ustrdup2(const char *a, const char *b)
{
 int len = b - a;
 char *ret;
 ((b >= a) ? (void) (0) : __assert_fail ("b >= a", "alloc.c", 71, __extension__ __PRETTY_FUNCTION__));
 ret = umalloc(len + 1);
 strncpy(ret, a, len);
 return ret;
}

canonical_original_code:
char *ustrdup2(char *a, char *b)
{
 int len = b - a;
 char *ret;
 ((b >= a) ? (void) (0) : __assert_fail ("b >= a", "alloc.c", 71, __extension__ __PRETTY_FUNCTION__));
 ret = umalloc(len + 1);
 strncpy(ret, a, len);
 return ret;
}

variable_types:
a
char *

variable_types:
b
char *

variable_types: len int

variable_types:
ret
char *


ustrvprintf

decompiled_code:
char *__fastcall ustrvprintf(char *format, const __m128i *a2)
{
int v2; // ebp
char *v3; // rbx
int v4; // edx
__m128i arg; // [rsp+8h] [rbp-40h] BYREF
__int64 v7; // [rsp+18h] [rbp-30h]

v2 = 8;
v3 = 0LL;
do
{
v4 = v2;
v2 *= 2;
v3 = urealloc(v3, v2, v4);
arg = _mm_loadu_si128(a2);
v7 = a2[1].m128i_i64[0];
}
while ( v2 <= vsnprintf(v3, v2, format, &arg) );
return v3;
}

canonical_decompiled_code:
char *__fastcall func7(char *format, const __m128i *a2)
{
int v2; // ebp
char *v3; // rbx
int v4; // edx
__m128i arg; // [rsp+8h] [rbp-40h] BYREF
__int64 v7; // [rsp+18h] [rbp-30h]

v2 = 8;
v3 = 0LL;
do
{
v4 = v2;
v2 *= 2;
v3 = func2(v3, v2, v4);
arg = _mm_loadu_si128(a2);
v7 = a2[1].m128i_i64[0];
}
while ( v2 <= vsnprintf(v3, v2, format, &arg) );
return v3;
}

original_code:
char *ustrvprintf(const char *fmt, va_list l)
{
 char *buf = ((void *)0);
 int len = 8, ret;
 do{
  va_list lcp;
  int old = len;
  len *= 2;
  buf = urealloc(buf, len, old);
  __builtin_va_copy(lcp,l);
  ret = vsnprintf(buf, len, fmt, lcp);
  __builtin_va_end(lcp);
 }while(ret >= len);
 return buf;
}

canonical_original_code:
char *ustrvprintf(char *fmt, __builtin_va_list l)
{
 char *buf = ((void *)0);
 int len = 8; int ret;
 do{
  __builtin_va_list lcp;
  int old = len;
  len *= 2;
  buf = urealloc(buf, len, old);
  __builtin_va_copy(lcp,l);
  ret = vsnprintf(buf, len, fmt, lcp);
  __builtin_va_end(lcp);
 }while(ret >= len);
 return buf;
}

variable_types:
fmt
char *

variable_types:
buf
char *

variable_types: ret int

variable_types: old int


ustrprintf

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

va_start(va, a1);
return ustrvprintf(a1, (const __m128i *)va);
}

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

va_start(va, a1);
return func7(a1, (const __m128i *)va);
}

original_code:
char *ustrprintf(const char *fmt, ...)
{
 va_list l;
 char *r;
 __builtin_va_start(l,fmt);
 r = ustrvprintf(fmt, l);
 __builtin_va_end(l);
 return r;
}

canonical_original_code:
char *ustrprintf(char *fmt, ...)
{
 __builtin_va_list l;
 char *r;
 __builtin_va_start(l,fmt);
 r = ustrvprintf(fmt, l);
 __builtin_va_end(l);
 return r;
}


decompiled_code:
__int64 __fastcall snapshot_take_1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rcx
__int64 i; // rax

if ( !a1 )
return 0LL;
v3 = umalloc(4 * a1, a2, a3, 0LL);
for ( i = 0LL; i != a1; ++i )
*(_DWORD *)(v3 + 4 * i) = *(_DWORD *)(*(_QWORD *)(macros + 8 * i) + 68LL);
return v3;
}

original_code:
static int *snapshot_take_1(size_t n)
{
 int *p;
 size_t i;
 if(!n)
  return ((void *)0);
 p = umalloc(n * sizeof *p);
 for(i = 0; i < n; i++)
  p[i] = macros[i]->use_cnt;
 return p;
}

canonical_original_code:
static int *snapshot_take_1(unsigned long n)
{
 int *p;
 unsigned long i;
 if(!n)
  return ((void *)0);
 p = umalloc(n * sizeof *p);
 for(i = 0; i < n; i++)
  p[i] = macros[i]->use_cnt;
 return p;
}

variable_types:
p
int *

variable_types:
i
unsigned long

return_type: int *


decompiled_code:
void __fastcall snapshot_restore_used(_QWORD *a1)
{
__int64 v1; // rsi
unsigned __int64 v2; // rax

if ( a1[2] )
{
v1 = macros;
v2 = 0LL;
do
{
*(_DWORD *)(*(_QWORD *)(v1 + 8 * v2) + 68LL) = *(_DWORD *)(*a1 + 4 * v2);
++v2;
}
while ( a1[2] > v2 );
}
}

original_code:
void snapshot_restore_used(snapshot *snap)
{
 size_t i;
 for(i = 0; i < snap->n; i++)
  macros[i]->use_cnt = snap->pre[i];
}

canonical_original_code:
void snapshot_restore_used(struct snapshot *snap)
{
 unsigned long i;
 for(i = 0; i < snap->n; i++)
  macros[i]->use_cnt = snap->pre[i];
}

variable_types: struct snapshot { int *pre; unsigned long n; } *


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

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

original_code:
void snapshot_free(snapshot *snap)
{
 free(snap->pre);
 free(snap->post);
 free(snap);
}

canonical_original_code:
void snapshot_free(struct snapshot *snap)
{
 free(snap->pre);
 free(snap->post);
 free(snap);
}

user_defined_types: struct snapshot { int *pre; unsigned long n; }


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

result = snapshot_take_1(*(_QWORD *)(a1 + 16), a2, a3);
*(_QWORD *)(a1 + 8) = result;
return result;
}

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

result = func1(*(_QWORD *)(a1 + 16), a2, a3);
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
void snapshot_take_post(snapshot *snap)
{
 snap->post = snapshot_take_1(snap->n);
}

canonical_original_code:
void snapshot_take_post(struct snapshot *snap)
{
 snap->post = snapshot_take_1(snap->n);
}


decompiled_code:
void __fastcall cstring_asciify(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbp
unsigned __int64 v3; // rax

v1 = umalloc(*(_QWORD *)(a1 + 8) + 1LL);
if ( *(_DWORD *)(a1 + 16) != 2 )
_assert_fail("cstr->type == CSTRING_WIDE", "str.c", 0x4Au, "cstring_asciify");
v2 = v1;
v3 = 0LL;
if ( *(_QWORD *)(a1 + 8) != -1LL )
{
do
{
*(_BYTE *)(v2 + v3) = *(_DWORD *)(*(_QWORD *)a1 + 4 * v3);
++v3;
}
while ( *(_QWORD *)(a1 + 8) + 1LL > v3 );
}
free(*(void **)a1);
*(_QWORD *)a1 = v2;
*(_DWORD *)(a1 + 16) = 1;
}

original_code:
static void cstring_asciify(struct cstring *cstr)
{
 char *ascii = umalloc(cstr->count + 1);
 size_t i;
 ((cstr->type == CSTRING_WIDE) ? (void) (0) : __assert_fail ("cstr->type == CSTRING_WIDE", "str.c", 74, __extension__ __PRETTY_FUNCTION__));
 for(i = 0; i < cstr->count + 1; i++)
  ascii[i] = cstr->bits.wides[i];
 free(cstr->bits.wides);
 cstr->bits.ascii = ascii;
 cstr->type = CSTRING_ASCII;
}

canonical_original_code:
static void cstring_asciify(struct cstring *cstr)
{
 char *ascii = umalloc(cstr->count + 1);
 unsigned long i;
 ((cstr->type == CSTRING_WIDE) ? (void) (0) : __assert_fail ("cstr->type == CSTRING_WIDE", "str.c", 74, __extension__ __PRETTY_FUNCTION__));
 for(i = 0; i < cstr->count + 1; i++)
  ascii[i] = cstr->bits.wides[i];
 free(cstr->bits.wides);
 cstr->bits.ascii = ascii;
 cstr->type = CSTRING_ASCII;
}

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:
ascii
char *

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


decompiled_code:
void __fastcall cstring_widen(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbp
unsigned __int64 v3; // rax

v1 = umalloc(4LL * *(_QWORD *)(a1 + 8) + 4);
if ( *(_DWORD *)(a1 + 16) > 1u )
_assert_fail("cstr->type == CSTRING_RAW || cstr->type == CSTRING_ASCII", "str.c", 0x3Bu, "cstring_widen");
v2 = v1;
v3 = 0LL;
if ( *(_QWORD *)(a1 + 8) != -1LL )
{
do
{
*(_DWORD *)(v2 + 4 * v3) = *(char *)(*(_QWORD *)a1 + v3);
++v3;
}
while ( *(_QWORD *)(a1 + 8) + 1LL > v3 );
}
free(*(void **)a1);
*(_QWORD *)a1 = v2;
*(_DWORD *)(a1 + 16) = 2;
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbp
unsigned __int64 v3; // rax

v1 = umalloc(4LL * *(_QWORD *)(a1 + 8) + 4);
if ( *(_DWORD *)(a1 + 16) > 1u )
_assert_fail("cstr->type == CSTRING_RAW || cstr->type == CSTRING_ASCII", "str.c", 0x3Bu, "cstring_widen");
v2 = v1;
v3 = 0LL;
if ( *(_QWORD *)(a1 + 8) != -1LL )
{
do
{
*(_DWORD *)(v2 + 4 * v3) = *(char *)(*(_QWORD *)a1 + v3);
++v3;
}
while ( *(_QWORD *)(a1 + 8) + 1LL > v3 );
}
free(*(void **)a1);
*(_QWORD *)a1 = v2;
*(_DWORD *)(a1 + 16) = 2;
}

original_code:
static void cstring_widen(struct cstring *cstr)
{
 int *wides = umalloc(sizeof(*wides) * (cstr->count + 1));
 size_t i;
 ((cstr->type == CSTRING_RAW || cstr->type == CSTRING_ASCII) ? (void) (0) : __assert_fail ("cstr->type == CSTRING_RAW || cstr->type == CSTRING_ASCII", "str.c", 59, __extension__ __PRETTY_FUNCTION__));
 for(i = 0; i < cstr->count + 1; i++)
  wides[i] = cstr->bits.ascii[i];
 free(cstr->bits.ascii);
 cstr->bits.wides = wides;
 cstr->type = CSTRING_WIDE;
}

canonical_original_code:
static void cstring_widen(struct cstring *cstr)
{
 int *wides = umalloc(sizeof(*wides) * (cstr->count + 1));
 unsigned long i;
 ((cstr->type == CSTRING_RAW || cstr->type == CSTRING_ASCII) ? (void) (0) : __assert_fail ("cstr->type == CSTRING_RAW || cstr->type == CSTRING_ASCII", "str.c", 59, __extension__ __PRETTY_FUNCTION__));
 for(i = 0; i < cstr->count + 1; i++)
  wides[i] = cstr->bits.ascii[i];
 free(cstr->bits.ascii);
 cstr->bits.wides = wides;
 cstr->type = CSTRING_WIDE;
}

variable_types:
wides
int *

user_defined_types: enum cstring_type { CSTRING_RAW=0, CSTRING_ASCII=1, CSTRING_WIDE=2 }


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

if ( *(_DWORD *)(a1 + 16) == 2 )
result = *(unsigned int *)(*(_QWORD *)a1 + 4 * a2);
else
result = (unsigned int)*(char *)(*(_QWORD *)a1 + a2);
return result;
}

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

if ( *(_DWORD *)(a1 + 16) == 2 )
result = *(unsigned int *)(*(_QWORD *)a1 + 4 * a2);
else
result = (unsigned int)*(char *)(*(_QWORD *)a1 + a2);
return result;
}

original_code:
int cstring_char_at(const struct cstring *cstr, size_t i)
{
 if(cstr->type == CSTRING_WIDE)
  return cstr->bits.wides[i];
 else
  return cstr->bits.ascii[i];
}

canonical_original_code:
int cstring_char_at(struct cstring *cstr, unsigned long i)
{
 if(cstr->type == CSTRING_WIDE)
  return cstr->bits.wides[i];
 else
  return cstr->bits.ascii[i];
}


decompiled_code:
__int64 __fastcall cstring_escape(char **a1, unsigned int a2, void (__fastcall *a3)(_QWORD, _QWORD, _QWORD, __int64), __int64 a4)
{
__int64 v4; // rbp
__int64 v5; // r12
__int64 v6; // rbx
unsigned __int64 v7; // rax
char *v8; // rdx
char v9; // al
int v10; // er13
unsigned int v11; // ebp
__int64 result; // rax
unsigned int v15; // [rsp+10h] [rbp-68h] BYREF
unsigned int v16; // [rsp+14h] [rbp-64h] BYREF
__int64 v17; // [rsp+18h] [rbp-60h] BYREF
__int64 v18[2]; // [rsp+20h] [rbp-58h] BYREF
__int64 v19; // [rsp+30h] [rbp-48h]

v18[0] = 0LL;
v18[1] = 0LL;
v19 = 0LL;
if ( *((_DWORD *)a1 + 4) )
_assert_fail("cstr->type == CSTRING_RAW", "str.c", 0x5Cu, "cstring_escape");
if ( a2 )
{
v18[0] = umalloc(4LL * (_QWORD)a1[1] + 4);
LODWORD(v19) = 2;
v4 = (__int64)a1[1];
if ( !v4 )
{
free(*a1);
LABEL_18:
*a1 = (char *)v18[0];
goto LABEL_19;
}
}
else
{
v18[0] = umalloc(a1[1] + 1);
LODWORD(v19) = 1;
v4 = (__int64)a1[1];
if ( !v4 )
{
free(*a1);
goto LABEL_8;
}
}
v5 = 0LL;
v6 = 0LL;
while ( 1 )
{
v8 = *a1;
v9 = (*a1)[v6];
v10 = v9;
if ( v9 == 92 )
{
v11 = v6 + 1;
v16 = 0;
v15 = 0;
v10 = escape_char_1(&v8[v6 + 1], &v17, a2, &v15, &v16);
v6 = v17;
if ( v17 )
{
v6 = v17 - (_QWORD)*a1 - 1;
a3(v15, v16, v11, a4);
}
else
{
ice("str.c", 114LL, "cstring_escape", "bad parse?");
}
}
v4 = v5 + 1;
cstring_char_set(v18, v5, v10);
v7 = (unsigned __int64)a1[1];
if ( v7 < v5 + 1 )
_assert_fail("iout <= cstr->count", "str.c", 0x7Du, "cstring_escape");
if ( v7 <= ++v6 )
break;
++v5;
}
free(*a1);
if ( a2 )
goto LABEL_18;
LABEL_8:
*a1 = (char *)v18[0];
LABEL_19:
result = (unsigned int)v19;
*((_DWORD *)a1 + 4) = v19;
a1[1] = (char *)v4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char **a1, unsigned int a2, void (__fastcall *a3)(_QWORD, _QWORD, _QWORD, __int64), __int64 a4)
{
__int64 v4; // rbp
__int64 v5; // r12
__int64 v6; // rbx
unsigned __int64 v7; // rax
char *v8; // rdx
char v9; // al
int v10; // er13
unsigned int v11; // ebp
__int64 result; // rax
unsigned int v15; // [rsp+10h] [rbp-68h] BYREF
unsigned int v16; // [rsp+14h] [rbp-64h] BYREF
__int64 v17; // [rsp+18h] [rbp-60h] BYREF
__int64 v18[2]; // [rsp+20h] [rbp-58h] BYREF
__int64 v19; // [rsp+30h] [rbp-48h]

v18[0] = 0LL;
v18[1] = 0LL;
v19 = 0LL;
if ( *((_DWORD *)a1 + 4) )
_assert_fail("cstr->type == CSTRING_RAW", "str.c", 0x5Cu, "cstring_escape");
if ( a2 )
{
v18[0] = umalloc(4LL * (_QWORD)a1[1] + 4);
LODWORD(v19) = 2;
v4 = (__int64)a1[1];
if ( !v4 )
{
free(*a1);
LABEL_18:
*a1 = (char *)v18[0];
goto LABEL_19;
}
}
else
{
v18[0] = umalloc(a1[1] + 1);
LODWORD(v19) = 1;
v4 = (__int64)a1[1];
if ( !v4 )
{
free(*a1);
goto LABEL_8;
}
}
v5 = 0LL;
v6 = 0LL;
while ( 1 )
{
v8 = *a1;
v9 = (*a1)[v6];
v10 = v9;
if ( v9 == 92 )
{
v11 = v6 + 1;
v16 = 0;
v15 = 0;
v10 = escape_char_1(&v8[v6 + 1], &v17, a2, &v15, &v16);
v6 = v17;
if ( v17 )
{
v6 = v17 - (_QWORD)*a1 - 1;
a3(v15, v16, v11, a4);
}
else
{
ice("str.c", 114LL, "cstring_escape", "bad parse?");
}
}
v4 = v5 + 1;
func0(v18, v5, v10);
v7 = (unsigned __int64)a1[1];
if ( v7 < v5 + 1 )
_assert_fail("iout <= cstr->count", "str.c", 0x7Du, "cstring_escape");
if ( v7 <= ++v6 )
break;
++v5;
}
free(*a1);
if ( a2 )
goto LABEL_18;
LABEL_8:
*a1 = (char *)v18[0];
LABEL_19:
result = (unsigned int)v19;
*((_DWORD *)a1 + 4) = v19;
a1[1] = (char *)v4;
return result;
}

original_code:
void cstring_escape(
  struct cstring *cstr, int is_wide,
  void handle_escape_warn_err(int w, int e, int escape_offset, void *),
  void *ctx)
{
 struct cstring tmpout = { 0 };
 size_t i, iout;
 ((cstr->type == CSTRING_RAW) ? (void) (0) : __assert_fail ("cstr->type == CSTRING_RAW", "str.c", 92, __extension__ __PRETTY_FUNCTION__));
 if(is_wide){
  tmpout.bits.wides = umalloc((cstr->count + 1) * sizeof(tmpout.bits.wides[0]));
  tmpout.type = CSTRING_WIDE;
 }else{
  tmpout.bits.ascii = umalloc(cstr->count + 1);
  tmpout.type = CSTRING_ASCII;
 }
 for(i = iout = 0; i < cstr->count; i++){
  unsigned add;
  if(cstr->bits.ascii[i] == '\\'){
   int warn, err;
   const int escape_loc = i + 1;
   char *end;
   warn = err = 0;
   add = escape_char_1(&cstr->bits.ascii[i + 1], &end, is_wide, &warn, &err);
   do if(!(end)) ice("str.c", 114, __func__, "bad parse?"); while(0);
   i = (end - cstr->bits.ascii) - 1;
   handle_escape_warn_err(warn, err, escape_loc, ctx);
  }else{
   add = cstr->bits.ascii[i];
  }
  cstring_char_set(&tmpout, iout++, add);
  ((iout <= cstr->count) ? (void) (0) : __assert_fail ("iout <= cstr->count", "str.c", 125, __extension__ __PRETTY_FUNCTION__));
 }
 free(cstr->bits.ascii);
 if(is_wide)
  cstr->bits.wides = tmpout.bits.wides;
 else
  cstr->bits.ascii = tmpout.bits.ascii;
 cstr->type = tmpout.type;
 cstr->count = iout;
}

canonical_original_code:
void cstring_escape(struct cstring *cstr, int is_wide, void handle_escape_warn_err(int w, int e, int escape_offset, void *), void *ctx)
{
 struct cstring tmpout = { 0 };
 unsigned long i; unsigned long iout;
 ((cstr->type == CSTRING_RAW) ? (void) (0) : __assert_fail ("cstr->type == CSTRING_RAW", "str.c", 92, __extension__ __PRETTY_FUNCTION__));
 if(is_wide){
  tmpout.bits.wides = umalloc((cstr->count + 1) * sizeof(tmpout.bits.wides[0]));
  tmpout.type = CSTRING_WIDE;
 }else{
  tmpout.bits.ascii = umalloc(cstr->count + 1);
  tmpout.type = CSTRING_ASCII;
 }
 for(i = iout = 0; i < cstr->count; i++){
  unsigned int add;
  if(cstr->bits.ascii[i] == '\\'){
   int warn; int err;
   int escape_loc = i + 1;
   char *end;
   warn = err = 0;
   add = escape_char_1(&cstr->bits.ascii[i + 1], &end, is_wide, &warn, &err);
   do if(!(end)) ice("str.c", 114, __func__, "bad parse?"); while(0);
   i = (end - cstr->bits.ascii) - 1;
   handle_escape_warn_err(warn, err, escape_loc, ctx);
  }else{
   add = cstr->bits.ascii[i];
  }
  cstring_char_set(&tmpout, iout++, add);
  ((iout <= cstr->count) ? (void) (0) : __assert_fail ("iout <= cstr->count", "str.c", 125, __extension__ __PRETTY_FUNCTION__));
 }
 free(cstr->bits.ascii);
 if(is_wide)
  cstr->bits.wides = tmpout.bits.wides;
 else
  cstr->bits.ascii = tmpout.bits.ascii;
 cstr->type = tmpout.type;
 cstr->count = iout;
}

variable_types: void (int w, int e, int escape_offset, void *)

variable_types:
ctx
void *

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:
iout
unsigned long

variable_types:
add
unsigned int

variable_types: warn int

variable_types: err int

variable_types:
end
char *


decompiled_code:
void __fastcall cstring_deinit(void **a1)
{
free(*a1);
}

canonical_decompiled_code:
void __fastcall func6(void **a1)
{
free(*a1);
}

original_code:
void cstring_deinit(struct cstring *cstr)
{
 if(cstr->type == CSTRING_WIDE)
  free(cstr->bits.wides);
 else
  free(cstr->bits.ascii);
}


decompiled_code:
void __fastcall cstring_free(void *ptr)
{
cstring_deinit((void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
func6((void **)ptr);
free(ptr);
}

original_code:
void cstring_free(struct cstring *cstr)
{
 cstring_deinit(cstr);
 free(cstr);
}


decompiled_code:
__int64 __fastcall cstring_detach(_DWORD *a1)
{
__int64 v1; // rbx

v1 = *(_QWORD *)a1;
*(_QWORD *)a1 = 0LL;
if ( a1[4] == 2 )
_assert_fail("cstr->type != CSTRING_WIDE", "str.c", 0x90u, "cstring_detach");
cstring_free(a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(_DWORD *a1)
{
__int64 v1; // rbx

v1 = *(_QWORD *)a1;
*(_QWORD *)a1 = 0LL;
if ( a1[4] == 2 )
_assert_fail("cstr->type != CSTRING_WIDE", "str.c", 0x90u, "cstring_detach");
func7(a1);
return v1;
}

original_code:
char *cstring_detach(struct cstring *cstr)
{
 char *r = cstr->bits.ascii;
 cstr->bits.ascii = ((void *)0);
 ((cstr->type != CSTRING_WIDE) ? (void) (0) : __assert_fail ("cstr->type != CSTRING_WIDE", "str.c", 144, __extension__ __PRETTY_FUNCTION__));
 cstring_free(cstr);
 return r;
}

variable_types:
r
char *


decompiled_code:
__int64 __fastcall cstring_converting_detach(_DWORD *a1)
{
if ( a1[4] == 2 )
cstring_asciify((__int64)a1);
return cstring_detach(a1);
}

canonical_decompiled_code:
__int64 __fastcall func9(_DWORD *a1)
{
if ( a1[4] == 2 )
func1((__int64)a1);
return func8(a1);
}

original_code:
char *cstring_converting_detach(struct cstring *cstr)
{
 switch(cstr->type){
  case CSTRING_WIDE:
   cstring_asciify(cstr);
  default:
   return cstring_detach(cstr);
 }
}


decompiled_code:
int __fastcall cstring_eq(__int64 a1, __int64 a2, __int64 a3, __int64 a4, const void *a5, const void *a6)
{
__int64 v6; // r10
unsigned int v7; // edx
int result; // eax
__int64 v9; // rcx

v7 = *(_DWORD *)(a1 + 16);
result = 1;
if ( v7 == *(_DWORD *)(a2 + 16) )
{
v9 = *(_QWORD *)(a1 + 8);
if ( v9 == *(_QWORD *)(a2 + 8) )
{
if ( v7 <= 1 )
{
a5 = *(const void **)a1;
a6 = *(const void **)a2;
v6 = 1LL;
}
else if ( v7 == 2 )
{
a5 = *(const void **)a1;
a6 = *(const void **)a2;
v6 = 4LL;
}
result = memcmp(a5, a6, v6 * v9);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, const void *a5, const void *a6)
{
__int64 v6; // r10
unsigned int v7; // edx
int result; // eax
__int64 v9; // rcx

v7 = *(_DWORD *)(a1 + 16);
result = 1;
if ( v7 == *(_DWORD *)(a2 + 16) )
{
v9 = *(_QWORD *)(a1 + 8);
if ( v9 == *(_QWORD *)(a2 + 8) )
{
if ( v7 <= 1 )
{
a5 = *(const void **)a1;
a6 = *(const void **)a2;
v6 = 1LL;
}
else if ( v7 == 2 )
{
a5 = *(const void **)a1;
a6 = *(const void **)a2;
v6 = 4LL;
}
result = memcmp(a5, a6, v6 * v9);
}
}
return result;
}

original_code:
int cstring_eq(const struct cstring *a, const struct cstring *b)
{
 enum { EQUAL, NOT_EQUAL };
 size_t sz;
 void *ap, *bp;
 if(a->type != b->type)
  return NOT_EQUAL;
 if(a->count != b->count)
  return NOT_EQUAL;
 switch(a->type){
  case CSTRING_WIDE:
   sz = sizeof(a->bits.wides[0]);
   ap = a->bits.wides;
   bp = b->bits.wides;
   break;
  case CSTRING_ASCII:
  case CSTRING_RAW:
   sz = 1;
   ap = a->bits.ascii;
   bp = b->bits.ascii;
   break;
 }
 return memcmp(ap, bp, sz * a->count);
}

canonical_original_code:
int cstring_eq(struct cstring *a, struct cstring *b)
{
 enum { EQUAL, NOT_EQUAL };
 unsigned long sz;
 void *ap; void *bp;
 if(a->type != b->type)
  return NOT_EQUAL;
 if(a->count != b->count)
  return NOT_EQUAL;
 switch(a->type){
  case CSTRING_WIDE:
   sz = sizeof(a->bits.wides[0]);
   ap = a->bits.wides;
   bp = b->bits.wides;
   break;
  case CSTRING_ASCII:
  case CSTRING_RAW:
   sz = 1;
   ap = a->bits.ascii;
   bp = b->bits.ascii;
   break;
 }
 return memcmp(ap, bp, sz * a->count);
}

variable_types:
b
struct cstring *

variable_types:
sz
unsigned long

variable_types:
ap
void *

variable_types:
bp
void *


decompiled_code:
__int64 __fastcall cstring_hash(__int64 a1)
{
__int64 v1; // r13
__int64 v2; // rbx
unsigned int v3; // ebp

v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return 5381;
v2 = 0LL;
v3 = 5381;
do
v3 += cstring_char_at(a1, v2++) + 32 * v3;
while ( v2 != v1 );
return v3;
}

original_code:
unsigned cstring_hash(const struct cstring *cstr)
{
 unsigned hash = 5381;
 size_t i;
 for(i = 0; i < cstr->count; i++)
  hash = ((hash << 5) + hash) + cstring_char_at(cstr, i);
 return hash;
}

canonical_original_code:
unsigned int cstring_hash(struct cstring *cstr)
{
 unsigned int hash = 5381;
 unsigned long i;
 for(i = 0; i < cstr->count; i++)
  hash = ((hash << 5) + hash) + cstring_char_at(cstr, i);
 return hash;
}

variable_types:
hash
unsigned int

variable_types:
i
unsigned long

return_type: unsigned int


original_code:
void cstring_append(struct cstring *out, struct cstring *addend)
{
 const size_t orig_out_count = out->count;
 int last_is_nul;
 if(out->type == CSTRING_WIDE){
  last_is_nul = out->bits.wides[orig_out_count - 1] == '\0';
 }else{
  last_is_nul = out->bits.ascii[orig_out_count - 1] == '\0';
 }
 if(addend->type != out->type){
  ((addend->type == CSTRING_WIDE || out->type == CSTRING_WIDE) ? (void) (0) : __assert_fail ("addend->type == CSTRING_WIDE || out->type == CSTRING_WIDE", "str.c", 230, __extension__ __PRETTY_FUNCTION__));
  if(addend->type == CSTRING_WIDE)
   cstring_widen(out);
  else
   cstring_widen(addend);
 }
 out->count += addend->count;
 if(out->type == CSTRING_WIDE){
  out->bits.wides = urealloc1(
    out->bits.wides,
    sizeof(out->bits.wides[0]) * (out->count + 1));
  memcpy(
    out->bits.wides + out->count - addend->count - !!last_is_nul,
    addend->bits.wides,
    sizeof(addend->bits.wides[0]) * (addend->count + 1));
 }else{
  out->bits.ascii = urealloc1(out->bits.ascii, out->count + 1);
  memcpy(
    out->bits.ascii + out->count - addend->count - !!last_is_nul,
    addend->bits.ascii,
    addend->count + 1);
 }
 if(last_is_nul)
  out->count--;
}

canonical_original_code:
void cstring_append(struct cstring *out, struct cstring *addend)
{
 unsigned long orig_out_count = out->count;
 int last_is_nul;
 if(out->type == CSTRING_WIDE){
  last_is_nul = out->bits.wides[orig_out_count - 1] == '\0';
 }else{
  last_is_nul = out->bits.ascii[orig_out_count - 1] == '\0';
 }
 if(addend->type != out->type){
  ((addend->type == CSTRING_WIDE || out->type == CSTRING_WIDE) ? (void) (0) : __assert_fail ("addend->type == CSTRING_WIDE || out->type == CSTRING_WIDE", "str.c", 230, __extension__ __PRETTY_FUNCTION__));
  if(addend->type == CSTRING_WIDE)
   cstring_widen(out);
  else
   cstring_widen(addend);
 }
 out->count += addend->count;
 if(out->type == CSTRING_WIDE){
  out->bits.wides = urealloc1(
    out->bits.wides,
    sizeof(out->bits.wides[0]) * (out->count + 1));
  memcpy(
    out->bits.wides + out->count - addend->count - !!last_is_nul,
    addend->bits.wides,
    sizeof(addend->bits.wides[0]) * (addend->count + 1));
 }else{
  out->bits.ascii = urealloc1(out->bits.ascii, out->count + 1);
  memcpy(
    out->bits.ascii + out->count - addend->count - !!last_is_nul,
    addend->bits.ascii,
    addend->count + 1);
 }
 if(last_is_nul)
  out->count--;
}

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:
addend
struct cstring *


original_code:
char *str_add_escape(const struct cstring *cstr)
{
 size_t nlen = 0, i;
 char *new, *p;
 for(i = 0; i < cstr->count; i++){
  int v = cstring_char_at(cstr, i);
  if(v == '\\' || v == '"')
   nlen += 3;
  else if(!((*__ctype_b_loc ())[(int) ((v))] & (unsigned short int) _ISprint))
   nlen += 4;
  else
   nlen++;
 }
 p = new = umalloc(nlen + 1);
 for(i = 0; i < cstr->count; i++){
  int v = cstring_char_at(cstr, i);
  if(v == '\\' || v == '"'){
   *p++ = '\\';
   *p++ = v;
  }else if(!((*__ctype_b_loc ())[(int) ((v))] & (unsigned short int) _ISprint)){
   int n = sprintf(p, "\\%03o", (unsigned char)v);
   do if(!(n <= 4)) ice("str.c", 291, __func__, "sprintf(octal), length %d > 4", n); while(0);
   p += n;
  }else{
   *p++ = v;
  }
 }
 return new;
}

canonical_original_code:
char *str_add_escape(struct cstring *cstr)
{
 unsigned long nlen = 0; unsigned long i;
 char *new; char *p;
 for(i = 0; i < cstr->count; i++){
  int v = cstring_char_at(cstr, i);
  if(v == '\\' || v == '"')
   nlen += 3;
  else if(!((*__ctype_b_loc ())[(int) ((v))] & (unsigned short) _ISprint))
   nlen += 4;
  else
   nlen++;
 }
 p = new = umalloc(nlen + 1);
 for(i = 0; i < cstr->count; i++){
  int v = cstring_char_at(cstr, i);
  if(v == '\\' || v == '"'){
   *p++ = '\\';
   *p++ = v;
  }else if(!((*__ctype_b_loc ())[(int) ((v))] & (unsigned short) _ISprint)){
   int n = sprintf(p, "\\%03o", (unsigned char)v);
   do if(!(n <= 4)) ice("str.c", 291, __func__, "sprintf(octal), length %d > 4", n); while(0);
   p += n;
  }else{
   *p++ = v;
  }
 }
 return new;
}

variable_types:
nlen
unsigned long

variable_types:
new
char *

variable_types:
p
char *

variable_types: v int

variable_types: n int


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

if ( a1 > 0xF )
result = a1 == 18;
else
result = a1 != 0;
return result;
}

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

if ( a1 > 0xF )
result = a1 == 18;
else
result = a1 != 0;
return result;
}

original_code:
static int type_convertible(enum type_primitive p)
{
 switch(p){
  case type__Bool:
  case type_nchar: case type_schar: case type_uchar:
  case type_int: case type_uint:
  case type_short: case type_ushort:
  case type_long: case type_ulong:
  case type_llong: case type_ullong:
  case type_float:
  case type_double:
  case type_ldouble:
  case type_enum:
   return 1;
  case type_void:
  case type_struct:
  case type_union:
  case type_unknown:
   break;
 }
 return 0;
}

variable_types: enum type_primitive { type_void=0, type__Bool=1, type_nchar=2, type_schar=3, type_uchar=4, type_int=5, type_uint=6, type_short=7, type_ushort=8, type_long=9, type_ulong=10, type_llong=11, type_ullong=12, type_float=13, type_double=14, type_ldouble=15, type_struct=16, type_union=17, type_enum=18, type_unknown=19 }


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

result = 0xFFFFFFFFLL;
if ( a1 - 2 <= 0xA )
result = a1;
return result;
}

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

result = 0xFFFFFFFFLL;
if ( a1 - 2 <= 0xA )
result = a1;
return result;
}

original_code:
int type_intrank(enum type_primitive p)
{
 switch(p){
  default:
   return -1;
  case type_nchar:
  case type_schar:
  case type_uchar:
  case type_int:
  case type_uint:
  case type_short:
  case type_ushort:
  case type_long:
  case type_ulong:
  case type_llong:
  case type_ullong:
   return p;
 }
}

user_defined_types: enum type_primitive { type_void=0, type__Bool=1, type_nchar=2, type_schar=3, type_uchar=4, type_int=5, type_uint=6, type_short=7, type_ushort=8, type_long=9, type_ulong=10, type_llong=11, type_ullong=12, type_float=13, type_double=14, type_ldouble=15, type_struct=16, type_union=17, type_enum=18, type_unknown=19 }


decompiled_code:
_BOOL8 __fastcall type_floating(int a1)
{
return (unsigned int)(a1 - 13) <= 2;
}

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

original_code:
int type_floating(enum type_primitive p)
{
 switch(p){
  case type_float:
  case type_double:
  case type_ldouble:
   return 1;
  default:
   return 0;
 }
}


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

switch ( a1 )
{
case 0:
result = "void";
break;
case 1:
result = "_Bool";
break;
case 2:
result = "char";
break;
case 3:
result = "signed char";
break;
case 4:
result = "unsigned char";
break;
case 5:
result = "int";
break;
case 6:
result = "unsigned int";
break;
case 7:
result = "short";
break;
case 8:
result = "unsigned short";
break;
case 9:
result = "long";
break;
case 10:
result = "unsigned long";
break;
case 11:
result = "long long";
break;
case 12:
result = "unsigned long long";
break;
case 13:
result = "float";
break;
case 14:
result = "double";
break;
case 15:
result = "long double";
break;
case 16:
result = "struct";
break;
case 17:
result = "union";
break;
case 18:
result = "enum";
break;
case 19:
result = "unknown";
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = "void";
break;
case 1:
result = "_Bool";
break;
case 2:
result = "char";
break;
case 3:
result = "signed char";
break;
case 4:
result = "unsigned char";
break;
case 5:
result = "int";
break;
case 6:
result = "unsigned int";
break;
case 7:
result = "short";
break;
case 8:
result = "unsigned short";
break;
case 9:
result = "long";
break;
case 10:
result = "unsigned long";
break;
case 11:
result = "long long";
break;
case 12:
result = "unsigned long long";
break;
case 13:
result = "float";
break;
case 14:
result = "double";
break;
case 15:
result = "long double";
break;
case 16:
result = "struct";
break;
case 17:
result = "union";
break;
case 18:
result = "enum";
break;
case 19:
result = "unknown";
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
const char *type_primitive_to_str(const enum type_primitive p)
{
 switch(p){
  case type_nchar: return "char";
  case type_schar: return "signed char";
  case type_uchar: return "unsigned char";
  case type_void: return "void";
  case type_short: return "short";
  case type_int: return "int";
  case type_long: return "long";
  case type_ushort: return "unsigned short";
  case type_uint: return "unsigned int";
  case type_ulong: return "unsigned long";
  case type_float: return "float";
  case type_double: return "double";
  case type__Bool: return "_Bool";
  case type_llong: return "long long";
  case type_ullong: return "unsigned long long";
  case type_ldouble: return "long double";
  case type_struct: return "struct";
  case type_union: return "union";
  case type_enum: return "enum";
  case type_unknown: return "unknown";
 }
 return ((void *)0);
}

canonical_original_code:
char *type_primitive_to_str(enum type_primitive p)
{
 switch(p){
  case type_nchar: return "char";
  case type_schar: return "signed char";
  case type_uchar: return "unsigned char";
  case type_void: return "void";
  case type_short: return "short";
  case type_int: return "int";
  case type_long: return "long";
  case type_ushort: return "unsigned short";
  case type_uint: return "unsigned int";
  case type_ulong: return "unsigned long";
  case type_float: return "float";
  case type_double: return "double";
  case type__Bool: return "_Bool";
  case type_llong: return "long long";
  case type_ullong: return "unsigned long long";
  case type_ldouble: return "long double";
  case type_struct: return "struct";
  case type_union: return "union";
  case type_enum: return "enum";
  case type_unknown: return "unknown";
 }
 return ((void *)0);
}


decompiled_code:
_BOOL8 __fastcall type_primitive_is_signed(int a1, int a2)
{
const char *v3; // rax

switch ( a1 )
{
case 0:
case 1:
case 4:
case 6:
case 8:
case 10:
case 12:
case 18:
return 0LL;
case 2:
return cc1_fopt[5] != 0;
case 3:
case 5:
case 7:
case 9:
case 11:
case 13:
case 14:
case 15:
return 1LL;
case 16:
case 17:
if ( !a2 )
return 0LL;
v3 = type_primitive_to_str(a1);
ice("btype.c", 107LL, "type_primitive_is_signed", "%s(%s)", "type_primitive_is_signed", v3);
LABEL_8:
ice("btype.c", 126LL, "type_primitive_is_signed", "type_unknown in %s", "type_primitive_is_signed");
LABEL_9:
ice("btype.c", 129LL, "type_primitive_is_signed", "unreachable");
return 1LL;
case 19:
goto LABEL_8;
default:
goto LABEL_9;
}
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(int a1, int a2)
{
const char *v3; // rax

switch ( a1 )
{
case 0:
case 1:
case 4:
case 6:
case 8:
case 10:
case 12:
case 18:
return 0LL;
case 2:
return cc1_fopt[5] != 0;
case 3:
case 5:
case 7:
case 9:
case 11:
case 13:
case 14:
case 15:
return 1LL;
case 16:
case 17:
if ( !a2 )
return 0LL;
v3 = func4(a1);
ice("btype.c", 107LL, "type_primitive_is_signed", "%s(%s)", "type_primitive_is_signed", v3);
LABEL_8:
ice("btype.c", 126LL, "type_primitive_is_signed", "type_unknown in %s", "type_primitive_is_signed");
LABEL_9:
ice("btype.c", 129LL, "type_primitive_is_signed", "unreachable");
return 1LL;
case 19:
goto LABEL_8;
default:
goto LABEL_9;
}
}

original_code:
int type_primitive_is_signed(enum type_primitive p, int hard_err_on_su)
{
 switch(p){
  case type_nchar:
   return !!(cc1_fopt.signed_char);
  case type_schar:
  case type_int:
  case type_short:
  case type_long:
  case type_llong:
  case type_float:
  case type_double:
  case type_ldouble:
   return 1;
  case type_struct:
  case type_union:
   if(hard_err_on_su){
    ice("btype.c", 107, __func__, "%s(%s)", __func__, type_primitive_to_str(p));
   }
   return 0;
  case type_enum:
   return 0;
  case type_void:
  case type__Bool:
  case type_uchar:
  case type_uint:
  case type_ushort:
  case type_ulong:
  case type_ullong:
   return 0;
  case type_unknown:
   ice("btype.c", 126, __func__, "type_unknown in %s", __func__);
 }
 do{ ice("btype.c", 129, __func__, "unreachable"); return 0; }while(0);
}


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

switch ( (int)a1 )
{
case 0:
case 1:
case 2:
case 3:
case 4:
return 1LL;
case 5:
case 6:
case 13:
return 4LL;
case 7:
case 8:
return 2LL;
case 9:
case 10:
result = platform_word_size();
if ( (_DWORD)result != 4 )
result = 8LL;
return result;
case 11:
case 12:
return 8LL;
case 14:
result = platform_word_size();
if ( (_DWORD)result != 4 )
result = 8LL;
return result;
case 15:
icw("btype.c", 267LL, "type_primitive_size", "TODO: long double");
return 4 * (unsigned int)((unsigned int)platform_word_size() != 4) + 12;
case 16:
case 17:
case 18:
a1 = "btype.c";
ice("btype.c", 273LL, "type_primitive_size", "s/u/e size");
goto LABEL_12;
default:
LABEL_12:
v2 = type_primitive_to_str((int)a1);
ice("btype.c", 279LL, "type_primitive_size", "type %s in %s()", v2, "type_primitive_size");
return 1LL;
}
}

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

switch ( (int)a1 )
{
case 0:
case 1:
case 2:
case 3:
case 4:
return 1LL;
case 5:
case 6:
case 13:
return 4LL;
case 7:
case 8:
return 2LL;
case 9:
case 10:
result = platform_word_size();
if ( (_DWORD)result != 4 )
result = 8LL;
return result;
case 11:
case 12:
return 8LL;
case 14:
result = platform_word_size();
if ( (_DWORD)result != 4 )
result = 8LL;
return result;
case 15:
icw("btype.c", 267LL, "type_primitive_size", "TODO: long double");
return 4 * (unsigned int)((unsigned int)platform_word_size() != 4) + 12;
case 16:
case 17:
case 18:
a1 = "btype.c";
ice("btype.c", 273LL, "type_primitive_size", "s/u/e size");
goto LABEL_12;
default:
LABEL_12:
v2 = func4((int)a1);
ice("btype.c", 279LL, "type_primitive_size", "type %s in %s()", v2, "type_primitive_size");
return 1LL;
}
}

original_code:
unsigned type_primitive_size(enum type_primitive tp)
{
 switch(tp){
  case type__Bool:
  case type_void:
   return 1;
  case type_schar:
  case type_uchar:
  case type_nchar:
   return 1;
  case type_short:
  case type_ushort:
   return 2;
  case type_int:
  case type_uint:
   return 4;
  case type_float:
   return 4;
  case type_long:
  case type_ulong:
   if((platform_word_size() == 4))
    return 4;
   return 8;
  case type_llong:
  case type_ullong:
   return 8;
  case type_double:
   return (platform_word_size() == 4) ? 4 : 8;
  case type_ldouble:
   icw("btype.c", 267, __func__, "TODO: long double");
   return (platform_word_size() == 4) ? 12 : 16;
  case type_enum:
  case type_union:
  case type_struct:
   ice("btype.c", 273, __func__, "s/u/e size");
  case type_unknown:
   break;
 }
 ice("btype.c", 279, __func__, "type %s in %s()", type_primitive_to_str(tp), __func__);
 return -1;
}

canonical_original_code:
unsigned int type_primitive_size(enum type_primitive tp)
{
 switch(tp){
  case type__Bool:
  case type_void:
   return 1;
  case type_schar:
  case type_uchar:
  case type_nchar:
   return 1;
  case type_short:
  case type_ushort:
   return 2;
  case type_int:
  case type_uint:
   return 4;
  case type_float:
   return 4;
  case type_long:
  case type_ulong:
   if((platform_word_size() == 4))
    return 4;
   return 8;
  case type_llong:
  case type_ullong:
   return 8;
  case type_double:
   return (platform_word_size() == 4) ? 4 : 8;
  case type_ldouble:
   icw("btype.c", 267, __func__, "TODO: long double");
   return (platform_word_size() == 4) ? 12 : 16;
  case type_enum:
  case type_union:
  case type_struct:
   ice("btype.c", 273, __func__, "s/u/e size");
  case type_unknown:
   break;
 }
 ice("btype.c", 279, __func__, "type %s in %s()", type_primitive_to_str(tp), __func__);
 return -1;
}


decompiled_code:
__int64 __fastcall type_primitive_max(const char *a1, int a2)
{
__int64 result; // rax
const char *v3; // rax

switch ( (int)a1 )
{
case 1:
return 1LL;
case 2:
case 3:
case 4:
goto LABEL_11;
case 5:
result = 0x7FFFFFFFLL;
goto LABEL_4;
case 7:
result = 0x7FFFLL;
goto LABEL_4;
case 9:
result = 0x7FFFFFFFFFFFFFFFLL;
goto LABEL_4;
case 11:
result = 0x7FFFFFFFFFFFFFFFLL;
goto LABEL_4;
case 13:
case 14:
case 15:
ice("btype.c", 306LL, "type_primitive_max", "TODO: float max");
goto LABEL_9;
case 16:
case 17:
case 18:
LABEL_9:
a1 = "btype.c";
ice("btype.c", 311LL, "type_primitive_max", "sue max");
break;
default:
break;
}
v3 = type_primitive_to_str((int)a1);
a2 = 316;
ice("btype.c", 316LL, "type_primitive_max", "bad primitive %s", v3);
LABEL_11:
result = 127LL;
LABEL_4:
if ( !a2 )
result = 2 * result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(const char *a1, int a2)
{
__int64 result; // rax
const char *v3; // rax

switch ( (int)a1 )
{
case 1:
return 1LL;
case 2:
case 3:
case 4:
goto LABEL_11;
case 5:
result = 0x7FFFFFFFLL;
goto LABEL_4;
case 7:
result = 0x7FFFLL;
goto LABEL_4;
case 9:
result = 0x7FFFFFFFFFFFFFFFLL;
goto LABEL_4;
case 11:
result = 0x7FFFFFFFFFFFFFFFLL;
goto LABEL_4;
case 13:
case 14:
case 15:
ice("btype.c", 306LL, "type_primitive_max", "TODO: float max");
goto LABEL_9;
case 16:
case 17:
case 18:
LABEL_9:
a1 = "btype.c";
ice("btype.c", 311LL, "type_primitive_max", "sue max");
break;
default:
break;
}
v3 = func4((int)a1);
a2 = 316;
ice("btype.c", 316LL, "type_primitive_max", "bad primitive %s", v3);
LABEL_11:
result = 127LL;
LABEL_4:
if ( !a2 )
result = 2 * result + 1;
return result;
}

original_code:
unsigned long long
type_primitive_max(enum type_primitive p, int is_signed)
{
 unsigned long long max;
 switch(p){
  case type__Bool: return 1;
  case type_nchar:
  case type_schar:
  case type_uchar:
   max = 127;
   break;
  case type_short: max = 32767; break;
  case type_int: max = 2147483647; break;
  case type_long: max = 9223372036854775807L; break;
  case type_llong: max = 9223372036854775807LL; break;
  case type_float:
  case type_double:
  case type_ldouble:
   ice("btype.c", 306, __func__, "TODO: float max");
  case type_union:
  case type_struct:
  case type_enum:
   ice("btype.c", 311, __func__, "sue max");
  case type_void:
  case type_unknown:
  default:
   ice("btype.c", 316, __func__, "bad primitive %s", type_primitive_to_str(p));
 }
 return is_signed ? max : max * 2 + 1;
}

variable_types:
max
unsigned long long

return_type: unsigned long long