// File: /workspace/github_cpp_makefile_star2_O3/millanek[P]evo/evo_AlleleFeq.cpp
// Function: AFmain(int, char**)
int AFmain(int argc, char** argv) {
    parseAFoptions(argc, argv);
    string line; // for reading the input files
    

    
    std::istream* vcfFile = createReader(opt::vcfFile.c_str());
    std::ifstream* setsFile = new std::ifstream(opt::setsFile.c_str());
    
    std::map<string, std::vector<string>> popToIDsMap;
    std::map<string, string> IDsToPopMap;
    std::map<string, std::vector<size_t>> popToPosMap;
    std::map<size_t, string> posToPopMap;
    
    // Get the sample sets
    while (getline(*setsFile, line)) {
        // std::cerr << line << std::endl;
        std::vector<string> ID_Pop = split(line, '\t');
        popToIDsMap[ID_Pop[1]].push_back(ID_Pop[0]);
        IDsToPopMap[ID_Pop[0]] = ID_Pop[1];
        //std::cerr << ID_Species[1] << "\t" << ID_Species[0] << std::endl;
    }
    // Get a vector of set names (usually populations/species)
    std::vector<string> populations;
    for(std::map<string,std::vector<string>>::iterator it = popToIDsMap.begin(); it != popToIDsMap.end(); ++it) {
        populations.push_back(it->first);
        // std::cerr << it->first << std::endl;
    } std::cerr << "There are " << populations.size() << " populations " << std::endl;

    int totalVariantNumber = 0;
    std::vector<string> sampleNames; std::vector<std::string> fields;
    int reportProgressEvery = 10000; string chr; string coord; double coordDouble;
    std::clock_t start; std::clock_t startGettingCounts;
    double durationOverall; double durationGettingCounts; 
    //std::ofstream* outFileAF = new std::ofstream(stripExtension(opt::setsFile) + "_" + opt::runName + "_AF" + ".txt");
    std::ostream* outFileAF = createWriter(stripExtension(opt::setsFile) + "_" + opt::runName + "_AF" + ".txt");
    
    while (getline(*vcfFile, line)) {
        line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); // Deal with any left over \r from files prepared on Windows
        if (line[0] == '#' && line[1] == '#')
            continue;
        else if (line[0] == '#' && line[1] == 'C') {
            fields = split(line, '\t');
            std::vector<std::string> sampleNames(fields.begin()+NUM_NON_GENOTYPE_COLUMNS,fields.end());
            // print_vector_stream(sampleNames, std::cerr);
            for (std::vector<std::string>::size_type i = 0; i != sampleNames.size(); i++) {
                posToPopMap[i] = IDsToPopMap[sampleNames[i]];
            }
            // Iterate over all the keys in the map to find the samples in the VCF:
            // Give an error if no sample is found for a species:
            for(std::map<string, std::vector<string>>::iterator it = popToIDsMap.begin(); it != popToIDsMap.end(); ++it) {
                string sp =  it->first;
                //std::cerr << "sp " << sp << std::endl;
                std::vector<string> IDs = it->second;
                std::vector<size_t> spPos = locateSet(sampleNames, IDs);
                if (spPos.empty()) {
                    std::cerr << "Did not find any samples in the VCF for \"" << sp << "\"" << std::endl;
                    assert(!spPos.empty());
                }
                popToPosMap[sp] = spPos;
            }
            start = std::clock();
            //  std::cerr << " " << std::endl;
            //  std::cerr << "Outgroup at pos: "; print_vector_stream(speciesToPosMap["Outgroup"], std::cerr);
            //  std::cerr << "telvit at pos: "; print_vector_stream(speciesToPosMap["telvit"], std::cerr);
        } else {
            totalVariantNumber++;
            if (totalVariantNumber == 1) {
                *outFileAF << "chr" << "\t" << "coord" << "\t" << "ref" << "\t" << "alt";
                for(std::map<string,std::vector<size_t>>::iterator iter =  popToPosMap.begin(); iter != popToPosMap.end(); ++iter) {
                    *outFileAF << "\t" << iter->first;
                }
                *outFileAF << "\n";
            }
            if (totalVariantNumber % reportProgressEvery == 0) {
                durationOverall = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
                std::cerr << "Processed " << totalVariantNumber << " variants in " << durationOverall << "secs" << std::endl;
            }
            fields = split(line, '\t'); chr = fields[0]; coord = fields[1]; coordDouble = stringToDouble(coord);
            std::vector<std::string> genotypes(fields.begin()+NUM_NON_GENOTYPE_COLUMNS,fields.end());
            // Only consider biallelic SNPs
            string refAllele = fields[3]; string altAllele = fields[4];
            if (refAllele.length() > 1 || altAllele.length() > 1 || altAllele == "*") {
                refAllele.clear(); refAllele.shrink_to_fit(); altAllele.clear(); altAllele.shrink_to_fit();
                genotypes.clear(); genotypes.shrink_to_fit(); continue;
            }
            startGettingCounts = std::clock();
            GeneralSetCounts* c = new GeneralSetCounts(popToPosMap, (int)genotypes.size());
            c->getSetVariantCountsSimple(genotypes, posToPopMap);
            durationGettingCounts = ( std::clock() - startGettingCounts ) / (double) CLOCKS_PER_SEC;
            // std::cerr << "Here:" << totalVariantNumber << std::endl;

            
            *outFileAF << chr << "\t" << coord << "\t" << refAllele << "\t" << altAllele;
            if (opt::useGenotypeProbabilities) {
                int likelihoodsOrProbabilitiesTagPosition = c->checkForGenotypeLikelihoodsOrProbabilities(fields);
                if (likelihoodsOrProbabilitiesTagPosition == LikelihoodsProbabilitiesAbsent) {
                    printMissingLikelihoodsWarning(fields[0], fields[1]);
                    opt::useGenotypeProbabilities = false;
                } else c->getAFsFromGenotypeLikelihoodsOrProbabilities(genotypes,posToPopMap,likelihoodsOrProbabilitiesTagPosition);
                for(std::map<string,double>::iterator iter =  c->setAAFsFromLikelihoods.begin(); iter != c->setAAFsFromLikelihoods.end(); ++iter) {
                    *outFileAF << "\t" << iter->second;
                }
            
            } else {
                for(std::map<string,double>::iterator iter =  c->setAAFs.begin(); iter != c->setAAFs.end(); ++iter) {
                    *outFileAF << "\t" << iter->second;
                }
            }
            *outFileAF << "\n";

            genotypes.clear(); genotypes.shrink_to_fit();
            
            delete c;
        }
    }
    
    outFileAF->flush();
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
callq 0xb9eea
leaq 0x30(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq $0x0, -0x8(%rbx)
movb $0x0, (%rbx)
movq 0x4b457(%rip), %rsi     # 0x104070
leaq 0x110(%rsp), %rdi
leaq 0x228(%rsp), %rdx
callq 0x287de
leaq 0x110(%rsp), %rdi
movl $0x8, %esi
callq 0x500af
movq %rax, %r15
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb8c64
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x8480
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %r14
movq %r15, 0x188(%rsp)
movq 0x4b410(%rip), %rsi     # 0x104090
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
leaq 0x118(%rsp), %rcx
xorl %eax, %eax
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x230(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x1d0(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x200(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x20(%rsp), %r15
leaq 0x70(%rsp), %r12
leaq 0x110(%rsp), %r13
leaq 0x228(%rsp), %rbp
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xb8d9b
movq %r12, %rdi
movq %r15, %rsi
movl $0x9, %edx
callq 0x4d650
movq 0x70(%rsp), %rsi
addq $0x20, %rsi
movq %r13, %rdi
callq 0x46fb4
movq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x3133c
movq 0x70(%rsp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3b46e
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8270
movq %r12, %rdi
callq 0x2e784
jmp 0xb8d11
xorpd %xmm0, %xmm0
movapd %xmm0, 0x160(%rsp)
movq $0x0, 0x170(%rsp)
movq 0x128(%rsp), %r14
leaq 0x118(%rsp), %rax
cmpq %rax, %r14
je 0xb8df5
leaq 0x160(%rsp), %r15
leaq 0x20(%r14), %rsi
movq %r15, %rdi
callq 0x3133c
movq %r14, %rdi
callq 0x8310
movq %rax, %r14
leaq 0x118(%rsp), %rax
cmpq %rax, %r14
jne 0xb8dd1
movq 0x491ec(%rip), %rdi     # 0x101fe8
leaq 0x28166(%rip), %rsi     # 0xe0f69
movl $0xa, %edx
callq 0x84e0
movq 0x168(%rsp), %rsi
subq 0x160(%rsp), %rsi
sarq $0x5, %rsi
movq 0x491c0(%rip), %rdi     # 0x101fe8
callq 0x82f0
movq %rax, %r14
leaq 0x18f5d(%rip), %rsi     # 0xd1d94
movl $0xd, %edx
movq %rax, %rdi
callq 0x84e0
movq (%r14), %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
xorpd %xmm0, %xmm0
movapd %xmm0, 0x1b0(%rsp)
xorl %eax, %eax
movq %rax, 0x1c0(%rsp)
movq %rax, 0xa0(%rsp)
movapd %xmm0, 0x90(%rsp)
leaq 0x80(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xd8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x4b1d2(%rip), %rsi     # 0x104090
leaq 0x190(%rsp), %rdi
callq 0x4d82f
leaq 0x1c1aa(%rip), %rsi     # 0xd507c
leaq 0x190(%rsp), %rdi
callq 0x88c0
leaq 0x100(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb8f10
movq %rdx, 0xf0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x100(%rsp)
jmp 0xb8f1a
movupd (%rcx), %xmm0
movupd %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0xf0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x4b170(%rip), %rsi     # 0x1040b0
movq 0x4b171(%rip), %rdx     # 0x1040b8
callq 0x8180
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb8f7c
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0xb8f86
movupd (%rcx), %xmm0
movupd %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0xa8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x252d7(%rip), %rsi     # 0xde283
callq 0x88c0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb8fd7
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0xb8fe0
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rsp, %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x24144(%rip), %rsi     # 0xdd145
callq 0x88c0
leaq 0x50(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb902d
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0xb9035
movupd (%rcx), %xmm0
movupd %xmm0, (%rbx)
movq 0x8(%rax), %rdx
leaq 0x40(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x10, %esi
callq 0x5013e
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0xb9075
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8480
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xb908b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0xb90a8
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0xb90c5
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x1a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb90e6
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x8480
movq $0x0, 0xe8(%rsp)
leaq 0x40(%rsp), %r13
movq %rbx, %r15
movq 0x188(%rsp), %rbx
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xb9ac9
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
addq %rdi, %rsi
movb $0xd, 0x40(%rsp)
movq %r13, %rdx
callq 0x7fd35
movq %rax, %rcx
subq 0x20(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movb $0x0, (%rax)
movq 0x20(%rsp), %rax
cmpb $0x23, (%rax)
movq %r15, %rbx
jne 0xb93e7
movzbl 0x1(%rax), %eax
cmpl $0x23, %eax
je 0xb90f7
cmpl $0x43, %eax
jne 0xb93e7
movq %rsp, %r12
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
movl $0x9, %edx
callq 0x4d650
movq 0xa0(%rsp), %rax
movapd (%rsp), %xmm0
movq 0x10(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
movaps 0x90(%rsp), %xmm1
movapd %xmm0, 0x90(%rsp)
movaps %xmm1, 0x40(%rsp)
movq %rax, 0x50(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r13, %rdi
callq 0x2e784
movq %r12, %rdi
callq 0x2e784
movq 0x90(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq 0x98(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rcx
callq 0x7f67a
movq $0x0, 0x40(%rsp)
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0xb9282
xorl %esi, %esi
shlq $0x5, %rsi
addq %rax, %rsi
leaq 0x228(%rsp), %rdi
callq 0x3b46e
movq %rax, %r12
leaq 0x1f8(%rsp), %rdi
movq %r13, %rsi
callq 0x5d958
movq %rax, %rdi
movq %r12, %rsi
callq 0x8270
movq 0x40(%rsp), %rsi
incq %rsi
movq %rsi, 0x40(%rsp)
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rcx, %rsi
jne 0xb922e
movq 0x128(%rsp), %r12
leaq 0x118(%rsp), %rax
cmpq %rax, %r12
je 0xb94c9
movq %rbx, 0x40(%rsp)
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x2ba06
leaq 0x40(%r12), %rsi
leaq 0xa8(%rsp), %rbp
movq %rbp, %rdi
callq 0x2fc8e
leaq 0xf0(%rsp), %rdi
movq %rsp, %rsi
movq %rbp, %rdx
callq 0x5038c
movq 0xf0(%rsp), %rax
cmpq 0xf8(%rsp), %rax
jne 0xb9376
movl $0x29, %edx
movq 0x48ce9(%rip), %rdi     # 0x101fe8
leaq 0x18bf5(%rip), %rsi     # 0xd1efb
callq 0x84e0
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x48ccc(%rip), %rdi     # 0x101fe8
callq 0x84e0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x17318(%rip), %rsi     # 0xd064b
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 0xf0(%rsp), %rax
cmpq 0xf8(%rsp), %rax
je 0xb9ba3
leaq 0x1c8(%rsp), %rdi
movq %r13, %rsi
callq 0x5d9be
movq %rax, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x5da3a
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xb93b3
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0xa8(%rsp), %rdi
callq 0x2e784
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0xb93d7
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r12, %rdi
callq 0x8310
movq %rax, %r12
jmp 0xb928a
cmpl $0x0, 0xe8(%rsp)
jne 0xb94f7
movl $0x3, %edx
movq %r14, %rdi
leaq 0x26477(%rip), %rsi     # 0xdf87b
callq 0x84e0
movl $0x1, %edx
movq %r14, %rdi
leaq 0x145b2(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movl $0x5, %edx
movq %r14, %rdi
leaq 0x26453(%rip), %rsi     # 0xdf87f
callq 0x84e0
movl $0x1, %edx
movq %r14, %rdi
leaq 0x1458a(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movl $0x3, %edx
movq %r14, %rdi
leaq 0x1338c(%rip), %rsi     # 0xcc7e0
callq 0x84e0
movl $0x1, %edx
movq %r14, %rdi
leaq 0x14562(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movl $0x3, %edx
movq %r14, %rdi
leaq 0x25af3(%rip), %rsi     # 0xdef6f
callq 0x84e0
movq 0x1e0(%rsp), %r12
leaq 0x1d0(%rsp), %rax
cmpq %rax, %r12
je 0xb94e3
movl $0x1, %edx
movq %r14, %rdi
leaq 0x14525(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
movq %r14, %rdi
callq 0x84e0
movq %r12, %rdi
callq 0x8310
movq %rax, %r12
jmp 0xb9489
callq 0x82e0
movq %rax, 0x180(%rsp)
movq %rsp, %rdi
callq 0x2e784
jmp 0xb90f7
movl $0x1, %edx
movq %r14, %rdi
leaq 0x11f4b(%rip), %rsi     # 0xcb43d
callq 0x84e0
movq 0xe8(%rsp), %rax
incl %eax
movq %rax, 0xe8(%rsp)
imull $0x3afb7e91, %eax, %eax # imm = 0x3AFB7E91
addl $0x346dc0, %eax         # imm = 0x346DC0
rorl $0x4, %eax
cmpl $0x68db8, %eax          # imm = 0x68DB8
ja 0xb95d2
callq 0x82e0
subq 0x180(%rsp), %rax
cvtsi2sd %rax, %xmm0
divsd 0x159d4(%rip), %xmm0    # 0xcef10
movsd %xmm0, 0x68(%rsp)
movl $0xa, %edx
movq 0x48a9a(%rip), %rdi     # 0x101fe8
leaq 0x18a11(%rip), %rsi     # 0xd1f66
callq 0x84e0
movq 0x48a87(%rip), %rdi     # 0x101fe8
movq 0xe8(%rsp), %rsi
callq 0x8810
movq %rax, %r12
movl $0xd, %edx
movq %rax, %rdi
leaq 0x1b8ee(%rip), %rsi     # 0xd4e6e
callq 0x84e0
movq %r12, %rdi
movsd 0x68(%rsp), %xmm0
callq 0x8730
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0x1de59(%rip), %rsi     # 0xd73fe
callq 0x84e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r12, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movq %rsp, %r12
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
movl $0x9, %edx
callq 0x4d650
movq 0xa0(%rsp), %rax
movapd (%rsp), %xmm0
movq 0x10(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
movaps 0x90(%rsp), %xmm1
movapd %xmm0, 0x90(%rsp)
movaps %xmm1, 0x40(%rsp)
movq %rax, 0x50(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r13, %rdi
callq 0x2e784
movq %r12, %rdi
callq 0x2e784
movq 0x90(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x8270
movq 0x90(%rsp), %rsi
addq $0x20, %rsi
leaq 0xc8(%rsp), %rdi
callq 0x8270
leaq 0x150(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x140(%rsp), %rdi
callq 0x2ba06
leaq 0x140(%rsp), %rdi
callq 0x4d578
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xb96cb
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x90(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq 0x98(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
movq %r13, %rcx
callq 0x7f67a
movq 0x90(%rsp), %rax
movq %rbx, 0x40(%rsp)
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x2ba06
movq 0x90(%rsp), %rax
leaq 0x10(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x80(%rax), %rsi
movq 0x88(%rax), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x2ba06
cmpq $0x1, 0x48(%rsp)
ja 0xb98a1
cmpq $0x1, 0x8(%rsp)
ja 0xb98a1
movq %rsp, %rdi
leaq 0x26fef(%rip), %rsi     # 0xe074e
callq 0x8160
testl %eax, %eax
je 0xb98a1
callq 0x82e0
movl $0x240, %edi            # imm = 0x240
callq 0x8470
movq %rax, %r13
movq %rax, %r12
movq 0xb0(%rsp), %rdx
subq 0xa8(%rsp), %rdx
shrq $0x5, %rdx
movq %r13, %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x7f6bc
movq %r12, 0x68(%rsp)
movq %r12, %rdi
leaq 0xa8(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
callq 0x4d0d4
callq 0x82e0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq %r14, %rdi
callq 0x84e0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x141df(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
movq %rbp, %rdi
callq 0x84e0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x141b0(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbp, %rdi
callq 0x84e0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x14187(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x84e0
cmpb $0x1, 0x4a870(%rip)     # 0x1040d0
jne 0xb9939
movq 0x68(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x5169a
testl %eax, %eax
je 0xb9988
movq 0x68(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
movl %eax, %ecx
callq 0x510b0
jmp 0xb99a0
movq $0x0, 0x48(%rsp)
movq 0x40(%rsp), %rax
movb $0x0, (%rax)
movq %r13, %rdi
callq 0x8290
movq $0x0, 0x8(%rsp)
movq (%rsp), %rax
movb $0x0, (%rax)
movq %rsp, %rdi
callq 0x8290
movq 0xa8(%rsp), %r12
movq 0xb0(%rsp), %rbp
cmpq %r12, %rbp
je 0xb9918
leaq 0x10(%r12), %rbx
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0xb9900
movq (%rbx), %rsi
incq %rsi
callq 0x8480
leaq 0x20(%rbx), %rax
addq $0x10, %rbx
cmpq %rbp, %rbx
movq %rax, %rbx
jne 0xb98ec
movq %r12, 0xb0(%rsp)
cmpq %r12, 0xb8(%rsp)
je 0xb992f
leaq 0xa8(%rsp), %rdi
callq 0x7fe80
xorl %ebp, %ebp
movq %r15, %rbx
jmp 0xb9a7f
movq 0x68(%rsp), %rax
movq 0xf8(%rax), %rbp
addq $0xe8, %r13
cmpq %r13, %rbp
je 0xb99e9
movl $0x1, %edx
movq %r14, %rdi
leaq 0x14066(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movsd 0x40(%rbp), %xmm0
movq %r14, %rdi
callq 0x8730
movq %rbp, %rdi
callq 0x8310
movq %rax, %rbp
cmpq %r13, %rax
jne 0xb9955
jmp 0xb99e9
movq 0x90(%rsp), %rdi
leaq 0x20(%rdi), %rsi
callq 0x4cba4
movb $0x0, 0x4a730(%rip)     # 0x1040d0
movq 0x68(%rsp), %rax
movq 0x168(%rax), %rbp
addq $0x158, %r13            # imm = 0x158
cmpq %r13, %rbp
je 0xb99e9
movl $0x1, %edx
movq %r14, %rdi
leaq 0x14003(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movsd 0x40(%rbp), %xmm0
movq %r14, %rdi
callq 0x8730
movq %rbp, %rdi
callq 0x8310
movq %rax, %rbp
cmpq %r13, %rax
jne 0xb99b8
movl $0x1, %edx
movq %r14, %rdi
leaq 0x11a45(%rip), %rsi     # 0xcb43d
callq 0x84e0
movq 0xa8(%rsp), %r12
movq 0xb0(%rsp), %rbp
cmpq %r12, %rbp
leaq 0x40(%rsp), %r13
je 0xb9a4b
leaq 0x10(%r12), %rbx
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0xb9a30
movq (%rbx), %rsi
incq %rsi
callq 0x8480
leaq 0x20(%rbx), %rax
addq $0x10, %rbx
cmpq %rbp, %rbx
movq %rax, %rbx
jne 0xb9a1c
movq %r12, 0xb0(%rsp)
movq %r15, %rbx
cmpq %r12, 0xb8(%rsp)
je 0xb9a62
leaq 0xa8(%rsp), %rdi
callq 0x7fe80
movq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x7fb02
movl $0x240, %esi            # imm = 0x240
movq %r15, %rdi
callq 0x8480
movb $0x1, %bpl
leaq 0x10(%rsp), %rax
movq (%rsp), %rdi
cmpq %rax, %rdi
je 0xb9a9a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
leaq 0xa8(%rsp), %r15
je 0xb9ab9
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r15, %rdi
callq 0x2e784
testb %bpl, %bpl
jmp 0xb90f7
movq %r14, %rdi
callq 0x8300
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
leaq 0x30(%rsp), %rbx
leaq 0x80(%rsp), %r14
je 0xb9b03
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0xb9b1d
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x90(%rsp), %rdi
callq 0x2e784
leaq 0x1b0(%rsp), %rdi
callq 0x2e784
leaq 0x160(%rsp), %rdi
callq 0x2e784
leaq 0x1f8(%rsp), %rdi
callq 0x5df54
leaq 0x1c8(%rsp), %rdi
callq 0x5dfcc
leaq 0x228(%rsp), %rdi
callq 0x3c6d4
leaq 0x110(%rsp), %rdi
callq 0x3c602
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0xb9b8f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8480
xorl %eax, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1837b(%rip), %rdi     # 0xd1f25
leaq 0x25c9f(%rip), %rsi     # 0xdf850
leaq 0x25caa(%rip), %rcx     # 0xdf862
movl $0x68, %edx
callq 0x82c0
movq %rax, %rbp
movl $0x240, %esi            # imm = 0x240
movq %r12, %rdi
callq 0x8480
jmp 0xb9d38
jmp 0xb9d35
jmp 0xb9d9f
jmp 0xb9d9f
jmp 0xb9d9f
movq %rax, %rbp
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0xb9c0a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xb9c0a
movq %rax, %rbp
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb9c2a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xb9c2a
movq %rax, %rbp
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0xb9c4c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xb9c4c
movq %rax, %rbp
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0xb9c6e
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xb9c6e
movq %rax, %rbp
leaq 0x1a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb9da2
movq 0x1a0(%rsp), %rsi
jmp 0xb9d14
jmp 0xb9d9f
movq %rax, %rbp
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
callq 0x8480
leaq 0x30(%rsp), %rbx
jmp 0xb9ecb
jmp 0xb9cde
movq %rax, %rbp
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb9ecb
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xb9ecb
movq %rax, %rbp
jmp 0xb9ecb
jmp 0xb9ce8
movq %rax, %rdi
callq 0x288e1
movq %rax, %rbp
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xb9da2
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xb9da2
jmp 0xb9d9f
movq %rax, %rbp
jmp 0xb9d6a
jmp 0xb9d9f
movq %rax, %rbp
jmp 0xb9d53
jmp 0xb9d35
jmp 0xb9d87
jmp 0xb9d35
movq %rax, %rbp
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb9d53
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0xb9d6a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0xa8(%rsp), %rdi
callq 0x2e784
jmp 0xb9da2
jmp 0xb9d9f
jmp 0xb9d9a
movq %rax, %rbp
jmp 0xb9df1
movq %rax, %rbp
jmp 0xb9de1
movq %rax, %rbp
leaq 0x30(%rsp), %rbx
jmp 0xb9e76
jmp 0xb9d9f
jmp 0xb9d9f
jmp 0xb9db9
movq %rax, %rbp
jmp 0xb9e08
movq %rax, %rbp
leaq 0x30(%rsp), %rbx
leaq 0x80(%rsp), %r14
leaq 0xd8(%rsp), %r12
jmp 0xb9e25
movq %rax, %rbp
jmp 0xb9e92
movq %rax, %rbp
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xb9de1
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0xa8(%rsp), %rdi
callq 0x2e784
movq %r15, %rbx
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0xb9e08
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x30(%rsp), %rbx
leaq 0x80(%rsp), %r14
leaq 0xd8(%rsp), %r12
movq %rsp, %rdi
callq 0x2e784
movq 0xc8(%rsp), %rdi
cmpq %r12, %rdi
je 0xb9e42
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0xb9e5c
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x90(%rsp), %rdi
callq 0x2e784
leaq 0x1b0(%rsp), %rdi
callq 0x2e784
leaq 0x160(%rsp), %rdi
callq 0x2e784
jmp 0xb9e97
movq %rax, %rbp
leaq 0x70(%rsp), %rdi
callq 0x2e784
leaq 0x30(%rsp), %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x5df54
leaq 0x1c8(%rsp), %rdi
callq 0x5dfcc
leaq 0x228(%rsp), %rdi
callq 0x3c6d4
leaq 0x110(%rsp), %rdi
callq 0x3c602
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0xb9ee2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8480
movq %rbp, %rdi
callq 0x8840