// File: millanek[P]evo/process_vcf_massoko.cpp
// Function: massokoMain(int, char**)
int massokoMain(int argc, char** argv) {
    parseMassokoOptions(argc, argv);
    std::ios_base::openmode mode = std::ios_base::in;
    string fileName = opt::vcfFile;
    string fileRoot = stripExtension(fileName);
    std::map<int, std::vector<int> > counts_blue;
    
    std::cerr << "Filtering variants from: " << fileName << std::endl;
    std::cerr << "Maximum read depth (overall) set to: " << opt::max_overall_depth << std::endl;
    std::cerr << "Minimum copies for a variant (e.g. 1 for allowing singletons): " << opt::min_copies << std::endl;
    std::cerr << "Minimum read depth at the variant position: " << opt::min_depth_in_any_individual << std::endl;
    
    // Open connection to read from the vcf file
    std::ifstream* inFile = new std::ifstream(fileName.c_str(), mode);
    std::ios_base::openmode mode_out = std::ios_base::out;
    string VarFile12FileName = fileRoot + ".fixed_variants12.txt";
    string VarFile11FileName = fileRoot + ".fixed_variants11.txt";
    string VarFile10FileName = fileRoot + ".fixed_variants10_two_hets.txt";
    string VarFile10HomFileName = fileRoot + ".fixed_variants10_hom.txt";
    string VarFile9FileName = fileRoot + ".fixed_variants9_three_hets.txt";
    string VarFile9HomFileName = fileRoot + ".fixed_variants9_hom.txt";
    std::ofstream* pFixedVarFile12 = new std::ofstream(VarFile12FileName.c_str(), mode_out);
    std::ofstream* pFixedVarFile11 = new std::ofstream(VarFile11FileName.c_str(), mode_out);
    std::ofstream* pFixedVarFile10 = new std::ofstream(VarFile10FileName.c_str(), mode_out);
    std::ofstream* pFixedVarFile10hom = new std::ofstream(VarFile10HomFileName.c_str(), mode_out);
    std::ofstream* pFixedVarFile9 = new std::ofstream(VarFile9FileName.c_str(), mode_out);
    std::ofstream* pFixedVarFile9hom = new std::ofstream(VarFile9HomFileName.c_str(), mode_out);
    bool gotChromosomeNumber = false;
    int numChromosomes;
    string line;
    int totalVariantNumber = 0;
    while (getline(*inFile, line)) {
        if (line[0] == '#') {
            std::cout << line << std::endl;
            *pFixedVarFile12 << line << std::endl; 
            *pFixedVarFile11 << line << std::endl;
            *pFixedVarFile10 << line << std::endl;
        } else {
            totalVariantNumber++;
            MassokoFilterResult result;
            std::vector<std::string> fields = split(line, '\t');
            if (!gotChromosomeNumber) {
                const std::vector<std::string>::size_type numSamples = fields.size() - NUM_NON_GENOTYPE_COLUMNS;
                numChromosomes = numSamples * 2;
                std::cerr << "Number of chromosomes: " << numChromosomes << std::endl;
                gotChromosomeNumber = true;
                initializeCountsBlue(counts_blue, numChromosomes);
            }
            result.overallQuality = atoi(fields[5].c_str());
            
            
            if (result.overallQuality >= MIN_OVERALL_VARIANT_PHRED_QUAL) 
                result.maxDepthPassed = testOverallReadDepth(opt::max_overall_depth,opt::min_overall_depth,fields[7]);
            
            if (result.maxDepthPassed)
                result.biallelicPassed = testBiallelic(fields[4]);
            
            if (result.biallelicPassed) 
                result.counts = getMassokoVariantCounts(fields);
            
            // filter out sites where more than MAX_NUM_HET individuals are heterozygous
            int num_hets = getNumHets(result);
            
            if (result.biallelicPassed && result.counts.overall <= (numChromosomes - opt::min_copies) && result.counts.overall >= opt::min_copies) {
                if (result.counts.minimumDepthInAnIndividual >= opt::min_depth_in_any_individual) {
                    std::cout << line << std::endl;
                    counts_blue[result.counts.overall][result.counts.blue]++;
                    if (result.counts.overall == 12 && (result.counts.blue == 12 || result.counts.blue == 0)) {
                        *pFixedVarFile12 << line << std::endl;
                    }
                    if (result.counts.overall == 11 && (result.counts.blue == 11 || result.counts.blue == 0)) {
                        *pFixedVarFile11 << line << std::endl;
                    }
                    if (result.counts.overall == 13 && (result.counts.blue == 12 || result.counts.blue == 1)) {
                        *pFixedVarFile11 << line << std::endl;
                    }
                    if (result.counts.overall == 10 && (result.counts.blue == 10 || result.counts.blue == 0) && (num_hets == 2)) {
                        *pFixedVarFile10 << line << std::endl;
                    } else if (result.counts.overall == 10 && (result.counts.blue == 10 || result.counts.blue == 0)) {
                        *pFixedVarFile10hom << line << std::endl;
                    }
                    if (result.counts.overall == 14 && (result.counts.blue == 12 || result.counts.blue == 2) && (num_hets == 2)) {
                        *pFixedVarFile10 << line << std::endl;
                    } else if (result.counts.overall == 14 && (result.counts.blue == 14 || result.counts.blue == 2)) {
                        *pFixedVarFile10hom << line << std::endl;
                    }
                    if (result.counts.overall == 9 && (result.counts.blue == 9 || result.counts.blue == 0) && (num_hets == 3)) {
                        *pFixedVarFile9 << line << std::endl;
                    } else if (result.counts.overall == 9 && (result.counts.blue == 9 || result.counts.blue == 0)) {
                        *pFixedVarFile9hom << line << std::endl;
                    }
                    if (result.counts.overall == 15 && (result.counts.blue == 12 || result.counts.blue == 3) && (num_hets == 3)) {
                        *pFixedVarFile9 << line << std::endl;
                    } else if (result.counts.overall == 15 && (result.counts.blue == 12 || result.counts.blue == 3)) {
                        *pFixedVarFile9hom << line << std::endl;
                    }
                }
            }
        }
    }
    for (int i = numChromosomes - opt::min_copies; i >= opt::min_copies; i--) {
        for (std::vector<std::string>::size_type j = 0; j != counts_blue[i].size(); j++) {
            if (j == (counts_blue[i].size()-1)) {
                std::cerr << counts_blue[i][j];
            } else {
                std::cerr << counts_blue[i][j] << "\t";
            }
        } std::cerr << std::endl;
    } 
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x580, %rsp            # imm = 0x580
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xa5110
movl $0x8, -0x14(%rbp)
leaq 0xf6734(%rip), %rsi     # 0x19a870
leaq -0x38(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0xa250
movq -0x410(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x7be70
jmp 0xa415e
leaq -0x98(%rbp), %rdi
callq 0xa55a0
movq 0xf4e7f(%rip), %rdi     # 0x198ff0
leaq 0x9985c(%rip), %rsi     # 0x13d9d4
callq 0xa5c0
movq %rax, -0x418(%rbp)
jmp 0xa4186
movq -0x418(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xa520
movq %rax, -0x420(%rbp)
jmp 0xa419f
movq -0x420(%rbp), %rdi
movq 0xf4ddb(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa41b4
movq 0xf4e35(%rip), %rdi     # 0x198ff0
leaq 0x9985d(%rip), %rsi     # 0x13da1f
callq 0xa5c0
movq %rax, -0x428(%rbp)
jmp 0xa41d0
movq -0x428(%rbp), %rdi
movl 0xf5657(%rip), %esi     # 0x199834
callq 0xab20
movq %rax, -0x430(%rbp)
jmp 0xa41eb
movq -0x430(%rbp), %rdi
movq 0xf4d8f(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4200
movq 0xf4de9(%rip), %rdi     # 0x198ff0
leaq 0x9985d(%rip), %rsi     # 0x13da6b
callq 0xa5c0
movq %rax, -0x438(%rbp)
jmp 0xa421c
movq -0x438(%rbp), %rdi
movl 0xf5607(%rip), %esi     # 0x199830
callq 0xab20
movq %rax, -0x440(%rbp)
jmp 0xa4237
movq -0x440(%rbp), %rdi
movq 0xf4d43(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa424c
movq 0xf4d9d(%rip), %rdi     # 0x198ff0
leaq 0x99851(%rip), %rsi     # 0x13daab
callq 0xa5c0
movq %rax, -0x448(%rbp)
jmp 0xa4268
movq -0x448(%rbp), %rdi
movl 0xf55c3(%rip), %esi     # 0x199838
callq 0xab20
movq %rax, -0x450(%rbp)
jmp 0xa4283
movq -0x450(%rbp), %rdi
movq 0xf4cf7(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4298
movl $0x208, %edi            # imm = 0x208
callq 0xa5d0
movq %rax, -0x458(%rbp)
jmp 0xa42ab
leaq -0x38(%rbp), %rdi
callq 0xa220
movq -0x458(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
callq 0xab90
jmp 0xa42c8
movq -0x458(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl $0x10, -0xa4(%rbp)
leaq 0x9afa9(%rip), %rdx     # 0x13f290
leaq -0xc8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3da80
jmp 0xa42f9
leaq 0x9afa6(%rip), %rdx     # 0x13f2a6
leaq -0xe8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3da80
jmp 0xa4312
leaq 0x9afa3(%rip), %rdx     # 0x13f2bc
leaq -0x108(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3da80
jmp 0xa432b
leaq 0x9afa9(%rip), %rdx     # 0x13f2db
leaq -0x128(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3da80
jmp 0xa4344
leaq 0x9afaa(%rip), %rdx     # 0x13f2f5
leaq -0x148(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3da80
jmp 0xa435d
leaq 0x9afb1(%rip), %rdx     # 0x13f315
leaq -0x168(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3da80
jmp 0xa4376
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x460(%rbp)
jmp 0xa4389
leaq -0xc8(%rbp), %rdi
callq 0xa220
movq -0x460(%rbp), %rdi
movq %rax, %rsi
movl -0xa4(%rbp), %edx
callq 0xa650
jmp 0xa43ac
movq -0x460(%rbp), %rax
movq %rax, -0x170(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x468(%rbp)
jmp 0xa43cd
leaq -0xe8(%rbp), %rdi
callq 0xa220
movq -0x468(%rbp), %rdi
movq %rax, %rsi
movl -0xa4(%rbp), %edx
callq 0xa650
jmp 0xa43f0
movq -0x468(%rbp), %rax
movq %rax, -0x178(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x470(%rbp)
jmp 0xa4411
leaq -0x108(%rbp), %rdi
callq 0xa220
movq -0x470(%rbp), %rdi
movq %rax, %rsi
movl -0xa4(%rbp), %edx
callq 0xa650
jmp 0xa4434
movq -0x470(%rbp), %rax
movq %rax, -0x180(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x478(%rbp)
jmp 0xa4455
leaq -0x128(%rbp), %rdi
callq 0xa220
movq -0x478(%rbp), %rdi
movq %rax, %rsi
movl -0xa4(%rbp), %edx
callq 0xa650
jmp 0xa4478
movq -0x478(%rbp), %rax
movq %rax, -0x188(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x480(%rbp)
jmp 0xa4499
leaq -0x148(%rbp), %rdi
callq 0xa220
movq -0x480(%rbp), %rdi
movq %rax, %rsi
movl -0xa4(%rbp), %edx
callq 0xa650
jmp 0xa44bc
movq -0x480(%rbp), %rax
movq %rax, -0x190(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0xa5d0
movq %rax, -0x488(%rbp)
jmp 0xa44dd
leaq -0x168(%rbp), %rdi
callq 0xa220
movq -0x488(%rbp), %rdi
movq %rax, %rsi
movl -0xa4(%rbp), %edx
callq 0xa650
jmp 0xa4500
movq -0x488(%rbp), %rax
movq %rax, -0x198(%rbp)
movb $0x0, -0x199(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xa820
movl $0x0, -0x1c4(%rbp)
movq -0xa0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa0d0
movq %rax, -0x490(%rbp)
jmp 0xa4547
movq -0x490(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0x491(%rbp)
jmp 0xa4565
movb -0x491(%rbp), %al
testb $0x1, %al
jne 0xa4574
jmp 0xa4e69
xorl %eax, %eax
movl %eax, %esi
leaq -0x1c0(%rbp), %rdi
callq 0xac60
movq %rax, -0x4a0(%rbp)
jmp 0xa458d
movq -0x4a0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0xa47f0
movq 0xf4a11(%rip), %rdi     # 0x198fb8
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x4a8(%rbp)
jmp 0xa45bc
movq -0x4a8(%rbp), %rdi
movq 0xf49be(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa45d1
movq -0x170(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x4b0(%rbp)
jmp 0xa45ed
movq -0x4b0(%rbp), %rdi
movq 0xf498d(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4602
movq -0x178(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x4b8(%rbp)
jmp 0xa461e
movq -0x4b8(%rbp), %rdi
movq 0xf495c(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4633
movq -0x180(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x4c0(%rbp)
jmp 0xa464f
movq -0x4c0(%rbp), %rdi
movq 0xf492b(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4664
jmp 0xa4e64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa50f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa50dd
movq -0x458(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0xa50dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa50d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa50c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa50b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa50ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa50a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa5095
movq -0x460(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xa5095
movq -0x468(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xa5095
movq -0x470(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xa5095
movq -0x478(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xa5095
movq -0x480(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xa5095
movq -0x488(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x200, %esi            # imm = 0x200
callq 0xa5e0
jmp 0xa5095
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa5089
movl -0x1c4(%rbp), %eax
incl %eax
movl %eax, -0x1c4(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0xa55c0
jmp 0xa480c
leaq -0x2f0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0xa4826
testb $0x1, -0x199(%rbp)
jne 0xa48ef
leaq -0x2f0(%rbp), %rdi
callq 0x3ffd0
addq $-0x9, %rax
movq %rax, -0x2f8(%rbp)
movl -0x2f8(%rbp), %eax
addl %eax, %eax
movl %eax, -0x1a0(%rbp)
movq 0xf4791(%rip), %rdi     # 0x198ff0
leaq 0x9805d(%rip), %rsi     # 0x13c8c3
callq 0xa5c0
movq %rax, -0x4c8(%rbp)
jmp 0xa4874
movq -0x4c8(%rbp), %rdi
movl -0x1a0(%rbp), %esi
callq 0xab20
movq %rax, -0x4d0(%rbp)
jmp 0xa488f
movq -0x4d0(%rbp), %rdi
movq 0xf46eb(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa48a4
movb $0x1, -0x199(%rbp)
movl -0x1a0(%rbp), %esi
leaq -0x98(%rbp), %rdi
callq 0xa3f80
jmp 0xa48bf
jmp 0xa48ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa4e53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x3dfa0
jmp 0xa4e53
leaq -0x2f0(%rbp), %rdi
movl $0x5, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movl %eax, -0x2d8(%rbp)
cmpl $0x1e, -0x2d8(%rbp)
jl 0xa4972
movl 0xf4f0f(%rip), %eax     # 0x199834
movl %eax, -0x4dc(%rbp)
movl 0xf5f5f(%rip), %eax     # 0x19a890
movl %eax, -0x4d8(%rbp)
leaq -0x2f0(%rbp), %rdi
movl $0x7, %esi
callq 0x3d940
movl -0x4dc(%rbp), %edi
movl -0x4d8(%rbp), %esi
movq %rax, %rdx
callq 0x80110
movb %al, -0x4d1(%rbp)
jmp 0xa4964
movb -0x4d1(%rbp), %al
andb $0x1, %al
movb %al, -0x2d4(%rbp)
testb $0x1, -0x2d4(%rbp)
je 0xa49aa
leaq -0x2f0(%rbp), %rdi
movl $0x4, %esi
callq 0x3d940
movq %rax, %rdi
callq 0x800b0
movb %al, -0x4dd(%rbp)
jmp 0xa499c
movb -0x4dd(%rbp), %al
andb $0x1, %al
movb %al, -0x1d0(%rbp)
testb $0x1, -0x1d0(%rbp)
je 0xa49eb
leaq -0x3f8(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0xa3c20
jmp 0xa49c8
leaq -0x2d8(%rbp), %rdi
addq $0x8, %rdi
leaq -0x3f8(%rbp), %rsi
callq 0xa5600
leaq -0x3f8(%rbp), %rdi
callq 0xa5430
leaq -0x2d8(%rbp), %rdi
callq 0xa4090
movl %eax, -0x3fc(%rbp)
testb $0x1, -0x1d0(%rbp)
je 0xa4e39
movl -0x2d0(%rbp), %eax
movl -0x1a0(%rbp), %ecx
subl 0xf4e14(%rip), %ecx     # 0x199830
cmpl %ecx, %eax
jg 0xa4e39
movl -0x2d0(%rbp), %eax
cmpl 0xf4e00(%rip), %eax     # 0x199830
jl 0xa4e39
movl -0x2cc(%rbp), %eax
cmpl 0xf4df6(%rip), %eax     # 0x199838
jl 0xa4e37
movq 0xf4569(%rip), %rdi     # 0x198fb8
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x4e8(%rbp)
jmp 0xa4a64
movq -0x4e8(%rbp), %rdi
movq 0xf4516(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4a79
leaq -0x2d0(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0xa54c0
movq %rax, -0x4f0(%rbp)
jmp 0xa4a95
movq -0x4f0(%rbp), %rdi
movslq -0x1d4(%rbp), %rsi
callq 0x4d100
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
cmpl $0xc, -0x2d0(%rbp)
jne 0xa4afd
cmpl $0xc, -0x1d4(%rbp)
je 0xa4aca
cmpl $0x0, -0x1d4(%rbp)
jne 0xa4afd
movq -0x170(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x4f8(%rbp)
jmp 0xa4ae6
movq -0x4f8(%rbp), %rdi
movq 0xf4494(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4afb
jmp 0xa4afd
cmpl $0xb, -0x2d0(%rbp)
jne 0xa4b4b
cmpl $0xb, -0x1d4(%rbp)
je 0xa4b18
cmpl $0x0, -0x1d4(%rbp)
jne 0xa4b4b
movq -0x178(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x500(%rbp)
jmp 0xa4b34
movq -0x500(%rbp), %rdi
movq 0xf4446(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4b49
jmp 0xa4b4b
cmpl $0xd, -0x2d0(%rbp)
jne 0xa4b99
cmpl $0xc, -0x1d4(%rbp)
je 0xa4b66
cmpl $0x1, -0x1d4(%rbp)
jne 0xa4b99
movq -0x178(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x508(%rbp)
jmp 0xa4b82
movq -0x508(%rbp), %rdi
movq 0xf43f8(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4b97
jmp 0xa4b99
cmpl $0xa, -0x2d0(%rbp)
jne 0xa4bf0
cmpl $0xa, -0x1d4(%rbp)
je 0xa4bb4
cmpl $0x0, -0x1d4(%rbp)
jne 0xa4bf0
cmpl $0x2, -0x3fc(%rbp)
jne 0xa4bf0
movq -0x180(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x510(%rbp)
jmp 0xa4bd9
movq -0x510(%rbp), %rdi
movq 0xf43a1(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4bee
jmp 0xa4c40
cmpl $0xa, -0x2d0(%rbp)
jne 0xa4c3e
cmpl $0xa, -0x1d4(%rbp)
je 0xa4c0b
cmpl $0x0, -0x1d4(%rbp)
jne 0xa4c3e
movq -0x188(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x518(%rbp)
jmp 0xa4c27
movq -0x518(%rbp), %rdi
movq 0xf4353(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4c3c
jmp 0xa4c3e
jmp 0xa4c40
cmpl $0xe, -0x2d0(%rbp)
jne 0xa4c97
cmpl $0xc, -0x1d4(%rbp)
je 0xa4c5b
cmpl $0x2, -0x1d4(%rbp)
jne 0xa4c97
cmpl $0x2, -0x3fc(%rbp)
jne 0xa4c97
movq -0x180(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x520(%rbp)
jmp 0xa4c80
movq -0x520(%rbp), %rdi
movq 0xf42fa(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4c95
jmp 0xa4ce7
cmpl $0xe, -0x2d0(%rbp)
jne 0xa4ce5
cmpl $0xe, -0x1d4(%rbp)
je 0xa4cb2
cmpl $0x2, -0x1d4(%rbp)
jne 0xa4ce5
movq -0x188(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x528(%rbp)
jmp 0xa4cce
movq -0x528(%rbp), %rdi
movq 0xf42ac(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4ce3
jmp 0xa4ce5
jmp 0xa4ce7
cmpl $0x9, -0x2d0(%rbp)
jne 0xa4d3e
cmpl $0x9, -0x1d4(%rbp)
je 0xa4d02
cmpl $0x0, -0x1d4(%rbp)
jne 0xa4d3e
cmpl $0x3, -0x3fc(%rbp)
jne 0xa4d3e
movq -0x190(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x530(%rbp)
jmp 0xa4d27
movq -0x530(%rbp), %rdi
movq 0xf4253(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4d3c
jmp 0xa4d8e
cmpl $0x9, -0x2d0(%rbp)
jne 0xa4d8c
cmpl $0x9, -0x1d4(%rbp)
je 0xa4d59
cmpl $0x0, -0x1d4(%rbp)
jne 0xa4d8c
movq -0x198(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x538(%rbp)
jmp 0xa4d75
movq -0x538(%rbp), %rdi
movq 0xf4205(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4d8a
jmp 0xa4d8c
jmp 0xa4d8e
cmpl $0xf, -0x2d0(%rbp)
jne 0xa4de5
cmpl $0xc, -0x1d4(%rbp)
je 0xa4da9
cmpl $0x3, -0x1d4(%rbp)
jne 0xa4de5
cmpl $0x3, -0x3fc(%rbp)
jne 0xa4de5
movq -0x190(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x540(%rbp)
jmp 0xa4dce
movq -0x540(%rbp), %rdi
movq 0xf41ac(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4de3
jmp 0xa4e35
cmpl $0xf, -0x2d0(%rbp)
jne 0xa4e33
cmpl $0xc, -0x1d4(%rbp)
je 0xa4e00
cmpl $0x3, -0x1d4(%rbp)
jne 0xa4e33
movq -0x198(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa520
movq %rax, -0x548(%rbp)
jmp 0xa4e1c
movq -0x548(%rbp), %rdi
movq 0xf415e(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4e31
jmp 0xa4e33
jmp 0xa4e35
jmp 0xa4e37
jmp 0xa4e39
leaq -0x2f0(%rbp), %rdi
callq 0x3dfa0
leaq -0x2d8(%rbp), %rdi
callq 0xa5640
jmp 0xa4e64
leaq -0x2d8(%rbp), %rdi
callq 0xa5640
jmp 0xa5089
jmp 0xa452b
movl -0x1a0(%rbp), %eax
subl 0xf49bb(%rip), %eax     # 0x199830
movl %eax, -0x400(%rbp)
movl -0x400(%rbp), %eax
cmpl 0xf49a9(%rip), %eax     # 0x199830
jl 0xa500c
movq $0x0, -0x408(%rbp)
movq -0x408(%rbp), %rax
movq %rax, -0x558(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0xa54c0
movq %rax, -0x550(%rbp)
jmp 0xa4ec2
movq -0x550(%rbp), %rdi
callq 0x467f0
movq %rax, %rcx
movq -0x558(%rbp), %rax
cmpq %rcx, %rax
je 0xa4fe1
movq -0x408(%rbp), %rax
movq %rax, -0x568(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0xa54c0
movq %rax, -0x560(%rbp)
jmp 0xa4f0b
movq -0x560(%rbp), %rdi
callq 0x467f0
movq %rax, %rcx
movq -0x568(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0xa4f6b
leaq -0x98(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0xa54c0
movq %rax, -0x570(%rbp)
jmp 0xa4f46
movq -0x570(%rbp), %rdi
movq -0x408(%rbp), %rsi
callq 0x4d100
movl (%rax), %esi
movq 0xf408e(%rip), %rdi     # 0x198ff0
callq 0xab20
jmp 0xa4f69
jmp 0xa4fc8
leaq -0x98(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0xa54c0
movq %rax, -0x578(%rbp)
jmp 0xa4f87
movq -0x578(%rbp), %rdi
movq -0x408(%rbp), %rsi
callq 0x4d100
movl (%rax), %esi
movq 0xf404d(%rip), %rdi     # 0x198ff0
callq 0xab20
movq %rax, -0x580(%rbp)
jmp 0xa4fb1
movq -0x580(%rbp), %rdi
leaq 0x90f1f(%rip), %rsi     # 0x135ede
callq 0xa5c0
jmp 0xa4fc6
jmp 0xa4fc8
jmp 0xa4fca
movq -0x408(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x408(%rbp)
jmp 0xa4e98
movq 0xf4008(%rip), %rdi     # 0x198ff0
movq 0xf3f99(%rip), %rsi     # 0x198f88
callq 0xa610
jmp 0xa4ff6
jmp 0xa4ff8
movl -0x400(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x400(%rbp)
jmp 0xa4e7b
leaq -0x1c0(%rbp), %rdi
callq 0xac88
leaq -0x168(%rbp), %rdi
callq 0xac88
leaq -0x148(%rbp), %rdi
callq 0xac88
leaq -0x128(%rbp), %rdi
callq 0xac88
leaq -0x108(%rbp), %rdi
callq 0xac88
leaq -0xe8(%rbp), %rdi
callq 0xac88
leaq -0xc8(%rbp), %rdi
callq 0xac88
leaq -0x98(%rbp), %rdi
callq 0xa5660
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x38(%rbp), %rdi
callq 0xac88
xorl %eax, %eax
addq $0x580, %rsp            # imm = 0x580
popq %rbp
retq
leaq -0x1c0(%rbp), %rdi
callq 0xac88
leaq -0x168(%rbp), %rdi
callq 0xac88
leaq -0x148(%rbp), %rdi
callq 0xac88
leaq -0x128(%rbp), %rdi
callq 0xac88
leaq -0x108(%rbp), %rdi
callq 0xac88
leaq -0xe8(%rbp), %rdi
callq 0xac88
leaq -0xc8(%rbp), %rdi
callq 0xac88
leaq -0x98(%rbp), %rdi
callq 0xa5660
leaq -0x58(%rbp), %rdi
callq 0xac88
leaq -0x38(%rbp), %rdi
callq 0xac88
movq -0x60(%rbp), %rdi
callq 0xab50
nopw %cs:(%rax,%rax)