// File: /workspace/github_cpp_makefile_star2_O2/medvedevgroup[P]varmatch/src/wholegenome.cpp
// Function: WholeGenome::ConstructMatchRecordBackup(SequencePath&, std::vector<DiploidVariant, std::allocator<DiploidVariant>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, int, int, int, int, int)
void WholeGenome::ConstructMatchRecordBackup(SequencePath & best_path,
                                       vector<DiploidVariant> & variant_list,
                                       string & subsequence,
                                       int offset,
                                       int thread_index,
                                       int chr_id,
                                       int mode_index,
                                       int threshold_index){
    int truth_num = 0;
    int predict_num = 0;

    bool need_match_record = false;

    if (threshold_index == 0) need_match_record = true;

    bool multiple_match = false;

    if(best_path.donor_sequences[0] != best_path.donor_sequences[1]) multiple_match = true;

    string parsimonious_ref = subsequence;
    string parsimonious_alt0 = best_path.donor_sequences[0];
    string parsimonious_alt1 = best_path.donor_sequences[1];

    int parsimonious_pos = offset;
//    NormalizeVariantSequence(offset,
//                             parsimonious_ref,
//                             parsimonious_alt0,
//                             parsimonious_alt1,
//                             chr_id);

    string match_record = chrname_by_chrid[chr_id] + "\t" + to_string(parsimonious_pos+1) + "\t" + parsimonious_ref + "\t" + parsimonious_alt0;
    if(multiple_match) match_record += "/" + parsimonious_alt1;

    string vcf_record[2];
    string phasing_record[2];

	for (int i = 0; i < 2; i++) {
		for (auto it = best_path.choice_made[i].begin(); it != best_path.choice_made[i].end(); ++it) {
            pair<int, int> selection = it->second;
            int phasing = selection.second;
            if(selection.first == -1) continue;
            DiploidVariant variant = variant_list[selection.first];
            if(!variant.flag){
                truth_num++;
            }else{
                predict_num++;
            }

            if(need_match_record){
                string alt_string = variant.alts[0];
                if(variant.multi_alts){
                    alt_string += "/" + variant.alts[1];
                }
                string phasing_string = "";
                if(phasing == 0){
                    phasing_string += "1";
                    if(variant.heterozygous){
                        if(variant.multi_alts && !variant.zero_one_var){
                            phasing_string += "|2";
                        }else{
                            phasing_string += "|0";
                        }
                    }else{
                        phasing_string += "|1";
                    }
                }else if(phasing == 1){
                    if(variant.multi_alts && !variant.zero_one_var){
                        phasing_string += "2|1";
                    }else if(variant.multi_alts && variant.zero_one_var){
                        phasing_string += "2|0";
                    }else{
                        phasing_string += "0|1";
                    }
                }else if(phasing == -1){
                    phasing_string += "0|1";
                }else if(phasing == -2){
                    phasing_string += "0|2";
                }
                string variant_record = to_string(variant.pos+1) + "," + variant.ref + "," + alt_string;
                vcf_record[i] += variant_record;
                phasing_record[i] += phasing_string;
                vcf_record[i] += ";";
                phasing_record[i] += ";";
            }
		}
        if(need_match_record){
            vcf_record[i] = vcf_record[i].substr(0, vcf_record[i].size()-1);
            phasing_record[i] = phasing_record[i].substr(0, phasing_record[i].size()-1);
        }

	}

    if(need_match_record){
    	match_record += "\t" + vcf_record[0] + "\t" + vcf_record[1];
        match_record += "\t" + phasing_record[0] + "\t" + phasing_record[1];
    	match_record += "\t" + to_string(best_path.score) + "\n";

    	//complex_match_records[thread_index]->push_back(match_record);
    	
        // this line should be recovered


        match_records_by_mode_by_thread[thread_index][mode_index]->push_back(match_record);
    

    }

    baseline_total_match_num[thread_index][threshold_index]->at(mode_index) += truth_num;
    query_total_match_num[thread_index][threshold_index]->at(mode_index) += predict_num;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movl %r9d, 0xc(%rsp)
movl %r8d, %ebp
movq %rcx, %r15
movq %rdx, 0xe0(%rsp)
movq %rdi, 0x50(%rsp)
leaq 0xd0(%rsi), %r12
movq %rsi, 0xc8(%rsp)
leaq 0xf0(%rsi), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0xa908
movl %eax, %ebx
leaq 0x1f8(%rsp), %rdi
movq %r15, %rsi
callq 0x53f0
leaq 0x1d8(%rsp), %rdi
movq %r12, %rsi
callq 0x53f0
leaq 0x1b8(%rsp), %rdi
movq %r14, %rsi
callq 0x53f0
movq 0x50(%rsp), %rax
leaq 0xb8(%rax), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x19a5a
leaq 0xcf75(%rip), %rdx      # 0x225a9
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x96b0
incl %ebp
leaq 0xf0(%rsp), %rdi
movl %ebp, %esi
callq 0x8011
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x94bb
leaq 0xcf39(%rip), %rdx      # 0x225a9
leaq 0x130(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7fce
leaq 0x170(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
callq 0x9691
leaq 0xcf03(%rip), %rdx      # 0x225a9
leaq 0x70(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x7fce
leaq 0x110(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x1d8(%rsp), %rdx
callq 0x9691
leaq 0x70(%rsp), %rdi
callq 0x55e8
leaq 0x170(%rsp), %rdi
callq 0x55e8
leaq 0x130(%rsp), %rdi
callq 0x55e8
leaq 0x30(%rsp), %rdi
callq 0x55e8
leaq 0xf0(%rsp), %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
callq 0x55e8
testb %bl, %bl
je 0x15750
leaq 0xce89(%rip), %rsi      # 0x225ab
leaq 0x70(%rsp), %rdi
leaq 0x1b8(%rsp), %rdx
callq 0x9dae
leaq 0x110(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x55c0
leaq 0x70(%rsp), %rdi
callq 0x55e8
pushq $0x10
popq %rax
leaq (%rsp,%rax), %rcx
addq $0x170, %rcx            # imm = 0x170
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x15753
pushq $0x10
popq %rax
leaq (%rsp,%rax), %rcx
addq $0x130, %rcx            # imm = 0x130
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x15777
movq 0xc8(%rsp), %rax
addq $0x68, %rax
movq %rax, 0xd0(%rsp)
xorl %edx, %edx
leaq 0x70(%rsp), %r15
xorl %ebx, %ebx
xorl %r13d, %r13d
cmpq $0x2, %rdx
je 0x15b1b
imulq $0x30, %rdx, %rax
movq 0xd0(%rsp), %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0xe8(%rsp)
movq 0x10(%rax), %rbp
movq %rdx, 0xd8(%rsp)
movq %rdx, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %rcx
addq $0x170, %rcx            # imm = 0x170
movq %rcx, 0x60(%rsp)
addq %rsp, %rax
addq $0x130, %rax            # imm = 0x130
movq %rax, 0x58(%rsp)
cmpq 0xe8(%rsp), %rbp
je 0x15aa9
movslq 0x24(%rbp), %rax
cmpq $-0x1, %rax
je 0x15a99
movl %r13d, 0x6c(%rsp)
movl 0x28(%rbp), %r13d
imulq $0x58, %rax, %rsi
movq 0xe0(%rsp), %rax
addq (%rax), %rsi
movq %r15, %rdi
callq 0x1a174
movzbl 0xbc(%rsp), %r15d
cmpl $0x0, 0x2e0(%rsp)
jne 0x15a7d
movq 0x98(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x53f0
cmpb $0x1, 0xb1(%rsp)
jne 0x158b2
movq 0x98(%rsp), %rdx
addq $0x20, %rdx
leaq 0x10(%rsp), %r12
movq %r12, %rdi
leaq 0xcd13(%rip), %rsi      # 0x225ab
callq 0x9dae
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x55c0
movq %r12, %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
leaq 0xccec(%rip), %rsi      # 0x225aa
leaq 0xf0(%rsp), %rdx
callq 0x72ee
addl $0x2, %r13d
cmpl $0x3, %r13d
ja 0x15979
leaq 0xc9b8(%rip), %rcx      # 0x22298
movslq (%rcx,%r13,4), %rax
addq %rcx, %rax
leaq 0xcf4d(%rip), %rsi      # 0x2283b
jmpq *%rax
leaq 0xcf48(%rip), %rsi      # 0x2283f
jmp 0x1596f
leaq 0x10(%rsp), %rdi
leaq 0xcd06(%rip), %rsi      # 0x2260b
callq 0x55a0
cmpb $0x1, 0xb0(%rsp)
leaq 0xcf23(%rip), %rsi      # 0x2283c
jne 0x1596f
cmpb $0x1, 0xb1(%rsp)
leaq 0xcf0e(%rip), %rsi      # 0x22838
jne 0x1596f
cmpb $0x0, 0xb2(%rsp)
leaq 0xcf05(%rip), %rsi      # 0x22840
leaq 0xcef6(%rip), %rax      # 0x22838
jmp 0x1596b
cmpb $0x1, 0xb1(%rsp)
leaq 0xcee8(%rip), %rsi      # 0x2283b
jne 0x1596f
cmpb $0x0, 0xb2(%rsp)
leaq 0xcecf(%rip), %rsi      # 0x22833
leaq 0xcecc(%rip), %rax      # 0x22837
cmovneq %rax, %rsi
leaq 0x10(%rsp), %rdi
callq 0x55a0
movl 0x70(%rsp), %esi
incl %esi
leaq 0x258(%rsp), %r13
movq %r13, %rdi
callq 0x8011
leaq 0x218(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
leaq 0xcba5(%rip), %rdx      # 0x22549
callq 0x7fce
leaq 0x238(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
leaq 0x78(%rsp), %rdx
callq 0x9691
leaq 0x278(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
leaq 0xcb73(%rip), %rdx      # 0x22549
callq 0x7fce
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
leaq 0x30(%rsp), %rdx
callq 0x9691
movq %r12, %rdi
callq 0x55e8
leaq 0x238(%rsp), %rdi
callq 0x55e8
leaq 0x218(%rsp), %rdi
callq 0x55e8
movq %r13, %rdi
callq 0x55e8
movq 0x60(%rsp), %rdi
movq %r14, %rsi
callq 0x55c0
leaq 0x10(%rsp), %r13
movq 0x58(%rsp), %rdi
movq %r13, %rsi
callq 0x55c0
movq 0x60(%rsp), %rdi
leaq 0xcdfb(%rip), %rsi      # 0x22843
callq 0x55a0
movq 0x58(%rsp), %rdi
leaq 0xcdea(%rip), %rsi      # 0x22843
callq 0x55a0
leaq 0xf0(%rsp), %rdi
callq 0x55e8
movq %r13, %rdi
callq 0x55e8
leaq 0x30(%rsp), %rdi
callq 0x55e8
addl %r15d, %ebx
xorl $0x1, %r15d
movl 0x6c(%rsp), %r13d
addl %r15d, %r13d
leaq 0x70(%rsp), %r15
movq %r15, %rdi
callq 0x19c16
movq %rbp, %rdi
callq 0x5240
movq %rax, %rbp
jmp 0x1580e
cmpl $0x0, 0x2e0(%rsp)
jne 0x15b0b
movq 0x60(%rsp), %r14
movq 0x8(%r14), %rcx
decq %rcx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5320
movq %r14, %rdi
movq %r15, %rsi
callq 0x5390
movq %r15, %rdi
callq 0x55e8
movq 0x58(%rsp), %r14
movq 0x8(%r14), %rcx
decq %rcx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5320
movq %r14, %rdi
movq %r15, %rsi
callq 0x5390
movq %r15, %rdi
callq 0x55e8
movq 0xd8(%rsp), %rdx
incq %rdx
jmp 0x157b8
movl %ebx, %r12d
cmpl $0x0, 0x2e0(%rsp)
je 0x15b42
movl %r13d, %ebx
movslq 0xc(%rsp), %r15
movslq 0x2d8(%rsp), %r14
movq 0x50(%rsp), %rbp
jmp 0x15cd3
leaq 0xca60(%rip), %rsi      # 0x225a9
leaq 0x10(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x9dae
leaq 0xca47(%rip), %rdx      # 0x225a9
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7fce
leaq 0x190(%rsp), %rdx
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x9691
leaq 0x110(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x55c0
leaq 0x70(%rsp), %rdi
callq 0x55e8
leaq 0x30(%rsp), %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
callq 0x55e8
leaq 0xc9ea(%rip), %rsi      # 0x225a9
leaq 0x10(%rsp), %rdi
leaq 0x130(%rsp), %rdx
callq 0x9dae
leaq 0xc9d1(%rip), %rdx      # 0x225a9
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7fce
leaq 0x150(%rsp), %rdx
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x9691
leaq 0x110(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x55c0
leaq 0x70(%rsp), %rdi
callq 0x55e8
leaq 0x30(%rsp), %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
callq 0x55e8
movq 0xc8(%rsp), %rax
movl 0x158(%rax), %esi
leaq 0x10(%rsp), %rdi
callq 0x8011
leaq 0xc95c(%rip), %rsi      # 0x225a9
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x7fed
leaq 0xb409(%rip), %rdx      # 0x2106c
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7fce
movl %r13d, %ebx
leaq 0x110(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x55c0
leaq 0x70(%rsp), %rdi
callq 0x55e8
leaq 0x30(%rsp), %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
callq 0x55e8
movq 0x50(%rsp), %rbp
movq 0x178(%rbp), %rax
movslq 0xc(%rsp), %r15
movq (%rax,%r15,8), %rax
movslq 0x2d8(%rsp), %r14
movq (%rax,%r14,8), %rdi
leaq 0x110(%rsp), %rsi
callq 0xc896
movq 0x180(%rbp), %rax
movq (%rax,%r15,8), %rax
movslq 0x2e0(%rsp), %r13
movq (%rax,%r13,8), %rdi
movq %r14, %rsi
callq 0x1a1ca
addl %ebx, (%rax)
movq 0x188(%rbp), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%r13,8), %rdi
movq %r14, %rsi
callq 0x1a1ca
addl %r12d, (%rax)
pushq $0x20
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x55e8
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x15d11
pushq $0x20
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x170, %rdi            # imm = 0x170
callq 0x55e8
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x15d2e
leaq 0x110(%rsp), %rdi
callq 0x55e8
leaq 0x1b8(%rsp), %rdi
callq 0x55e8
leaq 0x1d8(%rsp), %rdi
callq 0x55e8
leaq 0x1f8(%rsp), %rdi
callq 0x55e8
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15da4
jmp 0x15db3
jmp 0x15dc2
jmp 0x15eca
jmp 0x15da4
jmp 0x15db3
jmp 0x15dc2
jmp 0x15eca
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x55e8
jmp 0x15db6
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x55e8
jmp 0x15dc5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x55e8
jmp 0x15efd
jmp 0x15eca
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x55e8
jmp 0x15f39
movq %rax, %rbx
jmp 0x15f39
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x55e8
jmp 0x15e05
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
callq 0x55e8
jmp 0x15e17
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x55e8
jmp 0x15e29
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x55e8
jmp 0x15e38
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
jmp 0x15f41
movq %rax, %rbx
jmp 0x15e45
movq %rax, %rbx
jmp 0x15f53
movq %rax, %rbx
jmp 0x15f60
movq %rax, %rbx
jmp 0x15f46
jmp 0x15eca
jmp 0x15eca
jmp 0x15eca
jmp 0x15ebb
jmp 0x15ec0
movq %rax, %rbx
leaq 0x278(%rsp), %rdi
callq 0x55e8
jmp 0x15e8b
movq %rax, %rbx
leaq 0x238(%rsp), %rdi
callq 0x55e8
jmp 0x15e9d
movq %rax, %rbx
leaq 0x218(%rsp), %rdi
callq 0x55e8
jmp 0x15eaf
movq %rax, %rbx
leaq 0x258(%rsp), %rdi
jmp 0x15eda
jmp 0x15ebb
movq %rax, %rbx
jmp 0x15edf
movq %rax, %rbx
jmp 0x15ee9
movq %rax, %rbx
jmp 0x15ef3
movq %rax, %rbx
jmp 0x15efd
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x55e8
leaq 0x10(%rsp), %rdi
callq 0x55e8
leaq 0x30(%rsp), %rdi
callq 0x55e8
leaq 0x70(%rsp), %rdi
callq 0x19c16
pushq $0x20
popq %r14
leaq (%rsp,%r14), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x55e8
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x15f01
pushq $0x20
popq %r14
leaq (%rsp,%r14), %rdi
addq $0x170, %rdi            # imm = 0x170
callq 0x55e8
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x15f1f
leaq 0x110(%rsp), %rdi
callq 0x55e8
leaq 0x1b8(%rsp), %rdi
callq 0x55e8
leaq 0x1d8(%rsp), %rdi
callq 0x55e8
leaq 0x1f8(%rsp), %rdi
callq 0x55e8
movq %rbx, %rdi
callq 0x5540
nop