/* Generated by Nim Compiler v0.12.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, 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_145013)(NI h, NI val);
static N_INLINE(NI, HEX21HEX24_145042)(NI h);
static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_144029)(NCSTRING cs, NI i);
TNimType NTI145005; /* Hash */

static N_INLINE(NI, HEX21HEX26_145013)(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_145042)(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_145848)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_145863;
		NI HEX3Atmp_145874;
		NI res_145877;
		i_145863 = 0;
		HEX3Atmp_145874 = 0;
		HEX3Atmp_145874 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_145877 = ((NI) 0);
		{
			while (1) {
				if (!(res_145877 <= HEX3Atmp_145874)) goto LA3;
				i_145863 = res_145877;
				h = HEX21HEX26_145013(h, ((NI) (((NU8)(x->data[i_145863])))));
				res_145877 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_145042(h);
	return result;
}

static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_144029)(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_145945)(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_144029(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_145013(h, ((NI) (((NU8)(c)))));
				i += ((NI) 1);
			}
			LA3: ;
		} LA2: ;
	}
	result = HEX21HEX24_145042(h);
	return result;
}

N_NIMCALL(NI, hashignorecase_146136)(NimStringDesc* x) {
	NI result;
	NI h;
	result = 0;
	h = ((NI) 0);
	{
		NI i_146151;
		NI HEX3Atmp_146201;
		NI res_146204;
		i_146151 = 0;
		HEX3Atmp_146201 = 0;
		HEX3Atmp_146201 = (NI)((x ? x->Sup.len : 0) - ((NI) 1));
		res_146204 = ((NI) 0);
		{
			while (1) {
				NIM_CHAR c;
				if (!(res_146204 <= HEX3Atmp_146201)) goto LA3;
				i_146151 = res_146204;
				c = x->data[i_146151];
				{
					if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA6;
					c = ((NIM_CHAR) (((NI) ((NI)(((NI) (((NU8)(c)))) + ((NI) 32))))));
				}
				LA6: ;
				h = HEX21HEX26_145013(h, ((NI) (((NU8)(c)))));
				res_146204 += ((NI) 1);
			} LA3: ;
		}
	}
	result = HEX21HEX24_145042(h);
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_hashesInit000)(void) {
}

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

