// File: /workspace/github_cpp_makefile_star2_O3/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 0xcbd6
movl 0x24(%r15), %r13d
cmpl $0x8, %r13d
jge 0x15c71
movb 0x20(%r15), %bpl
leaq 0x1f860(%rip), %rsi     # 0x3529e
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15be4
leaq 0x1f84e(%rip), %rsi     # 0x352a5
leaq 0x8(%rsp), %rdi
callq 0x50f0
movq %r14, %rbx
testl %eax, %eax
je 0x15be4
leaq 0x1f837(%rip), %rsi     # 0x352aa
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15b0b
leaq 0x1f828(%rip), %rsi     # 0x352b4
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15b44
leaq 0x1f81a(%rip), %rsi     # 0x352bf
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x15b74
leaq 0x1f80c(%rip), %rsi     # 0x352ca
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
jne 0x15c90
leaq 0x30189(%rip), %rax     # 0x45c60
movq 0x10(%rax), %rdx
movq %rdx, %rsi
subq 0x18(%rax), %rsi
movq 0x28(%rax), %rcx
sarq $0x3, %rsi
leaq 0x3(%rsi), %rax
cmpq $-0x3, %rsi
jl 0x15ba4
cmpq $0x3f, %rax
ja 0x15bad
addq $0x18, %rdx
jmp 0x15bde
leaq 0x3014e(%rip), %rdx     # 0x45c60
movq 0x10(%rdx), %rax
movq 0x28(%rdx), %rcx
movq %rax, %rsi
subq 0x18(%rdx), %rsi
movq %rsi, %rdx
sarq $0x3, %rdx
js 0x15bc8
cmpq $0x40, %rdx
jb 0x15be1
movq %rdx, %rsi
shrq $0x6, %rsi
jmp 0x15bcc
leaq 0x30115(%rip), %rax     # 0x45c60
movq 0x10(%rax), %rdx
movq %rdx, %rsi
subq 0x18(%rax), %rsi
movq 0x28(%rax), %rcx
sarq $0x3, %rsi
leaq 0x1(%rsi), %rax
cmpq $-0x1, %rsi
jl 0x15ba4
cmpq $0x3f, %rax
ja 0x15bad
addq $0x8, %rdx
jmp 0x15bde
leaq 0x300e5(%rip), %rax     # 0x45c60
movq 0x10(%rax), %rdx
movq %rdx, %rsi
subq 0x18(%rax), %rsi
movq 0x28(%rax), %rcx
sarq $0x3, %rsi
leaq 0x2(%rsi), %rax
cmpq $-0x2, %rsi
jl 0x15ba4
cmpq $0x3f, %rax
ja 0x15bad
addq $0x10, %rdx
jmp 0x15bde
movq %rax, %rdx
sarq $0x6, %rdx
jmp 0x15bb4
movq %rax, %rdx
shrq $0x6, %rdx
movq %rdx, %rsi
shlq $0x6, %rsi
subq %rsi, %rax
shlq $0x3, %rax
addq (%rcx,%rdx,8), %rax
jmp 0x15be1
sarq $0x9, %rsi
movq %rsi, %rax
shlq $0x6, %rax
subq %rax, %rdx
shlq $0x3, %rdx
addq (%rcx,%rsi,8), %rdx
movq %rdx, %rax
movq (%rax), %rbx
movl %r13d, %esi
shll $0x3, %esi
leal 0x7(,%r13,8), %edx
movq %rbx, %rdi
callq 0x2e347
movq %rax, %rbx
testb %bpl, %bpl
je 0x15c51
leaq 0x30057(%rip), %rcx     # 0x45c60
movq 0x10(%rcx), %rsi
movq 0x28(%rcx), %rax
movq %rsi, %rdx
subq 0x18(%rcx), %rdx
movq %rdx, %rcx
sarq $0x3, %rcx
js 0x15c30
cmpq $0x40, %rcx
jb 0x15c49
movq %rcx, %rdx
shrq $0x6, %rdx
jmp 0x15c34
sarq $0x9, %rdx
movq %rdx, %rsi
shlq $0x6, %rsi
subq %rsi, %rcx
shlq $0x3, %rcx
addq (%rax,%rdx,8), %rcx
movq %rcx, %rsi
movzbl (%rsi), %eax
movzbl %bl, %ebx
xorl %eax, %ebx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x15c60
callq 0x52b0
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f5cd(%rip), %rdi     # 0x35245
leaq 0x1f5d0(%rip), %rsi     # 0x3524f
leaq 0x1f5e1(%rip), %rcx     # 0x35267
movl $0x12, %edx
callq 0x51d0
leaq 0x1f63e(%rip), %rdi     # 0x352d5
leaq 0x1f5b1(%rip), %rsi     # 0x3524f
leaq 0x1f5c2(%rip), %rcx     # 0x35267
movl $0x22, %edx
callq 0x51d0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x15cc1
callq 0x52b0
movq %rbx, %rdi
callq 0x55a0