// File: /workspace/github_cpp_makefile_star2_O1/gvaumour[P]cache-simulator/src/Predictor.cc
// Function: Predictor::updateFUcaches(unsigned long, bool)
void 
Predictor::updateFUcaches(uint64_t block_addr, bool inNVM)
{
	if(!simu_parameters.simulate_conflicts)
		return;
	DPRINTF(DebugFUcache, "Predictor::updateFUcaches update block %#lx\n", block_addr);
	
	if(m_accessedBlocks.count(block_addr) == 0)
	{
		m_accessedBlocks.insert(pair<uint64_t,uint64_t>(block_addr, cpt_time));
		DPRINTF(DebugFUcache, "First Touch of the block\n");
	}

	vector< vector<MissingTagEntry*> > FUcaches = { m_SRAM_FU , m_NVM_FU };
	
	bool find = false;
		
	for(unsigned i = 0 ; i < FUcaches[inNVM].size() && !find ; i++)
	{
		if(FUcaches[inNVM][i]->addr == block_addr)
		{
			DPRINTF(DebugFUcache, "Find at index %d , updatation !!! \n" , i);				
			FUcaches[inNVM][i]->last_time_touched = cpt_time;
			find = true;
		}
	}
	if(!find) // Data not found, insert the access in the FU cache 
	{
		for(unsigned i = 0; i < FUcaches[inNVM].size() && !find; i++)
		{
			if(!FUcaches[inNVM][i]->isValid)
			{
				FUcaches[inNVM][i]->addr = block_addr;
				FUcaches[inNVM][i]->isValid = true;
				FUcaches[inNVM][i]->last_time_touched = cpt_time;	
				DPRINTF(DebugFUcache, "Added in index %d \n" , i);				
				find = true;		
			}
		}
		if(!find){	
			DPRINTF(DebugFUcache, "HERE ? \n");				
			uint64_t min_time = FUcaches[inNVM][0]->last_time_touched, min_index = 0;
			for(unsigned i = 0; i < FUcaches[inNVM].size() ; i++)
			{
				if(FUcaches[inNVM][i]->last_time_touched < min_time)
				{
					min_time = FUcaches[inNVM][i]->last_time_touched;
					min_index = i;
				}
			}
			FUcaches[inNVM][min_index]->addr = block_addr;
			FUcaches[inNVM][min_index]->isValid = true;
			FUcaches[inNVM][min_index]->last_time_touched = cpt_time;					
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x1f5e5(%rip), %rax     # 0x45f50
cmpb $0x1, 0x88(%rax)
jne 0x26d99
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xfe45(%rip), %rsi      # 0x367d8
leaq 0xfe4a(%rip), %rdx      # 0x367e4
leaq 0x10(%rsp), %rdi
callq 0xccac
leaq 0x8(%r14), %rdi
leaq 0x10(%rsp), %r12
movq %rdi, 0x48(%rsp)
movq %r12, %rsi
callq 0x182c0
movq %rax, %r13
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x269d1
callq 0x52a0
addq $0x10, %r14
movq %r14, 0x40(%rsp)
cmpq %r14, %r13
je 0x269f0
leaq 0xfdff(%rip), %rdi      # 0x367e5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x5050
movq 0x198(%r15), %rdx
leaq 0x190(%r15), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x26a21
movq %rax, %rcx
xorl %esi, %esi
cmpq %rbx, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x26a09
movq %rax, %rdx
cmpq %rax, %rcx
je 0x26a34
cmpq %rbx, 0x20(%rcx)
cmovaq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
jne 0x26ab7
leaq 0x188(%r15), %rdi
leaq 0x10(%rsp), %r14
movq %rbx, (%r14)
leaq 0x1f4c9(%rip), %rax     # 0x45f18
movq (%rax), %rax
movq %rax, 0x8(%r14)
movq %r14, %rsi
callq 0x290be
leaq 0x20(%rsp), %rax
movq %rax, (%r14)
leaq 0xfd6b(%rip), %rsi      # 0x367d8
leaq 0xfd70(%rip), %rdx      # 0x367e4
leaq 0x10(%rsp), %rdi
callq 0xccac
leaq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x182c0
movq %rax, %r13
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26aa4
callq 0x52a0
cmpq 0x40(%rsp), %r13
je 0x26ab7
leaq 0x10028(%rip), %rdi     # 0x36ada
callq 0x54a0
leaq 0x170(%r15), %rsi
movq %r12, %r13
movq %r12, %rdi
callq 0x28a9e
leaq 0x28(%rsp), %r13
addq $0x158, %r15            # imm = 0x158
movq %r13, %rdi
movq %r15, %rsi
callq 0x28a9e
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
callq 0x28b1e
movl $0x18, %r14d
movq 0x10(%rsp,%r14), %rdi
testq %rdi, %rdi
je 0x26b0e
callq 0x52a0
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x26aff
movzbl %bpl, %eax
movq 0x50(%rsp), %rcx
leaq (%rax,%rax,2), %r15
movq (%rcx,%r15,8), %rax
cmpq %rax, 0x8(%rcx,%r15,8)
je 0x26bee
leaq 0x10(%rsp), %r13
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq (%rax,%r12,8), %rax
cmpq %rbx, (%rax)
jne 0x26bc3
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r13, %rdi
leaq 0xfc7a(%rip), %rsi      # 0x367d8
leaq 0xfc7f(%rip), %rdx      # 0x367e4
callq 0xccac
movq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x182c0
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26b8e
callq 0x52a0
cmpq 0x40(%rsp), %r14
je 0x26ba5
leaq 0xfc76(%rip), %rdi      # 0x36812
movl %ebp, %esi
xorl %eax, %eax
callq 0x5050
leaq 0x1f36c(%rip), %rax     # 0x45f18
movq (%rax), %rax
movq 0x50(%rsp), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rcx,%r12,8), %rcx
movq %rax, 0x8(%rcx)
movb $0x1, %r14b
incl %ebp
movq 0x50(%rsp), %rcx
movq (%rcx,%r15,8), %rax
movq 0x8(%rcx,%r15,8), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
jbe 0x26bf1
movq %rbp, %r12
testb $0x1, %r14b
je 0x26b41
jmp 0x26bf1
xorl %r14d, %r14d
testb $0x1, %r14b
jne 0x26d8f
movq 0x50(%rsp), %rcx
movq (%rcx,%r15,8), %rax
cmpq %rax, 0x8(%rcx,%r15,8)
sete %cl
orb %r14b, %cl
testb $0x1, %cl
jne 0x26ccf
movl $0x1, %r12d
leaq 0x10(%rsp), %r13
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rax
cmpb $0x0, 0x14(%rax)
jne 0x26ca5
movq %rbx, (%rax)
movb $0x1, 0x14(%rax)
leaq 0x1f2db(%rip), %rcx     # 0x45f18
movq (%rcx), %rcx
movq %rcx, 0x8(%rax)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r13, %rdi
leaq 0xfb80(%rip), %rsi      # 0x367d8
leaq 0xfb85(%rip), %rdx      # 0x367e4
callq 0xccac
movq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x182c0
movq %rax, %rbp
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26c88
callq 0x52a0
movb $0x1, %r14b
cmpq 0x40(%rsp), %rbp
je 0x26ca5
leal -0x1(%r12), %esi
leaq 0xfb98(%rip), %rdi      # 0x36836
xorl %eax, %eax
callq 0x5050
movl %r12d, %ecx
movq 0x50(%rsp), %rdx
movq (%rdx,%r15,8), %rax
movq 0x8(%rdx,%r15,8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rdx
jbe 0x26ccf
incl %r12d
testb $0x1, %r14b
je 0x26c25
testb $0x1, %r14b
jne 0x26d8f
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, (%rdi)
leaq 0xfaeb(%rip), %rsi      # 0x367d8
leaq 0xfaf0(%rip), %rdx      # 0x367e4
callq 0xccac
leaq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x182c0
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26d1f
callq 0x52a0
cmpq 0x40(%rsp), %r14
je 0x26d32
leaq 0xfdc6(%rip), %rdi      # 0x36af3
callq 0x54a0
movq 0x50(%rsp), %rcx
movq (%rcx,%r15,8), %rax
movq 0x8(%rcx,%r15,8), %rcx
subq %rax, %rcx
je 0x26d74
sarq $0x3, %rcx
movq (%rax), %rdx
movq 0x8(%rdx), %rsi
xorl %edi, %edi
xorl %edx, %edx
movq (%rax,%rdi,8), %r8
movq 0x8(%r8), %r8
cmpq %rsi, %r8
cmovbq %r8, %rsi
cmovbq %rdi, %rdx
incq %rdi
movl %edi, %r8d
cmpq %r8, %rcx
ja 0x26d54
jmp 0x26d76
xorl %edx, %edx
movq (%rax,%rdx,8), %rax
movq %rbx, (%rax)
movb $0x1, 0x14(%rax)
leaq 0x1f190(%rip), %rcx     # 0x45f18
movq (%rcx), %rcx
movq %rcx, 0x8(%rax)
leaq 0x50(%rsp), %rdi
callq 0x28a5e
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x26e21
jmp 0x26e1c
jmp 0x26dd4
jmp 0x26ded
movq %rax, %rbx
movl $0x18, %r14d
movq 0x10(%rsp,%r14), %rdi
testq %rdi, %rdi
je 0x26dc8
callq 0x52a0
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x26db9
jmp 0x26e42
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26e42
callq 0x52a0
jmp 0x26e42
movq %rax, %rbx
jmp 0x26e42
movq %rax, %rbx
cmpq %r13, %r12
je 0x26e42
leaq 0x10(%rsp), %r14
movq -0x18(%r13), %rdi
testq %rdi, %rdi
je 0x26e0d
callq 0x52a0
addq $-0x18, %r13
cmpq %r14, %r13
jne 0x26dff
jmp 0x26e42
jmp 0x26e1c
jmp 0x26e21
movq %rax, %rbx
jmp 0x26e38
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26e38
callq 0x52a0
leaq 0x50(%rsp), %rdi
callq 0x28a5e
movq %rbx, %rdi
callq 0x55a0