/* Generated by Nim Compiler v1.6.10 */
#define NIM_INTBITS 32

#include "nimbase.h"
#include <io.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <setjmp.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 NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw;
typedef struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tySequence__uB9b75OUPRENsBAu4AnoePA tySequence__uB9b75OUPRENsBAu4AnoePA;
typedef struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g;
typedef struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w;
typedef struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ;
typedef struct tyObject_GcStack__7fytPA5bBsob6See21YMRA tyObject_GcStack__7fytPA5bBsob6See21YMRA;
typedef struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg;
typedef struct tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ;
typedef struct tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg;
typedef struct tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw;
typedef struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA;
typedef struct tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw;
typedef struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw;
typedef struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg;
typedef struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyTuple__ujsjpB2O9cjj3uDHsXbnSzg;
typedef struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg;
typedef struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ;
typedef struct tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg;
typedef struct TSafePoint TSafePoint;
typedef struct tyObject_EOFError__KGSY1JdrNB7Xi8KDhXFhSg tyObject_EOFError__KGSY1JdrNB7Xi8KDhXFhSg;
typedef struct tySequence__sM4lkSb7zS6F7OVMvW9cffQ tySequence__sM4lkSb7zS6F7OVMvW9cffQ;
typedef struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_STDCALL_PTR(NI32, tyProc__YrlAFY4fseJeExebH9aRGbw) (unsigned int codepage);
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;
NI align;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
struct RootObj {
TNimType* m_type;
};
struct Exception {
  RootObj Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
tySequence__uB9b75OUPRENsBAu4AnoePA* trace;
Exception* up;
};
struct tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA {
  Exception Sup;
};
struct tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw {
  tyObject_CatchableError__qrLSDoe2oBoAqNtJ9badtnA Sup;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g {
NI refcount;
TNimType* typ;
};
struct tyObject_GcStack__7fytPA5bBsob6See21YMRA {
void* bottom;
};
struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w {
NI len;
NI cap;
tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g** d;
};
typedef tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ* tyArray__SPr7N6UKfuF549bNPiUvSRw[256];
typedef NU32 tyArray__BHbOSqU1t9b3Gt7K2c6fQig[24];
typedef tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* tyArray__N1u1nqOgmuJN9cSZrnMHgOQ[32];
typedef tyArray__N1u1nqOgmuJN9cSZrnMHgOQ tyArray__B6durA4ZCi1xjJvRtyYxMg[24];
typedef tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw* tyArray__lh2A89ahMmYg9bCmpVaplLbA[256];
struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA {
tyArray__lh2A89ahMmYg9bCmpVaplLbA data;
};
typedef tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* tyArray__0aOLqZchNi8nWtMTi8ND8w[2];
struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw {
tyArray__0aOLqZchNi8nWtMTi8ND8w link;
NI key;
NI upperBound;
NI level;
};
struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg {
tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* Field0;
NI Field1;
};
typedef tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyArray__LzOv2eCDGiceMKQstCLmhw[30];
struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg {
NI len;
tyArray__LzOv2eCDGiceMKQstCLmhw chunks;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg* next;
};
struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg {
NI minLargeObj;
NI maxLargeObj;
tyArray__SPr7N6UKfuF549bNPiUvSRw freeSmallChunks;
NU32 flBitmap;
tyArray__BHbOSqU1t9b3Gt7K2c6fQig slBitmap;
tyArray__B6durA4ZCi1xjJvRtyYxMg matrix;
tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw* llmem;
NI currMem;
NI maxMem;
NI freeMem;
NI occ;
NI lastSize;
tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA chunkStarts;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* root;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* deleted;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* last;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* freeAvlNodes;
NIM_BOOL locked;
NIM_BOOL blockChunkSizeIncrease;
NI nextChunkSize;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw bottomData;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg heapLinks;
};
struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg {
NI stackScans;
NI cycleCollections;
NI maxThreshold;
NI maxStackSize;
NI maxStackCells;
NI cycleTableSize;
NI64 maxPause;
};
struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ {
NI counter;
NI max;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg* head;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg** data;
};
struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ {
tyObject_GcStack__7fytPA5bBsob6See21YMRA stack;
NI cycleThreshold;
NI zctThreshold;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w zct;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w decStack;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tempStack;
NI recGcLock;
tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg region;
tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg stat;
tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ marked;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w additionalRoots;
NI gcThreadId;
};
typedef NU8 tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg;
typedef NCSTRING tyArray__Djap3EijveoDksCG9bY8s5w[5];
typedef N_STDCALL_PTR(NI32, tyProc__PUnN9cBvfpDX0GlY5QGXGXw) (int hConsoleInput, void* lpBuffer, NI32 nNumberOfCharsToRead, NI32* lpNumberOfCharsRead, void* pInputControl);
typedef N_STDCALL_PTR(NI32, tyProc__9bXer9a4ps9aSGctILcxWReVw) (void);
typedef N_STDCALL_PTR(NI32, tyProc__aO673xGTLLxou7P7GxoCXA) (NI32 dwFlags, void* lpSource, NI32 dwMessageId, NI32 dwLanguageId, void* lpBuffer, NI32 nSize, void* arguments);
typedef N_STDCALL_PTR(void, tyProc__im9buRnIvptJfzdASYMEbBA) (void* p);
struct TSafePoint {
TSafePoint* prev;
NI status;
jmp_buf context;
};
struct tyObject_EOFError__KGSY1JdrNB7Xi8KDhXFhSg {
  tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw Sup;
};
typedef NU8 tyEnum_FileSeekPos__I9aQjuvWxs8BspGbxwsngWw;
struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
NCSTRING procname;
NI line;
NCSTRING filename;
};
struct tySequence__sM4lkSb7zS6F7OVMvW9cffQ {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};
struct tySequence__uB9b75OUPRENsBAu4AnoePA {
  TGenericSeq Sup;
  tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void*, nimLoadLibrary)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(void, nimLoadLibraryError)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(void*, nimGetProcAddr)(void* lib, NCSTRING name);
N_LIB_PRIVATE N_NIMCALL(void, writeWindows__systemZio_205)(FILE* f, NimStringDesc* s, NIM_BOOL doRaise);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s);
N_LIB_PRIVATE N_NOINLINE(void, raiseEIO__systemZio_96)(NimStringDesc* msg) __attribute__((noreturn));
N_LIB_PRIVATE N_NOINLINE(void*, newObj)(TNimType* typ, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(void, decRef__system_5370)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(NI, minuspercent___system_716)(NI x, NI y);
static N_INLINE(NIM_BOOL, ltpercent___system_1005)(NI x, NI y);
static N_INLINE(void, rtlAddZCT__system_5368)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
N_LIB_PRIVATE N_NOINLINE(void, addZCT__system_5319)(tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w* s, tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__system_5325)(void* usr);
static N_INLINE(void, asgnRef)(void** dest, void* src);
static N_INLINE(void, incRef__system_5363)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(NI, pluspercent___system_696)(NI x, NI y);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e, NCSTRING ename, NCSTRING procname, NCSTRING filename, NI line);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, open__systemZio_487)(FILE** f, NimStringDesc* filename, tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg mode, NI bufSize);
N_LIB_PRIVATE N_NIMCALL(void*, fopen__systemZio_463)(NCSTRING filename, NCSTRING mode);
N_LIB_PRIVATE N_NIMCALL(NI16*, newWideCString__systemZwidestrs_254)(NCSTRING s);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__system_1727)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isatty__systemZio_301)(FILE* f);
N_LIB_PRIVATE N_NIMCALL(int, getFileHandle__systemZio_248)(FILE* f);
N_LIB_PRIVATE N_NIMCALL(NI16*, newWideCString__systemZwidestrs_231)(NCSTRING source, NI L);
N_LIB_PRIVATE N_NIMCALL(int, getOsFileHandle__systemZio_251)(FILE* f);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___systemZwidestrs_324)(NI16* s);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___systemZdollars_3)(NI x);
N_LIB_PRIVATE N_NIMCALL(void, close__systemZio_237)(FILE* f);
N_LIB_PRIVATE N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newLen);
static N_INLINE(NIM_BOOL, eqeq___system_7778)(NCSTRING x, NCSTRING y);
N_LIB_PRIVATE N_NIMCALL(void, checkErr__systemZio_141)(FILE* f);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str);
static N_INLINE(void, pushSafePoint)(TSafePoint* s);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readAll__systemZio_443)(FILE* file);
N_LIB_PRIVATE N_NIMCALL(NI64, rawFileSize__systemZio_426)(FILE* file);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readAllFile__systemZio_434)(FILE* file, NI64 len);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_LIB_PRIVATE N_NIMCALL(NI, readBuffer__systemZio_144)(FILE* f, void* buffer, NI len);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, endOfFile__systemZio_430)(FILE* f);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readAllBuffer__systemZio_421)(FILE* file);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
static N_INLINE(void, popSafePoint)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimLeaveFinally)(void);
N_LIB_PRIVATE N_NIMCALL(void, reraiseException)(void);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, readLine__systemZio_276)(FILE* f, NimStringDesc** line);
N_LIB_PRIVATE N_NOINLINE(void, raiseEOF__systemZio_117)(void) __attribute__((noreturn));
N_LIB_PRIVATE N_NIMCALL(NI, writeBuffer__systemZio_176)(FILE* f, void* buffer, NI len);
N_LIB_PRIVATE N_NIMCALL(void, write__systemZio_220)(FILE* f, NimStringDesc* s);
N_LIB_PRIVATE N_NIMCALL(tySequence__sM4lkSb7zS6F7OVMvW9cffQ*, newSeq__systemZio_594)(NI len);
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_4, "kernel32", 8);
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_5, "kernel32", 8);
extern TNimType NTIrefioerror__HMIVdYjdZYWskTmTQVo5BQ_;
extern TNimType NTIioerror__iLZrPn9anoh9ad1MmO0RczFw_;
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_10, "cannot write string to file", 27);
N_LIB_PRIVATE NIM_CONST tyArray__Djap3EijveoDksCG9bY8s5w FormatOpen__systemZio_477 = {"rbN",
"wbN",
"w+bN",
"r+bN",
"abN"}
;
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_11, "cannot open: ", 13);
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_20, "error: ", 7);
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_21, " `", 2);
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_22, "`", 1);
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_23, "errno: ", 7);
extern TNimType NTIrefeoferror__LEclZrWX2FQAodlapxGITw_;
extern TNimType NTIeoferror__KGSY1JdrNB7Xi8KDhXFhSg_;
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_25, "EOF reached", 11);
N_LIB_PRIVATE TNimType NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_;
N_LIB_PRIVATE TNimType NTIfile__XBeRj4rw9bUuE7CB3DS1rgg_;
N_LIB_PRIVATE TNimType NTIfilehandle__2gIj3gQlK3HZJjQaYCP6ZQ_;
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_28, "cannot set file position", 24);
STRING_LITERAL(TM__MnCJ0VAmeZ9aTATUB39cx60Q_29, "cannot retrieve file position", 29);
static void* TM__MnCJ0VAmeZ9aTATUB39cx60Q_2;
tyProc__YrlAFY4fseJeExebH9aRGbw Dl_436208173_;
tyProc__YrlAFY4fseJeExebH9aRGbw Dl_436208175_;
extern tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ gch__system_5272;
tyProc__PUnN9cBvfpDX0GlY5QGXGXw Dl_436207900_;
tyProc__9bXer9a4ps9aSGctILcxWReVw Dl_436207906_;
tyProc__aO673xGTLLxou7P7GxoCXA Dl_436207907_;
tyProc__im9buRnIvptJfzdASYMEbBA Dl_436207915_;
extern TSafePoint* excHandler__system_2567;
extern TSafePoint* excHandler__system_2567;
extern TSafePoint* excHandler__system_2567;
extern TSafePoint* excHandler__system_2567;
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s) {
	NCSTRING result;
	result = (NCSTRING)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (s == ((NimStringDesc*) NIM_NIL));
		if (T3_) goto LA4_;
		T3_ = ((*s).Sup.len == ((NI) 0));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = "";
	}
	goto LA1_;
	LA5_: ;
	{
		result = ((NCSTRING) ((*s).data));
	}
	LA1_: ;
	return result;
}
static N_INLINE(NI, minuspercent___system_716)(NI x, NI y) {
	NI result;
	result = (NI)0;
	result = ((NI) ((NU)((NU32)(((NU) (x))) - (NU32)(((NU) (y))))));
	return result;
}
static N_INLINE(NIM_BOOL, ltpercent___system_1005)(NI x, NI y) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	result = ((NU32)(((NU) (x))) < (NU32)(((NU) (y))));
	return result;
}
static N_INLINE(void, rtlAddZCT__system_5368)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
	addZCT__system_5319((&gch__system_5272.zct), c);
}
static N_INLINE(void, decRef__system_5370)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
	(*c).refcount = minuspercent___system_716((*c).refcount, ((NI) 8));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = ltpercent___system_1005((*c).refcount, ((NI) 8));
		if (!T3_) goto LA4_;
		rtlAddZCT__system_5368(c);
	}
	LA4_: ;
}
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__system_5325)(void* usr) {
	tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* result;
	NI T1_;
	result = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
	T1_ = (NI)0;
	T1_ = minuspercent___system_716(((NI) (ptrdiff_t) (usr)), ((NI) 8));
	result = ((tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*) (T1_));
	return result;
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T1_;
	T1_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
	T1_ = usrToCell__system_5325(p);
	decRef__system_5370(T1_);
}
static N_INLINE(NI, pluspercent___system_696)(NI x, NI y) {
	NI result;
	result = (NI)0;
	result = ((NI) ((NU)((NU32)(((NU) (x))) + (NU32)(((NU) (y))))));
	return result;
}
static N_INLINE(void, incRef__system_5363)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
	(*c).refcount = pluspercent___system_696((*c).refcount, ((NI) 8));
}
static N_INLINE(void, asgnRef)(void** dest, void* src) {
	{
		tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T5_;
		if (!!((src == NIM_NIL))) goto LA3_;
		T5_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
		T5_ = usrToCell__system_5325(src);
		incRef__system_5363(T5_);
	}
	LA3_: ;
	{
		tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T10_;
		if (!!(((*dest) == NIM_NIL))) goto LA8_;
		T10_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
		T10_ = usrToCell__system_5325((*dest));
		decRef__system_5370(T10_);
	}
	LA8_: ;
	(*dest) = src;
}
N_LIB_PRIVATE N_NOINLINE(void, raiseEIO__systemZio_96)(NimStringDesc* msg) {
	tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw* T1_;
	NimStringDesc* T2_;
	T1_ = NIM_NIL;
	T1_ = (tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw*) newObj((&NTIrefioerror__HMIVdYjdZYWskTmTQVo5BQ_), sizeof(tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw));
	(*T1_).Sup.Sup.Sup.m_type = (&NTIioerror__iLZrPn9anoh9ad1MmO0RczFw_);
	(*T1_).Sup.Sup.name = "IOError";
	T2_ = NIM_NIL;
	T2_ = (*T1_).Sup.Sup.message; (*T1_).Sup.Sup.message = copyStringRC1(msg);
	if (T2_) nimGCunrefNoCycle(T2_);
	asgnRef((void**) (&(*T1_).Sup.Sup.parent), ((Exception*) NIM_NIL));
	raiseExceptionEx((Exception*)T1_, "IOError", "raiseEIO", "io.nim", 153);
}
N_LIB_PRIVATE N_NIMCALL(void, writeWindows__systemZio_205)(FILE* f, NimStringDesc* s, NIM_BOOL doRaise) {
	int i;
	i = fprintf(f, "%s", nimToCStringConv(s));
	{
		while (1) {
			if (!(((NI) (i)) < (s ? s->Sup.len : 0))) goto LA2;
			{
				int w;
				if (!((NU8)(s->data[i]) == (NU8)(0))) goto LA5_;
				w = fputc(0, f);
				{
					if (!!((w == ((NI32) 0)))) goto LA9_;
					{
						if (!doRaise) goto LA13_;
						raiseEIO__systemZio_96(((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_10));
					}
					LA13_: ;
					goto LA1;
				}
				LA9_: ;
				i += ((NI) 1);
			}
			goto LA3_;
			LA5_: ;
			{
				int w_2;
				w_2 = fprintf(f, "%s", (&s->data[i]));
				{
					if (!(w_2 <= ((NI32) 0))) goto LA18_;
					{
						if (!doRaise) goto LA22_;
						raiseEIO__systemZio_96(((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_10));
					}
					LA22_: ;
					goto LA1;
				}
				LA18_: ;
				i += ((NI) (w_2));
			}
			LA3_: ;
		} LA2: ;
	} LA1: ;
}
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0) {
	size_t T4_;
	int T5_;
	{
		NimStringDesc** s;
		NI i;
		s = (NimStringDesc**)0;
		i = ((NI) 0);
		{
			while (1) {
				if (!(i < argsLen_0)) goto LA3;
				s = (&args[i]);
				writeWindows__systemZio_205(stdout, (*s), NIM_FALSE);
				i += ((NI) 1);
			} LA3: ;
		}
	}
	T4_ = (size_t)0;
	T4_ = fwrite(((void*) ("\012")), ((size_t) 1), ((size_t) 1), stdout);
	(void)(T4_);
	T5_ = (int)0;
	T5_ = fflush(stdout);
	(void)(T5_);
}
N_LIB_PRIVATE N_NIMCALL(int, getFileHandle__systemZio_248)(FILE* f) {
	int result;
	result = (int)0;
	result = _fileno(f);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, write__systemZio_220)(FILE* f, NimStringDesc* s) {
	writeWindows__systemZio_205(f, s, NIM_TRUE);
}
N_LIB_PRIVATE N_NIMCALL(void, flushFile__systemZio_246)(FILE* f) {
	int T1_;
	T1_ = (int)0;
	T1_ = fflush(f);
	(void)(T1_);
}
N_LIB_PRIVATE N_NIMCALL(void*, fopen__systemZio_463)(NCSTRING filename, NCSTRING mode) {
	void* result;
	NI16* f;
	NI16* m;
	result = (void*)0;
	f = newWideCString__systemZwidestrs_254(filename);
	m = newWideCString__systemZwidestrs_254(mode);
	result = _wfopen(f, m);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, open__systemZio_487)(FILE** f, NimStringDesc* filename, tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg mode, NI bufSize) {
	NIM_BOOL result;
	void* p;
	result = (NIM_BOOL)0;
	p = fopen__systemZio_463(nimToCStringConv(filename), FormatOpen__systemZio_477[(mode)- 0]);
	{
		FILE* f2;
		if (!!((p == NIM_NIL))) goto LA3_;
		f2 = ((FILE*) (p));
		result = NIM_TRUE;
		(*f) = ((FILE*) (p));
		{
			NIM_BOOL T7_;
			int T11_;
			T7_ = (NIM_BOOL)0;
			T7_ = (((NI) 0) < bufSize);
			if (!(T7_)) goto LA8_;
			T7_ = (bufSize <= ((NI) 2147483647));
			LA8_: ;
			if (!T7_) goto LA9_;
			T11_ = (int)0;
			T11_ = setvbuf((*f), NIM_NIL, _IOFBF, ((size_t) (bufSize)));
			(void)(T11_);
		}
		goto LA5_;
		LA9_: ;
		{
			int T15_;
			if (!(bufSize == ((NI) 0))) goto LA13_;
			T15_ = (int)0;
			T15_ = setvbuf((*f), NIM_NIL, _IONBF, ((size_t) 0));
			(void)(T15_);
		}
		goto LA5_;
		LA13_: ;
		LA5_: ;
	}
	LA3_: ;
	return result;
}
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__system_1727)(void* dest, void* source, NI size) {
	nimCopyMem(dest, source, size);
}
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	{
		if (!!((src == ((NimStringDesc*) NIM_NIL)))) goto LA3_;
		copyMem__system_1727(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
		(*dest).Sup.len += (*src).Sup.len;
	}
	LA3_: ;
}
N_LIB_PRIVATE N_NIMCALL(FILE*, open__systemZio_518)(NimStringDesc* filename, tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg mode, NI bufSize) {
	FILE* result;
	result = (FILE*)0;
	{
		NIM_BOOL T3_;
		tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw* T6_;
		NimStringDesc* T7_;
		T3_ = (NIM_BOOL)0;
		T3_ = open__systemZio_487(&result, filename, mode, bufSize);
		if (!!(T3_)) goto LA4_;
		T6_ = NIM_NIL;
		T6_ = (tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw*) newObj((&NTIrefioerror__HMIVdYjdZYWskTmTQVo5BQ_), sizeof(tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw));
		(*T6_).Sup.Sup.Sup.m_type = (&NTIioerror__iLZrPn9anoh9ad1MmO0RczFw_);
		(*T6_).Sup.Sup.name = "IOError";
		T7_ = NIM_NIL;
		T7_ = rawNewString((filename ? filename->Sup.len : 0) + 13);
appendString(T7_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_11));
appendString(T7_, filename);
		asgnRef((void**) (&(*T6_).Sup.Sup.message), T7_);
		asgnRef((void**) (&(*T6_).Sup.Sup.parent), ((Exception*) NIM_NIL));
		raiseExceptionEx((Exception*)T6_, "IOError", "open", "io.nim", 759);
	}
	LA4_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isatty__systemZio_301)(FILE* f) {
	NIM_BOOL result;
	int T1_;
	int T2_;
	result = (NIM_BOOL)0;
	T1_ = (int)0;
	T1_ = getFileHandle__systemZio_248(f);
	T2_ = (int)0;
	T2_ = _isatty(T1_);
	result = !((T2_ == ((NI32) 0)));
	return result;
}
N_LIB_PRIVATE N_NIMCALL(int, getOsFileHandle__systemZio_251)(FILE* f) {
	int result;
	int T1_;
	NI T2_;
	result = (int)0;
	T1_ = (int)0;
	T1_ = getFileHandle__systemZio_248(f);
	T2_ = (NI)0;
	T2_ = _get_osfhandle(T1_);
	result = ((int) (T2_));
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, close__systemZio_237)(FILE* f) {
	{
		int T5_;
		if (!!((f == 0))) goto LA3_;
		T5_ = (int)0;
		T5_ = fclose(f);
		(void)(T5_);
	}
	LA3_: ;
}
static N_INLINE(NIM_BOOL, eqeq___system_7778)(NCSTRING x, NCSTRING y) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	{
		if (!(((void*) (x)) == ((void*) (y)))) goto LA3_;
		result = NIM_TRUE;
	}
	goto LA1_;
	LA3_: ;
	{
		NIM_BOOL T6_;
		T6_ = (NIM_BOOL)0;
		T6_ = (x == 0);
		if (T6_) goto LA7_;
		T6_ = (y == 0);
		LA7_: ;
		if (!T6_) goto LA8_;
		result = NIM_FALSE;
	}
	goto LA1_;
	LA8_: ;
	{
		int T11_;
		T11_ = (int)0;
		T11_ = strcmp(x, y);
		result = (T11_ == ((NI32) 0));
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, checkErr__systemZio_141)(FILE* f) {
	{
		int T3_;
		NimStringDesc* msg;
		NimStringDesc* T6_;
		NimStringDesc* T7_;
		NCSTRING T8_;
		NimStringDesc* T9_;
		T3_ = (int)0;
		T3_ = ferror(f);
		if (!!((T3_ == ((NI32) 0)))) goto LA4_;
		T6_ = NIM_NIL;
		T7_ = NIM_NIL;
		T7_ = dollar___systemZdollars_3(((NI) (errno)));
		T8_ = (NCSTRING)0;
		T8_ = strerror(errno);
		T9_ = NIM_NIL;
		T9_ = cstrToNimstr(T8_);
		T6_ = rawNewString((T7_ ? T7_->Sup.len : 0) + (T9_ ? T9_->Sup.len : 0) + 10);
appendString(T6_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_23));
appendString(T6_, T7_);
appendString(T6_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_21));
appendString(T6_, T9_);
appendString(T6_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_22));
		msg = T6_;
		clearerr(f);
		raiseEIO__systemZio_96(msg);
	}
	LA4_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, readLine__systemZio_276)(FILE* f, NimStringDesc** line) {
	NIM_BOOL result;
	NI pos;
	NI sp;
{	result = (NIM_BOOL)0;
	{
		NIM_BOOL T3_;
		NI32 numberOfCharsRead;
		NI16* buffer;
		T3_ = (NIM_BOOL)0;
		T3_ = isatty__systemZio_301(f);
		if (!T3_) goto LA4_;
		numberOfCharsRead = ((NI32) 0);
		buffer = newWideCString__systemZwidestrs_231("", ((NI) 2048));
		{
			int T8_;
			NI32 T9_;
			NI32 error;
			NimStringDesc* errorMsg;
			NI16* msgbuf;
			NimStringDesc* T21_;
			NimStringDesc* T22_;
			T8_ = (int)0;
			T8_ = getOsFileHandle__systemZio_251(f);
			T9_ = (NI32)0;
			T9_ = Dl_436207900_(T8_, ((void*) ((&buffer[((NI) 0)]))), ((NI32) 2048), (&numberOfCharsRead), NIM_NIL);
			if (!(T9_ == ((NI32) 0))) goto LA10_;
			error = Dl_436207906_();
			errorMsg = NIM_NIL;
			msgbuf = NIM_NIL;
			{
				NI32 T14_;
				T14_ = (NI32)0;
				T14_ = Dl_436207907_(((NI32) 4864), NIM_NIL, error, ((NI32) 0), ((void*) (&msgbuf)), ((NI32) 0), NIM_NIL);
				if (!!((T14_ == ((NI32) 0)))) goto LA15_;
				errorMsg = dollar___systemZwidestrs_324(msgbuf);
				{
					if (!!((msgbuf == ((NI16*) NIM_NIL)))) goto LA19_;
					Dl_436207915_(((void*) (msgbuf)));
				}
				LA19_: ;
			}
			LA15_: ;
			T21_ = NIM_NIL;
			T22_ = NIM_NIL;
			T22_ = dollar___systemZdollars_3(((NI) (error)));
			T21_ = rawNewString((T22_ ? T22_->Sup.len : 0) + (errorMsg ? errorMsg->Sup.len : 0) + 10);
appendString(T21_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_20));
appendString(T21_, T22_);
appendString(T21_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_21));
appendString(T21_, errorMsg);
appendString(T21_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_22));
			raiseEIO__systemZio_96(T21_);
		}
		LA10_: ;
		numberOfCharsRead -= ((NI) 2);
		{
			NI32 i;
			NI32 res;
			i = (NI32)0;
			res = ((NI32) 0);
			{
				while (1) {
					if (!(res < numberOfCharsRead)) goto LA25;
					i = res;
					{
						if (!(((NU16) (buffer[i])) == ((NU16) 26))) goto LA28_;
						close__systemZio_237(f);
						{
							if (!(i == ((NI32) 0))) goto LA32_;
							unsureAsgnRef((void**) (&(*line)), ((NimStringDesc*) NIM_NIL));
							result = NIM_FALSE;
							goto BeforeRet_;
						}
						LA32_: ;
						numberOfCharsRead = i;
						goto LA23;
					}
					LA28_: ;
					res += ((NI) 1);
				} LA25: ;
			}
		} LA23: ;
		buffer[numberOfCharsRead] = ((NI16) 0);
		unsureAsgnRef((void**) (&(*line)), dollar___systemZwidestrs_324(buffer));
		result = NIM_TRUE;
		goto BeforeRet_;
	}
	LA4_: ;
	pos = ((NI) 0);
	sp = ((((*line) ? (*line)->Sup.len : 0) >= ((NI) 80)) ? ((*line) ? (*line)->Sup.len : 0) : ((NI) 80));
	unsureAsgnRef((void**) (&(*line)), setLengthStr((*line), ((NI) (sp))));
	{
		while (1) {
			NIM_BOOL fgetsSuccess;
			void* m;
			{
				NI i_2;
				NI i_3;
				i_2 = (NI)0;
				i_3 = ((NI) 0);
				{
					while (1) {
						if (!(i_3 < sp)) goto LA38;
						i_2 = i_3;
						(*line)->data[(NI)(pos + i_2)] = 10;
						i_3 += ((NI) 1);
					} LA38: ;
				}
			}
			fgetsSuccess = (NIM_BOOL)0;
			{
				while (1) {
					{
						NCSTRING T42_;
						NIM_BOOL T43_;
						T42_ = (NCSTRING)0;
						T42_ = fgets(((NCSTRING) ((&(*line)->data[pos]))), ((int) (sp)), f);
						T43_ = (NIM_BOOL)0;
						T43_ = eqeq___system_7778(T42_, ((NCSTRING) NIM_NIL));
						fgetsSuccess = !(T43_);
						{
							if (!fgetsSuccess) goto LA46_;
							goto LA39;
						}
						LA46_: ;
						{
							if (!(errno == EINTR)) goto LA50_;
							errno = ((int) 0);
							clearerr(f);
							goto LA41;
						}
						LA50_: ;
						checkErr__systemZio_141(f);
						goto LA39;
					} LA41: ;
				}
			} LA39: ;
			m = memchr(((void*) ((&(*line)->data[pos]))), ((int) 10), ((size_t) (sp)));
			{
				NI last;
				NIM_BOOL T75_;
				if (!!((m == NIM_NIL))) goto LA54_;
				last = (NI)(((NI) (ptrdiff_t) (m)) - ((NI) (ptrdiff_t) ((&(*line)->data[((NI) 0)]))));
				{
					NIM_BOOL T58_;
					NIM_BOOL T62_;
					T58_ = (NIM_BOOL)0;
					T58_ = (((NI) 0) < last);
					if (!(T58_)) goto LA59_;
					T58_ = ((NU8)((*line)->data[(NI)(last - ((NI) 1))]) == (NU8)(13));
					LA59_: ;
					if (!T58_) goto LA60_;
					unsureAsgnRef((void**) (&(*line)), setLengthStr((*line), ((NI) ((NI)(last - ((NI) 1))))));
					T62_ = (NIM_BOOL)0;
					T62_ = (((NI) 1) < last);
					if (T62_) goto LA63_;
					T62_ = fgetsSuccess;
					LA63_: ;
					result = T62_;
					goto BeforeRet_;
				}
				goto LA56_;
				LA60_: ;
				{
					NIM_BOOL T65_;
					T65_ = (NIM_BOOL)0;
					T65_ = (((NI) 0) < last);
					if (!(T65_)) goto LA66_;
					T65_ = ((NU8)((*line)->data[(NI)(last - ((NI) 1))]) == (NU8)(0));
					LA66_: ;
					if (!T65_) goto LA67_;
					{
						NIM_BOOL T71_;
						T71_ = (NIM_BOOL)0;
						T71_ = (last < (NI)((NI)(pos + sp) - ((NI) 1)));
						if (!(T71_)) goto LA72_;
						T71_ = !(((NU8)((*line)->data[(NI)(last + ((NI) 1))]) == (NU8)(0)));
						LA72_: ;
						if (!T71_) goto LA73_;
						last -= ((NI) 1);
					}
					LA73_: ;
				}
				goto LA56_;
				LA67_: ;
				LA56_: ;
				unsureAsgnRef((void**) (&(*line)), setLengthStr((*line), ((NI) (last))));
				T75_ = (NIM_BOOL)0;
				T75_ = (((NI) 0) < last);
				if (T75_) goto LA76_;
				T75_ = fgetsSuccess;
				LA76_: ;
				result = T75_;
				goto BeforeRet_;
			}
			goto LA52_;
			LA54_: ;
			{
				sp -= ((NI) 1);
			}
			LA52_: ;
			pos += sp;
			sp = ((NI) 128);
			unsureAsgnRef((void**) (&(*line)), setLengthStr((*line), ((NI) ((NI)(pos + sp)))));
		}
	}
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, pushSafePoint)(TSafePoint* s) {
	(*s).prev = excHandler__system_2567;
	excHandler__system_2567 = s;
}
N_LIB_PRIVATE N_NIMCALL(NI64, rawFileSize__systemZio_426)(FILE* file) {
	NI64 result;
	NI64 oldPos;
	int T1_;
	int T2_;
	result = (NI64)0;
	oldPos = ftell(file);
	T1_ = (int)0;
	T1_ = fseek(file, IL64(0), ((int) 2));
	(void)(T1_);
	result = ftell(file);
	T2_ = (int)0;
	T2_ = fseek(file, oldPos, ((int) 0));
	(void)(T2_);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, readBuffer__systemZio_144)(FILE* f, void* buffer, NI len) {
	NI result;
	size_t T1_;
	result = (NI)0;
	T1_ = (size_t)0;
	T1_ = fread(buffer, ((size_t) 1), ((size_t) (len)), f);
	result = ((NI) (T1_));
	{
		if (!!((result == ((NI) (len))))) goto LA4_;
		checkErr__systemZio_141(f);
	}
	LA4_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, endOfFile__systemZio_430)(FILE* f) {
	NIM_BOOL result;
	int c;
	int T1_;
{	result = (NIM_BOOL)0;
	c = fgetc(f);
	T1_ = (int)0;
	T1_ = ungetc(c, f);
	(void)(T1_);
	result = (c < ((NI32) 0));
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readAllBuffer__systemZio_421)(FILE* file) {
	NimStringDesc* result;
	NimStringDesc* buffer;
	result = NIM_NIL;
	result = ((NimStringDesc*) NIM_NIL);
	buffer = mnewString(((NI) 4000));
	{
		while (1) {
			NI bytesRead;
			bytesRead = readBuffer__systemZio_144(file, ((void*) ((&buffer->data[((NI) 0)]))), ((NI) 4000));
			{
				if (!(bytesRead == ((NI) 4000))) goto LA5_;
				result = resizeString(result, (buffer ? buffer->Sup.len : 0) + 0);
appendString(result, buffer);
			}
			goto LA3_;
			LA5_: ;
			{
				buffer = setLengthStr(buffer, ((NI) (bytesRead)));
				result = resizeString(result, (buffer ? buffer->Sup.len : 0) + 0);
appendString(result, buffer);
				goto LA1;
			}
			LA3_: ;
		}
	} LA1: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readAllFile__systemZio_434)(FILE* file, NI64 len) {
	NimStringDesc* result;
	NI bytes;
	result = NIM_NIL;
	result = mnewString(((NI) (len)));
	bytes = readBuffer__systemZio_144(file, ((void*) ((&result->data[((NI) 0)]))), ((NI) (len)));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = endOfFile__systemZio_430(file);
		if (!T3_) goto LA4_;
		{
			if (!(((NI64) (bytes)) < len)) goto LA8_;
			result = setLengthStr(result, ((NI) (bytes)));
		}
		LA8_: ;
	}
	goto LA1_;
	LA4_: ;
	{
		NimStringDesc* T11_;
		T11_ = NIM_NIL;
		T11_ = readAllBuffer__systemZio_421(file);
		result = resizeString(result, (T11_ ? T11_->Sup.len : 0) + 0);
appendString(result, T11_);
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readAll__systemZio_443)(FILE* file) {
	NimStringDesc* result;
	NI64 len;
	result = NIM_NIL;
	{
		if (!!((file == stdin))) goto LA3_;
		len = rawFileSize__systemZio_426(file);
	}
	goto LA1_;
	LA3_: ;
	{
		len = IL64(-1);
	}
	LA1_: ;
	{
		if (!(IL64(0) < len)) goto LA8_;
		result = readAllFile__systemZio_434(file, len);
	}
	goto LA6_;
	LA8_: ;
	{
		result = readAllBuffer__systemZio_421(file);
	}
	LA6_: ;
	return result;
}
static N_INLINE(void, popSafePoint)(void) {
	excHandler__system_2567 = (*excHandler__system_2567).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readFile__systemZio_562)(NimStringDesc* filename) {
	NimStringDesc* volatile result;
	FILE* f;
	result = NIM_NIL;
	f = ((FILE*) NIM_NIL);
	{
		NIM_BOOL T3_;
		TSafePoint TM__MnCJ0VAmeZ9aTATUB39cx60Q_24;
		T3_ = (NIM_BOOL)0;
		T3_ = open__systemZio_487(&f, filename, ((tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg) 0), ((NI) -1));
		if (!T3_) goto LA4_;
		pushSafePoint(&TM__MnCJ0VAmeZ9aTATUB39cx60Q_24);
		TM__MnCJ0VAmeZ9aTATUB39cx60Q_24.status = setjmp(TM__MnCJ0VAmeZ9aTATUB39cx60Q_24.context);
		if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_24.status == 0) {
		result = readAll__systemZio_443(f);
		popSafePoint();
		}
		else {
			popSafePoint();
		}
		{
			close__systemZio_237(f);
			if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_24.status != 0) nimLeaveFinally();
		}
		if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_24.status != 0) reraiseException();
	}
	goto LA1_;
	LA4_: ;
	{
		tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw* T9_;
		NimStringDesc* T10_;
		T9_ = NIM_NIL;
		T9_ = (tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw*) newObj((&NTIrefioerror__HMIVdYjdZYWskTmTQVo5BQ_), sizeof(tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw));
		(*T9_).Sup.Sup.Sup.m_type = (&NTIioerror__iLZrPn9anoh9ad1MmO0RczFw_);
		(*T9_).Sup.Sup.name = "IOError";
		T10_ = NIM_NIL;
		T10_ = rawNewString((filename ? filename->Sup.len : 0) + 13);
appendString(T10_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_11));
appendString(T10_, filename);
		asgnRef((void**) (&(*T9_).Sup.Sup.message), T10_);
		asgnRef((void**) (&(*T9_).Sup.Sup.parent), ((Exception*) NIM_NIL));
		raiseExceptionEx((Exception*)T9_, "IOError", "readFile", "io.nim", 870);
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, readChars__systemZio_156)(FILE* f, NIM_CHAR* a, NI aLen_0) {
	NI result;
	result = (NI)0;
	result = readBuffer__systemZio_144(f, ((void*) ((&a[((NI) 0)]))), ((NI) (aLen_0)));
	return result;
}
N_LIB_PRIVATE N_NOINLINE(void, raiseEOF__systemZio_117)(void) {
	tyObject_EOFError__KGSY1JdrNB7Xi8KDhXFhSg* T1_;
	NimStringDesc* T2_;
	T1_ = NIM_NIL;
	T1_ = (tyObject_EOFError__KGSY1JdrNB7Xi8KDhXFhSg*) newObj((&NTIrefeoferror__LEclZrWX2FQAodlapxGITw_), sizeof(tyObject_EOFError__KGSY1JdrNB7Xi8KDhXFhSg));
	(*T1_).Sup.Sup.Sup.Sup.m_type = (&NTIeoferror__KGSY1JdrNB7Xi8KDhXFhSg_);
	(*T1_).Sup.Sup.Sup.name = "EOFError";
	T2_ = NIM_NIL;
	T2_ = (*T1_).Sup.Sup.Sup.message; (*T1_).Sup.Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_25));
	if (T2_) nimGCunrefNoCycle(T2_);
	asgnRef((void**) (&(*T1_).Sup.Sup.Sup.parent), ((Exception*) NIM_NIL));
	raiseExceptionEx((Exception*)T1_, "EOFError", "raiseEOF", "io.nim", 156);
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, readLine__systemZio_364)(FILE* f) {
	NimStringDesc* result;
	result = NIM_NIL;
	result = rawNewString(((NI) 80));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = readLine__systemZio_276(f, (&result));
		if (!!(T3_)) goto LA4_;
		raiseEOF__systemZio_117();
	}
	LA4_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, writeBuffer__systemZio_176)(FILE* f, void* buffer, NI len) {
	NI result;
	size_t T1_;
	result = (NI)0;
	T1_ = (size_t)0;
	T1_ = fwrite(buffer, ((size_t) 1), ((size_t) (len)), f);
	result = ((NI) (T1_));
	checkErr__systemZio_141(f);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, readBytes__icZrodfiles_159)(FILE* f, NU8* a, NI aLen_0, NI start, NI len) {
	NI result;
	result = (NI)0;
	result = readBuffer__systemZio_144(f, ((void*) ((&a[start]))), len);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, writeBytes__icZrodfiles_123)(FILE* f, NU8* a, NI aLen_0, NI start, NI len) {
	NI result;
	NI8* x;
	result = (NI)0;
	x = ((NI8*) (a));
	result = writeBuffer__systemZio_176(f, ((void*) ((&x[start]))), len);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, writeFile__systemZio_567)(NimStringDesc* filename, NimStringDesc* content) {
	FILE* f;
	f = ((FILE*) NIM_NIL);
	{
		NIM_BOOL T3_;
		TSafePoint TM__MnCJ0VAmeZ9aTATUB39cx60Q_26;
		T3_ = (NIM_BOOL)0;
		T3_ = open__systemZio_487(&f, filename, ((tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg) 1), ((NI) -1));
		if (!T3_) goto LA4_;
		pushSafePoint(&TM__MnCJ0VAmeZ9aTATUB39cx60Q_26);
		TM__MnCJ0VAmeZ9aTATUB39cx60Q_26.status = setjmp(TM__MnCJ0VAmeZ9aTATUB39cx60Q_26.context);
		if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_26.status == 0) {
		write__systemZio_220(f, content);
		popSafePoint();
		}
		else {
			popSafePoint();
		}
		{
			close__systemZio_237(f);
			if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_26.status != 0) nimLeaveFinally();
		}
		if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_26.status != 0) reraiseException();
	}
	goto LA1_;
	LA4_: ;
	{
		tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw* T9_;
		NimStringDesc* T10_;
		T9_ = NIM_NIL;
		T9_ = (tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw*) newObj((&NTIrefioerror__HMIVdYjdZYWskTmTQVo5BQ_), sizeof(tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw));
		(*T9_).Sup.Sup.Sup.m_type = (&NTIioerror__iLZrPn9anoh9ad1MmO0RczFw_);
		(*T9_).Sup.Sup.name = "IOError";
		T10_ = NIM_NIL;
		T10_ = rawNewString((filename ? filename->Sup.len : 0) + 13);
appendString(T10_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_11));
appendString(T10_, filename);
		asgnRef((void**) (&(*T9_).Sup.Sup.message), T10_);
		asgnRef((void**) (&(*T9_).Sup.Sup.parent), ((Exception*) NIM_NIL));
		raiseExceptionEx((Exception*)T9_, "IOError", "writeFile", "io.nim", 883);
	}
	LA1_: ;
}
N_LIB_PRIVATE N_NIMCALL(tySequence__sM4lkSb7zS6F7OVMvW9cffQ*, readLines__systemZio_585)(NimStringDesc* filename, NI n) {
	tySequence__sM4lkSb7zS6F7OVMvW9cffQ* volatile result;
	FILE* f;
	result = NIM_NIL;
	f = ((FILE*) NIM_NIL);
	{
		NIM_BOOL T3_;
		TSafePoint TM__MnCJ0VAmeZ9aTATUB39cx60Q_27;
		T3_ = (NIM_BOOL)0;
		T3_ = open__systemZio_487(&f, filename, ((tyEnum_FileMode__ZJfK20XeZ9bv2j1pZjw9aswg) 0), ((NI) -1));
		if (!T3_) goto LA4_;
		pushSafePoint(&TM__MnCJ0VAmeZ9aTATUB39cx60Q_27);
		TM__MnCJ0VAmeZ9aTATUB39cx60Q_27.status = setjmp(TM__MnCJ0VAmeZ9aTATUB39cx60Q_27.context);
		if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_27.status == 0) {
		result = newSeq__systemZio_594(n);
		{
			NI i;
			NI colontmp_;
			NI res;
			i = (NI)0;
			colontmp_ = (NI)0;
			colontmp_ = (NI)(((NI) (n)) - ((NI) 1));
			res = ((NI) 0);
			{
				while (1) {
					if (!(res <= colontmp_)) goto LA8;
					i = res;
					{
						NIM_BOOL T11_;
						T11_ = (NIM_BOOL)0;
						T11_ = readLine__systemZio_276(f, (&result->data[i]));
						if (!!(T11_)) goto LA12_;
						raiseEOF__systemZio_117();
					}
					LA12_: ;
					res += ((NI) 1);
				} LA8: ;
			}
		}
		popSafePoint();
		}
		else {
			popSafePoint();
		}
		{
			close__systemZio_237(f);
			if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_27.status != 0) nimLeaveFinally();
		}
		if (TM__MnCJ0VAmeZ9aTATUB39cx60Q_27.status != 0) reraiseException();
	}
	goto LA1_;
	LA4_: ;
	{
		tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw* T17_;
		NimStringDesc* T18_;
		T17_ = NIM_NIL;
		T17_ = (tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw*) newObj((&NTIrefioerror__HMIVdYjdZYWskTmTQVo5BQ_), sizeof(tyObject_IOError__iLZrPn9anoh9ad1MmO0RczFw));
		(*T17_).Sup.Sup.Sup.m_type = (&NTIioerror__iLZrPn9anoh9ad1MmO0RczFw_);
		(*T17_).Sup.Sup.name = "IOError";
		T18_ = NIM_NIL;
		T18_ = rawNewString((filename ? filename->Sup.len : 0) + 13);
appendString(T18_, ((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_11));
appendString(T18_, filename);
		asgnRef((void**) (&(*T17_).Sup.Sup.message), T18_);
		asgnRef((void**) (&(*T17_).Sup.Sup.parent), ((Exception*) NIM_NIL));
		raiseExceptionEx((Exception*)T17_, "IOError", "readLines", "io.nim", 913);
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, setFilePos__systemZio_524)(FILE* f, NI64 pos, tyEnum_FileSeekPos__I9aQjuvWxs8BspGbxwsngWw relativeTo) {
	{
		int T3_;
		T3_ = (int)0;
		T3_ = fseek(f, pos, ((int) (relativeTo)));
		if (!!((T3_ == ((NI32) 0)))) goto LA4_;
		raiseEIO__systemZio_96(((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_28));
	}
	LA4_: ;
}
N_LIB_PRIVATE N_NIMCALL(NI64, getFilePos__systemZio_537)(FILE* f) {
	NI64 result;
	result = (NI64)0;
	result = ftell(f);
	{
		if (!(result < IL64(0))) goto LA3_;
		raiseEIO__systemZio_96(((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_29));
	}
	LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, write__systemZio_397)(FILE* f, NimStringDesc** a, NI aLen_0) {
	{
		NimStringDesc** x;
		NI i;
		x = (NimStringDesc**)0;
		i = ((NI) 0);
		{
			while (1) {
				if (!(i < aLen_0)) goto LA3;
				x = (&a[i]);
				write__systemZio_220(f, (*x));
				i += ((NI) 1);
			} LA3: ;
		}
	}
}
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatslibatssystematsiodotnim_Init000)(void) {
{
	int T1_;
	int T2_;
	int T3_;
	NI32 T4_;
	NI32 T5_;
	T1_ = (int)0;
	T1_ = _fileno(stdin);
	_setmode(T1_, _O_BINARY);
	T2_ = (int)0;
	T2_ = _fileno(stdout);
	_setmode(T2_, _O_BINARY);
	T3_ = (int)0;
	T3_ = _fileno(stderr);
	_setmode(T3_, _O_BINARY);
	T4_ = (NI32)0;
	T4_ = Dl_436208173_(((unsigned int) 65001));
	(void)(T4_);
	T5_ = (NI32)0;
	T5_ = Dl_436208175_(((unsigned int) 65001));
	(void)(T5_);
}
}

N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatslibatssystematsiodotnim_DatInit000)(void) {
static TNimNode TM__MnCJ0VAmeZ9aTATUB39cx60Q_0[1];
NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_.size = sizeof(void*);
NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_.align = NIM_ALIGNOF(void*);
NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_.kind = 18;
NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_.base = 0;
NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_.flags = 1;
NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_.node = &TM__MnCJ0VAmeZ9aTATUB39cx60Q_0[0];
NTIfile__XBeRj4rw9bUuE7CB3DS1rgg_.size = sizeof(FILE*);
NTIfile__XBeRj4rw9bUuE7CB3DS1rgg_.align = NIM_ALIGNOF(FILE*);
NTIfile__XBeRj4rw9bUuE7CB3DS1rgg_.kind = 21;
NTIfile__XBeRj4rw9bUuE7CB3DS1rgg_.base = (&NTIcfile__MAWzaQJYFu3mlxj0Ppxhmw_);
NTIfile__XBeRj4rw9bUuE7CB3DS1rgg_.flags = 3;
NTIfilehandle__2gIj3gQlK3HZJjQaYCP6ZQ_.size = sizeof(int);
NTIfilehandle__2gIj3gQlK3HZJjQaYCP6ZQ_.align = NIM_ALIGNOF(int);
NTIfilehandle__2gIj3gQlK3HZJjQaYCP6ZQ_.kind = 34;
NTIfilehandle__2gIj3gQlK3HZJjQaYCP6ZQ_.base = 0;
NTIfilehandle__2gIj3gQlK3HZJjQaYCP6ZQ_.flags = 3;
if (!((TM__MnCJ0VAmeZ9aTATUB39cx60Q_2 = nimLoadLibrary(((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_4)))
)) nimLoadLibraryError(((NimStringDesc*) &TM__MnCJ0VAmeZ9aTATUB39cx60Q_5));
	Dl_436208173_ = (tyProc__YrlAFY4fseJeExebH9aRGbw) nimGetProcAddr(TM__MnCJ0VAmeZ9aTATUB39cx60Q_2, "SetConsoleOutputCP");
	Dl_436208175_ = (tyProc__YrlAFY4fseJeExebH9aRGbw) nimGetProcAddr(TM__MnCJ0VAmeZ9aTATUB39cx60Q_2, "SetConsoleCP");
	Dl_436207900_ = (tyProc__PUnN9cBvfpDX0GlY5QGXGXw) nimGetProcAddr(TM__MnCJ0VAmeZ9aTATUB39cx60Q_2, "ReadConsoleW");
	Dl_436207906_ = (tyProc__9bXer9a4ps9aSGctILcxWReVw) nimGetProcAddr(TM__MnCJ0VAmeZ9aTATUB39cx60Q_2, "GetLastError");
	Dl_436207907_ = (tyProc__aO673xGTLLxou7P7GxoCXA) nimGetProcAddr(TM__MnCJ0VAmeZ9aTATUB39cx60Q_2, "FormatMessageW");
	Dl_436207915_ = (tyProc__im9buRnIvptJfzdASYMEbBA) nimGetProcAddr(TM__MnCJ0VAmeZ9aTATUB39cx60Q_2, "LocalFree");
}

