// File: /workspace/github_c_makefile_star2_O3/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 0x7325
leaq 0xadec(%rip), %rax      # 0x120f8
movq (%rax), %rcx
leaq 0x60b6(%rip), %rdi      # 0xd3cc
movl $0x14, %esi
movl $0x1, %edx
callq 0x32c0
leaq 0xbe34(%rip), %rax      # 0x13160
movq (%rax), %rax
cmpl $0x1, (%rax)
jne 0x7456
leaq 0x4c95(%rip), %rsi      # 0xbfd4
movq %rbx, %rdi
callq 0x5860
testq %rax, %rax
je 0x7352
movq 0x30(%rax), %r14
jmp 0x7355
xorl %r14d, %r14d
leaq 0x4cdb(%rip), %rsi      # 0xc037
movq %rbx, %rdi
callq 0x5860
testq %rax, %rax
je 0x736f
movq 0x30(%rax), %r12
jmp 0x7372
xorl %r12d, %r12d
leaq 0x4cfc(%rip), %rsi      # 0xc075
movq %rbx, %rdi
callq 0x5860
testq %rax, %rax
je 0x738c
movq 0x30(%rax), %r13
jmp 0x738f
xorl %r13d, %r13d
leaq 0x5144(%rip), %rsi      # 0xc4da
movq %rbx, %rdi
callq 0x5860
testq %rax, %rax
je 0x73a9
movq 0x30(%rax), %r15
jmp 0x73ac
xorl %r15d, %r15d
leaq 0x5152(%rip), %rsi      # 0xc505
movq %rbx, %rdi
callq 0x5860
testq %rax, %rax
je 0x73c6
movq 0x30(%rax), %rbx
jmp 0x73c8
xorl %ebx, %ebx
testq %r14, %r14
je 0x7456
testl %ebp, %ebp
je 0x7465
cmpl $0x1, %ebp
jne 0x7456
leaq 0xad13(%rip), %rbp      # 0x120f8
movq (%rbp), %rcx
testq %r12, %r12
je 0x75d3
movq %r13, %xmm1
movq 0x4541(%rip), %xmm2     # 0xb940
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x4545(%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 0x4488(%rip), %xmm0     # 0xb8c8
leaq 0x5ce8(%rip), %rsi      # 0xd12f
movq %rcx, %rdi
movb $0x1, %al
callq 0x31c0
jmp 0x75e9
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xac8c(%rip), %rbp      # 0x120f8
movq (%rbp), %rdi
leaq 0x5e11(%rip), %rsi      # 0xd288
movq %r14, %rdx
xorl %eax, %eax
callq 0x31c0
movq (%rbp), %rdi
movq %r12, %xmm0
movq 0x44ae(%rip), %xmm1     # 0xb940
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movdqa %xmm1, %xmm2
movapd 0x44ae(%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 0x4460(%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 0x5ef0(%rip), %rsi      # 0xd3e1
movq %r12, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %r13, %xmm1
punpckldq 0x4434(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x443c(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x10(%rsp), %xmm0
mulsd 0x439a(%rip), %xmm0     # 0xb8c8
leaq 0x5ee7(%rip), %rsi      # 0xd41c
movq %r13, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %r15, %xmm1
punpckldq 0x43f0(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x43f8(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x43bc(%rip), %xmm0     # 0xb928
divsd (%rsp), %xmm0
leaq 0x5edd(%rip), %rsi      # 0xd455
movq %r15, %rdx
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %rbx, %xmm1
punpckldq 0x43ad(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x43b5(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x4379(%rip), %xmm0     # 0xb928
divsd (%rsp), %xmm0
leaq 0x5ed5(%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 0x5ca4(%rip), %rdi      # 0xd27e
movl $0x3, %esi
movl $0x1, %edx
callq 0x32c0
movq (%rbp), %rdi
movq %r15, %xmm1
movq 0x4346(%rip), %xmm0     # 0xb940
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movdqa %xmm0, %xmm2
movapd 0x4346(%rip), %xmm0     # 0xb950
subpd %xmm0, %xmm1
movapd %xmm0, %xmm3
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x4302(%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 0x5c33(%rip), %r14      # 0xd282
movq %r14, %rsi
movb $0x1, %al
callq 0x31c0
movq (%rbp), %rdi
movq %rbx, %xmm1
punpckldq 0x42d6(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x42de(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x42a2(%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