// File: /workspace/github_c_makefile_star2_O2/mvermeulen[P]wspy/topdown.c
// Function: print_l3cache
void print_l3cache(struct counter_group *cgroup,enum output_format oformat){
  struct counter_info *cinfo;
  unsigned long l3_access=0, l3_miss=0;
  unsigned long instructions = 0;

  if (oformat == PRINT_CSV_HEADER){
    fprintf(outfile,"l3miss,");
    return;
  }  

  switch(cpu_info->vendor){
  case VENDOR_INTEL:
    break;
  case VENDOR_AMD:
    if (cinfo = find_ci_label(cgroup,"instructions"))
      instructions = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"l3_lookup_state.all_coherent_accesses_to_l3"))
      l3_access = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"l3_lookup_state.l3_miss"))
      l3_miss = cinfo->value;

    if (csvflag){
      fprintf(outfile,"%4.2f%%,",(double) l3_miss / l3_access * 100.0);
    } else {
      fprintf(outfile,"instructions         %-14lu # %4.3f l3 access per 1000 inst\n",
	      instructions,(double) l3_access / instructions*1000.0);
      fprintf(outfile,"l3 access            %-14lu # %4.3f l3 access per 1000 inst\n",
	      l3_access, (double) l3_access / instructions*1000.0);
      fprintf(outfile,"l3 miss              %-14lu # %4.2f%% l3 miss\n",
	      l3_miss, (double) l3_miss / l3_access * 100.0);
    }
    break;    
  default:
    return;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x2, %esi
jne 0x7ce2
leaq 0x9446(%rip), %rax      # 0x11108
movq (%rax), %rcx
leaq 0x4a6d(%rip), %rdi      # 0xc739
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x32d0
leaq 0xa487(%rip), %rax      # 0x12170
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x7d0b
movq %rdi, %r15
leaq 0x32d9(%rip), %rsi      # 0xafd4
callq 0x576f
testq %rax, %rax
je 0x7d17
movq 0x30(%rax), %r14
jmp 0x7d1a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r14d, %r14d
leaq 0x3613(%rip), %rsi      # 0xb334
movq %r15, %rdi
callq 0x576f
testq %rax, %rax
je 0x7d34
movq 0x30(%rax), %rbx
jmp 0x7d36
xorl %ebx, %ebx
leaq 0x365a(%rip), %rsi      # 0xb397
movq %r15, %rdi
callq 0x576f
testq %rax, %rax
je 0x7d50
movq 0x30(%rax), %r15
jmp 0x7d53
xorl %r15d, %r15d
leaq 0x938e(%rip), %rax      # 0x110e8
cmpl $0x0, (%rax)
leaq 0x93a4(%rip), %r12      # 0x11108
movq (%r12), %rdi
je 0x7dd1
movq %r15, %xmm1
movq 0x2bc9(%rip), %xmm2     # 0xa940
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x2bcd(%rip), %xmm3     # 0xa950
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rbx, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
mulsd 0x2b10(%rip), %xmm0     # 0xa8c8
leaq 0x4719(%rip), %rsi      # 0xc4d8
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x31c0
movq %rbx, %xmm0
movq 0x2b62(%rip), %xmm2     # 0xa940
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x2b66(%rip), %xmm3     # 0xa950
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, %xmm4
movapd %xmm1, 0x10(%rsp)
movq %r14, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm4, %xmm0
divsd %xmm1, %xmm0
mulsd 0x2afb(%rip), %xmm0     # 0xa928
movapd %xmm0, (%rsp)
leaq 0x4908(%rip), %rsi      # 0xc741
movq %r14, %rdx
movb $0x1, %al
callq 0x31c0
movq (%r12), %rdi
leaq 0x4930(%rip), %rsi      # 0xc77e
movq %rbx, %rdx
movaps (%rsp), %xmm0
movb $0x1, %al
callq 0x31c0
movq (%r12), %rdi
movq %r15, %xmm1
punpckldq 0x2ad3(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2adb(%rip), %xmm1     # 0xa950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x10(%rsp), %xmm0
mulsd 0x2a39(%rip), %xmm0     # 0xa8c8
leaq 0x4925(%rip), %rsi      # 0xc7bb
movq %r15, %rdx
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x31c0