/* 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 Cell48946 Cell48946;
typedef struct Cellseq48962 Cellseq48962;
typedef struct Gcheap51018 Gcheap51018;
typedef struct Gcstack51016 Gcstack51016;
typedef struct Cellset48958 Cellset48958;
typedef struct Pagedesc48954 Pagedesc48954;
typedef struct Memregion30890 Memregion30890;
typedef struct Smallchunk30842 Smallchunk30842;
typedef struct Llchunk30884 Llchunk30884;
typedef struct Bigchunk30844 Bigchunk30844;
typedef struct Intset30817 Intset30817;
typedef struct Trunk30813 Trunk30813;
typedef struct Avlnode30888 Avlnode30888;
typedef struct Gcstat51014 Gcstat51014;
typedef struct Basechunk30840 Basechunk30840;
typedef struct Freecell30832 Freecell30832;
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  Cell48946  {
NI refcount;
TNimType* typ;
};
struct  Cellseq48962  {
NI len;
NI cap;
Cell48946** d;
};
struct  Cellset48958  {
NI counter;
NI max;
Pagedesc48954* head;
Pagedesc48954** data;
};
typedef Smallchunk30842* TY30905[512];
typedef Trunk30813* Trunkbuckets30815[256];
struct  Intset30817  {
Trunkbuckets30815 data;
};
struct  Memregion30890  {
NI minlargeobj;
NI maxlargeobj;
TY30905 freesmallchunks;
Llchunk30884* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk30844* freechunkslist;
Intset30817 chunkstarts;
Avlnode30888* root;
Avlnode30888* deleted;
Avlnode30888* last;
Avlnode30888* freeavlnodes;
};
struct  Gcstat51014  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap51018  {
Gcstack51016* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq48962 zct;
Cellseq48962 decstack;
Cellset48958 cycleroots;
Cellseq48962 tempstack;
NI recgclock;
Memregion30890 region;
Gcstat51014 stat;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Gcstack51016  {
Gcstack51016* prev;
Gcstack51016* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY30821[16];
struct  Pagedesc48954  {
Pagedesc48954* next;
NI key;
TY30821 bits;
};
struct  Basechunk30840  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk30842  {
  Basechunk30840 Sup;
Smallchunk30842* next;
Smallchunk30842* prev;
Freecell30832* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk30884  {
NI size;
NI acc;
Llchunk30884* next;
};
struct  Bigchunk30844  {
  Basechunk30840 Sup;
Bigchunk30844* next;
Bigchunk30844* prev;
NI align;
NF data;
};
struct  Trunk30813  {
Trunk30813* next;
NI key;
TY30821 bits;
};
typedef Avlnode30888* TY30895[2];
struct  Avlnode30888  {
TY30895 link;
NI key;
NI upperbound;
NI level;
};
struct  Freecell30832  {
Freecell30832* 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(Cell48946*, usrtocell_52646)(void* usr);
static N_INLINE(void, rtladdzct_54204)(Cell48946* c);
N_NOINLINE(void, addzct_52617)(Cellseq48962* s, Cell48946* c);
N_NIMCALL(NI, cmpignorestyle_198044)(NCSTRING a, NCSTRING b, NI blen);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_141029)(NCSTRING cs, NI i);
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP511)(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_142945)(NimStringDesc* x);
N_NIMCALL(void, TMP914)(void* p, NI op);
STRING_LITERAL(TMP512, ":anonymous", 10);
STRING_LITERAL(TMP513, ":delegator", 10);
NIM_BOOL firstchariscs_198029;
TY198038 buckets_198039;
NI wordcounter_198276;
Tident198021* idanon_198495;
extern Gcheap51018 gch_51059;
extern TNimType NTI4011; /* RootObj */
TNimType NTI198015; /* TIdObj */
extern TNimType NTI108; /* int */
TNimType NTI198021; /* TIdent */
extern TNimType NTI149; /* string */
extern TNimType NTI142005; /* 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(Cell48946*, usrtocell_52646)(void* usr) {
	Cell48946* result;
	result = 0;
	result = ((Cell48946*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(Cell48946))))));
	return result;
}

static N_INLINE(void, rtladdzct_54204)(Cell48946* c) {
	addzct_52617((&gch_51059.zct), c);
}

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

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_141029)(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_141029(a, i);
					if (!LOC17) goto LA16;
					i += ((NI) 3);
				} LA16: ;
			}
			{
				while (1) {
					NIM_BOOL LOC20;
					LOC20 = 0;
					LOC20 = ismagicidentseparatorrune_141029(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, TMP511)(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_142945(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, TMP914)(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*) &TMP512)));
	asgnRefNoCycle((void**) (&iddelegator_198562), getident_198463(((NimStringDesc*) &TMP513)));
}

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

