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

#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 Cell47504 Cell47504;
typedef struct Cellseq47520 Cellseq47520;
typedef struct Gcheap49818 Gcheap49818;
typedef struct Gcstack49816 Gcstack49816;
typedef struct Cellset47516 Cellset47516;
typedef struct Pagedesc47512 Pagedesc47512;
typedef struct Memregion29687 Memregion29687;
typedef struct Smallchunk29639 Smallchunk29639;
typedef struct Llchunk29681 Llchunk29681;
typedef struct Bigchunk29641 Bigchunk29641;
typedef struct Intset29614 Intset29614;
typedef struct Trunk29610 Trunk29610;
typedef struct Avlnode29685 Avlnode29685;
typedef struct Gcstat49814 Gcstat49814;
typedef struct TY125202 TY125202;
typedef struct Slice88082 Slice88082;
typedef struct Basechunk29637 Basechunk29637;
typedef struct Freecell29629 Freecell29629;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY3489) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 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;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Cell47504  {
NI refcount;
TNimType* typ;
};
struct  Cellseq47520  {
NI len;
NI cap;
Cell47504** d;
};
struct  Cellset47516  {
NI counter;
NI max;
Pagedesc47512* head;
Pagedesc47512** data;
};
typedef Smallchunk29639* TY29702[512];
typedef Trunk29610* Trunkbuckets29612[256];
struct  Intset29614  {
Trunkbuckets29612 data;
};
struct  Memregion29687  {
NI minlargeobj;
NI maxlargeobj;
TY29702 freesmallchunks;
Llchunk29681* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk29641* freechunkslist;
Intset29614 chunkstarts;
Avlnode29685* root;
Avlnode29685* deleted;
Avlnode29685* last;
Avlnode29685* freeavlnodes;
};
struct  Gcstat49814  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap49818  {
Gcstack49816* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq47520 zct;
Cellseq47520 decstack;
Cellset47516 cycleroots;
Cellseq47520 tempstack;
NI recgclock;
Memregion29687 region;
Gcstat49814 stat;
};
typedef NimStringDesc* TY184752[1];
typedef NI Skiptable100505[256];
typedef NU8 TY203404[32];
typedef NIM_CHAR TY102408[6];
typedef NIM_CHAR TY102412[2501];
typedef NIM_CHAR TY102404[3];
struct  Slice88082  {
NI a;
NI b;
};
struct  Gcstack49816  {
Gcstack49816* prev;
Gcstack49816* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY29618[16];
struct  Pagedesc47512  {
Pagedesc47512* next;
NI key;
TY29618 bits;
};
struct  Basechunk29637  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk29639  {
  Basechunk29637 Sup;
Smallchunk29639* next;
Smallchunk29639* prev;
Freecell29629* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk29681  {
NI size;
NI acc;
Llchunk29681* next;
};
struct  Bigchunk29641  {
  Basechunk29637 Sup;
Bigchunk29641* next;
Bigchunk29641* prev;
NI align;
NF data;
};
struct  Trunk29610  {
Trunk29610* next;
NI key;
TY29618 bits;
};
typedef Avlnode29685* TY29692[2];
struct  Avlnode29685  {
TY29692 link;
NI key;
NI upperbound;
NI level;
};
struct  Freecell29629  {
Freecell29629* next;
NI zerofield;
};
struct TY125202 {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
N_NIMCALL(NIM_CHAR, nsuToLowerChar)(NIM_CHAR c);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_NIMCALL(void, nsuAddf)(NimStringDesc** s, NimStringDesc* formatstr, NimStringDesc** a, NI aLen0);
N_NOINLINE(void, invalidformatstring_102542)(void);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(Cell47504*, usrtocell_51440)(void* usr);
static N_INLINE(void, rtladdzct_53001)(Cell47504* c);
N_NOINLINE(void, addzct_51417)(Cellseq47520* s, Cell47504* c);
N_NIMCALL(void, raiseException)(Exception* e, NCSTRING ename);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
N_NIMCALL(NI, findnormalized_102525)(NimStringDesc* x, NimStringDesc** inarray, NI inarrayLen0);
N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_79810, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(NI, npuParseFloat)(NimStringDesc* s, NF* number, NI start);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(NI, npuParseBiggestInt)(NimStringDesc* s, NI64* number, NI start);
N_NIMCALL(void, preprocesssub_100508)(NimStringDesc* sub, NI* a);
N_NIMCALL(NI, findaux_100550)(NimStringDesc* s, NimStringDesc* sub, NI start, Skiptable100505 a);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY203404 chars, NI start);
N_NIMCALL(NI, npuParseInt)(NimStringDesc* s, NI* number, NI start);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newlen);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(TGenericSeq*, incrSeqV2)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len);
N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_NIMCALL(NimStringDesc*, nsuformatBiggestFloat)(NF f, NU8 format, NI precision, NIM_CHAR decimalsep);
static N_INLINE(Slice88082, HEX2EHEX2E_102424)(NI a, NI b);
N_NIMCALL(NimStringDesc*, nimInt64ToStr)(NI64 x);
N_NIMCALL(NimStringDesc*, nsuInsertSep)(NimStringDesc* s, NIM_CHAR sep, NI digits);
STRING_LITERAL(TMP155, "invalid format string", 21);
STRING_LITERAL(TMP1075, "invalid float: ", 15);
STRING_LITERAL(TMP1268, "invalid integer: ", 17);
STRING_LITERAL(TMP1411, "0123456789ABCDEF", 16);
STRING_LITERAL(TMP1413, "", 0);
STRING_LITERAL(TMP2114, "\\x", 2);
STRING_LITERAL(TMP2115, "\\\\", 2);
STRING_LITERAL(TMP2116, "\\\'", 2);
STRING_LITERAL(TMP2117, "\\\"", 2);
NIM_CONST TY102404 floatformattochar_102401 = {103,
102,
101}
;
STRING_LITERAL(TMP5293, "GB", 2);
STRING_LITERAL(TMP5294, "MB", 2);
STRING_LITERAL(TMP5295, "KB", 2);
STRING_LITERAL(TMP5296, "B", 1);
extern TNimType NTI23625; /* ref ValueError */
extern TNimType NTI3646; /* ValueError */
extern Gcheap49818 gch_49859;
extern TNimType NTI125202; /* seq[string] */
extern TNimType NTI104; /* int */
TNimType NTI100505; /* SkipTable */

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

N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a, NimStringDesc* b) {
	NI result;
	NI i;
	NI j;
	result = 0;
	i = ((NI) 0);
	j = ((NI) 0);
	{
		while (1) {
			NIM_CHAR aa;
			NIM_CHAR bb;
			{
				while (1) {
					if (!((NU8)(a->data[i]) == (NU8)(95))) goto LA4;
					i += ((NI) 1);
				} LA4: ;
			}
			{
				while (1) {
					if (!((NU8)(b->data[j]) == (NU8)(95))) goto LA6;
					j += ((NI) 1);
				} LA6: ;
			}
			aa = nsuToLowerChar(a->data[i]);
			bb = nsuToLowerChar(b->data[j]);
			result = (NI)(((NI) (((NU8)(aa)))) - ((NI) (((NU8)(bb)))));
			{
				NIM_BOOL LOC9;
				LOC9 = 0;
				LOC9 = !((result == ((NI) 0)));
				if (LOC9) goto LA10;
				LOC9 = ((NU8)(aa) == (NU8)(0));
				LA10: ;
				if (!LOC9) goto LA11;
				goto LA1;
			}
			LA11: ;
			i += ((NI) 1);
			j += ((NI) 1);
		}
	} LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToOctal)(NIM_CHAR c) {
	NimStringDesc* result;
	NI val;
	result = 0;
	result = mnewString(((NI) 3));
	val = ((NU8)(c));
	{
		NI i_98774;
		NI res_98789;
		i_98774 = 0;
		res_98789 = ((NI) 2);
		{
			while (1) {
				if (!(((NI) 0) <= res_98789)) goto LA3;
				i_98774 = res_98789;
				result->data[i_98774] = ((NIM_CHAR) (((NI) ((NI)(((NI) ((NI)(((NI) (val)) % ((NI) 8)))) + ((NI) 48))))));
				val = ((NI) ((NI)(((NI) (val)) / ((NI) 8))));
				res_98789 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

static N_INLINE(Cell47504*, usrtocell_51440)(void* usr) {
	Cell47504* result;
	result = 0;
	result = ((Cell47504*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(Cell47504))))));
	return result;
}

static N_INLINE(void, rtladdzct_53001)(Cell47504* c) {
	addzct_51417((&gch_49859.zct), c);
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	Cell47504* c;
	c = usrtocell_51440(p);
	{
		(*c).refcount -= ((NI) 8);
		if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA3;
		rtladdzct_53001(c);
	}
	LA3: ;
}

N_NOINLINE(void, invalidformatstring_102542)(void) {
	Valueerror3646* e_102547;
	NimStringDesc* LOC1;
	e_102547 = 0;
	e_102547 = (Valueerror3646*) newObj((&NTI23625), sizeof(Valueerror3646));
	(*e_102547).Sup.Sup.m_type = (&NTI3646);
	LOC1 = 0;
	LOC1 = (*e_102547).Sup.message; (*e_102547).Sup.message = copyStringRC1(((NimStringDesc*) &TMP155));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	raiseException((Exception*)e_102547, "ValueError");
}

static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	memcpy(((NCSTRING) ((&(*dest).data[((*dest).Sup.len)- 0]))), ((NCSTRING) ((*src).data)), (NI)((*src).Sup.len + ((NI) 1)));
	(*dest).Sup.len += (*src).Sup.len;
}

N_NIMCALL(NI, findnormalized_102525)(NimStringDesc* x, NimStringDesc** inarray, NI inarrayLen0) {
	NI result;
	NI i;
{	result = 0;
	i = ((NI) 0);
	{
		while (1) {
			if (!(i < (inarrayLen0-1))) goto LA2;
			{
				NI LOC5;
				LOC5 = 0;
				LOC5 = nsuCmpIgnoreStyle(x, inarray[i]);
				if (!(LOC5 == ((NI) 0))) goto LA6;
				result = i;
				goto BeforeRet;
			}
			LA6: ;
			i += ((NI) 2);
		} LA2: ;
	}
	result = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, nsuAddf)(NimStringDesc** s, NimStringDesc* formatstr, NimStringDesc** a, NI aLen0) {
	NI i;
	NI num;
	i = ((NI) 0);
	num = ((NI) 0);
	{
		while (1) {
			if (!(i < (formatstr ? formatstr->Sup.len : 0))) goto LA2;
			{
				if (!((NU8)(formatstr->data[i]) == (NU8)(36))) goto LA5;
				switch (((NU8)(formatstr->data[(NI)(i + ((NI) 1))]))) {
				case 35:
				{
					{
						if (!((NU32)((aLen0-1)) < (NU32)(num))) goto LA10;
						invalidformatstring_102542();
					}
					LA10: ;
					(*s) = resizeString((*s), a[num]->Sup.len + 0);
appendString((*s), a[num]);
					i += ((NI) 2);
					num += ((NI) 1);
				}
				break;
				case 36:
				{
					(*s) = addChar((*s), 36);
					i += ((NI) 2);
				}
				break;
				case 49 ... 57:
				case 45:
				{
					NI j;
					NIM_BOOL negative;
					NI idx;
					j = ((NI) 0);
					i += ((NI) 1);
					negative = ((NU8)(formatstr->data[i]) == (NU8)(45));
					{
						if (!negative) goto LA16;
						i += ((NI) 1);
					}
					LA16: ;
					{
						while (1) {
							if (!(((NU8)(formatstr->data[i])) >= ((NU8)(48)) && ((NU8)(formatstr->data[i])) <= ((NU8)(57)))) goto LA19;
							j = (NI)((NI)((NI)(j * ((NI) 10)) + ((NI) (((NU8)(formatstr->data[i]))))) - ((NI) 48));
							i += ((NI) 1);
						} LA19: ;
					}
					{
						if (!!(negative)) goto LA22;
						idx = (NI)(j - ((NI) 1));
					}
					goto LA20;
					LA22: ;
					{
						idx = (NI)(aLen0 - j);
					}
					LA20: ;
					{
						if (!((NU32)((aLen0-1)) < (NU32)(idx))) goto LA27;
						invalidformatstring_102542();
					}
					LA27: ;
					(*s) = resizeString((*s), a[idx]->Sup.len + 0);
appendString((*s), a[idx]);
				}
				break;
				case 123:
				{
					NI j;
					NI x;
					NimStringDesc* LOC32;
					j = (NI)(i + ((NI) 1));
					{
						while (1) {
							if (!!((((NU8)(formatstr->data[j])) == ((NU8)(0)) || ((NU8)(formatstr->data[j])) == ((NU8)(125))))) goto LA31;
							j += ((NI) 1);
						} LA31: ;
					}
					LOC32 = 0;
					LOC32 = copyStrLast(formatstr, (NI)(i + ((NI) 2)), (NI)(j - ((NI) 1)));
					x = findnormalized_102525(LOC32, a, aLen0);
					{
						NIM_BOOL LOC35;
						LOC35 = 0;
						LOC35 = (((NI) 0) <= x);
						if (!(LOC35)) goto LA36;
						LOC35 = (x < (aLen0-1));
						LA36: ;
						if (!LOC35) goto LA37;
						(*s) = resizeString((*s), a[(NI)(x + ((NI) 1))]->Sup.len + 0);
appendString((*s), a[(NI)(x + ((NI) 1))]);
					}
					goto LA33;
					LA37: ;
					{
						invalidformatstring_102542();
					}
					LA33: ;
					i = (NI)(j + ((NI) 1));
				}
				break;
				case 97 ... 122:
				case 65 ... 90:
				case 128 ... 255:
				case 95:
				{
					NI j;
					NI x;
					NimStringDesc* LOC43;
					j = (NI)(i + ((NI) 1));
					{
						while (1) {
							if (!(((NU8)(formatstr->data[j])) >= ((NU8)(97)) && ((NU8)(formatstr->data[j])) <= ((NU8)(122)) || ((NU8)(formatstr->data[j])) >= ((NU8)(65)) && ((NU8)(formatstr->data[j])) <= ((NU8)(90)) || ((NU8)(formatstr->data[j])) >= ((NU8)(48)) && ((NU8)(formatstr->data[j])) <= ((NU8)(57)) || ((NU8)(formatstr->data[j])) >= ((NU8)(128)) && ((NU8)(formatstr->data[j])) <= ((NU8)(255)) || ((NU8)(formatstr->data[j])) == ((NU8)(95)))) goto LA42;
							j += ((NI) 1);
						} LA42: ;
					}
					LOC43 = 0;
					LOC43 = copyStrLast(formatstr, (NI)(i + ((NI) 1)), (NI)(j - ((NI) 1)));
					x = findnormalized_102525(LOC43, a, aLen0);
					{
						NIM_BOOL LOC46;
						LOC46 = 0;
						LOC46 = (((NI) 0) <= x);
						if (!(LOC46)) goto LA47;
						LOC46 = (x < (aLen0-1));
						LA47: ;
						if (!LOC46) goto LA48;
						(*s) = resizeString((*s), a[(NI)(x + ((NI) 1))]->Sup.len + 0);
appendString((*s), a[(NI)(x + ((NI) 1))]);
					}
					goto LA44;
					LA48: ;
					{
						invalidformatstring_102542();
					}
					LA44: ;
					i = j;
				}
				break;
				default:
				{
					invalidformatstring_102542();
				}
				break;
				}
			}
			goto LA3;
			LA5: ;
			{
				(*s) = addChar((*s), formatstr->data[i]);
				i += ((NI) 1);
			}
			LA3: ;
		} LA2: ;
	}
}

N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr, NimStringDesc** a, NI aLen0) {
	NimStringDesc* result;
	result = 0;
	result = rawNewString(((NI) ((NI)((formatstr ? formatstr->Sup.len : 0) + (NI)((NU32)(aLen0) << (NU32)(((NI) 4)))))));
	nsuAddf((&result), formatstr, a, aLen0);
	return result;
}

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

N_NIMCALL(NimStringDesc*, nsuRepeatChar)(NIM_CHAR c, NI count) {
	NimStringDesc* result;
	result = 0;
	result = mnewString(count);
	{
		NI i_99895;
		NI HEX3Atmp_99897;
		NI res_99900;
		i_99895 = 0;
		HEX3Atmp_99897 = 0;
		HEX3Atmp_99897 = (NI)(((NI) (count)) - ((NI) 1));
		res_99900 = ((NI) 0);
		{
			while (1) {
				if (!(res_99900 <= ((NI) (HEX3Atmp_99897)))) goto LA3;
				i_99895 = ((NI) (res_99900));
				result->data[i_99895] = c;
				res_99900 += ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Cell47504* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_51440(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell47504* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_51440((*dest));
		{
			(*c).refcount -= ((NI) 8);
			if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA11;
			rtladdzct_53001(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

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

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

N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start) {
	NI result;
{	result = 0;
	{
		NI i_100815;
		NI HEX3Atmp_100817;
		NI res_100820;
		i_100815 = 0;
		HEX3Atmp_100817 = 0;
		HEX3Atmp_100817 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_100820 = ((NI) (start));
		{
			while (1) {
				if (!(res_100820 <= HEX3Atmp_100817)) goto LA3;
				i_100815 = res_100820;
				{
					if (!((NU8)(sub) == (NU8)(s->data[i_100815]))) goto LA6;
					result = i_100815;
					goto BeforeRet;
				}
				LA6: ;
				res_100820 += ((NI) 1);
			} LA3: ;
		}
	}
	result = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

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

N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len) {
	NimStringDesc* result;
	NI64 n;
	result = 0;
	n = x;
	result = mnewString(((NI) (len)));
	{
		NI j_99614;
		NI HEX3Atmp_99617;
		NI res_99620;
		j_99614 = 0;
		HEX3Atmp_99617 = 0;
		HEX3Atmp_99617 = (NI)(((NI) (len)) - ((NI) 1));
		res_99620 = ((NI) (HEX3Atmp_99617));
		{
			while (1) {
				if (!(((NI) 0) <= res_99620)) goto LA3;
				j_99614 = ((NI) (res_99620));
				result->data[j_99614] = ((NimStringDesc*) &TMP1411)->data[(NI64)(n & IL64(15))];
				n = (NI64)((NU64)(n) >> (NU64)(IL64(4)));
				{
					NIM_BOOL LOC6;
					LOC6 = 0;
					LOC6 = (n == IL64(0));
					if (!(LOC6)) goto LA7;
					LOC6 = (x < IL64(0));
					LA7: ;
					if (!LOC6) goto LA8;
					n = IL64(-1);
				}
				LA8: ;
				res_99620 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(void, preprocesssub_100508)(NimStringDesc* sub, NI* a) {
	NI m;
	m = (sub ? sub->Sup.len : 0);
	{
		NI i_100524;
		NI res_100538;
		i_100524 = 0;
		res_100538 = ((NI) 0);
		{
			while (1) {
				if (!(res_100538 <= ((NI) 255))) goto LA3;
				i_100524 = res_100538;
				a[(((NU8)(((NIM_CHAR) (((NI) (i_100524)))))))- 0] = (NI)(m + ((NI) 1));
				res_100538 += ((NI) 1);
			} LA3: ;
		}
	}
	{
		NI i_100534;
		NI HEX3Atmp_100543;
		NI res_100546;
		i_100534 = 0;
		HEX3Atmp_100543 = 0;
		HEX3Atmp_100543 = (NI)(m - ((NI) 1));
		res_100546 = ((NI) 0);
		{
			while (1) {
				if (!(res_100546 <= HEX3Atmp_100543)) goto LA6;
				i_100534 = res_100546;
				a[(((NU8)(sub->data[i_100534])))- 0] = (NI)(m - i_100534);
				res_100546 += ((NI) 1);
			} LA6: ;
		}
	}
}

N_NIMCALL(NI, findaux_100550)(NimStringDesc* s, NimStringDesc* sub, NI start, Skiptable100505 a) {
	NI result;
	NI m;
	NI n;
	NI j;
{	result = 0;
	m = (sub ? sub->Sup.len : 0);
	n = (s ? s->Sup.len : 0);
	j = start;
	{
		while (1) {
			if (!(j <= (NI)(n - m))) goto LA2;
			{
				{
					NI k_100570;
					NI HEX3Atmp_100582;
					NI res_100585;
					k_100570 = 0;
					HEX3Atmp_100582 = 0;
					HEX3Atmp_100582 = (NI)(m - ((NI) 1));
					res_100585 = ((NI) 0);
					{
						while (1) {
							if (!(res_100585 <= HEX3Atmp_100582)) goto LA6;
							k_100570 = res_100585;
							{
								if (!!(((NU8)(sub->data[k_100570]) == (NU8)(s->data[(NI)(k_100570 + j)])))) goto LA9;
								goto LA3;
							}
							LA9: ;
							res_100585 += ((NI) 1);
						} LA6: ;
					}
				}
				result = j;
				goto BeforeRet;
			} LA3: ;
			j += a[(((NU8)(s->data[(NI)(j + m)])))- 0];
		} LA2: ;
	}
	result = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuReplaceStr)(NimStringDesc* s, NimStringDesc* sub, NimStringDesc* by) {
	NimStringDesc* result;
	Skiptable100505 a;
	NI i;
	NimStringDesc* LOC8;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP1413));
	preprocesssub_100508(sub, a);
	i = ((NI) 0);
	{
		while (1) {
			NI j;
			NimStringDesc* LOC7;
			j = findaux_100550(s, sub, i, a);
			{
				if (!(j < ((NI) 0))) goto LA5;
				goto LA1;
			}
			LA5: ;
			LOC7 = 0;
			LOC7 = copyStrLast(s, i, (NI)(j - ((NI) 1)));
			result = resizeString(result, LOC7->Sup.len + 0);
appendString(result, LOC7);
			result = resizeString(result, by->Sup.len + 0);
appendString(result, by);
			i = (NI)(j + (sub ? sub->Sup.len : 0));
		}
	} LA1: ;
	LOC8 = 0;
	LOC8 = copyStr(s, i);
	result = resizeString(result, LOC8->Sup.len + 0);
appendString(result, LOC8);
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToBin)(NI64 x, NI len) {
	NimStringDesc* result;
	NI64 mask;
	NI64 shift;
	result = 0;
	mask = IL64(1);
	shift = IL64(0);
	result = mnewString(((NI) (len)));
	{
		NI j_101612;
		NI HEX3Atmp_101624;
		NI res_101627;
		j_101612 = 0;
		HEX3Atmp_101624 = 0;
		HEX3Atmp_101624 = (NI)(((NI) (len)) - ((NI) 1));
		res_101627 = ((NI) (HEX3Atmp_101624));
		{
			while (1) {
				if (!(((NI) 0) <= res_101627)) goto LA3;
				j_101612 = ((NI) (res_101627));
				result->data[j_101612] = ((NIM_CHAR) (((NI) ((NI)(((NI) ((NI64)((NU64)((NI64)(x & mask)) >> (NU64)(shift)))) + ((NI) 48))))));
				shift = (NI64)(shift + IL64(1));
				mask = (NI64)((NU64)(mask) << (NU64)(IL64(1)));
				res_101627 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToOct)(NI64 x, NI len) {
	NimStringDesc* result;
	NI64 mask;
	NI64 shift;
	result = 0;
	mask = IL64(7);
	shift = IL64(0);
	result = mnewString(((NI) (len)));
	{
		NI j_101412;
		NI HEX3Atmp_101424;
		NI res_101427;
		j_101412 = 0;
		HEX3Atmp_101424 = 0;
		HEX3Atmp_101424 = (NI)(((NI) (len)) - ((NI) 1));
		res_101427 = ((NI) (HEX3Atmp_101424));
		{
			while (1) {
				if (!(((NI) 0) <= res_101427)) goto LA3;
				j_101412 = ((NI) (res_101427));
				result->data[j_101412] = ((NIM_CHAR) (((NI) ((NI)(((NI) ((NI64)((NU64)((NI64)(x & mask)) >> (NU64)(shift)))) + ((NI) 48))))));
				shift = (NI64)(shift + IL64(3));
				mask = (NI64)((NU64)(mask) << (NU64)(IL64(3)));
				res_101427 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY203404 chars, NI start) {
	NI result;
{	result = 0;
	{
		NI i_100840;
		NI HEX3Atmp_100852;
		NI res_100855;
		i_100840 = 0;
		HEX3Atmp_100852 = 0;
		HEX3Atmp_100852 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_100855 = ((NI) (start));
		{
			while (1) {
				if (!(res_100855 <= HEX3Atmp_100852)) goto LA3;
				i_100840 = res_100855;
				{
					if (!((chars[(NU)(((NU8)(s->data[i_100840])))>>3] &(1U<<((NU)(((NU8)(s->data[i_100840])))&7U)))!=0)) goto LA6;
					result = i_100840;
					goto BeforeRet;
				}
				LA6: ;
				res_100855 += ((NI) 1);
			} LA3: ;
		}
	}
	result = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, contains_101033)(NimStringDesc* s, TY203404 chars) {
	NIM_BOOL result;
	NI LOC1;
{	result = 0;
	LOC1 = 0;
	LOC1 = nsuFindCharSet(s, chars, ((NI) 0));
	result = (((NI) 0) <= LOC1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuStrip)(NimStringDesc* s, NIM_BOOL leading, NIM_BOOL trailing, TY203404 chars) {
	NimStringDesc* result;
	NI first;
	NI last;
	result = 0;
	first = ((NI) 0);
	last = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
	{
		if (!leading) goto LA3;
		{
			while (1) {
				if (!((chars[(NU)(((NU8)(s->data[first])))>>3] &(1U<<((NU)(((NU8)(s->data[first])))&7U)))!=0)) goto LA6;
				first += ((NI) 1);
			} LA6: ;
		}
	}
	LA3: ;
	{
		if (!trailing) goto LA9;
		{
			while (1) {
				NIM_BOOL LOC13;
				LOC13 = 0;
				LOC13 = (((NI) 0) <= last);
				if (!(LOC13)) goto LA14;
				LOC13 = ((chars[(NU)(((NU8)(s->data[last])))>>3] &(1U<<((NU)(((NU8)(s->data[last])))&7U)))!=0);
				LA14: ;
				if (!LOC13) goto LA12;
				last -= ((NI) 1);
			} LA12: ;
		}
	}
	LA9: ;
	result = copyStrLast(s, first, last);
	return result;
}

N_NIMCALL(NI, nsuCmpIgnoreCase)(NimStringDesc* a, NimStringDesc* b) {
	NI result;
	NI i;
	NI m;
{	result = 0;
	i = ((NI) 0);
	m = (((a ? a->Sup.len : 0) <= (b ? b->Sup.len : 0)) ? (a ? a->Sup.len : 0) : (b ? b->Sup.len : 0));
	{
		while (1) {
			NIM_CHAR LOC3;
			NIM_CHAR LOC4;
			if (!(i < m)) goto LA2;
			LOC3 = 0;
			LOC3 = nsuToLowerChar(a->data[i]);
			LOC4 = 0;
			LOC4 = nsuToLowerChar(b->data[i]);
			result = (NI)(((NI) (((NU8)(LOC3)))) - ((NI) (((NU8)(LOC4)))));
			{
				if (!!((result == ((NI) 0)))) goto LA7;
				goto BeforeRet;
			}
			LA7: ;
			i += ((NI) 1);
		} LA2: ;
	}
	result = (NI)((a ? a->Sup.len : 0) - (b ? b->Sup.len : 0));
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NI, nsuParseInt)(NimStringDesc* s) {
	NI result;
	NI L;
	result = 0;
	L = npuParseInt(s, (&result), ((NI) 0));
	{
		NIM_BOOL LOC3;
		Valueerror3646* e_99655;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = !((L == (s ? s->Sup.len : 0)));
		if (LOC3) goto LA4;
		LOC3 = (L == ((NI) 0));
		LA4: ;
		if (!LOC3) goto LA5;
		e_99655 = 0;
		e_99655 = (Valueerror3646*) newObj((&NTI23625), sizeof(Valueerror3646));
		(*e_99655).Sup.Sup.m_type = (&NTI3646);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &TMP1268));
appendString(LOC7, s);
		asgnRefNoCycle((void**) (&(*e_99655).Sup.message), LOC7);
		raiseException((Exception*)e_99655, "ValueError");
	}
	LA5: ;
	return result;
}

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

N_NIMCALL(NimStringDesc*, nsuNormalize)(NimStringDesc* s) {
	NimStringDesc* result;
	NI j;
	result = 0;
	result = mnewString(((NI) ((s ? s->Sup.len : 0))));
	j = ((NI) 0);
	{
		NI i_98535;
		NI HEX3Atmp_98593;
		NI res_98596;
		i_98535 = 0;
		HEX3Atmp_98593 = 0;
		HEX3Atmp_98593 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_98596 = ((NI) 0);
		{
			while (1) {
				if (!(res_98596 <= HEX3Atmp_98593)) goto LA3;
				i_98535 = res_98596;
				{
					if (!(((NU8)(s->data[i_98535])) >= ((NU8)(65)) && ((NU8)(s->data[i_98535])) <= ((NU8)(90)))) goto LA6;
					result->data[j] = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(s->data[i_98535])))) + ((NI) 32))))));
					j += ((NI) 1);
				}
				goto LA4;
				LA6: ;
				{
					if (!!(((NU8)(s->data[i_98535]) == (NU8)(95)))) goto LA9;
					result->data[j] = s->data[i_98535];
					j += ((NI) 1);
				}
				goto LA4;
				LA9: ;
				LA4: ;
				res_98596 += ((NI) 1);
			} LA3: ;
		}
	}
	{
		if (!!((j == (s ? s->Sup.len : 0)))) goto LA13;
		result = setLengthStr(result, ((NI) (j)));
	}
	LA13: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToLowerStr)(NimStringDesc* s) {
	NimStringDesc* result;
	result = 0;
	result = mnewString(((NI) ((s ? s->Sup.len : 0))));
	{
		NI i_98444;
		NI HEX3Atmp_98446;
		NI res_98449;
		i_98444 = 0;
		HEX3Atmp_98446 = 0;
		HEX3Atmp_98446 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_98449 = ((NI) 0);
		{
			while (1) {
				if (!(res_98449 <= HEX3Atmp_98446)) goto LA3;
				i_98444 = res_98449;
				result->data[i_98444] = nsuToLowerChar(s->data[i_98444]);
				res_98449 += ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NIM_BOOL, nsuEndsWith)(NimStringDesc* s, NimStringDesc* suffix) {
	NIM_BOOL result;
	NI i;
	NI j;
{	result = 0;
	i = ((NI) 0);
	j = (NI)((s ? s->Sup.len : 0) - (suffix ? suffix->Sup.len : 0));
	{
		while (1) {
			if (!((NU32)((NI)(i + j)) < (NU32)((s ? s->Sup.len : 0)))) goto LA2;
			{
				if (!!(((NU8)(s->data[(NI)(i + j)]) == (NU8)(suffix->data[i])))) goto LA5;
				result = NIM_FALSE;
				goto BeforeRet;
			}
			LA5: ;
			i += ((NI) 1);
		} LA2: ;
	}
	{
		if (!((NU8)(suffix->data[i]) == (NU8)(0))) goto LA9;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA9: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, contains_101023)(NimStringDesc* s, NIM_CHAR c) {
	NIM_BOOL result;
	NI LOC1;
{	result = 0;
	LOC1 = 0;
	LOC1 = nsuFindChar(s, c, ((NI) 0));
	result = (((NI) 0) <= LOC1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, allcharsinset_100325)(NimStringDesc* s, TY203404 theset) {
	NIM_BOOL result;
{	result = 0;
	{
		NIM_CHAR c_100332;
		NI i_100346;
		NI L_100348;
		c_100332 = 0;
		i_100346 = ((NI) 0);
		L_100348 = (s ? s->Sup.len : 0);
		{
			while (1) {
				if (!(i_100346 < L_100348)) goto LA3;
				c_100332 = s->data[i_100346];
				{
					if (!!(((theset[(NU)(((NU8)(c_100332)))>>3] &(1U<<((NU)(((NU8)(c_100332)))&7U)))!=0))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				i_100346 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuJoin)(NimStringDesc** a, NI aLen0) {
	NimStringDesc* result;
	result = 0;
	{
		NI L;
		if (!(((NI) 0) < aLen0)) goto LA3;
		L = ((NI) 0);
		{
			NI i_100468;
			NI HEX3Atmp_100489;
			NI res_100492;
			i_100468 = 0;
			HEX3Atmp_100489 = 0;
			HEX3Atmp_100489 = (aLen0-1);
			res_100492 = ((NI) 0);
			{
				while (1) {
					if (!(res_100492 <= HEX3Atmp_100489)) goto LA7;
					i_100468 = res_100492;
					L += (a[i_100468] ? a[i_100468]->Sup.len : 0);
					res_100492 += ((NI) 1);
				} LA7: ;
			}
		}
		result = rawNewString(((NI) (L)));
		{
			NI i_100487;
			NI HEX3Atmp_100497;
			NI res_100500;
			i_100487 = 0;
			HEX3Atmp_100497 = 0;
			HEX3Atmp_100497 = (aLen0-1);
			res_100500 = ((NI) 0);
			{
				while (1) {
					if (!(res_100500 <= HEX3Atmp_100497)) goto LA10;
					i_100487 = res_100500;
					result = resizeString(result, a[i_100487]->Sup.len + 0);
appendString(result, a[i_100487]);
					res_100500 += ((NI) 1);
				} LA10: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1413));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NI, nsuFindStr)(NimStringDesc* s, NimStringDesc* sub, NI start) {
	NI result;
	Skiptable100505 a;
	result = 0;
	preprocesssub_100508(sub, a);
	result = findaux_100550(s, sub, ((NI) (start)), a);
	return result;
}

N_NIMCALL(TY125202*, nsuSplitChar)(NimStringDesc* s, NIM_CHAR sep) {
	TY125202* result;
	result = 0;
	result = (TY125202*) newSeq((&NTI125202), 0);
	{
		NimStringDesc* x_99442;
		NI last_99473;
		x_99442 = 0;
		last_99473 = ((NI) 0);
		{
			if (!(((NI) 0) < (s ? s->Sup.len : 0))) goto LA4;
			{
				while (1) {
					NI first_99475;
					NimStringDesc* LOC12;
					if (!(last_99473 <= (s ? s->Sup.len : 0))) goto LA7;
					first_99475 = last_99473;
					{
						while (1) {
							NIM_BOOL LOC10;
							LOC10 = 0;
							LOC10 = (last_99473 < (s ? s->Sup.len : 0));
							if (!(LOC10)) goto LA11;
							LOC10 = !(((NU8)(s->data[last_99473]) == (NU8)(sep)));
							LA11: ;
							if (!LOC10) goto LA9;
							last_99473 += ((NI) 1);
						} LA9: ;
					}
					x_99442 = copyStrLast(s, first_99475, (NI)(last_99473 - ((NI) 1)));
					result = (TY125202*) incrSeqV2(&(result)->Sup, sizeof(NimStringDesc*));
					LOC12 = 0;
					LOC12 = result->data[result->Sup.len]; result->data[result->Sup.len] = copyStringRC1(x_99442);
					if (LOC12) nimGCunrefNoCycle(LOC12);
					++result->Sup.len;
					last_99473 += ((NI) 1);
				} LA7: ;
			}
		}
		LA4: ;
	}
	return result;
}

N_NIMCALL(NimStringDesc*, nsuJoinSep)(NimStringDesc** a, NI aLen0, NimStringDesc* sep) {
	NimStringDesc* result;
	result = 0;
	{
		NI L;
		if (!(((NI) 0) < aLen0)) goto LA3;
		L = (NI)((sep ? sep->Sup.len : 0) * (NI)(aLen0 - ((NI) 1)));
		{
			NI i_100410;
			NI HEX3Atmp_100431;
			NI res_100434;
			i_100410 = 0;
			HEX3Atmp_100431 = 0;
			HEX3Atmp_100431 = (aLen0-1);
			res_100434 = ((NI) 0);
			{
				while (1) {
					if (!(res_100434 <= HEX3Atmp_100431)) goto LA7;
					i_100410 = res_100434;
					L += (a[i_100410] ? a[i_100410]->Sup.len : 0);
					res_100434 += ((NI) 1);
				} LA7: ;
			}
		}
		result = rawNewString(((NI) (L)));
		result = resizeString(result, a[((NI) 0)]->Sup.len + 0);
appendString(result, a[((NI) 0)]);
		{
			NI i_100429;
			NI HEX3Atmp_100439;
			NI res_100442;
			i_100429 = 0;
			HEX3Atmp_100439 = 0;
			HEX3Atmp_100439 = (aLen0-1);
			res_100442 = ((NI) 1);
			{
				while (1) {
					if (!(res_100442 <= HEX3Atmp_100439)) goto LA10;
					i_100429 = res_100442;
					result = resizeString(result, sep->Sup.len + 0);
appendString(result, sep);
					result = resizeString(result, a[i_100429]->Sup.len + 0);
appendString(result, a[i_100429]);
					res_100442 += ((NI) 1);
				} LA10: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1413));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuEscape)(NimStringDesc* s, NimStringDesc* prefix, NimStringDesc* suffix) {
	NimStringDesc* result;
	result = 0;
	result = rawNewString(((NI) ((NI)((s ? s->Sup.len : 0) + (NI)((NU32)((s ? s->Sup.len : 0)) >> (NU32)(((NI) 2)))))));
	result = resizeString(result, prefix->Sup.len + 0);
appendString(result, prefix);
	{
		NIM_CHAR c_101700;
		NI i_101712;
		NI L_101714;
		c_101700 = 0;
		i_101712 = ((NI) 0);
		L_101714 = (s ? s->Sup.len : 0);
		{
			while (1) {
				if (!(i_101712 < L_101714)) goto LA3;
				c_101700 = s->data[i_101712];
				switch (((NU8)(c_101700))) {
				case 0 ... 31:
				case 128 ... 255:
				{
					NimStringDesc* LOC5;
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2114));
					LOC5 = 0;
					LOC5 = nsuToHex(((NI64) (((NU8)(c_101700)))), ((NI) 2));
					result = resizeString(result, LOC5->Sup.len + 0);
appendString(result, LOC5);
				}
				break;
				case 92:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2115));
				}
				break;
				case 39:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2116));
				}
				break;
				case 34:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2117));
				}
				break;
				default:
				{
					result = addChar(result, c_101700);
				}
				break;
				}
				i_101712 += ((NI) 1);
			} LA3: ;
		}
	}
	result = resizeString(result, suffix->Sup.len + 0);
appendString(result, suffix);
	return result;
}

N_NIMCALL(void, nsuDelete)(NimStringDesc** s, NI first, NI last) {
	NI i;
	NI j;
	NI newlen;
	i = first;
	j = (NI)(last + ((NI) 1));
	newlen = (NI)((NI)(((*s) ? (*s)->Sup.len : 0) - j) + i);
	{
		while (1) {
			if (!(i < newlen)) goto LA2;
			(*s)->data[i] = (*s)->data[j];
			i += ((NI) 1);
			j += ((NI) 1);
		} LA2: ;
	}
	(*s) = setLengthStr((*s), ((NI) (newlen)));
}

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

N_NIMCALL(NIM_BOOL, nsuContinuesWith)(NimStringDesc* s, NimStringDesc* substr, NI start) {
	NIM_BOOL result;
	NI i;
{	result = 0;
	i = ((NI) 0);
	{
		while (1) {
			{
				if (!((NU8)(substr->data[i]) == (NU8)(0))) goto LA5;
				result = NIM_TRUE;
				goto BeforeRet;
			}
			LA5: ;
			{
				if (!!(((NU8)(s->data[(NI)(i + ((NI) (start)))]) == (NU8)(substr->data[i])))) goto LA9;
				result = NIM_FALSE;
				goto BeforeRet;
			}
			LA9: ;
			i += ((NI) 1);
		}
	}
	}BeforeRet: ;
	return result;
}

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

N_NIMCALL(NimStringDesc*, nsuIntToStr)(NI x, NI minchars) {
	NimStringDesc* result;
	result = 0;
	result = nimIntToStr((x > 0? (x) : -(x)));
	{
		NI i_99637;
		NI HEX3Atmp_99639;
		NI res_99642;
		i_99637 = 0;
		HEX3Atmp_99639 = 0;
		HEX3Atmp_99639 = (NI)(((NI) (minchars)) - (result ? result->Sup.len : 0));
		res_99642 = ((NI) 1);
		{
			while (1) {
				NimStringDesc* LOC4;
				if (!(res_99642 <= HEX3Atmp_99639)) goto LA3;
				i_99637 = res_99642;
				LOC4 = 0;
				LOC4 = rawNewString(result->Sup.len + 1);
appendChar(LOC4, 48);
appendString(LOC4, result);
				result = LOC4;
				res_99642 += ((NI) 1);
			} LA3: ;
		}
	}
	{
		NimStringDesc* LOC9;
		if (!(x < ((NI) 0))) goto LA7;
		LOC9 = 0;
		LOC9 = rawNewString(result->Sup.len + 1);
appendChar(LOC9, 45);
appendString(LOC9, result);
		result = LOC9;
	}
	LA7: ;
	return result;
}

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

N_NIMCALL(NimStringDesc*, nsuRepeatStr)(NimStringDesc* s, NI n) {
	NimStringDesc* result;
	result = 0;
	result = rawNewString(((NI) ((NI)(((NI) (n)) * (s ? s->Sup.len : 0)))));
	{
		NI i_100014;
		NI res_100018;
		i_100014 = 0;
		res_100018 = ((NI) 1);
		{
			while (1) {
				if (!(res_100018 <= ((NI) (n)))) goto LA3;
				i_100014 = ((NI) (res_100018));
				result = resizeString(result, s->Sup.len + 0);
appendString(result, s);
				res_100018 += ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NimStringDesc*, nsuReplaceChar)(NimStringDesc* s, NIM_CHAR sub, NIM_CHAR by) {
	NimStringDesc* result;
	NI i;
	result = 0;
	result = mnewString(((NI) ((s ? s->Sup.len : 0))));
	i = ((NI) 0);
	{
		while (1) {
			if (!(i < (s ? s->Sup.len : 0))) goto LA2;
			{
				if (!((NU8)(s->data[i]) == (NU8)(sub))) goto LA5;
				result->data[i] = by;
			}
			goto LA3;
			LA5: ;
			{
				result->data[i] = s->data[i];
			}
			LA3: ;
			i += ((NI) 1);
		} LA2: ;
	}
	return result;
}

static N_INLINE(Slice88082, HEX2EHEX2E_102424)(NI a, NI b) {
	Slice88082 result;
	memset((void*)(&result), 0, sizeof(result));
	result.a = a;
	result.b = b;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuformatBiggestFloat)(NF f, NU8 format, NI precision, NIM_CHAR decimalsep) {
	NimStringDesc* result;
	TY102408 frmtstr;
	TY102412 buf;
	int L;
	result = 0;
	L = 0;
	frmtstr[(((NI) 0))- 0] = 37;
	{
		if (!(((NI) 0) < ((NI) (precision)))) goto LA3;
		frmtstr[(((NI) 1))- 0] = 35;
		frmtstr[(((NI) 2))- 0] = 46;
		frmtstr[(((NI) 3))- 0] = 42;
		frmtstr[(((NI) 4))- 0] = floatformattochar_102401[(format)- 0];
		frmtstr[(((NI) 5))- 0] = 0;
		L = sprintf(((NCSTRING) (buf)), ((NCSTRING) (frmtstr)), precision, f);
	}
	goto LA1;
	LA3: ;
	{
		frmtstr[(((NI) 1))- 0] = floatformattochar_102401[(format)- 0];
		frmtstr[(((NI) 2))- 0] = 0;
		L = sprintf(((NCSTRING) (buf)), ((NCSTRING) (frmtstr)), f);
	}
	LA1: ;
	result = mnewString(((NI) (L)));
	{
		NI i_102459;
		Slice88082 HEX3Atmp_102475;
		i_102459 = 0;
		memset((void*)(&HEX3Atmp_102475), 0, sizeof(HEX3Atmp_102475));
		HEX3Atmp_102475 = HEX2EHEX2E_102424(((NI) 0), ((NI) ((L - 1))));
		{
			NI x_102479;
			NI HEX3Atmp_102481;
			NI HEX3Atmp_102483;
			NI res_102485;
			x_102479 = 0;
			HEX3Atmp_102481 = 0;
			HEX3Atmp_102483 = 0;
			HEX3Atmp_102481 = HEX3Atmp_102475.a;
			HEX3Atmp_102483 = HEX3Atmp_102475.b;
			res_102485 = HEX3Atmp_102481;
			{
				while (1) {
					if (!(res_102485 <= HEX3Atmp_102483)) goto LA9;
					x_102479 = res_102485;
					i_102459 = x_102479;
					{
						if (!(((NU8)(buf[(i_102459)- 0])) == ((NU8)(46)) || ((NU8)(buf[(i_102459)- 0])) == ((NU8)(44)))) goto LA12;
						result->data[i_102459] = decimalsep;
					}
					goto LA10;
					LA12: ;
					{
						result->data[i_102459] = buf[(i_102459)- 0];
					}
					LA10: ;
					res_102485 += ((NI) 1);
				} LA9: ;
			}
		}
	}
	return result;
}

N_NIMCALL(NimStringDesc*, nsuformatFloat)(NF f, NU8 format, NI precision, NIM_CHAR decimalsep) {
	NimStringDesc* result;
	result = 0;
	result = nsuformatBiggestFloat(f, format, precision, decimalsep);
	return result;
}

N_NIMCALL(NimStringDesc*, nsuInsertSep)(NimStringDesc* s, NIM_CHAR sep, NI digits) {
	NimStringDesc* result;
	NI L;
	NI j;
	result = 0;
	L = (NI)((NI)((NI)((s ? s->Sup.len : 0) - ((NI) 1)) / digits) + (s ? s->Sup.len : 0));
	result = mnewString(((NI) (L)));
	j = ((NI) 0);
	L -= ((NI) 1);
	{
		NI i_101657;
		NI HEX3Atmp_101686;
		NI res_101689;
		i_101657 = 0;
		HEX3Atmp_101686 = 0;
		HEX3Atmp_101686 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_101689 = HEX3Atmp_101686;
		{
			while (1) {
				if (!(((NI) 0) <= res_101689)) goto LA3;
				i_101657 = res_101689;
				{
					if (!(j == digits)) goto LA6;
					result->data[L] = sep;
					L -= ((NI) 1);
					j = ((NI) 0);
				}
				LA6: ;
				result->data[L] = s->data[i_101657];
				j += ((NI) 1);
				L -= ((NI) 1);
				res_101689 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NimStringDesc*, formatsize_102497)(NI64 bytes, NIM_CHAR decimalsep) {
	NimStringDesc* result;
	NI64 gigabytes;
	NI64 megabytes;
	NI64 kilobytes;
	result = 0;
	gigabytes = (NI64)((NU64)(bytes) >> (NU64)(IL64(30)));
	megabytes = (NI64)((NU64)(bytes) >> (NU64)(IL64(20)));
	kilobytes = (NI64)((NU64)(bytes) >> (NU64)(IL64(10)));
	{
		NimStringDesc* bs_102520;
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		NimStringDesc* LOC8;
		if (!!((gigabytes == IL64(0)))) goto LA3;
		bs_102520 = nimInt64ToStr(megabytes);
		LOC5 = 0;
		LOC6 = 0;
		LOC6 = nimInt64ToStr(gigabytes);
		LOC7 = 0;
		LOC7 = nsuInsertSep(LOC6, 95, ((NI) 3));
		LOC8 = 0;
		LOC8 = copyStrLast(bs_102520, ((NI) 0), ((NI) 2));
		LOC5 = rawNewString(LOC7->Sup.len + LOC8->Sup.len + 3);
appendString(LOC5, LOC7);
appendChar(LOC5, decimalsep);
appendString(LOC5, LOC8);
appendString(LOC5, ((NimStringDesc*) &TMP5293));
		result = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* bs_102522;
		NimStringDesc* LOC12;
		NimStringDesc* LOC13;
		NimStringDesc* LOC14;
		NimStringDesc* LOC15;
		if (!!((megabytes == IL64(0)))) goto LA10;
		bs_102522 = nimInt64ToStr(kilobytes);
		LOC12 = 0;
		LOC13 = 0;
		LOC13 = nimInt64ToStr(megabytes);
		LOC14 = 0;
		LOC14 = nsuInsertSep(LOC13, 95, ((NI) 3));
		LOC15 = 0;
		LOC15 = copyStrLast(bs_102522, ((NI) 0), ((NI) 2));
		LOC12 = rawNewString(LOC14->Sup.len + LOC15->Sup.len + 3);
appendString(LOC12, LOC14);
appendChar(LOC12, decimalsep);
appendString(LOC12, LOC15);
appendString(LOC12, ((NimStringDesc*) &TMP5294));
		result = LOC12;
	}
	goto LA1;
	LA10: ;
	{
		NimStringDesc* bs_102524;
		NimStringDesc* LOC19;
		NimStringDesc* LOC20;
		NimStringDesc* LOC21;
		NimStringDesc* LOC22;
		if (!!((kilobytes == IL64(0)))) goto LA17;
		bs_102524 = nimInt64ToStr(bytes);
		LOC19 = 0;
		LOC20 = 0;
		LOC20 = nimInt64ToStr(kilobytes);
		LOC21 = 0;
		LOC21 = nsuInsertSep(LOC20, 95, ((NI) 3));
		LOC22 = 0;
		LOC22 = copyStrLast(bs_102524, ((NI) 0), ((NI) 2));
		LOC19 = rawNewString(LOC21->Sup.len + LOC22->Sup.len + 3);
appendString(LOC19, LOC21);
appendChar(LOC19, decimalsep);
appendString(LOC19, LOC22);
appendString(LOC19, ((NimStringDesc*) &TMP5295));
		result = LOC19;
	}
	goto LA1;
	LA17: ;
	{
		NimStringDesc* LOC24;
		NimStringDesc* LOC25;
		NimStringDesc* LOC26;
		LOC24 = 0;
		LOC25 = 0;
		LOC25 = nimInt64ToStr(bytes);
		LOC26 = 0;
		LOC26 = nsuInsertSep(LOC25, 95, ((NI) 3));
		LOC24 = rawNewString(LOC26->Sup.len + 1);
appendString(LOC24, LOC26);
appendString(LOC24, ((NimStringDesc*) &TMP5296));
		result = LOC24;
	}
	LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_strutilsInit000)(void) {
}

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

