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

#include "nimbase.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 NU8 tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw;
static N_INLINE(NIM_BOOL, isNaN__pureZmath_u214)(NF x_p0);
static N_INLINE(NF, abs__pureZmath_u219)(NF x_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
extern NIM_BOOL nimInErrorMode__system_u4143;
N_LIB_PRIVATE N_NIMCALL(NI, nextPowerOfTwo__pureZmath_u256)(NI x_p0) {
	NI result;
	result = (NI)(x_p0 - ((NI)1));
	result = (NI)(result | (NI)((NI32)(result) >> (NU32)(((NI)16) & (32 - 1))));
	result = (NI)(result | (NI)((NI32)(result) >> (NU32)(((NI)8) & (32 - 1))));
	result = (NI)(result | (NI)((NI32)(result) >> (NU32)(((NI)4) & (32 - 1))));
	result = (NI)(result | (NI)((NI32)(result) >> (NU32)(((NI)2) & (32 - 1))));
	result = (NI)(result | (NI)((NI32)(result) >> (NU32)(((NI)1) & (32 - 1))));
	result += (NI)(((NI)1) + (x_p0 <= ((NI)0)));
	return result;
}
static N_INLINE(NIM_BOOL, isNaN__pureZmath_u214)(NF x_p0) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	result = isnan(x_p0);
	return result;
}
static N_INLINE(NF, abs__pureZmath_u219)(NF x_p0) {
	NF result;
	result = (NF)0;
	result = fabs(x_p0);
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4143);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw, classify__pureZmath_u211)(NF x_p0) {
	tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = isNaN__pureZmath_u214(x_p0);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T3_) goto LA4_;
		result = ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)4);
		goto BeforeRet_;
	}
LA4_: ;
	{
		if (!(x_p0 == 0.0)) goto LA8_;
		{
			if (!(((NF)(1.0) / (NF)(x_p0)) == INF)) goto LA12_;
			result = ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)2);
			goto BeforeRet_;
		}
		goto LA10_;
LA12_: ;
		{
			result = ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)3);
			goto BeforeRet_;
		}
LA10_: ;
	}
LA8_: ;
	{
		if (!(((NF)(x_p0) * (NF)(0.5)) == x_p0)) goto LA17_;
		{
			if (!(0.0 < x_p0)) goto LA21_;
			result = ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)5);
			goto BeforeRet_;
		}
		goto LA19_;
LA21_: ;
		{
			result = ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)6);
			goto BeforeRet_;
		}
LA19_: ;
	}
LA17_: ;
	{
		NF T26_;
		T26_ = (NF)0;
		T26_ = abs__pureZmath_u219(x_p0);
		if (!(T26_ < 2.225073858507201e-308)) goto LA27_;
		result = ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)1);
		goto BeforeRet_;
	}
LA27_: ;
	result = ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)0);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isPowerOfTwo__pureZmath_u253)(NI x_p0) {
	NIM_BOOL result;
	NIM_BOOL T1_;
{	T1_ = (NIM_BOOL)0;
	T1_ = (((NI)0) < x_p0);
	if (!(T1_)) goto LA2_;
	T1_ = ((NI)(x_p0 & (NI)(x_p0 - ((NI)1))) == ((NI)0));
LA2_: ;
	result = T1_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NF, round__vm_u13588)(NF x_p0, NI places_p1) {
	NF result;
	{
		if (!(places_p1 == ((NI)0))) goto LA3_;
		result = round(x_p0);
	}
	goto LA1_;
LA3_: ;
	{
		NF mult_1;
		NF T6_;
		mult_1 = pow(10.0, ((NF) (places_p1)));
		T6_ = (NF)0;
		T6_ = round(((NF)(x_p0) * (NF)(mult_1)));
		result = ((NF)(T6_) / (NF)(mult_1));
	}
LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI64, floorDiv__pureZtimes_u303)(NI64 x_p0, NI64 y_p1) {
	NI64 result;
	NI64 r_1;
	result = (NI64)(x_p0 / y_p1);
	r_1 = (NI64)(x_p0 % y_p1);
	{
		NIM_BOOL T3_;
		NIM_BOOL T4_;
		NIM_BOOL T7_;
		T3_ = (NIM_BOOL)0;
		T4_ = (NIM_BOOL)0;
		T4_ = (IL64(0) < r_1);
		if (!(T4_)) goto LA5_;
		T4_ = (y_p1 < IL64(0));
LA5_: ;
		T3_ = T4_;
		if (T3_) goto LA6_;
		T7_ = (NIM_BOOL)0;
		T7_ = (r_1 < IL64(0));
		if (!(T7_)) goto LA8_;
		T7_ = (IL64(0) < y_p1);
LA8_: ;
		T3_ = T7_;
LA6_: ;
		if (!T3_) goto LA9_;
		result -= ((NI)1);
	}
LA9_: ;
	return result;
}
