// File: gvaumour[P]cache-simulator/src/Cerebron.cc
// Function: CerebronPredictor::updatePolicy(unsigned long, unsigned long, bool, Access, bool)
void
CerebronPredictor::updatePolicy(uint64_t set, uint64_t index, bool inNVM, Access element, bool isWBrequest)
{
	CacheEntry *entry = get_entry(set , index , inNVM);
	RD_TYPE rd = classifyRD( set , index , inNVM );
	stats_access_class[rd][element.isWrite()]++;
	
	entry->policyInfo = m_cpt++;
	if ( element.isDemandAccess())
		update_globalPChistory(element.m_pc);

	entry->cost_value += m_costAccess[element.isWrite()][rd];
	if(entry->isLearning_policy)
	{
		recordAccess( entry , element.block_addr, entry->missPC, set, element.isWrite() , inNVM, index, rd , true);
	}
	if(entry->isLearning_weight)
	{
		if(simu_parameters.Cerebron_fastlearning)
			doLearning(entry, inNVM);
	}

	if(miss_counter < 0)
		miss_counter = 0;

	stats_update++;
	stats_nbHits++;
	miss_counter--;

	if(simu_parameters.Cerebron_enableMigration)
	{
		assert(entry->isValid);
		entry = checkLazyMigration(entry , set , inNVM , index, element.isWrite());		
	}

	reportAccess( element, entry , set , entry->isNVM, string("UPDATE"), string(str_RD_status[rd]) );

	Predictor::updatePolicy(set , index , inNVM , element , isWBrequest);
}

// Assembly:
pushq %rbx
subq $0x1e0, %rsp            # imm = 0x1E0
movb %r8b, %al
leaq 0x1f0(%rsp), %r8
movq %r8, 0xd0(%rsp)
movq %rdi, 0x1d8(%rsp)
movq %rsi, 0x1d0(%rsp)
movq %rdx, 0x1c8(%rsp)
andb $0x1, %cl
movb %cl, 0x1c7(%rsp)
andb $0x1, %al
movb %al, 0x1c6(%rsp)
movq 0x1d8(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
movq 0x1d0(%rsp), %rsi
movq 0x1c8(%rsp), %rdx
movb 0x1c7(%rsp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x8c90
movq 0xc8(%rsp), %rdi
movq %rax, 0x1b8(%rsp)
movq 0x1d0(%rsp), %rax
movl %eax, %esi
movq 0x1c8(%rsp), %rax
movl %eax, %edx
movb 0x1c7(%rsp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0xaa40
movq 0xc8(%rsp), %rdi
movl %eax, 0x1b4(%rsp)
addq $0x4a8, %rdi            # imm = 0x4A8
movl 0x1b4(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq 0xd0(%rsp), %rdi
movq %rax, 0xc0(%rsp)
callq 0xf7c0
movq 0xc0(%rsp), %rdi
andb $0x1, %al
movzbl %al, %eax
movl %eax, %esi
callq 0xef90
movq 0xc8(%rsp), %rcx
movq 0xd0(%rsp), %rdi
movl (%rax), %edx
addl $0x1, %edx
movl %edx, (%rax)
movq 0x2f8(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x2f8(%rcx)
movl %eax, %ecx
movq 0x1b8(%rsp), %rax
movl %ecx, 0x38(%rax)
callq 0xf950
testb $0x1, %al
jne 0xa4fd
jmp 0xa516
movq 0xc8(%rsp), %rdi
movq 0xd0(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x573a0
movq 0xd0(%rsp), %rdi
movq 0xc8(%rsp), %rax
addq $0x2d8, %rax            # imm = 0x2D8
movq %rax, 0xb8(%rsp)
callq 0xf7c0
movq 0xb8(%rsp), %rdi
andb $0x1, %al
movzbl %al, %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl 0x1b4(%rsp), %eax
movl %eax, %esi
callq 0xef90
cvtsi2sdl (%rax), %xmm0
movq 0x1b8(%rsp), %rax
addsd 0x130(%rax), %xmm0
movsd %xmm0, 0x130(%rax)
movq 0x1b8(%rsp), %rax
testb $0x1, 0x149(%rax)
je 0xa648
movq 0xd0(%rsp), %rdi
movq 0x1b8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x30(%rdi), %rax
movq %rax, 0xa0(%rsp)
movq 0x1b8(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0x1d0(%rsp), %rax
movl %eax, 0xb4(%rsp)
callq 0xf7c0
movq 0xc8(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
movl 0xb4(%rsp), %r8d
movb 0x1c7(%rsp), %r10b
movq 0x1c8(%rsp), %r9
movl %r9d, %r11d
movl 0x1b4(%rsp), %ebx
movq %rsp, %r9
movl %ebx, 0x10(%r9)
movl %r11d, 0x8(%r9)
movzbl %r10b, %r10d
andl $0x1, %r10d
movl %r10d, (%r9)
movl $0x1, 0x18(%r9)
movzbl %al, %r9d
andl $0x1, %r9d
callq 0x8d20
movq 0x1b8(%rsp), %rax
testb $0x1, 0x14a(%rax)
je 0xa68c
leaq 0x89990(%rip), %rax     # 0x93ff0
testb $0x1, 0x225(%rax)
je 0xa68a
movq 0xc8(%rsp), %rdi
movq 0x1b8(%rsp), %rsi
movb 0x1c7(%rsp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xac60
jmp 0xa68c
leaq 0x89bad(%rip), %rax     # 0x94240
cmpl $0x0, (%rax)
jge 0xa6a5
leaq 0x89ba1(%rip), %rax     # 0x94240
movl $0x0, (%rax)
movq 0xc8(%rsp), %rax
movq 0x410(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x410(%rax)
movq 0x3d8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x3d8(%rax)
leaq 0x89b68(%rip), %rax     # 0x94240
movl (%rax), %ecx
addl $-0x1, %ecx
leaq 0x89b5c(%rip), %rax     # 0x94240
movl %ecx, (%rax)
leaq 0x89903(%rip), %rax     # 0x93ff0
testb $0x1, 0x223(%rax)
je 0xa7af
movq 0x1b8(%rsp), %rax
testb $0x1, (%rax)
je 0xa709
jmp 0xa728
leaq 0x683f0(%rip), %rdi     # 0x72b00
leaq 0x66978(%rip), %rsi     # 0x7108f
movl $0xe4, %edx
leaq 0x66a22(%rip), %rcx     # 0x71145
callq 0x5260
movq 0xd0(%rsp), %rdi
movq 0x1b8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x1d0(%rsp), %rax
movq %rax, 0x88(%rsp)
movb 0x1c7(%rsp), %al
movb %al, 0x7f(%rsp)
movq 0x1c8(%rsp), %rax
movq %rax, 0x90(%rsp)
callq 0xf7c0
movb 0x7f(%rsp), %cl
movq 0xc8(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0x90(%rsp), %r8
movzbl %cl, %ecx
andl $0x1, %ecx
movzbl %al, %r9d
andl $0x1, %r9d
callq 0xb1d0
movq %rax, 0x1b8(%rsp)
movq 0xd0(%rsp), %rax
movq 0x30(%rax), %rcx
movq %rcx, 0x1a0(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movaps %xmm2, 0x190(%rsp)
movaps %xmm1, 0x180(%rsp)
movaps %xmm0, 0x170(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0x1d0(%rsp), %ecx
movl %ecx, 0x68(%rsp)
movb 0x40(%rax), %al
movb %al, 0x6f(%rsp)
leaq 0x14f(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x56a0
movq 0x70(%rsp), %rdx
leaq 0x66977(%rip), %rsi     # 0x7119a
leaq 0x150(%rsp), %rdi
callq 0x5530
jmp 0xa832
movl 0x1b4(%rsp), %eax
movl %eax, %ecx
leaq 0x88c8e(%rip), %rax     # 0x934d0
movq (%rax,%rcx,8), %rax
movq %rax, 0x50(%rsp)
leaq 0x117(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x56a0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0x118(%rsp), %rdi
callq 0x5530
jmp 0xa876
movl 0x68(%rsp), %edx
movq 0x60(%rsp), %rsi
movq 0xc8(%rsp), %rdi
movb 0x6f(%rsp), %al
movq 0x1a0(%rsp), %r8
movq %rsp, %rcx
movq %r8, 0x30(%rcx)
movaps 0x170(%rsp), %xmm0
movaps 0x180(%rsp), %xmm1
movaps 0x190(%rsp), %xmm2
movups %xmm2, 0x20(%rcx)
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
movzbl %al, %ecx
andl $0x1, %ecx
leaq 0x150(%rsp), %r8
leaq 0x118(%rsp), %r9
callq 0x91d0
jmp 0xa8da
leaq 0x118(%rsp), %rdi
callq 0x5768
leaq 0x117(%rsp), %rdi
callq 0x53e0
leaq 0x150(%rsp), %rdi
callq 0x5768
leaq 0x14f(%rsp), %rdi
callq 0x53e0
movq 0xd0(%rsp), %rsi
movq 0x1d0(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x1c8(%rsp), %rax
movq %rax, 0x48(%rsp)
movb 0x1c7(%rsp), %al
movb %al, 0x3f(%rsp)
leaq 0xd8(%rsp), %rdi
movl $0x38, %edx
callq 0x52f0
movb 0x3f(%rsp), %cl
movq 0xc8(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movb 0x1c6(%rsp), %al
movq 0x108(%rsp), %r9
movq %rsp, %r8
movq %r9, 0x30(%r8)
movups 0xd8(%rsp), %xmm0
movups 0xe8(%rsp), %xmm1
movups 0xf8(%rsp), %xmm2
movups %xmm2, 0x20(%r8)
movups %xmm1, 0x10(%r8)
movups %xmm0, (%r8)
movzbl %cl, %ecx
andl $0x1, %ecx
movzbl %al, %r8d
andl $0x1, %r8d
callq 0x56ed0
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbx
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0xaa22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0xaa08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x5768
leaq 0x117(%rsp), %rdi
callq 0x53e0
leaq 0x150(%rsp), %rdi
callq 0x5768
leaq 0x14f(%rsp), %rdi
callq 0x53e0
movq 0x140(%rsp), %rdi
callq 0x5690
nopl (%rax)