/* Generated by Nimrod Compiler v0.9.4 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, i386, gcc */
/* Command for C compiler:
   gcc -c  -w  -I/build/nimrod/src/nimrod/lib -o nimcache/stdlib_os.o nimcache/stdlib_os.c */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <stdlib.h>

#include <string.h>

#include <time.h>

#include <sys/time.h>

#include <errno.h>

#include <sys/stat.h>

#include <sys/types.h>

#include <stdio.h>

#include <dirent.h>

#include <unistd.h>
typedef struct TY10665 TY10665;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct einvalidindex2459 einvalidindex2459;
typedef struct esynch2429 esynch2429;
typedef struct E_Base E_Base;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell41290 tcell41290;
typedef struct tcellseq41306 tcellseq41306;
typedef struct tgcheap43216 tgcheap43216;
typedef struct tcellset41302 tcellset41302;
typedef struct tpagedesc41298 tpagedesc41298;
typedef struct tmemregion23610 tmemregion23610;
typedef struct tsmallchunk22838 tsmallchunk22838;
typedef struct tllchunk23604 tllchunk23604;
typedef struct tbigchunk22840 tbigchunk22840;
typedef struct tintset22815 tintset22815;
typedef struct ttrunk22811 ttrunk22811;
typedef struct tavlnode23608 tavlnode23608;
typedef struct tgcstat43214 tgcstat43214;
typedef struct eos2435 eos2435;
typedef struct esystem2431 esystem2431;
typedef struct TY107700 TY107700;
typedef struct TY93105 TY93105;
typedef struct tbasechunk22836 tbasechunk22836;
typedef struct tfreecell22828 tfreecell22828;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY2289) (void* p, NI op);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY2289 marker;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  E_Base  {
  TNimObject Sup;
E_Base* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  esynch2429  {
  E_Base Sup;
};
struct  einvalidindex2459  {
  esynch2429 Sup;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  tcell41290  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq41306  {
NI Len;
NI Cap;
tcell41290** D;
};
struct  tcellset41302  {
NI Counter;
NI Max;
tpagedesc41298* Head;
tpagedesc41298** Data;
};
typedef tsmallchunk22838* TY23622[512];
typedef ttrunk22811* ttrunkbuckets22813[256];
struct  tintset22815  {
ttrunkbuckets22813 Data;
};
struct  tmemregion23610  {
NI Minlargeobj;
NI Maxlargeobj;
TY23622 Freesmallchunks;
tllchunk23604* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk22840* Freechunkslist;
tintset22815 Chunkstarts;
tavlnode23608* Root;
tavlnode23608* Deleted;
tavlnode23608* Last;
tavlnode23608* Freeavlnodes;
};
struct  tgcstat43214  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap43216  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq41306 Zct;
tcellseq41306 Decstack;
tcellset41302 Cycleroots;
tcellseq41306 Tempstack;
NI Recgclock;
tmemregion23610 Region;
tgcstat43214 Stat;
};
struct  esystem2431  {
  esynch2429 Sup;
};
struct  eos2435  {
  esystem2431 Sup;
NI32 Errorcode;
};
struct TY107700 {
NimStringDesc* Field0;
NimStringDesc* Field1;
NimStringDesc* Field2;
};
struct TY93105 {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
typedef NIM_CHAR TY96549[256];
typedef NI TY22818[16];
struct  tpagedesc41298  {
tpagedesc41298* Next;
NI Key;
TY22818 Bits;
};
struct  tbasechunk22836  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk22838  {
  tbasechunk22836 Sup;
tsmallchunk22838* Next;
tsmallchunk22838* Prev;
tfreecell22828* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk23604  {
NI Size;
NI Acc;
tllchunk23604* Next;
};
struct  tbigchunk22840  {
  tbasechunk22836 Sup;
tbigchunk22840* Next;
tbigchunk22840* Prev;
NI Align;
NF Data;
};
struct  ttrunk22811  {
ttrunk22811* Next;
NI Key;
TY22818 Bits;
};
typedef tavlnode23608* TY23614[2];
struct  tavlnode23608  {
TY23614 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tfreecell22828  {
tfreecell22828* Next;
NI Zerofield;
};
struct TY10665 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
static N_INLINE(NimStringDesc*, pop_111300)(TY10665** s_111308);
static N_INLINE(NI, subInt)(NI a, NI b);
N_NOINLINE(void, raiseOverflow)(void);
N_NOINLINE(void, raiseIndexError)(void);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(TGenericSeq*, setLengthSeq)(TGenericSeq* seq, NI elemsize, NI newlen);
static N_INLINE(void, nimFrame)(TFrame* s);
static N_INLINE(void, popFrame)(void);
N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(tcell41290*, usrtocell_44643)(void* usr);
static N_INLINE(void, rtladdzct_46202)(tcell41290* c);
N_NOINLINE(void, addzct_44618)(tcellseq41306* s, tcell41290* c);
N_NIMCALL(void, raiseException)(E_Base* e, NCSTRING ename);
N_NIMCALL(NI, findenvvar_110403)(NimStringDesc* key);
N_NIMCALL(void, getenvvarsc_110002)(void);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
static N_INLINE(NI, addInt)(NI a, NI b);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(NIM_BOOL, nsuStartsWith)(NimStringDesc* s, NimStringDesc* prefix);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
static N_INLINE(NI, divInt)(NI a, NI b);
N_NOINLINE(void, raiseDivByZero)(void);
static N_INLINE(NI, modInt)(NI a, NI b);
N_NIMCALL(NI, mulInt)(NI a, NI b);
N_NIMCALL(NimStringDesc*, oserrormsg_105067)(NI32 errorcode);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(NimStringDesc*, nososErrorMsg)(void);
N_NIMCALL(NI, searchextpos_107661)(NimStringDesc* s);
N_NIMCALL(NimStringDesc*, normext_107655)(NimStringDesc* ext);
N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(NIM_BOOL, open_10203)(FILE** f, NimStringDesc* filename, NU8 mode, NI bufsize);
N_NIMCALL(void, oserror_105205)(NI32 errorcode);
N_NIMCALL(NI32, oslasterror_105231)(void);
N_NOCONV(void*, alloc_4601)(NI size);
N_NIMCALL(NI, readbuffer_10627)(FILE* f, void* buffer, NI len);
N_NIMCALL(NI, writebuffer_10646)(FILE* f, void* buffer, NI len);
N_NOCONV(void, dealloc_4645)(void* p);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_70824, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
N_NIMCALL(void, nossetFilePermissions)(NimStringDesc* filename, NU16 permissions);
N_NIMCALL(NU16, nosgetFilePermissions)(NimStringDesc* filename);
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NimStringDesc*, HEX2F_107477)(NimStringDesc* head, NimStringDesc* tail);
N_NIMCALL(void, nosremoveFile)(NimStringDesc* file);
N_NIMCALL(void, nosremoveDir)(NimStringDesc* dir);
N_NIMCALL(void, rawremovedir_111390)(NimStringDesc* dir);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newlen);
STRING_LITERAL(TMP256, "invalid index", 13);
STRING_LITERAL(TMP291, "", 0);
STRING_LITERAL(TMP373, "unknown OS error", 16);
STRING_LITERAL(TMP484, ".", 1);
STRING_LITERAL(TMP485, "..", 2);
NIM_BOOL envcomputed_109804;
TY10665* environment_109806;
extern NCSTRING* environ;
extern TFrame* frameptr_13038;
extern int cmdCount;
extern NCSTRING* cmdLine;
extern TNimType NTI17201; /* ref EInvalidIndex */
extern TNimType NTI2459; /* EInvalidIndex */
extern tgcheap43216 gch_43244;
extern TNimType NTI10665; /* seq[string] */
extern TNimType NTI105208; /* ref EOS */
extern TNimType NTI2435; /* EOS */

static N_INLINE(NI, subInt)(NI a, NI b) {
	NI result;
	result = 0;
	result = (NI)((NU32)(a) - (NU32)(b));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (0 <= (NI)(result ^ a));
		if (LOC3) goto LA4;
		LOC3 = (0 <= (NI)(result ^ (NI)((NU32) ~(b))));
		LA4: ;
		if (!LOC3) goto LA5;
		goto BeforeRet;
	}
	LA5: ;
	raiseOverflow();
	BeforeRet: ;
	return result;
}

static N_INLINE(void, nimFrame)(TFrame* s) {
	(*s).prev = frameptr_13038;
	frameptr_13038 = s;
}

static N_INLINE(void, popFrame)(void) {
	frameptr_13038 = (*frameptr_13038).prev;
}

static N_INLINE(NimStringDesc*, pop_111300)(TY10665** s_111308) {
	NimStringDesc* result;
	NI l;
	NI TMP249;
	nimfr("pop", "system.nim")
	result = 0;
	nimln(1692, "system.nim");
	nimln(1692, "system.nim");
	nimln(1692, "system.nim");
	TMP249 = subInt((*s_111308)->Sup.len, 1);
	l = (NI32)(TMP249);
	nimln(1693, "system.nim");
	if ((NU)(l) >= (NU)((*s_111308)->Sup.len)) raiseIndexError();
	result = copyString((*s_111308)->data[l]);
	nimln(1694, "system.nim");
	(*s_111308) = (TY10665*) setLengthSeq(&((*s_111308))->Sup, sizeof(NimStringDesc*), l);
	popFrame();
	return result;
}

N_NIMCALL(NI, paramcount_113233)(void) {
	NI result;
	NI32 TMP253;
	nimfr("paramCount", "os.nim")
	result = 0;
	nimln(1598, "os.nim");
	nimln(1598, "os.nim");
	nimln(1598, "os.nim");
	TMP253 = subInt(cmdCount, ((NI32) 1));
	result = ((NI) ((NI32)(TMP253)));
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

static N_INLINE(tcell41290*, usrtocell_44643)(void* usr) {
	tcell41290* result;
	nimfr("usrToCell", "gc.nim")
	result = 0;
	nimln(118, "gc.nim");
	nimln(118, "gc.nim");
	nimln(118, "gc.nim");
	result = ((tcell41290*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(tcell41290))))));
	popFrame();
	return result;
}

static N_INLINE(void, rtladdzct_46202)(tcell41290* c) {
	nimfr("rtlAddZCT", "gc.nim")
	nimln(199, "gc.nim");
	addzct_44618(&gch_43244.Zct, c);
	popFrame();
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tcell41290* c;
	nimfr("nimGCunrefNoCycle", "gc.nim")
	nimln(233, "gc.nim");
	c = usrtocell_44643(p);
	nimln(235, "gc.nim");
	{
		nimln(167, "gc.nim");
		(*c).Refcount -= 8;
		nimln(168, "gc.nim");
		if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA3;
		nimln(236, "gc.nim");
		rtladdzct_46202(c);
	}
	LA3: ;
	popFrame();
}

N_NIMCALL(NimStringDesc*, paramstr_113205)(NI i) {
	NimStringDesc* result;
	einvalidindex2459* e_113212;
	NimStringDesc* LOC7;
	nimfr("paramStr", "os.nim")
	result = 0;
	nimln(1595, "os.nim");
	{
		NIM_BOOL LOC3;
		nimln(1595, "os.nim");
		LOC3 = 0;
		nimln(1595, "os.nim");
		LOC3 = (i < ((NI) (cmdCount)));
		if (!(LOC3)) goto LA4;
		nimln(1595, "os.nim");
		LOC3 = (0 <= i);
		LA4: ;
		if (!LOC3) goto LA5;
		nimln(1595, "os.nim");
		nimln(1595, "os.nim");
		nimln(1595, "os.nim");
		if ((NU)(i) > (NU)(50000)) raiseIndexError();
		result = cstrToNimstr(cmdLine[(i)- 0]);
		goto BeforeRet;
	}
	LA5: ;
	e_113212 = 0;
	nimln(1992, "system.nim");
	e_113212 = (einvalidindex2459*) newObj((&NTI17201), sizeof(einvalidindex2459));
	(*e_113212).Sup.Sup.Sup.m_type = (&NTI2459);
	nimln(1993, "system.nim");
	LOC7 = 0;
	LOC7 = (*e_113212).Sup.Sup.message; (*e_113212).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP256));
	if (LOC7) nimGCunrefNoCycle(LOC7);
	nimln(1596, "os.nim");
	raiseException((E_Base*)e_113212, "EInvalidIndex");
	BeforeRet: ;
	popFrame();
	return result;
}

static N_INLINE(NI, addInt)(NI a, NI b) {
	NI result;
	result = 0;
	result = (NI)((NU32)(a) + (NU32)(b));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (0 <= (NI)(result ^ a));
		if (LOC3) goto LA4;
		LOC3 = (0 <= (NI)(result ^ b));
		LA4: ;
		if (!LOC3) goto LA5;
		goto BeforeRet;
	}
	LA5: ;
	raiseOverflow();
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, getenvvarsc_110002)(void) {
	nimfr("getEnvVarsC", "os.nim")
	nimln(1113, "os.nim");
	{
		NI i;
		nimln(1113, "os.nim");
		if (!!(envcomputed_109804)) goto LA3;
		nimln(1114, "os.nim");
		if (environment_109806) nimGCunrefNoCycle(environment_109806);
		environment_109806 = (TY10665*) newSeqRC1((&NTI10665), 0);
		nimln(1117, "os.nim");
		i = 0;
		nimln(1118, "os.nim");
		while (1) {
			NimStringDesc* LOC10;
			NimStringDesc* LOC11;
			nimln(1119, "os.nim");
			{
				nimln(1119, "os.nim");
				if ((NU)(i) > (NU)(50000)) raiseIndexError();
				if (!(environ[(i)- 0] == NIM_NIL)) goto LA8;
				nimln(1119, "os.nim");
				goto LA5;
			}
			LA8: ;
			nimln(1120, "os.nim");
			nimln(1120, "os.nim");
			if ((NU)(i) > (NU)(50000)) raiseIndexError();
			LOC10 = 0;
			LOC10 = cstrToNimstr(environ[(i)- 0]);
			environment_109806 = (TY10665*) incrSeq(&(environment_109806)->Sup, sizeof(NimStringDesc*));
			LOC11 = 0;
			LOC11 = environment_109806->data[environment_109806->Sup.len-1]; environment_109806->data[environment_109806->Sup.len-1] = copyStringRC1(LOC10);
			if (LOC11) nimGCunrefNoCycle(LOC11);
			nimln(1121, "os.nim");
			i = addInt(i, 1);
		} LA5: ;
		nimln(1122, "os.nim");
		envcomputed_109804 = NIM_TRUE;
	}
	LA3: ;
	popFrame();
}

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

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

N_NIMCALL(NI, findenvvar_110403)(NimStringDesc* key) {
	NI result;
	NimStringDesc* temp;
	NimStringDesc* LOC1;
	NI i_110418;
	NI HEX3Atmp_110419;
	NI res_110421;
	nimfr("findEnvVar", "os.nim")
	result = 0;
	nimln(1125, "os.nim");
	getenvvarsc_110002();
	nimln(1126, "os.nim");
	nimln(1126, "os.nim");
	LOC1 = 0;
	LOC1 = rawNewString(key->Sup.len + 1);
appendString(LOC1, key);
appendChar(LOC1, 61);
	temp = LOC1;
	i_110418 = 0;
	HEX3Atmp_110419 = 0;
	nimln(1127, "os.nim");
	nimln(1127, "os.nim");
	HEX3Atmp_110419 = (environment_109806->Sup.len-1);
	nimln(1458, "system.nim");
	res_110421 = 0;
	nimln(1459, "system.nim");
	while (1) {
		nimln(1459, "system.nim");
		if (!(res_110421 <= HEX3Atmp_110419)) goto LA2;
		nimln(1458, "system.nim");
		i_110418 = res_110421;
		nimln(1128, "os.nim");
		{
			NIM_BOOL LOC5;
			nimln(1128, "os.nim");
			if ((NU)(i_110418) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
			LOC5 = 0;
			LOC5 = nsuStartsWith(environment_109806->data[i_110418], temp);
			if (!LOC5) goto LA6;
			nimln(1128, "os.nim");
			nimln(1128, "os.nim");
			result = i_110418;
			goto BeforeRet;
		}
		LA6: ;
		nimln(1461, "system.nim");
		res_110421 = addInt(res_110421, 1);
	} LA2: ;
	nimln(1129, "os.nim");
	nimln(1129, "os.nim");
	result = -1;
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, getenv_110426)(NimStringDesc* key) {
	NimStringDesc* result;
	NI i;
	nimfr("getEnv", "os.nim")
	result = 0;
	nimln(1137, "os.nim");
	i = findenvvar_110403(key);
	nimln(1138, "os.nim");
	{
		NI LOC5;
		NI TMP290;
		nimln(1138, "os.nim");
		if (!(0 <= i)) goto LA3;
		nimln(1139, "os.nim");
		nimln(1139, "os.nim");
		nimln(1139, "os.nim");
		if ((NU)(i) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		nimln(1139, "os.nim");
		nimln(1139, "os.nim");
		if ((NU)(i) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		LOC5 = 0;
		LOC5 = nsuFindChar(environment_109806->data[i], 61, 0);
		TMP290 = addInt(LOC5, 1);
		result = copyStr(environment_109806->data[i], (NI32)(TMP290));
		goto BeforeRet;
	}
	goto LA1;
	LA3: ;
	{
		NCSTRING env;
		nimln(1141, "os.nim");
		env = getenv(key->data);
		nimln(1142, "os.nim");
		{
			nimln(1142, "os.nim");
			if (!(env == NIM_NIL)) goto LA9;
			nimln(1142, "os.nim");
			nimln(1142, "os.nim");
			result = copyString(((NimStringDesc*) &TMP291));
			goto BeforeRet;
		}
		LA9: ;
		nimln(1143, "os.nim");
		nimln(1143, "os.nim");
		result = cstrToNimstr(env);
	}
	LA1: ;
	BeforeRet: ;
	popFrame();
	return result;
}

static N_INLINE(NI, divInt)(NI a, NI b) {
	NI result;
	result = 0;
	{
		if (!(b == 0)) goto LA3;
		raiseDivByZero();
	}
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = (a == (-2147483647 -1));
		if (!(LOC7)) goto LA8;
		LOC7 = (b == -1);
		LA8: ;
		if (!LOC7) goto LA9;
		raiseOverflow();
	}
	LA9: ;
	result = (NI32)(a / b);
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

static N_INLINE(NI, modInt)(NI a, NI b) {
	NI result;
	result = 0;
	{
		if (!(b == 0)) goto LA3;
		raiseDivByZero();
	}
	LA3: ;
	result = (NI32)(a % b);
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, nossleep)(NI milsecs) {
	struct timespec a;
	struct timespec b;
	NI TMP351;
	NI TMP352;
	NI TMP353;
	NI TMP354;
	int LOC1;
	nimfr("sleep", "os.nim")
	memset((void*)&a, 0, sizeof(a));
	memset((void*)&b, 0, sizeof(b));
	nimln(1708, "os.nim");
	nimln(1708, "os.nim");
	TMP351 = divInt(milsecs, 1000);
	a.tv_sec = (NI32)(TMP351);
	nimln(1709, "os.nim");
	nimln(1709, "os.nim");
	nimln(1709, "os.nim");
	nimln(1709, "os.nim");
	TMP352 = modInt(milsecs, 1000);
	TMP353 = mulInt(((NI) ((NI32)(TMP352))), 1000);
	TMP354 = mulInt(((NI) ((NI32)(TMP353))), 1000);
	a.tv_nsec = ((NI) ((NI32)(TMP354)));
	nimln(1710, "os.nim");
	nimln(1710, "os.nim");
	LOC1 = 0;
	LOC1 = nanosleep(&a, &b);
	popFrame();
}

N_NIMCALL(NimStringDesc*, oserrormsg_105067)(NI32 errorcode) {
	NimStringDesc* result;
	nimfr("osErrorMsg", "os.nim")
	result = 0;
	nimln(236, "os.nim");
	result = copyString(((NimStringDesc*) &TMP291));
	nimln(252, "os.nim");
	{
		NCSTRING LOC5;
		nimln(252, "os.nim");
		nimln(252, "os.nim");
		if (!!((errorcode == ((NI32) 0)))) goto LA3;
		nimln(253, "os.nim");
		nimln(253, "os.nim");
		nimln(253, "os.nim");
		LOC5 = 0;
		LOC5 = strerror(errorcode);
		result = cstrToNimstr(LOC5);
	}
	LA3: ;
	popFrame();
	return result;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	nimfr("asgnRefNoCycle", "gc.nim")
	nimln(251, "gc.nim");
	{
		tcell41290* c;
		nimln(251, "gc.nim");
		nimln(251, "gc.nim");
		if (!!((src == NIM_NIL))) goto LA3;
		nimln(252, "gc.nim");
		c = usrtocell_44643(src);
		nimln(169, "gc.nim");
		(*c).Refcount += 8;
	}
	LA3: ;
	nimln(254, "gc.nim");
	{
		tcell41290* c;
		nimln(254, "gc.nim");
		nimln(254, "gc.nim");
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		nimln(255, "gc.nim");
		c = usrtocell_44643((*dest));
		nimln(256, "gc.nim");
		{
			nimln(167, "gc.nim");
			(*c).Refcount -= 8;
			nimln(168, "gc.nim");
			if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA11;
			nimln(257, "gc.nim");
			rtladdzct_46202(c);
		}
		LA11: ;
	}
	LA7: ;
	nimln(258, "gc.nim");
	(*dest) = src;
	popFrame();
}

N_NIMCALL(void, oserror_105205)(NI32 errorcode) {
	eos2435* e;
	nimfr("osError", "os.nim")
	e = 0;
	nimln(263, "os.nim");
	e = (eos2435*) newObj((&NTI105208), sizeof(eos2435));
	(*e).Sup.Sup.Sup.Sup.m_type = (&NTI2435);
	nimln(264, "os.nim");
	(*e).Errorcode = errorcode;
	nimln(265, "os.nim");
	asgnRefNoCycle((void**) &(*e).Sup.Sup.Sup.message, oserrormsg_105067(errorcode));
	nimln(266, "os.nim");
	{
		NimStringDesc* LOC5;
		nimln(266, "os.nim");
		if (!(((*e).Sup.Sup.Sup.message) && ((*e).Sup.Sup.Sup.message)->Sup.len == 0)) goto LA3;
		nimln(267, "os.nim");
		LOC5 = 0;
		LOC5 = (*e).Sup.Sup.Sup.message; (*e).Sup.Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP373));
		if (LOC5) nimGCunrefNoCycle(LOC5);
	}
	LA3: ;
	nimln(268, "os.nim");
	raiseException((E_Base*)e, "EOS");
	popFrame();
}

N_NIMCALL(NI32, oslasterror_105231)(void) {
	NI32 result;
	result = 0;
	result = errno;
	return result;
}

N_NIMCALL(NimStringDesc*, nososErrorMsg)(void) {
	NimStringDesc* result;
	nimfr("osErrorMsg", "os.nim")
	result = 0;
	nimln(187, "os.nim");
	result = copyString(((NimStringDesc*) &TMP291));
	nimln(203, "os.nim");
	{
		NCSTRING LOC5;
		nimln(203, "os.nim");
		nimln(203, "os.nim");
		if (!!((errno == ((NI32) 0)))) goto LA3;
		nimln(204, "os.nim");
		nimln(204, "os.nim");
		nimln(204, "os.nim");
		LOC5 = 0;
		LOC5 = strerror(errno);
		result = cstrToNimstr(LOC5);
	}
	LA3: ;
	popFrame();
	return result;
}

N_NOINLINE(void, nososError)(NimStringDesc* msg) {
	nimfr("osError", "os.nim")
	nimln(215, "os.nim");
	{
		NimStringDesc* m;
		eos2435* e_105011;
		nimln(215, "os.nim");
		nimln(215, "os.nim");
		if (!(msg->Sup.len == 0)) goto LA3;
		nimln(216, "os.nim");
		m = nososErrorMsg();
		e_105011 = 0;
		nimln(1992, "system.nim");
		e_105011 = (eos2435*) newObj((&NTI105208), sizeof(eos2435));
		(*e_105011).Sup.Sup.Sup.Sup.m_type = (&NTI2435);
		nimln(1993, "system.nim");
		nimln(217, "os.nim");
		{
			NimStringDesc* LOC9;
			nimln(217, "os.nim");
			nimln(217, "os.nim");
			if (!(0 < m->Sup.len)) goto LA7;
			LOC9 = 0;
			LOC9 = (*e_105011).Sup.Sup.Sup.message; (*e_105011).Sup.Sup.Sup.message = copyStringRC1(m);
			if (LOC9) nimGCunrefNoCycle(LOC9);
		}
		goto LA5;
		LA7: ;
		{
			NimStringDesc* LOC11;
			LOC11 = 0;
			LOC11 = (*e_105011).Sup.Sup.Sup.message; (*e_105011).Sup.Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP373));
			if (LOC11) nimGCunrefNoCycle(LOC11);
		}
		LA5: ;
		nimln(217, "os.nim");
		raiseException((E_Base*)e_105011, "EOS");
	}
	goto LA1;
	LA3: ;
	{
		eos2435* e_105032;
		NimStringDesc* LOC13;
		e_105032 = 0;
		nimln(1992, "system.nim");
		e_105032 = (eos2435*) newObj((&NTI105208), sizeof(eos2435));
		(*e_105032).Sup.Sup.Sup.Sup.m_type = (&NTI2435);
		nimln(1993, "system.nim");
		LOC13 = 0;
		LOC13 = (*e_105032).Sup.Sup.Sup.message; (*e_105032).Sup.Sup.Sup.message = copyStringRC1(msg);
		if (LOC13) nimGCunrefNoCycle(LOC13);
		nimln(219, "os.nim");
		raiseException((E_Base*)e_105032, "EOS");
	}
	LA1: ;
	popFrame();
}

N_NIMCALL(NI, searchextpos_107661)(NimStringDesc* s) {
	NI result;
	NI i_107676;
	NI HEX3Atmp_107691;
	NI TMP389;
	NI res_107693;
	nimfr("searchExtPos", "os.nim")
	result = 0;
	nimln(652, "os.nim");
	result = -1;
	i_107676 = 0;
	HEX3Atmp_107691 = 0;
	nimln(653, "os.nim");
	nimln(653, "os.nim");
	nimln(653, "os.nim");
	TMP389 = subInt(s->Sup.len, 1);
	HEX3Atmp_107691 = (NI32)(TMP389);
	nimln(1442, "system.nim");
	res_107693 = HEX3Atmp_107691;
	nimln(1443, "system.nim");
	while (1) {
		nimln(1443, "system.nim");
		if (!(1 <= res_107693)) goto LA1;
		nimln(1442, "system.nim");
		i_107676 = res_107693;
		nimln(654, "os.nim");
		{
			nimln(654, "os.nim");
			if ((NU)(i_107676) > (NU)(s->Sup.len)) raiseIndexError();
			if (!((NU8)(s->data[i_107676]) == (NU8)(46))) goto LA4;
			nimln(655, "os.nim");
			result = i_107676;
			nimln(656, "os.nim");
			goto LA1;
		}
		goto LA2;
		LA4: ;
		{
			nimln(657, "os.nim");
			if ((NU)(i_107676) > (NU)(s->Sup.len)) raiseIndexError();
			if (!(((NU8)(s->data[i_107676])) == ((NU8)(47)) || ((NU8)(s->data[i_107676])) == ((NU8)(47)))) goto LA7;
			nimln(658, "os.nim");
			goto LA1;
		}
		goto LA2;
		LA7: ;
		LA2: ;
		nimln(1445, "system.nim");
		res_107693 = subInt(res_107693, 1);
	} LA1: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, normext_107655)(NimStringDesc* ext) {
	NimStringDesc* result;
	nimfr("normExt", "os.nim")
	result = 0;
	nimln(647, "os.nim");
	{
		NIM_BOOL LOC3;
		nimln(647, "os.nim");
		LOC3 = 0;
		nimln(647, "os.nim");
		LOC3 = ((ext) && (ext)->Sup.len == 0);
		if (LOC3) goto LA4;
		nimln(647, "os.nim");
		if ((NU)(0) > (NU)(ext->Sup.len)) raiseIndexError();
		LOC3 = ((NU8)(ext->data[0]) == (NU8)(46));
		LA4: ;
		if (!LOC3) goto LA5;
		nimln(647, "os.nim");
		result = copyString(ext);
	}
	goto LA1;
	LA5: ;
	{
		NimStringDesc* LOC8;
		nimln(648, "os.nim");
		nimln(648, "os.nim");
		LOC8 = 0;
		LOC8 = rawNewString(ext->Sup.len + 1);
appendChar(LOC8, 46);
appendString(LOC8, ext);
		result = LOC8;
	}
	LA1: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, nosaddFileExt)(NimStringDesc* filename, NimStringDesc* ext) {
	NimStringDesc* result;
	NI extpos;
	nimfr("addFileExt", "os.nim")
	result = 0;
	nimln(748, "os.nim");
	extpos = searchextpos_107661(filename);
	nimln(749, "os.nim");
	{
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		nimln(749, "os.nim");
		if (!(extpos < 0)) goto LA3;
		nimln(749, "os.nim");
		nimln(749, "os.nim");
		LOC5 = 0;
		nimln(749, "os.nim");
		LOC6 = 0;
		LOC6 = normext_107655(ext);
		LOC5 = rawNewString(filename->Sup.len + LOC6->Sup.len + 0);
appendString(LOC5, filename);
appendString(LOC5, LOC6);
		result = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		nimln(750, "os.nim");
		result = copyString(filename);
	}
	LA1: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, nosjoinPath)(NimStringDesc* head, NimStringDesc* tail) {
	NimStringDesc* result;
	nimfr("joinPath", "os.nim")
	result = 0;
	nimln(527, "os.nim");
	{
		nimln(527, "os.nim");
		nimln(527, "os.nim");
		if (!(head->Sup.len == 0)) goto LA3;
		nimln(528, "os.nim");
		result = copyString(tail);
	}
	goto LA1;
	LA3: ;
	{
		NI TMP392;
		nimln(529, "os.nim");
		nimln(529, "os.nim");
		nimln(529, "os.nim");
		TMP392 = subInt(head->Sup.len, 1);
		if ((NU)((NI32)(TMP392)) > (NU)(head->Sup.len)) raiseIndexError();
		if (!(((NU8)(head->data[(NI32)(TMP392)])) == ((NU8)(47)) || ((NU8)(head->data[(NI32)(TMP392)])) == ((NU8)(47)))) goto LA6;
		nimln(530, "os.nim");
		{
			NimStringDesc* LOC12;
			NimStringDesc* LOC13;
			nimln(530, "os.nim");
			if ((NU)(0) > (NU)(tail->Sup.len)) raiseIndexError();
			if (!(((NU8)(tail->data[0])) == ((NU8)(47)) || ((NU8)(tail->data[0])) == ((NU8)(47)))) goto LA10;
			nimln(531, "os.nim");
			nimln(531, "os.nim");
			LOC12 = 0;
			nimln(531, "os.nim");
			LOC13 = 0;
			LOC13 = copyStr(tail, 1);
			LOC12 = rawNewString(head->Sup.len + LOC13->Sup.len + 0);
appendString(LOC12, head);
appendString(LOC12, LOC13);
			result = LOC12;
		}
		goto LA8;
		LA10: ;
		{
			NimStringDesc* LOC15;
			nimln(533, "os.nim");
			nimln(533, "os.nim");
			LOC15 = 0;
			LOC15 = rawNewString(head->Sup.len + tail->Sup.len + 0);
appendString(LOC15, head);
appendString(LOC15, tail);
			result = LOC15;
		}
		LA8: ;
	}
	goto LA1;
	LA6: ;
	{
		nimln(535, "os.nim");
		{
			NimStringDesc* LOC21;
			nimln(535, "os.nim");
			if ((NU)(0) > (NU)(tail->Sup.len)) raiseIndexError();
			if (!(((NU8)(tail->data[0])) == ((NU8)(47)) || ((NU8)(tail->data[0])) == ((NU8)(47)))) goto LA19;
			nimln(536, "os.nim");
			nimln(536, "os.nim");
			LOC21 = 0;
			LOC21 = rawNewString(head->Sup.len + tail->Sup.len + 0);
appendString(LOC21, head);
appendString(LOC21, tail);
			result = LOC21;
		}
		goto LA17;
		LA19: ;
		{
			NimStringDesc* LOC23;
			nimln(538, "os.nim");
			nimln(538, "os.nim");
			LOC23 = 0;
			LOC23 = rawNewString(head->Sup.len + tail->Sup.len + 1);
appendString(LOC23, head);
appendChar(LOC23, 47);
appendString(LOC23, tail);
			result = LOC23;
		}
		LA17: ;
	}
	LA1: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, HEX2F_107477)(NimStringDesc* head, NimStringDesc* tail) {
	NimStringDesc* result;
	nimfr("/", "os.nim")
	result = 0;
	nimln(559, "os.nim");
	nimln(559, "os.nim");
	result = nosjoinPath(head, tail);
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(NIM_BOOL, nosexistsFile)(NimStringDesc* filename) {
	NIM_BOOL result;
	struct stat res;
	NIM_BOOL LOC1;
	int LOC2;
	nimfr("existsFile", "os.nim")
	result = 0;
	memset((void*)&res, 0, sizeof(res));
	nimln(384, "os.nim");
	nimln(384, "os.nim");
	nimln(384, "os.nim");
	LOC1 = 0;
	nimln(384, "os.nim");
	nimln(384, "os.nim");
	LOC2 = 0;
	LOC2 = stat(filename->data, &res);
	LOC1 = (((NI32) 0) <= LOC2);
	if (!(LOC1)) goto LA3;
	nimln(384, "os.nim");
	LOC1 = S_ISREG(res.st_mode);
	LA3: ;
	result = LOC1;
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(NI, nosexecShellCmd)(NimStringDesc* command) {
	NI result;
	int LOC1;
	nimfr("execShellCmd", "os.nim")
	result = 0;
	nimln(1045, "os.nim");
	nimln(1045, "os.nim");
	nimln(1045, "os.nim");
	LOC1 = 0;
	LOC1 = system(command->data);
	result = ((NI) ((NI32)((NU32)(LOC1) >> (NU32)(((NI32) 8)))));
	popFrame();
	return result;
}

N_NIMCALL(void, noscopyFile)(NimStringDesc* source, NimStringDesc* dest) {
	FILE* d;
	FILE* s;
	void* buf;
	nimfr("copyFile", "os.nim")
	d = 0;
	s = 0;
	nimln(974, "os.nim");
	{
		NIM_BOOL LOC3;
		NI32 LOC6;
		nimln(974, "os.nim");
		nimln(974, "os.nim");
		LOC3 = 0;
		LOC3 = open_10203(&s, source, ((NU8) 0), -1);
		if (!!(LOC3)) goto LA4;
		nimln(974, "os.nim");
		nimln(974, "os.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	nimln(975, "os.nim");
	{
		NIM_BOOL LOC9;
		NI32 LOC12;
		nimln(975, "os.nim");
		nimln(975, "os.nim");
		LOC9 = 0;
		LOC9 = open_10203(&d, dest, ((NU8) 1), -1);
		if (!!(LOC9)) goto LA10;
		nimln(976, "os.nim");
		fclose(s);
		nimln(977, "os.nim");
		nimln(977, "os.nim");
		LOC12 = 0;
		LOC12 = oslasterror_105231();
		oserror_105205(LOC12);
	}
	LA10: ;
	nimln(978, "os.nim");
	buf = alloc_4601(8000);
	nimln(979, "os.nim");
	while (1) {
		NI bytesread;
		nimln(980, "os.nim");
		bytesread = readbuffer_10627(s, buf, 8000);
		nimln(981, "os.nim");
		{
			NI byteswritten;
			nimln(981, "os.nim");
			if (!(0 < bytesread)) goto LA16;
			nimln(982, "os.nim");
			byteswritten = writebuffer_10646(d, buf, bytesread);
			nimln(983, "os.nim");
			{
				NI32 LOC22;
				nimln(983, "os.nim");
				nimln(983, "os.nim");
				if (!!((bytesread == byteswritten))) goto LA20;
				nimln(984, "os.nim");
				dealloc_4645(buf);
				nimln(985, "os.nim");
				fclose(s);
				nimln(986, "os.nim");
				fclose(d);
				nimln(987, "os.nim");
				nimln(987, "os.nim");
				LOC22 = 0;
				LOC22 = oslasterror_105231();
				oserror_105205(LOC22);
			}
			LA20: ;
		}
		LA16: ;
		nimln(988, "os.nim");
		{
			nimln(988, "os.nim");
			nimln(988, "os.nim");
			if (!!((bytesread == 8000))) goto LA25;
			nimln(988, "os.nim");
			goto LA13;
		}
		LA25: ;
	} LA13: ;
	nimln(989, "os.nim");
	dealloc_4645(buf);
	nimln(990, "os.nim");
	fclose(s);
	nimln(991, "os.nim");
	fclose(d);
	popFrame();
}

N_NIMCALL(void, nossplitFile)(NimStringDesc* path, TY107700* Result) {
	nimfr("splitFile", "os.nim")
	nimln(677, "os.nim");
	{
		NIM_BOOL LOC3;
		NI TMP420;
		nimln(677, "os.nim");
		LOC3 = 0;
		nimln(677, "os.nim");
		nimln(677, "os.nim");
		LOC3 = (path->Sup.len == 0);
		if (LOC3) goto LA4;
		nimln(677, "os.nim");
		nimln(677, "os.nim");
		nimln(677, "os.nim");
		TMP420 = subInt(path->Sup.len, 1);
		if ((NU)((NI32)(TMP420)) > (NU)(path->Sup.len)) raiseIndexError();
		LOC3 = (((NU8)(path->data[(NI32)(TMP420)])) == ((NU8)(47)) || ((NU8)(path->data[(NI32)(TMP420)])) == ((NU8)(47)));
		LA4: ;
		if (!LOC3) goto LA5;
		nimln(678, "os.nim");
		unsureAsgnRef((void**) &(*Result).Field0, copyString(path));
		unsureAsgnRef((void**) &(*Result).Field1, copyString(((NimStringDesc*) &TMP291)));
		unsureAsgnRef((void**) &(*Result).Field2, copyString(((NimStringDesc*) &TMP291)));
	}
	goto LA1;
	LA5: ;
	{
		NI seppos;
		NI dotpos;
		NI i_107733;
		NI HEX3Atmp_107763;
		NI TMP421;
		NI res_107765;
		NI TMP423;
		NI TMP424;
		NI TMP425;
		nimln(680, "os.nim");
		seppos = -1;
		nimln(681, "os.nim");
		nimln(681, "os.nim");
		dotpos = path->Sup.len;
		i_107733 = 0;
		HEX3Atmp_107763 = 0;
		nimln(682, "os.nim");
		nimln(682, "os.nim");
		nimln(682, "os.nim");
		TMP421 = subInt(path->Sup.len, 1);
		HEX3Atmp_107763 = (NI32)(TMP421);
		nimln(1442, "system.nim");
		res_107765 = HEX3Atmp_107763;
		nimln(1443, "system.nim");
		while (1) {
			nimln(1443, "system.nim");
			if (!(0 <= res_107765)) goto LA8;
			nimln(1442, "system.nim");
			i_107733 = res_107765;
			nimln(683, "os.nim");
			{
				nimln(683, "os.nim");
				if ((NU)(i_107733) > (NU)(path->Sup.len)) raiseIndexError();
				if (!((NU8)(path->data[i_107733]) == (NU8)(46))) goto LA11;
				nimln(684, "os.nim");
				{
					NIM_BOOL LOC15;
					NIM_BOOL LOC16;
					NI TMP422;
					nimln(684, "os.nim");
					LOC15 = 0;
					nimln(684, "os.nim");
					LOC16 = 0;
					nimln(684, "os.nim");
					nimln(684, "os.nim");
					LOC16 = (dotpos == path->Sup.len);
					if (!(LOC16)) goto LA17;
					nimln(684, "os.nim");
					LOC16 = (0 < i_107733);
					LA17: ;
					LOC15 = LOC16;
					if (!(LOC15)) goto LA18;
					nimln(685, "os.nim");
					nimln(685, "os.nim");
					nimln(685, "os.nim");
					TMP422 = subInt(i_107733, 1);
					if ((NU)((NI32)(TMP422)) > (NU)(path->Sup.len)) raiseIndexError();
					LOC15 = !((((NU8)(path->data[(NI32)(TMP422)])) == ((NU8)(47)) || ((NU8)(path->data[(NI32)(TMP422)])) == ((NU8)(47))));
					LA18: ;
					if (!LOC15) goto LA19;
					nimln(685, "os.nim");
					dotpos = i_107733;
				}
				LA19: ;
			}
			goto LA9;
			LA11: ;
			{
				nimln(686, "os.nim");
				if ((NU)(i_107733) > (NU)(path->Sup.len)) raiseIndexError();
				if (!(((NU8)(path->data[i_107733])) == ((NU8)(47)) || ((NU8)(path->data[i_107733])) == ((NU8)(47)))) goto LA22;
				nimln(687, "os.nim");
				seppos = i_107733;
				nimln(688, "os.nim");
				goto LA8;
			}
			goto LA9;
			LA22: ;
			LA9: ;
			nimln(1445, "system.nim");
			res_107765 = subInt(res_107765, 1);
		} LA8: ;
		nimln(689, "os.nim");
		nimln(689, "os.nim");
		nimln(689, "os.nim");
		TMP423 = subInt(seppos, 1);
		unsureAsgnRef((void**) &(*Result).Field0, copyStrLast(path, 0, (NI32)(TMP423)));
		nimln(690, "os.nim");
		nimln(690, "os.nim");
		nimln(690, "os.nim");
		TMP424 = addInt(seppos, 1);
		nimln(690, "os.nim");
		TMP425 = subInt(dotpos, 1);
		unsureAsgnRef((void**) &(*Result).Field1, copyStrLast(path, (NI32)(TMP424), (NI32)(TMP425)));
		nimln(691, "os.nim");
		nimln(691, "os.nim");
		unsureAsgnRef((void**) &(*Result).Field2, copyStr(path, dotpos));
	}
	LA1: ;
	popFrame();
}

N_NIMCALL(void, nosremoveFile)(NimStringDesc* file) {
	nimfr("removeFile", "os.nim")
	nimln(1031, "os.nim");
	{
		NIM_BOOL LOC3;
		int LOC4;
		eos2435* e_109603;
		NCSTRING LOC8;
		nimln(1031, "os.nim");
		LOC3 = 0;
		nimln(1031, "os.nim");
		nimln(1031, "os.nim");
		nimln(1031, "os.nim");
		LOC4 = 0;
		LOC4 = remove(file->data);
		LOC3 = !((LOC4 == ((NI32) 0)));
		if (!(LOC3)) goto LA5;
		nimln(1031, "os.nim");
		nimln(1031, "os.nim");
		LOC3 = !((errno == ENOENT));
		LA5: ;
		if (!LOC3) goto LA6;
		e_109603 = 0;
		nimln(1992, "system.nim");
		e_109603 = (eos2435*) newObj((&NTI105208), sizeof(eos2435));
		(*e_109603).Sup.Sup.Sup.Sup.m_type = (&NTI2435);
		nimln(1993, "system.nim");
		nimln(1032, "os.nim");
		nimln(1032, "os.nim");
		LOC8 = 0;
		LOC8 = strerror(errno);
		asgnRefNoCycle((void**) &(*e_109603).Sup.Sup.Sup.message, cstrToNimstr(LOC8));
		nimln(1032, "os.nim");
		raiseException((E_Base*)e_109603, "EOS");
	}
	LA6: ;
	popFrame();
}

N_NIMCALL(void, nossetFilePermissions)(NimStringDesc* filename, NU16 permissions) {
	NI32 p;
	nimfr("setFilePermissions", "os.nim")
	nimln(922, "os.nim");
	p = ((NI32) 0);
	nimln(923, "os.nim");
	{
		nimln(923, "os.nim");
		if (!((permissions &(1<<((((NU8) 2))&15)))!=0)) goto LA3;
		nimln(923, "os.nim");
		nimln(923, "os.nim");
		p = (NI32)(p | S_IRUSR);
	}
	LA3: ;
	nimln(924, "os.nim");
	{
		nimln(924, "os.nim");
		if (!((permissions &(1<<((((NU8) 1))&15)))!=0)) goto LA7;
		nimln(924, "os.nim");
		nimln(924, "os.nim");
		p = (NI32)(p | S_IWUSR);
	}
	LA7: ;
	nimln(925, "os.nim");
	{
		nimln(925, "os.nim");
		if (!((permissions &(1<<((((NU8) 0))&15)))!=0)) goto LA11;
		nimln(925, "os.nim");
		nimln(925, "os.nim");
		p = (NI32)(p | S_IXUSR);
	}
	LA11: ;
	nimln(927, "os.nim");
	{
		nimln(927, "os.nim");
		if (!((permissions &(1<<((((NU8) 5))&15)))!=0)) goto LA15;
		nimln(927, "os.nim");
		nimln(927, "os.nim");
		p = (NI32)(p | S_IRGRP);
	}
	LA15: ;
	nimln(928, "os.nim");
	{
		nimln(928, "os.nim");
		if (!((permissions &(1<<((((NU8) 4))&15)))!=0)) goto LA19;
		nimln(928, "os.nim");
		nimln(928, "os.nim");
		p = (NI32)(p | S_IWGRP);
	}
	LA19: ;
	nimln(929, "os.nim");
	{
		nimln(929, "os.nim");
		if (!((permissions &(1<<((((NU8) 3))&15)))!=0)) goto LA23;
		nimln(929, "os.nim");
		nimln(929, "os.nim");
		p = (NI32)(p | S_IXGRP);
	}
	LA23: ;
	nimln(931, "os.nim");
	{
		nimln(931, "os.nim");
		if (!((permissions &(1<<((((NU8) 8))&15)))!=0)) goto LA27;
		nimln(931, "os.nim");
		nimln(931, "os.nim");
		p = (NI32)(p | S_IROTH);
	}
	LA27: ;
	nimln(932, "os.nim");
	{
		nimln(932, "os.nim");
		if (!((permissions &(1<<((((NU8) 7))&15)))!=0)) goto LA31;
		nimln(932, "os.nim");
		nimln(932, "os.nim");
		p = (NI32)(p | S_IWOTH);
	}
	LA31: ;
	nimln(933, "os.nim");
	{
		nimln(933, "os.nim");
		if (!((permissions &(1<<((((NU8) 6))&15)))!=0)) goto LA35;
		nimln(933, "os.nim");
		nimln(933, "os.nim");
		p = (NI32)(p | S_IXOTH);
	}
	LA35: ;
	nimln(935, "os.nim");
	{
		int LOC39;
		NI32 LOC42;
		nimln(935, "os.nim");
		nimln(935, "os.nim");
		nimln(935, "os.nim");
		LOC39 = 0;
		LOC39 = chmod(filename->data, p);
		if (!!((LOC39 == ((NI32) 0)))) goto LA40;
		nimln(935, "os.nim");
		nimln(935, "os.nim");
		LOC42 = 0;
		LOC42 = oslasterror_105231();
		oserror_105205(LOC42);
	}
	LA40: ;
	popFrame();
}

N_NIMCALL(NU16, nosgetFilePermissions)(NimStringDesc* filename) {
	NU16 result;
	struct stat a;
	nimfr("getFilePermissions", "os.nim")
	memset((void*)&result, 0, sizeof(result));
	memset((void*)&a, 0, sizeof(a));
	nimln(891, "os.nim");
	{
		int LOC3;
		NI32 LOC6;
		nimln(891, "os.nim");
		nimln(891, "os.nim");
		LOC3 = 0;
		LOC3 = stat(filename->data, &a);
		if (!(LOC3 < ((NI32) 0))) goto LA4;
		nimln(891, "os.nim");
		nimln(891, "os.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	nimln(892, "os.nim");
	result = 0;
	nimln(893, "os.nim");
	{
		nimln(893, "os.nim");
		nimln(893, "os.nim");
		nimln(893, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IRUSR) == ((NI32) 0)))) goto LA9;
		nimln(893, "os.nim");
		result |=((NI16)(1)<<((((NU8) 2))%(sizeof(NI16)*8)));
	}
	LA9: ;
	nimln(894, "os.nim");
	{
		nimln(894, "os.nim");
		nimln(894, "os.nim");
		nimln(894, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IWUSR) == ((NI32) 0)))) goto LA13;
		nimln(894, "os.nim");
		result |=((NI16)(1)<<((((NU8) 1))%(sizeof(NI16)*8)));
	}
	LA13: ;
	nimln(895, "os.nim");
	{
		nimln(895, "os.nim");
		nimln(895, "os.nim");
		nimln(895, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IXUSR) == ((NI32) 0)))) goto LA17;
		nimln(895, "os.nim");
		result |=((NI16)(1)<<((((NU8) 0))%(sizeof(NI16)*8)));
	}
	LA17: ;
	nimln(897, "os.nim");
	{
		nimln(897, "os.nim");
		nimln(897, "os.nim");
		nimln(897, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IRGRP) == ((NI32) 0)))) goto LA21;
		nimln(897, "os.nim");
		result |=((NI16)(1)<<((((NU8) 5))%(sizeof(NI16)*8)));
	}
	LA21: ;
	nimln(898, "os.nim");
	{
		nimln(898, "os.nim");
		nimln(898, "os.nim");
		nimln(898, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IWGRP) == ((NI32) 0)))) goto LA25;
		nimln(898, "os.nim");
		result |=((NI16)(1)<<((((NU8) 4))%(sizeof(NI16)*8)));
	}
	LA25: ;
	nimln(899, "os.nim");
	{
		nimln(899, "os.nim");
		nimln(899, "os.nim");
		nimln(899, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IXGRP) == ((NI32) 0)))) goto LA29;
		nimln(899, "os.nim");
		result |=((NI16)(1)<<((((NU8) 3))%(sizeof(NI16)*8)));
	}
	LA29: ;
	nimln(901, "os.nim");
	{
		nimln(901, "os.nim");
		nimln(901, "os.nim");
		nimln(901, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IROTH) == ((NI32) 0)))) goto LA33;
		nimln(901, "os.nim");
		result |=((NI16)(1)<<((((NU8) 8))%(sizeof(NI16)*8)));
	}
	LA33: ;
	nimln(902, "os.nim");
	{
		nimln(902, "os.nim");
		nimln(902, "os.nim");
		nimln(902, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IWOTH) == ((NI32) 0)))) goto LA37;
		nimln(902, "os.nim");
		result |=((NI16)(1)<<((((NU8) 7))%(sizeof(NI16)*8)));
	}
	LA37: ;
	nimln(903, "os.nim");
	{
		nimln(903, "os.nim");
		nimln(903, "os.nim");
		nimln(903, "os.nim");
		if (!!(((NI32)(a.st_mode & S_IXOTH) == ((NI32) 0)))) goto LA41;
		nimln(903, "os.nim");
		result |=((NI16)(1)<<((((NU8) 6))%(sizeof(NI16)*8)));
	}
	LA41: ;
	popFrame();
	return result;
}

N_NIMCALL(void, nosinclFilePermissions)(NimStringDesc* filename, NU16 permissions) {
	NU16 LOC1;
	nimfr("inclFilePermissions", "os.nim")
	nimln(1533, "os.nim");
	nimln(1533, "os.nim");
	nimln(1533, "os.nim");
	LOC1 = nosgetFilePermissions(filename);
	nossetFilePermissions(filename, (LOC1 | permissions));
	popFrame();
}

N_NIMCALL(NIM_BOOL, nossameFileContent)(NimStringDesc* path1, NimStringDesc* path2) {
	NIM_BOOL result;
	FILE* a;
	FILE* b;
	void* bufa;
	void* bufb;
	nimfr("sameFileContent", "os.nim")
	result = 0;
	a = 0;
	b = 0;
	nimln(849, "os.nim");
	{
		NIM_BOOL LOC3;
		nimln(849, "os.nim");
		nimln(849, "os.nim");
		LOC3 = 0;
		LOC3 = open_10203(&a, path1, ((NU8) 0), -1);
		if (!!(LOC3)) goto LA4;
		nimln(849, "os.nim");
		nimln(849, "os.nim");
		result = NIM_FALSE;
		goto BeforeRet;
	}
	LA4: ;
	nimln(850, "os.nim");
	{
		NIM_BOOL LOC8;
		nimln(850, "os.nim");
		nimln(850, "os.nim");
		LOC8 = 0;
		LOC8 = open_10203(&b, path2, ((NU8) 0), -1);
		if (!!(LOC8)) goto LA9;
		nimln(851, "os.nim");
		fclose(a);
		nimln(852, "os.nim");
		nimln(852, "os.nim");
		result = NIM_FALSE;
		goto BeforeRet;
	}
	LA9: ;
	nimln(853, "os.nim");
	bufa = alloc_4601(8192);
	nimln(854, "os.nim");
	bufb = alloc_4601(8192);
	nimln(855, "os.nim");
	while (1) {
		NI reada;
		NI readb;
		nimln(856, "os.nim");
		reada = readbuffer_10627(a, bufa, 8192);
		nimln(857, "os.nim");
		readb = readbuffer_10627(b, bufb, 8192);
		nimln(858, "os.nim");
		{
			nimln(858, "os.nim");
			nimln(858, "os.nim");
			if (!!((reada == readb))) goto LA14;
			nimln(859, "os.nim");
			result = NIM_FALSE;
			nimln(860, "os.nim");
			goto LA11;
		}
		LA14: ;
		nimln(861, "os.nim");
		{
			nimln(861, "os.nim");
			if (!(reada == 0)) goto LA18;
			nimln(862, "os.nim");
			result = NIM_TRUE;
			nimln(863, "os.nim");
			goto LA11;
		}
		LA18: ;
		nimln(864, "os.nim");
		result = equalMem(bufa, bufb, reada);
		nimln(865, "os.nim");
		{
			nimln(865, "os.nim");
			if (!!(result)) goto LA22;
			nimln(865, "os.nim");
			goto LA11;
		}
		LA22: ;
		nimln(866, "os.nim");
		{
			nimln(866, "os.nim");
			nimln(866, "os.nim");
			if (!!((reada == 8192))) goto LA26;
			nimln(866, "os.nim");
			goto LA11;
		}
		LA26: ;
	} LA11: ;
	nimln(867, "os.nim");
	dealloc_4645(bufa);
	nimln(868, "os.nim");
	dealloc_4645(bufb);
	nimln(869, "os.nim");
	fclose(a);
	nimln(870, "os.nim");
	fclose(b);
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(void, nossplitPath)(NimStringDesc* path, TY93105* Result) {
	NI seppos;
	NI i_107505;
	NI HEX3Atmp_107520;
	NI TMP476;
	NI res_107522;
	nimfr("splitPath", "os.nim")
	nimln(574, "os.nim");
	seppos = -1;
	i_107505 = 0;
	HEX3Atmp_107520 = 0;
	nimln(575, "os.nim");
	nimln(575, "os.nim");
	nimln(575, "os.nim");
	TMP476 = subInt(path->Sup.len, 1);
	HEX3Atmp_107520 = (NI32)(TMP476);
	nimln(1442, "system.nim");
	res_107522 = HEX3Atmp_107520;
	nimln(1443, "system.nim");
	while (1) {
		nimln(1443, "system.nim");
		if (!(0 <= res_107522)) goto LA1;
		nimln(1442, "system.nim");
		i_107505 = res_107522;
		nimln(576, "os.nim");
		{
			nimln(576, "os.nim");
			if ((NU)(i_107505) > (NU)(path->Sup.len)) raiseIndexError();
			if (!(((NU8)(path->data[i_107505])) == ((NU8)(47)) || ((NU8)(path->data[i_107505])) == ((NU8)(47)))) goto LA4;
			nimln(577, "os.nim");
			seppos = i_107505;
			nimln(578, "os.nim");
			goto LA1;
		}
		LA4: ;
		nimln(1445, "system.nim");
		res_107522 = subInt(res_107522, 1);
	} LA1: ;
	nimln(579, "os.nim");
	{
		NI TMP477;
		NI TMP478;
		nimln(579, "os.nim");
		if (!(0 <= seppos)) goto LA8;
		nimln(580, "os.nim");
		nimln(580, "os.nim");
		nimln(580, "os.nim");
		TMP477 = subInt(seppos, 1);
		unsureAsgnRef((void**) &(*Result).Field0, copyStrLast(path, 0, (NI32)(TMP477)));
		nimln(581, "os.nim");
		nimln(581, "os.nim");
		nimln(581, "os.nim");
		TMP478 = addInt(seppos, 1);
		unsureAsgnRef((void**) &(*Result).Field1, copyStr(path, (NI32)(TMP478)));
	}
	goto LA6;
	LA8: ;
	{
		nimln(583, "os.nim");
		unsureAsgnRef((void**) &(*Result).Field0, copyString(((NimStringDesc*) &TMP291)));
		nimln(584, "os.nim");
		unsureAsgnRef((void**) &(*Result).Field1, copyString(path));
	}
	LA6: ;
	popFrame();
}

static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b) {
	NIM_BOOL result;
	NIM_BOOL LOC11;
	int LOC13;
	result = 0;
	{
		if (!(a == b)) goto LA3;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = (a == NIM_NIL);
		if (LOC7) goto LA8;
		LOC7 = (b == NIM_NIL);
		LA8: ;
		if (!LOC7) goto LA9;
		result = NIM_FALSE;
		goto BeforeRet;
	}
	LA9: ;
	LOC11 = 0;
	LOC11 = ((*a).Sup.len == (*b).Sup.len);
	if (!(LOC11)) goto LA12;
	LOC13 = 0;
	LOC13 = memcmp(((NCSTRING) ((*a).data)), ((NCSTRING) ((*b).data)), (NI32)((*a).Sup.len * 1));
	LOC11 = (LOC13 == ((NI32) 0));
	LA12: ;
	result = LOC11;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, rawremovedir_111390)(NimStringDesc* dir) {
	nimfr("rawRemoveDir", "os.nim")
	nimln(1316, "os.nim");
	{
		NIM_BOOL LOC3;
		int LOC4;
		NI32 LOC8;
		nimln(1316, "os.nim");
		LOC3 = 0;
		nimln(1316, "os.nim");
		nimln(1316, "os.nim");
		nimln(1316, "os.nim");
		LOC4 = 0;
		LOC4 = rmdir(dir->data);
		LOC3 = !((LOC4 == ((NI32) 0)));
		if (!(LOC3)) goto LA5;
		nimln(1316, "os.nim");
		nimln(1316, "os.nim");
		LOC3 = !((errno == ENOENT));
		LA5: ;
		if (!LOC3) goto LA6;
		nimln(1316, "os.nim");
		nimln(1316, "os.nim");
		LOC8 = 0;
		LOC8 = oslasterror_105231();
		oserror_105205(LOC8);
	}
	LA6: ;
	popFrame();
}

N_NIMCALL(void, nosremoveDir)(NimStringDesc* dir) {
	NU8 kind_111406;
	NimStringDesc* path_111407;
	DIR* d_111409;
	nimfr("removeDir", "os.nim")
	kind_111406 = 0;
	path_111407 = 0;
	nimln(1262, "os.nim");
	d_111409 = opendir(dir->data);
	nimln(1263, "os.nim");
	{
		int LOC33;
		nimln(1263, "os.nim");
		nimln(1263, "os.nim");
		if (!!((d_111409 == NIM_NIL))) goto LA3;
		nimln(1264, "os.nim");
		while (1) {
			struct dirent* x_111411;
			NimStringDesc* y_111413;
			nimln(1265, "os.nim");
			x_111411 = readdir(d_111409);
			nimln(1266, "os.nim");
			{
				nimln(1266, "os.nim");
				if (!(x_111411 == NIM_NIL)) goto LA8;
				nimln(1266, "os.nim");
				goto LA5;
			}
			LA8: ;
			nimln(1267, "os.nim");
			nimln(1267, "os.nim");
			y_111413 = cstrToNimstr(((NCSTRING) ((*x_111411).d_name)));
			nimln(1268, "os.nim");
			{
				NIM_BOOL LOC12;
				struct stat s_111415;
				NU8 k_111417;
				nimln(1268, "os.nim");
				LOC12 = 0;
				nimln(1268, "os.nim");
				nimln(1268, "os.nim");
				LOC12 = !(eqStrings(y_111413, ((NimStringDesc*) &TMP484)));
				if (!(LOC12)) goto LA13;
				nimln(1268, "os.nim");
				nimln(1268, "os.nim");
				LOC12 = !(eqStrings(y_111413, ((NimStringDesc*) &TMP485)));
				LA13: ;
				if (!LOC12) goto LA14;
				memset((void*)&s_111415, 0, sizeof(s_111415));
				nimln(1270, "os.nim");
				y_111413 = HEX2F_107477(dir, y_111413);
				nimln(1271, "os.nim");
				{
					int LOC18;
					nimln(1271, "os.nim");
					nimln(1271, "os.nim");
					LOC18 = 0;
					LOC18 = lstat(y_111413->data, &s_111415);
					if (!(LOC18 < ((NI32) 0))) goto LA19;
					nimln(1271, "os.nim");
					goto LA5;
				}
				LA19: ;
				nimln(1272, "os.nim");
				k_111417 = ((NU8) 0);
				nimln(1273, "os.nim");
				{
					NIM_BOOL LOC23;
					nimln(1273, "os.nim");
					LOC23 = 0;
					LOC23 = S_ISDIR(s_111415.st_mode);
					if (!LOC23) goto LA24;
					nimln(1273, "os.nim");
					k_111417 = ((NU8) 2);
				}
				LA24: ;
				nimln(1274, "os.nim");
				{
					NIM_BOOL LOC28;
					nimln(1274, "os.nim");
					LOC28 = 0;
					LOC28 = S_ISLNK(s_111415.st_mode);
					if (!LOC28) goto LA29;
					nimln(1274, "os.nim");
					nimln(1274, "os.nim");
					k_111417 = addInt(k_111417, 1);
				}
				LA29: ;
				nimln(1272, "os.nim");
				kind_111406 = k_111417;
				nimln(1267, "os.nim");
				path_111407 = y_111413;
				nimln(1326, "os.nim");
				switch (kind_111406) {
				case ((NU8) 0):
				case ((NU8) 1):
				case ((NU8) 3):
				{
					nimln(1327, "os.nim");
					nosremoveFile(path_111407);
				}
				break;
				case ((NU8) 2):
				{
					nimln(1328, "os.nim");
					nosremoveDir(path_111407);
				}
				break;
				}
			}
			LA14: ;
		} LA5: ;
		nimln(1276, "os.nim");
		nimln(1276, "os.nim");
		LOC33 = 0;
		LOC33 = closedir(d_111409);
	}
	LA3: ;
	nimln(1329, "os.nim");
	rawremovedir_111390(dir);
	popFrame();
}

N_NIMCALL(NimStringDesc*, nosgetCurrentDir)(void) {
	NimStringDesc* result;
	nimfr("getCurrentDir", "os.nim")
	result = 0;
	nimln(484, "os.nim");
	nimln(484, "os.nim");
	result = mnewString(512);
	nimln(485, "os.nim");
	{
		NCSTRING LOC3;
		NI LOC6;
		nimln(485, "os.nim");
		nimln(485, "os.nim");
		nimln(485, "os.nim");
		LOC3 = 0;
		LOC3 = getcwd(result->data, 512);
		if (!!((LOC3 == NIM_NIL))) goto LA4;
		nimln(486, "os.nim");
		nimln(486, "os.nim");
		LOC6 = 0;
		LOC6 = strlen(result->data);
		result = setLengthStr(result, LOC6);
	}
	goto LA1;
	LA4: ;
	{
		NI32 LOC8;
		nimln(488, "os.nim");
		nimln(488, "os.nim");
		LOC8 = 0;
		LOC8 = oslasterror_105231();
		oserror_105205(LOC8);
	}
	LA1: ;
	popFrame();
	return result;
}
N_NOINLINE(void, stdlibosInit)(void) {
	nimfr("os", "os.nim")
	popFrame();
}

N_NOINLINE(void, stdlibosDatInit)(void) {
}

