// File: schneebergerlab[P]DrLink/sample_molecule.cpp
// Function: read_msize_dist(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*, std::map<int, unsigned long, std::less<int>, std::allocator<std::pair<int const, unsigned long>>>*)
bool read_msize_dist(string msfile, map<int, unsigned long>* mNum, map<int, unsigned long>* mNum_intersec)
{
    ifstream ifp;
    ifp.open(msfile.c_str(), ios::in);
    if(!ifp.is_open())
    {
        cout << "   Error: cannot open file " << msfile << endl;
        return false;
    }
    cout << "   Info: reading molecule size distribution from " << msfile << 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;
        int           key = atoi(lineinfo[0].c_str());
        unsigned long len = strtoul(lineinfo[lineinfo.size()-1].c_str(), NULL, 0);
        //
        map<int, unsigned long>::iterator itr;
        itr = (*mNum).find(key);
        if(itr != (*mNum).end() )
        {
            cout << "   Warning: skipping repeated line: " << line << endl;
            continue;
        }
        else
        {
            (*mNum).insert(std::pair<int, unsigned long>(key, len));
        }
        //
        itr = (*mNum_intersec).find(key);
        if(itr != (*mNum_intersec).end())
        {
            if((*itr).second > len)
            {
                // replace with lower value
                (*itr).second = len;
            }
        }
        else
        {
            (*mNum_intersec).insert(std::pair<int, unsigned long>(key, len));
        }
    }
    ifp.close();
    cout << "   Info: reading done. " << endl;
    return true;
}

// Assembly:
subq $0x3b8, %rsp            # imm = 0x3B8
movq %rdi, 0xb8(%rsp)
movq %rdi, 0x3a8(%rsp)
movq %rsi, 0x3a0(%rsp)
movq %rdx, 0x398(%rsp)
leaq 0x190(%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 0x41480
leaq 0x190(%rsp), %rdi
callq 0x56f0
movb %al, 0xb7(%rsp)
jmp 0x41496
movb 0xb7(%rsp), %al
testb $0x1, %al
jne 0x4152a
jmp 0x414a7
movq 0x43b1a(%rip), %rdi     # 0x84fc8
leaq 0x256a1(%rip), %rsi     # 0x66b56
callq 0x5460
movq %rax, 0xa8(%rsp)
jmp 0x414c4
movq 0xb8(%rsp), %rsi
movq 0xa8(%rsp), %rdi
callq 0x53e0
movq %rax, 0xa0(%rsp)
jmp 0x414e3
movq 0xa0(%rsp), %rdi
movq 0x43abe(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x414f9
movb $0x0, 0x3b7(%rsp)
movl $0x1, 0x180(%rsp)
jmp 0x41a3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x41a5c
movq 0x43a97(%rip), %rdi     # 0x84fc8
leaq 0x2909b(%rip), %rsi     # 0x6a5d3
callq 0x5460
movq %rax, 0x98(%rsp)
jmp 0x41547
movq 0xb8(%rsp), %rsi
movq 0x98(%rsp), %rdi
callq 0x53e0
movq %rax, 0x90(%rsp)
jmp 0x41566
movq 0x90(%rsp), %rdi
movq 0x43a3b(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x4157c
jmp 0x4157e
movq 0x190(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x190(%rsp,%rax), %rdi
callq 0x5760
movb %al, 0x8f(%rsp)
jmp 0x415a0
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0x415b0
jmp 0x419f1
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x57c0
movq 0x80(%rsp), %rdx
leaq 0x295c0(%rip), %rsi     # 0x6ab94
leaq 0x160(%rsp), %rdi
callq 0x6880
jmp 0x415e3
leaq 0x15f(%rsp), %rdi
callq 0x54d0
leaq 0x190(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x50c0
jmp 0x41607
leaq 0x160(%rsp), %rdi
callq 0x5310
cmpq $0x0, %rax
je 0x4163f
xorl %eax, %eax
movl %eax, %esi
leaq 0x160(%rsp), %rdi
callq 0x5880
movq %rax, 0x78(%rsp)
jmp 0x41632
movq 0x78(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x4168e
movl $0x2, 0x180(%rsp)
jmp 0x419be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x15f(%rsp), %rdi
callq 0x54d0
jmp 0x41a5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x419e2
movb $0x9, 0x13f(%rsp)
leaq 0x140(%rsp), %rdi
leaq 0x160(%rsp), %rsi
leaq 0x13f(%rsp), %rdx
callq 0x60790
jmp 0x416b5
leaq 0x140(%rsp), %rdi
callq 0xfbb0
cmpq $0x2, %rax
jae 0x416d8
movl $0x2, 0x180(%rsp)
jmp 0x419b1
xorl %eax, %eax
movl %eax, 0x6c(%rsp)
movl %eax, %esi
movq %rsi, 0x60(%rsp)
leaq 0x140(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x88f0
movq %rax, %rdi
callq 0x51d0
movq %rax, %rdi
callq 0x56a0
movq 0x58(%rsp), %rdi
movl %eax, 0x138(%rsp)
callq 0xfbb0
movq 0x58(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x88f0
movq %rax, %rdi
callq 0x51d0
movq 0x60(%rsp), %rsi
movl 0x6c(%rsp), %edx
movq %rax, %rdi
callq 0x5160
movq %rax, 0x130(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x106c0
movq 0x3a0(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x10250
movq %rax, 0x70(%rsp)
jmp 0x41772
movq 0x70(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x3a0(%rsp), %rdi
callq 0x102a0
movq %rax, 0x118(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x10740
testb $0x1, %al
jne 0x417bf
jmp 0x4183b
movq 0x43802(%rip), %rdi     # 0x84fc8
leaq 0x28e38(%rip), %rsi     # 0x6a605
callq 0x5460
movq %rax, 0x50(%rsp)
jmp 0x417d9
movq 0x50(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x53e0
movq %rax, 0x48(%rsp)
jmp 0x417f2
movq 0x48(%rsp), %rdi
movq 0x437b2(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x41805
movl $0x2, 0x180(%rsp)
jmp 0x419b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x8910
jmp 0x419e2
movq 0x3a0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x458d0
jmp 0x41867
movq 0x40(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x102d0
movb %dl, 0x37(%rsp)
movq %rax, 0x38(%rsp)
jmp 0x41884
movb 0x37(%rsp), %al
movq 0x38(%rsp), %rcx
movq %rcx, 0xf8(%rsp)
movb %al, 0x100(%rsp)
movq 0x398(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x10250
movq %rax, 0x28(%rsp)
jmp 0x418b8
movq 0x28(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x398(%rsp), %rdi
callq 0x102a0
movq %rax, 0xe8(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x10740
testb $0x1, %al
jne 0x41905
jmp 0x41945
leaq 0x128(%rsp), %rdi
callq 0x10380
movq 0x8(%rax), %rax
cmpq 0x130(%rsp), %rax
jbe 0x41943
movq 0x130(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x10380
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x419a6
movq 0x398(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x458d0
jmp 0x41971
movq 0x18(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x102d0
movb %dl, 0xf(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x4198e
movb 0xf(%rsp), %al
movq 0x10(%rsp), %rcx
movq %rcx, 0xc8(%rsp)
movb %al, 0xd0(%rsp)
movl $0x0, 0x180(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x8910
leaq 0x160(%rsp), %rdi
callq 0x58b8
movl 0x180(%rsp), %eax
testl %eax, %eax
je 0x419dd
jmp 0x419d8
jmp 0x4157e
jmp 0x4157e
leaq 0x160(%rsp), %rdi
callq 0x58b8
jmp 0x41a5c
leaq 0x190(%rsp), %rdi
callq 0x50d0
jmp 0x41a00
movq 0x435c1(%rip), %rdi     # 0x84fc8
leaq 0x28c1c(%rip), %rsi     # 0x6a62a
callq 0x5460
movq %rax, (%rsp)
jmp 0x41a19
movq (%rsp), %rdi
movq 0x4358c(%rip), %rsi     # 0x84fb0
callq 0x54b0
jmp 0x41a2b
movb $0x1, 0x3b7(%rsp)
movl $0x1, 0x180(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x5100
movb 0x3b7(%rsp), %al
andb $0x1, %al
addq $0x3b8, %rsp            # imm = 0x3B8
retq
leaq 0x190(%rsp), %rdi
callq 0x5100
movq 0x188(%rsp), %rdi
callq 0x57b0
nopw %cs:(%rax,%rax)