// File: gvaumour[P]cache-simulator/src/PHC.cc
// Function: PHCPredictor::printStats(std::ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void 
PHCPredictor::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];
	}
	
	uint64_t global_errors = 0;
	for(unsigned i = 0 ; i < stats_global_error.size() ; i++)
	{
		for(unsigned j = 0; j < stats_global_error[i].size(); j++)
			global_errors += stats_global_error[i][j];
	}
	
	vector<int> local_errors = vector<int>(m_features.size() , 0);
	for(unsigned i = 0 ; i < stats_local_error[0].size(); i++)
	{
		for(unsigned j = 0 ; j < stats_local_error.size() ; j++)
			local_errors[j] += stats_local_error[j][i];
	}
	
	out << entete << ":PHCPredictor:PredictionPreemptive\t" << stats_prediction_preemptive << endl;
	out << entete << ":PHCPredictor:PredictionConfident\t" << stats_prediction_confident << endl;
	out << entete << ":PHCPredictor:NBBypass\t" << total_BP << endl;
	out << entete << ":PHCPredictor:TotalDeadLines\t" << total_DeadLines << endl;
	out << entete << ":PHCPredictor:AllocationLearning\t" << stats_allocate_learning << endl;	
	out << entete << ":PHCPredictor:Allocation\t" << stats_allocate_learning + stats_allocate << endl;
	out << entete << ":PHCPredictor:UpdateLearning\t" << stats_update_learning << endl;
	out << entete << ":PHCPredictor:Update\t" << stats_update_learning + stats_update << endl;
	out << entete << ":PHCPredictor:SRAMerror\t" << stats_cptSRAMerror << endl;
	out << entete << ":PHCPredictor:LearningSRAMerror\t" << stats_cptLearningSRAMerror << endl;
	

	out << entete << ":PHCPredictor: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 << ":PHCPredictor:Read" <<  str_RD_status[i]	<< "\t" << stats_access_class[i][false] << endl;	
			out << entete << ":PHCPredictor:Write" << str_RD_status[i] << "\t" << stats_access_class[i][true] << endl; 		
		}
	}
	
	for(unsigned j = 0 ; j < m_features.size() ; j++)
		out << entete << ":PHCPredictor:" << m_criterias_names[j] << "_errors\t" << local_errors[j] << endl;
	out << entete << ":PHCPredictor:GlobalErrors\t" << global_errors << endl; 
	Predictor::printStats(out, entete);
}

// Assembly:
subq $0x298, %rsp            # imm = 0x298
movq %rdx, 0x1e8(%rsp)
movq %rdi, 0x290(%rsp)
movq %rsi, 0x288(%rsp)
movq %rdx, 0x280(%rsp)
movq 0x290(%rsp), %rax
movq %rax, 0x1f0(%rsp)
movq $0x0, 0x278(%rsp)
movq $0x0, 0x270(%rsp)
movl $0x0, 0x26c(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x26c(%rsp), %eax
movq %rax, 0x1e0(%rsp)
addq $0x320, %rdi            # imm = 0x320
callq 0xfa40
movq %rax, %rcx
movq 0x1e0(%rsp), %rax
cmpq %rcx, %rax
jae 0x4bca3
movq 0x1f0(%rsp), %rdi
addq $0x320, %rdi            # imm = 0x320
movl 0x26c(%rsp), %eax
movl %eax, %esi
callq 0xfa20
movq 0x1f0(%rsp), %rdi
movq (%rax), %rax
addq 0x278(%rsp), %rax
movq %rax, 0x278(%rsp)
addq $0x338, %rdi            # imm = 0x338
movl 0x26c(%rsp), %eax
movl %eax, %esi
callq 0xfa20
movq (%rax), %rax
addq 0x270(%rsp), %rax
movq %rax, 0x270(%rsp)
movl 0x26c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x26c(%rsp)
jmp 0x4bbfa
movq $0x0, 0x260(%rsp)
movl $0x0, 0x25c(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x25c(%rsp), %eax
movq %rax, 0x1d8(%rsp)
addq $0x418, %rdi            # imm = 0x418
callq 0xfb20
movq %rax, %rcx
movq 0x1d8(%rsp), %rax
cmpq %rcx, %rax
jae 0x4bdaf
movl $0x0, 0x258(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x258(%rsp), %eax
movq %rax, 0x1d0(%rsp)
addq $0x418, %rdi            # imm = 0x418
movl 0x25c(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
callq 0x11020
movq %rax, %rcx
movq 0x1d0(%rsp), %rax
cmpq %rcx, %rax
jae 0x4bd97
movq 0x1f0(%rsp), %rdi
addq $0x418, %rdi            # imm = 0x418
movl 0x25c(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl 0x258(%rsp), %eax
movl %eax, %esi
callq 0xef90
movslq (%rax), %rax
addq 0x260(%rsp), %rax
movq %rax, 0x260(%rsp)
movl 0x258(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x258(%rsp)
jmp 0x4bcfc
jmp 0x4bd99
movl 0x25c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25c(%rsp)
jmp 0x4bcba
movq 0x1f0(%rsp), %rdi
addq $0x270, %rdi            # imm = 0x270
callq 0xf840
movq %rax, 0x1c0(%rsp)
movl $0x0, 0x23c(%rsp)
leaq 0x23b(%rsp), %rdi
movq %rdi, 0x1c8(%rsp)
callq 0xed30
movq 0x1c0(%rsp), %rsi
movq 0x1c8(%rsp), %rcx
leaq 0x240(%rsp), %rdi
leaq 0x23c(%rsp), %rdx
callq 0xed40
jmp 0x4be12
leaq 0x23b(%rsp), %rdi
callq 0xef60
movl $0x0, 0x228(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x228(%rsp), %eax
movq %rax, 0x1b8(%rsp)
addq $0x400, %rdi            # imm = 0x400
xorl %eax, %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
callq 0x11020
movq %rax, %rcx
movq 0x1b8(%rsp), %rax
cmpq %rcx, %rax
jae 0x4bf5b
movl $0x0, 0x224(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x224(%rsp), %eax
movq %rax, 0x1b0(%rsp)
addq $0x400, %rdi            # imm = 0x400
callq 0xfb20
movq %rax, %rcx
movq 0x1b0(%rsp), %rax
cmpq %rcx, %rax
jae 0x4bf43
movq 0x1f0(%rsp), %rdi
addq $0x400, %rdi            # imm = 0x400
movl 0x224(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl 0x228(%rsp), %eax
movl %eax, %esi
callq 0xef90
movl (%rax), %eax
movl %eax, 0x1ac(%rsp)
movl 0x224(%rsp), %eax
movl %eax, %esi
leaq 0x240(%rsp), %rdi
callq 0xef90
movl 0x1ac(%rsp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl 0x224(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x224(%rsp)
jmp 0x4be78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
leaq 0x23b(%rsp), %rdi
callq 0xef60
jmp 0x4c8d8
jmp 0x4bf45
movl 0x228(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x228(%rsp)
jmp 0x4be2a
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x1a0(%rsp)
jmp 0x4bf7a
movq 0x1a0(%rsp), %rdi
leaq 0x271f0(%rip), %rsi     # 0x73179
callq 0x5380
movq %rax, 0x198(%rsp)
jmp 0x4bf98
movq 0x198(%rsp), %rdi
movq 0x1f0(%rsp), %rax
movq 0x3e0(%rax), %rsi
callq 0x50f0
movq %rax, 0x190(%rsp)
jmp 0x4bfbe
movq 0x190(%rsp), %rdi
movq 0x46feb(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4bfd4
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x188(%rsp)
jmp 0x4bff3
movq 0x188(%rsp), %rdi
leaq 0x2719b(%rip), %rsi     # 0x7319d
callq 0x5380
movq %rax, 0x180(%rsp)
jmp 0x4c011
movq 0x180(%rsp), %rdi
movq 0x1f0(%rsp), %rax
movq 0x3d8(%rax), %rsi
callq 0x50f0
movq %rax, 0x178(%rsp)
jmp 0x4c037
movq 0x178(%rsp), %rdi
movq 0x46f72(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c04d
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x170(%rsp)
jmp 0x4c06c
movq 0x170(%rsp), %rdi
leaq 0x27145(%rip), %rsi     # 0x731c0
callq 0x5380
movq %rax, 0x168(%rsp)
jmp 0x4c08a
movq 0x168(%rsp), %rdi
movq 0x278(%rsp), %rsi
callq 0x50f0
movq %rax, 0x160(%rsp)
jmp 0x4c0a9
movq 0x160(%rsp), %rdi
movq 0x46f00(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c0bf
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x158(%rsp)
jmp 0x4c0de
movq 0x158(%rsp), %rdi
leaq 0x270eb(%rip), %rsi     # 0x731d8
callq 0x5380
movq %rax, 0x150(%rsp)
jmp 0x4c0fc
movq 0x150(%rsp), %rdi
movq 0x270(%rsp), %rsi
callq 0x50f0
movq %rax, 0x148(%rsp)
jmp 0x4c11b
movq 0x148(%rsp), %rdi
movq 0x46e8e(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c131
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x140(%rsp)
jmp 0x4c150
movq 0x140(%rsp), %rdi
leaq 0x27097(%rip), %rsi     # 0x731f6
callq 0x5380
movq %rax, 0x138(%rsp)
jmp 0x4c16e
movq 0x138(%rsp), %rdi
movq 0x1f0(%rsp), %rax
movq 0x3c0(%rax), %rsi
callq 0x50f0
movq %rax, 0x130(%rsp)
jmp 0x4c194
movq 0x130(%rsp), %rdi
movq 0x46e15(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c1aa
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x128(%rsp)
jmp 0x4c1c9
movq 0x128(%rsp), %rdi
leaq 0x27040(%rip), %rsi     # 0x73218
callq 0x5380
movq %rax, 0x120(%rsp)
jmp 0x4c1e7
movq 0x120(%rsp), %rdi
movq 0x1f0(%rsp), %rcx
movq 0x3b8(%rcx), %rax
movq 0x3c0(%rcx), %rsi
addq %rax, %rsi
callq 0x50f0
movq %rax, 0x118(%rsp)
jmp 0x4c217
movq 0x118(%rsp), %rdi
movq 0x46d92(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c22d
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x110(%rsp)
jmp 0x4c24c
movq 0x110(%rsp), %rdi
leaq 0x26fd7(%rip), %rsi     # 0x73232
callq 0x5380
movq %rax, 0x108(%rsp)
jmp 0x4c26a
movq 0x108(%rsp), %rdi
movq 0x1f0(%rsp), %rax
movq 0x3b0(%rax), %rsi
callq 0x50f0
movq %rax, 0x100(%rsp)
jmp 0x4c290
movq 0x100(%rsp), %rdi
movq 0x46d19(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c2a6
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0xf8(%rsp)
jmp 0x4c2c5
movq 0xf8(%rsp), %rdi
leaq 0x26f7c(%rip), %rsi     # 0x73250
callq 0x5380
movq %rax, 0xf0(%rsp)
jmp 0x4c2e3
movq 0xf0(%rsp), %rdi
movq 0x1f0(%rsp), %rcx
movq 0x3a8(%rcx), %rax
movq 0x3b0(%rcx), %rsi
addq %rax, %rsi
callq 0x50f0
movq %rax, 0xe8(%rsp)
jmp 0x4c313
movq 0xe8(%rsp), %rdi
movq 0x46c96(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c329
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0xe0(%rsp)
jmp 0x4c348
movq 0xe0(%rsp), %rdi
leaq 0x26f0f(%rip), %rsi     # 0x73266
callq 0x5380
movq %rax, 0xd8(%rsp)
jmp 0x4c366
movq 0xd8(%rsp), %rdi
movq 0x1f0(%rsp), %rax
movq 0x3d0(%rax), %rsi
callq 0x50f0
movq %rax, 0xd0(%rsp)
jmp 0x4c38c
movq 0xd0(%rsp), %rdi
movq 0x46c1d(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c3a2
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0xc8(%rsp)
jmp 0x4c3c1
movq 0xc8(%rsp), %rdi
leaq 0x26eaf(%rip), %rsi     # 0x7327f
callq 0x5380
movq %rax, 0xc0(%rsp)
jmp 0x4c3df
movq 0xc0(%rsp), %rdi
movq 0x1f0(%rsp), %rax
movq 0x3c8(%rax), %rsi
callq 0x50f0
movq %rax, 0xb8(%rsp)
jmp 0x4c405
movq 0xb8(%rsp), %rdi
movq 0x46ba4(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c41b
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0xb0(%rsp)
jmp 0x4c43a
movq 0xb0(%rsp), %rdi
leaq 0x26e57(%rip), %rsi     # 0x732a0
callq 0x5380
movq %rax, 0xa8(%rsp)
jmp 0x4c458
movq 0xa8(%rsp), %rdi
movq 0x46b51(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c46e
movl $0x0, 0x220(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x220(%rsp), %eax
movq %rax, 0xa0(%rsp)
addq $0x430, %rdi            # imm = 0x430
callq 0xfb20
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
jae 0x4c6dd
movq 0x1f0(%rsp), %rdi
addq $0x430, %rdi            # imm = 0x430
movl 0x220(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xef90
cmpl $0x0, (%rax)
jne 0x4c511
movq 0x1f0(%rsp), %rdi
addq $0x430, %rdi            # imm = 0x430
movl 0x220(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl $0x1, %esi
callq 0xef90
cmpl $0x1, (%rax)
je 0x4c6c5
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x98(%rsp)
jmp 0x4c530
movq 0x98(%rsp), %rdi
leaq 0x26d84(%rip), %rsi     # 0x732c3
callq 0x5380
movq %rax, 0x90(%rsp)
jmp 0x4c54e
movq 0x90(%rsp), %rdi
movl 0x220(%rsp), %eax
movl %eax, %ecx
leaq 0x46f6a(%rip), %rax     # 0x934d0
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, 0x88(%rsp)
jmp 0x4c579
movq 0x88(%rsp), %rdi
leaq 0x266db(%rip), %rsi     # 0x72c63
callq 0x5380
movq %rax, 0x80(%rsp)
jmp 0x4c597
movq 0x1f0(%rsp), %rdi
addq $0x430, %rdi            # imm = 0x430
movl 0x220(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xef90
movq 0x80(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, 0x78(%rsp)
jmp 0x4c5d6
movq 0x78(%rsp), %rdi
movq 0x469d6(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c5e9
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x70(%rsp)
jmp 0x4c605
movq 0x70(%rsp), %rdi
leaq 0x26cc5(%rip), %rsi     # 0x732d6
callq 0x5380
movq %rax, 0x68(%rsp)
jmp 0x4c61d
movq 0x68(%rsp), %rdi
movl 0x220(%rsp), %eax
movl %eax, %ecx
leaq 0x46e9e(%rip), %rax     # 0x934d0
movq (%rax,%rcx,8), %rsi
callq 0x5380
movq %rax, 0x60(%rsp)
jmp 0x4c642
movq 0x60(%rsp), %rdi
leaq 0x26615(%rip), %rsi     # 0x72c63
callq 0x5380
movq %rax, 0x58(%rsp)
jmp 0x4c65a
movq 0x1f0(%rsp), %rdi
addq $0x430, %rdi            # imm = 0x430
movl 0x220(%rsp), %eax
movl %eax, %esi
callq 0xef70
movq %rax, %rdi
movl $0x1, %esi
callq 0xef90
movq 0x58(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, 0x50(%rsp)
jmp 0x4c697
movq 0x50(%rsp), %rdi
movq 0x46915(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c6aa
jmp 0x4c6c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
jmp 0x4c8cb
jmp 0x4c6c7
movl 0x220(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x220(%rsp)
jmp 0x4c479
movl $0x0, 0x21c(%rsp)
movq 0x1f0(%rsp), %rdi
movl 0x21c(%rsp), %eax
movq %rax, 0x48(%rsp)
addq $0x270, %rdi            # imm = 0x270
callq 0xf840
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0x4c7ea
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x40(%rsp)
jmp 0x4c735
movq 0x40(%rsp), %rdi
leaq 0x26ba9(%rip), %rsi     # 0x732ea
callq 0x5380
movq %rax, 0x38(%rsp)
jmp 0x4c74d
movq 0x1f0(%rsp), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
movl 0x21c(%rsp), %eax
movl %eax, %esi
callq 0xfd00
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x5330
movq %rax, 0x30(%rsp)
jmp 0x4c77e
movq 0x30(%rsp), %rdi
leaq 0x255ab(%rip), %rsi     # 0x71d35
callq 0x5380
movq %rax, 0x28(%rsp)
jmp 0x4c796
movl 0x21c(%rsp), %eax
movl %eax, %esi
leaq 0x240(%rsp), %rdi
callq 0xef90
movq 0x28(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, 0x20(%rsp)
jmp 0x4c7bf
movq 0x20(%rsp), %rdi
movq 0x467ed(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c7d2
jmp 0x4c7d4
movl 0x21c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x21c(%rsp)
jmp 0x4c6e8
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rdi
callq 0x5330
movq %rax, 0x18(%rsp)
jmp 0x4c806
movq 0x18(%rsp), %rdi
leaq 0x26ae7(%rip), %rsi     # 0x732f9
callq 0x5380
movq %rax, 0x10(%rsp)
jmp 0x4c81e
movq 0x10(%rsp), %rdi
movq 0x260(%rsp), %rsi
callq 0x50f0
movq %rax, 0x8(%rsp)
jmp 0x4c837
movq 0x8(%rsp), %rdi
movq 0x46775(%rip), %rsi     # 0x92fb8
callq 0x53d0
jmp 0x4c84a
movq 0x1e8(%rsp), %rsi
movq 0x288(%rsp), %rax
movq %rax, (%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x51b0
jmp 0x4c86d
movq (%rsp), %rsi
movq 0x1f0(%rsp), %rdi
leaq 0x1f8(%rsp), %rdx
callq 0x57bf0
jmp 0x4c888
leaq 0x1f8(%rsp), %rdi
callq 0x5768
leaq 0x240(%rsp), %rdi
callq 0xef00
addq $0x298, %rsp            # imm = 0x298
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x5768
leaq 0x240(%rsp), %rdi
callq 0xef00
movq 0x230(%rsp), %rdi
callq 0x5690
nopw %cs:(%rax,%rax)