/* Generated by Nim Compiler v0.13.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 Tnode213790 Tnode213790;
typedef struct Tcontext263020 Tcontext263020;
typedef struct Ttype213828 Ttype213828;
typedef struct Tlineinfo181337 Tlineinfo181337;
typedef struct Tsym213822 Tsym213822;
typedef struct Tident188012 Tident188012;
typedef struct Tnodeseq213784 Tnodeseq213784;
typedef struct Tidobj188006 Tidobj188006;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Ttypeseq213824 Ttypeseq213824;
typedef struct Tloc213804 Tloc213804;
typedef struct Ropeobj168006 Ropeobj168006;
typedef struct Cell47705 Cell47705;
typedef struct Cellseq47721 Cellseq47721;
typedef struct Gcheap50018 Gcheap50018;
typedef struct Gcstack50016 Gcstack50016;
typedef struct Cellset47717 Cellset47717;
typedef struct Pagedesc47713 Pagedesc47713;
typedef struct Memregion29887 Memregion29887;
typedef struct Smallchunk29839 Smallchunk29839;
typedef struct Llchunk29881 Llchunk29881;
typedef struct Bigchunk29841 Bigchunk29841;
typedef struct Intset29814 Intset29814;
typedef struct Trunk29810 Trunk29810;
typedef struct Avlnode29885 Avlnode29885;
typedef struct Gcstat50014 Gcstat50014;
typedef struct Tscope213816 Tscope213816;
typedef struct Tpasscontext260002 Tpasscontext260002;
typedef struct Tproccon263008 Tproccon263008;
typedef struct Tsymseq213792 Tsymseq213792;
typedef struct Intset210035 Intset210035;
typedef struct Trunk210031 Trunk210031;
typedef struct Trunkseq210033 Trunkseq210033;
typedef struct Tlinkedlist135016 Tlinkedlist135016;
typedef struct Tlistentry135010 Tlistentry135010;
typedef struct Tidtable213840 Tidtable213840;
typedef struct Tidpairseq213838 Tidpairseq213838;
typedef struct Tstrtable213794 Tstrtable213794;
typedef struct Tctx262036 Tctx262036;
typedef struct TY263140 TY263140;
typedef struct Ttabiter220071 Ttabiter220071;
typedef struct TY213925 TY213925;
typedef struct Tlib213808 Tlib213808;
typedef struct Basechunk29837 Basechunk29837;
typedef struct Freecell29829 Freecell29829;
typedef struct Tidpair213836 Tidpair213836;
typedef struct TY262242 TY262242;
typedef struct TY182093 TY182093;
typedef struct PprocHEX3Aobjecttype262221 PprocHEX3Aobjecttype262221;
typedef struct TY262261 TY262261;
typedef struct Tinstantiationpair263010 Tinstantiationpair263010;
typedef struct Tinstantiation213812 Tinstantiation213812;
typedef struct TY262222 TY262222;
typedef struct TY262227 TY262227;
typedef struct TY262262 TY262262;
typedef struct Vmargs262030 Vmargs262030;
typedef struct TY213913 TY213913;
typedef struct Tblock262018 Tblock262018;
typedef struct TY262202 TY262202;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(Tnode213790*, Transformation420004) (Tcontext263020* c, Tnode213790* n);
struct  Tlineinfo181337  {
NI16 line;
NI16 col;
NI32 fileindex;
};
struct  Tnode213790  {
Ttype213828* typ;
Tlineinfo181337 info;
NU16 flags;
NU8 kind;
union{
struct {NI64 intval;
} S1;
struct {NF floatval;
} S2;
struct {NimStringDesc* strval;
} S3;
struct {Tsym213822* sym;
} S4;
struct {Tident188012* ident;
} S5;
struct {Tnodeseq213784* sons;
} S6;
} kindU;
NimStringDesc* comment;
};
typedef N_NIMCALL_PTR(void, TY3489) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Tidobj188006  {
  TNimObject Sup;
NI id;
};
struct  Tloc213804  {
NU8 k;
NU8 s;
NU16 flags;
Ttype213828* t;
Ropeobj168006* r;
Ropeobj168006* heaproot;
};
struct  Ttype213828  {
  Tidobj188006 Sup;
NU8 kind;
NU8 callconv;
NU32 flags;
Ttypeseq213824* sons;
Tnode213790* n;
Tsym213822* owner;
Tsym213822* sym;
Tsym213822* destructor;
Tsym213822* deepcopy;
Tsym213822* assignment;
NI64 size;
NI16 align;
NI16 locklevel;
Tloc213804 loc;
};
struct  Cell47705  {
NI refcount;
TNimType* typ;
};
struct  Cellseq47721  {
NI len;
NI cap;
Cell47705** d;
};
struct  Cellset47717  {
NI counter;
NI max;
Pagedesc47713* head;
Pagedesc47713** data;
};
typedef Smallchunk29839* TY29902[512];
typedef Trunk29810* Trunkbuckets29812[256];
struct  Intset29814  {
Trunkbuckets29812 data;
};
struct  Memregion29887  {
NI minlargeobj;
NI maxlargeobj;
TY29902 freesmallchunks;
Llchunk29881* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk29841* freechunkslist;
Intset29814 chunkstarts;
Avlnode29885* root;
Avlnode29885* deleted;
Avlnode29885* last;
Avlnode29885* freeavlnodes;
};
struct  Gcstat50014  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap50018  {
Gcstack50016* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq47721 zct;
Cellseq47721 decstack;
Cellset47717 cycleroots;
Cellseq47721 tempstack;
NI recgclock;
Memregion29887 region;
Gcstat50014 stat;
};
struct  Tpasscontext260002  {
  TNimObject Sup;
NIM_BOOL fromcache;
};
struct  Intset210035  {
NI counter;
NI max;
Trunk210031* head;
Trunkseq210033* data;
};
struct  Tlinkedlist135016  {
Tlistentry135010* head;
Tlistentry135010* tail;
NI counter;
};
struct  Tidtable213840  {
NI counter;
Tidpairseq213838* data;
};
typedef N_NIMCALL_PTR(Tnode213790*, TY263071) (Tcontext263020* c, Tnode213790* n);
typedef N_NIMCALL_PTR(Tnode213790*, TY263076) (Tcontext263020* c, Tnode213790* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode213790*, TY263084) (Tcontext263020* c, Tnode213790* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode213790*, TY263092) (Tcontext263020* c, Tnode213790* n);
typedef N_NIMCALL_PTR(Tnode213790*, TY263097) (Tcontext263020* c, Tnode213790* n, NU16 flags);
typedef N_NIMCALL_PTR(Tnode213790*, TY263105) (Tcontext263020* c, Tnode213790* n);
typedef N_NIMCALL_PTR(Tnode213790*, TY263110) (Tcontext263020* c, Tnode213790* n, Tnode213790* norig, NU32 filter);
typedef N_NIMCALL_PTR(Ttype213828*, TY263117) (Tcontext263020* c, Tnode213790* n, Ttype213828* prev);
typedef struct {
N_NIMCALL_PTR(Tnode213790*, ClPrc) (Tcontext263020* c, Tidtable213840 pt, Tnode213790* n, void* ClEnv);
void* ClEnv;
} TY263123;
typedef struct {
N_NIMCALL_PTR(Tsym213822*, ClPrc) (Tcontext263020* c, Tsym213822* fn, Tidtable213840 pt, Tlineinfo181337 info, void* ClEnv);
void* ClEnv;
} TY263129;
struct  Tstrtable213794  {
NI counter;
Tsymseq213792* data;
};
typedef N_NIMCALL_PTR(Tsym213822*, TY263145) (Tcontext263020* c, Tsym213822* dc, Ttype213828* t, Tlineinfo181337 info, NU8 op);
struct  Tcontext263020  {
  Tpasscontext260002 Sup;
Tsym213822* module;
Tscope213816* currentscope;
Tscope213816* importtable;
Tscope213816* toplevelscope;
Tproccon263008* p;
Tsymseq213792* friendmodules;
NI instcounter;
Intset210035 ambiguoussymbols;
NI intypeclass;
NI ingenericcontext;
NI inunrolledcontext;
NI compilescontextid;
NI compilescontextidgenerator;
NI ingenericinst;
Tsymseq213792* converters;
Tsymseq213792* patterns;
Tlinkedlist135016 optionstack;
Tidtable213840 symmapping;
Tlinkedlist135016 libs;
TY263071 semconstexpr;
TY263076 semexpr;
TY263084 semtryexpr;
TY263092 semtryconstexpr;
TY263097 semoperand;
TY263105 semconstboolexpr;
TY263110 semoverloadedcall;
TY263117 semtypenode;
TY263123 seminferredlambda;
TY263129 semgenerateinstance;
Intset210035 includedfiles;
Tstrtable213794 userpragmas;
Tctx262036* evalcontext;
Intset210035 unknownidents;
TY263140* generics;
NI lastgenericidx;
NI hloloopdetector;
NI inparallelstmt;
TY263145 insttypeboundop;
};
struct  Tscope213816  {
NI depthlevel;
Tstrtable213794 symbols;
Tnodeseq213784* usingsyms;
Tscope213816* parent;
};
struct  Ttabiter220071  {
NI h;
};
struct  Tsym213822  {
  Tidobj188006 Sup;
NU8 kind;
union{
struct {Ttypeseq213824* typeinstcache;
Tscope213816* typscope;
} S1;
struct {TY213925* procinstcache;
Tsym213822* gcunsafetyreason;
} S2;
struct {TY213925* usedgenerics;
Tstrtable213794 tab;
} S3;
struct {Tsym213822* guard;
NI bitsize;
} S4;
} kindU;
NU8 magic;
Ttype213828* typ;
Tident188012* name;
Tlineinfo181337 info;
Tsym213822* owner;
NU32 flags;
Tnode213790* ast;
NU32 options;
NI position;
NI offset;
Tloc213804 loc;
Tlib213808* annex;
Tnode213790* constraint;
};
struct  Tident188012  {
  Tidobj188006 Sup;
NimStringDesc* s;
Tident188012* next;
NI h;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Ropeobj168006  {
  TNimObject Sup;
Ropeobj168006* left;
Ropeobj168006* right;
NI length;
NimStringDesc* data;
};
struct  Gcstack50016  {
Gcstack50016* prev;
Gcstack50016* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY29818[16];
struct  Pagedesc47713  {
Pagedesc47713* next;
NI key;
TY29818 bits;
};
struct  Basechunk29837  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk29839  {
  Basechunk29837 Sup;
Smallchunk29839* next;
Smallchunk29839* prev;
Freecell29829* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk29881  {
NI size;
NI acc;
Llchunk29881* next;
};
struct  Bigchunk29841  {
  Basechunk29837 Sup;
Bigchunk29841* next;
Bigchunk29841* prev;
NI align;
NF data;
};
struct  Trunk29810  {
Trunk29810* next;
NI key;
TY29818 bits;
};
typedef Avlnode29885* TY29892[2];
struct  Avlnode29885  {
TY29892 link;
NI key;
NI upperbound;
NI level;
};
struct  Tproccon263008  {
Tsym213822* owner;
Tsym213822* resultsym;
NI nestedloopcounter;
NI nestedblockcounter;
NI intrystmt;
Tproccon263008* next;
NIM_BOOL wasforwarded;
Tnode213790* bracketexpr;
};
struct  Trunk210031  {
Trunk210031* next;
NI key;
TY29818 bits;
};
struct  Tlistentry135010  {
  TNimObject Sup;
Tlistentry135010* prev;
Tlistentry135010* next;
};
struct  Tidpair213836  {
Tidobj188006* key;
TNimObject* val;
};
struct  Tctx262036  {
  Tpasscontext260002 Sup;
TY262242* code;
TY182093* debug;
Tnode213790* globals;
Tnode213790* constants;
Ttypeseq213824* types;
Tnode213790* currentexceptiona;
Tnode213790* currentexceptionb;
NI exceptioninstr;
PprocHEX3Aobjecttype262221* prc;
Tsym213822* module;
Tnode213790* callsite;
NU8 mode;
NU8 features;
NIM_BOOL traceactive;
NI loopiterations;
Tlineinfo181337 comesfromheuristic;
TY262261* callbacks;
NimStringDesc* errorflag;
};
struct  Tinstantiationpair263010  {
Tsym213822* genericsym;
Tinstantiation213812* inst;
};
struct  Tlib213808  {
  Tlistentry135010 Sup;
NU8 kind;
NIM_BOOL generated;
NIM_BOOL isoverriden;
Ropeobj168006* name;
Tnode213790* path;
};
struct  Freecell29829  {
Freecell29829* next;
NI zerofield;
};
struct TY262227 {
NIM_BOOL Field0;
NU8 Field1;
};
typedef TY262227 TY262230[256];
struct  PprocHEX3Aobjecttype262221  {
TY262222* blocks;
Tsym213822* sym;
TY262230 slots;
NI maxslots;
};
typedef struct {
N_NIMCALL_PTR(void, ClPrc) (Vmargs262030* args, void* ClEnv);
void* ClEnv;
} Vmcallback262032;
struct TY262262 {
NimStringDesc* Field0;
Vmcallback262032 Field1;
};
struct  Tinstantiation213812  {
Tsym213822* sym;
Ttypeseq213824* concretetypes;
TY213913* usedby;
NI compilesid;
};
struct  Tblock262018  {
Tsym213822* label;
TY262202* fixups;
};
struct  Vmargs262030  {
NI ra;
NI rb;
NI rc;
void* slots;
Tnode213790* currentexception;
};
struct Tnodeseq213784 {
  TGenericSeq Sup;
  Tnode213790* data[SEQ_DECL_SIZE];
};
struct Ttypeseq213824 {
  TGenericSeq Sup;
  Ttype213828* data[SEQ_DECL_SIZE];
};
struct Tsymseq213792 {
  TGenericSeq Sup;
  Tsym213822* data[SEQ_DECL_SIZE];
};
struct Trunkseq210033 {
  TGenericSeq Sup;
  Trunk210031* data[SEQ_DECL_SIZE];
};
struct Tidpairseq213838 {
  TGenericSeq Sup;
  Tidpair213836 data[SEQ_DECL_SIZE];
};
struct TY263140 {
  TGenericSeq Sup;
  Tinstantiationpair263010 data[SEQ_DECL_SIZE];
};
struct TY213925 {
  TGenericSeq Sup;
  Tinstantiation213812* data[SEQ_DECL_SIZE];
};
struct TY262242 {
  TGenericSeq Sup;
  NU32 data[SEQ_DECL_SIZE];
};
struct TY182093 {
  TGenericSeq Sup;
  Tlineinfo181337 data[SEQ_DECL_SIZE];
};
struct TY262261 {
  TGenericSeq Sup;
  TY262262 data[SEQ_DECL_SIZE];
};
struct TY262222 {
  TGenericSeq Sup;
  Tblock262018 data[SEQ_DECL_SIZE];
};
struct TY213913 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
struct TY262202 {
  TGenericSeq Sup;
  NI data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, registerplugin_420091)(NimStringDesc* package, NimStringDesc* module, NimStringDesc* fn, Transformation420004 t);
N_NIMCALL(Tnode213790*, semlocals_421005)(Tcontext263020* c, Tnode213790* n);
N_NIMCALL(Ttype213828*, newtypes_263185)(NU8 kind, Tcontext263020* c);
N_NIMCALL(Tnode213790*, newnodeit_215801)(NU8 kind, Tlineinfo181337 info, Ttype213828* typ);
N_NIMCALL(Tnode213790*, newnodei_215248)(NU8 kind, Tlineinfo181337 info);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Cell47705*, usrtocell_51640)(void* usr);
static N_INLINE(void, rtladdzct_53201)(Cell47705* c);
N_NOINLINE(void, addzct_51617)(Cellseq47721* s, Cell47705* c);
N_NIMCALL(Tsym213822*, inittabiter_220073)(Ttabiter220071* ti, Tstrtable213794 tab);
N_NIMCALL(Ttype213828*, skiptypes_217113)(Ttype213828* t, NU64 kinds);
N_NIMCALL(Tsym213822*, newsym_214684)(NU8 symkind, Tident188012* name, Tsym213822* owner, Tlineinfo181337 info);
N_NIMCALL(Tsym213822*, getcurrowner_263210)(void);
N_NIMCALL(void, addson_215807)(Tnode213790* father, Tnode213790* son);
N_NIMCALL(Tnode213790*, newsymnode_215234)(Tsym213822* sym);
N_NIMCALL(void, addsonskipintlit_257678)(Ttype213828* father, Ttype213828* son);
N_NIMCALL(Tnode213790*, newsymnode_215241)(Tsym213822* sym, Tlineinfo181337 info);
static N_INLINE(Tnode213790*, newderef_375006)(Tnode213790* n);
N_NIMCALL(void, add_214114)(Tnode213790* father, Tnode213790* son);
N_NIMCALL(Tsym213822*, nextiter_220078)(Ttabiter220071* ti, Tstrtable213794 tab);
STRING_LITERAL(TMP1044, "stdlib", 6);
STRING_LITERAL(TMP1045, "system", 6);
STRING_LITERAL(TMP1046, "locals", 6);
extern Gcheap50018 gch_50059;

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

static N_INLINE(void, rtladdzct_53201)(Cell47705* c) {
	addzct_51617((&gch_50059.zct), c);
}

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

static N_INLINE(Tnode213790*, newderef_375006)(Tnode213790* n) {
	Tnode213790* result;
	result = 0;
	result = newnodeit_215801(((NU8) 65), (*n).info, (*(*n).typ).sons->data[((NI) 0)]);
	addson_215807(result, n);
	return result;
}

N_NIMCALL(Tnode213790*, semlocals_421005)(Tcontext263020* c, Tnode213790* n) {
	Tnode213790* result;
	NI counter;
	Ttype213828* tupletype;
	result = 0;
	counter = ((NI) 0);
	tupletype = newtypes_263185(((NU8) 18), c);
	result = newnodeit_215801(((NU8) 37), (*n).info, tupletype);
	asgnRefNoCycle((void**) (&(*tupletype).n), newnodei_215248(((NU8) 138), (*n).info));
	{
		Tscope213816* scope_421012;
		Tscope213816* HEX3Atmp_421085;
		Tscope213816* current_421088;
		scope_421012 = 0;
		HEX3Atmp_421085 = 0;
		HEX3Atmp_421085 = (*c).currentscope;
		current_421088 = HEX3Atmp_421085;
		{
			while (1) {
				if (!!((current_421088 == NIM_NIL))) goto LA3;
				scope_421012 = current_421088;
				{
					if (!(scope_421012 == (*c).toplevelscope)) goto LA6;
					goto LA1;
				}
				LA6: ;
				{
					Tsym213822* it_421024;
					Tstrtable213794 HEX3Atmp_421079;
					Ttabiter220071 it_421082;
					Tsym213822* s_421084;
					it_421024 = 0;
					memset((void*)(&HEX3Atmp_421079), 0, sizeof(HEX3Atmp_421079));
					HEX3Atmp_421079.counter = (*scope_421012).symbols.counter;
					HEX3Atmp_421079.data = (*scope_421012).symbols.data;
					memset((void*)(&it_421082), 0, sizeof(it_421082));
					s_421084 = inittabiter_220073((&it_421082), HEX3Atmp_421079);
					{
						while (1) {
							if (!!((s_421084 == NIM_NIL))) goto LA10;
							it_421024 = s_421084;
							{
								NIM_BOOL LOC13;
								Ttype213828* LOC15;
								Tsym213822* field;
								Tsym213822* LOC18;
								Tnode213790* LOC19;
								Tnode213790* a;
								LOC13 = 0;
								LOC13 = ((1051400 &(1U<<((NU)((*it_421024).kind)&31U)))!=0);
								if (!(LOC13)) goto LA14;
								LOC15 = 0;
								LOC15 = skiptypes_217113((*it_421024).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_263210();
								field = newsym_214684(((NU8) 18), (*it_421024).name, LOC18, (*n).info);
								asgnRefNoCycle((void**) (&(*field).typ), skiptypes_217113((*it_421024).typ, 8390656));
								(*field).position = counter;
								counter += ((NI) 1);
								LOC19 = 0;
								LOC19 = newsymnode_215234(field);
								addson_215807((*tupletype).n, LOC19);
								addsonskipintlit_257678(tupletype, (*field).typ);
								a = newsymnode_215241(it_421024, (*result).info);
								{
									Ttype213828* LOC22;
									LOC22 = 0;
									LOC22 = skiptypes_217113((*it_421024).typ, 2048);
									if (!((*LOC22).kind == ((NU8) 23))) goto LA23;
									a = newderef_375006(a);
								}
								LA23: ;
								add_214114(result, a);
							}
							LA16: ;
							s_421084 = nextiter_220078((&it_421082), HEX3Atmp_421079);
						} LA10: ;
					}
				}
				current_421088 = (*current_421088).parent;
			} LA3: ;
		}
	} LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_localsInit000)(void) {
	registerplugin_420091(((NimStringDesc*) &TMP1044), ((NimStringDesc*) &TMP1045), ((NimStringDesc*) &TMP1046), semlocals_421005);
}

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

