/* Generated by Nim Compiler v1.6.6 */
#define NIM_INTBITS 64

#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__pPga1yW9b8J9cwNnm9b1aPRnA;
N_LIB_PRIVATE N_NIMCALL(tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA, 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_3127)(NimStringDesc** result, NF x);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__system_1727)(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_17775)(NF32 x);
N_LIB_PRIVATE N_NIMCALL(void, addFloatRoundtrip__system_6835)(NimStringDesc** result, NF32 x);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_2, "-NAN", 4);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_3, "NAN", 3);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_4, "-0.0", 4);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_5, "0.0", 3);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_6, "INF", 3);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_7, "-INF", 4);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_8, "-0.0f", 5);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_9, "0.0f", 4);
STRING_LITERAL(TM__mZLUkjbotQF2WK9bQcNKBCA_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_1727)(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_1727(((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__pPga1yW9b8J9cwNnm9b1aPRnA T1_;
	result = NIM_NIL;
	T1_ = (tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA)0;
	T1_ = classify__pureZmath_147(f);
	switch (T1_) {
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 4):
	{
		{
			NIM_BOOL T5_;
			T5_ = (NIM_BOOL)0;
			T5_ = signbit__astalgo_926(f);
			if (!T5_) goto LA6_;
			result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_2));
		}
		goto LA3_;
		LA6_: ;
		{
			result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_3));
		}
		LA3_: ;
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 3):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_4));
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 2):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_5));
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 5):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_6));
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 6):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_7));
	}
	break;
	default:
	{
		addFloatRoundtrip__system_3127((&result), f);
		result = resizeString(result, 0);
appendString(result, ((NimStringDesc*) NIM_NIL));
	}
	break;
	}
	return result;
}
static N_INLINE(NIM_BOOL, signbit__cgen_17775)(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_17769)(NF32 f) {
	NimStringDesc* result;
	tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA T1_;
	result = NIM_NIL;
	T1_ = (tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA)0;
	T1_ = classify__pureZmath_147(((NF) (f)));
	switch (T1_) {
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 4):
	{
		{
			NIM_BOOL T5_;
			T5_ = (NIM_BOOL)0;
			T5_ = signbit__cgen_17775(f);
			if (!T5_) goto LA6_;
			result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_2));
		}
		goto LA3_;
		LA6_: ;
		{
			result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_3));
		}
		LA3_: ;
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 3):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_8));
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 2):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_9));
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 5):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_6));
	}
	break;
	case ((tyEnum_FloatClass__pPga1yW9b8J9cwNnm9b1aPRnA) 6):
	{
		result = copyString(((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_7));
	}
	break;
	default:
	{
		addFloatRoundtrip__system_6835((&result), f);
		result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TM__mZLUkjbotQF2WK9bQcNKBCA_10));
	}
	break;
	}
	return result;
}
