/* Generated by Nimrod Compiler v0.9.4 */
/*   (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  -I/build/nimrod/src/nimrod/lib -o nimcache/stdlib_hashes.o nimcache/stdlib_hashes.c */
#define NIM_INTBITS 32
#include "nimbase.h"
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
static N_INLINE(NI, HEX21HEX26_119815)(NI h, NI val);
static N_INLINE(void, nimFrame)(TFrame* s);
static N_INLINE(void, popFrame)(void);
static N_INLINE(NI, HEX21HEX24_119840)(NI h);
N_NIMCALL(NI, hashdata_119864)(void* data, NI size);
static N_INLINE(NI, addInt)(NI a, NI b);
N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NI, subInt)(NI a, NI b);
static N_INLINE(NI, hash_120201)(void* x);
static N_INLINE(NI, hash_120601)(NI x);
static N_INLINE(NI, hash_120607)(NI64 x);
static N_INLINE(NI, hash_120613)(NIM_CHAR x);
N_NIMCALL(NI, hash_120627)(NimStringDesc* x);
N_NOINLINE(void, raiseIndexError)(void);
N_NIMCALL(NI, hashignorestyle_120659)(NimStringDesc* x);
static N_INLINE(NI, chckRange)(NI i, NI a, NI b);
N_NOINLINE(void, raiseRangeError)(NI64 val);
N_NIMCALL(NI, hashignorecase_120735)(NimStringDesc* x);
static N_INLINE(NI, hash_120821)(NF x);
extern TFrame* frameptr_13038;

static N_INLINE(void, nimFrame)(TFrame* s) {
	(*s).prev = frameptr_13038;
	frameptr_13038 = s;
}

static N_INLINE(void, popFrame)(void) {
	frameptr_13038 = (*frameptr_13038).prev;
}

static N_INLINE(NI, HEX21HEX26_119815)(NI h, NI val) {
	NI result;
	nimfr("!&", "hashes.nim")
	result = 0;
	nimln(24, "hashes.nim");
	nimln(24, "hashes.nim");
	result = (NI)((NU32)(h) + (NU32)(val));
	nimln(25, "hashes.nim");
	nimln(25, "hashes.nim");
	nimln(25, "hashes.nim");
	result = (NI)((NU32)(result) + (NU32)((NI)((NU32)(result) << (NU32)(10))));
	nimln(26, "hashes.nim");
	nimln(26, "hashes.nim");
	nimln(26, "hashes.nim");
	result = (NI)(result ^ (NI)((NU32)(result) >> (NU32)(6)));
	popFrame();
	return result;
}

static N_INLINE(NI, HEX21HEX24_119840)(NI h) {
	NI result;
	nimfr("!$", "hashes.nim")
	result = 0;
	nimln(31, "hashes.nim");
	nimln(31, "hashes.nim");
	nimln(31, "hashes.nim");
	result = (NI)((NU32)(h) + (NU32)((NI)((NU32)(h) << (NU32)(3))));
	nimln(32, "hashes.nim");
	nimln(32, "hashes.nim");
	nimln(32, "hashes.nim");
	result = (NI)(result ^ (NI)((NU32)(result) >> (NU32)(11)));
	nimln(33, "hashes.nim");
	nimln(33, "hashes.nim");
	nimln(33, "hashes.nim");
	result = (NI)((NU32)(result) + (NU32)((NI)((NU32)(result) << (NU32)(15))));
	popFrame();
	return result;
}

static N_INLINE(NI, addInt)(NI a, NI b) {
	NI result;
	result = 0;
	result = (NI)((NU32)(a) + (NU32)(b));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (0 <= (NI)(result ^ a));
		if (LOC3) goto LA4;
		LOC3 = (0 <= (NI)(result ^ b));
		LA4: ;
		if (!LOC3) goto LA5;
		goto BeforeRet;
	}
	LA5: ;
	raiseOverflow();
	BeforeRet: ;
	return result;
}

static N_INLINE(NI, subInt)(NI a, NI b) {
	NI result;
	result = 0;
	result = (NI)((NU32)(a) - (NU32)(b));
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (0 <= (NI)(result ^ a));
		if (LOC3) goto LA4;
		LOC3 = (0 <= (NI)(result ^ (NI)((NU32) ~(b))));
		LA4: ;
		if (!LOC3) goto LA5;
		goto BeforeRet;
	}
	LA5: ;
	raiseOverflow();
	BeforeRet: ;
	return result;
}

N_NIMCALL(NI, hashdata_119864)(void* data, NI size) {
	NI result;
	NI h;
	NCSTRING p;
	NI i;
	NI s;
	nimfr("hashData", "hashes.nim")
	result = 0;
	nimln(37, "hashes.nim");
	h = 0;
	nimln(42, "hashes.nim");
	p = ((NCSTRING) (data));
	nimln(43, "hashes.nim");
	i = 0;
	nimln(44, "hashes.nim");
	s = size;
	nimln(45, "hashes.nim");
	while (1) {
		nimln(45, "hashes.nim");
		if (!(0 < s)) goto LA1;
		nimln(46, "hashes.nim");
		nimln(46, "hashes.nim");
		h = HEX21HEX26_119815(h, ((NI) (((NU8)(p[i])))));
		nimln(47, "hashes.nim");
		i = addInt(i, 1);
		nimln(48, "hashes.nim");
		s = subInt(s, 1);
	} LA1: ;
	nimln(49, "hashes.nim");
	result = HEX21HEX24_119840(h);
	popFrame();
	return result;
}

static N_INLINE(NI, hash_120201)(void* x) {
	NI result;
	nimfr("hash", "hashes.nim")
	result = 0;
	nimln(68, "hashes.nim");
	nimln(68, "hashes.nim");
	result = (NI)((NU32)(((NI) (x))) >> (NU32)(3));
	popFrame();
	return result;
}

static N_INLINE(NI, hash_120601)(NI x) {
	NI result;
	nimfr("hash", "hashes.nim")
	result = 0;
	nimln(80, "hashes.nim");
	result = x;
	popFrame();
	return result;
}

static N_INLINE(NI, hash_120607)(NI64 x) {
	NI result;
	nimfr("hash", "hashes.nim")
	result = 0;
	nimln(84, "hashes.nim");
	nimln(84, "hashes.nim");
	result = ((NI) (((NI32)(NU32)(NU64)(x))));
	popFrame();
	return result;
}

static N_INLINE(NI, hash_120613)(NIM_CHAR x) {
	NI result;
	nimfr("hash", "hashes.nim")
	result = 0;
	nimln(88, "hashes.nim");
	nimln(88, "hashes.nim");
	result = ((NI) (((NU8)(x))));
	popFrame();
	return result;
}

N_NIMCALL(NI, hash_120627)(NimStringDesc* x) {
	NI result;
	NI h;
	NI i_120642;
	NI HEX3Atmp_120652;
	NI TMP268;
	NI res_120654;
	nimfr("hash", "hashes.nim")
	result = 0;
	nimln(92, "hashes.nim");
	h = 0;
	i_120642 = 0;
	HEX3Atmp_120652 = 0;
	nimln(93, "hashes.nim");
	nimln(93, "hashes.nim");
	nimln(93, "hashes.nim");
	TMP268 = subInt(x->Sup.len, 1);
	HEX3Atmp_120652 = (NI32)(TMP268);
	nimln(1458, "system.nim");
	res_120654 = 0;
	nimln(1459, "system.nim");
	while (1) {
		nimln(1459, "system.nim");
		if (!(res_120654 <= HEX3Atmp_120652)) goto LA1;
		nimln(1458, "system.nim");
		i_120642 = res_120654;
		nimln(94, "hashes.nim");
		nimln(94, "hashes.nim");
		if ((NU)(i_120642) > (NU)(x->Sup.len)) raiseIndexError();
		h = HEX21HEX26_119815(h, ((NI) (((NU8)(x->data[i_120642])))));
		nimln(1461, "system.nim");
		res_120654 = addInt(res_120654, 1);
	} LA1: ;
	nimln(95, "hashes.nim");
	result = HEX21HEX24_119840(h);
	popFrame();
	return result;
}

static N_INLINE(NI, chckRange)(NI i, NI a, NI b) {
	NI result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (a <= i);
		if (!(LOC3)) goto LA4;
		LOC3 = (i <= b);
		LA4: ;
		if (!LOC3) goto LA5;
		result = i;
		goto BeforeRet;
	}
	goto LA1;
	LA5: ;
	{
		raiseRangeError(((NI64) (i)));
	}
	LA1: ;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NI, hashignorestyle_120659)(NimStringDesc* x) {
	NI result;
	NI h;
	NI i_120674;
	NI HEX3Atmp_120727;
	NI TMP269;
	NI res_120729;
	nimfr("hashIgnoreStyle", "hashes.nim")
	result = 0;
	nimln(99, "hashes.nim");
	h = 0;
	i_120674 = 0;
	HEX3Atmp_120727 = 0;
	nimln(100, "hashes.nim");
	nimln(100, "hashes.nim");
	nimln(100, "hashes.nim");
	TMP269 = subInt(x->Sup.len, 1);
	HEX3Atmp_120727 = (NI32)(TMP269);
	nimln(1458, "system.nim");
	res_120729 = 0;
	nimln(1459, "system.nim");
	while (1) {
		nimln(1459, "system.nim");
		if (!(res_120729 <= HEX3Atmp_120727)) goto LA1;
		nimln(1458, "system.nim");
		i_120674 = res_120729;
		{
			NIM_CHAR c;
			nimln(101, "hashes.nim");
			if ((NU)(i_120674) > (NU)(x->Sup.len)) raiseIndexError();
			c = x->data[i_120674];
			nimln(102, "hashes.nim");
			{
				nimln(102, "hashes.nim");
				if (!((NU8)(c) == (NU8)(95))) goto LA5;
				nimln(103, "hashes.nim");
				goto LA2;
			}
			LA5: ;
			nimln(104, "hashes.nim");
			{
				NI TMP270;
				nimln(104, "hashes.nim");
				if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA9;
				nimln(105, "hashes.nim");
				nimln(105, "hashes.nim");
				nimln(105, "hashes.nim");
				nimln(105, "hashes.nim");
				TMP270 = addInt(((NI) (((NU8)(c)))), 32);
				c = ((NIM_CHAR) (((NI)chckRange((NI32)(TMP270), 0, 255))));
			}
			LA9: ;
			nimln(106, "hashes.nim");
			nimln(106, "hashes.nim");
			h = HEX21HEX26_119815(h, ((NI) (((NU8)(c)))));
		} LA2: ;
		nimln(1461, "system.nim");
		res_120729 = addInt(res_120729, 1);
	} LA1: ;
	nimln(107, "hashes.nim");
	result = HEX21HEX24_119840(h);
	popFrame();
	return result;
}

N_NIMCALL(NI, hashignorecase_120735)(NimStringDesc* x) {
	NI result;
	NI h;
	NI i_120750;
	NI HEX3Atmp_120802;
	NI TMP271;
	NI res_120804;
	nimfr("hashIgnoreCase", "hashes.nim")
	result = 0;
	nimln(111, "hashes.nim");
	h = 0;
	i_120750 = 0;
	HEX3Atmp_120802 = 0;
	nimln(112, "hashes.nim");
	nimln(112, "hashes.nim");
	nimln(112, "hashes.nim");
	TMP271 = subInt(x->Sup.len, 1);
	HEX3Atmp_120802 = (NI32)(TMP271);
	nimln(1458, "system.nim");
	res_120804 = 0;
	nimln(1459, "system.nim");
	while (1) {
		NIM_CHAR c;
		nimln(1459, "system.nim");
		if (!(res_120804 <= HEX3Atmp_120802)) goto LA1;
		nimln(1458, "system.nim");
		i_120750 = res_120804;
		nimln(113, "hashes.nim");
		if ((NU)(i_120750) > (NU)(x->Sup.len)) raiseIndexError();
		c = x->data[i_120750];
		nimln(114, "hashes.nim");
		{
			NI TMP272;
			nimln(114, "hashes.nim");
			if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA4;
			nimln(115, "hashes.nim");
			nimln(115, "hashes.nim");
			nimln(115, "hashes.nim");
			nimln(115, "hashes.nim");
			TMP272 = addInt(((NI) (((NU8)(c)))), 32);
			c = ((NIM_CHAR) (((NI)chckRange((NI32)(TMP272), 0, 255))));
		}
		LA4: ;
		nimln(116, "hashes.nim");
		nimln(116, "hashes.nim");
		h = HEX21HEX26_119815(h, ((NI) (((NU8)(c)))));
		nimln(1461, "system.nim");
		res_120804 = addInt(res_120804, 1);
	} LA1: ;
	nimln(117, "hashes.nim");
	result = HEX21HEX24_119840(h);
	popFrame();
	return result;
}

static N_INLINE(NI, hash_120821)(NF x) {
	NI result;
	NF y;
	nimfr("hash", "hashes.nim")
	result = 0;
	nimln(126, "hashes.nim");
	nimln(126, "hashes.nim");
	y = ((NF)(x) + (NF)(1.0000000000000000e+00));
	nimln(127, "hashes.nim");
	result = (*((NI*) (&y)));
	popFrame();
	return result;
}
N_NOINLINE(void, stdlibhashesInit)(void) {
	nimfr("hashes", "hashes.nim")
	popFrame();
}

N_NOINLINE(void, stdlibhashesDatInit)(void) {
}

