// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, %r12
movq %rdi, %r14
leaq 0x3c94c(%rip), %rcx     # 0x45f50
cmpb $0x1, 0x226(%rcx)
jne 0x9623
movq 0x138(%r12), %rax
cmpq 0x140(%r12), %rax
seta %bpl
jmp 0x9639
movsd 0x130(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setbe %bpl
cmpb $0x1, 0x220(%rcx)
jne 0x97db
movq 0x270(%r14), %rax
cmpq %rax, 0x278(%r14)
je 0x96cb
movl $0x1, %r15d
xorl %ecx, %ecx
testb %bpl, %bpl
je 0x9688
movq 0xd0(%r12), %rdx
cmpl $0x0, 0x4(%rdx,%rcx,8)
je 0x9697
movq (%rax,%rcx,8), %rdi
movq 0xd0(%r12), %rax
movl (%rax,%rcx,8), %esi
callq 0x14b60
jmp 0x96ab
movq 0xd0(%r12), %rdx
cmpl $0x1, 0x4(%rdx,%rcx,8)
jne 0x9672
movq (%rax,%rcx,8), %rdi
movq 0xd0(%r12), %rax
movl (%rax,%rcx,8), %esi
callq 0x14b12
movl %r15d, %ecx
movq 0x270(%r14), %rax
movq 0x278(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r15d
cmpq %rcx, %rdx
ja 0x965e
movq 0x278(%r14), %rax
cmpq 0x270(%r14), %rax
je 0x97b4
movl $0x1, %r15d
leaq 0x58(%rsp), %rbx
xorl %r13d, %r13d
movq %r14, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movl %r15d, 0x1c(%rsp)
movq 0x288(%r14), %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), %r14
movq %r14, %rdi
callq 0xcc1c
movq 0x20(%rbp,%r15,8), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%r12), %rsi
movq 0x20(%r12), %rdx
movq %r14, %rdi
callq 0x15bec
movl %eax, %ebp
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
movl 0x1c(%rsp), %r15d
je 0x975f
callq 0x52a0
movq 0x10(%rsp), %r14
movq 0x270(%r14), %rax
movq (%rax,%r13,8), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x1493e
movq 0x8(%rsp), %r12
movq 0xd0(%r12), %rcx
movl %ebp, (%rcx,%r13,8)
movl %eax, 0x4(%rcx,%r13,8)
movq 0x278(%r14), %rax
subq 0x270(%r14), %rax
movl %r15d, %r13d
sarq $0x3, %rax
incl %r15d
cmpq %r13, %rax
leaq 0x58(%rsp), %rbx
ja 0x96f7
leaq 0x3c795(%rip), %rax     # 0x45f50
cmpb $0x0, 0x222(%rax)
je 0x995f
xorpd %xmm0, %xmm0
movupd %xmm0, 0x138(%r12)
jmp 0x995f
movq %r12, 0x8(%rsp)
movq 0x270(%r14), %rax
movq 0x278(%r14), %rcx
cmpb %dl, %bpl
je 0x98a5
cmpq %rax, %rcx
je 0x995f
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 0xcc1c
movq 0x20(%rbp,%r15,8), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rax), %rdx
leaq 0x20(%rsp), %rdi
callq 0x15bec
movl %eax, %ebp
movq 0x20(%rsp), %rdi
movq %rbx, %r15
cmpq %rbx, %rdi
je 0x986a
callq 0x52a0
movq 0x270(%r14), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %esi
callq 0x14b12
movq 0x278(%r14), %rax
subq 0x270(%r14), %rax
movl %r13d, %r12d
sarq $0x3, %rax
incl %r13d
cmpq %r12, %rax
movq %r15, %rbx
ja 0x980e
jmp 0x995f
cmpq %rax, %rcx
je 0x995f
movl $0x1, %r13d
leaq 0x80(%rsp), %rbx
xorl %r12d, %r12d
movq %r14, 0x10(%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 0xcc1c
movq 0x20(%rbp,%r15,8), %rax
movq %rax, 0x90(%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rax), %rdx
movq %rbx, %rdi
callq 0x15bec
movl %eax, %ebp
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
movq %r14, %rbx
je 0x9927
callq 0x52a0
movq 0x10(%rsp), %r14
movq 0x270(%r14), %rax
movq (%rax,%r12,8), %rdi
movl %ebp, %esi
callq 0x14b60
movq 0x278(%r14), %rax
subq 0x270(%r14), %rax
movl %r13d, %r12d
sarq $0x3, %rax
incl %r13d
cmpq %r12, %rax
ja 0x98c4
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 0x9997
jmp 0x999c
movq %rax, %r15
movq 0x20(%rsp), %rdi
jmp 0x9992
movq %rax, %r15
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
je 0x999c
callq 0x52a0
movq %r15, %rdi
callq 0x55a0