// File: /workspace/github_c_makefile_star2_O1/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 0x58f6
leaq 0xc829(%rip), %rax      # 0x120f8
movq (%rax), %rcx
leaq 0x74e2(%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 0xd83e(%rip), %xmm0 # 0x13140
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0xd834(%rip), %xmm0 # 0x13148
movsd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0xd82a(%rip), %xmm0 # 0x13150
movsd %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0xd820(%rip), %xmm0 # 0x13158
movsd %xmm0, 0x28(%rsp)
movslq 0xc(%rdi), %rax
testq %rax, %rax
jle 0x5aac
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 0x6001(%rip), %rsi      # 0xb96b
callq 0x31a0
testl %eax, %eax
je 0x5a18
movq %r13, %rdi
leaq 0x6653(%rip), %rsi      # 0xbfd4
callq 0x31a0
testl %eax, %eax
jne 0x5a9d
movsd 0x30(%rbp,%r15), %xmm0
movsd 0x5fa3(%rip), %xmm3     # 0xb940
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x5fa8(%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 0x5ec8(%rip), %xmm2     # 0xb8d0
cvttsd2si %xmm2, %rbx
andq %rcx, %rbx
orq %rax, %rbx
jmp 0x5a9d
movsd 0x30(%rbp,%r15), %xmm0
movsd 0x5f19(%rip), %xmm3     # 0xb940
unpcklps %xmm3, %xmm0            # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x5f1e(%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 0x5e3e(%rip), %xmm2     # 0xb8d0
cvttsd2si %xmm2, %r14
andq %rcx, %r14
orq %rax, %r14
addq $0x58, %r15
cmpq %r15, %r12
jne 0x595b
jmp 0x5ab1
xorl %ebx, %ebx
xorl %r14d, %r14d
movl (%rsp), %eax
cmpl $0x1, %eax
je 0x5bf1
testl %eax, %eax
jne 0x5be2
testq %r14, %r14
je 0x5be2
movsd 0x5712(%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 0xc5f7(%rip), %r15      # 0x120f8
movq (%r15), %rdi
movq %r14, %xmm0
punpckldq 0x5e2f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x5e37(%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 0x56ae(%rip), %xmm0     # 0xb1e8
leaq 0xd61f(%rip), %rax      # 0x13160
movq (%rax), %rax
movl 0x10(%rax), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc56e(%rip), %rax      # 0x120c8
cmpl $0x0, (%rax)
jne 0x5b67
movsd 0x5d71(%rip), %xmm1     # 0xb8d8
divsd %xmm1, %xmm0
leaq 0x724e(%rip), %rsi      # 0xcdc0
movq %r14, %rdx
movb $0x1, %al
callq 0x31c0
movq (%r15), %rdi
movq %rbx, %xmm1
punpckldq 0x5db4(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x5dbc(%rip), %xmm1     # 0xb950
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd (%rsp), %xmm0
movapd %xmm0, (%rsp)
leaq 0x7238(%rip), %rsi      # 0xcde9
movq %rbx, %rdx
movb $0x1, %al
callq 0x31c0
movapd (%rsp), %xmm1
ucomisd 0x5d18(%rip), %xmm1     # 0xb8e0
jbe 0x5c5d
movq (%r15), %rcx
leaq 0x7239(%rip), %rdi      # 0xce11
movl $0x5, %esi
jmp 0x5c7a
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc500(%rip), %rax      # 0x120f8
movq (%rax), %rdi
movq %rbx, %xmm1
movq 0x5d38(%rip), %xmm2     # 0xb940
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x5d3c(%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 0x71d4(%rip), %rsi      # 0xce1c
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31c0
movsd 0x5c83(%rip), %xmm0     # 0xb8e8
ucomisd %xmm1, %xmm0
jbe 0x5c84
movq (%r15), %rcx
leaq 0x71a2(%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