// File: /workspace/github_cpp_makefile_star2_O1/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 0x38d6f
movq 0x132c0(%rip), %rdi     # 0x4bfc8
leaq 0x1e5f(%rip), %rsi      # 0x3ab6e
movl $0x1b, %edx
callq 0x43a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x132a1(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %rbx
leaq 0x62be(%rip), %rsi      # 0x3eff4
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 0x39014
leaq 0x58(%rsp), %r14
leaq 0x2eed(%rip), %rsi      # 0x3bc68
movl $0x5, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x628f(%rip), %rsi      # 0x3f01e
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2ed5(%rip), %rsi      # 0x3bc78
movl $0xa, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2ecc(%rip), %rsi      # 0x3bc83
movl $0x6, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2ebf(%rip), %rsi      # 0x3bc8a
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2eb9(%rip), %rsi      # 0x3bc98
movl $0xe, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2eb4(%rip), %rsi      # 0x3bca7
movl $0x8, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2ea9(%rip), %rsi      # 0x3bcb0
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2ea3(%rip), %rsi      # 0x3bcbe
movl $0xa, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e9a(%rip), %rsi      # 0x3bcc9
movl $0xb, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e92(%rip), %rsi      # 0x3bcd5
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e8c(%rip), %rsi      # 0x3bce3
movl $0x1a, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e93(%rip), %rsi      # 0x3bcfe
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e91(%rip), %rsi      # 0x3bd10
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e8f(%rip), %rsi      # 0x3bd22
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e89(%rip), %rsi      # 0x3bd30
movl $0x11, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e87(%rip), %rsi      # 0x3bd42
movl $0x12, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e86(%rip), %rsi      # 0x3bd55
movl $0xe, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e81(%rip), %rsi      # 0x3bd64
movl $0xf, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x2e7d(%rip), %rsi      # 0x3bd74
movl $0x8, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x6125(%rip), %rsi      # 0x3f030
movl $0xd, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x611f(%rip), %rsi      # 0x3f03e
movl $0xe, %edx
movq %r14, %rdi
callq 0x43a0
leaq 0x611a(%rip), %rsi      # 0x3f04d
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 0x39006
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 0x389f2
movq 0x30(%rsp), %r13
cmpq %rbx, %r13
je 0x38fe8
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 0x38f98
movq %r15, %rdi
callq 0x4230
movq %rax, %r15
movq %r12, %rdi
callq 0x20dfc
cmpq 0x10(%rsp), %r15
jne 0x38f64
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 0x3903b
jmp 0x39040
movq %rax, %rbx
jmp 0x3904d
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x20dfc
leaq 0x48(%rsp), %rdi
callq 0x40b0
movq %rbx, %rdi
callq 0x45a0
nop