// File: /workspace/github_c_makefile_star2_O1/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:
movl 0x38(%rdi), %eax
testl %eax, %eax
je 0x2ac0
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x58(%rdi), %rdx
movl 0x50(%rdi), %esi
movl %edx, %ecx
subl %esi, %ecx
movl %ecx, 0x40(%rdi)
movl (%rdi), %esi
testl %esi, %esi
je 0x2ad1
cmpl $0x1, %esi
je 0x2ac3
cmpl $0x2, %esi
jne 0x2ae7
cmpl $0xb, %eax
ja 0x291a
testl %ecx, %ecx
je 0x291a
movq %rbx, %rdi
callq 0x3074
cmpl $0xb, 0x38(%rbx)
ja 0x2936
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, 0x58(%rbx)
jne 0x2936
movq %rbx, %rdi
callq 0x30c6
movl 0x38(%rbx), %eax
cmpl $0xb, %eax
jbe 0x3047
movq 0x58(%rbx), %rdx
movl (%rdx), %esi
movl %esi, 0x10(%rbx)
leaq 0x4(%rdx), %rcx
movq %rcx, 0x58(%rbx)
movl 0x4(%rdx), %edi
movl %edi, 0x14(%rbx)
leaq 0x8(%rdx), %rcx
movq %rcx, 0x58(%rbx)
movl 0x8(%rdx), %ecx
movl %ecx, 0x18(%rbx)
addq $0xc, %rdx
movq %rdx, 0x58(%rbx)
addl $-0xc, %eax
movl %eax, 0x38(%rbx)
leal 0x3(%rcx), %edx
leal 0x6(%rcx), %r8d
testl %edx, %edx
cmovnsl %edx, %r8d
sarl $0x2, %r8d
addl %edi, %esi
leal (%r8,%rsi), %edx
addl $0x2, %edx
movsbl 0x2c(%rbx), %esi
xorl %ebp, %ebp
addl %edx, %esi
je 0x29b7
leal 0x7(%rcx), %edx
addl $0xe, %ecx
testl %edx, %edx
cmovnsl %edx, %ecx
sarl $0x3, %ecx
leal 0x3(%rcx), %edx
addl $0x6, %ecx
testl %edx, %edx
cmovnsl %edx, %ecx
andl $-0x4, %ecx
movl %ecx, %ebp
cmpl %ebp, %eax
jge 0x29c9
cmpl $0x0, 0x40(%rbx)
je 0x29c9
movq %rbx, %rdi
callq 0x3074
cmpl %ebp, 0x38(%rbx)
jge 0x29e4
movslq 0x34(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq %rax, 0x58(%rbx)
jne 0x29e4
movq %rbx, %rdi
callq 0x30c6
cmpl %ebp, 0x38(%rbx)
jl 0x3051
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 0x2a59
testl %eax, %eax
je 0x2a26
movq 0x70(%rbx), %rdi
callq 0x1040
cmpb $0x0, 0x2c(%rbx)
je 0x2a26
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 0x2a2e
movl %ecx, 0x68(%rbx)
movslq %ecx, %rdi
callq 0x57a0
movq %rax, 0x70(%rbx)
cmpb $0x0, 0x2c(%rbx)
je 0x2a59
movslq 0x68(%rbx), %rdi
callq 0x57a0
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 0x3121
cmpb $0x0, 0x2c(%rbx)
je 0x2aad
movslq 0x24(%rbx), %rax
movl 0x18(%rbx), %edx
leal 0x3(%rdx), %ecx
leal 0x6(%rdx), %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
movl 0x30(%rbx), %ecx
sarl $0x2, %esi
movslq %esi, %rdi
addq %rax, %rdi
movl %edi, 0x28(%rbx)
addq 0x50(%rbx), %rdi
movq 0x78(%rbx), %rsi
callq 0x316b
incq 0x8(%rbx)
movslq %ebp, %rax
addq %rax, 0x58(%rbx)
subl %ebp, 0x38(%rbx)
jmp 0x3039
xorl %eax, %eax
retq
cmpb $0x40, (%rdx)
je 0x2ae7
leaq 0x3e54(%rip), %rdi      # 0x6923
jmp 0x2add
cmpb $0x3e, (%rdx)
je 0x2ae7
leaq 0x3e20(%rip), %rdi      # 0x68fd
movl 0x3c(%rbx), %esi
xorl %eax, %eax
callq 0x56d8
movq 0x58(%rbx), %rax
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2b1c
cmpl $0x0, 0x40(%rbx)
je 0x2b07
movq %rbx, %rdi
callq 0x3074
jmp 0x2b1c
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2b1c
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
je 0x2e74
movl 0x58(%rbx), %eax
subl 0x50(%rbx), %eax
movl %eax, 0x1c(%rbx)
callq 0x1240
movq %rax, %r14
movq (%r14), %rcx
movq 0x58(%rbx), %rax
movsbq (%rax), %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x2b8d
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2b7a
cmpl $0x0, 0x40(%rbx)
je 0x2b65
movq %rbx, %rdi
callq 0x3074
jmp 0x2b7a
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2b7a
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
jne 0x2b37
movq %rbx, %rdi
callq 0x210e
jmp 0x306d
movl 0x50(%rbx), %ecx
addl 0x1c(%rbx), %ecx
movl %eax, %edx
subl %ecx, %edx
movl %edx, 0x10(%rbx)
cmpb $0xa, (%rax)
jne 0x2bad
movl $0x0, 0x20(%rbx)
xorl %eax, %eax
jmp 0x2c4d
movb $0x0, (%rax)
movq 0x58(%rbx), %rax
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2be5
cmpl $0x0, 0x40(%rbx)
je 0x2bd0
movq %rbx, %rdi
callq 0x3074
jmp 0x2be5
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2be5
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
je 0x303d
movl 0x58(%rbx), %eax
subl 0x50(%rbx), %eax
movl %eax, 0x20(%rbx)
movq 0x58(%rbx), %rax
cmpb $0xa, (%rax)
je 0x2c45
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2c32
cmpl $0x0, 0x40(%rbx)
je 0x2c1d
movq %rbx, %rdi
callq 0x3074
jmp 0x2c32
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2c32
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
jne 0x2bf8
movq %rbx, %rdi
callq 0x2007
jmp 0x306d
movl 0x50(%rbx), %ecx
addl 0x20(%rbx), %ecx
subl %ecx, %eax
movl %eax, 0x14(%rbx)
movq 0x58(%rbx), %rax
movb $0x0, (%rax)
incl 0x3c(%rbx)
movq 0x58(%rbx), %rax
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2c8f
cmpl $0x0, 0x40(%rbx)
je 0x2c7a
movq %rbx, %rdi
callq 0x3074
jmp 0x2c8f
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2c8f
movq %rbx, %rdi
callq 0x30c6
leaq 0x3c(%rbx), %r14
cmpl $0x0, 0x38(%rbx)
je 0x2e81
movl (%rbx), %eax
movl 0x58(%rbx), %ecx
subl 0x50(%rbx), %ecx
movl %ecx, 0x24(%rbx)
testl %eax, %eax
je 0x2d90
cmpl $0x1, %eax
jne 0x3035
movq 0x58(%rbx), %rax
cmpb $0xa, (%rax)
je 0x2da5
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2cf7
cmpl $0x0, 0x40(%rbx)
je 0x2ce2
movq %rbx, %rdi
callq 0x3074
jmp 0x2cf7
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2cf7
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
jne 0x2cb9
movq %r14, %rdi
callq 0x2043
jmp 0x306d
movq 0x58(%rbx), %rax
cmpb $0x3e, (%rax)
je 0x2d9a
movq 0x58(%rbx), %rax
cmpb $0xa, (%rax)
je 0x2d5c
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2d51
cmpl $0x0, 0x40(%rbx)
je 0x2d3c
movq %rbx, %rdi
callq 0x3074
jmp 0x2d51
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2d51
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
jne 0x2d17
jmp 0x2e24
incl 0x3c(%rbx)
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2d90
cmpl $0x0, 0x40(%rbx)
je 0x2d7b
movq %rbx, %rdi
callq 0x3074
jmp 0x2d90
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2d90
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
jne 0x2d0a
cmpl $0x2, (%rbx)
jne 0x2dd5
movq 0x70(%rbx), %rax
jmp 0x2ddd
movl (%rbx), %ecx
cmpl $0x2, %ecx
jne 0x2db2
movq 0x70(%rbx), %rdx
jmp 0x2dba
movslq 0x24(%rbx), %rdx
addq 0x50(%rbx), %rdx
subl %edx, %eax
movl %eax, 0x18(%rbx)
cmpq $0x0, 0x60(%rbx)
je 0x2e51
cmpl $0x2, %ecx
jne 0x2e31
movq 0x70(%rbx), %rax
jmp 0x2e4b
movslq 0x24(%rbx), %rax
addq 0x50(%rbx), %rax
cmpq 0x58(%rbx), %rax
jae 0x2e07
movq %rax, %rcx
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
cmpq 0x58(%rbx), %rcx
jb 0x2de6
cmpl $0x2, (%rbx)
jne 0x2e12
movq 0x70(%rbx), %rcx
jmp 0x2e1a
movslq 0x24(%rbx), %rcx
addq 0x50(%rbx), %rcx
subl %ecx, %eax
movl %eax, 0x18(%rbx)
jmp 0x3035
movq %r14, %rdi
callq 0x20d4
jmp 0x306d
movslq 0x24(%rbx), %rax
addq 0x50(%rbx), %rax
jmp 0x2e4b
movq 0x60(%rbx), %rcx
movsbq (%rax), %rdx
movb (%rcx,%rdx,4), %cl
movb %cl, (%rax)
incq %rax
cmpq 0x58(%rbx), %rax
jb 0x2e3b
incl 0x3c(%rbx)
movq 0x58(%rbx), %rax
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2ea3
cmpl $0x0, 0x40(%rbx)
je 0x2e8e
movq %rbx, %rdi
callq 0x3074
jmp 0x2ea3
movq %rbx, %rdi
callq 0x212c
jmp 0x306d
movq %r14, %rdi
callq 0x20f1
jmp 0x306d
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2ea3
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
je 0x305b
movq 0x58(%rbx), %rax
cmpb $0x2b, (%rax)
je 0x2ec7
movl (%r14), %esi
leaq 0x3a89(%rip), %rdi      # 0x6949
xorl %eax, %eax
callq 0x56d8
movq 0x58(%rbx), %rax
cmpb $0xa, (%rax)
je 0x2f14
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2f01
cmpl $0x0, 0x40(%rbx)
je 0x2eec
movq %rbx, %rdi
callq 0x3074
jmp 0x2f01
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2f01
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
jne 0x2ec7
movq %r14, %rdi
callq 0x2060
jmp 0x306d
incl 0x3c(%rbx)
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2f48
cmpl $0x0, 0x40(%rbx)
je 0x2f33
movq %rbx, %rdi
callq 0x3074
jmp 0x2f48
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2f48
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
je 0x3065
movl 0x58(%rbx), %eax
subl 0x50(%rbx), %eax
movl %eax, 0x28(%rbx)
movq 0x58(%rbx), %rax
cmpb $0xa, (%rax)
je 0x2fa8
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x2f95
cmpl $0x0, 0x40(%rbx)
je 0x2f80
movq %rbx, %rdi
callq 0x3074
jmp 0x2f95
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x2f95
movq %rbx, %rdi
callq 0x30c6
cmpl $0x0, 0x38(%rbx)
jne 0x2f5b
movq %r14, %rdi
callq 0x207d
jmp 0x306d
movslq 0x28(%rbx), %rcx
addq 0x50(%rbx), %rcx
subq %rcx, %rax
movslq 0x18(%rbx), %rcx
cmpq %rcx, %rax
je 0x2fcd
movl (%r14), %esi
leaq 0x399b(%rip), %rdi      # 0x6961
xorl %eax, %eax
callq 0x56d8
cmpb $0x0, 0x2c(%rbx)
je 0x2ffd
cmpl $0x2, (%rbx)
jne 0x2fde
movq 0x78(%rbx), %rax
jmp 0x2fe6
movslq 0x28(%rbx), %rax
addq 0x50(%rbx), %rax
movslq 0x18(%rbx), %rcx
testq %rcx, %rcx
jle 0x2ffd
addq %rax, %rcx
addb $-0x21, (%rax)
incq %rax
cmpq %rcx, %rax
jb 0x2ff2
incl 0x3c(%rbx)
movq 0x58(%rbx), %rax
incq %rax
movq %rax, 0x58(%rbx)
decl 0x38(%rbx)
jne 0x3035
cmpl $0x0, 0x40(%rbx)
je 0x3020
movq %rbx, %rdi
callq 0x3074
jmp 0x3035
movslq 0x34(%rbx), %rcx
addq 0x50(%rbx), %rcx
cmpq %rcx, %rax
jne 0x3035
movq %rbx, %rdi
callq 0x30c6
incq 0x8(%rbx)
movb $0x1, %al
jmp 0x306f
movq %rbx, %rdi
callq 0x2025
jmp 0x306d
movq %rbx, %rdi
callq 0x1fe9
jmp 0x306d
movq %rbx, %rdi
callq 0x1fcb
jmp 0x306d
movq %r14, %rdi
callq 0x20b7
jmp 0x306d
movq %r14, %rdi
callq 0x209a
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq