// File: /workspace/github_cpp_makefile_star2_O1/gvaumour[P]cache-simulator/src/FeaturesFunction.cc
// Function: hashing_function1(params_hash, unsigned long, unsigned long)
int hashing_function1(params_hash a , uint64_t addr , uint64_t missPC)
{
	string index = a.index;
	bool hash_with_PC = a.xorWithPC;
	int block = a.nbBlock;
	//string b = hash_with_PC ? "TRUE" : "FALSE";
	//cout << "index = " << index << " block = " << block << " hash_with_PC = " << b << endl;
	assert( block < 8);
	uint64_t tag = 0;
	
	if( index == "MissPC")
		tag = bitSelect( missPC , 8*block , 8*block+7);
	else if( index == "Addr")
		tag = bitSelect( addr , 8*block , 8*block+7);
	else if( index == "currentPC")
		tag = bitSelect( Predictor::m_global_PChistory[0] , 8*block , 8*block+7);
	else if( index == "currentPC1")
		tag = bitSelect( Predictor::m_global_PChistory[1] , 8*block , 8*block+7);
	else if( index == "currentPC2")
		tag = bitSelect( Predictor::m_global_PChistory[2] , 8*block , 8*block+7);
	else if( index == "currentPC3")
		tag = bitSelect( Predictor::m_global_PChistory[3] , 8*block , 8*block+7);
	else
		assert(false && "Hashing Function failed");
	
	if( hash_with_PC)
		tag = (tag ^ Predictor::m_global_PChistory[0])%256;

	return tag;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xcc1c
movl 0x24(%r15), %r13d
cmpl $0x8, %r13d
jge 0x15e9f
movb 0x20(%r15), %bpl
leaq 0x1f694(%rip), %rsi     # 0x352ce
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15e09
leaq 0x1f682(%rip), %rsi     # 0x352d5
leaq 0x8(%rsp), %rdi
callq 0x50f0
movq %r14, %rbx
testl %eax, %eax
je 0x15e09
leaq 0x1f66b(%rip), %rsi     # 0x352da
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15cf5
leaq 0x1f660(%rip), %rsi     # 0x352e4
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15d4b
leaq 0x1f652(%rip), %rsi     # 0x352ef
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15d74
leaq 0x1f644(%rip), %rsi     # 0x352fa
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
jne 0x15ebe
leaq 0x2ff91(%rip), %rdx     # 0x45c60
movq 0x10(%rdx), %rax
movq %rax, %rsi
subq 0x18(%rdx), %rsi
sarq $0x3, %rsi
leaq 0x3(%rsi), %rcx
cmpq $0x3f, %rcx
ja 0x15d9a
addq $0x18, %rax
jmp 0x15e06
leaq 0x2ff64(%rip), %rdx     # 0x45c60
movq 0x10(%rdx), %rax
movq %rax, %rcx
subq 0x18(%rdx), %rcx
sarq $0x3, %rcx
cmpq $0x40, %rcx
jb 0x15e06
movq %rcx, %rax
shrq $0x6, %rax
movabsq $-0x400000000000000, %rsi # imm = 0xFC00000000000000
orq %rax, %rsi
testq %rcx, %rcx
cmovgq %rax, %rsi
movq 0x28(%rdx), %rax
movq %rsi, %rdx
shlq $0x6, %rdx
subq %rdx, %rcx
shlq $0x3, %rcx
addq (%rax,%rsi,8), %rcx
jmp 0x15e03
leaq 0x2ff0e(%rip), %rdx     # 0x45c60
movq 0x10(%rdx), %rax
movq %rax, %rsi
subq 0x18(%rdx), %rsi
sarq $0x3, %rsi
leaq 0x1(%rsi), %rcx
cmpq $0x3f, %rcx
ja 0x15db4
addq $0x8, %rax
jmp 0x15e06
leaq 0x2fee5(%rip), %rdx     # 0x45c60
movq 0x10(%rdx), %rax
movq %rax, %rsi
subq 0x18(%rdx), %rsi
sarq $0x3, %rsi
leaq 0x2(%rsi), %rcx
cmpq $0x3f, %rcx
ja 0x15dd1
addq $0x10, %rax
jmp 0x15e06
movq %rcx, %rax
shrq $0x6, %rax
movabsq $-0x400000000000000, %rdi # imm = 0xFC00000000000000
orq %rax, %rdi
cmpq $-0x2, %rsi
jmp 0x15de9
movq %rcx, %rax
shrq $0x6, %rax
movabsq $-0x400000000000000, %rdi # imm = 0xFC00000000000000
orq %rax, %rdi
testq %rsi, %rsi
cmovnsq %rax, %rdi
jmp 0x15ded
movq %rcx, %rax
shrq $0x6, %rax
movabsq $-0x400000000000000, %rdi # imm = 0xFC00000000000000
orq %rax, %rdi
cmpq $-0x1, %rsi
cmovgeq %rax, %rdi
movq 0x28(%rdx), %rax
movq %rdi, %rdx
shlq $0x6, %rdx
subq %rdx, %rcx
shlq $0x3, %rcx
addq (%rax,%rdi,8), %rcx
movq %rcx, %rax
movq (%rax), %rbx
movl %r13d, %esi
shll $0x3, %esi
leal 0x7(,%r13,8), %edx
movq %rbx, %rdi
callq 0x2e6c3
movq %rax, %rbx
testb %bpl, %bpl
je 0x15e7f
leaq 0x2fe32(%rip), %rcx     # 0x45c60
movq 0x10(%rcx), %rdx
movq %rdx, %rax
subq 0x18(%rcx), %rax
sarq $0x3, %rax
cmpq $0x40, %rax
jb 0x15e77
movq %rax, %rdx
shrq $0x6, %rdx
movabsq $-0x400000000000000, %rsi # imm = 0xFC00000000000000
orq %rdx, %rsi
testq %rax, %rax
cmovgq %rdx, %rsi
movq 0x28(%rcx), %rcx
movq %rsi, %rdx
shlq $0x6, %rdx
subq %rdx, %rax
shlq $0x3, %rax
addq (%rcx,%rsi,8), %rax
movq %rax, %rdx
movzbl (%rdx), %eax
movzbl %bl, %ebx
xorl %eax, %ebx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x15e8e
callq 0x52a0
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f3cf(%rip), %rdi     # 0x35275
leaq 0x1f3d2(%rip), %rsi     # 0x3527f
leaq 0x1f3e3(%rip), %rcx     # 0x35297
movl $0x12, %edx
callq 0x51d0
leaq 0x1f440(%rip), %rdi     # 0x35305
leaq 0x1f3b3(%rip), %rsi     # 0x3527f
leaq 0x1f3c4(%rip), %rcx     # 0x35297
movl $0x22, %edx
callq 0x51d0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x15eef
callq 0x52a0
movq %rbx, %rdi
callq 0x55a0