// File: /workspace/github_cpp_makefile_star2_O3/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 $0x258, %rsp            # imm = 0x258
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x43c0
movq (%r14), %rsi
movq %r15, %rdi
movl $0x10, %edx
callq 0x42d0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %ebp
testl %ebp, %ebp
je 0x38a0b
movq 0x13624(%rip), %rdi     # 0x4bfc8
leaq 0x21c3(%rip), %rsi      # 0x3ab6e
movl $0x1b, %edx
callq 0x43a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x13605(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %rbx
leaq 0x6602(%rip), %rsi      # 0x3efd4
movl $0x29, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
jmp 0x38cb0
leaq 0x58(%rsp), %r14
leaq 0x3251(%rip), %rsi      # 0x3bc68
movl $0x5, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x65d3(%rip), %rsi      # 0x3effe
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x3239(%rip), %rsi      # 0x3bc78
movl $0xa, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x3230(%rip), %rsi      # 0x3bc83
movl $0x6, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x3223(%rip), %rsi      # 0x3bc8a
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x321d(%rip), %rsi      # 0x3bc98
movl $0xe, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x3218(%rip), %rsi      # 0x3bca7
movl $0x8, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x320d(%rip), %rsi      # 0x3bcb0
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x3207(%rip), %rsi      # 0x3bcbe
movl $0xa, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31fe(%rip), %rsi      # 0x3bcc9
movl $0xb, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31f6(%rip), %rsi      # 0x3bcd5
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31f0(%rip), %rsi      # 0x3bce3
movl $0x1a, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31f7(%rip), %rsi      # 0x3bcfe
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31f5(%rip), %rsi      # 0x3bd10
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31f3(%rip), %rsi      # 0x3bd22
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31ed(%rip), %rsi      # 0x3bd30
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31eb(%rip), %rsi      # 0x3bd42
movl $0x12, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31ea(%rip), %rsi      # 0x3bd55
movl $0xe, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31e5(%rip), %rsi      # 0x3bd64
movl $0xf, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x31e1(%rip), %rsi      # 0x3bd74
movl $0x8, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x6469(%rip), %rsi      # 0x3f010
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x6463(%rip), %rsi      # 0x3f01e
movl $0xe, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x645e(%rip), %rsi      # 0x3f02d
movl $0x19, %edx
movq %r14, %rdi
callq 0x43a0
movl %ebp, 0xc(%rsp)
movq 0x18(%rbx), %r15
addq $0x8, %rbx
movq %rbx, 0x10(%rsp)
cmpq %rbx, %r15
je 0x38ca2
leaq 0x20(%rsp), %rbx
leaq 0x18(%rsp), %r12
movl $0x0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
leaq 0x40(%r15), %rsi
movq %r12, %rdi
callq 0x3868e
movq 0x30(%rsp), %r13
cmpq %rbx, %r13
je 0x38c84
movq 0x90(%r13), %rsi
movq 0x98(%r13), %rdx
movq %r14, %rdi
callq 0x43a0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %r13, %rdi
callq 0x4230
movq %rax, %r13
cmpq %rbx, %rax
jne 0x38c34
movq %r15, %rdi
callq 0x4230
movq %rax, %r15
movq %r12, %rdi
callq 0x20c7c
cmpq 0x10(%rsp), %r15
jne 0x38c00
leaq 0x48(%rsp), %rdi
callq 0x4070
movl 0xc(%rsp), %ebp
testl %ebp, %ebp
sete %bl
leaq 0x48(%rsp), %rdi
callq 0x40b0
movl %ebx, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x38cd7
jmp 0x38cdc
movq %rax, %rbx
jmp 0x38ce9
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x20c7c
leaq 0x48(%rsp), %rdi
callq 0x40b0
movq %rbx, %rdi
callq 0x45a0
nop