// File: /workspace/github_cpp_makefile_star2_O3/medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::Compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, int, int, int)
void WholeGenome::Compare(string query_vcf,
	string output_prefix,
    bool detail_results,
    int score_unit_,
    int match_mode_,
    int score_scheme_)
{
    // initialize query variant data structure


	que_vcf_filename = query_vcf;

    this->output_prefix = output_prefix;
    this->detail_results = detail_results;

    score_unit_indicator = score_unit_;
    match_mode_indicator = match_mode_;
    score_scheme_indicator = score_scheme_;

    if(score_scheme_indicator == 3){
        DirectMatch(ref_vcf_filename, query_vcf, match_mode_, output_prefix);
        return;
    }

    query_variant_total_num = ReadQueryVariants(query_vcf);

    if(score_unit_indicator == -1){
        score_unit_list.push_back(0);
        score_unit_list.push_back(1);
    }else{
        score_unit_list.push_back(score_unit_indicator);
    }

    if(match_mode_indicator == -1){
        match_mode_list.push_back(0);
        match_mode_list.push_back(1);
    }else{
        match_mode_list.push_back(match_mode_indicator);
    }

    if(score_scheme_indicator == -1){
        score_scheme_list.push_back(0);
        score_scheme_list.push_back(1);
        score_scheme_list.push_back(2);
    }else{
        score_scheme_list.push_back(score_scheme_indicator);
    }

    for(int i = 0; i < score_unit_list.size(); i++){
        for(int j = 0; j < match_mode_list.size(); j++){
            for(int k = 0; k < score_scheme_list.size(); k++){
                int mode_index = GetIndexFromMatchScore(score_scheme_list[i], match_mode_list[j], score_scheme_list[k]);
                mode_index_list.push_back(mode_index);  // so that I can directly know how many mode, do not need to calculate all the time
            }
        }
    }

    cout << "Baseline VCF: " << ref_vcf_filename << endl;
    cout << "Query VCF: " << query_vcf << endl;
    cout << "========VCF Stat.==========" << endl;
    cout << "Total Number of VCF Entries: " << endl;
    cout << "Baseline: " << baseline_variant_total_num << "; Query: " << query_variant_total_num << endl;

    cout << "parallel clustering..." << endl;
    ParallelClustering();
    
    cout << "matching variants..." << endl;
    ClusteringMatchMultiThread();

    // most clustering results are cleared inside ParallelClustering function except the following one
    // which is needed for matching
    variants_by_cluster.clear();
    // clean at the end of function
    for(int j = 0; j < chrom_num; j++){
        que_variant_by_chrid[j]->clear();
        //delete que_variant_by_chrid[j];
    }
    //delete[] que_variant_by_chrid;

    query_variant_strings.clear();
    query_variant_total_num = 0;
    threshold_list.clear();
    threshold_num = 0;
    // The following three matching results are cleared inside ClusteringMatchMultiThread function
    // match_records_by_mode_by_thread;
    // baseline_total_match_num;
    // query_total_match_num;

    score_unit_list.clear();
    match_mode_list.clear();
    score_scheme_list.clear();
    mode_index_list.clear();

    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, %r12d
movl %r8d, %r14d
movl %ecx, %r13d
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %rbx
addq $0x28, %rdi
callq 0x51c0
leaq 0x1a0(%rbx), %rdi
movq %r15, %rsi
callq 0x51c0
movb %r13b, 0x80(%rbx)
movl %r14d, 0x1e0(%rbx)
movl %r12d, 0x1e4(%rbx)
movl 0xd0(%rsp), %eax
movl %eax, 0x1e8(%rbx)
cmpl $0x3, %eax
jne 0x26eba
movl %r12d, %r13d
leaq 0x88(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x1123c
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x1123c
leaq 0x28(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x1123c
leaq 0x38(%rsp), %rdx
leaq 0x18(%rsp), %r8
movq %rbx, %rdi
movl %r13d, %ecx
callq 0x275d8
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x26e80
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x26e97
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x27552
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x27552
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x1123c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x26860
leaq 0x1e0(%rbx), %r12
movl %eax, 0x4c(%rbx)
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x26f07
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x1e4(%rbx), %r15
movl (%r12), %eax
cmpl $-0x1, %eax
je 0x26f2b
movq 0x1f8(%rbx), %rsi
cmpq 0x200(%rbx), %rsi
je 0x26f60
movl %eax, (%rsi)
jmp 0x26f9f
leaq 0x1f0(%rbx), %r12
movl $0x0, 0xc(%rsp)
movq 0x1f8(%rbx), %rsi
movq 0x200(%rbx), %rax
cmpq %rax, %rsi
je 0x26f71
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x1f8(%rbx)
jmp 0x26f8c
leaq 0x1f0(%rbx), %rdi
movq %r12, %rdx
callq 0x2f18e
jmp 0x26faa
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x2aaf6
movq 0x1f8(%rbx), %rsi
movq 0x200(%rbx), %rax
movl $0x1, 0xc(%rsp)
cmpq %rax, %rsi
je 0x27016
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x1f8(%rbx)
leaq 0x1e8(%rbx), %r12
movl (%r15), %eax
cmpl $-0x1, %eax
je 0x26fd0
movq 0x210(%rbx), %rsi
cmpq 0x218(%rbx), %rsi
je 0x27005
movl %eax, (%rsi)
jmp 0x27053
leaq 0x208(%rbx), %r15
movl $0x0, 0xc(%rsp)
movq 0x210(%rbx), %rsi
movq 0x218(%rbx), %rax
cmpq %rax, %rsi
je 0x27025
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x210(%rbx)
jmp 0x27040
leaq 0x208(%rbx), %rdi
movq %r15, %rdx
callq 0x2f18e
jmp 0x2705e
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x2aaf6
jmp 0x26faa
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2aaf6
movq 0x210(%rbx), %rsi
movq 0x218(%rbx), %rax
movl $0x1, 0xc(%rsp)
cmpq %rax, %rsi
je 0x270c7
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x210(%rbx)
movl (%r12), %eax
cmpl $-0x1, %eax
je 0x2707e
movq 0x228(%rbx), %rsi
cmpq 0x230(%rbx), %rsi
je 0x270b3
movl %eax, (%rsi)
jmp 0x27143
leaq 0x220(%rbx), %r15
movl $0x0, 0xc(%rsp)
movq 0x228(%rbx), %rsi
movq 0x230(%rbx), %rax
cmpq %rax, %rsi
je 0x270d6
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x228(%rbx)
jmp 0x270f1
leaq 0x220(%rbx), %rdi
movq %r12, %rdx
callq 0x2f18e
jmp 0x2714e
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2aaf6
jmp 0x2705e
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2aaf6
movq 0x228(%rbx), %rsi
movq 0x230(%rbx), %rax
movl $0x1, 0xc(%rsp)
cmpq %rax, %rsi
je 0x27111
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x228(%rbx)
jmp 0x2712c
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2aaf6
movq 0x228(%rbx), %rsi
movq 0x230(%rbx), %rax
movl $0x2, 0xc(%rsp)
cmpq %rax, %rsi
je 0x27564
movl $0x2, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x228(%rbx)
movq 0x1f0(%rbx), %rcx
movq 0x1f8(%rbx), %rsi
cmpq %rcx, %rsi
je 0x2727e
leaq 0x238(%rbx), %r15
movq 0x208(%rbx), %rax
movq 0x210(%rbx), %rdx
xorl %r13d, %r13d
leaq 0xc(%rsp), %r12
movq %rdx, %rdi
movq %rbp, 0x10(%rsp)
cmpq %rax, %rdi
je 0x27265
movq 0x220(%rbx), %rcx
movq 0x228(%rbx), %rdi
movq %rdi, %rsi
xorl %ebp, %ebp
cmpq %rcx, %rsi
je 0x27234
xorl %r14d, %r14d
movl (%rcx,%r13,4), %eax
movq 0x208(%rbx), %rdx
movl (%rdx,%rbp,4), %edx
movl (%rcx,%r14,4), %esi
andl $0x1, %eax
andl $0x1, %edx
leal (%rdx,%rax,2), %eax
andl $0x3, %esi
leal (%rsi,%rax,4), %eax
movl %eax, 0xc(%rsp)
movq 0x240(%rbx), %rsi
cmpq 0x248(%rbx), %rsi
je 0x271f6
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x240(%rbx)
jmp 0x2720f
movq %r15, %rdi
movq %r12, %rdx
callq 0x2f18e
movq 0x220(%rbx), %rcx
movq 0x228(%rbx), %rdi
incq %r14
movq %rdi, %rax
subq %rcx, %rax
sarq $0x2, %rax
cmpq %r14, %rax
ja 0x271b2
movq 0x208(%rbx), %rax
movq 0x210(%rbx), %rdx
movq %rdi, %rsi
jmp 0x27237
movq %rcx, %rsi
incq %rbp
movq %rdx, %r8
subq %rax, %r8
sarq $0x2, %r8
cmpq %rbp, %r8
ja 0x271a6
movq 0x1f0(%rbx), %rcx
movq 0x1f8(%rbx), %rsi
movq %rdx, %rdi
movq 0x10(%rsp), %rbp
jmp 0x27268
movq %rax, %rdi
incq %r13
movq %rsi, %r8
subq %rcx, %r8
sarq $0x2, %r8
cmpq %r13, %r8
ja 0x2718a
movq 0x15d4b(%rip), %r15     # 0x3cfd0
leaq 0xa77b(%rip), %rsi      # 0x31a07
movl $0xe, %edx
movq %r15, %rdi
callq 0x53a0
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movq %r15, %rdi
callq 0x53a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %r12, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
leaq 0xa73c(%rip), %rsi      # 0x31a16
movl $0xb, %edx
movq %r15, %rdi
callq 0x53a0
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
movq %r15, %rdi
callq 0x53a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
leaq 0xa6fa(%rip), %rsi      # 0x31a22
movl $0x1b, %edx
movq %r15, %rdi
callq 0x53a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
leaq 0xa6db(%rip), %rsi      # 0x31a3e
movl $0x1d, %edx
movq %r15, %rdi
callq 0x53a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
leaq 0xa6be(%rip), %rsi      # 0x31a5c
movl $0xa, %edx
movq %r15, %rdi
callq 0x53a0
movl 0x48(%rbx), %esi
movq %r15, %rdi
callq 0x55a0
movq %rax, %r14
leaq 0xa6a7(%rip), %rsi      # 0x31a67
movl $0x9, %edx
movq %rax, %rdi
callq 0x53a0
movl 0x4c(%rbx), %esi
movq %r14, %rdi
callq 0x55a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
leaq 0xa668(%rip), %rsi      # 0x31a71
movl $0x16, %edx
movq %r15, %rdi
callq 0x53a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
movq %rbx, %rdi
callq 0x14182
leaq 0xa63c(%rip), %rsi      # 0x31a88
movl $0x14, %edx
movq %r15, %rdi
callq 0x53a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5310
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5240
movq %rbx, %rdi
callq 0x234b4
leaq 0x160(%rbx), %rdi
movq 0x160(%rbx), %rsi
callq 0x2c7e2
cmpl $0x0, (%rbx)
jle 0x274c1
xorl %r14d, %r14d
movq 0x150(%rbx), %rax
movq (%rax,%r14,8), %rdi
movq (%rdi), %rsi
callq 0x2b1a0
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x274a3
leaq 0x68(%rbx), %rdi
movq 0x68(%rbx), %rsi
callq 0x10e4c
movl $0x0, 0x4c(%rbx)
movq 0x250(%rbx), %rax
cmpq %rax, 0x258(%rbx)
je 0x274ec
movq %rax, 0x258(%rbx)
movl $0x0, 0x268(%rbx)
movq 0x1f0(%rbx), %rax
cmpq %rax, 0x1f8(%rbx)
je 0x2750d
movq %rax, 0x1f8(%rbx)
movq 0x208(%rbx), %rax
cmpq %rax, 0x210(%rbx)
je 0x27524
movq %rax, 0x210(%rbx)
movq 0x220(%rbx), %rax
cmpq %rax, 0x228(%rbx)
je 0x2753b
movq %rax, 0x228(%rbx)
movq 0x238(%rbx), %rax
cmpq %rax, 0x240(%rbx)
je 0x27552
movq %rax, 0x240(%rbx)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2aaf6
jmp 0x2714e
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x27595
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x27595
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x275bb
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x275bb
movq %rax, %rbx
movq 0x58(%rsp), %rdi
jmp 0x275c0
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x275d0
movq (%r14), %rsi
incq %rsi
callq 0x5340
movq %rbx, %rdi
callq 0x55c0