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

#include "nimbase.h"
typedef struct Tident200021 Tident200021;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Tidobj200015 Tidobj200015;
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 Memregion30891 Memregion30891;
typedef struct Smallchunk30843 Smallchunk30843;
typedef struct Llchunk30885 Llchunk30885;
typedef struct Bigchunk30845 Bigchunk30845;
typedef struct Intset30817 Intset30817;
typedef struct Trunk30813 Trunk30813;
typedef struct Avlnode30889 Avlnode30889;
typedef struct Gcstat51014 Gcstat51014;
typedef struct Basechunk30841 Basechunk30841;
typedef struct Freecell30833 Freecell30833;
typedef Tident200021* TY200038[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  Tidobj200015  {
  TNimObject Sup;
NI id;
};
struct  Tident200021  {
  Tidobj200015 Sup;
NimStringDesc* s;
Tident200021* 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 Smallchunk30843* TY30906[512];
typedef Trunk30813* Trunkbuckets30815[256];
struct  Intset30817  {
Trunkbuckets30815 data;
};
struct  Memregion30891  {
NI minlargeobj;
NI maxlargeobj;
TY30906 freesmallchunks;
Llchunk30885* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk30845* freechunkslist;
Intset30817 chunkstarts;
Avlnode30889* root;
Avlnode30889* deleted;
Avlnode30889* last;
Avlnode30889* 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;
Memregion30891 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 TY30822[8];
struct  Pagedesc48954  {
Pagedesc48954* next;
NI key;
TY30822 bits;
};
struct  Basechunk30841  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk30843  {
  Basechunk30841 Sup;
Smallchunk30843* next;
Smallchunk30843* prev;
Freecell30833* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk30885  {
NI size;
NI acc;
Llchunk30885* next;
};
struct  Bigchunk30845  {
  Basechunk30841 Sup;
Bigchunk30845* next;
Bigchunk30845* prev;
NI align;
NF data;
};
struct  Trunk30813  {
Trunk30813* next;
NI key;
TY30822 bits;
};
typedef Avlnode30889* TY30896[2];
struct  Avlnode30889  {
TY30896 link;
NI key;
NI upperbound;
NI level;
};
struct  Freecell30833  {
Freecell30833* next;
NI zerofield;
};
N_NIMCALL(Tident200021*, getident_200463)(NimStringDesc* identifier);
N_NIMCALL(Tident200021*, getident_200280)(NCSTRING identifier, NI length, NI h);
N_NIMCALL(NI, cmpexact_200219)(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_200044)(NCSTRING a, NCSTRING b, NI blen);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_144029)(NCSTRING cs, NI i);
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP516)(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_145945)(NimStringDesc* x);
N_NIMCALL(void, TMP919)(void* p, NI op);
STRING_LITERAL(TMP517, ":anonymous", 10);
STRING_LITERAL(TMP518, ":delegator", 10);
NIM_BOOL firstchariscs_200029;
TY200038 buckets_200039;
NI wordcounter_200276;
Tident200021* idanon_200495;
extern Gcheap51018 gch_51059;
extern TNimType NTI4011; /* RootObj */
TNimType NTI200015; /* TIdObj */
extern TNimType NTI108; /* int */
TNimType NTI200021; /* TIdent */
extern TNimType NTI149; /* string */
extern TNimType NTI145005; /* Hash */
TNimType NTI200019; /* PIdent */
Tident200021* iddelegator_200562;
TNimType NTI200017; /* PIdObj */

N_NIMCALL(NI, cmpexact_200219)(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)((NU64)(((NI) (usr))) - (NU64)(((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 (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA11;
			rtladdzct_54204(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_144029)(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_200044)(NCSTRING a, NCSTRING b, NI blen) {
	NI result;
	NI i;
	NI j;
{	result = 0;
	{
		if (!firstchariscs_200029) 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_144029(a, i);
					if (!LOC17) goto LA16;
					i += ((NI) 3);
				} LA16: ;
			}
			{
				while (1) {
					NIM_BOOL LOC20;
					LOC20 = 0;
					LOC20 = ismagicidentseparatorrune_144029(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, TMP516)(void* p, NI op) {
	Tident200021* a;
	a = (Tident200021*)p;
	nimGCvisit((void*)(*a).s, op);
	nimGCvisit((void*)(*a).next, op);
}

N_NIMCALL(Tident200021*, getident_200280)(NCSTRING identifier, NI length, NI h) {
	Tident200021* result;
	NI idx;
	Tident200021* last;
	NI id;
{	result = 0;
	idx = (NI)(h & ((NI) 8191));
	result = buckets_200039[(idx)- 0];
	last = NIM_NIL;
	id = ((NI) 0);
	{
		while (1) {
			if (!!((result == NIM_NIL))) goto LA2;
			{
				NI LOC5;
				LOC5 = 0;
				LOC5 = cmpexact_200219((*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_200039[(idx)- 0]);
					asgnRefNoCycle((void**) (&buckets_200039[(idx)- 0]), result);
				}
				LA10: ;
				goto BeforeRet;
			}
			goto LA3;
			LA6: ;
			{
				NI LOC13;
				LOC13 = 0;
				LOC13 = cmpignorestyle_200044((*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 = (Tident200021*) newObj((&NTI200019), sizeof(Tident200021));
	(*result).Sup.Sup.m_type = (&NTI200021);
	(*result).h = h;
	asgnRefNoCycle((void**) (&(*result).s), mnewString(((NI) (length))));
	{
		NI i_200421;
		NI HEX3Atmp_200435;
		NI res_200438;
		i_200421 = 0;
		HEX3Atmp_200435 = 0;
		HEX3Atmp_200435 = (NI)(length - ((NI) 1));
		res_200438 = ((NI) 0);
		{
			while (1) {
				if (!(res_200438 <= HEX3Atmp_200435)) goto LA18;
				i_200421 = res_200438;
				(*result).s->data[i_200421] = identifier[i_200421];
				res_200438 += ((NI) 1);
			} LA18: ;
		}
	}
	asgnRefNoCycle((void**) (&(*result).next), buckets_200039[(idx)- 0]);
	asgnRefNoCycle((void**) (&buckets_200039[(idx)- 0]), result);
	{
		if (!(id == ((NI) 0))) goto LA21;
		wordcounter_200276 += ((NI) 1);
		(*result).Sup.id = ((NI64)-(wordcounter_200276));
	}
	goto LA19;
	LA21: ;
	{
		(*result).Sup.id = id;
	}
	LA19: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tident200021*, getident_200463)(NimStringDesc* identifier) {
	Tident200021* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = hashignorestyle_145945(identifier);
	result = getident_200280(identifier->data, (identifier ? identifier->Sup.len : 0), LOC1);
	return result;
}

N_NIMCALL(Tident200021*, getident_200473)(NimStringDesc* identifier, NI h) {
	Tident200021* result;
	result = 0;
	result = getident_200280(identifier->data, (identifier ? identifier->Sup.len : 0), h);
	return result;
}
N_NIMCALL(void, TMP919)(void* p, NI op) {
	Tidobj200015* a;
	a = (Tidobj200015*)p;
}

N_NIMCALL(NIM_BOOL, identeq_200484)(Tident200021* id, NimStringDesc* name) {
	NIM_BOOL result;
	Tident200021* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = getident_200463(name);
	result = ((*id).Sup.id == (*LOC1).Sup.id);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_identsInit000)(void) {
	firstchariscs_200029 = NIM_TRUE;
	wordcounter_200276 = ((NI) 1);
	asgnRefNoCycle((void**) (&idanon_200495), getident_200463(((NimStringDesc*) &TMP517)));
	asgnRefNoCycle((void**) (&iddelegator_200562), getident_200463(((NimStringDesc*) &TMP518)));
}

NIM_EXTERNC N_NOINLINE(void, compiler_identsDatInit000)(void) {
static TNimNode* TMP515[3];
static TNimNode TMP513[5];
NTI200015.size = sizeof(Tidobj200015);
NTI200015.kind = 17;
NTI200015.base = (&NTI4011);
NTI200015.flags = 1;
TMP513[0].kind = 1;
TMP513[0].offset = offsetof(Tidobj200015, id);
TMP513[0].typ = (&NTI108);
TMP513[0].name = "id";
NTI200015.node = &TMP513[0];
NTI200021.size = sizeof(Tident200021);
NTI200021.kind = 17;
NTI200021.base = (&NTI200015);
NTI200021.flags = 2;
TMP515[0] = &TMP513[2];
TMP513[2].kind = 1;
TMP513[2].offset = offsetof(Tident200021, s);
TMP513[2].typ = (&NTI149);
TMP513[2].name = "s";
TMP515[1] = &TMP513[3];
TMP513[3].kind = 1;
TMP513[3].offset = offsetof(Tident200021, next);
TMP513[3].typ = (&NTI200019);
TMP513[3].name = "next";
TMP515[2] = &TMP513[4];
TMP513[4].kind = 1;
TMP513[4].offset = offsetof(Tident200021, h);
TMP513[4].typ = (&NTI145005);
TMP513[4].name = "h";
TMP513[1].len = 3; TMP513[1].kind = 2; TMP513[1].sons = &TMP515[0];
NTI200021.node = &TMP513[1];
NTI200019.size = sizeof(Tident200021*);
NTI200019.kind = 22;
NTI200019.base = (&NTI200021);
NTI200019.flags = 2;
NTI200019.marker = TMP516;
NTI200017.size = sizeof(Tidobj200015*);
NTI200017.kind = 22;
NTI200017.base = (&NTI200015);
NTI200017.marker = TMP919;
}

