// File: /workspace/github_c_makefile_star2_O2/gmcvicker[P]check_fastq/check_fastq.c
// Function: main
int main(int argc, char **argv) {
  ReadSeq read;
  gzFile gzf, out_gzf;
  long rec_num, line_num, n_err;
  char min_qual, max_qual;

  if(argc == 3) {
    if(util_file_exists(argv[2])) {
      fprintf(stderr, "output file '%s' already exists\n", argv[2]);
      fprintf(stderr, "usage: %s <fastq_file.txt.gz> "
	      "[<repaired_output_file.txt.gz>]\n", argv[0]);
      exit(2);
    }
	
    out_gzf = util_must_gzopen(argv[2], "wb");
    fprintf(stderr, "writing repaired fastq to '%s'\n", argv[2]);
  } else {
    if(argc != 2) {
      fprintf(stderr, "usage: %s <fastq_file.txt.gz> "
	      "[<repaired_output_file.txt.gz>]\n", argv[0]);
      exit(2);
    }
    out_gzf = NULL;
  }

  gzf = util_must_gzopen(argv[1], "rb");

  rec_num = 0;
  line_num = 1;
  n_err = 0;
  min_qual = max_qual = -1;

  while(TRUE) {
    long r = 0;

    r = parse_fastq_read(&read, gzf);

    if(r == FASTQ_END) {
      /* we have reached the end of the file */
      break;
    }

    if(r == FASTQ_ERR) {
      if(warn_count < MAX_WARN) {
	warn_count += 1;
	my_warn("%s:%d: invalid fastq record starting on line %ld:\n", 
		__FILE__, __LINE__, line_num);
	fprintf(stderr, "  %s\n  %s\n  %s\n  %s\n", read.line1, 
		read.line2, read.line3, read.line4);
      }
      n_err += 1;
    }

    if(r == FASTQ_OK) {
      /* record max and min quality values observed */
      if((min_qual == -1) || (min_qual > read.min_qual)) {
	min_qual = read.min_qual;
      }
      if((max_qual == -1) || (max_qual < read.max_qual)) {
	max_qual = read.max_qual;
      }      

      if(out_gzf) {
	int n_written;
	/* write record to file */
	n_written = gzprintf(out_gzf, "%s\n%s\n%s\n%s\n", read.line1,
			     read.line2, read.line3, read.line4);
	if(n_written == 0) {
	  my_err("%s:%d: failed to write to output file", __FILE__, __LINE__);
	}
      }
    }
	
    rec_num += 1;
    line_num += 4;

    if((rec_num % 1000000) == 0) {
      fprintf(stderr, ".");
    }
  }

  report_qual_type(min_qual, max_qual);

  fprintf(stderr, "\n");
  fprintf(stderr, "fastq records: %ld, errors: %ld\n", rec_num, n_err);

  gzclose(gzf);
  if(out_gzf) {
    gzclose(out_gzf);
  }

  if((n_err > 0) && !out_gzf) {
    /* return error if there were errors found and we are not writing 
     * a repaired version of the file 
     */
    exit(2);
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1458, %rsp           # imm = 0x1458
movq %rsi, %rbx
cmpl $0x2, %edi
je 0x1424
cmpl $0x3, %edi
jne 0x1c84
movq 0x10(%rbx), %rdi
callq 0x2290
testl %eax, %eax
jne 0x1c90
movq 0x10(%rbx), %rdi
leaq 0x1c67(%rip), %rsi      # 0x3064
callq 0x2b2c
movq %rax, -0x40(%rbp)
movq 0x4beb(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
movq 0x10(%rbx), %rdx
leaq 0x1c4c(%rip), %rsi      # 0x3067
xorl %eax, %eax
callq 0x1180
jmp 0x142c
movq $0x0, -0x40(%rbp)
movq 0x8(%rbx), %rdi
leaq 0x1c50(%rip), %rsi      # 0x3087
callq 0x2b2c
movq %rax, %r14
leaq -0x1056(%rbp), %r13
movb $-0x1, %al
movl %eax, -0x30(%rbp)
pushq $0x1
popq %r15
leaq -0x1474(%rbp), %rbx
xorl %r12d, %r12d
movq $0x0, -0x48(%rbp)
movb $-0x1, %al
movl %eax, -0x2c(%rbp)
andl $0x0, -0x54(%rbp)
movq %r14, %rdi
movq %r13, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x1b01
cmpb $0x40, -0x1056(%rbp)
movq %r12, -0x38(%rbp)
jne 0x155b
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1cc8
movq %r13, %rdi
callq 0x28fc
movq %r14, %rdi
leaq -0xc56(%rbp), %r12
movq %r12, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x15ca
movq %r15, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x1cc8
movq %r12, %rdi
callq 0x28fc
movq %r14, %rdi
leaq -0x856(%rbp), %r15
movq %r15, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x1740
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1cc8
movq %r15, %rdi
callq 0x28fc
movq %r14, %rdi
leaq -0x456(%rbp), %r15
movq %r15, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
movq -0x38(%rbp), %r12
je 0x17ba
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1cc8
movq %r15, %rdi
callq 0x28fc
movq %r13, %r15
jmp 0x1680
movl 0x4c13(%rip), %eax      # 0x6174
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x158a
incl %eax
movl %eax, 0x4c04(%rip)      # 0x6174
leaq 0x1c3e(%rip), %rdi      # 0x31b5
leaq 0x1b3f(%rip), %rsi      # 0x30bd
movl $0x94, %edx
xorl %eax, %eax
callq 0x2e85
movq %r15, -0x50(%rbp)
movl $0x1, -0x54(%rbp)
xorl %eax, %eax
movb %al, -0xc56(%rbp)
movb %al, -0x856(%rbp)
movb %al, -0x456(%rbp)
movl (%r14), %eax
testl %eax, %eax
je 0x1604
decl %eax
movl %eax, (%r14)
incq 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movb (%rax), %r15b
jmp 0x160f
leaq 0x1c15(%rip), %rdi      # 0x31e6
leaq 0x1ae5(%rip), %rsi      # 0x30bd
movl $0xa6, %edx
xorl %eax, %eax
callq 0x2e85
movl $0x1, -0x54(%rbp)
xorl %eax, %eax
movb %al, -0xc56(%rbp)
movb %al, -0x856(%rbp)
movb %al, -0x456(%rbp)
jmp 0x1779
movq %r14, %rdi
callq 0x10f0
movl %eax, %r15d
movb $0xa, %cl
xorl %r13d, %r13d
cmpb $-0x1, %r15b
je 0x1ab2
xorb $0xa, %cl
movl %r15d, %eax
xorb $0x40, %al
orb %cl, %al
je 0x165d
movl (%r14), %eax
testl %eax, %eax
je 0x164a
decl %eax
movl %eax, (%r14)
incq 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movb (%rax), %al
jmp 0x1652
movq %r14, %rdi
callq 0x10f0
incq %r13
movl %r15d, %ecx
movl %eax, %r15d
jmp 0x1614
pushq $0x40
popq %rdi
movq %r14, %rsi
callq 0x1100
cmpl $0x3e7, 0x4b02(%rip)    # imm = 0x3E7
movq -0x38(%rbp), %r12
movq -0x50(%rbp), %r15
jle 0x1ada
movl -0x54(%rbp), %eax
testl %eax, %eax
leaq -0xc56(%rbp), %rdi
leaq -0x856(%rbp), %r8
leaq -0x1474(%rbp), %rbx
leaq -0x1056(%rbp), %r13
je 0x16c2
testl %eax, %eax
je 0x1836
cmpl $0x1, %eax
je 0x1a13
cmpl $-0x1, %eax
jne 0x1a24
jmp 0x1b1f
cmpb $0x2b, -0x856(%rbp)
jne 0x1782
callq 0x1120
movq %rax, %r13
movl %r13d, -0x105c(%rbp)
leaq -0x456(%rbp), %rdi
callq 0x1120
testl %r13d, %r13d
jle 0x17ea
movl %r13d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rax, %rcx
jne 0x18be
xorl %edx, %edx
leaq -0x856(%rbp), %r8
leaq 0x1c2c(%rip), %rdi      # 0x3341
cmpq %rax, %rdx
je 0x1afa
movsbl -0xc56(%rbp,%rdx), %ecx
xorl %esi, %esi
cmpb (%rsi,%rdi), %cl
je 0x173b
incq %rsi
cmpq $0x17, %rsi
jne 0x1728
jmp 0x1907
incq %rdx
jmp 0x1715
leaq 0x1a9f(%rip), %rdi      # 0x31e6
leaq 0x196f(%rip), %rsi      # 0x30bd
movl $0xb4, %edx
xorl %eax, %eax
callq 0x2e85
movl $0x1, -0x54(%rbp)
xorl %eax, %eax
movb %al, -0x856(%rbp)
movb %al, -0x456(%rbp)
movq %r13, %r15
leaq -0x1056(%rbp), %r13
movq -0x38(%rbp), %r12
jmp 0x1a13
movl 0x49ec(%rip), %eax      # 0x6174
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1a0c
incl %eax
movl %eax, 0x49d9(%rip)      # 0x6174
leaq 0x1992(%rip), %rdi      # 0x3134
leaq 0x1914(%rip), %rsi      # 0x30bd
movl $0x156, %edx            # imm = 0x156
xorl %eax, %eax
callq 0x2e85
jmp 0x1a0c
leaq 0x1a25(%rip), %rdi      # 0x31e6
leaq 0x18f5(%rip), %rsi      # 0x30bd
movl $0xc0, %edx
xorl %eax, %eax
callq 0x2e85
movl $0x1, -0x54(%rbp)
movb $0x0, -0x456(%rbp)
movq %r13, %r15
jmp 0x18fb
movl 0x4984(%rip), %eax      # 0x6174
cmpl $0x3e7, %eax            # imm = 0x3E7
leaq -0x856(%rbp), %r8
leaq -0x1056(%rbp), %r13
jg 0x1836
incl %eax
movl %eax, 0x4967(%rip)      # 0x6174
leaq 0x194a(%rip), %rdi      # 0x315e
leaq 0x18a2(%rip), %rsi      # 0x30bd
movl $0x163, %edx            # imm = 0x163
xorl %eax, %eax
callq 0x2e85
leaq -0x856(%rbp), %r8
movl -0x54(%rbp), %eax
jmp 0x16a3
movl -0x1058(%rbp), %eax
movzbl -0x30(%rbp), %ecx
cmpb %al, %cl
movl %ecx, %edx
cmovgel %eax, %edx
cmpb $-0x1, %cl
cmovel %eax, %edx
movl %edx, -0x30(%rbp)
movzbl -0x1057(%rbp), %eax
movzbl -0x2c(%rbp), %ecx
cmpb %al, %cl
movl %ecx, %edx
cmovlel %eax, %edx
cmpb $-0x1, %cl
cmovel %eax, %edx
movl %edx, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1a24
leaq 0x1861(%rip), %rsi      # 0x30e0
movq %r13, %rdx
leaq -0xc56(%rbp), %rcx
leaq -0x456(%rbp), %r9
xorl %eax, %eax
callq 0x1110
testl %eax, %eax
jne 0x1a24
leaq 0x1847(%rip), %rdi      # 0x30ed
leaq 0x1810(%rip), %rsi      # 0x30bd
movl $0x1e6, %edx            # imm = 0x1E6
xorl %eax, %eax
callq 0x2db4
jmp 0x1a24
movl 0x48b0(%rip), %ecx      # 0x6174
cmpl $0x3e7, %ecx            # imm = 0x3E7
jg 0x18f4
incl %ecx
movl %ecx, 0x48a0(%rip)      # 0x6174
leaq 0x189d(%rip), %rdi      # 0x3178
leaq 0x17db(%rip), %rsi      # 0x30bd
movl $0x16d, %edx            # imm = 0x16D
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x2e85
movl $0x1, -0x54(%rbp)
leaq -0x1056(%rbp), %r13
jmp 0x1a13
movl 0x4867(%rip), %eax      # 0x6174
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1944
incl %eax
movl %eax, 0x4858(%rip)      # 0x6174
leaq 0x1a35(%rip), %rdi      # 0x3358
leaq 0x1793(%rip), %rsi      # 0x30bd
movl $0x102, %edx            # imm = 0x102
xorl %eax, %eax
callq 0x2e85
leaq -0x856(%rbp), %r8
movl -0x105c(%rbp), %r13d
movl $0x1, -0x54(%rbp)
pushq $0x1
popq %rax
orw $-0x1, -0x1058(%rbp)
testl %r13d, %r13d
movl $0x0, %ecx
cmovlel %ecx, %r13d
movb $-0x1, %cl
movb $-0x1, %dl
xorl %esi, %esi
cmpq %rsi, %r13
je 0x19a6
movb -0x456(%rbp,%rsi), %dil
cmpb $-0x1, %dl
je 0x198f
cmpb %dl, %dil
jge 0x1988
movb %dil, -0x1058(%rbp)
movl %edi, %edx
cmpb %cl, %dil
jg 0x1998
jmp 0x19a1
movb %dil, -0x1058(%rbp)
movl %edi, %edx
movb %dil, -0x1057(%rbp)
movl %edi, %ecx
incq %rsi
jmp 0x1968
cmpb $0x20, %dl
jg 0x19df
movsbl %dl, %ecx
leaq 0x19ca(%rip), %rdi      # 0x337f
leaq 0x1701(%rip), %rsi      # 0x30bd
movl $0x131, %edx            # imm = 0x131
xorl %eax, %eax
callq 0x2e85
leaq -0x856(%rbp), %r8
movl $0x1, -0x54(%rbp)
movb -0x1057(%rbp), %cl
pushq $0x1
popq %rax
cmpb $0x7f, %cl
leaq -0x1056(%rbp), %r13
jne 0x16a3
leaq 0x1989(%rip), %rdi      # 0x337f
leaq 0x16c0(%rip), %rsi      # 0x30bd
movl $0x136, %edx            # imm = 0x136
pushq $0x7f
popq %rcx
xorl %eax, %eax
callq 0x2e85
movl $0x1, -0x54(%rbp)
movl 0x475b(%rip), %eax      # 0x6174
cmpl $0x3e7, %eax            # imm = 0x3E7
jle 0x1a58
incq -0x48(%rbp)
incq %r12
addq $0x4, %r15
movq %r12, %rax
xorl %edx, %edx
movl $0xf4240, %ecx          # imm = 0xF4240
divq %rcx
testq %rdx, %rdx
jne 0x1466
movq 0x45b0(%rip), %rax      # 0x5ff8
movq (%rax), %rsi
pushq $0x2e
popq %rdi
callq 0x1160
jmp 0x1466
incl %eax
movl %eax, 0x4714(%rip)      # 0x6174
leaq 0x1623(%rip), %rdi      # 0x308a
leaq 0x164f(%rip), %rsi      # 0x30bd
movl $0x1d0, %edx            # imm = 0x1D0
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e85
movq 0x4574(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x163d(%rip), %rsi      # 0x30cb
movq %r13, %rdx
leaq -0xc56(%rbp), %rcx
leaq -0x856(%rbp), %r8
leaq -0x456(%rbp), %r9
xorl %eax, %eax
callq 0x1180
jmp 0x1a20
movq 0x453f(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x1779(%rip), %rsi      # 0x323c
movq %r13, %rdx
xorl %eax, %eax
callq 0x1180
movq -0x38(%rbp), %r12
movq -0x50(%rbp), %r15
jmp 0x1680
movq 0x4517(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x171f(%rip), %rsi      # 0x320a
movq %r13, %rdx
xorl %eax, %eax
callq 0x1180
jmp 0x1680
xorl %eax, %eax
jmp 0x194e
orl $-0x1, -0x54(%rbp)
xorl %eax, %eax
movb %al, -0x1056(%rbp)
movb %al, -0xc56(%rbp)
movb %al, -0x856(%rbp)
movb %al, -0x456(%rbp)
movq 0x44d2(%rip), %rbx      # 0x5ff8
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x1160
movq (%rbx), %rcx
leaq 0x187d(%rip), %rdi      # 0x33b8
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1270
movl -0x30(%rbp), %eax
movsbl %al, %ebx
movsbl -0x2c(%rbp), %r15d
cmpb $-0x1, %al
je 0x1b5b
cmpb $-0x1, -0x2c(%rbp)
jne 0x1b77
movq 0x4496(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0x1866(%rip), %rdi      # 0x33d2
pushq $0x35
popq %rsi
pushq $0x1
popq %rdx
callq 0x1270
movq 0x447a(%rip), %r13      # 0x5ff8
movq (%r13), %rdi
leaq 0x187f(%rip), %rsi      # 0x3408
movl %ebx, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x1180
movl -0x30(%rbp), %eax
cmpb $0x3a, %al
jg 0x1bdb
movq (%r13), %rcx
leaq 0x187d(%rip), %rdi      # 0x3424
pushq $0x42
popq %rsi
pushq $0x1
popq %rdx
callq 0x1270
cmpb $0x68, -0x2c(%rbp)
movq %r13, %rbx
movq -0x48(%rbp), %r15
jl 0x1c31
leaq 0x18a1(%rip), %rdi      # 0x3467
leaq 0x14f0(%rip), %rsi      # 0x30bd
movl $0x18a, %edx            # imm = 0x18A
xorl %eax, %eax
callq 0x2e85
jmp 0x1c31
cmpb $0x3f, %al
movq -0x48(%rbp), %r15
ja 0x1c06
leaq 0x18dc(%rip), %rdi      # 0x34c6
leaq 0x14cc(%rip), %rsi      # 0x30bd
movl $0x18f, %edx            # imm = 0x18F
xorl %eax, %eax
callq 0x2e85
movq 0x43f4(%rip), %rbx      # 0x5ff8
jmp 0x1c31
movq 0x43eb(%rip), %rbx      # 0x5ff8
movq (%rbx), %rcx
cmpb $0x41, %al
ja 0x1c1d
leaq 0x1909(%rip), %rdi      # 0x3524
jmp 0x1c24
leaq 0x198c(%rip), %rdi      # 0x35b0
pushq $0x1
popq %rdx
movl $0x8b, %esi
callq 0x1270
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x1160
movq (%rbx), %rdi
leaq 0x14cd(%rip), %rsi      # 0x3113
movq %r12, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1180
movq %r14, %rdi
callq 0x1040
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1c6b
callq 0x1040
jmp 0x1c70
testq %r15, %r15
jg 0x1cc0
xorl %eax, %eax
addq $0x1458, %rsp           # imm = 0x1458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x436d(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
jmp 0x1caf
movq 0x4361(%rip), %r14      # 0x5ff8
movq (%r14), %rdi
movq 0x10(%rbx), %rdx
leaq 0x135f(%rip), %rsi      # 0x3004
xorl %eax, %eax
callq 0x1180
movq (%r14), %rdi
movq (%rbx), %rdx
leaq 0x136c(%rip), %rsi      # 0x3025
xorl %eax, %eax
callq 0x1180
pushq $0x2
popq %rdi
callq 0x1260