/* Generated by Nim Compiler v2.2.10 */
/* Compiled for: MacOSX, arm64, clang */
/* Command for C compiler:
   clang -c  -w -ferror-limit=3 -fno-strict-aliasing -pthread -isysroot /Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -target arm64-apple-darwin24.2.0 -O3   -I/Users/runner/work/nightlies/nightlies/nim-2.2.10/lib -I/Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/src -o /Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/.nimcache/@mbasic@sosutils.nim.c.o /Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/.nimcache/@mbasic@sosutils.nim.c */
#define NIM_INTBITS 64
#define NIM_EmulateOverflowChecks

#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
typedef struct tyObject_StringTableObj__aB8otkyeeuZW5rawDMqajg tyObject_StringTableObj__aB8otkyeeuZW5rawDMqajg;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
	NimStringV2 Field0;
	NI Field1;
};
typedef NU8 tySet_tyEnum_ProcessOption__m5rj7fxDbuVx8PVIV9af9aLg;
static N_INLINE(NIM_BOOL, eqeq___stdZpaths_u59)(NimStringV2 x_p0, NimStringV2 y_p1);
N_LIB_PRIVATE N_NIMCALL(NI, noscmpPaths)(NimStringV2 pathA_p0, NimStringV2 pathB_p1);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___system_u2754)(NimStringV2* dest_p0, NimStringV2 src_p1);
static N_INLINE(NIM_BOOL, isAbsolute__stdZpaths_u143)(NimStringV2 path_p0);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosisAbsolute)(NimStringV2 path_p0);
static N_INLINE(NimStringV2, slash___stdZpaths_u84)(NimStringV2 head_p0, NimStringV2 tail_p1);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nosjoinPath)(NimStringV2 head_p0, NimStringV2 tail_p1);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__system_u2188)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(void, nimAddCharV1)(NimStringV2* s_p0, NIM_CHAR c_p1);
N_LIB_PRIVATE N_NIMCALL(void, prepareAdd)(NimStringV2* s_p0, NI addLen_p1);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nospquoteShell)(NimStringV2 s_p0);
static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1);
static N_INLINE(void, copyMem__system_u1755)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL, nimAddInt)(NI a_p0, NI b_p1, NI* res_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NIMCALL(tyTuple__XOVT24GHXwqiEj5GCsEGCA, execCmdEx__pureZosproc_u2044)(NimStringV2 command_p0, tySet_tyEnum_ProcessOption__m5rj7fxDbuVx8PVIV9af9aLg options_p1, tyObject_StringTableObj__aB8otkyeeuZW5rawDMqajg* env_p2, NimStringV2 workingDir_p3, NimStringV2 input_p4);
N_LIB_PRIVATE N_NIMCALL(void, eqwasMoved___system_u2751)(NimStringV2* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZosproc_u2088)(tyTuple__XOVT24GHXwqiEj5GCsEGCA* dest_p0);
static N_INLINE(NIM_BOOL, isRelativeTo__stdZpaths_u151)(NimStringV2 path_p0, NimStringV2 base_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isRelativeTo__stdZprivateZospaths2_u156)(NimStringV2 path_p0, NimStringV2 base_p1);
static N_INLINE(NimStringV2, relativePath__stdZpaths_u146)(NimStringV2 path_p0, NimStringV2 base_p1, NIM_CHAR sep_p2);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nosrelativePath)(NimStringV2 path_p0, NimStringV2 base_p1, NIM_CHAR sep_p2);
static const struct {
  NI cap; NIM_CHAR data[1+1];
} TM__aX9ajxGVY3Ez9bLhPB8GBdRw_2 = { 1 | NIM_STRLIT_FLAG, "." };
static const NimStringV2 TM__aX9ajxGVY3Ez9bLhPB8GBdRw_3 = {1, (NimStrPayload*)&TM__aX9ajxGVY3Ez9bLhPB8GBdRw_2};
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__aX9ajxGVY3Ez9bLhPB8GBdRw_5 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__aX9ajxGVY3Ez9bLhPB8GBdRw_6 = {0, (NimStrPayload*)&TM__aX9ajxGVY3Ez9bLhPB8GBdRw_5};
static const NimStringV2 TM__aX9ajxGVY3Ez9bLhPB8GBdRw_7 = {0, (NimStrPayload*)&TM__aX9ajxGVY3Ez9bLhPB8GBdRw_5};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4198;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4198);
	return result;
}
static N_INLINE(NIM_BOOL, eqeq___stdZpaths_u59)(NimStringV2 x_p0, NimStringV2 y_p1) {
	NIM_BOOL result;
	NI T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	T1_ = (NI)0;
	T1_ = noscmpPaths(x_p0, y_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = (T1_ == ((NI)0));
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NIM_BOOL, isAbsolute__stdZpaths_u143)(NimStringV2 path_p0) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	result = nosisAbsolute(path_p0);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NimStringV2, slash___stdZpaths_u84)(NimStringV2 head_p0, NimStringV2 tail_p1) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	result = nosjoinPath(head_p0, tail_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, absoluteDepsDir__basicZosutils_u74)(NimStringV2 project_p0, NimStringV2 value_p1) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = eqeq___stdZpaths_u59(value_p1, TM__aX9ajxGVY3Ez9bLhPB8GBdRw_3);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T3_) goto LA4_;
		eqcopy___system_u2754((&result), project_p0);
	}
	goto LA1_;
LA4_: ;
	{
		NIM_BOOL T7_;
		T7_ = (NIM_BOOL)0;
		T7_ = isAbsolute__stdZpaths_u143(value_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T7_) goto LA8_;
		eqcopy___system_u2754((&result), value_p1);
	}
	goto LA1_;
LA8_: ;
	{
		result = slash___stdZpaths_u84(project_p0, value_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, nimSetMem__system_u2188)(void* a_p0, int v_p1, NI size_p2) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
	nimSetMem__system_u2188(p_p0, ((int)0), size_p1);
}
static N_INLINE(void, nimAddCharV1)(NimStringV2* s_p0, NIM_CHAR c_p1) {
	prepareAdd(s_p0, ((NI)1));
	(*(*s_p0).p).data[(*s_p0).len] = c_p1;
	(*s_p0).len += ((NI)1);
	(*(*s_p0).p).data[(*s_p0).len] = 0;
}
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));
}
static N_INLINE(void, copyMem__system_u1755)(void* dest_p0, void* source_p1, NI size_p2) {
	nimCopyMem(dest_p0, source_p1, size_p2);
}
static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1) {
	{
		if (!(((NI)0) < src_p1.len)) goto LA3_;
		copyMem__system_u1755(((void*) ((&(*(*dest_p0).p).data[(*dest_p0).len]))), ((void*) ((&(*src_p1.p).data[((NI)0)]))), (src_p1.len));
		(*dest_p0).len += src_p1.len;
		(*(*dest_p0).p).data[(*dest_p0).len] = 0;
	}
LA3_: ;
}
static N_INLINE(NIM_BOOL, nimAddInt)(NI a_p0, NI b_p1, NI* res_p2) {
	NIM_BOOL result;
	NI r_1;
	result = (NIM_BOOL)0;
	r_1 = ((NI) ((NU)((NU64)(((NU) (a_p0))) + (NU64)(((NU) (b_p1))))));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI)0) <= (NI)(r_1 ^ a_p0));
		if (T3_) goto LA4_;
		T3_ = (((NI)0) <= (NI)(r_1 ^ b_p1));
LA4_: ;
		if (!T3_) goto LA5_;
		(*res_p2) = r_1;
	}
	goto LA1_;
LA5_: ;
	{
		result = NIM_TRUE;
	}
LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(tyTuple__XOVT24GHXwqiEj5GCsEGCA, silentExec__basicZosutils_u78)(NimStringV2 cmd_p0, NimStringV2* args_p1, NI args_p1Len_0) {
	tyTuple__XOVT24GHXwqiEj5GCsEGCA result;
	NimStringV2 cmdLine_1;
	tyTuple__XOVT24GHXwqiEj5GCsEGCA tmpTuple_1;
	NimStringV2 res_1;
	NimStringV2 colontmp_;
	NI code_1;
	NI colontmp__3;
	NimStringV2 blitTmp_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&result), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
	cmdLine_1.len = 0; cmdLine_1.p = NIM_NIL;
	nimZeroMem((void*)(&tmpTuple_1), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
	res_1.len = 0; res_1.p = NIM_NIL;
	colontmp_.len = 0; colontmp_.p = NIM_NIL;
	eqcopy___system_u2754((&cmdLine_1), cmd_p0);
	{
		NI i_1;
		NI colontmp__2;
		NI i_2;
		i_1 = (NI)0;
		colontmp__2 = (NI)0;
		colontmp__2 = args_p1Len_0;
		i_2 = ((NI)0);
		{
			while (1) {
				NI TM__aX9ajxGVY3Ez9bLhPB8GBdRw_4;
				if (!(i_2 < colontmp__2)) goto LA4;
				i_1 = i_2;
				nimAddCharV1((&cmdLine_1), 32);
				{
					NimStringV2 colontmpD_;
					if (i_1 < 0 || i_1 >= args_p1Len_0){ raiseIndexError2(i_1,args_p1Len_0-1); goto LA1_;
					}
					if (!(((NI)0) < args_p1[i_1].len)) goto LA7_;
					colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
					if (i_1 < 0 || i_1 >= args_p1Len_0){ raiseIndexError2(i_1,args_p1Len_0-1); goto LA1_;
					}
					colontmpD_ = nospquoteShell(args_p1[i_1]);
					if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
					prepareAdd((&cmdLine_1), colontmpD_.len + 0);
appendString((&cmdLine_1), colontmpD_);
					if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
				}
LA7_: ;
				if (nimAddInt(i_2, ((NI)1), &TM__aX9ajxGVY3Ez9bLhPB8GBdRw_4)) { raiseOverflow(); goto LA1_;
				};
				i_2 = (NI)(TM__aX9ajxGVY3Ez9bLhPB8GBdRw_4);
			} LA4: ;
		}
	}
	tmpTuple_1 = execCmdEx__pureZosproc_u2044(cmdLine_1, 10, ((tyObject_StringTableObj__aB8otkyeeuZW5rawDMqajg*) NIM_NIL), TM__aX9ajxGVY3Ez9bLhPB8GBdRw_6, TM__aX9ajxGVY3Ez9bLhPB8GBdRw_7);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	res_1 = tmpTuple_1.Field0;
	eqwasMoved___system_u2751((&tmpTuple_1.Field0));
	code_1 = tmpTuple_1.Field1;
	colontmp_ = res_1;
	eqwasMoved___system_u2751((&res_1));
	colontmp__3 = code_1;
	blitTmp_1 = colontmp_;
	eqwasMoved___system_u2751((&colontmp_));
	result.Field0 = blitTmp_1;
	result.Field1 = colontmp__3;
	{
		LA1_:;
	}
	{
		if (colontmp_.p && !(colontmp_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmp_.p);
}
		if (res_1.p && !(res_1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(res_1.p);
}
		eqdestroy___pureZosproc_u2088((&tmpTuple_1));
		if (cmdLine_1.p && !(cmdLine_1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(cmdLine_1.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___basicZosutils_u97)(tyTuple__XOVT24GHXwqiEj5GCsEGCA* dest_p0) {
	if ((*dest_p0).Field0.p && !((*dest_p0).Field0.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).Field0.p);
}
}
static N_INLINE(NIM_BOOL, isRelativeTo__stdZpaths_u151)(NimStringV2 path_p0, NimStringV2 base_p1) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	result = isRelativeTo__stdZprivateZospaths2_u156(path_p0, base_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NimStringV2, relativePath__stdZpaths_u146)(NimStringV2 path_p0, NimStringV2 base_p1, NIM_CHAR sep_p2) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	result = nosrelativePath(path_p0, base_p1, sep_p2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, readableFile__basicZosutils_u70)(NimStringV2 s_p0, NimStringV2 path_p1) {
	NimStringV2 result;
	NimStringV2 T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	T1_.len = 0; T1_.p = NIM_NIL;
	{
		NIM_BOOL T4_;
		T4_ = (NIM_BOOL)0;
		T4_ = isRelativeTo__stdZpaths_u151(s_p0, path_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T4_) goto LA5_;
		result = relativePath__stdZpaths_u146(s_p0, path_p1, 47);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA2_;
LA5_: ;
	{
		eqcopy___system_u2754((&result), s_p0);
	}
LA2_: ;
	}BeforeRet_: ;
	return result;
}
