// File: /workspace/github_c_makefile_star2_O1/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 0x7e37
leaq 0xa2e5(%rip), %rax      # 0x120f8
movq (%rax), %rcx
leaq 0x591c(%rip), %rdi      # 0xd739
movl $0x7, %esi
movl $0x1, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x32c0
leaq 0xb322(%rip), %rax      # 0x13160
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x7e60
movq %rdi, %r15
leaq 0x4184(%rip), %rsi      # 0xbfd4
callq 0x587d
testq %rax, %rax
je 0x7e6c
movq 0x30(%rax), %r14
jmp 0x7e6f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r14d, %r14d
leaq 0x44be(%rip), %rsi      # 0xc334
movq %r15, %rdi
callq 0x587d
testq %rax, %rax
je 0x7e89
movq 0x30(%rax), %rbx
jmp 0x7e8b
xorl %ebx, %ebx
leaq 0x4505(%rip), %rsi      # 0xc397
movq %r15, %rdi
callq 0x587d
testq %rax, %rax
je 0x7ea5
movq 0x30(%rax), %r15
jmp 0x7ea8
xorl %r15d, %r15d
leaq 0xa229(%rip), %rax      # 0x120d8
cmpl $0x0, (%rax)
leaq 0xa23f(%rip), %r12      # 0x120f8
movq (%r12), %rdi
je 0x7f26
movq %r15, %xmm1
movq 0x3a74(%rip), %xmm2     # 0xb940
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x3a78(%rip), %xmm3     # 0xb950
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 0x39bb(%rip), %xmm0     # 0xb8c8
leaq 0x55c4(%rip), %rsi      # 0xd4d8
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x31c0
movq %rbx, %xmm0
movq 0x3a0d(%rip), %xmm2     # 0xb940
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x3a11(%rip), %xmm3     # 0xb950
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 0x39a6(%rip), %xmm0     # 0xb928
movapd %xmm0, (%rsp)
leaq 0x57b3(%rip), %rsi      # 0xd741
movq %r14, %rdx
movb $0x1, %al
callq 0x31c0
movq (%r12), %rdi
leaq 0x57db(%rip), %rsi      # 0xd77e
movq %rbx, %rdx
movaps (%rsp), %xmm0
movb $0x1, %al
callq 0x31c0
movq (%r12), %rdi
movq %r15, %xmm1
punpckldq 0x397e(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3986(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x10(%rsp), %xmm0
mulsd 0x38e4(%rip), %xmm0     # 0xb8c8
leaq 0x57d0(%rip), %rsi      # 0xd7bb
movq %r15, %rdx
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x31c0