// File: /workspace/github_cpp_makefile_star2_O3/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 0x24c6
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 0x287c
cmpl $0x68, %eax
je 0x2872
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2050
testl %eax, %eax
jns 0x2409
cmpl $0x21, %ebx
je 0x2475
cmpl $0x40, %ebx
jne 0x2805
xorps %xmm0, %xmm0
movss (%rsp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x24db
movq 0x6b67(%rip), %rbx      # 0x8ff0
leaq 0x3c20(%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 0x3c0b(%rip), %rsi      # 0x60c7
movl $0x15, %edx
jmp 0x2839
movss 0x3b36(%rip), %xmm0     # 0x6004
movss %xmm0, (%rsp)
movl $0x21, %ebx
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x21c0
testl %eax, %eax
je 0x24f2
callq 0x2b12
jmp 0x2a32
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 0x2d64
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 0x3b5f(%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 0x27b1
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 0x27b1
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 0x27b1
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 0x27b1
movl 0x30(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0xb8(%rsp), %rsi
cmpq 0xc0(%rsp), %rsi
je 0x2665
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb8(%rsp)
jmp 0x2677
leaq 0xb0(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x59ae
incq 0xe0(%rsp)
movq %r12, 0x88(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x5882
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2de8
movl %eax, %ebp
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x26cb
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2130
cmpl $0x1, %ebp
jne 0x25ad
movq 0x6915(%rip), %rdi      # 0x8ff0
leaq 0x3a06(%rip), %rsi      # 0x60e8
movl $0x25, %edx
callq 0x2140
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x68f3(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x3a03(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x68c9(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x39d9(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x689f(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x39af(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x6875(%rip), %rdi      # 0x8ff0
callq 0x2140
leaq 0x3985(%rip), %rsi      # 0x610c
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq 0x6855(%rip), %rdi      # 0x8ff0
leaq 0x396c(%rip), %rsi      # 0x610e
callq 0x2110
movl $0x32, %edi
callq 0x2150
leaq 0x1a0(%rsp), %rdi
callq 0x2040
cmpq $0x0, 0xe0(%rsp)
je 0x28dc
leaq 0xa8(%rsp), %rdi
callq 0x2e92
leaq 0xa8(%rsp), %rdi
callq 0x31a0
movzbl %r13b, %esi
andl $0x1, %esi
leaq 0xa8(%rsp), %rdi
movss (%rsp), %xmm0
callq 0x34e8
jmp 0x2922
movq 0x67e4(%rip), %r14      # 0x8ff0
leaq 0x386b(%rip), %rsi      # 0x607e
movl $0x16, %edx
movq %r14, %rdi
callq 0x2140
movq %r14, %rdi
movl %ebx, %esi
callq 0x21b0
movq %rax, %rbx
leaq 0x3861(%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 0x2a32
callq 0x2b12
jmp 0x2a30
movq 0x674d(%rip), %rbx      # 0x8fd0
leaq 0x38e1(%rip), %rsi      # 0x616b
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2140
movq 0x6892(%rip), %rsi      # 0x9130
movq 0x6893(%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 0x2a30
movq 0x670d(%rip), %rbx      # 0x8ff0
leaq 0x3840(%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 0x66db(%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 0x294b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2967
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2983
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x299f
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x29bc
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x29d9
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x29f6
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x2a13
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x2a30
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 0x2a8d
movq %rax, %rbx
jmp 0x2afd
jmp 0x2a7d
jmp 0x2a7d
jmp 0x2a7d
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x2a80
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2130
jmp 0x2a80
jmp 0x2a7d
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x2060
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2aa9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2ac5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2ae1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2afd
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2130
leaq 0xa8(%rsp), %rdi
callq 0x4416
movq %rbx, %rdi
callq 0x21d0