// File: medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::PathMakeDecisionNoGenotype(SequencePath&, std::vector<DiploidVariant, std::allocator<DiploidVariant>>&, std::multimap<int, int, std::less<int>, std::allocator<std::pair<int const, int>>>**, std::__cxx11::list<SequencePath, std::allocator<SequencePath>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, int, int)
bool WholeGenome::PathMakeDecisionNoGenotype(SequencePath& sp,
                                 vector<DiploidVariant> & variant_list,
                                 multimap<int, int> * choices_by_pos[],
                                 list<SequencePath> & sequence_path_list,
                                 const string & reference_sequence,
                                 int score_unit,
                                 int match_mode,
                                 int score_scheme)
{
    int pos = sp.current_genome_pos+1;
    vector<pair<int, int>> candidate_choices[2];
    for(int i = 0; i < 2; i++){
        // because if it's (-1,-1), it will do nothing, so it's ok to have this one...
        candidate_choices[i].push_back(pair<int, int>(-1, -1));
        // to maintain existance
        // in this position, make choice of not use any variants, no matter if there is variant

        pair<multimap<int, int>::iterator, multimap<int, int>::iterator> var_range;
        var_range = choices_by_pos[i]->equal_range(pos);

        for(auto it = var_range.first; it != var_range.second; ++it){
            int var_index = (*it).second;
            DiploidVariant var = variant_list[var_index];
            // check if current var influence
            string ref = var.ref; //even we do not know the offset, we know ref start from pos of reference_sequence
            string alts[2];
            alts[0] = var.alts[0];
            alts[1] = alts[0];
            if(var.multi_alts){ //here do not have to change anything
                alts[1] = var.alts[1];
            }

            // not just purely consider if a vqriant can be applied, but if a choice
            bool choice_applicable = true;
            for(int k = 0; k < ref.length(); k++){
            // for each ref char
                int y = 0;
                // for each strain
                if(sp.string_sequences[i*2+y][k+pos] != "."){
                    // decision in this area has already been made
                    if(k >= alts[y].length()){
                        choice_applicable = false;
                        break;
                    }else{
                        if(ref[k] != alts[y][k]){
                            choice_applicable = false;
                            break;
                        }
                    }
                }
            }

            if(choice_applicable){
                candidate_choices[i].push_back(pair<int, int>(var_index, 0));
            }

            if(var.multi_alts){ // here do not have to change anything

                //if heterozygous, then there is another choice, check if it is applicable
                string temp = alts[0];
                alts[0] = alts[1];
                alts[1] = temp;

                choice_applicable = true;
                for(int k = 0; k < ref.length(); k++){
                // for each ref char
                    //for(int y = 0; y < 2; y++)
                    int y = 0;
                    // for each strain
                    if(sp.string_sequences[i*2+y][k+pos] != "."){
                        // decision in this area has already been made
                        if(k >= alts[y].length()){
                            // should be a deletion
                            choice_applicable = false;
                            break;
                        }else{
                            // should be equal at current position
                            // can be an insertion, as long as current position is the same
                            if(ref[k] != alts[y][k]){
                                choice_applicable = false;
                                break;
                            }
                        }
                    }
                }

                if(choice_applicable){
                    candidate_choices[i].push_back(pair<int, int>(var_index, 1));
                }
            }
        }
    }

    //dout << candidate_choices[0].size() << "," << candidate_choices[1].size() << endl;

    for(int i = 0; i < candidate_choices[0].size(); i++){
        for(int j = 0; j < candidate_choices[1].size(); j++){
            // iterate all choices
            SequencePath path = sp;
            pair<int, int> var_choice[2];
            var_choice[0] = candidate_choices[0][i];
            var_choice[1] = candidate_choices[1][j];
            for(int x = 0; x < 2; x++){
                // iterate truth and predict
                int var_index = var_choice[x].first;
                if(var_index != -1){
                    DiploidVariant var = variant_list[var_index];
                    // if(var.flag != x){
                    //     dout << "Error" << endl;
                    // }
                    string ref = var.ref;
                    string alts[2];
                    int c = var_choice[x].second;
                    alts[0] = var.alts[c];
                    path.score += CalculateScore(var,
                                                 c,
                                                 score_unit,
                                                 match_mode,
                                                 score_scheme);

                    ToUpper(ref);
                    ToUpper(alts[0]);
                    int y = 0;

                    int k = 0;
                    for(; k < ref.length()-1; k++){
                        if(k < alts[y].length()){
                            if(ref[k] != alts[y][k]){
                                path.string_sequences[x*2+y][pos+k] = alts[y].substr(k,1);
                            }
                            // else change nothing
                        }else{
                            path.string_sequences[x*2+y][pos+k] = "";
                        }
                    }
                    // hence k == ref.length()-1, the last position
                    if(k < alts[y].length()){
                        string alt_part = alts[y].substr(k, alts[y].length()-k);
                        if(alt_part.length() > 1){
                            if(alt_part[0] == ref[k]){
                                if(path.string_sequences[x*2+y][pos+k] == "."){
                                    path.string_sequences[x*2+y][pos+k] = alt_part;
                                }else{
                                    path.string_sequences[x*2+y][pos+k] += alt_part.substr(1, alt_part.size() - 1);
                                }
                            }else{
                                path.string_sequences[x*2+y][pos+k] = alt_part;
                            }
                        }else{
                            if(ref[k] != alts[y][k]){
                                path.string_sequences[x*2+y][pos+k] = alt_part;
                            }
                        }
                    }else{
                        path.string_sequences[x*2+y][pos+k] = "";
                    }

                }
                path.choice_made[x][pos] = var_choice[x];
            }
            sequence_path_list.push_back(path);
        }
    }

    //expected number of inserted paths are 2,3,4,6,x...
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6c0, %rsp            # imm = 0x6C0
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x4b8(%rbp)
movq -0x18(%rbp), %rax
movl 0xc8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x30, %rcx
movq %rcx, -0x4b0(%rbp)
movq %rax, -0x4a8(%rbp)
movq -0x4a8(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
callq 0x34a50
movq -0x4c0(%rbp), %rax
movq -0x4b0(%rbp), %rcx
addq $0x18, %rax
cmpq %rcx, %rax
movq %rax, -0x4a8(%rbp)
jne 0x221e0
movl $0x0, -0x74(%rbp)
cmpl $0x2, -0x74(%rbp)
jge 0x22936
movslq -0x74(%rbp), %rax
leaq (%rax,%rax,2), %rax
leaq -0x70(%rbp,%rax,8), %rax
movq %rax, -0x4c8(%rbp)
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
leaq -0x7c(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0x84(%rbp), %rdx
callq 0x34aa0
jmp 0x2225d
movq -0x4c8(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x34a70
jmp 0x2226f
leaq -0xa8(%rbp), %rdi
callq 0x34960
jmp 0x2227d
movq -0x28(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x34990
movq %rdx, -0x4d8(%rbp)
movq %rax, -0x4d0(%rbp)
jmp 0x222a2
movq -0x4d8(%rbp), %rax
movq -0x4d0(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x349d0
movq -0xa8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xa8(%rbp), %rsi
addq $0x8, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x33ac0
testb $0x1, %al
jne 0x222ff
jmp 0x22926
leaq -0xc0(%rbp), %rdi
callq 0x34a00
movl 0x4(%rax), %eax
movl %eax, -0xc4(%rbp)
movq -0x20(%rbp), %rdi
movslq -0xc4(%rbp), %rsi
callq 0x33de0
movq %rax, %rsi
leaq -0x120(%rbp), %rdi
callq 0x340a0
jmp 0x22335
leaq -0x118(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x61b0
jmp 0x2234a
leaq -0x180(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x4e8(%rbp)
movq %rax, -0x4e0(%rbp)
movq -0x4e0(%rbp), %rdi
movq %rdi, -0x4f0(%rbp)
callq 0x65e0
movq -0x4f0(%rbp), %rax
movq -0x4e8(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x4e0(%rbp)
jne 0x22366
leaq -0xf8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9080
movq %rax, %rsi
leaq -0x180(%rbp), %rdi
callq 0x6070
jmp 0x223b8
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x6070
jmp 0x223cd
testb $0x1, -0xdf(%rbp)
je 0x2243f
leaq -0xf8(%rbp), %rdi
movl $0x1, %esi
callq 0x9080
movq %rax, %rsi
leaq -0x160(%rbp), %rdi
callq 0x6070
jmp 0x223f8
jmp 0x2243f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x23356
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x22915
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x228bf
movb $0x1, -0x181(%rbp)
movl $0x0, -0x188(%rbp)
movslq -0x188(%rbp), %rax
movq %rax, -0x4f8(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x6630
movq %rax, %rcx
movq -0x4f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x225ae
movl $0x0, -0x18c(%rbp)
movq -0x18(%rbp), %rax
movl -0x74(%rbp), %ecx
movl -0x18c(%rbp), %esi
movl %ecx, %edx
movl %esi, %ecx
leal (%rcx,%rdx,2), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x8(%rax,%rcx,8), %rdi
movl -0x188(%rbp), %eax
movl -0x3c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq 0x3356e(%rip), %rsi     # 0x55a32
callq 0x17c70
movb %al, -0x4f9(%rbp)
jmp 0x224d1
movb -0x4f9(%rbp), %al
testb $0x1, %al
jne 0x224e0
jmp 0x22598
movslq -0x188(%rbp), %rax
movq %rax, -0x508(%rbp)
movslq -0x18c(%rbp), %rax
leaq -0x180(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
callq 0x6630
movq %rax, %rcx
movq -0x508(%rbp), %rax
cmpq %rcx, %rax
jb 0x22523
movb $0x0, -0x181(%rbp)
jmp 0x225ae
movslq -0x188(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x6810
movq %rax, -0x510(%rbp)
jmp 0x2253f
movq -0x510(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x51c(%rbp)
movslq -0x18c(%rbp), %rax
shlq $0x5, %rax
leaq -0x180(%rbp,%rax), %rdi
movslq -0x188(%rbp), %rsi
callq 0x6810
movq %rax, -0x518(%rbp)
jmp 0x22577
movl -0x51c(%rbp), %eax
movq -0x518(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x22594
movb $0x0, -0x181(%rbp)
jmp 0x225ae
jmp 0x22596
jmp 0x22598
jmp 0x2259a
movl -0x188(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x188(%rbp)
jmp 0x22450
testb $0x1, -0x181(%rbp)
je 0x22608
movslq -0x74(%rbp), %rax
leaq (%rax,%rax,2), %rax
leaq -0x70(%rbp,%rax,8), %rax
movq %rax, -0x528(%rbp)
movl $0x0, -0x198(%rbp)
leaq -0x194(%rbp), %rdi
leaq -0xc4(%rbp), %rsi
leaq -0x198(%rbp), %rdx
callq 0x34ad0
jmp 0x225f1
movq -0x528(%rbp), %rdi
leaq -0x194(%rbp), %rsi
callq 0x34a70
jmp 0x22606
jmp 0x22608
testb $0x1, -0xdf(%rbp)
je 0x2284c
leaq -0x1b8(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x61b0
jmp 0x2262a
leaq -0x160(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x6070
jmp 0x2263f
leaq -0x160(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x6070
jmp 0x22654
movb $0x1, -0x181(%rbp)
movl $0x0, -0x1bc(%rbp)
movslq -0x1bc(%rbp), %rax
movq %rax, -0x530(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x6630
movq %rax, %rcx
movq -0x530(%rbp), %rax
cmpq %rcx, %rax
jae 0x227e6
movl $0x0, -0x1c0(%rbp)
movq -0x18(%rbp), %rax
movl -0x74(%rbp), %ecx
movl -0x1c0(%rbp), %esi
movl %ecx, %edx
movl %esi, %ecx
leal (%rcx,%rdx,2), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x8(%rax,%rcx,8), %rdi
movl -0x1bc(%rbp), %eax
movl -0x3c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq 0x33359(%rip), %rsi     # 0x55a32
callq 0x17c70
movb %al, -0x531(%rbp)
jmp 0x226e6
movb -0x531(%rbp), %al
testb $0x1, %al
jne 0x226f5
jmp 0x227d0
movslq -0x1bc(%rbp), %rax
movq %rax, -0x540(%rbp)
movslq -0x1c0(%rbp), %rax
leaq -0x180(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
callq 0x6630
movq %rax, %rcx
movq -0x540(%rbp), %rax
cmpq %rcx, %rax
jb 0x2275b
movb $0x0, -0x181(%rbp)
jmp 0x227e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x6828
jmp 0x228bf
movslq -0x1bc(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x6810
movq %rax, -0x548(%rbp)
jmp 0x22777
movq -0x548(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x554(%rbp)
movslq -0x1c0(%rbp), %rax
shlq $0x5, %rax
leaq -0x180(%rbp,%rax), %rdi
movslq -0x1bc(%rbp), %rsi
callq 0x6810
movq %rax, -0x550(%rbp)
jmp 0x227af
movl -0x554(%rbp), %eax
movq -0x550(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x227cc
movb $0x0, -0x181(%rbp)
jmp 0x227e6
jmp 0x227ce
jmp 0x227d0
jmp 0x227d2
movl -0x1bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x22665
testb $0x1, -0x181(%rbp)
je 0x22840
movslq -0x74(%rbp), %rax
leaq (%rax,%rax,2), %rax
leaq -0x70(%rbp,%rax,8), %rax
movq %rax, -0x560(%rbp)
movl $0x1, -0x1cc(%rbp)
leaq -0x1c8(%rbp), %rdi
leaq -0xc4(%rbp), %rsi
leaq -0x1cc(%rbp), %rdx
callq 0x34ad0
jmp 0x22829
movq -0x560(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x34a70
jmp 0x2283e
jmp 0x22840
leaq -0x1b8(%rbp), %rdi
callq 0x6828
leaq -0x180(%rbp), %rax
movq %rax, -0x570(%rbp)
addq $0x40, %rax
movq %rax, -0x568(%rbp)
movq -0x568(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x578(%rbp)
callq 0x6828
movq -0x570(%rbp), %rcx
movq -0x578(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x568(%rbp)
jne 0x22865
leaq -0x140(%rbp), %rdi
callq 0x6828
leaq -0x120(%rbp), %rdi
callq 0x32c60
leaq -0xc0(%rbp), %rdi
callq 0x34a20
jmp 0x222df
leaq -0x180(%rbp), %rax
movq %rax, -0x588(%rbp)
addq $0x40, %rax
movq %rax, -0x580(%rbp)
movq -0x580(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x590(%rbp)
callq 0x6828
movq -0x588(%rbp), %rcx
movq -0x590(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x580(%rbp)
jne 0x228d8
leaq -0x140(%rbp), %rdi
callq 0x6828
leaq -0x120(%rbp), %rdi
callq 0x32c60
jmp 0x23356
jmp 0x22928
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x22218
movl $0x0, -0x1d0(%rbp)
movslq -0x1d0(%rbp), %rax
movq %rax, -0x598(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x34b00
movq %rax, %rcx
movq -0x598(%rbp), %rax
cmpq %rcx, %rax
jae 0x232fd
movl $0x0, -0x1d4(%rbp)
movslq -0x1d4(%rbp), %rax
movq %rax, -0x5a0(%rbp)
leaq -0x70(%rbp), %rdi
addq $0x18, %rdi
callq 0x34b00
movq %rax, %rcx
movq -0x5a0(%rbp), %rax
cmpq %rcx, %rax
jae 0x232e7
movq -0x18(%rbp), %rsi
leaq -0x358(%rbp), %rdi
callq 0x34b20
jmp 0x229b4
leaq -0x370(%rbp), %rax
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, -0x5b0(%rbp)
movq %rax, -0x5a8(%rbp)
movq -0x5a8(%rbp), %rdi
movq %rdi, -0x5b8(%rbp)
callq 0x34e90
jmp 0x229e5
movq -0x5b0(%rbp), %rcx
movq -0x5b8(%rbp), %rax
addq $0x8, %rax
cmpq %rcx, %rax
movq %rax, -0x5a8(%rbp)
jne 0x229d0
movslq -0x1d0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x34eb0
movq %rax, %rsi
leaq -0x370(%rbp), %rdi
callq 0x34ed0
jmp 0x22a24
leaq -0x58(%rbp), %rdi
movslq -0x1d4(%rbp), %rsi
callq 0x34eb0
movq %rax, %rsi
leaq -0x368(%rbp), %rdi
callq 0x34ed0
jmp 0x22a45
movl $0x0, -0x374(%rbp)
cmpl $0x2, -0x374(%rbp)
jge 0x232a7
movslq -0x374(%rbp), %rax
movl -0x370(%rbp,%rax,8), %eax
movl %eax, -0x378(%rbp)
cmpl $-0x1, -0x378(%rbp)
je 0x23244
movq -0x20(%rbp), %rdi
movslq -0x378(%rbp), %rsi
callq 0x33de0
movq %rax, %rsi
leaq -0x3d0(%rbp), %rdi
callq 0x340a0
jmp 0x22a9e
leaq -0x3c8(%rbp), %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x61b0
jmp 0x22ab3
leaq -0x430(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x5c8(%rbp)
movq %rax, -0x5c0(%rbp)
movq -0x5c0(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x65e0
movq -0x5d0(%rbp), %rax
movq -0x5c8(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x5c0(%rbp)
jne 0x22acf
movslq -0x374(%rbp), %rax
movl -0x36c(%rbp,%rax,8), %eax
movl %eax, -0x434(%rbp)
leaq -0x3a8(%rbp), %rdi
movslq -0x434(%rbp), %rsi
callq 0x9080
movq %rax, %rsi
leaq -0x430(%rbp), %rdi
callq 0x6070
jmp 0x22b38
movq -0x4b8(%rbp), %rdi
movl -0x434(%rbp), %edx
movl 0x10(%rbp), %ecx
movl 0x18(%rbp), %r8d
movl 0x20(%rbp), %r9d
leaq -0x3d0(%rbp), %rsi
callq 0x21fd0
movl %eax, -0x5d4(%rbp)
jmp 0x22b64
movq -0x4b8(%rbp), %rdi
movl -0x5d4(%rbp), %ecx
movl -0x200(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x200(%rbp)
leaq -0x3f0(%rbp), %rsi
callq 0x328c0
jmp 0x22b8d
movq -0x4b8(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x328c0
jmp 0x22ba2
movl $0x0, -0x438(%rbp)
movl $0x0, -0x43c(%rbp)
movslq -0x43c(%rbp), %rax
movq %rax, -0x5e0(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x6630
movq %rax, %rcx
movq -0x5e0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x22daf
movslq -0x43c(%rbp), %rax
movq %rax, -0x5e8(%rbp)
movslq -0x438(%rbp), %rax
leaq -0x430(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
callq 0x6630
movq %rax, %rcx
movq -0x5e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x22d52
movslq -0x43c(%rbp), %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x6810
movq %rax, -0x5f0(%rbp)
jmp 0x22c3e
movq -0x5f0(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x5fc(%rbp)
movslq -0x438(%rbp), %rax
shlq $0x5, %rax
leaq -0x430(%rbp,%rax), %rdi
movslq -0x43c(%rbp), %rsi
callq 0x6810
movq %rax, -0x5f8(%rbp)
jmp 0x22c76
movl -0x5fc(%rbp), %eax
movq -0x5f8(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x22d50
movslq -0x438(%rbp), %rax
shlq $0x5, %rax
leaq -0x430(%rbp,%rax), %rsi
movslq -0x43c(%rbp), %rdx
leaq -0x460(%rbp), %rdi
movl $0x1, %ecx
callq 0x6460
jmp 0x22cbb
leaq -0x358(%rbp), %rdi
addq $0x8, %rdi
movl -0x374(%rbp), %eax
shll %eax
addl -0x438(%rbp), %eax
cltq
imulq $0x18, %rax, %rax
addq %rax, %rdi
movl -0x3c(%rbp), %eax
addl -0x43c(%rbp), %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq -0x460(%rbp), %rsi
callq 0x6530
leaq -0x460(%rbp), %rdi
callq 0x6828
jmp 0x22d50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x232d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x23233
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x231dd
jmp 0x22d99
movl -0x374(%rbp), %eax
movl -0x438(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
cltq
leaq (%rax,%rax,2), %rax
leaq -0x350(%rbp,%rax,8), %rdi
movl -0x3c(%rbp), %eax
movl -0x43c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq 0x3280e(%rip), %rsi     # 0x5559e
callq 0x65c0
jmp 0x22d97
jmp 0x22d99
jmp 0x22d9b
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
jmp 0x22bb6
movslq -0x43c(%rbp), %rax
movq %rax, -0x608(%rbp)
movslq -0x438(%rbp), %rax
leaq -0x430(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
callq 0x6630
movq %rax, %rcx
movq -0x608(%rbp), %rax
cmpq %rcx, %rax
jae 0x23132
movslq -0x438(%rbp), %rax
shlq $0x5, %rax
leaq -0x430(%rbp,%rax), %rdi
movq %rdi, -0x618(%rbp)
movslq -0x43c(%rbp), %rax
movq %rax, -0x610(%rbp)
callq 0x6630
movq -0x618(%rbp), %rsi
movq -0x610(%rbp), %rdx
movq %rax, %rcx
movslq -0x43c(%rbp), %rax
subq %rax, %rcx
leaq -0x480(%rbp), %rdi
callq 0x6460
jmp 0x22e40
leaq -0x480(%rbp), %rdi
callq 0x6630
cmpq $0x1, %rax
jbe 0x23062
xorl %eax, %eax
movl %eax, %esi
leaq -0x480(%rbp), %rdi
callq 0x6810
movq %rax, -0x620(%rbp)
jmp 0x22e6f
movq -0x620(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x62c(%rbp)
movslq -0x43c(%rbp), %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x6810
movq %rax, -0x628(%rbp)
jmp 0x22e9b
movl -0x62c(%rbp), %eax
movq -0x628(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x23016
movl -0x374(%rbp), %eax
movl -0x438(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
cltq
leaq (%rax,%rax,2), %rax
leaq -0x350(%rbp,%rax,8), %rdi
movl -0x3c(%rbp), %eax
movl -0x43c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq 0x32b41(%rip), %rsi     # 0x55a32
callq 0x125e0
movb %al, -0x62d(%rbp)
jmp 0x22efe
movb -0x62d(%rbp), %al
testb $0x1, %al
jne 0x22f0a
jmp 0x22f6b
movl -0x374(%rbp), %eax
movl -0x438(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
cltq
leaq (%rax,%rax,2), %rax
leaq -0x350(%rbp,%rax,8), %rdi
movl -0x3c(%rbp), %eax
movl -0x43c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq -0x480(%rbp), %rsi
callq 0x6070
jmp 0x22f4f
jmp 0x23014
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x23121
leaq -0x480(%rbp), %rdi
movq %rdi, -0x638(%rbp)
callq 0x6320
movq -0x638(%rbp), %rsi
movq %rax, %rcx
decq %rcx
leaq -0x4a0(%rbp), %rdi
movl $0x1, %edx
callq 0x6460
jmp 0x22f9e
movl -0x374(%rbp), %eax
movl -0x438(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
cltq
leaq (%rax,%rax,2), %rax
leaq -0x350(%rbp,%rax,8), %rdi
movl -0x3c(%rbp), %eax
movl -0x43c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x6560
jmp 0x22fe3
leaq -0x4a0(%rbp), %rdi
callq 0x6828
jmp 0x23014
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x6828
jmp 0x23121
jmp 0x2305d
movl -0x374(%rbp), %eax
movl -0x438(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
cltq
leaq (%rax,%rax,2), %rax
leaq -0x350(%rbp,%rax,8), %rdi
movl -0x3c(%rbp), %eax
movl -0x43c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq -0x480(%rbp), %rsi
callq 0x6070
jmp 0x2305b
jmp 0x2305d
jmp 0x23113
movslq -0x43c(%rbp), %rsi
leaq -0x3f0(%rbp), %rdi
callq 0x6810
movq %rax, -0x640(%rbp)
jmp 0x2307e
movq -0x640(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x64c(%rbp)
movslq -0x438(%rbp), %rax
shlq $0x5, %rax
leaq -0x430(%rbp,%rax), %rdi
movslq -0x43c(%rbp), %rsi
callq 0x6810
movq %rax, -0x648(%rbp)
jmp 0x230b6
movl -0x64c(%rbp), %eax
movq -0x648(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x23111
movl -0x374(%rbp), %eax
movl -0x438(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
cltq
leaq (%rax,%rax,2), %rax
leaq -0x350(%rbp,%rax,8), %rdi
movl -0x3c(%rbp), %eax
movl -0x43c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq -0x480(%rbp), %rsi
callq 0x6070
jmp 0x2310f
jmp 0x23111
jmp 0x23113
leaq -0x480(%rbp), %rdi
callq 0x6828
jmp 0x23179
leaq -0x480(%rbp), %rdi
callq 0x6828
jmp 0x231dd
movl -0x374(%rbp), %eax
movl -0x438(%rbp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
cltq
leaq (%rax,%rax,2), %rax
leaq -0x350(%rbp,%rax,8), %rdi
movl -0x3c(%rbp), %eax
movl -0x43c(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x9080
movq %rax, %rdi
leaq 0x3242e(%rip), %rsi     # 0x5559e
callq 0x65c0
jmp 0x23177
jmp 0x23179
leaq -0x430(%rbp), %rax
movq %rax, -0x660(%rbp)
addq $0x40, %rax
movq %rax, -0x658(%rbp)
movq -0x658(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x668(%rbp)
callq 0x6828
movq -0x660(%rbp), %rcx
movq -0x668(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x658(%rbp)
jne 0x23192
leaq -0x3f0(%rbp), %rdi
callq 0x6828
leaq -0x3d0(%rbp), %rdi
callq 0x32c60
jmp 0x23244
leaq -0x430(%rbp), %rax
movq %rax, -0x678(%rbp)
addq $0x40, %rax
movq %rax, -0x670(%rbp)
movq -0x670(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x680(%rbp)
callq 0x6828
movq -0x678(%rbp), %rcx
movq -0x680(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x670(%rbp)
jne 0x231f6
leaq -0x3f0(%rbp), %rdi
callq 0x6828
leaq -0x3d0(%rbp), %rdi
callq 0x32c60
jmp 0x232d9
movslq -0x374(%rbp), %rax
leaq -0x370(%rbp,%rax,8), %rcx
movq %rcx, -0x690(%rbp)
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq -0x2f0(%rbp,%rax), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x34f00
movq %rax, -0x688(%rbp)
jmp 0x2327c
movq -0x690(%rbp), %rsi
movq -0x688(%rbp), %rdi
callq 0x34ed0
jmp 0x23291
jmp 0x23293
movl -0x374(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x374(%rbp)
jmp 0x22a4f
movq -0x30(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0x34fe0
jmp 0x232b9
leaq -0x358(%rbp), %rdi
callq 0x35020
movl -0x1d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d4(%rbp)
jmp 0x22974
leaq -0x358(%rbp), %rdi
callq 0x35020
jmp 0x23356
jmp 0x232e9
movl -0x1d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d0(%rbp)
jmp 0x22940
movb $0x1, -0x1(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x6a0(%rbp)
addq $0x30, %rax
movq %rax, -0x698(%rbp)
movq -0x698(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x6a8(%rbp)
callq 0x350f0
movq -0x6a0(%rbp), %rcx
movq -0x6a8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x698(%rbp)
jne 0x23317
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x6c0, %rsp            # imm = 0x6C0
popq %rbp
retq
leaq -0x70(%rbp), %rax
movq %rax, -0x6b8(%rbp)
addq $0x30, %rax
movq %rax, -0x6b0(%rbp)
movq -0x6b0(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x6c0(%rbp)
callq 0x350f0
movq -0x6b8(%rbp), %rcx
movq -0x6c0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x6b0(%rbp)
jne 0x2336c
jmp 0x2339f
movq -0x90(%rbp), %rdi
callq 0x6750
nopl (%rax,%rax)