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

	uint64_t total_BP = 0, total_DeadLines = 0;
	for(unsigned i = 0 ; i < stats_nbBPrequests.size() ; i++ )
	{
		total_BP+= stats_nbBPrequests[i];		
		total_DeadLines += stats_nbDeadLine[i];
	}
	/*
	ofstream file(FILE_OUTPUT_Cerebron);	
	for(unsigned i = 0 ; i < stats_histo_value.size() ; i++)
	{
		file << "Feature : " <<  m_criterias_names[i] << endl;
		for(unsigned j = 0 ; j < stats_histo_value[i].size() ; j++)
		{
			file << "Index " << j << "\t";
			for(auto cost : stats_histo_value[i][j])
				file << cost << ", ";
			file << endl;
		}
		
		
		file << "-------------" << endl;
		file << endl;
	}
	
	file.close();
	*/
	out << entete << ":CerebronPredictor:PredictionPreemptive\t" << stats_prediction_preemptive << endl;
	out << entete << ":CerebronPredictor:PredictionConfident\t" << stats_prediction_confident << endl;
	out << entete << ":CerebronPredictor:NBBypass\t" << total_BP << endl;
	out << entete << ":CerebronPredictor:TotalDeadLines\t" << total_DeadLines << endl;
	out << entete << ":CerebronPredictor:SRAMerror\t" << stats_cptSRAMerror << endl;
	out << entete << ":CerebronPredictor:LearningSRAMerror\t" << stats_cptLearningSRAMerror << endl;
	out << entete << ":CerebronPredictor:WrongAlloc\t" << stats_wrong_alloc << endl;
	out << entete << ":CerebronPredictor:CorrectAlloc\t" << stats_good_alloc << endl;
	out << entete << ":CerebronPredictor:TotalMigration\t" << stats_nbMigrations[true] + stats_nbMigrations[false] << endl;
	out << entete << ":CerebronPredictor:MigrationsFromSRAM\t" << stats_nbMigrations[true] << endl;
	out << entete << ":CerebronPredictor:MigrationsFromNVM\t" << stats_nbMigrations[false] << endl;
	
	
	out << entete << ":CerebronPredictor:AccessClassification" << endl;
	for(unsigned i = 0 ; i < stats_access_class.size() ; i++)
	{
		if(stats_access_class[i][0] != 0 || stats_access_class[i][1] != 1)
		{
			out << entete << ":CerebronPredictor:Read" <<  str_RD_status[i]	<< "\t" << stats_access_class[i][false] << endl;	
			out << entete << ":CerebronPredictor:Write" << str_RD_status[i] << "\t" << stats_access_class[i][true] << endl; 		
		}
	}

	Predictor::printStats(out, entete);
}

// Assembly:
subq $0xc8, %rsp
movq %rdx, 0x58(%rsp)
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x60(%rsp)
movq $0x0, 0xa8(%rsp)
movq $0x0, 0xa0(%rsp)
movl $0x0, 0x9c(%rsp)
movq 0x60(%rsp), %rdi
movl 0x9c(%rsp), %eax
movq %rax, 0x50(%rsp)
addq $0x388, %rdi            # imm = 0x388
callq 0xfa40
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jae 0xcaee
movq 0x60(%rsp), %rdi
addq $0x388, %rdi            # imm = 0x388
movl 0x9c(%rsp), %eax
movl %eax, %esi
callq 0xfa20
movq 0x60(%rsp), %rdi
movq (%rax), %rax
addq 0xa8(%rsp), %rax
movq %rax, 0xa8(%rsp)
addq $0x3a0, %rdi            # imm = 0x3A0
movl 0x9c(%rsp), %eax
movl %eax, %esi
callq 0xfa20
movq (%rax), %rax
addq 0xa0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0xca54
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x647db(%rip), %rsi     # 0x712e5
callq 0x5380
movq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x458(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x8648b(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x647c0(%rip), %rsi     # 0x7130e
callq 0x5380
movq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x450(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x86447(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x647a4(%rip), %rsi     # 0x71336
callq 0x5380
movq %rax, %rdi
movq 0xa8(%rsp), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x86407(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x64781(%rip), %rsi     # 0x71353
callq 0x5380
movq %rax, %rdi
movq 0xa0(%rsp), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x863c7(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x64764(%rip), %rsi     # 0x71376
callq 0x5380
movq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x448(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x86383(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x6473e(%rip), %rsi     # 0x71394
callq 0x5380
movq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x440(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x8633f(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x64720(%rip), %rsi     # 0x713ba
callq 0x5380
movq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x438(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x862fb(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x646fb(%rip), %rsi     # 0x713d9
callq 0x5380
movq %rax, %rdi
movq 0x60(%rsp), %rax
movq 0x430(%rax), %rsi
callq 0x50f0
movq %rax, %rdi
movq 0x862b7(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x646d8(%rip), %rsi     # 0x713fa
callq 0x5380
movq 0x60(%rsp), %rdi
movq %rax, 0x38(%rsp)
addq $0x4c0, %rdi            # imm = 0x4C0
movl $0x1, %esi
callq 0xef90
movq 0x60(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x34(%rsp)
addq $0x4c0, %rdi            # imm = 0x4C0
xorl %eax, %eax
movl %eax, %esi
callq 0xef90
movl 0x34(%rsp), %esi
movq 0x38(%rsp), %rdi
addl (%rax), %esi
callq 0x5680
movq %rax, %rdi
movq 0x86241(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x64685(%rip), %rsi     # 0x7141d
callq 0x5380
movq 0x60(%rsp), %rdi
movq %rax, 0x40(%rsp)
addq $0x4c0, %rdi            # imm = 0x4C0
movl $0x1, %esi
callq 0xef90
movq 0x40(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, %rdi
movq 0x861ea(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x64655(%rip), %rsi     # 0x71444
callq 0x5380
movq 0x60(%rsp), %rdi
movq %rax, 0x48(%rsp)
addq $0x4c0, %rdi            # imm = 0x4C0
xorl %eax, %eax
movl %eax, %esi
callq 0xef90
movq 0x48(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, %rdi
movq 0x86194(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x64625(%rip), %rsi     # 0x7146a
callq 0x5380
movq %rax, %rdi
movq 0x86164(%rip), %rsi     # 0x92fb8
callq 0x53d0
movl $0x0, 0x98(%rsp)
movq 0x60(%rsp), %rdi
movl 0x98(%rsp), %eax
movq %rax, 0x28(%rsp)
addq $0x4a8, %rdi            # imm = 0x4A8
callq 0xfb20
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0xd02a
movq 0x60(%rsp), %rdi
addq $0x4a8, %rdi            # imm = 0x4A8
movl 0x98(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xef90
cmpl $0x0, (%rax)
jne 0xceed
movq 0x60(%rsp), %rdi
addq $0x4a8, %rdi            # imm = 0x4A8
movl 0x98(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl $0x1, %esi
callq 0xef90
cmpl $0x1, (%rax)
je 0xd012
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x64589(%rip), %rsi     # 0x71492
callq 0x5380
movq %rax, %rdi
movl 0x98(%rsp), %eax
movl %eax, %ecx
leaq 0x865af(%rip), %rax     # 0x934d0
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, %rdi
leaq 0x65d2f(%rip), %rsi     # 0x72c63
callq 0x5380
movq 0x60(%rsp), %rdi
movq %rax, 0x18(%rsp)
addq $0x4a8, %rdi            # imm = 0x4A8
movl 0x98(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xef90
movq 0x18(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, %rdi
movq 0x8603e(%rip), %rsi     # 0x92fb8
callq 0x53d0
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x5330
movq %rax, %rdi
leaq 0x6450f(%rip), %rsi     # 0x714aa
callq 0x5380
movq %rax, %rdi
movl 0x98(%rsp), %eax
movl %eax, %ecx
leaq 0x8651d(%rip), %rax     # 0x934d0
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, %rdi
leaq 0x65c9d(%rip), %rsi     # 0x72c63
callq 0x5380
movq 0x60(%rsp), %rdi
movq %rax, 0x20(%rsp)
addq $0x4a8, %rdi            # imm = 0x4A8
movl 0x98(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl $0x1, %esi
callq 0xef90
movq 0x20(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, %rdi
movq 0x85fab(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0xd014
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0xce64
movq 0x58(%rsp), %rsi
movq 0xb8(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x78(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x51b0
movq 0x60(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x57bf0
jmp 0xd061
leaq 0x78(%rsp), %rdi
callq 0x5768
addq $0xc8, %rsp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x5768
movq 0x70(%rsp), %rdi
callq 0x5690
nopw %cs:(%rax,%rax)