/* Generated by Nim Compiler v1.3.5 */
/*   (c) 2020 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 64

/* section: NIM_merge_HEADERS */

#include "nimbase.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix

/* section: NIM_merge_FRAME_DEFINES */
#define nimfr_(x, y)
#define nimln_(x, y)

/* section: NIM_merge_FORWARD_TYPES */
typedef struct tySequence__sM4lkSb7zS6F7OVMvW9cffQ tySequence__sM4lkSb7zS6F7OVMvW9cffQ;
typedef struct TGenericSeq TGenericSeq;
typedef struct NimStringDesc NimStringDesc;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyTuple__UV3llMMYFckfui8YMBuUZA tyTuple__UV3llMMYFckfui8YMBuUZA;
typedef struct tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA;
typedef struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct tySequence__uB9b75OUPRENsBAu4AnoePA tySequence__uB9b75OUPRENsBAu4AnoePA;
typedef struct tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw;
typedef struct tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg;
typedef struct tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ;
typedef struct tyTuple__7q7q3E6Oj24ZNVJb9aonhAg tyTuple__7q7q3E6Oj24ZNVJb9aonhAg;
typedef struct tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw;
typedef struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;

/* section: NIM_merge_TYPES */
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
NI align;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef N_NIMCALL_PTR(void, tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ) (void);
struct tyTuple__UV3llMMYFckfui8YMBuUZA {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
struct RootObj {
TNimType* m_type;
};
struct Exception {
  RootObj Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
tySequence__uB9b75OUPRENsBAu4AnoePA* trace;
Exception* up;
};
struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA {
  Exception Sup;
};
struct tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA {
  tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA Sup;
NI32 errorCode;
};
struct tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw {
  tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA Sup;
};
struct tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg {
NI i;
NI prev;
NIM_BOOL notFirst;
};
struct tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ {
NI Field0;
NI Field1;
};
struct tyTuple__7q7q3E6Oj24ZNVJb9aonhAg {
NimStringDesc* Field0;
NimStringDesc* Field1;
NimStringDesc* Field2;
};
struct tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw {
  tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA Sup;
};
typedef NU8 tySet_tyChar__nmiMWKVIe46vacnhAFrQvw[32];
struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
NCSTRING procname;
NI line;
NCSTRING filename;
};

/* section: NIM_merge_SEQ_TYPES */
struct tySequence__sM4lkSb7zS6F7OVMvW9cffQ {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
struct tySequence__uB9b75OUPRENsBAu4AnoePA {
  TGenericSeq Sup;
  tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];
};

/* section: NIM_merge_PROC_HEADERS */
N_LIB_PRIVATE N_NIMCALL(void, nimGCvisit)(void* d, NI op);
static N_NIMCALL(void, Marker_tySequence__sM4lkSb7zS6F7OVMvW9cffQ)(void* p, NI op);
static N_NIMCALL(void, TM__yu6cxgKBBXbNsTkT9cyMd4g_2)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimRegisterThreadLocalMarker)(tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ markerProc);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, normalizePathEnd__cQ9bfE8YwK2s9aQkxFkMKhYg)(NimStringDesc* path, NIM_BOOL trailingSep);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_LIB_PRIVATE N_NIMCALL(void, normalizePathEnd__gKUeJXj8CrWvxdeNCA2BXg)(NimStringDesc** path, NIM_BOOL trailingSep);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newLen);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosextractFilename)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(void, nossplitPath)(NimStringDesc* path, tyTuple__UV3llMMYFckfui8YMBuUZA* Result);
static N_INLINE(void, unsureAsgnRef)(void** dest, void* src);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, substr__2yh9cer0ymNRHlOOg8P7IuA)(NimStringDesc* s, NI first, NI last);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, substr__iGg0RIKceRvsmvq8FUHOEw)(NimStringDesc* s, NI first);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_LIB_PRIVATE N_NIMCALL(void, joinPathImpl__zwiv42T0z9bOei4bjr58A9cA)(NimStringDesc** result, NI* state, NimStringDesc* tail);
static N_INLINE(NIM_CHAR, X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem)(NimStringDesc* s, NI i);
N_LIB_PRIVATE N_NIMCALL(void, addNormalizePath__bx9csIXjBBeHkYSkIUixO1g)(NimStringDesc* x, NimStringDesc** result, NI* state, NIM_CHAR dirSep);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, getEnv__hhED57tMl0Iaa5bOg9cJaig)(NimStringDesc* key, NimStringDesc* default_0);
N_LIB_PRIVATE N_NIMCALL(NI, findEnvVar__4kc4cxzsC7aY1IOKtOGazA)(NimStringDesc* key);
N_LIB_PRIVATE N_NIMCALL(void, getEnvVarsC__580467zYn32AEdYj9cD4LLA)(void);
static N_INLINE(NIM_BOOL, eqeq___aqip9cmQIuefPKdd25wuEEwsystem)(NCSTRING x, NCSTRING y);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
N_LIB_PRIVATE N_NIMCALL(TGenericSeq*, incrSeqV3)(TGenericSeq* s, TNimType* typ);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__i80o3k0SgEI5gTRCzYdyWAsystem)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nsuStartsWith)(NimStringDesc* s, NimStringDesc* prefix);
N_LIB_PRIVATE N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start, NI last);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s);
N_LIB_PRIVATE N_NOINLINE(void, raiseOSError__CWyPYlyH9a6rAuZckFyVxPA)(NI32 errorCode, NimStringDesc* additionalInfo);
N_LIB_PRIVATE N_NOINLINE(tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA*, newOSError__JXEuze9ctNbkn51HYBflQLg)(NI32 errorCode, NimStringDesc* additionalInfo);
N_LIB_PRIVATE N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, osErrorMsg__33xViSVWAmDrexoKkLfMhg)(NI32 errorCode);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_LIB_PRIVATE N_NIMCALL(void, addQuoted__45fPtFhY4FavRaYwDhRfuA)(NimStringDesc** s, NimStringDesc* x);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e, NCSTRING ename, NCSTRING procname, NCSTRING filename, NI line);
N_LIB_PRIVATE N_NIMCALL(NI32, osLastError__9bUWNxbcGnToMWA9b79aTXLIw)(void);
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b);
static N_INLINE(NIM_BOOL, equalMem__9bGgqEk7RXXl6eqM9c1HdELAsystem)(void* a, void* b, NI size);
static N_INLINE(int, nimCmpMem)(void* a, void* b, NI size);
static N_INLINE(void, normalizePathAux__Vd3ai1bzXYPREMwN8HbsmQos)(NimStringDesc** path);
N_LIB_PRIVATE N_NIMCALL(void, nosnormalizePath)(NimStringDesc** path);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, normalizePath__gol9aBbIZpJYUPc6xBOBJDQ)(NimStringDesc* path, NIM_CHAR dirSep);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosisAbsolute)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, absolutePathInternal__RmQRR8GLDFICboxWoCEpMw)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, absolutePath__I16hivp0o49aEba9bSd0N6ng)(NimStringDesc* path, NimStringDesc* root);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosgetCurrentDir)(void);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, hasNext__ecfBf9bSnUlnf5OQ0NQMxpQ)(tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg it, NimStringDesc* x);
N_LIB_PRIVATE N_NIMCALL(tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ, next__am1q4dBd9cls9au5CcmkX5oA)(tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg* it, NimStringDesc* x);
N_LIB_PRIVATE N_NIMCALL(NI, parentDirPos__sw9aya5BvknC6WiJX9aEYn9ag)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(NI, searchExtPos__sw9aya5BvknC6WiJX9aEYn9ag_2)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, normExt__5YE1ExrSIVKLWtBPQtnFCw)(NimStringDesc* ext);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosgetHomeDir)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, slash___gEyhbzZ1UcxyenWRLJRXNQ)(NimStringDesc* head, NimStringDesc* tail);
N_LIB_PRIVATE N_NIMCALL(void, nossplitFile)(NimStringDesc* path, tyTuple__7q7q3E6Oj24ZNVJb9aonhAg* Result);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosgetAppFilename)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, getApplAux__wpMsAlcjbgVsRya70vX0Ug)(NimStringDesc* procPath);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, getApplHeuristic__9bfzMt7nzg9apH9cE9c5SozLJw)(void);
static N_INLINE(NIM_BOOL, contains__Pa9a8m0kZYH6LC8N1EcZJdQsystem)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item);
static N_INLINE(NI, find__31wM5Ui9c8jnrQ5QD4oPxOQsystem)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename, NimStringDesc* ext);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosfileExists)(NimStringDesc* filename);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, expandTilde__RmQRR8GLDFICboxWoCEpMw_2)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, checkSymlink__K8A5Y9b9bcyjk7pehBjrT8Kw)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosparentDir)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, WIFSIGNALED__o9b5GK70QLj9ahJeczQ2LyRg)(int s);
N_LIB_PRIVATE N_NIMCALL(int, WTERMSIG__T7ZeAv6ofGPBA29bsuGG1ug)(int s);
N_LIB_PRIVATE N_NIMCALL(int, WEXITSTATUS__T7ZeAv6ofGPBA29bsuGG1ug_2)(int s);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosexistsOrCreateDir)(NimStringDesc* dir);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, rawCreateDir__GHseAa61lv8Sp9b2kQD9baYQ)(NimStringDesc* dir);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosdirExists)(NimStringDesc* dir);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nospquoteShellPosix)(NimStringDesc* s);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, allCharsInSet__dubrHoRt3C9a0HlJjsxM5ig)(NimStringDesc* s, tySet_tyChar__nmiMWKVIe46vacnhAFrQvw theSet);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nsuReplaceStr)(NimStringDesc* s, NimStringDesc* sub, NimStringDesc* by);

/* section: NIM_merge_DATA */
extern TNimType NTI__77mFvmsOLKik79ci2hXkHEg_;
N_LIB_PRIVATE TNimType NTI__sM4lkSb7zS6F7OVMvW9cffQ_;
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_3, "/", 1);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_4, "HOME", 4);
extern TNimType NTI__9clYsYwyjCqe2PFTuCI3Ubg_;
extern TNimType NTI__BeJgrOdDsczOwEWOZbRfKA_;
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_5, "Additional info: ", 17);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_6, "unknown OS error", 16);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_7, ".", 1);
extern TNimType NTI__Ie1m0dv1ZHg72IgPRr1cDw_;
extern TNimType NTI__yoNlBGx0D2tRizIdhQuENw_;
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_8, "The specified root is not absolute: ", 36);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_9, "os.nim(1369, 21) `bufsize >= 0` ", 32);
static NIM_CONST tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ TM__yu6cxgKBBXbNsTkT9cyMd4g_10 = {((NI) 0),
((NI) -1)}
;
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_11, "..", 2);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_12, "/proc/self/exe", 14);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_13, "PATH", 4);
extern TNimType NTI__HMIVdYjdZYWskTmTQVo5BQ_;
extern TNimType NTI__iLZrPn9anoh9ad1MmO0RczFw_;
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_14, "Failed to create \'", 18);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_15, "\'", 1);
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_16, "\'\'", 2);
static NIM_CONST tySet_tyChar__nmiMWKVIe46vacnhAFrQvw TM__yu6cxgKBBXbNsTkT9cyMd4g_17 = {
0x00, 0x00, 0x00, 0x00, 0x20, 0xe8, 0xff, 0x27,
0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
;
STRING_LITERAL(TM__yu6cxgKBBXbNsTkT9cyMd4g_18, "\'\"\'\"\'", 5);

/* section: NIM_merge_VARS */
N_LIB_PRIVATE NIM_BOOL envComputed__LLyFo9bsdu1ZXMDvAe8DhrQ;
N_LIB_PRIVATE tySequence__sM4lkSb7zS6F7OVMvW9cffQ* environment__mlhK49b6YMgc9cgrcYkKq9a3g;
extern NCSTRING* environ;
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;

/* section: NIM_merge_PROCS */
static N_NIMCALL(void, Marker_tySequence__sM4lkSb7zS6F7OVMvW9cffQ)(void* p, NI op) {
	tySequence__sM4lkSb7zS6F7OVMvW9cffQ* a;
	NI T1_;
	a = (tySequence__sM4lkSb7zS6F7OVMvW9cffQ*)p;
	T1_ = (NI)0;
	for (T1_ = 0; T1_ < (a ? a->Sup.len : 0); T1_++) {
	nimGCvisit((void*)a->data[T1_], op);
	}
}
static N_NIMCALL(void, TM__yu6cxgKBBXbNsTkT9cyMd4g_2)(void) {
	nimGCvisit((void*)environment__mlhK49b6YMgc9cgrcYkKq9a3g, 0);
}
N_LIB_PRIVATE N_NIMCALL(void, normalizePathEnd__gKUeJXj8CrWvxdeNCA2BXg)(NimStringDesc** path, NIM_BOOL trailingSep) {
	NI i;
{	{
		if (!(((*path) ? (*path)->Sup.len : 0) == ((NI) 0))) goto LA3_;
		goto BeforeRet_;
	}
	LA3_: ;
	i = ((*path) ? (*path)->Sup.len : 0);
	{
		while (1) {
			if (!(((NI) 1) <= i)) goto LA6;
			{
				if (!(((NU8)((*path)->data[(NI)(i - ((NI) 1))])) == ((NU8)(47)) || ((NU8)((*path)->data[(NI)(i - ((NI) 1))])) == ((NU8)(47)))) goto LA9_;
				i -= ((NI) 1);
			}
			goto LA7_;
			LA9_: ;
			{
				NIM_BOOL T12_;
				NIM_BOOL T13_;
				T12_ = (NIM_BOOL)0;
				T13_ = (NIM_BOOL)0;
				T13_ = ((NU8)((*path)->data[(NI)(i - ((NI) 1))]) == (NU8)(46));
				if (!(T13_)) goto LA14_;
				T13_ = (((NI) 2) <= i);
				LA14_: ;
				T12_ = T13_;
				if (!(T12_)) goto LA15_;
				T12_ = (((NU8)((*path)->data[(NI)(i - ((NI) 2))])) == ((NU8)(47)) || ((NU8)((*path)->data[(NI)(i - ((NI) 2))])) == ((NU8)(47)));
				LA15_: ;
				if (!T12_) goto LA16_;
				i -= ((NI) 1);
			}
			goto LA7_;
			LA16_: ;
			{
				goto LA5;
			}
			LA7_: ;
		} LA6: ;
	} LA5: ;
	{
		if (!trailingSep) goto LA21_;
		(*path) = setLengthStr((*path), ((NI) (i)));
		(*path) = addChar((*path), 47);
	}
	goto LA19_;
	LA21_: ;
	{
		if (!(((NI) 0) < i)) goto LA24_;
		(*path) = setLengthStr((*path), ((NI) (i)));
	}
	goto LA19_;
	LA24_: ;
	{
		(*path) = copyString(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_3));
	}
	LA19_: ;
	}BeforeRet_: ;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, normalizePathEnd__cQ9bfE8YwK2s9aQkxFkMKhYg)(NimStringDesc* path, NIM_BOOL trailingSep) {
	NimStringDesc* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	result = copyString(path);
	normalizePathEnd__gKUeJXj8CrWvxdeNCA2BXg((&result), trailingSep);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, unsureAsgnRef)(void** dest, void* src) {
	(*dest) = src;
}
N_LIB_PRIVATE N_NIMCALL(void, nossplitPath)(NimStringDesc* path, tyTuple__UV3llMMYFckfui8YMBuUZA* Result) {
	NI sepPos;
	unsureAsgnRef((void**)&(*Result).Field0, NIM_NIL);
	unsureAsgnRef((void**)&(*Result).Field1, NIM_NIL);
	sepPos = ((NI) -1);
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (NI)((path ? path->Sup.len : 0) - ((NI) 1));
		res = colontmp_;
		{
			while (1) {
				if (!(((NI) 0) <= res)) goto LA3;
				i = res;
				{
					if (!(((NU8)(path->data[i])) == ((NU8)(47)) || ((NU8)(path->data[i])) == ((NU8)(47)))) goto LA6_;
					sepPos = i;
					goto LA1;
				}
				LA6_: ;
				res -= ((NI) 1);
			} LA3: ;
		}
	} LA1: ;
	{
		NI T12_;
		if (!(((NI) 0) <= sepPos)) goto LA10_;
		T12_ = (NI)0;
		{
			NIM_BOOL T15_;
			T15_ = (NIM_BOOL)0;
			T15_ = NIM_LIKELY((((NI) 1) <= sepPos));
			if (!T15_) goto LA16_;
			T12_ = (NI)(sepPos - ((NI) 1));
		}
		goto LA13_;
		LA16_: ;
		{
			T12_ = ((NI) 0);
		}
		LA13_: ;
		(*Result).Field0 = substr__2yh9cer0ymNRHlOOg8P7IuA(path, ((NI) 0), T12_);
		(*Result).Field1 = substr__iGg0RIKceRvsmvq8FUHOEw(path, (NI)(sepPos + ((NI) 1)));
	}
	goto LA8_;
	LA10_: ;
	{
		(*Result).Field0 = ((NimStringDesc*) NIM_NIL);
		(*Result).Field1 = copyString(path);
	}
	LA8_: ;
}
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosextractFilename)(NimStringDesc* path) {
	NimStringDesc* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = ((path ? path->Sup.len : 0) == ((NI) 0));
		if (T3_) goto LA4_;
		T3_ = (((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)) || ((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = ((NimStringDesc*) NIM_NIL);
	}
	goto LA1_;
	LA5_: ;
	{
		tyTuple__UV3llMMYFckfui8YMBuUZA T8_;
		nimZeroMem((void*)(&T8_), sizeof(tyTuple__UV3llMMYFckfui8YMBuUZA));
		nossplitPath(path, (&T8_));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		result = copyString(T8_.Field1);
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, noslastPathPart)(NimStringDesc* path) {
	NimStringDesc* result;
	NimStringDesc* path_2;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	path_2 = normalizePathEnd__cQ9bfE8YwK2s9aQkxFkMKhYg(path, NIM_FALSE);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = nosextractFilename(path_2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NIM_CHAR, X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem)(NimStringDesc* s, NI i) {
	NIM_CHAR result;
	result = (NIM_CHAR)0;
	result = s->data[(NI)((s ? s->Sup.len : 0) - i)];
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, joinPathImpl__zwiv42T0z9bOei4bjr58A9cA)(NimStringDesc** result, NI* state, NimStringDesc* tail) {
	NIM_BOOL trailingSep;
	NIM_BOOL T1_;
	NIM_BOOL T2_;
	NIM_CHAR T4_;
	NIM_BOOL T6_;
	NIM_BOOL T8_;
	NIM_CHAR T10_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	T1_ = (NIM_BOOL)0;
	T2_ = (NIM_BOOL)0;
	T2_ = (((NI) 0) < (tail ? tail->Sup.len : 0));
	if (!(T2_)) goto LA3_;
	T4_ = (NIM_CHAR)0;
	T4_ = X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem(tail, ((NI) 1));
	T2_ = (((NU8)(T4_)) == ((NU8)(47)) || ((NU8)(T4_)) == ((NU8)(47)));
	LA3_: ;
	T1_ = T2_;
	if (T1_) goto LA5_;
	T6_ = (NIM_BOOL)0;
	T6_ = ((tail ? tail->Sup.len : 0) == ((NI) 0));
	if (!(T6_)) goto LA7_;
	T8_ = (NIM_BOOL)0;
	T8_ = (((NI) 0) < ((*result) ? (*result)->Sup.len : 0));
	if (!(T8_)) goto LA9_;
	T10_ = (NIM_CHAR)0;
	T10_ = X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem((*result), ((NI) 1));
	T8_ = (((NU8)(T10_)) == ((NU8)(47)) || ((NU8)(T10_)) == ((NU8)(47)));
	LA9_: ;
	T6_ = T8_;
	LA7_: ;
	T1_ = T6_;
	LA5_: ;
	trailingSep = T1_;
	normalizePathEnd__gKUeJXj8CrWvxdeNCA2BXg(result, NIM_FALSE);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	addNormalizePath__bx9csIXjBBeHkYSkIUixO1g(tail, result, state, 47);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	normalizePathEnd__gKUeJXj8CrWvxdeNCA2BXg(result, trailingSep);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head, NimStringDesc* tail) {
	NimStringDesc* result;
	NI state;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	result = rawNewString(((NI) ((NI)((head ? head->Sup.len : 0) + (tail ? tail->Sup.len : 0)))));
	state = ((NI) 0);
	joinPathImpl__zwiv42T0z9bOei4bjr58A9cA((&result), (&state), head);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	joinPathImpl__zwiv42T0z9bOei4bjr58A9cA((&result), (&state), tail);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, slash___gEyhbzZ1UcxyenWRLJRXNQ)(NimStringDesc* head, NimStringDesc* tail) {
	NimStringDesc* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	result = nosjoinPath(head, tail);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NIM_BOOL, eqeq___aqip9cmQIuefPKdd25wuEEwsystem)(NCSTRING x, NCSTRING y) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	{
		if (!(((void*) (x)) == ((void*) (y)))) goto LA3_;
		result = NIM_TRUE;
	}
	goto LA1_;
	LA3_: ;
	{
		NIM_BOOL T6_;
		T6_ = (NIM_BOOL)0;
		T6_ = (x == 0);
		if (T6_) goto LA7_;
		T6_ = (y == 0);
		LA7_: ;
		if (!T6_) goto LA8_;
		result = NIM_FALSE;
	}
	goto LA1_;
	LA8_: ;
	{
		int T11_;
		T11_ = (int)0;
		T11_ = strcmp(x, y);
		result = (T11_ == ((NI32) 0));
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, getEnvVarsC__580467zYn32AEdYj9cD4LLA)(void) {
	{
		NI i;
		if (!!(envComputed__LLyFo9bsdu1ZXMDvAe8DhrQ)) goto LA3_;
		environment__mlhK49b6YMgc9cgrcYkKq9a3g = NIM_NIL;
		i = ((NI) 0);
		{
			while (1) {
				NIM_BOOL T7_;
				NimStringDesc* T8_;
				NI T9_;
				T7_ = (NIM_BOOL)0;
				T7_ = eqeq___aqip9cmQIuefPKdd25wuEEwsystem(environ[i], NIM_NIL);
				if (!!(T7_)) goto LA6;
				T8_ = (NimStringDesc*)0;
				T8_ = cstrToNimstr(environ[i]);
				environment__mlhK49b6YMgc9cgrcYkKq9a3g = (tySequence__sM4lkSb7zS6F7OVMvW9cffQ*) incrSeqV3((TGenericSeq*)(environment__mlhK49b6YMgc9cgrcYkKq9a3g), (&NTI__sM4lkSb7zS6F7OVMvW9cffQ_));
				T9_ = environment__mlhK49b6YMgc9cgrcYkKq9a3g->Sup.len++;
				environment__mlhK49b6YMgc9cgrcYkKq9a3g->data[T9_] = copyString(T8_);
				i += ((NI) 1);
			} LA6: ;
		}
		envComputed__LLyFo9bsdu1ZXMDvAe8DhrQ = NIM_TRUE;
	}
	LA3_: ;
}
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest, source, ((size_t) (size)));
}
static N_INLINE(void, copyMem__i80o3k0SgEI5gTRCzYdyWAsystem)(void* dest, void* source, NI size) {
	nimCopyMem(dest, source, size);
}
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	{
		void* T5_;
		void* T6_;
		if (!!((src == NIM_NIL))) goto LA3_;
		T5_ = (void*)0;
		T5_ = ((void*) ((&(*dest).data[(*dest).Sup.len])));
		T6_ = (void*)0;
		T6_ = ((void*) ((*src).data));
		copyMem__i80o3k0SgEI5gTRCzYdyWAsystem(T5_, T6_, ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
		(*dest).Sup.len += (*src).Sup.len;
	}
	LA3_: ;
}
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c) {
	(*dest).data[(*dest).Sup.len] = c;
	(*dest).data[(NI)((*dest).Sup.len + ((NI) 1))] = 0;
	(*dest).Sup.len += ((NI) 1);
}
N_LIB_PRIVATE N_NIMCALL(NI, findEnvVar__4kc4cxzsC7aY1IOKtOGazA)(NimStringDesc* key) {
	NI result;
	NimStringDesc* temp;
	NimStringDesc* T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	getEnvVarsC__580467zYn32AEdYj9cD4LLA();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	T1_ = (NimStringDesc*)0;
	T1_ = rawNewString((key ? key->Sup.len : 0) + 1);
appendString(T1_, key);
appendChar(T1_, 61);
	temp = T1_;
	{
		NI i;
		NI colontmp_;
		NI T3_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		T3_ = ((environment__mlhK49b6YMgc9cgrcYkKq9a3g ? environment__mlhK49b6YMgc9cgrcYkKq9a3g->Sup.len : 0)-1);
		colontmp_ = T3_;
		res = ((NI) 0);
		{
			while (1) {
				if (!(res <= colontmp_)) goto LA5;
				i = res;
				{
					NIM_BOOL T8_;
					T8_ = (NIM_BOOL)0;
					T8_ = nsuStartsWith(environment__mlhK49b6YMgc9cgrcYkKq9a3g->data[i], temp);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					if (!T8_) goto LA9_;
					result = i;
					goto BeforeRet_;
				}
				LA9_: ;
				res += ((NI) 1);
			} LA5: ;
		}
	}
	result = ((NI) -1);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s) {
	NCSTRING result;
	result = (NCSTRING)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (s == NIM_NIL);
		if (T3_) goto LA4_;
		T3_ = ((*s).Sup.len == ((NI) 0));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = "";
	}
	goto LA1_;
	LA5_: ;
	{
		result = ((NCSTRING) ((*s).data));
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, getEnv__hhED57tMl0Iaa5bOg9cJaig)(NimStringDesc* key, NimStringDesc* default_0) {
	NimStringDesc* result;
	NI i;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	i = findEnvVar__4kc4cxzsC7aY1IOKtOGazA(key);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		NimStringDesc* T5_;
		NI T6_;
		if (!(((NI) 0) <= i)) goto LA3_;
		T5_ = (NimStringDesc*)0;
		T5_ = environment__mlhK49b6YMgc9cgrcYkKq9a3g->data[i];
		T6_ = (NI)0;
		T6_ = nsuFindChar(environment__mlhK49b6YMgc9cgrcYkKq9a3g->data[i], 61, ((NI) 0), ((NI) 0));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		result = substr__iGg0RIKceRvsmvq8FUHOEw(T5_, (NI)(T6_ + ((NI) 1)));
		goto BeforeRet_;
	}
	goto LA1_;
	LA3_: ;
	{
		NCSTRING env;
		env = getenv(nimToCStringConv(key));
		{
			NIM_BOOL T10_;
			T10_ = (NIM_BOOL)0;
			T10_ = eqeq___aqip9cmQIuefPKdd25wuEEwsystem(env, NIM_NIL);
			if (!T10_) goto LA11_;
			result = copyString(default_0);
			goto BeforeRet_;
		}
		LA11_: ;
		result = cstrToNimstr(env);
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosgetHomeDir)(void) {
	NimStringDesc* result;
	NimStringDesc* T1_;
	NimStringDesc* T2_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	T1_ = (NimStringDesc*)0;
	T2_ = (NimStringDesc*)0;
	T2_ = getEnv__hhED57tMl0Iaa5bOg9cJaig(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_4), ((NimStringDesc*) NIM_NIL));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	T1_ = rawNewString((T2_ ? T2_->Sup.len : 0) + 1);
appendString(T1_, T2_);
appendString(T1_, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_3));
	result = T1_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, osErrorMsg__33xViSVWAmDrexoKkLfMhg)(NI32 errorCode) {
	NimStringDesc* result;
	result = (NimStringDesc*)0;
	result = ((NimStringDesc*) NIM_NIL);
	{
		NCSTRING T5_;
		if (!!((errorCode == ((NI32) 0)))) goto LA3_;
		T5_ = (NCSTRING)0;
		T5_ = strerror(errorCode);
		result = cstrToNimstr(T5_);
	}
	LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NOINLINE(tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA*, newOSError__JXEuze9ctNbkn51HYBflQLg)(NI32 errorCode, NimStringDesc* additionalInfo) {
	tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA* result;
	tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA* e;
	NimStringDesc* T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA*)0;
	e = (tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA*)0;
	e = (tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA*) newObj((&NTI__9clYsYwyjCqe2PFTuCI3Ubg_), sizeof(tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA));
	(*e).Sup.Sup.Sup.m_type = (&NTI__BeJgrOdDsczOwEWOZbRfKA_);
	(*e).Sup.Sup.name = "OSError";
	(*e).errorCode = errorCode;
	T1_ = (NimStringDesc*)0;
	T1_ = osErrorMsg__33xViSVWAmDrexoKkLfMhg(errorCode);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	(*e).Sup.Sup.message = T1_;
	{
		if (!(((NI) 0) < (additionalInfo ? additionalInfo->Sup.len : 0))) goto LA4_;
		{
			NIM_BOOL T8_;
			NIM_CHAR T10_;
			T8_ = (NIM_BOOL)0;
			T8_ = (((NI) 0) < ((*e).Sup.Sup.message ? (*e).Sup.Sup.message->Sup.len : 0));
			if (!(T8_)) goto LA9_;
			T10_ = (NIM_CHAR)0;
			T10_ = X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem((*e).Sup.Sup.message, ((NI) 1));
			T8_ = !(((NU8)(T10_) == (NU8)(10)));
			LA9_: ;
			if (!T8_) goto LA11_;
			(*e).Sup.Sup.message = addChar((*e).Sup.Sup.message, 10);
		}
		LA11_: ;
		(*e).Sup.Sup.message = resizeString((*e).Sup.Sup.message, 17);
appendString((*e).Sup.Sup.message, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_5));
		addQuoted__45fPtFhY4FavRaYwDhRfuA((&(*e).Sup.Sup.message), additionalInfo);
	}
	LA4_: ;
	{
		if (!(((*e).Sup.Sup.message ? (*e).Sup.Sup.message->Sup.len : 0) == 0)) goto LA15_;
		(*e).Sup.Sup.message = copyString(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_6));
	}
	LA15_: ;
	result = e;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NOINLINE(void, raiseOSError__CWyPYlyH9a6rAuZckFyVxPA)(NI32 errorCode, NimStringDesc* additionalInfo) {
	tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA* T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	T1_ = (tyObject_OSError__BeJgrOdDsczOwEWOZbRfKA*)0;
	T1_ = newOSError__JXEuze9ctNbkn51HYBflQLg(errorCode, additionalInfo);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	raiseExceptionEx((Exception*)T1_, "OSError", "raiseOSError", "oserr.nim", 94);
	goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NI32, osLastError__9bUWNxbcGnToMWA9b79aTXLIw)(void) {
	NI32 result;
	result = (NI32)0;
	result = errno;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosexpandFilename)(NimStringDesc* filename) {
	NimStringDesc* result;
	NCSTRING r;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	r = realpath(nimToCStringConv(filename), NIM_NIL);
	{
		NI32 T5_;
		if (!(r == 0)) goto LA3_;
		T5_ = (NI32)0;
		T5_ = osLastError__9bUWNxbcGnToMWA9b79aTXLIw();
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		raiseOSError__CWyPYlyH9a6rAuZckFyVxPA(T5_, filename);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
	LA3_: ;
	{
		result = cstrToNimstr(r);
		free(((void*) (r)));
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(int, nimCmpMem)(void* a, void* b, NI size) {
	int result;
	result = (int)0;
	result = memcmp(a, b, ((size_t) (size)));
	return result;
}
static N_INLINE(NIM_BOOL, equalMem__9bGgqEk7RXXl6eqM9c1HdELAsystem)(void* a, void* b, NI size) {
	NIM_BOOL result;
	int T1_;
	result = (NIM_BOOL)0;
	T1_ = (int)0;
	T1_ = nimCmpMem(a, b, size);
	result = (T1_ == ((NI32) 0));
	return result;
}
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b) {
	NIM_BOOL result;
	NI alen;
	NI blen;
{	result = (NIM_BOOL)0;
	alen = (a ? a->Sup.len : 0);
	blen = (b ? b->Sup.len : 0);
	{
		if (!(alen == blen)) goto LA3_;
		{
			if (!(alen == ((NI) 0))) goto LA7_;
			result = NIM_TRUE;
			goto BeforeRet_;
		}
		LA7_: ;
		result = equalMem__9bGgqEk7RXXl6eqM9c1HdELAsystem(((void*) ((&a->data[((NI) 0)]))), ((void*) ((&b->data[((NI) 0)]))), ((NI) (alen)));
		goto BeforeRet_;
	}
	LA3_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, nosnormalizePath)(NimStringDesc** path) {
	NimStringDesc* T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	T1_ = (NimStringDesc*)0;
	T1_ = normalizePath__gol9aBbIZpJYUPc6xBOBJDQ((*path), 47);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	(*path) = T1_;
	}BeforeRet_: ;
}
static N_INLINE(void, normalizePathAux__Vd3ai1bzXYPREMwN8HbsmQos)(NimStringDesc** path) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nosnormalizePath(path);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosisAbsolute)(NimStringDesc* path) {
	NIM_BOOL result;
{	result = (NIM_BOOL)0;
	{
		if (!((path ? path->Sup.len : 0) == ((NI) 0))) goto LA3_;
		result = NIM_FALSE;
		goto BeforeRet_;
	}
	LA3_: ;
	result = ((NU8)(path->data[((NI) 0)]) == (NU8)(47));
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, absolutePath__I16hivp0o49aEba9bSd0N6ng)(NimStringDesc* path, NimStringDesc* root) {
	NimStringDesc* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nosisAbsolute(path);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T3_) goto LA4_;
		result = copyString(path);
	}
	goto LA1_;
	LA4_: ;
	{
		{
			NIM_BOOL T9_;
			tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw* T12_;
			NimStringDesc* T13_;
			T9_ = (NIM_BOOL)0;
			T9_ = nosisAbsolute(root);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			if (!!(T9_)) goto LA10_;
			T12_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*)0;
			T12_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*) newObj((&NTI__Ie1m0dv1ZHg72IgPRr1cDw_), sizeof(tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw));
			(*T12_).Sup.Sup.Sup.m_type = (&NTI__yoNlBGx0D2tRizIdhQuENw_);
			(*T12_).Sup.Sup.name = "ValueError";
			T13_ = (NimStringDesc*)0;
			T13_ = rawNewString((root ? root->Sup.len : 0) + 36);
appendString(T13_, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_8));
appendString(T13_, root);
			(*T12_).Sup.Sup.message = T13_;
			(*T12_).Sup.Sup.parent = NIM_NIL;
			raiseExceptionEx((Exception*)T12_, "ValueError", "absolutePath", "os.nim", 1407);
			goto BeforeRet_;
		}
		LA10_: ;
		result = nosjoinPath(root, path);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosgetCurrentDir)(void) {
	NimStringDesc* result;
	NI bufsize;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	bufsize = ((NI) 1024);
	result = mnewString(((NI) (bufsize)));
	{
		while (1) {
			{
				NCSTRING T5_;
				NIM_BOOL T6_;
				int T9_;
				T5_ = (NCSTRING)0;
				T5_ = getcwd(nimToCStringConv(result), bufsize);
				T6_ = (NIM_BOOL)0;
				T6_ = eqeq___aqip9cmQIuefPKdd25wuEEwsystem(T5_, NIM_NIL);
				if (!!(T6_)) goto LA7_;
				T9_ = (int)0;
				T9_ = strlen(nimToCStringConv(result));
				result = setLengthStr(result, ((NI) (T9_)));
				goto LA1;
			}
			goto LA3_;
			LA7_: ;
			{
				NI32 err;
				err = osLastError__9bUWNxbcGnToMWA9b79aTXLIw();
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				{
					if (!(err == ((int) 34))) goto LA13_;
					bufsize = (NI)((NU64)(bufsize) << (NU64)(((NI) 1)));
					{
						if (!!((((NI) 0) <= bufsize))) goto LA17_;
						failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_9));
						if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					}
					LA17_: ;
					result = mnewString(((NI) (bufsize)));
				}
				goto LA11_;
				LA13_: ;
				{
					NI32 T20_;
					T20_ = (NI32)0;
					T20_ = osLastError__9bUWNxbcGnToMWA9b79aTXLIw();
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					raiseOSError__CWyPYlyH9a6rAuZckFyVxPA(T20_, ((NimStringDesc*) NIM_NIL));
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				}
				LA11_: ;
			}
			LA3_: ;
		}
	} LA1: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, absolutePathInternal__RmQRR8GLDFICboxWoCEpMw)(NimStringDesc* path) {
	NimStringDesc* result;
	NimStringDesc* T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	T1_ = (NimStringDesc*)0;
	T1_ = nosgetCurrentDir();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = absolutePath__I16hivp0o49aEba9bSd0N6ng(path, T1_);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosrelativePath)(NimStringDesc* path, NimStringDesc* base, NIM_CHAR sep) {
	NimStringDesc* result;
	NimStringDesc* base_2;
	NimStringDesc* path_2;
	NIM_BOOL a1;
	NIM_BOOL a2;
	tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg f;
	tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg b;
	tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ ff;
	tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ bb;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	{
		if (!((path ? path->Sup.len : 0) == ((NI) 0))) goto LA3_;
		result = ((NimStringDesc*) NIM_NIL);
		goto BeforeRet_;
	}
	LA3_: ;
	{
		if (!eqStrings(base, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_7))) goto LA7_;
		base_2 = ((NimStringDesc*) NIM_NIL);
	}
	goto LA5_;
	LA7_: ;
	{
		base_2 = copyString(base);
	}
	LA5_: ;
	path_2 = copyString(path);
	normalizePathAux__Vd3ai1bzXYPREMwN8HbsmQos((&path_2));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	normalizePathAux__Vd3ai1bzXYPREMwN8HbsmQos((&base_2));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	a1 = nosisAbsolute(path_2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	a2 = nosisAbsolute(base_2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		NIM_BOOL T12_;
		T12_ = (NIM_BOOL)0;
		T12_ = a1;
		if (!(T12_)) goto LA13_;
		T12_ = !(a2);
		LA13_: ;
		if (!T12_) goto LA14_;
		base_2 = absolutePathInternal__RmQRR8GLDFICboxWoCEpMw(base_2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA10_;
	LA14_: ;
	{
		NIM_BOOL T17_;
		T17_ = (NIM_BOOL)0;
		T17_ = a2;
		if (!(T17_)) goto LA18_;
		T17_ = !(a1);
		LA18_: ;
		if (!T17_) goto LA19_;
		path_2 = absolutePathInternal__RmQRR8GLDFICboxWoCEpMw(path_2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA10_;
	LA19_: ;
	LA10_: ;
	nimZeroMem((void*)(&f), sizeof(tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg));
	nimZeroMem((void*)(&b), sizeof(tyObject_PathIter__tllF14xUpDWpqG9ci5sg9bMg));
	ff = TM__yu6cxgKBBXbNsTkT9cyMd4g_10;
	bb = TM__yu6cxgKBBXbNsTkT9cyMd4g_10;
	result = rawNewString(((NI) ((path_2 ? path_2->Sup.len : 0))));
	{
		while (1) {
			NIM_BOOL T23_;
			NI diff;
			NIM_BOOL same;
			NI colontmp_;
			NI colontmp__2;
			NI colontmp__3;
			NI colontmp__4;
			T23_ = (NIM_BOOL)0;
			T23_ = hasNext__ecfBf9bSnUlnf5OQ0NQMxpQ(f, path_2);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			if (!(T23_)) goto LA24_;
			T23_ = hasNext__ecfBf9bSnUlnf5OQ0NQMxpQ(b, base_2);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			LA24_: ;
			if (!T23_) goto LA22;
			ff = next__am1q4dBd9cls9au5CcmkX5oA((&f), path_2);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			bb = next__am1q4dBd9cls9au5CcmkX5oA((&b), base_2);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			diff = (NI)(ff.Field1 - ff.Field0);
			{
				if (!!((diff == (NI)(bb.Field1 - bb.Field0)))) goto LA27_;
				goto LA21;
			}
			LA27_: ;
			same = NIM_TRUE;
			{
				NI i;
				NI res;
				i = (NI)0;
				res = ((NI) 0);
				{
					while (1) {
						if (!(res <= diff)) goto LA31;
						i = res;
						{
							if (!!(((NU8)(path_2->data[(NI)(i + ff.Field0)]) == (NU8)(base_2->data[(NI)(i + bb.Field0)])))) goto LA34_;
							same = NIM_FALSE;
							goto LA29;
						}
						LA34_: ;
						res += ((NI) 1);
					} LA31: ;
				}
			} LA29: ;
			{
				if (!!(same)) goto LA38_;
				goto LA21;
			}
			LA38_: ;
			colontmp_ = ((NI) 0);
			colontmp__2 = ((NI) -1);
			ff.Field0 = colontmp_;
			ff.Field1 = colontmp__2;
			colontmp__3 = ((NI) 0);
			colontmp__4 = ((NI) -1);
			bb.Field0 = colontmp__3;
			bb.Field1 = colontmp__4;
		} LA22: ;
	} LA21: ;
	{
		while (1) {
			{
				if (!(bb.Field0 <= bb.Field1)) goto LA44_;
				{
					NIM_BOOL T48_;
					NIM_CHAR T50_;
					T48_ = (NIM_BOOL)0;
					T48_ = (((NI) 0) < (result ? result->Sup.len : 0));
					if (!(T48_)) goto LA49_;
					T50_ = (NIM_CHAR)0;
					T50_ = X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem(result, ((NI) 1));
					T48_ = !(((NU8)(T50_) == (NU8)(sep)));
					LA49_: ;
					if (!T48_) goto LA51_;
					result = addChar(result, sep);
				}
				LA51_: ;
				result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_11));
			}
			LA44_: ;
			{
				NIM_BOOL T55_;
				T55_ = (NIM_BOOL)0;
				T55_ = hasNext__ecfBf9bSnUlnf5OQ0NQMxpQ(b, base_2);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				if (!!(T55_)) goto LA56_;
				goto LA40;
			}
			LA56_: ;
			bb = next__am1q4dBd9cls9au5CcmkX5oA((&b), base_2);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		}
	} LA40: ;
	{
		while (1) {
			{
				if (!(ff.Field0 <= ff.Field1)) goto LA62_;
				{
					NIM_BOOL T66_;
					NIM_CHAR T68_;
					T66_ = (NIM_BOOL)0;
					T66_ = (((NI) 0) < (result ? result->Sup.len : 0));
					if (!(T66_)) goto LA67_;
					T68_ = (NIM_CHAR)0;
					T68_ = X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem(result, ((NI) 1));
					T66_ = !(((NU8)(T68_) == (NU8)(sep)));
					LA67_: ;
					if (!T66_) goto LA69_;
					result = addChar(result, sep);
				}
				LA69_: ;
				{
					NI i_2;
					NI colontmp__5;
					NI res_2;
					i_2 = (NI)0;
					colontmp__5 = (NI)0;
					colontmp__5 = (NI)(ff.Field1 - ff.Field0);
					res_2 = ((NI) 0);
					{
						while (1) {
							if (!(res_2 <= colontmp__5)) goto LA73;
							i_2 = res_2;
							result = addChar(result, path_2->data[(NI)(i_2 + ff.Field0)]);
							res_2 += ((NI) 1);
						} LA73: ;
					}
				}
			}
			LA62_: ;
			{
				NIM_BOOL T76_;
				T76_ = (NIM_BOOL)0;
				T76_ = hasNext__ecfBf9bSnUlnf5OQ0NQMxpQ(f, path_2);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				if (!!(T76_)) goto LA77_;
				goto LA58;
			}
			LA77_: ;
			ff = next__am1q4dBd9cls9au5CcmkX5oA((&f), path_2);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		}
	} LA58: ;
	{
		if (!((result ? result->Sup.len : 0) == ((NI) 0))) goto LA81_;
		result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_7));
	}
	LA81_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, nossplitFile)(NimStringDesc* path, tyTuple__7q7q3E6Oj24ZNVJb9aonhAg* Result) {
	NI namePos;
	NI dotPos;
	unsureAsgnRef((void**)&(*Result).Field0, NIM_NIL);
	unsureAsgnRef((void**)&(*Result).Field1, NIM_NIL);
	unsureAsgnRef((void**)&(*Result).Field2, NIM_NIL);
	namePos = ((NI) 0);
	dotPos = ((NI) 0);
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (NI)((path ? path->Sup.len : 0) - ((NI) 1));
		res = colontmp_;
		{
			while (1) {
				if (!(((NI) 0) <= res)) goto LA3;
				i = res;
				{
					NIM_BOOL T6_;
					T6_ = (NIM_BOOL)0;
					T6_ = (((NU8)(path->data[i])) == ((NU8)(47)) || ((NU8)(path->data[i])) == ((NU8)(47)));
					if (T6_) goto LA7_;
					T6_ = (i == ((NI) 0));
					LA7_: ;
					if (!T6_) goto LA8_;
					{
						NI T14_;
						if (!(((NU8)(path->data[i])) == ((NU8)(47)) || ((NU8)(path->data[i])) == ((NU8)(47)))) goto LA12_;
						T14_ = (NI)0;
						{
							NIM_BOOL T17_;
							T17_ = (NIM_BOOL)0;
							T17_ = NIM_LIKELY((((NI) 1) <= i));
							if (!T17_) goto LA18_;
							T14_ = (NI)(i - ((NI) 1));
						}
						goto LA15_;
						LA18_: ;
						{
							T14_ = ((NI) 0);
						}
						LA15_: ;
						(*Result).Field0 = substr__2yh9cer0ymNRHlOOg8P7IuA(path, ((NI) 0), T14_);
						namePos = (NI)(i + ((NI) 1));
					}
					LA12_: ;
					{
						if (!(i < dotPos)) goto LA23_;
						(*Result).Field1 = substr__2yh9cer0ymNRHlOOg8P7IuA(path, namePos, (NI)(dotPos - ((NI) 1)));
						(*Result).Field2 = substr__iGg0RIKceRvsmvq8FUHOEw(path, dotPos);
					}
					goto LA21_;
					LA23_: ;
					{
						(*Result).Field1 = substr__iGg0RIKceRvsmvq8FUHOEw(path, namePos);
					}
					LA21_: ;
					goto LA1;
				}
				goto LA4_;
				LA8_: ;
				{
					NIM_BOOL T27_;
					NIM_BOOL T28_;
					NIM_BOOL T29_;
					NIM_BOOL T30_;
					NIM_BOOL T31_;
					T27_ = (NIM_BOOL)0;
					T28_ = (NIM_BOOL)0;
					T29_ = (NIM_BOOL)0;
					T30_ = (NIM_BOOL)0;
					T31_ = (NIM_BOOL)0;
					T31_ = ((NU8)(path->data[i]) == (NU8)(46));
					if (!(T31_)) goto LA32_;
					T31_ = (((NI) 0) < i);
					LA32_: ;
					T30_ = T31_;
					if (!(T30_)) goto LA33_;
					T30_ = (i < (NI)((path ? path->Sup.len : 0) - ((NI) 1)));
					LA33_: ;
					T29_ = T30_;
					if (!(T29_)) goto LA34_;
					T29_ = !((((NU8)(path->data[(NI)(i - ((NI) 1))])) == ((NU8)(47)) || ((NU8)(path->data[(NI)(i - ((NI) 1))])) == ((NU8)(47))));
					LA34_: ;
					T28_ = T29_;
					if (!(T28_)) goto LA35_;
					T28_ = !(((NU8)(path->data[(NI)(i + ((NI) 1))]) == (NU8)(46)));
					LA35_: ;
					T27_ = T28_;
					if (!(T27_)) goto LA36_;
					T27_ = (dotPos == ((NI) 0));
					LA36_: ;
					if (!T27_) goto LA37_;
					dotPos = i;
				}
				goto LA4_;
				LA37_: ;
				LA4_: ;
				res -= ((NI) 1);
			} LA3: ;
		}
	} LA1: ;
}
N_LIB_PRIVATE N_NIMCALL(NI, parentDirPos__sw9aya5BvknC6WiJX9aEYn9ag)(NimStringDesc* path) {
	NI result;
	NI q;
{	result = (NI)0;
	q = ((NI) 1);
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI) 1) <= (path ? path->Sup.len : 0));
		if (!(T3_)) goto LA4_;
		T3_ = (((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)) || ((NU8)(path->data[(NI)((path ? path->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)));
		LA4_: ;
		if (!T3_) goto LA5_;
		q = ((NI) 2);
	}
	LA5_: ;
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (NI)((path ? path->Sup.len : 0) - q);
		res = colontmp_;
		{
			while (1) {
				if (!(((NI) 0) <= res)) goto LA9;
				i = res;
				{
					if (!(((NU8)(path->data[i])) == ((NU8)(47)) || ((NU8)(path->data[i])) == ((NU8)(47)))) goto LA12_;
					result = i;
					goto BeforeRet_;
				}
				LA12_: ;
				res -= ((NI) 1);
			} LA9: ;
		}
	}
	result = ((NI) -1);
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosparentDir)(NimStringDesc* path) {
	NimStringDesc* result;
	NI sepPos;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	result = normalizePath__gol9aBbIZpJYUPc6xBOBJDQ(path, 47);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	sepPos = parentDirPos__sw9aya5BvknC6WiJX9aEYn9ag(result);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		if (!(((NI) 0) <= sepPos)) goto LA3_;
		result = substr__2yh9cer0ymNRHlOOg8P7IuA(result, ((NI) 0), sepPos);
		normalizePathEnd__gKUeJXj8CrWvxdeNCA2BXg((&result), NIM_FALSE);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
	LA3_: ;
	{
		NIM_BOOL T6_;
		NIM_BOOL T7_;
		NIM_BOOL T8_;
		NIM_CHAR T12_;
		T6_ = (NIM_BOOL)0;
		T7_ = (NIM_BOOL)0;
		T8_ = (NIM_BOOL)0;
		T8_ = eqStrings(result, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_11));
		if (T8_) goto LA9_;
		T8_ = eqStrings(result, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_7));
		LA9_: ;
		T7_ = T8_;
		if (T7_) goto LA10_;
		T7_ = ((result ? result->Sup.len : 0) == ((NI) 0));
		LA10_: ;
		T6_ = T7_;
		if (T6_) goto LA11_;
		T12_ = (NIM_CHAR)0;
		T12_ = X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem(result, ((NI) 1));
		T6_ = (((NU8)(T12_)) == ((NU8)(47)) || ((NU8)(T12_)) == ((NU8)(47)));
		LA11_: ;
		if (!T6_) goto LA13_;
		result = ((NimStringDesc*) NIM_NIL);
	}
	goto LA1_;
	LA13_: ;
	{
		result = copyString(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_7));
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosfileExists)(NimStringDesc* filename) {
	NIM_BOOL result;
	struct stat res;
	NIM_BOOL T1_;
	int T2_;
{	result = (NIM_BOOL)0;
	nimZeroMem((void*)(&res), sizeof(struct stat));
	T1_ = (NIM_BOOL)0;
	T2_ = (int)0;
	T2_ = stat(nimToCStringConv(filename), (&res));
	T1_ = (((NI32) 0) <= T2_);
	if (!(T1_)) goto LA3_;
	T1_ = S_ISREG(res.st_mode);
	LA3_: ;
	result = T1_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, searchExtPos__sw9aya5BvknC6WiJX9aEYn9ag_2)(NimStringDesc* path) {
	NI result;
	result = (NI)0;
	result = ((NI) -1);
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (NI)((path ? path->Sup.len : 0) - ((NI) 1));
		res = colontmp_;
		{
			while (1) {
				if (!(((NI) 1) <= res)) goto LA3;
				i = res;
				{
					if (!((NU8)(path->data[i]) == (NU8)(46))) goto LA6_;
					result = i;
					goto LA1;
				}
				goto LA4_;
				LA6_: ;
				{
					if (!(((NU8)(path->data[i])) == ((NU8)(47)) || ((NU8)(path->data[i])) == ((NU8)(47)))) goto LA9_;
					goto LA1;
				}
				goto LA4_;
				LA9_: ;
				LA4_: ;
				res -= ((NI) 1);
			} LA3: ;
		}
	} LA1: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, normExt__5YE1ExrSIVKLWtBPQtnFCw)(NimStringDesc* ext) {
	NimStringDesc* result;
	result = (NimStringDesc*)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = ((ext ? ext->Sup.len : 0) == 0);
		if (T3_) goto LA4_;
		T3_ = ((NU8)(ext->data[((NI) 0)]) == (NU8)(46));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = copyString(ext);
	}
	goto LA1_;
	LA5_: ;
	{
		NimStringDesc* T8_;
		T8_ = (NimStringDesc*)0;
		T8_ = rawNewString((ext ? ext->Sup.len : 0) + 1);
appendChar(T8_, 46);
appendString(T8_, ext);
		result = T8_;
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename, NimStringDesc* ext) {
	NimStringDesc* result;
	NI extPos;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	extPos = searchExtPos__sw9aya5BvknC6WiJX9aEYn9ag_2(filename);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		NimStringDesc* T5_;
		NimStringDesc* T6_;
		if (!(extPos < ((NI) 0))) goto LA3_;
		T5_ = (NimStringDesc*)0;
		T6_ = (NimStringDesc*)0;
		T6_ = normExt__5YE1ExrSIVKLWtBPQtnFCw(ext);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T5_ = rawNewString((filename ? filename->Sup.len : 0) + (T6_ ? T6_->Sup.len : 0) + 0);
appendString(T5_, filename);
appendString(T5_, T6_);
		result = T5_;
	}
	goto LA1_;
	LA3_: ;
	{
		result = copyString(filename);
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, expandTilde__RmQRR8GLDFICboxWoCEpMw_2)(NimStringDesc* path) {
	NimStringDesc* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = ((path ? path->Sup.len : 0) == ((NI) 0));
		if (T3_) goto LA4_;
		T3_ = !(((NU8)(path->data[((NI) 0)]) == (NU8)(126)));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = copyString(path);
	}
	goto LA1_;
	LA5_: ;
	{
		if (!((path ? path->Sup.len : 0) == ((NI) 1))) goto LA8_;
		result = nosgetHomeDir();
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
	LA8_: ;
	{
		NimStringDesc* T13_;
		NimStringDesc* T14_;
		if (!(((NU8)(path->data[((NI) 1)])) == ((NU8)(47)) || ((NU8)(path->data[((NI) 1)])) == ((NU8)(47)))) goto LA11_;
		T13_ = (NimStringDesc*)0;
		T13_ = nosgetHomeDir();
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T14_ = (NimStringDesc*)0;
		T14_ = substr__iGg0RIKceRvsmvq8FUHOEw(path, ((NI) 2));
		result = slash___gEyhbzZ1UcxyenWRLJRXNQ(T13_, T14_);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
	LA11_: ;
	{
		result = copyString(path);
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosunixToNativePath)(NimStringDesc* path, NimStringDesc* drive) {
	NimStringDesc* result;
	result = (NimStringDesc*)0;
	result = copyString(path);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, getApplAux__wpMsAlcjbgVsRya70vX0Ug)(NimStringDesc* procPath) {
	NimStringDesc* result;
	NI len;
	result = (NimStringDesc*)0;
	result = mnewString(((NI) 256));
	len = readlink(nimToCStringConv(procPath), nimToCStringConv(result), ((NI) 256));
	{
		if (!(((NI) 256) < len)) goto LA3_;
		result = mnewString(((NI) ((NI)(len + ((NI) 1)))));
		len = readlink(nimToCStringConv(procPath), nimToCStringConv(result), len);
	}
	LA3_: ;
	result = setLengthStr(result, ((NI) (len)));
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, getApplHeuristic__9bfzMt7nzg9apH9cE9c5SozLJw)(void) {
	NimStringDesc* result;
	result = (NimStringDesc*)0;
	result = ((NimStringDesc*) NIM_NIL);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosgetAppFilename)(void) {
	NimStringDesc* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	result = getApplAux__wpMsAlcjbgVsRya70vX0Ug(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_12));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		if (!((result ? result->Sup.len : 0) == ((NI) 0))) goto LA3_;
		result = getApplHeuristic__9bfzMt7nzg9apH9cE9c5SozLJw();
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	LA3_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nosgetAppDir)(void) {
	NimStringDesc* result;
	NimStringDesc* T1_;
	tyTuple__7q7q3E6Oj24ZNVJb9aonhAg T2_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	T1_ = (NimStringDesc*)0;
	T1_ = nosgetAppFilename();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	nimZeroMem((void*)(&T2_), sizeof(tyTuple__7q7q3E6Oj24ZNVJb9aonhAg));
	nossplitFile(T1_, (&T2_));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = copyString(T2_.Field0);
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NI, find__31wM5Ui9c8jnrQ5QD4oPxOQsystem)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item) {
	NI result;
{	result = (NI)0;
	result = ((NI) 0);
	{
		NIM_CHAR i;
		NI i_2;
		i = (NIM_CHAR)0;
		i_2 = ((NI) 0);
		{
			while (1) {
				if (!(i_2 < aLen_0)) goto LA3;
				i = a[i_2];
				{
					if (!((NU8)(i) == (NU8)(item))) goto LA6_;
					goto BeforeRet_;
				}
				LA6_: ;
				result += ((NI) 1);
				i_2 += ((NI) 1);
			} LA3: ;
		}
	}
	result = ((NI) -1);
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NIM_BOOL, contains__Pa9a8m0kZYH6LC8N1EcZJdQsystem)(NIM_CHAR* a, NI aLen_0, NIM_CHAR item) {
	NIM_BOOL result;
	NI T1_;
{	result = (NIM_BOOL)0;
	T1_ = (NI)0;
	T1_ = find__31wM5Ui9c8jnrQ5QD4oPxOQsystem(a, aLen_0, item);
	result = (((NI) 0) <= T1_);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, checkSymlink__K8A5Y9b9bcyjk7pehBjrT8Kw)(NimStringDesc* path) {
	NIM_BOOL result;
	struct stat rawInfo;
	result = (NIM_BOOL)0;
	nimZeroMem((void*)(&rawInfo), sizeof(struct stat));
	{
		int T3_;
		T3_ = (int)0;
		T3_ = lstat(nimToCStringConv(path), (&rawInfo));
		if (!(T3_ < ((NI32) 0))) goto LA4_;
		result = NIM_FALSE;
	}
	goto LA1_;
	LA4_: ;
	{
		result = S_ISLNK(rawInfo.st_mode);
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, findExe__9cov9c3aI19bfbEIyMe9bNCSEA)(NimStringDesc* exe, NIM_BOOL followSymlinks, NimStringDesc** extensions, NI extensionsLen_0) {
	NimStringDesc* result;
	NimStringDesc* path;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	{
		if (!((exe ? exe->Sup.len : 0) == ((NI) 0))) goto LA3_;
		goto BeforeRet_;
	}
	LA3_: ;
	{
		NIM_BOOL T7_;
		T7_ = (NIM_BOOL)0;
		T7_ = contains__Pa9a8m0kZYH6LC8N1EcZJdQsystem(exe->data, (exe ? exe->Sup.len : 0), 47);
		if (!T7_) goto LA8_;
		{
			NimStringDesc** extX60gensym79_;
			NI i;
			extX60gensym79_ = (NimStringDesc**)0;
			i = ((NI) 0);
			{
				while (1) {
					if (!(i < extensionsLen_0)) goto LA12;
					extX60gensym79_ = (&extensions[i]);
					result = nosaddFileExt(exe, (*extX60gensym79_));
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					{
						NIM_BOOL T15_;
						T15_ = (NIM_BOOL)0;
						T15_ = nosfileExists(result);
						if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
						if (!T15_) goto LA16_;
						goto BeforeRet_;
					}
					LA16_: ;
					i += ((NI) 1);
				} LA12: ;
			}
		}
	}
	LA8_: ;
	path = getEnv__hhED57tMl0Iaa5bOg9cJaig(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_13), ((NimStringDesc*) NIM_NIL));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		NimStringDesc* candidate;
		NI lastX60gensym26_;
		NI splitsX60gensym26_;
		candidate = (NimStringDesc*)0;
		lastX60gensym26_ = ((NI) 0);
		splitsX60gensym26_ = ((NI) -1);
		{
			while (1) {
				NI firstX60gensym26_;
				if (!(lastX60gensym26_ <= (path ? path->Sup.len : 0))) goto LA20;
				firstX60gensym26_ = lastX60gensym26_;
				{
					while (1) {
						NIM_BOOL T23_;
						T23_ = (NIM_BOOL)0;
						T23_ = (lastX60gensym26_ < (path ? path->Sup.len : 0));
						if (!(T23_)) goto LA24_;
						T23_ = !(((NU8)(path->data[lastX60gensym26_]) == (NU8)(58)));
						LA24_: ;
						if (!T23_) goto LA22;
						lastX60gensym26_ += ((NI) 1);
					} LA22: ;
				}
				{
					if (!(splitsX60gensym26_ == ((NI) 0))) goto LA27_;
					lastX60gensym26_ = (path ? path->Sup.len : 0);
				}
				LA27_: ;
				candidate = substr__2yh9cer0ymNRHlOOg8P7IuA(path, firstX60gensym26_, (NI)(lastX60gensym26_ - ((NI) 1)));
				{
					NimStringDesc* x;
					NimStringDesc* T34_;
					{
						if (!((candidate ? candidate->Sup.len : 0) == ((NI) 0))) goto LA32_;
						goto LA29;
					}
					LA32_: ;
					T34_ = (NimStringDesc*)0;
					T34_ = expandTilde__RmQRR8GLDFICboxWoCEpMw_2(candidate);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					x = slash___gEyhbzZ1UcxyenWRLJRXNQ(T34_, exe);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					{
						NimStringDesc** ext;
						NI i_2;
						ext = (NimStringDesc**)0;
						i_2 = ((NI) 0);
						{
							while (1) {
								NimStringDesc* x_2;
								if (!(i_2 < extensionsLen_0)) goto LA37;
								ext = (&extensions[i_2]);
								x_2 = nosaddFileExt(x, (*ext));
								if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
								{
									NIM_BOOL T40_;
									T40_ = (NIM_BOOL)0;
									T40_ = nosfileExists(x_2);
									if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
									if (!T40_) goto LA41_;
									{
										while (1) {
											if (!followSymlinks) goto LA44;
											{
												NIM_BOOL T47_;
												NimStringDesc* r;
												NI len;
												T47_ = (NIM_BOOL)0;
												T47_ = checkSymlink__K8A5Y9b9bcyjk7pehBjrT8Kw(x_2);
												if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
												if (!T47_) goto LA48_;
												r = mnewString(((NI) 256));
												len = readlink(nimToCStringConv(x_2), nimToCStringConv(r), ((NI) 256));
												{
													NI32 T54_;
													if (!(len < ((NI) 0))) goto LA52_;
													T54_ = (NI32)0;
													T54_ = osLastError__9bUWNxbcGnToMWA9b79aTXLIw();
													if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
													raiseOSError__CWyPYlyH9a6rAuZckFyVxPA(T54_, exe);
													if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
												}
												LA52_: ;
												{
													if (!(((NI) 256) < len)) goto LA57_;
													r = mnewString(((NI) ((NI)(len + ((NI) 1)))));
													len = readlink(nimToCStringConv(x_2), nimToCStringConv(r), len);
												}
												LA57_: ;
												r = setLengthStr(r, ((NI) (len)));
												{
													NIM_BOOL T61_;
													T61_ = (NIM_BOOL)0;
													T61_ = nosisAbsolute(r);
													if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
													if (!T61_) goto LA62_;
													x_2 = copyString(r);
												}
												goto LA59_;
												LA62_: ;
												{
													NimStringDesc* T65_;
													T65_ = (NimStringDesc*)0;
													T65_ = nosparentDir(x_2);
													if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
													x_2 = slash___gEyhbzZ1UcxyenWRLJRXNQ(T65_, r);
													if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
												}
												LA59_: ;
											}
											goto LA45_;
											LA48_: ;
											{
												goto LA43;
											}
											LA45_: ;
										} LA44: ;
									} LA43: ;
									result = copyString(x_2);
									goto BeforeRet_;
								}
								LA41_: ;
								i_2 += ((NI) 1);
							} LA37: ;
						}
					}
				} LA29: ;
				{
					if (!(splitsX60gensym26_ == ((NI) 0))) goto LA69_;
					goto LA19;
				}
				LA69_: ;
				splitsX60gensym26_ -= ((NI) 1);
				lastX60gensym26_ += ((NI) 1);
			} LA20: ;
		} LA19: ;
	}
	result = ((NimStringDesc*) NIM_NIL);
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(int, exitStatusLikeShell__vmXOHpv9cjOB5AHi6OOlhbw)(int status) {
	int result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (int)0;
	{
		NIM_BOOL T3_;
		int T6_;
		T3_ = (NIM_BOOL)0;
		T3_ = WIFSIGNALED__o9b5GK70QLj9ahJeczQ2LyRg(status);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T3_) goto LA4_;
		T6_ = (int)0;
		T6_ = WTERMSIG__T7ZeAv6ofGPBA29bsuGG1ug(status);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		result = (NI32)(((NI32) 128) + T6_);
	}
	goto LA1_;
	LA4_: ;
	{
		result = WEXITSTATUS__T7ZeAv6ofGPBA29bsuGG1ug_2(status);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, rawCreateDir__GHseAa61lv8Sp9b2kQD9baYQ)(NimStringDesc* dir) {
	NIM_BOOL result;
	int res;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	res = mkdir(nimToCStringConv(dir), ((mode_t) 511));
	{
		if (!(res == ((NI32) 0))) goto LA3_;
		result = NIM_TRUE;
	}
	goto LA1_;
	LA3_: ;
	{
		if (!(errno == ((int) 17))) goto LA6_;
		result = NIM_FALSE;
	}
	goto LA1_;
	LA6_: ;
	{
		NI32 T9_;
		T9_ = (NI32)0;
		T9_ = osLastError__9bUWNxbcGnToMWA9b79aTXLIw();
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		raiseOSError__CWyPYlyH9a6rAuZckFyVxPA(T9_, dir);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosdirExists)(NimStringDesc* dir) {
	NIM_BOOL result;
	struct stat res;
	NIM_BOOL T1_;
	int T2_;
{	result = (NIM_BOOL)0;
	nimZeroMem((void*)(&res), sizeof(struct stat));
	T1_ = (NIM_BOOL)0;
	T2_ = (int)0;
	T2_ = stat(nimToCStringConv(dir), (&res));
	T1_ = (((NI32) 0) <= T2_);
	if (!(T1_)) goto LA3_;
	T1_ = S_ISDIR(res.st_mode);
	LA3_: ;
	result = T1_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosexistsOrCreateDir)(NimStringDesc* dir) {
	NIM_BOOL result;
	NIM_BOOL T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	T1_ = (NIM_BOOL)0;
	T1_ = rawCreateDir__GHseAa61lv8Sp9b2kQD9baYQ(dir);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = !(T1_);
	{
		if (!result) goto LA4_;
		{
			NIM_BOOL T8_;
			tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw* T11_;
			NimStringDesc* T12_;
			T8_ = (NIM_BOOL)0;
			T8_ = nosdirExists(dir);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			if (!!(T8_)) goto LA9_;
			T11_ = (tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw*)0;
			T11_ = (tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw*) newObj((&NTI__HMIVdYjdZYWskTmTQVo5BQ_), sizeof(tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw));
			(*T11_).Sup.Sup.Sup.m_type = (&NTI__iLZrPn9anoh9ad1MmO0RczFw_);
			(*T11_).Sup.Sup.name = "IOError";
			T12_ = (NimStringDesc*)0;
			T12_ = rawNewString((dir ? dir->Sup.len : 0) + 19);
appendString(T12_, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_14));
appendString(T12_, dir);
appendString(T12_, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_15));
			(*T11_).Sup.Sup.message = T12_;
			(*T11_).Sup.Sup.parent = NIM_NIL;
			raiseExceptionEx((Exception*)T11_, "IOError", "existsOrCreateDir", "os.nim", 2321);
			goto BeforeRet_;
		}
		LA9_: ;
	}
	LA4_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, noscreateDir)(NimStringDesc* dir) {
	NIM_BOOL omitNext;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	omitNext = NIM_FALSE;
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (NI)((dir ? dir->Sup.len : 0) - ((NI) 1));
		res = ((NI) 1);
		{
			while (1) {
				if (!(res <= colontmp_)) goto LA3;
				i = res;
				{
					if (!(((NU8)(dir->data[i])) == ((NU8)(47)) || ((NU8)(dir->data[i])) == ((NU8)(47)))) goto LA6_;
					{
						if (!omitNext) goto LA10_;
						omitNext = NIM_FALSE;
					}
					goto LA8_;
					LA10_: ;
					{
						NimStringDesc* T13_;
						NIM_BOOL T14_;
						T13_ = (NimStringDesc*)0;
						T13_ = substr__2yh9cer0ymNRHlOOg8P7IuA(dir, ((NI) 0), (NI)(i - ((NI) 1)));
						T14_ = (NIM_BOOL)0;
						T14_ = nosexistsOrCreateDir(T13_);
						if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
						(void)(T14_);
					}
					LA8_: ;
				}
				LA6_: ;
				res += ((NI) 1);
			} LA3: ;
		}
	}
	{
		NIM_BOOL T17_;
		NIM_BOOL T18_;
		NIM_CHAR T21_;
		NIM_BOOL T24_;
		T17_ = (NIM_BOOL)0;
		T18_ = (NIM_BOOL)0;
		T18_ = (((NI) 0) < (dir ? dir->Sup.len : 0));
		if (!(T18_)) goto LA19_;
		T18_ = !(omitNext);
		LA19_: ;
		T17_ = T18_;
		if (!(T17_)) goto LA20_;
		T21_ = (NIM_CHAR)0;
		T21_ = X5BX5D___okzHJ6GE9cv0bYG3b4r5KCAsystem(dir, ((NI) 1));
		T17_ = !((((NU8)(T21_)) == ((NU8)(47)) || ((NU8)(T21_)) == ((NU8)(47))));
		LA20_: ;
		if (!T17_) goto LA22_;
		T24_ = (NIM_BOOL)0;
		T24_ = nosexistsOrCreateDir(dir);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		(void)(T24_);
	}
	LA22_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, noschangeFileExt)(NimStringDesc* filename, NimStringDesc* ext) {
	NimStringDesc* result;
	NI extPos;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	extPos = searchExtPos__sw9aya5BvknC6WiJX9aEYn9ag_2(filename);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		NimStringDesc* T5_;
		NimStringDesc* T6_;
		if (!(extPos < ((NI) 0))) goto LA3_;
		T5_ = (NimStringDesc*)0;
		T6_ = (NimStringDesc*)0;
		T6_ = normExt__5YE1ExrSIVKLWtBPQtnFCw(ext);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T5_ = rawNewString((filename ? filename->Sup.len : 0) + (T6_ ? T6_->Sup.len : 0) + 0);
appendString(T5_, filename);
appendString(T5_, T6_);
		result = T5_;
	}
	goto LA1_;
	LA3_: ;
	{
		NimStringDesc* T8_;
		NimStringDesc* T9_;
		NimStringDesc* T10_;
		T8_ = (NimStringDesc*)0;
		T9_ = (NimStringDesc*)0;
		T9_ = substr__2yh9cer0ymNRHlOOg8P7IuA(filename, ((NI) 0), (NI)(extPos - ((NI) 1)));
		T10_ = (NimStringDesc*)0;
		T10_ = normExt__5YE1ExrSIVKLWtBPQtnFCw(ext);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T8_ = rawNewString((T9_ ? T9_->Sup.len : 0) + (T10_ ? T10_->Sup.len : 0) + 0);
appendString(T8_, T9_);
appendString(T8_, T10_);
		result = T8_;
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nospquoteShellPosix)(NimStringDesc* s) {
	NimStringDesc* result;
	NIM_BOOL safe;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	{
		if (!((s ? s->Sup.len : 0) == ((NI) 0))) goto LA3_;
		result = copyString(((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_16));
		goto BeforeRet_;
	}
	LA3_: ;
	safe = allCharsInSet__dubrHoRt3C9a0HlJjsxM5ig(s, TM__yu6cxgKBBXbNsTkT9cyMd4g_17);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		if (!safe) goto LA7_;
		result = copyString(s);
		goto BeforeRet_;
	}
	goto LA5_;
	LA7_: ;
	{
		NimStringDesc* T10_;
		NimStringDesc* T11_;
		T10_ = (NimStringDesc*)0;
		T11_ = (NimStringDesc*)0;
		T11_ = nsuReplaceStr(s, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_15), ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_18));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T10_ = rawNewString((T11_ ? T11_->Sup.len : 0) + 2);
appendString(T10_, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_15));
appendString(T10_, T11_);
appendString(T10_, ((NimStringDesc*) &TM__yu6cxgKBBXbNsTkT9cyMd4g_15));
		result = T10_;
		goto BeforeRet_;
	}
	LA5_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nospquoteShell)(NimStringDesc* s) {
	NimStringDesc* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NimStringDesc*)0;
	result = nospquoteShellPosix(s);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nostryRemoveFile)(NimStringDesc* file) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	result = NIM_TRUE;
	{
		NIM_BOOL T3_;
		int T4_;
		T3_ = (NIM_BOOL)0;
		T4_ = (int)0;
		T4_ = unlink(nimToCStringConv(file));
		T3_ = !((T4_ == ((NI32) 0)));
		if (!(T3_)) goto LA5_;
		T3_ = !((errno == ((int) 2)));
		LA5_: ;
		if (!T3_) goto LA6_;
		result = NIM_FALSE;
	}
	LA6_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osInit000)(void) {
{

	nimRegisterThreadLocalMarker(TM__yu6cxgKBBXbNsTkT9cyMd4g_2);

}
}

N_LIB_PRIVATE N_NIMCALL(void, stdlib_osDatInit000)(void) {

/* section: NIM_merge_TYPE_INIT3 */
NTI__sM4lkSb7zS6F7OVMvW9cffQ_.size = sizeof(tySequence__sM4lkSb7zS6F7OVMvW9cffQ*);
NTI__sM4lkSb7zS6F7OVMvW9cffQ_.align = NIM_ALIGNOF(tySequence__sM4lkSb7zS6F7OVMvW9cffQ*);
NTI__sM4lkSb7zS6F7OVMvW9cffQ_.kind = 24;
NTI__sM4lkSb7zS6F7OVMvW9cffQ_.base = (&NTI__77mFvmsOLKik79ci2hXkHEg_);
NTI__sM4lkSb7zS6F7OVMvW9cffQ_.flags = 2;
NTI__sM4lkSb7zS6F7OVMvW9cffQ_.marker = Marker_tySequence__sM4lkSb7zS6F7OVMvW9cffQ;
}

