// File: /workspace/github_cpp_makefile_star2_O1/medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::PathMakeDecision(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::PathMakeDecision(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));
        // 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];
            //PrintVariant(var);

            // 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 && !var.zero_one_var){
                alts[1] = var.alts[1];
            }else if(var.heterozygous){
                alts[1] = ref;
            }

            // not just purely consider if a vqriant can be applied, but if a choice
            int skiped_y = -1;
            if(alts[1] == ref) skiped_y = 1;

            bool choice_applicable = true;
            for(int k = 0; k < ref.length(); k++){
            // for each ref char
                for(int y = 0; y < 2; y++){
                    // for each strain
                    if(y == skiped_y) continue;
                    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) break;
            }

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

            if(var.heterozygous){

                //if heterozygous, then there is another choice, check if it is applicable

                string temp = alts[0];
                alts[0] = alts[1];
                alts[1] = temp;

                skiped_y = -1;
                if(alts[0] == ref) skiped_y = 0;

                choice_applicable = true;
                for(int k = 0; k < ref.length(); k++){
                // for each ref char
                    for(int y = 0; y < 2; y++){
                        // for each strain
                        if(skiped_y == y) continue;
                        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) break;
                }

                if(choice_applicable){
                    if(var.multi_alts && !var.zero_one_var){
                        candidate_choices[i].push_back(pair<int, int>(var_index, 1));
                    }else{
                        candidate_choices[i].push_back(pair<int, int>(var_index, -1));
                    }
                }
            }

            if(var.multi_alts && var.zero_one_var){
                // here contains another two combinations  alt1/ref and ref/alt1
                alts[0] = var.alts[1];
                alts[1] = ref;

                choice_applicable = true;
                int y = 0;
                for(int k = 0; k < ref.length(); k++){
                // for each ref char
                    {
                        // 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) break;
                }

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


                alts[0] = ref;
                alts[1] = var.alts[1];

                choice_applicable = true;
                y = 1;
                for(int k = 0; k < ref.length(); k++){
                // for each ref char
                    {
                        // 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) break;
                }

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

    //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){
//                    string temp_sequence = reference_sequence.substr(pos, 1);
//                    path.string_sequences[x*2][pos] = temp_sequence;
//                    path.string_sequences[x*2+1][pos] = temp_sequence;
//                }else{
                    // set score


                    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;
                    if(c == -1){
                        alts[0] = ref;
                        alts[1] = var.alts[0];
                    }else if(c == -2){
                        alts[0] = ref;
                        alts[1] = var.alts[1];
                    }else{
                        // c == 0 or 1
                        alts[0] = var.alts[c];
                        alts[1] = alts[0];

                        if(var.multi_alts && !var.zero_one_var){
                            // choose 1 or 0
                            alts[1] = var.alts[1- c];
                        }else{
                            // c is 0, choose 0 or -1
                            if(var.heterozygous) alts[1] = ref;
                        }
                    }

                    path.score += CalculateScore(var,
                                                 c,
                                                 score_unit,
                                                 match_mode,
                                                 score_scheme);

                    ToUpper(ref);
                    ToUpper(alts[0]);
                    ToUpper(alts[1]);
                    for(int y = 0; y < 2; y++){
                        // iterate two alts
                        string alt = alts[y];
                        vector<string> alt_vector;
                        GenerateAltVector(ref, alt, alt_vector);

                        int k = 0;
                        for(; k < ref.length()-1; k++){

                            if(alt_vector[k].size() != 1 || ref[k] != alt_vector[k][0]){
                                path.string_sequences[x*2+y][pos+k] = alt_vector[k];
                            }
                            // else changes nothing

                        }
                        // hence k == ref.length()-1, the last position
                        assert(k == ref.length()-1);
                        string alt_part = alt_vector[k];
                        if(alt_part.length() > 0){
                            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] != alt_vector[k][0]){
                                    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];
            }
            // choice made
            dout << "after decision at pos " << pos << endl;
            PrintPath(path);
            sequence_path_list.push_back(path);
        }
    }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3c8, %rsp            # imm = 0x3C8
movq %r8, 0x178(%rsp)
movq %rcx, 0x1f8(%rsp)
movq %rdx, 0x188(%rsp)
movq %rdi, 0x210(%rsp)
movl 0xc8(%rsi), %eax
incl %eax
leaq 0x4(%rsp), %rcx
movl %eax, (%rcx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x160(%rsp)
movaps %xmm0, 0x150(%rsp)
movaps %xmm0, 0x140(%rsp)
leaq 0x260(%rsp), %r13
leaq 0x270(%rsp), %rbp
leaq 0x60(%rsp), %r15
movq %rsi, 0x200(%rsp)
leaq 0x8(%rsi), %r12
movq %r12, 0x1f0(%rsp)
movq %r12, 0x10(%rsp)
xorl %eax, %eax
leaq (%rax,%rax,2), %rcx
movq %rcx, %r14
leaq (%rsp,%rcx,8), %rdi
addq $0x140, %rdi            # imm = 0x140
movq $-0x1, 0x248(%rsp)
movq %rdi, 0x38(%rsp)
leaq 0x248(%rsp), %rsi
movq %rax, %rbx
callq 0x2e284
movq 0x1f8(%rsp), %rax
movq %rbx, 0x180(%rsp)
movq (%rax,%rbx,8), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2e20c
movq %rax, %rsi
cmpq %rdx, %rax
je 0x1aa8b
shlq $0x4, %r14
movq 0x1f0(%rsp), %rcx
addq %rcx, %r14
movq %r14, 0x40(%rsp)
movq 0x180(%rsp), %rax
leaq 0x1(,%rax,2), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
movq %rax, 0x220(%rsp)
movq %rdx, 0x208(%rsp)
movq %rsi, 0x218(%rsp)
movslq 0x24(%rsi), %rcx
movq 0x188(%rsp), %rax
movq (%rax), %rbx
movq %rcx, 0x8(%rsp)
imulq $0x58, %rcx, %r14
movl (%rbx,%r14), %eax
movl %eax, 0x248(%rsp)
movq %r13, 0x250(%rsp)
movq 0x8(%rbx,%r14), %rsi
movq 0x10(%rbx,%r14), %rdx
addq %rsi, %rdx
leaq 0x250(%rsp), %rdi
callq 0x112ce
addq %r14, %rbx
leaq 0x28(%rbx), %rsi
movq %rbp, %rdi
callq 0x289ec
movq 0x50(%rbx), %rax
leaq 0x250(%rsp), %rcx
movq %rax, 0x48(%rcx)
movups 0x40(%rbx), %xmm0
movups %xmm0, 0x38(%rcx)
movq %r15, 0x50(%rsp)
movq 0x250(%rsp), %rsi
movq 0x258(%rsp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x112ce
movl $0x10, %eax
leaq (%rsp,%rax), %rcx
addq $0x90, %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x1a547
movq 0x270(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x51c0
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
callq 0x51c0
cmpb $0x1, 0x289(%rsp)
jne 0x1a5ac
cmpb $0x0, 0x28a(%rsp)
je 0x1a5bd
cmpb $0x1, 0x288(%rsp)
leaq 0x50(%rsp), %rsi
je 0x1a5c9
jmp 0x1a5d1
movq 0x270(%rsp), %rsi
addq $0x20, %rsi
movq %r14, %rdi
callq 0x51c0
movq 0xb8(%rsp), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq 0x58(%rsp), %rdx
jne 0x1a613
testq %rdx, %rdx
je 0x1a60e
movq 0x50(%rsp), %rsi
movq 0xb0(%rsp), %rdi
callq 0x5350
testl %eax, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmoveq %rcx, %rax
jmp 0x1a613
movl $0x1, %eax
cmpq $0x0, 0x58(%rsp)
je 0x1a6c2
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
movb $0x1, %r12b
xorl %r14d, %r14d
movslq %r14d, %rbx
leaq 0x98(%rsp), %r15
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x1a67c
movslq 0x4(%rsp), %rdi
addq %rbx, %rdi
shlq $0x5, %rdi
movq 0x10(%rsp), %rax
addq (%rax,%rbp), %rdi
leaq 0x173fb(%rip), %rsi     # 0x31a56
callq 0x50e0
testl %eax, %eax
je 0x1a67c
cmpq %r14, (%r15)
jbe 0x1a68c
movq 0x50(%rsp), %rax
movb (%rax,%r14), %al
movq -0x8(%r15), %rcx
cmpb (%rcx,%r14), %al
jne 0x1a68c
addq $0x18, %rbp
addq $0x20, %r15
cmpq $0x18, %rbp
je 0x1a63a
jmp 0x1a68f
xorl %r12d, %r12d
testb $0x1, %r12b
je 0x1a69f
incq %r14
cmpq %r14, 0x58(%rsp)
ja 0x1a62d
testb $0x1, %r12b
leaq 0x260(%rsp), %r13
leaq 0x270(%rsp), %rbp
leaq 0x60(%rsp), %r15
leaq 0xb0(%rsp), %r14
je 0x1a6e2
movq 0x8(%rsp), %rax
movl %eax, 0x18(%rsp)
movl $0x0, 0x1c(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2e284
cmpb $0x1, 0x288(%rsp)
jne 0x1a8a6
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x112ce
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x51c0
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x51c0
movq 0x98(%rsp), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq 0x58(%rsp), %rdx
jne 0x1a773
testq %rdx, %rdx
je 0x1a771
movq 0x50(%rsp), %rsi
movq 0x90(%rsp), %rdi
callq 0x5350
testl %eax, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x0, %ecx
cmoveq %rcx, %rax
jmp 0x1a773
xorl %eax, %eax
cmpq $0x0, 0x58(%rsp)
je 0x1a822
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
movb $0x1, %al
xorl %ebp, %ebp
movl %eax, 0x48(%rsp)
movslq %ebp, %rbx
leaq 0x98(%rsp), %r15
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x1a7dd
movslq 0x4(%rsp), %rdi
addq %rbx, %rdi
shlq $0x5, %rdi
movq 0x10(%rsp), %rax
addq (%rax,%r14), %rdi
leaq 0x17298(%rip), %rsi     # 0x31a56
callq 0x50e0
testl %eax, %eax
je 0x1a7dd
cmpq %rbp, (%r15)
jbe 0x1a7f1
movq 0x50(%rsp), %rax
movb (%rax,%rbp), %al
movq -0x8(%r15), %rcx
cmpb (%rcx,%rbp), %al
jne 0x1a7f1
addq $0x18, %r14
addq $0x20, %r15
cmpq $0x18, %r14
je 0x1a79d
movl 0x48(%rsp), %eax
jmp 0x1a7f3
xorl %eax, %eax
testb $0x1, %al
je 0x1a801
incq %rbp
cmpq %rbp, 0x58(%rsp)
ja 0x1a78b
testb $0x1, %al
leaq 0x260(%rsp), %r13
leaq 0x270(%rsp), %rbp
leaq 0x60(%rsp), %r15
leaq 0xb0(%rsp), %r14
je 0x1a88a
cmpb $0x1, 0x289(%rsp)
jne 0x1a836
cmpb $0x0, 0x28a(%rsp)
je 0x1a861
movq 0x8(%rsp), %rax
movl %eax, 0x100(%rsp)
movl $0xffffffff, 0x104(%rsp) # imm = 0xFFFFFFFF
movq 0x38(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x2e284
jmp 0x1a88a
movq 0x8(%rsp), %rax
movl %eax, 0x100(%rsp)
movl $0x1, 0x104(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x2e284
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1a8a6
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
cmpb $0x0, 0x289(%rsp)
je 0x1aa01
cmpb $0x1, 0x28a(%rsp)
jne 0x1aa01
movq 0x270(%rsp), %rsi
addq $0x20, %rsi
leaq 0x90(%rsp), %rdi
callq 0x51c0
movq %r14, %rdi
leaq 0x50(%rsp), %rsi
callq 0x51c0
cmpq $0x0, 0x58(%rsp)
je 0x1a940
xorl %ebx, %ebx
movl 0x4(%rsp), %eax
addl %ebx, %eax
movslq %eax, %rdi
shlq $0x5, %rdi
movq 0x40(%rsp), %rax
addq (%rax), %rdi
leaq 0x17148(%rip), %rsi     # 0x31a56
callq 0x50e0
testl %eax, %eax
je 0x1a936
cmpq %rbx, 0x98(%rsp)
jbe 0x1a960
movq 0x50(%rsp), %rax
movb (%rax,%rbx), %al
movq 0x90(%rsp), %rcx
cmpb (%rcx,%rbx), %al
jne 0x1a960
incq %rbx
cmpq %rbx, 0x58(%rsp)
ja 0x1a8f2
movq 0x8(%rsp), %rax
movl %eax, 0x18(%rsp)
movl $0x1, 0x1c(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2e284
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x51c0
movq 0x270(%rsp), %rsi
addq $0x20, %rsi
movq %r14, %rdi
callq 0x51c0
cmpq $0x0, 0x58(%rsp)
je 0x1a9e1
xorl %ebx, %ebx
movl 0x4(%rsp), %eax
addl %ebx, %eax
movslq %eax, %rdi
shlq $0x5, %rdi
movq 0x220(%rsp), %rax
addq (%rax), %rdi
leaq 0x170a7(%rip), %rsi     # 0x31a56
callq 0x50e0
testl %eax, %eax
je 0x1a9d7
cmpq %rbx, 0xb8(%rsp)
jbe 0x1aa01
movq 0x50(%rsp), %rax
movb (%rax,%rbx), %al
movq 0xb0(%rsp), %rcx
cmpb (%rcx,%rbx), %al
jne 0x1aa01
incq %rbx
cmpq %rbx, 0x58(%rsp)
ja 0x1a990
movq 0x8(%rsp), %rax
movl %eax, 0x18(%rsp)
movl $0xfffffffe, 0x1c(%rsp) # imm = 0xFFFFFFFE
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2e284
movq $-0x40, %rbx
leaq 0xc0(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x1aa24
movq (%r14), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x1aa10
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x1aa45
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5340
movq %rbp, %rdi
callq 0xe7ca
movq 0x250(%rsp), %rdi
cmpq %r13, %rdi
je 0x1aa6a
movq 0x260(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x218(%rsp), %rdi
callq 0x5250
movq %rax, %rsi
movq 0x208(%rsp), %rdx
cmpq %rdx, %rax
jne 0x1a4ac
movq 0x180(%rsp), %rcx
leaq 0x1(%rcx), %rax
addq $0x30, 0x10(%rsp)
testq %rcx, %rcx
je 0x1a413
movq 0x148(%rsp), %rax
cmpq 0x140(%rsp), %rax
je 0x1b39d
leaq 0x98(%rsp), %r12
leaq 0x110(%rsp), %r13
leaq 0x238(%rsp), %r14
movq $0x0, 0x40(%rsp)
movq 0x160(%rsp), %rax
cmpq 0x158(%rsp), %rax
je 0x1b373
movq $0x0, 0x8(%rsp)
leaq 0x248(%rsp), %rdi
movq 0x200(%rsp), %rsi
callq 0x2935c
xorps %xmm0, %xmm0
movaps %xmm0, 0xf0(%rsp)
movq 0x140(%rsp), %rax
movq 0x158(%rsp), %rcx
movq 0x40(%rsp), %rsi
movl (%rax,%rsi,8), %edx
movl %edx, 0xf0(%rsp)
movl 0x4(%rax,%rsi,8), %eax
movl %eax, 0xf4(%rsp)
movq 0x8(%rsp), %rdx
movl (%rcx,%rdx,8), %eax
movl %eax, 0xf8(%rsp)
movl 0x4(%rcx,%rdx,8), %eax
movl %eax, 0xfc(%rsp)
xorl %ebx, %ebx
movslq 0xf0(%rsp,%rbx,8), %rax
cmpq $-0x1, %rax
je 0x1b1f3
movq %rbx, 0x48(%rsp)
movq 0x188(%rsp), %rcx
movq (%rcx), %rbx
imulq $0x58, %rax, %r15
movl (%rbx,%r15), %eax
movl %eax, 0x90(%rsp)
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x8(%rbx,%r15), %rsi
movq 0x10(%rbx,%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x112ce
addq %r15, %rbx
leaq 0x28(%rbx), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x289ec
movq 0x50(%rbx), %rax
movq %rax, 0x48(%r12)
movups 0x40(%rbx), %xmm0
movups %xmm0, 0x38(%r12)
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x112ce
movl $0x10, %eax
leaq (%rsp,%rax), %rcx
addq $0x50, %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x1ac0b
movq 0x48(%rsp), %rax
movslq 0xf4(%rsp,%rax,8), %rbx
cmpq $-0x2, %rbx
je 0x1ac60
cmpl $-0x1, %ebx
jne 0x1ac7d
leaq 0x50(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x51c0
movq 0xb8(%rsp), %rsi
jmp 0x1ace0
leaq 0x50(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x51c0
movq 0xb8(%rsp), %rsi
addq $0x20, %rsi
jmp 0x1ace0
movq %rbx, %rsi
shlq $0x5, %rsi
addq 0xb8(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x51c0
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x51c0
cmpb $0x1, 0xd1(%rsp)
jne 0x1acb9
cmpb $0x0, 0xd2(%rsp)
je 0x1acca
cmpb $0x1, 0xd0(%rsp)
leaq 0x18(%rsp), %rsi
je 0x1ace0
jmp 0x1acea
movl $0x1, %eax
subl %ebx, %eax
movslq %eax, %rsi
shlq $0x5, %rsi
addq 0xb8(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x51c0
movq 0x210(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movl %ebx, %edx
movl 0x400(%rsp), %ecx
movl 0x408(%rsp), %r8d
movl 0x410(%rsp), %r9d
callq 0x176ee
addl %eax, 0x3a0(%rsp)
movq 0x20(%rsp), %rbx
testq %rbx, %rbx
je 0x1ad47
movq 0x18(%rsp), %r15
xorl %r12d, %r12d
movsbl (%r15,%r12), %edi
callq 0x5610
movb %al, (%r15,%r12)
incq %r12
cmpq %r12, %rbx
jne 0x1ad31
movq 0x58(%rsp), %rbx
testq %rbx, %rbx
je 0x1ad6f
movq 0x50(%rsp), %r15
xorl %r12d, %r12d
movsbl (%r15,%r12), %edi
callq 0x5610
movb %al, (%r15,%r12)
incq %r12
cmpq %r12, %rbx
jne 0x1ad59
movq 0x78(%rsp), %rbx
testq %rbx, %rbx
je 0x1ad97
movq 0x70(%rsp), %r15
xorl %r12d, %r12d
movsbl (%r15,%r12), %edi
callq 0x5610
movb %al, (%r15,%r12)
incq %r12
cmpq %r12, %rbx
jne 0x1ad81
movq 0x48(%rsp), %rax
addq %rax, %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
leaq 0x1b0(%rsp), %r15
movq %r12, %rax
shlq $0x5, %rax
movq %r13, 0x100(%rsp)
movq 0x50(%rsp,%rax), %rsi
movq 0x58(%rsp,%rax), %rdx
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0x112ce
xorps %xmm0, %xmm0
movaps %xmm0, 0x190(%rsp)
movq $0x0, 0x1a0(%rsp)
movq %r14, 0x228(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
leaq 0x228(%rsp), %rdi
callq 0x112ce
leaq 0x1c0(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x112ce
leaq 0x228(%rsp), %rsi
movq %r15, %rdx
leaq 0x190(%rsp), %rcx
callq 0x13f5e
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
je 0x1ae79
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x228(%rsp), %rdi
movq %r14, %rbx
cmpq %r14, %rdi
je 0x1ae99
movq 0x238(%rsp), %rsi
incq %rsi
callq 0x5340
movq %r13, %r14
movq 0x20(%rsp), %rax
decq %rax
je 0x1af17
movq 0x10(%rsp), %rax
addq %r12, %rax
leaq (%rax,%rax,2), %rax
leaq 0x250(%rsp), %rcx
leaq (%rcx,%rax,8), %r13
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x190(%rsp), %rax
leaq (%rax,%rbp), %rsi
cmpq $0x1, 0x8(%rax,%rbp)
jne 0x1aee7
movq 0x18(%rsp), %rax
movb (%rax,%r15), %al
movq (%rsi), %rcx
cmpb (%rcx), %al
je 0x1aefe
movl 0x4(%rsp), %eax
addl %r15d, %eax
movslq %eax, %rdi
shlq $0x5, %rdi
addq (%r13), %rdi
callq 0x51c0
incq %r15
movq 0x20(%rsp), %rax
decq %rax
addq $0x20, %rbp
cmpq %r15, %rax
ja 0x1aec3
movl %r15d, %r13d
jmp 0x1af1d
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq %r15, %rax
jne 0x1b3d9
movq 0x190(%rsp), %rax
movq %r15, %rbp
shlq $0x5, %rbp
leaq 0x130(%rsp), %rcx
movq %rcx, 0x120(%rsp)
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
addq %rsi, %rdx
leaq 0x120(%rsp), %rdi
callq 0x112ce
movq 0x128(%rsp), %rax
testq %rax, %rax
je 0x1afba
cmpq $0x1, %rax
jne 0x1b000
movq 0x18(%rsp), %rax
movb (%rax,%r15), %al
movq 0x190(%rsp), %rcx
movq (%rcx,%rbp), %rcx
cmpb (%rcx), %al
je 0x1b0fd
movq 0x10(%rsp), %rax
addq %r12, %rax
leaq (%rax,%rax,2), %rax
leaq 0x250(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
movslq 0x4(%rsp), %rax
movslq %r13d, %rdi
addq %rax, %rdi
jmp 0x1b0e9
movq 0x10(%rsp), %rax
addq %r12, %rax
leaq (%rax,%rax,2), %rax
movslq 0x4(%rsp), %rcx
movslq %r13d, %rdx
addq %rcx, %rdx
leaq 0x250(%rsp), %rcx
movq (%rcx,%rax,8), %rax
shlq $0x5, %rdx
leaq (%rax,%rdx), %rdi
movq 0x8(%rax,%rdx), %rdx
xorl %esi, %esi
leaq 0x165cf(%rip), %rcx     # 0x315c2
xorl %r8d, %r8d
callq 0x54b0
jmp 0x1b0fd
movq 0x120(%rsp), %rax
movb (%rax), %al
movq 0x18(%rsp), %rcx
movslq 0x4(%rsp), %rdi
movslq %r13d, %r13
addq %r13, %rdi
cmpb (%rcx,%r15), %al
jne 0x1b0c7
movq 0x10(%rsp), %rax
addq %r12, %rax
leaq (%rax,%rax,2), %rax
leaq 0x250(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
shlq $0x5, %rdi
addq (%r15), %rdi
leaq 0x16a0c(%rip), %rsi     # 0x31a56
callq 0x50e0
testl %eax, %eax
je 0x1b0e1
movq 0x128(%rsp), %rcx
decq %rcx
movl $0x1, %edx
leaq 0x1d0(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x5360
movslq 0x4(%rsp), %rdi
addq %r13, %rdi
shlq $0x5, %rdi
addq (%r15), %rdi
movq 0x1d0(%rsp), %rsi
movq 0x1d8(%rsp), %rdx
callq 0x50f0
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x1b0fd
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1b0fd
movq 0x10(%rsp), %rax
addq %r12, %rax
leaq (%rax,%rax,2), %rax
leaq 0x250(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
jmp 0x1b0e9
movslq 0x4(%rsp), %rdi
addq %r13, %rdi
shlq $0x5, %rdi
addq (%r15), %rdi
leaq 0x120(%rsp), %rsi
callq 0x51c0
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x1b122
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x190(%rsp), %rdi
callq 0xe7ca
movq 0x100(%rsp), %rdi
movq %r14, %r13
cmpq %r14, %rdi
leaq 0x1b0(%rsp), %r15
je 0x1b157
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x1(%r12), %rax
testq %r12, %r12
movq %rax, %r12
movq %rbx, %r14
je 0x1adaf
movq $-0x40, %rbx
leaq 0x80(%rsp), %r15
leaq 0x98(%rsp), %r12
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1b196
movq (%r15), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %r15
addq $0x20, %rbx
jne 0x1b182
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1b1bc
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0xb8(%rsp), %rdi
callq 0xe7ca
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
movq 0x48(%rsp), %rbx
je 0x1b1f3
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5340
leaq (%rbx,%rbx,2), %rdi
shlq $0x4, %rdi
leaq 0x2b0(%rsp), %rax
addq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x294fc
movl 0xf0(%rsp,%rbx,8), %ecx
movl %ecx, (%rax)
movl 0xf4(%rsp,%rbx,8), %ecx
movl %ecx, 0x4(%rax)
leaq 0x1(%rbx), %rax
testq %rbx, %rbx
movq %rax, %rbx
je 0x1ab62
movl $0x16, %edx
movq 0x20d91(%rip), %rdi     # 0x3bfd0
leaq 0x165a8(%rip), %rsi     # 0x317ee
callq 0x53a0
movl 0x4(%rsp), %esi
movq 0x20d7a(%rip), %rdi     # 0x3bfd0
callq 0x55a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
leaq 0x248(%rsp), %rsi
callq 0x1b6f0
movq 0x178(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x2e600
movq %rax, %rdi
movq 0x178(%rsp), %rbx
movq %rbx, %rsi
callq 0x5070
incq 0x10(%rbx)
movq 0x3b0(%rsp), %rdi
testq %rdi, %rdi
je 0x1b2db
movq 0x3c0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movl $0x140, %ebx            # imm = 0x140
leaq (%rsp,%rbx), %rax
addq $0x248, %rax            # imm = 0x248
movq -0x10(%rax), %rdi
cmpq %rdi, %rax
je 0x1b2fe
movq (%rax), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %rbx
cmpq $0xc0, %rbx
jne 0x1b2e0
movl $0x98, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0x2a5c6
addq $-0x30, %rbx
cmpq $0x38, %rbx
jne 0x1b310
movl $0x50, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0xe7ca
addq $-0x18, %rbx
cmpq $-0x10, %rbx
jne 0x1b32f
movq 0x8(%rsp), %rdx
incq %rdx
movq 0x160(%rsp), %rax
subq 0x158(%rsp), %rax
sarq $0x3, %rax
movq %rdx, 0x8(%rsp)
cmpq %rdx, %rax
ja 0x1aafc
movq 0x40(%rsp), %rdx
incq %rdx
movq 0x148(%rsp), %rax
subq 0x140(%rsp), %rax
sarq $0x3, %rax
movq %rdx, 0x40(%rsp)
cmpq %rdx, %rax
ja 0x1aadd
movl $0x30, %ebx
movq 0x128(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x1b3bf
movq 0x138(%rsp,%rbx), %rsi
subq %rdi, %rsi
callq 0x5340
addq $-0x18, %rbx
jne 0x1b3a2
movb $0x1, %al
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16231(%rip), %rdi     # 0x31611
leaq 0x1623e(%rip), %rsi     # 0x31625
leaq 0x16367(%rip), %rcx     # 0x31755
movl $0x845, %edx            # imm = 0x845
callq 0x5230
jmp 0x1b43b
jmp 0x1b43b
jmp 0x1b43b
jmp 0x1b410
jmp 0x1b45d
jmp 0x1b45d
jmp 0x1b410
jmp 0x1b455
jmp 0x1b45d
jmp 0x1b45d
jmp 0x1b45d
jmp 0x1b45d
movq %rax, %r12
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1b460
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1b460
movq %rax, %r12
jmp 0x1b4a9
movq %rax, %r12
jmp 0x1b4b1
movq %rax, %r12
jmp 0x1b6c0
jmp 0x1b455
movq %rax, %r12
jmp 0x1b610
movq %rax, %r12
jmp 0x1b603
movq %rax, %r12
jmp 0x1b635
movq %rax, %r12
movq $-0x40, %rbx
leaq 0xc0(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1b483
movq (%r15), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %r15
addq $0x20, %rbx
jne 0x1b46f
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1b4a9
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5340
movq %rbp, %rdi
callq 0xe7ca
movq 0x250(%rsp), %rdi
cmpq %r13, %rdi
je 0x1b6c0
movq 0x260(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1b6c0
jmp 0x1b585
movq %rax, %r12
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x1b50b
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1b50b
jmp 0x1b508
movq %rax, %r12
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x1b58d
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1b58d
jmp 0x1b58a
movq %rax, %r12
movq 0x1b0(%rsp), %rdi
leaq 0x1c0(%rsp), %rax
cmpq %rax, %rdi
je 0x1b566
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1b566
movq %rax, %r12
jmp 0x1b590
movq %rax, %r12
movq 0x228(%rsp), %rdi
cmpq %r14, %rdi
je 0x1b590
movq 0x238(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1b590
movq %rax, %r12
jmp 0x1b5ba
movq %rax, %r12
movq %r14, %r13
leaq 0x190(%rsp), %rdi
callq 0xe7ca
movq 0x100(%rsp), %rdi
cmpq %r13, %rdi
je 0x1b5ba
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5340
movq $-0x40, %rbx
leaq 0x80(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1b5dd
movq (%r15), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %r15
addq $0x20, %rbx
jne 0x1b5c9
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1b603
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0xb8(%rsp), %rdi
callq 0xe7ca
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1b635
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x3b0(%rsp), %rdi
testq %rdi, %rdi
je 0x1b652
movq 0x3c0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movl $0x140, %ebx            # imm = 0x140
leaq (%rsp,%rbx), %rax
addq $0x248, %rax            # imm = 0x248
movq -0x10(%rax), %rdi
cmpq %rdi, %rax
je 0x1b675
movq (%rax), %rsi
incq %rsi
callq 0x5340
addq $-0x20, %rbx
cmpq $0xc0, %rbx
jne 0x1b657
movl $0x98, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0x2a5c6
addq $-0x30, %rbx
cmpq $0x38, %rbx
jne 0x1b687
movl $0x50, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x248, %rdi            # imm = 0x248
callq 0xe7ca
addq $-0x18, %rbx
cmpq $-0x10, %rbx
jne 0x1b6a6
movl $0x30, %ebx
movq 0x128(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x1b6e2
movq 0x138(%rsp,%rbx), %rsi
subq %rdi, %rsi
callq 0x5340
addq $-0x18, %rbx
jne 0x1b6c5
movq %r12, %rdi
callq 0x55c0