// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]evo/process_vcf_search_sex.cpp
// Function: sexSearchMain(int, char**)
int sexSearchMain(int argc, char** argv) {
    parseSexSearchOptions(argc, argv);
    string fileRoot = stripExtension(opt::vcfFile);
    
    std::cerr << "Looking for the X and Y sex determining sequences using data from: " << opt::vcfFile << std::endl;
    std::cerr << "and male/female status defined in: " << opt::genderFile << std::endl;
    std::cerr << "The window width is: " << opt::window << " variants" << std::endl;
    
    // Open connections to read from the vcf and reference genome files
    std::ifstream* vcfFile = new std::ifstream(opt::vcfFile.c_str());
    std::ifstream* genderFile = new std::ifstream(opt::genderFile.c_str());
    
    string pValFileName = "sex_t_pvals_w" + numToString(opt::window) + ".txt";
    std::ofstream* pValFile = new std::ofstream(pValFileName.c_str());
    
    string maleString; string femaleString;
    getline(*genderFile, maleString);
    getline(*genderFile, femaleString);
    std::vector<string> males = split(maleString, ',');
    std::vector<string> females = split(femaleString, ',');
    std::sort(males.begin(),males.end());
    std::sort(females.begin(),females.end());
    
    
    // Prepare an object for output files
    
    string line;
    string currentScaffoldNum = "";
    string currentScaffoldReference;
    std::vector<string> sampleNames;
    string thisScaffoldName;
    std::vector<size_t> maleLoci;
    std::vector<size_t> femaleLoci;
    std::vector<SetDepths> setDepthsVector;
    std::vector<double> set1MeanDepths;
    std::vector<double> set2MeanDepths;
    unsigned int processedVariantCounter = 0;
    unsigned int regionStart = 1;
    std::vector<int> YlikeCounts;
    std::vector<int> nonZeroYlikeCounts;
    
    while (getline(*vcfFile, line)) {
        if (line[0] == '#' && line[1] == '#') {
            continue;
        } else if (line[0] == '#' && line[1] == 'C') {
            std::vector<std::string> fields = split(line, '\t');
            if (opt::sampleNameFile.empty()) {
                for (std::vector<std::string>::size_type i = NUM_NON_GENOTYPE_COLUMNS; i != fields.size(); i++) {
                    sampleNames.push_back(fields[i]);
                }
            } else {
                sampleNames = readSampleNamesFromTextFile(opt::sampleNameFile);
            }
            maleLoci = locateSet(sampleNames, males);
            femaleLoci = locateSet(sampleNames, females);
        } else {
            processedVariantCounter++;
            std::vector<std::string> fields = split(line, '\t');
            
            SetDepths depths = getSetVariantDepths(fields,maleLoci,femaleLoci);
            setDepthsVector.push_back(depths);
            set1MeanDepths.push_back(depths.set1_mean_depth);
            set2MeanDepths.push_back(depths.set2_mean_depth);
            
            if (processedVariantCounter % opt::window == 0) {
                int Ylike = 0;
                for (std::vector<SetDepths>::size_type i = 0; i != setDepthsVector.size(); i++) {
                    // Could this be a Y region
                    if(setDepthsVector[i].set1_mean_depth > 2 && setDepthsVector[i].set2_mean_depth <= 1) {
                        Ylike++;
                    }
                }
                
                // std::cerr << "Region: " << fields[0] << "\t" << regionStart << "-" << fields[1] << "processed" << std::endl;
                // std::cerr << Ylike << " Ylike variants" << std::endl;
                YlikeCounts.push_back(Ylike);
                if (Ylike > (opt::window/2)) {
                    std::cout << "Putative Y region: " << fields[0] << "\t" << regionStart << "-" << fields[1] << std::endl;
                }
                if (Ylike > 0) {
                    nonZeroYlikeCounts.push_back(Ylike);
                    std::cerr << "Region: " << fields[0] << "\t" << regionStart << "-" << fields[1] << "processed" << std::endl;
                    std::cerr << Ylike << " Ylike variants" << std::endl;
                }
                
                
               /* if (regionStart == 182909) {
                   // std::cerr << "Here " << set1MeanDepths.size() << "\t" << set1MeanDepths[50] << std::endl;
                  //  print_vector_stream(set1MeanDepths, std::cerr, '\n');
                  //  std::cerr << "Here " << set2MeanDepths.size() << std::endl;
                  //  print_vector_stream(depths.set1Depths, std::cerr, '\n');
                    //std::cerr << "Here " << set2MeanDepths.size() << std::endl;
                    //print_vector_stream(set2MeanDepths, std::cerr, '\n');
                    //std::cerr << "Here " << set2MeanDepths.size() << std::endl;
                    //print_vector_stream(depths.set2Depths, std::cerr, '\n');
                }
                */
                // alternative hypothesis: true difference in means is greater than 5
                double pval_t = two_sample_t(set1MeanDepths,set2MeanDepths);
                
                if (pval_t < 0.001) {
                    string loc = fields[0] + "\t" + numToString(regionStart) + "\t" + fields[1];
                    *pValFile << loc << "\t" << pval_t << "\t" << vector_average(set1MeanDepths) << "\t" << vector_average(set2MeanDepths) << std::endl;
                }
                
                //std::cerr << "Region: " << fields[0] << "\t" << regionStart << "-" << fields[1] << "processed" << std::endl;
                regionStart = atoi(fields[1].c_str());
                setDepthsVector.clear();
                set1MeanDepths.clear(); set2MeanDepths.clear();
                
            }
            if (processedVariantCounter % 100000 == 0)
                std::cerr << processedVariantCounter << " variants processed" << std::endl;
        }
    }
    
    std::ofstream* YlikeCountsDistribution = new std::ofstream("YlikeCounts.txt");
    print_vector(YlikeCounts, *YlikeCountsDistribution, '\n');
    std::ofstream* nonZeroYlikeCountsDistribution = new std::ofstream("nonZeroYlikeCounts.txt");
    print_vector(YlikeCounts, *nonZeroYlikeCountsDistribution, '\n');
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3c8, %rsp            # imm = 0x3C8
callq 0x81deb
leaq 0x8c1fd(%rip), %rsi     # 0x10c780
leaq 0x3a8(%rsp), %rdi
callq 0x50803
movq 0x8aa51(%rip), %rdi     # 0x10afe8
leaq 0x5eea2(%rip), %rsi     # 0xdf440
movl $0x43, %edx
callq 0x84e0
movq 0x8c1d1(%rip), %rsi     # 0x10c780
movq 0x8c1d2(%rip), %rdx     # 0x10c788
movq 0x8aa2b(%rip), %rdi     # 0x10afe8
callq 0x84e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %rbx, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movq 0x8a9f5(%rip), %rdi     # 0x10afe8
leaq 0x5ee8a(%rip), %rsi     # 0xdf484
movl $0x23, %edx
callq 0x84e0
movq 0x8c195(%rip), %rsi     # 0x10c7a0
movq 0x8c196(%rip), %rdx     # 0x10c7a8
movq 0x8a9cf(%rip), %rdi     # 0x10afe8
callq 0x84e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %rbx, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movq 0x8a999(%rip), %rdi     # 0x10afe8
leaq 0x5ee52(%rip), %rsi     # 0xdf4a8
movl $0x15, %edx
callq 0x84e0
movl 0x8af16(%rip), %esi     # 0x10b57c
movq 0x8a97b(%rip), %rdi     # 0x10afe8
callq 0x8810
movq %rax, %rbx
leaq 0x5ee73(%rip), %rsi     # 0xdf4ef
movl $0x9, %edx
movq %rax, %rdi
callq 0x84e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %rbx, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %rbx
movq 0x8c0bc(%rip), %rsi     # 0x10c780
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %r15
movq 0x8c0bb(%rip), %rsi     # 0x10c7a0
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
movl 0x8ae84(%rip), %esi     # 0x10b57c
leaq 0x110(%rsp), %rdi
callq 0x31297
leaq 0x5edb2(%rip), %rcx     # 0xdf4be
leaq 0x110(%rsp), %rdi
movl $0xd, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x84d0
leaq 0x80(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x80751
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x8075b
movupd (%rcx), %xmm0
movupd %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x70(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x643d7(%rip), %rsi     # 0xe4b55
callq 0x88c0
leaq 0x1f0(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x807b3
movq %rdx, 0x1e0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x1f0(%rsp)
jmp 0x807bb
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x1e8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x807f0
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x120(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x80811
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x8480
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq %rax, %r12
movq 0x1e0(%rsp), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
movq %r14, 0x110(%rsp)
xorl %eax, %eax
movq %rax, 0x118(%rsp)
movb %al, 0x120(%rsp)
leaq 0x2a0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
leaq 0x110(%rsp), %rsi
movq %r15, %rdi
callq 0x8870
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
leaq 0x290(%rsp), %rsi
movq %r15, %rdi
callq 0x8870
leaq 0x338(%rsp), %rdi
leaq 0x110(%rsp), %rsi
movl $0x2c, %edx
callq 0x50624
leaq 0x320(%rsp), %rdi
leaq 0x290(%rsp), %rsi
movl $0x2c, %edx
callq 0x50624
movq 0x338(%rsp), %r14
movq 0x340(%rsp), %r15
cmpq %r15, %r14
je 0x80922
movq %r15, %rax
subq %r14, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x5fd29
movq %r14, %rdi
movq %r15, %rsi
callq 0x5fe0d
movq 0x320(%rsp), %r14
movq 0x328(%rsp), %r15
cmpq %r15, %r14
je 0x80964
movq %r15, %rax
subq %r14, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x5fd29
movq %r14, %rdi
movq %r15, %rsi
callq 0x5fe0d
movq %r12, 0x2b0(%rsp)
leaq 0x280(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x310(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x512e9(%rip), %rdx     # 0xd1c7f
leaq 0x300(%rsp), %rdi
movq %rdx, %rsi
callq 0x28952
leaq 0x380(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %r15d, %r15d
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x220(%rsp), %r12
movq %r15, 0x10(%r12)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r12)
leaq 0x360(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x170(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
leaq 0x150(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
leaq 0x200(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
leaq 0x50(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
leaq 0x30(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
leaq 0x130(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
leaq 0x1c0(%rsp), %rax
movq %r15, 0x10(%rax)
movapd %xmm0, (%rax)
movl $0x1, 0xc(%rsp)
leaq 0x270(%rsp), %r13
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x81650
movq 0x270(%rsp), %rax
movb (%rax), %cl
cmpb $0x23, %cl
jne 0x80b72
cmpb $0x23, 0x1(%rax)
je 0x80a60
cmpb $0x23, %cl
jne 0x80b72
cmpb $0x43, 0x1(%rax)
jne 0x80b72
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
movl $0x9, %edx
callq 0x50624
cmpq $0x0, 0x8bcee(%rip)     # 0x10c7c8
je 0x80cbe
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
leaq 0x8bcce(%rip), %rsi     # 0x10c7c0
callq 0x52fb6
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movapd 0x220(%rsp), %xmm0
movq 0x230(%rsp), %rax
movups 0xf0(%rsp), %xmm1
movaps %xmm1, 0x220(%rsp)
movq 0x100(%rsp), %rcx
movq %rcx, 0x230(%rsp)
movapd 0x70(%rsp), %xmm1
movapd %xmm0, 0x70(%rsp)
movq %rax, 0x80(%rsp)
movupd %xmm1, 0xf0(%rsp)
movq $0x0, 0x100(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x3123c
movq %r14, %rdi
callq 0x3123c
jmp 0x80d06
leaq 0x188(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movl $0x9, %edx
callq 0x50624
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
leaq 0x170(%rsp), %rdx
leaq 0x150(%rsp), %rcx
callq 0x803c0
leaq 0x200(%rsp), %rdi
movq %r14, %rsi
callq 0x82206
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x80bde
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x80bf0
leaq 0x50(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x79f34
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x80c14
movsd 0xa8(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x80c26
leaq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x79f34
incl %r15d
movl %r15d, %eax
xorl %edx, %edx
divl 0x8a948(%rip)           # 0x10b57c
testl %edx, %edx
jne 0x815a8
movq 0x200(%rsp), %rax
movq 0x208(%rsp), %rcx
movl $0x0, 0x8(%rsp)
subq %rax, %rcx
je 0x80c91
sarq $0x6, %rcx
movl 0x8(%rsp), %edx
addq $0x38, %rax
movsd -0x8(%rax), %xmm0
ucomisd 0x5b36e(%rip), %xmm0    # 0xdbfe0
jbe 0x80c88
movsd 0x4e7c4(%rip), %xmm0    # 0xcf440
ucomisd (%rax), %xmm0
jb 0x80c88
incl %edx
movl %edx, 0x8(%rsp)
addq $0x40, %rax
decq %rcx
jne 0x80c65
movq 0x138(%rsp), %rsi
cmpq 0x140(%rsp), %rsi
je 0x80e11
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x138(%rsp)
jmp 0x80e23
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
cmpq $0x120, %rax            # imm = 0x120
je 0x80d06
movl $0x9, %r14d
movl $0x120, %ebp            # imm = 0x120
addq %rbp, %rsi
movq %r12, %rdi
callq 0x33db0
incq %r14
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
addq $0x20, %rbp
cmpq %rax, %r14
jne 0x80cde
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
leaq 0x338(%rsp), %rdx
callq 0x53501
movq 0x170(%rsp), %rdi
movq 0x180(%rsp), %rsi
movq 0x70(%rsp), %rax
movq %rax, 0x170(%rsp)
movupd 0x78(%rsp), %xmm0
movupd %xmm0, 0x178(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
testq %rdi, %rdi
je 0x80d6a
subq %rdi, %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x80d84
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
leaq 0x320(%rsp), %rdx
callq 0x53501
movq 0x150(%rsp), %rdi
movq 0x160(%rsp), %rsi
movq 0x70(%rsp), %rax
movq %rax, 0x150(%rsp)
movupd 0x78(%rsp), %xmm0
movupd %xmm0, 0x158(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
testq %rdi, %rdi
je 0x80de8
subq %rdi, %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x80e02
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x10(%rsp), %rdi
callq 0x3123c
jmp 0x80a60
leaq 0x130(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x4bc3a
movl 0x8a753(%rip), %eax     # 0x10b57c
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl 0xc(%rsp), %ebp
cmpl %ecx, 0x8(%rsp)
jle 0x80eee
movl $0x13, %edx
movq 0x8a16c(%rip), %rdi     # 0x10afb8
leaq 0x5e679(%rip), %rsi     # 0xdf4cc
callq 0x84e0
movq 0x188(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x8a14a(%rip), %rdi     # 0x10afb8
callq 0x84e0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x50df9(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x82f0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x4fa09(%rip), %rsi     # 0xd08b0
callq 0x84e0
movq 0x188(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
movq %r14, %rdi
callq 0x84e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movl 0x8(%rsp), %eax
testl %eax, %eax
jle 0x81040
movq 0x1c8(%rsp), %rsi
cmpq 0x1d0(%rsp), %rsi
je 0x80f1c
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x1c8(%rsp)
jmp 0x80f2e
leaq 0x1c0(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x4bc3a
movl $0x8, %edx
movq 0x8a0ae(%rip), %rdi     # 0x10afe8
leaq 0x5e59f(%rip), %rsi     # 0xdf4e0
callq 0x84e0
movq 0x188(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x8a08c(%rip), %rdi     # 0x10afe8
callq 0x84e0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x50d0b(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x82f0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x4f91b(%rip), %rsi     # 0xd08b0
callq 0x84e0
movq 0x188(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
movq %r14, %rdi
callq 0x84e0
movq %rax, %rbp
movl $0x9, %edx
movq %rax, %rdi
leaq 0x5e53f(%rip), %rsi     # 0xdf503
callq 0x84e0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %rbp, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movl 0x8(%rsp), %esi
movq 0x89fec(%rip), %rdi     # 0x10afe8
callq 0x8810
movq %rax, %rbp
movl $0xf, %edx
movq %rax, %rdi
leaq 0x5e4d6(%rip), %rsi     # 0xdf4e9
callq 0x84e0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %rbp, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x2e8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3a864
leaq 0x390(%rsp), %r14
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
callq 0x3a864
xorpd %xmm0, %xmm0
leaq 0x2e8(%rsp), %rdi
movq %r14, %rsi
callq 0x8222f
movsd %xmm0, 0x1d8(%rsp)
movq 0x390(%rsp), %rdi
testq %rdi, %rdi
je 0x810a1
movq 0x3a0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x2e8(%rsp), %rdi
testq %rdi, %rdi
je 0x810be
movq 0x2f8(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movsd 0x5e2ea(%rip), %xmm0    # 0xdf3b0
ucomisd 0x1d8(%rsp), %xmm0
jbe 0x8155c
movq 0x188(%rsp), %rax
leaq 0xc0(%rsp), %rcx
movq %rcx, 0xb0(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x2e45c
movq %r14, %rdi
leaq 0x50b6d(%rip), %rsi     # 0xd1c7e
callq 0x88c0
leaq 0x1a0(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x8264f
movq 0xb0(%rsp), %rcx
movl $0xf, %esi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rcx
je 0x81149
movq 0xc0(%rsp), %rsi
movq 0xb8(%rsp), %r8
movq 0x1a8(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x81186
movl $0xf, %esi
leaq 0x1b0(%rsp), %rdi
cmpq %rdi, 0x1a0(%rsp)
je 0x81181
movq 0x1b0(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x8119d
movq 0x1a0(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x8180
jmp 0x811ae
leaq 0x1a0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x84d0
leaq 0xe0(%rsp), %rsi
movq %rsi, 0xd0(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x811df
movq %rdx, 0xd0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xe0(%rsp)
jmp 0x811e7
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0xd8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0xd0(%rsp), %rdi
leaq 0x50a68(%rip), %rsi     # 0xd1c7e
callq 0x88c0
leaq 0x100(%rsp), %rsi
movq %rsi, 0xf0(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8124f
movq %rdx, 0xf0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x100(%rsp)
jmp 0x81257
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0xf8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x188(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
leaq 0xf0(%rsp), %rdi
callq 0x8180
leaq 0x20(%rsp), %rsi
movq %rsi, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x812b7
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x812bf
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x812fc
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x81321
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x81346
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x8136b
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x2b0(%rsp), %rdi
callq 0x84e0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x508ea(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq %r14, %rdi
movsd 0x1d8(%rsp), %xmm0
callq 0x8730
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x508c2(%rip), %rsi     # 0xd1c7e
callq 0x84e0
leaq 0x258(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3a864
movq 0x258(%rsp), %rcx
movq 0x260(%rsp), %rdx
movq %rdx, %rax
subq %rcx, %rax
sarq $0x3, %rax
cmpq %rcx, %rdx
je 0x81412
cmpq $0x1, %rax
movq %rax, %rdx
adcq $0x0, %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
addsd (%rcx,%rsi,8), %xmm0
incq %rsi
cmpq %rsi, %rdx
jne 0x81403
jmp 0x81416
xorpd %xmm0, %xmm0
movq %rax, %xmm1
punpckldq 0x48d7d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x48d85(%rip), %xmm1    # 0xca1b0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq %r14, %rdi
callq 0x8730
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x50829(%rip), %rsi     # 0xd1c7e
callq 0x84e0
leaq 0x240(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3a864
movq 0x240(%rsp), %rcx
movq 0x248(%rsp), %rdx
movq %rdx, %rax
subq %rcx, %rax
sarq $0x3, %rax
cmpq %rcx, %rdx
je 0x814ab
cmpq $0x1, %rax
movq %rax, %rdx
adcq $0x0, %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
addsd (%rcx,%rsi,8), %xmm0
incq %rsi
cmpq %rsi, %rdx
jne 0x8149c
jmp 0x814af
xorpd %xmm0, %xmm0
movq %rax, %xmm1
punpckldq 0x48ce4(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x48cec(%rip), %xmm1    # 0xca1b0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq %r14, %rdi
callq 0x8730
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movq 0x240(%rsp), %rdi
testq %rdi, %rdi
je 0x81523
movq 0x250(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x258(%rsp), %rdi
testq %rdi, %rdi
je 0x81540
movq 0x268(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8155c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x188(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x86e0
movl %eax, 0xc(%rsp)
movq 0x200(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x874f4
movq 0x50(%rsp), %rax
cmpq %rax, 0x58(%rsp)
je 0x81597
movq %rax, 0x58(%rsp)
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x815a8
movq %rax, 0x38(%rsp)
imull $0xbcbe61d, %r15d, %eax # imm = 0xBCBE61D
rorl $0x5, %eax
cmpl $0xa7c5, %eax           # imm = 0xA7C5
ja 0x81607
movl %r15d, %esi
movq 0x89a25(%rip), %rdi     # 0x10afe8
callq 0x82f0
movq %rax, %rbp
movl $0x13, %edx
movq %rax, %rdi
leaq 0x5df1f(%rip), %rsi     # 0xdf4f9
callq 0x84e0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %rbp, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x81624
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x8163e
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x188(%rsp), %rdi
callq 0x3123c
jmp 0x80a60
movl $0x200, %edi            # imm = 0x200
leaq 0x120(%rsp), %r14
callq 0x8470
movq %rax, %rbx
leaq 0x5dea8(%rip), %rsi     # 0xdf514
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
leaq 0x2d0(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x35990
leaq 0x2d0(%rsp), %rdi
movq %rbx, %rsi
movl $0xa, %edx
movl $0x1, %ecx
callq 0x415f4
movq 0x2d0(%rsp), %rdi
testq %rdi, %rdi
je 0x816c5
movq 0x2e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq %rax, %rbx
leaq 0x5de34(%rip), %rsi     # 0xdf50d
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
leaq 0x2b8(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x35990
leaq 0x2b8(%rsp), %rdi
movq %rbx, %rsi
movl $0xa, %edx
movl $0x1, %ecx
callq 0x415f4
movq 0x2b8(%rsp), %rdi
testq %rdi, %rdi
je 0x81732
movq 0x2c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x1c0(%rsp), %rdi
testq %rdi, %rdi
je 0x8174f
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x8176c
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x81783
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8179a
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x200(%rsp), %rdi
callq 0x82732
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x817c4
movq 0x160(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x817e1
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x350(%rsp), %rdi
leaq 0x360(%rsp), %rax
cmpq %rax, %rdi
je 0x81806
movq 0x360(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x220(%rsp), %rdi
callq 0x3123c
movq 0x370(%rsp), %rdi
leaq 0x380(%rsp), %rax
cmpq %rax, %rdi
je 0x81838
movq 0x380(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x300(%rsp), %rdi
leaq 0x310(%rsp), %rax
cmpq %rax, %rdi
je 0x8185d
movq 0x310(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x270(%rsp), %rdi
leaq 0x280(%rsp), %rax
cmpq %rax, %rdi
je 0x81882
movq 0x280(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x320(%rsp), %rdi
callq 0x3123c
leaq 0x338(%rsp), %rdi
callq 0x3123c
movq 0x290(%rsp), %rdi
leaq 0x2a0(%rsp), %rax
cmpq %rax, %rdi
je 0x818c1
movq 0x2a0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x110(%rsp), %rdi
cmpq %r14, %rdi
je 0x818de
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0x81903
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x3b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x81924
movq 0x3b8(%rsp), %rsi
incq %rsi
callq 0x8480
xorl %eax, %eax
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x81971
movq %rax, %r14
jmp 0x81996
jmp 0x819bd
jmp 0x81bc2
movq %rax, %r14
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x81971
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x81996
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x819c0
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0x819c0
movq %rax, %r14
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x81bc5
movq 0xc0(%rsp), %rsi
jmp 0x81aa1
movq %rax, %r14
jmp 0x81a0b
movq %rax, %r14
movq 0x390(%rsp), %rdi
testq %rdi, %rdi
je 0x81a0b
movq 0x3a0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x2e8(%rsp), %rdi
testq %rdi, %rdi
je 0x81bc5
movq 0x2f8(%rsp), %rsi
subq %rdi, %rsi
jmp 0x81aa4
jmp 0x81bc2
jmp 0x81bb8
movq %rax, %r14
jmp 0x81a58
movq %rax, %r14
movq 0x240(%rsp), %rdi
testq %rdi, %rdi
je 0x81a58
movq 0x250(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x258(%rsp), %rdi
testq %rdi, %rdi
je 0x81a89
movq 0x268(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
jmp 0x81a89
jmp 0x81be6
jmp 0x81bb8
jmp 0x81bb8
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x81bc5
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0x81bc5
movq %rax, %r14
movq 0x2b8(%rsp), %rdi
testq %rdi, %rdi
je 0x81be9
movq 0x2c8(%rsp), %rsi
jmp 0x81aea
jmp 0x81aef
movq %rax, %r14
movq 0x2d0(%rsp), %rdi
testq %rdi, %rdi
je 0x81be9
movq 0x2e0(%rsp), %rsi
subq %rdi, %rsi
jmp 0x81afa
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
callq 0x8480
jmp 0x81be9
movq %rax, %r14
jmp 0x81d14
movq %rax, %r14
jmp 0x81d46
jmp 0x81bb0
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq %r12, %rdi
jmp 0x81d98
movq %rax, %r14
jmp 0x81d9d
movq %rax, %r14
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x81b53
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0x81b53
movq %rax, %r14
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x81dc2
movq 0x120(%rsp), %rsi
jmp 0x81dba
jmp 0x81bde
movq %rax, %r14
movl $0x208, %esi            # imm = 0x208
movq %r15, %rdi
jmp 0x81dbd
jmp 0x81bde
movq %rax, %r14
movl $0x208, %esi            # imm = 0x208
movq %rbx, %rdi
jmp 0x81dbd
jmp 0x81bde
jmp 0x81be6
movq %rax, %r14
jmp 0x81bcf
jmp 0x81be6
jmp 0x81be6
movq %rax, %r14
jmp 0x81d39
jmp 0x81bc2
movq %rax, %r14
jmp 0x81d53
movq %rax, %r14
leaq 0x10(%rsp), %rdi
jmp 0x81bd7
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x821d6
leaq 0x188(%rsp), %rdi
callq 0x3123c
jmp 0x81be9
movq %rax, %r14
jmp 0x81dc2
movq %rax, %r14
movq 0x1c0(%rsp), %rdi
testq %rdi, %rdi
je 0x81c06
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x81c23
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x81c3a
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x81c51
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x200(%rsp), %rdi
callq 0x82732
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x81c7b
movq 0x160(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x81c98
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x350(%rsp), %rdi
leaq 0x360(%rsp), %rax
cmpq %rax, %rdi
je 0x81cbd
movq 0x360(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x220(%rsp), %rdi
callq 0x3123c
movq 0x370(%rsp), %rdi
leaq 0x380(%rsp), %rax
cmpq %rax, %rdi
je 0x81cef
movq 0x380(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x300(%rsp), %rdi
leaq 0x310(%rsp), %rax
cmpq %rax, %rdi
je 0x81d14
movq 0x310(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x270(%rsp), %rdi
leaq 0x280(%rsp), %rax
cmpq %rax, %rdi
je 0x81d39
movq 0x280(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x320(%rsp), %rdi
callq 0x3123c
leaq 0x338(%rsp), %rdi
callq 0x3123c
movq 0x290(%rsp), %rdi
leaq 0x2a0(%rsp), %rax
cmpq %rax, %rdi
je 0x81d78
movq 0x2a0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x81d9d
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0x81dc2
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x3b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x81de3
movq 0x3b8(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r14, %rdi
callq 0x8840