/* Generated by Nim Compiler v1.4.2 */
/*   (c) 2020 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32

/* section: NIM_merge_HEADERS */

#include "nimbase.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

/* section: NIM_merge_FRAME_DEFINES */
#define nimfr_(x, y)
#define nimln_(x, y)

/* section: NIM_merge_FORWARD_TYPES */
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;

/* section: NIM_merge_TYPES */
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};

/* section: NIM_merge_PROC_HEADERS */
N_LIB_PRIVATE N_NIMCALL(void, setLen__RERja5IIeMonpTtt9bmLiFg)(NimStringDesc** result, NI n, NIM_BOOL isInit);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newLen);
N_LIB_PRIVATE N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
static N_INLINE(void, zeroMem__9cLyRtoQz0YlIMEd4qW7Hdgsystem)(void* p, NI size);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__JE6t4x7Z3v2iVz27Nx0MRAmemory)(void* a, int v, NI size);
static N_INLINE(void, copyMem__M04YC71iJg1N7gBF3HZTngsystem)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
N_LIB_PRIVATE N_NIMCALL(void*, dataPointer__AnU4WGNDB4UiqbYYlJW8wA)(NimStringDesc* a);

/* section: NIM_merge_PROCS */
static N_INLINE(void, nimSetMem__JE6t4x7Z3v2iVz27Nx0MRAmemory)(void* a, int v, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
	nimSetMem__JE6t4x7Z3v2iVz27Nx0MRAmemory(p, ((int) 0), size);
}
static N_INLINE(void, zeroMem__9cLyRtoQz0YlIMEd4qW7Hdgsystem)(void* p, NI size) {
	nimZeroMem(p, size);
}
N_LIB_PRIVATE N_NIMCALL(void, setLen__RERja5IIeMonpTtt9bmLiFg)(NimStringDesc** result, NI n, NIM_BOOL isInit) {
	NI n0;
	n0 = ((*result) ? (*result)->Sup.len : 0);
	unsureAsgnRef((void**) (&(*result)), setLengthStr((*result), ((NI) (n))));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = isInit;
		if (!(T3_)) goto LA4_;
		T3_ = (n0 < n);
		LA4_: ;
		if (!T3_) goto LA5_;
		zeroMem__9cLyRtoQz0YlIMEd4qW7Hdgsystem(((void*) ((&(*result)->data[n0]))), ((NI) ((NI)(n - n0))));
	}
	LA5_: ;
}
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest, source, ((size_t) (size)));
}
static N_INLINE(void, copyMem__M04YC71iJg1N7gBF3HZTngsystem)(void* dest, void* source, NI size) {
	nimCopyMem(dest, source, size);
}
N_LIB_PRIVATE N_NIMCALL(void*, dataPointer__AnU4WGNDB4UiqbYYlJW8wA)(NimStringDesc* a) {
	void* result;
	result = (void*)0;
	{
		if (!((a ? a->Sup.len : 0) == ((NI) 0))) goto LA3_;
		result = NIM_NIL;
	}
	goto LA1_;
	LA3_: ;
	{
		result = ((void*) ((&a->data[((NI) 0)])));
	}
	LA1_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, forceCopy__9aS5wD8MwJoemnVo59bh54Sg)(NimStringDesc** result, NimStringDesc* a) {
	NI n;
	void* T1_;
	void* T2_;
	n = (a ? a->Sup.len : 0);
	setLen__RERja5IIeMonpTtt9bmLiFg(result, n, NIM_FALSE);
	T1_ = (void*)0;
	T1_ = dataPointer__AnU4WGNDB4UiqbYYlJW8wA((*result));
	T2_ = (void*)0;
	T2_ = dataPointer__AnU4WGNDB4UiqbYYlJW8wA(a);
	copyMem__M04YC71iJg1N7gBF3HZTngsystem(T1_, T2_, ((NI) (n)));
}
