// File: /workspace/github_c_makefile_star2_O3/richarddurbin[P]hash10x/hash10x.c
// Function: histogramReport
void histogramReport (char* prefix, Array a)
{
  U64 sum = 0, total = 0 ;
  int i ;
  for (i = 0 ; i < arrayMax(a) ; ++i) { sum += arr(a,i,int) ; total += i*arr(a,i,int) ; }
  U64 partSum = 0, partTotal = 0, max = 0, massMax = 0 ;
  int median = 0, massMedian = 0, n99 = 0, nMass99 = 0, mode, massMode ;
  int t50 = sum*0.5, tMass50 = total*0.5, t99 = sum*0.99, tMass99 = total*0.99 ;
  for (i = 0 ; i < arrayMax(a) ; ++i)
    { int n = arr(a,i,int) ;
      partSum += n ;
      partTotal += i*n ;
      fprintf (outFile, "%s_HIST %6d %d %.4f %.4f\n",
	       prefix, i, n, partSum / (double)sum, partTotal / (double)total) ;
      if (n > max) { mode = i ; max = n ; }
      if (i*n > massMax) { massMode = i ; massMax = i*n ; }
      if (partSum > t50 && !median) median = i ;
      if (partTotal > tMass50 && !massMedian) massMedian = i ;
      if (partSum > t99 && !n99) n99 = i ;
      if (partTotal > tMass99 && !nMass99) nMass99 = i ; 
    }
  fprintf (outFile, "%s_STATS MEAN %.1f", prefix, total/(double)sum) ;
  fprintf (outFile, "  MODE %d  MEDIAN %d  PERCENT99 %d", mode, median, n99) ;
  fprintf (outFile, "  MASS_MODE %d  N50 %d  N99 %d\n", massMode, massMedian, nMass99) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rdx
movslq 0x18(%rsi), %rax
testq %rax, %rax
jle 0x2d0e
movq %rsi, %r11
movq 0x8(%rsi), %r10
movslq 0x14(%rsi), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
xorl %ecx, %ecx
movslq (%r10), %r9
addq %r9, %r8
imulq %rdi, %r9
addq %r9, %rcx
incq %rdi
addq %rsi, %r10
cmpq %rdi, %rax
jne 0x2ac5
movq %r8, %xmm0
movq 0x7526(%rip), %xmm5     # 0xa010
punpckldq %xmm5, %xmm0    # xmm0 = xmm0[0],xmm5[0],xmm0[1],xmm5[1]
movapd 0x752a(%rip), %xmm6     # 0xa020
subpd %xmm6, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %rcx, %xmm0
punpckldq %xmm5, %xmm0    # xmm0 = xmm0[0],xmm5[0],xmm0[1],xmm5[1]
subpd %xmm6, %xmm0
movapd %xmm0, %xmm4
unpckhpd %xmm0, %xmm4            # xmm4 = xmm4[1],xmm0[1]
addsd %xmm0, %xmm4
testl %eax, %eax
jle 0x2d1a
movsd 0x7551(%rip), %xmm0     # 0xa080
movapd %xmm4, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %ecx
movsd 0x753d(%rip), %xmm0     # 0xa088
movapd %xmm4, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edi
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %esi
movslq %esi, %rsi
movq %rsi, 0x30(%rsp)
movslq %edi, %rsi
movq %rsi, 0x28(%rsp)
movslq %ecx, %rcx
movq %rcx, 0x20(%rsp)
cltq
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
xorl %esi, %esi
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %edi, %edi
xorl %r8d, %r8d
movapd %xmm3, 0x60(%rsp)
movapd %xmm4, 0x50(%rsp)
movq %rdi, 0x48(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movl %ebp, 0xc(%rsp)
movq 0x8(%r11), %rax
movslq 0x14(%r11), %rcx
movslq %r13d, %r13
movl %ebx, 0x8(%rsp)
imulq %r13, %rcx
movslq (%rax,%rcx), %rbx
movl %ebx, %eax
addq %rbx, %rsi
movq %rsi, 0x40(%rsp)
imull %r13d, %eax
cltq
movq %rax, 0x38(%rsp)
addq %rax, %r15
movl %r14d, 0x4(%rsp)
movq 0xd7a3(%rip), %rdi      # 0x10390
movq %rsi, %xmm1
punpckldq %xmm5, %xmm1    # xmm1 = xmm1[0],xmm5[0],xmm1[1],xmm5[1]
subpd %xmm6, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
movq %r15, %xmm2
addsd %xmm1, %xmm0
punpckldq %xmm5, %xmm2    # xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1]
subpd %xmm6, %xmm2
movapd %xmm2, %xmm1
divsd %xmm3, %xmm0
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd %xmm4, %xmm1
movl %r12d, (%rsp)
leaq 0x7873(%rip), %rsi      # 0xa4a5
movl %r13d, %ecx
movq %r8, %rbp
movl %ebx, %r8d
movb $0x2, %al
movq %rdx, %r14
movq %r11, %r12
callq 0x1150
movq %rbp, %r8
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %eax
movapd 0x73bb(%rip), %xmm6     # 0xa020
movq 0x73a3(%rip), %xmm5     # 0xa010
movapd 0x50(%rsp), %xmm4
movapd 0x60(%rsp), %xmm3
movq %r12, %r11
movq %r14, %rdx
cmpq %rbx, %rbp
cmovbeq %rbx, %r8
cmovbl %r13d, %ecx
movq 0x38(%rsp), %r9
cmpq %r9, %rdi
cmovbeq %r9, %rdi
cmovbl %r13d, %eax
movl 0xc(%rsp), %r9d
testl %r9d, %r9d
movl %r13d, %ebp
cmovnel %r9d, %ebp
cmpq 0x30(%rsp), %rsi
cmovbel %r9d, %ebp
movl 0x8(%rsp), %r9d
testl %r9d, %r9d
movl %r13d, %ebx
cmovnel %r9d, %ebx
cmpq 0x28(%rsp), %r15
cmovbel %r9d, %ebx
movl 0x4(%rsp), %r9d
testl %r9d, %r9d
movl %r13d, %r14d
cmovnel %r9d, %r14d
cmpq 0x20(%rsp), %rsi
cmovbel %r9d, %r14d
movl (%rsp), %r9d
testl %r9d, %r9d
movl %r13d, %r12d
cmovnel %r9d, %r12d
cmpq 0x18(%rsp), %r15
cmovbel %r9d, %r12d
incl %r13d
cmpl 0x18(%r11), %r13d
jl 0x2ba1
movl %eax, %r15d
movl %ecx, %r13d
jmp 0x2d24
xorl %ebp, %ebp
xorpd %xmm3, %xmm3
xorpd %xmm4, %xmm4
jmp 0x2d1c
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r12d, %r12d
divsd %xmm3, %xmm4
movq 0xd661(%rip), %rdi      # 0x10390
leaq 0x7789(%rip), %rsi      # 0xa4bf
movapd %xmm4, %xmm0
movb $0x1, %al
callq 0x1150
movq 0xd648(%rip), %rdi      # 0x10390
leaq 0x7783(%rip), %rsi      # 0xa4d2
movl %r13d, %edx
movl %ebp, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x1150
movq 0xd62b(%rip), %rdi      # 0x10390
leaq 0x7789(%rip), %rsi      # 0xa4f5
movl %r15d, %edx
movl %ebx, %ecx
movl %r12d, %r8d
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1150