/* Generated by Nim Compiler v0.11.2 */
/*   (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, TY3289) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3294) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3289 marker;
TY3294 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_131025)(NI h, NI val);
static N_INLINE(NI, HEX21HEX24_131054)(NI h);
TNimType NTI131021; /* THash */

static N_INLINE(NI, HEX21HEX26_131025)(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_131054)(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_131839)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_131854;
		NI HEX3Atmp_131865;
		NI res_131868;
		i_131854 = 0;
		HEX3Atmp_131865 = 0;
		HEX3Atmp_131865 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_131868 = ((NI) 0);
		{
			while (1) {
				if (!(res_131868 <= HEX3Atmp_131865)) goto LA3;
				i_131854 = res_131868;
				h = HEX21HEX26_131025(h, ((NI) (((NU8)(x->data[i_131854])))));
				res_131868 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_131054(h);
	return result;
}

N_NIMCALL(NI, hashignorestyle_131887)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_131902;
		NI HEX3Atmp_131953;
		NI res_131956;
		i_131902 = 0;
		HEX3Atmp_131953 = 0;
		HEX3Atmp_131953 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_131956 = ((NI) 0);
		{
			while (1) {
				if (!(res_131956 <= HEX3Atmp_131953)) goto LA3;
				i_131902 = res_131956;
				{
					NIM_CHAR c;
					c = x->data[i_131902];
					{
						if (!((NU8)(c) == (NU8)(95))) goto LA7;
						goto LA4;
					}
					LA7: ;
					{
						if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA11;
						c = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c)))) + ((NI) 32))))));
					}
					LA11: ;
					h = HEX21HEX26_131025(h, ((NI) (((NU8)(c)))));
				} LA4: ;
				res_131956 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_131054(h);
	return result;
}

N_NIMCALL(NI, hashignorecase_131978)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_131993;
		NI HEX3Atmp_132043;
		NI res_132046;
		i_131993 = 0;
		HEX3Atmp_132043 = 0;
		HEX3Atmp_132043 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_132046 = ((NI) 0);
		{
			while (1) {
				NIM_CHAR c;
				if (!(res_132046 <= HEX3Atmp_132043)) goto LA3;
				i_131993 = res_132046;
				c = x->data[i_131993];
				{
					if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA6;
					c = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c)))) + ((NI) 32))))));
				}
				LA6: ;
				h = HEX21HEX26_131025(h, ((NI) (((NU8)(c)))));
				res_132046 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_131054(h);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_hashesInit)(void) {
}

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

