// File: /workspace/github_c_makefile_star2_O3/richarddurbin[P]hash10x/moshasm.c
// Function: readsetFileRead
void readsetFileRead (Readset *rs, char *filename)
{
  char *seq ;			/* ignore the name for now */
  int len ;
  Array hitsA = arrayCreate (1024, U32) ; /* reuse these to build the lists of hits and dx */
  Array dxA = arrayCreate (1024, U16) ;

  memset (rs->ms->depth, 0, (rs->ms->max+1)*sizeof(U16)) ; /* rebuild depth from this file */
  dna2indexConv['N'] = dna2indexConv['n'] = 0 ; /* to get 2-bit encoding */
  SeqIO *si = seqIOopen (filename, dna2indexConv, FALSE) ;
  while (seqIOread (si))
    { Read *read = arrayp(rs->reads, arrayMax(rs->reads), Read) ;
      read->len = si->seqLen ;
      SeqhashRCiterator *mi = moshRCiterator (rs->ms->hasher, sqioSeq(si), si->seqLen) ;
      hitsA = arrayReCreate (hitsA, 1024, U32) ;
      dxA = arrayReCreate (dxA, 1024, U16) ;
      U64 hash ; int lastPos = 0, pos ; BOOL isForward ;
      while (moshRCnext (mi, &hash, &pos, &isForward))
	{ U32 index = moshsetIndexFind (rs->ms, hash, FALSE) ;
	  if (index)
	    { array(hitsA,read->nHit,U32) = isForward ? (index | TOPBIT) : index ;
	      array(dxA,read->nHit,U16) = pos - lastPos ; lastPos = pos ;
	      ++read->nHit ;
	      U16 *di = &rs->ms->depth[index] ; ++*di ; if (!*di) *di = U16MAX ;
	    }
	  else ++read->nMiss ;
	}
      seqhashRCiteratorDestroy (mi) ;
      if (read->nHit)
	{ read->hit = new (read->nHit, U32) ;
	  memcpy (read->hit, arrp(hitsA,0,U32), read->nHit*sizeof(U32)) ;
	  read->dx = new(read->nHit,U16) ;
	  memcpy (read->dx, arrp(dxA,0,U16), read->nHit*sizeof(U16)) ;
	  rs->totHit += read->nHit ;
	}
    }
  seqIOclose (si) ;

  invBuild (rs) ;
  arrayDestroy (hitsA) ; arrayDestroy (dxA) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movl $0x400, %edi            # imm = 0x400
movl $0x4, %esi
callq 0x6714
movq %rax, 0x10(%rsp)
movl $0x400, %edi            # imm = 0x400
movl $0x2, %esi
callq 0x6714
movq %rax, 0x8(%rsp)
movq (%rbx), %rax
movq 0x30(%rax), %rdi
movl 0x40(%rax), %edx
incl %edx
addq %rdx, %rdx
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x10e0
leaq 0xa23e(%rip), %rsi      # 0xc760
movl %ebp, 0x1b8(%rsi)
movl %ebp, 0x138(%rsi)
movq %r12, %rdi
xorl %edx, %edx
callq 0x3d9c
movq %rax, %r14
movq %rax, %rdi
callq 0x3f63
testb %al, %al
je 0x2709
movq %r14, 0x20(%rsp)
movq 0x8(%rbx), %rdi
movl 0x18(%rdi), %esi
callq 0x69bd
movq %rax, %r13
movl 0x18(%r14), %edx
movl %edx, (%rax)
cmpl $0x2, (%r14)
jne 0x2571
movq 0x70(%r14), %rsi
jmp 0x2579
movslq 0x24(%r14), %rsi
addq 0x50(%r14), %rsi
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x50c4
movq %rax, %rbp
movq 0x10(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movl $0x4, %edx
callq 0x6798
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movl $0x2, %edx
callq 0x6798
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x3(%rsp), %rcx
callq 0x526f
testb %al, %al
je 0x267b
xorl %r14d, %r14d
movq (%rbx), %rdi
movq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0x5563
testl %eax, %eax
je 0x2658
movl %eax, %r15d
movl %eax, %r12d
orl $0x80000000, %r12d      # imm = 0x80000000
cmpb $0x0, 0x3(%rsp)
cmovel %eax, %r12d
movl 0x4(%r13), %esi
movq 0x10(%rsp), %rdi
callq 0x69bd
movl %r12d, (%rax)
movl 0x4(%rsp), %r12d
subl %r14d, %r12d
movl 0x4(%r13), %esi
movq 0x8(%rsp), %rdi
callq 0x69bd
movw %r12w, (%rax)
movl 0x4(%rsp), %r14d
incl 0x4(%r13)
movq (%rbx), %rax
movq 0x30(%rax), %rax
movl %r15d, %ecx
movzwl (%rax,%rcx,2), %edx
movl $0xffff, %esi           # imm = 0xFFFF
incw %dx
je 0x2652
movl %edx, %esi
movw %si, (%rax,%rcx,2)
jmp 0x265c
incl 0x1c(%r13)
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x3(%rsp), %rcx
callq 0x526f
testb %al, %al
jne 0x25db
movq 0x28(%rbp), %rdi
callq 0x1040
movq 0x30(%rbp), %rdi
callq 0x1040
movq %rbp, %rdi
callq 0x1040
movslq 0x4(%r13), %rdi
testq %rdi, %rdi
je 0x26f4
shlq $0x2, %rdi
callq 0x6f4c
movq %rax, 0x8(%r13)
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rsi
movslq 0x4(%r13), %rdx
shlq $0x2, %rdx
movq %rax, %rdi
callq 0x1150
movslq 0x4(%r13), %rdi
addq %rdi, %rdi
callq 0x6f4c
movq %rax, 0x10(%r13)
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rsi
movslq 0x4(%r13), %rdx
addq %rdx, %rdx
movq %rax, %rdi
callq 0x1150
movslq 0x4(%r13), %rax
addq %rax, 0x10(%rbx)
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x3f63
testb %al, %al
jne 0x2550
movq %r14, %rdi
callq 0x3f28
movq %rbx, %rdi
callq 0x2337
movq 0x10(%rsp), %rdi
callq 0x6862
movq 0x8(%rsp), %rdi
callq 0x6862
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq