/* Generated by Nim Compiler v2.2.10 */
/* Compiled for: MacOSX, arm64, clang */
/* Command for C compiler:
   clang -c  -w -ferror-limit=3 -fno-strict-aliasing -pthread -isysroot /Applications/Xcode_16.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -target arm64-apple-darwin24.2.0 -O3   -I/Users/runner/work/nightlies/nightlies/nim-2.2.10/lib -I/Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/src -o /Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/.nimcache/@pstreams.nim.c.o /Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/.nimcache/@pstreams.nim.c */
#define NIM_INTBITS 64
#define NIM_EmulateOverflowChecks

#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_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ;
typedef struct tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA;
typedef struct tyObject_IOError__FsM2LSiW5usgjecIvsloBA tyObject_IOError__FsM2LSiW5usgjecIvsloBA;
typedef struct tyObject_CatchableError__liO6E8JNJNTVmf9cnXKZiug tyObject_CatchableError__liO6E8JNJNTVmf9cnXKZiug;
typedef struct Exception Exception;
typedef struct tySequence__3EvzHGO0xyXGnJBUggwfKQ tySequence__3EvzHGO0xyXGnJBUggwfKQ;
typedef struct tySequence__3EvzHGO0xyXGnJBUggwfKQ_Content tySequence__3EvzHGO0xyXGnJBUggwfKQ_Content;
typedef struct tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg;
typedef struct tyObject_StackTraceEntry__lcKzdyiD6sm3eeh28rx7fw tyObject_StackTraceEntry__lcKzdyiD6sm3eeh28rx7fw;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NU8 tyEnum_FileMode__wjF0STQGT1PBuQEl3p0tng;
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__E9aUxUbQfSfG9bDHtjp9bJx4Q) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
typedef N_NIMCALL_PTR(NIM_BOOL, tyProc__DMp9aUCWnCo4HurK9bbMFmZw) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
typedef N_NIMCALL_PTR(void, tyProc__itHc4jZtTpxT9bZ9cqWxzfDA) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI pos_p1);
typedef N_NIMCALL_PTR(NI, tyProc__n8ia0SZOWi9aLDiLsBb0yjw) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
typedef N_NIMCALL_PTR(NI, tyProc__0hYqEcBlB9bEANPIuHrMMfA) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ slice_p2);
typedef N_NIMCALL_PTR(NIM_BOOL, tyProc__wUWG9arq0ePuG9awasbo69cSw) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* line_p1);
typedef N_NIMCALL_PTR(NI, tyProc__vPMGV5XMHXAc89bq9byt1r9ag) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
typedef N_NIMCALL_PTR(void, tyProc__Xz9a8DVGoavze4NXIx9bBtkQ) (tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
struct tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ {
	RootObj Sup;
	tyProc__E9aUxUbQfSfG9bDHtjp9bJx4Q closeImpl;
	tyProc__DMp9aUCWnCo4HurK9bbMFmZw atEndImpl;
	tyProc__itHc4jZtTpxT9bZ9cqWxzfDA setPositionImpl;
	tyProc__n8ia0SZOWi9aLDiLsBb0yjw getPositionImpl;
	tyProc__0hYqEcBlB9bEANPIuHrMMfA readDataStrImpl;
	tyProc__wUWG9arq0ePuG9awasbo69cSw readLineImpl;
	tyProc__vPMGV5XMHXAc89bq9byt1r9ag readDataImpl;
	tyProc__vPMGV5XMHXAc89bq9byt1r9ag peekDataImpl;
	tyProc__Xz9a8DVGoavze4NXIx9bBtkQ writeDataImpl;
	tyProc__E9aUxUbQfSfG9bDHtjp9bJx4Q flushImpl;
};
struct tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw {
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ Sup;
	FILE* f;
};
struct tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA {
	NI rc;
	NI rootIdx;
};
typedef NU8 tyEnum_FileSeekPos__sobaHT4orl7Vk3X9cLPriwg;
struct tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ {
	NI a;
	NI b;
};
struct tySequence__3EvzHGO0xyXGnJBUggwfKQ {
  NI len; tySequence__3EvzHGO0xyXGnJBUggwfKQ_Content* p;
};
struct Exception {
	RootObj Sup;
	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__3EvzHGO0xyXGnJBUggwfKQ trace;
	Exception* up;
};
struct tyObject_CatchableError__liO6E8JNJNTVmf9cnXKZiug {
	Exception Sup;
};
struct tyObject_IOError__FsM2LSiW5usgjecIvsloBA {
	tyObject_CatchableError__liO6E8JNJNTVmf9cnXKZiug Sup;
};
struct tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg {
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ Sup;
	NimStringV2 data;
	NI pos;
};
typedef NIM_CHAR tyArray__75h3E3l6usQby9b3lSshL0Q[1024];
struct tyObject_StackTraceEntry__lcKzdyiD6sm3eeh28rx7fw {
	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__3EvzHGO0xyXGnJBUggwfKQ_Content { NI cap; tyObject_StackTraceEntry__lcKzdyiD6sm3eeh28rx7fw data[SEQ_DECL_SIZE]; };
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, open__stdZsyncio_u413)(FILE** f_p0, NimStringV2 filename_p1, tyEnum_FileMode__wjF0STQGT1PBuQEl3p0tng mode_p2, NI bufSize_p3);
N_LIB_PRIVATE N_NIMCALL(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*, newFileStream__pureZstreams_u1185)(FILE* f_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u1093)(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u813)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3555)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, fsClose__pureZstreams_u1084)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseObjectConversionError)(void);
N_LIB_PRIVATE N_NIMCALL(void, close__stdZsyncio_u269)(FILE* f_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, fsAtEnd__pureZstreams_u1151)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, endOfFile__stdZsyncio_u369)(FILE* f_p0);
N_LIB_PRIVATE N_NIMCALL(void, fsSetPosition__pureZstreams_u1154)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI pos_p1);
N_LIB_PRIVATE N_NIMCALL(void, setFilePos__stdZsyncio_u503)(FILE* f_p0, NI64 pos_p1, tyEnum_FileSeekPos__sobaHT4orl7Vk3X9cLPriwg relativeTo_p2);
N_LIB_PRIVATE N_NIMCALL(NI, fsGetPosition__pureZstreams_u1157)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
N_LIB_PRIVATE N_NIMCALL(NI64, getFilePos__stdZsyncio_u526)(FILE* f_p0);
N_LIB_PRIVATE N_NIMCALL(NI, fsReadDataStr__pureZstreams_u1165)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ slice_p2);
N_LIB_PRIVATE N_NIMCALL(NI, readBuffer__stdZsyncio_u165)(FILE* f_p0, void* buffer_p1, NI len_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
static N_INLINE(NIM_BOOL, nimAddInt)(NI a_p0, NI b_p1, NI* res_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NIM_BOOL, nimSubInt)(NI a_p0, NI b_p1, NI* res_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(NI, fsReadData__pureZstreams_u1160)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, fsReadLine__pureZstreams_u1181)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* line_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, readLine__stdZsyncio_u291)(FILE* f_p0, NimStringV2* line_p1);
N_LIB_PRIVATE N_NIMCALL(NI, fsPeekData__pureZstreams_u1171)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(void, fsWriteData__pureZstreams_u1177)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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__FsM2LSiW5usgjecIvsloBA*, newEIO__pureZstreams_u2)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___system_u9207)(tyObject_IOError__FsM2LSiW5usgjecIvsloBA* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___system_u2754)(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_u1149)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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_u793)(NI x_p0, NI y_p1);
static N_INLINE(void, prepareMutation__system_u2505)(NimStringV2* s_p0);
static N_INLINE(void, nimPrepareStrMutationV2)(NimStringV2* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimPrepareStrMutationImpl__system_u2493)(NimStringV2* s_p0);
N_LIB_PRIVATE N_NIMCALL(NI, readData__pureZstreams_u78)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(void, writeData__pureZstreams_u212)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0);
N_LIB_PRIVATE N_NIMCALL(void, setLengthStrV2)(NimStringV2* s_p0, NI newLen_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_CHAR, readChar__pureZstreams_u246)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
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, eqdestroy___pureZstreams_u725)(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__pureZstreams_u1233)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u745)(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* dest_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqsink___system_u2760)(NimStringV2* dest_p0, NimStringV2 src_p1);
N_LIB_PRIVATE N_NIMCALL(void, ssClose__pureZstreams_u939)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
N_LIB_PRIVATE N_NIMCALL(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ*, eqdup___pureZstreams_u793)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* src_p0, NIM_BOOL cyclic_p1);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, ssAtEnd__pureZstreams_u718)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, ssSetPosition__pureZstreams_u841)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI pos_p1);
N_LIB_PRIVATE N_NIMCALL(NI, clamp__pureZstreams_u845)(NI x_p0, NI a_p1, NI b_p2);
N_LIB_PRIVATE N_NIMCALL(NI, ssGetPosition__pureZstreams_u851)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0);
N_LIB_PRIVATE N_NIMCALL(NI, ssReadDataStr__pureZstreams_u855)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ slice_p2);
static N_INLINE(void, copyMem__system_u1755)(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_u912)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(NI, ssPeekData__pureZstreams_u923)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
N_LIB_PRIVATE N_NIMCALL(void, ssWriteData__pureZstreams_u929)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2);
N_NIMCALL(NimStringV2, mnewString)(NI len_p0);
N_LIB_PRIVATE N_NIMCALL(void, readStrPrivate__pureZstreams_u629)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI length_p1, NimStringV2* str_p2);
N_LIB_PRIVATE TNimTypeV2 NTIv2__55YZdAmhEXf1sGHQMYxWjw_;
extern TNimTypeV2 NTIv2__FsM2LSiW5usgjecIvsloBA_;
static const struct {
  NI cap; NIM_CHAR data[22+1];
} TM__Ue7tnBcsL67VCiRfvt8q0A_5 = { 22 | NIM_STRLIT_FLAG, "cannot write to stream" };
static const NimStringV2 TM__Ue7tnBcsL67VCiRfvt8q0A_6 = {22, (NimStrPayload*)&TM__Ue7tnBcsL67VCiRfvt8q0A_5};
N_LIB_PRIVATE TNimTypeV2 NTIv2__FCeo9aaO9bFFsI9aQbl29arbwg_;
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__Ue7tnBcsL67VCiRfvt8q0A_10 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__Ue7tnBcsL67VCiRfvt8q0A_11 = {0, (NimStrPayload*)&TM__Ue7tnBcsL67VCiRfvt8q0A_10};
static const NimStringV2 TM__Ue7tnBcsL67VCiRfvt8q0A_22 = {0, (NimStrPayload*)&TM__Ue7tnBcsL67VCiRfvt8q0A_10};
static NIM_CONST NU32 TM__Ue7tnBcsL67VCiRfvt8q0A_2[3] = {3701606400, 3400431616, 2518250496};
N_LIB_PRIVATE TNimTypeV2 NTIv2__55YZdAmhEXf1sGHQMYxWjw_ = {.destructor = (void*)NIM_NIL, .size = sizeof(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw), .align = (NI16) NIM_ALIGNOF(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw), .depth = 2, .display = TM__Ue7tnBcsL67VCiRfvt8q0A_2, .traceImpl = (void*)NIM_NIL, .flags = 0};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4198;
static NIM_CONST NU32 TM__Ue7tnBcsL67VCiRfvt8q0A_9[3] = {3701606400, 3400431616, 665384192};
N_LIB_PRIVATE TNimTypeV2 NTIv2__FCeo9aaO9bFFsI9aQbl29arbwg_ = {.destructor = (void*)rttiDestroy__pureZstreams_u1233, .size = sizeof(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg), .align = (NI16) NIM_ALIGNOF(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg), .depth = 2, .display = TM__Ue7tnBcsL67VCiRfvt8q0A_9, .traceImpl = (void*)NIM_NIL, .flags = 0};
static N_INLINE(NI, minuspercent___system_u813)(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__BVEqx9abcuAhztUEHxbqQJA* cell_1;
		NI T5_;
		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		T5_ = (NI)0;
		T5_ = minuspercent___system_u813(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
		cell_1 = ((tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA*) (T5_));
		{
			if (!((NI)((*cell_1).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
			result = NIM_TRUE;
		}
		goto LA6_;
LA8_: ;
		{
			(*cell_1).rc = minuspercent___system_u813((*cell_1).rc, ((NI)16));
		}
LA6_: ;
		rememberCycle__system_u3555(result, cell_1, (*((TNimTypeV2**) (p_p0))));
	}
LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u1093)(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw* dest_p0) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLastCyclicDyn(dest_p0);
		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2) {
	NIM_BOOL result;
	NIM_BOOL T1_;
	T1_ = (NIM_BOOL)0;
	T1_ = (targetDepth_p1 <= (*source_p0).depth);
	if (!(T1_)) goto LA2_;
	T1_ = ((*source_p0).display[targetDepth_p1] == token_p2);
LA2_: ;
	result = T1_;
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4198);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, fsClose__pureZstreams_u1084)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
		}
		if (!!(((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f == ((FILE*) NIM_NIL)))) goto LA3_;
		if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
		}
		close__stdZsyncio_u269((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
		}
		(*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f = ((FILE*) NIM_NIL);
	}
LA3_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, fsAtEnd__pureZstreams_u1151)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	result = endOfFile__stdZsyncio_u369((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, fsSetPosition__pureZstreams_u1154)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI pos_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	setFilePos__stdZsyncio_u503((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f, ((NI64) (pos_p1)), ((tyEnum_FileSeekPos__sobaHT4orl7Vk3X9cLPriwg)0));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsGetPosition__pureZstreams_u1157)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
	NI result;
	NI64 T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	T1_ = (NI64)0;
	T1_ = getFilePos__stdZsyncio_u526((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	result = ((NI) (T1_));
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NIM_BOOL, nimAddInt)(NI a_p0, NI b_p1, NI* res_p2) {
	NIM_BOOL result;
	NI r_1;
	result = (NIM_BOOL)0;
	r_1 = ((NI) ((NU)((NU64)(((NU) (a_p0))) + (NU64)(((NU) (b_p1))))));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI)0) <= (NI)(r_1 ^ a_p0));
		if (T3_) goto LA4_;
		T3_ = (((NI)0) <= (NI)(r_1 ^ b_p1));
LA4_: ;
		if (!T3_) goto LA5_;
		(*res_p2) = r_1;
	}
	goto LA1_;
LA5_: ;
	{
		result = NIM_TRUE;
	}
LA1_: ;
	return result;
}
static N_INLINE(NIM_BOOL, nimSubInt)(NI a_p0, NI b_p1, NI* res_p2) {
	NIM_BOOL result;
	NI r_1;
	result = (NIM_BOOL)0;
	r_1 = ((NI) ((NU)((NU64)(((NU) (a_p0))) - (NU64)(((NU) (b_p1))))));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (((NI)0) <= (NI)(r_1 ^ a_p0));
		if (T3_) goto LA4_;
		T3_ = (((NI)0) <= (NI)(r_1 ^ (NI)((NU64) ~(b_p1))));
LA4_: ;
		if (!T3_) goto LA5_;
		(*res_p2) = r_1;
	}
	goto LA1_;
LA5_: ;
	{
		result = NIM_TRUE;
	}
LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsReadDataStr__pureZstreams_u1165)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ slice_p2) {
	NI result;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_3;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_4;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	if (slice_p2.a < 0 || slice_p2.a >= (*buffer_p1).len){ raiseIndexError2(slice_p2.a,(*buffer_p1).len-1); goto BeforeRet_;
	}
	if (nimAddInt(slice_p2.b, ((NI)1), &TM__Ue7tnBcsL67VCiRfvt8q0A_3)) { raiseOverflow(); goto BeforeRet_;
	};
	if (nimSubInt((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_3), slice_p2.a, &TM__Ue7tnBcsL67VCiRfvt8q0A_4)) { raiseOverflow(); goto BeforeRet_;
	};
	if (((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_4)) < ((NI)0) || ((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_4)) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_4), ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
	}
	result = readBuffer__stdZsyncio_u165((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f, ((void*) ((&(*buffer_p1).p->data[slice_p2.a]))), ((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_4)));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsReadData__pureZstreams_u1160)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	if ((bufLen_p2) < ((NI)0) || (bufLen_p2) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(bufLen_p2, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
	}
	result = readBuffer__stdZsyncio_u165((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (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_u1181)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* line_p1) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	result = readLine__stdZsyncio_u291((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f, line_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, fsPeekData__pureZstreams_u1171)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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_u1157(s_p0);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto LA1_;
	}
	if ((bufLen_p2) < ((NI)0) || (bufLen_p2) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(bufLen_p2, ((NI)0), ((NI)IL64(9223372036854775807))); goto LA1_;
	}
	result = readBuffer__stdZsyncio_u165((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f, buffer_p1, (bufLen_p2));
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	{
		LA1_:;
	}
	{
		oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
		fsSetPosition__pureZstreams_u1154(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__FsM2LSiW5usgjecIvsloBA*, newEIO__pureZstreams_u2)(NimStringV2 msg_p0) {
	tyObject_IOError__FsM2LSiW5usgjecIvsloBA* result;
	result = NIM_NIL;
	eqdestroy___system_u9207(result);
	result = (tyObject_IOError__FsM2LSiW5usgjecIvsloBA*) nimNewObj(sizeof(tyObject_IOError__FsM2LSiW5usgjecIvsloBA), NIM_ALIGNOF(tyObject_IOError__FsM2LSiW5usgjecIvsloBA));
	(*result).Sup.Sup.Sup.m_type = (&NTIv2__FsM2LSiW5usgjecIvsloBA_);
	(*result).Sup.Sup.name = "IOError";
	eqcopy___system_u2754((&(*result).Sup.Sup.message), msg_p0);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, fsWriteData__pureZstreams_u1177)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		NI T3_;
		tyObject_IOError__FsM2LSiW5usgjecIvsloBA* T6_;
		if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
		}
		if ((bufLen_p2) < ((NI)0) || (bufLen_p2) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(bufLen_p2, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
		}
		T3_ = (NI)0;
		T3_ = writeBuffer__stdZsyncio_u196((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (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_u2(TM__Ue7tnBcsL67VCiRfvt8q0A_6);
		if (NIM_UNLIKELY(*nimErr_)) {eqdestroy___system_u9207(T6_); goto BeforeRet_;}
		raiseExceptionEx((Exception*)T6_, "IOError", "fsWriteData", "streams.nim", 1357);
goto BeforeRet_;
	}
LA4_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, fsFlush__pureZstreams_u1149)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 2518250496)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	flushFile__stdZsyncio_u278((*((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) (s_p0))).f);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*, newFileStream__pureZstreams_u1185)(FILE* f_p0) {
	tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw* result;
	result = NIM_NIL;
	eqdestroy___pureZstreams_u1093(result);
	result = (tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) nimNewObj(sizeof(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw), NIM_ALIGNOF(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw));
	(*result).Sup.Sup.m_type = (&NTIv2__55YZdAmhEXf1sGHQMYxWjw_);
	(*result).f = f_p0;
	(*result).Sup.closeImpl = fsClose__pureZstreams_u1084;
	(*result).Sup.atEndImpl = fsAtEnd__pureZstreams_u1151;
	(*result).Sup.setPositionImpl = fsSetPosition__pureZstreams_u1154;
	(*result).Sup.getPositionImpl = fsGetPosition__pureZstreams_u1157;
	(*result).Sup.readDataStrImpl = fsReadDataStr__pureZstreams_u1165;
	(*result).Sup.readDataImpl = fsReadData__pureZstreams_u1160;
	(*result).Sup.readLineImpl = fsReadLine__pureZstreams_u1181;
	(*result).Sup.peekDataImpl = fsPeekData__pureZstreams_u1171;
	(*result).Sup.writeDataImpl = fsWriteData__pureZstreams_u1177;
	(*result).Sup.flushImpl = fsFlush__pureZstreams_u1149;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*, newFileStream__pureZstreams_u1210)(NimStringV2 filename_p0, tyEnum_FileMode__wjF0STQGT1PBuQEl3p0tng mode_p1, NI bufSize_p2) {
	tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw* 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_u413(&f_1, filename_p0, mode_p1, bufSize_p2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!T3_) goto LA4_;
		result = newFileStream__pureZstreams_u1185(f_1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	goto LA1_;
LA4_: ;
	{
		result = ((tyObject_FileStreamObj__55YZdAmhEXf1sGHQMYxWjw*) NIM_NIL);
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NI, pluspercent___system_u793)(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__BVEqx9abcuAhztUEHxbqQJA* h_1;
	NI T1_;
	T1_ = (NI)0;
	T1_ = minuspercent___system_u813(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
	h_1 = ((tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA*) (T1_));
	(*h_1).rc = pluspercent___system_u793((*h_1).rc, ((NI)16));
}
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___pureZstreams_u789)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ** dest_p0, tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* src_p1, NIM_BOOL cyclic_p2) {
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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_: ;
}
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_u2493(s_p0);
	}
LA5_: ;
}
static N_INLINE(void, prepareMutation__system_u2505)(NimStringV2* s_p0) {
	NimStringV2* s_2;
	s_2 = s_p0;
	nimPrepareStrMutationV2(((NimStringV2*) (s_2)));
}
N_LIB_PRIVATE N_NIMCALL(NI, readData__pureZstreams_u78)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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(NI, readDataStr__pureZstreams_u84)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ 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_: ;
	{
		NI TM__Ue7tnBcsL67VCiRfvt8q0A_7;
		NI TM__Ue7tnBcsL67VCiRfvt8q0A_8;
		prepareMutation__system_u2505(buffer_p1);
		if (slice_p2.a < 0 || slice_p2.a >= (*buffer_p1).len){ raiseIndexError2(slice_p2.a,(*buffer_p1).len-1); goto BeforeRet_;
		}
		if (nimAddInt(slice_p2.b, ((NI)1), &TM__Ue7tnBcsL67VCiRfvt8q0A_7)) { raiseOverflow(); goto BeforeRet_;
		};
		if (nimSubInt((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_7), slice_p2.a, &TM__Ue7tnBcsL67VCiRfvt8q0A_8)) { raiseOverflow(); goto BeforeRet_;
		};
		result = readData__pureZstreams_u78(s_p0, ((void*) ((&(*buffer_p1).p->data[slice_p2.a]))), (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_8));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, close__pureZstreams_u57)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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(void, eqsink___pureZstreams_u797)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ** dest_p0, tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* src_p1) {
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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, writeData__pureZstreams_u212)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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_u221)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2 x_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		if (!(((NI)0) < x_p1.len)) goto LA3_;
		writeData__pureZstreams_u212(s_p0, ((void*) (nimToCStringConv(x_p1))), x_p1.len);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
LA3_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u786)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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(NIM_CHAR, readChar__pureZstreams_u246)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
	NIM_CHAR result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = 0;
	{
		{
			NI T4_;
			T4_ = (NI)0;
			T4_ = readData__pureZstreams_u78(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(NIM_BOOL, readLine__pureZstreams_u668)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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_u246(s_p0);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				{
					if (!((NU8)(c_1) == (NU8)(13))) goto LA10_;
					c_1 = readChar__pureZstreams_u246(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;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZstreams_u725)(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* 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_u745)(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* dest_p0) {
	if ((*dest_p0).data.p && !((*dest_p0).data.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).data.p);
}
}
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__pureZstreams_u1233)(void* dest_p0) {
	eqdestroy___pureZstreams_u745(((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg*) (dest_p0)));
}
N_LIB_PRIVATE N_NIMCALL(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ*, eqdup___pureZstreams_u793)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* src_p0, NIM_BOOL cyclic_p1) {
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* result;
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* 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_u939)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* colontmpD_;
{	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u793(s_p0, NIM_TRUE);
	if (colontmpD_ && !isObjDisplayCheck((*colontmpD_).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	s_2 = (*((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg**) (&(colontmpD_))));
	eqsink___system_u2760((&(*s_2).data), TM__Ue7tnBcsL67VCiRfvt8q0A_11);
	eqdestroy___pureZstreams_u725(s_2);
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, ssAtEnd__pureZstreams_u718)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
	NIM_BOOL result;
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
{	s_2 = NIM_NIL;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	s_2 = ((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg*) (s_p0));
	result = ((*s_2).data.len <= (*s_2).pos);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, ssSetPosition__pureZstreams_u841)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI pos_p1) {
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* colontmpD_;
{	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u793(s_p0, NIM_TRUE);
	if (colontmpD_ && !isObjDisplayCheck((*colontmpD_).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	s_2 = (*((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg**) (&(colontmpD_))));
	(*s_2).pos = clamp__pureZstreams_u845(pos_p1, ((NI)0), (*s_2).data.len);
	eqdestroy___pureZstreams_u725(s_2);
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NI, ssGetPosition__pureZstreams_u851)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
	NI result;
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
{	s_2 = NIM_NIL;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	s_2 = ((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg*) (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_u1755)(void* dest_p0, void* source_p1, NI size_p2) {
	nimCopyMem(dest_p0, source_p1, size_p2);
}
N_LIB_PRIVATE N_NIMCALL(NI, ssReadDataStr__pureZstreams_u855)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NimStringV2* buffer_p1, tyObject_HSlice__atPNPXY5GObvliR9b4ZIorQ slice_p2) {
	NI result;
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* colontmpD_;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_12;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_13;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_14;
{	result = (NI)0;
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u793(s_p0, NIM_TRUE);
	if (colontmpD_ && !isObjDisplayCheck((*colontmpD_).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	s_2 = (*((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg**) (&(colontmpD_))));
	prepareMutation__system_u2505(buffer_p1);
	if (nimAddInt(slice_p2.b, ((NI)1), &TM__Ue7tnBcsL67VCiRfvt8q0A_12)) { raiseOverflow(); goto BeforeRet_;
	};
	if (nimSubInt((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_12), slice_p2.a, &TM__Ue7tnBcsL67VCiRfvt8q0A_13)) { raiseOverflow(); goto BeforeRet_;
	};
	if (nimSubInt((*s_2).data.len, (*s_2).pos, &TM__Ue7tnBcsL67VCiRfvt8q0A_14)) { raiseOverflow(); goto BeforeRet_;
	};
	result = (((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_13) <= (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_14)) ? (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_13) : (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_14));
	{
		NI TM__Ue7tnBcsL67VCiRfvt8q0A_15;
		if (!(((NI)0) < result)) goto LA3_;
		{
			if (slice_p2.a < 0 || slice_p2.a >= (*buffer_p1).len){ raiseIndexError2(slice_p2.a,(*buffer_p1).len-1); goto BeforeRet_;
			}
			if ((*s_2).pos < 0 || (*s_2).pos >= (*s_2).data.len){ raiseIndexError2((*s_2).pos,(*s_2).data.len-1); goto BeforeRet_;
			}
			if ((result) < ((NI)0) || (result) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(result, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
			}
			copyMem__system_u1755(((void*) ((&(*buffer_p1).p->data[slice_p2.a]))), ((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), (result));
		}
		if (nimAddInt((*s_2).pos, result, &TM__Ue7tnBcsL67VCiRfvt8q0A_15)) { raiseOverflow(); goto BeforeRet_;
		};
		(*s_2).pos = (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_15);
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NI)0);
	}
LA1_: ;
	eqdestroy___pureZstreams_u725(s_2);
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, ssReadData__pureZstreams_u912)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* colontmpD_;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_16;
{	result = (NI)0;
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u793(s_p0, NIM_TRUE);
	if (colontmpD_ && !isObjDisplayCheck((*colontmpD_).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	s_2 = (*((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg**) (&(colontmpD_))));
	if (nimSubInt((*s_2).data.len, (*s_2).pos, &TM__Ue7tnBcsL67VCiRfvt8q0A_16)) { raiseOverflow(); goto BeforeRet_;
	};
	result = ((bufLen_p2 <= (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_16)) ? bufLen_p2 : (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_16));
	{
		NI TM__Ue7tnBcsL67VCiRfvt8q0A_17;
		if (!(((NI)0) < result)) goto LA3_;
		if ((*s_2).pos < 0 || (*s_2).pos >= (*s_2).data.len){ raiseIndexError2((*s_2).pos,(*s_2).data.len-1); goto BeforeRet_;
		}
		if ((result) < ((NI)0) || (result) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(result, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
		}
		copyMem__system_u1755(buffer_p1, ((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), (result));
		if (nimAddInt((*s_2).pos, result, &TM__Ue7tnBcsL67VCiRfvt8q0A_17)) { raiseOverflow(); goto BeforeRet_;
		};
		(*s_2).pos = (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_17);
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NI)0);
	}
LA1_: ;
	eqdestroy___pureZstreams_u725(s_2);
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NI, ssPeekData__pureZstreams_u923)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2) {
	NI result;
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_18;
{	result = (NI)0;
	s_2 = NIM_NIL;
	if (s_p0 && !isObjDisplayCheck((*s_p0).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto BeforeRet_;
	}
	s_2 = ((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg*) (s_p0));
	if (nimSubInt((*s_2).data.len, (*s_2).pos, &TM__Ue7tnBcsL67VCiRfvt8q0A_18)) { raiseOverflow(); goto BeforeRet_;
	};
	result = ((bufLen_p2 <= (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_18)) ? bufLen_p2 : (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_18));
	{
		if (!(((NI)0) < result)) goto LA3_;
		if ((*s_2).pos < 0 || (*s_2).pos >= (*s_2).data.len){ raiseIndexError2((*s_2).pos,(*s_2).data.len-1); goto BeforeRet_;
		}
		if ((result) < ((NI)0) || (result) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(result, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
		}
		copyMem__system_u1755(buffer_p1, ((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), (result));
	}
	goto LA1_;
LA3_: ;
	{
		result = ((NI)0);
	}
LA1_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, ssWriteData__pureZstreams_u929)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, void* buffer_p1, NI bufLen_p2) {
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* s_2;
	tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* colontmpD_;
	NI TM__Ue7tnBcsL67VCiRfvt8q0A_21;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	s_2 = NIM_NIL;
	colontmpD_ = eqdup___pureZstreams_u793(s_p0, NIM_TRUE);
	if (colontmpD_ && !isObjDisplayCheck((*colontmpD_).Sup.m_type, 2, 665384192)){ raiseObjectConversionError(); goto LA1_;
	}
	s_2 = (*((tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg**) (&(colontmpD_))));
	{
		if (!(bufLen_p2 <= ((NI)0))) goto LA4_;
		eqdestroy___pureZstreams_u725(s_2);
		goto BeforeRet_;
	}
LA4_: ;
	{
		NI TM__Ue7tnBcsL67VCiRfvt8q0A_19;
		NI TM__Ue7tnBcsL67VCiRfvt8q0A_20;
		if (nimAddInt((*s_2).pos, bufLen_p2, &TM__Ue7tnBcsL67VCiRfvt8q0A_19)) { raiseOverflow(); goto LA1_;
		};
		if (!((*s_2).data.len < (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_19))) goto LA8_;
		if (nimAddInt((*s_2).pos, bufLen_p2, &TM__Ue7tnBcsL67VCiRfvt8q0A_20)) { raiseOverflow(); goto LA1_;
		};
		if (((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_20)) < ((NI)0) || ((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_20)) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_20), ((NI)0), ((NI)IL64(9223372036854775807))); goto LA1_;
		}
		setLengthStrV2((&(*s_2).data), ((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_20)));
	}
LA8_: ;
	if ((*s_2).pos < 0 || (*s_2).pos >= (*s_2).data.len){ raiseIndexError2((*s_2).pos,(*s_2).data.len-1); goto LA1_;
	}
	if ((bufLen_p2) < ((NI)0) || (bufLen_p2) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(bufLen_p2, ((NI)0), ((NI)IL64(9223372036854775807))); goto LA1_;
	}
	copyMem__system_u1755(((void*) ((&(*s_2).data.p->data[(*s_2).pos]))), buffer_p1, (bufLen_p2));
	if (nimAddInt((*s_2).pos, bufLen_p2, &TM__Ue7tnBcsL67VCiRfvt8q0A_21)) { raiseOverflow(); goto LA1_;
	};
	(*s_2).pos = (NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_21);
	{
		LA1_:;
	}
	{
		eqdestroy___pureZstreams_u725(s_2);
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg*, newStringStream__pureZstreams_u942)(NimStringV2 s_p0) {
	tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg* result;
	result = NIM_NIL;
	eqdestroy___pureZstreams_u725(result);
	result = (tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg*) nimNewObj(sizeof(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg), NIM_ALIGNOF(tyObject_StringStreamObj__FCeo9aaO9bFFsI9aQbl29arbwg));
	(*result).Sup.Sup.m_type = (&NTIv2__FCeo9aaO9bFFsI9aQbl29arbwg_);
	eqsink___system_u2760((&(*result).data), s_p0);
	prepareMutation__system_u2505((&(*result).data));
	(*result).pos = ((NI)0);
	(*result).Sup.closeImpl = ssClose__pureZstreams_u939;
	(*result).Sup.atEndImpl = ssAtEnd__pureZstreams_u718;
	(*result).Sup.setPositionImpl = ssSetPosition__pureZstreams_u841;
	(*result).Sup.getPositionImpl = ssGetPosition__pureZstreams_u851;
	(*result).Sup.readDataStrImpl = ssReadDataStr__pureZstreams_u855;
	(*result).Sup.readDataImpl = ssReadData__pureZstreams_u912;
	(*result).Sup.peekDataImpl = ssPeekData__pureZstreams_u923;
	(*result).Sup.writeDataImpl = ssWriteData__pureZstreams_u929;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, setPosition__pureZstreams_u70)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI pos_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	(*s_p0).setPositionImpl(s_p0, pos_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, readStrPrivate__pureZstreams_u629)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI length_p1, NimStringV2* str_p2) {
	NI L_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		if (!((*str_p2).len < length_p1)) goto LA3_;
		if ((length_p1) < ((NI)0) || (length_p1) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(length_p1, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
		}
		setLengthStrV2((&(*str_p2)), (length_p1));
	}
LA3_: ;
	L_1 = (NI)0;
	L_1 = readData__pureZstreams_u78(s_p0, ((void*) (nimToCStringConv((*str_p2)))), length_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		if (!!((L_1 == (*str_p2).len))) goto LA7_;
		if ((L_1) < ((NI)0) || (L_1) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(L_1, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
		}
		setLengthStrV2((&(*str_p2)), (L_1));
	}
LA7_: ;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, readStr__pureZstreams_u647)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0, NI length_p1) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result.len = 0; result.p = NIM_NIL;
	if ((length_p1) < ((NI)0) || (length_p1) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(length_p1, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
	}
	result = mnewString((length_p1));
	readStrPrivate__pureZstreams_u629(s_p0, length_p1, (&result));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, readAll__pureZstreams_u102)(tyObject_StreamObj__bsqueMN9aCOGm2aNaHkuxoQ* s_p0) {
	NimStringV2 result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = TM__Ue7tnBcsL67VCiRfvt8q0A_22;
	{
		tyArray__75h3E3l6usQby9b3lSshL0Q buffer_1;
		{
			while (1) {
				NI readBytes_1;
				NI prevLen_1;
				NI TM__Ue7tnBcsL67VCiRfvt8q0A_23;
				readBytes_1 = readData__pureZstreams_u78(s_p0, ((void*) ((&buffer_1[(((NI)0))- 0]))), ((NI)1024));
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				{
					if (!(readBytes_1 == ((NI)0))) goto LA6_;
					goto LA2;
				}
LA6_: ;
				prevLen_1 = result.len;
				if (nimAddInt(prevLen_1, readBytes_1, &TM__Ue7tnBcsL67VCiRfvt8q0A_23)) { raiseOverflow(); goto BeforeRet_;
				};
				if (((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_23)) < ((NI)0) || ((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_23)) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_23), ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
				}
				setLengthStrV2((&result), ((NI)(TM__Ue7tnBcsL67VCiRfvt8q0A_23)));
				if (prevLen_1 < 0 || prevLen_1 >= result.len){ raiseIndexError2(prevLen_1,result.len-1); goto BeforeRet_;
				}
				if ((readBytes_1) < ((NI)0) || (readBytes_1) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(readBytes_1, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
				}
				copyMem__system_u1755(((void*) ((&result.p->data[prevLen_1]))), ((void*) ((&buffer_1[(((NI)0))- 0]))), (readBytes_1));
				{
					if (!(readBytes_1 < ((NI)1024))) goto LA10_;
					goto LA2;
				}
LA10_: ;
			}
		} LA2: ;
	}
	}BeforeRet_: ;
	return result;
}
