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

#include "nimbase.h"
#include <string.h>
#include <math.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 tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q;
typedef struct tySequence__YdLNCDKYeipzJx3I8Xw82Q tySequence__YdLNCDKYeipzJx3I8Xw82Q;
typedef struct tySequence__YdLNCDKYeipzJx3I8Xw82Q_Content tySequence__YdLNCDKYeipzJx3I8Xw82Q_Content;
typedef struct tyTuple__BUNQL5x2cKJaBSzOn5pwkg tyTuple__BUNQL5x2cKJaBSzOn5pwkg;
struct tySequence__YdLNCDKYeipzJx3I8Xw82Q {
  NI len; tySequence__YdLNCDKYeipzJx3I8Xw82Q_Content* p;
};
struct tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q {
	tySequence__YdLNCDKYeipzJx3I8Xw82Q x;
	NIM_BOOL invalid;
};
struct tyTuple__BUNQL5x2cKJaBSzOn5pwkg {
	NI32 Field0;
	NI32 Field1;
};
struct tySequence__YdLNCDKYeipzJx3I8Xw82Q_Content { NI cap; NU64 data[SEQ_DECL_SIZE]; };
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(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(tySequence__YdLNCDKYeipzJx3I8Xw82Q, newSeq__OOZdistZsatZsrcZsatZsatvars_u63)(NI len_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
static N_INLINE(tyTuple__BUNQL5x2cKJaBSzOn5pwkg, index__OOZdistZsatZsrcZsatZsatvars_u202)(NI32 v_p0);
static N_INLINE(NIM_BOOL, nimMulInt)(NI a_p0, NI b_p1, NI* res_p2);
static N_INLINE(NF, toFloat__system_u1705)(NI i_p0);
static N_INLINE(NF, abs__system_u5188)(NF x_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___OOZdistZsatZsrcZsatZsatvars_u150)(tySequence__YdLNCDKYeipzJx3I8Xw82Q* dest_p0, tySequence__YdLNCDKYeipzJx3I8Xw82Q src_p1);
static N_INLINE(NIM_BOOL, containsInvalid__OOZdistZsatZsrcZsatZsatvars_u293)(NU64 x_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___OOZdistZsatZsrcZsatZsatvars_u147)(tySequence__YdLNCDKYeipzJx3I8Xw82Q dest_p0);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4198;
N_LIB_PRIVATE N_NIMCALL(void, eqwasMoved___OOZdistZsatZsrcZsatZsatvars_u223)(NI32* dest_p0) {
	(*dest_p0) = 0;
}
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(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(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q, createSolution__OOZdistZsatZsrcZsatZsatvars_u26)(NI maxVars_p0) {
	tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q result;
	NI space_1;
{	nimZeroMem((void*)(&result), sizeof(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q));
	space_1 = (NI)((maxVars_p0) / (((NI)32)));
	{
		NI TM__9cfZ9clC7zy1EAocw3n9aXPWQ_2;
		if (!!(((NI)((maxVars_p0) % (((NI)32))) == ((NI)0)))) goto LA3_;
		if (nimAddInt(space_1, ((NI)1), &TM__9cfZ9clC7zy1EAocw3n9aXPWQ_2)) { raiseOverflow(); goto BeforeRet_;
		};
		space_1 = (NI)(TM__9cfZ9clC7zy1EAocw3n9aXPWQ_2);
	}
LA3_: ;
	nimZeroMem((void*)(&result), sizeof(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q));
	if ((space_1) < ((NI)0) || (space_1) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(space_1, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
	}
	result.x = newSeq__OOZdistZsatZsrcZsatZsatvars_u63((space_1));
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NF, toFloat__system_u1705)(NI i_p0) {
	NF result;
	result = ((NF) (i_p0));
	return result;
}
static N_INLINE(NF, abs__system_u5188)(NF x_p0) {
	NF result;
	result = (NF)0;
	result = fabs(x_p0);
	return result;
}
static N_INLINE(NIM_BOOL, nimMulInt)(NI a_p0, NI b_p1, NI* res_p2) {
	NIM_BOOL result;
	NI r_1;
	NF floatProd_1;
	NF T1_;
	NF T2_;
	NF resAsFloat_1;
	result = (NIM_BOOL)0;
	r_1 = ((NI) ((NU)((NU64)(((NU) (a_p0))) * (NU64)(((NU) (b_p1))))));
	T1_ = (NF)0;
	T1_ = toFloat__system_u1705(a_p0);
	T2_ = (NF)0;
	T2_ = toFloat__system_u1705(b_p1);
	floatProd_1 = ((NF)(T1_) * (NF)(T2_));
	resAsFloat_1 = toFloat__system_u1705(r_1);
	{
		if (!(resAsFloat_1 == floatProd_1)) goto LA5_;
		(*res_p2) = r_1;
	}
	goto LA3_;
LA5_: ;
	{
		{
			NF T10_;
			NF T11_;
			T10_ = (NF)0;
			T10_ = abs__system_u5188(((NF)(resAsFloat_1) - (NF)(floatProd_1)));
			T11_ = (NF)0;
			T11_ = abs__system_u5188(floatProd_1);
			if (!(((NF)(32.0) * (NF)(T10_)) <= T11_)) goto LA12_;
			(*res_p2) = r_1;
		}
		goto LA8_;
LA12_: ;
		{
			result = NIM_TRUE;
		}
LA8_: ;
	}
LA3_: ;
	return result;
}
static N_INLINE(tyTuple__BUNQL5x2cKJaBSzOn5pwkg, index__OOZdistZsatZsrcZsatZsatvars_u202)(NI32 v_p0) {
	tyTuple__BUNQL5x2cKJaBSzOn5pwkg result;
	NI32 colontmp_;
	NI32 colontmp__2;
	NI TM__9cfZ9clC7zy1EAocw3n9aXPWQ_3;
{	nimZeroMem((void*)(&result), sizeof(tyTuple__BUNQL5x2cKJaBSzOn5pwkg));
	colontmp_ = (NI32)((v_p0) / (((NI32)32)));
	if (nimMulInt((NI32)((v_p0) % (((NI32)32))), ((NI32)2), &TM__9cfZ9clC7zy1EAocw3n9aXPWQ_3)) { raiseOverflow(); goto BeforeRet_;
	};
	if (TM__9cfZ9clC7zy1EAocw3n9aXPWQ_3 < (-2147483647 -1) || TM__9cfZ9clC7zy1EAocw3n9aXPWQ_3 > 2147483647){ raiseOverflow(); goto BeforeRet_;
	}
	colontmp__2 = (NI32)(TM__9cfZ9clC7zy1EAocw3n9aXPWQ_3);
	result.Field0 = colontmp_;
	result.Field1 = colontmp__2;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4198);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NU64, getVar__OOZdistZsatZsrcZsatZsatvars_u277)(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q b_p0, NI32 v_p1) {
	NU64 result;
	tyTuple__BUNQL5x2cKJaBSzOn5pwkg tmpTuple_1;
	NI32 va_1;
	NI32 vb_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NU64)0;
	tmpTuple_1 = index__OOZdistZsatZsrcZsatZsatvars_u202(v_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	va_1 = tmpTuple_1.Field0;
	vb_1 = tmpTuple_1.Field1;
	if (va_1 < 0 || va_1 >= b_p0.x.len){ raiseIndexError2(va_1,b_p0.x.len-1); goto BeforeRet_;
	}
	result = (NU64)((NU64)((NU64)(b_p0.x.p->data[va_1]) >> (NU64)(vb_1 & (64 - 1))) & 3ULL);
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___OOZdistZsatZsrcZsatZsatvars_u187)(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q* dest_p0, tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q src_p1) {
	eqcopy___OOZdistZsatZsrcZsatZsatvars_u150((&(*dest_p0).x), src_p1.x);
	(*dest_p0).invalid = src_p1.invalid;
}
N_LIB_PRIVATE N_NIMCALL(void, setVar__OOZdistZsatZsrcZsatZsatvars_u262)(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q* b_p0, NI32 v_p1, NU64 val_p2) {
	tyTuple__BUNQL5x2cKJaBSzOn5pwkg tmpTuple_1;
	NI32 va_1;
	NI32 vb_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	tmpTuple_1 = index__OOZdistZsatZsrcZsatZsatvars_u202(v_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	va_1 = tmpTuple_1.Field0;
	vb_1 = tmpTuple_1.Field1;
	if (va_1 < 0 || va_1 >= (*b_p0).x.len){ raiseIndexError2(va_1,(*b_p0).x.len-1); goto BeforeRet_;
	}
	if (va_1 < 0 || va_1 >= (*b_p0).x.len){ raiseIndexError2(va_1,(*b_p0).x.len-1); goto BeforeRet_;
	}
	(*b_p0).x.p->data[va_1] = (NU64)((NU64)((*b_p0).x.p->data[va_1] & (NU64)((NU64) ~((NU64)((NU64)(3ULL) << (NU64)(vb_1 & (64 - 1)))))) | (NU64)((NU64)(val_p2) << (NU64)(vb_1 & (64 - 1))));
	}BeforeRet_: ;
}
static N_INLINE(NIM_BOOL, containsInvalid__OOZdistZsatZsrcZsatZsatvars_u293)(NU64 x_p0) {
	NIM_BOOL result;
	NU64 y_1;
	y_1 = (NU64)((NU64)((NU64)(x_p0 & 6148914691236517205ULL)) << (NU64)(((NI)1) & (64 - 1)));
	result = !(((NU64)(x_p0 & y_1) == 0ULL));
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, containsInvalid__OOZdistZsatZsrcZsatZsatvars_u323)(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q s_p0) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		NI i_1;
		NI colontmp_;
		NI T2_;
		NI i_2;
		i_1 = (NI)0;
		colontmp_ = (NI)0;
		T2_ = s_p0.x.len;
		colontmp_ = T2_;
		i_2 = ((NI)0);
		{
			while (1) {
				NI TM__9cfZ9clC7zy1EAocw3n9aXPWQ_4;
				if (!(i_2 < colontmp_)) goto LA4;
				i_1 = i_2;
				{
					NIM_BOOL T7_;
					if (i_1 < 0 || i_1 >= s_p0.x.len){ raiseIndexError2(i_1,s_p0.x.len-1); goto BeforeRet_;
					}
					T7_ = (NIM_BOOL)0;
					T7_ = containsInvalid__OOZdistZsatZsrcZsatZsatvars_u293(s_p0.x.p->data[i_1]);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					if (!T7_) goto LA8_;
					result = NIM_TRUE;
					goto BeforeRet_;
				}
LA8_: ;
				if (nimAddInt(i_2, ((NI)1), &TM__9cfZ9clC7zy1EAocw3n9aXPWQ_4)) { raiseOverflow(); goto BeforeRet_;
				};
				i_2 = (NI)(TM__9cfZ9clC7zy1EAocw3n9aXPWQ_4);
			} LA4: ;
		}
	}
	result = NIM_FALSE;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqsink___OOZdistZsatZsrcZsatZsatvars_u193)(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q* dest_p0, tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q src_p1) {
	if ((*dest_p0).x.p != src_p1.x.p) {	eqdestroy___OOZdistZsatZsrcZsatZsatvars_u147((*dest_p0).x);
	}
(*dest_p0).x.len = src_p1.x.len; (*dest_p0).x.p = src_p1.x.p;
	(*dest_p0).invalid = src_p1.invalid;
}
N_LIB_PRIVATE N_NIMCALL(void, eqwasMoved___OOZdistZsatZsrcZsatZsatvars_u181)(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q* dest_p0) {
	(*dest_p0).x.len = 0; (*dest_p0).x.p = NIM_NIL;
	(*dest_p0).invalid = 0;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___OOZdistZsatZsrcZsatZsatvars_u184)(tyObject_Solution__1PhBJDgAsOvN39cKpSkuZ5Q* dest_p0) {
	eqdestroy___OOZdistZsatZsrcZsatZsatvars_u147((*dest_p0).x);
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___OOZdistZsatZsrcZsatZsatvars_u227)(NI32* dest_p0) {
}
