// File: /workspace/github_c_makefile_star2_O1/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, %rdx
movslq 0x18(%rsi), %rcx
testq %rcx, %rcx
jle 0x2b35
movq 0x8(%r11), %r10
movslq 0x14(%r11), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
xorl %eax, %eax
movslq (%r10), %r9
addq %r9, %r8
imulq %rdi, %r9
addq %r9, %rax
incq %rdi
addq %rsi, %r10
cmpq %rdi, %rcx
jne 0x2ad9
movq %r8, %xmm0
movq 0x7512(%rip), %xmm1     # 0xa010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x7516(%rip), %xmm2     # 0xa020
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm4
unpckhpd %xmm0, %xmm4            # xmm4 = xmm4[1],xmm0[1]
addsd %xmm0, %xmm4
jmp 0x2b3d
xorpd %xmm4, %xmm4
xorpd %xmm3, %xmm3
cmpl $0x0, 0x18(%r11)
jle 0x2d2d
movsd 0x74f0(%rip), %xmm0     # 0xa040
movapd %xmm4, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %ecx
movsd 0x74dc(%rip), %xmm0     # 0xa048
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 %r12d, %r12d
xorl %esi, %esi
xorl %edi, %edi
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %ecx, %ecx
xorl %r8d, %r8d
movapd %xmm3, 0x70(%rsp)
movapd %xmm4, 0x60(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, 0x48(%rsp)
movl %r13d, 0xc(%rsp)
movl %r15d, 0x10(%rsp)
movl %r14d, 0x14(%rsp)
movq 0x8(%r11), %rax
movslq 0x14(%r11), %rcx
movslq %r12d, %r12
imulq %r12, %rcx
movslq (%rax,%rcx), %r14
movl %r14d, %eax
imull %r12d, %eax
cltq
movq %rax, 0x38(%rsp)
addq %r14, %rsi
movq %rsi, 0x58(%rsp)
addq %rax, %rdi
movq %rdi, 0x50(%rsp)
movq %rsi, %xmm1
movq 0x73f8(%rip), %xmm5     # 0xa010
punpckldq %xmm5, %xmm1    # xmm1 = xmm1[0],xmm5[0],xmm1[1],xmm5[1]
movapd 0x73fc(%rip), %xmm6     # 0xa020
subpd %xmm6, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
movq %rdi, %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
movq 0xd734(%rip), %rdi      # 0x10390
leaq 0x7802(%rip), %rsi      # 0xa465
movl %r12d, %ecx
movl %r14d, %r8d
movb $0x2, %al
movq %rdx, %r13
movl %ebp, %r15d
movl %ebx, %ebp
movq %r11, %rbx
callq 0x1150
movq 0x40(%rsp), %r8
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
movapd 0x60(%rsp), %xmm4
movapd 0x70(%rsp), %xmm3
movq %rbx, %r11
movl %ebp, %ebx
movl %r15d, %ebp
movl 0x10(%rsp), %r15d
movq %r13, %rdx
movl 0xc(%rsp), %r13d
cmpq %r14, %r8
cmovbeq %r14, %r8
movl 0x14(%rsp), %r14d
movl 0x8(%rsp), %eax
cmovbl %r12d, %eax
movl %eax, 0x8(%rsp)
movq 0x38(%rsp), %rax
cmpq %rax, %rcx
cmovbeq %rax, %rcx
cmovbl %r12d, %r14d
testl %r15d, %r15d
movl %r12d, %eax
cmovnel %r15d, %eax
cmpq 0x30(%rsp), %rsi
cmoval %eax, %r15d
testl %ebp, %ebp
movl %r12d, %eax
cmovnel %ebp, %eax
cmpq 0x28(%rsp), %rdi
cmoval %eax, %ebp
testl %r13d, %r13d
movl %r12d, %eax
cmovnel %r13d, %eax
cmpq 0x20(%rsp), %rsi
cmoval %eax, %r13d
testl %ebx, %ebx
movl %r12d, %eax
cmovnel %ebx, %eax
cmpq 0x18(%rsp), %rdi
cmoval %eax, %ebx
incl %r12d
cmpl 0x18(%r11), %r12d
jl 0x2bc1
jmp 0x2d37
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0xd652(%rip), %rdi      # 0x10390
divsd %xmm3, %xmm4
leaq 0x7736(%rip), %rsi      # 0xa47f
movapd %xmm4, %xmm0
movb $0x1, %al
callq 0x1150
movq 0xd635(%rip), %rdi      # 0x10390
leaq 0x7730(%rip), %rsi      # 0xa492
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x1150
movq 0xd616(%rip), %rdi      # 0x10390
leaq 0x7734(%rip), %rsi      # 0xa4b5
movl %r14d, %edx
movl %ebp, %ecx
movl %ebx, %r8d
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1150