// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/read_chrsize.cpp
// Function: read_chrsize(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>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 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, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>*)
bool read_chrsize(string chrSizeFile, map<string, string>* chrSizes)
{
    ifstream fp;
    fp.open(chrSizeFile.c_str(), ios::in);
    if(!fp.good())
    {
        cout << "   Error: cannot open chr size file " << chrSizeFile << endl;
        return false;
    }
    bool verbose = true;
    // Chr15	1091291
    cout << "\n   Info: reading sizes of chromosomes..." << endl;
    while(fp.good())
    {
        string line("");
        getline(fp, line);
        if(line.size()==0 || line[0]=='#') continue;
        
        vector<string> lineinfo = split_string(line, '\t');
        if(lineinfo.size() < 2) continue;
        
        map<string, string>::iterator itr;
        itr = (*chrSizes).find(lineinfo[0]);
        if(itr == (*chrSizes).end())
        {
            (*chrSizes).insert(std::pair<string, string>(lineinfo[0], lineinfo[1]));
            if(verbose)
            cout << "   Info: " << lineinfo[0] << " with size " << lineinfo[1]    << endl;
        }
        else
        {
            cout << "   Warning: repeated info " <<  line << endl;
        }        
    }
    fp.close();
    cout << "   Info: " << (*chrSizes).size() << " chrs recorded with size info." << endl << endl;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x90(%rsp), %r15
movq %r15, %rdi
callq 0x4380
movq (%r14), %rsi
pushq $0x8
popq %rdx
movq %r15, %rdi
callq 0x4200
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
movl 0xb0(%rsp,%rax), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0xb1db
movq 0x31e11(%rip), %rdi     # 0x3cfc8
leaq 0x1ee46(%rip), %rsi     # 0x2a004
callq 0x4330
movq %rax, %rdi
movq %r14, %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
jmp 0xb387
movq 0x31de6(%rip), %rdi     # 0x3cfc8
leaq 0x1ee40(%rip), %rsi     # 0x2a029
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0x22914(%rip), %r14     # 0x2db1a
leaq 0x30(%rsp), %r15
leaq 0x50(%rsp), %r12
leaq 0x90(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xb0(%rsp,%rax)
jne 0xb33c
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x4d3e
movq %r13, %rdi
movq %r15, %rsi
callq 0x4090
cmpq $0x0, 0x38(%rsp)
je 0xb32f
movq 0x30(%rsp), %rax
cmpb $0x23, (%rax)
je 0xb32f
movb $0x9, 0x50(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x26120
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
cmpq $0x21, %rax
jb 0xb327
movq %rbx, %rdi
callq 0xb44c
cmpq 0x28(%rsp), %rax
je 0xb2bb
movq 0x31d1e(%rip), %rdi     # 0x3cfc8
leaq 0x1edae(%rip), %rsi     # 0x2a05f
callq 0x4330
movq %r15, %rsi
jmp 0xb317
movq 0x10(%rsp), %rsi
leaq 0x20(%rsi), %rdx
movq %r12, %rdi
callq 0xb400
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb4c2
movq %r12, %rdi
callq 0xb436
movq 0x31ce2(%rip), %rdi     # 0x3cfc8
leaq 0x1ebb9(%rip), %rsi     # 0x29ea6
callq 0x4330
movq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0x1ed4a(%rip), %rsi     # 0x2a053
callq 0x4330
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq %rbp, %rdi
callq 0x5d02
movq %r15, %rdi
callq 0x4638
jmp 0xb21d
leaq 0x90(%rsp), %rdi
callq 0x40a0
movq 0x31c78(%rip), %rdi     # 0x3cfc8
leaq 0x1eb4f(%rip), %rsi     # 0x29ea6
callq 0x4330
movq 0x28(%rbx), %rsi
movq %rax, %rdi
callq 0x4230
leaq 0x1ed0b(%rip), %rsi     # 0x2a07a
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
cmpl $0x0, 0xc(%rsp)
sete %bl
leaq 0x90(%rsp), %rdi
callq 0x40d0
movl %ebx, %eax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xb436
jmp 0xb3cc
jmp 0xb3c9
jmp 0xb3c9
jmp 0xb3e7
jmp 0xb3e7
jmp 0xb3d8
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5d02
jmp 0xb3db
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4638
jmp 0xb3ea
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0
nop