checkundef

original_code:
static void
checkundef(Node *n, Reaching *r, Bitset *reach, Bitset *kill)
{
 size_t i, j, did;
 Node *def;
 Type *t;
 if (n->type != Nexpr)
  return;
 if (exprop(n) == Ovar) {
  did = n->expr.did;
  if (decls[did]->decl.isconst)
   return;
  for (j = 0; j < r->ndefs[did]; j++) {
   t = tybase(exprtype(n));
   if (t->type == Tystruct || t->type == Tyunion || t->type == Tyarray ||
    t->type == Tytuple || t->type == Tyvoid)
    continue;
   if (bshas(kill, r->defs[did][j]))
    continue;
   if (!bshas(reach, r->defs[did][j]))
    continue;
   def = nodes[r->defs[did][j]];
   if (exprop(def) == Oundef)
    fatal(n, "%s used before definition", namestr(n->expr.args[0]));
  }
 } else {
  switch (exprop(n)) {
  case Oset:
  case Oasn:
  case Oblit:
   checkundef(n->expr.args[1], r, reach, kill);
   break;
  case Oaddr:
  case Oslice:
   for (i = 1; i < n->expr.nargs; i++)
    checkundef(n->expr.args[i], r, reach, kill);
   break;
  case Ocall:
   for (i = 1; i < n->expr.nargs; i++)
    if (exprop(n->expr.args[i]) != Oaddr)
     checkundef(n->expr.args[i], r, reach, kill);
   break;
  default:
   for (i = 0; i < n->expr.nargs; i++)
    checkundef(n->expr.args[i], r, reach, kill);
   break;
  }
 }
}

canonical_original_code:
static void checkundef(struct Node *n, struct Reaching *r, struct Bitset *reach, struct Bitset *kill)
{
 unsigned long i; unsigned long j; unsigned long did;
 struct Node *def;
 struct Type *t;
 if (n->type != Nexpr)
  return;
 if (exprop(n) == Ovar) {
  did = n->expr.did;
  if (decls[did]->decl.isconst)
   return;
  for (j = 0; j < r->ndefs[did]; j++) {
   t = tybase(exprtype(n));
   if (t->type == Tystruct || t->type == Tyunion || t->type == Tyarray ||
    t->type == Tytuple || t->type == Tyvoid)
    continue;
   if (bshas(kill, r->defs[did][j]))
    continue;
   if (!bshas(reach, r->defs[did][j]))
    continue;
   def = nodes[r->defs[did][j]];
   if (exprop(def) == Oundef)
    fatal(n, "%s used before definition", namestr(n->expr.args[0]));
  }
 } else {
  switch (exprop(n)) {
  case Oset:
  case Oasn:
  case Oblit:
   checkundef(n->expr.args[1], r, reach, kill);
   break;
  case Oaddr:
  case Oslice:
   for (i = 1; i < n->expr.nargs; i++)
    checkundef(n->expr.args[i], r, reach, kill);
   break;
  case Ocall:
   for (i = 1; i < n->expr.nargs; i++)
    if (exprop(n->expr.args[i]) != Oaddr)
     checkundef(n->expr.args[i], r, reach, kill);
   break;
  default:
   for (i = 0; i < n->expr.nargs; i++)
    checkundef(n->expr.args[i], r, reach, kill);
   break;
  }
 }
}

variable_types: struct Node { struct Srcloc { int line; int file; } loc; enum Ntype { Nnone=0, Nblock=1, Nifstmt=2, Nloopstmt=3, Niterstmt=4, Nmatchstmt=5, Nmatch=6, Nuse=7, Nexpr=8, Nlit=9, Nname=10, Ndecl=11, Nfunc=12, Nimpl=13 } type; int nid; char inferred; union { struct { enum Op { Obad=0, Oauto=1, Oadd=2, Osub=3, Omul=4, Odiv=5, Omod=6, Oneg=7, Obor=8, Oband=9, Obxor=10, Obsl=11, Obsr=12, Obnot=13, Opreinc=14, Opostinc=15, Opredec=16, Opostdec=17, Oaddr=18, Oderef=19, Olor=20, Oland=21, Olnot=22, Oeq=23, One=24, Ogt=25, Oge=26, Olt=27, Ole=28, Oasn=29, Oaddeq=30, Osubeq=31, Omuleq=32, Odiveq=33, Omodeq=34, Oboreq=35, Obandeq=36, Obxoreq=37, Obsleq=38, Obsreq=39, Oidx=40, Oslice=41, Omemb=42, Otupmemb=43, Osize=44, Ocall=45, Ocast=46, Oret=47, Ojmp=48, Obreak=49, Ocontinue=50, Ovar=51, Ogap=52, Olit=53, Oucon=54, Otup=55, Ostruct=56, Oarr=57, Otern=58, Odead=59, Oundef=60, Odef=61, Ocjmp=62, Ovjmp=63, Oset=64, Osllen=65, Oslbase=66, Outag=67, Oudata=68, Otupget=69, Oblit=70, Oclear=71, Ocallind=72, Otrunc=73, Ozwiden=74, Oswiden=75, Oflt2int=76, Oint2flt=77, Oflt2flt=78, Ofadd=79, Ofsub=80, Ofmul=81, Ofdiv=82, Ofneg=83, Ofeq=84, Ofne=85, Ofgt=86, Ofge=87, Oflt=88, Ofle=89, Oueq=90, Oune=91, Ougt=92, Ouge=93, Oult=94, Oule=95, Numops=96 } op; struct Type { enum Ty { Tybad=0, Tyvoid=1, Tybool=2, Tychar=3, Tyint8=4, Tyint16=5, Tyint=6, Tyint32=7, Tyint64=8, Tybyte=9, Tyuint8=10, Tyuint16=11, Tyuint=12, Tyuint32=13, Tyuint64=14, Tyflt32=15, Tyflt64=16, Tyvalist=17, Typtr=18, Tyfunc=19, Tyslice=20, Tyarray=21, Tytuple=22, Tystruct=23, Tyunion=24, Tyvar=25, Typaram=26, Tyunres=27, Tyname=28, Tygeneric=29, Tycode=30, Ntypes=31 } type; unsigned int tid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Traitspec { struct Node **trait; unsigned long ntrait; struct Type *param; struct Type *aux; } **spec; unsigned long nspec; struct Type *seqaux; struct Type **gparam; unsigned long ngparam; struct Type **arg; unsigned long narg; struct Type **inst; unsigned long ninst; struct Tyenv { struct Tyenv *super; struct Htab { unsigned long nelt; unsigned long ndead; unsigned long sz; unsigned long (*hash)(void *k); int (*cmp)(void *a, void *b); void **keys; void **vals; unsigned long *hashes; char *dead; } *tab; } *env; struct Type **sub; unsigned long nsub; unsigned long nmemb; struct Bitset { unsigned long nchunks; unsigned long *chunks; } *trneed; union { struct Node *name; struct Node *asize; char *pname; struct Node **sdecls; struct Ucon { struct Srcloc loc; unsigned long id; int synth; struct Node *name; struct Type *utype; struct Type *etype; } **udecls; }; char hasparams; char isenum; char ishidden; char ispkglocal; char isimport; char isreflect; char isemitted; char resolved; char fixed; char tagged; } *type; struct Type *param; int isconst; int ispat; unsigned long did; unsigned long nargs; struct Node *idx; struct Node **args; } expr; struct { char *ns; char *name; } name; struct { int islocal; char *name; } use; struct { enum Littype { Lchr=0, Lbool=1, Lint=2, Lflt=3, Lstr=4, Lfunc=5, Llbl=6, Lvoid=7 } littype; struct Type *type; unsigned long nelt; union { unsigned long long intval; double fltval; unsigned int chrval; struct Str { unsigned long len; char *buf; } strval; struct { char *lblval; char *lblname; }; int boolval; struct Node *fnval; }; } lit; struct { struct Node *init; struct Node *cond; struct Node *step; struct Node *body; struct Stab { struct Stab *super; char *name; char isfunc; struct Htab *dcl; struct Htab *env; struct Htab *ty; struct Htab *tr; struct Htab *uc; struct Htab *lbl; struct Htab *impl; struct Node **autotmp; unsigned long nautotmp; struct Node *exit[-1]; unsigned long ndisposed[-1]; } *scope; } loopstmt; struct { struct Node *elt; struct Node *seq; struct Node *body; } iterstmt; struct { struct Node *cond; struct Node *iftrue; struct Node *iffalse; } ifstmt; struct { struct Node *val; unsigned long nmatches; struct Node **matches; } matchstmt; struct { struct Node *pat; struct Node *block; } match; struct { struct Stab *scope; unsigned long nstmts; struct Node **stmts; } block; struct { unsigned long did; struct Node *name; struct Type *type; struct Node *init; struct Tyenv *env; struct Trait { int uid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Node *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; } *trait; struct Htab *impls; struct Node **gimpl; unsigned long ngimpl; struct Node **gtype; unsigned long ngtype; char vis; char isglobl; char isconst; char isgeneric; char isextern; char ispkglocal; char ishidden; char isimport; char isnoret; char isexportval; char isinit; char isfini; } decl; struct { struct Tyenv *env; struct Stab *scope; struct Type *type; unsigned long nargs; struct Node **args; struct Node *body; } func; struct { struct Node *traitname; struct Trait *trait; struct Type *type; struct Type **aux; struct Tyenv *env; unsigned long naux; struct Node **decls; unsigned long ndecls; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; char isproto; char isextern; } impl; }; } *

variable_types: struct Reaching { struct Bitset **in; struct Bitset **out; unsigned long **defs; unsigned long *ndefs; unsigned long nbb; } *

variable_types:
reach
struct Bitset *

variable_types:
kill
struct Bitset *

variable_types:
j
unsigned long

variable_types:
did
unsigned long

variable_types: struct Type { enum Ty { Tybad=0, Tyvoid=1, Tybool=2, Tychar=3, Tyint8=4, Tyint16=5, Tyint=6, Tyint32=7, Tyint64=8, Tybyte=9, Tyuint8=10, Tyuint16=11, Tyuint=12, Tyuint32=13, Tyuint64=14, Tyflt32=15, Tyflt64=16, Tyvalist=17, Typtr=18, Tyfunc=19, Tyslice=20, Tyarray=21, Tytuple=22, Tystruct=23, Tyunion=24, Tyvar=25, Typaram=26, Tyunres=27, Tyname=28, Tygeneric=29, Tycode=30, Ntypes=31 } type; unsigned int tid; struct Srcloc { int line; int file; } loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Traitspec { struct Node { struct Srcloc loc; enum Ntype { Nnone=0, Nblock=1, Nifstmt=2, Nloopstmt=3, Niterstmt=4, Nmatchstmt=5, Nmatch=6, Nuse=7, Nexpr=8, Nlit=9, Nname=10, Ndecl=11, Nfunc=12, Nimpl=13 } type; int nid; char inferred; union { struct { enum Op { Obad=0, Oauto=1, Oadd=2, Osub=3, Omul=4, Odiv=5, Omod=6, Oneg=7, Obor=8, Oband=9, Obxor=10, Obsl=11, Obsr=12, Obnot=13, Opreinc=14, Opostinc=15, Opredec=16, Opostdec=17, Oaddr=18, Oderef=19, Olor=20, Oland=21, Olnot=22, Oeq=23, One=24, Ogt=25, Oge=26, Olt=27, Ole=28, Oasn=29, Oaddeq=30, Osubeq=31, Omuleq=32, Odiveq=33, Omodeq=34, Oboreq=35, Obandeq=36, Obxoreq=37, Obsleq=38, Obsreq=39, Oidx=40, Oslice=41, Omemb=42, Otupmemb=43, Osize=44, Ocall=45, Ocast=46, Oret=47, Ojmp=48, Obreak=49, Ocontinue=50, Ovar=51, Ogap=52, Olit=53, Oucon=54, Otup=55, Ostruct=56, Oarr=57, Otern=58, Odead=59, Oundef=60, Odef=61, Ocjmp=62, Ovjmp=63, Oset=64, Osllen=65, Oslbase=66, Outag=67, Oudata=68, Otupget=69, Oblit=70, Oclear=71, Ocallind=72, Otrunc=73, Ozwiden=74, Oswiden=75, Oflt2int=76, Oint2flt=77, Oflt2flt=78, Ofadd=79, Ofsub=80, Ofmul=81, Ofdiv=82, Ofneg=83, Ofeq=84, Ofne=85, Ofgt=86, Ofge=87, Oflt=88, Ofle=89, Oueq=90, Oune=91, Ougt=92, Ouge=93, Oult=94, Oule=95, Numops=96 } op; struct Type *type; struct Type *param; int isconst; int ispat; unsigned long did; unsigned long nargs; struct Node *idx; struct Node **args; } expr; struct { char *ns; char *name; } name; struct { int islocal; char *name; } use; struct { enum Littype { Lchr=0, Lbool=1, Lint=2, Lflt=3, Lstr=4, Lfunc=5, Llbl=6, Lvoid=7 } littype; struct Type *type; unsigned long nelt; union { unsigned long long intval; double fltval; unsigned int chrval; struct Str { unsigned long len; char *buf; } strval; struct { char *lblval; char *lblname; }; int boolval; struct Node *fnval; }; } lit; struct { struct Node *init; struct Node *cond; struct Node *step; struct Node *body; struct Stab { struct Stab *super; char *name; char isfunc; struct Htab { unsigned long nelt; unsigned long ndead; unsigned long sz; unsigned long (*hash)(void *k); int (*cmp)(void *a, void *b); void **keys; void **vals; unsigned long *hashes; char *dead; } *dcl; struct Htab *env; struct Htab *ty; struct Htab *tr; struct Htab *uc; struct Htab *lbl; struct Htab *impl; struct Node **autotmp; unsigned long nautotmp; struct Node *exit[-1]; unsigned long ndisposed[-1]; } *scope; } loopstmt; struct { struct Node *elt; struct Node *seq; struct Node *body; } iterstmt; struct { struct Node *cond; struct Node *iftrue; struct Node *iffalse; } ifstmt; struct { struct Node *val; unsigned long nmatches; struct Node **matches; } matchstmt; struct { struct Node *pat; struct Node *block; } match; struct { struct Stab *scope; unsigned long nstmts; struct Node **stmts; } block; struct { unsigned long did; struct Node *name; struct Type *type; struct Node *init; struct Tyenv { struct Tyenv *super; struct Htab *tab; } *env; struct Trait { int uid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Node *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; } *trait; struct Htab *impls; struct Node **gimpl; unsigned long ngimpl; struct Node **gtype; unsigned long ngtype; char vis; char isglobl; char isconst; char isgeneric; char isextern; char ispkglocal; char ishidden; char isimport; char isnoret; char isexportval; char isinit; char isfini; } decl; struct { struct Tyenv *env; struct Stab *scope; struct Type *type; unsigned long nargs; struct Node **args; struct Node *body; } func; struct { struct Node *traitname; struct Trait *trait; struct Type *type; struct Type **aux; struct Tyenv *env; unsigned long naux; struct Node **decls; unsigned long ndecls; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; char isproto; char isextern; } impl; }; } **trait; unsigned long ntrait; struct Type *param; struct Type *aux; } **spec; unsigned long nspec; struct Type *seqaux; struct Type **gparam; unsigned long ngparam; struct Type **arg; unsigned long narg; struct Type **inst; unsigned long ninst; struct Tyenv *env; struct Type **sub; unsigned long nsub; unsigned long nmemb; struct Bitset { unsigned long nchunks; unsigned long *chunks; } *trneed; union { struct Node *name; struct Node *asize; char *pname; struct Node **sdecls; struct Ucon { struct Srcloc loc; unsigned long id; int synth; struct Node *name; struct Type *utype; struct Type *etype; } **udecls; }; char hasparams; char isenum; char ishidden; char ispkglocal; char isimport; char isreflect; char isemitted; char resolved; char fixed; char tagged; } *

user_defined_types: struct Trait { int uid; struct Srcloc loc; enum Vis vis; struct Node *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; }


checkreach

repo: oridb/mc

original_code:
static void
checkreach(Cfg *cfg)
{
 Bitset *reach, *kill;
 size_t i, j, k;
 Reaching *r;
 Node *n, *m;
 Bb *bb;
 r = reaching(cfg);
 for (i = 0; i < cfg->nbb; i++) {
  bb = cfg->bb[i];
  if (!bb)
   continue;
  reach = bsdup(r->in[i]);
  kill = mkbs();
  for (j = 0; j < bb->nnl; j++) {
   n = bb->nl[j];
   if (exprop(n) == Oundef) {
    bsput(reach, n->nid);
   } else {
    m = assignee(n);
    if (m)
     for (k = 0; k < r->ndefs[m->expr.did]; k++)
      bsput(kill, r->defs[m->expr.did][k]);
    checkundef(n, r, reach, kill);
   }
  }
  bsfree(reach);
  bsfree(kill);
 }
 reachingfree(r);
}

canonical_original_code:
static void checkreach(struct Cfg *cfg)
{
 struct Bitset *reach; struct Bitset *kill;
 unsigned long i; unsigned long j; unsigned long k;
 struct Reaching *r;
 struct Node *n; struct Node *m;
 struct Bb *bb;
 r = reaching(cfg);
 for (i = 0; i < cfg->nbb; i++) {
  bb = cfg->bb[i];
  if (!bb)
   continue;
  reach = bsdup(r->in[i]);
  kill = mkbs();
  for (j = 0; j < bb->nnl; j++) {
   n = bb->nl[j];
   if (exprop(n) == Oundef) {
    bsput(reach, n->nid);
   } else {
    m = assignee(n);
    if (m)
     for (k = 0; k < r->ndefs[m->expr.did]; k++)
      bsput(kill, r->defs[m->expr.did][k]);
    checkundef(n, r, reach, kill);
   }
  }
  bsfree(reach);
  bsfree(kill);
 }
 reachingfree(r);
}

variable_types: struct Cfg { struct Node { struct Srcloc { int line; int file; } loc; enum Ntype { Nnone=0, Nblock=1, Nifstmt=2, Nloopstmt=3, Niterstmt=4, Nmatchstmt=5, Nmatch=6, Nuse=7, Nexpr=8, Nlit=9, Nname=10, Ndecl=11, Nfunc=12, Nimpl=13 } type; int nid; char inferred; union { struct { enum Op { Obad=0, Oauto=1, Oadd=2, Osub=3, Omul=4, Odiv=5, Omod=6, Oneg=7, Obor=8, Oband=9, Obxor=10, Obsl=11, Obsr=12, Obnot=13, Opreinc=14, Opostinc=15, Opredec=16, Opostdec=17, Oaddr=18, Oderef=19, Olor=20, Oland=21, Olnot=22, Oeq=23, One=24, Ogt=25, Oge=26, Olt=27, Ole=28, Oasn=29, Oaddeq=30, Osubeq=31, Omuleq=32, Odiveq=33, Omodeq=34, Oboreq=35, Obandeq=36, Obxoreq=37, Obsleq=38, Obsreq=39, Oidx=40, Oslice=41, Omemb=42, Otupmemb=43, Osize=44, Ocall=45, Ocast=46, Oret=47, Ojmp=48, Obreak=49, Ocontinue=50, Ovar=51, Ogap=52, Olit=53, Oucon=54, Otup=55, Ostruct=56, Oarr=57, Otern=58, Odead=59, Oundef=60, Odef=61, Ocjmp=62, Ovjmp=63, Oset=64, Osllen=65, Oslbase=66, Outag=67, Oudata=68, Otupget=69, Oblit=70, Oclear=71, Ocallind=72, Otrunc=73, Ozwiden=74, Oswiden=75, Oflt2int=76, Oint2flt=77, Oflt2flt=78, Ofadd=79, Ofsub=80, Ofmul=81, Ofdiv=82, Ofneg=83, Ofeq=84, Ofne=85, Ofgt=86, Ofge=87, Oflt=88, Ofle=89, Oueq=90, Oune=91, Ougt=92, Ouge=93, Oult=94, Oule=95, Numops=96 } op; struct Type { enum Ty { Tybad=0, Tyvoid=1, Tybool=2, Tychar=3, Tyint8=4, Tyint16=5, Tyint=6, Tyint32=7, Tyint64=8, Tybyte=9, Tyuint8=10, Tyuint16=11, Tyuint=12, Tyuint32=13, Tyuint64=14, Tyflt32=15, Tyflt64=16, Tyvalist=17, Typtr=18, Tyfunc=19, Tyslice=20, Tyarray=21, Tytuple=22, Tystruct=23, Tyunion=24, Tyvar=25, Typaram=26, Tyunres=27, Tyname=28, Tygeneric=29, Tycode=30, Ntypes=31 } type; unsigned int tid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Traitspec { struct Node **trait; unsigned long ntrait; struct Type *param; struct Type *aux; } **spec; unsigned long nspec; struct Type *seqaux; struct Type **gparam; unsigned long ngparam; struct Type **arg; unsigned long narg; struct Type **inst; unsigned long ninst; struct Tyenv { struct Tyenv *super; struct Htab { unsigned long nelt; unsigned long ndead; unsigned long sz; unsigned long (*hash)(void *k); int (*cmp)(void *a, void *b); void **keys; void **vals; unsigned long *hashes; char *dead; } *tab; } *env; struct Type **sub; unsigned long nsub; unsigned long nmemb; struct Bitset { unsigned long nchunks; unsigned long *chunks; } *trneed; union { struct Node *name; struct Node *asize; char *pname; struct Node **sdecls; struct Ucon { struct Srcloc loc; unsigned long id; int synth; struct Node *name; struct Type *utype; struct Type *etype; } **udecls; }; char hasparams; char isenum; char ishidden; char ispkglocal; char isimport; char isreflect; char isemitted; char resolved; char fixed; char tagged; } *type; struct Type *param; int isconst; int ispat; unsigned long did; unsigned long nargs; struct Node *idx; struct Node **args; } expr; struct { char *ns; char *name; } name; struct { int islocal; char *name; } use; struct { enum Littype { Lchr=0, Lbool=1, Lint=2, Lflt=3, Lstr=4, Lfunc=5, Llbl=6, Lvoid=7 } littype; struct Type *type; unsigned long nelt; union { unsigned long long intval; double fltval; unsigned int chrval; struct Str { unsigned long len; char *buf; } strval; struct { char *lblval; char *lblname; }; int boolval; struct Node *fnval; }; } lit; struct { struct Node *init; struct Node *cond; struct Node *step; struct Node *body; struct Stab { struct Stab *super; char *name; char isfunc; struct Htab *dcl; struct Htab *env; struct Htab *ty; struct Htab *tr; struct Htab *uc; struct Htab *lbl; struct Htab *impl; struct Node **autotmp; unsigned long nautotmp; struct Node *exit[-1]; unsigned long ndisposed[-1]; } *scope; } loopstmt; struct { struct Node *elt; struct Node *seq; struct Node *body; } iterstmt; struct { struct Node *cond; struct Node *iftrue; struct Node *iffalse; } ifstmt; struct { struct Node *val; unsigned long nmatches; struct Node **matches; } matchstmt; struct { struct Node *pat; struct Node *block; } match; struct { struct Stab *scope; unsigned long nstmts; struct Node **stmts; } block; struct { unsigned long did; struct Node *name; struct Type *type; struct Node *init; struct Tyenv *env; struct Trait { int uid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Node *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; } *trait; struct Htab *impls; struct Node **gimpl; unsigned long ngimpl; struct Node **gtype; unsigned long ngtype; char vis; char isglobl; char isconst; char isgeneric; char isextern; char ispkglocal; char ishidden; char isimport; char isnoret; char isexportval; char isinit; char isfini; } decl; struct { struct Tyenv *env; struct Stab *scope; struct Type *type; unsigned long nargs; struct Node **args; struct Node *body; } func; struct { struct Node *traitname; struct Trait *trait; struct Type *type; struct Type **aux; struct Tyenv *env; unsigned long naux; struct Node **decls; unsigned long ndecls; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; char isproto; char isextern; } impl; }; } *fn; struct Bb { int id; char **lbls; unsigned long nlbls; struct Node **nl; unsigned long nnl; struct Bitset *pred; struct Bitset *succ; } **bb; struct Bb *start; struct Bb *end; unsigned long nbb; int nextbbid; struct Htab *lblmap; struct Node **fixjmp; unsigned long nfixjmp; struct Bb **fixblk; unsigned long nfixblk; } *

variable_types:
i
unsigned long

variable_types:
k
unsigned long

variable_types: struct Reaching { struct Bitset { unsigned long nchunks; unsigned long *chunks; } **in; struct Bitset **out; unsigned long **defs; unsigned long *ndefs; unsigned long nbb; } *

variable_types: struct Bb { int id; char **lbls; unsigned long nlbls; struct Node { struct Srcloc { int line; int file; } loc; enum Ntype { Nnone=0, Nblock=1, Nifstmt=2, Nloopstmt=3, Niterstmt=4, Nmatchstmt=5, Nmatch=6, Nuse=7, Nexpr=8, Nlit=9, Nname=10, Ndecl=11, Nfunc=12, Nimpl=13 } type; int nid; char inferred; union { struct { enum Op { Obad=0, Oauto=1, Oadd=2, Osub=3, Omul=4, Odiv=5, Omod=6, Oneg=7, Obor=8, Oband=9, Obxor=10, Obsl=11, Obsr=12, Obnot=13, Opreinc=14, Opostinc=15, Opredec=16, Opostdec=17, Oaddr=18, Oderef=19, Olor=20, Oland=21, Olnot=22, Oeq=23, One=24, Ogt=25, Oge=26, Olt=27, Ole=28, Oasn=29, Oaddeq=30, Osubeq=31, Omuleq=32, Odiveq=33, Omodeq=34, Oboreq=35, Obandeq=36, Obxoreq=37, Obsleq=38, Obsreq=39, Oidx=40, Oslice=41, Omemb=42, Otupmemb=43, Osize=44, Ocall=45, Ocast=46, Oret=47, Ojmp=48, Obreak=49, Ocontinue=50, Ovar=51, Ogap=52, Olit=53, Oucon=54, Otup=55, Ostruct=56, Oarr=57, Otern=58, Odead=59, Oundef=60, Odef=61, Ocjmp=62, Ovjmp=63, Oset=64, Osllen=65, Oslbase=66, Outag=67, Oudata=68, Otupget=69, Oblit=70, Oclear=71, Ocallind=72, Otrunc=73, Ozwiden=74, Oswiden=75, Oflt2int=76, Oint2flt=77, Oflt2flt=78, Ofadd=79, Ofsub=80, Ofmul=81, Ofdiv=82, Ofneg=83, Ofeq=84, Ofne=85, Ofgt=86, Ofge=87, Oflt=88, Ofle=89, Oueq=90, Oune=91, Ougt=92, Ouge=93, Oult=94, Oule=95, Numops=96 } op; struct Type { enum Ty { Tybad=0, Tyvoid=1, Tybool=2, Tychar=3, Tyint8=4, Tyint16=5, Tyint=6, Tyint32=7, Tyint64=8, Tybyte=9, Tyuint8=10, Tyuint16=11, Tyuint=12, Tyuint32=13, Tyuint64=14, Tyflt32=15, Tyflt64=16, Tyvalist=17, Typtr=18, Tyfunc=19, Tyslice=20, Tyarray=21, Tytuple=22, Tystruct=23, Tyunion=24, Tyvar=25, Typaram=26, Tyunres=27, Tyname=28, Tygeneric=29, Tycode=30, Ntypes=31 } type; unsigned int tid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Traitspec { struct Node **trait; unsigned long ntrait; struct Type *param; struct Type *aux; } **spec; unsigned long nspec; struct Type *seqaux; struct Type **gparam; unsigned long ngparam; struct Type **arg; unsigned long narg; struct Type **inst; unsigned long ninst; struct Tyenv { struct Tyenv *super; struct Htab { unsigned long nelt; unsigned long ndead; unsigned long sz; unsigned long (*hash)(void *k); int (*cmp)(void *a, void *b); void **keys; void **vals; unsigned long *hashes; char *dead; } *tab; } *env; struct Type **sub; unsigned long nsub; unsigned long nmemb; struct Bitset { unsigned long nchunks; unsigned long *chunks; } *trneed; union { struct Node *name; struct Node *asize; char *pname; struct Node **sdecls; struct Ucon { struct Srcloc loc; unsigned long id; int synth; struct Node *name; struct Type *utype; struct Type *etype; } **udecls; }; char hasparams; char isenum; char ishidden; char ispkglocal; char isimport; char isreflect; char isemitted; char resolved; char fixed; char tagged; } *type; struct Type *param; int isconst; int ispat; unsigned long did; unsigned long nargs; struct Node *idx; struct Node **args; } expr; struct { char *ns; char *name; } name; struct { int islocal; char *name; } use; struct { enum Littype { Lchr=0, Lbool=1, Lint=2, Lflt=3, Lstr=4, Lfunc=5, Llbl=6, Lvoid=7 } littype; struct Type *type; unsigned long nelt; union { unsigned long long intval; double fltval; unsigned int chrval; struct Str { unsigned long len; char *buf; } strval; struct { char *lblval; char *lblname; }; int boolval; struct Node *fnval; }; } lit; struct { struct Node *init; struct Node *cond; struct Node *step; struct Node *body; struct Stab { struct Stab *super; char *name; char isfunc; struct Htab *dcl; struct Htab *env; struct Htab *ty; struct Htab *tr; struct Htab *uc; struct Htab *lbl; struct Htab *impl; struct Node **autotmp; unsigned long nautotmp; struct Node *exit[-1]; unsigned long ndisposed[-1]; } *scope; } loopstmt; struct { struct Node *elt; struct Node *seq; struct Node *body; } iterstmt; struct { struct Node *cond; struct Node *iftrue; struct Node *iffalse; } ifstmt; struct { struct Node *val; unsigned long nmatches; struct Node **matches; } matchstmt; struct { struct Node *pat; struct Node *block; } match; struct { struct Stab *scope; unsigned long nstmts; struct Node **stmts; } block; struct { unsigned long did; struct Node *name; struct Type *type; struct Node *init; struct Tyenv *env; struct Trait { int uid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Node *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; } *trait; struct Htab *impls; struct Node **gimpl; unsigned long ngimpl; struct Node **gtype; unsigned long ngtype; char vis; char isglobl; char isconst; char isgeneric; char isextern; char ispkglocal; char ishidden; char isimport; char isnoret; char isexportval; char isinit; char isfini; } decl; struct { struct Tyenv *env; struct Stab *scope; struct Type *type; unsigned long nargs; struct Node **args; struct Node *body; } func; struct { struct Node *traitname; struct Trait *trait; struct Type *type; struct Type **aux; struct Tyenv *env; unsigned long naux; struct Node **decls; unsigned long ndecls; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; char isproto; char isextern; } impl; }; } **nl; unsigned long nnl; struct Bitset *pred; struct Bitset *succ; } *

return_type: void

user_defined_types: struct Cfg { struct Node *fn; struct Bb **bb; struct Bb *start; struct Bb *end; unsigned long nbb; int nextbbid; struct Htab *lblmap; struct Node **fixjmp; unsigned long nfixjmp; struct Bb **fixblk; unsigned long nfixblk; }

user_defined_types: struct Reaching { struct Bitset **in; struct Bitset **out; unsigned long **defs; unsigned long *ndefs; unsigned long nbb; }

user_defined_types: struct Node { struct Srcloc loc; enum Ntype type; int nid; char inferred; union { struct { enum Op op; struct Type *type; struct Type *param; int isconst; int ispat; unsigned long did; unsigned long nargs; struct Node *idx; struct Node **args; } expr; struct { char *ns; char *name; } name; struct { int islocal; char *name; } use; struct { enum Littype littype; struct Type *type; unsigned long nelt; union { unsigned long long intval; double fltval; unsigned int chrval; struct Str strval; struct { char *lblval; char *lblname; }; int boolval; struct Node *fnval; }; } lit; struct { struct Node *init; struct Node *cond; struct Node *step; struct Node *body; struct Stab *scope; } loopstmt; struct { struct Node *elt; struct Node *seq; struct Node *body; } iterstmt; struct { struct Node *cond; struct Node *iftrue; struct Node *iffalse; } ifstmt; struct { struct Node *val; unsigned long nmatches; struct Node **matches; } matchstmt; struct { struct Node *pat; struct Node *block; } match; struct { struct Stab *scope; unsigned long nstmts; struct Node **stmts; } block; struct { unsigned long did; struct Node *name; struct Type *type; struct Node *init; struct Tyenv *env; struct Trait *trait; struct Htab *impls; struct Node **gimpl; unsigned long ngimpl; struct Node **gtype; unsigned long ngtype; char vis; char isglobl; char isconst; char isgeneric; char isextern; char ispkglocal; char ishidden; char isimport; char isnoret; char isexportval; char isinit; char isfini; } decl; struct { struct Tyenv *env; struct Stab *scope; struct Type *type; unsigned long nargs; struct Node **args; struct Node *body; } func; struct { struct Node *traitname; struct Trait *trait; struct Type *type; struct Type **aux; struct Tyenv *env; unsigned long naux; struct Node **decls; unsigned long ndecls; enum Vis vis; char isproto; char isextern; } impl; }; }

user_defined_types: struct Type { enum Ty type; unsigned int tid; struct Srcloc loc; enum Vis vis; struct Traitspec **spec; unsigned long nspec; struct Type *seqaux; struct Type **gparam; unsigned long ngparam; struct Type **arg; unsigned long narg; struct Type **inst; unsigned long ninst; struct Tyenv *env; struct Type **sub; unsigned long nsub; unsigned long nmemb; struct Bitset *trneed; union { struct Node *name; struct Node *asize; char *pname; struct Node **sdecls; struct Ucon **udecls; }; char hasparams; char isenum; char ishidden; char ispkglocal; char isimport; char isreflect; char isemitted; char resolved; char fixed; char tagged; }

user_defined_types: struct Tyenv { struct Tyenv *super; struct Htab *tab; }


check

decompiled_code:
__int64 __fastcall check(_QWORD *a1)
{
checkret(a1);
return checkreach((__int64)a1);
}

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

original_code:
void
check(Cfg *cfg)
{
 checkret(cfg);
 checkreach(cfg);
}

canonical_original_code:
void check(struct Cfg *cfg)
{
 checkret(cfg);
 checkreach(cfg);
}

user_defined_types: enum Ntype { Nnone=0, Nblock=1, Nifstmt=2, Nloopstmt=3, Niterstmt=4, Nmatchstmt=5, Nmatch=6, Nuse=7, Nexpr=8, Nlit=9, Nname=10, Ndecl=11, Nfunc=12, Nimpl=13 }

user_defined_types: struct Bb { int id; char **lbls; unsigned long nlbls; struct Node **nl; unsigned long nnl; struct Bitset *pred; struct Bitset *succ; }

user_defined_types: enum Op { Obad=0, Oauto=1, Oadd=2, Osub=3, Omul=4, Odiv=5, Omod=6, Oneg=7, Obor=8, Oband=9, Obxor=10, Obsl=11, Obsr=12, Obnot=13, Opreinc=14, Opostinc=15, Opredec=16, Opostdec=17, Oaddr=18, Oderef=19, Olor=20, Oland=21, Olnot=22, Oeq=23, One=24, Ogt=25, Oge=26, Olt=27, Ole=28, Oasn=29, Oaddeq=30, Osubeq=31, Omuleq=32, Odiveq=33, Omodeq=34, Oboreq=35, Obandeq=36, Obxoreq=37, Obsleq=38, Obsreq=39, Oidx=40, Oslice=41, Omemb=42, Otupmemb=43, Osize=44, Ocall=45, Ocast=46, Oret=47, Ojmp=48, Obreak=49, Ocontinue=50, Ovar=51, Ogap=52, Olit=53, Oucon=54, Otup=55, Ostruct=56, Oarr=57, Otern=58, Odead=59, Oundef=60, Odef=61, Ocjmp=62, Ovjmp=63, Oset=64, Osllen=65, Oslbase=66, Outag=67, Oudata=68, Otupget=69, Oblit=70, Oclear=71, Ocallind=72, Otrunc=73, Ozwiden=74, Oswiden=75, Oflt2int=76, Oint2flt=77, Oflt2flt=78, Ofadd=79, Ofsub=80, Ofmul=81, Ofdiv=82, Ofneg=83, Ofeq=84, Ofne=85, Ofgt=86, Ofge=87, Oflt=88, Ofle=89, Oueq=90, Oune=91, Ougt=92, Ouge=93, Oult=94, Oule=95, Numops=96 }

user_defined_types: enum Littype { Lchr=0, Lbool=1, Lint=2, Lflt=3, Lstr=4, Lfunc=5, Llbl=6, Lvoid=7 }

user_defined_types: enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 }

user_defined_types: struct Str { unsigned long len; char *buf; }

user_defined_types: struct Stab { struct Stab *super; char *name; char isfunc; struct Htab *dcl; struct Htab *env; struct Htab *ty; struct Htab *tr; struct Htab *uc; struct Htab *lbl; struct Htab *impl; struct Node **autotmp; unsigned long nautotmp; struct Node *exit[-1]; unsigned long ndisposed[-1]; }

user_defined_types: enum Ty { Tybad=0, Tyvoid=1, Tybool=2, Tychar=3, Tyint8=4, Tyint16=5, Tyint=6, Tyint32=7, Tyint64=8, Tybyte=9, Tyuint8=10, Tyuint16=11, Tyuint=12, Tyuint32=13, Tyuint64=14, Tyflt32=15, Tyflt64=16, Tyvalist=17, Typtr=18, Tyfunc=19, Tyslice=20, Tyarray=21, Tytuple=22, Tystruct=23, Tyunion=24, Tyvar=25, Typaram=26, Tyunres=27, Tyname=28, Tygeneric=29, Tycode=30, Ntypes=31 }

user_defined_types: struct Bitset { unsigned long nchunks; unsigned long *chunks; }

user_defined_types: struct Traitspec { struct Node **trait; unsigned long ntrait; struct Type *param; struct Type *aux; }

user_defined_types: struct Htab { unsigned long nelt; unsigned long ndead; unsigned long sz; unsigned long (*hash)(void *k); int (*cmp)(void *a, void *b); void **keys; void **vals; unsigned long *hashes; char *dead; }

user_defined_types: struct Ucon { struct Srcloc loc; unsigned long id; int synth; struct Node *name; struct Type *utype; struct Type *etype; }


tagreflect

decompiled_code:
__int64 __fastcall tagreflect(unsigned int *a1)
{
__int64 result; // rax
unsigned __int64 v3; // rbp
unsigned __int64 j; // rbp
unsigned __int64 i; // rbp
unsigned __int64 v6; // rbp
__int64 v7; // rax
__int64 v8; // rdi

result = hasparams();
if ( !(_DWORD)result && !*((_BYTE *)a1 + 149) )
{
*((_BYTE *)a1 + 149) = 1;
if ( *((_QWORD *)a1 + 14) )
{
v3 = 0LL;
do
tagreflect(*(_QWORD *)(*((_QWORD *)a1 + 13) + 8 * v3++));
while ( *((_QWORD *)a1 + 14) > v3 );
}
result = *a1;
if ( (_DWORD)result == 24 )
{
for ( i = 0LL; *((_QWORD *)a1 + 15) > i; ++i )
{
result = *(_QWORD *)(*((_QWORD *)a1 + 17) + 8 * i);
v8 = *(_QWORD *)(result + 40);
if ( v8 )
result = tagreflect(v8);
}
}
else if ( (_DWORD)result == 28 )
{
for ( j = 0LL; *((_QWORD *)a1 + 9) > j; ++j )
result = tagreflect(*(_QWORD *)(*((_QWORD *)a1 + 8) + 8 * j));
}
else if ( (_DWORD)result == 23 && *((_QWORD *)a1 + 15) )
{
v6 = 0LL;
do
{
v7 = decltype(*(_QWORD *)(*((_QWORD *)a1 + 17) + 8 * v6));
result = tagreflect(v7);
++v6;
}
while ( *((_QWORD *)a1 + 15) > v6 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1)
{
__int64 result; // rax
unsigned __int64 v3; // rbp
unsigned __int64 j; // rbp
unsigned __int64 i; // rbp
unsigned __int64 v6; // rbp
__int64 v7; // rax
__int64 v8; // rdi

result = hasparams();
if ( !(_DWORD)result && !*((_BYTE *)a1 + 149) )
{
*((_BYTE *)a1 + 149) = 1;
if ( *((_QWORD *)a1 + 14) )
{
v3 = 0LL;
do
func0(*(_QWORD *)(*((_QWORD *)a1 + 13) + 8 * v3++));
while ( *((_QWORD *)a1 + 14) > v3 );
}
result = *a1;
if ( (_DWORD)result == 24 )
{
for ( i = 0LL; *((_QWORD *)a1 + 15) > i; ++i )
{
result = *(_QWORD *)(*((_QWORD *)a1 + 17) + 8 * i);
v8 = *(_QWORD *)(result + 40);
if ( v8 )
result = func0(v8);
}
}
else if ( (_DWORD)result == 28 )
{
for ( j = 0LL; *((_QWORD *)a1 + 9) > j; ++j )
result = func0(*(_QWORD *)(*((_QWORD *)a1 + 8) + 8 * j));
}
else if ( (_DWORD)result == 23 && *((_QWORD *)a1 + 15) )
{
v6 = 0LL;
do
{
v7 = decltype(*(_QWORD *)(*((_QWORD *)a1 + 17) + 8 * v6));
result = func0(v7);
++v6;
}
while ( *((_QWORD *)a1 + 15) > v6 );
}
}
return result;
}

original_code:
void
tagreflect(Type *t)
{
 size_t i;
 if (hasparams(t) || t->isreflect)
  return;
 t->isreflect = 1;
 for (i = 0; i < t->nsub; i++)
  tagreflect(t->sub[i]);
 switch (t->type) {
 case Tystruct:
  for (i = 0; i < t->nmemb; i++)
   tagreflect(decltype(t->sdecls[i]));
  break;
 case Tyunion:
  for (i = 0; i < t->nmemb; i++)
   if (t->udecls[i]->etype)
    tagreflect(t->udecls[i]->etype);
  break;
 case Tyname:
  for (i = 0; i < t->narg; i++)
   tagreflect(t->arg[i]);
 default:
  break;
 }
}

canonical_original_code:
void tagreflect(struct Type *t)
{
 unsigned long i;
 if (hasparams(t) || t->isreflect)
  return;
 t->isreflect = 1;
 for (i = 0; i < t->nsub; i++)
  tagreflect(t->sub[i]);
 switch (t->type) {
 case Tystruct:
  for (i = 0; i < t->nmemb; i++)
   tagreflect(decltype(t->sdecls[i]));
  break;
 case Tyunion:
  for (i = 0; i < t->nmemb; i++)
   if (t->udecls[i]->etype)
    tagreflect(t->udecls[i]->etype);
  break;
 case Tyname:
  for (i = 0; i < t->narg; i++)
   tagreflect(t->arg[i]);
 default:
  break;
 }
}

user_defined_types: struct Trait { int uid; struct Srcloc loc; enum Vis vis; struct Node *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; }


isexportval

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

if ( *(_BYTE *)(a1 + 115) && !*(_QWORD *)(a1 + 64) )
result = 1LL;
else
result = (unsigned int)istyprimitive(*(_QWORD *)(a1 + 40)) != 0;
return result;
}

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

if ( *(_BYTE *)(a1 + 115) && !*(_QWORD *)(a1 + 64) )
result = 1LL;
else
result = (unsigned int)istyprimitive(*(_QWORD *)(a1 + 40)) != 0;
return result;
}

original_code:
int
isexportval(Node *n)
{
 if (n->decl.isgeneric && !n->decl.trait)
  return 1;
 if (istyprimitive(n->decl.type))
  return 1;
 return 0;
}

canonical_original_code:
int isexportval(struct Node *n)
{
 if (n->decl.isgeneric && !n->decl.trait)
  return 1;
 if (istyprimitive(n->decl.type))
  return 1;
 return 0;
}

return_type: int


tagexports

original_code:
void
tagexports(int hidelocal)
{
 size_t i, j, n;
 Trait *tr;
 Stab *st;
 void **k;
 Node *s;
 Type *t;
 st = file.globls;
 for (i = 0; i < file.ninit; i++)
  tagnode(st, file.init[i], 0, hidelocal);
 for (i = 0; i < file.nfini; i++)
  tagnode(st, file.fini[i], 0, hidelocal);
 if (file.localinit)
  tagnode(st, file.localinit, 0, hidelocal);
 if (file.localfini)
  tagnode(st, file.localfini, 0, hidelocal);
 k = htkeys(st->dcl, &n);
 for (i = 0; i < n; i++) {
  s = getdcl(st, k[i]);
  if (s->decl.vis == Visexport)
   tagnode(st, s, 0, hidelocal);
 }
 free(k);
 k = htkeys(st->ty, &n);
 for (i = 0; i < n; i++) {
  t = gettype(st, k[i]);
  if (!t->isreflect && t->vis != Visexport)
   continue;
  if (hidelocal && t->ispkglocal)
   t->vis = Vishidden;
  tagtype(st, t, 0, hidelocal);
  for (j = 0; j < t->nsub; j++)
   tagtype(st, t->sub[j], 0, hidelocal);
  if (t->type == Tyname) {
   tagreflect(t);
   for (j = 0; j < t->narg; j++)
    tagtype(st, t->arg[j], 0, hidelocal);
  } else if (t->type == Tygeneric) {
   for (j = 0; j < t->ngparam; j++)
    tagtype(st, t->gparam[j], 0, hidelocal);
  }
 }
 free(k);
 for (i = 0; i < ntraittab; i++) {
  tr = traittab[i];
  if (tr->vis != Visexport)
   continue;
  if (hidelocal && tr->ishidden)
   tr->vis = Vishidden;
  tagtype(st, tr->param, 0, hidelocal);
  tr->param->vis = tr->vis;
  for (j = 0; j < tr->naux; j++) {
   tagtype(st, tr->aux[j], 0, hidelocal);
   tr->aux[j]->vis = tr->vis;
  }
  for (j = 0; j < tr->nproto; j++) {
   tr->proto[j]->decl.vis = tr->vis;
   tagnode(st, tr->proto[j], 0, hidelocal);
  }
 }
 for (i = 0; i < nimpltab; i++) {
  s = impltab[i];
  if (s->impl.vis != Visexport)
   continue;
  tagnode(st, s, 0, hidelocal);
                tr = s->impl.trait;
  tagtrait(st, tr, 0, hidelocal);
  for (j = 0; j < tr->naux; j++)
   tr->aux[j]->vis = tr->vis;
 }
}

canonical_original_code:
void tagexports(int hidelocal)
{
 unsigned long i; unsigned long j; unsigned long n;
 struct Trait *tr;
 struct Stab *st;
 void **k;
 struct Node *s;
 struct Type *t;
 st = file.globls;
 for (i = 0; i < file.ninit; i++)
  tagnode(st, file.init[i], 0, hidelocal);
 for (i = 0; i < file.nfini; i++)
  tagnode(st, file.fini[i], 0, hidelocal);
 if (file.localinit)
  tagnode(st, file.localinit, 0, hidelocal);
 if (file.localfini)
  tagnode(st, file.localfini, 0, hidelocal);
 k = htkeys(st->dcl, &n);
 for (i = 0; i < n; i++) {
  s = getdcl(st, k[i]);
  if (s->decl.vis == Visexport)
   tagnode(st, s, 0, hidelocal);
 }
 free(k);
 k = htkeys(st->ty, &n);
 for (i = 0; i < n; i++) {
  t = gettype(st, k[i]);
  if (!t->isreflect && t->vis != Visexport)
   continue;
  if (hidelocal && t->ispkglocal)
   t->vis = Vishidden;
  tagtype(st, t, 0, hidelocal);
  for (j = 0; j < t->nsub; j++)
   tagtype(st, t->sub[j], 0, hidelocal);
  if (t->type == Tyname) {
   tagreflect(t);
   for (j = 0; j < t->narg; j++)
    tagtype(st, t->arg[j], 0, hidelocal);
  } else if (t->type == Tygeneric) {
   for (j = 0; j < t->ngparam; j++)
    tagtype(st, t->gparam[j], 0, hidelocal);
  }
 }
 free(k);
 for (i = 0; i < ntraittab; i++) {
  tr = traittab[i];
  if (tr->vis != Visexport)
   continue;
  if (hidelocal && tr->ishidden)
   tr->vis = Vishidden;
  tagtype(st, tr->param, 0, hidelocal);
  tr->param->vis = tr->vis;
  for (j = 0; j < tr->naux; j++) {
   tagtype(st, tr->aux[j], 0, hidelocal);
   tr->aux[j]->vis = tr->vis;
  }
  for (j = 0; j < tr->nproto; j++) {
   tr->proto[j]->decl.vis = tr->vis;
   tagnode(st, tr->proto[j], 0, hidelocal);
  }
 }
 for (i = 0; i < nimpltab; i++) {
  s = impltab[i];
  if (s->impl.vis != Visexport)
   continue;
  tagnode(st, s, 0, hidelocal);
                tr = s->impl.trait;
  tagtrait(st, tr, 0, hidelocal);
  for (j = 0; j < tr->naux; j++)
   tr->aux[j]->vis = tr->vis;
 }
}

variable_types: hidelocal int

variable_types:
n
unsigned long

variable_types: struct Trait { int uid; struct Srcloc { int line; int file; } loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Node { struct Srcloc loc; enum Ntype { Nnone=0, Nblock=1, Nifstmt=2, Nloopstmt=3, Niterstmt=4, Nmatchstmt=5, Nmatch=6, Nuse=7, Nexpr=8, Nlit=9, Nname=10, Ndecl=11, Nfunc=12, Nimpl=13 } type; int nid; char inferred; union { struct { enum Op { Obad=0, Oauto=1, Oadd=2, Osub=3, Omul=4, Odiv=5, Omod=6, Oneg=7, Obor=8, Oband=9, Obxor=10, Obsl=11, Obsr=12, Obnot=13, Opreinc=14, Opostinc=15, Opredec=16, Opostdec=17, Oaddr=18, Oderef=19, Olor=20, Oland=21, Olnot=22, Oeq=23, One=24, Ogt=25, Oge=26, Olt=27, Ole=28, Oasn=29, Oaddeq=30, Osubeq=31, Omuleq=32, Odiveq=33, Omodeq=34, Oboreq=35, Obandeq=36, Obxoreq=37, Obsleq=38, Obsreq=39, Oidx=40, Oslice=41, Omemb=42, Otupmemb=43, Osize=44, Ocall=45, Ocast=46, Oret=47, Ojmp=48, Obreak=49, Ocontinue=50, Ovar=51, Ogap=52, Olit=53, Oucon=54, Otup=55, Ostruct=56, Oarr=57, Otern=58, Odead=59, Oundef=60, Odef=61, Ocjmp=62, Ovjmp=63, Oset=64, Osllen=65, Oslbase=66, Outag=67, Oudata=68, Otupget=69, Oblit=70, Oclear=71, Ocallind=72, Otrunc=73, Ozwiden=74, Oswiden=75, Oflt2int=76, Oint2flt=77, Oflt2flt=78, Ofadd=79, Ofsub=80, Ofmul=81, Ofdiv=82, Ofneg=83, Ofeq=84, Ofne=85, Ofgt=86, Ofge=87, Oflt=88, Ofle=89, Oueq=90, Oune=91, Ougt=92, Ouge=93, Oult=94, Oule=95, Numops=96 } op; struct Type { enum Ty { Tybad=0, Tyvoid=1, Tybool=2, Tychar=3, Tyint8=4, Tyint16=5, Tyint=6, Tyint32=7, Tyint64=8, Tybyte=9, Tyuint8=10, Tyuint16=11, Tyuint=12, Tyuint32=13, Tyuint64=14, Tyflt32=15, Tyflt64=16, Tyvalist=17, Typtr=18, Tyfunc=19, Tyslice=20, Tyarray=21, Tytuple=22, Tystruct=23, Tyunion=24, Tyvar=25, Typaram=26, Tyunres=27, Tyname=28, Tygeneric=29, Tycode=30, Ntypes=31 } type; unsigned int tid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Traitspec { struct Node **trait; unsigned long ntrait; struct Type *param; struct Type *aux; } **spec; unsigned long nspec; struct Type *seqaux; struct Type **gparam; unsigned long ngparam; struct Type **arg; unsigned long narg; struct Type **inst; unsigned long ninst; struct Tyenv { struct Tyenv *super; struct Htab { unsigned long nelt; unsigned long ndead; unsigned long sz; unsigned long (*hash)(void *k); int (*cmp)(void *a, void *b); void **keys; void **vals; unsigned long *hashes; char *dead; } *tab; } *env; struct Type **sub; unsigned long nsub; unsigned long nmemb; struct Bitset { unsigned long nchunks; unsigned long *chunks; } *trneed; union { struct Node *name; struct Node *asize; char *pname; struct Node **sdecls; struct Ucon { struct Srcloc loc; unsigned long id; int synth; struct Node *name; struct Type *utype; struct Type *etype; } **udecls; }; char hasparams; char isenum; char ishidden; char ispkglocal; char isimport; char isreflect; char isemitted; char resolved; char fixed; char tagged; } *type; struct Type *param; int isconst; int ispat; unsigned long did; unsigned long nargs; struct Node *idx; struct Node **args; } expr; struct { char *ns; char *name; } name; struct { int islocal; char *name; } use; struct { enum Littype { Lchr=0, Lbool=1, Lint=2, Lflt=3, Lstr=4, Lfunc=5, Llbl=6, Lvoid=7 } littype; struct Type *type; unsigned long nelt; union { unsigned long long intval; double fltval; unsigned int chrval; struct Str { unsigned long len; char *buf; } strval; struct { char *lblval; char *lblname; }; int boolval; struct Node *fnval; }; } lit; struct { struct Node *init; struct Node *cond; struct Node *step; struct Node *body; struct Stab { struct Stab *super; char *name; char isfunc; struct Htab *dcl; struct Htab *env; struct Htab *ty; struct Htab *tr; struct Htab *uc; struct Htab *lbl; struct Htab *impl; struct Node **autotmp; unsigned long nautotmp; struct Node *exit[-1]; unsigned long ndisposed[-1]; } *scope; } loopstmt; struct { struct Node *elt; struct Node *seq; struct Node *body; } iterstmt; struct { struct Node *cond; struct Node *iftrue; struct Node *iffalse; } ifstmt; struct { struct Node *val; unsigned long nmatches; struct Node **matches; } matchstmt; struct { struct Node *pat; struct Node *block; } match; struct { struct Stab *scope; unsigned long nstmts; struct Node **stmts; } block; struct { unsigned long did; struct Node *name; struct Type *type; struct Node *init; struct Tyenv *env; struct Trait *trait; struct Htab *impls; struct Node **gimpl; unsigned long ngimpl; struct Node **gtype; unsigned long ngtype; char vis; char isglobl; char isconst; char isgeneric; char isextern; char ispkglocal; char ishidden; char isimport; char isnoret; char isexportval; char isinit; char isfini; } decl; struct { struct Tyenv *env; struct Stab *scope; struct Type *type; unsigned long nargs; struct Node **args; struct Node *body; } func; struct { struct Node *traitname; struct Trait *trait; struct Type *type; struct Type **aux; struct Tyenv *env; unsigned long naux; struct Node **decls; unsigned long ndecls; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; char isproto; char isextern; } impl; }; } *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; } *

variable_types: struct Stab { struct Stab *super; char *name; char isfunc; struct Htab { unsigned long nelt; unsigned long ndead; unsigned long sz; unsigned long (*hash)(void *k); int (*cmp)(void *a, void *b); void **keys; void **vals; unsigned long *hashes; char *dead; } *dcl; struct Htab *env; struct Htab *ty; struct Htab *tr; struct Htab *uc; struct Htab *lbl; struct Htab *impl; struct Node { struct Srcloc { int line; int file; } loc; enum Ntype { Nnone=0, Nblock=1, Nifstmt=2, Nloopstmt=3, Niterstmt=4, Nmatchstmt=5, Nmatch=6, Nuse=7, Nexpr=8, Nlit=9, Nname=10, Ndecl=11, Nfunc=12, Nimpl=13 } type; int nid; char inferred; union { struct { enum Op { Obad=0, Oauto=1, Oadd=2, Osub=3, Omul=4, Odiv=5, Omod=6, Oneg=7, Obor=8, Oband=9, Obxor=10, Obsl=11, Obsr=12, Obnot=13, Opreinc=14, Opostinc=15, Opredec=16, Opostdec=17, Oaddr=18, Oderef=19, Olor=20, Oland=21, Olnot=22, Oeq=23, One=24, Ogt=25, Oge=26, Olt=27, Ole=28, Oasn=29, Oaddeq=30, Osubeq=31, Omuleq=32, Odiveq=33, Omodeq=34, Oboreq=35, Obandeq=36, Obxoreq=37, Obsleq=38, Obsreq=39, Oidx=40, Oslice=41, Omemb=42, Otupmemb=43, Osize=44, Ocall=45, Ocast=46, Oret=47, Ojmp=48, Obreak=49, Ocontinue=50, Ovar=51, Ogap=52, Olit=53, Oucon=54, Otup=55, Ostruct=56, Oarr=57, Otern=58, Odead=59, Oundef=60, Odef=61, Ocjmp=62, Ovjmp=63, Oset=64, Osllen=65, Oslbase=66, Outag=67, Oudata=68, Otupget=69, Oblit=70, Oclear=71, Ocallind=72, Otrunc=73, Ozwiden=74, Oswiden=75, Oflt2int=76, Oint2flt=77, Oflt2flt=78, Ofadd=79, Ofsub=80, Ofmul=81, Ofdiv=82, Ofneg=83, Ofeq=84, Ofne=85, Ofgt=86, Ofge=87, Oflt=88, Ofle=89, Oueq=90, Oune=91, Ougt=92, Ouge=93, Oult=94, Oule=95, Numops=96 } op; struct Type { enum Ty { Tybad=0, Tyvoid=1, Tybool=2, Tychar=3, Tyint8=4, Tyint16=5, Tyint=6, Tyint32=7, Tyint64=8, Tybyte=9, Tyuint8=10, Tyuint16=11, Tyuint=12, Tyuint32=13, Tyuint64=14, Tyflt32=15, Tyflt64=16, Tyvalist=17, Typtr=18, Tyfunc=19, Tyslice=20, Tyarray=21, Tytuple=22, Tystruct=23, Tyunion=24, Tyvar=25, Typaram=26, Tyunres=27, Tyname=28, Tygeneric=29, Tycode=30, Ntypes=31 } type; unsigned int tid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Traitspec { struct Node **trait; unsigned long ntrait; struct Type *param; struct Type *aux; } **spec; unsigned long nspec; struct Type *seqaux; struct Type **gparam; unsigned long ngparam; struct Type **arg; unsigned long narg; struct Type **inst; unsigned long ninst; struct Tyenv { struct Tyenv *super; struct Htab *tab; } *env; struct Type **sub; unsigned long nsub; unsigned long nmemb; struct Bitset { unsigned long nchunks; unsigned long *chunks; } *trneed; union { struct Node *name; struct Node *asize; char *pname; struct Node **sdecls; struct Ucon { struct Srcloc loc; unsigned long id; int synth; struct Node *name; struct Type *utype; struct Type *etype; } **udecls; }; char hasparams; char isenum; char ishidden; char ispkglocal; char isimport; char isreflect; char isemitted; char resolved; char fixed; char tagged; } *type; struct Type *param; int isconst; int ispat; unsigned long did; unsigned long nargs; struct Node *idx; struct Node **args; } expr; struct { char *ns; char *name; } name; struct { int islocal; char *name; } use; struct { enum Littype { Lchr=0, Lbool=1, Lint=2, Lflt=3, Lstr=4, Lfunc=5, Llbl=6, Lvoid=7 } littype; struct Type *type; unsigned long nelt; union { unsigned long long intval; double fltval; unsigned int chrval; struct Str { unsigned long len; char *buf; } strval; struct { char *lblval; char *lblname; }; int boolval; struct Node *fnval; }; } lit; struct { struct Node *init; struct Node *cond; struct Node *step; struct Node *body; struct Stab *scope; } loopstmt; struct { struct Node *elt; struct Node *seq; struct Node *body; } iterstmt; struct { struct Node *cond; struct Node *iftrue; struct Node *iffalse; } ifstmt; struct { struct Node *val; unsigned long nmatches; struct Node **matches; } matchstmt; struct { struct Node *pat; struct Node *block; } match; struct { struct Stab *scope; unsigned long nstmts; struct Node **stmts; } block; struct { unsigned long did; struct Node *name; struct Type *type; struct Node *init; struct Tyenv *env; struct Trait { int uid; struct Srcloc loc; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; struct Node *name; struct Type *param; struct Type **aux; unsigned long naux; struct Node **proto; unsigned long nproto; struct Tyenv *env; char isproto; char ishidden; char isimport; } *trait; struct Htab *impls; struct Node **gimpl; unsigned long ngimpl; struct Node **gtype; unsigned long ngtype; char vis; char isglobl; char isconst; char isgeneric; char isextern; char ispkglocal; char ishidden; char isimport; char isnoret; char isexportval; char isinit; char isfini; } decl; struct { struct Tyenv *env; struct Stab *scope; struct Type *type; unsigned long nargs; struct Node **args; struct Node *body; } func; struct { struct Node *traitname; struct Trait *trait; struct Type *type; struct Type **aux; struct Tyenv *env; unsigned long naux; struct Node **decls; unsigned long ndecls; enum Vis { Visintern=0, Visexport=1, Vishidden=2, Visbuiltin=3 } vis; char isproto; char isextern; } impl; }; } **autotmp; unsigned long nautotmp; struct Node *exit[-1]; unsigned long ndisposed[-1]; } *

variable_types:
k
void **


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // rax
unsigned __int64 i; // rbx
FILE *v5; // rbx
__int64 v7[2]; // [rsp+0h] [rbp-58h] BYREF
unsigned __int64 v8; // [rsp+10h] [rbp-48h]

localincpath = (__int64)".";
optinit(v7, "sd:hmo:p:l:", argv, argc);
while ( !(unsigned int)optdone(v7) )
{
switch ( (unsigned int)optnext(v7) )
{
case 'd':
v3 = (_BYTE *)v7[0];
if ( v7[0] )
{
while ( *v3 )
{
v7[0] = (__int64)++v3;
debugopt[*(v3 - 1) & 0x7F] = 1;
}
}
break;
case 'h':
usage(*argv);
exit(0);
case 'l':
lappend(&extralibs, &nextralibs, v7[0]);
break;
case 'o':
outfile = (char *)v7[0];
break;
case 'p':
pkgname = v7[0];
break;
default:
usage(*argv);
exit(0);
}
}
if ( !outfile && !show )
{
fwrite("output file needed when merging usefiles.\n", 1uLL, 0x2AuLL, stderr);
exit(1);
}
if ( !pkgname )
{
fwrite("package needed when merging usefiles.\n", 1uLL, 0x26uLL, stderr);
exit(1);
}
initfile(file);
updatens(file[18], pkgname);
if ( v8 )
{
for ( i = 0LL; i < v8; ++i )
mergeuse(*(const char **)(v7[1] + 8 * i));
}
loaduses();
infer();
tagexports(1LL);
addextlibs(extralibs, nextralibs);
v5 = fopen(outfile, "w");
writeuse(v5);
fclose(v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // rax
unsigned __int64 i; // rbx
FILE *v5; // rbx
__int64 v7[2]; // [rsp+0h] [rbp-58h] BYREF
unsigned __int64 v8; // [rsp+10h] [rbp-48h]

localincpath = (__int64)".";
optinit(v7, "sd:hmo:p:l:", argv, argc);
while ( !(unsigned int)optdone(v7) )
{
switch ( (unsigned int)optnext(v7) )
{
case 'd':
v3 = (_BYTE *)v7[0];
if ( v7[0] )
{
while ( *v3 )
{
v7[0] = (__int64)++v3;
debugopt[*(v3 - 1) & 0x7F] = 1;
}
}
break;
case 'h':
func0(*argv);
exit(0);
case 'l':
lappend(&extralibs, &nextralibs, v7[0]);
break;
case 'o':
outfile = (char *)v7[0];
break;
case 'p':
pkgname = v7[0];
break;
default:
func0(*argv);
exit(0);
}
}
if ( !outfile && !show )
{
fwrite("output file needed when merging usefiles.\n", 1uLL, 0x2AuLL, stderr);
exit(1);
}
if ( !pkgname )
{
fwrite("package needed when merging usefiles.\n", 1uLL, 0x26uLL, stderr);
exit(1);
}
initfile(file);
updatens(file[18], pkgname);
if ( v8 )
{
for ( i = 0LL; i < v8; ++i )
func1(*(const char **)(v7[1] + 8 * i));
}
loaduses();
infer();
tagexports(1LL);
addextlibs(extralibs, nextralibs);
v5 = fopen(outfile, "w");
writeuse(v5);
fclose(v5);
return 0;
}

original_code:
int
main(int argc, char **argv)
{
 char buf[1024];
 Optctx ctx;
 size_t i;
 outfile = ((void *)0);
 optinit(&ctx, "cd:?hSo:I:9G:O:T", argv, argc);
 asmsyntax = Gnugaself;
 sizefn = size;
 while (!optdone(&ctx)) {
  switch (optnext(&ctx)) {
  case 'O':
   objdir = ctx.optarg;
   break;
  case 'o':
   outfile = ctx.optarg;
   break;
  case 'S':
   writeasm = 1;
   break;
  case '?':
  case 'h':
   usage(argv[0]);
   exit(0);
   break;
  case 'c':
   extracheck = 1;
   break;
  case 'd':
   while (ctx.optarg && *ctx.optarg)
    debugopt[*ctx.optarg++ & 0x7f]++;
   break;
  case '9':
   asmsyntax = Plan9;
   break;
  case 'G':
   if (!strcmp(ctx.optarg, "e"))
    asmsyntax = Gnugaself;
   else if (!strcmp(ctx.optarg, "m"))
    asmsyntax = Gnugasmacho;
   else
    die("unknown gnu syntax flavor");
   break;
  case 'I':
   lappend(&incpaths, &nincpaths, ctx.optarg);
   break;
  case 'T':
   allowhidden++;
   break;
  default:
   usage(argv[0]);
   exit(0);
   break;
  }
 }
 ;
 lappend(&incpaths, &nincpaths, "/usr/local" "/lib/myr");
 if (ctx.nargs == 0) {
  fprintf(stderr, "No input files given\n");
  exit(1);
 } else if (ctx.nargs > 1)
  outfile = ((void *)0);
 for (i = 0; i < ctx.nargs; i++) {
  if (outfile)
   localincpath = dirname(outfile);
  else
   localincpath = dirname(ctx.args[i]);
  initfile(&file, ctx.args[0]);
  tokinit(ctx.args[i]);
  yyparse();
  if (debugopt['T'])
   dump(stdout);
  loaduses();
  if (hasmain()) {
   genautocall(file.init, file.ninit,
       file.localinit, "__init__");
   genautocall(file.fini, file.nfini,
       file.localfini, "__fini__");
  }
  infer();
  tagexports(0);
  if (debugopt['t'])
   dump(stdout);
  if (writeasm) {
   if (outfile != ((void *)0))
    swapout(buf, sizeof buf, ".s");
   else
    swapsuffix(buf, sizeof buf, ctx.args[i], ".myr", ".s");
  } else {
   gentempfile(buf, sizeof buf, ctx.args[i], ".s");
  }
  genuse(ctx.args[i]);
  gen(buf);
  assemble(buf, ctx.args[i]);
  free(localincpath);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 char buf[1024];
 struct Optctx ctx;
 unsigned long i;
 outfile = ((void *)0);
 optinit(&ctx, "cd:?hSo:I:9G:O:T", argv, argc);
 asmsyntax = Gnugaself;
 sizefn = size;
 while (!optdone(&ctx)) {
  switch (optnext(&ctx)) {
  case 'O':
   objdir = ctx.optarg;
   break;
  case 'o':
   outfile = ctx.optarg;
   break;
  case 'S':
   writeasm = 1;
   break;
  case '?':
  case 'h':
   usage(argv[0]);
   exit(0);
   break;
  case 'c':
   extracheck = 1;
   break;
  case 'd':
   while (ctx.optarg && *ctx.optarg)
    debugopt[*ctx.optarg++ & 0x7f]++;
   break;
  case '9':
   asmsyntax = Plan9;
   break;
  case 'G':
   if (!strcmp(ctx.optarg, "e"))
    asmsyntax = Gnugaself;
   else if (!strcmp(ctx.optarg, "m"))
    asmsyntax = Gnugasmacho;
   else
    die("unknown gnu syntax flavor");
   break;
  case 'I':
   lappend(&incpaths, &nincpaths, ctx.optarg);
   break;
  case 'T':
   allowhidden++;
   break;
  default:
   usage(argv[0]);
   exit(0);
   break;
  }
 }
 ;
 lappend(&incpaths, &nincpaths, "/usr/local" "/lib/myr");
 if (ctx.nargs == 0) {
  fprintf(stderr, "No input files given\n");
  exit(1);
 } else if (ctx.nargs > 1)
  outfile = ((void *)0);
 for (i = 0; i < ctx.nargs; i++) {
  if (outfile)
   localincpath = dirname(outfile);
  else
   localincpath = dirname(ctx.args[i]);
  initfile(&file, ctx.args[0]);
  tokinit(ctx.args[i]);
  yyparse();
  if (debugopt['T'])
   dump(stdout);
  loaduses();
  if (hasmain()) {
   genautocall(file.init, file.ninit,
       file.localinit, "__init__");
   genautocall(file.fini, file.nfini,
       file.localfini, "__fini__");
  }
  infer();
  tagexports(0);
  if (debugopt['t'])
   dump(stdout);
  if (writeasm) {
   if (outfile != ((void *)0))
    swapout(buf, sizeof buf, ".s");
   else
    swapsuffix(buf, sizeof buf, ctx.args[i], ".myr", ".s");
  } else {
   gentempfile(buf, sizeof buf, ctx.args[i], ".s");
  }
  genuse(ctx.args[i]);
  gen(buf);
  assemble(buf, ctx.args[i]);
  free(localincpath);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
buf
char [1024]

variable_types: struct Optctx { char *optarg; char **args; unsigned long nargs; char *optstr; char **optargs; unsigned long noptargs; unsigned long argidx; int optdone; int finished; char *curarg; }


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
printf("%s [-hIdos] [-o outfile] [-p pkgname] [-m] inputs\n", a1);
puts("\t-h\tprint this help");
puts("\t\tThe outfile must be the same name as each package merged.");
puts("\t-d\tPrint debug dumps");
puts("\t-o out\tOutput to outfile");
return puts("\t-s\tShow the contents of usefiles `inputs`");
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
printf("%s [-hIdos] [-o outfile] [-p pkgname] [-m] inputs\n", a1);
puts("\t-h\tprint this help");
puts("\t\tThe outfile must be the same name as each package merged.");
puts("\t-d\tPrint debug dumps");
puts("\t-o out\tOutput to outfile");
return puts("\t-s\tShow the contents of usefiles `inputs`");
}

original_code:
static void
usage(char *prog)
{
 printf("%s [-?|-h] [-o outfile] [-O dir] [-d[dbgopts]] inputs\n", prog);
 printf("\t-?|-h\tPrint this help\n");
 printf("\t-o\tOutput to outfile\n");
 printf("\t-O dir\tOutput to dir\n");
 printf("\t-S\tGenerate assembly source alongside object code\n");
 printf("\t-T\tCompile in test mode\n");
 printf("\t-c\tEnable additional (possibly flaky) checking\n");
 printf("\t-I path\tAdd 'path' to use search path\n");
 printf("\t-d\tPrint debug dumps. Recognized options: f r p i\n");
 printf("\t-G\tGenerate asm in gas syntax\n");
 printf("\t-9\tGenerate asm in plan 9 syntax\n");
 printf("\t-d opts: additional debug logging. Options are listed below:\n");
 printf("\t\tf: log folded trees\n");
 printf("\t\tl: log lowered pre-cfg trees\n");
 printf("\t\tT: log tree immediately\n");
 printf("\t\tr: log register allocation activity\n");
 printf("\t\ti: log instruction selection activity\n");
 printf("\t\tu: log type unifications\n");
}

variable_types:
prog
char *


repo: orobitg/MTA

decompiled_code:
__int64 __fastcall declare_sequence(unsigned int a1, int a2, int a3)
{
__int64 v4; // rbx

v4 = vcalloc(1LL, 56LL);
*(_QWORD *)v4 = declare_char(a1, (unsigned int)(a2 + 1));
*(_QWORD *)(v4 + 8) = declare_char(a1, 101LL);
*(_QWORD *)(v4 + 48) = vcalloc(30LL, 1LL);
*(_QWORD *)(v4 + 16) = vcalloc((int)a1, 4LL);
*(_QWORD *)(v4 + 24) = vcalloc((int)a1, 4LL);
*(_DWORD *)(v4 + 40) = a2;
*(_DWORD *)(v4 + 36) = a3;
*(_DWORD *)(v4 + 32) = a1;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, int a2, int a3)
{
__int64 v4; // rbx

v4 = vcalloc(1LL, 56LL);
*(_QWORD *)v4 = declare_char(a1, (unsigned int)(a2 + 1));
*(_QWORD *)(v4 + 8) = declare_char(a1, 101LL);
*(_QWORD *)(v4 + 48) = vcalloc(30LL, 1LL);
*(_QWORD *)(v4 + 16) = vcalloc((int)a1, 4LL);
*(_QWORD *)(v4 + 24) = vcalloc((int)a1, 4LL);
*(_DWORD *)(v4 + 40) = a2;
*(_DWORD *)(v4 + 36) = a3;
*(_DWORD *)(v4 + 32) = a1;
return v4;
}

original_code:
Sequence *declare_sequence(int nseq, int max_len, int min_len){
    Sequence *LS;
    LS=vcalloc(1, sizeof(Sequence));
    LS->seq=declare_char(nseq, max_len+1);
    LS->seq_names=declare_char(nseq,100 +1);
    LS->type=vcalloc(30, sizeof (char));
    LS->seq_len=vcalloc(nseq, sizeof (int));
    LS->seq_id=vcalloc(nseq, sizeof (int));
    LS->max_len=max_len;
    LS->min_len=min_len;
    LS->nseq=nseq;
    return LS;
}

canonical_original_code:
struct Sequence *declare_sequence(int nseq, int max_len, int min_len){
    struct Sequence *LS;
    LS=vcalloc(1, sizeof(Sequence));
    LS->seq=declare_char(nseq, max_len+1);
    LS->seq_names=declare_char(nseq,100 +1);
    LS->type=vcalloc(30, sizeof (char));
    LS->seq_len=vcalloc(nseq, sizeof (int));
    LS->seq_id=vcalloc(nseq, sizeof (int));
    LS->max_len=max_len;
    LS->min_len=min_len;
    LS->nseq=nseq;
    return LS;
}

variable_types: nseq int

variable_types: struct Sequence { char **seq; char **seq_names; int *seq_len; int *seq_id; int nseq; int min_len; int max_len; char *type; } *


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

if ( a1 )
{
free_char(*a1, 0xFFFFFFFFLL);
free_char(a1[1], 0xFFFFFFFFLL);
vfree(a1[2]);
vfree(a1[6]);
vfree(a1[3]);
result = vfree(a1);
}
return result;
}

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

if ( a1 )
{
free_char(*a1, 0xFFFFFFFFLL);
free_char(a1[1], 0xFFFFFFFFLL);
vfree(a1[2]);
vfree(a1[6]);
vfree(a1[3]);
result = vfree(a1);
}
return result;
}

original_code:
void free_sequence(Sequence *LS){
    if (!LS) return;
    free_char(LS->seq, -1);
    free_char(LS->seq_names,-1);
    vfree(LS->seq_len);
    vfree(LS->type);
    vfree(LS->seq_id);
    vfree(LS);
}

canonical_original_code:
void free_sequence(struct Sequence *LS){
    if (!LS) return;
    free_char(LS->seq, -1);
    free_char(LS->seq_names,-1);
    vfree(LS->seq_len);
    vfree(LS->type);
    vfree(LS->seq_id);
    vfree(LS);
}

user_defined_types: struct Sequence { char **seq; char **seq_names; int *seq_len; int *seq_id; int nseq; int min_len; int max_len; char *type; }


decompiled_code:
_BOOL8 __fastcall is_in_set(char a1, const char *a2)
{
char needle[10]; // [rsp+Eh] [rbp-Ah] BYREF

needle[0] = a1;
return strstr(a2, needle) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(char a1, const char *a2)
{
char needle[10]; // [rsp+Eh] [rbp-Ah] BYREF

needle[0] = a1;
return strstr(a2, needle) != 0LL;
}

original_code:
int is_in_set(char r, char *list){
    char s[2];
    s[0]=r;
    if (strstr(list, s)!=((void *)0)){
        return 1;
    }
    else {
        return 0;
    }
}

variable_types: r char

variable_types:
list
char *

variable_types:
s
char [2]


decompiled_code:
_BOOL8 __fastcall is_aa(char a1)
{
_BOOL8 result; // rax

result = is_in_set(a1, "acdefghiklmnpqrstvwy-ACDEFGHIKLMNPQRSTVWY");
if ( result )
result = !is_in_set(a1, "-.#*~");
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(char a1)
{
_BOOL8 result; // rax

result = func5(a1, "acdefghiklmnpqrstvwy-ACDEFGHIKLMNPQRSTVWY");
if ( result )
result = !func5(a1, "-.#*~");
return result;
}

original_code:
int is_aa(char x){
    return (is_in_set (x, "acdefghiklmnpqrstvwy-ACDEFGHIKLMNPQRSTVWY") && !is_in_set (x, "-.#*~"));
}

variable_types: x char


decompiled_code:
_BOOL8 __fastcall is_rna(char a1)
{
_BOOL8 result; // rax

result = is_in_set(a1, "Uu");
if ( result )
result = !is_in_set(a1, "-.#*~");
return result;
}

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

result = func5(a1, "Uu");
if ( result )
result = !func5(a1, "-.#*~");
return result;
}

original_code:
int is_rna(char x){
    return (is_in_set (x, "Uu")&& !is_in_set (x, "-.#*~"));
}


decompiled_code:
_BOOL8 __fastcall is_dna(char a1)
{
_BOOL8 result; // rax

result = is_in_set(a1, "AGCTUNRYMKSWHBVD-agctunrymkswhbvd");
if ( result )
result = !is_in_set(a1, "-.#*~");
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(char a1)
{
_BOOL8 result; // rax

result = func5(a1, "AGCTUNRYMKSWHBVD-agctunrymkswhbvd");
if ( result )
result = !func5(a1, "-.#*~");
return result;
}

original_code:
int is_dna(char x){
    return (is_in_set (x, "AGCTUNRYMKSWHBVD-agctunrymkswhbvd")&& !is_in_set (x, "-.#*~"));
}


decompiled_code:
_BOOL8 __fastcall is_gap(char a1)
{
return is_in_set(a1, "-.#*~");
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(char a1)
{
return func5(a1, "-.#*~");
}

original_code:
int is_gap(char x){
    return (is_in_set( x, "-.#*~"));
}


original_code:
char *get_string_type(char *S){
    int a, l;
    int protein=0, dna=0,rna=0, tot=0;
    char *type;
    static char *ltype;
    static int warning;
    if(!ltype){
      (ltype=vcalloc ((((500) >(20)) ? (500):(20))+1, sizeof (char)));
    }
    (type=vcalloc ((((500) >(20)) ? (500):(20))+1, sizeof (char)));
    l=(int)strlen (S);
    if (l==0){
        sprintf ( type, "UNKNOWN");
        return type;
    }
    for(a=0; a<l; a++){
        if(!is_gap(S[a])){
            protein+=(is_aa (S[a]) && !is_dna(S[a]));
            dna+=(is_dna(S[a]));
            rna+=(is_rna(S[a]));
            tot++;
        }
    }
    protein=(protein*100)/tot;
    dna=(dna*100)/tot;
    rna=(rna*100)/tot;
    if(l<20 && warning==0){
        warning=1;
    }
    if(l<20 && ltype && ltype[0]){
        if(dna==100){
            sprintf ( type, "%s", ltype);
            ltype[0]='\0';
        }
        else
            sprintf ( type, "PROTEIN");
        }
    else if(dna>98 && rna>0){
        sprintf ( type, "RNA");
    }
    else if(dna>98){
        sprintf ( type, "DNA");
    }
    else{
        sprintf ( type, "PROTEIN");
    }
    sprintf ( ltype, "%s", type);
    return type;
}

canonical_original_code:
char *get_string_type(char *S){
    int a; int l;
    int protein = 0; int dna = 0; int rna = 0; int tot = 0;
    char *type;
    static char *ltype;
    static int warning;
    if(!ltype){
      (ltype=vcalloc ((((500) >(20)) ? (500):(20))+1, sizeof (char)));
    }
    (type=vcalloc ((((500) >(20)) ? (500):(20))+1, sizeof (char)));
    l=(int)strlen (S);
    if (l==0){
        sprintf ( type, "UNKNOWN");
        return type;
    }
    for(a=0; a<l; a++){
        if(!is_gap(S[a])){
            protein+=(is_aa (S[a]) && !is_dna(S[a]));
            dna+=(is_dna(S[a]));
            rna+=(is_rna(S[a]));
            tot++;
        }
    }
    protein=(protein*100)/tot;
    dna=(dna*100)/tot;
    rna=(rna*100)/tot;
    if(l<20 && warning==0){
        warning=1;
    }
    if(l<20 && ltype && ltype[0]){
        if(dna==100){
            sprintf ( type, "%s", ltype);
            ltype[0]='\0';
        }
        else
            sprintf ( type, "PROTEIN");
        }
    else if(dna>98 && rna>0){
        sprintf ( type, "RNA");
    }
    else if(dna>98){
        sprintf ( type, "DNA");
    }
    else{
        sprintf ( type, "PROTEIN");
    }
    sprintf ( ltype, "%s", type);
    return type;
}

variable_types:
S
char *

variable_types: a int

variable_types: l int

variable_types: protein int

variable_types: dna int

variable_types: rna int

variable_types: tot int

variable_types:
type
char *

variable_types:
ltype
char *

variable_types: warning int

return_type: char *


decompiled_code:
char *__fastcall get_array_type(int a1, const char **a2)
{
const char **v2; // rbx
char *v3; // r14
const char **v4; // rbp
__int64 v5; // r13
int v6; // er12
char *v7; // rbx
char *v8; // rax

v2 = a2;
v3 = (char *)vcalloc(100LL, 1LL);
if ( a1 <= 0 )
{
v7 = (char *)vcalloc(1LL, 1LL);
}
else
{
v4 = a2;
v5 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
v6 = 0;
do
v6 += strlen(*v2++);
while ( v2 != (const char **)v5 );
v7 = (char *)vcalloc(v6 + 1, 1LL);
do
strcat(v7, *v4++);
while ( v4 != (const char **)v5 );
}
v8 = get_string_type(v7);
strcpy(v3, v8);
vfree(v7);
return v3;
}

canonical_decompiled_code:
char *__fastcall func11(int a1, const char **a2)
{
const char **v2; // rbx
char *v3; // r14
const char **v4; // rbp
__int64 v5; // r13
int v6; // er12
char *v7; // rbx
char *v8; // rax

v2 = a2;
v3 = (char *)vcalloc(100LL, 1LL);
if ( a1 <= 0 )
{
v7 = (char *)vcalloc(1LL, 1LL);
}
else
{
v4 = a2;
v5 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
v6 = 0;
do
v6 += strlen(*v2++);
while ( v2 != (const char **)v5 );
v7 = (char *)vcalloc(v6 + 1, 1LL);
do
strcat(v7, *v4++);
while ( v4 != (const char **)v5 );
}
v8 = func10(v7);
strcpy(v3, v8);
vfree(v7);
return v3;
}

original_code:
char * get_array_type (int n, char **seq){
    char *buf, *buf2;
    int a, tot=0;
    buf2=vcalloc ( 100, sizeof (char));
    for(tot=0,a=0; a<n; a++){
        tot+=strlen (seq[a]);
    }
    buf=vcalloc (tot+1, sizeof (char));
    for ( a=0; a<n; a++){
        strcat (buf, seq[a]);
    }
    sprintf(buf2, "%s", get_string_type(buf));
    vfree (buf);
    return buf2;
}

canonical_original_code:
char *get_array_type(int n, char **seq){
    char *buf; char *buf2;
    int a; int tot = 0;
    buf2=vcalloc ( 100, sizeof (char));
    for(tot=0,a=0; a<n; a++){
        tot+=strlen (seq[a]);
    }
    buf=vcalloc (tot+1, sizeof (char));
    for ( a=0; a<n; a++){
        strcat (buf, seq[a]);
    }
    sprintf(buf2, "%s", get_string_type(buf));
    vfree (buf);
    return buf2;
}

variable_types: n int

variable_types:
seq
char **

variable_types:
buf
char *


decompiled_code:
__int64 __fastcall get_sequence_type(__int64 a1)
{
char *v1; // rax

if ( a1 )
{
v1 = get_array_type(*(_DWORD *)(a1 + 32), *(const char ***)a1);
strcpy(*(char **)(a1 + 48), v1);
}
return a1;
}

original_code:
Sequence *get_sequence_type(Sequence *S){
    if(!S){
        return ((void *)0);
    }
    else{
        sprintf(S->type, "%s", get_array_type (S->nseq, S->seq));
    }
    return S;
}

canonical_original_code:
struct Sequence *get_sequence_type(struct Sequence *S){
    if(!S){
        return ((void *)0);
    }
    else{
        sprintf(S->type, "%s", get_array_type (S->nseq, S->seq));
    }
    return S;
}

variable_types:
S
struct Sequence *

return_type: struct Sequence { char **seq; char **seq_names; int *seq_len; int *seq_id; int nseq; int min_len; int max_len; char *type; } *


decompiled_code:
__int64 __fastcall other_pg_identify_tree(_QWORD *a1)
{
__int64 v1; // rbx
unsigned int v2; // er12
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rbp
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7[0] = 0;
fwrite("\nTREE IDENTIFICATION METHOD:\n", 1uLL, 0x1DuLL, stdout);
v1 = read_fasta_sequences(*a1);
v2 = *(_DWORD *)(v1 + 32);
v3 = read_tree(a1[12], v7, v2, *(_QWORD *)(v1 + 8), *(_QWORD *)(v1 + 24), 0LL);
*(_DWORD *)(**(_QWORD **)(v3 + 24) + 176LL) = 0;
v4 = vcalloc((int)(5 * v2), 1LL);
v5 = identify_tree(**(_QWORD **)(v3 + 24), v4, *(unsigned int *)(v1 + 32));
free_sequence(v1);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 v1; // rbx
unsigned int v2; // er12
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rbp
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7[0] = 0;
fwrite("\nTREE IDENTIFICATION METHOD:\n", 1uLL, 0x1DuLL, stdout);
v1 = read_fasta_sequences(*a1);
v2 = *(_DWORD *)(v1 + 32);
v3 = read_tree(a1[12], v7, v2, *(_QWORD *)(v1 + 8), *(_QWORD *)(v1 + 24), 0LL);
*(_DWORD *)(**(_QWORD **)(v3 + 24) + 176LL) = 0;
v4 = vcalloc((int)(5 * v2), 1LL);
v5 = identify_tree(**(_QWORD **)(v3 + 24), v4, *(unsigned int *)(v1 + 32));
free_sequence(v1);
return v5;
}

original_code:
char* other_pg_identify_tree(Parameters *P){
    char *tree_id;
    NT_node **T;
    Sequence *S;
    int tot_node=0, tree_id_lenght=0;
    fprintf(stdout, "\nTREE IDENTIFICATION METHOD:\n");
    S=read_fasta_sequences(P->seqfile);
    tree_id_lenght = (5 * S->nseq);
    T=read_tree(P->tree_file, &tot_node, S->nseq, S->seq_names, S->seq_id, ((void *)0));
    T[3][0]->level = 0;
    tree_id = vcalloc(tree_id_lenght, sizeof(char));
    tree_id = identify_tree(T[3][0], tree_id, S->nseq);
    free_sequence(S);
    return tree_id;
 }

canonical_original_code:
char *other_pg_identify_tree(struct Parameters *P){
    char *tree_id;
    struct tnode ***T;
    struct Sequence *S;
    int tot_node = 0; int tree_id_lenght = 0;
    fprintf(stdout, "\nTREE IDENTIFICATION METHOD:\n");
    S=read_fasta_sequences(P->seqfile);
    tree_id_lenght = (5 * S->nseq);
    T=read_tree(P->tree_file, &tot_node, S->nseq, S->seq_names, S->seq_id, ((void *)0));
    T[3][0]->level = 0;
    tree_id = vcalloc(tree_id_lenght, sizeof(char));
    tree_id = identify_tree(T[3][0], tree_id, S->nseq);
    free_sequence(S);
    return tree_id;
 }

variable_types: struct Parameters { char *seqfile; int ntree; int seq_activated; int rep; int nattemps; int tree_id_activated; int random_percentage; int only_tree; int only_aln; char *dm_method; char *align_method; char *align_method_bin; char *score_method; char *outdir; char *workdir; char *tree_id_file; char *tree_file; char *tree_list; int treelist; int mpi_mode; int other_pg; char *other_pg_mode; char *mat; float gop; float gep; float egap; char *str_file; char *irmsd_file; struct Fname { char *name; char *path; char *suffix; char *full; } *F; struct Paths { char *mta_home; char *tcoffee_bin; char *clustalw_bin; char *clustalo_bin; char *mafft_bin; char *normd_bin; char *strike_bin; char *tc_score_bin; char *nwtomafft; char *retree_bin; } *PB; } *

variable_types: struct tnode { int visited; char *name; char *file; int seq_id; struct tnode *parent; struct tnode *left; struct tnode *right; struct tnode *bot; int isseq; int seq; int maxnseq; int nseq; int nnodes; int *lseq; int *lseq2; int *idist; int *ldist; float dist; float bootstrap; float dp; int order; int aligned; int leaf; int node; int group; float score; int align; char *seqal; int index; int fork; int level; int iscluster; int isorcluster; int ant; int cl_id; } ***

variable_types: struct Sequence { char **seq; char **seq_names; int *seq_len; int *seq_id; int nseq; int min_len; int max_len; char *type; } *

user_defined_types: struct Parameters { char *seqfile; int ntree; int seq_activated; int rep; int nattemps; int tree_id_activated; int random_percentage; int only_tree; int only_aln; char *dm_method; char *align_method; char *align_method_bin; char *score_method; char *outdir; char *workdir; char *tree_id_file; char *tree_file; char *tree_list; int treelist; int mpi_mode; int other_pg; char *other_pg_mode; char *mat; float gop; float gep; float egap; char *str_file; char *irmsd_file; struct Fname *F; struct Paths *PB; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r13
__int64 v4; // r15
_QWORD *v5; // rbx
const char *v6; // rbp
int v7; // er12
int v8; // er14
__int64 v9; // rax
__int64 v10; // rax
double v11; // xmm0_8
__int64 v13; // [rsp+0h] [rbp-48h]
double v14; // [rsp+8h] [rbp-40h]

if ( (unsigned int)search_mode(argc, argv, "-other_pg") )
{
v5 = (_QWORD *)read_parameters((unsigned int)argc, argv);
if ( !(unsigned int)vstrcmp(v5[16], "-tree_id") )
{
v6 = (const char *)other_pg_identify_tree(v5);
fprintf(stdout, "\nTree id: %s\n", v6);
vfree(v6);
free_parameters(v5);
exit(0);
}
fwrite("ERROR: BAD OTHER PROGRAM MODE\n", 1uLL, 0x1EuLL, stderr);
exit(1);
}
v7 = 0;
v8 = search_mode((unsigned int)argc, argv, "-mpi");
v14 = get_time();
if ( !v8 )
{
v3 = read_parameters((unsigned int)argc, argv);
fprintf(stdout, "\n------------------- MTA ~ Version %s ---------------------------\n\n", "2.0.1");
fwrite("Input Files:\n", 1uLL, 0xDuLL, stdout);
fprintf(
stdout,
"\tInput: (Sequences) %s.%s\n",
**(const char ***)(v3 + 176),
*(const char **)(*(_QWORD *)(v3 + 176) + 16LL));
fprintf(stdout, "\tInput: (MSA tool) %s\n", *(const char **)(v3 + 48));
fprintf(stdout, "\tInput: (Score strategy) %s\n", *(const char **)(v3 + 64));
fprintf(stdout, "\tInput: (Number of trees) %d\n", *(unsigned int *)(v3 + 8));
fprintf(stdout, "\tOutput: (Output folder) %s\n", *(const char **)(v3 + 72));
mkdir(*(const char **)(v3 + 72), 0x1C0u);
mkdir(*(const char **)(v3 + 80), 0x1C0u);
v9 = read_fasta_sequences(*(_QWORD *)v3);
v4 = v9;
if ( !v9 )
{
fwrite("Error - No Sequences\n", 1uLL, 0x15uLL, stderr);
return 1;
}
v10 = make_distance_matrix(v9, *(_QWORD *)(v3 + 40));
v13 = v10;
if ( *(_DWORD *)(v3 + 16) )
mta_program_repeated_trees(v3, v4, v10);
else
mta_program_no_repeated_trees(v3, v4, v10);
fwrite("\nOUTPUT RESULTS:\n", 1uLL, 0x11uLL, stdout);
fprintf(stdout, "\tFile Type: Guide Tree / Format: Newick / File Name: %s.dnd\n", **(const char ***)(v3 + 176));
fprintf(stdout, "\tFile Type: Alignment / Format: Fasta / File Name: %s.fasta_aln\n", **(const char ***)(v3 + 176));
fprintf(stdout, "\tFile Type: Scores / Format: txt / File Name: %s.scores\n", **(const char ***)(v3 + 176));
v11 = get_time();
fprintf(stdout, "\nMultiples Trees Method Time: %f seconds\n", v11 - v14);
}
free_parameters(v3);
free_distance_matrix(v13);
free_sequence(v4);
return v7;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r13
__int64 v4; // r15
_QWORD *v5; // rbx
const char *v6; // rbp
int v7; // er12
int v8; // er14
__int64 v9; // rax
__int64 v10; // rax
double v11; // xmm0_8
__int64 v13; // [rsp+0h] [rbp-48h]
double v14; // [rsp+8h] [rbp-40h]

if ( (unsigned int)search_mode(argc, argv, "-other_pg") )
{
v5 = (_QWORD *)read_parameters((unsigned int)argc, argv);
if ( !(unsigned int)vstrcmp(v5[16], "-tree_id") )
{
v6 = (const char *)func0(v5);
fprintf(stdout, "\nTree id: %s\n", v6);
vfree(v6);
free_parameters(v5);
exit(0);
}
fwrite("ERROR: BAD OTHER PROGRAM MODE\n", 1uLL, 0x1EuLL, stderr);
exit(1);
}
v7 = 0;
v8 = search_mode((unsigned int)argc, argv, "-mpi");
v14 = get_time();
if ( !v8 )
{
v3 = read_parameters((unsigned int)argc, argv);
fprintf(stdout, "\n------------------- MTA ~ Version %s ---------------------------\n\n", "2.0.1");
fwrite("Input Files:\n", 1uLL, 0xDuLL, stdout);
fprintf(
stdout,
"\tInput: (Sequences) %s.%s\n",
**(const char ***)(v3 + 176),
*(const char **)(*(_QWORD *)(v3 + 176) + 16LL));
fprintf(stdout, "\tInput: (MSA tool) %s\n", *(const char **)(v3 + 48));
fprintf(stdout, "\tInput: (Score strategy) %s\n", *(const char **)(v3 + 64));
fprintf(stdout, "\tInput: (Number of trees) %d\n", *(unsigned int *)(v3 + 8));
fprintf(stdout, "\tOutput: (Output folder) %s\n", *(const char **)(v3 + 72));
mkdir(*(const char **)(v3 + 72), 0x1C0u);
mkdir(*(const char **)(v3 + 80), 0x1C0u);
v9 = read_fasta_sequences(*(_QWORD *)v3);
v4 = v9;
if ( !v9 )
{
fwrite("Error - No Sequences\n", 1uLL, 0x15uLL, stderr);
return 1;
}
v10 = make_distance_matrix(v9, *(_QWORD *)(v3 + 40));
v13 = v10;
if ( *(_DWORD *)(v3 + 16) )
mta_program_repeated_trees(v3, v4, v10);
else
mta_program_no_repeated_trees(v3, v4, v10);
fwrite("\nOUTPUT RESULTS:\n", 1uLL, 0x11uLL, stdout);
fprintf(stdout, "\tFile Type: Guide Tree / Format: Newick / File Name: %s.dnd\n", **(const char ***)(v3 + 176));
fprintf(stdout, "\tFile Type: Alignment / Format: Fasta / File Name: %s.fasta_aln\n", **(const char ***)(v3 + 176));
fprintf(stdout, "\tFile Type: Scores / Format: txt / File Name: %s.scores\n", **(const char ***)(v3 + 176));
v11 = get_time();
fprintf(stdout, "\nMultiples Trees Method Time: %f seconds\n", v11 - v14);
}
free_parameters(v3);
free_distance_matrix(v13);
free_sequence(v4);
return v7;
}

original_code:
int main(int argc, char** argv) {
    Parameters *P;
    Sequence *S;
    Distance_matrix *DM;
    double tini=0.0, tfi=0.0;
    int mpi_mode = 0;
    int other_pg = 0;
    other_pg = search_mode(argc, argv, "-other_pg");
    if(other_pg){
        P = read_parameters(argc, argv);
        if((vstrcmp((P->other_pg_mode), ("-tree_id")) == 0)){
            char* tree_id;
            tree_id = other_pg_identify_tree(P);
            fprintf(stdout, "\nTree id: %s\n", tree_id);
            vfree(tree_id);
            free_parameters(P);
            exit(0);
        }
        else {
            fprintf(stderr, "ERROR: BAD OTHER PROGRAM MODE\n");
            exit(1);
        }
        free_parameters(P);
    }
    mpi_mode = search_mode(argc, argv, "-mpi");
    tini = get_time();
    if(mpi_mode == 0) {
        double max_score;
        P = read_parameters(argc, argv);
  fprintf(stdout, "\n------------------- MTA ~ Version %s ---------------------------\n\n", "2.0.1");
  fprintf(stdout, "Input Files:\n");
  fprintf(stdout, "\tInput: (Sequences) %s.%s\n", (P->F)->name, (P->F)->suffix);
  fprintf(stdout, "\tInput: (MSA tool) %s\n", P->align_method);
  fprintf(stdout, "\tInput: (Score strategy) %s\n", P->score_method);
  fprintf(stdout, "\tInput: (Number of trees) %d\n", P->ntree);
  fprintf(stdout, "\tOutput: (Output folder) %s\n", P->outdir);
  mkdir(P->outdir, 0700);
  mkdir(P->workdir, 0700);
        S=read_fasta_sequences(P->seqfile);
        if(S==((void *)0)){
            fprintf(stderr, "Error - No Sequences\n");
            return(1);
        }
        DM = make_distance_matrix(S, P->dm_method);
        if(P->rep){
            max_score = mta_program_repeated_trees(P, S, DM);
        }
        else{
            max_score = mta_program_no_repeated_trees(P, S, DM);
        }
        fprintf(stdout, "\nOUTPUT RESULTS:\n");
        fprintf(stdout,"\tFile Type: Guide Tree / Format: Newick / File Name: %s.dnd\n", (P->F)->name);
        fprintf(stdout,"\tFile Type: Alignment / Format: Fasta / File Name:  %s.fasta_aln\n", (P->F)->name);
        fprintf(stdout,"\tFile Type: Scores / Format: txt / File Name: %s.scores\n", (P->F)->name);
        tfi = get_time();
        fprintf(stdout,"\nMultiples Trees Method Time: %f seconds\n", tfi-tini);
    }
    free_parameters(P);
    free_distance_matrix(DM);
    free_sequence(S);
    return (0);
}

canonical_original_code:
int main(int argc, char **argv) {
    struct Parameters *P;
    struct Sequence *S;
    struct Distance_matrix *DM;
    double tini = 0.0; double tfi = 0.0;
    int mpi_mode = 0;
    int other_pg = 0;
    other_pg = search_mode(argc, argv, "-other_pg");
    if(other_pg){
        P = read_parameters(argc, argv);
        if((vstrcmp((P->other_pg_mode), ("-tree_id")) == 0)){
            char *tree_id;
            tree_id = other_pg_identify_tree(P);
            fprintf(stdout, "\nTree id: %s\n", tree_id);
            vfree(tree_id);
            free_parameters(P);
            exit(0);
        }
        else {
            fprintf(stderr, "ERROR: BAD OTHER PROGRAM MODE\n");
            exit(1);
        }
        free_parameters(P);
    }
    mpi_mode = search_mode(argc, argv, "-mpi");
    tini = get_time();
    if(mpi_mode == 0) {
        double max_score;
        P = read_parameters(argc, argv);
  fprintf(stdout, "\n------------------- MTA ~ Version %s ---------------------------\n\n", "2.0.1");
  fprintf(stdout, "Input Files:\n");
  fprintf(stdout, "\tInput: (Sequences) %s.%s\n", (P->F)->name, (P->F)->suffix);
  fprintf(stdout, "\tInput: (MSA tool) %s\n", P->align_method);
  fprintf(stdout, "\tInput: (Score strategy) %s\n", P->score_method);
  fprintf(stdout, "\tInput: (Number of trees) %d\n", P->ntree);
  fprintf(stdout, "\tOutput: (Output folder) %s\n", P->outdir);
  mkdir(P->outdir, 0700);
  mkdir(P->workdir, 0700);
        S=read_fasta_sequences(P->seqfile);
        if(S==((void *)0)){
            fprintf(stderr, "Error - No Sequences\n");
            return(1);
        }
        DM = make_distance_matrix(S, P->dm_method);
        if(P->rep){
            max_score = mta_program_repeated_trees(P, S, DM);
        }
        else{
            max_score = mta_program_no_repeated_trees(P, S, DM);
        }
        fprintf(stdout, "\nOUTPUT RESULTS:\n");
        fprintf(stdout,"\tFile Type: Guide Tree / Format: Newick / File Name: %s.dnd\n", (P->F)->name);
        fprintf(stdout,"\tFile Type: Alignment / Format: Fasta / File Name:  %s.fasta_aln\n", (P->F)->name);
        fprintf(stdout,"\tFile Type: Scores / Format: txt / File Name: %s.scores\n", (P->F)->name);
        tfi = get_time();
        fprintf(stdout,"\nMultiples Trees Method Time: %f seconds\n", tfi-tini);
    }
    free_parameters(P);
    free_distance_matrix(DM);
    free_sequence(S);
    return (0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct Distance_matrix { int nseq; int **similarity_matrix; int **score_similarity_matrix; int **distance_matrix; } *

variable_types: tini double

variable_types: tfi double

user_defined_types: struct Fname { char *name; char *path; char *suffix; char *full; }

user_defined_types: struct Paths { char *mta_home; char *tcoffee_bin; char *clustalw_bin; char *clustalo_bin; char *mafft_bin; char *normd_bin; char *strike_bin; char *tc_score_bin; char *nwtomafft; char *retree_bin; }


decompiled_code:
__int64 __fastcall align_tree(__int64 a1, const char *a2, const char *a3, const char *a4, unsigned int a5)
{
char *v8; // rbp
const char *v9; // rdx
const char *v11; // rdx
__int64 v12; // rax
const char *v13; // r12
__int64 v14; // rax
char *v15; // r14

v8 = (char *)vcalloc(1000LL, 1LL);
if ( !(unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "t_coffee") )
{
v9 = *(const char **)(*(_QWORD *)(a1 + 184) + 8LL);
if ( !v9 )
{
fwrite("Error - T-Coffee not found. Correct T-Coffee path\n", 1uLL, 0x32uLL, stderr);
exit(1);
}
if ( *(_DWORD *)(a1 + 116) || !a3 )
{
if ( *(_DWORD *)(a1 + 8) < np )
{
sprintf(
v8,
"%s %s -usetree %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1",
v9,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a4);
goto LABEL_10;
}
}
else if ( !a5 )
{
sprintf(
v8,
"%s %s -usetree %s -out_lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1",
v9,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a3,
a4);
LABEL_10:
system(v8);
return vfree(v8);
}
sprintf(
v8,
"%s %s -usetree %s -lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1",
v9,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a3,
a4);
goto LABEL_10;
}
if ( (unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "clustalw") )
{
if ( (unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "clustalo") )
{
if ( (unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "mafft") )
{
fwrite("Error - Bad MSA Method\n", 1uLL, 0x17uLL, stderr);
exit(1);
}
v14 = *(_QWORD *)(a1 + 184);
if ( !*(_QWORD *)(v14 + 32) || !*(_QWORD *)(v14 + 64) )
{
fwrite("Error - Mafft not found. Correct Mafft path\n", 1uLL, 0x2CuLL, stderr);
exit(1);
}
v15 = (char *)vcalloc(1000LL, 1LL);
root_unrooted_tree(a2, a5, *(_QWORD *)(*(_QWORD *)(a1 + 184) + 72LL));
sprintf(v15, "%s%s_%d.mafft", *(const char **)(a1 + 72), **(const char ***)(a1 + 176), a5);
sprintf(v8, "%s %s > %s", *(const char **)(*(_QWORD *)(a1 + 184) + 64LL), a2, v15);
system(v8);
sprintf(
v8,
"%s --auto --treein %s %s > %s 2> /dev/null",
*(const char **)(*(_QWORD *)(a1 + 184) + 32LL),
v15,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a4);
system(v8);
remove_file(v15);
vfree(v15);
}
else
{
v12 = *(_QWORD *)(a1 + 184);
if ( !*(_QWORD *)(v12 + 24) )
{
fwrite("Error - ClustalO not found. Correct ClustalO path\n", 1uLL, 0x32uLL, stderr);
exit(1);
}
v13 = (const char *)root_unrooted_tree(a2, a5, *(_QWORD *)(v12 + 72));
sprintf(
v8,
"%s -i %s --guidetree-in=%s --outfmt=fa -o %s",
*(const char **)(*(_QWORD *)(a1 + 184) + 24LL),
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
v13,
a4);
system(v8);
remove_file(v13);
vfree(v13);
}
}
else
{
v11 = *(const char **)(*(_QWORD *)(a1 + 184) + 16LL);
if ( !v11 )
{
fwrite("Error - ClustalW not found. Correct ClustalW path\n", 1uLL, 0x32uLL, stderr);
exit(1);
}
sprintf(
v8,
"%s -infile=%s -usetree=%s -output=fasta -outfile=%s > /dev/null 2>&1",
v11,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a4);
system(v8);
}
return vfree(v8);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, const char *a3, const char *a4, unsigned int a5)
{
char *v8; // rbp
const char *v9; // rdx
const char *v11; // rdx
__int64 v12; // rax
const char *v13; // r12
__int64 v14; // rax
char *v15; // r14

v8 = (char *)vcalloc(1000LL, 1LL);
if ( !(unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "t_coffee") )
{
v9 = *(const char **)(*(_QWORD *)(a1 + 184) + 8LL);
if ( !v9 )
{
fwrite("Error - T-Coffee not found. Correct T-Coffee path\n", 1uLL, 0x32uLL, stderr);
exit(1);
}
if ( *(_DWORD *)(a1 + 116) || !a3 )
{
if ( *(_DWORD *)(a1 + 8) < np )
{
sprintf(
v8,
"%s %s -usetree %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1",
v9,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a4);
goto LABEL_10;
}
}
else if ( !a5 )
{
sprintf(
v8,
"%s %s -usetree %s -out_lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1",
v9,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a3,
a4);
LABEL_10:
system(v8);
return vfree(v8);
}
sprintf(
v8,
"%s %s -usetree %s -lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1",
v9,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a3,
a4);
goto LABEL_10;
}
if ( (unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "clustalw") )
{
if ( (unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "clustalo") )
{
if ( (unsigned int)vstrcmp(*(_QWORD *)(a1 + 48), "mafft") )
{
fwrite("Error - Bad MSA Method\n", 1uLL, 0x17uLL, stderr);
exit(1);
}
v14 = *(_QWORD *)(a1 + 184);
if ( !*(_QWORD *)(v14 + 32) || !*(_QWORD *)(v14 + 64) )
{
fwrite("Error - Mafft not found. Correct Mafft path\n", 1uLL, 0x2CuLL, stderr);
exit(1);
}
v15 = (char *)vcalloc(1000LL, 1LL);
root_unrooted_tree(a2, a5, *(_QWORD *)(*(_QWORD *)(a1 + 184) + 72LL));
sprintf(v15, "%s%s_%d.mafft", *(const char **)(a1 + 72), **(const char ***)(a1 + 176), a5);
sprintf(v8, "%s %s > %s", *(const char **)(*(_QWORD *)(a1 + 184) + 64LL), a2, v15);
system(v8);
sprintf(
v8,
"%s --auto --treein %s %s > %s 2> /dev/null",
*(const char **)(*(_QWORD *)(a1 + 184) + 32LL),
v15,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a4);
system(v8);
remove_file(v15);
vfree(v15);
}
else
{
v12 = *(_QWORD *)(a1 + 184);
if ( !*(_QWORD *)(v12 + 24) )
{
fwrite("Error - ClustalO not found. Correct ClustalO path\n", 1uLL, 0x32uLL, stderr);
exit(1);
}
v13 = (const char *)root_unrooted_tree(a2, a5, *(_QWORD *)(v12 + 72));
sprintf(
v8,
"%s -i %s --guidetree-in=%s --outfmt=fa -o %s",
*(const char **)(*(_QWORD *)(a1 + 184) + 24LL),
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
v13,
a4);
system(v8);
remove_file(v13);
vfree(v13);
}
}
else
{
v11 = *(const char **)(*(_QWORD *)(a1 + 184) + 16LL);
if ( !v11 )
{
fwrite("Error - ClustalW not found. Correct ClustalW path\n", 1uLL, 0x32uLL, stderr);
exit(1);
}
sprintf(
v8,
"%s -infile=%s -usetree=%s -output=fasta -outfile=%s > /dev/null 2>&1",
v11,
*(const char **)(*(_QWORD *)(a1 + 176) + 24LL),
a2,
a4);
system(v8);
}
return vfree(v8);
}

original_code:
void align_tree(Parameters *P, char *treename, char *libname, char *alnname, int ntree){
    char *align_app;
    int ret;
    align_app = (char *) vcalloc(1000, sizeof(char));
    if((vstrcmp((P->align_method), ("t_coffee")) == 0)){
        if((P->PB)->tcoffee_bin != ((void *)0)){
            if(P->mpi_mode == 0 && libname != ((void *)0)){
                if(ntree == 0){
                    sprintf(align_app, "%s %s -usetree %s -out_lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, libname,alnname);
                }
                else {
                    sprintf(align_app, "%s %s -usetree %s -lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, libname, alnname);
                }
            }
            else {
                if(P->ntree >= np){
                    sprintf(align_app, "%s %s -usetree %s -lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, libname, alnname);
                }
                else {
                    sprintf(align_app, "%s %s -usetree %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, alnname);
                }
            }
            ret=system(align_app);
        }
        else {
            fprintf(stderr, "Error - T-Coffee not found. Correct T-Coffee path\n");
            exit(1);
        }
    }
    else if((vstrcmp((P->align_method), ("clustalw")) == 0)){
        if((P->PB)->clustalw_bin != ((void *)0)){
            sprintf(align_app, "%s -infile=%s -usetree=%s -output=fasta -outfile=%s > /dev/null 2>&1", (P->PB)->clustalw_bin, (P->F)->full, treename, alnname);
            ret=system(align_app);
        }
        else {
            fprintf(stderr, "Error - ClustalW not found. Correct ClustalW path\n");
            exit(1);
        }
    }
    else if((vstrcmp((P->align_method), ("clustalo")) == 0)){
        if((P->PB)->clustalo_bin != ((void *)0)){
            char *treename2;
            treename2 = root_unrooted_tree(treename, ntree, (P->PB)->retree_bin);
            sprintf(align_app, "%s -i %s --guidetree-in=%s --outfmt=fa -o %s", (P->PB)->clustalo_bin, (P->F)->full, treename2, alnname);
            ret=system(align_app);
            remove_file(treename2);
            vfree(treename2);
        }
        else {
            fprintf(stderr, "Error - ClustalO not found. Correct ClustalO path\n");
            exit(1);
        }
    }
    else if((vstrcmp((P->align_method), ("mafft")) == 0)){
        if((P->PB)->mafft_bin != ((void *)0) && (P->PB)->nwtomafft != ((void *)0)){
            char *treename2;
            treename2 = (char *) vcalloc(1000, sizeof(char));
            root_unrooted_tree(treename, ntree, (P->PB)->retree_bin);
            sprintf(treename2, "%s%s_%d.mafft", P->outdir, (P->F)->name, ntree);
            sprintf(align_app, "%s %s > %s", (P->PB)->nwtomafft, treename, treename2);
            ret=system(align_app);
            sprintf(align_app, "%s --auto --treein %s %s > %s 2> /dev/null", (P->PB)->mafft_bin, treename2, (P->F)->full, alnname);
            ret=system(align_app);
            remove_file(treename2);
            vfree(treename2);
        }
        else {
            fprintf(stderr, "Error - Mafft not found. Correct Mafft path\n");
            exit(1);
        }
    }
    else {
        fprintf(stderr, "Error - Bad MSA Method\n");
        exit(1);
    }
    vfree(align_app);
}

canonical_original_code:
void align_tree(struct Parameters *P, char *treename, char *libname, char *alnname, int ntree){
    char *align_app;
    int ret;
    align_app = (char *) vcalloc(1000, sizeof(char));
    if((vstrcmp((P->align_method), ("t_coffee")) == 0)){
        if((P->PB)->tcoffee_bin != ((void *)0)){
            if(P->mpi_mode == 0 && libname != ((void *)0)){
                if(ntree == 0){
                    sprintf(align_app, "%s %s -usetree %s -out_lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, libname,alnname);
                }
                else {
                    sprintf(align_app, "%s %s -usetree %s -lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, libname, alnname);
                }
            }
            else {
                if(P->ntree >= np){
                    sprintf(align_app, "%s %s -usetree %s -lib %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, libname, alnname);
                }
                else {
                    sprintf(align_app, "%s %s -usetree %s -output=fasta -n_core=1 -outfile=%s > /dev/null 2>&1", (P->PB)->tcoffee_bin, (P->F)->full, treename, alnname);
                }
            }
            ret=system(align_app);
        }
        else {
            fprintf(stderr, "Error - T-Coffee not found. Correct T-Coffee path\n");
            exit(1);
        }
    }
    else if((vstrcmp((P->align_method), ("clustalw")) == 0)){
        if((P->PB)->clustalw_bin != ((void *)0)){
            sprintf(align_app, "%s -infile=%s -usetree=%s -output=fasta -outfile=%s > /dev/null 2>&1", (P->PB)->clustalw_bin, (P->F)->full, treename, alnname);
            ret=system(align_app);
        }
        else {
            fprintf(stderr, "Error - ClustalW not found. Correct ClustalW path\n");
            exit(1);
        }
    }
    else if((vstrcmp((P->align_method), ("clustalo")) == 0)){
        if((P->PB)->clustalo_bin != ((void *)0)){
            char *treename2;
            treename2 = root_unrooted_tree(treename, ntree, (P->PB)->retree_bin);
            sprintf(align_app, "%s -i %s --guidetree-in=%s --outfmt=fa -o %s", (P->PB)->clustalo_bin, (P->F)->full, treename2, alnname);
            ret=system(align_app);
            remove_file(treename2);
            vfree(treename2);
        }
        else {
            fprintf(stderr, "Error - ClustalO not found. Correct ClustalO path\n");
            exit(1);
        }
    }
    else if((vstrcmp((P->align_method), ("mafft")) == 0)){
        if((P->PB)->mafft_bin != ((void *)0) && (P->PB)->nwtomafft != ((void *)0)){
            char *treename2;
            treename2 = (char *) vcalloc(1000, sizeof(char));
            root_unrooted_tree(treename, ntree, (P->PB)->retree_bin);
            sprintf(treename2, "%s%s_%d.mafft", P->outdir, (P->F)->name, ntree);
            sprintf(align_app, "%s %s > %s", (P->PB)->nwtomafft, treename, treename2);
            ret=system(align_app);
            sprintf(align_app, "%s --auto --treein %s %s > %s 2> /dev/null", (P->PB)->mafft_bin, treename2, (P->F)->full, alnname);
            ret=system(align_app);
            remove_file(treename2);
            vfree(treename2);
        }
        else {
            fprintf(stderr, "Error - Mafft not found. Correct Mafft path\n");
            exit(1);
        }
    }
    else {
        fprintf(stderr, "Error - Bad MSA Method\n");
        exit(1);
    }
    vfree(align_app);
}

variable_types:
treename
char *

variable_types:
libname
char *

variable_types:
alnname
char *

variable_types: ntree int

variable_types: ret int