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

#include <string.h>

#include <sys/types.h>

#include <unistd.h>

#include <spawn.h>

#include <signal.h>

#include <setjmp.h>

#include <errno.h>

#include <fcntl.h>

#include <stdio.h>

#include <sys/wait.h>

#include <sys/select.h>
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tprocess126203 tprocess126203;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tstream123829 tstream123829;
typedef struct TY127203 TY127203;
typedef struct tcell41290 tcell41290;
typedef struct tcellset41302 tcellset41302;
typedef struct tgcheap43216 tgcheap43216;
typedef struct tcellseq41306 tcellseq41306;
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 tstringtable121810 tstringtable121810;
typedef struct tkeyvaluepairseq121808 tkeyvaluepairseq121808;
typedef struct TY93105 TY93105;
typedef struct TY10665 TY10665;
typedef struct tstartprocessdata127715 tstartprocessdata127715;
typedef struct E_Base E_Base;
typedef struct TSafePoint TSafePoint;
typedef struct tfilestream124356 tfilestream124356;
typedef struct TY129808 TY129808;
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 NU8 TY89161[32];
typedef NimStringDesc* TY126462[1];
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  tprocess126203  {
  TNimObject Sup;
int Inhandle;
int Outhandle;
int Errhandle;
tstream123829* Instream;
tstream123829* Outstream;
tstream123829* Errstream;
pid_t Id;
int Exitcode;
};
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 TY93105 {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
struct  tstringtable121810  {
  TNimObject Sup;
NI Counter;
tkeyvaluepairseq121808* Data;
NU8 Mode;
};
typedef int TY127720[2];
struct  tstartprocessdata127715  {
NCSTRING Syscommand;
NCSTRING* Sysargs;
NCSTRING* Sysenv;
NCSTRING Workingdir;
TY127720 Pstdin;
TY127720 Pstdout;
TY127720 Pstderr;
TY127720 Perrorpipe;
NIM_BOOL Optionpousepath;
NIM_BOOL Optionpoparentstreams;
NIM_BOOL Optionpostderrtostdout;
};
struct  E_Base  {
  TNimObject Sup;
E_Base* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
typedef struct {
N_NIMCALL_PTR(NIM_BOOL, ClPrc) (E_Base* e, void* ClEnv);
void* ClEnv;
} TY11626;
struct  TSafePoint  {
TSafePoint* prev;
NI status;
jmp_buf context;
NIM_BOOL hasRaiseAction;
TY11626 raiseAction;
};
typedef NimStringDesc* TY127892[3];
typedef NimStringDesc* TY128024[1];
struct TY129808 {
NimStringDesc* Field0;
NI Field1;
};
typedef N_NIMCALL_PTR(void, TY123830) (tstream123829* s);
typedef N_NIMCALL_PTR(NIM_BOOL, TY123834) (tstream123829* s);
typedef N_NIMCALL_PTR(void, TY123838) (tstream123829* s, NI pos);
typedef N_NIMCALL_PTR(NI, TY123843) (tstream123829* s);
typedef N_NIMCALL_PTR(NI, TY123847) (tstream123829* s, void* buffer, NI buflen);
typedef N_NIMCALL_PTR(void, TY123853) (tstream123829* s, void* buffer, NI buflen);
typedef N_NIMCALL_PTR(void, TY123859) (tstream123829* s);
struct  tstream123829  {
  TNimObject Sup;
TY123830 Closeimpl;
TY123834 Atendimpl;
TY123838 Setpositionimpl;
TY123843 Getpositionimpl;
TY123847 Readdataimpl;
TY123853 Writedataimpl;
TY123859 Flushimpl;
};
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  tfilestream124356  {
  tstream123829 Sup;
FILE* F;
};
struct  tfreecell22828  {
tfreecell22828* Next;
NI Zerofield;
};
struct TY127203 {
  TGenericSeq Sup;
  tprocess126203* data[SEQ_DECL_SIZE];
};
struct tkeyvaluepairseq121808 {
  TGenericSeq Sup;
  TY93105 data[SEQ_DECL_SIZE];
};
struct TY10665 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
N_NIMCALL(NimStringDesc*, nospquoteShellWindows)(NimStringDesc* s);
N_NIMCALL(NIM_BOOL, contains_89258)(NimStringDesc* s, TY89161 chars);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_NOINLINE(void, raiseIndexError)(void);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newlen);
static N_INLINE(NI, addInt)(NI a, NI b);
N_NOINLINE(void, raiseOverflow)(void);
N_NIMCALL(void, failedassertimpl_79821)(NimStringDesc* msg);
static N_INLINE(void, nimFrame)(TFrame* s);
static N_INLINE(void, popFrame)(void);
N_NIMCALL(NimStringDesc*, nospquoteShellPosix)(NimStringDesc* s);
N_NIMCALL(NIM_BOOL, allcharsinset_88836)(NimStringDesc* s, TY89161 theset);
N_NIMCALL(NimStringDesc*, nsuReplaceStr)(NimStringDesc* s, NimStringDesc* sub, NimStringDesc* by);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(NimStringDesc*, nospquoteShell)(NimStringDesc* s);
N_NIMCALL(tprocess126203*, startcmd_126434)(NimStringDesc* command, NU8 options);
N_NIMCALL(NI, nospprocessID)(tprocess126203* p);
N_NIMCALL(int, nospinputHandle)(tprocess126203* p);
N_NIMCALL(int, nospoutputHandle)(tprocess126203* p);
N_NIMCALL(int, nosperrorHandle)(tprocess126203* p);
N_NIMCALL(NI, nospcountProcessors)(void);
N_NIMCALL(NI, nospexecProcesses)(NimStringDesc** cmds, NI cmdsLen0, NU8 options_126808, NI n);
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP348)(void* p, NI op);
N_NIMCALL(void, TMP349)(void* p, NI op);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
static N_INLINE(NI, subInt)(NI a, NI b);
static N_INLINE(void, asgnRef)(void** dest, void* src);
static N_INLINE(void, incref_47027)(tcell41290* c);
static N_INLINE(NIM_BOOL, canbecycleroot_44662)(tcell41290* c);
static N_INLINE(void, rtladdcycleroot_45435)(tcell41290* c);
N_NOINLINE(void, incl_42055)(tcellset41302* s, tcell41290* cell);
static N_INLINE(tcell41290*, usrtocell_44643)(void* usr);
static N_INLINE(void, decref_46602)(tcell41290* c);
static N_INLINE(void, rtladdzct_46202)(tcell41290* c);
N_NOINLINE(void, addzct_44618)(tcellseq41306* s, tcell41290* c);
N_NIMCALL(void, nossleep)(NI milsecs);
N_NIMCALL(NimStringDesc*, nospexecProcess)(NimStringDesc* command, NimStringDesc** args, NI argsLen0, tstringtable121810* env, NU8 options);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_NIMCALL(NIM_BOOL, readline_124204)(tstream123829* s, NimStringDesc** line);
N_NIMCALL(NCSTRING*, envtocstringarray_127604)(tstringtable121810* t);
N_NOCONV(void*, alloc0_4616)(NI size);
N_NIMCALL(NI, nstlen)(tstringtable121810* t);
N_NIMCALL(NI, mulInt)(NI a, NI b);
N_NOCONV(void*, alloc_4601)(NI size);
N_NIMCALL(NCSTRING*, envtocstringarray_127641)(void);
N_NIMCALL(void, getenvvarsc_110002)(void);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_70824, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(pid_t, startprocessauxspawn_127801)(tstartprocessdata127715* data);
N_NIMCALL(void, oserror_105205)(NI32 errorcode);
N_NIMCALL(NI32, oslasterror_105231)(void);
static N_INLINE(void, setcurrentdir_107203)(NimStringDesc* newdir);
N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
N_NIMCALL(pid_t, startprocessauxfork_127804)(tstartprocessdata127715* data);
static N_INLINE(void, pushSafePoint)(TSafePoint* s);
N_CDECL(void, startprocessafterfork_127807)(tstartprocessdata127715* data);
N_NIMCALL(void, startprocessfail_128623)(tstartprocessdata127715* data);
N_NOINLINE(void, nososError)(NimStringDesc* msg);
static N_INLINE(void, popSafePoint)(void);
static N_INLINE(void, setFrame)(TFrame* s);
N_NIMCALL(void, reraiseException)(void);
N_NIMCALL(tprocess126203*, nospstartProcess)(NimStringDesc* command, NimStringDesc* workingdir, NimStringDesc** args, NI argsLen0, tstringtable121810* env, NU8 options);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(NCSTRING*, alloccstringarray_10801)(NimStringDesc** a, NI aLen0);
N_NIMCALL(NimStringDesc*, nsuJoinSep)(NimStringDesc** a, NI aLen0, NimStringDesc* sep);
N_NIMCALL(void, dealloccstringarray_10842)(NCSTRING* a);
N_NIMCALL(void, nospclose)(tprocess126203* p);
N_NIMCALL(void, close_123876)(tstream123829* s);
N_NIMCALL(void, nospsuspend)(tprocess126203* p);
N_NIMCALL(void, nospresume)(tprocess126203* p);
N_NIMCALL(NIM_BOOL, nosprunning)(tprocess126203* p);
N_NIMCALL(void, nospterminate)(tprocess126203* p);
N_NIMCALL(NI, nospwaitForExit)(tprocess126203* p, NI timeout);
N_NIMCALL(NI, peekexitcode_126496)(tprocess126203* p);
N_NIMCALL(void, createstream_129117)(tstream123829** stream, NI32* handle, NU8 filemode);
N_NIMCALL(NIM_BOOL, open_10211)(FILE** f, int filehandle, NU8 mode);
N_NIMCALL(tfilestream124356*, newfilestream_124411)(FILE* f);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_NIMCALL(tstream123829*, nospinputStream)(tprocess126203* p);
N_NIMCALL(tstream123829*, nospoutputStream)(tprocess126203* p);
N_NIMCALL(tstream123829*, nosperrorStream)(tprocess126203* p);
N_NIMCALL(NI, nospexecCmd)(NimStringDesc* command);
N_NIMCALL(void, createfdset_129402)(fd_set* fd, TY127203* s, NI* m);
N_NIMCALL(void, pruneprocessset_129634)(TY127203** s, fd_set* fd);
N_NIMCALL(TGenericSeq*, setLengthSeq)(TGenericSeq* seq, NI elemsize, NI newlen);
N_NIMCALL(NI, select_127521)(TY127203** readfds, NI timeout);
N_NIMCALL(void, execcmdex_129802)(NimStringDesc* command, NU8 options, TY129808* Result);
static NIM_CONST TY89161 TMP325 = {
0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
;
STRING_LITERAL(TMP326, "", 0);
STRING_LITERAL(TMP327, "\"", 1);
STRING_LITERAL(TMP328, "\\\"", 2);
STRING_LITERAL(TMP329, "len(a) == L string modified while iterating over it", 51);
NIM_CONST TY89161 safeunixchars_126243 = {
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(TMP330, "\'\'", 2);
static NIM_CONST TY89161 TMP332 = {
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(TMP333, "\'", 1);
STRING_LITERAL(TMP344, "\'\"\'\"\'", 5);
STRING_LITERAL(TMP345, "n > 0 ", 6);
STRING_LITERAL(TMP357, "", 0);
STRING_LITERAL(TMP358, "\012", 1);
STRING_LITERAL(TMP361, "=", 1);
STRING_LITERAL(TMP375, "/bin/sh", 7);
STRING_LITERAL(TMP376, "-c", 2);
STRING_LITERAL(TMP377, "args.len == 0 `args` has to be empty when using poEvalCommand.", 62);
STRING_LITERAL(TMP380, " ", 1);
STRING_LITERAL(TMP383, "(len|len|len|len|len)(a) (==|==|==|==|==|==|==|==|==|==|==|==|="
"=|==|==|==|==|==|==|==)\012    L seq modified while iterating over "
"it", 129);
NIM_CONST TY129808 TMP388 = {((NimStringDesc*) &TMP357),
-1}
;
extern TFrame* frameptr_13038;
extern TNimType NTI2409; /* TObject */
TNimType NTI126203; /* TProcess */
extern TNimType NTI10008; /* TFileHandle */
extern TNimType NTI123827; /* PStream */
extern TNimType NTI96457; /* TPid */
extern TNimType NTI4409; /* cint */
TNimType NTI126205; /* PProcess */
TNimType NTI127203; /* seq[PProcess] */
extern tgcheap43216 gch_43244;
extern TY10665* environment_109806;
extern TSafePoint* exchandler_13039;
extern TNimType NTI10665; /* seq[string] */

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

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

N_NIMCALL(NimStringDesc*, nospquoteShellWindows)(NimStringDesc* s) {
	NimStringDesc* result;
	NIM_BOOL needquote;
	NIM_BOOL LOC1;
	NimStringDesc* backslashbuff;
	NIM_CHAR c_126231;
	NI i_126233;
	NI l_126235;
	nimfr("quoteShellWindows", "osproc.nim")
	result = 0;
	nimln(57, "osproc.nim");
	nimln(57, "osproc.nim");
	LOC1 = 0;
	nimln(57, "osproc.nim");
	LOC1 = contains_89258(s, TMP325);
	if (LOC1) goto LA2;
	nimln(57, "osproc.nim");
	nimln(57, "osproc.nim");
	LOC1 = (s->Sup.len == 0);
	LA2: ;
	needquote = LOC1;
	nimln(59, "osproc.nim");
	result = copyString(((NimStringDesc*) &TMP326));
	nimln(60, "osproc.nim");
	backslashbuff = copyString(((NimStringDesc*) &TMP326));
	nimln(61, "osproc.nim");
	{
		if (!needquote) goto LA5;
		nimln(62, "osproc.nim");
		result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TMP327));
	}
	LA5: ;
	c_126231 = 0;
	nimln(2805, "system.nim");
	i_126233 = 0;
	nimln(2806, "system.nim");
	nimln(2806, "system.nim");
	l_126235 = s->Sup.len;
	nimln(2807, "system.nim");
	while (1) {
		nimln(2807, "system.nim");
		if (!(i_126233 < l_126235)) goto LA7;
		nimln(2808, "system.nim");
		if ((NU)(i_126233) > (NU)(s->Sup.len)) raiseIndexError();
		c_126231 = s->data[i_126233];
		nimln(65, "osproc.nim");
		{
			nimln(65, "osproc.nim");
			if (!((NU8)(c_126231) == (NU8)(92))) goto LA10;
			nimln(66, "osproc.nim");
			backslashbuff = addChar(backslashbuff, c_126231);
		}
		goto LA8;
		LA10: ;
		{
			nimln(67, "osproc.nim");
			if (!((NU8)(c_126231) == (NU8)(34))) goto LA13;
			nimln(68, "osproc.nim");
			result = resizeString(result, backslashbuff->Sup.len + 0);
appendString(result, backslashbuff);
			nimln(69, "osproc.nim");
			result = resizeString(result, backslashbuff->Sup.len + 0);
appendString(result, backslashbuff);
			nimln(70, "osproc.nim");
			backslashbuff = setLengthStr(backslashbuff, 0);
			nimln(71, "osproc.nim");
			result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP328));
		}
		goto LA8;
		LA13: ;
		{
			nimln(73, "osproc.nim");
			{
				nimln(73, "osproc.nim");
				nimln(73, "osproc.nim");
				nimln(73, "osproc.nim");
				if (!!((backslashbuff->Sup.len == 0))) goto LA18;
				nimln(74, "osproc.nim");
				result = resizeString(result, backslashbuff->Sup.len + 0);
appendString(result, backslashbuff);
				nimln(75, "osproc.nim");
				backslashbuff = setLengthStr(backslashbuff, 0);
			}
			LA18: ;
			nimln(76, "osproc.nim");
			result = addChar(result, c_126231);
		}
		LA8: ;
		nimln(2809, "system.nim");
		i_126233 = addInt(i_126233, 1);
		nimln(2810, "system.nim");
		{
			nimln(2810, "system.nim");
			nimln(2810, "system.nim");
			nimln(2810, "system.nim");
			if (!!((s->Sup.len == l_126235))) goto LA22;
			nimln(2810, "system.nim");
			failedassertimpl_79821(((NimStringDesc*) &TMP329));
		}
		LA22: ;
	} LA7: ;
	nimln(78, "osproc.nim");
	{
		if (!needquote) goto LA26;
		nimln(79, "osproc.nim");
		result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TMP327));
	}
	LA26: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, nospquoteShellPosix)(NimStringDesc* s) {
	NimStringDesc* result;
	NIM_BOOL safe;
	nimfr("quoteShellPosix", "osproc.nim")
	result = 0;
	nimln(86, "osproc.nim");
	{
		nimln(86, "osproc.nim");
		nimln(86, "osproc.nim");
		if (!(s->Sup.len == 0)) goto LA3;
		nimln(87, "osproc.nim");
		nimln(87, "osproc.nim");
		result = copyString(((NimStringDesc*) &TMP330));
		goto BeforeRet;
	}
	LA3: ;
	nimln(89, "osproc.nim");
	safe = allcharsinset_88836(s, TMP332);
	nimln(91, "osproc.nim");
	{
		if (!safe) goto LA7;
		nimln(92, "osproc.nim");
		nimln(92, "osproc.nim");
		result = copyString(s);
		goto BeforeRet;
	}
	goto LA5;
	LA7: ;
	{
		NimStringDesc* LOC10;
		NimStringDesc* LOC11;
		nimln(94, "osproc.nim");
		nimln(94, "osproc.nim");
		nimln(94, "osproc.nim");
		LOC10 = 0;
		nimln(94, "osproc.nim");
		LOC11 = 0;
		LOC11 = nsuReplaceStr(s, ((NimStringDesc*) &TMP333), ((NimStringDesc*) &TMP344));
		LOC10 = rawNewString(LOC11->Sup.len + 2);
appendString(LOC10, ((NimStringDesc*) &TMP333));
appendString(LOC10, LOC11);
appendString(LOC10, ((NimStringDesc*) &TMP333));
		result = LOC10;
		goto BeforeRet;
	}
	LA5: ;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, nospquoteShell)(NimStringDesc* s) {
	NimStringDesc* result;
	nimfr("quoteShell", "osproc.nim")
	result = 0;
	nimln(101, "osproc.nim");
	nimln(101, "osproc.nim");
	result = nospquoteShellPosix(s);
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(tprocess126203*, startcmd_126434)(NimStringDesc* command, NU8 options) {
	tprocess126203* result;
	TY126462 LOC1;
	nimfr("startCmd", "osproc.nim")
	result = 0;
	nimln(155, "osproc.nim");
	memset((void*)LOC1, 0, sizeof(LOC1));
	nimln(155, "osproc.nim");
	result = nospstartProcess(command, ((NimStringDesc*) &TMP326), LOC1, 0, NIM_NIL, (options | 4));
	popFrame();
	return result;
}

N_NIMCALL(NI, nospprocessID)(tprocess126203* p) {
	NI result;
	nimfr("processID", "osproc.nim")
	result = 0;
	nimln(174, "osproc.nim");
	nimln(174, "osproc.nim");
	result = (*p).Id;
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(int, nospinputHandle)(tprocess126203* p) {
	int result;
	nimfr("inputHandle", "osproc.nim")
	result = 0;
	nimln(210, "osproc.nim");
	result = (*p).Inhandle;
	popFrame();
	return result;
}

N_NIMCALL(int, nospoutputHandle)(tprocess126203* p) {
	int result;
	nimfr("outputHandle", "osproc.nim")
	result = 0;
	nimln(218, "osproc.nim");
	result = (*p).Outhandle;
	popFrame();
	return result;
}

N_NIMCALL(int, nosperrorHandle)(tprocess126203* p) {
	int result;
	nimfr("errorHandle", "osproc.nim")
	result = 0;
	nimln(226, "osproc.nim");
	result = (*p).Errhandle;
	popFrame();
	return result;
}

N_NIMCALL(NI, nospcountProcessors)(void) {
	NI result;
	nimfr("countProcessors", "osproc.nim")
	result = 0;
	nimln(262, "osproc.nim");
	result = sysconf(_SC_NPROCESSORS_ONLN);
	nimln(263, "osproc.nim");
	{
		nimln(263, "osproc.nim");
		if (!(result <= 0)) goto LA3;
		nimln(263, "osproc.nim");
		result = 1;
	}
	LA3: ;
	popFrame();
	return result;
}
N_NIMCALL(void, TMP348)(void* p, NI op) {
	tprocess126203* a;
	a = (tprocess126203*)p;
	nimGCvisit((void*)(*a).Instream, op);
	nimGCvisit((void*)(*a).Outstream, op);
	nimGCvisit((void*)(*a).Errstream, op);
}
N_NIMCALL(void, TMP349)(void* p, NI op) {
	TY127203* a;
	NI LOC1;
	a = (TY127203*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1], op);
	}
}

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(NIM_BOOL, canbecycleroot_44662)(tcell41290* c) {
	NIM_BOOL result;
	nimfr("canbeCycleRoot", "gc.nim")
	result = 0;
	nimln(121, "gc.nim");
	nimln(121, "gc.nim");
	nimln(121, "gc.nim");
	result = !((((*(*c).Typ).flags &(1<<((((NU8) 1))&7)))!=0));
	popFrame();
	return result;
}

static N_INLINE(void, rtladdcycleroot_45435)(tcell41290* c) {
	nimfr("rtlAddCycleRoot", "gc.nim")
	nimln(189, "gc.nim");
	{
		nimln(189, "gc.nim");
		nimln(189, "gc.nim");
		nimln(189, "gc.nim");
		if (!!((((NI) ((NI)((*c).Refcount & 3))) == 3))) goto LA3;
		nimln(139, "gc.nim");
		nimln(139, "gc.nim");
		nimln(139, "gc.nim");
		(*c).Refcount = (NI)((NI)((*c).Refcount & -4) | 3);
		nimln(191, "gc.nim");
		incl_42055(&gch_43244.Cycleroots, c);
	}
	LA3: ;
	popFrame();
}

static N_INLINE(void, incref_47027)(tcell41290* c) {
	nimfr("incRef", "gc.nim")
	nimln(216, "gc.nim");
	nimln(216, "gc.nim");
	(*c).Refcount = (NI)((NU32)((*c).Refcount) + (NU32)(8));
	nimln(219, "gc.nim");
	{
		NIM_BOOL LOC3;
		nimln(219, "gc.nim");
		LOC3 = 0;
		LOC3 = canbecycleroot_44662(c);
		if (!LOC3) goto LA4;
		nimln(220, "gc.nim");
		rtladdcycleroot_45435(c);
	}
	LA4: ;
	popFrame();
}

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, decref_46602)(tcell41290* c) {
	nimfr("decRef", "gc.nim")
	nimln(206, "gc.nim");
	{
		nimln(167, "gc.nim");
		(*c).Refcount -= 8;
		nimln(168, "gc.nim");
		if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA3;
		nimln(207, "gc.nim");
		rtladdzct_46202(c);
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC6;
		nimln(208, "gc.nim");
		LOC6 = 0;
		LOC6 = canbecycleroot_44662(c);
		if (!LOC6) goto LA7;
		nimln(211, "gc.nim");
		rtladdcycleroot_45435(c);
	}
	goto LA1;
	LA7: ;
	LA1: ;
	popFrame();
}

static N_INLINE(void, asgnRef)(void** dest, void* src) {
	nimfr("asgnRef", "gc.nim")
	nimln(244, "gc.nim");
	{
		tcell41290* LOC5;
		nimln(244, "gc.nim");
		nimln(244, "gc.nim");
		if (!!((src == NIM_NIL))) goto LA3;
		nimln(244, "gc.nim");
		nimln(244, "gc.nim");
		LOC5 = 0;
		LOC5 = usrtocell_44643(src);
		incref_47027(LOC5);
	}
	LA3: ;
	nimln(245, "gc.nim");
	{
		tcell41290* LOC10;
		nimln(245, "gc.nim");
		nimln(245, "gc.nim");
		if (!!(((*dest) == NIM_NIL))) goto LA8;
		nimln(245, "gc.nim");
		nimln(245, "gc.nim");
		LOC10 = 0;
		LOC10 = usrtocell_44643((*dest));
		decref_46602(LOC10);
	}
	LA8: ;
	nimln(246, "gc.nim");
	(*dest) = src;
	popFrame();
}

N_NIMCALL(NI, nospexecProcesses)(NimStringDesc** cmds, NI cmdsLen0, NU8 options_126808, NI n) {
	NI result;
	NU8 options;
	nimfr("execProcesses", "osproc.nim")
	result = 0;
	nimln(274, "osproc.nim");
	nimln(274, "osproc.nim");
	options = (options_126808 & ~ 16);
	nimln(276, "osproc.nim");
	{
		nimln(276, "osproc.nim");
		nimln(276, "osproc.nim");
		if (!!((0 < n))) goto LA3;
		nimln(276, "osproc.nim");
		failedassertimpl_79821(((NimStringDesc*) &TMP345));
	}
	LA3: ;
	nimln(277, "osproc.nim");
	{
		TY127203* q;
		NI m;
		NI i_127242;
		NI HEX3Atmp_127498;
		NI TMP350;
		NI res_127500;
		NI i;
		NI j_127461;
		NI HEX3Atmp_127506;
		NI TMP356;
		NI res_127508;
		nimln(277, "osproc.nim");
		if (!(1 < n)) goto LA7;
		q = 0;
		nimln(279, "osproc.nim");
		q = (TY127203*) newSeq((&NTI127203), n);
		nimln(280, "osproc.nim");
		nimln(280, "osproc.nim");
		nimln(280, "osproc.nim");
		m = ((n <= cmdsLen0) ? n : cmdsLen0);
		i_127242 = 0;
		HEX3Atmp_127498 = 0;
		nimln(281, "osproc.nim");
		nimln(281, "osproc.nim");
		TMP350 = subInt(m, 1);
		HEX3Atmp_127498 = (NI32)(TMP350);
		nimln(1458, "system.nim");
		res_127500 = 0;
		nimln(1459, "system.nim");
		while (1) {
			nimln(1459, "system.nim");
			if (!(res_127500 <= HEX3Atmp_127498)) goto LA9;
			nimln(1458, "system.nim");
			i_127242 = res_127500;
			nimln(282, "osproc.nim");
			if ((NU)(i_127242) >= (NU)(q->Sup.len)) raiseIndexError();
			if ((NU)(i_127242) >= (NU)(cmdsLen0)) raiseIndexError();
			asgnRef((void**) &q->data[i_127242], startcmd_126434(cmds[i_127242], options));
			nimln(1461, "system.nim");
			res_127500 = addInt(res_127500, 1);
		} LA9: ;
		nimln(298, "osproc.nim");
		i = m;
		nimln(299, "osproc.nim");
		while (1) {
			NI r_127413;
			NI HEX3Atmp_127502;
			NI TMP355;
			NI res_127504;
			nimln(299, "osproc.nim");
			nimln(299, "osproc.nim");
			if (!(i <= (cmdsLen0-1))) goto LA10;
			nimln(300, "osproc.nim");
			nossleep(50);
			r_127413 = 0;
			HEX3Atmp_127502 = 0;
			nimln(301, "osproc.nim");
			nimln(301, "osproc.nim");
			TMP355 = subInt(n, 1);
			HEX3Atmp_127502 = (NI32)(TMP355);
			nimln(1458, "system.nim");
			res_127504 = 0;
			nimln(1459, "system.nim");
			while (1) {
				nimln(1459, "system.nim");
				if (!(res_127504 <= HEX3Atmp_127502)) goto LA11;
				nimln(1458, "system.nim");
				r_127413 = res_127504;
				nimln(302, "osproc.nim");
				{
					NIM_BOOL LOC14;
					NI LOC17;
					nimln(302, "osproc.nim");
					nimln(302, "osproc.nim");
					if ((NU)(r_127413) >= (NU)(q->Sup.len)) raiseIndexError();
					LOC14 = 0;
					LOC14 = nosprunning(q->data[r_127413]);
					if (!!(LOC14)) goto LA15;
					nimln(304, "osproc.nim");
					nimln(304, "osproc.nim");
					nimln(304, "osproc.nim");
					if ((NU)(r_127413) >= (NU)(q->Sup.len)) raiseIndexError();
					LOC17 = 0;
					LOC17 = nospwaitForExit(q->data[r_127413], -1);
					result = ((LOC17 >= result) ? LOC17 : result);
					nimln(305, "osproc.nim");
					{
						nimln(305, "osproc.nim");
						nimln(305, "osproc.nim");
						if ((NU)(r_127413) >= (NU)(q->Sup.len)) raiseIndexError();
						if (!!((q->data[r_127413] == NIM_NIL))) goto LA20;
						nimln(305, "osproc.nim");
						if ((NU)(r_127413) >= (NU)(q->Sup.len)) raiseIndexError();
						nospclose(q->data[r_127413]);
					}
					LA20: ;
					nimln(306, "osproc.nim");
					if ((NU)(r_127413) >= (NU)(q->Sup.len)) raiseIndexError();
					if ((NU)(i) >= (NU)(cmdsLen0)) raiseIndexError();
					asgnRef((void**) &q->data[r_127413], startcmd_126434(cmds[i], options));
					nimln(307, "osproc.nim");
					i = addInt(i, 1);
					nimln(308, "osproc.nim");
					{
						nimln(308, "osproc.nim");
						nimln(308, "osproc.nim");
						if (!((cmdsLen0-1) < i)) goto LA24;
						nimln(308, "osproc.nim");
						goto LA11;
					}
					LA24: ;
				}
				LA15: ;
				nimln(1461, "system.nim");
				res_127504 = addInt(res_127504, 1);
			} LA11: ;
		} LA10: ;
		j_127461 = 0;
		HEX3Atmp_127506 = 0;
		nimln(309, "osproc.nim");
		nimln(309, "osproc.nim");
		TMP356 = subInt(m, 1);
		HEX3Atmp_127506 = (NI32)(TMP356);
		nimln(1458, "system.nim");
		res_127508 = 0;
		nimln(1459, "system.nim");
		while (1) {
			NI LOC27;
			nimln(1459, "system.nim");
			if (!(res_127508 <= HEX3Atmp_127506)) goto LA26;
			nimln(1458, "system.nim");
			j_127461 = res_127508;
			nimln(310, "osproc.nim");
			nimln(310, "osproc.nim");
			nimln(310, "osproc.nim");
			if ((NU)(j_127461) >= (NU)(q->Sup.len)) raiseIndexError();
			LOC27 = 0;
			LOC27 = nospwaitForExit(q->data[j_127461], -1);
			result = ((LOC27 >= result) ? LOC27 : result);
			nimln(311, "osproc.nim");
			{
				nimln(311, "osproc.nim");
				nimln(311, "osproc.nim");
				if ((NU)(j_127461) >= (NU)(q->Sup.len)) raiseIndexError();
				if (!!((q->data[j_127461] == NIM_NIL))) goto LA30;
				nimln(311, "osproc.nim");
				if ((NU)(j_127461) >= (NU)(q->Sup.len)) raiseIndexError();
				nospclose(q->data[j_127461]);
			}
			LA30: ;
			nimln(1461, "system.nim");
			res_127508 = addInt(res_127508, 1);
		} LA26: ;
	}
	goto LA5;
	LA7: ;
	{
		NI i_127492;
		NI HEX3Atmp_127510;
		NI res_127512;
		i_127492 = 0;
		HEX3Atmp_127510 = 0;
		nimln(313, "osproc.nim");
		nimln(313, "osproc.nim");
		HEX3Atmp_127510 = (cmdsLen0-1);
		nimln(1458, "system.nim");
		res_127512 = 0;
		nimln(1459, "system.nim");
		while (1) {
			tprocess126203* p;
			NI LOC34;
			nimln(1459, "system.nim");
			if (!(res_127512 <= HEX3Atmp_127510)) goto LA33;
			nimln(1458, "system.nim");
			i_127492 = res_127512;
			nimln(314, "osproc.nim");
			if ((NU)(i_127492) >= (NU)(cmdsLen0)) raiseIndexError();
			p = startcmd_126434(cmds[i_127492], options);
			nimln(315, "osproc.nim");
			nimln(315, "osproc.nim");
			nimln(315, "osproc.nim");
			LOC34 = 0;
			LOC34 = nospwaitForExit(p, -1);
			result = ((LOC34 >= result) ? LOC34 : result);
			nimln(316, "osproc.nim");
			nospclose(p);
			nimln(1461, "system.nim");
			res_127512 = addInt(res_127512, 1);
		} LA33: ;
	}
	LA5: ;
	popFrame();
	return result;
}

N_NIMCALL(NimStringDesc*, nospexecProcess)(NimStringDesc* command, NimStringDesc** args, NI argsLen0, tstringtable121810* env, NU8 options) {
	NimStringDesc* result;
	tprocess126203* p;
	tstream123829* outp;
	NimStringDesc* line;
	nimfr("execProcess", "osproc.nim")
	result = 0;
	nimln(334, "osproc.nim");
	p = nospstartProcess(command, ((NimStringDesc*) &TMP326), args, argsLen0, env, options);
	nimln(335, "osproc.nim");
	outp = nospoutputStream(p);
	nimln(336, "osproc.nim");
	result = copyString(((NimStringDesc*) &TMP357));
	nimln(337, "osproc.nim");
	nimln(337, "osproc.nim");
	line = rawNewString(120);
	nimln(338, "osproc.nim");
	while (1) {
		nimln(340, "osproc.nim");
		{
			NIM_BOOL LOC4;
			nimln(340, "osproc.nim");
			LOC4 = 0;
			LOC4 = readline_124204(outp, &line);
			if (!LOC4) goto LA5;
			nimln(341, "osproc.nim");
			result = resizeString(result, line->Sup.len + 0);
appendString(result, line);
			nimln(342, "osproc.nim");
			result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TMP358));
		}
		goto LA2;
		LA5: ;
		{
			NIM_BOOL LOC8;
			nimln(343, "osproc.nim");
			nimln(343, "osproc.nim");
			LOC8 = 0;
			LOC8 = nosprunning(p);
			if (!!(LOC8)) goto LA9;
			nimln(343, "osproc.nim");
			goto LA1;
		}
		goto LA2;
		LA9: ;
		LA2: ;
	} LA1: ;
	nimln(344, "osproc.nim");
	nospclose(p);
	popFrame();
	return result;
}

N_NIMCALL(NCSTRING*, envtocstringarray_127604)(tstringtable121810* t) {
	NCSTRING* result;
	NI LOC1;
	NI TMP359;
	NI TMP360;
	void* LOC2;
	NI i;
	NimStringDesc* key_127610;
	NimStringDesc* val_127611;
	NI h_127634;
	NI HEX3Atmp_127636;
	NI res_127638;
	nimfr("envToCStringArray", "osproc.nim")
	result = 0;
	nimln(588, "osproc.nim");
	nimln(588, "osproc.nim");
	nimln(588, "osproc.nim");
	nimln(588, "osproc.nim");
	nimln(588, "osproc.nim");
	LOC1 = 0;
	LOC1 = nstlen(t);
	TMP359 = addInt(LOC1, 1);
	TMP360 = mulInt((NI32)(TMP359), 4);
	LOC2 = 0;
	LOC2 = alloc0_4616((NI32)(TMP360));
	result = ((NCSTRING*) (LOC2));
	nimln(589, "osproc.nim");
	i = 0;
	key_127610 = 0;
	val_127611 = 0;
	h_127634 = 0;
	HEX3Atmp_127636 = 0;
	nimln(40, "strtabs.nim");
	nimln(40, "strtabs.nim");
	HEX3Atmp_127636 = ((*t).Data->Sup.len-1);
	nimln(1458, "system.nim");
	res_127638 = 0;
	nimln(1459, "system.nim");
	while (1) {
		nimln(1459, "system.nim");
		if (!(res_127638 <= HEX3Atmp_127636)) goto LA3;
		nimln(1458, "system.nim");
		h_127634 = res_127638;
		nimln(41, "strtabs.nim");
		{
			NimStringDesc* x;
			NimStringDesc* LOC8;
			NI TMP362;
			void* LOC9;
			NI TMP363;
			nimln(41, "strtabs.nim");
			nimln(41, "strtabs.nim");
			if ((NU)(h_127634) >= (NU)((*t).Data->Sup.len)) raiseIndexError();
			if (!!((*t).Data->data[h_127634].Field0 == 0)) goto LA6;
			nimln(42, "strtabs.nim");
			if ((NU)(h_127634) >= (NU)((*t).Data->Sup.len)) raiseIndexError();
			key_127610 = (*t).Data->data[h_127634].Field0;
			nimln(42, "strtabs.nim");
			if ((NU)(h_127634) >= (NU)((*t).Data->Sup.len)) raiseIndexError();
			val_127611 = (*t).Data->data[h_127634].Field1;
			nimln(591, "osproc.nim");
			nimln(591, "osproc.nim");
			LOC8 = 0;
			LOC8 = rawNewString(key_127610->Sup.len + val_127611->Sup.len + 1);
appendString(LOC8, key_127610);
appendString(LOC8, ((NimStringDesc*) &TMP361));
appendString(LOC8, val_127611);
			x = LOC8;
			nimln(592, "osproc.nim");
			if ((NU)(i) > (NU)(50000)) raiseIndexError();
			nimln(592, "osproc.nim");
			nimln(592, "osproc.nim");
			nimln(592, "osproc.nim");
			TMP362 = addInt(x->Sup.len, 1);
			LOC9 = 0;
			LOC9 = alloc_4601((NI32)(TMP362));
			result[(i)- 0] = ((NCSTRING) (LOC9));
			nimln(593, "osproc.nim");
			if ((NU)(i) > (NU)(50000)) raiseIndexError();
			if ((NU)(0) > (NU)(x->Sup.len)) raiseIndexError();
			nimln(593, "osproc.nim");
			nimln(593, "osproc.nim");
			TMP363 = addInt(x->Sup.len, 1);
			memcpy(((void*) (result[(i)- 0])), ((void*) (&x->data[0])), (NI32)(TMP363));
			nimln(594, "osproc.nim");
			i = addInt(i, 1);
		}
		LA6: ;
		nimln(1461, "system.nim");
		res_127638 = addInt(res_127638, 1);
	} LA3: ;
	popFrame();
	return result;
}

N_NIMCALL(NCSTRING*, envtocstringarray_127641)(void) {
	NCSTRING* result;
	NI counter;
	NimStringDesc* key_127645;
	NimStringDesc* val_127646;
	NI i_127686;
	NI HEX3Atmp_127688;
	NI res_127690;
	NI TMP366;
	NI TMP367;
	void* LOC2;
	NI i;
	NimStringDesc* key_127665;
	NimStringDesc* val_127666;
	NI i_127702;
	NI HEX3Atmp_127704;
	NI res_127706;
	nimfr("envToCStringArray", "osproc.nim")
	result = 0;
	nimln(597, "osproc.nim");
	counter = 0;
	key_127645 = 0;
	val_127646 = 0;
	nimln(1180, "os.nim");
	getenvvarsc_110002();
	i_127686 = 0;
	HEX3Atmp_127688 = 0;
	nimln(1181, "os.nim");
	nimln(1181, "os.nim");
	HEX3Atmp_127688 = (environment_109806->Sup.len-1);
	nimln(1458, "system.nim");
	res_127690 = 0;
	nimln(1459, "system.nim");
	while (1) {
		NI p_127692;
		NI TMP364;
		NI TMP365;
		nimln(1459, "system.nim");
		if (!(res_127690 <= HEX3Atmp_127688)) goto LA1;
		nimln(1458, "system.nim");
		i_127686 = res_127690;
		nimln(1182, "os.nim");
		if ((NU)(i_127686) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		p_127692 = nsuFindChar(environment_109806->data[i_127686], 61, 0);
		nimln(1183, "os.nim");
		nimln(1183, "os.nim");
		if ((NU)(i_127686) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		nimln(1183, "os.nim");
		TMP364 = subInt(p_127692, 1);
		key_127645 = copyStrLast(environment_109806->data[i_127686], 0, (NI32)(TMP364));
		nimln(1184, "os.nim");
		nimln(1184, "os.nim");
		if ((NU)(i_127686) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		nimln(1184, "os.nim");
		TMP365 = addInt(p_127692, 1);
		val_127646 = copyStr(environment_109806->data[i_127686], (NI32)(TMP365));
		nimln(598, "osproc.nim");
		counter = addInt(counter, 1);
		nimln(1461, "system.nim");
		res_127690 = addInt(res_127690, 1);
	} LA1: ;
	nimln(599, "osproc.nim");
	nimln(599, "osproc.nim");
	nimln(599, "osproc.nim");
	nimln(599, "osproc.nim");
	TMP366 = addInt(counter, 1);
	TMP367 = mulInt((NI32)(TMP366), 4);
	LOC2 = 0;
	LOC2 = alloc0_4616((NI32)(TMP367));
	result = ((NCSTRING*) (LOC2));
	nimln(600, "osproc.nim");
	i = 0;
	key_127665 = 0;
	val_127666 = 0;
	nimln(1180, "os.nim");
	getenvvarsc_110002();
	i_127702 = 0;
	HEX3Atmp_127704 = 0;
	nimln(1181, "os.nim");
	nimln(1181, "os.nim");
	HEX3Atmp_127704 = (environment_109806->Sup.len-1);
	nimln(1458, "system.nim");
	res_127706 = 0;
	nimln(1459, "system.nim");
	while (1) {
		NI p_127708;
		NI TMP368;
		NI TMP369;
		NimStringDesc* x;
		NimStringDesc* LOC4;
		NI TMP370;
		void* LOC5;
		NI TMP371;
		nimln(1459, "system.nim");
		if (!(res_127706 <= HEX3Atmp_127704)) goto LA3;
		nimln(1458, "system.nim");
		i_127702 = res_127706;
		nimln(1182, "os.nim");
		if ((NU)(i_127702) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		p_127708 = nsuFindChar(environment_109806->data[i_127702], 61, 0);
		nimln(1183, "os.nim");
		nimln(1183, "os.nim");
		if ((NU)(i_127702) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		nimln(1183, "os.nim");
		TMP368 = subInt(p_127708, 1);
		key_127665 = copyStrLast(environment_109806->data[i_127702], 0, (NI32)(TMP368));
		nimln(1184, "os.nim");
		nimln(1184, "os.nim");
		if ((NU)(i_127702) >= (NU)(environment_109806->Sup.len)) raiseIndexError();
		nimln(1184, "os.nim");
		TMP369 = addInt(p_127708, 1);
		val_127666 = copyStr(environment_109806->data[i_127702], (NI32)(TMP369));
		nimln(602, "osproc.nim");
		nimln(602, "osproc.nim");
		LOC4 = 0;
		LOC4 = rawNewString(key_127665->Sup.len + val_127666->Sup.len + 1);
appendString(LOC4, key_127665);
appendString(LOC4, ((NimStringDesc*) &TMP361));
appendString(LOC4, val_127666);
		x = LOC4;
		nimln(603, "osproc.nim");
		if ((NU)(i) > (NU)(50000)) raiseIndexError();
		nimln(603, "osproc.nim");
		nimln(603, "osproc.nim");
		nimln(603, "osproc.nim");
		TMP370 = addInt(x->Sup.len, 1);
		LOC5 = 0;
		LOC5 = alloc_4601((NI32)(TMP370));
		result[(i)- 0] = ((NCSTRING) (LOC5));
		nimln(604, "osproc.nim");
		if ((NU)(i) > (NU)(50000)) raiseIndexError();
		if ((NU)(0) > (NU)(x->Sup.len)) raiseIndexError();
		nimln(604, "osproc.nim");
		nimln(604, "osproc.nim");
		TMP371 = addInt(x->Sup.len, 1);
		memcpy(((void*) (result[(i)- 0])), ((void*) (&x->data[0])), (NI32)(TMP371));
		nimln(605, "osproc.nim");
		i = addInt(i, 1);
		nimln(1461, "system.nim");
		res_127706 = addInt(res_127706, 1);
	} LA3: ;
	popFrame();
	return result;
}

static N_INLINE(void, setcurrentdir_107203)(NimStringDesc* newdir) {
	nimfr("setCurrentDir", "os.nim")
	nimln(500, "os.nim");
	{
		int LOC3;
		NI32 LOC6;
		nimln(500, "os.nim");
		nimln(500, "os.nim");
		nimln(500, "os.nim");
		LOC3 = 0;
		LOC3 = chdir(newdir->data);
		if (!!((LOC3 == ((NI32) 0)))) goto LA4;
		nimln(500, "os.nim");
		nimln(500, "os.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	popFrame();
}

N_NIMCALL(pid_t, startprocessauxspawn_127801)(tstartprocessdata127715* data) {
	pid_t result;
	posix_spawnattr_t attr;
	posix_spawn_file_actions_t fops;
	sigset_t mask;
	int res;
	pid_t pid;
	int LOC98;
	int LOC99;
	nimfr("startProcessAuxSpawn", "osproc.nim")
	result = 0;
	memset((void*)&attr, 0, sizeof(attr));
	memset((void*)&fops, 0, sizeof(fops));
	nimln(715, "osproc.nim");
	{
		int LOC3;
		NI32 LOC6;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		nimln(717, "osproc.nim");
		LOC3 = 0;
		LOC3 = posix_spawn_file_actions_init(&fops);
		if (!!((LOC3 == ((NI32) 0)))) goto LA4;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	nimln(715, "osproc.nim");
	{
		int LOC9;
		NI32 LOC12;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		nimln(718, "osproc.nim");
		LOC9 = 0;
		LOC9 = posix_spawnattr_init(&attr);
		if (!!((LOC9 == ((NI32) 0)))) goto LA10;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		LOC12 = 0;
		LOC12 = oslasterror_105231();
		oserror_105205(LOC12);
	}
	LA10: ;
	memset((void*)&mask, 0, sizeof(mask));
	nimln(715, "osproc.nim");
	{
		int LOC15;
		NI32 LOC18;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		nimln(721, "osproc.nim");
		LOC15 = 0;
		LOC15 = sigemptyset(&mask);
		if (!!((LOC15 == ((NI32) 0)))) goto LA16;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		LOC18 = 0;
		LOC18 = oslasterror_105231();
		oserror_105205(LOC18);
	}
	LA16: ;
	nimln(715, "osproc.nim");
	{
		int LOC21;
		NI32 LOC24;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		nimln(722, "osproc.nim");
		LOC21 = 0;
		LOC21 = posix_spawnattr_setsigmask(&attr, &mask);
		if (!!((LOC21 == ((NI32) 0)))) goto LA22;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		LOC24 = 0;
		LOC24 = oslasterror_105231();
		oserror_105205(LOC24);
	}
	LA22: ;
	nimln(715, "osproc.nim");
	{
		int LOC27;
		NI32 LOC30;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		nimln(723, "osproc.nim");
		LOC27 = 0;
		LOC27 = posix_spawnattr_setpgroup(&attr, 0);
		if (!!((LOC27 == ((NI32) 0)))) goto LA28;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		LOC30 = 0;
		LOC30 = oslasterror_105231();
		oserror_105205(LOC30);
	}
	LA28: ;
	nimln(715, "osproc.nim");
	{
		int LOC33;
		NI32 LOC36;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		nimln(725, "osproc.nim");
		nimln(726, "osproc.nim");
		nimln(725, "osproc.nim");
		LOC33 = 0;
		LOC33 = posix_spawnattr_setflags(&attr, (NI32)((NI32)(POSIX_SPAWN_USEVFORK | POSIX_SPAWN_SETSIGMASK) | POSIX_SPAWN_SETPGROUP));
		if (!!((LOC33 == ((NI32) 0)))) goto LA34;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		LOC36 = 0;
		LOC36 = oslasterror_105231();
		oserror_105205(LOC36);
	}
	LA34: ;
	nimln(729, "osproc.nim");
	{
		nimln(729, "osproc.nim");
		if (!!((*data).Optionpoparentstreams)) goto LA39;
		nimln(715, "osproc.nim");
		{
			int LOC43;
			NI32 LOC46;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			nimln(730, "osproc.nim");
			LOC43 = 0;
			LOC43 = posix_spawn_file_actions_addclose(&fops, (*data).Pstdin[(1)- 0]);
			if (!!((LOC43 == ((NI32) 0)))) goto LA44;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			LOC46 = 0;
			LOC46 = oslasterror_105231();
			oserror_105205(LOC46);
		}
		LA44: ;
		nimln(715, "osproc.nim");
		{
			int LOC49;
			NI32 LOC52;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			nimln(731, "osproc.nim");
			LOC49 = 0;
			LOC49 = posix_spawn_file_actions_adddup2(&fops, (*data).Pstdin[(0)- 0], ((int) 0));
			if (!!((LOC49 == ((NI32) 0)))) goto LA50;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			LOC52 = 0;
			LOC52 = oslasterror_105231();
			oserror_105205(LOC52);
		}
		LA50: ;
		nimln(715, "osproc.nim");
		{
			int LOC55;
			NI32 LOC58;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			nimln(732, "osproc.nim");
			LOC55 = 0;
			LOC55 = posix_spawn_file_actions_addclose(&fops, (*data).Pstdout[(0)- 0]);
			if (!!((LOC55 == ((NI32) 0)))) goto LA56;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			LOC58 = 0;
			LOC58 = oslasterror_105231();
			oserror_105205(LOC58);
		}
		LA56: ;
		nimln(715, "osproc.nim");
		{
			int LOC61;
			NI32 LOC64;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			nimln(733, "osproc.nim");
			LOC61 = 0;
			LOC61 = posix_spawn_file_actions_adddup2(&fops, (*data).Pstdout[(1)- 0], ((int) 1));
			if (!!((LOC61 == ((NI32) 0)))) goto LA62;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			LOC64 = 0;
			LOC64 = oslasterror_105231();
			oserror_105205(LOC64);
		}
		LA62: ;
		nimln(715, "osproc.nim");
		{
			int LOC67;
			NI32 LOC70;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			nimln(734, "osproc.nim");
			LOC67 = 0;
			LOC67 = posix_spawn_file_actions_addclose(&fops, (*data).Pstderr[(0)- 0]);
			if (!!((LOC67 == ((NI32) 0)))) goto LA68;
			nimln(715, "osproc.nim");
			nimln(715, "osproc.nim");
			LOC70 = 0;
			LOC70 = oslasterror_105231();
			oserror_105205(LOC70);
		}
		LA68: ;
		nimln(735, "osproc.nim");
		{
			if (!(*data).Optionpostderrtostdout) goto LA73;
			nimln(715, "osproc.nim");
			{
				int LOC77;
				NI32 LOC80;
				nimln(715, "osproc.nim");
				nimln(715, "osproc.nim");
				nimln(736, "osproc.nim");
				LOC77 = 0;
				LOC77 = posix_spawn_file_actions_adddup2(&fops, (*data).Pstdout[(1)- 0], ((int) 2));
				if (!!((LOC77 == ((NI32) 0)))) goto LA78;
				nimln(715, "osproc.nim");
				nimln(715, "osproc.nim");
				LOC80 = 0;
				LOC80 = oslasterror_105231();
				oserror_105205(LOC80);
			}
			LA78: ;
		}
		goto LA71;
		LA73: ;
		{
			nimln(715, "osproc.nim");
			{
				int LOC84;
				NI32 LOC87;
				nimln(715, "osproc.nim");
				nimln(715, "osproc.nim");
				nimln(738, "osproc.nim");
				LOC84 = 0;
				LOC84 = posix_spawn_file_actions_adddup2(&fops, (*data).Pstderr[(1)- 0], ((int) 2));
				if (!!((LOC84 == ((NI32) 0)))) goto LA85;
				nimln(715, "osproc.nim");
				nimln(715, "osproc.nim");
				LOC87 = 0;
				LOC87 = oslasterror_105231();
				oserror_105205(LOC87);
			}
			LA85: ;
		}
		LA71: ;
	}
	LA39: ;
	res = 0;
	nimln(742, "osproc.nim");
	{
		NimStringDesc* LOC92;
		nimln(742, "osproc.nim");
		nimln(742, "osproc.nim");
		if (!(0 < strlen((*data).Workingdir))) goto LA90;
		nimln(743, "osproc.nim");
		nimln(743, "osproc.nim");
		LOC92 = 0;
		LOC92 = cstrToNimstr((*data).Workingdir);
		setcurrentdir_107203(LOC92);
	}
	LA90: ;
	pid = 0;
	nimln(746, "osproc.nim");
	{
		if (!(*data).Optionpousepath) goto LA95;
		nimln(747, "osproc.nim");
		res = posix_spawnp(&pid, (*data).Syscommand, &fops, &attr, (*data).Sysargs, (*data).Sysenv);
	}
	goto LA93;
	LA95: ;
	{
		nimln(749, "osproc.nim");
		res = posix_spawn(&pid, (*data).Syscommand, &fops, &attr, (*data).Sysargs, (*data).Sysenv);
	}
	LA93: ;
	nimln(751, "osproc.nim");
	nimln(751, "osproc.nim");
	LOC98 = 0;
	LOC98 = posix_spawn_file_actions_destroy(&fops);
	nimln(752, "osproc.nim");
	nimln(752, "osproc.nim");
	LOC99 = 0;
	LOC99 = posix_spawnattr_destroy(&attr);
	nimln(715, "osproc.nim");
	{
		NI32 LOC104;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		if (!!((res == ((NI32) 0)))) goto LA102;
		nimln(715, "osproc.nim");
		nimln(715, "osproc.nim");
		LOC104 = 0;
		LOC104 = oslasterror_105231();
		oserror_105205(LOC104);
	}
	LA102: ;
	nimln(754, "osproc.nim");
	nimln(754, "osproc.nim");
	result = pid;
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

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

N_NIMCALL(void, startprocessfail_128623)(tstartprocessdata127715* data) {
	int error;
	NI LOC1;
	error = errno;
	LOC1 = 0;
	LOC1 = write((*data).Perrorpipe[(1)- 0], ((void*) (&error)), 4);
	_exit(1);
}

N_CDECL(void, startprocessafterfork_127807)(tstartprocessdata127715* data) {
	int LOC42;
	int LOC43;
	{
		int LOC5;
		int LOC11;
		int LOC17;
		if (!!((*data).Optionpoparentstreams)) goto LA3;
		LOC5 = 0;
		LOC5 = close((*data).Pstdin[(1)- 0]);
		{
			int LOC8;
			LOC8 = 0;
			LOC8 = dup2((*data).Pstdin[(0)- 0], ((int) 0));
			if (!(LOC8 < ((NI32) 0))) goto LA9;
			startprocessfail_128623(data);
		}
		LA9: ;
		LOC11 = 0;
		LOC11 = close((*data).Pstdout[(0)- 0]);
		{
			int LOC14;
			LOC14 = 0;
			LOC14 = dup2((*data).Pstdout[(1)- 0], ((int) 1));
			if (!(LOC14 < ((NI32) 0))) goto LA15;
			startprocessfail_128623(data);
		}
		LA15: ;
		LOC17 = 0;
		LOC17 = close((*data).Pstderr[(0)- 0]);
		{
			if (!(*data).Optionpostderrtostdout) goto LA20;
			{
				int LOC24;
				LOC24 = 0;
				LOC24 = dup2((*data).Pstdout[(1)- 0], ((int) 2));
				if (!(LOC24 < ((NI32) 0))) goto LA25;
				startprocessfail_128623(data);
			}
			LA25: ;
		}
		goto LA18;
		LA20: ;
		{
			{
				int LOC30;
				LOC30 = 0;
				LOC30 = dup2((*data).Pstderr[(1)- 0], ((int) 2));
				if (!(LOC30 < ((NI32) 0))) goto LA31;
				startprocessfail_128623(data);
			}
			LA31: ;
		}
		LA18: ;
	}
	LA3: ;
	{
		if (!(0 < strlen((*data).Workingdir))) goto LA35;
		{
			int LOC39;
			LOC39 = 0;
			LOC39 = chdir((*data).Workingdir);
			if (!(LOC39 < ((NI32) 0))) goto LA40;
			startprocessfail_128623(data);
		}
		LA40: ;
	}
	LA35: ;
	LOC42 = 0;
	LOC42 = close((*data).Perrorpipe[(0)- 0]);
	LOC43 = 0;
	LOC43 = fcntl((*data).Perrorpipe[(1)- 0], F_SETFD, FD_CLOEXEC);
	{
		int LOC48;
		if (!(*data).Optionpousepath) goto LA46;
		LOC48 = 0;
		LOC48 = execvpe((*data).Syscommand, (*data).Sysargs, (*data).Sysenv);
	}
	goto LA44;
	LA46: ;
	{
		int LOC50;
		LOC50 = 0;
		LOC50 = execve((*data).Syscommand, (*data).Sysargs, (*data).Sysenv);
	}
	LA44: ;
	startprocessfail_128623(data);
}

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

static N_INLINE(void, setFrame)(TFrame* s) {
	frameptr_13038 = s;
}

N_NIMCALL(pid_t, startprocessauxfork_127804)(tstartprocessdata127715* data) {
	pid_t result;
	TSafePoint TMP374;
	nimfr("startProcessAuxFork", "osproc.nim")
	result = 0;
	nimln(757, "osproc.nim");
	{
		int LOC3;
		NI32 LOC6;
		nimln(757, "osproc.nim");
		nimln(757, "osproc.nim");
		nimln(757, "osproc.nim");
		LOC3 = 0;
		LOC3 = pipe((*data).Perrorpipe);
		if (!!((LOC3 == ((NI32) 0)))) goto LA4;
		nimln(758, "osproc.nim");
		nimln(758, "osproc.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	nimln(760, "osproc.nim");
	pushSafePoint(&TMP374);
	TMP374.status = setjmp(TMP374.context);
	if (TMP374.status == 0) {
		pid_t volatile pid;
		tstartprocessdata127715 volatile datacopy;
		int LOC12;
		int volatile error;
		NI volatile sizeread;
		int LOC24;
		pid = 0;
		nimln(764, "osproc.nim");
		datacopy = (*data);
		nimln(777, "osproc.nim");
		pid = fork();
		nimln(778, "osproc.nim");
		{
			nimln(778, "osproc.nim");
			if (!(pid == 0)) goto LA10;
			nimln(779, "osproc.nim");
			startprocessafterfork_127807(&datacopy);
			nimln(780, "osproc.nim");
			_exit(1);
		}
		LA10: ;
		nimln(782, "osproc.nim");
		nimln(782, "osproc.nim");
		LOC12 = 0;
		LOC12 = close((*data).Perrorpipe[(1)- 0]);
		nimln(783, "osproc.nim");
		{
			NI32 LOC17;
			nimln(783, "osproc.nim");
			if (!(pid < 0)) goto LA15;
			nimln(783, "osproc.nim");
			nimln(783, "osproc.nim");
			LOC17 = 0;
			LOC17 = oslasterror_105231();
			oserror_105205(LOC17);
		}
		LA15: ;
		error = 0;
		nimln(786, "osproc.nim");
		sizeread = read((*data).Perrorpipe[(0)- 0], ((void*) (&error)), 4);
		nimln(787, "osproc.nim");
		{
			NCSTRING LOC22;
			NimStringDesc* LOC23;
			nimln(787, "osproc.nim");
			if (!(sizeread == 4)) goto LA20;
			nimln(788, "osproc.nim");
			nimln(788, "osproc.nim");
			nimln(788, "osproc.nim");
			LOC22 = 0;
			LOC22 = strerror(error);
			LOC23 = 0;
			LOC23 = cstrToNimstr(LOC22);
			nososError(LOC23);
		}
		LA20: ;
		nimln(790, "osproc.nim");
		nimln(790, "osproc.nim");
		result = pid;
		popSafePoint();
		nimln(761, "osproc.nim");
		nimln(761, "osproc.nim");
		LOC24 = 0;
		LOC24 = close((*data).Perrorpipe[(0)- 0]);
		goto BeforeRet;
		popSafePoint();
	}
	else {
		popSafePoint();
		setFrame((TFrame*)&F);
	}
	{
		int LOC27;
		nimln(761, "osproc.nim");
		nimln(761, "osproc.nim");
		LOC27 = 0;
		LOC27 = close((*data).Perrorpipe[(0)- 0]);
	}
	if (TMP374.status != 0) reraiseException();
	BeforeRet: ;
	popFrame();
	return result;
}

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(tprocess126203*, nospstartProcess)(NimStringDesc* command, NimStringDesc* workingdir, NimStringDesc** args, NI argsLen0, tstringtable121810* env, NU8 options) {
	tprocess126203* result;
	TY127720 pstdin;
	TY127720 pstdout;
	TY127720 pstderr;
	NimStringDesc* syscommand;
	TY10665* sysargsraw;
	pid_t pid;
	NCSTRING* sysargs;
	TSafePoint TMP378;
	nimfr("startProcess", "osproc.nim")
	result = 0;
	memset((void*)pstdin, 0, sizeof(pstdin));
	memset((void*)pstdout, 0, sizeof(pstdout));
	memset((void*)pstderr, 0, sizeof(pstderr));
	nimln(634, "osproc.nim");
	result = (tprocess126203*) newObj((&NTI126205), sizeof(tprocess126203));
	(*result).Sup.m_type = (&NTI126203);
	nimln(635, "osproc.nim");
	(*result).Exitcode = ((int) -3);
	nimln(636, "osproc.nim");
	{
		nimln(636, "osproc.nim");
		nimln(636, "osproc.nim");
		if (!!(((options &(1<<((((NU8) 4))&7)))!=0))) goto LA3;
		nimln(637, "osproc.nim");
		{
			NIM_BOOL LOC7;
			NIM_BOOL LOC8;
			int LOC9;
			int LOC11;
			int LOC13;
			NI32 LOC16;
			nimln(637, "osproc.nim");
			LOC7 = 0;
			nimln(637, "osproc.nim");
			LOC8 = 0;
			nimln(637, "osproc.nim");
			nimln(637, "osproc.nim");
			nimln(637, "osproc.nim");
			LOC9 = 0;
			LOC9 = pipe(pstdin);
			LOC8 = !((LOC9 == ((NI32) 0)));
			if (LOC8) goto LA10;
			nimln(637, "osproc.nim");
			nimln(637, "osproc.nim");
			nimln(637, "osproc.nim");
			LOC11 = 0;
			LOC11 = pipe(pstdout);
			LOC8 = !((LOC11 == ((NI32) 0)));
			LA10: ;
			LOC7 = LOC8;
			if (LOC7) goto LA12;
			nimln(638, "osproc.nim");
			nimln(638, "osproc.nim");
			nimln(638, "osproc.nim");
			LOC13 = 0;
			LOC13 = pipe(pstderr);
			LOC7 = !((LOC13 == ((NI32) 0)));
			LA12: ;
			if (!LOC7) goto LA14;
			nimln(639, "osproc.nim");
			nimln(639, "osproc.nim");
			LOC16 = 0;
			LOC16 = oslasterror_105231();
			oserror_105205(LOC16);
		}
		LA14: ;
	}
	LA3: ;
	syscommand = 0;
	sysargsraw = 0;
	nimln(643, "osproc.nim");
	{
		TY127892 LOC21;
		NimStringDesc* LOC22;
		NimStringDesc* LOC23;
		NimStringDesc* LOC24;
		nimln(643, "osproc.nim");
		if (!((options &(1<<((((NU8) 2))&7)))!=0)) goto LA19;
		nimln(644, "osproc.nim");
		syscommand = copyString(((NimStringDesc*) &TMP375));
		nimln(645, "osproc.nim");
		nimln(645, "osproc.nim");
		sysargsraw = (TY10665*) newSeq((&NTI10665), 3);
		memset((void*)LOC21, 0, sizeof(LOC21));
		LOC21[0] = copyString(syscommand);
		LOC21[1] = copyString(((NimStringDesc*) &TMP376));
		LOC21[2] = copyString(command);
		LOC22 = 0;
		LOC22 = sysargsraw->data[0]; sysargsraw->data[0] = copyStringRC1(LOC21[0]);
		if (LOC22) nimGCunrefNoCycle(LOC22);
		LOC23 = 0;
		LOC23 = sysargsraw->data[1]; sysargsraw->data[1] = copyStringRC1(LOC21[1]);
		if (LOC23) nimGCunrefNoCycle(LOC23);
		LOC24 = 0;
		LOC24 = sysargsraw->data[2]; sysargsraw->data[2] = copyStringRC1(LOC21[2]);
		if (LOC24) nimGCunrefNoCycle(LOC24);
		nimln(646, "osproc.nim");
		{
			nimln(646, "osproc.nim");
			nimln(646, "osproc.nim");
			nimln(646, "osproc.nim");
			if (!!((argsLen0 == 0))) goto LA27;
			nimln(646, "osproc.nim");
			failedassertimpl_79821(((NimStringDesc*) &TMP377));
		}
		LA27: ;
	}
	goto LA17;
	LA19: ;
	{
		TY128024 LOC30;
		NimStringDesc* LOC31;
		NimStringDesc* arg_128037;
		NI i_128287;
		nimln(648, "osproc.nim");
		syscommand = copyString(command);
		nimln(649, "osproc.nim");
		nimln(649, "osproc.nim");
		sysargsraw = (TY10665*) newSeq((&NTI10665), 1);
		memset((void*)LOC30, 0, sizeof(LOC30));
		LOC30[0] = copyString(command);
		LOC31 = 0;
		LOC31 = sysargsraw->data[0]; sysargsraw->data[0] = copyStringRC1(LOC30[0]);
		if (LOC31) nimGCunrefNoCycle(LOC31);
		arg_128037 = 0;
		nimln(1531, "system.nim");
		i_128287 = 0;
		nimln(1532, "system.nim");
		while (1) {
			NimStringDesc* LOC33;
			nimln(1532, "system.nim");
			nimln(1532, "system.nim");
			if (!(i_128287 < argsLen0)) goto LA32;
			nimln(1533, "system.nim");
			if ((NU)(i_128287) >= (NU)(argsLen0)) raiseIndexError();
			arg_128037 = args[i_128287];
			nimln(651, "osproc.nim");
			sysargsraw = (TY10665*) incrSeq(&(sysargsraw)->Sup, sizeof(NimStringDesc*));
			LOC33 = 0;
			LOC33 = sysargsraw->data[sysargsraw->Sup.len-1]; sysargsraw->data[sysargsraw->Sup.len-1] = copyStringRC1(arg_128037);
			if (LOC33) nimGCunrefNoCycle(LOC33);
			nimln(1534, "system.nim");
			i_128287 = addInt(i_128287, 1);
		} LA32: ;
	}
	LA17: ;
	pid = 0;
	nimln(655, "osproc.nim");
	sysargs = alloccstringarray_10801(sysargsraw->data, sysargsraw->Sup.len);
	nimln(656, "osproc.nim");
	pushSafePoint(&TMP378);
	TMP378.status = setjmp(TMP378.context);
	if (TMP378.status == 0) {
		NCSTRING* volatile sysenv;
		TSafePoint TMP379;
		nimln(658, "osproc.nim");
		nimln(658, "osproc.nim");
		{
			nimln(658, "osproc.nim");
			if (!(env == NIM_NIL)) goto LA37;
			nimln(659, "osproc.nim");
			sysenv = envtocstringarray_127641();
		}
		goto LA35;
		LA37: ;
		{
			nimln(661, "osproc.nim");
			sysenv = envtocstringarray_127604(env);
		}
		LA35: ;
		nimln(663, "osproc.nim");
		pushSafePoint(&TMP379);
		TMP379.status = setjmp(TMP379.context);
		if (TMP379.status == 0) {
			tstartprocessdata127715 volatile data;
			memset((void*)&data, 0, sizeof(data));
			nimln(666, "osproc.nim");
			data.Syscommand = syscommand->data;
			nimln(667, "osproc.nim");
			data.Sysargs = sysargs;
			nimln(668, "osproc.nim");
			data.Sysenv = sysenv;
			nimln(669, "osproc.nim");
			memcpy((void*)data.Pstdin, (NIM_CONST void*)pstdin, sizeof(data.Pstdin));
			nimln(670, "osproc.nim");
			memcpy((void*)data.Pstdout, (NIM_CONST void*)pstdout, sizeof(data.Pstdout));
			nimln(671, "osproc.nim");
			memcpy((void*)data.Pstderr, (NIM_CONST void*)pstderr, sizeof(data.Pstderr));
			nimln(672, "osproc.nim");
			nimln(672, "osproc.nim");
			data.Optionpoparentstreams = ((options &(1<<((((NU8) 4))&7)))!=0);
			nimln(673, "osproc.nim");
			nimln(673, "osproc.nim");
			data.Optionpousepath = ((options &(1<<((((NU8) 1))&7)))!=0);
			nimln(674, "osproc.nim");
			nimln(674, "osproc.nim");
			data.Optionpostderrtostdout = ((options &(1<<((((NU8) 3))&7)))!=0);
			nimln(675, "osproc.nim");
			data.Workingdir = workingdir->data;
			nimln(682, "osproc.nim");
			pid = startprocessauxfork_127804(&data);
			nimln(685, "osproc.nim");
			{
				NimStringDesc* LOC45;
				nimln(685, "osproc.nim");
				if (!((options &(1<<((((NU8) 0))&7)))!=0)) goto LA43;
				nimln(686, "osproc.nim");
				nimln(686, "osproc.nim");
				LOC45 = 0;
				LOC45 = nsuJoinSep(args, argsLen0, ((NimStringDesc*) &TMP380));
				printf("%s%s%s\012", (command)->data, (((NimStringDesc*) &TMP380))->data, (LOC45)->data);
			}
			LA43: ;
			nimln(687, "osproc.nim");
			(*result).Id = pid;
			nimln(689, "osproc.nim");
			{
				nimln(689, "osproc.nim");
				if (!((options &(1<<((((NU8) 4))&7)))!=0)) goto LA48;
				nimln(691, "osproc.nim");
				(*result).Inhandle = ((int) 0);
				nimln(692, "osproc.nim");
				(*result).Outhandle = ((int) 1);
				nimln(693, "osproc.nim");
				{
					nimln(693, "osproc.nim");
					if (!((options &(1<<((((NU8) 3))&7)))!=0)) goto LA52;
					nimln(694, "osproc.nim");
					(*result).Errhandle = (*result).Outhandle;
				}
				goto LA50;
				LA52: ;
				{
					nimln(696, "osproc.nim");
					(*result).Errhandle = ((int) 2);
				}
				LA50: ;
			}
			goto LA46;
			LA48: ;
			{
				int LOC62;
				int LOC63;
				int LOC64;
				nimln(698, "osproc.nim");
				(*result).Inhandle = pstdin[(1)- 0];
				nimln(699, "osproc.nim");
				(*result).Outhandle = pstdout[(0)- 0];
				nimln(700, "osproc.nim");
				{
					int LOC60;
					nimln(700, "osproc.nim");
					if (!((options &(1<<((((NU8) 3))&7)))!=0)) goto LA58;
					nimln(701, "osproc.nim");
					(*result).Errhandle = (*result).Outhandle;
					nimln(702, "osproc.nim");
					nimln(702, "osproc.nim");
					LOC60 = 0;
					LOC60 = close(pstderr[(0)- 0]);
				}
				goto LA56;
				LA58: ;
				{
					nimln(704, "osproc.nim");
					(*result).Errhandle = pstderr[(0)- 0];
				}
				LA56: ;
				nimln(705, "osproc.nim");
				nimln(705, "osproc.nim");
				LOC62 = 0;
				LOC62 = close(pstderr[(1)- 0]);
				nimln(706, "osproc.nim");
				nimln(706, "osproc.nim");
				LOC63 = 0;
				LOC63 = close(pstdin[(0)- 0]);
				nimln(707, "osproc.nim");
				nimln(707, "osproc.nim");
				LOC64 = 0;
				LOC64 = close(pstdout[(1)- 0]);
			}
			LA46: ;
			popSafePoint();
		}
		else {
			popSafePoint();
			setFrame((TFrame*)&F);
		}
		{
			nimln(663, "osproc.nim");
			dealloccstringarray_10842(sysenv);
		}
		if (TMP379.status != 0) reraiseException();
		popSafePoint();
	}
	else {
		popSafePoint();
		setFrame((TFrame*)&F);
	}
	{
		nimln(656, "osproc.nim");
		dealloccstringarray_10842(sysargs);
	}
	if (TMP378.status != 0) reraiseException();
	popFrame();
	return result;
}

N_NIMCALL(void, nospclose)(tprocess126203* p) {
	int LOC13;
	int LOC14;
	int LOC15;
	nimfr("close", "osproc.nim")
	nimln(842, "osproc.nim");
	{
		nimln(842, "osproc.nim");
		nimln(842, "osproc.nim");
		if (!!(((*p).Instream == NIM_NIL))) goto LA3;
		nimln(842, "osproc.nim");
		close_123876((*p).Instream);
	}
	LA3: ;
	nimln(843, "osproc.nim");
	{
		nimln(843, "osproc.nim");
		nimln(843, "osproc.nim");
		if (!!(((*p).Outstream == NIM_NIL))) goto LA7;
		nimln(843, "osproc.nim");
		close_123876((*p).Outstream);
	}
	LA7: ;
	nimln(844, "osproc.nim");
	{
		nimln(844, "osproc.nim");
		nimln(844, "osproc.nim");
		if (!!(((*p).Errstream == NIM_NIL))) goto LA11;
		nimln(844, "osproc.nim");
		close_123876((*p).Errstream);
	}
	LA11: ;
	nimln(845, "osproc.nim");
	nimln(845, "osproc.nim");
	LOC13 = 0;
	LOC13 = close((*p).Inhandle);
	nimln(846, "osproc.nim");
	nimln(846, "osproc.nim");
	LOC14 = 0;
	LOC14 = close((*p).Outhandle);
	nimln(847, "osproc.nim");
	nimln(847, "osproc.nim");
	LOC15 = 0;
	LOC15 = close((*p).Errhandle);
	popFrame();
}

N_NIMCALL(void, nospsuspend)(tprocess126203* p) {
	nimfr("suspend", "osproc.nim")
	nimln(850, "osproc.nim");
	{
		int LOC3;
		NI32 LOC6;
		nimln(850, "osproc.nim");
		nimln(850, "osproc.nim");
		nimln(850, "osproc.nim");
		nimln(850, "osproc.nim");
		if ((*p).Id == (-2147483647 -1)) raiseOverflow();
		LOC3 = 0;
		LOC3 = kill(((NI32)-((*p).Id)), SIGSTOP);
		if (!!((LOC3 == ((NI32) 0)))) goto LA4;
		nimln(850, "osproc.nim");
		nimln(850, "osproc.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	popFrame();
}

N_NIMCALL(void, nospresume)(tprocess126203* p) {
	nimfr("resume", "osproc.nim")
	nimln(853, "osproc.nim");
	{
		int LOC3;
		NI32 LOC6;
		nimln(853, "osproc.nim");
		nimln(853, "osproc.nim");
		nimln(853, "osproc.nim");
		nimln(853, "osproc.nim");
		if ((*p).Id == (-2147483647 -1)) raiseOverflow();
		LOC3 = 0;
		LOC3 = kill(((NI32)-((*p).Id)), SIGCONT);
		if (!!((LOC3 == ((NI32) 0)))) goto LA4;
		nimln(853, "osproc.nim");
		nimln(853, "osproc.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	popFrame();
}

N_NIMCALL(NIM_BOOL, nosprunning)(tprocess126203* p) {
	NIM_BOOL result;
	pid_t ret;
	nimfr("running", "osproc.nim")
	result = 0;
	nimln(856, "osproc.nim");
	ret = waitpid((*p).Id, &(*p).Exitcode, WNOHANG);
	nimln(857, "osproc.nim");
	{
		nimln(857, "osproc.nim");
		if (!(ret == 0)) goto LA3;
		nimln(857, "osproc.nim");
		nimln(857, "osproc.nim");
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA3: ;
	nimln(858, "osproc.nim");
	nimln(858, "osproc.nim");
	result = (ret == (*p).Id);
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(void, nospterminate)(tprocess126203* p) {
	nimfr("terminate", "osproc.nim")
	nimln(861, "osproc.nim");
	{
		int LOC3;
		nimln(861, "osproc.nim");
		nimln(861, "osproc.nim");
		nimln(861, "osproc.nim");
		if ((*p).Id == (-2147483647 -1)) raiseOverflow();
		LOC3 = 0;
		LOC3 = kill(((NI32)-((*p).Id)), SIGTERM);
		if (!(LOC3 == ((NI32) 0))) goto LA4;
		nimln(862, "osproc.nim");
		{
			NIM_BOOL LOC8;
			nimln(862, "osproc.nim");
			LOC8 = 0;
			LOC8 = nosprunning(p);
			if (!LOC8) goto LA9;
			nimln(863, "osproc.nim");
			{
				int LOC13;
				NI32 LOC16;
				nimln(863, "osproc.nim");
				nimln(863, "osproc.nim");
				nimln(863, "osproc.nim");
				nimln(863, "osproc.nim");
				if ((*p).Id == (-2147483647 -1)) raiseOverflow();
				LOC13 = 0;
				LOC13 = kill(((NI32)-((*p).Id)), SIGKILL);
				if (!!((LOC13 == ((NI32) 0)))) goto LA14;
				nimln(863, "osproc.nim");
				nimln(863, "osproc.nim");
				LOC16 = 0;
				LOC16 = oslasterror_105231();
				oserror_105205(LOC16);
			}
			LA14: ;
		}
		LA9: ;
	}
	goto LA1;
	LA4: ;
	{
		NI32 LOC18;
		nimln(864, "osproc.nim");
		nimln(864, "osproc.nim");
		LOC18 = 0;
		LOC18 = oslasterror_105231();
		oserror_105205(LOC18);
	}
	LA1: ;
	popFrame();
}

N_NIMCALL(NI, nospwaitForExit)(tprocess126203* p, NI timeout) {
	NI result;
	nimfr("waitForExit", "osproc.nim")
	result = 0;
	nimln(871, "osproc.nim");
	{
		nimln(871, "osproc.nim");
		nimln(871, "osproc.nim");
		if (!!(((*p).Exitcode == ((NI32) -3)))) goto LA3;
		nimln(871, "osproc.nim");
		nimln(871, "osproc.nim");
		result = ((NI) ((*p).Exitcode));
		goto BeforeRet;
	}
	LA3: ;
	nimln(872, "osproc.nim");
	{
		pid_t LOC7;
		NI32 LOC10;
		nimln(872, "osproc.nim");
		nimln(872, "osproc.nim");
		LOC7 = 0;
		LOC7 = waitpid((*p).Id, &(*p).Exitcode, ((int) 0));
		if (!(LOC7 < 0)) goto LA8;
		nimln(873, "osproc.nim");
		(*p).Exitcode = ((int) -3);
		nimln(874, "osproc.nim");
		nimln(874, "osproc.nim");
		LOC10 = 0;
		LOC10 = oslasterror_105231();
		oserror_105205(LOC10);
	}
	LA8: ;
	nimln(875, "osproc.nim");
	nimln(875, "osproc.nim");
	result = (NI)((NU32)(((NI) ((*p).Exitcode))) >> (NU32)(8));
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(NI, peekexitcode_126496)(tprocess126203* p) {
	NI result;
	pid_t ret;
	NIM_BOOL b;
	nimfr("peekExitCode", "osproc.nim")
	result = 0;
	nimln(878, "osproc.nim");
	{
		nimln(878, "osproc.nim");
		nimln(878, "osproc.nim");
		if (!!(((*p).Exitcode == ((NI32) -3)))) goto LA3;
		nimln(878, "osproc.nim");
		nimln(878, "osproc.nim");
		result = ((NI) ((*p).Exitcode));
		goto BeforeRet;
	}
	LA3: ;
	nimln(879, "osproc.nim");
	ret = waitpid((*p).Id, &(*p).Exitcode, WNOHANG);
	nimln(880, "osproc.nim");
	nimln(880, "osproc.nim");
	b = (ret == (*p).Id);
	nimln(881, "osproc.nim");
	{
		if (!b) goto LA7;
		nimln(881, "osproc.nim");
		result = -1;
	}
	LA7: ;
	nimln(882, "osproc.nim");
	{
		nimln(882, "osproc.nim");
		if (!((*p).Exitcode == ((NI32) -3))) goto LA11;
		nimln(882, "osproc.nim");
		result = -1;
	}
	goto LA9;
	LA11: ;
	{
		nimln(883, "osproc.nim");
		nimln(883, "osproc.nim");
		result = (NI)((NU32)(((NI) ((*p).Exitcode))) >> (NU32)(8));
	}
	LA9: ;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(void, createstream_129117)(tstream123829** stream, NI32* handle, NU8 filemode) {
	FILE* f;
	tfilestream124356* LOC7;
	nimfr("createStream", "osproc.nim")
	f = 0;
	nimln(888, "osproc.nim");
	{
		NIM_BOOL LOC3;
		NI32 LOC6;
		nimln(888, "osproc.nim");
		nimln(888, "osproc.nim");
		LOC3 = 0;
		LOC3 = open_10211(&f, (*handle), filemode);
		if (!!(LOC3)) goto LA4;
		nimln(888, "osproc.nim");
		nimln(888, "osproc.nim");
		LOC6 = 0;
		LOC6 = oslasterror_105231();
		oserror_105205(LOC6);
	}
	LA4: ;
	nimln(889, "osproc.nim");
	nimln(889, "osproc.nim");
	LOC7 = 0;
	LOC7 = newfilestream_124411(f);
	unsureAsgnRef((void**) &(*stream), &LOC7->Sup);
	popFrame();
}

N_NIMCALL(tstream123829*, nospinputStream)(tprocess126203* p) {
	tstream123829* result;
	nimfr("inputStream", "osproc.nim")
	result = 0;
	nimln(892, "osproc.nim");
	{
		nimln(892, "osproc.nim");
		if (!((*p).Instream == NIM_NIL)) goto LA3;
		nimln(893, "osproc.nim");
		createstream_129117(&(*p).Instream, &(*p).Inhandle, ((NU8) 1));
	}
	LA3: ;
	nimln(894, "osproc.nim");
	nimln(894, "osproc.nim");
	result = (*p).Instream;
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(tstream123829*, nospoutputStream)(tprocess126203* p) {
	tstream123829* result;
	nimfr("outputStream", "osproc.nim")
	result = 0;
	nimln(897, "osproc.nim");
	{
		nimln(897, "osproc.nim");
		if (!((*p).Outstream == NIM_NIL)) goto LA3;
		nimln(898, "osproc.nim");
		createstream_129117(&(*p).Outstream, &(*p).Outhandle, ((NU8) 0));
	}
	LA3: ;
	nimln(899, "osproc.nim");
	nimln(899, "osproc.nim");
	result = (*p).Outstream;
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(tstream123829*, nosperrorStream)(tprocess126203* p) {
	tstream123829* result;
	nimfr("errorStream", "osproc.nim")
	result = 0;
	nimln(902, "osproc.nim");
	{
		nimln(902, "osproc.nim");
		if (!((*p).Errstream == NIM_NIL)) goto LA3;
		nimln(903, "osproc.nim");
		createstream_129117(&(*p).Errstream, &(*p).Errhandle, ((NU8) 0));
	}
	LA3: ;
	nimln(904, "osproc.nim");
	nimln(904, "osproc.nim");
	result = (*p).Errstream;
	goto BeforeRet;
	BeforeRet: ;
	popFrame();
	return result;
}

N_NIMCALL(NI, nospexecCmd)(NimStringDesc* command) {
	NI result;
	int LOC1;
	nimfr("execCmd", "osproc.nim")
	result = 0;
	nimln(910, "osproc.nim");
	nimln(910, "osproc.nim");
	nimln(910, "osproc.nim");
	LOC1 = 0;
	LOC1 = system(command->data);
	result = ((NI) ((NI32)((NU32)(LOC1) >> (NU32)(((NI32) 8)))));
	popFrame();
	return result;
}

N_NIMCALL(void, createfdset_129402)(fd_set* fd, TY127203* s, NI* m) {
	tprocess126203* i_129614;
	NI i_129629;
	NI l_129631;
	nimfr("createFdSet", "osproc.nim")
	nimln(915, "osproc.nim");
	FD_ZERO(fd);
	i_129614 = 0;
	nimln(2796, "system.nim");
	i_129629 = 0;
	nimln(2797, "system.nim");
	nimln(2797, "system.nim");
	l_129631 = s->Sup.len;
	nimln(2798, "system.nim");
	while (1) {
		nimln(2798, "system.nim");
		if (!(i_129629 < l_129631)) goto LA1;
		nimln(2799, "system.nim");
		if ((NU)(i_129629) >= (NU)(s->Sup.len)) raiseIndexError();
		i_129614 = s->data[i_129629];
		nimln(917, "osproc.nim");
		nimln(917, "osproc.nim");
		(*m) = (((*m) >= ((NI) ((*i_129614).Outhandle))) ? (*m) : ((NI) ((*i_129614).Outhandle)));
		nimln(918, "osproc.nim");
		FD_SET((*i_129614).Outhandle, fd);
		nimln(2800, "system.nim");
		i_129629 = addInt(i_129629, 1);
		nimln(2801, "system.nim");
		{
			nimln(2801, "system.nim");
			nimln(2801, "system.nim");
			nimln(2801, "system.nim");
			if (!!((s->Sup.len == l_129631))) goto LA4;
			nimln(2801, "system.nim");
			failedassertimpl_79821(((NimStringDesc*) &TMP383));
		}
		LA4: ;
	} LA1: ;
	popFrame();
}

N_NIMCALL(void, pruneprocessset_129634)(TY127203** s, fd_set* fd) {
	NI i;
	NI l;
	nimfr("pruneProcessSet", "osproc.nim")
	nimln(921, "osproc.nim");
	i = 0;
	nimln(922, "osproc.nim");
	nimln(922, "osproc.nim");
	l = (*s)->Sup.len;
	nimln(923, "osproc.nim");
	while (1) {
		nimln(923, "osproc.nim");
		if (!(i < l)) goto LA1;
		nimln(924, "osproc.nim");
		{
			int LOC4;
			NI TMP384;
			nimln(924, "osproc.nim");
			nimln(924, "osproc.nim");
			if ((NU)(i) >= (NU)((*s)->Sup.len)) raiseIndexError();
			LOC4 = 0;
			LOC4 = FD_ISSET((*(*s)->data[i]).Outhandle, fd);
			if (!(LOC4 == ((NI32) 0))) goto LA5;
			nimln(925, "osproc.nim");
			if ((NU)(i) >= (NU)((*s)->Sup.len)) raiseIndexError();
			nimln(925, "osproc.nim");
			TMP384 = subInt(l, 1);
			if ((NU)((NI32)(TMP384)) >= (NU)((*s)->Sup.len)) raiseIndexError();
			asgnRef((void**) &(*s)->data[i], (*s)->data[(NI32)(TMP384)]);
			nimln(926, "osproc.nim");
			l = subInt(l, 1);
		}
		goto LA2;
		LA5: ;
		{
			nimln(928, "osproc.nim");
			i = addInt(i, 1);
		}
		LA2: ;
	} LA1: ;
	nimln(929, "osproc.nim");
	(*s) = (TY127203*) setLengthSeq(&((*s))->Sup, sizeof(tprocess126203*), l);
	popFrame();
}

N_NIMCALL(NI, select_127521)(TY127203** readfds, NI timeout) {
	NI result;
	struct timeval tv;
	NI TMP385;
	fd_set rd;
	NI m;
	nimfr("select", "osproc.nim")
	result = 0;
	memset((void*)&tv, 0, sizeof(tv));
	nimln(933, "osproc.nim");
	tv.tv_sec = 0;
	nimln(934, "osproc.nim");
	nimln(934, "osproc.nim");
	TMP385 = mulInt(timeout, 1000);
	tv.tv_usec = (NI32)(TMP385);
	memset((void*)&rd, 0, sizeof(rd));
	nimln(937, "osproc.nim");
	m = 0;
	nimln(938, "osproc.nim");
	createfdset_129402(&rd, (*readfds), &m);
	nimln(940, "osproc.nim");
	{
		NI TMP386;
		int LOC5;
		nimln(940, "osproc.nim");
		nimln(940, "osproc.nim");
		if (!!((timeout == -1))) goto LA3;
		nimln(941, "osproc.nim");
		nimln(941, "osproc.nim");
		nimln(941, "osproc.nim");
		TMP386 = addInt(m, 1);
		LOC5 = 0;
		LOC5 = select(((int) ((NI32)(TMP386))), &rd, NIM_NIL, NIM_NIL, &tv);
		result = ((NI) (LOC5));
	}
	goto LA1;
	LA3: ;
	{
		NI TMP387;
		int LOC7;
		nimln(943, "osproc.nim");
		nimln(943, "osproc.nim");
		nimln(943, "osproc.nim");
		TMP387 = addInt(m, 1);
		LOC7 = 0;
		LOC7 = select(((int) ((NI32)(TMP387))), &rd, NIM_NIL, NIM_NIL, NIM_NIL);
		result = ((NI) (LOC7));
	}
	LA1: ;
	nimln(945, "osproc.nim");
	pruneprocessset_129634(readfds, &rd);
	popFrame();
	return result;
}

N_NIMCALL(void, execcmdex_129802)(NimStringDesc* command, NU8 options, TY129808* Result) {
	tprocess126203* p;
	tstream123829* outp;
	NimStringDesc* line;
	nimfr("execCmdEx", "osproc.nim")
	nimln(954, "osproc.nim");
	p = startcmd_126434(command, options);
	nimln(955, "osproc.nim");
	outp = nospoutputStream(p);
	nimln(956, "osproc.nim");
	unsureAsgnRef((void**) &(*Result).Field0, copyString(TMP388.Field0));
	(*Result).Field1 = TMP388.Field1;
	nimln(957, "osproc.nim");
	nimln(957, "osproc.nim");
	line = rawNewString(120);
	nimln(958, "osproc.nim");
	while (1) {
		nimln(959, "osproc.nim");
		{
			NIM_BOOL LOC4;
			nimln(959, "osproc.nim");
			LOC4 = 0;
			LOC4 = readline_124204(outp, &line);
			if (!LOC4) goto LA5;
			nimln(960, "osproc.nim");
			(*Result).Field0 = resizeString((*Result).Field0, line->Sup.len + 0);
appendString((*Result).Field0, line);
			nimln(961, "osproc.nim");
			(*Result).Field0 = resizeString((*Result).Field0, 1);
appendString((*Result).Field0, ((NimStringDesc*) &TMP358));
		}
		goto LA2;
		LA5: ;
		{
			nimln(963, "osproc.nim");
			(*Result).Field1 = peekexitcode_126496(p);
			nimln(964, "osproc.nim");
			{
				nimln(964, "osproc.nim");
				nimln(964, "osproc.nim");
				if (!!(((*Result).Field1 == -1))) goto LA10;
				nimln(964, "osproc.nim");
				goto LA1;
			}
			LA10: ;
		}
		LA2: ;
	} LA1: ;
	nimln(965, "osproc.nim");
	nospclose(p);
	popFrame();
}
N_NOINLINE(void, stdlibosprocInit)(void) {
	nimfr("osproc", "osproc.nim")
	popFrame();
}

N_NOINLINE(void, stdlibosprocDatInit)(void) {
static TNimNode* TMP346[8];
static TNimNode TMP262[9];
NTI126203.size = sizeof(tprocess126203);
NTI126203.kind = 17;
NTI126203.base = (&NTI2409);
TMP346[0] = &TMP262[1];
TMP262[1].kind = 1;
TMP262[1].offset = offsetof(tprocess126203, Inhandle);
TMP262[1].typ = (&NTI10008);
TMP262[1].name = "inHandle";
TMP346[1] = &TMP262[2];
TMP262[2].kind = 1;
TMP262[2].offset = offsetof(tprocess126203, Outhandle);
TMP262[2].typ = (&NTI10008);
TMP262[2].name = "outHandle";
TMP346[2] = &TMP262[3];
TMP262[3].kind = 1;
TMP262[3].offset = offsetof(tprocess126203, Errhandle);
TMP262[3].typ = (&NTI10008);
TMP262[3].name = "errHandle";
TMP346[3] = &TMP262[4];
TMP262[4].kind = 1;
TMP262[4].offset = offsetof(tprocess126203, Instream);
TMP262[4].typ = (&NTI123827);
TMP262[4].name = "inStream";
TMP346[4] = &TMP262[5];
TMP262[5].kind = 1;
TMP262[5].offset = offsetof(tprocess126203, Outstream);
TMP262[5].typ = (&NTI123827);
TMP262[5].name = "outStream";
TMP346[5] = &TMP262[6];
TMP262[6].kind = 1;
TMP262[6].offset = offsetof(tprocess126203, Errstream);
TMP262[6].typ = (&NTI123827);
TMP262[6].name = "errStream";
TMP346[6] = &TMP262[7];
TMP262[7].kind = 1;
TMP262[7].offset = offsetof(tprocess126203, Id);
TMP262[7].typ = (&NTI96457);
TMP262[7].name = "id";
TMP346[7] = &TMP262[8];
TMP262[8].kind = 1;
TMP262[8].offset = offsetof(tprocess126203, Exitcode);
TMP262[8].typ = (&NTI4409);
TMP262[8].name = "exitCode";
TMP262[0].len = 8; TMP262[0].kind = 2; TMP262[0].sons = &TMP346[0];
NTI126203.node = &TMP262[0];
NTI126205.size = sizeof(tprocess126203*);
NTI126205.kind = 22;
NTI126205.base = (&NTI126203);
NTI126205.marker = TMP348;
NTI127203.size = sizeof(TY127203*);
NTI127203.kind = 24;
NTI127203.base = (&NTI126205);
NTI127203.marker = TMP349;
}

