// File: /workspace/github_cpp_makefile_star2_O3/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 0x1f813(%rip), %rax     # 0x45f50
cmpb $0x1, 0x88(%rax)
jne 0x26b49
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r13
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1006b(%rip), %rsi     # 0x367d0
leaq 0x10070(%rip), %rdx     # 0x367dc
leaq 0x10(%rsp), %rdi
callq 0xcc6c
leaq 0x8(%r14), %rdi
leaq 0x10(%rsp), %rsi
movq %rdi, 0x48(%rsp)
callq 0x1800c
movq %rax, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x267a0
callq 0x52b0
addq $0x10, %r14
movq %r14, 0x40(%rsp)
cmpq %r14, %r12
je 0x267bf
leaq 0x10028(%rip), %rdi     # 0x367dd
movq %rbx, %rsi
xorl %eax, %eax
callq 0x5050
movq 0x198(%r13), %rax
testq %rax, %rax
je 0x267f8
leaq 0x190(%r13), %rdx
movq %rdx, %rcx
xorl %esi, %esi
cmpq %rbx, 0x20(%rax)
setb %sil
cmovaeq %rax, %rcx
movq 0x10(%rax,%rsi,8), %rax
testq %rax, %rax
jne 0x267d5
cmpq %rdx, %rcx
je 0x267f8
cmpq %rbx, 0x20(%rcx)
jbe 0x26876
leaq 0x188(%r13), %rdi
leaq 0x10(%rsp), %r14
movq %rbx, (%r14)
leaq 0x1f70a(%rip), %rax     # 0x45f18
movq (%rax), %rax
movq %rax, 0x8(%r14)
movq %r14, %rsi
callq 0x28d86
leaq 0x20(%rsp), %rax
movq %rax, (%r14)
leaq 0xffa4(%rip), %rsi      # 0x367d0
leaq 0xffa9(%rip), %rdx      # 0x367dc
leaq 0x10(%rsp), %rdi
callq 0xcc6c
leaq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x1800c
movq %rax, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26863
callq 0x52b0
cmpq 0x40(%rsp), %r12
je 0x26876
leaq 0x10261(%rip), %rdi     # 0x36ad2
callq 0x54a0
leaq 0x170(%r13), %rsi
leaq 0x10(%rsp), %rdi
callq 0x28764
leaq 0x28(%rsp), %rdi
addq $0x158, %r13            # imm = 0x158
movq %r13, %rsi
callq 0x28764
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
callq 0x287e4
movl $0x18, %r14d
movq 0x10(%rsp,%r14), %rdi
testq %rdi, %rdi
je 0x268c9
callq 0x52b0
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x268ba
movzbl %bpl, %eax
movq 0x50(%rsp), %rcx
leaq (%rax,%rax,2), %r12
movq (%rcx,%r12,8), %rax
movq 0x8(%rcx,%r12,8), %rdx
cmpq %rax, %rdx
je 0x269b2
movq 0x40(%rsp), %r13
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq (%rax,%r15,8), %rdx
cmpq %rbx, (%rdx)
jne 0x26984
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0xfeaf(%rip), %rsi      # 0x367d0
leaq 0xfeb4(%rip), %rdx      # 0x367dc
callq 0xcc6c
movq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x1800c
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26951
callq 0x52b0
cmpq %r13, %r14
je 0x26966
leaq 0xfead(%rip), %rdi      # 0x3680a
movl %ebp, %esi
xorl %eax, %eax
callq 0x5050
leaq 0x1f5ab(%rip), %rax     # 0x45f18
movq (%rax), %rdx
movq 0x50(%rsp), %rcx
movq (%rcx,%r12,8), %rax
movq (%rax,%r15,8), %rsi
movq %rdx, 0x8(%rsi)
movb $0x1, %r14b
incl %ebp
movq 0x8(%rcx,%r12,8), %rdx
movq %rdx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
cmpq %rbp, %rsi
jbe 0x269a7
movq %rbp, %r15
testb $0x1, %r14b
je 0x268ff
testb $0x1, %r14b
je 0x269b5
jmp 0x26b3f
xorl %r14d, %r14d
cmpq %rax, %rdx
sete %cl
orb %r14b, %cl
testb $0x1, %cl
jne 0x26a83
movl $0x1, %r13d
leaq 0x10(%rsp), %rbp
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rax
cmpb $0x0, 0x14(%rax)
jne 0x26a59
movq %rbx, (%rax)
movb $0x1, 0x14(%rax)
leaq 0x1f52c(%rip), %rcx     # 0x45f18
movq (%rcx), %rcx
movq %rcx, 0x8(%rax)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
leaq 0xfdc9(%rip), %rsi      # 0x367d0
leaq 0xfdce(%rip), %rdx      # 0x367dc
callq 0xcc6c
movq 0x48(%rsp), %rdi
movq %rbp, %r15
movq %rbp, %rsi
callq 0x1800c
movq %rax, %rbp
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26a3a
callq 0x52b0
movb $0x1, %r14b
cmpq 0x40(%rsp), %rbp
je 0x26a56
leal -0x1(%r13), %esi
leaq 0xfddf(%rip), %rdi      # 0x3682e
xorl %eax, %eax
callq 0x5050
movq %r15, %rbp
movl %r13d, %ecx
movq 0x50(%rsp), %rdx
movq (%rdx,%r12,8), %rax
movq 0x8(%rdx,%r12,8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rdx
jbe 0x26a83
incl %r13d
testb $0x1, %r14b
je 0x269d4
testb $0x1, %r14b
jne 0x26b3f
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, (%rdi)
leaq 0xfd2f(%rip), %rsi      # 0x367d0
leaq 0xfd34(%rip), %rdx      # 0x367dc
callq 0xcc6c
leaq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x1800c
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26ad3
callq 0x52b0
cmpq 0x40(%rsp), %r14
je 0x26ae6
leaq 0x1000a(%rip), %rdi     # 0x36aeb
callq 0x54a0
movq 0x50(%rsp), %rcx
movq (%rcx,%r12,8), %rax
movq 0x8(%rcx,%r12,8), %rcx
movq (%rax), %rdx
subq %rax, %rcx
je 0x26b2a
sarq $0x3, %rcx
movq 0x8(%rdx), %rdx
xorl %esi, %esi
xorl %edi, %edi
movq (%rax,%rsi,8), %r8
movq 0x8(%r8), %r8
cmpq %rdx, %r8
cmovbq %r8, %rdx
cmovbq %rsi, %rdi
incq %rsi
movl %esi, %r8d
cmpq %r8, %rcx
ja 0x26b08
movq (%rax,%rdi,8), %rdx
movq %rbx, (%rdx)
movb $0x1, 0x14(%rdx)
leaq 0x1f3e0(%rip), %rax     # 0x45f18
movq (%rax), %rax
movq %rax, 0x8(%rdx)
leaq 0x50(%rsp), %rdi
callq 0x2871e
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x26bbc
jmp 0x26bb7
jmp 0x26b95
jmp 0x26bae
movq %rax, %rbx
movl $0x18, %r14d
movq 0x10(%rsp,%r14), %rdi
testq %rdi, %rdi
je 0x26b78
callq 0x52b0
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x26b69
jmp 0x26bdd
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x26ba7
jmp 0x26bdd
jmp 0x26bae
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26bdd
callq 0x52b0
jmp 0x26bdd
movq %rax, %rbx
jmp 0x26bdd
jmp 0x26bb7
jmp 0x26bbc
movq %rax, %rbx
jmp 0x26bd3
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x26bd3
callq 0x52b0
leaq 0x50(%rsp), %rdi
callq 0x2871e
movq %rbx, %rdi
callq 0x55a0
nop