// File: gvaumour[P]cache-simulator/src/HybridCache.cc
// Function: HybridCache::updateStatsDeallocate(CacheEntry*)
void
HybridCache::updateStatsDeallocate(CacheEntry* current)
{

	if(!current->isValid || m_isWarmup)
		return;
	
	if(simu_parameters.enablePCHistoryTracking && m_printStats){	
		ofstream file_history_cache("LLC_PC_History.out", std::ostream::app);
		file_history_cache << std::hex << current->address << "\t";
		for(unsigned i = 0; i < current->pc_history.size()-1; i++)
			file_history_cache << current->pc_history[i] << ",";
		file_history_cache << current->pc_history[current->pc_history.size()-1] << endl;
		file_history_cache << std::dec;
		file_history_cache.close();
	}
	
	if(stats_histo_ratioRW.count(current->nbWrite) == 0)
		stats_histo_ratioRW.insert(pair<int,int>(current->nbWrite , 0));
		
	stats_histo_ratioRW[current->nbWrite]++;
	
	if(current->justMigrate)
		stats_nbDeadMigration++;
	
	if(current->nbWrite == 0 && current->nbRead > 0){
		stats_nbROlines++;
		stats_nbROaccess+= current->nbRead; 
	}
	else if(current->nbWrite > 0 && current->nbRead == 0){
		stats_nbWOlines++;
		stats_nbWOaccess+= current->nbWrite; 	
	}
	else if( current->nbWrite == 0 && current->nbRead == 0){	
		stats_nbLostLine++;
	}
	else if( current->nbWrite == 1 && current->nbRead > 0){
		stats_nbAlmostROlines++;
		stats_nbAlmostROaccess+= current->nbWrite + current->nbRead; 		
	}
	else
	{
		stats_nbRWlines++;
		stats_nbRWaccess+= current->nbWrite + current->nbRead; 	
	}
}

// Assembly:
subq $0x298, %rsp            # imm = 0x298
movq %rdi, 0x290(%rsp)
movq %rsi, 0x288(%rsp)
movq 0x290(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x288(%rsp), %rax
testb $0x1, (%rax)
je 0x37fff
movq 0x40(%rsp), %rax
testb $0x1, 0x91(%rax)
je 0x38004
jmp 0x38442
leaq 0x5bfe5(%rip), %rax     # 0x93ff0
testb $0x1, 0x95(%rax)
je 0x381c4
movq 0x40(%rsp), %rax
testb $0x1, 0x90(%rax)
je 0x381c4
leaq 0x3a818(%rip), %rsi     # 0x72849
leaq 0x88(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movl $0x1, %edx
callq 0x53f0
movq 0x30(%rsp), %rdi
leaq -0x28854(%rip), %rsi    # 0xf800
callq 0x5160
movq %rax, 0x38(%rsp)
jmp 0x38060
movq 0x38(%rsp), %rdi
movq 0x288(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x50f0
movq %rax, 0x28(%rsp)
jmp 0x3807d
movq 0x28(%rsp), %rdi
leaq 0x3abda(%rip), %rsi     # 0x72c63
callq 0x5380
jmp 0x38090
movl $0x0, 0x78(%rsp)
movl 0x78(%rsp), %eax
movq %rax, 0x20(%rsp)
movq 0x288(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0xfa40
movq %rax, %rcx
movq 0x20(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x3813f
movq 0x288(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
movl 0x78(%rsp), %eax
movl %eax, %esi
callq 0xfa20
movq (%rax), %rsi
leaq 0x88(%rsp), %rdi
callq 0x50f0
movq %rax, 0x18(%rsp)
jmp 0x380f7
movq 0x18(%rsp), %rdi
leaq 0x38f3f(%rip), %rsi     # 0x71042
callq 0x5380
jmp 0x3810a
jmp 0x3810c
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x38098
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x5770
jmp 0x3844a
movq 0x288(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
movq %rdi, 0x8(%rsp)
callq 0xfa40
movq 0x8(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0xfa20
movq (%rax), %rsi
leaq 0x88(%rsp), %rdi
callq 0x50f0
movq %rax, 0x10(%rsp)
jmp 0x3817f
movq 0x10(%rsp), %rdi
movq 0x5ae2d(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x38192
leaq -0x28979(%rip), %rsi    # 0xf820
leaq 0x88(%rsp), %rdi
callq 0x5160
jmp 0x381a8
leaq 0x88(%rsp), %rdi
callq 0x5550
jmp 0x381b7
leaq 0x88(%rsp), %rdi
callq 0x5770
movq 0x40(%rsp), %rdi
addq $0x1f0, %rdi            # imm = 0x1F0
movq 0x288(%rsp), %rax
movslq 0x11c(%rax), %rax
movq %rax, 0x70(%rsp)
leaq 0x70(%rsp), %rsi
callq 0x3dc90
cmpq $0x0, %rax
jne 0x38240
movq 0x40(%rsp), %rax
addq $0x1f0, %rax            # imm = 0x1F0
movq %rax, (%rsp)
movq 0x288(%rsp), %rsi
addq $0x11c, %rsi            # imm = 0x11C
movl $0x0, 0x64(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x64(%rsp), %rdx
callq 0x3dd40
movq (%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3dcf0
movq %rax, 0x50(%rsp)
movb %dl, 0x58(%rsp)
movq 0x40(%rsp), %rdi
addq $0x1f0, %rdi            # imm = 0x1F0
movq 0x288(%rsp), %rax
movslq 0x11c(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x48(%rsp), %rsi
callq 0x3dd70
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x288(%rsp), %rax
testb $0x1, 0x14c(%rax)
je 0x3829c
movq 0x40(%rsp), %rax
movq 0x220(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x220(%rax)
movq 0x288(%rsp), %rax
cmpl $0x0, 0x11c(%rax)
jne 0x382f7
movq 0x288(%rsp), %rax
cmpl $0x0, 0x120(%rax)
jle 0x382f7
movq 0x40(%rsp), %rax
movq 0x1b0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x1b0(%rax)
movq 0x288(%rsp), %rcx
movslq 0x120(%rcx), %rcx
addq 0x1b8(%rax), %rcx
movq %rcx, 0x1b8(%rax)
jmp 0x38442
movq 0x288(%rsp), %rax
cmpl $0x0, 0x11c(%rax)
jle 0x38352
movq 0x288(%rsp), %rax
cmpl $0x0, 0x120(%rax)
jne 0x38352
movq 0x40(%rsp), %rax
movq 0x1d0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x1d0(%rax)
movq 0x288(%rsp), %rcx
movslq 0x11c(%rcx), %rcx
addq 0x1d8(%rax), %rcx
movq %rcx, 0x1d8(%rax)
jmp 0x38440
movq 0x288(%rsp), %rax
cmpl $0x0, 0x11c(%rax)
jne 0x38390
movq 0x288(%rsp), %rax
cmpl $0x0, 0x120(%rax)
jne 0x38390
movq 0x40(%rsp), %rax
movq 0x1a8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x1a8(%rax)
jmp 0x3843e
movq 0x288(%rsp), %rax
cmpl $0x1, 0x11c(%rax)
jne 0x383f8
movq 0x288(%rsp), %rax
cmpl $0x0, 0x120(%rax)
jle 0x383f8
movq 0x40(%rsp), %rax
movq 0x1e0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x1e0(%rax)
movq 0x288(%rsp), %rcx
movl 0x11c(%rcx), %ecx
movq 0x288(%rsp), %rdx
addl 0x120(%rdx), %ecx
movslq %ecx, %rcx
addq 0x1e8(%rax), %rcx
movq %rcx, 0x1e8(%rax)
jmp 0x3843c
movq 0x40(%rsp), %rax
movq 0x1c0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x1c0(%rax)
movq 0x288(%rsp), %rcx
movl 0x11c(%rcx), %ecx
movq 0x288(%rsp), %rdx
addl 0x120(%rdx), %ecx
movslq %ecx, %rcx
addq 0x1c8(%rax), %rcx
movq %rcx, 0x1c8(%rax)
jmp 0x3843e
jmp 0x38440
jmp 0x38442
addq $0x298, %rsp            # imm = 0x298
retq
movq 0x80(%rsp), %rdi
callq 0x5690
nopw (%rax,%rax)