// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x58(%rdi), %r12
movq 0x5efa(%rip), %r14      # 0x9fd8
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq %rax, %r15
leaq 0x302f(%rip), %rsi      # 0x713e
movl $0x22, %edx
movq %rax, %rdi
callq 0x2190
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x3017(%rip), %rsi      # 0x7161
movl $0x17, %edx
movq %r14, %rdi
callq 0x2190
testq %r12, %r12
je 0x42ca
movq 0x58(%rbx), %rax
movq 0x30(%rax), %rsi
movq %r14, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2fd8(%rip), %rsi      # 0x7179
movl $0x34, %edx
movq %r14, %rdi
callq 0x2190
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2fc4(%rip), %rsi      # 0x71ae
movl $0x37, %edx
movq %r14, %rdi
callq 0x2190
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2fb2(%rip), %rsi      # 0x71e6
movl $0x2a, %edx
movq %r14, %rdi
callq 0x2190
movq 0x58(%rbx), %rax
movq 0x28(%rax), %rsi
movq %r14, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2f91(%rip), %rsi      # 0x7213
movl $0x17, %edx
movq %r14, %rdi
callq 0x2190
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl $0xfffffefb, %edx       # imm = 0xFFFFFEFB
andl 0x18(%r14,%rcx), %edx
orl $0x4, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0x2, 0x8(%r14,%rax)
movq 0x8(%rbx), %rax
movq 0x58(%rbx), %rbx
addq 0x28(%rbx), %rax
addq $0x30, %rbx
jmp 0x441f
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2e73(%rip), %rsi      # 0x7179
movl $0x34, %edx
movq %r14, %rdi
callq 0x2190
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2e5f(%rip), %rsi      # 0x71ae
movl $0x37, %edx
movq %r14, %rdi
callq 0x2190
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2e4d(%rip), %rsi      # 0x71e6
movl $0x2a, %edx
movq %r14, %rdi
callq 0x2190
leaq 0x2e64(%rip), %rsi      # 0x7211
movl $0x1, %edx
movq %r14, %rdi
callq 0x2190
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x2e2b(%rip), %rsi      # 0x7213
movl $0x17, %edx
movq %r14, %rdi
callq 0x2190
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl $0xfffffefb, %edx       # imm = 0xFFFFFEFB
andl 0x18(%r14,%rcx), %edx
orl $0x4, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0x2, 0x8(%r14,%rax)
movq 0x8(%rbx), %rax
cvtsi2ss %rax, %xmm0
cvtsi2ssq (%rbx), %xmm1
divss %xmm1, %xmm0
mulss 0x2ce3(%rip), %xmm0     # 0x7118
cvtss2sd %xmm0, %xmm0
movq 0x5b98(%rip), %rdi      # 0x9fd8
callq 0x2220
movq %rax, %rbx
leaq 0x2ddc(%rip), %rsi      # 0x722b
movl $0x8, %edx
movq %rax, %rdi
callq 0x2190
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x20e0