/* 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_json.o compiler/nimcache/stdlib_json.c */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <string.h>
typedef struct tjsonnode292105 tjsonnode292105;
typedef struct TY292613 TY292613;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TY292120 TY292120;
typedef struct TY292125 TY292125;
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 tbasechunk22636 tbasechunk22636;
typedef struct tfreecell22628 tfreecell22628;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct TY292613 {
NimStringDesc* Field0;
tjsonnode292105* Field1;
};
struct  tjsonnode292105  {
NU8 Kind;
union {
struct {NimStringDesc* Str;
} S1;
struct {NI64 Num;
} S2;
struct {NF Fnum;
} S3;
struct {NIM_BOOL Bval;
} S4;
struct {TY292120* Fields;
} S6;
struct {TY292125* Elems;
} S7;
} kindU;
};
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  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 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 TY292120 {
  TGenericSeq Sup;
  TY292613 data[SEQ_DECL_SIZE];
};
struct TY292125 {
  TGenericSeq Sup;
  tjsonnode292105* data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP4460)(void* p, NI op);
N_NIMCALL(void, TMP4461)(void* p, NI op);
N_NIMCALL(void, TMP4462)(void* p, NI op);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
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*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(void, topretty_294896)(NimStringDesc** result, tjsonnode292105* node, NI indent, NIM_BOOL ml, NIM_BOOL lstarr, NI currindent);
N_NIMCALL(void, nl_294866)(NimStringDesc** s, NIM_BOOL ml);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_NIMCALL(void, indent_294851)(NimStringDesc** s, NI i);
N_NIMCALL(NimStringDesc*, nsuRepeatChar)(NI count, NIM_CHAR c);
N_NIMCALL(NI, newindent_294858)(NI curr, NI indent, NIM_BOOL ml);
N_NIMCALL(NimStringDesc*, escapejson_294873)(NimStringDesc* s);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len);
N_NIMCALL(NimStringDesc*, nimInt64ToStr)(NI64 x);
N_NIMCALL(NimStringDesc*, nimFloatToStr)(NF x);
N_NIMCALL(NimStringDesc*, nimBoolToStr)(NIM_BOOL x);
TNimNode* NimDT_tjsonnode_kind[8];
STRING_LITERAL(TMP4467, "", 0);
STRING_LITERAL(TMP4468, "\012", 1);
STRING_LITERAL(TMP4469, "{", 1);
STRING_LITERAL(TMP4470, ", ", 2);
STRING_LITERAL(TMP4471, "\"", 1);
STRING_LITERAL(TMP4472, "\\\"", 2);
STRING_LITERAL(TMP4473, "\\\\", 2);
STRING_LITERAL(TMP4474, "\\u", 2);
STRING_LITERAL(TMP4475, ": ", 2);
STRING_LITERAL(TMP4476, "}", 1);
STRING_LITERAL(TMP4477, "{}", 2);
STRING_LITERAL(TMP4480, "[", 1);
STRING_LITERAL(TMP4481, "]", 1);
STRING_LITERAL(TMP4482, "[]", 2);
STRING_LITERAL(TMP4483, "null", 4);
TNimType NTI292105; /* TJsonNode */
TNimType NTI292101; /* TJsonNodeKind */
extern TNimType NTI143; /* string */
extern TNimType NTI4289; /* BiggestInt */
extern TNimType NTI126; /* float */
extern TNimType NTI134; /* bool */
TNimType NTI292613; /* tuple[key: string, val: PJsonNode] */
TNimType NTI292120; /* seq[tuple[key: string, val: PJsonNode]] */
TNimType NTI292125; /* seq[PJsonNode] */
TNimType NTI292103; /* PJsonNode */
extern tgcheap43016 gch_43044;
N_NIMCALL(void, TMP4460)(void* p, NI op) {
	TY292120* a;
	NI LOC1;
	a = (TY292120*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1].Field0, op);
	nimGCvisit((void*)a->data[LOC1].Field1, op);
	}
}
N_NIMCALL(void, TMP4461)(void* p, NI op) {
	TY292125* a;
	NI LOC1;
	a = (TY292125*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1], op);
	}
}
N_NIMCALL(void, TMP4462)(void* p, NI op) {
	tjsonnode292105* a;
	a = (tjsonnode292105*)p;
	switch ((*a).Kind) {
	case ((NU8) 4):
	nimGCvisit((void*)(*a).kindU.S1.Str, op);
	break;
	case ((NU8) 2):
	break;
	case ((NU8) 3):
	break;
	case ((NU8) 1):
	break;
	case ((NU8) 0):
	break;
	case ((NU8) 5):
	nimGCvisit((void*)(*a).kindU.S6.Fields, op);
	break;
	case ((NU8) 6):
	nimGCvisit((void*)(*a).kindU.S7.Elems, op);
	break;
	} 
}

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: ;
}

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(tjsonnode292105*, HEX25_292610)(TY292613* keyvals, NI keyvalsLen0) {
	tjsonnode292105* result;
	NI i_292715;
	TY292613 p_292716;
	NI i_292732;
	result = 0;
	result = (tjsonnode292105*) newObj((&NTI292103), sizeof(tjsonnode292105));
	(*result).Kind = ((NU8) 5);
	if ((*result).kindU.S6.Fields) nimGCunrefNoCycle((*result).kindU.S6.Fields);
	(*result).kindU.S6.Fields = (TY292120*) newSeqRC1((&NTI292120), keyvalsLen0);
	i_292715 = 0;
	memset((void*)&p_292716, 0, sizeof(p_292716));
	i_292732 = 0;
	while (1) {
		NimStringDesc* LOC2;
		if (!(i_292732 < keyvalsLen0)) goto LA1;
		i_292715 = i_292732;
		p_292716.Field0 = keyvals[i_292732].Field0;
		p_292716.Field1 = keyvals[i_292732].Field1;
		LOC2 = 0;
		LOC2 = (*result).kindU.S6.Fields->data[i_292715].Field0; (*result).kindU.S6.Fields->data[i_292715].Field0 = copyStringRC1(p_292716.Field0);
		if (LOC2) nimGCunrefNoCycle(LOC2);
		asgnRefNoCycle((void**) &(*result).kindU.S6.Fields->data[i_292715].Field1, p_292716.Field1);
		i_292732 += 1;
	} LA1: ;
	return result;
}

N_NIMCALL(tjsonnode292105*, HEX25_292466)(NimStringDesc* s) {
	tjsonnode292105* result;
	NimStringDesc* LOC1;
	result = 0;
	result = (tjsonnode292105*) newObj((&NTI292103), sizeof(tjsonnode292105));
	(*result).Kind = ((NU8) 4);
	LOC1 = 0;
	LOC1 = (*result).kindU.S1.Str; (*result).kindU.S1.Str = copyStringRC1(s);
	if (LOC1) nimGCunrefNoCycle(LOC1);
	return result;
}

static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b) {
	NIM_BOOL result;
	NIM_BOOL LOC11;
	int LOC13;
	result = 0;
	{
		if (!(a == b)) goto LA3;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = (a == NIM_NIL);
		if (LOC7) goto LA8;
		LOC7 = (b == NIM_NIL);
		LA8: ;
		if (!LOC7) goto LA9;
		result = NIM_FALSE;
		goto BeforeRet;
	}
	LA9: ;
	LOC11 = 0;
	LOC11 = ((*a).Sup.len == (*b).Sup.len);
	if (!(LOC11)) goto LA12;
	LOC13 = 0;
	LOC13 = memcmp(((NCSTRING) ((*a).data)), ((NCSTRING) ((*b).data)), (NI32)((*a).Sup.len * 1));
	LOC11 = (LOC13 == ((NI32) 0));
	LA12: ;
	result = LOC11;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, HEX5BHEX5DHEX3D_294036)(tjsonnode292105* obj, NimStringDesc* key, tjsonnode292105* val) {
	NI i_294236;
	NI HEX3Atmp_294298;
	NI res_294300;
	TY292613 LOC6;
	NimStringDesc* LOC7;
	i_294236 = 0;
	HEX3Atmp_294298 = 0;
	HEX3Atmp_294298 = (NI32)((*obj).kindU.S6.Fields->Sup.len - 1);
	res_294300 = 0;
	while (1) {
		if (!(res_294300 <= HEX3Atmp_294298)) goto LA1;
		i_294236 = res_294300;
		{
			if (!eqStrings((*obj).kindU.S6.Fields->data[i_294236].Field0, key)) goto LA4;
			asgnRefNoCycle((void**) &(*obj).kindU.S6.Fields->data[i_294236].Field1, val);
			goto BeforeRet;
		}
		LA4: ;
		res_294300 += 1;
	} LA1: ;
	memset((void*)&LOC6, 0, sizeof(LOC6));
	LOC6.Field0 = copyString(key);
	LOC6.Field1 = val;
	(*obj).kindU.S6.Fields = (TY292120*) incrSeq(&((*obj).kindU.S6.Fields)->Sup, sizeof(TY292613));
	LOC7 = 0;
	LOC7 = (*obj).kindU.S6.Fields->data[(*obj).kindU.S6.Fields->Sup.len-1].Field0; (*obj).kindU.S6.Fields->data[(*obj).kindU.S6.Fields->Sup.len-1].Field0 = copyStringRC1(LOC6.Field0);
	if (LOC7) nimGCunrefNoCycle(LOC7);
	asgnRefNoCycle((void**) &(*obj).kindU.S6.Fields->data[(*obj).kindU.S6.Fields->Sup.len-1].Field1, LOC6.Field1);
	BeforeRet: ;
}

N_NIMCALL(tjsonnode292105*, newjarray_292411)(void) {
	tjsonnode292105* result;
	result = 0;
	result = (tjsonnode292105*) newObj((&NTI292103), sizeof(tjsonnode292105));
	(*result).Kind = ((NU8) 6);
	if ((*result).kindU.S7.Elems) nimGCunrefNoCycle((*result).kindU.S7.Elems);
	(*result).kindU.S7.Elems = (TY292125*) newSeqRC1((&NTI292125), 0);
	return result;
}

N_NIMCALL(void, add_293644)(tjsonnode292105* father, tjsonnode292105* child) {
	(*father).kindU.S7.Elems = (TY292125*) incrSeq(&((*father).kindU.S7.Elems)->Sup, sizeof(tjsonnode292105*));
	asgnRefNoCycle((void**) &(*father).kindU.S7.Elems->data[(*father).kindU.S7.Elems->Sup.len-1], child);
}

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(void, nl_294866)(NimStringDesc** s, NIM_BOOL ml) {
	{
		if (!ml) goto LA3;
		(*s) = resizeString((*s), 1);
appendString((*s), ((NimStringDesc*) &TMP4468));
	}
	LA3: ;
}

N_NIMCALL(void, indent_294851)(NimStringDesc** s, NI i) {
	NimStringDesc* LOC1;
	LOC1 = 0;
	LOC1 = nsuRepeatChar(i, 32);
	(*s) = resizeString((*s), LOC1->Sup.len + 0);
appendString((*s), LOC1);
}

N_NIMCALL(NI, newindent_294858)(NI curr, NI indent, NIM_BOOL ml) {
	NI result;
	result = 0;
	{
		if (!ml) goto LA3;
		result = (NI32)(curr + indent);
		goto BeforeRet;
	}
	goto LA1;
	LA3: ;
	{
		result = indent;
		goto BeforeRet;
	}
	LA1: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NimStringDesc*, escapejson_294873)(NimStringDesc* s) {
	NimStringDesc* result;
	NI x_294877;
	NI i_294883;
	NI result_294885;
	result = 0;
	result = rawNewString((NI32)(s->Sup.len + (NI)((NU32)(s->Sup.len) >> (NU32)(3))));
	result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TMP4471));
	x_294877 = 0;
	i_294883 = 0;
	result_294885 = 0;
	while (1) {
		NI r;
		if (!(i_294883 < s->Sup.len)) goto LA1;
		{
			if (!((NU32)(((NU8)(s->data[i_294883]))) <= (NU32)(127))) goto LA4;
			result_294885 = ((NI) (((NU8)(s->data[i_294883]))));
			i_294883 += 1;
		}
		goto LA2;
		LA4: ;
		{
			if (!((NI)((NU32)(((NI) (((NU8)(s->data[i_294883]))))) >> (NU32)(5)) == 6)) goto LA7;
			result_294885 = (NI)((NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[i_294883])))) & 31)))) << (NU32)(6)) | ((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 1)])))) & 63))));
			i_294883 += 2;
		}
		goto LA2;
		LA7: ;
		{
			if (!((NI)((NU32)(((NI) (((NU8)(s->data[i_294883]))))) >> (NU32)(4)) == 14)) goto LA10;
			result_294885 = (NI)((NI)((NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[i_294883])))) & 15)))) << (NU32)(12)) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 1)])))) & 63)))) << (NU32)(6))) | ((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 2)])))) & 63))));
			i_294883 += 3;
		}
		goto LA2;
		LA10: ;
		{
			if (!((NI)((NU32)(((NI) (((NU8)(s->data[i_294883]))))) >> (NU32)(3)) == 30)) goto LA13;
			result_294885 = (NI)((NI)((NI)((NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[i_294883])))) & 7)))) << (NU32)(18)) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 1)])))) & 63)))) << (NU32)(12))) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 2)])))) & 63)))) << (NU32)(6))) | ((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 3)])))) & 63))));
			i_294883 += 4;
		}
		goto LA2;
		LA13: ;
		{
			if (!((NI)((NU32)(((NI) (((NU8)(s->data[i_294883]))))) >> (NU32)(2)) == 62)) goto LA16;
			result_294885 = (NI)((NI)((NI)((NI)((NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[i_294883])))) & 3)))) << (NU32)(24)) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 1)])))) & 63)))) << (NU32)(18))) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 2)])))) & 63)))) << (NU32)(12))) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 3)])))) & 63)))) << (NU32)(6))) | ((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 4)])))) & 63))));
			i_294883 += 5;
		}
		goto LA2;
		LA16: ;
		{
			if (!((NI)((NU32)(((NI) (((NU8)(s->data[i_294883]))))) >> (NU32)(1)) == 126)) goto LA19;
			result_294885 = (NI)((NI)((NI)((NI)((NI)((NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[i_294883])))) & 1)))) << (NU32)(30)) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 1)])))) & 63)))) << (NU32)(24))) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 2)])))) & 63)))) << (NU32)(18))) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 3)])))) & 63)))) << (NU32)(12))) | (NI)((NU32)(((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 4)])))) & 63)))) << (NU32)(6))) | ((NI) ((NI)(((NI) (((NU8)(s->data[(NI32)(i_294883 + 5)])))) & 63))));
			i_294883 += 6;
		}
		goto LA2;
		LA19: ;
		{
			result_294885 = ((NI) (((NU8)(s->data[i_294883]))));
			i_294883 += 1;
		}
		LA2: ;
		x_294877 = result_294885;
		r = x_294877;
		{
			NIM_BOOL LOC24;
			NIM_CHAR c;
			LOC24 = 0;
			LOC24 = (32 <= r);
			if (!(LOC24)) goto LA25;
			LOC24 = (r <= 127);
			LA25: ;
			if (!LOC24) goto LA26;
			c = ((NIM_CHAR) (((NI) (r))));
			switch (((NU8)(c))) {
			case 34:
			{
				result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP4472));
			}
			break;
			case 92:
			{
				result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP4473));
			}
			break;
			default:
			{
				result = addChar(result, c);
			}
			break;
			}
		}
		goto LA22;
		LA26: ;
		{
			NimStringDesc* LOC32;
			result = resizeString(result, 2);
appendString(result, ((NimStringDesc*) &TMP4474));
			LOC32 = 0;
			LOC32 = nsuToHex(((NI64) (r)), 4);
			result = resizeString(result, LOC32->Sup.len + 0);
appendString(result, LOC32);
		}
		LA22: ;
	} LA1: ;
	result = resizeString(result, 1);
appendString(result, ((NimStringDesc*) &TMP4471));
	return result;
}

N_NIMCALL(void, topretty_294896)(NimStringDesc** result, tjsonnode292105* node, NI indent, NIM_BOOL ml, NIM_BOOL lstarr, NI currindent) {
	switch ((*node).Kind) {
	case ((NU8) 5):
	{
		{
			NIM_BOOL LOC4;
			LOC4 = 0;
			LOC4 = !((currindent == 0));
			if (!(LOC4)) goto LA5;
			LOC4 = !(lstarr);
			LA5: ;
			if (!LOC4) goto LA6;
			nl_294866(result, ml);
		}
		LA6: ;
		indent_294851(result, currindent);
		{
			NI i_294966;
			NI HEX3Atmp_295128;
			NI res_295130;
			if (!(0 < (*node).kindU.S6.Fields->Sup.len)) goto LA10;
			(*result) = resizeString((*result), 1);
appendString((*result), ((NimStringDesc*) &TMP4469));
			nl_294866(result, ml);
			i_294966 = 0;
			HEX3Atmp_295128 = 0;
			HEX3Atmp_295128 = (NI32)((*node).kindU.S6.Fields->Sup.len - 1);
			res_295130 = 0;
			while (1) {
				NI LOC17;
				NimStringDesc* LOC18;
				NI LOC19;
				if (!(res_295130 <= HEX3Atmp_295128)) goto LA12;
				i_294966 = res_295130;
				{
					if (!(0 < i_294966)) goto LA15;
					(*result) = resizeString((*result), 2);
appendString((*result), ((NimStringDesc*) &TMP4470));
					nl_294866(result, ml);
				}
				LA15: ;
				LOC17 = 0;
				LOC17 = newindent_294858(currindent, indent, ml);
				indent_294851(result, LOC17);
				LOC18 = 0;
				LOC18 = escapejson_294873((*node).kindU.S6.Fields->data[i_294966].Field0);
				(*result) = resizeString((*result), LOC18->Sup.len + 0);
appendString((*result), LOC18);
				(*result) = resizeString((*result), 2);
appendString((*result), ((NimStringDesc*) &TMP4475));
				LOC19 = 0;
				LOC19 = newindent_294858(currindent, indent, ml);
				topretty_294896(result, (*node).kindU.S6.Fields->data[i_294966].Field1, indent, ml, NIM_FALSE, LOC19);
				res_295130 += 1;
			} LA12: ;
			nl_294866(result, ml);
			indent_294851(result, currindent);
			(*result) = resizeString((*result), 1);
appendString((*result), ((NimStringDesc*) &TMP4476));
		}
		goto LA8;
		LA10: ;
		{
			(*result) = resizeString((*result), 2);
appendString((*result), ((NimStringDesc*) &TMP4477));
		}
		LA8: ;
	}
	break;
	case ((NU8) 4):
	{
		NimStringDesc* LOC26;
		{
			if (!lstarr) goto LA24;
			indent_294851(result, currindent);
		}
		LA24: ;
		LOC26 = 0;
		LOC26 = escapejson_294873((*node).kindU.S1.Str);
		(*result) = resizeString((*result), LOC26->Sup.len + 0);
appendString((*result), LOC26);
	}
	break;
	case ((NU8) 2):
	{
		NimStringDesc* LOC32;
		{
			if (!lstarr) goto LA30;
			indent_294851(result, currindent);
		}
		LA30: ;
		LOC32 = 0;
		LOC32 = nimInt64ToStr((*node).kindU.S2.Num);
		(*result) = resizeString((*result), LOC32->Sup.len + 0);
appendString((*result), LOC32);
	}
	break;
	case ((NU8) 3):
	{
		NimStringDesc* LOC38;
		{
			if (!lstarr) goto LA36;
			indent_294851(result, currindent);
		}
		LA36: ;
		LOC38 = 0;
		LOC38 = nimFloatToStr((*node).kindU.S3.Fnum);
		(*result) = resizeString((*result), LOC38->Sup.len + 0);
appendString((*result), LOC38);
	}
	break;
	case ((NU8) 1):
	{
		NimStringDesc* LOC44;
		{
			if (!lstarr) goto LA42;
			indent_294851(result, currindent);
		}
		LA42: ;
		LOC44 = 0;
		LOC44 = nimBoolToStr((*node).kindU.S4.Bval);
		(*result) = resizeString((*result), LOC44->Sup.len + 0);
appendString((*result), LOC44);
	}
	break;
	case ((NU8) 6):
	{
		{
			if (!lstarr) goto LA48;
			indent_294851(result, currindent);
		}
		LA48: ;
		{
			NI i_295112;
			NI HEX3Atmp_295132;
			NI res_295134;
			if (!!(((*node).kindU.S7.Elems->Sup.len == 0))) goto LA52;
			(*result) = resizeString((*result), 1);
appendString((*result), ((NimStringDesc*) &TMP4480));
			nl_294866(result, ml);
			i_295112 = 0;
			HEX3Atmp_295132 = 0;
			HEX3Atmp_295132 = (NI32)((*node).kindU.S7.Elems->Sup.len - 1);
			res_295134 = 0;
			while (1) {
				NI LOC59;
				if (!(res_295134 <= HEX3Atmp_295132)) goto LA54;
				i_295112 = res_295134;
				{
					if (!(0 < i_295112)) goto LA57;
					(*result) = resizeString((*result), 2);
appendString((*result), ((NimStringDesc*) &TMP4470));
					nl_294866(result, ml);
				}
				LA57: ;
				LOC59 = 0;
				LOC59 = newindent_294858(currindent, indent, ml);
				topretty_294896(result, (*node).kindU.S7.Elems->data[i_295112], indent, ml, NIM_TRUE, LOC59);
				res_295134 += 1;
			} LA54: ;
			nl_294866(result, ml);
			indent_294851(result, currindent);
			(*result) = resizeString((*result), 1);
appendString((*result), ((NimStringDesc*) &TMP4481));
		}
		goto LA50;
		LA52: ;
		{
			(*result) = resizeString((*result), 2);
appendString((*result), ((NimStringDesc*) &TMP4482));
		}
		LA50: ;
	}
	break;
	case ((NU8) 0):
	{
		{
			if (!lstarr) goto LA64;
			indent_294851(result, currindent);
		}
		LA64: ;
		(*result) = resizeString((*result), 4);
appendString((*result), ((NimStringDesc*) &TMP4483));
	}
	break;
	}
}

N_NIMCALL(NimStringDesc*, pretty_295140)(tjsonnode292105* node, NI indent) {
	NimStringDesc* result;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP4467));
	topretty_294896(&result, node, indent, NIM_TRUE, NIM_FALSE, 0);
	return result;
}

N_NIMCALL(NimStringDesc*, HEX24_295148)(tjsonnode292105* node) {
	NimStringDesc* result;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP4467));
	topretty_294896(&result, node, 1, NIM_FALSE, NIM_FALSE, 0);
	return result;
}
N_NOINLINE(void, stdlibjsonInit)(void) {
}

N_NOINLINE(void, stdlibjsonDatInit)(void) {
static TNimNode* TMP4456[7];
NI TMP4458;
static char* NIM_CONST TMP4457[7] = {
"JNull", 
"JBool", 
"JInt", 
"JFloat", 
"JString", 
"JObject", 
"JArray"};
static TNimNode* TMP4459[2];
static TNimNode TMP864[19];
NTI292105.size = sizeof(tjsonnode292105);
NTI292105.kind = 18;
NTI292105.base = 0;
NTI292105.flags = 2;
NTI292101.size = sizeof(NU8);
NTI292101.kind = 14;
NTI292101.base = 0;
NTI292101.flags = 3;
for (TMP4458 = 0; TMP4458 < 7; TMP4458++) {
TMP864[TMP4458+1].kind = 1;
TMP864[TMP4458+1].offset = TMP4458;
TMP864[TMP4458+1].name = TMP4457[TMP4458];
TMP4456[TMP4458] = &TMP864[TMP4458+1];
}
TMP864[8].len = 7; TMP864[8].kind = 2; TMP864[8].sons = &TMP4456[0];
NTI292101.node = &TMP864[8];
TMP864[0].kind = 3;
TMP864[0].offset = offsetof(tjsonnode292105, Kind);
TMP864[0].typ = (&NTI292101);
TMP864[0].name = "kind";
TMP864[0].sons = &NimDT_tjsonnode_kind[0];
TMP864[0].len = 7;
TMP864[9].kind = 1;
TMP864[9].offset = offsetof(tjsonnode292105, kindU.S1.Str);
TMP864[9].typ = (&NTI143);
TMP864[9].name = "str";
NimDT_tjsonnode_kind[4] = &TMP864[9];
TMP864[10].kind = 1;
TMP864[10].offset = offsetof(tjsonnode292105, kindU.S2.Num);
TMP864[10].typ = (&NTI4289);
TMP864[10].name = "num";
NimDT_tjsonnode_kind[2] = &TMP864[10];
TMP864[11].kind = 1;
TMP864[11].offset = offsetof(tjsonnode292105, kindU.S3.Fnum);
TMP864[11].typ = (&NTI126);
TMP864[11].name = "fnum";
NimDT_tjsonnode_kind[3] = &TMP864[11];
TMP864[12].kind = 1;
TMP864[12].offset = offsetof(tjsonnode292105, kindU.S4.Bval);
TMP864[12].typ = (&NTI134);
TMP864[12].name = "bval";
NimDT_tjsonnode_kind[1] = &TMP864[12];
TMP864[13].len = 0; TMP864[13].kind = 2;
NimDT_tjsonnode_kind[0] = &TMP864[13];
NTI292613.size = sizeof(TY292613);
NTI292613.kind = 18;
NTI292613.base = 0;
NTI292613.flags = 2;
TMP4459[0] = &TMP864[16];
TMP864[16].kind = 1;
TMP864[16].offset = offsetof(TY292613, Field0);
TMP864[16].typ = (&NTI143);
TMP864[16].name = "Field0";
TMP4459[1] = &TMP864[17];
TMP864[17].kind = 1;
TMP864[17].offset = offsetof(TY292613, Field1);
TMP864[17].typ = (&NTI292103);
TMP864[17].name = "Field1";
TMP864[15].len = 2; TMP864[15].kind = 2; TMP864[15].sons = &TMP4459[0];
NTI292613.node = &TMP864[15];
NTI292120.size = sizeof(TY292120*);
NTI292120.kind = 24;
NTI292120.base = (&NTI292613);
NTI292120.flags = 2;
NTI292120.marker = TMP4460;
TMP864[14].kind = 1;
TMP864[14].offset = offsetof(tjsonnode292105, kindU.S6.Fields);
TMP864[14].typ = (&NTI292120);
TMP864[14].name = "fields";
NimDT_tjsonnode_kind[5] = &TMP864[14];
NTI292125.size = sizeof(TY292125*);
NTI292125.kind = 24;
NTI292125.base = (&NTI292103);
NTI292125.flags = 2;
NTI292125.marker = TMP4461;
TMP864[18].kind = 1;
TMP864[18].offset = offsetof(tjsonnode292105, kindU.S7.Elems);
TMP864[18].typ = (&NTI292125);
TMP864[18].name = "elems";
NimDT_tjsonnode_kind[6] = &TMP864[18];
NTI292105.node = &TMP864[0];
NTI292103.size = sizeof(tjsonnode292105*);
NTI292103.kind = 22;
NTI292103.base = (&NTI292105);
NTI292103.flags = 2;
NTI292103.marker = TMP4462;
}

