// File: millanek[P]evo/process_vcf_filter.cpp
// Function: parseFilterOptions(int, char**)
void parseFilterOptions(int argc, char** argv) {
    
    bool die = false;
    for (char c; (c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1;)
    {
        std::istringstream arg(optarg != NULL ? optarg : "");
        switch (c) 
        {
            case 'd': arg >> opt::max_overall_depth; break;
            case 'm': arg >> opt::min_overall_depth; break;
            case 'c': arg >> opt::min_copies; break;
            case 's': arg >> opt::min_depth_in_any_individual; break;
            case '?': die = true; break;
            case OPT_TRIALLELIC: opt::bBiallelicFilter = false; break;
            case OPT_ALLOW_MISSING_GENOTYPES: opt::bAllowMissingGenotpyes = true; break;
            case OPT_MAX_NUM_HET: arg >> opt::max_het_indiv; break;
            case OPT_MQSB: arg >> opt::min_MQSB; break;
            case OPT_FS: arg >> opt::max_FS; break;
            case OPT_STATS: opt::bStats = true; break;
            case OPT_SUBS: arg >> opt::subsample; break;
            case OPT_MIN_F: arg >> opt::min_F; break;
            case OPT_OVERALL_Q: arg >> opt::min_overall_quality; break;
            case OPT_HELP:
                std::cout << FILTER_USAGE_MESSAGE;
                exit(EXIT_SUCCESS);
        }
    }
    if (argc - optind < 1) {
        std::cerr << "missing arguments\n";
        die = true;
    } 
    else if (argc - optind > 1) 
    {
        std::cerr << "too many arguments\n";
        die = true;
    }
    
    if (opt::min_F < -1 || opt::min_F > 1) {
        std::cerr << "The values of the inbreeding coefficient F range between -1 and 1 (negative values are likely variant calling errors)\n";
        die = true;
    }
    
    if (opt::min_MQSB < 0 || opt::min_MQSB > 1) {
        std::cerr << "The MQSB p-values range between 0 and 1 (try a value like 0.001)\n";
        die = true;
    }
    
    
    
    
    if (die) {
        std::cout << "\n" << FILTER_USAGE_MESSAGE;
        exit(EXIT_FAILURE);
    }
    
    // Parse the input filenames
    opt::vcfFile = argv[optind++];
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0xf8aac(%rip), %rdx     # 0x1997f0
leaq 0xf6675(%rip), %rcx     # 0x1973c0
xorl %eax, %eax
movl %eax, %r8d
callq 0xaa40
movb %al, -0x12(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0xa0fe7
movq 0xf8225(%rip), %rax     # 0x198f90
cmpq $0x0, (%rax)
je 0xa0d84
movq 0xf8218(%rip), %rax     # 0x198f90
movq (%rax), %rax
movq %rax, -0x1d8(%rbp)
jmp 0xa0d94
leaq 0x95154(%rip), %rax     # 0x135edf
movq %rax, -0x1d8(%rbp)
jmp 0xa0d94
movq -0x1d8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x1b9(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0xab60
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rdx
leaq -0x1b8(%rbp), %rdi
callq 0x2d6c0
jmp 0xa0dd1
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
movl $0x8, %edx
callq 0xaaa0
jmp 0xa0deb
leaq -0x1b8(%rbp), %rdi
callq 0xac88
leaq -0x1b9(%rbp), %rdi
callq 0xa640
movsbl -0x12(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x1f0(%rbp)
subl $0x72, %eax
ja 0xa0fd6
movq -0x1f0(%rbp), %rax
leaq 0x9c95f(%rip), %rcx     # 0x13d788
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0xa0e64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0xac88
leaq -0x1b9(%rbp), %rdi
callq 0xa640
jmp 0xa111d
leaq 0xf8948(%rip), %rsi     # 0x1997c4
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0xa0e8a
jmp 0xa0fd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x198(%rbp), %rdi
callq 0xa290
jmp 0xa111d
leaq 0xf98e3(%rip), %rsi     # 0x19a79c
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0xa0ec7
jmp 0xa0fd6
leaq 0xf88f5(%rip), %rsi     # 0x1997c8
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0xa0ee1
jmp 0xa0fd6
leaq 0xf98b3(%rip), %rsi     # 0x19a7a0
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0xa0efb
jmp 0xa0fd6
movb $0x1, -0x11(%rbp)
jmp 0xa0fd6
movb $0x0, 0xf88c8(%rip)     # 0x1997d8
jmp 0xa0fd6
movb $0x1, 0xf9888(%rip)     # 0x19a7a4
jmp 0xa0fd6
leaq 0xf88a4(%rip), %rsi     # 0x1997cc
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0xa0f36
jmp 0xa0fd6
leaq 0xf9866(%rip), %rsi     # 0x19a7a8
leaq -0x198(%rbp), %rdi
callq 0xa4b0
jmp 0xa0f50
jmp 0xa0fd6
leaq 0xf8884(%rip), %rsi     # 0x1997e0
leaq -0x198(%rbp), %rdi
callq 0xa4b0
jmp 0xa0f6a
jmp 0xa0fd6
movb $0x1, 0xf9825(%rip)     # 0x19a798
jmp 0xa0fd6
leaq 0xf8854(%rip), %rsi     # 0x1997d0
leaq -0x198(%rbp), %rdi
callq 0xa4b0
jmp 0xa0f8a
jmp 0xa0fd6
leaq 0xf8855(%rip), %rsi     # 0x1997e8
leaq -0x198(%rbp), %rdi
callq 0xa4b0
jmp 0xa0fa1
jmp 0xa0fd6
leaq 0xf8816(%rip), %rsi     # 0x1997c0
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0xa0fb8
jmp 0xa0fd6
movq 0xf8837(%rip), %rsi     # 0x1997f8
movq 0xf7ff0(%rip), %rdi     # 0x198fb8
callq 0xa5c0
jmp 0xa0fcf
xorl %edi, %edi
callq 0xa700
leaq -0x198(%rbp), %rdi
callq 0xa290
jmp 0xa0d36
movl -0x4(%rbp), %eax
movq 0xf7fcf(%rip), %rcx     # 0x198fc0
subl (%rcx), %eax
cmpl $0x1, %eax
jge 0xa1011
movq 0xf7ff1(%rip), %rdi     # 0x198ff0
leaq 0x91424(%rip), %rsi     # 0x13242a
callq 0xa5c0
movb $0x1, -0x11(%rbp)
jmp 0xa103b
movl -0x4(%rbp), %eax
movq 0xf7fa5(%rip), %rcx     # 0x198fc0
subl (%rcx), %eax
cmpl $0x1, %eax
jle 0xa1039
movq 0xf7fc7(%rip), %rdi     # 0x198ff0
leaq 0x9140d(%rip), %rsi     # 0x13243d
callq 0xa5c0
movb $0x1, -0x11(%rbp)
jmp 0xa103b
movsd 0x9267d(%rip), %xmm0    # 0x1336c0
ucomisd 0xf879d(%rip), %xmm0    # 0x1997e8
ja 0xa1063
movsd 0xf8793(%rip), %xmm0    # 0x1997e8
movsd 0x9125b(%rip), %xmm1    # 0x1322b8
ucomisd %xmm1, %xmm0
jbe 0xa107a
movq 0xf7f86(%rip), %rdi     # 0x198ff0
leaq 0x9cc57(%rip), %rsi     # 0x13dcc8
callq 0xa5c0
movb $0x1, -0x11(%rbp)
xorps %xmm0, %xmm0
ucomisd 0xf9723(%rip), %xmm0    # 0x19a7a8
ja 0xa109d
movsd 0xf9719(%rip), %xmm0    # 0x19a7a8
movsd 0x91221(%rip), %xmm1    # 0x1322b8
ucomisd %xmm1, %xmm0
jbe 0xa10b4
movq 0xf7f4c(%rip), %rdi     # 0x198ff0
leaq 0x9cc94(%rip), %rsi     # 0x13dd3f
callq 0xa5c0
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
je 0xa10e6
movq 0xf7ef7(%rip), %rdi     # 0x198fb8
leaq 0x8e7c5(%rip), %rsi     # 0x12f88d
callq 0xa5c0
movq %rax, %rdi
movq 0xf8721(%rip), %rsi     # 0x1997f8
callq 0xa5c0
movl $0x1, %edi
callq 0xa700
movq -0x10(%rbp), %rax
movq 0xf7ecf(%rip), %rcx     # 0x198fc0
movl (%rcx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movq 0xf7ec1(%rip), %rdx     # 0x198fc0
movl %esi, (%rdx)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xf9669(%rip), %rdi     # 0x19a778
callq 0xa810
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x1c8(%rbp), %rdi
callq 0xab50
nopl (%rax)