// File: /workspace/github_cpp_makefile_star2_O3/gvaumour[P]cache-simulator/src/DBAMBPredictor.cc
// Function: DBAMBPredictor::insertionPolicy(unsigned long, unsigned long, bool, Access)
void
DBAMBPredictor::insertionPolicy(uint64_t set, uint64_t index, bool inNVM, Access element)
{
	CacheEntry* current = NULL;
	if(inNVM)
		current = m_tableNVM[set][index];
	else 
		current = m_tableSRAM[set][index];
		
	current->policyInfo = m_cpt;
	current->signature = hashingSignature(element);
		
	
	RD_TYPE reuse_class = RD_NOT_ACCURATE;
	DHPEntry* rap_current;

	if(inNVM)
		stats_allocate_NVM++;			
	else
		stats_allocate_SRAM++;			


	if( (rap_current= lookup(current->signature) ) != NULL )
	{

		/* Set the flag of learning cache line when bypassing */
		if(rap_current->des == BYPASS_CACHE)
		{
			current->isLearning = true;
		}
		else
		{
		
			if(element.isSRAMerror)
				reuse_class = RD_MEDIUM; 

			rap_current->rd_history.push_back(reuse_class); 
			rap_current->rw_history.push_back(element.isWrite());

			updateWindow(rap_current);		
		}
	
		reportAccess(rap_current, element, current, inNVM, "INSERTION",  str_RD_status[reuse_class]);
	}
	
	Predictor::insertionPolicy(set , index , inNVM , element);
	m_cpt++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, %r13d
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xc0(%rsp), %rbp
movl %ecx, %eax
movq 0x8(%rdi,%rax,8), %rax
movq (%rax), %rax
leaq (%rsi,%rsi,2), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%rdx,8), %r12
movl 0x270(%rdi), %eax
movl %eax, 0x38(%r12)
movq 0x30(%rbp), %rax
movq %rax, 0x30(%rsp)
movaps (%rbp), %xmm0
movaps 0x10(%rbp), %xmm1
movaps 0x20(%rbp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xe7a6
movq %rax, %r9
movq %rax, 0x18(%r12)
movl $0x2, 0x40(%rsp)
movzbl %r13b, %ecx
xorb $0x1, %r13b
movzbl %r13b, %eax
incq 0x360(%rbx,%rax,8)
movl 0x338(%rbx), %esi
testq %rsi, %rsi
je 0xecab
movl 0x33c(%rbx), %r8d
xorl %edi, %edi
movq %r9, %rax
xorl %edx, %edx
divq %r8
movq 0x2e8(%rbx), %rax
leaq (%rdx,%rdx,2), %rdx
movq (%rax,%rdx,8), %rax
movq (%rax,%rdi,8), %r13
cmpq %r9, 0x20(%r13)
je 0xeb84
incq %rdi
cmpq %rdi, %rsi
jne 0xeb6d
jmp 0xecab
cmpl $0x2, 0x28(%r13)
movl %ecx, 0x3c(%rsp)
jne 0xeb9a
movb $0x1, 0x148(%r12)
jmp 0xebfe
movl $0x2, %eax
cmpb $0x1, 0x28(%rbp)
jne 0xebb2
movl $0x1, 0x40(%rsp)
movl $0x1, %eax
movq 0x48(%r13), %rsi
cmpq 0x50(%r13), %rsi
je 0xebc8
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%r13)
jmp 0xebd6
leaq 0x40(%r13), %rdi
leaq 0x40(%rsp), %rdx
callq 0x1274a
leaq 0x58(%r13), %rdi
movl 0x1c(%rbp), %eax
cmpl $0x3, %eax
sete %cl
cmpl $0x6, %eax
sete %al
orb %cl, %al
movzbl %al, %esi
callq 0x120dc
movq %rbx, %rdi
movq %r13, %rsi
callq 0xed2c
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x25501(%rip), %rsi     # 0x3410f
leaq 0x25503(%rip), %rdx     # 0x34118
leaq 0x48(%rsp), %rdi
callq 0xcc6c
movl 0x40(%rsp), %eax
leaq 0x36806(%rip), %rcx     # 0x45430
movq (%rcx,%rax,8), %rsi
leaq 0x68(%rsp), %rdi
leaq 0x47(%rsp), %rdx
callq 0x5140
movq 0x30(%rbp), %rax
movq %rax, 0x30(%rsp)
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups 0x20(%rbp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x48(%rsp), %r8
leaq 0x68(%rsp), %r9
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl 0x3c(%rsp), %ecx
callq 0xf054
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xec8f
callq 0x52b0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
movl 0x3c(%rsp), %ecx
je 0xecab
callq 0x52b0
movl 0x3c(%rsp), %ecx
movq 0x30(%rbp), %rax
movq %rax, 0x30(%rsp)
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups 0x20(%rbp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x26664
incq 0x270(%rbx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xed10
callq 0x52b0
jmp 0xed10
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xed24
callq 0x52b0
movq %rbx, %rdi
callq 0x55a0