/* Generated by Nimrod Compiler v0.9.5 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, i386, gcc */
/* Command for C compiler:
   gcc -c  -w -O3 -fno-strict-aliasing  -I/build/nimrod/src/nimrod/lib -o compiler/nimcache/stdlib_hashes.o compiler/nimcache/stdlib_hashes.c */
#define NIM_INTBITS 32
#include "nimbase.h"
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_NIMCALL_PTR(void, TY2289) (void* p, NI op);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY2289 marker;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
static N_INLINE(NI, HEX21HEX26_119015)(NI h, NI val);
static N_INLINE(NI, HEX21HEX24_119040)(NI h);
TNimType NTI119013; /* THash */

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

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

N_NIMCALL(NI, hash_119827)(NimStringDesc* x) {
	NI result;
	NI h;
	NI i_119842;
	NI HEX3Atmp_119852;
	NI res_119854;
	result = 0;
	h = 0;
	i_119842 = 0;
	HEX3Atmp_119852 = 0;
	HEX3Atmp_119852 = (NI32)(x->Sup.len - 1);
	res_119854 = 0;
	while (1) {
		if (!(res_119854 <= HEX3Atmp_119852)) goto LA1;
		i_119842 = res_119854;
		h = HEX21HEX26_119015(h, ((NI) (((NU8)(x->data[i_119842])))));
		res_119854 += 1;
	} LA1: ;
	result = HEX21HEX24_119040(h);
	return result;
}

N_NIMCALL(NI, hashignorestyle_119859)(NimStringDesc* x) {
	NI result;
	NI h;
	NI i_119874;
	NI HEX3Atmp_119927;
	NI res_119929;
	result = 0;
	h = 0;
	i_119874 = 0;
	HEX3Atmp_119927 = 0;
	HEX3Atmp_119927 = (NI32)(x->Sup.len - 1);
	res_119929 = 0;
	while (1) {
		if (!(res_119929 <= HEX3Atmp_119927)) goto LA1;
		i_119874 = res_119929;
		{
			NIM_CHAR c;
			c = x->data[i_119874];
			{
				if (!((NU8)(c) == (NU8)(95))) goto LA5;
				goto LA2;
			}
			LA5: ;
			{
				if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA9;
				c = ((NIM_CHAR) (((NI) ((NI32)(((NI) (((NU8)(c)))) + 32)))));
			}
			LA9: ;
			h = HEX21HEX26_119015(h, ((NI) (((NU8)(c)))));
		} LA2: ;
		res_119929 += 1;
	} LA1: ;
	result = HEX21HEX24_119040(h);
	return result;
}

N_NIMCALL(NI, hashignorecase_119935)(NimStringDesc* x) {
	NI result;
	NI h;
	NI i_119950;
	NI HEX3Atmp_120002;
	NI res_120004;
	result = 0;
	h = 0;
	i_119950 = 0;
	HEX3Atmp_120002 = 0;
	HEX3Atmp_120002 = (NI32)(x->Sup.len - 1);
	res_120004 = 0;
	while (1) {
		NIM_CHAR c;
		if (!(res_120004 <= HEX3Atmp_120002)) goto LA1;
		i_119950 = res_120004;
		c = x->data[i_119950];
		{
			if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA4;
			c = ((NIM_CHAR) (((NI) ((NI32)(((NI) (((NU8)(c)))) + 32)))));
		}
		LA4: ;
		h = HEX21HEX26_119015(h, ((NI) (((NU8)(c)))));
		res_120004 += 1;
	} LA1: ;
	result = HEX21HEX24_119040(h);
	return result;
}
N_NOINLINE(void, stdlibhashesInit)(void) {
}

N_NOINLINE(void, stdlibhashesDatInit)(void) {
NTI119013.size = sizeof(NI);
NTI119013.kind = 31;
NTI119013.base = 0;
NTI119013.flags = 3;
}

