// File: 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 %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, 0x58(%rax)
jne 0x502e
movq 0x8122(%rip), %rdi      # 0xcfd8
movq 0x810b(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq %rax, %rdi
leaq 0x4286(%rip), %rsi      # 0x9152
callq 0x21b0
movq %rax, %rdi
movq 0x80ed(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x80f1(%rip), %rdi      # 0xcfd8
leaq 0x4287(%rip), %rsi      # 0x9175
callq 0x21b0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x2100
movq %rax, %rdi
movq 0x80bc(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x80c0(%rip), %rdi      # 0xcfd8
leaq 0x426e(%rip), %rsi      # 0x918d
callq 0x21b0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x2100
movq %rax, %rdi
movq 0x808b(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x808f(%rip), %rdi      # 0xcfd8
leaq 0x4272(%rip), %rsi      # 0x91c2
callq 0x21b0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2100
movq %rax, %rdi
movq 0x8059(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x805d(%rip), %rdi      # 0xcfd8
leaq 0x4278(%rip), %rsi      # 0x91fa
callq 0x21b0
movq %rax, %rdi
leaq 0x4294(%rip), %rsi      # 0x9225
callq 0x21b0
movq %rax, %rdi
movq 0x8028(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x802c(%rip), %rdi      # 0xcfd8
leaq 0x4274(%rip), %rsi      # 0x9227
callq 0x21b0
movq %rax, %rdi
leaq 0x48e(%rip), %rsi       # 0x5450
callq 0x20a0
movq %rax, -0x20(%rbp)
movl $0x2, %edi
callq 0x5480
movq -0x20(%rbp), %rdi
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %esi
callq 0x2320
movq %rax, %rdi
movq -0x18(%rbp), %rax
cvtsi2ssq 0x8(%rax), %xmm0
cvtsi2ssq (%rax), %xmm1
divss %xmm1, %xmm0
movss 0x412a(%rip), %xmm1     # 0x912c
mulss %xmm1, %xmm0
callq 0x2150
movq %rax, %rdi
leaq 0x422a(%rip), %rsi      # 0x923f
callq 0x21b0
movq %rax, %rdi
movq 0x7fa4(%rip), %rsi      # 0xcfc8
callq 0x21e0
jmp 0x51f8
movq 0x7fa3(%rip), %rdi      # 0xcfd8
movq 0x7f8c(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq %rax, %rdi
leaq 0x4107(%rip), %rsi      # 0x9152
callq 0x21b0
movq %rax, %rdi
movq 0x7f6e(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x7f72(%rip), %rdi      # 0xcfd8
leaq 0x4108(%rip), %rsi      # 0x9175
callq 0x21b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, -0x48(%rbp)
movq 0x58(%rax), %rdi
callq 0x54a0
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x2100
movq %rax, %rdi
movq 0x7f2c(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x7f30(%rip), %rdi      # 0xcfd8
leaq 0x40de(%rip), %rsi      # 0x918d
callq 0x21b0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x2100
movq %rax, %rdi
movq 0x7efb(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x7eff(%rip), %rdi      # 0xcfd8
leaq 0x40e2(%rip), %rsi      # 0x91c2
callq 0x21b0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2100
movq %rax, %rdi
movq 0x7ec9(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x7ecd(%rip), %rdi      # 0xcfd8
leaq 0x40e8(%rip), %rsi      # 0x91fa
callq 0x21b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq 0x58(%rax), %rdi
callq 0x54c0
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x2100
movq %rax, %rdi
movq 0x7e87(%rip), %rsi      # 0xcfc8
callq 0x21e0
movq 0x7e8b(%rip), %rdi      # 0xcfd8
leaq 0x40d3(%rip), %rsi      # 0x9227
callq 0x21b0
movq %rax, %rdi
leaq 0x2ed(%rip), %rsi       # 0x5450
callq 0x20a0
movq %rax, -0x38(%rbp)
movl $0x2, %edi
callq 0x5480
movq -0x38(%rbp), %rdi
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %esi
callq 0x2320
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq 0x58(%rax), %rdi
callq 0x54c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
addq 0x8(%rax), %rcx
cvtsi2ss %rcx, %xmm0
movss %xmm0, -0x2c(%rbp)
movq 0x58(%rax), %rdi
callq 0x54a0
movss -0x2c(%rbp), %xmm0
movq -0x28(%rbp), %rdi
cvtsi2ss %rax, %xmm1
divss %xmm1, %xmm0
movss 0x3f5b(%rip), %xmm1     # 0x912c
mulss %xmm1, %xmm0
callq 0x2150
movq %rax, %rdi
leaq 0x405b(%rip), %rsi      # 0x923f
callq 0x21b0
movq %rax, %rdi
movq 0x7dd5(%rip), %rsi      # 0xcfc8
callq 0x21e0
addq $0x50, %rsp
popq %rbp
retq
nop