/* 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 TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tlistentry129022 tlistentry129022;
typedef struct TNimObject TNimObject;
typedef struct tlinkedlist129028 tlinkedlist129028;
typedef struct tcell44733 tcell44733;
typedef struct tcellset44745 tcellset44745;
typedef struct tgcheap46816 tgcheap46816;
typedef struct tcellseq44749 tcellseq44749;
typedef struct tpagedesc44741 tpagedesc44741;
typedef struct tmemregion27010 tmemregion27010;
typedef struct tsmallchunk26240 tsmallchunk26240;
typedef struct tllchunk27004 tllchunk27004;
typedef struct tbigchunk26242 tbigchunk26242;
typedef struct tintset26217 tintset26217;
typedef struct ttrunk26213 ttrunk26213;
typedef struct tavlnode27008 tavlnode27008;
typedef struct tgcstat46814 tgcstat46814;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tstrentry129024 tstrentry129024;
typedef struct tbasechunk26238 tbasechunk26238;
typedef struct tfreecell26230 tfreecell26230;
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  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tlistentry129022  {
  TNimObject Sup;
tlistentry129022* Prev;
tlistentry129022* Next;
};
struct  tlinkedlist129028  {
tlistentry129022* Head;
tlistentry129022* Tail;
NI Counter;
};
struct  tcell44733  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq44749  {
NI Len;
NI Cap;
tcell44733** D;
};
struct  tcellset44745  {
NI Counter;
NI Max;
tpagedesc44741* Head;
tpagedesc44741** Data;
};
typedef tsmallchunk26240* TY27022[512];
typedef ttrunk26213* ttrunkbuckets26215[256];
struct  tintset26217  {
ttrunkbuckets26215 Data;
};
struct  tmemregion27010  {
NI Minlargeobj;
NI Maxlargeobj;
TY27022 Freesmallchunks;
tllchunk27004* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk26242* Freechunkslist;
tintset26217 Chunkstarts;
tavlnode27008* Root;
tavlnode27008* Deleted;
tavlnode27008* Last;
tavlnode27008* Freeavlnodes;
};
struct  tgcstat46814  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap46816  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq44749 Zct;
tcellseq44749 Decstack;
tcellset44745 Cycleroots;
tcellseq44749 Tempstack;
NI Recgclock;
tmemregion27010 Region;
tgcstat46814 Stat;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  tstrentry129024  {
  tlistentry129022 Sup;
NimStringDesc* Data;
};
typedef NI TY26220[8];
struct  tpagedesc44741  {
tpagedesc44741* Next;
NI Key;
TY26220 Bits;
};
struct  tbasechunk26238  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk26240  {
  tbasechunk26238 Sup;
tsmallchunk26240* Next;
tsmallchunk26240* Prev;
tfreecell26230* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk27004  {
NI Size;
NI Acc;
tllchunk27004* Next;
};
struct  tbigchunk26242  {
  tbasechunk26238 Sup;
tbigchunk26242* Next;
tbigchunk26242* Prev;
NI Align;
NF Data;
};
struct  ttrunk26213  {
ttrunk26213* Next;
NI Key;
TY26220 Bits;
};
typedef tavlnode27008* TY27014[2];
struct  tavlnode27008  {
TY27014 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tfreecell26230  {
tfreecell26230* Next;
NI Zerofield;
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP789)(void* p, NI op);
N_NIMCALL(void, remove_129652)(tlinkedlist129028* list, tlistentry129022* entry);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
static N_INLINE(void, asgnRef)(void** dest, void* src);
static N_INLINE(void, incref_50825)(tcell44733* c);
static N_INLINE(NIM_BOOL, canbecycleroot_48467)(tcell44733* c);
static N_INLINE(void, rtladdcycleroot_49229)(tcell44733* c);
N_NOINLINE(void, incl_45471)(tcellset44745* s, tcell44733* cell);
static N_INLINE(tcell44733*, usrtocell_48446)(void* usr);
static N_INLINE(void, decref_50404)(tcell44733* c);
static N_INLINE(void, rtladdzct_50004)(tcell44733* c);
N_NOINLINE(void, addzct_48417)(tcellseq44749* s, tcell44733* c);
N_NIMCALL(void, prepend_129309)(tlinkedlist129028* list, tlistentry129022* entry);
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(tstrentry129024*, newstrentry_129260)(NimStringDesc* data);
N_NIMCALL(void, TMP1686)(void* p, NI op);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
N_NIMCALL(NI, noscmpPaths)(NimStringDesc* patha, NimStringDesc* pathb);
N_NIMCALL(void, append_129053)(tlinkedlist129028* list, tlistentry129022* entry);
N_NIMCALL(NIM_BOOL, contains_129224)(tlinkedlist129028* list, NimStringDesc* data);
N_NIMCALL(void, appendstr_129286)(tlinkedlist129028* list, NimStringDesc* data);
extern TNimType NTI3211; /* RootObj */
TNimType NTI129022; /* TListEntry */
TNimType NTI129020; /* PListEntry */
TNimType NTI129028; /* TLinkedList */
extern TNimType NTI108; /* int */
extern tgcheap46816 gch_46844;
TNimType NTI129024; /* TStrEntry */
extern TNimType NTI149; /* string */
TNimType NTI129026; /* PStrEntry */
N_NIMCALL(void, TMP789)(void* p, NI op) {
	tlistentry129022* a;
	a = (tlistentry129022*)p;
	nimGCvisit((void*)(*a).Prev, op);
	nimGCvisit((void*)(*a).Next, op);
}

static N_INLINE(NIM_BOOL, canbecycleroot_48467)(tcell44733* c) {
	NIM_BOOL result;
	result = 0;
	result = !((((*(*c).Typ).flags &(1<<((((NU8) 1))&7)))!=0));
	return result;
}

static N_INLINE(void, rtladdcycleroot_49229)(tcell44733* c) {
	{
		if (!!((((NI) ((NI)((*c).Refcount & 3))) == 3))) goto LA3;
		(*c).Refcount = (NI)((NI)((*c).Refcount & -4) | 3);
		incl_45471((&gch_46844.Cycleroots), c);
	}
	LA3: ;
}

static N_INLINE(void, incref_50825)(tcell44733* c) {
	(*c).Refcount = (NI)((NU64)((*c).Refcount) + (NU64)(8));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = canbecycleroot_48467(c);
		if (!LOC3) goto LA4;
		rtladdcycleroot_49229(c);
	}
	LA4: ;
}

static N_INLINE(tcell44733*, usrtocell_48446)(void* usr) {
	tcell44733* result;
	result = 0;
	result = ((tcell44733*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(tcell44733))))));
	return result;
}

static N_INLINE(void, rtladdzct_50004)(tcell44733* c) {
	addzct_48417((&gch_46844.Zct), c);
}

static N_INLINE(void, decref_50404)(tcell44733* c) {
	{
		(*c).Refcount -= 8;
		if (!((NU64)((*c).Refcount) < (NU64)(8))) goto LA3;
		rtladdzct_50004(c);
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC6;
		LOC6 = 0;
		LOC6 = canbecycleroot_48467(c);
		if (!LOC6) goto LA7;
		rtladdcycleroot_49229(c);
	}
	goto LA1;
	LA7: ;
	LA1: ;
}

static N_INLINE(void, asgnRef)(void** dest, void* src) {
	{
		tcell44733* LOC5;
		if (!!((src == NIM_NIL))) goto LA3;
		LOC5 = 0;
		LOC5 = usrtocell_48446(src);
		incref_50825(LOC5);
	}
	LA3: ;
	{
		tcell44733* LOC10;
		if (!!(((*dest) == NIM_NIL))) goto LA8;
		LOC10 = 0;
		LOC10 = usrtocell_48446((*dest));
		decref_50404(LOC10);
	}
	LA8: ;
	(*dest) = src;
}

N_NIMCALL(void, remove_129652)(tlinkedlist129028* list, tlistentry129022* entry) {
	(*list).Counter -= 1;
	{
		if (!(entry == (*list).Tail)) goto LA3;
		unsureAsgnRef((void**) (&(*list).Tail), (*entry).Prev);
	}
	LA3: ;
	{
		if (!(entry == (*list).Head)) goto LA7;
		unsureAsgnRef((void**) (&(*list).Head), (*entry).Next);
	}
	LA7: ;
	{
		if (!!(((*entry).Next == NIM_NIL))) goto LA11;
		asgnRef((void**) (&(*(*entry).Next).Prev), (*entry).Prev);
	}
	LA11: ;
	{
		if (!!(((*entry).Prev == NIM_NIL))) goto LA15;
		asgnRef((void**) (&(*(*entry).Prev).Next), (*entry).Next);
	}
	LA15: ;
}

N_NIMCALL(void, prepend_129309)(tlinkedlist129028* list, tlistentry129022* entry) {
	(*list).Counter += 1;
	asgnRef((void**) (&(*entry).Prev), NIM_NIL);
	asgnRef((void**) (&(*entry).Next), (*list).Head);
	{
		if (!!(((*list).Head == NIM_NIL))) goto LA3;
		asgnRef((void**) (&(*(*list).Head).Prev), entry);
	}
	LA3: ;
	unsureAsgnRef((void**) (&(*list).Head), entry);
	{
		if (!((*list).Tail == NIM_NIL)) goto LA7;
		unsureAsgnRef((void**) (&(*list).Tail), entry);
	}
	LA7: ;
}

N_NIMCALL(void, bringtofront_129741)(tlinkedlist129028* list, tlistentry129022* entry) {
	remove_129652(list, entry);
	prepend_129309(list, entry);
}

static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b) {
	NIM_BOOL result;
	NIM_BOOL LOC11;
	int LOC13;
	result = 0;
	{
		if (!(a == b)) goto LA3;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = (a == NIM_NIL);
		if (LOC7) goto LA8;
		LOC7 = (b == NIM_NIL);
		LA8: ;
		if (!LOC7) goto LA9;
		result = NIM_FALSE;
		goto BeforeRet;
	}
	LA9: ;
	LOC11 = 0;
	LOC11 = ((*a).Sup.len == (*b).Sup.len);
	if (!(LOC11)) goto LA12;
	LOC13 = 0;
	LOC13 = memcmp(((NCSTRING) ((*a).data)), ((NCSTRING) ((*b).data)), (NI64)((*a).Sup.len * 1));
	LOC11 = (LOC13 == ((NI32) 0));
	LA12: ;
	result = LOC11;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, contains_129224)(tlinkedlist129028* list, NimStringDesc* data) {
	NIM_BOOL result;
	tlistentry129022* it;
	result = 0;
	it = (*list).Head;
	{
		while (1) {
			if (!!((it == NIM_NIL))) goto LA2;
			{
				if (!eqStrings((*((tstrentry129024*) (it))).Data, data)) goto LA5;
				result = NIM_TRUE;
				goto BeforeRet;
			}
			LA5: ;
			it = (*it).Next;
		} LA2: ;
	}
	BeforeRet: ;
	return result;
}
N_NIMCALL(void, TMP1686)(void* p, NI op) {
	tstrentry129024* a;
	a = (tstrentry129024*)p;
	nimGCvisit((void*)(*a).Sup.Prev, op);
	nimGCvisit((void*)(*a).Sup.Next, op);
	nimGCvisit((void*)(*a).Data, op);
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tcell44733* c;
	c = usrtocell_48446(p);
	{
		(*c).Refcount -= 8;
		if (!((NU64)((*c).Refcount) < (NU64)(8))) goto LA3;
		rtladdzct_50004(c);
	}
	LA3: ;
}

N_NIMCALL(tstrentry129024*, newstrentry_129260)(NimStringDesc* data) {
	tstrentry129024* result;
	NimStringDesc* LOC1;
	result = 0;
	result = (tstrentry129024*) newObj((&NTI129026), sizeof(tstrentry129024));
	(*result).Sup.Sup.m_type = (&NTI129024);
	LOC1 = 0;
	LOC1 = (*result).Data; (*result).Data = copyStringRC1(data);
	if (LOC1) nimGCunrefNoCycle(LOC1);
	return result;
}

N_NIMCALL(void, prependstr_129424)(tlinkedlist129028* list, NimStringDesc* data) {
	tstrentry129024* LOC1;
	tlistentry129022* LOC2;
	LOC1 = 0;
	LOC1 = newstrentry_129260(data);
	LOC2 = 0;
	LOC2 = &LOC1->Sup;
	prepend_129309(list, LOC2);
}

N_NIMCALL(void, excludepath_129807)(tlinkedlist129028* list, NimStringDesc* data) {
	tlistentry129022* it;
	it = (*list).Head;
	{
		while (1) {
			tlistentry129022* nxt;
			if (!!((it == NIM_NIL))) goto LA2;
			nxt = (*it).Next;
			{
				NI LOC5;
				LOC5 = 0;
				LOC5 = noscmpPaths((*((tstrentry129024*) (it))).Data, data);
				if (!(LOC5 == 0)) goto LA6;
				remove_129652(list, it);
			}
			LA6: ;
			it = nxt;
		} LA2: ;
	}
}

N_NIMCALL(void, append_129053)(tlinkedlist129028* list, tlistentry129022* entry) {
	(*list).Counter += 1;
	asgnRef((void**) (&(*entry).Next), NIM_NIL);
	asgnRef((void**) (&(*entry).Prev), (*list).Tail);
	{
		if (!!(((*list).Tail == NIM_NIL))) goto LA3;
		asgnRef((void**) (&(*(*list).Tail).Next), entry);
	}
	LA3: ;
	unsureAsgnRef((void**) (&(*list).Tail), entry);
	{
		if (!((*list).Head == NIM_NIL)) goto LA7;
		unsureAsgnRef((void**) (&(*list).Head), entry);
	}
	LA7: ;
}

N_NIMCALL(void, appendstr_129286)(tlinkedlist129028* list, NimStringDesc* data) {
	tstrentry129024* LOC1;
	tlistentry129022* LOC2;
	LOC1 = 0;
	LOC1 = newstrentry_129260(data);
	LOC2 = 0;
	LOC2 = &LOC1->Sup;
	append_129053(list, LOC2);
}

N_NIMCALL(void, initlinkedlist_129043)(tlinkedlist129028* list) {
	(*list).Counter = 0;
	unsureAsgnRef((void**) (&(*list).Head), NIM_NIL);
	unsureAsgnRef((void**) (&(*list).Tail), NIM_NIL);
}

N_NIMCALL(NIM_BOOL, includestr_129297)(tlinkedlist129028* list, NimStringDesc* data) {
	NIM_BOOL result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = contains_129224((&(*list)), data);
		if (!LOC3) goto LA4;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA4: ;
	appendstr_129286(list, data);
	BeforeRet: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, HEX00_listsInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, HEX00_listsDatInit)(void) {
static TNimNode* TMP788[2];
static TNimNode* TMP981[3];
static TNimNode TMP25[8];
NTI129022.size = sizeof(tlistentry129022);
NTI129022.kind = 17;
NTI129022.base = (&NTI3211);
TMP788[0] = &TMP25[1];
NTI129020.size = sizeof(tlistentry129022*);
NTI129020.kind = 22;
NTI129020.base = (&NTI129022);
NTI129020.marker = TMP789;
TMP25[1].kind = 1;
TMP25[1].offset = offsetof(tlistentry129022, Prev);
TMP25[1].typ = (&NTI129020);
TMP25[1].name = "prev";
TMP788[1] = &TMP25[2];
TMP25[2].kind = 1;
TMP25[2].offset = offsetof(tlistentry129022, Next);
TMP25[2].typ = (&NTI129020);
TMP25[2].name = "next";
TMP25[0].len = 2; TMP25[0].kind = 2; TMP25[0].sons = &TMP788[0];
NTI129022.node = &TMP25[0];
NTI129028.size = sizeof(tlinkedlist129028);
NTI129028.kind = 18;
NTI129028.base = 0;
TMP981[0] = &TMP25[4];
TMP25[4].kind = 1;
TMP25[4].offset = offsetof(tlinkedlist129028, Head);
TMP25[4].typ = (&NTI129020);
TMP25[4].name = "head";
TMP981[1] = &TMP25[5];
TMP25[5].kind = 1;
TMP25[5].offset = offsetof(tlinkedlist129028, Tail);
TMP25[5].typ = (&NTI129020);
TMP25[5].name = "tail";
TMP981[2] = &TMP25[6];
TMP25[6].kind = 1;
TMP25[6].offset = offsetof(tlinkedlist129028, Counter);
TMP25[6].typ = (&NTI108);
TMP25[6].name = "counter";
TMP25[3].len = 3; TMP25[3].kind = 2; TMP25[3].sons = &TMP981[0];
NTI129028.node = &TMP25[3];
NTI129024.size = sizeof(tstrentry129024);
NTI129024.kind = 17;
NTI129024.base = (&NTI129022);
TMP25[7].kind = 1;
TMP25[7].offset = offsetof(tstrentry129024, Data);
TMP25[7].typ = (&NTI149);
TMP25[7].name = "data";
NTI129024.node = &TMP25[7];
NTI129026.size = sizeof(tstrentry129024*);
NTI129026.kind = 22;
NTI129026.base = (&NTI129024);
NTI129026.marker = TMP1686;
}

