// File: 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
movq %rsp, %rbp
subq $0x660, %rsp            # imm = 0x660
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xc94f0
leaq 0xd2ac3(%rip), %rsi     # 0x19ac78
leaq -0x30(%rbp), %rdi
callq 0x7be70
movq 0xd0e2b(%rip), %rdi     # 0x198ff0
leaq 0x7b6ec(%rip), %rsi     # 0x1438b8
callq 0xa5c0
movq %rax, -0x4b8(%rbp)
jmp 0xc81da
movq -0x4b8(%rbp), %rdi
leaq 0xd2a90(%rip), %rsi     # 0x19ac78
callq 0xa520
movq %rax, -0x4c0(%rbp)
jmp 0xc81f6
movq -0x4c0(%rbp), %rdi
movq 0xd0d84(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc820b
movq 0xd0dde(%rip), %rdi     # 0x198ff0
leaq 0x7b6e3(%rip), %rsi     # 0x1438fc
callq 0xa5c0
movq %rax, -0x4c8(%rbp)
jmp 0xc8227
movq -0x4c8(%rbp), %rdi
leaq 0xd2a63(%rip), %rsi     # 0x19ac98
callq 0xa520
movq %rax, -0x4d0(%rbp)
jmp 0xc8243
movq -0x4d0(%rbp), %rdi
movq 0xd0d37(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc8258
movq 0xd0d91(%rip), %rdi     # 0x198ff0
leaq 0x7b6ba(%rip), %rsi     # 0x143920
callq 0xa5c0
movq %rax, -0x4d8(%rbp)
jmp 0xc8274
movq -0x4d8(%rbp), %rdi
movl 0xd1637(%rip), %esi     # 0x1998b8
callq 0xab20
movq %rax, -0x4e0(%rbp)
jmp 0xc828f
movq -0x4e0(%rbp), %rdi
leaq 0x7b6ca(%rip), %rsi     # 0x143967
callq 0xa5c0
movq %rax, -0x4e8(%rbp)
jmp 0xc82ab
movq -0x4e8(%rbp), %rdi
movq 0xd0ccf(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc82c0
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0x4f0(%rbp)
jmp 0xc82d3
leaq 0xd299e(%rip), %rdi     # 0x19ac78
callq 0xa220
movq -0x4f0(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0xc82f5
movq -0x4f0(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0x4f8(%rbp)
jmp 0xc8313
leaq 0xd297e(%rip), %rdi     # 0x19ac98
callq 0xa220
movq -0x4f8(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0xc8335
movq -0x4f8(%rbp), %rax
movq %rax, -0x50(%rbp)
movl 0xd1572(%rip), %esi     # 0x1998b8
leaq -0xb0(%rbp), %rdi
callq 0x3e190
jmp 0xc8354
leaq 0x7b5db(%rip), %rsi     # 0x143936
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0xc2290
jmp 0xc8370
leaq 0x81230(%rip), %rdx     # 0x1495a7
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3e020
jmp 0xc8389
leaq -0x90(%rbp), %rdi
callq 0xac88
leaq -0xb0(%rbp), %rdi
callq 0xac88
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x500(%rbp)
jmp 0xc83b4
leaq -0x70(%rbp), %rdi
callq 0xa220
movq -0x500(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0xa650
jmp 0xc83d3
movq -0x500(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x508(%rbp)
callq 0xa820
leaq -0xf8(%rbp), %rdi
callq 0xa820
movq -0x508(%rbp), %rsi
movq -0x50(%rbp), %rdi
callq 0xa0d0
jmp 0xc8412
movq -0x50(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0xa0d0
jmp 0xc8424
leaq -0x110(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movl $0x2c, %edx
callq 0x7bbe0
jmp 0xc843e
leaq -0x128(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
movl $0x2c, %edx
callq 0x7bbe0
jmp 0xc8458
leaq -0x110(%rbp), %rdi
movq %rdi, -0x510(%rbp)
callq 0x44030
movq -0x510(%rbp), %rdi
movq %rax, -0x130(%rbp)
callq 0x44060
movq %rax, -0x138(%rbp)
movq -0x130(%rbp), %rdi
movq -0x138(%rbp), %rsi
callq 0x9d660
jmp 0xc849a
leaq -0x128(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x44030
movq -0x518(%rbp), %rdi
movq %rax, -0x140(%rbp)
callq 0x44060
movq %rax, -0x148(%rbp)
movq -0x140(%rbp), %rdi
movq -0x148(%rbp), %rsi
callq 0x9d660
jmp 0xc84dc
leaq -0x168(%rbp), %rdi
callq 0xa820
leaq -0x189(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0xab60
movq -0x520(%rbp), %rdx
leaq 0x6d9d6(%rip), %rsi     # 0x135edf
leaq -0x188(%rbp), %rdi
callq 0x2d6c0
jmp 0xc8517
leaq -0x189(%rbp), %rdi
callq 0xa640
leaq -0x1b0(%rbp), %rdi
callq 0xa820
leaq -0x1c8(%rbp), %rdi
callq 0x48da0
leaq -0x1e8(%rbp), %rdi
callq 0xa820
leaq -0x200(%rbp), %rdi
callq 0x50c10
leaq -0x218(%rbp), %rdi
callq 0x50c10
leaq -0x230(%rbp), %rdi
callq 0xc9910
leaq -0x248(%rbp), %rdi
callq 0x48410
leaq -0x260(%rbp), %rdi
callq 0x48410
movl $0x0, -0x264(%rbp)
movl $0x1, -0x268(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x46270
leaq -0x298(%rbp), %rdi
callq 0x46270
movq -0x48(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0xa0d0
movq %rax, -0x528(%rbp)
jmp 0xc85c8
movq -0x528(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0x529(%rbp)
jmp 0xc85e6
movb -0x529(%rbp), %al
testb $0x1, %al
jne 0xc85f5
jmp 0xc91c6
xorl %eax, %eax
movl %eax, %esi
leaq -0x168(%rbp), %rdi
callq 0xac60
movq %rax, -0x538(%rbp)
jmp 0xc860e
movq -0x538(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0xc8773
leaq -0x168(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0x540(%rbp)
jmp 0xc863b
movq -0x540(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0xc8773
jmp 0xc85af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc94d2
movq -0x4f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0xc94d2
movq -0x4f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0xc94d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc86ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xac88
leaq -0xb0(%rbp), %rdi
callq 0xac88
jmp 0xc94d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc94c9
movq -0x500(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xc94c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc94b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc94a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc9499
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x189(%rbp), %rdi
callq 0xa640
jmp 0xc948d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc9409
xorl %eax, %eax
movl %eax, %esi
leaq -0x168(%rbp), %rdi
callq 0xac60
movq %rax, -0x548(%rbp)
jmp 0xc878c
movq -0x548(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0xc894a
leaq -0x168(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0x550(%rbp)
jmp 0xc87b9
movq -0x550(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x43, %eax
jne 0xc894a
leaq -0x2b0(%rbp), %rdi
leaq -0x168(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0xc87e6
leaq 0xd24cb(%rip), %rdi     # 0x19acb8
callq 0xaa70
testb $0x1, %al
jne 0xc87fb
jmp 0xc8888
movq $0x9, -0x2b8(%rbp)
movq -0x2b8(%rbp), %rax
movq %rax, -0x558(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x3ffd0
movq %rax, %rcx
movq -0x558(%rbp), %rax
cmpq %rcx, %rax
je 0xc8886
movq -0x2b8(%rbp), %rsi
leaq -0x2b0(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0x48dc0
jmp 0xc8853
jmp 0xc8855
movq -0x2b8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2b8(%rbp)
jmp 0xc8806
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x3dfa0
jmp 0xc9409
jmp 0xc88bc
leaq 0xd2429(%rip), %rsi     # 0x19acb8
leaq -0x2d0(%rbp), %rdi
callq 0x80aa0
jmp 0xc889d
leaq -0x1c8(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x50c30
leaq -0x2d0(%rbp), %rdi
callq 0x3dfa0
leaq -0x2e8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x81250
jmp 0xc88d8
leaq -0x200(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
movq %rsi, -0x560(%rbp)
callq 0x50d10
movq -0x560(%rbp), %rdi
callq 0x50d40
leaq -0x300(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0x81250
jmp 0xc891a
leaq -0x218(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x50d10
leaq -0x300(%rbp), %rdi
callq 0x50d40
leaq -0x2b0(%rbp), %rdi
callq 0x3dfa0
jmp 0xc91bf
movl -0x264(%rbp), %eax
incl %eax
movl %eax, -0x264(%rbp)
leaq -0x318(%rbp), %rdi
leaq -0x168(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0xc8972
leaq -0x358(%rbp), %rdi
leaq -0x318(%rbp), %rsi
leaq -0x200(%rbp), %rdx
leaq -0x218(%rbp), %rcx
callq 0xc7f00
jmp 0xc8995
leaq -0x230(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0xc9930
jmp 0xc89aa
leaq -0x328(%rbp), %rsi
leaq -0x248(%rbp), %rdi
callq 0xb77b0
jmp 0xc89bf
leaq -0x320(%rbp), %rsi
leaq -0x260(%rbp), %rdi
callq 0xb77b0
jmp 0xc89d4
movl -0x264(%rbp), %eax
xorl %edx, %edx
divl 0xd0ed6(%rip)           # 0x1998b8
cmpl $0x0, %edx
jne 0xc9126
movl $0x0, -0x35c(%rbp)
movq $0x0, -0x368(%rbp)
movq -0x368(%rbp), %rax
movq %rax, -0x568(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xc99a0
movq %rax, %rcx
movq -0x568(%rbp), %rax
cmpq %rcx, %rax
je 0xc8ac1
movq -0x368(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0xc99c0
movsd 0x30(%rax), %xmm0
movsd 0x6ac7b(%rip), %xmm1    # 0x1336c8
ucomisd %xmm1, %xmm0
jbe 0xc8aa8
movq -0x368(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0xc99c0
movsd 0x6984a(%rip), %xmm0    # 0x1322b8
ucomisd 0x38(%rax), %xmm0
jb 0xc8aa8
movl -0x35c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x35c(%rbp)
jmp 0xc8aa8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc91ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc91a2
jmp 0xc8aaa
movq -0x368(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x368(%rbp)
jmp 0xc8a00
leaq -0x280(%rbp), %rdi
leaq -0x35c(%rbp), %rsi
callq 0x6b600
jmp 0xc8ad6
movl -0x35c(%rbp), %eax
movl %eax, -0x56c(%rbp)
movl 0xd0dd0(%rip), %eax     # 0x1998b8
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x56c(%rbp), %eax
cmpl %ecx, %eax
jle 0xc8bd7
movq 0xd04b1(%rip), %rdi     # 0x198fb8
leaq 0x7ae36(%rip), %rsi     # 0x143944
callq 0xa5c0
movq %rax, -0x578(%rbp)
jmp 0xc8b1c
xorl %eax, %eax
movl %eax, %esi
leaq -0x318(%rbp), %rdi
callq 0x3d940
movq -0x578(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x580(%rbp)
jmp 0xc8b44
movq -0x580(%rbp), %rdi
leaq 0x6d38c(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x588(%rbp)
jmp 0xc8b60
movq -0x588(%rbp), %rdi
movl -0x268(%rbp), %esi
callq 0xa7e0
movq %rax, -0x590(%rbp)
jmp 0xc8b7b
movq -0x590(%rbp), %rdi
leaq 0x6bf87(%rip), %rsi     # 0x134b10
callq 0xa5c0
movq %rax, -0x598(%rbp)
jmp 0xc8b97
leaq -0x318(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq -0x598(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x5a0(%rbp)
jmp 0xc8bc0
movq -0x5a0(%rbp), %rdi
movq 0xd03ba(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc8bd5
jmp 0xc8bd7
cmpl $0x0, -0x35c(%rbp)
jle 0xc8d38
leaq -0x298(%rbp), %rdi
leaq -0x35c(%rbp), %rsi
callq 0x6b600
jmp 0xc8bf9
movq 0xd03f0(%rip), %rdi     # 0x198ff0
leaq 0x7ad51(%rip), %rsi     # 0x143958
callq 0xa5c0
movq %rax, -0x5a8(%rbp)
jmp 0xc8c15
xorl %eax, %eax
movl %eax, %esi
leaq -0x318(%rbp), %rdi
callq 0x3d940
movq -0x5a8(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x5b0(%rbp)
jmp 0xc8c3d
movq -0x5b0(%rbp), %rdi
leaq 0x6d293(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x5b8(%rbp)
jmp 0xc8c59
movq -0x5b8(%rbp), %rdi
movl -0x268(%rbp), %esi
callq 0xa7e0
movq %rax, -0x5c0(%rbp)
jmp 0xc8c74
movq -0x5c0(%rbp), %rdi
leaq 0x6be8e(%rip), %rsi     # 0x134b10
callq 0xa5c0
movq %rax, -0x5c8(%rbp)
jmp 0xc8c90
leaq -0x318(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq -0x5c8(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x5d0(%rbp)
jmp 0xc8cb9
movq -0x5d0(%rbp), %rdi
leaq 0x7acb4(%rip), %rsi     # 0x14397b
callq 0xa5c0
movq %rax, -0x5d8(%rbp)
jmp 0xc8cd5
movq -0x5d8(%rbp), %rdi
movq 0xd02a5(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc8cea
movl -0x35c(%rbp), %esi
movq 0xd02f9(%rip), %rdi     # 0x198ff0
callq 0xab20
movq %rax, -0x5e0(%rbp)
jmp 0xc8d05
movq -0x5e0(%rbp), %rdi
leaq 0x7ac4e(%rip), %rsi     # 0x143961
callq 0xa5c0
movq %rax, -0x5e8(%rbp)
jmp 0xc8d21
movq -0x5e8(%rbp), %rdi
movq 0xd0259(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc8d36
jmp 0xc8d38
leaq -0x388(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x53120
jmp 0xc8d4d
leaq -0x3a0(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x53120
jmp 0xc8d62
leaq -0x388(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0xc99e0
movsd %xmm0, -0x5f0(%rbp)
jmp 0xc8d82
leaq -0x3a0(%rbp), %rdi
callq 0x3ecb0
leaq -0x388(%rbp), %rdi
callq 0x3ecb0
movsd -0x5f0(%rbp), %xmm0
movsd %xmm0, -0x370(%rbp)
movsd 0x7aa9e(%rip), %xmm0    # 0x143850
ucomisd -0x370(%rbp), %xmm0
jbe 0xc90db
xorl %eax, %eax
movl %eax, %esi
leaq -0x318(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq 0x6d104(%rip), %rdx     # 0x135ede
leaq -0x420(%rbp), %rdi
callq 0x3da80
jmp 0xc8de8
movl -0x268(%rbp), %esi
leaq -0x440(%rbp), %rdi
callq 0xc9f70
jmp 0xc8dfc
leaq -0x400(%rbp), %rdi
leaq -0x420(%rbp), %rsi
leaq -0x440(%rbp), %rdx
callq 0x3e070
jmp 0xc8e18
leaq 0x6d0bf(%rip), %rdx     # 0x135ede
leaq -0x3e0(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x3e020
jmp 0xc8e34
leaq -0x318(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdx
leaq -0x3c0(%rbp), %rdi
leaq -0x3e0(%rbp), %rsi
callq 0x3da30
jmp 0xc8e5d
leaq -0x3e0(%rbp), %rdi
callq 0xac88
leaq -0x400(%rbp), %rdi
callq 0xac88
leaq -0x440(%rbp), %rdi
callq 0xac88
leaq -0x420(%rbp), %rdi
callq 0xac88
movq -0xb8(%rbp), %rdi
leaq -0x3c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x5f8(%rbp)
jmp 0xc8ea9
movq -0x5f8(%rbp), %rdi
leaq 0x6d027(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x600(%rbp)
jmp 0xc8ec5
movq -0x600(%rbp), %rdi
movsd -0x370(%rbp), %xmm0
callq 0xabd0
movq %rax, -0x608(%rbp)
jmp 0xc8ee2
movq -0x608(%rbp), %rdi
leaq 0x6cfee(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x610(%rbp)
jmp 0xc8efe
leaq -0x458(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x53120
jmp 0xc8f13
leaq -0x458(%rbp), %rdi
callq 0x53060
movsd %xmm0, -0x618(%rbp)
jmp 0xc8f29
movsd -0x618(%rbp), %xmm0
movq -0x610(%rbp), %rdi
callq 0xabd0
movq %rax, -0x620(%rbp)
jmp 0xc8f46
movq -0x620(%rbp), %rdi
leaq 0x6cf8a(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x628(%rbp)
jmp 0xc8f62
leaq -0x470(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x53120
jmp 0xc8f77
leaq -0x470(%rbp), %rdi
callq 0x53060
movsd %xmm0, -0x630(%rbp)
jmp 0xc8f8d
movsd -0x630(%rbp), %xmm0
movq -0x628(%rbp), %rdi
callq 0xabd0
movq %rax, -0x638(%rbp)
jmp 0xc8faa
movq -0x638(%rbp), %rdi
movq 0xcffd0(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc8fbf
leaq -0x470(%rbp), %rdi
callq 0x3ecb0
leaq -0x458(%rbp), %rdi
callq 0x3ecb0
leaq -0x3c0(%rbp), %rdi
callq 0xac88
jmp 0xc90db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc900e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3a0(%rbp), %rdi
callq 0x3ecb0
leaq -0x388(%rbp), %rdi
callq 0x3ecb0
jmp 0xc91a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc9079
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc906d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc9061
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0xac88
leaq -0x400(%rbp), %rdi
callq 0xac88
leaq -0x440(%rbp), %rdi
callq 0xac88
leaq -0x420(%rbp), %rdi
callq 0xac88
jmp 0xc91a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc90ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xc90be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x470(%rbp), %rdi
callq 0x3ecb0
leaq -0x458(%rbp), %rdi
callq 0x3ecb0
leaq -0x3c0(%rbp), %rdi
callq 0xac88
jmp 0xc91a2
leaq -0x318(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movl %eax, -0x268(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xca070
leaq -0x248(%rbp), %rdi
callq 0x53210
leaq -0x260(%rbp), %rdi
callq 0x53210
movl -0x264(%rbp), %eax
movl $0x186a0, %ecx          # imm = 0x186A0
xorl %edx, %edx
divl %ecx
cmpl $0x0, %edx
jne 0xc9188
movl -0x264(%rbp), %esi
movq 0xcfea9(%rip), %rdi     # 0x198ff0
callq 0xa7e0
movq %rax, -0x640(%rbp)
jmp 0xc9155
movq -0x640(%rbp), %rdi
leaq 0x7a80e(%rip), %rsi     # 0x143971
callq 0xa5c0
movq %rax, -0x648(%rbp)
jmp 0xc9171
movq -0x648(%rbp), %rdi
movq 0xcfe09(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xc9186
jmp 0xc9188
leaq -0x358(%rbp), %rdi
callq 0xc98e0
leaq -0x318(%rbp), %rdi
callq 0x3dfa0
jmp 0xc91bf
leaq -0x358(%rbp), %rdi
callq 0xc98e0
leaq -0x318(%rbp), %rdi
callq 0x3dfa0
jmp 0xc9409
jmp 0xc91c1
jmp 0xc85af
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x650(%rbp)
jmp 0xc91d9
movq -0x650(%rbp), %rdi
leaq 0x7a7a5(%rip), %rsi     # 0x14398c
movl $0x10, %edx
callq 0xa650
jmp 0xc91f3
movq -0x650(%rbp), %rax
movq %rax, -0x478(%rbp)
leaq -0x490(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x4cf20
jmp 0xc9216
movq -0x478(%rbp), %rsi
leaq -0x490(%rbp), %rdi
movl $0xa, %edx
movl $0x1, %ecx
callq 0x5f9b0
jmp 0xc9235
leaq -0x490(%rbp), %rdi
callq 0x48290
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x658(%rbp)
jmp 0xc9254
movq -0x658(%rbp), %rdi
leaq 0x7a723(%rip), %rsi     # 0x143985
movl $0x10, %edx
callq 0xa650
jmp 0xc926e
movq -0x658(%rbp), %rax
movq %rax, -0x498(%rbp)
leaq -0x4b0(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x4cf20
jmp 0xc9291
movq -0x498(%rbp), %rsi
leaq -0x4b0(%rbp), %rdi
movl $0xa, %edx
movl $0x1, %ecx
callq 0x5f9b0
jmp 0xc92b0
leaq -0x4b0(%rbp), %rdi
callq 0x48290
leaq -0x298(%rbp), %rdi
callq 0x48290
leaq -0x280(%rbp), %rdi
callq 0x48290
leaq -0x260(%rbp), %rdi
callq 0x3ecb0
leaq -0x248(%rbp), %rdi
callq 0x3ecb0
leaq -0x230(%rbp), %rdi
callq 0xca090
leaq -0x218(%rbp), %rdi
callq 0x50d40
leaq -0x200(%rbp), %rdi
callq 0x50d40
leaq -0x1e8(%rbp), %rdi
callq 0xac88
leaq -0x1c8(%rbp), %rdi
callq 0x3dfa0
leaq -0x1b0(%rbp), %rdi
callq 0xac88
leaq -0x188(%rbp), %rdi
callq 0xac88
leaq -0x168(%rbp), %rdi
callq 0xac88
leaq -0x128(%rbp), %rdi
callq 0x3dfa0
leaq -0x110(%rbp), %rdi
callq 0x3dfa0
leaq -0xf8(%rbp), %rdi
callq 0xac88
leaq -0xd8(%rbp), %rdi
callq 0xac88
leaq -0x70(%rbp), %rdi
callq 0xac88
leaq -0x30(%rbp), %rdi
callq 0xac88
xorl %eax, %eax
addq $0x660, %rsp            # imm = 0x660
popq %rbp
retq
movq -0x650(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xc9409
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x490(%rbp), %rdi
callq 0x48290
jmp 0xc9409
movq -0x658(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xc9409
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x48290
leaq -0x298(%rbp), %rdi
callq 0x48290
leaq -0x280(%rbp), %rdi
callq 0x48290
leaq -0x260(%rbp), %rdi
callq 0x3ecb0
leaq -0x248(%rbp), %rdi
callq 0x3ecb0
leaq -0x230(%rbp), %rdi
callq 0xca090
leaq -0x218(%rbp), %rdi
callq 0x50d40
leaq -0x200(%rbp), %rdi
callq 0x50d40
leaq -0x1e8(%rbp), %rdi
callq 0xac88
leaq -0x1c8(%rbp), %rdi
callq 0x3dfa0
leaq -0x1b0(%rbp), %rdi
callq 0xac88
leaq -0x188(%rbp), %rdi
callq 0xac88
leaq -0x168(%rbp), %rdi
callq 0xac88
leaq -0x128(%rbp), %rdi
callq 0x3dfa0
leaq -0x110(%rbp), %rdi
callq 0x3dfa0
leaq -0xf8(%rbp), %rdi
callq 0xac88
leaq -0xd8(%rbp), %rdi
callq 0xac88
leaq -0x70(%rbp), %rdi
callq 0xac88
leaq -0x30(%rbp), %rdi
callq 0xac88
movq -0x38(%rbp), %rdi
callq 0xab50
nopw %cs:(%rax,%rax)