// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/output_co.cpp
// Function: output_co(std::multimap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::multimap<unsigned long, BPINFO, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, BPINFO>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::multimap<unsigned long, BPINFO, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, BPINFO>>>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool output_co(multimap<string, multimap<unsigned long, BPINFO> > rawbpmap, string rawbpfile)
{
    // output chr:left-coordinate-sorted raw break points: 
    // left-coordinate sorted raw break points
    fstream sortedrawfp;
    sortedrawfp.open(rawbpfile.c_str(), ios::out);
    if(!sortedrawfp.good())
    {
        cout << "   Error: cannot open file " << rawbpfile << " for collecting break point predictions. " << endl;
        return false;
    }
    sortedrawfp << "#chr\t"
                << "left_pos(sorted)\t"
                << "right_pos\t"
                << "score\t"
                << "left_alleles\t"
                << "right_alleles\t"
                << "barcode\t"
                << "vcf_mole_len\t"
                << "left_span\t"
                << "right_span\t"
                << "read_density\t"
                << "co_boundary_same_fragment\t"
                << "min_mole_RR_dist\t"
                << "max_mole_RR_dist\t"
                << "bam_mole_len\t"
                << "bam_mole_readNum\t"
                << "bam_mole_base_cov\t"          
                << "af_at_markers\t"
                << "cov_at_markers\t"
                << "co_size\t"
                << "readnum_left\t"
                << "readnum_right\t"
                << "maxium_RR_distance_in_CO\n";
                
    multimap<string, multimap<unsigned long, BPINFO> >::iterator chritr;
    multimap<string, multimap<unsigned long, BPINFO> >::iterator chritr_end;
    chritr = rawbpmap.begin();
    chritr_end = rawbpmap.end();
    while(chritr != chritr_end)
    {
        multimap<unsigned long, BPINFO> tmp;
        tmp = (*chritr).second;
        multimap<unsigned long, BPINFO>::iterator litr;
        multimap<unsigned long, BPINFO>::iterator litr_end;
        litr = tmp.begin();
        litr_end = tmp.end();
        while(litr != litr_end)
        {
            sortedrawfp << ((*litr).second).bpline << endl;
            litr ++;
        }
        chritr ++;
    }  
    sortedrawfp.close();     
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x43a0
movq (%r14), %rsi
pushq $0x10
popq %rdx
movq %r15, %rdi
callq 0x42f0
movq 0x38(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x58(%rsp,%rax), %ebp
testl %ebp, %ebp
je 0x278d5
movq 0x15726(%rip), %rdi     # 0x3cfc8
leaq 0x22ad(%rip), %rsi      # 0x29b56
callq 0x4330
movq %rax, %rdi
movq %r14, %rsi
callq 0x42e0
leaq 0x6724(%rip), %rsi      # 0x2dfe4
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
jmp 0x27ac6
leaq 0x48(%rsp), %r14
leaq 0x3367(%rip), %rsi      # 0x2ac48
movq %r14, %rdi
callq 0x4330
leaq 0x671e(%rip), %rsi      # 0x2e00e
movq %rax, %rdi
callq 0x4330
leaq 0x3359(%rip), %rsi      # 0x2ac58
movq %rax, %rdi
callq 0x4330
leaq 0x3355(%rip), %rsi      # 0x2ac63
movq %rax, %rdi
callq 0x4330
leaq 0x334d(%rip), %rsi      # 0x2ac6a
movq %rax, %rdi
callq 0x4330
leaq 0x334c(%rip), %rsi      # 0x2ac78
movq %rax, %rdi
callq 0x4330
leaq 0x334c(%rip), %rsi      # 0x2ac87
movq %rax, %rdi
callq 0x4330
leaq 0x3346(%rip), %rsi      # 0x2ac90
movq %rax, %rdi
callq 0x4330
leaq 0x3345(%rip), %rsi      # 0x2ac9e
movq %rax, %rdi
callq 0x4330
leaq 0x3341(%rip), %rsi      # 0x2aca9
movq %rax, %rdi
callq 0x4330
leaq 0x333e(%rip), %rsi      # 0x2acb5
movq %rax, %rdi
callq 0x4330
leaq 0x333d(%rip), %rsi      # 0x2acc3
movq %rax, %rdi
callq 0x4330
leaq 0x3349(%rip), %rsi      # 0x2acde
movq %rax, %rdi
callq 0x4330
leaq 0x334c(%rip), %rsi      # 0x2acf0
movq %rax, %rdi
callq 0x4330
leaq 0x334f(%rip), %rsi      # 0x2ad02
movq %rax, %rdi
callq 0x4330
leaq 0x334e(%rip), %rsi      # 0x2ad10
movq %rax, %rdi
callq 0x4330
leaq 0x3351(%rip), %rsi      # 0x2ad22
movq %rax, %rdi
callq 0x4330
leaq 0x3355(%rip), %rsi      # 0x2ad35
movq %rax, %rdi
callq 0x4330
leaq 0x3355(%rip), %rsi      # 0x2ad44
movq %rax, %rdi
callq 0x4330
leaq 0x3356(%rip), %rsi      # 0x2ad54
movq %rax, %rdi
callq 0x4330
leaq 0x6613(%rip), %rsi      # 0x2e020
movq %rax, %rdi
callq 0x4330
leaq 0x6612(%rip), %rsi      # 0x2e02e
movq %rax, %rdi
callq 0x4330
leaq 0x6612(%rip), %rsi      # 0x2e03d
movq %rax, %rdi
callq 0x4330
movl %ebp, 0x4(%rsp)
movq 0x18(%rbx), %r15
addq $0x8, %rbx
leaq 0x10(%rsp), %rbp
leaq 0x8(%rsp), %r12
cmpq %rbx, %r15
je 0x27ab8
andl $0x0, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movq %rbp, 0x20(%rsp)
movq %rbp, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
leaq 0x40(%r15), %rsi
movq %r12, %rdi
callq 0x275ca
movq 0x20(%rsp), %r13
cmpq %rbp, %r13
je 0x27aa3
leaq 0x90(%r13), %rsi
movq %r14, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq %r13, %rdi
callq 0x4240
movq %rax, %r13
jmp 0x27a7a
movq %r15, %rdi
callq 0x4240
movq %rax, %r15
movq %r12, %rdi
callq 0x16624
jmp 0x27a49
leaq 0x38(%rsp), %rdi
callq 0x4060
movl 0x4(%rsp), %ebp
testl %ebp, %ebp
sete %bl
leaq 0x38(%rsp), %rdi
callq 0x40b0
movl %ebx, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x27aed
jmp 0x27af2
movq %rax, %rbx
jmp 0x27aff
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x16624
leaq 0x38(%rsp), %rdi
callq 0x40b0
movq %rbx, %rdi
callq 0x45a0
nop