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

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

original_code: cst_utterance *val_utterance(const cst_val *v) { if (v && ((v)->c.a.type) == cst_val_type_utterance) return (cst_utterance *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "utterance", (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_utterance(struct cst_val_struct *v) { if (v && ((v)->c.a.type) == cst_val_type_utterance) return (struct cst_utterance_struct *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "utterance", (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; } *

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


repo: deardaniel/PizzaTest

decompiled_code:
__int64 val_delete_utterance()
{
return delete_utterance();
}

canonical_decompiled_code:
__int64 func5()
{
return delete_utterance();
}

original_code: void val_delete_utterance(void *v) { delete_utterance((cst_utterance *)v); }

canonical_original_code: void val_delete_utterance(void *v) { delete_utterance((struct cst_utterance_struct *)v); }

variable_types:
v
void *

return_type: void

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; }

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 utterance_val(__int64 a1)
{
return val_new_typed(cst_val_type_utterance, a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return val_new_typed(cst_val_type_utterance, a1);
}

original_code: cst_val *utterance_val(const cst_utterance *v) { return val_new_typed(cst_val_type_utterance, (void *)v); }

canonical_original_code: struct cst_val_struct *utterance_val(struct cst_utterance_struct *v) { return val_new_typed(cst_val_type_utterance, (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; } *

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_itemfunc(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_itemfunc )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "itemfunc");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

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

original_code: cst_itemfunc val_itemfunc(const cst_val *v) { if (v && ((v)->c.a.type) == cst_val_type_itemfunc) return (cst_itemfunc)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "itemfunc", (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_itemfunc(struct cst_val_struct *v))(struct cst_item_struct *i) { if (v && ((v)->c.a.type) == cst_val_type_itemfunc) return (cst_itemfunc)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "itemfunc", (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_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_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; }

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

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; }


decompiled_code:
__int64 __fastcall itemfunc_val(__int64 a1)
{
return val_new_typed(cst_val_type_itemfunc, a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return val_new_typed(cst_val_type_itemfunc, a1);
}

original_code: cst_val *itemfunc_val(const cst_itemfunc v) { return val_new_typed(cst_val_type_itemfunc, (void *)v); }

canonical_original_code: struct cst_val_struct *itemfunc_val(struct cst_val_struct *(*v)(struct cst_item_struct *i)) { return val_new_typed(cst_val_type_itemfunc, (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 item_unref_contents(_QWORD **a1)
{
if ( a1 && *a1 )
{
feat_remove((*a1)[1], *a1[1]);
if ( !(unsigned int)feat_length((*a1)[1]) )
{
delete_features((*a1)[1]);
delete_features(**a1);
cst_free(*a1);
}
*a1 = 0LL;
}
}

canonical_decompiled_code:
void __fastcall func9(_QWORD **a1)
{
if ( a1 && *a1 )
{
feat_remove((*a1)[1], *a1[1]);
if ( !(unsigned int)feat_length((*a1)[1]) )
{
delete_features((*a1)[1]);
delete_features(**a1);
cst_free(*a1);
}
*a1 = 0LL;
}
}

original_code:
void item_unref_contents(cst_item *item)
{
    if (item && item->contents)
    {
 feat_remove(item->contents->relations,item->relation->name);
 if (feat_length(item->contents->relations) == 0)
 {
     delete_features(item->contents->relations);
     delete_features(item->contents->features);
     cst_free((item->contents));
 }
 item->contents = ((void *)0);
    }
}

canonical_original_code:
void item_unref_contents(struct cst_item_struct *item)
{
    if (item && item->contents)
    {
 feat_remove(item->contents->relations,item->relation->name);
 if (feat_length(item->contents->relations) == 0)
 {
     delete_features(item->contents->relations);
     delete_features(item->contents->features);
     cst_free((item->contents));
 }
 item->contents = ((void *)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 { 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; } *


original_code:
void delete_item(cst_item *item)
{
    cst_item *ds, *nds;
    if (item->n != ((void *)0))
    {
 item->n->p = item->p;
 item->n->u = item->u;
    }
    if (item->p != ((void *)0)) item->p->n = item->n;
    if (item->u != ((void *)0)) item->u->d = item->n;
    if (item->relation)
    {
 if (item->relation->head == item)
     item->relation->head = item->n;
 if (item->relation->tail == item)
     item->relation->tail = item->p;
    }
    for (ds = item->d; ds; ds=nds)
    {
 nds = ds->n;
 delete_item(ds);
    }
    item_unref_contents(item);
    cst_free((item));
}

canonical_original_code:
void delete_item(struct cst_item_struct *item)
{
    struct cst_item_struct *ds; struct cst_item_struct *nds;
    if (item->n != ((void *)0))
    {
 item->n->p = item->p;
 item->n->u = item->u;
    }
    if (item->p != ((void *)0)) item->p->n = item->n;
    if (item->u != ((void *)0)) item->u->d = item->n;
    if (item->relation)
    {
 if (item->relation->head == item)
     item->relation->head = item->n;
 if (item->relation->tail == item)
     item->relation->tail = item->p;
    }
    for (ds = item->d; ds; ds=nds)
    {
 nds = ds->n;
 delete_item(ds);
    }
    item_unref_contents(item);
    cst_free((item));
}


decompiled_code:
void __fastcall item_contents_set(_QWORD **a1, _QWORD *a2)
{
_QWORD *v2; // rbp
__int64 v3; // rax
__int16 *v4; // rax
__int64 v5; // rbp
__int64 v6; // rax

if ( a2 )
v2 = (_QWORD *)*a2;
else
v2 = new_item_contents((__int64)a1);
if ( *a1 != v2 )
{
item_unref_contents(a1);
*a1 = v2;
if ( (unsigned int)feat_present(v2[1], *a1[1]) )
{
v4 = (__int16 *)feat_val((*a1)[1], *a1[1]);
v5 = val_item(v4);
v6 = item_val(v5);
feat_set(*(_QWORD *)(*(_QWORD *)v5 + 8LL), *a1[1], v6);
}
v3 = item_val((__int64)a1);
feat_set((*a1)[1], *a1[1], v3);
}
}

original_code:
void item_contents_set(cst_item *current, cst_item *i)
{
    cst_item_contents *c = 0;
    cst_item *nn_item;
    if (i == 0)
 c = new_item_contents(current);
    else
 c = i->contents;
    if (c != current->contents)
    {
 item_unref_contents(current);
 current->contents = c;
 if (feat_present(current->contents->relations,current->relation->name))
 {
     nn_item = val_item(feat_val(current->contents->relations,
     current->relation->name));
     feat_set(nn_item->contents->relations,
       current->relation->name,
       item_val(nn_item));
 }
 feat_set(current->contents->relations,
   current->relation->name,
   item_val(current));
    }
}

canonical_original_code:
void item_contents_set(struct cst_item_struct *current, struct cst_item_struct *i)
{
    struct cst_item_contents_struct *c = 0;
    struct cst_item_struct *nn_item;
    if (i == 0)
 c = new_item_contents(current);
    else
 c = i->contents;
    if (c != current->contents)
    {
 item_unref_contents(current);
 current->contents = c;
 if (feat_present(current->contents->relations,current->relation->name))
 {
     nn_item = val_item(feat_val(current->contents->relations,
     current->relation->name));
     feat_set(nn_item->contents->relations,
       current->relation->name,
       item_val(nn_item));
 }
 feat_set(current->contents->relations,
   current->relation->name,
   item_val(current));
    }
}

variable_types:
i
struct cst_item_struct *

variable_types: 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; } *


decompiled_code:
__int64 __fastcall item_as(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int16 *v4; // rax

if ( !a1 )
return 0LL;
v2 = feat_present(*(_QWORD *)(*(_QWORD *)a1 + 8LL), a2);
result = 0LL;
if ( v2 )
{
v4 = (__int16 *)feat_val(*(_QWORD *)(*(_QWORD *)a1 + 8LL), a2);
result = val_item(v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int16 *v4; // rax

if ( !a1 )
return 0LL;
v2 = feat_present(*(_QWORD *)(*(_QWORD *)a1 + 8LL), a2);
result = 0LL;
if ( v2 )
{
v4 = (__int16 *)feat_val(*(_QWORD *)(*(_QWORD *)a1 + 8LL), a2);
result = func2(v4);
}
return result;
}

original_code:
cst_item *item_as(const cst_item *i,const char *rname)
{
    if (i == ((void *)0))
 return ((void *)0);
    else if (feat_present(i->contents->relations,rname))
 return val_item(feat_val(i->contents->relations,rname));
    else
 return ((void *)0);
}

canonical_original_code:
struct cst_item_struct *item_as(struct cst_item_struct *i, char *rname)
{
    if (i == ((void *)0))
 return ((void *)0);
    else if (feat_present(i->contents->relations,rname))
 return val_item(feat_val(i->contents->relations,rname));
    else
 return ((void *)0);
}

variable_types:
rname
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; } *


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

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

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

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

original_code:
cst_item *item_next(const cst_item *i)
{
    if (i == ((void *)0))
 return ((void *)0);
    else
 return i->n;
}

canonical_original_code:
struct cst_item_struct *item_next(struct cst_item_struct *i)
{
    if (i == ((void *)0))
 return ((void *)0);
    else
 return i->n;
}


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

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

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

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

original_code:
cst_item *item_prev(const cst_item *i)
{
    if (i == ((void *)0))
 return ((void *)0);
    else
 return i->p;
}

canonical_original_code:
struct cst_item_struct *item_prev(struct cst_item_struct *i)
{
    if (i == ((void *)0))
 return ((void *)0);
    else
 return i->p;
}


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

do
{
v1 = a1;
a1 = item_prev(a1);
}
while ( a1 );
if ( v1 )
v1 = *(_QWORD *)(v1 + 32);
return v1;
}

original_code:
cst_item *item_parent(const cst_item *i)
{
    const cst_item *n;
    for (n=i; item_prev(n); n=item_prev(n));
    if (n == ((void *)0))
 return ((void *)0);
    else
 return n->u;
}

canonical_original_code:
struct cst_item_struct *item_parent(struct cst_item_struct *i)
{
    struct cst_item_struct *n;
    for (n=i; item_prev(n); n=item_prev(n));
    if (n == ((void *)0))
 return ((void *)0);
    else
 return n->u;
}


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

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

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

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

original_code:
cst_item *item_daughter(const cst_item *i)
{
    if (i == ((void *)0))
 return ((void *)0);
    else
 return i->d;
}

canonical_original_code:
struct cst_item_struct *item_daughter(struct cst_item_struct *i)
{
    if (i == ((void *)0))
 return ((void *)0);
    else
 return i->d;
}


decompiled_code:
__int64 __fastcall item_nth_daughter(__int64 a1, int a2)
{
__int64 v2; // rdi
int v3; // ebx

v2 = item_daughter(a1);
if ( v2 && a2 > 0 )
{
v3 = 0;
do
{
v2 = item_next(v2);
++v3;
}
while ( v2 && a2 > v3 );
}
return v2;
}

original_code:
cst_item *item_nth_daughter(const cst_item *i,int n)
{
    int d;
    cst_item *p;
    for (d=0,p=item_daughter(i); p && (d < n); p=item_next(p),d++);
    return p;
}

canonical_original_code:
struct cst_item_struct *item_nth_daughter(struct cst_item_struct *i, int n)
{
    int d;
    struct cst_item_struct *p;
    for (d=0,p=item_daughter(i); p && (d < n); p=item_next(p),d++);
    return p;
}

variable_types: n int

variable_types: d int


decompiled_code:
__int64 __fastcall item_last_daughter(__int64 a1)
{
__int64 v1; // rdi
__int64 v2; // rbx

v1 = item_daughter(a1);
do
{
v2 = v1;
v1 = item_next(v1);
}
while ( v1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1)
{
__int64 v1; // rdi
__int64 v2; // rbx

v1 = func18(a1);
do
{
v2 = v1;
v1 = func14(v1);
}
while ( v1 );
return v2;
}

original_code:
cst_item *item_last_daughter(const cst_item *i)
{
    cst_item *p;
    for (p=item_daughter(i); item_next(p); p=item_next(p));
    return p;
}

canonical_original_code:
struct cst_item_struct *item_last_daughter(struct cst_item_struct *i)
{
    struct cst_item_struct *p;
    for (p=item_daughter(i); item_next(p); p=item_next(p));
    return p;
}


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

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

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

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

original_code:
cst_features *item_feats(const cst_item *i)
{
    return (i ? i->contents->features : ((void *)0));
}

canonical_original_code:
struct cst_features_struct *item_feats(struct cst_item_struct *i)
{
    return (i ? i->contents->features : ((void *)0));
}

variable_types: 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; } *

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 item_feat_present(__int64 **a1, __int64 a2)
{
__int64 v2; // rax

v2 = item_feats(a1);
return feat_present(v2, a2);
}

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

v2 = func22(a1);
return feat_present(v2, a2);
}

original_code:
int item_feat_present(const cst_item *i,const char *name)
{
    return feat_present(item_feats(i),name);
}

canonical_original_code:
int item_feat_present(struct cst_item_struct *i, char *name)
{
    return feat_present(item_feats(i),name);
}

variable_types:
name
char *

return_type: int


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

v2 = item_feats(a1);
return feat_remove(v2, a2);
}

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

v2 = func22(a1);
return feat_remove(v2, a2);
}

original_code:
int item_feat_remove(const cst_item *i,const char *name)
{
    return feat_remove(item_feats(i),name);
}

canonical_original_code:
int item_feat_remove(struct cst_item_struct *i, char *name)
{
    return feat_remove(item_feats(i),name);
}


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

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

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

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

original_code:
const cst_val *item_feat(const cst_item *i,const char *name)
{
    return feat_val(item_feats(i),name);
}

canonical_original_code:
struct cst_val_struct *item_feat(struct cst_item_struct *i, char *name)
{
    return feat_val(item_feats(i),name);
}

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 item_feat_int(__int64 **a1, __int64 a2)
{
__int64 v2; // rax

v2 = item_feats(a1);
return feat_int(v2, a2);
}

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

v2 = func22(a1);
return feat_int(v2, a2);
}

original_code:
int item_feat_int(const cst_item *i,const char *name)
{
    return feat_int(item_feats(i),name);
}

canonical_original_code:
int item_feat_int(struct cst_item_struct *i, char *name)
{
    return feat_int(item_feats(i),name);
}


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

v2 = item_feats(a1);
return feat_float(v2, a2);
}

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

v2 = func22(a1);
return feat_float(v2, a2);
}

original_code:
float item_feat_float(const cst_item *i,const char *name)
{
    return feat_float(item_feats(i),name);
}

canonical_original_code:
float item_feat_float(struct cst_item_struct *i, char *name)
{
    return feat_float(item_feats(i),name);
}

return_type: float


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

v2 = item_feats(a1);
return feat_string(v2, a2);
}

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

v2 = func22(a1);
return feat_string(v2, a2);
}

original_code:
const char *item_feat_string(const cst_item *i,const char *name)
{
    return feat_string(item_feats(i),name);
}

canonical_original_code:
char *item_feat_string(struct cst_item_struct *i, char *name)
{
    return feat_string(item_feats(i),name);
}

return_type: char *


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

v4 = item_feats(a1);
return feat_set(v4, a2, a3);
}

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

v4 = func22(a1);
return feat_set(v4, a2, a3);
}

original_code:
void item_set(const cst_item *i,const char *name,const cst_val *val)
{
    feat_set(item_feats(i),name,val);
}

canonical_original_code:
void item_set(struct cst_item_struct *i, char *name, struct cst_val_struct *val)
{
    feat_set(item_feats(i),name,val);
}

variable_types:
val
struct cst_val_struct *


decompiled_code:
__int64 __fastcall item_set_int(__int64 **a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax

v4 = item_feats(a1);
return feat_set_int(v4, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func30(__int64 **a1, __int64 a2, unsigned int a3)
{
__int64 v4; // rax

v4 = func22(a1);
return feat_set_int(v4, a2, a3);
}

original_code:
void item_set_int(const cst_item *i,const char *name,int val)
{
    feat_set_int(item_feats(i),name,val);
}

canonical_original_code:
void item_set_int(struct cst_item_struct *i, char *name, int val)
{
    feat_set_int(item_feats(i),name,val);
}

variable_types: val int


decompiled_code:
__int64 __fastcall item_set_float(__int64 **a1, __int64 a2, float a3)
{
__int64 v3; // rax

v3 = item_feats(a1);
return feat_set_float(v3, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 **a1, __int64 a2, float a3)
{
__int64 v3; // rax

v3 = func22(a1);
return feat_set_float(v3, a2, a3);
}

original_code:
void item_set_float(const cst_item *i,const char *name,float val)
{
    feat_set_float(item_feats(i),name,val);
}

canonical_original_code:
void item_set_float(struct cst_item_struct *i, char *name, float val)
{
    feat_set_float(item_feats(i),name,val);
}

variable_types: val float


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

v4 = item_feats(a1);
return feat_set_string(v4, a2, a3);
}

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

v4 = func22(a1);
return feat_set_string(v4, a2, a3);
}

original_code:
void item_set_string(const cst_item *i,const char *name,const char *val)
{
    feat_set_string(item_feats(i),name,val);
}

canonical_original_code:
void item_set_string(struct cst_item_struct *i, char *name, char *val)
{
    feat_set_string(item_feats(i),name,val);
}

variable_types:
val
char *


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

if ( !a1 )
return 0LL;
result = *(_QWORD *)(a1 + 8);
if ( result )
result = *(_QWORD *)(result + 16);
return result;
}

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

if ( !a1 )
return 0LL;
result = *(_QWORD *)(a1 + 8);
if ( result )
result = *(_QWORD *)(result + 16);
return result;
}

original_code:
cst_utterance *item_utt(const cst_item *i)
{
    if (i && i->relation)
 return i->relation->utterance;
    else
 return ((void *)0);
}

canonical_original_code:
struct cst_utterance_struct *item_utt(struct cst_item_struct *i)
{
    if (i && i->relation)
 return i->relation->utterance;
    else
 return ((void *)0);
}

variable_types: 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 *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:
_BOOL8 __fastcall item_equal(_QWORD *a1, _QWORD *a2)
{
if ( a1 == a2 )
return 1LL;
if ( a1 && a2 )
return *a1 == *a2;
return 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func34(_QWORD *a1, _QWORD *a2)
{
if ( a1 == a2 )
return 1LL;
if ( a1 && a2 )
return *a1 == *a2;
return 0LL;
}

original_code:
int item_equal(const cst_item *a, const cst_item *b)
{
    if ((a == b) ||
 (a && b && (a->contents == b->contents)))
 return TRUE;
    else
 return FALSE;
}

canonical_original_code:
int item_equal(struct cst_item_struct *a, struct cst_item_struct *b)
{
    if ((a == b) ||
 (a && b && (a->contents == b->contents)))
 return TRUE;
    else
 return FALSE;
}

variable_types:
b
struct cst_item_struct *


decompiled_code:
__int64 __fastcall val_track(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_track )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "track");
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_track )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "track");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

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

canonical_original_code: struct cst_track_struct *val_track(struct cst_val_struct *v) { if (v && ((v)->c.a.type) == cst_val_type_track) return (struct cst_track_struct *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "track", (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_track_struct { char *type; int samples_rate; int num_frames; int num_channels; float *times; float **frames; } *


decompiled_code:
__int64 __fastcall track_val(__int64 a1)
{
return val_new_typed(cst_val_type_track, a1);
}

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

original_code: cst_val *track_val(const cst_track *v) { return val_new_typed(cst_val_type_track, (void *)v); }

canonical_original_code: struct cst_val_struct *track_val(struct cst_track_struct *v) { return val_new_typed(cst_val_type_track, (void *)v); }

variable_types: struct cst_track_struct { char *type; int samples_rate; int num_frames; int num_channels; float *times; float **frames; } *


decompiled_code:
__int64 new_track()
{
return cst_safe_alloc(40LL);
}

canonical_decompiled_code:
__int64 func2()
{
return cst_safe_alloc(40LL);
}

original_code:
cst_track *new_track()
{
    cst_track *w = ((struct cst_track_struct *)cst_safe_alloc(sizeof(struct cst_track_struct)*(1)));
    return w;
}

canonical_original_code:
struct cst_track_struct *new_track()
{
    struct cst_track_struct *w = ((struct cst_track_struct *)cst_safe_alloc(sizeof(struct cst_track_struct)*(1)));
    return w;
}

user_defined_types: struct cst_track_struct { char *type; int samples_rate; int num_frames; int num_channels; float *times; float **frames; }


decompiled_code:
__int64 __fastcall delete_track(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 )
{
cst_free(*(_QWORD *)(a1 + 24));
if ( *(int *)(a1 + 12) > 0 )
{
v1 = 0LL;
do
cst_free(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * v1++));
while ( *(_DWORD *)(a1 + 12) > (int)v1 );
}
cst_free(*(_QWORD *)(a1 + 32));
result = cst_free(a1);
}
return result;
}

original_code:
void delete_track(cst_track *w)
{
    int i;
    if (w)
    {
 cst_free(w->times);
 for (i=0; i < w->num_frames; i++)
     cst_free(w->frames[i]);
 cst_free(w->frames);
 cst_free(w);
    }
    return;
}

canonical_original_code:
void delete_track(struct cst_track_struct *w)
{
    int i;
    if (w)
    {
 cst_free(w->times);
 for (i=0; i < w->num_frames; i++)
     cst_free(w->frames[i]);
 cst_free(w->frames);
 cst_free(w);
    }
    return;
}

variable_types: i int


decompiled_code:
__int64 __fastcall val_delete_track(__int64 a1)
{
return delete_track(a1);
}

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

original_code: void val_delete_track(void *v) { delete_track((cst_track *)v); }

canonical_original_code: void val_delete_track(void *v) { delete_track((struct cst_track_struct *)v); }

variable_types:
v
void *


decompiled_code:
float __fastcall track_frame_shift(__int64 a1, int a2)
{
float result; // xmm0_4

if ( a2 )
result = *(float *)(*(_QWORD *)(a1 + 24) + 4LL * a2) - *(float *)(*(_QWORD *)(a1 + 24) + 4LL * a2 - 4);
else
result = **(float **)(a1 + 24);
return result;
}

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

if ( a2 )
result = *(float *)(*(_QWORD *)(a1 + 24) + 4LL * a2) - *(float *)(*(_QWORD *)(a1 + 24) + 4LL * a2 - 4);
else
result = **(float **)(a1 + 24);
return result;
}

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

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

variable_types: frame int


original_code:
void cst_track_resize(cst_track *t,int num_frames, int num_channels)
{
    float *n_times;
    float **n_frames;
    int i;
    n_times = ((float *)cst_safe_alloc(sizeof(float)*(num_frames)));
    memmove(n_times,t->times,
     (sizeof(float)*((num_frames < t->num_frames) ?
       num_frames : t->num_frames)));
    n_frames = ((float* *)cst_safe_alloc(sizeof(float*)*(num_frames)));
    for (i=0; i<num_frames; i++)
    {
 n_frames[i] = ((float *)cst_safe_alloc(sizeof(float)*(num_channels)));
 if (i<t->num_frames)
 {
     memmove(n_frames[i],
      t->frames[i],
      sizeof(float)*((num_channels < t->num_channels) ?
       num_channels : t->num_channels));
     cst_free(t->frames[i]);
 }
    }
    for ( ; i<t->num_frames; i++)
 cst_free(t->frames[i]);
    cst_free(t->frames);
    t->frames = n_frames;
    cst_free(t->times);
    t->times = n_times;
    t->num_frames = num_frames;
    t->num_channels = num_channels;
}

canonical_original_code:
void cst_track_resize(struct cst_track_struct *t, int num_frames, int num_channels)
{
    float *n_times;
    float **n_frames;
    int i;
    n_times = ((float *)cst_safe_alloc(sizeof(float)*(num_frames)));
    memmove(n_times,t->times,
     (sizeof(float)*((num_frames < t->num_frames) ?
       num_frames : t->num_frames)));
    n_frames = ((float **)cst_safe_alloc(sizeof(float *)*(num_frames)));
    for (i=0; i<num_frames; i++)
    {
 n_frames[i] = ((float *)cst_safe_alloc(sizeof(float)*(num_channels)));
 if (i<t->num_frames)
 {
     memmove(n_frames[i],
      t->frames[i],
      sizeof(float)*((num_channels < t->num_channels) ?
       num_channels : t->num_channels));
     cst_free(t->frames[i]);
 }
    }
    for ( ; i<t->num_frames; i++)
 cst_free(t->frames[i]);
    cst_free(t->frames);
    t->frames = n_frames;
    cst_free(t->times);
    t->times = n_times;
    t->num_frames = num_frames;
    t->num_channels = num_channels;
}


original_code:
static cst_lts_phone apply_model(char *vals,cst_lts_addr start,
     const cst_lts_model *model)
{
    cst_lts_rule state;
    short nstate;
    static const int sizeof_cst_lts_rule = 6;
    memmove(&state,&model[start*sizeof_cst_lts_rule],sizeof_cst_lts_rule);
    for ( ;
  state.feat != 255;
 )
    {
 if (vals[state.feat] == state.val)
     nstate = state.qtrue;
 else
     nstate = state.qfalse;
 if ((((char *)&cst_endian_loc)[0] == 0))
     nstate = ((((unsigned)nstate) & 0xff) << 8 | (((unsigned)nstate) & 0xff00) >> 8);
 memmove(&state,&model[nstate*sizeof_cst_lts_rule],sizeof_cst_lts_rule);
    }
    return (cst_lts_phone)state.val;
}

canonical_original_code:
static unsigned char apply_model(char *vals, unsigned short start, unsigned char *model)
{
    struct cst_lts_rule_struct state;
    short nstate;
    static int sizeof_cst_lts_rule = 6;
    memmove(&state,&model[start*sizeof_cst_lts_rule],sizeof_cst_lts_rule);
    for ( ;
  state.feat != 255;
 )
    {
 if (vals[state.feat] == state.val)
     nstate = state.qtrue;
 else
     nstate = state.qfalse;
 if ((((char *)&cst_endian_loc)[0] == 0))
     nstate = ((((unsigned int)nstate) & 0xff) << 8 | (((unsigned int)nstate) & 0xff00) >> 8);
 memmove(&state,&model[nstate*sizeof_cst_lts_rule],sizeof_cst_lts_rule);
    }
    return (unsigned char)state.val;
}

variable_types:
vals
char *

variable_types:
start
unsigned short

variable_types:
model
unsigned char *

variable_types: struct cst_lts_rule_struct { unsigned char feat; char val; unsigned short qtrue; unsigned short qfalse; }

variable_types: nstate short

return_type: unsigned char


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

result = cst_safe_alloc(40LL);
*(_QWORD *)result = 0LL;
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(result + 16) = 0LL;
*(_QWORD *)(result + 24) = 0LL;
*(_DWORD *)(result + 32) = 0;
*(_DWORD *)(result + 36) = 0;
return result;
}

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

result = cst_safe_alloc(40LL);
*(_QWORD *)result = 0LL;
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(result + 16) = 0LL;
*(_QWORD *)(result + 24) = 0LL;
*(_DWORD *)(result + 32) = 0;
*(_DWORD *)(result + 36) = 0;
return result;
}

original_code:
cst_lts_rules *new_lts_rules()
{
    cst_lts_rules *lt = ((cst_lts_rules *)cst_safe_alloc(sizeof(cst_lts_rules)*(1)));
    lt->name = 0;
    lt->letter_index = 0;
    lt->models = 0;
    lt->phone_table = 0;
    lt->context_window_size = 0;
    lt->context_extra_feats = 0;
    return lt;
}

canonical_original_code:
struct cst_lts_rules_struct *new_lts_rules()
{
    struct cst_lts_rules_struct *lt = ((cst_lts_rules *)cst_safe_alloc(sizeof(cst_lts_rules)*(1)));
    lt->name = 0;
    lt->letter_index = 0;
    lt->models = 0;
    lt->phone_table = 0;
    lt->context_window_size = 0;
    lt->context_extra_feats = 0;
    return lt;
}

variable_types: struct cst_lts_rules_struct { char *name; unsigned short *letter_index; unsigned char *models; char **phone_table; int context_window_size; int context_extra_feats; } *


original_code:
cst_val *lts_apply(const char *word,const char *feats,const cst_lts_rules *r)
{
    int pos;
    cst_val *phones=0;
    cst_lts_letter *fval_buff;
    cst_lts_letter *full_buff;
    cst_lts_phone phone;
    char *left, *right, *p;
    fval_buff = ((cst_lts_letter *)cst_safe_alloc(sizeof(cst_lts_letter)*((r->context_window_size*2)+ r->context_extra_feats)));
    full_buff = ((cst_lts_letter *)cst_safe_alloc(sizeof(cst_lts_letter)*((r->context_window_size*2)+ strlen(word)+1)));
    sprintf(full_buff,"%.*s#%s#%.*s",
     r->context_window_size-1, "00000000",
     word,
     r->context_window_size-1, "00000000");
    for (pos = r->context_window_size + strlen(word) - 1;
  full_buff[pos] != '#';
  pos--)
    {
 sprintf(fval_buff,"%.*s%.*s%s",
  r->context_window_size,
  full_buff+pos-r->context_window_size,
  r->context_window_size,
  full_buff+pos+1,
  feats);
 if ((full_buff[pos] < 'a') ||
     (full_buff[pos] > 'z'))
 {
     continue;
 }
 phone = apply_model(fval_buff,
       r->letter_index[((full_buff[pos])-'a')%26],
       r->models);
 if ((strcmp("epsilon",r->phone_table[phone]) == 0))
     continue;
 else if ((p=strchr(r->phone_table[phone],'-')) != ((void *)0))
 {
     left = cst_substr(r->phone_table[phone],0,
         strlen(r->phone_table[phone])-strlen(p));
     right = cst_substr(r->phone_table[phone],
          (strlen(r->phone_table[phone])-strlen(p))+1,
          (strlen(p)-1));
     phones = cons_val(string_val(left),
         cons_val(string_val(right),phones));
     cst_free(left);
     cst_free(right);
 }
 else
     phones = cons_val(string_val(r->phone_table[phone]),phones);
    }
    cst_free(full_buff);
    cst_free(fval_buff);
    return phones;
}

canonical_original_code:
struct cst_val_struct *lts_apply(char *word, char *feats, struct cst_lts_rules_struct *r)
{
    int pos;
    struct cst_val_struct *phones = 0;
    char *fval_buff;
    char *full_buff;
    unsigned char phone;
    char *left; char *right; char *p;
    fval_buff = ((char *)cst_safe_alloc(sizeof(cst_lts_letter)*((r->context_window_size*2)+ r->context_extra_feats)));
    full_buff = ((char *)cst_safe_alloc(sizeof(cst_lts_letter)*((r->context_window_size*2)+ strlen(word)+1)));
    sprintf(full_buff,"%.*s#%s#%.*s",
     r->context_window_size-1, "00000000",
     word,
     r->context_window_size-1, "00000000");
    for (pos = r->context_window_size + strlen(word) - 1;
  full_buff[pos] != '#';
  pos--)
    {
 sprintf(fval_buff,"%.*s%.*s%s",
  r->context_window_size,
  full_buff+pos-r->context_window_size,
  r->context_window_size,
  full_buff+pos+1,
  feats);
 if ((full_buff[pos] < 'a') ||
     (full_buff[pos] > 'z'))
 {
     continue;
 }
 phone = apply_model(fval_buff,
       r->letter_index[((full_buff[pos])-'a')%26],
       r->models);
 if ((strcmp("epsilon",r->phone_table[phone]) == 0))
     continue;
 else if ((p=strchr(r->phone_table[phone],'-')) != ((void *)0))
 {
     left = cst_substr(r->phone_table[phone],0,
         strlen(r->phone_table[phone])-strlen(p));
     right = cst_substr(r->phone_table[phone],
          (strlen(r->phone_table[phone])-strlen(p))+1,
          (strlen(p)-1));
     phones = cons_val(string_val(left),
         cons_val(string_val(right),phones));
     cst_free(left);
     cst_free(right);
 }
 else
     phones = cons_val(string_val(r->phone_table[phone]),phones);
    }
    cst_free(full_buff);
    cst_free(fval_buff);
    return phones;
}

variable_types:
word
char *

variable_types:
feats
char *

variable_types: pos int

variable_types:
phone
unsigned char

variable_types:
left
char *

variable_types:
right
char *

variable_types:
p
char *

user_defined_types: struct cst_lts_rules_struct { char *name; unsigned short *letter_index; unsigned char *models; char **phone_table; int context_window_size; int context_extra_feats; }


decompiled_code:
__int64 __fastcall val_phoneset(__int16 *a1)
{
if ( !a1 || *a1 != cst_val_type_phoneset )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "phoneset");
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_phoneset )
{
cst_errmsg("VAL: tried to access %s in %d type val\n", "phoneset");
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
return *((_QWORD *)a1 + 1);
}

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

canonical_original_code: struct cst_phoneset_struct *val_phoneset(struct cst_val_struct *v) { if (v && ((v)->c.a.type) == cst_val_type_phoneset) return (struct cst_phoneset_struct *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "phoneset", (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_phoneset_struct { char *name; char **featnames; 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; } **featvals; char **phonenames; char *silence; int num_phones; int **fvtable; } *

user_defined_types: struct cst_phoneset_struct { char *name; char **featnames; struct cst_val_struct **featvals; char **phonenames; char *silence; int num_phones; int **fvtable; }


decompiled_code:
__int64 __fastcall phoneset_val(__int64 a1)
{
return val_new_typed(cst_val_type_phoneset, a1);
}

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

original_code: cst_val *phoneset_val(const cst_phoneset *v) { return val_new_typed(cst_val_type_phoneset, (void *)v); }

canonical_original_code: struct cst_val_struct *phoneset_val(struct cst_phoneset_struct *v) { return val_new_typed(cst_val_type_phoneset, (void *)v); }

variable_types: struct cst_phoneset_struct { char *name; char **featnames; struct cst_val_struct **featvals; char **phonenames; char *silence; int num_phones; int **fvtable; } *


decompiled_code:
__int64 new_phoneset()
{
return cst_safe_alloc(56LL);
}

canonical_decompiled_code:
__int64 func2()
{
return cst_safe_alloc(56LL);
}

original_code:
cst_phoneset *new_phoneset()
{
    cst_phoneset *v = ((struct cst_phoneset_struct *)cst_safe_alloc(sizeof(struct cst_phoneset_struct)*(1)));
    return v;
}

canonical_original_code:
struct cst_phoneset_struct *new_phoneset()
{
    struct cst_phoneset_struct *v = ((struct cst_phoneset_struct *)cst_safe_alloc(sizeof(struct cst_phoneset_struct)*(1)));
    return v;
}

variable_types: struct cst_phoneset_struct { char *name; char **featnames; 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; } **featvals; char **phonenames; char *silence; int num_phones; int **fvtable; } *


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

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

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

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

original_code:
void delete_phoneset(cst_phoneset *v)
{
    if (v)
    {
 cst_free(v);
    }
}

canonical_original_code:
void delete_phoneset(struct cst_phoneset_struct *v)
{
    if (v)
    {
 cst_free(v);
    }
}


decompiled_code:
__int64 __fastcall phone_id(__int64 a1, const char *a2)
{
int v2; // ebp
__int64 v3; // r13
__int64 v4; // rbx
unsigned int v5; // er14

v2 = *(_DWORD *)(a1 + 40);
if ( v2 <= 0 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a1 + 24);
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( !strcmp(*(const char **)(v3 + 8 * v4), a2) )
break;
if ( ++v4 == v2 )
return (unsigned int)-1;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2)
{
int v2; // ebp
__int64 v3; // r13
__int64 v4; // rbx
unsigned int v5; // er14

v2 = *(_DWORD *)(a1 + 40);
if ( v2 <= 0 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a1 + 24);
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( !strcmp(*(const char **)(v3 + 8 * v4), a2) )
break;
if ( ++v4 == v2 )
return (unsigned int)-1;
}
return v5;
}

original_code:
int phone_id(const cst_phoneset *ps,const char* phonename)
{
    int i;
    for (i=0; i< ps->num_phones; i++)
 if ((strcmp(ps->phonenames[i],phonename) == 0))
     return i;
    return -1;
}

canonical_original_code:
int phone_id(struct cst_phoneset_struct *ps, char *phonename)
{
    int i;
    for (i=0; i< ps->num_phones; i++)
 if ((strcmp(ps->phonenames[i],phonename) == 0))
     return i;
    return -1;
}

variable_types:
phonename
char *

variable_types: i int


decompiled_code:
__int64 __fastcall phone_feat_id(__int64 a1, const char *a2)
{
const char **v2; // r12
const char *v3; // rdi
__int64 v4; // rbx
unsigned int v5; // er13

v2 = *(const char ***)(a1 + 8);
v3 = *v2;
if ( !*v2 )
return (unsigned int)-1;
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( !strcmp(v3, a2) )
break;
v3 = v2[++v4];
if ( !v3 )
return (unsigned int)-1;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char *a2)
{
const char **v2; // r12
const char *v3; // rdi
__int64 v4; // rbx
unsigned int v5; // er13

v2 = *(const char ***)(a1 + 8);
v3 = *v2;
if ( !*v2 )
return (unsigned int)-1;
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( !strcmp(v3, a2) )
break;
v3 = v2[++v4];
if ( !v3 )
return (unsigned int)-1;
}
return v5;
}

original_code:
int phone_feat_id(const cst_phoneset *ps,const char* featname)
{
    int i;
    for (i=0; ps->featnames[i]; i++)
 if ((strcmp(ps->featnames[i],featname) == 0))
     return i;
    return -1;
}

canonical_original_code:
int phone_feat_id(struct cst_phoneset_struct *ps, char *featname)
{
    int i;
    for (i=0; ps->featnames[i]; i++)
 if ((strcmp(ps->featnames[i],featname) == 0))
     return i;
    return -1;
}

variable_types:
featname
char *


decompiled_code:
__int64 __fastcall phone_feature(__int64 a1, const char *a2, const char *a3)
{
int v4; // ebp

v4 = phone_id(a1, a2);
return *(_QWORD *)(*(_QWORD *)(a1 + 16)
+ 8LL * *(int *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL * v4) + 4LL * (int)phone_feat_id(a1, a3)));
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const char *a2, const char *a3)
{
int v4; // ebp

v4 = func4(a1, a2);
return *(_QWORD *)(*(_QWORD *)(a1 + 16)
+ 8LL * *(int *)(*(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL * v4) + 4LL * (int)func5(a1, a3)));
}

original_code:
const cst_val *phone_feature(const cst_phoneset *ps,
        const char* phonename,
        const char *featname)
{
    return ps->featvals[ps->fvtable[phone_id(ps,phonename)]
                       [phone_feat_id(ps,featname)]];
}

canonical_original_code:
struct cst_val_struct *phone_feature(struct cst_phoneset_struct *ps, char *phonename, char *featname)
{
    return ps->featvals[ps->fvtable[phone_id(ps,phonename)]
                       [phone_feat_id(ps,featname)]];
}


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

v3 = phone_feature(a1, a2, a3);
return val_string(v3);
}

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

v3 = func6(a1, a2, a3);
return val_string(v3);
}

original_code:
const char *phone_feature_string(const cst_phoneset *ps,
     const char* phonename,
     const char *featname)
{
    return val_string(phone_feature(ps,phonename,featname));
}

canonical_original_code:
char *phone_feature_string(struct cst_phoneset_struct *ps, char *phonename, char *featname)
{
    return val_string(phone_feature(ps,phonename,featname));
}


decompiled_code:
__int64 item_phoneset()
{
_QWORD *v0; // rax
__int16 *v1; // rax

v0 = (_QWORD *)item_utt();
v1 = (__int16 *)feat_val(*v0, "phoneset");
return val_phoneset(v1);
}

canonical_decompiled_code:
__int64 func8()
{
_QWORD *v0; // rax
__int16 *v1; // rax

v0 = (_QWORD *)item_utt();
v1 = (__int16 *)feat_val(*v0, "phoneset");
return func0(v1);
}

original_code:
const cst_phoneset *item_phoneset(const cst_item *p)
{
    return val_phoneset(feat_val(item_utt(p)->features,"phoneset"));
}

canonical_original_code:
struct cst_phoneset_struct *item_phoneset(struct cst_item_struct *p)
{
    return val_phoneset(feat_val(item_utt(p)->features,"phoneset"));
}

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:
_BOOL8 __fastcall item_match(__int64 a1, __int64 a2, __int64 a3)
{
const char *v4; // rbp
const char *v5; // rax
int v6; // edx
_BOOL8 result; // rax
const char *v8; // rbp
__int64 v9; // rax
__int64 v10; // rax
const char *v11; // rax
__int64 v12; // rax
__int64 v13; // rbx
__int64 v14; // rax

v4 = (const char *)val_string(a2);
v5 = (const char *)val_string(a1);
v6 = strcmp(v5, v4);
result = 1LL;
if ( v6 )
{
if ( a3 )
{
while ( 1 )
{
v8 = (const char *)val_string(a1);
v9 = val_car(a3);
v10 = val_car(v9);
v11 = (const char *)val_string(v10);
if ( !strcmp(v11, v8) )
break;
a3 = val_cdr(a3);
if ( !a3 )
return 0LL;
}
v12 = val_car(a3);
v13 = val_cdr(v12);
v14 = val_string(a2);
result = (unsigned int)val_member_string(v14, v13) != 0;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
const char *v4; // rbp
const char *v5; // rax
int v6; // edx
_BOOL8 result; // rax
const char *v8; // rbp
__int64 v9; // rax
__int64 v10; // rax
const char *v11; // rax
__int64 v12; // rax
__int64 v13; // rbx
__int64 v14; // rax

v4 = (const char *)val_string(a2);
v5 = (const char *)val_string(a1);
v6 = strcmp(v5, v4);
result = 1LL;
if ( v6 )
{
if ( a3 )
{
while ( 1 )
{
v8 = (const char *)val_string(a1);
v9 = val_car(a3);
v10 = val_car(v9);
v11 = (const char *)val_string(v10);
if ( !strcmp(v11, v8) )
break;
a3 = val_cdr(a3);
if ( !a3 )
return 0LL;
}
v12 = val_car(a3);
v13 = val_cdr(v12);
v14 = val_string(a2);
result = (unsigned int)val_member_string(v14, v13) != 0;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
static int item_match(const cst_val *PATT, const cst_val *THING,
        const cst_val *sets)
{
    const cst_val *sss;
    if ((strcmp(val_string(PATT),val_string(THING)) == 0))
 return TRUE;
    for (sss=sets; sss; sss=val_cdr(sss))
    {
 if ((strcmp(val_string(val_car(val_car(sss))),val_string(PATT)) == 0))
 {
     if (val_member_string(val_string(THING),val_cdr(val_car(sss))))
     {
  return TRUE;
     }
     else
     {
  return FALSE;
     }
 }
    }
    return FALSE;
}

canonical_original_code:
static int item_match(struct cst_val_struct *PATT, struct cst_val_struct *THING, struct cst_val_struct *sets)
{
    struct cst_val_struct *sss;
    if ((strcmp(val_string(PATT),val_string(THING)) == 0))
 return TRUE;
    for (sss=sets; sss; sss=val_cdr(sss))
    {
 if ((strcmp(val_string(val_car(val_car(sss))),val_string(PATT)) == 0))
 {
     if (val_member_string(val_string(THING),val_cdr(val_car(sss))))
     {
  return TRUE;
     }
     else
     {
  return FALSE;
     }
 }
    }
    return FALSE;
}

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; } *

variable_types:
THING
struct cst_val_struct *

variable_types:
sets
struct cst_val_struct *


decompiled_code:
__int64 __fastcall context_match(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
int v10; // edx
__int64 v11; // rax
int v12; // edx
__int64 v13; // r13
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rbp
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rbp
__int64 v20; // rax

if ( !a1 )
return 1LL;
result = 0LL;
if ( a2 )
{
if ( val_cdr(a1) && (v5 = val_car(a1), !strcmp("*", (const char *)val_string(v5))) )
{
v8 = val_cdr(a1);
v9 = val_cdr(v8);
v10 = context_match(v9, a2, a3);
result = 1LL;
if ( !v10 )
{
v11 = val_cdr(a1);
v12 = context_match(v11, a2, a3);
result = 1LL;
if ( !v12 )
{
v13 = val_car(a2);
v14 = val_cdr(a1);
v15 = val_car(v14);
result = item_match(v15, v13, a3);
if ( (_DWORD)result )
{
v16 = val_cdr(a2);
v17 = val_cdr(a1);
v18 = val_cdr(v17);
result = (unsigned int)context_match(v18, v16, a3) != 0;
}
}
}
}
else
{
v6 = val_car(a2);
v7 = val_car(a1);
result = item_match(v7, v6, a3);
if ( (_DWORD)result )
{
v19 = val_cdr(a2);
v20 = val_cdr(a1);
result = context_match(v20, v19, a3);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
int v10; // edx
__int64 v11; // rax
int v12; // edx
__int64 v13; // r13
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rbp
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rbp
__int64 v20; // rax

if ( !a1 )
return 1LL;
result = 0LL;
if ( a2 )
{
if ( val_cdr(a1) && (v5 = val_car(a1), !strcmp("*", (const char *)val_string(v5))) )
{
v8 = val_cdr(a1);
v9 = val_cdr(v8);
v10 = func1(v9, a2, a3);
result = 1LL;
if ( !v10 )
{
v11 = val_cdr(a1);
v12 = func1(v11, a2, a3);
result = 1LL;
if ( !v12 )
{
v13 = val_car(a2);
v14 = val_cdr(a1);
v15 = val_car(v14);
result = func0(v15, v13, a3);
if ( (_DWORD)result )
{
v16 = val_cdr(a2);
v17 = val_cdr(a1);
v18 = val_cdr(v17);
result = (unsigned int)func1(v18, v16, a3) != 0;
}
}
}
}
else
{
v6 = val_car(a2);
v7 = val_car(a1);
result = func0(v7, v6, a3);
if ( (_DWORD)result )
{
v19 = val_cdr(a2);
v20 = val_cdr(a1);
result = func1(v20, v19, a3);
}
}
}
return result;
}

original_code:
static int context_match(const cst_val *PATTERN, const cst_val *STRING,
    const cst_val *sets)
{
    if (!PATTERN)
 return TRUE;
    else if (!STRING)
 return FALSE;
    else if (val_cdr(PATTERN) &&
      ((strcmp("*",val_string(val_car(PATTERN))) == 0)))
 return
     context_match(val_cdr(val_cdr(PATTERN)),STRING,sets) ||
     context_match(val_cdr(PATTERN),STRING,sets) ||
     (item_match(val_car(val_cdr(PATTERN)),val_car(STRING),sets) &&
      context_match(val_cdr(val_cdr(PATTERN)),
      val_cdr(STRING),sets));
    else if (item_match(val_car(PATTERN),val_car(STRING),sets))
 return context_match(val_cdr(PATTERN),val_cdr(STRING),sets);
    else
 return FALSE;
}

canonical_original_code:
static int context_match(struct cst_val_struct *PATTERN, struct cst_val_struct *STRING, struct cst_val_struct *sets)
{
    if (!PATTERN)
 return TRUE;
    else if (!STRING)
 return FALSE;
    else if (val_cdr(PATTERN) &&
      ((strcmp("*",val_string(val_car(PATTERN))) == 0)))
 return
     context_match(val_cdr(val_cdr(PATTERN)),STRING,sets) ||
     context_match(val_cdr(PATTERN),STRING,sets) ||
     (item_match(val_car(val_cdr(PATTERN)),val_car(STRING),sets) &&
      context_match(val_cdr(val_cdr(PATTERN)),
      val_cdr(STRING),sets));
    else if (item_match(val_car(PATTERN),val_car(STRING),sets))
 return context_match(val_cdr(PATTERN),val_cdr(STRING),sets);
    else
 return FALSE;
}

variable_types:
STRING
struct cst_val_struct *


decompiled_code:
__int64 __fastcall rule_matches(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v6; // rbp
__int64 v9; // rbx
__int64 v10; // rax
const char *v11; // r12
__int64 v12; // rax
const char *v13; // rax
unsigned int v14; // er12
__int64 v15; // rax

v6 = a2;
if ( a4 )
{
v9 = a4;
if ( a2 )
{
while ( 1 )
{
v10 = val_car(v6);
v11 = (const char *)val_string(v10);
v12 = val_car(v9);
v13 = (const char *)val_string(v12);
v14 = strcmp(v13, v11);
if ( v14 )
break;
v9 = val_cdr(v9);
v15 = val_cdr(v6);
v6 = v15;
if ( !v9 )
goto LABEL_7;
if ( !v15 )
return v14;
}
v14 = 0;
}
else
{
v14 = 0;
}
}
else
{
LABEL_7:
v14 = context_match(a3, a1, a6);
if ( v14 )
v14 = context_match(a5, v6, a6) != 0;
}
return v14;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v6; // rbp
__int64 v9; // rbx
__int64 v10; // rax
const char *v11; // r12
__int64 v12; // rax
const char *v13; // rax
unsigned int v14; // er12
__int64 v15; // rax

v6 = a2;
if ( a4 )
{
v9 = a4;
if ( a2 )
{
while ( 1 )
{
v10 = val_car(v6);
v11 = (const char *)val_string(v10);
v12 = val_car(v9);
v13 = (const char *)val_string(v12);
v14 = strcmp(v13, v11);
if ( v14 )
break;
v9 = val_cdr(v9);
v15 = val_cdr(v6);
v6 = v15;
if ( !v9 )
goto LABEL_7;
if ( !v15 )
return v14;
}
v14 = 0;
}
else
{
v14 = 0;
}
}
else
{
LABEL_7:
v14 = func1(a3, a1, a6);
if ( v14 )
v14 = func1(a5, v6, a6) != 0;
}
return v14;
}

original_code:
static int rule_matches(const cst_val *LC, const cst_val *RC,
   const cst_val *RLC, const cst_val *RA,
   const cst_val *RRC,
   const cst_val *sets)
{
    const cst_val *rc, *ra;
    for (rc=RC,ra=RA; ra; ra=val_cdr(ra),rc=val_cdr(rc))
    {
 if (!rc) return FALSE;
 if (!(strcmp(val_string(val_car(ra)),val_string(val_car(rc))) == 0))
     return FALSE;
    }
    if (context_match(RLC,LC,sets) && context_match(RRC,rc,sets))
 return TRUE;
    else
 return FALSE;
}

canonical_original_code:
static int rule_matches(struct cst_val_struct *LC, struct cst_val_struct *RC, struct cst_val_struct *RLC, struct cst_val_struct *RA, struct cst_val_struct *RRC, struct cst_val_struct *sets)
{
    struct cst_val_struct *rc; struct cst_val_struct *ra;
    for (rc=RC,ra=RA; ra; ra=val_cdr(ra),rc=val_cdr(rc))
    {
 if (!rc) return FALSE;
 if (!(strcmp(val_string(val_car(ra)),val_string(val_car(rc))) == 0))
     return FALSE;
    }
    if (context_match(RLC,LC,sets) && context_match(RRC,rc,sets))
 return TRUE;
    else
 return FALSE;
}

variable_types:
RC
struct cst_val_struct *

variable_types:
RLC
struct cst_val_struct *

variable_types:
RA
struct cst_val_struct *

variable_types:
RRC
struct cst_val_struct *


decompiled_code:
__int64 __fastcall find_rewrite_rule(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rbp
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // r12
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 result; // rax

v4 = *(_QWORD *)(a3 + 16);
if ( v4 )
{
while ( 1 )
{
v5 = val_car(v4);
v6 = val_car(v5);
v7 = val_car(v4);
v8 = val_cdr(v7);
v9 = val_car(v8);
v10 = val_car(v4);
v11 = val_cdr(v10);
v12 = val_cdr(v11);
v13 = val_car(v12);
if ( (unsigned int)rule_matches(a1, a2, v6, v9, v13, *(_QWORD *)(a3 + 8)) )
break;
v4 = val_cdr(v4);
if ( !v4 )
goto LABEL_4;
}
result = val_car(v4);
}
else
{
LABEL_4:
fwrite("LTS_REWRITES: unable to find a matching rules for:\n", 1uLL, 0x33uLL, stderr);
fwrite("CL: ", 1uLL, 4uLL, stderr);
val_print(stderr, a1);
fputc(10, stderr);
fwrite("RC: ", 1uLL, 4uLL, stderr);
val_print(stderr, a2);
fputc(10, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rbp
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // r12
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 result; // rax

v4 = *(_QWORD *)(a3 + 16);
if ( v4 )
{
while ( 1 )
{
v5 = val_car(v4);
v6 = val_car(v5);
v7 = val_car(v4);
v8 = val_cdr(v7);
v9 = val_car(v8);
v10 = val_car(v4);
v11 = val_cdr(v10);
v12 = val_cdr(v11);
v13 = val_car(v12);
if ( (unsigned int)func2(a1, a2, v6, v9, v13, *(_QWORD *)(a3 + 8)) )
break;
v4 = val_cdr(v4);
if ( !v4 )
goto LABEL_4;
}
result = val_car(v4);
}
else
{
LABEL_4:
fwrite("LTS_REWRITES: unable to find a matching rules for:\n", 1uLL, 0x33uLL, stderr);
fwrite("CL: ", 1uLL, 4uLL, stderr);
val_print(stderr, a1);
fputc(10, stderr);
fwrite("RC: ", 1uLL, 4uLL, stderr);
val_print(stderr, a2);
fputc(10, stderr);
result = 0LL;
}
return result;
}

original_code:
static const cst_val *find_rewrite_rule(const cst_val *LC,
     const cst_val *RC,
     const cst_lts_rewrites *r)
{
    const cst_val *i, *RLC, *RA, *RRC;
    for (i=r->rules; i; i=val_cdr(i))
    {
 RLC = val_car(val_car(i));
 RA = val_car(val_cdr(val_car(i)));
 RRC = val_car(val_cdr(val_cdr(val_car(i))));
 if (rule_matches(LC,RC,RLC,RA,RRC,r->sets))
     return val_car(i);
    }
    fprintf(stderr,"LTS_REWRITES: unable to find a matching rules for:\n");
    fprintf(stderr,"CL: ");
    val_print(stderr,LC);
    fprintf(stderr,"\n");
    fprintf(stderr,"RC: ");
    val_print(stderr,RC);
    fprintf(stderr,"\n");
    return ((void *)0);
}

canonical_original_code:
static struct cst_val_struct *find_rewrite_rule(struct cst_val_struct *LC, struct cst_val_struct *RC, struct cst_lts_rewrites_struct *r)
{
    struct cst_val_struct *i; struct cst_val_struct *RLC; struct cst_val_struct *RA; struct cst_val_struct *RRC;
    for (i=r->rules; i; i=val_cdr(i))
    {
 RLC = val_car(val_car(i));
 RA = val_car(val_cdr(val_car(i)));
 RRC = val_car(val_cdr(val_cdr(val_car(i))));
 if (rule_matches(LC,RC,RLC,RA,RRC,r->sets))
     return val_car(i);
    }
    fprintf(stderr,"LTS_REWRITES: unable to find a matching rules for:\n");
    fprintf(stderr,"CL: ");
    val_print(stderr,LC);
    fprintf(stderr,"\n");
    fprintf(stderr,"RC: ");
    val_print(stderr,RC);
    fprintf(stderr,"\n");
    return ((void *)0);
}

variable_types:
LC
struct cst_val_struct *

variable_types: struct cst_lts_rewrites_struct { char *name; struct cst_val_struct *sets; struct cst_val_struct *rules; } *


decompiled_code:
__int64 __fastcall lts_rewrites(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r15
__int64 v8; // rax
__int64 i; // rbx
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 j; // rbx
__int64 v15; // rax

v2 = val_car(a1);
v3 = cons_val(v2, 0LL);
v4 = val_cdr(a1);
v5 = 0LL;
while ( val_cdr(v4) )
{
v6 = find_rewrite_rule(v3, v4, a2);
v7 = v6;
if ( !v6 )
break;
v8 = val_cdr(v6);
for ( i = val_car(v8); i; i = val_cdr(i) )
{
v10 = val_car(v4);
v3 = cons_val(v10, v3);
v4 = val_cdr(v4);
}
v11 = val_cdr(v7);
v12 = val_cdr(v11);
v13 = val_cdr(v12);
for ( j = val_car(v13); j; j = val_cdr(j) )
{
v15 = val_car(j);
v5 = cons_val(v15, v5);
}
}
delete_val_list(v3);
return val_reverse(v5);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r15
__int64 v8; // rax
__int64 i; // rbx
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 j; // rbx
__int64 v15; // rax

v2 = val_car(a1);
v3 = cons_val(v2, 0LL);
v4 = val_cdr(a1);
v5 = 0LL;
while ( val_cdr(v4) )
{
v6 = func3(v3, v4, a2);
v7 = v6;
if ( !v6 )
break;
v8 = val_cdr(v6);
for ( i = val_car(v8); i; i = val_cdr(i) )
{
v10 = val_car(v4);
v3 = cons_val(v10, v3);
v4 = val_cdr(v4);
}
v11 = val_cdr(v7);
v12 = val_cdr(v11);
v13 = val_cdr(v12);
for ( j = val_car(v13); j; j = val_cdr(j) )
{
v15 = val_car(j);
v5 = cons_val(v15, v5);
}
}
delete_val_list(v3);
return val_reverse(v5);
}

original_code:
cst_val *lts_rewrites(const cst_val *itape, const cst_lts_rewrites *r)
{
    cst_val *LC;
    const cst_val *RC, *i;
    const cst_val *rule;
    cst_val *otape;
    LC = cons_val(val_car(itape),((void *)0));
    RC = val_cdr(itape);
    otape = ((void *)0);
    while (val_cdr(RC))
    {
 rule = find_rewrite_rule(LC,RC,r);
 if (!rule)
     break;
 for (i=val_car(val_cdr(rule)); i; i=val_cdr(i))
 {
     LC = cons_val(val_car(RC),LC);
     RC = val_cdr(RC);
 }
 for (i=val_car(val_cdr(val_cdr(val_cdr(rule)))); i; i=val_cdr(i))
     otape = cons_val(val_car(i),otape);
    }
    delete_val_list(LC);
    return val_reverse(otape);
}

canonical_original_code:
struct cst_val_struct *lts_rewrites(struct cst_val_struct *itape, struct cst_lts_rewrites_struct *r)
{
    struct cst_val_struct *LC;
    struct cst_val_struct *RC; struct cst_val_struct *i;
    struct cst_val_struct *rule;
    struct cst_val_struct *otape;
    LC = cons_val(val_car(itape),((void *)0));
    RC = val_cdr(itape);
    otape = ((void *)0);
    while (val_cdr(RC))
    {
 rule = find_rewrite_rule(LC,RC,r);
 if (!rule)
     break;
 for (i=val_car(val_cdr(rule)); i; i=val_cdr(i))
 {
     LC = cons_val(val_car(RC),LC);
     RC = val_cdr(RC);
 }
 for (i=val_car(val_cdr(val_cdr(val_cdr(rule)))); i; i=val_cdr(i))
     otape = cons_val(val_car(i),otape);
    }
    delete_val_list(LC);
    return val_reverse(otape);
}

variable_types:
itape
struct cst_val_struct *

user_defined_types: struct cst_lts_rewrites_struct { char *name; struct cst_val_struct *sets; struct cst_val_struct *rules; }


decompiled_code:
__int64 __fastcall lts_rewrites_word(char *a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbx
char v4; // al
char *v5; // rbp
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rbx
__int64 v10; // rbp
char v12[26]; // [rsp+Eh] [rbp-1Ah] BYREF

v12[1] = 0;
v2 = string_val("#");
v3 = cons_val(v2, 0LL);
v4 = *a1;
if ( *a1 )
{
v5 = a1 + 1;
do
{
v12[0] = v4;
v6 = string_val(v12);
v3 = cons_val(v6, v3);
v4 = *v5++;
}
while ( v4 );
}
v7 = string_val("#");
v8 = cons_val(v7, v3);
v9 = val_reverse(v8);
v10 = lts_rewrites(v9, a2);
delete_val(v9);
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbx
char v4; // al
char *v5; // rbp
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rbx
__int64 v10; // rbp
char v12[26]; // [rsp+Eh] [rbp-1Ah] BYREF

v12[1] = 0;
v2 = string_val("#");
v3 = cons_val(v2, 0LL);
v4 = *a1;
if ( *a1 )
{
v5 = a1 + 1;
do
{
v12[0] = v4;
v6 = string_val(v12);
v3 = cons_val(v6, v3);
v4 = *v5++;
}
while ( v4 );
}
v7 = string_val("#");
v8 = cons_val(v7, v3);
v9 = val_reverse(v8);
v10 = func4(v9, a2);
delete_val(v9);
return v10;
}

original_code:
cst_val *lts_rewrites_word(const char *word, const cst_lts_rewrites *r)
{
    cst_val *w, *p;
    char x[2];
    int i;
    x[1] = '\0';
    w = cons_val(string_val("#"),((void *)0));
    for (i=0; word[i]; i++)
    {
 x[0] = word[i];
 w = cons_val(string_val(x),w);
    }
    w = cons_val(string_val("#"),w);
    w = val_reverse(w);
    p = lts_rewrites(w,r);
    delete_val(w);
    return p;
}

canonical_original_code:
struct cst_val_struct *lts_rewrites_word(char *word, struct cst_lts_rewrites_struct *r)
{
    struct cst_val_struct *w; struct cst_val_struct *p;
    char x[2];
    int i;
    x[1] = '\0';
    w = cons_val(string_val("#"),((void *)0));
    for (i=0; word[i]; i++)
    {
 x[0] = word[i];
 w = cons_val(string_val(x),w);
    }
    w = cons_val(string_val("#"),w);
    w = val_reverse(w);
    p = lts_rewrites(w,r);
    delete_val(w);
    return p;
}

variable_types:
word
char *

variable_types:
x
char [2]


decompiled_code:
__int64 new_val()
{
return cst_safe_alloc(16LL);
}

canonical_decompiled_code:
__int64 func0()
{
return cst_safe_alloc(16LL);
}

original_code:
static cst_val *new_val()
{
   return ((struct cst_val_struct *)cst_safe_alloc(sizeof(struct cst_val_struct)*(1)));
}

canonical_original_code:
static struct cst_val_struct *new_val()
{
   return ((struct cst_val_struct *)cst_safe_alloc(sizeof(struct cst_val_struct)*(1)));
}


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

result = new_val();
*(_WORD *)result = 1;
*(_DWORD *)(result + 8) = a1;
return result;
}

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

result = func0();
*(_WORD *)result = 1;
*(_DWORD *)(result + 8) = a1;
return result;
}

original_code:
cst_val *int_val(int i)
{
   cst_val *v = new_val();
   ((v)->c.a.type) = 1;
   ((v)->c.a.v.ival) = i;
   return v;
}

canonical_original_code:
struct cst_val_struct *int_val(int i)
{
   struct cst_val_struct *v = new_val();
   ((v)->c.a.type) = 1;
   ((v)->c.a.v.ival) = i;
   return v;
}


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

result = new_val();
*(_WORD *)result = 3;
*(_DWORD *)(result + 8) = _mm_cvtsi128_si32(a1);
return result;
}

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

result = func0();
*(_WORD *)result = 3;
*(_DWORD *)(result + 8) = _mm_cvtsi128_si32(a1);
return result;
}

original_code:
cst_val *float_val(float f)
{
   cst_val *v = new_val();
   ((v)->c.a.type) = 3;
   ((v)->c.a.v.fval) = f;
   return v;
}

canonical_original_code:
struct cst_val_struct *float_val(float f)
{
   struct cst_val_struct *v = new_val();
   ((v)->c.a.type) = 3;
   ((v)->c.a.v.fval) = f;
   return v;
}

variable_types: f float


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

v1 = new_val();
*(_WORD *)v1 = 5;
*(_QWORD *)(v1 + 8) = cst_strdup(a1);
return v1;
}

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

v1 = func0();
*(_WORD *)v1 = 5;
*(_QWORD *)(v1 + 8) = cst_strdup(a1);
return v1;
}

original_code:
cst_val *string_val(const char *s)
{
   cst_val *v = new_val();
   ((v)->c.a.type) = 5;
   ((v)->c.a.v.vval) = cst_strdup(s);
   return v;
}

canonical_original_code:
struct cst_val_struct *string_val(char *s)
{
   struct cst_val_struct *v = new_val();
   ((v)->c.a.type) = 5;
   ((v)->c.a.v.vval) = cst_strdup(s);
   return v;
}

variable_types:
s
char *


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

result = new_val();
*(_WORD *)result = a1;
*(_QWORD *)(result + 8) = a2;
return result;
}

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

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

original_code:
cst_val *val_new_typed(int type,void *vv)
{
   cst_val *v = new_val();
   ((v)->c.a.type) = type;
   ((v)->c.a.v.vval) = vv;
   return v;
}

canonical_original_code:
struct cst_val_struct *val_new_typed(int type, void *vv)
{
   struct cst_val_struct *v = new_val();
   ((v)->c.a.type) = type;
   ((v)->c.a.v.vval) = vv;
   return v;
}

variable_types: type int

variable_types:
vv
void *


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; } *


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;
}


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;
}


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

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

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

if ( !a1 )
{
v2 = 0xFFFFFFFFLL;
LABEL_5:
cst_errmsg("VAL: tried to access void in %d typed val\n", v2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v1 = *a1;
if ( *a1 == 3 || v1 <= 1u )
{
v2 = (unsigned int)(__int16)v1;
goto LABEL_5;
}
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(_BYTE *a1)
{
return (*a1 & 1) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(_BYTE *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 *


decompiled_code:
__int64 __fastcall val_car(_BYTE *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 *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func10(_BYTE *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 *(_QWORD *)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 *


decompiled_code:
__int64 __fastcall val_cdr(__int16 *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)*a1;
goto LABEL_4;
}
return *((_QWORD *)a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int16 *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)*a1;
goto LABEL_4;
}
return *((_QWORD *)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(__int16 *a1)
{
unsigned int v1; // ebx

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

canonical_decompiled_code:
__int64 __fastcall func15(__int16 *a1)
{
unsigned int v1; // ebx

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

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, __int64 a2)
{
__int16 v2; // r12
__int64 result; // rax
__int64 v4; // r12
__int64 v5; // rax
__int64 v6; // rbp
__int64 v7; // rax
int v8; // ebx
float v9; // [rsp+0h] [rbp-1Ch]

if ( a1 == (__int16 *)a2 )
return 1LL;
if ( !a1 )
return 0LL;
v2 = *a1;
result = 0LL;
if ( *a1 == *(_WORD *)a2 )
{
if ( cst_val_consp(a1) )
{
v4 = val_car((_BYTE *)a2);
v5 = val_car(a1);
result = val_equal(v5, v4);
if ( (_DWORD)result )
{
v6 = val_cdr((__int16 *)a2);
v7 = val_cdr(a1);
result = (unsigned int)val_equal(v7, v6) != 0;
}
}
else
{
switch ( v2 )
{
case 1:
v8 = val_int(a1);
result = v8 == val_int((__int16 *)a2);
break;
case 3:
v9 = val_float((int *)a1);
result = v9 == val_float((int *)a2);
break;
case 5:
result = strcmp(*((const char **)a1 + 1), *(const char **)(a2 + 8)) == 0;
break;
default:
result = *((_QWORD *)a1 + 1) == *(_QWORD *)(a2 + 8);
break;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int16 *a1, __int64 a2)
{
__int16 v2; // r12
__int64 result; // rax
__int64 v4; // r12
__int64 v5; // rax
__int64 v6; // rbp
__int64 v7; // rax
int v8; // ebx
float v9; // [rsp+0h] [rbp-1Ch]

if ( a1 == (__int16 *)a2 )
return 1LL;
if ( !a1 )
return 0LL;
v2 = *a1;
result = 0LL;
if ( *a1 == *(_WORD *)a2 )
{
if ( func9(a1) )
{
v4 = func10((_BYTE *)a2);
v5 = func10(a1);
result = func16(v5, v4);
if ( (_DWORD)result )
{
v6 = func11((__int16 *)a2);
v7 = func11(a1);
result = (unsigned int)func16(v7, v6) != 0;
}
}
else
{
switch ( v2 )
{
case 1:
v8 = func5(a1);
result = v8 == func5((__int16 *)a2);
break;
case 3:
v9 = func6((int *)a1);
result = v9 == func6((int *)a2);
break;
case 5:
result = strcmp(*((const char **)a1 + 1), *(const char **)(a2 + 8)) == 0;
break;
default:
result = *((_QWORD *)a1 + 1) == *(_QWORD *)(a2 + 8);
break;
}
}
}
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 func17(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 func18(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(__int64 a1, __int16 *a2)
{
__int16 *v2; // rbx
__int16 *v3; // rax
unsigned int v4; // ebp

v2 = a2;
if ( !a2 )
return 0;
while ( 1 )
{
v3 = (__int16 *)val_car(v2);
v4 = val_equal(v3, a1);
if ( v4 )
break;
v2 = (__int16 *)val_cdr(v2);
if ( !v2 )
return v4;
}
return 1;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int16 *a2)
{
__int16 *v2; // rbx
__int16 *v3; // rax
unsigned int v4; // ebp

v2 = a2;
if ( !a2 )
return 0;
while ( 1 )
{
v3 = (__int16 *)func10(v2);
v4 = func16(v3, a1);
if ( v4 )
break;
v2 = (__int16 *)func11(v2);
if ( !v2 )
return v4;
}
return 1;
}

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, __int16 *a2)
{
__int16 *v2; // rbx
__int16 *v3; // rax
const char *v4; // rax

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

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

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

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;
}


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; // bx
_BOOL4 v2; // eax

v1 = *(_WORD *)(a1 + 2);
if ( v1 == -1 )
return -1;
v2 = cst_val_consp((_BYTE *)a1);
if ( !v1 || v2 )
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; // dx

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 / 2) + 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);
      }
   }
}


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 func24(_QWORD *a1)
{
if ( a1 )
{
if ( func9(a1) )
{
func24(a1[1]);
cst_free(a1);
}
else
{
func23(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);
   }
}