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

#include "nimbase.h"
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3894) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3889 marker;
TY3894 deepcopy;
};
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
static N_INLINE(NI, HEX21HEX26_143013)(NI h, NI val);
static N_INLINE(NI, HEX21HEX24_143042)(NI h);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_142029)(NCSTRING cs, NI i);
TNimType NTI143005; /* Hash */

static N_INLINE(NI, HEX21HEX26_143013)(NI h, NI val) {
	NI result;
	result = 0;
	result = (NI)((NU32)(h) + (NU32)(val));
	result = (NI)((NU32)(result) + (NU32)((NI)((NU32)(result) << (NU32)(((NI) 10)))));
	result = (NI)(result ^ (NI)((NU32)(result) >> (NU32)(((NI) 6))));
	return result;
}

static N_INLINE(NI, HEX21HEX24_143042)(NI h) {
	NI result;
	result = 0;
	result = (NI)((NU32)(h) + (NU32)((NI)((NU32)(h) << (NU32)(((NI) 3)))));
	result = (NI)(result ^ (NI)((NU32)(result) >> (NU32)(((NI) 11))));
	result = (NI)((NU32)(result) + (NU32)((NI)((NU32)(result) << (NU32)(((NI) 15)))));
	return result;
}

N_NIMCALL(NI, hash_143848)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_143863;
		NI HEX3Atmp_143874;
		NI res_143877;
		i_143863 = 0;
		HEX3Atmp_143874 = 0;
		HEX3Atmp_143874 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_143877 = ((NI) 0);
		{
			while (1) {
				if (!(res_143877 <= HEX3Atmp_143874)) goto LA3;
				i_143863 = res_143877;
				h = HEX21HEX26_143013(h, ((NI) (((NU8)(x->data[i_143863])))));
				res_143877 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_143042(h);
	return result;
}

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_142029)(NCSTRING cs, NI i) {
	NIM_BOOL result;
	NIM_BOOL LOC1;
	NIM_BOOL LOC2;
	result = 0;
	LOC1 = 0;
	LOC2 = 0;
	LOC2 = ((NU8)(cs[i]) == (NU8)(226));
	if (!(LOC2)) goto LA3;
	LOC2 = ((NU8)(cs[(NI)(i + ((NI) 1))]) == (NU8)(128));
	LA3: ;
	LOC1 = LOC2;
	if (!(LOC1)) goto LA4;
	LOC1 = ((NU8)(cs[(NI)(i + ((NI) 2))]) == (NU8)(147));
	LA4: ;
	result = LOC1;
	return result;
}

N_NIMCALL(NI, hashignorestyle_143945)(NimStringDesc* x) {
	NI result;
	NI h;
	NI i;
	NI xlen;
	result = 0;
	h = ((NI) 0);
	i = ((NI) 0);
	xlen = (x ? x->Sup.len : 0);
	{
		while (1) {
			NIM_CHAR c;
			if (!(i < xlen)) goto LA2;
			c = x->data[i];
			{
				if (!((NU8)(c) == (NU8)(95))) goto LA5;
				i += ((NI) 1);
			}
			goto LA3;
			LA5: ;
			{
				NIM_BOOL LOC8;
				LOC8 = 0;
				LOC8 = ismagicidentseparatorrune_142029(x->data, i);
				if (!LOC8) goto LA9;
				i += ((NI) 3);
			}
			goto LA3;
			LA9: ;
			{
				{
					if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA14;
					c = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c)))) + ((NI) 32))))));
				}
				LA14: ;
				h = HEX21HEX26_143013(h, ((NI) (((NU8)(c)))));
				i += ((NI) 1);
			}
			LA3: ;
		} LA2: ;
	}
	result = HEX21HEX24_143042(h);
	return result;
}

N_NIMCALL(NI, hashignorecase_144136)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_144151;
		NI HEX3Atmp_144201;
		NI res_144204;
		i_144151 = 0;
		HEX3Atmp_144201 = 0;
		HEX3Atmp_144201 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_144204 = ((NI) 0);
		{
			while (1) {
				NIM_CHAR c;
				if (!(res_144204 <= HEX3Atmp_144201)) goto LA3;
				i_144151 = res_144204;
				c = x->data[i_144151];
				{
					if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA6;
					c = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c)))) + ((NI) 32))))));
				}
				LA6: ;
				h = HEX21HEX26_143013(h, ((NI) (((NU8)(c)))));
				res_144204 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_143042(h);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_hashesInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, stdlib_hashesDatInit000)(void) {
NTI143005.size = sizeof(NI);
NTI143005.kind = 31;
NTI143005.base = 0;
NTI143005.flags = 3;
}

