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

/* 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__FsvhfMqbswETmyMWtamDewsystem)(void* p, NI size);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_INLINE(void, copyMem__i80o3k0SgEI5gTRCzYdyWAsystem)(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__zxfKBYntu9cBapkhrCOk1fgmemory)(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__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(void, zeroMem__FsvhfMqbswETmyMWtamDewsystem)(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_;
		void* T7_;
		T3_ = (NIM_BOOL)0;
		T3_ = isInit;
		if (!(T3_)) goto LA4_;
		T3_ = (n0 < n);
		LA4_: ;
		if (!T3_) goto LA5_;
		T7_ = (void*)0;
		T7_ = ((void*) ((&(*result)->data[n0])));
		zeroMem__FsvhfMqbswETmyMWtamDewsystem(T7_, ((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__i80o3k0SgEI5gTRCzYdyWAsystem)(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_;
	void* T3_;
	n = (a ? a->Sup.len : 0);
	setLen__RERja5IIeMonpTtt9bmLiFg(result, n, NIM_FALSE);
	T1_ = (void*)0;
	T1_ = dataPointer__AnU4WGNDB4UiqbYYlJW8wA((*result));
	T2_ = (void*)0;
	T2_ = T1_;
	T3_ = (void*)0;
	T3_ = dataPointer__AnU4WGNDB4UiqbYYlJW8wA(a);
	copyMem__i80o3k0SgEI5gTRCzYdyWAsystem(T2_, T3_, ((NI) (n)));
}
