/* Generated by Nimrod Compiler v0.9.5 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, i386, gcc */
/* Command for C compiler:
   gcc -c  -w -O3 -fno-strict-aliasing  -I/build/nimrod/src/nimrod/lib -o compiler/nimcache/cgmeth.o compiler/nimcache/cgmeth.c */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <string.h>
typedef struct TY364278 TY364278;
typedef struct tsymseq188805 tsymseq188805;
typedef struct tsym188833 tsym188833;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell41090 tcell41090;
typedef struct tcellseq41106 tcellseq41106;
typedef struct tgcheap43016 tgcheap43016;
typedef struct tcellset41102 tcellset41102;
typedef struct tpagedesc41098 tpagedesc41098;
typedef struct tmemregion23410 tmemregion23410;
typedef struct tsmallchunk22638 tsmallchunk22638;
typedef struct tllchunk23404 tllchunk23404;
typedef struct tbigchunk22640 tbigchunk22640;
typedef struct tintset22615 tintset22615;
typedef struct ttrunk22611 ttrunk22611;
typedef struct tavlnode23408 tavlnode23408;
typedef struct tgcstat43014 tgcstat43014;
typedef struct tnode188803 tnode188803;
typedef struct ttype188837 ttype188837;
typedef struct tlineinfo163527 tlineinfo163527;
typedef struct NimStringDesc NimStringDesc;
typedef struct tident167019 tident167019;
typedef struct tnodeseq188797 tnodeseq188797;
typedef struct tidobj167013 tidobj167013;
typedef struct TNimObject TNimObject;
typedef struct ttypeseq188835 ttypeseq188835;
typedef struct tscope188827 tscope188827;
typedef struct TY188933 TY188933;
typedef struct tinstantiation188823 tinstantiation188823;
typedef struct tstrtable188807 tstrtable188807;
typedef struct tloc188817 tloc188817;
typedef struct trope145007 trope145007;
typedef struct tlib188821 tlib188821;
typedef struct tintset185047 tintset185047;
typedef struct ttrunk185043 ttrunk185043;
typedef struct ttrunkseq185045 ttrunkseq185045;
typedef struct tbasechunk22636 tbasechunk22636;
typedef struct tfreecell22628 tfreecell22628;
typedef struct TY188922 TY188922;
typedef struct tlistentry118017 tlistentry118017;
struct  TGenericSeq  {
NI len;
NI reserved;
};
typedef N_NIMCALL_PTR(void, TY2289) (void* p, NI op);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY2289 marker;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  tcell41090  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq41106  {
NI Len;
NI Cap;
tcell41090** D;
};
struct  tcellset41102  {
NI Counter;
NI Max;
tpagedesc41098* Head;
tpagedesc41098** Data;
};
typedef tsmallchunk22638* TY23422[512];
typedef ttrunk22611* ttrunkbuckets22613[256];
struct  tintset22615  {
ttrunkbuckets22613 Data;
};
struct  tmemregion23410  {
NI Minlargeobj;
NI Maxlargeobj;
TY23422 Freesmallchunks;
tllchunk23404* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk22640* Freechunkslist;
tintset22615 Chunkstarts;
tavlnode23408* Root;
tavlnode23408* Deleted;
tavlnode23408* Last;
tavlnode23408* Freeavlnodes;
};
struct  tgcstat43014  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap43016  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq41106 Zct;
tcellseq41106 Decstack;
tcellset41102 Cycleroots;
tcellseq41106 Tempstack;
NI Recgclock;
tmemregion23410 Region;
tgcstat43014 Stat;
};
struct  tlineinfo163527  {
NI16 Line;
NI16 Col;
NI32 Fileindex;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  tnode188803  {
ttype188837* Typ;
tlineinfo163527 Info;
NU16 Flags;
NU8 Kind;
union {
struct {NI64 Intval;
} S1;
struct {NF Floatval;
} S2;
struct {NimStringDesc* Strval;
} S3;
struct {tsym188833* Sym;
} S4;
struct {tident167019* Ident;
} S5;
struct {tnodeseq188797* Sons;
} S6;
} kindU;
NimStringDesc* Comment;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  tidobj167013  {
  TNimObject Sup;
NI Id;
};
struct  tstrtable188807  {
NI Counter;
tsymseq188805* Data;
};
struct  tloc188817  {
NU8 K;
NU8 S;
NU8 Flags;
ttype188837* T;
trope145007* R;
trope145007* Heaproot;
NI A;
};
struct  tsym188833  {
  tidobj167013 Sup;
NU8 Kind;
union {
struct {ttypeseq188835* Typeinstcache;
tscope188827* Typscope;
} S1;
struct {TY188933* Procinstcache;
tscope188827* Scope;
} S2;
struct {TY188933* Usedgenerics;
tstrtable188807 Tab;
} S3;
} kindU;
NU16 Magic;
ttype188837* Typ;
tident167019* Name;
tlineinfo163527 Info;
tsym188833* Owner;
NU32 Flags;
tnode188803* Ast;
NU32 Options;
NI Position;
NI Offset;
tloc188817 Loc;
tlib188821* Annex;
tnode188803* Constraint;
};
struct  ttype188837  {
  tidobj167013 Sup;
NU8 Kind;
NU8 Callconv;
NU32 Flags;
ttypeseq188835* Sons;
tnode188803* N;
tsym188833* Destructor;
tsym188833* Owner;
tsym188833* Sym;
NI64 Size;
NI Align;
tloc188817 Loc;
};
struct  tident167019  {
  tidobj167013 Sup;
NimStringDesc* S;
tident167019* Next;
NI H;
};
typedef tsym188833* TY364619[1];
struct  tintset185047  {
NI Counter;
NI Max;
ttrunk185043* Head;
ttrunkseq185045* Data;
};
typedef NI TY22618[16];
struct  tpagedesc41098  {
tpagedesc41098* Next;
NI Key;
TY22618 Bits;
};
struct  tbasechunk22636  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk22638  {
  tbasechunk22636 Sup;
tsmallchunk22638* Next;
tsmallchunk22638* Prev;
tfreecell22628* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk23404  {
NI Size;
NI Acc;
tllchunk23404* Next;
};
struct  tbigchunk22640  {
  tbasechunk22636 Sup;
tbigchunk22640* Next;
tbigchunk22640* Prev;
NI Align;
NF Data;
};
struct  ttrunk22611  {
ttrunk22611* Next;
NI Key;
TY22618 Bits;
};
typedef tavlnode23408* TY23414[2];
struct  tavlnode23408  {
TY23414 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tscope188827  {
NI Depthlevel;
tstrtable188807 Symbols;
tnodeseq188797* Usingsyms;
tscope188827* Parent;
};
struct  tinstantiation188823  {
tsym188833* Sym;
ttypeseq188835* Concretetypes;
TY188922* Usedby;
};
struct  trope145007  {
  TNimObject Sup;
trope145007* Left;
trope145007* Right;
NI Length;
NimStringDesc* Data;
};
struct  tlistentry118017  {
  TNimObject Sup;
tlistentry118017* Prev;
tlistentry118017* Next;
};
struct  tlib188821  {
  tlistentry118017 Sup;
NU8 Kind;
NIM_BOOL Generated;
NIM_BOOL Isoverriden;
trope145007* Name;
tnode188803* Path;
};
struct  ttrunk185043  {
ttrunk185043* Next;
NI Key;
TY22618 Bits;
};
struct  tfreecell22628  {
tfreecell22628* Next;
NI Zerofield;
};
struct tsymseq188805 {
  TGenericSeq Sup;
  tsym188833* data[SEQ_DECL_SIZE];
};
struct TY364278 {
  TGenericSeq Sup;
  tsymseq188805* data[SEQ_DECL_SIZE];
};
struct tnodeseq188797 {
  TGenericSeq Sup;
  tnode188803* data[SEQ_DECL_SIZE];
};
struct ttypeseq188835 {
  TGenericSeq Sup;
  ttype188837* data[SEQ_DECL_SIZE];
};
struct TY188933 {
  TGenericSeq Sup;
  tinstantiation188823* data[SEQ_DECL_SIZE];
};
struct ttrunkseq185045 {
  TGenericSeq Sup;
  ttrunk185043* data[SEQ_DECL_SIZE];
};
struct TY188922 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP915)(void* p, NI op);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(tcell41090*, usrtocell_44443)(void* usr);
static N_INLINE(void, rtladdzct_46002)(tcell41090* c);
N_NOINLINE(void, addzct_44418)(tcellseq41106* s, tcell41090* c);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
static N_INLINE(tnode188803*, lastson_189189)(tnode188803* n);
static N_INLINE(NI, sonslen_189181)(tnode188803* n);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(tnode188803*, genconv_364012)(tnode188803* n, ttype188837* d, NIM_BOOL downcast);
N_NIMCALL(ttype188837*, skiptypes_192793)(ttype188837* t, NU64 kinds);
N_NIMCALL(NI, inheritancediff_230560)(ttype188837* a, ttype188837* b);
N_NIMCALL(void, internalerror_165591)(tlineinfo163527 info, NimStringDesc* errmsg);
N_NIMCALL(tnode188803*, newnodeit_189104)(NU8 kind, tlineinfo163527 info, ttype188837* typ);
N_NIMCALL(void, addson_189207)(tnode188803* father, tnode188803* son);
N_NIMCALL(NIM_BOOL, samemethodbucket_364302)(tsym188833* a, tsym188833* b);
static N_INLINE(NI, sonslen_189185)(ttype188837* n);
N_NIMCALL(NIM_BOOL, sametypeornil_228128)(ttype188837* a, ttype188837* b, NU8 flags);
static N_INLINE(ttype188837*, lastson_189193)(ttype188837* n);
N_NIMCALL(NIM_BOOL, sametype_228116)(ttype188837* a, ttype188837* b, NU8 flags);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
N_NIMCALL(void, attachdispatcher_364374)(tsym188833* s, tnode188803* dispatcher);
static N_INLINE(NI, len_189264)(tnode188803* n);
N_NIMCALL(void, add_189390)(tnode188803* father, tnode188803* son);
N_NIMCALL(void, checkmethodeffects_324602)(tsym188833* disp, tsym188833* branch);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(void, genericSeqAssign)(void* dest, void* src_74604, TNimType* mt);
N_NIMCALL(tsym188833*, copysym_189147)(tsym188833* s, NIM_BOOL keepid);
N_NIMCALL(ttype188837*, copytype_189141)(ttype188837* t, tsym188833* owner, NIM_BOOL keepid);
N_NIMCALL(tnode188803*, copytree_189237)(tnode188803* src);
N_NIMCALL(tnode188803*, newsymnode_189095)(tsym188833* sym);
N_NIMCALL(tnode188803*, newnode_189065)(NU8 kind);
N_NIMCALL(void, initintset_185918)(tintset185047* Result);
N_NOINLINE(void, chckNil)(void* p);
N_NIMCALL(NIM_BOOL, relevantcol_364773)(tsymseq188805* methods, NI col);
N_NIMCALL(void, incl_185849)(tintset185047* s, NI key);
N_NIMCALL(void, sortbucket_364842)(tsymseq188805** a, tintset185047 relevantcols);
N_NIMCALL(NI, cmpsignatures_364809)(tsym188833* a, tsym188833* b, tintset185047 relevantcols);
N_NIMCALL(NIM_BOOL, contains_185821)(tintset185047 s, NI key);
N_NIMCALL(tsym188833*, gendispatcher_364887)(tsymseq188805* methods, tintset185047 relevantcols);
N_NIMCALL(tnode188803*, newnodei_189099)(NU8 kind, tlineinfo163527 info);
N_NIMCALL(tsym188833*, getsyssym_242040)(NimStringDesc* name);
N_NIMCALL(ttype188837*, getsystype_242024)(NU8 kind);
STRING_LITERAL(TMP2950, "cgmeth.genConv", 14);
STRING_LITERAL(TMP2951, "cgmeth.genConv: no upcast allowed", 33);
STRING_LITERAL(TMP2952, "cgmeth.genConv: no downcast allowed", 35);
STRING_LITERAL(TMP3785, "and", 3);
STRING_LITERAL(TMP3786, "of", 2);
TY364278* gmethods_364299;
extern TNimType NTI188805; /* TSymSeq */
TNimType NTI364278; /* seq[TSymSeq] */
extern tgcheap43016 gch_43044;
extern tnode188803* emptynode_189727;
N_NIMCALL(void, TMP915)(void* p, NI op) {
	TY364278* a;
	NI LOC1;
	a = (TY364278*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1], op);
	}
}

static N_INLINE(tcell41090*, usrtocell_44443)(void* usr) {
	tcell41090* result;
	result = 0;
	result = ((tcell41090*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(tcell41090))))));
	return result;
}

static N_INLINE(void, rtladdzct_46002)(tcell41090* c) {
	addzct_44418(&gch_43044.Zct, c);
}

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

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

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

N_NIMCALL(tnode188803*, genconv_364012)(tnode188803* n, ttype188837* d, NIM_BOOL downcast) {
	tnode188803* result;
	ttype188837* dest;
	ttype188837* source;
	result = 0;
	dest = skiptypes_192793(d, IL64(211106247256320));
	source = skiptypes_192793((*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_230560(dest, source);
		{
			if (!(diff == 2147483647)) goto LA9;
			internalerror_165591((*n).Info, ((NimStringDesc*) &TMP2950));
		}
		LA9: ;
		{
			if (!(diff < 0)) goto LA13;
			result = newnodeit_189104(((NU8) 67), (*n).Info, d);
			addson_189207(result, n);
			{
				if (!downcast) goto LA17;
				internalerror_165591((*n).Info, ((NimStringDesc*) &TMP2951));
			}
			LA17: ;
		}
		goto LA11;
		LA13: ;
		{
			if (!(0 < diff)) goto LA20;
			result = newnodeit_189104(((NU8) 66), (*n).Info, d);
			addson_189207(result, n);
			{
				if (!!(downcast)) goto LA24;
				internalerror_165591((*n).Info, ((NimStringDesc*) &TMP2952));
			}
			LA24: ;
		}
		goto LA11;
		LA20: ;
		{
			result = n;
		}
		LA11: ;
	}
	goto LA1;
	LA5: ;
	{
		result = n;
	}
	LA1: ;
	return result;
}

N_NIMCALL(tnode188803*, methodcall_364047)(tnode188803* n) {
	tnode188803* result;
	tsym188833* disp;
	tnode188803* LOC1;
	NI i_364241;
	NI HEX3Atmp_364270;
	NI LOC2;
	NI res_364272;
	result = 0;
	result = n;
	LOC1 = 0;
	LOC1 = lastson_189189((*(*(*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);
	i_364241 = 0;
	HEX3Atmp_364270 = 0;
	LOC2 = 0;
	LOC2 = sonslen_189181(result);
	HEX3Atmp_364270 = (NI32)(LOC2 - 1);
	res_364272 = 1;
	while (1) {
		if (!(res_364272 <= HEX3Atmp_364270)) goto LA3;
		i_364241 = res_364272;
		asgnRefNoCycle((void**) &(*result).kindU.S6.Sons->data[i_364241], genconv_364012((*result).kindU.S6.Sons->data[i_364241], (*(*disp).Typ).Sons->data[i_364241], NIM_TRUE));
		res_364272 += 1;
	} LA3: ;
	return result;
}

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

N_NIMCALL(NIM_BOOL, samemethodbucket_364302)(tsym188833* a, tsym188833* b) {
	NIM_BOOL result;
	NI i_364319;
	NI HEX3Atmp_364366;
	NI LOC16;
	NI res_364368;
	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_189185((*a).Typ);
		LOC8 = 0;
		LOC8 = sonslen_189185((*b).Typ);
		if (!!((LOC7 == LOC8))) goto LA9;
		goto BeforeRet;
	}
	LA9: ;
	{
		NIM_BOOL LOC13;
		LOC13 = 0;
		LOC13 = sametypeornil_228128((*(*a).Typ).Sons->data[0], (*(*b).Typ).Sons->data[0], 0);
		if (!!(LOC13)) goto LA14;
		goto BeforeRet;
	}
	LA14: ;
	i_364319 = 0;
	HEX3Atmp_364366 = 0;
	LOC16 = 0;
	LOC16 = sonslen_189185((*a).Typ);
	HEX3Atmp_364366 = (NI32)(LOC16 - 1);
	res_364368 = 1;
	while (1) {
		ttype188837* aa;
		ttype188837* bb;
		if (!(res_364368 <= HEX3Atmp_364366)) goto LA17;
		i_364319 = res_364368;
		aa = (*(*a).Typ).Sons->data[i_364319];
		bb = (*(*b).Typ).Sons->data[i_364319];
		while (1) {
			aa = skiptypes_192793(aa, 2048);
			bb = skiptypes_192793(bb, 2048);
			{
				NIM_BOOL LOC21;
				LOC21 = 0;
				LOC21 = ((*aa).Kind == (*bb).Kind);
				if (!(LOC21)) goto LA22;
				LOC21 = ((*aa).Kind == ((NU8) 23) || (*aa).Kind == ((NU8) 21) || (*aa).Kind == ((NU8) 22));
				LA22: ;
				if (!LOC21) goto LA23;
				aa = lastson_189193(aa);
				bb = lastson_189193(bb);
			}
			goto LA19;
			LA23: ;
			{
				goto LA18;
			}
			LA19: ;
		} LA18: ;
		{
			NIM_BOOL LOC28;
			NIM_BOOL LOC30;
			NIM_BOOL LOC31;
			NI LOC34;
			LOC28 = 0;
			LOC28 = sametype_228116(aa, bb, 0);
			if (LOC28) goto LA29;
			LOC30 = 0;
			LOC31 = 0;
			LOC31 = ((*aa).Kind == ((NU8) 17));
			if (!(LOC31)) goto LA32;
			LOC31 = ((*bb).Kind == ((NU8) 17));
			LA32: ;
			LOC30 = LOC31;
			if (!(LOC30)) goto LA33;
			LOC34 = 0;
			LOC34 = inheritancediff_230560(bb, aa);
			LOC30 = (LOC34 < 0);
			LA33: ;
			LOC28 = LOC30;
			LA29: ;
			if (!LOC28) goto LA35;
		}
		goto LA26;
		LA35: ;
		{
			goto BeforeRet;
		}
		LA26: ;
		res_364368 += 1;
	} LA17: ;
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

static N_INLINE(NI, len_189264)(tnode188803* 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_364374)(tsym188833* s, tnode188803* dispatcher) {
	NI l;
	NI LOC1;
	tnode188803* x;
	LOC1 = 0;
	LOC1 = len_189264((*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_189390((*s).Ast, dispatcher);
	}
	LA2: ;
}

N_NIMCALL(void, methoddef_364446)(tsym188833* s, NIM_BOOL fromcache) {
	NI l;
	NI i_364474;
	NI HEX3Atmp_364766;
	NI res_364768;
	tsymseq188805* LOC8;
	TY364619 LOC9;
	l = gmethods_364299->Sup.len;
	i_364474 = 0;
	HEX3Atmp_364766 = 0;
	HEX3Atmp_364766 = (NI32)(l - 1);
	res_364768 = 0;
	while (1) {
		tsym188833* disp;
		if (!(res_364768 <= HEX3Atmp_364766)) goto LA1;
		i_364474 = res_364768;
		disp = gmethods_364299->data[i_364474]->data[0];
		{
			NIM_BOOL LOC4;
			tnode188803* LOC7;
			LOC4 = 0;
			LOC4 = samemethodbucket_364302(disp, s);
			if (!LOC4) goto LA5;
			gmethods_364299->data[i_364474] = (tsymseq188805*) incrSeq(&(gmethods_364299->data[i_364474])->Sup, sizeof(tsym188833*));
			asgnRefNoCycle((void**) &gmethods_364299->data[i_364474]->data[gmethods_364299->data[i_364474]->Sup.len-1], s);
			LOC7 = 0;
			LOC7 = lastson_189189((*disp).Ast);
			attachdispatcher_364374(s, LOC7);
			checkmethodeffects_324602(disp, s);
			goto BeforeRet;
		}
		LA5: ;
		res_364768 += 1;
	} LA1: ;
	LOC8 = 0;
	LOC8 = (tsymseq188805*) newSeq((&NTI188805), 1);
	memset((void*)LOC9, 0, sizeof(LOC9));
	LOC9[0] = s;
	asgnRefNoCycle((void**) &LOC8->data[0], LOC9[0]);
	gmethods_364299 = (TY364278*) incrSeq(&(gmethods_364299)->Sup, sizeof(tsymseq188805*));
	genericSeqAssign(&gmethods_364299->data[gmethods_364299->Sup.len-1], LOC8, (&NTI188805));
	{
		tsym188833* disp;
		tnode188803* LOC22;
		tnode188803* LOC23;
		if (!!(fromcache)) goto LA12;
		disp = copysym_189147(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_189141((*disp).Typ, (*(*disp).Typ).Owner, NIM_FALSE));
		{
			if (!((*(*disp).Typ).Callconv == ((NU8) 5))) goto LA16;
			(*(*disp).Typ).Callconv = ((NU8) 0);
		}
		LA16: ;
		asgnRefNoCycle((void**) &(*disp).Ast, copytree_189237((*s).Ast));
		asgnRefNoCycle((void**) &(*(*disp).Ast).kindU.S6.Sons->data[6], emptynode_189727);
		{
			if (!!(((*(*s).Typ).Sons->data[0] == NIM_NIL))) goto LA20;
			asgnRefNoCycle((void**) &(*(*(*disp).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym, copysym_189147((*(*(*s).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym, NIM_FALSE));
		}
		LA20: ;
		LOC22 = 0;
		LOC22 = newsymnode_189095(disp);
		attachdispatcher_364374(s, LOC22);
		LOC23 = 0;
		LOC23 = newsymnode_189095(disp);
		attachdispatcher_364374(disp, LOC23);
	}
	LA12: ;
	BeforeRet: ;
}

N_NIMCALL(NIM_BOOL, relevantcol_364773)(tsymseq188805* methods, NI col) {
	NIM_BOOL result;
	ttype188837* t;
	result = 0;
	t = skiptypes_192793((*(*methods->data[0]).Typ).Sons->data[col], IL64(211106247215360));
	{
		NI i_364800;
		NI HEX3Atmp_364802;
		NI res_364804;
		if (!((*t).Kind == ((NU8) 17))) goto LA3;
		i_364800 = 0;
		HEX3Atmp_364802 = 0;
		HEX3Atmp_364802 = (methods->Sup.len-1);
		res_364804 = 1;
		while (1) {
			ttype188837* t2;
			if (!(res_364804 <= HEX3Atmp_364802)) goto LA5;
			i_364800 = res_364804;
			t2 = skiptypes_192793((*(*methods->data[i_364800]).Typ).Sons->data[col], IL64(211106247215360));
			{
				NIM_BOOL LOC8;
				LOC8 = 0;
				LOC8 = sametype_228116(t2, t, 0);
				if (!!(LOC8)) goto LA9;
				result = NIM_TRUE;
				goto BeforeRet;
			}
			LA9: ;
			res_364804 += 1;
		} LA5: ;
	}
	LA3: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NI, cmpsignatures_364809)(tsym188833* a, tsym188833* b, tintset185047 relevantcols) {
	NI result;
	NI col_364827;
	NI HEX3Atmp_364835;
	NI LOC1;
	NI res_364837;
	result = 0;
	col_364827 = 0;
	HEX3Atmp_364835 = 0;
	LOC1 = 0;
	LOC1 = sonslen_189185((*a).Typ);
	HEX3Atmp_364835 = (NI32)(LOC1 - 1);
	res_364837 = 1;
	while (1) {
		if (!(res_364837 <= HEX3Atmp_364835)) goto LA2;
		col_364827 = res_364837;
		{
			NIM_BOOL LOC5;
			ttype188837* aa;
			ttype188837* bb;
			NI d;
			LOC5 = 0;
			LOC5 = contains_185821(relevantcols, col_364827);
			if (!LOC5) goto LA6;
			aa = skiptypes_192793((*(*a).Typ).Sons->data[col_364827], IL64(211106247215360));
			bb = skiptypes_192793((*(*b).Typ).Sons->data[col_364827], IL64(211106247215360));
			d = inheritancediff_230560(aa, bb);
			{
				if (!!((d == 2147483647))) goto LA10;
				result = d;
				goto BeforeRet;
			}
			LA10: ;
		}
		LA6: ;
		res_364837 += 1;
	} LA2: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, sortbucket_364842)(tsymseq188805** a, tintset185047 relevantcols) {
	NI n;
	NI h;
	n = (*a)->Sup.len;
	h = 1;
	while (1) {
		h = (NI32)((NI32)(3 * h) + 1);
		{
			if (!(n < h)) goto LA4;
			goto LA1;
		}
		LA4: ;
	} LA1: ;
	while (1) {
		NI i_364873;
		NI HEX3Atmp_364877;
		NI res_364879;
		h = (NI32)(h / 3);
		i_364873 = 0;
		HEX3Atmp_364877 = 0;
		HEX3Atmp_364877 = (NI32)(n - 1);
		res_364879 = h;
		while (1) {
			tsym188833* v;
			NI j;
			if (!(res_364879 <= HEX3Atmp_364877)) goto LA7;
			i_364873 = res_364879;
			v = (*a)->data[i_364873];
			j = i_364873;
			while (1) {
				NI LOC9;
				LOC9 = 0;
				LOC9 = cmpsignatures_364809((*a)->data[(NI32)(j - h)], v, relevantcols);
				if (!(0 <= LOC9)) goto LA8;
				asgnRefNoCycle((void**) &(*a)->data[j], (*a)->data[(NI32)(j - h)]);
				j = (NI32)(j - h);
				{
					if (!(j < h)) goto LA12;
					goto LA8;
				}
				LA12: ;
			} LA8: ;
			asgnRefNoCycle((void**) &(*a)->data[j], v);
			res_364879 += 1;
		} LA7: ;
		{
			if (!(h == 1)) goto LA16;
			goto LA6;
		}
		LA16: ;
	} LA6: ;
}

N_NIMCALL(tsym188833*, gendispatcher_364887)(tsymseq188805* methods, tintset185047 relevantcols) {
	tsym188833* result;
	tsym188833* base;
	tnode188803* LOC1;
	NI paramlen;
	tnode188803* disp;
	tsym188833* ands;
	tsym188833* iss;
	NI meth_364923;
	NI HEX3Atmp_365117;
	NI res_365119;
	result = 0;
	LOC1 = 0;
	LOC1 = lastson_189189((*methods->data[0]).Ast);
	base = (*LOC1).kindU.S4.Sym;
	result = base;
	paramlen = sonslen_189185((*base).Typ);
	disp = newnodei_189099(((NU8) 92), (*base).Info);
	ands = getsyssym_242040(((NimStringDesc*) &TMP3785));
	iss = getsyssym_242040(((NimStringDesc*) &TMP3786));
	meth_364923 = 0;
	HEX3Atmp_365117 = 0;
	HEX3Atmp_365117 = (methods->Sup.len-1);
	res_365119 = 0;
	while (1) {
		tsym188833* curr;
		tnode188803* cond;
		NI col_364938;
		NI HEX3Atmp_365108;
		NI res_365110;
		tnode188803* call;
		tnode188803* LOC20;
		NI col_364999;
		NI HEX3Atmp_365112;
		NI res_365114;
		tnode188803* ret;
		if (!(res_365119 <= HEX3Atmp_365117)) goto LA2;
		meth_364923 = res_365119;
		curr = methods->data[meth_364923];
		cond = NIM_NIL;
		col_364938 = 0;
		HEX3Atmp_365108 = 0;
		HEX3Atmp_365108 = (NI32)(paramlen - 1);
		res_365110 = 1;
		while (1) {
			if (!(res_365110 <= HEX3Atmp_365108)) goto LA3;
			col_364938 = res_365110;
			{
				NIM_BOOL LOC6;
				tnode188803* isn;
				ttype188837* LOC9;
				tnode188803* LOC10;
				tnode188803* LOC11;
				tnode188803* LOC12;
				LOC6 = 0;
				LOC6 = contains_185821(relevantcols, col_364938);
				if (!LOC6) goto LA7;
				LOC9 = 0;
				LOC9 = getsystype_242024(((NU8) 1));
				isn = newnodeit_189104(((NU8) 27), (*base).Info, LOC9);
				LOC10 = 0;
				LOC10 = newsymnode_189095(iss);
				addson_189207(isn, LOC10);
				LOC11 = 0;
				LOC11 = newsymnode_189095((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_364938]).kindU.S4.Sym);
				addson_189207(isn, LOC11);
				LOC12 = 0;
				LOC12 = newnodeit_189104(((NU8) 4), (*base).Info, (*(*curr).Typ).Sons->data[col_364938]);
				addson_189207(isn, LOC12);
				{
					tnode188803* a;
					ttype188837* LOC17;
					tnode188803* LOC18;
					if (!!((cond == NIM_NIL))) goto LA15;
					LOC17 = 0;
					LOC17 = getsystype_242024(((NU8) 1));
					a = newnodeit_189104(((NU8) 27), (*base).Info, LOC17);
					LOC18 = 0;
					LOC18 = newsymnode_189095(ands);
					addson_189207(a, LOC18);
					addson_189207(a, cond);
					addson_189207(a, isn);
					cond = a;
				}
				goto LA13;
				LA15: ;
				{
					cond = isn;
				}
				LA13: ;
			}
			LA7: ;
			res_365110 += 1;
		} LA3: ;
		call = newnodei_189099(((NU8) 27), (*base).Info);
		LOC20 = 0;
		LOC20 = newsymnode_189095(curr);
		addson_189207(call, LOC20);
		col_364999 = 0;
		HEX3Atmp_365112 = 0;
		HEX3Atmp_365112 = (NI32)(paramlen - 1);
		res_365114 = 1;
		while (1) {
			tnode188803* LOC22;
			tnode188803* LOC23;
			if (!(res_365114 <= HEX3Atmp_365112)) goto LA21;
			col_364999 = res_365114;
			LOC22 = 0;
			LOC22 = newsymnode_189095((*(*(*(*base).Typ).N).kindU.S6.Sons->data[col_364999]).kindU.S4.Sym);
			LOC23 = 0;
			LOC23 = genconv_364012(LOC22, (*(*curr).Typ).Sons->data[col_364999], NIM_FALSE);
			addson_189207(call, LOC23);
			res_365114 += 1;
		} LA21: ;
		ret = 0;
		{
			tnode188803* a;
			tnode188803* LOC28;
			if (!!(((*(*base).Typ).Sons->data[0] == NIM_NIL))) goto LA26;
			a = newnodei_189099(((NU8) 73), (*base).Info);
			LOC28 = 0;
			LOC28 = newsymnode_189095((*(*(*base).Ast).kindU.S6.Sons->data[7]).kindU.S4.Sym);
			addson_189207(a, LOC28);
			addson_189207(a, call);
			ret = newnodei_189099(((NU8) 108), (*base).Info);
			addson_189207(ret, a);
		}
		goto LA24;
		LA26: ;
		{
			ret = call;
		}
		LA24: ;
		{
			tnode188803* a;
			if (!!((cond == NIM_NIL))) goto LA32;
			a = newnodei_189099(((NU8) 86), (*base).Info);
			addson_189207(a, cond);
			addson_189207(a, ret);
			addson_189207(disp, a);
		}
		goto LA30;
		LA32: ;
		{
			disp = ret;
		}
		LA30: ;
		res_365119 += 1;
	} LA2: ;
	asgnRefNoCycle((void**) &(*(*result).Ast).kindU.S6.Sons->data[6], disp);
	return result;
}

N_NIMCALL(tnode188803*, generatemethoddispatchers_365126)(void) {
	tnode188803* result;
	NI bucket_365152;
	NI HEX3Atmp_365173;
	NI res_365175;
	result = 0;
	result = newnode_189065(((NU8) 114));
	bucket_365152 = 0;
	HEX3Atmp_365173 = 0;
	HEX3Atmp_365173 = (NI32)(gmethods_364299->Sup.len - 1);
	res_365175 = 0;
	while (1) {
		tintset185047 relevantcols;
		NI col_365166;
		NI HEX3Atmp_365169;
		NI LOC2;
		NI res_365171;
		tsym188833* LOC9;
		tnode188803* LOC10;
		if (!(res_365175 <= HEX3Atmp_365173)) goto LA1;
		bucket_365152 = res_365175;
		chckNil((void*)&relevantcols);
		memset((void*)&relevantcols, 0, sizeof(relevantcols));
		initintset_185918(&relevantcols);
		col_365166 = 0;
		HEX3Atmp_365169 = 0;
		LOC2 = 0;
		LOC2 = sonslen_189185((*gmethods_364299->data[bucket_365152]->data[0]).Typ);
		HEX3Atmp_365169 = (NI32)(LOC2 - 1);
		res_365171 = 1;
		while (1) {
			if (!(res_365171 <= HEX3Atmp_365169)) goto LA3;
			col_365166 = res_365171;
			{
				NIM_BOOL LOC6;
				LOC6 = 0;
				LOC6 = relevantcol_364773(gmethods_364299->data[bucket_365152], col_365166);
				if (!LOC6) goto LA7;
				incl_185849(&relevantcols, col_365166);
			}
			LA7: ;
			res_365171 += 1;
		} LA3: ;
		sortbucket_364842(&gmethods_364299->data[bucket_365152], relevantcols);
		LOC9 = 0;
		LOC9 = gendispatcher_364887(gmethods_364299->data[bucket_365152], relevantcols);
		LOC10 = 0;
		LOC10 = newsymnode_189095(LOC9);
		addson_189207(result, LOC10);
		res_365175 += 1;
	} LA1: ;
	return result;
}
N_NOINLINE(void, cgmethInit)(void) {
	if (gmethods_364299) nimGCunrefNoCycle(gmethods_364299);
	gmethods_364299 = (TY364278*) newSeqRC1((&NTI364278), 0);
}

N_NOINLINE(void, cgmethDatInit)(void) {
NTI364278.size = sizeof(TY364278*);
NTI364278.kind = 24;
NTI364278.base = (&NTI188805);
NTI364278.flags = 2;
NTI364278.marker = TMP915;
}

