// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/process_vcf_fst.cpp
// Function: getFstFromMs()
void getFstFromMs() {
    std::cerr << "Calculating Fst using variants from: " << opt::msFile << std::endl;
    std::cerr << "and outputting chi-sq test p-vals < " << opt::msPvalCutoff << std::endl;
    
    std::ifstream* msFile = new std::ifstream(opt::msFile.c_str());
    string fileRoot = stripExtension(opt::msFile);
    string PvalFileName = fileRoot + "_" + opt::runName + "_pvals.txt";
    std::ofstream* pValFile;
    if (opt::msPvalCutoff > 0) {
        pValFile = new std::ofstream(PvalFileName.c_str());
        *pValFile << "Fisher p-val" << "\t" << "chi-sq pval" << "\t" << "set1Alt" << "\t" << "set1Ref" << "\t" << "set2Alt" << "\t" << "set2Ref" << "\t" << "Fst" << std::endl;
    }
    
    
    std::vector<int> set1_loci;
    std::vector<int> set2_loci;
    srand((int)time(NULL));
    if (opt::msSet1FstSample == 0) {
        opt::msSet1FstSample = opt::msSet1Size;
        for (int i = 0; i != opt::msSet1FstSample; i++) {
            set1_loci.push_back(i);
        }
    } else { // Randomly sample individuals from population 1 for Fst calculation
        for (int i = 0; i != opt::msSet1FstSample; i++) {
            int rand_sample = (rand()%opt::msSet1Size);
            while (std::find(set1_loci.begin(),set1_loci.end(),rand_sample) != set1_loci.end()) {
                rand_sample = (rand()%opt::msSet1Size);
            }
            set1_loci.push_back(rand_sample);
        }
    }
    // Do the same for set2
    if (opt::msSet2FstSample == 0) {
        opt::msSet2FstSample = opt::msSet2Size;
        for (int i = 0; i != opt::msSet2FstSample; i++) {
            set2_loci.push_back(i+opt::msSet1Size);
        }
    } else { // Randomly sample individuals from population 2 for Fst calculation
        for (int i = 0; i != opt::msSet2FstSample; i++) {
            int rand_sample = (rand()%opt::msSet2Size)+opt::msSet1Size;
            while (std::find(set2_loci.begin(),set2_loci.end(),rand_sample) != set2_loci.end()) {
                rand_sample = (rand()%opt::msSet2Size)+opt::msSet1Size;
            }
            set2_loci.push_back(rand_sample);
        }
    }

    std::cerr << "Selected population 1 individuals: "; print_vector(set1_loci, std::cerr);
    std::cerr << "Selected population 2 individuals: "; print_vector(set2_loci, std::cerr);
    
    if (opt::msSet1Size != opt::msSet1FstSample || opt::msSet2Size != opt::msSet2FstSample) {
        std::cerr << "Warning: the Fst column is going to contain '-1' values where the site is not a segregating site in the sampled individuals for Fst calcultation" << std::endl;
    }
    
    std::vector<double> fstNumerators; fstNumerators.reserve(50000000);
    std::vector<double> fstDenominators; fstDenominators.reserve(50000000);
    
    
    string line;
    int numFixedSites = 0;
    int numNearlyFixedSites = 0;
    std::vector<double> nullForChisq;
    std::vector<int> moreSet1;
    std::vector<int> lessSet1;
    std::vector<int> moreSet2;
    std::vector<int> lessSet2;
    SetCounts counts;
    while (getline(*msFile, line)) {
        counts.reset();
        double thisFst = -1;
        for (std::vector<int>::iterator it = set1_loci.begin(); it != set1_loci.end(); it++) {
            // std::cerr << line[*it] << std::endl;
            if (line[*it] == '1') {
                counts.set1Count++;
            }
        }
        for (std::vector<int>::iterator it = set2_loci.begin(); it != set2_loci.end(); it++) {
            if (line[*it] == '1') {
                counts.set2Count++;
            }
        }
        counts.set1_n_withoutMissing = opt::msSet1FstSample;
        counts.set2_n_withoutMissing = opt::msSet2FstSample;
        
        //std::cerr << "counts.set1Count" << counts.set1Count << "\t" << "counts.set2Count" << counts.set2Count << std::endl;
        
        if (counts.set1Count > 0 || counts.set2Count > 0) {
            counts.calculateAlleleFrequencies();
            double FstNum = calculateFstNumerator(counts.p1, counts.p2, counts.set1_n_withoutMissing, counts.set2_n_withoutMissing);
            double FstDenom = calculateFstDenominator(counts.p1, counts.p2);
            thisFst = FstNum/FstDenom; if (thisFst < 0) thisFst = 0;
            fstNumerators.push_back(FstNum);
            fstDenominators.push_back(FstDenom);
            
        }
        
        if ((counts.set1Count == 0 && counts.set2Count == opt::msSet2FstSample) || (counts.set1Count == opt::msSet1FstSample && counts.set2Count == 0)) {
            numFixedSites++;
        }
        
        if ((counts.set1Count == 1 && counts.set2Count == opt::msSet2FstSample) || (counts.set1Count == 0 && counts.set2Count == opt::msSet2FstSample-1) ||
            (counts.set1Count == opt::msSet1FstSample-1 && counts.set2Count == 0) || (counts.set1Count == opt::msSet1FstSample && counts.set2Count == 1)) {
            numNearlyFixedSites++;
        }
        
        
        int set1WithoutVariant = opt::msSet1FstSample-counts.set1Count;
        int set2WithoutVariant = opt::msSet2FstSample-counts.set2Count;
        
        if (counts.set1Count >= set1WithoutVariant) {
            moreSet1.push_back(counts.set1Count);
            lessSet1.push_back(set1WithoutVariant);
            moreSet2.push_back(counts.set2Count);
            lessSet2.push_back(set2WithoutVariant);
        } else {
            moreSet1.push_back(set1WithoutVariant);
            lessSet1.push_back(counts.set1Count);
            moreSet2.push_back(set2WithoutVariant);
            lessSet2.push_back(counts.set2Count);
        }
        
       // std::cerr << counts.set1Count << "\t" << set1WithoutVariant << "\t" << counts.set2Count << "\t" << set2WithoutVariant << std::endl;
        if ((counts.set1Count != 0 || counts.set2Count != 0) && (set1WithoutVariant != 0 || set2WithoutVariant != 0)) {
            if (opt::msSet1FstSample + opt::msSet2FstSample <= 60) {
                counts.fisher_pval = fisher_exact(counts.set1Count,set1WithoutVariant , counts.set2Count, set2WithoutVariant);
   //             std::cerr << "Fisher: " << counts.fisher_pval << std::endl;
                counts.chi_sq_pval = pearson_chi_sq_indep(counts.set1Count,set1WithoutVariant , counts.set2Count, set2WithoutVariant);
            } else {
                counts.chi_sq_pval = pearson_chi_sq_indep(counts.set1Count,set1WithoutVariant , counts.set2Count, set2WithoutVariant);
            }
        }
        
        if (counts.fisher_pval < opt::msPvalCutoff || counts.chi_sq_pval < opt::msPvalCutoff) {
            *pValFile << counts.fisher_pval << "\t" << counts.chi_sq_pval << "\t" << counts.set1Count << "\t" << set1WithoutVariant << "\t" << counts.set2Count << "\t" << set2WithoutVariant << "\t" << thisFst << std::endl;
        }
    }
    
    double Fst = calculateFst(fstNumerators, fstDenominators);
    std::cerr << "Fst: " << Fst << std::endl;
    std::cerr << "Fixed sites: " << numFixedSites << std::endl;
    std::cerr << "Tier2 sites: " << numNearlyFixedSites << std::endl;
    std::cerr << "Null ChiSq 1:" << vector_average(moreSet1)/opt::msSet1FstSample << "\t" << vector_average(lessSet1)/opt::msSet1FstSample << std::endl;
    std::cerr << "Null ChiSq 2:" << vector_average(moreSet2)/opt::msSet2FstSample << "\t" << vector_average(lessSet2)/opt::msSet2FstSample << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movq 0x6dcad(%rip), %rbx     # 0xdcfe8
leaq 0x3bf9e(%rip), %rsi     # 0xab2e0
movq %rbx, %rdi
callq 0x8480
leaq 0x6f757(%rip), %rsi     # 0xdeaa8
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x3c2e2(%rip), %rsi     # 0xab64a
movq %rbx, %rdi
callq 0x8480
movsd 0x6f780(%rip), %xmm0    # 0xdeaf8
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq 0x6f70f(%rip), %rsi     # 0xdeaa8
pushq $0x8
popq %rdx
movq %rax, 0x58(%rsp)
movq %rax, %rdi
callq 0x8890
leaq 0x6f6f8(%rip), %rsi     # 0xdeaa8
leaq 0x308(%rsp), %rbx
movq %rbx, %rdi
callq 0x404d7
leaq 0x343f5(%rip), %rdx     # 0xa37bc
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x28806
leaq 0x6f6ed(%rip), %rdx     # 0xdeac8
leaq 0x148(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x287e7
leaq 0x3c27b(%rip), %rdx     # 0xab66f
leaq 0x2e8(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x28a29
leaq 0x148(%rsp), %rdi
callq 0x8978
leaq 0x60(%rsp), %rdi
callq 0x8978
movsd 0x6f6d0(%rip), %xmm0    # 0xdeaf8
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x6f521
movl $0x200, %edi            # imm = 0x200
callq 0x8490
movq %rax, %r12
movq 0x2e8(%rsp), %rsi
pushq $0x10
popq %rdx
movq %rax, %rdi
callq 0x84e0
leaq 0x3c21d(%rip), %rsi     # 0xab67a
movq %r12, %rdi
callq 0x8480
leaq 0x2a9b2(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
leaq 0x3c20c(%rip), %rsi     # 0xab687
movq %rax, %rdi
callq 0x8480
leaq 0x2a994(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
leaq 0x3c1fa(%rip), %rsi     # 0xab693
movq %rax, %rdi
callq 0x8480
leaq 0x2a976(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
leaq 0x3c1e4(%rip), %rsi     # 0xab69b
movq %rax, %rdi
callq 0x8480
leaq 0x2a958(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
leaq 0x3c1ce(%rip), %rsi     # 0xab6a3
movq %rax, %rdi
callq 0x8480
leaq 0x2a93a(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
leaq 0x3c1b8(%rip), %rsi     # 0xab6ab
movq %rax, %rdi
callq 0x8480
leaq 0x2a91c(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
leaq 0x3be91(%rip), %rsi     # 0xab3a2
movq %rax, %rdi
callq 0x8480
movq %rax, %rdi
callq 0x8230
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movapd %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x8450
movl %eax, %edi
callq 0x8470
movl 0x6f5ac(%rip), %eax     # 0xdeb00
testl %eax, %eax
je 0x6f5b0
leaq 0x148(%rsp), %rbx
leaq 0x40(%rsp), %r14
cmpl %eax, %r15d
je 0x6f5f2
callq 0x8160
cltd
idivl 0x6f58a(%rip)           # 0xdeb04
movl %edx, 0x148(%rsp)
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %rbx, %rdx
callq 0x451ef
cmpq 0x48(%rsp), %rax
jne 0x6f56e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3aca4
incl %r15d
movl 0x6f552(%rip), %eax     # 0xdeb00
jmp 0x6f565
movl 0x6f54e(%rip), %ecx     # 0xdeb04
movl %ecx, 0x6f544(%rip)     # 0xdeb00
xorl %eax, %eax
leaq 0x40(%rsp), %rbx
leaq 0x148(%rsp), %r14
movl %eax, 0x148(%rsp)
cmpl %ecx, %eax
je 0x6f5f2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3aca4
movl 0x148(%rsp), %eax
incl %eax
movl 0x6f510(%rip), %ecx     # 0xdeb00
jmp 0x6f5cb
movl 0x6f510(%rip), %eax     # 0xdeb08
testl %eax, %eax
je 0x6f65a
xorl %ebp, %ebp
leaq 0x148(%rsp), %rbx
leaq 0x20(%rsp), %r14
cmpl %eax, %ebp
je 0x6f69d
callq 0x8160
cltd
idivl 0x6f4ed(%rip)           # 0xdeb0c
addl 0x6f4df(%rip), %edx     # 0xdeb04
movl %edx, 0x148(%rsp)
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x451ef
cmpq 0x28(%rsp), %rax
jne 0x6f613
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3aca4
incl %ebp
movl 0x6f4b0(%rip), %eax     # 0xdeb08
jmp 0x6f60b
movl 0x6f4ac(%rip), %eax     # 0xdeb0c
movl %eax, 0x6f4a2(%rip)     # 0xdeb08
xorl %ebp, %ebp
leaq 0x20(%rsp), %rbx
leaq 0x148(%rsp), %r14
cmpl %eax, %ebp
je 0x6f69d
movl 0x6f485(%rip), %eax     # 0xdeb04
addl %ebp, %eax
movl %eax, 0x148(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c80c
incl %ebp
movl 0x6f46d(%rip), %eax     # 0xdeb08
jmp 0x6f675
movq 0x6d944(%rip), %rdi     # 0xdcfe8
leaq 0x3c008(%rip), %rsi     # 0xab6b3
callq 0x8480
leaq 0x2d0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x2c6d4
movq 0x6d91f(%rip), %rsi     # 0xdcfe8
leaq 0x2d0(%rsp), %rdi
pushq $0x9
popq %rdx
pushq $0x1
popq %rcx
callq 0x348a2
leaq 0x2d0(%rsp), %rdi
callq 0x2aef2
movq 0x6d8f8(%rip), %rdi     # 0xdcfe8
leaq 0x3bfe0(%rip), %rsi     # 0xab6d7
callq 0x8480
leaq 0x2b8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2c6d4
movq 0x6d8d3(%rip), %rsi     # 0xdcfe8
leaq 0x2b8(%rsp), %rdi
pushq $0x9
popq %rdx
pushq $0x1
popq %rcx
callq 0x348a2
leaq 0x2b8(%rsp), %rdi
callq 0x2aef2
movl 0x6f3c9(%rip), %eax     # 0xdeb04
cmpl 0x6f3bf(%rip), %eax     # 0xdeb00
jne 0x6f751
movl 0x6f3c3(%rip), %eax     # 0xdeb0c
cmpl 0x6f3b9(%rip), %eax     # 0xdeb08
je 0x6f76c
movq 0x6d890(%rip), %rdi     # 0xdcfe8
leaq 0x3bf9c(%rip), %rsi     # 0xab6fb
callq 0x8480
movq %rax, %rdi
callq 0x8230
xorpd %xmm0, %xmm0
leaq 0x130(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movl $0x2faf080, %esi        # imm = 0x2FAF080
callq 0x70d80
movq %r12, 0xe0(%rsp)
leaq 0x110(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movl $0x2faf080, %esi        # imm = 0x2FAF080
callq 0x70d80
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ebp, %ebp
movb %bpl, (%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x240(%rsp)
andq $0x0, 0x250(%rsp)
leaq 0xc0(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0xa0(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movapd %xmm0, (%rax)
movapd %xmm0, (%rcx)
leaq 0x80(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0xf0(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x188(%rsp), %r12
andl $0x0, -0x40(%r12)
movb %bpl, -0x3c(%r12)
andq $0x0, -0x10(%r12)
andl $0x0, -0x8(%r12)
movupd %xmm0, -0x38(%r12)
movupd %xmm0, -0x28(%r12)
andl $0x0, -0x18(%r12)
movl $0x95, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x82b0
movapd 0x27d77(%rip), %xmm0    # 0x975e0
movupd %xmm0, 0x98(%r12)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xa8(%r12)
leaq 0x18(%rsp), %r14
leaq 0x10(%rsp), %rbx
leaq 0x2a58c(%rip), %r13     # 0x99e1e
xorl %r15d, %r15d
movq 0x58(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6fc76
andl $0x0, 0x148(%rsp)
andq $0x0, 0x208(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x98(%r12)
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rsi
xorl %eax, %eax
movq 0x60(%rsp), %rdx
cmpq %rsi, %rcx
je 0x6f903
movslq (%rcx), %rdi
cmpb $0x31, (%rdx,%rdi)
jne 0x6f8fd
incl %eax
movl %eax, 0x208(%rsp)
addq $0x4, %rcx
jmp 0x6f8e6
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdi
xorl %ecx, %ecx
cmpq %rdi, %rsi
je 0x6f92d
movslq (%rsi), %r8
cmpb $0x31, (%rdx,%r8)
jne 0x6f927
incl %ecx
movl %ecx, 0x20c(%rsp)
addq $0x4, %rsi
jmp 0x6f90f
movl 0x6f1cd(%rip), %edi     # 0xdeb00
movl %edi, 0x210(%rsp)
movl 0x6f1c8(%rip), %esi     # 0xdeb08
movl %esi, 0x214(%rsp)
testl %eax, %eax
setg %dl
testl %ecx, %ecx
setg %r8b
orb %dl, %r8b
je 0x6fa2f
movd %ecx, %xmm0
movd %eax, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm0
movd %esi, %xmm1
movd %edi, %xmm2
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
cvtdq2pd %xmm2, %xmm1
divpd %xmm1, %xmm0
movupd %xmm0, 0x230(%rsp)
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
callq 0x70f23
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, 0x18(%rsp)
movsd 0x230(%rsp), %xmm0
movsd 0x238(%rsp), %xmm1
movsd 0x27c35(%rip), %xmm2    # 0x975f0
movapd %xmm2, %xmm3
subsd %xmm1, %xmm3
subsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, 0xe8(%rsp)
movsd %xmm3, 0x10(%rsp)
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
callq 0x5a406
leaq 0x110(%rsp), %rdi
movq %rbx, %rsi
callq 0x5a406
movsd 0x8(%rsp), %xmm1
divsd 0xe8(%rsp), %xmm1
xorpd %xmm0, %xmm0
maxsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x208(%rsp), %eax
movl 0x20c(%rsp), %ecx
jmp 0x6fa3d
movsd 0x27bc1(%rip), %xmm0    # 0x975f8
movsd %xmm0, 0x8(%rsp)
testl %eax, %eax
jne 0x6fa49
cmpl 0x6f0c1(%rip), %ecx     # 0xdeb08
je 0x6fa55
movl 0x6f0b1(%rip), %edx     # 0xdeb00
xorl %eax, %edx
orl %ecx, %edx
jne 0x6fa57
incl %ebp
cmpl $0x1, %eax
jne 0x6fa66
cmpl 0x6f0a6(%rip), %ecx     # 0xdeb08
jne 0x6fa76
jmp 0x6fa92
testl %eax, %eax
jne 0x6fa76
movl 0x6f098(%rip), %edx     # 0xdeb08
decl %edx
cmpl %edx, %ecx
je 0x6fa92
movl 0x6f084(%rip), %edx     # 0xdeb00
leal -0x1(%rdx), %esi
xorl %eax, %esi
orl %ecx, %esi
je 0x6fa92
movl %eax, %esi
xorl %edx, %esi
movl %ecx, %edi
xorl $0x1, %edi
orl %esi, %edi
jne 0x6fa9b
incl %r15d
movl 0x6f065(%rip), %edx     # 0xdeb00
subl %eax, %edx
movl %edx, 0x18(%rsp)
movl 0x6f061(%rip), %esi     # 0xdeb08
subl %ecx, %esi
movl %esi, 0x10(%rsp)
cmpl %edx, %eax
jge 0x6faf0
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x3aca4
leaq 0xa0(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x3aca4
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x3aca4
leaq 0x20c(%rsp), %rsi
jmp 0x6fb2d
leaq 0xc0(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x3aca4
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x3aca4
leaq 0x80(%rsp), %rdi
leaq 0x20c(%rsp), %rsi
callq 0x3aca4
movq %rbx, %rsi
leaq 0xf0(%rsp), %rdi
callq 0x3aca4
movl 0x208(%rsp), %edi
movl 0x20c(%rsp), %edx
movl %edi, %eax
orl %edx, %eax
je 0x6fb9f
movl 0x18(%rsp), %esi
movl 0x10(%rsp), %ecx
movl %esi, %eax
orl %ecx, %eax
je 0x6fb9f
movl 0x6efa6(%rip), %eax     # 0xdeb08
addl 0x6ef98(%rip), %eax     # 0xdeb00
cmpl $0x3c, %eax
jg 0x6fb91
callq 0x71301
movsd %xmm0, 0x220(%rsp)
movl 0x208(%rsp), %edi
movl 0x20c(%rsp), %edx
movl 0x18(%rsp), %esi
movl 0x10(%rsp), %ecx
callq 0x71714
movsd %xmm0, 0x228(%rsp)
movsd 0x220(%rsp), %xmm0
movsd 0x6ef48(%rip), %xmm1    # 0xdeaf8
ucomisd %xmm0, %xmm1
ja 0x6fbc5
ucomisd 0x228(%rsp), %xmm1
jbe 0x6f895
movq 0xe0(%rsp), %rdi
callq 0x8750
movq %rax, %rdi
movq %r13, %rsi
callq 0x8480
movsd 0x228(%rsp), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
movq %r13, %rsi
callq 0x8480
movl 0x208(%rsp), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
movq %r13, %rsi
callq 0x8480
movl 0x18(%rsp), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
movq %r13, %rsi
callq 0x8480
movl 0x20c(%rsp), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
movq %r13, %rsi
callq 0x8480
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
movq %r13, %rsi
callq 0x8480
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x8750
movq %rax, %rdi
callq 0x8230
jmp 0x6f895
leaq 0x130(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x6b356
movsd %xmm0, 0x8(%rsp)
movq 0x6d350(%rip), %rdi     # 0xdcfe8
leaq 0x3b96d(%rip), %rsi     # 0xab60c
callq 0x8480
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x8750
movq %rax, %rdi
callq 0x8230
movq 0x6d327(%rip), %rdi     # 0xdcfe8
leaq 0x3bac4(%rip), %rsi     # 0xab78c
callq 0x8480
movq %rax, %rdi
movl %ebp, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x6d302(%rip), %rdi     # 0xdcfe8
leaq 0x3baad(%rip), %rsi     # 0xab79a
callq 0x8480
movq %rax, %rdi
movl %r15d, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x6d2dc(%rip), %rdi     # 0xdcfe8
leaq 0x3ba95(%rip), %rsi     # 0xab7a8
callq 0x8480
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x2c6d4
leaq 0x2a0(%rsp), %rdi
callq 0x630f7
cvtsi2sdl 0x6edbb(%rip), %xmm1 # 0xdeb00
divsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x8750
leaq 0x2a0c6(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
movq %rax, %rbx
leaq 0x288(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2c6d4
leaq 0x288(%rsp), %rdi
callq 0x630f7
cvtsi2sdl 0x6ed73(%rip), %xmm1 # 0xdeb00
divsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x288(%rsp), %rdi
callq 0x2aef2
leaq 0x2a0(%rsp), %rdi
callq 0x2aef2
movq 0x6d226(%rip), %rdi     # 0xdcfe8
leaq 0x3b9ed(%rip), %rsi     # 0xab7b6
callq 0x8480
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x2c6d4
leaq 0x270(%rsp), %rdi
callq 0x630f7
cvtsi2sdl 0x6ed0d(%rip), %xmm1 # 0xdeb08
divsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x8750
leaq 0x2a010(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
movq %rax, %rbx
leaq 0x258(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x2c6d4
leaq 0x258(%rsp), %rdi
callq 0x630f7
cvtsi2sdl 0x6ecc5(%rip), %xmm1 # 0xdeb08
divsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x258(%rsp), %rdi
callq 0x2aef2
leaq 0x270(%rsp), %rdi
callq 0x2aef2
leaq 0x148(%rsp), %rdi
callq 0x712b4
leaq 0xf0(%rsp), %rdi
callq 0x2aef2
leaq 0x80(%rsp), %rdi
callq 0x2aef2
leaq 0xa0(%rsp), %rdi
callq 0x2aef2
leaq 0xc0(%rsp), %rdi
callq 0x2aef2
leaq 0x240(%rsp), %rdi
callq 0x2b43c
leaq 0x60(%rsp), %rdi
callq 0x8978
leaq 0x110(%rsp), %rdi
callq 0x2b43c
leaq 0x130(%rsp), %rdi
callq 0x2b43c
leaq 0x20(%rsp), %rdi
callq 0x2aef2
leaq 0x40(%rsp), %rdi
callq 0x2aef2
leaq 0x2e8(%rsp), %rdi
callq 0x8978
leaq 0x308(%rsp), %rdi
callq 0x8978
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdi
callq 0x84a0
jmp 0x7009c
movq %rax, %rbx
jmp 0x70067
movq %rax, %rbx
jmp 0x70074
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
jmp 0x6ff60
movq %rax, %rbx
leaq 0x2d0(%rsp), %rdi
callq 0x2aef2
jmp 0x70088
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x8978
jmp 0x6ff7f
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x700a4
movq %rax, %rbx
jmp 0x700a9
movq %rax, %rbx
movl $0x208, %esi            # imm = 0x208
movq 0x58(%rsp), %rdi
callq 0x84a0
jmp 0x700b6
movq %rax, %rbx
leaq 0x258(%rsp), %rdi
callq 0x2aef2
jmp 0x6ffcf
movq %rax, %rbx
leaq 0x288(%rsp), %rdi
callq 0x2aef2
jmp 0x6ffdc
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
jmp 0x6ffe4
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0x2aef2
jmp 0x7000f
jmp 0x70085
movq %rax, %rbx
jmp 0x7009c
jmp 0x70085
jmp 0x70085
jmp 0x7000c
jmp 0x70085
jmp 0x70085
jmp 0x7000c
jmp 0x7000c
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x712b4
leaq 0xf0(%rsp), %rdi
callq 0x2aef2
leaq 0x80(%rsp), %rdi
callq 0x2aef2
leaq 0xa0(%rsp), %rdi
callq 0x2aef2
leaq 0xc0(%rsp), %rdi
callq 0x2aef2
leaq 0x240(%rsp), %rdi
callq 0x2b43c
leaq 0x60(%rsp), %rdi
callq 0x8978
leaq 0x110(%rsp), %rdi
callq 0x2b43c
leaq 0x130(%rsp), %rdi
callq 0x2b43c
jmp 0x70088
jmp 0x70085
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2aef2
leaq 0x40(%rsp), %rdi
callq 0x2aef2
leaq 0x2e8(%rsp), %rdi
callq 0x8978
leaq 0x308(%rsp), %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8870