/* 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/@pstd@spaths.nim.c.o /Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/.nimcache/@pstd@spaths.nim.c */
#define NIM_INTBITS 64
#define NIM_EmulateOverflowChecks

#include "nimbase.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 tyTuple__UV3llMMYFckfui8YMBuUZA tyTuple__UV3llMMYFckfui8YMBuUZA;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyTuple__7q7q3E6Oj24ZNVJb9aonhAg tyTuple__7q7q3E6Oj24ZNVJb9aonhAg;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
struct tyTuple__UV3llMMYFckfui8YMBuUZA {
	NimStringV2 Field0;
	NimStringV2 Field1;
};
struct tyTuple__7q7q3E6Oj24ZNVJb9aonhAg {
	NimStringV2 Field0;
	NimStringV2 Field1;
	NimStringV2 Field2;
};
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___system_u2754)(NimStringV2* dest_p0, NimStringV2 src_p1);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nosgetHomeDir)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nosjoinPath)(NimStringV2 head_p0, NimStringV2 tail_p1);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, substr__system_u9109)(NimStringV2 s_p0, NI first_p1);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, absolutePath__stdZprivateZospaths2_u359)(NimStringV2 path_p0, NimStringV2 root_p1);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4198;
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___stdZpaths_u97)(tyTuple__UV3llMMYFckfui8YMBuUZA* dest_p0) {
	if ((*dest_p0).Field0.p && !((*dest_p0).Field0.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).Field0.p);
}
	if ((*dest_p0).Field1.p && !((*dest_p0).Field1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).Field1.p);
}
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4198);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, expandTildeImpl__stdZpaths_u208)(NimStringV2 path_p0) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (path_p0.len == ((NI)0));
		if (T3_) goto LA4_;
		if (((NI)0) < 0 || ((NI)0) >= path_p0.len){ raiseIndexError2(((NI)0),path_p0.len-1); goto BeforeRet_;
		}
		T3_ = !(((NU8)(path_p0.p->data[((NI)0)]) == (NU8)(126)));
LA4_: ;
		if (!T3_) goto LA5_;
		eqcopy___system_u2754((&result), path_p0);
	}
	goto LA1_;
LA5_: ;
	{
		if (!(path_p0.len == ((NI)1))) goto LA8_;
		result = nosgetHomeDir();
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
LA8_: ;
	{
		NimStringV2 colontmpD_;
		NimStringV2 colontmpD__2;
		if (((NI)1) < 0 || ((NI)1) >= path_p0.len){ raiseIndexError2(((NI)1),path_p0.len-1); goto BeforeRet_;
		}
		if (!(((NU8)(path_p0.p->data[((NI)1)])) == ((NU8)(47)) || ((NU8)(path_p0.p->data[((NI)1)])) == ((NU8)(47)))) goto LA11_;
		colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
		colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;
		colontmpD_ = nosgetHomeDir();
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		colontmpD__2 = substr__system_u9109(path_p0, ((NI)2));
		result = nosjoinPath(colontmpD_, colontmpD__2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (colontmpD__2.p && !(colontmpD__2.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD__2.p);
}
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	goto LA1_;
LA11_: ;
	{
		eqcopy___system_u2754((&result), path_p0);
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, absolutePath__stdZpaths_u204)(NimStringV2 path_p0, NimStringV2 root_p1) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	result = absolutePath__stdZprivateZospaths2_u359(path_p0, root_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___stdZpaths_u124)(tyTuple__7q7q3E6Oj24ZNVJb9aonhAg* dest_p0) {
	if ((*dest_p0).Field0.p && !((*dest_p0).Field0.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).Field0.p);
}
	if ((*dest_p0).Field1.p && !((*dest_p0).Field1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).Field1.p);
}
	if ((*dest_p0).Field2.p && !((*dest_p0).Field2.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).Field2.p);
}
}
