/* 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/modules.o compiler/nimcache/modules.c */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <string.h>

#include <stdio.h>
typedef struct tsymseq188805 tsymseq188805;
typedef struct tsym188833 tsym188833;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
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 TY524051 TY524051;
typedef struct tmoduleinmemory524012 tmoduleinmemory524012;
typedef struct TY188922 TY188922;
typedef struct tnode188803 tnode188803;
typedef struct tidobj167013 tidobj167013;
typedef struct TNimObject TNimObject;
typedef struct ttypeseq188835 ttypeseq188835;
typedef struct ttype188837 ttype188837;
typedef struct tscope188827 tscope188827;
typedef struct TY188933 TY188933;
typedef struct tinstantiation188823 tinstantiation188823;
typedef struct tstrtable188807 tstrtable188807;
typedef struct tident167019 tident167019;
typedef struct tlineinfo163527 tlineinfo163527;
typedef struct tloc188817 tloc188817;
typedef struct trope145007 trope145007;
typedef struct tlib188821 tlib188821;
typedef struct NimStringDesc NimStringDesc;
typedef struct TY108700 TY108700;
typedef struct trodreader236024 trodreader236024;
typedef struct tllstream176204 tllstream176204;
typedef struct TY79484 TY79484;
typedef struct TY465142 TY465142;
typedef struct tcgen465030 tcgen465030;
typedef struct tbasechunk22636 tbasechunk22636;
typedef struct tfreecell22628 tfreecell22628;
typedef struct tnodeseq188797 tnodeseq188797;
typedef struct tlistentry118017 tlistentry118017;
typedef struct tindex236022 tindex236022;
typedef struct tiitable197207 tiitable197207;
typedef struct tiipairseq197205 tiipairseq197205;
typedef struct tiipair197203 tiipair197203;
typedef struct tidtable188849 tidtable188849;
typedef struct tidpairseq188847 tidpairseq188847;
typedef struct tidpair188845 tidpair188845;
typedef struct tmemfile234204 tmemfile234204;
typedef struct tpasscontext246003 tpasscontext246003;
typedef struct tintset185047 tintset185047;
typedef struct ttrunk185043 ttrunk185043;
typedef struct ttrunkseq185045 ttrunkseq185045;
typedef struct tlinkedlist118023 tlinkedlist118023;
typedef struct tcproc465026 tcproc465026;
typedef struct tnodetable188861 tnodetable188861;
typedef struct tnodepairseq188859 tnodepairseq188859;
typedef struct tnodepair188857 tnodepair188857;
typedef struct TY163540 TY163540;
typedef struct TY465097 TY465097;
typedef struct tblock465024 tblock465024;
struct  TGenericSeq  {
NI len;
NI reserved;
};
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  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
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  tmoduleinmemory524012  {
NF Compiledat;
NI32 Crc;
TY188922* Deps;
NU8 Needsrecompile;
NU8 Crcstatus;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tidobj167013  {
  TNimObject Sup;
NI Id;
};
struct  tstrtable188807  {
NI Counter;
tsymseq188805* Data;
};
struct  tlineinfo163527  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  tloc188817  {
NU8 K;
NU8 S;
NU8 Flags;
ttype188837* T;
trope145007* R;
trope145007* Heaproot;
NI A;
};
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  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct TY108700 {
NimStringDesc* Field0;
NimStringDesc* Field1;
NimStringDesc* Field2;
};
struct  tident167019  {
  tidobj167013 Sup;
NimStringDesc* S;
tident167019* Next;
NI H;
};
struct TY79484 {
NimStringDesc* Field0;
NI Field1;
};
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  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  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  tscope188827  {
NI Depthlevel;
tstrtable188807 Symbols;
tnodeseq188797* Usingsyms;
tscope188827* Parent;
};
struct  tinstantiation188823  {
tsym188833* Sym;
ttypeseq188835* Concretetypes;
TY188922* Usedby;
};
struct  trope145007  {
  TNimObject Sup;
trope145007* Left;
trope145007* Right;
NI Length;
NimStringDesc* Data;
};
struct  tlistentry118017  {
  TNimObject Sup;
tlistentry118017* Prev;
tlistentry118017* Next;
};
struct  tlib188821  {
  tlistentry118017 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope145007* Name;
tnode188803* Path;
};
struct  tiipair197203  {
NI Key;
NI Val;
};
struct  tiitable197207  {
NI Counter;
tiipairseq197205* Data;
};
struct  tindex236022  {
NI Lastidxkey;
NI Lastidxval;
tiitable197207 Tab;
NimStringDesc* R;
NI Offset;
};
struct  tidpair188845  {
tidobj167013* Key;
TNimObject* Val;
};
struct  tidtable188849  {
NI Counter;
tidpairseq188847* Data;
};
struct  tmemfile234204  {
void* Mem;
NI Size;
int Handle;
};
struct  trodreader236024  {
  TNimObject Sup;
NI Pos;
NCSTRING S;
NU32 Options;
NU8 Reason;
TY188922* Moddeps;
TY188922* Files;
NI Dataidx;
NI Convertersidx;
NI Initidx;
NI Interfidx;
NI Compilerprocsidx;
NI Methodsidx;
NimStringDesc* Filename;
tindex236022 Index;
tindex236022 Imports;
NI Readerindex;
NI Line;
NI Moduleid;
tidtable188849 Syms;
tmemfile234204 Memfile;
tsymseq188805* Methods;
NimStringDesc* Origfile;
NIM_BOOL Inviewmode;
};
struct  tllstream176204  {
  TNimObject Sup;
NU8 Kind;
FILE* F;
NimStringDesc* S;
NI Rd;
NI Wr;
NI Lineoffset;
};
struct  tpasscontext246003  {
  TNimObject Sup;
NIM_BOOL Fromcache;
};
typedef trope145007* tcfilesections465014[18];
struct  tintset185047  {
NI Counter;
NI Max;
ttrunk185043* Head;
ttrunkseq185045* Data;
};
struct  tlinkedlist118023  {
tlistentry118017* Head;
tlistentry118017* Tail;
NI Counter;
};
struct  tnodepair188857  {
NI H;
tnode188803* Key;
NI Val;
};
struct  tnodetable188861  {
NI Counter;
tnodepairseq188859* Data;
};
typedef trope145007* TY465132[10];
struct  tcgen465030  {
  tpasscontext246003 Sup;
tsym188833* Module;
NimStringDesc* Filename;
tcfilesections465014 S;
NIM_BOOL Preventstacktrace;
NIM_BOOL Usesthreadvars;
NIM_BOOL Framedeclared;
NIM_BOOL Isheaderfile;
NIM_BOOL Includesstringh;
NimStringDesc* Cfilename;
tidtable188849 Typecache;
tidtable188849 Forwtypecache;
tintset185047 Declaredthings;
tintset185047 Declaredprotos;
tlinkedlist118023 Headerfiles;
tintset185047 Typeinfomarker;
tcproc465026* Initproc;
tcproc465026* Postinitproc;
tcproc465026* Preinitproc;
ttypeseq188835* Typestack;
tnodetable188861 Datacache;
tsymseq188805* Forwardedprocs;
NI Typenodes;
NI Nimtypes;
trope145007* Typenodesname;
trope145007* Nimtypesname;
NI Labels;
TY465132 Extensionloaders;
trope145007* Injectstmt;
};
struct  tfreecell22628  {
tfreecell22628* Next;
NI Zerofield;
};
struct  ttrunk185043  {
ttrunk185043* Next;
NI Key;
TY22618 Bits;
};
typedef trope145007* tcprocsections465018[3];
struct  tblock465024  {
NI Id;
trope145007* Label;
tcprocsections465018 Sections;
NIM_BOOL Isloop;
NI16 Nestedtrystmts;
NI16 Nestedexceptstmts;
NI16 Framelen;
};
struct  tcproc465026  {
tsym188833* Prc;
NIM_BOOL Beforeretneeded;
NIM_BOOL Threadvaraccessed;
tnodeseq188797* Nestedtrystmts;
NI Inexceptblock;
TY163540* Finallysafepoints;
NI Labels;
TY465097* Blocks;
NI Breakidx;
NU32 Options;
NI Maxframelen;
tcgen465030* Module;
NI Withinloop;
NI Gcframeid;
trope145007* Gcframetype;
};
struct tsymseq188805 {
  TGenericSeq Sup;
  tsym188833* data[SEQ_DECL_SIZE];
};
struct TY188922 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
struct TY524051 {
  TGenericSeq Sup;
  tmoduleinmemory524012 data[SEQ_DECL_SIZE];
};
struct ttypeseq188835 {
  TGenericSeq Sup;
  ttype188837* data[SEQ_DECL_SIZE];
};
struct TY188933 {
  TGenericSeq Sup;
  tinstantiation188823* data[SEQ_DECL_SIZE];
};
struct TY465142 {
  TGenericSeq Sup;
  tcgen465030* data[SEQ_DECL_SIZE];
};
struct tnodeseq188797 {
  TGenericSeq Sup;
  tnode188803* data[SEQ_DECL_SIZE];
};
struct tiipairseq197205 {
  TGenericSeq Sup;
  tiipair197203 data[SEQ_DECL_SIZE];
};
struct tidpairseq188847 {
  TGenericSeq Sup;
  tidpair188845 data[SEQ_DECL_SIZE];
};
struct ttrunkseq185045 {
  TGenericSeq Sup;
  ttrunk185043* data[SEQ_DECL_SIZE];
};
struct tnodepairseq188859 {
  TGenericSeq Sup;
  tnodepair188857 data[SEQ_DECL_SIZE];
};
struct TY163540 {
  TGenericSeq Sup;
  trope145007* data[SEQ_DECL_SIZE];
};
struct TY465097 {
  TGenericSeq Sup;
  tblock465024 data[SEQ_DECL_SIZE];
};
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
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*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP984)(void* p, NI op);
N_NIMCALL(tnode188803*, parsefile_220033)(NI32 fileidx);
N_NIMCALL(TGenericSeq*, setLengthSeq)(TGenericSeq* seq, NI elemsize, NI newlen);
N_NIMCALL(void, adddep_524157)(tsym188833* x, NI32 dep);
N_NIMCALL(void, safeadd_524191)(TY188922** x_524199, NI32 y_524203);
N_NIMCALL(void, docrc_524143)(NI32 fileidx);
N_NIMCALL(NI32, crcfromfile_144031)(NimStringDesc* filename);
N_NIMCALL(NimStringDesc*, tofilename_164780)(NI32 fileidx);
N_NIMCALL(tsym188833*, compilemodule_524750)(NI32 fileidx, NU32 flags);
N_NIMCALL(tsym188833*, getmodule_524076)(NI32 fileidx);
N_NIMCALL(tsym188833*, newmodule_524627)(NI32 fileidx);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(tident167019*, getident_167456)(NimStringDesc* identifier);
N_NIMCALL(void, nossplitFile)(NimStringDesc* path, TY108700* Result);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(NIM_BOOL, isnimrodidentifier_180276)(NimStringDesc* s);
N_NIMCALL(void, rawmessage_165386)(NU16 msg, NimStringDesc* arg);
N_NIMCALL(tlineinfo163527, newlineinfo_164069)(NI32 fileinfoidx, NI line, NI col);
N_NIMCALL(tsym188833*, newsym_189053)(NU8 symkind, tident167019* name, tsym188833* owner, tlineinfo163527 info);
N_NIMCALL(NimStringDesc*, getpackagename_137811)(NimStringDesc* path);
N_NIMCALL(void, initstrtable_189110)(tstrtable188807* x);
N_NIMCALL(void, strtableadd_197078)(tstrtable188807* t, tsym188833* n);
N_NIMCALL(trodreader236024*, handlesymbolfile_236061)(tsym188833* module);
N_NIMCALL(void, internalerror_165606)(NimStringDesc* errmsg);
static N_INLINE(NI, getid_187402)(void);
N_NIMCALL(void, processmodule_246049)(tsym188833* module, tllstream176204* stream, trodreader236024* rd);
N_NIMCALL(NU8, checkdepmem_524400)(NI32 fileidx);
N_NIMCALL(NIM_BOOL, crcchanged_524102)(NI32 fileidx);
N_NIMCALL(NimStringDesc*, HEX24_165714)(TY79484 x_165718);
N_NIMCALL(void, resetmodule_524357)(NI32 fileidx);
static N_INLINE(void, asgnRef)(void** dest, void* src);
static N_INLINE(void, incref_46827)(tcell41090* c);
static N_INLINE(NIM_BOOL, canbecycleroot_44462)(tcell41090* c);
static N_INLINE(void, rtladdcycleroot_45235)(tcell41090* c);
N_NOINLINE(void, incl_41855)(tcellset41102* s, tcell41090* cell);
static N_INLINE(void, decref_46402)(tcell41090* c);
N_NIMCALL(void, resetsourcemap_360598)(NI32 fileidx);
N_NIMCALL(NIM_BOOL, HEX3DHEX3D_524207)(TY188922* x_524213, TY188922* y_524218);
N_NIMCALL(void, localerror_165571)(tlineinfo163527 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(NI32, fileinfoidx_163721)(NimStringDesc* filename);
N_NIMCALL(NimStringDesc*, HEX2F_108477)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(void, compilesystemmodule_524946)(void);
N_NIMCALL(void, resetpackagecache_137603)(void);
STRING_LITERAL(TMP1788, "handleSymbolFile should have set the module\'s ID", 48);
STRING_LITERAL(TMP1791, "compiler/modules.nim", 20);
NIM_CONST TY79484 TMP1790 = {((NimStringDesc*) &TMP1791),
44}
;
STRING_LITERAL(TMP3842, "system.nim", 10);
STRING_LITERAL(TMP4522, "stdin", 5);
tsymseq188805* gcompiledmodules_524050;
extern TNimType NTI188805; /* TSymSeq */
extern tgcheap43016 gch_43044;
TY524051* gmemcachedata_524072;
TNimType NTI524012; /* TModuleInMemory */
extern TNimType NTI126; /* float */
extern TNimType NTI144007; /* TCrc32 */
extern TNimType NTI188922; /* seq[int32] */
TNimType NTI524008; /* TNeedRecompile */
TNimType NTI524010; /* TCrcStatus */
TNimType NTI524051; /* seq[TModuleInMemory] */
tsym188833* stdinmodule_524976;
extern NU32 gglobaloptions_137111;
extern TNimType NTI188801; /* PSym */
extern TNimType NTI188833; /* TSym */
extern NU8 gcmd_137113;
extern NI gfrontendid_187007;
extern NF glastcmdtime_137124;
extern TY465142* gmodules_465163;
extern NimStringDesc* libpath_137205;
extern tsym188833* systemmodule_242017;
extern NI32 systemfileidx_163641;

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, 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, TMP984)(void* p, NI op) {
	TY524051* a;
	NI LOC1;
	a = (TY524051*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1].Deps, op);
	}
}

N_NIMCALL(void, adddep_524157)(tsym188833* x, NI32 dep) {
	{
		if (!(gmemcachedata_524072->Sup.len <= ((NI) (dep)))) goto LA3;
		gmemcachedata_524072 = (TY524051*) setLengthSeq(&(gmemcachedata_524072)->Sup, sizeof(tmoduleinmemory524012), ((NI) ((NI32)(dep + ((NI32) 1)))));
	}
	LA3: ;
	safeadd_524191(&gmemcachedata_524072->data[(*x).Position].Deps, dep);
}

N_NIMCALL(void, docrc_524143)(NI32 fileidx) {
	{
		NimStringDesc* LOC5;
		if (!(gmemcachedata_524072->data[fileidx].Crcstatus == ((NU8) 0))) goto LA3;
		LOC5 = 0;
		LOC5 = tofilename_164780(fileidx);
		gmemcachedata_524072->data[fileidx].Crc = crcfromfile_144031(LOC5);
	}
	LA3: ;
}

N_NIMCALL(tnode188803*, includemodule_524892)(tsym188833* s, NI32 fileidx) {
	tnode188803* result;
	result = 0;
	result = parsefile_220033(fileidx);
	{
		if (!((gglobaloptions_137111 &(1<<((((NU8) 15))&31)))!=0)) goto LA3;
		{
			if (!(gmemcachedata_524072->Sup.len <= ((NI) (fileidx)))) goto LA7;
			gmemcachedata_524072 = (TY524051*) setLengthSeq(&(gmemcachedata_524072)->Sup, sizeof(tmoduleinmemory524012), ((NI) ((NI32)(fileidx + ((NI32) 1)))));
		}
		LA7: ;
		adddep_524157(s, fileidx);
		docrc_524143(fileidx);
	}
	LA3: ;
	return result;
}

N_NIMCALL(tsym188833*, getmodule_524076)(NI32 fileidx) {
	tsym188833* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (((NI32) 0) <= fileidx);
		if (!(LOC3)) goto LA4;
		LOC3 = (((NI) (fileidx)) < gcompiledmodules_524050->Sup.len);
		LA4: ;
		if (!LOC3) goto LA5;
		result = gcompiledmodules_524050->data[fileidx];
	}
	LA5: ;
	return result;
}

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

N_NIMCALL(tsym188833*, newmodule_524627)(NI32 fileidx) {
	tsym188833* result;
	NimStringDesc* filename;
	TY108700 LOC1;
	NimStringDesc* LOC7;
	tident167019* LOC8;
	result = 0;
	result = (tsym188833*) newObj((&NTI188801), sizeof(tsym188833));
	(*result).Sup.Sup.m_type = (&NTI188833);
	(*result).Sup.Id = -1;
	(*result).Kind = ((NU8) 6);
	filename = tofilename_164780(fileidx);
	memset((void*)&LOC1, 0, sizeof(LOC1));
	nossplitFile(filename, &LOC1);
	asgnRefNoCycle((void**) &(*result).Name, getident_167456(LOC1.Field1));
	{
		NIM_BOOL LOC4;
		LOC4 = 0;
		LOC4 = isnimrodidentifier_180276((*(*result).Name).S);
		if (!!(LOC4)) goto LA5;
		rawmessage_165386(((NU16) 21), (*(*result).Name).S);
	}
	LA5: ;
	(*result).Info = newlineinfo_164069(fileidx, 1, 1);
	LOC7 = 0;
	LOC7 = getpackagename_137811(filename);
	LOC8 = 0;
	LOC8 = getident_167456(LOC7);
	asgnRefNoCycle((void**) &(*result).Owner, newsym_189053(((NU8) 24), LOC8, NIM_NIL, (*result).Info));
	(*result).Position = ((NI) (fileidx));
	{
		if (!(gmemcachedata_524072->Sup.len <= ((NI) (fileidx)))) goto LA11;
		gmemcachedata_524072 = (TY524051*) setLengthSeq(&(gmemcachedata_524072)->Sup, sizeof(tmoduleinmemory524012), ((NI) ((NI32)(fileidx + ((NI32) 1)))));
	}
	LA11: ;
	{
		if (!(gcompiledmodules_524050->Sup.len <= ((NI) (fileidx)))) goto LA15;
		gcompiledmodules_524050 = (tsymseq188805*) setLengthSeq(&(gcompiledmodules_524050)->Sup, sizeof(tsym188833*), ((NI) ((NI32)(fileidx + ((NI32) 1)))));
	}
	LA15: ;
	asgnRefNoCycle((void**) &gcompiledmodules_524050->data[(*result).Position], result);
	(*result).Flags |=((NI32)(1)<<((((NU8) 0))%(sizeof(NI32)*8)));
	initstrtable_189110(&(*result).kindU.S3.Tab);
	strtableadd_197078(&(*result).kindU.S3.Tab, result);
	return result;
}

static N_INLINE(NI, getid_187402)(void) {
	NI result;
	result = 0;
	result = gfrontendid_187007;
	gfrontendid_187007 += 1;
	return result;
}

N_NIMCALL(NIM_BOOL, crcchanged_524102)(NI32 fileidx) {
	NIM_BOOL result;
	result = 0;
	{
		NIM_BOOL LOC3;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = (((NI32) 0) <= fileidx);
		if (!(LOC3)) goto LA4;
		LOC3 = (((NI) (fileidx)) < gmemcachedata_524072->Sup.len);
		LA4: ;
		if (!!(LOC3)) goto LA5;
		LOC7 = 0;
		LOC7 = HEX24_165714(TMP1790);
		internalerror_165606(LOC7);
	}
	LA5: ;
	switch (gmemcachedata_524072->data[fileidx].Crcstatus) {
	case ((NU8) 2):
	{
		result = NIM_TRUE;
	}
	break;
	case ((NU8) 3):
	{
		result = NIM_FALSE;
	}
	break;
	case ((NU8) 1):
	{
		NI32 newcrc;
		NimStringDesc* LOC11;
		LOC11 = 0;
		LOC11 = tofilename_164780(fileidx);
		newcrc = crcfromfile_144031(LOC11);
		result = !((newcrc == gmemcachedata_524072->data[fileidx].Crc));
		gmemcachedata_524072->data[fileidx].Crc = newcrc;
		{
			if (!result) goto LA14;
			gmemcachedata_524072->data[fileidx].Crcstatus = ((NU8) 2);
		}
		goto LA12;
		LA14: ;
		{
			gmemcachedata_524072->data[fileidx].Crcstatus = ((NU8) 3);
		}
		LA12: ;
	}
	break;
	case ((NU8) 0):
	{
		NimStringDesc* LOC18;
		LOC18 = 0;
		LOC18 = tofilename_164780(fileidx);
		gmemcachedata_524072->data[fileidx].Crc = crcfromfile_144031(LOC18);
		result = NIM_TRUE;
		{
			if (!result) goto LA21;
			gmemcachedata_524072->data[fileidx].Crcstatus = ((NU8) 2);
		}
		goto LA19;
		LA21: ;
		{
			gmemcachedata_524072->data[fileidx].Crcstatus = ((NU8) 3);
		}
		LA19: ;
	}
	break;
	}
	return result;
}

static N_INLINE(NIM_BOOL, canbecycleroot_44462)(tcell41090* c) {
	NIM_BOOL result;
	result = 0;
	result = !((((*(*c).Typ).flags &(1<<((((NU8) 1))&7)))!=0));
	return result;
}

static N_INLINE(void, rtladdcycleroot_45235)(tcell41090* c) {
	{
		if (!!((((NI) ((NI)((*c).Refcount & 3))) == 3))) goto LA3;
		(*c).Refcount = (NI)((NI)((*c).Refcount & -4) | 3);
		incl_41855(&gch_43044.Cycleroots, c);
	}
	LA3: ;
}

static N_INLINE(void, incref_46827)(tcell41090* c) {
	(*c).Refcount = (NI)((NU32)((*c).Refcount) + (NU32)(8));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = canbecycleroot_44462(c);
		if (!LOC3) goto LA4;
		rtladdcycleroot_45235(c);
	}
	LA4: ;
}

static N_INLINE(void, decref_46402)(tcell41090* c) {
	{
		(*c).Refcount -= 8;
		if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA3;
		rtladdzct_46002(c);
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC6;
		LOC6 = 0;
		LOC6 = canbecycleroot_44462(c);
		if (!LOC6) goto LA7;
		rtladdcycleroot_45235(c);
	}
	goto LA1;
	LA7: ;
	LA1: ;
}

static N_INLINE(void, asgnRef)(void** dest, void* src) {
	{
		tcell41090* LOC5;
		if (!!((src == NIM_NIL))) goto LA3;
		LOC5 = 0;
		LOC5 = usrtocell_44443(src);
		incref_46827(LOC5);
	}
	LA3: ;
	{
		tcell41090* LOC10;
		if (!!(((*dest) == NIM_NIL))) goto LA8;
		LOC10 = 0;
		LOC10 = usrtocell_44443((*dest));
		decref_46402(LOC10);
	}
	LA8: ;
	(*dest) = src;
}

N_NIMCALL(void, resetmodule_524357)(NI32 fileidx) {
	gmemcachedata_524072->data[fileidx].Needsrecompile = ((NU8) 2);
	asgnRefNoCycle((void**) &gcompiledmodules_524050->data[fileidx], NIM_NIL);
	asgnRef((void**) &gmodules_465163->data[fileidx], NIM_NIL);
	resetsourcemap_360598(fileidx);
}

N_NIMCALL(NU8, checkdepmem_524400)(NI32 fileidx) {
	NU8 result;
	result = 0;
	{
		if (!!((gmemcachedata_524072->data[fileidx].Needsrecompile == ((NU8) 0)))) goto LA3;
		result = gmemcachedata_524072->data[fileidx].Needsrecompile;
		goto BeforeRet;
	}
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = ((gglobaloptions_137111 &(1<<((((NU8) 1))&31)))!=0);
		if (LOC7) goto LA8;
		LOC7 = crcchanged_524102(fileidx);
		LA8: ;
		if (!LOC7) goto LA9;
		resetmodule_524357(fileidx);
		result = ((NU8) 2);
		goto BeforeRet;
	}
	LA9: ;
	{
		NIM_BOOL LOC13;
		NI32 dep_524603;
		TY188922* HEX3Atmp_524619;
		NI i_524621;
		NI l_524623;
		LOC13 = 0;
		LOC13 = HEX3DHEX3D_524207(gmemcachedata_524072->data[fileidx].Deps, NIM_NIL);
		if (!!(LOC13)) goto LA14;
		gmemcachedata_524072->data[fileidx].Needsrecompile = ((NU8) 3);
		dep_524603 = 0;
		HEX3Atmp_524619 = 0;
		HEX3Atmp_524619 = gmemcachedata_524072->data[fileidx].Deps;
		i_524621 = 0;
		l_524623 = HEX3Atmp_524619->Sup.len;
		while (1) {
			NU8 d;
			if (!(i_524621 < l_524623)) goto LA16;
			dep_524603 = HEX3Atmp_524619->data[i_524621];
			d = checkdepmem_524400(dep_524603);
			{
				if (!((20 &(1<<((d)&7)))!=0)) goto LA19;
				resetmodule_524357(fileidx);
				result = ((NU8) 2);
				goto BeforeRet;
			}
			LA19: ;
			i_524621 += 1;
		} LA16: ;
	}
	LA14: ;
	gmemcachedata_524072->data[fileidx].Needsrecompile = ((NU8) 1);
	result = ((NU8) 1);
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(tsym188833*, compilemodule_524750)(NI32 fileidx, NU32 flags) {
	tsym188833* result;
	result = 0;
	result = getmodule_524076(fileidx);
	{
		trodreader236024* rd;
		if (!(result == NIM_NIL)) goto LA3;
		{
			if (!(gmemcachedata_524072->Sup.len <= ((NI) (fileidx)))) goto LA7;
			gmemcachedata_524072 = (TY524051*) setLengthSeq(&(gmemcachedata_524072)->Sup, sizeof(tmoduleinmemory524012), ((NI) ((NI32)(fileidx + ((NI32) 1)))));
		}
		LA7: ;
		gmemcachedata_524072->data[fileidx].Needsrecompile = ((NU8) 3);
		result = newmodule_524627(fileidx);
		rd = 0;
		(*result).Flags = ((*result).Flags | flags);
		{
			if (!((18438 &(1<<((gcmd_137113)&31)))!=0)) goto LA11;
			rd = handlesymbolfile_236061(result);
			{
				if (!((*result).Sup.Id < 0)) goto LA15;
				internalerror_165606(((NimStringDesc*) &TMP1788));
				goto BeforeRet;
			}
			LA15: ;
		}
		goto LA9;
		LA11: ;
		{
			(*result).Sup.Id = getid_187402();
		}
		LA9: ;
		processmodule_246049(result, NIM_NIL, rd);
		{
			if (!((gglobaloptions_137111 &(1<<((((NU8) 15))&31)))!=0)) goto LA20;
			gmemcachedata_524072->data[fileidx].Compiledat = glastcmdtime_137124;
			gmemcachedata_524072->data[fileidx].Needsrecompile = ((NU8) 4);
			docrc_524143(fileidx);
		}
		LA20: ;
	}
	goto LA1;
	LA3: ;
	{
		{
			NU8 LOC25;
			LOC25 = 0;
			LOC25 = checkdepmem_524400(fileidx);
			if (!(LOC25 == ((NU8) 2))) goto LA26;
			result = compilemodule_524750(fileidx, flags);
		}
		goto LA23;
		LA26: ;
		{
			result = gcompiledmodules_524050->data[fileidx];
		}
		LA23: ;
	}
	LA1: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(tsym188833*, importmodule_524857)(tsym188833* s, NI32 fileidx) {
	tsym188833* result;
	result = 0;
	result = compilemodule_524750(fileidx, 0);
	{
		if (!((gglobaloptions_137111 &(1<<((((NU8) 15))&31)))!=0)) goto LA3;
		adddep_524157(s, fileidx);
	}
	LA3: ;
	{
		if (!(((*result).Flags &(1<<((((NU8) 13))&31)))!=0)) goto LA7;
		localerror_165571((*result).Info, ((NU16) 40), (*(*result).Name).S);
	}
	LA7: ;
	return result;
}

N_NIMCALL(void, compilesystemmodule_524946)(void) {
	{
		NimStringDesc* LOC5;
		tsym188833* LOC6;
		if (!(systemmodule_242017 == NIM_NIL)) goto LA3;
		LOC5 = 0;
		LOC5 = HEX2F_108477(libpath_137205, ((NimStringDesc*) &TMP3842));
		systemfileidx_163641 = fileinfoidx_163721(LOC5);
		LOC6 = 0;
		LOC6 = compilemodule_524750(systemfileidx_163641, 8192);
	}
	LA3: ;
}

N_NIMCALL(void, compileproject_524968)(NI32 projectfile) {
	NI32 systemfileidx;
	NimStringDesc* LOC1;
	LOC1 = 0;
	LOC1 = HEX2F_108477(libpath_137205, ((NimStringDesc*) &TMP3842));
	systemfileidx = fileinfoidx_163721(LOC1);
	{
		tsym188833* LOC6;
		if (!(projectfile == systemfileidx)) goto LA4;
		LOC6 = 0;
		LOC6 = compilemodule_524750(projectfile, 12288);
	}
	goto LA2;
	LA4: ;
	{
		tsym188833* LOC8;
		compilesystemmodule_524946();
		LOC8 = 0;
		LOC8 = compilemodule_524750(projectfile, 4096);
	}
	LA2: ;
}

N_NIMCALL(tsym188833*, makestdinmodule_524979)(void) {
	tsym188833* result;
	result = 0;
	{
		NI32 LOC5;
		if (!(stdinmodule_524976 == NIM_NIL)) goto LA3;
		LOC5 = 0;
		LOC5 = fileinfoidx_163721(((NimStringDesc*) &TMP4522));
		asgnRefNoCycle((void**) &stdinmodule_524976, newmodule_524627(LOC5));
		(*stdinmodule_524976).Sup.Id = getid_187402();
	}
	LA3: ;
	result = stdinmodule_524976;
	return result;
}

N_NIMCALL(void, resetallmodules_524362)(void) {
	NI i_524374;
	NI HEX3Atmp_524393;
	NI res_524395;
	i_524374 = 0;
	HEX3Atmp_524393 = 0;
	HEX3Atmp_524393 = (gcompiledmodules_524050->Sup.len-1);
	res_524395 = 0;
	while (1) {
		if (!(res_524395 <= HEX3Atmp_524393)) goto LA1;
		i_524374 = res_524395;
		{
			if (!!((gcompiledmodules_524050->data[i_524374] == NIM_NIL))) goto LA4;
			resetmodule_524357(((NI32) (i_524374)));
		}
		LA4: ;
		res_524395 += 1;
	} LA1: ;
	resetpackagecache_137603();
}
N_NOINLINE(void, modulesInit)(void) {
	if (gcompiledmodules_524050) nimGCunrefNoCycle(gcompiledmodules_524050);
	gcompiledmodules_524050 = (tsymseq188805*) newSeqRC1((&NTI188805), 0);
	if (gmemcachedata_524072) nimGCunrefNoCycle(gmemcachedata_524072);
	gmemcachedata_524072 = (TY524051*) newSeqRC1((&NTI524051), 0);
}

N_NOINLINE(void, modulesDatInit)(void) {
static TNimNode* TMP977[5];
static TNimNode* TMP978[5];
NI TMP980;
static char* NIM_CONST TMP979[5] = {
"Maybe", 
"No", 
"Yes", 
"Probing", 
"Recompiled"};
static TNimNode* TMP981[4];
NI TMP983;
static char* NIM_CONST TMP982[4] = {
"crcNotTaken", 
"crcCached", 
"crcHasChanged", 
"crcNotChanged"};
static TNimNode TMP975[17];
NTI524012.size = sizeof(tmoduleinmemory524012);
NTI524012.kind = 18;
NTI524012.base = 0;
NTI524012.flags = 2;
TMP977[0] = &TMP975[1];
TMP975[1].kind = 1;
TMP975[1].offset = offsetof(tmoduleinmemory524012, Compiledat);
TMP975[1].typ = (&NTI126);
TMP975[1].name = "compiledAt";
TMP977[1] = &TMP975[2];
TMP975[2].kind = 1;
TMP975[2].offset = offsetof(tmoduleinmemory524012, Crc);
TMP975[2].typ = (&NTI144007);
TMP975[2].name = "crc";
TMP977[2] = &TMP975[3];
TMP975[3].kind = 1;
TMP975[3].offset = offsetof(tmoduleinmemory524012, Deps);
TMP975[3].typ = (&NTI188922);
TMP975[3].name = "deps";
TMP977[3] = &TMP975[4];
NTI524008.size = sizeof(NU8);
NTI524008.kind = 14;
NTI524008.base = 0;
NTI524008.flags = 3;
for (TMP980 = 0; TMP980 < 5; TMP980++) {
TMP975[TMP980+5].kind = 1;
TMP975[TMP980+5].offset = TMP980;
TMP975[TMP980+5].name = TMP979[TMP980];
TMP978[TMP980] = &TMP975[TMP980+5];
}
TMP975[10].len = 5; TMP975[10].kind = 2; TMP975[10].sons = &TMP978[0];
NTI524008.node = &TMP975[10];
TMP975[4].kind = 1;
TMP975[4].offset = offsetof(tmoduleinmemory524012, Needsrecompile);
TMP975[4].typ = (&NTI524008);
TMP975[4].name = "needsRecompile";
TMP977[4] = &TMP975[11];
NTI524010.size = sizeof(NU8);
NTI524010.kind = 14;
NTI524010.base = 0;
NTI524010.flags = 3;
for (TMP983 = 0; TMP983 < 4; TMP983++) {
TMP975[TMP983+12].kind = 1;
TMP975[TMP983+12].offset = TMP983;
TMP975[TMP983+12].name = TMP982[TMP983];
TMP981[TMP983] = &TMP975[TMP983+12];
}
TMP975[16].len = 4; TMP975[16].kind = 2; TMP975[16].sons = &TMP981[0];
NTI524010.node = &TMP975[16];
TMP975[11].kind = 1;
TMP975[11].offset = offsetof(tmoduleinmemory524012, Crcstatus);
TMP975[11].typ = (&NTI524010);
TMP975[11].name = "crcStatus";
TMP975[0].len = 5; TMP975[0].kind = 2; TMP975[0].sons = &TMP977[0];
NTI524012.node = &TMP975[0];
NTI524051.size = sizeof(TY524051*);
NTI524051.kind = 24;
NTI524051.base = (&NTI524012);
NTI524051.flags = 2;
NTI524051.marker = TMP984;
}

