decompiled_code:
int __fastcall val_int(__int16 *a1)
{
__int16 v1; // ax
__int64 v2; // rsi

if ( !a1 )
{
v2 = 0xFFFFFFFFLL;
LABEL_5:
cst_errmsg("VAL: tried to access int in %d typed val\n", v2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = *a1;
if ( *a1 == 1 )
return *((_DWORD *)a1 + 2);
if ( v1 == 3 )
return (int)*((float *)a1 + 2);
v2 = (unsigned int)v1;
if ( v1 != 5 )
goto LABEL_5;
return atoi(*((const char **)a1 + 1));
}

canonical_decompiled_code:
int __fastcall func5(__int16 *a1)
{
__int16 v1; // ax
__int64 v2; // rsi

if ( !a1 )
{
v2 = 0xFFFFFFFFLL;
LABEL_5:
cst_errmsg("VAL: tried to access int in %d typed val\n", v2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = *a1;
if ( *a1 == 1 )
return *((_DWORD *)a1 + 2);
if ( v1 == 3 )
return (int)*((float *)a1 + 2);
v2 = (unsigned int)v1;
if ( v1 != 5 )
goto LABEL_5;
return atoi(*((const char **)a1 + 1));
}

original_code:
int val_int(const cst_val *v)
{
   if (v && (((v)->c.a.type) == 1))
      return ((v)->c.a.v.ival);
   else if (v && (((v)->c.a.type) == 3))
      return (int)((v)->c.a.v.fval);
   else if (v && (((v)->c.a.type) == 5))
      return atoi(((const char *)(((v)->c.a.v.vval))));
   else
   {
      cst_errmsg("VAL: tried to access int in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

canonical_original_code:
int val_int(struct cst_val_struct *v)
{
   if (v && (((v)->c.a.type) == 1))
      return ((v)->c.a.v.ival);
   else if (v && (((v)->c.a.type) == 3))
      return (int)((v)->c.a.v.fval);
   else if (v && (((v)->c.a.type) == 5))
      return atoi(((char *)(((v)->c.a.v.vval))));
   else
   {
      cst_errmsg("VAL: tried to access int in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

variable_types: struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *


repo: deardaniel/PizzaTest

decompiled_code:
float __fastcall val_float(int *a1)
{
__int16 v1; // ax
__int64 v2; // rsi

if ( !a1 )
{
v2 = 0xFFFFFFFFLL;
LABEL_5:
cst_errmsg("VAL: tried to access float in %d typed val\n", v2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = *(_WORD *)a1;
if ( *(_WORD *)a1 == 1 )
return (float)a1[2];
if ( v1 == 3 )
return *((float *)a1 + 2);
v2 = (unsigned int)v1;
if ( v1 != 5 )
goto LABEL_5;
return cst_atof(*((_QWORD *)a1 + 1), v2);
}

canonical_decompiled_code:
float __fastcall func6(int *a1)
{
__int16 v1; // ax
__int64 v2; // rsi

if ( !a1 )
{
v2 = 0xFFFFFFFFLL;
LABEL_5:
cst_errmsg("VAL: tried to access float in %d typed val\n", v2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = *(_WORD *)a1;
if ( *(_WORD *)a1 == 1 )
return (float)a1[2];
if ( v1 == 3 )
return *((float *)a1 + 2);
v2 = (unsigned int)v1;
if ( v1 != 5 )
goto LABEL_5;
return cst_atof(*((_QWORD *)a1 + 1), v2);
}

original_code:
float val_float(const cst_val *v)
{
   if (v && (((v)->c.a.type) == 1))
      return (float)((v)->c.a.v.ival);
   else if (v && (((v)->c.a.type) == 3))
      return ((v)->c.a.v.fval);
   else if (v && (((v)->c.a.type) == 5))
      return cst_atof(((const char *)(((v)->c.a.v.vval))));
   else
   {
      cst_errmsg("VAL: tried to access float in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

canonical_original_code:
float val_float(struct cst_val_struct *v)
{
   if (v && (((v)->c.a.type) == 1))
      return (float)((v)->c.a.v.ival);
   else if (v && (((v)->c.a.type) == 3))
      return ((v)->c.a.v.fval);
   else if (v && (((v)->c.a.type) == 5))
      return cst_atof(((char *)(((v)->c.a.v.vval))));
   else
   {
      cst_errmsg("VAL: tried to access float in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

return_type: float

user_defined_types: struct cst_val_struct { union { struct cst_val_cons_struct cc; struct cst_val_atom_struct a; } c; }

user_defined_types: struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; }

user_defined_types: struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; }


decompiled_code:
__int64 __fastcall val_string(__int16 *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_3:
cst_errmsg("VAL: tried to access string in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = (unsigned int)*a1;
if ( *a1 != 5 )
goto LABEL_3;
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int16 *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_3:
cst_errmsg("VAL: tried to access string in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = (unsigned int)*a1;
if ( *a1 != 5 )
goto LABEL_3;
return *((_QWORD *)a1 + 1);
}

original_code:
const char *val_string(const cst_val *v)
{
   if (v && (((v)->c.a.type) == 5))
      return ((const char *)(((v)->c.a.v.vval)));
   else
   {
      cst_errmsg("VAL: tried to access string in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

canonical_original_code:
char *val_string(struct cst_val_struct *v)
{
   if (v && (((v)->c.a.type) == 5))
      return ((char *)(((v)->c.a.v.vval)));
   else
   {
      cst_errmsg("VAL: tried to access string in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

return_type: char *


decompiled_code:
__int64 __fastcall val_void(__int16 *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_4:
cst_errmsg("VAL: tried to access void in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = (unsigned int)*a1;
if ( (unsigned __int16)*a1 <= 1u || *a1 == 3 )
goto LABEL_4;
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int16 *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_4:
cst_errmsg("VAL: tried to access void in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = (unsigned int)*a1;
if ( (unsigned __int16)*a1 <= 1u || *a1 == 3 )
goto LABEL_4;
return *((_QWORD *)a1 + 1);
}

original_code:
void *val_void(const cst_val *v)
{
   if ((v == ((void *)0)) ||
      (((v)->c.a.type) == 0) ||
      (((v)->c.a.type) == 1) ||
      (((v)->c.a.type) == 3))
   {
      cst_errmsg("VAL: tried to access void in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
      return ((void *)0);
   }
   else
      return ((v)->c.a.v.vval);
}

canonical_original_code:
void *val_void(struct cst_val_struct *v)
{
   if ((v == ((void *)0)) ||
      (((v)->c.a.type) == 0) ||
      (((v)->c.a.type) == 1) ||
      (((v)->c.a.type) == 3))
   {
      cst_errmsg("VAL: tried to access void in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
      return ((void *)0);
   }
   else
      return ((v)->c.a.v.vval);
}

return_type: void *


decompiled_code:
_BOOL8 __fastcall cst_val_consp(_QWORD *a1)
{
return (*a1 & 1) == 0;
}

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

original_code:
int cst_val_consp(const cst_val *v)
{
   void *t;
   int t1;
   t = ((v)->c.cc.car);
   t1 = (int)t;
   if ((t1&0x1) == 0)
      return TRUE;
   else
      return FALSE;
}

canonical_original_code:
int cst_val_consp(struct cst_val_struct *v)
{
   void *t;
   int t1;
   t = ((v)->c.cc.car);
   t1 = (int)t;
   if ((t1&0x1) == 0)
      return TRUE;
   else
      return FALSE;
}

variable_types:
t
void *

return_type: int


decompiled_code:
__int64 __fastcall val_car(_QWORD *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_4:
cst_errmsg("VAL: tried to access car in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
if ( !cst_val_consp(a1) )
{
v1 = (unsigned int)*(__int16 *)a1;
goto LABEL_4;
}
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_4:
cst_errmsg("VAL: tried to access car in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
if ( !func9(a1) )
{
v1 = (unsigned int)*(__int16 *)a1;
goto LABEL_4;
}
return *a1;
}

original_code:
const cst_val *val_car(const cst_val *v)
{
   if (v && cst_val_consp(v))
      return ((v)->c.cc.car);
   else
   {
      cst_errmsg("VAL: tried to access car in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

canonical_original_code:
struct cst_val_struct *val_car(struct cst_val_struct *v)
{
   if (v && cst_val_consp(v))
      return ((v)->c.cc.car);
   else
   {
      cst_errmsg("VAL: tried to access car in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

variable_types:
v
struct cst_val_struct *

return_type: struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *


decompiled_code:
__int64 __fastcall val_cdr(_QWORD *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_4:
cst_errmsg("VAL: tried to access cdr in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
if ( !cst_val_consp(a1) )
{
v1 = (unsigned int)*(__int16 *)a1;
goto LABEL_4;
}
return a1[1];
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1)
{
__int64 v1; // rsi

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_4:
cst_errmsg("VAL: tried to access cdr in %d typed val\n", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
if ( !func9(a1) )
{
v1 = (unsigned int)*(__int16 *)a1;
goto LABEL_4;
}
return a1[1];
}

original_code:
const cst_val *val_cdr(const cst_val *v)
{
   if (v && cst_val_consp(v))
      return ((v)->c.cc.cdr);
   else
   {
      cst_errmsg("VAL: tried to access cdr in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}

canonical_original_code:
struct cst_val_struct *val_cdr(struct cst_val_struct *v)
{
   if (v && cst_val_consp(v))
      return ((v)->c.cc.cdr);
   else
   {
      cst_errmsg("VAL: tried to access cdr in %d typed val\n",
         (v ? ((v)->c.a.type) : -1));
      (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
   }
   return 0;
}


decompiled_code:
__int64 __fastcall val_reverse(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rcx
__int64 v3; // rdx

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

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rcx
__int64 v3; // rdx

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

original_code:
cst_val *val_reverse(cst_val *l)
{
   cst_val *n,*np,*nl;
   for (nl=0,n=l; n; nl=n,n=np)
   {
      np=((n)->c.cc.cdr);
      ((n)->c.cc.cdr) = nl;
   }
   return nl;
}

canonical_original_code:
struct cst_val_struct *val_reverse(struct cst_val_struct *l)
{
   struct cst_val_struct *n; struct cst_val_struct *np; struct cst_val_struct *nl;
   for (nl=0,n=l; n; nl=n,n=np)
   {
      np=((n)->c.cc.cdr);
      ((n)->c.cc.cdr) = nl;
   }
   return nl;
}

variable_types:
l
struct cst_val_struct *


decompiled_code:
__int64 __fastcall val_length(_QWORD *a1)
{
unsigned int i; // er12

for ( i = 0; a1; a1 = (_QWORD *)val_cdr(a1) )
++i;
return i;
}

canonical_decompiled_code:
__int64 __fastcall func14(_QWORD *a1)
{
unsigned int i; // er12

for ( i = 0; a1; a1 = (_QWORD *)func11(a1) )
++i;
return i;
}

original_code:
int val_length(const cst_val *l)
{
   const cst_val *n;
   int i;
   for (i=0,n=l; n; n=val_cdr(n))
      i++;
   return i;
}

canonical_original_code:
int val_length(struct cst_val_struct *l)
{
   struct cst_val_struct *n;
   int i;
   for (i=0,n=l; n; n=val_cdr(n))
      i++;
   return i;
}

variable_types: i int


decompiled_code:
__int64 __fastcall val_equal(__int16 *a1, __int16 *a2, __m128i a3)
{
__int16 v3; // dx
const char *v4; // rdi
const char *v5; // rsi
__int64 result; // rax
__int64 v7; // r13
__int64 v8; // rax
__int64 v9; // r12
__int64 v10; // rax
int v11; // ebx

if ( a1 == a2 )
return 1LL;
if ( !a1 || *a1 != *a2 )
return 0LL;
if ( cst_val_consp(a1) )
{
v7 = val_car(a2);
v8 = val_car(a1);
if ( (unsigned int)val_equal(v8, v7) )
{
v9 = val_cdr(a2);
v10 = val_cdr(a1);
return (unsigned int)val_equal(v10, v9) != 0;
}
return 0LL;
}
if ( v3 == 1 )
{
v11 = val_int(a1);
result = v11 == val_int(a2);
}
else if ( v3 == 3 )
{
*(float *)a3.m128i_i32 = val_float((int *)a1);
result = COERCE_FLOAT(_mm_cvtsi128_si32(a3)) == val_float((int *)a2);
}
else
{
v4 = (const char *)*((_QWORD *)a1 + 1);
v5 = (const char *)*((_QWORD *)a2 + 1);
result = v4 == v5;
if ( v3 == 5 )
result = strcmp(v4, v5) == 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int16 *a1, __int16 *a2, __m128i a3)
{
__int16 v3; // dx
const char *v4; // rdi
const char *v5; // rsi
__int64 result; // rax
__int64 v7; // r13
__int64 v8; // rax
__int64 v9; // r12
__int64 v10; // rax
int v11; // ebx

if ( a1 == a2 )
return 1LL;
if ( !a1 || *a1 != *a2 )
return 0LL;
if ( func9(a1) )
{
v7 = func10(a2);
v8 = func10(a1);
if ( (unsigned int)func15(v8, v7) )
{
v9 = func11(a2);
v10 = func11(a1);
return (unsigned int)func15(v10, v9) != 0;
}
return 0LL;
}
if ( v3 == 1 )
{
v11 = func5(a1);
result = v11 == func5(a2);
}
else if ( v3 == 3 )
{
*(float *)a3.m128i_i32 = func6((int *)a1);
result = COERCE_FLOAT(_mm_cvtsi128_si32(a3)) == func6((int *)a2);
}
else
{
v4 = (const char *)*((_QWORD *)a1 + 1);
v5 = (const char *)*((_QWORD *)a2 + 1);
result = v4 == v5;
if ( v3 == 5 )
result = strcmp(v4, v5) == 0;
}
return result;
}

original_code:
int val_equal(const cst_val *v1, const cst_val *v2)
{
   if (v1 == v2)
      return TRUE;
   else if (v1 == 0)
      return FALSE;
   else if (((v1)->c.a.type) == ((v2)->c.a.type))
   {
      if (cst_val_consp(v1))
         return ((val_equal(val_car(v1),val_car(v2))) &&
         (val_equal(val_cdr(v1),val_cdr(v2))));
      else if (((v1)->c.a.type) == 1)
         return (val_int(v1) == val_int(v2));
      else if (((v1)->c.a.type) == 3)
         return (val_float(v1) == val_float(v2));
      else if (((v1)->c.a.type) == 5)
         return ((strcmp(((const char *)(((v1)->c.a.v.vval))),((const char *)(((v2)->c.a.v.vval)))) == 0));
      else
         return ((v1)->c.a.v.vval) == ((v2)->c.a.v.vval);
   }
   else
      return FALSE;
}

canonical_original_code:
int val_equal(struct cst_val_struct *v1, struct cst_val_struct *v2)
{
   if (v1 == v2)
      return TRUE;
   else if (v1 == 0)
      return FALSE;
   else if (((v1)->c.a.type) == ((v2)->c.a.type))
   {
      if (cst_val_consp(v1))
         return ((val_equal(val_car(v1),val_car(v2))) &&
         (val_equal(val_cdr(v1),val_cdr(v2))));
      else if (((v1)->c.a.type) == 1)
         return (val_int(v1) == val_int(v2));
      else if (((v1)->c.a.type) == 3)
         return (val_float(v1) == val_float(v2));
      else if (((v1)->c.a.type) == 5)
         return ((strcmp(((char *)(((v1)->c.a.v.vval))),((char *)(((v2)->c.a.v.vval)))) == 0));
      else
         return ((v1)->c.a.v.vval) == ((v2)->c.a.v.vval);
   }
   else
      return FALSE;
}


decompiled_code:
_BOOL8 __fastcall val_less(int *a1, int *a2)
{
float v3; // [rsp+Ch] [rbp-Ch]

v3 = val_float(a1);
return val_float(a2) > v3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(int *a1, int *a2)
{
float v3; // [rsp+Ch] [rbp-Ch]

v3 = func6(a1);
return func6(a2) > v3;
}

original_code:
int val_less(const cst_val *v1, const cst_val *v2)
{
   return val_float(v1) < val_float(v2);
}

canonical_original_code:
int val_less(struct cst_val_struct *v1, struct cst_val_struct *v2)
{
   return val_float(v1) < val_float(v2);
}


decompiled_code:
_BOOL8 __fastcall val_greater(int *a1, int *a2)
{
float v3; // [rsp+Ch] [rbp-Ch]

v3 = val_float(a1);
return v3 > val_float(a2);
}

canonical_decompiled_code:
_BOOL8 __fastcall func17(int *a1, int *a2)
{
float v3; // [rsp+Ch] [rbp-Ch]

v3 = func6(a1);
return v3 > func6(a2);
}

original_code:
int val_greater(const cst_val *v1,const cst_val *v2)
{
   return val_float(v1) > val_float(v2);
}

canonical_original_code:
int val_greater(struct cst_val_struct *v1, struct cst_val_struct *v2)
{
   return val_float(v1) > val_float(v2);
}


decompiled_code:
__int64 __fastcall val_member(__int16 *a1, _QWORD *a2, __m128i a3)
{
_QWORD *v3; // rbp
__int16 *v4; // rax

if ( !a2 )
return 0LL;
v3 = a2;
do
{
v4 = (__int16 *)val_car(v3);
if ( (unsigned int)val_equal(v4, a1, a3) )
return 1LL;
v3 = (_QWORD *)val_cdr(v3);
}
while ( v3 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int16 *a1, _QWORD *a2, __m128i a3)
{
_QWORD *v3; // rbp
__int16 *v4; // rax

if ( !a2 )
return 0LL;
v3 = a2;
do
{
v4 = (__int16 *)func10(v3);
if ( (unsigned int)func15(v4, a1, a3) )
return 1LL;
v3 = (_QWORD *)func11(v3);
}
while ( v3 );
return 0LL;
}

original_code:
int val_member(const cst_val *v1,const cst_val *l)
{
   const cst_val *i;
   for (i=l; i; i=val_cdr(i))
   {
      if (val_equal(val_car(i),v1))
         return TRUE;
   }
   return FALSE;
}

canonical_original_code:
int val_member(struct cst_val_struct *v1, struct cst_val_struct *l)
{
   struct cst_val_struct *i;
   for (i=l; i; i=val_cdr(i))
   {
      if (val_equal(val_car(i),v1))
         return TRUE;
   }
   return FALSE;
}


decompiled_code:
__int64 __fastcall val_member_string(char *s1, _QWORD *a2)
{
_QWORD *v2; // rbp
__int16 *v3; // rax
const char *v4; // rax

if ( !a2 )
return 0LL;
v2 = a2;
do
{
v3 = (__int16 *)val_car(v2);
v4 = (const char *)val_string(v3);
if ( !strcmp(s1, v4) )
return 1LL;
v2 = (_QWORD *)val_cdr(v2);
}
while ( v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func19(char *s1, _QWORD *a2)
{
_QWORD *v2; // rbp
__int16 *v3; // rax
const char *v4; // rax

if ( !a2 )
return 0LL;
v2 = a2;
do
{
v3 = (__int16 *)func10(v2);
v4 = (const char *)func7(v3);
if ( !strcmp(s1, v4) )
return 1LL;
v2 = (_QWORD *)func11(v2);
}
while ( v2 );
return 0LL;
}

original_code:
int val_member_string(const char *v1,const cst_val *l)
{
   const cst_val *i;
   for (i=l; i; i=val_cdr(i))
   {
      if ((strcmp(v1,val_string(val_car(i))) == 0))
         return TRUE;
   }
   return FALSE;
}

canonical_original_code:
int val_member_string(char *v1, struct cst_val_struct *l)
{
   struct cst_val_struct *i;
   for (i=l; i; i=val_cdr(i))
   {
      if ((strcmp(v1,val_string(val_car(i))) == 0))
         return TRUE;
   }
   return FALSE;
}


decompiled_code:
__int64 __fastcall val_inc_refcount(__int64 a1)
{
__int16 v2; // dx

if ( *(_WORD *)(a1 + 2) != 0xFFFF && !cst_val_consp((_QWORD *)a1) )
*(_WORD *)(a1 + 2) = v2 + 1;
return a1;
}

original_code:
cst_val *val_inc_refcount(const cst_val *b)
{
   cst_val *wb;
   wb = (cst_val *)(void *)b;
   if (((wb)->c.a.ref_count) == -1)
      return wb;
   else if (!cst_val_consp(wb))
      ((wb)->c.a.ref_count) += 1;
   return wb;
}

canonical_original_code:
struct cst_val_struct *val_inc_refcount(struct cst_val_struct *b)
{
   struct cst_val_struct *wb;
   wb = (struct cst_val_struct *)(void *)b;
   if (((wb)->c.a.ref_count) == -1)
      return wb;
   else if (!cst_val_consp(wb))
      ((wb)->c.a.ref_count) += 1;
   return wb;
}

variable_types:
b
struct cst_val_struct *


decompiled_code:
int __fastcall val_dec_refcount(__int64 a1)
{
__int16 v1; // dx

if ( *(_WORD *)(a1 + 2) == 0xFFFF )
return -1;
if ( cst_val_consp((_QWORD *)a1) || !v1 )
return 0;
*(_WORD *)(a1 + 2) = v1 - 1;
return (__int16)(v1 - 1);
}

original_code:
int val_dec_refcount(const cst_val *b)
{
   cst_val *wb;
   wb = (cst_val *)(void *)b;
   if (((wb)->c.a.ref_count) == -1)
      return -1;
   else if (cst_val_consp(wb))
      return 0;
   else if (((wb)->c.a.ref_count) == 0)
   {
      return 0;
   }
   else
   {
      ((wb)->c.a.ref_count) -= 1;
      return ((wb)->c.a.ref_count);
   }
}

canonical_original_code:
int val_dec_refcount(struct cst_val_struct *b)
{
   struct cst_val_struct *wb;
   wb = (struct cst_val_struct *)(void *)b;
   if (((wb)->c.a.ref_count) == -1)
      return -1;
   else if (cst_val_consp(wb))
      return 0;
   else if (((wb)->c.a.ref_count) == 0)
   {
      return 0;
   }
   else
   {
      ((wb)->c.a.ref_count) -= 1;
      return ((wb)->c.a.ref_count);
   }
}


decompiled_code:
void __fastcall delete_val(_QWORD *a1)
{
__int16 v1; // ax

if ( a1 )
{
if ( cst_val_consp(a1) )
{
delete_val(*a1);
delete_val(a1[1]);
cst_free(a1);
}
else if ( !val_dec_refcount((__int64)a1) )
{
v1 = *(_WORD *)a1;
if ( *(_WORD *)a1 == 5 )
{
cst_free(a1[1]);
}
else if ( v1 > 6 )
{
cst_val_defs[2 * (v1 >> 1) + 1](a1[1]);
}
cst_free(a1);
}
}
}

original_code:
void delete_val(cst_val *v)
{
   if (v)
   {
      if (cst_val_consp(v))
      {
         delete_val(((v)->c.cc.car));
         delete_val(((v)->c.cc.cdr));
         cst_free(v);
      }
      else if (val_dec_refcount(v) == 0)
      {
         if (((v)->c.a.type) == 5)
            cst_free(((v)->c.a.v.vval));
         else if (((v)->c.a.type) >= 7)
            (cst_val_defs[((v)->c.a.type)/2].delete_function)(((v)->c.a.v.vval));
         cst_free(v);
      }
   }
}

canonical_original_code:
void delete_val(struct cst_val_struct *v)
{
   if (v)
   {
      if (cst_val_consp(v))
      {
         delete_val(((v)->c.cc.car));
         delete_val(((v)->c.cc.cdr));
         cst_free(v);
      }
      else if (val_dec_refcount(v) == 0)
      {
         if (((v)->c.a.type) == 5)
            cst_free(((v)->c.a.v.vval));
         else if (((v)->c.a.type) >= 7)
            (cst_val_defs[((v)->c.a.type)/2].delete_function)(((v)->c.a.v.vval));
         cst_free(v);
      }
   }
}

return_type: void


decompiled_code:
void __fastcall delete_val_list(_QWORD *a1)
{
if ( a1 )
{
if ( cst_val_consp(a1) )
{
delete_val_list(a1[1]);
cst_free(a1);
}
else
{
delete_val(a1);
}
}
}

canonical_decompiled_code:
void __fastcall func23(_QWORD *a1)
{
if ( a1 )
{
if ( func9(a1) )
{
func23(a1[1]);
cst_free(a1);
}
else
{
func22(a1);
}
}
}

original_code:
void delete_val_list(cst_val *v)
{
   if (v)
   {
      if (cst_val_consp(v))
      {
         delete_val_list(((v)->c.cc.cdr));
         cst_free(v);
      }
      else
         delete_val(v);
   }
}

canonical_original_code:
void delete_val_list(struct cst_val_struct *v)
{
   if (v)
   {
      if (cst_val_consp(v))
      {
         delete_val_list(((v)->c.cc.cdr));
         cst_free(v);
      }
      else
         delete_val(v);
   }
}


decompiled_code:
__int64 __fastcall val_uttfunc(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_uttfunc )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "uttfunc");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_uttfunc )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "uttfunc");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

original_code: cst_uttfunc val_uttfunc(const cst_val *v) { if (v && ((v)->c.a.type) == cst_val_type_uttfunc) return (cst_uttfunc)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "uttfunc", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

canonical_original_code: struct cst_utterance_struct *(*val_uttfunc(struct cst_val_struct *v))(struct cst_utterance_struct *i) { if (v && ((v)->c.a.type) == cst_val_type_uttfunc) return (cst_uttfunc)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "uttfunc", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

return_type: struct cst_utterance_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *(*)(struct cst_utterance_struct *i)

user_defined_types: struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; }

user_defined_types: struct cst_features_struct { struct cst_featvalpair_struct *head; void *ctx; }

user_defined_types: struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; }


decompiled_code:
__int64 __fastcall uttfunc_val(__int64 a1)
{
return val_new_typed(cst_val_type_uttfunc, a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return val_new_typed(cst_val_type_uttfunc, a1);
}

original_code: cst_val *uttfunc_val(const cst_uttfunc v) { return val_new_typed(cst_val_type_uttfunc, (void *)v); }

canonical_original_code: struct cst_val_struct *uttfunc_val(struct cst_utterance_struct *(*v)(struct cst_utterance_struct *i)) { return val_new_typed(cst_val_type_uttfunc, (void *)v); }

variable_types: struct cst_utterance_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *(*)(struct cst_utterance_struct *i)


decompiled_code:
_QWORD *new_utterance()
{
__int64 v0; // rax
_QWORD *v1; // r12
__int64 v2; // rax
__int64 v3; // rdi
__int64 v4; // rax
__int64 v5; // rdi

v0 = cst_safe_alloc(32LL);
*(_QWORD *)(v0 + 24) = 0LL;
v1 = (_QWORD *)v0;
v2 = new_features_local(0LL);
v3 = v1[3];
*v1 = v2;
v4 = new_features_local(v3);
v5 = v1[3];
v1[1] = v4;
v1[2] = new_features_local(v5);
return v1;
}

canonical_decompiled_code:
_QWORD *func2()
{
__int64 v0; // rax
_QWORD *v1; // r12
__int64 v2; // rax
__int64 v3; // rdi
__int64 v4; // rax
__int64 v5; // rdi

v0 = cst_safe_alloc(32LL);
*(_QWORD *)(v0 + 24) = 0LL;
v1 = (_QWORD *)v0;
v2 = new_features_local(0LL);
v3 = v1[3];
*v1 = v2;
v4 = new_features_local(v3);
v5 = v1[3];
v1[1] = v4;
v1[2] = new_features_local(v5);
return v1;
}

original_code:
cst_utterance *new_utterance()
{
    cst_utterance *u;
    u = ((struct cst_utterance_struct *)cst_safe_alloc(sizeof(struct cst_utterance_struct)*(1)));
    u->ctx = (((void *)0));
    u->features = new_features_local(u->ctx);
    u->ffunctions = new_features_local(u->ctx);
    u->relations = new_features_local(u->ctx);
    return u;
}

canonical_original_code:
struct cst_utterance_struct *new_utterance()
{
    struct cst_utterance_struct *u;
    u = ((struct cst_utterance_struct *)cst_safe_alloc(sizeof(struct cst_utterance_struct)*(1)));
    u->ctx = (((void *)0));
    u->features = new_features_local(u->ctx);
    u->ffunctions = new_features_local(u->ctx);
    u->relations = new_features_local(u->ctx);
    return u;
}

variable_types: struct cst_utterance_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *


decompiled_code:
void __fastcall delete_utterance(_QWORD *a1)
{
__int64 *v2; // rdi
__int64 v3; // rbx
__int64 v4; // rax

if ( a1 )
{
delete_features(*a1);
delete_features(a1[1]);
v2 = (__int64 *)a1[2];
v3 = *v2;
if ( *v2 )
{
do
{
v4 = val_relation(*(_QWORD *)(v3 + 8));
delete_relation(v4);
v3 = *(_QWORD *)(v3 + 16);
}
while ( v3 );
v2 = (__int64 *)a1[2];
}
delete_features(v2);
cst_free(a1);
}
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1)
{
__int64 *v2; // rdi
__int64 v3; // rbx
__int64 v4; // rax

if ( a1 )
{
delete_features(*a1);
delete_features(a1[1]);
v2 = (__int64 *)a1[2];
v3 = *v2;
if ( *v2 )
{
do
{
v4 = val_relation(*(_QWORD *)(v3 + 8));
delete_relation(v4);
v3 = *(_QWORD *)(v3 + 16);
}
while ( v3 );
v2 = (__int64 *)a1[2];
}
delete_features(v2);
cst_free(a1);
}
}

original_code:
void delete_utterance(cst_utterance *u)
{
    cst_featvalpair *fp;
    if (u)
    {
 delete_features(u->features);
 delete_features(u->ffunctions);
 for (fp=u->relations->head; fp; fp=fp->next)
     delete_relation(val_relation(fp->val));
 delete_features(u->relations);
 ;
 cst_free(u);
    }
}

canonical_original_code:
void delete_utterance(struct cst_utterance_struct *u)
{
    struct cst_featvalpair_struct *fp;
    if (u)
    {
 delete_features(u->features);
 delete_features(u->ffunctions);
 for (fp=u->relations->head; fp; fp=fp->next)
     delete_relation(val_relation(fp->val));
 delete_features(u->relations);
 ;
 cst_free(u);
    }
}

variable_types: struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *


decompiled_code:
__int64 __fastcall utt_relation_delete(__int64 a1, __int64 a2)
{
__int64 v3; // rax
__int64 v4; // rax

if ( (unsigned int)feat_present(*(_QWORD *)(a1 + 16)) )
{
v3 = feat_val(*(_QWORD *)(a1 + 16), a2);
v4 = val_relation(v3);
delete_relation(v4);
}
return feat_remove(*(_QWORD *)(a1 + 16), a2);
}

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

if ( (unsigned int)feat_present(*(_QWORD *)(a1 + 16)) )
{
v3 = feat_val(*(_QWORD *)(a1 + 16), a2);
v4 = val_relation(v3);
delete_relation(v4);
}
return feat_remove(*(_QWORD *)(a1 + 16), a2);
}

original_code:
int utt_relation_delete(cst_utterance *u,const char *name)
{
    if (feat_present(u->relations, name))
 delete_relation(val_relation(feat_val(u->relations,name)));
    return feat_remove(u->relations,name);
}

canonical_original_code:
int utt_relation_delete(struct cst_utterance_struct *u, char *name)
{
    if (feat_present(u->relations, name))
 delete_relation(val_relation(feat_val(u->relations,name)));
    return feat_remove(u->relations,name);
}

variable_types:
name
char *


decompiled_code:
__int64 __fastcall utt_relation_create(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // rax

utt_relation_delete(a1, a2);
v2 = new_relation(a2, a1);
v3 = relation_val(v2);
feat_set(*(_QWORD *)(a1 + 16), a2, v3);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // rax

func4(a1, a2);
v2 = new_relation(a2, a1);
v3 = relation_val(v2);
feat_set(*(_QWORD *)(a1 + 16), a2, v3);
return v2;
}

original_code:
cst_relation *utt_relation_create(cst_utterance *u,const char *name)
{
    cst_relation *r;
    utt_relation_delete(u,name);
    r = new_relation(name,u);
    feat_set(u->relations,name,relation_val(r));
    return r;
}

canonical_original_code:
struct cst_relation_struct *utt_relation_create(struct cst_utterance_struct *u, char *name)
{
    struct cst_relation_struct *r;
    utt_relation_delete(u,name);
    r = new_relation(name,u);
    feat_set(u->relations,name,relation_val(r));
    return r;
}

variable_types:
u
struct cst_utterance_struct *

variable_types: struct cst_relation_struct { char *name; struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *head; struct cst_item_struct *tail; } *

user_defined_types: struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; }

user_defined_types: struct cst_item_struct { struct cst_item_contents_struct *contents; struct cst_relation_struct *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; }


decompiled_code:
__int64 __fastcall utt_relation_present(__int64 a1)
{
return feat_present(*(_QWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return feat_present(*(_QWORD *)(a1 + 16));
}

original_code:
int utt_relation_present(cst_utterance *u,const char *name)
{
    return feat_present(u->relations,name);
}

canonical_original_code:
int utt_relation_present(struct cst_utterance_struct *u, char *name)
{
    return feat_present(u->relations,name);
}


decompiled_code:
__int64 __fastcall utt_relation(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = feat_val(*(_QWORD *)(a1 + 16), a2);
if ( !v2 )
{
cst_errmsg("Relation: %s not present in utterance\n", a2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return val_relation(v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = feat_val(*(_QWORD *)(a1 + 16), a2);
if ( !v2 )
{
cst_errmsg("Relation: %s not present in utterance\n", a2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return val_relation(v2);
}

original_code:
cst_relation *utt_relation(cst_utterance *u,const char *name)
{
    const cst_val *v = feat_val(u->relations,name);
    if (v != ((void *)0))
 return val_relation(v);
    else
    {
 cst_errmsg("Relation: %s not present in utterance\n",
     name);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    return ((void *)0);
}

canonical_original_code:
struct cst_relation_struct *utt_relation(struct cst_utterance_struct *u, char *name)
{
    struct cst_val_struct *v = feat_val(u->relations,name);
    if (v != ((void *)0))
 return val_relation(v);
    else
    {
 cst_errmsg("Relation: %s not present in utterance\n",
     name);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    return ((void *)0);
}

return_type: struct cst_relation_struct { char *name; struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *head; struct cst_item_struct *tail; } *


decompiled_code:
_QWORD *new_voice()
{
_QWORD *v0; // r12

v0 = (_QWORD *)cst_safe_alloc(24LL);
*v0 = new_features();
v0[1] = new_features();
return v0;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *v0; // r12

v0 = (_QWORD *)cst_safe_alloc(24LL);
*v0 = new_features();
v0[1] = new_features();
return v0;
}

original_code:
cst_voice *new_voice()
{
    cst_voice *v = ((struct cst_voice_struct *)cst_safe_alloc(sizeof(struct cst_voice_struct)*(1)));
    v->features = new_features();
    v->ffunctions = new_features();
    return v;
}

canonical_original_code:
struct cst_voice_struct *new_voice()
{
    struct cst_voice_struct *v = ((struct cst_voice_struct *)cst_safe_alloc(sizeof(struct cst_voice_struct)*(1)));
    v->features = new_features();
    v->ffunctions = new_features();
    return v;
}

variable_types: struct cst_voice_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *ffunctions; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *(*utt_init)(struct cst_utterance_struct *u, struct cst_voice_struct *v); } *

user_defined_types: struct cst_voice_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_utterance_struct *(*utt_init)(struct cst_utterance_struct *u, struct cst_voice_struct *v); }


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

if ( a1 )
{
delete_features(*a1);
delete_features(a1[1]);
result = cst_free(a1);
}
return result;
}

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

if ( a1 )
{
delete_features(*a1);
delete_features(a1[1]);
result = cst_free(a1);
}
return result;
}

original_code:
void delete_voice(cst_voice *v)
{
    if (v)
    {
 delete_features(v->features);
 delete_features(v->ffunctions);
 cst_free(v);
    }
}

canonical_original_code:
void delete_voice(struct cst_voice_struct *v)
{
    if (v)
    {
 delete_features(v->features);
 delete_features(v->ffunctions);
 cst_free(v);
    }
}


original_code:
void swap_bytes_short(short *b, int n)
{
    int i;
    for (i=0; i<n; i++)
 b[i] = ((((unsigned)b[i]) & 0xff) << 8 | (((unsigned)b[i]) & 0xff00) >> 8);
}

canonical_original_code:
void swap_bytes_short(short *b, int n)
{
    int i;
    for (i=0; i<n; i++)
 b[i] = ((((unsigned int)b[i]) & 0xff) << 8 | (((unsigned int)b[i]) & 0xff00) >> 8);
}

variable_types:
b
short *

variable_types: n int


original_code:
cst_wave *lpc_resynth(cst_lpcres *lpcres)
{
    cst_wave *w;
    int i,j,r,o,k;
    int ci,cr;
    float *outbuf, *lpccoefs;
    int pm_size_samps;
    float pp = 0;
    w = new_wave();
    cst_wave_resize(w,lpcres->num_samples * lpcres->residual_fold,1);
    w->sample_rate = lpcres->sample_rate;
    outbuf = ((float *)cst_safe_alloc(sizeof(float)*(1+lpcres->num_channels)));
    lpccoefs = ((float *)cst_safe_alloc(sizeof(float)*(lpcres->num_channels)));
    for (r=0,o=lpcres->num_channels,i=0; i < lpcres->num_frames; i++)
    {
 pm_size_samps = lpcres->sizes[i] * lpcres->residual_fold;
 for (k=0; k<lpcres->num_channels; k++)
 {
     lpccoefs[k] = (float)((((double)lpcres->frames[i][k])/65535.0)*
      lpcres->lpc_range) + lpcres->lpc_min;
 }
 for (j=0; j < pm_size_samps; j++,r++)
 {
     outbuf[o] = (float)cst_ulaw_to_short(lpcres->residual[r/lpcres->residual_fold]);
     cr = (o == 0 ? lpcres->num_channels : o-1);
     for (ci=0; ci < lpcres->num_channels; ci++)
     {
  outbuf[o] += lpccoefs[ci] * outbuf[cr];
  cr = (cr == 0 ? lpcres->num_channels : cr-1);
     }
     w->samples[r] = (short)(outbuf[o] + pp*lpcres->post_emphasis);
     pp = outbuf[o];
     o = (o == lpcres->num_channels ? 0 : o+1);
 }
    }
    cst_free(outbuf);
    cst_free(lpccoefs);
    return w;
}

canonical_original_code:
struct cst_wave_struct *lpc_resynth(struct cst_lpcres_struct *lpcres)
{
    struct cst_wave_struct *w;
    int i; int j; int r; int o; int k;
    int ci; int cr;
    float *outbuf; float *lpccoefs;
    int pm_size_samps;
    float pp = 0;
    w = new_wave();
    cst_wave_resize(w,lpcres->num_samples * lpcres->residual_fold,1);
    w->sample_rate = lpcres->sample_rate;
    outbuf = ((float *)cst_safe_alloc(sizeof(float)*(1+lpcres->num_channels)));
    lpccoefs = ((float *)cst_safe_alloc(sizeof(float)*(lpcres->num_channels)));
    for (r=0,o=lpcres->num_channels,i=0; i < lpcres->num_frames; i++)
    {
 pm_size_samps = lpcres->sizes[i] * lpcres->residual_fold;
 for (k=0; k<lpcres->num_channels; k++)
 {
     lpccoefs[k] = (float)((((double)lpcres->frames[i][k])/65535.0)*
      lpcres->lpc_range) + lpcres->lpc_min;
 }
 for (j=0; j < pm_size_samps; j++,r++)
 {
     outbuf[o] = (float)cst_ulaw_to_short(lpcres->residual[r/lpcres->residual_fold]);
     cr = (o == 0 ? lpcres->num_channels : o-1);
     for (ci=0; ci < lpcres->num_channels; ci++)
     {
  outbuf[o] += lpccoefs[ci] * outbuf[cr];
  cr = (cr == 0 ? lpcres->num_channels : cr-1);
     }
     w->samples[r] = (short)(outbuf[o] + pp*lpcres->post_emphasis);
     pp = outbuf[o];
     o = (o == lpcres->num_channels ? 0 : o+1);
 }
    }
    cst_free(outbuf);
    cst_free(lpccoefs);
    return w;
}

variable_types: struct cst_lpcres_struct { unsigned short **frames; int *times; int num_frames; int num_channels; float lpc_min; float lpc_range; float post_emphasis; int num_samples; int sample_rate; int residual_fold; int *sizes; unsigned char *residual; } *

variable_types: struct cst_wave_struct { char *type; int sample_rate; int num_samples; int num_channels; short *samples; } *

variable_types: j int

variable_types: r int

variable_types: o int

variable_types: k int

variable_types: ci int

variable_types: cr int

variable_types:
outbuf
float *

variable_types:
lpccoefs
float *

variable_types: pp float


original_code:
cst_wave *lpc_resynth_windows(cst_lpcres *lpcres)
{
    cst_wave *w;
    int i,j,r,o,k;
    int ci,cr;
    float *outbuf, *lpccoefs;
    int pm_size_samps;
    float pp = 0;
    w = new_wave();
    cst_wave_resize(w,lpcres->num_samples * lpcres->residual_fold,1);
    w->sample_rate = lpcres->sample_rate;
    outbuf = ((float *)cst_safe_alloc(sizeof(float)*(1+lpcres->num_channels)));
    lpccoefs = ((float *)cst_safe_alloc(sizeof(float)*(lpcres->num_channels)));
    for (r=0,o=lpcres->num_channels,i=0; i < lpcres->num_frames; i++)
    {
 pm_size_samps = lpcres->sizes[i] * lpcres->residual_fold;
 for (k=0; k<lpcres->num_channels; k++)
 {
     lpccoefs[k] = ((float)(((double)lpcres->frames[i][k])/65535.0)*
      lpcres->lpc_range) + lpcres->lpc_min;
 }
 memset(outbuf,0,sizeof(float)*(1+lpcres->num_channels));
 for (j=0; j < pm_size_samps; j++,r++)
 {
     outbuf[o] = (float)cst_ulaw_to_short(lpcres->residual[r / lpcres->residual_fold]);
     cr = (o == 0 ? lpcres->num_channels : o-1);
     for (ci=0; ci < lpcres->num_channels; ci++)
     {
  outbuf[o] += lpccoefs[ci] * outbuf[cr];
  cr = (cr == 0 ? lpcres->num_channels : cr-1);
     }
     w->samples[r] = (short)(outbuf[o] + pp*lpcres->post_emphasis);
     pp = outbuf[o];
     o = (o == lpcres->num_channels ? 0 : o+1);
 }
    }
    cst_free(outbuf);
    cst_free(lpccoefs);
    return w;
}

canonical_original_code:
struct cst_wave_struct *lpc_resynth_windows(struct cst_lpcres_struct *lpcres)
{
    struct cst_wave_struct *w;
    int i; int j; int r; int o; int k;
    int ci; int cr;
    float *outbuf; float *lpccoefs;
    int pm_size_samps;
    float pp = 0;
    w = new_wave();
    cst_wave_resize(w,lpcres->num_samples * lpcres->residual_fold,1);
    w->sample_rate = lpcres->sample_rate;
    outbuf = ((float *)cst_safe_alloc(sizeof(float)*(1+lpcres->num_channels)));
    lpccoefs = ((float *)cst_safe_alloc(sizeof(float)*(lpcres->num_channels)));
    for (r=0,o=lpcres->num_channels,i=0; i < lpcres->num_frames; i++)
    {
 pm_size_samps = lpcres->sizes[i] * lpcres->residual_fold;
 for (k=0; k<lpcres->num_channels; k++)
 {
     lpccoefs[k] = ((float)(((double)lpcres->frames[i][k])/65535.0)*
      lpcres->lpc_range) + lpcres->lpc_min;
 }
 memset(outbuf,0,sizeof(float)*(1+lpcres->num_channels));
 for (j=0; j < pm_size_samps; j++,r++)
 {
     outbuf[o] = (float)cst_ulaw_to_short(lpcres->residual[r / lpcres->residual_fold]);
     cr = (o == 0 ? lpcres->num_channels : o-1);
     for (ci=0; ci < lpcres->num_channels; ci++)
     {
  outbuf[o] += lpccoefs[ci] * outbuf[cr];
  cr = (cr == 0 ? lpcres->num_channels : cr-1);
     }
     w->samples[r] = (short)(outbuf[o] + pp*lpcres->post_emphasis);
     pp = outbuf[o];
     o = (o == lpcres->num_channels ? 0 : o+1);
 }
    }
    cst_free(outbuf);
    cst_free(lpccoefs);
    return w;
}

variable_types: i int

return_type: struct cst_wave_struct { char *type; int sample_rate; int num_samples; int num_channels; short *samples; } *

user_defined_types: struct cst_lpcres_struct { unsigned short **frames; int *times; int num_frames; int num_channels; float lpc_min; float lpc_range; float post_emphasis; int num_samples; int sample_rate; int residual_fold; int *sizes; unsigned char *residual; }


original_code:
void lpc2ref(const float *lpc, float *rfc, int order)
{
    int i,j;
    float f,ai;
    float *vo,*vx;
    float *vn = ((float *)cst_safe_alloc(sizeof(float)*(order)));
    i = order-1;
    rfc[i] = ai = lpc[i];
    f = 1-ai*ai;
    i--;
    for (j=0; j<=i; j++)
        rfc[j] = (lpc[j]+((ai*lpc[i-j])))/f;
    vo=rfc;
    for ( ;i>0; )
    {
        ai=vo[i];
        f = 1-ai*ai;
        i--;
 for (j=0; j<=i; j++)
            vn[j] = (vo[j]+((ai*vo[i-j])))/f;
        rfc[i]=vn[i];
        vx = vn;
        vn = vo;
        vo = vx;
    }
    cst_free(vn);
}

canonical_original_code:
void lpc2ref(float *lpc, float *rfc, int order)
{
    int i; int j;
    float f; float ai;
    float *vo; float *vx;
    float *vn = ((float *)cst_safe_alloc(sizeof(float)*(order)));
    i = order-1;
    rfc[i] = ai = lpc[i];
    f = 1-ai*ai;
    i--;
    for (j=0; j<=i; j++)
        rfc[j] = (lpc[j]+((ai*lpc[i-j])))/f;
    vo=rfc;
    for ( ;i>0; )
    {
        ai=vo[i];
        f = 1-ai*ai;
        i--;
 for (j=0; j<=i; j++)
            vn[j] = (vo[j]+((ai*vo[i-j])))/f;
        rfc[i]=vn[i];
        vx = vn;
        vn = vo;
        vo = vx;
    }
    cst_free(vn);
}

variable_types:
lpc
float *

variable_types:
rfc
float *

variable_types: order int

variable_types: f float

variable_types: ai float

variable_types:
vo
float *

variable_types:
vx
float *

variable_types:
vn
float *


original_code:
void ref2lpc(const float *rfc, float *lpc, int order)
{
    float a,b;
    int n,k;
    for (n=0; n < order; n++)
    {
        lpc[n] = rfc[n];
        for (k=0; 2*(k+1) <= n+1; k++)
        {
            a = lpc[k];
            b = lpc[n-(k+1)];
            lpc[k] = a-b*lpc[n];
            lpc[n-(k+1)] = b-a*lpc[n];
        }
    }
}

canonical_original_code:
void ref2lpc(float *rfc, float *lpc, int order)
{
    float a; float b;
    int n; int k;
    for (n=0; n < order; n++)
    {
        lpc[n] = rfc[n];
        for (k=0; 2*(k+1) <= n+1; k++)
        {
            a = lpc[k];
            b = lpc[n-(k+1)];
            lpc[k] = a-b*lpc[n];
            lpc[n-(k+1)] = b-a*lpc[n];
        }
    }
}

variable_types: a float

variable_types: b float

variable_types: n int


decompiled_code:
void *__fastcall cst_safe_alloc(size_t a1)
{
unsigned int v1; // ebp
void *result; // rax
struct __jmp_buf_tag *v3; // rdi

v1 = a1;
if ( (a1 & 0x80000000) != 0LL )
{
cst_errmsg("alloc: asked for negative size %d\n", (unsigned int)a1);
v3 = cst_errjmp;
if ( !cst_errjmp )
goto LABEL_9;
goto LABEL_7;
}
a1 = (int)a1;
if ( !(_DWORD)a1 )
{
a1 = 1LL;
v1 = 1;
}
result = calloc(a1, 1uLL);
if ( !result )
{
cst_errmsg("alloc: can't alloc %d bytes\n", v1);
v3 = cst_errjmp;
if ( !cst_errjmp )
LABEL_9:
exit(-1);
LABEL_7:
longjmp(v3, 1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t a1)
{
unsigned int v1; // ebp
void *result; // rax
struct __jmp_buf_tag *v3; // rdi

v1 = a1;
if ( (a1 & 0x80000000) != 0LL )
{
cst_errmsg("alloc: asked for negative size %d\n", (unsigned int)a1);
v3 = cst_errjmp;
if ( !cst_errjmp )
goto LABEL_9;
goto LABEL_7;
}
a1 = (int)a1;
if ( !(_DWORD)a1 )
{
a1 = 1LL;
v1 = 1;
}
result = calloc(a1, 1uLL);
if ( !result )
{
cst_errmsg("alloc: can't alloc %d bytes\n", v1);
v3 = cst_errjmp;
if ( !cst_errjmp )
LABEL_9:
exit(-1);
LABEL_7:
longjmp(v3, 1);
}
return result;
}

original_code:
void *cst_safe_alloc(int size)
{
    void *p = ((void *)0);
    if (size < 0)
    {
 cst_errmsg("alloc: asked for negative size %d\n", size);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    else if (size == 0)
 size++;
    p = (void *)calloc(size,1);
    if (p == ((void *)0))
    {
 cst_errmsg("alloc: can't alloc %d bytes\n", size);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    return p;
}

variable_types: size int

variable_types:
p
void *


decompiled_code:
// attributes: thunk
void *__fastcall cst_safe_calloc(size_t a1)
{
return cst_safe_alloc(a1);
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
return func0(a1);
}

original_code:
void *cst_safe_calloc(int size)
{
    return cst_safe_alloc(size);
}


decompiled_code:
void *__fastcall cst_safe_realloc(void *a1, unsigned int a2)
{
unsigned int v2; // ebp
void *result; // rax

v2 = a2;
if ( !a2 )
v2 = 1;
if ( a1 )
result = realloc(a1, (int)v2);
else
result = cst_safe_alloc(v2);
if ( !result )
{
cst_errmsg("CST_REALLOC failed for %d bytes\n", v2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, unsigned int a2)
{
unsigned int v2; // ebp
void *result; // rax

v2 = a2;
if ( !a2 )
v2 = 1;
if ( a1 )
result = realloc(a1, (int)v2);
else
result = func0(v2);
if ( !result )
{
cst_errmsg("CST_REALLOC failed for %d bytes\n", v2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return result;
}

original_code:
void *cst_safe_realloc(void *p,int size)
{
    void *np=0;
    if (size == 0)
 size++;
    if (p == ((void *)0))
 np = cst_safe_alloc(size);
    else
 np = realloc(p,size);
    if (np == ((void *)0))
    {
 cst_errmsg("CST_REALLOC failed for %d bytes\n",size);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    return np;
}

canonical_original_code:
void *cst_safe_realloc(void *p, int size)
{
    void *np = 0;
    if (size == 0)
 size++;
    if (p == ((void *)0))
 np = cst_safe_alloc(size);
    else
 np = realloc(p,size);
    if (np == ((void *)0))
    {
 cst_errmsg("CST_REALLOC failed for %d bytes\n",size);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    return np;
}

variable_types:
np
void *


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

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

original_code:
void cst_free(void *p)
{
    if (p != ((void *)0))
    {
 free(p);
    }
}


decompiled_code:
__int64 __fastcall val_lpcres(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_lpcres )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "lpcres");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_lpcres )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "lpcres");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

original_code: cst_lpcres *val_lpcres(const cst_val *v) { if (v && ((v)->c.a.type) == cst_val_type_lpcres) return (cst_lpcres *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "lpcres", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

canonical_original_code: struct cst_lpcres_struct *val_lpcres(struct cst_val_struct *v) { if (v && ((v)->c.a.type) == cst_val_type_lpcres) return (struct cst_lpcres_struct *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "lpcres", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

variable_types: struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *

return_type: struct cst_lpcres_struct { unsigned short **frames; int *times; int num_frames; int num_channels; float lpc_min; float lpc_range; float post_emphasis; int num_samples; int sample_rate; int residual_fold; int *sizes; unsigned char *residual; } *


decompiled_code:
__int64 __fastcall lpcres_val(__int64 a1)
{
return val_new_typed(cst_val_type_lpcres, a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return val_new_typed(cst_val_type_lpcres, a1);
}

original_code: cst_val *lpcres_val(const cst_lpcres *v) { return val_new_typed(cst_val_type_lpcres, (void *)v); }

canonical_original_code: struct cst_val_struct *lpcres_val(struct cst_lpcres_struct *v) { return val_new_typed(cst_val_type_lpcres, (void *)v); }

variable_types: struct cst_lpcres_struct { unsigned short **frames; int *times; int num_frames; int num_channels; float lpc_min; float lpc_range; float post_emphasis; int num_samples; int sample_rate; int residual_fold; int *sizes; unsigned char *residual; } *


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

result = cst_safe_alloc(64LL);
*(_DWORD *)(result + 44) = 1;
return result;
}

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

result = cst_safe_alloc(64LL);
*(_DWORD *)(result + 44) = 1;
return result;
}

original_code:
cst_lpcres *new_lpcres()
{
    cst_lpcres *l = ((struct cst_lpcres_struct *)cst_safe_alloc(sizeof(struct cst_lpcres_struct)*(1)));
    l->residual_fold = 1;
    return l;
}

canonical_original_code:
struct cst_lpcres_struct *new_lpcres()
{
    struct cst_lpcres_struct *l = ((struct cst_lpcres_struct *)cst_safe_alloc(sizeof(struct cst_lpcres_struct)*(1)));
    l->residual_fold = 1;
    return l;
}


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

if ( a1 )
{
cst_free(a1[1]);
cst_free(*a1);
cst_free(a1[7]);
cst_free(a1[6]);
result = cst_free(a1);
}
return result;
}

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

if ( a1 )
{
cst_free(a1[1]);
cst_free(*a1);
cst_free(a1[7]);
cst_free(a1[6]);
result = cst_free(a1);
}
return result;
}

original_code:
void delete_lpcres(cst_lpcres *l)
{
    if (l)
    {
 cst_free(l->times);
 cst_free((unsigned short **)l->frames);
 cst_free(l->residual);
 cst_free(l->sizes);
 cst_free(l);
    }
    return;
}

canonical_original_code:
void delete_lpcres(struct cst_lpcres_struct *l)
{
    if (l)
    {
 cst_free(l->times);
 cst_free((unsigned short **)l->frames);
 cst_free(l->residual);
 cst_free(l->sizes);
 cst_free(l);
    }
    return;
}


decompiled_code:
// attributes: thunk
__int64 __fastcall val_delete_lpcres(_QWORD *a1)
{
return delete_lpcres(a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
return func3(a1);
}

original_code: void val_delete_lpcres(void *v) { delete_lpcres((cst_lpcres *)v); }

canonical_original_code: void val_delete_lpcres(void *v) { delete_lpcres((struct cst_lpcres_struct *)v); }

variable_types:
v
void *


decompiled_code:
float __fastcall lpcres_frame_shift(__int64 a1, int a2)
{
int *v2; // rax
float result; // xmm0_4

v2 = *(int **)(a1 + 8);
if ( a2 )
result = (float)v2[a2] - (float)v2[a2 - 1];
else
result = (float)*v2;
return result;
}

canonical_decompiled_code:
float __fastcall func5(__int64 a1, int a2)
{
int *v2; // rax
float result; // xmm0_4

v2 = *(int **)(a1 + 8);
if ( a2 )
result = (float)v2[a2] - (float)v2[a2 - 1];
else
result = (float)*v2;
return result;
}

original_code:
float lpcres_frame_shift(cst_lpcres *t, int frame)
{
    if (frame == 0)
 return (float) t->times[frame];
    else
 return (float) t->times[frame]-t->times[frame-1];
}

canonical_original_code:
float lpcres_frame_shift(struct cst_lpcres_struct *t, int frame)
{
    if (frame == 0)
 return (float) t->times[frame];
    else
 return (float) t->times[frame]-t->times[frame-1];
}

variable_types: frame int


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

*(_QWORD *)(a1 + 8) = cst_safe_alloc((unsigned int)(4 * a2));
*(_QWORD *)a1 = cst_safe_alloc((unsigned int)(8 * a2));
result = cst_safe_alloc((unsigned int)(4 * a2));
*(_DWORD *)(a1 + 16) = a2;
*(_QWORD *)(a1 + 48) = result;
return result;
}

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

*(_QWORD *)(a1 + 8) = cst_safe_alloc((unsigned int)(4 * a2));
*(_QWORD *)a1 = cst_safe_alloc((unsigned int)(8 * a2));
result = cst_safe_alloc((unsigned int)(4 * a2));
*(_DWORD *)(a1 + 16) = a2;
*(_QWORD *)(a1 + 48) = result;
return result;
}

original_code:
void lpcres_resize_frames(cst_lpcres *l,int num_frames)
{
    l->times = ((int *)cst_safe_alloc(sizeof(int)*(num_frames)));
    l->frames = ((const unsigned short* *)cst_safe_alloc(sizeof(const unsigned short*)*(num_frames)));
    l->sizes = ((int *)cst_safe_alloc(sizeof(int)*(num_frames)));
    l->num_frames = num_frames;
}

canonical_original_code:
void lpcres_resize_frames(struct cst_lpcres_struct *l, int num_frames)
{
    l->times = ((int *)cst_safe_alloc(sizeof(int)*(num_frames)));
    l->frames = ((unsigned short **)cst_safe_alloc(sizeof(unsigned short *)*(num_frames)));
    l->sizes = ((int *)cst_safe_alloc(sizeof(int)*(num_frames)));
    l->num_frames = num_frames;
}


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

v2 = (void *)cst_safe_alloc(a2);
*(_QWORD *)(a1 + 56) = v2;
result = memset(v2, 255, (int)a2);
*(_DWORD *)(a1 + 36) = a2;
return result;
}

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

v2 = (void *)cst_safe_alloc(a2);
*(_QWORD *)(a1 + 56) = v2;
result = memset(v2, 255, (int)a2);
*(_DWORD *)(a1 + 36) = a2;
return result;
}

original_code:
void lpcres_resize_samples(cst_lpcres *l,int num_samples)
{
    l->residual = ((unsigned char *)cst_safe_alloc(sizeof(unsigned char)*(num_samples)));
    memset(l->residual,255,num_samples);
    l->num_samples = num_samples;
}

canonical_original_code:
void lpcres_resize_samples(struct cst_lpcres_struct *l, int num_samples)
{
    l->residual = ((unsigned char *)cst_safe_alloc(sizeof(unsigned char)*(num_samples)));
    memset(l->residual,255,num_samples);
    l->num_samples = num_samples;
}


decompiled_code:
__int64 __fastcall feat_find_featpair(__int64 *a1, const char *a2)
{
__int64 i; // r12

if ( !a1 )
return 0LL;
for ( i = *a1; i; i = *(_QWORD *)(i + 16) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, const char *a2)
{
__int64 i; // r12

if ( !a1 )
return 0LL;
for ( i = *a1; i; i = *(_QWORD *)(i + 16) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

original_code:
static cst_featvalpair *feat_find_featpair(const cst_features *f,
        const char *name)
{
    cst_featvalpair *n;
    if (f == ((void *)0))
 return ((void *)0);
    else
    {
 for (n=f->head; n; n=n->next)
     if ((strcmp(name,n->name) == 0))
  return n;
 return ((void *)0);
    }
}

canonical_original_code:
static struct cst_featvalpair_struct *feat_find_featpair(struct cst_features_struct *f, char *name)
{
    struct cst_featvalpair_struct *n;
    if (f == ((void *)0))
 return ((void *)0);
    else
    {
 for (n=f->head; n; n=n->next)
     if ((strcmp(name,n->name) == 0))
  return n;
 return ((void *)0);
    }
}

variable_types: struct cst_features_struct { struct cst_featvalpair_struct *head; void *ctx; } *

variable_types:
name
char *

variable_types: struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *


decompiled_code:
__int64 __fastcall val_features(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_features )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "features");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_features )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "features");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

original_code: cst_features *val_features(const cst_val *v) { if (v && ((v)->c.a.type) == cst_val_type_features) return (cst_features *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "features", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

canonical_original_code: struct cst_features_struct *val_features(struct cst_val_struct *v) { if (v && ((v)->c.a.type) == cst_val_type_features) return (struct cst_features_struct *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "features", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

variable_types:
v
struct cst_val_struct *

return_type: struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *


decompiled_code:
__int64 __fastcall features_val(__int64 a1)
{
return val_new_typed(cst_val_type_features, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return val_new_typed(cst_val_type_features, a1);
}

original_code: cst_val *features_val(const cst_features *v) { return val_new_typed(cst_val_type_features, (void *)v); }

canonical_original_code: struct cst_val_struct *features_val(struct cst_features_struct *v) { return val_new_typed(cst_val_type_features, (void *)v); }

variable_types: struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *


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

result = (_QWORD *)cst_safe_alloc(16LL);
*result = 0LL;
result[1] = 0LL;
return result;
}

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

result = (_QWORD *)cst_safe_alloc(16LL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
cst_features *new_features(void)
{
    cst_features *f;
    f = ((cst_features *)cst_safe_alloc(sizeof(cst_features)*(1)));
    f->head = ((void *)0);
    f->ctx = ((void *)0);
    return f;
}

canonical_original_code:
struct cst_features_struct *new_features()
{
    struct cst_features_struct *f;
    f = ((struct cst_features_struct *)cst_safe_alloc(sizeof(cst_features)*(1)));
    f->head = ((void *)0);
    f->ctx = ((void *)0);
    return f;
}

variable_types: struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *


decompiled_code:
__int64 __fastcall delete_features(__int64 *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 16);
delete_val(*(_QWORD *)(v2 + 8));
cst_free(v2);
}
result = cst_free(a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 *a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 16);
delete_val(*(_QWORD *)(v2 + 8));
cst_free(v2);
}
result = cst_free(a1);
}
return result;
}

original_code:
void delete_features(cst_features *f)
{
    cst_featvalpair *n, *np;
    if (f)
    {
 for (n=f->head; n; n=np)
 {
     np = n->next;
     delete_val(n->val);
     cst_free(n);
 }
 cst_free(f);
    }
}

canonical_original_code:
void delete_features(struct cst_features_struct *f)
{
    struct cst_featvalpair_struct *n; struct cst_featvalpair_struct *np;
    if (f)
    {
 for (n=f->head; n; n=np)
 {
     np = n->next;
     delete_val(n->val);
     cst_free(n);
 }
 cst_free(f);
    }
}


decompiled_code:
// attributes: thunk
__int64 __fastcall val_delete_features(__int64 *a1)
{
return delete_features(a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 *a1)
{
return func4(a1);
}

original_code: void val_delete_features(void *v) { delete_features((cst_features *)v); }

canonical_original_code: void val_delete_features(void *v) { delete_features((struct cst_features_struct *)v); }


decompiled_code:
_BOOL8 __fastcall feat_present(__int64 *a1, const char *a2)
{
return feat_find_featpair(a1, a2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 *a1, const char *a2)
{
return func0(a1, a2) != 0;
}

original_code:
int feat_present(const cst_features *f, const char *name)
{
    return (feat_find_featpair(f,name) != ((void *)0));
}

canonical_original_code:
int feat_present(struct cst_features_struct *f, char *name)
{
    return (feat_find_featpair(f,name) != ((void *)0));
}


decompiled_code:
__int64 __fastcall feat_length(__int64 *a1)
{
unsigned int v1; // er8
__int64 i; // rax

v1 = 0;
if ( a1 )
{
for ( i = *a1; i; ++v1 )
i = *(_QWORD *)(i + 16);
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 *a1)
{
unsigned int v1; // er8
__int64 i; // rax

v1 = 0;
if ( a1 )
{
for ( i = *a1; i; ++v1 )
i = *(_QWORD *)(i + 16);
}
return v1;
}

original_code:
int feat_length(const cst_features *f)
{
    int i=0;
    cst_featvalpair *p;
    if (f)
 for (i=0,p=f->head; p; p=p->next)
     i++;
    return i;
}

canonical_original_code:
int feat_length(struct cst_features_struct *f)
{
    int i = 0;
    struct cst_featvalpair_struct *p;
    if (f)
 for (i=0,p=f->head; p; p=p->next)
     i++;
    return i;
}

variable_types: i int


decompiled_code:
__int64 __fastcall feat_remove(__int64 *a1, const char *a2)
{
__int64 v2; // r14
__int64 i; // rbp
__int64 v4; // rbx

if ( !a1 )
return 0LL;
v2 = 0LL;
for ( i = *a1; ; i = v4 )
{
if ( !i )
return 0LL;
v4 = *(_QWORD *)(i + 16);
if ( !strcmp(a2, *(const char **)i) )
break;
v2 = i;
}
if ( v2 )
*(_QWORD *)(v2 + 16) = v4;
else
*a1 = v4;
delete_val(*(_QWORD *)(i + 8));
cst_free(i);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 *a1, const char *a2)
{
__int64 v2; // r14
__int64 i; // rbp
__int64 v4; // rbx

if ( !a1 )
return 0LL;
v2 = 0LL;
for ( i = *a1; ; i = v4 )
{
if ( !i )
return 0LL;
v4 = *(_QWORD *)(i + 16);
if ( !strcmp(a2, *(const char **)i) )
break;
v2 = i;
}
if ( v2 )
*(_QWORD *)(v2 + 16) = v4;
else
*a1 = v4;
delete_val(*(_QWORD *)(i + 8));
cst_free(i);
return 1LL;
}

original_code:
int feat_remove(cst_features *f, const char *name)
{
    cst_featvalpair *n,*p,*np;
    if (f == ((void *)0))
 return FALSE;
    else
    {
 for (p=((void *)0),n=f->head; n; p=n,n=np)
 {
     np = n->next;
     if ((strcmp(name,n->name) == 0))
     {
  if (p == 0)
      f->head = np;
  else
      p->next = np;
  delete_val(n->val);
  cst_free(n);
  return TRUE;
     }
 }
 return FALSE;
    }
}

canonical_original_code:
int feat_remove(struct cst_features_struct *f, char *name)
{
    struct cst_featvalpair_struct *n; struct cst_featvalpair_struct *p; struct cst_featvalpair_struct *np;
    if (f == ((void *)0))
 return FALSE;
    else
    {
 for (p=((void *)0),n=f->head; n; p=n,n=np)
 {
     np = n->next;
     if ((strcmp(name,n->name) == 0))
     {
  if (p == 0)
      f->head = np;
  else
      p->next = np;
  delete_val(n->val);
  cst_free(n);
  return TRUE;
     }
 }
 return FALSE;
    }
}


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

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

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

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

original_code:
const cst_val *feat_val(const cst_features *f, const char *name)
{
    cst_featvalpair *n;
    n = feat_find_featpair(f,name);
    if (n == ((void *)0))
 return ((void *)0);
    else
 return n->val;
}

canonical_original_code:
struct cst_val_struct *feat_val(struct cst_features_struct *f, char *name)
{
    struct cst_featvalpair_struct *n;
    n = feat_find_featpair(f,name);
    if (n == ((void *)0))
 return ((void *)0);
    else
 return n->val;
}


decompiled_code:
__int64 __fastcall feat_int(__int64 *a1, const char *a2)
{
__int64 v2; // rax

v2 = feat_val(a1, a2);
return val_int(v2);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 *a1, const char *a2)
{
__int64 v2; // rax

v2 = func9(a1, a2);
return val_int(v2);
}

original_code:
int feat_int(const cst_features *f, const char *name)
{
    return val_int(feat_val(f,name));
}

canonical_original_code:
int feat_int(struct cst_features_struct *f, char *name)
{
    return val_int(feat_val(f,name));
}


decompiled_code:
__int64 __fastcall feat_float(__int64 *a1, const char *a2)
{
__int64 v2; // rax

v2 = feat_val(a1, a2);
return val_float(v2);
}

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

v2 = func9(a1, a2);
return val_float(v2);
}

original_code:
float feat_float(const cst_features *f, const char *name)
{
    return val_float(feat_val(f,name));
}

canonical_original_code:
float feat_float(struct cst_features_struct *f, char *name)
{
    return val_float(feat_val(f,name));
}


decompiled_code:
__int64 __fastcall feat_string(__int64 *a1, const char *a2)
{
__int64 v2; // rax

v2 = feat_val(a1, a2);
return val_string(v2);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 *a1, const char *a2)
{
__int64 v2; // rax

v2 = func9(a1, a2);
return val_string(v2);
}

original_code:
const char *feat_string(const cst_features *f, const char *name)
{
    return val_string(feat_val(f,name));
}

canonical_original_code:
char *feat_string(struct cst_features_struct *f, char *name)
{
    return val_string(feat_val(f,name));
}


decompiled_code:
__int64 __fastcall get_param_int(__int64 *a1, const char *a2, unsigned int a3)
{
__int64 v5; // rax

if ( !feat_present(a1, a2) )
return a3;
v5 = feat_val(a1, a2);
return val_int(v5);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 *a1, const char *a2, unsigned int a3)
{
__int64 v5; // rax

if ( !func6(a1, a2) )
return a3;
v5 = func9(a1, a2);
return val_int(v5);
}

original_code:
int get_param_int(const cst_features *f, const char *name,int def)
{
    if (feat_present(f,name))
 return val_int(feat_val(f,name));
    else
 return def;
}

canonical_original_code:
int get_param_int(struct cst_features_struct *f, char *name, int def)
{
    if (feat_present(f,name))
 return val_int(feat_val(f,name));
    else
 return def;
}

variable_types: def int


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

result = feat_present(a1, a2);
if ( (_DWORD)result )
{
v3 = feat_val(a1, a2);
result = val_float(v3);
}
return result;
}

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

result = func6(a1, a2);
if ( (_DWORD)result )
{
v3 = func9(a1, a2);
result = val_float(v3);
}
return result;
}

original_code:
float get_param_float(const cst_features *f, const char *name, float def)
{
    if (feat_present(f,name))
 return val_float(feat_val(f,name));
    else
 return def;
}

canonical_original_code:
float get_param_float(struct cst_features_struct *f, char *name, float def)
{
    if (feat_present(f,name))
 return val_float(feat_val(f,name));
    else
 return def;
}

variable_types: def float


decompiled_code:
__int64 __fastcall get_param_string(__int64 *a1, const char *a2, __int64 a3)
{
__int64 v5; // rax

if ( !feat_present(a1, a2) )
return a3;
v5 = feat_val(a1, a2);
return val_string(v5);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 *a1, const char *a2, __int64 a3)
{
__int64 v5; // rax

if ( !func6(a1, a2) )
return a3;
v5 = func9(a1, a2);
return val_string(v5);
}

original_code:
const char *get_param_string(const cst_features *f, const char *name, const char *def)
{
    if (feat_present(f,name))
 return val_string(feat_val(f,name));
    else
 return def;
}

canonical_original_code:
char *get_param_string(struct cst_features_struct *f, char *name, char *def)
{
    if (feat_present(f,name))
 return val_string(feat_val(f,name));
    else
 return def;
}

variable_types:
def
char *


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

if ( feat_present(a1, a2) )
result = feat_val(a1, a2);
else
result = a3;
return result;
}

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

if ( func6(a1, a2) )
result = func9(a1, a2);
else
result = a3;
return result;
}

original_code:
const cst_val *get_param_val(const cst_features *f, const char *name, cst_val *def)
{
    if (feat_present(f,name))
 return feat_val(f,name);
    else
 return def;
}

canonical_original_code:
struct cst_val_struct *get_param_val(struct cst_features_struct *f, char *name, struct cst_val_struct *def)
{
    if (feat_present(f,name))
 return feat_val(f,name);
    else
 return def;
}

variable_types:
def
struct cst_val_struct *


decompiled_code:
__int64 __fastcall feat_set(__int64 *a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
__int64 result; // rax
const char **v7; // rbx
__int64 v8; // rax

v4 = feat_find_featpair(a1, a2);
if ( !a3 )
return cst_errmsg("cst_val: trying to set a NULL val for feature \"%s\"\n", a2);
v5 = v4;
if ( v4 )
{
delete_val(*(_QWORD *)(v4 + 8));
result = val_inc_refcount(a3);
*(_QWORD *)(v5 + 8) = result;
}
else
{
v7 = (const char **)cst_safe_alloc(24LL);
v8 = *a1;
*v7 = a2;
v7[2] = (const char *)v8;
result = val_inc_refcount(a3);
v7[1] = (const char *)result;
*a1 = (__int64)v7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 *a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
__int64 result; // rax
const char **v7; // rbx
__int64 v8; // rax

v4 = func0(a1, a2);
if ( !a3 )
return cst_errmsg("cst_val: trying to set a NULL val for feature \"%s\"\n", a2);
v5 = v4;
if ( v4 )
{
delete_val(*(_QWORD *)(v4 + 8));
result = val_inc_refcount(a3);
*(_QWORD *)(v5 + 8) = result;
}
else
{
v7 = (const char **)cst_safe_alloc(24LL);
v8 = *a1;
*v7 = a2;
v7[2] = (const char *)v8;
result = val_inc_refcount(a3);
v7[1] = (const char *)result;
*a1 = (__int64)v7;
}
return result;
}

original_code:
void feat_set(cst_features *f, const char* name, const cst_val *val)
{
    cst_featvalpair *n;
    n = feat_find_featpair(f,name);
    if (val == ((void *)0))
    {
 cst_errmsg("cst_val: trying to set a NULL val for feature \"%s\"\n",
     name);
    }
    else if (n == ((void *)0))
    {
 cst_featvalpair *p;
 p = cst_safe_alloc(sizeof(*p));
 p->next = f->head;
 p->name = name;
 p->val = val_inc_refcount(val);
 f->head = p;
    }
    else
    {
 delete_val(n->val);
 n->val = val_inc_refcount(val);
    }
}

canonical_original_code:
void feat_set(struct cst_features_struct *f, char *name, struct cst_val_struct *val)
{
    struct cst_featvalpair_struct *n;
    n = feat_find_featpair(f,name);
    if (val == ((void *)0))
    {
 cst_errmsg("cst_val: trying to set a NULL val for feature \"%s\"\n",
     name);
    }
    else if (n == ((void *)0))
    {
 struct cst_featvalpair_struct *p;
 p = cst_safe_alloc(sizeof(*p));
 p->next = f->head;
 p->name = name;
 p->val = val_inc_refcount(val);
 f->head = p;
    }
    else
    {
 delete_val(n->val);
 n->val = val_inc_refcount(val);
    }
}

variable_types:
val
struct cst_val_struct *


decompiled_code:
__int64 __fastcall feat_set_int(__int64 *a1, const char *a2, unsigned int a3)
{
__int64 v3; // rax

v3 = int_val(a3);
return feat_set(a1, a2, v3);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 *a1, const char *a2, unsigned int a3)
{
__int64 v3; // rax

v3 = int_val(a3);
return func17(a1, a2, v3);
}

original_code:
void feat_set_int(cst_features *f, const char *name, int v)
{
    feat_set(f,name,int_val(v));
}

canonical_original_code:
void feat_set_int(struct cst_features_struct *f, char *name, int v)
{
    feat_set(f,name,int_val(v));
}

variable_types: v int


decompiled_code:
__int64 __fastcall feat_set_float(__int64 *a1, const char *a2)
{
__int64 v2; // rax

v2 = float_val();
return feat_set(a1, a2, v2);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 *a1, const char *a2)
{
__int64 v2; // rax

v2 = float_val();
return func17(a1, a2, v2);
}

original_code:
void feat_set_float(cst_features *f, const char *name, float v)
{
    feat_set(f,name,float_val(v));
}

canonical_original_code:
void feat_set_float(struct cst_features_struct *f, char *name, float v)
{
    feat_set(f,name,float_val(v));
}

variable_types: v float


decompiled_code:
__int64 __fastcall feat_set_string(__int64 *a1, const char *a2, __int64 a3)
{
__int64 v3; // rax

v3 = string_val(a3);
return feat_set(a1, a2, v3);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 *a1, const char *a2, __int64 a3)
{
__int64 v3; // rax

v3 = string_val(a3);
return func17(a1, a2, v3);
}

original_code:
void feat_set_string(cst_features *f, const char *name, const char *v)
{
    feat_set(f,name,string_val(v));
}

canonical_original_code:
void feat_set_string(struct cst_features_struct *f, char *name, char *v)
{
    feat_set(f,name,string_val(v));
}

variable_types:
v
char *


decompiled_code:
__int64 __fastcall feat_copy_into(__int64 *a1, __int64 *a2)
{
__int64 v2; // rbx
unsigned int v3; // er12

v2 = *a1;
if ( !*a1 )
return 0LL;
v3 = 0;
do
{
++v3;
feat_set(a2, *(const char **)v2, *(_QWORD *)(v2 + 8));
v2 = *(_QWORD *)(v2 + 16);
}
while ( v2 );
return v3;
}

original_code:
int feat_copy_into(const cst_features *from,cst_features *to)
{
    cst_featvalpair *p;
    int i;
    for (i=0,p=from->head; p; p=p->next,i++)
 feat_set(to,p->name,p->val);
    return i;
}

canonical_original_code:
int feat_copy_into(struct cst_features_struct *from, struct cst_features_struct *to)
{
    struct cst_featvalpair_struct *p;
    int i;
    for (i=0,p=from->head; p; p=p->next,i++)
 feat_set(to,p->name,p->val);
    return i;
}

variable_types:
to
struct cst_features_struct *


decompiled_code:
__int64 __fastcall val_ffunc(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_ffunc )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "ffunc");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_ffunc )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "ffunc");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

original_code: cst_ffunction val_ffunc(const cst_val *v) { if (v && ((v)->c.a.type) == cst_val_type_ffunc) return (cst_ffunction)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "ffunc", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

canonical_original_code: struct cst_val_struct *(*val_ffunc(struct cst_val_struct *v))(struct cst_item_struct *i) { if (v && ((v)->c.a.type) == cst_val_type_ffunc) return (cst_ffunction)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "ffunc", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

return_type: struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *(*)(struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; } *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *i)

user_defined_types: struct cst_item_contents_struct { struct cst_features_struct *features; struct cst_features_struct *relations; }


decompiled_code:
__int64 __fastcall ffunc_val(__int64 a1)
{
return val_new_typed(cst_val_type_ffunc, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return val_new_typed(cst_val_type_ffunc, a1);
}

original_code: cst_val *ffunc_val(const cst_ffunction v) { return val_new_typed(cst_val_type_ffunc, (void *)v); }

canonical_original_code: struct cst_val_struct *ffunc_val(struct cst_val_struct *(*v)(struct cst_item_struct *i)) { return val_new_typed(cst_val_type_ffunc, (void *)v); }

variable_types: struct cst_val_struct *(*)(struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; } *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *i)


decompiled_code:
void *__fastcall path_to_item(void *a1, __int64 a2)
{
return internal_ff(a1, a2, 1);
}

canonical_decompiled_code:
void *__fastcall func3(void *a1, __int64 a2)
{
return func1(a1, a2, 1);
}

original_code:
cst_item* path_to_item(const cst_item *item,const char *featpath)
{
    return (cst_item *)internal_ff(item,featpath,1);
}

canonical_original_code:
struct cst_item_struct *path_to_item(struct cst_item_struct *item, char *featpath)
{
    return (struct cst_item_struct *)internal_ff(item,featpath,1);
}

variable_types:
item
struct cst_item_struct *

variable_types:
featpath
char *

return_type: struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; } *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *


ffeature

decompiled_code:
void *__fastcall ffeature(void *a1, __int64 a2)
{
return internal_ff(a1, a2, 0);
}

canonical_decompiled_code:
void *__fastcall func4(void *a1, __int64 a2)
{
return func1(a1, a2, 0);
}

original_code:
const cst_val *ffeature(const cst_item *item,const char *featpath)
{
    return (cst_val *)internal_ff(item,featpath,0);
}

canonical_original_code:
struct cst_val_struct *ffeature(struct cst_item_struct *item, char *featpath)
{
    return (struct cst_val_struct *)internal_ff(item,featpath,0);
}

variable_types: struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; } *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *


decompiled_code:
__int64 __fastcall ffeature_string(void *a1, __int64 a2)
{
void *v2; // rax

v2 = ffeature(a1, a2);
return val_string(v2);
}

canonical_decompiled_code:
__int64 __fastcall func5(void *a1, __int64 a2)
{
void *v2; // rax

v2 = func4(a1, a2);
return val_string(v2);
}

original_code:
const char *ffeature_string(const cst_item *item,const char *featpath)
{
    return val_string(ffeature(item,featpath));
}

canonical_original_code:
char *ffeature_string(struct cst_item_struct *item, char *featpath)
{
    return val_string(ffeature(item,featpath));
}

variable_types: struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; } *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *


decompiled_code:
__int64 __fastcall ffeature_int(void *a1, __int64 a2)
{
void *v2; // rax

v2 = ffeature(a1, a2);
return val_int(v2);
}

canonical_decompiled_code:
__int64 __fastcall func6(void *a1, __int64 a2)
{
void *v2; // rax

v2 = func4(a1, a2);
return val_int(v2);
}

original_code:
int ffeature_int(const cst_item *item,const char *featpath)
{
    return val_int(ffeature(item,featpath));
}

canonical_original_code:
int ffeature_int(struct cst_item_struct *item, char *featpath)
{
    return val_int(ffeature(item,featpath));
}


decompiled_code:
__int64 __fastcall ffeature_float(void *a1, __int64 a2)
{
void *v2; // rax

v2 = ffeature(a1, a2);
return val_float(v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(void *a1, __int64 a2)
{
void *v2; // rax

v2 = func4(a1, a2);
return val_float(v2);
}

original_code:
float ffeature_float(const cst_item *item,const char *featpath)
{
    return val_float(ffeature(item,featpath));
}

canonical_original_code:
float ffeature_float(struct cst_item_struct *item, char *featpath)
{
    return val_float(ffeature(item,featpath));
}


decompiled_code:
__int64 __fastcall ff_register(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax

if ( (unsigned int)feat_present() )
cst_errmsg("warning: ffunction %s redefined\n", a2);
v4 = ffunc_val(a3);
return feat_set(a1, a2, v4);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax

if ( (unsigned int)feat_present() )
cst_errmsg("warning: ffunction %s redefined\n", a2);
v4 = func2(a3);
return feat_set(a1, a2, v4);
}

original_code:
void ff_register(cst_features *ffunctions, const char *name, cst_ffunction f)
{
    if (feat_present(ffunctions, name))
 cst_errmsg("warning: ffunction %s redefined\n", name);
    feat_set(ffunctions, name, ffunc_val(f));
}

canonical_original_code:
void ff_register(struct cst_features_struct *ffunctions, char *name, struct cst_val_struct *(*f)(struct cst_item_struct *i))
{
    if (feat_present(ffunctions, name))
 cst_errmsg("warning: ffunction %s redefined\n", name);
    feat_set(ffunctions, name, ffunc_val(f));
}

variable_types:
name
char *

variable_types: struct cst_val_struct *(*)(struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; } *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *i)


decompiled_code:
// attributes: thunk
__int64 ff_unregister()
{
return feat_remove();
}

canonical_decompiled_code:
__int64 func9()
{
return feat_remove();
}

original_code:
void ff_unregister(cst_features *ffunctions, const char *name)
{
    feat_remove(ffunctions, name);
}

canonical_original_code:
void ff_unregister(struct cst_features_struct *ffunctions, char *name)
{
    feat_remove(ffunctions, name);
}

variable_types: struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *


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

if ( !a1 )
return 0LL;
v1 = feat_val(*a1, "wave");
return val_wave(v1);
}

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

if ( !a1 )
return 0LL;
v1 = feat_val(*a1, "wave");
return val_wave(v1);
}

original_code:
cst_wave *utt_wave(cst_utterance *u)
{
    if (u)
 return val_wave(feat_val(u->features,"wave"));
    else
 return 0;
}

canonical_original_code:
struct cst_wave_struct *utt_wave(struct cst_utterance_struct *u)
{
    if (u)
 return val_wave(feat_val(u->features,"wave"));
    else
 return 0;
}

variable_types: struct cst_utterance_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *

user_defined_types: struct cst_wave_struct { char *type; int sample_rate; int num_samples; int num_channels; short *samples; }


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

v2 = wave_val(a2);
feat_set(*a1, "wave", v2);
return 0LL;
}

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

v2 = wave_val(a2);
feat_set(*a1, "wave", v2);
return 0LL;
}

original_code:
int utt_set_wave(cst_utterance *u, cst_wave *w)
{
    feat_set(u->features,"wave",wave_val(w));
    return 0;
}

canonical_original_code:
int utt_set_wave(struct cst_utterance_struct *u, struct cst_wave_struct *w)
{
    feat_set(u->features,"wave",wave_val(w));
    return 0;
}

variable_types: struct cst_wave_struct { char *type; int sample_rate; int num_samples; int num_channels; short *samples; } *


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

v1 = feat_val(*a1, "input_text");
return val_string(v1);
}

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

v1 = feat_val(*a1, "input_text");
return val_string(v1);
}

original_code:
const char *utt_input_text(cst_utterance *u)
{
    return val_string(feat_val(u->features,"input_text"));
}

canonical_original_code:
char *utt_input_text(struct cst_utterance_struct *u)
{
    return val_string(feat_val(u->features,"input_text"));
}


decompiled_code:
__int64 __fastcall utt_set_input_text(_QWORD *a1, __int64 a2)
{
feat_set_string(*a1, "input_text", a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, __int64 a2)
{
feat_set_string(*a1, "input_text", a2);
return 0LL;
}

original_code:
int utt_set_input_text(cst_utterance *u,const char *text)
{
    feat_set_string(u->features,"input_text",text);
    return 0;
}

canonical_original_code:
int utt_set_input_text(struct cst_utterance_struct *u, char *text)
{
    feat_set_string(u->features,"input_text",text);
    return 0;
}

variable_types:
text
char *


decompiled_code:
__int64 __fastcall val_cart(__int16 *a1)
{
__int64 v1; // rdx

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_3:
cst_errmsg("VAL: tried to access %s in %d type val\n", "cart", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = (unsigned int)*a1;
if ( (_DWORD)v1 != cst_val_type_cart )
goto LABEL_3;
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 *a1)
{
__int64 v1; // rdx

if ( !a1 )
{
v1 = 0xFFFFFFFFLL;
LABEL_3:
cst_errmsg("VAL: tried to access %s in %d type val\n", "cart", v1);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = (unsigned int)*a1;
if ( (_DWORD)v1 != cst_val_type_cart )
goto LABEL_3;
return *((_QWORD *)a1 + 1);
}

original_code: cst_cart *val_cart(const cst_val *v) { if (v && ((v)->c.a.type) == cst_val_type_cart) return (cst_cart *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "cart", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

canonical_original_code: struct cst_cart_struct *val_cart(struct cst_val_struct *v) { if (v && ((v)->c.a.type) == cst_val_type_cart) return (struct cst_cart_struct *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "cart", (v ? ((v)->c.a.type) : -1)); (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1)); } return ((void *)0); }

variable_types:
v
struct cst_val_struct *

return_type: struct cst_cart_struct { struct cst_cart_node_struct { unsigned char feat; unsigned char op; unsigned short no_node; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; } *rule_table; char **feat_table; } *

user_defined_types: struct cst_cart_struct { struct cst_cart_node_struct *rule_table; char **feat_table; }

user_defined_types: struct cst_cart_node_struct { unsigned char feat; unsigned char op; unsigned short no_node; struct cst_val_struct *val; }


decompiled_code:
__int64 __fastcall cart_val(__int64 a1)
{
return val_new_typed(cst_val_type_cart, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return val_new_typed(cst_val_type_cart, a1);
}

original_code: cst_val *cart_val(const cst_cart *v) { return val_new_typed(cst_val_type_cart, (void *)v); }

canonical_original_code: struct cst_val_struct *cart_val(struct cst_cart_struct *v) { return val_new_typed(cst_val_type_cart, (void *)v); }

variable_types: struct cst_cart_struct { struct cst_cart_node_struct { unsigned char feat; unsigned char op; unsigned short no_node; struct cst_val_struct *val; } *rule_table; char **feat_table; } *


decompiled_code:
__int64 delete_cart()
{
return ATKprintf("delete_cart function missing\n");
}

canonical_decompiled_code:
__int64 func3()
{
return ATKprintf("delete_cart function missing\n");
}

original_code:
void delete_cart(cst_cart *cart)
{
    ATKprintf("delete_cart function missing\n");
}

canonical_original_code:
void delete_cart(struct cst_cart_struct *cart)
{
    ATKprintf("delete_cart function missing\n");
}

variable_types: struct cst_cart_struct { struct cst_cart_node_struct { unsigned char feat; unsigned char op; unsigned short no_node; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; } *rule_table; char **feat_table; } *