// File: schneebergerlab[P]DrLink/separate_kb_molecule.cpp
// Function: write_molecule_kbcov(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long, 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, unsigned long>>>, 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)
bool write_molecule_kbcov(map<string, unsigned long> molecule_kbcov, string molfolder, string mollabel, int mlkey)
{
    // 1. molecule base coverage
    std::stringstream outMCovFile;
    outMCovFile.str(""); 
    outMCovFile << "./" << molfolder << "/" << mollabel << "_" << mlkey << "kb_moleCov_stat.txt";
    ofstream ofp;
    ofp.open( (outMCovFile.str()).c_str(), ios::out);
    if(!ofp.good())
    {
        cout << "   Error: cannot open " << outMCovFile.str() << " to write data. " << endl;
        return false;
    }
    map<string, unsigned long>::iterator mcitr;
    map<string, unsigned long>::iterator mcitr_end;
    mcitr     = molecule_kbcov.begin();
    mcitr_end = molecule_kbcov.end();
    ofp << "#molecule_base_cov\tmolecule_num_in_bin" << endl;
    while(mcitr != mcitr_end)
    {
        ofp << (*mcitr).first << "\t" << (*mcitr).second << endl;
        mcitr ++;
    }
    ofp.close();
    
    return true;
}

// Assembly:
subq $0x4e8, %rsp            # imm = 0x4E8
movq %rdi, 0x70(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdx, 0x80(%rsp)
movq %rdi, 0x4d8(%rsp)
movq %rsi, 0x4d0(%rsp)
movq %rdx, 0x4c8(%rsp)
movl %ecx, 0x4c4(%rsp)
leaq 0x338(%rsp), %rdi
callq 0x5320
leaq 0x317(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x57c0
movq 0x88(%rsp), %rdx
leaq 0xc7db(%rip), %rsi      # 0x6ab94
leaq 0x318(%rsp), %rdi
callq 0x6880
jmp 0x5e3c8
leaq 0x338(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x5510
jmp 0x5e3df
leaq 0x318(%rsp), %rdi
callq 0x58b8
leaq 0x317(%rsp), %rdi
callq 0x54d0
leaq 0x348(%rsp), %rdi
leaq 0xc9db(%rip), %rsi      # 0x6ade3
callq 0x5460
movq %rax, 0x68(%rsp)
jmp 0x5e414
movq 0x78(%rsp), %rsi
movq 0x68(%rsp), %rdi
callq 0x53e0
movq %rax, 0x60(%rsp)
jmp 0x5e42a
movq 0x60(%rsp), %rdi
leaq 0xc9ae(%rip), %rsi      # 0x6ade4
callq 0x5460
movq %rax, 0x58(%rsp)
jmp 0x5e442
movq 0x80(%rsp), %rsi
movq 0x58(%rsp), %rdi
callq 0x53e0
movq %rax, 0x50(%rsp)
jmp 0x5e45b
movq 0x50(%rsp), %rdi
leaq 0x9630(%rip), %rsi      # 0x67a97
callq 0x5460
movq %rax, 0x48(%rsp)
jmp 0x5e473
movq 0x48(%rsp), %rdi
movl 0x4c4(%rsp), %esi
callq 0x5790
movq %rax, 0x40(%rsp)
jmp 0x5e48b
movq 0x40(%rsp), %rdi
leaq 0xc65b(%rip), %rsi      # 0x6aaf2
callq 0x5460
jmp 0x5e49e
leaq 0x100(%rsp), %rdi
callq 0x5770
jmp 0x5e4ad
leaq 0xe0(%rsp), %rdi
leaq 0x338(%rsp), %rsi
callq 0x5440
jmp 0x5e4c4
leaq 0xe0(%rsp), %rdi
callq 0x51d0
movq %rax, %rsi
leaq 0x100(%rsp), %rdi
movl $0x10, %edx
callq 0x5070
jmp 0x5e4e8
leaq 0xe0(%rsp), %rdi
callq 0x58b8
movq 0x100(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x100(%rsp,%rax), %rdi
callq 0x5760
movb %al, 0x3f(%rsp)
jmp 0x5e514
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x5e683
jmp 0x5e522
movq 0x26a9f(%rip), %rdi     # 0x84fc8
leaq 0x85e8(%rip), %rsi      # 0x66b18
callq 0x5460
movq %rax, 0x30(%rsp)
jmp 0x5e53c
leaq 0xc0(%rsp), %rdi
leaq 0x338(%rsp), %rsi
callq 0x5440
jmp 0x5e553
movq 0x30(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x53e0
movq %rax, 0x28(%rsp)
jmp 0x5e56c
movq 0x28(%rsp), %rdi
leaq 0x8954(%rip), %rsi      # 0x66ecc
callq 0x5460
movq %rax, 0x20(%rsp)
jmp 0x5e584
movq 0x20(%rsp), %rdi
movq 0x26a20(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x5e597
leaq 0xc0(%rsp), %rdi
callq 0x58b8
movb $0x0, 0x4e7(%rsp)
movl $0x1, 0xbc(%rsp)
jmp 0x5e7dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x308(%rsp)
movl %eax, 0x304(%rsp)
jmp 0x5e5f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x308(%rsp)
movl %eax, 0x304(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x58b8
leaq 0x317(%rsp), %rdi
callq 0x54d0
jmp 0x5e814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x308(%rsp)
movl %eax, 0x304(%rsp)
jmp 0x5e814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x308(%rsp)
movl %eax, 0x304(%rsp)
jmp 0x5e807
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x308(%rsp)
movl %eax, 0x304(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x58b8
jmp 0x5e807
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x308(%rsp)
movl %eax, 0x304(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x58b8
jmp 0x5e807
leaq 0xb0(%rsp), %rdi
callq 0x10810
leaq 0xa8(%rsp), %rdi
callq 0x10810
movq 0x70(%rsp), %rdi
callq 0x10830
movq 0x70(%rsp), %rdi
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0xb0(%rsp)
callq 0x10160
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0x87f5(%rip), %rsi      # 0x66edd
leaq 0x100(%rsp), %rdi
callq 0x5460
movq %rax, 0x18(%rsp)
jmp 0x5e6fc
movq 0x18(%rsp), %rdi
movq 0x268a8(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x5e70f
jmp 0x5e711
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x10860
testb $0x1, %al
jne 0x5e72f
jmp 0x5e7ba
leaq 0xb0(%rsp), %rdi
callq 0x10230
movq %rax, %rsi
leaq 0x100(%rsp), %rdi
callq 0x53e0
movq %rax, 0x10(%rsp)
jmp 0x5e753
movq 0x10(%rsp), %rdi
leaq 0xc434(%rip), %rsi      # 0x6ab93
callq 0x5460
movq %rax, 0x8(%rsp)
jmp 0x5e76b
leaq 0xb0(%rsp), %rdi
callq 0x10230
movq 0x8(%rsp), %rdi
movq 0x20(%rax), %rsi
callq 0x50f0
movq %rax, (%rsp)
jmp 0x5e78c
movq (%rsp), %rdi
movq 0x26819(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x5e79e
leaq 0xb0(%rsp), %rdi
xorl %esi, %esi
callq 0x10880
movq %rax, 0x90(%rsp)
jmp 0x5e711
leaq 0x100(%rsp), %rdi
callq 0x5610
jmp 0x5e7c9
movb $0x1, 0x4e7(%rsp)
movl $0x1, 0xbc(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x5670
leaq 0x338(%rsp), %rdi
callq 0x5350
movb 0x4e7(%rsp), %al
andb $0x1, %al
addq $0x4e8, %rsp            # imm = 0x4E8
retq
leaq 0x100(%rsp), %rdi
callq 0x5670
leaq 0x338(%rsp), %rdi
callq 0x5350
movq 0x308(%rsp), %rdi
callq 0x57b0
nop