// File: /workspace/github_cpp_makefile_star2_O2/gvaumour[P]cache-simulator/src/Cerebron.cc
// Function: CerebronPredictor::reportAccess(Access, CacheEntry*, int, 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
CerebronPredictor::reportAccess(Access element, CacheEntry* current, int set, bool inNVM, string entete, string reuse_class)
{
	if(!simu_parameters.printDebug)
		return;

	string cl_location = inNVM ? "NVM" : "SRAM";
	string is_learning = current->isLearning_policy ? "LearningPolicy" : "Regular";
	is_learning += current->isLearning_weight ? "+LearningWeight" : "";
	is_learning ="";
	string access_type = element.isWrite() ? "WRITE" : "READ";
	
	string is_error= "";
	if(element.isSRAMerror)
		is_error = ", is an SRAM error";

	string des = "[" , confidence = "[", hashes = "[";	
	int total = 0;
	for(unsigned i = 0 ; i < m_features.size() ; i++)
	{
		int hash = hashing_function1( m_features_hash[i] , current->address , current->missPC);		
		confidence += to_string(m_features[i]->getConfidence(hash, true)) + " , ";
		des += string(str_allocDecision[m_features[i]->getAllocDecision(hash, element.isWrite())]) + " , " ;
		hashes += to_string(hash) + " , ";
		
		int conf = m_features[i]->getConfidence(hash, true);
		allocDecision a = m_features[i]->getAllocDecision(hash, element.isWrite());

		if( a == ALLOCATE_IN_SRAM)
			total += (-1) * conf;
		else
			total += conf; 
	}
	allocDecision final_des = convertToAllocDecision(total , element.isWrite());
	int first_hash = hashing_function1( m_features_hash[0] , current->address , current->missPC);
	
	debug_file << entete << ":Dataset n°" << first_hash << ": "
	<< str_allocDecision[final_des ] << "," \
	<< access_type << " on " << is_learning << " Cl 0x" << std::hex << current->address \
	<< std::dec << " allocated in " << cl_location<< ", Reuse=" << reuse_class \
	<< is_error << ", Features Hashes=" << hashes << "] , " \
        << "Des=" << des << "] , Confidence=" << confidence << "]";
        
	if( simu_parameters.Cerebron_RDmodel)
	{
		bool hitSRAM = false, hitNVM = false;
		if( !inNVM && entete == "UPDATE")
			hitSRAM = true;
		else
			hitSRAM = getHitPerDataArray( current->address , set , false);
				
	
		if( inNVM && entete == "UPDATE")
			hitNVM = true;
		else 
			hitNVM = getHitPerDataArray( current->address , set , true);
			
		string hitSRAM_str = hitSRAM ? "TRUE" : "FALSE";
		string hitNVM_str = hitNVM ? "TRUE" : "FALSE";
		
		
		debug_file << ", E_SRAM = " << current->e_sram << " , E_NVM = " << current->e_nvm\
			 << ", HitSRAM=" << hitSRAM_str << ", HitNVM=" << hitNVM_str;	
	}
	else
	{
		debug_file << ", cost = " << current->cost_value;	
	}
	
	debug_file << endl;	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %r9, 0x70(%rsp)
leaq 0x36b81(%rip), %rax     # 0x3df50
cmpb $0x1, (%rax)
jne 0x7ae5
movq %r8, %r14
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x2240f(%rip), %rax     # 0x297fc
leaq 0x22411(%rip), %rsi     # 0x29805
testb %r15b, %r15b
cmovneq %rax, %rsi
leaq 0x138(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x5140
leaq 0x2233c(%rip), %rax     # 0x29750
leaq 0x22344(%rip), %rsi     # 0x2975f
cmpb $0x0, 0x149(%r12)
cmovneq %rax, %rsi
leaq 0x78(%rsp), %rdi
leaq 0x118(%rsp), %rdx
callq 0x5140
movl %r15d, 0x1c(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x10(%rsp)
leaq 0x22317(%rip), %rax     # 0x29767
leaq 0x237cd(%rip), %rsi     # 0x2ac24
cmpb $0x0, 0x14a(%r12)
cmovneq %rax, %rsi
leaq 0x78(%rsp), %rdi
callq 0x55b0
leaq 0x237af(%rip), %rsi     # 0x2ac24
leaq 0x78(%rsp), %rdi
callq 0x55c0
leaq 0x1e0(%rsp), %r15
movl 0x1c(%r15), %eax
cmpl $0x3, %eax
sete %cl
cmpl $0x6, %eax
sete %bl
orb %cl, %bl
leaq 0x24b27(%rip), %rax     # 0x2bfc7
leaq 0x24b16(%rip), %rsi     # 0x2bfbd
cmovneq %rax, %rsi
leaq 0x118(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x5140
leaq 0x2375d(%rip), %rsi     # 0x2ac24
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x5140
cmpb $0x1, 0x28(%r15)
jne 0x74f7
leaq 0x2228d(%rip), %rsi     # 0x29777
leaq 0xf8(%rsp), %rdi
callq 0x55c0
leaq 0x227ca(%rip), %rsi     # 0x29cc8
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x5140
leaq 0x227ae(%rip), %rsi     # 0x29cc8
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x5140
movl %ebp, 0x20(%rsp)
leaq 0x2278e(%rip), %rsi     # 0x29cc8
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x5140
xorl %ebp, %ebp
leaq 0x180(%rsp), %r14
leaq 0x30(%rsp), %r13
leaq 0x2224a(%rip), %r15     # 0x297ac
movzbl %bl, %eax
movl %eax, 0x18(%rsp)
xorl %esi, %esi
movq 0x10(%rsp), %rbx
movl %ebp, %ebp
movq 0x278(%rbx), %rax
subq 0x270(%rbx), %rax
sarq $0x3, %rax
cmpq %rbp, %rax
jbe 0x7720
movl %esi, 0x24(%rsp)
imulq $0x28, %rbp, %rsi
addq 0x288(%rbx), %rsi
movq %r14, %rdi
callq 0x9f3a
movq 0x8(%r12), %rsi
movq 0x20(%r12), %rdx
movq %r14, %rdi
callq 0x11de8
movl %eax, %ebx
movq %r14, %rdi
callq 0x5618
movq 0x10(%rsp), %rax
movq 0x270(%rax), %rax
movq (%rax,%rbp,8), %rdi
movl %ebx, %esi
pushq $0x1
popq %rdx
callq 0x11132
movq %r13, %rdi
movl %eax, %esi
callq 0xa0dc
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xa0bd
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
callq 0x55f0
movq %r14, %rdi
callq 0x5618
movq %r13, %rdi
callq 0x5618
movq 0x10(%rsp), %rax
movq 0x270(%rax), %rax
movq (%rax,%rbp,8), %rdi
movl %ebx, %esi
movl 0x18(%rsp), %edx
callq 0x11088
movl %eax, %eax
leaq 0x35d55(%rip), %rcx     # 0x3d390
movq (%rcx,%rax,8), %rsi
movq %r13, %rdi
leaq 0xf(%rsp), %rdx
callq 0x5140
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xa0bd
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
callq 0x55f0
movq %r14, %rdi
callq 0x5618
movq %r13, %rdi
callq 0x5618
movq %r13, %rdi
movl %ebx, %esi
callq 0xa0dc
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xa0bd
movq %r14, %r15
movq %r12, %r14
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x55f0
movq %r15, %rdi
callq 0x5618
movq %r13, %r15
movq %r13, %rdi
callq 0x5618
movq 0x10(%rsp), %r13
movq 0x270(%r13), %rax
movq (%rax,%rbp,8), %rdi
movl %ebx, %esi
pushq $0x1
popq %rdx
callq 0x11132
movl %eax, %r12d
movq 0x270(%r13), %rax
movq (%rax,%rbp,8), %rdi
movl %ebx, %esi
movl 0x18(%rsp), %edx
callq 0x11088
movl %r12d, %ecx
negl %ecx
testl %eax, %eax
cmovnel %r12d, %ecx
movl 0x24(%rsp), %esi
addl %ecx, %esi
incl %ebp
movq %r14, %r12
movq 0x10(%rsp), %rbx
leaq 0x180(%rsp), %r14
movq %r15, %r13
leaq 0x22091(%rip), %r15     # 0x297ac
jmp 0x7570
movl 0x18(%rsp), %edx
callq 0x8916
movq %rbx, %rcx
movl %eax, %ebx
movq 0x288(%rcx), %rsi
leaq 0x158(%rsp), %rdi
callq 0x9f3a
movl 0x20(%rsp), %r14d
movq 0x28(%rsp), %r15
movq 0x8(%r12), %rsi
movq 0x20(%r12), %rdx
leaq 0x158(%rsp), %rdi
callq 0x11de8
movl %eax, %ebp
leaq 0x158(%rsp), %rdi
callq 0x5618
leaq 0x35ce7(%rip), %rdi     # 0x3d460
movq %r15, %rsi
callq 0x5290
leaq 0x22359(%rip), %rsi     # 0x29ae1
movq %rax, %rdi
callq 0x52c0
movq %rax, %rdi
movl %ebp, %esi
callq 0x5560
leaq 0x2188e(%rip), %rsi     # 0x2902f
movq %rax, %rdi
callq 0x52c0
movl %ebx, %ecx
leaq 0x35bde(%rip), %rdx     # 0x3d390
movq (%rdx,%rcx,8), %rsi
movq %rax, %rdi
callq 0x52c0
leaq 0x2186d(%rip), %rsi     # 0x29032
movq %rax, %rdi
callq 0x52c0
leaq 0x118(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x21fa6(%rip), %rsi     # 0x2978a
movq %rax, %rdi
callq 0x52c0
leaq 0x78(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x222fa(%rip), %rsi     # 0x29afa
movq %rax, %rdi
callq 0x52c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%rax,%rcx)
movq 0x8(%r12), %rsi
movq %rax, %rdi
callq 0x5200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
leaq 0x219e3(%rip), %rsi     # 0x29229
movq %rax, %rdi
callq 0x52c0
leaq 0x138(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x21f2a(%rip), %rsi     # 0x2978f
movq %rax, %rdi
callq 0x52c0
movq %rax, %rdi
movq 0x70(%rsp), %rsi
callq 0x5290
leaq 0xf8(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x21f07(%rip), %rsi     # 0x29798
movq %rax, %rdi
callq 0x52c0
leaq 0x98(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x21efb(%rip), %rsi     # 0x297ab
movq %rax, %rdi
callq 0x52c0
leaq 0x21f65(%rip), %rsi     # 0x29824
movq %rax, %rdi
callq 0x52c0
leaq 0xd8(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x21ed2(%rip), %rsi     # 0x297b0
movq %rax, %rdi
callq 0x52c0
leaq 0xb8(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x245fd(%rip), %rsi     # 0x2befa
movq %rax, %rdi
callq 0x52c0
leaq 0x36644(%rip), %rax     # 0x3df50
cmpb $0x1, 0x226(%rax)
jne 0x7938
cmpb $0x0, 0x1c(%rsp)
jne 0x7962
leaq 0x21867(%rip), %rsi     # 0x2918a
movq %r15, %rdi
callq 0x9f59
testb %al, %al
je 0x7962
leaq 0x21b92(%rip), %rbx     # 0x294c8
jmp 0x79a6
leaq 0x35b21(%rip), %rdi     # 0x3d460
leaq 0x21ea7(%rip), %rsi     # 0x297ed
callq 0x52c0
movsd 0x130(%r12), %xmm0
movq %rax, %rdi
callq 0x54f0
jmp 0x7a81
movq 0x8(%r12), %rsi
movq 0x10(%rsp), %rdi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x20196
leaq 0x21b4b(%rip), %r15     # 0x294c8
leaq 0x21b49(%rip), %rbx     # 0x294cd
testb %al, %al
cmovneq %r15, %rbx
cmpb $0x0, 0x1c(%rsp)
je 0x79a6
leaq 0x217f2(%rip), %rsi     # 0x2918a
movq 0x28(%rsp), %rdi
callq 0x9f59
testb %al, %al
jne 0x79cf
movq 0x8(%r12), %rsi
pushq $0x1
popq %rcx
movq 0x10(%rsp), %rdi
movl %r14d, %edx
callq 0x20196
leaq 0x21b06(%rip), %rcx     # 0x294c8
leaq 0x21b04(%rip), %r15     # 0x294cd
testb %al, %al
cmovneq %rcx, %r15
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movq %rbx, %rsi
callq 0x5140
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r15, %rsi
callq 0x5140
leaq 0x35a66(%rip), %rdi     # 0x3d460
leaq 0x21dbf(%rip), %rsi     # 0x297c0
callq 0x52c0
movq 0x138(%r12), %rsi
movq %rax, %rdi
callq 0x5200
leaq 0x21daf(%rip), %rsi     # 0x297cc
movq %rax, %rdi
callq 0x52c0
movq 0x140(%r12), %rsi
movq %rax, %rdi
callq 0x5200
leaq 0x21d9c(%rip), %rsi     # 0x297d8
movq %rax, %rdi
callq 0x52c0
leaq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x21d8b(%rip), %rsi     # 0x297e3
movq %rax, %rdi
callq 0x52c0
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
callq 0x5290
leaq 0x30(%rsp), %rdi
callq 0x5618
leaq 0x50(%rsp), %rdi
callq 0x5618
leaq 0x359d8(%rip), %rdi     # 0x3d460
callq 0x5190
leaq 0x98(%rsp), %rdi
callq 0x5618
leaq 0xb8(%rsp), %rdi
callq 0x5618
leaq 0xd8(%rsp), %rdi
callq 0x5618
leaq 0xf8(%rsp), %rdi
callq 0x5618
leaq 0x118(%rsp), %rdi
callq 0x5618
leaq 0x78(%rsp), %rdi
callq 0x5618
leaq 0x138(%rsp), %rdi
callq 0x5618
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x7b54
jmp 0x7b9c
jmp 0x7b25
jmp 0x7b9c
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0x7b91
movq %rax, %rbx
jmp 0x7bac
movq %rax, %rbx
jmp 0x7bb9
movq %rax, %rbx
jmp 0x7bc6
movq %rax, %rbx
jmp 0x7bd3
jmp 0x7b3f
movq %rax, %rbx
jmp 0x7bea
movq %rax, %rbx
jmp 0x7be0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5618
leaq 0x50(%rsp), %rdi
jmp 0x7b91
jmp 0x7b9c
jmp 0x7b9c
jmp 0x7b78
jmp 0x7b78
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
jmp 0x7b91
jmp 0x7b7f
jmp 0x7b9c
jmp 0x7b9c
jmp 0x7b9c
movq %rax, %rbx
jmp 0x7b8c
jmp 0x7b7f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5618
leaq 0x30(%rsp), %rdi
callq 0x5618
jmp 0x7b9f
jmp 0x7b9c
jmp 0x7b9c
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5618
leaq 0xb8(%rsp), %rdi
callq 0x5618
leaq 0xd8(%rsp), %rdi
callq 0x5618
leaq 0xf8(%rsp), %rdi
callq 0x5618
leaq 0x118(%rsp), %rdi
callq 0x5618
leaq 0x78(%rsp), %rdi
callq 0x5618
leaq 0x138(%rsp), %rdi
callq 0x5618
movq %rbx, %rdi
callq 0x5570
nop