// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/sample_molecule.cpp
// Function: read_mcove_dist(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 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::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>>>*)
bool read_mcove_dist(string                      mcfile, 
                     map<string, unsigned long>* mCov, 
                     map<string, unsigned long>* mCov_intersec)
{
    ifstream ifp;
    ifp.open(mcfile.c_str(), ios::in);
    if(!ifp.is_open())
    {
        cout << "   Error: cannot open file " << mcfile << endl;
        return false;
    }
    cout << "   Info: reading molecule base coverage distribution from " << mcfile << endl;
    while(ifp.good())
    {
        string line("");
        getline(ifp, line);
        if(line.size()==0 || line[0]=='#') continue;
        vector<string> lineinfo = split_string(line, '\t');
        if(lineinfo.size() < 2) continue;
        std::stringstream key0;
        key0.str(""); 
        key0 << lineinfo[0];
        string        key = key0.str();
        unsigned long num = strtoul(lineinfo[1].c_str(), NULL, 0);
        //
        map<string, unsigned long>::iterator itr;
        itr = (*mCov).find(key);
        if(itr != (*mCov).end() )
        {
            cout << "   Warning: skipping repeated line: " << line << endl;
            continue;
        }
        else
        {
            (*mCov).insert(std::pair<string, unsigned long>(key, num));
        }
        //
        itr = (*mCov_intersec).find(key);
        if(itr != (*mCov_intersec).end())
        {
            if((*itr).second > num)
            {
                // replace with lower value
                (*itr).second = num;
            }
        }
        else
        {
            (*mCov_intersec).insert(std::pair<string, unsigned long>(key, num));
        }
    }    
    ifp.close();
    cout << "   Info: reading done. " << endl;    
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rdx, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %rbx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0x4380
movq (%rbx), %rsi
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x4200
leaq 0x120(%rsp), %rdi
callq 0x40c0
movb %al, 0x7(%rsp)
testb %al, %al
je 0x1d439
movq 0x1fdae(%rip), %rdi     # 0x3cfc8
leaq 0x10389(%rip), %rsi     # 0x2d5aa
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x10(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x38(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x30(%rsp)
leaq 0x68(%rsp), %r13
leaq 0x2b0(%rsp), %rbx
leaq 0x40(%rsp), %r14
leaq 0x88(%rsp), %r12
movq 0xa8(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xc8(%rsp,%rax)
jne 0x1d459
movq %r13, %rdi
leaq 0x10887(%rip), %rsi     # 0x2db1a
movq %rbx, %rdx
callq 0x4d3e
leaq 0xa8(%rsp), %rdi
movq %r13, %rsi
callq 0x4090
cmpq $0x0, 0x70(%rsp)
je 0x1d3ae
movq 0x68(%rsp), %rax
cmpb $0x23, (%rax)
je 0x1d3ae
movb $0x9, 0x2b0(%rsp)
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x26120
movq 0x20(%rsp), %rax
subq 0x18(%rsp), %rax
cmpq $0x21, %rax
jb 0x1d3a4
movq %rbx, %rdi
callq 0x4250
movq %r14, %rdi
leaq 0x10817(%rip), %rsi     # 0x2db1a
movq %r12, %rdx
callq 0x4d3e
leaq 0x2c8(%rsp), %rdi
movq %r14, %rsi
callq 0x4490
movq %r14, %rdi
callq 0x4638
movq 0x18(%rsp), %rsi
leaq 0x2c0(%rsp), %rdi
callq 0x42e0
movq %r12, %rdi
leaq 0x2c8(%rsp), %rsi
callq 0x44e0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %r15
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xa47a
cmpq 0x38(%rsp), %rax
je 0x1d3bb
movq 0x1fc53(%rip), %rdi     # 0x3cfc8
leaq 0x101f1(%rip), %rsi     # 0x2d56d
callq 0x4330
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq %r12, %rdi
callq 0x4638
movq %rbx, %rdi
callq 0x4280
leaq 0x18(%rsp), %rdi
callq 0x5d02
movq %r13, %rdi
callq 0x4638
jmp 0x1d26f
movq %r12, %rsi
movq %r14, %r12
movq %r14, %rdi
movq %rsi, %rbp
callq 0x4400
movq %r15, 0x60(%rsp)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xa4f0
movq %r12, %rdi
callq 0x4638
movq 0x8(%rsp), %rdi
movq %rbp, %r12
movq %rbp, %rsi
callq 0xa47a
cmpq 0x30(%rsp), %rax
je 0x1d409
cmpq %r15, 0x40(%rax)
jbe 0x1d394
movq %r15, 0x40(%rax)
jmp 0x1d394
movq %r12, %rsi
movq %r14, %r12
movq %r14, %rdi
callq 0x4400
movq %r15, 0x60(%rsp)
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xa4f0
movq %r12, %rdi
callq 0x4638
movq %rbp, %r12
jmp 0x1d394
movq 0x1fb88(%rip), %rdi     # 0x3cfc8
leaq 0xc70f(%rip), %rsi      # 0x29b56
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42e0
jmp 0x1d479
leaq 0xa8(%rsp), %rdi
callq 0x40a0
movq 0x1fb5b(%rip), %rdi     # 0x3cfc8
leaq 0x1011e(%rip), %rsi     # 0x2d592
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0xa8(%rsp), %rdi
callq 0x40d0
movb 0x7(%rsp), %al
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1d4aa
jmp 0x1d4d5
jmp 0x1d4d5
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4638
jmp 0x1d4d8
jmp 0x1d4d5
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x1d4e0
jmp 0x1d4d0
jmp 0x1d4d0
jmp 0x1d4d5
movq %rax, %rbx
jmp 0x1d4f2
movq %rax, %rbx
jmp 0x1d4e5
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x4638
leaq 0x2b0(%rsp), %rdi
callq 0x4280
leaq 0x18(%rsp), %rdi
callq 0x5d02
jmp 0x1d50a
jmp 0x1d507
jmp 0x1d502
movq %rax, %rbx
jmp 0x1d514
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4638
leaq 0xa8(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0
nop