// File: /workspace/github_c_makefile_star2_O2/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 $0x88, %rsp
movq %rsi, %r11
movq %rdi, 0x10(%rsp)
movl 0x18(%rsi), %eax
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %esi
cmovgl %eax, %esi
xorl %ecx, %ecx
xorl %edi, %edi
cmpl %edx, %esi
je 0x214f
movq 0x8(%r11), %r8
movslq 0x14(%r11), %r9
movslq %edx, %r10
imulq %r10, %r9
movslq (%r8,%r9), %r8
addq %r8, %rdi
imulq %r10, %r8
addq %r8, %rcx
incl %edx
jmp 0x212a
movq %rdi, %xmm0
movq 0x6eb4(%rip), %xmm2     # 0x9010
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x6eb8(%rip), %xmm4     # 0x9020
subpd %xmm4, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movsd 0x6ec0(%rip), %xmm0     # 0x9040
movapd %xmm3, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edx
movq %rcx, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm4, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %ecx
movsd 0x6e93(%rip), %xmm0     # 0x9048
movapd %xmm3, 0x70(%rsp)
movapd %xmm3, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %esi
movapd %xmm2, 0x60(%rsp)
mulsd %xmm2, %xmm0
cvttsd2si %xmm0, %edi
movslq %edx, %rdx
movq %rdx, 0x38(%rsp)
movslq %ecx, %rcx
movq %rcx, 0x30(%rsp)
movslq %esi, %rcx
movq %rcx, 0x28(%rsp)
movslq %edi, %rcx
movq %rcx, 0x20(%rsp)
xorl %edx, %edx
xorl %esi, %esi
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %edi, %edi
xorl %r8d, %r8d
xorl %r12d, %r12d
cmpl %eax, %r12d
jge 0x236b
movq 0x8(%r11), %rax
movslq 0x14(%r11), %rcx
movq %rdx, 0x58(%rsp)
movslq %r12d, %rdx
imulq %rcx, %rdx
movl %r14d, 0xc(%rsp)
movslq (%rax,%rdx), %r14
addq %r14, %r8
movq %r8, 0x48(%rsp)
movl %r14d, %eax
imull %r12d, %eax
cltq
movq %rax, 0x40(%rsp)
addq %rax, %rdi
movq %rdi, 0x18(%rsp)
movq 0xe14a(%rip), %rdi      # 0x103a0
movq %r8, %xmm1
movq 0x6dad(%rip), %xmm3     # 0x9010
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x6db1(%rip), %xmm4     # 0x9020
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x70(%rsp), %xmm0
movq 0x18(%rsp), %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm4, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd 0x60(%rsp), %xmm1
movq %rsi, 0x50(%rsp)
leaq 0x71b4(%rip), %rsi      # 0x9465
movq 0x10(%rsp), %rdx
movl %r12d, %ecx
movl %r14d, %r8d
movb $0x2, %al
movl %ebp, %r15d
movl %ebx, %ebp
movq %r11, %rbx
callq 0x1150
movq 0x48(%rsp), %r8
movq 0x18(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %rbx, %r11
movl %ebp, %ebx
movl %r15d, %ebp
cmpq %r14, %rdx
cmovbeq %r14, %rdx
movl 0xc(%rsp), %r14d
movl 0x4(%rsp), %eax
cmovbl %r12d, %eax
movl %eax, 0x4(%rsp)
movq 0x40(%rsp), %rax
cmpq %rax, %rsi
cmovbeq %rax, %rsi
movl 0x8(%rsp), %eax
cmovbl %r12d, %eax
movl %eax, 0x8(%rsp)
testl %r14d, %r14d
movl %r12d, %eax
cmovnel %r14d, %eax
cmpq 0x38(%rsp), %r8
cmoval %eax, %r14d
testl %ebx, %ebx
movl %r12d, %eax
cmovnel %ebx, %eax
cmpq 0x30(%rsp), %rdi
cmoval %eax, %ebx
testl %r13d, %r13d
movl %r12d, %eax
cmovnel %r13d, %eax
cmpq 0x28(%rsp), %r8
cmoval %eax, %r13d
testl %r15d, %r15d
movl %r12d, %eax
cmovnel %r15d, %eax
cmpq 0x20(%rsp), %rdi
cmoval %eax, %ebp
incl %r12d
movl 0x18(%r11), %eax
jmp 0x220b
movq 0xe02e(%rip), %rdi      # 0x103a0
movapd 0x60(%rsp), %xmm0
divsd 0x70(%rsp), %xmm0
leaq 0x70fa(%rip), %rsi      # 0x947f
movq 0x10(%rsp), %rdx
movb $0x1, %al
callq 0x1150
movq 0xe008(%rip), %rdi      # 0x103a0
leaq 0x70f3(%rip), %rsi      # 0x9492
movl 0x4(%rsp), %edx
movl %r14d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x1150
movq 0xdfe9(%rip), %rdi      # 0x103a0
leaq 0x70f7(%rip), %rsi      # 0x94b5
movl 0x8(%rsp), %edx
movl %ebx, %ecx
movl %ebp, %r8d
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1150