// File: /workspace/github_cpp_makefile_star2_O1/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 $0x2c8, %rsp            # imm = 0x2C8
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x68(%rsp)
movq %rdi, %r14
leaq 0xc0(%rsp), %r13
movq %r13, %rdi
callq 0x4390
movq (%r14), %rsi
movq %r13, %rdi
movl $0x8, %edx
callq 0x41e0
leaq 0x138(%rsp), %rdi
callq 0x40c0
movl %eax, %ebx
testb %al, %al
je 0x2ff5a
movq 0x1c4bf(%rip), %rdi     # 0x4bfc8
leaq 0xeaa2(%rip), %rsi      # 0x3e5b2
movl $0x3a, %edx
callq 0x43a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x1c4a0(%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, 0x60(%rsp)
movq %r15, 0x70(%rsp)
movq 0xc0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xe0(%rsp,%rax)
jne 0x2ff05
leaq 0x88(%rsp), %r15
movq 0x68(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xa0(%rsp)
movq 0x60(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x98(%rsp)
movb $0x1, %al
movl %eax, 0x3c(%rsp)
leaq 0xef70(%rip), %r14      # 0x3eb22
leaq 0x78(%rsp), %rbp
movq %r15, 0x78(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x5384
movq 0xc0(%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, 0x80(%rsp)
je 0x2fed1
movq 0x78(%rsp), %rax
cmpb $0x23, (%rax)
je 0x2fed1
movb $0x9, 0x10(%rsp)
leaq 0xa8(%rsp), %rdi
movq %rbp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x36b7c
movq 0xa8(%rsp), %rax
movq 0xb0(%rsp), %rcx
subq %rax, %rcx
cmpq $0x21, %rcx
jb 0x2fec4
leaq 0x50(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0xda32
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %r12
movq 0x40(%rsp), %rdi
callq 0x43f0
ucomisd 0xe2fb(%rip), %xmm0     # 0x3df88
jbe 0x2fcf1
testb $0x1, 0x3c(%rsp)
je 0x2fea8
movl $0x42, %edx
movq 0x1c322(%rip), %rdi     # 0x4bfc8
leaq 0xeeaa(%rip), %rsi      # 0x3eb57
callq 0x43a0
movq 0x1c30f(%rip), %rcx     # 0x4bfc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x1c2f1(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movl $0x0, 0x3c(%rsp)
jmp 0x2fea8
movq 0x68(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xde70
cmpq 0xa0(%rsp), %rax
je 0x2fd6a
movl $0x24, %edx
movq 0x1c2b2(%rip), %rdi     # 0x4bfc8
leaq 0xe858(%rip), %rsi      # 0x3e575
callq 0x43a0
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x1c292(%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 0x2fea8
movb %bl, 0xf(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xda32
movq %r12, 0x30(%rsp)
movq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq 0xdefa
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
movb 0xf(%rsp), %bl
je 0x2fdc4
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xde70
cmpq 0x98(%rsp), %rax
je 0x2fdfd
cmpq %r12, 0x40(%rax)
jbe 0x2fde7
movq %r12, 0x40(%rax)
movq 0x70(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xcf74
incl (%rax)
jmp 0x2fea8
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xda32
movq %r12, 0x30(%rsp)
movq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0xdefa
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2fe4f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xda32
movl $0x1, 0x30(%rsp)
movq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0xe3f2
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
movb 0xf(%rsp), %bl
je 0x2fea8
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2fec4
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xa8(%rsp), %rdi
callq 0x6aa2
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x2feeb
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0xc0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xe0(%rsp,%rax)
je 0x2fbb7
leaq 0xc0(%rsp), %rdi
callq 0x40a0
movq 0x1c0af(%rip), %r14     # 0x4bfc8
leaq 0xe67a(%rip), %rsi      # 0x3e59a
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 0x1c07d(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
jmp 0x2ffaf
movq 0x1c067(%rip), %rdi     # 0x4bfc8
leaq 0xac06(%rip), %rsi      # 0x3ab6e
movl $0x1b, %edx
callq 0x43a0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x1c048(%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 0xc0(%rsp), %rdi
callq 0x40d0
movl %ebx, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2ffda
jmp 0x30006
jmp 0x2ffda
jmp 0x30006
jmp 0x30006
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x30009
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x30009
jmp 0x30006
jmp 0x30006
jmp 0x30006
movq %rax, %rbx
jmp 0x30025
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x30025
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xa8(%rsp), %rdi
callq 0x6aa2
jmp 0x30042
jmp 0x3003f
jmp 0x3003a
jmp 0x3003a
movq %rax, %rbx
jmp 0x3005c
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x3005c
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xc0(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0