// File: 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:
subq $0x5b8, %rsp            # imm = 0x5B8
movq %rdi, 0xb8(%rsp)
movq %rdi, 0x5a8(%rsp)
movq %rsi, 0x5a0(%rsp)
movq %rdx, 0x598(%rsp)
leaq 0x390(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x5500
movq 0xb8(%rsp), %rdi
callq 0x51d0
movq 0xc0(%rsp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x52c0
jmp 0x448f0
leaq 0x390(%rsp), %rdi
callq 0x56f0
movb %al, 0xb7(%rsp)
jmp 0x44906
movb 0xb7(%rsp), %al
testb $0x1, %al
jne 0x4499a
jmp 0x44917
movq 0x406aa(%rip), %rdi     # 0x84fc8
leaq 0x22231(%rip), %rsi     # 0x66b56
callq 0x5460
movq %rax, 0xa8(%rsp)
jmp 0x44934
movq 0xb8(%rsp), %rsi
movq 0xa8(%rsp), %rdi
callq 0x53e0
movq %rax, 0xa0(%rsp)
jmp 0x44953
movq 0xa0(%rsp), %rdi
movq 0x4064e(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x44969
movb $0x0, 0x5b7(%rsp)
movl $0x1, 0x380(%rsp)
jmp 0x4503a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x45058
movq 0x40627(%rip), %rdi     # 0x84fc8
leaq 0x25c9a(%rip), %rsi     # 0x6a642
callq 0x5460
movq %rax, 0x98(%rsp)
jmp 0x449b7
movq 0xb8(%rsp), %rsi
movq 0x98(%rsp), %rdi
callq 0x53e0
movq %rax, 0x90(%rsp)
jmp 0x449d6
movq 0x90(%rsp), %rdi
movq 0x405cb(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x449ec
jmp 0x449ee
movq 0x390(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x390(%rsp,%rax), %rdi
callq 0x5760
movb %al, 0x8f(%rsp)
jmp 0x44a10
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0x44a20
jmp 0x44feb
leaq 0x35f(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x57c0
movq 0x80(%rsp), %rdx
leaq 0x26150(%rip), %rsi     # 0x6ab94
leaq 0x360(%rsp), %rdi
callq 0x6880
jmp 0x44a53
leaq 0x35f(%rsp), %rdi
callq 0x54d0
leaq 0x390(%rsp), %rdi
leaq 0x360(%rsp), %rsi
callq 0x50c0
jmp 0x44a77
leaq 0x360(%rsp), %rdi
callq 0x5310
cmpq $0x0, %rax
je 0x44aaf
xorl %eax, %eax
movl %eax, %esi
leaq 0x360(%rsp), %rdi
callq 0x5880
movq %rax, 0x78(%rsp)
jmp 0x44aa2
movq 0x78(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x44afe
movl $0x2, 0x380(%rsp)
jmp 0x44f91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x35f(%rsp), %rdi
callq 0x54d0
jmp 0x45058
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x44fdc
movb $0x9, 0x33f(%rsp)
leaq 0x340(%rsp), %rdi
leaq 0x360(%rsp), %rsi
leaq 0x33f(%rsp), %rdx
callq 0x60790
jmp 0x44b25
leaq 0x340(%rsp), %rdi
callq 0xfbb0
cmpq $0x2, %rax
jae 0x44b48
movl $0x2, 0x380(%rsp)
jmp 0x44f84
leaq 0x1b0(%rsp), %rdi
callq 0x5320
jmp 0x44b57
leaq 0x18f(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x57c0
movq 0x70(%rsp), %rdx
leaq 0x2601f(%rip), %rsi     # 0x6ab94
leaq 0x190(%rsp), %rdi
callq 0x6880
jmp 0x44b84
leaq 0x1b0(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x5510
jmp 0x44b9b
leaq 0x190(%rsp), %rdi
callq 0x58b8
leaq 0x18f(%rsp), %rdi
callq 0x54d0
leaq 0x1c0(%rsp), %rax
movq %rax, 0x68(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0x340(%rsp), %rdi
callq 0x88f0
movq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x53e0
jmp 0x44be2
leaq 0x168(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x5440
jmp 0x44bf9
leaq 0x340(%rsp), %rdi
movl $0x1, %esi
callq 0x88f0
movq %rax, %rdi
callq 0x51d0
movq %rax, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5160
movq %rax, 0x160(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x10810
movq 0x5a0(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x10110
movq %rax, 0x60(%rsp)
jmp 0x44c50
movq 0x60(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x5a0(%rsp), %rdi
callq 0x10160
movq %rax, 0x148(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x10860
testb $0x1, %al
jne 0x44ca0
jmp 0x44d8a
movq 0x40321(%rip), %rdi     # 0x84fc8
leaq 0x25957(%rip), %rsi     # 0x6a605
callq 0x5460
movq %rax, 0x58(%rsp)
jmp 0x44cba
movq 0x58(%rsp), %rdi
leaq 0x360(%rsp), %rsi
callq 0x53e0
movq %rax, 0x50(%rsp)
jmp 0x44cd3
movq 0x50(%rsp), %rdi
movq 0x402d1(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x44ce6
movl $0x2, 0x380(%rsp)
jmp 0x44f6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x44fcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x44d46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x58b8
leaq 0x18f(%rsp), %rdi
callq 0x54d0
jmp 0x44fc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x44fc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x44fb5
movq 0x5a0(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x160(%rsp), %rdx
callq 0x45900
jmp 0x44db6
movq 0x48(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x10190
movb %dl, 0x3f(%rsp)
movq %rax, 0x40(%rsp)
jmp 0x44dd3
movb 0x3f(%rsp), %al
movq 0x40(%rsp), %rcx
movq %rcx, 0x110(%rsp)
movb %al, 0x118(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x10220
jmp 0x44e20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x10220
jmp 0x44fb5
movq 0x598(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x10110
movq %rax, 0x30(%rsp)
jmp 0x44e3c
movq 0x30(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x598(%rsp), %rdi
callq 0x10160
movq %rax, 0x100(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x10860
testb $0x1, %al
jne 0x44e89
jmp 0x44ecc
leaq 0x158(%rsp), %rdi
callq 0x10230
movq 0x20(%rax), %rax
cmpq 0x160(%rsp), %rax
jbe 0x44ec7
movq 0x160(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x10230
movq 0x28(%rsp), %rcx
movq %rcx, 0x20(%rax)
jmp 0x44f5f
movq 0x598(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x160(%rsp), %rdx
callq 0x45900
jmp 0x44ef8
movq 0x20(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x10190
movb %dl, 0x17(%rsp)
movq %rax, 0x18(%rsp)
jmp 0x44f15
movb 0x17(%rsp), %al
movq 0x18(%rsp), %rcx
movq %rcx, 0xc8(%rsp)
movb %al, 0xd0(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x10220
jmp 0x44f5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x10220
jmp 0x44fb5
movl $0x0, 0x380(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x58b8
leaq 0x1b0(%rsp), %rdi
callq 0x5350
leaq 0x340(%rsp), %rdi
callq 0x8910
leaq 0x360(%rsp), %rdi
callq 0x58b8
movl 0x380(%rsp), %eax
testl %eax, %eax
je 0x44fb0
jmp 0x44fab
jmp 0x449ee
jmp 0x449ee
leaq 0x168(%rsp), %rdi
callq 0x58b8
leaq 0x1b0(%rsp), %rdi
callq 0x5350
leaq 0x340(%rsp), %rdi
callq 0x8910
leaq 0x360(%rsp), %rdi
callq 0x58b8
jmp 0x45058
leaq 0x390(%rsp), %rdi
callq 0x50d0
jmp 0x44ffa
movq 0x3ffc7(%rip), %rdi     # 0x84fc8
leaq 0x25622(%rip), %rsi     # 0x6a62a
callq 0x5460
movq %rax, 0x8(%rsp)
jmp 0x45014
movq 0x8(%rsp), %rdi
movq 0x3ff90(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x45027
movb $0x1, 0x5b7(%rsp)
movl $0x1, 0x380(%rsp)
leaq 0x390(%rsp), %rdi
callq 0x5100
movb 0x5b7(%rsp), %al
andb $0x1, %al
addq $0x5b8, %rsp            # imm = 0x5B8
retq
leaq 0x390(%rsp), %rdi
callq 0x5100
movq 0x388(%rsp), %rdi
callq 0x57b0
nopw %cs:(%rax,%rax)
nopl (%rax)