// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/sample_molecule_v2.cpp
// Function: read_mcove_dist2(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>>>*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, 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, int>>>*)
bool read_mcove_dist2(string                     mcfile, 
                     map<string, unsigned long>* mCov, 
                     map<string, unsigned long>* mCov_intersec,
                     map<string, int>*           mCov_intersec_samNum)
{
    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;
    bool first1x = true;
    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;
        string        key = lineinfo[0];
        unsigned long num = strtoul(lineinfo[1].c_str(), NULL, 0);
        //
        if(atof(key.c_str()) > 1.0)
        {
            if(first1x == true)
            {
                first1x = false;
                cout << "   Warning: sample with >1.0x coverage molecules but all skipped. " << endl;
            }
            continue;
        }
        //
        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;
            }
            (*mCov_intersec_samNum)[key] += 1;
        }
        else
        {
            (*mCov_intersec).insert(std::pair<string, unsigned long>(key, num));
            (*mCov_intersec_samNum).insert(std::pair<string, int>(key, 1));
        }
    }    
    ifp.close();
    cout << "   Info: reading done. " << endl;    
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x8(%rsp)
movq %rdi, %rbx
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x4380
movq (%rbx), %rsi
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x4200
leaq 0x128(%rsp), %rdi
callq 0x40c0
movb %al, 0x3(%rsp)
testb %al, %al
je 0x2133b
movq 0x1bee8(%rip), %rdi     # 0x3cfc8
leaq 0xc4c3(%rip), %rsi      # 0x2d5aa
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq %r15, 0x10(%rsp)
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x48(%rsp)
movq %r12, 0x18(%rsp)
leaq 0x8(%r12), %rax
movq %rax, 0x40(%rsp)
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0xc9ec(%rip), %r13      # 0x2db1a
leaq 0x90(%rsp), %rbp
leaq 0x68(%rsp), %r14
leaq 0xb0(%rsp), %r15
leaq 0x50(%rsp), %rbx
movq 0xb0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xd0(%rsp,%rax)
jne 0x21363
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x4d3e
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4090
cmpq $0x0, 0x98(%rsp)
je 0x2132e
movq 0x90(%rsp), %rax
cmpb $0x23, (%rax)
je 0x2132e
movb $0x9, 0x68(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x26120
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rax
subq %rsi, %rax
cmpq $0x21, %rax
jb 0x21326
leaq 0x20(%rsp), %rdi
callq 0x4400
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %r12
movq 0x20(%rsp), %rdi
callq 0x43d0
ucomisd 0xbd8a(%rip), %xmm0     # 0x2cf80
jbe 0x21227
testb $0x1, 0x4(%rsp)
je 0x2121a
movq 0x1bdc2(%rip), %rdi     # 0x3cfc8
leaq 0xc942(%rip), %rsi      # 0x2db4f
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movl $0x0, 0x4(%rsp)
jmp 0x2131c
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa47a
cmpq 0x48(%rsp), %rax
je 0x21268
movq 0x1bd84(%rip), %rdi     # 0x3cfc8
leaq 0xc322(%rip), %rsi      # 0x2d56d
callq 0x4330
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
jmp 0x2131c
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x4400
movq %r12, 0x88(%rsp)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xa4f0
movq %r14, %rdi
callq 0x4638
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa47a
cmpq 0x40(%rsp), %rax
je 0x212c5
cmpq %r12, 0x40(%rax)
jbe 0x212b2
movq %r12, 0x40(%rax)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x978c
incl (%rax)
jmp 0x2131c
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x4400
movq %r12, 0x88(%rsp)
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0xa4f0
movq %r14, %rdi
callq 0x4638
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x4400
movl $0x1, 0x88(%rsp)
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0xaa08
movq %r14, %rdi
callq 0x4638
leaq 0x20(%rsp), %rdi
callq 0x4638
movq %rbx, %rdi
callq 0x5d02
movq %rbp, %rdi
callq 0x4638
jmp 0x21148
movq 0x1bc86(%rip), %rdi     # 0x3cfc8
leaq 0x880d(%rip), %rsi      # 0x29b56
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
jmp 0x2138b
leaq 0xb0(%rsp), %rdi
callq 0x40a0
movq 0x1bc51(%rip), %rdi     # 0x3cfc8
leaq 0xc214(%rip), %rsi      # 0x2d592
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0xb0(%rsp), %rdi
callq 0x40d0
movb 0x3(%rsp), %al
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x213ba
jmp 0x213d4
jmp 0x213ba
jmp 0x213d4
jmp 0x213d4
jmp 0x213d4
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4638
jmp 0x213d7
jmp 0x213d4
jmp 0x213d4
jmp 0x213f1
movq %rax, %rbx
jmp 0x213e1
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4638
leaq 0x50(%rsp), %rdi
callq 0x5d02
jmp 0x213f9
jmp 0x213f1
jmp 0x213f6
movq %rax, %rbx
jmp 0x21406
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4638
leaq 0xb0(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0