/* Generated by Nim Compiler v0.11.2 */
/*   (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 Valueerror3449 Valueerror3449;
typedef struct Exception Exception;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Tcell46346 Tcell46346;
typedef struct Tcellseq46362 Tcellseq46362;
typedef struct Tgcheap48216 Tgcheap48216;
typedef struct Tcellset46358 Tcellset46358;
typedef struct Tpagedesc46354 Tpagedesc46354;
typedef struct Tmemregion28210 Tmemregion28210;
typedef struct Tsmallchunk27440 Tsmallchunk27440;
typedef struct Tllchunk28204 Tllchunk28204;
typedef struct Tbigchunk27442 Tbigchunk27442;
typedef struct Tintset27417 Tintset27417;
typedef struct Ttrunk27413 Ttrunk27413;
typedef struct Tavlnode28208 Tavlnode28208;
typedef struct Tgcstat48214 Tgcstat48214;
typedef struct TY122008 TY122008;
typedef struct Tbasechunk27438 Tbasechunk27438;
typedef struct Tfreecell27430 Tfreecell27430;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY3289) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3294) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3289 marker;
TY3294 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Exception  {
  TNimObject Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  Valueerror3449  {
  Exception Sup;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Tcell46346  {
NI refcount;
TNimType* typ;
};
struct  Tcellseq46362  {
NI len;
NI cap;
Tcell46346** d;
};
struct  Tcellset46358  {
NI counter;
NI max;
Tpagedesc46354* head;
Tpagedesc46354** data;
};
typedef Tsmallchunk27440* TY28222[512];
typedef Ttrunk27413* Ttrunkbuckets27415[256];
struct  Tintset27417  {
Ttrunkbuckets27415 data;
};
struct  Tmemregion28210  {
NI minlargeobj;
NI maxlargeobj;
TY28222 freesmallchunks;
Tllchunk28204* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Tbigchunk27442* freechunkslist;
Tintset27417 chunkstarts;
Tavlnode28208* root;
Tavlnode28208* deleted;
Tavlnode28208* last;
Tavlnode28208* freeavlnodes;
};
struct  Tgcstat48214  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Tgcheap48216  {
void* stackbottom;
NI cyclethreshold;
Tcellseq46362 zct;
Tcellseq46362 decstack;
Tcellset46358 cycleroots;
Tcellseq46362 tempstack;
NI recgclock;
Tmemregion28210 region;
Tgcstat48214 stat;
};
typedef NimStringDesc* TY165566[1];
typedef NI Skiptable98721[256];
typedef NU8 TY179407[32];
typedef NIM_CHAR TY100669[6];
typedef NIM_CHAR TY100672[2501];
typedef NIM_CHAR TY100664[3];
typedef NI TY27420[16];
struct  Tpagedesc46354  {
Tpagedesc46354* next;
NI key;
TY27420 bits;
};
struct  Tbasechunk27438  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Tsmallchunk27440  {
  Tbasechunk27438 Sup;
Tsmallchunk27440* next;
Tsmallchunk27440* prev;
Tfreecell27430* freelist;
NI free;
NI acc;
NF data;
};
struct  Tllchunk28204  {
NI size;
NI acc;
Tllchunk28204* next;
};
struct  Tbigchunk27442  {
  Tbasechunk27438 Sup;
Tbigchunk27442* next;
Tbigchunk27442* prev;
NI align;
NF data;
};
struct  Ttrunk27413  {
Ttrunk27413* next;
NI key;
TY27420 bits;
};
typedef Tavlnode28208* TY28214[2];
struct  Tavlnode28208  {
TY28214 link;
NI key;
NI upperbound;
NI level;
};
struct  Tfreecell27430  {
Tfreecell27430* next;
NI zerofield;
};
struct TY122008 {
  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_100760)(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(Tcell46346*, usrtocell_49846)(void* usr);
static N_INLINE(void, rtladdzct_51404)(Tcell46346* c);
N_NOINLINE(void, addzct_49817)(Tcellseq46362* s, Tcell46346* 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_100731)(NimStringDesc* x, NimStringDesc** inarray, NI inarrayLen0);
N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_76243, 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_98727)(NimStringDesc* sub, NI* a);
N_NIMCALL(NI, findaux_98795)(NimStringDesc* s, NimStringDesc* sub, NI start, Skiptable98721 a);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY179407 chars, NI start);
N_NIMCALL(NI, npuParseInt)(NimStringDesc* s, NI* number, NI start);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newlen);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len);
N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
N_NIMCALL(NimStringDesc*, nsuformatBiggestFloat)(NF f, NU8 format, NI precision);
N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
N_NIMCALL(NimStringDesc*, nimInt64ToStr)(NI64 x);
N_NIMCALL(NimStringDesc*, nsuInsertSep)(NimStringDesc* s, NIM_CHAR sep, NI digits);
STRING_LITERAL(TMP147, "invalid format string", 21);
STRING_LITERAL(TMP996, "invalid float: ", 15);
STRING_LITERAL(TMP1140, "invalid integer: ", 17);
STRING_LITERAL(TMP1292, "0123456789ABCDEF", 16);
STRING_LITERAL(TMP1294, "", 0);
static NIM_CONST TY179407 TMP1538 = {
0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
;
STRING_LITERAL(TMP2089, "\\x", 2);
STRING_LITERAL(TMP2090, "\\\\", 2);
STRING_LITERAL(TMP2091, "\\\'", 2);
STRING_LITERAL(TMP2092, "\\\"", 2);
NIM_CONST TY100664 floatformattochar_100663 = {103,
102,
101}
;
STRING_LITERAL(TMP5008, "GB", 2);
STRING_LITERAL(TMP5009, "MB", 2);
STRING_LITERAL(TMP5010, "KB", 2);
STRING_LITERAL(TMP5011, "B", 1);
extern TNimType NTI22401; /* ref ValueError */
extern TNimType NTI3449; /* ValueError */
extern Tgcheap48216 gch_48244;
extern TNimType NTI122008; /* seq[string] */
extern TNimType NTI108; /* int */
TNimType NTI98721; /* 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_96541;
		NI res_96556;
		i_96541 = 0;
		res_96556 = ((NI) 2);
		{
			while (1) {
				if (!(((NI) 0) <= res_96556)) goto LA3;
				i_96541 = res_96556;
				result->data[i_96541] = ((NIM_CHAR) (((NI) ((NI)(((NI) ((NI)(((NI) (val)) % ((NI) 8)))) + ((NI) 48))))));
				val = ((NI) ((NI)(((NI) (val)) / ((NI) 8))));
				res_96556 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

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

static N_INLINE(void, rtladdzct_51404)(Tcell46346* c) {
	addzct_49817((&gch_48244.zct), c);
}

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

N_NOINLINE(void, invalidformatstring_100760)(void) {
	Valueerror3449* e_100764;
	NimStringDesc* LOC1;
	e_100764 = 0;
	e_100764 = (Valueerror3449*) newObj((&NTI22401), sizeof(Valueerror3449));
	(*e_100764).Sup.Sup.m_type = (&NTI3449);
	LOC1 = 0;
	LOC1 = (*e_100764).Sup.message; (*e_100764).Sup.message = copyStringRC1(((NimStringDesc*) &TMP147));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	raiseException((Exception*)e_100764, "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_100731)(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_100760();
					}
					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_100760();
					}
					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_100731(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_100760();
					}
					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_100731(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_100760();
					}
					LA44: ;
					i = j;
				}
				break;
				default:
				{
					invalidformatstring_100760();
				}
				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;
	TY165566 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_97773;
		NI HEX3Atmp_97775;
		NI res_97778;
		i_97773 = 0;
		HEX3Atmp_97775 = 0;
		HEX3Atmp_97775 = (NI)(((NI) (count)) - ((NI) 1));
		res_97778 = ((NI) 0);
		{
			while (1) {
				if (!(res_97778 <= ((NI) (HEX3Atmp_97775)))) goto LA3;
				i_97773 = ((NI) (res_97778));
				result->data[i_97773] = c;
				res_97778 += ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Tcell46346* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_49846(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Tcell46346* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_49846((*dest));
		{
			(*c).refcount -= ((NI) 8);
			if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA11;
			rtladdzct_51404(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;
		Valueerror3449* e_97544;
		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_97544 = 0;
		e_97544 = (Valueerror3449*) newObj((&NTI22401), sizeof(Valueerror3449));
		(*e_97544).Sup.Sup.m_type = (&NTI3449);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 15);
appendString(LOC7, ((NimStringDesc*) &TMP996));
appendString(LOC7, s);
		asgnRefNoCycle((void**) (&(*e_97544).Sup.message), LOC7);
		raiseException((Exception*)e_97544, "ValueError");
	}
	LA5: ;
	return result;
}

N_NIMCALL(NI64, nsuParseBiggestInt)(NimStringDesc* s) {
	NI64 result;
	NI L;
	result = 0;
	L = npuParseBiggestInt(s, (&result), ((NI) 0));
	{
		NIM_BOOL LOC3;
		Valueerror3449* e_97519;
		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_97519 = 0;
		e_97519 = (Valueerror3449*) newObj((&NTI22401), sizeof(Valueerror3449));
		(*e_97519).Sup.Sup.m_type = (&NTI3449);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &TMP1140));
appendString(LOC7, s);
		asgnRefNoCycle((void**) (&(*e_97519).Sup.message), LOC7);
		raiseException((Exception*)e_97519, "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_99024;
		NI HEX3Atmp_99026;
		NI res_99029;
		i_99024 = 0;
		HEX3Atmp_99026 = 0;
		HEX3Atmp_99026 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_99029 = ((NI) (start));
		{
			while (1) {
				if (!(res_99029 <= HEX3Atmp_99026)) goto LA3;
				i_99024 = res_99029;
				{
					if (!((NU8)(sub) == (NU8)(s->data[i_99024]))) goto LA6;
					result = i_99024;
					goto BeforeRet;
				}
				LA6: ;
				res_99029 += ((NI) 1);
			} LA3: ;
		}
	}
	result = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len) {
	NimStringDesc* result;
	NI64 n;
	result = 0;
	n = x;
	result = mnewString(((NI) (len)));
	{
		NI j_97423;
		NI HEX3Atmp_97426;
		NI res_97429;
		j_97423 = 0;
		HEX3Atmp_97426 = 0;
		HEX3Atmp_97426 = (NI)(((NI) (len)) - ((NI) 1));
		res_97429 = ((NI) (HEX3Atmp_97426));
		{
			while (1) {
				if (!(((NI) 0) <= res_97429)) goto LA3;
				j_97423 = ((NI) (res_97429));
				result->data[j_97423] = ((NimStringDesc*) &TMP1292)->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_97429 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(void, preprocesssub_98727)(NimStringDesc* sub, NI* a) {
	NI m;
	m = (sub ? sub->Sup.len : 0);
	{
		NI i_98744;
		NI res_98759;
		i_98744 = 0;
		res_98759 = ((NI) 0);
		{
			while (1) {
				if (!(res_98759 <= ((NI) 255))) goto LA3;
				i_98744 = res_98759;
				a[(((NU8)(((NIM_CHAR) (((NI) (i_98744)))))))- 0] = (NI)(m + ((NI) 1));
				res_98759 += ((NI) 1);
			} LA3: ;
		}
	}
	{
		NI i_98755;
		NI HEX3Atmp_98764;
		NI res_98767;
		i_98755 = 0;
		HEX3Atmp_98764 = 0;
		HEX3Atmp_98764 = (NI)(m - ((NI) 1));
		res_98767 = ((NI) 0);
		{
			while (1) {
				if (!(res_98767 <= HEX3Atmp_98764)) goto LA6;
				i_98755 = res_98767;
				a[(((NU8)(sub->data[i_98755])))- 0] = (NI)(m - i_98755);
				res_98767 += ((NI) 1);
			} LA6: ;
		}
	}
}

N_NIMCALL(NI, findaux_98795)(NimStringDesc* s, NimStringDesc* sub, NI start, Skiptable98721 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_98816;
					NI HEX3Atmp_98828;
					NI res_98831;
					k_98816 = 0;
					HEX3Atmp_98828 = 0;
					HEX3Atmp_98828 = (NI)(m - ((NI) 1));
					res_98831 = ((NI) 0);
					{
						while (1) {
							if (!(res_98831 <= HEX3Atmp_98828)) goto LA6;
							k_98816 = res_98831;
							{
								if (!!(((NU8)(sub->data[k_98816]) == (NU8)(s->data[(NI)(k_98816 + j)])))) goto LA9;
								goto LA3;
							}
							LA9: ;
							res_98831 += ((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;
	Skiptable98721 a;
	NI i;
	NimStringDesc* LOC8;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP1294));
	preprocesssub_98727(sub, a);
	i = ((NI) 0);
	{
		while (1) {
			NI j;
			NimStringDesc* LOC7;
			j = findaux_98795(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_100013;
		NI HEX3Atmp_100025;
		NI res_100028;
		j_100013 = 0;
		HEX3Atmp_100025 = 0;
		HEX3Atmp_100025 = (NI)(((NI) (len)) - ((NI) 1));
		res_100028 = ((NI) (HEX3Atmp_100025));
		{
			while (1) {
				if (!(((NI) 0) <= res_100028)) goto LA3;
				j_100013 = ((NI) (res_100028));
				result->data[j_100013] = ((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_100028 -= ((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_99813;
		NI HEX3Atmp_99825;
		NI res_99828;
		j_99813 = 0;
		HEX3Atmp_99825 = 0;
		HEX3Atmp_99825 = (NI)(((NI) (len)) - ((NI) 1));
		res_99828 = ((NI) (HEX3Atmp_99825));
		{
			while (1) {
				if (!(((NI) 0) <= res_99828)) goto LA3;
				j_99813 = ((NI) (res_99828));
				result->data[j_99813] = ((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_99828 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY179407 chars, NI start) {
	NI result;
{	result = 0;
	{
		NI i_99065;
		NI HEX3Atmp_99077;
		NI res_99080;
		i_99065 = 0;
		HEX3Atmp_99077 = 0;
		HEX3Atmp_99077 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_99080 = ((NI) (start));
		{
			while (1) {
				if (!(res_99080 <= HEX3Atmp_99077)) goto LA3;
				i_99065 = res_99080;
				{
					if (!((chars[((NU8)(s->data[i_99065]))/8] &(1<<(((NU8)(s->data[i_99065]))%8)))!=0)) goto LA6;
					result = i_99065;
					goto BeforeRet;
				}
				LA6: ;
				res_99080 += ((NI) 1);
			} LA3: ;
		}
	}
	result = ((NI) -1);
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, contains_99373)(NimStringDesc* s, TY179407 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) {
	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 (!(((NU8)(s->data[first])) == ((NU8)(32)) || ((NU8)(s->data[first])) == ((NU8)(9)) || ((NU8)(s->data[first])) == ((NU8)(11)) || ((NU8)(s->data[first])) == ((NU8)(13)) || ((NU8)(s->data[first])) == ((NU8)(10)) || ((NU8)(s->data[first])) == ((NU8)(12)))) 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 = (((NU8)(s->data[last])) == ((NU8)(32)) || ((NU8)(s->data[last])) == ((NU8)(9)) || ((NU8)(s->data[last])) == ((NU8)(11)) || ((NU8)(s->data[last])) == ((NU8)(13)) || ((NU8)(s->data[last])) == ((NU8)(10)) || ((NU8)(s->data[last])) == ((NU8)(12)));
				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;
		Valueerror3449* e_97494;
		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_97494 = 0;
		e_97494 = (Valueerror3449*) newObj((&NTI22401), sizeof(Valueerror3449));
		(*e_97494).Sup.Sup.m_type = (&NTI3449);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &TMP1140));
appendString(LOC7, s);
		asgnRefNoCycle((void**) (&(*e_97494).Sup.message), LOC7);
		raiseException((Exception*)e_97494, "ValueError");
	}
	LA5: ;
	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_96226;
		NI HEX3Atmp_96284;
		NI res_96287;
		i_96226 = 0;
		HEX3Atmp_96284 = 0;
		HEX3Atmp_96284 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_96287 = ((NI) 0);
		{
			while (1) {
				if (!(res_96287 <= HEX3Atmp_96284)) goto LA3;
				i_96226 = res_96287;
				{
					if (!(((NU8)(s->data[i_96226])) >= ((NU8)(65)) && ((NU8)(s->data[i_96226])) <= ((NU8)(90)))) goto LA6;
					result->data[j] = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(s->data[i_96226])))) + ((NI) 32))))));
					j += ((NI) 1);
				}
				goto LA4;
				LA6: ;
				{
					if (!!(((NU8)(s->data[i_96226]) == (NU8)(95)))) goto LA9;
					result->data[j] = s->data[i_96226];
					j += ((NI) 1);
				}
				goto LA4;
				LA9: ;
				LA4: ;
				res_96287 += ((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_96091;
		NI HEX3Atmp_96093;
		NI res_96096;
		i_96091 = 0;
		HEX3Atmp_96093 = 0;
		HEX3Atmp_96093 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_96096 = ((NI) 0);
		{
			while (1) {
				if (!(res_96096 <= HEX3Atmp_96093)) goto LA3;
				i_96091 = res_96096;
				result->data[i_96091] = nsuToLowerChar(s->data[i_96091]);
				res_96096 += ((NI) 1);
			} LA3: ;
		}
	}
	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*, quoteifcontainswhite_99340)(NimStringDesc* s) {
	NimStringDesc* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		NI LOC4;
		NimStringDesc* LOC8;
		LOC3 = 0;
		LOC4 = 0;
		LOC4 = nsuFindCharSet(s, TMP1538, ((NI) 0));
		LOC3 = (((NI) 0) <= LOC4);
		if (!(LOC3)) goto LA5;
		LOC3 = !(((NU8)(s->data[((NI) 0)]) == (NU8)(34)));
		LA5: ;
		if (!LOC3) goto LA6;
		LOC8 = 0;
		LOC8 = rawNewString(s->Sup.len + 2);
appendChar(LOC8, 34);
appendString(LOC8, s);
appendChar(LOC8, 34);
		result = LOC8;
	}
	goto LA1;
	LA6: ;
	{
		result = copyString(s);
	}
	LA1: ;
	return result;
}

N_NIMCALL(NIM_BOOL, contains_99351)(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_98459)(NimStringDesc* s, TY179407 theset) {
	NIM_BOOL result;
{	result = 0;
	{
		NIM_CHAR c_98465;
		NI i_98479;
		NI L_98481;
		c_98465 = 0;
		i_98479 = ((NI) 0);
		L_98481 = (s ? s->Sup.len : 0);
		{
			while (1) {
				if (!(i_98479 < L_98481)) goto LA3;
				c_98465 = s->data[i_98479];
				{
					if (!!(((theset[((NU8)(c_98465))/8] &(1<<(((NU8)(c_98465))%8)))!=0))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				i_98479 += ((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_98659;
			NI HEX3Atmp_98681;
			NI res_98684;
			i_98659 = 0;
			HEX3Atmp_98681 = 0;
			HEX3Atmp_98681 = (aLen0-1);
			res_98684 = ((NI) 0);
			{
				while (1) {
					if (!(res_98684 <= HEX3Atmp_98681)) goto LA7;
					i_98659 = res_98684;
					L += (a[i_98659] ? a[i_98659]->Sup.len : 0);
					res_98684 += ((NI) 1);
				} LA7: ;
			}
		}
		result = rawNewString(((NI) (L)));
		{
			NI i_98679;
			NI HEX3Atmp_98689;
			NI res_98692;
			i_98679 = 0;
			HEX3Atmp_98689 = 0;
			HEX3Atmp_98689 = (aLen0-1);
			res_98692 = ((NI) 0);
			{
				while (1) {
					if (!(res_98692 <= HEX3Atmp_98689)) goto LA10;
					i_98679 = res_98692;
					result = resizeString(result, a[i_98679]->Sup.len + 0);
appendString(result, a[i_98679]);
					res_98692 += ((NI) 1);
				} LA10: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1294));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NI, nsuFindStr)(NimStringDesc* s, NimStringDesc* sub, NI start) {
	NI result;
	Skiptable98721 a;
	result = 0;
	preprocesssub_98727(sub, a);
	result = findaux_98795(s, sub, ((NI) (start)), a);
	return result;
}

N_NIMCALL(TY122008*, nsuSplitChar)(NimStringDesc* s, NIM_CHAR sep) {
	TY122008* result;
	result = 0;
	result = (TY122008*) newSeq((&NTI122008), 0);
	{
		NimStringDesc* x_97158;
		NI last_97189;
		x_97158 = 0;
		last_97189 = ((NI) 0);
		{
			if (!(((NI) 0) < (s ? s->Sup.len : 0))) goto LA4;
			{
				while (1) {
					NI first_97191;
					NimStringDesc* LOC12;
					if (!(last_97189 <= (s ? s->Sup.len : 0))) goto LA7;
					first_97191 = last_97189;
					{
						while (1) {
							NIM_BOOL LOC10;
							LOC10 = 0;
							LOC10 = (last_97189 < (s ? s->Sup.len : 0));
							if (!(LOC10)) goto LA11;
							LOC10 = !(((NU8)(s->data[last_97189]) == (NU8)(sep)));
							LA11: ;
							if (!LOC10) goto LA9;
							last_97189 += ((NI) 1);
						} LA9: ;
					}
					x_97158 = copyStrLast(s, first_97191, (NI)(last_97189 - ((NI) 1)));
					result = (TY122008*) incrSeq(&(result)->Sup, sizeof(NimStringDesc*));
					LOC12 = 0;
					LOC12 = result->data[result->Sup.len-1]; result->data[result->Sup.len-1] = copyStringRC1(x_97158);
					if (LOC12) nimGCunrefNoCycle(LOC12);
					last_97189 += ((NI) 1);
				} LA7: ;
			}
		}
		LA4: ;
	}
	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_100131;
		NI i_100143;
		NI L_100145;
		c_100131 = 0;
		i_100143 = ((NI) 0);
		L_100145 = (s ? s->Sup.len : 0);
		{
			while (1) {
				if (!(i_100143 < L_100145)) goto LA3;
				c_100131 = s->data[i_100143];
				switch (((NU8)(c_100131))) {
				case 0 ... 31:
				case 128 ... 255:
				{
					NimStringDesc* LOC5;
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2089));
					LOC5 = 0;
					LOC5 = nsuToHex(((NI64) (((NU8)(c_100131)))), ((NI) 2));
					result = resizeString(result, LOC5->Sup.len + 0);
appendString(result, LOC5);
				}
				break;
				case 92:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2090));
				}
				break;
				case 39:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2091));
				}
				break;
				case 34:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2092));
				}
				break;
				default:
				{
					result = addChar(result, c_100131);
				}
				break;
				}
				i_100143 += ((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;
}

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_98575;
			NI HEX3Atmp_98597;
			NI res_98600;
			i_98575 = 0;
			HEX3Atmp_98597 = 0;
			HEX3Atmp_98597 = (aLen0-1);
			res_98600 = ((NI) 0);
			{
				while (1) {
					if (!(res_98600 <= HEX3Atmp_98597)) goto LA7;
					i_98575 = res_98600;
					L += (a[i_98575] ? a[i_98575]->Sup.len : 0);
					res_98600 += ((NI) 1);
				} LA7: ;
			}
		}
		result = rawNewString(((NI) (L)));
		result = resizeString(result, a[((NI) 0)]->Sup.len + 0);
appendString(result, a[((NI) 0)]);
		{
			NI i_98595;
			NI HEX3Atmp_98605;
			NI res_98608;
			i_98595 = 0;
			HEX3Atmp_98605 = 0;
			HEX3Atmp_98605 = (aLen0-1);
			res_98608 = ((NI) 1);
			{
				while (1) {
					if (!(res_98608 <= HEX3Atmp_98605)) goto LA10;
					i_98595 = res_98608;
					result = resizeString(result, sep->Sup.len + 0);
appendString(result, sep);
					result = resizeString(result, a[i_98595]->Sup.len + 0);
appendString(result, a[i_98595]);
					res_98608 += ((NI) 1);
				} LA10: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1294));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuIntToStr)(NI x, NI minchars) {
	NimStringDesc* result;
	result = 0;
	result = nimIntToStr((x > 0? (x) : -(x)));
	{
		NI i_97462;
		NI HEX3Atmp_97464;
		NI res_97467;
		i_97462 = 0;
		HEX3Atmp_97464 = 0;
		HEX3Atmp_97464 = (NI)(((NI) (minchars)) - (result ? result->Sup.len : 0));
		res_97467 = ((NI) 1);
		{
			while (1) {
				NimStringDesc* LOC4;
				if (!(res_97467 <= HEX3Atmp_97464)) goto LA3;
				i_97462 = res_97467;
				LOC4 = 0;
				LOC4 = rawNewString(result->Sup.len + 1);
appendChar(LOC4, 48);
appendString(LOC4, result);
				result = LOC4;
				res_97467 += ((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_98023;
		NI res_98027;
		i_98023 = 0;
		res_98027 = ((NI) 1);
		{
			while (1) {
				if (!(res_98027 <= ((NI) (n)))) goto LA3;
				i_98023 = ((NI) (res_98027));
				result = resizeString(result, s->Sup.len + 0);
appendString(result, s);
				res_98027 += ((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(NimStringDesc*, nsuformatBiggestFloat)(NF f, NU8 format, NI precision) {
	NimStringDesc* result;
	TY100669 frmtstr;
	TY100672 buf;
	result = 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_100663[(format)- 0];
		frmtstr[(((NI) 5))- 0] = 0;
		sprintf(((NCSTRING) (buf)), ((NCSTRING) (frmtstr)), precision, f);
	}
	goto LA1;
	LA3: ;
	{
		frmtstr[(((NI) 1))- 0] = floatformattochar_100663[(format)- 0];
		frmtstr[(((NI) 2))- 0] = 0;
		sprintf(((NCSTRING) (buf)), ((NCSTRING) (frmtstr)), f);
	}
	LA1: ;
	result = cstrToNimstr(((NCSTRING) (buf)));
	return result;
}

N_NIMCALL(NimStringDesc*, nsuformatFloat)(NF f, NU8 format, NI precision) {
	NimStringDesc* result;
	result = 0;
	result = nsuformatBiggestFloat(f, format, precision);
	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_100074;
		NI HEX3Atmp_100103;
		NI res_100106;
		i_100074 = 0;
		HEX3Atmp_100103 = 0;
		HEX3Atmp_100103 = (NI)((s ? s->Sup.len : 0) - ((NI) 1));
		res_100106 = HEX3Atmp_100103;
		{
			while (1) {
				if (!(((NI) 0) <= res_100106)) goto LA3;
				i_100074 = res_100106;
				{
					if (!(j == digits)) goto LA6;
					result->data[L] = sep;
					L -= ((NI) 1);
					j = ((NI) 0);
				}
				LA6: ;
				result->data[L] = s->data[i_100074];
				j += ((NI) 1);
				L -= ((NI) 1);
				res_100106 -= ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NimStringDesc*, formatsize_100697)(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_100720;
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		NimStringDesc* LOC8;
		if (!!((gigabytes == IL64(0)))) goto LA3;
		bs_100720 = nimInt64ToStr(megabytes);
		LOC5 = 0;
		LOC6 = 0;
		LOC6 = nimInt64ToStr(gigabytes);
		LOC7 = 0;
		LOC7 = nsuInsertSep(LOC6, 95, ((NI) 3));
		LOC8 = 0;
		LOC8 = copyStrLast(bs_100720, ((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*) &TMP5008));
		result = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* bs_100722;
		NimStringDesc* LOC12;
		NimStringDesc* LOC13;
		NimStringDesc* LOC14;
		NimStringDesc* LOC15;
		if (!!((megabytes == IL64(0)))) goto LA10;
		bs_100722 = nimInt64ToStr(kilobytes);
		LOC12 = 0;
		LOC13 = 0;
		LOC13 = nimInt64ToStr(megabytes);
		LOC14 = 0;
		LOC14 = nsuInsertSep(LOC13, 95, ((NI) 3));
		LOC15 = 0;
		LOC15 = copyStrLast(bs_100722, ((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*) &TMP5009));
		result = LOC12;
	}
	goto LA1;
	LA10: ;
	{
		NimStringDesc* bs_100724;
		NimStringDesc* LOC19;
		NimStringDesc* LOC20;
		NimStringDesc* LOC21;
		NimStringDesc* LOC22;
		if (!!((kilobytes == IL64(0)))) goto LA17;
		bs_100724 = nimInt64ToStr(bytes);
		LOC19 = 0;
		LOC20 = 0;
		LOC20 = nimInt64ToStr(kilobytes);
		LOC21 = 0;
		LOC21 = nsuInsertSep(LOC20, 95, ((NI) 3));
		LOC22 = 0;
		LOC22 = copyStrLast(bs_100724, ((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*) &TMP5010));
		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*) &TMP5011));
		result = LOC24;
	}
	LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_strutilsInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, stdlib_strutilsDatInit)(void) {
NTI98721.size = sizeof(Skiptable98721);
NTI98721.kind = 16;
NTI98721.base = (&NTI108);
NTI98721.flags = 3;
}

