// File: 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
movq %rsp, %rbp
subq $0x600, %rsp            # imm = 0x600
movq 0xb8cfe(%rip), %rdi     # 0x198ff0
movq %rdi, -0x408(%rbp)
leaq 0x676d0(%rip), %rsi     # 0x1479d0
callq 0xa5c0
movq %rax, %rdi
leaq 0xbac59(%rip), %rsi     # 0x19af68
movq %rsi, -0x3f8(%rbp)
callq 0xa520
movq %rax, %rdi
movq 0xb8c63(%rip), %rsi     # 0x198f88
movq %rsi, -0x400(%rbp)
callq 0xa610
movq -0x408(%rbp), %rdi
leaq 0x679fb(%rip), %rsi     # 0x147d3a
callq 0xa5c0
movq %rax, %rdi
movsd 0xbac69(%rip), %xmm0    # 0x19afb8
callq 0xabd0
movq -0x400(%rbp), %rsi
movq %rax, %rdi
callq 0xa610
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq -0x3f8(%rbp), %rdi
movq %rax, -0x3e8(%rbp)
movq %rax, -0x3f0(%rbp)
callq 0xa220
movq -0x3e8(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0xe039d
movq -0x3f0(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq 0xbabb9(%rip), %rsi     # 0x19af68
leaq -0x38(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x7be70
movq -0x410(%rbp), %rsi
leaq 0x5f9c3(%rip), %rdx     # 0x13fd90
leaq -0x98(%rbp), %rdi
callq 0x3da80
jmp 0xe03db
leaq 0xbaba6(%rip), %rdx     # 0x19af88
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3da30
jmp 0xe03f4
leaq 0x67964(%rip), %rdx     # 0x147d5f
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3e020
jmp 0xe040a
leaq -0x78(%rbp), %rdi
callq 0xac88
leaq -0x98(%rbp), %rdi
callq 0xac88
movsd 0xbab91(%rip), %xmm0    # 0x19afb8
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xe0694
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x418(%rbp)
jmp 0xe0447
leaq -0x58(%rbp), %rdi
callq 0xa220
movq -0x418(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0xa650
jmp 0xe0466
movq -0x418(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
leaq 0x678e8(%rip), %rsi     # 0x147d6a
callq 0xa5c0
movq %rax, -0x420(%rbp)
jmp 0xe0490
movq -0x420(%rbp), %rdi
leaq 0x55a40(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x428(%rbp)
jmp 0xe04ac
movq -0x428(%rbp), %rdi
leaq 0x678bd(%rip), %rsi     # 0x147d77
callq 0xa5c0
movq %rax, -0x430(%rbp)
jmp 0xe04c8
movq -0x430(%rbp), %rdi
leaq 0x55a08(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x438(%rbp)
jmp 0xe04e4
movq -0x438(%rbp), %rdi
leaq 0x67891(%rip), %rsi     # 0x147d83
callq 0xa5c0
movq %rax, -0x440(%rbp)
jmp 0xe0500
movq -0x440(%rbp), %rdi
leaq 0x559d0(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x448(%rbp)
jmp 0xe051c
movq -0x448(%rbp), %rdi
leaq 0x67861(%rip), %rsi     # 0x147d8b
callq 0xa5c0
movq %rax, -0x450(%rbp)
jmp 0xe0538
movq -0x450(%rbp), %rdi
leaq 0x55998(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x458(%rbp)
jmp 0xe0554
movq -0x458(%rbp), %rdi
leaq 0x67831(%rip), %rsi     # 0x147d93
callq 0xa5c0
movq %rax, -0x460(%rbp)
jmp 0xe0570
movq -0x460(%rbp), %rdi
leaq 0x55960(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x468(%rbp)
jmp 0xe058c
movq -0x468(%rbp), %rdi
leaq 0x67801(%rip), %rsi     # 0x147d9b
callq 0xa5c0
movq %rax, -0x470(%rbp)
jmp 0xe05a8
movq -0x470(%rbp), %rdi
leaq 0x55928(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x478(%rbp)
jmp 0xe05c4
movq -0x478(%rbp), %rdi
leaq 0x674c0(%rip), %rsi     # 0x147a92
callq 0xa5c0
movq %rax, -0x480(%rbp)
jmp 0xe05e0
movq -0x480(%rbp), %rdi
movq 0xb899a(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe05f5
jmp 0xe0694
movq -0x3f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0xe1762
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe1759
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe0650
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xac88
leaq -0x98(%rbp), %rdi
callq 0xac88
jmp 0xe1759
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe1750
movq -0x418(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xe1750
leaq -0xb8(%rbp), %rdi
callq 0x46270
leaq -0xd0(%rbp), %rdi
callq 0x46270
xorl %eax, %eax
movl %eax, %edi
callq 0xa550
movl %eax, %edi
callq 0xa590
cmpl $0x0, 0xba8fd(%rip)     # 0x19afc0
jne 0xe0727
movl 0xba8f9(%rip), %eax     # 0x19afc4
movl %eax, 0xba8ef(%rip)     # 0x19afc0
movl $0x0, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpl 0xba8d9(%rip), %eax     # 0x19afc0
je 0xe0722
leaq -0xb8(%rbp), %rdi
leaq -0xd4(%rbp), %rsi
callq 0x6b600
jmp 0xe06fe
jmp 0xe0700
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0xe06db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe1738
jmp 0xe0823
movl $0x0, -0xd8(%rbp)
movl -0xd8(%rbp), %eax
cmpl 0xba883(%rip), %eax     # 0x19afc0
je 0xe0821
callq 0xa180
cltd
idivl 0xba875(%rip)           # 0x19afc4
movl %edx, -0xdc(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x490(%rbp)
callq 0x46a90
movq -0x490(%rbp), %rdi
movq %rax, -0xf0(%rbp)
callq 0x46ac0
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rdi
movq -0xf8(%rbp), %rsi
leaq -0xdc(%rbp), %rdx
callq 0x9d7b0
movq %rax, -0x488(%rbp)
jmp 0xe07a5
movq -0x488(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x46ac0
movq %rax, -0x100(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x705f0
testb $0x1, %al
jne 0xe07df
jmp 0xe07f6
callq 0xa180
cltd
idivl 0xba7d9(%rip)           # 0x19afc4
movl %edx, -0xdc(%rbp)
jmp 0xe0755
leaq -0xb8(%rbp), %rdi
leaq -0xdc(%rbp), %rsi
callq 0x6b600
jmp 0xe080b
jmp 0xe080d
movl -0xd8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd8(%rbp)
jmp 0xe0731
jmp 0xe0823
cmpl $0x0, 0xba79e(%rip)     # 0x19afc8
jne 0xe0891
movl 0xba79a(%rip), %eax     # 0x19afcc
movl %eax, 0xba790(%rip)     # 0x19afc8
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
cmpl 0xba77a(%rip), %eax     # 0x19afc8
je 0xe088c
movl -0x104(%rbp), %eax
movl 0xba768(%rip), %ecx     # 0x19afc4
addl %ecx, %eax
movl %eax, -0x108(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x4ce80
jmp 0xe0879
jmp 0xe087b
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0xe0842
jmp 0xe0999
movl $0x0, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
cmpl 0xba721(%rip), %eax     # 0x19afc8
je 0xe0997
callq 0xa180
cltd
idivl 0xba713(%rip)           # 0x19afcc
addl 0xba705(%rip), %edx     # 0x19afc4
movl %edx, -0x110(%rbp)
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x46a90
movq -0x4a0(%rbp), %rdi
movq %rax, -0x120(%rbp)
callq 0x46ac0
movq %rax, -0x128(%rbp)
movq -0x120(%rbp), %rdi
movq -0x128(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x9d7b0
movq %rax, -0x498(%rbp)
jmp 0xe0915
movq -0x498(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x46ac0
movq %rax, -0x130(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x705f0
testb $0x1, %al
jne 0xe094f
jmp 0xe096c
callq 0xa180
cltd
idivl 0xba671(%rip)           # 0x19afcc
addl 0xba663(%rip), %edx     # 0x19afc4
movl %edx, -0x110(%rbp)
jmp 0xe08c5
leaq -0xd0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x6b600
jmp 0xe0981
jmp 0xe0983
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0xe089b
jmp 0xe0999
movq 0xb8650(%rip), %rdi     # 0x198ff0
leaq 0x673fc(%rip), %rsi     # 0x147da3
callq 0xa5c0
jmp 0xe09ae
leaq -0x148(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4cf20
jmp 0xe09c3
movq 0xb8626(%rip), %rsi     # 0x198ff0
leaq -0x148(%rbp), %rdi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x5f9b0
jmp 0xe09e2
leaq -0x148(%rbp), %rdi
callq 0x48290
movq 0xb85fb(%rip), %rdi     # 0x198ff0
leaq 0x673cb(%rip), %rsi     # 0x147dc7
callq 0xa5c0
jmp 0xe0a03
leaq -0x160(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x4cf20
jmp 0xe0a18
movq 0xb85d1(%rip), %rsi     # 0x198ff0
leaq -0x160(%rbp), %rdi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x5f9b0
jmp 0xe0a37
leaq -0x160(%rbp), %rdi
callq 0x48290
movl 0xba57b(%rip), %eax     # 0x19afc4
cmpl 0xba571(%rip), %eax     # 0x19afc0
jne 0xe0a5f
movl 0xba575(%rip), %eax     # 0x19afcc
cmpl 0xba56b(%rip), %eax     # 0x19afc8
je 0xe0acc
movq 0xb858a(%rip), %rdi     # 0x198ff0
leaq 0x6737e(%rip), %rsi     # 0x147deb
callq 0xa5c0
movq %rax, -0x4a8(%rbp)
jmp 0xe0a7b
movq -0x4a8(%rbp), %rdi
movq 0xb84ff(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe0a90
jmp 0xe0acc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x48290
jmp 0xe1738
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x48290
jmp 0xe1738
leaq -0x178(%rbp), %rdi
movq %rdi, -0x4b0(%rbp)
callq 0x48410
movq -0x4b0(%rbp), %rdi
movl $0x2faf080, %esi        # imm = 0x2FAF080
callq 0xe2f90
jmp 0xe0af2
leaq -0x190(%rbp), %rdi
movq %rdi, -0x4b8(%rbp)
callq 0x48410
movq -0x4b8(%rbp), %rdi
movl $0x2faf080, %esi        # imm = 0x2FAF080
callq 0xe2f90
jmp 0xe0b18
leaq -0x1b0(%rbp), %rdi
callq 0xa820
movl $0x0, -0x1b4(%rbp)
movl $0x0, -0x1b8(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x48410
leaq -0x1e8(%rbp), %rdi
callq 0x46270
leaq -0x200(%rbp), %rdi
callq 0x46270
leaq -0x218(%rbp), %rdi
callq 0x46270
leaq -0x230(%rbp), %rdi
callq 0x46270
leaq -0x328(%rbp), %rdi
callq 0xe3190
jmp 0xe0b82
jmp 0xe0b84
movq -0x8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0xa0d0
movq %rax, -0x4c0(%rbp)
jmp 0xe0b9d
movq -0x4c0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0x4c1(%rbp)
jmp 0xe0bbb
movb -0x4c1(%rbp), %al
testb $0x1, %al
jne 0xe0bca
jmp 0xe129a
leaq -0x328(%rbp), %rdi
callq 0xe3b50
jmp 0xe0bd8
movsd 0x52ae0(%rip), %xmm0    # 0x1336c0
movsd %xmm0, -0x330(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x46a90
movq %rax, -0x338(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x46ac0
movq %rax, -0x340(%rbp)
leaq -0x338(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x705f0
testb $0x1, %al
jne 0xe0c2a
jmp 0xe0cce
leaq -0x338(%rbp), %rdi
callq 0x4d970
movslq (%rax), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0xac60
movq %rax, -0x4d0(%rbp)
jmp 0xe0c4e
movq -0x4d0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0xe0cb2
movl -0x268(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x268(%rbp)
jmp 0xe0cb2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe172c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe1720
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe16d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe16cc
jmp 0xe0cb4
leaq -0x338(%rbp), %rdi
xorl %esi, %esi
callq 0xe3b90
movq %rax, -0x348(%rbp)
jmp 0xe0bfb
leaq -0xd0(%rbp), %rdi
callq 0x46a90
movq %rax, -0x350(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x46ac0
movq %rax, -0x358(%rbp)
leaq -0x350(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0x705f0
testb $0x1, %al
jne 0xe0d0d
jmp 0xe0d6b
leaq -0x350(%rbp), %rdi
callq 0x4d970
movslq (%rax), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0xac60
movq %rax, -0x4d8(%rbp)
jmp 0xe0d31
movq -0x4d8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0xe0d4f
movl -0x264(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x264(%rbp)
jmp 0xe0d51
leaq -0x350(%rbp), %rdi
xorl %esi, %esi
callq 0xe3b90
movq %rax, -0x360(%rbp)
jmp 0xe0ce1
movl 0xba24f(%rip), %eax     # 0x19afc0
movl %eax, -0x260(%rbp)
movl 0xba24b(%rip), %eax     # 0x19afc8
movl %eax, -0x25c(%rbp)
cmpl $0x0, -0x268(%rbp)
jg 0xe0d99
cmpl $0x0, -0x264(%rbp)
jle 0xe0e6d
leaq -0x328(%rbp), %rdi
callq 0xe3290
jmp 0xe0da7
movsd -0x240(%rbp), %xmm0
movsd -0x238(%rbp), %xmm1
movl -0x260(%rbp), %edi
movl -0x25c(%rbp), %esi
callq 0xe32e0
movsd %xmm0, -0x4e0(%rbp)
jmp 0xe0dd2
movsd -0x4e0(%rbp), %xmm0
movsd %xmm0, -0x368(%rbp)
movsd -0x240(%rbp), %xmm0
movsd -0x238(%rbp), %xmm1
callq 0xe3390
movsd %xmm0, -0x4e8(%rbp)
jmp 0xe0e01
movsd -0x4e8(%rbp), %xmm0
movsd %xmm0, -0x370(%rbp)
movsd -0x368(%rbp), %xmm0
divsd -0x370(%rbp), %xmm0
movsd %xmm0, -0x330(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x330(%rbp), %xmm0
jbe 0xe0e41
xorps %xmm0, %xmm0
movsd %xmm0, -0x330(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0xb77b0
jmp 0xe0e56
leaq -0x190(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0xb77b0
jmp 0xe0e6b
jmp 0xe0e6d
cmpl $0x0, -0x268(%rbp)
jne 0xe0e84
movl -0x264(%rbp), %eax
cmpl 0xba146(%rip), %eax     # 0x19afc8
je 0xe0e9b
movl -0x268(%rbp), %eax
cmpl 0xba130(%rip), %eax     # 0x19afc0
jne 0xe0eaa
cmpl $0x0, -0x264(%rbp)
jne 0xe0eaa
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
cmpl $0x1, -0x268(%rbp)
jne 0xe0ec1
movl -0x264(%rbp), %eax
cmpl 0xba109(%rip), %eax     # 0x19afc8
je 0xe0f10
cmpl $0x0, -0x268(%rbp)
jne 0xe0edd
movl -0x264(%rbp), %eax
movl 0xba0f2(%rip), %ecx     # 0x19afc8
subl $0x1, %ecx
cmpl %ecx, %eax
je 0xe0f10
movl -0x268(%rbp), %eax
movl 0xba0d7(%rip), %ecx     # 0x19afc0
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xe0ef9
cmpl $0x0, -0x264(%rbp)
je 0xe0f10
movl -0x268(%rbp), %eax
cmpl 0xba0bb(%rip), %eax     # 0x19afc0
jne 0xe0f1f
cmpl $0x1, -0x264(%rbp)
jne 0xe0f1f
movl -0x1b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b8(%rbp)
movl 0xba09b(%rip), %eax     # 0x19afc0
subl -0x268(%rbp), %eax
movl %eax, -0x374(%rbp)
movl 0xba091(%rip), %eax     # 0x19afc8
subl -0x264(%rbp), %eax
movl %eax, -0x378(%rbp)
movl -0x268(%rbp), %eax
cmpl -0x374(%rbp), %eax
jl 0xe0fa7
leaq -0x268(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
callq 0x6b600
jmp 0xe0f66
leaq -0x200(%rbp), %rdi
leaq -0x374(%rbp), %rsi
callq 0x6b600
jmp 0xe0f7b
leaq -0x264(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x6b600
jmp 0xe0f90
leaq -0x230(%rbp), %rdi
leaq -0x378(%rbp), %rsi
callq 0x6b600
jmp 0xe0fa5
jmp 0xe0ffd
leaq -0x1e8(%rbp), %rdi
leaq -0x374(%rbp), %rsi
callq 0x6b600
jmp 0xe0fbc
leaq -0x268(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x6b600
jmp 0xe0fd1
leaq -0x218(%rbp), %rdi
leaq -0x378(%rbp), %rsi
callq 0x6b600
jmp 0xe0fe6
leaq -0x264(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x6b600
jmp 0xe0ffb
jmp 0xe0ffd
cmpl $0x0, -0x268(%rbp)
jne 0xe1013
cmpl $0x0, -0x264(%rbp)
je 0xe10e3
cmpl $0x0, -0x374(%rbp)
jne 0xe1029
cmpl $0x0, -0x378(%rbp)
je 0xe10e3
movl 0xb9f91(%rip), %eax     # 0x19afc0
addl 0xb9f93(%rip), %eax     # 0x19afc8
cmpl $0x3c, %eax
jg 0xe10aa
movl -0x374(%rbp), %esi
movl -0x268(%rbp), %edi
movl -0x264(%rbp), %edx
movl -0x378(%rbp), %ecx
callq 0xe3bd0
movsd %xmm0, -0x4f0(%rbp)
jmp 0xe1061
movsd -0x4f0(%rbp), %xmm0
movsd %xmm0, -0x250(%rbp)
movl -0x374(%rbp), %esi
movl -0x268(%rbp), %edi
movl -0x264(%rbp), %edx
movl -0x378(%rbp), %ecx
callq 0xe4200
movsd %xmm0, -0x4f8(%rbp)
jmp 0xe1098
movsd -0x4f8(%rbp), %xmm0
movsd %xmm0, -0x248(%rbp)
jmp 0xe10e1
movl -0x374(%rbp), %esi
movl -0x268(%rbp), %edi
movl -0x264(%rbp), %edx
movl -0x378(%rbp), %ecx
callq 0xe4200
movsd %xmm0, -0x500(%rbp)
jmp 0xe10d1
movsd -0x500(%rbp), %xmm0
movsd %xmm0, -0x248(%rbp)
jmp 0xe10e3
movsd -0x250(%rbp), %xmm1
movsd 0xb9ec5(%rip), %xmm0    # 0x19afb8
ucomisd %xmm1, %xmm0
ja 0xe1113
movsd -0x248(%rbp), %xmm1
movsd 0xb9eaf(%rip), %xmm0    # 0x19afb8
ucomisd %xmm1, %xmm0
jbe 0xe1295
movq -0xa0(%rbp), %rdi
movsd -0x250(%rbp), %xmm0
callq 0xabd0
movq %rax, -0x508(%rbp)
jmp 0xe1130
movq -0x508(%rbp), %rdi
leaq 0x54da0(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x510(%rbp)
jmp 0xe114c
movq -0x510(%rbp), %rdi
movsd -0x248(%rbp), %xmm0
callq 0xabd0
movq %rax, -0x518(%rbp)
jmp 0xe1169
movq -0x518(%rbp), %rdi
leaq 0x54d67(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x520(%rbp)
jmp 0xe1185
movq -0x520(%rbp), %rdi
movl -0x268(%rbp), %esi
callq 0xab20
movq %rax, -0x528(%rbp)
jmp 0xe11a0
movq -0x528(%rbp), %rdi
leaq 0x54d30(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x530(%rbp)
jmp 0xe11bc
movq -0x530(%rbp), %rdi
movl -0x374(%rbp), %esi
callq 0xab20
movq %rax, -0x538(%rbp)
jmp 0xe11d7
movq -0x538(%rbp), %rdi
leaq 0x54cf9(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x540(%rbp)
jmp 0xe11f3
movq -0x540(%rbp), %rdi
movl -0x264(%rbp), %esi
callq 0xab20
movq %rax, -0x548(%rbp)
jmp 0xe120e
movq -0x548(%rbp), %rdi
leaq 0x54cc2(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x550(%rbp)
jmp 0xe122a
movq -0x550(%rbp), %rdi
movl -0x378(%rbp), %esi
callq 0xab20
movq %rax, -0x558(%rbp)
jmp 0xe1245
movq -0x558(%rbp), %rdi
leaq 0x54c8b(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x560(%rbp)
jmp 0xe1261
movq -0x560(%rbp), %rdi
movsd -0x330(%rbp), %xmm0
callq 0xabd0
movq %rax, -0x568(%rbp)
jmp 0xe127e
movq -0x568(%rbp), %rdi
movq 0xb7cfc(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe1293
jmp 0xe1295
jmp 0xe0b84
leaq -0x178(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0xd9b50
movsd %xmm0, -0x570(%rbp)
jmp 0xe12b7
movsd -0x570(%rbp), %xmm0
movsd %xmm0, -0x380(%rbp)
movq 0xb7d22(%rip), %rdi     # 0x198ff0
leaq 0x66a27(%rip), %rsi     # 0x147cfc
callq 0xa5c0
movq %rax, -0x578(%rbp)
jmp 0xe12e3
movq -0x578(%rbp), %rdi
movsd -0x380(%rbp), %xmm0
callq 0xabd0
movq %rax, -0x580(%rbp)
jmp 0xe1300
movq -0x580(%rbp), %rdi
movq 0xb7c7a(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe1315
movq 0xb7cd4(%rip), %rdi     # 0x198ff0
leaq 0x66b59(%rip), %rsi     # 0x147e7c
callq 0xa5c0
movq %rax, -0x588(%rbp)
jmp 0xe1331
movq -0x588(%rbp), %rdi
movl -0x1b4(%rbp), %esi
callq 0xab20
movq %rax, -0x590(%rbp)
jmp 0xe134c
movq -0x590(%rbp), %rdi
movq 0xb7c2e(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe1361
movq 0xb7c88(%rip), %rdi     # 0x198ff0
leaq 0x66b1b(%rip), %rsi     # 0x147e8a
callq 0xa5c0
movq %rax, -0x598(%rbp)
jmp 0xe137d
movq -0x598(%rbp), %rdi
movl -0x1b8(%rbp), %esi
callq 0xab20
movq %rax, -0x5a0(%rbp)
jmp 0xe1398
movq -0x5a0(%rbp), %rdi
movq 0xb7be2(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe13ad
movq 0xb7c3c(%rip), %rdi     # 0x198ff0
leaq 0x66add(%rip), %rsi     # 0x147e98
callq 0xa5c0
movq %rax, -0x5a8(%rbp)
jmp 0xe13c9
leaq -0x398(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x4cf20
jmp 0xe13de
leaq -0x398(%rbp), %rdi
callq 0xca0f0
movsd %xmm0, -0x5b0(%rbp)
jmp 0xe13f4
movq -0x5a8(%rbp), %rdi
movsd -0x5b0(%rbp), %xmm0
cvtsi2sdl 0xb9bb5(%rip), %xmm1 # 0x19afc0
divsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x5b8(%rbp)
jmp 0xe141d
movq -0x5b8(%rbp), %rdi
leaq 0x54ab3(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x5c0(%rbp)
jmp 0xe1439
leaq -0x3b0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x4cf20
jmp 0xe144e
leaq -0x3b0(%rbp), %rdi
callq 0xca0f0
movsd %xmm0, -0x5c8(%rbp)
jmp 0xe1464
movq -0x5c0(%rbp), %rdi
movsd -0x5c8(%rbp), %xmm0
cvtsi2sdl 0xb9b45(%rip), %xmm1 # 0x19afc0
divsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x5d0(%rbp)
jmp 0xe148d
movq -0x5d0(%rbp), %rdi
movq 0xb7aed(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe14a2
leaq -0x3b0(%rbp), %rdi
callq 0x48290
leaq -0x398(%rbp), %rdi
callq 0x48290
movq 0xb7b2f(%rip), %rdi     # 0x198ff0
leaq 0x669de(%rip), %rsi     # 0x147ea6
callq 0xa5c0
movq %rax, -0x5d8(%rbp)
jmp 0xe14d6
leaq -0x3c8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x4cf20
jmp 0xe14eb
leaq -0x3c8(%rbp), %rdi
callq 0xca0f0
movsd %xmm0, -0x5e0(%rbp)
jmp 0xe1501
movq -0x5d8(%rbp), %rdi
movsd -0x5e0(%rbp), %xmm0
cvtsi2sdl 0xb9ab0(%rip), %xmm1 # 0x19afc8
divsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x5e8(%rbp)
jmp 0xe152a
movq -0x5e8(%rbp), %rdi
leaq 0x549a6(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x5f0(%rbp)
jmp 0xe1546
leaq -0x3e0(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x4cf20
jmp 0xe155b
leaq -0x3e0(%rbp), %rdi
callq 0xca0f0
movsd %xmm0, -0x5f8(%rbp)
jmp 0xe1571
movq -0x5f0(%rbp), %rdi
movsd -0x5f8(%rbp), %xmm0
cvtsi2sdl 0xb9a40(%rip), %xmm1 # 0x19afc8
divsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x600(%rbp)
jmp 0xe159a
movq -0x600(%rbp), %rdi
movq 0xb79e0(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xe15af
leaq -0x3e0(%rbp), %rdi
callq 0x48290
leaq -0x3c8(%rbp), %rdi
callq 0x48290
leaq -0x328(%rbp), %rdi
callq 0xe3ad0
leaq -0x230(%rbp), %rdi
callq 0x48290
leaq -0x218(%rbp), %rdi
callq 0x48290
leaq -0x200(%rbp), %rdi
callq 0x48290
leaq -0x1e8(%rbp), %rdi
callq 0x48290
leaq -0x1d0(%rbp), %rdi
callq 0x3ecb0
leaq -0x1b0(%rbp), %rdi
callq 0xac88
leaq -0x190(%rbp), %rdi
callq 0x3ecb0
leaq -0x178(%rbp), %rdi
callq 0x3ecb0
leaq -0xd0(%rbp), %rdi
callq 0x48290
leaq -0xb8(%rbp), %rdi
callq 0x48290
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x38(%rbp), %rdi
callq 0xac88
addq $0x600, %rsp            # imm = 0x600
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe168c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0x48290
leaq -0x398(%rbp), %rdi
callq 0x48290
jmp 0xe16cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0xe16c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0x48290
leaq -0x3c8(%rbp), %rdi
callq 0x48290
leaq -0x328(%rbp), %rdi
callq 0xe3ad0
leaq -0x230(%rbp), %rdi
callq 0x48290
leaq -0x218(%rbp), %rdi
callq 0x48290
leaq -0x200(%rbp), %rdi
callq 0x48290
leaq -0x1e8(%rbp), %rdi
callq 0x48290
leaq -0x1d0(%rbp), %rdi
callq 0x3ecb0
leaq -0x1b0(%rbp), %rdi
callq 0xac88
leaq -0x190(%rbp), %rdi
callq 0x3ecb0
leaq -0x178(%rbp), %rdi
callq 0x3ecb0
leaq -0xd0(%rbp), %rdi
callq 0x48290
leaq -0xb8(%rbp), %rdi
callq 0x48290
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x38(%rbp), %rdi
callq 0xac88
movq -0x10(%rbp), %rdi
callq 0xab50
nopl (%rax,%rax)