// File: sopanpatra160[P]OOO_Superscalar_Processor_Simulator/cache.cc
// Function: cache::print_statistics()
void cache::print_statistics(){
	mr = (((float)num_miss_r+(float)num_miss_w)/((float)num_r+(float)num_w));
	unsigned int num_mem_traff = num_miss_r + num_miss_w + num_wb;
	//printf("\n%s","====== Simulation results (raw) ======\n");
	if(lev==1){
		printf("a. number of L%d reads: %d\n",lev,num_r);
		printf("b. number of L%d read misses: %d\n",lev,num_miss_r);
		printf("c. number of L%d writes: %d\n",lev,num_w);
		printf("d. number of L%d write misses: %d\n",lev,num_miss_w);
		printf("e. L%d miss rate: %.4f\n",lev,mr);
		printf("f. number of swaps:     %d\n",num_swap);
	}
	if(lev==0)
	{
			printf("g. number of victim cache writeback:     %d\n",num_wb_v);


	}

	if(lev==2){
		printf("h. number of L%d reads: %d\n",lev,num_r);
		printf("i. number of L%d read misses: %d\n",lev,num_miss_r);
		printf("j. number of L%d writes: %d\n",lev,num_w);
		printf("k. number of L%d write misses: %d\n",lev,num_miss_w);
		if(cs!=0)
			printf("l. L%d miss rate: %.4f\n",lev,mr);
		else
			printf("l. L%d miss rate: 0\n",lev);
		if(cs!=0)
			printf("m. number of L2 writeback: %d\n",num_wb);
		else
			printf("m. number of L2 writeback: 0\n");
			
		printf("%s %d\n","n. total memory traffic:",num_mem_traff);

	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl 0x80(%rax), %ecx
movl 0x84(%rax), %edx
cvtsi2ss %rdx, %xmm0
movl 0x8c(%rax), %edx
cvtsi2ss %rdx, %xmm1
addss %xmm1, %xmm0
cvtsi2ss %rcx, %xmm1
movl 0x88(%rax), %ecx
cvtsi2ss %rcx, %xmm2
addss %xmm2, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x90(%rax)
movl 0x84(%rax), %ecx
addl 0x8c(%rax), %ecx
addl 0x74(%rax), %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x1, 0x24(%rax)
jne 0x3122
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x80(%rax), %edx
leaq 0x3f84(%rip), %rdi      # 0x7018
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x84(%rax), %edx
leaq 0x3f85(%rip), %rdi      # 0x7034
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x88(%rax), %edx
leaq 0x3f8c(%rip), %rdi      # 0x7056
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x8c(%rax), %edx
leaq 0x3f8e(%rip), %rdi      # 0x7073
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movss 0x90(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3f90(%rip), %rdi      # 0x7096
movb $0x1, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x7c(%rax), %esi
leaq 0x3f93(%rip), %rdi      # 0x70ae
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jne 0x3141
movq -0x18(%rbp), %rax
movl 0x78(%rax), %esi
leaq 0x3f90(%rip), %rdi      # 0x70ca
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
cmpl $0x2, 0x24(%rax)
jne 0x3244
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x80(%rax), %edx
leaq 0x3f94(%rip), %rdi      # 0x70f7
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x84(%rax), %edx
leaq 0x3f95(%rip), %rdi      # 0x7113
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x88(%rax), %edx
leaq 0x3f9c(%rip), %rdi      # 0x7135
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movl 0x8c(%rax), %edx
leaq 0x3f9e(%rip), %rdi      # 0x7152
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x31e8
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
movss 0x90(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3f96(%rip), %rdi      # 0x7175
movb $0x1, %al
callq 0x1040
jmp 0x31fd
movq -0x18(%rbp), %rax
movl 0x24(%rax), %esi
leaq 0x3f97(%rip), %rdi      # 0x718d
movb $0x0, %al
callq 0x1040
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x321e
movq -0x18(%rbp), %rax
movl 0x74(%rax), %esi
leaq 0x3f8d(%rip), %rdi      # 0x71a2
movb $0x0, %al
callq 0x1040
jmp 0x322c
leaq 0x3f9c(%rip), %rdi      # 0x71c1
movb $0x0, %al
callq 0x1040
movl -0xc(%rbp), %edx
leaq 0x3fa9(%rip), %rdi      # 0x71df
leaq 0x3fa9(%rip), %rsi      # 0x71e6
movb $0x0, %al
callq 0x1040
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)