// File: millanek[P]evo/process_vcf_fst.cpp
// Function: parseFstOptions(int, char**)
void parseFstOptions(int argc, char** argv) {
    bool die = false;
    std::vector<string> windowSizeStep;
    for (char c; (c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1;)
    {
        std::istringstream arg(optarg != NULL ? optarg : "");
        switch (c)
        {
            case OPT_VCF: arg >> opt::vcfFile; break;
            case OPT_SETS: arg >> opt::sampleSets; break;
            case OPT_ANC_SETS: arg >> opt::ancSets; break;
            case 'w':
                windowSizeStep = split(arg.str(), ',');
                opt::windowSize = atoi(windowSizeStep[0].c_str());
                opt::windowStep = atoi(windowSizeStep[1].c_str());
                break;
            case OPT_REG_ABOVE: arg >> opt::regAbove; break;
            case OPT_ANNOT: arg >> opt::annotFile; break;
            case OPT_MS: arg >> opt::msFile; break;
            case OPT_EIGEN: arg >> opt::eigensoftFile; break;
            case OPT_MS_SET1_SIZE: arg >> opt::msSet1Size; break;
            case OPT_MS_SET1_SAMPLE: arg >> opt::msSet1FstSample; break;
            case OPT_MS_SET2_SIZE: arg >> opt::msSet2Size; break;
            case OPT_MS_SET2_SAMPLE: arg >> opt::msSet2FstSample; break;
            case OPT_MS_PVALS: arg >> opt::msPvalCutoff; break;
            case OPT_ACC_GEN_BED: arg >> opt::accesibleGenBedFile; break;
            case OPT_PHYS_WINDOW_SIZE: arg >> opt::physicalWindowSize; break;
            case 's': arg >> opt::sampleNameFile; break;
            case 'n': arg >> opt::runName; break;
            case '?': die = true; break;
            case 'h': std::cout << FST_USAGE_MESSAGE;
                exit(EXIT_SUCCESS);
        }
    }
    if (argc - optind > 0)
    {
        std::cerr << "too many arguments\n";
        die = true;
    }
    
    if ((!opt::vcfFile.empty() && opt::sampleSets.empty()) || (opt::vcfFile.empty() && !opt::sampleSets.empty())) {
        std::cerr << "To calculate Fst statistics from a vcf, you need to use both the --vcf and the --sets options\n";
        die = true;
    }
    
    if ((!opt::msFile.empty() && (opt::msSet1Size == 0 || opt::msSet2Size == 0)) || (opt::msFile.empty() && (opt::msSet1Size != 0 || opt::msSet2Size != 0))) {
        std::cerr << "To calculate Fst statistics from ms output, you need to use the --ms and the --set1msSimSize and --set2msSimSize  options together\n";
        die = true;
    }
    
    if (opt::msPvalCutoff > 1) {
        std::cerr << "The pvalue cutoff cannot be more than one...\n";
        die = true;
    }
    
    if (opt::regAbove > 0 && opt::windowSize == 0) {
        std::cerr << "The window size (-w option) needs to be set for --regions-above option to work (you can set -w 1,1 for per variant Fst)\n";
        die = true;
    }
    
    
    if (die) {
        std::cout << "\n" << FST_USAGE_MESSAGE;
        exit(EXIT_FAILURE);
    }

    
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x48da0
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0xb71e3(%rip), %rdx     # 0x199940
leaq 0xb56fc(%rip), %rcx     # 0x197e60
xorl %eax, %eax
movl %eax, %r8d
callq 0xaa40
movb %al, -0x31(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0xe2b41
movq 0xb680c(%rip), %rax     # 0x198f90
cmpq $0x0, (%rax)
je 0xe279d
movq 0xb67ff(%rip), %rax     # 0x198f90
movq (%rax), %rax
movq %rax, -0x230(%rbp)
jmp 0xe27ad
leaq 0x5373b(%rip), %rax     # 0x135edf
movq %rax, -0x230(%rbp)
jmp 0xe27ad
movq -0x230(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x1d9(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0xab60
movq -0x240(%rbp), %rsi
movq -0x238(%rbp), %rdx
leaq -0x1d8(%rbp), %rdi
callq 0x2d6c0
jmp 0xe27ea
leaq -0x1b8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
movl $0x8, %edx
callq 0xaaa0
jmp 0xe2804
leaq -0x1d8(%rbp), %rdi
callq 0xac88
leaq -0x1d9(%rbp), %rdi
callq 0xa640
movsbl -0x31(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x248(%rbp)
subl $0x75, %eax
ja 0xe2b1f
movq -0x248(%rbp), %rax
leaq 0x644fd(%rip), %rcx     # 0x146d40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0xe287e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0xac88
leaq -0x1d9(%rbp), %rdi
callq 0xa640
jmp 0xe2cf3
leaq 0xb85f2(%rip), %rsi     # 0x19ae88
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe28a4
jmp 0xe2b1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0xe2b30
leaq 0xb85e1(%rip), %rsi     # 0x19aea8
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe28d5
jmp 0xe2b1f
leaq 0xb85e7(%rip), %rsi     # 0x19aec8
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe28ef
jmp 0xe2b1f
leaq -0x228(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xa900
jmp 0xe2909
leaq -0x208(%rbp), %rdi
leaq -0x228(%rbp), %rsi
movl $0x2c, %edx
callq 0x7bbe0
jmp 0xe2923
leaq -0x30(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x50c30
leaq -0x208(%rbp), %rdi
callq 0x3dfa0
leaq -0x228(%rbp), %rdi
callq 0xac88
leaq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movl %eax, 0xb863a(%rip)     # 0x19afa8
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movl %eax, 0xb861a(%rip)     # 0x19afac
jmp 0xe2b1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
leaq -0x228(%rbp), %rdi
callq 0xac88
jmp 0xe2b30
leaq 0xb85ef(%rip), %rsi     # 0x19afb0
leaq -0x1b8(%rbp), %rdi
callq 0xa4b0
jmp 0xe29cf
jmp 0xe2b1f
leaq 0xb854d(%rip), %rsi     # 0x19af28
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe29e9
jmp 0xe2b1f
leaq 0xb8573(%rip), %rsi     # 0x19af68
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe2a03
jmp 0xe2b1f
leaq 0xb8539(%rip), %rsi     # 0x19af48
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe2a1d
jmp 0xe2b1f
leaq 0xb859b(%rip), %rsi     # 0x19afc4
leaq -0x1b8(%rbp), %rdi
callq 0xa370
jmp 0xe2a37
jmp 0xe2b1f
leaq 0xb857d(%rip), %rsi     # 0x19afc0
leaq -0x1b8(%rbp), %rdi
callq 0xa370
jmp 0xe2a51
jmp 0xe2b1f
leaq 0xb856f(%rip), %rsi     # 0x19afcc
leaq -0x1b8(%rbp), %rdi
callq 0xa370
jmp 0xe2a6b
jmp 0xe2b1f
leaq 0xb8551(%rip), %rsi     # 0x19afc8
leaq -0x1b8(%rbp), %rdi
callq 0xa370
jmp 0xe2a85
jmp 0xe2b1f
leaq 0xb8527(%rip), %rsi     # 0x19afb8
leaq -0x1b8(%rbp), %rdi
callq 0xa4b0
jmp 0xe2a9f
jmp 0xe2b1f
leaq 0xb8460(%rip), %rsi     # 0x19af08
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe2ab6
jmp 0xe2b1f
leaq 0xb6e79(%rip), %rsi     # 0x199938
leaq -0x1b8(%rbp), %rdi
callq 0xa370
jmp 0xe2acd
jmp 0xe2b1f
leaq 0xb8412(%rip), %rsi     # 0x19aee8
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe2ae4
jmp 0xe2b1f
leaq 0xb849b(%rip), %rsi     # 0x19af88
leaq -0x1b8(%rbp), %rdi
callq 0xa750
jmp 0xe2afb
jmp 0xe2b1f
movb $0x1, -0x11(%rbp)
jmp 0xe2b1f
movq 0xb6e3e(%rip), %rsi     # 0x199948
movq 0xb64a7(%rip), %rdi     # 0x198fb8
callq 0xa5c0
jmp 0xe2b18
xorl %edi, %edi
callq 0xa700
leaq -0x1b8(%rbp), %rdi
callq 0xa290
jmp 0xe274f
leaq -0x1b8(%rbp), %rdi
callq 0xa290
jmp 0xe2cf3
movl -0x4(%rbp), %eax
movq 0xb6475(%rip), %rcx     # 0x198fc0
subl (%rcx), %eax
cmpl $0x0, %eax
jle 0xe2b84
movq 0xb6497(%rip), %rdi     # 0x198ff0
leaq 0x4f8dd(%rip), %rsi     # 0x13243d
callq 0xa5c0
jmp 0xe2b67
movb $0x1, -0x11(%rbp)
jmp 0xe2b84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e8(%rbp)
movl %eax, -0x1ec(%rbp)
jmp 0xe2cf3
leaq 0xb82fd(%rip), %rdi     # 0x19ae88
callq 0xaa70
testb $0x1, %al
jne 0xe2ba4
leaq 0xb830d(%rip), %rdi     # 0x19aea8
callq 0xaa70
testb $0x1, %al
jne 0xe2bc6
leaq 0xb82dd(%rip), %rdi     # 0x19ae88
callq 0xaa70
testb $0x1, %al
jne 0xe2bb6
jmp 0xe2bdf
leaq 0xb82eb(%rip), %rdi     # 0x19aea8
callq 0xaa70
testb $0x1, %al
jne 0xe2bdf
movq 0xb6423(%rip), %rdi     # 0x198ff0
leaq 0x6530f(%rip), %rsi     # 0x147ee3
callq 0xa5c0
jmp 0xe2bdb
movb $0x1, -0x11(%rbp)
leaq 0xb8382(%rip), %rdi     # 0x19af68
callq 0xaa70
testb $0x1, %al
jne 0xe2c01
cmpl $0x0, 0xb83ce(%rip)     # 0x19afc4
je 0xe2c25
cmpl $0x0, 0xb83cd(%rip)     # 0x19afcc
je 0xe2c25
leaq 0xb8360(%rip), %rdi     # 0x19af68
callq 0xaa70
testb $0x1, %al
jne 0xe2c13
jmp 0xe2c3e
cmpl $0x0, 0xb83aa(%rip)     # 0x19afc4
jne 0xe2c25
cmpl $0x0, 0xb83a9(%rip)     # 0x19afcc
je 0xe2c3e
movq 0xb63c4(%rip), %rdi     # 0x198ff0
leaq 0x6530f(%rip), %rsi     # 0x147f42
callq 0xa5c0
jmp 0xe2c3a
movb $0x1, -0x11(%rbp)
movsd 0xb8372(%rip), %xmm0    # 0x19afb8
movsd 0x4f66a(%rip), %xmm1    # 0x1322b8
ucomisd %xmm1, %xmm0
jbe 0xe2c6d
movq 0xb6395(%rip), %rdi     # 0x198ff0
leaq 0x65364(%rip), %rsi     # 0x147fc6
callq 0xa5c0
jmp 0xe2c69
movb $0x1, -0x11(%rbp)
movsd 0xb833b(%rip), %xmm0    # 0x19afb0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xe2ca0
cmpl $0x0, 0xb8323(%rip)     # 0x19afa8
jne 0xe2ca0
movq 0xb6362(%rip), %rdi     # 0x198ff0
leaq 0x6535f(%rip), %rsi     # 0x147ff4
callq 0xa5c0
jmp 0xe2c9c
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
je 0xe2ce1
movq 0xb630b(%rip), %rdi     # 0x198fb8
leaq 0x4cbd9(%rip), %rsi     # 0x12f88d
callq 0xa5c0
movq %rax, -0x250(%rbp)
jmp 0xe2cc2
movq -0x250(%rbp), %rdi
movq 0xb6c78(%rip), %rsi     # 0x199948
callq 0xa5c0
jmp 0xe2cd7
movl $0x1, %edi
callq 0xa700
leaq -0x30(%rbp), %rdi
callq 0x3dfa0
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x3dfa0
movq -0x1e8(%rbp), %rdi
callq 0xab50
nopl (%rax,%rax)