// File: /workspace/github_cpp_makefile_star2_O1/rpetit3[P]fastq-scan/fastq-scan.cpp
// Function: main
int main(int argc, char **argv) {
    // Read command line
    float GENOME_SIZE =  1.0;
    int PHRED_OFFSET = 33;
    bool QC_ONLY = false;
    int opt;
    while ((opt = getopt(argc, argv, "g:p:qvh")) >= 0) {
        switch (opt) {
            case 'g': GENOME_SIZE = atof(optarg); break;
            case 'p': PHRED_OFFSET = atoi(optarg); break;
            case 'q': QC_ONLY = true; break;
            case 'v': return version();
            case 'h': return usage();
        }
    }
    if (!(PHRED_OFFSET == 33 || PHRED_OFFSET == 64)) {
        cerr << "Invalid value for -p (" << PHRED_OFFSET << "), only 33 or 64 are valid" << endl;
        return 1;
    } else if (GENOME_SIZE < 0) {
        cerr << "Invalid value for -g (" << GENOME_SIZE << "), value muse be >= 0" << endl;
        return 1;
    }
    
    if (isatty(0)) return usage();

    // Parse FASTQ
    Stats stats;
    stats.init();
    stats.phred = PHRED_OFFSET;
    string name, seq, plus, qual;
    ifstream in("/dev/stdin", ios::in);
    while(true) {
        if(!getline(in, name, '\n')) break;
        if(!getline(in, seq, '\n')) break;
        if(!getline(in, plus, '\n')) break;
        if(!getline(in, qual, '\n')) break;
        stats.read_length.push_back(seq.length());
        stats.read_total++;
        int missing_qual = stats.transform_quality(qual);
        if (missing_qual == 1){
            cerr << "WARNING: Missing quality for a read.\n";
            cerr << name << "\n";
            cerr << seq << "\n";
            cerr << plus << "\n";
            cerr << qual << "\n";
            cerr << "Please fix it to continue.\n";
            exit(50);
        }
    }
    in.close();

    if (stats.read_total > 0) {
        // Determine Stats
        stats.read_stats();
        stats.qual_stats();
        stats.jsonify_stats(GENOME_SIZE, QC_ONLY);
    } else {
        // Empty file, or nothing to parse
        cerr << "Nothing to parse in STDIN, please verify your file is not empty." << endl;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
movq %rsi, %r14
movl %edi, %ebp
leaq 0x3c9d(%rip), %rdx      # 0x6076
callq 0x2050
testl %eax, %eax
js 0x2469
movl $0x21, %ebx
movss 0x3c11(%rip), %xmm0     # 0x6004
movss %xmm0, (%rsp)
xorl %r13d, %r13d
movq 0x6bbe(%rip), %r12      # 0x8fc0
leaq 0x3c6d(%rip), %r15      # 0x6076
cmpl $0x6f, %eax
jle 0x241d
cmpl $0x70, %eax
je 0x2436
cmpl $0x71, %eax
jne 0x2443
movb $0x1, %r13b
jmp 0x2456
cmpl $0x67, %eax
jne 0x244d
movq (%r12), %rdi
callq 0x2160
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
jmp 0x2456
movq (%r12), %rdi
callq 0x2180
movl %eax, %ebx
jmp 0x2456
cmpl $0x76, %eax
jne 0x2456
jmp 0x2568
cmpl $0x68, %eax
je 0x255e
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2050
testl %eax, %eax
jns 0x2409
jmp 0x247e
movss 0x3b93(%rip), %xmm0     # 0x6004
movss %xmm0, (%rsp)
movl $0x21, %ebx
xorl %r13d, %r13d
cmpl $0x21, %ebx
je 0x2488
cmpl $0x40, %ebx
jne 0x24f1
xorps %xmm0, %xmm0
movss (%rsp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x24d6
movq 0x6b54(%rip), %rbx      # 0x8ff0
leaq 0x3c0d(%rip), %rsi      # 0x60b0
movl $0x16, %edx
movq %rbx, %rdi
movss %xmm1, (%rsp)
callq 0x2140
xorps %xmm0, %xmm0
cvtss2sd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x2190
movq %rax, %rbx
leaq 0x3bf8(%rip), %rsi      # 0x60c7
movl $0x15, %edx
jmp 0x2525
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x21c0
testl %eax, %eax
je 0x25c8
callq 0x2b0a
jmp 0x2a2a
movq 0x6af8(%rip), %r14      # 0x8ff0
leaq 0x3b7f(%rip), %rsi      # 0x607e
movl $0x16, %edx
movq %r14, %rdi
callq 0x2140
movq %r14, %rdi
movl %ebx, %esi
callq 0x21b0
movq %rax, %rbx
leaq 0x3b75(%rip), %rsi      # 0x6095
movl $0x1a, %edx
movq %rax, %rdi
callq 0x2140
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20a0
movl $0x1, %ebp
jmp 0x2a2a
callq 0x2b0a
jmp 0x2a28
movq 0x6a61(%rip), %rbx      # 0x8fd0
leaq 0x3bf5(%rip), %rsi      # 0x616b
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2140
movq 0x6ba6(%rip), %rsi      # 0x9130
movq 0x6ba7(%rip), %rdx      # 0x9138
movq %rbx, %rdi
callq 0x2140
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20a0
jmp 0x2a28
xorps %xmm0, %xmm0
leaq 0xa8(%rsp), %rdi
movups %xmm0, 0x28(%rdi)
movups %xmm0, 0x18(%rdi)
movups %xmm0, 0x8(%rdi)
movups %xmm0, 0x70(%rdi)
movups %xmm0, 0x80(%rdi)
movups %xmm0, 0x90(%rdi)
movups %xmm0, 0xa0(%rdi)
movq $0x0, 0xb0(%rdi)
callq 0x2d5c
movl %ebx, 0x160(%rsp)
leaq 0x78(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x58(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x3a89(%rip), %rsi      # 0x60dd
leaq 0x1a0(%rsp), %rdi
movl $0x8, %edx
callq 0x21f0
leaq 0x98(%rsp), %r12
leaq 0x1a0(%rsp), %r14
leaq 0x68(%rsp), %r15
leaq 0x88(%rsp), %rbx
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2887
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
movl $0xa, %edx
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2887
movq %r14, %rdi
leaq 0x48(%rsp), %rsi
movl $0xa, %edx
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2887
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2887
movl 0x30(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0xb8(%rsp), %rsi
cmpq 0xc0(%rsp), %rsi
je 0x273b
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb8(%rsp)
jmp 0x274d
leaq 0xb0(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x5a0c
incq 0xe0(%rsp)
movq %r12, 0x88(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x58ec
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2de0
movl %eax, %ebp
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x27a1
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2130
cmpl $0x1, %ebp
jne 0x2683
movq 0x683f(%rip), %rdi      # 0x8ff0
leaq 0x3930(%rip), %rsi      # 0x60e8
movl $0x25, %edx
callq 0x2140
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x681d(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x392d(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x67f3(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x3903(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x67c9(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x38d9(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x679f(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x38af(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x677f(%rip), %rdi      # 0x8ff0
leaq 0x3896(%rip), %rsi      # 0x610e
callq 0x2110
movl $0x32, %edi
callq 0x2150
leaq 0x1a0(%rsp), %rdi
callq 0x2040
cmpq $0x0, 0xe0(%rsp)
je 0x28d4
leaq 0xa8(%rsp), %rdi
callq 0x2e8e
leaq 0xa8(%rsp), %rdi
callq 0x31b2
movzbl %r13b, %esi
andl $0x1, %esi
leaq 0xa8(%rsp), %rdi
movss (%rsp), %xmm0
callq 0x3518
jmp 0x291a
movq 0x6715(%rip), %rbx      # 0x8ff0
leaq 0x3848(%rip), %rsi      # 0x612a
movl $0x40, %edx
movq %rbx, %rdi
callq 0x2140
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2100
movsbl %al, %esi
movq 0x66e3(%rip), %rdi      # 0x8ff0
callq 0x2030
movq %rax, %rdi
callq 0x20a0
leaq 0x1a0(%rsp), %rdi
callq 0x2060
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2943
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x295f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x297b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2997
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x29b4
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x29d1
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x29ee
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x2a0b
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x2a28
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2a85
movq %rax, %rbx
jmp 0x2af5
jmp 0x2a75
jmp 0x2a75
jmp 0x2a75
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x2a78
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2130
jmp 0x2a78
jmp 0x2a75
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x2060
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2aa1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2abd
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2ad9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2af5
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2130
leaq 0xa8(%rsp), %rdi
callq 0x443e
movq %rbx, %rdi
callq 0x21d0