// File: /workspace/github_c_makefile_star2_O3/richarddurbin[P]hash10x/moshasm.c
// Function: readsetStats
void readsetStats (Readset *rs)
{
  U32 n = arrayMax(rs->reads)-1 ;
  if (!n) { fprintf (stderr, "stats called on empty readset\n") ; return ; }

  moshsetSummary (rs->ms, outFile) ;
  
  U32 i, j ; 
  int nUnique0 = 0, nUnique1 = 0 ;
  U64 totLen = 0, totMiss = 0, lenUnique0 = 0, lenUnique1 = 0 ;
  U64 totCopy[4] ; totCopy[0] = totCopy[1] = totCopy[2] = totCopy[3] = 0 ;
  U32 nBad = 0, nBadRepeat = 0, nBadOrder10 = 0, nBadOrder1 = 0 ;
  U32 nBadNoMatch = 0, nBadLowHit = 0, nBadLowCopy1 = 0 ;
  
  for (i = 1 ; i <= n ; ++i)
    { Read *read = arrp(rs->reads, i, Read) ;
      totLen += read->len ;
      totMiss += read->nMiss ;
      for (j = 0 ; j < 4 ; ++j) totCopy[j] += read->nCopy[j] ;
      if (read->nCopy[1] == 0) { ++nUnique0 ; lenUnique0 += read->len ; }
      else if (read->nCopy[1] == 1) { ++nUnique1 ; lenUnique1 += read->len ; }
      if (read->bad)
	{ ++nBad ;
	  if (read->badRepeat) ++nBadRepeat ;
	  if (read->badOrder10) ++nBadOrder10 ;
	  if (read->badOrder1) ++nBadOrder1 ;
	  if (read->badNoMatch) ++nBadNoMatch ;
	  if (read->badLowHit) ++nBadLowHit ;
	  if (read->badLowCopy1) ++nBadLowCopy1 ;
	}
    }
  fprintf (outFile, "RS %d sequences, total length %llu (av %.1f)\n",
	   n, totLen, totLen/(double)n) ;
  fprintf (outFile, "RS %llu mosh hits, %.1f bp/hit, frac hit %.2f, av hits/read %.1f\n",
	   rs->totHit, totLen/(double)rs->totHit, rs->totHit/(double)(totMiss+rs->totHit),
	   rs->totHit/(double)n) ;
  fprintf (outFile, "RS hit distribution %.2f copy0, %.2f copy1, %.2f copy2, %.2f copyM\n",
	   totCopy[0]/(double)rs->totHit, totCopy[1]/(double)rs->totHit,
	   totCopy[2]/(double)rs->totHit, totCopy[3]/(double)rs->totHit) ;
  U32 nUniqueMulti = n - nUnique0 - nUnique1 ;
  fprintf (outFile, "RS num reads and av_len with 0 copy1 hits %d %.1f with 1 copy1 hits %d %.1f"
	   " >1 copy1 hits %d %.1f av copy1 hits %.1f\n",
	   nUnique0, lenUnique0/(double)nUnique0, nUnique1, lenUnique1/(double)nUnique1,
	   nUniqueMulti, (totLen - lenUnique0 - lenUnique1)/(double)nUniqueMulti,
	   (totCopy[1]-nUnique1)/(double)nUniqueMulti) ;
  fprintf (outFile, "RS bad %u : %u repeat, %u order10, %u order1, ",
	   nBad, nBadRepeat, nBadOrder10, nBadOrder1) ;
  fprintf (outFile, "%u no_match, %u low_hit, %u low_copy1\n",
	   nBadNoMatch, nBadLowHit, nBadLowCopy1) ;
  U32 nCopy[4], hitCopy[4], hit2Copy[4] ;
  U64 depthCopy[4] ;
  for (j = 0 ; j < 4 ; ++j) nCopy[j] = hitCopy[j] = hit2Copy[j] = depthCopy[j] = 0 ;
  for (i = 1 ; i <= rs->ms->max ; ++i)
    { j = msCopy(rs->ms,i) ;
      ++nCopy[j] ;
      if (rs->ms->depth[i] > 0) ++hitCopy[j] ;
      if (rs->ms->depth[i] > 1) { ++hit2Copy[j] ; depthCopy[j] += rs->ms->depth[i] ; }
    }
  fprintf (outFile, "RS mosh frac hit hit>1 av: copy0 %.3f %.3f %.1f copy1 %.3f %.3f %.1f copy2 %.3f %.3f %.1f copyM %.3f %.3f %.1f\n", 
   hitCopy[0]/(double)nCopy[0], hit2Copy[0]/(double)nCopy[0], depthCopy[0]/(double)hit2Copy[0], 
   hitCopy[1]/(double)nCopy[1], hit2Copy[1]/(double)nCopy[1], depthCopy[1]/(double)hit2Copy[1], 
   hitCopy[2]/(double)nCopy[2], hit2Copy[2]/(double)nCopy[2], depthCopy[2]/(double)hit2Copy[2], 
   hitCopy[3]/(double)nCopy[3], hit2Copy[3]/(double)nCopy[3], depthCopy[3]/(double)hit2Copy[3]) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq 0x8(%rdi), %rax
movl 0x18(%rax), %ebx
movl %ebx, %eax
decl %eax
je 0x2e46
movq %rdi, %r14
movq %rax, 0xc0(%rsp)
movq (%rdi), %rdi
movq 0xabfd(%rip), %rsi      # 0xd370
callq 0x59a3
pxor %xmm0, %xmm0
movdqa %xmm0, 0xa0(%rsp)
movdqa %xmm0, 0x90(%rsp)
movq %r14, 0xc8(%rsp)
movq 0x8(%r14), %rcx
movq 0x8(%rcx), %rax
movl 0x14(%rcx), %ecx
cmpl $0x3, %ebx
movl $0x2, %edx
cmovael %ebx, %edx
leaq 0x24(%rax), %rsi
movq $0x0, 0x48(%rsp)
movl $0x1, %edi
movl %ecx, %r8d
movl $0x0, 0x34(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x28(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movq $0x0, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
movq $0x0, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movl %r8d, %r13d
addq %rsi, %r13
movl %ecx, %r11d
imull %edi, %r11d
movslq (%rax,%r11), %r10
movslq 0x1c(%rax,%r11), %r9
xorl %ebx, %ebx
movq (%r13,%rbx,4), %xmm0
pxor %xmm1, %xmm1
pcmpgtd %xmm0, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
paddq 0x90(%rsp,%rbx,8), %xmm0
movdqa %xmm0, 0x90(%rsp,%rbx,8)
addq $0x2, %rbx
cmpq $0x4, %rbx
jne 0x282e
movl 0x28(%rax,%r11), %ebx
cmpl $0x1, %ebx
je 0x2881
testl %ebx, %ebx
jne 0x2895
movq 0x40(%rsp), %rbx
incl %ebx
movq %rbx, 0x40(%rsp)
addq %r10, 0x88(%rsp)
jmp 0x2895
movq 0x38(%rsp), %rbx
incl %ebx
movq %rbx, 0x38(%rsp)
addq %r10, 0x80(%rsp)
movzbl 0x18(%rax,%r11), %r11d
testl %r11d, %r11d
je 0x28e7
incl %r14d
movl %r11d, %ebx
andl $0x1, %ebx
addl %ebx, %r15d
btl $0x1, %r11d
adcl $0x0, 0x28(%rsp)
btl $0x2, %r11d
adcl $0x0, 0x2c(%rsp)
btl $0x3, %r11d
adcl $0x0, 0x30(%rsp)
btl $0x4, %r11d
adcl $0x0, 0x34(%rsp)
btl $0x5, %r11d
movq 0x48(%rsp), %r11
adcl $0x0, %r11d
movq %r11, 0x48(%rsp)
addq %r10, %rbp
addq %r9, %r12
incq %rdi
addl %ecx, %r8d
cmpq %rdx, %rdi
jne 0x2816
movq 0xaa6d(%rip), %rdi      # 0xd370
movq %rbp, %xmm0
punpckldq 0x5700(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x5708(%rip), %xmm0     # 0x8020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0xf0(%rsp)
movq 0xc0(%rsp), %r13
movl %r13d, %eax
cvtsi2sd %rax, %xmm2
movsd %xmm2, 0xb8(%rsp)
movapd %xmm1, %xmm0
divsd %xmm2, %xmm0
leaq 0x580a(%rip), %rsi      # 0x815f
movl %r13d, %edx
movq %rbp, %rcx
movb $0x1, %al
callq 0x1130
movq 0xaa07(%rip), %rdi      # 0xd370
movq 0xc8(%rsp), %rbx
movq 0x10(%rbx), %rdx
movq %rdx, %xmm0
movq 0x568e(%rip), %xmm1     # 0x8010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x5692(%rip), %xmm3     # 0x8020
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movapd 0xf0(%rsp), %xmm0
divsd %xmm2, %xmm0
addq %rdx, %r12
movq %r12, %xmm4
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
subpd %xmm3, %xmm4
movapd %xmm4, %xmm3
unpckhpd %xmm4, %xmm3            # xmm3 = xmm3[1],xmm4[1]
addsd %xmm4, %xmm3
movapd %xmm2, %xmm1
divsd %xmm3, %xmm1
divsd 0xb8(%rsp), %xmm2
leaq 0x57ae(%rip), %rsi      # 0x818d
movb $0x3, %al
callq 0x1130
movq 0xa983(%rip), %rdi      # 0xd370
movsd 0x90(%rsp), %xmm1
movsd 0x5612(%rip), %xmm2     # 0x8010
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x5617(%rip), %xmm3     # 0x8020
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd %xmm2, %xmm6
subpd %xmm3, %xmm1
movapd %xmm3, %xmm7
movapd %xmm1, %xmm4
unpckhpd %xmm1, %xmm4            # xmm4 = xmm4[1],xmm1[1]
addsd %xmm1, %xmm4
divsd %xmm4, %xmm0
movq 0x98(%rsp), %r12
movq %r12, %xmm2
punpckldq %xmm6, %xmm2    # xmm2 = xmm2[0],xmm6[0],xmm2[1],xmm6[1]
subpd %xmm3, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd %xmm4, %xmm1
movsd 0xa0(%rsp), %xmm3
unpcklps %xmm6, %xmm3            # xmm3 = xmm3[0],xmm6[0],xmm3[1],xmm6[1]
subpd %xmm7, %xmm3
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addsd %xmm3, %xmm2
divsd %xmm4, %xmm2
movsd 0xa8(%rsp), %xmm5
unpcklps %xmm6, %xmm5            # xmm5 = xmm5[0],xmm6[0],xmm5[1],xmm6[1]
subpd %xmm7, %xmm5
movapd %xmm5, %xmm3
unpckhpd %xmm5, %xmm3            # xmm3 = xmm3[1],xmm5[1]
addsd %xmm5, %xmm3
divsd %xmm4, %xmm3
leaq 0x5726(%rip), %rsi      # 0x81cf
movb $0x4, %al
callq 0x1130
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %rcx
subl %edx, %r13d
subl %ecx, %r13d
movq 0xa8a9(%rip), %rdi      # 0xd370
movq 0x88(%rsp), %rax
movq %rax, %xmm1
movq 0x5534(%rip), %xmm3     # 0x8010
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x5538(%rip), %xmm4     # 0x8020
subpd %xmm4, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
divsd %xmm1, %xmm0
movq 0x80(%rsp), %rsi
movq %rsi, %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
movdqa %xmm3, %xmm6
subpd %xmm4, %xmm2
movapd %xmm4, %xmm7
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
divsd %xmm2, %xmm1
addq %rsi, %rax
subq %rax, %rbp
movq %rbp, %xmm3
punpckldq %xmm6, %xmm3    # xmm3 = xmm3[0],xmm6[0],xmm3[1],xmm6[1]
subpd %xmm4, %xmm3
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addsd %xmm3, %xmm2
xorps %xmm4, %xmm4
cvtsi2sd %r13, %xmm4
divsd %xmm4, %xmm2
movslq %ecx, %rcx
subq %rcx, %r12
movq %r12, %xmm5
punpckldq %xmm6, %xmm5    # xmm5 = xmm5[0],xmm6[0],xmm5[1],xmm6[1]
subpd %xmm7, %xmm5
movapd %xmm5, %xmm3
unpckhpd %xmm5, %xmm3            # xmm3 = xmm3[1],xmm5[1]
addsd %xmm5, %xmm3
divsd %xmm4, %xmm3
leaq 0x5687(%rip), %rsi      # 0x8213
movl %r13d, %r8d
movb $0x4, %al
callq 0x1130
movq 0xa7d3(%rip), %rdi      # 0xd370
leaq 0x56e5(%rip), %rsi      # 0x8289
movl %r14d, %edx
movl %r15d, %ecx
movl 0x28(%rsp), %r8d
movl 0x2c(%rsp), %r9d
xorl %eax, %eax
callq 0x1130
movq 0xa7ae(%rip), %rdi      # 0xd370
leaq 0x56ef(%rip), %rsi      # 0x82b8
movl 0x30(%rsp), %edx
movl 0x34(%rsp), %ecx
movq 0x48(%rsp), %r8
xorl %eax, %eax
callq 0x1130
xorpd %xmm0, %xmm0
movapd %xmm0, 0xe0(%rsp)
movapd %xmm0, 0xd0(%rsp)
movapd %xmm0, 0x50(%rsp)
movapd %xmm0, 0x60(%rsp)
movapd %xmm0, 0x70(%rsp)
movq (%rbx), %rcx
movl 0x40(%rcx), %esi
testl %esi, %esi
je 0x2d82
movq 0x30(%rcx), %rax
movq 0x38(%rcx), %rcx
incl %esi
cmpl $0x3, %esi
movl $0x2, %edx
cmovael %esi, %edx
movl $0x1, %esi
movzbl (%rcx,%rsi), %edi
andl $0x3, %edi
movl %edi, %r8d
incl 0x70(%rsp,%r8,4)
movzwl (%rax,%rsi,2), %r8d
testq %r8, %r8
je 0x2c5c
incl 0x60(%rsp,%rdi,4)
cmpl $0x1, %r8d
je 0x2c5c
incl 0x50(%rsp,%rdi,4)
addq %r8, 0xd0(%rsp,%rdi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0x2c2d
movl 0x60(%rsp), %ebx
movl 0x64(%rsp), %edi
movl 0x70(%rsp), %r14d
movl 0x74(%rsp), %r10d
movl 0x50(%rsp), %r15d
movl 0x54(%rsp), %r11d
movl 0x68(%rsp), %esi
movl 0x78(%rsp), %r8d
movl 0x58(%rsp), %r9d
movl 0x6c(%rsp), %edx
movl 0x7c(%rsp), %ecx
movl 0x5c(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rbx, %xmm0
cvtsi2sd %r14, %xmm9
cvtsi2sd %r15, %xmm1
movsd 0xd0(%rsp), %xmm3
movsd 0x5352(%rip), %xmm13    # 0x8010
unpcklps %xmm13, %xmm3           # xmm3 = xmm3[0],xmm13[0],xmm3[1],xmm13[1]
movapd 0x5356(%rip), %xmm2     # 0x8020
subpd %xmm2, %xmm3
movapd %xmm2, %xmm8
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addsd %xmm3, %xmm2
xorps %xmm3, %xmm3
cvtsi2sd %rdi, %xmm3
cvtsi2sd %r10, %xmm11
cvtsi2sd %r11, %xmm4
movsd 0xd8(%rsp), %xmm6
unpcklps %xmm13, %xmm6           # xmm6 = xmm6[0],xmm13[0],xmm6[1],xmm13[1]
subpd %xmm8, %xmm6
movapd %xmm6, %xmm5
unpckhpd %xmm6, %xmm5            # xmm5 = xmm5[1],xmm6[1]
addsd %xmm6, %xmm5
xorps %xmm6, %xmm6
cvtsi2sd %rsi, %xmm6
cvtsi2sd %r8, %xmm12
cvtsi2sd %r9, %xmm7
movsd 0xe0(%rsp), %xmm10
unpcklps %xmm13, %xmm10          # xmm10 = xmm10[0],xmm13[0],xmm10[1],xmm13[1]
subpd %xmm8, %xmm10
movapd %xmm10, %xmm8
unpckhpd %xmm10, %xmm8           # xmm8 = xmm8[1],xmm10[1]
addsd %xmm10, %xmm8
xorps %xmm10, %xmm10
cvtsi2sd %rdx, %xmm10
movsd 0xe8(%rsp), %xmm15
unpcklps %xmm13, %xmm15          # xmm15 = xmm15[0],xmm13[0],xmm15[1],xmm13[1]
cvtsi2sd %rcx, %xmm14
subpd 0x52b8(%rip), %xmm15    # 0x8020
movapd %xmm15, %xmm13
unpckhpd %xmm15, %xmm13          # xmm13 = xmm13[1],xmm15[1]
addsd %xmm15, %xmm13
xorps %xmm15, %xmm15
cvtsi2sd %rax, %xmm15
jmp 0x2dca
xorpd %xmm13, %xmm13
xorpd %xmm15, %xmm15
xorpd %xmm14, %xmm14
xorpd %xmm10, %xmm10
xorpd %xmm8, %xmm8
xorpd %xmm7, %xmm7
xorpd %xmm12, %xmm12
pxor %xmm6, %xmm6
xorpd %xmm5, %xmm5
xorpd %xmm4, %xmm4
xorpd %xmm11, %xmm11
xorpd %xmm3, %xmm3
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
xorpd %xmm9, %xmm9
xorpd %xmm0, %xmm0
movq 0xa59f(%rip), %rdi      # 0xd370
divsd %xmm9, %xmm0
divsd %xmm1, %xmm2
divsd %xmm9, %xmm1
divsd %xmm11, %xmm3
divsd %xmm4, %xmm5
divsd %xmm11, %xmm4
divsd %xmm12, %xmm6
divsd %xmm7, %xmm8
divsd %xmm12, %xmm7
divsd %xmm14, %xmm10
divsd %xmm15, %xmm13
divsd %xmm14, %xmm15
movsd %xmm13, 0x18(%rsp)
movsd %xmm15, 0x10(%rsp)
movsd %xmm10, 0x8(%rsp)
movsd %xmm8, (%rsp)
leaq 0x54b2(%rip), %rsi      # 0x82df
movb $0x8, %al
callq 0x1130
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x13ea
jmp 0x2e34