// File: 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:
subq $0x58, %rsp
movq %rdx, 0x8(%rsp)
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x3c3b3(%rip), %rax     # 0x93ff0
testb $0x1, (%rax)
je 0x57c54
leaq 0x3c3a7(%rip), %rax     # 0x93ff0
testb $0x1, 0x158(%rax)
je 0x57c54
jmp 0x57c54
movl $0x0, 0x1c(%rsp)
movq 0x10(%rsp), %rdi
movl 0x1c(%rsp), %eax
movq %rax, (%rsp)
addq $0x1e0, %rdi            # imm = 0x1E0
callq 0x11020
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jae 0x57d25
movq 0x10(%rsp), %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movl 0x1c(%rsp), %eax
movl %eax, %esi
callq 0xef90
movq 0x10(%rsp), %rdi
movslq (%rax), %rax
addq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
addq $0x1f8, %rdi            # imm = 0x1F8
movl 0x1c(%rsp), %eax
movl %eax, %esi
callq 0xef90
movq 0x10(%rsp), %rdi
movslq (%rax), %rax
addq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
addq $0x210, %rdi            # imm = 0x210
movl 0x1c(%rsp), %eax
movl %eax, %esi
callq 0xef90
movq 0x10(%rsp), %rdi
movslq (%rax), %rax
addq 0x28(%rsp), %rax
movq %rax, 0x28(%rsp)
addq $0x228, %rdi            # imm = 0x228
movl 0x1c(%rsp), %eax
movl %eax, %esi
callq 0xef90
movslq (%rax), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x57c5c
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bc28(%rip), %rsi     # 0x73966
callq 0x5380
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x1d8(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b257(%rip), %rsi     # 0x92fb8
callq 0x53d0
leaq 0x3c283(%rip), %rax     # 0x93ff0
testb $0x1, 0x88(%rax)
je 0x57e7e
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bbea(%rip), %rsi     # 0x7397d
callq 0x5380
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x1c0(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b202(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bbc6(%rip), %rsi     # 0x7399a
callq 0x5380
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x1c8(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b1c1(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bba3(%rip), %rsi     # 0x739b8
callq 0x5380
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x1d0(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b180(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bb78(%rip), %rsi     # 0x739ce
callq 0x5380
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x1b8(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b13f(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bb51(%rip), %rsi     # 0x739e8
callq 0x5380
movq %rax, %rdi
movq 0x3b112(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bb40(%rip), %rsi     # 0x73a04
callq 0x5380
movq %rax, %rdi
movq 0x38(%rsp), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b0d8(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bb20(%rip), %rsi     # 0x73a1e
callq 0x5380
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x258(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b097(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bafb(%rip), %rsi     # 0x73a3a
callq 0x5380
movq %rax, %rdi
movq 0x10(%rsp), %rax
movq 0x260(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b056(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bad8(%rip), %rsi     # 0x73a58
callq 0x5380
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3b01c(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1bab9(%rip), %rsi     # 0x73a73
callq 0x5380
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3afe2(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x8(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x1ba95(%rip), %rsi     # 0x73a89
callq 0x5380
movq %rax, %rdi
movq 0x28(%rsp), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x3afa8(%rip), %rsi     # 0x92fb8
callq 0x53d0
addq $0x58, %rsp
retq
nopw (%rax,%rax)