// File: /workspace/github_cpp_makefile_star2_O1/medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::MatchVariantListInThread(int, int, int, std::vector<DiploidVariant, std::allocator<DiploidVariant>>&, int)
bool WholeGenome::MatchVariantListInThread(int thread_index, 
    int threshold_index,
    int chr_id,
    vector<DiploidVariant> & variant_list,
    int cluster_id){
    //===================================================
    sort(variant_list.begin(), variant_list.end());
    // decide reference sequence
    vector<DiploidVariant> separate_var_list[2];
    vector<Interval> intervals;
    // separate into ref and que
    int total_mil = 0;
    int total_mdl = 0;
    int min_pos = genome_sequences[chr_id].length() + 1;
    int max_pos = -1;
    for (int i = 0; i < variant_list.size(); i++) {
        int flag = 0;
        if (variant_list[i].flag) flag = 1; // flag indicate if the variant is from ref set(0) or query set(1)
        int pos = variant_list[i].pos;
        separate_var_list[flag].push_back(variant_list[i]);
        total_mil += variant_list[i].mil;
        total_mdl += variant_list[i].mdl;
        auto ref_sequence = variant_list[i].ref;
        auto alt_sequences = variant_list[i].alts;
        min_pos = min(pos, min_pos);
        max_pos = max((int)(pos + ref_sequence.length()), max_pos);

        int end_pos = pos + ref_sequence.length() - 1; // included end position!!
        intervals.push_back(Interval(pos, end_pos));
    }
    min_pos = max(min_pos - 1, 0);
    max_pos = min(max_pos + 1, (int)genome_sequences[chr_id].length()); //exclusive

    if (separate_var_list[0].size() == 0 || separate_var_list[1].size() == 0) {
        //dout << separate_var_list[0].size() << ", " << separate_var_list[1].size() << endl;
        return false;
    }
    if (separate_var_list[0].size() == 1 && separate_var_list[1].size() == 1){
        // try direct match to save time
        if(separate_var_list[0][0] == separate_var_list[1][0]){

            DiploidVariant tv = separate_var_list[0][0];
            string match_record = chrname_by_chrid[chr_id] + "\t" + to_string(tv.pos+1) + "\t" + tv.ref + "\t" + tv.alts[0];
            if(tv.multi_alts) match_record += "/" + tv.alts[1];
            match_record += "\t.\t.\t.\t.\t.\n";
            // here we need to push back for all mode_index
            //complex_match_records[thread_index]->push_back(match_record);

            int edit_distance = CalculateEditDistance(tv, 0, 0);
            for(int mi = 0; mi < mode_index_list.size(); mi ++){
                int mode_i = mode_index_list[mi];
                //if(mi == 0){
                

                // this line should be recovered
                match_records_by_mode_by_thread[thread_index][mode_i]->push_back(match_record);
                
                //}else{
                //    match_records_by_mode_by_thread[thread_index][mode_i]->push_back("$"+to_string(match_records_by_mode_by_thread[thread_index][0]->size()));
                    // use dollor to represent that it is the same
                //}
                baseline_total_match_num[thread_index][threshold_index]->at(mode_i)++;
                query_total_match_num[thread_index][threshold_index]->at(mode_i)++;

                baseline_total_edit_distance[thread_index][threshold_index]->at(mode_i) +=  edit_distance;
                query_total_edit_distance[thread_index][threshold_index]->at(mode_i) += edit_distance;
                //calculate the edit distance
            }
            // output match result
            return true;
        }
        // if not match, still can match by changing genome
    }else if(separate_var_list[0].size() == 1 || separate_var_list[1].size() == 1){
        int flag = 0;
        if(separate_var_list[1].size() == 1) flag = 1;
        int r_flag = 1-flag;
        if(separate_var_list[r_flag].size() > 4){
            int total_r_mdl = 0;
            int total_r_mil = 0;

            for(int k = 0; k < separate_var_list[r_flag].size(); k++){
                DiploidVariant var = separate_var_list[r_flag][k];
                int var_mdl = var.mdl;
                int var_mil = var.mil;
                int ref_length = var.ref.length();
                total_r_mdl += var_mdl;
                total_r_mil += var_mil;
            }

            if(max(separate_var_list[flag][0].mdl, separate_var_list[flag][0].mil) > max(total_r_mdl, total_r_mil)) return false;
        }
    }

    separate_var_list[0].clear();
    separate_var_list[1].clear();
    // remove singular variant
    // [todo] try removing this filter to see running time changes
    vector<bool> appliable_flag;
    int total_change = total_mil+total_mdl;

    if(variant_list.size() > EASY_MATCH_VAR_NUM){
        for(int k = 0; k < variant_list.size(); k++){
            DiploidVariant cur_var = variant_list[k];
            int max_change = max(cur_var.mil, cur_var.mdl);
            if(max_change > total_change-max_change){
                appliable_flag.push_back(false);
                //dout << "this variant is removed" << endl;
            }else{
                appliable_flag.push_back(true);
            }
        }
    }else{
        for(int k = 0; k < variant_list.size(); k++){
            appliable_flag.push_back(true);
        }
    }

    string subsequence = genome_sequences[chr_id].substr(min_pos, max_pos - min_pos);

    ToUpper(subsequence); // subsequence only contains upper char
    int offset = min_pos;
    int subsequence_length = max_pos - min_pos;

    // have subsequence in hand
    //generate decision point
    multimap<int, int> * choices_by_pos[2];
    // choice by pos is to also equal to var by pos
    for(int i = 0; i < 2; i++){
        choices_by_pos[i] = new multimap<int, int>();
    }

    for(int index = 0; index < variant_list.size(); index++){
        if(!appliable_flag[index]) continue;
        // remove decision point if not applicable
        int pos = variant_list[index].pos - offset;
        int flag = 0;
        if(variant_list[index].flag) flag = 1;
        choices_by_pos[flag]->insert(pair<int, int>(pos, index));
        //dout << pos << index << endl;
    }

    vector<Interval> mergered_intervals = merge(intervals);
//    unordered_map<int, bool> sync_points;
//    for(int i = 0; i < mergered_intervals.size(); i++){
//        sync_points[mergered_intervals[i].end-offset] = true;
//    }
    vector<int> sync_points;
    for(int i = 0; i < mergered_intervals.size(); i++){
        sync_points.push_back(mergered_intervals[i].end-offset);
    }

    if(sync_points.back() < subsequence.size() - 1){
        sync_points.push_back(subsequence.size()-1);
    }

    int score_unit;
    int match_mode;
    int score_scheme;

    for(int i = 0; i < score_unit_list.size(); i++){
        score_unit = score_unit_list[i];
        for(int j = 0; j < match_mode_list.size(); j++){
            match_mode = match_mode_list[j];
            for(int k = 0; k < score_scheme_list.size(); k++){
                score_scheme = score_scheme_list[k];

                bool method2 = MatchingSingleClusterBaseExtending(
                                            cluster_id,
                                            thread_index,
                                            variant_list,
                                            subsequence,
                                            offset,
                                            choices_by_pos,
                                            sync_points,
                                            chr_id,
                                            score_unit,
                                            match_mode,
                                            score_scheme,
                                            threshold_index);
            }
        }
    }

    for(int i = 0; i < 2; i++){
        delete choices_by_pos[i];
    }
    //delete choices_by_pos;

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movl %r9d, 0x12c(%rsp)
movq %r8, %rbx
movq %rdx, 0x1c8(%rsp)
movl %esi, 0xdc(%rsp)
movq %rdi, 0x18(%rsp)
movl %ecx, 0x4(%rsp)
movq (%r8), %r14
movq 0x8(%r8), %r13
movabsq $0x2e8ba2e8ba2e8ba3, %r15 # imm = 0x2E8BA2E8BA2E8BA3
cmpq %r13, %r14
je 0x15133
movq %r13, %rax
subq %r14, %rax
sarq $0x3, %rax
imulq %r15, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2cdcd
movq %r14, %rdi
movq %r13, %rsi
callq 0x2cef9
xorps %xmm0, %xmm0
movaps %xmm0, 0x1b0(%rsp)
movaps %xmm0, 0x1a0(%rsp)
movaps %xmm0, 0x190(%rsp)
movaps %xmm0, 0x1d0(%rsp)
movq $0x0, 0x1e0(%rsp)
movq 0x18(%rsp), %r13
leaq 0x118(%r13), %rdi
leaq 0x4(%rsp), %rsi
movq %rdi, 0x1c0(%rsp)
callq 0x28988
movl 0x8(%rax), %r12d
incl %r12d
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
movq %rbx, 0x28(%rsp)
je 0x152dc
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorl %r14d, %r14d
movl $0x0, 0x8(%rsp)
movl $0x0, 0x20(%rsp)
leaq (%rax,%r13), %rsi
cmpb $0x0, 0x4c(%rax,%r13)
movl (%rax,%r13), %r15d
leaq 0x190(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmovneq %rax, %rdi
callq 0x28b1a
movq 0x28(%rsp), %rbx
movq (%rbx), %rax
movl 0x8(%rsp), %ecx
addl 0x48(%rax,%r13), %ecx
movl %ecx, 0x8(%rsp)
movl 0x20(%rsp), %ecx
addl 0x44(%rax,%r13), %ecx
movl %ecx, 0x20(%rsp)
leaq 0x90(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movq 0x8(%rax,%r13), %rsi
movq 0x10(%rax,%r13), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x112ce
movq (%rbx), %rax
leaq (%rax,%r13), %rsi
addq $0x28, %rsi
leaq 0x38(%rsp), %rdi
callq 0x289ec
cmpl %r15d, %r12d
cmovgel %r15d, %r12d
movl 0x88(%rsp), %eax
leal (%r15,%rax), %ecx
cmpl %ebp, %ecx
cmovgl %ecx, %ebp
leal -0x1(%r15,%rax), %eax
movl %r15d, 0x60(%rsp)
movl %eax, 0x64(%rsp)
leaq 0x1d0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x2dbb8
leaq 0x38(%rsp), %rdi
callq 0xe7ca
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
movabsq $0x2e8ba2e8ba2e8ba3, %r15 # imm = 0x2E8BA2E8BA2E8BA3
je 0x152ac
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x5340
incq %r14
movq 0x28(%rsp), %rbx
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r15, %rcx
addq $0x58, %r13
cmpq %r14, %rcx
ja 0x151b4
incl %ebp
movq 0x18(%rsp), %r13
jmp 0x152ee
xorl %ebp, %ebp
movl $0x0, 0x20(%rsp)
movl $0x0, 0x8(%rsp)
cmpl $0x2, %r12d
movl $0x1, %eax
cmovgel %r12d, %eax
movl %eax, (%rsp)
leaq 0x4(%rsp), %rsi
movq 0x1c0(%rsp), %rdi
callq 0x28988
movl 0x8(%rax), %r14d
cmpl %r14d, %ebp
cmovll %ebp, %r14d
movq 0x190(%rsp), %rdi
movq 0x198(%rsp), %rax
subq %rdi, %rax
je 0x15642
movq 0x1a8(%rsp), %rsi
movq 0x1b0(%rsp), %r8
subq %rsi, %r8
je 0x15642
movq %rax, %rcx
xorq $0x58, %rcx
movq %r8, %rdx
xorq $0x58, %rdx
orq %rcx, %rdx
jne 0x15488
callq 0x28f46
testb %al, %al
je 0x15649
movq 0x190(%rsp), %rbx
movl (%rbx), %eax
leaq 0x88(%rsp), %rdi
movl %eax, -0x8(%rdi)
leaq 0x98(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
callq 0x112ce
leaq 0xa8(%rsp), %rdi
leaq 0x28(%rbx), %rsi
callq 0x289ec
movq 0x50(%rbx), %rax
movq %rax, 0xd0(%rsp)
movups 0x40(%rbx), %xmm0
movups %xmm0, 0xc0(%rsp)
leaq 0xb8(%r13), %rdi
leaq 0x4(%rsp), %rsi
callq 0x28988
leaq 0x160(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x150(%rsp), %rdi
callq 0x112ce
leaq 0x1c1bb(%rip), %rsi     # 0x315c1
leaq 0x150(%rsp), %rdi
callq 0x5630
movl 0x80(%rsp), %r15d
incl %r15d
movl %r15d, %r14d
negl %r14d
cmovsl %r15d, %r14d
movl $0x1, %r12d
cmpl $0xa, %r14d
jb 0x15c09
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0x15c00
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x15c06
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x15c09
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x15446
addl $-0x3, %r12d
jmp 0x15c09
cmpq $0x58, %rax
setne %al
cmpq $0x58, %r8
setne %cl
testb %cl, %al
jne 0x15649
xorl %eax, %eax
cmpq $0x58, %r8
setne %al
leaq (%rax,%rax,2), %rax
movq 0x198(%rsp,%rax,8), %rcx
subq 0x190(%rsp,%rax,8), %rcx
sarq $0x3, %rcx
imulq %r15, %rcx
cmpq $0x5, %rcx
jb 0x15649
movq %r8, 0x1f0(%rsp)
movl %r14d, 0x34(%rsp)
leaq (%rsp,%rax,8), %rbx
addq $0x190, %rbx            # imm = 0x190
movq (%rbx), %r12
cmpq %r12, 0x8(%rbx)
je 0x155e8
xorl %r15d, %r15d
movl $0x28, %ebp
movl $0x0, 0x14(%rsp)
movl $0x0, 0x18(%rsp)
movl -0x28(%r12,%rbp), %eax
movl %eax, 0x80(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq -0x20(%r12,%rbp), %rsi
movq -0x18(%r12,%rbp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x112ce
leaq (%r12,%rbp), %rsi
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0x289ec
movq 0x28(%r12,%rbp), %rax
leaq 0x88(%rsp), %rcx
movq %rax, 0x48(%rcx)
movups 0x18(%r12,%rbp), %xmm0
movups %xmm0, 0x38(%rcx)
movl 0x14(%rsp), %eax
addl 0xc4(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x18(%rsp), %eax
addl 0xc8(%rsp), %eax
movl %eax, 0x18(%rsp)
movq %r14, %rdi
callq 0xe7ca
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x155ba
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5340
incq %r15
movq (%rbx), %r12
movq 0x8(%rbx), %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
addq $0x58, %rbp
cmpq %r15, %rax
ja 0x1550a
jmp 0x155f8
movl $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
xorl %eax, %eax
cmpq $0x58, 0x1f0(%rsp)
sete %al
leaq (%rax,%rax,2), %rax
movq 0x190(%rsp,%rax,8), %rax
movl 0x44(%rax), %ecx
movl 0x48(%rax), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0x18(%rsp), %ecx
movl 0x14(%rsp), %ebx
cmpl %ecx, %ebx
cmovgl %ebx, %ecx
cmpl %ecx, %eax
movq 0x28(%rsp), %rbx
movabsq $0x2e8ba2e8ba2e8ba3, %r15 # imm = 0x2E8BA2E8BA2E8BA3
movl 0x34(%rsp), %r14d
jle 0x15649
xorl %ebx, %ebx
jmp 0x16131
movl %r14d, 0x34(%rsp)
leaq 0x1a8(%rsp), %r14
movq -0x18(%r14), %rsi
leaq 0x190(%rsp), %r12
movq %r12, %rdi
callq 0x2b686
movq 0x18(%r12), %rsi
movq %r14, %rdi
callq 0x2b686
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movl %eax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movq (%rbx), %r12
movq 0x8(%rbx), %rax
movq %rax, %rcx
subq %r12, %rcx
sarq $0x3, %rcx
imulq %r15, %rcx
cmpq $0x5, %rcx
jbe 0x157bb
cmpq %r12, %rax
je 0x157fa
movl 0x20(%rsp), %eax
addl %eax, 0x8(%rsp)
leaq 0x88(%rsp), %rbx
movl $0x28, %r15d
xorl %ebp, %ebp
movl -0x28(%r12,%r15), %eax
movl %eax, 0x80(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq -0x20(%r12,%r15), %rsi
movq -0x18(%r12,%r15), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x112ce
leaq (%r12,%r15), %rsi
leaq 0xa8(%rsp), %rdi
callq 0x289ec
movq 0x28(%r12,%r15), %rax
movq %rax, 0x48(%rbx)
movups 0x18(%r12,%r15), %xmm0
movq %rbx, %r14
movups %xmm0, 0x38(%rbx)
movl 0xc4(%rsp), %eax
movl 0xc8(%rsp), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0x8(%rsp), %ecx
subl %eax, %ecx
xorl %esi, %esi
cmpl %ecx, %eax
setle %sil
leaq 0x38(%rsp), %rdi
callq 0x29118
leaq 0xa8(%rsp), %rdi
callq 0xe7ca
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
movq 0x28(%rsp), %rbx
je 0x1578a
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5340
incq %rbp
movq (%rbx), %r12
movq 0x8(%rbx), %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
addq $0x58, %r15
cmpq %rbp, %rax
movq %r14, %rbx
ja 0x156d0
jmp 0x157fa
cmpq %r12, %rax
je 0x157fa
xorl %ebx, %ebx
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x29118
movq 0x28(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
incq %rbx
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
cmpq %rbx, %rax
ja 0x157c7
leaq 0x4(%rsp), %rsi
movq 0x1c0(%rsp), %rdi
callq 0x28988
movl (%rsp), %ecx
decl %ecx
movl %ecx, %edx
movl %ecx, (%rsp)
movl 0x34(%rsp), %esi
subl %ecx, %esi
movslq %esi, %rcx
leaq 0x80(%rsp), %rdi
movq %rax, %rsi
callq 0x5360
movq 0x88(%rsp), %rbx
testq %rbx, %rbx
movq 0x28(%rsp), %r12
je 0x15862
movq 0x80(%rsp), %r14
xorl %r15d, %r15d
movsbl (%r14,%r15), %edi
callq 0x5610
movb %al, (%r14,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x1584c
xorl %ebx, %ebx
movl $0x30, %edi
callq 0x5330
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x170(%rsp,%rbx,8)
incq %rbx
cmpq $0x1, %rbx
je 0x15864
movq (%r12), %rax
cmpq %rax, 0x8(%r12)
je 0x1591e
xorl %r15d, %r15d
leaq 0x60(%rsp), %r14
xorl %ebx, %ebx
movq 0x38(%rsp), %rcx
movq %rbx, %rdx
shrq $0x6, %rdx
movq (%rcx,%rdx,8), %rcx
btq %rbx, %rcx
jae 0x158f4
movl (%rax,%r15), %ecx
subl (%rsp), %ecx
movzbl 0x4c(%rax,%r15), %eax
movq 0x170(%rsp,%rax,8), %rdi
movl %ecx, 0x60(%rsp)
movl %ebx, 0x64(%rsp)
movq %r14, %rsi
callq 0x2e088
incq %rbx
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rdx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rdx, %rcx
addq $0x58, %r15
cmpq %rbx, %rcx
ja 0x158b9
leaq 0x60(%rsp), %rdi
leaq 0x1d0(%rsp), %rdx
movq %r13, %rsi
callq 0x29166
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movq $0x0, 0xf0(%rsp)
movq 0x60(%rsp), %rax
cmpq %rax, 0x68(%rsp)
je 0x159bc
xorl %ebx, %ebx
leaq 0xe0(%rsp), %r15
leaq 0x108(%rsp), %r14
movl 0x4(%rax,%rbx,8), %eax
subl (%rsp), %eax
movl %eax, 0x108(%rsp)
movq 0xe8(%rsp), %rsi
cmpq 0xf0(%rsp), %rsi
je 0x15998
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe8(%rsp)
jmp 0x159a3
movq %r15, %rdi
movq %r14, %rdx
callq 0x2afe6
incq %rbx
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
ja 0x15968
movq 0xe8(%rsp), %rsi
movslq -0x4(%rsi), %rcx
movq 0x88(%rsp), %rax
leaq -0x1(%rax), %rdx
cmpq %rcx, %rdx
jbe 0x15a11
decl %eax
movl %eax, 0x108(%rsp)
cmpq 0xf0(%rsp), %rsi
je 0x159fc
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe8(%rsp)
jmp 0x15a11
leaq 0xe0(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x2afe6
movq 0x1f0(%r13), %rax
cmpq %rax, 0x1f8(%r13)
je 0x15b44
movq $0x0, 0x20(%rsp)
leaq 0x170(%rsp), %r15
leaq 0x80(%rsp), %r14
movq 0x208(%r13), %rcx
cmpq %rcx, 0x210(%r13)
je 0x15b19
movq 0x20(%rsp), %rdx
movl (%rax,%rdx,4), %r12d
movq $0x0, 0x8(%rsp)
movq 0x220(%r13), %rax
cmpq %rax, 0x228(%r13)
movq %r13, %rbp
je 0x15aeb
movq 0x8(%rsp), %rdx
movl (%rcx,%rdx,4), %ebx
xorl %r13d, %r13d
movl (%rax,%r13,4), %eax
movl 0x4(%rsp), %r10d
subq $0x8, %rsp
movq %rbp, %rdi
movl 0x134(%rsp), %esi
movl 0xe4(%rsp), %edx
movq 0x30(%rsp), %rcx
movq %r14, %r8
movl 0x8(%rsp), %r9d
pushq 0x1d0(%rsp)
pushq %rax
pushq %rbx
pushq %r12
pushq %r10
leaq 0x110(%rsp), %rax
pushq %rax
pushq %r15
callq 0x16582
addq $0x40, %rsp
incq %r13
movq 0x220(%rbp), %rax
movq 0x228(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
ja 0x15a82
movq 0x8(%rsp), %rsi
incq %rsi
movq 0x208(%rbp), %rcx
movq 0x210(%rbp), %rax
subq %rcx, %rax
sarq $0x2, %rax
movq %rsi, 0x8(%rsp)
cmpq %rsi, %rax
movq %rbp, %r13
ja 0x15a64
movq 0x20(%rsp), %rsi
incq %rsi
movq 0x1f0(%r13), %rax
movq 0x1f8(%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq %rsi, 0x20(%rsp)
cmpq %rsi, %rcx
ja 0x15a3e
xorl %r14d, %r14d
movq 0x170(%rsp,%r14,8), %rbx
testq %rbx, %rbx
je 0x15b69
movq %rbx, %rdi
callq 0x29ea4
movl $0x30, %esi
movq %rbx, %rdi
callq 0x5340
incq %r14
cmpq $0x1, %r14
je 0x15b47
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x15b8f
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15ba6
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15bc7
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1612f
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movl %eax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
jmp 0x1612f
addl $-0x2, %r12d
jmp 0x15c09
decl %r12d
shrl $0x1f, %r15d
leal (%r12,%r15), %esi
leaq 0x140(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x130(%rsp), %rdi
movl $0x2d, %edx
callq 0x53b0
movl %r15d, %edi
addq 0x130(%rsp), %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0xe3b6
movq 0x150(%rsp), %rcx
movq 0x158(%rsp), %r8
movq 0x138(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0x15c73
movq 0x160(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x15c9c
movl $0xf, %esi
leaq 0x140(%rsp), %rdi
cmpq %rdi, 0x130(%rsp)
je 0x15c97
movq 0x140(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x15cb3
movq 0x130(%rsp), %rsi
leaq 0x150(%rsp), %rdi
callq 0x50f0
jmp 0x15cc4
leaq 0x130(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x118(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x15cf1
movq %rsi, 0x108(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x118(%rsp)
jmp 0x15cf7
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x110(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x1b8a3(%rip), %rsi     # 0x315c1
leaq 0x108(%rsp), %rdi
callq 0x5630
leaq 0x180(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15d5b
movq %rdx, 0x170(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x180(%rsp)
jmp 0x15d62
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq %r13, %r15
movq 0x8(%rax), %rdx
leaq 0x170(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x50f0
leaq 0xf0(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15dc9
movq %rdx, 0xe0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf0(%rsp)
jmp 0x15dd1
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0xe0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1b7ca(%rip), %rsi     # 0x315c1
callq 0x5630
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15e24
movq %rdx, 0x60(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x70(%rsp)
jmp 0x15e2c
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x60(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xa8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x50f0
leaq 0x48(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15e83
movq %rdx, 0x38(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x48(%rsp)
jmp 0x15e89
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x40(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x15eb8
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0xe0(%rsp), %rdi
cmpq %r13, %rdi
je 0x15ed5
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x170(%rsp), %rdi
cmpq %r14, %rdi
movq 0x18(%rsp), %rbx
je 0x15ef7
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15f18
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0x15f3d
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x150(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f5a
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x5340
cmpb $0x1, 0xc1(%rsp)
jne 0x15fac
movq 0xa8(%rsp), %rdx
addq $0x20, %rdx
leaq 0x1b64c(%rip), %rsi     # 0x315c3
leaq 0x60(%rsp), %rdi
callq 0xce96
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq 0x38(%rsp), %rdi
callq 0x50f0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x15fac
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x1b612(%rip), %rsi     # 0x315c5
leaq 0x38(%rsp), %rdi
callq 0x5630
leaq 0x80(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x164bc
movl %eax, %r12d
movq 0x238(%rbx), %rax
cmpq %rax, 0x240(%rbx)
je 0x160e1
movslq 0xdc(%rsp), %rbp
movslq 0x1c8(%rsp), %r15
xorl %r14d, %r14d
movslq (%rax,%r14,4), %r13
movq 0x178(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r13,8), %rdi
leaq 0x38(%rsp), %rsi
callq 0x10ca6
movq 0x180(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x16182
incl (%rax,%r13,4)
movq 0x188(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x16182
incl (%rax,%r13,4)
movq 0x190(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x16182
addl %r12d, (%rax,%r13,4)
movq 0x198(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x16182
addl %r12d, (%rax,%r13,4)
incq %r14
movq 0x238(%rbx), %rax
movq 0x240(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x15ffb
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x160fd
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0xa8(%rsp), %rdi
callq 0xe7ca
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x1612f
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5340
movb $0x1, %bl
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x1614e
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movl $0x18, %r14d
leaq (%rsp,%r14), %rdi
addq $0x190, %rdi            # imm = 0x190
callq 0x28958
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x16154
movl %ebx, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b93b(%rip), %rdi     # 0x31ac4
movq %r13, %rsi
xorl %eax, %eax
callq 0x5490
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x1636e
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1636e
jmp 0x1636b
jmp 0x163ee
jmp 0x1636b
jmp 0x1636b
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x161e9
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x161e9
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1620b
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1620b
movq %rax, %rbx
movq 0x170(%rsp), %rdi
cmpq %r14, %rdi
je 0x16230
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x16230
movq %r13, %r15
movq %rax, %rbx
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16259
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x16259
movq %r13, %r15
movq %rax, %rbx
movq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %rax
cmpq %rax, %rdi
je 0x16286
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x16286
movq %r13, %r15
movq %rax, %rbx
movq 0x150(%rsp), %rdi
cmpq %r15, %rdi
je 0x1638a
movq 0x160(%rsp), %rsi
jmp 0x16382
movq %rax, %rbx
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
jne 0x16297
jmp 0x1638a
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
jne 0x162fe
jmp 0x16476
jmp 0x163a6
movq %rax, %rbx
jmp 0x1638a
jmp 0x1639c
jmp 0x16361
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x16476
movq 0x98(%rsp), %rsi
jmp 0x163e1
jmp 0x163a6
jmp 0x163a6
jmp 0x163a6
jmp 0x1636b
jmp 0x163ee
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x28b44
jmp 0x16446
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x16446
movq 0x98(%rsp), %rsi
jmp 0x1643e
jmp 0x16361
movq %rax, %rbx
jmp 0x16446
jmp 0x1639c
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1638a
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x80(%rsp), %rdi
callq 0x28b44
jmp 0x16476
movq %rax, %rbx
jmp 0x16425
jmp 0x163a6
movq %rax, %rbx
jmp 0x16476
movq %rax, %rbx
jmp 0x163c0
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xe7ca
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x16476
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x16476
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x1640e
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x16425
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16446
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x16476
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movl %eax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x16493
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movl $0x18, %r14d
leaq (%rsp,%r14), %rdi
addq $0x190, %rdi            # imm = 0x190
callq 0x28958
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x16499
movq %rbx, %rdi
callq 0x55c0
nop