/* 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 TY422291 TY422291;
typedef struct TY422292 TY422292;
typedef struct tsymseq225818 tsymseq225818;
typedef struct tsym225846 tsym225846;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell45135 tcell45135;
typedef struct tcellseq45151 tcellseq45151;
typedef struct tgcheap47216 tgcheap47216;
typedef struct tcellset45147 tcellset45147;
typedef struct tpagedesc45143 tpagedesc45143;
typedef struct tmemregion27410 tmemregion27410;
typedef struct tsmallchunk26640 tsmallchunk26640;
typedef struct tllchunk27404 tllchunk27404;
typedef struct tbigchunk26642 tbigchunk26642;
typedef struct tintset26617 tintset26617;
typedef struct ttrunk26613 ttrunk26613;
typedef struct tavlnode27408 tavlnode27408;
typedef struct tgcstat47214 tgcstat47214;
typedef struct tidobj200015 tidobj200015;
typedef struct TNimObject TNimObject;
typedef struct ttypeseq225848 ttypeseq225848;
typedef struct ttype225852 ttype225852;
typedef struct tscope225840 tscope225840;
typedef struct TY225947 TY225947;
typedef struct tinstantiation225836 tinstantiation225836;
typedef struct tstrtable225820 tstrtable225820;
typedef struct tident200021 tident200021;
typedef struct tlineinfo195539 tlineinfo195539;
typedef struct tnode225816 tnode225816;
typedef struct tloc225830 tloc225830;
typedef struct trope177009 trope177009;
typedef struct tlib225834 tlib225834;
typedef struct NimStringDesc NimStringDesc;
typedef struct tnodeseq225810 tnodeseq225810;
typedef struct intset222056 intset222056;
typedef struct ttrunk222052 ttrunk222052;
typedef struct ttrunkseq222054 ttrunkseq222054;
typedef struct tbasechunk26638 tbasechunk26638;
typedef struct tfreecell26630 tfreecell26630;
typedef struct TY225936 TY225936;
typedef struct tlistentry127022 tlistentry127022;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct TY422292 {
tsymseq225818* Field0;
tsym225846* 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  tcell45135  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq45151  {
NI Len;
NI Cap;
tcell45135** D;
};
struct  tcellset45147  {
NI Counter;
NI Max;
tpagedesc45143* Head;
tpagedesc45143** Data;
};
typedef tsmallchunk26640* TY27422[512];
typedef ttrunk26613* ttrunkbuckets26615[256];
struct  tintset26617  {
ttrunkbuckets26615 Data;
};
struct  tmemregion27410  {
NI Minlargeobj;
NI Maxlargeobj;
TY27422 Freesmallchunks;
tllchunk27404* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk26642* Freechunkslist;
tintset26617 Chunkstarts;
tavlnode27408* Root;
tavlnode27408* Deleted;
tavlnode27408* Last;
tavlnode27408* Freeavlnodes;
};
struct  tgcstat47214  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap47216  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq45151 Zct;
tcellseq45151 Decstack;
tcellset45147 Cycleroots;
tcellseq45151 Tempstack;
NI Recgclock;
tmemregion27410 Region;
tgcstat47214 Stat;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tidobj200015  {
  TNimObject Sup;
NI Id;
};
struct  tstrtable225820  {
NI Counter;
tsymseq225818* Data;
};
struct  tlineinfo195539  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  tloc225830  {
NU8 K;
NU8 S;
NU8 Flags;
ttype225852* T;
trope177009* R;
trope177009* Heaproot;
};
struct  tsym225846  {
  tidobj200015 Sup;
NU8 Kind;
union {
struct {ttypeseq225848* Typeinstcache;
tscope225840* Typscope;
} S1;
struct {TY225947* Procinstcache;
tscope225840* Scope;
} S2;
struct {TY225947* Usedgenerics;
tstrtable225820 Tab;
} S3;
struct {tsym225846* Guard;
} S4;
} kindU;
NU16 Magic;
ttype225852* Typ;
tident200021* Name;
tlineinfo195539 Info;
tsym225846* Owner;
NU32 Flags;
tnode225816* Ast;
NU32 Options;
NI Position;
NI Offset;
tloc225830 Loc;
tlib225834* Annex;
tnode225816* Constraint;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  tident200021  {
  tidobj200015 Sup;
NimStringDesc* S;
tident200021* Next;
NI H;
};
struct  ttype225852  {
  tidobj200015 Sup;
NU8 Kind;
NU8 Callconv;
NU32 Flags;
ttypeseq225848* Sons;
tnode225816* N;
tsym225846* Owner;
tsym225846* Sym;
tsym225846* Destructor;
tsym225846* Deepcopy;
NI64 Size;
NI16 Align;
NI16 Locklevel;
tloc225830 Loc;
};
struct  tnode225816  {
ttype225852* Typ;
tlineinfo195539 Info;
NU16 Flags;
NU8 Kind;
union {
struct {NI64 Intval;
} S1;
struct {NF Floatval;
} S2;
struct {NimStringDesc* Strval;
} S3;
struct {tsym225846* Sym;
} S4;
struct {tident200021* Ident;
} S5;
struct {tnodeseq225810* Sons;
} S6;
} kindU;
NimStringDesc* Comment;
};
typedef NimStringDesc* TY169969[2];
typedef tsym225846* TY290499[1];
struct  intset222056  {
NI Counter;
NI Max;
ttrunk222052* Head;
ttrunkseq222054* Data;
};
typedef NI TY26620[16];
struct  tpagedesc45143  {
tpagedesc45143* Next;
NI Key;
TY26620 Bits;
};
struct  tbasechunk26638  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk26640  {
  tbasechunk26638 Sup;
tsmallchunk26640* Next;
tsmallchunk26640* Prev;
tfreecell26630* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk27404  {
NI Size;
NI Acc;
tllchunk27404* Next;
};
struct  tbigchunk26642  {
  tbasechunk26638 Sup;
tbigchunk26642* Next;
tbigchunk26642* Prev;
NI Align;
NF Data;
};
struct  ttrunk26613  {
ttrunk26613* Next;
NI Key;
TY26620 Bits;
};
typedef tavlnode27408* TY27414[2];
struct  tavlnode27408  {
TY27414 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tscope225840  {
NI Depthlevel;
tstrtable225820 Symbols;
tnodeseq225810* Usingsyms;
tscope225840* Parent;
};
struct  tinstantiation225836  {
tsym225846* Sym;
ttypeseq225848* Concretetypes;
TY225936* Usedby;
};
struct  trope177009  {
  TNimObject Sup;
trope177009* Left;
trope177009* Right;
NI Length;
NimStringDesc* Data;
};
struct  tlistentry127022  {
  TNimObject Sup;
tlistentry127022* Prev;
tlistentry127022* Next;
};
struct  tlib225834  {
  tlistentry127022 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope177009* Name;
tnode225816* Path;
};
struct  ttrunk222052  {
ttrunk222052* Next;
NI Key;
TY26620 Bits;
};
struct  tfreecell26630  {
tfreecell26630* Next;
NI Zerofield;
};
struct tsymseq225818 {
  TGenericSeq Sup;
  tsym225846* data[SEQ_DECL_SIZE];
};
struct TY422291 {
  TGenericSeq Sup;
  TY422292 data[SEQ_DECL_SIZE];
};
struct ttypeseq225848 {
  TGenericSeq Sup;
  ttype225852* data[SEQ_DECL_SIZE];
};
struct TY225947 {
  TGenericSeq Sup;
  tinstantiation225836* data[SEQ_DECL_SIZE];
};
struct tnodeseq225810 {
  TGenericSeq Sup;
  tnode225816* data[SEQ_DECL_SIZE];
};
struct ttrunkseq222054 {
  TGenericSeq Sup;
  ttrunk222052* data[SEQ_DECL_SIZE];
};
struct TY225936 {
  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(tcell45135*, usrtocell_48846)(void* usr);
static N_INLINE(void, rtladdzct_50404)(tcell45135* c);
N_NOINLINE(void, addzct_48817)(tcellseq45151* s, tcell45135* c);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(NIM_BOOL, samemethodbucket_422320)(tsym225846* a, tsym225846* b);
static N_INLINE(NI, sonslen_226255)(ttype225852* n);
N_NIMCALL(NIM_BOOL, sametypeornil_268367)(ttype225852* a, ttype225852* b, NU8 flags);
N_NIMCALL(ttype225852*, skiptypes_230245)(ttype225852* t, NU64 kinds);
static N_INLINE(ttype225852*, lastson_226267)(ttype225852* n);
N_NIMCALL(NIM_BOOL, sametype_268351)(ttype225852* a, ttype225852* b, NU8 flags);
N_NIMCALL(NI, inheritancediff_270588)(ttype225852* a, ttype225852* b);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(void, attachdispatcher_422412)(tsym225846* s, tnode225816* dispatcher);
static N_INLINE(NI, len_226364)(tnode225816* n);
N_NIMCALL(void, add_226498)(tnode225816* father, tnode225816* son);
static N_INLINE(tnode225816*, lastson_226261)(tnode225816* n);
static N_INLINE(NI, sonslen_226249)(tnode225816* n);
N_NIMCALL(void, fixupdispatcher_422628)(tsym225846* meth, tsym225846* disp);
N_NIMCALL(tnode225816*, copytree_226329)(tnode225816* src);
N_NIMCALL(void, message_197976)(tlineinfo195539 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(NimStringDesc*, nsuFormatOpenArray)(NimStringDesc* formatstr, NimStringDesc** a, NI aLen0);
N_NIMCALL(NimStringDesc*, HEX24_228488)(NI16 x);
N_NIMCALL(void, checkmethodeffects_383471)(tsym225846* disp, tsym225846* branch);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(tsym225846*, createdispatcher_422488)(tsym225846* s);
N_NIMCALL(tsym225846*, copysym_226203)(tsym225846* s, NIM_BOOL keepid);
N_NIMCALL(ttype225852*, copytype_226195)(ttype225852* t, tsym225846* owner, NIM_BOOL keepid);
N_NIMCALL(void, addson_226287)(tnode225816* father, tnode225816* son);
N_NIMCALL(tnode225816*, newsymnode_226132)(tsym225846* sym);
N_NIMCALL(void, genericSeqAssign)(void* dest, void* src_79804, TNimType* mt);
N_NIMCALL(void, internalerror_197987)(tlineinfo195539 info, NimStringDesc* errmsg);
N_NIMCALL(tnode225816*, genconv_422017)(tnode225816* n, ttype225852* d, NIM_BOOL downcast);
N_NIMCALL(tnode225816*, newnodeit_226145)(NU8 kind, tlineinfo195539 info, ttype225852* typ);
N_NIMCALL(tnode225816*, newnode_226090)(NU8 kind);
N_NIMCALL(void, initintset_222950)(intset222056* Result);
N_NOINLINE(void, chckNil)(void* p);
N_NIMCALL(NIM_BOOL, relevantcol_423061)(tsymseq225818* methods, NI col);
N_NIMCALL(void, incl_222869)(intset222056* s, NI key);
N_NIMCALL(void, sortbucket_423158)(tsymseq225818** a, intset222056 relevantcols);
N_NIMCALL(NI, cmpsignatures_423111)(tsym225846* a, tsym225846* b, intset222056 relevantcols);
N_NIMCALL(NIM_BOOL, contains_222837)(intset222056 s, NI key);
N_NIMCALL(tsym225846*, gendispatcher_423235)(tsymseq225818* methods, intset222056 relevantcols);
N_NIMCALL(tnode225816*, newnodei_226138)(NU8 kind, tlineinfo195539 info);
N_NIMCALL(tsym225846*, getsyssym_282054)(NimStringDesc* name);
N_NIMCALL(ttype225852*, getsystype_282030)(NU8 kind);
STRING_LITERAL(TMP3141, "method has lock level $1, but another method has $2", 51);
STRING_LITERAL(TMP3149, "no method dispatcher found", 26);
STRING_LITERAL(TMP3150, "cgmeth.genConv", 14);
STRING_LITERAL(TMP3151, "cgmeth.genConv: no upcast allowed", 33);
STRING_LITERAL(TMP3152, "cgmeth.genConv: no downcast allowed", 35);
STRING_LITERAL(TMP4077, "and", 3);
STRING_LITERAL(TMP4078, "of", 2);
TY422291* gmethods_422315;
TNimType NTI422292; /* tuple[methods: TSymSeq, dispatcher: PSym] */
extern TNimType NTI225818; /* TSymSeq */
extern TNimType NTI225814; /* PSym */
TNimType NTI422291; /* seq[tuple[methods: TSymSeq, dispatcher: PSym]] */
extern tgcheap47216 gch_47244;
extern tnode225816* emptynode_226738;
N_NIMCALL(void, TMP931)(void* p, NI op) {
	TY422291* a;
	NI LOC1;
	a = (TY422291*)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(tcell45135*, usrtocell_48846)(void* usr) {
	tcell45135* result;
	result = 0;
	result = ((tcell45135*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(tcell45135))))));
	return result;
}

static N_INLINE(void, rtladdzct_50404)(tcell45135* c) {
	addzct_48817((&gch_47244.Zct), c);
}

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

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

N_NIMCALL(NIM_BOOL, samemethodbucket_422320)(tsym225846* a, tsym225846* 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_226255((*a).Typ);
		LOC8 = 0;
		LOC8 = sonslen_226255((*b).Typ);
		if (!!((LOC7 == LOC8))) goto LA9;
		goto BeforeRet;
	}
	LA9: ;
	{
		NIM_BOOL LOC13;
		LOC13 = 0;
		LOC13 = sametypeornil_268367((*(*a).Typ).Sons->data[0], (*(*b).Typ).Sons->data[0], 0);
		if (!!(LOC13)) goto LA14;
		goto BeforeRet;
	}
	LA14: ;
	{
		NI i_422337;
		NI HEX3Atmp_422386;
		NI LOC17;
		NI res_422389;
		i_422337 = 0;
		HEX3Atmp_422386 = 0;
		LOC17 = 0;
		LOC17 = sonslen_226255((*a).Typ);
		HEX3Atmp_422386 = (NI32)(LOC17 - 1);
		res_422389 = 1;
		{
			while (1) {
				ttype225852* aa;
				ttype225852* bb;
				if (!(res_422389 <= HEX3Atmp_422386)) goto LA19;
				i_422337 = res_422389;
				aa = (*(*a).Typ).Sons->data[i_422337];
				bb = (*(*b).Typ).Sons->data[i_422337];
				{
					while (1) {
						aa = skiptypes_230245(aa, 2048);
						bb = skiptypes_230245(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_226267(aa);
							bb = lastson_226267(bb);
						}
						goto LA22;
						LA26: ;
						{
							goto LA20;
						}
						LA22: ;
					}
				} LA20: ;
				{
					NIM_BOOL LOC31;
					NIM_BOOL LOC33;
					NIM_BOOL LOC34;
					NI LOC37;
					LOC31 = 0;
					LOC31 = sametype_268351(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_270588(bb, aa);
					LOC33 = (LOC37 < 0);
					LA36: ;
					LOC31 = LOC33;
					LA32: ;
					if (!LOC31) goto LA38;
				}
				goto LA29;
				LA38: ;
				{
					goto BeforeRet;
				}
				LA29: ;
				res_422389 += 1;
			} LA19: ;
		}
	}
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

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

static N_INLINE(NI, len_226364)(tnode225816* 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_422412)(tsym225846* s, tnode225816* dispatcher) {
	NI l;
	NI LOC1;
	tnode225816* x;
	LOC1 = 0;
	LOC1 = len_226364((*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_226498((*s).Ast, dispatcher);
	}
	LA2: ;
}

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

N_NIMCALL(void, fixupdispatcher_422628)(tsym225846* meth, tsym225846* disp) {
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		NI LOC5;
		NI LOC7;
		LOC3 = 0;
		LOC4 = 0;
		LOC5 = 0;
		LOC5 = sonslen_226249((*disp).Ast);
		LOC4 = (7 < LOC5);
		if (!(LOC4)) goto LA6;
		LOC7 = 0;
		LOC7 = sonslen_226249((*meth).Ast);
		LOC4 = (7 < LOC7);
		LA6: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA8;
		LOC3 = ((*(*disp).Ast).kindU.S6.Sons->data[7] == emptynode_226738);
		LA8: ;
		if (!LOC3) goto LA9;
		asgnRefNoCycle((void**) (&(*(*disp).Ast).kindU.S6.Sons->data[7]), copytree_226329((*(*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;
		TY169969 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_228488((*(*meth).Typ).Locklevel);
		LOC20[1] = HEX24_228488((*(*disp).Typ).Locklevel);
		LOC21 = 0;
		LOC21 = nsuFormatOpenArray(((NimStringDesc*) &TMP3141), LOC20, 2);
		message_197976((*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(tsym225846*, createdispatcher_422488)(tsym225846* s) {
	tsym225846* result;
	tsym225846* disp;
	tnode225816* LOC15;
	tnode225816* LOC16;
	result = 0;
	disp = copysym_226203(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_226195((*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_226329((*s).Ast));
	asgnRefNoCycle((void**) (&(*(*disp).Ast).kindU.S6.Sons->data[6]), emptynode_226738);
	asgnRefNoCycle((void**) (&(*disp).Loc.R), NIM_NIL);
	{
		if (!!(((*(*s).Typ).Sons->data[0] == NIM_NIL))) goto LA7;
		{
			NI LOC11;
			LOC11 = 0;
			LOC11 = sonslen_226249((*disp).Ast);
			if (!(7 < LOC11)) goto LA12;
			asgnRefNoCycle((void**) (&(*(*(*disp).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym), copysym_226203((*(*(*s).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym, NIM_FALSE));
		}
		goto LA9;
		LA12: ;
		{
			addson_226287((*disp).Ast, emptynode_226738);
		}
		LA9: ;
	}
	LA7: ;
	LOC15 = 0;
	LOC15 = newsymnode_226132(disp);
	attachdispatcher_422412(s, LOC15);
	LOC16 = 0;
	LOC16 = newsymnode_226132(disp);
	attachdispatcher_422412(disp, LOC16);
	result = disp;
	goto BeforeRet;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, methoddef_422824)(tsym225846* s, NIM_BOOL fromcache) {
	NI l;
	TY422292 LOC10;
	TY290499 LOC11;
	l = gmethods_422315->Sup.len;
	{
		NI i_422852;
		NI HEX3Atmp_423041;
		NI res_423044;
		i_422852 = 0;
		HEX3Atmp_423041 = 0;
		HEX3Atmp_423041 = (NI32)(l - 1);
		res_423044 = 0;
		{
			while (1) {
				tsym225846* disp;
				if (!(res_423044 <= HEX3Atmp_423041)) goto LA3;
				i_422852 = res_423044;
				disp = gmethods_422315->data[i_422852].Field1;
				{
					NIM_BOOL LOC6;
					tnode225816* LOC9;
					LOC6 = 0;
					LOC6 = samemethodbucket_422320(disp, s);
					if (!LOC6) goto LA7;
					gmethods_422315->data[i_422852].Field0 = (tsymseq225818*) incrSeq(&(gmethods_422315->data[i_422852].Field0)->Sup, sizeof(tsym225846*));
					asgnRefNoCycle((void**) (&gmethods_422315->data[i_422852].Field0->data[gmethods_422315->data[i_422852].Field0->Sup.len-1]), s);
					LOC9 = 0;
					LOC9 = lastson_226261((*disp).Ast);
					attachdispatcher_422412(s, LOC9);
					fixupdispatcher_422628(s, disp);
					checkmethodeffects_383471(disp, s);
					goto BeforeRet;
				}
				LA7: ;
				res_423044 += 1;
			} LA3: ;
		}
	}
	memset((void*)(&LOC10), 0, sizeof(LOC10));
	LOC10.Field0 = (tsymseq225818*) newSeq((&NTI225818), 1);
	memset((void*)LOC11, 0, sizeof(LOC11));
	LOC11[0] = s;
	asgnRefNoCycle((void**) (&LOC10.Field0->data[0]), LOC11[0]);
	LOC10.Field1 = createdispatcher_422488(s);
	gmethods_422315 = (TY422291*) incrSeq(&(gmethods_422315)->Sup, sizeof(TY422292));
	genericSeqAssign((&gmethods_422315->data[gmethods_422315->Sup.len-1].Field0), LOC10.Field0, (&NTI225818));
	asgnRefNoCycle((void**) (&gmethods_422315->data[gmethods_422315->Sup.len-1].Field1), LOC10.Field1);
	{
		if (!fromcache) goto LA14;
		internalerror_197987((*s).Info, ((NimStringDesc*) &TMP3149));
	}
	LA14: ;
	BeforeRet: ;
}

N_NIMCALL(tnode225816*, genconv_422017)(tnode225816* n, ttype225852* d, NIM_BOOL downcast) {
	tnode225816* result;
	ttype225852* dest;
	ttype225852* source;
	result = 0;
	dest = skiptypes_230245(d, IL64(211106247256320));
	source = skiptypes_230245((*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_270588(dest, source);
		{
			if (!(diff == 2147483647)) goto LA9;
			internalerror_197987((*n).Info, ((NimStringDesc*) &TMP3150));
		}
		LA9: ;
		{
			if (!(diff < 0)) goto LA13;
			result = newnodeit_226145(((NU8) 67), (*n).Info, d);
			addson_226287(result, n);
			{
				if (!downcast) goto LA17;
				internalerror_197987((*n).Info, ((NimStringDesc*) &TMP3151));
			}
			LA17: ;
		}
		goto LA11;
		LA13: ;
		{
			if (!(0 < diff)) goto LA20;
			result = newnodeit_226145(((NU8) 66), (*n).Info, d);
			addson_226287(result, n);
			{
				if (!!(downcast)) goto LA24;
				internalerror_197987((*n).Info, ((NimStringDesc*) &TMP3152));
			}
			LA24: ;
		}
		goto LA11;
		LA20: ;
		{
			result = n;
		}
		LA11: ;
	}
	goto LA1;
	LA5: ;
	{
		result = n;
	}
	LA1: ;
	return result;
}

N_NIMCALL(tnode225816*, methodcall_422056)(tnode225816* n) {
	tnode225816* result;
	tsym225846* disp;
	tnode225816* LOC1;
	result = 0;
	result = n;
	LOC1 = 0;
	LOC1 = lastson_226261((*(*(*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_422241;
		NI HEX3Atmp_422271;
		NI LOC3;
		NI res_422274;
		i_422241 = 0;
		HEX3Atmp_422271 = 0;
		LOC3 = 0;
		LOC3 = sonslen_226249(result);
		HEX3Atmp_422271 = (NI32)(LOC3 - 1);
		res_422274 = 1;
		{
			while (1) {
				if (!(res_422274 <= HEX3Atmp_422271)) goto LA5;
				i_422241 = res_422274;
				asgnRefNoCycle((void**) (&(*result).kindU.S6.Sons->data[i_422241]), genconv_422017((*result).kindU.S6.Sons->data[i_422241], (*(*disp).Typ).Sons->data[i_422241], NIM_TRUE));
				res_422274 += 1;
			} LA5: ;
		}
	}
	return result;
}

N_NIMCALL(NIM_BOOL, relevantcol_423061)(tsymseq225818* methods, NI col) {
	NIM_BOOL result;
	ttype225852* t;
	result = 0;
	t = skiptypes_230245((*(*methods->data[0]).Typ).Sons->data[col], IL64(211106247215360));
	{
		if (!((*t).Kind == ((NU8) 17))) goto LA3;
		{
			NI i_423088;
			NI HEX3Atmp_423091;
			NI res_423094;
			i_423088 = 0;
			HEX3Atmp_423091 = 0;
			HEX3Atmp_423091 = (methods->Sup.len-1);
			res_423094 = 1;
			{
				while (1) {
					ttype225852* t2;
					if (!(res_423094 <= HEX3Atmp_423091)) goto LA7;
					i_423088 = res_423094;
					t2 = skiptypes_230245((*(*methods->data[i_423088]).Typ).Sons->data[col], IL64(211106247215360));
					{
						NIM_BOOL LOC10;
						LOC10 = 0;
						LOC10 = sametype_268351(t2, t, 0);
						if (!!(LOC10)) goto LA11;
						result = NIM_TRUE;
						goto BeforeRet;
					}
					LA11: ;
					res_423094 += 1;
				} LA7: ;
			}
		}
	}
	LA3: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NI, cmpsignatures_423111)(tsym225846* a, tsym225846* b, intset222056 relevantcols) {
	NI result;
	result = 0;
	{
		NI col_423129;
		NI HEX3Atmp_423138;
		NI LOC2;
		NI res_423141;
		col_423129 = 0;
		HEX3Atmp_423138 = 0;
		LOC2 = 0;
		LOC2 = sonslen_226255((*a).Typ);
		HEX3Atmp_423138 = (NI32)(LOC2 - 1);
		res_423141 = 1;
		{
			while (1) {
				if (!(res_423141 <= HEX3Atmp_423138)) goto LA4;
				col_423129 = res_423141;
				{
					NIM_BOOL LOC7;
					ttype225852* aa;
					ttype225852* bb;
					NI d;
					LOC7 = 0;
					LOC7 = contains_222837(relevantcols, col_423129);
					if (!LOC7) goto LA8;
					aa = skiptypes_230245((*(*a).Typ).Sons->data[col_423129], IL64(211106247215360));
					bb = skiptypes_230245((*(*b).Typ).Sons->data[col_423129], IL64(211106247215360));
					d = inheritancediff_270588(aa, bb);
					{
						if (!!((d == 2147483647))) goto LA12;
						result = d;
						goto BeforeRet;
					}
					LA12: ;
				}
				LA8: ;
				res_423141 += 1;
			} LA4: ;
		}
	}
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, sortbucket_423158)(tsymseq225818** a, intset222056 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_423189;
				NI HEX3Atmp_423197;
				NI res_423200;
				i_423189 = 0;
				HEX3Atmp_423197 = 0;
				HEX3Atmp_423197 = (NI32)(n - 1);
				res_423200 = h;
				{
					while (1) {
						tsym225846* v;
						NI j;
						if (!(res_423200 <= HEX3Atmp_423197)) goto LA11;
						i_423189 = res_423200;
						v = (*a)->data[i_423189];
						j = i_423189;
						{
							while (1) {
								NI LOC14;
								LOC14 = 0;
								LOC14 = cmpsignatures_423111((*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_423200 += 1;
					} LA11: ;
				}
			}
			{
				if (!(h == 1)) goto LA21;
				goto LA7;
			}
			LA21: ;
		}
	} LA7: ;
}

N_NIMCALL(tsym225846*, gendispatcher_423235)(tsymseq225818* methods, intset222056 relevantcols) {
	tsym225846* result;
	tsym225846* base;
	tnode225816* LOC1;
	NI paramlen;
	tnode225816* disp;
	tsym225846* ands;
	tsym225846* iss;
	result = 0;
	LOC1 = 0;
	LOC1 = lastson_226261((*methods->data[0]).Ast);
	base = (*LOC1).kindU.S4.Sym;
	result = base;
	paramlen = sonslen_226255((*base).Typ);
	disp = newnodei_226138(((NU8) 92), (*base).Info);
	ands = getsyssym_282054(((NimStringDesc*) &TMP4077));
	iss = getsyssym_282054(((NimStringDesc*) &TMP4078));
	{
		NI meth_423271;
		NI HEX3Atmp_423470;
		NI res_423473;
		meth_423271 = 0;
		HEX3Atmp_423470 = 0;
		HEX3Atmp_423470 = (methods->Sup.len-1);
		res_423473 = 0;
		{
			while (1) {
				tsym225846* curr;
				tnode225816* cond;
				tnode225816* call;
				tnode225816* LOC24;
				tnode225816* ret;
				if (!(res_423473 <= HEX3Atmp_423470)) goto LA4;
				meth_423271 = res_423473;
				curr = methods->data[meth_423271];
				cond = NIM_NIL;
				{
					NI col_423286;
					NI HEX3Atmp_423458;
					NI res_423461;
					col_423286 = 0;
					HEX3Atmp_423458 = 0;
					HEX3Atmp_423458 = (NI32)(paramlen - 1);
					res_423461 = 1;
					{
						while (1) {
							if (!(res_423461 <= HEX3Atmp_423458)) goto LA7;
							col_423286 = res_423461;
							{
								NIM_BOOL LOC10;
								tnode225816* isn;
								ttype225852* LOC13;
								tnode225816* LOC14;
								tnode225816* LOC15;
								tnode225816* LOC16;
								LOC10 = 0;
								LOC10 = contains_222837(relevantcols, col_423286);
								if (!LOC10) goto LA11;
								LOC13 = 0;
								LOC13 = getsystype_282030(((NU8) 1));
								isn = newnodeit_226145(((NU8) 27), (*base).Info, LOC13);
								LOC14 = 0;
								LOC14 = newsymnode_226132(iss);
								addson_226287(isn, LOC14);
								LOC15 = 0;
								LOC15 = newsymnode_226132((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_423286]).kindU.S4.Sym);
								addson_226287(isn, LOC15);
								LOC16 = 0;
								LOC16 = newnodeit_226145(((NU8) 4), (*base).Info, (*(*curr).Typ).Sons->data[col_423286]);
								addson_226287(isn, LOC16);
								{
									tnode225816* a;
									ttype225852* LOC21;
									tnode225816* LOC22;
									if (!!((cond == NIM_NIL))) goto LA19;
									LOC21 = 0;
									LOC21 = getsystype_282030(((NU8) 1));
									a = newnodeit_226145(((NU8) 27), (*base).Info, LOC21);
									LOC22 = 0;
									LOC22 = newsymnode_226132(ands);
									addson_226287(a, LOC22);
									addson_226287(a, cond);
									addson_226287(a, isn);
									cond = a;
								}
								goto LA17;
								LA19: ;
								{
									cond = isn;
								}
								LA17: ;
							}
							LA11: ;
							res_423461 += 1;
						} LA7: ;
					}
				}
				call = newnodei_226138(((NU8) 27), (*base).Info);
				LOC24 = 0;
				LOC24 = newsymnode_226132(curr);
				addson_226287(call, LOC24);
				{
					NI col_423347;
					NI HEX3Atmp_423464;
					NI res_423467;
					col_423347 = 0;
					HEX3Atmp_423464 = 0;
					HEX3Atmp_423464 = (NI32)(paramlen - 1);
					res_423467 = 1;
					{
						while (1) {
							tnode225816* LOC28;
							tnode225816* LOC29;
							if (!(res_423467 <= HEX3Atmp_423464)) goto LA27;
							col_423347 = res_423467;
							LOC28 = 0;
							LOC28 = newsymnode_226132((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_423347]).kindU.S4.Sym);
							LOC29 = 0;
							LOC29 = genconv_422017(LOC28, (*(*curr).Typ).Sons->data[col_423347], NIM_FALSE);
							addson_226287(call, LOC29);
							res_423467 += 1;
						} LA27: ;
					}
				}
				ret = 0;
				{
					tnode225816* a;
					tnode225816* LOC34;
					if (!!(((*(*base).Typ).Sons->data[0] == NIM_NIL))) goto LA32;
					a = newnodei_226138(((NU8) 73), (*base).Info);
					LOC34 = 0;
					LOC34 = newsymnode_226132((*(*(*base).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym);
					addson_226287(a, LOC34);
					addson_226287(a, call);
					ret = newnodei_226138(((NU8) 109), (*base).Info);
					addson_226287(ret, a);
				}
				goto LA30;
				LA32: ;
				{
					ret = call;
				}
				LA30: ;
				{
					tnode225816* a;
					if (!!((cond == NIM_NIL))) goto LA38;
					a = newnodei_226138(((NU8) 86), (*base).Info);
					addson_226287(a, cond);
					addson_226287(a, ret);
					addson_226287(disp, a);
				}
				goto LA36;
				LA38: ;
				{
					disp = ret;
				}
				LA36: ;
				res_423473 += 1;
			} LA4: ;
		}
	}
	asgnRefNoCycle((void**) (&(*(*result).Ast).kindU.S6.Sons->data[6]), disp);
	return result;
}

N_NIMCALL(tnode225816*, generatemethoddispatchers_423508)(void) {
	tnode225816* result;
	result = 0;
	result = newnode_226090(((NU8) 115));
	{
		NI bucket_423534;
		NI HEX3Atmp_423558;
		NI res_423561;
		bucket_423534 = 0;
		HEX3Atmp_423558 = 0;
		HEX3Atmp_423558 = (NI32)(gmethods_422315->Sup.len - 1);
		res_423561 = 0;
		{
			while (1) {
				intset222056 relevantcols;
				tsym225846* LOC13;
				tnode225816* LOC14;
				if (!(res_423561 <= HEX3Atmp_423558)) goto LA3;
				bucket_423534 = res_423561;
				memset((void*)(&relevantcols), 0, sizeof(relevantcols));
				chckNil((void*)(&relevantcols));
				memset((void*)(&relevantcols), 0, sizeof(relevantcols));
				initintset_222950((&relevantcols));
				{
					NI col_423548;
					NI HEX3Atmp_423553;
					NI LOC5;
					NI res_423556;
					col_423548 = 0;
					HEX3Atmp_423553 = 0;
					LOC5 = 0;
					LOC5 = sonslen_226255((*gmethods_422315->data[bucket_423534].Field0->data[0]).Typ);
					HEX3Atmp_423553 = (NI32)(LOC5 - 1);
					res_423556 = 1;
					{
						while (1) {
							if (!(res_423556 <= HEX3Atmp_423553)) goto LA7;
							col_423548 = res_423556;
							{
								NIM_BOOL LOC10;
								LOC10 = 0;
								LOC10 = relevantcol_423061(gmethods_422315->data[bucket_423534].Field0, col_423548);
								if (!LOC10) goto LA11;
								incl_222869((&relevantcols), col_423548);
							}
							LA11: ;
							res_423556 += 1;
						} LA7: ;
					}
				}
				sortbucket_423158((&gmethods_422315->data[bucket_423534].Field0), relevantcols);
				LOC13 = 0;
				LOC13 = gendispatcher_423235(gmethods_422315->data[bucket_423534].Field0, relevantcols);
				LOC14 = 0;
				LOC14 = newsymnode_226132(LOC13);
				addson_226287(result, LOC14);
				res_423561 += 1;
			} LA3: ;
		}
	}
	return result;
}
NIM_EXTERNC N_NOINLINE(void, HEX00_cgmethInit)(void) {
	if (gmethods_422315) nimGCunrefNoCycle(gmethods_422315);
	gmethods_422315 = (TY422291*) newSeqRC1((&NTI422291), 0);
}

NIM_EXTERNC N_NOINLINE(void, HEX00_cgmethDatInit)(void) {
static TNimNode* TMP930[2];
static TNimNode TMP928[3];
NTI422292.size = sizeof(TY422292);
NTI422292.kind = 18;
NTI422292.base = 0;
NTI422292.flags = 2;
TMP930[0] = &TMP928[1];
TMP928[1].kind = 1;
TMP928[1].offset = offsetof(TY422292, Field0);
TMP928[1].typ = (&NTI225818);
TMP928[1].name = "Field0";
TMP930[1] = &TMP928[2];
TMP928[2].kind = 1;
TMP928[2].offset = offsetof(TY422292, Field1);
TMP928[2].typ = (&NTI225814);
TMP928[2].name = "Field1";
TMP928[0].len = 2; TMP928[0].kind = 2; TMP928[0].sons = &TMP930[0];
NTI422292.node = &TMP928[0];
NTI422291.size = sizeof(TY422291*);
NTI422291.kind = 24;
NTI422291.base = (&NTI422292);
NTI422291.flags = 2;
NTI422291.marker = TMP931;
}

