// File: /workspace/github_cpp_makefile_star2_O3/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, 0x58(%rsp)
movq %rdi, %r14
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
callq 0x4390
movq (%r14), %rsi
movq %r13, %rdi
movl $0x8, %edx
callq 0x41e0
leaq 0x128(%rsp), %rdi
callq 0x40c0
movl %eax, %ebx
testb %al, %al
je 0x2fcfc
movq 0x1c70d(%rip), %rdi     # 0x4bfc8
leaq 0xecda(%rip), %rsi      # 0x3e59c
movl $0x3a, %edx
callq 0x43a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x1c6ee(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %r12, 0x50(%rsp)
movq %r15, 0x60(%rsp)
movq 0xb0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xd0(%rsp,%rax)
jne 0x2fca7
leaq 0x78(%rsp), %r15
movq 0x58(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x90(%rsp)
movq 0x50(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x88(%rsp)
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0xf1a9(%rip), %r14      # 0x3eb0a
leaq 0x68(%rsp), %rbp
movq %r15, 0x68(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x5384
movq 0xb0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x45c0
cmpq $0x0, 0x70(%rsp)
movq 0x68(%rsp), %rdi
je 0x2fc7b
cmpb $0x23, (%rdi)
je 0x2fc7b
movb $0x9, 0x8(%rsp)
leaq 0x98(%rsp), %rdi
movq %rbp, %rsi
leaq 0x8(%rsp), %rdx
callq 0x367c0
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rcx
subq %rax, %rcx
cmpq $0x21, %rcx
jb 0x2fc69
leaq 0x40(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xd940
movq 0x98(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %r12
movq 0x30(%rsp), %rdi
callq 0x43f0
ucomisd 0xe54f(%rip), %xmm0     # 0x3df88
jbe 0x2fa99
testb $0x1, 0x4(%rsp)
je 0x2fa8c
movl $0x42, %edx
movq 0x1c57a(%rip), %rdi     # 0x4bfc8
leaq 0xf0ea(%rip), %rsi      # 0x3eb3f
callq 0x43a0
movq 0x1c567(%rip), %rcx     # 0x4bfc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x1c549(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movl $0x0, 0x4(%rsp)
jmp 0x2fc4d
movq 0x58(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xdd92
cmpq 0x90(%rsp), %rax
je 0x2fb0f
movl $0x24, %edx
movq 0x1c50a(%rip), %rdi     # 0x4bfc8
leaq 0xea9a(%rip), %rsi      # 0x3e55f
callq 0x43a0
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x1c4ed(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r12, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
jmp 0x2fc4d
movb %bl, 0x3(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xd940
movq %r12, 0x28(%rsp)
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0xde1c
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
movb 0x3(%rsp), %bl
je 0x2fb69
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xdd92
cmpq 0x88(%rsp), %rax
je 0x2fba2
cmpq %r12, 0x40(%rax)
jbe 0x2fb8c
movq %r12, 0x40(%rax)
movq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xce80
incl (%rax)
jmp 0x2fc4d
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xd940
movq %r12, 0x28(%rsp)
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0xde1c
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2fbf4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xd940
movl $0x1, 0x28(%rsp)
movq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0xe312
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
movb 0x3(%rsp), %bl
je 0x2fc4d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2fc69
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x98(%rsp), %rdi
callq 0x6aac
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x2fc8d
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0xb0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xd0(%rsp,%rax)
je 0x2f966
leaq 0xb0(%rsp), %rdi
callq 0x40a0
movq 0x1c30d(%rip), %r14     # 0x4bfc8
leaq 0xe8c2(%rip), %rsi      # 0x3e584
movl $0x17, %edx
movq %r14, %rdi
callq 0x43a0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x1c2db(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
jmp 0x2fd51
movq 0x1c2c5(%rip), %rdi     # 0x4bfc8
leaq 0xae64(%rip), %rsi      # 0x3ab6e
movl $0x1b, %edx
callq 0x43a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x1c2a6(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
leaq 0xb0(%rsp), %rdi
callq 0x40d0
movl %ebx, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2fd7c
jmp 0x2fda8
jmp 0x2fd7c
jmp 0x2fda8
jmp 0x2fda8
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2fdab
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x2fdab
jmp 0x2fda8
jmp 0x2fda8
jmp 0x2fda8
movq %rax, %rbx
jmp 0x2fdc7
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2fdc7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x98(%rsp), %rdi
callq 0x6aac
jmp 0x2fde4
jmp 0x2fde1
jmp 0x2fddc
jmp 0x2fddc
movq %rax, %rbx
jmp 0x2fdfb
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x2fdfb
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xb0(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0