// File: /workspace/github_c_makefile_star2_O3/richarddurbin[P]hash10x/moshmap.c
// Function: queryProcess
void queryProcess (Reference *ref, FILE *f)
{
  char *seq, *seqName ;
  int len ;
  Array seeds = 0 ;

  dna2indexConv['N'] = dna2indexConv['n'] = 0 ; /* to get 2-bit encoding */
  while (readSequence (f, dna2indexConv, &seq, &seqName, 0, &len))
    { SeqhashRCiterator *mi = moshRCiterator (ref->ms->hasher, seq, len) ;
      U64 hash ; int pos ;
      seeds = arrayReCreate (seeds, 1024, Seed) ;
      int missed = 0, copy[4] ; copy[1] = copy[2] = copy[3] = 0 ;
      while (moshRCnext (mi, &hash, &pos, 0))
	{ U32 index = moshsetIndexFind (ref->ms, hash, FALSE) ;
	  Seed *s = arrayp(seeds,arrayMax(seeds),Seed) ;
	  s->index = index ; s->pos = pos ;
	  if (index) ++copy[msCopy(ref->ms,index)] ;
	  else ++missed ;
	}
      seqhashRCiteratorDestroy (mi) ;
      fprintf (outFile, "Q\t%s\t%d\t%d miss, %d copy1, %d copy2, %d multi, %.2f hit\n",
	       seqName, len, missed, copy[1], copy[2], copy[3],
	       (arrayMax(seeds)-missed)/(double)(arrayMax(seeds))) ;

      int i ;
      U32 loc0 = 0, locN, i0, iN ;
      int n1 = 0, n2 = 0 ;
      for (i = 0 ; i < arrayMax(seeds) ; ++i)
	{ Seed *s = arrp (seeds, i, Seed) ;
	  if (s->index && !msIsCopyM(ref->ms,s->index)) /* ignore multi-hits for now */
	    { U32 loc = ref->rev[ref->loc[s->index]] ;
	      BOOL is1 = msIsCopy1(ref->ms,s->index) ;
	      if (isVerbose)
		{ if (is1)
		    printf ("  %6d\t%s %d\n", s->pos,
			    dictName(ref->dict,ref->id[loc]), ref->offset[loc]) ;
		  else
		    { U32 loc2 = ref->rev[ref->loc[s->index]+1] ;
		      printf ("  %6d\t%s %d\t%s %d\n", s->pos,
			      dictName(ref->dict,ref->id[loc]), ref->offset[loc],
			      dictName(ref->dict,ref->id[loc2]), ref->offset[loc2]) ;
		    }
		}
	      BOOL endBlock = FALSE ;
	      if (!loc0 || ref->id[loc] != ref->id[loc0]) endBlock = TRUE ;
	      else if (loc0 < locN)
		{ if (loc < locN) endBlock = TRUE ;
		  int d = locN - loc0 - iN + i0 ; if (d > 50 || d < -50) endBlock = TRUE ;
		}
	      else if (loc0 > locN)
		{ if (loc > locN) endBlock = TRUE ;
		  int d = loc0 - locN - iN + i0 ; if (d > 50 || d < -50) endBlock = TRUE ;
		}
	      if (endBlock && loc0 && !is1) /* try the second loc */
		{ loc = ref->rev[ref->loc[s->index]+1] ;
		  endBlock = FALSE ;
		  if (ref->id[loc] != ref->id[loc0]) endBlock = TRUE ;
		   else if (loc0 < locN)
		     { if (loc < locN) endBlock = TRUE ;
		       int d = locN - loc0 - iN + i0 ; if (d > 50 || d < -50) endBlock = TRUE ;
		     }
		   else if (loc0 > locN)
		     { if (loc > locN) endBlock = TRUE ;
		       int d = loc0 - locN - iN + i0 ; if (d > 50 || d < -50) endBlock = TRUE ;
		     }
		}
	      if (endBlock)
		{ if (n1 > 2)
		    fprintf (outFile, "M\t%s\t%d\t%d\t%d\t%s\t%d\t%d\t%d %d\t%.2f\t%.2f\n",
			     seqName, arrp(seeds,i0,Seed)->pos, arrp(seeds,iN,Seed)->pos, len,
			     dictName(ref->dict,ref->id[loc0]),
			     ref->offset[loc0], ref->offset[locN],
			     n1, n2, (n1+n2) / (double)((locN>loc0) ? (locN-loc0) : (loc0-locN)),
			     n1 / (double)copy[1]) ;
		  n1 = 0 ; n2 = 0 ; loc0 = loc ; i0 = i ;
		}
	      if (is1) ++n1 ; else ++n2 ; locN = loc ; iN = i ;
	    }
	}
      if (n2 > 2)
	fprintf (outFile, "M\t%s\t%d\t%d\t%d\t%s\t%d\t%d\t%d %d\t%.2f\t%.2f\n",
		 seqName, arrp(seeds,i0,Seed)->pos, arrp(seeds,iN,Seed)->pos, len,
		 dictName(ref->dict,ref->id[loc0]),
		 ref->offset[loc0], ref->offset[locN],
		 n1, n2, (n1+n2) / (double)((locN>loc0) ? (locN-loc0) : (loc0-locN)),
		 n1 / (double)copy[1]) ;

      free (seq) ; free (seqName) ;
    }

  arrayDestroy (seeds) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %rax
movq %rdi, %r13
leaq 0x8ec0(%rip), %rsi      # 0xb730
xorl %r15d, %r15d
movl %r15d, 0x1b8(%rsi)
movl %r15d, 0x138(%rsi)
leaq 0x70(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0x14(%rsp), %r9
movq %rax, 0xa8(%rsp)
movq %rax, %rdi
xorl %r8d, %r8d
callq 0x3020
testl %eax, %eax
je 0x2f6d
xorl %r15d, %r15d
movq %rax, 0x50(%rsp)
movq %rax, 0x8(%rsp)
movq %rax, 0x30(%rsp)
movq %r13, 0x20(%rsp)
movq (%r13), %rax
movq (%rax), %rdi
movq 0x70(%rsp), %rsi
movl 0x14(%rsp), %edx
callq 0x4624
movq %rax, %rbx
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
movl $0x8, %edx
callq 0x5cf8
movq %rax, %r15
movl $0x0, 0x8c(%rsp)
movq $0x0, 0x84(%rsp)
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x6c(%rsp), %rdx
xorl %ecx, %ecx
callq 0x47cf
movl $0x0, %r13d
movl $0x0, %r14d
movl $0x0, %r12d
movl $0x0, %ebp
testb %al, %al
je 0x29c5
xorl %ebp, %ebp
movq 0x20(%rsp), %r14
leaq 0xa0(%rsp), %r13
movq (%r14), %rdi
movq 0xa0(%rsp), %rsi
xorl %edx, %edx
callq 0x4ac3
movl %eax, %r12d
movl 0x18(%r15), %esi
movq %r15, %rdi
callq 0x5f1d
movl %r12d, (%rax)
movl 0x6c(%rsp), %ecx
movl %ecx, 0x4(%rax)
testl %r12d, %r12d
je 0x2995
movq (%r14), %rax
movq 0x38(%rax), %rax
movl %r12d, %ecx
movzbl (%rax,%rcx), %eax
andl $0x3, %eax
incl 0x80(%rsp,%rax,4)
jmp 0x2997
incl %ebp
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x6c(%rsp), %rdx
xorl %ecx, %ecx
callq 0x47cf
testb %al, %al
jne 0x294b
movl 0x84(%rsp), %r12d
movl 0x88(%rsp), %r14d
movl 0x8c(%rsp), %r13d
movq %rbx, %rdi
callq 0x2318
movq 0x9974(%rip), %rdi      # 0xc348
movq 0x60(%rsp), %rdx
movl 0x14(%rsp), %ecx
movl 0x18(%r15), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
subl %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
leaq 0x492d(%rip), %rsi      # 0x7329
movl %ebp, %r8d
movl %r12d, %r9d
movb $0x1, %al
pushq %r13
pushq %r14
callq 0x1120
addq $0x10, %rsp
movl 0x18(%r15), %eax
testl %eax, %eax
jle 0x2f26
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd %xmm0, 0x98(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %edi, %edi
movq $0x0, 0x28(%rsp)
xorl %r11d, %r11d
movq 0x20(%rsp), %r13
movq %r15, 0x58(%rsp)
movq 0x8(%rsp), %r8
movq 0x50(%rsp), %r9
movq 0x30(%rsp), %r10
movq 0x8(%r15), %rbx
movslq 0x14(%r15), %rcx
movslq %r12d, %r14
imulq %rcx, %r14
movl (%rbx,%r14), %ecx
testq %rcx, %rcx
je 0x2e18
movq (%r13), %rdx
movq 0x38(%rdx), %rdx
movq %r13, %rsi
movb (%rdx,%rcx), %r13b
andb $0x3, %r13b
cmpb $0x3, %r13b
jne 0x2a97
movq %rsi, %r13
jmp 0x2e18
movq 0x30(%rsi), %rax
movq 0x38(%rsi), %rdx
movl (%rdx,%rcx,4), %ecx
movl (%rax,%rcx,4), %esi
cmpb $0x0, 0x9894(%rip)      # 0xc340
movq %r9, 0x50(%rsp)
je 0x2bcb
movq %rdi, 0x40(%rsp)
movq %r11, 0x48(%rsp)
movq %r10, 0x30(%rsp)
movq %r8, 0x8(%rsp)
cmpb $0x1, %r13b
jne 0x2b1f
movl 0x4(%rbx,%r14), %eax
movl %eax, (%rsp)
movq 0x20(%rsp), %r15
movq 0x20(%r15), %rax
movq 0x40(%r15), %rdi
movb %r13b, 0x18(%rsp)
movq %rsi, %r13
movl (%rax,%rsi,4), %esi
callq 0x5c67
movq 0x18(%r15), %rcx
movl (%rcx,%r13,4), %ecx
leaq 0x485d(%rip), %rdi      # 0x7362
movl (%rsp), %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x10b0
movq %r13, %rsi
movb 0x18(%rsp), %r13b
jmp 0x2bad
incl %ecx
movl (%rax,%rcx,4), %eax
movq %rax, 0x18(%rsp)
movl 0x4(%rbx,%r14), %eax
movl %eax, 0x3c(%rsp)
movq 0x20(%rsp), %r15
movq 0x20(%r15), %rax
movq 0x40(%r15), %rdi
movq %rsi, (%rsp)
movq (%rsp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x5c67
movq %rax, 0xb0(%rsp)
movq 0x18(%r15), %rax
movq 0x20(%r15), %rcx
movq (%rsp), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, 0x7c(%rsp)
movq 0x40(%r15), %rdi
movq 0x18(%rsp), %rax
movl (%rcx,%rax,4), %esi
callq 0x5c67
movq 0x18(%r15), %rcx
movq 0x18(%rsp), %rdx
movl (%rcx,%rdx,4), %r9d
leaq 0x47e0(%rip), %rdi      # 0x736f
movl 0x3c(%rsp), %esi
movq 0xb0(%rsp), %rdx
movl 0x7c(%rsp), %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x10b0
movq (%rsp), %rsi
movq 0x58(%rsp), %r15
movq 0x8(%rsp), %r8
movq 0x50(%rsp), %r9
movq 0x30(%rsp), %r10
movq 0x48(%rsp), %r11
movq 0x40(%rsp), %rdi
testl %edi, %edi
je 0x2ce2
movq 0x20(%rsp), %rax
movq 0x20(%rax), %rax
movl %edi, %ecx
movl (%rax,%rcx,4), %ecx
movb $0x1, %dl
cmpl %ecx, (%rax,%rsi,4)
jne 0x2c58
cmpl %edi, %r9d
jbe 0x2c15
cmpl %r9d, %esi
movq %rsi, (%rsp)
setb %sil
movl %r8d, %edx
subl %r10d, %edx
addl %r9d, %edx
addl %ebp, %edx
addl $-0x33, %edx
cmpl $-0x65, %edx
setb %dl
orb %sil, %dl
movq (%rsp), %rsi
jmp 0x2c58
jae 0x2de7
cmpl %r9d, %esi
movb %r13b, 0x18(%rsp)
movq %rsi, (%rsp)
seta %r13b
movq %r8, %rsi
movq %rdi, %r8
movl %esi, %edi
subl %r10d, %edi
subl %r9d, %edi
leal (%rdi,%r8), %edx
addl $-0x33, %edx
movq %r8, %rdi
movq %rsi, %r8
cmpl $-0x65, %edx
setb %dl
orb %r13b, %dl
movq (%rsp), %rsi
movb 0x18(%rsp), %r13b
cmpb $0x1, %r13b
je 0x2cda
testb %dl, %dl
je 0x2cda
movq %r8, 0x8(%rsp)
movq %rdi, %r8
movq 0x20(%rsp), %rsi
movq 0x30(%rsi), %rdx
movq 0x38(%rsi), %rsi
movl (%rbx,%r14), %edi
movl (%rsi,%rdi,4), %esi
incl %esi
movl (%rdx,%rsi,4), %esi
cmpl %ecx, (%rax,%rsi,4)
jne 0x2cab
movq %r8, %rdi
cmpl %edi, %r9d
jbe 0x2cb5
cmpl %r9d, %esi
setb %dl
movq 0x8(%rsp), %r8
movl %r8d, %eax
subl %r10d, %eax
addl %r9d, %eax
addl %ebp, %eax
addl $-0x33, %eax
jmp 0x2cd5
movq %r8, %rdi
movq 0x8(%rsp), %r8
jmp 0x2ce2
movq 0x8(%rsp), %r8
jae 0x2de7
cmpl %r9d, %esi
seta %dl
movl %r8d, %ecx
subl %r10d, %ecx
subl %r9d, %ecx
leal (%rcx,%rdi), %eax
addl $-0x33, %eax
cmpl $-0x65, %eax
jb 0x2ce2
testb %dl, %dl
je 0x2de7
xorl %edx, %edx
cmpl $0x3, %r11d
jl 0x2dde
movl %edi, %eax
subl %r9d, %eax
negl %eax
movl %edi, %r14d
subl %r9d, %r14d
movq 0x9646(%rip), %rcx      # 0xc348
movq %rcx, 0x30(%rsp)
movq 0x60(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%r15), %rcx
movl 0x14(%r15), %edx
cmovbl %eax, %r14d
imull %edx, %r8d
movl 0x4(%rcx,%r8), %eax
movl %eax, 0x40(%rsp)
imull %edx, %r10d
movl 0x4(%rcx,%r10), %eax
movl %eax, 0x18(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x20(%rsp), %r15
movq 0x20(%r15), %rax
movq %rdi, %rcx
movq 0x40(%r15), %rdi
movl %ecx, %ebp
movq %rsi, (%rsp)
movl (%rax,%rbp,4), %esi
movq %r11, %rbx
callq 0x5c67
movq %rax, 0x48(%rsp)
movq 0x18(%r15), %rax
movq 0x58(%rsp), %r15
movl (%rax,%rbp,4), %r11d
movl 0x50(%rsp), %ecx
movl (%rax,%rcx,4), %ebp
movq 0x28(%rsp), %r10
leal (%r10,%rbx), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sd %r14, %xmm1
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
divsd 0x98(%rsp), %xmm1
subq $0x8, %rsp
movq 0x38(%rsp), %rdi
leaq 0x45d3(%rip), %rsi      # 0x7382
movq 0x10(%rsp), %rdx
movl 0x48(%rsp), %ecx
movl 0x20(%rsp), %r8d
movl 0x44(%rsp), %r9d
movb $0x2, %al
pushq %r10
pushq %rbx
pushq %rbp
pushq %r11
pushq 0x70(%rsp)
callq 0x1120
xorl %edx, %edx
movq 0x30(%rsp), %rsi
addq $0x30, %rsp
xorl %ecx, %ecx
movl %r12d, %r8d
movl %esi, %edi
jmp 0x2def
movl %r11d, %edx
movq 0x28(%rsp), %rcx
xorl %eax, %eax
xorl %r11d, %r11d
cmpb $0x1, %r13b
setne %al
sete %r11b
addl %edx, %r11d
addl %eax, %ecx
movq %rcx, 0x28(%rsp)
movl 0x18(%r15), %eax
movl %r12d, %r10d
movl %esi, %r9d
movq 0x20(%rsp), %r13
incl %r12d
movl %edi, %ebp
negl %ebp
cmpl %eax, %r12d
jl 0x2a5a
movq 0x28(%rsp), %rbp
cmpl $0x3, %ebp
movq %r8, 0x8(%rsp)
movq %r9, 0x50(%rsp)
movq %r10, 0x30(%rsp)
jl 0x2f2b
movl %edi, %eax
subl %r9d, %eax
negl %eax
movl %edi, %ebx
subl %r9d, %ebx
movq 0x94f0(%rip), %rcx      # 0xc348
movq %rcx, 0x48(%rsp)
movq 0x60(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x8(%r15), %rcx
movl 0x14(%r15), %edx
cmovbl %eax, %ebx
movl %edx, %eax
imull %r8d, %eax
movl 0x4(%rcx,%rax), %eax
movl %eax, 0x40(%rsp)
imull %r10d, %edx
movl 0x4(%rcx,%rdx), %eax
movl %eax, 0x58(%rsp)
movq %rbp, 0x28(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x18(%rsp)
movq 0x20(%r13), %rax
movq %rdi, %rcx
movq 0x40(%r13), %rdi
movl %ecx, %r14d
movl (%rax,%r14,4), %esi
movq %r9, %r12
movq %r11, %rbp
callq 0x5c67
movq %rax, %r10
movq 0x18(%r13), %rax
movl (%rax,%r14,4), %r11d
movl %r12d, %ecx
movl (%rax,%rcx,4), %r14d
movq 0x28(%rsp), %r12
leal (%r12,%rbp), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sd %rbx, %xmm1
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
divsd 0x98(%rsp), %xmm1
subq $0x8, %rsp
movq 0x50(%rsp), %rdi
leaq 0x4485(%rip), %rsi      # 0x7382
movq 0x8(%rsp), %rdx
movl 0x48(%rsp), %ecx
movl 0x60(%rsp), %r8d
movl 0x20(%rsp), %r9d
movb $0x2, %al
pushq %r12
pushq %rbp
pushq %r14
pushq %r11
pushq %r10
callq 0x1120
addq $0x30, %rsp
jmp 0x2f2b
movq 0x20(%rsp), %r13
movq 0x70(%rsp), %rdi
callq 0x1040
movq 0x60(%rsp), %rdi
callq 0x1040
movq 0xa8(%rsp), %rdi
leaq 0x87e2(%rip), %rsi      # 0xb730
leaq 0x70(%rsp), %rdx
leaq 0x60(%rsp), %rcx
xorl %r8d, %r8d
leaq 0x14(%rsp), %r9
callq 0x3020
testl %eax, %eax
jne 0x28c2
movq %r15, %rdi
callq 0x5dc2
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq