/* Generated by Nim Compiler v0.13.0 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32

#include "nimbase.h"
typedef struct Tident188012 Tident188012;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Tidobj188006 Tidobj188006;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Cell47705 Cell47705;
typedef struct Cellseq47721 Cellseq47721;
typedef struct Gcheap50018 Gcheap50018;
typedef struct Gcstack50016 Gcstack50016;
typedef struct Cellset47717 Cellset47717;
typedef struct Pagedesc47713 Pagedesc47713;
typedef struct Memregion29887 Memregion29887;
typedef struct Smallchunk29839 Smallchunk29839;
typedef struct Llchunk29881 Llchunk29881;
typedef struct Bigchunk29841 Bigchunk29841;
typedef struct Intset29814 Intset29814;
typedef struct Trunk29810 Trunk29810;
typedef struct Avlnode29885 Avlnode29885;
typedef struct Gcstat50014 Gcstat50014;
typedef struct Basechunk29837 Basechunk29837;
typedef struct Freecell29829 Freecell29829;
typedef Tident188012* TY188023[8192];
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY3489) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Tidobj188006  {
  TNimObject Sup;
NI id;
};
struct  Tident188012  {
  Tidobj188006 Sup;
NimStringDesc* s;
Tident188012* next;
NI h;
};
struct  Cell47705  {
NI refcount;
TNimType* typ;
};
struct  Cellseq47721  {
NI len;
NI cap;
Cell47705** d;
};
struct  Cellset47717  {
NI counter;
NI max;
Pagedesc47713* head;
Pagedesc47713** data;
};
typedef Smallchunk29839* TY29902[512];
typedef Trunk29810* Trunkbuckets29812[256];
struct  Intset29814  {
Trunkbuckets29812 data;
};
struct  Memregion29887  {
NI minlargeobj;
NI maxlargeobj;
TY29902 freesmallchunks;
Llchunk29881* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk29841* freechunkslist;
Intset29814 chunkstarts;
Avlnode29885* root;
Avlnode29885* deleted;
Avlnode29885* last;
Avlnode29885* freeavlnodes;
};
struct  Gcstat50014  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap50018  {
Gcstack50016* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq47721 zct;
Cellseq47721 decstack;
Cellset47717 cycleroots;
Cellseq47721 tempstack;
NI recgclock;
Memregion29887 region;
Gcstat50014 stat;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Gcstack50016  {
Gcstack50016* prev;
Gcstack50016* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY29818[16];
struct  Pagedesc47713  {
Pagedesc47713* next;
NI key;
TY29818 bits;
};
struct  Basechunk29837  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk29839  {
  Basechunk29837 Sup;
Smallchunk29839* next;
Smallchunk29839* prev;
Freecell29829* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk29881  {
NI size;
NI acc;
Llchunk29881* next;
};
struct  Bigchunk29841  {
  Basechunk29837 Sup;
Bigchunk29841* next;
Bigchunk29841* prev;
NI align;
NF data;
};
struct  Trunk29810  {
Trunk29810* next;
NI key;
TY29818 bits;
};
typedef Avlnode29885* TY29892[2];
struct  Avlnode29885  {
TY29892 link;
NI key;
NI upperbound;
NI level;
};
struct  Freecell29829  {
Freecell29829* next;
NI zerofield;
};
N_NIMCALL(Tident188012*, getident_188441)(NimStringDesc* identifier);
N_NIMCALL(Tident188012*, getident_188211)(NCSTRING identifier, NI length, NI h);
N_NIMCALL(NI, cmpexact_188165)(NCSTRING a, NCSTRING b, NI blen);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Cell47705*, usrtocell_51640)(void* usr);
static N_INLINE(void, rtladdzct_53201)(Cell47705* c);
N_NOINLINE(void, addzct_51617)(Cellseq47721* s, Cell47705* c);
N_NIMCALL(NI, cmpignorestyle_188026)(NCSTRING a, NCSTRING b, NI blen);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_136008)(NCSTRING cs, NI i);
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP513)(void* p, NI op);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_NIMCALL(NI, hashignorestyle_137892)(NimStringDesc* x);
N_NIMCALL(void, TMP916)(void* p, NI op);
STRING_LITERAL(TMP514, ":anonymous", 10);
STRING_LITERAL(TMP515, ":delegator", 10);
NIM_BOOL firstchariscs_188017;
TY188023 buckets_188024;
NI wordcounter_188210;
Tident188012* idanon_188455;
extern Gcheap50018 gch_50059;
extern TNimType NTI3608; /* RootObj */
TNimType NTI188006; /* TIdObj */
extern TNimType NTI104; /* int */
TNimType NTI188012; /* TIdent */
extern TNimType NTI138; /* string */
extern TNimType NTI137002; /* Hash */
TNimType NTI188010; /* PIdent */
Tident188012* iddelegator_188456;
TNimType NTI188008; /* PIdObj */

N_NIMCALL(NI, cmpexact_188165)(NCSTRING a, NCSTRING b, NI blen) {
	NI result;
	NI i;
	NI j;
	result = 0;
	i = ((NI) 0);
	j = ((NI) 0);
	result = ((NI) 1);
	{
		while (1) {
			NIM_CHAR aa;
			NIM_CHAR bb;
			if (!(j < blen)) goto LA2;
			aa = a[i];
			bb = b[j];
			result = (NI)(((NI) (((NU8)(aa)))) - ((NI) (((NU8)(bb)))));
			{
				NIM_BOOL LOC5;
				LOC5 = 0;
				LOC5 = !((result == ((NI) 0)));
				if (LOC5) goto LA6;
				LOC5 = ((NU8)(aa) == (NU8)(0));
				LA6: ;
				if (!LOC5) goto LA7;
				goto LA1;
			}
			LA7: ;
			i += ((NI) 1);
			j += ((NI) 1);
		} LA2: ;
	} LA1: ;
	{
		if (!(result == ((NI) 0))) goto LA11;
		{
			if (!!(((NU8)(a[i]) == (NU8)(0)))) goto LA15;
			result = ((NI) 1);
		}
		LA15: ;
	}
	LA11: ;
	return result;
}

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

static N_INLINE(void, rtladdzct_53201)(Cell47705* c) {
	addzct_51617((&gch_50059.zct), c);
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Cell47705* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_51640(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell47705* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_51640((*dest));
		{
			(*c).refcount -= ((NI) 8);
			if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA11;
			rtladdzct_53201(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_136008)(NCSTRING cs, NI i) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	NIM_BOOL LOC2;
	result = 0;
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = ((NU8)(cs[i]) == (NU8)(226));
	if (!(LOC2)) goto LA3;
	LOC2 = ((NU8)(cs[(NI)(i + ((NI) 1))]) == (NU8)(128));
	LA3: ;
	LOC1 = LOC2;
	if (!(LOC1)) goto LA4;
	LOC1 = ((NU8)(cs[(NI)(i + ((NI) 2))]) == (NU8)(147));
	LA4: ;
	result = LOC1;
	return result;
}

N_NIMCALL(NI, cmpignorestyle_188026)(NCSTRING a, NCSTRING b, NI blen) {
	NI result;
	NI i;
	NI j;
{	result = 0;
	{
		if (!firstchariscs_188017) goto LA3;
		{
			if (!!(((NU8)(a[((NI) 0)]) == (NU8)(b[((NI) 0)])))) goto LA7;
			result = ((NI) 1);
			goto BeforeRet;
		}
		LA7: ;
	}
	LA3: ;
	i = ((NI) 0);
	j = ((NI) 0);
	result = ((NI) 1);
	{
		while (1) {
			NIM_CHAR aa;
			NIM_CHAR bb;
			if (!(j < blen)) goto LA10;
			{
				while (1) {
					if (!((NU8)(a[i]) == (NU8)(95))) goto LA12;
					i += ((NI) 1);
				} LA12: ;
			}
			{
				while (1) {
					if (!((NU8)(b[j]) == (NU8)(95))) goto LA14;
					j += ((NI) 1);
				} LA14: ;
			}
			{
				while (1) {
					NIM_BOOL LOC17;
					LOC17 = 0;
					LOC17 = ismagicidentseparatorrune_136008(a, i);
					if (!LOC17) goto LA16;
					i += ((NI) 3);
				} LA16: ;
			}
			{
				while (1) {
					NIM_BOOL LOC20;
					LOC20 = 0;
					LOC20 = ismagicidentseparatorrune_136008(b, j);
					if (!LOC20) goto LA19;
					j += ((NI) 3);
				} LA19: ;
			}
			aa = a[i];
			bb = b[j];
			{
				NIM_BOOL LOC23;
				LOC23 = 0;
				LOC23 = ((NU8)(65) <= (NU8)(aa));
				if (!(LOC23)) goto LA24;
				LOC23 = ((NU8)(aa) <= (NU8)(90));
				LA24: ;
				if (!LOC23) goto LA25;
				aa = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(aa)))) + ((NI) 32))))));
			}
			LA25: ;
			{
				NIM_BOOL LOC29;
				LOC29 = 0;
				LOC29 = ((NU8)(65) <= (NU8)(bb));
				if (!(LOC29)) goto LA30;
				LOC29 = ((NU8)(bb) <= (NU8)(90));
				LA30: ;
				if (!LOC29) goto LA31;
				bb = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(bb)))) + ((NI) 32))))));
			}
			LA31: ;
			result = (NI)(((NI) (((NU8)(aa)))) - ((NI) (((NU8)(bb)))));
			{
				NIM_BOOL LOC35;
				LOC35 = 0;
				LOC35 = !((result == ((NI) 0)));
				if (LOC35) goto LA36;
				LOC35 = ((NU8)(aa) == (NU8)(0));
				LA36: ;
				if (!LOC35) goto LA37;
				goto LA9;
			}
			LA37: ;
			i += ((NI) 1);
			j += ((NI) 1);
		} LA10: ;
	} LA9: ;
	{
		if (!(result == ((NI) 0))) goto LA41;
		{
			if (!!(((NU8)(a[i]) == (NU8)(0)))) goto LA45;
			result = ((NI) 1);
		}
		LA45: ;
	}
	LA41: ;
	}BeforeRet: ;
	return result;
}
N_NIMCALL(void, TMP513)(void* p, NI op) {
	Tident188012* a;
	a = (Tident188012*)p;
	nimGCvisit((void*)(*a).s, op);
	nimGCvisit((void*)(*a).next, op);
}

N_NIMCALL(Tident188012*, getident_188211)(NCSTRING identifier, NI length, NI h) {
	Tident188012* result;
	NI idx;
	Tident188012* last;
	NI id;
{	result = 0;
	idx = (NI)(h & ((NI) 8191));
	result = buckets_188024[(idx)- 0];
	last = NIM_NIL;
	id = ((NI) 0);
	{
		while (1) {
			if (!!((result == NIM_NIL))) goto LA2;
			{
				NI LOC5;
				LOC5 = 0;
				LOC5 = cmpexact_188165((*result).s->data, identifier, length);
				if (!(LOC5 == ((NI) 0))) goto LA6;
				{
					if (!!((last == NIM_NIL))) goto LA10;
					asgnRefNoCycle((void**) (&(*last).next), (*result).next);
					asgnRefNoCycle((void**) (&(*result).next), buckets_188024[(idx)- 0]);
					asgnRefNoCycle((void**) (&buckets_188024[(idx)- 0]), result);
				}
				LA10: ;
				goto BeforeRet;
			}
			goto LA3;
			LA6: ;
			{
				NI LOC13;
				LOC13 = 0;
				LOC13 = cmpignorestyle_188026((*result).s->data, identifier, length);
				if (!(LOC13 == ((NI) 0))) goto LA14;
				id = (*result).Sup.id;
			}
			goto LA3;
			LA14: ;
			LA3: ;
			last = result;
			result = (*result).next;
		} LA2: ;
	}
	result = (Tident188012*) newObj((&NTI188010), sizeof(Tident188012));
	(*result).Sup.Sup.m_type = (&NTI188012);
	(*result).h = h;
	asgnRefNoCycle((void**) (&(*result).s), mnewString(((NI) (length))));
	{
		NI i_188420;
		NI HEX3Atmp_188434;
		NI res_188437;
		i_188420 = 0;
		HEX3Atmp_188434 = 0;
		HEX3Atmp_188434 = (NI)(length - ((NI) 1));
		res_188437 = ((NI) 0);
		{
			while (1) {
				if (!(res_188437 <= HEX3Atmp_188434)) goto LA18;
				i_188420 = res_188437;
				(*result).s->data[i_188420] = identifier[i_188420];
				res_188437 += ((NI) 1);
			} LA18: ;
		}
	}
	asgnRefNoCycle((void**) (&(*result).next), buckets_188024[(idx)- 0]);
	asgnRefNoCycle((void**) (&buckets_188024[(idx)- 0]), result);
	{
		if (!(id == ((NI) 0))) goto LA21;
		wordcounter_188210 += ((NI) 1);
		(*result).Sup.id = ((NI32)-(wordcounter_188210));
	}
	goto LA19;
	LA21: ;
	{
		(*result).Sup.id = id;
	}
	LA19: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tident188012*, getident_188441)(NimStringDesc* identifier) {
	Tident188012* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = hashignorestyle_137892(identifier);
	result = getident_188211(identifier->data, (identifier ? identifier->Sup.len : 0), LOC1);
	return result;
}

N_NIMCALL(Tident188012*, getident_188445)(NimStringDesc* identifier, NI h) {
	Tident188012* result;
	result = 0;
	result = getident_188211(identifier->data, (identifier ? identifier->Sup.len : 0), h);
	return result;
}
N_NIMCALL(void, TMP916)(void* p, NI op) {
	Tidobj188006* a;
	a = (Tidobj188006*)p;
}

N_NIMCALL(NIM_BOOL, identeq_188450)(Tident188012* id, NimStringDesc* name) {
	NIM_BOOL result;
	Tident188012* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = getident_188441(name);
	result = ((*id).Sup.id == (*LOC1).Sup.id);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_identsInit000)(void) {
	firstchariscs_188017 = NIM_TRUE;
	wordcounter_188210 = ((NI) 1);
	asgnRefNoCycle((void**) (&idanon_188455), getident_188441(((NimStringDesc*) &TMP514)));
	asgnRefNoCycle((void**) (&iddelegator_188456), getident_188441(((NimStringDesc*) &TMP515)));
}

NIM_EXTERNC N_NOINLINE(void, compiler_identsDatInit000)(void) {
static TNimNode* TMP512[3];
static TNimNode TMP510[5];
NTI188006.size = sizeof(Tidobj188006);
NTI188006.kind = 17;
NTI188006.base = (&NTI3608);
NTI188006.flags = 1;
TMP510[0].kind = 1;
TMP510[0].offset = offsetof(Tidobj188006, id);
TMP510[0].typ = (&NTI104);
TMP510[0].name = "id";
NTI188006.node = &TMP510[0];
NTI188012.size = sizeof(Tident188012);
NTI188012.kind = 17;
NTI188012.base = (&NTI188006);
NTI188012.flags = 2;
TMP512[0] = &TMP510[2];
TMP510[2].kind = 1;
TMP510[2].offset = offsetof(Tident188012, s);
TMP510[2].typ = (&NTI138);
TMP510[2].name = "s";
TMP512[1] = &TMP510[3];
TMP510[3].kind = 1;
TMP510[3].offset = offsetof(Tident188012, next);
TMP510[3].typ = (&NTI188010);
TMP510[3].name = "next";
TMP512[2] = &TMP510[4];
TMP510[4].kind = 1;
TMP510[4].offset = offsetof(Tident188012, h);
TMP510[4].typ = (&NTI137002);
TMP510[4].name = "h";
TMP510[1].len = 3; TMP510[1].kind = 2; TMP510[1].sons = &TMP512[0];
NTI188012.node = &TMP510[1];
NTI188010.size = sizeof(Tident188012*);
NTI188010.kind = 22;
NTI188010.base = (&NTI188012);
NTI188010.flags = 2;
NTI188010.marker = TMP513;
NTI188008.size = sizeof(Tidobj188006*);
NTI188008.kind = 22;
NTI188008.base = (&NTI188006);
NTI188008.marker = TMP916;
}

