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

#include "nimbase.h"
typedef struct Tident198021 Tident198021;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Tidobj198015 Tidobj198015;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Cell49147 Cell49147;
typedef struct Cellseq49163 Cellseq49163;
typedef struct Gcheap51218 Gcheap51218;
typedef struct Gcstack51216 Gcstack51216;
typedef struct Cellset49159 Cellset49159;
typedef struct Pagedesc49155 Pagedesc49155;
typedef struct Memregion31090 Memregion31090;
typedef struct Smallchunk31042 Smallchunk31042;
typedef struct Llchunk31084 Llchunk31084;
typedef struct Bigchunk31044 Bigchunk31044;
typedef struct Intset31017 Intset31017;
typedef struct Trunk31013 Trunk31013;
typedef struct Avlnode31088 Avlnode31088;
typedef struct Gcstat51214 Gcstat51214;
typedef struct Basechunk31040 Basechunk31040;
typedef struct Freecell31032 Freecell31032;
typedef Tident198021* TY198038[8192];
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3894) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3889 marker;
TY3894 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Tidobj198015  {
  TNimObject Sup;
NI id;
};
struct  Tident198021  {
  Tidobj198015 Sup;
NimStringDesc* s;
Tident198021* next;
NI h;
};
struct  Cell49147  {
NI refcount;
TNimType* typ;
};
struct  Cellseq49163  {
NI len;
NI cap;
Cell49147** d;
};
struct  Cellset49159  {
NI counter;
NI max;
Pagedesc49155* head;
Pagedesc49155** data;
};
typedef Smallchunk31042* TY31105[512];
typedef Trunk31013* Trunkbuckets31015[256];
struct  Intset31017  {
Trunkbuckets31015 data;
};
struct  Memregion31090  {
NI minlargeobj;
NI maxlargeobj;
TY31105 freesmallchunks;
Llchunk31084* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk31044* freechunkslist;
Intset31017 chunkstarts;
Avlnode31088* root;
Avlnode31088* deleted;
Avlnode31088* last;
Avlnode31088* freeavlnodes;
};
struct  Gcstat51214  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap51218  {
Gcstack51216* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq49163 zct;
Cellseq49163 decstack;
Cellset49159 cycleroots;
Cellseq49163 tempstack;
NI recgclock;
Memregion31090 region;
Gcstat51214 stat;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Gcstack51216  {
Gcstack51216* prev;
Gcstack51216* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY31021[16];
struct  Pagedesc49155  {
Pagedesc49155* next;
NI key;
TY31021 bits;
};
struct  Basechunk31040  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk31042  {
  Basechunk31040 Sup;
Smallchunk31042* next;
Smallchunk31042* prev;
Freecell31032* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk31084  {
NI size;
NI acc;
Llchunk31084* next;
};
struct  Bigchunk31044  {
  Basechunk31040 Sup;
Bigchunk31044* next;
Bigchunk31044* prev;
NI align;
NF data;
};
struct  Trunk31013  {
Trunk31013* next;
NI key;
TY31021 bits;
};
typedef Avlnode31088* TY31095[2];
struct  Avlnode31088  {
TY31095 link;
NI key;
NI upperbound;
NI level;
};
struct  Freecell31032  {
Freecell31032* next;
NI zerofield;
};
N_NIMCALL(Tident198021*, getident_198463)(NimStringDesc* identifier);
N_NIMCALL(Tident198021*, getident_198280)(NCSTRING identifier, NI length, NI h);
N_NIMCALL(NI, cmpexact_198219)(NCSTRING a, NCSTRING b, NI blen);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Cell49147*, usrtocell_52846)(void* usr);
static N_INLINE(void, rtladdzct_54404)(Cell49147* c);
N_NOINLINE(void, addzct_52817)(Cellseq49163* s, Cell49147* c);
N_NIMCALL(NI, cmpignorestyle_198044)(NCSTRING a, NCSTRING b, NI blen);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_142029)(NCSTRING cs, NI i);
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP509)(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_143945)(NimStringDesc* x);
N_NIMCALL(void, TMP912)(void* p, NI op);
STRING_LITERAL(TMP510, ":anonymous", 10);
STRING_LITERAL(TMP511, ":delegator", 10);
NIM_BOOL firstchariscs_198029;
TY198038 buckets_198039;
NI wordcounter_198276;
Tident198021* idanon_198495;
extern Gcheap51218 gch_51259;
extern TNimType NTI4011; /* RootObj */
TNimType NTI198015; /* TIdObj */
extern TNimType NTI108; /* int */
TNimType NTI198021; /* TIdent */
extern TNimType NTI149; /* string */
extern TNimType NTI143005; /* Hash */
TNimType NTI198019; /* PIdent */
Tident198021* iddelegator_198562;
TNimType NTI198017; /* PIdObj */

N_NIMCALL(NI, cmpexact_198219)(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(Cell49147*, usrtocell_52846)(void* usr) {
	Cell49147* result;
	result = 0;
	result = ((Cell49147*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(Cell49147))))));
	return result;
}

static N_INLINE(void, rtladdzct_54404)(Cell49147* c) {
	addzct_52817((&gch_51259.zct), c);
}

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

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_142029)(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_198044)(NCSTRING a, NCSTRING b, NI blen) {
	NI result;
	NI i;
	NI j;
{	result = 0;
	{
		if (!firstchariscs_198029) 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_142029(a, i);
					if (!LOC17) goto LA16;
					i += ((NI) 3);
				} LA16: ;
			}
			{
				while (1) {
					NIM_BOOL LOC20;
					LOC20 = 0;
					LOC20 = ismagicidentseparatorrune_142029(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, TMP509)(void* p, NI op) {
	Tident198021* a;
	a = (Tident198021*)p;
	nimGCvisit((void*)(*a).s, op);
	nimGCvisit((void*)(*a).next, op);
}

N_NIMCALL(Tident198021*, getident_198280)(NCSTRING identifier, NI length, NI h) {
	Tident198021* result;
	NI idx;
	Tident198021* last;
	NI id;
{	result = 0;
	idx = (NI)(h & ((NI) 8191));
	result = buckets_198039[(idx)- 0];
	last = NIM_NIL;
	id = ((NI) 0);
	{
		while (1) {
			if (!!((result == NIM_NIL))) goto LA2;
			{
				NI LOC5;
				LOC5 = 0;
				LOC5 = cmpexact_198219((*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_198039[(idx)- 0]);
					asgnRefNoCycle((void**) (&buckets_198039[(idx)- 0]), result);
				}
				LA10: ;
				goto BeforeRet;
			}
			goto LA3;
			LA6: ;
			{
				NI LOC13;
				LOC13 = 0;
				LOC13 = cmpignorestyle_198044((*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 = (Tident198021*) newObj((&NTI198019), sizeof(Tident198021));
	(*result).Sup.Sup.m_type = (&NTI198021);
	(*result).h = h;
	asgnRefNoCycle((void**) (&(*result).s), mnewString(((NI) (length))));
	{
		NI i_198421;
		NI HEX3Atmp_198435;
		NI res_198438;
		i_198421 = 0;
		HEX3Atmp_198435 = 0;
		HEX3Atmp_198435 = (NI)(length - ((NI) 1));
		res_198438 = ((NI) 0);
		{
			while (1) {
				if (!(res_198438 <= HEX3Atmp_198435)) goto LA18;
				i_198421 = res_198438;
				(*result).s->data[i_198421] = identifier[i_198421];
				res_198438 += ((NI) 1);
			} LA18: ;
		}
	}
	asgnRefNoCycle((void**) (&(*result).next), buckets_198039[(idx)- 0]);
	asgnRefNoCycle((void**) (&buckets_198039[(idx)- 0]), result);
	{
		if (!(id == ((NI) 0))) goto LA21;
		wordcounter_198276 += ((NI) 1);
		(*result).Sup.id = ((NI32)-(wordcounter_198276));
	}
	goto LA19;
	LA21: ;
	{
		(*result).Sup.id = id;
	}
	LA19: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tident198021*, getident_198463)(NimStringDesc* identifier) {
	Tident198021* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = hashignorestyle_143945(identifier);
	result = getident_198280(identifier->data, (identifier ? identifier->Sup.len : 0), LOC1);
	return result;
}

N_NIMCALL(Tident198021*, getident_198473)(NimStringDesc* identifier, NI h) {
	Tident198021* result;
	result = 0;
	result = getident_198280(identifier->data, (identifier ? identifier->Sup.len : 0), h);
	return result;
}
N_NIMCALL(void, TMP912)(void* p, NI op) {
	Tidobj198015* a;
	a = (Tidobj198015*)p;
}

N_NIMCALL(NIM_BOOL, identeq_198484)(Tident198021* id, NimStringDesc* name) {
	NIM_BOOL result;
	Tident198021* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = getident_198463(name);
	result = ((*id).Sup.id == (*LOC1).Sup.id);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_identsInit000)(void) {
	firstchariscs_198029 = NIM_TRUE;
	wordcounter_198276 = ((NI) 1);
	asgnRefNoCycle((void**) (&idanon_198495), getident_198463(((NimStringDesc*) &TMP510)));
	asgnRefNoCycle((void**) (&iddelegator_198562), getident_198463(((NimStringDesc*) &TMP511)));
}

NIM_EXTERNC N_NOINLINE(void, compiler_identsDatInit000)(void) {
static TNimNode* TMP508[3];
static TNimNode TMP506[5];
NTI198015.size = sizeof(Tidobj198015);
NTI198015.kind = 17;
NTI198015.base = (&NTI4011);
NTI198015.flags = 1;
TMP506[0].kind = 1;
TMP506[0].offset = offsetof(Tidobj198015, id);
TMP506[0].typ = (&NTI108);
TMP506[0].name = "id";
NTI198015.node = &TMP506[0];
NTI198021.size = sizeof(Tident198021);
NTI198021.kind = 17;
NTI198021.base = (&NTI198015);
NTI198021.flags = 2;
TMP508[0] = &TMP506[2];
TMP506[2].kind = 1;
TMP506[2].offset = offsetof(Tident198021, s);
TMP506[2].typ = (&NTI149);
TMP506[2].name = "s";
TMP508[1] = &TMP506[3];
TMP506[3].kind = 1;
TMP506[3].offset = offsetof(Tident198021, next);
TMP506[3].typ = (&NTI198019);
TMP506[3].name = "next";
TMP508[2] = &TMP506[4];
TMP506[4].kind = 1;
TMP506[4].offset = offsetof(Tident198021, h);
TMP506[4].typ = (&NTI143005);
TMP506[4].name = "h";
TMP506[1].len = 3; TMP506[1].kind = 2; TMP506[1].sons = &TMP508[0];
NTI198021.node = &TMP506[1];
NTI198019.size = sizeof(Tident198021*);
NTI198019.kind = 22;
NTI198019.base = (&NTI198021);
NTI198019.flags = 2;
NTI198019.marker = TMP509;
NTI198017.size = sizeof(Tidobj198015*);
NTI198017.kind = 22;
NTI198017.base = (&NTI198015);
NTI198017.marker = TMP912;
}

