/* 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>
typedef struct tidtable224864 tidtable224864;
typedef struct tidpairseq224862 tidpairseq224862;
typedef struct tidpair224860 tidpair224860;
typedef struct tidobj199015 tidobj199015;
typedef struct TNimObject TNimObject;
typedef struct TGenericSeq TGenericSeq;
typedef struct ttype224852 ttype224852;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct ttypeseq224848 ttypeseq224848;
typedef struct tnode224816 tnode224816;
typedef struct tsym224846 tsym224846;
typedef struct tloc224830 tloc224830;
typedef struct trope176009 trope176009;
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 NimStringDesc NimStringDesc;
typedef struct tlineinfo194539 tlineinfo194539;
typedef struct tident199021 tident199021;
typedef struct tnodeseq224810 tnodeseq224810;
typedef struct tinfocpu173463 tinfocpu173463;
typedef struct tscope224840 tscope224840;
typedef struct TY224947 TY224947;
typedef struct tinstantiation224836 tinstantiation224836;
typedef struct tstrtable224820 tstrtable224820;
typedef struct tsymseq224818 tsymseq224818;
typedef struct tlib224834 tlib224834;
typedef struct tbasechunk26438 tbasechunk26438;
typedef struct tfreecell26430 tfreecell26430;
typedef struct TY224936 TY224936;
typedef struct tlistentry126022 tlistentry126022;
struct  tidpair224860  {
tidobj199015* Key;
TNimObject* Val;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  tidtable224864  {
NI Counter;
tidpairseq224862* Data;
};
typedef tidtable224864 TY547278[62];
typedef ttype224852* TY281060[62];
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  tidobj199015  {
  TNimObject Sup;
NI Id;
};
struct  tloc224830  {
NU8 K;
NU8 S;
NU8 Flags;
ttype224852* T;
trope176009* R;
trope176009* Heaproot;
};
struct  ttype224852  {
  tidobj199015 Sup;
NU8 Kind;
NU8 Callconv;
NU32 Flags;
ttypeseq224848* Sons;
tnode224816* N;
tsym224846* Owner;
tsym224846* Sym;
tsym224846* Destructor;
tsym224846* Deepcopy;
NI64 Size;
NI16 Align;
NI16 Locklevel;
tloc224830 Loc;
};
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;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  tlineinfo194539  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  tnode224816  {
ttype224852* Typ;
tlineinfo194539 Info;
NU16 Flags;
NU8 Kind;
union {
struct {NI64 Intval;
} S1;
struct {NF Floatval;
} S2;
struct {NimStringDesc* Strval;
} S3;
struct {tsym224846* Sym;
} S4;
struct {tident199021* Ident;
} S5;
struct {tnodeseq224810* Sons;
} S6;
} kindU;
NimStringDesc* Comment;
};
struct tinfocpu173463 {
NimStringDesc* Field0;
NI Field1;
NU8 Field2;
NI Field3;
NI Field4;
};
typedef tinfocpu173463 TY173481[14];
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  tstrtable224820  {
NI Counter;
tsymseq224818* Data;
};
struct  tsym224846  {
  tidobj199015 Sup;
NU8 Kind;
union {
struct {ttypeseq224848* Typeinstcache;
tscope224840* Typscope;
} S1;
struct {TY224947* Procinstcache;
tscope224840* Scope;
} S2;
struct {TY224947* Usedgenerics;
tstrtable224820 Tab;
} S3;
struct {tsym224846* Guard;
} S4;
} kindU;
NU16 Magic;
ttype224852* Typ;
tident199021* Name;
tlineinfo194539 Info;
tsym224846* Owner;
NU32 Flags;
tnode224816* Ast;
NU32 Options;
NI Position;
NI Offset;
tloc224830 Loc;
tlib224834* Annex;
tnode224816* Constraint;
};
struct  trope176009  {
  TNimObject Sup;
trope176009* Left;
trope176009* Right;
NI Length;
NimStringDesc* Data;
};
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  tident199021  {
  tidobj199015 Sup;
NimStringDesc* S;
tident199021* Next;
NI H;
};
struct  tscope224840  {
NI Depthlevel;
tstrtable224820 Symbols;
tnodeseq224810* Usingsyms;
tscope224840* Parent;
};
struct  tinstantiation224836  {
tsym224846* Sym;
ttypeseq224848* Concretetypes;
TY224936* Usedby;
};
struct  tlistentry126022  {
  TNimObject Sup;
tlistentry126022* Prev;
tlistentry126022* Next;
};
struct  tlib224834  {
  tlistentry126022 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope176009* Name;
tnode224816* Path;
};
struct  tfreecell26430  {
tfreecell26430* Next;
NI Zerofield;
};
struct tidpairseq224862 {
  TGenericSeq Sup;
  tidpair224860 data[SEQ_DECL_SIZE];
};
struct ttypeseq224848 {
  TGenericSeq Sup;
  ttype224852* data[SEQ_DECL_SIZE];
};
struct tnodeseq224810 {
  TGenericSeq Sup;
  tnode224816* data[SEQ_DECL_SIZE];
};
struct TY224947 {
  TGenericSeq Sup;
  tinstantiation224836* data[SEQ_DECL_SIZE];
};
struct tsymseq224818 {
  TGenericSeq Sup;
  tsym224846* data[SEQ_DECL_SIZE];
};
struct TY224936 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, inittypetables_547291)(void);
N_NIMCALL(void, initidtable_225167)(tidtable224864* x);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
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, internalerror_197006)(NimStringDesc* errmsg);
N_NIMCALL(ttype224852*, getuniquetype_547401)(ttype224852* key);
static N_INLINE(ttype224852*, lastson_225267)(ttype224852* n);
static N_INLINE(NI, sonslen_225255)(ttype224852* n);
N_NIMCALL(NIM_BOOL, idtablehasobjectaskey_234205)(tidtable224864 t, tidobj199015* key);
N_NIMCALL(NIM_BOOL, samebackendtype_269542)(ttype224852* x, ttype224852* y);
N_NIMCALL(void, idtableput_234196)(tidtable224864* t, tidobj199015* key, TNimObject* val);
N_NIMCALL(TNimObject*, idtableget_234182)(tidtable224864 t, tidobj199015* key);
N_NIMCALL(NIM_BOOL, sametype_267351)(ttype224852* a, ttype224852* b, NU8 flags);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_NIMCALL(NIM_CHAR, nsuToLowerChar)(NIM_CHAR c);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_NIMCALL(NimStringDesc*, nsuToHex)(NI64 x, NI len);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(NimStringDesc*, tocchar_194649)(NIM_CHAR c);
N_NIMCALL(tnode224816*, getpragmastmt_547017)(tnode224816* n, NU8 w);
static N_INLINE(NI, len_225364)(tnode224816* n);
static N_INLINE(tnode224816*, HEX5BHEX5D_225698)(tnode224816* n, NI i);
N_NIMCALL(NU8, whichpragma_261304)(tnode224816* n);
N_NIMCALL(void, app_176052)(trope176009** a, trope176009* b);
N_NIMCALL(trope176009*, torope_176076)(NimStringDesc* s);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newlen);
STRING_LITERAL(TMP3354, "GetUniqueType", 13);
STRING_LITERAL(TMP3361, "N", 1);
STRING_LITERAL(TMP3362, "HEX", 3);
STRING_LITERAL(TMP3453, "\"", 1);
STRING_LITERAL(TMP3964, "c\"", 2);
STRING_LITERAL(TMP3965, "\\00\"", 4);
extern NIM_CONST TY173481 cpu_173480;
TY547278 gtypetable_547281;
TY281060 gcanonicaltypes_547285;
extern tgcheap47016 gch_47044;
extern NU8 targetcpu_173587;

N_NIMCALL(void, inittypetables_547291)(void) {
	{
		NU8 i_547341;
		NU8 res_547348;
		i_547341 = 0;
		res_547348 = ((NU8) 0);
		{
			while (1) {
				if (!(res_547348 <= ((NU8) 61))) goto LA3;
				i_547341 = res_547348;
				initidtable_225167((&gtypetable_547281[(i_547341)- 0]));
				res_547348 += 1;
			} LA3: ;
		}
	}
}

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

static N_INLINE(NI, sonslen_225255)(ttype224852* n) {
	NI result;
	result = 0;
	{
		if (!(*n).Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).Sons->Sup.len;
	}
	LA1: ;
	return result;
}

static N_INLINE(ttype224852*, lastson_225267)(ttype224852* n) {
	ttype224852* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = sonslen_225255(n);
	result = (*n).Sons->data[(NI64)(LOC1 - 1)];
	return result;
}

N_NIMCALL(ttype224852*, getuniquetype_547401)(ttype224852* key) {
	ttype224852* result;
	NU8 k;
	result = 0;
	{
		if (!(key == NIM_NIL)) goto LA3;
		goto BeforeRet;
	}
	LA3: ;
	k = (*key).Kind;
	switch (k) {
	case ((NU8) 1):
	case ((NU8) 2):
	case ((NU8) 31) ... ((NU8) 44):
	{
		result = key;
	}
	break;
	case ((NU8) 3):
	case ((NU8) 5):
	case ((NU8) 6):
	case ((NU8) 7):
	case ((NU8) 26):
	case ((NU8) 28):
	case ((NU8) 29):
	case ((NU8) 0):
	case ((NU8) 45):
	{
		result = gcanonicaltypes_547285[(k)- 0];
		{
			if (!(result == NIM_NIL)) goto LA9;
			asgnRefNoCycle((void**) (&gcanonicaltypes_547285[(k)- 0]), key);
			result = key;
		}
		LA9: ;
	}
	break;
	case ((NU8) 8):
	case ((NU8) 51):
	case ((NU8) 12):
	case ((NU8) 60):
	case ((NU8) 61):
	case ((NU8) 54):
	case ((NU8) 52):
	case ((NU8) 53):
	case ((NU8) 55):
	case ((NU8) 56):
	case ((NU8) 57):
	case ((NU8) 58):
	{
		internalerror_197006(((NimStringDesc*) &TMP3354));
	}
	break;
	case ((NU8) 13):
	{
		{
			if (!!(((*key).Deepcopy == NIM_NIL))) goto LA15;
			result = key;
		}
		goto LA13;
		LA15: ;
		{
			ttype224852* LOC18;
			LOC18 = 0;
			LOC18 = lastson_225267(key);
			result = getuniquetype_547401(LOC18);
		}
		LA13: ;
	}
	break;
	case ((NU8) 11):
	case ((NU8) 15):
	case ((NU8) 47):
	case ((NU8) 46):
	case ((NU8) 49):
	case ((NU8) 59):
	{
		ttype224852* LOC20;
		LOC20 = 0;
		LOC20 = lastson_225267(key);
		result = getuniquetype_547401(LOC20);
	}
	break;
	case ((NU8) 4):
	case ((NU8) 9):
	case ((NU8) 10):
	case ((NU8) 27):
	case ((NU8) 16):
	case ((NU8) 19):
	case ((NU8) 20):
	case ((NU8) 18):
	case ((NU8) 21):
	case ((NU8) 22):
	case ((NU8) 24):
	case ((NU8) 30):
	case ((NU8) 48):
	case ((NU8) 50):
	case ((NU8) 23):
	{
		tidobj199015* LOC37;
		TNimObject* LOC38;
		{
			tidobj199015* LOC24;
			NIM_BOOL LOC25;
			LOC24 = 0;
			LOC24 = &key->Sup;
			LOC25 = 0;
			LOC25 = idtablehasobjectaskey_234205(gtypetable_547281[(k)- 0], LOC24);
			if (!LOC25) goto LA26;
			result = key;
			goto BeforeRet;
		}
		LA26: ;
		{
			NI h_547469;
			NI HEX3Atmp_547612;
			NI res_547615;
			h_547469 = 0;
			HEX3Atmp_547612 = 0;
			HEX3Atmp_547612 = (gtypetable_547281[(k)- 0].Data->Sup.len-1);
			res_547615 = 0;
			{
				while (1) {
					ttype224852* t;
					if (!(res_547615 <= HEX3Atmp_547612)) goto LA30;
					h_547469 = res_547615;
					t = ((ttype224852*) (gtypetable_547281[(k)- 0].Data->data[h_547469].Key));
					{
						NIM_BOOL LOC33;
						LOC33 = 0;
						LOC33 = !((t == NIM_NIL));
						if (!(LOC33)) goto LA34;
						LOC33 = samebackendtype_269542(t, key);
						LA34: ;
						if (!LOC33) goto LA35;
						result = t;
						goto BeforeRet;
					}
					LA35: ;
					res_547615 += 1;
				} LA30: ;
			}
		}
		LOC37 = 0;
		LOC37 = &key->Sup;
		LOC38 = 0;
		LOC38 = &key->Sup.Sup;
		idtableput_234196((&gtypetable_547281[(k)- 0]), LOC37, LOC38);
		result = key;
	}
	break;
	case ((NU8) 17):
	{
		{
			tidobj199015* LOC44;
			TNimObject* LOC45;
			if (!!((((*key).Flags &(1<<((((NU8) 8))&31)))!=0))) goto LA42;
			LOC44 = 0;
			LOC44 = &key->Sup;
			LOC45 = 0;
			LOC45 = idtableget_234182(gtypetable_547281[(k)- 0], LOC44);
			result = ((ttype224852*) (LOC45));
			{
				tidobj199015* LOC50;
				TNimObject* LOC51;
				if (!(result == NIM_NIL)) goto LA48;
				LOC50 = 0;
				LOC50 = &key->Sup;
				LOC51 = 0;
				LOC51 = &key->Sup.Sup;
				idtableput_234196((&gtypetable_547281[(k)- 0]), LOC50, LOC51);
				result = key;
			}
			LA48: ;
		}
		goto LA40;
		LA42: ;
		{
			tidobj199015* LOC68;
			TNimObject* LOC69;
			{
				tidobj199015* LOC55;
				NIM_BOOL LOC56;
				LOC55 = 0;
				LOC55 = &key->Sup;
				LOC56 = 0;
				LOC56 = idtablehasobjectaskey_234205(gtypetable_547281[(k)- 0], LOC55);
				if (!LOC56) goto LA57;
				result = key;
				goto BeforeRet;
			}
			LA57: ;
			{
				NI h_547532;
				NI HEX3Atmp_547618;
				NI res_547621;
				h_547532 = 0;
				HEX3Atmp_547618 = 0;
				HEX3Atmp_547618 = (gtypetable_547281[(k)- 0].Data->Sup.len-1);
				res_547621 = 0;
				{
					while (1) {
						ttype224852* t;
						if (!(res_547621 <= HEX3Atmp_547618)) goto LA61;
						h_547532 = res_547621;
						t = ((ttype224852*) (gtypetable_547281[(k)- 0].Data->data[h_547532].Key));
						{
							NIM_BOOL LOC64;
							LOC64 = 0;
							LOC64 = !((t == NIM_NIL));
							if (!(LOC64)) goto LA65;
							LOC64 = sametype_267351(t, key, 0);
							LA65: ;
							if (!LOC64) goto LA66;
							result = t;
							goto BeforeRet;
						}
						LA66: ;
						res_547621 += 1;
					} LA61: ;
				}
			}
			LOC68 = 0;
			LOC68 = &key->Sup;
			LOC69 = 0;
			LOC69 = &key->Sup.Sup;
			idtableput_234196((&gtypetable_547281[(k)- 0]), LOC68, LOC69);
			result = key;
		}
		LA40: ;
	}
	break;
	case ((NU8) 14):
	{
		tidobj199015* LOC71;
		TNimObject* LOC72;
		LOC71 = 0;
		LOC71 = &key->Sup;
		LOC72 = 0;
		LOC72 = idtableget_234182(gtypetable_547281[(k)- 0], LOC71);
		result = ((ttype224852*) (LOC72));
		{
			tidobj199015* LOC77;
			TNimObject* LOC78;
			if (!(result == NIM_NIL)) goto LA75;
			LOC77 = 0;
			LOC77 = &key->Sup;
			LOC78 = 0;
			LOC78 = &key->Sup.Sup;
			idtableput_234196((&gtypetable_547281[(k)- 0]), LOC77, LOC78);
			result = key;
		}
		LA75: ;
	}
	break;
	case ((NU8) 25):
	{
		{
			if (!!(((*key).Callconv == ((NU8) 8)))) goto LA82;
			result = key;
		}
		goto LA80;
		LA82: ;
		{
			tidobj199015* LOC100;
			TNimObject* LOC101;
			{
				tidobj199015* LOC87;
				NIM_BOOL LOC88;
				LOC87 = 0;
				LOC87 = &key->Sup;
				LOC88 = 0;
				LOC88 = idtablehasobjectaskey_234205(gtypetable_547281[(k)- 0], LOC87);
				if (!LOC88) goto LA89;
				result = key;
				goto BeforeRet;
			}
			LA89: ;
			{
				NI h_547591;
				NI HEX3Atmp_547624;
				NI res_547627;
				h_547591 = 0;
				HEX3Atmp_547624 = 0;
				HEX3Atmp_547624 = (gtypetable_547281[(k)- 0].Data->Sup.len-1);
				res_547627 = 0;
				{
					while (1) {
						ttype224852* t;
						if (!(res_547627 <= HEX3Atmp_547624)) goto LA93;
						h_547591 = res_547627;
						t = ((ttype224852*) (gtypetable_547281[(k)- 0].Data->data[h_547591].Key));
						{
							NIM_BOOL LOC96;
							LOC96 = 0;
							LOC96 = !((t == NIM_NIL));
							if (!(LOC96)) goto LA97;
							LOC96 = samebackendtype_269542(t, key);
							LA97: ;
							if (!LOC96) goto LA98;
							result = t;
							goto BeforeRet;
						}
						LA98: ;
						res_547627 += 1;
					} LA93: ;
				}
			}
			LOC100 = 0;
			LOC100 = &key->Sup;
			LOC101 = 0;
			LOC101 = &key->Sup.Sup;
			idtableput_234196((&gtypetable_547281[(k)- 0]), LOC100, LOC101);
			result = key;
		}
		LA80: ;
	}
	break;
	}
	BeforeRet: ;
	return result;
}

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

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*, mangle_547763)(NimStringDesc* name) {
	NimStringDesc* result;
	result = 0;
	result = rawNewString(name->Sup.len);
	switch (((NU8)(name->data[0]))) {
	case 65 ... 90:
	case 97 ... 122:
	{
		NIM_CHAR LOC2;
		LOC2 = 0;
		LOC2 = nsuToLowerChar(name->data[0]);
		result = addChar(result, LOC2);
	}
	break;
	case 48 ... 57:
	{
		NimStringDesc* LOC4;
		LOC4 = 0;
		LOC4 = rawNewString(2);
appendString(LOC4, ((NimStringDesc*) &TMP3361));
appendChar(LOC4, name->data[0]);
		result = resizeString(result, LOC4->Sup.len + 0);
appendString(result, LOC4);
	}
	break;
	default:
	{
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		LOC6 = 0;
		LOC7 = 0;
		LOC7 = nsuToHex(((NI64) (((NU8)(name->data[0])))), 2);
		LOC6 = rawNewString(LOC7->Sup.len + 3);
appendString(LOC6, ((NimStringDesc*) &TMP3362));
appendString(LOC6, LOC7);
		result = LOC6;
	}
	break;
	}
	{
		NI i_547785;
		NI HEX3Atmp_547796;
		NI res_547799;
		i_547785 = 0;
		HEX3Atmp_547796 = 0;
		HEX3Atmp_547796 = (NI64)(name->Sup.len - 1);
		res_547799 = 1;
		{
			while (1) {
				NIM_CHAR c;
				if (!(res_547799 <= HEX3Atmp_547796)) goto LA10;
				i_547785 = res_547799;
				c = name->data[i_547785];
				switch (((NU8)(c))) {
				case 65 ... 90:
				{
					NIM_CHAR LOC12;
					LOC12 = 0;
					LOC12 = nsuToLowerChar(c);
					result = addChar(result, LOC12);
				}
				break;
				case 95:
				{
				}
				break;
				case 97 ... 122:
				case 48 ... 57:
				{
					result = addChar(result, c);
				}
				break;
				default:
				{
					NimStringDesc* LOC16;
					NimStringDesc* LOC17;
					LOC16 = 0;
					LOC17 = 0;
					LOC17 = nsuToHex(((NI64) (((NU8)(c)))), 2);
					LOC16 = rawNewString(LOC17->Sup.len + 3);
appendString(LOC16, ((NimStringDesc*) &TMP3362));
appendString(LOC16, LOC17);
					result = resizeString(result, LOC16->Sup.len + 0);
appendString(result, LOC16);
				}
				break;
				}
				res_547799 += 1;
			} LA10: ;
		}
	}
	return result;
}

N_NIMCALL(NimStringDesc*, makesinglelinecstring_547737)(NimStringDesc* s) {
	NimStringDesc* result;
	result = 0;
	result = copyString(((NimStringDesc*) &TMP3453));
	{
		NIM_CHAR c_547741;
		NI i_547745;
		NI l_547747;
		c_547741 = 0;
		i_547745 = 0;
		l_547747 = s->Sup.len;
		{
			while (1) {
				NimStringDesc* LOC4;
				if (!(i_547745 < l_547747)) goto LA3;
				c_547741 = s->data[i_547745];
				LOC4 = 0;
				LOC4 = tocchar_194649(c_547741);
				result = resizeString(result, LOC4->Sup.len + 0);
appendString(result, LOC4);
				i_547745 += 1;
			} LA3: ;
		}
	}
	result = addChar(result, 34);
	return result;
}

static N_INLINE(NI, len_225364)(tnode224816* n) {
	NI result;
	result = 0;
	{
		if (!(*n).kindU.S6.Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).kindU.S6.Sons->Sup.len;
	}
	LA1: ;
	return result;
}

static N_INLINE(tnode224816*, HEX5BHEX5D_225698)(tnode224816* n, NI i) {
	tnode224816* result;
	result = 0;
	result = (*n).kindU.S6.Sons->data[i];
	return result;
}

N_NIMCALL(tnode224816*, getpragmastmt_547017)(tnode224816* n, NU8 w) {
	tnode224816* result;
	result = 0;
	switch ((*n).Kind) {
	case ((NU8) 115):
	{
		{
			NI i_547043;
			NI HEX3Atmp_547093;
			NI LOC3;
			NI res_547096;
			i_547043 = 0;
			HEX3Atmp_547093 = 0;
			LOC3 = 0;
			LOC3 = len_225364(n);
			HEX3Atmp_547093 = (LOC3 - 1);
			res_547096 = 0;
			{
				while (1) {
					tnode224816* LOC6;
					if (!(res_547096 <= HEX3Atmp_547093)) goto LA5;
					i_547043 = res_547096;
					LOC6 = 0;
					LOC6 = HEX5BHEX5D_225698(n, i_547043);
					result = getpragmastmt_547017(LOC6, w);
					{
						if (!!((result == NIM_NIL))) goto LA9;
						goto LA2;
					}
					LA9: ;
					res_547096 += 1;
				} LA5: ;
			}
		} LA2: ;
	}
	break;
	case ((NU8) 90):
	{
		{
			NI i_547082;
			NI HEX3Atmp_547099;
			NI LOC13;
			NI res_547102;
			i_547082 = 0;
			HEX3Atmp_547099 = 0;
			LOC13 = 0;
			LOC13 = len_225364(n);
			HEX3Atmp_547099 = (LOC13 - 1);
			res_547102 = 0;
			{
				while (1) {
					if (!(res_547102 <= HEX3Atmp_547099)) goto LA15;
					i_547082 = res_547102;
					{
						tnode224816* LOC18;
						NU8 LOC19;
						LOC18 = 0;
						LOC18 = HEX5BHEX5D_225698(n, i_547082);
						LOC19 = 0;
						LOC19 = whichpragma_261304(LOC18);
						if (!(LOC19 == w)) goto LA20;
						result = HEX5BHEX5D_225698(n, i_547082);
						goto BeforeRet;
					}
					LA20: ;
					res_547102 += 1;
				} LA15: ;
			}
		}
	}
	break;
	default:
	{
	}
	break;
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, stmtscontainpragma_547128)(tnode224816* n, NU8 w) {
	NIM_BOOL result;
	tnode224816* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = getpragmastmt_547017(n, w);
	result = !((LOC1 == NIM_NIL));
	return result;
}

N_NIMCALL(trope176009*, makellvmstring_547816)(NimStringDesc* s) {
	trope176009* result;
	NimStringDesc* res;
	trope176009* LOC12;
	result = 0;
	result = NIM_NIL;
	res = copyString(((NimStringDesc*) &TMP3964));
	{
		NI i_547834;
		NI HEX3Atmp_547847;
		NI res_547850;
		i_547834 = 0;
		HEX3Atmp_547847 = 0;
		HEX3Atmp_547847 = (NI64)(s->Sup.len - 1);
		res_547850 = 0;
		{
			while (1) {
				if (!(res_547850 <= HEX3Atmp_547847)) goto LA3;
				i_547834 = res_547850;
				{
					trope176009* LOC8;
					if (!(((NI) ((NI64)((NI64)(i_547834 + 1) % 64))) == 0)) goto LA6;
					LOC8 = 0;
					LOC8 = torope_176076(res);
					app_176052(&result, LOC8);
					res = setLengthStr(res, 0);
				}
				LA6: ;
				switch (((NU8)(s->data[i_547834]))) {
				case 0 ... 31:
				case 128 ... 255:
				case 34:
				case 92:
				{
					NimStringDesc* LOC10;
					res = addChar(res, 92);
					LOC10 = 0;
					LOC10 = nsuToHex(((NI64) (((NU8)(s->data[i_547834])))), 2);
					res = resizeString(res, LOC10->Sup.len + 0);
appendString(res, LOC10);
				}
				break;
				default:
				{
					res = addChar(res, s->data[i_547834]);
				}
				break;
				}
				res_547850 += 1;
			} LA3: ;
		}
	}
	res = resizeString(res, 4);
appendString(res, ((NimStringDesc*) &TMP3965));
	LOC12 = 0;
	LOC12 = torope_176076(res);
	app_176052(&result, LOC12);
	return result;
}

N_NIMCALL(NI64, hashstring_547156)(NimStringDesc* s) {
	NI64 result;
	result = 0;
	{
		NI64 b;
		if (!(cpu_173480[(targetcpu_173587)- 1].Field4 == 64)) goto LA3;
		b = IL64(0);
		{
			NI i_547173;
			NI HEX3Atmp_547242;
			NI res_547245;
			i_547173 = 0;
			HEX3Atmp_547242 = 0;
			HEX3Atmp_547242 = (NI64)(s->Sup.len - 1);
			res_547245 = 0;
			{
				while (1) {
					if (!(res_547245 <= HEX3Atmp_547242)) goto LA7;
					i_547173 = res_547245;
					b = (NI64)((NU64)(b) + (NU64)(((NI64) (((NU8)(s->data[i_547173]))))));
					b = (NI64)((NU64)(b) + (NU64)((NI64)((NU64)(b) << (NU64)(IL64(10)))));
					b = (NI64)(b ^ (NI64)((NU64)(b) >> (NU64)(IL64(6))));
					res_547245 += 1;
				} LA7: ;
			}
		}
		b = (NI64)((NU64)(b) + (NU64)((NI64)((NU64)(b) << (NU64)(IL64(3)))));
		b = (NI64)(b ^ (NI64)((NU64)(b) >> (NU64)(IL64(11))));
		b = (NI64)((NU64)(b) + (NU64)((NI64)((NU64)(b) << (NU64)(IL64(15)))));
		result = b;
	}
	goto LA1;
	LA3: ;
	{
		NI32 a;
		a = ((NI32) 0);
		{
			NI i_547195;
			NI HEX3Atmp_547249;
			NI res_547252;
			i_547195 = 0;
			HEX3Atmp_547249 = 0;
			HEX3Atmp_547249 = (NI64)(s->Sup.len - 1);
			res_547252 = 0;
			{
				while (1) {
					if (!(res_547252 <= HEX3Atmp_547249)) goto LA11;
					i_547195 = res_547252;
					a = (NI32)((NU32)(a) + (NU32)(((NI32) (((NU8)(s->data[i_547195]))))));
					a = (NI32)((NU32)(a) + (NU32)((NI32)((NU32)(a) << (NU32)(((NI32) 10)))));
					a = (NI32)(a ^ (NI32)((NU32)(a) >> (NU32)(((NI32) 6))));
					res_547252 += 1;
				} LA11: ;
			}
		}
		a = (NI32)((NU32)(a) + (NU32)((NI32)((NU32)(a) << (NU32)(((NI32) 3)))));
		a = (NI32)(a ^ (NI32)((NU32)(a) >> (NU32)(((NI32) 11))));
		a = (NI32)((NU32)(a) + (NU32)((NI32)((NU32)(a) << (NU32)(((NI32) 15)))));
		result = ((NI64) (a));
	}
	LA1: ;
	return result;
}

N_NIMCALL(void, resetcaches_547365)(void) {
	inittypetables_547291();
	{
		NU8 i_547377;
		NU8 res_547381;
		i_547377 = 0;
		res_547381 = ((NU8) 0);
		{
			while (1) {
				if (!(res_547381 <= ((NU8) 61))) goto LA3;
				i_547377 = res_547381;
				asgnRefNoCycle((void**) (&gcanonicaltypes_547285[(i_547377)- 0]), NIM_NIL);
				res_547381 += 1;
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, HEX00_ccgutilsInit)(void) {
	inittypetables_547291();
}

NIM_EXTERNC N_NOINLINE(void, HEX00_ccgutilsDatInit)(void) {
}

