// File: millanek[P]evo/process_vcf_stats.cpp
// Function: parseStatsOptions(int, char**)
void parseStatsOptions(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 OPT_POP: arg >> opt::populationsFile; break;
            case OPT_INDIV: arg >> opt::sampleNameFile; break;
            case OPT_DIFF_MATRIX: opt::bDiffs = true; break;    
            case OPT_DOUBLETON: opt::bDoubleton = true; break;
            case OPT_HETS: opt::countHets = true; break;
            case OPT_DIFF_MATRIX_H1: opt::bDiffH1 = true; break;
            case OPT_DIFF_MATRIX_ALLH: opt::bDiffAllH = true; break;
            case OPT_BLOCK_BOOTSTRAP: arg >> opt::bootstrapBlockSize; opt::bDoBootstrap = true; break;
            case OPT_PRIVATE_VARS: opt::countPrivateVars = true; break;
            case OPT_ACC_GEN_BED: arg >> opt::accesibleGenBedFile; break;
            case OPT_NUM_ACCESSIBLE: arg >> opt::numAccessibleBP; break;
            case OPT_ACC_GEN_BED_WINDOW: arg >> opt::accessibleGenBedWindow; break;
            case 'h':
                std::cout << STATS_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::countPrivateVars && opt::populationsFile == "") {
        std::cerr << "You need to supply a file defining populations to count private fixed variants\n";
        die = true;
    }
    
    if (!opt::bDiffs && !opt::bDoubleton && !opt::countHets && !opt::countPrivateVars && opt::accesibleGenBedFile.empty()) {
        std::cerr << "Which statistics should the program calculate?\n";
        die = true;
    }
    
    if (die) {
        std::cout << "\n" << STATS_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 0x1049b4(%rip), %rdx    # 0x1997a8
leaq 0x102405(%rip), %rcx    # 0x197200
xorl %eax, %eax
movl %eax, %r8d
callq 0xaa40
movb %al, -0x12(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x95058
movq 0x104175(%rip), %rax    # 0x198f90
cmpq $0x0, (%rax)
je 0x94e34
movq 0x104168(%rip), %rax    # 0x198f90
movq (%rax), %rax
movq %rax, -0x1d8(%rbp)
jmp 0x94e44
leaq 0xa10a4(%rip), %rax     # 0x135edf
movq %rax, -0x1d8(%rbp)
jmp 0x94e44
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 0x94e81
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
movl $0x8, %edx
callq 0xaaa0
jmp 0x94e9b
leaq -0x1b8(%rbp), %rdi
callq 0xac88
leaq -0x1b9(%rbp), %rdi
callq 0xa640
movsbl -0x12(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x1f0(%rbp)
subl $0x68, %eax
ja 0x95047
movq -0x1f0(%rbp), %rax
leaq 0xa76f5(%rip), %rcx     # 0x13c5cc
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 0x94f12
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 0x9519b
movb $0x1, -0x11(%rbp)
jmp 0x95047
leaq 0x1057f5(%rip), %rsi    # 0x19a728
leaq -0x198(%rbp), %rdi
callq 0xa750
jmp 0x94f41
jmp 0x95047
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x198(%rbp), %rdi
callq 0xa290
jmp 0x9519b
leaq 0x105798(%rip), %rsi    # 0x19a708
leaq -0x198(%rbp), %rdi
callq 0xa750
jmp 0x94f7e
jmp 0x95047
movb $0x1, 0x1057e3(%rip)    # 0x19a76d
jmp 0x95047
movb $0x1, 0x1057d3(%rip)    # 0x19a769
jmp 0x95047
movb $0x1, 0x1057c6(%rip)    # 0x19a768
jmp 0x95047
movb $0x1, 0x1057bd(%rip)    # 0x19a76b
jmp 0x95047
movb $0x1, 0x1057b2(%rip)    # 0x19a76c
jmp 0x95047
leaq 0x1047d6(%rip), %rsi    # 0x19979c
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0x94fd4
movb $0x1, 0x105793(%rip)    # 0x19a76e
jmp 0x95047
movb $0x1, 0x105786(%rip)    # 0x19a76a
jmp 0x95047
leaq 0x10575b(%rip), %rsi    # 0x19a748
leaq -0x198(%rbp), %rdi
callq 0xa750
jmp 0x94ffb
jmp 0x95047
leaq 0x10479c(%rip), %rsi    # 0x1997a0
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0x95012
jmp 0x95047
leaq 0x10477d(%rip), %rsi    # 0x199798
leaq -0x198(%rbp), %rdi
callq 0xa370
jmp 0x95029
jmp 0x95047
movq 0x10477e(%rip), %rsi    # 0x1997b0
movq 0x103f7f(%rip), %rdi    # 0x198fb8
callq 0xa5c0
jmp 0x95040
xorl %edi, %edi
callq 0xa700
leaq -0x198(%rbp), %rdi
callq 0xa290
jmp 0x94de6
movl -0x4(%rbp), %eax
movq 0x103f5e(%rip), %rcx    # 0x198fc0
subl (%rcx), %eax
cmpl $0x1, %eax
jge 0x95082
movq 0x103f80(%rip), %rdi    # 0x198ff0
leaq 0x9d3b3(%rip), %rsi     # 0x13242a
callq 0xa5c0
movb $0x1, -0x11(%rbp)
jmp 0x950ac
movl -0x4(%rbp), %eax
movq 0x103f34(%rip), %rcx    # 0x198fc0
subl (%rcx), %eax
cmpl $0x1, %eax
jle 0x950aa
movq 0x103f56(%rip), %rdi    # 0x198ff0
leaq 0x9d39c(%rip), %rsi     # 0x13243d
callq 0xa5c0
movb $0x1, -0x11(%rbp)
jmp 0x950ac
testb $0x1, 0x1056b7(%rip)    # 0x19a76a
je 0x950e5
leaq 0x10566c(%rip), %rdi    # 0x19a728
leaq 0xa0e1c(%rip), %rsi     # 0x135edf
callq 0x2d770
testb $0x1, %al
jne 0x950ce
jmp 0x950e5
movq 0x103f1b(%rip), %rdi    # 0x198ff0
leaq 0xa7891(%rip), %rsi     # 0x13c96d
callq 0xa5c0
movb $0x1, -0x11(%rbp)
testb $0x1, 0x105681(%rip)    # 0x19a76d
jne 0x95132
testb $0x1, 0x105674(%rip)    # 0x19a769
jne 0x95132
testb $0x1, 0x10566a(%rip)    # 0x19a768
jne 0x95132
testb $0x1, 0x105663(%rip)    # 0x19a76a
jne 0x95132
leaq 0x105638(%rip), %rdi    # 0x19a748
callq 0xaa70
testb $0x1, %al
jne 0x9511b
jmp 0x95132
movq 0x103ece(%rip), %rdi    # 0x198ff0
leaq 0xa7894(%rip), %rsi     # 0x13c9bd
callq 0xa5c0
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
je 0x95164
movq 0x103e79(%rip), %rdi    # 0x198fb8
leaq 0x9a747(%rip), %rsi     # 0x12f88d
callq 0xa5c0
movq %rax, %rdi
movq 0x10465b(%rip), %rsi    # 0x1997b0
callq 0xa5c0
movl $0x1, %edi
callq 0xa700
movq -0x10(%rbp), %rax
movq 0x103e51(%rip), %rcx    # 0x198fc0
movl (%rcx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movq 0x103e43(%rip), %rdx    # 0x198fc0
movl %esi, (%rdx)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x10555b(%rip), %rdi    # 0x19a6e8
callq 0xa810
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x1c8(%rbp), %rdi
callq 0xab50
nopw (%rax,%rax)