// File: gvaumour[P]cache-simulator/src/DBAMBPredictor.cc
// Function: DBAMBPredictor::reportAccess(DHPEntry*, Access, CacheEntry*, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void
DBAMBPredictor::reportAccess(DHPEntry* rap_current, Access element, CacheEntry* current, bool inNVM, string entete, string reuse_class)
{
	string cl_location = inNVM ? "NVM" : "SRAM";
	string is_learning = current->isLearning ? "Learning" : "Regular";
	string access_type = element.isWrite() ? "WRITE" : "READ";
	
	string is_error= "";
	if(element.isSRAMerror)
		is_error = ", is an SRAM error";
	
	if(simu_parameters.printDebug)
	{
		dataset_file << entete << ":Dataset n°" << rap_current->id << ": [" \
		<< str_RW_status[rap_current->state_rw] << ","  << str_RD_status[rap_current->state_rd] \
		<< "] = " << str_allocDecision[rap_current->des] << "," \
		<< access_type << " on " << is_learning << " Cl 0x" << std::hex << current->address \
		<< std::dec << " allocated in " << cl_location<< ", Reuse=" << reuse_class \
		<< " , " << is_error << ", " << endl;	
	}
	
	
	if(inNVM && element.isWrite()){
		if(rap_current->des == ALLOCATE_IN_NVM)
			stats_error_wrongpolicy++;
		else if(rap_current->des == ALLOCATE_PREEMPTIVELY)
			stats_error_learning++;
		else if(rap_current->des == ALLOCATE_IN_SRAM && inNVM)
			stats_error_wrongallocation++;	
	}
	if(element.isSRAMerror){
		if(rap_current->des == ALLOCATE_IN_SRAM)
			stats_error_SRAMwrongpolicy++;
		else if(rap_current->des == ALLOCATE_PREEMPTIVELY)
			stats_error_SRAMlearning++;
		else if(rap_current->des == ALLOCATE_IN_NVM && !inNVM)
			stats_error_SRAMwrongallocation++;
	}
	if(simu_parameters.printDebug)
	{
		if(inNVM && element.isWrite())
		{
			dataset_file << "NVM Error : ";
			if(rap_current->des == ALLOCATE_IN_NVM)
				dataset_file << " Policy Error";		
			else if(rap_current->des == ALLOCATE_PREEMPTIVELY)
				dataset_file << " Learning Error";
			else if(rap_current->des == ALLOCATE_IN_SRAM && inNVM)
				dataset_file << "Wrongly allocated cl";
			else
				dataset_file << " Des: " << str_allocDecision[rap_current->des] << "UNKNOW Error";
			dataset_file << endl;
		}
		
		if(element.isSRAMerror)
		{
			dataset_file << "SRAM Error : ";
		
			if(rap_current->des == ALLOCATE_IN_SRAM)
				dataset_file << "Wrong policy";
			else if(rap_current->des == ALLOCATE_PREEMPTIVELY)
				dataset_file << " Learning Error";
			else if(rap_current->des == ALLOCATE_IN_NVM && !inNVM)
				dataset_file << "Wrongly allocated cl";
		
			dataset_file << endl;		
		}
	
	}
}

// Assembly:
subq $0x218, %rsp            # imm = 0x218
movq %r9, 0x108(%rsp)
movq %r8, 0x110(%rsp)
movb %cl, %al
leaq 0x220(%rsp), %rcx
movq %rcx, 0x118(%rsp)
movq %rdi, 0x210(%rsp)
movq %rsi, 0x208(%rsp)
movq %rdx, 0x200(%rsp)
andb $0x1, %al
movb %al, 0x1ff(%rsp)
movq %r8, 0x1f0(%rsp)
movq %r9, 0x1e8(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x120(%rsp)
movb 0x1ff(%rsp), %dl
leaq 0x55a5b(%rip), %rcx     # 0x71823
leaq 0x55a5d(%rip), %rax     # 0x7182c
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x128(%rsp)
leaq 0x1c7(%rsp), %rdi
movq %rdi, 0x130(%rsp)
callq 0x56a0
movq 0x128(%rsp), %rsi
movq 0x130(%rsp), %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x5530
jmp 0x1be12
leaq 0x1c7(%rsp), %rdi
callq 0x53e0
movq 0x200(%rsp), %rax
movb 0x148(%rax), %dl
leaq 0x5892b(%rip), %rcx     # 0x7475f
leaq 0x5594b(%rip), %rax     # 0x71786
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0xf8(%rsp)
leaq 0x18f(%rsp), %rdi
movq %rdi, 0x100(%rsp)
callq 0x56a0
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
leaq 0x190(%rsp), %rdi
callq 0x5530
jmp 0x1be7e
leaq 0x18f(%rsp), %rdi
callq 0x53e0
movq 0x118(%rsp), %rdi
callq 0xf7c0
movb %al, 0xf7(%rsp)
jmp 0x1bea1
movb 0xf7(%rsp), %dl
leaq 0x580e8(%rip), %rcx     # 0x73f97
leaq 0x580d7(%rip), %rax     # 0x73f8d
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0xe0(%rsp)
leaq 0x167(%rsp), %rdi
movq %rdi, 0xe8(%rsp)
callq 0x56a0
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
leaq 0x168(%rsp), %rdi
callq 0x5530
jmp 0x1bef9
leaq 0x167(%rsp), %rdi
callq 0x53e0
leaq 0x13f(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x56a0
movq 0xd8(%rsp), %rdx
leaq 0x56d3a(%rip), %rsi     # 0x72c64
leaq 0x140(%rsp), %rdi
callq 0x5530
jmp 0x1bf39
leaq 0x13f(%rsp), %rdi
callq 0x53e0
movq 0x118(%rsp), %rax
testb $0x1, 0x28(%rax)
je 0x1c04a
leaq 0x5583f(%rip), %rsi     # 0x7179e
leaq 0x140(%rsp), %rdi
callq 0x5520
jmp 0x1bf6e
jmp 0x1c04a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x1c7(%rsp), %rdi
callq 0x53e0
jmp 0x1c6f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x18f(%rsp), %rdi
callq 0x53e0
jmp 0x1c6e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x1c6dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x167(%rsp), %rdi
callq 0x53e0
jmp 0x1c6dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x13f(%rsp), %rdi
callq 0x53e0
jmp 0x1c6cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x5768
jmp 0x1c6cf
leaq 0x77f9f(%rip), %rax     # 0x93ff0
testb $0x1, (%rax)
je 0x1c33b
movq 0x110(%rsp), %rsi
leaq 0x7769f(%rip), %rdi     # 0x93708
callq 0x5330
movq %rax, 0xd0(%rsp)
jmp 0x1c078
movq 0xd0(%rsp), %rdi
leaq 0x55a6a(%rip), %rsi     # 0x71af1
callq 0x5380
movq %rax, 0xc8(%rsp)
jmp 0x1c096
movq 0xc8(%rsp), %rdi
movq 0x208(%rsp), %rax
movl 0x18(%rax), %esi
callq 0x5680
movq %rax, 0xc0(%rsp)
jmp 0x1c0b8
movq 0xc0(%rsp), %rdi
leaq 0x55a66(%rip), %rsi     # 0x71b2d
callq 0x5380
movq %rax, 0xb8(%rsp)
jmp 0x1c0d6
movq 0xb8(%rsp), %rdi
movq 0x208(%rsp), %rax
movl 0x98(%rax), %eax
movl %eax, %ecx
leaq 0x773ab(%rip), %rax     # 0x934a0
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, 0xb0(%rsp)
jmp 0x1c108
movq 0xb0(%rsp), %rdi
leaq 0x54f2b(%rip), %rsi     # 0x71042
callq 0x5380
movq %rax, 0xa8(%rsp)
jmp 0x1c126
movq 0xa8(%rsp), %rdi
movq 0x208(%rsp), %rax
movl 0x9c(%rax), %eax
movl %eax, %ecx
leaq 0x7738b(%rip), %rax     # 0x934d0
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, 0xa0(%rsp)
jmp 0x1c158
movq 0xa0(%rsp), %rdi
leaq 0x559ca(%rip), %rsi     # 0x71b31
callq 0x5380
movq %rax, 0x98(%rsp)
jmp 0x1c176
movq 0x98(%rsp), %rdi
movq 0x208(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, %ecx
leaq 0x7729e(%rip), %rax     # 0x93430
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, 0x90(%rsp)
jmp 0x1c1a5
movq 0x90(%rsp), %rdi
leaq 0x54e8e(%rip), %rsi     # 0x71042
callq 0x5380
movq %rax, 0x88(%rsp)
jmp 0x1c1c3
movq 0x88(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x5330
movq %rax, 0x80(%rsp)
jmp 0x1c1e2
movq 0x80(%rsp), %rdi
leaq 0x555c0(%rip), %rsi     # 0x717b1
callq 0x5380
movq %rax, 0x78(%rsp)
jmp 0x1c1fd
movq 0x78(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x5330
movq %rax, 0x70(%rsp)
jmp 0x1c216
movq 0x70(%rsp), %rdi
leaq 0x558e8(%rip), %rsi     # 0x71b0a
callq 0x5380
movq %rax, 0x68(%rsp)
jmp 0x1c22e
movq 0x68(%rsp), %rdi
leaq -0xca3a(%rip), %rsi     # 0xf800
callq 0x5160
movq %rax, 0x60(%rsp)
jmp 0x1c246
movq 0x60(%rsp), %rdi
movq 0x200(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x50f0
movq %rax, 0x58(%rsp)
jmp 0x1c263
movq 0x58(%rsp), %rdi
leaq -0xca4f(%rip), %rsi     # 0xf820
callq 0x5160
movq %rax, 0x50(%rsp)
jmp 0x1c27b
movq 0x50(%rsp), %rdi
leaq 0x54fb2(%rip), %rsi     # 0x71239
callq 0x5380
movq %rax, 0x48(%rsp)
jmp 0x1c293
movq 0x48(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x5330
movq %rax, 0x40(%rsp)
jmp 0x1c2ac
movq 0x40(%rsp), %rdi
leaq 0x554fe(%rip), %rsi     # 0x717b6
callq 0x5380
movq %rax, 0x38(%rsp)
jmp 0x1c2c4
movq 0x108(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x5330
movq %rax, 0x30(%rsp)
jmp 0x1c2dd
movq 0x30(%rsp), %rdi
leaq 0x554ea(%rip), %rsi     # 0x717d3
callq 0x5380
movq %rax, 0x28(%rsp)
jmp 0x1c2f5
movq 0x28(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x5330
movq %rax, 0x20(%rsp)
jmp 0x1c30e
movq 0x20(%rsp), %rdi
leaq 0x554ba(%rip), %rsi     # 0x717d4
callq 0x5380
movq %rax, 0x18(%rsp)
jmp 0x1c326
movq 0x18(%rsp), %rdi
movq 0x76c86(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x1c339
jmp 0x1c33b
testb $0x1, 0x1ff(%rsp)
je 0x1c3f5
movq 0x118(%rsp), %rdi
callq 0xf7c0
movb %al, 0x17(%rsp)
jmp 0x1c35c
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x1c369
jmp 0x1c3f5
movq 0x208(%rsp), %rax
cmpl $0x1, 0x28(%rax)
jne 0x1c393
movq 0x120(%rsp), %rax
movq 0x3f8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x3f8(%rax)
jmp 0x1c3f3
movq 0x208(%rsp), %rax
cmpl $0x3, 0x28(%rax)
jne 0x1c3bd
movq 0x120(%rsp), %rax
movq 0x3f0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x3f0(%rax)
jmp 0x1c3f1
movq 0x208(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x1c3ef
testb $0x1, 0x1ff(%rsp)
je 0x1c3ef
movq 0x120(%rsp), %rax
movq 0x3e8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x3e8(%rax)
jmp 0x1c3f1
jmp 0x1c3f3
jmp 0x1c3f5
movq 0x118(%rsp), %rax
testb $0x1, 0x28(%rax)
je 0x1c493
movq 0x208(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x1c431
movq 0x120(%rsp), %rax
movq 0x410(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x410(%rax)
jmp 0x1c491
movq 0x208(%rsp), %rax
cmpl $0x3, 0x28(%rax)
jne 0x1c45b
movq 0x120(%rsp), %rax
movq 0x408(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x408(%rax)
jmp 0x1c48f
movq 0x208(%rsp), %rax
cmpl $0x1, 0x28(%rax)
jne 0x1c48d
testb $0x1, 0x1ff(%rsp)
jne 0x1c48d
movq 0x120(%rsp), %rax
movq 0x400(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x400(%rax)
jmp 0x1c48f
jmp 0x1c491
jmp 0x1c493
leaq 0x77b56(%rip), %rax     # 0x93ff0
testb $0x1, (%rax)
je 0x1c693
testb $0x1, 0x1ff(%rsp)
je 0x1c5d6
movq 0x118(%rsp), %rdi
callq 0xf7c0
movb %al, 0x16(%rsp)
jmp 0x1c4c4
movb 0x16(%rsp), %al
testb $0x1, %al
jne 0x1c4d1
jmp 0x1c5d6
leaq 0x77230(%rip), %rdi     # 0x93708
leaq 0x55657(%rip), %rsi     # 0x71b36
callq 0x5380
jmp 0x1c4e6
movq 0x208(%rsp), %rax
cmpl $0x1, 0x28(%rax)
jne 0x1c50e
leaq 0x7720d(%rip), %rdi     # 0x93708
leaq 0x55641(%rip), %rsi     # 0x71b43
callq 0x5380
jmp 0x1c509
jmp 0x1c5bf
movq 0x208(%rsp), %rax
cmpl $0x3, 0x28(%rax)
jne 0x1c536
leaq 0x771e5(%rip), %rdi     # 0x93708
leaq 0x55627(%rip), %rsi     # 0x71b51
callq 0x5380
jmp 0x1c531
jmp 0x1c5bd
movq 0x208(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x1c565
testb $0x1, 0x1ff(%rsp)
je 0x1c565
leaq 0x771b3(%rip), %rdi     # 0x93708
leaq 0x55605(%rip), %rsi     # 0x71b61
callq 0x5380
jmp 0x1c563
jmp 0x1c5bb
leaq 0x7719c(%rip), %rdi     # 0x93708
leaq 0x55603(%rip), %rsi     # 0x71b76
callq 0x5380
movq %rax, 0x8(%rsp)
jmp 0x1c57f
movq 0x8(%rsp), %rdi
movq 0x208(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, %ecx
leaq 0x76e98(%rip), %rax     # 0x93430
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, (%rsp)
jmp 0x1c5a7
movq (%rsp), %rdi
leaq 0x555cb(%rip), %rsi     # 0x71b7d
callq 0x5380
jmp 0x1c5b9
jmp 0x1c5bb
jmp 0x1c5bd
jmp 0x1c5bf
leaq 0x77142(%rip), %rdi     # 0x93708
movq 0x769eb(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x1c5d4
jmp 0x1c5d6
movq 0x118(%rsp), %rax
testb $0x1, 0x28(%rax)
je 0x1c691
leaq 0x77119(%rip), %rdi     # 0x93708
leaq 0x55594(%rip), %rsi     # 0x71b8a
callq 0x5380
jmp 0x1c5fd
movq 0x208(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x1c622
leaq 0x770f6(%rip), %rdi     # 0x93708
leaq 0x5557f(%rip), %rsi     # 0x71b98
callq 0x5380
jmp 0x1c620
jmp 0x1c67a
movq 0x208(%rsp), %rax
cmpl $0x3, 0x28(%rax)
jne 0x1c647
leaq 0x770d1(%rip), %rdi     # 0x93708
leaq 0x55513(%rip), %rsi     # 0x71b51
callq 0x5380
jmp 0x1c645
jmp 0x1c678
movq 0x208(%rsp), %rax
cmpl $0x1, 0x28(%rax)
jne 0x1c676
testb $0x1, 0x1ff(%rsp)
jne 0x1c676
leaq 0x770a2(%rip), %rdi     # 0x93708
leaq 0x554f4(%rip), %rsi     # 0x71b61
callq 0x5380
jmp 0x1c674
jmp 0x1c676
jmp 0x1c678
jmp 0x1c67a
leaq 0x77087(%rip), %rdi     # 0x93708
movq 0x76930(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x1c68f
jmp 0x1c691
jmp 0x1c693
leaq 0x140(%rsp), %rdi
callq 0x5768
leaq 0x168(%rsp), %rdi
callq 0x5768
leaq 0x190(%rsp), %rdi
callq 0x5768
leaq 0x1c8(%rsp), %rdi
callq 0x5768
addq $0x218, %rsp            # imm = 0x218
retq
leaq 0x168(%rsp), %rdi
callq 0x5768
leaq 0x190(%rsp), %rdi
callq 0x5768
leaq 0x1c8(%rsp), %rdi
callq 0x5768
movq 0x1b8(%rsp), %rdi
callq 0x5690
nopw %cs:(%rax,%rax)