// File: millanek[P]evo/process_vcf_mt_sequences.cpp
// Function: getMtSeqMain(int, char**)
int getMtSeqMain(int argc, char** argv) {
    parseGetMtSeqOptions(argc, argv);
    string vcfFileRoot = stripExtension(opt::vcfFile);    
    
    std::cerr << "Generating the mitochondrial genome sequences using variants from: " << opt::vcfFile << std::endl;
    std::cerr << "and the reference genome: " << opt::genomeFile << std::endl;
    
    // Open connections to read from the vcf and reference genome files
    std::ifstream* vcfFile = new std::ifstream(opt::vcfFile.c_str());
    std::ifstream* genomeFile = new std::ifstream(opt::genomeFile.c_str());
    
    // Prepare an object for output files
    string mtFileName = vcfFileRoot + "_mtDNA.fa";
    string mtRefName = vcfFileRoot + "_mtRef.fa";
    std::ofstream* mtFile = new std::ofstream(mtFileName.c_str());    
    
    string line;
    string currentScaffoldNum = "";
    string currentScaffoldReference;
    string::size_type inStrPos = 0;
    std::vector<string> sampleNames = readSampleNamesFromTextFile(opt::sampleNameFile);;
    string thisScaffoldName; getline(*genomeFile, thisScaffoldName); thisScaffoldName.erase(0,1);
    unsigned int processedVariantCounter = 0;
    
    std::vector<string::size_type> splits;
    
    
    string sc747Ref; sc747Ref.reserve(20000000);
    string sc2036Ref; sc2036Ref.reserve(20000000);
    string mtRef; mtRef.reserve(20000000);
    while (thisScaffoldName != "") {
        std::cerr << "Starting to read " << thisScaffoldName << std::endl;
        if (thisScaffoldName == "scaffold_747") {
            currentScaffoldReference = readScaffold(genomeFile, thisScaffoldName);
            thisScaffoldName.erase(0,1);
            sc747Ref.append(currentScaffoldReference);
            mtRef.append(currentScaffoldReference);
        } else if (thisScaffoldName == "scaffold_2036") {
            currentScaffoldReference = readScaffold(genomeFile, thisScaffoldName);
            thisScaffoldName.erase(0,1);
            sc2036Ref.append(currentScaffoldReference);
            mtRef.append(currentScaffoldReference);
        } else {
            currentScaffoldReference = readScaffold(genomeFile, thisScaffoldName);
            thisScaffoldName.erase(0,1);
        }
    }
    
    std::vector<string> mtStrings;
    mtStrings.resize(sampleNames.size());
    
    for (std::vector<string>::size_type i = 0; i != mtStrings.size(); i++) {
        mtStrings[i].reserve(20000000);
        mtStrings[i] = "";
    }
    
    string scaffold = "scaffold_747";
    while (getline(*vcfFile, line)) {
        if (line[0] == '#')
            continue;
        else {
            processedVariantCounter++;
            std::vector<std::string> fields = split(line, '\t');
            // Also get overall depth for this variant
            std::vector<std::string> info = split(fields[7], ';');
            
            
            if (info[0] != "INDEL" && fields[4].length() == 1) {
                bool printedHet = false;
                for (std::vector<std::string>::size_type i = NUM_NON_GENOTYPE_COLUMNS; i != fields.size(); i++) {
                    //std::cerr << "Going through genotypes1:" << i << std::endl;
                    //std::cerr << scaffoldStrings.size() << " " << inStrPos << " " << fields[1] << " " << currentScaffoldReference.size() << std::endl;
                    std::vector<string> genotypeFields = split(fields[i], ':');
                    // Unphased vcf
                    std::vector<string> genotype = split(genotypeFields[0], '/');
                    if (opt::bLDhat) {
                        for (int j = 0; j != ((atoi(fields[1].c_str()) - 1)-inStrPos); j++) {
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append("0");
                        }
                        if (genotype[0] == "0" && genotype[1] == "0")
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append("0");
                        else if (genotype[0] == "1" && genotype[1] == "1")
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append("1");
                        else {
                            string ambiguityBase = getAmbiguityCode(fields[3], fields[4]);
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append("2");
                        }
                    } else {
                        if (fields[0] == "scaffold_747")
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append(mtRef.substr(inStrPos, (atoi(fields[1].c_str()) - 1)-inStrPos));
                        else
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append(mtRef.substr(inStrPos, (atoi(fields[1].c_str()) + sc747Ref.length() - 1)-inStrPos));
                        //std::cerr << "Going through genotypes2:" << i << std::endl;
                        if (genotype[0] == "0" && genotype[1] == "0")
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append(fields[3]);
                        else if (genotype[0] == "1" && genotype[1] == "1")
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append(fields[4]);
                        else {
                            mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append(fields[4]);
                            if (!printedHet) {
                                std::cout << "Het in mitochondrial sequence:" << sampleNames[i- NUM_NON_GENOTYPE_COLUMNS] << std::endl;
                                std::cout << line << std::endl;
                                printedHet = true;
                            }
                            //string ambiguityBase = getAmbiguityCode(fields[3], fields[4]);
                            //mtStrings[i- NUM_NON_GENOTYPE_COLUMNS].append(ambiguityBase);
                        }
                    }
                    //std::cerr << "Going through genotypes3:" << i << std::endl;
                }
                if (fields[0] == "scaffold_747")
                    inStrPos = atoi(fields[1].c_str());
                else
                    inStrPos = atoi(fields[1].c_str()) + sc747Ref.length();
                
                
                
#ifdef DEBUG
                if (mtRef[inStrPos-1] != fields[3][0]) {
                    std::cerr << "Error!!! Sequence: " << mtRef[inStrPos-1] << " vcf-ref: " << fields[3][0] << std::endl;
                }
#endif
            }

        }
    }
    
    for (std::vector<std::string>::size_type i = 0; i != sampleNames.size(); i++) {
        mtStrings[i].append(mtRef.substr(inStrPos, string::npos));
    }
#ifdef DEBUG
    if (mtStrings[0].length() != mtRef.length()) {
        std::cerr << "Error!!! Reference scaffold/LG length: " << mtRef.length() << " vcf scaffold length: " << mtStrings[0].length() << std::endl;
    }
#endif
    
    for (std::vector<std::string>::size_type i = 0; i != sampleNames.size(); i++) {
        *mtFile << ">" << sampleNames[i] << std::endl;
        print80bpPerLineFile(mtFile, mtStrings[i]);
    }
    
    
    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 0xd2790
leaq 0xc9beb(%rip), %rsi     # 0x19ace0
leaq -0x30(%rbp), %rdi
callq 0x7be70
movq 0xc7eeb(%rip), %rdi     # 0x198ff0
leaq 0x74674(%rip), %rsi     # 0x145780
callq 0xa5c0
movq %rax, -0x3d8(%rbp)
jmp 0xd111a
movq -0x3d8(%rbp), %rdi
leaq 0xc9bb8(%rip), %rsi     # 0x19ace0
callq 0xa520
movq %rax, -0x3e0(%rbp)
jmp 0xd1136
movq -0x3e0(%rbp), %rdi
movq 0xc7e44(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd114b
movq 0xc7e9e(%rip), %rdi     # 0x198ff0
leaq 0x6e8b6(%rip), %rsi     # 0x13fa0f
callq 0xa5c0
movq %rax, -0x3e8(%rbp)
jmp 0xd1167
movq -0x3e8(%rbp), %rdi
leaq 0xc9b8b(%rip), %rsi     # 0x19ad00
callq 0xa520
movq %rax, -0x3f0(%rbp)
jmp 0xd1183
movq -0x3f0(%rbp), %rdi
movq 0xc7df7(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd1198
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0x3f8(%rbp)
jmp 0xd11ab
leaq 0xc9b2e(%rip), %rdi     # 0x19ace0
callq 0xa220
movq -0x3f8(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0xd11cd
movq -0x3f8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0x400(%rbp)
jmp 0xd11eb
leaq 0xc9b0e(%rip), %rdi     # 0x19ad00
callq 0xa220
movq -0x400(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0xab90
jmp 0xd120d
movq -0x400(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x745a5(%rip), %rdx     # 0x1457c4
leaq -0x70(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3da80
jmp 0xd122e
leaq 0x74599(%rip), %rdx     # 0x1457ce
leaq -0x90(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3da80
jmp 0xd1247
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x408(%rbp)
jmp 0xd125a
leaq -0x70(%rbp), %rdi
callq 0xa220
movq -0x408(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0xa650
jmp 0xd1279
movq -0x408(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xa820
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0xab60
movq -0x410(%rbp), %rdx
leaq 0x64c2b(%rip), %rsi     # 0x135edf
leaq -0xd8(%rbp), %rdi
callq 0x2d6c0
jmp 0xd12c2
leaq -0xd9(%rbp), %rdi
callq 0xa640
leaq -0x100(%rbp), %rdi
callq 0xa820
movq $0x0, -0x108(%rbp)
leaq 0xc9a34(%rip), %rsi     # 0x19ad20
leaq -0x120(%rbp), %rdi
callq 0x80aa0
jmp 0xd12fa
leaq -0x140(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0xa820
movq -0x418(%rbp), %rsi
movq -0x50(%rbp), %rdi
callq 0xa0d0
jmp 0xd131f
xorl %eax, %eax
movl %eax, %esi
leaq -0x140(%rbp), %rdi
movl $0x1, %edx
callq 0xa130
jmp 0xd1336
movl $0x0, -0x144(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x50c10
leaq -0x180(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0xa820
movq -0x420(%rbp), %rdi
movl $0x1312d00, %esi        # imm = 0x1312D00
callq 0xa980
jmp 0xd1372
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x428(%rbp)
callq 0xa820
movq -0x428(%rbp), %rdi
movl $0x1312d00, %esi        # imm = 0x1312D00
callq 0xa980
jmp 0xd1398
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x430(%rbp)
callq 0xa820
movq -0x430(%rbp), %rdi
movl $0x1312d00, %esi        # imm = 0x1312D00
callq 0xa980
jmp 0xd13be
jmp 0xd13c0
leaq 0x64b18(%rip), %rsi     # 0x135edf
leaq -0x140(%rbp), %rdi
callq 0x50eb0
movb %al, -0x431(%rbp)
jmp 0xd13db
movb -0x431(%rbp), %al
testb $0x1, %al
jne 0xd13ea
jmp 0xd16fc
movq 0xc7bff(%rip), %rdi     # 0x198ff0
leaq 0x6e776(%rip), %rsi     # 0x13fb6e
callq 0xa5c0
movq %rax, -0x440(%rbp)
jmp 0xd1406
movq -0x440(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xa520
movq %rax, -0x448(%rbp)
jmp 0xd1422
movq -0x448(%rbp), %rdi
movq 0xc7b58(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd1437
leaq 0x7439a(%rip), %rsi     # 0x1457d8
leaq -0x140(%rbp), %rdi
callq 0x2d770
movb %al, -0x449(%rbp)
jmp 0xd1452
movb -0x449(%rbp), %al
testb $0x1, %al
jne 0xd1461
jmp 0xd15f1
leaq -0x1e0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x6a7e0
jmp 0xd147a
leaq -0x100(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
movq %rsi, -0x458(%rbp)
callq 0xa710
movq -0x458(%rbp), %rdi
callq 0xac88
xorl %eax, %eax
movl %eax, %esi
leaq -0x140(%rbp), %rdi
movl $0x1, %edx
callq 0xa130
jmp 0xd14b7
leaq -0x180(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xac20
jmp 0xd14cc
leaq -0x1c0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xac20
jmp 0xd14e1
jmp 0xd16f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd2773
movq -0x3f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0xd2773
movq -0x400(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0xd2773
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd276a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd275e
movq -0x408(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xd275e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd9(%rbp), %rdi
callq 0xa640
jmp 0xd2752
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd273a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd2722
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd270a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd26fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd26f2
leaq 0x741ed(%rip), %rsi     # 0x1457e5
leaq -0x140(%rbp), %rdi
callq 0x2d770
movb %al, -0x459(%rbp)
jmp 0xd160c
movb -0x459(%rbp), %al
testb $0x1, %al
jne 0xd161b
jmp 0xd169d
leaq -0x200(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x6a7e0
jmp 0xd1634
leaq -0x100(%rbp), %rdi
leaq -0x200(%rbp), %rsi
movq %rsi, -0x468(%rbp)
callq 0xa710
movq -0x468(%rbp), %rdi
callq 0xac88
xorl %eax, %eax
movl %eax, %esi
leaq -0x140(%rbp), %rdi
movl $0x1, %edx
callq 0xa130
jmp 0xd1671
leaq -0x1a0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xac20
jmp 0xd1686
leaq -0x1c0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xac20
jmp 0xd169b
jmp 0xd16f5
leaq -0x220(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x6a7e0
jmp 0xd16b6
leaq -0x100(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movq %rsi, -0x470(%rbp)
callq 0xa710
movq -0x470(%rbp), %rdi
callq 0xac88
xorl %eax, %eax
movl %eax, %esi
leaq -0x140(%rbp), %rdi
movl $0x1, %edx
callq 0xa130
jmp 0xd16f3
jmp 0xd16f5
jmp 0xd16f7
jmp 0xd13c0
leaq -0x238(%rbp), %rdi
movq %rdi, -0x478(%rbp)
callq 0x48da0
leaq -0x120(%rbp), %rdi
callq 0x3ffd0
movq -0x478(%rbp), %rdi
movq %rax, %rsi
callq 0x5f8f0
jmp 0xd172c
movq $0x0, -0x240(%rbp)
movq -0x240(%rbp), %rax
movq %rax, -0x480(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3ffd0
movq %rax, %rcx
movq -0x480(%rbp), %rax
cmpq %rcx, %rax
je 0xd17d0
movq -0x240(%rbp), %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
movl $0x1312d00, %esi        # imm = 0x1312D00
callq 0xa980
jmp 0xd1782
movq -0x240(%rbp), %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x64740(%rip), %rsi     # 0x135edf
callq 0xa810
jmp 0xd17a6
jmp 0xd17a8
movq -0x240(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x240(%rbp)
jmp 0xd1737
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd26e6
leaq -0x261(%rbp), %rdi
movq %rdi, -0x488(%rbp)
callq 0xab60
movq -0x488(%rbp), %rdx
leaq 0x73fe7(%rip), %rsi     # 0x1457d8
leaq -0x260(%rbp), %rdi
callq 0x2d6c0
jmp 0xd17ff
leaq -0x261(%rbp), %rdi
callq 0xa640
movq -0x48(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xa0d0
movq %rax, -0x490(%rbp)
jmp 0xd1824
movq -0x490(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0x491(%rbp)
jmp 0xd1842
movb -0x491(%rbp), %al
testb $0x1, %al
jne 0xd1851
jmp 0xd2375
xorl %eax, %eax
movl %eax, %esi
leaq -0xb8(%rbp), %rdi
callq 0xac60
movq %rax, -0x4a0(%rbp)
jmp 0xd186a
movq -0x4a0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0xd18a9
jmp 0xd180b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x261(%rbp), %rdi
callq 0xa640
jmp 0xd26e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd26da
movl -0x144(%rbp), %eax
incl %eax
movl %eax, -0x144(%rbp)
leaq -0x280(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0xd18d1
leaq -0x280(%rbp), %rdi
movl $0x7, %esi
callq 0x3d940
movq %rax, %rsi
leaq -0x298(%rbp), %rdi
movl $0x3b, %edx
callq 0x7bbe0
jmp 0xd18f8
xorl %eax, %eax
movl %eax, %esi
leaq -0x298(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x61e70(%rip), %rsi     # 0x133782
callq 0x50eb0
movb %al, -0x4a1(%rbp)
jmp 0xd191f
movb -0x4a1(%rbp), %al
testb $0x1, %al
jne 0xd192e
jmp 0xd2339
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa930
cmpq $0x1, %rax
jne 0xd2339
movb $0x0, -0x299(%rbp)
movq $0x9, -0x2a8(%rbp)
movq -0x2a8(%rbp), %rax
movq %rax, -0x4b0(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x3ffd0
movq %rax, %rcx
movq -0x4b0(%rbp), %rax
cmpq %rcx, %rax
je 0xd214f
movq -0x2a8(%rbp), %rsi
leaq -0x280(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x2c0(%rbp), %rdi
movl $0x3a, %edx
callq 0x7bbe0
jmp 0xd19b9
xorl %eax, %eax
movl %eax, %esi
leaq -0x2c0(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x2d8(%rbp), %rdi
movl $0x2f, %edx
callq 0x7bbe0
jmp 0xd19df
testb $0x1, 0xc935a(%rip)     # 0x19ad40
je 0xd1cf7
movl $0x0, -0x2dc(%rbp)
movslq -0x2dc(%rbp), %rax
movq %rax, -0x4b8(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movl %eax, %ecx
movq -0x4b8(%rbp), %rax
subl $0x1, %ecx
movslq %ecx, %rcx
subq -0x108(%rbp), %rcx
cmpq %rcx, %rax
je 0xd1ac6
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x61c88(%rip), %rsi     # 0x1336ed
callq 0xabe0
jmp 0xd1a6c
jmp 0xd1a6e
movl -0x2dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2dc(%rbp)
jmp 0xd19f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd235f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd2353
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd213e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd2132
xorl %eax, %eax
movl %eax, %esi
leaq -0x2d8(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x61c0d(%rip), %rsi     # 0x1336ed
callq 0x2d770
movb %al, -0x4b9(%rbp)
jmp 0xd1aed
movb -0x4b9(%rbp), %al
testb $0x1, %al
jne 0xd1af9
jmp 0xd1b5a
leaq -0x2d8(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
leaq 0x61bd9(%rip), %rsi     # 0x1336ed
callq 0x2d770
movb %al, -0x4ba(%rbp)
jmp 0xd1b21
movb -0x4ba(%rbp), %al
testb $0x1, %al
jne 0xd1b2d
jmp 0xd1b5a
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x61b9f(%rip), %rsi     # 0x1336ed
callq 0xabe0
jmp 0xd1b55
jmp 0xd1cf2
xorl %eax, %eax
movl %eax, %esi
leaq -0x2d8(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x7c94c(%rip), %rsi     # 0x14e4c0
callq 0x2d770
movb %al, -0x4bb(%rbp)
jmp 0xd1b81
movb -0x4bb(%rbp), %al
testb $0x1, %al
jne 0xd1b8d
jmp 0xd1bee
leaq -0x2d8(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
leaq 0x7c918(%rip), %rsi     # 0x14e4c0
callq 0x2d770
movb %al, -0x4bc(%rbp)
jmp 0xd1bb5
movb -0x4bc(%rbp), %al
testb $0x1, %al
jne 0xd1bc1
jmp 0xd1bee
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x7c8de(%rip), %rsi     # 0x14e4c0
callq 0xabe0
jmp 0xd1be9
jmp 0xd1cf0
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq %rax, %rsi
leaq -0x320(%rbp), %rdi
callq 0xa250
jmp 0xd1c10
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq %rax, %rsi
leaq -0x340(%rbp), %rdi
callq 0xa250
jmp 0xd1c32
leaq -0x300(%rbp), %rdi
leaq -0x320(%rbp), %rsi
leaq -0x340(%rbp), %rdx
callq 0x8e990
jmp 0xd1c4e
leaq -0x340(%rbp), %rdi
callq 0xac88
leaq -0x320(%rbp), %rdi
callq 0xac88
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x6a942(%rip), %rsi     # 0x13c5c9
callq 0xabe0
jmp 0xd1c8e
leaq -0x300(%rbp), %rdi
callq 0xac88
jmp 0xd1cf0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd1cc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x340(%rbp), %rdi
callq 0xac88
leaq -0x320(%rbp), %rdi
callq 0xac88
jmp 0xd2132
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0xac88
jmp 0xd2132
jmp 0xd1cf2
jmp 0xd2103
xorl %eax, %eax
movl %eax, %esi
leaq -0x280(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x73ac7(%rip), %rsi     # 0x1457d8
callq 0x2d770
movb %al, -0x4bd(%rbp)
jmp 0xd1d1e
movb -0x4bd(%rbp), %al
testb $0x1, %al
jne 0xd1d2d
jmp 0xd1de8
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, -0x4d0(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x4c8(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movq -0x4c8(%rbp), %rdx
decl %eax
movslq %eax, %rcx
movq -0x108(%rbp), %rax
subq %rax, %rcx
leaq -0x360(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa5f0
jmp 0xd1da5
movq -0x4d0(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0xac20
jmp 0xd1dba
leaq -0x360(%rbp), %rdi
callq 0xac88
jmp 0xd1ec0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x360(%rbp), %rdi
callq 0xac88
jmp 0xd2132
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, -0x4e8(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x4e0(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
cltq
movq %rax, -0x4d8(%rbp)
leaq -0x180(%rbp), %rdi
callq 0xa930
movq -0x4e0(%rbp), %rdx
movq %rax, %rcx
movq -0x4d8(%rbp), %rax
addq %rcx, %rax
movq -0x108(%rbp), %rcx
notq %rcx
addq %rax, %rcx
leaq -0x380(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa5f0
jmp 0xd1e80
movq -0x4e8(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0xac20
jmp 0xd1e95
leaq -0x380(%rbp), %rdi
callq 0xac88
jmp 0xd1ec0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x380(%rbp), %rdi
callq 0xac88
jmp 0xd2132
xorl %eax, %eax
movl %eax, %esi
leaq -0x2d8(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x61813(%rip), %rsi     # 0x1336ed
callq 0x2d770
movb %al, -0x4e9(%rbp)
jmp 0xd1ee7
movb -0x4e9(%rbp), %al
testb $0x1, %al
jne 0xd1ef3
jmp 0xd1f6c
leaq -0x2d8(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
leaq 0x617df(%rip), %rsi     # 0x1336ed
callq 0x2d770
movb %al, -0x4ea(%rbp)
jmp 0xd1f1b
movb -0x4ea(%rbp), %al
testb $0x1, %al
jne 0xd1f27
jmp 0xd1f6c
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, -0x4f8(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq -0x4f8(%rbp), %rdi
movq %rax, %rsi
callq 0xac20
jmp 0xd1f67
jmp 0xd2101
xorl %eax, %eax
movl %eax, %esi
leaq -0x2d8(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x7c53a(%rip), %rsi     # 0x14e4c0
callq 0x2d770
movb %al, -0x4f9(%rbp)
jmp 0xd1f93
movb -0x4f9(%rbp), %al
testb $0x1, %al
jne 0xd1f9f
jmp 0xd2018
leaq -0x2d8(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
leaq 0x7c506(%rip), %rsi     # 0x14e4c0
callq 0x2d770
movb %al, -0x4fa(%rbp)
jmp 0xd1fc7
movb -0x4fa(%rbp), %al
testb $0x1, %al
jne 0xd1fd3
jmp 0xd2018
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, -0x508(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq -0x508(%rbp), %rdi
movq %rax, %rsi
callq 0xac20
jmp 0xd2013
jmp 0xd20ff
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, -0x510(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq -0x510(%rbp), %rdi
movq %rax, %rsi
callq 0xac20
jmp 0xd2058
testb $0x1, -0x299(%rbp)
jne 0xd20fd
movq 0xc6f4c(%rip), %rdi     # 0x198fb8
leaq 0x73780(%rip), %rsi     # 0x1457f3
callq 0xa5c0
movq %rax, -0x518(%rbp)
jmp 0xd2081
movq -0x2a8(%rbp), %rsi
addq $-0x9, %rsi
leaq -0x120(%rbp), %rdi
callq 0x3d940
movq -0x518(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x520(%rbp)
jmp 0xd20b0
movq -0x520(%rbp), %rdi
movq 0xc6eca(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd20c5
movq 0xc6eec(%rip), %rdi     # 0x198fb8
leaq -0xb8(%rbp), %rsi
callq 0xa520
movq %rax, -0x528(%rbp)
jmp 0xd20e1
movq -0x528(%rbp), %rdi
movq 0xc6e99(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd20f6
movb $0x1, -0x299(%rbp)
jmp 0xd20ff
jmp 0xd2101
jmp 0xd2103
leaq -0x2d8(%rbp), %rdi
callq 0x3dfa0
leaq -0x2c0(%rbp), %rdi
callq 0x3dfa0
movq -0x2a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2a8(%rbp)
jmp 0xd1963
leaq -0x2d8(%rbp), %rdi
callq 0x3dfa0
leaq -0x2c0(%rbp), %rdi
callq 0x3dfa0
jmp 0xd2353
xorl %eax, %eax
movl %eax, %esi
leaq -0x280(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
leaq 0x7366f(%rip), %rsi     # 0x1457d8
callq 0x2d770
movb %al, -0x529(%rbp)
jmp 0xd2176
movb -0x529(%rbp), %al
testb $0x1, %al
jne 0xd2182
jmp 0xd21ae
leaq -0x280(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
cltq
movq %rax, -0x108(%rbp)
jmp 0xd21f8
leaq -0x280(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
cltq
movq %rax, -0x538(%rbp)
leaq -0x180(%rbp), %rdi
callq 0xa930
movq %rax, %rcx
movq -0x538(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rsi
decq %rsi
leaq -0x1c0(%rbp), %rdi
callq 0xac60
movq %rax, -0x540(%rbp)
jmp 0xd2217
movq -0x540(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x54c(%rbp)
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x548(%rbp)
jmp 0xd224d
movl -0x54c(%rbp), %eax
movq -0x548(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0xd2337
movq 0xc6d84(%rip), %rdi     # 0x198ff0
leaq 0x6eac5(%rip), %rsi     # 0x140d38
callq 0xa5c0
movq %rax, -0x558(%rbp)
jmp 0xd2281
movq -0x108(%rbp), %rsi
decq %rsi
leaq -0x1c0(%rbp), %rdi
callq 0xac60
movq %rax, -0x560(%rbp)
jmp 0xd22a0
movq -0x558(%rbp), %rdi
movq -0x560(%rbp), %rax
movsbl (%rax), %esi
callq 0xa6d0
movq %rax, -0x568(%rbp)
jmp 0xd22bf
movq -0x568(%rbp), %rdi
leaq 0x6ea7f(%rip), %rsi     # 0x140d4c
callq 0xa5c0
movq %rax, -0x570(%rbp)
jmp 0xd22db
leaq -0x280(%rbp), %rdi
movl $0x3, %esi
callq 0x3d940
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xac60
movq %rax, -0x578(%rbp)
jmp 0xd2301
movq -0x570(%rbp), %rdi
movq -0x578(%rbp), %rax
movsbl (%rax), %esi
callq 0xa6d0
movq %rax, -0x580(%rbp)
jmp 0xd2320
movq -0x580(%rbp), %rdi
movq 0xc6c5a(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd2335
jmp 0xd2337
jmp 0xd2339
leaq -0x298(%rbp), %rdi
callq 0x3dfa0
leaq -0x280(%rbp), %rdi
callq 0x3dfa0
jmp 0xd2370
leaq -0x298(%rbp), %rdi
callq 0x3dfa0
leaq -0x280(%rbp), %rdi
callq 0x3dfa0
jmp 0xd26da
jmp 0xd180b
movq $0x0, -0x388(%rbp)
movq -0x388(%rbp), %rax
movq %rax, -0x588(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x3ffd0
movq %rax, %rcx
movq -0x588(%rbp), %rax
cmpq %rcx, %rax
je 0xd243f
movq -0x388(%rbp), %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, -0x590(%rbp)
movq -0x108(%rbp), %rdx
leaq -0x3a8(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
movq $-0x1, %rcx
callq 0xa5f0
jmp 0xd23ea
movq -0x590(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0xac20
jmp 0xd23ff
leaq -0x3a8(%rbp), %rdi
callq 0xac88
movq -0x388(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x388(%rbp)
jmp 0xd2380
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0xac88
jmp 0xd26da
leaq -0x238(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa930
movq %rax, -0x598(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xa930
movq %rax, %rcx
movq -0x598(%rbp), %rax
cmpq %rcx, %rax
je 0xd2520
movq 0xc6b6c(%rip), %rdi     # 0x198ff0
leaq 0x6d5f5(%rip), %rsi     # 0x13fa80
callq 0xa5c0
movq %rax, -0x5a0(%rbp)
jmp 0xd2499
leaq -0x1c0(%rbp), %rdi
callq 0xa930
movq -0x5a0(%rbp), %rdi
movq %rax, %rsi
callq 0xa140
movq %rax, -0x5a8(%rbp)
jmp 0xd24bd
movq -0x5a8(%rbp), %rdi
leaq 0x6d5dd(%rip), %rsi     # 0x13faa8
callq 0xa5c0
movq %rax, -0x5b0(%rbp)
jmp 0xd24d9
xorl %eax, %eax
movl %eax, %esi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rdi
callq 0xa930
movq -0x5b0(%rbp), %rdi
movq %rax, %rsi
callq 0xa140
movq %rax, -0x5b8(%rbp)
jmp 0xd2509
movq -0x5b8(%rbp), %rdi
movq 0xc6a71(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd251e
jmp 0xd2520
movq $0x0, -0x3b0(%rbp)
movq -0x3b0(%rbp), %rax
movq %rax, -0x5c0(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x3ffd0
movq %rax, %rcx
movq -0x5c0(%rbp), %rax
cmpq %rcx, %rax
je 0xd262d
movq -0x98(%rbp), %rdi
leaq 0x686c0(%rip), %rsi     # 0x13ac26
callq 0xa5c0
movq %rax, -0x5c8(%rbp)
jmp 0xd2574
movq -0x3b0(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0x3d940
movq -0x5c8(%rbp), %rdi
movq %rax, %rsi
callq 0xa520
movq %rax, -0x5d0(%rbp)
jmp 0xd259f
movq -0x5d0(%rbp), %rdi
movq 0xc69db(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xd25b4
movq -0x3b0(%rbp), %rsi
leaq -0x238(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x3d0(%rbp), %rdi
callq 0xa250
jmp 0xd25d8
leaq -0x98(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x81170
jmp 0xd25ed
leaq -0x3d0(%rbp), %rdi
callq 0xac88
movq -0x3b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3b0(%rbp)
jmp 0xd252b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0xac88
jmp 0xd26da
leaq -0x260(%rbp), %rdi
callq 0xac88
leaq -0x238(%rbp), %rdi
callq 0x3dfa0
leaq -0x1c0(%rbp), %rdi
callq 0xac88
leaq -0x1a0(%rbp), %rdi
callq 0xac88
leaq -0x180(%rbp), %rdi
callq 0xac88
leaq -0x160(%rbp), %rdi
callq 0x50d40
leaq -0x140(%rbp), %rdi
callq 0xac88
leaq -0x120(%rbp), %rdi
callq 0x3dfa0
leaq -0x100(%rbp), %rdi
callq 0xac88
leaq -0xd8(%rbp), %rdi
callq 0xac88
leaq -0xb8(%rbp), %rdi
callq 0xac88
leaq -0x90(%rbp), %rdi
callq 0xac88
leaq -0x70(%rbp), %rdi
callq 0xac88
leaq -0x30(%rbp), %rdi
callq 0xac88
xorl %eax, %eax
addq $0x5d0, %rsp            # imm = 0x5D0
popq %rbp
retq
leaq -0x260(%rbp), %rdi
callq 0xac88
leaq -0x238(%rbp), %rdi
callq 0x3dfa0
leaq -0x1c0(%rbp), %rdi
callq 0xac88
leaq -0x1a0(%rbp), %rdi
callq 0xac88
leaq -0x180(%rbp), %rdi
callq 0xac88
leaq -0x160(%rbp), %rdi
callq 0x50d40
leaq -0x140(%rbp), %rdi
callq 0xac88
leaq -0x120(%rbp), %rdi
callq 0x3dfa0
leaq -0x100(%rbp), %rdi
callq 0xac88
leaq -0xd8(%rbp), %rdi
callq 0xac88
leaq -0xb8(%rbp), %rdi
callq 0xac88
leaq -0x90(%rbp), %rdi
callq 0xac88
leaq -0x70(%rbp), %rdi
callq 0xac88
leaq -0x30(%rbp), %rdi
callq 0xac88
movq -0x38(%rbp), %rdi
callq 0xab50
nopw %cs:(%rax,%rax)