// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
cmpl $0x2, %esi
jne 0x5807
leaq 0xb924(%rip), %rax      # 0x11108
movq (%rax), %rcx
leaq 0x65cd(%rip), %rdi      # 0xbdbb
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x32d0
movl %esi, 0x10(%rsp)
movq 0xc93e(%rip), %rax      # 0x12150
movq %rax, 0x38(%rsp)
cvtsi2sdq 0xc938(%rip), %xmm1 # 0x12158
movsd 0x49c0(%rip), %xmm0     # 0xa1e8
divsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
cvtsi2sdq 0xc925(%rip), %xmm1 # 0x12160
movsd %xmm1, 0x28(%rsp)
cvtsi2sdq 0xc91e(%rip), %xmm1 # 0x12168
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
movl 0xc(%rdi), %eax
xorl %r13d, %r13d
testl %eax, %eax
cmovlel %r13d, %eax
imulq $0x58, %rax, %r12
movq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
cmpq %r13, %r12
je 0x59d2
movq %rdi, %rbx
movq 0x18(%rdi), %r15
movq (%r15,%r13), %rbp
movq %rbp, %rdi
leaq 0x50dd(%rip), %rsi      # 0xa96b
callq 0x31a0
testl %eax, %eax
je 0x5941
movq %rbp, %rdi
leaq 0x572f(%rip), %rsi      # 0xafd4
callq 0x31a0
testl %eax, %eax
jne 0x59c6
movsd 0x30(%r15,%r13), %xmm0
movsd 0x507f(%rip), %xmm4     # 0xa940
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
movapd 0x5084(%rip), %xmm3     # 0xa950
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x50(%r15,%r13), %xmm0
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movsd 0x48(%r15,%r13), %xmm0
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %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 0x4fa4(%rip), %xmm2     # 0xa8d0
cvttsd2si %xmm2, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x8(%rsp)
jmp 0x59c6
movsd 0x30(%r15,%r13), %xmm0
movsd 0x4ff0(%rip), %xmm4     # 0xa940
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
movapd 0x4ff5(%rip), %xmm3     # 0xa950
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x50(%r15,%r13), %xmm0
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movsd 0x48(%r15,%r13), %xmm0
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm3, %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 0x4f15(%rip), %xmm2     # 0xa8d0
cvttsd2si %xmm2, %r14
andq %rcx, %r14
orq %rax, %r14
movq %rbx, %rdi
addq $0x58, %r13
jmp 0x5870
movl 0x10(%rsp), %eax
cmpl $0x1, %eax
je 0x5b04
testl %eax, %eax
jne 0x5af5
testq %r14, %r14
je 0x5af5
cvtsi2sdq 0x38(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
addsd %xmm0, %xmm1
subsd 0x28(%rsp), %xmm1
subsd 0x30(%rsp), %xmm1
leaq 0xb6f4(%rip), %r15      # 0x11108
movq (%r15), %rdi
movq %r14, %xmm0
punpckldq 0x4f1c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4f24(%rip), %xmm0     # 0xa950
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movapd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
divsd 0x479a(%rip), %xmm0     # 0xa1e8
leaq 0xc71b(%rip), %rax      # 0x12170
movq (%rax), %rax
movl 0x10(%rax), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xb66d(%rip), %rax      # 0x110d8
cmpl $0x0, (%rax)
jne 0x5a78
movsd 0x4e60(%rip), %xmm1     # 0xa8d8
divsd %xmm1, %xmm0
leaq 0x633d(%rip), %rsi      # 0xbdc0
movq %r14, %rdx
movb $0x1, %al
callq 0x31c0
movq (%r15), %rdi
movq 0x8(%rsp), %rdx
movq %rdx, %xmm1
punpckldq 0x4e9e(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4ea6(%rip), %xmm1     # 0xa950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x10(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
leaq 0x6320(%rip), %rsi      # 0xbde9
movb $0x1, %al
callq 0x31c0
movapd 0x10(%rsp), %xmm1
ucomisd 0x4e02(%rip), %xmm1     # 0xa8e0
jbe 0x5b70
movq (%r15), %rcx
leaq 0x6323(%rip), %rdi      # 0xbe11
pushq $0x5
jmp 0x5b8a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb5fd(%rip), %rax      # 0x11108
movq (%rax), %rdi
movsd 0x8(%rsp), %xmm1
movsd 0x4e24(%rip), %xmm3     # 0xa940
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x4e29(%rip), %xmm2     # 0xa950
subpd %xmm2, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r14, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x62c1(%rip), %rsi      # 0xbe1c
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31c0
movsd 0x4d70(%rip), %xmm0     # 0xa8e8
ucomisd %xmm1, %xmm0
jbe 0x5b93
movq (%r15), %rcx
leaq 0x628f(%rip), %rdi      # 0xbe17
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
callq 0x32d0
movq (%r15), %rsi
pushq $0xa
popq %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3150