/* 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 Tnode224809 Tnode224809;
typedef struct Tcontext279023 Tcontext279023;
typedef struct Ttype224847 Ttype224847;
typedef struct Tlineinfo189352 Tlineinfo189352;
typedef struct Tsym224841 Tsym224841;
typedef struct Tident197021 Tident197021;
typedef struct Tnodeseq224803 Tnodeseq224803;
typedef struct Tidobj197015 Tidobj197015;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Ttypeseq224843 Ttypeseq224843;
typedef struct Tloc224823 Tloc224823;
typedef struct Ropeobj175009 Ropeobj175009;
typedef struct Cell48947 Cell48947;
typedef struct Cellseq48963 Cellseq48963;
typedef struct Gcheap51018 Gcheap51018;
typedef struct Gcstack51016 Gcstack51016;
typedef struct Cellset48959 Cellset48959;
typedef struct Pagedesc48955 Pagedesc48955;
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 Tscope224835 Tscope224835;
typedef struct Tpasscontext276005 Tpasscontext276005;
typedef struct Tproccon279011 Tproccon279011;
typedef struct Tsymseq224811 Tsymseq224811;
typedef struct Intset221056 Intset221056;
typedef struct Trunk221052 Trunk221052;
typedef struct Trunkseq221054 Trunkseq221054;
typedef struct Tlinkedlist140028 Tlinkedlist140028;
typedef struct Tlistentry140022 Tlistentry140022;
typedef struct Tidtable224859 Tidtable224859;
typedef struct Tidpairseq224857 Tidpairseq224857;
typedef struct Tstrtable224813 Tstrtable224813;
typedef struct Tctx278048 Tctx278048;
typedef struct TY279143 TY279143;
typedef struct Ttabiter232119 Ttabiter232119;
typedef struct TY224944 TY224944;
typedef struct Tlib224827 Tlib224827;
typedef struct Basechunk30840 Basechunk30840;
typedef struct Freecell30832 Freecell30832;
typedef struct Tidpair224855 Tidpair224855;
typedef struct TY278254 TY278254;
typedef struct TY190420 TY190420;
typedef struct PprocHEX3Aobjecttype278233 PprocHEX3Aobjecttype278233;
typedef struct TY278273 TY278273;
typedef struct Tinstantiationpair279013 Tinstantiationpair279013;
typedef struct Tinstantiation224831 Tinstantiation224831;
typedef struct TY278234 TY278234;
typedef struct TY278239 TY278239;
typedef struct TY278274 TY278274;
typedef struct Vmargs278042 Vmargs278042;
typedef struct TY224932 TY224932;
typedef struct Tblock278030 Tblock278030;
typedef struct TY278214 TY278214;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(Tnode224809*, Transformation453013) (Tcontext279023* c, Tnode224809* n);
struct  Tlineinfo189352  {
NI16 line;
NI16 col;
NI32 fileindex;
};
struct  Tnode224809  {
Ttype224847* typ;
Tlineinfo189352 info;
NU16 flags;
NU8 kind;
union{
struct {NI64 intval;
} S1;
struct {NF floatval;
} S2;
struct {NimStringDesc* strval;
} S3;
struct {Tsym224841* sym;
} S4;
struct {Tident197021* ident;
} S5;
struct {Tnodeseq224803* 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  Tidobj197015  {
  TNimObject Sup;
NI id;
};
struct  Tloc224823  {
NU8 k;
NU8 s;
NU16 flags;
Ttype224847* t;
Ropeobj175009* r;
Ropeobj175009* heaproot;
};
struct  Ttype224847  {
  Tidobj197015 Sup;
NU8 kind;
NU8 callconv;
NU32 flags;
Ttypeseq224843* sons;
Tnode224809* n;
Tsym224841* owner;
Tsym224841* sym;
Tsym224841* destructor;
Tsym224841* deepcopy;
Tsym224841* assignment;
NI64 size;
NI16 align;
NI16 locklevel;
Tloc224823 loc;
};
struct  Cell48947  {
NI refcount;
TNimType* typ;
};
struct  Cellseq48963  {
NI len;
NI cap;
Cell48947** d;
};
struct  Cellset48959  {
NI counter;
NI max;
Pagedesc48955* head;
Pagedesc48955** 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;
Cellseq48963 zct;
Cellseq48963 decstack;
Cellset48959 cycleroots;
Cellseq48963 tempstack;
NI recgclock;
Memregion30890 region;
Gcstat51014 stat;
};
struct  Tpasscontext276005  {
  TNimObject Sup;
NIM_BOOL fromcache;
};
struct  Intset221056  {
NI counter;
NI max;
Trunk221052* head;
Trunkseq221054* data;
};
struct  Tlinkedlist140028  {
Tlistentry140022* head;
Tlistentry140022* tail;
NI counter;
};
struct  Tidtable224859  {
NI counter;
Tidpairseq224857* data;
};
typedef N_NIMCALL_PTR(Tnode224809*, TY279074) (Tcontext279023* c, Tnode224809* n);
typedef N_NIMCALL_PTR(Tnode224809*, TY279079) (Tcontext279023* c, Tnode224809* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode224809*, TY279087) (Tcontext279023* c, Tnode224809* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode224809*, TY279095) (Tcontext279023* c, Tnode224809* n);
typedef N_NIMCALL_PTR(Tnode224809*, TY279100) (Tcontext279023* c, Tnode224809* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode224809*, TY279108) (Tcontext279023* c, Tnode224809* n);
typedef N_NIMCALL_PTR(Tnode224809*, TY279113) (Tcontext279023* c, Tnode224809* n, Tnode224809* norig, NU32 filter);
typedef N_NIMCALL_PTR(Ttype224847*, TY279120) (Tcontext279023* c, Tnode224809* n, Ttype224847* prev);
typedef struct {
N_NIMCALL_PTR(Tnode224809*, ClPrc) (Tcontext279023* c, Tidtable224859 pt, Tnode224809* n, void* ClEnv);
void* ClEnv;
} TY279126;
typedef struct {
N_NIMCALL_PTR(Tsym224841*, ClPrc) (Tcontext279023* c, Tsym224841* fn, Tidtable224859 pt, Tlineinfo189352 info, void* ClEnv);
void* ClEnv;
} TY279132;
struct  Tstrtable224813  {
NI counter;
Tsymseq224811* data;
};
typedef N_NIMCALL_PTR(Tsym224841*, TY279148) (Tcontext279023* c, Tsym224841* dc, Ttype224847* t, Tlineinfo189352 info, NU8 op);
struct  Tcontext279023  {
  Tpasscontext276005 Sup;
Tsym224841* module;
Tscope224835* currentscope;
Tscope224835* importtable;
Tscope224835* toplevelscope;
Tproccon279011* p;
Tsymseq224811* friendmodules;
NI instcounter;
Intset221056 ambiguoussymbols;
NI intypeclass;
NI ingenericcontext;
NI inunrolledcontext;
NI compilescontextid;
NI compilescontextidgenerator;
NI ingenericinst;
Tsymseq224811* converters;
Tsymseq224811* patterns;
Tlinkedlist140028 optionstack;
Tidtable224859 symmapping;
Tlinkedlist140028 libs;
TY279074 semconstexpr;
TY279079 semexpr;
TY279087 semtryexpr;
TY279095 semtryconstexpr;
TY279100 semoperand;
TY279108 semconstboolexpr;
TY279113 semoverloadedcall;
TY279120 semtypenode;
TY279126 seminferredlambda;
TY279132 semgenerateinstance;
Intset221056 includedfiles;
Tstrtable224813 userpragmas;
Tctx278048* evalcontext;
Intset221056 unknownidents;
TY279143* generics;
NI lastgenericidx;
NI hloloopdetector;
NI inparallelstmt;
TY279148 insttypeboundop;
};
struct  Tscope224835  {
NI depthlevel;
Tstrtable224813 symbols;
Tnodeseq224803* usingsyms;
Tscope224835* parent;
};
struct  Ttabiter232119  {
NI h;
};
struct  Tsym224841  {
  Tidobj197015 Sup;
NU8 kind;
union{
struct {Ttypeseq224843* typeinstcache;
Tscope224835* typscope;
} S1;
struct {TY224944* procinstcache;
Tsym224841* gcunsafetyreason;
} S2;
struct {TY224944* usedgenerics;
Tstrtable224813 tab;
} S3;
struct {Tsym224841* guard;
NI bitsize;
} S4;
} kindU;
NU8 magic;
Ttype224847* typ;
Tident197021* name;
Tlineinfo189352 info;
Tsym224841* owner;
NU32 flags;
Tnode224809* ast;
NU32 options;
NI position;
NI offset;
Tloc224823 loc;
Tlib224827* annex;
Tnode224809* constraint;
};
struct  Tident197021  {
  Tidobj197015 Sup;
NimStringDesc* s;
Tident197021* next;
NI h;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Ropeobj175009  {
  TNimObject Sup;
Ropeobj175009* left;
Ropeobj175009* right;
NI length;
NimStringDesc* data;
};
struct  Gcstack51016  {
Gcstack51016* prev;
Gcstack51016* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY30821[16];
struct  Pagedesc48955  {
Pagedesc48955* 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  Tproccon279011  {
Tsym224841* owner;
Tsym224841* resultsym;
NI nestedloopcounter;
NI nestedblockcounter;
NI intrystmt;
Tproccon279011* next;
NIM_BOOL wasforwarded;
Tnode224809* bracketexpr;
};
struct  Trunk221052  {
Trunk221052* next;
NI key;
TY30821 bits;
};
struct  Tlistentry140022  {
  TNimObject Sup;
Tlistentry140022* prev;
Tlistentry140022* next;
};
struct  Tidpair224855  {
Tidobj197015* key;
TNimObject* val;
};
struct  Tctx278048  {
  Tpasscontext276005 Sup;
TY278254* code;
TY190420* debug;
Tnode224809* globals;
Tnode224809* constants;
Ttypeseq224843* types;
Tnode224809* currentexceptiona;
Tnode224809* currentexceptionb;
NI exceptioninstr;
PprocHEX3Aobjecttype278233* prc;
Tsym224841* module;
Tnode224809* callsite;
NU8 mode;
NU8 features;
NIM_BOOL traceactive;
NI loopiterations;
Tlineinfo189352 comesfromheuristic;
TY278273* callbacks;
NimStringDesc* errorflag;
};
struct  Tinstantiationpair279013  {
Tsym224841* genericsym;
Tinstantiation224831* inst;
};
struct  Tlib224827  {
  Tlistentry140022 Sup;
NU8 kind;
NIM_BOOL generated;
NIM_BOOL isoverriden;
Ropeobj175009* name;
Tnode224809* path;
};
struct  Freecell30832  {
Freecell30832* next;
NI zerofield;
};
struct TY278239 {
NIM_BOOL Field0;
NU8 Field1;
};
typedef TY278239 TY278242[256];
struct  PprocHEX3Aobjecttype278233  {
TY278234* blocks;
Tsym224841* sym;
TY278242 slots;
NI maxslots;
};
typedef struct {
N_NIMCALL_PTR(void, ClPrc) (Vmargs278042* args, void* ClEnv);
void* ClEnv;
} Vmcallback278044;
struct TY278274 {
NimStringDesc* Field0;
Vmcallback278044 Field1;
};
struct  Tinstantiation224831  {
Tsym224841* sym;
Ttypeseq224843* concretetypes;
TY224932* usedby;
NI compilesid;
};
struct  Tblock278030  {
Tsym224841* label;
TY278214* fixups;
};
struct  Vmargs278042  {
NI ra;
NI rb;
NI rc;
void* slots;
Tnode224809* currentexception;
};
struct Tnodeseq224803 {
  TGenericSeq Sup;
  Tnode224809* data[SEQ_DECL_SIZE];
};
struct Ttypeseq224843 {
  TGenericSeq Sup;
  Ttype224847* data[SEQ_DECL_SIZE];
};
struct Tsymseq224811 {
  TGenericSeq Sup;
  Tsym224841* data[SEQ_DECL_SIZE];
};
struct Trunkseq221054 {
  TGenericSeq Sup;
  Trunk221052* data[SEQ_DECL_SIZE];
};
struct Tidpairseq224857 {
  TGenericSeq Sup;
  Tidpair224855 data[SEQ_DECL_SIZE];
};
struct TY279143 {
  TGenericSeq Sup;
  Tinstantiationpair279013 data[SEQ_DECL_SIZE];
};
struct TY224944 {
  TGenericSeq Sup;
  Tinstantiation224831* data[SEQ_DECL_SIZE];
};
struct TY278254 {
  TGenericSeq Sup;
  NU32 data[SEQ_DECL_SIZE];
};
struct TY190420 {
  TGenericSeq Sup;
  Tlineinfo189352 data[SEQ_DECL_SIZE];
};
struct TY278273 {
  TGenericSeq Sup;
  TY278274 data[SEQ_DECL_SIZE];
};
struct TY278234 {
  TGenericSeq Sup;
  Tblock278030 data[SEQ_DECL_SIZE];
};
struct TY224932 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
struct TY278214 {
  TGenericSeq Sup;
  NI data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, registerplugin_453124)(NimStringDesc* package, NimStringDesc* module, NimStringDesc* fn, Transformation453013 t);
N_NIMCALL(Tnode224809*, semlocals_454020)(Tcontext279023* c, Tnode224809* n);
N_NIMCALL(Ttype224847*, newtypes_279221)(NU8 kind, Tcontext279023* c);
N_NIMCALL(Tnode224809*, newnodeit_226807)(NU8 kind, Tlineinfo189352 info, Ttype224847* typ);
N_NIMCALL(Tnode224809*, newnodei_226351)(NU8 kind, Tlineinfo189352 info);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Cell48947*, usrtocell_52646)(void* usr);
static N_INLINE(void, rtladdzct_54204)(Cell48947* c);
N_NOINLINE(void, addzct_52617)(Cellseq48963* s, Cell48947* c);
N_NIMCALL(Tsym224841*, inittabiter_232124)(Ttabiter232119* ti, Tstrtable224813 tab);
N_NIMCALL(Ttype224847*, skiptypes_228167)(Ttype224847* t, NU64 kinds);
N_NIMCALL(Tsym224841*, newsym_225656)(NU8 symkind, Tident197021* name, Tsym224841* owner, Tlineinfo189352 info);
N_NIMCALL(Tsym224841*, getcurrowner_279258)(void);
N_NIMCALL(void, addson_226819)(Tnode224809* father, Tnode224809* son);
N_NIMCALL(Tnode224809*, newsymnode_226325)(Tsym224841* sym);
N_NIMCALL(void, addsonskipintlit_273729)(Ttype224847* father, Ttype224847* son);
N_NIMCALL(Tnode224809*, newsymnode_226338)(Tsym224841* sym, Tlineinfo189352 info);
static N_INLINE(Tnode224809*, newderef_401024)(Tnode224809* n);
N_NIMCALL(void, add_225165)(Tnode224809* father, Tnode224809* son);
N_NIMCALL(Tsym224841*, nextiter_232132)(Ttabiter232119* ti, Tstrtable224813 tab);
STRING_LITERAL(TMP1040, "stdlib", 6);
STRING_LITERAL(TMP1041, "system", 6);
STRING_LITERAL(TMP1042, "locals", 6);
extern Gcheap51018 gch_51059;

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

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

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Cell48947* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_52646(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell48947* 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(Tnode224809*, newderef_401024)(Tnode224809* n) {
	Tnode224809* result;
	result = 0;
	result = newnodeit_226807(((NU8) 65), (*n).info, (*(*n).typ).sons->data[((NI) 0)]);
	addson_226819(result, n);
	return result;
}

N_NIMCALL(Tnode224809*, semlocals_454020)(Tcontext279023* c, Tnode224809* n) {
	Tnode224809* result;
	NI counter;
	Ttype224847* tupletype;
	result = 0;
	counter = ((NI) 0);
	tupletype = newtypes_279221(((NU8) 18), c);
	result = newnodeit_226807(((NU8) 37), (*n).info, tupletype);
	asgnRefNoCycle((void**) (&(*tupletype).n), newnodei_226351(((NU8) 138), (*n).info));
	{
		Tscope224835* scope_454027;
		Tscope224835* HEX3Atmp_454100;
		Tscope224835* current_454103;
		scope_454027 = 0;
		HEX3Atmp_454100 = 0;
		HEX3Atmp_454100 = (*c).currentscope;
		current_454103 = HEX3Atmp_454100;
		{
			while (1) {
				if (!!((current_454103 == NIM_NIL))) goto LA3;
				scope_454027 = current_454103;
				{
					if (!(scope_454027 == (*c).toplevelscope)) goto LA6;
					goto LA1;
				}
				LA6: ;
				{
					Tsym224841* it_454039;
					Tstrtable224813 HEX3Atmp_454094;
					Ttabiter232119 it_454097;
					Tsym224841* s_454099;
					it_454039 = 0;
					memset((void*)(&HEX3Atmp_454094), 0, sizeof(HEX3Atmp_454094));
					HEX3Atmp_454094.counter = (*scope_454027).symbols.counter;
					HEX3Atmp_454094.data = (*scope_454027).symbols.data;
					memset((void*)(&it_454097), 0, sizeof(it_454097));
					s_454099 = inittabiter_232124((&it_454097), HEX3Atmp_454094);
					{
						while (1) {
							if (!!((s_454099 == NIM_NIL))) goto LA10;
							it_454039 = s_454099;
							{
								NIM_BOOL LOC13;
								Ttype224847* LOC15;
								Tsym224841* field;
								Tsym224841* LOC18;
								Tnode224809* LOC19;
								Tnode224809* a;
								LOC13 = 0;
								LOC13 = ((2099976 &(1<<(((*it_454039).kind)&31)))!=0);
								if (!(LOC13)) goto LA14;
								LOC15 = 0;
								LOC15 = skiptypes_228167((*it_454039).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_279258();
								field = newsym_225656(((NU8) 19), (*it_454039).name, LOC18, (*n).info);
								asgnRefNoCycle((void**) (&(*field).typ), skiptypes_228167((*it_454039).typ, 8390656));
								(*field).position = counter;
								counter += ((NI) 1);
								LOC19 = 0;
								LOC19 = newsymnode_226325(field);
								addson_226819((*tupletype).n, LOC19);
								addsonskipintlit_273729(tupletype, (*field).typ);
								a = newsymnode_226338(it_454039, (*result).info);
								{
									Ttype224847* LOC22;
									LOC22 = 0;
									LOC22 = skiptypes_228167((*it_454039).typ, 2048);
									if (!((*LOC22).kind == ((NU8) 23))) goto LA23;
									a = newderef_401024(a);
								}
								LA23: ;
								add_225165(result, a);
							}
							LA16: ;
							s_454099 = nextiter_232132((&it_454097), HEX3Atmp_454094);
						} LA10: ;
					}
				}
				current_454103 = (*current_454103).parent;
			} LA3: ;
		}
	} LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_localsInit000)(void) {
	registerplugin_453124(((NimStringDesc*) &TMP1040), ((NimStringDesc*) &TMP1041), ((NimStringDesc*) &TMP1042), semlocals_454020);
}

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

