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

#include "nimbase.h"
#include <stdio.h>
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_ConfigRefcolonObjectType___LaK09ayL9alwKUad7rts0rTw tyObject_ConfigRefcolonObjectType___LaK09ayL9alwKUad7rts0rTw;
typedef struct tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w;
typedef struct tyObject_TIdObj__iIXPrEsiKHiioLj0HSkQhA tyObject_TIdObj__iIXPrEsiKHiioLj0HSkQhA;
typedef struct RootObj RootObj;
typedef struct tySequence__Ef05srmQTDulnBdXR4Ja6Q tySequence__Ef05srmQTDulnBdXR4Ja6Q;
typedef struct tySequence__DXS6mEo7PVUFJkirsQ9bNQA tySequence__DXS6mEo7PVUFJkirsQ9bNQA;
typedef struct tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw;
typedef struct tyObject_TStrTable__f07aOS3dr28kGa5wcE29aFA tyObject_TStrTable__f07aOS3dr28kGa5wcE29aFA;
typedef struct tySequence__DfgJFJEYoj4YBAHLZPl5lQ tySequence__DfgJFJEYoj4YBAHLZPl5lQ;
typedef struct tyObject_TType__v9ae2Dpu13OW2ZJ2U9bNMd9cQ tyObject_TType__v9ae2Dpu13OW2ZJ2U9bNMd9cQ;
typedef struct tyObject_TIdent__GufRQq9c0miSybX3zBD4tyA tyObject_TIdent__GufRQq9c0miSybX3zBD4tyA;
typedef struct tyObject_TLineInfo__WGx4rAexNXnczy1Avn646Q tyObject_TLineInfo__WGx4rAexNXnczy1Avn646Q;
typedef struct tyObject_TLoc__EtHNvCB0bgfu9bFjzx9cb6aA tyObject_TLoc__EtHNvCB0bgfu9bFjzx9cb6aA;
typedef struct tyObject_RopeObj__OFzf0kSiPTcNreUIeJgWVA tyObject_RopeObj__OFzf0kSiPTcNreUIeJgWVA;
typedef struct tyObject_TLib__NBMxlJ6g3utqUlplqTTHkA tyObject_TLib__NBMxlJ6g3utqUlplqTTHkA;
typedef struct tyObject_TInstantiation__5LqgVn6Tq9ainQRK7TQAQxA tyObject_TInstantiation__5LqgVn6Tq9ainQRK7TQAQxA;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw {
NIM_BOOL enabled;
FILE* f;
NimStringDesc* buf;
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef NU8 tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg;
struct RootObj {
TNimType* m_type;
};
struct tyObject_TIdObj__iIXPrEsiKHiioLj0HSkQhA {
  RootObj Sup;
NI id;
};
typedef NU8 tyEnum_TSymKind__cNCW9acsSznmEccl1fgQwkw;
struct tyObject_TStrTable__f07aOS3dr28kGa5wcE29aFA {
NI counter;
tySequence__DfgJFJEYoj4YBAHLZPl5lQ* data;
};
typedef NU16 tyEnum_TMagic__shZhZOdbVC5nnFvcXQAImg;
struct tyObject_TLineInfo__WGx4rAexNXnczy1Avn646Q {
NU16 line;
NI16 col;
NI32 fileIndex;
};
typedef NU64 tySet_tyEnum_TSymFlag__K9ay6LWMat9bUiT9bIbMxpDHw;
typedef NU32 tySet_tyEnum_TOption__WspMeQySXNP2XoTWR5MTgg;
typedef NU8 tyEnum_TLocKind__O7PRFZKuiBBWbku09cayVBg;
typedef NU8 tyEnum_TStorageLoc__JK9cKMX3XnqHaUky9b6gkGEw;
typedef NU16 tySet_tyEnum_TLocFlag__o2bqJgR4ceIupnUSpxiudA;
struct tyObject_TLoc__EtHNvCB0bgfu9bFjzx9cb6aA {
tyEnum_TLocKind__O7PRFZKuiBBWbku09cayVBg k;
tyEnum_TStorageLoc__JK9cKMX3XnqHaUky9b6gkGEw storage;
tySet_tyEnum_TLocFlag__o2bqJgR4ceIupnUSpxiudA flags;
tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw* lode;
tyObject_RopeObj__OFzf0kSiPTcNreUIeJgWVA* r;
};
struct tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w {
  tyObject_TIdObj__iIXPrEsiKHiioLj0HSkQhA Sup;
tyEnum_TSymKind__cNCW9acsSznmEccl1fgQwkw kind;
union{
struct {tySequence__Ef05srmQTDulnBdXR4Ja6Q* typeInstCache;
};
struct {tySequence__DXS6mEo7PVUFJkirsQ9bNQA* procInstCache;
tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w* gcUnsafetyReason;
tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw* transformedBody;
};
struct {tySequence__DXS6mEo7PVUFJkirsQ9bNQA* usedGenerics;
tyObject_TStrTable__f07aOS3dr28kGa5wcE29aFA tab;
};
struct {tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w* guard;
NI bitsize;
};
};
tyEnum_TMagic__shZhZOdbVC5nnFvcXQAImg magic;
tyObject_TType__v9ae2Dpu13OW2ZJ2U9bNMd9cQ* typ;
tyObject_TIdent__GufRQq9c0miSybX3zBD4tyA* name;
tyObject_TLineInfo__WGx4rAexNXnczy1Avn646Q info;
tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w* owner;
tySet_tyEnum_TSymFlag__K9ay6LWMat9bUiT9bIbMxpDHw flags;
tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw* ast;
tySet_tyEnum_TOption__WspMeQySXNP2XoTWR5MTgg options;
NI position;
NI offset;
tyObject_TLoc__EtHNvCB0bgfu9bFjzx9cb6aA loc;
tyObject_TLib__NBMxlJ6g3utqUlplqTTHkA* annex;
tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw* constraint;
};
typedef NimStringDesc* tyArray__Re75IspeoxXy2oCZHwcRrA[2];
struct tyObject_TIdent__GufRQq9c0miSybX3zBD4tyA {
  tyObject_TIdObj__iIXPrEsiKHiioLj0HSkQhA Sup;
NimStringDesc* s;
tyObject_TIdent__GufRQq9c0miSybX3zBD4tyA* next;
NI h;
};
typedef NimStringDesc* tyArray__sMpvt1sOxOJ3LFGulnbeMQ[4];
struct tySequence__Ef05srmQTDulnBdXR4Ja6Q {
  TGenericSeq Sup;
  tyObject_TType__v9ae2Dpu13OW2ZJ2U9bNMd9cQ* data[SEQ_DECL_SIZE];
};
struct tySequence__DXS6mEo7PVUFJkirsQ9bNQA {
  TGenericSeq Sup;
  tyObject_TInstantiation__5LqgVn6Tq9ainQRK7TQAQxA* data[SEQ_DECL_SIZE];
};
struct tySequence__DfgJFJEYoj4YBAHLZPl5lQ {
  TGenericSeq Sup;
  tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w* data[SEQ_DECL_SIZE];
};
static N_INLINE(NIM_BOOL, isEmpty__kPpSxL0H5sJ9a6ujvdQ0QVQpathutils)(NimStringDesc* x);
N_LIB_PRIVATE N_NIMCALL(FILE*, open__cb1k9citqyT9a9brBSJAz8pkg)(NimStringDesc* filename, tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg mode, NI bufSize);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newLen);
N_LIB_PRIVATE N_NIMCALL(void, addInt__mftMOxbyu0h4yByfs3sqjA)(NimStringDesc** result, NI64 x);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__i80o3k0SgEI5gTRCzYdyWAsystem)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_LIB_PRIVATE N_NIMCALL(void, write__y2dplmr7ar8o7Yykk7MOlA)(FILE* f, NimStringDesc** a, NI aLen_0);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_LIB_PRIVATE N_NIMCALL(void, writeRope__FwuzOBq6SLlanVUstm8q9cA)(FILE* f, tyObject_RopeObj__OFzf0kSiPTcNreUIeJgWVA* r);
static N_INLINE(void, writeLine__45Em82MGXqv9biomV0DEbSgio)(FILE* f, NimStringDesc** x, NI xLen_0);
N_NOINLINE(void, raiseIndexError2)(NI i, NI n);
N_LIB_PRIVATE N_NIMCALL(void, write__PArlm09bKklm2BLsCg6YtaA)(FILE* f, NimStringDesc* s);
static N_INLINE(NI, addInt)(NI a, NI b);
N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, toFullPath__VW1RaR1l9c9bPnJxr1KuvIrg)(tyObject_ConfigRefcolonObjectType___LaK09ayL9alwKUad7rts0rTw* conf, NI32 fileIdx);
N_LIB_PRIVATE N_NIMCALL(void, close__fU6ZlJAtQ9bre04EDZLdGsA_3)(FILE* f);
TNimType NTI__9cEuXfAnHp9bnWFK409cMtsEw_;
extern TNimType NTI__VaVACK0bpYmqIQ0mKcHfQQ_;
extern TNimType NTI__XBeRj4rw9bUuE7CB3DS1rgg_;
extern TNimType NTI__77mFvmsOLKik79ci2hXkHEg_;
STRING_LITERAL(TM__QVKrxgdkvZgAHGFrhgVOcA_3, "\011", 1);
STRING_LITERAL(TM__QVKrxgdkvZgAHGFrhgVOcA_5, "\012", 1);
static N_INLINE(NIM_BOOL, isEmpty__kPpSxL0H5sJ9a6ujvdQ0QVQpathutils)(NimStringDesc* x) {	NIM_BOOL result;
	result = (NIM_BOOL)0;
	result = ((x ? x->Sup.len : 0) == ((NI) 0));
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, open__jmWVcl5Qp9atJWCEkvq1SfA)(tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw* f, NimStringDesc* filename, tyObject_ConfigRefcolonObjectType___LaK09ayL9alwKUad7rts0rTw* conf) {	NIM_BOOL T1_;
	T1_ = (NIM_BOOL)0;
	T1_ = isEmpty__kPpSxL0H5sJ9a6ujvdQ0QVQpathutils(filename);
	(*f).enabled = !(T1_);
	{
		if (!(*f).enabled) goto LA4_;
		(*f).f = open__cb1k9citqyT9a9brBSJAz8pkg(filename, ((tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg) 1), ((NI) 8000));
		unsureAsgnRef((void**) (&(*f).buf), rawNewString(((NI) 20)));
	}
	LA4_: ;
}
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest, source, ((size_t) (size)));
}
static N_INLINE(void, copyMem__i80o3k0SgEI5gTRCzYdyWAsystem)(void* dest, void* source, NI size) {	nimCopyMem(dest, source, size);
}
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {	{
		if (!!((src == NIM_NIL))) goto LA3_;
		copyMem__i80o3k0SgEI5gTRCzYdyWAsystem(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
		(*dest).Sup.len += (*src).Sup.len;
	}
	LA3_: ;
}
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(NI, addInt)(NI a, NI b) {	NI result;
{	result = (NI)0;
	result = (NI)((NU64)(a) + (NU64)(b));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI) 0) <= (NI)(result ^ a));
		if (T3_) goto LA4_;
		T3_ = (((NI) 0) <= (NI)(result ^ b));
		LA4_: ;
		if (!T3_) goto LA5_;
		goto BeforeRet_;
	}
	LA5_: ;
	raiseOverflow();
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, writeLine__45Em82MGXqv9biomV0DEbSgio)(FILE* f, NimStringDesc** x, NI xLen_0) {	{
		NimStringDesc* i;
		NI i_2;
		i = (NimStringDesc*)0;
		i_2 = ((NI) 0);
		{
			while (1) {
				NI TM__QVKrxgdkvZgAHGFrhgVOcA_4;
				if (!(i_2 < xLen_0)) goto LA3;
				if ((NU)(i_2) >= (NU)(xLen_0)) raiseIndexError2(i_2,xLen_0-1);
				i = x[i_2];
				write__PArlm09bKklm2BLsCg6YtaA(f, i);
				TM__QVKrxgdkvZgAHGFrhgVOcA_4 = addInt(i_2, ((NI) 1));
				i_2 = (NI)(TM__QVKrxgdkvZgAHGFrhgVOcA_4);
			} LA3: ;
		}
	}
	write__PArlm09bKklm2BLsCg6YtaA(f, ((NimStringDesc*) &TM__QVKrxgdkvZgAHGFrhgVOcA_5));
}
N_LIB_PRIVATE N_NIMCALL(void, doWrite__1nU29cZKUVlth4bckzRe6Tw)(tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw* f, tyObject_TSym__JpsEh5i1AcKChGYbg7aV4w* s, tyObject_ConfigRefcolonObjectType___LaK09ayL9alwKUad7rts0rTw* conf) {	tyArray__Re75IspeoxXy2oCZHwcRrA T1_;
	tyArray__sMpvt1sOxOJ3LFGulnbeMQ T2_;
	unsureAsgnRef((void**) (&(*f).buf), setLengthStr((*f).buf, ((NI) 0)));
	addInt__mftMOxbyu0h4yByfs3sqjA((&(*f).buf), ((NI64) (((NI) ((*s).info.line)))));
	unsureAsgnRef((void**) (&(*f).buf), resizeString((*f).buf, 1));
appendString((*f).buf, ((NimStringDesc*) &TM__QVKrxgdkvZgAHGFrhgVOcA_3));
	addInt__mftMOxbyu0h4yByfs3sqjA((&(*f).buf), ((NI64) (((NI) ((*s).info.col)))));
	nimZeroMem((void*)T1_, sizeof(tyArray__Re75IspeoxXy2oCZHwcRrA));
	T1_[0] = copyString((*(*s).name).s);
	T1_[1] = copyString(((NimStringDesc*) &TM__QVKrxgdkvZgAHGFrhgVOcA_3));
	write__y2dplmr7ar8o7Yykk7MOlA((*f).f, T1_, 2);
	writeRope__FwuzOBq6SLlanVUstm8q9cA((*f).f, (*s).loc.r);
	nimZeroMem((void*)T2_, sizeof(tyArray__sMpvt1sOxOJ3LFGulnbeMQ));
	T2_[0] = copyString(((NimStringDesc*) &TM__QVKrxgdkvZgAHGFrhgVOcA_3));
	T2_[1] = toFullPath__VW1RaR1l9c9bPnJxr1KuvIrg(conf, (*s).info.fileIndex);
	T2_[2] = copyString(((NimStringDesc*) &TM__QVKrxgdkvZgAHGFrhgVOcA_3));
	T2_[3] = copyString((*f).buf);
	writeLine__45Em82MGXqv9biomV0DEbSgio((*f).f, T2_, 4);
}
N_LIB_PRIVATE N_NIMCALL(void, close__GvEyiCVhfPFZLA80aIn5Nw)(tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw* f) {	{
		if (!(*f).enabled) goto LA3_;
		close__fU6ZlJAtQ9bre04EDZLdGsA_3((*f).f);
	}
	LA3_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, compiler_ndiDatInit000)(void) {
static TNimNode* TM__QVKrxgdkvZgAHGFrhgVOcA_2_3[3];
static TNimNode TM__QVKrxgdkvZgAHGFrhgVOcA_0[4];
NTI__9cEuXfAnHp9bnWFK409cMtsEw_.size = sizeof(tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw);
NTI__9cEuXfAnHp9bnWFK409cMtsEw_.kind = 18;
NTI__9cEuXfAnHp9bnWFK409cMtsEw_.base = 0;
NTI__9cEuXfAnHp9bnWFK409cMtsEw_.flags = 2;
TM__QVKrxgdkvZgAHGFrhgVOcA_2_3[0] = &TM__QVKrxgdkvZgAHGFrhgVOcA_0[1];
TM__QVKrxgdkvZgAHGFrhgVOcA_0[1].kind = 1;
TM__QVKrxgdkvZgAHGFrhgVOcA_0[1].offset = offsetof(tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw, enabled);
TM__QVKrxgdkvZgAHGFrhgVOcA_0[1].typ = (&NTI__VaVACK0bpYmqIQ0mKcHfQQ_);
TM__QVKrxgdkvZgAHGFrhgVOcA_0[1].name = "enabled";
TM__QVKrxgdkvZgAHGFrhgVOcA_2_3[1] = &TM__QVKrxgdkvZgAHGFrhgVOcA_0[2];
TM__QVKrxgdkvZgAHGFrhgVOcA_0[2].kind = 1;
TM__QVKrxgdkvZgAHGFrhgVOcA_0[2].offset = offsetof(tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw, f);
TM__QVKrxgdkvZgAHGFrhgVOcA_0[2].typ = (&NTI__XBeRj4rw9bUuE7CB3DS1rgg_);
TM__QVKrxgdkvZgAHGFrhgVOcA_0[2].name = "f";
TM__QVKrxgdkvZgAHGFrhgVOcA_2_3[2] = &TM__QVKrxgdkvZgAHGFrhgVOcA_0[3];
TM__QVKrxgdkvZgAHGFrhgVOcA_0[3].kind = 1;
TM__QVKrxgdkvZgAHGFrhgVOcA_0[3].offset = offsetof(tyObject_NdiFile__9cEuXfAnHp9bnWFK409cMtsEw, buf);
TM__QVKrxgdkvZgAHGFrhgVOcA_0[3].typ = (&NTI__77mFvmsOLKik79ci2hXkHEg_);
TM__QVKrxgdkvZgAHGFrhgVOcA_0[3].name = "buf";
TM__QVKrxgdkvZgAHGFrhgVOcA_0[0].len = 3; TM__QVKrxgdkvZgAHGFrhgVOcA_0[0].kind = 2; TM__QVKrxgdkvZgAHGFrhgVOcA_0[0].sons = &TM__QVKrxgdkvZgAHGFrhgVOcA_2_3[0];
NTI__9cEuXfAnHp9bnWFK409cMtsEw_.node = &TM__QVKrxgdkvZgAHGFrhgVOcA_0[0];
}

