// File: millanek[P]evo/evo_diversity_subsampling.cpp
// Function: subsamplingDxy(int, char**)
int subsamplingDxy(int argc, char** argv) {
    parseSubsamplingDxyOptions(argc, argv);
    
    // Load up the intervals file
    std::ifstream* bedFile = new std::ifstream(opt::bedFile.c_str());
    std::map<int, string> linearToGenomeMap;
    std::cerr << "Loading coordinates from the bed file " << opt::bedFile << std::endl;
    LinkedCoordsBed coords;
    if (!opt::bElements) {
        SimpleCoordsBed simpleCoords(bedFile, linearToGenomeMap);
    } else {
        coords = LinkedCoordsBed(bedFile);
    }
    std::cerr << "Done" << std::endl;
    
    // Load up the VCF file:
    std::istream* vcfFile = createReader(opt::vcfFile.c_str());
    string line; std::unordered_map<string, Counts> vcfCountsMap;
    std::unordered_map<string, double> vcfDxyMap;
    std::unordered_map<string, double> vcfInbreedingPvalMap;
    
    std::cerr << "Loading variants from the VCF file " << opt::vcfFile << std::endl;
    double totalDxySum = 0;
    while (getline(*vcfFile, line)) {
        if (line[0] == '#' && line[1] == '#') {
        
        } else if (line[0] == '#' && line[1] == 'C') {
        
        } else {
            // totalVariantNumber++;
            //std::cerr << "Variant N:" << totalVariantNumber << std::endl;
            std::vector<std::string> fields = split(line, '\t');
            string scaffold = fields[0]; string pos = fields[1];
            Counts* counts = new Counts();
            getThisVariantCountsSimple(fields, counts);
            counts->inbreedingCoefficient = calculateInbreedingCoefficient(counts->individualsWithVariant);
            counts->chiSqPvalForInbreeding = calculateChiSqPvalForInbreeding(counts->individualsWithVariant);
            if (counts->inbreedingCoefficient < 0 && counts->chiSqPvalForInbreeding < 0.05) {
                std::cerr << "filtering out:" << std::endl;
                std::cerr << scaffold+"\t"+pos << std::endl;
                std::cerr << "counts.chiSqPvalForInbreeding: " << counts->chiSqPvalForInbreeding << std::endl;
                std::cerr << "counts.inbreedingCoefficient: " << counts->inbreedingCoefficient << std::endl;
                std::cerr << std::endl;
            } else {
                vcfCountsMap[scaffold+"\t"+pos] = *counts;
                double thisVariantDxy = calculateOverallDxy(*counts);
                totalDxySum = totalDxySum + thisVariantDxy;
                vcfDxyMap[scaffold+"\t"+pos] = thisVariantDxy;
            }
            delete counts;
        }
    }
    std::cerr << "Done" << std::endl;
    
    if (!opt::bElements) {
        int totalIntervalsLength = (int)linearToGenomeMap.size();
        std::cout << "Average Dxy = " << totalDxySum/totalIntervalsLength << std::endl;
        // Prepare the output file for subsamples of Dxy values
        size_t suffixPos = opt::bedFile.find_last_of('.');
        string outDxyFileName;
        if (suffixPos != std::string::npos) {
            outDxyFileName = opt::outFolder + stripExtension(opt::bedFile) + "_DxyVals_l" + numToString(opt::subsampleLength) + ".txt";
        } else {
            outDxyFileName = opt::outFolder + opt::bedFile + "_DxyVals_l" + numToString(opt::subsampleLength) + ".txt";
        }
        //std::cerr << "into: " << AAFileName << std::endl;
        std::ofstream* outDxyFile = new std::ofstream(outDxyFileName.c_str());
        
        
        // Subsampling:
        int numSubsamplesToDo = totalIntervalsLength/opt::subsampleLength;
        std::mt19937_64 rng; // random number generator
        rng.seed();
        std::uniform_int_distribution<int> distribution(0,totalIntervalsLength);
        std::cerr << "Now running subsamples to be written into: " << outDxyFileName << std::endl;
        for (int i = 0; i < numSubsamplesToDo; i++) {
            if (i % 10000 == 0) {
                std::cerr << "Subsample " << i << " out of " << numSubsamplesToDo << std::endl;
            }
            double subsampleDxyTotal = 0;
            for (int j = 0; j < opt::subsampleLength; j++) {
                int linearIndex = distribution(rng);
                string genomeLocation = linearToGenomeMap[linearIndex];
                if (vcfDxyMap.count(genomeLocation) == 1) {
                    subsampleDxyTotal = subsampleDxyTotal + vcfDxyMap[genomeLocation];
                }
            }
            *outDxyFile << subsampleDxyTotal/opt::subsampleLength << std::endl;
        }
    } else {
        string outDxyFileName;
        size_t suffixPos = opt::bedFile.find_last_of('.');
        if (suffixPos != std::string::npos) {
            outDxyFileName = opt::outFolder + stripExtension(opt::bedFile) + "_DxyVals_perElement.txt";
        } else {
            outDxyFileName = opt::outFolder + opt::bedFile + "_DxyVals_perElement.txt";
        } std::ofstream* outDxyFile = new std::ofstream(outDxyFileName.c_str());
        
        std::cerr << "Now calculating Dxy values per element to be written out into: " << outDxyFileName << std::endl;
        std::vector<double> elementDxyValues = coords.getMeanPerElement(vcfDxyMap);
        std::cerr << "Calculations done" << std::endl;
        std::vector<string> elementNames = coords.getElementNames();
        std::vector<std::vector<string> > elementOuterBounds = coords.getElementOuterBoundaries();
        for (int i = 0; i < (int)elementDxyValues.size(); i++) {
            *outDxyFile << elementOuterBounds[i][0] << "\t" << elementOuterBounds[i][1] << "\t" << elementOuterBounds[i][2] << "\t" << elementNames[i] << "\t" << elementDxyValues[i] << std::endl;
        }
    }
    std::cerr << "Done" << std::endl;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1180, %rsp           # imm = 0x1180
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x3d4b0
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0xf88(%rbp)
movq %rax, -0xf90(%rbp)
leaq 0x15dd8b(%rip), %rdi    # 0x199c48
callq 0xa220
movq -0xf88(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0x3bed8
movq -0xf90(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3d7b0
movq 0x15d0fd(%rip), %rdi    # 0x198ff0
leaq 0xf63ce(%rip), %rsi     # 0x1322c8
callq 0xa5c0
movq %rax, -0xf98(%rbp)
jmp 0x3bf08
movq -0xf98(%rbp), %rdi
leaq 0x15dd32(%rip), %rsi    # 0x199c48
callq 0xa520
movq %rax, -0xfa0(%rbp)
jmp 0x3bf24
movq -0xfa0(%rbp), %rdi
movq 0x15d056(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3bf39
leaq -0x70(%rbp), %rdi
callq 0x3d7d0
jmp 0x3bf44
testb $0x1, 0x15dd5d(%rip)    # 0x199ca8
jne 0x3bfa6
leaq -0x71(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x3d7f0
jmp 0x3bf60
jmp 0x3bfd4
movq -0xf90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0x3d4a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d499
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d490
leaq -0x90(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3d830
jmp 0x3bfb8
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3d8b0
leaq -0x90(%rbp), %rdi
callq 0x3d8e0
movq 0x15d015(%rip), %rdi    # 0x198ff0
leaq 0xf630d(%rip), %rsi     # 0x1322ef
callq 0xa5c0
movq %rax, -0xfa8(%rbp)
jmp 0x3bff0
movq -0xfa8(%rbp), %rdi
movq 0x15cf8a(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c005
leaq 0x15dc5c(%rip), %rdi    # 0x199c68
callq 0xa220
movq %rax, -0xfb8(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0xfb0(%rbp)
callq 0xab60
movq -0xfb8(%rbp), %rsi
movq -0xfb0(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x2d6c0
jmp 0x3c047
leaq -0xb8(%rbp), %rdi
movl $0x8, %esi
callq 0x80e30
movq %rax, -0xfc0(%rbp)
jmp 0x3c061
leaq -0xb8(%rbp), %rdi
callq 0xac88
leaq -0xb9(%rbp), %rdi
callq 0xa640
movq -0xfc0(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xa820
leaq -0x118(%rbp), %rdi
callq 0x3d900
leaq -0x150(%rbp), %rdi
callq 0x3d920
leaq -0x188(%rbp), %rdi
callq 0x3d920
movq 0x15cf32(%rip), %rdi    # 0x198ff0
leaq 0xf622f(%rip), %rsi     # 0x1322f4
callq 0xa5c0
movq %rax, -0xfc8(%rbp)
jmp 0x3c0d3
movq -0xfc8(%rbp), %rdi
leaq 0x15db87(%rip), %rsi    # 0x199c68
callq 0xa520
movq %rax, -0xfd0(%rbp)
jmp 0x3c0ef
movq -0xfd0(%rbp), %rdi
movq 0x15ce8b(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c104
xorps %xmm0, %xmm0
movsd %xmm0, -0x190(%rbp)
movq -0x98(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xa0d0
movq %rax, -0xfd8(%rbp)
jmp 0x3c12b
movq -0xfd8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0xfd9(%rbp)
jmp 0x3c149
movb -0xfd9(%rbp), %al
testb $0x1, %al
jne 0x3c158
jmp 0x3c7c8
xorl %eax, %eax
movl %eax, %esi
leaq -0xe0(%rbp), %rdi
callq 0xac60
movq %rax, -0xfe8(%rbp)
jmp 0x3c171
movq -0xfe8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x3c1f6
leaq -0xe0(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0xff0(%rbp)
jmp 0x3c19a
movq -0xff0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x3c1f6
jmp 0x3c7c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c1d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xac88
leaq -0xb9(%rbp), %rdi
callq 0xa640
jmp 0x3d490
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d460
xorl %eax, %eax
movl %eax, %esi
leaq -0xe0(%rbp), %rdi
callq 0xac60
movq %rax, -0xff8(%rbp)
jmp 0x3c20f
movq -0xff8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x3c24c
leaq -0xe0(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0x1000(%rbp)
jmp 0x3c238
movq -0x1000(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x43, %eax
jne 0x3c24c
jmp 0x3c7c1
leaq -0x1a8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0x3c266
xorl %eax, %eax
movl %eax, %esi
leaq -0x1a8(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xa250
jmp 0x3c287
leaq -0x1a8(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rsi
leaq -0x1e8(%rbp), %rdi
callq 0xa250
jmp 0x3c2a9
movl $0x100, %edi            # imm = 0x100
callq 0xa5d0
movq %rax, -0x1008(%rbp)
jmp 0x3c2bc
movq -0x1008(%rbp), %rdi
callq 0x3d960
jmp 0x3c2ca
movq -0x1008(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x7cec0
jmp 0x3c2ed
movq -0x1f0(%rbp), %rdi
addq $0x70, %rdi
callq 0x7bfe0
movsd %xmm0, -0x1010(%rbp)
jmp 0x3c307
movsd -0x1010(%rbp), %xmm0
movq -0x1f0(%rbp), %rax
movsd %xmm0, 0x58(%rax)
movq -0x1f0(%rbp), %rdi
addq $0x70, %rdi
callq 0x7c190
movsd %xmm0, -0x1018(%rbp)
jmp 0x3c335
movsd -0x1018(%rbp), %xmm0
movq -0x1f0(%rbp), %rax
movsd %xmm0, 0x60(%rax)
movq -0x1f0(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd 0x58(%rax), %xmm0
jbe 0x3c574
movq -0x1f0(%rbp), %rax
movsd 0xf5f43(%rip), %xmm0    # 0x1322b0
ucomisd 0x60(%rax), %xmm0
jbe 0x3c574
movq 0x15cc71(%rip), %rdi    # 0x198ff0
leaq 0xf5f92(%rip), %rsi     # 0x132318
callq 0xa5c0
movq %rax, -0x1020(%rbp)
jmp 0x3c394
movq -0x1020(%rbp), %rdi
movq 0x15cbe6(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c3a9
leaq 0xf9b2e(%rip), %rdx     # 0x135ede
leaq -0x230(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x3da80
jmp 0x3c3c5
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x3da30
jmp 0x3c3e1
movq 0x15cc08(%rip), %rdi    # 0x198ff0
leaq -0x210(%rbp), %rsi
callq 0xa520
movq %rax, -0x1028(%rbp)
jmp 0x3c3fd
movq -0x1028(%rbp), %rdi
movq 0x15cb7d(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c412
leaq -0x210(%rbp), %rdi
callq 0xac88
leaq -0x230(%rbp), %rdi
callq 0xac88
movq 0x15cbbf(%rip), %rdi    # 0x198ff0
leaq 0xf5eef(%rip), %rsi     # 0x132327
callq 0xa5c0
movq %rax, -0x1030(%rbp)
jmp 0x3c446
movq -0x1030(%rbp), %rdi
movq -0x1f0(%rbp), %rax
movsd 0x60(%rax), %xmm0
callq 0xabd0
movq %rax, -0x1038(%rbp)
jmp 0x3c467
movq -0x1038(%rbp), %rdi
movq 0x15cb13(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c47c
movq 0x15cb6d(%rip), %rdi    # 0x198ff0
leaq 0xf5ebd(%rip), %rsi     # 0x132347
callq 0xa5c0
movq %rax, -0x1040(%rbp)
jmp 0x3c498
movq -0x1040(%rbp), %rdi
movq -0x1f0(%rbp), %rax
movsd 0x58(%rax), %xmm0
callq 0xabd0
movq %rax, -0x1048(%rbp)
jmp 0x3c4b9
movq -0x1048(%rbp), %rdi
movq 0x15cac1(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c4ce
movq 0x15cb1b(%rip), %rdi    # 0x198ff0
movq 0x15caac(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c4e3
jmp 0x3c741
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c7b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c7a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c798
movq -0x1008(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x100, %esi            # imm = 0x100
callq 0xa5e0
jmp 0x3c798
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c563
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x210(%rbp), %rdi
callq 0xac88
leaq -0x230(%rbp), %rdi
callq 0xac88
jmp 0x3c798
movq -0x1f0(%rbp), %rax
movq %rax, -0x1050(%rbp)
leaq 0xf9955(%rip), %rdx     # 0x135ede
leaq -0x270(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x3da80
jmp 0x3c59e
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x3da30
jmp 0x3c5ba
leaq -0x118(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x3db00
movq %rax, -0x1058(%rbp)
jmp 0x3c5d6
movq -0x1050(%rbp), %rsi
movq -0x1058(%rbp), %rdi
callq 0x3db30
jmp 0x3c5eb
leaq -0x250(%rbp), %rdi
callq 0xac88
leaq -0x270(%rbp), %rdi
callq 0xac88
movq -0x1f0(%rbp), %rdi
callq 0x3dc40
movsd %xmm0, -0x1060(%rbp)
jmp 0x3c619
movsd -0x1060(%rbp), %xmm0
movsd %xmm0, -0x278(%rbp)
movsd -0x190(%rbp), %xmm0
movsd -0x278(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x190(%rbp)
movsd -0x278(%rbp), %xmm0
movsd %xmm0, -0x1068(%rbp)
leaq 0xf9882(%rip), %rdx     # 0x135ede
leaq -0x2b8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x3da80
jmp 0x3c671
leaq -0x298(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x3da30
jmp 0x3c68d
leaq -0x150(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x3def0
movq %rax, -0x1070(%rbp)
jmp 0x3c6a9
movq -0x1070(%rbp), %rax
movsd -0x1068(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x298(%rbp), %rdi
callq 0xac88
leaq -0x2b8(%rbp), %rdi
callq 0xac88
jmp 0x3c741
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c6fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x250(%rbp), %rdi
callq 0xac88
leaq -0x270(%rbp), %rdi
callq 0xac88
jmp 0x3c798
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3c733
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x298(%rbp), %rdi
callq 0xac88
leaq -0x2b8(%rbp), %rdi
callq 0xac88
jmp 0x3c798
movq -0x1f0(%rbp), %rax
movq %rax, -0x1078(%rbp)
cmpq $0x0, %rax
je 0x3c772
movq -0x1078(%rbp), %rdi
callq 0x3df20
movq -0x1078(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0xa5e0
leaq -0x1e8(%rbp), %rdi
callq 0xac88
leaq -0x1c8(%rbp), %rdi
callq 0xac88
leaq -0x1a8(%rbp), %rdi
callq 0x3dfa0
jmp 0x3c7c1
leaq -0x1e8(%rbp), %rdi
callq 0xac88
leaq -0x1c8(%rbp), %rdi
callq 0xac88
leaq -0x1a8(%rbp), %rdi
callq 0x3dfa0
jmp 0x3d460
jmp 0x3c7c3
jmp 0x3c10f
movq 0x15c821(%rip), %rdi    # 0x198ff0
leaq 0xf5b19(%rip), %rsi     # 0x1322ef
callq 0xa5c0
movq %rax, -0x1080(%rbp)
jmp 0x3c7e4
movq -0x1080(%rbp), %rdi
movq 0x15c796(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c7f9
testb $0x1, 0x15d4a8(%rip)    # 0x199ca8
jne 0x3cece
leaq -0x58(%rbp), %rdi
callq 0x3e000
movl %eax, -0x2bc(%rbp)
movq 0x15c79c(%rip), %rdi    # 0x198fb8
leaq 0xf5b43(%rip), %rsi     # 0x132366
callq 0xa5c0
movq %rax, -0x1088(%rbp)
jmp 0x3c831
movq -0x1088(%rbp), %rdi
movsd -0x190(%rbp), %xmm0
cvtsi2sdl -0x2bc(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x1090(%rbp)
jmp 0x3c85a
movq -0x1090(%rbp), %rdi
movq 0x15c720(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3c86f
leaq 0x15d3d2(%rip), %rdi    # 0x199c48
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0xabf0
movq %rax, -0x2c8(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0xa820
cmpq $-0x1, -0x2c8(%rbp)
je 0x3ca37
leaq 0x15d399(%rip), %rsi    # 0x199c48
leaq -0x388(%rbp), %rdi
callq 0x7be70
jmp 0x3c8bd
leaq 0x15d3c4(%rip), %rsi    # 0x199c88
leaq -0x368(%rbp), %rdi
leaq -0x388(%rbp), %rdx
callq 0x3e140
jmp 0x3c8d9
leaq 0xf5a95(%rip), %rdx     # 0x132375
leaq -0x348(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0x3e020
jmp 0x3c8f5
movl 0x15cd95(%rip), %esi    # 0x199690
leaq -0x3a8(%rbp), %rdi
callq 0x3e190
jmp 0x3c909
leaq -0x328(%rbp), %rdi
leaq -0x348(%rbp), %rsi
leaq -0x3a8(%rbp), %rdx
callq 0x3e070
jmp 0x3c925
leaq 0x10cc7b(%rip), %rdx    # 0x1495a7
leaq -0x308(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x3e020
jmp 0x3c941
leaq -0x2e8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0xa710
leaq -0x308(%rbp), %rdi
callq 0xac88
leaq -0x328(%rbp), %rdi
callq 0xac88
leaq -0x3a8(%rbp), %rdi
callq 0xac88
leaq -0x348(%rbp), %rdi
callq 0xac88
leaq -0x368(%rbp), %rdi
callq 0xac88
leaq -0x388(%rbp), %rdi
callq 0xac88
jmp 0x3cb77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3cebd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3ca26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3ca1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3ca0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3ca02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x328(%rbp), %rdi
callq 0xac88
leaq -0x3a8(%rbp), %rdi
callq 0xac88
leaq -0x348(%rbp), %rdi
callq 0xac88
leaq -0x368(%rbp), %rdi
callq 0xac88
leaq -0x388(%rbp), %rdi
callq 0xac88
jmp 0x3cebd
leaq 0x15d24a(%rip), %rsi    # 0x199c88
leaq 0x15d203(%rip), %rdx    # 0x199c48
leaq -0x428(%rbp), %rdi
callq 0x3e290
jmp 0x3ca53
leaq 0xf591b(%rip), %rdx     # 0x132375
leaq -0x408(%rbp), %rdi
leaq -0x428(%rbp), %rsi
callq 0x3e020
jmp 0x3ca6f
movl 0x15cc1b(%rip), %esi    # 0x199690
leaq -0x448(%rbp), %rdi
callq 0x3e190
jmp 0x3ca83
leaq -0x3e8(%rbp), %rdi
leaq -0x408(%rbp), %rsi
leaq -0x448(%rbp), %rdx
callq 0x3e070
jmp 0x3ca9f
leaq 0x10cb01(%rip), %rdx    # 0x1495a7
leaq -0x3c8(%rbp), %rdi
leaq -0x3e8(%rbp), %rsi
callq 0x3e020
jmp 0x3cabb
leaq -0x2e8(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0xa710
leaq -0x3c8(%rbp), %rdi
callq 0xac88
leaq -0x3e8(%rbp), %rdi
callq 0xac88
leaq -0x448(%rbp), %rdi
callq 0xac88
leaq -0x408(%rbp), %rdi
callq 0xac88
leaq -0x428(%rbp), %rdi
callq 0xac88
jmp 0x3cb77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3cb66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3cb5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3cb4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x3e8(%rbp), %rdi
callq 0xac88
leaq -0x448(%rbp), %rdi
callq 0xac88
leaq -0x408(%rbp), %rdi
callq 0xac88
leaq -0x428(%rbp), %rdi
callq 0xac88
jmp 0x3cebd
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x1098(%rbp)
jmp 0x3cb8a
leaq -0x2e8(%rbp), %rdi
callq 0xa220
movq -0x1098(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0xa650
jmp 0x3cbac
movq -0x1098(%rbp), %rax
movq %rax, -0x450(%rbp)
movl -0x2bc(%rbp), %eax
movl 0x15caca(%rip), %ecx    # 0x199690
cltd
idivl %ecx
movl %eax, -0x454(%rbp)
leaq -0xe20(%rbp), %rdi
callq 0x3e310
jmp 0x3cbdd
leaq -0xe20(%rbp), %rdi
movl $0x1571, %esi           # imm = 0x1571
callq 0x3e330
jmp 0x3cbf0
movl -0x2bc(%rbp), %edx
leaq -0xe28(%rbp), %rdi
xorl %esi, %esi
callq 0x3e3f0
jmp 0x3cc06
movq 0x15c3e3(%rip), %rdi    # 0x198ff0
leaq 0xf576c(%rip), %rsi     # 0x132380
callq 0xa5c0
movq %rax, -0x10a0(%rbp)
jmp 0x3cc22
movq -0x10a0(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0xa520
movq %rax, -0x10a8(%rbp)
jmp 0x3cc3e
movq -0x10a8(%rbp), %rdi
movq 0x15c33c(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3cc53
movl $0x0, -0xe2c(%rbp)
movl -0xe2c(%rbp), %eax
cmpl -0x454(%rbp), %eax
jge 0x3ceac
movl -0xe2c(%rbp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x3cd2d
movq 0x15c363(%rip), %rdi    # 0x198ff0
leaq 0xf5718(%rip), %rsi     # 0x1323ac
callq 0xa5c0
movq %rax, -0x10b0(%rbp)
jmp 0x3cca2
movq -0x10b0(%rbp), %rdi
movl -0xe2c(%rbp), %esi
callq 0xab20
movq %rax, -0x10b8(%rbp)
jmp 0x3ccbd
movq -0x10b8(%rbp), %rdi
leaq 0xf56ec(%rip), %rsi     # 0x1323b7
callq 0xa5c0
movq %rax, -0x10c0(%rbp)
jmp 0x3ccd9
movq -0x10c0(%rbp), %rdi
movl -0x454(%rbp), %esi
callq 0xab20
movq %rax, -0x10c8(%rbp)
jmp 0x3ccf4
movq -0x10c8(%rbp), %rdi
movq 0x15c286(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3cd09
jmp 0x3cd2d
movq -0x1098(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0x3cebd
xorps %xmm0, %xmm0
movsd %xmm0, -0xe38(%rbp)
movl $0x0, -0xe3c(%rbp)
movl -0xe3c(%rbp), %eax
cmpl 0x15c942(%rip), %eax    # 0x199690
jge 0x3ce58
leaq -0xe28(%rbp), %rdi
leaq -0xe20(%rbp), %rsi
callq 0x3e420
movl %eax, -0x10cc(%rbp)
jmp 0x3cd6f
movl -0x10cc(%rbp), %eax
movl %eax, -0xe40(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0xe40(%rbp), %rsi
callq 0x3e450
movq %rax, -0x10d8(%rbp)
jmp 0x3cd94
movq -0x10d8(%rbp), %rsi
leaq -0xe60(%rbp), %rdi
callq 0xa250
jmp 0x3cda9
leaq -0x150(%rbp), %rdi
leaq -0xe60(%rbp), %rsi
callq 0x3e530
movq %rax, -0x10e0(%rbp)
jmp 0x3cdc5
movq -0x10e0(%rbp), %rax
cmpq $0x1, %rax
jne 0x3ce38
movsd -0xe38(%rbp), %xmm0
movsd %xmm0, -0x10f0(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0xe60(%rbp), %rsi
callq 0x3e560
movq %rax, -0x10e8(%rbp)
jmp 0x3cdfe
movq -0x10e8(%rbp), %rax
movsd -0x10f0(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, -0xe38(%rbp)
jmp 0x3ce38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xe60(%rbp), %rdi
callq 0xac88
jmp 0x3cebd
leaq -0xe60(%rbp), %rdi
callq 0xac88
movl -0xe3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe3c(%rbp)
jmp 0x3cd42
movq -0x450(%rbp), %rdi
movsd -0xe38(%rbp), %xmm0
cvtsi2sdl 0x15c821(%rip), %xmm1 # 0x199690
divsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x10f8(%rbp)
jmp 0x3ce81
movq -0x10f8(%rbp), %rdi
movq 0x15c0f9(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3ce96
jmp 0x3ce98
movl -0xe2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe2c(%rbp)
jmp 0x3cc5d
leaq -0x2e8(%rbp), %rdi
callq 0xac88
jmp 0x3d3e2
leaq -0x2e8(%rbp), %rdi
callq 0xac88
jmp 0x3d460
leaq -0xe80(%rbp), %rdi
callq 0xa820
leaq 0x15cd67(%rip), %rdi    # 0x199c48
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0xabf0
movq %rax, -0xe88(%rbp)
cmpq $-0x1, -0xe88(%rbp)
je 0x3cfd8
leaq 0x15cd3a(%rip), %rsi    # 0x199c48
leaq -0xee8(%rbp), %rdi
callq 0x7be70
jmp 0x3cf1c
leaq 0x15cd65(%rip), %rsi    # 0x199c88
leaq -0xec8(%rbp), %rdi
leaq -0xee8(%rbp), %rdx
callq 0x3e140
jmp 0x3cf38
leaq 0xf5481(%rip), %rdx     # 0x1323c0
leaq -0xea8(%rbp), %rdi
leaq -0xec8(%rbp), %rsi
callq 0x3e020
jmp 0x3cf54
leaq -0xe80(%rbp), %rdi
leaq -0xea8(%rbp), %rsi
callq 0xa710
leaq -0xea8(%rbp), %rdi
callq 0xac88
leaq -0xec8(%rbp), %rdi
callq 0xac88
leaq -0xee8(%rbp), %rdi
callq 0xac88
jmp 0x3d05a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d3d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3cfc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xec8(%rbp), %rdi
callq 0xac88
leaq -0xee8(%rbp), %rdi
callq 0xac88
jmp 0x3d3d4
leaq 0x15cca9(%rip), %rsi    # 0x199c88
leaq 0x15cc62(%rip), %rdx    # 0x199c48
leaq -0xf28(%rbp), %rdi
callq 0x3e290
jmp 0x3cff4
leaq 0xf53c5(%rip), %rdx     # 0x1323c0
leaq -0xf08(%rbp), %rdi
leaq -0xf28(%rbp), %rsi
callq 0x3e020
jmp 0x3d010
leaq -0xe80(%rbp), %rdi
leaq -0xf08(%rbp), %rsi
callq 0xa710
leaq -0xf08(%rbp), %rdi
callq 0xac88
leaq -0xf28(%rbp), %rdi
callq 0xac88
jmp 0x3d05a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xf28(%rbp), %rdi
callq 0xac88
jmp 0x3d3d4
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x1100(%rbp)
jmp 0x3d06d
leaq -0xe80(%rbp), %rdi
callq 0xa220
movq -0x1100(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0xa650
jmp 0x3d08f
movq -0x1100(%rbp), %rax
movq %rax, -0xf30(%rbp)
movq 0x15bf4c(%rip), %rdi    # 0x198ff0
leaq 0xf532d(%rip), %rsi     # 0x1323d8
callq 0xa5c0
movq %rax, -0x1108(%rbp)
jmp 0x3d0b9
movq -0x1108(%rbp), %rdi
leaq -0xe80(%rbp), %rsi
callq 0xa520
movq %rax, -0x1110(%rbp)
jmp 0x3d0d5
movq -0x1110(%rbp), %rdi
movq 0x15bea5(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3d0ea
leaq -0xf48(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x3e590
jmp 0x3d103
movq 0x15bee6(%rip), %rdi    # 0x198ff0
leaq 0xf5307(%rip), %rsi     # 0x132418
callq 0xa5c0
movq %rax, -0x1118(%rbp)
jmp 0x3d11f
movq -0x1118(%rbp), %rdi
movq 0x15be5b(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3d134
leaq -0xf60(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3e960
jmp 0x3d146
leaq -0xf78(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3ea60
jmp 0x3d158
movl $0x0, -0xf7c(%rbp)
movl -0xf7c(%rbp), %eax
movl %eax, -0x111c(%rbp)
leaq -0xf48(%rbp), %rdi
callq 0x3ebf0
movq %rax, %rcx
movl -0x111c(%rbp), %eax
cmpl %ecx, %eax
jge 0x3d38a
movq -0xf30(%rbp), %rax
movq %rax, -0x1130(%rbp)
movslq -0xf7c(%rbp), %rsi
leaq -0xf78(%rbp), %rdi
callq 0x3ec10
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d940
movq -0x1130(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x1128(%rbp)
jmp 0x3d1d0
movq -0x1128(%rbp), %rdi
leaq 0xf8d00(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x1138(%rbp)
jmp 0x3d1ec
movslq -0xf7c(%rbp), %rsi
leaq -0xf78(%rbp), %rdi
callq 0x3ec10
movq %rax, %rdi
movl $0x1, %esi
callq 0x3d940
movq -0x1138(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x1140(%rbp)
jmp 0x3d224
movq -0x1140(%rbp), %rdi
leaq 0xf8cac(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x1148(%rbp)
jmp 0x3d240
movslq -0xf7c(%rbp), %rsi
leaq -0xf78(%rbp), %rdi
callq 0x3ec10
movq %rax, %rdi
movl $0x2, %esi
callq 0x3d940
movq -0x1148(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x1150(%rbp)
jmp 0x3d278
movq -0x1150(%rbp), %rdi
leaq 0xf8c58(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x1158(%rbp)
jmp 0x3d294
movslq -0xf7c(%rbp), %rsi
leaq -0xf60(%rbp), %rdi
callq 0x3d940
movq -0x1158(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x1160(%rbp)
jmp 0x3d2bf
movq -0x1160(%rbp), %rdi
leaq 0xf8c11(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x1168(%rbp)
jmp 0x3d2db
movslq -0xf7c(%rbp), %rsi
leaq -0xf48(%rbp), %rdi
callq 0x3ec30
movq -0x1168(%rbp), %rdi
movsd (%rax), %xmm0
callq 0xabd0
movq %rax, -0x1170(%rbp)
jmp 0x3d307
movq -0x1170(%rbp), %rdi
movq 0x15bc73(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3d31c
jmp 0x3d31e
movl -0xf7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf7c(%rbp)
jmp 0x3d162
movq -0x1100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0x3d3d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d3c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3d3bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xf78(%rbp), %rdi
callq 0x3ec50
jmp 0x3d3bc
leaq -0xf78(%rbp), %rdi
callq 0x3ec50
leaq -0xf60(%rbp), %rdi
callq 0x3dfa0
leaq -0xf48(%rbp), %rdi
callq 0x3ecb0
leaq -0xe80(%rbp), %rdi
callq 0xac88
jmp 0x3d3e2
leaq -0xf60(%rbp), %rdi
callq 0x3dfa0
leaq -0xf48(%rbp), %rdi
callq 0x3ecb0
leaq -0xe80(%rbp), %rdi
callq 0xac88
jmp 0x3d460
movq 0x15bc07(%rip), %rdi    # 0x198ff0
leaq 0xf4eff(%rip), %rsi     # 0x1322ef
callq 0xa5c0
movq %rax, -0x1178(%rbp)
jmp 0x3d3fe
movq -0x1178(%rbp), %rdi
movq 0x15bb7c(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3d413
leaq -0x188(%rbp), %rdi
callq 0x2d530
leaq -0x150(%rbp), %rdi
callq 0x2d530
leaq -0x118(%rbp), %rdi
callq 0x3ed10
leaq -0xe0(%rbp), %rdi
callq 0xac88
leaq -0x70(%rbp), %rdi
callq 0x3d8e0
leaq -0x58(%rbp), %rdi
callq 0x3ed30
xorl %eax, %eax
addq $0x1180, %rsp           # imm = 0x1180
popq %rbp
retq
leaq -0x188(%rbp), %rdi
callq 0x2d530
leaq -0x150(%rbp), %rdi
callq 0x2d530
leaq -0x118(%rbp), %rdi
callq 0x3ed10
leaq -0xe0(%rbp), %rdi
callq 0xac88
leaq -0x70(%rbp), %rdi
callq 0x3d8e0
leaq -0x58(%rbp), %rdi
callq 0x3ed30
movq -0x20(%rbp), %rdi
callq 0xab50
nopl (%rax,%rax)