// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %r8, 0x18(%rsp)
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r14
cmpq %rdi, 0x9828(%rip)      # 0x10460
je 0x6c4b
movl $0x1, 0x9824(%rip)      # 0x10468
movq %r14, 0x9815(%rip)      # 0x10460
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6c6d
movzbl %bl, %eax
cmpl $0x40, %eax
jne 0x706f
movq %rbp, 0x20(%rsp)
movq %r13, 0x30(%rsp)
movq %r15, 0x28(%rsp)
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movl $0xffffffe0, 0x14(%rsp) # imm = 0xFFFFFFE0
movq %r14, %rdi
callq 0x1160
xorl %r13d, %r13d
testl %eax, %eax
je 0x6e20
movq 0x18(%rsp), %r15
testq %r15, %r15
je 0x6cd6
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movq %r15, %rsi
movl %r13d, %ecx
callq 0x6bae
jmp 0x6cd6
cmpb $0x20, %bl
je 0x6ccc
movzbl %bl, %eax
cmpl $0x9, %eax
jne 0x6ce2
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
je 0x6cbf
movl $0xffffffe0, 0x14(%rsp) # imm = 0xFFFFFFE0
movq %r14, %rdi
callq 0x1160
xorl %r13d, %r13d
cmpb $0xa, %bl
setne %r15b
je 0x6d46
testl %eax, %eax
jne 0x6d46
xorl %r13d, %r13d
leaq 0x14(%rsp), %rbp
testq %r12, %r12
je 0x6d27
leal 0x1(%r13), %r15d
movsbl %bl, %edi
movq %r12, %rsi
movq %rbp, %rdx
movl %r13d, %ecx
callq 0x6bae
movl %r15d, %r13d
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
cmpb $0xa, %bl
setne %r15b
je 0x6d46
testl %eax, %eax
je 0x6d0a
testq %r12, %r12
je 0x6d5d
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movq %r12, %rsi
movl %r13d, %ecx
callq 0x6bae
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
setne %al
xorb $0x1, %r15b
orb %al, %r15b
movq 0x20(%rsp), %rbp
je 0x7076
incl 0x96e6(%rip)            # 0x10468
movabsq $-0x200000001, %rax     # imm = 0xFFFFFFFDFFFFFFFF
movq %rax, 0x24(%rbp)
movl $0xffffffff, 0x80(%rbp) # imm = 0xFFFFFFFF
movl $0xfffffc00, 0x14(%rsp) # imm = 0xFFFFFC00
movq %r14, %rdi
callq 0x1160
xorl %r12d, %r12d
testl %eax, %eax
movq 0x18(%rsp), %r15
movq 0x30(%rsp), %r13
je 0x6e85
movq 0x70(%rsp), %rbx
testq %r13, %r13
je 0x6ddb
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movq %r13, %rsi
movl %r12d, %ecx
callq 0x6bae
testq %rbx, %rbx
je 0x6de3
movl %r12d, (%rbx)
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6e05
movzbl %bl, %eax
cmpl $0x2b, %eax
jne 0x707d
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
testq %r15, %r15
je 0x6f0e
movq (%r15), %r13
jmp 0x6f4c
xorl %r13d, %r13d
movabsq $0x100000600, %rbp      # imm = 0x100000600
movq 0x18(%rsp), %r15
cmpb $0x20, %bl
ja 0x6e44
movzbl %bl, %eax
btq %rax, %rbp
jb 0x6ca6
testq %r15, %r15
je 0x6e6a
leal 0x1(%r13), %r15d
movsbl %bl, %edi
movq 0x18(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movl %r13d, %ecx
callq 0x6bae
movl %r15d, %r13d
movq 0x18(%rsp), %r15
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
je 0x6e32
jmp 0x6ca6
xorl %r12d, %r12d
leaq 0x14(%rsp), %rbx
movq %r14, %rdi
callq 0x1260
movl %eax, %ecx
shll $0x18, %ecx
cmpl $0xff000000, %ecx       # imm = 0xFF000000
je 0x6dbf
cmpl $0x2b000000, %ecx       # imm = 0x2B000000
je 0x704b
movsbq %al, %rax
movl (%rbp,%rax,4), %eax
cmpl $-0x3, %eax
je 0x6ef2
cmpl $-0x1, %eax
je 0x6efd
cmpl $-0x2, %eax
je 0x709e
testq %r13, %r13
je 0x6efa
leal 0x1(%r12), %ebp
movsbl %al, %edi
movq %r13, %rsi
movq %rbx, %rdx
movl %r12d, %ecx
callq 0x6bae
movl %ebp, %r12d
movq 0x20(%rsp), %rbp
jmp 0x6efd
incl 0x9570(%rip)            # 0x10468
jmp 0x6efd
incl %r12d
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
je 0x6e8d
jmp 0x6dbf
jmp 0x6f4c
movl %ebx, %eax
shll $0x18, %eax
cmpl $0x9000000, %eax        # imm = 0x9000000
je 0x6f58
cmpl $0x20000000, %eax       # imm = 0x20000000
je 0x6f58
cmpl $0xa000000, %eax        # imm = 0xA000000
je 0x6f58
testq %r15, %r15
je 0x6f42
movsbl %bl, %eax
movsbl (%r13), %ecx
cmpl %ecx, %eax
jne 0x7097
incq %r13
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
je 0x6f10
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
setne %al
cmpb $0xa, %bl
sete %cl
orb %al, %cl
jne 0x6f8d
movq %r14, %rdi
callq 0x1260
movl %eax, %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6f8d
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0x6f6f
incl 0x94d5(%rip)            # 0x10468
movl %r12d, %eax
notl %eax
movl %eax, 0x14(%rsp)
movq %r14, %rdi
callq 0x1160
xorl %ebx, %ebx
testl %eax, %eax
movq 0x28(%rsp), %r13
je 0x6fd8
testq %r13, %r13
je 0x6fc5
leaq 0x14(%rsp), %rdx
xorl %edi, %edi
movq %r13, %rsi
movl %ebx, %ecx
callq 0x6bae
cmpl %r12d, %ebx
je 0x7085
callq 0x1a22
jmp 0x7082
xorl %ebx, %ebx
leaq 0x14(%rsp), %r15
movq %r14, %rdi
callq 0x1260
movl %eax, %ecx
shll $0x18, %ecx
movl %ecx, %edx
xorl $0x40000000, %edx       # imm = 0x40000000
movl %ebx, %esi
xorl %r12d, %esi
orl %edx, %esi
je 0x705d
cmpl %r12d, %ebx
jg 0x6faf
cmpl $0xff000000, %ecx       # imm = 0xFF000000
je 0x6faf
cmpl $0xa000000, %ecx        # imm = 0xA000000
jne 0x701a
incl 0x9450(%rip)            # 0x10468
jmp 0x703a
testq %r13, %r13
je 0x7038
addb $-0x21, %al
leal 0x1(%rbx), %ebp
movsbl %al, %edi
movq %r13, %rsi
movq %r15, %rdx
movl %ebx, %ecx
callq 0x6bae
movl %ebp, %ebx
jmp 0x703a
incl %ebx
movq %r14, %rdi
callq 0x1160
testl %eax, %eax
je 0x6fdf
jmp 0x6faf
movl $0x2b, %edi
movq %r14, %rsi
callq 0x11b0
jmp 0x6dbf
movl $0x40, %edi
movq %r14, %rsi
callq 0x11b0
jmp 0x6faf
callq 0x1a7c
jmp 0x7082
callq 0x1a5e
jmp 0x7082
callq 0x1a40
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1a04
jmp 0x7082
sarl $0x18, %ecx
movq 0x7f48(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movl 0x93b6(%rip), %r8d      # 0x10468
testq %r15, %r15
jne 0x70c0
leaq 0x4601(%rip), %rsi      # 0xb6bf
jmp 0x70ce
movq (%r15), %rax
movq %rax, (%rsp)
leaq 0x45ba(%rip), %rsi      # 0xb688
movl %ecx, %edx
movl %r12d, %r9d
xorl %eax, %eax
callq 0x1150
jmp 0x7082