/* Generated by Nim Compiler v0.11.2 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 64
#include "nimbase.h"

#include <string.h>

#include <stdlib.h>

#include <time.h>
typedef struct TY123008 TY123008;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Keyvaluepair136008 Keyvaluepair136008;
typedef struct Oserror3433 Oserror3433;
typedef struct Systemerror3429 Systemerror3429;
typedef struct Exception Exception;
typedef struct TNimObject TNimObject;
typedef struct Tcell46346 Tcell46346;
typedef struct Tcellseq46362 Tcellseq46362;
typedef struct Tgcheap48216 Tgcheap48216;
typedef struct Tcellset46358 Tcellset46358;
typedef struct Tpagedesc46354 Tpagedesc46354;
typedef struct Tmemregion28210 Tmemregion28210;
typedef struct Tsmallchunk27440 Tsmallchunk27440;
typedef struct Tllchunk28204 Tllchunk28204;
typedef struct Tbigchunk27442 Tbigchunk27442;
typedef struct Tintset27417 Tintset27417;
typedef struct Ttrunk27413 Ttrunk27413;
typedef struct Tavlnode28208 Tavlnode28208;
typedef struct Tgcstat48214 Tgcstat48214;
typedef struct TY118789 TY118789;
typedef struct Twin32finddata105219 Twin32finddata105219;
typedef struct Tfiletime104248 Tfiletime104248;
typedef struct Slice87574 Slice87574;
typedef struct Tbasechunk27438 Tbasechunk27438;
typedef struct Tfreecell27430 Tfreecell27430;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY3289) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3294) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3289 marker;
TY3294 deepcopy;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct Keyvaluepair136008 {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Exception  {
  TNimObject Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  Systemerror3429  {
  Exception Sup;
};
struct  Oserror3433  {
  Systemerror3429 Sup;
NI32 errorcode;
};
typedef N_STDCALL_PTR(NI32, TY104663) (NI32 dwflags, void* lpsource, NI32 dwmessageid, NI32 dwlanguageid, void* lpbuffer, NI32 nsize, void* Arguments);
typedef N_STDCALL_PTR(void, TY104805) (void* p);
struct  Tcell46346  {
NI refcount;
TNimType* typ;
};
struct  Tcellseq46362  {
NI len;
NI cap;
Tcell46346** d;
};
struct  Tcellset46358  {
NI counter;
NI max;
Tpagedesc46354* head;
Tpagedesc46354** data;
};
typedef Tsmallchunk27440* TY28222[512];
typedef Ttrunk27413* Ttrunkbuckets27415[256];
struct  Tintset27417  {
Ttrunkbuckets27415 data;
};
struct  Tmemregion28210  {
NI minlargeobj;
NI maxlargeobj;
TY28222 freesmallchunks;
Tllchunk28204* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Tbigchunk27442* freechunkslist;
Tintset27417 chunkstarts;
Tavlnode28208* root;
Tavlnode28208* deleted;
Tavlnode28208* last;
Tavlnode28208* freeavlnodes;
};
struct  Tgcstat48214  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Tgcheap48216  {
void* stackbottom;
NI cyclethreshold;
Tcellseq46362 zct;
Tcellseq46362 decstack;
Tcellset46358 cycleroots;
Tcellseq46362 tempstack;
NI recgclock;
Tmemregion28210 region;
Tgcstat48214 stat;
};
typedef N_STDCALL_PTR(NI32, TY104658) (void);
typedef N_STDCALL_PTR(NI32, TY105411) (NI16* lpfilename, NI32 nbufferlength, NI16* lpbuffer, NI16** lpfilepart);
struct TY118789 {
NimStringDesc* Field0;
NimStringDesc* Field1;
NimStringDesc* Field2;
};
typedef N_STDCALL_PTR(NI32, TY104829) (NI handle, NI16* buf, NI32 size);
typedef N_STDCALL_PTR(NI, TY105240) (NI16* lpfilename, Twin32finddata105219* lpfindfiledata);
typedef N_STDCALL_PTR(NI32, TY104818) (NI16* pathname, void* security);
typedef N_STDCALL_PTR(NI32, TY105418) (NI16* lpfilename);
typedef N_STDCALL_PTR(NI16*, TY105440) (void);
typedef N_STDCALL_PTR(NI16*, TY105435) (void);
typedef N_STDCALL_PTR(NI32, TY105437) (NI16* para1);
typedef N_STDCALL_PTR(NI32, TY104825) (NI16* lpname, NI16* lpvalue);
typedef N_STDCALL_PTR(NI32, TY104811) (NI32 nbufferlength, NI16* lpbuffer);
struct  Tfiletime104248  {
NI32 dwlowdatetime;
NI32 dwhighdatetime;
};
typedef NI16 TY105228[260];
typedef NI16 TY105232[14];
struct  Twin32finddata105219  {
NI32 dwfileattributes;
Tfiletime104248 ftcreationtime;
Tfiletime104248 ftlastaccesstime;
Tfiletime104248 ftlastwritetime;
NI32 nfilesizehigh;
NI32 nfilesizelow;
NI32 dwreserved0;
NI32 dwreserved1;
TY105228 cfilename;
TY105232 calternatefilename;
};
typedef N_STDCALL_PTR(void, TY105405) (NI hfindfile);
typedef N_STDCALL_PTR(void, TY105632) (NI32 dwmilliseconds);
struct  Slice87574  {
NI a;
NI b;
};
typedef NI TY27420[8];
struct  Tpagedesc46354  {
Tpagedesc46354* next;
NI key;
TY27420 bits;
};
struct  Tbasechunk27438  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Tsmallchunk27440  {
  Tbasechunk27438 Sup;
Tsmallchunk27440* next;
Tsmallchunk27440* prev;
Tfreecell27430* freelist;
NI free;
NI acc;
NF data;
};
struct  Tllchunk28204  {
NI size;
NI acc;
Tllchunk28204* next;
};
struct  Tbigchunk27442  {
  Tbasechunk27438 Sup;
Tbigchunk27442* next;
Tbigchunk27442* prev;
NI align;
NF data;
};
struct  Ttrunk27413  {
Ttrunk27413* next;
NI key;
TY27420 bits;
};
typedef Tavlnode28208* TY28214[2];
struct  Tavlnode28208  {
TY28214 link;
NI key;
NI upperbound;
NI level;
};
struct  Tfreecell27430  {
Tfreecell27430* next;
NI zerofield;
};
struct TY123008 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP54)(void* p, NI op);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(void, nossplitPath)(NimStringDesc* path, Keyvaluepair136008* Result);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_76243, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(NI, searchextpos_118736)(NimStringDesc* s);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, normext_118726)(NimStringDesc* ext);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(NimStringDesc*, oserrormsg_114020)(NI32 errorcode);
N_NIMCALL(NimStringDesc*, HEX24_80989)(NI16* s);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Tcell46346*, usrtocell_49846)(void* usr);
static N_INLINE(void, rtladdzct_51404)(Tcell46346* c);
N_NOINLINE(void, addzct_49817)(Tcellseq46362* s, Tcell46346* c);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
N_NIMCALL(void, raiseException)(Exception* e, NCSTRING ename);
N_NIMCALL(NI16*, newwidecstring_80621)(NCSTRING source, NI L);
N_NIMCALL(NI16*, newwidecstring_80805)(NimStringDesc* s);
N_NIMCALL(void, raiseoserror_114430)(NI32 errorcode);
N_NIMCALL(NI32, oslasterror_114454)(void);
N_NIMCALL(NimStringDesc*, HEX24_80812)(NI16* w, NI estimate);
N_NIMCALL(void, nossplitFile)(NimStringDesc* path, TY118789* Result);
N_NIMCALL(NimStringDesc*, nosgetAppFilename)(void);
N_NOCONV(void*, alloc_6001)(NI size);
N_NIMCALL(NI, parentdirpos_118559)(NimStringDesc* path);
N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(NIM_BOOL, nosisAbsolute)(NimStringDesc* path);
N_NIMCALL(void, rawcreatedir_125041)(NimStringDesc* dir);
N_NIMCALL(TY123008*, nosparseCmdLine)(NimStringDesc* c);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newlen);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_NIMCALL(NimStringDesc*, getenv_123843)(NimStringDesc* key);
N_NIMCALL(NI, findenvvar_123804)(NimStringDesc* key);
N_NIMCALL(void, getenvvarsc_123405)(void);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(NIM_BOOL, nsuStartsWith)(NimStringDesc* s, NimStringDesc* prefix);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
N_NIMCALL(NI, cmp_4717)(NimStringDesc* x, NimStringDesc* y);
N_NIMCALL(NI, nsuCmpIgnoreCase)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NI64, ntDiffTime)(time_t a, time_t b);
N_NIMCALL(time_t, nosgetLastModificationTime)(NimStringDesc* file);
N_NIMCALL(NI, findfirstfile_115416)(NimStringDesc* a, Twin32finddata105219* b);
N_NIMCALL(time_t, wintimetounixtime_108688)(NI64 t);
N_NIMCALL(NI64, rdfiletime_105604)(Tfiletime104248 f);
N_NIMCALL(NimStringDesc*, HEX2F_118492)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(NimStringDesc*, nosgetHomeDir)(void);
static N_INLINE(NimStringDesc*, HEX5BHEX5D_87567)(NimStringDesc* s, Slice87574 x);
static N_INLINE(Slice87574, HEX2EHEX2E_109273)(NI a, NI b);
N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename, NimStringDesc* ext);
N_NIMCALL(NIM_BOOL, nosexistsFile)(NimStringDesc* filename);
STRING_LITERAL(TMP136, "", 0);
STRING_LITERAL(TMP1088, "unknown OS error", 16);
STRING_LITERAL(TMP1550, ":\\", 2);
STRING_LITERAL(TMP1551, "\\", 1);
STRING_LITERAL(TMP1552, ".", 1);
STRING_LITERAL(TMP1553, "..\\", 3);
STRING_LITERAL(TMP1666, "USERPROFILE", 11);
STRING_LITERAL(TMP1898, "APPDATA", 7);
STRING_LITERAL(TMP5025, "exe", 3);
STRING_LITERAL(TMP5026, "PATH", 4);
NIM_BOOL envcomputed_123007;
TY123008* environment_123009;
TY123008* ownargv_127609;
extern TNimType NTI149; /* string */
TNimType NTI123008; /* seq[string] */
extern TNimType NTI114433; /* ref OSError */
extern TNimType NTI3433; /* OSError */
extern TY104663 Dl_104662;
extern TY104805 Dl_104804;
extern Tgcheap48216 gch_48244;
extern TY104658 Dl_104657;
extern TY105411 Dl_105410;
extern TY104829 Dl_104828;
extern TY105240 Dl_105239;
extern TY104818 Dl_104817;
extern TY105418 Dl_105417;
extern TY105440 Dl_105439;
extern TY105435 Dl_105434;
extern TY105437 Dl_105436;
extern TY104825 Dl_104824;
extern TY104811 Dl_104810;
extern TY105405 Dl_105404;
extern TY105632 Dl_105631;
N_NIMCALL(void, TMP54)(void* p, NI op) {
	TY123008* a;
	NI LOC1;
	a = (TY123008*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1], op);
	}
}

N_NIMCALL(void, nossplitPath)(NimStringDesc* path, Keyvaluepair136008* Result) {
	NI seppos;
	seppos = ((NI) -1);
	{
		NI i_118524;
		NI HEX3Atmp_118537;
		NI res_118540;
		i_118524 = 0;
		HEX3Atmp_118537 = 0;
		HEX3Atmp_118537 = (NI)((path ? path->Sup.len : 0) - ((NI) 1));
		res_118540 = HEX3Atmp_118537;
		{
			while (1) {
				if (!(((NI) 0) <= res_118540)) goto LA3;
				i_118524 = res_118540;
				{
					if (!(((NU8)(path->data[i_118524])) == ((NU8)(92)) || ((NU8)(path->data[i_118524])) == ((NU8)(47)))) goto LA6;
					seppos = i_118524;
					goto LA1;
				}
				LA6: ;
				res_118540 -= ((NI) 1);
			} LA3: ;
		}
	} LA1: ;
	{
		if (!(((NI) 0) <= seppos)) goto LA10;
		unsureAsgnRef((void**) (&(*Result).Field0), copyStrLast(path, ((NI) 0), (NI)(seppos - ((NI) 1))));
		unsureAsgnRef((void**) (&(*Result).Field1), copyStr(path, (NI)(seppos + ((NI) 1))));
	}
	goto LA8;
	LA10: ;
	{
		unsureAsgnRef((void**) (&(*Result).Field0), copyString(((NimStringDesc*) &TMP136)));
		unsureAsgnRef((void**) (&(*Result).Field1), copyString(path));
	}
	LA8: ;
}

N_NIMCALL(NimStringDesc*, nosextractFilename)(NimStringDesc* path) {
	NimStringDesc* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = ((path ? path->Sup.len : 0) == ((NI) 0));
		if (LOC3) goto LA4;
		LOC3 = (((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(92)) || ((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)));
		LA4: ;
		if (!LOC3) goto LA5;
		result = copyString(((NimStringDesc*) &TMP136));
	}
	goto LA1;
	LA5: ;
	{
		Keyvaluepair136008 LOC8;
		memset((void*)(&LOC8), 0, sizeof(LOC8));
		nossplitPath(path, (&LOC8));
		result = copyString(LOC8.Field1);
	}
	LA1: ;
	return result;
}

N_NIMCALL(NI, searchextpos_118736)(NimStringDesc* s) {
	NI result;
	result = 0;
	result = ((NI) -1);
	{
		NI i_118751;
		NI HEX3Atmp_118764;
		NI res_118767;
		i_118751 = 0;
		HEX3Atmp_118764 = 0;
		HEX3Atmp_118764 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_118767 = HEX3Atmp_118764;
		{
			while (1) {
				if (!(((NI) 1) <= res_118767)) goto LA3;
				i_118751 = res_118767;
				{
					if (!((NU8)(s->data[i_118751]) == (NU8)(46))) goto LA6;
					result = i_118751;
					goto LA1;
				}
				goto LA4;
				LA6: ;
				{
					if (!(((NU8)(s->data[i_118751])) == ((NU8)(92)) || ((NU8)(s->data[i_118751])) == ((NU8)(47)))) goto LA9;
					goto LA1;
				}
				goto LA4;
				LA9: ;
				LA4: ;
				res_118767 -= ((NI) 1);
			} LA3: ;
		}
	} LA1: ;
	return result;
}

static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	memcpy(((NCSTRING) ((&(*dest).data[((*dest).Sup.len)- 0]))), ((NCSTRING) ((*src).data)), (NI)((*src).Sup.len + ((NI) 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[((NI)((*dest).Sup.len + ((NI) 1)))- 0] = 0;
	(*dest).Sup.len += ((NI) 1);
}

N_NIMCALL(NimStringDesc*, normext_118726)(NimStringDesc* ext) {
	NimStringDesc* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = ((ext) && (ext)->Sup.len == 0);
		if (LOC3) goto LA4;
		LOC3 = ((NU8)(ext->data[((NI) 0)]) == (NU8)(46));
		LA4: ;
		if (!LOC3) goto LA5;
		result = copyString(ext);
	}
	goto LA1;
	LA5: ;
	{
		NimStringDesc* LOC8;
		LOC8 = 0;
		LOC8 = rawNewString(ext->Sup.len + 1);
appendChar(LOC8, 46);
appendString(LOC8, ext);
		result = LOC8;
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, noschangeFileExt)(NimStringDesc* filename, NimStringDesc* ext) {
	NimStringDesc* result;
	NI extpos;
	result = 0;
	extpos = searchextpos_118736(filename);
	{
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		if (!(extpos < ((NI) 0))) goto LA3;
		LOC5 = 0;
		LOC6 = 0;
		LOC6 = normext_118726(ext);
		LOC5 = rawNewString(filename->Sup.len + LOC6->Sup.len + 0);
appendString(LOC5, filename);
appendString(LOC5, LOC6);
		result = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* LOC8;
		NimStringDesc* LOC9;
		NimStringDesc* LOC10;
		LOC8 = 0;
		LOC9 = 0;
		LOC9 = copyStrLast(filename, ((NI) 0), (NI)(extpos - ((NI) 1)));
		LOC10 = 0;
		LOC10 = normext_118726(ext);
		LOC8 = rawNewString(LOC9->Sup.len + LOC10->Sup.len + 0);
appendString(LOC8, LOC9);
appendString(LOC8, LOC10);
		result = LOC8;
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, oserrormsg_114020)(NI32 errorcode) {
	NimStringDesc* result;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP136));
	{
		NI16* msgbuf;
		if (!!((errorcode == ((NI32) 0)))) goto LA3;
		msgbuf = 0;
		{
			NI32 LOC7;
			LOC7 = 0;
			LOC7 = Dl_104662(((NI32) 4864), NIM_NIL, errorcode, ((NI32) 0), ((void*) (&msgbuf)), ((NI32) 0), NIM_NIL);
			if (!!((LOC7 == ((NI32) 0)))) goto LA8;
			result = HEX24_80989(msgbuf);
			{
				if (!!((msgbuf == NIM_NIL))) goto LA12;
				Dl_104804(((void*) (msgbuf)));
			}
			LA12: ;
		}
		LA8: ;
	}
	LA3: ;
	return result;
}

static N_INLINE(Tcell46346*, usrtocell_49846)(void* usr) {
	Tcell46346* result;
	result = 0;
	result = ((Tcell46346*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(Tcell46346))))));
	return result;
}

static N_INLINE(void, rtladdzct_51404)(Tcell46346* c) {
	addzct_49817((&gch_48244.zct), c);
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Tcell46346* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_49846(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Tcell46346* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_49846((*dest));
		{
			(*c).refcount -= ((NI) 8);
			if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA11;
			rtladdzct_51404(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	Tcell46346* c;
	c = usrtocell_49846(p);
	{
		(*c).refcount -= ((NI) 8);
		if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA3;
		rtladdzct_51404(c);
	}
	LA3: ;
}

N_NIMCALL(void, raiseoserror_114430)(NI32 errorcode) {
	Oserror3433* e;
	e = 0;
	e = (Oserror3433*) newObj((&NTI114433), sizeof(Oserror3433));
	(*e).Sup.Sup.Sup.m_type = (&NTI3433);
	(*e).errorcode = errorcode;
	asgnRefNoCycle((void**) (&(*e).Sup.Sup.message), oserrormsg_114020(errorcode));
	{
		NimStringDesc* LOC5;
		if (!(((*e).Sup.Sup.message) && ((*e).Sup.Sup.message)->Sup.len == 0)) goto LA3;
		LOC5 = 0;
		LOC5 = (*e).Sup.Sup.message; (*e).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP1088));
		if (LOC5) nimGCunrefNoCycle(LOC5);
	}
	LA3: ;
	raiseException((Exception*)e, "OSError");
}

N_NIMCALL(NI32, oslasterror_114454)(void) {
	NI32 result;
	result = 0;
	result = Dl_104657();
	return result;
}

N_NIMCALL(NimStringDesc*, nosexpandFilename)(NimStringDesc* filename) {
	NimStringDesc* result;
	NI16* unused;
	NI16* res;
	NI32 L;
	NI16* LOC1;
	result = 0;
	unused = 0;
	res = newwidecstring_80621("", ((NI) 1536));
	LOC1 = 0;
	LOC1 = newwidecstring_80805(filename);
	L = Dl_105410(LOC1, ((NI32) 3072), res, &unused);
	{
		NIM_BOOL LOC4;
		NI32 LOC8;
		LOC4 = 0;
		LOC4 = (L <= ((NI32) 0));
		if (LOC4) goto LA5;
		LOC4 = (((NI32) 3072) <= L);
		LA5: ;
		if (!LOC4) goto LA6;
		LOC8 = 0;
		LOC8 = oslasterror_114454();
		raiseoserror_114430(LOC8);
	}
	LA6: ;
	result = HEX24_80812(res, ((NI) (L)));
	return result;
}

N_NIMCALL(void, nossplitFile)(NimStringDesc* path, TY118789* Result) {
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = ((path ? path->Sup.len : 0) == ((NI) 0));
		if (LOC3) goto LA4;
		LOC3 = (((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(92)) || ((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)));
		LA4: ;
		if (!LOC3) goto LA5;
		unsureAsgnRef((void**) (&(*Result).Field0), copyString(path));
		unsureAsgnRef((void**) (&(*Result).Field1), copyString(((NimStringDesc*) &TMP136)));
		unsureAsgnRef((void**) (&(*Result).Field2), copyString(((NimStringDesc*) &TMP136)));
	}
	goto LA1;
	LA5: ;
	{
		NI seppos;
		NI dotpos;
		seppos = ((NI) -1);
		dotpos = (path ? path->Sup.len : 0);
		{
			NI i_118819;
			NI HEX3Atmp_118843;
			NI res_118846;
			i_118819 = 0;
			HEX3Atmp_118843 = 0;
			HEX3Atmp_118843 = (NI)((path ? path->Sup.len : 0) - ((NI) 1));
			res_118846 = HEX3Atmp_118843;
			{
				while (1) {
					if (!(((NI) 0) <= res_118846)) goto LA10;
					i_118819 = res_118846;
					{
						if (!((NU8)(path->data[i_118819]) == (NU8)(46))) goto LA13;
						{
							NIM_BOOL LOC17;
							NIM_BOOL LOC18;
							LOC17 = 0;
							LOC18 = 0;
							LOC18 = (dotpos == (path ? path->Sup.len : 0));
							if (!(LOC18)) goto LA19;
							LOC18 = (((NI) 0) < i_118819);
							LA19: ;
							LOC17 = LOC18;
							if (!(LOC17)) goto LA20;
							LOC17 = !((((NU8)(path->data[(NI)(i_118819 - ((NI) 1))])) == ((NU8)(92)) || ((NU8)(path->data[(NI)(i_118819 - ((NI) 1))])) == ((NU8)(47))));
							LA20: ;
							if (!LOC17) goto LA21;
							dotpos = i_118819;
						}
						LA21: ;
					}
					goto LA11;
					LA13: ;
					{
						if (!(((NU8)(path->data[i_118819])) == ((NU8)(92)) || ((NU8)(path->data[i_118819])) == ((NU8)(47)))) goto LA24;
						seppos = i_118819;
						goto LA8;
					}
					goto LA11;
					LA24: ;
					LA11: ;
					res_118846 -= ((NI) 1);
				} LA10: ;
			}
		} LA8: ;
		unsureAsgnRef((void**) (&(*Result).Field0), copyStrLast(path, ((NI) 0), (NI)(seppos - ((NI) 1))));
		unsureAsgnRef((void**) (&(*Result).Field1), copyStrLast(path, (NI)(seppos + ((NI) 1)), (NI)(dotpos - ((NI) 1))));
		unsureAsgnRef((void**) (&(*Result).Field2), copyStr(path, dotpos));
	}
	LA1: ;
}

N_NIMCALL(NimStringDesc*, nosgetAppFilename)(void) {
	NimStringDesc* result;
	NI16* buf;
	void* LOC1;
	NI32 len;
	result = 0;
	LOC1 = 0;
	LOC1 = alloc_6001(((NI) 512));
	buf = ((NI16*) (LOC1));
	len = Dl_104828(((NI) 0), buf, ((NI32) 256));
	result = HEX24_80812(buf, ((NI) (len)));
	return result;
}

N_NIMCALL(NimStringDesc*, nosgetAppDir)(void) {
	NimStringDesc* result;
	NimStringDesc* LOC1;
	TY118789 LOC2;
	result = 0;
	LOC1 = 0;
	LOC1 = nosgetAppFilename();
	memset((void*)(&LOC2), 0, sizeof(LOC2));
	nossplitFile(LOC1, (&LOC2));
	result = copyString(LOC2.Field0);
	return result;
}

N_NIMCALL(NI, parentdirpos_118559)(NimStringDesc* path) {
	NI result;
	NI q;
{	result = 0;
	q = ((NI) 1);
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (((NI) 1) <= (path ? path->Sup.len : 0));
		if (!(LOC3)) goto LA4;
		LOC3 = (((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(92)) || ((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)));
		LA4: ;
		if (!LOC3) goto LA5;
		q = ((NI) 2);
	}
	LA5: ;
	{
		NI i_118586;
		NI HEX3Atmp_118599;
		NI res_118602;
		i_118586 = 0;
		HEX3Atmp_118599 = 0;
		HEX3Atmp_118599 = (NI)((path ? path->Sup.len : 0) - q);
		res_118602 = HEX3Atmp_118599;
		{
			while (1) {
				if (!(((NI) 0) <= res_118602)) goto LA9;
				i_118586 = res_118602;
				{
					if (!(((NU8)(path->data[i_118586])) == ((NU8)(92)) || ((NU8)(path->data[i_118586])) == ((NU8)(47)))) goto LA12;
					result = i_118586;
					goto BeforeRet;
				}
				LA12: ;
				res_118602 -= ((NI) 1);
			} LA9: ;
		}
	}
	result = ((NI) -1);
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nosparentDir)(NimStringDesc* path) {
	NimStringDesc* result;
	NI seppos;
	result = 0;
	seppos = parentdirpos_118559(path);
	{
		if (!(((NI) 0) <= seppos)) goto LA3;
		result = copyStrLast(path, ((NI) 0), (NI)(seppos - ((NI) 1)));
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP136));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head, NimStringDesc* tail) {
	NimStringDesc* result;
	result = 0;
	{
		if (!((head ? head->Sup.len : 0) == ((NI) 0))) goto LA3;
		result = copyString(tail);
	}
	goto LA1;
	LA3: ;
	{
		if (!(((NU8)(head->data[(NI)((head ? head->Sup.len : 0) - ((NI) 1))])) == ((NU8)(92)) || ((NU8)(head->data[(NI)((head ? head->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)))) goto LA6;
		{
			NimStringDesc* LOC12;
			NimStringDesc* LOC13;
			if (!(((NU8)(tail->data[((NI) 0)])) == ((NU8)(92)) || ((NU8)(tail->data[((NI) 0)])) == ((NU8)(47)))) goto LA10;
			LOC12 = 0;
			LOC13 = 0;
			LOC13 = copyStr(tail, ((NI) 1));
			LOC12 = rawNewString(head->Sup.len + LOC13->Sup.len + 0);
appendString(LOC12, head);
appendString(LOC12, LOC13);
			result = LOC12;
		}
		goto LA8;
		LA10: ;
		{
			NimStringDesc* LOC15;
			LOC15 = 0;
			LOC15 = rawNewString(head->Sup.len + tail->Sup.len + 0);
appendString(LOC15, head);
appendString(LOC15, tail);
			result = LOC15;
		}
		LA8: ;
	}
	goto LA1;
	LA6: ;
	{
		{
			NimStringDesc* LOC21;
			if (!(((NU8)(tail->data[((NI) 0)])) == ((NU8)(92)) || ((NU8)(tail->data[((NI) 0)])) == ((NU8)(47)))) goto LA19;
			LOC21 = 0;
			LOC21 = rawNewString(head->Sup.len + tail->Sup.len + 0);
appendString(LOC21, head);
appendString(LOC21, tail);
			result = LOC21;
		}
		goto LA17;
		LA19: ;
		{
			NimStringDesc* LOC23;
			LOC23 = 0;
			LOC23 = rawNewString(head->Sup.len + tail->Sup.len + 1);
appendString(LOC23, head);
appendChar(LOC23, 92);
appendString(LOC23, tail);
			result = LOC23;
		}
		LA17: ;
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, HEX2F_118492)(NimStringDesc* head, NimStringDesc* tail) {
	NimStringDesc* result;
{	result = 0;
	result = nosjoinPath(head, tail);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NI, findfirstfile_115416)(NimStringDesc* a, Twin32finddata105219* b) {
	NI result;
	NI16* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = newwidecstring_80805(a);
	result = Dl_105239(LOC1, b);
	return result;
}

N_NIMCALL(NIM_BOOL, nosisAbsolute)(NimStringDesc* path) {
	NIM_BOOL result;
	NI len;
	NIM_BOOL LOC1;
	NIM_BOOL LOC2;
	NIM_BOOL LOC5;
	NIM_BOOL LOC6;
	result = 0;
	len = (path ? path->Sup.len : 0);
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = (((NI) 1) < len);
	if (!(LOC2)) goto LA3;
	LOC2 = (((NU8)(path->data[((NI) 0)])) == ((NU8)(47)) || ((NU8)(path->data[((NI) 0)])) == ((NU8)(92)));
	LA3: ;
	LOC1 = LOC2;
	if (LOC1) goto LA4;
	LOC5 = 0;
	LOC6 = 0;
	LOC6 = (((NI) 2) < len);
	if (!(LOC6)) goto LA7;
	LOC6 = (((NU8)(path->data[((NI) 0)])) >= ((NU8)(65)) && ((NU8)(path->data[((NI) 0)])) <= ((NU8)(90)) || ((NU8)(path->data[((NI) 0)])) >= ((NU8)(97)) && ((NU8)(path->data[((NI) 0)])) <= ((NU8)(122)));
	LA7: ;
	LOC5 = LOC6;
	if (!(LOC5)) goto LA8;
	LOC5 = ((NU8)(path->data[((NI) 1)]) == (NU8)(58));
	LA8: ;
	LOC1 = LOC5;
	LA4: ;
	result = LOC1;
	return result;
}

N_NIMCALL(void, rawcreatedir_125041)(NimStringDesc* dir) {
	NI32 res;
	NI16* LOC1;
	LOC1 = 0;
	LOC1 = newwidecstring_80805(dir);
	res = Dl_104817(LOC1, NIM_NIL);
	{
		NIM_BOOL LOC4;
		NI32 LOC6;
		NI32 LOC9;
		LOC4 = 0;
		LOC4 = (res == ((NI32) 0));
		if (!(LOC4)) goto LA5;
		LOC6 = 0;
		LOC6 = Dl_104657();
		LOC4 = !((LOC6 == ((NI32) 183)));
		LA5: ;
		if (!LOC4) goto LA7;
		LOC9 = 0;
		LOC9 = oslasterror_114454();
		raiseoserror_114430(LOC9);
	}
	LA7: ;
}

N_NIMCALL(void, noscreateDir)(NimStringDesc* dir) {
	NIM_BOOL omitnext;
	omitnext = NIM_FALSE;
	omitnext = nosisAbsolute(dir);
	{
		NI i_125611;
		NI HEX3Atmp_125624;
		NI res_125627;
		i_125611 = 0;
		HEX3Atmp_125624 = 0;
		HEX3Atmp_125624 = (NI)((dir ? dir->Sup.len : 0) - ((NI) 1));
		res_125627 = ((NI) 1);
		{
			while (1) {
				if (!(res_125627 <= HEX3Atmp_125624)) goto LA3;
				i_125611 = res_125627;
				{
					if (!(((NU8)(dir->data[i_125611])) == ((NU8)(92)) || ((NU8)(dir->data[i_125611])) == ((NU8)(47)))) goto LA6;
					{
						if (!omitnext) goto LA10;
						omitnext = NIM_FALSE;
					}
					goto LA8;
					LA10: ;
					{
						NimStringDesc* LOC13;
						LOC13 = 0;
						LOC13 = copyStrLast(dir, ((NI) 0), (NI)(i_125611 - ((NI) 1)));
						rawcreatedir_125041(LOC13);
					}
					LA8: ;
				}
				LA6: ;
				res_125627 += ((NI) 1);
			} LA3: ;
		}
	}
	rawcreatedir_125041(dir);
}

N_NIMCALL(NimStringDesc*, nosjoinPathOpenArray)(NimStringDesc** parts, NI partsLen0) {
	NimStringDesc* result;
	result = 0;
	result = copyString(parts[((NI) 0)]);
	{
		NI i_118466;
		NI HEX3Atmp_118470;
		NI res_118473;
		i_118466 = 0;
		HEX3Atmp_118470 = 0;
		HEX3Atmp_118470 = (partsLen0-1);
		res_118473 = ((NI) 1);
		{
			while (1) {
				if (!(res_118473 <= HEX3Atmp_118470)) goto LA3;
				i_118466 = res_118473;
				result = nosjoinPath(result, parts[i_118466]);
				res_118473 += ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NIM_BOOL, nosexistsFile)(NimStringDesc* filename) {
	NIM_BOOL result;
	NI32 a;
	NI16* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = newwidecstring_80805(filename);
	a = Dl_105417(LOC1);
	{
		if (!!((a == ((NI32) -1)))) goto LA4;
		result = ((NI32)(a & ((NI32) 16)) == ((NI32) 0));
	}
	LA4: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename, NimStringDesc* ext) {
	NimStringDesc* result;
	NI extpos;
	result = 0;
	extpos = searchextpos_118736(filename);
	{
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		if (!(extpos < ((NI) 0))) goto LA3;
		LOC5 = 0;
		LOC6 = 0;
		LOC6 = normext_118726(ext);
		LOC5 = rawNewString(filename->Sup.len + LOC6->Sup.len + 0);
appendString(LOC5, filename);
appendString(LOC5, LOC6);
		result = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(filename);
	}
	LA1: ;
	return result;
}

N_NIMCALL(TY123008*, nosparseCmdLine)(NimStringDesc* c) {
	TY123008* result;
	NI i;
	NimStringDesc* a;
	result = 0;
	result = (TY123008*) newSeq((&NTI123008), 0);
	i = ((NI) 0);
	a = copyString(((NimStringDesc*) &TMP136));
	{
		while (1) {
			NIM_BOOL inquote;
			NimStringDesc* LOC49;
			a = setLengthStr(a, ((NI) 0));
			{
				while (1) {
					NIM_BOOL LOC5;
					NIM_BOOL LOC6;
					NIM_BOOL LOC7;
					LOC5 = 0;
					LOC6 = 0;
					LOC7 = 0;
					LOC7 = ((NU8)(c->data[i]) == (NU8)(32));
					if (LOC7) goto LA8;
					LOC7 = ((NU8)(c->data[i]) == (NU8)(9));
					LA8: ;
					LOC6 = LOC7;
					if (LOC6) goto LA9;
					LOC6 = ((NU8)(c->data[i]) == (NU8)(10));
					LA9: ;
					LOC5 = LOC6;
					if (LOC5) goto LA10;
					LOC5 = ((NU8)(c->data[i]) == (NU8)(13));
					LA10: ;
					if (!LOC5) goto LA4;
					i += ((NI) 1);
				} LA4: ;
			}
			{
				if (!((NU8)(c->data[i]) == (NU8)(0))) goto LA13;
				goto LA1;
			}
			LA13: ;
			inquote = NIM_FALSE;
			{
				while (1) {
					switch (((NU8)(c->data[i]))) {
					case 0:
					{
						goto LA15;
					}
					break;
					case 92:
					{
						NI j;
						j = i;
						{
							while (1) {
								if (!((NU8)(c->data[j]) == (NU8)(92))) goto LA20;
								j += ((NI) 1);
							} LA20: ;
						}
						{
							if (!((NU8)(c->data[j]) == (NU8)(34))) goto LA23;
							{
								NI k_126622;
								NI HEX3Atmp_126684;
								NI res_126687;
								k_126622 = 0;
								HEX3Atmp_126684 = 0;
								HEX3Atmp_126684 = (NI)((NI)(j - i) / ((NI) 2));
								res_126687 = ((NI) 1);
								{
									while (1) {
										if (!(res_126687 <= HEX3Atmp_126684)) goto LA27;
										k_126622 = res_126687;
										a = addChar(a, 92);
										res_126687 += ((NI) 1);
									} LA27: ;
								}
							}
							{
								if (!(((NI) ((NI)((NI)(j - i) % ((NI) 2)))) == ((NI) 0))) goto LA30;
								i = j;
							}
							goto LA28;
							LA30: ;
							{
								a = addChar(a, 34);
								i = (NI)(j + ((NI) 1));
							}
							LA28: ;
						}
						goto LA21;
						LA23: ;
						{
							a = addChar(a, c->data[i]);
							i += ((NI) 1);
						}
						LA21: ;
					}
					break;
					case 34:
					{
						i += ((NI) 1);
						{
							if (!!(inquote)) goto LA37;
							inquote = NIM_TRUE;
						}
						goto LA35;
						LA37: ;
						{
							if (!((NU8)(c->data[i]) == (NU8)(34))) goto LA40;
							a = addChar(a, c->data[i]);
							i += ((NI) 1);
						}
						goto LA35;
						LA40: ;
						{
							inquote = NIM_FALSE;
							goto LA15;
						}
						LA35: ;
					}
					break;
					case 32:
					case 9:
					{
						{
							if (!!(inquote)) goto LA46;
							goto LA15;
						}
						LA46: ;
						a = addChar(a, c->data[i]);
						i += ((NI) 1);
					}
					break;
					default:
					{
						a = addChar(a, c->data[i]);
						i += ((NI) 1);
					}
					break;
					}
				}
			} LA15: ;
			result = (TY123008*) incrSeq(&(result)->Sup, sizeof(NimStringDesc*));
			LOC49 = 0;
			LOC49 = result->data[result->Sup.len-1]; result->data[result->Sup.len-1] = copyStringRC1(a);
			if (LOC49) nimGCunrefNoCycle(LOC49);
		}
	} LA1: ;
	return result;
}

N_NIMCALL(NI, nosparamCount)(void) {
	NI result;
	result = 0;
	{
		NI16* LOC5;
		NimStringDesc* LOC6;
		if (!ownargv_127609 == 0) goto LA3;
		LOC5 = 0;
		LOC5 = Dl_105439();
		LOC6 = 0;
		LOC6 = HEX24_80989(LOC5);
		asgnRefNoCycle((void**) (&ownargv_127609), nosparseCmdLine(LOC6));
	}
	LA3: ;
	result = (NI)((ownargv_127609 ? ownargv_127609->Sup.len : 0) - ((NI) 1));
	return result;
}

N_NIMCALL(NimStringDesc*, nosparamStr)(NI i) {
	NimStringDesc* result;
{	result = 0;
	{
		NI16* LOC5;
		NimStringDesc* LOC6;
		if (!ownargv_127609 == 0) goto LA3;
		LOC5 = 0;
		LOC5 = Dl_105439();
		LOC6 = 0;
		LOC6 = HEX24_80989(LOC5);
		asgnRefNoCycle((void**) (&ownargv_127609), nosparseCmdLine(LOC6));
	}
	LA3: ;
	result = copyString(ownargv_127609->data[i]);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nosunixToNativePath)(NimStringDesc* path, NimStringDesc* drive) {
	NimStringDesc* result;
	NI start;
	NI i;
	result = 0;
	start = 0;
	{
		if (!((NU8)(path->data[((NI) 0)]) == (NU8)(47))) goto LA3;
		{
			NimStringDesc* LOC9;
			if (!!(((drive) && (drive)->Sup.len == 0))) goto LA7;
			LOC9 = 0;
			LOC9 = rawNewString(drive->Sup.len + 2);
appendString(LOC9, drive);
appendString(LOC9, ((NimStringDesc*) &TMP1550));
			result = LOC9;
		}
		goto LA5;
		LA7: ;
		{
			result = copyString(((NimStringDesc*) &TMP1551));
		}
		LA5: ;
		start = ((NI) 1);
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC12;
		LOC12 = 0;
		LOC12 = ((NU8)(path->data[((NI) 0)]) == (NU8)(46));
		if (!(LOC12)) goto LA13;
		LOC12 = ((NU8)(path->data[((NI) 1)]) == (NU8)(47));
		LA13: ;
		if (!LOC12) goto LA14;
		result = copyString(((NimStringDesc*) &TMP1552));
		start = ((NI) 2);
	}
	goto LA1;
	LA14: ;
	{
		result = copyString(((NimStringDesc*) &TMP136));
		start = ((NI) 0);
	}
	LA1: ;
	i = start;
	{
		while (1) {
			if (!(i < (path ? path->Sup.len : 0))) goto LA18;
			{
				NIM_BOOL LOC21;
				NIM_BOOL LOC22;
				LOC21 = 0;
				LOC22 = 0;
				LOC22 = ((NU8)(path->data[i]) == (NU8)(46));
				if (!(LOC22)) goto LA23;
				LOC22 = ((NU8)(path->data[(NI)(i + ((NI) 1))]) == (NU8)(46));
				LA23: ;
				LOC21 = LOC22;
				if (!(LOC21)) goto LA24;
				LOC21 = ((NU8)(path->data[(NI)(i + ((NI) 2))]) == (NU8)(47));
				LA24: ;
				if (!LOC21) goto LA25;
				result = resizeString(result, 3);
appendString(result, ((NimStringDesc*) &TMP1553));
				i += ((NI) 3);
			}
			goto LA19;
			LA25: ;
			{
				if (!((NU8)(path->data[i]) == (NU8)(47))) goto LA28;
				result = addChar(result, 92);
				i += ((NI) 1);
			}
			goto LA19;
			LA28: ;
			{
				result = addChar(result, path->data[i]);
				i += ((NI) 1);
			}
			LA19: ;
		} LA18: ;
	}
	return result;
}

N_NIMCALL(void, getenvvarsc_123405)(void) {
{	{
		NI16* env;
		NI16* e;
		NI32 LOC17;
		if (!!(envcomputed_123007)) goto LA3;
		if (environment_123009) nimGCunrefNoCycle(environment_123009);
		environment_123009 = (TY123008*) newSeqRC1((&NTI123008), 0);
		env = Dl_105434();
		e = env;
		{
			if (!(e == NIM_NIL)) goto LA7;
			goto BeforeRet;
		}
		LA7: ;
		{
			while (1) {
				NI16* eend;
				NimStringDesc* LOC11;
				NimStringDesc* LOC12;
				eend = wcschr(e, ((NI32) 0));
				LOC11 = 0;
				LOC11 = HEX24_80989(e);
				environment_123009 = (TY123008*) incrSeq(&(environment_123009)->Sup, sizeof(NimStringDesc*));
				LOC12 = 0;
				LOC12 = environment_123009->data[environment_123009->Sup.len-1]; environment_123009->data[environment_123009->Sup.len-1] = copyStringRC1(LOC11);
				if (LOC12) nimGCunrefNoCycle(LOC12);
				e = ((NI16*) ((NI)(((NI) (eend)) + ((NI) 2))));
				{
					if (!(((NI) (eend[(((NI) 1))- 0])) == ((NI) 0))) goto LA15;
					goto LA9;
				}
				LA15: ;
			}
		} LA9: ;
		LOC17 = 0;
		LOC17 = Dl_105436(env);
		envcomputed_123007 = NIM_TRUE;
	}
	LA3: ;
	}BeforeRet: ;
}

N_NIMCALL(NI, findenvvar_123804)(NimStringDesc* key) {
	NI result;
	NimStringDesc* temp;
	NimStringDesc* LOC1;
{	result = 0;
	getenvvarsc_123405();
	LOC1 = 0;
	LOC1 = rawNewString(key->Sup.len + 1);
appendString(LOC1, key);
appendChar(LOC1, 61);
	temp = LOC1;
	{
		NI i_123819;
		NI HEX3Atmp_123821;
		NI res_123824;
		i_123819 = 0;
		HEX3Atmp_123821 = 0;
		HEX3Atmp_123821 = (environment_123009 ? (environment_123009->Sup.len-1) : -1);
		res_123824 = ((NI) 0);
		{
			while (1) {
				if (!(res_123824 <= HEX3Atmp_123821)) goto LA4;
				i_123819 = res_123824;
				{
					NIM_BOOL LOC7;
					LOC7 = 0;
					LOC7 = nsuStartsWith(environment_123009->data[i_123819], temp);
					if (!LOC7) goto LA8;
					result = i_123819;
					goto BeforeRet;
				}
				LA8: ;
				res_123824 += ((NI) 1);
			} LA4: ;
		}
	}
	result = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, getenv_123843)(NimStringDesc* key) {
	NimStringDesc* result;
	NI i;
{	result = 0;
	i = findenvvar_123804(key);
	{
		NI LOC5;
		if (!(((NI) 0) <= i)) goto LA3;
		LOC5 = 0;
		LOC5 = nsuFindChar(environment_123009->data[i], 61, ((NI) 0));
		result = copyStr(environment_123009->data[i], (NI)(LOC5 + ((NI) 1)));
		goto BeforeRet;
	}
	goto LA1;
	LA3: ;
	{
		NCSTRING env;
		env = getenv(key->data);
		{
			if (!(env == NIM_NIL)) goto LA9;
			result = copyString(((NimStringDesc*) &TMP136));
			goto BeforeRet;
		}
		LA9: ;
		result = cstrToNimstr(env);
	}
	LA1: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nosgetHomeDir)(void) {
	NimStringDesc* result;
	NimStringDesc* LOC1;
	NimStringDesc* LOC2;
{	result = 0;
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = getenv_123843(((NimStringDesc*) &TMP1666));
	LOC1 = rawNewString(LOC2->Sup.len + 1);
appendString(LOC1, LOC2);
appendString(LOC1, ((NimStringDesc*) &TMP1551));
	result = LOC1;
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NI, noscmpPaths)(NimStringDesc* patha, NimStringDesc* pathb) {
	NI result;
	result = 0;
	{
		if (!NIM_FALSE) goto LA3;
		result = cmp_4717(patha, pathb);
	}
	goto LA1;
	LA3: ;
	{
		result = nsuCmpIgnoreCase(patha, pathb);
	}
	LA1: ;
	return result;
}

N_NIMCALL(void, putenv_123868)(NimStringDesc* key, NimStringDesc* val) {
	NI indx;
	NI16* k;
	NI16* v;
	indx = findenvvar_123804(key);
	{
		NimStringDesc* LOC5;
		if (!(((NI) 0) <= indx)) goto LA3;
		LOC5 = 0;
		LOC5 = rawNewString(key->Sup.len + val->Sup.len + 1);
appendString(LOC5, key);
appendChar(LOC5, 61);
appendString(LOC5, val);
		asgnRefNoCycle((void**) (&environment_123009->data[indx]), LOC5);
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* LOC7;
		NimStringDesc* LOC8;
		LOC7 = 0;
		LOC7 = rawNewString(key->Sup.len + val->Sup.len + 1);
appendString(LOC7, key);
appendChar(LOC7, 61);
appendString(LOC7, val);
		environment_123009 = (TY123008*) incrSeq(&(environment_123009)->Sup, sizeof(NimStringDesc*));
		LOC8 = 0;
		LOC8 = environment_123009->data[environment_123009->Sup.len-1]; environment_123009->data[environment_123009->Sup.len-1] = copyStringRC1(LOC7);
		if (LOC8) nimGCunrefNoCycle(LOC8);
		indx = (environment_123009 ? (environment_123009->Sup.len-1) : -1);
	}
	LA1: ;
	k = newwidecstring_80805(key);
	v = newwidecstring_80805(val);
	{
		NI32 LOC11;
		NI32 LOC14;
		LOC11 = 0;
		LOC11 = Dl_104824(k, v);
		if (!(LOC11 == ((NI32) 0))) goto LA12;
		LOC14 = 0;
		LOC14 = oslasterror_114454();
		raiseoserror_114430(LOC14);
	}
	LA12: ;
}

N_NIMCALL(NimStringDesc*, nosgetCurrentDir)(void) {
	NimStringDesc* result;
	NI16* res;
	NI32 L;
	result = 0;
	res = newwidecstring_80621("", ((NI) 512));
	L = Dl_104810(((NI32) 512), res);
	{
		NI32 LOC5;
		if (!(L == ((NI32) 0))) goto LA3;
		LOC5 = 0;
		LOC5 = oslasterror_114454();
		raiseoserror_114430(LOC5);
	}
	LA3: ;
	result = HEX24_80812(res, ((NI) (L)));
	return result;
}

N_NIMCALL(NimStringDesc*, nosgetConfigDir)(void) {
	NimStringDesc* result;
	NimStringDesc* LOC1;
	NimStringDesc* LOC2;
{	result = 0;
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = getenv_123843(((NimStringDesc*) &TMP1898));
	LOC1 = rawNewString(LOC2->Sup.len + 1);
appendString(LOC1, LOC2);
appendString(LOC1, ((NimStringDesc*) &TMP1551));
	result = LOC1;
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, nosisRootDir)(NimStringDesc* path) {
	NIM_BOOL result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = parentdirpos_118559(path);
	result = (LOC1 < ((NI) 0));
	return result;
}

N_NIMCALL(NIM_BOOL, existsenv_123858)(NimStringDesc* key) {
	NIM_BOOL result;
{	result = 0;
	{
		NCSTRING LOC3;
		LOC3 = 0;
		LOC3 = getenv(key->data);
		if (!!((LOC3 == NIM_NIL))) goto LA4;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	goto LA1;
	LA4: ;
	{
		NI LOC7;
		LOC7 = 0;
		LOC7 = findenvvar_123804(key);
		result = (((NI) 0) <= LOC7);
		goto BeforeRet;
	}
	LA1: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, nosexistsDir)(NimStringDesc* dir) {
	NIM_BOOL result;
	NI32 a;
	NI16* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = newwidecstring_80805(dir);
	a = Dl_105417(LOC1);
	{
		if (!!((a == ((NI32) -1)))) goto LA4;
		result = !(((NI32)(a & ((NI32) 16)) == ((NI32) 0)));
	}
	LA4: ;
	return result;
}

N_NIMCALL(time_t, nosgetLastModificationTime)(NimStringDesc* file) {
	time_t result;
	Twin32finddata105219 f;
	NI h;
	NI64 LOC6;
	result = 0;
	memset((void*)(&f), 0, sizeof(f));
	h = findfirstfile_115416(file, (&f));
	{
		NI32 LOC5;
		if (!(h == ((NI) -1))) goto LA3;
		LOC5 = 0;
		LOC5 = oslasterror_114454();
		raiseoserror_114430(LOC5);
	}
	LA3: ;
	LOC6 = 0;
	LOC6 = rdfiletime_105604(f.ftlastwritetime);
	result = wintimetounixtime_108688(LOC6);
	Dl_105404(h);
	return result;
}

N_NIMCALL(NIM_BOOL, nosfileNewer)(NimStringDesc* a, NimStringDesc* b) {
	NIM_BOOL result;
	time_t LOC1;
	time_t LOC2;
	NI64 LOC3;
	result = 0;
	LOC1 = 0;
	LOC1 = nosgetLastModificationTime(a);
	LOC2 = 0;
	LOC2 = nosgetLastModificationTime(b);
	LOC3 = 0;
	LOC3 = ntDiffTime(LOC1, LOC2);
	result = (IL64(0) < LOC3);
	return result;
}

N_NIMCALL(void, nossleep)(NI milsecs) {
	Dl_105631(((NI32) (milsecs)));
}

static N_INLINE(NimStringDesc*, HEX5BHEX5D_87567)(NimStringDesc* s, Slice87574 x) {
	NimStringDesc* result;
	result = 0;
	result = copyStrLast(s, x.a, x.b);
	return result;
}

static N_INLINE(Slice87574, HEX2EHEX2E_109273)(NI a, NI b) {
	Slice87574 result;
	memset((void*)(&result), 0, sizeof(result));
	result.a = a;
	result.b = b;
	return result;
}

N_NIMCALL(NimStringDesc*, expandtilde_129411)(NimStringDesc* path) {
	NimStringDesc* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		NIM_BOOL LOC7;
		NimStringDesc* LOC11;
		Slice87574 LOC12;
		NimStringDesc* LOC13;
		LOC3 = 0;
		LOC4 = 0;
		LOC4 = (((NI) 1) < (path ? path->Sup.len : 0));
		if (!(LOC4)) goto LA5;
		LOC4 = ((NU8)(path->data[((NI) 0)]) == (NU8)(126));
		LA5: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA6;
		LOC7 = 0;
		LOC7 = ((NU8)(path->data[((NI) 1)]) == (NU8)(47));
		if (LOC7) goto LA8;
		LOC7 = ((NU8)(path->data[((NI) 1)]) == (NU8)(92));
		LA8: ;
		LOC3 = LOC7;
		LA6: ;
		if (!LOC3) goto LA9;
		LOC11 = 0;
		LOC11 = nosgetHomeDir();
		LOC12 = HEX2EHEX2E_109273(((NI) 2), (NI)((path ? path->Sup.len : 0) - ((NI) 1)));
		LOC13 = 0;
		LOC13 = HEX5BHEX5D_87567(path, LOC12);
		result = HEX2F_118492(LOC11, LOC13);
	}
	goto LA1;
	LA9: ;
	{
		result = copyString(path);
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, findexe_129417)(NimStringDesc* exe) {
	NimStringDesc* result;
	NimStringDesc* path;
{	result = 0;
	result = nosaddFileExt(exe, ((NimStringDesc*) &TMP5025));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = nosexistsFile(result);
		if (!LOC3) goto LA4;
		goto BeforeRet;
	}
	LA4: ;
	path = getenv_123843(((NimStringDesc*) &TMP5026));
	{
		NimStringDesc* candidate_129422;
		NI last_129607;
		candidate_129422 = 0;
		last_129607 = ((NI) 0);
		{
			if (!(((NI) 0) < (path ? path->Sup.len : 0))) goto LA9;
			{
				while (1) {
					NI first_129609;
					NimStringDesc* x;
					if (!(last_129607 <= (path ? path->Sup.len : 0))) goto LA12;
					first_129609 = last_129607;
					{
						while (1) {
							NIM_BOOL LOC15;
							LOC15 = 0;
							LOC15 = (last_129607 < (path ? path->Sup.len : 0));
							if (!(LOC15)) goto LA16;
							LOC15 = !(((NU8)(path->data[last_129607]) == (NU8)(59)));
							LA16: ;
							if (!LOC15) goto LA14;
							last_129607 += ((NI) 1);
						} LA14: ;
					}
					candidate_129422 = copyStrLast(path, first_129609, (NI)(last_129607 - ((NI) 1)));
					x = HEX2F_118492(candidate_129422, result);
					{
						NIM_BOOL LOC19;
						LOC19 = 0;
						LOC19 = nosexistsFile(x);
						if (!LOC19) goto LA20;
						result = copyString(x);
						goto BeforeRet;
					}
					LA20: ;
					last_129607 += ((NI) 1);
				} LA12: ;
			}
		}
		LA9: ;
	}
	result = copyString(((NimStringDesc*) &TMP136));
	}BeforeRet: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_osInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, stdlib_osDatInit)(void) {
NTI123008.size = sizeof(TY123008*);
NTI123008.kind = 24;
NTI123008.base = (&NTI149);
NTI123008.flags = 2;
NTI123008.marker = TMP54;
}

