/* Generated by Nimrod Compiler v0.9.5 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, i386, gcc */
/* Command for C compiler:
   gcc -c  -w -O3 -fno-strict-aliasing  -I/build/nimrod/src/nimrod/lib -o compiler/nimcache/semtypinst.o compiler/nimcache/semtypinst.c */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <string.h>
typedef struct ttype188837 ttype188837;
typedef struct tcontext250019 tcontext250019;
typedef struct tidtable188849 tidtable188849;
typedef struct tidpairseq188847 tidpairseq188847;
typedef struct tidpair188845 tidpair188845;
typedef struct tidobj167013 tidobj167013;
typedef struct TNimObject TNimObject;
typedef struct TGenericSeq TGenericSeq;
typedef struct tlineinfo163527 tlineinfo163527;
typedef struct trepltypevars273546 trepltypevars273546;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct ttypeseq188835 ttypeseq188835;
typedef struct tnode188803 tnode188803;
typedef struct tsym188833 tsym188833;
typedef struct tloc188817 tloc188817;
typedef struct trope145007 trope145007;
typedef struct NimStringDesc NimStringDesc;
typedef struct TY79484 TY79484;
typedef struct tscope188827 tscope188827;
typedef struct TY188933 TY188933;
typedef struct tinstantiation188823 tinstantiation188823;
typedef struct tstrtable188807 tstrtable188807;
typedef struct tsymseq188805 tsymseq188805;
typedef struct tident167019 tident167019;
typedef struct tlib188821 tlib188821;
typedef struct tcell41090 tcell41090;
typedef struct tcellseq41106 tcellseq41106;
typedef struct tgcheap43016 tgcheap43016;
typedef struct tcellset41102 tcellset41102;
typedef struct tpagedesc41098 tpagedesc41098;
typedef struct tmemregion23410 tmemregion23410;
typedef struct tsmallchunk22638 tsmallchunk22638;
typedef struct tllchunk23404 tllchunk23404;
typedef struct tbigchunk22640 tbigchunk22640;
typedef struct tintset22615 tintset22615;
typedef struct ttrunk22611 ttrunk22611;
typedef struct tavlnode23408 tavlnode23408;
typedef struct tgcstat43014 tgcstat43014;
typedef struct tnodeseq188797 tnodeseq188797;
typedef struct tpasscontext246003 tpasscontext246003;
typedef struct tproccon250009 tproccon250009;
typedef struct tintset185047 tintset185047;
typedef struct ttrunk185043 ttrunk185043;
typedef struct ttrunkseq185045 ttrunkseq185045;
typedef struct tlinkedlist118023 tlinkedlist118023;
typedef struct tlistentry118017 tlistentry118017;
typedef struct tctx249037 tctx249037;
typedef struct TY250131 TY250131;
typedef struct tinstantiationpair250011 tinstantiationpair250011;
typedef struct TY188922 TY188922;
typedef struct tbasechunk22636 tbasechunk22636;
typedef struct tfreecell22628 tfreecell22628;
typedef struct TY249229 TY249229;
typedef struct TY164208 TY164208;
typedef struct pprocHEX3Aobjecttype249216 pprocHEX3Aobjecttype249216;
typedef struct TY249217 TY249217;
typedef struct tblock249023 tblock249023;
typedef struct TY249198 TY249198;
typedef struct TY249223 TY249223;
struct  tidpair188845  {
tidobj167013* Key;
TNimObject* Val;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  tidtable188849  {
NI Counter;
tidpairseq188847* Data;
};
struct  tlineinfo163527  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  trepltypevars273546  {
tcontext250019* C;
tidtable188849 Typemap;
tidtable188849 Symmap;
tidtable188849 Localcache;
tlineinfo163527 Info;
NIM_BOOL Allowmetatypes;
};
typedef N_NIMCALL_PTR(void, TY2289) (void* p, NI op);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY2289 marker;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tidobj167013  {
  TNimObject Sup;
NI Id;
};
struct  tloc188817  {
NU8 K;
NU8 S;
NU8 Flags;
ttype188837* T;
trope145007* R;
trope145007* Heaproot;
NI A;
};
struct  ttype188837  {
  tidobj167013 Sup;
NU8 Kind;
NU8 Callconv;
NU32 Flags;
ttypeseq188835* Sons;
tnode188803* N;
tsym188833* Destructor;
tsym188833* Owner;
tsym188833* Sym;
NI64 Size;
NI Align;
tloc188817 Loc;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct TY79484 {
NimStringDesc* Field0;
NI Field1;
};
struct  tstrtable188807  {
NI Counter;
tsymseq188805* Data;
};
struct  tsym188833  {
  tidobj167013 Sup;
NU8 Kind;
union {
struct {ttypeseq188835* Typeinstcache;
tscope188827* Typscope;
} S1;
struct {TY188933* Procinstcache;
tscope188827* Scope;
} S2;
struct {TY188933* Usedgenerics;
tstrtable188807 Tab;
} S3;
} kindU;
NU16 Magic;
ttype188837* Typ;
tident167019* Name;
tlineinfo163527 Info;
tsym188833* Owner;
NU32 Flags;
tnode188803* Ast;
NU32 Options;
NI Position;
NI Offset;
tloc188817 Loc;
tlib188821* Annex;
tnode188803* Constraint;
};
struct  tcell41090  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq41106  {
NI Len;
NI Cap;
tcell41090** D;
};
struct  tcellset41102  {
NI Counter;
NI Max;
tpagedesc41098* Head;
tpagedesc41098** Data;
};
typedef tsmallchunk22638* TY23422[512];
typedef ttrunk22611* ttrunkbuckets22613[256];
struct  tintset22615  {
ttrunkbuckets22613 Data;
};
struct  tmemregion23410  {
NI Minlargeobj;
NI Maxlargeobj;
TY23422 Freesmallchunks;
tllchunk23404* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk22640* Freechunkslist;
tintset22615 Chunkstarts;
tavlnode23408* Root;
tavlnode23408* Deleted;
tavlnode23408* Last;
tavlnode23408* Freeavlnodes;
};
struct  tgcstat43014  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap43016  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq41106 Zct;
tcellseq41106 Decstack;
tcellset41102 Cycleroots;
tcellseq41106 Tempstack;
NI Recgclock;
tmemregion23410 Region;
tgcstat43014 Stat;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef ttype188837* TY350968[1];
struct  tnode188803  {
ttype188837* Typ;
tlineinfo163527 Info;
NU16 Flags;
NU8 Kind;
union {
struct {NI64 Intval;
} S1;
struct {NF Floatval;
} S2;
struct {NimStringDesc* Strval;
} S3;
struct {tsym188833* Sym;
} S4;
struct {tident167019* Ident;
} S5;
struct {tnodeseq188797* Sons;
} S6;
} kindU;
NimStringDesc* Comment;
};
struct  tpasscontext246003  {
  TNimObject Sup;
NIM_BOOL Fromcache;
};
struct  tintset185047  {
NI Counter;
NI Max;
ttrunk185043* Head;
ttrunkseq185045* Data;
};
struct  tlinkedlist118023  {
tlistentry118017* Head;
tlistentry118017* Tail;
NI Counter;
};
typedef N_NIMCALL_PTR(tnode188803*, TY250061) (tcontext250019* c, tnode188803* n);
typedef N_NIMCALL_PTR(tnode188803*, TY250066) (tcontext250019* c, tnode188803* n, NU16 flags);
typedef N_NIMCALL_PTR(tnode188803*, TY250074) (tcontext250019* c, tnode188803* n, NU16 flags, NIM_BOOL buffererrors);
typedef N_NIMCALL_PTR(tnode188803*, TY250083) (tcontext250019* c, tnode188803* n);
typedef N_NIMCALL_PTR(tnode188803*, TY250088) (tcontext250019* c, tnode188803* n, NU16 flags);
typedef N_NIMCALL_PTR(tnode188803*, TY250096) (tcontext250019* c, tnode188803* n);
typedef N_NIMCALL_PTR(tnode188803*, TY250101) (tcontext250019* c, tnode188803* n, tnode188803* norig, NU32 filter);
typedef N_NIMCALL_PTR(ttype188837*, TY250108) (tcontext250019* c, tnode188803* n, ttype188837* prev);
typedef struct {
N_NIMCALL_PTR(tnode188803*, ClPrc) (tcontext250019* c, tidtable188849 pt, tnode188803* n, void* ClEnv);
void* ClEnv;
} TY250114;
typedef struct {
N_NIMCALL_PTR(tsym188833*, ClPrc) (tcontext250019* c, tsym188833* fn, tidtable188849 pt, tlineinfo163527 info, void* ClEnv);
void* ClEnv;
} TY250120;
struct  tinstantiationpair250011  {
tsym188833* Genericsym;
tinstantiation188823* Inst;
};
struct  tcontext250019  {
  tpasscontext246003 Sup;
tsym188833* Module;
tscope188827* Currentscope;
tscope188827* Importtable;
tscope188827* Toplevelscope;
tproccon250009* P;
tsym188833* Friendmodule;
NI Instcounter;
tintset185047 Ambiguoussymbols;
NI Intypeclass;
NI Ingenericcontext;
NI Inunrolledcontext;
NI Incompilescontext;
NI Ingenericinst;
tsymseq188805* Converters;
tsymseq188805* Patterns;
tlinkedlist118023 Optionstack;
tidtable188849 Symmapping;
tlinkedlist118023 Libs;
TY250061 Semconstexpr;
TY250066 Semexpr;
TY250074 Semtryexpr;
TY250083 Semtryconstexpr;
TY250088 Semoperand;
TY250096 Semconstboolexpr;
TY250101 Semoverloadedcall;
TY250108 Semtypenode;
TY250114 Seminferredlambda;
TY250120 Semgenerateinstance;
tintset185047 Includedfiles;
tstrtable188807 Userpragmas;
tctx249037* Evalcontext;
tintset185047 Unknownidents;
TY250131* Generics;
NI Lastgenericidx;
NI Hloloopdetector;
};
struct  trope145007  {
  TNimObject Sup;
trope145007* Left;
trope145007* Right;
NI Length;
NimStringDesc* Data;
};
struct  tscope188827  {
NI Depthlevel;
tstrtable188807 Symbols;
tnodeseq188797* Usingsyms;
tscope188827* Parent;
};
struct  tinstantiation188823  {
tsym188833* Sym;
ttypeseq188835* Concretetypes;
TY188922* Usedby;
};
struct  tident167019  {
  tidobj167013 Sup;
NimStringDesc* S;
tident167019* Next;
NI H;
};
struct  tlistentry118017  {
  TNimObject Sup;
tlistentry118017* Prev;
tlistentry118017* Next;
};
struct  tlib188821  {
  tlistentry118017 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope145007* Name;
tnode188803* Path;
};
typedef NI TY22618[16];
struct  tpagedesc41098  {
tpagedesc41098* Next;
NI Key;
TY22618 Bits;
};
struct  tbasechunk22636  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk22638  {
  tbasechunk22636 Sup;
tsmallchunk22638* Next;
tsmallchunk22638* Prev;
tfreecell22628* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk23404  {
NI Size;
NI Acc;
tllchunk23404* Next;
};
struct  tbigchunk22640  {
  tbasechunk22636 Sup;
tbigchunk22640* Next;
tbigchunk22640* Prev;
NI Align;
NF Data;
};
struct  ttrunk22611  {
ttrunk22611* Next;
NI Key;
TY22618 Bits;
};
typedef tavlnode23408* TY23414[2];
struct  tavlnode23408  {
TY23414 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tproccon250009  {
tsym188833* Owner;
tsym188833* Resultsym;
NI Nestedloopcounter;
NI Nestedblockcounter;
NI Intrystmt;
tproccon250009* Next;
};
struct  ttrunk185043  {
ttrunk185043* Next;
NI Key;
TY22618 Bits;
};
struct  tctx249037  {
  tpasscontext246003 Sup;
TY249229* Code;
TY164208* Debug;
tnode188803* Globals;
tnode188803* Constants;
ttypeseq188835* Types;
tnode188803* Currentexceptiona;
tnode188803* Currentexceptionb;
NI Exceptioninstr;
pprocHEX3Aobjecttype249216* Prc;
tsym188833* Module;
tnode188803* Callsite;
NU8 Mode;
NU8 Features;
NIM_BOOL Traceactive;
NI Loopiterations;
};
struct  tfreecell22628  {
tfreecell22628* Next;
NI Zerofield;
};
struct  tblock249023  {
tsym188833* Label;
TY249198* Fixups;
};
struct TY249223 {
NIM_BOOL Field0;
NU8 Field1;
};
typedef TY249223 TY249220[256];
struct  pprocHEX3Aobjecttype249216  {
TY249217* Blocks;
tsym188833* Sym;
TY249220 Slots;
NI Maxslots;
};
struct tidpairseq188847 {
  TGenericSeq Sup;
  tidpair188845 data[SEQ_DECL_SIZE];
};
struct ttypeseq188835 {
  TGenericSeq Sup;
  ttype188837* data[SEQ_DECL_SIZE];
};
struct TY188933 {
  TGenericSeq Sup;
  tinstantiation188823* data[SEQ_DECL_SIZE];
};
struct tsymseq188805 {
  TGenericSeq Sup;
  tsym188833* data[SEQ_DECL_SIZE];
};
struct tnodeseq188797 {
  TGenericSeq Sup;
  tnode188803* data[SEQ_DECL_SIZE];
};
struct ttrunkseq185045 {
  TGenericSeq Sup;
  ttrunk185043* data[SEQ_DECL_SIZE];
};
struct TY250131 {
  TGenericSeq Sup;
  tinstantiationpair250011 data[SEQ_DECL_SIZE];
};
struct TY188922 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
struct TY249229 {
  TGenericSeq Sup;
  NU32 data[SEQ_DECL_SIZE];
};
struct TY164208 {
  TGenericSeq Sup;
  tlineinfo163527 data[SEQ_DECL_SIZE];
};
struct TY249198 {
  TGenericSeq Sup;
  NI data[SEQ_DECL_SIZE];
};
struct TY249217 {
  TGenericSeq Sup;
  tblock249023 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, inittypevars_275714)(tcontext250019* p, tidtable188849 pt, tlineinfo163527 info, trepltypevars273546* Result);
N_NIMCALL(void, initidtable_189120)(tidtable188849* x);
N_NIMCALL(void, copyidtable_189175)(tidtable188849* dest, tidtable188849 src);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_NOINLINE(void, chckNil)(void* p);
N_NIMCALL(void, pushinfocontext_164697)(tlineinfo163527 info);
N_NIMCALL(ttype188837*, replacetypevarst_273584)(trepltypevars273546* cl, ttype188837* t);
N_NIMCALL(ttype188837*, replacetypevarstaux_273554)(trepltypevars273546* cl, ttype188837* t);
N_NIMCALL(TNimObject*, idtableget_197137)(tidtable188849 t, tidobj167013* key);
N_NIMCALL(ttype188837*, handlegenericinvokation_274647)(trepltypevars273546* cl, ttype188837* t);
N_NIMCALL(void, internalerror_165591)(tlineinfo163527 info, NimStringDesc* errmsg);
N_NIMCALL(ttype188837*, searchinsttypes_273203)(ttype188837* key);
N_NIMCALL(void, internalerror_165606)(NimStringDesc* errmsg);
N_NIMCALL(NimStringDesc*, HEX24_165714)(TY79484 x_165718);
N_NIMCALL(NIM_BOOL, HEX3DHEX3D_233264)(ttypeseq188835* x_233270, ttypeseq188835* y_233275);
N_NIMCALL(NIM_BOOL, comparetypes_230547)(ttype188837* x, ttype188837* y, NU8 cmp, NU8 flags);
static N_INLINE(NI, sonslen_189185)(ttype188837* n);
N_NIMCALL(ttype188837*, lookuptypevar_274558)(trepltypevars273546* cl, ttype188837* t);
N_NIMCALL(void, localerror_165571)(tlineinfo163527 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(NimStringDesc*, typetostring_223020)(ttype188837* typ, NU8 prefer);
N_NIMCALL(ttype188837*, errortype_251136)(tcontext250019* c);
N_NIMCALL(ttype188837*, instcopytype_274604)(trepltypevars273546* cl, ttype188837* t);
N_NIMCALL(ttype188837*, copytype_189141)(ttype188837* t, tsym188833* owner, NIM_BOOL keepid);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(tcell41090*, usrtocell_44443)(void* usr);
static N_INLINE(void, rtladdzct_46002)(tcell41090* c);
N_NOINLINE(void, addzct_44418)(tcellseq41106* s, tcell41090* c);
N_NIMCALL(void, propagatetoowner_192852)(ttype188837* owner, ttype188837* elem);
N_NIMCALL(ttype188837*, newtype_189060)(NU8 kind, tsym188833* owner);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(void, cachetypeinst_273454)(ttype188837* inst);
N_NIMCALL(void, safeadd_273475)(ttypeseq188835** x_273483, ttype188837* y_273487);
N_NIMCALL(void, idtableput_197147)(tidtable188849* t, tidobj167013* key, TNimObject* val);
N_NIMCALL(void, rawaddson_193092)(ttype188837* father, ttype188837* son);
static N_INLINE(ttype188837*, lastson_189193)(ttype188837* n);
N_NIMCALL(NIM_BOOL, isgenericalias_229482)(ttype188837* t);
N_NIMCALL(ttype188837*, skipgenericalias_229506)(ttype188837* t);
N_NIMCALL(void, checkpartialconstructedtype_273094)(tlineinfo163527 info, ttype188837* t);
N_NIMCALL(ttype188837*, skiptypes_192793)(ttype188837* t, NU64 kinds);
N_NIMCALL(void, sharedptrcheck_273010)(tlineinfo163527 info, ttype188837* t);
N_NIMCALL(NI, len_192569)(ttype188837* n);
static N_INLINE(NIM_BOOL, isgcedmem_192814)(ttype188837* t);
N_NIMCALL(tnode188803*, preparenode_273603)(trepltypevars273546* cl, tnode188803* n);
N_NIMCALL(tnode188803*, copynode_189233)(tnode188803* src);
N_NIMCALL(tsym188833*, replacetypevarss_273560)(trepltypevars273546* cl, tsym188833* s);
N_NIMCALL(tsym188833*, copysym_189147)(tsym188833* s, NIM_BOOL keepid);
N_NIMCALL(tnode188803*, replacetypevarsn_273566)(trepltypevars273546* cl, tnode188803* n_273570);
N_NIMCALL(tnode188803*, newnode_191003)(NU8 kind, tlineinfo163527 info, tnodeseq188797* sons, ttype188837* typ);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
static N_INLINE(NI, sonslen_189181)(tnode188803* n);
N_NIMCALL(void, illformedast_251203)(tnode188803* n);
N_NIMCALL(void, checksonslen_251209)(tnode188803* n, NI length);
N_NIMCALL(tnode188803*, newnodei_189099)(NU8 kind, tlineinfo163527 info);
N_NIMCALL(tnode188803*, reresolvecallswithtypedescparams_273974)(trepltypevars273546* cl, tnode188803* n);
static N_INLINE(tnode188803*, HEX5BHEX5D_189694)(tnode188803* n, NI i);
static N_INLINE(NI, safelen_189320)(tnode188803* n);
N_NIMCALL(NIM_BOOL, istypeparam_273733)(tnode188803* n);
N_NIMCALL(tnode188803*, newsymnode_189095)(tsym188833* sym);
N_NIMCALL(void, newsons_189197)(tnode188803* father, NI length);
N_NIMCALL(void, add_189390)(tnode188803* father, tnode188803* son);
N_NIMCALL(ttype188837*, newtypes_250180)(NU8 kind, tcontext250019* c);
static N_INLINE(ttype188837*, skipintlit_242424)(ttype188837* t);
N_NIMCALL(ttype188837*, getsystype_242024)(NU8 kind);
N_NIMCALL(ttype188837*, base_223029)(ttype188837* t);
N_NIMCALL(ttype188837*, maketypedesc_250627)(tcontext250019* c, ttype188837* typ);
N_NIMCALL(NIM_BOOL, containsgenerictype_232717)(ttype188837* t);
N_NIMCALL(void, propagatefieldflags_275421)(ttype188837* t, tnode188803* n);
static N_INLINE(NI, len_189264)(tnode188803* n);
N_NIMCALL(void, erasevoidparams_275102)(ttype188837* t);
N_NIMCALL(TGenericSeq*, setLengthSeq)(TGenericSeq* seq, NI elemsize, NI newlen);
N_NIMCALL(void, skipintliteralparams_275297)(ttype188837* t);
N_NIMCALL(void, popinfocontext_164720)(void);
N_NIMCALL(NIM_BOOL, hasgenericarguments_273821)(tnode188803* n);
N_NIMCALL(NI64, computesize_223154)(ttype188837* typ);
STRING_LITERAL(TMP2528, "no generic body", 15);
STRING_LITERAL(TMP2530, "compiler/semtypinst.nim", 23);
NIM_CONST TY79484 TMP2529 = {((NimStringDesc*) &TMP2530),
52}
;
STRING_LITERAL(TMP2531, "substitution with generic parameter", 35);
STRING_LITERAL(TMP2532, "acyclic", 7);
STRING_LITERAL(TMP2533, "", 0);
STRING_LITERAL(TMP2534, "shared memory may not refer to GC\'ed thread local memory", 56);
STRING_LITERAL(TMP2535, "ReplaceTypeVarsN: when condition not a bool", 43);
NIM_CONST TY79484 TMP2538 = {((NimStringDesc*) &TMP2530),
417}
;
NIM_CONST TY79484 TMP2539 = {((NimStringDesc*) &TMP2530),
333}
;
extern tgcheap43016 gch_43044;
extern TNimType NTI188835; /* TTypeSeq */
extern TNimType NTI188797; /* TNodeSeq */

N_NIMCALL(void, inittypevars_275714)(tcontext250019* p, tidtable188849 pt, tlineinfo163527 info, trepltypevars273546* Result) {
	initidtable_189120(&(*Result).Symmap);
	copyidtable_189175(&(*Result).Typemap, pt);
	initidtable_189120(&(*Result).Localcache);
	(*Result).Info = info;
	unsureAsgnRef((void**) &(*Result).C, p);
}

N_NIMCALL(ttype188837*, searchinsttypes_273203)(ttype188837* key) {
	ttype188837* result;
	ttype188837* generictyp;
	ttype188837* inst_273403;
	ttypeseq188835* HEX3Atmp_273444;
	NI i_273446;
	NI l_273448;
	result = 0;
	generictyp = (*key).Sons->data[0];
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		NimStringDesc* LOC9;
		LOC3 = 0;
		LOC4 = 0;
		LOC4 = ((*generictyp).Kind == ((NU8) 10));
		if (!(LOC4)) goto LA5;
		LOC4 = ((*key).Sons->data[0] == generictyp);
		LA5: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA6;
		LOC3 = !(((*generictyp).Sym == NIM_NIL));
		LA6: ;
		if (!!(LOC3)) goto LA7;
		LOC9 = 0;
		LOC9 = HEX24_165714(TMP2529);
		internalerror_165606(LOC9);
	}
	LA7: ;
	{
		NIM_BOOL LOC12;
		LOC12 = 0;
		LOC12 = HEX3DHEX3D_233264((*(*generictyp).Sym).kindU.S1.Typeinstcache, NIM_NIL);
		if (!LOC12) goto LA13;
		goto BeforeRet;
	}
	LA13: ;
	inst_273403 = 0;
	HEX3Atmp_273444 = 0;
	HEX3Atmp_273444 = (*(*generictyp).Sym).kindU.S1.Typeinstcache;
	i_273446 = 0;
	l_273448 = HEX3Atmp_273444->Sup.len;
	while (1) {
		if (!(i_273446 < l_273448)) goto LA15;
		inst_273403 = HEX3Atmp_273444->data[i_273446];
		{
			if (!((*inst_273403).Sup.Id == (*key).Sup.Id)) goto LA18;
			result = inst_273403;
			goto BeforeRet;
		}
		LA18: ;
		{
			if (!((*inst_273403).Sons->Sup.len < (*key).Sons->Sup.len)) goto LA22;
			goto BeforeRet;
		}
		LA22: ;
		{
			NI j_273438;
			NI HEX3Atmp_273440;
			NI res_273442;
			j_273438 = 0;
			HEX3Atmp_273440 = 0;
			HEX3Atmp_273440 = ((*key).Sons->Sup.len-1);
			res_273442 = 1;
			while (1) {
				if (!(res_273442 <= HEX3Atmp_273440)) goto LA25;
				j_273438 = res_273442;
				{
					NIM_BOOL LOC28;
					LOC28 = 0;
					LOC28 = comparetypes_230547((*inst_273403).Sons->data[j_273438], (*key).Sons->data[j_273438], ((NU8) 0), 8);
					if (!!(LOC28)) goto LA29;
					goto LA24;
				}
				LA29: ;
				res_273442 += 1;
			} LA25: ;
			result = inst_273403;
			goto BeforeRet;
		} LA24: ;
		i_273446 += 1;
	} LA15: ;
	BeforeRet: ;
	return result;
}

static N_INLINE(NI, sonslen_189185)(ttype188837* n) {
	NI result;
	result = 0;
	{
		if (!(*n).Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).Sons->Sup.len;
	}
	LA1: ;
	return result;
}

N_NIMCALL(ttype188837*, lookuptypevar_274558)(trepltypevars273546* cl, ttype188837* t) {
	ttype188837* result;
	TNimObject* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = idtableget_197137((*cl).Typemap, &t->Sup);
	result = ((ttype188837*) (LOC1));
	{
		NimStringDesc* LOC12;
		if (!(result == NIM_NIL)) goto LA4;
		{
			NIM_BOOL LOC8;
			LOC8 = 0;
			LOC8 = (*cl).Allowmetatypes;
			if (LOC8) goto LA9;
			LOC8 = (((*t).Flags &(1<<((((NU8) 10))&31)))!=0);
			LA9: ;
			if (!LOC8) goto LA10;
			goto BeforeRet;
		}
		LA10: ;
		LOC12 = 0;
		LOC12 = typetostring_223020(t, ((NU8) 0));
		localerror_165571((*(*t).Sym).Info, ((NU16) 124), LOC12);
		result = errortype_251136((*cl).C);
	}
	goto LA2;
	LA4: ;
	{
		NIM_BOOL LOC14;
		LOC14 = 0;
		LOC14 = ((*result).Kind == ((NU8) 12));
		if (!(LOC14)) goto LA15;
		LOC14 = !((*cl).Allowmetatypes);
		LA15: ;
		if (!LOC14) goto LA16;
		internalerror_165591((*cl).Info, ((NimStringDesc*) &TMP2531));
	}
	goto LA2;
	LA16: ;
	LA2: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(ttype188837*, instcopytype_274604)(trepltypevars273546* cl, ttype188837* t) {
	ttype188837* result;
	result = 0;
	result = copytype_189141(t, (*t).Owner, (*cl).Allowmetatypes);
	(*result).Flags |=((NI32)(1)<<((((NU8) 8))%(sizeof(NI32)*8)));
	(*result).Flags = ((*result).Flags & ~ 524288);
	return result;
}

static N_INLINE(tcell41090*, usrtocell_44443)(void* usr) {
	tcell41090* result;
	result = 0;
	result = ((tcell41090*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(tcell41090))))));
	return result;
}

static N_INLINE(void, rtladdzct_46002)(tcell41090* c) {
	addzct_44418(&gch_43044.Zct, c);
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		tcell41090* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_44443(src);
		(*c).Refcount += 8;
	}
	LA3: ;
	{
		tcell41090* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_44443((*dest));
		{
			(*c).Refcount -= 8;
			if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA11;
			rtladdzct_46002(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tcell41090* c;
	c = usrtocell_44443(p);
	{
		(*c).Refcount -= 8;
		if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA3;
		rtladdzct_46002(c);
	}
	LA3: ;
}

N_NIMCALL(void, cachetypeinst_273454)(ttype188837* inst) {
	ttype188837* generictyp;
	generictyp = (*inst).Sons->data[0];
	safeadd_273475(&(*(*generictyp).Sym).kindU.S1.Typeinstcache, inst);
}

static N_INLINE(ttype188837*, lastson_189193)(ttype188837* n) {
	ttype188837* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = sonslen_189185(n);
	result = (*n).Sons->data[(NI32)(LOC1 - 1)];
	return result;
}

static N_INLINE(NIM_BOOL, isgcedmem_192814)(ttype188837* t) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	NIM_BOOL LOC3;
	result = 0;
	LOC1 = 0;
	LOC1 = ((*t).Kind == ((NU8) 28) || (*t).Kind == ((NU8) 22) || (*t).Kind == ((NU8) 24));
	if (LOC1) goto LA2;
	LOC3 = 0;
	LOC3 = ((*t).Kind == ((NU8) 25));
	if (!(LOC3)) goto LA4;
	LOC3 = ((*t).Callconv == ((NU8) 8));
	LA4: ;
	LOC1 = LOC3;
	LA2: ;
	result = LOC1;
	return result;
}

N_NIMCALL(void, sharedptrcheck_273010)(tlineinfo163527 info, ttype188837* t) {
	{
		NIM_BOOL LOC3;
		NI LOC5;
		LOC3 = 0;
		LOC3 = ((*t).Kind == ((NU8) 21));
		if (!(LOC3)) goto LA4;
		LOC5 = 0;
		LOC5 = len_192569(t);
		LOC3 = (1 < LOC5);
		LA4: ;
		if (!LOC3) goto LA6;
		{
			if (!((*(*(*t).Sons->data[0]).Sym).Magic == ((NU16) 209) || (*(*(*t).Sons->data[0]).Sym).Magic == ((NU16) 210))) goto LA10;
			(*t).Flags |=((NI32)(1)<<((((NU8) 15))%(sizeof(NI32)*8)));
			{
				if (!((*(*(*t).Sons->data[0]).Sym).Magic == ((NU16) 210))) goto LA14;
				(*t).Flags |=((NI32)(1)<<((((NU8) 26))%(sizeof(NI32)*8)));
			}
			LA14: ;
			{
				NIM_BOOL LOC18;
				LOC18 = 0;
				LOC18 = (((*t).Flags &(1<<((((NU8) 20))&31)))!=0);
				if (LOC18) goto LA19;
				LOC18 = isgcedmem_192814(t);
				LA19: ;
				if (!LOC18) goto LA20;
				localerror_165571(info, ((NU16) 4), ((NimStringDesc*) &TMP2534));
			}
			LA20: ;
		}
		LA10: ;
	}
	LA6: ;
}

N_NIMCALL(void, checkpartialconstructedtype_273094)(tlineinfo163527 info, ttype188837* t) {
	{
		NIM_BOOL LOC3;
		ttype188837* LOC5;
		LOC3 = 0;
		LOC3 = (((*t).Flags &(1<<((((NU8) 4))&31)))!=0);
		if (!(LOC3)) goto LA4;
		LOC5 = 0;
		LOC5 = skiptypes_192793(t, IL64(211106232576256));
		LOC3 = !(((*LOC5).Kind == ((NU8) 17)));
		LA4: ;
		if (!LOC3) goto LA6;
		localerror_165571(info, ((NU16) 162), ((NimStringDesc*) &TMP2532));
	}
	goto LA1;
	LA6: ;
	{
		NIM_BOOL LOC9;
		LOC9 = 0;
		LOC9 = ((*t).Kind == ((NU8) 23));
		if (!(LOC9)) goto LA10;
		LOC9 = ((*(*t).Sons->data[0]).Kind == ((NU8) 23));
		LA10: ;
		if (!LOC9) goto LA11;
		localerror_165571(info, ((NU16) 197), ((NimStringDesc*) &TMP2533));
	}
	goto LA1;
	LA11: ;
	{
		sharedptrcheck_273010(info, t);
	}
	LA1: ;
}

N_NIMCALL(ttype188837*, handlegenericinvokation_274647)(trepltypevars273546* cl, ttype188837* t) {
	ttype188837* result;
	ttype188837* body;
	ttype188837* header;
	NI i_274693;
	NI HEX3Atmp_275085;
	NI LOC15;
	NI res_275087;
	TY350968 LOC39;
	NI i_274801;
	NI HEX3Atmp_275089;
	NI LOC45;
	NI res_275091;
	NI i_275014;
	NI HEX3Atmp_275093;
	NI LOC47;
	NI res_275095;
	ttype188837* newbody;
	ttype188837* LOC49;
	result = 0;
	body = (*t).Sons->data[0];
	{
		if (!!(((*body).Kind == ((NU8) 10)))) goto LA3;
		internalerror_165591((*cl).Info, ((NimStringDesc*) &TMP2528));
	}
	LA3: ;
	header = t;
	{
		TNimObject* LOC9;
		if (!(*cl).Allowmetatypes) goto LA7;
		LOC9 = 0;
		LOC9 = idtableget_197137((*cl).Localcache, &t->Sup);
		result = ((ttype188837*) (LOC9));
	}
	goto LA5;
	LA7: ;
	{
		result = searchinsttypes_273203(t);
	}
	LA5: ;
	{
		if (!!((result == NIM_NIL))) goto LA13;
		goto BeforeRet;
	}
	LA13: ;
	i_274693 = 0;
	HEX3Atmp_275085 = 0;
	LOC15 = 0;
	LOC15 = sonslen_189185(t);
	HEX3Atmp_275085 = (NI32)(LOC15 - 1);
	res_275087 = 1;
	while (1) {
		ttype188837* x;
		if (!(res_275087 <= HEX3Atmp_275085)) goto LA16;
		i_274693 = res_275087;
		x = (*t).Sons->data[i_274693];
		{
			if (!((*x).Kind == ((NU8) 12))) goto LA19;
			x = lookuptypevar_274558(&(*cl), x);
			{
				if (!!((x == NIM_NIL))) goto LA23;
				{
					if (!(header == t)) goto LA27;
					header = instcopytype_274604(cl, t);
				}
				LA27: ;
				asgnRefNoCycle((void**) &(*header).Sons->data[i_274693], x);
				propagatetoowner_192852(header, x);
			}
			LA23: ;
		}
		goto LA17;
		LA19: ;
		{
			propagatetoowner_192852(header, x);
		}
		LA17: ;
		res_275087 += 1;
	} LA16: ;
	{
		if (!!((header == t))) goto LA32;
		result = searchinsttypes_273203(header);
		{
			if (!!((result == NIM_NIL))) goto LA36;
			goto BeforeRet;
		}
		LA36: ;
	}
	goto LA30;
	LA32: ;
	{
		header = instcopytype_274604(cl, t);
	}
	LA30: ;
	result = newtype_189060(((NU8) 11), (*(*t).Sons->data[0]).Owner);
	(*result).Flags = (*header).Flags;
	if ((*result).Sons) nimGCunrefNoCycle((*result).Sons);
	(*result).Sons = (ttypeseq188835*) newSeqRC1((&NTI188835), 1);
	memset((void*)LOC39, 0, sizeof(LOC39));
	LOC39[0] = (*header).Sons->data[0];
	asgnRefNoCycle((void**) &(*result).Sons->data[0], LOC39[0]);
	{
		if (!!((*cl).Allowmetatypes)) goto LA42;
		cachetypeinst_273454(result);
	}
	goto LA40;
	LA42: ;
	{
		idtableput_197147(&(*cl).Localcache, &t->Sup, &result->Sup.Sup);
	}
	LA40: ;
	i_274801 = 0;
	HEX3Atmp_275089 = 0;
	LOC45 = 0;
	LOC45 = sonslen_189185(t);
	HEX3Atmp_275089 = (NI32)(LOC45 - 1);
	res_275091 = 1;
	while (1) {
		ttype188837* x;
		if (!(res_275091 <= HEX3Atmp_275089)) goto LA46;
		i_274801 = res_275091;
		x = replacetypevarst_273584(cl, (*t).Sons->data[i_274801]);
		asgnRefNoCycle((void**) &(*header).Sons->data[i_274801], x);
		propagatetoowner_192852(header, x);
		idtableput_197147(&(*cl).Typemap, &(*body).Sons->data[(NI32)(i_274801 - 1)]->Sup, &x->Sup.Sup);
		res_275091 += 1;
	} LA46: ;
	i_275014 = 0;
	HEX3Atmp_275093 = 0;
	LOC47 = 0;
	LOC47 = sonslen_189185(t);
	HEX3Atmp_275093 = (NI32)(LOC47 - 1);
	res_275095 = 1;
	while (1) {
		if (!(res_275095 <= HEX3Atmp_275093)) goto LA48;
		i_275014 = res_275095;
		rawaddson_193092(result, (*header).Sons->data[i_275014]);
		res_275095 += 1;
	} LA48: ;
	LOC49 = 0;
	LOC49 = lastson_189193(body);
	newbody = replacetypevarst_273584(cl, LOC49);
	(*newbody).Flags = ((*newbody).Flags | (((*t).Flags | (*body).Flags) & ~ 524288));
	(*result).Flags = ((*result).Flags | (*newbody).Flags);
	(*newbody).Callconv = (*body).Callconv;
	{
		NIM_BOOL LOC52;
		LOC52 = 0;
		LOC52 = isgenericalias_229482(newbody);
		if (!LOC52) goto LA53;
		newbody = skipgenericalias_229506(newbody);
	}
	LA53: ;
	rawaddson_193092(result, newbody);
	checkpartialconstructedtype_273094((*cl).Info, newbody);
	BeforeRet: ;
	return result;
}

static N_INLINE(NI, sonslen_189181)(tnode188803* n) {
	NI result;
	result = 0;
	{
		if (!(*n).kindU.S6.Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).kindU.S6.Sons->Sup.len;
	}
	LA1: ;
	return result;
}

static N_INLINE(tnode188803*, HEX5BHEX5D_189694)(tnode188803* n, NI i) {
	tnode188803* result;
	result = 0;
	result = (*n).kindU.S6.Sons->data[i];
	return result;
}

static N_INLINE(NI, safelen_189320)(tnode188803* n) {
	NI result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = ((*n).Kind >= ((NU8) 0) && (*n).Kind <= ((NU8) 23));
		if (LOC3) goto LA4;
		LOC3 = (*n).kindU.S6.Sons == 0;
		LA4: ;
		if (!LOC3) goto LA5;
		result = 0;
	}
	goto LA1;
	LA5: ;
	{
		result = (*n).kindU.S6.Sons->Sup.len;
	}
	LA1: ;
	return result;
}

N_NIMCALL(NIM_BOOL, istypeparam_273733)(tnode188803* n) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	NIM_BOOL LOC3;
	NIM_BOOL LOC5;
	result = 0;
	LOC1 = 0;
	LOC1 = ((*n).Kind == ((NU8) 3));
	if (!(LOC1)) goto LA2;
	LOC3 = 0;
	LOC3 = ((*(*n).kindU.S4.Sym).Kind == ((NU8) 4));
	if (LOC3) goto LA4;
	LOC5 = 0;
	LOC5 = ((*(*n).kindU.S4.Sym).Kind == ((NU8) 7));
	if (!(LOC5)) goto LA6;
	LOC5 = (((*(*n).kindU.S4.Sym).Flags &(1<<((((NU8) 2))&31)))!=0);
	LA6: ;
	LOC3 = LOC5;
	LA4: ;
	LOC1 = LOC3;
	LA2: ;
	result = LOC1;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(tnode188803*, reresolvecallswithtypedescparams_273974)(trepltypevars273546* cl, tnode188803* n) {
	tnode188803* result;
	NI i_274107;
	NI HEX3Atmp_274126;
	NI LOC20;
	NI res_274128;
	result = 0;
	{
		NIM_BOOL LOC3;
		tnode188803* LOC5;
		NIM_BOOL needsfixing;
		NI i_274042;
		NI HEX3Atmp_274122;
		NI LOC8;
		NI res_274124;
		LOC3 = 0;
		LOC3 = ((*n).Kind == ((NU8) 27) || (*n).Kind == ((NU8) 29) || (*n).Kind == ((NU8) 30) || (*n).Kind == ((NU8) 31) || (*n).Kind == ((NU8) 26) || (*n).Kind == ((NU8) 28) || (*n).Kind == ((NU8) 32));
		if (!(LOC3)) goto LA4;
		LOC5 = 0;
		LOC5 = HEX5BHEX5D_189694(n, 0);
		LOC3 = (((*(*LOC5).kindU.S4.Sym).Flags &(1<<((((NU8) 2))&31)))!=0);
		LA4: ;
		if (!LOC3) goto LA6;
		needsfixing = NIM_FALSE;
		i_274042 = 0;
		HEX3Atmp_274122 = 0;
		LOC8 = 0;
		LOC8 = safelen_189320(n);
		HEX3Atmp_274122 = LOC8 - 1;
		res_274124 = 1;
		while (1) {
			if (!(res_274124 <= HEX3Atmp_274122)) goto LA9;
			i_274042 = res_274124;
			{
				tnode188803* LOC12;
				NIM_BOOL LOC13;
				LOC12 = 0;
				LOC12 = HEX5BHEX5D_189694(n, i_274042);
				LOC13 = 0;
				LOC13 = istypeparam_273733(LOC12);
				if (!LOC13) goto LA14;
				needsfixing = NIM_TRUE;
			}
			LA14: ;
			res_274124 += 1;
		} LA9: ;
		{
			if (!needsfixing) goto LA18;
			asgnRefNoCycle((void**) &(*n).kindU.S6.Sons->data[0], newsymnode_189095((*(*(*n).kindU.S6.Sons->data[0]).kindU.S4.Sym).Owner));
			result = (*(*cl).C).Semoverloadedcall((*cl).C, n, n, 4096);
			goto BeforeRet;
		}
		LA18: ;
	}
	LA6: ;
	i_274107 = 0;
	HEX3Atmp_274126 = 0;
	LOC20 = 0;
	LOC20 = safelen_189320(n);
	HEX3Atmp_274126 = LOC20 - 1;
	res_274128 = 0;
	while (1) {
		tnode188803* LOC22;
		if (!(res_274128 <= HEX3Atmp_274126)) goto LA21;
		i_274107 = res_274128;
		LOC22 = 0;
		LOC22 = HEX5BHEX5D_189694(n, i_274107);
		asgnRefNoCycle((void**) &(*n).kindU.S6.Sons->data[i_274107], reresolvecallswithtypedescparams_273974(cl, LOC22));
		res_274128 += 1;
	} LA21: ;
	result = n;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(tnode188803*, replacetypevarsn_273566)(trepltypevars273546* cl, tnode188803* n_273570) {
	tnode188803* result;
	result = 0;
	{
		if (!(n_273570 == NIM_NIL)) goto LA3;
		goto BeforeRet;
	}
	LA3: ;
	result = copynode_189233(n_273570);
	{
		if (!!(((*n_273570).Typ == NIM_NIL))) goto LA7;
		asgnRefNoCycle((void**) &(*result).Typ, replacetypevarst_273584(cl, (*n_273570).Typ));
	}
	LA7: ;
	switch ((*n_273570).Kind) {
	case ((NU8) 0) ... ((NU8) 2):
	case ((NU8) 4) ... ((NU8) 23):
	{
	}
	break;
	case ((NU8) 3):
	{
		asgnRefNoCycle((void**) &(*result).kindU.S4.Sym, replacetypevarss_273560(cl, (*n_273570).kindU.S4.Sym));
		{
			tnodeseq188797* LOC15;
			if (!((*(*(*result).kindU.S4.Sym).Typ).Kind == ((NU8) 3))) goto LA13;
			LOC15 = 0;
			LOC15 = (tnodeseq188797*) newSeq((&NTI188797), 0);
			result = newnode_191003(((NU8) 136), (*n_273570).Info, LOC15, NIM_NIL);
		}
		LA13: ;
	}
	break;
	case ((NU8) 138):
	{
		tnode188803* branch;
		NI i_274291;
		NI HEX3Atmp_274487;
		NI LOC17;
		NI res_274489;
		branch = NIM_NIL;
		i_274291 = 0;
		HEX3Atmp_274487 = 0;
		LOC17 = 0;
		LOC17 = sonslen_189181(n_273570);
		HEX3Atmp_274487 = (NI32)(LOC17 - 1);
		res_274489 = 0;
		while (1) {
			tnode188803* it;
			if (!(res_274489 <= HEX3Atmp_274487)) goto LA18;
			i_274291 = res_274489;
			it = (*n_273570).kindU.S6.Sons->data[i_274291];
			{
				if (!(it == NIM_NIL)) goto LA21;
				illformedast_251203(n_273570);
			}
			LA21: ;
			switch ((*it).Kind) {
			case ((NU8) 86):
			{
				tnode188803* cond;
				tnode188803* e;
				checksonslen_251209(it, 2);
				cond = preparenode_273603(cl, (*it).kindU.S6.Sons->data[0]);
				e = (*(*cl).C).Semconstexpr((*cl).C, cond);
				{
					if (!!(((*e).Kind == ((NU8) 6)))) goto LA26;
					internalerror_165591((*e).Info, ((NimStringDesc*) &TMP2535));
				}
				LA26: ;
				{
					NIM_BOOL LOC30;
					LOC30 = 0;
					LOC30 = !(((*e).kindU.S1.Intval == 0));
					if (!(LOC30)) goto LA31;
					LOC30 = (branch == NIM_NIL);
					LA31: ;
					if (!LOC30) goto LA32;
					branch = (*it).kindU.S6.Sons->data[1];
				}
				LA32: ;
			}
			break;
			case ((NU8) 88):
			{
				checksonslen_251209(it, 1);
				{
					if (!(branch == NIM_NIL)) goto LA37;
					branch = (*it).kindU.S6.Sons->data[0];
				}
				LA37: ;
			}
			break;
			default:
			{
				illformedast_251203(n_273570);
			}
			break;
			}
			res_274489 += 1;
		} LA18: ;
		{
			if (!!((branch == NIM_NIL))) goto LA42;
			result = replacetypevarsn_273566(cl, branch);
		}
		goto LA40;
		LA42: ;
		{
			result = newnodei_189099(((NU8) 136), (*n_273570).Info);
		}
		LA40: ;
	}
	break;
	case ((NU8) 62):
	{
		tnode188803* n;
		n = preparenode_273603(cl, n_273570);
		n = reresolvecallswithtypedescparams_273974(cl, n);
		{
			if (!(*cl).Allowmetatypes) goto LA48;
			result = n;
		}
		goto LA46;
		LA48: ;
		{
			result = (*(*cl).C).Semexpr((*cl).C, n, 0);
		}
		LA46: ;
	}
	break;
	default:
	{
		NI length;
		length = sonslen_189181(n_273570);
		{
			NI i_274457;
			NI HEX3Atmp_274491;
			NI res_274493;
			if (!(0 < length)) goto LA54;
			newsons_189197(result, length);
			i_274457 = 0;
			HEX3Atmp_274491 = 0;
			HEX3Atmp_274491 = (NI32)(length - 1);
			res_274493 = 0;
			while (1) {
				if (!(res_274493 <= HEX3Atmp_274491)) goto LA56;
				i_274457 = res_274493;
				asgnRefNoCycle((void**) &(*result).kindU.S6.Sons->data[i_274457], replacetypevarsn_273566(cl, (*n_273570).kindU.S6.Sons->data[i_274457]));
				res_274493 += 1;
			} LA56: ;
		}
		LA54: ;
	}
	break;
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(tsym188833*, replacetypevarss_273560)(trepltypevars273546* cl, tsym188833* s) {
	tsym188833* result;
	TNimObject* LOC5;
	result = 0;
	{
		if (!(s == NIM_NIL)) goto LA3;
		result = NIM_NIL;
		goto BeforeRet;
	}
	LA3: ;
	LOC5 = 0;
	LOC5 = idtableget_197137((*cl).Symmap, &s->Sup);
	result = ((tsym188833*) (LOC5));
	{
		if (!(result == NIM_NIL)) goto LA8;
		result = copysym_189147(s, NIM_FALSE);
		(*result).Flags |=((NI32)(1)<<((((NU8) 2))%(sizeof(NI32)*8)));
		idtableput_197147(&(*cl).Symmap, &s->Sup, &result->Sup.Sup);
		asgnRefNoCycle((void**) &(*result).Owner, (*s).Owner);
		asgnRefNoCycle((void**) &(*result).Typ, replacetypevarst_273584(cl, (*s).Typ));
		asgnRefNoCycle((void**) &(*result).Ast, replacetypevarsn_273566(cl, (*s).Ast));
	}
	LA8: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(tnode188803*, preparenode_273603)(trepltypevars273546* cl, tnode188803* n) {
	tnode188803* result;
	ttype188837* t;
	NIM_BOOL iscall;
	NI i_273725;
	NI HEX3Atmp_273726;
	NI LOC13;
	NI res_273728;
	result = 0;
	t = replacetypevarst_273584(cl, (*n).Typ);
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		LOC3 = 0;
		LOC4 = 0;
		LOC4 = !((t == NIM_NIL));
		if (!(LOC4)) goto LA5;
		LOC4 = ((*t).Kind == ((NU8) 59));
		LA5: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA6;
		LOC3 = !(((*t).N == NIM_NIL));
		LA6: ;
		if (!LOC3) goto LA7;
		result = (*t).N;
		goto BeforeRet;
	}
	LA7: ;
	result = copynode_189233(n);
	asgnRefNoCycle((void**) &(*result).Typ, t);
	{
		if (!((*result).Kind == ((NU8) 3))) goto LA11;
		asgnRefNoCycle((void**) &(*result).kindU.S4.Sym, replacetypevarss_273560(cl, (*n).kindU.S4.Sym));
	}
	LA11: ;
	iscall = ((*result).Kind == ((NU8) 27) || (*result).Kind == ((NU8) 29) || (*result).Kind == ((NU8) 30) || (*result).Kind == ((NU8) 31) || (*result).Kind == ((NU8) 26) || (*result).Kind == ((NU8) 28) || (*result).Kind == ((NU8) 32));
	i_273725 = 0;
	HEX3Atmp_273726 = 0;
	LOC13 = 0;
	LOC13 = safelen_189320(n);
	HEX3Atmp_273726 = LOC13 - 1;
	res_273728 = 0;
	while (1) {
		if (!(res_273728 <= HEX3Atmp_273726)) goto LA14;
		i_273725 = res_273728;
		{
			NIM_BOOL LOC17;
			tnode188803* LOC21;
			LOC17 = 0;
			LOC17 = iscall;
			if (!(LOC17)) goto LA18;
			LOC17 = (i_273725 == 0);
			LA18: ;
			if (!LOC17) goto LA19;
			LOC21 = 0;
			LOC21 = HEX5BHEX5D_189694(n, i_273725);
			add_189390(result, LOC21);
		}
		goto LA15;
		LA19: ;
		{
			tnode188803* LOC23;
			tnode188803* LOC24;
			LOC23 = 0;
			LOC23 = HEX5BHEX5D_189694(n, i_273725);
			LOC24 = 0;
			LOC24 = preparenode_273603(cl, LOC23);
			add_189390(result, LOC24);
		}
		LA15: ;
		res_273728 += 1;
	} LA14: ;
	BeforeRet: ;
	return result;
}

static N_INLINE(ttype188837*, skipintlit_242424)(ttype188837* t) {
	ttype188837* result;
	result = 0;
	{
		if (!!(((*t).N == NIM_NIL))) goto LA3;
		{
			if (!((*t).Kind == ((NU8) 31) || (*t).Kind == ((NU8) 36))) goto LA7;
			result = getsystype_242024((*t).Kind);
			goto BeforeRet;
		}
		LA7: ;
	}
	LA3: ;
	result = t;
	BeforeRet: ;
	return result;
}

static N_INLINE(NI, len_189264)(tnode188803* n) {
	NI result;
	result = 0;
	{
		if (!(*n).kindU.S6.Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).kindU.S6.Sons->Sup.len;
	}
	LA1: ;
	return result;
}

N_NIMCALL(void, propagatefieldflags_275421)(ttype188837* t, tnode188803* n) {
	{
		NimStringDesc* LOC5;
		if (!!(!(((*n).Kind == ((NU8) 138))))) goto LA3;
		LOC5 = 0;
		LOC5 = HEX24_165714(TMP2539);
		internalerror_165606(LOC5);
	}
	LA3: ;
	switch ((*n).Kind) {
	case ((NU8) 3):
	{
		propagatetoowner_192852(t, (*(*n).kindU.S4.Sym).Typ);
	}
	break;
	case ((NU8) 136):
	case ((NU8) 137):
	case ((NU8) 85):
	case ((NU8) 88):
	{
		tnode188803* son_275464;
		NI i_275466;
		NI HEX3Atmp_275468;
		NI LOC8;
		NI res_275470;
		son_275464 = 0;
		i_275466 = 0;
		HEX3Atmp_275468 = 0;
		LOC8 = 0;
		LOC8 = len_189264(n);
		HEX3Atmp_275468 = LOC8 - 1;
		res_275470 = 0;
		while (1) {
			if (!(res_275470 <= HEX3Atmp_275468)) goto LA9;
			i_275466 = res_275470;
			son_275464 = (*n).kindU.S6.Sons->data[i_275466];
			propagatefieldflags_275421(t, son_275464);
			res_275470 += 1;
		} LA9: ;
	}
	break;
	default:
	{
	}
	break;
	}
}

N_NIMCALL(void, erasevoidparams_275102)(ttype188837* t) {
	NI i_275152;
	NI HEX3Atmp_275289;
	NI LOC7;
	NI res_275291;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = !(((*t).Sons->data[0] == NIM_NIL));
		if (!(LOC3)) goto LA4;
		LOC3 = ((*(*t).Sons->data[0]).Kind == ((NU8) 3));
		LA4: ;
		if (!LOC3) goto LA5;
		asgnRefNoCycle((void**) &(*t).Sons->data[0], NIM_NIL);
	}
	LA5: ;
	i_275152 = 0;
	HEX3Atmp_275289 = 0;
	LOC7 = 0;
	LOC7 = sonslen_189185(t);
	HEX3Atmp_275289 = LOC7 - 1;
	res_275291 = 1;
	while (1) {
		if (!(res_275291 <= HEX3Atmp_275289)) goto LA8;
		i_275152 = res_275291;
		{
			NI pos;
			NI j_275184;
			NI HEX3Atmp_275284;
			NI HEX3Atmp_275285;
			NI LOC13;
			NI res_275287;
			if (!((*(*t).Sons->data[i_275152]).Kind == ((NU8) 3))) goto LA11;
			pos = i_275152;
			j_275184 = 0;
			HEX3Atmp_275284 = 0;
			HEX3Atmp_275285 = 0;
			HEX3Atmp_275284 = (NI32)(i_275152 + 1);
			LOC13 = 0;
			LOC13 = sonslen_189185(t);
			HEX3Atmp_275285 = LOC13 - 1;
			res_275287 = HEX3Atmp_275284;
			while (1) {
				if (!(res_275287 <= HEX3Atmp_275285)) goto LA14;
				j_275184 = res_275287;
				{
					if (!!(((*(*t).Sons->data[j_275184]).Kind == ((NU8) 3)))) goto LA17;
					asgnRefNoCycle((void**) &(*t).Sons->data[pos], (*t).Sons->data[j_275184]);
					asgnRefNoCycle((void**) &(*(*t).N).kindU.S6.Sons->data[pos], (*(*t).N).kindU.S6.Sons->data[j_275184]);
					pos += 1;
				}
				LA17: ;
				res_275287 += 1;
			} LA14: ;
			(*t).Sons = (ttypeseq188835*) setLengthSeq(&((*t).Sons)->Sup, sizeof(ttype188837*), pos);
			(*(*t).N).kindU.S6.Sons = (tnodeseq188797*) setLengthSeq(&((*(*t).N).kindU.S6.Sons)->Sup, sizeof(tnode188803*), pos);
			goto BeforeRet;
		}
		LA11: ;
		res_275291 += 1;
	} LA8: ;
	BeforeRet: ;
}

N_NIMCALL(void, skipintliteralparams_275297)(ttype188837* t) {
	NI i_275321;
	NI HEX3Atmp_275413;
	NI LOC1;
	NI res_275415;
	i_275321 = 0;
	HEX3Atmp_275413 = 0;
	LOC1 = 0;
	LOC1 = sonslen_189185(t);
	HEX3Atmp_275413 = LOC1 - 1;
	res_275415 = 0;
	while (1) {
		if (!(res_275415 <= HEX3Atmp_275413)) goto LA2;
		i_275321 = res_275415;
		{
			ttype188837* p;
			ttype188837* skipped;
			p = (*t).Sons->data[i_275321];
			{
				if (!(p == NIM_NIL)) goto LA6;
				goto LA3;
			}
			LA6: ;
			skipped = skipintlit_242424(p);
			{
				if (!!((skipped == p))) goto LA10;
				asgnRefNoCycle((void**) &(*t).Sons->data[i_275321], skipped);
				{
					if (!(0 < i_275321)) goto LA14;
					asgnRefNoCycle((void**) &(*(*(*(*t).N).kindU.S6.Sons->data[i_275321]).kindU.S4.Sym).Typ, skipped);
				}
				LA14: ;
			}
			LA10: ;
		} LA3: ;
		res_275415 += 1;
	} LA2: ;
	{
		NIM_BOOL LOC18;
		LOC18 = 0;
		LOC18 = !(((*t).Sons->data[0] == NIM_NIL));
		if (!(LOC18)) goto LA19;
		LOC18 = ((*(*t).Sons->data[0]).Kind == ((NU8) 59));
		LA19: ;
		if (!LOC18) goto LA20;
		asgnRefNoCycle((void**) &(*t).Sons->data[0], base_223029((*t).Sons->data[0]));
	}
	LA20: ;
}

N_NIMCALL(ttype188837*, replacetypevarstaux_273554)(trepltypevars273546* cl, ttype188837* t) {
	ttype188837* result;
	result = 0;
	result = t;
	{
		if (!(t == NIM_NIL)) goto LA3;
		goto BeforeRet;
	}
	LA3: ;
	{
		ttype188837* lookup;
		TNimObject* LOC9;
		if (!((*t).Kind == ((NU8) 12) || (*t).Kind == ((NU8) 49) || (*t).Kind >= ((NU8) 51) && (*t).Kind <= ((NU8) 59))) goto LA7;
		LOC9 = 0;
		LOC9 = idtableget_197137((*cl).Typemap, &t->Sup);
		lookup = ((ttype188837*) (LOC9));
		{
			if (!!((lookup == NIM_NIL))) goto LA12;
			result = lookup;
			goto BeforeRet;
		}
		LA12: ;
	}
	LA7: ;
	switch ((*t).Kind) {
	case ((NU8) 9):
	{
		result = handlegenericinvokation_274647(cl, t);
	}
	break;
	case ((NU8) 10):
	{
		NimStringDesc* LOC16;
		LOC16 = 0;
		LOC16 = typetostring_223020(t, ((NU8) 0));
		localerror_165571((*cl).Info, ((NU16) 124), LOC16);
		result = t;
	}
	break;
	case ((NU8) 60):
	{
		tnode188803* n;
		{
			if (!(*cl).Allowmetatypes) goto LA20;
			goto BeforeRet;
		}
		LA20: ;
		n = preparenode_273603(cl, (*t).N);
		n = (*(*cl).C).Semconstexpr((*cl).C, n);
		{
			if (!((*(*n).Typ).Kind == ((NU8) 8))) goto LA24;
			result = skiptypes_192793((*n).Typ, 256);
		}
		goto LA22;
		LA24: ;
		{
			{
				TY350968 LOC31;
				if (!!(((*(*n).Typ).Kind == ((NU8) 59)))) goto LA29;
				result = newtypes_250180(((NU8) 59), (*cl).C);
				if ((*result).Sons) nimGCunrefNoCycle((*result).Sons);
				(*result).Sons = (ttypeseq188835*) newSeqRC1((&NTI188835), 1);
				memset((void*)LOC31, 0, sizeof(LOC31));
				LOC31[0] = (*n).Typ;
				asgnRefNoCycle((void**) &(*result).Sons->data[0], LOC31[0]);
				asgnRefNoCycle((void**) &(*result).N, n);
			}
			goto LA27;
			LA29: ;
			{
				result = (*n).Typ;
			}
			LA27: ;
		}
		LA22: ;
	}
	break;
	case ((NU8) 31):
	{
		result = skipintlit_242424(t);
	}
	break;
	case ((NU8) 8):
	{
		ttype188837* lookup;
		TNimObject* LOC35;
		LOC35 = 0;
		LOC35 = idtableget_197137((*cl).Typemap, &t->Sup);
		lookup = ((ttype188837*) (LOC35));
		{
			if (!!((lookup == NIM_NIL))) goto LA38;
			result = lookup;
			{
				if (!(((*t).Flags &(1<<((((NU8) 9))&31)))!=0)) goto LA42;
				result = base_223029(result);
			}
			LA42: ;
		}
		goto LA36;
		LA38: ;
		{
			ttype188837* LOC47;
			if (!!(((*(*t).Sons->data[0]).Kind == ((NU8) 0)))) goto LA45;
			LOC47 = 0;
			LOC47 = replacetypevarst_273584(cl, (*t).Sons->data[0]);
			result = maketypedesc_250627((*cl).C, LOC47);
		}
		goto LA36;
		LA45: ;
		LA36: ;
	}
	break;
	case ((NU8) 52):
	{
		result = t;
	}
	break;
	case ((NU8) 11):
	{
		NI i_275645;
		NI HEX3Atmp_275702;
		NI LOC50;
		NI res_275704;
		ttype188837* LOC52;
		result = instcopytype_274604(cl, t);
		i_275645 = 0;
		HEX3Atmp_275702 = 0;
		LOC50 = 0;
		LOC50 = sonslen_189185(result);
		HEX3Atmp_275702 = LOC50 - 1;
		res_275704 = 1;
		while (1) {
			if (!(res_275704 <= HEX3Atmp_275702)) goto LA51;
			i_275645 = res_275704;
			asgnRefNoCycle((void**) &(*result).Sons->data[i_275645], replacetypevarst_273584(cl, (*result).Sons->data[i_275645]));
			res_275704 += 1;
		} LA51: ;
		LOC52 = 0;
		LOC52 = lastson_189193(result);
		propagatetoowner_192852(result, LOC52);
	}
	break;
	default:
	{
		{
			NIM_BOOL LOC56;
			NI i_275658;
			NI HEX3Atmp_275706;
			NI LOC59;
			NI res_275708;
			LOC56 = 0;
			LOC56 = containsgenerictype_232717(t);
			if (!LOC56) goto LA57;
			result = instcopytype_274604(cl, t);
			(*result).Size = -1;
			i_275658 = 0;
			HEX3Atmp_275706 = 0;
			LOC59 = 0;
			LOC59 = sonslen_189185(result);
			HEX3Atmp_275706 = (NI32)(LOC59 - 1);
			res_275708 = 0;
			while (1) {
				if (!(res_275708 <= HEX3Atmp_275706)) goto LA60;
				i_275658 = res_275708;
				{
					if (!!(((*result).Sons->data[i_275658] == NIM_NIL))) goto LA63;
					asgnRefNoCycle((void**) &(*result).Sons->data[i_275658], replacetypevarst_273584(cl, (*result).Sons->data[i_275658]));
					propagatetoowner_192852(result, (*result).Sons->data[i_275658]);
				}
				LA63: ;
				res_275708 += 1;
			} LA60: ;
			asgnRefNoCycle((void**) &(*result).N, replacetypevarsn_273566(cl, (*result).N));
			switch ((*result).Kind) {
			case ((NU8) 16):
			{
				ttype188837* idx;
				idx = (*result).Sons->data[0];
				{
					NimStringDesc* LOC70;
					if (!!(!(((*idx).Kind == ((NU8) 59))))) goto LA68;
					LOC70 = 0;
					LOC70 = HEX24_165714(TMP2538);
					internalerror_165606(LOC70);
				}
				LA68: ;
			}
			break;
			case ((NU8) 17):
			case ((NU8) 18):
			{
				propagatefieldflags_275421(result, (*result).N);
			}
			break;
			case ((NU8) 25):
			{
				erasevoidparams_275102(result);
				skipintliteralparams_275297(result);
			}
			break;
			default:
			{
			}
			break;
			}
		}
		LA57: ;
	}
	break;
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(ttype188837*, replacetypevarst_273584)(trepltypevars273546* cl, ttype188837* t) {
	ttype188837* result;
	result = 0;
	result = replacetypevarstaux_273554(cl, t);
	return result;
}

N_NIMCALL(ttype188837*, generatetypeinstance_275735)(tcontext250019* p, tidtable188849 pt, tlineinfo163527 info, ttype188837* t) {
	ttype188837* result;
	trepltypevars273546 cl;
	result = 0;
	chckNil((void*)&cl);
	memset((void*)&cl, 0, sizeof(cl));
	inittypevars_275714(p, pt, info, &cl);
	pushinfocontext_164697(info);
	result = replacetypevarst_273584(&cl, t);
	popinfocontext_164720();
	return result;
}

N_NIMCALL(tnode188803*, replacetypesinbody_275725)(tcontext250019* p, tidtable188849 pt, tnode188803* n) {
	tnode188803* result;
	trepltypevars273546 cl;
	result = 0;
	chckNil((void*)&cl);
	memset((void*)&cl, 0, sizeof(cl));
	inittypevars_275714(p, pt, (*n).Info, &cl);
	pushinfocontext_164697((*n).Info);
	result = replacetypevarsn_273566(&cl, n);
	popinfocontext_164720();
	return result;
}

N_NIMCALL(NIM_BOOL, hasgenericarguments_273821)(tnode188803* n) {
	NIM_BOOL result;
	result = 0;
	{
		NIM_BOOL LOC5;
		NIM_BOOL LOC7;
		if (!((*n).Kind == ((NU8) 3))) goto LA3;
		LOC5 = 0;
		LOC5 = ((*(*n).kindU.S4.Sym).Kind == ((NU8) 4));
		if (LOC5) goto LA6;
		LOC7 = 0;
		LOC7 = ((*(*n).kindU.S4.Sym).Kind == ((NU8) 7));
		if (!(LOC7)) goto LA8;
		LOC7 = !((((*(*(*n).kindU.S4.Sym).Typ).Flags & 25165824) == 0));
		LA8: ;
		LOC5 = LOC7;
		LA6: ;
		result = LOC5;
		goto BeforeRet;
	}
	goto LA1;
	LA3: ;
	{
		NI i_273952;
		NI HEX3Atmp_273967;
		NI LOC10;
		NI res_273969;
		i_273952 = 0;
		HEX3Atmp_273967 = 0;
		LOC10 = 0;
		LOC10 = safelen_189320(n);
		HEX3Atmp_273967 = LOC10 - 1;
		res_273969 = 0;
		while (1) {
			if (!(res_273969 <= HEX3Atmp_273967)) goto LA11;
			i_273952 = res_273969;
			{
				NIM_BOOL LOC14;
				LOC14 = 0;
				LOC14 = hasgenericarguments_273821((*n).kindU.S6.Sons->data[i_273952]);
				if (!LOC14) goto LA15;
				result = NIM_TRUE;
				goto BeforeRet;
			}
			LA15: ;
			res_273969 += 1;
		} LA11: ;
		result = NIM_FALSE;
		goto BeforeRet;
	}
	LA1: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, checkconstructedtype_273140)(tlineinfo163527 info, ttype188837* typ) {
	ttype188837* t;
	t = skiptypes_192793(typ, 8192);
	{
		if (!((*t).Kind == ((NU8) 51) || (*t).Kind == ((NU8) 54) || (*t).Kind == ((NU8) 52) || (*t).Kind == ((NU8) 53) || (*t).Kind == ((NU8) 55) || (*t).Kind == ((NU8) 56) || (*t).Kind == ((NU8) 57) || (*t).Kind == ((NU8) 58))) goto LA3;
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC6;
		ttype188837* LOC8;
		LOC6 = 0;
		LOC6 = (((*t).Flags &(1<<((((NU8) 4))&31)))!=0);
		if (!(LOC6)) goto LA7;
		LOC8 = 0;
		LOC8 = skiptypes_192793(t, IL64(211106232576256));
		LOC6 = !(((*LOC8).Kind == ((NU8) 17)));
		LA7: ;
		if (!LOC6) goto LA9;
		localerror_165571(info, ((NU16) 162), ((NimStringDesc*) &TMP2532));
	}
	goto LA1;
	LA9: ;
	{
		NIM_BOOL LOC12;
		LOC12 = 0;
		LOC12 = ((*t).Kind == ((NU8) 23));
		if (!(LOC12)) goto LA13;
		LOC12 = ((*(*t).Sons->data[0]).Kind == ((NU8) 23));
		LA13: ;
		if (!LOC12) goto LA14;
		localerror_165571(info, ((NU16) 197), ((NimStringDesc*) &TMP2533));
	}
	goto LA1;
	LA14: ;
	{
		NI64 LOC17;
		NimStringDesc* LOC20;
		LOC17 = 0;
		LOC17 = computesize_223154(t);
		if (!(LOC17 == -2)) goto LA18;
		LOC20 = 0;
		LOC20 = typetostring_223020(t, ((NU8) 0));
		localerror_165571(info, ((NU16) 123), LOC20);
	}
	goto LA1;
	LA18: ;
	{
		sharedptrcheck_273010(info, t);
	}
	LA1: ;
}
N_NOINLINE(void, semtypinstInit)(void) {
}

N_NOINLINE(void, semtypinstDatInit)(void) {
}

