// File: /workspace/github_cpp_makefile_star2_O3/gvaumour[P]cache-simulator/src/Cerebron.cc
// Function: CerebronPredictor::activationFunction(bool, unsigned long, unsigned long)
allocDecision
CerebronPredictor::activationFunction( bool isWrite , uint64_t block_addr , uint64_t missPC)
{

	if(m_activation_function == "linear")
	{
	
		int sum_pred = 0;
		for(unsigned i = 0 ; i < m_features.size() ; i++)
		{
			int hash = hashing_function1 ( m_features_hash[i] , block_addr , missPC);
			int confidence = m_features[i]->getConfidence(hash, true);
			allocDecision des = m_features[i]->getAllocDecision(hash, isWrite );

			if(simu_parameters.printDebug)
				debug_file << "Feature " << i << " -- ID Dataset:" << hash << "\t" << missPC << endl;

		
			if( des == ALLOCATE_IN_SRAM )
				sum_pred += (-1) * confidence;
			else
				sum_pred += confidence;
		}
		return convertToAllocDecision(sum_pred, isWrite );
	}
	else if(m_activation_function == "max")
	{
		allocDecision des = ALLOCATE_IN_SRAM;
		int max_confidence = 0;
		for(unsigned i = 0 ; i < m_features.size() ; i++)
		{
			int hash = hashing_function1( m_features_hash[i] , block_addr , missPC);
			int confidence = m_features[i]->getConfidence(hash, true);
			
			if(max_confidence < confidence)
			{
				max_confidence = confidence;
				des = m_features[i]->getAllocDecision(hash, isWrite );
			}
			return des;
		}
	}
	
	assert(false && "Error, should have return before");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, (%rsp)
movq %rdx, 0x18(%rsp)
movl %esi, %ebp
movq %rdi, %r12
leaq 0x2b8(%rdi), %rbx
leaq 0x2c88c(%rip), %rsi     # 0x34018
movq %rbx, %rdi
callq 0x50f0
testl %eax, %eax
je 0x7855
leaq 0x2c87c(%rip), %rsi     # 0x3401f
movq %rbx, %rdi
callq 0x50f0
testl %eax, %eax
jne 0x7a46
movq 0x278(%r12), %rax
cmpq 0x270(%r12), %rax
je 0x7a46
movq 0x288(%r12), %r15
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0xcbd6
movq 0x20(%r15), %rax
movq %rax, 0x20(%rbx)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq (%rsp), %rdx
callq 0x159f0
movl %eax, %ebx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x781b
callq 0x52b0
movq 0x270(%r12), %rax
movq (%rax), %rdi
movl %ebx, %esi
movl $0x1, %edx
callq 0x1491e
testl %eax, %eax
jle 0x7a02
movq 0x270(%r12), %rax
movq (%rax), %rdi
movzbl %bpl, %edx
movl %ebx, %esi
callq 0x147cc
jmp 0x7a37
movq 0x278(%r12), %rax
cmpq 0x270(%r12), %rax
movl %ebp, 0xc(%rsp)
je 0x7a06
xorl %ebx, %ebx
movl $0x1, %r14d
leaq 0x38(%rsp), %r15
movzbl %bpl, %ecx
movl %ecx, 0x10(%rsp)
xorl %edx, %edx
movq %r12, 0x20(%rsp)
movl %edx, 0x14(%rsp)
movq 0x288(%r12), %r12
leaq (%rbx,%rbx,4), %r13
movq %r15, 0x28(%rsp)
movq (%r12,%r13,8), %rsi
movq 0x8(%r12,%r13,8), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rbp
movq %rbp, %rdi
callq 0xcbd6
movq 0x20(%r12,%r13,8), %rax
movq %rax, 0x48(%rsp)
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
movq (%rsp), %rdx
callq 0x159f0
movl %eax, %ebp
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x78e5
callq 0x52b0
movq 0x20(%rsp), %r13
movq 0x270(%r13), %rax
movq (%rax,%rbx,8), %rdi
movl %ebp, %esi
movl $0x1, %edx
callq 0x1491e
movl %eax, %r12d
movq 0x270(%r13), %rax
movq (%rax,%rbx,8), %rdi
movl %ebp, %esi
movl 0x10(%rsp), %edx
callq 0x147cc
movl %eax, %r13d
leaq 0x3e62c(%rip), %rax     # 0x45f50
cmpb $0x1, (%rax)
jne 0x79c1
movl $0x8, %edx
leaq 0x3db27(%rip), %r15     # 0x45460
movq %r15, %rdi
leaq 0x2c8e3(%rip), %rsi     # 0x34226
callq 0x5360
movq %r15, %rdi
movq %rbx, %rsi
callq 0x51f0
movq %rax, %rbx
movl $0xf, %edx
movq %rax, %rdi
leaq 0x2c8ca(%rip), %rsi     # 0x3422f
callq 0x5360
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5580
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2e2ed(%rip), %rsi     # 0x35c73
callq 0x5360
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x51f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x52c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5200
movl %r12d, %eax
negl %eax
testl %r13d, %r13d
cmovnel %r12d, %eax
movl 0x14(%rsp), %edx
addl %eax, %edx
movq 0x20(%rsp), %r12
movq 0x278(%r12), %rax
subq 0x270(%r12), %rax
movl %r14d, %ebx
sarq $0x3, %rax
incl %r14d
cmpq %rbx, %rax
leaq 0x38(%rsp), %r15
ja 0x788b
jmp 0x7a08
xorl %eax, %eax
jmp 0x7a37
xorl %edx, %edx
leaq 0x3e541(%rip), %rax     # 0x45f50
cmpb $0x1, 0x221(%rax)
jne 0x7a2f
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
cmpl 0x1c0(%rax), %ecx
jge 0x7a2f
movl 0xc(%rsp), %eax
xorb $0x1, %al
jmp 0x7a34
testl %edx, %edx
setns %al
movzbl %al, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2c7f2(%rip), %rdi     # 0x3423f
leaq 0x2c60f(%rip), %rsi     # 0x34063
leaq 0x2c810(%rip), %rcx     # 0x3426b
movl $0x1f9, %edx            # imm = 0x1F9
callq 0x51d0
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
jne 0x7a81
jmp 0x7a86
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a86
callq 0x52b0
movq %rbx, %rdi
callq 0x55a0