/* Generated by Nim Compiler v2.2.10 */
#define NIM_INTBITS 32

#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__7q7q3E6Oj24ZNVJb9aonhAg tyTuple__7q7q3E6Oj24ZNVJb9aonhAg;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__pK4u9cQ1bJzH46rrmNu9bPMQ[2];
struct tyTuple__7q7q3E6Oj24ZNVJb9aonhAg {
	NimStringV2 Field0;
	NimStringV2 Field1;
	NimStringV2 Field2;
};
typedef NimStringV2 tyArray__Seu7uK9aaOSN0BK3EAjjSHw[4];
typedef NimStringV2 tyArray__YgExxhfgKcesA5EOUj1MOA[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuFormatOpenArray)(NimStringV2 formatstr_p0, NimStringV2* a_p1, NI a_p1Len_0);
static N_INLINE(NIM_BOOL, contains__stdZprivateZospaths2_u383)(NIM_CHAR* a_p0, NI a_p0Len_0, NIM_CHAR item_p1);
static N_INLINE(NI, find__stdZprivateZospaths2_u388)(NIM_CHAR* a_p0, NI a_p0Len_0, NIM_CHAR item_p1);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u79)(NimStringV2 msg_p0);
static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1);
static N_INLINE(void, copyMem__system_u1742)(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___nimpaths_u31)(tyTuple__7q7q3E6Oj24ZNVJb9aonhAg x_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, rawNewString)(NI space_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___system_u2691)(NimStringV2 dest_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, interp__nimpaths_u27)(NimStringV2 path_p0, NimStringV2 nimr_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosfileExists)(NimStringV2 filename_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nospquoteShell)(NimStringV2 s_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(NI, nosexecShellCmd)(NimStringV2 command_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqwasMoved___system_u2688)(NimStringV2* dest_p0);
static const struct {
  NI cap; NIM_CHAR data[4+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_2 = { 4 | NIM_STRLIT_FLAG, "nimr" };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_3 = {4, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_2};
static const struct {
  NI cap; NIM_CHAR data[39+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_4 = { 39 | NIM_STRLIT_FLAG, "nimpaths.nim(43, 3) `\'$\' notin result` " };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_5 = {39, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_4};
static const struct {
  NI cap; NIM_CHAR data[30+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_6 = { 30 | NIM_STRLIT_FLAG, "$nimr/tools/dochack/dochack.js" };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_7 = {30, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_6};
static const struct {
  NI cap; NIM_CHAR data[24+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_8 = { 24 | NIM_STRLIT_FLAG, "$nim js -d:release $file" };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_9 = {24, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_8};
static const struct {
  NI cap; NIM_CHAR data[3+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_10 = { 3 | NIM_STRLIT_FLAG, "nim" };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_11 = {3, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_10};
static const struct {
  NI cap; NIM_CHAR data[4+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_12 = { 4 | NIM_STRLIT_FLAG, "file" };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_13 = {4, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_12};
static const struct {
  NI cap; NIM_CHAR data[31+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_14 = { 31 | NIM_STRLIT_FLAG, "$nimr/tools/dochack/dochack.nim" };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_15 = {31, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_14};
static const struct {
  NI cap; NIM_CHAR data[20+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_16 = { 20 | NIM_STRLIT_FLAG, "getDocHacksJs: cmd: " };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_17 = {20, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_16};
static const struct {
  NI cap; NIM_CHAR data[45+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_18 = { 45 | NIM_STRLIT_FLAG, "nimpaths.nim(52, 5) `execShellCmd(cmd) == 0` " };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_19 = {45, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_18};
static const struct {
  NI cap; NIM_CHAR data[44+1];
} TM__O9aA9byHYLJvQWppK9cdLra6Q_20 = { 44 | NIM_STRLIT_FLAG, "nimpaths.nim(53, 3) `docHackJs2.fileExists` " };
static const NimStringV2 TM__O9aA9byHYLJvQWppK9cdLra6Q_21 = {44, (NimStrPayload*)&TM__O9aA9byHYLJvQWppK9cdLra6Q_20};
extern NIM_BOOL nimInErrorMode__system_u4143;
static N_INLINE(NI, find__stdZprivateZospaths2_u388)(NIM_CHAR* a_p0, NI a_p0Len_0, NIM_CHAR item_p1) {
	NI result;
{	result = ((NI)0);
	{
		NIM_CHAR i_1;
		NI i_2;
		i_1 = (NIM_CHAR)0;
		i_2 = ((NI)0);
		{
			while (1) {
				if (!(i_2 < a_p0Len_0)) goto LA3;
				i_1 = a_p0[i_2];
				{
					if (!((NU8)(i_1) == (NU8)(item_p1))) goto LA6_;
					goto BeforeRet_;
				}
LA6_: ;
				result += ((NI)1);
				i_2 += ((NI)1);
			} LA3: ;
		}
	}
	result = ((NI)-1);
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NIM_BOOL, contains__stdZprivateZospaths2_u383)(NIM_CHAR* a_p0, NI a_p0Len_0, NIM_CHAR item_p1) {
	NIM_BOOL result;
	NI T1_;
{	T1_ = (NI)0;
	T1_ = find__stdZprivateZospaths2_u388(a_p0, a_p0Len_0, item_p1);
	result = (((NI)0) <= T1_);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
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_u1742)(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_u1742(((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*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4143);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, interp__nimpaths_u27)(NimStringV2 path_p0, NimStringV2 nimr_p1) {
	NimStringV2 result;
	tyArray__pK4u9cQ1bJzH46rrmNu9bPMQ T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	T1_[0] = TM__O9aA9byHYLJvQWppK9cdLra6Q_3;
	T1_[1] = nimr_p1;
	result = nsuFormatOpenArray(path_p0, T1_, 2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		NIM_BOOL T4_;
		NimStringV2 colontmpD_;
		NimStringV2 colontmpD__2;
		NimStringV2 T7_;
		tyTuple__7q7q3E6Oj24ZNVJb9aonhAg T8_;
		T4_ = (NIM_BOOL)0;
		T4_ = contains__stdZprivateZospaths2_u383(((result).p) ? (result.p->data) : NIM_NIL, result.len, 36);
		if (!!(!(T4_))) goto LA5_;
		colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
		colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;
		T7_.len = 0; T7_.p = NIM_NIL;
		T8_.Field0 = path_p0;
		T8_.Field1 = nimr_p1;
		T8_.Field2 = result;
		colontmpD_ = dollar___nimpaths_u31(T8_);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T7_ = rawNewString(colontmpD_.len + 39);
appendString((&T7_), TM__O9aA9byHYLJvQWppK9cdLra6Q_5);
appendString((&T7_), colontmpD_);
		colontmpD__2 = T7_;
		failedAssertImpl__stdZassertions_u79(colontmpD__2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		eqdestroy___system_u2691(colontmpD__2);
		eqdestroy___system_u2691(colontmpD_);
	}
LA5_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, getDocHacksJs__nimpaths_u94)(NimStringV2 nimr_p0, NimStringV2 nim_p1, NIM_BOOL forceRebuild_p2) {
	NimStringV2 result;
	NimStringV2 docHackJs2_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	docHackJs2_1.len = 0; docHackJs2_1.p = NIM_NIL;
	docHackJs2_1 = interp__nimpaths_u27(TM__O9aA9byHYLJvQWppK9cdLra6Q_7, nimr_p0);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	{
		NIM_BOOL T4_;
		NIM_BOOL T6_;
		NimStringV2 cmd_1;
		NimStringV2 colontmpD_;
		NimStringV2 colontmpD__2;
		NimStringV2 colontmpD__3;
		NimStringV2 colontmpD__4;
		tyArray__Seu7uK9aaOSN0BK3EAjjSHw T10_;
		tyArray__YgExxhfgKcesA5EOUj1MOA T11_;
		NimStringV2 T12_;
		T4_ = (NIM_BOOL)0;
		T4_ = forceRebuild_p2;
		if (T4_) goto LA5_;
		T6_ = (NIM_BOOL)0;
		T6_ = nosfileExists(docHackJs2_1);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
		T4_ = !(T6_);
LA5_: ;
		if (!T4_) goto LA7_;
		cmd_1.len = 0; cmd_1.p = NIM_NIL;
		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;
		colontmpD__4.len = 0; colontmpD__4.p = NIM_NIL;
		T10_[0] = TM__O9aA9byHYLJvQWppK9cdLra6Q_11;
		colontmpD_ = nospquoteShell(nim_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto LA9_;
		T10_[1] = colontmpD_;
		T10_[2] = TM__O9aA9byHYLJvQWppK9cdLra6Q_13;
		colontmpD__2 = interp__nimpaths_u27(TM__O9aA9byHYLJvQWppK9cdLra6Q_15, nimr_p0);
		if (NIM_UNLIKELY(*nimErr_)) goto LA9_;
		colontmpD__3 = nospquoteShell(colontmpD__2);
		if (NIM_UNLIKELY(*nimErr_)) goto LA9_;
		T10_[3] = colontmpD__3;
		cmd_1 = nsuFormatOpenArray(TM__O9aA9byHYLJvQWppK9cdLra6Q_9, T10_, 4);
		if (NIM_UNLIKELY(*nimErr_)) goto LA9_;
		T12_.len = 0; T12_.p = NIM_NIL;
		T12_ = rawNewString(cmd_1.len + 20);
appendString((&T12_), TM__O9aA9byHYLJvQWppK9cdLra6Q_17);
appendString((&T12_), cmd_1);
		colontmpD__4 = T12_;
		T11_[0] = colontmpD__4;
		echoBinSafe(T11_, 1);
		{
			NI T15_;
			NimStringV2 colontmpD__5;
			NimStringV2 T18_;
			T15_ = (NI)0;
			T15_ = nosexecShellCmd(cmd_1);
			if (NIM_UNLIKELY(*nimErr_)) goto LA9_;
			if (!!((T15_ == ((NI)0)))) goto LA16_;
			colontmpD__5.len = 0; colontmpD__5.p = NIM_NIL;
			T18_.len = 0; T18_.p = NIM_NIL;
			T18_ = rawNewString(cmd_1.len + 45);
appendString((&T18_), TM__O9aA9byHYLJvQWppK9cdLra6Q_19);
appendString((&T18_), cmd_1);
			colontmpD__5 = T18_;
			failedAssertImpl__stdZassertions_u79(colontmpD__5);
			if (NIM_UNLIKELY(*nimErr_)) goto LA9_;
			eqdestroy___system_u2691(colontmpD__5);
		}
LA16_: ;
		{
			LA9_:;
		}
		{
			eqdestroy___system_u2691(colontmpD__4);
			eqdestroy___system_u2691(colontmpD__3);
			eqdestroy___system_u2691(colontmpD__2);
			eqdestroy___system_u2691(colontmpD_);
			eqdestroy___system_u2691(cmd_1);
		}
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	}
LA7_: ;
	{
		NIM_BOOL T23_;
		T23_ = (NIM_BOOL)0;
		T23_ = nosfileExists(docHackJs2_1);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
		if (!!(T23_)) goto LA24_;
		failedAssertImpl__stdZassertions_u79(TM__O9aA9byHYLJvQWppK9cdLra6Q_21);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	}
LA24_: ;
	result = docHackJs2_1;
	eqwasMoved___system_u2688((&docHackJs2_1));
	{
		LA1_:;
	}
	{
		eqdestroy___system_u2691(docHackJs2_1);
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
