/* Generated by Nim Compiler v0.12.0 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32

#include "nimbase.h"
#include <string.h>
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Tnode227809 Tnode227809;
typedef struct Tcontext282023 Tcontext282023;
typedef struct Ttype227847 Ttype227847;
typedef struct Tlineinfo192352 Tlineinfo192352;
typedef struct Tsym227841 Tsym227841;
typedef struct Tident200021 Tident200021;
typedef struct Tnodeseq227803 Tnodeseq227803;
typedef struct Tidobj200015 Tidobj200015;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Ttypeseq227843 Ttypeseq227843;
typedef struct Tloc227823 Tloc227823;
typedef struct Ropeobj178009 Ropeobj178009;
typedef struct Cell48946 Cell48946;
typedef struct Cellseq48962 Cellseq48962;
typedef struct Gcheap51018 Gcheap51018;
typedef struct Gcstack51016 Gcstack51016;
typedef struct Cellset48958 Cellset48958;
typedef struct Pagedesc48954 Pagedesc48954;
typedef struct Memregion30890 Memregion30890;
typedef struct Smallchunk30842 Smallchunk30842;
typedef struct Llchunk30884 Llchunk30884;
typedef struct Bigchunk30844 Bigchunk30844;
typedef struct Intset30817 Intset30817;
typedef struct Trunk30813 Trunk30813;
typedef struct Avlnode30888 Avlnode30888;
typedef struct Gcstat51014 Gcstat51014;
typedef struct Tscope227835 Tscope227835;
typedef struct Tpasscontext279005 Tpasscontext279005;
typedef struct Tproccon282011 Tproccon282011;
typedef struct Tsymseq227811 Tsymseq227811;
typedef struct Intset224056 Intset224056;
typedef struct Trunk224052 Trunk224052;
typedef struct Trunkseq224054 Trunkseq224054;
typedef struct Tlinkedlist143028 Tlinkedlist143028;
typedef struct Tlistentry143022 Tlistentry143022;
typedef struct Tidtable227859 Tidtable227859;
typedef struct Tidpairseq227857 Tidpairseq227857;
typedef struct Tstrtable227813 Tstrtable227813;
typedef struct Tctx281048 Tctx281048;
typedef struct TY282143 TY282143;
typedef struct Ttabiter235119 Ttabiter235119;
typedef struct TY227944 TY227944;
typedef struct Tlib227827 Tlib227827;
typedef struct Basechunk30840 Basechunk30840;
typedef struct Freecell30832 Freecell30832;
typedef struct Tidpair227855 Tidpair227855;
typedef struct TY281254 TY281254;
typedef struct TY193420 TY193420;
typedef struct PprocHEX3Aobjecttype281233 PprocHEX3Aobjecttype281233;
typedef struct TY281273 TY281273;
typedef struct Tinstantiationpair282013 Tinstantiationpair282013;
typedef struct Tinstantiation227831 Tinstantiation227831;
typedef struct TY281234 TY281234;
typedef struct TY281239 TY281239;
typedef struct TY281274 TY281274;
typedef struct Vmargs281042 Vmargs281042;
typedef struct TY227932 TY227932;
typedef struct Tblock281030 Tblock281030;
typedef struct TY281214 TY281214;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(Tnode227809*, Transformation456013) (Tcontext282023* c, Tnode227809* n);
struct  Tlineinfo192352  {
NI16 line;
NI16 col;
NI32 fileindex;
};
struct  Tnode227809  {
Ttype227847* typ;
Tlineinfo192352 info;
NU16 flags;
NU8 kind;
union{
struct {NI64 intval;
} S1;
struct {NF floatval;
} S2;
struct {NimStringDesc* strval;
} S3;
struct {Tsym227841* sym;
} S4;
struct {Tident200021* ident;
} S5;
struct {Tnodeseq227803* sons;
} S6;
} kindU;
NimStringDesc* comment;
};
typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3894) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3889 marker;
TY3894 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Tidobj200015  {
  TNimObject Sup;
NI id;
};
struct  Tloc227823  {
NU8 k;
NU8 s;
NU16 flags;
Ttype227847* t;
Ropeobj178009* r;
Ropeobj178009* heaproot;
};
struct  Ttype227847  {
  Tidobj200015 Sup;
NU8 kind;
NU8 callconv;
NU32 flags;
Ttypeseq227843* sons;
Tnode227809* n;
Tsym227841* owner;
Tsym227841* sym;
Tsym227841* destructor;
Tsym227841* deepcopy;
Tsym227841* assignment;
NI64 size;
NI16 align;
NI16 locklevel;
Tloc227823 loc;
};
struct  Cell48946  {
NI refcount;
TNimType* typ;
};
struct  Cellseq48962  {
NI len;
NI cap;
Cell48946** d;
};
struct  Cellset48958  {
NI counter;
NI max;
Pagedesc48954* head;
Pagedesc48954** data;
};
typedef Smallchunk30842* TY30905[512];
typedef Trunk30813* Trunkbuckets30815[256];
struct  Intset30817  {
Trunkbuckets30815 data;
};
struct  Memregion30890  {
NI minlargeobj;
NI maxlargeobj;
TY30905 freesmallchunks;
Llchunk30884* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk30844* freechunkslist;
Intset30817 chunkstarts;
Avlnode30888* root;
Avlnode30888* deleted;
Avlnode30888* last;
Avlnode30888* freeavlnodes;
};
struct  Gcstat51014  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap51018  {
Gcstack51016* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq48962 zct;
Cellseq48962 decstack;
Cellset48958 cycleroots;
Cellseq48962 tempstack;
NI recgclock;
Memregion30890 region;
Gcstat51014 stat;
};
struct  Tpasscontext279005  {
  TNimObject Sup;
NIM_BOOL fromcache;
};
struct  Intset224056  {
NI counter;
NI max;
Trunk224052* head;
Trunkseq224054* data;
};
struct  Tlinkedlist143028  {
Tlistentry143022* head;
Tlistentry143022* tail;
NI counter;
};
struct  Tidtable227859  {
NI counter;
Tidpairseq227857* data;
};
typedef N_NIMCALL_PTR(Tnode227809*, TY282074) (Tcontext282023* c, Tnode227809* n);
typedef N_NIMCALL_PTR(Tnode227809*, TY282079) (Tcontext282023* c, Tnode227809* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode227809*, TY282087) (Tcontext282023* c, Tnode227809* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode227809*, TY282095) (Tcontext282023* c, Tnode227809* n);
typedef N_NIMCALL_PTR(Tnode227809*, TY282100) (Tcontext282023* c, Tnode227809* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode227809*, TY282108) (Tcontext282023* c, Tnode227809* n);
typedef N_NIMCALL_PTR(Tnode227809*, TY282113) (Tcontext282023* c, Tnode227809* n, Tnode227809* norig, NU32 filter);
typedef N_NIMCALL_PTR(Ttype227847*, TY282120) (Tcontext282023* c, Tnode227809* n, Ttype227847* prev);
typedef struct {
N_NIMCALL_PTR(Tnode227809*, ClPrc) (Tcontext282023* c, Tidtable227859 pt, Tnode227809* n, void* ClEnv);
void* ClEnv;
} TY282126;
typedef struct {
N_NIMCALL_PTR(Tsym227841*, ClPrc) (Tcontext282023* c, Tsym227841* fn, Tidtable227859 pt, Tlineinfo192352 info, void* ClEnv);
void* ClEnv;
} TY282132;
struct  Tstrtable227813  {
NI counter;
Tsymseq227811* data;
};
typedef N_NIMCALL_PTR(Tsym227841*, TY282148) (Tcontext282023* c, Tsym227841* dc, Ttype227847* t, Tlineinfo192352 info, NU8 op);
struct  Tcontext282023  {
  Tpasscontext279005 Sup;
Tsym227841* module;
Tscope227835* currentscope;
Tscope227835* importtable;
Tscope227835* toplevelscope;
Tproccon282011* p;
Tsymseq227811* friendmodules;
NI instcounter;
Intset224056 ambiguoussymbols;
NI intypeclass;
NI ingenericcontext;
NI inunrolledcontext;
NI compilescontextid;
NI compilescontextidgenerator;
NI ingenericinst;
Tsymseq227811* converters;
Tsymseq227811* patterns;
Tlinkedlist143028 optionstack;
Tidtable227859 symmapping;
Tlinkedlist143028 libs;
TY282074 semconstexpr;
TY282079 semexpr;
TY282087 semtryexpr;
TY282095 semtryconstexpr;
TY282100 semoperand;
TY282108 semconstboolexpr;
TY282113 semoverloadedcall;
TY282120 semtypenode;
TY282126 seminferredlambda;
TY282132 semgenerateinstance;
Intset224056 includedfiles;
Tstrtable227813 userpragmas;
Tctx281048* evalcontext;
Intset224056 unknownidents;
TY282143* generics;
NI lastgenericidx;
NI hloloopdetector;
NI inparallelstmt;
TY282148 insttypeboundop;
};
struct  Tscope227835  {
NI depthlevel;
Tstrtable227813 symbols;
Tnodeseq227803* usingsyms;
Tscope227835* parent;
};
struct  Ttabiter235119  {
NI h;
};
struct  Tsym227841  {
  Tidobj200015 Sup;
NU8 kind;
union{
struct {Ttypeseq227843* typeinstcache;
Tscope227835* typscope;
} S1;
struct {TY227944* procinstcache;
Tsym227841* gcunsafetyreason;
} S2;
struct {TY227944* usedgenerics;
Tstrtable227813 tab;
} S3;
struct {Tsym227841* guard;
NI bitsize;
} S4;
} kindU;
NU8 magic;
Ttype227847* typ;
Tident200021* name;
Tlineinfo192352 info;
Tsym227841* owner;
NU32 flags;
Tnode227809* ast;
NU32 options;
NI position;
NI offset;
Tloc227823 loc;
Tlib227827* annex;
Tnode227809* constraint;
};
struct  Tident200021  {
  Tidobj200015 Sup;
NimStringDesc* s;
Tident200021* next;
NI h;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Ropeobj178009  {
  TNimObject Sup;
Ropeobj178009* left;
Ropeobj178009* right;
NI length;
NimStringDesc* data;
};
struct  Gcstack51016  {
Gcstack51016* prev;
Gcstack51016* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY30821[16];
struct  Pagedesc48954  {
Pagedesc48954* next;
NI key;
TY30821 bits;
};
struct  Basechunk30840  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk30842  {
  Basechunk30840 Sup;
Smallchunk30842* next;
Smallchunk30842* prev;
Freecell30832* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk30884  {
NI size;
NI acc;
Llchunk30884* next;
};
struct  Bigchunk30844  {
  Basechunk30840 Sup;
Bigchunk30844* next;
Bigchunk30844* prev;
NI align;
NF data;
};
struct  Trunk30813  {
Trunk30813* next;
NI key;
TY30821 bits;
};
typedef Avlnode30888* TY30895[2];
struct  Avlnode30888  {
TY30895 link;
NI key;
NI upperbound;
NI level;
};
struct  Tproccon282011  {
Tsym227841* owner;
Tsym227841* resultsym;
NI nestedloopcounter;
NI nestedblockcounter;
NI intrystmt;
Tproccon282011* next;
NIM_BOOL wasforwarded;
Tnode227809* bracketexpr;
};
struct  Trunk224052  {
Trunk224052* next;
NI key;
TY30821 bits;
};
struct  Tlistentry143022  {
  TNimObject Sup;
Tlistentry143022* prev;
Tlistentry143022* next;
};
struct  Tidpair227855  {
Tidobj200015* key;
TNimObject* val;
};
struct  Tctx281048  {
  Tpasscontext279005 Sup;
TY281254* code;
TY193420* debug;
Tnode227809* globals;
Tnode227809* constants;
Ttypeseq227843* types;
Tnode227809* currentexceptiona;
Tnode227809* currentexceptionb;
NI exceptioninstr;
PprocHEX3Aobjecttype281233* prc;
Tsym227841* module;
Tnode227809* callsite;
NU8 mode;
NU8 features;
NIM_BOOL traceactive;
NI loopiterations;
Tlineinfo192352 comesfromheuristic;
TY281273* callbacks;
NimStringDesc* errorflag;
};
struct  Tinstantiationpair282013  {
Tsym227841* genericsym;
Tinstantiation227831* inst;
};
struct  Tlib227827  {
  Tlistentry143022 Sup;
NU8 kind;
NIM_BOOL generated;
NIM_BOOL isoverriden;
Ropeobj178009* name;
Tnode227809* path;
};
struct  Freecell30832  {
Freecell30832* next;
NI zerofield;
};
struct TY281239 {
NIM_BOOL Field0;
NU8 Field1;
};
typedef TY281239 TY281242[256];
struct  PprocHEX3Aobjecttype281233  {
TY281234* blocks;
Tsym227841* sym;
TY281242 slots;
NI maxslots;
};
typedef struct {
N_NIMCALL_PTR(void, ClPrc) (Vmargs281042* args, void* ClEnv);
void* ClEnv;
} Vmcallback281044;
struct TY281274 {
NimStringDesc* Field0;
Vmcallback281044 Field1;
};
struct  Tinstantiation227831  {
Tsym227841* sym;
Ttypeseq227843* concretetypes;
TY227932* usedby;
NI compilesid;
};
struct  Tblock281030  {
Tsym227841* label;
TY281214* fixups;
};
struct  Vmargs281042  {
NI ra;
NI rb;
NI rc;
void* slots;
Tnode227809* currentexception;
};
struct Tnodeseq227803 {
  TGenericSeq Sup;
  Tnode227809* data[SEQ_DECL_SIZE];
};
struct Ttypeseq227843 {
  TGenericSeq Sup;
  Ttype227847* data[SEQ_DECL_SIZE];
};
struct Tsymseq227811 {
  TGenericSeq Sup;
  Tsym227841* data[SEQ_DECL_SIZE];
};
struct Trunkseq224054 {
  TGenericSeq Sup;
  Trunk224052* data[SEQ_DECL_SIZE];
};
struct Tidpairseq227857 {
  TGenericSeq Sup;
  Tidpair227855 data[SEQ_DECL_SIZE];
};
struct TY282143 {
  TGenericSeq Sup;
  Tinstantiationpair282013 data[SEQ_DECL_SIZE];
};
struct TY227944 {
  TGenericSeq Sup;
  Tinstantiation227831* data[SEQ_DECL_SIZE];
};
struct TY281254 {
  TGenericSeq Sup;
  NU32 data[SEQ_DECL_SIZE];
};
struct TY193420 {
  TGenericSeq Sup;
  Tlineinfo192352 data[SEQ_DECL_SIZE];
};
struct TY281273 {
  TGenericSeq Sup;
  TY281274 data[SEQ_DECL_SIZE];
};
struct TY281234 {
  TGenericSeq Sup;
  Tblock281030 data[SEQ_DECL_SIZE];
};
struct TY227932 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
struct TY281214 {
  TGenericSeq Sup;
  NI data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, registerplugin_456124)(NimStringDesc* package, NimStringDesc* module, NimStringDesc* fn, Transformation456013 t);
N_NIMCALL(Tnode227809*, semlocals_457020)(Tcontext282023* c, Tnode227809* n);
N_NIMCALL(Ttype227847*, newtypes_282221)(NU8 kind, Tcontext282023* c);
N_NIMCALL(Tnode227809*, newnodeit_229807)(NU8 kind, Tlineinfo192352 info, Ttype227847* typ);
N_NIMCALL(Tnode227809*, newnodei_229351)(NU8 kind, Tlineinfo192352 info);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Cell48946*, usrtocell_52646)(void* usr);
static N_INLINE(void, rtladdzct_54204)(Cell48946* c);
N_NOINLINE(void, addzct_52617)(Cellseq48962* s, Cell48946* c);
N_NIMCALL(Tsym227841*, inittabiter_235124)(Ttabiter235119* ti, Tstrtable227813 tab);
N_NIMCALL(Ttype227847*, skiptypes_231167)(Ttype227847* t, NU64 kinds);
N_NIMCALL(Tsym227841*, newsym_228656)(NU8 symkind, Tident200021* name, Tsym227841* owner, Tlineinfo192352 info);
N_NIMCALL(Tsym227841*, getcurrowner_282258)(void);
N_NIMCALL(void, addson_229819)(Tnode227809* father, Tnode227809* son);
N_NIMCALL(Tnode227809*, newsymnode_229325)(Tsym227841* sym);
N_NIMCALL(void, addsonskipintlit_276729)(Ttype227847* father, Ttype227847* son);
N_NIMCALL(Tnode227809*, newsymnode_229338)(Tsym227841* sym, Tlineinfo192352 info);
static N_INLINE(Tnode227809*, newderef_404024)(Tnode227809* n);
N_NIMCALL(void, add_228165)(Tnode227809* father, Tnode227809* son);
N_NIMCALL(Tsym227841*, nextiter_235132)(Ttabiter235119* ti, Tstrtable227813 tab);
STRING_LITERAL(TMP1047, "stdlib", 6);
STRING_LITERAL(TMP1048, "system", 6);
STRING_LITERAL(TMP1049, "locals", 6);
extern Gcheap51018 gch_51059;

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

static N_INLINE(void, rtladdzct_54204)(Cell48946* c) {
	addzct_52617((&gch_51059.zct), c);
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Cell48946* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_52646(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell48946* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_52646((*dest));
		{
			(*c).refcount -= ((NI) 8);
			if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA11;
			rtladdzct_54204(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

static N_INLINE(Tnode227809*, newderef_404024)(Tnode227809* n) {
	Tnode227809* result;
	result = 0;
	result = newnodeit_229807(((NU8) 65), (*n).info, (*(*n).typ).sons->data[((NI) 0)]);
	addson_229819(result, n);
	return result;
}

N_NIMCALL(Tnode227809*, semlocals_457020)(Tcontext282023* c, Tnode227809* n) {
	Tnode227809* result;
	NI counter;
	Ttype227847* tupletype;
	result = 0;
	counter = ((NI) 0);
	tupletype = newtypes_282221(((NU8) 18), c);
	result = newnodeit_229807(((NU8) 37), (*n).info, tupletype);
	asgnRefNoCycle((void**) (&(*tupletype).n), newnodei_229351(((NU8) 138), (*n).info));
	{
		Tscope227835* scope_457027;
		Tscope227835* HEX3Atmp_457100;
		Tscope227835* current_457103;
		scope_457027 = 0;
		HEX3Atmp_457100 = 0;
		HEX3Atmp_457100 = (*c).currentscope;
		current_457103 = HEX3Atmp_457100;
		{
			while (1) {
				if (!!((current_457103 == NIM_NIL))) goto LA3;
				scope_457027 = current_457103;
				{
					if (!(scope_457027 == (*c).toplevelscope)) goto LA6;
					goto LA1;
				}
				LA6: ;
				{
					Tsym227841* it_457039;
					Tstrtable227813 HEX3Atmp_457094;
					Ttabiter235119 it_457097;
					Tsym227841* s_457099;
					it_457039 = 0;
					memset((void*)(&HEX3Atmp_457094), 0, sizeof(HEX3Atmp_457094));
					HEX3Atmp_457094.counter = (*scope_457027).symbols.counter;
					HEX3Atmp_457094.data = (*scope_457027).symbols.data;
					memset((void*)(&it_457097), 0, sizeof(it_457097));
					s_457099 = inittabiter_235124((&it_457097), HEX3Atmp_457094);
					{
						while (1) {
							if (!!((s_457099 == NIM_NIL))) goto LA10;
							it_457039 = s_457099;
							{
								NIM_BOOL LOC13;
								Ttype227847* LOC15;
								Tsym227841* field;
								Tsym227841* LOC18;
								Tnode227809* LOC19;
								Tnode227809* a;
								LOC13 = 0;
								LOC13 = ((2099976 &(1<<(((*it_457039).kind)&31)))!=0);
								if (!(LOC13)) goto LA14;
								LOC15 = 0;
								LOC15 = skiptypes_231167((*it_457039).typ, 8390656);
								LOC13 = !(((*LOC15).kind == ((NU8) 48) || (*LOC15).kind == ((NU8) 27) || (*LOC15).kind == ((NU8) 8) || (*LOC15).kind == ((NU8) 59) || (*LOC15).kind == ((NU8) 6) || (*LOC15).kind == ((NU8) 7) || (*LOC15).kind == ((NU8) 3)));
								LA14: ;
								if (!LOC13) goto LA16;
								LOC18 = 0;
								LOC18 = getcurrowner_282258();
								field = newsym_228656(((NU8) 19), (*it_457039).name, LOC18, (*n).info);
								asgnRefNoCycle((void**) (&(*field).typ), skiptypes_231167((*it_457039).typ, 8390656));
								(*field).position = counter;
								counter += ((NI) 1);
								LOC19 = 0;
								LOC19 = newsymnode_229325(field);
								addson_229819((*tupletype).n, LOC19);
								addsonskipintlit_276729(tupletype, (*field).typ);
								a = newsymnode_229338(it_457039, (*result).info);
								{
									Ttype227847* LOC22;
									LOC22 = 0;
									LOC22 = skiptypes_231167((*it_457039).typ, 2048);
									if (!((*LOC22).kind == ((NU8) 23))) goto LA23;
									a = newderef_404024(a);
								}
								LA23: ;
								add_228165(result, a);
							}
							LA16: ;
							s_457099 = nextiter_235132((&it_457097), HEX3Atmp_457094);
						} LA10: ;
					}
				}
				current_457103 = (*current_457103).parent;
			} LA3: ;
		}
	} LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_localsInit000)(void) {
	registerplugin_456124(((NimStringDesc*) &TMP1047), ((NimStringDesc*) &TMP1048), ((NimStringDesc*) &TMP1049), semlocals_457020);
}

NIM_EXTERNC N_NOINLINE(void, compiler_localsDatInit000)(void) {
}

