/* Generated by Nimrod Compiler v0.9.5 */
/*   (c) 2014 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  -I/build/nimrod/src/nimrod/lib -o compiler/nimcache/stdlib_xmltree.o compiler/nimcache/stdlib_xmltree.c */
#define NIM_INTBITS 32
#include "nimbase.h"

#include <string.h>
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_NIMCALL(void, addescaped_332654)(NimStringDesc** result, NimStringDesc* s);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
STRING_LITERAL(TMP4357, "&lt;", 4);
STRING_LITERAL(TMP4358, "&gt;", 4);
STRING_LITERAL(TMP4359, "&amp;", 5);
STRING_LITERAL(TMP4360, "&quot;", 6);

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

N_NIMCALL(void, addescaped_332654)(NimStringDesc** result, NimStringDesc* s) {
	NIM_CHAR c_332659;
	NI i_332661;
	NI l_332663;
	c_332659 = 0;
	i_332661 = 0;
	l_332663 = s->Sup.len;
	while (1) {
		if (!(i_332661 < l_332663)) goto LA1;
		c_332659 = s->data[i_332661];
		switch (((NU8)(c_332659))) {
		case 60:
		{
			(*result) = resizeString((*result), 4);
appendString((*result), ((NimStringDesc*) &TMP4357));
		}
		break;
		case 62:
		{
			(*result) = resizeString((*result), 4);
appendString((*result), ((NimStringDesc*) &TMP4358));
		}
		break;
		case 38:
		{
			(*result) = resizeString((*result), 5);
appendString((*result), ((NimStringDesc*) &TMP4359));
		}
		break;
		case 34:
		{
			(*result) = resizeString((*result), 6);
appendString((*result), ((NimStringDesc*) &TMP4360));
		}
		break;
		default:
		{
			(*result) = addChar((*result), c_332659);
		}
		break;
		}
		i_332661 += 1;
	} LA1: ;
}

N_NIMCALL(NimStringDesc*, escape_332667)(NimStringDesc* s) {
	NimStringDesc* result;
	result = 0;
	result = rawNewString(s->Sup.len);
	addescaped_332654(&result, s);
	return result;
}
N_NOINLINE(void, stdlibxmltreeInit)(void) {
}

N_NOINLINE(void, stdlibxmltreeDatInit)(void) {
}

