decompiled_code:
__int64 __fastcall vit_point_init_dynamic_path_array(__int64 a1, __int64 a2)
{
int v2; // eax

if ( a2 )
{
v2 = 0;
do
{
*(_DWORD *)(a2 + 20) = v2++;
a2 = *(_QWORD *)(a2 + 32);
}
while ( a2 );
}
else
{
v2 = 0;
}
return vit_point_init_path_array(a1, v2);
}

original_code:
static void vit_point_init_dynamic_path_array(cst_vit_point *n,
           cst_vit_cand *c)
{
    int i;
    cst_vit_cand *cc;
    for (cc=c,i=0; cc; i++,cc=cc->next)
 cc->pos = i;
    vit_point_init_path_array(n,i);
}

canonical_original_code:
static void vit_point_init_dynamic_path_array(struct cst_vit_point_struct *n, struct cst_vit_cand_struct *c)
{
    int i;
    struct cst_vit_cand_struct *cc;
    for (cc=c,i=0; cc; i++,cc=cc->next)
 cc->pos = i;
    vit_point_init_path_array(n,i);
}

variable_types:
c
struct cst_vit_cand_struct *

variable_types: i int

variable_types: struct cst_vit_cand_struct { int score; 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; int ival; 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; } *item; struct cst_vit_cand_struct *next; } *

user_defined_types: struct cst_vit_cand_struct { int score; struct cst_val_struct *val; int ival; struct cst_item_struct *item; struct cst_vit_cand_struct *next; }

user_defined_types: struct cst_vit_path_struct { int score; int state; struct cst_vit_cand_struct *cand; struct cst_features_struct *f; struct cst_vit_path_struct *from; struct cst_vit_path_struct *next; }


repo: deardaniel/PizzaTest

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

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

original_code:
cst_vit_cand *new_vit_cand()
{
    cst_vit_cand *c = ((struct cst_vit_cand_struct *)cst_safe_alloc(sizeof(struct cst_vit_cand_struct)*(1)));
    return c;
}

canonical_original_code:
struct cst_vit_cand_struct *new_vit_cand()
{
    struct cst_vit_cand_struct *c = ((struct cst_vit_cand_struct *)cst_safe_alloc(sizeof(struct cst_vit_cand_struct)*(1)));
    return c;
}

return_type: struct cst_vit_cand_struct { int score; 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; int ival; 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; } *item; struct cst_vit_cand_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_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; }

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


decompiled_code:
__int64 __fastcall vit_cand_set(__int64 a1, __int64 a2)
{
if ( *(_QWORD *)(a1 + 8) )
delete_val();
*(_QWORD *)(a1 + 8) = a2;
return val_inc_refcount(a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
if ( *(_QWORD *)(a1 + 8) )
delete_val();
*(_QWORD *)(a1 + 8) = a2;
return val_inc_refcount(a2);
}

original_code:
void vit_cand_set(cst_vit_cand *vc, cst_val *val)
{
 if (vc->val)
  delete_val(vc->val);
 vc->val = val;
 val_inc_refcount(vc->val);
}

canonical_original_code:
void vit_cand_set(struct cst_vit_cand_struct *vc, struct cst_val_struct *val)
{
 if (vc->val)
  delete_val(vc->val);
 vc->val = val;
 val_inc_refcount(vc->val);
}

variable_types:
val
struct cst_val_struct *

return_type: void

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

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

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


decompiled_code:
__int64 __fastcall vit_cand_set_int(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

*(_DWORD *)(a1 + 16) = a2;
v2 = int_val(a2);
return vit_cand_set(a1, v2);
}

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

*(_DWORD *)(a1 + 16) = a2;
v2 = int_val(a2);
return func5(a1, v2);
}

original_code:
void vit_cand_set_int(cst_vit_cand *vc, int ival)
{
 vc->ival = ival;
 vit_cand_set(vc, int_val(ival));
}

canonical_original_code:
void vit_cand_set_int(struct cst_vit_cand_struct *vc, int ival)
{
 vc->ival = ival;
 vit_cand_set(vc, int_val(ival));
}

variable_types: ival int


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

if ( a1 )
{
delete_val(*(_QWORD *)(a1 + 8));
delete_vit_cand(*(_QWORD *)(a1 + 32));
result = cst_free(a1);
}
return result;
}

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

if ( a1 )
{
delete_val(*(_QWORD *)(a1 + 8));
func7(*(_QWORD *)(a1 + 32));
result = cst_free(a1);
}
return result;
}

original_code:
void delete_vit_cand(cst_vit_cand *vc)
{
    if (vc)
    {
 delete_val(vc->val);
 delete_vit_cand(vc->next);
 cst_free(vc);
    }
}

canonical_original_code:
void delete_vit_cand(struct cst_vit_cand_struct *vc)
{
    if (vc)
    {
 delete_val(vc->val);
 delete_vit_cand(vc->next);
 cst_free(vc);
    }
}


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

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

original_code:
cst_vit_path *new_vit_path()
{
    cst_vit_path *p = ((struct cst_vit_path_struct *)cst_safe_alloc(sizeof(struct cst_vit_path_struct)*(1)));
    return p;
}

canonical_original_code:
struct cst_vit_path_struct *new_vit_path()
{
    struct cst_vit_path_struct *p = ((struct cst_vit_path_struct *)cst_safe_alloc(sizeof(struct cst_vit_path_struct)*(1)));
    return p;
}

variable_types: struct cst_vit_path_struct { int score; int state; struct cst_vit_cand_struct { int score; 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; int ival; 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; } *item; struct cst_vit_cand_struct *next; } *cand; struct cst_features_struct *f; struct cst_vit_path_struct *from; struct cst_vit_path_struct *next; } *


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

if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
delete_features();
delete_vit_path(*(_QWORD *)(a1 + 32));
result = cst_free(a1);
}
return result;
}

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

if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
delete_features();
func9(*(_QWORD *)(a1 + 32));
result = cst_free(a1);
}
return result;
}

original_code:
void delete_vit_path(cst_vit_path *vp)
{
    if (vp)
    {
 if (vp->f)
     delete_features(vp->f);
 delete_vit_path(vp->next);
 cst_free(vp);
    }
}

canonical_original_code:
void delete_vit_path(struct cst_vit_path_struct *vp)
{
    if (vp)
    {
 if (vp->f)
     delete_features(vp->f);
 delete_vit_path(vp->next);
 cst_free(vp);
    }
}


decompiled_code:
int **__fastcall vit_add_path(__int64 a1, __int64 a2, int *a3)
{
int **result; // rax
int *v5; // r12

result = (int **)(*(_QWORD *)(a2 + 32) + 8LL * a3[1]);
v5 = *result;
if ( *result )
{
if ( betterthan(a1, *a3, *v5) )
{
delete_vit_path((__int64)v5);
result = *(int ***)(a2 + 32);
result[a3[1]] = a3;
}
else
{
result = (int **)delete_vit_path((__int64)a3);
}
}
else
{
*result = a3;
}
return result;
}

canonical_decompiled_code:
int **__fastcall func10(__int64 a1, __int64 a2, int *a3)
{
int **result; // rax
int *v5; // r12

result = (int **)(*(_QWORD *)(a2 + 32) + 8LL * a3[1]);
v5 = *result;
if ( *result )
{
if ( func0(a1, *a3, *v5) )
{
func9((__int64)v5);
result = *(int ***)(a2 + 32);
result[a3[1]] = a3;
}
else
{
result = (int **)func9((__int64)a3);
}
}
else
{
*result = a3;
}
return result;
}

original_code:
static void vit_add_path(cst_viterbi *vd,cst_vit_point *p, cst_vit_path *np)
{
    if (p->state_paths[np->state] == 0)
    {
 p->state_paths[np->state] = np;
    }
    else if (betterthan(vd,np->score,p->state_paths[np->state]->score))
    {
 delete_vit_path(p->state_paths[np->state]);
 p->state_paths[np->state] = np;
    }
    else
 delete_vit_path(np);
}

canonical_original_code:
static void vit_add_path(struct cst_viterbi_struct *vd, struct cst_vit_point_struct *p, struct cst_vit_path_struct *np)
{
    if (p->state_paths[np->state] == 0)
    {
 p->state_paths[np->state] = np;
    }
    else if (betterthan(vd,np->score,p->state_paths[np->state]->score))
    {
 delete_vit_path(p->state_paths[np->state]);
 p->state_paths[np->state] = np;
    }
    else
 delete_vit_path(np);
}

variable_types: struct cst_viterbi_struct { int num_states; struct cst_vit_cand_struct { int score; 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; int ival; 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; } *item; struct cst_vit_cand_struct *next; } *(*cand_func)(struct cst_item_struct *s, struct cst_viterbi_struct *vd); struct cst_vit_path_struct { int score; int state; struct cst_vit_cand_struct *cand; struct cst_features_struct *f; struct cst_vit_path_struct *from; struct cst_vit_path_struct *next; } *(*path_func)(struct cst_vit_path_struct *p, struct cst_vit_cand_struct *c, struct cst_viterbi_struct *vd); int big_is_good; struct cst_vit_point_struct { struct cst_item_struct *item; int num_states; int num_paths; struct cst_vit_cand_struct *cands; struct cst_vit_path_struct *paths; struct cst_vit_path_struct **state_paths; struct cst_vit_point_struct *next; } *timeline; struct cst_vit_point_struct *last_point; struct cst_features_struct *f; } *

variable_types:
p
struct cst_vit_point_struct *

variable_types:
np
struct cst_vit_path_struct *

user_defined_types: struct cst_viterbi_struct { int num_states; struct cst_vit_cand_struct *(*cand_func)(struct cst_item_struct *s, struct cst_viterbi_struct *vd); struct cst_vit_path_struct *(*path_func)(struct cst_vit_path_struct *p, struct cst_vit_cand_struct *c, struct cst_viterbi_struct *vd); int big_is_good; struct cst_vit_point_struct *timeline; struct cst_vit_point_struct *last_point; struct cst_features_struct *f; }


decompiled_code:
int **__fastcall vit_add_paths(__int64 a1, __int64 a2, __int64 a3)
{
__int64 i; // rbx
int *v4; // rdx
int **result; // rax

for ( i = a3; i; result = vit_add_path(a1, a2, v4) )
{
v4 = (int *)i;
i = *(_QWORD *)(i + 32);
}
return result;
}

canonical_decompiled_code:
int **__fastcall func11(__int64 a1, __int64 a2, __int64 a3)
{
__int64 i; // rbx
int *v4; // rdx
int **result; // rax

for ( i = a3; i; result = func10(a1, a2, v4) )
{
v4 = (int *)i;
i = *(_QWORD *)(i + 32);
}
return result;
}

original_code:
static void vit_add_paths(cst_viterbi *vd,
     cst_vit_point *point,
     cst_vit_path *path)
{
    cst_vit_path *p, *next_p;
    for (p=path; p; p=next_p)
    {
 next_p = p->next;
 vit_add_path(vd,point,p);
    }
}

canonical_original_code:
static void vit_add_paths(struct cst_viterbi_struct *vd, struct cst_vit_point_struct *point, struct cst_vit_path_struct *path)
{
    struct cst_vit_path_struct *p; struct cst_vit_path_struct *next_p;
    for (p=path; p; p=next_p)
    {
 next_p = p->next;
 vit_add_path(vd,point,p);
    }
}

variable_types:
point
struct cst_vit_point_struct *

variable_types:
path
struct cst_vit_path_struct *

user_defined_types: struct cst_vit_point_struct { struct cst_item_struct *item; int num_states; int num_paths; struct cst_vit_cand_struct *cands; struct cst_vit_path_struct *paths; struct cst_vit_path_struct **state_paths; struct cst_vit_point_struct *next; }


decompiled_code:
__int64 new_vit_point()
{
return cst_safe_alloc(48LL);
}

canonical_decompiled_code:
__int64 func12()
{
return cst_safe_alloc(48LL);
}

original_code:
cst_vit_point *new_vit_point()
{
    cst_vit_point *p = ((struct cst_vit_point_struct *)cst_safe_alloc(sizeof(struct cst_vit_point_struct)*(1)));
    return p;
}

canonical_original_code:
struct cst_vit_point_struct *new_vit_point()
{
    struct cst_vit_point_struct *p = ((struct cst_vit_point_struct *)cst_safe_alloc(sizeof(struct cst_vit_point_struct)*(1)));
    return p;
}

variable_types: struct cst_vit_point_struct { 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; } *item; int num_states; int num_paths; struct cst_vit_cand_struct { int score; struct cst_val_struct *val; int ival; struct cst_item_struct *item; struct cst_vit_cand_struct *next; } *cands; struct cst_vit_path_struct { int score; int state; struct cst_vit_cand_struct *cand; struct cst_features_struct *f; struct cst_vit_path_struct *from; struct cst_vit_path_struct *next; } *paths; struct cst_vit_path_struct **state_paths; struct cst_vit_point_struct *next; } *


decompiled_code:
void __fastcall delete_vit_point(__int64 a1)
{
__int64 v2; // rdi
int v3; // eax
__int64 v4; // rbp
__int64 v5; // rdi

if ( a1 )
{
v2 = *(_QWORD *)(a1 + 24);
if ( v2 )
delete_vit_path(v2);
v3 = *(_DWORD *)(a1 + 8);
if ( v3 )
{
if ( v3 > 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * v4);
if ( v5 )
delete_vit_path(v5);
++v4;
}
while ( *(_DWORD *)(a1 + 8) > (int)v4 );
}
cst_free(*(_QWORD *)(a1 + 32));
}
delete_vit_cand(*(_QWORD *)(a1 + 16));
delete_vit_point(*(_QWORD *)(a1 + 40));
cst_free(a1);
}
}

original_code:
void delete_vit_point(cst_vit_point *vp)
{
    int i;
    if (vp)
    {
 if (vp->paths)
     delete_vit_path(vp->paths);
 if (vp->num_states != 0)
 {
     for (i=0; i<vp->num_states; i++)
  if (vp->state_paths[i])
      delete_vit_path(vp->state_paths[i]);
     cst_free(vp->state_paths);
 }
 delete_vit_cand(vp->cands);
 delete_vit_point(vp->next);
 cst_free(vp);
    }
}

canonical_original_code:
void delete_vit_point(struct cst_vit_point_struct *vp)
{
    int i;
    if (vp)
    {
 if (vp->paths)
     delete_vit_path(vp->paths);
 if (vp->num_states != 0)
 {
     for (i=0; i<vp->num_states; i++)
  if (vp->state_paths[i])
      delete_vit_path(vp->state_paths[i]);
     cst_free(vp->state_paths);
 }
 delete_vit_cand(vp->cands);
 delete_vit_point(vp->next);
 cst_free(vp);
    }
}


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

if ( a1 )
{
delete_vit_point(*(_QWORD *)(a1 + 32));
delete_features(*(_QWORD *)(a1 + 48));
result = cst_free(a1);
}
return result;
}

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

if ( a1 )
{
func13(*(_QWORD *)(a1 + 32));
delete_features(*(_QWORD *)(a1 + 48));
result = cst_free(a1);
}
return result;
}

original_code:
void delete_viterbi(cst_viterbi *vd)
{
    if (vd)
    {
 delete_vit_point(vd->timeline);
 delete_features(vd->f);
 cst_free(vd);
    }
    return;
}

canonical_original_code:
void delete_viterbi(struct cst_viterbi_struct *vd)
{
    if (vd)
    {
 delete_vit_point(vd->timeline);
 delete_features(vd->f);
 cst_free(vd);
    }
    return;
}


original_code:
void viterbi_decode(cst_viterbi *vd)
{
    cst_vit_point *p;
    cst_vit_path *np;
    cst_vit_cand *c;
    int i;
    for (p=vd->timeline; p->next != ((void *)0); p=p->next)
    {
 p->cands = (*vd->cand_func)(p->item,vd);
 if (vd->num_states != 0)
 {
     if (vd->num_states == -1)
  vit_point_init_dynamic_path_array(p->next,p->cands);
     for (i=0; i<p->num_states; i++)
     {
  if (((p == vd->timeline) && i==0) ||
      (p->state_paths[i] != 0))
      for (c=p->cands; c; c=c->next)
      {
   np = (*vd->path_func)(p->state_paths[i],c,vd);
   vit_add_paths(vd,p->next,np);
      }
     }
 }
 else
 {
     cst_errmsg("viterbi, general beam search not implemented\n");
 }
    }
}

canonical_original_code:
void viterbi_decode(struct cst_viterbi_struct *vd)
{
    struct cst_vit_point_struct *p;
    struct cst_vit_path_struct *np;
    struct cst_vit_cand_struct *c;
    int i;
    for (p=vd->timeline; p->next != ((void *)0); p=p->next)
    {
 p->cands = (*vd->cand_func)(p->item,vd);
 if (vd->num_states != 0)
 {
     if (vd->num_states == -1)
  vit_point_init_dynamic_path_array(p->next,p->cands);
     for (i=0; i<p->num_states; i++)
     {
  if (((p == vd->timeline) && i==0) ||
      (p->state_paths[i] != 0))
      for (c=p->cands; c; c=c->next)
      {
   np = (*vd->path_func)(p->state_paths[i],c,vd);
   vit_add_paths(vd,p->next,np);
      }
     }
 }
 else
 {
     cst_errmsg("viterbi, general beam search not implemented\n");
 }
    }
}


decompiled_code:
__int64 __fastcall viterbi_result(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int *v3; // rbx
__int64 v5; // rax

v2 = *(_QWORD *)(a1 + 32);
if ( !v2 )
return 1LL;
if ( !*(_QWORD *)(v2 + 40) )
return 1LL;
v3 = find_best_path(a1);
if ( !v3 )
return 0LL;
do
{
v5 = *((_QWORD *)v3 + 1);
if ( v5 )
item_set(*(_QWORD *)(v5 + 24), a2, *(_QWORD *)(v5 + 8));
v3 = (int *)*((_QWORD *)v3 + 3);
}
while ( v3 );
return 1LL;
}

original_code:
int viterbi_result(cst_viterbi *vd,const char *n)
{
    cst_vit_path *p;
    if ((vd->timeline == 0) || (vd->timeline->next == 0))
 return TRUE;
    p = find_best_path(vd);
    if (p == ((void *)0))
 return FALSE;
    for (; p; p=p->from)
 if (p->cand)
 {
     item_set(p->cand->item,n,p->cand->val);
 }
    return TRUE;
}

canonical_original_code:
int viterbi_result(struct cst_viterbi_struct *vd, char *n)
{
    struct cst_vit_path_struct *p;
    if ((vd->timeline == 0) || (vd->timeline->next == 0))
 return TRUE;
    p = find_best_path(vd);
    if (p == ((void *)0))
 return FALSE;
    for (; p; p=p->from)
 if (p->cand)
 {
     item_set(p->cand->item,n,p->cand->val);
 }
    return TRUE;
}

variable_types:
n
char *

return_type: int


decompiled_code:
int *__fastcall viterbi_copy_feature(__int64 a1, __int64 a2)
{
int *result; // rax
int *i; // rbx
__int64 v4; // rax

result = find_best_path(a1);
for ( i = result; i; i = (int *)*((_QWORD *)i + 3) )
{
if ( *((_QWORD *)i + 1) )
{
result = (int *)feat_present(*((_QWORD *)i + 2), a2);
if ( (_DWORD)result )
{
v4 = feat_val(*((_QWORD *)i + 2), a2);
result = (int *)item_set(*(_QWORD *)(*((_QWORD *)i + 1) + 24LL), a2, v4);
}
}
}
return result;
}

canonical_decompiled_code:
int *__fastcall func17(__int64 a1, __int64 a2)
{
int *result; // rax
int *i; // rbx
__int64 v4; // rax

result = func1(a1);
for ( i = result; i; i = (int *)*((_QWORD *)i + 3) )
{
if ( *((_QWORD *)i + 1) )
{
result = (int *)feat_present(*((_QWORD *)i + 2), a2);
if ( (_DWORD)result )
{
v4 = feat_val(*((_QWORD *)i + 2), a2);
result = (int *)item_set(*(_QWORD *)(*((_QWORD *)i + 1) + 24LL), a2, v4);
}
}
}
return result;
}

original_code:
void viterbi_copy_feature(cst_viterbi *vd,const char *featname)
{
    cst_vit_path *p;
    p = find_best_path(vd);
    if (p == ((void *)0))
 return;
    for (; p; p=p->from)
 if (p->cand && feat_present(p->f, featname))
     item_set(p->cand->item,featname,feat_val(p->f,featname));
    return;
}

canonical_original_code:
void viterbi_copy_feature(struct cst_viterbi_struct *vd, char *featname)
{
    struct cst_vit_path_struct *p;
    p = find_best_path(vd);
    if (p == ((void *)0))
 return;
    for (; p; p=p->from)
 if (p->cand && feat_present(p->f, featname))
     item_set(p->cand->item,featname,feat_val(p->f,featname));
    return;
}

variable_types:
featname
char *


decompiled_code:
_BOOL8 __fastcall cmu_is_silence(const char *a1)
{
return strcmp(a1, "pau") == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(const char *a1)
{
return strcmp(a1, "pau") == 0;
}

original_code:
static int cmu_is_silence(const char *p)
{
    if ((strcmp(p,"pau") == 0))
 return TRUE;
    else
 return FALSE;
}

canonical_original_code:
static int cmu_is_silence(char *p)
{
    if ((strcmp(p,"pau") == 0))
 return TRUE;
    else
 return FALSE;
}

variable_types:
p
char *


decompiled_code:
_BOOL8 __fastcall cmu_has_vowel_in_list(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
char *v3; // rax
_BOOL4 v4; // ebp

if ( !a1 )
return 0;
v1 = a1;
while ( 1 )
{
v2 = val_car(a1);
v3 = (char *)val_string(v2);
v4 = cmu_is_vowel(v3);
if ( v4 )
break;
v1 = val_cdr(v1);
if ( !v1 )
return v4;
}
return 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
char *v3; // rax
_BOOL4 v4; // ebp

if ( !a1 )
return 0;
v1 = a1;
while ( 1 )
{
v2 = val_car(a1);
v3 = (char *)val_string(v2);
v4 = func1(v3);
if ( v4 )
break;
v1 = val_cdr(v1);
if ( !v1 )
return v4;
}
return 1;
}

original_code:
static int cmu_has_vowel_in_list(const cst_val *v)
{
    const cst_val *t;
    for (t=v; t; t=val_cdr(t))
 if (cmu_is_vowel(val_string(val_car(v))))
     return TRUE;
    return FALSE;
}

canonical_original_code:
static int cmu_has_vowel_in_list(struct cst_val_struct *v)
{
    struct cst_val_struct *t;
    for (t=v; t; t=val_cdr(t))
 if (cmu_is_vowel(val_string(val_car(v))))
     return TRUE;
    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; } *


decompiled_code:
_BOOL8 __fastcall cmu_has_vowel_in_syl(__int64 a1)
{
__int64 v1; // rbx
char *v2; // rax
_BOOL4 v3; // ebp

v1 = a1;
if ( !a1 )
return 0;
while ( 1 )
{
v2 = (char *)item_feat_string(v1, "name");
v3 = cmu_is_vowel(v2);
if ( v3 )
break;
v1 = item_prev(v1);
if ( !v1 )
return v3;
}
return 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
__int64 v1; // rbx
char *v2; // rax
_BOOL4 v3; // ebp

v1 = a1;
if ( !a1 )
return 0;
while ( 1 )
{
v2 = (char *)item_feat_string(v1, "name");
v3 = func1(v2);
if ( v3 )
break;
v1 = item_prev(v1);
if ( !v1 )
return v3;
}
return 1;
}

original_code:
static int cmu_has_vowel_in_syl(const cst_item *i)
{
    const cst_item *n;
    for (n=i; n; n=item_prev(n))
 if (cmu_is_vowel(item_feat_string(n,"name")))
     return TRUE;
    return FALSE;
}

canonical_original_code:
static int cmu_has_vowel_in_syl(struct cst_item_struct *i)
{
    struct cst_item_struct *n;
    for (n=i; n; n=item_prev(n))
 if (cmu_is_vowel(item_feat_string(n,"name")))
     return TRUE;
    return FALSE;
}

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


decompiled_code:
__int64 __fastcall cmu_sonority(char *a1)
{
_BOOL4 v1; // edx
__int64 result; // rax
_BOOL4 v3; // edx
int v4; // ebx
char *v5; // rdx
char *v6; // rdx

v1 = cmu_is_vowel(a1);
result = 5LL;
if ( !v1 )
{
v3 = cmu_is_silence(a1);
result = 5LL;
if ( !v3 )
{
v4 = *a1;
v5 = strchr("wylr", v4);
result = 4LL;
if ( !v5 )
{
v6 = strchr("nm", v4);
result = 3LL;
if ( !v6 )
result = 1 - ((unsigned int)(strchr("bdgjlmnnnrvwyz", v4) == 0LL) - 1);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
_BOOL4 v1; // edx
__int64 result; // rax
_BOOL4 v3; // edx
int v4; // ebx
char *v5; // rdx
char *v6; // rdx

v1 = func1(a1);
result = 5LL;
if ( !v1 )
{
v3 = func0(a1);
result = 5LL;
if ( !v3 )
{
v4 = *a1;
v5 = strchr("wylr", v4);
result = 4LL;
if ( !v5 )
{
v6 = strchr("nm", v4);
result = 3LL;
if ( !v6 )
result = 1 - ((unsigned int)(strchr("bdgjlmnnnrvwyz", v4) == 0LL) - 1);
}
}
}
return result;
}

original_code:
static int cmu_sonority(const char *p)
{
    if (cmu_is_vowel(p) || (cmu_is_silence(p)))
 return 5;
    else if (strchr("wylr",p[0]) != ((void *)0))
 return 4;
    else if (strchr("nm",p[0]) != ((void *)0))
 return 3;
    else if (strchr("bdgjlmnnnrvwyz",p[0]) != ((void *)0))
 return 2;
    else
 return 1;
}

canonical_original_code:
static int cmu_sonority(char *p)
{
    if (cmu_is_vowel(p) || (cmu_is_silence(p)))
 return 5;
    else if (strchr("wylr",p[0]) != ((void *)0))
 return 4;
    else if (strchr("nm",p[0]) != ((void *)0))
 return 3;
    else if (strchr("bdgjlmnnnrvwyz",p[0]) != ((void *)0))
 return 2;
    else
 return 1;
}


decompiled_code:
__int64 __fastcall cmu_syl_boundary(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
__int64 v3; // rax
const char *v4; // rax
__int64 v6; // rax
char *v7; // rax
char *v8; // rax
int v9; // ebp
__int64 v10; // rax
char *v11; // rax
int v12; // er12
__int64 v13; // rax
__int64 v14; // rax
char *v15; // rax

v2 = 1;
if ( a2 )
{
v3 = val_car(a2);
v4 = (const char *)val_string(v3);
if ( !cmu_is_silence(v4) )
{
v2 = cmu_has_vowel_in_list(a2);
if ( v2 )
{
v2 = cmu_has_vowel_in_syl(a1);
if ( v2 )
{
v6 = val_car(a2);
v7 = (char *)val_string(v6);
v2 = cmu_is_vowel(v7);
if ( v2 )
{
v2 = 1;
}
else if ( val_cdr(a2) )
{
v8 = (char *)item_feat_string(a1, "name");
v9 = cmu_sonority(v8);
v10 = val_car(a2);
v11 = (char *)val_string(v10);
v12 = cmu_sonority(v11);
v13 = val_cdr(a2);
v14 = val_car(v13);
v15 = (char *)val_string(v14);
v2 = (v9 <= v12) & (v12 <= (int)cmu_sonority(v15));
}
}
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
__int64 v3; // rax
const char *v4; // rax
__int64 v6; // rax
char *v7; // rax
char *v8; // rax
int v9; // ebp
__int64 v10; // rax
char *v11; // rax
int v12; // er12
__int64 v13; // rax
__int64 v14; // rax
char *v15; // rax

v2 = 1;
if ( a2 )
{
v3 = val_car(a2);
v4 = (const char *)val_string(v3);
if ( !func0(v4) )
{
v2 = func2(a2);
if ( v2 )
{
v2 = func3(a1);
if ( v2 )
{
v6 = val_car(a2);
v7 = (char *)val_string(v6);
v2 = func1(v7);
if ( v2 )
{
v2 = 1;
}
else if ( val_cdr(a2) )
{
v8 = (char *)item_feat_string(a1, "name");
v9 = func4(v8);
v10 = val_car(a2);
v11 = (char *)val_string(v10);
v12 = func4(v11);
v13 = val_cdr(a2);
v14 = val_car(v13);
v15 = (char *)val_string(v14);
v2 = (v9 <= v12) & (v12 <= (int)func4(v15));
}
}
}
}
}
return v2;
}

original_code:
int cmu_syl_boundary(const cst_item *i,const cst_val *v)
{
    int p, n, nn;
    if (v == ((void *)0))
 return TRUE;
    else if (cmu_is_silence(val_string(val_car(v))))
 return TRUE;
    else if (!cmu_has_vowel_in_list(v))
 return FALSE;
    else if (!cmu_has_vowel_in_syl(i))
 return FALSE;
    else if (cmu_is_vowel(val_string(val_car(v))))
 return TRUE;
    else if (val_cdr(v) == ((void *)0))
 return FALSE;
    else
    {
 p = cmu_sonority(item_feat_string(i,"name"));
 n = cmu_sonority(val_string(val_car(v)));
 nn = cmu_sonority(val_string(val_car(val_cdr(v))));
 if ((p <= n) && (n <= nn))
     return TRUE;
 else
     return FALSE;
    }
}

canonical_original_code:
int cmu_syl_boundary(struct cst_item_struct *i, struct cst_val_struct *v)
{
    int p; int n; int nn;
    if (v == ((void *)0))
 return TRUE;
    else if (cmu_is_silence(val_string(val_car(v))))
 return TRUE;
    else if (!cmu_has_vowel_in_list(v))
 return FALSE;
    else if (!cmu_has_vowel_in_syl(i))
 return FALSE;
    else if (cmu_is_vowel(val_string(val_car(v))))
 return TRUE;
    else if (val_cdr(v) == ((void *)0))
 return FALSE;
    else
    {
 p = cmu_sonority(item_feat_string(i,"name"));
 n = cmu_sonority(val_string(val_car(v)));
 nn = cmu_sonority(val_string(val_car(val_cdr(v))));
 if ((p <= n) && (n <= nn))
     return TRUE;
 else
     return FALSE;
    }
}

variable_types:
v
struct cst_val_struct *

variable_types: p int

variable_types: n int

variable_types: nn int


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

cmu_lex = (__int64)"cmu";
result = cmu_num_entries;
*((_DWORD *)&cmu_lex + 2) = cmu_num_entries;
*(&cmu_lex + 2) = (__int64)&cmu_lex_entry;
*(&cmu_lex + 3) = (__int64)&cmu_lex_phones;
*(&cmu_lex + 4) = (__int64)&cmu_phone_table;
*(&cmu_lex + 6) = (__int64)cmu_syl_boundary;
*(&cmu_lex + 8) = (__int64)addenda;
*(&cmu_lex + 5) = (__int64)&cmu6_lts_rules;
return result;
}

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

cmu_lex = (__int64)"cmu";
result = cmu_num_entries;
*((_DWORD *)&cmu_lex + 2) = cmu_num_entries;
*(&cmu_lex + 2) = (__int64)&cmu_lex_entry;
*(&cmu_lex + 3) = (__int64)&cmu_lex_phones;
*(&cmu_lex + 4) = (__int64)&cmu_phone_table;
*(&cmu_lex + 6) = (__int64)cmu_syl_boundary;
*(&cmu_lex + 8) = (__int64)addenda;
*(&cmu_lex + 5) = (__int64)&cmu6_lts_rules;
return result;
}

original_code:
void cmu_lex_init()
{
    cmu_lex.name = "cmu";
    cmu_lex.num_entries = cmu_num_entries;
    cmu_lex.entry_index = (lexicon_entry *) cmu_lex_entry;
    cmu_lex.phones = (unsigned char *) cmu_lex_phones;
    cmu_lex.phone_table = (char **) cmu_phone_table;
    cmu_lex.syl_boundary = cmu_syl_boundary;
    cmu_lex.addenda = (char ***) addenda;
    cmu_lex.lts_rule_set = (cst_lts_rules *) &cmu6_lts_rules;
}

canonical_original_code:
void cmu_lex_init()
{
    cmu_lex.name = "cmu";
    cmu_lex.num_entries = cmu_num_entries;
    cmu_lex.entry_index = (struct lexicon_entry_struct *) cmu_lex_entry;
    cmu_lex.phones = (unsigned char *) cmu_lex_phones;
    cmu_lex.phone_table = (char **) cmu_phone_table;
    cmu_lex.syl_boundary = cmu_syl_boundary;
    cmu_lex.addenda = (char ***) addenda;
    cmu_lex.lts_rule_set = (struct cst_lts_rules_struct *) &cmu6_lts_rules;
}

user_defined_types: struct lexicon_entry_struct { char *word_pos; int phone_index; }

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

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

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

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


decompiled_code:
__int64 __fastcall wave_val(__int64 a1)
{
return val_new_typed(cst_val_type_wave, a1);
}

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

original_code: cst_val *wave_val(const cst_wave *v) { return val_new_typed(cst_val_type_wave, (void *)v); }

canonical_original_code: struct cst_val_struct *wave_val(struct cst_wave_struct *v) { return val_new_typed(cst_val_type_wave, (void *)v); }

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

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 new_wave()
{
__int64 result; // rax

result = cst_safe_alloc(32LL);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 12) = 0;
*(_QWORD *)(result + 24) = 0LL;
return result;
}

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

result = cst_safe_alloc(32LL);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 12) = 0;
*(_QWORD *)(result + 24) = 0LL;
return result;
}

original_code:
cst_wave *new_wave()
{
    cst_wave *w = ((struct cst_wave_struct *)cst_safe_alloc(sizeof(struct cst_wave_struct)*(1)));
    w->type = ((void *)0);
    w->num_samples = 0;
    w->samples = ((void *)0);
    return w;
}

canonical_original_code:
struct cst_wave_struct *new_wave()
{
    struct cst_wave_struct *w = ((struct cst_wave_struct *)cst_safe_alloc(sizeof(struct cst_wave_struct)*(1)));
    w->type = ((void *)0);
    w->num_samples = 0;
    w->samples = ((void *)0);
    return w;
}

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


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

if ( a1 )
{
cst_free(*(_QWORD *)(a1 + 24));
result = cst_free(a1);
}
return result;
}

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

if ( a1 )
{
cst_free(*(_QWORD *)(a1 + 24));
result = cst_free(a1);
}
return result;
}

original_code:
void delete_wave(cst_wave *w)
{
    if (w)
    {
 cst_free(w->samples);
 cst_free(w);
    }
    return;
}

canonical_original_code:
void delete_wave(struct cst_wave_struct *w)
{
    if (w)
    {
 cst_free(w->samples);
 cst_free(w);
    }
    return;
}


decompiled_code:
__int64 __fastcall val_delete_wave(__int64 a1)
{
return delete_wave(a1);
}

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

original_code: void val_delete_wave(void *v) { delete_wave((cst_wave *)v); }

canonical_original_code: void val_delete_wave(void *v) { delete_wave((struct cst_wave_struct *)v); }

variable_types:
v
void *


decompiled_code:
__int64 __fastcall cst_wave_resize(__int64 a1, __int64 a2, int a3)
{
void *v4; // r13
__int64 result; // rax
int v6; // edx

if ( !a1 )
{
cst_errmsg("cst_wave_resize: null wave given to resize\n", a2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v4 = (void *)cst_safe_alloc((unsigned int)(2 * a3 * a2));
if ( *(_DWORD *)(a1 + 16) == a3 )
{
v6 = a2;
if ( *(_DWORD *)(a1 + 12) <= (int)a2 )
v6 = *(_DWORD *)(a1 + 12);
memmove(v4, *(const void **)(a1 + 24), 2 * a3 * (__int64)v6);
}
result = cst_free(*(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 24) = v4;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 16) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, int a3)
{
void *v4; // r13
__int64 result; // rax
int v6; // edx

if ( !a1 )
{
cst_errmsg("cst_wave_resize: null wave given to resize\n", a2);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v4 = (void *)cst_safe_alloc((unsigned int)(2 * a3 * a2));
if ( *(_DWORD *)(a1 + 16) == a3 )
{
v6 = a2;
if ( *(_DWORD *)(a1 + 12) <= (int)a2 )
v6 = *(_DWORD *)(a1 + 12);
memmove(v4, *(const void **)(a1 + 24), 2 * a3 * (__int64)v6);
}
result = cst_free(*(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 24) = v4;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 16) = a3;
return result;
}

original_code:
void cst_wave_resize(cst_wave *w,int samples, int num_channels)
{
    short *ns;
    if (!w)
    {
 cst_errmsg("cst_wave_resize: null wave given to resize\n");
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    ns = ((short *)cst_safe_alloc(sizeof(short)*(samples*num_channels)));
    if (num_channels == w->num_channels)
 memmove(ns,w->samples,
  sizeof(short) *
  num_channels *
  (samples < w->num_samples ? samples : w->num_samples));
    cst_free(w->samples);
    w->samples = ns;
    w->num_samples = samples;
    w->num_channels = num_channels;
}

canonical_original_code:
void cst_wave_resize(struct cst_wave_struct *w, int samples, int num_channels)
{
    short *ns;
    if (!w)
    {
 cst_errmsg("cst_wave_resize: null wave given to resize\n");
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    ns = ((short *)cst_safe_alloc(sizeof(short)*(samples*num_channels)));
    if (num_channels == w->num_channels)
 memmove(ns,w->samples,
  sizeof(short) *
  num_channels *
  (samples < w->num_samples ? samples : w->num_samples));
    cst_free(w->samples);
    w->samples = ns;
    w->num_samples = samples;
    w->num_channels = num_channels;
}

variable_types: samples int

variable_types:
ns
short *


original_code:
void cst_wave_rescale(cst_wave *w, int factor)
{
 int i;
 for (i = 0; i < w->num_samples; ++i)
  w->samples[i] = ((int)w->samples[i] * factor) / 65536;
}

canonical_original_code:
void cst_wave_rescale(struct cst_wave_struct *w, int factor)
{
 int i;
 for (i = 0; i < w->num_samples; ++i)
  w->samples[i] = ((int)w->samples[i] * factor) / 65536;
}

variable_types: factor int

variable_types: i int


decompiled_code:
__int64 __fastcall cst_wave_resample(__int64 a1, int a2)
{
int v2; // eax
int v3; // er13
unsigned int v4; // ebp
__int64 v5; // rbx
unsigned int v6; // er12
int v7; // eax
__int64 v8; // rbp
unsigned int v9; // er13
__int64 v10; // r14
int v11; // eax
int v12; // eax
int v13; // eax
__int64 v15; // [rsp+8h] [rbp-40h]

v2 = *(_DWORD *)(a1 + 8);
v3 = v2 / 1000;
v4 = a2 / 1000;
if ( a2 <= 999 || v2 <= 999 )
{
cst_errmsg("cst_wave_resample: invalid input/output sample rates (%d, %d)\n", 1000 * v4);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v5 = new_rateconv(v4, (unsigned int)v3, *(unsigned int *)(a1 + 16));
v15 = *(_QWORD *)(a1 + 24);
v6 = *(_DWORD *)(a1 + 12);
v7 = (int)(v6 * v4) / v3 + 2048;
*(_DWORD *)(a1 + 12) = v7;
v8 = cst_safe_alloc((unsigned int)(2 * *(_DWORD *)(a1 + 16) * v7));
*(_QWORD *)(a1 + 24) = v8;
*(_DWORD *)(a1 + 8) = a2;
v9 = *(_DWORD *)(a1 + 12);
v10 = v15;
while ( 1 )
{
v12 = cst_rateconv_in(v5, v10, v6);
if ( v12 <= 0 )
break;
v10 += 2LL * v12;
v6 -= v12;
while ( 1 )
{
v11 = cst_rateconv_out(v5, v8, v9);
if ( v11 <= 0 )
break;
v8 += 2LL * v11;
v9 -= v11;
}
}
cst_rateconv_leadout(v5);
while ( 1 )
{
v13 = cst_rateconv_out(v5, v8, v9);
if ( v13 <= 0 )
break;
v8 += 2LL * v13;
v9 -= v13;
}
cst_free(v15);
return delete_rateconv(v5);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
int v2; // eax
int v3; // er13
unsigned int v4; // ebp
__int64 v5; // rbx
unsigned int v6; // er12
int v7; // eax
__int64 v8; // rbp
unsigned int v9; // er13
__int64 v10; // r14
int v11; // eax
int v12; // eax
int v13; // eax
__int64 v15; // [rsp+8h] [rbp-40h]

v2 = *(_DWORD *)(a1 + 8);
v3 = v2 / 1000;
v4 = a2 / 1000;
if ( a2 <= 999 || v2 <= 999 )
{
cst_errmsg("cst_wave_resample: invalid input/output sample rates (%d, %d)\n", 1000 * v4);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v5 = new_rateconv(v4, (unsigned int)v3, *(unsigned int *)(a1 + 16));
v15 = *(_QWORD *)(a1 + 24);
v6 = *(_DWORD *)(a1 + 12);
v7 = (int)(v6 * v4) / v3 + 2048;
*(_DWORD *)(a1 + 12) = v7;
v8 = cst_safe_alloc((unsigned int)(2 * *(_DWORD *)(a1 + 16) * v7));
*(_QWORD *)(a1 + 24) = v8;
*(_DWORD *)(a1 + 8) = a2;
v9 = *(_DWORD *)(a1 + 12);
v10 = v15;
while ( 1 )
{
v12 = cst_rateconv_in(v5, v10, v6);
if ( v12 <= 0 )
break;
v10 += 2LL * v12;
v6 -= v12;
while ( 1 )
{
v11 = cst_rateconv_out(v5, v8, v9);
if ( v11 <= 0 )
break;
v8 += 2LL * v11;
v9 -= v11;
}
}
cst_rateconv_leadout(v5);
while ( 1 )
{
v13 = cst_rateconv_out(v5, v8, v9);
if ( v13 <= 0 )
break;
v8 += 2LL * v13;
v9 -= v13;
}
cst_free(v15);
return delete_rateconv(v5);
}

original_code:
void cst_wave_resample(cst_wave *w, int sample_rate)
{
 cst_rateconv *filt;
 int up, down;
 short *in;
 const short *inptr;
 short *outptr;
 int n, insize, outsize;
 down = w->sample_rate / 1000;
 up = sample_rate / 1000;
 if (up < 1 || down < 1) {
  cst_errmsg("cst_wave_resample: invalid input/output sample rates (%d, %d)\n",
      up * 1000, down * 1000);
  (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
 }
 filt = new_rateconv(up, down, w->num_channels);
 inptr = in = w->samples;
 insize = w->num_samples;
 w->num_samples = w->num_samples * up / down + 2048;
 w->samples = ((short *)cst_safe_alloc(sizeof(short)*(w->num_samples * w->num_channels)));
 w->sample_rate = sample_rate;
 outptr = w->samples;
 outsize = w->num_samples;
 while ((n = cst_rateconv_in(filt, inptr, insize)) > 0) {
  inptr += n;
  insize -= n;
  while ((n = cst_rateconv_out(filt, outptr, outsize)) > 0) {
   outptr += n;
   outsize -= n;
  }
  }
 cst_rateconv_leadout(filt);
 while ((n = cst_rateconv_out(filt, outptr, outsize)) > 0) {
  outptr += n;
  outsize -= n;
 }
 cst_free(in);
 delete_rateconv(filt);
}

canonical_original_code:
void cst_wave_resample(struct cst_wave_struct *w, int sample_rate)
{
 struct cst_rateconv_struct *filt;
 int up; int down;
 short *in;
 short *inptr;
 short *outptr;
 int n; int insize; int outsize;
 down = w->sample_rate / 1000;
 up = sample_rate / 1000;
 if (up < 1 || down < 1) {
  cst_errmsg("cst_wave_resample: invalid input/output sample rates (%d, %d)\n",
      up * 1000, down * 1000);
  (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
 }
 filt = new_rateconv(up, down, w->num_channels);
 inptr = in = w->samples;
 insize = w->num_samples;
 w->num_samples = w->num_samples * up / down + 2048;
 w->samples = ((short *)cst_safe_alloc(sizeof(short)*(w->num_samples * w->num_channels)));
 w->sample_rate = sample_rate;
 outptr = w->samples;
 outsize = w->num_samples;
 while ((n = cst_rateconv_in(filt, inptr, insize)) > 0) {
  inptr += n;
  insize -= n;
  while ((n = cst_rateconv_out(filt, outptr, outsize)) > 0) {
   outptr += n;
   outsize -= n;
  }
  }
 cst_rateconv_leadout(filt);
 while ((n = cst_rateconv_out(filt, outptr, outsize)) > 0) {
  outptr += n;
  outsize -= n;
 }
 cst_free(in);
 delete_rateconv(filt);
}

variable_types: struct cst_rateconv_struct { int channels; int up; double gain; int lag; int *sin; int insize; int incount; int len; double fsin; int inbaseidx; } *

variable_types: up int

variable_types: down int

variable_types:
in
short *

variable_types:
inptr
short *

variable_types:
outptr
short *

variable_types: insize int

variable_types: outsize int


original_code:
cst_wave *copy_wave(const cst_wave *w)
{
    cst_wave *n = new_wave();
    cst_wave_resize(n,w->num_samples,w->num_channels);
    n->sample_rate = w->sample_rate;
    n->num_channels = w->num_channels;
    n->type = w->type;
    memcpy(n->samples,w->samples,sizeof(short)*w->num_samples*w->num_channels);
    return n;
}

canonical_original_code:
struct cst_wave_struct *copy_wave(struct cst_wave_struct *w)
{
    struct cst_wave_struct *n = new_wave();
    cst_wave_resize(n,w->num_samples,w->num_channels);
    n->sample_rate = w->sample_rate;
    n->num_channels = w->num_channels;
    n->type = w->type;
    memcpy(n->samples,w->samples,sizeof(short)*w->num_samples*w->num_channels);
    return n;
}

variable_types:
w
struct cst_wave_struct *


decompiled_code:
__int64 __fastcall concat_wave(__int64 a1, __int64 a2)
{
__int64 v3; // rsi
unsigned int v4; // eax
int v5; // eax
int v6; // er12

v3 = *(unsigned int *)(a1 + 16);
if ( (_DWORD)v3 != *(_DWORD *)(a2 + 16) )
{
cst_errmsg("concat_wave: channel count mismatch (%d != %d)\n", v3);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v4 = *(_DWORD *)(a1 + 8);
if ( v4 != *(_DWORD *)(a2 + 8) )
{
cst_errmsg("concat_wave: sample rate mismatch (%d != %d)\n", v4);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v5 = *(_DWORD *)(a1 + 12);
v6 = v5 * v3;
cst_wave_resize(a1, (unsigned int)(*(_DWORD *)(a2 + 12) + v5), v3);
memcpy(
(void *)(*(_QWORD *)(a1 + 24) + 2LL * v6),
*(const void **)(a2 + 24),
2LL * *(_DWORD *)(a2 + 16) * *(_DWORD *)(a2 + 12));
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
__int64 v3; // rsi
unsigned int v4; // eax
int v5; // eax
int v6; // er12

v3 = *(unsigned int *)(a1 + 16);
if ( (_DWORD)v3 != *(_DWORD *)(a2 + 16) )
{
cst_errmsg("concat_wave: channel count mismatch (%d != %d)\n", v3);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v4 = *(_DWORD *)(a1 + 8);
if ( v4 != *(_DWORD *)(a2 + 8) )
{
cst_errmsg("concat_wave: sample rate mismatch (%d != %d)\n", v4);
if ( cst_errjmp )
longjmp(cst_errjmp, 1);
exit(-1);
}
v5 = *(_DWORD *)(a1 + 12);
v6 = v5 * v3;
func5(a1, (unsigned int)(*(_DWORD *)(a2 + 12) + v5), v3);
memcpy(
(void *)(*(_QWORD *)(a1 + 24) + 2LL * v6),
*(const void **)(a2 + 24),
2LL * *(_DWORD *)(a2 + 16) * *(_DWORD *)(a2 + 12));
return a1;
}

original_code:
cst_wave *concat_wave(cst_wave *dest, const cst_wave *src)
{
    int orig_nsamps;
    if (dest->num_channels != src->num_channels)
    {
 cst_errmsg("concat_wave: channel count mismatch (%d != %d)\n",
     dest->num_channels, src->num_channels);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    if (dest->sample_rate != src->sample_rate)
    {
 cst_errmsg("concat_wave: sample rate mismatch (%d != %d)\n",
     dest->sample_rate, src->sample_rate);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    orig_nsamps = dest->num_samples * dest->num_channels;
    cst_wave_resize(dest, dest->num_samples + src->num_samples,
      dest->num_channels);
    memcpy(dest->samples + orig_nsamps, src->samples,
    src->num_samples * src->num_channels * sizeof(short));
    return dest;
}

canonical_original_code:
struct cst_wave_struct *concat_wave(struct cst_wave_struct *dest, struct cst_wave_struct *src)
{
    int orig_nsamps;
    if (dest->num_channels != src->num_channels)
    {
 cst_errmsg("concat_wave: channel count mismatch (%d != %d)\n",
     dest->num_channels, src->num_channels);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    if (dest->sample_rate != src->sample_rate)
    {
 cst_errmsg("concat_wave: sample rate mismatch (%d != %d)\n",
     dest->sample_rate, src->sample_rate);
 (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
    orig_nsamps = dest->num_samples * dest->num_channels;
    cst_wave_resize(dest, dest->num_samples + src->num_samples,
      dest->num_channels);
    memcpy(dest->samples + orig_nsamps, src->samples,
    src->num_samples * src->num_channels * sizeof(short));
    return dest;
}

variable_types:
dest
struct cst_wave_struct *

variable_types:
src
struct cst_wave_struct *


decompiled_code:
__int64 new_ss()
{
return cst_safe_alloc(24LL);
}

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

original_code:
cst_ss *new_ss()
{
    cst_ss *ss = ((cst_ss *)cst_safe_alloc(sizeof(cst_ss)*(1)));
    return ss;
}

canonical_original_code:
struct cst_ss_struct *new_ss()
{
    struct cst_ss_struct *ss = ((cst_ss *)cst_safe_alloc(sizeof(cst_ss)*(1)));
    return ss;
}

variable_types: struct cst_ss_struct { double num_samples; double sum; double sumx; } *


decompiled_code:
__int64 delete_ss()
{
return cst_free();
}

canonical_decompiled_code:
__int64 func1()
{
return cst_free();
}

original_code:
void delete_ss(cst_ss *ss)
{
    cst_free(ss);
}

canonical_original_code:
void delete_ss(struct cst_ss_struct *ss)
{
    cst_free(ss);
}

user_defined_types: struct cst_ss_struct { double num_samples; double sum; double sumx; }


decompiled_code:
double __fastcall ss_mean(double *a1)
{
double result; // xmm0_8

if ( *a1 <= 0.0 )
result = 0.0;
else
result = a1[1] / *a1;
return result;
}

canonical_decompiled_code:
double __fastcall func3(double *a1)
{
double result; // xmm0_8

if ( *a1 <= 0.0 )
result = 0.0;
else
result = a1[1] / *a1;
return result;
}

original_code:
double ss_mean(cst_ss *ss)
{
    if (ss->num_samples > 0)
 return ss->sum/ss->num_samples;
    else
 return 0;
}

canonical_original_code:
double ss_mean(struct cst_ss_struct *ss)
{
    if (ss->num_samples > 0)
 return ss->sum/ss->num_samples;
    else
 return 0;
}

return_type: double


decompiled_code:
double __fastcall ss_variance(double *a1)
{
double result; // xmm0_8

if ( *a1 <= 1.0 )
result = 0.0;
else
result = (*a1 * a1[2] - a1[1] * a1[1]) / (*a1 * (*a1 - 1.0));
return result;
}

canonical_decompiled_code:
double __fastcall func4(double *a1)
{
double result; // xmm0_8

if ( *a1 <= 1.0 )
result = 0.0;
else
result = (*a1 * a1[2] - a1[1] * a1[1]) / (*a1 * (*a1 - 1.0));
return result;
}

original_code:
double ss_variance(cst_ss *ss)
{
    if (ss->num_samples > 1)
 return ((ss->num_samples*ss->sumx)-(ss->sum*ss->sum))/
     (ss->num_samples*(ss->num_samples-1));
    else
 return 0;
}

canonical_original_code:
double ss_variance(struct cst_ss_struct *ss)
{
    if (ss->num_samples > 1)
 return ((ss->num_samples*ss->sumx)-(ss->sum*ss->sum))/
     (ss->num_samples*(ss->num_samples-1));
    else
 return 0;
}


decompiled_code:
double __fastcall ss_stddev(double *a1)
{
double v1; // xmm0_8
double result; // xmm0_8

v1 = ss_variance(a1);
if ( v1 < 0.0 )
result = sqrt(v1);
else
result = sqrt(v1);
return result;
}

canonical_decompiled_code:
double __fastcall func5(double *a1)
{
double v1; // xmm0_8
double result; // xmm0_8

v1 = func4(a1);
if ( v1 < 0.0 )
result = sqrt(v1);
else
result = sqrt(v1);
return result;
}

original_code:
double ss_stddev(cst_ss *ss)
{
    return sqrt(ss_variance(ss));
}

canonical_original_code:
double ss_stddev(struct cst_ss_struct *ss)
{
    return sqrt(ss_variance(ss));
}


original_code:
void ss_cummulate(cst_ss *ss,double a)
{
    ss->sum += a;
    ss->sumx += a*a;
    ss->num_samples++;
}

canonical_original_code:
void ss_cummulate(struct cst_ss_struct *ss, double a)
{
    ss->sum += a;
    ss->sumx += a*a;
    ss->num_samples++;
}

variable_types: a double


decompiled_code:
void __fastcall ss_cummulate_n(double *a1, double a2, double a3)
{
a1[1] = a2 * a3 + a1[1];
a1[2] = a2 * a2 * a3 + a1[2];
*a1 = a3 + *a1;
}

original_code:
void ss_cummulate_n(cst_ss *ss,double a, double count)
{
    ss->sum += a*count;
    ss->sumx += (a*a)*count;
    ss->num_samples += count;
}

canonical_original_code:
void ss_cummulate_n(struct cst_ss_struct *ss, double a, double count)
{
    ss->sum += a*count;
    ss->sumx += (a*a)*count;
    ss->num_samples += count;
}

variable_types: count double


decompiled_code:
char *__fastcall cst_strrchr(const char *a1, int a2)
{
return strrchr(a1, a2);
}

canonical_decompiled_code:
char *__fastcall func0(const char *a1, int a2)
{
return strrchr(a1, a2);
}

original_code:
char *cst_strrchr(const char *str, int c)
{
    return strrchr(str, c);
}

canonical_original_code:
char *cst_strrchr(char *str, int c)
{
    return strrchr(str, c);
}

variable_types:
str
char *

variable_types: c int

return_type: char *


decompiled_code:
double __fastcall cst_atof(const char *a1)
{
return atof(a1);
}

canonical_decompiled_code:
double __fastcall func1(const char *a1)
{
return atof(a1);
}

original_code:
double cst_atof(const char *str)
{
    return atof(str);
}

canonical_original_code:
double cst_atof(char *str)
{
    return atof(str);
}


decompiled_code:
char *__fastcall cst_strdup(char *src)
{
char *v1; // rbp
int v2; // eax

v1 = src;
if ( src )
{
v2 = strlen(src);
v1 = (char *)cst_safe_alloc((unsigned int)(v2 + 1));
strcpy(v1, src);
}
return v1;
}

canonical_decompiled_code:
char *__fastcall func2(char *src)
{
char *v1; // rbp
int v2; // eax

v1 = src;
if ( src )
{
v2 = strlen(src);
v1 = (char *)cst_safe_alloc((unsigned int)(v2 + 1));
strcpy(v1, src);
}
return v1;
}

original_code:
char *cst_strdup(const char *str)
{
   char *nstr = ((void *)0);
   if (str)
   {
      nstr = ((char *)cst_safe_alloc(sizeof(char)*(strlen(str)+1)));
      strcpy(nstr,str);
   }
   return nstr;
}

canonical_original_code:
char *cst_strdup(char *str)
{
   char *nstr = ((void *)0);
   if (str)
   {
      nstr = ((char *)cst_safe_alloc(sizeof(char)*(strlen(str)+1)));
      strcpy(nstr,str);
   }
   return nstr;
}

variable_types:
nstr
char *


decompiled_code:
char *__fastcall cst_substr(char *a1, int a2, int a3)
{
char *v3; // r12

v3 = a1;
if ( a1 )
{
v3 = (char *)cst_safe_alloc((unsigned int)(a3 + 1));
strncpy(v3, &a1[a2], a3);
v3[a3] = 0;
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func3(char *a1, int a2, int a3)
{
char *v3; // r12

v3 = a1;
if ( a1 )
{
v3 = (char *)cst_safe_alloc((unsigned int)(a3 + 1));
strncpy(v3, &a1[a2], a3);
v3[a3] = 0;
}
return v3;
}

original_code:
char *cst_substr(const char *str,int start, int length)
{
   char *nstr = ((void *)0);
   if (str)
   {
      nstr = ((char *)cst_safe_alloc(sizeof(char)*(length+1)));
      strncpy(nstr,str+start,length);
      nstr[length] = '\0';
   }
   return nstr;
}

canonical_original_code:
char *cst_substr(char *str, int start, int length)
{
   char *nstr = ((void *)0);
   if (str)
   {
      nstr = ((char *)cst_safe_alloc(sizeof(char)*(length+1)));
      strncpy(nstr,str+start,length);
      nstr[length] = '\0';
   }
   return nstr;
}

variable_types: start int

variable_types: length int


decompiled_code:
char *__fastcall cst_string_before(char *src, const char *a2)
{
char *v2; // r12
char *v3; // rbp
size_t v4; // rbx

v2 = strstr(src, a2);
v3 = cst_strdup(src);
v4 = strlen(src);
v3[v4 - strlen(v2)] = 0;
return v3;
}

canonical_decompiled_code:
char *__fastcall func4(char *src, const char *a2)
{
char *v2; // r12
char *v3; // rbp
size_t v4; // rbx

v2 = strstr(src, a2);
v3 = func2(src);
v4 = strlen(src);
v3[v4 - strlen(v2)] = 0;
return v3;
}

original_code:
char *cst_string_before(const char *s,const char *c)
{
    char *p;
    char *q;
    p = strstr(s,c);
    q = cst_strdup(s);
    q[strlen(s)-strlen(p)] = '\0';
    return q;
}

canonical_original_code:
char *cst_string_before(char *s, char *c)
{
    char *p;
    char *q;
    p = strstr(s,c);
    q = cst_strdup(s);
    q[strlen(s)-strlen(p)] = '\0';
    return q;
}

variable_types:
s
char *

variable_types:
c
char *

variable_types:
p
char *

variable_types:
q
char *


decompiled_code:
char *__fastcall cst_downcase(char *a1)
{
char *v1; // r14
char v2; // bl
const unsigned __int16 **v3; // r13
char *v4; // rbp
char *v5; // r12

v1 = cst_strdup(a1);
v2 = *a1;
if ( *a1 )
{
v3 = _ctype_b_loc();
v4 = a1 + 1;
v5 = v1;
do
{
if ( ((*v3)[v2] & 0x100) != 0 )
*v5 = tolower(v2);
v2 = *v4++;
++v5;
}
while ( v2 );
}
return v1;
}

original_code:
char *cst_downcase(const char *str)
{
   char *dc;
   int i;
   dc = cst_strdup(str);
   for (i=0; str[i] != '\0'; i++)
   {
      if (((*__ctype_b_loc ())[(int) (((int)str[i]))] & (unsigned short int) _ISupper))
         dc[i] = tolower((int)str[i]);
   }
   return dc;
}

canonical_original_code:
char *cst_downcase(char *str)
{
   char *dc;
   int i;
   dc = cst_strdup(str);
   for (i=0; str[i] != '\0'; i++)
   {
      if (((*__ctype_b_loc ())[(int) (((int)str[i]))] & (unsigned short) _ISupper))
         dc[i] = tolower((int)str[i]);
   }
   return dc;
}

variable_types:
dc
char *

variable_types: i int


decompiled_code:
char *__fastcall cst_upcase(char *a1)
{
char *v1; // r14
char v2; // bl
const unsigned __int16 **v3; // r13
char *v4; // rbp
char *v5; // r12

v1 = cst_strdup(a1);
v2 = *a1;
if ( *a1 )
{
v3 = _ctype_b_loc();
v4 = a1 + 1;
v5 = v1;
do
{
if ( ((*v3)[v2] & 0x200) != 0 )
*v5 = toupper(v2);
v2 = *v4++;
++v5;
}
while ( v2 );
}
return v1;
}

original_code:
char *cst_upcase(const char *str)
{
   char *uc;
   int i;
   uc = cst_strdup(str);
   for (i=0; str[i] != '\0'; i++)
   {
      if (((*__ctype_b_loc ())[(int) (((int)str[i]))] & (unsigned short int) _ISlower))
         uc[i] = toupper((int)str[i]);
   }
   return uc;
}

canonical_original_code:
char *cst_upcase(char *str)
{
   char *uc;
   int i;
   uc = cst_strdup(str);
   for (i=0; str[i] != '\0'; i++)
   {
      if (((*__ctype_b_loc ())[(int) (((int)str[i]))] & (unsigned short) _ISlower))
         uc[i] = toupper((int)str[i]);
   }
   return uc;
}

variable_types:
uc
char *


decompiled_code:
_BOOL8 __fastcall cst_member_string(char *s2, const char **a2)
{
const char **v2; // rbx
const char *i; // rbp

v2 = a2;
for ( i = *a2; *v2; i = *v2 )
{
if ( !strcmp(i, s2) )
break;
++v2;
}
return i != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(char *s2, const char **a2)
{
const char **v2; // rbx
const char *i; // rbp

v2 = a2;
for ( i = *a2; *v2; i = *v2 )
{
if ( !strcmp(i, s2) )
break;
++v2;
}
return i != 0LL;
}

original_code:
int cst_member_string(const char *str, const char * const *slist)
{
   const char * const *p;
   for (p = slist; *p; ++p)
      if ((strcmp(*p,str) == 0))
         break;
   return *p != ((void *)0);
}

canonical_original_code:
int cst_member_string(char *str, char **slist)
{
   char **p;
   for (p = slist; *p; ++p)
      if ((strcmp(*p,str) == 0))
         break;
   return *p != ((void *)0);
}

variable_types:
slist
char **

variable_types:
p
char **


decompiled_code:
__int64 __fastcall extend_buffer(const void **a1, unsigned int *a2)
{
unsigned int v2; // ebx
void *v3; // r13
__int64 result; // rax

v2 = *a2 + (int)*a2 / 5;
v3 = (void *)cst_safe_alloc(v2);
memmove(v3, *a1, (int)*a2);
result = cst_free(*a1);
*a1 = v3;
*a2 = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const void **a1, unsigned int *a2)
{
unsigned int v2; // ebx
void *v3; // r13
__int64 result; // rax

v2 = *a2 + (int)*a2 / 5;
v3 = (void *)cst_safe_alloc(v2);
memmove(v3, *a1, (int)*a2);
result = cst_free(*a1);
*a1 = v3;
*a2 = v2;
return result;
}

original_code:
static void extend_buffer(char **buffer,int *buffer_max)
{
    int new_max;
    char *new_buffer;
    new_max = (*buffer_max)+(*buffer_max)/5;
    new_buffer = ((char *)cst_safe_alloc(sizeof(char)*(new_max)));
    memmove(new_buffer,*buffer,*buffer_max);
    cst_free(*buffer);
    *buffer = new_buffer;
    *buffer_max = new_max;
}

canonical_original_code:
static void extend_buffer(char **buffer, int *buffer_max)
{
    int new_max;
    char *new_buffer;
    new_max = (*buffer_max)+(*buffer_max)/5;
    new_buffer = ((char *)cst_safe_alloc(sizeof(char)*(new_max)));
    memmove(new_buffer,*buffer,*buffer_max);
    cst_free(*buffer);
    *buffer = new_buffer;
    *buffer_max = new_max;
}

variable_types:
buffer
char **


original_code:
size_t cst_regsub(const cst_regstate *state, const char *in, char *out, size_t max)
{
 const char *src;
 char *dst;
 int c, no, len;
 size_t count;
 if (state == ((void *)0) || in == ((void *)0)) {
  cst_errmsg("NULL parm to regsub\n");
  (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
 }
 src = in;
 dst = out;
 count = 0;
 while ((c = *src++) != '\0') {
  if (out && dst + 1 > out + max - 1)
   break;
  if (c == '&')
   no = 0;
  else if (c == '\\' && '0' <= *src && *src <= '9')
   no = *src++ - '0';
  else
   no = -1;
   if (no < 0) {
    if (c == '\\' && (*src == '\\' || *src == '&'))
     c = *src++;
   if (out)
    *dst++ = c;
   count++;
   } else if (state->startp[no] != ((void *)0) && state->endp[no] != ((void *)0)) {
   len = state->endp[no] - state->startp[no];
   if (out) {
    if (dst + len > out + max - 1)
     len = (out + max - 1) - dst;
    strncpy(dst, state->startp[no], len);
    dst += len;
    if (len != 0 && *(dst-1) == '\0') {
     cst_errmsg("damaged match string");
     (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
   }
   count += len;
  }
 }
 if (out && dst - out + 1 < max)
  *dst++ = '\0';
 return count;
}

canonical_original_code:
unsigned long cst_regsub(struct cst_regstate_struct *state, char *in, char *out, unsigned long max)
{
 char *src;
 char *dst;
 int c; int no; int len;
 unsigned long count;
 if (state == ((void *)0) || in == ((void *)0)) {
  cst_errmsg("NULL parm to regsub\n");
  (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
 }
 src = in;
 dst = out;
 count = 0;
 while ((c = *src++) != '\0') {
  if (out && dst + 1 > out + max - 1)
   break;
  if (c == '&')
   no = 0;
  else if (c == '\\' && '0' <= *src && *src <= '9')
   no = *src++ - '0';
  else
   no = -1;
   if (no < 0) {
    if (c == '\\' && (*src == '\\' || *src == '&'))
     c = *src++;
   if (out)
    *dst++ = c;
   count++;
   } else if (state->startp[no] != ((void *)0) && state->endp[no] != ((void *)0)) {
   len = state->endp[no] - state->startp[no];
   if (out) {
    if (dst + len > out + max - 1)
     len = (out + max - 1) - dst;
    strncpy(dst, state->startp[no], len);
    dst += len;
    if (len != 0 && *(dst-1) == '\0') {
     cst_errmsg("damaged match string");
     (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1));
    }
   }
   count += len;
  }
 }
 if (out && dst - out + 1 < max)
  *dst++ = '\0';
 return count;
}

variable_types: struct cst_regstate_struct { char *startp[10]; char *endp[10]; char *input; char *bol; } *

variable_types:
in
char *

variable_types:
out
char *

variable_types:
max
unsigned long

variable_types:
src
char *

variable_types:
dst
char *

variable_types: no int

variable_types: len int

variable_types:
count
unsigned long

return_type: unsigned long


VocabHash

decompiled_code:
__int64 __fastcall VocabHash(unsigned int a1)
{
return a1 % 0x2BD;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
return a1 % 0x2BD;
}

original_code:
static int VocabHash(LabId name)
{
   return (int) (((unsigned) name)%701);
}

canonical_original_code:
static int VocabHash(struct _NameCell *name)
{
   return (int) (((unsigned int) name)%701);
}

variable_types: struct _NameCell { char *name; void *aux; struct _NameCell *next; unsigned short lmid; } *


decompiled_code:
int __fastcall Wd_Cmp(const void *a1, const void *a2)
{
return strcmp(***(const char ****)a1, ***(const char ****)a2);
}

canonical_decompiled_code:
int __fastcall func3(const void *a1, const void *a2)
{
return strcmp(***(const char ****)a1, ***(const char ****)a2);
}

original_code:
static int Wd_Cmp(const void *v1,const void *v2)
{
   Word w1,w2;
   w1=*(Word*)v1; w2=*(Word*)v2;
   return(strcmp(w1->wordName->name,w2->wordName->name));
}

canonical_original_code:
static int Wd_Cmp(void *v1, void *v2)
{
   struct _DictEntry *w1; struct _DictEntry *w2;
   w1=*(struct _DictEntry **)v1; w2=*(struct _DictEntry **)v2;
   return(strcmp(w1->wordName->name,w2->wordName->name));
}

variable_types: struct _DictEntry { struct _NameCell { char *name; void *aux; struct _NameCell *next; unsigned short lmid; } *wordName; struct _WordPron { short pnum; short nphones; struct _NameCell **phones; float prob; struct _NameCell *outSym; struct _DictEntry *word; struct _WordPron *next; } *pron; int nprons; struct _DictEntry *next; void *aux; } *

user_defined_types: struct _DictEntry { struct _NameCell *wordName; struct _WordPron *pron; int nprons; struct _DictEntry *next; void *aux; }


InitDict

decompiled_code:
__int64 InitDict()
{
__int64 result; // rax
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

Register(hdict_version);
result = GetConfig("HDICT", 1LL, &cParm, 256LL);
if ( (int)result > 0 )
{
result = GetConfInt(&cParm, (unsigned int)result, "TRACE", v1);
if ( (_DWORD)result )
{
result = v1[0];
trace = v1[0];
}
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

Register(hdict_version);
result = GetConfig("HDICT", 1LL, &cParm, 256LL);
if ( (int)result > 0 )
{
result = GetConfInt(&cParm, (unsigned int)result, "TRACE", v1);
if ( (_DWORD)result )
{
result = v1[0];
trace = v1[0];
}
}
return result;
}

original_code:
void InitDict(void)
{
   int i;
   Register(hdict_version);
   nParm = GetConfig("HDICT", TRUE, cParm, 256);
   if (nParm>0){
      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;
   }
}

canonical_original_code:
void InitDict()
{
   int i;
   Register(hdict_version);
   nParm = GetConfig("HDICT", TRUE, cParm, 256);
   if (nParm>0){
      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;
   }
}


decompiled_code:
__int64 __fastcall apostrophe_s(_QWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rax
__int64 result; // rax
__int64 i; // rbx
__int64 v7; // rax
__int64 v8; // r12
char *v9; // rax
char *v10; // rax
__int64 v11; // rax
const char *v12; // rax
__int64 v13; // r12
__int64 v14; // rax

v1 = feat_val(*a1, "phoneset");
v2 = val_phoneset(v1);
v3 = utt_relation(a1, "Segment");
v4 = relation_head(v3);
result = item_next(v4);
for ( i = result; result; i = result )
{
v11 = ffeature(i, "R:SylStructure.parent.parent.name");
v12 = (const char *)val_string(v11);
if ( !strcmp("'s", v12) )
{
v7 = item_prev(i);
v8 = item_feat_string(v7, "name");
v9 = (char *)phone_feature_string(v2, v8, "ctype");
if ( !strchr("fa", *v9) || (v10 = (char *)phone_feature_string(v2, v8, "cplace"), strchr("dbg", *v10)) )
{
if ( !strcmp("-", (const char *)phone_feature_string(v2, v8, "cvox")) )
item_set_string(i, "name", "s");
goto LABEL_10;
}
}
else if ( strcmp("'ve", v12) && strcmp("'ll", v12) && strcmp("'d", v12)
|| strcmp("-", (const char *)ffeature_string(i, "p.ph_vc")) )
{
goto LABEL_10;
}
v13 = item_prepend(i, 0LL);
item_set_string(v13, "name", "ax");
v14 = item_as(i, "SylStructure");
item_prepend(v14, v13);
LABEL_10:
result = item_next(i);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rax
__int64 result; // rax
__int64 i; // rbx
__int64 v7; // rax
__int64 v8; // r12
char *v9; // rax
char *v10; // rax
__int64 v11; // rax
const char *v12; // rax
__int64 v13; // r12
__int64 v14; // rax

v1 = feat_val(*a1, "phoneset");
v2 = val_phoneset(v1);
v3 = utt_relation(a1, "Segment");
v4 = relation_head(v3);
result = item_next(v4);
for ( i = result; result; i = result )
{
v11 = ffeature(i, "R:SylStructure.parent.parent.name");
v12 = (const char *)val_string(v11);
if ( !strcmp("'s", v12) )
{
v7 = item_prev(i);
v8 = item_feat_string(v7, "name");
v9 = (char *)phone_feature_string(v2, v8, "ctype");
if ( !strchr("fa", *v9) || (v10 = (char *)phone_feature_string(v2, v8, "cplace"), strchr("dbg", *v10)) )
{
if ( !strcmp("-", (const char *)phone_feature_string(v2, v8, "cvox")) )
item_set_string(i, "name", "s");
goto LABEL_10;
}
}
else if ( strcmp("'ve", v12) && strcmp("'ll", v12) && strcmp("'d", v12)
|| strcmp("-", (const char *)ffeature_string(i, "p.ph_vc")) )
{
goto LABEL_10;
}
v13 = item_prepend(i, 0LL);
item_set_string(v13, "name", "ax");
v14 = item_as(i, "SylStructure");
item_prepend(v14, v13);
LABEL_10:
result = item_next(i);
}
return result;
}

original_code:
static void apostrophe_s(cst_utterance *u)
{
   cst_item *s;
   cst_item *schwa;
   cst_phoneset *ps=0;
   const char *pname, *word;
   ps = val_phoneset(feat_val(u->features,"phoneset"));
   for (s=item_next(relation_head(utt_relation(u,"Segment")));
      s; s=item_next(s))
   {
      word = val_string(ffeature(s, "R:SylStructure.parent.parent.name"));
      if ((strcmp("'s",word) == 0))
      {
         pname = item_feat_string(item_prev(s),"name");
         if ((strchr("fa",*phone_feature_string(ps,pname,"ctype")) != ((void *)0))
            && (strchr("dbg",
            *phone_feature_string(ps,pname,"cplace")) == ((void *)0)))
         {
            schwa = item_prepend(s,((void *)0));
            item_set_string(schwa,"name","ax");
            item_prepend(item_as(s,"SylStructure"),schwa);
         }
         else if ((strcmp("-",phone_feature_string(ps,pname,"cvox")) == 0))
            item_set_string(s,"name","s");
      }
      else if ((strcmp("'ve",word) == 0)
         || (strcmp("'ll",word) == 0)
         || (strcmp("'d",word) == 0))
      {
         if ((strcmp("-",ffeature_string(s,"p.ph_vc")) == 0))
         {
            schwa = item_prepend(s,((void *)0));
            item_set_string(schwa,"name","ax");
            item_prepend(item_as(s,"SylStructure"),schwa);
         }
      }
   }
}

canonical_original_code:
static void apostrophe_s(struct cst_utterance_struct *u)
{
   struct cst_item_struct *s;
   struct cst_item_struct *schwa;
   struct cst_phoneset_struct *ps = 0;
   char *pname; char *word;
   ps = val_phoneset(feat_val(u->features,"phoneset"));
   for (s=item_next(relation_head(utt_relation(u,"Segment")));
      s; s=item_next(s))
   {
      word = val_string(ffeature(s, "R:SylStructure.parent.parent.name"));
      if ((strcmp("'s",word) == 0))
      {
         pname = item_feat_string(item_prev(s),"name");
         if ((strchr("fa",*phone_feature_string(ps,pname,"ctype")) != ((void *)0))
            && (strchr("dbg",
            *phone_feature_string(ps,pname,"cplace")) == ((void *)0)))
         {
            schwa = item_prepend(s,((void *)0));
            item_set_string(schwa,"name","ax");
            item_prepend(item_as(s,"SylStructure"),schwa);
         }
         else if ((strcmp("-",phone_feature_string(ps,pname,"cvox")) == 0))
            item_set_string(s,"name","s");
      }
      else if ((strcmp("'ve",word) == 0)
         || (strcmp("'ll",word) == 0)
         || (strcmp("'d",word) == 0))
      {
         if ((strcmp("-",ffeature_string(s,"p.ph_vc")) == 0))
         {
            schwa = item_prepend(s,((void *)0));
            item_set_string(schwa,"name","ax");
            item_prepend(item_as(s,"SylStructure"),schwa);
         }
      }
   }
}

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

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

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

variable_types:
pname
char *

variable_types:
word
char *

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 the_iy_ax(__int64 a1)
{
__int64 v1; // rax
__int64 result; // rax
__int64 i; // rbx

v1 = utt_relation(a1, "Segment");
result = relation_head(v1);
for ( i = result; result; i = result )
{
if ( !strcmp("ax", (const char *)item_feat_string(i, "name"))
&& !strcmp("the", (const char *)ffeature_string(i, "R:SylStructure.parent.parent.name"))
&& !strcmp("+", (const char *)ffeature_string(i, "n.ph_vc")) )
{
item_set_string(i, "name", "iy");
}
result = item_next(i);
}
return result;
}

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

v1 = utt_relation(a1, "Segment");
result = relation_head(v1);
for ( i = result; result; i = result )
{
if ( !strcmp("ax", (const char *)item_feat_string(i, "name"))
&& !strcmp("the", (const char *)ffeature_string(i, "R:SylStructure.parent.parent.name"))
&& !strcmp("+", (const char *)ffeature_string(i, "n.ph_vc")) )
{
item_set_string(i, "name", "iy");
}
result = item_next(i);
}
return result;
}

original_code:
static void the_iy_ax(cst_utterance *u)
{
   const cst_item *i;
   const char *word;
   for (i = relation_head(utt_relation(u, "Segment")); i; i = item_next(i))
   {
      if ((strcmp("ax",item_feat_string(i,"name")) == 0))
      {
         word = ffeature_string(i,"R:SylStructure.parent.parent.name");
         if ((strcmp("the",word) == 0)
            && (strcmp("+",ffeature_string(i,"n.ph_vc")) == 0))
            item_set_string(i, "name", "iy");
      }
   }
}

canonical_original_code:
static void the_iy_ax(struct cst_utterance_struct *u)
{
   struct cst_item_struct *i;
   char *word;
   for (i = relation_head(utt_relation(u, "Segment")); i; i = item_next(i))
   {
      if ((strcmp("ax",item_feat_string(i,"name")) == 0))
      {
         word = ffeature_string(i,"R:SylStructure.parent.parent.name");
         if ((strcmp("the",word) == 0)
            && (strcmp("+",ffeature_string(i,"n.ph_vc")) == 0))
            item_set_string(i, "name", "iy");
      }
   }
}

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


decompiled_code:
void val_delete_uttfunc()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code: void val_delete_uttfunc(void *v) { (void)v; }

variable_types:
v
void *


decompiled_code:
void val_delete_ffunc()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code: void val_delete_ffunc(void *v) { (void)v; }


decompiled_code:
void val_delete_relation()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code: void val_delete_relation(void *v) { (void)v; }


decompiled_code:
void val_delete_item()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code: void val_delete_item(void *v) { (void)v; }


decompiled_code:
void val_delete_cart()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code: void val_delete_cart(void *v) { (void)v; }


decompiled_code:
void val_delete_phoneset()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code: void val_delete_phoneset(void *v) { (void)v; }


decompiled_code:
void val_delete_lexicon()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code: void val_delete_lexicon(void *v) { (void)v; }


decompiled_code:
void val_delete_dur_stats()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code: void val_delete_dur_stats(void *v) { (void)v; }


decompiled_code:
void val_delete_diphone_db()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code: void val_delete_diphone_db(void *v) { (void)v; }


decompiled_code:
void val_delete_clunit_db()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code: void val_delete_clunit_db(void *v) { (void)v; }


decompiled_code:
void val_delete_vit_cand()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code: void val_delete_vit_cand(void *v) { (void)v; }


decompiled_code:
void val_delete_sts_list()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code: void val_delete_sts_list(void *v) { (void)v; }


decompiled_code:
void val_delete_userdata()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code: void val_delete_userdata(void *v) { (void)v; }


decompiled_code:
void val_delete_itemfunc()
{
;
}

canonical_decompiled_code:
void func13()
{
;
}

original_code: void val_delete_itemfunc(void *v) { (void)v; }


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

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

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

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

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

canonical_original_code: void *val_userdata(struct cst_val_struct *v) { if (v && ((v)->c.a.type) == cst_val_type_userdata) return (void *)((v)->c.a.v.vval); else { cst_errmsg("VAL: tried to access %s in %d type val\n", "userdata", (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: void *


decompiled_code:
__int64 __fastcall userdata_val(__int64 a1)
{
return val_new_typed(41LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
return val_new_typed(41LL, a1);
}

original_code: cst_val *userdata_val(const cst_userdata *v) { return val_new_typed(cst_val_type_userdata, (void *)v); }

canonical_original_code: struct cst_val_struct *userdata_val(void *v) { return val_new_typed(cst_val_type_userdata, (void *)v); }


decompiled_code:
__int64 __fastcall fsm_transition(__int16 *a1, int a2, int a3)
{
unsigned __int16 *v3; // rsi
unsigned __int16 v4; // ax
int v5; // edi

v3 = (unsigned __int16 *)(*((_QWORD *)a1 + 1) + 2LL * a2);
v4 = *v3;
if ( !*v3 )
return 0xFFFFFFFFLL;
v5 = *a1;
while ( v4 % v5 != a3 )
{
v4 = *++v3;
if ( !*v3 )
return 0xFFFFFFFFLL;
}
return (unsigned int)(v4 / v5);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1, int a2, int a3)
{
unsigned __int16 *v3; // rsi
unsigned __int16 v4; // ax
int v5; // edi

v3 = (unsigned __int16 *)(*((_QWORD *)a1 + 1) + 2LL * a2);
v4 = *v3;
if ( !*v3 )
return 0xFFFFFFFFLL;
v5 = *a1;
while ( v4 % v5 != a3 )
{
v4 = *++v3;
if ( !*v3 )
return 0xFFFFFFFFLL;
}
return (unsigned int)(v4 / v5);
}

original_code:
int fsm_transition(cst_fsm *fsm,int state, int symbol)
{
    int i;
    for (i=state; fsm->transitions[i]; i++)
    {
 if ((fsm->transitions[i] % fsm->vocab_size) == symbol)
     return fsm->transitions[i] / fsm->vocab_size;
    }
    return -1;
}

canonical_original_code:
int fsm_transition(struct fsm_struct *fsm, int state, int symbol)
{
    int i;
    for (i=state; fsm->transitions[i]; i++)
    {
 if ((fsm->transitions[i] % fsm->vocab_size) == symbol)
     return fsm->transitions[i] / fsm->vocab_size;
    }
    return -1;
}

variable_types: struct fsm_struct { short vocab_size; short num_transitions; unsigned short *transitions; } *

variable_types: state int

variable_types: symbol int

variable_types: i int


decompiled_code:
__int64 __fastcall is_word_pre(_BYTE *a1)
{
int v1; // eax
int v2; // ebp
int v3; // ebx
_BYTE *v4; // r13

v1 = fsm_transition(fsm_aswdP, 0, 35);
LOBYTE(v2) = *a1;
if ( !*a1 )
return 0LL;
v3 = v1;
v4 = a1 + 1;
while ( (unsigned __int8)(v2 - 109) <= 1u )
{
v3 = fsm_transition(fsm_aswdP, v3, 78);
if ( v3 == -1 )
return 0LL;
LABEL_8:
LOBYTE(v2) = *v4++;
if ( !(_BYTE)v2 )
return 0LL;
}
v2 = (char)v2;
if ( strchr("aeiouy", (char)v2) )
v2 = 86;
v3 = fsm_transition(fsm_aswdP, v3, v2);
if ( v3 == -1 )
return 0LL;
if ( v2 != 86 )
goto LABEL_8;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1)
{
int v1; // eax
int v2; // ebp
int v3; // ebx
_BYTE *v4; // r13

v1 = func0(fsm_aswdP, 0, 35);
LOBYTE(v2) = *a1;
if ( !*a1 )
return 0LL;
v3 = v1;
v4 = a1 + 1;
while ( (unsigned __int8)(v2 - 109) <= 1u )
{
v3 = func0(fsm_aswdP, v3, 78);
if ( v3 == -1 )
return 0LL;
LABEL_8:
LOBYTE(v2) = *v4++;
if ( !(_BYTE)v2 )
return 0LL;
}
v2 = (char)v2;
if ( strchr("aeiouy", (char)v2) )
v2 = 86;
v3 = func0(fsm_aswdP, v3, v2);
if ( v3 == -1 )
return 0LL;
if ( v2 != 86 )
goto LABEL_8;
return 1LL;
}

original_code:
static int is_word_pre(const char *word)
{
    int i, state, symbol;
    state = fsm_transition(&fsm_aswdP,0,'#');
    for (i=0; word[i]; i++)
    {
 if ((word[i] == 'n') || ((word[i] == 'm')))
     symbol = 'N';
 else if (strchr("aeiouy",word[i]) != ((void *)0))
     symbol = 'V';
 else
     symbol = word[i];
 state = fsm_transition(&fsm_aswdP,state,symbol);
 if (state == -1)
     return 0;
 else if (symbol == 'V')
     return 1;
    }
    return 0;
}

canonical_original_code:
static int is_word_pre(char *word)
{
    int i; int state; int symbol;
    state = fsm_transition(&fsm_aswdP,0,'#');
    for (i=0; word[i]; i++)
    {
 if ((word[i] == 'n') || ((word[i] == 'm')))
     symbol = 'N';
 else if (strchr("aeiouy",word[i]) != ((void *)0))
     symbol = 'V';
 else
     symbol = word[i];
 state = fsm_transition(&fsm_aswdP,state,symbol);
 if (state == -1)
     return 0;
 else if (symbol == 'V')
     return 1;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall is_word_suf(char *s)
{
int v1; // ebx
int v2; // eax
__int64 v3; // rbp
char v5; // r12
int v6; // er15

v1 = fsm_transition(fsm_aswdP, 0, 35);
v2 = strlen(s) - 1;
if ( v2 < 0 )
return 0LL;
v3 = v2;
while ( 1 )
{
v5 = s[v3];
if ( (unsigned __int8)(v5 - 109) > 1u )
break;
v1 = fsm_transition(fsm_aswdS, v1, 78);
if ( v1 == -1 )
return 0LL;
LABEL_8:
if ( (int)--v3 < 0 )
return 0LL;
}
v6 = v5;
if ( strchr("aeiouy", v5) )
v6 = 86;
v1 = fsm_transition(fsm_aswdS, v1, v6);
if ( v1 == -1 )
return 0LL;
if ( v6 != 86 )
goto LABEL_8;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s)
{
int v1; // ebx
int v2; // eax
__int64 v3; // rbp
char v5; // r12
int v6; // er15

v1 = func0(fsm_aswdP, 0, 35);
v2 = strlen(s) - 1;
if ( v2 < 0 )
return 0LL;
v3 = v2;
while ( 1 )
{
v5 = s[v3];
if ( (unsigned __int8)(v5 - 109) > 1u )
break;
v1 = func0(fsm_aswdS, v1, 78);
if ( v1 == -1 )
return 0LL;
LABEL_8:
if ( (int)--v3 < 0 )
return 0LL;
}
v6 = v5;
if ( strchr("aeiouy", v5) )
v6 = 86;
v1 = func0(fsm_aswdS, v1, v6);
if ( v1 == -1 )
return 0LL;
if ( v6 != 86 )
goto LABEL_8;
return 1LL;
}

original_code:
static int is_word_suf(const char *word)
{
    int i, state, symbol;
    state = fsm_transition(&fsm_aswdP,0,'#');
    for (i=strlen(word)-1; i >= 0 ; i--)
    {
 if ((word[i] == 'n') || ((word[i] == 'm')))
     symbol = 'N';
 else if (strchr("aeiouy",word[i]) != ((void *)0))
     symbol = 'V';
 else
     symbol = word[i];
 state = fsm_transition(&fsm_aswdS,state,symbol);
 if (state == -1)
     return 0;
 else if (symbol == 'V')
     return 1;
    }
    return 0;
}

canonical_original_code:
static int is_word_suf(char *word)
{
    int i; int state; int symbol;
    state = fsm_transition(&fsm_aswdP,0,'#');
    for (i=strlen(word)-1; i >= 0 ; i--)
    {
 if ((word[i] == 'n') || ((word[i] == 'm')))
     symbol = 'N';
 else if (strchr("aeiouy",word[i]) != ((void *)0))
     symbol = 'V';
 else
     symbol = word[i];
 state = fsm_transition(&fsm_aswdS,state,symbol);
 if (state == -1)
     return 0;
 else if (symbol == 'V')
     return 1;
    }
    return 0;
}


decompiled_code:
__int64 us_aswd()
{
char *v0; // rbp
unsigned int v1; // ebx

v0 = (char *)cst_downcase();
v1 = is_word_pre(v0);
if ( v1 )
v1 = is_word_suf(v0) != 0;
cst_free(v0);
return v1;
}

canonical_decompiled_code:
__int64 func3()
{
char *v0; // rbp
unsigned int v1; // ebx

v0 = (char *)cst_downcase();
v1 = func1(v0);
if ( v1 )
v1 = func2(v0) != 0;
cst_free(v0);
return v1;
}

original_code:
int us_aswd(const char *word)
{
    char *dc;
    int i;
    dc = cst_downcase(word);
    i = is_word_pre(dc) && is_word_suf(dc);
    cst_free(dc);
    return i;
}

canonical_original_code:
int us_aswd(char *word)
{
    char *dc;
    int i;
    dc = cst_downcase(word);
    i = is_word_pre(dc) && is_word_suf(dc);
    cst_free(dc);
    return i;
}

variable_types:
dc
char *


decompiled_code:
__int64 __fastcall flite_synth_foo(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64))
{
__int64 v3; // rbx

v3 = a1;
utt_init();
if ( !a3(a1) )
{
delete_utterance(a1);
v3 = 0LL;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64))
{
__int64 v3; // rbx

v3 = a1;
utt_init();
if ( !a3(a1) )
{
delete_utterance(a1);
v3 = 0LL;
}
return v3;
}

original_code:
static cst_utterance *flite_synth_foo(cst_utterance *u,
          cst_voice *voice,
          cst_uttfunc synth)
{
   utt_init(u, voice);
   if ((*synth)(u) == ((void *)0))
   {
      delete_utterance(u);
      return ((void *)0);
   } else
      return u;
}

canonical_original_code:
static struct cst_utterance_struct *flite_synth_foo(struct cst_utterance_struct *u, struct cst_voice_struct *voice, struct cst_utterance_struct *(*synth)(struct cst_utterance_struct *i))
{
   utt_init(u, voice);
   if ((*synth)(u) == ((void *)0))
   {
      delete_utterance(u);
      return ((void *)0);
   } else
      return u;
}

variable_types:
u
struct cst_utterance_struct *

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

variable_types: struct cst_utterance_struct *(*)(struct cst_utterance_struct *i)

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


decompiled_code:
__int64 flite_init()
{
cst_regex_init();
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
cst_regex_init();
return 0LL;
}

original_code:
int flite_init()
{
    cst_regex_init();
    return 0;
}


decompiled_code:
__int64 __fastcall flite_synth_text(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

v2 = new_utterance();
utt_set_input_text(v2, a1);
return flite_synth_foo(v2, a2, (__int64 (__fastcall *)(__int64))&utt_synth);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

v2 = new_utterance();
utt_set_input_text(v2, a1);
return func0(v2, a2, (__int64 (__fastcall *)(__int64))&utt_synth);
}

original_code:
cst_utterance *flite_synth_text(const char *text, cst_voice *voice)
{
    cst_utterance *u;
    u = new_utterance();
    utt_set_input_text(u,text);
    return flite_synth_foo(u, voice, utt_synth);
}

canonical_original_code:
struct cst_utterance_struct *flite_synth_text(char *text, struct cst_voice_struct *voice)
{
    struct cst_utterance_struct *u;
    u = new_utterance();
    utt_set_input_text(u,text);
    return flite_synth_foo(u, voice, utt_synth);
}

variable_types:
text
char *

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


decompiled_code:
__int64 __fastcall flite_synth_phones(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

v2 = new_utterance();
utt_set_input_text(v2, a1);
return flite_synth_foo(v2, a2, (__int64 (__fastcall *)(__int64))&utt_synth_phones);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

v2 = new_utterance();
utt_set_input_text(v2, a1);
return func0(v2, a2, (__int64 (__fastcall *)(__int64))&utt_synth_phones);
}

original_code:
cst_utterance *flite_synth_phones(const char *text, cst_voice *voice)
{
    cst_utterance *u;
    u = new_utterance();
    utt_set_input_text(u,text);
    return flite_synth_foo(u, voice, utt_synth_phones);
}

canonical_original_code:
struct cst_utterance_struct *flite_synth_phones(char *text, struct cst_voice_struct *voice)
{
    struct cst_utterance_struct *u;
    u = new_utterance();
    utt_set_input_text(u,text);
    return flite_synth_foo(u, voice, utt_synth_phones);
}


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

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

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

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

variable_types: j int

variable_types: r int

variable_types: o int

variable_types: k int

variable_types: ci int

variable_types: cr int

variable_types:
outbuf
int *

variable_types:
lpccoefs
int *

variable_types: pp int