// File: millanek[P]Dsuite/Dmin.cpp
// Function: parseDminOptions(int, char**)
void parseDminOptions(int argc, char** argv) {
    bool die = false; string regionArgString; std::vector<string> regionArgs;
    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 'n': arg >> opt::runName; break;
            case 't': arg >> opt::treeFile; break;
            case 'j': arg >> opt::jkWindowSize; break;
            case 'k': arg >> opt::jkNum; break;
            case OPT_NO_F4: opt::fStats = false; break;
            case OPT_KS_TEST: opt::KStest = true; break;
            case 'c': opt::combine = false; break;
            case 'g': opt::useGenotypeProbabilities = true; break;
            case 'l': arg >> opt::providedNumLines; break;
            case 'o': arg >> opt::providedOutPrefix; break;
            case 'p': opt::poolSeq = true; arg >> opt::poolMinDepth; break;
            case 'r': arg >> regionArgString; regionArgs = split(regionArgString, ',');
                if (regionArgs.size() != 2) {
                    std::cerr << "the --region argument should be two numbers separated by a comma\n";
                    die = true;
                } else {
                    opt::regionStart = (int)stringToDouble(regionArgs[0]); opt::regionLength = (int)stringToDouble(regionArgs[1]);  break;
                }
            case 'h':
                std::cout << DMIN_USAGE_MESSAGE;
                exit(EXIT_SUCCESS);
        }
    }
    
    int maxNumArgs = 2; int minNumArgs = 2; // if (opt::poolSeq) { minNumArgs = 1; }
    
    if (opt::poolSeq && opt::useGenotypeProbabilities) {
        std::cerr << "Error: The -p and -g options are not compatible. Please check your command line. Exiting ....\n";
        die = true;
    }
    
    if (argc - optind < minNumArgs) {
        std::cerr << "missing arguments\n";
        die = true;
    }
    else if (argc - optind > maxNumArgs)
    {
        std::cerr << "too many arguments\n";
        die = true;
    }
    
    if (die) {
        std::cout << "\n" << DMIN_USAGE_MESSAGE;
        exit(EXIT_FAILURE);
    }
    
    // Parse the input filenames
    opt::vcfFile = argv[optind++];
    opt::setsFile = argv[optind++];
    
    if (opt::vcfFile == "stdin" && opt::providedNumLines <= 0) {
        std::cerr << "If you want to read the VCF via a pipe, you need to specify the number of lines in the input via the -l option\n";
        std::cerr << "See the example above\n";
        die = true;
    }
    
    if (die) {
        std::cout << "\n" << DMIN_USAGE_MESSAGE;
        exit(EXIT_FAILURE);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x87d0
leaq -0x50(%rbp), %rdi
callq 0x11d80
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0x897f2(%rip), %rdx     # 0xbf668
leaq 0x88763(%rip), %rcx     # 0xbe5e0
xorl %eax, %eax
movl %eax, %r8d
callq 0x8970
movb %al, -0x51(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x3624b
movq 0x890cb(%rip), %rax     # 0xbef68
cmpq $0x0, (%rax)
je 0x35eb6
movq 0x890be(%rip), %rax     # 0xbef68
movq (%rax), %rax
movq %rax, -0x278(%rbp)
jmp 0x35ec6
leaq 0x554ac(%rip), %rax     # 0x8b369
movq %rax, -0x278(%rbp)
jmp 0x35ec6
movq -0x278(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x1f9(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x8a60
movq -0x288(%rbp), %rsi
movq -0x280(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
callq 0x9a00
jmp 0x35f03
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
movl $0x8, %edx
callq 0x89a0
jmp 0x35f1d
leaq -0x1f8(%rbp), %rdi
callq 0x8c08
leaq -0x1f9(%rbp), %rdi
callq 0x8610
movsbl -0x51(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x290(%rbp)
subl $0x74, %eax
ja 0x36229
movq -0x290(%rbp), %rax
leaq 0x5329f(%rip), %rcx     # 0x891f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x208(%rbp)
movl %eax, -0x20c(%rbp)
jmp 0x35f94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x208(%rbp)
movl %eax, -0x20c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x8c08
leaq -0x1f9(%rbp), %rdi
callq 0x8610
jmp 0x36448
movb $0x1, -0x11(%rbp)
jmp 0x36229
leaq 0x89e3b(%rip), %rsi     # 0xbfdf0
leaq -0x1d8(%rbp), %rdi
callq 0x8730
jmp 0x35fc3
jmp 0x36229
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x208(%rbp)
movl %eax, -0x20c(%rbp)
jmp 0x3623a
leaq 0x89dea(%rip), %rsi     # 0xbfdd0
leaq -0x1d8(%rbp), %rdi
callq 0x8730
jmp 0x35ff4
jmp 0x36229
leaq 0x89e30(%rip), %rsi     # 0xbfe30
leaq -0x1d8(%rbp), %rdi
callq 0x8360
jmp 0x3600e
jmp 0x36229
leaq 0x89646(%rip), %rsi     # 0xbf660
leaq -0x1d8(%rbp), %rdi
callq 0x8360
jmp 0x36028
jmp 0x36229
movb $0x0, 0x89629(%rip)     # 0xbf65d
jmp 0x36229
movb $0x1, 0x89dfc(%rip)     # 0xbfe3c
jmp 0x36229
movb $0x0, 0x89610(%rip)     # 0xbf65c
jmp 0x36229
movb $0x1, 0x89ddc(%rip)     # 0xbfe34
jmp 0x36229
leaq 0x895f4(%rip), %rsi     # 0xbf658
leaq -0x1d8(%rbp), %rdi
callq 0x8360
jmp 0x36072
jmp 0x36229
leaq 0x89d92(%rip), %rsi     # 0xbfe10
leaq -0x1d8(%rbp), %rdi
callq 0x8730
jmp 0x3608c
jmp 0x36229
movb $0x1, 0x89d9d(%rip)     # 0xbfe35
leaq 0x89d99(%rip), %rsi     # 0xbfe38
leaq -0x1d8(%rbp), %rdi
callq 0x8360
jmp 0x360ad
jmp 0x36229
leaq -0x1d8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x8730
jmp 0x360c4
leaq -0x228(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movl $0x2c, %edx
callq 0xaef0
jmp 0x360db
leaq -0x50(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x20aa0
leaq -0x228(%rbp), %rdi
callq 0x10760
leaq -0x50(%rbp), %rdi
callq 0x10740
cmpq $0x2, %rax
je 0x36124
movq 0x88ee3(%rip), %rdi     # 0xbeff0
leaq 0x5365b(%rip), %rsi     # 0x8976f
callq 0x8590
jmp 0x3611b
movb $0x1, -0x11(%rbp)
jmp 0x3620b
xorl %eax, %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x10b10
movq %rax, %rsi
leaq -0x248(%rbp), %rdi
callq 0x8250
jmp 0x36142
leaq -0x248(%rbp), %rdi
callq 0xf4f0
movsd %xmm0, -0x298(%rbp)
jmp 0x36158
movsd -0x298(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x894e6(%rip)     # 0xbf650
leaq -0x248(%rbp), %rdi
callq 0x8c08
leaq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0x10b10
movq %rax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x8250
jmp 0x36195
leaq -0x268(%rbp), %rdi
callq 0xf4f0
movsd %xmm0, -0x2a0(%rbp)
jmp 0x361ab
movsd -0x2a0(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x89497(%rip)     # 0xbf654
leaq -0x268(%rbp), %rdi
callq 0x8c08
jmp 0x36229
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x208(%rbp)
movl %eax, -0x20c(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x8c08
jmp 0x3623a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x208(%rbp)
movl %eax, -0x20c(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x8c08
jmp 0x3623a
jmp 0x3620d
movq 0x8945c(%rip), %rsi     # 0xbf670
movq 0x88d8d(%rip), %rdi     # 0xbefa8
callq 0x8590
jmp 0x36222
xorl %edi, %edi
callq 0x86e0
leaq -0x1d8(%rbp), %rdi
callq 0x8290
jmp 0x35e68
leaq -0x1d8(%rbp), %rdi
callq 0x8290
jmp 0x36448
movl $0x2, -0x26c(%rbp)
movl $0x2, -0x270(%rbp)
testb $0x1, 0x89bcf(%rip)     # 0xbfe35
je 0x362a3
testb $0x1, 0x89bc5(%rip)     # 0xbfe34
je 0x362a3
movq 0x88d78(%rip), %rdi     # 0xbeff0
leaq 0x53532(%rip), %rsi     # 0x897b1
callq 0x8590
jmp 0x36286
movb $0x1, -0x11(%rbp)
jmp 0x362a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x208(%rbp)
movl %eax, -0x20c(%rbp)
jmp 0x36448
movl -0x4(%rbp), %eax
movq 0x88d03(%rip), %rcx     # 0xbefb0
subl (%rcx), %eax
cmpl -0x270(%rbp), %eax
jge 0x362d2
movq 0x88d32(%rip), %rdi     # 0xbeff0
leaq 0x5277d(%rip), %rsi     # 0x88a42
callq 0x8590
jmp 0x362cc
movb $0x1, -0x11(%rbp)
jmp 0x36301
movl -0x4(%rbp), %eax
movq 0x88cd4(%rip), %rcx     # 0xbefb0
subl (%rcx), %eax
cmpl -0x26c(%rbp), %eax
jle 0x362ff
movq 0x88d03(%rip), %rdi     # 0xbeff0
leaq 0x52761(%rip), %rsi     # 0x88a55
callq 0x8590
jmp 0x362fb
movb $0x1, -0x11(%rbp)
jmp 0x36301
testb $0x1, -0x11(%rbp)
je 0x36342
movq 0x88c9a(%rip), %rdi     # 0xbefa8
leaq 0x52125(%rip), %rsi     # 0x8843a
callq 0x8590
movq %rax, -0x2a8(%rbp)
jmp 0x36323
movq -0x2a8(%rbp), %rdi
movq 0x8933f(%rip), %rsi     # 0xbf670
callq 0x8590
jmp 0x36338
movl $0x1, %edi
callq 0x86e0
movq -0x10(%rbp), %rax
movq 0x88c63(%rip), %rdx     # 0xbefb0
movslq (%rdx), %rcx
movl %ecx, %esi
incl %esi
movl %esi, (%rdx)
movq (%rax,%rcx,8), %rsi
leaq 0x89a2f(%rip), %rdi     # 0xbfd90
callq 0x87c0
jmp 0x36368
movq -0x10(%rbp), %rax
movq 0x88c3d(%rip), %rdx     # 0xbefb0
movslq (%rdx), %rcx
movl %ecx, %esi
incl %esi
movl %esi, (%rdx)
movq (%rax,%rcx,8), %rsi
leaq 0x89a29(%rip), %rdi     # 0xbfdb0
callq 0x87c0
jmp 0x3638e
leaq 0x899fb(%rip), %rdi     # 0xbfd90
leaq 0x53074(%rip), %rsi     # 0x89410
callq 0x9ab0
movb %al, -0x2a9(%rbp)
jmp 0x363a9
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0x363b5
jmp 0x363ec
cmpl $0x0, 0x8929c(%rip)     # 0xbf658
jg 0x363ec
movq 0x88c2b(%rip), %rdi     # 0xbeff0
leaq 0x53444(%rip), %rsi     # 0x89810
callq 0x8590
jmp 0x363d3
movq 0x88c16(%rip), %rdi     # 0xbeff0
leaq 0x5349f(%rip), %rsi     # 0x89880
callq 0x8590
jmp 0x363e8
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
je 0x3642d
movq 0x88baf(%rip), %rdi     # 0xbefa8
leaq 0x5203a(%rip), %rsi     # 0x8843a
callq 0x8590
movq %rax, -0x2b8(%rbp)
jmp 0x3640e
movq -0x2b8(%rbp), %rdi
movq 0x89254(%rip), %rsi     # 0xbf670
callq 0x8590
jmp 0x36423
movl $0x1, %edi
callq 0x86e0
leaq -0x50(%rbp), %rdi
callq 0x10760
leaq -0x38(%rbp), %rdi
callq 0x8c08
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x10760
leaq -0x38(%rbp), %rdi
callq 0x8c08
movq -0x208(%rbp), %rdi
callq 0x8a50
nopw %cs:(%rax,%rax)