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

#include "nimbase.h"
#include <string.h>
typedef struct Tnode214790 Tnode214790;
typedef struct Tsym214822 Tsym214822;
typedef struct Ttype214828 Ttype214828;
typedef struct Detectionpass380248 Detectionpass380248;
typedef struct Intset211035 Intset211035;
typedef struct Trunk211031 Trunk211031;
typedef struct Trunkseq211033 Trunkseq211033;
typedef struct Table380256 Table380256;
typedef struct Keyvaluepairseq380259 Keyvaluepairseq380259;
typedef struct Tidobj189006 Tidobj189006;
typedef struct TNimObject TNimObject;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Ttypeseq214824 Ttypeseq214824;
typedef struct Tscope214816 Tscope214816;
typedef struct TY214925 TY214925;
typedef struct Tstrtable214794 Tstrtable214794;
typedef struct Tsymseq214792 Tsymseq214792;
typedef struct Tident189012 Tident189012;
typedef struct Tlineinfo182337 Tlineinfo182337;
typedef struct Tloc214804 Tloc214804;
typedef struct Ropeobj169006 Ropeobj169006;
typedef struct Tlib214808 Tlib214808;
typedef struct Liftingpass381050 Liftingpass381050;
typedef struct Table381057 Table381057;
typedef struct Keyvaluepairseq381060 Keyvaluepairseq381060;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct Tnodeseq214784 Tnodeseq214784;
typedef struct Cell47505 Cell47505;
typedef struct Cellseq47521 Cellseq47521;
typedef struct Gcheap49818 Gcheap49818;
typedef struct Gcstack49816 Gcstack49816;
typedef struct Cellset47517 Cellset47517;
typedef struct Pagedesc47513 Pagedesc47513;
typedef struct Memregion29688 Memregion29688;
typedef struct Smallchunk29640 Smallchunk29640;
typedef struct Llchunk29682 Llchunk29682;
typedef struct Bigchunk29642 Bigchunk29642;
typedef struct Intset29614 Intset29614;
typedef struct Trunk29610 Trunk29610;
typedef struct Avlnode29686 Avlnode29686;
typedef struct Gcstat49814 Gcstat49814;
typedef struct Slice88080 Slice88080;
typedef struct Keyvaluepair380262 Keyvaluepair380262;
typedef struct Tinstantiation214812 Tinstantiation214812;
typedef struct Tlistentry135010 Tlistentry135010;
typedef struct Keyvaluepair381063 Keyvaluepair381063;
typedef struct Basechunk29638 Basechunk29638;
typedef struct Freecell29630 Freecell29630;
typedef struct TY214913 TY214913;
struct  Intset211035  {
NI counter;
NI max;
Trunk211031* head;
Trunkseq211033* data;
};
struct  Table380256  {
Keyvaluepairseq380259* data;
NI counter;
};
struct  Detectionpass380248  {
Intset211035 processed;
Intset211035 capturedvars;
Table380256 ownertotype;
NIM_BOOL somethingtodo;
};
typedef N_NIMCALL_PTR(void, TY3489) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 deepcopy;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Tidobj189006  {
  TNimObject Sup;
NI id;
};
struct  Tstrtable214794  {
NI counter;
Tsymseq214792* data;
};
struct  Tlineinfo182337  {
NI16 line;
NI16 col;
NI32 fileindex;
};
struct  Tloc214804  {
NU8 k;
NU8 s;
NU16 flags;
Ttype214828* t;
Ropeobj169006* r;
Ropeobj169006* heaproot;
};
struct  Tsym214822  {
  Tidobj189006 Sup;
NU8 kind;
union{
struct {Ttypeseq214824* typeinstcache;
Tscope214816* typscope;
} S1;
struct {TY214925* procinstcache;
Tsym214822* gcunsafetyreason;
} S2;
struct {TY214925* usedgenerics;
Tstrtable214794 tab;
} S3;
struct {Tsym214822* guard;
NI bitsize;
} S4;
} kindU;
NU8 magic;
Ttype214828* typ;
Tident189012* name;
Tlineinfo182337 info;
Tsym214822* owner;
NU32 flags;
Tnode214790* ast;
NU32 options;
NI position;
NI offset;
Tloc214804 loc;
Tlib214808* annex;
Tnode214790* constraint;
};
struct  Table381057  {
Keyvaluepairseq381060* data;
NI counter;
};
struct  Liftingpass381050  {
Intset211035 processed;
Table381057 envvars;
};
struct  Ttype214828  {
  Tidobj189006 Sup;
NU8 kind;
NU8 callconv;
NU32 flags;
Ttypeseq214824* sons;
Tnode214790* n;
Tsym214822* owner;
Tsym214822* sym;
Tsym214822* destructor;
Tsym214822* deepcopy;
Tsym214822* assignment;
NI64 size;
NI16 align;
NI16 locklevel;
Tloc214804 loc;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  Tnode214790  {
Ttype214828* typ;
Tlineinfo182337 info;
NU16 flags;
NU8 kind;
union{
struct {NI64 intval;
} S1;
struct {NF floatval;
} S2;
struct {NimStringDesc* strval;
} S3;
struct {Tsym214822* sym;
} S4;
struct {Tident189012* ident;
} S5;
struct {Tnodeseq214784* sons;
} S6;
} kindU;
NimStringDesc* comment;
};
struct  Tident189012  {
  Tidobj189006 Sup;
NimStringDesc* s;
Tident189012* next;
NI h;
};
struct  Cell47505  {
NI refcount;
TNimType* typ;
};
struct  Cellseq47521  {
NI len;
NI cap;
Cell47505** d;
};
struct  Cellset47517  {
NI counter;
NI max;
Pagedesc47513* head;
Pagedesc47513** data;
};
typedef Smallchunk29640* TY29703[512];
typedef Trunk29610* Trunkbuckets29612[256];
struct  Intset29614  {
Trunkbuckets29612 data;
};
struct  Memregion29688  {
NI minlargeobj;
NI maxlargeobj;
TY29703 freesmallchunks;
Llchunk29682* llmem;
NI currmem;
NI maxmem;
NI freemem;
NI lastsize;
Bigchunk29642* freechunkslist;
Intset29614 chunkstarts;
Avlnode29686* root;
Avlnode29686* deleted;
Avlnode29686* last;
Avlnode29686* freeavlnodes;
};
struct  Gcstat49814  {
NI stackscans;
NI cyclecollections;
NI maxthreshold;
NI maxstacksize;
NI maxstackcells;
NI cycletablesize;
NI64 maxpause;
};
struct  Gcheap49818  {
Gcstack49816* stack;
void* stackbottom;
NI cyclethreshold;
Cellseq47521 zct;
Cellseq47521 decstack;
Cellset47517 cycleroots;
Cellseq47521 tempstack;
NI recgclock;
Memregion29688 region;
Gcstat49814 stat;
};
struct  Slice88080  {
NI a;
NI b;
};
typedef Tnode214790* TY382939[2];
typedef NI TY29619[8];
struct  Trunk211031  {
Trunk211031* next;
NI key;
TY29619 bits;
};
struct Keyvaluepair380262 {
NI Field0;
NI Field1;
Ttype214828* Field2;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  Tscope214816  {
NI depthlevel;
Tstrtable214794 symbols;
Tnodeseq214784* usingsyms;
Tscope214816* parent;
};
struct  Ropeobj169006  {
  TNimObject Sup;
Ropeobj169006* left;
Ropeobj169006* right;
NI length;
NimStringDesc* data;
};
struct  Tlistentry135010  {
  TNimObject Sup;
Tlistentry135010* prev;
Tlistentry135010* next;
};
struct  Tlib214808  {
  Tlistentry135010 Sup;
NU8 kind;
NIM_BOOL generated;
NIM_BOOL isoverriden;
Ropeobj169006* name;
Tnode214790* path;
};
struct Keyvaluepair381063 {
NI Field0;
NI Field1;
Tnode214790* Field2;
};
struct  Gcstack49816  {
Gcstack49816* prev;
Gcstack49816* next;
void* starts;
void* pos;
NI maxstacksize;
};
struct  Pagedesc47513  {
Pagedesc47513* next;
NI key;
TY29619 bits;
};
struct  Basechunk29638  {
NI prevsize;
NI size;
NIM_BOOL used;
};
struct  Smallchunk29640  {
  Basechunk29638 Sup;
Smallchunk29640* next;
Smallchunk29640* prev;
Freecell29630* freelist;
NI free;
NI acc;
NF data;
};
struct  Llchunk29682  {
NI size;
NI acc;
Llchunk29682* next;
};
struct  Bigchunk29642  {
  Basechunk29638 Sup;
Bigchunk29642* next;
Bigchunk29642* prev;
NI align;
NF data;
};
struct  Trunk29610  {
Trunk29610* next;
NI key;
TY29619 bits;
};
typedef Avlnode29686* TY29693[2];
struct  Avlnode29686  {
TY29693 link;
NI key;
NI upperbound;
NI level;
};
struct  Tinstantiation214812  {
Tsym214822* sym;
Ttypeseq214824* concretetypes;
TY214913* usedby;
NI compilesid;
};
struct  Freecell29630  {
Freecell29630* next;
NI zerofield;
};
struct Trunkseq211033 {
  TGenericSeq Sup;
  Trunk211031* data[SEQ_DECL_SIZE];
};
struct Keyvaluepairseq380259 {
  TGenericSeq Sup;
  Keyvaluepair380262 data[SEQ_DECL_SIZE];
};
struct Ttypeseq214824 {
  TGenericSeq Sup;
  Ttype214828* data[SEQ_DECL_SIZE];
};
struct TY214925 {
  TGenericSeq Sup;
  Tinstantiation214812* data[SEQ_DECL_SIZE];
};
struct Tsymseq214792 {
  TGenericSeq Sup;
  Tsym214822* data[SEQ_DECL_SIZE];
};
struct Keyvaluepairseq381060 {
  TGenericSeq Sup;
  Keyvaluepair381063 data[SEQ_DECL_SIZE];
};
struct Tnodeseq214784 {
  TGenericSeq Sup;
  Tnode214790* data[SEQ_DECL_SIZE];
};
struct TY214913 {
  TGenericSeq Sup;
  NI32 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, initdetectionpass_380276)(Tsym214822* fn, Detectionpass380248* Result);
N_NIMCALL(void, initintset_211885)(Intset211035* Result);
N_NIMCALL(void, inittable_380281)(NI initialsize, Table380256* Result);
N_NIMCALL(void, incl_211832)(Intset211035* s, NI key);
N_NOINLINE(void, chckNil)(void* p);
N_NIMCALL(void, initliftingpass_381076)(Tsym214822* fn, Liftingpass381050* Result);
N_NIMCALL(void, inittable_381083)(NI initialsize, Table381057* Result);
N_NIMCALL(void, HEX5BHEX5DHEX3D_380464)(Table380256* t, NI key, Ttype214828* val);
N_NIMCALL(void, detectcapturedvars_380760)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* c);
N_NIMCALL(void, addclosureparam_380695)(Detectionpass380248* c, Tsym214822* fn);
N_NIMCALL(Tsym214822*, getenvparam_379603)(Tsym214822* routine);
N_NIMCALL(Tnode214790*, lastson_217364)(Tnode214790* n);
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(Tsym214822*, skipgenericowner_219353)(Tsym214822* s);
N_NIMCALL(Ttype214828*, getenvtypeforowner_380413)(Detectionpass380248* c, Tsym214822* owner);
N_NIMCALL(Ttype214828*, getordefault_380421)(Table380256 t, NI key);
N_NIMCALL(Ttype214828*, newtype_217107)(NU8 kind, Tsym214822* owner);
N_NIMCALL(Ttype214828*, createenvobj_379033)(Tsym214822* owner);
N_NIMCALL(Ttype214828*, createobj_376328)(Tsym214822* owner, Tlineinfo182337 info);
N_NIMCALL(void, rawaddfield_376343)(Ttype214828* obj, Tsym214822* field);
N_NIMCALL(Tsym214822*, createstatefield_379027)(Tsym214822* iter);
N_NIMCALL(Tsym214822*, newsym_215683)(NU8 symkind, Tident189012* name, Tsym214822* owner, Tlineinfo182337 info);
N_NIMCALL(Tident189012*, getident_189441)(NimStringDesc* identifier);
N_NIMCALL(Ttype214828*, createstatetype_379012)(Tsym214822* iter);
N_NIMCALL(Tnode214790*, newnodei_216248)(NU8 kind, Tlineinfo182337 info);
N_NIMCALL(void, addson_216807)(Tnode214790* father, Tnode214790* son);
N_NIMCALL(Tnode214790*, newintnode_215659)(NU8 kind, NI64 intval);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(Cell47505*, usrtocell_51440)(void* usr);
static N_INLINE(void, rtladdzct_53001)(Cell47505* c);
N_NOINLINE(void, addzct_51417)(Cellseq47521* s, Cell47505* c);
N_NIMCALL(Ttype214828*, nilorsysint_258018)(void);
N_NIMCALL(void, rawaddson_218408)(Ttype214828* father, Ttype214828* son);
N_NIMCALL(void, addhiddenparam_379063)(Tsym214822* routine, Tsym214822* param);
static N_INLINE(NI, len_215059)(Tnode214790* n);
N_NIMCALL(Tnode214790*, newsymnode_216234)(Tsym214822* sym);
N_NIMCALL(void, localerror_187085)(Tlineinfo182337 info, NimStringDesc* arg);
N_NIMCALL(NIM_BOOL, isinnerproc_379852)(Tsym214822* s);
N_NIMCALL(NIM_BOOL, containsorincl_211862)(Intset211035* s, NI key);
N_NIMCALL(Tnode214790*, getbody_254827)(Tsym214822* s);
static N_INLINE(NIM_BOOL, interestingitervar_379928)(Tsym214822* s);
N_NIMCALL(Ttype214828*, lastson_217377)(Ttype214828* n);
N_NIMCALL(Tsym214822*, gethiddenparam_379401)(Tsym214822* routine);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(void, addfield_376603)(Ttype214828* obj, Tsym214822* s);
static N_INLINE(NIM_BOOL, interestingvar_379801)(Tsym214822* s);
N_NIMCALL(void, markasclosure_380216)(Tsym214822* owner, Tnode214790* n);
static N_INLINE(NIM_BOOL, illegalcapture_379827)(Tsym214822* s);
N_NIMCALL(Ttype214828*, skiptypes_218113)(Ttype214828* t, NU64 kinds);
N_NIMCALL(void, localerror_187080)(Tlineinfo182337 info, NU16 msg, NimStringDesc* arg);
N_NIMCALL(void, createupfield_380644)(Detectionpass380248* c, Tsym214822* dest, Tsym214822* dep);
N_NIMCALL(Tsym214822*, lookupinrecord_221140)(Tnode214790* n, Tident189012* field);
static N_INLINE(Tnode214790*, HEX5BHEX5D_215238)(Tnode214790* n, NI i);
static N_INLINE(Slice88080, HEX2EHEX2E_102424)(NI a, NI b);
N_NIMCALL(Tnode214790*, wrapiterbody_382656)(Tnode214790* n, Tsym214822* owner);
N_NIMCALL(void, add_215114)(Tnode214790* father, Tnode214790* son);
N_NIMCALL(Tnode214790*, rawindirectaccess_376402)(Tnode214790* a, Tsym214822* field, Tlineinfo182337 info);
N_NIMCALL(Tsym214822*, getstatefield_382159)(Tsym214822* owner);
N_NIMCALL(Tnode214790*, newinttypenode_215665)(NU8 kind, NI64 intval, Ttype214828* typ);
N_NIMCALL(Ttype214828*, getsystype_258130)(NU8 kind);
N_NIMCALL(Tnode214790*, liftcapturedvars_382166)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(Tnode214790*, getordefault_381631)(Table381057 t, NI key);
N_NIMCALL(Tnode214790*, newtree_215601)(NU8 kind, Tnode214790** children, NI childrenLen0);
N_NIMCALL(Tnode214790*, rawclosurecreation_381918)(Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(Tnode214790*, setupenvvar_381601)(Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(Tnode214790*, newenvvar_381429)(Tsym214822* owner, Ttype214828* typ);
N_NIMCALL(void, HEX5BHEX5DHEX3D_381696)(Table381057* t, NI key, Tnode214790* val);
N_NIMCALL(void, addvar_376017)(Tnode214790* father, Tnode214790* v);
N_NIMCALL(Tnode214790*, newcall_379004)(Tsym214822* a, Tnode214790* b);
N_NIMCALL(Tsym214822*, getsyssym_258041)(NimStringDesc* name);
N_NIMCALL(NIM_BOOL, contains_211811)(Intset211035* s, NI key);
N_NIMCALL(Tnode214790*, indirectaccess_377826)(Tnode214790* a, Tsym214822* b, Tlineinfo182337 info);
N_NIMCALL(Tnode214790*, newasgnstmt_379888)(Tnode214790* le, Tnode214790* ri, Tlineinfo182337 info);
N_NIMCALL(Tnode214790*, newnodei_216401)(NU8 kind, Tlineinfo182337 info, NI children);
N_NIMCALL(Tnode214790*, getupviaparam_381876)(Tsym214822* owner);
N_NIMCALL(Tnode214790*, symtoclosure_382815)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(Tnode214790*, makeclosure_379896)(Tsym214822* prc, Tnode214790* env, Tlineinfo182337 info);
N_NIMCALL(Tnode214790*, newnodeit_216801)(NU8 kind, Tlineinfo182337 info, Ttype214828* typ);
N_NIMCALL(Tnode214790*, skipconv_249082)(Tnode214790* n);
N_NIMCALL(Tnode214790*, closurecreationforiter_382049)(Tnode214790* iter, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(void, adduniquefield_376802)(Ttype214828* obj, Tsym214822* s);
N_NIMCALL(Tnode214790*, accessviaenvparam_381211)(Tnode214790* n, Tsym214822* owner);
N_NIMCALL(Tsym214822*, getfieldfromobj_377447)(Ttype214828* t_377449, Tsym214822* v);
N_NIMCALL(Tnode214790*, accessviaenvvar_382135)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(Tnode214790*, transformyield_382173)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(Tsym214822*, getiterresult_379038)(Tsym214822* iter);
N_NIMCALL(Tnode214790*, transformreturn_382642)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c);
N_NIMCALL(NIM_BOOL, isgenericroutine_219315)(Tsym214822* s);
STRING_LITERAL(TMP1128, ":envP", 5);
STRING_LITERAL(TMP1129, ":state", 6);
STRING_LITERAL(TMP1130, "internal error: inconsistent environment type", 45);
STRING_LITERAL(TMP1131, "internal error: could not find env param for ", 45);
STRING_LITERAL(TMP1132, "internal error: invalid up reference computed", 45);
STRING_LITERAL(TMP1133, ":up", 3);
STRING_LITERAL(TMP1137, "internal error: up references do not agree", 42);
STRING_LITERAL(TMP1138, "internal error: could not determine closure type", 48);
STRING_LITERAL(TMP1139, ":env", 4);
STRING_LITERAL(TMP1140, "internalNew", 11);
STRING_LITERAL(TMP1144, "could not find up reference for closure iter", 44);
STRING_LITERAL(TMP1145, "internal error: cannot create up reference", 42);
STRING_LITERAL(TMP1146, "internal error: taking closure of closure", 41);
STRING_LITERAL(TMP1147, "internal error: cannot create up reference for iter", 51);
STRING_LITERAL(TMP1148, "internal error: no environment found", 36);
STRING_LITERAL(TMP1149, "internal error: environment misses: ", 36);
STRING_LITERAL(TMP1150, "internal error: not part of closure object type", 47);
STRING_LITERAL(TMP1151, ":result", 7);
STRING_LITERAL(TMP3439, "ignored invalid for loop", 24);
STRING_LITERAL(TMP3440, "internal error: cannot generate fresh variable", 46);
extern Gcheap49818 gch_49859;
extern Tnode214790* emptynode_215801;
extern NU8 gcmd_160123;

N_NIMCALL(void, initdetectionpass_380276)(Tsym214822* fn, Detectionpass380248* Result) {
	initintset_211885((&(*Result).processed));
	initintset_211885((&(*Result).capturedvars));
	inittable_380281(((NI) 64), (&(*Result).ownertotype));
	incl_211832((&(*Result).processed), (*fn).Sup.id);
}

N_NIMCALL(void, initliftingpass_381076)(Tsym214822* fn, Liftingpass381050* Result) {
	initintset_211885((&(*Result).processed));
	incl_211832((&(*Result).processed), (*fn).Sup.id);
	inittable_381083(((NI) 64), (&(*Result).envvars));
}

static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b) {
	NIM_BOOL result;
	NIM_BOOL LOC11;
	int LOC13;
{	result = 0;
	{
		if (!(a == b)) goto LA3;
		result = NIM_TRUE;
		goto BeforeRet;
	}
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = (a == NIM_NIL);
		if (LOC7) goto LA8;
		LOC7 = (b == NIM_NIL);
		LA8: ;
		if (!LOC7) goto LA9;
		result = NIM_FALSE;
		goto BeforeRet;
	}
	LA9: ;
	LOC11 = 0;
	LOC11 = ((*a).Sup.len == (*b).Sup.len);
	if (!(LOC11)) goto LA12;
	LOC13 = 0;
	LOC13 = memcmp(((NCSTRING) ((*a).data)), ((NCSTRING) ((*b).data)), (*a).Sup.len);
	LOC11 = (LOC13 == ((NI32) 0));
	LA12: ;
	result = LOC11;
	goto BeforeRet;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tsym214822*, getenvparam_379603)(Tsym214822* routine) {
	Tsym214822* result;
	Tnode214790* params;
	Tnode214790* hidden;
	result = 0;
	params = (*(*routine).ast).kindU.S6.sons->data[((NI) 3)];
	hidden = lastson_217364(params);
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = ((*hidden).kind == ((NU8) 3));
		if (!(LOC3)) goto LA4;
		LOC3 = eqStrings((*(*(*hidden).kindU.S4.sym).name).s, ((NimStringDesc*) &TMP1128));
		LA4: ;
		if (!LOC3) goto LA5;
		result = (*hidden).kindU.S4.sym;
	}
	LA5: ;
	return result;
}

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

static N_INLINE(void, rtladdzct_53001)(Cell47505* c) {
	addzct_51417((&gch_49859.zct), c);
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Cell47505* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_51440(src);
		(*c).refcount += ((NI) 8);
	}
	LA3: ;
	{
		Cell47505* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_51440((*dest));
		{
			(*c).refcount -= ((NI) 8);
			if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA11;
			rtladdzct_53001(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

N_NIMCALL(Ttype214828*, createstatetype_379012)(Tsym214822* iter) {
	Ttype214828* result;
	Tnode214790* n;
	Tnode214790* LOC1;
	Tnode214790* LOC2;
	Ttype214828* inttype;
	result = 0;
	n = newnodei_216248(((NU8) 44), (*iter).info);
	LOC1 = 0;
	LOC1 = newintnode_215659(((NU8) 6), IL64(-1));
	addson_216807(n, LOC1);
	LOC2 = 0;
	LOC2 = newintnode_215659(((NU8) 6), IL64(0));
	addson_216807(n, LOC2);
	result = newtype_217107(((NU8) 20), iter);
	asgnRefNoCycle((void**) (&(*result).n), n);
	inttype = nilorsysint_258018();
	{
		if (!inttype == 0) goto LA5;
		inttype = newtype_217107(((NU8) 31), iter);
	}
	LA5: ;
	rawaddson_218408(result, inttype);
	return result;
}

N_NIMCALL(Tsym214822*, createstatefield_379027)(Tsym214822* iter) {
	Tsym214822* result;
	Tident189012* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = getident_189441(((NimStringDesc*) &TMP1129));
	result = newsym_215683(((NU8) 18), LOC1, iter, (*iter).info);
	asgnRefNoCycle((void**) (&(*result).typ), createstatetype_379012(iter));
	return result;
}

N_NIMCALL(Ttype214828*, createenvobj_379033)(Tsym214822* owner) {
	Ttype214828* result;
	Tsym214822* LOC1;
	result = 0;
	result = createobj_376328(owner, (*owner).info);
	LOC1 = 0;
	LOC1 = createstatefield_379027(owner);
	rawaddfield_376343(result, LOC1);
	return result;
}

N_NIMCALL(Ttype214828*, getenvtypeforowner_380413)(Detectionpass380248* c, Tsym214822* owner) {
	Ttype214828* result;
	result = 0;
	result = getordefault_380421((*c).ownertotype, (*owner).Sup.id);
	{
		Ttype214828* obj;
		if (!result == 0) goto LA3;
		result = newtype_217107(((NU8) 22), owner);
		obj = createenvobj_379033(owner);
		rawaddson_218408(result, obj);
		HEX5BHEX5DHEX3D_380464((&(*c).ownertotype), (*owner).Sup.id, result);
	}
	LA3: ;
	return result;
}

static N_INLINE(NI, len_215059)(Tnode214790* 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;
}

N_NIMCALL(void, addhiddenparam_379063)(Tsym214822* routine, Tsym214822* param) {
	Tnode214790* params;
	NI LOC1;
	Tnode214790* LOC2;
	params = (*(*routine).ast).kindU.S6.sons->data[((NI) 3)];
	LOC1 = 0;
	LOC1 = len_215059((*(*routine).typ).n);
	(*param).position = (NI)(LOC1 - ((NI) 1));
	LOC2 = 0;
	LOC2 = newsymnode_216234(param);
	addson_216807(params, LOC2);
}

N_NIMCALL(void, addclosureparam_380695)(Detectionpass380248* c, Tsym214822* fn) {
	Tsym214822* cp;
	Tsym214822* owner;
	Ttype214828* t;
	cp = getenvparam_379603(fn);
	{
		if (!((*fn).kind == ((NU8) 14))) goto LA3;
		owner = fn;
	}
	goto LA1;
	LA3: ;
	{
		owner = skipgenericowner_219353(fn);
	}
	LA1: ;
	t = getenvtypeforowner_380413(c, owner);
	{
		Tident189012* LOC10;
		if (!(cp == NIM_NIL)) goto LA8;
		LOC10 = 0;
		LOC10 = getident_189441(((NimStringDesc*) &TMP1128));
		cp = newsym_215683(((NU8) 3), LOC10, fn, (*fn).info);
		(*cp).flags |= ((NU32)1)<<((((NU8) 2))%(sizeof(NU32)*8));
		asgnRefNoCycle((void**) (&(*cp).typ), t);
		addhiddenparam_379063(fn, cp);
	}
	goto LA6;
	LA8: ;
	{
		NIM_BOOL LOC12;
		LOC12 = 0;
		LOC12 = !(((*cp).typ == t));
		if (!(LOC12)) goto LA13;
		LOC12 = !(((*fn).kind == ((NU8) 14)));
		LA13: ;
		if (!LOC12) goto LA14;
		localerror_187085((*fn).info, ((NimStringDesc*) &TMP1130));
	}
	goto LA6;
	LA14: ;
	LA6: ;
}

N_NIMCALL(NIM_BOOL, isinnerproc_379852)(Tsym214822* s) {
	NIM_BOOL result;
	result = 0;
	{
		NIM_BOOL LOC3;
		Tsym214822* LOC7;
		LOC3 = 0;
		LOC3 = ((61440 &(1U<<((NU)((*s).kind)&31U)))!=0);
		if (!(LOC3)) goto LA4;
		LOC3 = ((*s).magic == ((NU8) 0));
		LA4: ;
		if (!LOC3) goto LA5;
		LOC7 = 0;
		LOC7 = skipgenericowner_219353(s);
		result = ((258048 &(1U<<((NU)((*LOC7).kind)&31U)))!=0);
	}
	LA5: ;
	return result;
}

static N_INLINE(NIM_BOOL, interestingitervar_379928)(Tsym214822* s) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = ((1049376 &(1U<<((NU)((*s).kind)&31U)))!=0);
	if (!(LOC1)) goto LA2;
	LOC1 = !((((*s).flags &(1U<<((NU)(((NU8) 3))&31U)))!=0));
	LA2: ;
	result = LOC1;
	return result;
}

static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	memcpy(((NCSTRING) ((&(*dest).data[((*dest).Sup.len)- 0]))), ((NCSTRING) ((*src).data)), (NI)((*src).Sup.len + ((NI) 1)));
	(*dest).Sup.len += (*src).Sup.len;
}

N_NIMCALL(Tsym214822*, gethiddenparam_379401)(Tsym214822* routine) {
	Tsym214822* result;
	Tnode214790* params;
	Tnode214790* hidden;
	result = 0;
	params = (*(*routine).ast).kindU.S6.sons->data[((NI) 3)];
	hidden = lastson_217364(params);
	{
		NIM_BOOL LOC3;
		NIM_BOOL LOC4;
		LOC3 = 0;
		LOC4 = 0;
		LOC4 = ((*hidden).kind == ((NU8) 3));
		if (!(LOC4)) goto LA5;
		LOC4 = ((*(*hidden).kindU.S4.sym).kind == ((NU8) 3));
		LA5: ;
		LOC3 = LOC4;
		if (!(LOC3)) goto LA6;
		LOC3 = eqStrings((*(*(*hidden).kindU.S4.sym).name).s, ((NimStringDesc*) &TMP1128));
		LA6: ;
		if (!LOC3) goto LA7;
		result = (*hidden).kindU.S4.sym;
	}
	goto LA1;
	LA7: ;
	{
		NimStringDesc* LOC10;
		LOC10 = 0;
		LOC10 = rawNewString((*(*routine).name).s->Sup.len + 45);
appendString(LOC10, ((NimStringDesc*) &TMP1131));
appendString(LOC10, (*(*routine).name).s);
		localerror_187085((*routine).info, LOC10);
		result = routine;
	}
	LA1: ;
	return result;
}

static N_INLINE(NIM_BOOL, interestingvar_379801)(Tsym214822* s) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = ((1051432 &(1U<<((NU)((*s).kind)&31U)))!=0);
	if (!(LOC1)) goto LA2;
	LOC1 = !((((*s).flags &(1U<<((NU)(((NU8) 3))&31U)))!=0));
	LA2: ;
	result = LOC1;
	return result;
}

static N_INLINE(NIM_BOOL, illegalcapture_379827)(Tsym214822* s) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	Ttype214828* LOC2;
	result = 0;
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = skiptypes_218113((*s).typ, IL64(211106232576256));
	LOC1 = ((IL64(281475119316992) &((NU64)1<<((NU)((*LOC2).kind)&63U)))!=0);
	if (LOC1) goto LA3;
	LOC1 = ((*s).kind == ((NU8) 11));
	LA3: ;
	result = LOC1;
	return result;
}

N_NIMCALL(void, markasclosure_380216)(Tsym214822* owner, Tnode214790* n) {
	Tsym214822* s;
	s = (*n).kindU.S4.sym;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = illegalcapture_379827(s);
		if (LOC3) goto LA4;
		LOC3 = !(((257 &(1U<<((NU)((*(*owner).typ).callconv)&15U)))!=0));
		LA4: ;
		if (!LOC3) goto LA5;
		localerror_187080((*n).info, ((NU16) 227), (*(*s).name).s);
	}
	LA5: ;
	(*(*owner).typ).flags |= ((NU32)1)<<((((NU8) 11))%(sizeof(NU32)*8));
	(*(*owner).typ).callconv = ((NU8) 8);
}

N_NIMCALL(void, createupfield_380644)(Detectionpass380248* c, Tsym214822* dest, Tsym214822* dep) {
	Ttype214828* refobj;
	Ttype214828* obj;
	Ttype214828* fieldtype;
	Tident189012* upident;
	Tsym214822* upfield;
	refobj = getenvtypeforowner_380413(c, dest);
	obj = lastson_217377(refobj);
	fieldtype = getenvtypeforowner_380413(c, dep);
	{
		if (!(refobj == fieldtype)) goto LA3;
		localerror_187085((*dep).info, ((NimStringDesc*) &TMP1132));
	}
	LA3: ;
	upident = getident_189441(((NimStringDesc*) &TMP1133));
	upfield = lookupinrecord_221140((*obj).n, upident);
	{
		if (!!((upfield == NIM_NIL))) goto LA7;
		{
			if (!!(((*upfield).typ == fieldtype))) goto LA11;
			localerror_187085((*dep).info, ((NimStringDesc*) &TMP1137));
		}
		LA11: ;
	}
	goto LA5;
	LA7: ;
	{
		Tsym214822* result;
		result = newsym_215683(((NU8) 18), upident, (*obj).owner, (*(*obj).owner).info);
		asgnRefNoCycle((void**) (&(*result).typ), fieldtype);
		rawaddfield_376343(obj, result);
	}
	LA5: ;
}

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

static N_INLINE(Slice88080, HEX2EHEX2E_102424)(NI a, NI b) {
	Slice88080 result;
	memset((void*)(&result), 0, sizeof(result));
	result.a = a;
	result.b = b;
	return result;
}

N_NIMCALL(void, detectcapturedvars_380760)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* c) {
{	switch ((*n).kind) {
	case ((NU8) 3):
	{
		Tsym214822* s;
		NIM_BOOL innerproc;
		Tsym214822* ow;
		s = (*n).kindU.S4.sym;
		{
			NIM_BOOL LOC4;
			NIM_BOOL LOC5;
			LOC4 = 0;
			LOC5 = 0;
			LOC5 = ((61440 &(1U<<((NU)((*s).kind)&31U)))!=0);
			if (!(LOC5)) goto LA6;
			LOC5 = !(((*s).typ == NIM_NIL));
			LA6: ;
			LOC4 = LOC5;
			if (!(LOC4)) goto LA7;
			LOC4 = ((*(*s).typ).callconv == ((NU8) 8));
			LA7: ;
			if (!LOC4) goto LA8;
			addclosureparam_380695(c, s);
			(*c).somethingtodo = NIM_TRUE;
		}
		LA8: ;
		innerproc = isinnerproc_379852(s);
		{
			if (!innerproc) goto LA12;
			{
				NIM_BOOL LOC16;
				LOC16 = 0;
				LOC16 = ((*s).kind == ((NU8) 14));
				if (!(LOC16)) goto LA17;
				LOC16 = ((*(*s).typ).callconv == ((NU8) 8));
				LA17: ;
				if (!LOC16) goto LA18;
				(*c).somethingtodo = NIM_TRUE;
			}
			LA18: ;
			{
				NIM_BOOL LOC22;
				Tnode214790* LOC25;
				LOC22 = 0;
				LOC22 = containsorincl_211862((&(*c).processed), (*s).Sup.id);
				if (!!(LOC22)) goto LA23;
				LOC25 = 0;
				LOC25 = getbody_254827(s);
				detectcapturedvars_380760(LOC25, s, c);
			}
			LA23: ;
		}
		LA12: ;
		ow = skipgenericowner_219353(s);
		{
			if (!(ow == owner)) goto LA28;
			{
				NIM_BOOL LOC32;
				LOC32 = 0;
				LOC32 = ((*owner).kind == ((NU8) 14));
				if (!(LOC32)) goto LA33;
				LOC32 = ((*(*owner).typ).callconv == ((NU8) 8));
				LA33: ;
				if (!LOC32) goto LA34;
				(*c).somethingtodo = NIM_TRUE;
				addclosureparam_380695(c, owner);
				{
					NIM_BOOL LOC38;
					LOC38 = 0;
					LOC38 = interestingitervar_379928(s);
					if (!LOC38) goto LA39;
					{
						NIM_BOOL LOC43;
						Ttype214828* obj;
						Tsym214822* LOC46;
						LOC43 = 0;
						LOC43 = containsorincl_211862((&(*c).capturedvars), (*s).Sup.id);
						if (!!(LOC43)) goto LA44;
						LOC46 = 0;
						LOC46 = gethiddenparam_379401(owner);
						obj = lastson_217377((*LOC46).typ);
						addfield_376603(obj, s);
					}
					LA44: ;
				}
				LA39: ;
			}
			LA34: ;
			goto BeforeRet;
		}
		LA28: ;
		{
			NIM_BOOL LOC49;
			NIM_BOOL LOC50;
			Tsym214822* w;
			LOC49 = 0;
			LOC50 = 0;
			LOC50 = innerproc;
			if (!(LOC50)) goto LA51;
			LOC50 = ((*(*s).typ).callconv == ((NU8) 8));
			LA51: ;
			LOC49 = LOC50;
			if (LOC49) goto LA52;
			LOC49 = interestingvar_379801(s);
			LA52: ;
			if (!LOC49) goto LA53;
			(*c).somethingtodo = NIM_TRUE;
			markasclosure_380216(owner, n);
			addclosureparam_380695(c, owner);
			{
				NIM_BOOL LOC57;
				NIM_BOOL LOC59;
				Ttype214828* obj;
				Ttype214828* LOC62;
				LOC57 = 0;
				LOC57 = interestingvar_379801(s);
				if (!(LOC57)) goto LA58;
				LOC59 = 0;
				LOC59 = containsorincl_211862((&(*c).capturedvars), (*s).Sup.id);
				LOC57 = !(LOC59);
				LA58: ;
				if (!LOC57) goto LA60;
				LOC62 = 0;
				LOC62 = getenvtypeforowner_380413(c, ow);
				obj = lastson_217377(LOC62);
				addfield_376603(obj, s);
			}
			LA60: ;
			w = skipgenericowner_219353(owner);
			{
				NIM_BOOL LOC65;
				NIM_BOOL LOC67;
				Tsym214822* last;
				LOC65 = 0;
				LOC65 = isinnerproc_379852(w);
				if (LOC65) goto LA66;
				LOC67 = 0;
				LOC67 = ((*owner).kind == ((NU8) 14));
				if (!(LOC67)) goto LA68;
				LOC67 = ((*(*owner).typ).callconv == ((NU8) 8));
				LA68: ;
				LOC65 = LOC67;
				LA66: ;
				if (!LOC65) goto LA69;
				{
					NIM_BOOL LOC73;
					LOC73 = 0;
					LOC73 = ((*owner).kind == ((NU8) 14));
					if (!(LOC73)) goto LA74;
					LOC73 = ((*(*owner).typ).callconv == ((NU8) 8));
					LA74: ;
					if (!LOC73) goto LA75;
					w = owner;
				}
				LA75: ;
				{
					NIM_BOOL LOC79;
					LOC79 = 0;
					LOC79 = ((*ow).kind == ((NU8) 14));
					if (!(LOC79)) goto LA80;
					LOC79 = ((*(*ow).typ).callconv == ((NU8) 8));
					LA80: ;
					if (!LOC79) goto LA81;
					last = skipgenericowner_219353(ow);
				}
				goto LA77;
				LA81: ;
				{
					last = ow;
				}
				LA77: ;
				{
					while (1) {
						NIM_BOOL LOC86;
						NIM_BOOL LOC87;
						Tsym214822* up;
						LOC86 = 0;
						LOC87 = 0;
						LOC87 = !((w == NIM_NIL));
						if (!(LOC87)) goto LA88;
						LOC87 = !(((*w).kind == ((NU8) 6)));
						LA88: ;
						LOC86 = LOC87;
						if (!(LOC86)) goto LA89;
						LOC86 = !((last == w));
						LA89: ;
						if (!LOC86) goto LA85;
						up = skipgenericowner_219353(w);
						markasclosure_380216(w, n);
						addclosureparam_380695(c, w);
						createupfield_380644(c, w, up);
						w = up;
					} LA85: ;
				}
			}
			LA69: ;
		}
		LA53: ;
	}
	break;
	case ((NU8) 1) ... ((NU8) 2):
	case ((NU8) 4) ... ((NU8) 23):
	case ((NU8) 83):
	case ((NU8) 98):
	{
	}
	break;
	case ((NU8) 79):
	case ((NU8) 80):
	case ((NU8) 81):
	case ((NU8) 82):
	{
	}
	break;
	case ((NU8) 51):
	case ((NU8) 84):
	case ((NU8) 52):
	{
		{
			Tnode214790* LOC97;
			if (!!(((*n).typ == NIM_NIL))) goto LA95;
			LOC97 = 0;
			LOC97 = HEX5BHEX5D_215238(n, ((NI) 0));
			detectcapturedvars_380760(LOC97, owner, c);
		}
		LA95: ;
	}
	break;
	default:
	{
		{
			NI i_381032;
			Slice88080 HEX3Atmp_381035;
			NI LOC100;
			i_381032 = 0;
			memset((void*)(&HEX3Atmp_381035), 0, sizeof(HEX3Atmp_381035));
			LOC100 = 0;
			LOC100 = len_215059(n);
			HEX3Atmp_381035 = HEX2EHEX2E_102424(((NI) 0), (LOC100 - 1));
			{
				NI x_381039;
				NI HEX3Atmp_381041;
				NI HEX3Atmp_381043;
				NI res_381045;
				x_381039 = 0;
				HEX3Atmp_381041 = 0;
				HEX3Atmp_381043 = 0;
				HEX3Atmp_381041 = HEX3Atmp_381035.a;
				HEX3Atmp_381043 = HEX3Atmp_381035.b;
				res_381045 = HEX3Atmp_381041;
				{
					while (1) {
						Tnode214790* LOC104;
						if (!(res_381045 <= HEX3Atmp_381043)) goto LA103;
						x_381039 = res_381045;
						i_381032 = x_381039;
						LOC104 = 0;
						LOC104 = HEX5BHEX5D_215238(n, i_381032);
						detectcapturedvars_380760(LOC104, owner, c);
						res_381045 += ((NI) 1);
					} LA103: ;
				}
			}
		}
	}
	break;
	}
	}BeforeRet: ;
}

N_NIMCALL(Tsym214822*, getstatefield_382159)(Tsym214822* owner) {
	Tsym214822* result;
	Tsym214822* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = gethiddenparam_379401(owner);
	result = (*(*(*(*(*LOC1).typ).sons->data[((NI) 0)]).n).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym;
	return result;
}

N_NIMCALL(Tnode214790*, wrapiterbody_382656)(Tnode214790* n, Tsym214822* owner) {
	Tnode214790* result;
	Tlineinfo182337 info;
	Tnode214790* gs;
	Tsym214822* LOC7;
	Tnode214790* LOC8;
	Tsym214822* LOC9;
	Tnode214790* LOC10;
	Tnode214790* state0;
	Tnode214790* LOC11;
	Tnode214790* stateasgnstmt;
	Tsym214822* LOC12;
	Tnode214790* LOC13;
	Tsym214822* LOC14;
	Tnode214790* LOC15;
	Ttype214828* LOC16;
	Tnode214790* LOC17;
{	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = ((*owner).kind == ((NU8) 14));
		if (!(LOC3)) goto LA4;
		LOC3 = ((*(*owner).typ).callconv == ((NU8) 8));
		LA4: ;
		if (!!(LOC3)) goto LA5;
		result = n;
		goto BeforeRet;
	}
	LA5: ;
	info = (*n).info;
	result = newnodei_216248(((NU8) 115), info);
	gs = newnodei_216248(((NU8) 156), info);
	LOC7 = 0;
	LOC7 = gethiddenparam_379401(owner);
	LOC8 = 0;
	LOC8 = newsymnode_216234(LOC7);
	LOC9 = 0;
	LOC9 = getstatefield_382159(owner);
	LOC10 = 0;
	LOC10 = rawindirectaccess_376402(LOC8, LOC9, info);
	add_215114(gs, LOC10);
	add_215114(result, gs);
	state0 = newnodei_216248(((NU8) 157), info);
	LOC11 = 0;
	LOC11 = newintnode_215659(((NU8) 6), IL64(0));
	add_215114(state0, LOC11);
	add_215114(result, state0);
	add_215114(result, n);
	stateasgnstmt = newnodei_216248(((NU8) 73), info);
	LOC12 = 0;
	LOC12 = gethiddenparam_379401(owner);
	LOC13 = 0;
	LOC13 = newsymnode_216234(LOC12);
	LOC14 = 0;
	LOC14 = getstatefield_382159(owner);
	LOC15 = 0;
	LOC15 = rawindirectaccess_376402(LOC13, LOC14, info);
	add_215114(stateasgnstmt, LOC15);
	LOC16 = 0;
	LOC16 = getsystype_258130(((NU8) 31));
	LOC17 = 0;
	LOC17 = newinttypenode_215665(((NU8) 6), IL64(-1), LOC16);
	add_215114(stateasgnstmt, LOC17);
	add_215114(result, stateasgnstmt);
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tnode214790*, newenvvar_381429)(Tsym214822* owner, Ttype214828* typ) {
	Tnode214790* result;
	Tsym214822* v;
	Tident189012* LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = getident_189441(((NimStringDesc*) &TMP1139));
	v = newsym_215683(((NU8) 8), LOC1, owner, (*owner).info);
	(*v).flags |= ((NU32)1)<<((((NU8) 21))%(sizeof(NU32)*8));
	asgnRefNoCycle((void**) (&(*v).typ), typ);
	result = newsymnode_216234(v);
	return result;
}

N_NIMCALL(Tnode214790*, setupenvvar_381601)(Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
{	result = 0;
	{
		NIM_BOOL LOC3;
		Tsym214822* LOC7;
		LOC3 = 0;
		LOC3 = ((*owner).kind == ((NU8) 14));
		if (!(LOC3)) goto LA4;
		LOC3 = ((*(*owner).typ).callconv == ((NU8) 8));
		LA4: ;
		if (!LOC3) goto LA5;
		LOC7 = 0;
		LOC7 = gethiddenparam_379401(owner);
		result = newsymnode_216234(LOC7);
		goto BeforeRet;
	}
	LA5: ;
	result = getordefault_381631((*c).envvars, (*owner).Sup.id);
	{
		Ttype214828* envvartype;
		if (!result == 0) goto LA10;
		envvartype = getordefault_380421((*d).ownertotype, (*owner).Sup.id);
		{
			if (!envvartype == 0) goto LA14;
			localerror_187085((*owner).info, ((NimStringDesc*) &TMP1138));
		}
		LA14: ;
		result = newenvvar_381429(owner, envvartype);
		HEX5BHEX5DHEX3D_381696((&(*c).envvars), (*owner).Sup.id, result);
	}
	LA10: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tnode214790*, newcall_379004)(Tsym214822* a, Tnode214790* b) {
	Tnode214790* result;
	Tnode214790* LOC1;
	result = 0;
	result = newnodei_216248(((NU8) 27), (*a).info);
	LOC1 = 0;
	LOC1 = newsymnode_216234(a);
	add_215114(result, LOC1);
	add_215114(result, b);
	return result;
}

N_NIMCALL(Tnode214790*, newasgnstmt_379888)(Tnode214790* le, Tnode214790* ri, Tlineinfo182337 info) {
	Tnode214790* result;
	result = 0;
	result = newnodei_216401(((NU8) 73), info, ((NI) 2));
	asgnRefNoCycle((void**) (&(*result).kindU.S6.sons->data[((NI) 0)]), le);
	asgnRefNoCycle((void**) (&(*result).kindU.S6.sons->data[((NI) 1)]), ri);
	return result;
}

N_NIMCALL(Tnode214790*, getupviaparam_381876)(Tsym214822* owner) {
	Tnode214790* result;
	Tsym214822* p;
	result = 0;
	p = gethiddenparam_379401(owner);
	result = newsymnode_216234(p);
	{
		NIM_BOOL LOC3;
		Tsym214822* upfield;
		Ttype214828* LOC7;
		Tident189012* LOC8;
		LOC3 = 0;
		LOC3 = ((*owner).kind == ((NU8) 14));
		if (!(LOC3)) goto LA4;
		LOC3 = ((*(*owner).typ).callconv == ((NU8) 8));
		LA4: ;
		if (!LOC3) goto LA5;
		LOC7 = 0;
		LOC7 = lastson_217377((*p).typ);
		LOC8 = 0;
		LOC8 = getident_189441(((NimStringDesc*) &TMP1133));
		upfield = lookupinrecord_221140((*LOC7).n, LOC8);
		{
			if (!(upfield == NIM_NIL)) goto LA11;
			localerror_187085((*owner).info, ((NimStringDesc*) &TMP1144));
		}
		goto LA9;
		LA11: ;
		{
			result = rawindirectaccess_376402(result, upfield, (*p).info);
		}
		LA9: ;
	}
	LA5: ;
	return result;
}

N_NIMCALL(Tnode214790*, rawclosurecreation_381918)(Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
	Tnode214790* env;
	Tsym214822* upfield;
	Ttype214828* LOC28;
	Tident189012* LOC29;
	result = 0;
	result = newnodei_216248(((NU8) 115), (*owner).info);
	env = 0;
	{
		NIM_BOOL LOC3;
		Tsym214822* LOC7;
		LOC3 = 0;
		LOC3 = ((*owner).kind == ((NU8) 14));
		if (!(LOC3)) goto LA4;
		LOC3 = ((*(*owner).typ).callconv == ((NU8) 8));
		LA4: ;
		if (!LOC3) goto LA5;
		LOC7 = 0;
		LOC7 = gethiddenparam_379401(owner);
		env = newsymnode_216234(LOC7);
	}
	goto LA1;
	LA5: ;
	{
		Tsym214822* LOC13;
		Tnode214790* LOC14;
		env = setupenvvar_381601(owner, d, c);
		{
			Tnode214790* v;
			if (!((*env).kind == ((NU8) 3))) goto LA11;
			v = newnodei_216248(((NU8) 99), (*env).info);
			addvar_376017(v, env);
			add_215114(result, v);
		}
		LA11: ;
		LOC13 = 0;
		LOC13 = getsyssym_258041(((NimStringDesc*) &TMP1140));
		LOC14 = 0;
		LOC14 = newcall_379004(LOC13, env);
		add_215114(result, LOC14);
		{
			NI i_381987;
			Slice88080 HEX3Atmp_382035;
			NI LOC16;
			i_381987 = 0;
			memset((void*)(&HEX3Atmp_382035), 0, sizeof(HEX3Atmp_382035));
			LOC16 = 0;
			LOC16 = len_215059((*(*owner).typ).n);
			HEX3Atmp_382035 = HEX2EHEX2E_102424(((NI) 1), (LOC16 - 1));
			{
				NI x_382039;
				NI HEX3Atmp_382041;
				NI HEX3Atmp_382043;
				NI res_382045;
				x_382039 = 0;
				HEX3Atmp_382041 = 0;
				HEX3Atmp_382043 = 0;
				HEX3Atmp_382041 = HEX3Atmp_382035.a;
				HEX3Atmp_382043 = HEX3Atmp_382035.b;
				res_382045 = HEX3Atmp_382041;
				{
					while (1) {
						Tsym214822* local;
						Tnode214790* LOC20;
						if (!(res_382045 <= HEX3Atmp_382043)) goto LA19;
						x_382039 = res_382045;
						i_381987 = x_382039;
						LOC20 = 0;
						LOC20 = HEX5BHEX5D_215238((*(*owner).typ).n, i_381987);
						local = (*LOC20).kindU.S4.sym;
						{
							NIM_BOOL LOC23;
							Tnode214790* fieldaccess;
							Tnode214790* LOC26;
							Tnode214790* LOC27;
							LOC23 = 0;
							LOC23 = contains_211811((&(*d).capturedvars), (*local).Sup.id);
							if (!LOC23) goto LA24;
							fieldaccess = indirectaccess_377826(env, local, (*env).info);
							LOC26 = 0;
							LOC26 = newsymnode_216234(local);
							LOC27 = 0;
							LOC27 = newasgnstmt_379888(fieldaccess, LOC26, (*env).info);
							add_215114(result, LOC27);
						}
						LA24: ;
						res_382045 += ((NI) 1);
					} LA19: ;
				}
			}
		}
	}
	LA1: ;
	LOC28 = 0;
	LOC28 = lastson_217377((*env).typ);
	LOC29 = 0;
	LOC29 = getident_189441(((NimStringDesc*) &TMP1133));
	upfield = lookupinrecord_221140((*LOC28).n, LOC29);
	{
		Tnode214790* up;
		if (!!((upfield == NIM_NIL))) goto LA32;
		up = getupviaparam_381876(owner);
		{
			NIM_BOOL LOC36;
			Tnode214790* LOC40;
			Tnode214790* LOC41;
			LOC36 = 0;
			LOC36 = !((up == NIM_NIL));
			if (!(LOC36)) goto LA37;
			LOC36 = ((*upfield).typ == (*up).typ);
			LA37: ;
			if (!LOC36) goto LA38;
			LOC40 = 0;
			LOC40 = rawindirectaccess_376402(env, upfield, (*env).info);
			LOC41 = 0;
			LOC41 = newasgnstmt_379888(LOC40, up, (*env).info);
			add_215114(result, LOC41);
		}
		goto LA34;
		LA38: ;
		{
			localerror_187085((*env).info, ((NimStringDesc*) &TMP1145));
		}
		LA34: ;
	}
	LA32: ;
	return result;
}

N_NIMCALL(Tnode214790*, makeclosure_379896)(Tsym214822* prc, Tnode214790* env, Tlineinfo182337 info) {
	Tnode214790* result;
	Tnode214790* LOC1;
	result = 0;
	result = newnodeit_216801(((NU8) 155), info, (*prc).typ);
	LOC1 = 0;
	LOC1 = newsymnode_216234(prc);
	add_215114(result, LOC1);
	{
		Ttype214828* LOC6;
		Tnode214790* LOC7;
		if (!(env == NIM_NIL)) goto LA4;
		LOC6 = 0;
		LOC6 = getsystype_258130(((NU8) 5));
		LOC7 = 0;
		LOC7 = newnodeit_216801(((NU8) 23), info, LOC6);
		add_215114(result, LOC7);
	}
	goto LA2;
	LA4: ;
	{
		{
			Tnode214790* LOC11;
			LOC11 = 0;
			LOC11 = skipconv_249082(env);
			if (!((*LOC11).kind == ((NU8) 155))) goto LA12;
			localerror_187085(info, ((NimStringDesc*) &TMP1146));
		}
		LA12: ;
		add_215114(result, env);
	}
	LA2: ;
	return result;
}

N_NIMCALL(Tnode214790*, closurecreationforiter_382049)(Tnode214790* iter, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
	Tsym214822* owner;
	Tsym214822* v;
	Tident189012* LOC1;
	Tsym214822* LOC2;
	Tnode214790* vnode;
	Tsym214822* LOC11;
	Tnode214790* LOC12;
	Tsym214822* upfield;
	Ttype214828* LOC13;
	Tident189012* LOC14;
	Tnode214790* LOC26;
	result = 0;
	result = newnodeit_216801(((NU8) 126), (*iter).info, (*(*iter).kindU.S4.sym).typ);
	owner = skipgenericowner_219353((*iter).kindU.S4.sym);
	LOC1 = 0;
	LOC1 = getident_189441(((NimStringDesc*) &TMP1139));
	v = newsym_215683(((NU8) 8), LOC1, owner, (*iter).info);
	(*v).flags |= ((NU32)1)<<((((NU8) 21))%(sizeof(NU32)*8));
	LOC2 = 0;
	LOC2 = gethiddenparam_379401((*iter).kindU.S4.sym);
	asgnRefNoCycle((void**) (&(*v).typ), (*LOC2).typ);
	vnode = 0;
	{
		NIM_BOOL LOC5;
		Tsym214822* it;
		Tnode214790* LOC9;
		LOC5 = 0;
		LOC5 = ((*owner).kind == ((NU8) 14));
		if (!(LOC5)) goto LA6;
		LOC5 = ((*(*owner).typ).callconv == ((NU8) 8));
		LA6: ;
		if (!LOC5) goto LA7;
		it = gethiddenparam_379401(owner);
		adduniquefield_376802((*(*it).typ).sons->data[((NI) 0)], v);
		LOC9 = 0;
		LOC9 = newsymnode_216234(it);
		vnode = indirectaccess_377826(LOC9, v, (*v).info);
	}
	goto LA3;
	LA7: ;
	{
		Tnode214790* vs;
		vnode = newsymnode_216234(v);
		vs = newnodei_216248(((NU8) 99), (*iter).info);
		addvar_376017(vs, vnode);
		add_215114(result, vs);
	}
	LA3: ;
	LOC11 = 0;
	LOC11 = getsyssym_258041(((NimStringDesc*) &TMP1140));
	LOC12 = 0;
	LOC12 = newcall_379004(LOC11, vnode);
	add_215114(result, LOC12);
	LOC13 = 0;
	LOC13 = lastson_217377((*v).typ);
	LOC14 = 0;
	LOC14 = getident_189441(((NimStringDesc*) &TMP1133));
	upfield = lookupinrecord_221140((*LOC13).n, LOC14);
	{
		Tnode214790* u;
		if (!!((upfield == NIM_NIL))) goto LA17;
		u = setupenvvar_381601(owner, d, c);
		{
			Tnode214790* LOC23;
			Tnode214790* LOC24;
			if (!((*u).typ == (*upfield).typ)) goto LA21;
			LOC23 = 0;
			LOC23 = rawindirectaccess_376402(vnode, upfield, (*iter).info);
			LOC24 = 0;
			LOC24 = newasgnstmt_379888(LOC23, u, (*iter).info);
			add_215114(result, LOC24);
		}
		goto LA19;
		LA21: ;
		{
			localerror_187085((*iter).info, ((NimStringDesc*) &TMP1147));
		}
		LA19: ;
	}
	LA17: ;
	LOC26 = 0;
	LOC26 = makeclosure_379896((*iter).kindU.S4.sym, vnode, (*iter).info);
	add_215114(result, LOC26);
	return result;
}

N_NIMCALL(Tnode214790*, symtoclosure_382815)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
	Tsym214822* s;
{	result = 0;
	s = (*n).kindU.S4.sym;
	{
		Tsym214822* available;
		Tnode214790* LOC5;
		if (!(s == owner)) goto LA3;
		available = gethiddenparam_379401(owner);
		LOC5 = 0;
		LOC5 = newsymnode_216234(available);
		result = makeclosure_379896(s, LOC5, (*n).info);
	}
	goto LA1;
	LA3: ;
	{
		NIM_BOOL LOC7;
		LOC7 = 0;
		LOC7 = ((*s).kind == ((NU8) 14));
		if (!(LOC7)) goto LA8;
		LOC7 = ((*(*s).typ).callconv == ((NU8) 8));
		LA8: ;
		if (!LOC7) goto LA9;
		result = closurecreationforiter_382049(n, d, c);
	}
	goto LA1;
	LA9: ;
	{
		Tsym214822* LOC12;
		Tnode214790* LOC15;
		LOC12 = 0;
		LOC12 = skipgenericowner_219353(s);
		if (!(LOC12 == owner)) goto LA13;
		LOC15 = 0;
		LOC15 = setupenvvar_381601(owner, d, c);
		result = makeclosure_379896(s, LOC15, (*n).info);
	}
	goto LA1;
	LA13: ;
	{
		Tsym214822* available;
		Ttype214828* wanted;
		Tsym214822* LOC17;
		Tnode214790* access;
		available = gethiddenparam_379401(owner);
		LOC17 = 0;
		LOC17 = gethiddenparam_379401(s);
		wanted = (*LOC17).typ;
		access = newsymnode_216234(available);
		{
			while (1) {
				Ttype214828* obj;
				Tsym214822* upfield;
				Tident189012* LOC24;
				{
					if (!((*access).typ == wanted)) goto LA22;
					result = makeclosure_379896(s, access, (*n).info);
					goto BeforeRet;
				}
				LA22: ;
				obj = (*(*access).typ).sons->data[((NI) 0)];
				LOC24 = 0;
				LOC24 = getident_189441(((NimStringDesc*) &TMP1133));
				upfield = lookupinrecord_221140((*obj).n, LOC24);
				{
					if (!(upfield == NIM_NIL)) goto LA27;
					localerror_187085((*n).info, ((NimStringDesc*) &TMP1148));
					result = n;
					goto BeforeRet;
				}
				LA27: ;
				access = rawindirectaccess_376402(access, upfield, (*n).info);
			}
		}
	}
	LA1: ;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tnode214790*, accessviaenvparam_381211)(Tnode214790* n, Tsym214822* owner) {
	Tnode214790* result;
	Tsym214822* s;
	Tsym214822* envparam;
	NimStringDesc* LOC16;
{	result = 0;
	s = (*n).kindU.S4.sym;
	envparam = gethiddenparam_379401(owner);
	{
		Tnode214790* access;
		if (!!(envparam == 0)) goto LA3;
		access = newsymnode_216234(envparam);
		{
			while (1) {
				Ttype214828* obj;
				Tsym214822* field;
				Tsym214822* upfield;
				Tident189012* LOC11;
				obj = (*(*access).typ).sons->data[((NI) 0)];
				field = getfieldfromobj_377447(obj, s);
				{
					if (!!((field == NIM_NIL))) goto LA9;
					result = rawindirectaccess_376402(access, field, (*n).info);
					goto BeforeRet;
				}
				LA9: ;
				LOC11 = 0;
				LOC11 = getident_189441(((NimStringDesc*) &TMP1133));
				upfield = lookupinrecord_221140((*obj).n, LOC11);
				{
					if (!(upfield == NIM_NIL)) goto LA14;
					goto LA5;
				}
				LA14: ;
				access = rawindirectaccess_376402(access, upfield, (*n).info);
			}
		} LA5: ;
	}
	LA3: ;
	LOC16 = 0;
	LOC16 = rawNewString((*(*s).name).s->Sup.len + 36);
appendString(LOC16, ((NimStringDesc*) &TMP1149));
appendString(LOC16, (*(*s).name).s);
	localerror_187085((*n).info, LOC16);
	result = n;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tnode214790*, accessviaenvvar_382135)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
	Tnode214790* access;
	Ttype214828* obj;
	Tsym214822* field;
	result = 0;
	access = setupenvvar_381601(owner, d, c);
	obj = (*(*access).typ).sons->data[((NI) 0)];
	field = getfieldfromobj_377447(obj, (*n).kindU.S4.sym);
	{
		if (!!((field == NIM_NIL))) goto LA3;
		result = rawindirectaccess_376402(access, field, (*n).info);
	}
	goto LA1;
	LA3: ;
	{
		localerror_187085((*n).info, ((NimStringDesc*) &TMP1150));
		result = n;
	}
	LA1: ;
	return result;
}

N_NIMCALL(Tsym214822*, getiterresult_379038)(Tsym214822* iter) {
	Tsym214822* result;
	result = 0;
	{
		NI LOC3;
		LOC3 = 0;
		LOC3 = len_215059((*iter).ast);
		if (!(((NI) 7) < LOC3)) goto LA4;
		result = (*(*(*iter).ast).kindU.S6.sons->data[((NI) 7)]).kindU.S4.sym;
	}
	goto LA1;
	LA4: ;
	{
		Tident189012* LOC7;
		Tnode214790* LOC8;
		LOC7 = 0;
		LOC7 = getident_189441(((NimStringDesc*) &TMP1151));
		result = newsym_215683(((NU8) 11), LOC7, iter, (*iter).info);
		asgnRefNoCycle((void**) (&(*result).typ), (*(*iter).typ).sons->data[((NI) 0)]);
		(*result).flags |= ((NU32)1)<<((((NU8) 0))%(sizeof(NU32)*8));
		LOC8 = 0;
		LOC8 = newsymnode_216234(result);
		add_215114((*iter).ast, LOC8);
	}
	LA1: ;
	return result;
}

N_NIMCALL(Tnode214790*, transformyield_382173)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
	Tsym214822* state;
	NI64 stateno;
	Tnode214790* stateasgnstmt;
	Tsym214822* LOC1;
	Tnode214790* LOC2;
	Tnode214790* LOC3;
	Ttype214828* LOC4;
	Tnode214790* LOC5;
	Tnode214790* retstmt;
	Tnode214790* statelabelstmt;
	Ttype214828* LOC13;
	Tnode214790* LOC14;
	result = 0;
	state = getstatefield_382159(owner);
	(*(*(*(*state).typ).n).kindU.S6.sons->data[((NI) 1)]).kindU.S1.intval += ((NI) 1);
	stateno = (*(*(*(*state).typ).n).kindU.S6.sons->data[((NI) 1)]).kindU.S1.intval;
	stateasgnstmt = newnodei_216248(((NU8) 73), (*n).info);
	LOC1 = 0;
	LOC1 = getenvparam_379603(owner);
	LOC2 = 0;
	LOC2 = newsymnode_216234(LOC1);
	LOC3 = 0;
	LOC3 = rawindirectaccess_376402(LOC2, state, (*n).info);
	add_215114(stateasgnstmt, LOC3);
	LOC4 = 0;
	LOC4 = getsystype_258130(((NU8) 31));
	LOC5 = 0;
	LOC5 = newinttypenode_215665(((NU8) 6), stateno, LOC4);
	add_215114(stateasgnstmt, LOC5);
	retstmt = newnodei_216248(((NU8) 109), (*n).info);
	{
		Tnode214790* a;
		Tnode214790* retval;
		Tsym214822* LOC10;
		Tnode214790* LOC11;
		if (!!(((*(*n).kindU.S6.sons->data[((NI) 0)]).kind == ((NU8) 1)))) goto LA8;
		a = newnodei_216248(((NU8) 73), (*(*n).kindU.S6.sons->data[((NI) 0)]).info);
		retval = liftcapturedvars_382166((*n).kindU.S6.sons->data[((NI) 0)], owner, d, c);
		LOC10 = 0;
		LOC10 = getiterresult_379038(owner);
		LOC11 = 0;
		LOC11 = newsymnode_216234(LOC10);
		addson_216807(a, LOC11);
		addson_216807(a, retval);
		add_215114(retstmt, a);
	}
	goto LA6;
	LA8: ;
	{
		add_215114(retstmt, emptynode_215801);
	}
	LA6: ;
	statelabelstmt = newnodei_216248(((NU8) 157), (*n).info);
	LOC13 = 0;
	LOC13 = getsystype_258130(((NU8) 31));
	LOC14 = 0;
	LOC14 = newinttypenode_215665(((NU8) 6), stateno, LOC13);
	add_215114(statelabelstmt, LOC14);
	result = newnodei_216248(((NU8) 115), (*n).info);
	add_215114(result, stateasgnstmt);
	add_215114(result, retstmt);
	add_215114(result, statelabelstmt);
	return result;
}

N_NIMCALL(Tnode214790*, transformreturn_382642)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
	Tsym214822* state;
	Tnode214790* stateasgnstmt;
	Tsym214822* LOC1;
	Tnode214790* LOC2;
	Tnode214790* LOC3;
	Ttype214828* LOC4;
	Tnode214790* LOC5;
	result = 0;
	state = getstatefield_382159(owner);
	result = newnodei_216248(((NU8) 115), (*n).info);
	stateasgnstmt = newnodei_216248(((NU8) 73), (*n).info);
	LOC1 = 0;
	LOC1 = getenvparam_379603(owner);
	LOC2 = 0;
	LOC2 = newsymnode_216234(LOC1);
	LOC3 = 0;
	LOC3 = rawindirectaccess_376402(LOC2, state, (*n).info);
	add_215114(stateasgnstmt, LOC3);
	LOC4 = 0;
	LOC4 = getsystype_258130(((NU8) 31));
	LOC5 = 0;
	LOC5 = newinttypenode_215665(((NU8) 6), IL64(-1), LOC4);
	add_215114(stateasgnstmt, LOC5);
	add_215114(result, stateasgnstmt);
	add_215114(result, n);
	return result;
}

N_NIMCALL(Tnode214790*, liftcapturedvars_382166)(Tnode214790* n, Tsym214822* owner, Detectionpass380248* d, Liftingpass381050* c) {
	Tnode214790* result;
{	result = 0;
	result = n;
	switch ((*n).kind) {
	case ((NU8) 3):
	{
		Tsym214822* s;
		s = (*n).kindU.S4.sym;
		{
			NIM_BOOL LOC4;
			LOC4 = 0;
			LOC4 = isinnerproc_379852(s);
			if (!LOC4) goto LA5;
			{
				NIM_BOOL LOC9;
				Tnode214790* body;
				Tnode214790* LOC12;
				Tnode214790* LOC13;
				LOC9 = 0;
				LOC9 = containsorincl_211862((&(*c).processed), (*s).Sup.id);
				if (!!(LOC9)) goto LA10;
				LOC12 = 0;
				LOC12 = getbody_254827(s);
				LOC13 = 0;
				LOC13 = liftcapturedvars_382166(LOC12, s, d, c);
				body = wrapiterbody_382656(LOC13, s);
				{
					Tnode214790* LOC16;
					LOC16 = 0;
					LOC16 = getordefault_381631((*c).envvars, (*s).Sup.id);
					if (!LOC16 == 0) goto LA17;
					asgnRefNoCycle((void**) (&(*(*s).ast).kindU.S6.sons->data[((NI) 6)]), body);
				}
				goto LA14;
				LA17: ;
				{
					TY382939 LOC20;
					memset((void*)LOC20, 0, sizeof(LOC20));
					LOC20[0] = rawclosurecreation_381918(s, d, c);
					LOC20[1] = body;
					asgnRefNoCycle((void**) (&(*(*s).ast).kindU.S6.sons->data[((NI) 6)]), newtree_215601(((NU8) 115), LOC20, 2));
				}
				LA14: ;
			}
			LA10: ;
			{
				if (!((*(*s).typ).callconv == ((NU8) 8))) goto LA23;
				result = symtoclosure_382815(n, owner, d, c);
			}
			LA23: ;
		}
		goto LA2;
		LA5: ;
		{
			NIM_BOOL LOC26;
			LOC26 = 0;
			LOC26 = contains_211811((&(*d).capturedvars), (*s).Sup.id);
			if (!LOC26) goto LA27;
			{
				if (!!(((*s).owner == owner))) goto LA31;
				result = accessviaenvparam_381211(n, owner);
			}
			goto LA29;
			LA31: ;
			{
				NIM_BOOL LOC34;
				NIM_BOOL LOC35;
				LOC34 = 0;
				LOC35 = 0;
				LOC35 = ((*owner).kind == ((NU8) 14));
				if (!(LOC35)) goto LA36;
				LOC35 = ((*(*owner).typ).callconv == ((NU8) 8));
				LA36: ;
				LOC34 = LOC35;
				if (!(LOC34)) goto LA37;
				LOC34 = interestingitervar_379928(s);
				LA37: ;
				if (!LOC34) goto LA38;
				result = accessviaenvparam_381211(n, owner);
			}
			goto LA29;
			LA38: ;
			{
				result = accessviaenvvar_382135(n, owner, d, c);
			}
			LA29: ;
		}
		goto LA2;
		LA27: ;
		LA2: ;
	}
	break;
	case ((NU8) 1) ... ((NU8) 2):
	case ((NU8) 4) ... ((NU8) 23):
	case ((NU8) 83):
	case ((NU8) 98):
	{
	}
	break;
	case ((NU8) 79):
	case ((NU8) 80):
	case ((NU8) 81):
	case ((NU8) 82):
	{
	}
	break;
	case ((NU8) 155):
	{
		{
			Tnode214790* LOC46;
			Tnode214790* LOC49;
			Tnode214790* x;
			LOC46 = 0;
			LOC46 = HEX5BHEX5D_215238(n, ((NI) 1));
			if (!((*LOC46).kind == ((NU8) 23))) goto LA47;
			LOC49 = 0;
			LOC49 = HEX5BHEX5D_215238(n, ((NI) 0));
			asgnRefNoCycle((void**) (&(*n).kindU.S6.sons->data[((NI) 0)]), liftcapturedvars_382166(LOC49, owner, d, c));
			x = skipconv_249082((*n).kindU.S6.sons->data[((NI) 0)]);
			{
				if (!((*x).kind == ((NU8) 155))) goto LA52;
				asgnRefNoCycle((void**) (&(*n).kindU.S6.sons->data[((NI) 0)]), (*x).kindU.S6.sons->data[((NI) 0)]);
			}
			LA52: ;
		}
		LA47: ;
	}
	break;
	case ((NU8) 51):
	case ((NU8) 84):
	case ((NU8) 52):
	{
		{
			NIM_BOOL LOC57;
			Tnode214790* LOC59;
			Tnode214790* m;
			Tnode214790* LOC62;
			LOC57 = 0;
			LOC57 = !(((*n).typ == NIM_NIL));
			if (!(LOC57)) goto LA58;
			LOC59 = 0;
			LOC59 = HEX5BHEX5D_215238(n, ((NI) 0));
			LOC57 = ((*LOC59).kind == ((NU8) 3));
			LA58: ;
			if (!LOC57) goto LA60;
			LOC62 = 0;
			LOC62 = HEX5BHEX5D_215238(n, ((NI) 0));
			m = newsymnode_216234((*LOC62).kindU.S4.sym);
			asgnRefNoCycle((void**) (&(*m).typ), (*n).typ);
			result = liftcapturedvars_382166(m, owner, d, c);
		}
		LA60: ;
	}
	break;
	default:
	{
		{
			NIM_BOOL LOC66;
			LOC66 = 0;
			LOC66 = ((*owner).kind == ((NU8) 14));
			if (!(LOC66)) goto LA67;
			LOC66 = ((*(*owner).typ).callconv == ((NU8) 8));
			LA67: ;
			if (!LOC66) goto LA68;
			{
				if (!((*n).kind == ((NU8) 104))) goto LA72;
				result = transformyield_382173(n, owner, d, c);
				goto BeforeRet;
			}
			goto LA70;
			LA72: ;
			{
				if (!((*n).kind == ((NU8) 109))) goto LA75;
				result = transformreturn_382642(n, owner, d, c);
				goto BeforeRet;
			}
			goto LA70;
			LA75: ;
			{
				Tnode214790* LOC80;
				if (!(((*n).flags &(1U<<((NU)(((NU8) 8))&15U)))!=0)) goto LA78;
				LOC80 = 0;
				LOC80 = HEX5BHEX5D_215238(n, ((NI) 1));
				asgnRefNoCycle((void**) (&(*n).kindU.S6.sons->data[((NI) 1)]), liftcapturedvars_382166(LOC80, owner, d, c));
				goto BeforeRet;
			}
			goto LA70;
			LA78: ;
			LA70: ;
		}
		LA68: ;
		{
			NI i_383126;
			Slice88080 HEX3Atmp_383129;
			NI LOC82;
			i_383126 = 0;
			memset((void*)(&HEX3Atmp_383129), 0, sizeof(HEX3Atmp_383129));
			LOC82 = 0;
			LOC82 = len_215059(n);
			HEX3Atmp_383129 = HEX2EHEX2E_102424(((NI) 0), (LOC82 - 1));
			{
				NI x_383133;
				NI HEX3Atmp_383135;
				NI HEX3Atmp_383137;
				NI res_383139;
				x_383133 = 0;
				HEX3Atmp_383135 = 0;
				HEX3Atmp_383137 = 0;
				HEX3Atmp_383135 = HEX3Atmp_383129.a;
				HEX3Atmp_383137 = HEX3Atmp_383129.b;
				res_383139 = HEX3Atmp_383135;
				{
					while (1) {
						Tnode214790* LOC86;
						if (!(res_383139 <= HEX3Atmp_383137)) goto LA85;
						x_383133 = res_383139;
						i_383126 = x_383133;
						LOC86 = 0;
						LOC86 = HEX5BHEX5D_215238(n, i_383126);
						asgnRefNoCycle((void**) (&(*n).kindU.S6.sons->data[i_383126]), liftcapturedvars_382166(LOC86, owner, d, c));
						res_383139 += ((NI) 1);
					} LA85: ;
				}
			}
		}
	}
	break;
	}
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tnode214790*, liftitertoproc_383207)(Tsym214822* fn, Tnode214790* body, Ttype214828* ptrtype) {
	Tnode214790* result;
	Detectionpass380248 d;
	Liftingpass381050 c;
	NU8 oldkind;
	NU8 oldcc;
	Tnode214790* LOC1;
	result = 0;
	memset((void*)(&d), 0, sizeof(d));
	chckNil((void*)(&d));
	memset((void*)(&d), 0, sizeof(d));
	initdetectionpass_380276(fn, (&d));
	memset((void*)(&c), 0, sizeof(c));
	chckNil((void*)(&c));
	memset((void*)(&c), 0, sizeof(c));
	initliftingpass_381076(fn, (&c));
	oldkind = (*fn).kind;
	oldcc = (*(*fn).typ).callconv;
	(*fn).kind = ((NU8) 14);
	(*(*fn).typ).callconv = ((NU8) 8);
	HEX5BHEX5DHEX3D_380464((&d.ownertotype), (*fn).Sup.id, ptrtype);
	detectcapturedvars_380760(body, fn, (&d));
	LOC1 = 0;
	LOC1 = liftcapturedvars_382166(body, fn, (&d), (&c));
	result = wrapiterbody_382656(LOC1, fn);
	(*fn).kind = oldkind;
	(*(*fn).typ).callconv = oldcc;
	return result;
}

N_NIMCALL(void, semcapturesym_383143)(Tsym214822* s, Tsym214822* owner) {
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = interestingvar_379801(s);
		if (!(LOC3)) goto LA4;
		LOC3 = !(((*s).kind == ((NU8) 11)));
		LA4: ;
		if (!LOC3) goto LA5;
		{
			NIM_BOOL LOC9;
			NIM_BOOL LOC11;
			Tsym214822* o;
			LOC9 = 0;
			LOC9 = !(((*owner).typ == NIM_NIL));
			if (!(LOC9)) goto LA10;
			LOC11 = 0;
			LOC11 = isgenericroutine_219315(owner);
			LOC9 = !(LOC11);
			LA10: ;
			if (!LOC9) goto LA12;
			o = skipgenericowner_219353(owner);
			{
				while (1) {
					NIM_BOOL LOC16;
					LOC16 = 0;
					LOC16 = !(((*o).kind == ((NU8) 6)));
					if (!(LOC16)) goto LA17;
					LOC16 = !((o == NIM_NIL));
					LA17: ;
					if (!LOC16) goto LA15;
					{
						if (!((*s).owner == o)) goto LA20;
						(*(*owner).typ).callconv = ((NU8) 8);
					}
					LA20: ;
					o = skipgenericowner_219353(o);
				} LA15: ;
			}
		}
		LA12: ;
	}
	LA5: ;
}

N_NIMCALL(Tnode214790*, liftitersym_379960)(Tnode214790* n, Tsym214822* owner) {
	Tnode214790* result;
	Tsym214822* iter;
	Tsym214822* hp;
	Tsym214822* env;
	Tnode214790* v;
	Tnode214790* LOC1;
	Tnode214790* envasnode;
	Tsym214822* LOC2;
	Tnode214790* LOC3;
	Tnode214790* LOC4;
	result = 0;
	iter = (*n).kindU.S4.sym;
	result = newnodeit_216801(((NU8) 126), (*n).info, (*n).typ);
	hp = gethiddenparam_379401(iter);
	env = newsym_215683(((NU8) 9), (*iter).name, owner, (*n).info);
	asgnRefNoCycle((void**) (&(*env).typ), (*hp).typ);
	(*env).flags = (*hp).flags;
	v = newnodei_216248(((NU8) 99), (*n).info);
	LOC1 = 0;
	LOC1 = newsymnode_216234(env);
	addvar_376017(v, LOC1);
	add_215114(result, v);
	envasnode = newsymnode_216234(env);
	LOC2 = 0;
	LOC2 = getsyssym_258041(((NimStringDesc*) &TMP1140));
	LOC3 = 0;
	LOC3 = newcall_379004(LOC2, envasnode);
	add_215114(result, LOC3);
	LOC4 = 0;
	LOC4 = makeclosure_379896(iter, envasnode, (*n).info);
	add_215114(result, LOC4);
	return result;
}

N_NIMCALL(Tnode214790*, liftforloop_383369)(Tnode214790* body, Tsym214822* owner) {
	Tnode214790* result;
	NI L;
	Tnode214790* call;
	Tsym214822* env;
	Tnode214790* op;
	Tnode214790* loopbody;
	Tnode214790* whileloop;
	Ttype214828* LOC32;
	Tnode214790* v2;
	Tnode214790* vpart;
	NU8 LOC33;
	Tnode214790* bs;
{	result = 0;
	L = len_215059(body);
	{
		NIM_BOOL LOC3;
		Tnode214790* LOC5;
		LOC3 = 0;
		LOC3 = ((*body).kind == ((NU8) 94));
		if (!(LOC3)) goto LA4;
		LOC5 = 0;
		LOC5 = HEX5BHEX5D_215238(body, (NI)(L - ((NI) 2)));
		LOC3 = ((*LOC5).kind == ((NU8) 27) || (*LOC5).kind == ((NU8) 29) || (*LOC5).kind == ((NU8) 30) || (*LOC5).kind == ((NU8) 31) || (*LOC5).kind == ((NU8) 26) || (*LOC5).kind == ((NU8) 28) || (*LOC5).kind == ((NU8) 32));
		LA4: ;
		if (!!(LOC3)) goto LA6;
		localerror_187085((*body).info, ((NimStringDesc*) &TMP3439));
		result = body;
		goto BeforeRet;
	}
	LA6: ;
	call = HEX5BHEX5D_215238(body, (NI)(L - ((NI) 2)));
	result = newnodei_216248(((NU8) 115), (*body).info);
	env = 0;
	op = HEX5BHEX5D_215238(call, ((NI) 0));
	{
		NIM_BOOL LOC10;
		NIM_BOOL LOC12;
		Tsym214822* iter;
		Tsym214822* hp;
		Tnode214790* v;
		Tnode214790* LOC16;
		Tsym214822* LOC17;
		Tnode214790* LOC18;
		Tnode214790* LOC19;
		LOC10 = 0;
		LOC10 = ((*op).kind == ((NU8) 3));
		if (!(LOC10)) goto LA11;
		LOC12 = 0;
		LOC12 = ((*(*op).kindU.S4.sym).kind == ((NU8) 14));
		if (!(LOC12)) goto LA13;
		LOC12 = ((*(*(*op).kindU.S4.sym).typ).callconv == ((NU8) 8));
		LA13: ;
		LOC10 = LOC12;
		LA11: ;
		if (!LOC10) goto LA14;
		iter = (*op).kindU.S4.sym;
		hp = gethiddenparam_379401(iter);
		env = newsym_215683(((NU8) 9), (*iter).name, owner, (*body).info);
		asgnRefNoCycle((void**) (&(*env).typ), (*hp).typ);
		(*env).flags = (*hp).flags;
		v = newnodei_216248(((NU8) 99), (*body).info);
		LOC16 = 0;
		LOC16 = newsymnode_216234(env);
		addvar_376017(v, LOC16);
		add_215114(result, v);
		LOC17 = 0;
		LOC17 = getsyssym_258041(((NimStringDesc*) &TMP1140));
		LOC18 = 0;
		LOC18 = newsymnode_216234(env);
		LOC19 = 0;
		LOC19 = newcall_379004(LOC17, LOC18);
		add_215114(result, LOC19);
	}
	goto LA8;
	LA14: ;
	{
		Tnode214790* closure;
		if (!((*op).kind == ((NU8) 126))) goto LA21;
		closure = lastson_217364(op);
		{
			if (!((*closure).kind == ((NU8) 155))) goto LA25;
			asgnRefNoCycle((void**) (&(*call).kindU.S6.sons->data[((NI) 0)]), closure);
			{
				NI i_383471;
				NI HEX3Atmp_383521;
				NI LOC28;
				NI res_383524;
				i_383471 = 0;
				HEX3Atmp_383521 = 0;
				LOC28 = 0;
				LOC28 = len_215059(op);
				HEX3Atmp_383521 = (NI)(LOC28 - ((NI) 2));
				res_383524 = ((NI) 0);
				{
					while (1) {
						Tnode214790* LOC31;
						if (!(res_383524 <= HEX3Atmp_383521)) goto LA30;
						i_383471 = res_383524;
						LOC31 = 0;
						LOC31 = HEX5BHEX5D_215238(op, i_383471);
						add_215114(result, LOC31);
						res_383524 += ((NI) 1);
					} LA30: ;
				}
			}
		}
		LA25: ;
	}
	goto LA8;
	LA21: ;
	LA8: ;
	loopbody = newnodei_216401(((NU8) 115), (*body).info, ((NI) 3));
	whileloop = newnodei_216401(((NU8) 96), (*body).info, ((NI) 2));
	LOC32 = 0;
	LOC32 = getsystype_258130(((NU8) 1));
	asgnRefNoCycle((void**) (&(*whileloop).kindU.S6.sons->data[((NI) 0)]), newinttypenode_215665(((NU8) 6), IL64(1), LOC32));
	asgnRefNoCycle((void**) (&(*whileloop).kindU.S6.sons->data[((NI) 1)]), loopbody);
	add_215114(result, whileloop);
	v2 = newnodei_216248(((NU8) 100), (*body).info);
	LOC33 = 0;
	{
		if (!(L == ((NI) 3))) goto LA36;
		LOC33 = ((NU8) 35);
	}
	goto LA34;
	LA36: ;
	{
		LOC33 = ((NU8) 36);
	}
	LA34: ;
	vpart = newnodei_216248(LOC33, (*body).info);
	{
		NI i_383489;
		NI HEX3Atmp_383529;
		NI res_383532;
		i_383489 = 0;
		HEX3Atmp_383529 = 0;
		HEX3Atmp_383529 = (NI)(L - ((NI) 3));
		res_383532 = ((NI) 0);
		{
			while (1) {
				Tnode214790* LOC48;
				if (!(res_383532 <= HEX3Atmp_383529)) goto LA41;
				i_383489 = res_383532;
				{
					Tnode214790* LOC44;
					Tnode214790* LOC47;
					LOC44 = 0;
					LOC44 = HEX5BHEX5D_215238(body, i_383489);
					if (!((*LOC44).kind == ((NU8) 3))) goto LA45;
					LOC47 = 0;
					LOC47 = HEX5BHEX5D_215238(body, i_383489);
					(*(*LOC47).kindU.S4.sym).kind = ((NU8) 9);
				}
				LA45: ;
				LOC48 = 0;
				LOC48 = HEX5BHEX5D_215238(body, i_383489);
				addson_216807(vpart, LOC48);
				res_383532 += ((NI) 1);
			} LA41: ;
		}
	}
	addson_216807(vpart, emptynode_215801);
	{
		Tnode214790* LOC53;
		if (!!(env == 0)) goto LA51;
		LOC53 = 0;
		LOC53 = newsymnode_216234(env);
		asgnRefNoCycle((void**) (&(*call).kindU.S6.sons->data[((NI) 0)]), makeclosure_379896((*(*call).kindU.S6.sons->data[((NI) 0)]).kindU.S4.sym, LOC53, (*body).info));
	}
	LA51: ;
	addson_216807(vpart, call);
	addson_216807(v2, vpart);
	asgnRefNoCycle((void**) (&(*loopbody).kindU.S6.sons->data[((NI) 0)]), v2);
	bs = newnodei_216248(((NU8) 158), (*body).info);
	addson_216807(bs, (*call).kindU.S6.sons->data[((NI) 0)]);
	asgnRefNoCycle((void**) (&(*loopbody).kindU.S6.sons->data[((NI) 1)]), bs);
	asgnRefNoCycle((void**) (&(*loopbody).kindU.S6.sons->data[((NI) 2)]), HEX5BHEX5D_215238(body, (NI)(L - ((NI) 1))));
	}BeforeRet: ;
	return result;
}

N_NIMCALL(Tnode214790*, freshvarforclosureiter_380014)(Tsym214822* s, Tsym214822* owner) {
	Tnode214790* result;
	Tsym214822* envparam;
	Ttype214828* obj;
	Tnode214790* access;
	Tsym214822* field;
	result = 0;
	envparam = gethiddenparam_379401(owner);
	obj = lastson_217377((*envparam).typ);
	addfield_376603(obj, s);
	access = newsymnode_216234(envparam);
	field = getfieldfromobj_377447(obj, s);
	{
		if (!!((field == NIM_NIL))) goto LA3;
		result = rawindirectaccess_376402(access, field, (*s).info);
	}
	goto LA1;
	LA3: ;
	{
		localerror_187085((*s).info, ((NimStringDesc*) &TMP3440));
		result = access;
	}
	LA1: ;
	return result;
}

N_NIMCALL(Tnode214790*, liftlambdas_383237)(Tsym214822* fn, Tnode214790* body, NIM_BOOL* tooearly) {
	Tnode214790* result;
	NIM_BOOL iscompiletime;
	NIM_BOOL LOC1;
	result = 0;
	LOC1 = 0;
	LOC1 = (((*fn).flags &(1U<<((NU)(((NU8) 23))&31U)))!=0);
	if (LOC1) goto LA2;
	LOC1 = ((*fn).kind == ((NU8) 16));
	LA2: ;
	iscompiletime = LOC1;
	{
		NIM_BOOL LOC5;
		NIM_BOOL LOC6;
		NIM_BOOL LOC8;
		Tsym214822* LOC11;
		LOC5 = 0;
		LOC6 = 0;
		LOC6 = ((*body).kind == ((NU8) 1));
		if (LOC6) goto LA7;
		LOC8 = 0;
		LOC8 = (gcmd_160123 == ((NU8) 4));
		if (!(LOC8)) goto LA9;
		LOC8 = !(iscompiletime);
		LA9: ;
		LOC6 = LOC8;
		LA7: ;
		LOC5 = LOC6;
		if (LOC5) goto LA10;
		LOC11 = 0;
		LOC11 = skipgenericowner_219353(fn);
		LOC5 = !(((*LOC11).kind == ((NU8) 6)));
		LA10: ;
		if (!LOC5) goto LA12;
		result = body;
		(*tooearly) = NIM_TRUE;
	}
	goto LA3;
	LA12: ;
	{
		Detectionpass380248 d;
		memset((void*)(&d), 0, sizeof(d));
		chckNil((void*)(&d));
		memset((void*)(&d), 0, sizeof(d));
		initdetectionpass_380276(fn, (&d));
		detectcapturedvars_380760(body, fn, (&d));
		{
			NIM_BOOL LOC17;
			NIM_BOOL LOC19;
			LOC17 = 0;
			LOC17 = !(d.somethingtodo);
			if (!(LOC17)) goto LA18;
			LOC19 = 0;
			LOC19 = ((*fn).kind == ((NU8) 14));
			if (!(LOC19)) goto LA20;
			LOC19 = ((*(*fn).typ).callconv == ((NU8) 8));
			LA20: ;
			LOC17 = LOC19;
			LA18: ;
			if (!LOC17) goto LA21;
			addclosureparam_380695((&d), fn);
			d.somethingtodo = NIM_TRUE;
		}
		LA21: ;
		{
			Liftingpass381050 c;
			Tnode214790* newbody;
			if (!d.somethingtodo) goto LA25;
			memset((void*)(&c), 0, sizeof(c));
			chckNil((void*)(&c));
			memset((void*)(&c), 0, sizeof(c));
			initliftingpass_381076(fn, (&c));
			newbody = liftcapturedvars_382166(body, fn, (&d), (&c));
			{
				Tnode214790* LOC29;
				TY382939 LOC32;
				LOC29 = 0;
				LOC29 = getordefault_381631(c.envvars, (*fn).Sup.id);
				if (!!((LOC29 == NIM_NIL))) goto LA30;
				memset((void*)LOC32, 0, sizeof(LOC32));
				LOC32[0] = rawclosurecreation_381918(fn, (&d), (&c));
				LOC32[1] = newbody;
				newbody = newtree_215601(((NU8) 115), LOC32, 2);
			}
			LA30: ;
			result = wrapiterbody_382656(newbody, fn);
		}
		goto LA23;
		LA25: ;
		{
			result = body;
		}
		LA23: ;
	}
	LA3: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, compiler_lambdaliftingInit000)(void) {
}

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

