// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1e8, %rsp            # imm = 0x1E8
movl %r9d, 0x11c(%rsp)
movq %r8, %r12
movq %rdx, 0x198(%rsp)
movl %esi, 0xa4(%rsp)
movq %rdi, 0x40(%rsp)
movl %ecx, 0x4(%rsp)
movq (%r8), %r14
movq 0x8(%r8), %r13
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
cmpq %r13, %r14
je 0x14ff9
movq %r13, %rax
subq %r14, %rax
sarq $0x3, %rax
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2c82b
movq %r14, %rdi
movq %r13, %rsi
callq 0x2c957
xorps %xmm0, %xmm0
movaps %xmm0, 0x180(%rsp)
movaps %xmm0, 0x170(%rsp)
movaps %xmm0, 0x160(%rsp)
movaps %xmm0, 0x1c0(%rsp)
movq $0x0, 0x1d0(%rsp)
movq 0x40(%rsp), %rbx
leaq 0x118(%rbx), %r13
leaq 0x4(%rsp), %rsi
movq %r13, %rdi
callq 0x2851c
movl 0x8(%rax), %ecx
incl %ecx
movq (%r12), %rax
movq %r12, 0x8(%rsp)
cmpq %rax, 0x8(%r12)
movq %r13, 0x190(%rsp)
je 0x151b2
movl %ecx, (%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
leaq 0xa8(%rsp), %rbx
xorl %r14d, %r14d
movl $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movq %rbx, %rbp
leaq (%rax,%r13), %rsi
cmpb $0x0, 0x4c(%rax,%r13)
movl (%rax,%r13), %r12d
leaq 0x160(%rsp), %rdi
leaq 0x178(%rsp), %rax
cmovneq %rax, %rdi
callq 0x286b0
movq 0x8(%rsp), %rbx
movq (%rbx), %rax
movl 0x18(%rsp), %ecx
addl 0x48(%rax,%r13), %ecx
movl %ecx, 0x18(%rsp)
movl 0x14(%rsp), %ecx
addl 0x44(%rax,%r13), %ecx
movl %ecx, 0x14(%rsp)
leaq 0x58(%rsp), %rcx
movq %rcx, 0x48(%rsp)
movq 0x8(%rax,%r13), %rsi
movq 0x10(%rax,%r13), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x1123c
movq (%rbx), %rax
leaq (%rax,%r13), %rsi
addq $0x28, %rsi
movq %rbp, %rbx
movq %rbp, %rdi
callq 0x28582
movl (%rsp), %eax
cmpl %r12d, %eax
cmovgel %r12d, %eax
movl %eax, (%rsp)
movl 0x50(%rsp), %eax
leal (%r12,%rax), %ecx
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
leal -0x1(%r12,%rax), %eax
movl %r12d, 0x20(%rsp)
movl %eax, 0x24(%rsp)
leaq 0x1c0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2d6fe
movq %rbx, %rdi
callq 0xe71c
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x1516c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5340
incq %r14
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rdx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rdx, %rcx
addq $0x58, %r13
cmpq %r14, %rcx
ja 0x15089
incl %r15d
movq 0x40(%rsp), %rbx
movq 0x190(%rsp), %r13
movl (%rsp), %ecx
jmp 0x151c5
xorl %r15d, %r15d
movl $0x0, 0x14(%rsp)
movl $0x0, 0x18(%rsp)
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
movl %eax, (%rsp)
leaq 0x4(%rsp), %rsi
movq %r13, %rdi
callq 0x2851c
movl 0x8(%rax), %ecx
cmpl %ecx, %r15d
cmovll %r15d, %ecx
movq 0x160(%rsp), %r12
movq 0x168(%rsp), %rax
subq %r12, %rax
je 0x154d1
movq 0x178(%rsp), %rsi
movq 0x180(%rsp), %rdi
subq %rsi, %rdi
je 0x154d1
cmpq $0x58, %rax
movl %ecx, 0x118(%rsp)
jne 0x1535d
cmpq $0x58, %rdi
movq 0x8(%rsp), %r15
jne 0x1536c
movq %r12, %rdi
callq 0x28ab8
movq 0x160(%rsp), %r12
testb %al, %al
je 0x154e5
movl (%r12), %eax
leaq 0x50(%rsp), %rdi
movl %eax, -0x8(%rdi)
leaq 0x60(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
callq 0x1123c
leaq 0x70(%rsp), %rdi
leaq 0x28(%r12), %rsi
callq 0x28582
movq 0x50(%r12), %rax
movq %rax, 0x98(%rsp)
movups 0x40(%r12), %xmm0
movups %xmm0, 0x88(%rsp)
leaq 0xb8(%rbx), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2851c
leaq 0x150(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x140(%rsp), %rdi
callq 0x1123c
leaq 0x1c310(%rip), %rsi     # 0x315f1
leaq 0x140(%rsp), %rdi
callq 0x5630
movl 0x48(%rsp), %r15d
incl %r15d
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r14d
cmpl $0xa, %ebp
jb 0x15b02
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0x15af9
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x15aff
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x15b02
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x1531b
addl $-0x3, %r14d
jmp 0x15b02
cmpq $0x58, %rdi
movq 0x8(%rsp), %r15
jne 0x154e5
xorl %eax, %eax
cmpq $0x58, %rdi
setne %al
leaq (%rax,%rax,2), %rax
movq 0x160(%rsp,%rax,8), %r14
movq 0x168(%rsp,%rax,8), %rcx
movq %rcx, %rdx
subq %r14, %rdx
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %rsi, %rdx
cmpq $0x5, %rdx
jb 0x154e5
movq %rdi, 0x1e0(%rsp)
cmpq %r14, %rcx
je 0x15495
leaq (%rsp,%rax,8), %rbx
addq $0x160, %rbx            # imm = 0x160
xorl %r15d, %r15d
movl $0x28, %r12d
movl $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movl -0x28(%r14,%r12), %eax
movl %eax, 0x48(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq -0x20(%r14,%r12), %rsi
movq -0x18(%r14,%r12), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x1123c
leaq (%r14,%r12), %rsi
leaq 0x70(%rsp), %r13
movq %r13, %rdi
callq 0x28582
movq 0x28(%r14,%r12), %rax
leaq 0x50(%rsp), %rcx
movq %rax, 0x48(%rcx)
movups 0x18(%r14,%r12), %xmm0
movups %xmm0, 0x38(%rcx)
movl 0x10(%rsp), %eax
addl 0x8c(%rsp), %eax
movl %eax, 0x10(%rsp)
addl 0x90(%rsp), %ebp
movq %r13, %rdi
callq 0xe71c
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x15467
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5340
incq %r15
movq (%rbx), %r14
movq 0x8(%rbx), %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
addq $0x58, %r12
cmpq %r15, %rax
ja 0x153da
jmp 0x1549f
xorl %ebp, %ebp
movl $0x0, 0x10(%rsp)
xorl %eax, %eax
cmpq $0x58, 0x1e0(%rsp)
sete %al
leaq (%rax,%rax,2), %rax
movq 0x160(%rsp,%rax,8), %rax
movl 0x44(%rax), %ecx
movl 0x48(%rax), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0x10(%rsp), %ebx
cmpl %ebp, %ebx
cmovgl %ebx, %ebp
cmpl %ebp, %eax
jle 0x154d8
xorl %ebx, %ebx
jmp 0x15aa8
movq 0x160(%rsp), %r12
movq 0x8(%rsp), %r15
leaq 0x178(%rsp), %rbx
leaq 0x160(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x2b1a0
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x2b1a0
xorl %eax, %eax
movq %rax, 0xa8(%rsp)
movl %eax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movl %eax, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
movq (%r15), %rbp
movq 0x8(%r15), %rax
movq %rax, %rcx
subq %rbp, %rcx
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rdx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rdx, %rcx
cmpq $0x5, %rcx
jbe 0x15654
cmpq %rbp, %rax
je 0x15696
movl 0x14(%rsp), %eax
addl %eax, 0x18(%rsp)
leaq 0x50(%rsp), %r14
leaq 0x70(%rsp), %rbx
movl $0x28, %r12d
xorl %r13d, %r13d
movl -0x28(%rbp,%r12), %eax
movl %eax, 0x48(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq -0x20(%rbp,%r12), %rsi
movq -0x18(%rbp,%r12), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x1123c
leaq (%r12,%rbp), %rsi
movq %rbx, %rdi
callq 0x28582
movq 0x28(%rbp,%r12), %rax
movq %rax, 0x48(%r14)
movups 0x18(%rbp,%r12), %xmm0
movups %xmm0, 0x38(%r14)
movl 0x8c(%rsp), %eax
movl 0x90(%rsp), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0x18(%rsp), %ecx
subl %eax, %ecx
xorl %esi, %esi
cmpl %ecx, %eax
setle %sil
leaq 0xa8(%rsp), %rdi
callq 0x28ca4
movq %rbx, %r15
movq %rbx, %rdi
callq 0xe71c
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
movq 0x8(%rsp), %rbx
je 0x15623
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5340
incq %r13
movq (%rbx), %rbp
movq 0x8(%rbx), %rax
subq %rbp, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
addq $0x58, %r12
cmpq %r13, %rax
movq %r15, %rbx
ja 0x15581
jmp 0x15696
cmpq %rbp, %rax
je 0x15696
xorl %ebx, %ebx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x28ca4
movq 0x8(%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 0x15663
leaq 0x4(%rsp), %rsi
movq 0x190(%rsp), %rdi
callq 0x2851c
movl (%rsp), %ecx
decl %ecx
movl %ecx, %edx
movl %ecx, (%rsp)
movl 0x118(%rsp), %esi
subl %ecx, %esi
movslq %esi, %rcx
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x5360
leaq 0x128(%rsp), %r12
movq 0x50(%rsp), %rbx
testq %rbx, %rbx
movq 0x40(%rsp), %r13
movq 0x8(%rsp), %rbp
je 0x15705
movq 0x48(%rsp), %r14
xorl %r15d, %r15d
movsbl (%r14,%r15), %edi
callq 0x5610
movb %al, (%r14,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x156ef
leaq 0x120(%rsp), %r14
movb $0x1, %bl
movl $0x30, %edi
callq 0x5330
movq %rax, %rcx
addq $0x8, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, (%r14)
movq %r12, %r14
testb $0x1, %bl
movl $0x0, %ebx
jne 0x1570f
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
cmpq %rax, %rcx
je 0x157cc
xorl %r15d, %r15d
leaq 0x20(%rsp), %r14
xorl %r12d, %r12d
movq 0xa8(%rsp), %rdx
movl %r12d, %esi
shrl $0x6, %esi
movq (%rdx,%rsi,8), %rdx
btq %r12, %rdx
jae 0x157a8
movl (%rax,%r15), %ecx
subl (%rsp), %ecx
movzbl 0x4c(%rax,%r15), %eax
movq 0x120(%rsp,%rax,8), %rdi
movl %ecx, 0x20(%rsp)
movl %r12d, 0x24(%rsp)
movq %r14, %rsi
callq 0x2dbd6
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
incq %r12
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %rsi, %rdx
addq $0x58, %r15
cmpq %r12, %rdx
ja 0x15762
leaq 0x20(%rsp), %rdi
leaq 0x1c0(%rsp), %rdx
movq %r13, %rsi
callq 0x28cf2
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
xorl %r15d, %r15d
leaq 0xf8(%rsp), %rbp
movl 0x4(%rax,%r15,8), %edx
subl (%rsp), %edx
movl %edx, 0xf8(%rsp)
movq 0xd8(%rsp), %rsi
cmpq 0xe0(%rsp), %rsi
je 0x1583d
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xd8(%rsp)
jmp 0x15857
leaq 0xd0(%rsp), %rdi
movq %rbp, %rdx
callq 0x2aaf6
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
incq %r15
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
ja 0x1580c
movq 0xd8(%rsp), %rsi
movslq -0x4(%rsi), %rcx
movq 0x50(%rsp), %rax
leaq -0x1(%rax), %rdx
cmpq %rcx, %rdx
leaq 0x128(%rsp), %r14
jbe 0x158c3
decl %eax
movl %eax, 0xf8(%rsp)
cmpq 0xe0(%rsp), %rsi
je 0x158ae
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xd8(%rsp)
jmp 0x158c3
leaq 0xd0(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x2aaf6
movq 0x1f0(%r13), %rdx
movq 0x1f8(%r13), %rsi
cmpq %rdx, %rsi
je 0x15a04
movq 0x208(%r13), %rax
movq 0x210(%r13), %rcx
xorl %r9d, %r9d
leaq 0x48(%rsp), %rbp
movq %rcx, %rdi
movq 0x40(%rsp), %r15
cmpq %rax, %rdi
je 0x159eb
movq %r9, 0x18(%rsp)
movl (%rdx,%r9,4), %r12d
movq 0x220(%r13), %rdx
movq 0x228(%r13), %rsi
xorl %r13d, %r13d
cmpq %rdx, %rsi
je 0x159ad
movl (%rax,%r13,4), %r14d
xorl %ebx, %ebx
movl (%rdx,%rbx,4), %eax
movl 0x4(%rsp), %r10d
subq $0x8, %rsp
movq %r15, %rdi
movl 0x124(%rsp), %esi
movl 0xac(%rsp), %edx
movq 0x10(%rsp), %rcx
movq %rbp, %r8
movl 0x8(%rsp), %r9d
pushq 0x1a0(%rsp)
pushq %rax
pushq %r14
pushq %r12
pushq %r10
leaq 0x100(%rsp), %rax
pushq %rax
leaq 0x158(%rsp), %rax
pushq %rax
callq 0x163ee
addq $0x40, %rsp
incq %rbx
movq 0x220(%r15), %rdx
movq 0x228(%r15), %rsi
movq %rsi, %rax
subq %rdx, %rax
sarq $0x2, %rax
cmpq %rbx, %rax
ja 0x1592a
movq 0x208(%r15), %rax
movq 0x210(%r15), %rcx
jmp 0x159b0
movq %rdx, %rsi
incq %r13
movq %rcx, %rdi
subq %rax, %rdi
sarq $0x2, %rdi
cmpq %r13, %rdi
ja 0x1591b
movq 0x40(%rsp), %r13
movq 0x1f0(%r13), %rdx
movq 0x1f8(%r13), %rsi
movq %rcx, %rdi
leaq 0x128(%rsp), %r14
movq 0x18(%rsp), %r9
jmp 0x159ee
movq %rax, %rdi
incq %r9
movq %rsi, %r8
subq %rdx, %r8
sarq $0x2, %r8
cmpq %r9, %r8
ja 0x158f8
leaq 0x120(%rsp), %rax
movb $0x1, %bpl
movq (%rax), %rbx
testq %rbx, %rbx
je 0x15a1f
movq %rbx, %rdi
callq 0x29a0e
movl $0x30, %esi
movq %rbx, %rdi
callq 0x5340
movq %r14, %rax
testb $0x1, %bpl
movl $0x0, %ebp
jne 0x15a0f
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x15a57
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x15a6e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15a89
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x15aa6
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movb $0x1, %bl
movq 0x1c0(%rsp), %rdi
testq %rdi, %rdi
je 0x15ac5
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movl $0x18, %r14d
leaq (%rsp,%r14), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x284ec
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x15acb
movl %ebx, %eax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl $-0x2, %r14d
jmp 0x15b02
decl %r14d
shrl $0x1f, %r15d
leal (%r14,%r15), %esi
leaq 0x1b0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1a0(%rsp), %rdi
movl $0x2d, %edx
callq 0x53b0
movl %r15d, %edi
addq 0x1a0(%rsp), %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0xe33a
movq 0x140(%rsp), %rcx
movq 0x148(%rsp), %r8
movq 0x1a8(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r12, %rcx
je 0x15b6b
movq 0x150(%rsp), %rdi
movq 0x1a0(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x15b8f
movl $0xf, %edi
cmpq %r13, %rsi
je 0x15b8a
movq 0x1b0(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x15b9e
leaq 0x140(%rsp), %rdi
callq 0x50f0
jmp 0x15baf
leaq 0x1a0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x108(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x15bdc
movq %rsi, 0xf8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x108(%rsp)
jmp 0x15be2
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x100(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x1b9e8(%rip), %rsi     # 0x315f1
leaq 0xf8(%rsp), %rdi
callq 0x5630
leaq 0x130(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15c46
movq %rdx, 0x120(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x130(%rsp)
jmp 0x15c4d
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq %r12, %r15
movq 0x8(%rax), %rdx
leaq 0x120(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x50f0
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15caf
movq %rdx, 0xd0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xe0(%rsp)
jmp 0x15cb7
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0xd0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1b914(%rip), %rsi     # 0x315f1
callq 0x5630
leaq 0x30(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15d09
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x15d10
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
leaq 0x20(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x70(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x50f0
leaq 0xb8(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15d6d
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0x15d73
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0xb0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x15da5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x15dc2
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x120(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ddf
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x108(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15e00
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x1a0(%rsp), %rdi
cmpq %r13, %rdi
je 0x15e1d
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x140(%rsp), %rdi
cmpq %r15, %rdi
movq 0x40(%rsp), %rbx
je 0x15e3f
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x5340
cmpb $0x1, 0x89(%rsp)
jne 0x15e91
movq 0x70(%rsp), %rdx
addq $0x20, %rdx
leaq 0x1b79a(%rip), %rsi     # 0x315f3
leaq 0x20(%rsp), %rdi
callq 0xce20
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
callq 0x50f0
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x15e91
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x1b75d(%rip), %rsi     # 0x315f5
leaq 0xa8(%rsp), %rdi
callq 0x5630
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16328
movl %eax, %ebp
movq 0x238(%rbx), %rax
cmpq %rax, 0x240(%rbx)
je 0x15fc4
movslq 0xa4(%rsp), %r13
movslq 0x198(%rsp), %r15
xorl %r14d, %r14d
movslq (%rax,%r14,4), %r12
movq 0x178(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r12,8), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x10c62
movq 0x180(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0x16013
incl (%rax,%r12,4)
movq 0x188(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0x16013
incl (%rax,%r12,4)
movq 0x190(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0x16013
addl %ebp, (%rax,%r12,4)
movq 0x198(%rbx), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r15,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0x16013
addl %ebp, (%rax,%r12,4)
incq %r14
movq 0x238(%rbx), %rax
movq 0x240(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x15edf
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x15fe9
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x70(%rsp), %rdi
callq 0xe71c
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x15aa6
movq 0x60(%rsp), %rsi
incq %rsi
jmp 0x15aa1
leaq 0x1bada(%rip), %rdi     # 0x31af4
movq %r12, %rsi
xorl %eax, %eax
callq 0x5490
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x161df
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x161df
jmp 0x161dc
jmp 0x161dc
jmp 0x161dc
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x16075
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x16075
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x16097
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x16097
movq %rax, %rbx
movq 0x120(%rsp), %rdi
cmpq %r14, %rdi
je 0x160bc
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x160bc
movq %r12, %r15
movq %rax, %rbx
leaq 0x108(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x160e5
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x160e5
movq %r12, %r15
movq %rax, %rbx
movq 0x1a0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1610a
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x1610a
movq %r12, %r15
movq %rax, %rbx
movq 0x140(%rsp), %rdi
cmpq %r15, %rdi
je 0x16204
movq 0x150(%rsp), %rsi
jmp 0x161fc
movq %rax, %rbx
movq 0x140(%rsp), %rdi
cmpq %r12, %rdi
jne 0x1611b
jmp 0x16204
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
jne 0x1618a
jmp 0x162e2
jmp 0x1621a
jmp 0x1625c
movq %rax, %rbx
jmp 0x16204
jmp 0x16213
jmp 0x161cd
jmp 0x161dc
jmp 0x1621a
jmp 0x1621a
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x162e2
movq 0x60(%rsp), %rsi
jmp 0x1624f
jmp 0x1621a
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x286da
jmp 0x162ae
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x162ae
movq 0x60(%rsp), %rsi
jmp 0x162a6
jmp 0x161cd
movq %rax, %rbx
jmp 0x162ae
jmp 0x1625c
jmp 0x16213
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x16204
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x48(%rsp), %rdi
callq 0x286da
jmp 0x162e2
movq %rax, %rbx
jmp 0x16293
jmp 0x1621a
movq %rax, %rbx
jmp 0x162e2
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xe71c
jmp 0x16237
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x162e2
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x162e2
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x1627c
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x16293
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x162ae
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x162e2
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movq $0x0, 0xa8(%rsp)
movl $0x0, 0xb0(%rsp)
movq 0x1c0(%rsp), %rdi
testq %rdi, %rdi
je 0x162ff
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x5340
movl $0x18, %r14d
leaq (%rsp,%r14), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x284ec
addq $-0x18, %r14
cmpq $-0x18, %r14
jne 0x16305
movq %rbx, %rdi
callq 0x55c0
nop