decompiled_code:
__int64 __fastcall humanize_number(char *s, size_t maxlen, __int64 a3, const char *a4, int a5, char a6)
{
__int64 v11; // rbp
__int16 *v12; // rax
size_t v13; // rcx
int i; // esi
__int64 v15; // rdx
__int64 v16; // rdi
int *v17; // rax
int *v18; // rax
int *v19; // rax
__int16 *v20; // rax
int v21; // eax
__int64 v22; // rdi
__int64 v24; // [rsp+0h] [rbp-58h]
const char *v25; // [rsp+8h] [rbp-50h]
int v27; // [rsp+14h] [rbp-44h]
__int16 *v28; // [rsp+18h] [rbp-40h]

if ( !s )
{
v17 = _errno_location();
VAS_Fail("humanize_number", "humanize_number.c", 51LL, "buf != NULL", (unsigned int)*v17, 0LL);
}
if ( !a4 )
{
v18 = _errno_location();
VAS_Fail("humanize_number", "humanize_number.c", 52LL, "suffix != NULL", (unsigned int)*v18, 0LL);
}
if ( a5 < 0 )
{
v19 = _errno_location();
VAS_Fail("humanize_number", "humanize_number.c", 53LL, "scale >= 0", (unsigned int)*v19, 0LL);
}
if ( (a6 & 8) != 0 )
{
v11 = 1000LL;
v12 = L"";
if ( (a6 & 4) != 0 )
v12 = L"BkMGTPE";
v28 = v12;
}
else
{
v11 = 1024LL;
v20 = L"";
if ( (a6 & 4) != 0 )
v20 = L"BKMGTPEBkMGTPE";
v28 = v20;
}
if ( a5 > 6 && (a5 & 0x30) == 0 )
return (unsigned int)-1;
if ( !s || !a4 )
return (unsigned int)-1;
if ( maxlen )
*s = 0;
v24 = 2LL;
v27 = 1;
if ( a3 < 0 )
{
a3 = -a3;
v24 = 3LL;
v27 = -1;
}
v25 = (const char *)&unk_3E2;
if ( (a6 & 2) == 0 )
{
++v24;
v25 = " ";
}
v13 = strlen(a4) + v24;
if ( v13 + 1 > maxlen )
return (unsigned int)-1;
i = a5 & 0x30;
if ( (a5 & 0x30) == 0 )
{
LODWORD(v15) = a5 & 0x30;
if ( a5 <= 0 )
return (unsigned int)snprintf(
s,
maxlen,
"%jd%s%s%s",
v27 * (a3 + ((int)v15 + 50) / 1000),
v25,
(const char *)&v28[i],
a4);
do
{
v16 = a3;
a3 /= v11;
++i;
}
while ( a5 > i && i <= 6 );
v15 = v16 % v11;
LABEL_27:
if ( (int)v15 <= 949 && a3 <= 9 && i > 0 && (a6 & 1) != 0 )
{
if ( v13 + 3 > maxlen )
i = -1;
else
i = snprintf(
s,
maxlen,
"%d%s%d%s%s%s",
(unsigned int)(v27 * (a3 + ((int)v15 + 50) / 1000)),
",",
(unsigned int)(((int)v15 + 50) / 100 % 10),
v25,
(const char *)&v28[i],
a4);
return (unsigned int)i;
}
return (unsigned int)snprintf(
s,
maxlen,
"%jd%s%s%s",
v27 * (a3 + ((int)v15 + 50) / 1000),
v25,
(const char *)&v28[i],
a4);
}
v21 = maxlen - v13 - 1;
if ( (int)maxlen - (int)v13 <= 0 )
{
v22 = 1LL;
}
else
{
v22 = 1LL;
do
{
v22 *= 10LL;
--v21;
}
while ( v21 != -1 );
}
LODWORD(v15) = 0;
for ( i = 0; (a3 >= v22 || v22 - 1 == a3 && (int)v15 > 949) && i != 7; ++i )
{
v15 = a3 % v11;
a3 /= v11;
}
if ( (a5 & 0x10) == 0 )
goto LABEL_27;
return (unsigned int)i;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s, size_t maxlen, __int64 a3, const char *a4, int a5, char a6)
{
__int64 v11; // rbp
__int16 *v12; // rax
size_t v13; // rcx
int i; // esi
__int64 v15; // rdx
__int64 v16; // rdi
int *v17; // rax
int *v18; // rax
int *v19; // rax
__int16 *v20; // rax
int v21; // eax
__int64 v22; // rdi
__int64 v24; // [rsp+0h] [rbp-58h]
const char *v25; // [rsp+8h] [rbp-50h]
int v27; // [rsp+14h] [rbp-44h]
__int16 *v28; // [rsp+18h] [rbp-40h]

if ( !s )
{
v17 = _errno_location();
VAS_Fail("humanize_number", "humanize_number.c", 51LL, "buf != NULL", (unsigned int)*v17, 0LL);
}
if ( !a4 )
{
v18 = _errno_location();
VAS_Fail("humanize_number", "humanize_number.c", 52LL, "suffix != NULL", (unsigned int)*v18, 0LL);
}
if ( a5 < 0 )
{
v19 = _errno_location();
VAS_Fail("humanize_number", "humanize_number.c", 53LL, "scale >= 0", (unsigned int)*v19, 0LL);
}
if ( (a6 & 8) != 0 )
{
v11 = 1000LL;
v12 = L"";
if ( (a6 & 4) != 0 )
v12 = L"BkMGTPE";
v28 = v12;
}
else
{
v11 = 1024LL;
v20 = L"";
if ( (a6 & 4) != 0 )
v20 = L"BKMGTPEBkMGTPE";
v28 = v20;
}
if ( a5 > 6 && (a5 & 0x30) == 0 )
return (unsigned int)-1;
if ( !s || !a4 )
return (unsigned int)-1;
if ( maxlen )
*s = 0;
v24 = 2LL;
v27 = 1;
if ( a3 < 0 )
{
a3 = -a3;
v24 = 3LL;
v27 = -1;
}
v25 = (const char *)&unk_3E2;
if ( (a6 & 2) == 0 )
{
++v24;
v25 = " ";
}
v13 = strlen(a4) + v24;
if ( v13 + 1 > maxlen )
return (unsigned int)-1;
i = a5 & 0x30;
if ( (a5 & 0x30) == 0 )
{
LODWORD(v15) = a5 & 0x30;
if ( a5 <= 0 )
return (unsigned int)snprintf(
s,
maxlen,
"%jd%s%s%s",
v27 * (a3 + ((int)v15 + 50) / 1000),
v25,
(const char *)&v28[i],
a4);
do
{
v16 = a3;
a3 /= v11;
++i;
}
while ( a5 > i && i <= 6 );
v15 = v16 % v11;
LABEL_27:
if ( (int)v15 <= 949 && a3 <= 9 && i > 0 && (a6 & 1) != 0 )
{
if ( v13 + 3 > maxlen )
i = -1;
else
i = snprintf(
s,
maxlen,
"%d%s%d%s%s%s",
(unsigned int)(v27 * (a3 + ((int)v15 + 50) / 1000)),
",",
(unsigned int)(((int)v15 + 50) / 100 % 10),
v25,
(const char *)&v28[i],
a4);
return (unsigned int)i;
}
return (unsigned int)snprintf(
s,
maxlen,
"%jd%s%s%s",
v27 * (a3 + ((int)v15 + 50) / 1000),
v25,
(const char *)&v28[i],
a4);
}
v21 = maxlen - v13 - 1;
if ( (int)maxlen - (int)v13 <= 0 )
{
v22 = 1LL;
}
else
{
v22 = 1LL;
do
{
v22 *= 10LL;
--v21;
}
while ( v21 != -1 );
}
LODWORD(v15) = 0;
for ( i = 0; (a3 >= v22 || v22 - 1 == a3 && (int)v15 > 949) && i != 7; ++i )
{
v15 = a3 % v11;
a3 /= v11;
}
if ( (a5 & 0x10) == 0 )
goto LABEL_27;
return (unsigned int)i;
}

original_code:
int
humanize_number(char *buf, size_t len, int64_t quotient,
    const char *suffix, int scale, int flags)
{
 const char *prefixes, *sep;
 int i, r, remainder, maxscale, s1, s2, sign;
 int64_t divisor, max;
 size_t baselen;
 do { if (!(buf != ((void *)0))) VAS_Fail(__func__, "humanize_number.c", 51, "buf != NULL", (*__errno_location ()), 0); } while (0);
 do { if (!(suffix != ((void *)0))) VAS_Fail(__func__, "humanize_number.c", 52, "suffix != NULL", (*__errno_location ()), 0); } while (0);
 do { if (!(scale >= 0)) VAS_Fail(__func__, "humanize_number.c", 53, "scale >= 0", (*__errno_location ()), 0); } while (0);
 remainder = 0;
 if (flags & 0x08) {
  divisor = 1000;
  if (flags & 0x04)
   prefixes = "B\0k\0M\0G\0T\0P\0E";
  else
   prefixes = "\0\0k\0M\0G\0T\0P\0E";
 } else {
  divisor = 1024;
  if (flags & 0x04)
   prefixes = "B\0K\0M\0G\0T\0P\0E";
  else
   prefixes = "\0\0K\0M\0G\0T\0P\0E";
 }
 maxscale = 7;
 if (scale >= maxscale &&
     (scale & (0x20 | 0x10)) == 0)
  return (-1);
 if (buf == ((void *)0) || suffix == ((void *)0))
  return (-1);
 if (len > 0)
  buf[0] = '\0';
 if (quotient < 0) {
  sign = -1;
  quotient = -quotient;
  baselen = 3;
 } else {
  sign = 1;
  baselen = 2;
 }
 if (flags & 0x02)
  sep = "";
 else {
  sep = " ";
  baselen++;
 }
 baselen += strlen(suffix);
 if (len < baselen + 1)
  return (-1);
 if (scale & (0x20 | 0x10)) {
  for (max = 1, i = len - baselen; i-- > 0;)
   max *= 10;
  for (i = 0;
      (quotient >= max || (quotient == max - 1 && remainder >= 950)) &&
      i < maxscale; i++) {
   remainder = quotient % divisor;
   quotient /= divisor;
  }
  if (scale & 0x10)
   return (i);
 } else {
  for (i = 0; i < scale && i < maxscale; i++) {
   remainder = quotient % divisor;
   quotient /= divisor;
  }
 }
 if (quotient <= 9 && remainder < 950 && i > 0 && flags & 0x01) {
  if (len < baselen + 1 + 2)
   return (-1);
  s1 = (int)quotient + ((remainder + 50) / 1000);
  s2 = ((remainder + 50) / 100) % 10;
  r = snprintf(buf, len, "%d%s%d%s%s%s",
      sign * s1, ",", s2,
      sep, (&prefixes[(i) << 1]), suffix);
 } else {
  r = snprintf(buf, len, "%jd%s%s%s",
      sign * (quotient + (remainder + 50) / 1000),
      sep, (&prefixes[(i) << 1]), suffix);
 }
 return (r);
}

canonical_original_code:
int humanize_number(char *buf, unsigned long len, long quotient, char *suffix, int scale, int flags)
{
 char *prefixes; char *sep;
 int i; int r; int remainder; int maxscale; int s1; int s2; int sign;
 long divisor; long max;
 unsigned long baselen;
 do { if (!(buf != ((void *)0))) VAS_Fail(__func__, "humanize_number.c", 51, "buf != NULL", (*__errno_location ()), 0); } while (0);
 do { if (!(suffix != ((void *)0))) VAS_Fail(__func__, "humanize_number.c", 52, "suffix != NULL", (*__errno_location ()), 0); } while (0);
 do { if (!(scale >= 0)) VAS_Fail(__func__, "humanize_number.c", 53, "scale >= 0", (*__errno_location ()), 0); } while (0);
 remainder = 0;
 if (flags & 0x08) {
  divisor = 1000;
  if (flags & 0x04)
   prefixes = "B\0k\0M\0G\0T\0P\0E";
  else
   prefixes = "\0\0k\0M\0G\0T\0P\0E";
 } else {
  divisor = 1024;
  if (flags & 0x04)
   prefixes = "B\0K\0M\0G\0T\0P\0E";
  else
   prefixes = "\0\0K\0M\0G\0T\0P\0E";
 }
 maxscale = 7;
 if (scale >= maxscale &&
     (scale & (0x20 | 0x10)) == 0)
  return (-1);
 if (buf == ((void *)0) || suffix == ((void *)0))
  return (-1);
 if (len > 0)
  buf[0] = '\0';
 if (quotient < 0) {
  sign = -1;
  quotient = -quotient;
  baselen = 3;
 } else {
  sign = 1;
  baselen = 2;
 }
 if (flags & 0x02)
  sep = "";
 else {
  sep = " ";
  baselen++;
 }
 baselen += strlen(suffix);
 if (len < baselen + 1)
  return (-1);
 if (scale & (0x20 | 0x10)) {
  for (max = 1, i = len - baselen; i-- > 0;)
   max *= 10;
  for (i = 0;
      (quotient >= max || (quotient == max - 1 && remainder >= 950)) &&
      i < maxscale; i++) {
   remainder = quotient % divisor;
   quotient /= divisor;
  }
  if (scale & 0x10)
   return (i);
 } else {
  for (i = 0; i < scale && i < maxscale; i++) {
   remainder = quotient % divisor;
   quotient /= divisor;
  }
 }
 if (quotient <= 9 && remainder < 950 && i > 0 && flags & 0x01) {
  if (len < baselen + 1 + 2)
   return (-1);
  s1 = (int)quotient + ((remainder + 50) / 1000);
  s2 = ((remainder + 50) / 100) % 10;
  r = snprintf(buf, len, "%d%s%d%s%s%s",
      sign * s1, ",", s2,
      sep, (&prefixes[(i) << 1]), suffix);
 } else {
  r = snprintf(buf, len, "%jd%s%s%s",
      sign * (quotient + (remainder + 50) / 1000),
      sep, (&prefixes[(i) << 1]), suffix);
 }
 return (r);
}

variable_types:
buf
char *

variable_types:
len
unsigned long

variable_types: quotient long

variable_types:
suffix
char *

variable_types: scale int

variable_types: flags int

variable_types:
prefixes
char *

variable_types:
sep
char *

variable_types: i int

variable_types: r int

variable_types: remainder int

variable_types: maxscale int

variable_types: sign int

variable_types: divisor long

variable_types: max long

variable_types:
baselen
unsigned long


repo: weongyo/varnish-perf

decompiled_code:
void __fastcall __noreturn VAS_Fail_default(const char *a1, const char *a2, unsigned int a3, const char *a4, unsigned int a5, int a6)
{
char *v7; // rax

if ( a6 )
fprintf(stderr, "Missing errorhandling code in %s(), %s line %d:\n Condition(%s) not true.\n", a1, a2, a3, a4);
else
fprintf(stderr, "Assert error in %s(), %s line %d:\n Condition(%s) not true.\n", a1, a2, a3, a4);
if ( a5 )
{
v7 = strerror(a5);
fprintf(stderr, " errno = %d (%s)\n", a5, v7);
}
abort();
}

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

if ( a6 )
fprintf(stderr, "Missing errorhandling code in %s(), %s line %d:\n Condition(%s) not true.\n", a1, a2, a3, a4);
else
fprintf(stderr, "Assert error in %s(), %s line %d:\n Condition(%s) not true.\n", a1, a2, a3, a4);
if ( a5 )
{
v7 = strerror(a5);
fprintf(stderr, " errno = %d (%s)\n", a5, v7);
}
abort();
}

original_code:
static void
VAS_Fail_default(const char *func, const char *file, int line,
    const char *cond, int err, int xxx)
{
 if (xxx) {
  fprintf(stderr,
      "Missing errorhandling code in %s(), %s line %d:\n"
      "  Condition(%s) not true.\n",
      func, file, line, cond);
 } else {
  fprintf(stderr,
      "Assert error in %s(), %s line %d:\n"
      "  Condition(%s) not true.\n",
      func, file, line, cond);
 }
 if (err)
  fprintf(stderr,
      "  errno = %d (%s)\n", err, strerror(err));
 abort();
}

canonical_original_code:
static void VAS_Fail_default(char *func, char *file, int line, char *cond, int err, int xxx)
{
 if (xxx) {
  fprintf(stderr,
      "Missing errorhandling code in %s(), %s line %d:\n"
      "  Condition(%s) not true.\n",
      func, file, line, cond);
 } else {
  fprintf(stderr,
      "Assert error in %s(), %s line %d:\n"
      "  Condition(%s) not true.\n",
      func, file, line, cond);
 }
 if (err)
  fprintf(stderr,
      "  errno = %d (%s)\n", err, strerror(err));
 abort();
}

variable_types:
func
char *

variable_types:
file
char *

variable_types: line int

variable_types:
cond
char *

variable_types: err int

variable_types: xxx int

return_type: void


repo: wernsey/miscsrc

decompiled_code:
__int64 __fastcall get_char(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char v3; // al

result = *(unsigned int *)(a1 + 84);
if ( (_DWORD)result != -1 )
{
if ( (_DWORD)result )
{
*(_DWORD *)(a1 + 84) = 0;
result = (unsigned int)(char)result;
}
else
{
v2 = *(_DWORD *)(a1 + 80);
if ( v2 <= 63 )
{
*(_DWORD *)(a1 + 80) = v2 + 1;
v3 = *(_BYTE *)(a1 + v2 + 16);
if ( v3 )
return (unsigned int)v3;
}
if ( (*(unsigned int (__fastcall **)(__int64, __int64, _QWORD))a1)(a1 + 16, 64LL, *(_QWORD *)(a1 + 8)) )
{
*(_DWORD *)(a1 + 80) = 1;
return (unsigned int)*(char *)(a1 + 16);
}
*(_DWORD *)(a1 + 84) = -1;
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char v3; // al

result = *(unsigned int *)(a1 + 84);
if ( (_DWORD)result != -1 )
{
if ( (_DWORD)result )
{
*(_DWORD *)(a1 + 84) = 0;
result = (unsigned int)(char)result;
}
else
{
v2 = *(_DWORD *)(a1 + 80);
if ( v2 <= 63 )
{
*(_DWORD *)(a1 + 80) = v2 + 1;
v3 = *(_BYTE *)(a1 + v2 + 16);
if ( v3 )
return (unsigned int)v3;
}
if ( (*(unsigned int (__fastcall **)(__int64, __int64, _QWORD))a1)(a1 + 16, 64LL, *(_QWORD *)(a1 + 8)) )
{
*(_DWORD *)(a1 + 80) = 1;
return (unsigned int)*(char *)(a1 + 16);
}
*(_DWORD *)(a1 + 84) = -1;
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
static int get_char(CsvContext *csv) {
    char c = 0;
    if(csv->last_char == (-1)) {
        return (-1);
    } else if(csv->last_char) {
        c = csv->last_char;
        csv->last_char = 0;
        return c;
    }
    if(csv->in_pos >= 64 || (c = csv->raw_buffer[csv->in_pos++]) == '\0') {
        int cnt = csv->get_data(csv->raw_buffer, 64, csv->data);
        if(!cnt) {
            csv->last_char = (-1);
            return (-1);
        }
        csv->in_pos = 0;
        c = csv->raw_buffer[csv->in_pos++];
    }
    return c;
}

canonical_original_code:
static int get_char(struct CsvContext *csv) {
    char c = 0;
    if(csv->last_char == (-1)) {
        return (-1);
    } else if(csv->last_char) {
        c = csv->last_char;
        csv->last_char = 0;
        return c;
    }
    if(csv->in_pos >= 64 || (c = csv->raw_buffer[csv->in_pos++]) == '\0') {
        int cnt = csv->get_data(csv->raw_buffer, 64, csv->data);
        if(!cnt) {
            csv->last_char = (-1);
            return (-1);
        }
        csv->in_pos = 0;
        c = csv->raw_buffer[csv->in_pos++];
    }
    return c;
}

variable_types: struct CsvContext { int (*get_data)(char *b, int n, void *d); void *data; char raw_buffer[64]; int in_pos; int last_char; char buffer[256]; char *fields[32]; int nf; enum csv_error_code { CSV_OK=0, CSV_ERR_BUFFER=1, CSV_ERR_FIELDS=2, CSV_ERR_BAD_QUOTE=3, CSV_ERR_LINE_END=4 } err; } *

variable_types: c char

variable_types: cnt int

return_type: int

user_defined_types: struct CsvContext { int (*get_data)(char *b, int n, void *d); void *data; char raw_buffer[64]; int in_pos; int last_char; char buffer[256]; char *fields[32]; int nf; enum csv_error_code err; }


decompiled_code:
void __fastcall unget_char(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 84) = a2;
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 84) = a2;
}

original_code:
static void unget_char(CsvContext *csv, int c) {
    csv->last_char = c;
}

canonical_original_code:
static void unget_char(struct CsvContext *csv, int c) {
    csv->last_char = c;
}

variable_types: c int

user_defined_types: enum csv_error_code { CSV_OK=0, CSV_ERR_BUFFER=1, CSV_ERR_FIELDS=2, CSV_ERR_BAD_QUOTE=3, CSV_ERR_LINE_END=4 }


original_code:
int csv_read_record(CsvContext *csv) {
    int c = 0;
    size_t start, bump = 0;
    enum parse_state {
        RECORD_START, FIELD_START, FIELD, QUOTE, FIELD_END, RECORD_END
    } state = RECORD_START;
    if(csv->last_char == (-1)) return 0;
    csv->nf = 0;
    csv->err = CSV_OK;
    for(;;) {
        switch(state) {
            case RECORD_START:
                c = get_char(csv);
                if(c == (-1))
                    return 0;
                state = FIELD_START;
                unget_char(csv, c);
            break;
            case FIELD_START:
                if(csv->nf == 32) {
                    csv->err = CSV_ERR_FIELDS;
                    return csv->nf;
                }
                c = get_char(csv);
                while(strchr(" \t\v\f", c))
                    c = get_char(csv);
                csv->fields[csv->nf] = &csv->buffer[bump];
                if(c == '\"')
                    state = QUOTE;
                else {
                    unget_char(csv, c);
                    start = bump;
                    state = FIELD;
                }
            break;
            case FIELD:
                c = get_char(csv);
                if(c == '\r') {
                    c = get_char(csv);
                    if(c != '\n') {
                        csv->err = CSV_ERR_LINE_END;
                        return csv->nf;
                    }
                }
                if(c == (-1) || c == '\n' || c == ',') {
                    while(bump > start && strchr(" \t\v\f", csv->buffer[bump-1]))
                        bump--;
                    state = c == ',' ? FIELD_END : RECORD_END;
                } else {
                    if(bump == 256 - 1) {
                        csv->err = CSV_ERR_BUFFER;
                        return csv->nf;
                    }
                    csv->buffer[bump++] = c;
                }
            break;
            case QUOTE:
                c = get_char(csv);
                if(c == (-1)) {
                    csv->err = CSV_ERR_BAD_QUOTE;
                    return csv->nf;
                }
                if(c == '\"') {
                    c = get_char(csv);
                    if(c != '\"') {
                        while(strchr(" \t\v\f", c))
                            c = get_char(csv);
                        if(c == (-1) || c == '\n') {
                            state = RECORD_END;
                        } else if(c == ',') {
                            state = FIELD_END;
                        } else {
                            csv->err = CSV_ERR_BAD_QUOTE;
                            return csv->nf;
                        }
                        break;
                    }
                }
                if(bump == 256 - 1) {
                    csv->err = CSV_ERR_BUFFER;
                    return csv->nf;
                }
                csv->buffer[bump++] = c;
            break;
            case FIELD_END:
            case RECORD_END:
                if(bump == 256 - 1) {
                    csv->err = CSV_ERR_BUFFER;
                    return csv->nf;
                }
                csv->buffer[bump++] = '\0';
                csv->nf++;
                if(state == RECORD_END)
                    return csv->nf;
                else
                    state = FIELD_START;
            break;
        }
    }
}

canonical_original_code:
int csv_read_record(struct CsvContext *csv) {
    int c = 0;
    unsigned long start; unsigned long bump = 0;
    enum parse_state state = RECORD_START;
    if(csv->last_char == (-1)) return 0;
    csv->nf = 0;
    csv->err = CSV_OK;
    for(;;) {
        switch(state) {
            case RECORD_START:
                c = get_char(csv);
                if(c == (-1))
                    return 0;
                state = FIELD_START;
                unget_char(csv, c);
            break;
            case FIELD_START:
                if(csv->nf == 32) {
                    csv->err = CSV_ERR_FIELDS;
                    return csv->nf;
                }
                c = get_char(csv);
                while(strchr(" \t\v\f", c))
                    c = get_char(csv);
                csv->fields[csv->nf] = &csv->buffer[bump];
                if(c == '\"')
                    state = QUOTE;
                else {
                    unget_char(csv, c);
                    start = bump;
                    state = FIELD;
                }
            break;
            case FIELD:
                c = get_char(csv);
                if(c == '\r') {
                    c = get_char(csv);
                    if(c != '\n') {
                        csv->err = CSV_ERR_LINE_END;
                        return csv->nf;
                    }
                }
                if(c == (-1) || c == '\n' || c == ',') {
                    while(bump > start && strchr(" \t\v\f", csv->buffer[bump-1]))
                        bump--;
                    state = c == ',' ? FIELD_END : RECORD_END;
                } else {
                    if(bump == 256 - 1) {
                        csv->err = CSV_ERR_BUFFER;
                        return csv->nf;
                    }
                    csv->buffer[bump++] = c;
                }
            break;
            case QUOTE:
                c = get_char(csv);
                if(c == (-1)) {
                    csv->err = CSV_ERR_BAD_QUOTE;
                    return csv->nf;
                }
                if(c == '\"') {
                    c = get_char(csv);
                    if(c != '\"') {
                        while(strchr(" \t\v\f", c))
                            c = get_char(csv);
                        if(c == (-1) || c == '\n') {
                            state = RECORD_END;
                        } else if(c == ',') {
                            state = FIELD_END;
                        } else {
                            csv->err = CSV_ERR_BAD_QUOTE;
                            return csv->nf;
                        }
                        break;
                    }
                }
                if(bump == 256 - 1) {
                    csv->err = CSV_ERR_BUFFER;
                    return csv->nf;
                }
                csv->buffer[bump++] = c;
            break;
            case FIELD_END:
            case RECORD_END:
                if(bump == 256 - 1) {
                    csv->err = CSV_ERR_BUFFER;
                    return csv->nf;
                }
                csv->buffer[bump++] = '\0';
                csv->nf++;
                if(state == RECORD_END)
                    return csv->nf;
                else
                    state = FIELD_START;
            break;
        }
    }
}

variable_types:
start
unsigned long

variable_types:
bump
unsigned long

variable_types: enum parse_state { RECORD_START=0, FIELD_START=1, FIELD=2, QUOTE=3, FIELD_END=4, RECORD_END=5 }


original_code:
void csv_context_custom(CsvContext *csv, csv_read_data_fun fun, void *data) {
    csv->get_data = fun;
    csv->data = data;
    csv->last_char = 0;
    csv->in_pos = 64;
    csv->nf = 0;
    csv->err = CSV_OK;
}

canonical_original_code:
void csv_context_custom(struct CsvContext *csv, int (*fun)(char *b, int n, void *d), void *data) {
    csv->get_data = fun;
    csv->data = data;
    csv->last_char = 0;
    csv->in_pos = 64;
    csv->nf = 0;
    csv->err = CSV_OK;
}

variable_types:
fun
int (*)(char *b, int n, void *d)

variable_types:
data
void *


decompiled_code:
__int64 __fastcall csv_count(__int64 a1)
{
return *(unsigned int *)(a1 + 600);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(unsigned int *)(a1 + 600);
}

original_code:
int csv_count(CsvContext *csv) {
    return csv->nf;
}

canonical_original_code:
int csv_count(struct CsvContext *csv) {
    return csv->nf;
}


decompiled_code:
void *__fastcall csv_field(__int64 a1, int a2)
{
void *result; // rax

result = &unk_55D;
if ( a2 >= 0 && *(_DWORD *)(a1 + 600) > a2 )
result = *(void **)(a1 + 8LL * a2 + 344);
return result;
}

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

result = &unk_55D;
if ( a2 >= 0 && *(_DWORD *)(a1 + 600) > a2 )
result = *(void **)(a1 + 8LL * a2 + 344);
return result;
}

original_code:
const char *csv_field(CsvContext *csv, int i) {
    if(i < 0 || i >= csv->nf) return "";
    return csv->fields[i];
}

canonical_original_code:
char *csv_field(struct CsvContext *csv, int i) {
    if(i < 0 || i >= csv->nf) return "";
    return csv->fields[i];
}

variable_types: i int

return_type: char *


decompiled_code:
__int64 __fastcall csv_get_error(__int64 a1)
{
return *(unsigned int *)(a1 + 604);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return *(unsigned int *)(a1 + 604);
}

original_code:
enum csv_error_code csv_get_error(CsvContext *csv) {
    return csv->err;
}

canonical_original_code:
enum csv_error_code csv_get_error(struct CsvContext *csv) {
    return csv->err;
}

return_type: enum csv_error_code { CSV_OK=0, CSV_ERR_BUFFER=1, CSV_ERR_FIELDS=2, CSV_ERR_BAD_QUOTE=3, CSV_ERR_LINE_END=4 }


original_code:
static int csv_set_int(csv_file *csv, int row, int col, char *value)
{
 csv_row *rp;
 if(!csv || row < 0 || col < 0) return -4;
 if(row >= csv->nrows)
 {
  if(row >= csv->arows)
  {
   int i, ns = (((row+1)>(csv->arows + (csv->arows >> 1)))?(row+1):(csv->arows + (csv->arows >> 1)));
   void *op = csv->rows;
   if(ns <= 2) ns = 3;
   csv->rows = realloc(csv->rows, ns * sizeof *csv->rows);
   if(!csv->rows)
   {
    csv->rows = op;
    return -1;
   }
   for(i = csv->arows; i < ns; i++)
   {
    csv->rows[i].cols = calloc(csv->def_cols, sizeof *csv->rows[i].cols);
    if(!csv->rows[i].cols)
     return -1;
    csv->rows[i].acols = csv->def_cols;
    csv->rows[i].ncols = 0;
   }
   csv->arows = ns;
  }
  csv->nrows = row + 1;
  ((void) (0));
 }
 ((void) (0));
 rp = &csv->rows[row];
 if(col >= rp->ncols)
 {
  if(col >= rp->acols)
  {
   int i, ns = (((col+1)>(rp->acols + (rp->acols >> 1)))?(col+1):(rp->acols + (rp->acols >> 1)));
   void *op = rp->cols;
   if(ns <= 2) ns = 3;
   rp->cols = realloc(rp->cols, ns * sizeof *rp->cols);
   if(!rp->cols)
   {
    rp->cols = op;
    return -1;
   }
   for(i = rp->acols; i < ns; i++)
    rp->cols[i] = ((void *)0);
   rp->acols = ns;
  }
  rp->ncols = col + 1;
  ((void) (0));
 }
 ((void) (0));
 if(rp->cols[col])
  free(rp->cols[col]);
 rp->cols[col] = value;
 if(rp->cols[col])
  return 1;
 return -1;
}

canonical_original_code:
static int csv_set_int(struct csv_file *csv, int row, int col, char *value)
{
 struct csv_row *rp;
 if(!csv || row < 0 || col < 0) return -4;
 if(row >= csv->nrows)
 {
  if(row >= csv->arows)
  {
   int i; int ns = (((row+1)>(csv->arows + (csv->arows >> 1)))?(row+1):(csv->arows + (csv->arows >> 1)));
   void *op = csv->rows;
   if(ns <= 2) ns = 3;
   csv->rows = realloc(csv->rows, ns * sizeof *csv->rows);
   if(!csv->rows)
   {
    csv->rows = op;
    return -1;
   }
   for(i = csv->arows; i < ns; i++)
   {
    csv->rows[i].cols = calloc(csv->def_cols, sizeof *csv->rows[i].cols);
    if(!csv->rows[i].cols)
     return -1;
    csv->rows[i].acols = csv->def_cols;
    csv->rows[i].ncols = 0;
   }
   csv->arows = ns;
  }
  csv->nrows = row + 1;
  ((void) (0));
 }
 ((void) (0));
 rp = &csv->rows[row];
 if(col >= rp->ncols)
 {
  if(col >= rp->acols)
  {
   int i; int ns = (((col+1)>(rp->acols + (rp->acols >> 1)))?(col+1):(rp->acols + (rp->acols >> 1)));
   void *op = rp->cols;
   if(ns <= 2) ns = 3;
   rp->cols = realloc(rp->cols, ns * sizeof *rp->cols);
   if(!rp->cols)
   {
    rp->cols = op;
    return -1;
   }
   for(i = rp->acols; i < ns; i++)
    rp->cols[i] = ((void *)0);
   rp->acols = ns;
  }
  rp->ncols = col + 1;
  ((void) (0));
 }
 ((void) (0));
 if(rp->cols[col])
  free(rp->cols[col]);
 rp->cols[col] = value;
 if(rp->cols[col])
  return 1;
 return -1;
}

variable_types: struct csv_file { int nrows; int arows; struct csv_row { int ncols; int acols; char **cols; } *rows; int def_cols; } *

variable_types: row int

variable_types: col int

variable_types:
value
char *

variable_types: ns int

variable_types:
op
void *

user_defined_types: struct csv_file { int nrows; int arows; struct csv_row *rows; int def_cols; }


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

switch ( a1 )
{
case -6:
result = "Expected a field or record separator after the \"";
break;
case -5:
result = "Unterminated string";
break;
case -4:
result = "Invalid parameter";
break;
case -3:
result = "Unable to read file";
break;
case -2:
result = "Unable to open file for writing";
break;
case -1:
result = "Out of memory";
break;
case 1:
result = "Success";
break;
default:
result = "Unknown";
break;
}
return result;
}

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

switch ( a1 )
{
case -6:
result = "Expected a field or record separator after the \"";
break;
case -5:
result = "Unterminated string";
break;
case -4:
result = "Invalid parameter";
break;
case -3:
result = "Unable to read file";
break;
case -2:
result = "Unable to open file for writing";
break;
case -1:
result = "Out of memory";
break;
case 1:
result = "Success";
break;
default:
result = "Unknown";
break;
}
return result;
}

original_code:
const char *csv_errstr(int err)
{
 switch(err)
 {
  case 1: return "Success";
  case -1: return "Out of memory";
  case -2: return "Unable to open file for writing";
  case -3: return "Unable to read file";
  case -4: return "Invalid parameter";
  case -5 : return "Unterminated string";
  case -6 : return "Expected a field or record separator after the \"";
 }
 return "Unknown";
}

variable_types: err int


original_code:
void csv_free(csv_file *csv)
{
 int r,c;
 for(r = 0; r < csv->arows; r++)
 {
  for(c = 0; c < csv->rows[r].acols; c++)
   if(csv->rows[r].cols[c])
    free(csv->rows[r].cols[c]);
  free(csv->rows[r].cols);
 }
 free(csv->rows);
 free(csv);
}

canonical_original_code:
void csv_free(struct csv_file *csv)
{
 int r; int c;
 for(r = 0; r < csv->arows; r++)
 {
  for(c = 0; c < csv->rows[r].acols; c++)
   if(csv->rows[r].cols[c])
    free(csv->rows[r].cols[c]);
  free(csv->rows[r].cols);
 }
 free(csv->rows);
 free(csv);
}

variable_types: r int

user_defined_types: struct csv_row { int ncols; int acols; char **cols; }


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

if ( a1 )
result = *a1;
else
result = 0LL;
return result;
}

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

if ( a1 )
result = *a1;
else
result = 0LL;
return result;
}

original_code:
int csv_rowcount(csv_file *csv)
{
 if(!csv) return 0;
 return csv->nrows;
}

canonical_original_code:
int csv_rowcount(struct csv_file *csv)
{
 if(!csv) return 0;
 return csv->nrows;
}


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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_DWORD *)a1 > a2 )
result = *(unsigned int *)(*(_QWORD *)(a1 + 8) + 16LL * a2);
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_DWORD *)a1 > a2 )
result = *(unsigned int *)(*(_QWORD *)(a1 + 8) + 16LL * a2);
return result;
}

original_code:
int csv_colcount(csv_file *csv, int row)
{
 if(!csv || row >= csv->nrows) return 0;
 return csv->rows[row].ncols;
}

canonical_original_code:
int csv_colcount(struct csv_file *csv, int row)
{
 if(!csv || row >= csv->nrows) return 0;
 return csv->rows[row].ncols;
}


decompiled_code:
void *__fastcall csv_get(__int64 a1, int a2, int a3)
{
void *result; // rax
__int64 v4; // rcx

if ( !a1 )
return &unk_AE3;
result = &unk_AE3;
if ( *(_DWORD *)a1 > a2 )
{
v4 = *(_QWORD *)(a1 + 8) + 16LL * a2;
if ( *(_DWORD *)v4 > a3 )
{
if ( a2 < 0 || a3 < 0 )
{
result = &unk_AE3;
}
else
{
result = *(void **)(*(_QWORD *)(v4 + 8) + 8LL * a3);
if ( !result )
result = &unk_AE3;
}
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func8(__int64 a1, int a2, int a3)
{
void *result; // rax
__int64 v4; // rcx

if ( !a1 )
return &unk_AE3;
result = &unk_AE3;
if ( *(_DWORD *)a1 > a2 )
{
v4 = *(_QWORD *)(a1 + 8) + 16LL * a2;
if ( *(_DWORD *)v4 > a3 )
{
if ( a2 < 0 || a3 < 0 )
{
result = &unk_AE3;
}
else
{
result = *(void **)(*(_QWORD *)(v4 + 8) + 8LL * a3);
if ( !result )
result = &unk_AE3;
}
}
}
return result;
}

original_code:
const char *csv_get(csv_file *csv, int row, int col)
{
 if(!csv || row >= csv->nrows || col >= csv->rows[row].ncols || row < 0 || col < 0 || !csv->rows[row].cols[col])
  return "";
 return csv->rows[row].cols[col];
}

canonical_original_code:
char *csv_get(struct csv_file *csv, int row, int col)
{
 if(!csv || row >= csv->nrows || col >= csv->rows[row].ncols || row < 0 || col < 0 || !csv->rows[row].cols[col])
  return "";
 return csv->rows[row].cols[col];
}


decompiled_code:
__int64 __fastcall csv_set(__int64 a1, int a2, int a3, __int64 a4)
{
__int64 v5; // rax

v5 = my_strdup(a4);
return csv_set_int(a1, a2, a3, v5);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2, int a3, __int64 a4)
{
__int64 v5; // rax

v5 = my_strdup(a4);
return func0(a1, a2, a3, v5);
}

original_code:
int csv_set(csv_file *csv, int row, int col, const char *value)
{
 return csv_set_int(csv, row, col, my_strdup(value));
}

canonical_original_code:
int csv_set(struct csv_file *csv, int row, int col, char *value)
{
 return csv_set_int(csv, row, col, my_strdup(value));
}


decompiled_code:
__int64 csv_setx(__int64 a1, int a2, int a3, const char *a4, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-2E0h] BYREF
char s[512]; // [rsp+20h] [rbp-2C8h] BYREF

va_start(arg, a4);
vsnprintf(s, 0x200uLL, a4, arg);
return csv_set(a1, a2, a3, (__int64)s);
}

canonical_decompiled_code:
__int64 func10(__int64 a1, int a2, int a3, const char *a4, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-2E0h] BYREF
char s[512]; // [rsp+20h] [rbp-2C8h] BYREF

va_start(arg, a4);
vsnprintf(s, 0x200uLL, a4, arg);
return func9(a1, a2, a3, (__int64)s);
}

original_code:
int csv_setx(csv_file *csv, int row, int col, const char *fmt, ...)
{
 char buffer[512];
 va_list arg;
 __builtin_va_start(arg,fmt);
 vsnprintf (buffer, 512, fmt, arg);
 __builtin_va_end(arg);
 return csv_set(csv, row, col, buffer);
}

canonical_original_code:
int csv_setx(struct csv_file *csv, int row, int col, char *fmt, ...)
{
 char buffer[512];
 __builtin_va_list arg;
 __builtin_va_start(arg,fmt);
 vsnprintf (buffer, 512, fmt, arg);
 __builtin_va_end(arg);
 return csv_set(csv, row, col, buffer);
}

variable_types:
fmt
char *

variable_types:
buffer
char [512]


decompiled_code:
__int64 __fastcall my_stricmp(char *a1, char *a2)
{
char v3; // bl
char *v4; // r12
const __int32_t *v5; // rax
const __int32_t **v6; // rax

v3 = *a1;
if ( *a1 )
{
v4 = a1;
v5 = *_ctype_tolower_loc();
do
{
if ( v5[*a2] != v5[v3] )
break;
++v4;
++a2;
v3 = *v4;
}
while ( *v4 );
}
v6 = _ctype_tolower_loc();
return (unsigned int)((*v6)[v3] - (*v6)[*a2]);
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, char *a2)
{
char v3; // bl
char *v4; // r12
const __int32_t *v5; // rax
const __int32_t **v6; // rax

v3 = *a1;
if ( *a1 )
{
v4 = a1;
v5 = *_ctype_tolower_loc();
do
{
if ( v5[*a2] != v5[v3] )
break;
++v4;
++a2;
v3 = *v4;
}
while ( *v4 );
}
v6 = _ctype_tolower_loc();
return (unsigned int)((*v6)[v3] - (*v6)[*a2]);
}

original_code:
int my_stricmp(const char *p, const char *q) {
    for(;*p && tolower(*p) == tolower(*q); p++, q++);
    return tolower(*p) - tolower(*q);
}

canonical_original_code:
int my_stricmp(char *p, char *q) {
    for(;*p && tolower(*p) == tolower(*q); p++, q++);
    return tolower(*p) - tolower(*q);
}

variable_types:
p
char *

variable_types:
q
char *


decompiled_code:
void *__fastcall my_strdup(void *src)
{
size_t v1; // r12
void *v2; // rax
void *v3; // rbx

v1 = strlen((const char *)src) + 1;
v2 = malloc(v1);
v3 = v2;
if ( v2 )
memcpy(v2, src, v1);
return v3;
}

canonical_decompiled_code:
void *__fastcall func1(void *src)
{
size_t v1; // r12
void *v2; // rax
void *v3; // rbx

v1 = strlen((const char *)src) + 1;
v2 = malloc(v1);
v3 = v2;
if ( v2 )
memcpy(v2, src, v1);
return v3;
}

original_code:
char *my_strdup(const char *s) {
    char *a;
    size_t len = strlen(s);
    a = malloc(len + 1);
    if(!a) return ((void *)0);
    memcpy(a, s, len + 1);
    return a;
}

canonical_original_code:
char *my_strdup(char *s) {
    char *a;
    unsigned long len = strlen(s);
    a = malloc(len + 1);
    if(!a) return ((void *)0);
    memcpy(a, s, len + 1);
    return a;
}

variable_types:
s
char *

variable_types:
a
char *

variable_types:
len
unsigned long


original_code:
char *my_strtok_r(char *str, const char *delim, char **saveptr) {
    char *s;
    if(!str)
        str = *saveptr;
    if(!str[0]) {
        *saveptr = str;
        return ((void *)0);
    }
    s = strpbrk(str, delim);
    if(s) {
        s[0] = '\0';
        *saveptr = s + 1;
        while((*saveptr)[0] && strchr(delim, (*saveptr)[0]))
            (*saveptr)++;
    } else
        for(*saveptr = str; (*saveptr)[0]; (*saveptr)++);
    return str;
}

canonical_original_code:
char *my_strtok_r(char *str, char *delim, char **saveptr) {
    char *s;
    if(!str)
        str = *saveptr;
    if(!str[0]) {
        *saveptr = str;
        return ((void *)0);
    }
    s = strpbrk(str, delim);
    if(s) {
        s[0] = '\0';
        *saveptr = s + 1;
        while((*saveptr)[0] && strchr(delim, (*saveptr)[0]))
            (*saveptr)++;
    } else
        for(*saveptr = str; (*saveptr)[0]; (*saveptr)++);
    return str;
}

variable_types:
str
char *

variable_types:
delim
char *

variable_types:
saveptr
char **


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

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

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

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

original_code:
link_list *list_create()
{
 link_list *list;
 list = malloc(sizeof *list);
 if(!list)
  return ((void *)0);
 list->first = ((void *)0);
 list->last = ((void *)0);
 return list;
}

canonical_original_code:
struct link_list *list_create()
{
 struct link_list *list;
 list = malloc(sizeof *list);
 if(!list)
  return ((void *)0);
 list->first = ((void *)0);
 list->last = ((void *)0);
 return list;
}

variable_types: struct link_list { struct list_element { struct list_element *next; void *data; } *first; } *

user_defined_types: struct link_list { struct list_element *first; }


decompiled_code:
void __fastcall list_destroy(void *ptr, void (__fastcall *a2)(_QWORD))
{
_QWORD *v2; // rbx
_QWORD *v3; // rax

v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
if ( a2 )
a2(v3[2]);
free(*(void **)ptr);
*(_QWORD *)ptr = v2;
}
while ( v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr, void (__fastcall *a2)(_QWORD))
{
_QWORD *v2; // rbx
_QWORD *v3; // rax

v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
if ( a2 )
a2(v3[2]);
free(*(void **)ptr);
*(_QWORD *)ptr = v2;
}
while ( v2 );
}
free(ptr);
}

original_code:
void list_destroy(link_list *list, list_dtor dtor)
{
 while(list->first) {
  list_element *next = list->first->next;
  if(dtor) dtor(list->first->data);
  free(list->first);
  list->first = next;
 }
 free(list);
}

canonical_original_code:
void list_destroy(struct link_list *list, void (*dtor)(void *data))
{
 while(list->first) {
  struct list_element *next = list->first->next;
  if(dtor) dtor(list->first->data);
  free(list->first);
  list->first = next;
 }
 free(list);
}

variable_types:
dtor
void (*)(void *data)

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


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

if ( !a1 )
return 1LL;
if ( !a2 )
return 1LL;
v2 = (_QWORD *)*a1;
if ( !*a1 )
return 1LL;
while ( 1 )
{
result = a2(v2[2]);
if ( !(_DWORD)result )
break;
v2 = (_QWORD *)*v2;
if ( !v2 )
return 1LL;
}
return result;
}

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

if ( !a1 )
return 1LL;
if ( !a2 )
return 1LL;
v2 = (_QWORD *)*a1;
if ( !*a1 )
return 1LL;
while ( 1 )
{
result = a2(v2[2]);
if ( !(_DWORD)result )
break;
v2 = (_QWORD *)*v2;
if ( !v2 )
return 1LL;
}
return result;
}

original_code:
int list_iterate(link_list *list, list_iter iter)
{
 list_element *le;
 if(!list || !iter) return 1;
 for(le = list->first; le; le = le->next)
  if(!iter(le->data))
   return 0;
 return 1;
}

canonical_original_code:
int list_iterate(struct link_list *list, int (*iter)(void *data))
{
 struct list_element *le;
 if(!list || !iter) return 1;
 for(le = list->first; le; le = le->next)
  if(!iter(le->data))
   return 0;
 return 1;
}

variable_types:
iter
int (*)(void *data)

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


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

if ( !a1 )
return 1LL;
if ( !a2 )
return 1LL;
v2 = *(_QWORD *)(a1 + 8);
if ( !v2 )
return 1LL;
while ( 1 )
{
result = a2(*(_QWORD *)(v2 + 16));
if ( !(_DWORD)result )
break;
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
return 1LL;
}
return result;
}

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

if ( !a1 )
return 1LL;
if ( !a2 )
return 1LL;
v2 = *(_QWORD *)(a1 + 8);
if ( !v2 )
return 1LL;
while ( 1 )
{
result = a2(*(_QWORD *)(v2 + 16));
if ( !(_DWORD)result )
break;
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
return 1LL;
}
return result;
}

original_code:
int list_iterate_reverse(link_list *list, list_iter iter)
{
 list_element *le;
 if(!list || !iter) return 1;
 for(le = list->last; le; le = le->prev)
  if(!iter(le->data))
   return 0;
 return 1;
}

canonical_original_code:
int list_iterate_reverse(struct link_list *list, int (*iter)(void *data))
{
 struct list_element *le;
 if(!list || !iter) return 1;
 for(le = list->last; le; le = le->prev)
  if(!iter(le->data))
   return 0;
 return 1;
}


original_code:
void *list_remove_element(link_list *list, list_element *el)
{
 void *d = el->data;
 ((void) (0));
 if(!el) return ((void *)0);
 if(!el->prev)
 {
  ((void) (0));
  if(!el->next)
  {
   ((void) (0));
   list->first = ((void *)0);
   list->last = ((void *)0);
  }
  else
  {
   list->first = el->next;
   el->next->prev = ((void *)0);
  }
 }
 else
 {
  if(!el->next)
  {
   ((void) (0));
   list->last = el->prev;
   el->prev->next = ((void *)0);
  }
  else
  {
   el->next->prev = el->prev;
   el->prev->next = el->next;
  }
 }
 free(el);
 return d;
}

canonical_original_code:
void *list_remove_element(struct link_list *list, struct list_element *el)
{
 void *d = el->data;
 ((void) (0));
 if(!el) return ((void *)0);
 if(!el->prev)
 {
  ((void) (0));
  if(!el->next)
  {
   ((void) (0));
   list->first = ((void *)0);
   list->last = ((void *)0);
  }
  else
  {
   list->first = el->next;
   el->next->prev = ((void *)0);
  }
 }
 else
 {
  if(!el->next)
  {
   ((void) (0));
   list->last = el->prev;
   el->prev->next = ((void *)0);
  }
  else
  {
   el->next->prev = el->prev;
   el->prev->next = el->next;
  }
 }
 free(el);
 return d;
}

variable_types:
el
struct list_element *

variable_types:
d
void *

return_type: void *


decompiled_code:
_BOOL8 __fastcall list_strcmp(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int list_strcmp(void *p, void *q)
{
 char *s1 = p, *s2 = q;
 return !strcmp(s1, s2);
}

canonical_original_code:
int list_strcmp(void *p, void *q)
{
 char *s1 = p; char *s2 = q;
 return !strcmp(s1, s2);
}

variable_types:
p
void *

variable_types:
q
void *


decompiled_code:
_BOOL8 __fastcall list_stricmp(char *a1, char *a2)
{
char *v2; // r13
char i; // bp
char v5; // bl
const __int32_t **v6; // rax
const __int32_t **v7; // rax

v2 = a1;
for ( i = *a1; *v2; i = *v2 )
{
v5 = *a2;
if ( !*a2 )
break;
v6 = _ctype_tolower_loc();
if ( (*v6)[i] != (*v6)[v5] )
break;
++v2;
++a2;
}
v7 = _ctype_tolower_loc();
return (*v7)[*a2] == (*v7)[i];
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(char *a1, char *a2)
{
char *v2; // r13
char i; // bp
char v5; // bl
const __int32_t **v6; // rax
const __int32_t **v7; // rax

v2 = a1;
for ( i = *a1; *v2; i = *v2 )
{
v5 = *a2;
if ( !*a2 )
break;
v6 = _ctype_tolower_loc();
if ( (*v6)[i] != (*v6)[v5] )
break;
++v2;
++a2;
}
v7 = _ctype_tolower_loc();
return (*v7)[*a2] == (*v7)[i];
}

original_code:
int list_stricmp(void *p, void *q)
{
 char *s1 = p, *s2 = q;
 for(;s1[0] && s2[0] && tolower(s1[0]) == tolower(s2[0]); s1++, s2++);
 return tolower(s1[0]) == tolower(s2[0]);
}

canonical_original_code:
int list_stricmp(void *p, void *q)
{
 char *s1 = p; char *s2 = q;
 for(;s1[0] && s2[0] && tolower(s1[0]) == tolower(s2[0]); s1++, s2++);
 return tolower(s1[0]) == tolower(s2[0]);
}


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

result = *a1;
if ( *a1 )
result = list_remove_element(a1, (_QWORD *)*a1);
return result;
}

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

result = *a1;
if ( *a1 )
result = func4(a1, (_QWORD *)*a1);
return result;
}

original_code:
void *list_pop_front(link_list *list)
{
 ((void) (0));
 if(!list->first)
 {
  ((void) (0));
  return ((void *)0);
 }
 return list_remove_element(list, list->first);
}

canonical_original_code:
void *list_pop_front(struct link_list *list)
{
 ((void) (0));
 if(!list->first)
 {
  ((void) (0));
  return ((void *)0);
 }
 return list_remove_element(list, list->first);
}


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

result = a1[1];
if ( result )
result = list_remove_element(a1, (_QWORD *)a1[1]);
return result;
}

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

result = a1[1];
if ( result )
result = func4(a1, (_QWORD *)a1[1]);
return result;
}

original_code:
void *list_pop_back(link_list *list)
{
 ((void) (0));
 if(!list->last)
 {
  ((void) (0));
  return ((void *)0);
 }
 return list_remove_element(list, list->last);
}

canonical_original_code:
void *list_pop_back(struct link_list *list)
{
 ((void) (0));
 if(!list->last)
 {
  ((void) (0));
  return ((void *)0);
 }
 return list_remove_element(list, list->last);
}


decompiled_code:
_BOOL8 __fastcall list_isempty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
int list_isempty(link_list *list)
{
 ((void) (0));
 return !list->first;
}

canonical_original_code:
int list_isempty(struct link_list *list)
{
 ((void) (0));
 return !list->first;
}


decompiled_code:
__int64 __fastcall list_count(_QWORD **a1)
{
_QWORD *v1; // rax
unsigned int v2; // edx

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

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD **a1)
{
_QWORD *v1; // rax
unsigned int v2; // edx

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

original_code:
int list_count(link_list *list)
{
 list_element *le;
 int count = 0;
 ((void) (0));
 for(le = list->first; le; le = le->next)
  count++;
 return count;
}

canonical_original_code:
int list_count(struct link_list *list)
{
 struct list_element *le;
 int count = 0;
 ((void) (0));
 for(le = list->first; le; le = le->next)
  count++;
 return count;
}

variable_types: count int


pop

original_code:
static double pop(struct eval *ev)
{
 ((void) (0));
 return ev->st[--ev->sp];
}

variable_types: struct eval { struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } j[1]; char *p; double *st; int st_size; int sp; struct { int type; double n_val; char s_val[11]; } token[2]; int cur_tok; } *

return_type: double

user_defined_types: struct eval { struct __jmp_buf_tag j[1]; char *p; double *st; int st_size; int sp; struct { int type; double n_val; char s_val[11]; } token[2]; int cur_tok; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


lex

original_code:
static int lex(struct eval *ev)
{
 int next_tok;
start:
 next_tok = ev->cur_tok;
 ev->cur_tok = ev->cur_tok?0:1;
 while(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short int) _ISspace)) ev->p++;
 if(!ev->p[0])
 {
  ev->token[next_tok].type = 0;
  goto end;
 }
 else if(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short int) _ISdigit) || ev->p[0] == '.')
 {
  char *endp;
  ev->token[next_tok].type = 3;
  ev->token[next_tok].n_val = strtod(ev->p, &endp);
  ev->p = endp;
  goto end;
 }
 else if(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short int) _ISalpha))
 {
  int i;
  for(i = 0; ((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short int) _ISalnum) && i < 11 - 1; i++, ev->p++)
   ev->token[next_tok].s_val[i] = ev->p[0];
  if(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short int) _ISalpha)) longjmp(ev->j, 3);
  ev->token[next_tok].s_val[i] = '\0';
  ev->token[next_tok].type = 2;
  goto end;
 }
 else if(strchr("+-*/%(),^", ev->p[0]))
 {
  ev->token[next_tok].type = ev->p[0];
  ev->p++;
  goto end;
 }
 else
  longjmp(ev->j, 2);
end:
 if(ev->token[ev->cur_tok].type == 1)
  goto start;
 return ev->token[ev->cur_tok].type;
}

canonical_original_code:
static int lex(struct eval *ev)
{
 int next_tok;
start:
 next_tok = ev->cur_tok;
 ev->cur_tok = ev->cur_tok?0:1;
 while(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short) _ISspace)) ev->p++;
 if(!ev->p[0])
 {
  ev->token[next_tok].type = 0;
  goto end;
 }
 else if(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short) _ISdigit) || ev->p[0] == '.')
 {
  char *endp;
  ev->token[next_tok].type = 3;
  ev->token[next_tok].n_val = strtod(ev->p, &endp);
  ev->p = endp;
  goto end;
 }
 else if(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short) _ISalpha))
 {
  int i;
  for(i = 0; ((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short) _ISalnum) && i < 11 - 1; i++, ev->p++)
   ev->token[next_tok].s_val[i] = ev->p[0];
  if(((*__ctype_b_loc ())[(int) ((ev->p[0]))] & (unsigned short) _ISalpha)) longjmp(ev->j, 3);
  ev->token[next_tok].s_val[i] = '\0';
  ev->token[next_tok].type = 2;
  goto end;
 }
 else if(strchr("+-*/%(),^", ev->p[0]))
 {
  ev->token[next_tok].type = ev->p[0];
  ev->p++;
  goto end;
 }
 else
  longjmp(ev->j, 2);
end:
 if(ev->token[ev->cur_tok].type == 1)
  goto start;
 return ev->token[ev->cur_tok].type;
}

variable_types:
endp
char *

variable_types: i int

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }


istrcmp

decompiled_code:
__int64 __fastcall istrcmp(__int64 a1, __int64 a2)
{
const __int32_t *v4; // rsi
__int64 v5; // rax
char v6; // dl
__int32_t v7; // ecx
__int32_t v8; // edi

v4 = *_ctype_tolower_loc();
v5 = 0LL;
do
{
v6 = *(_BYTE *)(a1 + v5);
v7 = v4[v6];
v8 = v4[*(char *)(a2 + v5++)];
}
while ( v6 && v8 == v7 );
return (unsigned int)(v7 - v8);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
const __int32_t *v4; // rsi
__int64 v5; // rax
char v6; // dl
__int32_t v7; // ecx
__int32_t v8; // edi

v4 = *_ctype_tolower_loc();
v5 = 0LL;
do
{
v6 = *(_BYTE *)(a1 + v5);
v7 = v4[v6];
v8 = v4[*(char *)(a2 + v5++)];
}
while ( v6 && v8 == v7 );
return (unsigned int)(v7 - v8);
}

original_code:
static int istrcmp(const char *p, const char *q)
{
 for(; tolower(p[0]) == tolower(q[0]) && p[0]; p++, q++);
 return tolower(p[0]) - tolower(q[0]);
}

canonical_original_code:
static int istrcmp(char *p, char *q)
{
 for(; tolower(p[0]) == tolower(q[0]) && p[0]; p++, q++);
 return tolower(p[0]) - tolower(q[0]);
}

variable_types:
p
char *

variable_types:
q
char *


push

decompiled_code:
__int64 __fastcall push(struct __jmp_buf_tag env[1], double a2)
{
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax
void *v5; // r13
int v6; // er12
void *v7; // rax

v2 = env[1].__jmpbuf[2];
if ( HIDWORD(env[1].__jmpbuf[2]) == v2 )
{
v5 = (void *)env[1].__jmpbuf[1];
v6 = v2 + (v2 >> 1);
v7 = realloc(v5, v6);
env[1].__jmpbuf[1] = (__int64)v7;
if ( !v7 )
{
env[1].__jmpbuf[1] = (__int64)v5;
longjmp(env, 1);
}
LODWORD(env[1].__jmpbuf[2]) = v6;
}
v3 = env[1].__jmpbuf[1];
LODWORD(result) = HIDWORD(env[1].__jmpbuf[2]);
HIDWORD(env[1].__jmpbuf[2]) = result + 1;
result = (int)result;
*(double *)(v3 + 8LL * (int)result) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(struct __jmp_buf_tag env[1], double a2)
{
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax
void *v5; // r13
int v6; // er12
void *v7; // rax

v2 = env[1].__jmpbuf[2];
if ( HIDWORD(env[1].__jmpbuf[2]) == v2 )
{
v5 = (void *)env[1].__jmpbuf[1];
v6 = v2 + (v2 >> 1);
v7 = realloc(v5, v6);
env[1].__jmpbuf[1] = (__int64)v7;
if ( !v7 )
{
env[1].__jmpbuf[1] = (__int64)v5;
longjmp(env, 1);
}
LODWORD(env[1].__jmpbuf[2]) = v6;
}
v3 = env[1].__jmpbuf[1];
LODWORD(result) = HIDWORD(env[1].__jmpbuf[2]);
HIDWORD(env[1].__jmpbuf[2]) = result + 1;
result = (int)result;
*(double *)(v3 + 8LL * (int)result) = a2;
return result;
}

original_code:
static void push(struct eval *ev, double d)
{
 if(ev->sp == ev->st_size)
 {
  double *old = ev->st;
  int new_size = ev->st_size + (ev->st_size >> 1);
  ev->st = realloc(ev->st, new_size);
  if(!ev->st)
  {
   ev->st = old;
   longjmp(ev->j, 1);
  }
  ev->st_size = new_size;
 }
 ev->st[ev->sp++] = d;
}

variable_types: d double

variable_types:
old
double *


decompiled_code:
__int64 __fastcall num_expr(struct __jmp_buf_tag env[1])
{
char *v1; // rax

v1 = (char *)env + 32 * SLODWORD(env[1].__saved_mask.__val[2]);
if ( *((_DWORD *)v1 + 56) != 3 )
longjmp(env, 4);
push(env, *((double *)v1 + 29));
return lex((__int64)env);
}

canonical_decompiled_code:
__int64 __fastcall func4(struct __jmp_buf_tag env[1])
{
char *v1; // rax

v1 = (char *)env + 32 * SLODWORD(env[1].__saved_mask.__val[2]);
if ( *((_DWORD *)v1 + 56) != 3 )
longjmp(env, 4);
func3(env, *((double *)v1 + 29));
return func1((__int64)env);
}

original_code:
static void num_expr(struct eval *ev)
{
 if((ev->token[ev->cur_tok].type) != 3)
  longjmp(ev->j, (4));
 push(ev, ev->token[ev->cur_tok].n_val);
 lex(ev);
}


decompiled_code:
__int64 __fastcall mul_expr(struct __jmp_buf_tag env[1])
{
double v1; // rbp
double v2; // xmm2_8
double v3; // r12
double v4; // xmm0_8
double v5; // xmm0_8
__int64 result; // rax
int v7; // ebp

pow_expr(env);
while ( 1 )
{
while ( 1 )
{
result = 4LL * SLODWORD(env[1].__saved_mask.__val[2]);
v7 = env[1].__jmpbuf[result + 3];
if ( v7 != 42 )
break;
lex((__int64)env);
pow_expr(env);
v1 = pop((__int64)env);
v2 = v1 * pop((__int64)env);
push(env, v2);
}
if ( v7 != 47 && v7 != 37 )
break;
lex((__int64)env);
pow_expr(env);
v3 = pop((__int64)env);
v4 = pop((__int64)env);
if ( v7 == 47 )
{
push(env, v4 / v3);
}
else
{
v5 = fmod(v4, v3);
push(env, v5);
}
}
return result * 8;
}

canonical_decompiled_code:
__int64 __fastcall func5(struct __jmp_buf_tag env[1])
{
double v1; // rbp
double v2; // xmm2_8
double v3; // r12
double v4; // xmm0_8
double v5; // xmm0_8
__int64 result; // rax
int v7; // ebp

func10(env);
while ( 1 )
{
while ( 1 )
{
result = 4LL * SLODWORD(env[1].__saved_mask.__val[2]);
v7 = env[1].__jmpbuf[result + 3];
if ( v7 != 42 )
break;
func1((__int64)env);
func10(env);
v1 = func0((__int64)env);
v2 = v1 * func0((__int64)env);
func3(env, v2);
}
if ( v7 != 47 && v7 != 37 )
break;
func1((__int64)env);
func10(env);
v3 = func0((__int64)env);
v4 = func0((__int64)env);
if ( v7 == 47 )
{
func3(env, v4 / v3);
}
else
{
v5 = fmod(v4, v3);
func3(env, v5);
}
}
return result * 8;
}

original_code:
static void mul_expr(struct eval *ev)
{
 int t;
 pow_expr(ev);
 while((t = (ev->token[ev->cur_tok].type)) == '*' || t == '/' || t == '%')
 {
   double a,b;
   lex(ev);
   pow_expr(ev);
   b = pop(ev);
   a = pop(ev);
   if(t == '*')
    push(ev, a * b);
   else if(t == '/')
    push(ev, a / b);
   else
    push(ev, fmod(a, b));
 }
}

canonical_original_code:
static void mul_expr(struct eval *ev)
{
 int t;
 pow_expr(ev);
 while((t = (ev->token[ev->cur_tok].type)) == '*' || t == '/' || t == '%')
 {
   double a; double b;
   lex(ev);
   pow_expr(ev);
   b = pop(ev);
   a = pop(ev);
   if(t == '*')
    push(ev, a * b);
   else if(t == '/')
    push(ev, a / b);
   else
    push(ev, fmod(a, b));
 }
}

variable_types: t int

variable_types: a double

variable_types: b double


decompiled_code:
__int64 __fastcall add_expr(struct __jmp_buf_tag env[1])
{
int v1; // ebp
__int64 result; // rax
double v3; // r14
double v4; // xmm0_8

mul_expr(env);
v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
for ( result = (unsigned int)(v1 - 43); (result & 0xFFFFFFFD) == 0; result = (unsigned int)(v1 - 43) )
{
lex((__int64)env);
mul_expr(env);
v3 = pop((__int64)env);
v4 = pop((__int64)env);
if ( v1 == 43 )
push(env, v4 + v3);
else
push(env, v4 - v3);
v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(struct __jmp_buf_tag env[1])
{
int v1; // ebp
__int64 result; // rax
double v3; // r14
double v4; // xmm0_8

func5(env);
v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
for ( result = (unsigned int)(v1 - 43); (result & 0xFFFFFFFD) == 0; result = (unsigned int)(v1 - 43) )
{
func1((__int64)env);
func5(env);
v3 = func0((__int64)env);
v4 = func0((__int64)env);
if ( v1 == 43 )
func3(env, v4 + v3);
else
func3(env, v4 - v3);
v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
}
return result;
}

original_code:
static void add_expr(struct eval *ev)
{
 int t;
 mul_expr(ev);
 while((t =(ev->token[ev->cur_tok].type)) == '+' || t == '-')
 {
   double a,b;
   lex(ev);
   mul_expr(ev);
   b = pop(ev);
   a = pop(ev);
   if(t == '+')
    push(ev, a + b);
   else
    push(ev, a - b);
 }
}

canonical_original_code:
static void add_expr(struct eval *ev)
{
 int t;
 mul_expr(ev);
 while((t =(ev->token[ev->cur_tok].type)) == '+' || t == '-')
 {
   double a; double b;
   lex(ev);
   mul_expr(ev);
   b = pop(ev);
   a = pop(ev);
   if(t == '+')
    push(ev, a + b);
   else
    push(ev, a - b);
 }
}


decompiled_code:
__int64 __fastcall id_expr(struct __jmp_buf_tag env[1])
{
__int64 v1; // rax
__int64 result; // rax
int v3; // ebp
int v4; // eax
double v5; // xmm0_8
double v6; // xmm0_8
__m128d v7; // xmm3
__m128d v8; // xmm1
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm0_8
double v17; // xmm0_8
double v18; // xmm0_8
double v19; // xmm0_8
double v20; // xmm0_8
double v21; // rbp
double v22; // xmm0_8
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // xmm0_8
double v26; // xmm0_8
double v27; // xmm0_8
double v28; // xmm0_8
double v29; // xmm0_8
double v30; // xmm0_8
double v31; // xmm0_8
double v32; // xmm0_8
double v33; // xmm0_8
double v34; // xmm0_8
double v35; // xmm0_8
double v36; // xmm0_8
double v37; // xmm0_8
double v38; // xmm0_8
double v39; // xmm0_8
double v40; // rbp
double v41; // xmm0_8
double v42; // xmm0_8
double v43; // xmm0_8
double v44; // xmm0_8
__m128d v45; // xmm0
__m128d v46; // xmm3
double v47; // [rsp+8h] [rbp-30h]
char dest[35]; // [rsp+15h] [rbp-23h] BYREF

v1 = 4LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( LODWORD(env[1].__jmpbuf[v1 + 3]) != 2 )
return num_expr(env);
strcpy(dest, (const char *)&env[1].__jmpbuf[v1 + 5]);
lex((__int64)env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
{
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"pi") )
return push(env, 3.141592654);
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"e") )
longjmp(env, 8);
return push(env, 2.718281828);
}
lex((__int64)env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) == 41 )
{
lex((__int64)env);
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"abs") )
goto LABEL_15;
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"ceil") )
goto LABEL_21;
v3 = 0;
}
else
{
v3 = 0;
do
{
add_expr(env);
++v3;
v4 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( v4 == 41 )
break;
if ( v4 != 44 )
longjmp(env, 5);
lex((__int64)env);
}
while ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 );
lex((__int64)env);
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"abs") )
{
if ( v3 == 1 )
{
v5 = pop((__int64)env);
return push(env, COERCE_DOUBLE(*(_QWORD *)&v5 & LC2));
}
LABEL_15:
longjmp(env, 7);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"ceil") )
{
if ( v3 == 1 )
{
v6 = pop((__int64)env);
v7.m128d_f64[0] = v6;
if ( COERCE_DOUBLE(*(_QWORD *)&v6 & LC2) < 4.503599627370496e15 )
{
v8.m128d_f64[0] = (double)(int)v6;
*(_QWORD *)&v7.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v7, v8) & LC5) + v8.m128d_f64[0]) | ~(_QWORD)LC2 & *(_QWORD *)&v6;
}
return push(env, v7.m128d_f64[0]);
}
LABEL_21:
longjmp(env, 7);
}
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"floor") )
{
if ( v3 != 1 )
longjmp(env, 7);
v45.m128d_f64[0] = pop((__int64)env);
v7.m128d_f64[0] = v45.m128d_f64[0];
if ( COERCE_DOUBLE(*(_QWORD *)&v45.m128d_f64[0] & LC2) < 4.503599627370496e15 )
{
v46.m128d_f64[0] = (double)(int)v45.m128d_f64[0];
*(_QWORD *)&v7.m128d_f64[0] = COERCE_UNSIGNED_INT64(v46.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v46, v45) & LC5)) | ~(_QWORD)LC2 & *(_QWORD *)&v45.m128d_f64[0];
}
return push(env, v7.m128d_f64[0]);
}
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"sin") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"asin") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"cos") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"acos") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"tan") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"atan") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"atan2") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"sinh") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"cosh") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"tanh") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"log") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"log10") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"exp") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"sqrt") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"rad") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"deg") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"pow") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"hypot") )
longjmp(env, 6);
if ( v3 != 2 )
longjmp(env, 7);
v47 = pop((__int64)env);
v43 = pop((__int64)env);
v44 = sqrt(v43 * v43 + v47 * v47);
result = push(env, v44);
}
else
{
if ( v3 != 2 )
longjmp(env, 7);
v40 = pop((__int64)env);
v41 = pop((__int64)env);
v42 = pow(v41, v40);
result = push(env, v42);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v39 = pop((__int64)env);
result = push(env, v39 * 180.0 / 3.141592654);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v38 = pop((__int64)env);
result = push(env, v38 * 3.141592654 / 180.0);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v36 = pop((__int64)env);
v37 = sqrt(v36);
result = push(env, v37);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v34 = pop((__int64)env);
v35 = exp(v34);
result = push(env, v35);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v32 = pop((__int64)env);
v33 = log10(v32);
result = push(env, v33);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v30 = pop((__int64)env);
v31 = log(v30);
result = push(env, v31);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v28 = pop((__int64)env);
v29 = tanh(v28);
result = push(env, v29);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v26 = pop((__int64)env);
v27 = cosh(v26);
result = push(env, v27);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v24 = pop((__int64)env);
v25 = sinh(v24);
result = push(env, v25);
}
}
else
{
if ( v3 != 2 )
longjmp(env, 7);
v21 = pop((__int64)env);
v22 = pop((__int64)env);
v23 = atan2(v22, v21);
result = push(env, v23);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v19 = pop((__int64)env);
v20 = atan(v19);
result = push(env, v20);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v17 = pop((__int64)env);
v18 = tan(v17);
result = push(env, v18);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v15 = pop((__int64)env);
v16 = acos(v15);
result = push(env, v16);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v13 = pop((__int64)env);
v14 = cos(v13);
result = push(env, v14);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v11 = pop((__int64)env);
v12 = asin(v11);
result = push(env, v12);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v9 = pop((__int64)env);
v10 = sin(v9);
result = push(env, v10);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(struct __jmp_buf_tag env[1])
{
__int64 v1; // rax
__int64 result; // rax
int v3; // ebp
int v4; // eax
double v5; // xmm0_8
double v6; // xmm0_8
__m128d v7; // xmm3
__m128d v8; // xmm1
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm0_8
double v17; // xmm0_8
double v18; // xmm0_8
double v19; // xmm0_8
double v20; // xmm0_8
double v21; // rbp
double v22; // xmm0_8
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // xmm0_8
double v26; // xmm0_8
double v27; // xmm0_8
double v28; // xmm0_8
double v29; // xmm0_8
double v30; // xmm0_8
double v31; // xmm0_8
double v32; // xmm0_8
double v33; // xmm0_8
double v34; // xmm0_8
double v35; // xmm0_8
double v36; // xmm0_8
double v37; // xmm0_8
double v38; // xmm0_8
double v39; // xmm0_8
double v40; // rbp
double v41; // xmm0_8
double v42; // xmm0_8
double v43; // xmm0_8
double v44; // xmm0_8
__m128d v45; // xmm0
__m128d v46; // xmm3
double v47; // [rsp+8h] [rbp-30h]
char dest[35]; // [rsp+15h] [rbp-23h] BYREF

v1 = 4LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( LODWORD(env[1].__jmpbuf[v1 + 3]) != 2 )
return func4(env);
strcpy(dest, (const char *)&env[1].__jmpbuf[v1 + 5]);
func1((__int64)env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
{
if ( !(unsigned int)func2((__int64)dest, (__int64)"pi") )
return func3(env, 3.141592654);
if ( (unsigned int)func2((__int64)dest, (__int64)"e") )
longjmp(env, 8);
return func3(env, 2.718281828);
}
func1((__int64)env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) == 41 )
{
func1((__int64)env);
if ( !(unsigned int)func2((__int64)dest, (__int64)"abs") )
goto LABEL_15;
if ( !(unsigned int)func2((__int64)dest, (__int64)"ceil") )
goto LABEL_21;
v3 = 0;
}
else
{
v3 = 0;
do
{
func6(env);
++v3;
v4 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( v4 == 41 )
break;
if ( v4 != 44 )
longjmp(env, 5);
func1((__int64)env);
}
while ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 );
func1((__int64)env);
if ( !(unsigned int)func2((__int64)dest, (__int64)"abs") )
{
if ( v3 == 1 )
{
v5 = func0((__int64)env);
return func3(env, COERCE_DOUBLE(*(_QWORD *)&v5 & LC2));
}
LABEL_15:
longjmp(env, 7);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"ceil") )
{
if ( v3 == 1 )
{
v6 = func0((__int64)env);
v7.m128d_f64[0] = v6;
if ( COERCE_DOUBLE(*(_QWORD *)&v6 & LC2) < 4.503599627370496e15 )
{
v8.m128d_f64[0] = (double)(int)v6;
*(_QWORD *)&v7.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v7, v8) & LC5) + v8.m128d_f64[0]) | ~(_QWORD)LC2 & *(_QWORD *)&v6;
}
return func3(env, v7.m128d_f64[0]);
}
LABEL_21:
longjmp(env, 7);
}
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"floor") )
{
if ( v3 != 1 )
longjmp(env, 7);
v45.m128d_f64[0] = func0((__int64)env);
v7.m128d_f64[0] = v45.m128d_f64[0];
if ( COERCE_DOUBLE(*(_QWORD *)&v45.m128d_f64[0] & LC2) < 4.503599627370496e15 )
{
v46.m128d_f64[0] = (double)(int)v45.m128d_f64[0];
*(_QWORD *)&v7.m128d_f64[0] = COERCE_UNSIGNED_INT64(v46.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v46, v45) & LC5)) | ~(_QWORD)LC2 & *(_QWORD *)&v45.m128d_f64[0];
}
return func3(env, v7.m128d_f64[0]);
}
if ( (unsigned int)func2((__int64)dest, (__int64)"sin") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"asin") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"cos") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"acos") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"tan") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"atan") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"atan2") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"sinh") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"cosh") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"tanh") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"log") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"log10") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"exp") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"sqrt") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"rad") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"deg") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"pow") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"hypot") )
longjmp(env, 6);
if ( v3 != 2 )
longjmp(env, 7);
v47 = func0((__int64)env);
v43 = func0((__int64)env);
v44 = sqrt(v43 * v43 + v47 * v47);
result = func3(env, v44);
}
else
{
if ( v3 != 2 )
longjmp(env, 7);
v40 = func0((__int64)env);
v41 = func0((__int64)env);
v42 = pow(v41, v40);
result = func3(env, v42);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v39 = func0((__int64)env);
result = func3(env, v39 * 180.0 / 3.141592654);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v38 = func0((__int64)env);
result = func3(env, v38 * 3.141592654 / 180.0);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v36 = func0((__int64)env);
v37 = sqrt(v36);
result = func3(env, v37);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v34 = func0((__int64)env);
v35 = exp(v34);
result = func3(env, v35);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v32 = func0((__int64)env);
v33 = log10(v32);
result = func3(env, v33);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v30 = func0((__int64)env);
v31 = log(v30);
result = func3(env, v31);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v28 = func0((__int64)env);
v29 = tanh(v28);
result = func3(env, v29);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v26 = func0((__int64)env);
v27 = cosh(v26);
result = func3(env, v27);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v24 = func0((__int64)env);
v25 = sinh(v24);
result = func3(env, v25);
}
}
else
{
if ( v3 != 2 )
longjmp(env, 7);
v21 = func0((__int64)env);
v22 = func0((__int64)env);
v23 = atan2(v22, v21);
result = func3(env, v23);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v19 = func0((__int64)env);
v20 = atan(v19);
result = func3(env, v20);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v17 = func0((__int64)env);
v18 = tan(v17);
result = func3(env, v18);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v15 = func0((__int64)env);
v16 = acos(v15);
result = func3(env, v16);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v13 = func0((__int64)env);
v14 = cos(v13);
result = func3(env, v14);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v11 = func0((__int64)env);
v12 = asin(v11);
result = func3(env, v12);
}
}
else
{
if ( v3 != 1 )
longjmp(env, 7);
v9 = func0((__int64)env);
v10 = sin(v9);
result = func3(env, v10);
}
return result;
}

original_code:
static void id_expr(struct eval *ev)
{
 if((ev->token[ev->cur_tok].type) == 2)
 {
  char id[11];
  strcpy(id, ev->token[ev->cur_tok].s_val);
  lex(ev);
  if((ev->token[ev->cur_tok].type) == '(')
  {
   int nargs = 0;
   lex(ev);
   while((ev->token[ev->cur_tok].type) != ')')
   {
    add_expr(ev);
    nargs++;
    if((ev->token[ev->cur_tok].type) == ')') break;
    if((ev->token[ev->cur_tok].type) != ',')
     longjmp(ev->j, (5));
    lex(ev);
   }
   lex(ev);
   if(!istrcmp(id, "abs"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, fabs(pop(ev)));
   }
   else if(!istrcmp(id, "ceil"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, ceil(pop(ev)));
   }
   else if(!istrcmp(id, "floor"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, floor(pop(ev)));
   }
   else if(!istrcmp(id, "sin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sin(pop(ev)));
   }
   else if(!istrcmp(id, "asin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, asin(pop(ev)));
   }
   else if(!istrcmp(id, "cos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cos(pop(ev)));
   }
   else if(!istrcmp(id, "acos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, acos(pop(ev)));
   }
   else if(!istrcmp(id, "tan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tan(pop(ev)));
   }
   else if(!istrcmp(id, "atan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, atan(pop(ev)));
   }
   else if(!istrcmp(id, "atan2"))
   {
    double a, b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, atan2(a,b));
   }
   else if(!istrcmp(id, "sinh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sinh(pop(ev)));
   }
   else if(!istrcmp(id, "cosh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cosh(pop(ev)));
   }
   else if(!istrcmp(id, "tanh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tanh(pop(ev)));
   }
   else if(!istrcmp(id, "log"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log(pop(ev)));
   }
   else if(!istrcmp(id, "log10"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log10(pop(ev)));
   }
   else if(!istrcmp(id, "exp"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, exp(pop(ev)));
   }
   else if(!istrcmp(id, "sqrt"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sqrt(pop(ev)));
   }
   else if(!istrcmp(id, "rad"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*3.141592654/180);
   }
   else if(!istrcmp(id, "deg"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*180/3.141592654);
   }
   else if(!istrcmp(id, "pow"))
   {
    double a, b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, pow(a,b));
   }
   else if(!istrcmp(id, "hypot"))
   {
    double a, b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, sqrt(a*a + b*b));
   }
   else
    longjmp(ev->j, (6));
  }
  else
  {
   if(!istrcmp(id, "pi"))
    push(ev, 3.141592654);
   else if(!istrcmp(id, "e"))
    push(ev, 2.718281828);
   else
    longjmp(ev->j, (8));
  }
 }
 else
  num_expr(ev);
}

canonical_original_code:
static void id_expr(struct eval *ev)
{
 if((ev->token[ev->cur_tok].type) == 2)
 {
  char id[11];
  strcpy(id, ev->token[ev->cur_tok].s_val);
  lex(ev);
  if((ev->token[ev->cur_tok].type) == '(')
  {
   int nargs = 0;
   lex(ev);
   while((ev->token[ev->cur_tok].type) != ')')
   {
    add_expr(ev);
    nargs++;
    if((ev->token[ev->cur_tok].type) == ')') break;
    if((ev->token[ev->cur_tok].type) != ',')
     longjmp(ev->j, (5));
    lex(ev);
   }
   lex(ev);
   if(!istrcmp(id, "abs"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, fabs(pop(ev)));
   }
   else if(!istrcmp(id, "ceil"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, ceil(pop(ev)));
   }
   else if(!istrcmp(id, "floor"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, floor(pop(ev)));
   }
   else if(!istrcmp(id, "sin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sin(pop(ev)));
   }
   else if(!istrcmp(id, "asin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, asin(pop(ev)));
   }
   else if(!istrcmp(id, "cos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cos(pop(ev)));
   }
   else if(!istrcmp(id, "acos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, acos(pop(ev)));
   }
   else if(!istrcmp(id, "tan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tan(pop(ev)));
   }
   else if(!istrcmp(id, "atan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, atan(pop(ev)));
   }
   else if(!istrcmp(id, "atan2"))
   {
    double a; double b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, atan2(a,b));
   }
   else if(!istrcmp(id, "sinh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sinh(pop(ev)));
   }
   else if(!istrcmp(id, "cosh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cosh(pop(ev)));
   }
   else if(!istrcmp(id, "tanh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tanh(pop(ev)));
   }
   else if(!istrcmp(id, "log"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log(pop(ev)));
   }
   else if(!istrcmp(id, "log10"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log10(pop(ev)));
   }
   else if(!istrcmp(id, "exp"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, exp(pop(ev)));
   }
   else if(!istrcmp(id, "sqrt"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sqrt(pop(ev)));
   }
   else if(!istrcmp(id, "rad"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*3.141592654/180);
   }
   else if(!istrcmp(id, "deg"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*180/3.141592654);
   }
   else if(!istrcmp(id, "pow"))
   {
    double a; double b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, pow(a,b));
   }
   else if(!istrcmp(id, "hypot"))
   {
    double a; double b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, sqrt(a*a + b*b));
   }
   else
    longjmp(ev->j, (6));
  }
  else
  {
   if(!istrcmp(id, "pi"))
    push(ev, 3.141592654);
   else if(!istrcmp(id, "e"))
    push(ev, 2.718281828);
   else
    longjmp(ev->j, (8));
  }
 }
 else
  num_expr(ev);
}

variable_types:
id
char [11]

variable_types: nargs int


decompiled_code:
__int64 __fastcall bra_expr(struct __jmp_buf_tag env[1])
{
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
return id_expr(env);
lex((__int64)env);
add_expr(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 )
longjmp(env, 5);
return lex((__int64)env);
}

canonical_decompiled_code:
__int64 __fastcall func8(struct __jmp_buf_tag env[1])
{
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
return func7(env);
func1((__int64)env);
func6(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 )
longjmp(env, 5);
return func1((__int64)env);
}

original_code:
static void bra_expr(struct eval *ev)
{
 if((ev->token[ev->cur_tok].type) == '(')
 {
  lex(ev);
  add_expr(ev);
  if((ev->token[ev->cur_tok].type) != ')')
   longjmp(ev->j, (5));
  lex(ev);
 }
 else
   id_expr(ev);
}


decompiled_code:
__int64 __fastcall uni_expr(struct __jmp_buf_tag env[1])
{
int v1; // ebp
__int64 result; // rax
double v3; // xmm0_8

v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( ((v1 - 43) & 0xFFFFFFFD) != 0 )
return bra_expr(env);
lex((__int64)env);
result = bra_expr(env);
if ( v1 == 45 )
{
v3 = pop((__int64)env);
result = push(env, COERCE_DOUBLE(*(_QWORD *)&v3 ^ LC30));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(struct __jmp_buf_tag env[1])
{
int v1; // ebp
__int64 result; // rax
double v3; // xmm0_8

v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( ((v1 - 43) & 0xFFFFFFFD) != 0 )
return func8(env);
func1((__int64)env);
result = func8(env);
if ( v1 == 45 )
{
v3 = func0((__int64)env);
result = func3(env, COERCE_DOUBLE(*(_QWORD *)&v3 ^ LC30));
}
return result;
}

original_code:
static void uni_expr(struct eval *ev)
{
 int t = '+';
 if((ev->token[ev->cur_tok].type) == '-' || (ev->token[ev->cur_tok].type) == '+')
 {
  t = (ev->token[ev->cur_tok].type);
  lex(ev);
 }
 bra_expr(ev);
 if(t == '-')
 {
  double a = pop(ev);
  push(ev, -a);
 }
}


decompiled_code:
__int64 __fastcall pow_expr(struct __jmp_buf_tag env[1])
{
__int64 result; // rax
double v2; // rbp
double v3; // xmm0_8
double v4; // xmm0_8

uni_expr(env);
result = 32LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( *(_DWORD *)((char *)&env[1].__jmpbuf[3] + result) == 94 )
{
lex((__int64)env);
pow_expr(env);
v2 = pop((__int64)env);
v3 = pop((__int64)env);
v4 = pow(v3, v2);
result = push(env, v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(struct __jmp_buf_tag env[1])
{
__int64 result; // rax
double v2; // rbp
double v3; // xmm0_8
double v4; // xmm0_8

func9(env);
result = 32LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( *(_DWORD *)((char *)&env[1].__jmpbuf[3] + result) == 94 )
{
func1((__int64)env);
func10(env);
v2 = func0((__int64)env);
v3 = func0((__int64)env);
v4 = pow(v3, v2);
result = func3(env, v4);
}
return result;
}

original_code:
static void pow_expr(struct eval *ev)
{
 uni_expr(ev);
 if((ev->token[ev->cur_tok].type) == '^')
 {
  double a,b;
  lex(ev);
  pow_expr(ev);
  b = pop(ev);
  a = pop(ev);
  push(ev, pow(a,b));
 }
}

canonical_original_code:
static void pow_expr(struct eval *ev)
{
 uni_expr(ev);
 if((ev->token[ev->cur_tok].type) == '^')
 {
  double a; double b;
  lex(ev);
  pow_expr(ev);
  b = pop(ev);
  a = pop(ev);
  push(ev, pow(a,b));
 }
}


eval

decompiled_code:
double __fastcall eval(__int64 a1, int *a2)
{
int v2; // eax
double v3; // rbx
jmp_buf env; // [rsp+10h] [rbp-138h] BYREF
__int64 v6; // [rsp+D8h] [rbp-70h]
void *ptr; // [rsp+E0h] [rbp-68h]
int v8; // [rsp+E8h] [rbp-60h]
int v9; // [rsp+ECh] [rbp-5Ch]
int v10; // [rsp+F0h] [rbp-58h]
char v11; // [rsp+100h] [rbp-48h]
int v12; // [rsp+110h] [rbp-38h]
char v13; // [rsp+120h] [rbp-28h]
int v14; // [rsp+130h] [rbp-18h]

v8 = 10;
ptr = calloc(0xAuLL, 8uLL);
if ( ptr )
{
v9 = 0;
v2 = setjmp(env);
*a2 = v2;
if ( v2 )
{
free(ptr);
v3 = *(double *)&LC31;
}
else
{
v10 = 1;
v11 = 0;
v12 = 1;
v13 = 0;
v14 = 0;
v6 = a1;
v3 = *(double *)&LC31;
if ( (unsigned int)lex((__int64)env) )
{
expr(env);
v3 = pop((__int64)env);
}
free(ptr);
}
}
else
{
*a2 = 1;
v3 = *(double *)&LC31;
}
return v3;
}

canonical_decompiled_code:
double __fastcall func12(__int64 a1, int *a2)
{
int v2; // eax
double v3; // rbx
jmp_buf env; // [rsp+10h] [rbp-138h] BYREF
__int64 v6; // [rsp+D8h] [rbp-70h]
void *ptr; // [rsp+E0h] [rbp-68h]
int v8; // [rsp+E8h] [rbp-60h]
int v9; // [rsp+ECh] [rbp-5Ch]
int v10; // [rsp+F0h] [rbp-58h]
char v11; // [rsp+100h] [rbp-48h]
int v12; // [rsp+110h] [rbp-38h]
char v13; // [rsp+120h] [rbp-28h]
int v14; // [rsp+130h] [rbp-18h]

v8 = 10;
ptr = calloc(0xAuLL, 8uLL);
if ( ptr )
{
v9 = 0;
v2 = setjmp(env);
*a2 = v2;
if ( v2 )
{
free(ptr);
v3 = *(double *)&LC31;
}
else
{
v10 = 1;
v11 = 0;
v12 = 1;
v13 = 0;
v14 = 0;
v6 = a1;
v3 = *(double *)&LC31;
if ( (unsigned int)func1((__int64)env) )
{
func11(env);
v3 = func0((__int64)env);
}
free(ptr);
}
}
else
{
*a2 = 1;
v3 = *(double *)&LC31;
}
return v3;
}

original_code:
double eval(const char *exp, int *ep)
{
 struct eval ev;
 double ans = 0.0;
 ((void) (0));
 ev.st_size = 10;
 ev.st = calloc(ev.st_size, sizeof *ev.st);
 if(!ev.st)
 {
  *ep = 1;
  return 0.0;
 }
 ev.sp = 0;
 *ep = _setjmp (ev.j);
 if(*ep != 0)
 {
  free(ev.st);
  return 0.0;
 }
 ev.token[0].type = 1;
 ev.token[0].s_val[0] = '\0';
 ev.token[1].type = 1;
 ev.token[1].s_val[0] = '\0';
 ev.cur_tok = 0;
 ev.p = exp;
 if(lex(&ev) != 0)
 {
  expr(&ev);
  ans = pop(&ev);
 }
 free(ev.st);
 return ans;
}

canonical_original_code:
double eval(char *exp, int *ep)
{
 struct eval ev;
 double ans = 0.0;
 ((void) (0));
 ev.st_size = 10;
 ev.st = calloc(ev.st_size, sizeof *ev.st);
 if(!ev.st)
 {
  *ep = 1;
  return 0.0;
 }
 ev.sp = 0;
 *ep = _setjmp (ev.j);
 if(*ep != 0)
 {
  free(ev.st);
  return 0.0;
 }
 ev.token[0].type = 1;
 ev.token[0].s_val[0] = '\0';
 ev.token[1].type = 1;
 ev.token[1].s_val[0] = '\0';
 ev.cur_tok = 0;
 ev.p = exp;
 if(lex(&ev) != 0)
 {
  expr(&ev);
  ans = pop(&ev);
 }
 free(ev.st);
 return ans;
}

variable_types:
exp
char *

variable_types:
ep
int *

variable_types: struct eval { struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } j[1]; char *p; double *st; int st_size; int sp; struct { int type; double n_val; char s_val[11]; } token[2]; int cur_tok; }

variable_types: ans double


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

switch ( a1 )
{
case 0:
result = "no error";
break;
case 1:
result = "out of memory";
break;
case 2:
result = "unknown token";
break;
case 3:
result = "identifier too long";
break;
case 4:
result = "value expected";
break;
case 5:
result = "missing ')'";
break;
case 6:
result = "unknown function";
break;
case 7:
result = "wrong number of arguments";
break;
case 8:
result = "unknown constant";
break;
default:
result = "unknown error";
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = "no error";
break;
case 1:
result = "out of memory";
break;
case 2:
result = "unknown token";
break;
case 3:
result = "identifier too long";
break;
case 4:
result = "value expected";
break;
case 5:
result = "missing ')'";
break;
case 6:
result = "unknown function";
break;
case 7:
result = "wrong number of arguments";
break;
case 8:
result = "unknown constant";
break;
default:
result = "unknown error";
break;
}
return result;
}

original_code:
const char *eval_error(int err)
{
 switch(err)
 {
 case 0: return "no error";
 case 1: return "out of memory";
 case 2: return "unknown token";
 case 3: return "identifier too long";
 case 4: return "value expected";
 case 5: return "missing ')'";
 case 6: return "unknown function";
 case 7: return "wrong number of arguments";
 case 8: return "unknown constant";
 }
 return "unknown error";
}

variable_types: err int


expr

decompiled_code:
__int64 __fastcall expr(struct __jmp_buf_tag *a1)
{
return add_expr(a1);
}

canonical_decompiled_code:
__int64 __fastcall func11(struct __jmp_buf_tag *a1)
{
return func6(a1);
}

original_code:
static void expr(struct eval *ev)
{
 add_expr(ev);
}

variable_types: struct eval { struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } j[1]; char *p; double *st; int st_size; int sp; struct { int type; double n_val; char s_val[11]; } token[2]; int cur_tok; } *


original_code:
int
ht_rehash (struct hash_tbl *ht, int new_size)
{
  struct hash_el **buckets, *j, *e, *k;
  int i, h;
  if (new_size >= 100000)
    {
      if (ht->size < 100000)
        new_size = 100000;
      else
        return 0;
    }
  buckets = calloc (new_size, sizeof *buckets);
  if (!buckets)
    return 0;
  for (i = 0; i < ht->size; i++)
    for (j = ht->buckets[i]; j;)
      {
        h = hash (j->key, new_size);
        e = j;
        j = j->next;
        e->next = ((void *)0);
        if (buckets[h])
          {
            for (k = buckets[h]; k->next; k = k->next);
            k->next = e;
          }
        else
          buckets[h] = e;
      }
  free (ht->buckets);
  ht->buckets = buckets;
  ht->size = new_size;
  return 1;
}

canonical_original_code:
int ht_rehash(struct hash_tbl *ht, int new_size)
{
  struct hash_el **buckets; struct hash_el *j; struct hash_el *e; struct hash_el *k;
  int i; int h;
  if (new_size >= 100000)
    {
      if (ht->size < 100000)
        new_size = 100000;
      else
        return 0;
    }
  buckets = calloc (new_size, sizeof *buckets);
  if (!buckets)
    return 0;
  for (i = 0; i < ht->size; i++)
    for (j = ht->buckets[i]; j;)
      {
        h = hash (j->key, new_size);
        e = j;
        j = j->next;
        e->next = ((void *)0);
        if (buckets[h])
          {
            for (k = buckets[h]; k->next; k = k->next);
            k->next = e;
          }
        else
          buckets[h] = e;
      }
  free (ht->buckets);
  ht->buckets = buckets;
  ht->size = new_size;
  return 1;
}

variable_types: struct hash_tbl { struct hash_el { char *key; void *value; struct hash_el *next; } **buckets; int size; int cnt; } *

variable_types: h int

user_defined_types: struct hash_tbl { struct hash_el **buckets; int size; int cnt; }


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

result = search(a1, a2, v3);
if ( result )
result = *(_QWORD *)(result + 8);
return result;
}

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

result = func1(a1, a2, v3);
if ( result )
result = *(_QWORD *)(result + 8);
return result;
}

original_code:
void *
ht_find (struct hash_tbl *h, const char *key)
{
  int f;
  struct hash_el *i = search (h, key, &f);
  if (i)
    return i->value;
  return ((void *)0);
}

canonical_original_code:
void *ht_find(struct hash_tbl *h, char *key)
{
  int f;
  struct hash_el *i = search (h, key, &f);
  if (i)
    return i->value;
  return ((void *)0);
}

variable_types:
key
char *

variable_types: f int

variable_types: struct hash_el { char *key; void *value; struct hash_el *next; } *


original_code:
void *
ht_delete (struct hash_tbl *h, const char *key)
{
  struct hash_el *i, *p = ((void *)0);
  void *d = ((void *)0);
  int f;
  f = hash (key, h->size);
  if (h->buckets[f])
    {
      for (i = h->buckets[f]; i; i = i->next)
        {
          if (!strcmp (i->key, key))
            {
              if (p)
                p->next = i->next;
              else
                h->buckets[f] = i->next;
              d = i->value;
              free (i->key);
              free (i);
              h->cnt--;
              break;
            }
          p = i;
        }
    }
  return d;
}

canonical_original_code:
void *ht_delete(struct hash_tbl *h, char *key)
{
  struct hash_el *i; struct hash_el *p = ((void *)0);
  void *d = ((void *)0);
  int f;
  f = hash (key, h->size);
  if (h->buckets[f])
    {
      for (i = h->buckets[f]; i; i = i->next)
        {
          if (!strcmp (i->key, key))
            {
              if (p)
                p->next = i->next;
              else
                h->buckets[f] = i->next;
              d = i->value;
              free (i->key);
              free (i);
              h->cnt--;
              break;
            }
          p = i;
        }
    }
  return d;
}

variable_types:
d
void *

user_defined_types: struct hash_el { char *key; void *value; struct hash_el *next; }


decompiled_code:
void __fastcall ht_free(void *ptr, void (__fastcall *a2)(void *, void *))
{
__int64 v2; // r14
void **i; // rbx

if ( *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
for ( i = *(void ***)(*(_QWORD *)ptr + 8 * v2); i; i = *(void ***)(*(_QWORD *)ptr + 8 * v2) )
{
*(_QWORD *)(*(_QWORD *)ptr + 8 * v2) = i[2];
if ( a2 )
a2(*i, i[1]);
free(*i);
free(i);
}
++v2;
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr, void (__fastcall *a2)(void *, void *))
{
__int64 v2; // r14
void **i; // rbx

if ( *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
for ( i = *(void ***)(*(_QWORD *)ptr + 8 * v2); i; i = *(void ***)(*(_QWORD *)ptr + 8 * v2) )
{
*(_QWORD *)(*(_QWORD *)ptr + 8 * v2) = i[2];
if ( a2 )
a2(*i, i[1]);
free(*i);
free(i);
}
++v2;
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
free(*(void **)ptr);
free(ptr);
}

original_code:
void
ht_free (struct hash_tbl *h, clear_all_dtor dtor)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            h->buckets[i] = e->next;
            if (dtor)
              dtor (e->key, e->value);
            free (e->key);
            free (e);
            e = h->buckets[i];
          }
      }
  free (h->buckets);
  free (h);
}

canonical_original_code:
void ht_free(struct hash_tbl *h, void (*dtor)(char *key, void *val))
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            h->buckets[i] = e->next;
            if (dtor)
              dtor (e->key, e->value);
            free (e->key);
            free (e);
            e = h->buckets[i];
          }
      }
  free (h->buckets);
  free (h);
}

variable_types:
dtor
void (*)(char *key, void *val)

variable_types: i int


decompiled_code:
void __fastcall ht_foreach(__int64 a1, unsigned int (__fastcall *a2)(_QWORD, _QWORD, __int64), __int64 a3)
{
__int64 v4; // r13
_QWORD *v5; // rbx

if ( *(int *)(a1 + 8) > 0 )
{
v4 = 0LL;
while ( 1 )
{
v5 = *(_QWORD **)(*(_QWORD *)a1 + 8 * v4);
if ( v5 )
break;
LABEL_3:
if ( *(_DWORD *)(a1 + 8) <= (int)++v4 )
return;
}
while ( a2(*v5, v5[1], a3) )
{
v5 = (_QWORD *)v5[2];
if ( !v5 )
goto LABEL_3;
}
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, unsigned int (__fastcall *a2)(_QWORD, _QWORD, __int64), __int64 a3)
{
__int64 v4; // r13
_QWORD *v5; // rbx

if ( *(int *)(a1 + 8) > 0 )
{
v4 = 0LL;
while ( 1 )
{
v5 = *(_QWORD **)(*(_QWORD *)a1 + 8 * v4);
if ( v5 )
break;
LABEL_3:
if ( *(_DWORD *)(a1 + 8) <= (int)++v4 )
return;
}
while ( a2(*v5, v5[1], a3) )
{
v5 = (_QWORD *)v5[2];
if ( !v5 )
goto LABEL_3;
}
}
}

original_code:
void
ht_foreach (struct hash_tbl *h,
            int (*f) (const char *key, void *value, void *data), void *data)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            if (!f (e->key, e->value, data))
              return;
            e = e->next;
          }
      }
}

canonical_original_code:
void ht_foreach(struct hash_tbl *h, int (*f)(char *key, void *value, void *data), void *data)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            if (!f (e->key, e->value, data))
              return;
            e = e->next;
          }
      }
}

variable_types: int (*)(char *key, void *value, void *data)

variable_types:
data
void *


hash

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

v2 = *a1;
if ( *a1 )
{
v3 = 0;
do
{
v3 = v2 + 65599 * v3;
v2 = *++a1;
}
while ( *a1 );
}
else
{
v3 = 0;
}
return v3 & (unsigned int)(a2 - 1);
}

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

v2 = *a1;
if ( *a1 )
{
v3 = 0;
do
{
v3 = v2 + 65599 * v3;
v2 = *++a1;
}
while ( *a1 );
}
else
{
v3 = 0;
}
return v3 & (unsigned int)(a2 - 1);
}

original_code:
static int
hash (const char *str, int size)
{
  int x = 0;
  ((void) (0));
  while (str[0])
    {
      x = (x * 65599) + str[0];
      str++;
    }
  return x & (size - 1);
}

canonical_original_code:
static int hash(char *str, int size)
{
  int x = 0;
  ((void) (0));
  while (str[0])
    {
      x = (x * 65599) + str[0];
      str++;
    }
  return x & (size - 1);
}

variable_types:
str
char *

variable_types: size int

variable_types: x int


original_code:
const char *
ht_next (struct hash_tbl *h, const char *key)
{
  int f;
  struct hash_el *i;
  if (key == ((void *)0))
    {
      for (f = 0; f < h->size && !h->buckets[f]; f++);
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
  i = search (h, key, &f);
  if (!i)
    return ((void *)0);
  if (i->next)
    return i->next->key;
  else
    {
      f++;
      while (f < h->size && !h->buckets[f])
        f++;
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
}

canonical_original_code:
char *ht_next(struct hash_tbl *h, char *key)
{
  int f;
  struct hash_el *i;
  if (key == ((void *)0))
    {
      for (f = 0; f < h->size && !h->buckets[f]; f++);
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
  i = search (h, key, &f);
  if (!i)
    return ((void *)0);
  if (i->next)
    return i->next->key;
  else
    {
      f++;
      while (f < h->size && !h->buckets[f])
        f++;
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
}


original_code:
static void gc_sweep() {
 GcObj *gc = gc_objs;
 int collected = 0;
 while(gc) {
  if(gc->mark == 0) {
   GcObj *col = gc;
   gc = gc->next;
   if(col->next) col->next->prev = col->prev;
   if(col->prev) col->prev->next = col->next;
   if(gc_objs == col)
    gc_objs = col->next;
   if(col->dtor) {
    void *data = (char*)col + sizeof *col;
    col->dtor(data);
   }
   free(col);
   collected++;
  } else {
   gc->mark = 0;
   gc = gc->next;
  }
 }
}

canonical_original_code:
static void gc_sweep() {
 struct gc_object *gc = gc_objs;
 int collected = 0;
 while(gc) {
  if(gc->mark == 0) {
   struct gc_object *col = gc;
   gc = gc->next;
   if(col->next) col->next->prev = col->prev;
   if(col->prev) col->prev->next = col->next;
   if(gc_objs == col)
    gc_objs = col->next;
   if(col->dtor) {
    void *data = (char*)col + sizeof *col;
    col->dtor(data);
   }
   free(col);
   collected++;
  } else {
   gc->mark = 0;
   gc = gc->next;
  }
 }
}

variable_types: struct gc_object { int mark; void (*marker)(void *); void (*dtor)(void *); int retcount; struct gc_object *next; struct gc_object *rnext; } *

variable_types: collected int


original_code:
void *gc_retain(void *p) {
 GcObj *r;
 ((void) (0));
 r = (GcObj *)((char *)p - sizeof *r);
 ((void) (0));
 if(r->retcount == 0) {
  r->rnext = gc_roots;
  gc_roots = r;
  if(r->rnext) r->rnext->rprev = r;
  r->rprev = ((void *)0);
 }
 r->retcount++;
 return p;
}

canonical_original_code:
void *gc_retain(void *p) {
 struct gc_object *r;
 ((void) (0));
 r = (struct gc_object *)((char *)p - sizeof *r);
 ((void) (0));
 if(r->retcount == 0) {
  r->rnext = gc_roots;
  gc_roots = r;
  if(r->rnext) r->rnext->rprev = r;
  r->rprev = ((void *)0);
 }
 r->retcount++;
 return p;
}

variable_types:
p
void *

user_defined_types: struct gc_object { int mark; void (*marker)(void *); void (*dtor)(void *); int retcount; struct gc_object *next; struct gc_object *rnext; }


original_code:
void gc_release(void *p) {
 GcObj *r;
 ((void) (0));
 r = (GcObj *)((char *)p - sizeof *r);
 ((void) (0));
 r->retcount--;
 if(r->retcount == 0) {
  if(r->rnext) r->rnext->rprev = r->rprev;
  if(r->rprev) r->rprev->rnext = r->rnext;
  if(gc_roots == r)
   gc_roots = r->rnext;
  r->rnext = ((void *)0);
  r->rprev = ((void *)0);
 }
}

canonical_original_code:
void gc_release(void *p) {
 struct gc_object *r;
 ((void) (0));
 r = (struct gc_object *)((char *)p - sizeof *r);
 ((void) (0));
 r->retcount--;
 if(r->retcount == 0) {
  if(r->rnext) r->rnext->rprev = r->rprev;
  if(r->rprev) r->rprev->rnext = r->rnext;
  if(gc_roots == r)
   gc_roots = r->rnext;
  r->rnext = ((void *)0);
  r->rprev = ((void *)0);
 }
}


decompiled_code:
void gc_collect()
{
gc_mark_all();
gc_sweep();
}

canonical_decompiled_code:
void func5()
{
func4();
func0();
}