/* Generated by Nimrod Compiler v0.9.5 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, i386, gcc */
/* Command for C compiler:
   gcc -c  -w -O3 -fno-strict-aliasing  -I/build/nimrod/src/nimrod/lib -o compiler/nimcache/stdlib_strutils.o compiler/nimcache/stdlib_strutils.c */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <string.h>

#include <stdio.h>
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct einvalidvalue2453 einvalidvalue2453;
typedef struct esynch2429 esynch2429;
typedef struct E_Base E_Base;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell41090 tcell41090;
typedef struct tcellseq41106 tcellseq41106;
typedef struct tgcheap43016 tgcheap43016;
typedef struct tcellset41102 tcellset41102;
typedef struct tpagedesc41098 tpagedesc41098;
typedef struct tmemregion23410 tmemregion23410;
typedef struct tsmallchunk22638 tsmallchunk22638;
typedef struct tllchunk23404 tllchunk23404;
typedef struct tbigchunk22640 tbigchunk22640;
typedef struct tintset22615 tintset22615;
typedef struct ttrunk22611 ttrunk22611;
typedef struct tavlnode23408 tavlnode23408;
typedef struct tgcstat43014 tgcstat43014;
typedef struct TY110805 TY110805;
typedef struct tbasechunk22636 tbasechunk22636;
typedef struct tfreecell22628 tfreecell22628;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY2289) (void* p, NI op);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY2289 marker;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  E_Base  {
  TNimObject Sup;
E_Base* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  esynch2429  {
  E_Base Sup;
};
struct  einvalidvalue2453  {
  esynch2429 Sup;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  tcell41090  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq41106  {
NI Len;
NI Cap;
tcell41090** D;
};
struct  tcellset41102  {
NI Counter;
NI Max;
tpagedesc41098* Head;
tpagedesc41098** Data;
};
typedef tsmallchunk22638* TY23422[512];
typedef ttrunk22611* ttrunkbuckets22613[256];
struct  tintset22615  {
ttrunkbuckets22613 Data;
};
struct  tmemregion23410  {
NI Minlargeobj;
NI Maxlargeobj;
TY23422 Freesmallchunks;
tllchunk23404* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk22640* Freechunkslist;
tintset22615 Chunkstarts;
tavlnode23408* Root;
tavlnode23408* Deleted;
tavlnode23408* Last;
tavlnode23408* Freeavlnodes;
};
struct  tgcstat43014  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap43016  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq41106 Zct;
tcellseq41106 Decstack;
tcellset41102 Cycleroots;
tcellseq41106 Tempstack;
NI Recgclock;
tmemregion23410 Region;
tgcstat43014 Stat;
};
typedef NimStringDesc* TY165002[1];
typedef NU8 TY90161[32];
typedef NI tskiptable90032[256];
typedef NIM_CHAR TY91546[6];
typedef NIM_CHAR TY91549[2501];
typedef NIM_CHAR TY91541[3];
typedef NI TY22618[16];
struct  tpagedesc41098  {
tpagedesc41098* Next;
NI Key;
TY22618 Bits;
};
struct  tbasechunk22636  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk22638  {
  tbasechunk22636 Sup;
tsmallchunk22638* Next;
tsmallchunk22638* Prev;
tfreecell22628* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk23404  {
NI Size;
NI Acc;
tllchunk23404* Next;
};
struct  tbigchunk22640  {
  tbasechunk22636 Sup;
tbigchunk22640* Next;
tbigchunk22640* Prev;
NI Align;
NF Data;
};
struct  ttrunk22611  {
ttrunk22611* Next;
NI Key;
TY22618 Bits;
};
typedef tavlnode23408* TY23414[2];
struct  tavlnode23408  {
TY23414 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tfreecell22628  {
tfreecell22628* Next;
NI Zerofield;
};
struct TY110805 {
  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_91624)(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(tcell41090*, usrtocell_44443)(void* usr);
static N_INLINE(void, rtladdzct_46002)(tcell41090* c);
N_NOINLINE(void, addzct_44418)(tcellseq41106* s, tcell41090* c);
N_NIMCALL(void, raiseException)(E_Base* 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_91597)(NimStringDesc* x, NimStringDesc** inarray, NI inarrayLen0);
N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_70624, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newlen);
N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY90161 chars, NI start);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_NIMCALL(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start);
N_NIMCALL(void, preprocesssub_90036)(NimStringDesc* sub, NI* a);
N_NIMCALL(NI, findaux_90076)(NimStringDesc* s, NimStringDesc* sub, NI start, tskiptable90032 a);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI start);
N_NIMCALL(NimStringDesc*, copyStr)(NimStringDesc* s, NI first);
N_NIMCALL(NI, npuParseInt)(NimStringDesc* s, NI* number, NI start);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(NI, npuParseFloat)(NimStringDesc* s, NF* number, NI start);
N_NIMCALL(NI, npuParseBiggestInt)(NimStringDesc* s, NI64* number, NI start);
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);
static NIM_CONST TY90161 TMP1015 = {
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(TMP1282, "", 0);
STRING_LITERAL(TMP1294, "invalid integer: ", 17);
STRING_LITERAL(TMP1405, "invalid float: ", 15);
STRING_LITERAL(TMP1581, "0123456789ABCDEF", 16);
STRING_LITERAL(TMP1982, "\\x", 2);
STRING_LITERAL(TMP1983, "\\\\", 2);
STRING_LITERAL(TMP1984, "\\\'", 2);
STRING_LITERAL(TMP1985, "\\\"", 2);
NIM_CONST TY91541 floatformattochar_91540 = {103,
102,
101}
;
STRING_LITERAL(TMP4548, "GB", 2);
STRING_LITERAL(TMP4549, "MB", 2);
STRING_LITERAL(TMP4550, "KB", 2);
STRING_LITERAL(TMP4551, "B", 1);
extern TNimType NTI17801; /* ref EInvalidValue */
extern TNimType NTI2453; /* EInvalidValue */
extern tgcheap43016 gch_43044;
extern TNimType NTI110805; /* seq[string] */
extern TNimType NTI106; /* int */
TNimType NTI90032; /* TSkipTable */

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) ((NI32)(((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 LA2;
			i += 1;
		} LA2: ;
		while (1) {
			if (!((NU8)(b->data[j]) == (NU8)(95))) goto LA3;
			j += 1;
		} LA3: ;
		aa = nsuToLowerChar(a->data[i]);
		bb = nsuToLowerChar(b->data[j]);
		result = (NI32)(((NI) (((NU8)(aa)))) - ((NI) (((NU8)(bb)))));
		{
			NIM_BOOL LOC6;
			LOC6 = 0;
			LOC6 = !((result == 0));
			if (LOC6) goto LA7;
			LOC6 = ((NU8)(aa) == (NU8)(0));
			LA7: ;
			if (!LOC6) goto LA8;
			goto LA1;
		}
		LA8: ;
		i += 1;
		j += 1;
	} LA1: ;
	return result;
}

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

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

static N_INLINE(void, rtladdzct_46002)(tcell41090* c) {
	addzct_44418(&gch_43044.Zct, c);
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tcell41090* c;
	c = usrtocell_44443(p);
	{
		(*c).Refcount -= 8;
		if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA3;
		rtladdzct_46002(c);
	}
	LA3: ;
}

N_NOINLINE(void, invalidformatstring_91624)(void) {
	einvalidvalue2453* e_91628;
	NimStringDesc* LOC1;
	e_91628 = 0;
	e_91628 = (einvalidvalue2453*) newObj((&NTI17801), sizeof(einvalidvalue2453));
	(*e_91628).Sup.Sup.Sup.m_type = (&NTI2453);
	LOC1 = 0;
	LOC1 = (*e_91628).Sup.Sup.message; (*e_91628).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP151));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	raiseException((E_Base*)e_91628, "EInvalidValue");
}

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

N_NIMCALL(NI, findnormalized_91597)(NimStringDesc* x, NimStringDesc** inarray, NI inarrayLen0) {
	NI result;
	NI i;
	result = 0;
	i = 0;
	while (1) {
		if (!(i < (inarrayLen0-1))) goto LA1;
		{
			NI LOC4;
			LOC4 = 0;
			LOC4 = nsuCmpIgnoreStyle(x, inarray[i]);
			if (!(LOC4 == 0)) goto LA5;
			result = i;
			goto BeforeRet;
		}
		LA5: ;
		i += 2;
	} LA1: ;
	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 LA1;
		{
			if (!((NU8)(formatstr->data[i]) == (NU8)(36))) goto LA4;
			switch (((NU8)(formatstr->data[(NI32)(i + 1)]))) {
			case 35:
			{
				{
					if (!((NU32)((aLen0-1)) < (NU32)(num))) goto LA9;
					invalidformatstring_91624();
				}
				LA9: ;
				(*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 LA15;
					i += 1;
				}
				LA15: ;
				while (1) {
					if (!(((NU8)(formatstr->data[i])) >= ((NU8)(48)) && ((NU8)(formatstr->data[i])) <= ((NU8)(57)))) goto LA17;
					j = (NI32)((NI32)((NI32)(j * 10) + ((NI) (((NU8)(formatstr->data[i]))))) - 48);
					i += 1;
				} LA17: ;
				{
					if (!!(negative)) goto LA20;
					idx = (NI32)(j - 1);
				}
				goto LA18;
				LA20: ;
				{
					idx = (NI32)(aLen0 - j);
				}
				LA18: ;
				{
					if (!((NU32)((aLen0-1)) < (NU32)(idx))) goto LA25;
					invalidformatstring_91624();
				}
				LA25: ;
				(*s) = resizeString((*s), a[idx]->Sup.len + 0);
appendString((*s), a[idx]);
			}
			break;
			case 123:
			{
				NI j;
				NI x;
				NimStringDesc* LOC29;
				j = (NI32)(i + 1);
				while (1) {
					if (!!((((NU8)(formatstr->data[j])) == ((NU8)(0)) || ((NU8)(formatstr->data[j])) == ((NU8)(125))))) goto LA28;
					j += 1;
				} LA28: ;
				LOC29 = 0;
				LOC29 = copyStrLast(formatstr, (NI32)(i + 2), (NI32)(j - 1));
				x = findnormalized_91597(LOC29, a, aLen0);
				{
					NIM_BOOL LOC32;
					LOC32 = 0;
					LOC32 = (0 <= x);
					if (!(LOC32)) goto LA33;
					LOC32 = (x < (aLen0-1));
					LA33: ;
					if (!LOC32) goto LA34;
					(*s) = resizeString((*s), a[(NI32)(x + 1)]->Sup.len + 0);
appendString((*s), a[(NI32)(x + 1)]);
				}
				goto LA30;
				LA34: ;
				{
					invalidformatstring_91624();
				}
				LA30: ;
				i = (NI32)(j + 1);
			}
			break;
			case 97 ... 122:
			case 65 ... 90:
			case 128 ... 255:
			case 95:
			{
				NI j;
				NI x;
				NimStringDesc* LOC39;
				j = (NI32)(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 LA38;
					j += 1;
				} LA38: ;
				LOC39 = 0;
				LOC39 = copyStrLast(formatstr, (NI32)(i + 1), (NI32)(j - 1));
				x = findnormalized_91597(LOC39, a, aLen0);
				{
					NIM_BOOL LOC42;
					LOC42 = 0;
					LOC42 = (0 <= x);
					if (!(LOC42)) goto LA43;
					LOC42 = (x < (aLen0-1));
					LA43: ;
					if (!LOC42) goto LA44;
					(*s) = resizeString((*s), a[(NI32)(x + 1)]->Sup.len + 0);
appendString((*s), a[(NI32)(x + 1)]);
				}
				goto LA40;
				LA44: ;
				{
					invalidformatstring_91624();
				}
				LA40: ;
				i = j;
			}
			break;
			default:
			{
				invalidformatstring_91624();
			}
			break;
			}
		}
		goto LA2;
		LA4: ;
		{
			(*s) = addChar((*s), formatstr->data[i]);
			i += 1;
		}
		LA2: ;
	} LA1: ;
}

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

N_NIMCALL(NimStringDesc*, nsuFormatSingleElem)(NimStringDesc* formatstr, NimStringDesc* a) {
	NimStringDesc* result;
	TY165002 LOC1;
	result = 0;
	result = rawNewString((NI32)(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(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 LOC2;
		NIM_CHAR LOC3;
		if (!(i < m)) goto LA1;
		LOC2 = 0;
		LOC2 = nsuToLowerChar(a->data[i]);
		LOC3 = 0;
		LOC3 = nsuToLowerChar(b->data[i]);
		result = (NI32)(((NI) (((NU8)(LOC2)))) - ((NI) (((NU8)(LOC3)))));
		{
			if (!!((result == 0))) goto LA6;
			goto BeforeRet;
		}
		LA6: ;
		i += 1;
	} LA1: ;
	result = (NI32)(a->Sup.len - b->Sup.len);
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuNormalize)(NimStringDesc* s) {
	NimStringDesc* result;
	NI j;
	NI i_87982;
	NI HEX3Atmp_88056;
	NI res_88058;
	result = 0;
	result = mnewString(s->Sup.len);
	j = 0;
	i_87982 = 0;
	HEX3Atmp_88056 = 0;
	HEX3Atmp_88056 = (NI32)(s->Sup.len - 1);
	res_88058 = 0;
	while (1) {
		if (!(res_88058 <= HEX3Atmp_88056)) goto LA1;
		i_87982 = res_88058;
		{
			if (!(((NU8)(s->data[i_87982])) >= ((NU8)(65)) && ((NU8)(s->data[i_87982])) <= ((NU8)(90)))) goto LA4;
			result->data[j] = ((NIM_CHAR) (((NI) ((NI32)(((NI) (((NU8)(s->data[i_87982])))) + 32)))));
			j += 1;
		}
		goto LA2;
		LA4: ;
		{
			if (!!(((NU8)(s->data[i_87982]) == (NU8)(95)))) goto LA7;
			result->data[j] = s->data[i_87982];
			j += 1;
		}
		goto LA2;
		LA7: ;
		LA2: ;
		res_88058 += 1;
	} LA1: ;
	{
		if (!!((j == s->Sup.len))) goto LA11;
		result = setLengthStr(result, j);
	}
	LA11: ;
	return result;
}

N_NIMCALL(NI, nsuFindCharSet)(NimStringDesc* s, TY90161 chars, NI start) {
	NI result;
	NI i_90175;
	NI HEX3Atmp_90189;
	NI res_90191;
	result = 0;
	i_90175 = 0;
	HEX3Atmp_90189 = 0;
	HEX3Atmp_90189 = (NI32)(s->Sup.len - 1);
	res_90191 = start;
	while (1) {
		if (!(res_90191 <= HEX3Atmp_90189)) goto LA1;
		i_90175 = res_90191;
		{
			if (!((chars[((NU8)(s->data[i_90175]))/8] &(1<<(((NU8)(s->data[i_90175]))%8)))!=0)) goto LA4;
			result = i_90175;
			goto BeforeRet;
		}
		LA4: ;
		res_90191 += 1;
	} LA1: ;
	result = -1;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

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

N_NIMCALL(NimStringDesc*, quoteifcontainswhite_90237)(NimStringDesc* s) {
	NimStringDesc* result;
	result = 0;
	{
		NIM_BOOL LOC3;
		NI LOC4;
		NimStringDesc* LOC8;
		LOC3 = 0;
		LOC4 = 0;
		LOC4 = nsuFindCharSet(s, TMP1015, 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(NI, nsuFindChar)(NimStringDesc* s, NIM_CHAR sub, NI start) {
	NI result;
	NI i_90150;
	NI HEX3Atmp_90151;
	NI res_90153;
	result = 0;
	i_90150 = 0;
	HEX3Atmp_90151 = 0;
	HEX3Atmp_90151 = (NI32)(s->Sup.len - 1);
	res_90153 = start;
	while (1) {
		if (!(res_90153 <= HEX3Atmp_90151)) goto LA1;
		i_90150 = res_90153;
		{
			if (!((NU8)(sub) == (NU8)(s->data[i_90150]))) goto LA4;
			result = i_90150;
			goto BeforeRet;
		}
		LA4: ;
		res_90153 += 1;
	} LA1: ;
	result = -1;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuRepeatChar)(NI count, NIM_CHAR c) {
	NimStringDesc* result;
	NI i_89463;
	NI HEX3Atmp_89464;
	NI res_89466;
	result = 0;
	result = mnewString(count);
	i_89463 = 0;
	HEX3Atmp_89464 = 0;
	HEX3Atmp_89464 = (NI32)(count - 1);
	res_89466 = 0;
	while (1) {
		if (!(res_89466 <= HEX3Atmp_89464)) goto LA1;
		i_89463 = res_89466;
		result->data[i_89463] = c;
		res_89466 += 1;
	} LA1: ;
	return result;
}

N_NIMCALL(NIM_BOOL, contains_90244)(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, nsuStartsWith)(NimStringDesc* s, NimStringDesc* prefix) {
	NIM_BOOL result;
	NI i;
	result = 0;
	i = 0;
	while (1) {
		{
			if (!((NU8)(prefix->data[i]) == (NU8)(0))) goto LA4;
			result = NIM_TRUE;
			goto BeforeRet;
		}
		LA4: ;
		{
			if (!!(((NU8)(s->data[i]) == (NU8)(prefix->data[i])))) goto LA8;
			result = NIM_FALSE;
			goto BeforeRet;
		}
		LA8: ;
		i += 1;
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToLowerStr)(NimStringDesc* s) {
	NimStringDesc* result;
	NI i_87884;
	NI HEX3Atmp_87885;
	NI res_87887;
	result = 0;
	result = mnewString(s->Sup.len);
	i_87884 = 0;
	HEX3Atmp_87885 = 0;
	HEX3Atmp_87885 = (NI32)(s->Sup.len - 1);
	res_87887 = 0;
	while (1) {
		if (!(res_87887 <= HEX3Atmp_87885)) goto LA1;
		i_87884 = res_87887;
		result->data[i_87884] = nsuToLowerChar(s->data[i_87884]);
		res_87887 += 1;
	} LA1: ;
	return result;
}

N_NIMCALL(NIM_BOOL, allcharsinset_89836)(NimStringDesc* s, TY90161 theset) {
	NIM_BOOL result;
	NIM_CHAR c_89841;
	NI i_89856;
	NI l_89858;
	result = 0;
	c_89841 = 0;
	i_89856 = 0;
	l_89858 = s->Sup.len;
	while (1) {
		if (!(i_89856 < l_89858)) goto LA1;
		c_89841 = s->data[i_89856];
		{
			if (!!(((theset[((NU8)(c_89841))/8] &(1<<(((NU8)(c_89841))%8)))!=0))) goto LA4;
			result = NIM_FALSE;
			goto BeforeRet;
		}
		LA4: ;
		i_89856 += 1;
	} LA1: ;
	result = NIM_TRUE;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, preprocesssub_90036)(NimStringDesc* sub, NI* a) {
	NI m;
	NI i_90053;
	NI res_90066;
	NI i_90064;
	NI HEX3Atmp_90068;
	NI res_90070;
	m = sub->Sup.len;
	i_90053 = 0;
	res_90066 = 0;
	while (1) {
		if (!(res_90066 <= 255)) goto LA1;
		i_90053 = res_90066;
		a[(((NU8)(((NIM_CHAR) (((NI) (i_90053)))))))- 0] = (NI32)(m + 1);
		res_90066 += 1;
	} LA1: ;
	i_90064 = 0;
	HEX3Atmp_90068 = 0;
	HEX3Atmp_90068 = (NI32)(m - 1);
	res_90070 = 0;
	while (1) {
		if (!(res_90070 <= HEX3Atmp_90068)) goto LA2;
		i_90064 = res_90070;
		a[(((NU8)(sub->data[i_90064])))- 0] = (NI32)(m - i_90064);
		res_90070 += 1;
	} LA2: ;
}

N_NIMCALL(NI, findaux_90076)(NimStringDesc* s, NimStringDesc* sub, NI start, tskiptable90032 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 <= (NI32)(n - m))) goto LA1;
		{
			NI k_90097;
			NI HEX3Atmp_90114;
			NI res_90116;
			k_90097 = 0;
			HEX3Atmp_90114 = 0;
			HEX3Atmp_90114 = (NI32)(m - 1);
			res_90116 = 0;
			while (1) {
				if (!(res_90116 <= HEX3Atmp_90114)) goto LA3;
				k_90097 = res_90116;
				{
					if (!!(((NU8)(sub->data[k_90097]) == (NU8)(s->data[(NI32)(k_90097 + j)])))) goto LA6;
					goto LA2;
				}
				LA6: ;
				res_90116 += 1;
			} LA3: ;
			result = j;
			goto BeforeRet;
		} LA2: ;
		j += a[(((NU8)(s->data[(NI32)(j + m)])))- 0];
	} LA1: ;
	result = -1;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuReplaceStr)(NimStringDesc* s, NimStringDesc* sub, NimStringDesc* by) {
	NimStringDesc* result;
	tskiptable90032 a;
	NI i;
	NimStringDesc* LOC7;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP1282));
	preprocesssub_90036(sub, a);
	i = 0;
	while (1) {
		NI j;
		NimStringDesc* LOC6;
		j = findaux_90076(s, sub, i, a);
		{
			if (!(j < 0)) goto LA4;
			goto LA1;
		}
		LA4: ;
		LOC6 = 0;
		LOC6 = copyStrLast(s, i, (NI32)(j - 1));
		result = resizeString(result, LOC6->Sup.len + 0);
appendString(result, LOC6);
		result = resizeString(result, by->Sup.len + 0);
appendString(result, by);
		i = (NI32)(j + sub->Sup.len);
	} LA1: ;
	LOC7 = 0;
	LOC7 = copyStr(s, i);
	result = resizeString(result, LOC7->Sup.len + 0);
appendString(result, LOC7);
	return result;
}

N_NIMCALL(NimStringDesc*, nsuJoin)(NimStringDesc** a, NI aLen0) {
	NimStringDesc* result;
	result = 0;
	{
		NI l;
		NI i_89991;
		NI HEX3Atmp_90019;
		NI res_90021;
		NI i_90018;
		NI HEX3Atmp_90023;
		NI res_90025;
		if (!(0 < aLen0)) goto LA3;
		l = 0;
		i_89991 = 0;
		HEX3Atmp_90019 = 0;
		HEX3Atmp_90019 = (aLen0-1);
		res_90021 = 0;
		while (1) {
			if (!(res_90021 <= HEX3Atmp_90019)) goto LA5;
			i_89991 = res_90021;
			l += a[i_89991]->Sup.len;
			res_90021 += 1;
		} LA5: ;
		result = rawNewString(l);
		i_90018 = 0;
		HEX3Atmp_90023 = 0;
		HEX3Atmp_90023 = (aLen0-1);
		res_90025 = 0;
		while (1) {
			if (!(res_90025 <= HEX3Atmp_90023)) goto LA6;
			i_90018 = res_90025;
			result = resizeString(result, a[i_90018]->Sup.len + 0);
appendString(result, a[i_90018]);
			res_90025 += 1;
		} LA6: ;
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1282));
	}
	LA1: ;
	return result;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		tcell41090* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_44443(src);
		(*c).Refcount += 8;
	}
	LA3: ;
	{
		tcell41090* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_44443((*dest));
		{
			(*c).Refcount -= 8;
			if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA11;
			rtladdzct_46002(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

N_NIMCALL(NI, nsuParseInt)(NimStringDesc* s) {
	NI result;
	NI l;
	result = 0;
	l = npuParseInt(s, &result, 0);
	{
		NIM_BOOL LOC3;
		einvalidvalue2453* e_89133;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = !((l == s->Sup.len));
		if (LOC3) goto LA4;
		LOC3 = (l == 0);
		LA4: ;
		if (!LOC3) goto LA5;
		e_89133 = 0;
		e_89133 = (einvalidvalue2453*) newObj((&NTI17801), sizeof(einvalidvalue2453));
		(*e_89133).Sup.Sup.Sup.m_type = (&NTI2453);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &TMP1294));
appendString(LOC7, s);
		asgnRefNoCycle((void**) &(*e_89133).Sup.Sup.message, LOC7);
		raiseException((E_Base*)e_89133, "EInvalidValue");
	}
	LA5: ;
	return result;
}

N_NIMCALL(NI, nsuFindStr)(NimStringDesc* s, NimStringDesc* sub, NI start) {
	NI result;
	tskiptable90032 a;
	result = 0;
	preprocesssub_90036(sub, a);
	result = findaux_90076(s, sub, start, a);
	return result;
}

N_NIMCALL(TY110805*, nsuSplitChar)(NimStringDesc* s, NIM_CHAR sep) {
	TY110805* result;
	NimStringDesc* x_88973;
	NI last_89013;
	result = 0;
	result = (TY110805*) newSeq((&NTI110805), 0);
	x_88973 = 0;
	last_89013 = 0;
	{
		if (!(0 < s->Sup.len)) goto LA3;
		while (1) {
			NI first_89015;
			NimStringDesc* LOC9;
			if (!(last_89013 <= s->Sup.len)) goto LA5;
			first_89015 = last_89013;
			while (1) {
				NIM_BOOL LOC7;
				LOC7 = 0;
				LOC7 = (last_89013 < s->Sup.len);
				if (!(LOC7)) goto LA8;
				LOC7 = !(((NU8)(s->data[last_89013]) == (NU8)(sep)));
				LA8: ;
				if (!LOC7) goto LA6;
				last_89013 += 1;
			} LA6: ;
			x_88973 = copyStrLast(s, first_89015, (NI32)(last_89013 - 1));
			result = (TY110805*) incrSeq(&(result)->Sup, sizeof(NimStringDesc*));
			LOC9 = 0;
			LOC9 = result->data[result->Sup.len-1]; result->data[result->Sup.len-1] = copyStringRC1(x_88973);
			if (LOC9) nimGCunrefNoCycle(LOC9);
			last_89013 += 1;
		} LA5: ;
	}
	LA3: ;
	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 = (NI32)(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 LA5;
			first += 1;
		} LA5: ;
	}
	LA3: ;
	{
		if (!trailing) goto LA8;
		while (1) {
			NIM_BOOL LOC11;
			LOC11 = 0;
			LOC11 = (0 <= last);
			if (!(LOC11)) goto LA12;
			LOC11 = (((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)));
			LA12: ;
			if (!LOC11) goto LA10;
			last -= 1;
		} LA10: ;
	}
	LA8: ;
	result = copyStrLast(s, first, last);
	return result;
}

N_NIMCALL(NF, nsuParseFloat)(NimStringDesc* s) {
	NF result;
	NI l;
	result = 0;
	l = npuParseFloat(s, &result, 0);
	{
		NIM_BOOL LOC3;
		einvalidvalue2453* e_89191;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = !((l == s->Sup.len));
		if (LOC3) goto LA4;
		LOC3 = (l == 0);
		LA4: ;
		if (!LOC3) goto LA5;
		e_89191 = 0;
		e_89191 = (einvalidvalue2453*) newObj((&NTI17801), sizeof(einvalidvalue2453));
		(*e_89191).Sup.Sup.Sup.m_type = (&NTI2453);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 15);
appendString(LOC7, ((NimStringDesc*) &TMP1405));
appendString(LOC7, s);
		asgnRefNoCycle((void**) &(*e_89191).Sup.Sup.message, LOC7);
		raiseException((E_Base*)e_89191, "EInvalidValue");
	}
	LA5: ;
	return result;
}

N_NIMCALL(NI64, nsuParseBiggestInt)(NimStringDesc* s) {
	NI64 result;
	NI l;
	result = 0;
	l = npuParseBiggestInt(s, &result, 0);
	{
		NIM_BOOL LOC3;
		einvalidvalue2453* e_89162;
		NimStringDesc* LOC7;
		LOC3 = 0;
		LOC3 = !((l == s->Sup.len));
		if (LOC3) goto LA4;
		LOC3 = (l == 0);
		LA4: ;
		if (!LOC3) goto LA5;
		e_89162 = 0;
		e_89162 = (einvalidvalue2453*) newObj((&NTI17801), sizeof(einvalidvalue2453));
		(*e_89162).Sup.Sup.Sup.m_type = (&NTI2453);
		LOC7 = 0;
		LOC7 = rawNewString(s->Sup.len + 17);
appendString(LOC7, ((NimStringDesc*) &TMP1294));
appendString(LOC7, s);
		asgnRefNoCycle((void**) &(*e_89162).Sup.Sup.message, LOC7);
		raiseException((E_Base*)e_89162, "EInvalidValue");
	}
	LA5: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len) {
	NimStringDesc* result;
	NI64 shift;
	NI j_89092;
	NI HEX3Atmp_89095;
	NI res_89097;
	result = 0;
	shift = 0;
	result = mnewString(len);
	j_89092 = 0;
	HEX3Atmp_89095 = 0;
	HEX3Atmp_89095 = (NI32)(len - 1);
	res_89097 = HEX3Atmp_89095;
	while (1) {
		if (!(0 <= res_89097)) goto LA1;
		j_89092 = res_89097;
		result->data[j_89092] = ((NimStringDesc*) &TMP1581)->data[(NI32)(((NI32)(NU32)(NU64)((NI64)((NU64)(x) >> (NU64)(shift)))) & ((NI32) 15))];
		shift = (NI64)(shift + 4);
		res_89097 -= 1;
	} LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuToBin)(NI64 x, NI len) {
	NimStringDesc* result;
	NI64 mask;
	NI64 shift;
	NI j_90812;
	NI HEX3Atmp_90823;
	NI res_90825;
	result = 0;
	mask = 1;
	shift = 0;
	result = mnewString(len);
	j_90812 = 0;
	HEX3Atmp_90823 = 0;
	HEX3Atmp_90823 = (NI32)(len - 1);
	res_90825 = HEX3Atmp_90823;
	while (1) {
		if (!(0 <= res_90825)) goto LA1;
		j_90812 = res_90825;
		result->data[j_90812] = ((NIM_CHAR) (((NI) ((NI32)(((NI) ((NI64)((NU64)((NI64)(x & mask)) >> (NU64)(shift)))) + 48)))));
		shift = (NI64)(shift + 1);
		mask = (NI64)((NU64)(mask) << (NU64)(1));
		res_90825 -= 1;
	} LA1: ;
	return result;
}

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

N_NIMCALL(NIM_BOOL, contains_90258)(NimStringDesc* s, TY90161 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*, nsuEscape)(NimStringDesc* s, NimStringDesc* prefix, NimStringDesc* suffix) {
	NimStringDesc* result;
	NIM_CHAR c_90925;
	NI i_90935;
	NI l_90937;
	result = 0;
	result = rawNewString((NI32)(s->Sup.len + (NI)((NU32)(s->Sup.len) >> (NU32)(2))));
	result = resizeString(result, prefix->Sup.len + 0);
appendString(result, prefix);
	c_90925 = 0;
	i_90935 = 0;
	l_90937 = s->Sup.len;
	while (1) {
		if (!(i_90935 < l_90937)) goto LA1;
		c_90925 = s->data[i_90935];
		switch (((NU8)(c_90925))) {
		case 0 ... 31:
		case 128 ... 255:
		{
			NimStringDesc* LOC3;
			result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP1982));
			LOC3 = 0;
			LOC3 = nsuToHex(((NI64) (((NU8)(c_90925)))), 2);
			result = resizeString(result, LOC3->Sup.len + 0);
appendString(result, LOC3);
		}
		break;
		case 92:
		{
			result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP1983));
		}
		break;
		case 39:
		{
			result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP1984));
		}
		break;
		case 34:
		{
			result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP1985));
		}
		break;
		default:
		{
			result = addChar(result, c_90925);
		}
		break;
		}
		i_90935 += 1;
	} LA1: ;
	result = resizeString(result, suffix->Sup.len + 0);
appendString(result, suffix);
	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 LA4;
			result = NIM_TRUE;
			goto BeforeRet;
		}
		LA4: ;
		{
			if (!!(((NU8)(s->data[(NI32)(i + start)]) == (NU8)(substr->data[i])))) goto LA8;
			result = NIM_FALSE;
			goto BeforeRet;
		}
		LA8: ;
		i += 1;
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuJoinSep)(NimStringDesc** a, NI aLen0, NimStringDesc* sep) {
	NimStringDesc* result;
	result = 0;
	{
		NI l;
		NI i_89927;
		NI HEX3Atmp_89955;
		NI res_89957;
		NI i_89954;
		NI HEX3Atmp_89959;
		NI res_89961;
		if (!(0 < aLen0)) goto LA3;
		l = (NI32)(sep->Sup.len * (NI32)(aLen0 - 1));
		i_89927 = 0;
		HEX3Atmp_89955 = 0;
		HEX3Atmp_89955 = (aLen0-1);
		res_89957 = 0;
		while (1) {
			if (!(res_89957 <= HEX3Atmp_89955)) goto LA5;
			i_89927 = res_89957;
			l += a[i_89927]->Sup.len;
			res_89957 += 1;
		} LA5: ;
		result = rawNewString(l);
		result = resizeString(result, a[0]->Sup.len + 0);
appendString(result, a[0]);
		i_89954 = 0;
		HEX3Atmp_89959 = 0;
		HEX3Atmp_89959 = (aLen0-1);
		res_89961 = 1;
		while (1) {
			if (!(res_89961 <= HEX3Atmp_89959)) goto LA6;
			i_89954 = res_89961;
			result = resizeString(result, sep->Sup.len + 0);
appendString(result, sep);
			result = resizeString(result, a[i_89954]->Sup.len + 0);
appendString(result, a[i_89954]);
			res_89961 += 1;
		} LA6: ;
	}
	goto LA1;
	LA3: ;
	{
		result = copyString(((NimStringDesc*) &TMP1282));
	}
	LA1: ;
	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) ((NI32)(((NI) (((NU8)(c)))) - 32)))));
	}
	goto LA1;
	LA3: ;
	{
		result = c;
	}
	LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuIntToStr)(NI x, NI minchars) {
	NimStringDesc* result;
	NI i_89116;
	NI HEX3Atmp_89118;
	NI res_89120;
	result = 0;
	result = nimIntToStr((NI32)abs(x));
	i_89116 = 0;
	HEX3Atmp_89118 = 0;
	HEX3Atmp_89118 = (NI32)(minchars - result->Sup.len);
	res_89120 = 1;
	while (1) {
		NimStringDesc* LOC2;
		if (!(res_89120 <= HEX3Atmp_89118)) goto LA1;
		i_89116 = res_89120;
		LOC2 = 0;
		LOC2 = rawNewString(result->Sup.len + 1);
appendChar(LOC2, 48);
appendString(LOC2, result);
		result = LOC2;
		res_89120 += 1;
	} LA1: ;
	{
		NimStringDesc* LOC7;
		if (!(x < 0)) goto LA5;
		LOC7 = 0;
		LOC7 = rawNewString(result->Sup.len + 1);
appendChar(LOC7, 45);
appendString(LOC7, result);
		result = LOC7;
	}
	LA5: ;
	return result;
}

N_NIMCALL(NimStringDesc*, nsuRepeatStr)(NI count, NimStringDesc* s) {
	NimStringDesc* result;
	NI i_89486;
	NI HEX3Atmp_89487;
	NI res_89489;
	result = 0;
	result = rawNewString((NI32)(count * s->Sup.len));
	i_89486 = 0;
	HEX3Atmp_89487 = 0;
	HEX3Atmp_89487 = (NI32)(count - 1);
	res_89489 = 0;
	while (1) {
		if (!(res_89489 <= HEX3Atmp_89487)) goto LA1;
		i_89486 = res_89489;
		result = resizeString(result, s->Sup.len + 0);
appendString(result, s);
		res_89489 += 1;
	} LA1: ;
	return result;
}

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

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

N_NIMCALL(NimStringDesc*, nsuformatBiggestFloat)(NF f, NU8 format, NI precision) {
	NimStringDesc* result;
	TY91546 frmtstr;
	TY91549 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_91540[(format)- 0];
		frmtstr[(5)- 0] = 0;
		sprintf(((NCSTRING) (buf)), ((NCSTRING) (frmtstr)), precision, f);
	}
	goto LA1;
	LA3: ;
	{
		frmtstr[(1)- 0] = floatformattochar_91540[(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;
	NI i_90864;
	NI HEX3Atmp_90913;
	NI res_90915;
	result = 0;
	l = (NI32)((NI32)((NI32)(s->Sup.len - 1) / digits) + s->Sup.len);
	result = mnewString(l);
	j = 0;
	l -= 1;
	i_90864 = 0;
	HEX3Atmp_90913 = 0;
	HEX3Atmp_90913 = (NI32)(s->Sup.len - 1);
	res_90915 = HEX3Atmp_90913;
	while (1) {
		if (!(0 <= res_90915)) goto LA1;
		i_90864 = res_90915;
		{
			if (!(j == digits)) goto LA4;
			result->data[l] = sep;
			l -= 1;
			j = 0;
		}
		LA4: ;
		result->data[l] = s->data[i_90864];
		j += 1;
		l -= 1;
		res_90915 -= 1;
	} LA1: ;
	return result;
}

N_NIMCALL(NimStringDesc*, formatsize_91567)(NI64 bytes, NIM_CHAR decimalsep) {
	NimStringDesc* result;
	NI64 gigabytes;
	NI64 megabytes;
	NI64 kilobytes;
	result = 0;
	gigabytes = (NI64)((NU64)(bytes) >> (NU64)(30));
	megabytes = (NI64)((NU64)(bytes) >> (NU64)(20));
	kilobytes = (NI64)((NU64)(bytes) >> (NU64)(10));
	{
		NimStringDesc* bs_91590;
		NimStringDesc* LOC5;
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		NimStringDesc* LOC8;
		if (!!((gigabytes == 0))) goto LA3;
		bs_91590 = nimInt64ToStr(megabytes);
		LOC5 = 0;
		LOC6 = 0;
		LOC6 = nimInt64ToStr(gigabytes);
		LOC7 = 0;
		LOC7 = nsuInsertSep(LOC6, 95, 3);
		LOC8 = 0;
		LOC8 = copyStrLast(bs_91590, 0, 2);
		LOC5 = rawNewString(LOC7->Sup.len + LOC8->Sup.len + 3);
appendString(LOC5, LOC7);
appendChar(LOC5, decimalsep);
appendString(LOC5, LOC8);
appendString(LOC5, ((NimStringDesc*) &TMP4548));
		result = LOC5;
	}
	goto LA1;
	LA3: ;
	{
		NimStringDesc* bs_91592;
		NimStringDesc* LOC12;
		NimStringDesc* LOC13;
		NimStringDesc* LOC14;
		NimStringDesc* LOC15;
		if (!!((megabytes == 0))) goto LA10;
		bs_91592 = nimInt64ToStr(kilobytes);
		LOC12 = 0;
		LOC13 = 0;
		LOC13 = nimInt64ToStr(megabytes);
		LOC14 = 0;
		LOC14 = nsuInsertSep(LOC13, 95, 3);
		LOC15 = 0;
		LOC15 = copyStrLast(bs_91592, 0, 2);
		LOC12 = rawNewString(LOC14->Sup.len + LOC15->Sup.len + 3);
appendString(LOC12, LOC14);
appendChar(LOC12, decimalsep);
appendString(LOC12, LOC15);
appendString(LOC12, ((NimStringDesc*) &TMP4549));
		result = LOC12;
	}
	goto LA1;
	LA10: ;
	{
		NimStringDesc* bs_91594;
		NimStringDesc* LOC19;
		NimStringDesc* LOC20;
		NimStringDesc* LOC21;
		NimStringDesc* LOC22;
		if (!!((kilobytes == 0))) goto LA17;
		bs_91594 = nimInt64ToStr(bytes);
		LOC19 = 0;
		LOC20 = 0;
		LOC20 = nimInt64ToStr(kilobytes);
		LOC21 = 0;
		LOC21 = nsuInsertSep(LOC20, 95, 3);
		LOC22 = 0;
		LOC22 = copyStrLast(bs_91594, 0, 2);
		LOC19 = rawNewString(LOC21->Sup.len + LOC22->Sup.len + 3);
appendString(LOC19, LOC21);
appendChar(LOC19, decimalsep);
appendString(LOC19, LOC22);
appendString(LOC19, ((NimStringDesc*) &TMP4550));
		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*) &TMP4551));
		result = LOC24;
	}
	LA1: ;
	return result;
}
N_NOINLINE(void, stdlibstrutilsInit)(void) {
}

N_NOINLINE(void, stdlibstrutilsDatInit)(void) {
NTI90032.size = sizeof(tskiptable90032);
NTI90032.kind = 16;
NTI90032.base = (&NTI106);
NTI90032.flags = 3;
}

