// File: /workspace/github_cpp_makefile_star2_O2/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, %ebp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xc0(%rsp), %r14
movl %ecx, %eax
movq 0x8(%rdi,%rax,8), %rax
movq (%rax), %rax
imulq $0x18, %rsi, %rcx
movq (%rax,%rcx), %rax
movq %rdx, 0x40(%rsp)
movq (%rax,%rdx,8), %r12
movl 0x270(%rdi), %eax
movl %eax, 0x38(%r12)
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movaps (%r14), %xmm0
movaps 0x10(%r14), %xmm1
movaps 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xc14e
movq %rax, 0x18(%r12)
movl $0x2, 0x38(%rsp)
movl %ebp, %ecx
xorb $0x1, %cl
movzbl %cl, %ecx
incq 0x360(%rbx,%rcx,8)
movq %rbx, %rdi
movq %rax, %rsi
callq 0xc1d8
movzbl %bpl, %ebp
testq %rax, %rax
je 0xc510
movq %rax, %r13
cmpl $0x2, 0x28(%rax)
jne 0xc440
movb $0x1, 0x148(%r12)
jmp 0xc489
cmpb $0x1, 0x28(%r14)
jne 0xc44f
movl $0x1, 0x38(%rsp)
leaq 0x40(%r13), %rdi
leaq 0x38(%rsp), %rsi
callq 0xe92c
movq %r13, %rdi
addq $0x58, %rdi
movl 0x1c(%r14), %eax
cmpl $0x3, %eax
sete %cl
cmpl $0x6, %eax
sete %al
orb %cl, %al
movzbl %al, %esi
callq 0xe94a
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc584
leaq 0x1cc9b(%rip), %rsi     # 0x2912b
leaq 0x68(%rsp), %rdi
leaq 0x3f(%rsp), %rdx
callq 0x5140
movl 0x38(%rsp), %eax
leaq 0x30f86(%rip), %rcx     # 0x3d430
movq (%rcx,%rax,8), %rsi
leaq 0x48(%rsp), %rdi
leaq 0x3e(%rsp), %rdx
callq 0x5140
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x68(%rsp), %r8
leaq 0x48(%rsp), %r9
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl %ebp, %ecx
callq 0xc7a6
leaq 0x48(%rsp), %rdi
callq 0x5618
leaq 0x68(%rsp), %rdi
callq 0x5618
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq 0x40(%rsp), %rdx
movl %ebp, %ecx
callq 0x1f3a2
incq 0x270(%rbx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5618
jmp 0xc572
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x5618
movq %rbx, %rdi
callq 0x5570