1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
/* Generated by Nim Compiler v2.2.0 */
#define NIM_INTBITS 64
#define NIM_EmulateOverflowChecks
#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__system_u5201)(NF x_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
extern NIM_BOOL nimInErrorMode__system_u4274;
N_LIB_PRIVATE N_NIMCALL(NI, nextPowerOfTwo__pureZmath_u255)(NI x_p0) {
NI result;
result = (NI)(x_p0 - ((NI)1));
result = (NI)(result | (NI)((NI64)(result) >> (NU64)(((NI)32))));
result = (NI)(result | (NI)((NI64)(result) >> (NU64)(((NI)16))));
result = (NI)(result | (NI)((NI64)(result) >> (NU64)(((NI)8))));
result = (NI)(result | (NI)((NI64)(result) >> (NU64)(((NI)4))));
result = (NI)(result | (NI)((NI64)(result) >> (NU64)(((NI)2))));
result = (NI)(result | (NI)((NI64)(result) >> (NU64)(((NI)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__system_u5201)(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_u4274);
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__system_u5201(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_u252)(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_u13252)(NF x_p0, NI places_p1) {
NF result;
{
if (!(places_p1 == ((NI)0))) goto LA3_;
result = round(x_p0);
}
goto LA1_;
LA3_: ;
{
NF mult;
NF T6_;
mult = pow(10.0, ((NF) (places_p1)));
T6_ = (NF)0;
T6_ = round(((NF)(x_p0) * (NF)(mult)));
result = ((NF)(T6_) / (NF)(mult));
}
LA1_: ;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NI64, floorDiv__pureZtimes_u303)(NI64 x_p0, NI64 y_p1) {
NI64 result;
NI64 r;
result = (NI64)(x_p0 / y_p1);
r = (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);
if (!(T4_)) goto LA5_;
T4_ = (y_p1 < IL64(0));
LA5_: ;
T3_ = T4_;
if (T3_) goto LA6_;
T7_ = (NIM_BOOL)0;
T7_ = (r < 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;
}
|