/* 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/@mrunners.nim.c.o /Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/.nimcache/@mrunners.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__UV3llMMYFckfui8YMBuUZA tyTuple__UV3llMMYFckfui8YMBuUZA;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__YgExxhfgKcesA5EOUj1MOA[1];
typedef NimStringV2 tyArray__pK4u9cQ1bJzH46rrmNu9bPMQ[2];
struct tyTuple__UV3llMMYFckfui8YMBuUZA {
	NimStringV2 Field0;
	NimStringV2 Field1;
};
N_LIB_PRIVATE N_NIMCALL(void, notice__basicZgitops_u1160)(NimStringV2 p_p0, NimStringV2* args_p1, NI args_p1Len_0);
N_LIB_PRIVATE N_NIMCALL(void, runNimScript__runners_u8)(NimStringV2 scriptContent_p0, NimStringV2 name_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosfileExists)(NimStringV2 filename_p0);
N_LIB_PRIVATE N_NIMCALL(void, error__basicZconfigutils_u107)(NimStringV2 p_p0, NimStringV2* args_p1, NI args_p1Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqsink___system_u2760)(NimStringV2* dest_p0, NimStringV2 src_p1);
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_NIMCALL(NimStringV2, dollar___systemZdollars_u14)(NI xX60gensym0__p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, rawNewString)(NI space_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(void, writeFile__stdZsyncio_u539)(NimStringV2 filename_p0, NimStringV2 content_p1);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nospquoteShell)(NimStringV2 s_p0);
N_LIB_PRIVATE N_NIMCALL(NI, nosexecShellCmd)(NimStringV2 command_p0);
N_LIB_PRIVATE N_NIMCALL(void, nosremoveFile)(NimStringV2 file_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuFormatOpenArray)(NimStringV2 formatstr_p0, NimStringV2* a_p1, NI a_p1Len_0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuEscape)(NimStringV2 s_p0, NimStringV2 prefix_p1, NimStringV2 suffix_p2);
static const struct {
  NI cap; NIM_CHAR data[21+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_3 = { 21 | NIM_STRLIT_FLAG, "running install hooks" };
static const struct {
  NI cap; NIM_CHAR data[18+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_4 = { 18 | NIM_STRLIT_FLAG, "atlas_build_0.nims" };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_5 = {18, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_4};
static const struct {
  NI cap; NIM_CHAR data[40+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_7 = { 40 | NIM_STRLIT_FLAG, "could not create new: atlas_build_0.nims" };
static const struct {
  NI cap; NIM_CHAR data[12+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_8 = { 12 | NIM_STRLIT_FLAG, "atlas_build_" };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_9 = {12, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_8};
static const struct {
  NI cap; NIM_CHAR data[5+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_10 = { 5 | NIM_STRLIT_FLAG, ".nims" };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_11 = {5, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_10};
static const struct {
  NI cap; NIM_CHAR data[27+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_13 = { 27 | NIM_STRLIT_FLAG, "nim e --hints:off -d:atlas " };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_14 = {27, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_13};
static const struct {
  NI cap; NIM_CHAR data[18+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_15 = { 18 | NIM_STRLIT_FLAG, "Nimscript failed: " };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_16 = {18, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_15};
static const struct {
  NI cap; NIM_CHAR data[1220+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_17 = { 1220 | NIM_STRLIT_FLAG, "\012var\012  packageName* = \"\"    ## Set this to the package name. It\012                       ## is usually not required to do that, nims\' filename is\012                       ## the default.\012  version*: string     ## The package\'s version.\012  author*: string      ## The package\'s author.\012  description*: string ## The package\'s description.\012  license*: string     ## The package\'s license.\012  srcDir*: string      ## The package\'s source directory.\012  binDir*: string      ## The package\'s binary directory.\012  backend*: string     ## The package\'s backend.\012\012  skipDirs*, skipFiles*, skipExt*, installDirs*, installFiles*,\012    installExt*, bin*: seq[string] = @[] ## Nimble metadata.\012  requiresData*: seq[string] = @[] ## The package\'s dependencies.\012\012  foreignDeps*: seq[string] = @[] ## The foreign dependencies. Only\012                                  ## exported for \'distros.nim\'.\012\012proc requires*(deps: varargs[string]) =\012  for d in deps: requiresData.add(d)\012\012template after(name, body: untyped) =\012  when astToStr(name) == \"install\":\012    body\012\012template before(name, body: untyped) =\012  when astToStr(name) == \"install\":\012    body\012\012proc getPkgDir*(): string = getCurrentDir()\012proc thisDir*(): string = getCurrentDir()\012\012include $1\012\012" };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_18 = {1220, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_17};
static const struct {
  NI cap; NIM_CHAR data[1+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_19 = { 1 | NIM_STRLIT_FLAG, "\"" };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_20 = {1, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_19};
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_21 = {1, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_19};
static const struct {
  NI cap; NIM_CHAR data[28+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_23 = { 28 | NIM_STRLIT_FLAG, "running nimble build scripts" };
static const struct {
  NI cap; NIM_CHAR data[134+1];
} TM__gYDdhYeby35GQNI7sv9bLlg_24 = { 134 | NIM_STRLIT_FLAG, "\012const matchedPattern = $1\012\012template builder(pattern: string; body: untyped) =\012  when pattern == matchedPattern:\012    body\012\012include $2\012" };
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_25 = {134, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_24};
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_26 = {1, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_19};
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_27 = {1, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_19};
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_28 = {1, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_19};
static const NimStringV2 TM__gYDdhYeby35GQNI7sv9bLlg_29 = {1, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_19};
static NIM_CONST tyArray__YgExxhfgKcesA5EOUj1MOA TM__gYDdhYeby35GQNI7sv9bLlg_2 = {{21, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_3}}
;
static NIM_CONST tyArray__YgExxhfgKcesA5EOUj1MOA TM__gYDdhYeby35GQNI7sv9bLlg_6 = {{40, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_7}}
;
static NIM_CONST tyArray__YgExxhfgKcesA5EOUj1MOA TM__gYDdhYeby35GQNI7sv9bLlg_22 = {{28, (NimStrPayload*)&TM__gYDdhYeby35GQNI7sv9bLlg_23}}
;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4198;
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;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4198);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, runNimScript__runners_u8)(NimStringV2 scriptContent_p0, NimStringV2 name_p1) {
	NimStringV2 buildNims_1;
	NimStringV2 cmdLine_1;
	NimStringV2 colontmpD_;
	NI i_1;
	NimStringV2 T13_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	buildNims_1.len = 0; buildNims_1.p = NIM_NIL;
	cmdLine_1.len = 0; cmdLine_1.p = NIM_NIL;
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	buildNims_1 = TM__gYDdhYeby35GQNI7sv9bLlg_5;
	i_1 = ((NI)1);
	{
		while (1) {
			NIM_BOOL T4_;
			NimStringV2 colontmpD__2;
			NimStringV2 T10_;
			NI TM__gYDdhYeby35GQNI7sv9bLlg_12;
			T4_ = (NIM_BOOL)0;
			T4_ = nosfileExists(buildNims_1);
			if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
			if (!T4_) goto LA3;
			colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;
			{
				if (!(((NI)20) <= i_1)) goto LA8_;
				error__basicZconfigutils_u107(name_p1, TM__gYDdhYeby35GQNI7sv9bLlg_6, 1);
				if (NIM_UNLIKELY(*nimErr_)) goto LA5_;
				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);
}
				if (cmdLine_1.p && !(cmdLine_1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(cmdLine_1.p);
}
				if (buildNims_1.p && !(buildNims_1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(buildNims_1.p);
}
				goto BeforeRet_;
			}
LA8_: ;
			T10_.len = 0; T10_.p = NIM_NIL;
			colontmpD__2 = dollar___systemZdollars_u14(i_1);
			if (NIM_UNLIKELY(*nimErr_)) goto LA5_;
			T10_ = rawNewString(colontmpD__2.len + 17);
appendString((&T10_), TM__gYDdhYeby35GQNI7sv9bLlg_9);
appendString((&T10_), colontmpD__2);
appendString((&T10_), TM__gYDdhYeby35GQNI7sv9bLlg_11);
			eqsink___system_u2760((&buildNims_1), T10_);
			if (nimAddInt(i_1, ((NI)1), &TM__gYDdhYeby35GQNI7sv9bLlg_12)) { raiseOverflow(); goto LA5_;
			};
			i_1 = (NI)(TM__gYDdhYeby35GQNI7sv9bLlg_12);
			{
				LA5_:;
			}
			{
				if (colontmpD__2.p && !(colontmpD__2.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD__2.p);
}
			}
			if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
		} LA3: ;
	}
	writeFile__stdZsyncio_u539(buildNims_1, scriptContent_p0);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T13_.len = 0; T13_.p = NIM_NIL;
	colontmpD_ = nospquoteShell(buildNims_1);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T13_ = rawNewString(colontmpD_.len + 27);
appendString((&T13_), TM__gYDdhYeby35GQNI7sv9bLlg_14);
appendString((&T13_), colontmpD_);
	cmdLine_1 = T13_;
	{
		NI T16_;
		NimStringV2 colontmpD__3;
		tyArray__YgExxhfgKcesA5EOUj1MOA T20_;
		NimStringV2 T21_;
		T16_ = (NI)0;
		T16_ = nosexecShellCmd(cmdLine_1);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
		if (!!((T16_ == ((NI)0)))) goto LA17_;
		colontmpD__3.len = 0; colontmpD__3.p = NIM_NIL;
		T21_.len = 0; T21_.p = NIM_NIL;
		T21_ = rawNewString(cmdLine_1.len + 18);
appendString((&T21_), TM__gYDdhYeby35GQNI7sv9bLlg_16);
appendString((&T21_), cmdLine_1);
		colontmpD__3 = T21_;
		T20_[0] = colontmpD__3;
		error__basicZconfigutils_u107(name_p1, T20_, 1);
		if (NIM_UNLIKELY(*nimErr_)) goto LA19_;
		{
			LA19_:;
		}
		{
			if (colontmpD__3.p && !(colontmpD__3.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD__3.p);
}
		}
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	}
	goto LA14_;
LA17_: ;
	{
		nosremoveFile(buildNims_1);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	}
LA14_: ;
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
		if (cmdLine_1.p && !(cmdLine_1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(cmdLine_1.p);
}
		if (buildNims_1.p && !(buildNims_1.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(buildNims_1.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, runNimScriptInstallHook__runners_u27)(NimStringV2 nimbleFile_p0, NimStringV2 name_p1) {
	NimStringV2 colontmpD_;
	NimStringV2 colontmpD__2;
	tyArray__YgExxhfgKcesA5EOUj1MOA T2_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;
	notice__basicZgitops_u1160(name_p1, TM__gYDdhYeby35GQNI7sv9bLlg_2, 1);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = nsuEscape(nimbleFile_p0, TM__gYDdhYeby35GQNI7sv9bLlg_20, TM__gYDdhYeby35GQNI7sv9bLlg_21);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	colontmpD__2 = nsuFormatOpenArray(TM__gYDdhYeby35GQNI7sv9bLlg_18, T2_, 1);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	runNimScript__runners_u8(colontmpD__2, name_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	{
		LA1_:;
	}
	{
		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);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, runNimScriptBuilder__runners_u34)(tyTuple__UV3llMMYFckfui8YMBuUZA* p_p0, NimStringV2 name_p1) {
	NimStringV2 colontmpD_;
	NimStringV2 colontmpD__2;
	NimStringV2 colontmpD__3;
	tyArray__pK4u9cQ1bJzH46rrmNu9bPMQ T2_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;
	colontmpD__3.len = 0; colontmpD__3.p = NIM_NIL;
	notice__basicZgitops_u1160(name_p1, TM__gYDdhYeby35GQNI7sv9bLlg_22, 1);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = nsuEscape((*p_p0).Field0, TM__gYDdhYeby35GQNI7sv9bLlg_26, TM__gYDdhYeby35GQNI7sv9bLlg_27);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	colontmpD__2 = nsuEscape((*p_p0).Field1, TM__gYDdhYeby35GQNI7sv9bLlg_28, TM__gYDdhYeby35GQNI7sv9bLlg_29);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[1] = colontmpD__2;
	colontmpD__3 = nsuFormatOpenArray(TM__gYDdhYeby35GQNI7sv9bLlg_25, T2_, 2);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	runNimScript__runners_u8(colontmpD__3, name_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	{
		LA1_:;
	}
	{
		if (colontmpD__3.p && !(colontmpD__3.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD__3.p);
}
		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);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
