/* 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_141013)(NI h, NI val);
static N_INLINE(NI, HEX21HEX24_141042)(NI h);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_140029)(NCSTRING cs, NI i);
TNimType NTI141005; /* Hash */

static N_INLINE(NI, HEX21HEX26_141013)(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_141042)(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_141848)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_141863;
		NI HEX3Atmp_141874;
		NI res_141877;
		i_141863 = 0;
		HEX3Atmp_141874 = 0;
		HEX3Atmp_141874 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_141877 = ((NI) 0);
		{
			while (1) {
				if (!(res_141877 <= HEX3Atmp_141874)) goto LA3;
				i_141863 = res_141877;
				h = HEX21HEX26_141013(h, ((NI) (((NU8)(x->data[i_141863])))));
				res_141877 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_141042(h);
	return result;
}

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_140029)(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_141945)(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_140029(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_141013(h, ((NI) (((NU8)(c)))));
				i += ((NI) 1);
			}
			LA3: ;
		} LA2: ;
	}
	result = HEX21HEX24_141042(h);
	return result;
}

N_NIMCALL(NI, hashignorecase_142136)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_142151;
		NI HEX3Atmp_142201;
		NI res_142204;
		i_142151 = 0;
		HEX3Atmp_142201 = 0;
		HEX3Atmp_142201 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_142204 = ((NI) 0);
		{
			while (1) {
				NIM_CHAR c;
				if (!(res_142204 <= HEX3Atmp_142201)) goto LA3;
				i_142151 = res_142204;
				c = x->data[i_142151];
				{
					if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA6;
					c = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c)))) + ((NI) 32))))));
				}
				LA6: ;
				h = HEX21HEX26_141013(h, ((NI) (((NU8)(c)))));
				res_142204 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_141042(h);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_hashesInit000)(void) {
}

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

