// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x35faf(%rip), %r12     # 0x3df50
cmpb $0x1, 0x226(%r12)
jne 0x7fc0
movq 0x138(%rbx), %rax
cmpq 0x140(%rbx), %rax
seta %bpl
jmp 0x7fd4
movsd 0x130(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setbe %bpl
cmpb $0x1, 0x220(%r12)
jne 0x80c0
xorl %r15d, %r15d
movl %r15d, %r15d
movq 0x270(%r14), %rax
movq 0x278(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x8041
movq 0xd0(%rbx), %rcx
movl 0x4(%rcx,%r15,8), %edx
testb %bpl, %bpl
je 0x802a
testl %edx, %edx
je 0x802f
movq (%rax,%r15,8), %rdi
movl (%rcx,%r15,8), %esi
callq 0x111ac
jmp 0x803c
cmpl $0x1, %edx
jne 0x801b
movq (%rax,%r15,8), %rdi
movl (%rcx,%r15,8), %esi
callq 0x11188
incl %r15d
jmp 0x7fe6
xorl %edx, %edx
leaq 0x50(%rsp), %r15
subq %rax, %rcx
movl %edx, %r13d
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x8130
imulq $0x28, %r13, %rsi
addq 0x288(%r14), %rsi
movq %r15, %rdi
callq 0x9f3a
movq 0x8(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq %r15, %rdi
callq 0x11de8
movl %eax, %ebp
movq %r15, %rdi
callq 0x5618
movq 0x270(%r14), %rax
movq (%rax,%r13,8), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x11088
movq 0xd0(%rbx), %rcx
movl %ebp, (%rcx,%r13,8)
movl %eax, 0x4(%rcx,%r13,8)
leal 0x1(%r13), %edx
movq 0x270(%r14), %rax
movq 0x278(%r14), %rcx
jmp 0x8048
xorl %eax, %eax
cmpb %dl, %bpl
je 0x8156
leaq 0x28(%rsp), %r15
movl %eax, %r12d
movq 0x278(%r14), %rax
subq 0x270(%r14), %rax
sarq $0x3, %rax
cmpq %r12, %rax
jbe 0x8147
imulq $0x28, %r12, %rsi
addq 0x288(%r14), %rsi
movq %r15, %rdi
callq 0x9f3a
movq 0x8(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq %r15, %rdi
callq 0x11de8
movl %eax, %ebp
movq %r15, %rdi
callq 0x5618
movq 0x270(%r14), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %esi
callq 0x11188
leal 0x1(%r12), %eax
jmp 0x80d0
cmpb $0x0, 0x222(%r12)
je 0x8147
xorpd %xmm0, %xmm0
movupd %xmm0, 0x138(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %r15
movl %eax, %r12d
movq 0x278(%r14), %rax
subq 0x270(%r14), %rax
sarq $0x3, %rax
cmpq %r12, %rax
jbe 0x8147
imulq $0x28, %r12, %rsi
addq 0x288(%r14), %rsi
movq %r15, %rdi
callq 0x9f3a
movq 0x8(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq %r15, %rdi
callq 0x11de8
movl %eax, %ebp
movq %r15, %rdi
callq 0x5618
movq 0x270(%r14), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %esi
callq 0x111ac
leal 0x1(%r12), %eax
jmp 0x8159
jmp 0x81bd
jmp 0x81bd
movq %rax, %rbx
movq %r15, %rdi
callq 0x5618
movq %rbx, %rdi
callq 0x5570