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

#include "nimbase.h"
#include <unistd.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__UV3llMMYFckfui8YMBuUZA tyTuple__UV3llMMYFckfui8YMBuUZA;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
struct tyTuple__UV3llMMYFckfui8YMBuUZA {
	NimStringV2 Field0;
	NimStringV2 Field1;
};
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOSError__stdZoserrors_u119)(NI32 errorCode_p0, NimStringV2 additionalInfo_p1);
N_LIB_PRIVATE N_NIMCALL(NI32, osLastError__stdZoserrors_u122)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___stdZprivateZoscommon_u93)(tyTuple__UV3llMMYFckfui8YMBuUZA* x_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqsink___system_u2760)(NimStringV2* dest_p0, NimStringV2 src_p1);
N_NIMCALL(NimStringV2, mnewString)(NI len_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(void, setLengthStrV2)(NimStringV2* s_p0, NI newLen_p1);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4198;
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0) {
	NCSTRING result;
	{
		if (!(s_p0.len == ((NI)0))) goto LA3_;
		result = "";
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NCSTRING) ((*s_p0.p).data));
	}
LA1_: ;
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4198);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, createSymlink__stdZprivateZossymlinks_u10)(NimStringV2 src_p0, NimStringV2 dest_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		int T3_;
		NimStringV2 colontmpD_;
		NI32 T7_;
		tyTuple__UV3llMMYFckfui8YMBuUZA T8_;
		T3_ = (int)0;
		T3_ = symlink(nimToCStringConv(src_p0), nimToCStringConv(dest_p1));
		if (!!((T3_ == ((NI32)0)))) goto LA4_;
		colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
		T7_ = (NI32)0;
		T7_ = osLastError__stdZoserrors_u122();
		if (NIM_UNLIKELY(*nimErr_)) goto LA6_;
		T8_.Field0 = src_p0;
		T8_.Field1 = dest_p1;
		colontmpD_ = dollar___stdZprivateZoscommon_u93((&T8_));
		if (NIM_UNLIKELY(*nimErr_)) goto LA6_;
		raiseOSError__stdZoserrors_u119(T7_, colontmpD_);
		if (NIM_UNLIKELY(*nimErr_)) goto LA6_;
		{
			LA6_:;
		}
		{
			if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
		}
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
LA4_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, expandSymlink__stdZprivateZossymlinks_u16)(NimStringV2 symlinkPath_p0) {
	NimStringV2 result;
	NI bufLen_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	bufLen_1 = ((NI)1024);
	{
		while (1) {
			NimStringV2 T3_;
			NI len_1;
			if ((bufLen_1) < ((NI)0) || (bufLen_1) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(bufLen_1, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
			}
			T3_.len = 0; T3_.p = NIM_NIL;
			T3_ = mnewString((bufLen_1));
			eqsink___system_u2760((&result), T3_);
			len_1 = readlink(nimToCStringConv(symlinkPath_p0), nimToCStringConv(result), bufLen_1);
			{
				NI32 T8_;
				if (!(len_1 < ((NI)0))) goto LA6_;
				T8_ = (NI32)0;
				T8_ = osLastError__stdZoserrors_u122();
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				raiseOSError__stdZoserrors_u119(T8_, symlinkPath_p0);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			}
LA6_: ;
			{
				if (!(len_1 < bufLen_1)) goto LA11_;
				if ((len_1) < ((NI)0) || (len_1) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(len_1, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
				}
				setLengthStrV2((&result), (len_1));
				goto LA1;
			}
LA11_: ;
			bufLen_1 = (NI)((NU64)(bufLen_1) << (NU64)(((NI)1) & (64 - 1)));
		}
	} LA1: ;
	}BeforeRet_: ;
	return result;
}
