/* 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/docutils_rstast.o compiler/nimcache/docutils_rstast.c */
#define NIM_INTBITS 32
#include "nimbase.h"
typedef struct trstnode297009 trstnode297009;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct trstnodeseq297007 trstnodeseq297007;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell41090 tcell41090;
typedef struct tcellseq41106 tcellseq41106;
typedef struct tgcheap43016 tgcheap43016;
typedef struct tcellset41102 tcellset41102;
typedef struct tpagedesc41098 tpagedesc41098;
typedef struct tmemregion23410 tmemregion23410;
typedef struct tsmallchunk22638 tsmallchunk22638;
typedef struct tllchunk23404 tllchunk23404;
typedef struct tbigchunk22640 tbigchunk22640;
typedef struct tintset22615 tintset22615;
typedef struct ttrunk22611 ttrunk22611;
typedef struct tavlnode23408 tavlnode23408;
typedef struct tgcstat43014 tgcstat43014;
typedef struct tbasechunk22636 tbasechunk22636;
typedef struct tfreecell22628 tfreecell22628;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  trstnode297009  {
NU8 Kind;
NimStringDesc* Text;
NI Level;
trstnodeseq297007* Sons;
};
typedef N_NIMCALL_PTR(void, TY2289) (void* p, NI op);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY2289 marker;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct  tcell41090  {
NI Refcount;
TNimType* Typ;
};
struct  tcellseq41106  {
NI Len;
NI Cap;
tcell41090** D;
};
struct  tcellset41102  {
NI Counter;
NI Max;
tpagedesc41098* Head;
tpagedesc41098** Data;
};
typedef tsmallchunk22638* TY23422[512];
typedef ttrunk22611* ttrunkbuckets22613[256];
struct  tintset22615  {
ttrunkbuckets22613 Data;
};
struct  tmemregion23410  {
NI Minlargeobj;
NI Maxlargeobj;
TY23422 Freesmallchunks;
tllchunk23404* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk22640* Freechunkslist;
tintset22615 Chunkstarts;
tavlnode23408* Root;
tavlnode23408* Deleted;
tavlnode23408* Last;
tavlnode23408* Freeavlnodes;
};
struct  tgcstat43014  {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct  tgcheap43016  {
void* Stackbottom;
NI Cyclethreshold;
tcellseq41106 Zct;
tcellseq41106 Decstack;
tcellset41102 Cycleroots;
tcellseq41106 Tempstack;
NI Recgclock;
tmemregion23410 Region;
tgcstat43014 Stat;
};
typedef NI TY22618[16];
struct  tpagedesc41098  {
tpagedesc41098* Next;
NI Key;
TY22618 Bits;
};
struct  tbasechunk22636  {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct  tsmallchunk22638  {
  tbasechunk22636 Sup;
tsmallchunk22638* Next;
tsmallchunk22638* Prev;
tfreecell22628* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct  tllchunk23404  {
NI Size;
NI Acc;
tllchunk23404* Next;
};
struct  tbigchunk22640  {
  tbasechunk22636 Sup;
tbigchunk22640* Next;
tbigchunk22640* Prev;
NI Align;
NF Data;
};
struct  ttrunk22611  {
ttrunk22611* Next;
NI Key;
TY22618 Bits;
};
typedef tavlnode23408* TY23414[2];
struct  tavlnode23408  {
TY23414 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct  tfreecell22628  {
tfreecell22628* Next;
NI Zerofield;
};
struct trstnodeseq297007 {
  TGenericSeq Sup;
  trstnode297009* data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
N_NIMCALL(void, TMP2333)(void* p, NI op);
N_NIMCALL(void, TMP2334)(void* p, NI op);
N_NIMCALL(trstnode297009*, newrstnode_297097)(NU8 kind);
N_NIMCALL(void*, newObj)(TNimType* typ, NI size);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(tcell41090*, usrtocell_44443)(void* usr);
static N_INLINE(void, rtladdzct_46002)(tcell41090* c);
N_NOINLINE(void, addzct_44418)(tcellseq41106* s, tcell41090* c);
N_NIMCALL(void*, newSeqRC1)(TNimType* typ, NI len);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
N_NIMCALL(TGenericSeq*, incrSeq)(TGenericSeq* seq, NI elemsize);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
N_NIMCALL(void, add_297163)(trstnode297009* father, trstnode297009* son);
TNimType NTI297009; /* TRstNode */
TNimType NTI297003; /* TRstNodeKind */
extern TNimType NTI143; /* string */
extern TNimType NTI106; /* int */
TNimType NTI297007; /* TRstNodeSeq */
TNimType NTI297005; /* PRstNode */
extern tgcheap43016 gch_43044;

N_NIMCALL(NI, len_297080)(trstnode297009* n) {
	NI result;
	result = 0;
	result = (*n).Sons->Sup.len;
	return result;
}

N_NIMCALL(trstnode297009*, lastson_297146)(trstnode297009* n) {
	trstnode297009* result;
	result = 0;
	result = (*n).Sons->data[(NI32)((*n).Sons->Sup.len - 1)];
	return result;
}
N_NIMCALL(void, TMP2333)(void* p, NI op) {
	trstnodeseq297007* a;
	NI LOC1;
	a = (trstnodeseq297007*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	nimGCvisit((void*)a->data[LOC1], op);
	}
}
N_NIMCALL(void, TMP2334)(void* p, NI op) {
	trstnode297009* a;
	a = (trstnode297009*)p;
	nimGCvisit((void*)(*a).Text, op);
	nimGCvisit((void*)(*a).Sons, op);
}

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

static N_INLINE(void, rtladdzct_46002)(tcell41090* c) {
	addzct_44418(&gch_43044.Zct, c);
}

static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tcell41090* c;
	c = usrtocell_44443(p);
	{
		(*c).Refcount -= 8;
		if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA3;
		rtladdzct_46002(c);
	}
	LA3: ;
}

N_NIMCALL(trstnode297009*, newrstnode_297097)(NU8 kind) {
	trstnode297009* result;
	result = 0;
	result = (trstnode297009*) newObj((&NTI297005), sizeof(trstnode297009));
	if ((*result).Sons) nimGCunrefNoCycle((*result).Sons);
	(*result).Sons = (trstnodeseq297007*) newSeqRC1((&NTI297007), 0);
	(*result).Kind = kind;
	return result;
}

N_NIMCALL(trstnode297009*, newrstnode_297139)(NU8 kind, NimStringDesc* s) {
	trstnode297009* result;
	NimStringDesc* LOC1;
	result = 0;
	result = newrstnode_297097(kind);
	LOC1 = 0;
	LOC1 = (*result).Text; (*result).Text = copyStringRC1(s);
	if (LOC1) nimGCunrefNoCycle(LOC1);
	return result;
}

static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
	{
		tcell41090* c;
		if (!!((src == NIM_NIL))) goto LA3;
		c = usrtocell_44443(src);
		(*c).Refcount += 8;
	}
	LA3: ;
	{
		tcell41090* c;
		if (!!(((*dest) == NIM_NIL))) goto LA7;
		c = usrtocell_44443((*dest));
		{
			(*c).Refcount -= 8;
			if (!((NU32)((*c).Refcount) < (NU32)(8))) goto LA11;
			rtladdzct_46002(c);
		}
		LA11: ;
	}
	LA7: ;
	(*dest) = src;
}

N_NIMCALL(void, add_297163)(trstnode297009* father, trstnode297009* son) {
	(*father).Sons = (trstnodeseq297007*) incrSeq(&((*father).Sons)->Sup, sizeof(trstnode297009*));
	asgnRefNoCycle((void**) &(*father).Sons->data[(*father).Sons->Sup.len-1], son);
}

N_NIMCALL(void, addifnotnil_297187)(trstnode297009* father, trstnode297009* son) {
	{
		if (!!((son == NIM_NIL))) goto LA3;
		add_297163(father, son);
	}
	LA3: ;
}
N_NOINLINE(void, docutilsrstastInit)(void) {
}

N_NOINLINE(void, docutilsrstastDatInit)(void) {
static TNimNode* TMP2329[4];
static TNimNode* TMP2330[65];
NI TMP2332;
static char* NIM_CONST TMP2331[65] = {
"rnInner", 
"rnHeadline", 
"rnOverline", 
"rnTransition", 
"rnParagraph", 
"rnBulletList", 
"rnBulletItem", 
"rnEnumList", 
"rnEnumItem", 
"rnDefList", 
"rnDefItem", 
"rnDefName", 
"rnDefBody", 
"rnFieldList", 
"rnField", 
"rnFieldName", 
"rnFieldBody", 
"rnOptionList", 
"rnOptionListItem", 
"rnOptionGroup", 
"rnOption", 
"rnOptionString", 
"rnOptionArgument", 
"rnDescription", 
"rnLiteralBlock", 
"rnQuotedLiteralBlock", 
"rnLineBlock", 
"rnLineBlockItem", 
"rnBlockQuote", 
"rnTable", 
"rnGridTable", 
"rnTableRow", 
"rnTableHeaderCell", 
"rnTableDataCell", 
"rnLabel", 
"rnFootnote", 
"rnCitation", 
"rnStandaloneHyperlink", 
"rnHyperlink", 
"rnRef", 
"rnDirective", 
"rnDirArg", 
"rnRaw", 
"rnTitle", 
"rnContents", 
"rnImage", 
"rnFigure", 
"rnCodeBlock", 
"rnRawHtml", 
"rnRawLatex", 
"rnContainer", 
"rnIndex", 
"rnSubstitutionDef", 
"rnGeneralRole", 
"rnSub", 
"rnSup", 
"rnIdx", 
"rnEmphasis", 
"rnStrongEmphasis", 
"rnTripleEmphasis", 
"rnInterpretedText", 
"rnInlineLiteral", 
"rnSubstitutionReferences", 
"rnSmiley", 
"rnLeaf"};
static TNimNode TMP862[71];
NTI297009.size = sizeof(trstnode297009);
NTI297009.kind = 18;
NTI297009.base = 0;
NTI297009.flags = 2;
TMP2329[0] = &TMP862[1];
NTI297003.size = sizeof(NU8);
NTI297003.kind = 14;
NTI297003.base = 0;
NTI297003.flags = 3;
for (TMP2332 = 0; TMP2332 < 65; TMP2332++) {
TMP862[TMP2332+2].kind = 1;
TMP862[TMP2332+2].offset = TMP2332;
TMP862[TMP2332+2].name = TMP2331[TMP2332];
TMP2330[TMP2332] = &TMP862[TMP2332+2];
}
TMP862[67].len = 65; TMP862[67].kind = 2; TMP862[67].sons = &TMP2330[0];
NTI297003.node = &TMP862[67];
TMP862[1].kind = 1;
TMP862[1].offset = offsetof(trstnode297009, Kind);
TMP862[1].typ = (&NTI297003);
TMP862[1].name = "kind";
TMP2329[1] = &TMP862[68];
TMP862[68].kind = 1;
TMP862[68].offset = offsetof(trstnode297009, Text);
TMP862[68].typ = (&NTI143);
TMP862[68].name = "text";
TMP2329[2] = &TMP862[69];
TMP862[69].kind = 1;
TMP862[69].offset = offsetof(trstnode297009, Level);
TMP862[69].typ = (&NTI106);
TMP862[69].name = "level";
TMP2329[3] = &TMP862[70];
NTI297007.size = sizeof(trstnodeseq297007*);
NTI297007.kind = 24;
NTI297007.base = (&NTI297005);
NTI297007.flags = 2;
NTI297007.marker = TMP2333;
TMP862[70].kind = 1;
TMP862[70].offset = offsetof(trstnode297009, Sons);
TMP862[70].typ = (&NTI297007);
TMP862[70].name = "sons";
TMP862[0].len = 4; TMP862[0].kind = 2; TMP862[0].sons = &TMP2329[0];
NTI297009.node = &TMP862[0];
NTI297005.size = sizeof(trstnode297009*);
NTI297005.kind = 22;
NTI297005.base = (&NTI297009);
NTI297005.flags = 2;
NTI297005.marker = TMP2334;
}

