/* Generated by Nim Compiler v0.17.0 */
/*   (c) 2017 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, i386, gcc */
/* Command for C compiler:
   gcc -c  -w -O3 -fno-strict-aliasing -fPIC  -I/build/nim/src/Nim-0.17.0/lib -o lib/nimcache/stdlib_ropes.o lib/nimcache/stdlib_ropes.c */
#define NIM_NEW_MANGLING_RULES
#define NIM_INTBITS 32

#include "nimbase.h"
#include <string.h>
#include <stdio.h>
#undef linux
#undef near
typedef struct RopeObj_pk4sC5H3E9ceov4bEasyPVw RopeObj_pk4sC5H3E9ceov4bEasyPVw;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Cell_1zcF9cV8XIAtbN8h5HRUB8g Cell_1zcF9cV8XIAtbN8h5HRUB8g;
typedef struct TY_xyYfiXqv9bXR7uHakYC9cy3A TY_xyYfiXqv9bXR7uHakYC9cy3A;
typedef struct ValueError_Gi06FkNeykJn7mrqRZYrkA ValueError_Gi06FkNeykJn7mrqRZYrkA;
typedef struct Exception Exception;
typedef struct TNimObject TNimObject;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  RopeObj_pk4sC5H3E9ceov4bEasyPVw  {
RopeObj_pk4sC5H3E9ceov4bEasyPVw* left;
RopeObj_pk4sC5H3E9ceov4bEasyPVw* right;
NI length;
NimStringDesc* data;
};
typedef NU8 TNimKind_jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 TNimTypeFlag_v8QUszD1sWlSIWZz7mC4bQ_Set;
typedef N_NIMCALL_PTR(void, TY_ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY_WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct  TNimType  {
NI size;
TNimKind_jIBKr1ejBgsfM33Kxw4j7A kind;
TNimTypeFlag_v8QUszD1sWlSIWZz7mC4bQ_Set flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY_ojoeKfW4VYIm36I9cpDTQIg marker;
TY_WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 TNimNodeKind_unfNsxrcATrufDZmpBq4HQ;
struct  TNimNode  {
TNimNodeKind_unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef N_NIMCALL_PTR(void, TY_T4eqaYlFJYZUv9aG9b1TV0bQ) (void);
struct  Cell_1zcF9cV8XIAtbN8h5HRUB8g  {
NI refcount;
TNimType* typ;
};
struct  TNimObject  {
TNimType* m_type;
};
struct  Exception  {
  TNimObject Sup;
Exception* parent;
NCSTRING name;
NimStringDesc* message;
NimStringDesc* trace;
};
struct  ValueError_Gi06FkNeykJn7mrqRZYrkA  {
  Exception Sup;
};
typedef NIM_CHAR TY_9bKy7UA2LOi2vzOViufaW1Q[1024];
typedef NU8 FileMode_fVUBHvW79bXUw1j55Oo9avSQ;
struct TY_xyYfiXqv9bXR7uHakYC9cy3A {
  TGenericSeq Sup;
  RopeObj_pk4sC5H3E9ceov4bEasyPVw* data[SEQ_DECL_SIZE];
};
N_LIB_EXPORT N_CDECL(NI, nrolen)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* a);
N_LIB_EXPORT N_CDECL(void, nimrtl_nimGCvisit)(void* d, NI op);
static N_NIMCALL(void, Marker_TY_VYsfqmmqchsY5XzU9aJJBBA)(void* p, NI op);
static N_NIMCALL(void, TM_7lAtbav61D2a8Y3CNxNADw_3)(void);
N_NIMCALL(void, nimRegisterGlobalMarker)(TY_T4eqaYlFJYZUv9aG9b1TV0bQ markerProc);
static N_NIMCALL(void, TM_7lAtbav61D2a8Y3CNxNADw_4)(void);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroropeStr)(NimStringDesc* s);
N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, insertInCache_zyNKR9bGqWnYs3KqoSwEkmw)(NimStringDesc* s, RopeObj_pk4sC5H3E9ceov4bEasyPVw* tree);
N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, newRope_ZCIC6k9cUm3AxZaNUwQjbQA)(NimStringDesc* data);
N_LIB_EXPORT N_CDECL(void*, nimrtl_newObj)(TNimType* typ, NI size);
N_LIB_EXPORT N_CDECL(NimStringDesc*, nimrtl_copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(Cell_1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell_yB9aH5WIlwd0xkYrcdPeXrQsystem)(void* usr);
N_LIB_EXPORT N_CDECL(void, nimrtl_rtlAddZCT)(Cell_1zcF9cV8XIAtbN8h5HRUB8g* c);
N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, splay_7mVUhfvaqnODOd3UFhWBOw)(NimStringDesc* s, RopeObj_pk4sC5H3E9ceov4bEasyPVw* tree, NI* cmpres);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(NI, cmp_xEnKsp9cfvO7Do9cTYXo8eJw)(NimStringDesc* x, NimStringDesc* y);
static N_INLINE(NI, cmpStrings)(NimStringDesc* a, NimStringDesc* b);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroropeBiggestInt)(NI64 i);
N_LIB_EXPORT N_CDECL(NimStringDesc*, nimrtl_nimInt64ToStr)(NI64 x);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroropeBiggestFloat)(NF f);
N_NIMCALL(NimStringDesc*, nimFloatToStr)(NF f);
N_LIB_EXPORT N_CDECL(void, nroenableCache)(void);
N_LIB_EXPORT N_CDECL(void, nrodisableCache)(void);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcRopeRope)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* a, RopeObj_pk4sC5H3E9ceov4bEasyPVw* b);
N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, newRope_WJVf4Z1xJABh8ibr4mr22w)(void);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcRopeStr)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* a, NimStringDesc* b);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcStrRope)(NimStringDesc* a, RopeObj_pk4sC5H3E9ceov4bEasyPVw* b);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcOpenArray)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** a, NI aLen_0);
N_LIB_EXPORT N_CDECL(void, nroaddRope)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** a, RopeObj_pk4sC5H3E9ceov4bEasyPVw* b);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_LIB_EXPORT N_CDECL(void, nroaddStr)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** a, NimStringDesc* b);
N_LIB_EXPORT N_CDECL(NIM_CHAR, nroCharAt)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r, NI i);
static N_INLINE(NIM_BOOL, isConc_XZ8qsVA5ELaAT0pRYWW5Ywropes)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r);
N_LIB_EXPORT N_CDECL(void, nrowrite)(FILE* f, RopeObj_pk4sC5H3E9ceov4bEasyPVw* r);
N_LIB_EXPORT N_CDECL(void*, nimrtl_newSeq)(TNimType* typ, NI len);
static N_INLINE(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, pop_ty7pjOMAEzlk2hF5VjHEsAropes)(TY_xyYfiXqv9bXR7uHakYC9cy3A** s);
N_LIB_EXPORT N_CDECL(TGenericSeq*, nimrtl_setLengthSeq)(TGenericSeq* seq, NI elemSize, NI newLen);
N_NIMCALL(TGenericSeq*, incrSeqV2)(TGenericSeq* seq, NI elemSize);
N_NIMCALL(void, write_c4mGyJBvK73pdM22jiweKQ)(FILE* f, NimStringDesc* s);
N_LIB_EXPORT N_CDECL(NimStringDesc*, nroToString)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_NIMCALL(NimStringDesc*, mnewString)(NI len);
N_LIB_EXPORT N_CDECL(NimStringDesc*, nimrtl_setLengthStr)(NimStringDesc* s, NI newLen);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem_fPlwH3r9agN9aEHB6yCPMh0wsystem)(void* dest, void* source, NI size);
N_LIB_EXPORT N_CDECL(NimStringDesc*, nimrtl_resizeString)(NimStringDesc* dest, NI addlen);
N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroFormat)(NimStringDesc* frmt, RopeObj_pk4sC5H3E9ceov4bEasyPVw** args, NI argsLen_0);
static N_INLINE(void, asgnRef)(void** dest, void* src);
static N_INLINE(void, incRef_9cAA5YuQAAC3MVbnGeV86swsystem)(Cell_1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(void, decRef_MV4BBk6J1qu70IbBxwEn4wsystem)(Cell_1zcF9cV8XIAtbN8h5HRUB8g* c);
N_LIB_EXPORT N_CDECL(void, nimrtl_raiseException)(Exception* e, NCSTRING ename);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
N_LIB_EXPORT N_CDECL(void, nroaddf)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** c, NimStringDesc* frmt, RopeObj_pk4sC5H3E9ceov4bEasyPVw** args, NI argsLen_0);
N_LIB_EXPORT N_CDECL(NIM_BOOL, nroequalsFileFile)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r, FILE* f);
N_NIMCALL(NI, readBuffer_nZ0pNe9cd9cXtoayexCiaDtA)(FILE* f, void* buffer, NI len);
static N_INLINE(NIM_BOOL, equalMem_DCrUjdaMvFDHaR1hs7sQGwstrutils)(void* a, void* b, NI size);
N_LIB_EXPORT N_CDECL(NIM_BOOL, nroequalsFileStr)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r, NimStringDesc* filename);
N_NIMCALL(NIM_BOOL, open_sEp0GH2306oGo9bqBpj5oTQ)(FILE** f, NimStringDesc* filename, FileMode_fVUBHvW79bXUw1j55Oo9avSQ mode, NI bufSize);
N_NIMCALL(void, close_BWnr8V7RERYno9bIdPmw8Hw_2)(FILE* f);
N_LIB_EXPORT N_CDECL(void*, nimrtl_newObjRC1)(TNimType* typ, NI size);
NIM_BOOL cacheEnabled_Tx9b9cwni2VzCnsN5eGrePhg;
RopeObj_pk4sC5H3E9ceov4bEasyPVw* cache_lDP9b48rBnemgIUaWT45Xng;
TNimType NTI_pk4sC5H3E9ceov4bEasyPVw_;
extern TNimType NTI_rR5Bzr1D5krxoo1NcNyeMA_;
extern TNimType NTI_77mFvmsOLKik79ci2hXkHEg_;
TNimType NTI_VYsfqmmqchsY5XzU9aJJBBA_;
RopeObj_pk4sC5H3E9ceov4bEasyPVw* N_Exgp9asfFKZJfhz9bzz9bL89cg;
extern TNimType NTI_xyYfiXqv9bXR7uHakYC9cy3A_;
extern TNimType NTI_yCEN9anxCD6mzBxGjuaRBdg_;
extern TNimType NTI_Gi06FkNeykJn7mrqRZYrkA_;
STRING_LITERAL(TM_7lAtbav61D2a8Y3CNxNADw_5, "$", 1);
STRING_LITERAL(TM_7lAtbav61D2a8Y3CNxNADw_6, "invalid format string", 21);

N_LIB_EXPORT N_CDECL(NI, nrolen)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* a) {
	NI result;
	result = (NI)0;
	{
		if (!(a == NIM_NIL)) goto LA3_;
		result = ((NI) 0);
	}
	goto LA1_;
	LA3_: ;
	{
		result = (*a).length;
	}
	LA1_: ;
	return result;
}
static N_NIMCALL(void, Marker_TY_VYsfqmmqchsY5XzU9aJJBBA)(void* p, NI op) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* a;
	a = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)p;
	nimrtl_nimGCvisit((void*)(*a).left, op);
	nimrtl_nimGCvisit((void*)(*a).right, op);
	nimrtl_nimGCvisit((void*)(*a).data, op);
}
static N_NIMCALL(void, TM_7lAtbav61D2a8Y3CNxNADw_3)(void) {
	nimrtl_nimGCvisit((void*)cache_lDP9b48rBnemgIUaWT45Xng, 0);
}
static N_NIMCALL(void, TM_7lAtbav61D2a8Y3CNxNADw_4)(void) {
	nimrtl_nimGCvisit((void*)N_Exgp9asfFKZJfhz9bzz9bL89cg, 0);
}

static N_INLINE(Cell_1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell_yB9aH5WIlwd0xkYrcdPeXrQsystem)(void* usr) {
	Cell_1zcF9cV8XIAtbN8h5HRUB8g* result;
	result = (Cell_1zcF9cV8XIAtbN8h5HRUB8g*)0;
	result = ((Cell_1zcF9cV8XIAtbN8h5HRUB8g*) ((NI)((NU32)(((NI) (usr))) - (NU32)(((NI)sizeof(Cell_1zcF9cV8XIAtbN8h5HRUB8g))))));
	return result;
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	Cell_1zcF9cV8XIAtbN8h5HRUB8g* c;
	c = usrToCell_yB9aH5WIlwd0xkYrcdPeXrQsystem(p);
	{
		(*c).refcount -= ((NI) 8);
		if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA3_;
		nimrtl_rtlAddZCT(c);
	}
	LA3_: ;
}

N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, newRope_ZCIC6k9cUm3AxZaNUwQjbQA)(NimStringDesc* data) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	NimStringDesc* T1_;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*) nimrtl_newObj((&NTI_VYsfqmmqchsY5XzU9aJJBBA_), sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw));
	(*result).length = (data ? data->Sup.len : 0);
	T1_ = (NimStringDesc*)0;
	T1_ = (*result).data; (*result).data = nimrtl_copyStringRC1(data);
	if (T1_) nimGCunrefNoCycle(T1_);
	return result;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		Cell_1zcF9cV8XIAtbN8h5HRUB8g* c;
		if (!!((src == NIM_NIL))) goto LA3_;
		c = usrToCell_yB9aH5WIlwd0xkYrcdPeXrQsystem(src);
		(*c).refcount += ((NI) 8);
	}
	LA3_: ;
	{
		Cell_1zcF9cV8XIAtbN8h5HRUB8g* c_2;
		if (!!(((*dest) == NIM_NIL))) goto LA7_;
		c_2 = usrToCell_yB9aH5WIlwd0xkYrcdPeXrQsystem((*dest));
		{
			(*c_2).refcount -= ((NI) 8);
			if (!((NU32)((*c_2).refcount) < (NU32)(((NI) 8)))) goto LA11_;
			nimrtl_rtlAddZCT(c_2);
		}
		LA11_: ;
	}
	LA7_: ;
	(*dest) = src;
}

static N_INLINE(NI, cmpStrings)(NimStringDesc* a, NimStringDesc* b) {
	NI result;
	int T13_;
{	result = (NI)0;
	{
		if (!(a == b)) goto LA3_;
		result = ((NI) 0);
		goto BeforeRet_;
	}
	LA3_: ;
	{
		if (!(a == NIM_NIL)) goto LA7_;
		result = ((NI) -1);
		goto BeforeRet_;
	}
	LA7_: ;
	{
		if (!(b == NIM_NIL)) goto LA11_;
		result = ((NI) 1);
		goto BeforeRet_;
	}
	LA11_: ;
	T13_ = (int)0;
	T13_ = strcmp(((NCSTRING) ((*a).data)), ((NCSTRING) ((*b).data)));
	result = ((NI) (T13_));
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}

N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, splay_7mVUhfvaqnODOd3UFhWBOw)(NimStringDesc* s, RopeObj_pk4sC5H3E9ceov4bEasyPVw* tree, NI* cmpres) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	NI c;
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* t;
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* le;
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* r;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	c = (NI)0;
	t = tree;
	asgnRefNoCycle((void**) (&(*N_Exgp9asfFKZJfhz9bzz9bL89cg).left), NIM_NIL);
	asgnRefNoCycle((void**) (&(*N_Exgp9asfFKZJfhz9bzz9bL89cg).right), NIM_NIL);
	le = N_Exgp9asfFKZJfhz9bzz9bL89cg;
	r = N_Exgp9asfFKZJfhz9bzz9bL89cg;
	{
		while (1) {
			c = cmp_xEnKsp9cfvO7Do9cTYXo8eJw(s, (*t).data);
			{
				if (!(c < ((NI) 0))) goto LA5_;
				{
					NIM_BOOL T9_;
					RopeObj_pk4sC5H3E9ceov4bEasyPVw* y;
					T9_ = (NIM_BOOL)0;
					T9_ = !(((*t).left == NIM_NIL));
					if (!(T9_)) goto LA10_;
					T9_ = (cmpStrings(s, (*(*t).left).data) < 0);
					LA10_: ;
					if (!T9_) goto LA11_;
					y = (*t).left;
					asgnRefNoCycle((void**) (&(*t).left), (*y).right);
					asgnRefNoCycle((void**) (&(*y).right), t);
					t = y;
				}
				LA11_: ;
				{
					if (!((*t).left == NIM_NIL)) goto LA15_;
					goto LA1;
				}
				LA15_: ;
				asgnRefNoCycle((void**) (&(*r).left), t);
				r = t;
				t = (*t).left;
			}
			goto LA3_;
			LA5_: ;
			{
				if (!(((NI) 0) < c)) goto LA18_;
				{
					NIM_BOOL T22_;
					RopeObj_pk4sC5H3E9ceov4bEasyPVw* y_2;
					T22_ = (NIM_BOOL)0;
					T22_ = !(((*t).right == NIM_NIL));
					if (!(T22_)) goto LA23_;
					T22_ = (cmpStrings((*(*t).right).data, s) < 0);
					LA23_: ;
					if (!T22_) goto LA24_;
					y_2 = (*t).right;
					asgnRefNoCycle((void**) (&(*t).right), (*y_2).left);
					asgnRefNoCycle((void**) (&(*y_2).left), t);
					t = y_2;
				}
				LA24_: ;
				{
					if (!((*t).right == NIM_NIL)) goto LA28_;
					goto LA1;
				}
				LA28_: ;
				asgnRefNoCycle((void**) (&(*le).right), t);
				le = t;
				t = (*t).right;
			}
			goto LA3_;
			LA18_: ;
			{
				goto LA1;
			}
			LA3_: ;
		}
	} LA1: ;
	(*cmpres) = c;
	asgnRefNoCycle((void**) (&(*le).right), (*t).left);
	asgnRefNoCycle((void**) (&(*r).left), (*t).right);
	asgnRefNoCycle((void**) (&(*t).left), (*N_Exgp9asfFKZJfhz9bzz9bL89cg).right);
	asgnRefNoCycle((void**) (&(*t).right), (*N_Exgp9asfFKZJfhz9bzz9bL89cg).left);
	result = t;
	return result;
}

N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, insertInCache_zyNKR9bGqWnYs3KqoSwEkmw)(NimStringDesc* s, RopeObj_pk4sC5H3E9ceov4bEasyPVw* tree) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* t;
	NI cmp;
{	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	t = tree;
	{
		if (!(t == NIM_NIL)) goto LA3_;
		result = newRope_ZCIC6k9cUm3AxZaNUwQjbQA(s);
		goto BeforeRet_;
	}
	LA3_: ;
	cmp = (NI)0;
	t = splay_7mVUhfvaqnODOd3UFhWBOw(s, t, (&cmp));
	{
		if (!(cmp == ((NI) 0))) goto LA7_;
		result = t;
	}
	goto LA5_;
	LA7_: ;
	{
		result = newRope_ZCIC6k9cUm3AxZaNUwQjbQA(s);
		{
			if (!(cmp < ((NI) 0))) goto LA12_;
			asgnRefNoCycle((void**) (&(*result).left), (*t).left);
			asgnRefNoCycle((void**) (&(*result).right), t);
			asgnRefNoCycle((void**) (&(*t).left), NIM_NIL);
		}
		goto LA10_;
		LA12_: ;
		{
			asgnRefNoCycle((void**) (&(*result).right), (*t).right);
			asgnRefNoCycle((void**) (&(*result).left), t);
			asgnRefNoCycle((void**) (&(*t).right), NIM_NIL);
		}
		LA10_: ;
	}
	LA5_: ;
	}BeforeRet_: ;
	return result;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroropeStr)(NimStringDesc* s) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	{
		if (!((s ? s->Sup.len : 0) == ((NI) 0))) goto LA3_;
		result = NIM_NIL;
	}
	goto LA1_;
	LA3_: ;
	{
		{
			if (!cacheEnabled_Tx9b9cwni2VzCnsN5eGrePhg) goto LA8_;
			result = insertInCache_zyNKR9bGqWnYs3KqoSwEkmw(s, cache_lDP9b48rBnemgIUaWT45Xng);
			asgnRefNoCycle((void**) (&cache_lDP9b48rBnemgIUaWT45Xng), result);
		}
		goto LA6_;
		LA8_: ;
		{
			result = newRope_ZCIC6k9cUm3AxZaNUwQjbQA(s);
		}
		LA6_: ;
	}
	LA1_: ;
	return result;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroropeBiggestInt)(NI64 i) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	NimStringDesc* T1_;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	T1_ = (NimStringDesc*)0;
	T1_ = nimrtl_nimInt64ToStr(i);
	result = nroropeStr(T1_);
	return result;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroropeBiggestFloat)(NF f) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	NimStringDesc* T1_;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	T1_ = (NimStringDesc*)0;
	T1_ = nimFloatToStr(f);
	result = nroropeStr(T1_);
	return result;
}

N_LIB_EXPORT N_CDECL(void, nroenableCache)(void) {
	cacheEnabled_Tx9b9cwni2VzCnsN5eGrePhg = NIM_TRUE;
}

N_LIB_EXPORT N_CDECL(void, nrodisableCache)(void) {
	asgnRefNoCycle((void**) (&cache_lDP9b48rBnemgIUaWT45Xng), NIM_NIL);
	cacheEnabled_Tx9b9cwni2VzCnsN5eGrePhg = NIM_FALSE;
}

N_NIMCALL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, newRope_WJVf4Z1xJABh8ibr4mr22w)(void) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*) nimrtl_newObj((&NTI_VYsfqmmqchsY5XzU9aJJBBA_), sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw));
	return result;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcRopeRope)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* a, RopeObj_pk4sC5H3E9ceov4bEasyPVw* b) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	{
		if (!(a == NIM_NIL)) goto LA3_;
		result = b;
	}
	goto LA1_;
	LA3_: ;
	{
		if (!(b == NIM_NIL)) goto LA6_;
		result = a;
	}
	goto LA1_;
	LA6_: ;
	{
		result = newRope_WJVf4Z1xJABh8ibr4mr22w();
		(*result).length = (NI)((*a).length + (*b).length);
		asgnRefNoCycle((void**) (&(*result).left), a);
		asgnRefNoCycle((void**) (&(*result).right), b);
	}
	LA1_: ;
	return result;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcRopeStr)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* a, NimStringDesc* b) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* T1_;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	T1_ = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	T1_ = nroropeStr(b);
	result = nroConcRopeRope(a, T1_);
	return result;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcStrRope)(NimStringDesc* a, RopeObj_pk4sC5H3E9ceov4bEasyPVw* b) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* T1_;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	T1_ = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	T1_ = nroropeStr(a);
	result = nroConcRopeRope(T1_, b);
	return result;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroConcOpenArray)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** a, NI aLen_0) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (aLen_0-1);
		res = ((NI) 0);
		{
			while (1) {
				if (!(res <= colontmp_)) goto LA3;
				i = res;
				result = nroConcRopeRope(result, a[i]);
				res += ((NI) 1);
			} LA3: ;
		}
	}
	return result;
}

N_LIB_EXPORT N_CDECL(void, nroaddRope)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** a, RopeObj_pk4sC5H3E9ceov4bEasyPVw* b) {
	unsureAsgnRef((void**) (&(*a)), nroConcRopeRope((*a), b));
}

N_LIB_EXPORT N_CDECL(void, nroaddStr)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** a, NimStringDesc* b) {
	unsureAsgnRef((void**) (&(*a)), nroConcRopeStr((*a), b));
}

static N_INLINE(NIM_BOOL, isConc_XZ8qsVA5ELaAT0pRYWW5Ywropes)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r) {
	NIM_BOOL result;
{	result = (NIM_BOOL)0;
	result = ((*r).data == 0);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}

N_LIB_EXPORT N_CDECL(NIM_CHAR, nroCharAt)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r, NI i) {
	NIM_CHAR result;
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* x;
	NI j;
{	result = (NIM_CHAR)0;
	x = r;
	j = i;
	{
		if (!(x == NIM_NIL)) goto LA3_;
		goto BeforeRet_;
	}
	LA3_: ;
	{
		while (1) {
			{
				NIM_BOOL T9_;
				T9_ = (NIM_BOOL)0;
				T9_ = isConc_XZ8qsVA5ELaAT0pRYWW5Ywropes(x);
				if (!!(T9_)) goto LA10_;
				{
					if (!((NU32)(((*x).data ? (*x).data->Sup.len : 0)) < (NU32)(j))) goto LA14_;
					result = (*x).data->data[j];
					goto BeforeRet_;
				}
				LA14_: ;
				result = 0;
				goto BeforeRet_;
			}
			goto LA7_;
			LA10_: ;
			{
				{
					NI T19_;
					T19_ = (NI)0;
					T19_ = nrolen((*x).left);
					if (!((NU32)(j) < (NU32)(T19_))) goto LA20_;
					x = (*x).left;
				}
				goto LA17_;
				LA20_: ;
				{
					NI T23_;
					x = (*x).right;
					T23_ = (NI)0;
					T23_ = nrolen(x);
					j -= T23_;
				}
				LA17_: ;
			}
			LA7_: ;
		}
	}
	}BeforeRet_: ;
	return result;
}

static N_INLINE(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, pop_ty7pjOMAEzlk2hF5VjHEsAropes)(TY_xyYfiXqv9bXR7uHakYC9cy3A** s) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	NI L;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	L = (NI)(((*s) ? (*s)->Sup.len : 0) - ((NI) 1));
	result = (*s)->data[L];
	(*s) = (TY_xyYfiXqv9bXR7uHakYC9cy3A*) nimrtl_setLengthSeq(&((*s))->Sup, sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw*), ((NI) (L)));
	return result;
}

N_LIB_EXPORT N_CDECL(void, nrowrite)(FILE* f, RopeObj_pk4sC5H3E9ceov4bEasyPVw* r) {
	{
		NimStringDesc* s;
		s = (NimStringDesc*)0;
		{
			TY_xyYfiXqv9bXR7uHakYC9cy3A* stack;
			if (!!((r == NIM_NIL))) goto LA4_;
			stack = (TY_xyYfiXqv9bXR7uHakYC9cy3A*) nimrtl_newSeq((&NTI_xyYfiXqv9bXR7uHakYC9cy3A_), 1);
			asgnRefNoCycle((void**) (&stack->data[0]), r);
			{
				while (1) {
					RopeObj_pk4sC5H3E9ceov4bEasyPVw* it;
					if (!(((NI) 0) < (stack ? stack->Sup.len : 0))) goto LA7;
					it = pop_ty7pjOMAEzlk2hF5VjHEsAropes((&stack));
					{
						while (1) {
							NIM_BOOL T10_;
							T10_ = (NIM_BOOL)0;
							T10_ = isConc_XZ8qsVA5ELaAT0pRYWW5Ywropes(it);
							if (!T10_) goto LA9;
							stack = (TY_xyYfiXqv9bXR7uHakYC9cy3A*) incrSeqV2(&(stack)->Sup, sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw*));
							asgnRefNoCycle((void**) (&stack->data[stack->Sup.len]), (*it).right);
							++stack->Sup.len;
							it = (*it).left;
						} LA9: ;
					}
					s = (*it).data;
					write_c4mGyJBvK73pdM22jiweKQ(f, s);
				} LA7: ;
			}
		}
		LA4_: ;
	}
}

static N_INLINE(void, copyMem_fPlwH3r9agN9aEHB6yCPMh0wsystem)(void* dest, void* source, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest, source, ((size_t) (size)));
}

static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	copyMem_fPlwH3r9agN9aEHB6yCPMh0wsystem(((void*) ((&(*dest).data[((*dest).Sup.len)- 0]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
	(*dest).Sup.len += (*src).Sup.len;
}

N_LIB_EXPORT N_CDECL(NimStringDesc*, nroToString)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r) {
	NimStringDesc* result;
	NI T1_;
	result = (NimStringDesc*)0;
	T1_ = (NI)0;
	T1_ = nrolen(r);
	result = mnewString(((NI) (T1_)));
	result = nimrtl_setLengthStr(result, ((NI) 0));
	{
		NimStringDesc* s;
		s = (NimStringDesc*)0;
		{
			TY_xyYfiXqv9bXR7uHakYC9cy3A* stack;
			if (!!((r == NIM_NIL))) goto LA5_;
			stack = (TY_xyYfiXqv9bXR7uHakYC9cy3A*) nimrtl_newSeq((&NTI_xyYfiXqv9bXR7uHakYC9cy3A_), 1);
			asgnRefNoCycle((void**) (&stack->data[0]), r);
			{
				while (1) {
					RopeObj_pk4sC5H3E9ceov4bEasyPVw* it;
					if (!(((NI) 0) < (stack ? stack->Sup.len : 0))) goto LA8;
					it = pop_ty7pjOMAEzlk2hF5VjHEsAropes((&stack));
					{
						while (1) {
							NIM_BOOL T11_;
							T11_ = (NIM_BOOL)0;
							T11_ = isConc_XZ8qsVA5ELaAT0pRYWW5Ywropes(it);
							if (!T11_) goto LA10;
							stack = (TY_xyYfiXqv9bXR7uHakYC9cy3A*) incrSeqV2(&(stack)->Sup, sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw*));
							asgnRefNoCycle((void**) (&stack->data[stack->Sup.len]), (*it).right);
							++stack->Sup.len;
							it = (*it).left;
						} LA10: ;
					}
					s = (*it).data;
					result = nimrtl_resizeString(result, s->Sup.len + 0);
appendString(result, s);
				} LA8: ;
			}
		}
		LA5_: ;
	}
	return result;
}

static N_INLINE(void, incRef_9cAA5YuQAAC3MVbnGeV86swsystem)(Cell_1zcF9cV8XIAtbN8h5HRUB8g* c) {
	(*c).refcount = (NI)((NU32)((*c).refcount) + (NU32)(((NI) 8)));
}

static N_INLINE(void, decRef_MV4BBk6J1qu70IbBxwEn4wsystem)(Cell_1zcF9cV8XIAtbN8h5HRUB8g* c) {
	{
		(*c).refcount -= ((NI) 8);
		if (!((NU32)((*c).refcount) < (NU32)(((NI) 8)))) goto LA3_;
		nimrtl_rtlAddZCT(c);
	}
	LA3_: ;
}

static N_INLINE(void, asgnRef)(void** dest, void* src) {
	{
		Cell_1zcF9cV8XIAtbN8h5HRUB8g* T5_;
		if (!!((src == NIM_NIL))) goto LA3_;
		T5_ = (Cell_1zcF9cV8XIAtbN8h5HRUB8g*)0;
		T5_ = usrToCell_yB9aH5WIlwd0xkYrcdPeXrQsystem(src);
		incRef_9cAA5YuQAAC3MVbnGeV86swsystem(T5_);
	}
	LA3_: ;
	{
		Cell_1zcF9cV8XIAtbN8h5HRUB8g* T10_;
		if (!!(((*dest) == NIM_NIL))) goto LA8_;
		T10_ = (Cell_1zcF9cV8XIAtbN8h5HRUB8g*)0;
		T10_ = usrToCell_yB9aH5WIlwd0xkYrcdPeXrQsystem((*dest));
		decRef_MV4BBk6J1qu70IbBxwEn4wsystem(T10_);
	}
	LA8_: ;
	(*dest) = src;
}

N_LIB_EXPORT N_CDECL(RopeObj_pk4sC5H3E9ceov4bEasyPVw*, nroFormat)(NimStringDesc* frmt, RopeObj_pk4sC5H3E9ceov4bEasyPVw** args, NI argsLen_0) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* result;
	NI i;
	NI length;
	NI num;
	result = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	i = ((NI) 0);
	length = (frmt ? frmt->Sup.len : 0);
	result = NIM_NIL;
	num = ((NI) 0);
	{
		while (1) {
			NI start;
			if (!(i < length)) goto LA2;
			{
				if (!((NU8)(frmt->data[i]) == (NU8)(36))) goto LA5_;
				i += ((NI) 1);
				switch (((NU8)(frmt->data[i]))) {
				case 36:
				{
					nroaddStr(&result, ((NimStringDesc*) &TM_7lAtbav61D2a8Y3CNxNADw_5));
					i += ((NI) 1);
				}
				break;
				case 35:
				{
					i += ((NI) 1);
					nroaddRope(&result, args[num]);
					num += ((NI) 1);
				}
				break;
				case 48 ... 57:
				{
					NI j;
					j = ((NI) 0);
					{
						while (1) {
							j = (NI)((NI)((NI)(j * ((NI) 10)) + ((NI) (((NU8)(frmt->data[i]))))) - ((NI) 48));
							i += ((NI) 1);
							{
								if (!!((((NU8)(frmt->data[i])) >= ((NU8)(48)) && ((NU8)(frmt->data[i])) <= ((NU8)(57))))) goto LA14_;
								goto LA10;
							}
							LA14_: ;
						}
					} LA10: ;
					nroaddRope(&result, args[(NI)(j - ((NI) 1))]);
				}
				break;
				case 123:
				{
					NI j_2;
					i += ((NI) 1);
					j_2 = ((NI) 0);
					{
						while (1) {
							if (!(((NU8)(frmt->data[i])) >= ((NU8)(48)) && ((NU8)(frmt->data[i])) <= ((NU8)(57)))) goto LA18;
							j_2 = (NI)((NI)((NI)(j_2 * ((NI) 10)) + ((NI) (((NU8)(frmt->data[i]))))) - ((NI) 48));
							i += ((NI) 1);
						} LA18: ;
					}
					{
						if (!((NU8)(frmt->data[i]) == (NU8)(125))) goto LA21_;
						i += ((NI) 1);
					}
					goto LA19_;
					LA21_: ;
					{
						ValueError_Gi06FkNeykJn7mrqRZYrkA* e;
						NimStringDesc* T24_;
						e = (ValueError_Gi06FkNeykJn7mrqRZYrkA*)0;
						e = (ValueError_Gi06FkNeykJn7mrqRZYrkA*) nimrtl_newObj((&NTI_yCEN9anxCD6mzBxGjuaRBdg_), sizeof(ValueError_Gi06FkNeykJn7mrqRZYrkA));
						(*e).Sup.Sup.m_type = (&NTI_Gi06FkNeykJn7mrqRZYrkA_);
						T24_ = (NimStringDesc*)0;
						T24_ = (*e).Sup.message; (*e).Sup.message = nimrtl_copyStringRC1(((NimStringDesc*) &TM_7lAtbav61D2a8Y3CNxNADw_6));
						if (T24_) nimGCunrefNoCycle(T24_);
						asgnRef((void**) (&(*e).Sup.parent), NIM_NIL);
						nimrtl_raiseException((Exception*)e, "ValueError");
					}
					LA19_: ;
					nroaddRope(&result, args[(NI)(j_2 - ((NI) 1))]);
				}
				break;
				default:
				{
					ValueError_Gi06FkNeykJn7mrqRZYrkA* e_2;
					NimStringDesc* T26_;
					e_2 = (ValueError_Gi06FkNeykJn7mrqRZYrkA*)0;
					e_2 = (ValueError_Gi06FkNeykJn7mrqRZYrkA*) nimrtl_newObj((&NTI_yCEN9anxCD6mzBxGjuaRBdg_), sizeof(ValueError_Gi06FkNeykJn7mrqRZYrkA));
					(*e_2).Sup.Sup.m_type = (&NTI_Gi06FkNeykJn7mrqRZYrkA_);
					T26_ = (NimStringDesc*)0;
					T26_ = (*e_2).Sup.message; (*e_2).Sup.message = nimrtl_copyStringRC1(((NimStringDesc*) &TM_7lAtbav61D2a8Y3CNxNADw_6));
					if (T26_) nimGCunrefNoCycle(T26_);
					asgnRef((void**) (&(*e_2).Sup.parent), NIM_NIL);
					nimrtl_raiseException((Exception*)e_2, "ValueError");
				}
				break;
				}
			}
			LA5_: ;
			start = i;
			{
				while (1) {
					if (!(i < length)) goto LA28;
					{
						if (!!(((NU8)(frmt->data[i]) == (NU8)(36)))) goto LA31_;
						i += ((NI) 1);
					}
					goto LA29_;
					LA31_: ;
					{
						goto LA27;
					}
					LA29_: ;
				} LA28: ;
			} LA27: ;
			{
				NimStringDesc* T38_;
				if (!(start <= (NI)(i - ((NI) 1)))) goto LA36_;
				T38_ = (NimStringDesc*)0;
				T38_ = copyStrLast(frmt, start, (NI)(i - ((NI) 1)));
				nroaddStr(&result, T38_);
			}
			LA36_: ;
		} LA2: ;
	}
	return result;
}

N_LIB_EXPORT N_CDECL(void, nroaddf)(RopeObj_pk4sC5H3E9ceov4bEasyPVw** c, NimStringDesc* frmt, RopeObj_pk4sC5H3E9ceov4bEasyPVw** args, NI argsLen_0) {
	RopeObj_pk4sC5H3E9ceov4bEasyPVw* T1_;
	T1_ = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*)0;
	T1_ = nroFormat(frmt, args, argsLen_0);
	nroaddRope(c, T1_);
}

static N_INLINE(NIM_BOOL, equalMem_DCrUjdaMvFDHaR1hs7sQGwstrutils)(void* a, void* b, NI size) {
	NIM_BOOL result;
	int T1_;
	result = (NIM_BOOL)0;
	T1_ = (int)0;
	T1_ = memcmp(a, b, ((size_t) (size)));
	result = (T1_ == ((NI32) 0));
	return result;
}

N_LIB_EXPORT N_CDECL(NIM_BOOL, nroequalsFileFile)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r, FILE* f) {
	NIM_BOOL result;
	TY_9bKy7UA2LOi2vzOViufaW1Q buf;
	NI bpos;
	NI blen;
	NI T26_;
{	result = (NIM_BOOL)0;
	memset((void*)buf, 0, sizeof(buf));
	bpos = ((NI) 1024);
	blen = ((NI) 1024);
	{
		NimStringDesc* s;
		s = (NimStringDesc*)0;
		{
			TY_xyYfiXqv9bXR7uHakYC9cy3A* stack;
			if (!!((r == NIM_NIL))) goto LA4_;
			stack = (TY_xyYfiXqv9bXR7uHakYC9cy3A*) nimrtl_newSeq((&NTI_xyYfiXqv9bXR7uHakYC9cy3A_), 1);
			asgnRefNoCycle((void**) (&stack->data[0]), r);
			{
				while (1) {
					RopeObj_pk4sC5H3E9ceov4bEasyPVw* it;
					NI spos;
					NI slen;
					if (!(((NI) 0) < (stack ? stack->Sup.len : 0))) goto LA7;
					it = pop_ty7pjOMAEzlk2hF5VjHEsAropes((&stack));
					{
						while (1) {
							NIM_BOOL T10_;
							T10_ = (NIM_BOOL)0;
							T10_ = isConc_XZ8qsVA5ELaAT0pRYWW5Ywropes(it);
							if (!T10_) goto LA9;
							stack = (TY_xyYfiXqv9bXR7uHakYC9cy3A*) incrSeqV2(&(stack)->Sup, sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw*));
							asgnRefNoCycle((void**) (&stack->data[stack->Sup.len]), (*it).right);
							++stack->Sup.len;
							it = (*it).left;
						} LA9: ;
					}
					s = (*it).data;
					spos = ((NI) 0);
					slen = (s ? s->Sup.len : 0);
					{
						while (1) {
							NI n;
							if (!(spos < slen)) goto LA12;
							{
								if (!(bpos == blen)) goto LA15_;
								bpos = ((NI) 0);
								blen = readBuffer_nZ0pNe9cd9cXtoayexCiaDtA(f, ((void*) ((&buf[(((NI) 0))- 0]))), ((NI) 1024));
								{
									if (!(blen == ((NI) 0))) goto LA19_;
									result = NIM_FALSE;
									goto BeforeRet_;
								}
								LA19_: ;
							}
							LA15_: ;
							n = (((NI)(blen - bpos) <= (NI)(slen - spos)) ? (NI)(blen - bpos) : (NI)(slen - spos));
							{
								NIM_BOOL T23_;
								T23_ = (NIM_BOOL)0;
								T23_ = equalMem_DCrUjdaMvFDHaR1hs7sQGwstrutils(((void*) ((&buf[(bpos)- 0]))), ((void*) ((NI)(((NI) (s->data)) + spos))), ((NI) (n)));
								if (!!(T23_)) goto LA24_;
								result = NIM_FALSE;
								goto BeforeRet_;
							}
							LA24_: ;
							spos += n;
							bpos += n;
						} LA12: ;
					}
				} LA7: ;
			}
		}
		LA4_: ;
	}
	T26_ = (NI)0;
	T26_ = readBuffer_nZ0pNe9cd9cXtoayexCiaDtA(f, ((void*) ((&buf[(((NI) 0))- 0]))), ((NI) 1));
	result = (T26_ == ((NI) 0));
	}BeforeRet_: ;
	return result;
}

N_LIB_EXPORT N_CDECL(NIM_BOOL, nroequalsFileStr)(RopeObj_pk4sC5H3E9ceov4bEasyPVw* r, NimStringDesc* filename) {
	NIM_BOOL result;
	FILE* f;
	result = (NIM_BOOL)0;
	f = (FILE*)0;
	result = open_sEp0GH2306oGo9bqBpj5oTQ(&f, filename, ((FileMode_fVUBHvW79bXUw1j55Oo9avSQ) 0), ((NI) -1));
	{
		if (!result) goto LA3_;
		result = nroequalsFileFile(r, f);
		close_BWnr8V7RERYno9bIdPmw8Hw_2(f);
	}
	LA3_: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_ropesInit000)(void) {
nimRegisterGlobalMarker(TM_7lAtbav61D2a8Y3CNxNADw_3);
nimRegisterGlobalMarker(TM_7lAtbav61D2a8Y3CNxNADw_4);
	cacheEnabled_Tx9b9cwni2VzCnsN5eGrePhg = NIM_FALSE;
	if (N_Exgp9asfFKZJfhz9bzz9bL89cg) nimGCunrefNoCycle(N_Exgp9asfFKZJfhz9bzz9bL89cg);
	N_Exgp9asfFKZJfhz9bzz9bL89cg = (RopeObj_pk4sC5H3E9ceov4bEasyPVw*) nimrtl_newObjRC1((&NTI_VYsfqmmqchsY5XzU9aJJBBA_), sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw));
}

NIM_EXTERNC N_NOINLINE(void, stdlib_ropesDatInit000)(void) {
static TNimNode* TM_7lAtbav61D2a8Y3CNxNADw_2[4];
static TNimNode TM_7lAtbav61D2a8Y3CNxNADw_0[5];
NTI_pk4sC5H3E9ceov4bEasyPVw_.size = sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw);
NTI_pk4sC5H3E9ceov4bEasyPVw_.kind = 18;
NTI_pk4sC5H3E9ceov4bEasyPVw_.base = 0;
NTI_pk4sC5H3E9ceov4bEasyPVw_.flags = 2;
TM_7lAtbav61D2a8Y3CNxNADw_2[0] = &TM_7lAtbav61D2a8Y3CNxNADw_0[1];
TM_7lAtbav61D2a8Y3CNxNADw_0[1].kind = 1;
TM_7lAtbav61D2a8Y3CNxNADw_0[1].offset = offsetof(RopeObj_pk4sC5H3E9ceov4bEasyPVw, left);
TM_7lAtbav61D2a8Y3CNxNADw_0[1].typ = (&NTI_VYsfqmmqchsY5XzU9aJJBBA_);
TM_7lAtbav61D2a8Y3CNxNADw_0[1].name = "left";
TM_7lAtbav61D2a8Y3CNxNADw_2[1] = &TM_7lAtbav61D2a8Y3CNxNADw_0[2];
TM_7lAtbav61D2a8Y3CNxNADw_0[2].kind = 1;
TM_7lAtbav61D2a8Y3CNxNADw_0[2].offset = offsetof(RopeObj_pk4sC5H3E9ceov4bEasyPVw, right);
TM_7lAtbav61D2a8Y3CNxNADw_0[2].typ = (&NTI_VYsfqmmqchsY5XzU9aJJBBA_);
TM_7lAtbav61D2a8Y3CNxNADw_0[2].name = "right";
TM_7lAtbav61D2a8Y3CNxNADw_2[2] = &TM_7lAtbav61D2a8Y3CNxNADw_0[3];
TM_7lAtbav61D2a8Y3CNxNADw_0[3].kind = 1;
TM_7lAtbav61D2a8Y3CNxNADw_0[3].offset = offsetof(RopeObj_pk4sC5H3E9ceov4bEasyPVw, length);
TM_7lAtbav61D2a8Y3CNxNADw_0[3].typ = (&NTI_rR5Bzr1D5krxoo1NcNyeMA_);
TM_7lAtbav61D2a8Y3CNxNADw_0[3].name = "length";
TM_7lAtbav61D2a8Y3CNxNADw_2[3] = &TM_7lAtbav61D2a8Y3CNxNADw_0[4];
TM_7lAtbav61D2a8Y3CNxNADw_0[4].kind = 1;
TM_7lAtbav61D2a8Y3CNxNADw_0[4].offset = offsetof(RopeObj_pk4sC5H3E9ceov4bEasyPVw, data);
TM_7lAtbav61D2a8Y3CNxNADw_0[4].typ = (&NTI_77mFvmsOLKik79ci2hXkHEg_);
TM_7lAtbav61D2a8Y3CNxNADw_0[4].name = "data";
TM_7lAtbav61D2a8Y3CNxNADw_0[0].len = 4; TM_7lAtbav61D2a8Y3CNxNADw_0[0].kind = 2; TM_7lAtbav61D2a8Y3CNxNADw_0[0].sons = &TM_7lAtbav61D2a8Y3CNxNADw_2[0];
NTI_pk4sC5H3E9ceov4bEasyPVw_.node = &TM_7lAtbav61D2a8Y3CNxNADw_0[0];
NTI_VYsfqmmqchsY5XzU9aJJBBA_.size = sizeof(RopeObj_pk4sC5H3E9ceov4bEasyPVw*);
NTI_VYsfqmmqchsY5XzU9aJJBBA_.kind = 22;
NTI_VYsfqmmqchsY5XzU9aJJBBA_.base = (&NTI_pk4sC5H3E9ceov4bEasyPVw_);
NTI_VYsfqmmqchsY5XzU9aJJBBA_.flags = 2;
NTI_VYsfqmmqchsY5XzU9aJJBBA_.marker = Marker_TY_VYsfqmmqchsY5XzU9aJJBBA;
}

