// File: /workspace/github_c_makefile_star2_O1/richarddurbin[P]hash10x/moshmap.c
// Function: referenceFastaRead
void referenceFastaRead (Reference *ref, FILE *f, BOOL isAdd)
{
  char *seq, *seqName ;
  int len ;
  U64 totLen = 0 ;
  
  dna2indexConv['N'] = dna2indexConv['n'] = 0 ; /* to get 2-bit encoding */
  while (readSequence (f, dna2indexConv, &seq, &seqName, 0, &len))
    { int id ;
      if (!dictAdd (ref->dict, seqName, &id)) die ("duplicate ref sequence name %s", seqName) ;
      array (ref->len, id, int) = len ;
      totLen += len ;
      SeqhashRCiterator *mi = moshRCiterator (ref->ms->hasher, seq, len) ;
      U64 hash ; int pos ;
      while (moshRCnext (mi, &hash, &pos, 0))
	{ U32 index = moshsetIndexFind (ref->ms, hash, isAdd) ;
	  if (index)
	    { if (ref->max+1 >= ref->size) die ("reference size overflow") ;
	      ref->index[ref->max] = index ;
	      ++ref->depth[index] ;
	      ref->offset[ref->max] = pos ;
	      ref->id[ref->max] = id ;
	      ++ref->max ;
	    }
	}
      seqhashRCiteratorDestroy (mi) ;
      free (seq) ; free (seqName) ;
    }
  fclose (f) ;

  fprintf (outFile, "  %d hashes from %d reference sequences, total length %lld\n",
	   ref->max, dictMax(ref->dict), totLen) ;
  int i ; U32 *d = &ref->depth[1] ; U32 n1 = 0, n2 = 0, nM = 0 ;
  for (i = 1 ; i <= ref->ms->max ; ++i, ++d)
    if (*d == 1) { msSetCopy1 (ref->ms, i) ; ++n1 ; }
    else if (*d == 2) { msSetCopy2 (ref->ms, i) ; ++n2 ; }
    else { msSetCopyM (ref->ms, i) ; ++nM ; }
  fprintf (outFile, "  %d copy 1, %d copy 2, %d multiple\n", n1, n2, nM) ;

  if (isAdd) moshsetPack (ref->ms) ;
  referencePack (ref) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, 0x8(%rsp)
movq %rsi, %r8
movq %rdi, %rbx
leaq 0x9846(%rip), %rsi      # 0xb730
xorl %eax, %eax
movl %eax, 0x1b8(%rsi)
movl %eax, 0x138(%rsi)
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x4(%rsp), %r9
movq %r8, 0x28(%rsp)
movq %r8, %rdi
xorl %r8d, %r8d
callq 0x2df4
movl $0x0, %r12d
testl %eax, %eax
je 0x2066
movsbl 0x8(%rsp), %r13d
leaq 0x40(%rsp), %rbp
leaq 0x24(%rsp), %r14
xorl %r12d, %r12d
movq %r12, 0x38(%rsp)
movq 0x40(%rbx), %rdi
movq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x5824
testl %eax, %eax
jne 0x1f67
movq 0x10(%rsp), %rsi
leaq 0x510a(%rip), %rdi      # 0x706a
xorl %eax, %eax
callq 0x614c
movl 0x4(%rsp), %r15d
movq 0x48(%rbx), %rdi
movl 0xc(%rsp), %esi
callq 0x5c6f
movl %r15d, (%rax)
movslq 0x4(%rsp), %rdx
movq (%rbx), %rax
movq (%rax), %rdi
movq 0x18(%rsp), %rsi
movq %rdx, 0x30(%rsp)
callq 0x437a
movq %rax, %r15
movq %rax, %rdi
movq %rbp, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x450c
testb %al, %al
je 0x2015
movq (%rbx), %rdi
movq 0x40(%rsp), %rsi
movl %r13d, %edx
callq 0x47f3
testl %eax, %eax
je 0x2010
movl %eax, %r12d
movl 0xc(%rbx), %eax
incl %eax
cmpl 0x8(%rbx), %eax
jb 0x1fdc
leaq 0x50b4(%rip), %rdi      # 0x7089
xorl %eax, %eax
callq 0x614c
movq 0x10(%rbx), %rax
movl 0xc(%rbx), %ecx
movl %r12d, (%rax,%rcx,4)
movq 0x28(%rbx), %rax
movl %r12d, %ecx
incl (%rax,%rcx,4)
movl 0x24(%rsp), %eax
movq 0x18(%rbx), %rcx
movl 0xc(%rbx), %edx
movl %eax, (%rcx,%rdx,4)
movl 0xc(%rsp), %eax
movq 0x20(%rbx), %rcx
movl 0xc(%rbx), %edx
movl %eax, (%rcx,%rdx,4)
incl 0xc(%rbx)
movq %r15, %rdi
jmp 0x1f9c
movq 0x38(%rsp), %r12
addq 0x30(%rsp), %r12
movq %r15, %rdi
callq 0x2149
movq 0x18(%rsp), %rdi
callq 0x1040
movq 0x10(%rsp), %rdi
callq 0x1040
movq 0x28(%rsp), %rdi
leaq 0x96e9(%rip), %rsi      # 0xb730
leaq 0x18(%rsp), %rdx
leaq 0x10(%rsp), %rcx
xorl %r8d, %r8d
leaq 0x4(%rsp), %r9
callq 0x2df4
testl %eax, %eax
jne 0x1f38
movq 0x28(%rsp), %rdi
callq 0x1090
movq 0xa2c9(%rip), %rdi      # 0xc340
movl 0xc(%rbx), %edx
movq 0x40(%rbx), %rax
movl 0x10(%rax), %ecx
leaq 0x5019(%rip), %rsi      # 0x70a1
movq %r12, %r8
xorl %eax, %eax
callq 0x1120
movq (%rbx), %rsi
cmpl $0x0, 0x40(%rsi)
movl $0x0, %ecx
movl $0x0, %r8d
movl $0x0, %edx
je 0x210e
movq 0x28(%rbx), %rax
xorl %r10d, %r10d
xorl %r8d, %r8d
xorl %ecx, %ecx
xorl %edx, %edx
movl 0x4(%rax,%r10,4), %r9d
movq 0x38(%rsi), %rsi
movb 0x1(%rsi,%r10), %dil
cmpl $0x2, %r9d
je 0x20e3
cmpl $0x1, %r9d
jne 0x20f4
andb $-0x4, %dil
incb %dil
movb %dil, 0x1(%rsi,%r10)
incl %edx
jmp 0x2100
andb $-0x4, %dil
orb $0x2, %dil
movb %dil, 0x1(%rsi,%r10)
incl %ecx
jmp 0x2100
orb $0x3, %dil
movb %dil, 0x1(%rsi,%r10)
incl %r8d
movq (%rbx), %rsi
movl 0x40(%rsi), %edi
incq %r10
cmpq %rdi, %r10
jb 0x20b9
movq 0xa22b(%rip), %rdi      # 0xc340
leaq 0x4fc1(%rip), %rsi      # 0x70dd
xorl %eax, %eax
callq 0x1120
cmpb $0x0, 0x8(%rsp)
je 0x2132
movq (%rbx), %rdi
callq 0x4729
movq %rbx, %rdi
callq 0x1d3a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq