// File: /workspace/github_c_makefile_star2_O1/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 0x734d
leaq 0xadc4(%rip), %rax      # 0x120f8
movq (%rax), %rcx
leaq 0x608e(%rip), %rdi      # 0xd3cc
movl $0x14, %esi
movl $0x1, %edx
callq 0x32c0
leaq 0xbe0c(%rip), %rax      # 0x13160
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x747e
leaq 0x4c6d(%rip), %rsi      # 0xbfd4
movq %rbx, %rdi
callq 0x587d
testq %rax, %rax
je 0x737a
movq 0x30(%rax), %r14
jmp 0x737d
xorl %r14d, %r14d
leaq 0x4cb3(%rip), %rsi      # 0xc037
movq %rbx, %rdi
callq 0x587d
testq %rax, %rax
je 0x7397
movq 0x30(%rax), %r12
jmp 0x739a
xorl %r12d, %r12d
leaq 0x4cd4(%rip), %rsi      # 0xc075
movq %rbx, %rdi
callq 0x587d
testq %rax, %rax
je 0x73b4
movq 0x30(%rax), %r13
jmp 0x73b7
xorl %r13d, %r13d
leaq 0x511c(%rip), %rsi      # 0xc4da
movq %rbx, %rdi
callq 0x587d
testq %rax, %rax
je 0x73d1
movq 0x30(%rax), %r15
jmp 0x73d4
xorl %r15d, %r15d
leaq 0x512a(%rip), %rsi      # 0xc505
movq %rbx, %rdi
callq 0x587d
testq %rax, %rax
je 0x73ee
movq 0x30(%rax), %rbx
jmp 0x73f0
xorl %ebx, %ebx
testq %r14, %r14
je 0x747e
testl %ebp, %ebp
je 0x748d
cmpl $0x1, %ebp
jne 0x747e
leaq 0xaceb(%rip), %rbp      # 0x120f8
movq (%rbp), %rcx
testq %r12, %r12
je 0x75fb
movq %r13, %xmm1
movq 0x4519(%rip), %xmm2     # 0xb940
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x451d(%rip), %xmm3     # 0xb950
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 0x4460(%rip), %xmm0     # 0xb8c8
leaq 0x5cc0(%rip), %rsi      # 0xd12f
movq %rcx, %rdi
movb $0x1, %al
callq 0x31c0
jmp 0x7611
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xac64(%rip), %rbp      # 0x120f8
movq (%rbp), %rdi
leaq 0x5de9(%rip), %rsi      # 0xd288
movq %r14, %rdx
xorl %eax, %eax
callq 0x31c0
movq (%rbp), %rdi
movq %r12, %xmm0
movq 0x4486(%rip), %xmm1     # 0xb940
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movdqa %xmm1, %xmm2
movapd 0x4486(%rip), %xmm1     # 0xb950
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 0x4438(%rip), %xmm0     # 0xb928
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 0x5ec8(%rip), %rsi      # 0xd3e1
movq %r12, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %r13, %xmm1
punpckldq 0x440c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4414(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x10(%rsp), %xmm0
mulsd 0x4372(%rip), %xmm0     # 0xb8c8
leaq 0x5ebf(%rip), %rsi      # 0xd41c
movq %r13, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %r15, %xmm1
punpckldq 0x43c8(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x43d0(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x4394(%rip), %xmm0     # 0xb928
divsd (%rsp), %xmm0
leaq 0x5eb5(%rip), %rsi      # 0xd455
movq %r15, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %rbx, %xmm1
punpckldq 0x4385(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x438d(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x4351(%rip), %xmm0     # 0xb928
divsd (%rsp), %xmm0
leaq 0x5ead(%rip), %rsi      # 0xd490
movq %rbx, %rdx
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31c0
leaq 0x5c7c(%rip), %rdi      # 0xd27e
movl $0x3, %esi
movl $0x1, %edx
callq 0x32c0
movq (%rbp), %rdi
movq %r15, %xmm1
movq 0x431e(%rip), %xmm0     # 0xb940
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movdqa %xmm0, %xmm2
movapd 0x431e(%rip), %xmm0     # 0xb950
subpd %xmm0, %xmm1
movapd %xmm0, %xmm3
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x42da(%rip), %xmm0     # 0xb928
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 0x5c0b(%rip), %r14      # 0xd282
movq %r14, %rsi
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %rbx, %xmm1
punpckldq 0x42ae(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x42b6(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x427a(%rip), %xmm0     # 0xb928
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