// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x4390
movq (%r15), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x41e0
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
movl 0xb0(%rsp,%rax), %ebp
testl %ebp, %ebp
je 0xeb4c
movq 0x3d4cf(%rip), %rdi     # 0x4bfc8
leaq 0x2c51c(%rip), %rsi     # 0x3b01c
movl $0x24, %edx
callq 0x43a0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x3d4b0(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
jmp 0xee66
movq 0x3d475(%rip), %r15     # 0x4bfc8
leaq 0x2c4e7(%rip), %rsi     # 0x3b041
movl $0x29, %edx
movq %r15, %rdi
callq 0x43a0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq 0x3d443(%rip), %rdi     # 0x4bfc8
callq 0x4030
movq %rax, %rdi
callq 0x4220
movl %ebp, 0xc(%rsp)
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xb0(%rsp,%rax)
jne 0xedc5
leaq 0x20(%rsp), %r13
leaq 0x8(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x2ff5d(%rip), %r15     # 0x3eb22
leaq 0x10(%rsp), %r12
movq %r13, 0x10(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x5384
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x45c0
cmpq $0x0, 0x18(%rsp)
je 0xed94
movq 0x10(%rsp), %rax
cmpb $0x23, (%rax)
je 0xed94
movb $0x9, 0x50(%rsp)
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
leaq 0x50(%rsp), %rdx
callq 0x36b7c
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
subq %rsi, %rax
cmpq $0x21, %rax
jb 0xed8a
movq %rbx, %rdi
callq 0xef82
cmpq 0x48(%rsp), %rax
je 0xeca5
movl $0x1a, %edx
movq 0x3d361(%rip), %rdi     # 0x4bfc8
leaq 0x2c409(%rip), %rsi     # 0x3b077
callq 0x43a0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x3d344(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0xed77
movq 0x30(%rsp), %rsi
leaq 0x20(%rsi), %rdx
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
callq 0xeee8
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xf00c
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xece8
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xed04
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4340
movl $0x9, %edx
movq 0x3d2b8(%rip), %rdi     # 0x4bfc8
leaq 0x2c1a7(%rip), %rsi     # 0x3aebe
callq 0x43a0
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x3d299(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %rbp
movl $0xb, %edx
movq %rax, %rdi
leaq 0x2c325(%rip), %rsi     # 0x3b06b
callq 0x43a0
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
movq %rbp, %rdi
callq 0x43a0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
leaq 0x30(%rsp), %rdi
callq 0x6aa2
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0xedab
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xb0(%rsp,%rax)
je 0xebca
leaq 0x90(%rsp), %rdi
callq 0x40a0
movl 0xc(%rsp), %ebp
movq 0x3d1eb(%rip), %rdi     # 0x4bfc8
leaq 0x2c0da(%rip), %rsi     # 0x3aebe
movl $0x9, %edx
callq 0x43a0
movq 0x28(%rbx), %rsi
movq 0x3d1cf(%rip), %rdi     # 0x4bfc8
callq 0x4210
movq %rax, %rbx
leaq 0x2c28a(%rip), %rsi     # 0x3b092
movl $0x1e, %edx
movq %rax, %rdi
callq 0x43a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
testl %ebp, %ebp
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 0xef4c
jmp 0xeea4
jmp 0xeea1
jmp 0xeea1
jmp 0xeeb9
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x6aa2
jmp 0xeebc
jmp 0xeeb4
jmp 0xeeb4
movq %rax, %rbx
jmp 0xeed3
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0xeed3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x90(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0