mkblobpad

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

result = zalloc(56LL);
*(_DWORD *)result = 8;
*(_QWORD *)(result + 32) = a1;
return result;
}

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

result = zalloc(56LL);
*(_DWORD *)result = 8;
*(_QWORD *)(result + 32) = a1;
return result;
}

original_code:
Blob *
mkblobpad(size_t sz)
{
 Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btpad;
 b->npad = sz;
 return b;
}

canonical_original_code:
struct Blob *mkblobpad(unsigned long sz)
{
 struct Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btpad;
 b->npad = sz;
 return b;
}

variable_types:
sz
unsigned long

return_type: struct Blob { enum Blobtype { Bti8=0, Bti16=1, Bti32=2, Bti64=3, Btimin=4, Btref=5, Btbytes=6, Btseq=7, Btpad=8 } type; unsigned long align; char *lbl; char isglobl; char iscomdat; union { unsigned long long npad; unsigned long long ival; struct { char *str; char isextern; unsigned long off; } ref; struct { unsigned long len; char *buf; } bytes; struct { unsigned long nsub; struct Blob **sub; } seq; }; } *


mkblobbytes

repo: oridb/mc

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

result = zalloc(56LL);
*(_DWORD *)result = 6;
*(_QWORD *)(result + 40) = a1;
*(_QWORD *)(result + 32) = a2;
return result;
}

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

result = zalloc(56LL);
*(_DWORD *)result = 6;
*(_QWORD *)(result + 40) = a1;
*(_QWORD *)(result + 32) = a2;
return result;
}

original_code:
Blob *
mkblobbytes(char *buf, size_t len)
{
 Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btbytes;
 b->bytes.buf = buf;
 b->bytes.len = len;
 return b;
}

canonical_original_code:
struct Blob *mkblobbytes(char *buf, unsigned long len)
{
 struct Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btbytes;
 b->bytes.buf = buf;
 b->bytes.len = len;
 return b;
}

variable_types:
buf
char *

variable_types:
len
unsigned long

variable_types: struct Blob { enum Blobtype { Bti8=0, Bti16=1, Bti32=2, Bti64=3, Btimin=4, Btref=5, Btbytes=6, Btseq=7, Btpad=8 } type; unsigned long align; char *lbl; char isglobl; char iscomdat; union { unsigned long long npad; unsigned long long ival; struct { char *str; char isextern; unsigned long off; } ref; struct { unsigned long len; char *buf; } bytes; struct { unsigned long nsub; struct Blob **sub; } seq; }; } *

user_defined_types: struct Blob { enum Blobtype type; unsigned long align; char *lbl; char isglobl; char iscomdat; union { unsigned long long npad; unsigned long long ival; struct { char *str; char isextern; unsigned long off; } ref; struct { unsigned long len; char *buf; } bytes; struct { unsigned long nsub; struct Blob **sub; } seq; }; }


mkblobseq

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

result = zalloc(56LL);
*(_DWORD *)result = 7;
*(_QWORD *)(result + 40) = a1;
*(_QWORD *)(result + 32) = a2;
return result;
}

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

result = zalloc(56LL);
*(_DWORD *)result = 7;
*(_QWORD *)(result + 40) = a1;
*(_QWORD *)(result + 32) = a2;
return result;
}

original_code:
Blob *
mkblobseq(Blob **sub, size_t nsub)
{
 Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btseq;
 b->seq.sub = sub;
 b->seq.nsub = nsub;
 return b;
}

canonical_original_code:
struct Blob *mkblobseq(struct Blob **sub, unsigned long nsub)
{
 struct Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btseq;
 b->seq.sub = sub;
 b->seq.nsub = nsub;
 return b;
}

variable_types:
sub
struct Blob **

variable_types:
nsub
unsigned long

user_defined_types: enum Blobtype { Bti8=0, Bti16=1, Bti32=2, Bti64=3, Btimin=4, Btref=5, Btbytes=6, Btseq=7, Btpad=8 }


mkblobref

decompiled_code:
__int64 __fastcall mkblobref(char *s, __int64 a2, char a3)
{
_DWORD *v4; // rax
__int64 v5; // r12
char *v6; // rax
__int64 result; // rax

v4 = (_DWORD *)zalloc(56LL);
*v4 = 5;
v5 = (__int64)v4;
v6 = strdup(s);
*(_BYTE *)(v5 + 40) = a3;
*(_QWORD *)(v5 + 32) = v6;
result = v5;
*(_QWORD *)(v5 + 48) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s, __int64 a2, char a3)
{
_DWORD *v4; // rax
__int64 v5; // r12
char *v6; // rax
__int64 result; // rax

v4 = (_DWORD *)zalloc(56LL);
*v4 = 5;
v5 = (__int64)v4;
v6 = strdup(s);
*(_BYTE *)(v5 + 40) = a3;
*(_QWORD *)(v5 + 32) = v6;
result = v5;
*(_QWORD *)(v5 + 48) = a2;
return result;
}

original_code:
Blob *
mkblobref(char *lbl, size_t off, int isextern)
{
 Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btref;
 b->ref.str = strdup(lbl);
 b->ref.isextern = isextern;
 b->ref.off = off;
 return b;
}

canonical_original_code:
struct Blob *mkblobref(char *lbl, unsigned long off, int isextern)
{
 struct Blob *b;
 b = zalloc(sizeof(Blob));
 b->type = Btref;
 b->ref.str = strdup(lbl);
 b->ref.isextern = isextern;
 b->ref.off = off;
 return b;
}

variable_types:
lbl
char *

variable_types:
off
unsigned long

variable_types: isextern int


blobfree

decompiled_code:
void __fastcall blobfree(void **a1)
{
unsigned __int64 v2; // rbx
__int64 v3; // rdi

if ( a1 )
{
if ( *(_DWORD *)a1 == 5 )
{
free(a1[2]);
free(a1);
}
else
{
if ( *(_DWORD *)a1 == 7 )
{
v2 = 0LL;
if ( a1[4] )
{
do
{
v3 = *((_QWORD *)a1[5] + v2++);
blobfree(v3);
}
while ( (unsigned __int64)a1[4] > v2 );
}
}
free(a1);
}
}
}

original_code:
void
blobfree(Blob *b)
{
 size_t i;
 if (!b)
  return;
 switch (b->type) {
 case Btref:
  free(b->lbl);
  break;
 case Btseq:
  for (i = 0; i < b->seq.nsub; i++)
   blobfree(b->seq.sub[i]);
  break;
 default:
  break;
 }
 free(b);
}

canonical_original_code:
void blobfree(struct Blob *b)
{
 unsigned long i;
 if (!b)
  return;
 switch (b->type) {
 case Btref:
  free(b->lbl);
  break;
 case Btseq:
  for (i = 0; i < b->seq.nsub; i++)
   blobfree(b->seq.sub[i]);
  break;
 default:
  break;
 }
 free(b);
}

variable_types:
i
unsigned long

return_type: void


b

decompiled_code:
__int64 __fastcall b(__int64 a1, __int64 a2)
{
return lappend(a1 + 40, a1 + 32, a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return lappend(a1 + 40, a1 + 32, a2);
}

original_code:
void
b(Blob *b, Blob *n)
{
 lappend(&b->seq.sub, &b->seq.nsub, n);
}

canonical_original_code:
void b(struct Blob *b, struct Blob *n)
{
 lappend(&b->seq.sub, &b->seq.nsub, n);
}

variable_types:
n
struct Blob *


blobpad

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

if ( !a2 )
return 0LL;
v3 = mkblobpad(a2);
b(a1, v3);
return a2;
}

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

if ( !a2 )
return 0LL;
v3 = func2(a2);
func7(a1, v3);
return a2;
}

original_code:
static size_t
blobpad(Blob *seq, size_t sz)
{
 if (sz)
  b(seq, mkblobpad(sz));
 return sz;
}

canonical_original_code:
static unsigned long blobpad(struct Blob *seq, unsigned long sz)
{
 if (sz)
  b(seq, mkblobpad(sz));
 return sz;
}

return_type: unsigned long


blobrec

original_code:
static size_t
blobrec(Blob *b, Htab *globls, Htab *strtab, Node *n)
{
 size_t i, sz, end;
 vlong nelt, idx, last;
 Type *ty;
 switch(exprop(n)) {
 case Oucon: sz = blobucon(b, globls, strtab, n); break;
 case Oslice: sz = blobslice(b, globls, strtab, n); break;
 case Ostruct: sz = blobstruct(b, globls, strtab, n); break;
 case Ovar: sz = blobvar(b, strtab, n, exprtype(n)); break;
 case Olit: sz = bloblit(b, strtab, n->expr.args[0], exprtype(n)); break;
 case Otup:
  sz = 0;
  if (!n->expr.args)
   break;
  for (i = 0; i < n->expr.nargs; i++) {
   end = alignto(sz, exprtype(n->expr.args[i]));
   sz += blobpad(b, end - sz);
   sz += blobrec(b, globls, strtab, n->expr.args[i]);
  }
  end = alignto(sz, exprtype(n));
  sz += blobpad(b, end - sz);
  break;
 case Oarr:
  sz = 0;
  idx = 0;
  last = 0;
  ty = exprtype(n);
  if (!n->expr.args)
   break;
  if (!getintlit(ty->asize, &nelt))
   die("array missing size");
  for (i = 0; i < n->expr.nargs; i++) {
   if (!getintlit(n->expr.args[i]->expr.idx, &idx))
    die("non-numeric array size");
   if (idx != last + 1)
    sz += blobpad(b, (idx - last)*size(n->expr.args[i]));
   sz += blobrec(b, globls, strtab, n->expr.args[i]);
   last = idx + 1;
  }
  end = alignto(sz, exprtype(n));
  sz += blobpad(b, end - sz);
  break;
 default:
  dumpn(n, stdout);
  die("Nonliteral initializer for global");
  break;
 }
 return sz;
}

canonical_original_code:
static unsigned long blobrec(struct Blob *b, struct Htab *globls, struct Htab *strtab, struct Node *n)
{
 unsigned long i; unsigned long sz; unsigned long end;
 long long nelt; long long idx; long long last;
 struct Type *ty;
 switch(exprop(n)) {
 case Oucon: sz = blobucon(b, globls, strtab, n); break;
 case Oslice: sz = blobslice(b, globls, strtab, n); break;
 case Ostruct: sz = blobstruct(b, globls, strtab, n); break;
 case Ovar: sz = blobvar(b, strtab, n, exprtype(n)); break;
 case Olit: sz = bloblit(b, strtab, n->expr.args[0], exprtype(n)); break;
 case Otup:
  sz = 0;
  if (!n->expr.args)
   break;
  for (i = 0; i < n->expr.nargs; i++) {
   end = alignto(sz, exprtype(n->expr.args[i]));
   sz += blobpad(b, end - sz);
   sz += blobrec(b, globls, strtab, n->expr.args[i]);
  }
  end = alignto(sz, exprtype(n));
  sz += blobpad(b, end - sz);
  break;
 case Oarr:
  sz = 0;
  idx = 0;
  last = 0;
  ty = exprtype(n);
  if (!n->expr.args)
   break;
  if (!getintlit(ty->asize, &nelt))
   die("array missing size");
  for (i = 0; i < n->expr.nargs; i++) {
   if (!getintlit(n->expr.args[i]->expr.idx, &idx))
    die("non-numeric array size");
   if (idx != last + 1)
    sz += blobpad(b, (idx - last)*size(n->expr.args[i]));
   sz += blobrec(b, globls, strtab, n->expr.args[i]);
   last = idx + 1;
  }
  end = alignto(sz, exprtype(n));
  sz += blobpad(b, end - sz);
  break;
 default:
  dumpn(n, stdout);
  die("Nonliteral initializer for global");
  break;
 }
 return sz;
}

variable_types:
strtab
struct Htab *

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 *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:
end
unsigned long

variable_types:
nelt
long long

variable_types:
idx
long long

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


blobucon

original_code:
static size_t
blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
{
 size_t sz, align;
 Ucon *uc;
 sz = 4;
 uc = finducon(exprtype(n), n->expr.args[0]);
 b(seq, mkblobi(Bti32, uc->id));
 align = 1;
 if (n->expr.nargs > 1) {
  align = tyalign(exprtype(n->expr.args[1]));
  if (align > sz)
   sz += blobpad(seq, align - sz);
  sz += blobrec(seq, globls, strtab, n->expr.args[1]);
 }
 sz += blobpad(seq, size(n) - sz);
 return sz;
}

canonical_original_code:
static unsigned long blobucon(struct Blob *seq, struct Htab *globls, struct Htab *strtab, struct Node *n)
{
 unsigned long sz; unsigned long align;
 struct Ucon *uc;
 sz = 4;
 uc = finducon(exprtype(n), n->expr.args[0]);
 b(seq, mkblobi(Bti32, uc->id));
 align = 1;
 if (n->expr.nargs > 1) {
  align = tyalign(exprtype(n->expr.args[1]));
  if (align > sz)
   sz += blobpad(seq, align - sz);
  sz += blobrec(seq, globls, strtab, n->expr.args[1]);
 }
 sz += blobpad(seq, size(n) - sz);
 return sz;
}

variable_types:
sz
unsigned long

variable_types:
align
unsigned long

variable_types: struct Ucon { struct Srcloc { int line; int file; } loc; unsigned long id; int synth; 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 **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; }; } *name; struct Type *utype; struct Type *etype; } *

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

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


blobstruct

original_code:
static size_t
blobstruct(Blob *seq, Htab *globls, Htab *strtab, Node *n)
{
 size_t i, sz, pad, end, ndcl;
 Node **dcl, *m;
 Type *t;
 sz = 0;
 t = tybase(exprtype(n));
 ((void) sizeof ((t->type == Tystruct) ? 1 : 0), __extension__ ({ if (t->type == Tystruct) ; else __assert_fail ("t->type == Tystruct", "blob.c", 232, __extension__ __PRETTY_FUNCTION__); }));
 dcl = t->sdecls;
 ndcl = t->nmemb;
 for (i = 0; i < ndcl; i++) {
  pad = alignto(sz, decltype(dcl[i]));
  m = structmemb(n, declname(dcl[i]));
  sz += blobpad(seq, pad - sz);
  if (m)
   sz += blobrec(seq, globls, strtab, m);
  else
   sz += blobpad(seq, size(dcl[i]));
 }
 end = alignto(sz, t);
 sz += blobpad(seq, end - sz);
 return sz;
}

canonical_original_code:
static unsigned long blobstruct(struct Blob *seq, struct Htab *globls, struct Htab *strtab, struct Node *n)
{
 unsigned long i; unsigned long sz; unsigned long pad; unsigned long end; unsigned long ndcl;
 struct Node **dcl; struct Node *m;
 struct Type *t;
 sz = 0;
 t = tybase(exprtype(n));
 ((void) sizeof ((t->type == Tystruct) ? 1 : 0), __extension__ ({ if (t->type == Tystruct) ; else __assert_fail ("t->type == Tystruct", "blob.c", 232, __extension__ __PRETTY_FUNCTION__); }));
 dcl = t->sdecls;
 ndcl = t->nmemb;
 for (i = 0; i < ndcl; i++) {
  pad = alignto(sz, decltype(dcl[i]));
  m = structmemb(n, declname(dcl[i]));
  sz += blobpad(seq, pad - sz);
  if (m)
   sz += blobrec(seq, globls, strtab, m);
  else
   sz += blobpad(seq, size(dcl[i]));
 }
 end = alignto(sz, t);
 sz += blobpad(seq, end - sz);
 return sz;
}

variable_types: struct Blob { enum Blobtype { Bti8=0, Bti16=1, Bti32=2, Bti64=3, Btimin=4, Btref=5, Btbytes=6, Btseq=7, Btpad=8 } type; unsigned long align; char *lbl; char isglobl; char iscomdat; union { unsigned long long npad; unsigned long long ival; struct { char *str; char isextern; unsigned long off; } ref; struct { unsigned long len; char *buf; } bytes; struct { unsigned long nsub; struct Blob **sub; } seq; }; } *

variable_types:
pad
unsigned long

variable_types:
ndcl
unsigned long

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


litblob

decompiled_code:
__int64 __fastcall litblob(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r12

v4 = mkblobseq(0LL, 0LL);
blobrec(v4, a1, a2, a3);
return v4;
}

original_code:
Blob *
litblob(Htab *globls, Htab *strtab, Node *n)
{
 Blob *b;
 b = mkblobseq(((void *)0), 0);
 blobrec(b, globls, strtab, n);
 return b;
}

canonical_original_code:
struct Blob *litblob(struct Htab *globls, struct Htab *strtab, struct Node *n)
{
 struct Blob *b;
 b = mkblobseq(((void *)0), 0);
 blobrec(b, globls, strtab, n);
 return b;
}

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


structmemb

decompiled_code:
__int64 __fastcall structmemb(__int64 a1, const char *a2)
{
unsigned __int64 v2; // rbx
const char *v3; // rax

if ( !*(_QWORD *)(a1 + 64) )
return 0LL;
v2 = 0LL;
do
{
v3 = (const char *)namestr(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 80) + 8 * v2) + 72LL));
if ( !strcmp(v3, a2) )
return *(_QWORD *)(*(_QWORD *)(a1 + 80) + 8 * v2);
++v2;
}
while ( *(_QWORD *)(a1 + 64) > v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2)
{
unsigned __int64 v2; // rbx
const char *v3; // rax

if ( !*(_QWORD *)(a1 + 64) )
return 0LL;
v2 = 0LL;
do
{
v3 = (const char *)namestr(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 80) + 8 * v2) + 72LL));
if ( !strcmp(v3, a2) )
return *(_QWORD *)(*(_QWORD *)(a1 + 80) + 8 * v2);
++v2;
}
while ( *(_QWORD *)(a1 + 64) > v2 );
return 0LL;
}

original_code:
static Node *
structmemb(Node *n, char *dcl)
{
 size_t i;
 for (i = 0; i < n->expr.nargs; i++)
  if (!strcmp(namestr(n->expr.args[i]->expr.idx), dcl))
   return n->expr.args[i];
 return ((void *)0);
}

canonical_original_code:
static struct Node *structmemb(struct Node *n, char *dcl)
{
 unsigned long i;
 for (i = 0; i < n->expr.nargs; i++)
  if (!strcmp(namestr(n->expr.args[i]->expr.idx), dcl))
   return n->expr.args[i];
 return ((void *)0);
}

variable_types:
n
struct Node *

variable_types:
dcl
char *

variable_types:
i
unsigned long

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


xstrdup

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

result = strdup(a1);
if ( !result )
{
die("Out of memory");
result = (char *)strjoin();
}
return result;
}

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

result = strdup(a1);
if ( !result )
{
die("Out of memory");
result = (char *)func3();
}
return result;
}

original_code:
char *
xstrdup(char *s)
{
 char *p;
 p = strdup(s);
 if (!p && s)
  die("Out of memory");
 return p;
}

canonical_original_code:
char *xstrdup(char *s)
{
 char *p;
 p = strdup(s);
 if (!p && s)
  die("Out of memory");
 return p;
}

variable_types:
s
char *

variable_types:
p
char *

return_type: char *


strjoin

decompiled_code:
__int64 __fastcall strjoin(const char *a1, const char *a2)
{
size_t v2; // rbx
size_t v3; // rbx
__int64 v4; // r12

v2 = strlen(a1);
v3 = strlen(a2) + v2;
v4 = xalloc(v3 + 1);
bprintf(v4, v3 + 2, "%s%s", a1, a2);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, const char *a2)
{
size_t v2; // rbx
size_t v3; // rbx
__int64 v4; // r12

v2 = strlen(a1);
v3 = strlen(a2) + v2;
v4 = xalloc(v3 + 1);
bprintf(v4, v3 + 2, "%s%s", a1, a2);
return v4;
}

original_code:
char *
strjoin(char *u, char *v)
{
 size_t n;
 char *s;
 n = strlen(u) + strlen(v) + 1;
 s = xalloc(n);
 bprintf(s, n + 1, "%s%s", u, v);
 return s;
}

canonical_original_code:
char *strjoin(char *u, char *v)
{
 unsigned long n;
 char *s;
 n = strlen(u) + strlen(v) + 1;
 s = xalloc(n);
 bprintf(s, n + 1, "%s%s", u, v);
 return s;
}

variable_types:
u
char *

variable_types:
v
char *

variable_types:
n
unsigned long


swapsuffix

decompiled_code:
char *__fastcall swapsuffix(char *dest, size_t a2, const char *a3, const char *a4, const char *a5)
{
size_t v8; // rbp
size_t v9; // rax
size_t v10; // rdx
size_t v11; // rbp
char *result; // rax
size_t na; // [rsp+8h] [rbp-40h]
size_t n; // [rsp+8h] [rbp-40h]

v8 = strlen(a3);
na = strlen(a4);
v9 = strlen(a5);
v10 = na;
if ( v8 < na )
return 0LL;
if ( v8 + v9 >= a2 )
{
die("swapsuffix: buf too small");
result = (char *)max();
}
else
{
n = v9;
*dest = 0;
if ( v8 > v10 && (v11 = v8 - v10, !strcmp(a4, &a3[v11])) )
{
strncat(dest, a3, v11);
result = strncat(dest, a5, n);
}
else
{
bprintf(dest, a2, "%s%s", a3, a5);
result = dest;
}
}
return result;
}

canonical_decompiled_code:
char *__fastcall func4(char *dest, size_t a2, const char *a3, const char *a4, const char *a5)
{
size_t v8; // rbp
size_t v9; // rax
size_t v10; // rdx
size_t v11; // rbp
char *result; // rax
size_t na; // [rsp+8h] [rbp-40h]
size_t n; // [rsp+8h] [rbp-40h]

v8 = strlen(a3);
na = strlen(a4);
v9 = strlen(a5);
v10 = na;
if ( v8 < na )
return 0LL;
if ( v8 + v9 >= a2 )
{
die("swapsuffix: buf too small");
result = (char *)func5();
}
else
{
n = v9;
*dest = 0;
if ( v8 > v10 && (v11 = v8 - v10, !strcmp(a4, &a3[v11])) )
{
strncat(dest, a3, v11);
result = strncat(dest, a5, n);
}
else
{
bprintf(dest, a2, "%s%s", a3, a5);
result = dest;
}
}
return result;
}

original_code:
char *
swapsuffix(char *buf, size_t sz, char *s, char *suf, char *swap)
{
 size_t slen, suflen, swaplen;
 slen = strlen(s);
 suflen = strlen(suf);
 swaplen = strlen(swap);
 if (slen < suflen)
  return ((void *)0);
 if (slen + swaplen >= sz)
  die("swapsuffix: buf too small");
 buf[0] = '\0';
 if (suflen < slen && !strcmp(suf, &s[slen - suflen])) {
  strncat(buf, s, slen - suflen);
  strncat(buf, swap, swaplen);
 } else {
  bprintf(buf, sz, "%s%s", s, swap);
 }
 return buf;
}

canonical_original_code:
char *swapsuffix(char *buf, unsigned long sz, char *s, char *suf, char *swap)
{
 unsigned long slen; unsigned long suflen; unsigned long swaplen;
 slen = strlen(s);
 suflen = strlen(suf);
 swaplen = strlen(swap);
 if (slen < suflen)
  return ((void *)0);
 if (slen + swaplen >= sz)
  die("swapsuffix: buf too small");
 buf[0] = '\0';
 if (suflen < slen && !strcmp(suf, &s[slen - suflen])) {
  strncat(buf, s, slen - suflen);
  strncat(buf, swap, swaplen);
 } else {
  bprintf(buf, sz, "%s%s", s, swap);
 }
 return buf;
}

variable_types:
buf
char *

variable_types:
suf
char *

variable_types:
swap
char *

variable_types:
slen
unsigned long

variable_types:
suflen
unsigned long

variable_types:
swaplen
unsigned long


max

decompiled_code:
unsigned __int64 __fastcall max(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

result = a2;
if ( a1 >= a2 )
result = a1;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

result = a2;
if ( a1 >= a2 )
result = a1;
return result;
}

original_code:
size_t
max(size_t a, size_t b)
{
 if (a > b)
  return a;
 else
  return b;
}

canonical_original_code:
unsigned long max(unsigned long a, unsigned long b)
{
 if (a > b)
  return a;
 else
  return b;
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long


min

decompiled_code:
unsigned __int64 __fastcall min(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

result = a2;
if ( a1 <= a2 )
result = a1;
return result;
}

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

result = a2;
if ( a1 <= a2 )
result = a1;
return result;
}

original_code:
size_t
min(size_t a, size_t b)
{
 if (a < b)
  return a;
 else
  return b;
}

canonical_original_code:
unsigned long min(unsigned long a, unsigned long b)
{
 if (a < b)
  return a;
 else
  return b;
}


align

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

result = a1;
if ( a2 )
result = -a2 & (a1 + a2 - 1);
return result;
}

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

result = a1;
if ( a2 )
result = -a2 & (a1 + a2 - 1);
return result;
}

original_code:
size_t
align(size_t sz, size_t a)
{
 if (a == 0)
  return sz;
 return (sz + a - 1) & ~(a - 1);
}

canonical_original_code:
unsigned long align(unsigned long sz, unsigned long a)
{
 if (a == 0)
  return sz;
 return (sz + a - 1) & ~(a - 1);
}

variable_types:
sz
unsigned long


indentf

decompiled_code:
int indentf(int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return vfindentf(stdout, a1, a2, va);
}

canonical_decompiled_code:
int func9(int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return func8(stdout, a1, a2, va);
}

original_code:
void
indentf(int depth, char *fmt, ...)
{
 va_list ap;
 __builtin_va_start(ap,fmt);
 vfindentf(stdout, depth, fmt, ap);
 __builtin_va_end(ap);
}

canonical_original_code:
void indentf(int depth, char *fmt, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 vfindentf(stdout, depth, fmt, ap);
 __builtin_va_end(ap);
}

variable_types: depth int

variable_types:
fmt
char *


optinit

original_code:
void
optinit(Optctx *ctx, char *optstr, char **optargs, size_t noptargs)
{
 ctx->args = ((void *)0);
 ctx->nargs = 0;
 ctx->optstr = optstr;
 ctx->optargs = optargs;
 ctx->noptargs = noptargs;
 ctx->optdone = 0;
 ctx->finished = 0;
 ctx->argidx = 0;
 ctx->curarg = "";
 findnextopt(ctx);
}

canonical_original_code:
void optinit(struct Optctx *ctx, char *optstr, char **optargs, unsigned long noptargs)
{
 ctx->args = ((void *)0);
 ctx->nargs = 0;
 ctx->optstr = optstr;
 ctx->optargs = optargs;
 ctx->noptargs = noptargs;
 ctx->optdone = 0;
 ctx->finished = 0;
 ctx->argidx = 0;
 ctx->curarg = "";
 findnextopt(ctx);
}

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

variable_types:
optstr
char *

variable_types:
optargs
char **

variable_types:
noptargs
unsigned long


optnext

decompiled_code:
__int64 __fastcall optnext(__int64 a1)
{
char *v1; // rax
unsigned int v2; // er12
int v3; // edx
const char *v4; // rbx
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rdx
__int64 v8; // rax
int v9; // [rsp+8h] [rbp-20h] BYREF
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = *(char **)(a1 + 64);
v2 = *v1;
*(_QWORD *)(a1 + 64) = v1 + 1;
if ( !(unsigned int)optinfo_isra_0(*(char **)(a1 + 24), v2, &v9, v10) )
{
printf("Unexpected argument %c\n", v2);
exit(1);
}
v3 = v9;
v4 = *(const char **)(a1 + 64);
*(_QWORD *)a1 = 0LL;
if ( v3 )
{
if ( *v4 )
{
*(_QWORD *)a1 = v4;
*(_QWORD *)(a1 + 64) = &v4[strlen(v4)];
}
else
{
v6 = *(_QWORD *)(a1 + 48);
if ( v6 >= *(_QWORD *)(a1 + 40) - 1LL )
{
if ( v10[0] )
fprintf(stderr, "expected argument for %c\n", 0LL);
}
else
{
v7 = v6 + 1;
v8 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * v7);
*(_QWORD *)(a1 + 48) = v7;
*(_QWORD *)a1 = v8;
}
}
goto LABEL_5;
}
if ( !*v4 )
{
LABEL_5:
findnextopt_isra_0(a1);
return v2;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
char *v1; // rax
unsigned int v2; // er12
int v3; // edx
const char *v4; // rbx
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rdx
__int64 v8; // rax
int v9; // [rsp+8h] [rbp-20h] BYREF
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = *(char **)(a1 + 64);
v2 = *v1;
*(_QWORD *)(a1 + 64) = v1 + 1;
if ( !(unsigned int)func1(*(char **)(a1 + 24), v2, &v9, v10) )
{
printf("Unexpected argument %c\n", v2);
exit(1);
}
v3 = v9;
v4 = *(const char **)(a1 + 64);
*(_QWORD *)a1 = 0LL;
if ( v3 )
{
if ( *v4 )
{
*(_QWORD *)a1 = v4;
*(_QWORD *)(a1 + 64) = &v4[strlen(v4)];
}
else
{
v6 = *(_QWORD *)(a1 + 48);
if ( v6 >= *(_QWORD *)(a1 + 40) - 1LL )
{
if ( v10[0] )
fprintf(stderr, "expected argument for %c\n", 0LL);
}
else
{
v7 = v6 + 1;
v8 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * v7);
*(_QWORD *)(a1 + 48) = v7;
*(_QWORD *)a1 = v8;
}
}
goto LABEL_5;
}
if ( !*v4 )
{
LABEL_5:
func0(a1);
return v2;
}
return v2;
}

original_code:
int
optnext(Optctx *ctx)
{
 int take, mand;
 int c;
 c = *ctx->curarg;
 ctx->curarg++;
 if (!optinfo(ctx, c, &take, &mand)) {
  printf("Unexpected argument %c\n", c);
  exit(1);
 }
 ctx->optarg = ((void *)0);
 if (take) {
  if (*ctx->curarg) {
   ctx->optarg = ctx->curarg;
   ctx->curarg += strlen(ctx->optarg);
  } else if (ctx->argidx < ctx->noptargs - 1) {
   ctx->optarg = ctx->optargs[ctx->argidx + 1];
   ctx->argidx++;
  } else if (mand) {
   fprintf(stderr, "expected argument for %c\n", *ctx->curarg);
  }
  findnextopt(ctx);
 } else {
  if (*ctx->curarg == '\0')
   findnextopt(ctx);
 }
 return c;
}

canonical_original_code:
int optnext(struct Optctx *ctx)
{
 int take; int mand;
 int c;
 c = *ctx->curarg;
 ctx->curarg++;
 if (!optinfo(ctx, c, &take, &mand)) {
  printf("Unexpected argument %c\n", c);
  exit(1);
 }
 ctx->optarg = ((void *)0);
 if (take) {
  if (*ctx->curarg) {
   ctx->optarg = ctx->curarg;
   ctx->curarg += strlen(ctx->optarg);
  } else if (ctx->argidx < ctx->noptargs - 1) {
   ctx->optarg = ctx->optargs[ctx->argidx + 1];
   ctx->argidx++;
  } else if (mand) {
   fprintf(stderr, "expected argument for %c\n", *ctx->curarg);
  }
  findnextopt(ctx);
 } else {
  if (*ctx->curarg == '\0')
   findnextopt(ctx);
 }
 return c;
}

variable_types: take int

variable_types: mand int

variable_types: c int

return_type: int

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


optdone

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

result = 0LL;
if ( !**(_BYTE **)(a1 + 64) )
result = *(_DWORD *)(a1 + 60) != 0;
return result;
}

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

result = 0LL;
if ( !**(_BYTE **)(a1 + 64) )
result = *(_DWORD *)(a1 + 60) != 0;
return result;
}

original_code:
int
optdone(Optctx *ctx) { return *ctx->curarg == '\0' && ctx->finished; }

canonical_original_code: int optdone(struct Optctx *ctx) { return *ctx->curarg == '\0' && ctx->finished; }


dirname

decompiled_code:
__int64 __fastcall dirname(const char *a1)
{
char *v1; // rax
__int64 result; // rax

v1 = strrchr(a1, 47);
if ( v1 )
result = strdupn(a1, v1 - a1);
else
result = xstrdup(".");
return result;
}

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

v1 = strrchr(a1, 47);
if ( v1 )
result = strdupn(a1, v1 - a1);
else
result = xstrdup(".");
return result;
}

original_code:
static char *
dirname(char *path)
{
 char *p;
 p = strrchr(path, '/');
 if (p)
  return strdupn(path, p - path);
 else
  return xstrdup(".");
}

canonical_original_code:
static char *dirname(char *path)
{
 char *p;
 p = strrchr(path, '/');
 if (p)
  return strdupn(path, p - path);
 else
  return xstrdup(".");
}

variable_types:
path
char *

variable_types:
p
char *


hasmain

decompiled_code:
_BOOL8 hasmain()
{
__int64 v0; // rax
__int64 v1; // rax
_BOOL8 result; // rax

v0 = mknsname(0xFFFFFFFFLL, 0LL, "main");
v1 = getdcl(file[18], v0);
if ( v1 )
result = *(_QWORD *)(*(_QWORD *)(v1 + 32) + 24LL) == 0LL;
else
result = 0LL;
return result;
}

canonical_decompiled_code:
_BOOL8 func2()
{
__int64 v0; // rax
__int64 v1; // rax
_BOOL8 result; // rax

v0 = mknsname(0xFFFFFFFFLL, 0LL, "main");
v1 = getdcl(file[18], v0);
if ( v1 )
result = *(_QWORD *)(*(_QWORD *)(v1 + 32) + 24LL) == 0LL;
else
result = 0LL;
return result;
}

original_code:
static int
hasmain(void)
{
 Node *n, *name;
 name = mknsname(((Srcloc){-1, 0}), ((void *)0), "main");
 n = getdcl(file.globls, name);
 if (!n)
  return 0;
 n = n->decl.name;
 if (n->name.ns)
  return 0;
 return 1;
}

canonical_original_code:
static int hasmain()
{
 struct Node *n; struct Node *name;
 name = mknsname(((struct Srcloc){-1, 0}), ((void *)0), "main");
 n = getdcl(file.globls, name);
 if (!n)
  return 0;
 n = n->decl.name;
 if (n->name.ns)
  return 0;
 return 1;
}

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


assemble

decompiled_code:
int __fastcall assemble(char *name, char *s)
{
const char **v4; // rbx
const char *v5; // rdx
__pid_t v6; // eax
int result; // eax
char *v8; // rax
char *v9; // r13
__int64 v10; // rax
__int64 v11; // rsi
char *v12; // rdi
int stat_loc; // [rsp+Ch] [rbp-15Ch] BYREF
char **argv; // [rsp+10h] [rbp-158h] BYREF
__int64 v15; // [rsp+18h] [rbp-150h] BYREF
__int64 v16[4]; // [rsp+20h] [rbp-148h] BYREF
char dest[296]; // [rsp+40h] [rbp-128h] BYREF

v16[0] = (__int64)"as";
v16[1] = (__int64)"-o";
v16[2] = 0LL;
if ( !outfile )
goto LABEL_12;
strncpy(dest, outfile, 0x100uLL);
while ( 1 )
{
v4 = (const char **)v16;
mkpath(dest);
v5 = "as";
argv = 0LL;
v15 = 0LL;
do
{
++v4;
lappend(&argv, &v15, v5);
v5 = *v4;
}
while ( *v4 );
lappend(&argv, &v15, dest);
lappend(&argv, &v15, name);
lappend(&argv, &v15, 0LL);
v6 = fork();
if ( v6 == -1 )
{
die("couldn't fork");
goto LABEL_19;
}
if ( v6 )
break;
if ( execvp(*argv, argv) != -1 )
goto LABEL_8;
die("Couldn't exec assembler\n");
LABEL_12:
v8 = strrchr(s, 43);
v9 = v8;
if ( objdir )
{
v10 = bprintf(dest, 256LL, "%s/", (const char *)objdir);
v11 = 256 - v10;
v12 = &dest[v10];
if ( v9 )
goto LABEL_14;
LABEL_17:
swapsuffix(v12, v11, s, ".myr", ".o");
}
else
{
v12 = dest;
v11 = 256LL;
if ( !v8 )
goto LABEL_17;
LABEL_14:
swapsuffix(v12, v11, s, v9, ".o");
}
}
waitpid(v6, &stat_loc, 0);
if ( stat_loc & 0x7F | BYTE1(stat_loc) )
{
LABEL_19:
die("Couldn't run assembler");
return swapout_constprop_0();
}
LABEL_8:
result = writeasm;
if ( !writeasm )
result = unlink(name);
return result;
}

canonical_decompiled_code:
int __fastcall func4(char *name, char *s)
{
const char **v4; // rbx
const char *v5; // rdx
__pid_t v6; // eax
int result; // eax
char *v8; // rax
char *v9; // r13
__int64 v10; // rax
__int64 v11; // rsi
char *v12; // rdi
int stat_loc; // [rsp+Ch] [rbp-15Ch] BYREF
char **argv; // [rsp+10h] [rbp-158h] BYREF
__int64 v15; // [rsp+18h] [rbp-150h] BYREF
__int64 v16[4]; // [rsp+20h] [rbp-148h] BYREF
char dest[296]; // [rsp+40h] [rbp-128h] BYREF

v16[0] = (__int64)"as";
v16[1] = (__int64)"-o";
v16[2] = 0LL;
if ( !outfile )
goto LABEL_12;
strncpy(dest, outfile, 0x100uLL);
while ( 1 )
{
v4 = (const char **)v16;
func3(dest);
v5 = "as";
argv = 0LL;
v15 = 0LL;
do
{
++v4;
lappend(&argv, &v15, v5);
v5 = *v4;
}
while ( *v4 );
lappend(&argv, &v15, dest);
lappend(&argv, &v15, name);
lappend(&argv, &v15, 0LL);
v6 = fork();
if ( v6 == -1 )
{
die("couldn't fork");
goto LABEL_19;
}
if ( v6 )
break;
if ( execvp(*argv, argv) != -1 )
goto LABEL_8;
die("Couldn't exec assembler\n");
LABEL_12:
v8 = strrchr(s, 43);
v9 = v8;
if ( objdir )
{
v10 = bprintf(dest, 256LL, "%s/", (const char *)objdir);
v11 = 256 - v10;
v12 = &dest[v10];
if ( v9 )
goto LABEL_14;
LABEL_17:
swapsuffix(v12, v11, s, ".myr", ".o");
}
else
{
v12 = dest;
v11 = 256LL;
if ( !v8 )
goto LABEL_17;
LABEL_14:
swapsuffix(v12, v11, s, v9, ".o");
}
}
waitpid(v6, &stat_loc, 0);
if ( stat_loc & 0x7F | BYTE1(stat_loc) )
{
LABEL_19:
die("Couldn't run assembler");
return func5();
}
LABEL_8:
result = writeasm;
if ( !writeasm )
result = unlink(name);
return result;
}

original_code:
static void
assemble(char *asmsrc, char *path)
{
 char *asmcmd[] = {"as", "-o", ((void *)0)};
 char objfile[256];
 char *psuffix;
 char **p, **cmd;
 size_t ncmd, i;
 int pid, status;
 if (outfile != ((void *)0))
  strncpy(objfile, outfile, sizeof(objfile));
 else {
  psuffix = strrchr(path, '+');
  i = 0;
  if (objdir)
   i = bprintf(objfile, sizeof objfile, "%s/", objdir);
  if (psuffix != ((void *)0))
   swapsuffix(objfile + i, sizeof objfile - i, path, psuffix, ".o");
  else
   swapsuffix(objfile + i, sizeof objfile - i, path, ".myr", ".o");
 }
 mkpath(objfile);
 cmd = ((void *)0);
 ncmd = 0;
 for (p = asmcmd; *p != ((void *)0); p++)
  lappend(&cmd, &ncmd, *p);
 lappend(&cmd, &ncmd, objfile);
 lappend(&cmd, &ncmd, asmsrc);
 lappend(&cmd, &ncmd, ((void *)0));
 pid = fork();
 if (pid == -1) {
  die("couldn't fork");
 } else if (pid == 0) {
  if (execvp(cmd[0], cmd) == -1)
   die("Couldn't exec assembler\n");
 } else {
  waitpid(pid, &status, 0);
  if (!(((status) & 0x7f) == 0) || (((status) & 0xff00) >> 8) != 0)
   die("Couldn't run assembler");
 }
 if (!writeasm)
  unlink(asmsrc);
}

canonical_original_code:
static void assemble(char *asmsrc, char *path)
{
 char *asmcmd[] = {"as", "-o", ((void *)0)};
 char objfile[256];
 char *psuffix;
 char **p; char **cmd;
 unsigned long ncmd; unsigned long i;
 int pid; int status;
 if (outfile != ((void *)0))
  strncpy(objfile, outfile, sizeof(objfile));
 else {
  psuffix = strrchr(path, '+');
  i = 0;
  if (objdir)
   i = bprintf(objfile, sizeof objfile, "%s/", objdir);
  if (psuffix != ((void *)0))
   swapsuffix(objfile + i, sizeof objfile - i, path, psuffix, ".o");
  else
   swapsuffix(objfile + i, sizeof objfile - i, path, ".myr", ".o");
 }
 mkpath(objfile);
 cmd = ((void *)0);
 ncmd = 0;
 for (p = asmcmd; *p != ((void *)0); p++)
  lappend(&cmd, &ncmd, *p);
 lappend(&cmd, &ncmd, objfile);
 lappend(&cmd, &ncmd, asmsrc);
 lappend(&cmd, &ncmd, ((void *)0));
 pid = fork();
 if (pid == -1) {
  die("couldn't fork");
 } else if (pid == 0) {
  if (execvp(cmd[0], cmd) == -1)
   die("Couldn't exec assembler\n");
 } else {
  waitpid(pid, &status, 0);
  if (!(((status) & 0x7f) == 0) || (((status) & 0xff00) >> 8) != 0)
   die("Couldn't run assembler");
 }
 if (!writeasm)
  unlink(asmsrc);
}

variable_types:
asmsrc
char *

variable_types:
asmcmd
char *[]

variable_types:
objfile
char [256]

variable_types:
psuffix
char *

variable_types:
p
char **

variable_types:
cmd
char **

variable_types:
ncmd
unsigned long

variable_types:
i
unsigned long

variable_types: pid int

variable_types: status int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // rbp
unsigned __int64 v5; // rbp
const char *v6; // rdi
__int64 v7; // rbx
char *s1; // [rsp+0h] [rbp-468h] BYREF
_QWORD *v10; // [rsp+8h] [rbp-460h]
unsigned __int64 v11; // [rsp+10h] [rbp-458h]
char name[1048]; // [rsp+50h] [rbp-418h] BYREF

outfile = 0LL;
optinit(&s1, "cd:?hSo:I:9G:O:T", argv, argc);
asmsyntax = 0;
sizefn = &size;
while ( !(unsigned int)optdone(&s1) )
{
switch ( (unsigned int)optnext(&s1) )
{
case '9':
asmsyntax = 2;
break;
case 'G':
v4 = s1;
if ( !strcmp(s1, "e") )
{
asmsyntax = 0;
}
else
{
if ( strcmp(v4, "m") )
{
die("unknown gnu syntax flavor");
JUMPOUT(0xE92LL);
}
asmsyntax = 1;
}
break;
case 'I':
lappend(&incpaths, &nincpaths, s1);
break;
case 'O':
objdir = (__int64)s1;
break;
case 'S':
writeasm = 1;
break;
case 'T':
++allowhidden;
break;
case 'c':
extracheck = 1;
break;
case 'd':
v3 = s1;
if ( s1 )
{
while ( *v3 )
{
s1 = ++v3;
++debugopt[*(v3 - 1) & 0x7F];
}
}
break;
case 'o':
outfile = s1;
break;
default:
usage(*argv);
exit(0);
}
}
lappend(&incpaths, &nincpaths, "/usr/local/lib/myr");
if ( !v11 )
{
fwrite("No input files given\n", 1uLL, 0x15uLL, stderr);
exit(1);
}
if ( v11 != 1 )
outfile = 0LL;
v5 = 0LL;
do
{
v6 = outfile;
v7 = v5;
if ( !outfile )
v6 = (const char *)v10[v5];
localincpath = (void *)dirname(v6);
initfile(file, *v10);
tokinit(v10[v5]);
yyparse();
if ( debugopt[84] )
dump(stdout);
loaduses();
if ( hasmain() )
{
genautocall(file[10], file[11], file[16], "__init__");
genautocall(file[12], file[13], file[17], "__fini__");
}
infer();
tagexports(0LL);
if ( debugopt[116] )
dump(stdout);
if ( writeasm )
{
if ( outfile )
swapout_constprop_0((__int64)name, ".s");
else
swapsuffix(name, 1024LL, v10[v5], ".myr", ".s");
}
else
{
gentempfile_constprop_0_isra_0((__int64)name, (const char *)v10[v5]);
}
++v5;
genuse((const char *)v10[v7]);
gen(name);
assemble(name, (char *)v10[v7]);
free(localincpath);
}
while ( v11 > v5 );
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // rbp
unsigned __int64 v5; // rbp
const char *v6; // rdi
__int64 v7; // rbx
char *s1; // [rsp+0h] [rbp-468h] BYREF
_QWORD *v10; // [rsp+8h] [rbp-460h]
unsigned __int64 v11; // [rsp+10h] [rbp-458h]
char name[1048]; // [rsp+50h] [rbp-418h] BYREF

outfile = 0LL;
optinit(&s1, "cd:?hSo:I:9G:O:T", argv, argc);
asmsyntax = 0;
sizefn = &size;
while ( !(unsigned int)optdone(&s1) )
{
switch ( (unsigned int)optnext(&s1) )
{
case '9':
asmsyntax = 2;
break;
case 'G':
v4 = s1;
if ( !strcmp(s1, "e") )
{
asmsyntax = 0;
}
else
{
if ( strcmp(v4, "m") )
{
die("unknown gnu syntax flavor");
JUMPOUT(0xE92LL);
}
asmsyntax = 1;
}
break;
case 'I':
lappend(&incpaths, &nincpaths, s1);
break;
case 'O':
objdir = (__int64)s1;
break;
case 'S':
writeasm = 1;
break;
case 'T':
++allowhidden;
break;
case 'c':
extracheck = 1;
break;
case 'd':
v3 = s1;
if ( s1 )
{
while ( *v3 )
{
s1 = ++v3;
++debugopt[*(v3 - 1) & 0x7F];
}
}
break;
case 'o':
outfile = s1;
break;
default:
func0(*argv);
exit(0);
}
}
lappend(&incpaths, &nincpaths, "/usr/local/lib/myr");
if ( !v11 )
{
fwrite("No input files given\n", 1uLL, 0x15uLL, stderr);
exit(1);
}
if ( v11 != 1 )
outfile = 0LL;
v5 = 0LL;
do
{
v6 = outfile;
v7 = v5;
if ( !outfile )
v6 = (const char *)v10[v5];
localincpath = (void *)func1(v6);
initfile(file, *v10);
tokinit(v10[v5]);
yyparse();
if ( debugopt[84] )
dump(stdout);
loaduses();
if ( func2() )
{
genautocall(file[10], file[11], file[16], "__init__");
genautocall(file[12], file[13], file[17], "__fini__");
}
infer();
tagexports(0LL);
if ( debugopt[116] )
dump(stdout);
if ( writeasm )
{
if ( outfile )
func5((__int64)name, ".s");
else
swapsuffix(name, 1024LL, v10[v5], ".myr", ".s");
}
else
{
func7((__int64)name, (const char *)v10[v5]);
}
++v5;
func6((const char *)v10[v7]);
gen(name);
func4(name, (char *)v10[v7]);
free(localincpath);
}
while ( v11 > 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 [-?|-h] [-o outfile] [-O dir] [-d[dbgopts]] inputs\n", a1);
puts("\t-?|-h\tPrint this help");
puts("\t-o\tOutput to outfile");
puts("\t-O dir\tOutput to dir");
puts("\t-S\tGenerate assembly source alongside object code");
puts("\t-T\tCompile in test mode");
puts("\t-c\tEnable additional (possibly flaky) checking");
puts("\t-I path\tAdd 'path' to use search path");
puts("\t-d\tPrint debug dumps. Recognized options: f r p i");
puts("\t-G\tGenerate asm in gas syntax");
puts("\t-9\tGenerate asm in plan 9 syntax");
puts("\t-d opts: additional debug logging. Options are listed below:");
puts("\t\tf: log folded trees");
puts("\t\tl: log lowered pre-cfg trees");
puts("\t\tT: log tree immediately");
puts("\t\tr: log register allocation activity");
puts("\t\ti: log instruction selection activity");
return puts("\t\tu: log type unifications");
}

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

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 *


mkpath

decompiled_code:
char *__fastcall mkpath(void *src)
{
_BYTE *v1; // r12
signed __int64 v2; // rbp
char *result; // rax
__int64 v4; // rbx
char v5[280]; // [rsp+0h] [rbp-118h] BYREF

v1 = src;
if ( strlen((const char *)src) > 0xFF )
_assert_fail("strlen(p) < sizeof(path)", "main.c", 0x4Bu, "mkpath");
while ( 1 )
{
result = strchr((const char *)src, 47);
v4 = (__int64)result;
if ( !result )
break;
v2 = result - v1;
memcpy(v5, v1, result - v1);
v5[v2] = 0;
mkdir(v5, 0x1EDu);
src = (void *)(v4 + 1);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func3(void *src)
{
_BYTE *v1; // r12
signed __int64 v2; // rbp
char *result; // rax
__int64 v4; // rbx
char v5[280]; // [rsp+0h] [rbp-118h] BYREF

v1 = src;
if ( strlen((const char *)src) > 0xFF )
_assert_fail("strlen(p) < sizeof(path)", "main.c", 0x4Bu, "mkpath");
while ( 1 )
{
result = strchr((const char *)src, 47);
v4 = (__int64)result;
if ( !result )
break;
v2 = result - v1;
memcpy(v5, v1, result - v1);
v5[v2] = 0;
mkdir(v5, 0x1EDu);
src = (void *)(v4 + 1);
}
return result;
}

original_code:
static void
mkpath(char *p)
{
 char *e, path[256];
 e = p;
 ((void) sizeof ((strlen(p) < sizeof(path)) ? 1 : 0), __extension__ ({ if (strlen(p) < sizeof(path)) ; else __assert_fail ("strlen(p) < sizeof(path)", "main.c", 75, __extension__ __PRETTY_FUNCTION__); }));
 while ((e = strstr(e, "/")) != ((void *)0)) {
  memcpy(path, p, (e - p));
  path[e - p] = 0;
  mkdir(path, 0755);
  e++;
 }
}

canonical_original_code:
static void mkpath(char *p)
{
 char *e; char path[256];
 e = p;
 ((void) sizeof ((strlen(p) < sizeof(path)) ? 1 : 0), __extension__ ({ if (strlen(p) < sizeof(path)) ; else __assert_fail ("strlen(p) < sizeof(path)", "main.c", 75, __extension__ __PRETTY_FUNCTION__); }));
 while ((e = strstr(e, "/")) != ((void *)0)) {
  memcpy(path, p, (e - p));
  path[e - p] = 0;
  mkdir(path, 0755);
  e++;
 }
}

variable_types:
p
char *

variable_types:
e
char *

variable_types:
path
char [256]


zalloc

decompiled_code:
void *__fastcall zalloc(size_t size)
{
void *result; // rax

result = calloc(1uLL, size);
if ( !result )
{
if ( size )
{
die("Out of memory");
result = (void *)xalloc();
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t size)
{
void *result; // rax

result = calloc(1uLL, size);
if ( !result )
{
if ( size )
{
die("Out of memory");
result = (void *)func1();
}
}
return result;
}

original_code:
void *
zalloc(size_t sz)
{
 void *mem;
 mem = calloc(1, sz);
 if (!mem && sz)
  die("Out of memory");
 return mem;
}

canonical_original_code:
void *zalloc(unsigned long sz)
{
 void *mem;
 mem = calloc(1, sz);
 if (!mem && sz)
  die("Out of memory");
 return mem;
}

variable_types:
sz
unsigned long

variable_types:
mem
void *

return_type: void *


xalloc

decompiled_code:
void *__fastcall xalloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
if ( a1 )
{
die("Out of memory");
result = (void *)xrealloc();
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
if ( a1 )
{
die("Out of memory");
result = (void *)func2();
}
}
return result;
}

original_code:
void *
xalloc(size_t sz)
{
 void *mem;
 mem = malloc(sz);
 if (!mem && sz)
  die("Out of memory");
 return mem;
}

canonical_original_code:
void *xalloc(unsigned long sz)
{
 void *mem;
 mem = malloc(sz);
 if (!mem && sz)
  die("Out of memory");
 return mem;
}


xrealloc

decompiled_code:
void *__fastcall xrealloc(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
if ( a2 )
{
die("Out of memory");
result = (void *)zrealloc();
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
if ( a2 )
{
die("Out of memory");
result = (void *)func3();
}
}
return result;
}

original_code:
void *
xrealloc(void *mem, size_t sz)
{
 mem = realloc(mem, sz);
 if (!mem && sz)
  die("Out of memory");
 return mem;
}

canonical_original_code:
void *xrealloc(void *mem, unsigned long sz)
{
 mem = realloc(mem, sz);
 if (!mem && sz)
  die("Out of memory");
 return mem;
}


zrealloc

decompiled_code:
char *__fastcall zrealloc(void *a1, unsigned __int64 a2, size_t a3)
{
char *result; // rax
char *v5; // r12

result = (char *)xrealloc(a1, a3);
v5 = result;
if ( a3 > a2 )
{
memset(&result[a2], 0, a3 - a2);
result = v5;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func3(void *a1, unsigned __int64 a2, size_t a3)
{
char *result; // rax
char *v5; // r12

result = (char *)func2(a1, a3);
v5 = result;
if ( a3 > a2 )
{
memset(&result[a2], 0, a3 - a2);
result = v5;
}
return result;
}

original_code:
void *
zrealloc(void *mem, size_t oldsz, size_t sz)
{
 char *p;
 p = xrealloc(mem, sz);
 if (sz > oldsz)
  memset(&p[oldsz], 0, sz - oldsz);
 return p;
}

canonical_original_code:
void *zrealloc(void *mem, unsigned long oldsz, unsigned long sz)
{
 char *p;
 p = xrealloc(mem, sz);
 if (sz > oldsz)
  memset(&p[oldsz], 0, sz - oldsz);
 return p;
}

variable_types:
oldsz
unsigned long


lpop

original_code:
void *
lpop(void *l, size_t *len)
{
 void ***pl;
 void *v;
 pl = l;
 (*len)--;
 v = (*pl)[*len];
 *pl = xrealloc(*pl, *len * sizeof(void *));
 return v;
}

canonical_original_code:
void *lpop(void *l, unsigned long *len)
{
 void ***pl;
 void *v;
 pl = l;
 (*len)--;
 v = (*pl)[*len];
 *pl = xrealloc(*pl, *len * sizeof(void *));
 return v;
}

variable_types:
l
void *

variable_types:
len
unsigned long *

variable_types:
pl
void ***

variable_types:
v
void *


ldel

decompiled_code:
void *__fastcall ldel(void **a1, __int64 *a2, unsigned __int64 a3)
{
void *v4; // r12
__int64 v5; // rsi
void *result; // rax

if ( !a1 )
_assert_fail("p != NULL", "alloc.c", 0x68u, "ldel");
if ( *a2 <= a3 )
_assert_fail("idx < *len", "alloc.c", 0x69u, "ldel");
v4 = *a1;
memmove((char *)*a1 + 8 * a3, (char *)*a1 + 8 * a3 + 8, 8 * (*a2 + ~a3));
v5 = *a2 - 1;
*a2 = v5;
result = xrealloc(v4, 8 * v5);
*a1 = result;
return result;
}

canonical_decompiled_code:
void *__fastcall func7(void **a1, __int64 *a2, unsigned __int64 a3)
{
void *v4; // r12
__int64 v5; // rsi
void *result; // rax

if ( !a1 )
_assert_fail("p != NULL", "alloc.c", 0x68u, "ldel");
if ( *a2 <= a3 )
_assert_fail("idx < *len", "alloc.c", 0x69u, "ldel");
v4 = *a1;
memmove((char *)*a1 + 8 * a3, (char *)*a1 + 8 * a3 + 8, 8 * (*a2 + ~a3));
v5 = *a2 - 1;
*a2 = v5;
result = func2(v4, 8 * v5);
*a1 = result;
return result;
}

original_code:
void
ldel(void *p, size_t *len, size_t idx)
{
 void ***pl, **l;
 ((void) sizeof ((p != ((void *)0)) ? 1 : 0), __extension__ ({ if (p != ((void *)0)) ; else __assert_fail ("p != NULL", "alloc.c", 104, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((idx < *len) ? 1 : 0), __extension__ ({ if (idx < *len) ; else __assert_fail ("idx < *len", "alloc.c", 105, __extension__ __PRETTY_FUNCTION__); }));
 pl = p;
 l = *pl;
 memmove(&l[idx], &l[idx + 1], (*len - idx - 1) * sizeof(void *));
 (*len)--;
 *pl = xrealloc(l, *len * sizeof(void *));
}

canonical_original_code:
void ldel(void *p, unsigned long *len, unsigned long idx)
{
 void ***pl; void **l;
 ((void) sizeof ((p != ((void *)0)) ? 1 : 0), __extension__ ({ if (p != ((void *)0)) ; else __assert_fail ("p != NULL", "alloc.c", 104, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((idx < *len) ? 1 : 0), __extension__ ({ if (idx < *len) ; else __assert_fail ("idx < *len", "alloc.c", 105, __extension__ __PRETTY_FUNCTION__); }));
 pl = p;
 l = *pl;
 memmove(&l[idx], &l[idx + 1], (*len - idx - 1) * sizeof(void *));
 (*len)--;
 *pl = xrealloc(l, *len * sizeof(void *));
}

variable_types:
p
void *

variable_types:
idx
unsigned long

variable_types:
l
void **


lcat

decompiled_code:
__int64 __fastcall lcat(void **a1, __int64 *a2, __int64 a3, __int64 a4)
{
__int64 i; // rbx
__int64 v7; // rdx
__int64 result; // rax

if ( a4 )
{
for ( i = 0LL; i != a4; ++i )
{
v7 = *(_QWORD *)(a3 + 8 * i);
result = lappend(a1, a2, v7);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(void **a1, __int64 *a2, __int64 a3, __int64 a4)
{
__int64 i; // rbx
__int64 v7; // rdx
__int64 result; // rax

if ( a4 )
{
for ( i = 0LL; i != a4; ++i )
{
v7 = *(_QWORD *)(a3 + 8 * i);
result = func4(a1, a2, v7);
}
}
return result;
}

original_code:
void
lcat(void *dst, size_t *ndst, void *src, size_t nsrc)
{
 size_t i;
 void ***d, **s;
 d = dst;
 s = src;
 for (i = 0; i < nsrc; i++)
  lappend(d, ndst, s[i]);
}

canonical_original_code:
void lcat(void *dst, unsigned long *ndst, void *src, unsigned long nsrc)
{
 unsigned long i;
 void ***d; void **s;
 d = dst;
 s = src;
 for (i = 0; i < nsrc; i++)
  lappend(d, ndst, s[i]);
}

variable_types:
dst
void *

variable_types:
ndst
unsigned long *

variable_types:
src
void *

variable_types:
nsrc
unsigned long

variable_types:
i
unsigned long

variable_types:
d
void ***

variable_types:
s
void **


memdup

decompiled_code:
void *__fastcall memdup(void *src, size_t n)
{
void *v2; // rax

if ( !src )
return 0LL;
v2 = xalloc(n);
return memcpy(v2, src, n);
}

canonical_decompiled_code:
void *__fastcall func10(void *src, size_t n)
{
void *v2; // rax

if ( !src )
return 0LL;
v2 = func1(n);
return memcpy(v2, src, n);
}

original_code:
void *
memdup(void *mem, size_t len)
{
 void *ret;
        if (!mem)
            return ((void *)0);
 ret = xalloc(len);
 return memcpy(ret, mem, len);
}

canonical_original_code:
void *memdup(void *mem, unsigned long len)
{
 void *ret;
        if (!mem)
            return ((void *)0);
 ret = xalloc(len);
 return memcpy(ret, mem, len);
}

variable_types:
len
unsigned long

variable_types:
ret
void *


locregid

original_code:
static Loc *
locregid(regid id, Mode m)
{
 Loc *l;
 l = zalloc(sizeof(Loc));
 l->type = Locreg;
 l->mode = m;
 l->reg.id = id;
 locmap = xrealloc(locmap, maxregid * sizeof(Loc*));
 locmap[l->reg.id] = l;
 return l;
}

canonical_original_code:
static struct Loc *locregid(unsigned long id, enum Mode m)
{
 struct Loc *l;
 l = zalloc(sizeof(Loc));
 l->type = Locreg;
 l->mode = m;
 l->reg.id = id;
 locmap = xrealloc(locmap, maxregid * sizeof(struct Loc *));
 locmap[l->reg.id] = l;
 return l;
}

variable_types:
id
unsigned long

variable_types: struct Loc { enum Loctype { Locnone=0, Loclbl=1, Locreg=2, Locmem=3, Locmeml=4, Loclit=5, Loclitl=6 } type; enum Mode { ModeNone=0, ModeB=1, ModeW=2, ModeL=3, ModeQ=4, ModeF=5, ModeD=6, Nmode=7 } mode; void *list; union { char *lbl; struct { unsigned long id; enum Reg { Rnone=0, Ral=1, Rcl=2, Rdl=3, Rbl=4, Rsil=5, Rdil=6, Rspl=7, Rbpl=8, Rr8b=9, Rr9b=10, Rr10b=11, Rr11b=12, Rr12b=13, Rr13b=14, Rr14b=15, Rr15b=16, Rah=17, Rch=18, Rdh=19, Rbh=20, Rax=21, Rcx=22, Rdx=23, Rbx=24, Rsi=25, Rdi=26, Rsp=27, Rbp=28, Rr8w=29, Rr9w=30, Rr10w=31, Rr11w=32, Rr12w=33, Rr13w=34, Rr14w=35, Rr15w=36, Reax=37, Recx=38, Redx=39, Rebx=40, Resi=41, Redi=42, Resp=43, Rebp=44, Rr8d=45, Rr9d=46, Rr10d=47, Rr11d=48, Rr12d=49, Rr13d=50, Rr14d=51, Rr15d=52, Rrax=53, Rrcx=54, Rrdx=55, Rrbx=56, Rrsi=57, Rrdi=58, Rrsp=59, Rrbp=60, Rr8=61, Rr9=62, Rr10=63, Rr11=64, Rr12=65, Rr13=66, Rr14=67, Rr15=68, Rxmm0f=69, Rxmm1f=70, Rxmm2f=71, Rxmm3f=72, Rxmm4f=73, Rxmm5f=74, Rxmm6f=75, Rxmm7f=76, Rxmm8f=77, Rxmm9f=78, Rxmm10f=79, Rxmm11f=80, Rxmm12f=81, Rxmm13f=82, Rxmm14f=83, Rxmm15f=84, Rxmm0d=85, Rxmm1d=86, Rxmm2d=87, Rxmm3d=88, Rxmm4d=89, Rxmm5d=90, Rxmm6d=91, Rxmm7d=92, Rxmm8d=93, Rxmm9d=94, Rxmm10d=95, Rxmm11d=96, Rxmm12d=97, Rxmm13d=98, Rxmm14d=99, Rxmm15d=100, Rrip=101, Nreg=102 } colour; } reg; long lit; struct { char *lbldisp; long constdisp; int scale; struct Loc *base; struct Loc *idx; } mem; }; } *

user_defined_types: struct Loc { enum Loctype type; enum Mode mode; void *list; union { char *lbl; struct { unsigned long id; enum Reg colour; } reg; long lit; struct { char *lbldisp; long constdisp; int scale; struct Loc *base; struct Loc *idx; } mem; }; }


isintmode

decompiled_code:
_BOOL8 __fastcall isintmode(int a1)
{
return (unsigned int)(a1 - 1) <= 3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(int a1)
{
return (unsigned int)(a1 - 1) <= 3;
}

original_code:
int
isintmode(Mode m)
{
 return m == ModeB || m == ModeW || m == ModeL || m == ModeQ;
}

canonical_original_code:
int isintmode(enum Mode m)
{
 return m == ModeB || m == ModeW || m == ModeL || m == ModeQ;
}

variable_types: enum Mode { ModeNone=0, ModeB=1, ModeW=2, ModeL=3, ModeQ=4, ModeF=5, ModeD=6, Nmode=7 }


isfloatmode

decompiled_code:
_BOOL8 __fastcall isfloatmode(int a1)
{
return (unsigned int)(a1 - 5) <= 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(int a1)
{
return (unsigned int)(a1 - 5) <= 1;
}

original_code:
int
isfloatmode(Mode m)
{
 return m == ModeF || m == ModeD;
}

canonical_original_code:
int isfloatmode(enum Mode m)
{
 return m == ModeF || m == ModeD;
}

user_defined_types: enum Mode { ModeNone=0, ModeB=1, ModeW=2, ModeL=3, ModeQ=4, ModeF=5, ModeD=6, Nmode=7 }


resetregs

decompiled_code:
void resetregs()
{
maxregid = 102LL;
}

canonical_decompiled_code:
void func3()
{
maxregid = 102LL;
}

original_code:
void
resetregs()
{
 maxregid = Nreg;
}

canonical_original_code:
void resetregs()
{
 maxregid = Nreg;
}


locreg

decompiled_code:
__int64 __fastcall locreg(int a1)
{
__int64 v2; // rdi

v2 = maxregid++;
return locregid(v2, a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
__int64 v2; // rdi

v2 = maxregid++;
return func0(v2, a1);
}

original_code:
Loc *
locreg(Mode m)
{
 return locregid(maxregid++, m);
}

canonical_original_code:
struct Loc *locreg(enum Mode m)
{
 return locregid(maxregid++, m);
}

return_type: struct Loc { enum Loctype { Locnone=0, Loclbl=1, Locreg=2, Locmem=3, Locmeml=4, Loclit=5, Loclitl=6 } type; enum Mode { ModeNone=0, ModeB=1, ModeW=2, ModeL=3, ModeQ=4, ModeF=5, ModeD=6, Nmode=7 } mode; void *list; union { char *lbl; struct { unsigned long id; enum Reg { Rnone=0, Ral=1, Rcl=2, Rdl=3, Rbl=4, Rsil=5, Rdil=6, Rspl=7, Rbpl=8, Rr8b=9, Rr9b=10, Rr10b=11, Rr11b=12, Rr12b=13, Rr13b=14, Rr14b=15, Rr15b=16, Rah=17, Rch=18, Rdh=19, Rbh=20, Rax=21, Rcx=22, Rdx=23, Rbx=24, Rsi=25, Rdi=26, Rsp=27, Rbp=28, Rr8w=29, Rr9w=30, Rr10w=31, Rr11w=32, Rr12w=33, Rr13w=34, Rr14w=35, Rr15w=36, Reax=37, Recx=38, Redx=39, Rebx=40, Resi=41, Redi=42, Resp=43, Rebp=44, Rr8d=45, Rr9d=46, Rr10d=47, Rr11d=48, Rr12d=49, Rr13d=50, Rr14d=51, Rr15d=52, Rrax=53, Rrcx=54, Rrdx=55, Rrbx=56, Rrsi=57, Rrdi=58, Rrsp=59, Rrbp=60, Rr8=61, Rr9=62, Rr10=63, Rr11=64, Rr12=65, Rr13=66, Rr14=67, Rr15=68, Rxmm0f=69, Rxmm1f=70, Rxmm2f=71, Rxmm3f=72, Rxmm4f=73, Rxmm5f=74, Rxmm6f=75, Rxmm7f=76, Rxmm8f=77, Rxmm9f=78, Rxmm10f=79, Rxmm11f=80, Rxmm12f=81, Rxmm13f=82, Rxmm14f=83, Rxmm15f=84, Rxmm0d=85, Rxmm1d=86, Rxmm2d=87, Rxmm3d=88, Rxmm4d=89, Rxmm5d=90, Rxmm6d=91, Rxmm7d=92, Rxmm8d=93, Rxmm9d=94, Rxmm10d=95, Rxmm11d=96, Rxmm12d=97, Rxmm13d=98, Rxmm14d=99, Rxmm15d=100, Rrip=101, Nreg=102 } colour; } reg; long lit; struct { char *lbldisp; long constdisp; int scale; struct Loc *base; struct Loc *idx; } mem; }; } *