// File: /workspace/github_c_makefile_star2_O2/mvermeulen[P]wspy/topdown.c
// Function: print_topdown_op
void print_topdown_op(struct counter_group *cgroup,enum output_format oformat,int mask){
  unsigned long instructions=0;
  unsigned long opcache_miss=0;
  unsigned long opcache_access=0;
  unsigned long dtlb1=0;
  unsigned long dtlb2=0;
  
  struct counter_info *cinfo;

  if (oformat == PRINT_CSV_HEADER){
    fprintf(outfile,"opcache,dtlb1,dtlb2,");
  }

  switch(cpu_info->vendor){
  case VENDOR_INTEL:
    return;
    break;
  case VENDOR_AMD:
    if (cinfo = find_ci_label(cgroup,"instructions")) instructions = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"op_cache_hit_miss.all_op_cache_accesses")) opcache_access = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"op_cache_hit_miss.op_cache_miss")) opcache_miss = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"ls_l1_d_tlb_miss.all")) dtlb1 = cinfo->value;
    if (cinfo = find_ci_label(cgroup,"ls_l1_d_tlb_miss.all_l2_miss")) dtlb2 = cinfo->value;
    break;
  default:
    return;
  }

  if (instructions){
    switch(oformat){
    case PRINT_CSV:
      if (opcache_access)
	fprintf(outfile,"%4.1f,",(double) opcache_miss / opcache_access*100);
      else
	fprintf(outfile,"0.0");
      fprintf(outfile,"%4.3f",(double) dtlb1*1000.0 / instructions);
      fprintf(outfile,"%4.3f",(double) dtlb2*1000.0 / instructions);
      break;
    case PRINT_NORMAL:
      fprintf(outfile,"instructions         %-14lu #\n",instructions);
      fprintf(outfile,"opcache              %-14lu # %4.3f opcache per 1000 inst\n",
	      opcache_access,(double) opcache_access * 1000 / instructions);
      fprintf(outfile,"opcache miss         %-14lu # %4.1f%% opcache miss rate\n",
	      opcache_miss,(double) opcache_miss / opcache_access*100.0);
      fprintf(outfile,"l1 dTLB miss         %-14lu # %4.3f L1 dTLB per 1000 inst\n",
	      dtlb1,(double) dtlb1*1000/instructions);
      fprintf(outfile,"l2 dTLB miss         %-14lu # %4.3f L2 dTLB per 1000 inst\n",
	      dtlb2,(double) dtlb2*1000/instructions);
      break;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x2, %esi
jne 0x7208
leaq 0x9f15(%rip), %rax      # 0x11108
movq (%rax), %rcx
leaq 0x51cf(%rip), %rdi      # 0xc3cc
pushq $0x14
popq %rsi
pushq $0x1
popq %rdx
callq 0x32d0
leaq 0xaf61(%rip), %rax      # 0x12170
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x7339
leaq 0x3db2(%rip), %rsi      # 0xafd4
movq %rbx, %rdi
callq 0x576f
testq %rax, %rax
je 0x7235
movq 0x30(%rax), %r14
jmp 0x7238
xorl %r14d, %r14d
leaq 0x3df8(%rip), %rsi      # 0xb037
movq %rbx, %rdi
callq 0x576f
testq %rax, %rax
je 0x7252
movq 0x30(%rax), %r12
jmp 0x7255
xorl %r12d, %r12d
leaq 0x3e19(%rip), %rsi      # 0xb075
movq %rbx, %rdi
callq 0x576f
testq %rax, %rax
je 0x726f
movq 0x30(%rax), %r13
jmp 0x7272
xorl %r13d, %r13d
leaq 0x4261(%rip), %rsi      # 0xb4da
movq %rbx, %rdi
callq 0x576f
testq %rax, %rax
je 0x728c
movq 0x30(%rax), %r15
jmp 0x728f
xorl %r15d, %r15d
leaq 0x426f(%rip), %rsi      # 0xb505
movq %rbx, %rdi
callq 0x576f
testq %rax, %rax
je 0x72a9
movq 0x30(%rax), %rbx
jmp 0x72ab
xorl %ebx, %ebx
testq %r14, %r14
je 0x7339
testl %ebp, %ebp
je 0x7348
cmpl $0x1, %ebp
jne 0x7339
leaq 0x9e40(%rip), %rbp      # 0x11108
movq (%rbp), %rcx
testq %r12, %r12
je 0x74b6
movq %r13, %xmm1
movq 0x365e(%rip), %xmm2     # 0xa940
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x3662(%rip), %xmm3     # 0xa950
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r12, %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 0x35a5(%rip), %xmm0     # 0xa8c8
leaq 0x4e05(%rip), %rsi      # 0xc12f
movq %rcx, %rdi
movb $0x1, %al
callq 0x31c0
jmp 0x74c8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9db9(%rip), %rbp      # 0x11108
movq (%rbp), %rdi
leaq 0x4f2e(%rip), %rsi      # 0xc288
movq %r14, %rdx
xorl %eax, %eax
callq 0x31c0
movq (%rbp), %rdi
movq %r12, %xmm0
movq 0x35cb(%rip), %xmm1     # 0xa940
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movdqa %xmm1, %xmm2
movapd 0x35cb(%rip), %xmm1     # 0xa950
subpd %xmm1, %xmm0
movapd %xmm1, %xmm3
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movapd %xmm1, %xmm0
mulsd 0x357d(%rip), %xmm0     # 0xa928
movq %r14, %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
movapd %xmm2, (%rsp)
divsd %xmm2, %xmm0
leaq 0x500d(%rip), %rsi      # 0xc3e1
movq %r12, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %r13, %xmm1
punpckldq 0x3551(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3559(%rip), %xmm1     # 0xa950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x10(%rsp), %xmm0
mulsd 0x34b7(%rip), %xmm0     # 0xa8c8
leaq 0x5004(%rip), %rsi      # 0xc41c
movq %r13, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %r15, %xmm1
punpckldq 0x350d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x3515(%rip), %xmm1     # 0xa950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x34d9(%rip), %xmm0     # 0xa928
divsd (%rsp), %xmm0
leaq 0x4ffa(%rip), %rsi      # 0xc455
movq %r15, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %rbx, %xmm1
punpckldq 0x34ca(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x34d2(%rip), %xmm1     # 0xa950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x3496(%rip), %xmm0     # 0xa928
divsd (%rsp), %xmm0
leaq 0x4ff2(%rip), %rsi      # 0xc490
movq %rbx, %rdx
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31c0
leaq 0x4dc1(%rip), %rdi      # 0xc27e
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
callq 0x32d0
movq (%rbp), %rdi
movq %r15, %xmm1
movq 0x3467(%rip), %xmm0     # 0xa940
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movdqa %xmm0, %xmm2
movapd 0x3467(%rip), %xmm0     # 0xa950
subpd %xmm0, %xmm1
movapd %xmm0, %xmm3
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x3423(%rip), %xmm0     # 0xa928
movq %r14, %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
movapd %xmm2, (%rsp)
divsd %xmm2, %xmm0
leaq 0x4d54(%rip), %r14      # 0xc282
movq %r14, %rsi
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %rbx, %xmm1
punpckldq 0x33f7(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x33ff(%rip), %xmm1     # 0xa950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x33c3(%rip), %xmm0     # 0xa928
divsd (%rsp), %xmm0
movq %r14, %rsi
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31c0