// File: gvaumour[P]cache-simulator/src/SimplePerceptron.cc
// Function: SimplePerceptronPredictor::reportAccess(Access, CacheEntry*, int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void
SimplePerceptronPredictor::reportAccess(Access element, CacheEntry* current, int set , bool inNVM, string entete)
{
	if(!simu_parameters.printDebug)
		return;
	
	string cl_location = inNVM ? "NVM" : "SRAM";
	string access_type = element.isWrite() ? "WRITE" : "READ";
	
	string is_error= "";
	if( isHitInBPtags(element.block_addr , set) && entete == "INSERTION")
	{
		is_error == "is a BP error";
	}
	//if(element.isSRAMerror)
	//	is_error = "is an SRAM error, ";

	string counters = "[";
	string hashes = "[";	
	
	for(unsigned i = 0 ; i < m_features.size()-1; i++)
	{
		int hash = hashing_function1( m_features_hash[i] , current->address , current->missPC);		
		int counter = m_features[i]->getCounter(hash);
		counters += to_string(counter) + " , ";
		hashes += to_string(hash) + " , ";
	}
	int hash = hashing_function1( m_features_hash[m_features.size()-1] , current->address , current->missPC);		
	counters += to_string(m_features[m_features.size()-1]->getCounter(hash)) + " ]";
	hashes	+= to_string(hash) + " ]";
	
	int first_hash = hashing_function1( m_features_hash[0] , current->address , current->missPC);
	
	debug_file_simple_perceptron << entete << ":Dataset n°" << first_hash << ": " \
	<< access_type << " on Cl 0x" << std::hex << current->address << std::dec << ", E_SRAM =" \
	<< current->e_sram << " , E_NVM =" << current->e_nvm << " allocated in " << cl_location << ", " << is_error << "Hashes=" << hashes \
        << ", Counters=" << counters << endl;	
}

// Assembly:
subq $0x3c8, %rsp            # imm = 0x3C8
movq %r8, 0x120(%rsp)
movb %cl, %al
leaq 0x3d0(%rsp), %rcx
movq %rcx, 0x128(%rsp)
movq %rdi, 0x3c0(%rsp)
movq %rsi, 0x3b8(%rsp)
movl %edx, 0x3b4(%rsp)
andb $0x1, %al
movb %al, 0x3b3(%rsp)
movq %r8, 0x3a8(%rsp)
movq 0x3c0(%rsp), %rax
movq %rax, 0x130(%rsp)
leaq 0x32850(%rip), %rax     # 0x93ff0
testb $0x1, (%rax)
jne 0x617aa
jmp 0x621f1
movb 0x3b3(%rsp), %dl
leaq 0x1006b(%rip), %rcx     # 0x71823
leaq 0x1006d(%rip), %rax     # 0x7182c
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x110(%rsp)
leaq 0x387(%rsp), %rdi
movq %rdi, 0x118(%rsp)
callq 0x56a0
movq 0x110(%rsp), %rsi
movq 0x118(%rsp), %rdx
leaq 0x388(%rsp), %rdi
callq 0x5530
jmp 0x61802
leaq 0x387(%rsp), %rdi
callq 0x53e0
movq 0x128(%rsp), %rdi
callq 0xf7c0
movb %al, 0x10f(%rsp)
jmp 0x61825
movb 0x10f(%rsp), %dl
leaq 0x12764(%rip), %rcx     # 0x73f97
leaq 0x12753(%rip), %rax     # 0x73f8d
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0xf8(%rsp)
leaq 0x34f(%rsp), %rdi
movq %rdi, 0x100(%rsp)
callq 0x56a0
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
leaq 0x350(%rsp), %rdi
callq 0x5530
jmp 0x6187d
leaq 0x34f(%rsp), %rdi
callq 0x53e0
leaq 0x327(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x56a0
movq 0xf0(%rsp), %rdx
leaq 0x113b6(%rip), %rsi     # 0x72c64
leaq 0x328(%rsp), %rdi
callq 0x5530
jmp 0x618bd
leaq 0x327(%rsp), %rdi
callq 0x53e0
movq 0x128(%rsp), %rax
movq 0x130(%rsp), %rdi
movq 0x30(%rax), %rsi
movl 0x3b4(%rsp), %edx
callq 0x573f0
movb %al, 0xef(%rsp)
jmp 0x618f3
movb 0xef(%rsp), %al
testb $0x1, %al
jne 0x61903
jmp 0x619ef
movq 0x120(%rsp), %rdi
leaq 0xf829(%rip), %rsi      # 0x7113b
callq 0xfa60
movb %al, 0xee(%rsp)
jmp 0x61920
movb 0xee(%rsp), %al
testb $0x1, %al
jne 0x61930
jmp 0x619ef
leaq 0x125ae(%rip), %rsi     # 0x73ee5
leaq 0x328(%rsp), %rdi
callq 0xfa60
jmp 0x61946
jmp 0x619ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x387(%rsp), %rdi
callq 0x53e0
jmp 0x6230d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
jmp 0x62300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x34f(%rsp), %rdi
callq 0x53e0
jmp 0x62300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x327(%rsp), %rdi
callq 0x53e0
jmp 0x622f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
jmp 0x622e6
leaq 0x2ff(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0x56a0
movq 0xe0(%rsp), %rdx
leaq 0x102c5(%rip), %rsi     # 0x71cd8
leaq 0x300(%rsp), %rdi
callq 0x5530
jmp 0x61a22
leaq 0x2ff(%rsp), %rdi
callq 0x53e0
leaq 0x2d7(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x56a0
movq 0xd8(%rsp), %rdx
leaq 0x10285(%rip), %rsi     # 0x71cd8
leaq 0x2d8(%rsp), %rdi
callq 0x5530
jmp 0x61a62
leaq 0x2d7(%rsp), %rdi
callq 0x53e0
movl $0x0, 0x2d0(%rsp)
movq 0x130(%rsp), %rdi
movl 0x2d0(%rsp), %eax
movq %rax, 0xd0(%rsp)
addq $0x270, %rdi            # imm = 0x270
callq 0x64a70
movq %rax, %rcx
movq 0xd0(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x61d65
movq 0x130(%rsp), %rdi
addq $0x288, %rdi            # imm = 0x288
movl 0x2d0(%rsp), %eax
movl %eax, %esi
callq 0xf860
movq %rax, %rsi
leaq 0x2a0(%rsp), %rdi
callq 0xf880
jmp 0x61ae4
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rax), %rdx
leaq 0x2a0(%rsp), %rdi
callq 0x2ff40
movl %eax, 0xcc(%rsp)
jmp 0x61b0a
leaq 0x2a0(%rsp), %rdi
callq 0xf7b0
movl 0xcc(%rsp), %eax
movq 0x130(%rsp), %rdi
movl %eax, 0x2cc(%rsp)
addq $0x270, %rdi            # imm = 0x270
movl 0x2d0(%rsp), %eax
movl %eax, %esi
callq 0x64a90
movq (%rax), %rdi
movl 0x2cc(%rsp), %esi
callq 0x5e6e0
movl %eax, 0xc8(%rsp)
jmp 0x61b5a
movl 0xc8(%rsp), %eax
movl %eax, 0x29c(%rsp)
movl 0x29c(%rsp), %esi
leaq 0x258(%rsp), %rdi
callq 0x101d0
jmp 0x61b7e
leaq 0xfc4e(%rip), %rdx      # 0x717d3
leaq 0x278(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0x10180
jmp 0x61b9c
leaq 0x300(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0x54f0
jmp 0x61bb3
leaq 0x278(%rsp), %rdi
callq 0x5768
leaq 0x258(%rsp), %rdi
callq 0x5768
movl 0x2cc(%rsp), %esi
leaq 0x218(%rsp), %rdi
callq 0x101d0
jmp 0x61be3
leaq 0xfbe9(%rip), %rdx      # 0x717d3
leaq 0x238(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x10180
jmp 0x61c01
leaq 0x2d8(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x54f0
jmp 0x61c18
leaq 0x238(%rsp), %rdi
callq 0x5768
leaq 0x218(%rsp), %rdi
callq 0x5768
movl 0x2d0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2d0(%rsp)
jmp 0x61a7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x2ff(%rsp), %rdi
callq 0x53e0
jmp 0x622e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x2d7(%rsp), %rdi
callq 0x53e0
jmp 0x622d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
jmp 0x622cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0xf7b0
jmp 0x622cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
jmp 0x61d0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x278(%rsp), %rdi
callq 0x5768
leaq 0x258(%rsp), %rdi
callq 0x5768
jmp 0x622cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
jmp 0x61d53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x5768
leaq 0x218(%rsp), %rdi
callq 0x5768
jmp 0x622cc
movq 0x130(%rsp), %rdi
movq %rdi, %rax
addq $0x288, %rax            # imm = 0x288
movq %rax, 0xc0(%rsp)
addq $0x270, %rdi            # imm = 0x270
callq 0x64a70
movq 0xc0(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0xf860
movq %rax, %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xf880
jmp 0x61daf
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rax), %rdx
leaq 0x1e8(%rsp), %rdi
callq 0x2ff40
movl %eax, 0xbc(%rsp)
jmp 0x61dd5
leaq 0x1e8(%rsp), %rdi
callq 0xf7b0
movl 0xbc(%rsp), %eax
movq 0x130(%rsp), %rdi
movl %eax, 0x214(%rsp)
addq $0x270, %rdi            # imm = 0x270
movq %rdi, 0xb0(%rsp)
callq 0x64a70
movq 0xb0(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x64a90
movq (%rax), %rdi
movl 0x214(%rsp), %esi
callq 0x5e6e0
movl %eax, 0xb8(%rsp)
jmp 0x61e37
movl 0xb8(%rsp), %esi
leaq 0x1a8(%rsp), %rdi
callq 0x101d0
jmp 0x61e4d
leaq 0x1209f(%rip), %rdx     # 0x73ef3
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x10180
jmp 0x61e6b
leaq 0x300(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x54f0
jmp 0x61e82
leaq 0x1c8(%rsp), %rdi
callq 0x5768
leaq 0x1a8(%rsp), %rdi
callq 0x5768
movl 0x214(%rsp), %esi
leaq 0x168(%rsp), %rdi
callq 0x101d0
jmp 0x61eb2
leaq 0x1203a(%rip), %rdx     # 0x73ef3
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x10180
jmp 0x61ed0
leaq 0x2d8(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x54f0
jmp 0x61ee7
leaq 0x188(%rsp), %rdi
callq 0x5768
leaq 0x168(%rsp), %rdi
callq 0x5768
movq 0x130(%rsp), %rdi
addq $0x288, %rdi            # imm = 0x288
xorl %eax, %eax
movl %eax, %esi
callq 0xf860
movq %rax, %rsi
leaq 0x138(%rsp), %rdi
callq 0xf880
jmp 0x61f2b
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x20(%rax), %rdx
leaq 0x138(%rsp), %rdi
callq 0x2ff40
movl %eax, 0xac(%rsp)
jmp 0x61f51
leaq 0x138(%rsp), %rdi
callq 0xf7b0
movl 0xac(%rsp), %eax
movq 0x120(%rsp), %rsi
movl %eax, 0x164(%rsp)
leaq 0x31e35(%rip), %rdi     # 0x93db0
callq 0x5330
movq %rax, 0xa0(%rsp)
jmp 0x61f8a
movq 0xa0(%rsp), %rdi
leaq 0xfb58(%rip), %rsi      # 0x71af1
callq 0x5380
movq %rax, 0x98(%rsp)
jmp 0x61fa8
movq 0x98(%rsp), %rdi
movl 0x164(%rsp), %esi
callq 0x5680
movq %rax, 0x90(%rsp)
jmp 0x61fc6
movq 0x90(%rsp), %rdi
leaq 0xf06a(%rip), %rsi      # 0x7103f
callq 0x5380
movq %rax, 0x88(%rsp)
jmp 0x61fe4
movq 0x88(%rsp), %rdi
leaq 0x350(%rsp), %rsi
callq 0x5330
movq %rax, 0x80(%rsp)
jmp 0x62003
movq 0x80(%rsp), %rdi
leaq 0x11ee4(%rip), %rsi     # 0x73ef6
callq 0x5380
movq %rax, 0x78(%rsp)
jmp 0x6201e
movq 0x78(%rsp), %rdi
leaq -0x5282a(%rip), %rsi    # 0xf800
callq 0x5160
movq %rax, 0x70(%rsp)
jmp 0x62036
movq 0x70(%rsp), %rdi
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x50f0
movq %rax, 0x68(%rsp)
jmp 0x62053
movq 0x68(%rsp), %rdi
leaq -0x5283f(%rip), %rsi    # 0xf820
callq 0x5160
movq %rax, 0x60(%rsp)
jmp 0x6206b
movq 0x60(%rsp), %rdi
leaq 0x11e89(%rip), %rsi     # 0x73f00
callq 0x5380
movq %rax, 0x58(%rsp)
jmp 0x62083
movq 0x58(%rsp), %rdi
movq 0x3b8(%rsp), %rax
movq 0x138(%rax), %rsi
callq 0x50f0
movq %rax, 0x50(%rsp)
jmp 0x620a3
movq 0x50(%rsp), %rdi
leaq 0x11e5c(%rip), %rsi     # 0x73f0b
callq 0x5380
movq %rax, 0x48(%rsp)
jmp 0x620bb
movq 0x48(%rsp), %rdi
movq 0x3b8(%rsp), %rax
movq 0x140(%rax), %rsi
callq 0x50f0
movq %rax, 0x40(%rsp)
jmp 0x620db
movq 0x40(%rsp), %rdi
leaq 0xf152(%rip), %rsi      # 0x71239
callq 0x5380
movq %rax, 0x38(%rsp)
jmp 0x620f3
movq 0x38(%rsp), %rdi
leaq 0x388(%rsp), %rsi
callq 0x5330
movq %rax, 0x30(%rsp)
jmp 0x6210c
movq 0x30(%rsp), %rdi
leaq 0xf6bc(%rip), %rsi      # 0x717d4
callq 0x5380
movq %rax, 0x28(%rsp)
jmp 0x62124
movq 0x28(%rsp), %rdi
leaq 0x328(%rsp), %rsi
callq 0x5330
movq %rax, 0x20(%rsp)
jmp 0x6213d
movq 0x20(%rsp), %rdi
leaq 0x11dec(%rip), %rsi     # 0x73f35
callq 0x5380
movq %rax, 0x18(%rsp)
jmp 0x62155
movq 0x18(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0x5330
movq %rax, 0x10(%rsp)
jmp 0x6216e
movq 0x10(%rsp), %rdi
leaq 0x11dc5(%rip), %rsi     # 0x73f3f
callq 0x5380
movq %rax, 0x8(%rsp)
jmp 0x62186
movq 0x8(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x5330
movq %rax, (%rsp)
jmp 0x6219e
movq (%rsp), %rdi
movq 0x30e0f(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x621b0
leaq 0x2d8(%rsp), %rdi
callq 0x5768
leaq 0x300(%rsp), %rdi
callq 0x5768
leaq 0x328(%rsp), %rdi
callq 0x5768
leaq 0x350(%rsp), %rdi
callq 0x5768
leaq 0x388(%rsp), %rdi
callq 0x5768
addq $0x3c8, %rsp            # imm = 0x3C8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0xf7b0
jmp 0x622cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
jmp 0x62256
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x5768
leaq 0x1a8(%rsp), %rdi
callq 0x5768
jmp 0x622cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
jmp 0x6229c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x5768
leaq 0x168(%rsp), %rdi
callq 0x5768
jmp 0x622cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x378(%rsp)
movl %eax, 0x374(%rsp)
leaq 0x138(%rsp), %rdi
callq 0xf7b0
leaq 0x2d8(%rsp), %rdi
callq 0x5768
leaq 0x300(%rsp), %rdi
callq 0x5768
leaq 0x328(%rsp), %rdi
callq 0x5768
leaq 0x350(%rsp), %rdi
callq 0x5768
leaq 0x388(%rsp), %rdi
callq 0x5768
movq 0x378(%rsp), %rdi
callq 0x5690
nopw (%rax,%rax)