// File: /workspace/github_cpp_makefile_star2_O2/gvaumour[P]cache-simulator/src/Predictor.cc
// Function: Predictor::printStats(std::ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void 
Predictor::printStats(std::ostream& out, string entete)
{

	uint64_t totalNVMerrors = 0, totalSRAMerrors= 0, totalBPerrors = 0, totalMigration = 0;	
	
	if(simu_parameters.printDebug && simu_parameters.enableDatasetSpilling)
	{	/*
		ofstream output_file;
		output_file.open(PREDICTOR_OUTPUT_FILE);	
		for(int i = 0 ; i < m_nb_set ; i++)
		{
			output_file << "Set " << i << "\t";
			for(unsigned j = 0 ; j < stats_SRAMpressure.size() ; j++)
			{
				string a  = stats_SRAMpressure[j][i] ? "High" : "Low";
				output_file << a << ",";
			}
			output_file << endl;
		}
		output_file.close();*/
	}

	for(unsigned i = 0 ; i <  stats_NVM_errors.size(); i++)
	{	
		totalNVMerrors += stats_NVM_errors[i];
		totalSRAMerrors += stats_SRAM_errors[i];
		totalBPerrors += stats_BP_errors[i];
		totalMigration += stats_MigrationErrors[i];
	}
	
	out << entete << ":Predictor:TotalMiss:\t" << stats_total_miss << endl;
	
	if(simu_parameters.simulate_conflicts)
	{
		out << entete << ":Predictor:NVMConflictMiss:\t" << stats_nvm_conflict_miss << endl;
		out << entete << ":Predictor:SRAMConflictMiss:\t" << stats_sram_conflict_miss << endl;
		out << entete << ":Predictor:ColdMiss:\t" << stats_cold_miss << endl;
		out << entete << ":Predictor:CapacityMiss:\t" << stats_capacity_miss << endl;	
	}


	out << entete << ":Predictor:PredictorErrors:" <<endl;
	out << entete << ":Predictor:TotalNVMError\t" << totalNVMerrors << endl;
	out << entete << ":Predictor:NVMError:FromWB\t"  << stats_WBerrors << endl;
	out << entete << ":Predictor:NVMError:FromCore\t" <<  stats_COREerrors << endl;
	out << entete << ":Predictor:TotalMigration\t" <<  totalMigration << endl;
	out << entete << ":Predictor:SRAMError\t" << totalSRAMerrors << endl;
	out << entete << ":Predictor:BPError\t" << totalBPerrors << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r10
movq %rdi, %rbp
movq 0x1e0(%rdi), %rax
movq 0x1e8(%rdi), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq 0x1f8(%rdi), %rdx
movq 0x210(%rdi), %rsi
movq 0x228(%rdi), %rdi
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %r13d, %r13d
xorl %r8d, %r8d
movl %r8d, %r8d
cmpq %r8, %rcx
jbe 0x20408
movslq (%rax,%r8,4), %r9
addq %r9, %rbx
movslq (%rdx,%r8,4), %r9
addq %r9, %r12
movslq (%rsi,%r8,4), %r9
addq %r9, %r15
movslq (%rdi,%r8,4), %r9
addq %r9, %r13
incl %r8d
jmp 0x203df
movq %r10, %rdi
movq %r14, %rsi
movq %r14, (%rsp)
movq %r10, 0x8(%rsp)
callq 0x5290
leaq 0xb528(%rip), %rsi      # 0x2b94b
movq %rax, %rdi
callq 0x52c0
movq 0x1d8(%rbp), %rsi
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5190
leaq 0x1db07(%rip), %rax     # 0x3df50
cmpb $0x0, 0x88(%rax)
movq %rbp, 0x10(%rsp)
je 0x20531
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq (%rsp), %rsi
callq 0x5290
leaq 0xb4ef(%rip), %rsi      # 0x2b962
movq %rax, %rdi
callq 0x52c0
movq 0x10(%rsp), %r14
movq 0x1c0(%r14), %rsi
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq (%rsp), %rsi
callq 0x5290
leaq 0xb4d5(%rip), %rsi      # 0x2b97f
movq %rax, %rdi
callq 0x52c0
movq 0x1c8(%r14), %rsi
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq (%rsp), %rbp
movq %rbp, %rsi
callq 0x5290
leaq 0xb4be(%rip), %rsi      # 0x2b99d
movq %rax, %rdi
callq 0x52c0
movq 0x1d0(%r14), %rsi
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x5290
leaq 0xb4a1(%rip), %rsi      # 0x2b9b3
movq %rax, %rdi
callq 0x52c0
movq 0x1b8(%r14), %rsi
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq (%rsp), %r14
movq %r14, %rsi
callq 0x5290
leaq 0xb481(%rip), %rsi      # 0x2b9cd
movq %rax, %rdi
callq 0x52c0
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5290
leaq 0xb47b(%rip), %rsi      # 0x2b9e9
movq %rax, %rdi
callq 0x52c0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5290
leaq 0xb468(%rip), %rsi      # 0x2ba03
movq %rax, %rdi
callq 0x52c0
movq 0x10(%rsp), %rbx
movq 0x258(%rbx), %rsi
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5290
leaq 0xb44e(%rip), %rsi      # 0x2ba1f
movq %rax, %rdi
callq 0x52c0
movq 0x260(%rbx), %rsi
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5290
leaq 0xb43b(%rip), %rsi      # 0x2ba3d
movq %rax, %rdi
callq 0x52c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5290
leaq 0xb429(%rip), %rsi      # 0x2ba58
movq %rax, %rdi
callq 0x52c0
movq %rax, %rdi
movq %r12, %rsi
callq 0x5200
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
movq %r14, %rsi
callq 0x5290
leaq 0xb412(%rip), %rsi      # 0x2ba6e
movq %rax, %rdi
callq 0x52c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x5200
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5190
nop