/* Generated by Nim Compiler v2.2.10 */
#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
typedef struct tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA;
typedef struct tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A;
typedef struct tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA;
typedef struct tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q;
typedef struct tyObject_CatchableError__TCF9b1Y9b2ct0xPZvZnaY7gg tyObject_CatchableError__TCF9b1Y9b2ct0xPZvZnaY7gg;
typedef struct Exception Exception;
typedef struct tySequence__S89cE01OvNjsN9c71FKsSrqQ tySequence__S89cE01OvNjsN9c71FKsSrqQ;
typedef struct tySequence__S89cE01OvNjsN9c71FKsSrqQ_Content tySequence__S89cE01OvNjsN9c71FKsSrqQ_Content;
typedef struct tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ;
typedef struct tyObject_StackTraceEntry__RcJz5RXFIYjIseutvVFICA tyObject_StackTraceEntry__RcJz5RXFIYjIseutvVFICA;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
struct TNimTypeV2 {
	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
	void* vTable[SEQ_DECL_SIZE];
};
struct RootObj {
	TNimTypeV2* m_type;
};
typedef N_NIMCALL_PTR(void, tyProc__DXGqmuActUm0S3MKNsreGw) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
typedef N_NIMCALL_PTR(NIM_BOOL, tyProc__Fono1uAye9aDS77o2sqPoIg) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
typedef N_NIMCALL_PTR(void, tyProc__zdMZVwOrDkH4aQdAWbmhfA) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NI pos_p1);
typedef N_NIMCALL_PTR(NI, tyProc__hJ4RdVQy2jQRw0zV2TsXng) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
typedef N_NIMCALL_PTR(NI, tyProc__e59bWp0wEul4j9a5QwZc9bB9cQ) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA slice_p2);
typedef N_NIMCALL_PTR(NIM_BOOL, tyProc__7tjyszhbbb180aOkghqCyw) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* line_p1);
typedef N_NIMCALL_PTR(NI, tyProc__a9cZWdPu9bXGVJA7dJZ9aX8bQ) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
typedef N_NIMCALL_PTR(void, tyProc__BwfRbL9cjs7RFNMDfL4200g) (tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
struct tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w {
	RootObj Sup;
	tyProc__DXGqmuActUm0S3MKNsreGw closeImpl;
	tyProc__Fono1uAye9aDS77o2sqPoIg atEndImpl;
	tyProc__zdMZVwOrDkH4aQdAWbmhfA setPositionImpl;
	tyProc__hJ4RdVQy2jQRw0zV2TsXng getPositionImpl;
	tyProc__e59bWp0wEul4j9a5QwZc9bB9cQ readDataStrImpl;
	tyProc__7tjyszhbbb180aOkghqCyw readLineImpl;
	tyProc__a9cZWdPu9bXGVJA7dJZ9aX8bQ readDataImpl;
	tyProc__a9cZWdPu9bXGVJA7dJZ9aX8bQ peekDataImpl;
	tyProc__BwfRbL9cjs7RFNMDfL4200g writeDataImpl;
	tyProc__DXGqmuActUm0S3MKNsreGw flushImpl;
};
struct tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A {
	NI rc;
	NI rootIdx;
};
struct tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA {
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w Sup;
	FILE* f;
};
typedef NU8 tyEnum_FileSeekPos__QFEvOmw2SocDVWqi9ciAztA;
struct tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA {
	NI a;
	NI b;
};
struct tySequence__S89cE01OvNjsN9c71FKsSrqQ {
  NI len; tySequence__S89cE01OvNjsN9c71FKsSrqQ_Content* p;
};
struct Exception {
	RootObj Sup;
	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__S89cE01OvNjsN9c71FKsSrqQ trace;
	Exception* up;
};
struct tyObject_CatchableError__TCF9b1Y9b2ct0xPZvZnaY7gg {
	Exception Sup;
};
struct tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q {
	tyObject_CatchableError__TCF9b1Y9b2ct0xPZvZnaY7gg Sup;
};
struct tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ {
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w Sup;
	NimStringV2 data;
	NI pos;
};
typedef NU8 tyEnum_FileMode__YkEVJbjDa9aPvYTBr8yiUWg;
struct tyObject_StackTraceEntry__RcJz5RXFIYjIseutvVFICA {
	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__S89cE01OvNjsN9c71FKsSrqQ_Content { NI cap; tyObject_StackTraceEntry__RcJz5RXFIYjIseutvVFICA data[SEQ_DECL_SIZE]; };
N_LIB_PRIVATE N_NIMCALL(void, writeData__pureZstreams_u175)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u805)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3500)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u980)(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, fsClose__pureZstreams_u971)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, close__stdZsyncio_u268)(FILE* f_p0);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, fsAtEnd__pureZstreams_u1038)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, endOfFile__stdZsyncio_u368)(FILE* f_p0);
N_LIB_PRIVATE N_NIMCALL(void, fsSetPosition__pureZstreams_u1041)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NI pos_p1);
N_LIB_PRIVATE N_NIMCALL(void, setFilePos__stdZsyncio_u496)(FILE* f_p0, NI64 pos_p1, tyEnum_FileSeekPos__QFEvOmw2SocDVWqi9ciAztA relativeTo_p2);
N_LIB_PRIVATE N_NIMCALL(NI, fsGetPosition__pureZstreams_u1044)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(NI64, getFilePos__stdZsyncio_u519)(FILE* f_p0);
N_LIB_PRIVATE N_NIMCALL(NI, fsReadDataStr__pureZstreams_u1052)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA slice_p2);
N_LIB_PRIVATE N_NIMCALL(NI, readBuffer__stdZsyncio_u165)(FILE* f_p0, void* buffer_p1, NI len_p2);
N_LIB_PRIVATE N_NIMCALL(NI, fsReadData__pureZstreams_u1047)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, fsReadLine__pureZstreams_u1068)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* line_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, readLine__stdZsyncio_u290)(FILE* f_p0, NimStringV2* line_p1);
N_LIB_PRIVATE N_NIMCALL(NI, fsPeekData__pureZstreams_u1058)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(void, fsWriteData__pureZstreams_u1064)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(NI, writeBuffer__stdZsyncio_u196)(FILE* f_p0, void* buffer_p1, NI len_p2);
N_LIB_PRIVATE N_NIMCALL(tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q*, newEIO__pureZstreams_u3)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___system_u8764)(tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___system_u2694)(NimStringV2* dest_p0, NimStringV2 src_p1);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e_p0, NCSTRING ename_p1, NCSTRING procname_p2, NCSTRING filename_p3, NI line_p4);
N_LIB_PRIVATE N_NIMCALL(void, fsFlush__pureZstreams_u1036)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, flushFile__stdZsyncio_u278)(FILE* f_p0);
static N_INLINE(void, nimIncRefCyclic)(void* p_p0, NIM_BOOL cyclic_p1);
static N_INLINE(NI, pluspercent___system_u785)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, atEnd__pureZstreams_u67)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(NIM_CHAR, readChar__pureZstreams_u209)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(NI, readData__pureZstreams_u79)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
static N_INLINE(void, nimAddCharV1)(NimStringV2* s_p0, NIM_CHAR c_p1);
N_LIB_PRIVATE N_NIMCALL(void, prepareAdd)(NimStringV2* s_p0, NI addLen_p1);
N_LIB_PRIVATE N_NIMCALL(void, setLengthStrV2)(NimStringV2* s_p0, NI newLen_p1);
static N_INLINE(void, prepareMutation__system_u2442)(NimStringV2* s_p0);
static N_INLINE(void, nimPrepareStrMutationV2)(NimStringV2* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimPrepareStrMutationImpl__system_u2430)(NimStringV2* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u612)(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__pureZstreams_u1121)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u632)(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___system_u2691)(NimStringV2 dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqsink___system_u2700)(NimStringV2* dest_p0, NimStringV2 src_p1);
N_LIB_PRIVATE N_NIMCALL(void, ssClose__pureZstreams_u826)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w*, eqdup___pureZstreams_u680)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* src_p0, NIM_BOOL cyclic_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, ssAtEnd__pureZstreams_u605)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, ssSetPosition__pureZstreams_u728)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NI pos_p1);
N_LIB_PRIVATE N_NIMCALL(NI, clamp__pureZstreams_u732)(NI x_p0, NI a_p1, NI b_p2);
N_LIB_PRIVATE N_NIMCALL(NI, ssGetPosition__pureZstreams_u738)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0);
N_LIB_PRIVATE N_NIMCALL(NI, ssReadDataStr__pureZstreams_u742)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA slice_p2);
static N_INLINE(void, copyMem__system_u1742)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NIMCALL(NI, ssReadData__pureZstreams_u799)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(NI, ssPeekData__pureZstreams_u810)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(void, ssWriteData__pureZstreams_u816)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, open__stdZsyncio_u412)(FILE** f_p0, NimStringV2 filename_p1, tyEnum_FileMode__YkEVJbjDa9aPvYTBr8yiUWg mode_p2, NI bufSize_p3);
N_LIB_PRIVATE N_NIMCALL(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*, newFileStream__pureZstreams_u1072)(FILE* f_p0);
N_LIB_PRIVATE TNimTypeV2 NTIv2__5UvDPztSlRBlwzg9bp1LtoA_;
extern TNimTypeV2 NTIv2__vBePDvr8fj01uTfaJy9aD3Q_;
static const struct {
  NI cap; NIM_CHAR data[22+1];
} TM__Ue7tnBcsL67VCiRfvt8q0A_3 = { 22 | NIM_STRLIT_FLAG, "cannot write to stream" };
static const NimStringV2 TM__Ue7tnBcsL67VCiRfvt8q0A_4 = {22, (NimStrPayload*)&TM__Ue7tnBcsL67VCiRfvt8q0A_3};
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__Ue7tnBcsL67VCiRfvt8q0A_5 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__Ue7tnBcsL67VCiRfvt8q0A_6 = {0, (NimStrPayload*)&TM__Ue7tnBcsL67VCiRfvt8q0A_5};
static const struct {
  NI cap; NIM_CHAR data[23+1];
} TM__Ue7tnBcsL67VCiRfvt8q0A_7 = { 23 | NIM_STRLIT_FLAG, "cannot read from stream" };
static const NimStringV2 TM__Ue7tnBcsL67VCiRfvt8q0A_8 = {23, (NimStrPayload*)&TM__Ue7tnBcsL67VCiRfvt8q0A_7};
N_LIB_PRIVATE TNimTypeV2 NTIv2__OvoQd4jSzPo0Qf5Vj9aPcAQ_;
static const NimStringV2 TM__Ue7tnBcsL67VCiRfvt8q0A_10 = {0, (NimStrPayload*)&TM__Ue7tnBcsL67VCiRfvt8q0A_5};
extern NIM_BOOL nimInErrorMode__system_u4146;
static NIM_CONST NU32 TM__Ue7tnBcsL67VCiRfvt8q0A_2[3] = {3701606400, 2112120064, 1271086848};
N_LIB_PRIVATE TNimTypeV2 NTIv2__5UvDPztSlRBlwzg9bp1LtoA_ = {.destructor = (void*)NIM_NIL, .size = sizeof(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA), .align = (NI16) NIM_ALIGNOF(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA), .depth = 2, .display = TM__Ue7tnBcsL67VCiRfvt8q0A_2, .traceImpl = (void*)NIM_NIL, .flags = 0};
static NIM_CONST NU32 TM__Ue7tnBcsL67VCiRfvt8q0A_9[3] = {3701606400, 2112120064, 4195383040};
N_LIB_PRIVATE TNimTypeV2 NTIv2__OvoQd4jSzPo0Qf5Vj9aPcAQ_ = {.destructor = (void*)rttiDestroy__pureZstreams_u1121, .size = sizeof(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ), .align = (NI16) NIM_ALIGNOF(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ), .depth = 2, .display = TM__Ue7tnBcsL67VCiRfvt8q0A_9, .traceImpl = (void*)NIM_NIL, .flags = 0};
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4146);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, writeData__pureZstreams_u175)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	(*s_p0).writeDataImpl(s_p0, buffer_p1, bufLen_p2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0) {
	NCSTRING result;
	{
		if (!(s_p0.len == ((NI)0))) goto LA3_;
		result = "";
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NCSTRING) ((*s_p0.p).data));
	}
LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, write__pureZstreams_u184)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2 x_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		if (!(((NI)0) < x_p1.len)) goto LA3_;
		writeData__pureZstreams_u175(s_p0, ((void*) (nimToCStringConv(x_p1))), x_p1.len);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
LA3_: ;
	}BeforeRet_: ;
}
static N_INLINE(NI, minuspercent___system_u805)(NI x_p0, NI y_p1) {
	NI result;
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
	return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
	NIM_BOOL result;
	result = NIM_FALSE;
	{
		tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A* cell_1;
		NI T5_;
		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		T5_ = (NI)0;
		T5_ = minuspercent___system_u805(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
		cell_1 = ((tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A*) (T5_));
		{
			if (!((NI)((*cell_1).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
			result = NIM_TRUE;
		}
		goto LA6_;
LA8_: ;
		{
			(*cell_1).rc = minuspercent___system_u805((*cell_1).rc, ((NI)16));
		}
LA6_: ;
		rememberCycle__system_u3500(result, cell_1, (*((TNimTypeV2**) (p_p0))));
	}
LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqsink___pureZstreams_u684)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w** dest_p0, tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* src_p1) {
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmp_;
	colontmp_ = (*dest_p0);
	(*dest_p0) = src_p1;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLastCyclicDyn(colontmp_);
		if (!T3_) goto LA4_;
		nimDestroyAndDispose(colontmp_);
	}
LA4_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u980)(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA* dest_p0) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLastCyclicDyn(dest_p0);
		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, fsClose__pureZstreams_u971)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		if (!!(((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f == ((FILE*) NIM_NIL)))) goto LA3_;
		close__stdZsyncio_u268((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		(*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f = ((FILE*) NIM_NIL);
	}
LA3_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, fsAtEnd__pureZstreams_u1038)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	result = endOfFile__stdZsyncio_u368((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, fsSetPosition__pureZstreams_u1041)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NI pos_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	setFilePos__stdZsyncio_u496((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f, ((NI64) (pos_p1)), ((tyEnum_FileSeekPos__QFEvOmw2SocDVWqi9ciAztA)0));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsGetPosition__pureZstreams_u1044)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	NI result;
	NI64 T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	T1_ = (NI64)0;
	T1_ = getFilePos__stdZsyncio_u519((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = ((NI) (T1_));
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsReadDataStr__pureZstreams_u1052)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA slice_p2) {
	NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	result = readBuffer__stdZsyncio_u165((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f, ((void*) ((&(*buffer_p1).p->data[slice_p2.a]))), ((NI)((NI)(slice_p2.b + ((NI)1)) - slice_p2.a)));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsReadData__pureZstreams_u1047)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	result = readBuffer__stdZsyncio_u165((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f, buffer_p1, (bufLen_p2));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, fsReadLine__pureZstreams_u1068)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* line_p1) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	result = readLine__stdZsyncio_u290((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f, line_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsPeekData__pureZstreams_u1058)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
	NI pos_1;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	pos_1 = fsGetPosition__pureZstreams_u1044(s_p0);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = readBuffer__stdZsyncio_u165((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f, buffer_p1, (bufLen_p2));
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	{
		LA1_:;
	}
	{
		oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
		fsSetPosition__pureZstreams_u1041(s_p0, pos_1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		*nimErr_ = oldNimErrFin1_;
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q*, newEIO__pureZstreams_u3)(NimStringV2 msg_p0) {
	tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q* result;
	result = NIM_NIL;
	eqdestroy___system_u8764(result);
	result = (tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q*) nimNewObj(sizeof(tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q), NIM_ALIGNOF(tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q));
	(*result).Sup.Sup.Sup.m_type = (&NTIv2__vBePDvr8fj01uTfaJy9aD3Q_);
	(*result).Sup.Sup.name = "IOError";
	eqcopy___system_u2694((&(*result).Sup.Sup.message), msg_p0);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, fsWriteData__pureZstreams_u1064)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		NI T3_;
		tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q* T6_;
		T3_ = (NI)0;
		T3_ = writeBuffer__stdZsyncio_u196((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f, buffer_p1, (bufLen_p2));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!!((T3_ == bufLen_p2))) goto LA4_;
		T6_ = NIM_NIL;
		T6_ = newEIO__pureZstreams_u3(TM__Ue7tnBcsL67VCiRfvt8q0A_4);
		if (NIM_UNLIKELY(*nimErr_)) {eqdestroy___system_u8764(T6_); goto BeforeRet_;}
		raiseExceptionEx((Exception*)T6_, "IOError", "fsWriteData", "streams.nim", 1357);
goto BeforeRet_;
	}
LA4_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, fsFlush__pureZstreams_u1036)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	flushFile__stdZsyncio_u278((*((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) (s_p0))).f);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*, newFileStream__pureZstreams_u1072)(FILE* f_p0) {
	tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA* result;
	result = NIM_NIL;
	eqdestroy___pureZstreams_u980(result);
	result = (tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) nimNewObj(sizeof(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA), NIM_ALIGNOF(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA));
	(*result).Sup.Sup.m_type = (&NTIv2__5UvDPztSlRBlwzg9bp1LtoA_);
	(*result).f = f_p0;
	(*result).Sup.closeImpl = fsClose__pureZstreams_u971;
	(*result).Sup.atEndImpl = fsAtEnd__pureZstreams_u1038;
	(*result).Sup.setPositionImpl = fsSetPosition__pureZstreams_u1041;
	(*result).Sup.getPositionImpl = fsGetPosition__pureZstreams_u1044;
	(*result).Sup.readDataStrImpl = fsReadDataStr__pureZstreams_u1052;
	(*result).Sup.readDataImpl = fsReadData__pureZstreams_u1047;
	(*result).Sup.readLineImpl = fsReadLine__pureZstreams_u1068;
	(*result).Sup.peekDataImpl = fsPeekData__pureZstreams_u1058;
	(*result).Sup.writeDataImpl = fsWriteData__pureZstreams_u1064;
	(*result).Sup.flushImpl = fsFlush__pureZstreams_u1036;
	return result;
}
static N_INLINE(NI, pluspercent___system_u785)(NI x_p0, NI y_p1) {
	NI result;
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) + (NU64)(((NU) (y_p1))))));
	return result;
}
static N_INLINE(void, nimIncRefCyclic)(void* p_p0, NIM_BOOL cyclic_p1) {
	tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A* h_1;
	NI T1_;
	T1_ = (NI)0;
	T1_ = minuspercent___system_u805(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
	h_1 = ((tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A*) (T1_));
	(*h_1).rc = pluspercent___system_u785((*h_1).rc, ((NI)16));
}
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___pureZstreams_u676)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w** dest_p0, tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* src_p1, NIM_BOOL cyclic_p2) {
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmp_;
	colontmp_ = (*dest_p0);
	{
		if (!src_p1) goto LA3_;
		nimIncRefCyclic(src_p1, cyclic_p2);
	}
LA3_: ;
	(*dest_p0) = src_p1;
	{
		NIM_BOOL T7_;
		T7_ = (NIM_BOOL)0;
		T7_ = nimDecRefIsLastCyclicDyn(colontmp_);
		if (!T7_) goto LA8_;
		nimDestroyAndDispose(colontmp_);
	}
LA8_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u673)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* dest_p0) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLastCyclicDyn(dest_p0);
		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, close__pureZstreams_u58)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = !((s_p0 == 0));
		if (!(T3_)) goto LA4_;
		T3_ = !(((*s_p0).closeImpl == 0));
LA4_: ;
		if (!T3_) goto LA5_;
		(*s_p0).closeImpl(s_p0);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
LA5_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, atEnd__pureZstreams_u67)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	result = (*s_p0).atEndImpl(s_p0);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, readData__pureZstreams_u79)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	result = (*s_p0).readDataImpl(s_p0, buffer_p1, bufLen_p2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_CHAR, readChar__pureZstreams_u209)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	NIM_CHAR result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = 0;
	{
		{
			NI T4_;
			T4_ = (NI)0;
			T4_ = readData__pureZstreams_u79(s_p0, ((void*) ((&result))), ((NI)1));
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			if (!!((T4_ == ((NI)1)))) goto LA5_;
			result = 0;
		}
LA5_: ;
	}
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, nimAddCharV1)(NimStringV2* s_p0, NIM_CHAR c_p1) {
	prepareAdd(s_p0, ((NI)1));
	(*(*s_p0).p).data[(*s_p0).len] = c_p1;
	(*s_p0).len += ((NI)1);
	(*(*s_p0).p).data[(*s_p0).len] = 0;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, readLine__pureZstreams_u570)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = TM__Ue7tnBcsL67VCiRfvt8q0A_6;
	{
		NIM_BOOL T3_;
		tyObject_IOError__vBePDvr8fj01uTfaJy9aD3Q* T6_;
		T3_ = (NIM_BOOL)0;
		T3_ = atEnd__pureZstreams_u67(s_p0);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T3_) goto LA4_;
		T6_ = NIM_NIL;
		T6_ = newEIO__pureZstreams_u3(TM__Ue7tnBcsL67VCiRfvt8q0A_8);
		if (NIM_UNLIKELY(*nimErr_)) {eqdestroy___system_u8764(T6_); goto BeforeRet_;}
		raiseExceptionEx((Exception*)T6_, "IOError", "readLine", "streams.nim", 1095);
goto BeforeRet_;
	}
LA4_: ;
	{
		while (1) {
			NIM_CHAR c_1;
			c_1 = readChar__pureZstreams_u209(s_p0);
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
			{
				if (!((NU8)(c_1) == (NU8)(13))) goto LA11_;
				c_1 = readChar__pureZstreams_u209(s_p0);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				goto LA7;
			}
LA11_: ;
			{
				NIM_BOOL T15_;
				T15_ = (NIM_BOOL)0;
				T15_ = ((NU8)(c_1) == (NU8)(10));
				if (T15_) goto LA16_;
				T15_ = ((NU8)(c_1) == (NU8)(0));
LA16_: ;
				if (!T15_) goto LA17_;
				goto LA7;
			}
			goto LA13_;
LA17_: ;
			{
				nimAddCharV1((&result), c_1);
			}
LA13_: ;
		}
	} LA7: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, readLine__pureZstreams_u555)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* line_p1) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	{
		if (!!(((*s_p0).readLineImpl == NIM_NIL))) goto LA3_;
		result = (*s_p0).readLineImpl(s_p0, line_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
LA3_: ;
	{
		setLengthStrV2((&(*line_p1)), ((NI)0));
		{
			while (1) {
				NIM_CHAR c_1;
				c_1 = readChar__pureZstreams_u209(s_p0);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				{
					if (!((NU8)(c_1) == (NU8)(13))) goto LA10_;
					c_1 = readChar__pureZstreams_u209(s_p0);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					goto LA6;
				}
				goto LA8_;
LA10_: ;
				{
					if (!((NU8)(c_1) == (NU8)(10))) goto LA13_;
					goto LA6;
				}
				goto LA8_;
LA13_: ;
				{
					if (!((NU8)(c_1) == (NU8)(0))) goto LA16_;
					{
						if (!(((NI)0) < (*line_p1).len)) goto LA20_;
						goto LA6;
					}
					goto LA18_;
LA20_: ;
					{
						result = NIM_FALSE;
						goto BeforeRet_;
					}
LA18_: ;
				}
				goto LA8_;
LA16_: ;
LA8_: ;
				nimAddCharV1((&(*line_p1)), c_1);
			}
		} LA6: ;
		result = NIM_TRUE;
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, nimPrepareStrMutationV2)(NimStringV2* s_p0) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = !(((*s_p0).p == ((NimStrPayload*) NIM_NIL)));
		if (!(T3_)) goto LA4_;
		T3_ = ((NI)((*(*s_p0).p).cap & ((NI)IL64(4611686018427387904))) == ((NI)IL64(4611686018427387904)));
LA4_: ;
		if (!T3_) goto LA5_;
		nimPrepareStrMutationImpl__system_u2430(s_p0);
	}
LA5_: ;
}
static N_INLINE(void, prepareMutation__system_u2442)(NimStringV2* s_p0) {
	NimStringV2* s_2;
	s_2 = s_p0;
	nimPrepareStrMutationV2(((NimStringV2*) (s_2)));
}
N_LIB_PRIVATE N_NIMCALL(NI, readDataStr__pureZstreams_u85)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA slice_p2) {
	NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	{
		if (!!(((*s_p0).readDataStrImpl == NIM_NIL))) goto LA3_;
		result = (*s_p0).readDataStrImpl(s_p0, buffer_p1, slice_p2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
LA3_: ;
	{
		prepareMutation__system_u2442(buffer_p1);
		result = readData__pureZstreams_u79(s_p0, ((void*) ((&(*buffer_p1).p->data[slice_p2.a]))), (NI)((NI)(slice_p2.b + ((NI)1)) - slice_p2.a));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u612)(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* dest_p0) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLastCyclicDyn(dest_p0);
		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u632)(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* dest_p0) {
	eqdestroy___system_u2691((*dest_p0).data);
}
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__pureZstreams_u1121)(void* dest_p0) {
	eqdestroy___pureZstreams_u632((&(*((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ*) (dest_p0)))));
}
N_LIB_PRIVATE N_NIMCALL(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w*, eqdup___pureZstreams_u680)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* src_p0, NIM_BOOL cyclic_p1) {
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* result;
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmp_;
	result = NIM_NIL;
	colontmp_ = result;
	result = src_p0;
	{
		if (!src_p0) goto LA3_;
		nimIncRefCyclic(src_p0, cyclic_p1);
	}
LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, ssClose__pureZstreams_u826)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmpD_;
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u680(s_p0, NIM_TRUE);
	s_2 = (*((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ**) (&(colontmpD_))));
	eqsink___system_u2700((&(*s_2).data), TM__Ue7tnBcsL67VCiRfvt8q0A_10);
	eqdestroy___pureZstreams_u612(s_2);
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, ssAtEnd__pureZstreams_u605)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	NIM_BOOL result;
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
{	s_2 = NIM_NIL;
	s_2 = ((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ*) (s_p0));
	result = ((*s_2).data.len <= (*s_2).pos);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, ssSetPosition__pureZstreams_u728)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NI pos_p1) {
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmpD_;
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u680(s_p0, NIM_TRUE);
	s_2 = (*((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ**) (&(colontmpD_))));
	(*s_2).pos = clamp__pureZstreams_u732(pos_p1, ((NI)0), (*s_2).data.len);
	eqdestroy___pureZstreams_u612(s_2);
}
N_LIB_PRIVATE N_NIMCALL(NI, ssGetPosition__pureZstreams_u738)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0) {
	NI result;
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
{	s_2 = NIM_NIL;
	s_2 = ((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ*) (s_p0));
	result = (*s_2).pos;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));
}
static N_INLINE(void, copyMem__system_u1742)(void* dest_p0, void* source_p1, NI size_p2) {
	nimCopyMem(dest_p0, source_p1, size_p2);
}
N_LIB_PRIVATE N_NIMCALL(NI, ssReadDataStr__pureZstreams_u742)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__OAVyDXS0QPw7LdXClfU2hA slice_p2) {
	NI result;
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmpD_;
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u680(s_p0, NIM_TRUE);
	s_2 = (*((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ**) (&(colontmpD_))));
	prepareMutation__system_u2442(buffer_p1);
	result = (((NI)((NI)(slice_p2.b + ((NI)1)) - slice_p2.a) <= (NI)((*s_2).data.len - (*s_2).pos)) ? (NI)((NI)(slice_p2.b + ((NI)1)) - slice_p2.a) : (NI)((*s_2).data.len - (*s_2).pos));
	{
		if (!(((NI)0) < result)) goto LA3_;
		{
			copyMem__system_u1742(((void*) ((&(*buffer_p1).p->data[slice_p2.a]))), ((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), (result));
		}
		(*s_2).pos += result;
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NI)0);
	}
LA1_: ;
	eqdestroy___pureZstreams_u612(s_2);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, ssReadData__pureZstreams_u799)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmpD_;
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u680(s_p0, NIM_TRUE);
	s_2 = (*((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ**) (&(colontmpD_))));
	result = ((bufLen_p2 <= (NI)((*s_2).data.len - (*s_2).pos)) ? bufLen_p2 : (NI)((*s_2).data.len - (*s_2).pos));
	{
		if (!(((NI)0) < result)) goto LA3_;
		copyMem__system_u1742(buffer_p1, ((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), (result));
		(*s_2).pos += result;
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NI)0);
	}
LA1_: ;
	eqdestroy___pureZstreams_u612(s_2);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, ssPeekData__pureZstreams_u810)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
	s_2 = NIM_NIL;
	s_2 = ((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ*) (s_p0));
	result = ((bufLen_p2 <= (NI)((*s_2).data.len - (*s_2).pos)) ? bufLen_p2 : (NI)((*s_2).data.len - (*s_2).pos));
	{
		if (!(((NI)0) < result)) goto LA3_;
		copyMem__system_u1742(buffer_p1, ((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), (result));
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NI)0);
	}
LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, ssWriteData__pureZstreams_u816)(tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* s_p0, void* buffer_p1, NI bufLen_p2) {
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* s_2;
	tyObject_StreamObj__nX3kZRlh8Dq3gQ2cC6DE8w* colontmpD_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u680(s_p0, NIM_TRUE);
	s_2 = (*((tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ**) (&(colontmpD_))));
	{
		if (!(bufLen_p2 <= ((NI)0))) goto LA4_;
		eqdestroy___pureZstreams_u612(s_2);
		goto BeforeRet_;
	}
LA4_: ;
	{
		if (!((*s_2).data.len < (NI)((*s_2).pos + bufLen_p2))) goto LA8_;
		setLengthStrV2((&(*s_2).data), ((NI)((*s_2).pos + bufLen_p2)));
	}
LA8_: ;
	copyMem__system_u1742(((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), buffer_p1, (bufLen_p2));
	(*s_2).pos += bufLen_p2;
	{
		LA1_:;
	}
	{
		eqdestroy___pureZstreams_u612(s_2);
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ*, newStringStream__pureZstreams_u829)(NimStringV2 s_p0) {
	tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ* result;
	result = NIM_NIL;
	eqdestroy___pureZstreams_u612(result);
	result = (tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ*) nimNewObj(sizeof(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ), NIM_ALIGNOF(tyObject_StringStreamObj__OvoQd4jSzPo0Qf5Vj9aPcAQ));
	(*result).Sup.Sup.m_type = (&NTIv2__OvoQd4jSzPo0Qf5Vj9aPcAQ_);
	eqsink___system_u2700((&(*result).data), s_p0);
	prepareMutation__system_u2442((&(*result).data));
	(*result).pos = ((NI)0);
	(*result).Sup.closeImpl = ssClose__pureZstreams_u826;
	(*result).Sup.atEndImpl = ssAtEnd__pureZstreams_u605;
	(*result).Sup.setPositionImpl = ssSetPosition__pureZstreams_u728;
	(*result).Sup.getPositionImpl = ssGetPosition__pureZstreams_u738;
	(*result).Sup.readDataStrImpl = ssReadDataStr__pureZstreams_u742;
	(*result).Sup.readDataImpl = ssReadData__pureZstreams_u799;
	(*result).Sup.peekDataImpl = ssPeekData__pureZstreams_u810;
	(*result).Sup.writeDataImpl = ssWriteData__pureZstreams_u816;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*, newFileStream__pureZstreams_u1097)(NimStringV2 filename_p0, tyEnum_FileMode__YkEVJbjDa9aPvYTBr8yiUWg mode_p1, NI bufSize_p2) {
	tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA* result;
	FILE* f_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = NIM_NIL;
	f_1 = 0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = open__stdZsyncio_u412(&f_1, filename_p0, mode_p1, bufSize_p2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T3_) goto LA4_;
		result = newFileStream__pureZstreams_u1072(f_1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
LA4_: ;
	{
		result = ((tyObject_FileStreamObj__5UvDPztSlRBlwzg9bp1LtoA*) NIM_NIL);
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
