/* Generated by Nim Compiler v1.2.4 */
/*   (c) 2020 Andreas Rumpf */
/* The generated code is subject to the original license. */
#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
#define nimfr_(x, y)
#define nimln_(x, y)
N_LIB_PRIVATE N_NOINLINE(void, raiseDivByZero)(void);
static N_INLINE(NIM_BOOL, nimDivInt)(NI a, NI b, NI* res);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NIM_BOOL, nimAddInt)(NI a, NI b, NI* res);
static N_INLINE(NIM_BOOL, nimMulInt)(NI a, NI b, NI* res);
static N_INLINE(NF, toFloat__y1Fm9aHmxw9bS2jir137Fu5gsystem)(NI i);
static N_INLINE(NF, abs__BRaAqinz6OWTHkALb4oj6Qsystem)(NF x);
N_LIB_PRIVATE NI gFrontEndId__gyRrMPnY7JyC6tAu9bCfGng;
static N_INLINE(NIM_BOOL, nimDivInt)(NI a, NI b, NI* res) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (a == ((NI) (IL64(-9223372036854775807) - IL64(1))));
		if (!(T3_)) goto LA4_;
		T3_ = (b == ((NI) -1));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = NIM_TRUE;
	}
	goto LA1_;
	LA5_: ;
	{
		(*res) = (NI)(a / b);
	}
	LA1_: ;
	return result;
}
static N_INLINE(NIM_BOOL, nimAddInt)(NI a, NI b, NI* res) {
	NIM_BOOL result;
	NI r;
	result = (NIM_BOOL)0;
	r = ((NI) ((NU)((NU64)(((NU) (a))) + (NU64)(((NU) (b))))));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI) 0) <= (NI)(r ^ a));
		if (T3_) goto LA4_;
		T3_ = (((NI) 0) <= (NI)(r ^ b));
		LA4_: ;
		if (!T3_) goto LA5_;
		(*res) = r;
	}
	goto LA1_;
	LA5_: ;
	{
		result = NIM_TRUE;
	}
	LA1_: ;
	return result;
}
static N_INLINE(NF, toFloat__y1Fm9aHmxw9bS2jir137Fu5gsystem)(NI i) {
	NF result;
	result = (NF)0;
	result = ((NF) (i));
	return result;
}
static N_INLINE(NF, abs__BRaAqinz6OWTHkALb4oj6Qsystem)(NF x) {
	NF result;
	result = (NF)0;
	{
		if (!(x < 0.0)) goto LA3_;
		result = -(x);
	}
	goto LA1_;
	LA3_: ;
	{
		result = x;
	}
	LA1_: ;
	return result;
}
static N_INLINE(NIM_BOOL, nimMulInt)(NI a, NI b, NI* res) {
	NIM_BOOL result;
	NI r;
	NF floatProd;
	NF T1_;
	NF T2_;
	NF resAsFloat;
	result = (NIM_BOOL)0;
	r = ((NI) ((NU)((NU64)(((NU) (a))) * (NU64)(((NU) (b))))));
	T1_ = (NF)0;
	T1_ = toFloat__y1Fm9aHmxw9bS2jir137Fu5gsystem(a);
	T2_ = (NF)0;
	T2_ = toFloat__y1Fm9aHmxw9bS2jir137Fu5gsystem(b);
	floatProd = ((NF)(T1_) * (NF)(T2_));
	resAsFloat = toFloat__y1Fm9aHmxw9bS2jir137Fu5gsystem(r);
	{
		if (!(resAsFloat == floatProd)) goto LA5_;
		(*res) = r;
	}
	goto LA3_;
	LA5_: ;
	{
		{
			NF T10_;
			NF T11_;
			T10_ = (NF)0;
			T10_ = abs__BRaAqinz6OWTHkALb4oj6Qsystem(((NF)(resAsFloat) - (NF)(floatProd)));
			T11_ = (NF)0;
			T11_ = abs__BRaAqinz6OWTHkALb4oj6Qsystem(floatProd);
			if (!(((NF)(3.2000000000000000e+01) * (NF)(T10_)) <= T11_)) goto LA12_;
			(*res) = r;
		}
		goto LA8_;
		LA12_: ;
		{
			result = NIM_TRUE;
		}
		LA8_: ;
	}
	LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, idSynchronizationPoint__o9blMKDNUEgfiqOxiffy8Tw)(NI idRange) {
	NI TM__OcNXKFm0N2ybP5hO0iXdjw_2;
	NI TM__OcNXKFm0N2ybP5hO0iXdjw_3;
	NI TM__OcNXKFm0N2ybP5hO0iXdjw_4;
	NI TM__OcNXKFm0N2ybP5hO0iXdjw_5;
	if (idRange == 0){ raiseDivByZero(); }
	if (nimDivInt(gFrontEndId__gyRrMPnY7JyC6tAu9bCfGng, idRange, &TM__OcNXKFm0N2ybP5hO0iXdjw_2)) { raiseOverflow(); };
	if (nimAddInt((NI)(TM__OcNXKFm0N2ybP5hO0iXdjw_2), ((NI) 1), &TM__OcNXKFm0N2ybP5hO0iXdjw_3)) { raiseOverflow(); };
	if (nimMulInt((NI)(TM__OcNXKFm0N2ybP5hO0iXdjw_3), idRange, &TM__OcNXKFm0N2ybP5hO0iXdjw_4)) { raiseOverflow(); };
	if (nimAddInt((NI)(TM__OcNXKFm0N2ybP5hO0iXdjw_4), ((NI) 1), &TM__OcNXKFm0N2ybP5hO0iXdjw_5)) { raiseOverflow(); };
	gFrontEndId__gyRrMPnY7JyC6tAu9bCfGng = (NI)(TM__OcNXKFm0N2ybP5hO0iXdjw_5);
}
