/* 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/@pcompiler@sllstream.nim.c.o /Users/runner/work/nightlies/nightlies/nim-2.2.10/dist/atlas/.nimcache/@pcompiler@sllstream.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_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ;
typedef struct tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct RootObj RootObj;
typedef struct tyObject_GcEnv__1z8AJ0tfLlYlFBizZRHD7A tyObject_GcEnv__1z8AJ0tfLlYlFBizZRHD7A;
typedef struct tyObject_CellSeq__ssWvVk43J2HePNvNGK2tCw tyObject_CellSeq__ssWvVk43J2HePNvNGK2tCw;
typedef struct tyTuple__N4J9cV4JZGem3ljqqj5rT0Q tyTuple__N4J9cV4JZGem3ljqqj5rT0Q;
typedef struct tyObject_CellSeq__dIiPa2COtDnavhK2KIqxCQ tyObject_CellSeq__dIiPa2COtDnavhK2KIqxCQ;
typedef struct tyTuple__EMes4DT7YbRCwj3TmsFXyA tyTuple__EMes4DT7YbRCwj3TmsFXyA;
struct tyObject_RefHeader__BVEqx9abcuAhztUEHxbqQJA {
	NI rc;
	NI rootIdx;
};
struct TNimTypeV2 {
	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
	void* vTable[SEQ_DECL_SIZE];
};
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NU8 tyEnum_FileMode__wjF0STQGT1PBuQEl3p0tng;
struct RootObj {
	TNimTypeV2* m_type;
};
typedef NU8 tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w;
typedef struct {
N_NIMCALL_PTR(NI, ClP_0) (tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, void* buf_p1, NI bufLen_p2, void* ClE_0);
void* ClE_0;
} tyProc__wlJibQYTL5o48Y4PSwC79ag;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (void* ClE_0);
void* ClE_0;
} tyProc__HzVCwACFYM9cx9aV62PdjtuA;
struct tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ {
	RootObj Sup;
	tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w kind;
	FILE* f;
	NimStringV2 s;
	NI rd;
	NI wr;
	NI lineOffset;
	tyProc__wlJibQYTL5o48Y4PSwC79ag repl;
	tyProc__HzVCwACFYM9cx9aV62PdjtuA onPrompt;
};
struct tyObject_CellSeq__ssWvVk43J2HePNvNGK2tCw {
	NI len;
	NI cap;
	tyTuple__N4J9cV4JZGem3ljqqj5rT0Q* d;
};
struct tyObject_CellSeq__dIiPa2COtDnavhK2KIqxCQ {
	NI len;
	NI cap;
	tyTuple__EMes4DT7YbRCwj3TmsFXyA* d;
};
struct tyObject_GcEnv__1z8AJ0tfLlYlFBizZRHD7A {
	tyObject_CellSeq__ssWvVk43J2HePNvNGK2tCw traceStack;
	tyObject_CellSeq__dIiPa2COtDnavhK2KIqxCQ toFree;
	NI freed;
	NI touched;
	NI edges;
	NI rcSum;
	NIM_BOOL keepThreshold;
};
struct tyTuple__N4J9cV4JZGem3ljqqj5rT0Q {
	void** Field0;
	TNimTypeV2* Field1;
};
typedef N_CLOSURE_PTR(void, TM__ml9aueblxGz9aYsRLKvPmpow_11) (void);
typedef N_CLOSURE_PTR(NI, TM__ml9aueblxGz9aYsRLKvPmpow_12) (tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, void* buf_p1, NI bufLen_p2);
typedef NU8 tySet_tyChar__nmiMWKVIe46vacnhAFrQvw[32];
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, rttiDestroy__OOZOOZOOZcompilerZllstream_u518)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___OOZOOZOOZcompilerZllstream_u56)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* dest_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqtrace___OOZOOZOOZcompilerZllstream_u68)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* dest_p0, void* env_p1);
static N_INLINE(void, nimTraceRefDyn)(void* q_p0, void* env_p1);
static N_INLINE(void, add__system_u3076)(tyObject_CellSeq__ssWvVk43J2HePNvNGK2tCw* s_p0, void** c_p1, TNimTypeV2* t_p2);
N_LIB_PRIVATE N_NIMCALL(void, resize__system_u3084)(tyObject_CellSeq__ssWvVk43J2HePNvNGK2tCw* s_p0);
static N_INLINE(NI, pluspercent___system_u793)(NI x_p0, NI y_p1);
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(void, eqsink___OOZOOZOOZcompilerZllstream_u122)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ** dest_p0, tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* src_p1);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, setLengthStrV2)(NimStringV2* s_p0, NI newLen_p1);
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(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(NIM_BOOL, readLine__stdZsyncio_u291)(FILE* f_p0, NimStringV2* line_p1);
static N_INLINE(void, nimIncRefCyclic)(void* p_p0, NIM_BOOL cyclic_p1);
static N_INLINE(NIM_BOOL, nimSubInt)(NI a_p0, NI b_p1, NI* res_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_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(NI, readBuffer__stdZsyncio_u165)(FILE* f_p0, void* buffer_p1, NI len_p2);
N_LIB_PRIVATE N_NIMCALL(void, close__stdZsyncio_u269)(FILE* f_p0);
static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1);
N_LIB_PRIVATE N_NIMCALL(void, write__stdZsyncio_u254)(FILE* f_p0, NimStringV2 s_p1);
N_LIB_PRIVATE N_NIMCALL(NI, writeBuffer__stdZsyncio_u196)(FILE* f_p0, void* buffer_p1, NI len_p2);
N_LIB_PRIVATE N_NIMCALL(void, llStreamWrite__OOZOOZOOZcompilerZllstream_u478)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, NimStringV2 data_p1);
N_LIB_PRIVATE TNimTypeV2 NTIv2__SBuFBW9b2EpSkuka9b9cYZHgQ_;
static NIM_CONST tyProc__HzVCwACFYM9cx9aV62PdjtuA TM__ml9aueblxGz9aYsRLKvPmpow_10 = {NIM_NIL,NIM_NIL};
static const struct {
  NI cap; NIM_CHAR data[1+1];
} TM__ml9aueblxGz9aYsRLKvPmpow_17 = { 1 | NIM_STRLIT_FLAG, "\012" };
static const NimStringV2 TM__ml9aueblxGz9aYsRLKvPmpow_18 = {1, (NimStrPayload*)&TM__ml9aueblxGz9aYsRLKvPmpow_17};
static NIM_CONST NU32 TM__ml9aueblxGz9aYsRLKvPmpow_2[2] = {3701606400, 461702400};
N_LIB_PRIVATE TNimTypeV2 NTIv2__SBuFBW9b2EpSkuka9b9cYZHgQ_ = {.destructor = (void*)rttiDestroy__OOZOOZOOZcompilerZllstream_u518, .size = sizeof(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ), .align = (NI16) NIM_ALIGNOF(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ), .depth = 1, .display = TM__ml9aueblxGz9aYsRLKvPmpow_2, .traceImpl = (void*)eqtrace___OOZOOZOOZcompilerZllstream_u68, .flags = 0};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4198;
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___OOZOOZOOZcompilerZllstream_u111)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* 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___OOZOOZOOZcompilerZllstream_u56)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* dest_p0) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).onPrompt.ClE_0);
		if (!T3_) goto LA4_;
		nimDestroyAndDispose((*dest_p0).onPrompt.ClE_0);
	}
LA4_: ;
	{
		NIM_BOOL T8_;
		T8_ = (NIM_BOOL)0;
		T8_ = nimDecRefIsLastCyclicDyn((*dest_p0).repl.ClE_0);
		if (!T8_) goto LA9_;
		nimDestroyAndDispose((*dest_p0).repl.ClE_0);
	}
LA9_: ;
	if ((*dest_p0).s.p && !((*dest_p0).s.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest_p0).s.p);
}
}
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__OOZOOZOOZcompilerZllstream_u518)(void* dest_p0) {
	eqdestroy___OOZOOZOOZcompilerZllstream_u56(((tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*) (dest_p0)));
}
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, add__system_u3076)(tyObject_CellSeq__ssWvVk43J2HePNvNGK2tCw* s_p0, void** c_p1, TNimTypeV2* t_p2) {
	void** colontmp_;
	TNimTypeV2* colontmp__2;
	{
		if (!((*s_p0).cap <= (*s_p0).len)) goto LA3_;
		resize__system_u3084(s_p0);
	}
LA3_: ;
	colontmp_ = c_p1;
	colontmp__2 = t_p2;
	(*s_p0).d[(*s_p0).len].Field0 = colontmp_;
	(*s_p0).d[(*s_p0).len].Field1 = colontmp__2;
	(*s_p0).len = pluspercent___system_u793((*s_p0).len, ((NI)1));
}
static N_INLINE(void, nimTraceRefDyn)(void* q_p0, void* env_p1) {
	void** p_1;
	p_1 = ((void**) (q_p0));
	{
		tyObject_GcEnv__1z8AJ0tfLlYlFBizZRHD7A* j_1;
		if (!!(((*p_1) == NIM_NIL))) goto LA3_;
		j_1 = ((tyObject_GcEnv__1z8AJ0tfLlYlFBizZRHD7A*) (env_p1));
		add__system_u3076((&(*j_1).traceStack), p_1, (*((TNimTypeV2**) ((*p_1)))));
	}
LA3_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, eqtrace___OOZOOZOOZcompilerZllstream_u68)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* dest_p0, void* env_p1) {
	nimTraceRefDyn((&(*dest_p0).repl.ClE_0), env_p1);
	nimTraceRefDyn((&(*dest_p0).onPrompt.ClE_0), env_p1);
}
N_LIB_PRIVATE N_NIMCALL(void, eqsink___OOZOOZOOZcompilerZllstream_u122)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ** dest_p0, tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* src_p1) {
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* 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_: ;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4198);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*, llStreamOpen__OOZOOZOOZcompilerZllstream_u135)(NimStringV2 filename_p0, tyEnum_FileMode__wjF0STQGT1PBuQEl3p0tng mode_p1) {
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* result;
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	T1_ = NIM_NIL;
	T1_ = (tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*) nimNewObj(sizeof(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ), NIM_ALIGNOF(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ));
	(*T1_).Sup.m_type = (&NTIv2__SBuFBW9b2EpSkuka9b9cYZHgQ_);
	(*T1_).kind = ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)2);
	result = T1_;
	{
		NIM_BOOL T4_;
		T4_ = (NIM_BOOL)0;
		T4_ = open__stdZsyncio_u413(&(*result).f, filename_p0, mode_p1, ((NI)-1));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!!(T4_)) goto LA5_;
		eqsink___OOZOOZOOZcompilerZllstream_u122(&result, ((tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*) NIM_NIL));
	}
LA5_: ;
	}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(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, llStreamReadLine__OOZOOZOOZcompilerZllstream_u454)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, NimStringV2* line_p1) {
	NIM_BOOL result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	setLengthStrV2((&(*line_p1)), ((NI)0));
	switch ((*s_p0).kind) {
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)0):
	{
		result = NIM_TRUE;
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)1):
	{
		NIM_BOOL T12_;
		{
			while (1) {
				if (!((*s_p0).rd < (*s_p0).s.len)) goto LA4;
				if ((*s_p0).rd < 0 || (*s_p0).rd >= (*s_p0).s.len){ raiseIndexError2((*s_p0).rd,(*s_p0).s.len-1); goto BeforeRet_;
				}
				switch (((NU8)((*s_p0).s.p->data[(*s_p0).rd]))) {
				case 13:
				{
					NI TM__ml9aueblxGz9aYsRLKvPmpow_3;
					if (nimAddInt((*s_p0).rd, ((NI)1), &TM__ml9aueblxGz9aYsRLKvPmpow_3)) { raiseOverflow(); goto BeforeRet_;
					};
					(*s_p0).rd = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_3);
					{
						NI TM__ml9aueblxGz9aYsRLKvPmpow_4;
						if ((*s_p0).rd < 0 || (*s_p0).rd >= (*s_p0).s.len){ raiseIndexError2((*s_p0).rd,(*s_p0).s.len-1); goto BeforeRet_;
						}
						if (!((NU8)((*s_p0).s.p->data[(*s_p0).rd]) == (NU8)(10))) goto LA8_;
						if (nimAddInt((*s_p0).rd, ((NI)1), &TM__ml9aueblxGz9aYsRLKvPmpow_4)) { raiseOverflow(); goto BeforeRet_;
						};
						(*s_p0).rd = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_4);
					}
LA8_: ;
					goto LA3;
				}
				break;
				case 10:
				{
					NI TM__ml9aueblxGz9aYsRLKvPmpow_5;
					if (nimAddInt((*s_p0).rd, ((NI)1), &TM__ml9aueblxGz9aYsRLKvPmpow_5)) { raiseOverflow(); goto BeforeRet_;
					};
					(*s_p0).rd = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_5);
					goto LA3;
				}
				break;
				default:
				{
					NI TM__ml9aueblxGz9aYsRLKvPmpow_6;
					if ((*s_p0).rd < 0 || (*s_p0).rd >= (*s_p0).s.len){ raiseIndexError2((*s_p0).rd,(*s_p0).s.len-1); goto BeforeRet_;
					}
					nimAddCharV1((&(*line_p1)), (*s_p0).s.p->data[(*s_p0).rd]);
					if (nimAddInt((*s_p0).rd, ((NI)1), &TM__ml9aueblxGz9aYsRLKvPmpow_6)) { raiseOverflow(); goto BeforeRet_;
					};
					(*s_p0).rd = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_6);
				}
				break;
				}
			} LA4: ;
		} LA3: ;
		T12_ = (NIM_BOOL)0;
		T12_ = (((NI)0) < (*line_p1).len);
		if (T12_) goto LA13_;
		T12_ = ((*s_p0).rd < (*s_p0).s.len);
LA13_: ;
		result = T12_;
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)2):
	{
		result = readLine__stdZsyncio_u291((*s_p0).f, line_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)3):
	{
		result = readLine__stdZsyncio_u291(__stdinp, line_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	break;
	default: __builtin_unreachable();
	}
	}BeforeRet_: ;
	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___OOZOOZOOZcompilerZllstream_u114)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ** dest_p0, tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* src_p1, NIM_BOOL cyclic_p2) {
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* 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(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;
}
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, llStreamRead__OOZOOZOOZcompilerZllstream_u436)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, void* buf_p1, NI bufLen_p2) {
	NI result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NI)0;
	switch ((*s_p0).kind) {
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)0):
	{
		result = ((NI)0);
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)1):
	{
		NI TM__ml9aueblxGz9aYsRLKvPmpow_7;
		if (nimSubInt((*s_p0).s.len, (*s_p0).rd, &TM__ml9aueblxGz9aYsRLKvPmpow_7)) { raiseOverflow(); goto BeforeRet_;
		};
		result = ((bufLen_p2 <= (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_7)) ? bufLen_p2 : (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_7));
		{
			NI TM__ml9aueblxGz9aYsRLKvPmpow_8;
			NI TM__ml9aueblxGz9aYsRLKvPmpow_9;
			if (!(((NI)0) < result)) goto LA5_;
			if (nimAddInt(((NI)0), (*s_p0).rd, &TM__ml9aueblxGz9aYsRLKvPmpow_8)) { raiseOverflow(); goto BeforeRet_;
			};
			if ((NI)(TM__ml9aueblxGz9aYsRLKvPmpow_8) < 0 || (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_8) >= (*s_p0).s.len){ raiseIndexError2((NI)(TM__ml9aueblxGz9aYsRLKvPmpow_8),(*s_p0).s.len-1); goto BeforeRet_;
			}
			if ((result) < ((NI)0) || (result) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(result, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
			}
			copyMem__system_u1755(buf_p1, ((void*) ((&(*s_p0).s.p->data[(NI)(TM__ml9aueblxGz9aYsRLKvPmpow_8)]))), (result));
			if (nimAddInt((*s_p0).rd, result, &TM__ml9aueblxGz9aYsRLKvPmpow_9)) { raiseOverflow(); goto BeforeRet_;
			};
			(*s_p0).rd = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_9);
		}
LA5_: ;
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)2):
	{
		if ((bufLen_p2) < ((NI)0) || (bufLen_p2) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(bufLen_p2, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
		}
		result = readBuffer__stdZsyncio_u165((*s_p0).f, buf_p1, (bufLen_p2));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)3):
	{
		{
			if (!!(((*s_p0).onPrompt.ClP_0 == TM__ml9aueblxGz9aYsRLKvPmpow_10.ClP_0 && (*s_p0).onPrompt.ClE_0 == TM__ml9aueblxGz9aYsRLKvPmpow_10.ClE_0))) goto LA11_;
			(*s_p0).onPrompt.ClE_0? (*s_p0).onPrompt.ClP_0((*s_p0).onPrompt.ClE_0):((TM__ml9aueblxGz9aYsRLKvPmpow_11)((*s_p0).onPrompt.ClP_0))();
			if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		}
LA11_: ;
		result = (*s_p0).repl.ClE_0? (*s_p0).repl.ClP_0(s_p0, buf_p1, bufLen_p2, (*s_p0).repl.ClE_0):((TM__ml9aueblxGz9aYsRLKvPmpow_12)((*s_p0).repl.ClP_0))(s_p0, buf_p1, bufLen_p2);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	break;
	default: __builtin_unreachable();
	}
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*, llStreamOpen__OOZOOZOOZcompilerZllstream_u31)(NimStringV2 data_p0) {
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* result;
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* T1_;
	NimStringV2 blitTmp_1;
	T1_ = NIM_NIL;
	T1_ = (tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*) nimNewObj(sizeof(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ), NIM_ALIGNOF(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ));
	(*T1_).Sup.m_type = (&NTIv2__SBuFBW9b2EpSkuka9b9cYZHgQ_);
	(*T1_).kind = ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)1);
	blitTmp_1 = data_p0;
	(*T1_).s = blitTmp_1;
	result = T1_;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, llStreamClose__OOZOOZOOZcompilerZllstream_u181)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	switch ((*s_p0).kind) {
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)0):
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)1):
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)3):
	{
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)2):
	{
		close__stdZsyncio_u269((*s_p0).f);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	break;
	default: __builtin_unreachable();
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*, eqdup___OOZOOZOOZcompilerZllstream_u118)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* src_p0, NIM_BOOL cyclic_p1) {
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* result;
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* colontmp_;
	result = NIM_NIL;
	colontmp_ = result;
	result = src_p0;
	{
		if (!src_p0) goto LA3_;
		nimIncRefCyclic(src_p0, cyclic_p1);
	}
LA3_: ;
	return result;
}
static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1) {
	{
		if (!(((NI)0) < src_p1.len)) goto LA3_;
		copyMem__system_u1755(((void*) ((&(*(*dest_p0).p).data[(*dest_p0).len]))), ((void*) ((&(*src_p1.p).data[((NI)0)]))), (src_p1.len));
		(*dest_p0).len += src_p1.len;
		(*(*dest_p0).p).data[(*dest_p0).len] = 0;
	}
LA3_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, llStreamWrite__OOZOOZOOZcompilerZllstream_u478)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, NimStringV2 data_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	switch ((*s_p0).kind) {
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)0):
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)3):
	{
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)1):
	{
		NI TM__ml9aueblxGz9aYsRLKvPmpow_13;
		prepareAdd((&(*s_p0).s), data_p1.len + 0);
appendString((&(*s_p0).s), data_p1);
		if (nimAddInt((*s_p0).wr, data_p1.len, &TM__ml9aueblxGz9aYsRLKvPmpow_13)) { raiseOverflow(); goto BeforeRet_;
		};
		(*s_p0).wr = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_13);
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)2):
	{
		write__stdZsyncio_u254((*s_p0).f, data_p1);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}
	break;
	default: __builtin_unreachable();
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, endsWith__OOZOOZOOZcompilerZllstream_u187)(NimStringV2 x_p0, tySet_tyChar__nmiMWKVIe46vacnhAFrQvw s_p1) {
	NIM_BOOL result;
	NI i_1;
	NI TM__ml9aueblxGz9aYsRLKvPmpow_14;
{	result = (NIM_BOOL)0;
	if (nimSubInt(x_p0.len, ((NI)1), &TM__ml9aueblxGz9aYsRLKvPmpow_14)) { raiseOverflow(); goto BeforeRet_;
	};
	i_1 = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_14);
	{
		while (1) {
			NIM_BOOL T3_;
			NI TM__ml9aueblxGz9aYsRLKvPmpow_15;
			T3_ = (NIM_BOOL)0;
			T3_ = (((NI)0) <= i_1);
			if (!(T3_)) goto LA4_;
			if (i_1 < 0 || i_1 >= x_p0.len){ raiseIndexError2(i_1,x_p0.len-1); goto BeforeRet_;
			}
			T3_ = ((NU8)(x_p0.p->data[i_1]) == (NU8)(32));
LA4_: ;
			if (!T3_) goto LA2;
			if (nimSubInt(i_1, ((NI)1), &TM__ml9aueblxGz9aYsRLKvPmpow_15)) { raiseOverflow(); goto BeforeRet_;
			};
			i_1 = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_15);
		} LA2: ;
	}
	{
		NIM_BOOL T7_;
		T7_ = (NIM_BOOL)0;
		T7_ = (((NI)0) <= i_1);
		if (!(T7_)) goto LA8_;
		if (i_1 < 0 || i_1 >= x_p0.len){ raiseIndexError2(i_1,x_p0.len-1); goto BeforeRet_;
		}
		T7_ = ((s_p1[(NU)((((NU8)(x_p0.p->data[i_1]))))>>3] &(1U<<((NU)((((NU8)(x_p0.p->data[i_1]))))&7U)))!=0);
LA8_: ;
		if (!T7_) goto LA9_;
		result = NIM_TRUE;
	}
	goto LA5_;
LA9_: ;
	{
		result = NIM_FALSE;
	}
LA5_: ;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, llStreamWrite__OOZOOZOOZcompilerZllstream_u489)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, NIM_CHAR data_p1) {
	NIM_CHAR c_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	c_1 = (NIM_CHAR)0;
	switch ((*s_p0).kind) {
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)0):
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)3):
	{
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)1):
	{
		NI TM__ml9aueblxGz9aYsRLKvPmpow_16;
		nimAddCharV1((&(*s_p0).s), data_p1);
		if (nimAddInt((*s_p0).wr, ((NI)1), &TM__ml9aueblxGz9aYsRLKvPmpow_16)) { raiseOverflow(); goto BeforeRet_;
		};
		(*s_p0).wr = (NI)(TM__ml9aueblxGz9aYsRLKvPmpow_16);
	}
	break;
	case ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)2):
	{
		NI T4_;
		c_1 = data_p1;
		T4_ = (NI)0;
		T4_ = writeBuffer__stdZsyncio_u196((*s_p0).f, ((void*) ((&c_1))), ((NI)1));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		(void)(T4_);
	}
	break;
	default: __builtin_unreachable();
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, eqwasMoved___OOZOOZOOZcompilerZllstream_u108)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ** dest_p0) {
	(*dest_p0) = 0;
}
N_LIB_PRIVATE N_NIMCALL(void, llStreamWriteln__OOZOOZOOZcompilerZllstream_u486)(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* s_p0, NimStringV2 data_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	llStreamWrite__OOZOOZOOZcompilerZllstream_u478(s_p0, data_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	llStreamWrite__OOZOOZOOZcompilerZllstream_u478(s_p0, TM__ml9aueblxGz9aYsRLKvPmpow_18);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*, llStreamOpen__OOZOOZOOZcompilerZllstream_u132)(FILE* f_p0) {
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* result;
	tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ* T1_;
	T1_ = NIM_NIL;
	T1_ = (tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ*) nimNewObj(sizeof(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ), NIM_ALIGNOF(tyObject_TLLStream__SBuFBW9b2EpSkuka9b9cYZHgQ));
	(*T1_).Sup.m_type = (&NTIv2__SBuFBW9b2EpSkuka9b9cYZHgQ_);
	(*T1_).kind = ((tyEnum_TLLStreamKind__Vt32Tvf0nxx4kIGObvTB4w)2);
	(*T1_).f = f_p0;
	result = T1_;
	return result;
}
