/* Generated by Nim Compiler v0.10.2 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <string.h>
typedef struct TY423291 TY423291;
typedef struct TY423292 TY423292;
typedef struct tsymseq226818 tsymseq226818;
typedef struct tsym226846 tsym226846;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell44933 tcell44933;
typedef struct tcellseq44949 tcellseq44949;
typedef struct tgcheap47016 tgcheap47016;
typedef struct tcellset44945 tcellset44945;
typedef struct tpagedesc44941 tpagedesc44941;
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 tidobj201015 tidobj201015;
typedef struct TNimObject TNimObject;
typedef struct ttypeseq226848 ttypeseq226848;
typedef struct ttype226852 ttype226852;
typedef struct tscope226840 tscope226840;
typedef struct TY226947 TY226947;
typedef struct tinstantiation226836 tinstantiation226836;
typedef struct tstrtable226820 tstrtable226820;
typedef struct tident201021 tident201021;
typedef struct tlineinfo196539 tlineinfo196539;
typedef struct tnode226816 tnode226816;
typedef struct tloc226830 tloc226830;
typedef struct trope178009 trope178009;
typedef struct tlib226834 tlib226834;
typedef struct NimStringDesc NimStringDesc;
typedef struct tnodeseq226810 tnodeseq226810;
typedef struct intset223056 intset223056;
typedef struct ttrunk223052 ttrunk223052;
typedef struct ttrunkseq223054 ttrunkseq223054;
typedef struct tbasechunk26438 tbasechunk26438;
typedef struct tfreecell26430 tfreecell26430;
typedef struct TY226936 TY226936;
typedef struct tlistentry127022 tlistentry127022;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct TY423292 {
tsymseq226818* Field0;
tsym226846* 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  tcell44933  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq44949  {
NI Len;
NI Cap;
tcell44933** D;
};
struct  tcellset44945  {
NI Counter;
NI Max;
tpagedesc44941* Head;
tpagedesc44941** 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;
tcellseq44949 Zct;
tcellseq44949 Decstack;
tcellset44945 Cycleroots;
tcellseq44949 Tempstack;
NI Recgclock;
tmemregion27210 Region;
tgcstat47014 Stat;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tidobj201015  {
  TNimObject Sup;
NI Id;
};
struct  tstrtable226820  {
NI Counter;
tsymseq226818* Data;
};
struct  tlineinfo196539  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  tloc226830  {
NU8 K;
NU8 S;
NU8 Flags;
ttype226852* T;
trope178009* R;
trope178009* Heaproot;
};
struct  tsym226846  {
  tidobj201015 Sup;
NU8 Kind;
union {
struct {ttypeseq226848* Typeinstcache;
tscope226840* Typscope;
} S1;
struct {TY226947* Procinstcache;
tscope226840* Scope;
} S2;
struct {TY226947* Usedgenerics;
tstrtable226820 Tab;
} S3;
struct {tsym226846* Guard;
} S4;
} kindU;
NU16 Magic;
ttype226852* Typ;
tident201021* Name;
tlineinfo196539 Info;
tsym226846* Owner;
NU32 Flags;
tnode226816* Ast;
NU32 Options;
NI Position;
NI Offset;
tloc226830 Loc;
tlib226834* Annex;
tnode226816* Constraint;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  tident201021  {
  tidobj201015 Sup;
NimStringDesc* S;
tident201021* Next;
NI H;
};
struct  ttype226852  {
  tidobj201015 Sup;
NU8 Kind;
NU8 Callconv;
NU32 Flags;
ttypeseq226848* Sons;
tnode226816* N;
tsym226846* Owner;
tsym226846* Sym;
tsym226846* Destructor;
tsym226846* Deepcopy;
NI64 Size;
NI16 Align;
NI16 Locklevel;
tloc226830 Loc;
};
struct  tnode226816  {
ttype226852* Typ;
tlineinfo196539 Info;
NU16 Flags;
NU8 Kind;
union {
struct {NI64 Intval;
} S1;
struct {NF Floatval;
} S2;
struct {NimStringDesc* Strval;
} S3;
struct {tsym226846* Sym;
} S4;
struct {tident201021* Ident;
} S5;
struct {tnodeseq226810* Sons;
} S6;
} kindU;
NimStringDesc* Comment;
};
typedef NimStringDesc* TY170969[2];
typedef tsym226846* TY291499[1];
struct  intset223056  {
NI Counter;
NI Max;
ttrunk223052* Head;
ttrunkseq223054* Data;
};
typedef NI TY26420[16];
struct  tpagedesc44941  {
tpagedesc44941* 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  tscope226840  {
NI Depthlevel;
tstrtable226820 Symbols;
tnodeseq226810* Usingsyms;
tscope226840* Parent;
};
struct  tinstantiation226836  {
tsym226846* Sym;
ttypeseq226848* Concretetypes;
TY226936* Usedby;
};
struct  trope178009  {
  TNimObject Sup;
trope178009* Left;
trope178009* Right;
NI Length;
NimStringDesc* Data;
};
struct  tlistentry127022  {
  TNimObject Sup;
tlistentry127022* Prev;
tlistentry127022* Next;
};
struct  tlib226834  {
  tlistentry127022 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope178009* Name;
tnode226816* Path;
};
struct  ttrunk223052  {
ttrunk223052* Next;
NI Key;
TY26420 Bits;
};
struct  tfreecell26430  {
tfreecell26430* Next;
NI Zerofield;
};
struct tsymseq226818 {
  TGenericSeq Sup;
  tsym226846* data[SEQ_DECL_SIZE];
};
struct TY423291 {
  TGenericSeq Sup;
  TY423292 data[SEQ_DECL_SIZE];
};
struct ttypeseq226848 {
  TGenericSeq Sup;
  ttype226852* data[SEQ_DECL_SIZE];
};
struct TY226947 {
  TGenericSeq Sup;
  tinstantiation226836* data[SEQ_DECL_SIZE];
};
struct tnodeseq226810 {
  TGenericSeq Sup;
  tnode226816* data[SEQ_DECL_SIZE];
};
struct ttrunkseq223054 {
  TGenericSeq Sup;
  ttrunk223052* data[SEQ_DECL_SIZE];
};
struct TY226936 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP933)(void* p, NI op);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(tcell44933*, usrtocell_48646)(void* usr);
static N_INLINE(void, rtladdzct_50204)(tcell44933* c);
N_NOINLINE(void, addzct_48617)(tcellseq44949* s, tcell44933* c);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(NIM_BOOL, samemethodbucket_423320)(tsym226846* a, tsym226846* b);
static N_INLINE(NI, sonslen_227255)(ttype226852* n);
N_NIMCALL(NIM_BOOL, sametypeornil_269367)(ttype226852* a, ttype226852* b, NU8 flags);
N_NIMCALL(ttype226852*, skiptypes_231245)(ttype226852* t, NU64 kinds);
static N_INLINE(ttype226852*, lastson_227267)(ttype226852* n);
N_NIMCALL(NIM_BOOL, sametype_269351)(ttype226852* a, ttype226852* b, NU8 flags);
N_NIMCALL(NI, inheritancediff_271588)(ttype226852* a, ttype226852* b);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(void, attachdispatcher_423412)(tsym226846* s, tnode226816* dispatcher);
static N_INLINE(NI, len_227364)(tnode226816* n);
N_NIMCALL(void, add_227498)(tnode226816* father, tnode226816* son);
static N_INLINE(tnode226816*, lastson_227261)(tnode226816* n);
static N_INLINE(NI, sonslen_227249)(tnode226816* n);
N_NIMCALL(void, fixupdispatcher_423628)(tsym226846* meth, tsym226846* disp);
N_NIMCALL(tnode226816*, copytree_227329)(tnode226816* src);
N_NIMCALL(void, message_198976)(tlineinfo196539 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr, NimStringDesc** a, NI aLen0);
N_NIMCALL(NimStringDesc*, HEX24_229488)(NI16 x);
N_NIMCALL(void, checkmethodeffects_384471)(tsym226846* disp, tsym226846* branch);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(tsym226846*, createdispatcher_423488)(tsym226846* s);
N_NIMCALL(tsym226846*, copysym_227203)(tsym226846* s, NIM_BOOL keepid);
N_NIMCALL(ttype226852*, copytype_227195)(ttype226852* t, tsym226846* owner, NIM_BOOL keepid);
N_NIMCALL(void, addson_227287)(tnode226816* father, tnode226816* son);
N_NIMCALL(tnode226816*, newsymnode_227132)(tsym226846* sym);
N_NIMCALL(void, genericSeqAssign)(void* dest, void* src_79604, TNimType* mt);
N_NIMCALL(void, internalerror_198987)(tlineinfo196539 info, NimStringDesc* errmsg);
N_NIMCALL(tnode226816*, genconv_423017)(tnode226816* n, ttype226852* d, NIM_BOOL downcast);
N_NIMCALL(tnode226816*, newnodeit_227145)(NU8 kind, tlineinfo196539 info, ttype226852* typ);
N_NIMCALL(tnode226816*, newnode_227090)(NU8 kind);
N_NIMCALL(void, initintset_223950)(intset223056* Result);
N_NOINLINE(void, chckNil)(void* p);
N_NIMCALL(NIM_BOOL, relevantcol_424061)(tsymseq226818* methods, NI col);
N_NIMCALL(void, incl_223869)(intset223056* s, NI key);
N_NIMCALL(void, sortbucket_424158)(tsymseq226818** a, intset223056 relevantcols);
N_NIMCALL(NI, cmpsignatures_424111)(tsym226846* a, tsym226846* b, intset223056 relevantcols);
N_NIMCALL(NIM_BOOL, contains_223837)(intset223056 s, NI key);
N_NIMCALL(tsym226846*, gendispatcher_424235)(tsymseq226818* methods, intset223056 relevantcols);
N_NIMCALL(tnode226816*, newnodei_227138)(NU8 kind, tlineinfo196539 info);
N_NIMCALL(tsym226846*, getsyssym_283054)(NimStringDesc* name);
N_NIMCALL(ttype226852*, getsystype_283030)(NU8 kind);
STRING_LITERAL(TMP3146, "method has lock level $1, but another method has $2", 51);
STRING_LITERAL(TMP3154, "no method dispatcher found", 26);
STRING_LITERAL(TMP3155, "cgmeth.genConv", 14);
STRING_LITERAL(TMP3156, "cgmeth.genConv: no upcast allowed", 33);
STRING_LITERAL(TMP3157, "cgmeth.genConv: no downcast allowed", 35);
STRING_LITERAL(TMP4082, "and", 3);
STRING_LITERAL(TMP4083, "of", 2);
TY423291* gmethods_423315;
TNimType NTI423292; /* tuple[methods: TSymSeq, dispatcher: PSym] */
extern TNimType NTI226818; /* TSymSeq */
extern TNimType NTI226814; /* PSym */
TNimType NTI423291; /* seq[tuple[methods: TSymSeq, dispatcher: PSym]] */
extern tgcheap47016 gch_47044;
extern tnode226816* emptynode_227738;
N_NIMCALL(void, TMP933)(void* p, NI op) {
	TY423291* a;
	NI LOC1;
	a = (TY423291*)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(tcell44933*, usrtocell_48646)(void* usr) {
	tcell44933* result;
	result = 0;
	result = ((tcell44933*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(tcell44933))))));
	return result;
}

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

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

static N_INLINE(NI, sonslen_227255)(ttype226852* 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(ttype226852*, lastson_227267)(ttype226852* n) {
	ttype226852* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = sonslen_227255(n);
	result = (*n).Sons->data[(NI32)(LOC1 - 1)];
	return result;
}

N_NIMCALL(NIM_BOOL, samemethodbucket_423320)(tsym226846* a, tsym226846* 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_227255((*a).Typ);
		LOC8 = 0;
		LOC8 = sonslen_227255((*b).Typ);
		if (!!((LOC7 == LOC8))) goto LA9;
		goto BeforeRet;
	}
	LA9: ;
	{
		NIM_BOOL LOC13;
		LOC13 = 0;
		LOC13 = sametypeornil_269367((*(*a).Typ).Sons->data[0], (*(*b).Typ).Sons->data[0], 0);
		if (!!(LOC13)) goto LA14;
		goto BeforeRet;
	}
	LA14: ;
	{
		NI i_423337;
		NI HEX3Atmp_423386;
		NI LOC17;
		NI res_423389;
		i_423337 = 0;
		HEX3Atmp_423386 = 0;
		LOC17 = 0;
		LOC17 = sonslen_227255((*a).Typ);
		HEX3Atmp_423386 = (NI32)(LOC17 - 1);
		res_423389 = 1;
		{
			while (1) {
				ttype226852* aa;
				ttype226852* bb;
				if (!(res_423389 <= HEX3Atmp_423386)) goto LA19;
				i_423337 = res_423389;
				aa = (*(*a).Typ).Sons->data[i_423337];
				bb = (*(*b).Typ).Sons->data[i_423337];
				{
					while (1) {
						aa = skiptypes_231245(aa, 2048);
						bb = skiptypes_231245(bb, 2048);
						{
							NIM_BOOL LOC24;
							LOC24 = 0;
							LOC24 = ((*aa).Kind == (*bb).Kind);
							if (!(LOC24)) goto LA25;
							LOC24 = ((*aa).Kind == ((NU8) 23) || (*aa).Kind == ((NU8) 21) || (*aa).Kind == ((NU8) 22));
							LA25: ;
							if (!LOC24) goto LA26;
							aa = lastson_227267(aa);
							bb = lastson_227267(bb);
						}
						goto LA22;
						LA26: ;
						{
							goto LA20;
						}
						LA22: ;
					}
				} LA20: ;
				{
					NIM_BOOL LOC31;
					NIM_BOOL LOC33;
					NIM_BOOL LOC34;
					NI LOC37;
					LOC31 = 0;
					LOC31 = sametype_269351(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_271588(bb, aa);
					LOC33 = (LOC37 < 0);
					LA36: ;
					LOC31 = LOC33;
					LA32: ;
					if (!LOC31) goto LA38;
				}
				goto LA29;
				LA38: ;
				{
					goto BeforeRet;
				}
				LA29: ;
				res_423389 += 1;
			} LA19: ;
		}
	}
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

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

static N_INLINE(NI, len_227364)(tnode226816* 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_423412)(tsym226846* s, tnode226816* dispatcher) {
	NI l;
	NI LOC1;
	tnode226816* x;
	LOC1 = 0;
	LOC1 = len_227364((*s).Ast);
	l = (NI32)(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_227498((*s).Ast, dispatcher);
	}
	LA2: ;
}

static N_INLINE(NI, sonslen_227249)(tnode226816* 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(tnode226816*, lastson_227261)(tnode226816* n) {
	tnode226816* result;
	NI LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = sonslen_227249(n);
	result = (*n).kindU.S6.Sons->data[(NI32)(LOC1 - 1)];
	return result;
}

N_NIMCALL(void, fixupdispatcher_423628)(tsym226846* meth, tsym226846* disp) {
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		NI LOC5;
		NI LOC7;
		LOC3 = 0;
		LOC4 = 0;
		LOC5 = 0;
		LOC5 = sonslen_227249((*disp).Ast);
		LOC4 = (7 < LOC5);
		if (!(LOC4)) goto LA6;
		LOC7 = 0;
		LOC7 = sonslen_227249((*meth).Ast);
		LOC4 = (7 < LOC7);
		LA6: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA8;
		LOC3 = ((*(*disp).Ast).kindU.S6.Sons->data[7] == emptynode_227738);
		LA8: ;
		if (!LOC3) goto LA9;
		asgnRefNoCycle((void**) (&(*(*disp).Ast).kindU.S6.Sons->data[7]), copytree_227329((*(*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;
		TY170969 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_229488((*(*meth).Typ).Locklevel);
		LOC20[1] = HEX24_229488((*(*disp).Typ).Locklevel);
		LOC21 = 0;
		LOC21 = nsuFormatOpenArray(((NimStringDesc*) &TMP3146), LOC20, 2);
		message_198976((*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(tsym226846*, createdispatcher_423488)(tsym226846* s) {
	tsym226846* result;
	tsym226846* disp;
	tnode226816* LOC15;
	tnode226816* LOC16;
	result = 0;
	disp = copysym_227203(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_227195((*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_227329((*s).Ast));
	asgnRefNoCycle((void**) (&(*(*disp).Ast).kindU.S6.Sons->data[6]), emptynode_227738);
	asgnRefNoCycle((void**) (&(*disp).Loc.R), NIM_NIL);
	{
		if (!!(((*(*s).Typ).Sons->data[0] == NIM_NIL))) goto LA7;
		{
			NI LOC11;
			LOC11 = 0;
			LOC11 = sonslen_227249((*disp).Ast);
			if (!(7 < LOC11)) goto LA12;
			asgnRefNoCycle((void**) (&(*(*(*disp).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym), copysym_227203((*(*(*s).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym, NIM_FALSE));
		}
		goto LA9;
		LA12: ;
		{
			addson_227287((*disp).Ast, emptynode_227738);
		}
		LA9: ;
	}
	LA7: ;
	LOC15 = 0;
	LOC15 = newsymnode_227132(disp);
	attachdispatcher_423412(s, LOC15);
	LOC16 = 0;
	LOC16 = newsymnode_227132(disp);
	attachdispatcher_423412(disp, LOC16);
	result = disp;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, methoddef_423824)(tsym226846* s, NIM_BOOL fromcache) {
	NI l;
	TY423292 LOC10;
	TY291499 LOC11;
	l = gmethods_423315->Sup.len;
	{
		NI i_423852;
		NI HEX3Atmp_424041;
		NI res_424044;
		i_423852 = 0;
		HEX3Atmp_424041 = 0;
		HEX3Atmp_424041 = (NI32)(l - 1);
		res_424044 = 0;
		{
			while (1) {
				tsym226846* disp;
				if (!(res_424044 <= HEX3Atmp_424041)) goto LA3;
				i_423852 = res_424044;
				disp = gmethods_423315->data[i_423852].Field1;
				{
					NIM_BOOL LOC6;
					tnode226816* LOC9;
					LOC6 = 0;
					LOC6 = samemethodbucket_423320(disp, s);
					if (!LOC6) goto LA7;
					gmethods_423315->data[i_423852].Field0 = (tsymseq226818*) incrSeq(&(gmethods_423315->data[i_423852].Field0)->Sup, sizeof(tsym226846*));
					asgnRefNoCycle((void**) (&gmethods_423315->data[i_423852].Field0->data[gmethods_423315->data[i_423852].Field0->Sup.len-1]), s);
					LOC9 = 0;
					LOC9 = lastson_227261((*disp).Ast);
					attachdispatcher_423412(s, LOC9);
					fixupdispatcher_423628(s, disp);
					checkmethodeffects_384471(disp, s);
					goto BeforeRet;
				}
				LA7: ;
				res_424044 += 1;
			} LA3: ;
		}
	}
	memset((void*)(&LOC10), 0, sizeof(LOC10));
	LOC10.Field0 = (tsymseq226818*) newSeq((&NTI226818), 1);
	memset((void*)LOC11, 0, sizeof(LOC11));
	LOC11[0] = s;
	asgnRefNoCycle((void**) (&LOC10.Field0->data[0]), LOC11[0]);
	LOC10.Field1 = createdispatcher_423488(s);
	gmethods_423315 = (TY423291*) incrSeq(&(gmethods_423315)->Sup, sizeof(TY423292));
	genericSeqAssign((&gmethods_423315->data[gmethods_423315->Sup.len-1].Field0), LOC10.Field0, (&NTI226818));
	asgnRefNoCycle((void**) (&gmethods_423315->data[gmethods_423315->Sup.len-1].Field1), LOC10.Field1);
	{
		if (!fromcache) goto LA14;
		internalerror_198987((*s).Info, ((NimStringDesc*) &TMP3154));
	}
	LA14: ;
	BeforeRet: ;
}

N_NIMCALL(tnode226816*, genconv_423017)(tnode226816* n, ttype226852* d, NIM_BOOL downcast) {
	tnode226816* result;
	ttype226852* dest;
	ttype226852* source;
	result = 0;
	dest = skiptypes_231245(d, IL64(211106247256320));
	source = skiptypes_231245((*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_271588(dest, source);
		{
			if (!(diff == 2147483647)) goto LA9;
			internalerror_198987((*n).Info, ((NimStringDesc*) &TMP3155));
		}
		LA9: ;
		{
			if (!(diff < 0)) goto LA13;
			result = newnodeit_227145(((NU8) 67), (*n).Info, d);
			addson_227287(result, n);
			{
				if (!downcast) goto LA17;
				internalerror_198987((*n).Info, ((NimStringDesc*) &TMP3156));
			}
			LA17: ;
		}
		goto LA11;
		LA13: ;
		{
			if (!(0 < diff)) goto LA20;
			result = newnodeit_227145(((NU8) 66), (*n).Info, d);
			addson_227287(result, n);
			{
				if (!!(downcast)) goto LA24;
				internalerror_198987((*n).Info, ((NimStringDesc*) &TMP3157));
			}
			LA24: ;
		}
		goto LA11;
		LA20: ;
		{
			result = n;
		}
		LA11: ;
	}
	goto LA1;
	LA5: ;
	{
		result = n;
	}
	LA1: ;
	return result;
}

N_NIMCALL(tnode226816*, methodcall_423056)(tnode226816* n) {
	tnode226816* result;
	tsym226846* disp;
	tnode226816* LOC1;
	result = 0;
	result = n;
	LOC1 = 0;
	LOC1 = lastson_227261((*(*(*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_423241;
		NI HEX3Atmp_423271;
		NI LOC3;
		NI res_423274;
		i_423241 = 0;
		HEX3Atmp_423271 = 0;
		LOC3 = 0;
		LOC3 = sonslen_227249(result);
		HEX3Atmp_423271 = (NI32)(LOC3 - 1);
		res_423274 = 1;
		{
			while (1) {
				if (!(res_423274 <= HEX3Atmp_423271)) goto LA5;
				i_423241 = res_423274;
				asgnRefNoCycle((void**) (&(*result).kindU.S6.Sons->data[i_423241]), genconv_423017((*result).kindU.S6.Sons->data[i_423241], (*(*disp).Typ).Sons->data[i_423241], NIM_TRUE));
				res_423274 += 1;
			} LA5: ;
		}
	}
	return result;
}

N_NIMCALL(NIM_BOOL, relevantcol_424061)(tsymseq226818* methods, NI col) {
	NIM_BOOL result;
	ttype226852* t;
	result = 0;
	t = skiptypes_231245((*(*methods->data[0]).Typ).Sons->data[col], IL64(211106247215360));
	{
		if (!((*t).Kind == ((NU8) 17))) goto LA3;
		{
			NI i_424088;
			NI HEX3Atmp_424091;
			NI res_424094;
			i_424088 = 0;
			HEX3Atmp_424091 = 0;
			HEX3Atmp_424091 = (methods->Sup.len-1);
			res_424094 = 1;
			{
				while (1) {
					ttype226852* t2;
					if (!(res_424094 <= HEX3Atmp_424091)) goto LA7;
					i_424088 = res_424094;
					t2 = skiptypes_231245((*(*methods->data[i_424088]).Typ).Sons->data[col], IL64(211106247215360));
					{
						NIM_BOOL LOC10;
						LOC10 = 0;
						LOC10 = sametype_269351(t2, t, 0);
						if (!!(LOC10)) goto LA11;
						result = NIM_TRUE;
						goto BeforeRet;
					}
					LA11: ;
					res_424094 += 1;
				} LA7: ;
			}
		}
	}
	LA3: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NI, cmpsignatures_424111)(tsym226846* a, tsym226846* b, intset223056 relevantcols) {
	NI result;
	result = 0;
	{
		NI col_424129;
		NI HEX3Atmp_424138;
		NI LOC2;
		NI res_424141;
		col_424129 = 0;
		HEX3Atmp_424138 = 0;
		LOC2 = 0;
		LOC2 = sonslen_227255((*a).Typ);
		HEX3Atmp_424138 = (NI32)(LOC2 - 1);
		res_424141 = 1;
		{
			while (1) {
				if (!(res_424141 <= HEX3Atmp_424138)) goto LA4;
				col_424129 = res_424141;
				{
					NIM_BOOL LOC7;
					ttype226852* aa;
					ttype226852* bb;
					NI d;
					LOC7 = 0;
					LOC7 = contains_223837(relevantcols, col_424129);
					if (!LOC7) goto LA8;
					aa = skiptypes_231245((*(*a).Typ).Sons->data[col_424129], IL64(211106247215360));
					bb = skiptypes_231245((*(*b).Typ).Sons->data[col_424129], IL64(211106247215360));
					d = inheritancediff_271588(aa, bb);
					{
						if (!!((d == 2147483647))) goto LA12;
						result = d;
						goto BeforeRet;
					}
					LA12: ;
				}
				LA8: ;
				res_424141 += 1;
			} LA4: ;
		}
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, sortbucket_424158)(tsymseq226818** a, intset223056 relevantcols) {
	NI n;
	NI h;
	n = (*a)->Sup.len;
	h = 1;
	{
		while (1) {
			h = (NI32)((NI32)(3 * h) + 1);
			{
				if (!(n < h)) goto LA5;
				goto LA1;
			}
			LA5: ;
		}
	} LA1: ;
	{
		while (1) {
			h = (NI32)(h / 3);
			{
				NI i_424189;
				NI HEX3Atmp_424197;
				NI res_424200;
				i_424189 = 0;
				HEX3Atmp_424197 = 0;
				HEX3Atmp_424197 = (NI32)(n - 1);
				res_424200 = h;
				{
					while (1) {
						tsym226846* v;
						NI j;
						if (!(res_424200 <= HEX3Atmp_424197)) goto LA11;
						i_424189 = res_424200;
						v = (*a)->data[i_424189];
						j = i_424189;
						{
							while (1) {
								NI LOC14;
								LOC14 = 0;
								LOC14 = cmpsignatures_424111((*a)->data[(NI32)(j - h)], v, relevantcols);
								if (!(0 <= LOC14)) goto LA13;
								asgnRefNoCycle((void**) (&(*a)->data[j]), (*a)->data[(NI32)(j - h)]);
								j = (NI32)(j - h);
								{
									if (!(j < h)) goto LA17;
									goto LA12;
								}
								LA17: ;
							} LA13: ;
						} LA12: ;
						asgnRefNoCycle((void**) (&(*a)->data[j]), v);
						res_424200 += 1;
					} LA11: ;
				}
			}
			{
				if (!(h == 1)) goto LA21;
				goto LA7;
			}
			LA21: ;
		}
	} LA7: ;
}

N_NIMCALL(tsym226846*, gendispatcher_424235)(tsymseq226818* methods, intset223056 relevantcols) {
	tsym226846* result;
	tsym226846* base;
	tnode226816* LOC1;
	NI paramlen;
	tnode226816* disp;
	tsym226846* ands;
	tsym226846* iss;
	result = 0;
	LOC1 = 0;
	LOC1 = lastson_227261((*methods->data[0]).Ast);
	base = (*LOC1).kindU.S4.Sym;
	result = base;
	paramlen = sonslen_227255((*base).Typ);
	disp = newnodei_227138(((NU8) 92), (*base).Info);
	ands = getsyssym_283054(((NimStringDesc*) &TMP4082));
	iss = getsyssym_283054(((NimStringDesc*) &TMP4083));
	{
		NI meth_424271;
		NI HEX3Atmp_424470;
		NI res_424473;
		meth_424271 = 0;
		HEX3Atmp_424470 = 0;
		HEX3Atmp_424470 = (methods->Sup.len-1);
		res_424473 = 0;
		{
			while (1) {
				tsym226846* curr;
				tnode226816* cond;
				tnode226816* call;
				tnode226816* LOC24;
				tnode226816* ret;
				if (!(res_424473 <= HEX3Atmp_424470)) goto LA4;
				meth_424271 = res_424473;
				curr = methods->data[meth_424271];
				cond = NIM_NIL;
				{
					NI col_424286;
					NI HEX3Atmp_424458;
					NI res_424461;
					col_424286 = 0;
					HEX3Atmp_424458 = 0;
					HEX3Atmp_424458 = (NI32)(paramlen - 1);
					res_424461 = 1;
					{
						while (1) {
							if (!(res_424461 <= HEX3Atmp_424458)) goto LA7;
							col_424286 = res_424461;
							{
								NIM_BOOL LOC10;
								tnode226816* isn;
								ttype226852* LOC13;
								tnode226816* LOC14;
								tnode226816* LOC15;
								tnode226816* LOC16;
								LOC10 = 0;
								LOC10 = contains_223837(relevantcols, col_424286);
								if (!LOC10) goto LA11;
								LOC13 = 0;
								LOC13 = getsystype_283030(((NU8) 1));
								isn = newnodeit_227145(((NU8) 27), (*base).Info, LOC13);
								LOC14 = 0;
								LOC14 = newsymnode_227132(iss);
								addson_227287(isn, LOC14);
								LOC15 = 0;
								LOC15 = newsymnode_227132((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_424286]).kindU.S4.Sym);
								addson_227287(isn, LOC15);
								LOC16 = 0;
								LOC16 = newnodeit_227145(((NU8) 4), (*base).Info, (*(*curr).Typ).Sons->data[col_424286]);
								addson_227287(isn, LOC16);
								{
									tnode226816* a;
									ttype226852* LOC21;
									tnode226816* LOC22;
									if (!!((cond == NIM_NIL))) goto LA19;
									LOC21 = 0;
									LOC21 = getsystype_283030(((NU8) 1));
									a = newnodeit_227145(((NU8) 27), (*base).Info, LOC21);
									LOC22 = 0;
									LOC22 = newsymnode_227132(ands);
									addson_227287(a, LOC22);
									addson_227287(a, cond);
									addson_227287(a, isn);
									cond = a;
								}
								goto LA17;
								LA19: ;
								{
									cond = isn;
								}
								LA17: ;
							}
							LA11: ;
							res_424461 += 1;
						} LA7: ;
					}
				}
				call = newnodei_227138(((NU8) 27), (*base).Info);
				LOC24 = 0;
				LOC24 = newsymnode_227132(curr);
				addson_227287(call, LOC24);
				{
					NI col_424347;
					NI HEX3Atmp_424464;
					NI res_424467;
					col_424347 = 0;
					HEX3Atmp_424464 = 0;
					HEX3Atmp_424464 = (NI32)(paramlen - 1);
					res_424467 = 1;
					{
						while (1) {
							tnode226816* LOC28;
							tnode226816* LOC29;
							if (!(res_424467 <= HEX3Atmp_424464)) goto LA27;
							col_424347 = res_424467;
							LOC28 = 0;
							LOC28 = newsymnode_227132((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_424347]).kindU.S4.Sym);
							LOC29 = 0;
							LOC29 = genconv_423017(LOC28, (*(*curr).Typ).Sons->data[col_424347], NIM_FALSE);
							addson_227287(call, LOC29);
							res_424467 += 1;
						} LA27: ;
					}
				}
				ret = 0;
				{
					tnode226816* a;
					tnode226816* LOC34;
					if (!!(((*(*base).Typ).Sons->data[0] == NIM_NIL))) goto LA32;
					a = newnodei_227138(((NU8) 73), (*base).Info);
					LOC34 = 0;
					LOC34 = newsymnode_227132((*(*(*base).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym);
					addson_227287(a, LOC34);
					addson_227287(a, call);
					ret = newnodei_227138(((NU8) 109), (*base).Info);
					addson_227287(ret, a);
				}
				goto LA30;
				LA32: ;
				{
					ret = call;
				}
				LA30: ;
				{
					tnode226816* a;
					if (!!((cond == NIM_NIL))) goto LA38;
					a = newnodei_227138(((NU8) 86), (*base).Info);
					addson_227287(a, cond);
					addson_227287(a, ret);
					addson_227287(disp, a);
				}
				goto LA36;
				LA38: ;
				{
					disp = ret;
				}
				LA36: ;
				res_424473 += 1;
			} LA4: ;
		}
	}
	asgnRefNoCycle((void**) (&(*(*result).Ast).kindU.S6.Sons->data[6]), disp);
	return result;
}

N_NIMCALL(tnode226816*, generatemethoddispatchers_424508)(void) {
	tnode226816* result;
	result = 0;
	result = newnode_227090(((NU8) 115));
	{
		NI bucket_424534;
		NI HEX3Atmp_424558;
		NI res_424561;
		bucket_424534 = 0;
		HEX3Atmp_424558 = 0;
		HEX3Atmp_424558 = (NI32)(gmethods_423315->Sup.len - 1);
		res_424561 = 0;
		{
			while (1) {
				intset223056 relevantcols;
				tsym226846* LOC13;
				tnode226816* LOC14;
				if (!(res_424561 <= HEX3Atmp_424558)) goto LA3;
				bucket_424534 = res_424561;
				memset((void*)(&relevantcols), 0, sizeof(relevantcols));
				chckNil((void*)(&relevantcols));
				memset((void*)(&relevantcols), 0, sizeof(relevantcols));
				initintset_223950((&relevantcols));
				{
					NI col_424548;
					NI HEX3Atmp_424553;
					NI LOC5;
					NI res_424556;
					col_424548 = 0;
					HEX3Atmp_424553 = 0;
					LOC5 = 0;
					LOC5 = sonslen_227255((*gmethods_423315->data[bucket_424534].Field0->data[0]).Typ);
					HEX3Atmp_424553 = (NI32)(LOC5 - 1);
					res_424556 = 1;
					{
						while (1) {
							if (!(res_424556 <= HEX3Atmp_424553)) goto LA7;
							col_424548 = res_424556;
							{
								NIM_BOOL LOC10;
								LOC10 = 0;
								LOC10 = relevantcol_424061(gmethods_423315->data[bucket_424534].Field0, col_424548);
								if (!LOC10) goto LA11;
								incl_223869((&relevantcols), col_424548);
							}
							LA11: ;
							res_424556 += 1;
						} LA7: ;
					}
				}
				sortbucket_424158((&gmethods_423315->data[bucket_424534].Field0), relevantcols);
				LOC13 = 0;
				LOC13 = gendispatcher_424235(gmethods_423315->data[bucket_424534].Field0, relevantcols);
				LOC14 = 0;
				LOC14 = newsymnode_227132(LOC13);
				addson_227287(result, LOC14);
				res_424561 += 1;
			} LA3: ;
		}
	}
	return result;
}
NIM_EXTERNC N_NOINLINE(void, HEX00_cgmethInit)(void) {
	if (gmethods_423315) nimGCunrefNoCycle(gmethods_423315);
	gmethods_423315 = (TY423291*) newSeqRC1((&NTI423291), 0);
}

NIM_EXTERNC N_NOINLINE(void, HEX00_cgmethDatInit)(void) {
static TNimNode* TMP932[2];
static TNimNode TMP930[3];
NTI423292.size = sizeof(TY423292);
NTI423292.kind = 18;
NTI423292.base = 0;
NTI423292.flags = 2;
TMP932[0] = &TMP930[1];
TMP930[1].kind = 1;
TMP930[1].offset = offsetof(TY423292, Field0);
TMP930[1].typ = (&NTI226818);
TMP930[1].name = "Field0";
TMP932[1] = &TMP930[2];
TMP930[2].kind = 1;
TMP930[2].offset = offsetof(TY423292, Field1);
TMP930[2].typ = (&NTI226814);
TMP930[2].name = "Field1";
TMP930[0].len = 2; TMP930[0].kind = 2; TMP930[0].sons = &TMP932[0];
NTI423292.node = &TMP930[0];
NTI423291.size = sizeof(TY423291*);
NTI423291.kind = 24;
NTI423291.base = (&NTI423292);
NTI423291.flags = 2;
NTI423291.marker = TMP933;
}

