/* 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 TY421291 TY421291;
typedef struct TY421292 TY421292;
typedef struct tsymseq224818 tsymseq224818;
typedef struct tsym224846 tsym224846;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell44935 tcell44935;
typedef struct tcellseq44951 tcellseq44951;
typedef struct tgcheap47016 tgcheap47016;
typedef struct tcellset44947 tcellset44947;
typedef struct tpagedesc44943 tpagedesc44943;
typedef struct tmemregion27210 tmemregion27210;
typedef struct tsmallchunk26440 tsmallchunk26440;
typedef struct tllchunk27204 tllchunk27204;
typedef struct tbigchunk26442 tbigchunk26442;
typedef struct tintset26417 tintset26417;
typedef struct ttrunk26413 ttrunk26413;
typedef struct tavlnode27208 tavlnode27208;
typedef struct tgcstat47014 tgcstat47014;
typedef struct tidobj199015 tidobj199015;
typedef struct TNimObject TNimObject;
typedef struct ttypeseq224848 ttypeseq224848;
typedef struct ttype224852 ttype224852;
typedef struct tscope224840 tscope224840;
typedef struct TY224947 TY224947;
typedef struct tinstantiation224836 tinstantiation224836;
typedef struct tstrtable224820 tstrtable224820;
typedef struct tident199021 tident199021;
typedef struct tlineinfo194539 tlineinfo194539;
typedef struct tnode224816 tnode224816;
typedef struct tloc224830 tloc224830;
typedef struct trope176009 trope176009;
typedef struct tlib224834 tlib224834;
typedef struct NimStringDesc NimStringDesc;
typedef struct tnodeseq224810 tnodeseq224810;
typedef struct intset221056 intset221056;
typedef struct ttrunk221052 ttrunk221052;
typedef struct ttrunkseq221054 ttrunkseq221054;
typedef struct tbasechunk26438 tbasechunk26438;
typedef struct tfreecell26430 tfreecell26430;
typedef struct TY224936 TY224936;
typedef struct tlistentry126022 tlistentry126022;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct TY421292 {
tsymseq224818* Field0;
tsym224846* Field1;
};
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  tcell44935  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq44951  {
NI Len;
NI Cap;
tcell44935** D;
};
struct  tcellset44947  {
NI Counter;
NI Max;
tpagedesc44943* Head;
tpagedesc44943** Data;
};
typedef tsmallchunk26440* TY27222[512];
typedef ttrunk26413* ttrunkbuckets26415[256];
struct  tintset26417  {
ttrunkbuckets26415 Data;
};
struct  tmemregion27210  {
NI Minlargeobj;
NI Maxlargeobj;
TY27222 Freesmallchunks;
tllchunk27204* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk26442* Freechunkslist;
tintset26417 Chunkstarts;
tavlnode27208* Root;
tavlnode27208* Deleted;
tavlnode27208* Last;
tavlnode27208* Freeavlnodes;
};
struct  tgcstat47014  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap47016  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq44951 Zct;
tcellseq44951 Decstack;
tcellset44947 Cycleroots;
tcellseq44951 Tempstack;
NI Recgclock;
tmemregion27210 Region;
tgcstat47014 Stat;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tidobj199015  {
  TNimObject Sup;
NI Id;
};
struct  tstrtable224820  {
NI Counter;
tsymseq224818* Data;
};
struct  tlineinfo194539  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  tloc224830  {
NU8 K;
NU8 S;
NU8 Flags;
ttype224852* T;
trope176009* R;
trope176009* Heaproot;
};
struct  tsym224846  {
  tidobj199015 Sup;
NU8 Kind;
union {
struct {ttypeseq224848* Typeinstcache;
tscope224840* Typscope;
} S1;
struct {TY224947* Procinstcache;
tscope224840* Scope;
} S2;
struct {TY224947* Usedgenerics;
tstrtable224820 Tab;
} S3;
struct {tsym224846* Guard;
} S4;
} kindU;
NU16 Magic;
ttype224852* Typ;
tident199021* Name;
tlineinfo194539 Info;
tsym224846* Owner;
NU32 Flags;
tnode224816* Ast;
NU32 Options;
NI Position;
NI Offset;
tloc224830 Loc;
tlib224834* Annex;
tnode224816* Constraint;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  tident199021  {
  tidobj199015 Sup;
NimStringDesc* S;
tident199021* Next;
NI H;
};
struct  ttype224852  {
  tidobj199015 Sup;
NU8 Kind;
NU8 Callconv;
NU32 Flags;
ttypeseq224848* Sons;
tnode224816* N;
tsym224846* Owner;
tsym224846* Sym;
tsym224846* Destructor;
tsym224846* Deepcopy;
NI64 Size;
NI16 Align;
NI16 Locklevel;
tloc224830 Loc;
};
struct  tnode224816  {
ttype224852* Typ;
tlineinfo194539 Info;
NU16 Flags;
NU8 Kind;
union {
struct {NI64 Intval;
} S1;
struct {NF Floatval;
} S2;
struct {NimStringDesc* Strval;
} S3;
struct {tsym224846* Sym;
} S4;
struct {tident199021* Ident;
} S5;
struct {tnodeseq224810* Sons;
} S6;
} kindU;
NimStringDesc* Comment;
};
typedef NimStringDesc* TY168969[2];
typedef tsym224846* TY289498[1];
struct  intset221056  {
NI Counter;
NI Max;
ttrunk221052* Head;
ttrunkseq221054* Data;
};
typedef NI TY26420[8];
struct  tpagedesc44943  {
tpagedesc44943* Next;
NI Key;
TY26420 Bits;
};
struct  tbasechunk26438  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk26440  {
  tbasechunk26438 Sup;
tsmallchunk26440* Next;
tsmallchunk26440* Prev;
tfreecell26430* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk27204  {
NI Size;
NI Acc;
tllchunk27204* Next;
};
struct  tbigchunk26442  {
  tbasechunk26438 Sup;
tbigchunk26442* Next;
tbigchunk26442* Prev;
NI Align;
NF Data;
};
struct  ttrunk26413  {
ttrunk26413* Next;
NI Key;
TY26420 Bits;
};
typedef tavlnode27208* TY27214[2];
struct  tavlnode27208  {
TY27214 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tscope224840  {
NI Depthlevel;
tstrtable224820 Symbols;
tnodeseq224810* Usingsyms;
tscope224840* Parent;
};
struct  tinstantiation224836  {
tsym224846* Sym;
ttypeseq224848* Concretetypes;
TY224936* Usedby;
};
struct  trope176009  {
  TNimObject Sup;
trope176009* Left;
trope176009* Right;
NI Length;
NimStringDesc* Data;
};
struct  tlistentry126022  {
  TNimObject Sup;
tlistentry126022* Prev;
tlistentry126022* Next;
};
struct  tlib224834  {
  tlistentry126022 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope176009* Name;
tnode224816* Path;
};
struct  ttrunk221052  {
ttrunk221052* Next;
NI Key;
TY26420 Bits;
};
struct  tfreecell26430  {
tfreecell26430* Next;
NI Zerofield;
};
struct tsymseq224818 {
  TGenericSeq Sup;
  tsym224846* data[SEQ_DECL_SIZE];
};
struct TY421291 {
  TGenericSeq Sup;
  TY421292 data[SEQ_DECL_SIZE];
};
struct ttypeseq224848 {
  TGenericSeq Sup;
  ttype224852* data[SEQ_DECL_SIZE];
};
struct TY224947 {
  TGenericSeq Sup;
  tinstantiation224836* data[SEQ_DECL_SIZE];
};
struct tnodeseq224810 {
  TGenericSeq Sup;
  tnode224816* data[SEQ_DECL_SIZE];
};
struct ttrunkseq221054 {
  TGenericSeq Sup;
  ttrunk221052* data[SEQ_DECL_SIZE];
};
struct TY224936 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP931)(void* p, NI op);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(tcell44935*, usrtocell_48646)(void* usr);
static N_INLINE(void, rtladdzct_50204)(tcell44935* c);
N_NOINLINE(void, addzct_48617)(tcellseq44951* s, tcell44935* c);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(NIM_BOOL, samemethodbucket_421320)(tsym224846* a, tsym224846* b);
static N_INLINE(NI, sonslen_225255)(ttype224852* n);
N_NIMCALL(NIM_BOOL, sametypeornil_267367)(ttype224852* a, ttype224852* b, NU8 flags);
N_NIMCALL(ttype224852*, skiptypes_229245)(ttype224852* t, NU64 kinds);
static N_INLINE(ttype224852*, lastson_225267)(ttype224852* n);
N_NIMCALL(NIM_BOOL, sametype_267351)(ttype224852* a, ttype224852* b, NU8 flags);
N_NIMCALL(NI, inheritancediff_269588)(ttype224852* a, ttype224852* b);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(void, attachdispatcher_421412)(tsym224846* s, tnode224816* dispatcher);
static N_INLINE(NI, len_225364)(tnode224816* n);
N_NIMCALL(void, add_225498)(tnode224816* father, tnode224816* son);
static N_INLINE(tnode224816*, lastson_225261)(tnode224816* n);
static N_INLINE(NI, sonslen_225249)(tnode224816* n);
N_NIMCALL(void, fixupdispatcher_421628)(tsym224846* meth, tsym224846* disp);
N_NIMCALL(tnode224816*, copytree_225329)(tnode224816* src);
N_NIMCALL(void, message_196976)(tlineinfo194539 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr, NimStringDesc** a, NI aLen0);
N_NIMCALL(NimStringDesc*, HEX24_227488)(NI16 x);
N_NIMCALL(void, checkmethodeffects_382471)(tsym224846* disp, tsym224846* branch);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(tsym224846*, createdispatcher_421488)(tsym224846* s);
N_NIMCALL(tsym224846*, copysym_225203)(tsym224846* s, NIM_BOOL keepid);
N_NIMCALL(ttype224852*, copytype_225195)(ttype224852* t, tsym224846* owner, NIM_BOOL keepid);
N_NIMCALL(void, addson_225287)(tnode224816* father, tnode224816* son);
N_NIMCALL(tnode224816*, newsymnode_225132)(tsym224846* sym);
N_NIMCALL(void, genericSeqAssign)(void* dest, void* src_79604, TNimType* mt);
N_NIMCALL(void, internalerror_196987)(tlineinfo194539 info, NimStringDesc* errmsg);
N_NIMCALL(tnode224816*, genconv_421017)(tnode224816* n, ttype224852* d, NIM_BOOL downcast);
N_NIMCALL(tnode224816*, newnodeit_225145)(NU8 kind, tlineinfo194539 info, ttype224852* typ);
N_NIMCALL(tnode224816*, newnode_225090)(NU8 kind);
N_NIMCALL(void, initintset_221950)(intset221056* Result);
N_NOINLINE(void, chckNil)(void* p);
N_NIMCALL(NIM_BOOL, relevantcol_422061)(tsymseq224818* methods, NI col);
N_NIMCALL(void, incl_221869)(intset221056* s, NI key);
N_NIMCALL(void, sortbucket_422158)(tsymseq224818** a, intset221056* relevantcols);
N_NIMCALL(NI, cmpsignatures_422111)(tsym224846* a, tsym224846* b, intset221056* relevantcols);
N_NIMCALL(NIM_BOOL, contains_221837)(intset221056* s, NI key);
N_NIMCALL(tsym224846*, gendispatcher_422235)(tsymseq224818* methods, intset221056* relevantcols);
N_NIMCALL(tnode224816*, newnodei_225138)(NU8 kind, tlineinfo194539 info);
N_NIMCALL(tsym224846*, getsyssym_281054)(NimStringDesc* name);
N_NIMCALL(ttype224852*, getsystype_281030)(NU8 kind);
STRING_LITERAL(TMP3144, "method has lock level $1, but another method has $2", 51);
STRING_LITERAL(TMP3152, "no method dispatcher found", 26);
STRING_LITERAL(TMP3153, "cgmeth.genConv", 14);
STRING_LITERAL(TMP3154, "cgmeth.genConv: no upcast allowed", 33);
STRING_LITERAL(TMP3155, "cgmeth.genConv: no downcast allowed", 35);
STRING_LITERAL(TMP4080, "and", 3);
STRING_LITERAL(TMP4081, "of", 2);
TY421291* gmethods_421315;
TNimType NTI421292; /* tuple[methods: TSymSeq, dispatcher: PSym] */
extern TNimType NTI224818; /* TSymSeq */
extern TNimType NTI224814; /* PSym */
TNimType NTI421291; /* seq[tuple[methods: TSymSeq, dispatcher: PSym]] */
extern tgcheap47016 gch_47044;
extern tnode224816* emptynode_225738;
N_NIMCALL(void, TMP931)(void* p, NI op) {
	TY421291* a;
	NI LOC1;
	a = (TY421291*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1].Field0, op);
	nimGCvisit((void*)a->data[LOC1].Field1, op);
	}
}

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

static N_INLINE(void, rtladdzct_50204)(tcell44935* c) {
	addzct_48617((&gch_47044.Zct), c);
}

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

static N_INLINE(NI, sonslen_225255)(ttype224852* n) {
	NI result;
	result = 0;
	{
		if (!(*n).Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).Sons->Sup.len;
	}
	LA1: ;
	return result;
}

static N_INLINE(ttype224852*, lastson_225267)(ttype224852* n) {
	ttype224852* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = sonslen_225255(n);
	result = (*n).Sons->data[(NI64)(LOC1 - 1)];
	return result;
}

N_NIMCALL(NIM_BOOL, samemethodbucket_421320)(tsym224846* a, tsym224846* b) {
	NIM_BOOL result;
	result = 0;
	result = NIM_FALSE;
	{
		if (!!(((*(*a).Name).Sup.Id == (*(*b).Name).Sup.Id))) goto LA3;
		goto BeforeRet;
	}
	LA3: ;
	{
		NI LOC7;
		NI LOC8;
		LOC7 = 0;
		LOC7 = sonslen_225255((*a).Typ);
		LOC8 = 0;
		LOC8 = sonslen_225255((*b).Typ);
		if (!!((LOC7 == LOC8))) goto LA9;
		goto BeforeRet;
	}
	LA9: ;
	{
		NIM_BOOL LOC13;
		LOC13 = 0;
		LOC13 = sametypeornil_267367((*(*a).Typ).Sons->data[0], (*(*b).Typ).Sons->data[0], 0);
		if (!!(LOC13)) goto LA14;
		goto BeforeRet;
	}
	LA14: ;
	{
		NI i_421337;
		NI HEX3Atmp_421386;
		NI LOC17;
		NI res_421389;
		i_421337 = 0;
		HEX3Atmp_421386 = 0;
		LOC17 = 0;
		LOC17 = sonslen_225255((*a).Typ);
		HEX3Atmp_421386 = (NI64)(LOC17 - 1);
		res_421389 = 1;
		{
			while (1) {
				ttype224852* aa;
				ttype224852* bb;
				if (!(res_421389 <= HEX3Atmp_421386)) goto LA19;
				i_421337 = res_421389;
				aa = (*(*a).Typ).Sons->data[i_421337];
				bb = (*(*b).Typ).Sons->data[i_421337];
				{
					while (1) {
						aa = skiptypes_229245(aa, 2048);
						bb = skiptypes_229245(bb, 2048);
						{
							NIM_BOOL LOC24;
							LOC24 = 0;
							LOC24 = ((*aa).Kind == (*bb).Kind);
							if (!(LOC24)) goto LA25;
							LOC24 = ((14680064 &(IL64(1)<<(((*aa).Kind)&IL64(63))))!=0);
							LA25: ;
							if (!LOC24) goto LA26;
							aa = lastson_225267(aa);
							bb = lastson_225267(bb);
						}
						goto LA22;
						LA26: ;
						{
							goto LA20;
						}
						LA22: ;
					}
				} LA20: ;
				{
					NIM_BOOL LOC31;
					NIM_BOOL LOC33;
					NIM_BOOL LOC34;
					NI LOC37;
					LOC31 = 0;
					LOC31 = sametype_267351(aa, bb, 0);
					if (LOC31) goto LA32;
					LOC33 = 0;
					LOC34 = 0;
					LOC34 = ((*aa).Kind == ((NU8) 17));
					if (!(LOC34)) goto LA35;
					LOC34 = ((*bb).Kind == ((NU8) 17));
					LA35: ;
					LOC33 = LOC34;
					if (!(LOC33)) goto LA36;
					LOC37 = 0;
					LOC37 = inheritancediff_269588(bb, aa);
					LOC33 = (LOC37 < 0);
					LA36: ;
					LOC31 = LOC33;
					LA32: ;
					if (!LOC31) goto LA38;
				}
				goto LA29;
				LA38: ;
				{
					goto BeforeRet;
				}
				LA29: ;
				res_421389 += 1;
			} LA19: ;
		}
	}
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		tcell44935* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_48646(src);
		(*c).Refcount += 8;
	}
	LA3: ;
	{
		tcell44935* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_48646((*dest));
		{
			(*c).Refcount -= 8;
			if (!((NU64)((*c).Refcount) < (NU64)(8))) goto LA11;
			rtladdzct_50204(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

static N_INLINE(NI, len_225364)(tnode224816* n) {
	NI result;
	result = 0;
	{
		if (!(*n).kindU.S6.Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).kindU.S6.Sons->Sup.len;
	}
	LA1: ;
	return result;
}

N_NIMCALL(void, attachdispatcher_421412)(tsym224846* s, tnode224816* dispatcher) {
	NI l;
	NI LOC1;
	tnode224816* x;
	LOC1 = 0;
	LOC1 = len_225364((*s).Ast);
	l = (NI64)(LOC1 - 1);
	x = (*(*s).Ast).kindU.S6.Sons->data[l];
	{
		NIM_BOOL LOC4;
		LOC4 = 0;
		LOC4 = ((*x).Kind == ((NU8) 3));
		if (!(LOC4)) goto LA5;
		LOC4 = (((*(*x).kindU.S4.Sym).Flags &(1<<((((NU8) 25))&31)))!=0);
		LA5: ;
		if (!LOC4) goto LA6;
		asgnRefNoCycle((void**) (&(*(*s).Ast).kindU.S6.Sons->data[l]), dispatcher);
	}
	goto LA2;
	LA6: ;
	{
		add_225498((*s).Ast, dispatcher);
	}
	LA2: ;
}

static N_INLINE(NI, sonslen_225249)(tnode224816* n) {
	NI result;
	result = 0;
	{
		if (!(*n).kindU.S6.Sons == 0) goto LA3;
		result = 0;
	}
	goto LA1;
	LA3: ;
	{
		result = (*n).kindU.S6.Sons->Sup.len;
	}
	LA1: ;
	return result;
}

static N_INLINE(tnode224816*, lastson_225261)(tnode224816* n) {
	tnode224816* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = sonslen_225249(n);
	result = (*n).kindU.S6.Sons->data[(NI64)(LOC1 - 1)];
	return result;
}

N_NIMCALL(void, fixupdispatcher_421628)(tsym224846* meth, tsym224846* disp) {
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		NI LOC5;
		NI LOC7;
		LOC3 = 0;
		LOC4 = 0;
		LOC5 = 0;
		LOC5 = sonslen_225249((*disp).Ast);
		LOC4 = (7 < LOC5);
		if (!(LOC4)) goto LA6;
		LOC7 = 0;
		LOC7 = sonslen_225249((*meth).Ast);
		LOC4 = (7 < LOC7);
		LA6: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA8;
		LOC3 = ((*(*disp).Ast).kindU.S6.Sons->data[7] == emptynode_225738);
		LA8: ;
		if (!LOC3) goto LA9;
		asgnRefNoCycle((void**) (&(*(*disp).Ast).kindU.S6.Sons->data[7]), copytree_225329((*(*meth).Ast).kindU.S6.Sons->data[7]));
	}
	LA9: ;
	{
		if (!((*(*disp).Typ).Locklevel == ((NI16) -1))) goto LA13;
		(*(*disp).Typ).Locklevel = (*(*meth).Typ).Locklevel;
	}
	goto LA11;
	LA13: ;
	{
		NIM_BOOL LOC16;
		TY168969 LOC20;
		NimStringDesc* LOC21;
		LOC16 = 0;
		LOC16 = !(((*(*meth).Typ).Locklevel == ((NI16) -1)));
		if (!(LOC16)) goto LA17;
		LOC16 = !(((*(*meth).Typ).Locklevel == (*(*disp).Typ).Locklevel));
		LA17: ;
		if (!LOC16) goto LA18;
		memset((void*)LOC20, 0, sizeof(LOC20));
		LOC20[0] = HEX24_227488((*(*meth).Typ).Locklevel);
		LOC20[1] = HEX24_227488((*(*disp).Typ).Locklevel);
		LOC21 = 0;
		LOC21 = nsuFormatOpenArray(((NimStringDesc*) &TMP3144), LOC20, 2);
		message_196976((*meth).Info, ((NU16) 257), LOC21);
		{
			if (!((*(*disp).Typ).Locklevel < (*(*meth).Typ).Locklevel)) goto LA24;
			(*(*disp).Typ).Locklevel = (*(*meth).Typ).Locklevel;
		}
		LA24: ;
	}
	goto LA11;
	LA18: ;
	LA11: ;
}

N_NIMCALL(tsym224846*, createdispatcher_421488)(tsym224846* s) {
	tsym224846* result;
	tsym224846* disp;
	tnode224816* LOC15;
	tnode224816* LOC16;
	result = 0;
	disp = copysym_225203(s, NIM_FALSE);
	(*disp).Flags |= ((NI32)1)<<((((NU8) 25))%(sizeof(NI32)*8));
	(*disp).Flags &= ~(((NI32)1) << ((((NU8) 1)) % (sizeof(NI32)*8)));
	asgnRefNoCycle((void**) (&(*disp).Typ), copytype_225195((*disp).Typ, (*(*disp).Typ).Owner, NIM_FALSE));
	{
		if (!((*(*disp).Typ).Callconv == ((NU8) 5))) goto LA3;
		(*(*disp).Typ).Callconv = ((NU8) 0);
	}
	LA3: ;
	asgnRefNoCycle((void**) (&(*disp).Ast), copytree_225329((*s).Ast));
	asgnRefNoCycle((void**) (&(*(*disp).Ast).kindU.S6.Sons->data[6]), emptynode_225738);
	asgnRefNoCycle((void**) (&(*disp).Loc.R), NIM_NIL);
	{
		if (!!(((*(*s).Typ).Sons->data[0] == NIM_NIL))) goto LA7;
		{
			NI LOC11;
			LOC11 = 0;
			LOC11 = sonslen_225249((*disp).Ast);
			if (!(7 < LOC11)) goto LA12;
			asgnRefNoCycle((void**) (&(*(*(*disp).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym), copysym_225203((*(*(*s).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym, NIM_FALSE));
		}
		goto LA9;
		LA12: ;
		{
			addson_225287((*disp).Ast, emptynode_225738);
		}
		LA9: ;
	}
	LA7: ;
	LOC15 = 0;
	LOC15 = newsymnode_225132(disp);
	attachdispatcher_421412(s, LOC15);
	LOC16 = 0;
	LOC16 = newsymnode_225132(disp);
	attachdispatcher_421412(disp, LOC16);
	result = disp;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, methoddef_421824)(tsym224846* s, NIM_BOOL fromcache) {
	NI l;
	TY421292 LOC10;
	TY289498 LOC11;
	l = gmethods_421315->Sup.len;
	{
		NI i_421852;
		NI HEX3Atmp_422041;
		NI res_422044;
		i_421852 = 0;
		HEX3Atmp_422041 = 0;
		HEX3Atmp_422041 = (NI64)(l - 1);
		res_422044 = 0;
		{
			while (1) {
				tsym224846* disp;
				if (!(res_422044 <= HEX3Atmp_422041)) goto LA3;
				i_421852 = res_422044;
				disp = gmethods_421315->data[i_421852].Field1;
				{
					NIM_BOOL LOC6;
					tnode224816* LOC9;
					LOC6 = 0;
					LOC6 = samemethodbucket_421320(disp, s);
					if (!LOC6) goto LA7;
					gmethods_421315->data[i_421852].Field0 = (tsymseq224818*) incrSeq(&(gmethods_421315->data[i_421852].Field0)->Sup, sizeof(tsym224846*));
					asgnRefNoCycle((void**) (&gmethods_421315->data[i_421852].Field0->data[gmethods_421315->data[i_421852].Field0->Sup.len-1]), s);
					LOC9 = 0;
					LOC9 = lastson_225261((*disp).Ast);
					attachdispatcher_421412(s, LOC9);
					fixupdispatcher_421628(s, disp);
					checkmethodeffects_382471(disp, s);
					goto BeforeRet;
				}
				LA7: ;
				res_422044 += 1;
			} LA3: ;
		}
	}
	memset((void*)(&LOC10), 0, sizeof(LOC10));
	LOC10.Field0 = (tsymseq224818*) newSeq((&NTI224818), 1);
	memset((void*)LOC11, 0, sizeof(LOC11));
	LOC11[0] = s;
	asgnRefNoCycle((void**) (&LOC10.Field0->data[0]), LOC11[0]);
	LOC10.Field1 = createdispatcher_421488(s);
	gmethods_421315 = (TY421291*) incrSeq(&(gmethods_421315)->Sup, sizeof(TY421292));
	genericSeqAssign((&gmethods_421315->data[gmethods_421315->Sup.len-1].Field0), LOC10.Field0, (&NTI224818));
	asgnRefNoCycle((void**) (&gmethods_421315->data[gmethods_421315->Sup.len-1].Field1), LOC10.Field1);
	{
		if (!fromcache) goto LA14;
		internalerror_196987((*s).Info, ((NimStringDesc*) &TMP3152));
	}
	LA14: ;
	BeforeRet: ;
}

N_NIMCALL(tnode224816*, genconv_421017)(tnode224816* n, ttype224852* d, NIM_BOOL downcast) {
	tnode224816* result;
	ttype224852* dest;
	ttype224852* source;
	result = 0;
	dest = skiptypes_229245(d, IL64(211106247256320));
	source = skiptypes_229245((*n).Typ, IL64(211106247256320));
	{
		NIM_BOOL LOC3;
		NI diff;
		LOC3 = 0;
		LOC3 = ((*source).Kind == ((NU8) 17));
		if (!(LOC3)) goto LA4;
		LOC3 = ((*dest).Kind == ((NU8) 17));
		LA4: ;
		if (!LOC3) goto LA5;
		diff = inheritancediff_269588(dest, source);
		{
			if (!(diff == IL64(9223372036854775807))) goto LA9;
			internalerror_196987((*n).Info, ((NimStringDesc*) &TMP3153));
		}
		LA9: ;
		{
			if (!(diff < 0)) goto LA13;
			result = newnodeit_225145(((NU8) 67), (*n).Info, d);
			addson_225287(result, n);
			{
				if (!downcast) goto LA17;
				internalerror_196987((*n).Info, ((NimStringDesc*) &TMP3154));
			}
			LA17: ;
		}
		goto LA11;
		LA13: ;
		{
			if (!(0 < diff)) goto LA20;
			result = newnodeit_225145(((NU8) 66), (*n).Info, d);
			addson_225287(result, n);
			{
				if (!!(downcast)) goto LA24;
				internalerror_196987((*n).Info, ((NimStringDesc*) &TMP3155));
			}
			LA24: ;
		}
		goto LA11;
		LA20: ;
		{
			result = n;
		}
		LA11: ;
	}
	goto LA1;
	LA5: ;
	{
		result = n;
	}
	LA1: ;
	return result;
}

N_NIMCALL(tnode224816*, methodcall_421056)(tnode224816* n) {
	tnode224816* result;
	tsym224846* disp;
	tnode224816* LOC1;
	result = 0;
	result = n;
	LOC1 = 0;
	LOC1 = lastson_225261((*(*(*result).kindU.S6.Sons->data[0]).kindU.S4.Sym).Ast);
	disp = (*LOC1).kindU.S4.Sym;
	asgnRefNoCycle((void**) (&(*(*result).kindU.S6.Sons->data[0]).kindU.S4.Sym), disp);
	{
		NI i_421241;
		NI HEX3Atmp_421271;
		NI LOC3;
		NI res_421274;
		i_421241 = 0;
		HEX3Atmp_421271 = 0;
		LOC3 = 0;
		LOC3 = sonslen_225249(result);
		HEX3Atmp_421271 = (NI64)(LOC3 - 1);
		res_421274 = 1;
		{
			while (1) {
				if (!(res_421274 <= HEX3Atmp_421271)) goto LA5;
				i_421241 = res_421274;
				asgnRefNoCycle((void**) (&(*result).kindU.S6.Sons->data[i_421241]), genconv_421017((*result).kindU.S6.Sons->data[i_421241], (*(*disp).Typ).Sons->data[i_421241], NIM_TRUE));
				res_421274 += 1;
			} LA5: ;
		}
	}
	return result;
}

N_NIMCALL(NIM_BOOL, relevantcol_422061)(tsymseq224818* methods, NI col) {
	NIM_BOOL result;
	ttype224852* t;
	result = 0;
	t = skiptypes_229245((*(*methods->data[0]).Typ).Sons->data[col], IL64(211106247215360));
	{
		if (!((*t).Kind == ((NU8) 17))) goto LA3;
		{
			NI i_422088;
			NI HEX3Atmp_422091;
			NI res_422094;
			i_422088 = 0;
			HEX3Atmp_422091 = 0;
			HEX3Atmp_422091 = (methods->Sup.len-1);
			res_422094 = 1;
			{
				while (1) {
					ttype224852* t2;
					if (!(res_422094 <= HEX3Atmp_422091)) goto LA7;
					i_422088 = res_422094;
					t2 = skiptypes_229245((*(*methods->data[i_422088]).Typ).Sons->data[col], IL64(211106247215360));
					{
						NIM_BOOL LOC10;
						LOC10 = 0;
						LOC10 = sametype_267351(t2, t, 0);
						if (!!(LOC10)) goto LA11;
						result = NIM_TRUE;
						goto BeforeRet;
					}
					LA11: ;
					res_422094 += 1;
				} LA7: ;
			}
		}
	}
	LA3: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NI, cmpsignatures_422111)(tsym224846* a, tsym224846* b, intset221056* relevantcols) {
	NI result;
	result = 0;
	{
		NI col_422129;
		NI HEX3Atmp_422138;
		NI LOC2;
		NI res_422141;
		col_422129 = 0;
		HEX3Atmp_422138 = 0;
		LOC2 = 0;
		LOC2 = sonslen_225255((*a).Typ);
		HEX3Atmp_422138 = (NI64)(LOC2 - 1);
		res_422141 = 1;
		{
			while (1) {
				if (!(res_422141 <= HEX3Atmp_422138)) goto LA4;
				col_422129 = res_422141;
				{
					NIM_BOOL LOC7;
					ttype224852* aa;
					ttype224852* bb;
					NI d;
					LOC7 = 0;
					LOC7 = contains_221837(relevantcols, col_422129);
					if (!LOC7) goto LA8;
					aa = skiptypes_229245((*(*a).Typ).Sons->data[col_422129], IL64(211106247215360));
					bb = skiptypes_229245((*(*b).Typ).Sons->data[col_422129], IL64(211106247215360));
					d = inheritancediff_269588(aa, bb);
					{
						if (!!((d == IL64(9223372036854775807)))) goto LA12;
						result = d;
						goto BeforeRet;
					}
					LA12: ;
				}
				LA8: ;
				res_422141 += 1;
			} LA4: ;
		}
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, sortbucket_422158)(tsymseq224818** a, intset221056* relevantcols) {
	NI n;
	NI h;
	n = (*a)->Sup.len;
	h = 1;
	{
		while (1) {
			h = (NI64)((NI64)(3 * h) + 1);
			{
				if (!(n < h)) goto LA5;
				goto LA1;
			}
			LA5: ;
		}
	} LA1: ;
	{
		while (1) {
			h = (NI64)(h / 3);
			{
				NI i_422189;
				NI HEX3Atmp_422197;
				NI res_422200;
				i_422189 = 0;
				HEX3Atmp_422197 = 0;
				HEX3Atmp_422197 = (NI64)(n - 1);
				res_422200 = h;
				{
					while (1) {
						tsym224846* v;
						NI j;
						if (!(res_422200 <= HEX3Atmp_422197)) goto LA11;
						i_422189 = res_422200;
						v = (*a)->data[i_422189];
						j = i_422189;
						{
							while (1) {
								NI LOC14;
								LOC14 = 0;
								LOC14 = cmpsignatures_422111((*a)->data[(NI64)(j - h)], v, relevantcols);
								if (!(0 <= LOC14)) goto LA13;
								asgnRefNoCycle((void**) (&(*a)->data[j]), (*a)->data[(NI64)(j - h)]);
								j = (NI64)(j - h);
								{
									if (!(j < h)) goto LA17;
									goto LA12;
								}
								LA17: ;
							} LA13: ;
						} LA12: ;
						asgnRefNoCycle((void**) (&(*a)->data[j]), v);
						res_422200 += 1;
					} LA11: ;
				}
			}
			{
				if (!(h == 1)) goto LA21;
				goto LA7;
			}
			LA21: ;
		}
	} LA7: ;
}

N_NIMCALL(tsym224846*, gendispatcher_422235)(tsymseq224818* methods, intset221056* relevantcols) {
	tsym224846* result;
	tsym224846* base;
	tnode224816* LOC1;
	NI paramlen;
	tnode224816* disp;
	tsym224846* ands;
	tsym224846* iss;
	result = 0;
	LOC1 = 0;
	LOC1 = lastson_225261((*methods->data[0]).Ast);
	base = (*LOC1).kindU.S4.Sym;
	result = base;
	paramlen = sonslen_225255((*base).Typ);
	disp = newnodei_225138(((NU8) 92), (*base).Info);
	ands = getsyssym_281054(((NimStringDesc*) &TMP4080));
	iss = getsyssym_281054(((NimStringDesc*) &TMP4081));
	{
		NI meth_422271;
		NI HEX3Atmp_422470;
		NI res_422473;
		meth_422271 = 0;
		HEX3Atmp_422470 = 0;
		HEX3Atmp_422470 = (methods->Sup.len-1);
		res_422473 = 0;
		{
			while (1) {
				tsym224846* curr;
				tnode224816* cond;
				tnode224816* call;
				tnode224816* LOC24;
				tnode224816* ret;
				if (!(res_422473 <= HEX3Atmp_422470)) goto LA4;
				meth_422271 = res_422473;
				curr = methods->data[meth_422271];
				cond = NIM_NIL;
				{
					NI col_422286;
					NI HEX3Atmp_422458;
					NI res_422461;
					col_422286 = 0;
					HEX3Atmp_422458 = 0;
					HEX3Atmp_422458 = (NI64)(paramlen - 1);
					res_422461 = 1;
					{
						while (1) {
							if (!(res_422461 <= HEX3Atmp_422458)) goto LA7;
							col_422286 = res_422461;
							{
								NIM_BOOL LOC10;
								tnode224816* isn;
								ttype224852* LOC13;
								tnode224816* LOC14;
								tnode224816* LOC15;
								tnode224816* LOC16;
								LOC10 = 0;
								LOC10 = contains_221837(relevantcols, col_422286);
								if (!LOC10) goto LA11;
								LOC13 = 0;
								LOC13 = getsystype_281030(((NU8) 1));
								isn = newnodeit_225145(((NU8) 27), (*base).Info, LOC13);
								LOC14 = 0;
								LOC14 = newsymnode_225132(iss);
								addson_225287(isn, LOC14);
								LOC15 = 0;
								LOC15 = newsymnode_225132((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_422286]).kindU.S4.Sym);
								addson_225287(isn, LOC15);
								LOC16 = 0;
								LOC16 = newnodeit_225145(((NU8) 4), (*base).Info, (*(*curr).Typ).Sons->data[col_422286]);
								addson_225287(isn, LOC16);
								{
									tnode224816* a;
									ttype224852* LOC21;
									tnode224816* LOC22;
									if (!!((cond == NIM_NIL))) goto LA19;
									LOC21 = 0;
									LOC21 = getsystype_281030(((NU8) 1));
									a = newnodeit_225145(((NU8) 27), (*base).Info, LOC21);
									LOC22 = 0;
									LOC22 = newsymnode_225132(ands);
									addson_225287(a, LOC22);
									addson_225287(a, cond);
									addson_225287(a, isn);
									cond = a;
								}
								goto LA17;
								LA19: ;
								{
									cond = isn;
								}
								LA17: ;
							}
							LA11: ;
							res_422461 += 1;
						} LA7: ;
					}
				}
				call = newnodei_225138(((NU8) 27), (*base).Info);
				LOC24 = 0;
				LOC24 = newsymnode_225132(curr);
				addson_225287(call, LOC24);
				{
					NI col_422347;
					NI HEX3Atmp_422464;
					NI res_422467;
					col_422347 = 0;
					HEX3Atmp_422464 = 0;
					HEX3Atmp_422464 = (NI64)(paramlen - 1);
					res_422467 = 1;
					{
						while (1) {
							tnode224816* LOC28;
							tnode224816* LOC29;
							if (!(res_422467 <= HEX3Atmp_422464)) goto LA27;
							col_422347 = res_422467;
							LOC28 = 0;
							LOC28 = newsymnode_225132((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_422347]).kindU.S4.Sym);
							LOC29 = 0;
							LOC29 = genconv_421017(LOC28, (*(*curr).Typ).Sons->data[col_422347], NIM_FALSE);
							addson_225287(call, LOC29);
							res_422467 += 1;
						} LA27: ;
					}
				}
				ret = 0;
				{
					tnode224816* a;
					tnode224816* LOC34;
					if (!!(((*(*base).Typ).Sons->data[0] == NIM_NIL))) goto LA32;
					a = newnodei_225138(((NU8) 73), (*base).Info);
					LOC34 = 0;
					LOC34 = newsymnode_225132((*(*(*base).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym);
					addson_225287(a, LOC34);
					addson_225287(a, call);
					ret = newnodei_225138(((NU8) 109), (*base).Info);
					addson_225287(ret, a);
				}
				goto LA30;
				LA32: ;
				{
					ret = call;
				}
				LA30: ;
				{
					tnode224816* a;
					if (!!((cond == NIM_NIL))) goto LA38;
					a = newnodei_225138(((NU8) 86), (*base).Info);
					addson_225287(a, cond);
					addson_225287(a, ret);
					addson_225287(disp, a);
				}
				goto LA36;
				LA38: ;
				{
					disp = ret;
				}
				LA36: ;
				res_422473 += 1;
			} LA4: ;
		}
	}
	asgnRefNoCycle((void**) (&(*(*result).Ast).kindU.S6.Sons->data[6]), disp);
	return result;
}

N_NIMCALL(tnode224816*, generatemethoddispatchers_422508)(void) {
	tnode224816* result;
	result = 0;
	result = newnode_225090(((NU8) 115));
	{
		NI bucket_422534;
		NI HEX3Atmp_422558;
		NI res_422561;
		bucket_422534 = 0;
		HEX3Atmp_422558 = 0;
		HEX3Atmp_422558 = (NI64)(gmethods_421315->Sup.len - 1);
		res_422561 = 0;
		{
			while (1) {
				intset221056 relevantcols;
				tsym224846* LOC13;
				tnode224816* LOC14;
				if (!(res_422561 <= HEX3Atmp_422558)) goto LA3;
				bucket_422534 = res_422561;
				memset((void*)(&relevantcols), 0, sizeof(relevantcols));
				chckNil((void*)(&relevantcols));
				memset((void*)(&relevantcols), 0, sizeof(relevantcols));
				initintset_221950((&relevantcols));
				{
					NI col_422548;
					NI HEX3Atmp_422553;
					NI LOC5;
					NI res_422556;
					col_422548 = 0;
					HEX3Atmp_422553 = 0;
					LOC5 = 0;
					LOC5 = sonslen_225255((*gmethods_421315->data[bucket_422534].Field0->data[0]).Typ);
					HEX3Atmp_422553 = (NI64)(LOC5 - 1);
					res_422556 = 1;
					{
						while (1) {
							if (!(res_422556 <= HEX3Atmp_422553)) goto LA7;
							col_422548 = res_422556;
							{
								NIM_BOOL LOC10;
								LOC10 = 0;
								LOC10 = relevantcol_422061(gmethods_421315->data[bucket_422534].Field0, col_422548);
								if (!LOC10) goto LA11;
								incl_221869((&relevantcols), col_422548);
							}
							LA11: ;
							res_422556 += 1;
						} LA7: ;
					}
				}
				sortbucket_422158((&gmethods_421315->data[bucket_422534].Field0), (&relevantcols));
				LOC13 = 0;
				LOC13 = gendispatcher_422235(gmethods_421315->data[bucket_422534].Field0, (&relevantcols));
				LOC14 = 0;
				LOC14 = newsymnode_225132(LOC13);
				addson_225287(result, LOC14);
				res_422561 += 1;
			} LA3: ;
		}
	}
	return result;
}
NIM_EXTERNC N_NOINLINE(void, HEX00_cgmethInit)(void) {
	if (gmethods_421315) nimGCunrefNoCycle(gmethods_421315);
	gmethods_421315 = (TY421291*) newSeqRC1((&NTI421291), 0);
}

NIM_EXTERNC N_NOINLINE(void, HEX00_cgmethDatInit)(void) {
static TNimNode* TMP930[2];
static TNimNode TMP928[3];
NTI421292.size = sizeof(TY421292);
NTI421292.kind = 18;
NTI421292.base = 0;
NTI421292.flags = 2;
TMP930[0] = &TMP928[1];
TMP928[1].kind = 1;
TMP928[1].offset = offsetof(TY421292, Field0);
TMP928[1].typ = (&NTI224818);
TMP928[1].name = "Field0";
TMP930[1] = &TMP928[2];
TMP928[2].kind = 1;
TMP928[2].offset = offsetof(TY421292, Field1);
TMP928[2].typ = (&NTI224814);
TMP928[2].name = "Field1";
TMP928[0].len = 2; TMP928[0].kind = 2; TMP928[0].sons = &TMP930[0];
NTI421292.node = &TMP928[0];
NTI421291.size = sizeof(TY421291*);
NTI421291.kind = 24;
NTI421291.base = (&NTI421292);
NTI421291.flags = 2;
NTI421291.marker = TMP931;
}

