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

#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw;
typedef struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tySequence__uB9b75OUPRENsBAu4AnoePA tySequence__uB9b75OUPRENsBAu4AnoePA;
typedef struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
struct RootObj {
TNimType* m_type;
};
struct Exception {
  RootObj Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
tySequence__uB9b75OUPRENsBAu4AnoePA* trace;
NU raiseId;
Exception* up;
};
struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA {
  Exception Sup;
};
struct tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw {
  tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA Sup;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
NCSTRING procname;
NI line;
NCSTRING filename;
};
struct tySequence__uB9b75OUPRENsBAu4AnoePA {
  TGenericSeq Sup;
  tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];
};
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
static N_INLINE(NI, addInt)(NI a, NI b);
N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NI, chckRange)(NI i, NI a, NI b);
N_NOINLINE(void, raiseRangeError)(NI64 val);
N_LIB_PRIVATE N_NIMCALL(void, nsuAddf)(NimStringDesc** s, NimStringDesc* formatstr, NimStringDesc** a, NI aLen_0);
N_NOINLINE(void, raiseIndexError2)(NI i, NI n);
N_LIB_PRIVATE N_NOINLINE(void, invalidFormatString__8vOMwvNB8blLQSoRXfInAg)(void);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(void, raiseExceptionEx)(Exception* e, NCSTRING ename, NCSTRING procname, NCSTRING filename, NI line);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__i80o3k0SgEI5gTRCzYdyWAsystem)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
N_NIMCALL(NI, mulInt)(NI a, NI b);
static N_INLINE(NI, subInt)(NI a, NI b);
N_LIB_PRIVATE N_NIMCALL(NI, findNormalized__7LxW6wQxHkQGOeaPw6nEjQ)(NimStringDesc* x, NimStringDesc** inArray, NI inArrayLen_0);
N_LIB_PRIVATE N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a, NimStringDesc* b);
N_LIB_PRIVATE N_NIMCALL(NIM_CHAR, nsuToLowerAsciiChar)(NIM_CHAR c);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, substr__2yh9cer0ymNRHlOOg8P7IuA)(NimStringDesc* s, NI first, NI last);
extern TNimType NTI__Ie1m0dv1ZHg72IgPRr1cDw_;
extern TNimType NTI__yoNlBGx0D2tRizIdhQuENw_;
STRING_LITERAL(TM__JGc9b9bh2D3nTdUR7TGyq8aA_5, "invalid format string", 21);
static N_INLINE(NI, addInt)(NI a, NI b) {	NI result;
{	result = (NI)0;
	result = (NI)((NU64)(a) + (NU64)(b));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI) 0) <= (NI)(result ^ a));
		if (T3_) goto LA4_;
		T3_ = (((NI) 0) <= (NI)(result ^ b));
		LA4_: ;
		if (!T3_) goto LA5_;
		goto BeforeRet_;
	}
	LA5_: ;
	raiseOverflow();
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NI, chckRange)(NI i, NI a, NI b) {	NI result;
{	result = (NI)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (a <= i);
		if (!(T3_)) goto LA4_;
		T3_ = (i <= b);
		LA4_: ;
		if (!T3_) goto LA5_;
		result = i;
		goto BeforeRet_;
	}
	goto LA1_;
	LA5_: ;
	{
		raiseRangeError(((NI64) (i)));
	}
	LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NOINLINE(void, invalidFormatString__8vOMwvNB8blLQSoRXfInAg)(void) {	tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw* eX60gensym247570_;
	eX60gensym247570_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*)0;
	eX60gensym247570_ = (tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw*) newObj((&NTI__Ie1m0dv1ZHg72IgPRr1cDw_), sizeof(tyObject_ValueError__yoNlBGx0D2tRizIdhQuENw));
	(*eX60gensym247570_).Sup.Sup.Sup.m_type = (&NTI__yoNlBGx0D2tRizIdhQuENw_);
	(*eX60gensym247570_).Sup.Sup.name = "ValueError";
	(*eX60gensym247570_).Sup.Sup.message = copyString(((NimStringDesc*) &TM__JGc9b9bh2D3nTdUR7TGyq8aA_5));
	(*eX60gensym247570_).Sup.Sup.parent = NIM_NIL;
	raiseExceptionEx((Exception*)eX60gensym247570_, "ValueError", "invalidFormatString", "strutils.nim", 2634);
}
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest, source, ((size_t) (size)));
}
static N_INLINE(void, copyMem__i80o3k0SgEI5gTRCzYdyWAsystem)(void* dest, void* source, NI size) {	nimCopyMem(dest, source, size);
}
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {	{
		if (!!((src == NIM_NIL))) goto LA3_;
		copyMem__i80o3k0SgEI5gTRCzYdyWAsystem(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
		(*dest).Sup.len += (*src).Sup.len;
	}
	LA3_: ;
}
static N_INLINE(NI, subInt)(NI a, NI b) {	NI result;
{	result = (NI)0;
	result = (NI)((NU64)(a) - (NU64)(b));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI) 0) <= (NI)(result ^ a));
		if (T3_) goto LA4_;
		T3_ = (((NI) 0) <= (NI)(result ^ (NI)((NU64) ~(b))));
		LA4_: ;
		if (!T3_) goto LA5_;
		goto BeforeRet_;
	}
	LA5_: ;
	raiseOverflow();
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_CHAR, nsuToLowerAsciiChar)(NIM_CHAR c) {	NIM_CHAR result;
	result = (NIM_CHAR)0;
	{
		NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_25;
		if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA3_;
		TM__JGc9b9bh2D3nTdUR7TGyq8aA_25 = addInt(((NU8)(c)), ((NI) 32));
		result = ((NIM_CHAR) (((NI)chckRange((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_25), ((NI) 0), ((NI) 255)))));
	}
	goto LA1_;
	LA3_: ;
	{
		result = c;
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, nsuCmpIgnoreStyle)(NimStringDesc* a, NimStringDesc* b) {	NI result;
	NI i;
	NI j;
{	result = (NI)0;
	i = ((NI) 0);
	j = ((NI) 0);
	{
		while (1) {
			NIM_CHAR aa;
			NIM_CHAR bb;
			{
				while (1) {
					NIM_BOOL T5_;
					T5_ = (NIM_BOOL)0;
					T5_ = (i < (a ? a->Sup.len : 0));
					if (!(T5_)) goto LA6_;
					T5_ = ((NU8)(a->data[i]) == (NU8)(95));
					LA6_: ;
					if (!T5_) goto LA4;
					i += ((NI) 1);
				} LA4: ;
			}
			{
				while (1) {
					NIM_BOOL T9_;
					T9_ = (NIM_BOOL)0;
					T9_ = (j < (b ? b->Sup.len : 0));
					if (!(T9_)) goto LA10_;
					T9_ = ((NU8)(b->data[j]) == (NU8)(95));
					LA10_: ;
					if (!T9_) goto LA8;
					j += ((NI) 1);
				} LA8: ;
			}
			{
				if (!(i < (a ? a->Sup.len : 0))) goto LA13_;
				aa = nsuToLowerAsciiChar(a->data[i]);
			}
			goto LA11_;
			LA13_: ;
			{
				aa = 0;
			}
			LA11_: ;
			{
				if (!(j < (b ? b->Sup.len : 0))) goto LA18_;
				bb = nsuToLowerAsciiChar(b->data[j]);
			}
			goto LA16_;
			LA18_: ;
			{
				bb = 0;
			}
			LA16_: ;
			result = (NI)(((NU8)(aa)) - ((NU8)(bb)));
			{
				if (!!((result == ((NI) 0)))) goto LA23_;
				goto BeforeRet_;
			}
			LA23_: ;
			{
				if (!((a ? a->Sup.len : 0) <= i)) goto LA27_;
				{
					if (!((b ? b->Sup.len : 0) <= j)) goto LA31_;
					result = ((NI) 0);
					goto BeforeRet_;
				}
				LA31_: ;
				result = ((NI) -1);
				goto BeforeRet_;
			}
			goto LA25_;
			LA27_: ;
			{
				if (!((b ? b->Sup.len : 0) <= j)) goto LA34_;
				result = ((NI) 1);
				goto BeforeRet_;
			}
			goto LA25_;
			LA34_: ;
			LA25_: ;
			i += ((NI) 1);
			j += ((NI) 1);
		}
	}
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, findNormalized__7LxW6wQxHkQGOeaPw6nEjQ)(NimStringDesc* x, NimStringDesc** inArray, NI inArrayLen_0) {	NI result;
	NI i;
{	result = (NI)0;
	i = ((NI) 0);
	{
		while (1) {
			NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_26;
			if (!(i < (inArrayLen_0-1))) goto LA2;
			{
				NI T5_;
				if ((NU)(i) >= (NU)(inArrayLen_0)) raiseIndexError2(i,inArrayLen_0-1);
				T5_ = (NI)0;
				T5_ = nsuCmpIgnoreStyle(x, inArray[i]);
				if (!(T5_ == ((NI) 0))) goto LA6_;
				result = i;
				goto BeforeRet_;
			}
			LA6_: ;
			TM__JGc9b9bh2D3nTdUR7TGyq8aA_26 = addInt(i, ((NI) 2));
			i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_26);
		} LA2: ;
	}
	result = ((NI) -1);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, nsuAddf)(NimStringDesc** s, NimStringDesc* formatstr, NimStringDesc** a, NI aLen_0) {	NI i;
	NI num;
	i = ((NI) 0);
	num = ((NI) 0);
	{
		while (1) {
			if (!(i < (formatstr ? formatstr->Sup.len : 0))) goto LA2;
			{
				NIM_BOOL T5_;
				NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_3;
				NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_4;
				T5_ = (NIM_BOOL)0;
				if ((NU)(i) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(i,(formatstr ? formatstr->Sup.len : 0)-1);
				T5_ = ((NU8)(formatstr->data[i]) == (NU8)(36));
				if (!(T5_)) goto LA6_;
				TM__JGc9b9bh2D3nTdUR7TGyq8aA_3 = addInt(i, ((NI) 1));
				T5_ = ((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_3) < (formatstr ? formatstr->Sup.len : 0));
				LA6_: ;
				if (!T5_) goto LA7_;
				TM__JGc9b9bh2D3nTdUR7TGyq8aA_4 = addInt(i, ((NI) 1));
				if ((NU)((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_4)) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_4),(formatstr ? formatstr->Sup.len : 0)-1);
				switch (((NU8)(formatstr->data[(NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_4)]))) {
				case 35:
				{
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_6;
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_7;
					{
						if (!((aLen_0-1) < num)) goto LA12_;
						invalidFormatString__8vOMwvNB8blLQSoRXfInAg();
					}
					LA12_: ;
					if ((NU)(num) >= (NU)(aLen_0)) raiseIndexError2(num,aLen_0-1);
					(*s) = resizeString((*s), (a[num] ? a[num]->Sup.len : 0) + 0);
appendString((*s), a[num]);
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_6 = addInt(i, ((NI) 2));
					i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_6);
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_7 = addInt(num, ((NI) 1));
					num = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_7);
				}
				break;
				case 36:
				{
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_8;
					(*s) = addChar((*s), 36);
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_8 = addInt(i, ((NI) 2));
					i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_8);
				}
				break;
				case 49 ... 57:
				case 45:
				{
					NI j;
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_9;
					NIM_BOOL negative;
					NI idx;
					j = ((NI) 0);
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_9 = addInt(i, ((NI) 1));
					i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_9);
					if ((NU)(i) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(i,(formatstr ? formatstr->Sup.len : 0)-1);
					negative = ((NU8)(formatstr->data[i]) == (NU8)(45));
					{
						NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_10;
						if (!negative) goto LA18_;
						TM__JGc9b9bh2D3nTdUR7TGyq8aA_10 = addInt(i, ((NI) 1));
						i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_10);
					}
					LA18_: ;
					{
						while (1) {
							NIM_BOOL T22_;
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_11;
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_12;
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_13;
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_14;
							T22_ = (NIM_BOOL)0;
							T22_ = (i < (formatstr ? formatstr->Sup.len : 0));
							if (!(T22_)) goto LA23_;
							if ((NU)(i) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(i,(formatstr ? formatstr->Sup.len : 0)-1);
							T22_ = (((NU8)(formatstr->data[i])) >= ((NU8)(48)) && ((NU8)(formatstr->data[i])) <= ((NU8)(57)));
							LA23_: ;
							if (!T22_) goto LA21;
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_11 = mulInt(j, ((NI) 10));
							if ((NU)(i) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(i,(formatstr ? formatstr->Sup.len : 0)-1);
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_12 = addInt((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_11), ((NU8)(formatstr->data[i])));
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_13 = subInt((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_12), ((NI) 48));
							j = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_13);
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_14 = addInt(i, ((NI) 1));
							i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_14);
						} LA21: ;
					}
					{
						NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_15;
						if (!!(negative)) goto LA26_;
						TM__JGc9b9bh2D3nTdUR7TGyq8aA_15 = subInt(j, ((NI) 1));
						idx = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_15);
					}
					goto LA24_;
					LA26_: ;
					{
						NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_16;
						TM__JGc9b9bh2D3nTdUR7TGyq8aA_16 = subInt(aLen_0, j);
						idx = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_16);
					}
					LA24_: ;
					{
						NIM_BOOL T31_;
						T31_ = (NIM_BOOL)0;
						T31_ = (idx < ((NI) 0));
						if (T31_) goto LA32_;
						T31_ = ((aLen_0-1) < idx);
						LA32_: ;
						if (!T31_) goto LA33_;
						invalidFormatString__8vOMwvNB8blLQSoRXfInAg();
					}
					LA33_: ;
					if ((NU)(idx) >= (NU)(aLen_0)) raiseIndexError2(idx,aLen_0-1);
					(*s) = resizeString((*s), (a[idx] ? a[idx]->Sup.len : 0) + 0);
appendString((*s), a[idx]);
				}
				break;
				case 123:
				{
					NI j_2;
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_17;
					NI k;
					NIM_BOOL negative_2;
					NI isNumber;
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_30;
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_17 = addInt(i, ((NI) 2));
					j_2 = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_17);
					k = ((NI) 0);
					if ((NU)(j_2) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(j_2,(formatstr ? formatstr->Sup.len : 0)-1);
					negative_2 = ((NU8)(formatstr->data[j_2]) == (NU8)(45));
					{
						NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_18;
						if (!negative_2) goto LA38_;
						TM__JGc9b9bh2D3nTdUR7TGyq8aA_18 = addInt(j_2, ((NI) 1));
						j_2 = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_18);
					}
					LA38_: ;
					isNumber = ((NI) 0);
					{
						while (1) {
							NIM_BOOL T42_;
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_22;
							T42_ = (NIM_BOOL)0;
							T42_ = (j_2 < (formatstr ? formatstr->Sup.len : 0));
							if (!(T42_)) goto LA43_;
							if ((NU)(j_2) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(j_2,(formatstr ? formatstr->Sup.len : 0)-1);
							T42_ = !((((NU8)(formatstr->data[j_2])) == ((NU8)(0)) || ((NU8)(formatstr->data[j_2])) == ((NU8)(125))));
							LA43_: ;
							if (!T42_) goto LA41;
							{
								NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_19;
								NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_20;
								NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_21;
								if ((NU)(j_2) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(j_2,(formatstr ? formatstr->Sup.len : 0)-1);
								if (!(((NU8)(formatstr->data[j_2])) >= ((NU8)(48)) && ((NU8)(formatstr->data[j_2])) <= ((NU8)(57)))) goto LA46_;
								TM__JGc9b9bh2D3nTdUR7TGyq8aA_19 = mulInt(k, ((NI) 10));
								if ((NU)(j_2) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(j_2,(formatstr ? formatstr->Sup.len : 0)-1);
								TM__JGc9b9bh2D3nTdUR7TGyq8aA_20 = addInt((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_19), ((NU8)(formatstr->data[j_2])));
								TM__JGc9b9bh2D3nTdUR7TGyq8aA_21 = subInt((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_20), ((NI) 48));
								k = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_21);
								{
									if (!(isNumber == ((NI) 0))) goto LA50_;
									isNumber = ((NI) 1);
								}
								LA50_: ;
							}
							goto LA44_;
							LA46_: ;
							{
								isNumber = ((NI) -1);
							}
							LA44_: ;
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_22 = addInt(j_2, ((NI) 1));
							j_2 = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_22);
						} LA41: ;
					}
					{
						NI idx_2;
						if (!(isNumber == ((NI) 1))) goto LA55_;
						{
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_23;
							if (!!(negative_2)) goto LA59_;
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_23 = subInt(k, ((NI) 1));
							idx_2 = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_23);
						}
						goto LA57_;
						LA59_: ;
						{
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_24;
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_24 = subInt(aLen_0, k);
							idx_2 = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_24);
						}
						LA57_: ;
						{
							NIM_BOOL T64_;
							T64_ = (NIM_BOOL)0;
							T64_ = (idx_2 < ((NI) 0));
							if (T64_) goto LA65_;
							T64_ = ((aLen_0-1) < idx_2);
							LA65_: ;
							if (!T64_) goto LA66_;
							invalidFormatString__8vOMwvNB8blLQSoRXfInAg();
						}
						LA66_: ;
						if ((NU)(idx_2) >= (NU)(aLen_0)) raiseIndexError2(idx_2,aLen_0-1);
						(*s) = resizeString((*s), (a[idx_2] ? a[idx_2]->Sup.len : 0) + 0);
appendString((*s), a[idx_2]);
					}
					goto LA53_;
					LA55_: ;
					{
						NI x;
						NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_27;
						NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_28;
						NimStringDesc* T69_;
						TM__JGc9b9bh2D3nTdUR7TGyq8aA_27 = addInt(i, ((NI) 2));
						TM__JGc9b9bh2D3nTdUR7TGyq8aA_28 = subInt(j_2, ((NI) 1));
						T69_ = (NimStringDesc*)0;
						T69_ = substr__2yh9cer0ymNRHlOOg8P7IuA(formatstr, (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_27), (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_28));
						x = findNormalized__7LxW6wQxHkQGOeaPw6nEjQ(T69_, a, aLen_0);
						{
							NIM_BOOL T72_;
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_29;
							T72_ = (NIM_BOOL)0;
							T72_ = (((NI) 0) <= x);
							if (!(T72_)) goto LA73_;
							T72_ = (x < (aLen_0-1));
							LA73_: ;
							if (!T72_) goto LA74_;
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_29 = addInt(x, ((NI) 1));
							if ((NU)((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_29)) >= (NU)(aLen_0)) raiseIndexError2((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_29),aLen_0-1);
							(*s) = resizeString((*s), (a[(NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_29)] ? a[(NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_29)]->Sup.len : 0) + 0);
appendString((*s), a[(NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_29)]);
						}
						goto LA70_;
						LA74_: ;
						{
							invalidFormatString__8vOMwvNB8blLQSoRXfInAg();
						}
						LA70_: ;
					}
					LA53_: ;
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_30 = addInt(j_2, ((NI) 1));
					i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_30);
				}
				break;
				case 97 ... 122:
				case 65 ... 90:
				case 128 ... 255:
				case 95:
				{
					NI j_3;
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_31;
					NI x_2;
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_33;
					NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_34;
					NimStringDesc* T82_;
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_31 = addInt(i, ((NI) 1));
					j_3 = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_31);
					{
						while (1) {
							NIM_BOOL T80_;
							NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_32;
							T80_ = (NIM_BOOL)0;
							T80_ = (j_3 < (formatstr ? formatstr->Sup.len : 0));
							if (!(T80_)) goto LA81_;
							if ((NU)(j_3) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(j_3,(formatstr ? formatstr->Sup.len : 0)-1);
							T80_ = (((NU8)(formatstr->data[j_3])) >= ((NU8)(97)) && ((NU8)(formatstr->data[j_3])) <= ((NU8)(122)) || ((NU8)(formatstr->data[j_3])) >= ((NU8)(65)) && ((NU8)(formatstr->data[j_3])) <= ((NU8)(90)) || ((NU8)(formatstr->data[j_3])) >= ((NU8)(48)) && ((NU8)(formatstr->data[j_3])) <= ((NU8)(57)) || ((NU8)(formatstr->data[j_3])) >= ((NU8)(128)) && ((NU8)(formatstr->data[j_3])) <= ((NU8)(255)) || ((NU8)(formatstr->data[j_3])) == ((NU8)(95)));
							LA81_: ;
							if (!T80_) goto LA79;
							TM__JGc9b9bh2D3nTdUR7TGyq8aA_32 = addInt(j_3, ((NI) 1));
							j_3 = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_32);
						} LA79: ;
					}
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_33 = addInt(i, ((NI) 1));
					TM__JGc9b9bh2D3nTdUR7TGyq8aA_34 = subInt(j_3, ((NI) 1));
					T82_ = (NimStringDesc*)0;
					T82_ = substr__2yh9cer0ymNRHlOOg8P7IuA(formatstr, (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_33), (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_34));
					x_2 = findNormalized__7LxW6wQxHkQGOeaPw6nEjQ(T82_, a, aLen_0);
					{
						NIM_BOOL T85_;
						NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_35;
						T85_ = (NIM_BOOL)0;
						T85_ = (((NI) 0) <= x_2);
						if (!(T85_)) goto LA86_;
						T85_ = (x_2 < (aLen_0-1));
						LA86_: ;
						if (!T85_) goto LA87_;
						TM__JGc9b9bh2D3nTdUR7TGyq8aA_35 = addInt(x_2, ((NI) 1));
						if ((NU)((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_35)) >= (NU)(aLen_0)) raiseIndexError2((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_35),aLen_0-1);
						(*s) = resizeString((*s), (a[(NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_35)] ? a[(NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_35)]->Sup.len : 0) + 0);
appendString((*s), a[(NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_35)]);
					}
					goto LA83_;
					LA87_: ;
					{
						invalidFormatString__8vOMwvNB8blLQSoRXfInAg();
					}
					LA83_: ;
					i = j_3;
				}
				break;
				default:
				{
					invalidFormatString__8vOMwvNB8blLQSoRXfInAg();
				}
				break;
				}
			}
			goto LA3_;
			LA7_: ;
			{
				NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_36;
				if ((NU)(i) >= (NU)(formatstr ? formatstr->Sup.len : 0)) raiseIndexError2(i,(formatstr ? formatstr->Sup.len : 0)-1);
				(*s) = addChar((*s), formatstr->data[i]);
				TM__JGc9b9bh2D3nTdUR7TGyq8aA_36 = addInt(i, ((NI) 1));
				i = (NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_36);
			}
			LA3_: ;
		} LA2: ;
	}
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr, NimStringDesc** a, NI aLen_0) {	NimStringDesc* result;
	NI TM__JGc9b9bh2D3nTdUR7TGyq8aA_2;
	result = (NimStringDesc*)0;
	TM__JGc9b9bh2D3nTdUR7TGyq8aA_2 = addInt((formatstr ? formatstr->Sup.len : 0), (NI)((NU64)(aLen_0) << (NU64)(((NI) 4))));
	result = rawNewString(((NI)chckRange((NI)(TM__JGc9b9bh2D3nTdUR7TGyq8aA_2), ((NI) 0), ((NI) IL64(9223372036854775807)))));
	nsuAddf((&result), formatstr, a, aLen_0);
	return result;
}
