// File: medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::DirectMatch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void WholeGenome::DirectMatch(string ref_vcf, string query_vcf, int match_mode_, string output_prefix)
{
    //dout << "direct match" << endl;
    match_mode_indicator = match_mode_;
    //int ref_variant_num = ReadReferenceVariants(ref_vcf);
    int que_variant_num = ReadQueryVariants(query_vcf);
    //dout << que_variant_num << endl;
    int match_num = 0;
    ofstream output_stat_file;
    output_stat_file.open(output_dir + "/" + output_prefix+".direct");
    for(int i = 0; i < chrom_num; i++){
        if(ref_variant_by_chrid[i]->size() == 0 || que_variant_by_chrid[i]->size() == 0)
            continue;
        //[TODO] not the right way to do it, at least need multimap
        multimap<int, int> ref_variant_by_pos;
        for(int j = 0; j < ref_variant_by_chrid[i]->size(); j++){
            DiploidVariant var = ref_variant_by_chrid[i]->at(j);
            int pos = var.pos;
            ref_variant_by_pos.insert(pair<int, int>(pos, j));
        }

        for(int j = 0; j < que_variant_by_chrid[i]->size(); j++){
            DiploidVariant var = que_variant_by_chrid[i]->at(j);
            int pos = var.pos;
            if(ref_variant_by_pos.find(pos) == ref_variant_by_pos.end())
                continue;

            pair<multimap<int, int>::iterator, multimap<int, int>::iterator> var_range;
            var_range = ref_variant_by_pos.equal_range(pos);

            for(auto it = var_range.first; it != var_range.second; ++it){
                int ref_index = (*it).second;
                DiploidVariant ref_var = ref_variant_by_chrid[i]->at(ref_index);
                if (match_mode_indicator != 1 && var == ref_var){
                    match_num ++;
                    string matched_variant = chrname_by_chrid[i] + "\t" + to_string(ref_var.pos) + "\t" + ref_var.ref + "\t";
                    output_stat_file << matched_variant << endl;
                    break;
                }else if(match_mode_indicator == 1 && var.CompareNoGenotype(ref_var)){
                    match_num ++;
                    break;
                }
            }
        }
    }
    output_stat_file.close();
    dout << "matched variants: " << match_num << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5e0, %rsp            # imm = 0x5E0
movq %rdx, -0x560(%rbp)
movq %rsi, %rax
movq -0x560(%rbp), %rsi
movq %r8, -0x558(%rbp)
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x550(%rbp)
movl -0x1c(%rbp), %ecx
movl %ecx, 0x1e4(%rax)
leaq -0x50(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x61b0
movq -0x550(%rbp), %rdi
movq -0x548(%rbp), %rsi
callq 0x30cc0
movl %eax, -0x53c(%rbp)
jmp 0x31965
leaq -0x50(%rbp), %rdi
callq 0x6828
movl -0x53c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x60(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x6710
movq -0x550(%rbp), %rsi
addq $0x1c0, %rsi            # imm = 0x1C0
leaq 0x23c00(%rip), %rdx     # 0x5559f
leaq -0x2c0(%rbp), %rdi
callq 0xe200
jmp 0x319ad
movq -0x558(%rbp), %rdx
leaq -0x2a0(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0xe1b0
jmp 0x319c9
leaq 0x24079(%rip), %rdx     # 0x55a49
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0xb0f0
jmp 0x319e5
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
movl $0x10, %edx
callq 0x6200
jmp 0x319ff
leaq -0x280(%rbp), %rdi
callq 0x6828
leaq -0x2a0(%rbp), %rdi
callq 0x6828
leaq -0x2c0(%rbp), %rdi
callq 0x6828
movl $0x0, -0x2c4(%rbp)
movq -0x550(%rbp), %rcx
movl -0x2c4(%rbp), %eax
cmpl (%rcx), %eax
jge 0x3218b
movq -0x550(%rbp), %rax
movq 0x148(%rax), %rax
movslq -0x2c4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x335b0
cmpq $0x0, %rax
je 0x31a8e
movq -0x550(%rbp), %rax
movq 0x150(%rax), %rax
movslq -0x2c4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x335b0
cmpq $0x0, %rax
jne 0x31b0f
jmp 0x32169
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6828
jmp 0x32203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x321f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x31afe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x31af2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x6828
leaq -0x2a0(%rbp), %rdi
callq 0x6828
leaq -0x2c0(%rbp), %rdi
callq 0x6828
jmp 0x321f7
leaq -0x2f8(%rbp), %rdi
callq 0x34260
movl $0x0, -0x2fc(%rbp)
movq -0x550(%rbp), %rax
movslq -0x2fc(%rbp), %rcx
movq %rcx, -0x568(%rbp)
movq 0x148(%rax), %rax
movslq -0x2c4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x335b0
movq %rax, %rcx
movq -0x568(%rbp), %rax
cmpq %rcx, %rax
jae 0x31c47
movq -0x550(%rbp), %rax
movq 0x148(%rax), %rax
movslq -0x2c4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x2fc(%rbp), %rsi
callq 0x347f0
movq %rax, -0x570(%rbp)
jmp 0x31b92
movq -0x570(%rbp), %rsi
leaq -0x358(%rbp), %rdi
callq 0x340a0
jmp 0x31ba7
movl -0x358(%rbp), %eax
movl %eax, -0x35c(%rbp)
leaq -0x364(%rbp), %rdi
leaq -0x35c(%rbp), %rsi
leaq -0x2fc(%rbp), %rdx
callq 0x34340
jmp 0x31bcf
leaq -0x2f8(%rbp), %rdi
leaq -0x364(%rbp), %rsi
callq 0x34310
movq %rax, -0x578(%rbp)
jmp 0x31beb
movq -0x578(%rbp), %rax
movq %rax, -0x370(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x32c60
movl -0x2fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2fc(%rbp)
jmp 0x31b25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3217d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x32c60
jmp 0x3217d
movl $0x0, -0x374(%rbp)
movq -0x550(%rbp), %rax
movslq -0x374(%rbp), %rcx
movq %rcx, -0x580(%rbp)
movq 0x150(%rax), %rax
movslq -0x2c4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x335b0
movq %rax, %rcx
movq -0x580(%rbp), %rax
cmpq %rcx, %rax
jae 0x3215d
movq -0x550(%rbp), %rax
movq 0x150(%rax), %rax
movslq -0x2c4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x374(%rbp), %rsi
callq 0x347f0
movq %rax, -0x588(%rbp)
jmp 0x31cbe
movq -0x588(%rbp), %rsi
leaq -0x3d0(%rbp), %rdi
callq 0x340a0
jmp 0x31cd3
movl -0x3d0(%rbp), %eax
movl %eax, -0x3d4(%rbp)
leaq -0x2f8(%rbp), %rdi
leaq -0x3d4(%rbp), %rsi
callq 0x34900
movq %rax, -0x590(%rbp)
jmp 0x31cfb
movq -0x590(%rbp), %rax
movq %rax, -0x3e0(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x34930
movq %rax, -0x3e8(%rbp)
leaq -0x3e0(%rbp), %rdi
leaq -0x3e8(%rbp), %rsi
callq 0x33c30
testb $0x1, %al
jne 0x31d35
jmp 0x31d55
movl $0xa, -0x3ec(%rbp)
jmp 0x3211f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3214f
leaq -0x400(%rbp), %rdi
callq 0x34960
jmp 0x31d63
leaq -0x2f8(%rbp), %rdi
leaq -0x3d4(%rbp), %rsi
callq 0x34990
movq %rdx, -0x5a0(%rbp)
movq %rax, -0x598(%rbp)
jmp 0x31d86
movq -0x5a0(%rbp), %rax
movq -0x598(%rbp), %rcx
movq %rcx, -0x410(%rbp)
movq %rax, -0x408(%rbp)
leaq -0x400(%rbp), %rdi
leaq -0x410(%rbp), %rsi
callq 0x349d0
movq -0x400(%rbp), %rax
movq %rax, -0x418(%rbp)
leaq -0x400(%rbp), %rsi
addq $0x8, %rsi
leaq -0x418(%rbp), %rdi
callq 0x33ac0
testb $0x1, %al
jne 0x31de3
jmp 0x32115
leaq -0x418(%rbp), %rdi
callq 0x34a00
movq %rax, %rcx
movq -0x550(%rbp), %rax
movl 0x4(%rcx), %ecx
movl %ecx, -0x41c(%rbp)
movq 0x148(%rax), %rax
movslq -0x2c4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x41c(%rbp), %rsi
callq 0x347f0
movq %rax, -0x5a8(%rbp)
jmp 0x31e29
movq -0x5a8(%rbp), %rsi
leaq -0x478(%rbp), %rdi
callq 0x340a0
jmp 0x31e3e
movq -0x550(%rbp), %rax
cmpl $0x1, 0x1e4(%rax)
je 0x32082
leaq -0x3d0(%rbp), %rdi
leaq -0x478(%rbp), %rsi
callq 0x33e50
movb %al, -0x5a9(%rbp)
jmp 0x31e6d
movb -0x5a9(%rbp), %al
testb $0x1, %al
jne 0x31e7c
jmp 0x32082
movq -0x550(%rbp), %rdi
movl -0x60(%rbp), %eax
incl %eax
movl %eax, -0x60(%rbp)
addq $0xb8, %rdi
leaq -0x2c4(%rbp), %rsi
callq 0x32770
movq %rax, -0x5b8(%rbp)
jmp 0x31ea7
movq -0x5b8(%rbp), %rsi
leaq 0x236e8(%rip), %rdx     # 0x5559d
leaq -0x518(%rbp), %rdi
callq 0xe200
jmp 0x31ec3
movl -0x478(%rbp), %esi
leaq -0x538(%rbp), %rdi
callq 0xb190
jmp 0x31ed7
leaq -0x4f8(%rbp), %rdi
leaq -0x518(%rbp), %rsi
leaq -0x538(%rbp), %rdx
callq 0xde60
jmp 0x31ef3
leaq 0x236a3(%rip), %rdx     # 0x5559d
leaq -0x4d8(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
callq 0xb0f0
jmp 0x31f0f
leaq -0x470(%rbp), %rdx
leaq -0x4b8(%rbp), %rdi
leaq -0x4d8(%rbp), %rsi
callq 0xe1b0
jmp 0x31f2b
leaq 0x2366b(%rip), %rdx     # 0x5559d
leaq -0x498(%rbp), %rdi
leaq -0x4b8(%rbp), %rsi
callq 0xb0f0
jmp 0x31f47
leaq -0x4b8(%rbp), %rdi
callq 0x6828
leaq -0x4d8(%rbp), %rdi
callq 0x6828
leaq -0x4f8(%rbp), %rdi
callq 0x6828
leaq -0x538(%rbp), %rdi
callq 0x6828
leaq -0x518(%rbp), %rdi
callq 0x6828
leaq -0x260(%rbp), %rdi
leaq -0x498(%rbp), %rsi
callq 0x63e0
movq %rax, -0x5c0(%rbp)
jmp 0x31f9f
movq -0x5c0(%rbp), %rdi
movq 0x41fd3(%rip), %rsi     # 0x73f80
callq 0x6480
jmp 0x31fb4
movl $0xb, -0x3ec(%rbp)
leaq -0x498(%rbp), %rdi
callq 0x6828
jmp 0x320da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x32107
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x32054
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x32048
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x3203c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x32030
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x4b8(%rbp), %rdi
callq 0x6828
leaq -0x4d8(%rbp), %rdi
callq 0x6828
leaq -0x4f8(%rbp), %rdi
callq 0x6828
leaq -0x538(%rbp), %rdi
callq 0x6828
leaq -0x518(%rbp), %rdi
callq 0x6828
jmp 0x32107
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x498(%rbp), %rdi
callq 0x6828
jmp 0x32107
movq -0x550(%rbp), %rax
cmpl $0x1, 0x1e4(%rax)
jne 0x320ce
leaq -0x3d0(%rbp), %rdi
leaq -0x478(%rbp), %rsi
callq 0x365a0
movb %al, -0x5c1(%rbp)
jmp 0x320ad
movb -0x5c1(%rbp), %al
testb $0x1, %al
jne 0x320b9
jmp 0x320ce
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl $0xb, -0x3ec(%rbp)
jmp 0x320da
jmp 0x320d0
movl $0x0, -0x3ec(%rbp)
leaq -0x478(%rbp), %rdi
callq 0x32c60
movl -0x3ec(%rbp), %eax
testl %eax, %eax
je 0x320f4
jmp 0x320f2
jmp 0x32115
jmp 0x320f6
leaq -0x418(%rbp), %rdi
callq 0x34a20
jmp 0x31dc3
leaq -0x478(%rbp), %rdi
callq 0x32c60
jmp 0x3214f
movl $0x0, -0x3ec(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x32c60
movl -0x3ec(%rbp), %eax
testl %eax, %eax
je 0x32139
jmp 0x32137
jmp 0x3213b
jmp 0x3213b
movl -0x374(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x374(%rbp)
jmp 0x31c51
leaq -0x3d0(%rbp), %rdi
callq 0x32c60
jmp 0x3217d
leaq -0x2f8(%rbp), %rdi
callq 0x34580
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x31a2d
leaq -0x2f8(%rbp), %rdi
callq 0x34580
jmp 0x321f7
leaq -0x260(%rbp), %rdi
callq 0x65f0
jmp 0x32199
movq 0x41e18(%rip), %rdi     # 0x73fb8
leaq 0x238aa(%rip), %rsi     # 0x55a51
callq 0x6420
movq %rax, -0x5d0(%rbp)
jmp 0x321b5
movq -0x5d0(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x6740
movq %rax, -0x5d8(%rbp)
jmp 0x321cd
movq -0x5d8(%rbp), %rdi
movq 0x41da5(%rip), %rsi     # 0x73f80
callq 0x6480
jmp 0x321e2
leaq -0x260(%rbp), %rdi
callq 0x6620
addq $0x5e0, %rsp            # imm = 0x5E0
popq %rbp
retq
leaq -0x260(%rbp), %rdi
callq 0x6620
movq -0x58(%rbp), %rdi
callq 0x6750
nopl (%rax)