// File: /workspace/github_c_makefile_star2_O3/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 $0x1448, %rsp           # imm = 0x1448
movq %rsi, %rbx
cmpl $0x2, %edi
je 0x1636
cmpl $0x3, %edi
jne 0x1e8c
leaq 0x10(%rbx), %r14
movq 0x10(%rbx), %rdi
callq 0x24d3
testl %eax, %eax
jne 0x1e94
movq (%r14), %rdi
leaq 0x2a54(%rip), %rsi      # 0x4064
callq 0x2e28
movq %rax, -0x48(%rbp)
movq 0x59d8(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0x2a3a(%rip), %rsi      # 0x4067
xorl %eax, %eax
callq 0x1180
jmp 0x163e
movq $0x0, -0x48(%rbp)
movq 0x8(%rbx), %rdi
leaq 0x2a3e(%rip), %rsi      # 0x4087
callq 0x2e28
movq %rax, %r14
leaq -0x104e(%rbp), %rbx
movl $0x0, 0x1002(%rbx)
movq %rax, %rdi
movq %rbx, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
jne 0x1726
movb $-0x1, %al
movl %eax, -0x2c(%rbp)
xorl %r12d, %r12d
xorl %r15d, %r15d
movb $-0x1, %al
movl %eax, -0x30(%rbp)
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
xorl %eax, %eax
movb %al, -0x104e(%rbp)
movb %al, -0xc4e(%rbp)
movb %al, -0x84e(%rbp)
movb %al, -0x44e(%rbp)
movq 0x5945(%rip), %rbx      # 0x6ff8
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x1160
movq (%rbx), %rcx
leaq 0x2cee(%rip), %rdi      # 0x43b8
movl $0x19, %esi
movl $0x1, %edx
callq 0x1260
movsbl -0x2c(%rbp), %r13d
movl -0x30(%rbp), %eax
movsbl %al, %ebx
cmpb $-0x1, %r13b
je 0x16ee
cmpb $-0x1, %al
jne 0x16f3
callq 0x1304
movq 0x58fe(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2d04(%rip), %rsi      # 0x4408
movl %r13d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1180
cmpb $0x3a, %r13b
jg 0x1df3
movl %ebx, %edi
callq 0x1360
jmp 0x1e30
movl $0x1, %r13d
movb $-0x1, %al
movl %eax, -0x30(%rbp)
leaq -0x146c(%rbp), %rdi
movb $-0x1, %al
movl %eax, -0x2c(%rbp)
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpb $0x40, -0x104e(%rbp)
movq %r13, -0x38(%rbp)
jne 0x1826
movq %r12, -0x40(%rbp)
movq %rbx, %rsi
movq %r14, %rdx
movq %rdi, %r12
callq 0x1ea9
movq %rbx, %rdi
callq 0x2bc0
movq %r14, %rdi
leaq -0xc4e(%rbp), %rbx
movq %rbx, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x1893
movq %r15, %r13
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1ea9
movq %rbx, %rdi
callq 0x2bc0
movq %r14, %rdi
leaq -0x84e(%rbp), %r15
movq %r15, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x1a08
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1ea9
movq %r15, %rdi
callq 0x2bc0
movq %r14, %rdi
leaq -0x44e(%rbp), %r15
movq %r15, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x1a71
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1ea9
movq %r15, %rdi
callq 0x2bc0
movq %r13, %r15
leaq -0x104e(%rbp), %rbx
movq -0x40(%rbp), %r12
jmp 0x1953
movl 0x5940(%rip), %eax      # 0x716c
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1855
incl %eax
movl %eax, 0x5931(%rip)      # 0x716c
leaq 0x2973(%rip), %rdi      # 0x41b5
leaq 0x2874(%rip), %rsi      # 0x40bd
movl $0x94, %edx
xorl %eax, %eax
callq 0x1403
movl $0x1, -0x4c(%rbp)
xorl %eax, %eax
movb %al, -0xc4e(%rbp)
movb %al, -0x84e(%rbp)
movb %al, -0x44e(%rbp)
movl (%r14), %eax
movq %r12, %rbx
testl %eax, %eax
je 0x18cd
decl %eax
movl %eax, (%r14)
incq 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movb (%rax), %al
jmp 0x18d5
leaq 0x294c(%rip), %rdi      # 0x41e6
leaq 0x281c(%rip), %rsi      # 0x40bd
movl $0xa6, %edx
xorl %eax, %eax
callq 0x1403
movl $0x1, -0x4c(%rbp)
xorl %eax, %eax
movb %al, -0xc4e(%rbp)
movb %al, -0x84e(%rbp)
movb %al, -0x44e(%rbp)
jmp 0x1aa0
movq %r14, %rdi
callq 0x10f0
movq %r15, %r12
cmpb $-0x1, %al
je 0x1c6a
movb $0xa, %r15b
xorl %r13d, %r13d
movl %r15d, %ecx
movl %eax, %r15d
xorb $0xa, %cl
xorb $0x40, %al
orb %cl, %al
je 0x1929
movl (%r14), %eax
testl %eax, %eax
je 0x1915
decl %eax
movl %eax, (%r14)
incq 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movb (%rax), %al
jmp 0x191d
movq %r14, %rdi
callq 0x10f0
incq %r13
cmpb $-0x1, %al
jne 0x18e6
jmp 0x1c6d
movl $0x40, %edi
movq %r14, %rsi
callq 0x1100
cmpl $0x3e7, 0x582c(%rip)    # imm = 0x3E7
movq %r12, %r15
movq %rbx, %r12
leaq -0x104e(%rbp), %rbx
jle 0x1c9a
movl -0x4c(%rbp), %eax
testl %eax, %eax
movq -0x38(%rbp), %r13
je 0x197d
testl %eax, %eax
je 0x1aeb
cmpl $0x1, %eax
je 0x1d1e
cmpl $-0x1, %eax
jne 0x1d2e
jmp 0x16ac
cmpb $0x2b, -0x84e(%rbp)
jne 0x1a39
leaq -0xc4e(%rbp), %rdi
callq 0x1120
movq %rax, %r13
movl %r13d, -0x1054(%rbp)
leaq -0x44e(%rbp), %rdi
callq 0x1120
testl %r13d, %r13d
jle 0x1ab0
movl %r13d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rax, %rcx
jne 0x1b7a
xorl %edx, %edx
movsbl -0xc4e(%rbp,%rdx), %ecx
cmpl $0x41, %ecx
je 0x19f9
movl $0x1, %esi
cmpq $0x17, %rsi
je 0x1bc0
leaq 0x1(%rsi), %rdi
leaq 0x2951(%rip), %r8       # 0x4341
cmpb (%rsi,%r8), %cl
movq %rdi, %rsi
jne 0x19db
incq %rdx
cmpq %rax, %rdx
jne 0x19c9
xorl %eax, %eax
jmp 0x1c02
leaq 0x27d7(%rip), %rdi      # 0x41e6
leaq 0x26a7(%rip), %rsi      # 0x40bd
movl $0xb4, %edx
xorl %eax, %eax
callq 0x1403
movl $0x1, -0x4c(%rbp)
xorl %eax, %eax
movb %al, -0x84e(%rbp)
movb %al, -0x44e(%rbp)
jmp 0x1a99
movl 0x572d(%rip), %eax      # 0x716c
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1d17
incl %eax
movl %eax, 0x571a(%rip)      # 0x716c
leaq 0x26db(%rip), %rdi      # 0x4134
leaq 0x265d(%rip), %rsi      # 0x40bd
movl $0x156, %edx            # imm = 0x156
xorl %eax, %eax
callq 0x1403
jmp 0x1d17
leaq 0x276e(%rip), %rdi      # 0x41e6
leaq 0x263e(%rip), %rsi      # 0x40bd
movl $0xc0, %edx
xorl %eax, %eax
callq 0x1403
movl $0x1, -0x4c(%rbp)
movb $0x0, -0x44e(%rbp)
movq %r13, %r15
movq -0x38(%rbp), %r13
leaq -0x104e(%rbp), %rbx
movq -0x40(%rbp), %r12
jmp 0x1d1e
movl 0x56b6(%rip), %eax      # 0x716c
cmpl $0x3e7, %eax            # imm = 0x3E7
movq -0x38(%rbp), %r13
jg 0x1aeb
incl %eax
movl %eax, 0x56a3(%rip)      # 0x716c
leaq 0x268e(%rip), %rdi      # 0x415e
leaq 0x25e6(%rip), %rsi      # 0x40bd
movl $0x163, %edx            # imm = 0x163
xorl %eax, %eax
callq 0x1403
movl -0x4c(%rbp), %eax
jmp 0x195e
movl -0x1050(%rbp), %eax
movzbl -0x2c(%rbp), %ecx
cmpb %al, %cl
movl %ecx, %edx
cmovgel %eax, %edx
cmpb $-0x1, %cl
cmovel %eax, %edx
movl %edx, -0x2c(%rbp)
movzbl -0x104f(%rbp), %eax
movzbl -0x30(%rbp), %ecx
cmpb %al, %cl
movl %ecx, %edx
cmovlel %eax, %edx
cmpb $-0x1, %cl
cmovel %eax, %edx
movl %edx, -0x30(%rbp)
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x1d2e
leaq 0x25ac(%rip), %rsi      # 0x40e0
movq %rbx, %rdx
leaq -0xc4e(%rbp), %rcx
leaq -0x84e(%rbp), %r8
leaq -0x44e(%rbp), %r9
xorl %eax, %eax
callq 0x1110
testl %eax, %eax
jne 0x1d2e
leaq 0x258b(%rip), %rdi      # 0x40ed
leaq 0x2554(%rip), %rsi      # 0x40bd
movl $0x1e6, %edx            # imm = 0x1E6
xorl %eax, %eax
callq 0x30d4
jmp 0x1d2e
movl 0x55ec(%rip), %ecx      # 0x716c
cmpl $0x3e7, %ecx            # imm = 0x3E7
jg 0x1bb0
incl %ecx
movl %ecx, 0x55dc(%rip)      # 0x716c
leaq 0x25e1(%rip), %rdi      # 0x4178
leaq 0x251f(%rip), %rsi      # 0x40bd
movl $0x16d, %edx            # imm = 0x16D
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x1403
movl $0x1, -0x4c(%rbp)
movq -0x38(%rbp), %r13
jmp 0x1d1e
movl 0x55a6(%rip), %eax      # 0x716c
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1bf6
incl %eax
movl %eax, 0x5597(%rip)      # 0x716c
leaq 0x277c(%rip), %rdi      # 0x4358
leaq 0x24da(%rip), %rsi      # 0x40bd
movl $0x102, %edx            # imm = 0x102
xorl %eax, %eax
callq 0x1403
movl -0x1054(%rbp), %r13d
movl $0x1, -0x4c(%rbp)
movl $0x1, %eax
movw $0xffff, -0x1050(%rbp)  # imm = 0xFFFF
testl %r13d, %r13d
jle 0x1cba
movl %r13d, %esi
movb $-0x1, %cl
xorl %edi, %edi
movb $-0x1, %dl
movq -0x38(%rbp), %r13
movb -0x44e(%rbp,%rdi), %r8b
cmpb $-0x1, %dl
je 0x1c44
cmpb %dl, %r8b
jge 0x1c3d
movb %r8b, -0x1050(%rbp)
movl %r8d, %edx
cmpb %cl, %r8b
jg 0x1c4e
jmp 0x1c58
movb %r8b, -0x1050(%rbp)
movl %r8d, %edx
movb %r8b, -0x104f(%rbp)
movl %r8d, %ecx
incq %rdi
cmpq %rdi, %rsi
jne 0x1c21
cmpb $0x20, %dl
jle 0x1cc0
jmp 0x1cef
xorl %r13d, %r13d
movq 0x5384(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x25be(%rip), %rsi      # 0x423c
movq %r13, %rdx
xorl %eax, %eax
callq 0x1180
movq %r12, %r15
movq %rbx, %r12
leaq -0x104e(%rbp), %rbx
jmp 0x1953
movq 0x5357(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x255f(%rip), %rsi      # 0x420a
movq %r13, %rdx
xorl %eax, %eax
callq 0x1180
jmp 0x1953
movb $-0x1, %dl
movq -0x38(%rbp), %r13
movsbl %dl, %ecx
leaq 0x26b5(%rip), %rdi      # 0x437f
leaq 0x23ec(%rip), %rsi      # 0x40bd
movl $0x131, %edx            # imm = 0x131
xorl %eax, %eax
callq 0x1403
movl $0x1, -0x4c(%rbp)
movl $0x1, %eax
movb -0x104f(%rbp), %cl
cmpb $0x7f, %cl
jne 0x195e
leaq 0x2680(%rip), %rdi      # 0x437f
leaq 0x23b7(%rip), %rsi      # 0x40bd
movl $0x136, %edx            # imm = 0x136
movl $0x7f, %ecx
xorl %eax, %eax
callq 0x1403
movl $0x1, -0x4c(%rbp)
movl 0x5448(%rip), %eax      # 0x716c
cmpl $0x3e7, %eax            # imm = 0x3E7
jle 0x1d99
incq %r15
incq %r12
movq %r12, %rax
movabsq $0x790fb65668c26139, %rcx # imm = 0x790FB65668C26139
imulq %rcx, %rax
rorq $0x6, %rax
movabsq $0x10c6f7a0b5ed, %rcx   # imm = 0x10C6F7A0B5ED
cmpq %rcx, %rax
ja 0x1d69
movq 0x529c(%rip), %rax      # 0x6ff8
movq (%rax), %rsi
movl $0x2e, %edi
callq 0x1160
addq $0x4, %r13
movl $0x0, -0x4c(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
leaq -0x146c(%rbp), %rdi
jne 0x1743
jmp 0x168b
incl %eax
movl %eax, 0x53cb(%rip)      # 0x716c
leaq 0x22e2(%rip), %rdi      # 0x408a
leaq 0x230e(%rip), %rsi      # 0x40bd
movl $0x1d0, %edx            # imm = 0x1D0
movq %r13, %rcx
xorl %eax, %eax
callq 0x1403
movq 0x5233(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x22fc(%rip), %rsi      # 0x40cb
movq %rbx, %rdx
leaq -0xc4e(%rbp), %rcx
leaq -0x84e(%rbp), %r8
leaq -0x44e(%rbp), %r9
xorl %eax, %eax
callq 0x1180
jmp 0x1d2b
movl -0x2c(%rbp), %eax
cmpb $0x3f, %al
ja 0x1e16
leaq 0x26c5(%rip), %rdi      # 0x44c6
leaq 0x22b5(%rip), %rsi      # 0x40bd
movl $0x18f, %edx            # imm = 0x18F
xorl %eax, %eax
callq 0x1403
jmp 0x1e30
movq 0x51db(%rip), %rcx      # 0x6ff8
movq (%rcx), %rdi
cmpb $0x41, %al
ja 0x1e2b
callq 0x1343
jmp 0x1e30
callq 0x1326
movq 0x51c1(%rip), %rbx      # 0x6ff8
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x1160
movq (%rbx), %rdi
leaq 0x22c5(%rip), %rsi      # 0x4113
movq %r12, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1180
movq %r14, %rdi
callq 0x1040
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x1e73
callq 0x1040
jmp 0x1e78
testq %r15, %r15
jg 0x1e9f
xorl %eax, %eax
addq $0x1448, %rsp           # imm = 0x1448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x13aa
movq %r14, %rdi
movq %rbx, %rsi
callq 0x12c0
movl $0x2, %edi
callq 0x1250