// File: /workspace/github_cpp_makefile_star2_O3/gvaumour[P]cache-simulator/src/Cerebron.cc
// Function: CerebronPredictor::doLearning(CacheEntry*, bool)
void 
CerebronPredictor::doLearning(CacheEntry* entry, bool inNVM)
{
	allocDecision des = getDecision(entry);
	if( simu_parameters.Cerebron_independantLearning)
	{
		for(unsigned i = 0; i < m_features.size() ; i++)
		{
			if( (des == ALLOCATE_IN_NVM && entry->PHC_allocation_pred[i].second == ALLOCATE_IN_SRAM ) || \
			( des == ALLOCATE_IN_SRAM && entry->PHC_allocation_pred[i].second == ALLOCATE_IN_NVM) )
				m_features[i]->decreaseConfidence(entry->PHC_allocation_pred[i].first);
			else 
				m_features[i]->increaseConfidence(entry->PHC_allocation_pred[i].first);
		}
		
		for(unsigned i = 0 ; i < m_features.size() ; i++)
		{
			pair<int , allocDecision> dummy;
			dummy.first = hashing_function1(m_features_hash[i] , entry->address , entry->missPC);
			dummy.second = m_features[i]->getAllocDecision(dummy.first, false);
			entry->PHC_allocation_pred[i] = dummy;
		}
		if(simu_parameters.Cerebron_resetEnergyValues)
		{
			entry->e_sram = 0;
			entry->e_nvm = 0;
		}
	
	}
	else
	{	
		if( ( des == ALLOCATE_IN_NVM && !inNVM) || \
			(des == ALLOCATE_IN_SRAM && inNVM) )
		{
			for(unsigned i = 0; i < m_features.size() ; i++)
			{
				int hash = hashing_function1( m_features_hash[i] , entry->address , entry->missPC);
				m_features[i]->decreaseConfidence(hash);
			}
		}			
		else
		{
			for(unsigned i = 0; i < m_features.size() ; i++)
			{
				int hash = hashing_function1 ( m_features_hash[i] , entry->address , entry->missPC);
				m_features[i]->increaseConfidence(hash);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r14
leaq 0x3c9e5(%rip), %rcx     # 0x45f50
cmpb $0x1, 0x226(%rcx)
jne 0x9588
movq 0x138(%rsi), %rax
cmpq 0x140(%rsi), %rax
seta %bpl
jmp 0x959c
movsd 0x130(%rsi), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setbe %bpl
cmpb $0x1, 0x220(%rcx)
jne 0x9730
movq 0x270(%r14), %rax
cmpq %rax, 0x278(%r14)
movq %r14, %rcx
movq %rsi, %r14
je 0x970a
movq %rcx, 0x8(%rsp)
movl $0x1, %r15d
xorl %ecx, %ecx
movq 0xd0(%r14), %rdx
movl 0x4(%rdx,%rcx,8), %esi
testb %bpl, %bpl
je 0x95f2
testl %esi, %esi
je 0x95f7
movq (%rax,%rcx,8), %rdi
movl (%rdx,%rcx,8), %esi
callq 0x149f2
jmp 0x9603
cmpl $0x1, %esi
jne 0x95e4
movq (%rax,%rcx,8), %rdi
movl (%rdx,%rcx,8), %esi
callq 0x149a4
movl %r15d, %ecx
movq 0x8(%rsp), %rdx
movq 0x270(%rdx), %rax
movq 0x278(%rdx), %rdx
movq %rdx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
incl %r15d
cmpq %rcx, %rsi
ja 0x95d0
cmpq %rax, %rdx
movq 0x8(%rsp), %r12
je 0x970a
movl $0x1, %r15d
leaq 0x58(%rsp), %rbx
xorl %r13d, %r13d
movq %r14, 0x10(%rsp)
movl %r15d, 0x1c(%rsp)
movq 0x288(%r12), %rbp
leaq (,%r13,4), %r15
addq %r13, %r15
movq %rbx, 0x48(%rsp)
movq (%rbp,%r15,8), %rsi
movq 0x8(%rbp,%r15,8), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0xcbd6
movq 0x20(%rbp,%r15,8), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%r14), %rsi
movq 0x20(%r14), %rdx
movq %r12, %rdi
callq 0x159f0
movl %eax, %ebp
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
movl 0x1c(%rsp), %r15d
je 0x96b3
callq 0x52b0
movq 0x8(%rsp), %r12
movq 0x270(%r12), %rax
movq (%rax,%r13,8), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x147cc
movq 0x10(%rsp), %r14
movq 0xd0(%r14), %rcx
movl %ebp, (%rcx,%r13,8)
movl %eax, 0x4(%rcx,%r13,8)
movq 0x278(%r12), %rax
subq 0x270(%r12), %rax
movl %r15d, %r13d
sarq $0x3, %rax
incl %r15d
cmpq %r13, %rax
leaq 0x58(%rsp), %rbx
ja 0x964c
leaq 0x3c83f(%rip), %rax     # 0x45f50
cmpb $0x0, 0x222(%rax)
je 0x98b4
xorpd %xmm0, %xmm0
movupd %xmm0, 0x138(%r14)
jmp 0x98b4
movq %rsi, 0x10(%rsp)
movq 0x270(%r14), %rax
movq 0x278(%r14), %rcx
cmpb %dl, %bpl
je 0x97fa
cmpq %rax, %rcx
je 0x98b4
movl $0x1, %r13d
leaq 0x30(%rsp), %rbx
xorl %r12d, %r12d
movq 0x288(%r14), %rbp
leaq (%r12,%r12,4), %r15
movq %rbx, 0x20(%rsp)
movq (%rbp,%r15,8), %rsi
movq 0x8(%rbp,%r15,8), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0xcbd6
movq 0x20(%rbp,%r15,8), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rax), %rdx
leaq 0x20(%rsp), %rdi
callq 0x159f0
movl %eax, %ebp
movq 0x20(%rsp), %rdi
movq %rbx, %r15
cmpq %rbx, %rdi
je 0x97bf
callq 0x52b0
movq 0x270(%r14), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %esi
callq 0x149a4
movq 0x278(%r14), %rax
subq 0x270(%r14), %rax
movl %r13d, %r12d
sarq $0x3, %rax
incl %r13d
cmpq %r12, %rax
movq %r15, %rbx
ja 0x9763
jmp 0x98b4
cmpq %rax, %rcx
je 0x98b4
movl $0x1, %r13d
leaq 0x80(%rsp), %rbx
xorl %r12d, %r12d
movq %r14, 0x8(%rsp)
movq 0x288(%r14), %rbp
leaq (%r12,%r12,4), %r15
movq %rbx, 0x70(%rsp)
movq (%rbp,%r15,8), %rsi
movq 0x8(%rbp,%r15,8), %rdx
addq %rsi, %rdx
movq %rbx, %r14
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0xcbd6
movq 0x20(%rbp,%r15,8), %rax
movq %rax, 0x90(%rsp)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rax), %rdx
movq %rbx, %rdi
callq 0x159f0
movl %eax, %ebp
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
movq %r14, %rbx
je 0x987c
callq 0x52b0
movq 0x8(%rsp), %r14
movq 0x270(%r14), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %esi
callq 0x149f2
movq 0x278(%r14), %rax
subq 0x270(%r14), %rax
movl %r13d, %r12d
sarq $0x3, %rax
incl %r13d
cmpq %r12, %rax
ja 0x9819
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
jne 0x98ec
jmp 0x98f1
movq %rax, %r15
movq 0x20(%rsp), %rdi
jmp 0x98e7
movq %rax, %r15
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
je 0x98f1
callq 0x52b0
movq %r15, %rdi
callq 0x55a0
nop