// File: /workspace/github_c_makefile_star2_O2/richarddurbin[P]hash10x/seqio.c
// Function: seqIOread
BOOL seqIOread (SeqIO *si)
{
  if (!si->nb) return FALSE ;
  si->recStart = si->b - si->buf ;
  
  if (si->type == BINARY)
    { bufConfirmNbytes (si, 3*sizeof(int)) ;
      si->idLen = *((int*)si->b) ; si->b += sizeof(int) ;
      si->descLen = *((int*)si->b) ; si->b += sizeof(int) ;
      si->seqLen = *((int*)si->b) ; si->b += sizeof(int) ;
      si->nb -= 3*sizeof(int) ;
      int nBytes = si->idLen+1 + si->descLen+1
	+ (si->seqLen+3)/4 + si->isQual ? (si->seqLen+7)/8 : 0 ;
      nBytes = 4*((nBytes+3)/4) ;
      bufConfirmNbytes (si, nBytes) ;
      si->idStart = si->b - si->buf ;
      si->descStart = si->idStart + si->idLen+1 ;
      if (si->seqLen > si->seqBufSize)
	{ if (si->seqBufSize) { free (si->seqBuf) ; if (si->isQual) free (si->qualBuf) ; }
	  si->seqBufSize = 1 << 20 ; while (si->seqBufSize < si->seqLen) si->seqBufSize <<= 1 ;
	  si->seqBuf = new (si->seqBufSize, char) ;
	  if (si->isQual) si->qualBuf = new (si->seqBufSize, char) ;
	}
      si->seqStart = si->descStart + si->descLen+1 ;
      sqioSeqUnpack ((U8*)(si->buf+si->seqStart), si->seqBuf, si->seqLen) ;
      if (si->isQual)
	{ si->qualStart = si->seqStart + (si->seqLen+3)/4 ;
	  sqioQualUnpack ((U8*)(si->buf+si->qualStart), si->qualBuf, si->seqLen, si->qualThresh) ;
	}
      ++si->nSeq ;
      si->b += nBytes ; si->nb -= nBytes ;
      return TRUE ;
    }

  /* if get to here then this is a text file, FASTA or FASTQ */
  
  if (si->type == FASTA)
    { if (*si->b != '>') die ("no initial > for FASTA record line %d", si->line) ; }
  else if (si->type == FASTQ)
    { if (*si->b != '@') die ("no initial @ for FASTQ record line %d", si->line) ; }
  bufAdvanceInRecord(si) ; si->idStart = si->b - si->buf ;
  while (!isspace(*si->b)) bufAdvanceInRecord(si) ;
  si->idLen = si->b - sqioId(si) ;
  if (*si->b != '\n') /* a space or tab - whatever follows on this line is description */
    { *si->b = 0 ; bufAdvanceInRecord(si) ;
      si->descStart = si->b - si->buf ;
      while (*si->b != '\n') bufAdvanceInRecord(si) ;
      si->descLen = si->b - sqioDesc(si) ;
    }
  else { si->descLen = si->descStart = 0 ; }
  *si->b = 0 ;
  ++si->line ; bufAdvanceInRecord(si) ;	              /* line 2 */
  si->seqStart = si->b - si->buf ;
  if (si->type == FASTA)
    { while (si->nb && *si->b != '>')
	{ while (*si->b != '\n') bufAdvanceInRecord(si) ;
	  ++si->line ; bufAdvanceEndRecord(si) ;
	}
      char *s = sqioSeq(si), *t = s ;
      while (s < si->b) if ((*t++ = si->convert[*s++]) < 0) --t ;
      si->seqLen = t - sqioSeq(si) ;
    }
  else if (si->type == FASTQ)
    { while (*si->b != '\n') bufAdvanceInRecord(si) ;
      si->seqLen = si->b - sqioSeq(si) ;
      if (si->convert)
	{ char *s = sqioSeq(si) ;
	  while (s < si->b) { *s = si->convert[*s] ; ++s ; }
	}
      ++si->line ; bufAdvanceInRecord(si) ; 	      /* line 3 */
      if (*si->b != '+') die ("missing + FASTQ line %d", si->line) ;
      while (*si->b != '\n') bufAdvanceInRecord(si) ; /* ignore remainder of + line */
      ++si->line ; bufAdvanceInRecord(si) ;	      /* line 4 */
      si->qualStart = si->b - si->buf ;
      while (*si->b != '\n') bufAdvanceInRecord(si) ;
      if (si->b - si->buf - si->qualStart != si->seqLen)
	die ("qual not same length as seq line %d", si->line) ;
      if (si->isQual) { char *q = sqioQual(si), *e = q + si->seqLen ; while (q < e) *q++ -= 33 ; }
      ++si->line ; bufAdvanceEndRecord(si) ;
    }

  ++si->nSeq ;
  return TRUE ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x38(%rdi), %esi
testl %esi, %esi
je 0x2839
movq %rdi, %rbx
movq 0x58(%rdi), %rax
movl 0x50(%rdi), %edx
movl %eax, %ecx
subl %edx, %ecx
movl %ecx, 0x40(%rdi)
movl (%rdi), %edx
testl %edx, %edx
je 0x284e
cmpl $0x1, %edx
je 0x2840
cmpl $0x2, %edx
jne 0x2864
cmpl $0xb, %esi
ja 0x26ab
testl %ecx, %ecx
je 0x26ab
movq %rbx, %rdi
callq 0x2dfe
movl 0x38(%rbx), %esi
movq 0x58(%rbx), %rax
cmpl $0xb, %esi
ja 0x26d9
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2d66
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %esi
cmpl $0xc, %esi
jb 0x2d66
movq 0x58(%rbx), %rax
movl (%rax), %edi
movl %edi, 0x10(%rbx)
movl 0x4(%rax), %r8d
movl %r8d, 0x14(%rbx)
movl 0x8(%rax), %ecx
movl %ecx, 0x18(%rbx)
addq $0xc, %rax
movq %rax, 0x58(%rbx)
addl $-0xc, %esi
movl %esi, 0x38(%rbx)
leal 0x3(%rcx), %eax
pushq $0x4
popq %r14
cltd
idivl %r14d
addl %r8d, %edi
addl %edi, %eax
addl $0x2, %eax
movsbl 0x2c(%rbx), %edx
xorl %ebp, %ebp
addl %eax, %edx
je 0x272e
addl $0x7, %ecx
pushq $0x8
popq %rdi
movl %ecx, %eax
cltd
idivl %edi
addl $0x3, %eax
cltd
idivl %r14d
movl %eax, %ebp
shll $0x2, %ebp
cmpl %ebp, %esi
jge 0x2743
cmpl $0x0, 0x40(%rbx)
je 0x2743
movq %rbx, %rdi
callq 0x2dfe
movl 0x38(%rbx), %esi
cmpl %ebp, %esi
jge 0x2760
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, 0x58(%rbx)
jne 0x2760
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %esi
cmpl %ebp, %esi
jl 0x2d66
movl 0x58(%rbx), %eax
subl 0x50(%rbx), %eax
movl %eax, 0x1c(%rbx)
movl 0x10(%rbx), %ecx
movl 0x18(%rbx), %edx
addl %ecx, %eax
incl %eax
movl %eax, 0x20(%rbx)
movl 0x68(%rbx), %eax
cmpl %eax, %edx
jle 0x27d4
testl %eax, %eax
je 0x27a1
movq 0x70(%rbx), %rdi
callq 0x1040
cmpb $0x0, 0x2c(%rbx)
je 0x27a1
movq 0x78(%rbx), %rdi
callq 0x1040
movl 0x18(%rbx), %eax
movl $0x100000, %edx         # imm = 0x100000
movl %edx, %ecx
leal (%rcx,%rcx), %edx
cmpl %eax, %ecx
jl 0x27a9
movl %ecx, 0x68(%rbx)
movslq %ecx, %rdi
callq 0x5258
movq %rax, 0x70(%rbx)
cmpb $0x0, 0x2c(%rbx)
je 0x27d4
movslq 0x68(%rbx), %rdi
callq 0x5258
movq %rax, 0x78(%rbx)
movl 0x20(%rbx), %eax
movl 0x14(%rbx), %ecx
movl 0x18(%rbx), %edx
addl %ecx, %eax
incl %eax
movl %eax, 0x24(%rbx)
movslq %eax, %rdi
addq 0x50(%rbx), %rdi
movq 0x70(%rbx), %rsi
callq 0x2eb1
cmpb $0x0, 0x2c(%rbx)
je 0x2826
movslq 0x24(%rbx), %rsi
movl 0x18(%rbx), %r8d
movl 0x30(%rbx), %ecx
leal 0x3(%r8), %eax
cltd
idivl %r14d
movslq %eax, %rdi
addq %rsi, %rdi
movl %edi, 0x28(%rbx)
addq 0x50(%rbx), %rdi
movq 0x78(%rbx), %rsi
movl %r8d, %edx
callq 0x2f12
incq 0x8(%rbx)
movslq %ebp, %rax
addq %rax, 0x58(%rbx)
subl %ebp, 0x38(%rbx)
jmp 0x2def
xorl %ebx, %ebx
jmp 0x2df1
cmpb $0x40, (%rax)
je 0x2864
leaq 0x40cd(%rip), %rdi      # 0x6919
jmp 0x285a
cmpb $0x3e, (%rax)
je 0x2864
leaq 0x4099(%rip), %rdi      # 0x68f3
movl 0x3c(%rbx), %esi
xorl %eax, %eax
callq 0x5198
movq 0x58(%rbx), %r15
incq %r15
movq %r15, 0x58(%rbx)
movl 0x38(%rbx), %ebp
decl %ebp
movl %ebp, 0x38(%rbx)
jne 0x28ad
cmpl $0x0, 0x40(%rbx)
je 0x2889
movq %rbx, %rdi
callq 0x2dfe
jmp 0x289e
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %r15
jne 0x289e
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %ebp
testl %ebp, %ebp
je 0x2d66
movq 0x58(%rbx), %r15
movl 0x50(%rbx), %eax
movl %r15d, %ecx
subl %eax, %ecx
movl %ecx, 0x1c(%rbx)
callq 0x1240
movq %rax, %r14
movq (%r14), %rax
movsbq (%r15), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x2912
incq %r15
movq %r15, 0x58(%rbx)
decl %ebp
movl %ebp, 0x38(%rbx)
jne 0x28c0
cmpl $0x0, 0x40(%rbx)
je 0x28ec
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2901
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %r15
jne 0x2901
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %ebp
testl %ebp, %ebp
je 0x2d66
movq 0x58(%rbx), %r15
jmp 0x28c0
movl 0x50(%rbx), %eax
addl 0x1c(%rbx), %eax
movl %r15d, %ecx
subl %eax, %ecx
movl %ecx, 0x10(%rbx)
cmpb $0xa, (%r15)
jne 0x2931
andl $0x0, 0x20(%rbx)
xorl %eax, %eax
jmp 0x29de
movb $0x0, (%r15)
movq 0x58(%rbx), %r15
incq %r15
movq %r15, 0x58(%rbx)
movl 0x38(%rbx), %eax
decl %eax
movl %eax, 0x38(%rbx)
jne 0x297e
cmpl $0x0, 0x40(%rbx)
je 0x295a
movq %rbx, %rdi
callq 0x2dfe
jmp 0x296f
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %r15
jne 0x296f
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %eax
testl %eax, %eax
je 0x2d66
movq 0x58(%rbx), %r15
movl 0x50(%rbx), %ecx
movl %r15d, %edx
subl %ecx, %edx
movl %edx, 0x20(%rbx)
cmpb $0xa, (%r15)
je 0x29d3
incq %r15
movq %r15, 0x58(%rbx)
decl %eax
movl %eax, 0x38(%rbx)
jne 0x2989
cmpl $0x0, 0x40(%rbx)
je 0x29ad
movq %rbx, %rdi
callq 0x2dfe
jmp 0x29c2
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %r15
jne 0x29c2
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %eax
testl %eax, %eax
je 0x2d66
movq 0x58(%rbx), %r15
jmp 0x2989
movl 0x50(%rbx), %ecx
addl 0x20(%rbx), %ecx
movl %r15d, %eax
subl %ecx, %eax
movl %eax, 0x14(%rbx)
movb $0x0, (%r15)
movq 0x58(%rbx), %rcx
incq %rcx
movq %rcx, 0x58(%rbx)
movq 0x38(%rbx), %xmm0
paddd 0x3e63(%rip), %xmm0     # 0x6860
movq %xmm0, 0x38(%rbx)
movd %xmm0, %eax
testl %eax, %eax
jne 0x2a3e
cmpl $0x0, 0x40(%rbx)
je 0x2a1a
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2a2f
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %rcx
jne 0x2a2f
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %eax
testl %eax, %eax
je 0x2d66
movq 0x58(%rbx), %rcx
movl 0x50(%rbx), %edx
movl %ecx, %esi
subl %edx, %esi
movl %esi, 0x24(%rbx)
movl (%rbx), %edx
testl %edx, %edx
je 0x2b3b
cmpl $0x1, %edx
jne 0x2deb
cmpb $0xa, (%rcx)
je 0x2b4e
incq %rcx
movq %rcx, 0x58(%rbx)
decl %eax
movl %eax, 0x38(%rbx)
jne 0x2a5b
cmpl $0x0, 0x40(%rbx)
je 0x2a82
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2a97
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %rcx
jne 0x2a97
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %eax
testl %eax, %eax
je 0x2d66
movq 0x58(%rbx), %rcx
jmp 0x2a5b
movq 0x58(%rbx), %rcx
movb (%rcx), %dl
cmpb $0x3e, %dl
je 0x2b43
cmpb $0xa, %dl
je 0x2b02
incq %rcx
movq %rcx, 0x58(%rbx)
decl %eax
movl %eax, 0x38(%rbx)
jne 0x2afe
cmpl $0x0, 0x40(%rbx)
je 0x2ada
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2aef
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %rcx
jne 0x2aef
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %eax
testl %eax, %eax
je 0x2d66
movq 0x58(%rbx), %rcx
movb (%rcx), %dl
jmp 0x2ab7
incl 0x3c(%rbx)
incq %rcx
movq %rcx, 0x58(%rbx)
decl %eax
movl %eax, 0x38(%rbx)
jne 0x2b38
cmpl $0x0, 0x40(%rbx)
je 0x2b23
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2b38
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %rcx
jne 0x2b38
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %eax
testl %eax, %eax
jne 0x2aa8
cmpl $0x2, (%rbx)
jne 0x2b7c
movq 0x70(%rbx), %rcx
jmp 0x2b84
movl (%rbx), %edx
cmpl $0x2, %edx
jne 0x2b5b
movq 0x70(%rbx), %rsi
jmp 0x2b63
movslq 0x24(%rbx), %rsi
addq 0x50(%rbx), %rsi
movl %ecx, %edi
subl %esi, %edi
movl %edi, 0x18(%rbx)
cmpq $0x0, 0x60(%rbx)
je 0x2bed
cmpl $0x2, %edx
jne 0x2bc7
movq 0x70(%rbx), %rax
jmp 0x2be5
movslq 0x24(%rbx), %rcx
addq 0x50(%rbx), %rcx
movq %rcx, %rax
cmpq 0x58(%rbx), %rcx
jae 0x2baa
movq 0x60(%rbx), %rdx
movsbq (%rcx), %rsi
incq %rcx
movb (%rdx,%rsi,4), %dl
movb %dl, (%rax)
xorl %esi, %esi
testb %dl, %dl
setns %sil
addq %rsi, %rax
jmp 0x2b87
cmpl $0x2, (%rbx)
jne 0x2bb5
movq 0x70(%rbx), %rcx
jmp 0x2bbd
movslq 0x24(%rbx), %rcx
addq 0x50(%rbx), %rcx
subl %ecx, %eax
movl %eax, 0x18(%rbx)
jmp 0x2deb
movslq 0x24(%rbx), %rax
addq 0x50(%rbx), %rax
jmp 0x2be5
movq 0x60(%rbx), %rcx
movsbq (%rax), %rdx
movb (%rcx,%rdx,4), %cl
movb %cl, (%rax)
incq %rax
movq 0x58(%rbx), %rcx
cmpq %rcx, %rax
jb 0x2bd1
movl 0x38(%rbx), %eax
incl 0x3c(%rbx)
incq %rcx
movq %rcx, 0x58(%rbx)
decl %eax
movl %eax, 0x38(%rbx)
jne 0x2c31
cmpl $0x0, 0x40(%rbx)
je 0x2c0e
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2c23
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, %rcx
jne 0x2c23
movq %rbx, %rdi
callq 0x2e56
cmpl $0x0, 0x38(%rbx)
je 0x2d66
movq 0x58(%rbx), %rcx
cmpb $0x2b, (%rcx)
je 0x2c47
movl 0x3c(%rbx), %esi
leaq 0x3cff(%rip), %rdi      # 0x693f
xorl %eax, %eax
callq 0x5198
movq 0x58(%rbx), %rax
cmpb $0xa, (%rax)
je 0x2c8c
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2c47
cmpl $0x0, 0x40(%rbx)
je 0x2c6c
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2c81
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2c81
movq %rbx, %rdi
callq 0x2e56
cmpl $0x0, 0x38(%rbx)
jne 0x2c47
jmp 0x2d66
incq %rax
movq %rax, 0x58(%rbx)
movq 0x38(%rbx), %xmm0
paddd 0x3bc0(%rip), %xmm0     # 0x6860
movq %xmm0, 0x38(%rbx)
movd %xmm0, %ecx
testl %ecx, %ecx
jne 0x2ce1
cmpl $0x0, 0x40(%rbx)
je 0x2cbd
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2cd2
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2cd2
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %ecx
testl %ecx, %ecx
je 0x2d66
movq 0x58(%rbx), %rax
movl 0x50(%rbx), %edx
movl %eax, %esi
subl %edx, %esi
movl %esi, 0x28(%rbx)
cmpb $0xa, (%rax)
je 0x2d30
incq %rax
movq %rax, 0x58(%rbx)
decl %ecx
movl %ecx, 0x38(%rbx)
jne 0x2ceb
cmpl $0x0, 0x40(%rbx)
je 0x2d0e
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2d23
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2d23
movq %rbx, %rdi
callq 0x2e56
movl 0x38(%rbx), %ecx
testl %ecx, %ecx
je 0x2d66
movq 0x58(%rbx), %rax
jmp 0x2ceb
movslq 0x28(%rbx), %rcx
addq 0x50(%rbx), %rcx
subq %rcx, %rax
movslq 0x18(%rbx), %rcx
cmpq %rcx, %rax
je 0x2d55
movl 0x3c(%rbx), %esi
leaq 0x3c09(%rip), %rdi      # 0x6957
xorl %eax, %eax
callq 0x5198
cmpb $0x0, 0x2c(%rbx)
je 0x2da1
cmpl $0x2, (%rbx)
jne 0x2d85
movq 0x78(%rbx), %rax
jmp 0x2d8d
movq 0x728b(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl 0x3c(%rbx), %edx
leaq 0x3b55(%rip), %rsi      # 0x68cf
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1120
jmp 0x2df1
movslq 0x28(%rbx), %rax
addq 0x50(%rbx), %rax
movslq 0x18(%rbx), %rcx
addq %rax, %rcx
cmpq %rcx, %rax
jae 0x2da1
addb $-0x21, (%rax)
incq %rax
jmp 0x2d94
movq 0x58(%rbx), %rax
incq %rax
movq %rax, 0x58(%rbx)
movq 0x38(%rbx), %xmm0
paddd 0x3aa7(%rip), %xmm0     # 0x6860
movq %xmm0, 0x38(%rbx)
movd %xmm0, %ecx
testl %ecx, %ecx
jne 0x2deb
cmpl $0x0, 0x40(%rbx)
je 0x2dd6
movq %rbx, %rdi
callq 0x2dfe
jmp 0x2deb
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2deb
movq %rbx, %rdi
callq 0x2e56
incq 0x8(%rbx)
movb $0x1, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq