// File: 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:
subq $0x468, %rsp            # imm = 0x468
movq %rdi, 0xc8(%rsp)
movq %rdi, 0x458(%rsp)
movq %rsi, 0x450(%rsp)
movq %rdx, 0x448(%rsp)
movq %rcx, 0x440(%rsp)
leaq 0x238(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x5500
movq 0xc8(%rsp), %rdi
callq 0x51d0
movq 0xd0(%rsp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x52c0
jmp 0x4fe28
leaq 0x238(%rsp), %rdi
callq 0x56f0
movb %al, 0xc7(%rsp)
jmp 0x4fe3e
movb 0xc7(%rsp), %al
testb $0x1, %al
jne 0x4fed2
jmp 0x4fe4f
movq 0x35172(%rip), %rdi     # 0x84fc8
leaq 0x16cf9(%rip), %rsi     # 0x66b56
callq 0x5460
movq %rax, 0xb8(%rsp)
jmp 0x4fe6c
movq 0xc8(%rsp), %rsi
movq 0xb8(%rsp), %rdi
callq 0x53e0
movq %rax, 0xb0(%rsp)
jmp 0x4fe8b
movq 0xb0(%rsp), %rdi
movq 0x35116(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x4fea1
movb $0x0, 0x467(%rsp)
movl $0x1, 0x228(%rsp)
jmp 0x505ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
jmp 0x505d8
movq 0x350ef(%rip), %rdi     # 0x84fc8
leaq 0x1a762(%rip), %rsi     # 0x6a642
callq 0x5460
movq %rax, 0xa8(%rsp)
jmp 0x4feef
movq 0xc8(%rsp), %rsi
movq 0xa8(%rsp), %rdi
callq 0x53e0
movq %rax, 0xa0(%rsp)
jmp 0x4ff0e
movq 0xa0(%rsp), %rdi
movq 0x35093(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x4ff24
movb $0x1, 0x227(%rsp)
movq 0x238(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x238(%rsp,%rax), %rdi
callq 0x5760
movb %al, 0x9f(%rsp)
jmp 0x4ff4e
movb 0x9f(%rsp), %al
testb $0x1, %al
jne 0x4ff5e
jmp 0x5056d
leaq 0x1ff(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x57c0
movq 0x90(%rsp), %rdx
leaq 0x1ac12(%rip), %rsi     # 0x6ab94
leaq 0x200(%rsp), %rdi
callq 0x6880
jmp 0x4ff91
leaq 0x1ff(%rsp), %rdi
callq 0x54d0
leaq 0x238(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x50c0
jmp 0x4ffb5
leaq 0x200(%rsp), %rdi
callq 0x5310
cmpq $0x0, %rax
je 0x4fff3
xorl %eax, %eax
movl %eax, %esi
leaq 0x200(%rsp), %rdi
callq 0x5880
movq %rax, 0x88(%rsp)
jmp 0x4ffe3
movq 0x88(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x50042
movl $0x2, 0x228(%rsp)
jmp 0x50520
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
leaq 0x1ff(%rsp), %rdi
callq 0x54d0
jmp 0x505d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
jmp 0x5055e
movb $0x9, 0x1df(%rsp)
leaq 0x1e0(%rsp), %rdi
leaq 0x200(%rsp), %rsi
leaq 0x1df(%rsp), %rdx
callq 0x60790
jmp 0x50069
leaq 0x1e0(%rsp), %rdi
callq 0xfbb0
cmpq $0x2, %rax
jae 0x5008c
movl $0x2, 0x228(%rsp)
jmp 0x50513
xorl %eax, %eax
movl %eax, %esi
leaq 0x1e0(%rsp), %rdi
callq 0x88f0
movq %rax, %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x51f0
jmp 0x500af
leaq 0x1e0(%rsp), %rdi
movl $0x1, %esi
callq 0x88f0
movq %rax, %rdi
callq 0x51d0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x5160
movq %rax, 0x1b0(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x51d0
movq %rax, %rdi
callq 0x5570
movsd 0x16fb4(%rip), %xmm1    # 0x670b0
ucomisd %xmm1, %xmm0
jbe 0x50196
movb 0x227(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x50186
movb $0x0, 0x227(%rsp)
movq 0x34ea2(%rip), %rdi     # 0x84fc8
leaq 0x1aa9c(%rip), %rsi     # 0x6abc9
callq 0x5460
movq %rax, 0x80(%rsp)
jmp 0x5013c
movq 0x80(%rsp), %rdi
movq 0x34e65(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x50152
jmp 0x50186
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
jmp 0x50551
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
jmp 0x50544
movl $0x2, 0x228(%rsp)
jmp 0x50506
leaq 0x1a8(%rsp), %rdi
callq 0x10810
movq 0x450(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x10110
movq %rax, 0x78(%rsp)
jmp 0x501bf
movq 0x78(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq 0x450(%rsp), %rdi
callq 0x10160
movq %rax, 0x198(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x10860
testb $0x1, %al
jne 0x5020c
jmp 0x50262
movq 0x34db5(%rip), %rdi     # 0x84fc8
leaq 0x1a3eb(%rip), %rsi     # 0x6a605
callq 0x5460
movq %rax, 0x70(%rsp)
jmp 0x50226
movq 0x70(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x53e0
movq %rax, 0x68(%rsp)
jmp 0x5023f
movq 0x68(%rsp), %rdi
movq 0x34d65(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x50252
movl $0x2, 0x228(%rsp)
jmp 0x50506
movq 0x450(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x170(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0x1b0(%rsp), %rdx
callq 0x45900
jmp 0x5028e
movq 0x60(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x10190
movb %dl, 0x57(%rsp)
movq %rax, 0x58(%rsp)
jmp 0x502ab
movb 0x57(%rsp), %al
movq 0x58(%rsp), %rcx
movq %rcx, 0x160(%rsp)
movb %al, 0x168(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x10220
jmp 0x502f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x10220
jmp 0x50544
movq 0x448(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x10110
movq %rax, 0x48(%rsp)
jmp 0x50314
movq 0x48(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq 0x448(%rsp), %rdi
callq 0x10160
movq %rax, 0x150(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x10860
testb $0x1, %al
jne 0x50361
jmp 0x503cc
leaq 0x1a8(%rsp), %rdi
callq 0x10230
movq 0x20(%rax), %rax
cmpq 0x1b0(%rsp), %rax
jbe 0x5039f
movq 0x1b0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x10230
movq 0x40(%rsp), %rcx
movq %rcx, 0x20(%rax)
movq 0x440(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x105d0
movq %rax, 0x38(%rsp)
jmp 0x503bb
movq 0x38(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x504fb
movq 0x448(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0x1b0(%rsp), %rdx
callq 0x45900
jmp 0x503f8
movq 0x30(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x10190
movb %dl, 0x27(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x50415
movb 0x27(%rsp), %al
movq 0x28(%rsp), %rcx
movq %rcx, 0x118(%rsp)
movb %al, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x10220
movq 0x440(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0x1, 0xec(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0xec(%rsp), %rdx
callq 0x10580
jmp 0x50471
movq 0x18(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x10530
movb %dl, 0xf(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x5048e
movb 0xf(%rsp), %al
movq 0x10(%rsp), %rcx
movq %rcx, 0xd8(%rsp)
movb %al, 0xe0(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x105c0
jmp 0x504fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x10220
jmp 0x50544
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x105c0
jmp 0x50544
movl $0x0, 0x228(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x58b8
leaq 0x1e0(%rsp), %rdi
callq 0x8910
leaq 0x200(%rsp), %rdi
callq 0x58b8
movl 0x228(%rsp), %eax
testl %eax, %eax
je 0x5053f
jmp 0x5053a
jmp 0x4ff2c
jmp 0x4ff2c
leaq 0x1b8(%rsp), %rdi
callq 0x58b8
leaq 0x1e0(%rsp), %rdi
callq 0x8910
leaq 0x200(%rsp), %rdi
callq 0x58b8
jmp 0x505d8
leaq 0x238(%rsp), %rdi
callq 0x50d0
jmp 0x5057c
movq 0x34a45(%rip), %rdi     # 0x84fc8
leaq 0x1a0a0(%rip), %rsi     # 0x6a62a
callq 0x5460
movq %rax, (%rsp)
jmp 0x50595
movq (%rsp), %rdi
movq 0x34a10(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x505a7
movb $0x1, 0x467(%rsp)
movl $0x1, 0x228(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x5100
movb 0x467(%rsp), %al
andb $0x1, %al
addq $0x468, %rsp            # imm = 0x468
retq
leaq 0x238(%rsp), %rdi
callq 0x5100
movq 0x230(%rsp), %rdi
callq 0x57b0
nopw %cs:(%rax,%rax)