/* Generated by Nim Compiler v0.15.0 */
/*   (c) 2016 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 <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <dirent.h>
#include <setjmp.h>
#include <stdio.h>
typedef struct TY135002 TY135002;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Keyvaluepair152604 Keyvaluepair152604;
typedef struct Oserror3630 Oserror3630;
typedef struct Systemerror3626 Systemerror3626;
typedef struct Exception Exception;
typedef struct TNimObject TNimObject;
typedef struct Cell47305 Cell47305;
typedef struct Cellseq47321 Cellseq47321;
typedef struct Gcheap49818 Gcheap49818;
typedef struct Gcstack49816 Gcstack49816;
typedef struct Memregion29486 Memregion29486;
typedef struct Smallchunk29440 Smallchunk29440;
typedef struct Llchunk29480 Llchunk29480;
typedef struct Bigchunk29442 Bigchunk29442;
typedef struct Intset29414 Intset29414;
typedef struct Trunk29410 Trunk29410;
typedef struct Avlnode29484 Avlnode29484;
typedef struct Gcstat49814 Gcstat49814;
typedef struct Cellset47317 Cellset47317;
typedef struct Pagedesc47313 Pagedesc47313;
typedef struct TY128506 TY128506;
typedef struct Indexerror3652 Indexerror3652;
typedef struct TSafePoint TSafePoint;
typedef struct Basechunk29438 Basechunk29438;
typedef struct Freecell29430 Freecell29430;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 Tnimkind3403;
typedef NU8 Tnimtypeflag3409Set;
typedef N_NIMCALL_PTR(void, TY3489) (void* p0, NI op0);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p0);
struct  TNimType  {
NI size;
Tnimkind3403 kind;
Tnimtypeflag3409Set flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 deepcopy;
};
typedef NU8 Tnimnodekind3405;
struct  TNimNode  {
Tnimnodekind3405 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef N_NIMCALL_PTR(void, Globalmarkerproc55802) (void);
struct Keyvaluepair152604 {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Exception  {
  TNimObject Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  Systemerror3626  {
  Exception Sup;
};
struct  Oserror3630  {
  Systemerror3626 Sup;
NI32 errorcode;
};
struct  Cell47305  {
NI refcount;
TNimType* typ;
};
struct  Cellseq47321  {
NI len;
NI cap;
Cell47305** d;
};
typedef Smallchunk29440* TY29501[512];
typedef Trunk29410* Trunkbuckets29412[256];
struct  Intset29414  {
Trunkbuckets29412 data;
};
struct  Memregion29486  {
NI minlargeobj;
NI maxlargeobj;
TY29501 freesmallchunks;
Llchunk29480* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk29442* freechunkslist;
Intset29414 chunkstarts;
Avlnode29484* root;
Avlnode29484* deleted;
Avlnode29484* last;
Avlnode29484* freeavlnodes;
NIM_BOOL locked;
};
struct  Gcstat49814  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Cellset47317  {
NI counter;
NI max;
Pagedesc47313* head;
Pagedesc47313** data;
};
struct  Gcheap49818  {
Gcstack49816* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq47321 zct;
Cellseq47321 decstack;
Cellseq47321 tempstack;
NI recgclock;
Memregion29486 region;
Gcstat49814 stat;
Cellset47317 marked;
Cellseq47321 additionalroots;
};
struct TY128506 {
NimStringDesc* Field0;
NimStringDesc* Field1;
NimStringDesc* Field2;
};
struct  Indexerror3652  {
  Exception Sup;
};
typedef NU8 Pathcomponent137212;
typedef struct {
N_NIMCALL_PTR(NIM_BOOL, ClPrc) (Exception* e0, void* ClEnv);
void* ClEnv;
} TY17211;
struct  TSafePoint  {
TSafePoint* prev;
NI status;
jmp_buf context;
NIM_BOOL hasRaiseAction;
TY17211 raiseAction;
};
typedef NIM_CHAR TY120770[256];
typedef NU8 Filemode13009;
struct  Gcstack49816  {
Gcstack49816* prev;
Gcstack49816* next;
void* starts;
void* pos;
NI maxstacksize;
};
struct  Basechunk29438  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk29440  {
  Basechunk29438 Sup;
Smallchunk29440* next;
Smallchunk29440* prev;
Freecell29430* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk29480  {
NI size;
NI acc;
Llchunk29480* next;
};
struct  Bigchunk29442  {
  Basechunk29438 Sup;
Bigchunk29442* next;
Bigchunk29442* prev;
NI align;
NF data;
};
typedef NI TY29419[8];
struct  Trunk29410  {
Trunk29410* next;
NI key;
TY29419 bits;
};
typedef Avlnode29484* TY29491[2];
struct  Avlnode29484  {
TY29491 link;
NI key;
NI upperbound;
NI level;
};
struct  Pagedesc47313  {
Pagedesc47313* next;
NI key;
TY29419 bits;
};
struct  Freecell29430  {
Freecell29430* next;
NI zerofield;
};
struct TY135002 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, nimGCvisit)(void* d0, NI op0);
N_NIMCALL(void, T2125978480_2)(void* p, NI op);
N_NIMCALL(void, T2125978480_3)(void);
N_NIMCALL(void, nimRegisterGlobalMarker)(Globalmarkerproc55802 markerproc0);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src0);
N_NIMCALL(void, nossplitPath)(NimStringDesc* path0, Keyvaluepair152604* Result);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s0, NI start_79210_1689653243, NI last0);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s0, NI first0, NI last0);
N_NIMCALL(void, unsureAsgnRef)(void** dest0, void* src0);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s0, NI start0);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s0, NI first0);
N_NIMCALL(NI, searchextpos_128469_2125978480)(NimStringDesc* s0);
static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0);
static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0);
N_NIMCALL(NimStringDesc*, normext_128465_2125978480)(NimStringDesc* ext0);
static N_INLINE(void, appendChar)(NimStringDesc* dest0, NIM_CHAR c0);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space0);
N_NIMCALL(NimStringDesc*, mnewString)(NI len0);
N_NIMCALL(NimStringDesc*, mnewString)(NI len0);
N_NOINLINE(void, raiseoserror_130603_2125978480)(NI32 errorcode0, NimStringDesc* additionalinfo0);
N_NIMCALL(void*, newObj)(TNimType* typ0, NI size0);
N_NIMCALL(NimStringDesc*, oserrormsg_130411_2125978480)(NI32 errorcode0);
N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str0);
static N_INLINE(void, asgnRefNoCycle)(void** dest0, void* src0);
static N_INLINE(Cell47305*, usrtocell_51440_1689653243)(void* usr0);
static N_INLINE(void, rtladdzct_52601_1689653243)(Cell47305* c0);
N_NOINLINE(void, addzct_51417_1689653243)(Cellseq47321* s0, Cell47305* c0);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src0);
static N_INLINE(void, nimGCunrefNoCycle)(void* p0);
N_NIMCALL(void, raiseException)(Exception* e0, NCSTRING ename0);
N_NIMCALL(NI32, oslasterror_130619_2125978480)(void);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s0, NI newlen0);
N_NIMCALL(void, nossplitFile)(NimStringDesc* path0, TY128506* Result);
N_NIMCALL(NimStringDesc*, nosgetAppFilename)(void);
N_NIMCALL(NimStringDesc*, getapplaux_143401_2125978480)(NimStringDesc* procpath0);
N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x0);
N_NIMCALL(NimStringDesc*, getapplheuristic_143601_2125978480)(void);
N_NIMCALL(NimStringDesc*, paramstr_143007_2125978480)(NI i0);
N_NIMCALL(NimStringDesc*, getenv_135625_2125978480)(NimStringDesc* key0);
N_NIMCALL(NI, findenvvar_135602_2125978480)(NimStringDesc* key0);
N_NIMCALL(void, getenvvarsc_135202_2125978480)(void);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ0, NI len0);
static N_INLINE(NIM_BOOL, HEX3DHEX3D_93846_1689653243)(NCSTRING x0, NCSTRING y0);
N_NIMCALL(TGenericSeq*, incrSeqV2)(TGenericSeq* seq0, NI elemsize0);
N_NIMCALL(NIM_BOOL, nsuStartsWith)(NimStringDesc* s0, NimStringDesc* prefix0);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s0, NIM_CHAR sub0, NI start0);
N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head0, NimStringDesc* tail0);
N_NIMCALL(NIM_BOOL, nosexistsFile)(NimStringDesc* filename0);
N_NIMCALL(NI, parentdirpos_128310_2125978480)(NimStringDesc* path0);
N_NIMCALL(void, rawcreatedir_138830_2125978480)(NimStringDesc* dir0);
N_NIMCALL(NI, cmp_5683_1689653243)(NimStringDesc* x0, NimStringDesc* y0);
N_NIMCALL(NI, nsuCmpIgnoreCase)(NimStringDesc* a0, NimStringDesc* b0);
N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename0, NimStringDesc* ext0);
N_NIMCALL(NimStringDesc*, HEX2F_128265_2125978480)(NimStringDesc* head0, NimStringDesc* tail0);
N_NIMCALL(NimStringDesc*, expandtilde_141801_2125978480)(NimStringDesc* path0);
N_NIMCALL(NimStringDesc*, nosgetHomeDir)(void);
N_NIMCALL(NIM_BOOL, checksymlink_142201_2125978480)(NimStringDesc* path0);
N_NIMCALL(NIM_BOOL, nosisAbsolute)(NimStringDesc* path0);
N_NIMCALL(NimStringDesc*, nosparentDir)(NimStringDesc* path0);
static N_INLINE(void, pushSafePoint)(TSafePoint* s0);
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a0, NimStringDesc* b0);
static N_INLINE(NIM_BOOL, equalmem_7495_1689653243)(void* a0, void* b0, NI size0);
N_NIMCALL(Pathcomponent137212, getsymlinkfilekind_137219_2125978480)(NimStringDesc* path0);
N_NIMCALL(void, nosremoveFile)(NimStringDesc* file0);
N_NIMCALL(void, nosremoveDir)(NimStringDesc* dir0);
static N_INLINE(void, popSafePoint)(void);
N_NIMCALL(void, reraiseException)(void);
N_NIMCALL(void, rawremovedir_138714_2125978480)(NimStringDesc* dir0);
N_NIMCALL(NIM_BOOL, open_14803_1689653243)(FILE** f0, NimStringDesc* filename0, Filemode13009 mode0, NI bufsize0);
N_NIMCALL(void, close_14853_1689653243)(FILE* f0);
N_NOCONV(void*, alloc_7801_1689653243)(NI size0);
N_NIMCALL(NI, readbuffer_14956_1689653243)(FILE* f0, void* buffer0, NI len0);
N_NIMCALL(NI, writebuffer_14978_1689653243)(FILE* f0, void* buffer0, NI len0);
N_NOCONV(void, dealloc_7848_1689653243)(void* p0);
N_NIMCALL(NI64, ntDiffTime)(time_t a0, time_t b0);
N_NIMCALL(time_t, nosgetLastModificationTime)(NimStringDesc* file0);
STRING_LITERAL(T2125978480_4, "", 0);
STRING_LITERAL(T2125978480_5, "\012Additional info: ", 18);
STRING_LITERAL(T2125978480_6, "unknown OS error", 16);
STRING_LITERAL(T2125978480_7, "/proc/", 6);
STRING_LITERAL(T2125978480_8, "/path/a.out", 11);
STRING_LITERAL(T2125978480_9, "invalid index", 13);
STRING_LITERAL(T2125978480_10, "PATH", 4);
STRING_LITERAL(T2125978480_11, "HOME", 4);
STRING_LITERAL(T2125978480_12, "/", 1);
STRING_LITERAL(T2125978480_13, "/.config/", 9);
STRING_LITERAL(T2125978480_15, ".", 1);
STRING_LITERAL(T2125978480_16, "..", 2);
NIM_BOOL envcomputed_135001_2125978480;
TY135002* environment_135003_2125978480;
extern TNimType NTI138; /* string */
TNimType NTI135002; /* seq[string] */
extern NCSTRING* environ;
extern int cmdCount;
extern NCSTRING* cmdLine;
extern TNimType NTI130607; /* ref OSError */
extern TNimType NTI3630; /* OSError */
extern Gcheap49818 gch_49858_1689653243;
extern TNimType NTI143015; /* ref IndexError */
extern TNimType NTI3652; /* IndexError */
extern TSafePoint* exchandler_18837_1689653243;
N_NIMCALL(void, T2125978480_2)(void* p, NI op) {
	TY135002* a;
	NI LOC1;
	a = (TY135002*)p;
	LOC1 = (NI)0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1], op);
	}
}
N_NIMCALL(void, T2125978480_3)(void) {
	nimGCvisit((void*)environment_135003_2125978480, 0);
}

N_NIMCALL(void, nossplitPath)(NimStringDesc* path0, Keyvaluepair152604* Result) {
	NI seppos0;
	seppos0 = ((NI) -1);
	{
		NI i_128290_2125978480;
		NI HEX3Atmp_128303_2125978480;
		NI res_128306_2125978480;
		i_128290_2125978480 = (NI)0;
		HEX3Atmp_128303_2125978480 = (NI)0;
		HEX3Atmp_128303_2125978480 = (NI)((path0 ? path0->Sup.len : 0) - ((NI) 1));
		res_128306_2125978480 = HEX3Atmp_128303_2125978480;
		{
			while (1) {
				if (!(((NI) 0) <= res_128306_2125978480)) goto LA3;
				i_128290_2125978480 = res_128306_2125978480;
				{
					if (!(((NU8)(path0->data[i_128290_2125978480])) == ((NU8)(47)) || ((NU8)(path0->data[i_128290_2125978480])) == ((NU8)(47)))) goto LA6;
					seppos0 = i_128290_2125978480;
					goto LA1;
				}
				LA6: ;
				res_128306_2125978480 -= ((NI) 1);
			} LA3: ;
		}
	} LA1: ;
	{
		if (!(((NI) 0) <= seppos0)) goto LA10;
		unsureAsgnRef((void**) (&(*Result).Field0), copyStrLast(path0, ((NI) 0), (NI)(seppos0 - ((NI) 1))));
		unsureAsgnRef((void**) (&(*Result).Field1), copyStr(path0, (NI)(seppos0 + ((NI) 1))));
	}
	goto LA8;
	LA10: ;
	{
		unsureAsgnRef((void**) (&(*Result).Field0), copyString(((NimStringDesc*) &T2125978480_4)));
		unsureAsgnRef((void**) (&(*Result).Field1), copyString(path0));
	}
	LA8: ;
}

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

N_NIMCALL(NI, searchextpos_128469_2125978480)(NimStringDesc* s0) {
	NI result0;
	result0 = (NI)0;
	result0 = ((NI) -1);
	{
		NI i_128483_2125978480;
		NI HEX3Atmp_128496_2125978480;
		NI res_128499_2125978480;
		i_128483_2125978480 = (NI)0;
		HEX3Atmp_128496_2125978480 = (NI)0;
		HEX3Atmp_128496_2125978480 = (NI)((s0 ? s0->Sup.len : 0) - ((NI) 1));
		res_128499_2125978480 = HEX3Atmp_128496_2125978480;
		{
			while (1) {
				if (!(((NI) 1) <= res_128499_2125978480)) goto LA3;
				i_128483_2125978480 = res_128499_2125978480;
				{
					if (!((NU8)(s0->data[i_128483_2125978480]) == (NU8)(46))) goto LA6;
					result0 = i_128483_2125978480;
					goto LA1;
				}
				goto LA4;
				LA6: ;
				{
					if (!(((NU8)(s0->data[i_128483_2125978480])) == ((NU8)(47)) || ((NU8)(s0->data[i_128483_2125978480])) == ((NU8)(47)))) goto LA9;
					goto LA1;
				}
				goto LA4;
				LA9: ;
				LA4: ;
				res_128499_2125978480 -= ((NI) 1);
			} LA3: ;
		}
	} LA1: ;
	return result0;
}

static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0) {
	void* LOC1;
	LOC1 = (void*)0;
	LOC1 = memcpy(dest0, source0, ((size_t) (size0)));
}

static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0) {
	copymem_7485_1689653243(((void*) ((&(*dest0).data[((*dest0).Sup.len)- 0]))), ((void*) ((*src0).data)), ((NI) ((NI)((*src0).Sup.len + ((NI) 1)))));
	(*dest0).Sup.len += (*src0).Sup.len;
}

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

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

N_NIMCALL(NimStringDesc*, noschangeFileExt)(NimStringDesc* filename0, NimStringDesc* ext0) {
	NimStringDesc* result0;
	NI extpos0;
	result0 = (NimStringDesc*)0;
	extpos0 = searchextpos_128469_2125978480(filename0);
	{
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		if (!(extpos0 < ((NI) 0))) goto LA3;
		LOC5 = (NimStringDesc*)0;
		LOC6 = (NimStringDesc*)0;
		LOC6 = normext_128465_2125978480(ext0);
		LOC5 = rawNewString(filename0->Sup.len + LOC6->Sup.len + 0);
appendString(LOC5, filename0);
appendString(LOC5, LOC6);
		result0 = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* LOC8;
		NimStringDesc* LOC9;
		NimStringDesc* LOC10;
		LOC8 = (NimStringDesc*)0;
		LOC9 = (NimStringDesc*)0;
		LOC9 = copyStrLast(filename0, ((NI) 0), (NI)(extpos0 - ((NI) 1)));
		LOC10 = (NimStringDesc*)0;
		LOC10 = normext_128465_2125978480(ext0);
		LOC8 = rawNewString(LOC9->Sup.len + LOC10->Sup.len + 0);
appendString(LOC8, LOC9);
appendString(LOC8, LOC10);
		result0 = LOC8;
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, oserrormsg_130411_2125978480)(NI32 errorcode0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = copyString(((NimStringDesc*) &T2125978480_4));
	{
		NCSTRING LOC5;
		if (!!((errorcode0 == ((NI32) 0)))) goto LA3;
		LOC5 = (NCSTRING)0;
		LOC5 = strerror(errorcode0);
		result0 = cstrToNimstr(LOC5);
	}
	LA3: ;
	return result0;
}

static N_INLINE(Cell47305*, usrtocell_51440_1689653243)(void* usr0) {
	Cell47305* result0;
	result0 = (Cell47305*)0;
	result0 = ((Cell47305*) ((NI)((NU64)(((NI) (usr0))) - (NU64)(((NI)sizeof(Cell47305))))));
	return result0;
}

static N_INLINE(void, rtladdzct_52601_1689653243)(Cell47305* c0) {
	addzct_51417_1689653243((&gch_49858_1689653243.zct), c0);
}

static N_INLINE(void, asgnRefNoCycle)(void** dest0, void* src0) {
	{
		Cell47305* c0;
		if (!!((src0 == NIM_NIL))) goto LA3;
		c0 = usrtocell_51440_1689653243(src0);
		(*c0).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell47305* c0;
		if (!!(((*dest0) == NIM_NIL))) goto LA7;
		c0 = usrtocell_51440_1689653243((*dest0));
		{
			(*c0).refcount -= ((NI) 8);
			if (!((NU64)((*c0).refcount) < (NU64)(((NI) 8)))) goto LA11;
			rtladdzct_52601_1689653243(c0);
		}
		LA11: ;
	}
	LA7: ;
	(*dest0) = src0;
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p0) {
	Cell47305* c0;
	c0 = usrtocell_51440_1689653243(p0);
	{
		(*c0).refcount -= ((NI) 8);
		if (!((NU64)((*c0).refcount) < (NU64)(((NI) 8)))) goto LA3;
		rtladdzct_52601_1689653243(c0);
	}
	LA3: ;
}

N_NOINLINE(void, raiseoserror_130603_2125978480)(NI32 errorcode0, NimStringDesc* additionalinfo0) {
	Oserror3630* e0;
	e0 = (Oserror3630*)0;
	e0 = (Oserror3630*) newObj((&NTI130607), sizeof(Oserror3630));
	(*e0).Sup.Sup.Sup.m_type = (&NTI3630);
	(*e0).errorcode = errorcode0;
	{
		if (!((additionalinfo0 ? additionalinfo0->Sup.len : 0) == ((NI) 0))) goto LA3;
		asgnRefNoCycle((void**) (&(*e0).Sup.Sup.message), oserrormsg_130411_2125978480(errorcode0));
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		LOC6 = (NimStringDesc*)0;
		LOC7 = (NimStringDesc*)0;
		LOC7 = oserrormsg_130411_2125978480(errorcode0);
		LOC6 = rawNewString(LOC7->Sup.len + additionalinfo0->Sup.len + 18);
appendString(LOC6, LOC7);
appendString(LOC6, ((NimStringDesc*) &T2125978480_5));
appendString(LOC6, additionalinfo0);
		asgnRefNoCycle((void**) (&(*e0).Sup.Sup.message), LOC6);
	}
	LA1: ;
	{
		NimStringDesc* LOC12;
		if (!(((*e0).Sup.Sup.message) && ((*e0).Sup.Sup.message)->Sup.len == 0)) goto LA10;
		LOC12 = (NimStringDesc*)0;
		LOC12 = (*e0).Sup.Sup.message; (*e0).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &T2125978480_6));
		if (LOC12) nimGCunrefNoCycle(LOC12);
	}
	LA10: ;
	raiseException((Exception*)e0, "OSError");
}

N_NIMCALL(NI32, oslasterror_130619_2125978480)(void) {
	NI32 result0;
	result0 = (NI32)0;
	result0 = errno;
	return result0;
}

N_NIMCALL(NimStringDesc*, nosexpandFilename)(NimStringDesc* filename0) {
	NimStringDesc* result0;
	NCSTRING r0;
	int LOC6;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(((NI) (PATH_MAX)));
	r0 = realpath(filename0->data, result0->data);
	{
		NI32 LOC5;
		if (!r0 == 0) goto LA3;
		LOC5 = (NI32)0;
		LOC5 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC5, ((NimStringDesc*) &T2125978480_4));
	}
	LA3: ;
	LOC6 = (int)0;
	LOC6 = strlen(result0->data);
	result0 = setLengthStr(result0, ((NI) (LOC6)));
	return result0;
}

N_NIMCALL(void, nossplitFile)(NimStringDesc* path0, TY128506* Result) {
	{
		NIM_BOOL LOC3;
		LOC3 = (NIM_BOOL)0;
		LOC3 = ((path0 ? path0->Sup.len : 0) == ((NI) 0));
		if (LOC3) goto LA4;
		LOC3 = (((NU8)(path0->data[(NI)((path0 ? path0->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)) || ((NU8)(path0->data[(NI)((path0 ? path0->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)));
		LA4: ;
		if (!LOC3) goto LA5;
		unsureAsgnRef((void**) (&(*Result).Field0), copyString(path0));
		unsureAsgnRef((void**) (&(*Result).Field1), copyString(((NimStringDesc*) &T2125978480_4)));
		unsureAsgnRef((void**) (&(*Result).Field2), copyString(((NimStringDesc*) &T2125978480_4)));
	}
	goto LA1;
	LA5: ;
	{
		NI seppos0;
		NI dotpos0;
		seppos0 = ((NI) -1);
		dotpos0 = (path0 ? path0->Sup.len : 0);
		{
			NI i_128535_2125978480;
			NI HEX3Atmp_128559_2125978480;
			NI res_128562_2125978480;
			i_128535_2125978480 = (NI)0;
			HEX3Atmp_128559_2125978480 = (NI)0;
			HEX3Atmp_128559_2125978480 = (NI)((path0 ? path0->Sup.len : 0) - ((NI) 1));
			res_128562_2125978480 = HEX3Atmp_128559_2125978480;
			{
				while (1) {
					if (!(((NI) 0) <= res_128562_2125978480)) goto LA10;
					i_128535_2125978480 = res_128562_2125978480;
					{
						if (!((NU8)(path0->data[i_128535_2125978480]) == (NU8)(46))) goto LA13;
						{
							NIM_BOOL LOC17;
							NIM_BOOL LOC18;
							LOC17 = (NIM_BOOL)0;
							LOC18 = (NIM_BOOL)0;
							LOC18 = (dotpos0 == (path0 ? path0->Sup.len : 0));
							if (!(LOC18)) goto LA19;
							LOC18 = (((NI) 0) < i_128535_2125978480);
							LA19: ;
							LOC17 = LOC18;
							if (!(LOC17)) goto LA20;
							LOC17 = !((((NU8)(path0->data[(NI)(i_128535_2125978480 - ((NI) 1))])) == ((NU8)(47)) || ((NU8)(path0->data[(NI)(i_128535_2125978480 - ((NI) 1))])) == ((NU8)(47))));
							LA20: ;
							if (!LOC17) goto LA21;
							dotpos0 = i_128535_2125978480;
						}
						LA21: ;
					}
					goto LA11;
					LA13: ;
					{
						if (!(((NU8)(path0->data[i_128535_2125978480])) == ((NU8)(47)) || ((NU8)(path0->data[i_128535_2125978480])) == ((NU8)(47)))) goto LA24;
						seppos0 = i_128535_2125978480;
						goto LA8;
					}
					goto LA11;
					LA24: ;
					LA11: ;
					res_128562_2125978480 -= ((NI) 1);
				} LA10: ;
			}
		} LA8: ;
		unsureAsgnRef((void**) (&(*Result).Field0), copyStrLast(path0, ((NI) 0), (NI)(seppos0 - ((NI) 1))));
		unsureAsgnRef((void**) (&(*Result).Field1), copyStrLast(path0, (NI)(seppos0 + ((NI) 1)), (NI)(dotpos0 - ((NI) 1))));
		unsureAsgnRef((void**) (&(*Result).Field2), copyStr(path0, dotpos0));
	}
	LA1: ;
}

N_NIMCALL(NimStringDesc*, getapplaux_143401_2125978480)(NimStringDesc* procpath0) {
	NimStringDesc* result0;
	NI len0;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(((NI) 256));
	len0 = readlink(procpath0->data, result0->data, ((NI) 256));
	{
		if (!(((NI) 256) < len0)) goto LA3;
		result0 = mnewString(((NI) ((NI)(len0 + ((NI) 1)))));
		len0 = readlink(procpath0->data, result0->data, len0);
	}
	LA3: ;
	result0 = setLengthStr(result0, ((NI) (len0)));
	return result0;
}

N_NIMCALL(NimStringDesc*, paramstr_143007_2125978480)(NI i0) {
	NimStringDesc* result0;
	Indexerror3652* e_143014_2125978480;
	NimStringDesc* LOC7;
{	result0 = (NimStringDesc*)0;
	{
		NIM_BOOL LOC3;
		LOC3 = (NIM_BOOL)0;
		LOC3 = (i0 < ((NI) (cmdCount)));
		if (!(LOC3)) goto LA4;
		LOC3 = (((NI) 0) <= i0);
		LA4: ;
		if (!LOC3) goto LA5;
		result0 = cstrToNimstr(cmdLine[(i0)- 0]);
		goto BeforeRet;
	}
	LA5: ;
	e_143014_2125978480 = (Indexerror3652*)0;
	e_143014_2125978480 = (Indexerror3652*) newObj((&NTI143015), sizeof(Indexerror3652));
	(*e_143014_2125978480).Sup.Sup.m_type = (&NTI3652);
	LOC7 = (NimStringDesc*)0;
	LOC7 = (*e_143014_2125978480).Sup.message; (*e_143014_2125978480).Sup.message = copyStringRC1(((NimStringDesc*) &T2125978480_9));
	if (LOC7) nimGCunrefNoCycle(LOC7);
	raiseException((Exception*)e_143014_2125978480, "IndexError");
	}BeforeRet: ;
	return result0;
}

static N_INLINE(NIM_BOOL, HEX3DHEX3D_93846_1689653243)(NCSTRING x0, NCSTRING y0) {
	NIM_BOOL result0;
	result0 = (NIM_BOOL)0;
	{
		if (!(((void*) (x0)) == ((void*) (y0)))) goto LA3;
		result0 = NIM_TRUE;
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC6;
		LOC6 = (NIM_BOOL)0;
		LOC6 = x0 == 0;
		if (LOC6) goto LA7;
		LOC6 = y0 == 0;
		LA7: ;
		if (!LOC6) goto LA8;
		result0 = NIM_FALSE;
	}
	goto LA1;
	LA8: ;
	{
		int LOC11;
		LOC11 = (int)0;
		LOC11 = strcmp(x0, y0);
		result0 = (LOC11 == ((NI32) 0));
	}
	LA1: ;
	return result0;
}

N_NIMCALL(void, getenvvarsc_135202_2125978480)(void) {
	{
		NI i0;
		if (!!(envcomputed_135001_2125978480)) goto LA3;
		if (environment_135003_2125978480) nimGCunrefNoCycle(environment_135003_2125978480);
		environment_135003_2125978480 = (TY135002*) newSeqRC1((&NTI135002), 0);
		i0 = ((NI) 0);
		{
			while (1) {
				NimStringDesc* LOC12;
				NimStringDesc* LOC13;
				{
					NIM_BOOL LOC9;
					LOC9 = (NIM_BOOL)0;
					LOC9 = HEX3DHEX3D_93846_1689653243(environ[(i0)- 0], NIM_NIL);
					if (!LOC9) goto LA10;
					goto LA5;
				}
				LA10: ;
				LOC12 = (NimStringDesc*)0;
				LOC12 = cstrToNimstr(environ[(i0)- 0]);
				environment_135003_2125978480 = (TY135002*) incrSeqV2(&(environment_135003_2125978480)->Sup, sizeof(NimStringDesc*));
				LOC13 = (NimStringDesc*)0;
				LOC13 = environment_135003_2125978480->data[environment_135003_2125978480->Sup.len]; environment_135003_2125978480->data[environment_135003_2125978480->Sup.len] = copyStringRC1(LOC12);
				if (LOC13) nimGCunrefNoCycle(LOC13);
				++environment_135003_2125978480->Sup.len;
				i0 += ((NI) 1);
			}
		} LA5: ;
		envcomputed_135001_2125978480 = NIM_TRUE;
	}
	LA3: ;
}

N_NIMCALL(NI, findenvvar_135602_2125978480)(NimStringDesc* key0) {
	NI result0;
	NimStringDesc* temp0;
	NimStringDesc* LOC1;
{	result0 = (NI)0;
	getenvvarsc_135202_2125978480();
	LOC1 = (NimStringDesc*)0;
	LOC1 = rawNewString(key0->Sup.len + 1);
appendString(LOC1, key0);
appendChar(LOC1, 61);
	temp0 = LOC1;
	{
		NI i_135616_2125978480;
		NI HEX3Atmp_135618_2125978480;
		NI res_135621_2125978480;
		i_135616_2125978480 = (NI)0;
		HEX3Atmp_135618_2125978480 = (NI)0;
		HEX3Atmp_135618_2125978480 = (environment_135003_2125978480 ? (environment_135003_2125978480->Sup.len-1) : -1);
		res_135621_2125978480 = ((NI) 0);
		{
			while (1) {
				if (!(res_135621_2125978480 <= HEX3Atmp_135618_2125978480)) goto LA4;
				i_135616_2125978480 = res_135621_2125978480;
				{
					NIM_BOOL LOC7;
					LOC7 = (NIM_BOOL)0;
					LOC7 = nsuStartsWith(environment_135003_2125978480->data[i_135616_2125978480], temp0);
					if (!LOC7) goto LA8;
					result0 = i_135616_2125978480;
					goto BeforeRet;
				}
				LA8: ;
				res_135621_2125978480 += ((NI) 1);
			} LA4: ;
		}
	}
	result0 = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, getenv_135625_2125978480)(NimStringDesc* key0) {
	NimStringDesc* result0;
	NI i0;
{	result0 = (NimStringDesc*)0;
	i0 = findenvvar_135602_2125978480(key0);
	{
		NI LOC5;
		if (!(((NI) 0) <= i0)) goto LA3;
		LOC5 = (NI)0;
		LOC5 = nsuFindChar(environment_135003_2125978480->data[i0], 61, ((NI) 0));
		result0 = copyStr(environment_135003_2125978480->data[i0], (NI)(LOC5 + ((NI) 1)));
		goto BeforeRet;
	}
	goto LA1;
	LA3: ;
	{
		NCSTRING env0;
		env0 = getenv(key0->data);
		{
			NIM_BOOL LOC9;
			LOC9 = (NIM_BOOL)0;
			LOC9 = HEX3DHEX3D_93846_1689653243(env0, NIM_NIL);
			if (!LOC9) goto LA10;
			result0 = copyString(((NimStringDesc*) &T2125978480_4));
			goto BeforeRet;
		}
		LA10: ;
		result0 = cstrToNimstr(env0);
	}
	LA1: ;
	}BeforeRet: ;
	return result0;
}

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

N_NIMCALL(NIM_BOOL, nosexistsFile)(NimStringDesc* filename0) {
	NIM_BOOL result0;
	struct stat res0;
	NIM_BOOL LOC1;
	int LOC2;
{	result0 = (NIM_BOOL)0;
	memset((void*)(&res0), 0, sizeof(res0));
	LOC1 = (NIM_BOOL)0;
	LOC2 = (int)0;
	LOC2 = stat(filename0->data, (&res0));
	LOC1 = (((NI32) 0) <= LOC2);
	if (!(LOC1)) goto LA3;
	LOC1 = S_ISREG(res0.st_mode);
	LA3: ;
	result0 = LOC1;
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, getapplheuristic_143601_2125978480)(void) {
	NimStringDesc* result0;
{	result0 = (NimStringDesc*)0;
	result0 = paramstr_143007_2125978480(((NI) 0));
	{
		NIM_BOOL LOC3;
		LOC3 = (NIM_BOOL)0;
		LOC3 = (((NI) 0) < (result0 ? result0->Sup.len : 0));
		if (!(LOC3)) goto LA4;
		LOC3 = !(((NU8)(result0->data[((NI) 0)]) == (NU8)(47)));
		LA4: ;
		if (!LOC3) goto LA5;
		{
			NimStringDesc* p_143802_2125978480;
			NimStringDesc* HEX3Atmp_143809_2125978480;
			NI last_143813_2125978480;
			NI splits_143815_2125978480;
			p_143802_2125978480 = (NimStringDesc*)0;
			HEX3Atmp_143809_2125978480 = (NimStringDesc*)0;
			HEX3Atmp_143809_2125978480 = getenv_135625_2125978480(((NimStringDesc*) &T2125978480_10));
			last_143813_2125978480 = ((NI) 0);
			splits_143815_2125978480 = ((NI) -1);
			{
				if (!(((NI) 0) < (HEX3Atmp_143809_2125978480 ? HEX3Atmp_143809_2125978480->Sup.len : 0))) goto LA10;
				{
					while (1) {
						NI first_143817_2125978480;
						NimStringDesc* x0;
						if (!(last_143813_2125978480 <= (HEX3Atmp_143809_2125978480 ? HEX3Atmp_143809_2125978480->Sup.len : 0))) goto LA13;
						first_143817_2125978480 = last_143813_2125978480;
						{
							while (1) {
								NIM_BOOL LOC16;
								LOC16 = (NIM_BOOL)0;
								LOC16 = (last_143813_2125978480 < (HEX3Atmp_143809_2125978480 ? HEX3Atmp_143809_2125978480->Sup.len : 0));
								if (!(LOC16)) goto LA17;
								LOC16 = !((((NU8)(HEX3Atmp_143809_2125978480->data[last_143813_2125978480])) == ((NU8)(58))));
								LA17: ;
								if (!LOC16) goto LA15;
								last_143813_2125978480 += ((NI) 1);
							} LA15: ;
						}
						{
							if (!(splits_143815_2125978480 == ((NI) 0))) goto LA20;
							last_143813_2125978480 = (HEX3Atmp_143809_2125978480 ? HEX3Atmp_143809_2125978480->Sup.len : 0);
						}
						LA20: ;
						p_143802_2125978480 = copyStrLast(HEX3Atmp_143809_2125978480, first_143817_2125978480, (NI)(last_143813_2125978480 - ((NI) 1)));
						x0 = nosjoinPath(p_143802_2125978480, result0);
						{
							NIM_BOOL LOC24;
							LOC24 = (NIM_BOOL)0;
							LOC24 = nosexistsFile(x0);
							if (!LOC24) goto LA25;
							result0 = copyString(x0);
							goto BeforeRet;
						}
						LA25: ;
						{
							if (!(splits_143815_2125978480 == ((NI) 0))) goto LA29;
							goto LA12;
						}
						LA29: ;
						splits_143815_2125978480 -= ((NI) 1);
						last_143813_2125978480 += ((NI) 1);
					} LA13: ;
				} LA12: ;
			}
			LA10: ;
		}
	}
	LA5: ;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nosgetAppFilename)(void) {
	NimStringDesc* result0;
	NimStringDesc* LOC1;
	pid_t LOC2;
	NimStringDesc* LOC3;
	result0 = (NimStringDesc*)0;
	LOC1 = (NimStringDesc*)0;
	LOC2 = (pid_t)0;
	LOC2 = getpid();
	LOC3 = (NimStringDesc*)0;
	LOC3 = nimIntToStr(LOC2);
	LOC1 = rawNewString(LOC3->Sup.len + 17);
appendString(LOC1, ((NimStringDesc*) &T2125978480_7));
appendString(LOC1, LOC3);
appendString(LOC1, ((NimStringDesc*) &T2125978480_8));
	result0 = getapplaux_143401_2125978480(LOC1);
	{
		if (!((result0 ? result0->Sup.len : 0) == ((NI) 0))) goto LA6;
		result0 = getapplheuristic_143601_2125978480();
	}
	LA6: ;
	return result0;
}

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

N_NIMCALL(NI, parentdirpos_128310_2125978480)(NimStringDesc* path0) {
	NI result0;
	NI q0;
{	result0 = (NI)0;
	q0 = ((NI) 1);
	{
		NIM_BOOL LOC3;
		LOC3 = (NIM_BOOL)0;
		LOC3 = (((NI) 1) <= (path0 ? path0->Sup.len : 0));
		if (!(LOC3)) goto LA4;
		LOC3 = (((NU8)(path0->data[(NI)((path0 ? path0->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)) || ((NU8)(path0->data[(NI)((path0 ? path0->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)));
		LA4: ;
		if (!LOC3) goto LA5;
		q0 = ((NI) 2);
	}
	LA5: ;
	{
		NI i_128336_2125978480;
		NI HEX3Atmp_128349_2125978480;
		NI res_128352_2125978480;
		i_128336_2125978480 = (NI)0;
		HEX3Atmp_128349_2125978480 = (NI)0;
		HEX3Atmp_128349_2125978480 = (NI)((path0 ? path0->Sup.len : 0) - q0);
		res_128352_2125978480 = HEX3Atmp_128349_2125978480;
		{
			while (1) {
				if (!(((NI) 0) <= res_128352_2125978480)) goto LA9;
				i_128336_2125978480 = res_128352_2125978480;
				{
					if (!(((NU8)(path0->data[i_128336_2125978480])) == ((NU8)(47)) || ((NU8)(path0->data[i_128336_2125978480])) == ((NU8)(47)))) goto LA12;
					result0 = i_128336_2125978480;
					goto BeforeRet;
				}
				LA12: ;
				res_128352_2125978480 -= ((NI) 1);
			} LA9: ;
		}
	}
	result0 = ((NI) -1);
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nosparentDir)(NimStringDesc* path0) {
	NimStringDesc* result0;
	NI seppos0;
	result0 = (NimStringDesc*)0;
	seppos0 = parentdirpos_128310_2125978480(path0);
	{
		if (!(((NI) 0) <= seppos0)) goto LA3;
		result0 = copyStrLast(path0, ((NI) 0), (NI)(seppos0 - ((NI) 1)));
	}
	goto LA1;
	LA3: ;
	{
		result0 = copyString(((NimStringDesc*) &T2125978480_4));
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, HEX2F_128265_2125978480)(NimStringDesc* head0, NimStringDesc* tail0) {
	NimStringDesc* result0;
{	result0 = (NimStringDesc*)0;
	result0 = nosjoinPath(head0, tail0);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(void, rawcreatedir_138830_2125978480)(NimStringDesc* dir0) {
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		int LOC5;
		NI32 LOC10;
		LOC3 = (NIM_BOOL)0;
		LOC4 = (NIM_BOOL)0;
		LOC5 = (int)0;
		LOC5 = mkdir(dir0->data, ((mode_t) 511));
		LOC4 = !((LOC5 == ((NI32) 0)));
		if (!(LOC4)) goto LA6;
		LOC4 = !((errno == EEXIST));
		LA6: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA7;
		LOC3 = !((errno == ENOSYS));
		LA7: ;
		if (!LOC3) goto LA8;
		LOC10 = (NI32)0;
		LOC10 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC10, ((NimStringDesc*) &T2125978480_4));
	}
	LA8: ;
}

N_NIMCALL(void, noscreateDir)(NimStringDesc* dir0) {
	NIM_BOOL omitnext0;
	omitnext0 = NIM_FALSE;
	{
		NI i_139210_2125978480;
		NI HEX3Atmp_139223_2125978480;
		NI res_139226_2125978480;
		i_139210_2125978480 = (NI)0;
		HEX3Atmp_139223_2125978480 = (NI)0;
		HEX3Atmp_139223_2125978480 = (NI)((dir0 ? dir0->Sup.len : 0) - ((NI) 1));
		res_139226_2125978480 = ((NI) 1);
		{
			while (1) {
				if (!(res_139226_2125978480 <= HEX3Atmp_139223_2125978480)) goto LA3;
				i_139210_2125978480 = res_139226_2125978480;
				{
					if (!(((NU8)(dir0->data[i_139210_2125978480])) == ((NU8)(47)) || ((NU8)(dir0->data[i_139210_2125978480])) == ((NU8)(47)))) goto LA6;
					{
						if (!omitnext0) goto LA10;
						omitnext0 = NIM_FALSE;
					}
					goto LA8;
					LA10: ;
					{
						NimStringDesc* LOC13;
						LOC13 = (NimStringDesc*)0;
						LOC13 = copyStrLast(dir0, ((NI) 0), (NI)(i_139210_2125978480 - ((NI) 1)));
						rawcreatedir_138830_2125978480(LOC13);
					}
					LA8: ;
				}
				LA6: ;
				res_139226_2125978480 += ((NI) 1);
			} LA3: ;
		}
	}
	rawcreatedir_138830_2125978480(dir0);
}

N_NIMCALL(NimStringDesc*, nosjoinPathOpenArray)(NimStringDesc** parts0, NI parts0Len0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = copyString(parts0[((NI) 0)]);
	{
		NI i_128254_2125978480;
		NI HEX3Atmp_128258_2125978480;
		NI res_128261_2125978480;
		i_128254_2125978480 = (NI)0;
		HEX3Atmp_128258_2125978480 = (NI)0;
		HEX3Atmp_128258_2125978480 = (parts0Len0-1);
		res_128261_2125978480 = ((NI) 1);
		{
			while (1) {
				if (!(res_128261_2125978480 <= HEX3Atmp_128258_2125978480)) goto LA3;
				i_128254_2125978480 = res_128261_2125978480;
				result0 = nosjoinPath(result0, parts0[i_128254_2125978480]);
				res_128261_2125978480 += ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

N_NIMCALL(NI, paramcount_143026_2125978480)(void) {
	NI result0;
	result0 = (NI)0;
	result0 = ((NI) ((NI32)(cmdCount - ((NI32) 1))));
	return result0;
}

N_NIMCALL(NimStringDesc*, nosunixToNativePath)(NimStringDesc* path0, NimStringDesc* drive0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = copyString(path0);
	return result0;
}

N_NIMCALL(NIM_BOOL, nosisAbsolute)(NimStringDesc* path0) {
	NIM_BOOL result0;
	result0 = (NIM_BOOL)0;
	result0 = ((NU8)(path0->data[((NI) 0)]) == (NU8)(47));
	return result0;
}

N_NIMCALL(NimStringDesc*, nosgetHomeDir)(void) {
	NimStringDesc* result0;
	NimStringDesc* LOC1;
	NimStringDesc* LOC2;
{	result0 = (NimStringDesc*)0;
	LOC1 = (NimStringDesc*)0;
	LOC2 = (NimStringDesc*)0;
	LOC2 = getenv_135625_2125978480(((NimStringDesc*) &T2125978480_11));
	LOC1 = rawNewString(LOC2->Sup.len + 1);
appendString(LOC1, LOC2);
appendString(LOC1, ((NimStringDesc*) &T2125978480_12));
	result0 = LOC1;
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(Pathcomponent137212, getsymlinkfilekind_137219_2125978480)(NimStringDesc* path0) {
	Pathcomponent137212 result0;
	struct stat s0;
	result0 = (Pathcomponent137212)0;
	memset((void*)(&s0), 0, sizeof(s0));
	{
		int LOC3;
		NI32 LOC6;
		LOC3 = (int)0;
		LOC3 = stat(path0->data, (&s0));
		if (!(LOC3 < ((NI32) 0))) goto LA4;
		LOC6 = (NI32)0;
		LOC6 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC6, ((NimStringDesc*) &T2125978480_4));
	}
	LA4: ;
	{
		NIM_BOOL LOC9;
		LOC9 = (NIM_BOOL)0;
		LOC9 = S_ISDIR(s0.st_mode);
		if (!LOC9) goto LA10;
		result0 = ((Pathcomponent137212) 3);
	}
	goto LA7;
	LA10: ;
	{
		result0 = ((Pathcomponent137212) 1);
	}
	LA7: ;
	return result0;
}

N_NIMCALL(NI, noscmpPaths)(NimStringDesc* patha0, NimStringDesc* pathb0) {
	NI result0;
	result0 = (NI)0;
	{
		if (!NIM_TRUE) goto LA3;
		result0 = cmp_5683_1689653243(patha0, pathb0);
	}
	goto LA1;
	LA3: ;
	{
		result0 = nsuCmpIgnoreCase(patha0, pathb0);
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename0, NimStringDesc* ext0) {
	NimStringDesc* result0;
	NI extpos0;
	result0 = (NimStringDesc*)0;
	extpos0 = searchextpos_128469_2125978480(filename0);
	{
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		if (!(extpos0 < ((NI) 0))) goto LA3;
		LOC5 = (NimStringDesc*)0;
		LOC6 = (NimStringDesc*)0;
		LOC6 = normext_128465_2125978480(ext0);
		LOC5 = rawNewString(filename0->Sup.len + LOC6->Sup.len + 0);
appendString(LOC5, filename0);
appendString(LOC5, LOC6);
		result0 = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		result0 = copyString(filename0);
	}
	LA1: ;
	return result0;
}

N_NIMCALL(void, putenv_135638_2125978480)(NimStringDesc* key0, NimStringDesc* val0) {
	NI indx0;
	indx0 = findenvvar_135602_2125978480(key0);
	{
		NimStringDesc* LOC5;
		if (!(((NI) 0) <= indx0)) goto LA3;
		LOC5 = (NimStringDesc*)0;
		LOC5 = rawNewString(key0->Sup.len + val0->Sup.len + 1);
appendString(LOC5, key0);
appendChar(LOC5, 61);
appendString(LOC5, val0);
		asgnRefNoCycle((void**) (&environment_135003_2125978480->data[indx0]), LOC5);
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* LOC7;
		NimStringDesc* LOC8;
		LOC7 = (NimStringDesc*)0;
		LOC7 = rawNewString(key0->Sup.len + val0->Sup.len + 1);
appendString(LOC7, key0);
appendChar(LOC7, 61);
appendString(LOC7, val0);
		environment_135003_2125978480 = (TY135002*) incrSeqV2(&(environment_135003_2125978480)->Sup, sizeof(NimStringDesc*));
		LOC8 = (NimStringDesc*)0;
		LOC8 = environment_135003_2125978480->data[environment_135003_2125978480->Sup.len]; environment_135003_2125978480->data[environment_135003_2125978480->Sup.len] = copyStringRC1(LOC7);
		if (LOC8) nimGCunrefNoCycle(LOC8);
		++environment_135003_2125978480->Sup.len;
		indx0 = (environment_135003_2125978480 ? (environment_135003_2125978480->Sup.len-1) : -1);
	}
	LA1: ;
	{
		int LOC11;
		NI32 LOC14;
		LOC11 = (int)0;
		LOC11 = putenv(environment_135003_2125978480->data[indx0]->data);
		if (!!((LOC11 == ((NI32) 0)))) goto LA12;
		LOC14 = (NI32)0;
		LOC14 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC14, ((NimStringDesc*) &T2125978480_4));
	}
	LA12: ;
}

N_NIMCALL(NimStringDesc*, nosgetCurrentDir)(void) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(((NI) 512));
	{
		NCSTRING LOC3;
		NIM_BOOL LOC4;
		int LOC7;
		LOC3 = (NCSTRING)0;
		LOC3 = getcwd(result0->data, ((NI) 512));
		LOC4 = (NIM_BOOL)0;
		LOC4 = HEX3DHEX3D_93846_1689653243(LOC3, NIM_NIL);
		if (!!(LOC4)) goto LA5;
		LOC7 = (int)0;
		LOC7 = strlen(result0->data);
		result0 = setLengthStr(result0, ((NI) (LOC7)));
	}
	goto LA1;
	LA5: ;
	{
		NI32 LOC9;
		LOC9 = (NI32)0;
		LOC9 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC9, ((NimStringDesc*) &T2125978480_4));
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, expandtilde_141801_2125978480)(NimStringDesc* path0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		NIM_BOOL LOC7;
		NimStringDesc* LOC11;
		NimStringDesc* LOC12;
		LOC3 = (NIM_BOOL)0;
		LOC4 = (NIM_BOOL)0;
		LOC4 = (((NI) 1) < (path0 ? path0->Sup.len : 0));
		if (!(LOC4)) goto LA5;
		LOC4 = ((NU8)(path0->data[((NI) 0)]) == (NU8)(126));
		LA5: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA6;
		LOC7 = (NIM_BOOL)0;
		LOC7 = ((NU8)(path0->data[((NI) 1)]) == (NU8)(47));
		if (LOC7) goto LA8;
		LOC7 = ((NU8)(path0->data[((NI) 1)]) == (NU8)(92));
		LA8: ;
		LOC3 = LOC7;
		LA6: ;
		if (!LOC3) goto LA9;
		LOC11 = (NimStringDesc*)0;
		LOC11 = nosgetHomeDir();
		LOC12 = (NimStringDesc*)0;
		LOC12 = copyStr(path0, ((NI) 2));
		result0 = HEX2F_128265_2125978480(LOC11, LOC12);
	}
	goto LA1;
	LA9: ;
	{
		result0 = copyString(path0);
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, checksymlink_142201_2125978480)(NimStringDesc* path0) {
	NIM_BOOL result0;
	struct stat rawinfo0;
	result0 = (NIM_BOOL)0;
	memset((void*)(&rawinfo0), 0, sizeof(rawinfo0));
	{
		int LOC3;
		LOC3 = (int)0;
		LOC3 = lstat(path0->data, (&rawinfo0));
		if (!(LOC3 < ((NI32) 0))) goto LA4;
		result0 = NIM_FALSE;
	}
	goto LA1;
	LA4: ;
	{
		result0 = S_ISLNK(rawinfo0.st_mode);
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, findexe_142208_2125978480)(NimStringDesc* exe0, NIM_BOOL followsymlinks0) {
	NimStringDesc* result0;
	NimStringDesc* path0;
{	result0 = (NimStringDesc*)0;
	result0 = nosaddFileExt(exe0, ((NimStringDesc*) &T2125978480_4));
	{
		NIM_BOOL LOC3;
		LOC3 = (NIM_BOOL)0;
		LOC3 = nosexistsFile(result0);
		if (!LOC3) goto LA4;
		goto BeforeRet;
	}
	LA4: ;
	path0 = getenv_135625_2125978480(((NimStringDesc*) &T2125978480_10));
	{
		NimStringDesc* candidate_142214_2125978480;
		NI last_142612_2125978480;
		NI splits_142614_2125978480;
		candidate_142214_2125978480 = (NimStringDesc*)0;
		last_142612_2125978480 = ((NI) 0);
		splits_142614_2125978480 = ((NI) -1);
		{
			if (!(((NI) 0) < (path0 ? path0->Sup.len : 0))) goto LA9;
			{
				while (1) {
					NI first_142616_2125978480;
					NimStringDesc* x0;
					NimStringDesc* LOC21;
					if (!(last_142612_2125978480 <= (path0 ? path0->Sup.len : 0))) goto LA12;
					first_142616_2125978480 = last_142612_2125978480;
					{
						while (1) {
							NIM_BOOL LOC15;
							LOC15 = (NIM_BOOL)0;
							LOC15 = (last_142612_2125978480 < (path0 ? path0->Sup.len : 0));
							if (!(LOC15)) goto LA16;
							LOC15 = !(((NU8)(path0->data[last_142612_2125978480]) == (NU8)(58)));
							LA16: ;
							if (!LOC15) goto LA14;
							last_142612_2125978480 += ((NI) 1);
						} LA14: ;
					}
					{
						if (!(splits_142614_2125978480 == ((NI) 0))) goto LA19;
						last_142612_2125978480 = (path0 ? path0->Sup.len : 0);
					}
					LA19: ;
					candidate_142214_2125978480 = copyStrLast(path0, first_142616_2125978480, (NI)(last_142612_2125978480 - ((NI) 1)));
					LOC21 = (NimStringDesc*)0;
					LOC21 = expandtilde_141801_2125978480(candidate_142214_2125978480);
					x0 = HEX2F_128265_2125978480(LOC21, result0);
					{
						NIM_BOOL LOC24;
						LOC24 = (NIM_BOOL)0;
						LOC24 = nosexistsFile(x0);
						if (!LOC24) goto LA25;
						{
							while (1) {
								if (!followsymlinks0) goto LA28;
								{
									NIM_BOOL LOC31;
									NimStringDesc* r0;
									NI len0;
									LOC31 = (NIM_BOOL)0;
									LOC31 = checksymlink_142201_2125978480(x0);
									if (!LOC31) goto LA32;
									r0 = mnewString(((NI) 256));
									len0 = readlink(x0->data, r0->data, ((NI) 256));
									{
										NI32 LOC38;
										if (!(len0 < ((NI) 0))) goto LA36;
										LOC38 = (NI32)0;
										LOC38 = oslasterror_130619_2125978480();
										raiseoserror_130603_2125978480(LOC38, ((NimStringDesc*) &T2125978480_4));
									}
									LA36: ;
									{
										if (!(((NI) 256) < len0)) goto LA41;
										r0 = mnewString(((NI) ((NI)(len0 + ((NI) 1)))));
										len0 = readlink(x0->data, r0->data, len0);
									}
									LA41: ;
									r0 = setLengthStr(r0, ((NI) (len0)));
									{
										NIM_BOOL LOC45;
										LOC45 = (NIM_BOOL)0;
										LOC45 = nosisAbsolute(r0);
										if (!LOC45) goto LA46;
										x0 = copyString(r0);
									}
									goto LA43;
									LA46: ;
									{
										NimStringDesc* LOC49;
										LOC49 = (NimStringDesc*)0;
										LOC49 = nosparentDir(x0);
										x0 = HEX2F_128265_2125978480(LOC49, r0);
									}
									LA43: ;
								}
								goto LA29;
								LA32: ;
								{
									goto LA27;
								}
								LA29: ;
							} LA28: ;
						} LA27: ;
						result0 = copyString(x0);
						goto BeforeRet;
					}
					LA25: ;
					{
						if (!(splits_142614_2125978480 == ((NI) 0))) goto LA53;
						goto LA11;
					}
					LA53: ;
					splits_142614_2125978480 -= ((NI) 1);
					last_142612_2125978480 += ((NI) 1);
				} LA12: ;
			} LA11: ;
		}
		LA9: ;
	}
	result0 = copyString(((NimStringDesc*) &T2125978480_4));
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nosgetConfigDir)(void) {
	NimStringDesc* result0;
	NimStringDesc* LOC1;
	NimStringDesc* LOC2;
{	result0 = (NimStringDesc*)0;
	LOC1 = (NimStringDesc*)0;
	LOC2 = (NimStringDesc*)0;
	LOC2 = getenv_135625_2125978480(((NimStringDesc*) &T2125978480_11));
	LOC1 = rawNewString(LOC2->Sup.len + 9);
appendString(LOC1, LOC2);
appendString(LOC1, ((NimStringDesc*) &T2125978480_13));
	result0 = LOC1;
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, nosisRootDir)(NimStringDesc* path0) {
	NIM_BOOL result0;
	NI LOC1;
	result0 = (NIM_BOOL)0;
	LOC1 = (NI)0;
	LOC1 = parentdirpos_128310_2125978480(path0);
	result0 = (LOC1 < ((NI) 0));
	return result0;
}

N_NIMCALL(NIM_BOOL, existsenv_135634_2125978480)(NimStringDesc* key0) {
	NIM_BOOL result0;
{	result0 = (NIM_BOOL)0;
	{
		NCSTRING LOC3;
		NIM_BOOL LOC4;
		LOC3 = (NCSTRING)0;
		LOC3 = getenv(key0->data);
		LOC4 = (NIM_BOOL)0;
		LOC4 = HEX3DHEX3D_93846_1689653243(LOC3, NIM_NIL);
		if (!!(LOC4)) goto LA5;
		result0 = NIM_TRUE;
		goto BeforeRet;
	}
	goto LA1;
	LA5: ;
	{
		NI LOC8;
		LOC8 = (NI)0;
		LOC8 = findenvvar_135602_2125978480(key0);
		result0 = (((NI) 0) <= LOC8);
		goto BeforeRet;
	}
	LA1: ;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, nosexistsDir)(NimStringDesc* dir0) {
	NIM_BOOL result0;
	struct stat res0;
	NIM_BOOL LOC1;
	int LOC2;
{	result0 = (NIM_BOOL)0;
	memset((void*)(&res0), 0, sizeof(res0));
	LOC1 = (NIM_BOOL)0;
	LOC2 = (int)0;
	LOC2 = stat(dir0->data, (&res0));
	LOC1 = (((NI32) 0) <= LOC2);
	if (!(LOC1)) goto LA3;
	LOC1 = S_ISDIR(res0.st_mode);
	LA3: ;
	result0 = LOC1;
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

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

static N_INLINE(NIM_BOOL, equalmem_7495_1689653243)(void* a0, void* b0, NI size0) {
	NIM_BOOL result0;
	int LOC1;
	result0 = (NIM_BOOL)0;
	LOC1 = (int)0;
	LOC1 = memcmp(a0, b0, ((size_t) (size0)));
	result0 = (LOC1 == ((NI32) 0));
	return result0;
}

static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a0, NimStringDesc* b0) {
	NIM_BOOL result0;
	NIM_BOOL LOC11;
{	result0 = (NIM_BOOL)0;
	{
		if (!(a0 == b0)) goto LA3;
		result0 = NIM_TRUE;
		goto BeforeRet;
	}
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = (NIM_BOOL)0;
		LOC7 = (a0 == NIM_NIL);
		if (LOC7) goto LA8;
		LOC7 = (b0 == NIM_NIL);
		LA8: ;
		if (!LOC7) goto LA9;
		result0 = NIM_FALSE;
		goto BeforeRet;
	}
	LA9: ;
	LOC11 = (NIM_BOOL)0;
	LOC11 = ((*a0).Sup.len == (*b0).Sup.len);
	if (!(LOC11)) goto LA12;
	LOC11 = equalmem_7495_1689653243(((void*) ((*a0).data)), ((void*) ((*b0).data)), ((NI) ((*a0).Sup.len)));
	LA12: ;
	result0 = LOC11;
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(void, nosremoveFile)(NimStringDesc* file0) {
	{
		NIM_BOOL LOC3;
		int LOC4;
		NI32 LOC8;
		NCSTRING LOC9;
		NimStringDesc* LOC10;
		LOC3 = (NIM_BOOL)0;
		LOC4 = (int)0;
		LOC4 = remove(file0->data);
		LOC3 = !((LOC4 == ((NI32) 0)));
		if (!(LOC3)) goto LA5;
		LOC3 = !((errno == ENOENT));
		LA5: ;
		if (!LOC3) goto LA6;
		LOC8 = (NI32)0;
		LOC8 = oslasterror_130619_2125978480();
		LOC9 = (NCSTRING)0;
		LOC9 = strerror(errno);
		LOC10 = (NimStringDesc*)0;
		LOC10 = cstrToNimstr(LOC9);
		raiseoserror_130603_2125978480(LOC8, LOC10);
	}
	LA6: ;
}

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

N_NIMCALL(void, rawremovedir_138714_2125978480)(NimStringDesc* dir0) {
	{
		NIM_BOOL LOC3;
		int LOC4;
		NI32 LOC8;
		LOC3 = (NIM_BOOL)0;
		LOC4 = (int)0;
		LOC4 = rmdir(dir0->data);
		LOC3 = !((LOC4 == ((NI32) 0)));
		if (!(LOC3)) goto LA5;
		LOC3 = !((errno == ENOENT));
		LA5: ;
		if (!LOC3) goto LA6;
		LOC8 = (NI32)0;
		LOC8 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC8, ((NimStringDesc*) &T2125978480_4));
	}
	LA6: ;
}

N_NIMCALL(void, nosremoveDir)(NimStringDesc* dir0) {
	{
		Pathcomponent137212 kind_138804_2125978480;
		NimStringDesc* path_138805_2125978480;
		DIR* d_138821_2125978480;
		kind_138804_2125978480 = (Pathcomponent137212)0;
		path_138805_2125978480 = (NimStringDesc*)0;
		d_138821_2125978480 = opendir(dir0->data);
		{
			TSafePoint T2125978480_14;
			if (!!((d_138821_2125978480 == NIM_NIL))) goto LA4;
			pushSafePoint(&T2125978480_14);
			T2125978480_14.status = _setjmp(T2125978480_14.context);
			if (T2125978480_14.status == 0) {
				{
					while (1) {
						struct dirent* x_138823_2125978480;
						NimStringDesc* volatile y_138825_2125978480;
						x_138823_2125978480 = readdir(d_138821_2125978480);
						{
							if (!(x_138823_2125978480 == NIM_NIL)) goto LA11;
							goto LA7;
						}
						LA11: ;
						y_138825_2125978480 = cstrToNimstr(((NCSTRING) ((*x_138823_2125978480).d_name)));
						{
							NIM_BOOL LOC15;
							struct stat s_138827_2125978480;
							Pathcomponent137212 volatile k_138829_2125978480;
							LOC15 = (NIM_BOOL)0;
							LOC15 = !(eqStrings(y_138825_2125978480, ((NimStringDesc*) &T2125978480_15)));
							if (!(LOC15)) goto LA16;
							LOC15 = !(eqStrings(y_138825_2125978480, ((NimStringDesc*) &T2125978480_16)));
							LA16: ;
							if (!LOC15) goto LA17;
							memset((void*)(&s_138827_2125978480), 0, sizeof(s_138827_2125978480));
							{
								if (!NIM_TRUE) goto LA21;
								y_138825_2125978480 = HEX2F_128265_2125978480(dir0, y_138825_2125978480);
							}
							LA21: ;
							k_138829_2125978480 = ((Pathcomponent137212) 0);
							{
								int LOC25;
								LOC25 = (int)0;
								LOC25 = lstat(y_138825_2125978480->data, (&s_138827_2125978480));
								if (!(LOC25 < ((NI32) 0))) goto LA26;
								goto LA7;
							}
							LA26: ;
							{
								NIM_BOOL LOC30;
								LOC30 = (NIM_BOOL)0;
								LOC30 = S_ISDIR(s_138827_2125978480.st_mode);
								if (!LOC30) goto LA31;
								k_138829_2125978480 = ((Pathcomponent137212) 2);
							}
							goto LA28;
							LA31: ;
							{
								NIM_BOOL LOC34;
								LOC34 = (NIM_BOOL)0;
								LOC34 = S_ISLNK(s_138827_2125978480.st_mode);
								if (!LOC34) goto LA35;
								k_138829_2125978480 = getsymlinkfilekind_137219_2125978480(y_138825_2125978480);
							}
							goto LA28;
							LA35: ;
							LA28: ;
							kind_138804_2125978480 = k_138829_2125978480;
							path_138805_2125978480 = y_138825_2125978480;
							switch (kind_138804_2125978480) {
							case ((Pathcomponent137212) 0):
							case ((Pathcomponent137212) 1):
							case ((Pathcomponent137212) 3):
							{
								nosremoveFile(path_138805_2125978480);
							}
							break;
							case ((Pathcomponent137212) 2):
							{
								nosremoveDir(path_138805_2125978480);
							}
							break;
							}
						}
						LA17: ;
					}
				} LA7: ;
				popSafePoint();
			}
			else {
				popSafePoint();
			}
			{
				int LOC41;
				LOC41 = (int)0;
				LOC41 = closedir(d_138821_2125978480);
			}
			if (T2125978480_14.status != 0) reraiseException();
		}
		LA4: ;
	}
	rawremovedir_138714_2125978480(dir0);
}

N_NIMCALL(void, nosmoveFile)(NimStringDesc* source0, NimStringDesc* dest0) {
	{
		int LOC3;
		NI32 LOC6;
		NCSTRING LOC7;
		NimStringDesc* LOC8;
		LOC3 = (int)0;
		LOC3 = rename(source0->data, dest0->data);
		if (!!((LOC3 == ((NI32) 0)))) goto LA4;
		LOC6 = (NI32)0;
		LOC6 = oslasterror_130619_2125978480();
		LOC7 = (NCSTRING)0;
		LOC7 = strerror(errno);
		LOC8 = (NimStringDesc*)0;
		LOC8 = cstrToNimstr(LOC7);
		raiseoserror_130603_2125978480(LOC6, LOC8);
	}
	LA4: ;
}

N_NIMCALL(void, noscopyFile)(NimStringDesc* source0, NimStringDesc* dest0) {
	FILE* d0;
	FILE* s0;
	void* buf0;
	d0 = (FILE*)0;
	s0 = (FILE*)0;
	{
		NIM_BOOL LOC3;
		NI32 LOC6;
		LOC3 = (NIM_BOOL)0;
		LOC3 = open_14803_1689653243(&s0, source0, ((Filemode13009) 0), ((NI) -1));
		if (!!(LOC3)) goto LA4;
		LOC6 = (NI32)0;
		LOC6 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC6, ((NimStringDesc*) &T2125978480_4));
	}
	LA4: ;
	{
		NIM_BOOL LOC9;
		NI32 LOC12;
		LOC9 = (NIM_BOOL)0;
		LOC9 = open_14803_1689653243(&d0, dest0, ((Filemode13009) 1), ((NI) -1));
		if (!!(LOC9)) goto LA10;
		close_14853_1689653243(s0);
		LOC12 = (NI32)0;
		LOC12 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC12, ((NimStringDesc*) &T2125978480_4));
	}
	LA10: ;
	buf0 = alloc_7801_1689653243(((NI) 8000));
	{
		while (1) {
			NI bytesread0;
			bytesread0 = readbuffer_14956_1689653243(s0, buf0, ((NI) 8000));
			{
				NI byteswritten0;
				if (!(((NI) 0) < bytesread0)) goto LA17;
				byteswritten0 = writebuffer_14978_1689653243(d0, buf0, ((NI) (bytesread0)));
				{
					NI32 LOC23;
					if (!!((bytesread0 == byteswritten0))) goto LA21;
					dealloc_7848_1689653243(buf0);
					close_14853_1689653243(s0);
					close_14853_1689653243(d0);
					LOC23 = (NI32)0;
					LOC23 = oslasterror_130619_2125978480();
					raiseoserror_130603_2125978480(LOC23, ((NimStringDesc*) &T2125978480_4));
				}
				LA21: ;
			}
			LA17: ;
			{
				if (!!((bytesread0 == ((NI) 8000)))) goto LA26;
				goto LA13;
			}
			LA26: ;
		}
	} LA13: ;
	dealloc_7848_1689653243(buf0);
	close_14853_1689653243(s0);
	close_14853_1689653243(d0);
}

N_NIMCALL(time_t, nosgetLastModificationTime)(NimStringDesc* file0) {
	time_t result0;
	struct stat res0;
{	result0 = (time_t)0;
	memset((void*)(&res0), 0, sizeof(res0));
	{
		int LOC3;
		NI32 LOC6;
		LOC3 = (int)0;
		LOC3 = stat(file0->data, (&res0));
		if (!(LOC3 < ((NI32) 0))) goto LA4;
		LOC6 = (NI32)0;
		LOC6 = oslasterror_130619_2125978480();
		raiseoserror_130603_2125978480(LOC6, ((NimStringDesc*) &T2125978480_4));
	}
	LA4: ;
	result0 = res0.st_mtime;
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, nosfileNewer)(NimStringDesc* a0, NimStringDesc* b0) {
	NIM_BOOL result0;
	time_t LOC1;
	time_t LOC2;
	NI64 LOC3;
	result0 = (NIM_BOOL)0;
	LOC1 = (time_t)0;
	LOC1 = nosgetLastModificationTime(a0);
	LOC2 = (time_t)0;
	LOC2 = nosgetLastModificationTime(b0);
	LOC3 = (NI64)0;
	LOC3 = ntDiffTime(LOC1, LOC2);
	result0 = (IL64(0) <= LOC3);
	return result0;
}

N_NIMCALL(void, nossleep)(NI milsecs0) {
	struct timespec a0;
	struct timespec b0;
	int LOC1;
	memset((void*)(&a0), 0, sizeof(a0));
	memset((void*)(&b0), 0, sizeof(b0));
	a0.tv_sec = (NI)(milsecs0 / ((NI) 1000));
	a0.tv_nsec = ((NI) ((NI)(((NI) ((NI)(((NI) ((NI)(milsecs0 % ((NI) 1000)))) * ((NI) 1000)))) * ((NI) 1000))));
	LOC1 = (int)0;
	LOC1 = nanosleep((&a0), (&b0));
}
NIM_EXTERNC N_NOINLINE(void, stdlib_osInit000)(void) {
nimRegisterGlobalMarker(T2125978480_3);
}

NIM_EXTERNC N_NOINLINE(void, stdlib_osDatInit000)(void) {
NTI135002.size = sizeof(TY135002*);
NTI135002.kind = 24;
NTI135002.base = (&NTI138);
NTI135002.flags = 2;
NTI135002.marker = T2125978480_2;
}

