// File: millanek[P]evo/process_vcf_fill_aa.cpp
// Function: fillAaMain(int, char**)
int fillAaMain(int argc, char** argv) {
    parseFillAaOptions(argc, argv);
    string line; // for reading the input files
    
    std::istream* vcfFile = createReader(opt::vcfFile.c_str());
    std::ifstream* ancSeqFile = new std::ifstream(opt::ancSeqFile.c_str());
    
    string refFastaFileRoot;
    if (opt::out.empty()) {
        refFastaFileRoot = stripExtension(opt::vcfFile);
    } else {
        refFastaFileRoot = opt::out;
    }
    // the output file
    std::ostream* outFile;
    if (opt::out == "") {
        outFile = &std::cout;
    } else {
        string outFN = refFastaFileRoot + "_AAfilled.vcf.gz";
        outFile = createWriter(outFN.c_str());
    }
    
    // Read in the whole ancestral sequence
    std::map<string, string> ancSeqs;
    getline(*ancSeqFile, line);
    string currentScaffold = line.substr(1,string::npos);
    ancSeqs[currentScaffold] = ""; ancSeqs[currentScaffold].reserve(50000000);
    while (getline(*ancSeqFile, line)) {
        if (line[0] != '>') {
            ancSeqs[currentScaffold].append(line);
        } else {
            // std::cerr << currentScaffold << " length: " << ancSeqs[currentScaffold].length() << std::endl;
            currentScaffold = line.substr(1,string::npos);
            ancSeqs[currentScaffold] = ""; ancSeqs[currentScaffold].reserve(50000000);
        }
    }
    
    // Now go through the vcf and add the AA fields
    int totalVariantNumber = 0;
    int aaDashCount = 0; int aaRefCount = 0; int aaAltCount = 0; int aaDiffCount = 0; int aaNcount = 0; int aaHetCount = 0;
    while (getline(*vcfFile, line)) {
        if (line[0] == '#' && line[1] == '#')
            *outFile << line << std::endl;
        else if (line[0] == '#' && line[1] == 'C') {
            if (opt::IndividualName == "") {
                *outFile << "##INFO=<ID=AA,Number=1,Type=String,Description=\"Ancestral allele\">" << std::endl;
                *outFile << line << std::endl;
            } else {
                *outFile << line << "\t" << opt::IndividualName << std::endl;
            }
        } else {
            totalVariantNumber++; string genotypeToAdd;
            std::vector<std::string> fields = split(line, '\t');
            std::vector<std::string> info = split(fields[7], ';');
            if (info[0] != "INDEL") {
                assert(ancSeqs.find(fields[0]) != ancSeqs.end());
                char AA;
                if (ancSeqs[fields[0]].length() == 0) {
                    AA = 'N';
                } else {
                    AA = std::toupper(ancSeqs[fields[0]][atoi(fields[1].c_str())-1]);
                    if (AA == '-') { aaDashCount++; genotypeToAdd = "./."; }
                    else if (AA == 'N') { aaNcount++; genotypeToAdd = "./."; }
                    else if (isDNAonly(AA)) {
                         if (AA == fields[3][0]) { aaRefCount++; genotypeToAdd = "0/0"; }
                        else if (AA == fields[4][0]) { aaAltCount++; genotypeToAdd = "1/1"; }
                        else if (!((AA == fields[3][0]) || (AA == fields[4][0]))) {
                            aaDiffCount++; genotypeToAdd = "./.";
                        }
                    } else {
                        aaHetCount++; string AAhetBases = returnHetIUPAC(AA);
                        if ((AAhetBases[0] == fields[3][0]) && (AAhetBases[1] == fields[4][0])) {
                            genotypeToAdd = "1/0";
                        } else if ((AAhetBases[1] == fields[3][0]) && (AAhetBases[0] == fields[4][0])) {
                            genotypeToAdd = "1/0";
                        } else {
                            genotypeToAdd = "./.";
                        }
                    }
                    // std::cerr << fields[0] << "\t" << fields[1] << "\t" << fields[3] << "\t" << fields[4] << "\t" << AA << std::endl;
                    // assert((AA == fields[3][0]) || (AA == fields[4][0]));
                }
                if (opt::IndividualName == "") {
                    fields[7] += ";AA="; fields[7] += AA;
                    print_vector(fields, *outFile, '\t');
                } else {
                    fields.push_back(genotypeToAdd);
                    print_vector(fields, *outFile, '\t');
                }
            } else {
                if (opt::IndividualName == "") {
                    *outFile << line << std::endl;
                } else {
                    fields.push_back("./.");
                    print_vector(fields, *outFile, '\t');
                }
            }
            if (totalVariantNumber % 100000 == 0) {
                double totalAAfilled = aaRefCount + aaAltCount + aaDashCount + aaDiffCount + aaNcount;
                std::cerr << totalVariantNumber << " variants processed. AA=Ref:" << aaRefCount << "("<< 100*(aaRefCount/totalAAfilled) <<"%); AA=Alt:" << aaAltCount << "("<< 100*(aaAltCount/totalAAfilled) <<"%); AA='-':" << aaDashCount << "("<< 100*(aaDashCount/totalAAfilled) << "%); AA=?(Neither Ref nor Alt):" << aaDiffCount << "("<< 100*(aaDiffCount/totalAAfilled) <<"%); AA=N:" << aaNcount << "("<< 100*(aaNcount/totalAAfilled) << "%)" << std::endl;
            }
        }
    }
    // Final summary
    double totalAAfilled = aaRefCount + aaAltCount + aaDashCount + aaDiffCount;
    std::cerr << std::endl;
    std::cerr << "All " << totalVariantNumber << " variants processed. AA=Ref:" << aaRefCount << "("<< 100*(aaRefCount/totalAAfilled) <<"%); AA=Alt:" << aaAltCount << "("<< 100*(aaAltCount/totalAAfilled) <<"%); AA='-':" << aaDashCount << "("<< 100*(aaDashCount/totalAAfilled) << "%); AA=?(Neither Ref nor Alt):" << aaDiffCount << "("<< 100*(aaDiffCount/totalAAfilled) <<"%)" << std::endl;
    
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5d0, %rsp            # imm = 0x5D0
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x7a280
leaq -0x30(%rbp), %rdi
callq 0xa820
leaq 0x121a72(%rip), %rdi    # 0x19a610
callq 0xa220
movq %rax, -0x2b0(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0xab60
movq -0x2b0(%rbp), %rsi
movq -0x2a8(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x2d6c0
jmp 0x78bd3
leaq -0x58(%rbp), %rdi
movl $0x8, %esi
callq 0x80e30
movq %rax, -0x2b8(%rbp)
jmp 0x78bea
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x59(%rbp), %rdi
callq 0xa640
movq -0x2b8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0x2c0(%rbp)
jmp 0x78c1a
leaq 0x121a0f(%rip), %rdi    # 0x19a630
callq 0xa220
movq -0x2c0(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0x78c3c
movq -0x2c0(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xa820
leaq 0x1219f6(%rip), %rdi    # 0x19a650
callq 0xaa70
testb $0x1, %al
jne 0x78c68
jmp 0x78d16
leaq 0x1219a1(%rip), %rsi    # 0x19a610
leaq -0xb8(%rbp), %rdi
callq 0x7be70
jmp 0x78c7d
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xa710
leaq -0xb8(%rbp), %rdi
callq 0xac88
jmp 0x78d2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x78cc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x59(%rbp), %rdi
callq 0xa640
jmp 0x7a25f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x7a25f
movq -0x2c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0x7a25f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x7a253
leaq 0x121933(%rip), %rsi    # 0x19a650
leaq -0x98(%rbp), %rdi
callq 0xa060
jmp 0x78d2b
jmp 0x78d2d
leaq 0x12191c(%rip), %rdi    # 0x19a650
leaq 0xbd1a4(%rip), %rsi     # 0x135edf
callq 0x2d770
movb %al, -0x2c1(%rbp)
jmp 0x78d48
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0x78d54
jmp 0x78d67
movq 0x12025d(%rip), %rax    # 0x198fb8
movq %rax, -0xc0(%rbp)
jmp 0x78e56
leaq 0xc1e66(%rip), %rdx     # 0x13abd4
leaq -0xe0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3da80
jmp 0x78d83
leaq -0xe0(%rbp), %rdi
callq 0xa220
movq %rax, -0x2d8(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0xab60
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
leaq -0x100(%rbp), %rdi
callq 0x2d6c0
jmp 0x78dc5
leaq -0x100(%rbp), %rdi
movl $0x10, %esi
callq 0x80f60
movq %rax, -0x2e0(%rbp)
jmp 0x78ddf
movq -0x2e0(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x100(%rbp), %rdi
callq 0xac88
leaq -0x101(%rbp), %rdi
callq 0xa640
leaq -0xe0(%rbp), %rdi
callq 0xac88
jmp 0x78e56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x78e39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0xac88
leaq -0x101(%rbp), %rdi
callq 0xa640
leaq -0xe0(%rbp), %rdi
callq 0xac88
jmp 0x7a253
leaq -0x138(%rbp), %rdi
callq 0x584b0
movq -0x78(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa0d0
jmp 0x78e71
leaq -0x158(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0xa5f0
jmp 0x78e8f
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x584d0
movq %rax, -0x2e8(%rbp)
jmp 0x78eab
movq -0x2e8(%rbp), %rdi
leaq 0xbd026(%rip), %rsi     # 0x135edf
callq 0xa810
jmp 0x78ec0
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x584d0
movq %rax, -0x2f0(%rbp)
jmp 0x78edc
movq -0x2f0(%rbp), %rdi
movl $0x2faf080, %esi        # imm = 0x2FAF080
callq 0xa980
jmp 0x78eef
jmp 0x78ef1
movq -0x78(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa0d0
movq %rax, -0x2f8(%rbp)
jmp 0x78f07
movq -0x2f8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0x2f9(%rbp)
jmp 0x78f25
movb -0x2f9(%rbp), %al
testb $0x1, %al
jne 0x78f34
jmp 0x79060
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xac60
movq %rax, -0x308(%rbp)
jmp 0x78f4a
movq -0x308(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
je 0x78fae
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x584d0
movq %rax, -0x310(%rbp)
jmp 0x78f75
movq -0x310(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xac20
jmp 0x78f87
jmp 0x7905b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x7a247
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x7a23b
leaq -0x178(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0xa5f0
jmp 0x78fcc
leaq -0x158(%rbp), %rdi
movq %rdi, -0x320(%rbp)
leaq -0x178(%rbp), %rsi
movq %rsi, -0x328(%rbp)
callq 0xa710
movq -0x328(%rbp), %rdi
callq 0xac88
movq -0x320(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x584d0
movq %rax, -0x318(%rbp)
jmp 0x79015
movq -0x318(%rbp), %rdi
leaq 0xbcebc(%rip), %rsi     # 0x135edf
callq 0xa810
jmp 0x7902a
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x584d0
movq %rax, -0x330(%rbp)
jmp 0x79046
movq -0x330(%rbp), %rdi
movl $0x2faf080, %esi        # imm = 0x2FAF080
callq 0xa980
jmp 0x79059
jmp 0x7905b
jmp 0x78ef1
movl $0x0, -0x17c(%rbp)
movl $0x0, -0x180(%rbp)
movl $0x0, -0x184(%rbp)
movl $0x0, -0x188(%rbp)
movl $0x0, -0x18c(%rbp)
movl $0x0, -0x190(%rbp)
movl $0x0, -0x194(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa0d0
movq %rax, -0x338(%rbp)
jmp 0x790bc
movq -0x338(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0x339(%rbp)
jmp 0x790da
movb -0x339(%rbp), %al
testb $0x1, %al
jne 0x790e9
jmp 0x79f3c
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xac60
movq %rax, -0x348(%rbp)
jmp 0x790ff
movq -0x348(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x79167
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0x350(%rbp)
jmp 0x79125
movq -0x350(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x79167
movq -0xc0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa520
movq %rax, -0x358(%rbp)
jmp 0x7914d
movq -0x358(%rbp), %rdi
movq 0x11fe2d(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x79162
jmp 0x79f37
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xac60
movq %rax, -0x360(%rbp)
jmp 0x7917d
movq -0x360(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x792af
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0x368(%rbp)
jmp 0x791a7
movq -0x368(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x43, %eax
jne 0x792af
leaq 0x1214af(%rip), %rdi    # 0x19a670
leaq 0xbcd17(%rip), %rsi     # 0x135edf
callq 0x2d770
movb %al, -0x369(%rbp)
jmp 0x791d5
movb -0x369(%rbp), %al
testb $0x1, %al
jne 0x791e1
jmp 0x79242
movq -0xc0(%rbp), %rdi
leaq 0xc19f6(%rip), %rsi     # 0x13abe5
callq 0xa5c0
movq %rax, -0x378(%rbp)
jmp 0x791fd
movq -0x378(%rbp), %rdi
movq 0x11fd7d(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x79212
movq -0xc0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa520
movq %rax, -0x380(%rbp)
jmp 0x7922b
movq -0x380(%rbp), %rdi
movq 0x11fd4f(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x79240
jmp 0x792aa
movq -0xc0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa520
movq %rax, -0x388(%rbp)
jmp 0x7925b
movq -0x388(%rbp), %rdi
leaq 0xbcc75(%rip), %rsi     # 0x135ede
callq 0xa5c0
movq %rax, -0x390(%rbp)
jmp 0x79277
movq -0x390(%rbp), %rdi
leaq 0x1213eb(%rip), %rsi    # 0x19a670
callq 0xa520
movq %rax, -0x398(%rbp)
jmp 0x79293
movq -0x398(%rbp), %rdi
movq 0x11fce7(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x792a8
jmp 0x792aa
jmp 0x79f35
movl -0x17c(%rbp), %eax
incl %eax
movl %eax, -0x17c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0xa820
leaq -0x1d0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0x792e0
leaq -0x1d0(%rbp), %rdi
movl $0x7, %esi
callq 0x3d940
movq %rax, %rsi
leaq -0x1e8(%rbp), %rdi
movl $0x3b, %edx
callq 0x7bbe0
jmp 0x79307
xorl %eax, %eax
movl %eax, %esi
leaq -0x1e8(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0xba461(%rip), %rsi     # 0x133782
callq 0x50eb0
movb %al, -0x399(%rbp)
jmp 0x7932e
movb -0x399(%rbp), %al
testb $0x1, %al
jne 0x7933d
jmp 0x79a59
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x138(%rbp), %rdi
callq 0x7a570
movq %rax, -0x3a8(%rbp)
jmp 0x79365
movq -0x3a8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x586c0
movq %rax, -0x1f8(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x58690
testb $0x1, %al
jne 0x7939f
jmp 0x793a1
jmp 0x793f3
leaq 0xc1880(%rip), %rdi     # 0x13ac28
leaq 0xc18a2(%rip), %rsi     # 0x13ac51
movl $0x67, %edx
leaq 0xc18ae(%rip), %rcx     # 0x13ac69
callq 0xa390
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x79f24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x79f18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x79f0c
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x138(%rbp), %rdi
callq 0x584d0
movq %rax, -0x3b0(%rbp)
jmp 0x7941b
movq -0x3b0(%rbp), %rdi
callq 0xa930
cmpq $0x0, %rax
jne 0x79439
movb $0x4e, -0x1f9(%rbp)
jmp 0x79904
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d0(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x138(%rbp), %rdi
callq 0x584d0
movq %rax, -0x3b8(%rbp)
jmp 0x79461
leaq -0x1d0(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movq -0x3b8(%rbp), %rdi
decl %eax
movslq %eax, %rsi
callq 0xac60
movq %rax, -0x3c0(%rbp)
jmp 0x7949c
movq -0x3c0(%rbp), %rax
movsbl (%rax), %edi
callq 0xac90
movb %al, -0x1f9(%rbp)
movsbl -0x1f9(%rbp), %eax
cmpl $0x2d, %eax
jne 0x794e5
movl -0x180(%rbp), %eax
incl %eax
movl %eax, -0x180(%rbp)
leaq 0xc17b4(%rip), %rsi     # 0x13ac86
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x794e0
jmp 0x79902
movsbl -0x1f9(%rbp), %eax
cmpl $0x4e, %eax
jne 0x79519
movl -0x190(%rbp), %eax
incl %eax
movl %eax, -0x190(%rbp)
leaq 0xc1780(%rip), %rsi     # 0x13ac86
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x79514
jmp 0x79900
movsbl -0x1f9(%rbp), %edi
callq 0x7a5a0
movb %al, -0x3c1(%rbp)
jmp 0x7952d
movb -0x3c1(%rbp), %al
testb $0x1, %al
jne 0x7953c
jmp 0x796d6
movsbl -0x1f9(%rbp), %eax
movl %eax, -0x3d4(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x3d0(%rbp)
jmp 0x7956f
movl -0x3d4(%rbp), %eax
movq -0x3d0(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x795ab
movl -0x184(%rbp), %eax
incl %eax
movl %eax, -0x184(%rbp)
leaq 0xc16f2(%rip), %rsi     # 0x13ac8a
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x795a6
jmp 0x796d1
movsbl -0x1f9(%rbp), %eax
movl %eax, -0x3e4(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x3e0(%rbp)
jmp 0x795de
movl -0x3e4(%rbp), %eax
movq -0x3e0(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x7961a
movl -0x188(%rbp), %eax
incl %eax
movl %eax, -0x188(%rbp)
leaq 0xc1687(%rip), %rsi     # 0x13ac8e
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x79615
jmp 0x796cf
movsbl -0x1f9(%rbp), %eax
movl %eax, -0x3f4(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x3f0(%rbp)
jmp 0x7964d
movl -0x3f4(%rbp), %eax
movq -0x3f0(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x796cd
movsbl -0x1f9(%rbp), %eax
movl %eax, -0x404(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x400(%rbp)
jmp 0x79694
movl -0x404(%rbp), %eax
movq -0x400(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x796cd
movl -0x18c(%rbp), %eax
incl %eax
movl %eax, -0x18c(%rbp)
leaq 0xc15c9(%rip), %rsi     # 0x13ac86
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x796cb
jmp 0x796cd
jmp 0x796cf
jmp 0x796d1
jmp 0x798fe
movl -0x194(%rbp), %eax
incl %eax
movl %eax, -0x194(%rbp)
movsbl -0x1f9(%rbp), %esi
leaq -0x220(%rbp), %rdi
callq 0x7a600
jmp 0x796f9
xorl %eax, %eax
movl %eax, %esi
leaq -0x220(%rbp), %rdi
callq 0xac60
movq %rax, -0x410(%rbp)
jmp 0x79712
movq -0x410(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x41c(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x418(%rbp)
jmp 0x79748
movl -0x41c(%rbp), %eax
movq -0x418(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x797fb
leaq -0x220(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0x428(%rbp)
jmp 0x7977a
movq -0x428(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x434(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x430(%rbp)
jmp 0x797b0
movl -0x434(%rbp), %eax
movq -0x430(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x797fb
leaq 0xc14c7(%rip), %rsi     # 0x13ac92
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x797d9
jmp 0x798f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0xac88
jmp 0x79f0c
leaq -0x220(%rbp), %rdi
movl $0x1, %esi
callq 0xac60
movq %rax, -0x440(%rbp)
jmp 0x79815
movq -0x440(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x44c(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x448(%rbp)
jmp 0x7984b
movl -0x44c(%rbp), %eax
movq -0x448(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x798d9
xorl %eax, %eax
movl %eax, %esi
leaq -0x220(%rbp), %rdi
callq 0xac60
movq %rax, -0x458(%rbp)
jmp 0x79878
movq -0x458(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x464(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x460(%rbp)
jmp 0x798ae
movl -0x464(%rbp), %eax
movq -0x460(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x798d9
leaq 0xc13c9(%rip), %rsi     # 0x13ac92
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x798d7
jmp 0x798f0
leaq 0xc13a6(%rip), %rsi     # 0x13ac86
leaq -0x1b8(%rbp), %rdi
callq 0xa810
jmp 0x798ee
jmp 0x798f0
jmp 0x798f2
leaq -0x220(%rbp), %rdi
callq 0xac88
jmp 0x79900
jmp 0x79902
jmp 0x79904
leaq 0x120d65(%rip), %rdi    # 0x19a670
leaq 0xbc5cd(%rip), %rsi     # 0x135edf
callq 0x2d770
movb %al, -0x465(%rbp)
jmp 0x7991f
movb -0x465(%rbp), %al
testb $0x1, %al
jne 0x7992e
jmp 0x799e0
leaq -0x1d0(%rbp), %rdi
movl $0x7, %esi
callq 0x3d940
movq %rax, %rdi
leaq 0xc134d(%rip), %rsi     # 0x13ac96
callq 0xa580
jmp 0x79950
movsbl -0x1f9(%rbp), %eax
movl %eax, -0x46c(%rbp)
leaq -0x1d0(%rbp), %rdi
movl $0x7, %esi
callq 0x3d940
movl -0x46c(%rbp), %esi
movq %rax, %rdi
callq 0xa380
jmp 0x7997e
leaq -0x238(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x3fee0
jmp 0x79993
movq -0xc0(%rbp), %rsi
leaq -0x238(%rbp), %rdi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x50da0
jmp 0x799b2
leaq -0x238(%rbp), %rdi
callq 0x3dfa0
jmp 0x79a54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3dfa0
jmp 0x79f0c
leaq -0x1d0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x48dc0
jmp 0x799f5
leaq -0x250(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x3fee0
jmp 0x79a0a
movq -0xc0(%rbp), %rsi
leaq -0x250(%rbp), %rdi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x50da0
jmp 0x79a29
leaq -0x250(%rbp), %rdi
callq 0x3dfa0
jmp 0x79a54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x3dfa0
jmp 0x79f0c
jmp 0x79ba7
leaq 0x120c10(%rip), %rdi    # 0x19a670
leaq 0xbc478(%rip), %rsi     # 0x135edf
callq 0x2d770
movb %al, -0x46d(%rbp)
jmp 0x79a74
movb -0x46d(%rbp), %al
testb $0x1, %al
jne 0x79a80
jmp 0x79ab3
movq -0xc0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa520
movq %rax, -0x478(%rbp)
jmp 0x79a99
movq -0x478(%rbp), %rdi
movq 0x11f4e1(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x79aae
jmp 0x79ba5
leaq -0x271(%rbp), %rdi
movq %rdi, -0x480(%rbp)
callq 0xab60
movq -0x480(%rbp), %rdx
leaq 0xc11b2(%rip), %rsi     # 0x13ac86
leaq -0x270(%rbp), %rdi
callq 0x2d6c0
jmp 0x79ae2
leaq -0x1d0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x5f980
jmp 0x79af7
leaq -0x270(%rbp), %rdi
callq 0xac88
leaq -0x271(%rbp), %rdi
callq 0xa640
leaq -0x290(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x3fee0
jmp 0x79b24
movq -0xc0(%rbp), %rsi
leaq -0x290(%rbp), %rdi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x50da0
jmp 0x79b43
leaq -0x290(%rbp), %rdi
callq 0x3dfa0
jmp 0x79ba5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x79b77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x270(%rbp), %rdi
callq 0xac88
leaq -0x271(%rbp), %rdi
callq 0xa640
jmp 0x79f0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x3dfa0
jmp 0x79f0c
jmp 0x79ba7
movl -0x17c(%rbp), %eax
movl $0x186a0, %ecx          # imm = 0x186A0
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x79ee6
movl -0x184(%rbp), %eax
movl -0x188(%rbp), %ecx
addl %ecx, %eax
movl -0x180(%rbp), %ecx
addl %ecx, %eax
movl -0x18c(%rbp), %ecx
addl %ecx, %eax
movl -0x190(%rbp), %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x298(%rbp)
movl -0x17c(%rbp), %esi
movq 0x11f3f3(%rip), %rdi    # 0x198ff0
callq 0xab20
movq %rax, -0x488(%rbp)
jmp 0x79c0b
movq -0x488(%rbp), %rdi
leaq 0xc1082(%rip), %rsi     # 0x13ac9b
callq 0xa5c0
movq %rax, -0x490(%rbp)
jmp 0x79c27
movq -0x490(%rbp), %rdi
movl -0x184(%rbp), %esi
callq 0xab20
movq %rax, -0x498(%rbp)
jmp 0x79c42
movq -0x498(%rbp), %rdi
leaq 0xc4020(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x4a0(%rbp)
jmp 0x79c5e
movq -0x4a0(%rbp), %rdi
cvtsi2sdl -0x184(%rbp), %xmm0
movsd -0x298(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0ebf(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x4a8(%rbp)
jmp 0x79c93
movq -0x4a8(%rbp), %rdi
leaq 0xc1017(%rip), %rsi     # 0x13acb8
callq 0xa5c0
movq %rax, -0x4b0(%rbp)
jmp 0x79caf
movq -0x4b0(%rbp), %rdi
movl -0x188(%rbp), %esi
callq 0xab20
movq %rax, -0x4b8(%rbp)
jmp 0x79cca
movq -0x4b8(%rbp), %rdi
leaq 0xc3f98(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x4c0(%rbp)
jmp 0x79ce6
movq -0x4c0(%rbp), %rdi
cvtsi2sdl -0x188(%rbp), %xmm0
movsd -0x298(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0e37(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x4c8(%rbp)
jmp 0x79d1b
movq -0x4c8(%rbp), %rdi
leaq 0xc0f9b(%rip), %rsi     # 0x13acc4
callq 0xa5c0
movq %rax, -0x4d0(%rbp)
jmp 0x79d37
movq -0x4d0(%rbp), %rdi
movl -0x180(%rbp), %esi
callq 0xab20
movq %rax, -0x4d8(%rbp)
jmp 0x79d52
movq -0x4d8(%rbp), %rdi
leaq 0xc3f10(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x4e0(%rbp)
jmp 0x79d6e
movq -0x4e0(%rbp), %rdi
cvtsi2sdl -0x180(%rbp), %xmm0
movsd -0x298(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0daf(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x4e8(%rbp)
jmp 0x79da3
movq -0x4e8(%rbp), %rdi
leaq 0xc0f1f(%rip), %rsi     # 0x13acd0
callq 0xa5c0
movq %rax, -0x4f0(%rbp)
jmp 0x79dbf
movq -0x4f0(%rbp), %rdi
movl -0x18c(%rbp), %esi
callq 0xab20
movq %rax, -0x4f8(%rbp)
jmp 0x79dda
movq -0x4f8(%rbp), %rdi
leaq 0xc3e88(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x500(%rbp)
jmp 0x79df6
movq -0x500(%rbp), %rdi
cvtsi2sdl -0x18c(%rbp), %xmm0
movsd -0x298(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0d27(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x508(%rbp)
jmp 0x79e2b
movq -0x508(%rbp), %rdi
leaq 0xc0eb6(%rip), %rsi     # 0x13acef
callq 0xa5c0
movq %rax, -0x510(%rbp)
jmp 0x79e47
movq -0x510(%rbp), %rdi
movl -0x190(%rbp), %esi
callq 0xab20
movq %rax, -0x518(%rbp)
jmp 0x79e62
movq -0x518(%rbp), %rdi
leaq 0xc3e00(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x520(%rbp)
jmp 0x79e7e
movq -0x520(%rbp), %rdi
cvtsi2sdl -0x190(%rbp), %xmm0
movsd -0x298(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0c9f(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x528(%rbp)
jmp 0x79eb3
movq -0x528(%rbp), %rdi
leaq 0xca035(%rip), %rsi     # 0x143ef6
callq 0xa5c0
movq %rax, -0x530(%rbp)
jmp 0x79ecf
movq -0x530(%rbp), %rdi
movq 0x11f0ab(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x79ee4
jmp 0x79ee6
leaq -0x1e8(%rbp), %rdi
callq 0x3dfa0
leaq -0x1d0(%rbp), %rdi
callq 0x3dfa0
leaq -0x1b8(%rbp), %rdi
callq 0xac88
jmp 0x79f35
leaq -0x1e8(%rbp), %rdi
callq 0x3dfa0
leaq -0x1d0(%rbp), %rdi
callq 0x3dfa0
leaq -0x1b8(%rbp), %rdi
callq 0xac88
jmp 0x7a23b
jmp 0x79f37
jmp 0x790a6
movl -0x184(%rbp), %eax
movl -0x188(%rbp), %ecx
addl %ecx, %eax
movl -0x180(%rbp), %ecx
addl %ecx, %eax
movl -0x18c(%rbp), %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x2a0(%rbp)
movq 0x11f083(%rip), %rdi    # 0x198ff0
movq 0x11f014(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x79f7b
movq 0x11f06e(%rip), %rdi    # 0x198ff0
leaq 0xc0d70(%rip), %rsi     # 0x13acf9
callq 0xa5c0
movq %rax, -0x538(%rbp)
jmp 0x79f97
movq -0x538(%rbp), %rdi
movl -0x17c(%rbp), %esi
callq 0xab20
movq %rax, -0x540(%rbp)
jmp 0x79fb2
movq -0x540(%rbp), %rdi
leaq 0xc0cdb(%rip), %rsi     # 0x13ac9b
callq 0xa5c0
movq %rax, -0x548(%rbp)
jmp 0x79fce
movq -0x548(%rbp), %rdi
movl -0x184(%rbp), %esi
callq 0xab20
movq %rax, -0x550(%rbp)
jmp 0x79fe9
movq -0x550(%rbp), %rdi
leaq 0xc3c79(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x558(%rbp)
jmp 0x7a005
movq -0x558(%rbp), %rdi
cvtsi2sdl -0x184(%rbp), %xmm0
movsd -0x2a0(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0b18(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x560(%rbp)
jmp 0x7a03a
movq -0x560(%rbp), %rdi
leaq 0xc0c70(%rip), %rsi     # 0x13acb8
callq 0xa5c0
movq %rax, -0x568(%rbp)
jmp 0x7a056
movq -0x568(%rbp), %rdi
movl -0x188(%rbp), %esi
callq 0xab20
movq %rax, -0x570(%rbp)
jmp 0x7a071
movq -0x570(%rbp), %rdi
leaq 0xc3bf1(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x578(%rbp)
jmp 0x7a08d
movq -0x578(%rbp), %rdi
cvtsi2sdl -0x188(%rbp), %xmm0
movsd -0x2a0(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0a90(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x580(%rbp)
jmp 0x7a0c2
movq -0x580(%rbp), %rdi
leaq 0xc0bf4(%rip), %rsi     # 0x13acc4
callq 0xa5c0
movq %rax, -0x588(%rbp)
jmp 0x7a0de
movq -0x588(%rbp), %rdi
movl -0x180(%rbp), %esi
callq 0xab20
movq %rax, -0x590(%rbp)
jmp 0x7a0f9
movq -0x590(%rbp), %rdi
leaq 0xc3b69(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x598(%rbp)
jmp 0x7a115
movq -0x598(%rbp), %rdi
cvtsi2sdl -0x180(%rbp), %xmm0
movsd -0x2a0(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0a08(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x5a0(%rbp)
jmp 0x7a14a
movq -0x5a0(%rbp), %rdi
leaq 0xc0b78(%rip), %rsi     # 0x13acd0
callq 0xa5c0
movq %rax, -0x5a8(%rbp)
jmp 0x7a166
movq -0x5a8(%rbp), %rdi
movl -0x18c(%rbp), %esi
callq 0xab20
movq %rax, -0x5b0(%rbp)
jmp 0x7a181
movq -0x5b0(%rbp), %rdi
leaq 0xc3ae1(%rip), %rsi     # 0x13dc70
callq 0xa5c0
movq %rax, -0x5b8(%rbp)
jmp 0x7a19d
movq -0x5b8(%rbp), %rdi
cvtsi2sdl -0x18c(%rbp), %xmm0
movsd -0x2a0(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0xc0980(%rip), %xmm1    # 0x13ab40
mulsd %xmm1, %xmm0
callq 0xabd0
movq %rax, -0x5c0(%rbp)
jmp 0x7a1d2
movq -0x5c0(%rbp), %rdi
leaq 0xc9d16(%rip), %rsi     # 0x143ef6
callq 0xa5c0
movq %rax, -0x5c8(%rbp)
jmp 0x7a1ee
movq -0x5c8(%rbp), %rdi
movq 0x11ed8c(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x7a203
leaq -0x158(%rbp), %rdi
callq 0xac88
leaq -0x138(%rbp), %rdi
callq 0x58620
leaq -0x98(%rbp), %rdi
callq 0xac88
leaq -0x30(%rbp), %rdi
callq 0xac88
xorl %eax, %eax
addq $0x5d0, %rsp            # imm = 0x5D0
popq %rbp
retq
leaq -0x158(%rbp), %rdi
callq 0xac88
leaq -0x138(%rbp), %rdi
callq 0x58620
leaq -0x98(%rbp), %rdi
callq 0xac88
leaq -0x30(%rbp), %rdi
callq 0xac88
movq -0x68(%rbp), %rdi
callq 0xab50
nopw %cs:(%rax,%rax)