// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/evo_protein_SegregatingSites.cpp
// Function: ProteinSs(int, char**)
int ProteinSs(int argc, char** argv) {
    parseProteinSsOptions(argc, argv);
    std::vector<string> allAligmentFiles; string AAFileName;
    std::vector<string> allNewLabels;
    
    
    std::cerr << "Outputting segregating sites" << std::endl;
    
    if (opt::alignmentFile != "") {
        allAligmentFiles.push_back(opt::alignmentFile);
        // look at suffix
        size_t suffixPos = opt::alignmentFile.find_last_of('.');
        if (suffixPos !=  std::string::npos) {
            if (opt::alignmentFile.substr(suffixPos) == ".fa" || opt::alignmentFile.substr(suffixPos) == ".fasta")
                std::cerr << "for the gene: " << stripExtension(opt::alignmentFile) << std::endl;
            else
                std::cerr << "for the gene: " << opt::alignmentFile << std::endl;
        } else {
            std::cerr << "for the gene: " << opt::alignmentFile << std::endl;
        }
    } else {
        std::ifstream* alignmentList = new std::ifstream(opt::alignmentListFile.c_str());
        std::cerr << "for the genes in: " << opt::alignmentListFile << std::endl;
        std::string line;
        while (getline(*alignmentList, line)) {
            allAligmentFiles.push_back(line);
        }
    }
    if (opt::newLabelFile != "") {
        std::cerr << "using labels from: " << opt::newLabelFile << std::endl;
        std::ifstream* newLabels = new std::ifstream(opt::newLabelFile.c_str());
        std::string line;
        while (getline(*newLabels, line)) {
            allNewLabels.push_back(line);
        }
    }
    
    // Loop over the mutiple alignment files:
    for (std::vector<std::string>::size_type i = 0; i != allAligmentFiles.size(); i++) {
        std::ifstream* alignment = new std::ifstream(allAligmentFiles[i].c_str());
        std::vector<string> allSeqs; std::vector<string> allSeqsAA;
        std::vector<int> ssPos;
        // Load the DNA alignment
        std::string line; int lineNum = 1;
        while (getline(*alignment, line)) {
            if (lineNum % 2 == 1) assert(line[0] == '>');
            lineNum++;
            if (line[0] == '>' && opt::newLabelFile != "") continue;
            if (line[0] == '>' && opt::newLabelFile == "") { allNewLabels.push_back(line); continue; }
            allSeqs.push_back(line);
        } alignment->close();
        
        // std::cerr << "loaded seqs for: " << allAligmentFiles[i] << std::endl;
        //std::cerr << "allSeqs.size(): " << allSeqs.size() << std::endl;
        // Translate to Amino Acid sequences:
        std::string::size_type geneLength = allSeqs[0].length();
        int numSamples = (int)allSeqs.size();
        std::vector<string> altCodons; altCodons.resize(numSamples);
        allSeqsAA.resize(numSamples);
        std::vector<string> uniqueHpt; std::vector<string> uniqueNames;
        std::vector<string> otherSamples;
        if (numSamples > 0) {
            for (std::vector<std::string>::size_type j = 0; j != numSamples; j++) {
                allSeqsAA[j].reserve(geneLength);
            }
            for (string::size_type k = 0; k != geneLength; k++) {
                // Find if it's a segregating site:
                bool segregating = false;
                for (std::vector<std::string>::size_type j = 0; j != numSamples - 1; j++) {
                    for (std::vector<std::string>::size_type l = j + 1; l != numSamples; l++) {
                        if (allSeqs[j][k] != allSeqs[l][k]) {
                            segregating = true; break;
                        }
                    }
                    if (segregating) break;
                }
                if (segregating) {
                    ssPos.push_back((int)k+1);
                    for (std::vector<std::string>::size_type j = 0; j != numSamples; j++) {
                        allSeqsAA[j] += allSeqs[j][k];
                    }
                }
            }
            
            // Only print unique haplotypes (and keep a list of other samples with the same):
            // otherSamples.resize(numSamples);
            for (std::vector<std::string>::size_type j = 0; j != numSamples; j++) {
                bool unique = true;
                for (std::vector<std::string>::size_type l = 0; l != uniqueHpt.size(); l++) {
                    if (allSeqsAA[j] == uniqueHpt[l]) {
                        unique = false;
                        if (otherSamples[l] != "") otherSamples[l] += ',';
                        otherSamples[l] += allNewLabels[j].substr(1);
                    }
                }
                if (unique) {
                    uniqueHpt.push_back(allSeqsAA[j]);
                    uniqueNames.push_back(allNewLabels[j]);
                    otherSamples.push_back("");
                }
            }
            
            string ancSeq = allSeqsAA[0];  // For now we don't know the ancestral states at the segregating sites
                                            // so just arbitrarily taking the first one as the reference
            for (string::size_type k = 0; k != ancSeq.length(); k++) {
                for (std::vector<std::string>::size_type j = 1; j != numSamples; j++) {
                    if (allSeqsAA[j][k] == ancSeq[k]) {
                        allSeqsAA[j][k] = '.';
                    }
                }
                for (std::vector<std::string>::size_type j = 1; j != uniqueHpt.size(); j++) {
                    if (uniqueHpt[j][k] == ancSeq[k]) {
                        uniqueHpt[j][k] = '.';
                    }
                }
            }
        } else{
            std::cerr << allAligmentFiles[i] << "has no alignment.." << std::endl;
        }
        //std::cerr << "processed seqs for: " << allAligmentFiles[i] << std::endl;
        //std::cerr << "going to output: " << allAligmentFiles[i] << std::endl;
        size_t suffixPos = allAligmentFiles[i].find_last_of('.');
        if (suffixPos != std::string::npos) {
            if (allAligmentFiles[i].substr(suffixPos) == ".fa" || allAligmentFiles[i].substr(suffixPos) == ".fasta")
                AAFileName = opt::outFolder + stripExtension(allAligmentFiles[i]) + "_ssPos.txt";
            else
                AAFileName = opt::outFolder + allAligmentFiles[i] + "_ssPos.txt";
        } else {
            AAFileName = opt::outFolder + allAligmentFiles[i] + "_ssPos.txt";
        }
        //std::cerr << "into: " << AAFileName << std::endl;
        std::ofstream* AAalignment = new std::ofstream(AAFileName.c_str());
        *AAalignment << "Amino Acid positions:" << "\t"; print_vector(ssPos, *AAalignment,' ');
        /*
        for (std::vector<std::string>::size_type j = 0; j != numSamples; j++) {
            if (allNewLabels[j].length() < 16)
                *AAalignment << allNewLabels[j] << "\t\t" << allSeqsAA[j] << std::endl;
            else
                *AAalignment << allNewLabels[j] << "\t" << allSeqsAA[j] << std::endl;
        } AAalignment->close(); */
        for (std::vector<std::string>::size_type j = 0; j != uniqueHpt.size(); j++) {
            if (uniqueNames[j].length() < 16)
                *AAalignment << uniqueNames[j] << "\t\t" << uniqueHpt[j] << "\t" << otherSamples [j] << std::endl;
            else
                *AAalignment << uniqueNames[j] << "\t" << uniqueHpt[j] << "\t" << otherSamples [j] << std::endl;
        } AAalignment->close();
        
        
        
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
callq 0x34631
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x170(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movaps %xmm0, 0xe0(%rsp)
andq $0x0, 0xf0(%rsp)
movq 0xa9620(%rip), %rdi     # 0xdcfe8
leaq 0x663b1(%rip), %rsi     # 0x99d80
callq 0x8480
movq %rax, %rdi
callq 0x8230
leaq 0xaa2bd(%rip), %rdi     # 0xddca0
leaq 0x66435(%rip), %rsi     # 0x99e1f
callq 0x2ea9b
testb %al, %al
je 0x33a5c
leaq 0xaa2a6(%rip), %rsi     # 0xddca0
leaq 0x20(%rsp), %rdi
callq 0x2b0a4
leaq 0xaa295(%rip), %rdi     # 0xddca0
pushq $0x2e
popq %rsi
pushq $-0x1
popq %rdx
callq 0x8940
cmpq $-0x1, %rax
je 0x33b6c
movq %rax, %rbx
leaq 0xaa276(%rip), %rsi     # 0xddca0
movq %rsp, %rdi
pushq $-0x1
popq %rcx
movq %rax, %rdx
callq 0x84b0
leaq 0x7584b(%rip), %rsi     # 0xa928a
movq %rsp, %rdi
callq 0x2193f
testb %al, %al
je 0x33ae8
movq %rsp, %rdi
callq 0x8978
jmp 0x33b2a
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq %rax, %r14
movq 0xaa250(%rip), %rsi     # 0xddcc0
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x8890
movq 0xa9566(%rip), %rdi     # 0xdcfe8
leaq 0x62bc7(%rip), %rsi     # 0x96650
callq 0x8480
leaq 0xaa22b(%rip), %rsi     # 0xddcc0
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsp, %rbx
leaq 0x20(%rsp), %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x33b62
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2b0a4
jmp 0x33abe
leaq 0xaa1b1(%rip), %rsi     # 0xddca0
leaq 0x40(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %rbx, %rdx
callq 0x84b0
leaq 0x67193(%rip), %rsi     # 0x9ac99
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x2193f
movl %eax, %ebp
movq %rbx, %rdi
callq 0x8978
movq %rsp, %rdi
callq 0x8978
testb %bpl, %bpl
je 0x33b6c
movq 0xa94b7(%rip), %rdi     # 0xdcfe8
leaq 0x66265(%rip), %rsi     # 0x99d9d
callq 0x8480
movq %rax, %rbx
leaq 0xaa159(%rip), %rsi     # 0xddca0
movq %rsp, %rdi
callq 0x404d7
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
movq %rsp, %rdi
callq 0x8978
jmp 0x33b96
movq 0xa9475(%rip), %rdi     # 0xdcfe8
leaq 0x66223(%rip), %rsi     # 0x99d9d
callq 0x8480
leaq 0xaa11a(%rip), %rsi     # 0xddca0
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0xaa143(%rip), %rdi     # 0xddce0
leaq 0x6627b(%rip), %rsi     # 0x99e1f
callq 0x2ea9b
testb %al, %al
je 0x33c44
movq 0xa9430(%rip), %rdi     # 0xdcfe8
leaq 0x652af(%rip), %rsi     # 0x98e6e
callq 0x8480
leaq 0xaa115(%rip), %rsi     # 0xddce0
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq %rax, %r14
movq 0xaa0f1(%rip), %rsi     # 0xddce0
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x8890
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsp, %rbx
leaq 0xe0(%rsp), %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x33c3c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2b0a4
jmp 0x33c16
movq %rsp, %rdi
callq 0x8978
xorl %r15d, %r15d
movq %rsp, %r12
pushq $-0x1
popq %r13
leaq 0x661c9(%rip), %rbp     # 0x99e1e
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %rax
subq %rbx, %rax
sarq $0x5, %rax
cmpq %rax, %r15
je 0x34450
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq %rax, %r14
movq %r15, %rax
shlq $0x5, %rax
movq %rax, 0xd8(%rsp)
movq (%rbx,%rax), %rsi
movq %r14, %rdi
pushq $0x8
popq %rdx
callq 0x8890
andq $0x0, 0xd0(%rsp)
andq $0x0, 0x90(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
andq $0x0, 0x130(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x120(%rsp)
movb $0x0, 0x10(%rsp)
pushq $0x1
popq %rbx
movq %r14, %rdi
movq %r12, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x33d7c
movq (%rsp), %rax
movb (%rax), %al
testb $0x1, %bl
jne 0x33d14
orl $0x1, %ebx
cmpb $0x3e, %al
je 0x33d1e
jmp 0x33d67
cmpb $0x3e, %al
jne 0x34488
incl %ebx
leaq 0xa9fbb(%rip), %rdi     # 0xddce0
leaq 0x660f3(%rip), %rsi     # 0x99e1f
callq 0x2ea9b
testb %al, %al
jne 0x33ce7
movq (%rsp), %rax
cmpb $0x3e, (%rax)
jne 0x33d67
leaq 0xa9f9b(%rip), %rdi     # 0xddce0
leaq 0x660d3(%rip), %rsi     # 0x99e1f
callq 0x2193f
testb %al, %al
je 0x33d67
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x2b0a4
jmp 0x33ce7
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x2b0a4
jmp 0x33ce7
movq %r15, 0x138(%rsp)
movq %r14, %rdi
callq 0x80e0
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %r15
movq 0x8(%rax), %rbx
subq %rax, %r15
andq $0x0, 0x190(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x180(%rsp)
movq %r15, %rax
shrq $0x5, %rax
movslq %eax, %r14
leaq 0x180(%rsp), %rdi
movq %r14, %rsi
callq 0x34872
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x34872
sarq $0x5, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movaps %xmm0, 0x100(%rsp)
andq $0x0, 0x110(%rsp)
movaps %xmm0, 0xa0(%rsp)
andq $0x0, 0xb0(%rsp)
testl %r15d, %r15d
jle 0x340fc
movq %r14, 0x78(%rsp)
xorl %r12d, %r12d
subq $0x1, %r14
jb 0x33e45
movq 0x80(%rsp), %rdi
addq %r12, %rdi
movq %rbx, %rsi
callq 0x8700
addq $0x20, %r12
jmp 0x33e26
movq %r13, %rbp
decl %r15d
xorl %r13d, %r13d
cmpq %rbx, %r13
movq 0x78(%rsp), %r14
je 0x33f05
movq 0xc0(%rsp), %rax
leaq 0x20(%rax), %rcx
movq %r14, %rdx
xorl %esi, %esi
cmpq %r15, %rsi
je 0x33efd
leaq 0x1(%rsi), %rdi
shlq $0x5, %rsi
addq %rax, %rsi
movq %rdx, %r8
movq %rcx, %r9
movq 0x78(%rsp), %r14
decq %r8
je 0x33ea7
movq (%rsi), %r10
movb (%r10,%r13), %r10b
movq (%r9), %r11
addq $0x20, %r9
cmpb (%r11,%r13), %r10b
je 0x33e8c
jmp 0x33eb3
addq $0x20, %rcx
decq %rdx
movq %rdi, %rsi
jmp 0x33e6d
leal 0x1(%r13), %eax
movl %eax, 0x40(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x2c80c
xorl %r12d, %r12d
subq $0x1, %r14
jb 0x33efd
movq 0xc0(%rsp), %rax
movq (%rax,%r12), %rax
movsbl (%rax,%r13), %esi
movq 0x80(%rsp), %rdi
addq %r12, %rdi
callq 0x8400
addq $0x20, %r12
jmp 0x33ed0
incq %r13
jmp 0x33e4e
xorl %r15d, %r15d
movq %rsp, %r12
cmpq %r14, %r15
je 0x34049
movb $0x1, %r14b
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rax, %r12
je 0x33fcb
movq %r15, %rbx
shlq $0x5, %rbx
movq 0x80(%rsp), %rdi
addq %rbx, %rdi
addq %r13, %rsi
callq 0x26b06
testb %al, %al
je 0x33fbf
movq 0xa0(%rsp), %rdi
addq %r13, %rdi
leaq 0x65eb8(%rip), %rsi     # 0x99e1f
callq 0x2ea9b
testb %al, %al
je 0x33f83
movq 0xa0(%rsp), %rdi
addq %r13, %rdi
pushq $0x2c
popq %rsi
callq 0x8400
addq 0xe0(%rsp), %rbx
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
movq %rbp, %rcx
callq 0x84b0
movq 0xa0(%rsp), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x8920
movq %r14, %rdi
callq 0x8978
xorl %r14d, %r14d
incq %r12
addq $0x20, %r13
jmp 0x33f1d
testb $0x1, %r14b
movq %rsp, %r12
movq 0x78(%rsp), %r14
je 0x34041
movq %r15, %rbx
shlq $0x5, %rbx
movq 0x80(%rsp), %rsi
addq %rbx, %rsi
leaq 0x60(%rsp), %rdi
callq 0x2b0a4
addq 0xe0(%rsp), %rbx
leaq 0x100(%rsp), %rdi
movq %rbx, %rsi
callq 0x2b0a4
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
leaq 0x65e03(%rip), %rsi     # 0x99e1f
leaq 0x140(%rsp), %rdx
callq 0x21904
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x3490e
movq %rbx, %rdi
callq 0x8978
incq %r15
jmp 0x33f0b
movq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x8600
decq %r14
xorl %eax, %eax
pushq $0x20
popq %r9
movq %rbp, %r13
leaq 0x65dad(%rip), %rbp     # 0x99e1e
movq 0xd8(%rsp), %r15
cmpq 0x48(%rsp), %rax
je 0x340f2
movq %r14, %rcx
movq %r9, %rdx
subq $0x1, %rcx
jb 0x340b1
movq 0x80(%rsp), %rsi
movq (%rsi,%rdx), %rsi
movb (%rsi,%rax), %dil
movq 0x40(%rsp), %r8
cmpb (%r8,%rax), %dil
jne 0x340ab
movb $0x2e, (%rsi,%rax)
addq $0x20, %rdx
jmp 0x34086
movq %r9, %rcx
pushq $0x1
popq %rdx
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdi
subq %rsi, %rdi
sarq $0x5, %rdi
cmpq %rdi, %rdx
je 0x340ed
movq (%rsi,%rcx), %rsi
movb (%rsi,%rax), %dil
movq 0x40(%rsp), %r8
cmpb (%r8,%rax), %dil
jne 0x340e4
movb $0x2e, (%rsi,%rax)
incq %rdx
addq $0x20, %rcx
jmp 0x340b7
incq %rax
jmp 0x34079
movq %rbx, %rdi
callq 0x8978
jmp 0x3412f
movq 0x20(%rsp), %rsi
movq 0xd8(%rsp), %r15
addq %r15, %rsi
movq 0xa8ed5(%rip), %rdi     # 0xdcfe8
callq 0x8430
movq %rax, %rdi
leaq 0x65cc7(%rip), %rsi     # 0x99de9
callq 0x8480
movq %rax, %rdi
callq 0x8230
movq 0x20(%rsp), %rdi
addq %r15, %rdi
pushq $0x2e
popq %rsi
movq %r13, %rdx
callq 0x8940
cmpq $-0x1, %rax
je 0x34186
movq %rax, %rbx
movq 0x20(%rsp), %rsi
addq %r15, %rsi
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rax, %rdx
movq %r13, %rcx
callq 0x84b0
movq %r14, %rdi
leaq 0x7511a(%rip), %rsi     # 0xa928a
callq 0x2193f
testb %al, %al
je 0x341c1
movq %r14, %rdi
callq 0x8978
jmp 0x34206
addq 0x20(%rsp), %r15
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
leaq 0xa9b63(%rip), %rsi     # 0xddd00
movq %r15, %rdx
callq 0x28b6d
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x65c45(%rip), %rdx     # 0x99dfc
callq 0x28a29
jmp 0x342af
movq 0x20(%rsp), %rsi
addq %r15, %rsi
leaq 0x140(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x84b0
movq %r14, %rdi
leaq 0x66ab0(%rip), %rsi     # 0x9ac99
callq 0x2193f
movl %eax, %ebx
movq %r14, %rdi
callq 0x8978
leaq 0x40(%rsp), %rdi
callq 0x8978
testb %bl, %bl
je 0x34279
addq 0x20(%rsp), %r15
leaq 0x1a0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x404d7
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
leaq 0xa9ad0(%rip), %rsi     # 0xddd00
movq %r14, %rdx
callq 0x28aaf
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x65bb2(%rip), %rdx     # 0x99dfc
callq 0x28a29
leaq 0x160(%rsp), %rdi
movq %r14, %rsi
callq 0x8550
movq %r14, %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8978
leaq 0x1a0(%rsp), %rdi
jmp 0x342ca
addq 0x20(%rsp), %r15
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
leaq 0xa9a70(%rip), %rsi     # 0xddd00
movq %r15, %rdx
callq 0x28b6d
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x65b52(%rip), %rdx     # 0x99dfc
callq 0x28a29
leaq 0x160(%rsp), %rdi
movq %r14, %rsi
callq 0x8550
movq %r14, %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8978
movl $0x200, %edi            # imm = 0x200
callq 0x8490
leaq 0x1c0(%rsp), %rbx
movq %rax, %r14
movq 0x160(%rsp), %rsi
movq %rax, %rdi
pushq $0x10
popq %rdx
callq 0x84e0
movq %r14, %rdi
leaq 0x65b06(%rip), %rsi     # 0x99e07
callq 0x8480
movq %rax, %rdi
movq %rbp, %rsi
callq 0x8480
movq %rbx, %rdi
leaq 0x120(%rsp), %rsi
callq 0x2c6d4
movq %rbx, %rdi
movq %r14, %rsi
pushq $0x20
popq %rdx
pushq $0x1
popq %rcx
callq 0x348a2
movq %rbx, %rdi
callq 0x2aef2
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
sarq $0x5, %rax
cmpq %rax, %r15
je 0x343d8
movq 0x100(%rsp), %rax
leaq (%rax,%rbx), %rsi
cmpq $0xf, 0x8(%rax,%rbx)
ja 0x34383
movq %r14, %rdi
callq 0x8430
movq %rax, %rdi
leaq 0x65aa1(%rip), %rsi     # 0x99e1d
callq 0x8480
jmp 0x34396
movq %r14, %rdi
callq 0x8430
movq %rax, %rdi
movq %rbp, %rsi
callq 0x8480
movq 0x60(%rsp), %rsi
addq %rbx, %rsi
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
movq %rbp, %rsi
callq 0x8480
movq 0xa0(%rsp), %rsi
addq %rbx, %rsi
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
incq %r15
addq $0x20, %rbx
jmp 0x3433f
movq %r14, %rdi
callq 0x8620
movq 0x138(%rsp), %r15
leaq 0xa0(%rsp), %rdi
callq 0x28a08
leaq 0x100(%rsp), %rdi
callq 0x28a08
leaq 0x60(%rsp), %rdi
callq 0x28a08
leaq 0x180(%rsp), %rdi
callq 0x28a08
movq %r12, %rdi
callq 0x8978
leaq 0x120(%rsp), %rdi
callq 0x2aef2
leaq 0x80(%rsp), %rdi
callq 0x28a08
leaq 0xc0(%rsp), %rdi
callq 0x28a08
incq %r15
jmp 0x33c55
leaq 0xe0(%rsp), %rdi
callq 0x28a08
leaq 0x160(%rsp), %rdi
callq 0x8978
leaq 0x20(%rsp), %rdi
callq 0x28a08
xorl %eax, %eax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x621d4(%rip), %rdi     # 0x96663
leaq 0x65916(%rip), %rsi     # 0x99dac
leaq 0x65930(%rip), %rcx     # 0x99dcd
pushq $0x5e
popq %rdx
callq 0x82f0
jmp 0x34565
jmp 0x34546
jmp 0x34546
jmp 0x34565
jmp 0x3454e
jmp 0x34546
jmp 0x3454e
jmp 0x34546
jmp 0x34546
jmp 0x34546
jmp 0x344df
jmp 0x345a2
jmp 0x34593
jmp 0x345a2
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
jmp 0x3459b
movq %rax, %rbx
jmp 0x34509
jmp 0x345a2
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x8978
leaq 0x1a0(%rsp), %rdi
jmp 0x3459b
jmp 0x345a2
jmp 0x345a2
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x2aef2
jmp 0x345a5
movq %rax, %rbx
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
callq 0x84a0
jmp 0x345a5
jmp 0x34588
movq %rax, %rbx
jmp 0x34605
movq %rax, %rbx
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
callq 0x84a0
jmp 0x34605
jmp 0x34565
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8978
jmp 0x34605
jmp 0x345a2
movq %rax, %rbx
jmp 0x345c9
jmp 0x345a2
jmp 0x345a2
jmp 0x34593
jmp 0x345a2
jmp 0x345a2
jmp 0x345a2
movq %rax, %rbx
jmp 0x345d6
jmp 0x345a2
jmp 0x345a2
jmp 0x345a2
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x8978
jmp 0x345a5
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x28a08
leaq 0x100(%rsp), %rdi
callq 0x28a08
leaq 0x60(%rsp), %rdi
callq 0x28a08
leaq 0x180(%rsp), %rdi
callq 0x28a08
movq %rsp, %rdi
callq 0x8978
leaq 0x120(%rsp), %rdi
callq 0x2aef2
leaq 0x80(%rsp), %rdi
callq 0x28a08
leaq 0xc0(%rsp), %rdi
callq 0x28a08
leaq 0xe0(%rsp), %rdi
callq 0x28a08
leaq 0x160(%rsp), %rdi
callq 0x8978
leaq 0x20(%rsp), %rdi
callq 0x28a08
movq %rbx, %rdi
callq 0x8870