/* Generated by Nim Compiler v0.15.0 */
/*   (c) 2016 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 64

#include "nimbase.h"
#include <string.h>
#include <stdio.h>
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Valueerror3646 Valueerror3646;
typedef struct Exception Exception;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Cell47305 Cell47305;
typedef struct Cellseq47321 Cellseq47321;
typedef struct Gcheap49818 Gcheap49818;
typedef struct Gcstack49816 Gcstack49816;
typedef struct Memregion29486 Memregion29486;
typedef struct Smallchunk29440 Smallchunk29440;
typedef struct Llchunk29480 Llchunk29480;
typedef struct Bigchunk29442 Bigchunk29442;
typedef struct Intset29414 Intset29414;
typedef struct Trunk29410 Trunk29410;
typedef struct Avlnode29484 Avlnode29484;
typedef struct Gcstat49814 Gcstat49814;
typedef struct Cellset47317 Cellset47317;
typedef struct Pagedesc47313 Pagedesc47313;
typedef struct TY135002 TY135002;
typedef struct Basechunk29438 Basechunk29438;
typedef struct Freecell29430 Freecell29430;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 Tnimkind3403;
typedef NU8 Tnimtypeflag3409Set;
typedef N_NIMCALL_PTR(void, TY3489) (void* p0, NI op0);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p0);
struct  TNimType  {
NI size;
Tnimkind3403 kind;
Tnimtypeflag3409Set flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Exception  {
  TNimObject Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  Valueerror3646  {
  Exception Sup;
};
typedef NU8 Tnimnodekind3405;
struct  TNimNode  {
Tnimnodekind3405 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Cell47305  {
NI refcount;
TNimType* typ;
};
struct  Cellseq47321  {
NI len;
NI cap;
Cell47305** d;
};
typedef Smallchunk29440* TY29501[512];
typedef Trunk29410* Trunkbuckets29412[256];
struct  Intset29414  {
Trunkbuckets29412 data;
};
struct  Memregion29486  {
NI minlargeobj;
NI maxlargeobj;
TY29501 freesmallchunks;
Llchunk29480* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk29442* freechunkslist;
Intset29414 chunkstarts;
Avlnode29484* root;
Avlnode29484* deleted;
Avlnode29484* last;
Avlnode29484* freeavlnodes;
NIM_BOOL locked;
};
struct  Gcstat49814  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Cellset47317  {
NI counter;
NI max;
Pagedesc47313* head;
Pagedesc47313** data;
};
struct  Gcheap49818  {
Gcstack49816* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq47321 zct;
Cellseq47321 decstack;
Cellseq47321 tempstack;
NI recgclock;
Memregion29486 region;
Gcstat49814 stat;
Cellset47317 marked;
Cellseq47321 additionalroots;
};
typedef NimStringDesc* TY193732[1];
typedef NI Skiptable109518[256];
typedef NU8 char136Set[32];
typedef NU8 Floatformatmode111202;
typedef NIM_CHAR TY111408[6];
typedef NIM_CHAR TY111412[2501];
typedef NIM_CHAR TY111404[3];
typedef NU8 Binaryprefixmode111544;
typedef NimStringDesc* TY419062[9];
typedef NIM_CHAR TY111471[2];
struct  Gcstack49816  {
Gcstack49816* prev;
Gcstack49816* next;
void* starts;
void* pos;
NI maxstacksize;
};
struct  Basechunk29438  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk29440  {
  Basechunk29438 Sup;
Smallchunk29440* next;
Smallchunk29440* prev;
Freecell29430* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk29480  {
NI size;
NI acc;
Llchunk29480* next;
};
struct  Bigchunk29442  {
  Basechunk29438 Sup;
Bigchunk29442* next;
Bigchunk29442* prev;
NI align;
NF data;
};
typedef NI TY29419[8];
struct  Trunk29410  {
Trunk29410* next;
NI key;
TY29419 bits;
};
typedef Avlnode29484* TY29491[2];
struct  Avlnode29484  {
TY29491 link;
NI key;
NI upperbound;
NI level;
};
struct  Pagedesc47313  {
Pagedesc47313* next;
NI key;
TY29419 bits;
};
struct  Freecell29430  {
Freecell29430* next;
NI zerofield;
};
struct TY135002 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
N_NIMCALL(NIM_CHAR, nsuToLowerAsciiChar)(NIM_CHAR c0);
N_NIMCALL(NimStringDesc*, mnewString)(NI len0);
N_NIMCALL(NimStringDesc*, mnewString)(NI len0);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space0);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap0);
N_NIMCALL(void, nsuAddf)(NimStringDesc** s0, NimStringDesc* formatstr0, NimStringDesc** a0, NI a0Len0);
N_NOINLINE(void, invalidformatstring_111745_4286263276)(void);
N_NIMCALL(void*, newObj)(TNimType* typ0, NI size0);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src0);
static N_INLINE(void, nimGCunrefNoCycle)(void* p0);
static N_INLINE(Cell47305*, usrtocell_51440_1689653243)(void* usr0);
static N_INLINE(void, rtladdzct_52601_1689653243)(Cell47305* c0);
N_NOINLINE(void, addzct_51417_1689653243)(Cellseq47321* s0, Cell47305* c0);
N_NIMCALL(void, raiseException)(Exception* e0, NCSTRING ename0);
static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0);
static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest0, NI addlen0);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s0, NIM_CHAR c0);
N_NIMCALL(NI, findnormalized_111728_4286263276)(NimStringDesc* x0, NimStringDesc** inarray0, NI inarray0Len0);
N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a0, NimStringDesc* b0);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s0, NI start_79210_1689653243, NI last0);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s0, NI first0, NI last0);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src0);
N_NIMCALL(NI, npuParseFloat)(NimStringDesc* s0, NF* number0, NI start0);
static N_INLINE(void, asgnRefNoCycle)(void** dest0, void* src0);
N_NIMCALL(NI, npuParseBiggestInt)(NimStringDesc* s0, NI64* number0, NI start0);
N_NIMCALL(void, preprocesssub_109524_4286263276)(NimStringDesc* sub0, NI* a0);
N_NIMCALL(NI, findaux_109566_4286263276)(NimStringDesc* s0, NimStringDesc* sub0, NI start0, Skiptable109518 a0);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s0, NI start0);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s0, NI first0);
N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s0, char136Set chars0, NI start0);
N_NIMCALL(NI, npuParseInt)(NimStringDesc* s0, NI* number0, NI start0);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s0, NI newlen0);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s0, NIM_CHAR sub0, NI start0);
N_NIMCALL(void*, newSeq)(TNimType* typ0, NI len0);
N_NIMCALL(TGenericSeq*, incrSeqV2)(TGenericSeq* seq0, NI elemsize0);
N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x0, NI len0);
N_NIMCALL(NimStringDesc*, nsuToLowerAsciiStr)(NimStringDesc* s0);
N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x0);
static N_INLINE(void, appendChar)(NimStringDesc* dest0, NIM_CHAR c0);
N_NIMCALL(NimStringDesc*, nsuformatBiggestFloat)(NF f0, Floatformatmode111202 format0, NI precision0, NIM_CHAR decimalsep0);
N_NIMCALL(void, genericAssign)(void* dest0, void* src0, TNimType* mt0);
N_NIMCALL(NimStringDesc*, nsuformatFloat)(NF f0, Floatformatmode111202 format0, NI precision0, NIM_CHAR decimalsep0);
N_NIMCALL(void, trimzeros_111462_4286263276)(NimStringDesc** x0);
N_NIMCALL(NIM_BOOL, contains_110046_4286263276)(NimStringDesc* s0, NIM_CHAR c0);
N_NIMCALL(TY135002*, nsuSplitChar)(NimStringDesc* s0, NIM_CHAR sep0, NI maxsplit0);
N_NIMCALL(void, unsureAsgnRef)(void** dest0, void* src0);
static N_INLINE(NIM_BOOL, contains_111475_1689653243)(NIM_CHAR* a0, NI a0Len0, NIM_CHAR item0);
static N_INLINE(NI, find_111485_1689653243)(NIM_CHAR* a0, NI a0Len0, NIM_CHAR item0);
STRING_LITERAL(T4286263276_2, "invalid format string", 21);
STRING_LITERAL(T4286263276_3, "invalid float: ", 15);
STRING_LITERAL(T4286263276_4, "invalid integer: ", 17);
STRING_LITERAL(T4286263276_5, "0123456789ABCDEF", 16);
STRING_LITERAL(T4286263276_6, "", 0);
STRING_LITERAL(T4286263276_7, "\\x", 2);
STRING_LITERAL(T4286263276_8, "\\\\", 2);
STRING_LITERAL(T4286263276_9, "\\\'", 2);
STRING_LITERAL(T4286263276_10, "\\\"", 2);
NIM_CONST TY111404 floatformattochar_111401_4286263276 = {103,
102,
101}
;
STRING_LITERAL(T4286263276_11, "k", 1);
STRING_LITERAL(T4286263276_12, "M", 1);
STRING_LITERAL(T4286263276_13, "G", 1);
STRING_LITERAL(T4286263276_14, "T", 1);
STRING_LITERAL(T4286263276_15, "P", 1);
STRING_LITERAL(T4286263276_16, "E", 1);
STRING_LITERAL(T4286263276_17, "Z", 1);
STRING_LITERAL(T4286263276_18, "Y", 1);
NIM_CONST TY419062 collprefixes_111557_4286263276 = {((NimStringDesc*) &T4286263276_6),
((NimStringDesc*) &T4286263276_11),
((NimStringDesc*) &T4286263276_12),
((NimStringDesc*) &T4286263276_13),
((NimStringDesc*) &T4286263276_14),
((NimStringDesc*) &T4286263276_15),
((NimStringDesc*) &T4286263276_16),
((NimStringDesc*) &T4286263276_17),
((NimStringDesc*) &T4286263276_18)}
;
STRING_LITERAL(T4286263276_19, "Ki", 2);
STRING_LITERAL(T4286263276_20, "Mi", 2);
STRING_LITERAL(T4286263276_21, "Gi", 2);
STRING_LITERAL(T4286263276_22, "Ti", 2);
STRING_LITERAL(T4286263276_23, "Pi", 2);
STRING_LITERAL(T4286263276_24, "Ei", 2);
STRING_LITERAL(T4286263276_25, "Zi", 2);
STRING_LITERAL(T4286263276_26, "Yi", 2);
NIM_CONST TY419062 iecprefixes_111554_4286263276 = {((NimStringDesc*) &T4286263276_6),
((NimStringDesc*) &T4286263276_19),
((NimStringDesc*) &T4286263276_20),
((NimStringDesc*) &T4286263276_21),
((NimStringDesc*) &T4286263276_22),
((NimStringDesc*) &T4286263276_23),
((NimStringDesc*) &T4286263276_24),
((NimStringDesc*) &T4286263276_25),
((NimStringDesc*) &T4286263276_26)}
;
NIM_CONST TY111471 T4286263276_27 = {44,
46}
;
STRING_LITERAL(T4286263276_28, "e", 1);
STRING_LITERAL(T4286263276_29, " ", 1);
STRING_LITERAL(T4286263276_30, "B", 1);
extern TNimType NTI23025; /* ref ValueError */
extern TNimType NTI3646; /* ValueError */
extern Gcheap49818 gch_49858_1689653243;
extern TNimType NTI135002; /* seq[string] */
extern TNimType NTI104; /* int */
TNimType NTI109518; /* SkipTable */
extern TNimType NTI419062; /* array[0..8, string] */

N_NIMCALL(NIM_CHAR, nsuToLowerAsciiChar)(NIM_CHAR c0) {
	NIM_CHAR result0;
	result0 = (NIM_CHAR)0;
	{
		if (!(((NU8)(c0)) >= ((NU8)(65)) && ((NU8)(c0)) <= ((NU8)(90)))) goto LA3;
		result0 = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c0)))) + ((NI) 32))))));
	}
	goto LA1;
	LA3: ;
	{
		result0 = c0;
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a0, NimStringDesc* b0) {
	NI result0;
	NI i0;
	NI j0;
	result0 = (NI)0;
	i0 = ((NI) 0);
	j0 = ((NI) 0);
	{
		while (1) {
			NIM_CHAR aa0;
			NIM_CHAR bb0;
			{
				while (1) {
					if (!((NU8)(a0->data[i0]) == (NU8)(95))) goto LA4;
					i0 += ((NI) 1);
				} LA4: ;
			}
			{
				while (1) {
					if (!((NU8)(b0->data[j0]) == (NU8)(95))) goto LA6;
					j0 += ((NI) 1);
				} LA6: ;
			}
			aa0 = nsuToLowerAsciiChar(a0->data[i0]);
			bb0 = nsuToLowerAsciiChar(b0->data[j0]);
			result0 = (NI)(((NI) (((NU8)(aa0)))) - ((NI) (((NU8)(bb0)))));
			{
				NIM_BOOL LOC9;
				LOC9 = (NIM_BOOL)0;
				LOC9 = !((result0 == ((NI) 0)));
				if (LOC9) goto LA10;
				LOC9 = ((NU8)(aa0) == (NU8)(0));
				LA10: ;
				if (!LOC9) goto LA11;
				goto LA1;
			}
			LA11: ;
			i0 += ((NI) 1);
			j0 += ((NI) 1);
		}
	} LA1: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuToOctal)(NIM_CHAR c0) {
	NimStringDesc* result0;
	NI val0;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(((NI) 3));
	val0 = ((NU8)(c0));
	{
		NI i_107227_4286263276;
		NI res_107242_4286263276;
		i_107227_4286263276 = (NI)0;
		res_107242_4286263276 = ((NI) 2);
		{
			while (1) {
				if (!(((NI) 0) <= res_107242_4286263276)) goto LA3;
				i_107227_4286263276 = res_107242_4286263276;
				result0->data[i_107227_4286263276] = ((NIM_CHAR) (((NI) ((NI)(((NI) ((NI)(((NI) (val0)) % ((NI) 8)))) + ((NI) 48))))));
				val0 = ((NI) ((NI)(((NI) (val0)) / ((NI) 8))));
				res_107242_4286263276 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

static N_INLINE(Cell47305*, usrtocell_51440_1689653243)(void* usr0) {
	Cell47305* result0;
	result0 = (Cell47305*)0;
	result0 = ((Cell47305*) ((NI)((NU64)(((NI) (usr0))) - (NU64)(((NI)sizeof(Cell47305))))));
	return result0;
}

static N_INLINE(void, rtladdzct_52601_1689653243)(Cell47305* c0) {
	addzct_51417_1689653243((&gch_49858_1689653243.zct), c0);
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p0) {
	Cell47305* c0;
	c0 = usrtocell_51440_1689653243(p0);
	{
		(*c0).refcount -= ((NI) 8);
		if (!((NU64)((*c0).refcount) < (NU64)(((NI) 8)))) goto LA3;
		rtladdzct_52601_1689653243(c0);
	}
	LA3: ;
}

N_NOINLINE(void, invalidformatstring_111745_4286263276)(void) {
	Valueerror3646* e_111750_4286263276;
	NimStringDesc* LOC1;
	e_111750_4286263276 = (Valueerror3646*)0;
	e_111750_4286263276 = (Valueerror3646*) newObj((&NTI23025), sizeof(Valueerror3646));
	(*e_111750_4286263276).Sup.Sup.m_type = (&NTI3646);
	LOC1 = (NimStringDesc*)0;
	LOC1 = (*e_111750_4286263276).Sup.message; (*e_111750_4286263276).Sup.message = copyStringRC1(((NimStringDesc*) &T4286263276_2));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	raiseException((Exception*)e_111750_4286263276, "ValueError");
}

static N_INLINE(void, copymem_7485_1689653243)(void* dest0, void* source0, NI size0) {
	void* LOC1;
	LOC1 = (void*)0;
	LOC1 = memcpy(dest0, source0, ((size_t) (size0)));
}

static N_INLINE(void, appendString)(NimStringDesc* dest0, NimStringDesc* src0) {
	copymem_7485_1689653243(((void*) ((&(*dest0).data[((*dest0).Sup.len)- 0]))), ((void*) ((*src0).data)), ((NI) ((NI)((*src0).Sup.len + ((NI) 1)))));
	(*dest0).Sup.len += (*src0).Sup.len;
}

N_NIMCALL(NI, findnormalized_111728_4286263276)(NimStringDesc* x0, NimStringDesc** inarray0, NI inarray0Len0) {
	NI result0;
	NI i0;
{	result0 = (NI)0;
	i0 = ((NI) 0);
	{
		while (1) {
			if (!(i0 < (inarray0Len0-1))) goto LA2;
			{
				NI LOC5;
				LOC5 = (NI)0;
				LOC5 = nsuCmpIgnoreStyle(x0, inarray0[i0]);
				if (!(LOC5 == ((NI) 0))) goto LA6;
				result0 = i0;
				goto BeforeRet;
			}
			LA6: ;
			i0 += ((NI) 2);
		} LA2: ;
	}
	result0 = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(void, nsuAddf)(NimStringDesc** s0, NimStringDesc* formatstr0, NimStringDesc** a0, NI a0Len0) {
	NI i0;
	NI num0;
	i0 = ((NI) 0);
	num0 = ((NI) 0);
	{
		while (1) {
			if (!(i0 < (formatstr0 ? formatstr0->Sup.len : 0))) goto LA2;
			{
				if (!((NU8)(formatstr0->data[i0]) == (NU8)(36))) goto LA5;
				switch (((NU8)(formatstr0->data[(NI)(i0 + ((NI) 1))]))) {
				case 35:
				{
					{
						if (!((NU64)((a0Len0-1)) < (NU64)(num0))) goto LA10;
						invalidformatstring_111745_4286263276();
					}
					LA10: ;
					(*s0) = resizeString((*s0), a0[num0]->Sup.len + 0);
appendString((*s0), a0[num0]);
					i0 += ((NI) 2);
					num0 += ((NI) 1);
				}
				break;
				case 36:
				{
					(*s0) = addChar((*s0), 36);
					i0 += ((NI) 2);
				}
				break;
				case 49 ... 57:
				case 45:
				{
					NI j0;
					NIM_BOOL negative0;
					NI idx0;
					j0 = ((NI) 0);
					i0 += ((NI) 1);
					negative0 = ((NU8)(formatstr0->data[i0]) == (NU8)(45));
					{
						if (!negative0) goto LA16;
						i0 += ((NI) 1);
					}
					LA16: ;
					{
						while (1) {
							if (!(((NU8)(formatstr0->data[i0])) >= ((NU8)(48)) && ((NU8)(formatstr0->data[i0])) <= ((NU8)(57)))) goto LA19;
							j0 = (NI)((NI)((NI)(j0 * ((NI) 10)) + ((NI) (((NU8)(formatstr0->data[i0]))))) - ((NI) 48));
							i0 += ((NI) 1);
						} LA19: ;
					}
					{
						if (!!(negative0)) goto LA22;
						idx0 = (NI)(j0 - ((NI) 1));
					}
					goto LA20;
					LA22: ;
					{
						idx0 = (NI)(a0Len0 - j0);
					}
					LA20: ;
					{
						if (!((NU64)((a0Len0-1)) < (NU64)(idx0))) goto LA27;
						invalidformatstring_111745_4286263276();
					}
					LA27: ;
					(*s0) = resizeString((*s0), a0[idx0]->Sup.len + 0);
appendString((*s0), a0[idx0]);
				}
				break;
				case 123:
				{
					NI j0;
					NI x0;
					NimStringDesc* LOC32;
					j0 = (NI)(i0 + ((NI) 1));
					{
						while (1) {
							if (!!((((NU8)(formatstr0->data[j0])) == ((NU8)(0)) || ((NU8)(formatstr0->data[j0])) == ((NU8)(125))))) goto LA31;
							j0 += ((NI) 1);
						} LA31: ;
					}
					LOC32 = (NimStringDesc*)0;
					LOC32 = copyStrLast(formatstr0, (NI)(i0 + ((NI) 2)), (NI)(j0 - ((NI) 1)));
					x0 = findnormalized_111728_4286263276(LOC32, a0, a0Len0);
					{
						NIM_BOOL LOC35;
						LOC35 = (NIM_BOOL)0;
						LOC35 = (((NI) 0) <= x0);
						if (!(LOC35)) goto LA36;
						LOC35 = (x0 < (a0Len0-1));
						LA36: ;
						if (!LOC35) goto LA37;
						(*s0) = resizeString((*s0), a0[(NI)(x0 + ((NI) 1))]->Sup.len + 0);
appendString((*s0), a0[(NI)(x0 + ((NI) 1))]);
					}
					goto LA33;
					LA37: ;
					{
						invalidformatstring_111745_4286263276();
					}
					LA33: ;
					i0 = (NI)(j0 + ((NI) 1));
				}
				break;
				case 97 ... 122:
				case 65 ... 90:
				case 128 ... 255:
				case 95:
				{
					NI j0;
					NI x0;
					NimStringDesc* LOC43;
					j0 = (NI)(i0 + ((NI) 1));
					{
						while (1) {
							if (!(((NU8)(formatstr0->data[j0])) >= ((NU8)(97)) && ((NU8)(formatstr0->data[j0])) <= ((NU8)(122)) || ((NU8)(formatstr0->data[j0])) >= ((NU8)(65)) && ((NU8)(formatstr0->data[j0])) <= ((NU8)(90)) || ((NU8)(formatstr0->data[j0])) >= ((NU8)(48)) && ((NU8)(formatstr0->data[j0])) <= ((NU8)(57)) || ((NU8)(formatstr0->data[j0])) >= ((NU8)(128)) && ((NU8)(formatstr0->data[j0])) <= ((NU8)(255)) || ((NU8)(formatstr0->data[j0])) == ((NU8)(95)))) goto LA42;
							j0 += ((NI) 1);
						} LA42: ;
					}
					LOC43 = (NimStringDesc*)0;
					LOC43 = copyStrLast(formatstr0, (NI)(i0 + ((NI) 1)), (NI)(j0 - ((NI) 1)));
					x0 = findnormalized_111728_4286263276(LOC43, a0, a0Len0);
					{
						NIM_BOOL LOC46;
						LOC46 = (NIM_BOOL)0;
						LOC46 = (((NI) 0) <= x0);
						if (!(LOC46)) goto LA47;
						LOC46 = (x0 < (a0Len0-1));
						LA47: ;
						if (!LOC46) goto LA48;
						(*s0) = resizeString((*s0), a0[(NI)(x0 + ((NI) 1))]->Sup.len + 0);
appendString((*s0), a0[(NI)(x0 + ((NI) 1))]);
					}
					goto LA44;
					LA48: ;
					{
						invalidformatstring_111745_4286263276();
					}
					LA44: ;
					i0 = j0;
				}
				break;
				default:
				{
					invalidformatstring_111745_4286263276();
				}
				break;
				}
			}
			goto LA3;
			LA5: ;
			{
				(*s0) = addChar((*s0), formatstr0->data[i0]);
				i0 += ((NI) 1);
			}
			LA3: ;
		} LA2: ;
	}
}

N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr0, NimStringDesc** a0, NI a0Len0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = rawNewString(((NI) ((NI)((formatstr0 ? formatstr0->Sup.len : 0) + (NI)((NU64)(a0Len0) << (NU64)(((NI) 4)))))));
	nsuAddf((&result0), formatstr0, a0, a0Len0);
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuFormatSingleElem)(NimStringDesc* formatstr0, NimStringDesc* a0) {
	NimStringDesc* result0;
	TY193732 LOC1;
	result0 = (NimStringDesc*)0;
	result0 = rawNewString(((NI) ((NI)((formatstr0 ? formatstr0->Sup.len : 0) + (a0 ? a0->Sup.len : 0)))));
	memset((void*)LOC1, 0, sizeof(LOC1));
	LOC1[0] = copyString(a0);
	nsuAddf((&result0), formatstr0, LOC1, 1);
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuRepeatChar)(NIM_CHAR c0, NI count0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(count0);
	{
		NI i_108944_4286263276;
		NI HEX3Atmp_108946_4286263276;
		NI res_108949_4286263276;
		i_108944_4286263276 = (NI)0;
		HEX3Atmp_108946_4286263276 = (NI)0;
		HEX3Atmp_108946_4286263276 = (NI)(((NI) (count0)) - ((NI) 1));
		res_108949_4286263276 = ((NI) 0);
		{
			while (1) {
				if (!(res_108949_4286263276 <= ((NI) (HEX3Atmp_108946_4286263276)))) goto LA3;
				i_108944_4286263276 = ((NI) (res_108949_4286263276));
				result0->data[i_108944_4286263276] = c0;
				res_108949_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest0, void* src0) {
	{
		Cell47305* c0;
		if (!!((src0 == NIM_NIL))) goto LA3;
		c0 = usrtocell_51440_1689653243(src0);
		(*c0).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell47305* c0;
		if (!!(((*dest0) == NIM_NIL))) goto LA7;
		c0 = usrtocell_51440_1689653243((*dest0));
		{
			(*c0).refcount -= ((NI) 8);
			if (!((NU64)((*c0).refcount) < (NU64)(((NI) 8)))) goto LA11;
			rtladdzct_52601_1689653243(c0);
		}
		LA11: ;
	}
	LA7: ;
	(*dest0) = src0;
}

N_NIMCALL(NF, nsuParseFloat)(NimStringDesc* s0) {
	NF result0;
	NI L0;
	result0 = (NF)0;
	L0 = npuParseFloat(s0, (&result0), ((NI) 0));
	{
		NIM_BOOL LOC3;
		Valueerror3646* e_108744_4286263276;
		NimStringDesc* LOC7;
		LOC3 = (NIM_BOOL)0;
		LOC3 = !((L0 == (s0 ? s0->Sup.len : 0)));
		if (LOC3) goto LA4;
		LOC3 = (L0 == ((NI) 0));
		LA4: ;
		if (!LOC3) goto LA5;
		e_108744_4286263276 = (Valueerror3646*)0;
		e_108744_4286263276 = (Valueerror3646*) newObj((&NTI23025), sizeof(Valueerror3646));
		(*e_108744_4286263276).Sup.Sup.m_type = (&NTI3646);
		LOC7 = (NimStringDesc*)0;
		LOC7 = rawNewString(s0->Sup.len + 15);
appendString(LOC7, ((NimStringDesc*) &T4286263276_3));
appendString(LOC7, s0);
		asgnRefNoCycle((void**) (&(*e_108744_4286263276).Sup.message), LOC7);
		raiseException((Exception*)e_108744_4286263276, "ValueError");
	}
	LA5: ;
	return result0;
}

N_NIMCALL(NI64, nsuParseBiggestInt)(NimStringDesc* s0) {
	NI64 result0;
	NI L0;
	result0 = (NI64)0;
	L0 = npuParseBiggestInt(s0, (&result0), ((NI) 0));
	{
		NIM_BOOL LOC3;
		Valueerror3646* e_108684_4286263276;
		NimStringDesc* LOC7;
		LOC3 = (NIM_BOOL)0;
		LOC3 = !((L0 == (s0 ? s0->Sup.len : 0)));
		if (LOC3) goto LA4;
		LOC3 = (L0 == ((NI) 0));
		LA4: ;
		if (!LOC3) goto LA5;
		e_108684_4286263276 = (Valueerror3646*)0;
		e_108684_4286263276 = (Valueerror3646*) newObj((&NTI23025), sizeof(Valueerror3646));
		(*e_108684_4286263276).Sup.Sup.m_type = (&NTI3646);
		LOC7 = (NimStringDesc*)0;
		LOC7 = rawNewString(s0->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &T4286263276_4));
appendString(LOC7, s0);
		asgnRefNoCycle((void**) (&(*e_108684_4286263276).Sup.message), LOC7);
		raiseException((Exception*)e_108684_4286263276, "ValueError");
	}
	LA5: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, nsuStartsWith)(NimStringDesc* s0, NimStringDesc* prefix0) {
	NIM_BOOL result0;
	NI i0;
{	result0 = (NIM_BOOL)0;
	i0 = ((NI) 0);
	{
		while (1) {
			{
				if (!((NU8)(prefix0->data[i0]) == (NU8)(0))) goto LA5;
				result0 = NIM_TRUE;
				goto BeforeRet;
			}
			LA5: ;
			{
				if (!!(((NU8)(s0->data[i0]) == (NU8)(prefix0->data[i0])))) goto LA9;
				result0 = NIM_FALSE;
				goto BeforeRet;
			}
			LA9: ;
			i0 += ((NI) 1);
		}
	}
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x0, NI len0) {
	NimStringDesc* result0;
	NI64 n0;
	result0 = (NimStringDesc*)0;
	n0 = x0;
	result0 = mnewString(((NI) (len0)));
	{
		NI j_108614_4286263276;
		NI HEX3Atmp_108617_4286263276;
		NI res_108620_4286263276;
		j_108614_4286263276 = (NI)0;
		HEX3Atmp_108617_4286263276 = (NI)0;
		HEX3Atmp_108617_4286263276 = (NI)(((NI) (len0)) - ((NI) 1));
		res_108620_4286263276 = ((NI) (HEX3Atmp_108617_4286263276));
		{
			while (1) {
				if (!(((NI) 0) <= res_108620_4286263276)) goto LA3;
				j_108614_4286263276 = ((NI) (res_108620_4286263276));
				result0->data[j_108614_4286263276] = ((NimStringDesc*) &T4286263276_5)->data[(NI64)(n0 & IL64(15))];
				n0 = (NI64)((NU64)(n0) >> (NU64)(IL64(4)));
				{
					NIM_BOOL LOC6;
					LOC6 = (NIM_BOOL)0;
					LOC6 = (n0 == IL64(0));
					if (!(LOC6)) goto LA7;
					LOC6 = (x0 < IL64(0));
					LA7: ;
					if (!LOC6) goto LA8;
					n0 = IL64(-1);
				}
				LA8: ;
				res_108620_4286263276 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

N_NIMCALL(void, preprocesssub_109524_4286263276)(NimStringDesc* sub0, NI* a0) {
	NI m0;
	m0 = (sub0 ? sub0->Sup.len : 0);
	{
		NI i_109540_4286263276;
		NI res_109554_4286263276;
		i_109540_4286263276 = (NI)0;
		res_109554_4286263276 = ((NI) 0);
		{
			while (1) {
				if (!(res_109554_4286263276 <= ((NI) 255))) goto LA3;
				i_109540_4286263276 = res_109554_4286263276;
				a0[(((NU8)(((NIM_CHAR) (((NI) (i_109540_4286263276)))))))- 0] = (NI)(m0 + ((NI) 1));
				res_109554_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	{
		NI i_109550_4286263276;
		NI HEX3Atmp_109559_4286263276;
		NI res_109562_4286263276;
		i_109550_4286263276 = (NI)0;
		HEX3Atmp_109559_4286263276 = (NI)0;
		HEX3Atmp_109559_4286263276 = (NI)(m0 - ((NI) 1));
		res_109562_4286263276 = ((NI) 0);
		{
			while (1) {
				if (!(res_109562_4286263276 <= HEX3Atmp_109559_4286263276)) goto LA6;
				i_109550_4286263276 = res_109562_4286263276;
				a0[(((NU8)(sub0->data[i_109550_4286263276])))- 0] = (NI)(m0 - i_109550_4286263276);
				res_109562_4286263276 += ((NI) 1);
			} LA6: ;
		}
	}
}

N_NIMCALL(NI, findaux_109566_4286263276)(NimStringDesc* s0, NimStringDesc* sub0, NI start0, Skiptable109518 a0) {
	NI result0;
	NI m0;
	NI n0;
	NI j0;
{	result0 = (NI)0;
	m0 = (sub0 ? sub0->Sup.len : 0);
	n0 = (s0 ? s0->Sup.len : 0);
	j0 = start0;
	{
		while (1) {
			if (!(j0 <= (NI)(n0 - m0))) goto LA2;
			{
				{
					NI k_109586_4286263276;
					NI HEX3Atmp_109598_4286263276;
					NI res_109601_4286263276;
					k_109586_4286263276 = (NI)0;
					HEX3Atmp_109598_4286263276 = (NI)0;
					HEX3Atmp_109598_4286263276 = (NI)(m0 - ((NI) 1));
					res_109601_4286263276 = ((NI) 0);
					{
						while (1) {
							if (!(res_109601_4286263276 <= HEX3Atmp_109598_4286263276)) goto LA6;
							k_109586_4286263276 = res_109601_4286263276;
							{
								if (!!(((NU8)(sub0->data[k_109586_4286263276]) == (NU8)(s0->data[(NI)(k_109586_4286263276 + j0)])))) goto LA9;
								goto LA3;
							}
							LA9: ;
							res_109601_4286263276 += ((NI) 1);
						} LA6: ;
					}
				}
				result0 = j0;
				goto BeforeRet;
			} LA3: ;
			j0 += a0[(((NU8)(s0->data[(NI)(j0 + m0)])))- 0];
		} LA2: ;
	}
	result0 = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuReplaceStr)(NimStringDesc* s0, NimStringDesc* sub0, NimStringDesc* by0) {
	NimStringDesc* result0;
	Skiptable109518 a0;
	NI i0;
	NimStringDesc* LOC8;
	result0 = (NimStringDesc*)0;
	result0 = copyString(((NimStringDesc*) &T4286263276_6));
	preprocesssub_109524_4286263276(sub0, a0);
	i0 = ((NI) 0);
	{
		while (1) {
			NI j0;
			NimStringDesc* LOC7;
			j0 = findaux_109566_4286263276(s0, sub0, i0, a0);
			{
				if (!(j0 < ((NI) 0))) goto LA5;
				goto LA1;
			}
			LA5: ;
			LOC7 = (NimStringDesc*)0;
			LOC7 = copyStrLast(s0, i0, (NI)(j0 - ((NI) 1)));
			result0 = resizeString(result0, LOC7->Sup.len + 0);
appendString(result0, LOC7);
			result0 = resizeString(result0, by0->Sup.len + 0);
appendString(result0, by0);
			i0 = (NI)(j0 + (sub0 ? sub0->Sup.len : 0));
		}
	} LA1: ;
	LOC8 = (NimStringDesc*)0;
	LOC8 = copyStr(s0, i0);
	result0 = resizeString(result0, LOC8->Sup.len + 0);
appendString(result0, LOC8);
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuToBin)(NI64 x0, NI len0) {
	NimStringDesc* result0;
	NI64 mask0;
	NI64 shift0;
	result0 = (NimStringDesc*)0;
	mask0 = IL64(1);
	shift0 = IL64(0);
	result0 = mnewString(((NI) (len0)));
	{
		NI j_110612_4286263276;
		NI HEX3Atmp_110625_4286263276;
		NI res_110628_4286263276;
		j_110612_4286263276 = (NI)0;
		HEX3Atmp_110625_4286263276 = (NI)0;
		HEX3Atmp_110625_4286263276 = (NI)(((NI) (len0)) - ((NI) 1));
		res_110628_4286263276 = ((NI) (HEX3Atmp_110625_4286263276));
		{
			while (1) {
				if (!(((NI) 0) <= res_110628_4286263276)) goto LA3;
				j_110612_4286263276 = ((NI) (res_110628_4286263276));
				result0->data[j_110612_4286263276] = ((NIM_CHAR) (((NI) ((NI)(((NI) ((NI64)((NU64)((NI64)(x0 & mask0)) >> (NU64)(shift0)))) + ((NI) 48))))));
				shift0 = (NI64)(shift0 + IL64(1));
				mask0 = (NI64)((NU64)(mask0) << (NU64)(IL64(1)));
				res_110628_4286263276 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuToOct)(NI64 x0, NI len0) {
	NimStringDesc* result0;
	NI64 mask0;
	NI64 shift0;
	result0 = (NimStringDesc*)0;
	mask0 = IL64(7);
	shift0 = IL64(0);
	result0 = mnewString(((NI) (len0)));
	{
		NI j_110412_4286263276;
		NI HEX3Atmp_110425_4286263276;
		NI res_110428_4286263276;
		j_110412_4286263276 = (NI)0;
		HEX3Atmp_110425_4286263276 = (NI)0;
		HEX3Atmp_110425_4286263276 = (NI)(((NI) (len0)) - ((NI) 1));
		res_110428_4286263276 = ((NI) (HEX3Atmp_110425_4286263276));
		{
			while (1) {
				if (!(((NI) 0) <= res_110428_4286263276)) goto LA3;
				j_110412_4286263276 = ((NI) (res_110428_4286263276));
				result0->data[j_110412_4286263276] = ((NIM_CHAR) (((NI) ((NI)(((NI) ((NI64)((NU64)((NI64)(x0 & mask0)) >> (NU64)(shift0)))) + ((NI) 48))))));
				shift0 = (NI64)(shift0 + IL64(3));
				mask0 = (NI64)((NU64)(mask0) << (NU64)(IL64(3)));
				res_110428_4286263276 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s0, char136Set chars0, NI start0) {
	NI result0;
{	result0 = (NI)0;
	{
		NI i_109840_4286263276;
		NI HEX3Atmp_109852_4286263276;
		NI res_109855_4286263276;
		i_109840_4286263276 = (NI)0;
		HEX3Atmp_109852_4286263276 = (NI)0;
		HEX3Atmp_109852_4286263276 = (NI)((s0 ? s0->Sup.len : 0) - ((NI) 1));
		res_109855_4286263276 = ((NI) (start0));
		{
			while (1) {
				if (!(res_109855_4286263276 <= HEX3Atmp_109852_4286263276)) goto LA3;
				i_109840_4286263276 = res_109855_4286263276;
				{
					if (!((chars0[(NU)(((NU8)(s0->data[i_109840_4286263276])))>>3] &(1U<<((NU)(((NU8)(s0->data[i_109840_4286263276])))&7U)))!=0)) goto LA6;
					result0 = i_109840_4286263276;
					goto BeforeRet;
				}
				LA6: ;
				res_109855_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	result0 = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, contains_110056_4286263276)(NimStringDesc* s0, char136Set chars0) {
	NIM_BOOL result0;
	NI LOC1;
{	result0 = (NIM_BOOL)0;
	LOC1 = (NI)0;
	LOC1 = nsuFindCharSet(s0, chars0, ((NI) 0));
	result0 = (((NI) 0) <= LOC1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuStrip)(NimStringDesc* s0, NIM_BOOL leading0, NIM_BOOL trailing0, char136Set chars0) {
	NimStringDesc* result0;
	NI first0;
	NI last0;
	result0 = (NimStringDesc*)0;
	first0 = ((NI) 0);
	last0 = (NI)((s0 ? s0->Sup.len : 0) - ((NI) 1));
	{
		if (!leading0) goto LA3;
		{
			while (1) {
				if (!((chars0[(NU)(((NU8)(s0->data[first0])))>>3] &(1U<<((NU)(((NU8)(s0->data[first0])))&7U)))!=0)) goto LA6;
				first0 += ((NI) 1);
			} LA6: ;
		}
	}
	LA3: ;
	{
		if (!trailing0) goto LA9;
		{
			while (1) {
				NIM_BOOL LOC13;
				LOC13 = (NIM_BOOL)0;
				LOC13 = (((NI) 0) <= last0);
				if (!(LOC13)) goto LA14;
				LOC13 = ((chars0[(NU)(((NU8)(s0->data[last0])))>>3] &(1U<<((NU)(((NU8)(s0->data[last0])))&7U)))!=0);
				LA14: ;
				if (!LOC13) goto LA12;
				last0 -= ((NI) 1);
			} LA12: ;
		}
	}
	LA9: ;
	result0 = copyStrLast(s0, first0, last0);
	return result0;
}

N_NIMCALL(NI, nsuCmpIgnoreCase)(NimStringDesc* a0, NimStringDesc* b0) {
	NI result0;
	NI i0;
	NI m0;
{	result0 = (NI)0;
	i0 = ((NI) 0);
	m0 = (((a0 ? a0->Sup.len : 0) <= (b0 ? b0->Sup.len : 0)) ? (a0 ? a0->Sup.len : 0) : (b0 ? b0->Sup.len : 0));
	{
		while (1) {
			NIM_CHAR LOC3;
			NIM_CHAR LOC4;
			if (!(i0 < m0)) goto LA2;
			LOC3 = (NIM_CHAR)0;
			LOC3 = nsuToLowerAsciiChar(a0->data[i0]);
			LOC4 = (NIM_CHAR)0;
			LOC4 = nsuToLowerAsciiChar(b0->data[i0]);
			result0 = (NI)(((NI) (((NU8)(LOC3)))) - ((NI) (((NU8)(LOC4)))));
			{
				if (!!((result0 == ((NI) 0)))) goto LA7;
				goto BeforeRet;
			}
			LA7: ;
			i0 += ((NI) 1);
		} LA2: ;
	}
	result0 = (NI)((a0 ? a0->Sup.len : 0) - (b0 ? b0->Sup.len : 0));
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NI, nsuParseInt)(NimStringDesc* s0) {
	NI result0;
	NI L0;
	result0 = (NI)0;
	L0 = npuParseInt(s0, (&result0), ((NI) 0));
	{
		NIM_BOOL LOC3;
		Valueerror3646* e_108664_4286263276;
		NimStringDesc* LOC7;
		LOC3 = (NIM_BOOL)0;
		LOC3 = !((L0 == (s0 ? s0->Sup.len : 0)));
		if (LOC3) goto LA4;
		LOC3 = (L0 == ((NI) 0));
		LA4: ;
		if (!LOC3) goto LA5;
		e_108664_4286263276 = (Valueerror3646*)0;
		e_108664_4286263276 = (Valueerror3646*) newObj((&NTI23025), sizeof(Valueerror3646));
		(*e_108664_4286263276).Sup.Sup.m_type = (&NTI3646);
		LOC7 = (NimStringDesc*)0;
		LOC7 = rawNewString(s0->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &T4286263276_4));
appendString(LOC7, s0);
		asgnRefNoCycle((void**) (&(*e_108664_4286263276).Sup.message), LOC7);
		raiseException((Exception*)e_108664_4286263276, "ValueError");
	}
	LA5: ;
	return result0;
}

N_NIMCALL(NI, nsuParseHexInt)(NimStringDesc* s0) {
	NI result0;
	NI i0;
	result0 = (NI)0;
	i0 = ((NI) 0);
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC5;
		LOC3 = (NIM_BOOL)0;
		LOC3 = ((NU8)(s0->data[i0]) == (NU8)(48));
		if (!(LOC3)) goto LA4;
		LOC5 = (NIM_BOOL)0;
		LOC5 = ((NU8)(s0->data[(NI)(i0 + ((NI) 1))]) == (NU8)(120));
		if (LOC5) goto LA6;
		LOC5 = ((NU8)(s0->data[(NI)(i0 + ((NI) 1))]) == (NU8)(88));
		LA6: ;
		LOC3 = LOC5;
		LA4: ;
		if (!LOC3) goto LA7;
		i0 += ((NI) 2);
	}
	goto LA1;
	LA7: ;
	{
		if (!((NU8)(s0->data[i0]) == (NU8)(35))) goto LA10;
		i0 += ((NI) 1);
	}
	goto LA1;
	LA10: ;
	LA1: ;
	{
		while (1) {
			switch (((NU8)(s0->data[i0]))) {
			case 95:
			{
				i0 += ((NI) 1);
			}
			break;
			case 48 ... 57:
			{
				result0 = (NI)((NI)((NU64)(result0) << (NU64)(((NI) 4))) | ((NI) ((NI)(((NI) (((NU8)(s0->data[i0])))) - ((NI) 48)))));
				i0 += ((NI) 1);
			}
			break;
			case 97 ... 102:
			{
				result0 = (NI)((NI)((NU64)(result0) << (NU64)(((NI) 4))) | ((NI) ((NI)(((NI) ((NI)(((NI) (((NU8)(s0->data[i0])))) - ((NI) 97)))) + ((NI) 10)))));
				i0 += ((NI) 1);
			}
			break;
			case 65 ... 70:
			{
				result0 = (NI)((NI)((NU64)(result0) << (NU64)(((NI) 4))) | ((NI) ((NI)(((NI) ((NI)(((NI) (((NU8)(s0->data[i0])))) - ((NI) 65)))) + ((NI) 10)))));
				i0 += ((NI) 1);
			}
			break;
			case 0:
			{
				goto LA12;
			}
			break;
			default:
			{
				Valueerror3646* e_108872_4286263276;
				NimStringDesc* LOC20;
				e_108872_4286263276 = (Valueerror3646*)0;
				e_108872_4286263276 = (Valueerror3646*) newObj((&NTI23025), sizeof(Valueerror3646));
				(*e_108872_4286263276).Sup.Sup.m_type = (&NTI3646);
				LOC20 = (NimStringDesc*)0;
				LOC20 = rawNewString(s0->Sup.len + 17);
appendString(LOC20, ((NimStringDesc*) &T4286263276_4));
appendString(LOC20, s0);
				asgnRefNoCycle((void**) (&(*e_108872_4286263276).Sup.message), LOC20);
				raiseException((Exception*)e_108872_4286263276, "ValueError");
			}
			break;
			}
		}
	} LA12: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuNormalize)(NimStringDesc* s0) {
	NimStringDesc* result0;
	NI j0;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(((NI) ((s0 ? s0->Sup.len : 0))));
	j0 = ((NI) 0);
	{
		NI i_106988_4286263276;
		NI HEX3Atmp_107046_4286263276;
		NI res_107049_4286263276;
		i_106988_4286263276 = (NI)0;
		HEX3Atmp_107046_4286263276 = (NI)0;
		HEX3Atmp_107046_4286263276 = (NI)((s0 ? s0->Sup.len : 0) - ((NI) 1));
		res_107049_4286263276 = ((NI) 0);
		{
			while (1) {
				if (!(res_107049_4286263276 <= HEX3Atmp_107046_4286263276)) goto LA3;
				i_106988_4286263276 = res_107049_4286263276;
				{
					if (!(((NU8)(s0->data[i_106988_4286263276])) >= ((NU8)(65)) && ((NU8)(s0->data[i_106988_4286263276])) <= ((NU8)(90)))) goto LA6;
					result0->data[j0] = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(s0->data[i_106988_4286263276])))) + ((NI) 32))))));
					j0 += ((NI) 1);
				}
				goto LA4;
				LA6: ;
				{
					if (!!(((NU8)(s0->data[i_106988_4286263276]) == (NU8)(95)))) goto LA9;
					result0->data[j0] = s0->data[i_106988_4286263276];
					j0 += ((NI) 1);
				}
				goto LA4;
				LA9: ;
				LA4: ;
				res_107049_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	{
		if (!!((j0 == (s0 ? s0->Sup.len : 0)))) goto LA13;
		result0 = setLengthStr(result0, ((NI) (j0)));
	}
	LA13: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, nsuEndsWith)(NimStringDesc* s0, NimStringDesc* suffix0) {
	NIM_BOOL result0;
	NI i0;
	NI j0;
{	result0 = (NIM_BOOL)0;
	i0 = ((NI) 0);
	j0 = (NI)((s0 ? s0->Sup.len : 0) - (suffix0 ? suffix0->Sup.len : 0));
	{
		while (1) {
			if (!((NU64)((NI)(i0 + j0)) < (NU64)((s0 ? s0->Sup.len : 0)))) goto LA2;
			{
				if (!!(((NU8)(s0->data[(NI)(i0 + j0)]) == (NU8)(suffix0->data[i0])))) goto LA5;
				result0 = NIM_FALSE;
				goto BeforeRet;
			}
			LA5: ;
			i0 += ((NI) 1);
		} LA2: ;
	}
	{
		if (!((NU8)(suffix0->data[i0]) == (NU8)(0))) goto LA9;
		result0 = NIM_TRUE;
		goto BeforeRet;
	}
	LA9: ;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s0, NIM_CHAR sub0, NI start0) {
	NI result0;
{	result0 = (NI)0;
	{
		NI i_109815_4286263276;
		NI HEX3Atmp_109817_4286263276;
		NI res_109820_4286263276;
		i_109815_4286263276 = (NI)0;
		HEX3Atmp_109817_4286263276 = (NI)0;
		HEX3Atmp_109817_4286263276 = (NI)((s0 ? s0->Sup.len : 0) - ((NI) 1));
		res_109820_4286263276 = ((NI) (start0));
		{
			while (1) {
				if (!(res_109820_4286263276 <= HEX3Atmp_109817_4286263276)) goto LA3;
				i_109815_4286263276 = res_109820_4286263276;
				{
					if (!((NU8)(sub0) == (NU8)(s0->data[i_109815_4286263276]))) goto LA6;
					result0 = i_109815_4286263276;
					goto BeforeRet;
				}
				LA6: ;
				res_109820_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	result0 = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NIM_BOOL, contains_110046_4286263276)(NimStringDesc* s0, NIM_CHAR c0) {
	NIM_BOOL result0;
	NI LOC1;
{	result0 = (NIM_BOOL)0;
	LOC1 = (NI)0;
	LOC1 = nsuFindChar(s0, c0, ((NI) 0));
	result0 = (((NI) 0) <= LOC1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuToLowerAsciiStr)(NimStringDesc* s0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(((NI) ((s0 ? s0->Sup.len : 0))));
	{
		NI i_106845_4286263276;
		NI HEX3Atmp_106847_4286263276;
		NI res_106850_4286263276;
		i_106845_4286263276 = (NI)0;
		HEX3Atmp_106847_4286263276 = (NI)0;
		HEX3Atmp_106847_4286263276 = (NI)((s0 ? s0->Sup.len : 0) - ((NI) 1));
		res_106850_4286263276 = ((NI) 0);
		{
			while (1) {
				if (!(res_106850_4286263276 <= HEX3Atmp_106847_4286263276)) goto LA3;
				i_106845_4286263276 = res_106850_4286263276;
				result0->data[i_106845_4286263276] = nsuToLowerAsciiChar(s0->data[i_106845_4286263276]);
				res_106850_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

N_NIMCALL(NIM_BOOL, allcharsinset_109382_4286263276)(NimStringDesc* s0, char136Set theset0) {
	NIM_BOOL result0;
{	result0 = (NIM_BOOL)0;
	{
		NIM_CHAR c_109389_4286263276;
		NI i_109403_4286263276;
		NI L_109405_4286263276;
		c_109389_4286263276 = (NIM_CHAR)0;
		i_109403_4286263276 = ((NI) 0);
		L_109405_4286263276 = (s0 ? s0->Sup.len : 0);
		{
			while (1) {
				if (!(i_109403_4286263276 < L_109405_4286263276)) goto LA3;
				c_109389_4286263276 = s0->data[i_109403_4286263276];
				{
					if (!!(((theset0[(NU)(((NU8)(c_109389_4286263276)))>>3] &(1U<<((NU)(((NU8)(c_109389_4286263276)))&7U)))!=0))) goto LA6;
					result0 = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				i_109403_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	result0 = NIM_TRUE;
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuJoinSep)(NimStringDesc** a0, NI a0Len0, NimStringDesc* sep0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	{
		NI L0;
		if (!(((NI) 0) < a0Len0)) goto LA3;
		L0 = (NI)((sep0 ? sep0->Sup.len : 0) * (NI)(a0Len0 - ((NI) 1)));
		{
			NI i_109467_4286263276;
			NI HEX3Atmp_109488_4286263276;
			NI res_109491_4286263276;
			i_109467_4286263276 = (NI)0;
			HEX3Atmp_109488_4286263276 = (NI)0;
			HEX3Atmp_109488_4286263276 = (a0Len0-1);
			res_109491_4286263276 = ((NI) 0);
			{
				while (1) {
					if (!(res_109491_4286263276 <= HEX3Atmp_109488_4286263276)) goto LA7;
					i_109467_4286263276 = res_109491_4286263276;
					L0 += (a0[i_109467_4286263276] ? a0[i_109467_4286263276]->Sup.len : 0);
					res_109491_4286263276 += ((NI) 1);
				} LA7: ;
			}
		}
		result0 = rawNewString(((NI) (L0)));
		result0 = resizeString(result0, a0[((NI) 0)]->Sup.len + 0);
appendString(result0, a0[((NI) 0)]);
		{
			NI i_109486_4286263276;
			NI HEX3Atmp_109496_4286263276;
			NI res_109499_4286263276;
			i_109486_4286263276 = (NI)0;
			HEX3Atmp_109496_4286263276 = (NI)0;
			HEX3Atmp_109496_4286263276 = (a0Len0-1);
			res_109499_4286263276 = ((NI) 1);
			{
				while (1) {
					if (!(res_109499_4286263276 <= HEX3Atmp_109496_4286263276)) goto LA10;
					i_109486_4286263276 = res_109499_4286263276;
					result0 = resizeString(result0, sep0->Sup.len + 0);
appendString(result0, sep0);
					result0 = resizeString(result0, a0[i_109486_4286263276]->Sup.len + 0);
appendString(result0, a0[i_109486_4286263276]);
					res_109499_4286263276 += ((NI) 1);
				} LA10: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		result0 = copyString(((NimStringDesc*) &T4286263276_6));
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NI, nsuFindStr)(NimStringDesc* s0, NimStringDesc* sub0, NI start0) {
	NI result0;
	Skiptable109518 a0;
	result0 = (NI)0;
	preprocesssub_109524_4286263276(sub0, a0);
	result0 = findaux_109566_4286263276(s0, sub0, ((NI) (start0)), a0);
	return result0;
}

N_NIMCALL(TY135002*, nsuSplitChar)(NimStringDesc* s0, NIM_CHAR sep0, NI maxsplit0) {
	TY135002* result0;
	result0 = (TY135002*)0;
	result0 = (TY135002*) newSeq((&NTI135002), 0);
	{
		NimStringDesc* x_108127_4286263276;
		NI last_108158_4286263276;
		NI splits_108160_4286263276;
		x_108127_4286263276 = (NimStringDesc*)0;
		last_108158_4286263276 = ((NI) 0);
		splits_108160_4286263276 = maxsplit0;
		{
			if (!(((NI) 0) < (s0 ? s0->Sup.len : 0))) goto LA4;
			{
				while (1) {
					NI first_108162_4286263276;
					NimStringDesc* LOC16;
					if (!(last_108158_4286263276 <= (s0 ? s0->Sup.len : 0))) goto LA7;
					first_108162_4286263276 = last_108158_4286263276;
					{
						while (1) {
							NIM_BOOL LOC10;
							LOC10 = (NIM_BOOL)0;
							LOC10 = (last_108158_4286263276 < (s0 ? s0->Sup.len : 0));
							if (!(LOC10)) goto LA11;
							LOC10 = !(((NU8)(s0->data[last_108158_4286263276]) == (NU8)(sep0)));
							LA11: ;
							if (!LOC10) goto LA9;
							last_108158_4286263276 += ((NI) 1);
						} LA9: ;
					}
					{
						if (!(splits_108160_4286263276 == ((NI) 0))) goto LA14;
						last_108158_4286263276 = (s0 ? s0->Sup.len : 0);
					}
					LA14: ;
					x_108127_4286263276 = copyStrLast(s0, first_108162_4286263276, (NI)(last_108158_4286263276 - ((NI) 1)));
					result0 = (TY135002*) incrSeqV2(&(result0)->Sup, sizeof(NimStringDesc*));
					LOC16 = (NimStringDesc*)0;
					LOC16 = result0->data[result0->Sup.len]; result0->data[result0->Sup.len] = copyStringRC1(x_108127_4286263276);
					if (LOC16) nimGCunrefNoCycle(LOC16);
					++result0->Sup.len;
					{
						if (!(splits_108160_4286263276 == ((NI) 0))) goto LA19;
						goto LA6;
					}
					LA19: ;
					splits_108160_4286263276 -= ((NI) 1);
					last_108158_4286263276 += ((NI) 1);
				} LA7: ;
			} LA6: ;
		}
		LA4: ;
	}
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuEscape)(NimStringDesc* s0, NimStringDesc* prefix0, NimStringDesc* suffix0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = rawNewString(((NI) ((NI)((s0 ? s0->Sup.len : 0) + (NI)((NU64)((s0 ? s0->Sup.len : 0)) >> (NU64)(((NI) 2)))))));
	result0 = resizeString(result0, prefix0->Sup.len + 0);
appendString(result0, prefix0);
	{
		NIM_CHAR c_110701_4286263276;
		NI i_110713_4286263276;
		NI L_110715_4286263276;
		c_110701_4286263276 = (NIM_CHAR)0;
		i_110713_4286263276 = ((NI) 0);
		L_110715_4286263276 = (s0 ? s0->Sup.len : 0);
		{
			while (1) {
				if (!(i_110713_4286263276 < L_110715_4286263276)) goto LA3;
				c_110701_4286263276 = s0->data[i_110713_4286263276];
				switch (((NU8)(c_110701_4286263276))) {
				case 0 ... 31:
				case 128 ... 255:
				{
					NimStringDesc* LOC5;
					result0 = resizeString(result0, 2);
appendString(result0, ((NimStringDesc*) &T4286263276_7));
					LOC5 = (NimStringDesc*)0;
					LOC5 = nsuToHex(((NI64) (((NU8)(c_110701_4286263276)))), ((NI) 2));
					result0 = resizeString(result0, LOC5->Sup.len + 0);
appendString(result0, LOC5);
				}
				break;
				case 92:
				{
					result0 = resizeString(result0, 2);
appendString(result0, ((NimStringDesc*) &T4286263276_8));
				}
				break;
				case 39:
				{
					result0 = resizeString(result0, 2);
appendString(result0, ((NimStringDesc*) &T4286263276_9));
				}
				break;
				case 34:
				{
					result0 = resizeString(result0, 2);
appendString(result0, ((NimStringDesc*) &T4286263276_10));
				}
				break;
				default:
				{
					result0 = addChar(result0, c_110701_4286263276);
				}
				break;
				}
				i_110713_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	result0 = resizeString(result0, suffix0->Sup.len + 0);
appendString(result0, suffix0);
	return result0;
}

N_NIMCALL(void, nsuDelete)(NimStringDesc** s0, NI first0, NI last0) {
	NI i0;
	NI j0;
	NI newlen0;
	i0 = first0;
	j0 = (NI)(last0 + ((NI) 1));
	newlen0 = (NI)((NI)(((*s0) ? (*s0)->Sup.len : 0) - j0) + i0);
	{
		while (1) {
			if (!(i0 < newlen0)) goto LA2;
			(*s0)->data[i0] = (*s0)->data[j0];
			i0 += ((NI) 1);
			j0 += ((NI) 1);
		} LA2: ;
	}
	(*s0) = setLengthStr((*s0), ((NI) (newlen0)));
}

N_NIMCALL(NimStringDesc*, nsuToLowerStr)(NimStringDesc* s0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = nsuToLowerAsciiStr(s0);
	return result0;
}

N_NIMCALL(NI, nsuCountLines)(NimStringDesc* s0) {
	NI result0;
	NI i0;
	result0 = (NI)0;
	i0 = ((NI) 0);
	{
		while (1) {
			if (!(i0 < (s0 ? s0->Sup.len : 0))) goto LA2;
			switch (((NU8)(s0->data[i0]))) {
			case 13:
			{
				{
					if (!((NU8)(s0->data[(NI)(i0 + ((NI) 1))]) == (NU8)(10))) goto LA6;
					i0 += ((NI) 1);
				}
				LA6: ;
				result0 += ((NI) 1);
			}
			break;
			case 10:
			{
				result0 += ((NI) 1);
			}
			break;
			default:
			{
			}
			break;
			}
			i0 += ((NI) 1);
		} LA2: ;
	}
	return result0;
}

N_NIMCALL(NIM_BOOL, nsuContinuesWith)(NimStringDesc* s0, NimStringDesc* substr0, NI start0) {
	NIM_BOOL result0;
	NI i0;
{	result0 = (NIM_BOOL)0;
	i0 = ((NI) 0);
	{
		while (1) {
			{
				if (!((NU8)(substr0->data[i0]) == (NU8)(0))) goto LA5;
				result0 = NIM_TRUE;
				goto BeforeRet;
			}
			LA5: ;
			{
				if (!!(((NU8)(s0->data[(NI)(i0 + ((NI) (start0)))]) == (NU8)(substr0->data[i0])))) goto LA9;
				result0 = NIM_FALSE;
				goto BeforeRet;
			}
			LA9: ;
			i0 += ((NI) 1);
		}
	}
	}BeforeRet: ;
	return result0;
}

static N_INLINE(void, appendChar)(NimStringDesc* dest0, NIM_CHAR c0) {
	(*dest0).data[((*dest0).Sup.len)- 0] = c0;
	(*dest0).data[((NI)((*dest0).Sup.len + ((NI) 1)))- 0] = 0;
	(*dest0).Sup.len += ((NI) 1);
}

N_NIMCALL(NimStringDesc*, nsuIntToStr)(NI x0, NI minchars0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = nimIntToStr((x0 > 0? (x0) : -(x0)));
	{
		NI i_108646_4286263276;
		NI HEX3Atmp_108648_4286263276;
		NI res_108651_4286263276;
		i_108646_4286263276 = (NI)0;
		HEX3Atmp_108648_4286263276 = (NI)0;
		HEX3Atmp_108648_4286263276 = (NI)(((NI) (minchars0)) - (result0 ? result0->Sup.len : 0));
		res_108651_4286263276 = ((NI) 1);
		{
			while (1) {
				NimStringDesc* LOC4;
				if (!(res_108651_4286263276 <= HEX3Atmp_108648_4286263276)) goto LA3;
				i_108646_4286263276 = res_108651_4286263276;
				LOC4 = (NimStringDesc*)0;
				LOC4 = rawNewString(result0->Sup.len + 1);
appendChar(LOC4, 48);
appendString(LOC4, result0);
				result0 = LOC4;
				res_108651_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	{
		NimStringDesc* LOC9;
		if (!(x0 < ((NI) 0))) goto LA7;
		LOC9 = (NimStringDesc*)0;
		LOC9 = rawNewString(result0->Sup.len + 1);
appendChar(LOC9, 45);
appendString(LOC9, result0);
		result0 = LOC9;
	}
	LA7: ;
	return result0;
}

N_NIMCALL(NIM_CHAR, nsuToUpperAsciiChar)(NIM_CHAR c0) {
	NIM_CHAR result0;
	result0 = (NIM_CHAR)0;
	{
		if (!(((NU8)(c0)) >= ((NU8)(97)) && ((NU8)(c0)) <= ((NU8)(122)))) goto LA3;
		result0 = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c0)))) - ((NI) 32))))));
	}
	goto LA1;
	LA3: ;
	{
		result0 = c0;
	}
	LA1: ;
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuRepeatStr)(NimStringDesc* s0, NI n0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = rawNewString(((NI) ((NI)(((NI) (n0)) * (s0 ? s0->Sup.len : 0)))));
	{
		NI i_109014_4286263276;
		NI res_109018_4286263276;
		i_109014_4286263276 = (NI)0;
		res_109018_4286263276 = ((NI) 1);
		{
			while (1) {
				if (!(res_109018_4286263276 <= ((NI) (n0)))) goto LA3;
				i_109014_4286263276 = ((NI) (res_109018_4286263276));
				result0 = resizeString(result0, s0->Sup.len + 0);
appendString(result0, s0);
				res_109018_4286263276 += ((NI) 1);
			} LA3: ;
		}
	}
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuReplaceChar)(NimStringDesc* s0, NIM_CHAR sub0, NIM_CHAR by0) {
	NimStringDesc* result0;
	NI i0;
	result0 = (NimStringDesc*)0;
	result0 = mnewString(((NI) ((s0 ? s0->Sup.len : 0))));
	i0 = ((NI) 0);
	{
		while (1) {
			if (!(i0 < (s0 ? s0->Sup.len : 0))) goto LA2;
			{
				if (!((NU8)(s0->data[i0]) == (NU8)(sub0))) goto LA5;
				result0->data[i0] = by0;
			}
			goto LA3;
			LA5: ;
			{
				result0->data[i0] = s0->data[i0];
			}
			LA3: ;
			i0 += ((NI) 1);
		} LA2: ;
	}
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuformatBiggestFloat)(NF f0, Floatformatmode111202 format0, NI precision0, NIM_CHAR decimalsep0) {
	NimStringDesc* result0;
	TY111408 frmtstr0;
	TY111412 buf0;
	int L0;
	result0 = (NimStringDesc*)0;
	L0 = (int)0;
	frmtstr0[(((NI) 0))- 0] = 37;
	{
		if (!(((NI) 0) < ((NI) (precision0)))) goto LA3;
		frmtstr0[(((NI) 1))- 0] = 35;
		frmtstr0[(((NI) 2))- 0] = 46;
		frmtstr0[(((NI) 3))- 0] = 42;
		frmtstr0[(((NI) 4))- 0] = floatformattochar_111401_4286263276[(format0)- 0];
		frmtstr0[(((NI) 5))- 0] = 0;
		L0 = sprintf(((NCSTRING) (buf0)), ((NCSTRING) (frmtstr0)), precision0, f0);
	}
	goto LA1;
	LA3: ;
	{
		frmtstr0[(((NI) 1))- 0] = floatformattochar_111401_4286263276[(format0)- 0];
		frmtstr0[(((NI) 2))- 0] = 0;
		L0 = sprintf(((NCSTRING) (buf0)), ((NCSTRING) (frmtstr0)), f0);
	}
	LA1: ;
	result0 = mnewString(((NI) (L0)));
	{
		int i_111435_4286263276;
		int i_111453_4286263276;
		i_111435_4286263276 = (int)0;
		i_111453_4286263276 = ((int) 0);
		{
			while (1) {
				if (!(i_111453_4286263276 < L0)) goto LA8;
				i_111435_4286263276 = i_111453_4286263276;
				{
					if (!(((NU8)(buf0[(i_111435_4286263276)- 0])) == ((NU8)(46)) || ((NU8)(buf0[(i_111435_4286263276)- 0])) == ((NU8)(44)))) goto LA11;
					result0->data[i_111435_4286263276] = decimalsep0;
				}
				goto LA9;
				LA11: ;
				{
					result0->data[i_111435_4286263276] = buf0[(i_111435_4286263276)- 0];
				}
				LA9: ;
				i_111453_4286263276 += ((NI) 1);
			} LA8: ;
		}
	}
	return result0;
}

N_NIMCALL(NimStringDesc*, nsuformatFloat)(NF f0, Floatformatmode111202 format0, NI precision0, NIM_CHAR decimalsep0) {
	NimStringDesc* result0;
	result0 = (NimStringDesc*)0;
	result0 = nsuformatBiggestFloat(f0, format0, precision0, decimalsep0);
	return result0;
}

static N_INLINE(NI, find_111485_1689653243)(NIM_CHAR* a0, NI a0Len0, NIM_CHAR item0) {
	NI result0;
{	result0 = (NI)0;
	{
		NIM_CHAR i_111519_1689653243;
		NI i_111532_1689653243;
		i_111519_1689653243 = (NIM_CHAR)0;
		i_111532_1689653243 = ((NI) 0);
		{
			while (1) {
				if (!(i_111532_1689653243 < a0Len0)) goto LA3;
				i_111519_1689653243 = a0[i_111532_1689653243];
				{
					if (!((NU8)(i_111519_1689653243) == (NU8)(item0))) goto LA6;
					goto BeforeRet;
				}
				LA6: ;
				result0 += ((NI) 1);
				i_111532_1689653243 += ((NI) 1);
			} LA3: ;
		}
	}
	result0 = ((NI) -1);
	}BeforeRet: ;
	return result0;
}

static N_INLINE(NIM_BOOL, contains_111475_1689653243)(NIM_CHAR* a0, NI a0Len0, NIM_CHAR item0) {
	NIM_BOOL result0;
	NI LOC1;
{	result0 = (NIM_BOOL)0;
	LOC1 = (NI)0;
	LOC1 = find_111485_1689653243(a0, a0Len0, item0);
	result0 = (((NI) 0) <= LOC1);
	goto BeforeRet;
	}BeforeRet: ;
	return result0;
}

N_NIMCALL(void, trimzeros_111462_4286263276)(NimStringDesc** x0) {
	TY135002* spl0;
	spl0 = (TY135002*)0;
	{
		NIM_BOOL LOC3;
		LOC3 = (NIM_BOOL)0;
		LOC3 = contains_110046_4286263276((*x0), 46);
		if (LOC3) goto LA4;
		LOC3 = contains_110046_4286263276((*x0), 44);
		LA4: ;
		if (!LOC3) goto LA5;
		{
			NIM_BOOL LOC9;
			LOC9 = (NIM_BOOL)0;
			LOC9 = contains_110046_4286263276((*x0), 101);
			if (!LOC9) goto LA10;
			spl0 = nsuSplitChar((*x0), 101, ((NI) -1));
			unsureAsgnRef((void**) (&(*x0)), copyString(spl0->data[((NI) 0)]));
		}
		LA10: ;
		{
			while (1) {
				if (!((NU8)((*x0)->data[((*x0) ? ((*x0)->Sup.len-1) : -1)]) == (NU8)(48))) goto LA13;
				(*x0) = setLengthStr((*x0), ((NI) ((NI)(((*x0) ? (*x0)->Sup.len : 0) - ((NI) 1)))));
			} LA13: ;
		}
		{
			NIM_BOOL LOC16;
			LOC16 = (NIM_BOOL)0;
			LOC16 = contains_111475_1689653243(T4286263276_27, 2, (*x0)->data[((*x0) ? ((*x0)->Sup.len-1) : -1)]);
			if (!LOC16) goto LA17;
			(*x0) = setLengthStr((*x0), ((NI) ((NI)(((*x0) ? (*x0)->Sup.len : 0) - ((NI) 1)))));
		}
		LA17: ;
		{
			NimStringDesc* LOC23;
			if (!(((NI) 0) < (spl0 ? spl0->Sup.len : 0))) goto LA21;
			LOC23 = (NimStringDesc*)0;
			LOC23 = rawNewString(spl0->data[((NI) 1)]->Sup.len + 1);
appendString(LOC23, ((NimStringDesc*) &T4286263276_28));
appendString(LOC23, spl0->data[((NI) 1)]);
			(*x0) = resizeString((*x0), LOC23->Sup.len + 0);
appendString((*x0), LOC23);
		}
		LA21: ;
	}
	LA5: ;
}

N_NIMCALL(NimStringDesc*, formatsize_111547_4286263276)(NI64 bytes0, NIM_CHAR decimalsep0, Binaryprefixmode111544 prefix0, NIM_BOOL includespace0) {
	NimStringDesc* result0;
	NI64 xb0;
	NF fbytes0;
	NI64 lastxb0;
	NI matchedindex0;
	TY419062 prefixes0;
	result0 = (NimStringDesc*)0;
	xb0 = bytes0;
	fbytes0 = (NF)0;
	lastxb0 = bytes0;
	matchedindex0 = (NI)0;
	memset((void*)prefixes0, 0, sizeof(prefixes0));
	{
		if (!(prefix0 == ((Binaryprefixmode111544) 1))) goto LA3;
		genericAssign((void*)prefixes0, (void*)collprefixes_111557_4286263276, (&NTI419062));
	}
	goto LA1;
	LA3: ;
	{
		genericAssign((void*)prefixes0, (void*)iecprefixes_111554_4286263276, (&NTI419062));
	}
	LA1: ;
	{
		NI index_111594_4286263276;
		NI i_111604_4286263276;
		index_111594_4286263276 = (NI)0;
		i_111604_4286263276 = ((NI) 1);
		{
			while (1) {
				if (!(i_111604_4286263276 < ((NI) 9))) goto LA8;
				index_111594_4286263276 = i_111604_4286263276;
				lastxb0 = xb0;
				xb0 = (NI64)(bytes0 / (NI64)((NU64)(IL64(1)) << (NU64)(((NI64) ((NI)(index_111594_4286263276 * ((NI) 10)))))));
				matchedindex0 = index_111594_4286263276;
				{
					if (!(xb0 == IL64(0))) goto LA11;
					xb0 = lastxb0;
					matchedindex0 = (NI)(index_111594_4286263276 - ((NI) 1));
					goto LA6;
				}
				LA11: ;
				i_111604_4286263276 += ((NI) 1);
			} LA8: ;
		}
	} LA6: ;
	fbytes0 = ((NF)(((NF) (bytes0))) / (NF)(((NF) ((NI64)((NU64)(IL64(1)) << (NU64)(((NI64) ((NI)(matchedindex0 * ((NI) 10))))))))));
	result0 = nsuformatFloat(fbytes0, ((Floatformatmode111202) 1), ((NI) 3), decimalsep0);
	trimzeros_111462_4286263276((&result0));
	{
		if (!includespace0) goto LA15;
		result0 = resizeString(result0, 1);
appendString(result0, ((NimStringDesc*) &T4286263276_29));
	}
	LA15: ;
	result0 = resizeString(result0, prefixes0[(matchedindex0)- 0]->Sup.len + 0);
appendString(result0, prefixes0[(matchedindex0)- 0]);
	result0 = resizeString(result0, 1);
appendString(result0, ((NimStringDesc*) &T4286263276_30));
	return result0;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_strutilsInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, stdlib_strutilsDatInit000)(void) {
NTI109518.size = sizeof(Skiptable109518);
NTI109518.kind = 16;
NTI109518.base = (&NTI104);
NTI109518.flags = 3;
}

