// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x2b8(%rdi), %r14
leaq 0x224db(%rip), %rsi     # 0x29034
movq %r14, %rdi
callq 0x9f59
testb %al, %al
je 0x6c7e
xorl %r13d, %r13d
leaq 0x40(%rsp), %r15
movzbl %bpl, %eax
movl %eax, 0x4(%rsp)
xorl %r12d, %r12d
movl %r13d, %r13d
movq 0x278(%rbx), %rax
subq 0x270(%rbx), %rax
sarq $0x3, %rax
cmpq %r13, %rax
jbe 0x6d0d
imulq $0x28, %r13, %rsi
addq 0x288(%rbx), %rsi
movq %r15, %rdi
callq 0x9f3a
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x11de8
movl %eax, %r14d
movq %r15, %rdi
callq 0x5618
movq 0x270(%rbx), %rax
movq (%rax,%r13,8), %rdi
movl %r14d, %esi
pushq $0x1
popq %rdx
callq 0x11132
movl %eax, %ebp
movq 0x270(%rbx), %rax
movq (%rax,%r13,8), %rdi
movl %r14d, %esi
movl 0x4(%rsp), %edx
callq 0x11088
movl %eax, %r15d
leaq 0x3734d(%rip), %rax     # 0x3df50
cmpb $0x1, (%rax)
jne 0x6c64
leaq 0x36851(%rip), %rdi     # 0x3d460
leaq 0x2262c(%rip), %rsi     # 0x29242
callq 0x52c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x5200
movq %rax, %rdi
leaq 0x2261b(%rip), %rsi     # 0x2924b
callq 0x52c0
movq %rax, %rdi
movl %r14d, %esi
callq 0x5560
movq %rax, %rdi
leaq 0x23fd9(%rip), %rsi     # 0x2ac23
callq 0x52c0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movl %ebp, %eax
negl %eax
testl %r15d, %r15d
cmovnel %ebp, %eax
addl %eax, %r12d
incl %r13d
leaq 0x40(%rsp), %r15
jmp 0x6b7c
leaq 0x223b6(%rip), %rsi     # 0x2903b
movq %r14, %rdi
callq 0x9f59
testb %al, %al
je 0x6d2c
movq 0x278(%rbx), %rax
cmpq 0x270(%rbx), %rax
je 0x6d2c
movq 0x288(%rbx), %rsi
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x9f3a
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x11de8
movl %eax, %r14d
leaq 0x18(%rsp), %rdi
callq 0x5618
movq 0x270(%rbx), %rax
movq (%rax), %rdi
pushq $0x1
popq %rdx
movl %r14d, %esi
callq 0x11132
testl %eax, %eax
jle 0x6d1b
movq 0x270(%rbx), %rax
movq (%rax), %rdi
movzbl %bpl, %edx
movl %r14d, %esi
callq 0x11088
jmp 0x6d1d
movl %r12d, %esi
movl 0x4(%rsp), %edx
callq 0x8916
jmp 0x6d1d
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22528(%rip), %rdi     # 0x2925b
leaq 0x22345(%rip), %rsi     # 0x2907f
leaq 0x22546(%rip), %rcx     # 0x29287
movl $0x1f9, %edx            # imm = 0x1F9
callq 0x51e0
jmp 0x6d4d
movq %r15, %rdi
movq %rax, %rbx
callq 0x5618
movq %rbx, %rdi
callq 0x5570