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

#include "nimbase.h"
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef N_NIMCALL_PTR(void, TY3489) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 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_137004)(NI h, NI val);
static N_INLINE(NI, HEX21HEX24_137027)(NI h);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_136008)(NCSTRING cs, NI i);
TNimType NTI137002; /* Hash */

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

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

N_NIMCALL(NI, hash_137827)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_137841;
		NI HEX3Atmp_137852;
		NI res_137855;
		i_137841 = 0;
		HEX3Atmp_137852 = 0;
		HEX3Atmp_137852 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_137855 = ((NI) 0);
		{
			while (1) {
				if (!(res_137855 <= HEX3Atmp_137852)) goto LA3;
				i_137841 = res_137855;
				h = HEX21HEX26_137004(h, ((NI) (((NU8)(x->data[i_137841])))));
				res_137855 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_137027(h);
	return result;
}

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_136008)(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_137892)(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_136008(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_137004(h, ((NI) (((NU8)(c)))));
				i += ((NI) 1);
			}
			LA3: ;
		} LA2: ;
	}
	result = HEX21HEX24_137027(h);
	return result;
}

N_NIMCALL(NI, hashignorecase_138059)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_138073;
		NI HEX3Atmp_138123;
		NI res_138126;
		i_138073 = 0;
		HEX3Atmp_138123 = 0;
		HEX3Atmp_138123 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_138126 = ((NI) 0);
		{
			while (1) {
				NIM_CHAR c;
				if (!(res_138126 <= HEX3Atmp_138123)) goto LA3;
				i_138073 = res_138126;
				c = x->data[i_138073];
				{
					if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA6;
					c = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c)))) + ((NI) 32))))));
				}
				LA6: ;
				h = HEX21HEX26_137004(h, ((NI) (((NU8)(c)))));
				res_138126 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_137027(h);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_hashesInit000)(void) {
}

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

