/* Generated by Nim Compiler v1.6.14 */
#define NIM_INTBITS 32

#include "nimbase.h"
#include <math.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
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg;
N_LIB_PRIVATE N_NIMCALL(tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg, classify__pureZmath_147)(NF x);
static N_INLINE(NIM_BOOL, signbit__astalgo_926)(NF x);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_LIB_PRIVATE N_NIMCALL(void, addFloatRoundtrip__system_3135)(NimStringDesc** result, NF x);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__system_1733)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
static N_INLINE(NIM_BOOL, signbit__cgen_17856)(NF32 x);
N_LIB_PRIVATE N_NIMCALL(void, addFloatRoundtrip__system_6827)(NimStringDesc** result, NF32 x);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_2, "-NAN", 4);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_3, "NAN", 3);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_4, "-0.0", 4);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_5, "0.0", 3);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_6, "INF", 3);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_7, "-INF", 4);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_8, "-0.0f", 5);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_9, "0.0f", 4);
STRING_LITERAL(TM__qENY1F9aF8k8WjeLE9cUs6Mw_10, "f", 1);
static N_INLINE(NIM_BOOL, signbit__astalgo_926)(NF x) {
	NIM_BOOL result;
	int T1_;
	result = (NIM_BOOL)0;
	T1_ = (int)0;
	T1_ = signbit(x);
	result = !((T1_ == ((NI32) 0)));
	return result;
}
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest, source, ((size_t) (size)));
}
static N_INLINE(void, copyMem__system_1733)(void* dest, void* source, NI size) {
	nimCopyMem(dest, source, size);
}
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	{
		if (!!((src == ((NimStringDesc*) NIM_NIL)))) goto LA3_;
		copyMem__system_1733(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
		(*dest).Sup.len += (*src).Sup.len;
	}
	LA3_: ;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, toStrMaxPrecision__astalgo_920)(NF f) {
	NimStringDesc* result;
	tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg T1_;
	result = NIM_NIL;
	T1_ = (tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg)0;
	T1_ = classify__pureZmath_147(f);
	switch (T1_) {
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 4):
	{
		{
			NIM_BOOL T5_;
			T5_ = (NIM_BOOL)0;
			T5_ = signbit__astalgo_926(f);
			if (!T5_) goto LA6_;
			result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_2));
		}
		goto LA3_;
		LA6_: ;
		{
			result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_3));
		}
		LA3_: ;
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 3):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_4));
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 2):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_5));
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 5):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_6));
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 6):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_7));
	}
	break;
	default:
	{
		addFloatRoundtrip__system_3135((&result), f);
		result = resizeString(result, 0);
appendString(result, ((NimStringDesc*) NIM_NIL));
	}
	break;
	}
	return result;
}
static N_INLINE(NIM_BOOL, signbit__cgen_17856)(NF32 x) {
	NIM_BOOL result;
	int T1_;
	result = (NIM_BOOL)0;
	T1_ = (int)0;
	T1_ = signbit(x);
	result = !((T1_ == ((NI32) 0)));
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, toStrMaxPrecision__cgen_17850)(NF32 f) {
	NimStringDesc* result;
	tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg T1_;
	result = NIM_NIL;
	T1_ = (tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg)0;
	T1_ = classify__pureZmath_147(((NF) (f)));
	switch (T1_) {
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 4):
	{
		{
			NIM_BOOL T5_;
			T5_ = (NIM_BOOL)0;
			T5_ = signbit__cgen_17856(f);
			if (!T5_) goto LA6_;
			result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_2));
		}
		goto LA3_;
		LA6_: ;
		{
			result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_3));
		}
		LA3_: ;
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 3):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_8));
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 2):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_9));
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 5):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_6));
	}
	break;
	case ((tyEnum_FloatClass__sXQOxr9c3EE79allMY12fv9cg) 6):
	{
		result = copyString(((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_7));
	}
	break;
	default:
	{
		addFloatRoundtrip__system_6827((&result), f);
		result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TM__qENY1F9aF8k8WjeLE9cUs6Mw_10));
	}
	break;
	}
	return result;
}
