// File: gvaumour[P]cache-simulator/src/HybridCache.cc
// Function: HybridCache::receiveInvalidation(unsigned long)
bool
HybridCache::receiveInvalidation(uint64_t block_addr)
{
	entete_debug();
	DPRINTF(DebugCache , "HERE Receive Invalidation for the block [%#lx] by the LLC\n" , block_addr);

	map<uint64_t,HybridLocation>::iterator p = m_tag_index.find(block_addr);
	
	if (p != m_tag_index.end()){

	
		DPRINTF(DebugCache , "Find block [%#lx]\n" , block_addr);

		int id_set = blockAddressToCacheSet(block_addr);
		HybridLocation loc = p->second;
		CacheEntry* entry = NULL;

		if(loc.m_inNVM)
			entry = m_tableNVM[id_set][loc.m_way];
		else 
			entry = m_tableSRAM[id_set][loc.m_way];	
	
		entete_debug();
		DPRINTF(DebugCache , "Receive Invalidation for the block [%#lx] by the LLC\n" , entry->address);

		entry->isValid = false;
		return entry->isDirty;
	}
	else{
		DPRINTF(DebugCache , "Didn't find block [%#lx]\n" , block_addr);
		return false;
	
	}
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq 0x128(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x38560
leaq 0xff(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x56a0
movq 0x48(%rsp), %rdx
leaq 0x37717(%rip), %rsi     # 0x7286e
leaq 0x100(%rsp), %rdi
callq 0x5530
jmp 0x3b166
leaq 0x58e83(%rip), %rdi     # 0x93ff0
addq $0x8, %rdi
leaq 0x100(%rsp), %rsi
callq 0x33a00
movq %rax, 0x38(%rsp)
jmp 0x3b185
leaq 0x100(%rsp), %rdi
callq 0x5768
leaq 0xff(%rsp), %rdi
callq 0x53e0
movq 0x38(%rsp), %rax
cmpq $0x0, %rax
je 0x3b20b
movq 0x120(%rsp), %rsi
leaq 0x379dd(%rip), %rdi     # 0x72b96
movb $0x0, %al
callq 0x5060
jmp 0x3b20b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0x3b1f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x5768
leaq 0xff(%rsp), %rdi
callq 0x53e0
jmp 0x3b5a9
movq 0x40(%rsp), %rdi
addq $0x38, %rdi
leaq 0x120(%rsp), %rsi
callq 0x3d9b0
movq 0x40(%rsp), %rdi
movq %rax, 0xe0(%rsp)
addq $0x38, %rdi
callq 0x3db60
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x3db40
testb $0x1, %al
jne 0x3b25d
jmp 0x3b4d6
leaq 0xb7(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x56a0
movq 0x30(%rsp), %rdx
leaq 0x375f3(%rip), %rsi     # 0x7286e
leaq 0xb8(%rsp), %rdi
callq 0x5530
jmp 0x3b28a
leaq 0x58d5f(%rip), %rdi     # 0x93ff0
addq $0x8, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x33a00
movq %rax, 0x28(%rsp)
jmp 0x3b2a9
leaq 0xb8(%rsp), %rdi
callq 0x5768
leaq 0xb7(%rsp), %rdi
callq 0x53e0
movq 0x28(%rsp), %rax
cmpq $0x0, %rax
je 0x3b32f
movq 0x120(%rsp), %rsi
leaq 0x378f4(%rip), %rdi     # 0x72bd1
movb $0x0, %al
callq 0x5060
jmp 0x3b32f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0x3b31d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x5768
leaq 0xb7(%rsp), %rdi
callq 0x53e0
jmp 0x3b5a9
movq 0x40(%rsp), %rdi
movq 0x120(%rsp), %rsi
callq 0x3ab60
movl %eax, 0xb0(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x3d9e0
movq 0x8(%rax), %rax
movq %rax, 0xa8(%rsp)
movq $0x0, 0xa0(%rsp)
testb $0x1, 0xac(%rsp)
je 0x3b3aa
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
movslq 0xb0(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movslq 0xa8(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
jmp 0x3b3db
movq 0x40(%rsp), %rdi
addq $0x20, %rdi
movslq 0xb0(%rsp), %rsi
callq 0xf9a0
movq %rax, %rdi
movslq 0xa8(%rsp), %rsi
callq 0xf9c0
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0x40(%rsp), %rdi
callq 0x38560
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x56a0
movq 0x20(%rsp), %rdx
leaq 0x3746e(%rip), %rsi     # 0x7286e
leaq 0x80(%rsp), %rdi
callq 0x5530
jmp 0x3b40f
leaq 0x58bda(%rip), %rdi     # 0x93ff0
addq $0x8, %rdi
leaq 0x80(%rsp), %rsi
callq 0x33a00
movq %rax, 0x18(%rsp)
jmp 0x3b42e
leaq 0x80(%rsp), %rdi
callq 0x5768
leaq 0x7f(%rsp), %rdi
callq 0x53e0
movq 0x18(%rsp), %rax
cmpq $0x0, %rax
je 0x3b4b2
movq 0xa0(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x37738(%rip), %rdi     # 0x72b9b
movb $0x0, %al
callq 0x5060
jmp 0x3b4b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0x3b4a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x5768
leaq 0x7f(%rsp), %rdi
callq 0x53e0
jmp 0x3b5a9
movq 0xa0(%rsp), %rax
movb $0x0, (%rax)
movq 0xa0(%rsp), %rax
movb 0x1(%rax), %al
andb $0x1, %al
movb %al, 0x137(%rsp)
jmp 0x3b598
leaq 0x57(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x56a0
movq 0x10(%rsp), %rdx
leaq 0x3737d(%rip), %rsi     # 0x7286e
leaq 0x58(%rsp), %rdi
callq 0x5530
jmp 0x3b4fd
leaq 0x58aec(%rip), %rdi     # 0x93ff0
addq $0x8, %rdi
leaq 0x58(%rsp), %rsi
callq 0x33a00
movq %rax, 0x8(%rsp)
jmp 0x3b519
leaq 0x58(%rsp), %rdi
callq 0x5768
leaq 0x57(%rsp), %rdi
callq 0x53e0
movq 0x8(%rsp), %rax
cmpq $0x0, %rax
je 0x3b590
movq 0x120(%rsp), %rsi
leaq 0x3769d(%rip), %rdi     # 0x72be4
movb $0x0, %al
callq 0x5060
jmp 0x3b590
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0x3b584
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x5768
leaq 0x57(%rsp), %rdi
callq 0x53e0
jmp 0x3b5a9
movb $0x0, 0x137(%rsp)
movb 0x137(%rsp), %al
andb $0x1, %al
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xf0(%rsp), %rdi
callq 0x5690
nopw %cs:(%rax,%rax)