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

#include <string.h>

#include <glob.h>

#include <setjmp.h>

#include <stdio.h>

#include <stdlib.h>
typedef struct tlinkedlist118023 tlinkedlist118023;
typedef struct tlistentry118017 tlistentry118017;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tcell41090 tcell41090;
typedef struct TNimType TNimType;
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 tstringtable121810 tstringtable121810;
typedef struct TNimNode TNimNode;
typedef struct TY110805 TY110805;
typedef struct tkeyvaluepair121806 tkeyvaluepair121806;
typedef struct tstrentry118019 tstrentry118019;
typedef struct TNimObject TNimObject;
typedef struct TY108700 TY108700;
typedef struct E_Base E_Base;
typedef struct TSafePoint TSafePoint;
typedef struct tbasechunk22636 tbasechunk22636;
typedef struct tfreecell22628 tfreecell22628;
typedef struct tkeyvaluepairseq121808 tkeyvaluepairseq121808;
struct  tlinkedlist118023  {
tlistentry118017* Head;
tlistentry118017* Tail;
NI Counter;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
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;
};
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 tkeyvaluepair121806 {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tlistentry118017  {
  TNimObject Sup;
tlistentry118017* Prev;
tlistentry118017* Next;
};
struct  tstrentry118019  {
  tlistentry118017 Sup;
NimStringDesc* Data;
};
typedef NimStringDesc* TY137892[2];
struct TY108700 {
NimStringDesc* Field0;
NimStringDesc* Field1;
NimStringDesc* Field2;
};
struct  E_Base  {
  TNimObject Sup;
E_Base* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
typedef struct {
N_NIMCALL_PTR(NIM_BOOL, ClPrc) (E_Base* e, void* ClEnv);
void* ClEnv;
} TY11626;
struct  TSafePoint  {
TSafePoint* prev;
NI status;
jmp_buf context;
NIM_BOOL hasRaiseAction;
TY11626 raiseAction;
};
typedef NimStringDesc* TY165002[1];
typedef NU8 TY90161[32];
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  tstringtable121810  {
  TNimObject Sup;
NI Counter;
tkeyvaluepairseq121808* Data;
NU8 Mode;
};
struct  tfreecell22628  {
tfreecell22628* Next;
NI Zerofield;
};
struct TY110805 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
struct tkeyvaluepairseq121808 {
  TGenericSeq Sup;
  tkeyvaluepair121806 data[SEQ_DECL_SIZE];
};
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
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(tstringtable121810*, nstnewStringTable)(NU8 mode);
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*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(void, nossplitPath)(NimStringDesc* path, tkeyvaluepair121806* Result);
N_NIMCALL(NimStringDesc*, nosgetAppDir)(void);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_70624, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
N_NIMCALL(NimStringDesc*, rawfindfile_138266)(NimStringDesc* f);
N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(NIM_BOOL, nosexistsFile)(NimStringDesc* filename);
N_NIMCALL(NimStringDesc*, canonicalizepath_137335)(NimStringDesc* path);
N_NIMCALL(NimStringDesc*, nosexpandFilename)(NimStringDesc* filename);
N_NIMCALL(NimStringDesc*, nsuToLowerStr)(NimStringDesc* s);
N_NIMCALL(NimStringDesc*, rawfindfile2_138278)(NimStringDesc* f);
N_NIMCALL(void, bringtofront_118741)(tlinkedlist118023* list, tlistentry118017* entry);
N_NIMCALL(NimStringDesc*, nosjoinPathOpenArray)(NimStringDesc** parts, NI partsLen0);
N_NIMCALL(NimStringDesc*, getgeneratedpath_137417)(void);
N_NIMCALL(NimStringDesc*, HEX2F_108477)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(NimStringDesc*, shortendir_137403)(NimStringDesc* dir);
N_NIMCALL(NimStringDesc*, getprefixdir_137330)(void);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(NIM_BOOL, nsuStartsWith)(NimStringDesc* s, NimStringDesc* prefix);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(NimStringDesc*, noschangeFileExt)(NimStringDesc* filename, NimStringDesc* ext);
N_NIMCALL(NimStringDesc*, getpackagename_137811)(NimStringDesc* path);
N_NIMCALL(NimStringDesc*, nosparentDir)(NimStringDesc* path);
N_NIMCALL(NIM_BOOL, nsthasKey)(tstringtable121810* t, NimStringDesc* key);
N_NIMCALL(NimStringDesc*, nstGet)(tstringtable121810* t, NimStringDesc* key);
N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
N_NIMCALL(void, nossplitFile)(NimStringDesc* path, TY108700* Result);
N_NIMCALL(void, nstPut)(tstringtable121810* t, NimStringDesc* key, NimStringDesc* val);
static N_INLINE(void, pushSafePoint)(TSafePoint* s);
N_NIMCALL(void, noscreateDir)(NimStringDesc* dir);
static N_INLINE(void, popSafePoint)(void);
N_NIMCALL(NIM_BOOL, isObj)(TNimType* obj, TNimType* subclass);
static N_INLINE(E_Base*, getCurrentException)(void);
static N_INLINE(void, writeln_138205)(FILE* f_138209, NimStringDesc** x_138213, NI x_138213Len0);
N_NIMCALL(void, write_10463)(FILE* f, NimStringDesc* s);
static N_INLINE(void, popCurrentException)(void);
N_NIMCALL(void, reraiseException)(void);
N_NIMCALL(NimStringDesc*, canondynlibname_138360)(NimStringDesc* s);
N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY90161 chars, NI start);
N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename, NimStringDesc* ext);
N_NIMCALL(NimStringDesc*, findfile_138306)(NimStringDesc* f);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
N_NIMCALL(void, libcandidates_138321)(NimStringDesc* s, TY110805** dest);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
STRING_LITERAL(TMP39, "", 0);
STRING_LITERAL(TMP1175, "nimcache", 8);
STRING_LITERAL(TMP1176, "*.babel", 7);
STRING_LITERAL(TMP1285, "\012", 1);
STRING_LITERAL(TMP1286, "cannot create directory: ", 25);
STRING_LITERAL(TMP1370, "lib", 3);
static NIM_CONST TY90161 TMP1371 = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
;
STRING_LITERAL(TMP1372, "true", 4);
STRING_LITERAL(TMP1747, "nim", 3);
NU32 goptions_137108;
NU32 gglobaloptions_137111;
NI8 gexitcode_137112;
NU8 gcmd_137113;
NU8 gselectedgc_137114;
tlinkedlist118023 searchpaths_137115;
tlinkedlist118023 lazypaths_137116;
NimStringDesc* outfile_137117;
extern tgcheap43016 gch_43044;
NimStringDesc* docseesrcurl_137118;
NimStringDesc* headerfile_137119;
NI gverbosity_137120;
NI gnumberofprocessors_137121;
NIM_BOOL gwholeproject_137122;
NimStringDesc* gevalexpr_137123;
NF glastcmdtime_137124;
NIM_BOOL glistfullpaths_137125;
NIM_BOOL isserving_137126;
NI32 gdirtybufferidx_137127;
NI32 gdirtyoriginalidx_137128;
NIM_BOOL gnobabelpath_137129;
tstringtable121810* gconfigvars_137203;
tstringtable121810* gdlloverrides_137204;
NimStringDesc* libpath_137205;
NimStringDesc* gprojectname_137206;
NimStringDesc* gprojectpath_137207;
NimStringDesc* gprojectfull_137208;
NI32 gprojectmainidx_137209;
NimStringDesc* optmainmodule_137210;
NimStringDesc* nimcachedir_137211;
NimStringDesc* command_137212;
TY110805* commandargs_137234;
extern TNimType NTI110805; /* seq[string] */
NIM_BOOL gkeepcomments_137235;
TY110805* implicitimports_137257;
TY110805* implicitincludes_137279;
tstringtable121810* packagecache_137601;
TNimType NTI137010; /* TOption */
TNimType NTI137012; /* TOptions */
extern TSafePoint* exchandler_13039;
extern TNimType NTI2435; /* EOS */
extern E_Base* currexception_13041;

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

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(NimStringDesc*, getprefixdir_137330)(void) {
	NimStringDesc* result;
	NimStringDesc* LOC1;
	tkeyvaluepair121806 LOC2;
	result = 0;
	LOC1 = 0;
	LOC1 = nosgetAppDir();
	memset((void*)&LOC2, 0, sizeof(LOC2));
	nossplitPath(LOC1, &LOC2);
	result = copyString(LOC2.Field0);
	return result;
}

N_NIMCALL(NimStringDesc*, removetrailingdirsep_137410)(NimStringDesc* path) {
	NimStringDesc* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (0 < path->Sup.len);
		if (!(LOC3)) goto LA4;
		LOC3 = ((NU8)(path->data[(NI32)(path->Sup.len - 1)]) == (NU8)(47));
		LA4: ;
		if (!LOC3) goto LA5;
		result = copyStrLast(path, 0, (NI32)(path->Sup.len - 2));
	}
	goto LA1;
	LA5: ;
	{
		result = copyString(path);
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, canonicalizepath_137335)(NimStringDesc* path) {
	NimStringDesc* result;
	result = 0;
	result = nosexpandFilename(path);
	return result;
}

N_NIMCALL(NimStringDesc*, rawfindfile_138266)(NimStringDesc* f) {
	NimStringDesc* result;
	NimStringDesc* it_138270;
	tstrentry118019* it_138274;
	result = 0;
	it_138270 = 0;
	it_138274 = ((tstrentry118019*) (searchpaths_137115.Head));
	while (1) {
		if (!!((it_138274 == NIM_NIL))) goto LA1;
		it_138270 = (*it_138274).Data;
		result = nosjoinPath(it_138270, f);
		{
			NIM_BOOL LOC4;
			LOC4 = 0;
			LOC4 = nosexistsFile(result);
			if (!LOC4) goto LA5;
			result = canonicalizepath_137335(result);
			goto BeforeRet;
		}
		LA5: ;
		it_138274 = ((tstrentry118019*) ((*it_138274).Sup.Next));
	} LA1: ;
	result = copyString(((NimStringDesc*) &TMP39));
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, rawfindfile2_138278)(NimStringDesc* f) {
	NimStringDesc* result;
	tstrentry118019* it;
	result = 0;
	it = ((tstrentry118019*) (lazypaths_137116.Head));
	while (1) {
		if (!!((it == NIM_NIL))) goto LA1;
		result = nosjoinPath((*it).Data, f);
		{
			NIM_BOOL LOC4;
			LOC4 = 0;
			LOC4 = nosexistsFile(result);
			if (!LOC4) goto LA5;
			bringtofront_118741(&lazypaths_137116, &it->Sup);
			result = canonicalizepath_137335(result);
			goto BeforeRet;
		}
		LA5: ;
		it = ((tstrentry118019*) ((*it).Sup.Next));
	} LA1: ;
	result = copyString(((NimStringDesc*) &TMP39));
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, findfile_138306)(NimStringDesc* f) {
	NimStringDesc* result;
	result = 0;
	result = rawfindfile_138266(f);
	{
		NimStringDesc* LOC5;
		if (!(result->Sup.len == 0)) goto LA3;
		LOC5 = 0;
		LOC5 = nsuToLowerStr(f);
		result = rawfindfile_138266(LOC5);
		{
			if (!(result->Sup.len == 0)) goto LA8;
			result = rawfindfile2_138278(f);
			{
				NimStringDesc* LOC14;
				if (!(result->Sup.len == 0)) goto LA12;
				LOC14 = 0;
				LOC14 = nsuToLowerStr(f);
				result = rawfindfile2_138278(LOC14);
			}
			LA12: ;
		}
		LA8: ;
	}
	LA3: ;
	return result;
}

static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	memcpy(((NCSTRING) (&(*dest).data[((*dest).Sup.len)- 0])), ((NCSTRING) ((*src).data)), (NI32)((*src).Sup.len + 1));
	(*dest).Sup.len += (*src).Sup.len;
}

static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c) {
	(*dest).data[((*dest).Sup.len)- 0] = c;
	(*dest).data[((NI32)((*dest).Sup.len + 1))- 0] = 0;
	(*dest).Sup.len += 1;
}

N_NIMCALL(NimStringDesc*, shortendir_137403)(NimStringDesc* dir) {
	NimStringDesc* result;
	NimStringDesc* prefix;
	NimStringDesc* LOC1;
	NimStringDesc* LOC2;
	NimStringDesc* LOC8;
	result = 0;
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = getprefixdir_137330();
	LOC1 = rawNewString(LOC2->Sup.len + 1);
appendString(LOC1, LOC2);
appendChar(LOC1, 47);
	prefix = LOC1;
	{
		NIM_BOOL LOC5;
		LOC5 = 0;
		LOC5 = nsuStartsWith(dir, prefix);
		if (!LOC5) goto LA6;
		result = copyStr(dir, prefix->Sup.len);
		goto BeforeRet;
	}
	LA6: ;
	LOC8 = 0;
	LOC8 = rawNewString(gprojectpath_137207->Sup.len + 1);
appendString(LOC8, gprojectpath_137207);
appendChar(LOC8, 47);
	prefix = LOC8;
	{
		NIM_BOOL LOC11;
		LOC11 = 0;
		LOC11 = nsuStartsWith(dir, prefix);
		if (!LOC11) goto LA12;
		result = copyStr(dir, prefix->Sup.len);
		goto BeforeRet;
	}
	LA12: ;
	result = copyString(dir);
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, getgeneratedpath_137417)(void) {
	NimStringDesc* result;
	result = 0;
	{
		if (!(0 < nimcachedir_137211->Sup.len)) goto LA3;
		result = copyString(nimcachedir_137211);
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* LOC6;
		LOC6 = 0;
		LOC6 = shortendir_137403(gprojectpath_137207);
		result = HEX2F_108477(LOC6, ((NimStringDesc*) &TMP1175));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, togeneratedfile_137883)(NimStringDesc* path, NimStringDesc* ext) {
	NimStringDesc* result;
	tkeyvaluepair121806 LOC1;
	NimStringDesc* head;
	NimStringDesc* tail;
	TY137892 LOC2;
	result = 0;
	memset((void*)&LOC1, 0, sizeof(LOC1));
	nossplitPath(path, &LOC1);
	head = copyString(LOC1.Field0);
	tail = copyString(LOC1.Field1);
	memset((void*)LOC2, 0, sizeof(LOC2));
	LOC2[0] = getgeneratedpath_137417();
	LOC2[1] = noschangeFileExt(tail, ext);
	result = nosjoinPathOpenArray(LOC2, 2);
	return result;
}

N_NIMCALL(NimStringDesc*, getpackagename_137811)(NimStringDesc* path) {
	NimStringDesc* result;
	NI parents;
	NimStringDesc* d_137835;
	NimStringDesc* current_137866;
	result = 0;
	parents = 0;
	{
		NimStringDesc* d_137817;
		NimStringDesc* current_137864;
		d_137817 = 0;
		current_137864 = copyString(path);
		while (1) {
			NimStringDesc* file_137834;
			NimStringDesc* HEX3Atmp_137852;
			glob_t f_137854;
			NI res_137856;
			int LOC12;
			current_137864 = nosparentDir(current_137864);
			{
				if (!(current_137864->Sup.len == 0)) goto LA5;
				goto LA2;
			}
			LA5: ;
			d_137817 = current_137864;
			{
				NIM_BOOL LOC9;
				LOC9 = 0;
				LOC9 = nsthasKey(packagecache_137601, d_137817);
				if (!LOC9) goto LA10;
				result = nstGet(packagecache_137601, d_137817);
				goto BeforeRet;
			}
			LA10: ;
			parents += 1;
			file_137834 = 0;
			HEX3Atmp_137852 = 0;
			HEX3Atmp_137852 = HEX2F_108477(d_137817, ((NimStringDesc*) &TMP1176));
			memset((void*)&f_137854, 0, sizeof(f_137854));
			res_137856 = 0;
			f_137854.gl_offs = 0;
			f_137854.gl_pathc = 0;
			f_137854.gl_pathv = NIM_NIL;
			LOC12 = 0;
			LOC12 = glob(HEX3Atmp_137852->data, ((int) 0), NIM_NIL, &f_137854);
			res_137856 = ((NI) (LOC12));
			{
				NI i_137858;
				NI HEX3Atmp_137860;
				NI res_137862;
				if (!(res_137856 == 0)) goto LA15;
				i_137858 = 0;
				HEX3Atmp_137860 = 0;
				HEX3Atmp_137860 = (NI32)(f_137854.gl_pathc - 1);
				res_137862 = 0;
				while (1) {
					TY108700 LOC18;
					if (!(res_137862 <= HEX3Atmp_137860)) goto LA17;
					i_137858 = res_137862;
					file_137834 = cstrToNimstr(f_137854.gl_pathv[(i_137858)- 0]);
					memset((void*)&LOC18, 0, sizeof(LOC18));
					nossplitFile(file_137834, &LOC18);
					result = copyString(LOC18.Field1);
					goto LA1;
					res_137862 += 1;
				} LA17: ;
			}
			LA15: ;
			globfree(&f_137854);
		} LA2: ;
	} LA1: ;
	{
		if (!result == 0) goto LA21;
		result = copyString(((NimStringDesc*) &TMP39));
	}
	LA21: ;
	d_137835 = 0;
	current_137866 = copyString(path);
	while (1) {
		current_137866 = nosparentDir(current_137866);
		{
			if (!(current_137866->Sup.len == 0)) goto LA26;
			goto LA23;
		}
		LA26: ;
		d_137835 = current_137866;
		nstPut(packagecache_137601, d_137835, result);
		parents -= 1;
		{
			if (!(parents <= 0)) goto LA30;
			goto LA23;
		}
		LA30: ;
	} LA23: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, withpackagename_137873)(NimStringDesc* path) {
	NimStringDesc* result;
	NimStringDesc* x;
	result = 0;
	x = getpackagename_137811(path);
	{
		if (!(x->Sup.len == 0)) goto LA3;
		result = copyString(path);
	}
	goto LA1;
	LA3: ;
	{
		TY108700 LOC6;
		NimStringDesc* p;
		NimStringDesc* file;
		NimStringDesc* ext;
		NimStringDesc* LOC7;
		NimStringDesc* LOC8;
		NimStringDesc* LOC9;
		memset((void*)&LOC6, 0, sizeof(LOC6));
		nossplitFile(path, &LOC6);
		p = LOC6.Field0;
		file = LOC6.Field1;
		ext = LOC6.Field2;
		LOC7 = 0;
		LOC8 = 0;
		LOC8 = rawNewString(x->Sup.len + file->Sup.len + 1);
appendString(LOC8, x);
appendChar(LOC8, 95);
appendString(LOC8, file);
		LOC9 = 0;
		LOC9 = HEX2F_108477(p, LOC8);
		LOC7 = rawNewString(LOC9->Sup.len + ext->Sup.len + 0);
appendString(LOC7, LOC9);
appendString(LOC7, ext);
		result = LOC7;
	}
	LA1: ;
	return result;
}

N_NIMCALL(NIM_BOOL, existsconfigvar_137305)(NimStringDesc* key) {
	NIM_BOOL result;
	result = 0;
	result = nsthasKey(gconfigvars_137203, key);
	return result;
}

N_NIMCALL(NimStringDesc*, getconfigvar_137311)(NimStringDesc* key) {
	NimStringDesc* result;
	result = 0;
	result = nstGet(gconfigvars_137203, key);
	return result;
}

static N_INLINE(void, pushSafePoint)(TSafePoint* s) {
	(*s).hasRaiseAction = NIM_FALSE;
	(*s).prev = exchandler_13039;
	exchandler_13039 = s;
}

static N_INLINE(void, popSafePoint)(void) {
	exchandler_13039 = (*exchandler_13039).prev;
}

static N_INLINE(E_Base*, getCurrentException)(void) {
	E_Base* result;
	result = 0;
	result = currexception_13041;
	return result;
}

static N_INLINE(void, writeln_138205)(FILE* f_138209, NimStringDesc** x_138213, NI x_138213Len0) {
	NimStringDesc* i_138226;
	NI i_138232;
	i_138226 = 0;
	i_138232 = 0;
	while (1) {
		if (!(i_138232 < x_138213Len0)) goto LA1;
		i_138226 = x_138213[i_138232];
		write_10463(f_138209, i_138226);
		i_138232 += 1;
	} LA1: ;
	write_10463(f_138209, ((NimStringDesc*) &TMP1285));
}

static N_INLINE(void, popCurrentException)(void) {
	asgnRef((void**) &currexception_13041, (*currexception_13041).parent);
}

N_NIMCALL(NimStringDesc*, completegeneratedfilepath_138001)(NimStringDesc* f, NIM_BOOL createsubdir) {
	NimStringDesc* result;
	tkeyvaluepair121806 LOC1;
	NimStringDesc* head;
	NimStringDesc* tail;
	NimStringDesc* subdir;
	result = 0;
	memset((void*)&LOC1, 0, sizeof(LOC1));
	nossplitPath(f, &LOC1);
	head = copyString(LOC1.Field0);
	tail = copyString(LOC1.Field1);
	subdir = getgeneratedpath_137417();
	{
		TSafePoint TMP1284;
		if (!createsubdir) goto LA4;
		pushSafePoint(&TMP1284);
		TMP1284.status = setjmp(TMP1284.context);
		if (TMP1284.status == 0) {
			noscreateDir(subdir);
			popSafePoint();
		}
		else {
			popSafePoint();
			if (isObj(getCurrentException()->Sup.m_type, (&NTI2435))) {
				TY165002 LOC9;
				NimStringDesc* LOC10;
				TMP1284.status = 0;
				memset((void*)LOC9, 0, sizeof(LOC9));
				LOC10 = 0;
				LOC10 = rawNewString(subdir->Sup.len + 25);
appendString(LOC10, ((NimStringDesc*) &TMP1286));
appendString(LOC10, subdir);
				LOC9[0] = LOC10;
				writeln_138205(stdout, LOC9, 1);
				exit(1);
				popCurrentException();
			}
		}
		if (TMP1284.status != 0) reraiseException();
	}
	LA4: ;
	result = nosjoinPath(subdir, tail);
	return result;
}

N_NIMCALL(NimStringDesc*, canondynlibname_138360)(NimStringDesc* s) {
	NimStringDesc* result;
	NI start;
	NI ende;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = nsuStartsWith(s, ((NimStringDesc*) &TMP1370));
		if (!LOC3) goto LA4;
		start = 3;
	}
	goto LA1;
	LA4: ;
	{
		start = 0;
	}
	LA1: ;
	ende = nsuFindCharSet(s, TMP1371, 0);
	{
		if (!(0 <= ende)) goto LA9;
		result = copyStrLast(s, start, (NI32)(ende - 1));
	}
	goto LA7;
	LA9: ;
	{
		result = copyStr(s, start);
	}
	LA7: ;
	return result;
}

N_NIMCALL(void, incldynliboverride_138369)(NimStringDesc* lib) {
	NimStringDesc* LOC1;
	LOC1 = 0;
	LOC1 = canondynlibname_138360(lib);
	nstPut(gdlloverrides_137204, LOC1, ((NimStringDesc*) &TMP1372));
}

N_NIMCALL(void, setconfigvar_137317)(NimStringDesc* key, NimStringDesc* val) {
	nstPut(gconfigvars_137203, key, val);
}

N_NIMCALL(NimStringDesc*, findmodule_138312)(NimStringDesc* modulename, NimStringDesc* currentmodule) {
	NimStringDesc* result;
	NimStringDesc* m;
	NimStringDesc* currentpath;
	TY108700 LOC1;
	result = 0;
	m = nosaddFileExt(modulename, ((NimStringDesc*) &TMP1747));
	memset((void*)&LOC1, 0, sizeof(LOC1));
	nossplitFile(currentmodule, &LOC1);
	currentpath = LOC1.Field0;
	result = HEX2F_108477(currentpath, m);
	{
		NIM_BOOL LOC4;
		LOC4 = 0;
		LOC4 = nosexistsFile(result);
		if (!!(LOC4)) goto LA5;
		result = findfile_138306(m);
	}
	LA5: ;
	return result;
}

N_NIMCALL(NIM_BOOL, isdynliboverride_138374)(NimStringDesc* lib) {
	NIM_BOOL result;
	NimStringDesc* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = canondynlibname_138360(lib);
	result = nsthasKey(gdlloverrides_137204, LOC1);
	return result;
}

N_NIMCALL(void, libcandidates_138321)(NimStringDesc* s, TY110805** dest) {
	NI le;
	NI ri;
	le = nsuFindChar(s, 40, 0);
	ri = nsuFindChar(s, 41, (NI32)(le + 1));
	{
		NIM_BOOL LOC3;
		NimStringDesc* prefix;
		NimStringDesc* suffix;
		NimStringDesc* middle_138332;
		NimStringDesc* HEX3Atmp_138351;
		NI last_138353;
		LOC3 = 0;
		LOC3 = (0 <= le);
		if (!(LOC3)) goto LA4;
		LOC3 = (le < ri);
		LA4: ;
		if (!LOC3) goto LA5;
		prefix = copyStrLast(s, 0, (NI32)(le - 1));
		suffix = copyStr(s, (NI32)(ri + 1));
		middle_138332 = 0;
		HEX3Atmp_138351 = 0;
		HEX3Atmp_138351 = copyStrLast(s, (NI32)(le + 1), (NI32)(ri - 1));
		last_138353 = 0;
		{
			if (!(0 < HEX3Atmp_138351->Sup.len)) goto LA9;
			while (1) {
				NI first_138355;
				NimStringDesc* LOC15;
				if (!(last_138353 <= HEX3Atmp_138351->Sup.len)) goto LA11;
				first_138355 = last_138353;
				while (1) {
					NIM_BOOL LOC13;
					LOC13 = 0;
					LOC13 = (last_138353 < HEX3Atmp_138351->Sup.len);
					if (!(LOC13)) goto LA14;
					LOC13 = !(((NU8)(HEX3Atmp_138351->data[last_138353]) == (NU8)(124)));
					LA14: ;
					if (!LOC13) goto LA12;
					last_138353 += 1;
				} LA12: ;
				middle_138332 = copyStrLast(HEX3Atmp_138351, first_138355, (NI32)(last_138353 - 1));
				LOC15 = 0;
				LOC15 = rawNewString(prefix->Sup.len + middle_138332->Sup.len + suffix->Sup.len + 0);
appendString(LOC15, prefix);
appendString(LOC15, middle_138332);
appendString(LOC15, suffix);
				libcandidates_138321(LOC15, dest);
				last_138353 += 1;
			} LA11: ;
		}
		LA9: ;
	}
	goto LA1;
	LA5: ;
	{
		NimStringDesc* LOC17;
		(*dest) = (TY110805*) incrSeq(&((*dest))->Sup, sizeof(NimStringDesc*));
		LOC17 = 0;
		LOC17 = (*dest)->data[(*dest)->Sup.len-1]; (*dest)->data[(*dest)->Sup.len-1] = copyStringRC1(s);
		if (LOC17) nimGCunrefNoCycle(LOC17);
	}
	LA1: ;
}

N_NIMCALL(NimStringDesc*, getoutfile_137323)(NimStringDesc* filename, NimStringDesc* ext) {
	NimStringDesc* result;
	result = 0;
	{
		if (!!(((outfile_137117) && (outfile_137117)->Sup.len == 0))) goto LA3;
		result = copyString(outfile_137117);
	}
	goto LA1;
	LA3: ;
	{
		result = noschangeFileExt(filename, ext);
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, maincommandarg_137288)(void) {
	NimStringDesc* result;
	result = 0;
	{
		if (!(0 < commandargs_137234->Sup.len)) goto LA3;
		result = copyString(commandargs_137234->data[0]);
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(gprojectname_137206);
	}
	LA1: ;
	return result;
}

N_NIMCALL(void, resetpackagecache_137603)(void) {
	asgnRef((void**) &packagecache_137601, nstnewStringTable(((NU8) 1)));
}
N_NOINLINE(void, optionsInit)(void) {
	NimStringDesc* LOC1;
	NimStringDesc* LOC2;
	NimStringDesc* LOC3;
	NimStringDesc* LOC4;
	NimStringDesc* LOC5;
	NimStringDesc* LOC6;
	NimStringDesc* LOC7;
	NimStringDesc* LOC8;
	NimStringDesc* LOC9;
	NimStringDesc* LOC10;
	NimStringDesc* LOC11;
	goptions_137108 = 2202238;
	gglobaloptions_137111 = 0;
	gcmd_137113 = ((NU8) 0);
	gselectedgc_137114 = ((NU8) 3);
	LOC1 = 0;
	LOC1 = outfile_137117; outfile_137117 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	LOC2 = 0;
	LOC2 = docseesrcurl_137118; docseesrcurl_137118 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC2) nimGCunrefNoCycle(LOC2);
	LOC3 = 0;
	LOC3 = headerfile_137119; headerfile_137119 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC3) nimGCunrefNoCycle(LOC3);
	gverbosity_137120 = 1;
	LOC4 = 0;
	LOC4 = gevalexpr_137123; gevalexpr_137123 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC4) nimGCunrefNoCycle(LOC4);
	isserving_137126 = NIM_FALSE;
	gdirtybufferidx_137127 = ((NI32) 0);
	gdirtyoriginalidx_137128 = ((NI32) 0);
	gnobabelpath_137129 = NIM_FALSE;
	asgnRef((void**) &gconfigvars_137203, nstnewStringTable(((NU8) 2)));
	asgnRef((void**) &gdlloverrides_137204, nstnewStringTable(((NU8) 1)));
	LOC5 = 0;
	LOC5 = libpath_137205; libpath_137205 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC5) nimGCunrefNoCycle(LOC5);
	LOC6 = 0;
	LOC6 = gprojectname_137206; gprojectname_137206 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC6) nimGCunrefNoCycle(LOC6);
	LOC7 = 0;
	LOC7 = gprojectpath_137207; gprojectpath_137207 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC7) nimGCunrefNoCycle(LOC7);
	LOC8 = 0;
	LOC8 = gprojectfull_137208; gprojectfull_137208 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC8) nimGCunrefNoCycle(LOC8);
	LOC9 = 0;
	LOC9 = optmainmodule_137210; optmainmodule_137210 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC9) nimGCunrefNoCycle(LOC9);
	LOC10 = 0;
	LOC10 = nimcachedir_137211; nimcachedir_137211 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC10) nimGCunrefNoCycle(LOC10);
	LOC11 = 0;
	LOC11 = command_137212; command_137212 = copyStringRC1(((NimStringDesc*) &TMP39));
	if (LOC11) nimGCunrefNoCycle(LOC11);
	if (commandargs_137234) nimGCunrefNoCycle(commandargs_137234);
	commandargs_137234 = (TY110805*) newSeqRC1((&NTI110805), 0);
	gkeepcomments_137235 = NIM_TRUE;
	if (implicitimports_137257) nimGCunrefNoCycle(implicitimports_137257);
	implicitimports_137257 = (TY110805*) newSeqRC1((&NTI110805), 0);
	if (implicitincludes_137279) nimGCunrefNoCycle(implicitincludes_137279);
	implicitincludes_137279 = (TY110805*) newSeqRC1((&NTI110805), 0);
	asgnRef((void**) &packagecache_137601, nstnewStringTable(((NU8) 1)));
}

N_NOINLINE(void, optionsDatInit)(void) {
static TNimNode* TMP754[22];
NI TMP756;
static char* NIM_CONST TMP755[22] = {
"optNone", 
"optObjCheck", 
"optFieldCheck", 
"optRangeCheck", 
"optBoundsCheck", 
"optOverflowCheck", 
"optNilCheck", 
"optNaNCheck", 
"optInfCheck", 
"optAssert", 
"optLineDir", 
"optWarns", 
"optHints", 
"optOptimizeSpeed", 
"optOptimizeSize", 
"optStackTrace", 
"optLineTrace", 
"optEndb", 
"optByRef", 
"optProfiler", 
"optImplicitStatic", 
"optPatterns"};
static TNimNode TMP21[24];
NTI137010.size = sizeof(NU8);
NTI137010.kind = 14;
NTI137010.base = 0;
NTI137010.flags = 3;
for (TMP756 = 0; TMP756 < 22; TMP756++) {
TMP21[TMP756+0].kind = 1;
TMP21[TMP756+0].offset = TMP756;
TMP21[TMP756+0].name = TMP755[TMP756];
TMP754[TMP756] = &TMP21[TMP756+0];
}
TMP21[22].len = 22; TMP21[22].kind = 2; TMP21[22].sons = &TMP754[0];
NTI137010.node = &TMP21[22];
NTI137012.size = sizeof(NU32);
NTI137012.kind = 19;
NTI137012.base = (&NTI137010);
NTI137012.flags = 3;
TMP21[23].len = 0; TMP21[23].kind = 0;
NTI137012.node = &TMP21[23];
}

