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

#include <string.h>

#include <sys/types.h>

#include <unistd.h>

#include <setjmp.h>

#include <errno.h>

#include <fcntl.h>

#include <stdio.h>

#include <sys/wait.h>

#include <stdlib.h>
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Processobj143402 Processobj143402;
typedef struct Stringtableobj134012 Stringtableobj134012;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Streamobj138027 Streamobj138027;
typedef struct TY122008 TY122008;
typedef struct Tcell46347 Tcell46347;
typedef struct Tcellseq46363 Tcellseq46363;
typedef struct Tgcheap48216 Tgcheap48216;
typedef struct Tcellset46359 Tcellset46359;
typedef struct Tpagedesc46355 Tpagedesc46355;
typedef struct Tmemregion28210 Tmemregion28210;
typedef struct Tsmallchunk27440 Tsmallchunk27440;
typedef struct Tllchunk28204 Tllchunk28204;
typedef struct Tbigchunk27442 Tbigchunk27442;
typedef struct Tintset27417 Tintset27417;
typedef struct Ttrunk27413 Ttrunk27413;
typedef struct Tavlnode28208 Tavlnode28208;
typedef struct Tgcstat48214 Tgcstat48214;
typedef struct Exception Exception;
typedef struct TSafePoint TSafePoint;
typedef struct Keyvaluepairseq134010 Keyvaluepairseq134010;
typedef struct Keyvaluepair134008 Keyvaluepair134008;
typedef struct Tstartprocessdata144948 Tstartprocessdata144948;
typedef struct Filestreamobj138692 Filestreamobj138692;
typedef struct TY144201 TY144201;
typedef struct Tbasechunk27438 Tbasechunk27438;
typedef struct Tfreecell27430 Tfreecell27430;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 TY178407[32];
typedef int TY145023[2];
typedef N_NIMCALL_PTR(void, TY3289) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3294) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3289 marker;
TY3294 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Processobj143402  {
  TNimObject Sup;
int inhandle;
int outhandle;
int errhandle;
Streamobj138027* instream;
Streamobj138027* outstream;
Streamobj138027* errstream;
pid_t id;
int exitcode;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef NimStringDesc* TY176061[3];
struct  Tcell46347  {
NI refcount;
TNimType* typ;
};
struct  Tcellseq46363  {
NI len;
NI cap;
Tcell46347** d;
};
struct  Tcellset46359  {
NI counter;
NI max;
Tpagedesc46355* head;
Tpagedesc46355** data;
};
typedef Tsmallchunk27440* TY28222[512];
typedef Ttrunk27413* Ttrunkbuckets27415[256];
struct  Tintset27417  {
Ttrunkbuckets27415 data;
};
struct  Tmemregion28210  {
NI minlargeobj;
NI maxlargeobj;
TY28222 freesmallchunks;
Tllchunk28204* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Tbigchunk27442* freechunkslist;
Tintset27417 chunkstarts;
Tavlnode28208* root;
Tavlnode28208* deleted;
Tavlnode28208* last;
Tavlnode28208* freeavlnodes;
};
struct  Tgcstat48214  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Tgcheap48216  {
void* stackbottom;
NI cyclethreshold;
Tcellseq46363 zct;
Tcellseq46363 decstack;
Tcellset46359 cycleroots;
Tcellseq46363 tempstack;
NI recgclock;
Tmemregion28210 region;
Tgcstat48214 stat;
};
typedef NimStringDesc* TY164566[1];
struct  Exception  {
  TNimObject Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
typedef struct {
N_NIMCALL_PTR(NIM_BOOL, ClPrc) (Exception* e, void* ClEnv);
void* ClEnv;
} TY15609;
struct  TSafePoint  {
TSafePoint* prev;
NI status;
jmp_buf context;
NIM_BOOL hasRaiseAction;
TY15609 raiseAction;
};
struct  Stringtableobj134012  {
  TNimObject Sup;
NI counter;
Keyvaluepairseq134010* data;
NU8 mode;
};
struct Keyvaluepair134008 {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
struct  Tstartprocessdata144948  {
NCSTRING syscommand;
NCSTRING* sysargs;
NCSTRING* sysenv;
NCSTRING workingdir;
TY145023 pstdin;
TY145023 pstdout;
TY145023 pstderr;
TY145023 perrorpipe;
NIM_BOOL optionpousepath;
NIM_BOOL optionpoparentstreams;
NIM_BOOL optionpostderrtostdout;
};
typedef struct {
N_NIMCALL_PTR(void, ClPrc) (NI idx, void* ClEnv);
void* ClEnv;
} TY171642;
typedef N_CLOSURE_PTR(void, TMP4339) (NI idx);
typedef NimStringDesc* TY218714[1];
typedef N_CLOSURE_PTR(void, TMP4341) (NI idx);
typedef N_CLOSURE_PTR(void, TMP4342) (NI idx);
typedef N_NIMCALL_PTR(void, TY138028) (Streamobj138027* s);
typedef N_NIMCALL_PTR(NIM_BOOL, TY138032) (Streamobj138027* s);
typedef N_NIMCALL_PTR(void, TY138036) (Streamobj138027* s, NI pos);
typedef N_NIMCALL_PTR(NI, TY138041) (Streamobj138027* s);
typedef N_NIMCALL_PTR(NI, TY138045) (Streamobj138027* s, void* buffer, NI buflen);
typedef N_NIMCALL_PTR(void, TY138051) (Streamobj138027* s, void* buffer, NI buflen);
typedef N_NIMCALL_PTR(void, TY138057) (Streamobj138027* s);
struct  Streamobj138027  {
  TNimObject Sup;
TY138028 closeimpl;
TY138032 atendimpl;
TY138036 setpositionimpl;
TY138041 getpositionimpl;
TY138045 readdataimpl;
TY138051 writedataimpl;
TY138057 flushimpl;
};
typedef NI TY27420[16];
struct  Tpagedesc46355  {
Tpagedesc46355* next;
NI key;
TY27420 bits;
};
struct  Tbasechunk27438  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Tsmallchunk27440  {
  Tbasechunk27438 Sup;
Tsmallchunk27440* next;
Tsmallchunk27440* prev;
Tfreecell27430* freelist;
NI free;
NI acc;
NF data;
};
struct  Tllchunk28204  {
NI size;
NI acc;
Tllchunk28204* next;
};
struct  Tbigchunk27442  {
  Tbasechunk27438 Sup;
Tbigchunk27442* next;
Tbigchunk27442* prev;
NI align;
NF data;
};
struct  Ttrunk27413  {
Ttrunk27413* next;
NI key;
TY27420 bits;
};
typedef Tavlnode28208* TY28214[2];
struct  Tavlnode28208  {
TY28214 link;
NI key;
NI upperbound;
NI level;
};
struct  Filestreamobj138692  {
  Streamobj138027 Sup;
FILE* f;
};
struct  Tfreecell27430  {
Tfreecell27430* next;
NI zerofield;
};
struct TY122008 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
struct TY144201 {
  TGenericSeq Sup;
  Processobj143402* data[SEQ_DECL_SIZE];
};
struct Keyvaluepairseq134010 {
  TGenericSeq Sup;
  Keyvaluepair134008 data[SEQ_DECL_SIZE];
};
N_NIMCALL(NimStringDesc*, nospquoteShellPosix)(NimStringDesc* s);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(NIM_BOOL, allcharsinset_98459)(NimStringDesc* s, TY178407 theset);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, nsuReplaceStr)(NimStringDesc* s, NimStringDesc* sub, NimStringDesc* by);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP2888)(void* p, NI op);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(void, raiseoserror_116809)(NI32 errorcode);
N_NIMCALL(NI32, oslasterror_116833)(void);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(Tcell46347*, usrtocell_49846)(void* usr);
static N_INLINE(void, rtladdzct_51404)(Tcell46347* c);
N_NOINLINE(void, addzct_49817)(Tcellseq46363* s, Tcell46347* c);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(NCSTRING*, alloccstringarray_14001)(NimStringDesc** a, NI aLen0);
static N_INLINE(void, pushSafePoint)(TSafePoint* s);
N_NIMCALL(NCSTRING*, envtocstringarray_144854)(void);
N_NIMCALL(void, getenvvarsc_122202)(void);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_76243, 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_NOCONV(void*, alloc0_6017)(NI size);
N_NOCONV(void*, alloc_6001)(NI size);
N_NIMCALL(NCSTRING*, envtocstringarray_144806)(Stringtableobj134012* t);
N_NIMCALL(NI, nstlen)(Stringtableobj134012* t);
N_NIMCALL(pid_t, startprocessauxfork_145001)(Tstartprocessdata144948* data);
N_CDECL(void, startprocessafterfork_145004)(Tstartprocessdata144948* data);
N_NIMCALL(void, startprocessfail_145824)(Tstartprocessdata144948* data);
N_NOINLINE(void, nosraiseOSError)(NimStringDesc* msg);
N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
static N_INLINE(void, popSafePoint)(void);
N_NIMCALL(void, reraiseException)(void);
N_NIMCALL(NimStringDesc*, nsuJoinSep)(NimStringDesc** a, NI aLen0, NimStringDesc* sep);
N_NIMCALL(void, dealloccstringarray_14250)(NCSTRING* a);
N_NIMCALL(void, createstream_146641)(Streamobj138027** stream, int* handle, NU8 filemode);
N_NIMCALL(NIM_BOOL, open_13211)(FILE** f, int filehandle, NU8 mode);
N_NIMCALL(Filestreamobj138692*, newfilestream_138758)(FILE* f);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_NIMCALL(NI, ncpicountProcessors)(void);
N_NIMCALL(void, TMP4337)(void* p, NI op);
N_NIMCALL(Processobj143402*, nospstartProcess)(NimStringDesc* command, NimStringDesc* workingdir, NimStringDesc** args, NI argsLen0, Stringtableobj134012* env, NU8 options);
static N_INLINE(void, asgnRef)(void** dest, void* src);
static N_INLINE(void, incref_52222)(Tcell46347* c);
static N_INLINE(NIM_BOOL, canbecycleroot_49867)(Tcell46347* c);
static N_INLINE(void, rtladdcycleroot_50623)(Tcell46347* c);
N_NOINLINE(void, incl_47065)(Tcellset46359* s, Tcell46347* cell);
static N_INLINE(void, decref_51804)(Tcell46347* c);
N_NIMCALL(void, nossleep)(NI milsecs);
N_NIMCALL(NIM_BOOL, nosprunning)(Processobj143402* p);
N_NIMCALL(NI, nospwaitForExit)(Processobj143402* p, NI timeout);
N_NIMCALL(void, nospclose)(Processobj143402* p);
N_NIMCALL(void, close_138085)(Streamobj138027* s);
STRING_LITERAL(TMP1766, "\'\'", 2);
static NIM_CONST TY178407 TMP1767 = {
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(TMP1768, "\'", 1);
STRING_LITERAL(TMP1769, "\'\"\'\"\'", 5);
STRING_LITERAL(TMP2889, "/bin/sh", 7);
STRING_LITERAL(TMP2890, "-c", 2);
STRING_LITERAL(TMP2892, "=", 1);
STRING_LITERAL(TMP2895, " ", 1);
static NIM_CONST TY171642 TMP4338 = {NIM_NIL,NIM_NIL};
STRING_LITERAL(TMP4340, "", 0);
extern TNimType NTI3411; /* RootObj */
TNimType NTI143402; /* ProcessObj */
extern TNimType NTI13008; /* FileHandle */
extern TNimType NTI138025; /* Stream */
extern TNimType NTI107285; /* TPid */
extern TNimType NTI5811; /* cint */
TNimType NTI143404; /* Process */
extern TNimType NTI122008; /* seq[string] */
extern Tgcheap48216 gch_48244;
extern TSafePoint* exchandler_17043;
extern TY122008* environment_122009;
TNimType NTI144201; /* seq[Process] */

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

N_NIMCALL(NimStringDesc*, nospquoteShellPosix)(NimStringDesc* s) {
	NimStringDesc* result;
	NIM_BOOL safe;
{	result = 0;
	{
		if (!((s ? s->Sup.len : 0) == ((NI) 0))) goto LA3;
		result = copyString(((NimStringDesc*) &TMP1766));
		goto BeforeRet;
	}
	LA3: ;
	safe = allcharsinset_98459(s, TMP1767);
	{
		if (!safe) goto LA7;
		result = copyString(s);
		goto BeforeRet;
	}
	goto LA5;
	LA7: ;
	{
		NimStringDesc* LOC10;
		NimStringDesc* LOC11;
		LOC10 = 0;
		LOC11 = 0;
		LOC11 = nsuReplaceStr(s, ((NimStringDesc*) &TMP1768), ((NimStringDesc*) &TMP1769));
		LOC10 = rawNewString(LOC11->Sup.len + 2);
appendString(LOC10, ((NimStringDesc*) &TMP1768));
appendString(LOC10, LOC11);
appendString(LOC10, ((NimStringDesc*) &TMP1768));
		result = LOC10;
		goto BeforeRet;
	}
	LA5: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nospquoteShell)(NimStringDesc* s) {
	NimStringDesc* result;
{	result = 0;
	result = nospquoteShellPosix(s);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}
N_NIMCALL(void, TMP2888)(void* p, NI op) {
	Processobj143402* a;
	a = (Processobj143402*)p;
	nimGCvisit((void*)(*a).instream, op);
	nimGCvisit((void*)(*a).outstream, op);
	nimGCvisit((void*)(*a).errstream, op);
}

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

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

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

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

N_NIMCALL(NCSTRING*, envtocstringarray_144854)(void) {
	NCSTRING* result;
	NI counter;
	void* LOC5;
	NI i;
	result = 0;
	counter = ((NI) 0);
	{
		NimStringDesc* key_144858;
		NimStringDesc* val_144859;
		key_144858 = 0;
		val_144859 = 0;
		getenvvarsc_122202();
		{
			NI i_144888;
			NI HEX3Atmp_144890;
			NI res_144892;
			i_144888 = 0;
			HEX3Atmp_144890 = 0;
			HEX3Atmp_144890 = (environment_122009 ? (environment_122009->Sup.len-1) : -1);
			res_144892 = ((NI) 0);
			{
				while (1) {
					NI p_144896;
					if (!(res_144892 <= HEX3Atmp_144890)) goto LA4;
					i_144888 = res_144892;
					p_144896 = nsuFindChar(environment_122009->data[i_144888], 61, ((NI) 0));
					key_144858 = copyStrLast(environment_122009->data[i_144888], ((NI) 0), (NI)(p_144896 - ((NI) 1)));
					val_144859 = copyStr(environment_122009->data[i_144888], (NI)(p_144896 + ((NI) 1)));
					counter += ((NI) 1);
					res_144892 += ((NI) 1);
				} LA4: ;
			}
		}
	}
	LOC5 = 0;
	LOC5 = alloc0_6017(((NI) ((NI)((NI)(counter + ((NI) 1)) * ((NI) 4)))));
	result = ((NCSTRING*) (LOC5));
	i = ((NI) 0);
	{
		NimStringDesc* key_144871;
		NimStringDesc* val_144872;
		key_144871 = 0;
		val_144872 = 0;
		getenvvarsc_122202();
		{
			NI i_144909;
			NI HEX3Atmp_144911;
			NI res_144913;
			i_144909 = 0;
			HEX3Atmp_144911 = 0;
			HEX3Atmp_144911 = (environment_122009 ? (environment_122009->Sup.len-1) : -1);
			res_144913 = ((NI) 0);
			{
				while (1) {
					NI p_144917;
					NimStringDesc* x;
					NimStringDesc* LOC10;
					void* LOC11;
					if (!(res_144913 <= HEX3Atmp_144911)) goto LA9;
					i_144909 = res_144913;
					p_144917 = nsuFindChar(environment_122009->data[i_144909], 61, ((NI) 0));
					key_144871 = copyStrLast(environment_122009->data[i_144909], ((NI) 0), (NI)(p_144917 - ((NI) 1)));
					val_144872 = copyStr(environment_122009->data[i_144909], (NI)(p_144917 + ((NI) 1)));
					LOC10 = 0;
					LOC10 = rawNewString(key_144871->Sup.len + val_144872->Sup.len + 1);
appendString(LOC10, key_144871);
appendString(LOC10, ((NimStringDesc*) &TMP2892));
appendString(LOC10, val_144872);
					x = LOC10;
					LOC11 = 0;
					LOC11 = alloc_6001(((NI) ((NI)((x ? x->Sup.len : 0) + ((NI) 1)))));
					result[(i)- 0] = ((NCSTRING) (LOC11));
					memcpy(((void*) (result[(i)- 0])), ((void*) ((&x->data[((NI) 0)]))), ((NI) ((NI)((x ? x->Sup.len : 0) + ((NI) 1)))));
					i += ((NI) 1);
					res_144913 += ((NI) 1);
				} LA9: ;
			}
		}
	}
	return result;
}

N_NIMCALL(NCSTRING*, envtocstringarray_144806)(Stringtableobj134012* t) {
	NCSTRING* result;
	NI LOC1;
	void* LOC2;
	NI i;
	result = 0;
	LOC1 = 0;
	LOC1 = nstlen(t);
	LOC2 = 0;
	LOC2 = alloc0_6017(((NI) ((NI)((NI)(LOC1 + ((NI) 1)) * ((NI) 4)))));
	result = ((NCSTRING*) (LOC2));
	i = ((NI) 0);
	{
		NimStringDesc* key_144812;
		NimStringDesc* val_144813;
		key_144812 = 0;
		val_144813 = 0;
		{
			NI h_144832;
			NI HEX3Atmp_144834;
			NI res_144836;
			h_144832 = 0;
			HEX3Atmp_144834 = 0;
			HEX3Atmp_144834 = ((*t).data ? ((*t).data->Sup.len-1) : -1);
			res_144836 = ((NI) 0);
			{
				while (1) {
					if (!(res_144836 <= HEX3Atmp_144834)) goto LA6;
					h_144832 = res_144836;
					{
						NimStringDesc* x;
						NimStringDesc* LOC11;
						void* LOC12;
						if (!!((*t).data->data[h_144832].Field0 == 0)) goto LA9;
						key_144812 = (*t).data->data[h_144832].Field0;
						val_144813 = (*t).data->data[h_144832].Field1;
						LOC11 = 0;
						LOC11 = rawNewString(key_144812->Sup.len + val_144813->Sup.len + 1);
appendString(LOC11, key_144812);
appendString(LOC11, ((NimStringDesc*) &TMP2892));
appendString(LOC11, val_144813);
						x = LOC11;
						LOC12 = 0;
						LOC12 = alloc_6001(((NI) ((NI)((x ? x->Sup.len : 0) + ((NI) 1)))));
						result[(i)- 0] = ((NCSTRING) (LOC12));
						memcpy(((void*) (result[(i)- 0])), ((void*) ((&x->data[((NI) 0)]))), ((NI) ((NI)((x ? x->Sup.len : 0) + ((NI) 1)))));
						i += ((NI) 1);
					}
					LA9: ;
					res_144836 += ((NI) 1);
				} LA6: ;
			}
		}
	}
	return result;
}

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

N_CDECL(void, startprocessafterfork_145004)(Tstartprocessdata144948* data) {
	int LOC42;
	int LOC43;
	{
		int LOC5;
		int LOC11;
		int LOC17;
		if (!!((*data).optionpoparentstreams)) goto LA3;
		LOC5 = 0;
		LOC5 = close((*data).pstdin[(((NI) 1))- 0]);
		{
			int LOC8;
			LOC8 = 0;
			LOC8 = dup2((*data).pstdin[(((NI) 0))- 0], ((int) 0));
			if (!(LOC8 < ((NI32) 0))) goto LA9;
			startprocessfail_145824(data);
		}
		LA9: ;
		LOC11 = 0;
		LOC11 = close((*data).pstdout[(((NI) 0))- 0]);
		{
			int LOC14;
			LOC14 = 0;
			LOC14 = dup2((*data).pstdout[(((NI) 1))- 0], ((int) 1));
			if (!(LOC14 < ((NI32) 0))) goto LA15;
			startprocessfail_145824(data);
		}
		LA15: ;
		LOC17 = 0;
		LOC17 = close((*data).pstderr[(((NI) 0))- 0]);
		{
			if (!(*data).optionpostderrtostdout) goto LA20;
			{
				int LOC24;
				LOC24 = 0;
				LOC24 = dup2((*data).pstdout[(((NI) 1))- 0], ((int) 2));
				if (!(LOC24 < ((NI32) 0))) goto LA25;
				startprocessfail_145824(data);
			}
			LA25: ;
		}
		goto LA18;
		LA20: ;
		{
			{
				int LOC30;
				LOC30 = 0;
				LOC30 = dup2((*data).pstderr[(((NI) 1))- 0], ((int) 2));
				if (!(LOC30 < ((NI32) 0))) goto LA31;
				startprocessfail_145824(data);
			}
			LA31: ;
		}
		LA18: ;
	}
	LA3: ;
	{
		if (!(((NI) 0) < ((*data).workingdir ? strlen((*data).workingdir) : 0))) goto LA35;
		{
			int LOC39;
			LOC39 = 0;
			LOC39 = chdir((*data).workingdir);
			if (!(LOC39 < ((NI32) 0))) goto LA40;
			startprocessfail_145824(data);
		}
		LA40: ;
	}
	LA35: ;
	LOC42 = 0;
	LOC42 = close((*data).perrorpipe[(((NI) 0))- 0]);
	LOC43 = 0;
	LOC43 = fcntl((*data).perrorpipe[(((NI) 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_145824(data);
}

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

N_NIMCALL(pid_t, startprocessauxfork_145001)(Tstartprocessdata144948* data) {
	pid_t volatile result;
	TSafePoint TMP2894;
{	result = 0;
	{
		int LOC3;
		NI32 LOC6;
		LOC3 = 0;
		LOC3 = pipe((*data).perrorpipe);
		if (!!((LOC3 == ((NI32) 0)))) goto LA4;
		LOC6 = 0;
		LOC6 = oslasterror_116833();
		raiseoserror_116809(LOC6);
	}
	LA4: ;
	pushSafePoint(&TMP2894);
	TMP2894.status = setjmp(TMP2894.context);
	if (TMP2894.status == 0) {
		pid_t volatile pid;
		Tstartprocessdata144948 datacopy;
		int LOC12;
		int error;
		NI sizeread;
		int LOC24;
		pid = 0;
		datacopy = (*data);
		pid = fork();
		{
			if (!(pid == ((NI) 0))) goto LA10;
			startprocessafterfork_145004((&datacopy));
			_exit(((NI) 1));
		}
		LA10: ;
		LOC12 = 0;
		LOC12 = close((*data).perrorpipe[(((NI) 1))- 0]);
		{
			NI32 LOC17;
			if (!(pid < ((NI) 0))) goto LA15;
			LOC17 = 0;
			LOC17 = oslasterror_116833();
			raiseoserror_116809(LOC17);
		}
		LA15: ;
		error = 0;
		sizeread = read((*data).perrorpipe[(((NI) 0))- 0], ((void*) ((&error))), ((NI) 4));
		{
			NCSTRING LOC22;
			NimStringDesc* LOC23;
			if (!(sizeread == ((NI) 4))) goto LA20;
			LOC22 = 0;
			LOC22 = strerror(error);
			LOC23 = 0;
			LOC23 = cstrToNimstr(LOC22);
			nosraiseOSError(LOC23);
		}
		LA20: ;
		result = pid;
		popSafePoint();
		LOC24 = 0;
		LOC24 = close((*data).perrorpipe[(((NI) 0))- 0]);
		goto BeforeRet;
		popSafePoint();
	}
	else {
		popSafePoint();
	}
	{
		int LOC27;
		LOC27 = 0;
		LOC27 = close((*data).perrorpipe[(((NI) 0))- 0]);
	}
	if (TMP2894.status != 0) reraiseException();
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Processobj143402*, nospstartProcess)(NimStringDesc* command, NimStringDesc* workingdir, NimStringDesc** args, NI argsLen0, Stringtableobj134012* env, NU8 options) {
	Processobj143402* result;
	TY145023 pstdin;
	TY145023 pstdout;
	TY145023 pstderr;
	NimStringDesc* syscommand;
	TY122008* sysargsraw;
	pid_t volatile pid;
	NCSTRING* sysargs;
	TSafePoint TMP2891;
	result = 0;
	memset((void*)pstdin, 0, sizeof(pstdin));
	memset((void*)pstdout, 0, sizeof(pstdout));
	memset((void*)pstderr, 0, sizeof(pstderr));
	result = (Processobj143402*) newObj((&NTI143404), sizeof(Processobj143402));
	(*result).Sup.m_type = (&NTI143402);
	(*result).exitcode = ((int) -3);
	{
		if (!!(((options &(1<<((((NU8) 4))&7)))!=0))) goto LA3;
		{
			NIM_BOOL LOC7;
			NIM_BOOL LOC8;
			int LOC9;
			int LOC11;
			int LOC13;
			NI32 LOC16;
			LOC7 = 0;
			LOC8 = 0;
			LOC9 = 0;
			LOC9 = pipe(pstdin);
			LOC8 = !((LOC9 == ((NI32) 0)));
			if (LOC8) goto LA10;
			LOC11 = 0;
			LOC11 = pipe(pstdout);
			LOC8 = !((LOC11 == ((NI32) 0)));
			LA10: ;
			LOC7 = LOC8;
			if (LOC7) goto LA12;
			LOC13 = 0;
			LOC13 = pipe(pstderr);
			LOC7 = !((LOC13 == ((NI32) 0)));
			LA12: ;
			if (!LOC7) goto LA14;
			LOC16 = 0;
			LOC16 = oslasterror_116833();
			raiseoserror_116809(LOC16);
		}
		LA14: ;
	}
	LA3: ;
	syscommand = 0;
	sysargsraw = 0;
	{
		TY176061 LOC21;
		NimStringDesc* LOC22;
		NimStringDesc* LOC23;
		NimStringDesc* LOC24;
		if (!((options &(1<<((((NU8) 2))&7)))!=0)) goto LA19;
		syscommand = copyString(((NimStringDesc*) &TMP2889));
		sysargsraw = (TY122008*) newSeq((&NTI122008), 3);
		memset((void*)LOC21, 0, sizeof(LOC21));
		LOC21[0] = copyString(syscommand);
		LOC21[1] = copyString(((NimStringDesc*) &TMP2890));
		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);
	}
	goto LA17;
	LA19: ;
	{
		TY164566 LOC26;
		NimStringDesc* LOC27;
		syscommand = copyString(command);
		sysargsraw = (TY122008*) newSeq((&NTI122008), 1);
		memset((void*)LOC26, 0, sizeof(LOC26));
		LOC26[0] = copyString(command);
		LOC27 = 0;
		LOC27 = sysargsraw->data[0]; sysargsraw->data[0] = copyStringRC1(LOC26[0]);
		if (LOC27) nimGCunrefNoCycle(LOC27);
		{
			NimStringDesc* arg_145222;
			NI i_145479;
			arg_145222 = 0;
			i_145479 = ((NI) 0);
			{
				while (1) {
					NimStringDesc* LOC31;
					if (!(i_145479 < argsLen0)) goto LA30;
					arg_145222 = args[i_145479];
					sysargsraw = (TY122008*) incrSeq(&(sysargsraw)->Sup, sizeof(NimStringDesc*));
					LOC31 = 0;
					LOC31 = sysargsraw->data[sysargsraw->Sup.len-1]; sysargsraw->data[sysargsraw->Sup.len-1] = copyStringRC1(arg_145222);
					if (LOC31) nimGCunrefNoCycle(LOC31);
					i_145479 += ((NI) 1);
				} LA30: ;
			}
		}
	}
	LA17: ;
	pid = 0;
	sysargs = alloccstringarray_14001(sysargsraw->data, sysargsraw->Sup.len);
	pushSafePoint(&TMP2891);
	TMP2891.status = setjmp(TMP2891.context);
	if (TMP2891.status == 0) {
		NCSTRING* sysenv;
		TSafePoint TMP2893;
		{
			if (!(env == NIM_NIL)) goto LA35;
			sysenv = envtocstringarray_144854();
		}
		goto LA33;
		LA35: ;
		{
			sysenv = envtocstringarray_144806(env);
		}
		LA33: ;
		pushSafePoint(&TMP2893);
		TMP2893.status = setjmp(TMP2893.context);
		if (TMP2893.status == 0) {
			Tstartprocessdata144948 data;
			memset((void*)(&data), 0, sizeof(data));
			data.syscommand = syscommand->data;
			data.sysargs = sysargs;
			data.sysenv = sysenv;
			memcpy((void*)data.pstdin, (NIM_CONST void*)pstdin, sizeof(data.pstdin));
			memcpy((void*)data.pstdout, (NIM_CONST void*)pstdout, sizeof(data.pstdout));
			memcpy((void*)data.pstderr, (NIM_CONST void*)pstderr, sizeof(data.pstderr));
			data.optionpoparentstreams = ((options &(1<<((((NU8) 4))&7)))!=0);
			data.optionpousepath = ((options &(1<<((((NU8) 1))&7)))!=0);
			data.optionpostderrtostdout = ((options &(1<<((((NU8) 3))&7)))!=0);
			data.workingdir = workingdir->data;
			pid = startprocessauxfork_145001((&data));
			{
				NimStringDesc* LOC43;
				if (!((options &(1<<((((NU8) 0))&7)))!=0)) goto LA41;
				LOC43 = 0;
				LOC43 = nsuJoinSep(args, argsLen0, ((NimStringDesc*) &TMP2895));
				printf("%s%s%s\012", command? (command)->data:"nil", ((NimStringDesc*) &TMP2895)? (((NimStringDesc*) &TMP2895))->data:"nil", LOC43? (LOC43)->data:"nil");
			}
			LA41: ;
			(*result).id = pid;
			{
				if (!((options &(1<<((((NU8) 4))&7)))!=0)) goto LA46;
				(*result).inhandle = ((int) 0);
				(*result).outhandle = ((int) 1);
				{
					if (!((options &(1<<((((NU8) 3))&7)))!=0)) goto LA50;
					(*result).errhandle = (*result).outhandle;
				}
				goto LA48;
				LA50: ;
				{
					(*result).errhandle = ((int) 2);
				}
				LA48: ;
			}
			goto LA44;
			LA46: ;
			{
				int LOC60;
				int LOC61;
				int LOC62;
				(*result).inhandle = pstdin[(((NI) 1))- 0];
				(*result).outhandle = pstdout[(((NI) 0))- 0];
				{
					int LOC58;
					if (!((options &(1<<((((NU8) 3))&7)))!=0)) goto LA56;
					(*result).errhandle = (*result).outhandle;
					LOC58 = 0;
					LOC58 = close(pstderr[(((NI) 0))- 0]);
				}
				goto LA54;
				LA56: ;
				{
					(*result).errhandle = pstderr[(((NI) 0))- 0];
				}
				LA54: ;
				LOC60 = 0;
				LOC60 = close(pstderr[(((NI) 1))- 0]);
				LOC61 = 0;
				LOC61 = close(pstdin[(((NI) 0))- 0]);
				LOC62 = 0;
				LOC62 = close(pstdout[(((NI) 1))- 0]);
			}
			LA44: ;
			popSafePoint();
		}
		else {
			popSafePoint();
		}
		{
			dealloccstringarray_14250(sysenv);
		}
		if (TMP2893.status != 0) reraiseException();
		popSafePoint();
	}
	else {
		popSafePoint();
	}
	{
		dealloccstringarray_14250(sysargs);
	}
	if (TMP2891.status != 0) reraiseException();
	return result;
}

N_NIMCALL(void, createstream_146641)(Streamobj138027** stream, int* handle, NU8 filemode) {
	FILE* f;
	Filestreamobj138692* LOC7;
	f = 0;
	{
		NIM_BOOL LOC3;
		NI32 LOC6;
		LOC3 = 0;
		LOC3 = open_13211(&f, (*handle), filemode);
		if (!!(LOC3)) goto LA4;
		LOC6 = 0;
		LOC6 = oslasterror_116833();
		raiseoserror_116809(LOC6);
	}
	LA4: ;
	LOC7 = 0;
	LOC7 = newfilestream_138758(f);
	unsureAsgnRef((void**) (&(*stream)), &LOC7->Sup);
}

N_NIMCALL(Streamobj138027*, nospinputStream)(Processobj143402* p) {
	Streamobj138027* result;
{	result = 0;
	{
		if (!((*p).instream == NIM_NIL)) goto LA3;
		createstream_146641(&(*p).instream, (&(*p).inhandle), ((NU8) 1));
	}
	LA3: ;
	result = (*p).instream;
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Streamobj138027*, nospoutputStream)(Processobj143402* p) {
	Streamobj138027* result;
{	result = 0;
	{
		if (!((*p).outstream == NIM_NIL)) goto LA3;
		createstream_146641(&(*p).outstream, (&(*p).outhandle), ((NU8) 0));
	}
	LA3: ;
	result = (*p).outstream;
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NI, nospwaitForExit)(Processobj143402* p, NI timeout) {
	NI result;
{	result = 0;
	{
		if (!!(((*p).exitcode == ((NI32) -3)))) goto LA3;
		result = ((NI) ((*p).exitcode));
		goto BeforeRet;
	}
	LA3: ;
	{
		pid_t LOC7;
		NI32 LOC10;
		LOC7 = 0;
		LOC7 = waitpid((*p).id, (&(*p).exitcode), ((int) 0));
		if (!(LOC7 < ((NI) 0))) goto LA8;
		(*p).exitcode = ((int) -3);
		LOC10 = 0;
		LOC10 = oslasterror_116833();
		raiseoserror_116809(LOC10);
	}
	LA8: ;
	result = (NI)((NU32)(((NI) ((*p).exitcode))) >> (NU32)(((NI) 8)));
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NI, nospcountProcessors)(void) {
	NI result;
	result = 0;
	result = ncpicountProcessors();
	return result;
}

N_NIMCALL(NI, nospexecCmd)(NimStringDesc* command) {
	NI result;
	int LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = system(command->data);
	result = ((NI) (LOC1));
	return result;
}
N_NIMCALL(void, TMP4337)(void* p, NI op) {
	TY144201* a;
	NI LOC1;
	a = (TY144201*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1], op);
	}
}

static N_INLINE(NIM_BOOL, canbecycleroot_49867)(Tcell46347* c) {
	NIM_BOOL result;
	result = 0;
	result = !((((*(*c).typ).flags &(1<<((((NU8) 1))&7)))!=0));
	return result;
}

static N_INLINE(void, rtladdcycleroot_50623)(Tcell46347* c) {
	{
		if (!!((((NI) ((NI)((*c).refcount & ((NI) 3)))) == ((NI) 3)))) goto LA3;
		(*c).refcount = (NI)((NI)((*c).refcount & ((NI) -4)) | ((NI) 3));
		incl_47065((&gch_48244.cycleroots), c);
	}
	LA3: ;
}

static N_INLINE(void, incref_52222)(Tcell46347* c) {
	(*c).refcount = (NI)((NU32)((*c).refcount) + (NU32)(((NI) 8)));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = canbecycleroot_49867(c);
		if (!LOC3) goto LA4;
		rtladdcycleroot_50623(c);
	}
	LA4: ;
}

static N_INLINE(void, decref_51804)(Tcell46347* c) {
	{
		(*c).refcount -= ((NI) 8);
		if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA3;
		rtladdzct_51404(c);
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC6;
		LOC6 = 0;
		LOC6 = canbecycleroot_49867(c);
		if (!LOC6) goto LA7;
		rtladdcycleroot_50623(c);
	}
	goto LA1;
	LA7: ;
	LA1: ;
}

static N_INLINE(void, asgnRef)(void** dest, void* src) {
	{
		Tcell46347* LOC5;
		if (!!((src == NIM_NIL))) goto LA3;
		LOC5 = 0;
		LOC5 = usrtocell_49846(src);
		incref_52222(LOC5);
	}
	LA3: ;
	{
		Tcell46347* LOC10;
		if (!!(((*dest) == NIM_NIL))) goto LA8;
		LOC10 = 0;
		LOC10 = usrtocell_49846((*dest));
		decref_51804(LOC10);
	}
	LA8: ;
	(*dest) = src;
}

N_NIMCALL(NIM_BOOL, nosprunning)(Processobj143402* p) {
	NIM_BOOL result;
	NI ret;
{	result = 0;
	ret = 0;
	ret = waitpid((*p).id, (&(*p).exitcode), WNOHANG);
	{
		if (!(ret == ((NI) 0))) goto LA3;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA3: ;
	result = (ret == (*p).id);
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, nospclose)(Processobj143402* p) {
	int LOC13;
	int LOC14;
	int LOC15;
	{
		if (!!(((*p).instream == NIM_NIL))) goto LA3;
		close_138085((*p).instream);
	}
	LA3: ;
	{
		if (!!(((*p).outstream == NIM_NIL))) goto LA7;
		close_138085((*p).outstream);
	}
	LA7: ;
	{
		if (!!(((*p).errstream == NIM_NIL))) goto LA11;
		close_138085((*p).errstream);
	}
	LA11: ;
	LOC13 = 0;
	LOC13 = close((*p).inhandle);
	LOC14 = 0;
	LOC14 = close((*p).outhandle);
	LOC15 = 0;
	LOC15 = close((*p).errhandle);
}

N_NIMCALL(NI, nospexecProcesses)(NimStringDesc** cmds, NI cmdsLen0, NU8 options_143793, NI n, TY171642 beforerunevent) {
	NI result;
	NU8 options;
	result = 0;
	options = (options_143793 & ~ 16);
	{
		TY144201* q;
		NI m;
		NI i;
		if (!(((NI) 1) < n)) goto LA3;
		q = 0;
		q = (TY144201*) newSeq((&NTI144201), ((NI) (n)));
		m = ((n <= cmdsLen0) ? n : cmdsLen0);
		{
			NI i_144235;
			NI HEX3Atmp_144528;
			NI res_144531;
			i_144235 = 0;
			HEX3Atmp_144528 = 0;
			HEX3Atmp_144528 = (NI)(m - ((NI) 1));
			res_144531 = ((NI) 0);
			{
				while (1) {
					TY218714 LOC12;
					if (!(res_144531 <= HEX3Atmp_144528)) goto LA7;
					i_144235 = res_144531;
					{
						if (!!((beforerunevent.ClPrc == TMP4338.ClPrc && beforerunevent.ClEnv == TMP4338.ClEnv))) goto LA10;
						beforerunevent.ClEnv? beforerunevent.ClPrc(i_144235, beforerunevent.ClEnv):((TMP4339)(beforerunevent.ClPrc))(i_144235);
					}
					LA10: ;
					memset((void*)LOC12, 0, sizeof(LOC12));
					asgnRef((void**) (&q->data[i_144235]), nospstartProcess(cmds[i_144235], ((NimStringDesc*) &TMP4340), LOC12, 0, NIM_NIL, (options | 4)));
					res_144531 += ((NI) 1);
				} LA7: ;
			}
		}
		i = m;
		{
			while (1) {
				if (!(i <= (cmdsLen0-1))) goto LA14;
				nossleep(((NI) 50));
				{
					NI r_144413;
					NI HEX3Atmp_144537;
					NI res_144540;
					r_144413 = 0;
					HEX3Atmp_144537 = 0;
					HEX3Atmp_144537 = (NI)(n - ((NI) 1));
					res_144540 = ((NI) 0);
					{
						while (1) {
							if (!(res_144540 <= HEX3Atmp_144537)) goto LA17;
							r_144413 = res_144540;
							{
								NIM_BOOL LOC20;
								NI LOC23;
								TY218714 LOC32;
								LOC20 = 0;
								LOC20 = nosprunning(q->data[r_144413]);
								if (!!(LOC20)) goto LA21;
								LOC23 = 0;
								LOC23 = nospwaitForExit(q->data[r_144413], ((NI) -1));
								result = ((LOC23 >= result) ? LOC23 : result);
								{
									if (!!((q->data[r_144413] == NIM_NIL))) goto LA26;
									nospclose(q->data[r_144413]);
								}
								LA26: ;
								{
									if (!!((beforerunevent.ClPrc == TMP4338.ClPrc && beforerunevent.ClEnv == TMP4338.ClEnv))) goto LA30;
									beforerunevent.ClEnv? beforerunevent.ClPrc(i, beforerunevent.ClEnv):((TMP4341)(beforerunevent.ClPrc))(i);
								}
								LA30: ;
								memset((void*)LOC32, 0, sizeof(LOC32));
								asgnRef((void**) (&q->data[r_144413]), nospstartProcess(cmds[i], ((NimStringDesc*) &TMP4340), LOC32, 0, NIM_NIL, (options | 4)));
								i += ((NI) 1);
								{
									if (!((cmdsLen0-1) < i)) goto LA35;
									goto LA15;
								}
								LA35: ;
							}
							LA21: ;
							res_144540 += ((NI) 1);
						} LA17: ;
					}
				} LA15: ;
			} LA14: ;
		}
		{
			NI j_144471;
			NI HEX3Atmp_144545;
			NI res_144548;
			j_144471 = 0;
			HEX3Atmp_144545 = 0;
			HEX3Atmp_144545 = (NI)(m - ((NI) 1));
			res_144548 = ((NI) 0);
			{
				while (1) {
					NI LOC40;
					if (!(res_144548 <= HEX3Atmp_144545)) goto LA39;
					j_144471 = res_144548;
					LOC40 = 0;
					LOC40 = nospwaitForExit(q->data[j_144471], ((NI) -1));
					result = ((LOC40 >= result) ? LOC40 : result);
					{
						if (!!((q->data[j_144471] == NIM_NIL))) goto LA43;
						nospclose(q->data[j_144471]);
					}
					LA43: ;
					res_144548 += ((NI) 1);
				} LA39: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		{
			NI i_144498;
			NI HEX3Atmp_144553;
			NI res_144556;
			i_144498 = 0;
			HEX3Atmp_144553 = 0;
			HEX3Atmp_144553 = (cmdsLen0-1);
			res_144556 = ((NI) 0);
			{
				while (1) {
					Processobj143402* p;
					TY218714 LOC53;
					NI LOC54;
					if (!(res_144556 <= HEX3Atmp_144553)) goto LA48;
					i_144498 = res_144556;
					{
						if (!!((beforerunevent.ClPrc == TMP4338.ClPrc && beforerunevent.ClEnv == TMP4338.ClEnv))) goto LA51;
						beforerunevent.ClEnv? beforerunevent.ClPrc(i_144498, beforerunevent.ClEnv):((TMP4342)(beforerunevent.ClPrc))(i_144498);
					}
					LA51: ;
					memset((void*)LOC53, 0, sizeof(LOC53));
					p = nospstartProcess(cmds[i_144498], ((NimStringDesc*) &TMP4340), LOC53, 0, NIM_NIL, (options | 4));
					LOC54 = 0;
					LOC54 = nospwaitForExit(p, ((NI) -1));
					result = ((LOC54 >= result) ? LOC54 : result);
					nospclose(p);
					res_144556 += ((NI) 1);
				} LA48: ;
			}
		}
	}
	LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_osprocInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, stdlib_osprocDatInit)(void) {
static TNimNode* TMP2887[8];
static TNimNode TMP29[9];
NTI143402.size = sizeof(Processobj143402);
NTI143402.kind = 17;
NTI143402.base = (&NTI3411);
TMP2887[0] = &TMP29[1];
TMP29[1].kind = 1;
TMP29[1].offset = offsetof(Processobj143402, inhandle);
TMP29[1].typ = (&NTI13008);
TMP29[1].name = "inHandle";
TMP2887[1] = &TMP29[2];
TMP29[2].kind = 1;
TMP29[2].offset = offsetof(Processobj143402, outhandle);
TMP29[2].typ = (&NTI13008);
TMP29[2].name = "outHandle";
TMP2887[2] = &TMP29[3];
TMP29[3].kind = 1;
TMP29[3].offset = offsetof(Processobj143402, errhandle);
TMP29[3].typ = (&NTI13008);
TMP29[3].name = "errHandle";
TMP2887[3] = &TMP29[4];
TMP29[4].kind = 1;
TMP29[4].offset = offsetof(Processobj143402, instream);
TMP29[4].typ = (&NTI138025);
TMP29[4].name = "inStream";
TMP2887[4] = &TMP29[5];
TMP29[5].kind = 1;
TMP29[5].offset = offsetof(Processobj143402, outstream);
TMP29[5].typ = (&NTI138025);
TMP29[5].name = "outStream";
TMP2887[5] = &TMP29[6];
TMP29[6].kind = 1;
TMP29[6].offset = offsetof(Processobj143402, errstream);
TMP29[6].typ = (&NTI138025);
TMP29[6].name = "errStream";
TMP2887[6] = &TMP29[7];
TMP29[7].kind = 1;
TMP29[7].offset = offsetof(Processobj143402, id);
TMP29[7].typ = (&NTI107285);
TMP29[7].name = "id";
TMP2887[7] = &TMP29[8];
TMP29[8].kind = 1;
TMP29[8].offset = offsetof(Processobj143402, exitcode);
TMP29[8].typ = (&NTI5811);
TMP29[8].name = "exitCode";
TMP29[0].len = 8; TMP29[0].kind = 2; TMP29[0].sons = &TMP2887[0];
NTI143402.node = &TMP29[0];
NTI143404.size = sizeof(Processobj143402*);
NTI143404.kind = 22;
NTI143404.base = (&NTI143402);
NTI143404.marker = TMP2888;
NTI144201.size = sizeof(TY144201*);
NTI144201.kind = 24;
NTI144201.base = (&NTI143404);
NTI144201.marker = TMP4337;
}

