// File: /workspace/github_cpp_makefile_star2_O3/gvaumour[P]cache-simulator/src/DBAMBPredictor.cc
// Function: DBAMBPredictor::updateWindow(DHPEntry*)
void
DBAMBPredictor::updateWindow(DHPEntry* rap_current)
{

	if(rap_current->cptWindow < simu_parameters.window_size)
		rap_current->cptWindow++;
	else
	{
		RW_TYPE old_rw = rap_current->state_rw;
		RD_TYPE old_rd = rap_current->state_rd;
		allocDecision old_alloc = rap_current->des;
		
		determineStatus(rap_current);
		
		dataset_file << "Window:Dataset n°" << rap_current->id << ": NewWindow [" << str_RW_status[rap_current->state_rw] << "," \
		  	     << str_RD_status[rap_current->state_rd] << "]"  << endl;	
	

	
		if(!m_isWarmup)
			stats_ClassErrors[old_rd + NUM_RD_TYPE*old_rw][rap_current->state_rd + NUM_RD_TYPE*rap_current->state_rw]++;

		if(old_rd != rap_current->state_rd || old_rw != rap_current->state_rw)
		{
			HistoEntry current = {rap_current->state_rw , rap_current->state_rd, rap_current->nbKeepState};

			if(!m_isWarmup)
				rap_current->stats_history.push_back(current);

			rap_current->nbSwitchState++;
			rap_current->nbKeepState = 0;					

			rap_current->des = convertState(rap_current);
			if(old_alloc == ALLOCATE_PREEMPTIVELY &&  simu_parameters.writeDatasetFile)
			{	
				firstAlloc_dataset_file << std::hex << "0x" << rap_current->signature << std::dec << "\t" << rap_current->des << endl;	
			}
		}
		else{
			rap_current->nbKeepState++;
			rap_current->nbKeepCurrentState++;			
		}

		/* Reset the window */			
		rap_current->rd_history.clear();
		rap_current->rw_history.clear();
		rap_current->cptWindow = 0;		
	}	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl 0x84(%rsi), %eax
leaq 0x37206(%rip), %rcx     # 0x45f50
cmpl 0xa0(%rcx), %eax
jge 0xed59
incl %eax
jmp 0xf03e
movq %rdi, %r14
movl 0x28(%rbx), %eax
movl %eax, 0x8(%rsp)
movl 0x98(%rbx), %ebp
movl 0x9c(%rbx), %r13d
movq %rbx, %rsi
callq 0x104b2
leaq 0x368e9(%rip), %r15     # 0x45668
leaq 0x25e3d(%rip), %rsi     # 0x34bc3
movl $0x12, %edx
movq %r15, %rdi
callq 0x5360
movl 0x18(%rbx), %esi
movq %r15, %rdi
callq 0x5580
movq %rax, %r15
leaq 0x25e2e(%rip), %rsi     # 0x34bd6
movl $0xd, %edx
movq %rax, %rdi
callq 0x5360
movl 0x98(%rbx), %eax
leaq 0x3663e(%rip), %rcx     # 0x45400
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0xede3
movq %r12, %rdi
callq 0x5160
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x5360
jmp 0xedfb
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x5560
leaq 0x25214(%rip), %rsi     # 0x34016
movl $0x1, %edx
movq %r15, %rdi
callq 0x5360
movl 0x9c(%rbx), %eax
leaq 0x36614(%rip), %rcx     # 0x45430
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0xee3d
movq %r12, %rdi
callq 0x5160
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x5360
jmp 0xee57
movq (%r15), %rax
movq -0x18(%rax), %rax
movq %r15, %rdi
addq %rax, %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x5560
leaq 0x280ec(%rip), %rsi     # 0x36f4a
movl $0x1, %edx
movq %r15, %rdi
callq 0x5360
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x52c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5200
movb 0x81(%r14), %al
movl 0x98(%rbx), %edx
movl 0x9c(%rbx), %ecx
testb %al, %al
jne 0xeed0
leal (%rbp,%rbp,2), %esi
addl %r13d, %esi
movslq %esi, %rsi
movq 0x3a0(%r14), %rdi
leaq (%rsi,%rsi,2), %rsi
leal (%rdx,%rdx,2), %r8d
addl %ecx, %r8d
movslq %r8d, %r8
movq (%rdi,%rsi,8), %rsi
incl (%rsi,%r8,4)
xorl %ecx, %r13d
xorl %edx, %ebp
orl %r13d, %ebp
jne 0xeeeb
incl 0x8c(%rbx)
incl 0x94(%rbx)
jmp 0xf01f
movl %edx, 0xc(%rsp)
movl %ecx, 0x10(%rsp)
movl 0x8c(%rbx), %ecx
movl %ecx, 0x14(%rsp)
testb %al, %al
jne 0xef3b
movq 0xa8(%rbx), %rsi
cmpq 0xb0(%rbx), %rsi
je 0xef2a
movl 0x14(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0xc(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0xa8(%rbx)
jmp 0xef3b
leaq 0xa0(%rbx), %rdi
leaq 0xc(%rsp), %rdx
callq 0x12cc2
incl 0x90(%rbx)
movl $0x0, 0x8c(%rbx)
movq %rbx, %rsi
callq 0x10648
movl %eax, 0x28(%rbx)
cmpl $0x3, 0x8(%rsp)
jne 0xf01f
leaq 0x36fe8(%rip), %rax     # 0x45f50
cmpb $0x1, 0x15a(%rax)
jne 0xf01f
leaq 0x368fc(%rip), %r14     # 0x45878
leaq 0x368e5(%rip), %rax     # 0x45868
movq 0x368ee(%rip), %rcx     # 0x45878
movq -0x18(%rcx), %rcx
movl 0x28(%rcx,%rax), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x28(%rcx,%rax)
leaq 0x25169(%rip), %rsi     # 0x3410c
movl $0x2, %edx
movq %r14, %rdi
callq 0x5360
movq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x51f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%r14,%rax)
leaq 0x26c96(%rip), %rsi     # 0x35c73
movl $0x1, %edx
movq %r14, %rdi
callq 0x5360
movl 0x28(%rbx), %esi
movq %r14, %rdi
callq 0x5580
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x52c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5200
movq 0x40(%rbx), %rax
cmpq %rax, 0x48(%rbx)
je 0xf02d
movq %rax, 0x48(%rbx)
movq 0x58(%rbx), %rax
movq %rax, 0x68(%rbx)
movl $0x0, 0x70(%rbx)
xorl %eax, %eax
movl %eax, 0x84(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop