/* Generated by Nim Compiler v0.10.2 */
/*   (c) 2014 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 valueerror3249 valueerror3249;
typedef struct Exception Exception;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell44935 tcell44935;
typedef struct tcellseq44951 tcellseq44951;
typedef struct tgcheap47016 tgcheap47016;
typedef struct tcellset44947 tcellset44947;
typedef struct tpagedesc44943 tpagedesc44943;
typedef struct tmemregion27210 tmemregion27210;
typedef struct tsmallchunk26440 tsmallchunk26440;
typedef struct tllchunk27204 tllchunk27204;
typedef struct tbigchunk26442 tbigchunk26442;
typedef struct tintset26417 tintset26417;
typedef struct ttrunk26413 ttrunk26413;
typedef struct tavlnode27208 tavlnode27208;
typedef struct tgcstat47014 tgcstat47014;
typedef struct TY119808 TY119808;
typedef struct tbasechunk26438 tbasechunk26438;
typedef struct tfreecell26430 tfreecell26430;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY3089) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3094) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3089 marker;
TY3094 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Exception  {
  TNimObject Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  valueerror3249  {
  Exception Sup;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  tcell44935  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq44951  {
NI Len;
NI Cap;
tcell44935** D;
};
struct  tcellset44947  {
NI Counter;
NI Max;
tpagedesc44943* Head;
tpagedesc44943** Data;
};
typedef tsmallchunk26440* TY27222[512];
typedef ttrunk26413* ttrunkbuckets26415[256];
struct  tintset26417  {
ttrunkbuckets26415 Data;
};
struct  tmemregion27210  {
NI Minlargeobj;
NI Maxlargeobj;
TY27222 Freesmallchunks;
tllchunk27204* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk26442* Freechunkslist;
tintset26417 Chunkstarts;
tavlnode27208* Root;
tavlnode27208* Deleted;
tavlnode27208* Last;
tavlnode27208* Freeavlnodes;
};
struct  tgcstat47014  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap47016  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq44951 Zct;
tcellseq44951 Decstack;
tcellset44947 Cycleroots;
tcellseq44951 Tempstack;
NI Recgclock;
tmemregion27210 Region;
tgcstat47014 Stat;
};
typedef NimStringDesc* TY197301[1];
typedef NI skiptable96742[256];
typedef NU8 TY211607[32];
typedef NIM_CHAR TY98576[6];
typedef NIM_CHAR TY98579[2501];
typedef NIM_CHAR TY98571[3];
typedef NI TY26420[8];
struct  tpagedesc44943  {
tpagedesc44943* Next;
NI Key;
TY26420 Bits;
};
struct  tbasechunk26438  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk26440  {
  tbasechunk26438 Sup;
tsmallchunk26440* Next;
tsmallchunk26440* Prev;
tfreecell26430* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk27204  {
NI Size;
NI Acc;
tllchunk27204* Next;
};
struct  tbigchunk26442  {
  tbasechunk26438 Sup;
tbigchunk26442* Next;
tbigchunk26442* Prev;
NI Align;
NF Data;
};
struct  ttrunk26413  {
ttrunk26413* Next;
NI Key;
TY26420 Bits;
};
typedef tavlnode27208* TY27214[2];
struct  tavlnode27208  {
TY27214 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tfreecell26430  {
tfreecell26430* Next;
NI Zerofield;
};
struct TY119808 {
  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_98672)(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(tcell44935*, usrtocell_48646)(void* usr);
static N_INLINE(void, rtladdzct_50204)(tcell44935* c);
N_NOINLINE(void, addzct_48617)(tcellseq44951* s, tcell44935* 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_98639)(NimStringDesc* x, NimStringDesc** inarray, NI inarrayLen0);
N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_74828, 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_96748)(NimStringDesc* sub, NI* a);
N_NIMCALL(NI, findaux_96812)(NimStringDesc* s, NimStringDesc* sub, NI start, skiptable96742 a);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY211607 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(TMP151, "invalid format string", 21);
STRING_LITERAL(TMP1064, "invalid float: ", 15);
STRING_LITERAL(TMP1070, "invalid integer: ", 17);
STRING_LITERAL(TMP1217, "0123456789ABCDEF", 16);
STRING_LITERAL(TMP1219, "", 0);
static NIM_CONST TY211607 TMP1566 = {
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(TMP2105, "\\x", 2);
STRING_LITERAL(TMP2106, "\\\\", 2);
STRING_LITERAL(TMP2107, "\\\'", 2);
STRING_LITERAL(TMP2108, "\\\"", 2);
NIM_CONST TY98571 floatformattochar_98570 = {103,
102,
101}
;
STRING_LITERAL(TMP4875, "GB", 2);
STRING_LITERAL(TMP4876, "MB", 2);
STRING_LITERAL(TMP4877, "KB", 2);
STRING_LITERAL(TMP4878, "B", 1);
extern TNimType NTI21401; /* ref ValueError */
extern TNimType NTI3249; /* ValueError */
extern tgcheap47016 gch_47044;
extern TNimType NTI119808; /* seq[string] */
extern TNimType NTI108; /* int */
TNimType NTI96742; /* 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) ((NI64)(((NI) (((NU8)(c)))) + 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 = 0;
	j = 0;
	{
		while (1) {
			NIM_CHAR aa;
			NIM_CHAR bb;
			{
				while (1) {
					if (!((NU8)(a->data[i]) == (NU8)(95))) goto LA4;
					i += 1;
				} LA4: ;
			}
			{
				while (1) {
					if (!((NU8)(b->data[j]) == (NU8)(95))) goto LA6;
					j += 1;
				} LA6: ;
			}
			aa = nsuToLowerChar(a->data[i]);
			bb = nsuToLowerChar(b->data[j]);
			result = (NI64)(((NI) (((NU8)(aa)))) - ((NI) (((NU8)(bb)))));
			{
				NIM_BOOL LOC9;
				LOC9 = 0;
				LOC9 = !((result == 0));
				if (LOC9) goto LA10;
				LOC9 = ((NU8)(aa) == (NU8)(0));
				LA10: ;
				if (!LOC9) goto LA11;
				goto LA1;
			}
			LA11: ;
			i += 1;
			j += 1;
		}
	} LA1: ;
	return result;
}

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

static N_INLINE(tcell44935*, usrtocell_48646)(void* usr) {
	tcell44935* result;
	result = 0;
	result = ((tcell44935*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(tcell44935))))));
	return result;
}

static N_INLINE(void, rtladdzct_50204)(tcell44935* c) {
	addzct_48617((&gch_47044.Zct), c);
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tcell44935* c;
	c = usrtocell_48646(p);
	{
		(*c).Refcount -= 8;
		if (!((NU64)((*c).Refcount) < (NU64)(8))) goto LA3;
		rtladdzct_50204(c);
	}
	LA3: ;
}

N_NOINLINE(void, invalidformatstring_98672)(void) {
	valueerror3249* e_98676;
	NimStringDesc* LOC1;
	e_98676 = 0;
	e_98676 = (valueerror3249*) newObj((&NTI21401), sizeof(valueerror3249));
	(*e_98676).Sup.Sup.m_type = (&NTI3249);
	LOC1 = 0;
	LOC1 = (*e_98676).Sup.message; (*e_98676).Sup.message = copyStringRC1(((NimStringDesc*) &TMP151));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	raiseException((Exception*)e_98676, "ValueError");
}

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

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

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

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

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

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

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		tcell44935* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_48646(src);
		(*c).Refcount += 8;
	}
	LA3: ;
	{
		tcell44935* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_48646((*dest));
		{
			(*c).Refcount -= 8;
			if (!((NU64)((*c).Refcount) < (NU64)(8))) goto LA11;
			rtladdzct_50204(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

N_NIMCALL(NF, nsuParseFloat)(NimStringDesc* s) {
	NF result;
	NI l;
	result = 0;
	l = npuParseFloat(s, (&result), 0);
	{
		NIM_BOOL LOC3;
		valueerror3249* e_95723;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = !((l == s->Sup.len));
		if (LOC3) goto LA4;
		LOC3 = (l == 0);
		LA4: ;
		if (!LOC3) goto LA5;
		e_95723 = 0;
		e_95723 = (valueerror3249*) newObj((&NTI21401), sizeof(valueerror3249));
		(*e_95723).Sup.Sup.m_type = (&NTI3249);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 15);
appendString(LOC7, ((NimStringDesc*) &TMP1064));
appendString(LOC7, s);
		asgnRefNoCycle((void**) (&(*e_95723).Sup.message), LOC7);
		raiseException((Exception*)e_95723, "ValueError");
	}
	LA5: ;
	return result;
}

N_NIMCALL(NI64, nsuParseBiggestInt)(NimStringDesc* s) {
	NI64 result;
	NI l;
	result = 0;
	l = npuParseBiggestInt(s, (&result), 0);
	{
		NIM_BOOL LOC3;
		valueerror3249* e_95690;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = !((l == s->Sup.len));
		if (LOC3) goto LA4;
		LOC3 = (l == 0);
		LA4: ;
		if (!LOC3) goto LA5;
		e_95690 = 0;
		e_95690 = (valueerror3249*) newObj((&NTI21401), sizeof(valueerror3249));
		(*e_95690).Sup.Sup.m_type = (&NTI3249);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &TMP1070));
appendString(LOC7, s);
		asgnRefNoCycle((void**) (&(*e_95690).Sup.message), LOC7);
		raiseException((Exception*)e_95690, "ValueError");
	}
	LA5: ;
	return result;
}

N_NIMCALL(NIM_BOOL, nsuStartsWith)(NimStringDesc* s, NimStringDesc* prefix) {
	NIM_BOOL result;
	NI i;
	result = 0;
	i = 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 += 1;
		}
	}
	BeforeRet: ;
	return result;
}

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

N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len) {
	NimStringDesc* result;
	NI64 shift;
	result = 0;
	shift = 0;
	result = mnewString(len);
	{
		NI j_95588;
		NI HEX3Atmp_95592;
		NI res_95595;
		j_95588 = 0;
		HEX3Atmp_95592 = 0;
		HEX3Atmp_95592 = (NI64)(len - 1);
		res_95595 = HEX3Atmp_95592;
		{
			while (1) {
				if (!(0 <= res_95595)) goto LA3;
				j_95588 = res_95595;
				result->data[j_95588] = ((NimStringDesc*) &TMP1217)->data[(NI32)(((NI32)(NU32)(NU64)((NI64)((NU64)(x) >> (NU64)(shift)))) & ((NI32) 15))];
				shift = (NI64)(shift + IL64(4));
				res_95595 -= 1;
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(void, preprocesssub_96748)(NimStringDesc* sub, NI* a) {
	NI m;
	m = sub->Sup.len;
	{
		NI i_96765;
		NI res_96780;
		i_96765 = 0;
		res_96780 = 0;
		{
			while (1) {
				if (!(res_96780 <= 255)) goto LA3;
				i_96765 = res_96780;
				a[(((NU8)(((NIM_CHAR) (((NI) (i_96765)))))))- 0] = (NI64)(m + 1);
				res_96780 += 1;
			} LA3: ;
		}
	}
	{
		NI i_96776;
		NI HEX3Atmp_96783;
		NI res_96786;
		i_96776 = 0;
		HEX3Atmp_96783 = 0;
		HEX3Atmp_96783 = (NI64)(m - 1);
		res_96786 = 0;
		{
			while (1) {
				if (!(res_96786 <= HEX3Atmp_96783)) goto LA6;
				i_96776 = res_96786;
				a[(((NU8)(sub->data[i_96776])))- 0] = (NI64)(m - i_96776);
				res_96786 += 1;
			} LA6: ;
		}
	}
}

N_NIMCALL(NI, findaux_96812)(NimStringDesc* s, NimStringDesc* sub, NI start, skiptable96742 a) {
	NI result;
	NI m;
	NI n;
	NI j;
	result = 0;
	m = sub->Sup.len;
	n = s->Sup.len;
	j = start;
	{
		while (1) {
			if (!(j <= (NI64)(n - m))) goto LA2;
			{
				{
					NI k_96833;
					NI HEX3Atmp_96848;
					NI res_96851;
					k_96833 = 0;
					HEX3Atmp_96848 = 0;
					HEX3Atmp_96848 = (NI64)(m - 1);
					res_96851 = 0;
					{
						while (1) {
							if (!(res_96851 <= HEX3Atmp_96848)) goto LA6;
							k_96833 = res_96851;
							{
								if (!!(((NU8)(sub->data[k_96833]) == (NU8)(s->data[(NI64)(k_96833 + j)])))) goto LA9;
								goto LA3;
							}
							LA9: ;
							res_96851 += 1;
						} LA6: ;
					}
				}
				result = j;
				goto BeforeRet;
			} LA3: ;
			j += a[(((NU8)(s->data[(NI64)(j + m)])))- 0];
		} LA2: ;
	}
	result = -1;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuReplaceStr)(NimStringDesc* s, NimStringDesc* sub, NimStringDesc* by) {
	NimStringDesc* result;
	skiptable96742 a;
	NI i;
	NimStringDesc* LOC8;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP1219));
	preprocesssub_96748(sub, a);
	i = 0;
	{
		while (1) {
			NI j;
			NimStringDesc* LOC7;
			j = findaux_96812(s, sub, i, a);
			{
				if (!(j < 0)) goto LA5;
				goto LA1;
			}
			LA5: ;
			LOC7 = 0;
			LOC7 = copyStrLast(s, i, (NI64)(j - 1));
			result = resizeString(result, LOC7->Sup.len + 0);
appendString(result, LOC7);
			result = resizeString(result, by->Sup.len + 0);
appendString(result, by);
			i = (NI64)(j + sub->Sup.len);
		}
	} 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(len);
	{
		NI j_97812;
		NI HEX3Atmp_97825;
		NI res_97828;
		j_97812 = 0;
		HEX3Atmp_97825 = 0;
		HEX3Atmp_97825 = (NI64)(len - 1);
		res_97828 = HEX3Atmp_97825;
		{
			while (1) {
				if (!(0 <= res_97828)) goto LA3;
				j_97812 = res_97828;
				result->data[j_97812] = ((NIM_CHAR) (((NI) ((NI64)(((NI) ((NI64)((NU64)((NI64)(x & mask)) >> (NU64)(shift)))) + 48)))));
				shift = (NI64)(shift + IL64(1));
				mask = (NI64)((NU64)(mask) << (NU64)(IL64(1)));
				res_97828 -= 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(len);
	{
		NI j_97612;
		NI HEX3Atmp_97625;
		NI res_97628;
		j_97612 = 0;
		HEX3Atmp_97625 = 0;
		HEX3Atmp_97625 = (NI64)(len - 1);
		res_97628 = HEX3Atmp_97625;
		{
			while (1) {
				if (!(0 <= res_97628)) goto LA3;
				j_97612 = res_97628;
				result->data[j_97612] = ((NIM_CHAR) (((NI) ((NI64)(((NI) ((NI64)((NU64)((NI64)(x & mask)) >> (NU64)(shift)))) + 48)))));
				shift = (NI64)(shift + IL64(3));
				mask = (NI64)((NU64)(mask) << (NU64)(IL64(3)));
				res_97628 -= 1;
			} LA3: ;
		}
	}
	return result;
}

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

N_NIMCALL(NIM_BOOL, contains_97267)(NimStringDesc* s, TY211607 chars) {
	NIM_BOOL result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = nsuFindCharSet(s, chars, 0);
	result = (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 = 0;
	last = (NI64)(s->Sup.len - 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 += 1;
			} LA6: ;
		}
	}
	LA3: ;
	{
		if (!trailing) goto LA9;
		{
			while (1) {
				NIM_BOOL LOC13;
				LOC13 = 0;
				LOC13 = (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 -= 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 = 0;
	m = ((a->Sup.len <= b->Sup.len) ? a->Sup.len : b->Sup.len);
	{
		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 = (NI64)(((NI) (((NU8)(LOC3)))) - ((NI) (((NU8)(LOC4)))));
			{
				if (!!((result == 0))) goto LA7;
				goto BeforeRet;
			}
			LA7: ;
			i += 1;
		} LA2: ;
	}
	result = (NI64)(a->Sup.len - b->Sup.len);
	BeforeRet: ;
	return result;
}

N_NIMCALL(NI, nsuParseInt)(NimStringDesc* s) {
	NI result;
	NI l;
	result = 0;
	l = npuParseInt(s, (&result), 0);
	{
		NIM_BOOL LOC3;
		valueerror3249* e_95657;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = !((l == s->Sup.len));
		if (LOC3) goto LA4;
		LOC3 = (l == 0);
		LA4: ;
		if (!LOC3) goto LA5;
		e_95657 = 0;
		e_95657 = (valueerror3249*) newObj((&NTI21401), sizeof(valueerror3249));
		(*e_95657).Sup.Sup.m_type = (&NTI3249);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &TMP1070));
appendString(LOC7, s);
		asgnRefNoCycle((void**) (&(*e_95657).Sup.message), LOC7);
		raiseException((Exception*)e_95657, "ValueError");
	}
	LA5: ;
	return result;
}

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

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

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

N_NIMCALL(NimStringDesc*, quoteifcontainswhite_97234)(NimStringDesc* s) {
	NimStringDesc* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		NI LOC4;
		NimStringDesc* LOC8;
		LOC3 = 0;
		LOC4 = 0;
		LOC4 = nsuFindCharSet(s, TMP1566, 0);
		LOC3 = (0 <= LOC4);
		if (!(LOC3)) goto LA5;
		LOC3 = !(((NU8)(s->data[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_97245)(NimStringDesc* s, NIM_CHAR c) {
	NIM_BOOL result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = nsuFindChar(s, c, 0);
	result = (0 <= LOC1);
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, allcharsinset_96479)(NimStringDesc* s, TY211607 theset) {
	NIM_BOOL result;
	result = 0;
	{
		NIM_CHAR c_96485;
		NI i_96502;
		NI l_96504;
		c_96485 = 0;
		i_96502 = 0;
		l_96504 = s->Sup.len;
		{
			while (1) {
				if (!(i_96502 < l_96504)) goto LA3;
				c_96485 = s->data[i_96502];
				{
					if (!!(((theset[((NU8)(c_96485))/8] &(1<<(((NU8)(c_96485))%8)))!=0))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				i_96502 += 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 (!(0 < aLen0)) goto LA3;
		l = 0;
		{
			NI i_96681;
			NI HEX3Atmp_96706;
			NI res_96709;
			i_96681 = 0;
			HEX3Atmp_96706 = 0;
			HEX3Atmp_96706 = (aLen0-1);
			res_96709 = 0;
			{
				while (1) {
					if (!(res_96709 <= HEX3Atmp_96706)) goto LA7;
					i_96681 = res_96709;
					l += a[i_96681]->Sup.len;
					res_96709 += 1;
				} LA7: ;
			}
		}
		result = rawNewString(l);
		{
			NI i_96704;
			NI HEX3Atmp_96712;
			NI res_96715;
			i_96704 = 0;
			HEX3Atmp_96712 = 0;
			HEX3Atmp_96712 = (aLen0-1);
			res_96715 = 0;
			{
				while (1) {
					if (!(res_96715 <= HEX3Atmp_96712)) goto LA10;
					i_96704 = res_96715;
					result = resizeString(result, a[i_96704]->Sup.len + 0);
appendString(result, a[i_96704]);
					res_96715 += 1;
				} LA10: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1219));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NI, nsuFindStr)(NimStringDesc* s, NimStringDesc* sub, NI start) {
	NI result;
	skiptable96742 a;
	result = 0;
	preprocesssub_96748(sub, a);
	result = findaux_96812(s, sub, start, a);
	return result;
}

N_NIMCALL(TY119808*, nsuSplitChar)(NimStringDesc* s, NIM_CHAR sep) {
	TY119808* result;
	result = 0;
	result = (TY119808*) newSeq((&NTI119808), 0);
	{
		NimStringDesc* x_95429;
		NI last_95472;
		x_95429 = 0;
		last_95472 = 0;
		{
			if (!(0 < s->Sup.len)) goto LA4;
			{
				while (1) {
					NI first_95474;
					NimStringDesc* LOC12;
					if (!(last_95472 <= s->Sup.len)) goto LA7;
					first_95474 = last_95472;
					{
						while (1) {
							NIM_BOOL LOC10;
							LOC10 = 0;
							LOC10 = (last_95472 < s->Sup.len);
							if (!(LOC10)) goto LA11;
							LOC10 = !(((NU8)(s->data[last_95472]) == (NU8)(sep)));
							LA11: ;
							if (!LOC10) goto LA9;
							last_95472 += 1;
						} LA9: ;
					}
					x_95429 = copyStrLast(s, first_95474, (NI64)(last_95472 - 1));
					result = (TY119808*) incrSeq(&(result)->Sup, sizeof(NimStringDesc*));
					LOC12 = 0;
					LOC12 = result->data[result->Sup.len-1]; result->data[result->Sup.len-1] = copyStringRC1(x_95429);
					if (LOC12) nimGCunrefNoCycle(LOC12);
					last_95472 += 1;
				} LA7: ;
			}
		}
		LA4: ;
	}
	return result;
}

N_NIMCALL(NimStringDesc*, nsuEscape)(NimStringDesc* s, NimStringDesc* prefix, NimStringDesc* suffix) {
	NimStringDesc* result;
	result = 0;
	result = rawNewString((NI64)(s->Sup.len + (NI)((NU64)(s->Sup.len) >> (NU64)(2))));
	result = resizeString(result, prefix->Sup.len + 0);
appendString(result, prefix);
	{
		NIM_CHAR c_97938;
		NI i_97950;
		NI l_97952;
		c_97938 = 0;
		i_97950 = 0;
		l_97952 = s->Sup.len;
		{
			while (1) {
				if (!(i_97950 < l_97952)) goto LA3;
				c_97938 = s->data[i_97950];
				switch (((NU8)(c_97938))) {
				case 0 ... 31:
				case 128 ... 255:
				{
					NimStringDesc* LOC5;
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2105));
					LOC5 = 0;
					LOC5 = nsuToHex(((NI64) (((NU8)(c_97938)))), 2);
					result = resizeString(result, LOC5->Sup.len + 0);
appendString(result, LOC5);
				}
				break;
				case 92:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2106));
				}
				break;
				case 39:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2107));
				}
				break;
				case 34:
				{
					result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP2108));
				}
				break;
				default:
				{
					result = addChar(result, c_97938);
				}
				break;
				}
				i_97950 += 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 = (NI64)(last + 1);
	newlen = (NI64)((NI64)((*s)->Sup.len - j) + i);
	{
		while (1) {
			if (!(i < newlen)) goto LA2;
			(*s)->data[i] = (*s)->data[j];
			i += 1;
			j += 1;
		} LA2: ;
	}
	(*s) = setLengthStr((*s), newlen);
}

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

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

N_NIMCALL(NimStringDesc*, nsuJoinSep)(NimStringDesc** a, NI aLen0, NimStringDesc* sep) {
	NimStringDesc* result;
	result = 0;
	{
		NI l;
		if (!(0 < aLen0)) goto LA3;
		l = (NI64)(sep->Sup.len * (NI64)(aLen0 - 1));
		{
			NI i_96597;
			NI HEX3Atmp_96622;
			NI res_96625;
			i_96597 = 0;
			HEX3Atmp_96622 = 0;
			HEX3Atmp_96622 = (aLen0-1);
			res_96625 = 0;
			{
				while (1) {
					if (!(res_96625 <= HEX3Atmp_96622)) goto LA7;
					i_96597 = res_96625;
					l += a[i_96597]->Sup.len;
					res_96625 += 1;
				} LA7: ;
			}
		}
		result = rawNewString(l);
		result = resizeString(result, a[0]->Sup.len + 0);
appendString(result, a[0]);
		{
			NI i_96620;
			NI HEX3Atmp_96628;
			NI res_96631;
			i_96620 = 0;
			HEX3Atmp_96628 = 0;
			HEX3Atmp_96628 = (aLen0-1);
			res_96631 = 1;
			{
				while (1) {
					if (!(res_96631 <= HEX3Atmp_96628)) goto LA10;
					i_96620 = res_96631;
					result = resizeString(result, sep->Sup.len + 0);
appendString(result, sep);
					result = resizeString(result, a[i_96620]->Sup.len + 0);
appendString(result, a[i_96620]);
					res_96631 += 1;
				} LA10: ;
			}
		}
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1219));
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuIntToStr)(NI x, NI minchars) {
	NimStringDesc* result;
	result = 0;
	result = nimIntToStr((x > 0? (x) : -(x)));
	{
		NI i_95626;
		NI HEX3Atmp_95629;
		NI res_95632;
		i_95626 = 0;
		HEX3Atmp_95629 = 0;
		HEX3Atmp_95629 = (NI64)(minchars - result->Sup.len);
		res_95632 = 1;
		{
			while (1) {
				NimStringDesc* LOC4;
				if (!(res_95632 <= HEX3Atmp_95629)) goto LA3;
				i_95626 = res_95632;
				LOC4 = 0;
				LOC4 = rawNewString(result->Sup.len + 1);
appendChar(LOC4, 48);
appendString(LOC4, result);
				result = LOC4;
				res_95632 += 1;
			} LA3: ;
		}
	}
	{
		NimStringDesc* LOC9;
		if (!(x < 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) ((NI64)(((NI) (((NU8)(c)))) - 32)))));
	}
	goto LA1;
	LA3: ;
	{
		result = c;
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuRepeatStr)(NI count, NimStringDesc* s) {
	NimStringDesc* result;
	result = 0;
	result = rawNewString((NI64)(count * s->Sup.len));
	{
		NI i_96030;
		NI HEX3Atmp_96032;
		NI res_96035;
		i_96030 = 0;
		HEX3Atmp_96032 = 0;
		HEX3Atmp_96032 = (NI64)(count - 1);
		res_96035 = 0;
		{
			while (1) {
				if (!(res_96035 <= HEX3Atmp_96032)) goto LA3;
				i_96030 = res_96035;
				result = resizeString(result, s->Sup.len + 0);
appendString(result, s);
				res_96035 += 1;
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NIM_BOOL, nsuEndsWith)(NimStringDesc* s, NimStringDesc* suffix) {
	NIM_BOOL result;
	NI i;
	NI j;
	result = 0;
	i = 0;
	j = (NI64)(s->Sup.len - suffix->Sup.len);
	{
		while (1) {
			if (!((NU64)((NI64)(i + j)) < (NU64)(s->Sup.len))) goto LA2;
			{
				if (!!(((NU8)(s->data[(NI64)(i + j)]) == (NU8)(suffix->data[i])))) goto LA5;
				result = NIM_FALSE;
				goto BeforeRet;
			}
			LA5: ;
			i += 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;
	TY98576 frmtstr;
	TY98579 buf;
	result = 0;
	frmtstr[(0)- 0] = 37;
	{
		if (!(0 < ((NI) (precision)))) goto LA3;
		frmtstr[(1)- 0] = 35;
		frmtstr[(2)- 0] = 46;
		frmtstr[(3)- 0] = 42;
		frmtstr[(4)- 0] = floatformattochar_98570[(format)- 0];
		frmtstr[(5)- 0] = 0;
		sprintf(((NCSTRING) (buf)), ((NCSTRING) (frmtstr)), precision, f);
	}
	goto LA1;
	LA3: ;
	{
		frmtstr[(1)- 0] = floatformattochar_98570[(format)- 0];
		frmtstr[(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 = (NI64)((NI64)((NI64)(s->Sup.len - 1) / digits) + s->Sup.len);
	result = mnewString(l);
	j = 0;
	l -= 1;
	{
		NI i_97875;
		NI HEX3Atmp_97913;
		NI res_97916;
		i_97875 = 0;
		HEX3Atmp_97913 = 0;
		HEX3Atmp_97913 = (NI64)(s->Sup.len - 1);
		res_97916 = HEX3Atmp_97913;
		{
			while (1) {
				if (!(0 <= res_97916)) goto LA3;
				i_97875 = res_97916;
				{
					if (!(j == digits)) goto LA6;
					result->data[l] = sep;
					l -= 1;
					j = 0;
				}
				LA6: ;
				result->data[l] = s->data[i_97875];
				j += 1;
				l -= 1;
				res_97916 -= 1;
			} LA3: ;
		}
	}
	return result;
}

N_NIMCALL(NimStringDesc*, formatsize_98605)(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_98628;
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		NimStringDesc* LOC8;
		if (!!((gigabytes == IL64(0)))) goto LA3;
		bs_98628 = nimInt64ToStr(megabytes);
		LOC5 = 0;
		LOC6 = 0;
		LOC6 = nimInt64ToStr(gigabytes);
		LOC7 = 0;
		LOC7 = nsuInsertSep(LOC6, 95, 3);
		LOC8 = 0;
		LOC8 = copyStrLast(bs_98628, 0, 2);
		LOC5 = rawNewString(LOC7->Sup.len + LOC8->Sup.len + 3);
appendString(LOC5, LOC7);
appendChar(LOC5, decimalsep);
appendString(LOC5, LOC8);
appendString(LOC5, ((NimStringDesc*) &TMP4875));
		result = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* bs_98630;
		NimStringDesc* LOC12;
		NimStringDesc* LOC13;
		NimStringDesc* LOC14;
		NimStringDesc* LOC15;
		if (!!((megabytes == IL64(0)))) goto LA10;
		bs_98630 = nimInt64ToStr(kilobytes);
		LOC12 = 0;
		LOC13 = 0;
		LOC13 = nimInt64ToStr(megabytes);
		LOC14 = 0;
		LOC14 = nsuInsertSep(LOC13, 95, 3);
		LOC15 = 0;
		LOC15 = copyStrLast(bs_98630, 0, 2);
		LOC12 = rawNewString(LOC14->Sup.len + LOC15->Sup.len + 3);
appendString(LOC12, LOC14);
appendChar(LOC12, decimalsep);
appendString(LOC12, LOC15);
appendString(LOC12, ((NimStringDesc*) &TMP4876));
		result = LOC12;
	}
	goto LA1;
	LA10: ;
	{
		NimStringDesc* bs_98632;
		NimStringDesc* LOC19;
		NimStringDesc* LOC20;
		NimStringDesc* LOC21;
		NimStringDesc* LOC22;
		if (!!((kilobytes == IL64(0)))) goto LA17;
		bs_98632 = nimInt64ToStr(bytes);
		LOC19 = 0;
		LOC20 = 0;
		LOC20 = nimInt64ToStr(kilobytes);
		LOC21 = 0;
		LOC21 = nsuInsertSep(LOC20, 95, 3);
		LOC22 = 0;
		LOC22 = copyStrLast(bs_98632, 0, 2);
		LOC19 = rawNewString(LOC21->Sup.len + LOC22->Sup.len + 3);
appendString(LOC19, LOC21);
appendChar(LOC19, decimalsep);
appendString(LOC19, LOC22);
appendString(LOC19, ((NimStringDesc*) &TMP4877));
		result = LOC19;
	}
	goto LA1;
	LA17: ;
	{
		NimStringDesc* LOC24;
		NimStringDesc* LOC25;
		NimStringDesc* LOC26;
		LOC24 = 0;
		LOC25 = 0;
		LOC25 = nimInt64ToStr(bytes);
		LOC26 = 0;
		LOC26 = nsuInsertSep(LOC25, 95, 3);
		LOC24 = rawNewString(LOC26->Sup.len + 1);
appendString(LOC24, LOC26);
appendString(LOC24, ((NimStringDesc*) &TMP4878));
		result = LOC24;
	}
	LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_strutilsInit)(void) {
}

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

