// File: millanek[P]evo/process_vcf_get_sequences.cpp
// Function: parseGetSeqOptions(int, char**)
void parseGetSeqOptions(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 '?': die = true; break;
            case 's': arg >> opt::sampleNameFile; break;
            case 'H': arg >> opt::hetTreatment; break;
            case OPT_LDHAT: opt::bLDhat = true; break;
            case OPT_BY_SCAFFOLD: opt::bByScaffold = true; break;
            case OPT_SPLIT: arg >> opt::splitNum; break;
            case OPT_WG: opt::bWholeGenome = true; break;
            case OPT_PN: arg >> opt::outgroupFile; break;
            case OPT_ACC_GEN_BED: arg >> opt::accesibleGenBedFile; break;
            case OPT_SVD: opt::bSVD = true; break;
            case OPT_SVD_BOOT: arg >> opt::bootSVDnameRoot; break;
            case OPT_METH: opt::methylome = true; break;
            case 'h':
                std::cout << GETSEQ_USAGE_MESSAGE;
                exit(EXIT_SUCCESS);
        }
    }
    if (argc - optind < 1) {
        std::cerr << "missing arguments\n";
        die = true;
    } 
    else if (argc - optind > 2)
    {
        std::cerr << "too many arguments\n";
        die = true;
    }
    
    if (opt::hetTreatment != 'r' && opt::hetTreatment != 'p' && opt::hetTreatment != 'b' && opt::hetTreatment != 'i') {
        std::cerr << "The -H (--het-treatment) option can only have the values 'r', 'p', 'b', or 'i'\n";
        die = true;
    }
    
    if (opt::splitNum > 0 && opt::bByScaffold) {
        std::cerr << "The option --split is incompatible with --by-scaffold\n";
        die = true;
    }
    
    if (opt::bWholeGenome && (opt::splitNum > 0 || opt::bByScaffold)) {
        std::cerr << "The option --whole-genome is incompatible with --by-scaffold and --split\n";
        die = true;
    }
    
    if (opt::splitNum < 0) {
        std::cerr << "The argument to --split cannot be negative\n";
        die = true;
    }
    
    if (die) {
        std::cout << "\n" << GETSEQ_USAGE_MESSAGE;
        exit(EXIT_FAILURE);
    }
    
    // Parse the input filenames
    opt::vcfFile = argv[optind++];
    //std::cerr << "argc - optind " << argc - optind << std::endl;
    if( argc - optind == 1) {
        opt::genomeFile = 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 0xeea84(%rip), %rdx     # 0x199858
leaq 0xeca25(%rip), %rcx     # 0x197800
xorl %eax, %eax
movl %eax, %r8d
callq 0xaa40
movb %al, -0x12(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0xab01f
movq 0xee195(%rip), %rax     # 0x198f90
cmpq $0x0, (%rax)
je 0xaae14
movq 0xee188(%rip), %rax     # 0x198f90
movq (%rax), %rax
movq %rax, -0x1d8(%rbp)
jmp 0xaae24
leaq 0x8b0c4(%rip), %rax     # 0x135edf
movq %rax, -0x1d8(%rbp)
jmp 0xaae24
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 0xaae61
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
movl $0x8, %edx
callq 0xaaa0
jmp 0xaae7b
leaq -0x1b8(%rbp), %rdi
callq 0xac88
leaq -0x1b9(%rbp), %rdi
callq 0xa640
movsbl -0x12(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x1f0(%rbp)
subl $0x73, %eax
ja 0xab00e
movq -0x1f0(%rbp), %rax
leaq 0x94949(%rip), %rcx     # 0x13f800
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 0xaaef2
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 0xab1dd
movb $0x1, -0x11(%rbp)
jmp 0xab00e
leaq 0xef9ed(%rip), %rsi     # 0x19a900
leaq -0x198(%rbp), %rdi
callq 0xa750
jmp 0xaaf21
jmp 0xab00e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x198(%rbp), %rdi
callq 0xa290
jmp 0xab1dd
leaq 0xee900(%rip), %rsi     # 0x199850
leaq -0x198(%rbp), %rdi
callq 0xa7c0
jmp 0xaaf5e
jmp 0xab00e
movb $0x1, 0xef9fc(%rip)     # 0x19a966
jmp 0xab00e
movb $0x1, 0xef9f1(%rip)     # 0x19a967
jmp 0xab00e
leaq 0xef9de(%rip), %rsi     # 0x19a960
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0xaaf90
jmp 0xab00e
movb $0x1, 0xef9cb(%rip)     # 0x19a964
jmp 0xab00e
leaq 0xef93e(%rip), %rsi     # 0x19a8e0
leaq -0x198(%rbp), %rdi
callq 0xa750
jmp 0xaafb0
jmp 0xab00e
leaq 0xef987(%rip), %rsi     # 0x19a940
leaq -0x198(%rbp), %rdi
callq 0xa750
jmp 0xaafc7
jmp 0xab00e
movb $0x1, 0xef995(%rip)     # 0x19a965
jmp 0xab00e
leaq 0xef947(%rip), %rsi     # 0x19a920
leaq -0x198(%rbp), %rdi
callq 0xa750
jmp 0xaafe7
jmp 0xab00e
movb $0x1, 0xef978(%rip)     # 0x19a968
jmp 0xab00e
movq 0xee867(%rip), %rsi     # 0x199860
movq 0xedfb8(%rip), %rdi     # 0x198fb8
callq 0xa5c0
jmp 0xab007
xorl %edi, %edi
callq 0xa700
leaq -0x198(%rbp), %rdi
callq 0xa290
jmp 0xaadc6
movl -0x4(%rbp), %eax
movq 0xedf97(%rip), %rcx     # 0x198fc0
subl (%rcx), %eax
cmpl $0x1, %eax
jge 0xab049
movq 0xedfb9(%rip), %rdi     # 0x198ff0
leaq 0x873ec(%rip), %rsi     # 0x13242a
callq 0xa5c0
movb $0x1, -0x11(%rbp)
jmp 0xab073
movl -0x4(%rbp), %eax
movq 0xedf6d(%rip), %rcx     # 0x198fc0
subl (%rcx), %eax
cmpl $0x2, %eax
jle 0xab071
movq 0xedf8f(%rip), %rdi     # 0x198ff0
leaq 0x873d5(%rip), %rsi     # 0x13243d
callq 0xa5c0
movb $0x1, -0x11(%rbp)
jmp 0xab073
movsbl 0xee7d6(%rip), %eax     # 0x199850
cmpl $0x72, %eax
je 0xab0ba
movsbl 0xee7ca(%rip), %eax     # 0x199850
cmpl $0x70, %eax
je 0xab0ba
movsbl 0xee7be(%rip), %eax     # 0x199850
cmpl $0x62, %eax
je 0xab0ba
movsbl 0xee7b2(%rip), %eax     # 0x199850
cmpl $0x69, %eax
je 0xab0ba
movq 0xedf46(%rip), %rdi     # 0x198ff0
leaq 0x94ce1(%rip), %rsi     # 0x13fd92
callq 0xa5c0
movb $0x1, -0x11(%rbp)
cmpl $0x0, 0xef89f(%rip)     # 0x19a960
jle 0xab0e3
testb $0x1, 0xef89d(%rip)     # 0x19a967
je 0xab0e3
movq 0xedf1d(%rip), %rdi     # 0x198ff0
leaq 0x94d08(%rip), %rsi     # 0x13fde2
callq 0xa5c0
movb $0x1, -0x11(%rbp)
testb $0x1, 0xef87a(%rip)     # 0x19a964
je 0xab115
cmpl $0x0, 0xef86d(%rip)     # 0x19a960
jg 0xab0fe
testb $0x1, 0xef86b(%rip)     # 0x19a967
je 0xab115
movq 0xedeeb(%rip), %rdi     # 0x198ff0
leaq 0x94d0d(%rip), %rsi     # 0x13fe19
callq 0xa5c0
movb $0x1, -0x11(%rbp)
cmpl $0x0, 0xef844(%rip)     # 0x19a960
jge 0xab135
movq 0xedecb(%rip), %rdi     # 0x198ff0
leaq 0x94d37(%rip), %rsi     # 0x13fe63
callq 0xa5c0
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
je 0xab167
movq 0xede76(%rip), %rdi     # 0x198fb8
leaq 0x84744(%rip), %rsi     # 0x12f88d
callq 0xa5c0
movq %rax, %rdi
movq 0xee708(%rip), %rsi     # 0x199860
callq 0xa5c0
movl $0x1, %edi
callq 0xa700
movq -0x10(%rbp), %rax
movq 0xede4e(%rip), %rcx     # 0x198fc0
movl (%rcx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movq 0xede40(%rip), %rdx     # 0x198fc0
movl %esi, (%rdx)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xef710(%rip), %rdi     # 0x19a8a0
callq 0xa810
movl -0x4(%rbp), %eax
movq 0xede21(%rip), %rcx     # 0x198fc0
subl (%rcx), %eax
cmpl $0x1, %eax
jne 0xab1d4
movq -0x10(%rbp), %rax
movq 0xede0f(%rip), %rcx     # 0x198fc0
movl (%rcx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movq 0xede01(%rip), %rdx     # 0x198fc0
movl %esi, (%rdx)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xef6f1(%rip), %rdi     # 0x19a8c0
callq 0xa810
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x1c8(%rbp), %rdi
callq 0xab50
nopl (%rax)