// File: /workspace/github_cpp_makefile_star2_O1/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 $0x248, %rsp            # imm = 0x248
callq 0xbaf28
leaq 0xa8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq $0x0, -0x8(%rbx)
movb $0x0, (%rbx)
movq 0x533cc(%rip), %rsi     # 0x10d060
leaq 0x100(%rsp), %rdi
leaq 0x218(%rsp), %rdx
callq 0x286de
leaq 0x100(%rsp), %rdi
movl $0x8, %esi
callq 0x53224
movq %rax, %r15
leaq 0x110(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb9cdf
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x8480
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %r14
movq %r15, 0x178(%rsp)
movq 0x53385(%rip), %rsi     # 0x10d080
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
leaq 0x108(%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 0x220(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x1c0(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x1f0(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x98(%rsp), %r15
leaq 0x78(%rsp), %r12
leaq 0x100(%rsp), %r13
leaq 0x218(%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 0xb9e19
movq %r12, %rdi
movq %r15, %rsi
movl $0x9, %edx
callq 0x50624
movq 0x78(%rsp), %rsi
addq $0x20, %rsi
movq %r13, %rdi
callq 0x49f44
movq 0x78(%rsp), %rsi
movq %rax, %rdi
callq 0x33db0
movq 0x78(%rsp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3e394
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8270
movq %r12, %rdi
callq 0x3123c
jmp 0xb9d8f
xorpd %xmm0, %xmm0
movapd %xmm0, 0x150(%rsp)
movq $0x0, 0x160(%rsp)
movq 0x118(%rsp), %r14
leaq 0x108(%rsp), %rax
cmpq %rax, %r14
je 0xb9e73
leaq 0x150(%rsp), %r15
leaq 0x20(%r14), %rsi
movq %r15, %rdi
callq 0x33db0
movq %r14, %rdi
callq 0x8310
movq %rax, %r14
leaq 0x108(%rsp), %rax
cmpq %rax, %r14
jne 0xb9e4f
movq 0x5116e(%rip), %rdi     # 0x10afe8
leaq 0x30070(%rip), %rsi     # 0xe9ef1
movl $0xa, %edx
callq 0x84e0
movq 0x158(%rsp), %rsi
subq 0x150(%rsp), %rsi
sarq $0x5, %rsi
movq 0x51142(%rip), %rdi     # 0x10afe8
callq 0x82f0
movq %rax, %r14
leaq 0x1e39f(%rip), %rsi     # 0xd8254
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, 0x1a0(%rsp)
xorl %eax, %eax
movq %rax, 0x1b0(%rsp)
movq %rax, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
leaq 0x88(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xf0(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq %rax, -0x8(%rbx)
movb %al, (%rbx)
leaq 0x5314a(%rip), %rsi     # 0x10d080
leaq 0x180(%rsp), %rdi
callq 0x50803
leaq 0x215f2(%rip), %rsi     # 0xdb53c
leaq 0x180(%rsp), %rdi
callq 0x88c0
leaq 0xd0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb9f88
movq %rdx, 0xc0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xd0(%rsp)
jmp 0xb9f92
movupd (%rcx), %xmm0
movupd %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0xc0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x530e8(%rip), %rsi     # 0x10d0a0
movq 0x530e9(%rip), %rdx     # 0x10d0a8
callq 0x8180
leaq 0x68(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb9feb
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0xb9ff5
movupd (%rcx), %xmm0
movupd %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0x58(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x2d1f3(%rip), %rsi     # 0xe720b
callq 0x88c0
leaq 0x30(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xba044
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0xba04c
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x20(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x2aae6(%rip), %rsi     # 0xe4b55
callq 0x88c0
leaq 0x10(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xba09a
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0xba0a2
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rsp, %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x10, %esi
callq 0x532b3
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xba0e4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xba100
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0xba117
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0xc0(%rsp), %rdi
cmpq %r12, %rdi
je 0xba134
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x190(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xba155
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x8480
movq $0x0, 0xb8(%rsp)
movq %rsp, %r13
leaq 0x58(%rsp), %rbp
movq 0x178(%rsp), %r15
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %r15, %rdi
leaq 0x98(%rsp), %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xbab00
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %rsi
addq %rdi, %rsi
movb $0xd, (%rsp)
movq %r13, %rdx
callq 0x80103
movq %rax, %rcx
subq 0x98(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
movb $0x0, (%rax)
movq 0x98(%rsp), %rax
movb (%rax), %cl
cmpb $0x23, %cl
jne 0xba207
cmpb $0x23, 0x1(%rax)
je 0xba169
cmpb $0x23, %cl
jne 0xba207
cmpb $0x43, 0x1(%rax)
je 0xba892
cmpl $0x0, 0xb8(%rsp)
jne 0xba2fb
movl $0x3, %edx
movq %r14, %rdi
leaq 0x2e5df(%rip), %rsi     # 0xe8803
callq 0x84e0
movl $0x1, %edx
movq %r14, %rdi
leaq 0x17a46(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movl $0x5, %edx
movq %r14, %rdi
leaq 0x2e5bb(%rip), %rsi     # 0xe8807
callq 0x84e0
movl $0x1, %edx
movq %r14, %rdi
leaq 0x17a1e(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movl $0x3, %edx
movq %r14, %rdi
leaq 0x152b4(%rip), %rsi     # 0xcf528
callq 0x84e0
movl $0x1, %edx
movq %r14, %rdi
leaq 0x179f6(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movl $0x3, %edx
movq %r14, %rdi
leaq 0x2dc5b(%rip), %rsi     # 0xe7ef7
callq 0x84e0
movq 0x1d0(%rsp), %r15
leaq 0x1c0(%rsp), %rax
cmpq %rax, %r15
je 0xba2e7
movl $0x1, %edx
movq %r14, %rdi
leaq 0x179b9(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
movq %r14, %rdi
callq 0x84e0
movq %r15, %rdi
callq 0x8310
movq %rax, %r15
jmp 0xba2a9
movl $0x1, %edx
movq %r14, %rdi
leaq 0x12387(%rip), %rsi     # 0xcc67d
callq 0x84e0
movq 0xb8(%rsp), %rax
incl %eax
movq %rax, 0xb8(%rsp)
imull $0x3afb7e91, %eax, %eax # imm = 0x3AFB7E91
addl $0x346dc0, %eax         # imm = 0x346DC0
rorl $0x4, %eax
cmpl $0x68db8, %eax          # imm = 0x68DB8
ja 0xba3db
callq 0x82e0
subq 0x168(%rsp), %rax
cvtsi2sd %rax, %xmm0
divsd 0x1aea8(%rip), %xmm0    # 0xd51e8
movsd %xmm0, 0x170(%rsp)
movl $0xa, %edx
movq 0x50c93(%rip), %rdi     # 0x10afe8
leaq 0x1e0ca(%rip), %rsi     # 0xd8426
callq 0x84e0
movq 0x50c80(%rip), %rdi     # 0x10afe8
movq 0xb8(%rsp), %rsi
callq 0x8810
movq %rax, %r15
movl $0xd, %edx
movq %rax, %rdi
leaq 0x20fa7(%rip), %rsi     # 0xdb32e
callq 0x84e0
movq %r15, %rdi
movsd 0x170(%rsp), %xmm0
callq 0x8730
movq %rax, %r15
movl $0x4, %edx
movq %rax, %rdi
leaq 0x23fbf(%rip), %rsi     # 0xde36e
callq 0x84e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r15, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x20(%rsp), %r15
movq %r15, %rdi
leaq 0x98(%rsp), %rsi
movl $0x9, %edx
callq 0x50624
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movapd 0x40(%rsp), %xmm0
movq 0x50(%rsp), %rax
movups 0x20(%rsp), %xmm1
movaps %xmm1, 0x40(%rsp)
movq 0x30(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movaps (%rsp), %xmm1
movapd %xmm0, (%rsp)
movq %rax, 0x10(%rsp)
movups %xmm1, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %r13, %rdi
callq 0x3123c
movq %r15, %rdi
callq 0x3123c
movq 0x40(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x8270
movq 0x40(%rsp), %rsi
addq $0x20, %rsi
leaq 0xe0(%rsp), %rdi
callq 0x8270
leaq 0x140(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x130(%rsp), %rdi
callq 0x2e45c
leaq 0x130(%rsp), %rdi
callq 0x5054c
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0xba4d0
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x40(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq 0x48(%rsp), %rdx
movq %rbp, %rdi
movq %r13, %rcx
callq 0x7fa48
movq 0x40(%rsp), %rax
leaq 0x10(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x2e45c
movq 0x40(%rsp), %rax
leaq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq 0x80(%rax), %rsi
movq 0x88(%rax), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x2e45c
cmpq $0x1, 0x8(%rsp)
ja 0xba689
cmpq $0x1, 0x28(%rsp)
ja 0xba689
leaq 0x20(%rsp), %rdi
leaq 0x2f17a(%rip), %rsi     # 0xe96d6
callq 0x8160
testl %eax, %eax
je 0xba689
callq 0x82e0
movl $0x240, %edi            # imm = 0x240
callq 0x8470
movq %rax, %r15
movq %rax, %rbp
movq 0x60(%rsp), %rdx
subq 0x58(%rsp), %rdx
shrq $0x5, %rdx
movq %r15, %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x7fa8a
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
leaq 0x1e8(%rsp), %rdx
callq 0x500d0
callq 0x82e0
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq %r14, %rdi
callq 0x84e0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x176a1(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
movq %r12, %rdi
callq 0x84e0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x17672(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r12, %rdi
callq 0x84e0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1764a(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %r12, %rdi
callq 0x84e0
cmpb $0x1, 0x52a6e(%rip)     # 0x10d0c0
jne 0xba716
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x54842
testl %eax, %eax
je 0xba762
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
leaq 0x1e8(%rsp), %rdx
movl %eax, %ecx
callq 0x54258
jmp 0xba777
movq $0x0, 0x8(%rsp)
movq (%rsp), %rax
movb $0x0, (%rax)
movq %r13, %rdi
callq 0x8290
movq $0x0, 0x28(%rsp)
movq 0x20(%rsp), %rax
movb $0x0, (%rax)
leaq 0x20(%rsp), %rdi
callq 0x8290
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %r12
cmpq %r15, %r12
je 0xba6f9
leaq 0x10(%r15), %rbp
movq -0x10(%rbp), %rdi
cmpq %rdi, %rbp
je 0xba6e4
movq (%rbp), %rsi
incq %rsi
callq 0x8480
leaq 0x20(%rbp), %rax
addq $0x10, %rbp
cmpq %r12, %rbp
movq %rax, %rbp
jne 0xba6cf
movq %r15, 0x60(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0xba70f
leaq 0x58(%rsp), %rdi
callq 0x8024a
xorl %ebp, %ebp
jmp 0xba843
movq 0xf8(%rbp), %r12
addq $0xe8, %r15
cmpq %r15, %r12
je 0xba7bd
movl $0x1, %edx
movq %r14, %rdi
leaq 0x17542(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movsd 0x40(%r12), %xmm0
movq %r14, %rdi
callq 0x8730
movq %r12, %rdi
callq 0x8310
movq %rax, %r12
cmpq %r15, %rax
jne 0xba72d
jmp 0xba7bd
movq 0x40(%rsp), %rdi
leaq 0x20(%rdi), %rsi
callq 0x4fba0
movb $0x0, 0x52949(%rip)     # 0x10d0c0
movq 0x168(%rbp), %r12
addq $0x158, %r15            # imm = 0x158
cmpq %r15, %r12
je 0xba7bd
movl $0x1, %edx
movq %r14, %rdi
leaq 0x174e5(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movsd 0x40(%r12), %xmm0
movq %r14, %rdi
callq 0x8730
movq %r12, %rdi
callq 0x8310
movq %rax, %r12
cmpq %r15, %rax
jne 0xba78a
movl $0x1, %edx
movq %r14, %rdi
leaq 0x11eb1(%rip), %rsi     # 0xcc67d
callq 0x84e0
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %r12
cmpq %r15, %r12
je 0xba80d
leaq 0x10(%r15), %rbx
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0xba7f8
movq (%rbx), %rsi
incq %rsi
callq 0x8480
leaq 0x20(%rbx), %rax
addq $0x10, %rbx
cmpq %r12, %rbx
movq %rax, %rbx
jne 0xba7e4
movq %r15, 0x60(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0xba823
leaq 0x58(%rsp), %rdi
callq 0x8024a
movq %rbp, %rdi
callq 0x7fed0
movl $0x240, %esi            # imm = 0x240
movq %rbp, %rdi
callq 0x8480
movb $0x1, %bpl
leaq 0xf0(%rsp), %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xba85f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8480
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xba87a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x3123c
testb %bpl, %bpl
movq %r15, %rbp
jmp 0xba169
leaq 0x20(%rsp), %r15
movq %r15, %rdi
leaq 0x98(%rsp), %rsi
movl $0x9, %edx
callq 0x50624
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movapd 0x40(%rsp), %xmm0
movq 0x50(%rsp), %rax
movups 0x20(%rsp), %xmm1
movaps %xmm1, 0x40(%rsp)
movq 0x30(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movaps (%rsp), %xmm1
movapd %xmm0, (%rsp)
movq %rax, 0x10(%rsp)
movups %xmm1, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %r13, %rdi
callq 0x3123c
movq %r15, %rdi
callq 0x3123c
movq 0x40(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq 0x48(%rsp), %rdx
movq %r15, %rdi
movq %r13, %rcx
callq 0x7fa48
movq $0x0, (%rsp)
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%rsp)
je 0xba986
xorl %esi, %esi
shlq $0x5, %rsi
addq %rax, %rsi
leaq 0x218(%rsp), %rdi
callq 0x3e394
movq %rax, %r15
leaq 0x1e8(%rsp), %rdi
movq %r13, %rsi
callq 0x5d80c
movq %rax, %rdi
movq %r15, %rsi
callq 0x8270
movq (%rsp), %rsi
incq %rsi
movq %rsi, (%rsp)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rcx, %rsi
jne 0xba933
movq 0x118(%rsp), %r15
leaq 0x108(%rsp), %rax
cmpq %rax, %r15
je 0xbaae4
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x2e45c
leaq 0x40(%r15), %rsi
movq %rbp, %rdi
callq 0x3273a
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rbp, %rdx
callq 0x53501
movq 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jne 0xbaa74
movl $0x29, %edx
movq 0x505ea(%rip), %rdi     # 0x10afe8
leaq 0x1d9b6(%rip), %rsi     # 0xd83bb
callq 0x84e0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x505ce(%rip), %rdi     # 0x10afe8
callq 0x84e0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1c6ee(%rip), %rsi     # 0xd711f
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 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
je 0xbabd8
leaq 0x1b8(%rsp), %rdi
movq %r13, %rsi
callq 0x5d872
movq %rax, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x5d8ee
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xbaab1
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq %rbp, %rdi
callq 0x3123c
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xbaad4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r15, %rdi
callq 0x8310
movq %rax, %r15
jmp 0xba98e
callq 0x82e0
movq %rax, 0x168(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x3123c
jmp 0xba169
movq %r14, %rdi
callq 0x8300
movq 0xe0(%rsp), %rdi
cmpq %rbx, %rdi
leaq 0xa8(%rsp), %rbx
leaq 0x88(%rsp), %r14
je 0xbab35
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0xbab4f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x40(%rsp), %rdi
callq 0x3123c
leaq 0x1a0(%rsp), %rdi
callq 0x3123c
leaq 0x150(%rsp), %rdi
callq 0x3123c
leaq 0x1e8(%rsp), %rdi
callq 0x5ddda
leaq 0x1b8(%rsp), %rdi
callq 0x5de52
leaq 0x218(%rsp), %rdi
callq 0x3f5f4
leaq 0x100(%rsp), %rdi
callq 0x3f522
movq 0x98(%rsp), %rdi
cmpq %rbx, %rdi
je 0xbabc4
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x8480
xorl %eax, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d806(%rip), %rdi     # 0xd83e5
leaq 0x2dbf2(%rip), %rsi     # 0xe87d8
leaq 0x2dbfd(%rip), %rcx     # 0xe87ea
movl $0x68, %edx
callq 0x82c0
jmp 0xbae45
jmp 0xbae45
movq %rax, %r15
jmp 0xbad61
movq %rax, %r15
jmp 0xbad57
jmp 0xbac2d
jmp 0xbadda
movq %rax, %r15
movl $0x240, %esi            # imm = 0x240
movq %rbp, %rdi
callq 0x8480
jmp 0xbaddd
movq %rax, %r15
jmp 0xbad7c
jmp 0xbae45
movq %rax, %r15
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xbac5d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xbac5d
movq %rax, %r15
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xbac7e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xbac7e
movq %rax, %r15
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0xbac9a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xbac9a
movq %rax, %r15
movq 0xc0(%rsp), %rdi
cmpq %r12, %rdi
je 0xbacbc
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xbacbc
movq %rax, %r15
leaq 0x190(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbae48
movq 0x190(%rsp), %rsi
jmp 0xbadc8
jmp 0xbae45
movq %rax, %r15
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
callq 0x8480
leaq 0xa8(%rsp), %rbx
jmp 0xbaf03
jmp 0xbad2f
movq %rax, %r15
leaq 0x110(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbaf03
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xbaf03
movq %rax, %r15
jmp 0xbaf03
movq %rax, %r15
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xbad57
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x58(%rsp), %rdi
callq 0x3123c
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xbad7c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x20(%rsp), %rdi
callq 0x3123c
jmp 0xbae48
jmp 0xbad8d
movq %rax, %rdi
callq 0x287e1
movq %rax, %r15
jmp 0xbadf9
movq %rax, %r15
jmp 0xbae14
jmp 0xbae45
movq %rax, %r15
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0xbae48
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x8480
jmp 0xbae48
jmp 0xbae45
jmp 0xbadda
jmp 0xbae32
jmp 0xbadda
movq %rax, %r15
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xbadf9
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8480
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xbae14
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x58(%rsp), %rdi
callq 0x3123c
leaq 0x88(%rsp), %r14
leaq 0xf0(%rsp), %rbx
jmp 0xbae50
jmp 0xbae45
movq %rax, %r15
leaq 0xa8(%rsp), %rbx
jmp 0xbaea6
jmp 0xbae45
jmp 0xbae45
jmp 0xbaeb5
movq %rax, %r15
leaq 0x88(%rsp), %r14
movq 0xe0(%rsp), %rdi
cmpq %rbx, %rdi
leaq 0xa8(%rsp), %rbx
je 0xbae75
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0xbae8f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8480
leaq 0x40(%rsp), %rdi
callq 0x3123c
leaq 0x1a0(%rsp), %rdi
callq 0x3123c
leaq 0x150(%rsp), %rdi
callq 0x3123c
jmp 0xbaecf
movq %rax, %r15
jmp 0xbaec7
movq %rax, %r15
leaq 0x78(%rsp), %rdi
callq 0x3123c
leaq 0xa8(%rsp), %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x5ddda
leaq 0x1b8(%rsp), %rdi
callq 0x5de52
leaq 0x218(%rsp), %rdi
callq 0x3f5f4
leaq 0x100(%rsp), %rdi
callq 0x3f522
movq 0x98(%rsp), %rdi
cmpq %rbx, %rdi
je 0xbaf20
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r15, %rdi
callq 0x8840