// File: /workspace/github_cpp_makefile_star2_O1/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 0x27398
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 0x112ce
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x112ce
leaq 0x28(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x112ce
leaq 0x38(%rsp), %rdx
leaq 0x18(%rsp), %r8
movq %rbx, %rdi
movl %r13d, %ecx
callq 0x27a6c
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2735e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x27375
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5340
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x279e5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x279e5
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 0x112ce
movq %rbx, %rdi
movq %r15, %rsi
callq 0x26d3e
leaq 0x1e0(%rbx), %r12
movl %eax, 0x4c(%rbx)
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x273e5
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5340
leaq 0x1e4(%rbx), %r15
movl (%r12), %eax
cmpl $-0x1, %eax
je 0x27409
movq 0x1f8(%rbx), %rsi
cmpq 0x200(%rbx), %rsi
je 0x2743b
movl %eax, (%rsi)
jmp 0x27477
leaq 0x1f0(%rbx), %r12
movl $0x0, 0xc(%rsp)
movq 0x1f8(%rbx), %rsi
cmpq 0x200(%rbx), %rsi
je 0x2744c
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x1f8(%rbx)
jmp 0x27459
leaq 0x1f0(%rbx), %rdi
movq %r12, %rdx
callq 0x2f290
jmp 0x27482
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x2afe6
movl $0x1, 0xc(%rsp)
movq 0x1f8(%rbx), %rsi
cmpq 0x200(%rbx), %rsi
je 0x274e8
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x1f8(%rbx)
leaq 0x1e8(%rbx), %r12
movl (%r15), %eax
cmpl $-0x1, %eax
je 0x274a5
movq 0x210(%rbx), %rsi
cmpq 0x218(%rbx), %rsi
je 0x274d7
movl %eax, (%rsi)
jmp 0x27522
leaq 0x208(%rbx), %r15
movl $0x0, 0xc(%rsp)
movq 0x210(%rbx), %rsi
cmpq 0x218(%rbx), %rsi
je 0x274f7
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x210(%rbx)
jmp 0x27504
leaq 0x208(%rbx), %rdi
movq %r15, %rdx
callq 0x2f290
jmp 0x2752d
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x2afe6
jmp 0x27482
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2afe6
movl $0x1, 0xc(%rsp)
movq 0x210(%rbx), %rsi
cmpq 0x218(%rbx), %rsi
je 0x27598
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x210(%rbx)
movl (%r12), %eax
cmpl $-0x1, %eax
movq %rbp, 0x10(%rsp)
je 0x27552
movq 0x228(%rbx), %rsi
cmpq 0x230(%rbx), %rsi
je 0x27584
movl %eax, (%rsi)
jmp 0x2760e
leaq 0x220(%rbx), %r15
movl $0x0, 0xc(%rsp)
movq 0x228(%rbx), %rsi
cmpq 0x230(%rbx), %rsi
je 0x275a7
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x228(%rbx)
jmp 0x275b4
leaq 0x220(%rbx), %rdi
movq %r12, %rdx
callq 0x2f290
jmp 0x27619
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2afe6
jmp 0x2752d
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2afe6
movl $0x1, 0xc(%rsp)
movq 0x228(%rbx), %rsi
cmpq 0x230(%rbx), %rsi
je 0x275df
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x228(%rbx)
jmp 0x275ec
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
callq 0x2afe6
movl $0x2, 0xc(%rsp)
movq 0x228(%rbx), %rsi
cmpq 0x230(%rbx), %rsi
je 0x279f7
movl $0x2, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x228(%rbx)
movq 0x1f8(%rbx), %rax
cmpq 0x1f0(%rbx), %rax
je 0x2770d
leaq 0x238(%rbx), %r15
xorl %r13d, %r13d
leaq 0xc(%rsp), %r12
movq 0x210(%rbx), %rax
cmpq 0x208(%rbx), %rax
je 0x276ef
xorl %ebp, %ebp
movq 0x220(%rbx), %rax
cmpq %rax, 0x228(%rbx)
je 0x276d1
xorl %r14d, %r14d
movl (%rax,%r13,4), %ecx
movq 0x208(%rbx), %rdx
movl (%rdx,%rbp,4), %edx
movl (%rax,%r14,4), %eax
andl $0x1, %ecx
andl $0x1, %edx
leal (%rdx,%rcx,2), %ecx
andl $0x3, %eax
leal (%rax,%rcx,4), %eax
movl %eax, 0xc(%rsp)
movq 0x240(%rbx), %rsi
cmpq 0x248(%rbx), %rsi
je 0x276a9
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x240(%rbx)
jmp 0x276b4
movq %r15, %rdi
movq %r12, %rdx
callq 0x2f290
incq %r14
movq 0x220(%rbx), %rax
movq 0x228(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x27665
incq %rbp
movq 0x210(%rbx), %rax
subq 0x208(%rbx), %rax
sarq $0x2, %rax
cmpq %rbp, %rax
ja 0x27652
incq %r13
movq 0x1f8(%rbx), %rax
subq 0x1f0(%rbx), %rax
sarq $0x2, %rax
cmpq %r13, %rax
ja 0x2763c
movq 0x148bc(%rip), %r15     # 0x3bfd0
leaq 0xa2bc(%rip), %rsi      # 0x319d7
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 0xa27d(%rip), %rsi      # 0x319e6
movl $0xb, %edx
movq %r15, %rdi
callq 0x53a0
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %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 0xa237(%rip), %rsi      # 0x319f2
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 0xa218(%rip), %rsi      # 0x31a0e
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 0xa1fb(%rip), %rsi      # 0x31a2c
movl $0xa, %edx
movq %r15, %rdi
callq 0x53a0
movl 0x48(%rbx), %esi
movq %r15, %rdi
callq 0x55a0
movq %rax, %r14
leaq 0xa1e4(%rip), %rsi      # 0x31a37
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 0xa1a5(%rip), %rsi      # 0x31a41
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 0x1422e
leaq 0xa179(%rip), %rsi      # 0x31a58
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 0x23992
leaq 0x160(%rbx), %rdi
movq 0x160(%rbx), %rsi
callq 0x2cd84
cmpl $0x0, (%rbx)
jle 0x27954
xorl %r14d, %r14d
movq 0x150(%rbx), %rax
movq (%rax,%r14,8), %rdi
movq (%rdi), %rsi
callq 0x2b686
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x27936
leaq 0x68(%rbx), %rdi
movq 0x68(%rbx), %rsi
callq 0x10ec8
movl $0x0, 0x4c(%rbx)
movq 0x250(%rbx), %rax
cmpq %rax, 0x258(%rbx)
je 0x2797f
movq %rax, 0x258(%rbx)
movl $0x0, 0x268(%rbx)
movq 0x1f0(%rbx), %rax
cmpq %rax, 0x1f8(%rbx)
je 0x279a0
movq %rax, 0x1f8(%rbx)
movq 0x208(%rbx), %rax
cmpq %rax, 0x210(%rbx)
je 0x279b7
movq %rax, 0x210(%rbx)
movq 0x220(%rbx), %rax
cmpq %rax, 0x228(%rbx)
je 0x279ce
movq %rax, 0x228(%rbx)
movq 0x238(%rbx), %rax
cmpq %rax, 0x240(%rbx)
je 0x279e5
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 0x2afe6
jmp 0x27619
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x27a28
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x27a28
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x27a4e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5340
jmp 0x27a4e
movq %rax, %rbx
movq 0x58(%rsp), %rdi
jmp 0x27a53
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x27a63
movq (%r14), %rsi
incq %rsi
callq 0x5340
movq %rbx, %rdi
callq 0x55c0
nop