/* Generated by Nim Compiler v0.12.0 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32

#include "nimbase.h"
#include <string.h>
typedef struct Tnode224809 Tnode224809;
typedef struct Tsym224841 Tsym224841;
typedef struct Tlineinfo189352 Tlineinfo189352;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Ttype224847 Ttype224847;
typedef struct Tident197021 Tident197021;
typedef struct Tnodeseq224803 Tnodeseq224803;
typedef struct Tidobj197015 Tidobj197015;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Ttypeseq224843 Ttypeseq224843;
typedef struct Tscope224835 Tscope224835;
typedef struct TY224944 TY224944;
typedef struct Tstrtable224813 Tstrtable224813;
typedef struct Tsymseq224811 Tsymseq224811;
typedef struct Tloc224823 Tloc224823;
typedef struct Ropeobj175009 Ropeobj175009;
typedef struct Tlib224827 Tlib224827;
typedef struct Templctx430019 Templctx430019;
typedef struct Tidtable224859 Tidtable224859;
typedef struct Tidpairseq224857 Tidpairseq224857;
typedef struct TY90959 TY90959;
typedef struct Cell48947 Cell48947;
typedef struct Cellseq48963 Cellseq48963;
typedef struct Gcheap51018 Gcheap51018;
typedef struct Gcstack51016 Gcstack51016;
typedef struct Cellset48959 Cellset48959;
typedef struct Pagedesc48955 Pagedesc48955;
typedef struct Memregion30890 Memregion30890;
typedef struct Smallchunk30842 Smallchunk30842;
typedef struct Llchunk30884 Llchunk30884;
typedef struct Bigchunk30844 Bigchunk30844;
typedef struct Intset30817 Intset30817;
typedef struct Trunk30813 Trunk30813;
typedef struct Avlnode30888 Avlnode30888;
typedef struct Gcstat51014 Gcstat51014;
typedef struct Tinstantiation224831 Tinstantiation224831;
typedef struct Tlistentry140022 Tlistentry140022;
typedef struct Tidpair224855 Tidpair224855;
typedef struct Basechunk30840 Basechunk30840;
typedef struct Freecell30832 Freecell30832;
typedef struct TY224932 TY224932;
struct  Tlineinfo189352  {
NI16 line;
NI16 col;
NI32 fileindex;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  Tnode224809  {
Ttype224847* typ;
Tlineinfo189352 info;
NU16 flags;
NU8 kind;
union{
struct {NI64 intval;
} S1;
struct {NF floatval;
} S2;
struct {NimStringDesc* strval;
} S3;
struct {Tsym224841* sym;
} S4;
struct {Tident197021* ident;
} S5;
struct {Tnodeseq224803* sons;
} S6;
} kindU;
NimStringDesc* comment;
};
typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3894) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3889 marker;
TY3894 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Tidobj197015  {
  TNimObject Sup;
NI id;
};
struct  Tstrtable224813  {
NI counter;
Tsymseq224811* data;
};
struct  Tloc224823  {
NU8 k;
NU8 s;
NU16 flags;
Ttype224847* t;
Ropeobj175009* r;
Ropeobj175009* heaproot;
};
struct  Tsym224841  {
  Tidobj197015 Sup;
NU8 kind;
union{
struct {Ttypeseq224843* typeinstcache;
Tscope224835* typscope;
} S1;
struct {TY224944* procinstcache;
Tsym224841* gcunsafetyreason;
} S2;
struct {TY224944* usedgenerics;
Tstrtable224813 tab;
} S3;
struct {Tsym224841* guard;
NI bitsize;
} S4;
} kindU;
NU8 magic;
Ttype224847* typ;
Tident197021* name;
Tlineinfo189352 info;
Tsym224841* owner;
NU32 flags;
Tnode224809* ast;
NU32 options;
NI position;
NI offset;
Tloc224823 loc;
Tlib224827* annex;
Tnode224809* constraint;
};
struct  Ttype224847  {
  Tidobj197015 Sup;
NU8 kind;
NU8 callconv;
NU32 flags;
Ttypeseq224843* sons;
Tnode224809* n;
Tsym224841* owner;
Tsym224841* sym;
Tsym224841* destructor;
Tsym224841* deepcopy;
Tsym224841* assignment;
NI64 size;
NI16 align;
NI16 locklevel;
Tloc224823 loc;
};
struct  Tidtable224859  {
NI counter;
Tidpairseq224857* data;
};
struct  Templctx430019  {
Tsym224841* owner;
Tsym224841* gensymowner;
NIM_BOOL instlines;
Tidtable224859 mapping;
};
struct TY90959 {
NimStringDesc* Field0;
NI Field1;
};
struct  Cell48947  {
NI refcount;
TNimType* typ;
};
struct  Cellseq48963  {
NI len;
NI cap;
Cell48947** d;
};
struct  Cellset48959  {
NI counter;
NI max;
Pagedesc48955* head;
Pagedesc48955** data;
};
typedef Smallchunk30842* TY30905[512];
typedef Trunk30813* Trunkbuckets30815[256];
struct  Intset30817  {
Trunkbuckets30815 data;
};
struct  Memregion30890  {
NI minlargeobj;
NI maxlargeobj;
TY30905 freesmallchunks;
Llchunk30884* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk30844* freechunkslist;
Intset30817 chunkstarts;
Avlnode30888* root;
Avlnode30888* deleted;
Avlnode30888* last;
Avlnode30888* freeavlnodes;
};
struct  Gcstat51014  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap51018  {
Gcstack51016* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq48963 zct;
Cellseq48963 decstack;
Cellset48959 cycleroots;
Cellseq48963 tempstack;
NI recgclock;
Memregion30890 region;
Gcstat51014 stat;
};
struct  Tident197021  {
  Tidobj197015 Sup;
NimStringDesc* s;
Tident197021* next;
NI h;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Tscope224835  {
NI depthlevel;
Tstrtable224813 symbols;
Tnodeseq224803* usingsyms;
Tscope224835* parent;
};
struct  Ropeobj175009  {
  TNimObject Sup;
Ropeobj175009* left;
Ropeobj175009* right;
NI length;
NimStringDesc* data;
};
struct  Tlistentry140022  {
  TNimObject Sup;
Tlistentry140022* prev;
Tlistentry140022* next;
};
struct  Tlib224827  {
  Tlistentry140022 Sup;
NU8 kind;
NIM_BOOL generated;
NIM_BOOL isoverriden;
Ropeobj175009* name;
Tnode224809* path;
};
struct  Tidpair224855  {
Tidobj197015* key;
TNimObject* val;
};
struct  Gcstack51016  {
Gcstack51016* prev;
Gcstack51016* next;
void* starts;
void* pos;
NI maxstacksize;
};
typedef NI TY30821[16];
struct  Pagedesc48955  {
Pagedesc48955* next;
NI key;
TY30821 bits;
};
struct  Basechunk30840  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk30842  {
  Basechunk30840 Sup;
Smallchunk30842* next;
Smallchunk30842* prev;
Freecell30832* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk30884  {
NI size;
NI acc;
Llchunk30884* next;
};
struct  Bigchunk30844  {
  Basechunk30840 Sup;
Bigchunk30844* next;
Bigchunk30844* prev;
NI align;
NF data;
};
struct  Trunk30813  {
Trunk30813* next;
NI key;
TY30821 bits;
};
typedef Avlnode30888* TY30895[2];
struct  Avlnode30888  {
TY30895 link;
NI key;
NI upperbound;
NI level;
};
struct  Tinstantiation224831  {
Tsym224841* sym;
Ttypeseq224843* concretetypes;
TY224932* usedby;
NI compilesid;
};
struct  Freecell30832  {
Freecell30832* next;
NI zerofield;
};
struct Tnodeseq224803 {
  TGenericSeq Sup;
  Tnode224809* data[SEQ_DECL_SIZE];
};
struct Ttypeseq224843 {
  TGenericSeq Sup;
  Ttype224847* data[SEQ_DECL_SIZE];
};
struct TY224944 {
  TGenericSeq Sup;
  Tinstantiation224831* data[SEQ_DECL_SIZE];
};
struct Tsymseq224811 {
  TGenericSeq Sup;
  Tsym224841* data[SEQ_DECL_SIZE];
};
struct Tidpairseq224857 {
  TGenericSeq Sup;
  Tidpair224855 data[SEQ_DECL_SIZE];
};
struct TY224932 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, globalerror_195107)(Tlineinfo189352 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(Tnode224809*, evaltemplateargs_430248)(Tnode224809* n, Tsym224841* s);
static N_INLINE(NI, len_225098)(Tnode224809* n);
static N_INLINE(Tnode224809*, HEX5BHEX5D_225244)(Tnode224809* n, NI i);
N_NIMCALL(NI, len_227369)(Ttype224847* n);
N_NIMCALL(Tnode224809*, newnodei_226351)(NU8 kind, Tlineinfo189352 info);
N_NIMCALL(void, addson_226819)(Tnode224809* father, Tnode224809* son);
N_NIMCALL(void, localerror_195128)(Tlineinfo189352 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(Tnode224809*, copytree_229028)(Tnode224809* src);
N_NIMCALL(void, initidtable_228057)(Tidtable224859* x);
N_NIMCALL(Tnode224809*, getbody_270062)(Tsym224841* s);
static N_INLINE(NIM_BOOL, isatom_229904)(Tnode224809* n);
N_NIMCALL(void, evaltemplateaux_430039)(Tnode224809* templ, Tnode224809* actual, Templctx430019* c, Tnode224809* result);
N_NIMCALL(void, add_225165)(Tnode224809* father, Tnode224809* son);
N_NIMCALL(void, internalerror_195191)(NimStringDesc* errmsg);
N_NIMCALL(NimStringDesc*, HEX24_195279)(TY90959 x);
N_NIMCALL(TNimObject*, idtableget_232182)(Tidtable224859 t, Tidobj197015* key);
N_NIMCALL(Tsym224841*, copysym_227607)(Tsym224841* s, NIM_BOOL keepid);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Cell48947*, usrtocell_52646)(void* usr);
static N_INLINE(void, rtladdzct_54204)(Cell48947* c);
N_NOINLINE(void, addzct_52617)(Cellseq48963* s, Cell48947* c);
N_NIMCALL(void, idtableput_232196)(Tidtable224859* t, Tidobj197015* key, TNimObject* val);
N_NIMCALL(Tnode224809*, newsymnode_226338)(Tsym224841* sym, Tlineinfo189352 info);
N_NIMCALL(Tnode224809*, copynode_430027)(Templctx430019* ctx, Tnode224809* a, Tnode224809* b);
N_NIMCALL(Tnode224809*, copynode_228660)(Tnode224809* src);
N_NIMCALL(NI, sonslen_227387)(Tnode224809* n);
N_NIMCALL(NimStringDesc*, rendertree_246059)(Tnode224809* n, NU8 renderflags);
static N_INLINE(NI, safelen_225126)(Tnode224809* n);
STRING_LITERAL(TMP2934, "", 0);
STRING_LITERAL(TMP2936, "compiler/evaltempl.nim", 22);
NIM_CONST TY90959 TMP2935 = {((NimStringDesc*) &TMP2936),
((NI) 44)}
;
NI evaltemplatecounter_430396;
extern Tnode224809* emptynode_225807;
extern Gcheap51018 gch_51059;

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

static N_INLINE(Tnode224809*, HEX5BHEX5D_225244)(Tnode224809* n, NI i) {
	Tnode224809* result;
	result = 0;
	result = (*n).kindU.S6.sons->data[i];
	return result;
}

N_NIMCALL(Tnode224809*, evaltemplateargs_430248)(Tnode224809* n, Tsym224841* s) {
	Tnode224809* result;
	NI totalparams;
	NI genericparams;
	NI expectedregularparams;
	NI LOC10;
	NI givenregularparams;
	result = 0;
	switch ((*n).kind) {
	case ((NU8) 27):
	case ((NU8) 29):
	case ((NU8) 30):
	case ((NU8) 31):
	case ((NU8) 26):
	case ((NU8) 28):
	{
		NI LOC2;
		LOC2 = 0;
		LOC2 = len_225098(n);
		totalparams = (NI)(LOC2 - ((NI) 1));
	}
	break;
	default:
	{
		totalparams = ((NI) 0);
	}
	break;
	}
	{
		if (!(((*s).flags &(1<<((((NU8) 25))&31)))!=0)) goto LA6;
		genericparams = ((NI) 0);
	}
	goto LA4;
	LA6: ;
	{
		Tnode224809* LOC9;
		LOC9 = 0;
		LOC9 = HEX5BHEX5D_225244((*s).ast, ((NI) 2));
		genericparams = len_225098(LOC9);
	}
	LA4: ;
	LOC10 = 0;
	LOC10 = len_227369((*s).typ);
	expectedregularparams = (LOC10 - 1);
	givenregularparams = (NI)(totalparams - genericparams);
	{
		if (!((NI)(expectedregularparams + genericparams) < totalparams)) goto LA13;
		globalerror_195107((*n).info, ((NU16) 137), ((NimStringDesc*) &TMP2934));
	}
	LA13: ;
	result = newnodei_226351(((NU8) 152), (*n).info);
	{
		NI i_430290;
		NI res_430344;
		i_430290 = 0;
		res_430344 = ((NI) 1);
		{
			while (1) {
				if (!(res_430344 <= givenregularparams)) goto LA17;
				i_430290 = res_430344;
				addson_226819(result, (*n).kindU.S6.sons->data[i_430290]);
				res_430344 += ((NI) 1);
			} LA17: ;
		}
	}
	{
		NI i_430303;
		NI HEX3Atmp_430349;
		NI res_430352;
		i_430303 = 0;
		HEX3Atmp_430349 = 0;
		HEX3Atmp_430349 = (NI)(givenregularparams + ((NI) 1));
		res_430352 = HEX3Atmp_430349;
		{
			while (1) {
				Tnode224809* default_430308;
				if (!(res_430352 <= expectedregularparams)) goto LA20;
				i_430303 = res_430352;
				default_430308 = (*(*(*(*(*s).typ).n).kindU.S6.sons->data[i_430303]).kindU.S4.sym).ast;
				{
					NIM_BOOL LOC23;
					LOC23 = 0;
					LOC23 = default_430308 == 0;
					if (LOC23) goto LA24;
					LOC23 = ((*default_430308).kind == ((NU8) 1));
					LA24: ;
					if (!LOC23) goto LA25;
					localerror_195128((*n).info, ((NU16) 137), ((NimStringDesc*) &TMP2934));
					addson_226819(result, emptynode_225807);
				}
				goto LA21;
				LA25: ;
				{
					Tnode224809* LOC28;
					LOC28 = 0;
					LOC28 = copytree_229028(default_430308);
					addson_226819(result, LOC28);
				}
				LA21: ;
				res_430352 += ((NI) 1);
			} LA20: ;
		}
	}
	{
		NI i_430338;
		NI res_430359;
		i_430338 = 0;
		res_430359 = ((NI) 1);
		{
			while (1) {
				if (!(res_430359 <= genericparams)) goto LA31;
				i_430338 = res_430359;
				addson_226819(result, (*n).kindU.S6.sons->data[(NI)(givenregularparams + i_430338)]);
				res_430359 += ((NI) 1);
			} LA31: ;
		}
	}
	return result;
}

static N_INLINE(NIM_BOOL, isatom_229904)(Tnode224809* n) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = (((NU8) 0) <= (*n).kind);
	if (!(LOC1)) goto LA2;
	LOC1 = ((*n).kind <= ((NU8) 23));
	LA2: ;
	result = LOC1;
	return result;
}

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

static N_INLINE(void, rtladdzct_54204)(Cell48947* c) {
	addzct_52617((&gch_51059.zct), c);
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Cell48947* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_52646(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell48947* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_52646((*dest));
		{
			(*c).refcount -= ((NI) 8);
			if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA11;
			rtladdzct_54204(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

N_NIMCALL(Tnode224809*, copynode_430027)(Templctx430019* ctx, Tnode224809* a, Tnode224809* b) {
	Tnode224809* result;
	result = 0;
	result = copynode_228660(a);
	{
		if (!(*ctx).instlines) goto LA3;
		(*result).info = (*b).info;
	}
	LA3: ;
	return result;
}

N_NIMCALL(void, evaltemplateaux_430039)(Tnode224809* templ, Tnode224809* actual, Templctx430019* c, Tnode224809* result) {
	switch ((*templ).kind) {
	case ((NU8) 3):
	{
		Tsym224841* s;
		s = (*templ).kindU.S4.sym;
		{
			if (!((*(*s).owner).Sup.id == (*(*c).owner).Sup.id)) goto LA4;
			{
				NIM_BOOL LOC8;
				Tnode224809* x_430083;
				LOC8 = 0;
				LOC8 = ((*s).kind == ((NU8) 3));
				if (!(LOC8)) goto LA9;
				LOC8 = !((((*s).flags &(1<<((((NU8) 31))&31)))!=0));
				LA9: ;
				if (!LOC8) goto LA10;
				x_430083 = (*actual).kindU.S6.sons->data[(*s).position];
				{
					if (!((*x_430083).kind == ((NU8) 152))) goto LA14;
					{
						Tnode224809* y_430085;
						y_430085 = 0;
						{
							NI i_430183;
							NI HEX3Atmp_430185;
							NI LOC18;
							NI res_430187;
							i_430183 = 0;
							HEX3Atmp_430185 = 0;
							LOC18 = 0;
							LOC18 = len_225098(x_430083);
							HEX3Atmp_430185 = (LOC18 - 1);
							res_430187 = ((NI) 0);
							{
								while (1) {
									if (!(res_430187 <= HEX3Atmp_430185)) goto LA20;
									i_430183 = res_430187;
									y_430085 = (*x_430083).kindU.S6.sons->data[i_430183];
									add_225165(result, y_430085);
									res_430187 += ((NI) 1);
								} LA20: ;
							}
						}
					}
				}
				goto LA12;
				LA14: ;
				{
					Tnode224809* LOC22;
					LOC22 = 0;
					LOC22 = copytree_229028(x_430083);
					add_225165(result, LOC22);
				}
				LA12: ;
			}
			goto LA6;
			LA10: ;
			{
				Tnode224809* x_430109;
				NI LOC26;
				if (!((*s).kind == ((NU8) 4))) goto LA24;
				LOC26 = 0;
				LOC26 = len_227369((*(*s).owner).typ);
				x_430109 = (*actual).kindU.S6.sons->data[(NI)((NI)(LOC26 + (*s).position) - ((NI) 1))];
				{
					if (!((*x_430109).kind == ((NU8) 152))) goto LA29;
					{
						Tnode224809* y_430111;
						y_430111 = 0;
						{
							NI i_430194;
							NI HEX3Atmp_430196;
							NI LOC33;
							NI res_430198;
							i_430194 = 0;
							HEX3Atmp_430196 = 0;
							LOC33 = 0;
							LOC33 = len_225098(x_430109);
							HEX3Atmp_430196 = (LOC33 - 1);
							res_430198 = ((NI) 0);
							{
								while (1) {
									if (!(res_430198 <= HEX3Atmp_430196)) goto LA35;
									i_430194 = res_430198;
									y_430111 = (*x_430109).kindU.S6.sons->data[i_430194];
									add_225165(result, y_430111);
									res_430198 += ((NI) 1);
								} LA35: ;
							}
						}
					}
				}
				goto LA27;
				LA29: ;
				{
					Tnode224809* LOC37;
					LOC37 = 0;
					LOC37 = copytree_229028(x_430109);
					add_225165(result, LOC37);
				}
				LA27: ;
			}
			goto LA6;
			LA24: ;
			{
				Tsym224841* x;
				Tidobj197015* LOC44;
				TNimObject* LOC45;
				Tlineinfo189352 LOC52;
				Tnode224809* LOC58;
				{
					NimStringDesc* LOC43;
					if (!!((((*s).flags &(1<<((((NU8) 31))&31)))!=0))) goto LA41;
					LOC43 = 0;
					LOC43 = HEX24_195279(TMP2935);
					internalerror_195191(LOC43);
				}
				LA41: ;
				LOC44 = 0;
				LOC44 = &s->Sup;
				LOC45 = 0;
				LOC45 = idtableget_232182((*c).mapping, LOC44);
				x = ((Tsym224841*) (LOC45));
				{
					Tidobj197015* LOC50;
					TNimObject* LOC51;
					if (!(x == NIM_NIL)) goto LA48;
					x = copysym_227607(s, NIM_FALSE);
					asgnRefNoCycle((void**) (&(*x).owner), (*c).gensymowner);
					LOC50 = 0;
					LOC50 = &s->Sup;
					LOC51 = 0;
					LOC51 = &x->Sup.Sup;
					idtableput_232196((&(*c).mapping), LOC50, LOC51);
				}
				LA48: ;
				{
					if (!(*c).instlines) goto LA55;
					LOC52 = (*actual).info;
				}
				goto LA53;
				LA55: ;
				{
					LOC52 = (*templ).info;
				}
				LA53: ;
				LOC58 = 0;
				LOC58 = newsymnode_226338(x, LOC52);
				add_225165(result, LOC58);
			}
			LA6: ;
		}
		goto LA2;
		LA4: ;
		{
			Tnode224809* LOC60;
			LOC60 = 0;
			LOC60 = copynode_430027((&(*c)), templ, actual);
			add_225165(result, LOC60);
		}
		LA2: ;
	}
	break;
	case ((NU8) 0) ... ((NU8) 2):
	case ((NU8) 4) ... ((NU8) 23):
	{
		Tnode224809* LOC62;
		LOC62 = 0;
		LOC62 = copynode_430027((&(*c)), templ, actual);
		add_225165(result, LOC62);
	}
	break;
	default:
	{
		Tnode224809* res;
		res = copynode_430027((&(*c)), templ, actual);
		{
			NI i_430176;
			NI HEX3Atmp_430202;
			NI LOC65;
			NI res_430205;
			i_430176 = 0;
			HEX3Atmp_430202 = 0;
			LOC65 = 0;
			LOC65 = sonslen_227387(templ);
			HEX3Atmp_430202 = (NI)(LOC65 - ((NI) 1));
			res_430205 = ((NI) 0);
			{
				while (1) {
					if (!(res_430205 <= HEX3Atmp_430202)) goto LA67;
					i_430176 = res_430205;
					evaltemplateaux_430039((*templ).kindU.S6.sons->data[i_430176], actual, c, res);
					res_430205 += ((NI) 1);
				} LA67: ;
			}
		}
		add_225165(result, res);
	}
	break;
	}
}

static N_INLINE(NI, safelen_225126)(Tnode224809* n) {
	NI result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = ((*n).kind >= ((NU8) 0) && (*n).kind <= ((NU8) 23));
		if (LOC3) goto LA4;
		LOC3 = (*n).kindU.S6.sons == 0;
		LA4: ;
		if (!LOC3) goto LA5;
		result = ((NI) 0);
	}
	goto LA1;
	LA5: ;
	{
		result = ((*n).kindU.S6.sons ? (*n).kindU.S6.sons->Sup.len : 0);
	}
	LA1: ;
	return result;
}

N_NIMCALL(Tnode224809*, evaltemplate_430400)(Tnode224809* n, Tsym224841* tmpl, Tsym224841* gensymowner) {
	Tnode224809* result;
	Tnode224809* args;
	Templctx430019 ctx;
	Tnode224809* body;
	result = 0;
	evaltemplatecounter_430396 += ((NI) 1);
	{
		if (!(((NI) 100) < evaltemplatecounter_430396)) goto LA3;
		globalerror_195107((*n).info, ((NU16) 188), ((NimStringDesc*) &TMP2934));
		result = n;
	}
	LA3: ;
	args = evaltemplateargs_430248(n, tmpl);
	memset((void*)(&ctx), 0, sizeof(ctx));
	ctx.owner = tmpl;
	ctx.gensymowner = gensymowner;
	initidtable_228057((&ctx.mapping));
	body = getbody_270062(tmpl);
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = isatom_229904(body);
		if (!LOC7) goto LA8;
		result = newnodei_226351(((NU8) 37), (*body).info);
		evaltemplateaux_430039(body, args, (&ctx), result);
		{
			NI LOC12;
			LOC12 = 0;
			LOC12 = len_225098(result);
			if (!(LOC12 == ((NI) 1))) goto LA13;
			result = (*result).kindU.S6.sons->data[((NI) 0)];
		}
		goto LA10;
		LA13: ;
		{
			NimStringDesc* LOC16;
			LOC16 = 0;
			LOC16 = rendertree_246059(result, 4);
			localerror_195128((*result).info, ((NU16) 1), LOC16);
		}
		LA10: ;
	}
	goto LA5;
	LA8: ;
	{
		result = copynode_228660(body);
		ctx.instlines = !(((*body).kind == ((NU8) 115) || (*body).kind == ((NU8) 126) || (*body).kind == ((NU8) 112) || (*body).kind == ((NU8) 127)));
		{
			if (!ctx.instlines) goto LA20;
			(*result).info = (*n).info;
		}
		LA20: ;
		{
			NI i_430448;
			NI HEX3Atmp_430462;
			NI LOC23;
			NI res_430465;
			i_430448 = 0;
			HEX3Atmp_430462 = 0;
			LOC23 = 0;
			LOC23 = safelen_225126(body);
			HEX3Atmp_430462 = (NI)(LOC23 - ((NI) 1));
			res_430465 = ((NI) 0);
			{
				while (1) {
					if (!(res_430465 <= HEX3Atmp_430462)) goto LA25;
					i_430448 = res_430465;
					evaltemplateaux_430039((*body).kindU.S6.sons->data[i_430448], args, (&ctx), result);
					res_430465 += ((NI) 1);
				} LA25: ;
			}
		}
	}
	LA5: ;
	evaltemplatecounter_430396 -= ((NI) 1);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_evaltemplInit000)(void) {
	evaltemplatecounter_430396 = ((NI) 0);
}

NIM_EXTERNC N_NOINLINE(void, compiler_evaltemplDatInit000)(void) {
}

