// File: /workspace/github_c_makefile_star2_O1/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 0x1645
cmpl $0x3, %edi
jne 0x1e4f
leaq 0x10(%rbx), %r14
movq 0x10(%rbx), %rdi
callq 0x249b
testl %eax, %eax
jne 0x1e57
movq (%r14), %rdi
leaq 0x2a44(%rip), %rsi      # 0x4064
callq 0x2df0
movq %rax, %r15
movq 0x59c9(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0x2a2b(%rip), %rsi      # 0x4067
xorl %eax, %eax
callq 0x1190
jmp 0x1648
xorl %r15d, %r15d
movq %r15, -0x50(%rbp)
movq 0x8(%rbx), %rdi
leaq 0x2a30(%rip), %rsi      # 0x4087
callq 0x2df0
movq %rax, %r14
leaq -0x1056(%rbp), %rbx
leaq -0xc56(%rbp), %r15
movb $-0x1, %al
movl %eax, -0x2c(%rbp)
movl $0x1, %eax
movq %rax, -0x48(%rbp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movb $-0x1, %al
movl %eax, -0x30(%rbp)
movl $0x0, -0x54(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x177b
cmpb $0x40, -0x1056(%rbp)
jne 0x17a1
movq %r12, -0x38(%rbp)
movq %r13, -0x40(%rbp)
leaq -0x1474(%rbp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1e6c
movq %rbx, %r12
movq %rbx, %rdi
callq 0x2b8d
movq %r14, %rdi
movq %r15, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x180e
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1e6c
movq %r15, %rdi
callq 0x2b8d
movq %r14, %rdi
leaq -0x856(%rbp), %r15
movq %r15, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x18de
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1e6c
movq %r15, %rdi
callq 0x2b8d
movq %r14, %rdi
leaq -0x456(%rbp), %r15
movq %r15, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
testq %rax, %rax
je 0x1c6f
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1e6c
movq %r15, %rdi
callq 0x2b8d
jmp 0x190d
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
xorl %eax, %eax
movb %al, -0x1056(%rbp)
movb %al, -0xc56(%rbp)
movb %al, -0x856(%rbp)
movb %al, -0x456(%rbp)
jmp 0x1918
movl 0x59cd(%rip), %eax      # 0x7174
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x17d0
incl %eax
movl %eax, 0x59be(%rip)      # 0x7174
leaq 0x29f8(%rip), %rdi      # 0x41b5
leaq 0x28f9(%rip), %rsi      # 0x40bd
movl $0x94, %edx
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
xorl %eax, %eax
movb %al, -0xc56(%rbp)
movb %al, -0x856(%rbp)
movb %al, -0x456(%rbp)
movl (%r14), %eax
movq %r12, %rbx
testl %eax, %eax
je 0x183c
decl %eax
movl %eax, (%r14)
incq 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movb (%rax), %al
jmp 0x1844
leaq 0x29d1(%rip), %rdi      # 0x41e6
leaq 0x28a1(%rip), %rsi      # 0x40bd
movl $0xa6, %edx
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
xorl %eax, %eax
movb %al, -0xc56(%rbp)
jmp 0x1901
movq %r14, %rdi
callq 0x10f0
movq %r13, %r12
cmpb $-0x1, %al
je 0x1cf7
movb $0xa, %r13b
xorl %r15d, %r15d
movl %r13d, %ecx
movl %eax, %r13d
xorb $0xa, %cl
xorb $0x40, %al
orb %cl, %al
je 0x1898
movl (%r14), %eax
testl %eax, %eax
je 0x1884
decl %eax
movl %eax, (%r14)
incq 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movb (%rax), %al
jmp 0x188c
movq %r14, %rdi
callq 0x10f0
incq %r15
cmpb $-0x1, %al
jne 0x1855
jmp 0x1cfa
movl $0x40, %edi
movq %r14, %rsi
callq 0x1100
cmpl $0x3e7, 0x58c5(%rip)    # imm = 0x3E7
movq %rbx, %rax
leaq -0x1056(%rbp), %rbx
movq %r12, %r13
movq %rax, %r12
jg 0x1918
movq 0x5730(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2938(%rip), %rsi      # 0x420a
movq %r15, %rdx
xorl %eax, %eax
callq 0x1190
jmp 0x1918
leaq 0x2901(%rip), %rdi      # 0x41e6
leaq 0x27d1(%rip), %rsi      # 0x40bd
movl $0xb4, %edx
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
xorl %eax, %eax
movb %al, -0x856(%rbp)
movb %al, -0x456(%rbp)
movq -0x40(%rbp), %r13
movq %r12, %rbx
movq -0x38(%rbp), %r12
movl -0x54(%rbp), %r15d
testl %r15d, %r15d
jne 0x1b51
cmpb $0x2b, -0x856(%rbp)
jne 0x19aa
leaq -0xc56(%rbp), %rdi
callq 0x1120
movq %rax, %r15
movl %r15d, -0x105c(%rbp)
leaq -0x456(%rbp), %rdi
callq 0x1120
testl %r15d, %r15d
jle 0x19df
movl %r15d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rax, %rdx
jne 0x1a17
xorl %eax, %eax
leaq 0x29cd(%rip), %r8       # 0x4341
movsbl -0xc56(%rbp,%rax), %ecx
cmpl $0x41, %ecx
je 0x199d
movl $0x1, %esi
cmpq $0x17, %rsi
je 0x1a5f
leaq 0x1(%rsi), %rdi
cmpb (%rsi,%r8), %cl
movq %rdi, %rsi
jne 0x1986
incq %rax
cmpq %rdx, %rax
jne 0x1974
jmp 0x1a95
movl 0x57c4(%rip), %eax      # 0x7174
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1a4d
incl %eax
movl %eax, 0x57b1(%rip)      # 0x7174
leaq 0x276a(%rip), %rdi      # 0x4134
leaq 0x26ec(%rip), %rsi      # 0x40bd
movl $0x156, %edx            # imm = 0x156
xorl %eax, %eax
callq 0x1413
jmp 0x1a4d
movl 0x578f(%rip), %eax      # 0x7174
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1b4d
incl %eax
movl %eax, 0x577c(%rip)      # 0x7174
leaq 0x275f(%rip), %rdi      # 0x415e
leaq 0x26b7(%rip), %rsi      # 0x40bd
movl $0x163, %edx            # imm = 0x163
xorl %eax, %eax
callq 0x1413
jmp 0x1b4d
movl 0x5757(%rip), %ecx      # 0x7174
cmpl $0x3e7, %ecx            # imm = 0x3E7
jg 0x1a4d
incl %ecx
movl %ecx, 0x5747(%rip)      # 0x7174
leaq 0x2744(%rip), %rdi      # 0x4178
leaq 0x2682(%rip), %rsi      # 0x40bd
movl $0x16d, %edx            # imm = 0x16D
movl %r15d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
movl $0x1, %r15d
jmp 0x1b51
movl 0x570f(%rip), %eax      # 0x7174
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1a8e
incl %eax
movl %eax, 0x5700(%rip)      # 0x7174
leaq 0x28dd(%rip), %rdi      # 0x4358
leaq 0x263b(%rip), %rsi      # 0x40bd
movl $0x102, %edx            # imm = 0x102
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
movw $0xffff, -0x1058(%rbp)  # imm = 0xFFFF
movslq -0x105c(%rbp), %rax
testq %rax, %rax
jle 0x1af1
movb $-0x1, %dl
movb -0x1057(%rbp), %sil
xorl %ecx, %ecx
movb -0x456(%rbp,%rcx), %dil
cmpb $-0x1, %dl
je 0x1ad7
cmpb %dl, %dil
jge 0x1ad0
movb %dil, -0x1058(%rbp)
movl %edi, %edx
cmpb %sil, %dil
jg 0x1ae0
jmp 0x1ae9
movb %dil, -0x1058(%rbp)
movl %edi, %edx
movb %dil, -0x1057(%rbp)
movl %edi, %esi
incq %rcx
cmpq %rcx, %rax
jne 0x1ab5
movsbl -0x1058(%rbp), %ecx
cmpl $0x20, %ecx
jg 0x1b1e
leaq 0x287b(%rip), %rdi      # 0x437f
leaq 0x25b2(%rip), %rsi      # 0x40bd
movl $0x131, %edx            # imm = 0x131
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
cmpb $0x7f, -0x1057(%rbp)
jne 0x1b4d
leaq 0x2851(%rip), %rdi      # 0x437f
leaq 0x2588(%rip), %rsi      # 0x40bd
movl $0x136, %edx            # imm = 0x136
movl $0x7f, %ecx
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
movl -0x54(%rbp), %r15d
cmpl $-0x1, %r15d
je 0x1bc8
cmpl $0x1, %r15d
jne 0x1b71
movl 0x5611(%rip), %eax      # 0x7174
cmpl $0x3e7, %eax            # imm = 0x3E7
jle 0x1c9c
incq %r12
testl %r15d, %r15d
je 0x1be0
incq %r13
addq $0x4, -0x48(%rbp)
movq %r13, %rax
movabsq $0x790fb65668c26139, %rcx # imm = 0x790FB65668C26139
imulq %rcx, %rax
movabsq $0x218def416bd80, %rcx  # imm = 0x218DEF416BD80
addq %rcx, %rax
rorq $0x6, %rax
movb $0x1, %r15b
movabsq $0x10c6f7a0b5ec, %rcx   # imm = 0x10C6F7A0B5EC
cmpq %rcx, %rax
ja 0x1bcb
movq 0x543f(%rip), %rax      # 0x6ff8
movq (%rax), %rsi
movl $0x2e, %edi
callq 0x1160
jmp 0x1bcb
xorl %r15d, %r15d
testb %r15b, %r15b
leaq -0xc56(%rbp), %r15
jne 0x1686
jmp 0x1d2a
movl -0x1058(%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 -0x1057(%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 -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1b76
leaq 0x24b7(%rip), %rsi      # 0x40e0
movq %rbx, %rdx
leaq -0xc56(%rbp), %rcx
leaq -0x856(%rbp), %r8
leaq -0x456(%rbp), %r9
xorl %eax, %eax
callq 0x1110
testl %eax, %eax
jne 0x1b76
leaq 0x2496(%rip), %rdi      # 0x40ed
leaq 0x245f(%rip), %rsi      # 0x40bd
movl $0x1e6, %edx            # imm = 0x1E6
xorl %eax, %eax
callq 0x309c
jmp 0x1b76
leaq 0x2570(%rip), %rdi      # 0x41e6
leaq 0x2440(%rip), %rsi      # 0x40bd
movl $0xc0, %edx
xorl %eax, %eax
callq 0x1413
movl $0x1, -0x54(%rbp)
movb $0x0, -0x456(%rbp)
jmp 0x190d
incl %eax
movl %eax, 0x54d0(%rip)      # 0x7174
leaq 0x23df(%rip), %rdi      # 0x408a
leaq 0x240b(%rip), %rsi      # 0x40bd
movl $0x1d0, %edx            # imm = 0x1D0
movq -0x48(%rbp), %rcx
xorl %eax, %eax
callq 0x1413
movq 0x532f(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x23f8(%rip), %rsi      # 0x40cb
movq %rbx, %rdx
leaq -0xc56(%rbp), %rcx
leaq -0x856(%rbp), %r8
leaq -0x456(%rbp), %r9
xorl %eax, %eax
callq 0x1190
jmp 0x1b6e
xorl %r15d, %r15d
movq 0x52f7(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2531(%rip), %rsi      # 0x423c
movq %r15, %rdx
xorl %eax, %eax
callq 0x1190
movq %rbx, %rax
leaq -0x1056(%rbp), %rbx
movq %r12, %r13
movq %rax, %r12
jmp 0x1918
movq 0x52c7(%rip), %rbx      # 0x6ff8
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x1160
movq (%rbx), %rcx
leaq 0x2670(%rip), %rdi      # 0x43b8
movl $0x19, %esi
movl $0x1, %edx
callq 0x1270
movsbl -0x2c(%rbp), %r15d
movl -0x30(%rbp), %ebx
movsbl %bl, %ecx
cmpb $-0x1, %r15b
je 0x1d6d
cmpb $-0x1, %bl
jne 0x1d78
movl %ecx, -0x48(%rbp)
callq 0x1314
movl -0x48(%rbp), %ecx
movq 0x5279(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x267f(%rip), %rsi      # 0x4408
movl %r15d, %edx
xorl %eax, %eax
callq 0x1190
cmpb $0x3a, %r15b
jg 0x1da7
movzbl %bl, %edi
callq 0x1370
movq -0x50(%rbp), %rbx
jmp 0x1deb
movl -0x2c(%rbp), %eax
cmpb $0x3f, %al
movq -0x50(%rbp), %rbx
jg 0x1dce
leaq 0x270d(%rip), %rdi      # 0x44c6
leaq 0x22fd(%rip), %rsi      # 0x40bd
movl $0x18f, %edx            # imm = 0x18F
xorl %eax, %eax
callq 0x1413
jmp 0x1deb
movl %eax, %ecx
movq 0x5221(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
cmpb $0x41, %cl
jg 0x1de6
callq 0x1353
jmp 0x1deb
callq 0x1336
movq 0x5206(%rip), %r15      # 0x6ff8
movq (%r15), %rsi
movl $0xa, %edi
callq 0x1160
movq (%r15), %rdi
leaq 0x230a(%rip), %rsi      # 0x4113
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1190
movq %r14, %rdi
callq 0x1040
testq %rbx, %rbx
je 0x1e2b
movq %rbx, %rdi
callq 0x1040
testq %rbx, %rbx
setne %al
testq %r12, %r12
setle %cl
orb %al, %cl
je 0x1e62
xorl %eax, %eax
addq $0x1458, %rsp           # imm = 0x1458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x13ba
movq %r14, %rdi
movq %rbx, %rsi
callq 0x12d0
movl $0x2, %edi
callq 0x1260