// File: /workspace/github_c_makefile_star2_O3/mvermeulen[P]wspy/topdown.c
// Function: print_ipc
void print_ipc(struct counter_group *cgroup,enum output_format oformat){
  int i;
  unsigned long cpu_cycles=0,scaled_cpu_cycles=0;
  unsigned long instructions=0;
  unsigned long branches=0;
  unsigned long branch_misses=0;
  double elapsed;
  double scale;
  if (oformat == PRINT_CSV_HEADER){
    fprintf(outfile,"ipc,");
    return;
  }
  elapsed = finish_time.tv_sec + finish_time.tv_nsec / 1000000000.0 -
    start_time.tv_sec - start_time.tv_nsec / 1000000000.0;  

  for (i=0;i<cgroup->ncounters;i++){
    if (!strcmp(cgroup->cinfo[i].label,"cpu-cycles")){
      cpu_cycles = (double) cgroup->cinfo[i].value * cgroup->cinfo[i].time_enabled / cgroup->cinfo[i].time_running;
      scaled_cpu_cycles = (double) cpu_cycles * (double) cgroup->cinfo[i].time_enabled / (double) cgroup->cinfo[i].time_running;
    } else if (!strcmp(cgroup->cinfo[i].label,"instructions")){
      instructions = (double) cgroup->cinfo[i].value * cgroup->cinfo[i].time_enabled / cgroup->cinfo[i].time_running;
    } else if (!strcmp(cgroup->cinfo[i].label,"branches")){
      branches = (double) cgroup->cinfo[i].value * cgroup->cinfo[i].time_enabled / cgroup->cinfo[i].time_running;
    } else if (!strcmp(cgroup->cinfo[i].label,"branch-misses")){
      branch_misses = (double) cgroup->cinfo[i].value * cgroup->cinfo[i].time_enabled / cgroup->cinfo[i].time_running;
    }
  }

  switch(oformat){
  case PRINT_NORMAL:
    if (cpu_cycles){
      fprintf(outfile,"cpu-cycles           %-14lu # %4.2f GHz\n",cpu_cycles,(double) cpu_cycles / elapsed / 1000000000.0 / cpu_info->num_cores_available / (aflag?cpu_info->num_cores_available:1));
      fprintf(outfile,"instructions         %-14lu # %4.2f IPC",instructions,(double) instructions / cpu_cycles);
      if (((double) instructions / cpu_cycles) > 3.0){
	fprintf(outfile," high");
      }
      else if (((double) instructions / cpu_cycles) < 0.7){
	fprintf(outfile," low");
      }
      fprintf(outfile,"\n");
      break;
    case PRINT_CSV:
      fprintf(outfile,"%4.2f,",(double) instructions / cpu_cycles);
      break;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl $0x2, %esi
jne 0x58d9
leaq 0xc846(%rip), %rax      # 0x120f8
movq (%rax), %rcx
leaq 0x74ff(%rip), %rdi      # 0xcdbb
movl $0x4, %esi
movl $0x1, %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x32c0
movl %esi, (%rsp)
cvtsi2sdq 0xd85b(%rip), %xmm0 # 0x13140
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0xd851(%rip), %xmm0 # 0x13148
movsd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0xd847(%rip), %xmm0 # 0x13150
movsd %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0xd83d(%rip), %xmm0 # 0x13158
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rdi), %rax
testq %rax, %rax
jle 0x5a8f
movq 0x18(%rdi), %rbp
imulq $0x58, %rax, %r12
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq (%rbp,%r15), %r13
movq %r13, %rdi
leaq 0x601e(%rip), %rsi      # 0xb96b
callq 0x31a0
testl %eax, %eax
je 0x59fb
movq %r13, %rdi
leaq 0x6670(%rip), %rsi      # 0xbfd4
callq 0x31a0
testl %eax, %eax
jne 0x5a80
movsd 0x30(%rbp,%r15), %xmm0
movsd 0x5fc0(%rip), %xmm3     # 0xb940
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x5fc5(%rip), %xmm4     # 0xb950
subpd %xmm4, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x50(%rbp,%r15), %xmm0
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm4, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movsd 0x48(%rbp,%r15), %xmm0
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm4, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x5ee5(%rip), %xmm2     # 0xb8d0
cvttsd2si %xmm2, %rbx
andq %rcx, %rbx
orq %rax, %rbx
jmp 0x5a80
movsd 0x30(%rbp,%r15), %xmm0
movsd 0x5f36(%rip), %xmm3     # 0xb940
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x5f3b(%rip), %xmm4     # 0xb950
subpd %xmm4, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x50(%rbp,%r15), %xmm0
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm4, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movsd 0x48(%rbp,%r15), %xmm0
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm4, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x5e5b(%rip), %xmm2     # 0xb8d0
cvttsd2si %xmm2, %r14
andq %rcx, %r14
orq %rax, %r14
addq $0x58, %r15
cmpq %r15, %r12
jne 0x593e
jmp 0x5a94
xorl %ebx, %ebx
xorl %r14d, %r14d
movl (%rsp), %eax
cmpl $0x1, %eax
je 0x5bd4
testl %eax, %eax
jne 0x5bc5
testq %r14, %r14
je 0x5bc5
movsd 0x572f(%rip), %xmm0     # 0xb1e8
movsd 0x30(%rsp), %xmm1
divsd %xmm0, %xmm1
addsd 0x20(%rsp), %xmm1
subsd 0x18(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
divsd %xmm0, %xmm2
subsd %xmm2, %xmm1
leaq 0xc614(%rip), %r15      # 0x120f8
movq (%r15), %rdi
movq %r14, %xmm0
punpckldq 0x5e4c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x5e54(%rip), %xmm0     # 0xb950
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movapd %xmm2, (%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
divsd 0x56cb(%rip), %xmm0     # 0xb1e8
leaq 0xd63c(%rip), %rax      # 0x13160
movq (%rax), %rax
movl 0x10(%rax), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc58b(%rip), %rax      # 0x120c8
cmpl $0x0, (%rax)
jne 0x5b4a
movsd 0x5d8e(%rip), %xmm1     # 0xb8d8
divsd %xmm1, %xmm0
leaq 0x726b(%rip), %rsi      # 0xcdc0
movq %r14, %rdx
movb $0x1, %al
callq 0x31c0
movq (%r15), %rdi
movq %rbx, %xmm1
punpckldq 0x5dd1(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x5dd9(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd (%rsp), %xmm0
movapd %xmm0, (%rsp)
leaq 0x7255(%rip), %rsi      # 0xcde9
movq %rbx, %rdx
movb $0x1, %al
callq 0x31c0
movapd (%rsp), %xmm1
ucomisd 0x5d35(%rip), %xmm1     # 0xb8e0
jbe 0x5c40
movq (%r15), %rcx
leaq 0x7256(%rip), %rdi      # 0xce11
movl $0x5, %esi
jmp 0x5c5d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc51d(%rip), %rax      # 0x120f8
movq (%rax), %rdi
movq %rbx, %xmm1
movq 0x5d55(%rip), %xmm2     # 0xb940
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x5d59(%rip), %xmm3     # 0xb950
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
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
divsd %xmm2, %xmm0
leaq 0x71f1(%rip), %rsi      # 0xce1c
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31c0
movsd 0x5ca0(%rip), %xmm0     # 0xb8e8
ucomisd %xmm1, %xmm0
jbe 0x5c67
movq (%r15), %rcx
leaq 0x71bf(%rip), %rdi      # 0xce17
movl $0x4, %esi
movl $0x1, %edx
callq 0x32c0
movq (%r15), %rsi
movl $0xa, %edi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3150