// File: /workspace/github_c_makefile_star2_O2/richarddurbin[P]hash10x/readseq.c
// Function: readFastq
int readFastq (FILE *fil, int *conv, 
	       char **seq, char **qval, char **id, char **desc, int *length)
{
  char c, *cp ;
  int n, m ;
  static FILE *oldFil = 0 ;
  static int line ;
  int buflen ;

  if (fil != oldFil)
    { line = 1 ;
      oldFil = fil ;
    }
  
/* get id */
  c = getc (fil) ;
  if (!feof(fil) && c != '@')			/* header line */
    { fprintf (stderr, "bad @ header line %d\n", line) ; return 0 ; }
  
  c = getc(fil) ;
  n = 0 ;			/* id */
  buflen = -32;
  while (!feof (fil) && c != ' ' && c != '\n' && c != '\t')
    { if (id) add (c, id, &buflen, n++) ;
      c = getc (fil) ;
    }
  if (id) add (0, id, &buflen, n) ;

				/* white space */
  while (!feof (fil) && (c == ' ' || c == '\t'))
    c = getc (fil) ;

  n = 0 ;			/* desc */
  buflen = -32 ;
  while (!feof (fil) && c != '\n')
    { if (desc) add (c, desc, &buflen, n++) ;
      c = getc (fil) ;
    }
  if (desc) add (0, desc, &buflen, n) ;
  
  if (!feof (fil) && c != '\n')
    { fprintf (stderr, "bad @ identifier line %d\n", line) ; return 0 ; }
  ++line ;

  /* ensure whitespace ignored */

  conv[' '] = conv['\t'] = -1 ;
  conv['\n'] = -3 ;

  n = 0 ;			/* sequence */
  buflen = -1024 ;

  while (!feof (fil))
    { 
      c = getc (fil) ;
      if (c == '+')
	{ ungetc (c, fil) ;
	  break ;
	}

      if (c == EOF)  /* for some compiler once needed || c == EOF + 256 */
	break ;
    
      switch (conv[c]) {
        case -2:
          { if (id) 
              fprintf (stderr, "Bad char 0x%x = '%c' at line %d, base %d, sequence %s\n",
          	     c, c, line, n, *id) ;
            else
              fprintf (stderr, "Bad char 0x%x = '%c' at line %d, base %d\n",
          	     c, c, line, n) ;
            return 0 ;
          }
          break;
        case -3:
          ++line;
        case -1:
          break;
        default:
	  if (seq) add (conv[c], seq, &buflen, n++) ;
	  else ++n ;
      }
    }
  if (seq) add (0, seq, &buflen, n) ;

  if (length)
    *length = n ;
  
/* second block with same identifier and matching quality values */
  c = getc (fil) ;
  if (!feof(fil) && c != '+')			/* header line */
    { fprintf (stderr, "bad + header line %d\n", line) ; return 0 ; }
  
  c = getc(fil) ; if (id) cp = *id ;
  while (!feof (fil) && c != ' ' && c != '\n' && c != '\t')
    { if (id && c != *cp++) 
	{ fprintf (stderr, "mismatching + identifier line %d\n", line) ; return 0 ; }
      c = getc (fil) ;
    }

  while (!feof (fil) && c != '\n')		/* ignore rest of line - may have desc or not */
    c = getc (fil) ;

  ++line ;

  m = 0 ;			/* qualities */
  buflen = -(n+1) ;

  while (!feof (fil))
    { 
      c = getc (fil) ;
      if (c == '@' && m == n)
	{ ungetc (c, fil) ;
	  break ;
	}
      else if (m > n)
	break ;

      if (c == EOF)  /* for some compiler once needed || c == EOF + 256 */
	break ;

      if (c == '\n')
	++line;
      else if (qval) 
	add (c-33, qval, &buflen, m++) ;
      else 
	++m ;
    }
  if (qval) add (0, qval, &buflen, m) ;

  if (m != n)
    { fprintf (stderr, "mismatching seq, q length line %d\n", line) ; return 0 ; }

  return n ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbp
movq %r8, %r13
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x30(%rsp)
movq %rdi, %r14
cmpq %rdi, 0x9ea5(%rip)      # 0x10478
je 0x65e6
movl $0x1, 0x9ea1(%rip)      # 0x10480
movq %r14, 0x9e92(%rip)      # 0x10478
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6608
movzbl %bl, %eax
cmpl $0x40, %eax
jne 0x695c
movq %r12, 0x28(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
leaq 0x14(%rsp), %r15
movl $0xffffffe0, (%r15)     # imm = 0xFFFFFFE0
xorl %r12d, %r12d
movq %r13, 0x18(%rsp)
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6685
cmpb $0x20, %bl
ja 0x6654
movzbl %bl, %eax
movabsq $0x100000600, %rcx      # imm = 0x100000600
btq %rax, %rcx
jb 0x6685
testq %r13, %r13
je 0x6679
leal 0x1(%r12), %r13d
movsbl %bl, %edi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movl %r12d, %ecx
callq 0x6528
movl %r13d, %r12d
movq 0x18(%rsp), %r13
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
jmp 0x6630
testq %r13, %r13
je 0x66b5
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movq %r13, %rsi
movl %r12d, %ecx
callq 0x6528
jmp 0x66b5
cmpb $0x20, %bl
je 0x66ab
movzbl %bl, %eax
cmpl $0x9, %eax
jne 0x66c1
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
je 0x669e
leaq 0x14(%rsp), %r13
movl $0xffffffe0, (%r13)     # imm = 0xFFFFFFE0
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x1160
cmpb $0xa, %bl
je 0x670c
testl %eax, %eax
jne 0x670c
testq %rbp, %rbp
je 0x6700
leal 0x1(%r12), %r15d
movsbl %bl, %edi
movq %rbp, %rsi
movq %r13, %rdx
movl %r12d, %ecx
callq 0x6528
movl %r15d, %r12d
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
jmp 0x66d1
testq %rbp, %rbp
je 0x6723
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movq %rbp, %rsi
movl %r12d, %ecx
callq 0x6528
movq %r14, %rdi
callq 0x1160
cmpb $0xa, %bl
movq 0x18(%rsp), %r15
movq 0x30(%rsp), %r13
je 0x6742
testl %eax, %eax
je 0x6975
incl 0x9d38(%rip)            # 0x10480
movabsq $-0x200000001, %rax     # imm = 0xFFFFFFFDFFFFFFFF
movq %rax, 0x24(%r13)
orl $-0x1, 0x80(%r13)
leaq 0x14(%rsp), %rbx
movl $0xfffffc00, (%rbx)     # imm = 0xFFFFFC00
xorl %ebp, %ebp
movq 0x28(%rsp), %r12
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x67e1
movq %r14, %rdi
callq 0x1270
movl %eax, %ecx
shll $0x18, %ecx
cmpl $0xff000000, %ecx       # imm = 0xFF000000
je 0x67e1
cmpl $0x2b000000, %ecx       # imm = 0x2B000000
je 0x67d6
movsbq %al, %rax
movl (%r13,%rax,4), %eax
cmpl $-0x3, %eax
je 0x67ce
cmpl $-0x1, %eax
je 0x6770
cmpl $-0x2, %eax
je 0x69bf
testq %r12, %r12
je 0x67ca
movsbl %al, %edi
movq %r12, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
callq 0x6528
incl %ebp
jmp 0x6770
incl 0x9cac(%rip)            # 0x10480
jmp 0x6770
pushq $0x2b
popq %rdi
movq %r14, %rsi
callq 0x11b0
testq %r12, %r12
je 0x67f7
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movq %r12, %rsi
movl %ebp, %ecx
callq 0x6528
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x6803
movl %ebp, (%rax)
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6825
movzbl %bl, %eax
cmpl $0x2b, %eax
jne 0x698e
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
testq %r15, %r15
je 0x6839
movq (%r15), %r12
jmp 0x6839
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6895
movl %ebx, %eax
shll $0x18, %eax
cmpl $0x9000000, %eax        # imm = 0x9000000
je 0x6895
cmpl $0x20000000, %eax       # imm = 0x20000000
je 0x6895
cmpl $0xa000000, %eax        # imm = 0xA000000
je 0x6895
testq %r15, %r15
je 0x6877
movsbl %bl, %eax
movsbl (%r12), %ecx
cmpl %ecx, %eax
jne 0x69e1
incq %r12
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
jmp 0x6839
movzbl %bl, %eax
cmpl $0xa, %eax
je 0x68a1
movq %r14, %rdi
callq 0x1270
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
je 0x6883
incl 0x9bd9(%rip)            # 0x10480
movl %ebp, %eax
notl %eax
leaq 0x14(%rsp), %r15
movl %eax, (%r15)
xorl %ebx, %ebx
movl %ebx, %r12d
xorl %ebp, %r12d
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6927
movq %r14, %rdi
callq 0x1270
movl %eax, %ecx
shll $0x18, %ecx
movl %ecx, %edx
xorl $0x40000000, %edx       # imm = 0x40000000
orl %r12d, %edx
je 0x691a
cmpl %ebp, %ebx
jg 0x6927
cmpl $0xff000000, %ecx       # imm = 0xFF000000
je 0x6927
cmpl $0xa000000, %ecx        # imm = 0xA000000
jne 0x68fd
incl 0x9b85(%rip)            # 0x10480
jmp 0x68bb
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0x6916
addb $-0x21, %al
movsbl %al, %edi
movq %r15, %rdx
movl %ebx, %ecx
callq 0x6528
incl %ebx
jmp 0x68b5
pushq $0x40
popq %rdi
movq %r14, %rsi
callq 0x11b0
movl %ebp, %ebx
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0x693f
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movl %ebx, %ecx
callq 0x6528
cmpl %ebp, %ebx
je 0x69ae
movq 0x86a6(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movl 0x9b2d(%rip), %edx      # 0x10480
leaq 0x3ddd(%rip), %rsi      # 0xa737
jmp 0x69a5
movq 0x868d(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movl 0x9b14(%rip), %edx      # 0x10480
leaq 0x3d5c(%rip), %rsi      # 0xa6cf
jmp 0x69a5
movq 0x8674(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movl 0x9afb(%rip), %edx      # 0x10480
leaq 0x3d59(%rip), %rsi      # 0xa6e5
jmp 0x69a5
movq 0x865b(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movl 0x9ae2(%rip), %edx      # 0x10480
leaq 0x3d5a(%rip), %rsi      # 0xa6ff
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1150
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
sarl $0x18, %ecx
movq 0x8627(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movl 0x9aad(%rip), %r8d      # 0x10480
testq %r15, %r15
jne 0x69fa
leaq 0x3cc6(%rip), %rsi      # 0xa6a5
jmp 0x6a08
movq 0x8608(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movl 0x9a8f(%rip), %edx      # 0x10480
leaq 0x3d1d(%rip), %rsi      # 0xa715
jmp 0x69a5
movq (%r15), %rax
movq %rax, (%rsp)
leaq 0x3c66(%rip), %rsi      # 0xa66e
movl %ecx, %edx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x1150
xorl %ebp, %ebp
jmp 0x69ae