// File: /workspace/github_c_makefile_star2_O1/richarddurbin[P]hash10x/moshasm.c
// Function: markContained
void markContained (Readset *rs) 
{
  int ix, io ;
  Read *x, *x0 = arrp(rs->reads,0,Read) ;
  int nContained = 0, nNotContained = 0 ;
  U64 totLen = 0 ;
  Array overlaps = 0 ;
  
  for (ix = 0, x = x0 ; ix < arrayMax(rs->reads) ; ++ix, ++x)
    { if (overlaps) { arrayDestroy (overlaps) ; overlaps = 0 ; }
      if (x->bad) continue ;
      overlaps = findOverlaps (rs, x, 0) ;
      int maxHit = 0 ;
      for (io = 0 ; io < arrayMax (overlaps) ; ++io)
	{ Overlap *o = arrp(overlaps,io,Overlap) ;
	  if (o->iy == ix) continue ; /* don't allow self-containment! */
	  Read *y = arrp(rs->reads,o->iy,Read) ;
	  if (y->len < x->len || o->nHit <= maxHit) continue ;
	  if (o->isPlus && (o->offset > 0 || o->offset + y->len < x->len)) continue ;
	  if (!o->isPlus && (o->offset < x->len || o->offset - y->len > 0)) continue ;
	  x->contained = o->iy ; maxHit = o->nHit ;
	}
      if (x->contained) ++nContained ; else { ++nNotContained ; totLen += x->len ; }
    }
  printf ("MC  found %d contained reads, leaving %d not contained, av length %.1f\n",
	  nContained, nNotContained, nNotContained ? totLen/(double)nNotContained : 0.) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x8(%rdi), %rax
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
cmpl $0x0, 0x18(%rax)
jle 0x377e
movq %rdi, %r14
movq 0x8(%rax), %r15
xorl %r12d, %r12d
xorl %edi, %edi
movq $0x0, 0x10(%rsp)
movl $0x0, 0x4(%rsp)
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x3690
callq 0x658d
cmpb $0x0, 0x18(%r15)
je 0x369e
xorl %edi, %edi
jmp 0x3742
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2cbe
movq %rax, %rdi
movslq 0x18(%rax), %rax
testq %rax, %rax
jle 0x372b
movq 0x8(%rdi), %rcx
movslq 0x14(%rdi), %rdx
addq $0xc, %rcx
xorl %esi, %esi
movl -0xc(%rcx), %r8d
cmpl %r12d, %r8d
je 0x3723
movq 0x8(%r14), %r9
movq 0x8(%r9), %r10
movl 0x14(%r9), %r9d
imull %r8d, %r9d
movl (%r10,%r9), %r10d
movl (%r15), %r11d
cmpl %r11d, %r10d
jl 0x3723
movl -0x8(%rcx), %r9d
cmpl %esi, %r9d
jle 0x3723
movb (%rcx), %r13b
testb %r13b, %r13b
je 0x370f
movl -0x4(%rcx), %ebp
testl %ebp, %ebp
jg 0x3723
addl %r10d, %ebp
cmpl %r11d, %ebp
jl 0x3723
testb %r13b, %r13b
jne 0x371c
movl -0x4(%rcx), %ebp
cmpl %r11d, %ebp
jl 0x3723
cmpl %r10d, %ebp
jg 0x3723
movl %r8d, 0x20(%r15)
movl %r9d, %esi
addq %rdx, %rcx
decq %rax
jne 0x36c5
cmpl $0x0, 0x20(%r15)
je 0x3736
incl %ebx
jmp 0x3742
incl 0x4(%rsp)
movslq (%r15), %rax
addq %rax, 0x10(%rsp)
incl %r12d
addq $0x48, %r15
movq 0x8(%r14), %rax
cmpl 0x18(%rax), %r12d
jl 0x3686
movsd 0x10(%rsp), %xmm1
unpcklps 0x48ac(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x48b4(%rip), %xmm1     # 0x8020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movl 0x4(%rsp), %edx
jmp 0x3782
xorl %ebx, %ebx
xorl %edx, %edx
testl %edx, %edx
je 0x3797
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x4d0c(%rip), %rdi      # 0x84aa
movl %ebx, %esi
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0