// File: /workspace/github_cpp_makefile_star2_O1/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
movl %ecx, %eax
movq 0x8(%rdi,%rax,8), %rax
movq (%rax), %rax
leaq (%rsi,%rsi,2), %rcx
movq (%rax,%rcx,8), %rax
movq %rdx, 0x40(%rsp)
movq (%rax,%rdx,8), %r12
movl 0x270(%rdi), %eax
movl %eax, 0x38(%r12)
movq 0xf0(%rsp), %rax
movq %rax, 0x30(%rsp)
movaps 0xc0(%rsp), %xmm0
movaps 0xd0(%rsp), %xmm1
movaps 0xe0(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xe832
movq %rax, 0x18(%r12)
movl $0x2, 0x38(%rsp)
movl %ebp, %eax
xorb $0x1, %al
movzbl %al, %eax
incq 0x360(%rbx,%rax,8)
movl 0x338(%rbx), %esi
testq %rsi, %rsi
je 0xec0c
movq 0x18(%r12), %rcx
movl 0x33c(%rbx), %edi
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movq 0x2e8(%rbx), %rax
leaq (%rdx,%rdx,2), %rdx
movq (%rax,%rdx,8), %rax
xorl %edx, %edx
movq (%rax,%rdx,8), %r13
cmpq %rcx, 0x20(%r13)
je 0xec0f
incq %rdx
cmpq %rdx, %rsi
jne 0xebfa
xorl %r13d, %r13d
leaq 0xc0(%rsp), %r14
movzbl %bpl, %ebp
testq %r13, %r13
je 0xed3b
cmpl $0x2, 0x28(%r13)
jne 0xec36
movb $0x1, 0x148(%r12)
jmp 0xec96
cmpb $0x1, 0x28(%r14)
jne 0xec45
movl $0x1, 0x38(%rsp)
movq 0x48(%r13), %rsi
cmpq 0x50(%r13), %rsi
je 0xec5f
movl 0x38(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%r13)
jmp 0xec6d
leaq 0x40(%r13), %rdi
leaq 0x38(%rsp), %rdx
callq 0x127f2
leaq 0x58(%r13), %rdi
movl 0x1c(%r14), %eax
cmpl $0x3, %eax
sete %cl
cmpl $0x6, %eax
sete %al
orb %cl, %al
movzbl %al, %esi
callq 0x12186
movq %rbx, %rdi
movq %r13, %rsi
callq 0xedc2
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x25495(%rip), %rsi     # 0x3413b
leaq 0x25497(%rip), %rdx     # 0x34144
leaq 0x48(%rsp), %rdi
callq 0xccac
movl 0x38(%rsp), %eax
leaq 0x3676e(%rip), %rcx     # 0x45430
movq (%rcx,%rax,8), %rsi
leaq 0x68(%rsp), %rdi
leaq 0x3f(%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 0x48(%rsp), %r8
leaq 0x68(%rsp), %r9
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl %ebp, %ecx
callq 0xf0f6
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xed27
callq 0x52a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xed3b
callq 0x52a0
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 0x26892
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 0xeda6
callq 0x52a0
jmp 0xeda6
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xedba
callq 0x52a0
movq %rbx, %rdi
callq 0x55a0