// File: /workspace/github_cpp_makefile_star2_O2/chinmayachaudhry[P]Branch-Predictor/bimodal.cpp
// Function: bimodal::print_stats()
void bimodal :: print_stats()
{
	if(branch_buffer == NULL)
	{
		cout << endl << "Final Branch Predictor Statistics:" << endl;
		cout << "a. Number of branches: " << predictions << endl;
		cout << "b. Number of predictions from the branch predictor: " << predictions << endl;
		cout << "c. Number of mispredictions from the branch predictor: " << mispredictions << endl;
		cout << "d. Number of mispredictions from the BTB: " << "0" << endl;
		cout << "e. Misprediction Rate: " << fixed << setprecision(2) << (float)((mispredictions)/(float)(predictions))*100 << " percent" << endl;
	}
	else
	{
		cout << endl << "Final Branch Predictor Statistics:" << endl;
		cout << "a. Number of branches: " << branch_buffer->get_branch_count() << endl;
		cout << "b. Number of predictions from the branch predictor: " << predictions << endl;
		cout << "c. Number of mispredictions from the branch predictor: " << mispredictions << endl;
		cout << "d. Number of mispredictions from the BTB: " << branch_buffer->getMispredictions() << endl;
		cout << "e. Misprediction Rate: " << fixed << setprecision(2) << (float)((branch_buffer->getMispredictions() + mispredictions)/(float)(branch_buffer->get_branch_count()))*100 << " percent" << endl;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x58(%rdi), %r15
movq 0x4857(%rip), %r14      # 0x7fd8
movq %r14, %rdi
callq 0x20d0
leaq 0x19ae(%rip), %rsi      # 0x513e
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
leaq 0x19ba(%rip), %rsi      # 0x5161
movq %r14, %rdi
callq 0x2180
testq %r15, %r15
je 0x388b
movq 0x58(%rbx), %rcx
movq 0x30(%rcx), %rsi
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x20d0
movq 0x4801(%rip), %r14      # 0x7fd8
leaq 0x199b(%rip), %rsi      # 0x5179
movq %r14, %rdi
callq 0x2180
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x20d0
leaq 0x19ae(%rip), %rsi      # 0x51ae
movq %r14, %rdi
callq 0x2180
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x20d0
leaq 0x19c3(%rip), %rsi      # 0x51e6
movq %r14, %rdi
callq 0x2180
movq 0x58(%rbx), %rcx
movq 0x28(%rcx), %rsi
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x20d0
leaq 0x19c9(%rip), %rsi      # 0x5213
movq %r14, %rdi
callq 0x2180
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl $0xfffffefb, %esi       # imm = 0xFFFFFEFB
andl 0x18(%rax,%rdx), %esi
orl $0x4, %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x2, 0x8(%rax,%rcx)
movq 0x8(%rbx), %rcx
movq 0x58(%rbx), %rbx
addq 0x28(%rbx), %rcx
addq $0x30, %rbx
jmp 0x3947
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x20d0
movq 0x4733(%rip), %r14      # 0x7fd8
leaq 0x18cd(%rip), %rsi      # 0x5179
movq %r14, %rdi
callq 0x2180
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x20d0
leaq 0x18e0(%rip), %rsi      # 0x51ae
movq %r14, %rdi
callq 0x2180
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x2090
movq %rax, %rdi
callq 0x20d0
leaq 0x18f5(%rip), %rsi      # 0x51e6
movq %r14, %rdi
callq 0x2180
leaq 0x1911(%rip), %rsi      # 0x5211
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
leaq 0x18fc(%rip), %rsi      # 0x5213
movq %r14, %rdi
callq 0x2180
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl $0xfffffefb, %esi       # imm = 0xFFFFFEFB
andl 0x18(%rax,%rdx), %esi
orl $0x4, %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x2, 0x8(%rax,%rcx)
movq 0x8(%rbx), %rcx
cvtsi2ss %rcx, %xmm0
cvtsi2ssq (%rbx), %xmm1
divss %xmm1, %xmm0
mulss 0x17bb(%rip), %xmm0     # 0x5118
movq %rax, %rdi
callq 0x2120
leaq 0x18bf(%rip), %rsi      # 0x522b
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x20d0
nop