// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/sample_molecule.cpp
// Function: read_msize_dist(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*)
bool read_msize_dist(string msfile, map<int, unsigned long>* mNum, map<int, unsigned long>* mNum_intersec)
{
    ifstream ifp;
    ifp.open(msfile.c_str(), ios::in);
    if(!ifp.is_open())
    {
        cout << "   Error: cannot open file " << msfile << endl;
        return false;
    }
    cout << "   Info: reading molecule size distribution from " << msfile << 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;
        int           key = atoi(lineinfo[0].c_str());
        unsigned long len = strtoul(lineinfo[lineinfo.size()-1].c_str(), NULL, 0);
        //
        map<int, unsigned long>::iterator itr;
        itr = (*mNum).find(key);
        if(itr != (*mNum).end() )
        {
            cout << "   Warning: skipping repeated line: " << line << endl;
            continue;
        }
        else
        {
            (*mNum).insert(std::pair<int, unsigned long>(key, len));
        }
        //
        itr = (*mNum_intersec).find(key);
        if(itr != (*mNum_intersec).end())
        {
            if((*itr).second > len)
            {
                // replace with lower value
                (*itr).second = len;
            }
        }
        else
        {
            (*mNum_intersec).insert(std::pair<int, unsigned long>(key, len));
        }
    }
    ifp.close();
    cout << "   Info: reading done. " << endl;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdx, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %rbx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
callq 0x4380
movq (%rbx), %rsi
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x4200
leaq 0xe8(%rsp), %rdi
callq 0x40c0
movb %al, 0x3(%rsp)
testb %al, %al
je 0x1bab9
movq 0x2169c(%rip), %rdi     # 0x3cfc8
leaq 0x11c08(%rip), %rsi     # 0x2d53b
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x10(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x28(%rsp)
leaq 0x121ac(%rip), %r12     # 0x2db1a
leaq 0x50(%rsp), %r13
leaq 0x38(%rsp), %rbp
leaq 0x70(%rsp), %rbx
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x90(%rsp,%rax)
jne 0x1bad9
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x4d3e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4090
cmpq $0x0, 0x58(%rsp)
je 0x1ba50
movq 0x50(%rsp), %rax
cmpb $0x23, (%rax)
je 0x1ba50
movb $0x9, 0x18(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x18(%rsp), %rdx
callq 0x26120
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %r15
subq %r14, %r15
cmpq $0x21, %r15
jb 0x1ba48
movq (%r14), %rdi
callq 0x44c0
movl %eax, 0x4(%rsp)
movq -0x20(%r14,%r15), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0xa69a
cmpq 0x30(%rsp), %rax
je 0x1ba5d
movq 0x2159f(%rip), %rdi     # 0x3cfc8
leaq 0x11b3d(%rip), %rsi     # 0x2d56d
callq 0x4330
movq %rax, %rdi
movq %r13, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq %rbp, %rdi
callq 0x5d02
movq %r13, %rdi
callq 0x4638
jmp 0x1b97d
movl 0x4(%rsp), %eax
movl %eax, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xa6ec
movq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0xa69a
cmpq 0x28(%rsp), %rax
je 0x1ba9b
cmpq %r14, 0x28(%rax)
jbe 0x1ba48
movq %r14, 0x28(%rax)
jmp 0x1ba48
movl 0x4(%rsp), %eax
movl %eax, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xa6ec
jmp 0x1ba48
movq 0x21508(%rip), %rdi     # 0x3cfc8
leaq 0xe08f(%rip), %rsi      # 0x29b56
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42e0
jmp 0x1baf6
leaq 0x70(%rsp), %rdi
callq 0x40a0
movq 0x214de(%rip), %rdi     # 0x3cfc8
leaq 0x11aa1(%rip), %rsi     # 0x2d592
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x70(%rsp), %rdi
callq 0x40d0
movb 0x3(%rsp), %al
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1bb26
jmp 0x1bb26
jmp 0x1bb26
jmp 0x1bb26
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5d02
jmp 0x1bb3c
jmp 0x1bb39
jmp 0x1bb48
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4638
jmp 0x1bb4b
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0