// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpl $0x2, -0xc(%rbp)
jne 0x9fea
leaq 0x9134(%rip), %rax      # 0x13108
movq (%rax), %rdi
leaq 0x574d(%rip), %rsi      # 0xf72b
movb $0x0, %al
callq 0x31d0
jmp 0xa240
leaq 0xa17f(%rip), %rax      # 0x14170
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
subl $0x1, %eax
je 0xa013
jmp 0xa000
movl -0x34(%rbp), %eax
subl $0x2, %eax
jne 0xa23e
jmp 0xa00e
jmp 0xa240
movq -0x8(%rbp), %rdi
leaq 0x3fa6(%rip), %rsi      # 0xdfc4
callq 0x6930
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0xa039
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x42e0(%rip), %rsi      # 0xe324
callq 0x6930
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0xa05f
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x431d(%rip), %rsi      # 0xe387
callq 0x6930
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0xa085
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
leaq 0x905c(%rip), %rax      # 0x130e8
cmpl $0x0, (%rax)
je 0xa0fd
leaq 0x9070(%rip), %rax      # 0x13108
movq (%rax), %rdi
movq -0x28(%rbp), %xmm0
movaps 0x3889(%rip), %xmm3     # 0xd930
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x388d(%rip), %xmm2     # 0xd940
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x20(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x37ca(%rip), %xmm1     # 0xd8b0
mulsd %xmm1, %xmm0
leaq 0x53d9(%rip), %rsi      # 0xf4ca
movb $0x1, %al
callq 0x31d0
jmp 0xa23c
leaq 0x9004(%rip), %rax      # 0x13108
movq %rax, -0x40(%rbp)
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %xmm0
movaps 0x3815(%rip), %xmm3     # 0xd930
movaps %xmm3, -0x60(%rbp)
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x3815(%rip), %xmm2     # 0xd940
movaps %xmm2, -0x50(%rbp)
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq %rdx, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x37ae(%rip), %xmm1     # 0xd910
movsd %xmm1, -0x70(%rbp)
mulsd %xmm1, %xmm0
leaq 0x55c1(%rip), %rsi      # 0xf733
movb $0x1, %al
movb %al, -0x61(%rbp)
callq 0x31d0
movsd -0x70(%rbp), %xmm1
movq -0x40(%rbp), %rcx
movaps -0x60(%rbp), %xmm4
movaps -0x50(%rbp), %xmm3
movb -0x61(%rbp), %al
movq (%rcx), %rdi
movq -0x20(%rbp), %rdx
movq %rdx, %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movq -0x30(%rbp), %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
divsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
leaq 0x559a(%rip), %rsi      # 0xf770
callq 0x31d0
movaps -0x60(%rbp), %xmm3
movaps -0x50(%rbp), %xmm2
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
movq %rdx, %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x20(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x3686(%rip), %xmm1     # 0xd8b0
mulsd %xmm1, %xmm0
leaq 0x5578(%rip), %rsi      # 0xf7ad
movb $0x1, %al
callq 0x31d0
jmp 0xa240
jmp 0xa240
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)