// File: /workspace/github_cpp_makefile_star2_O3/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 0xea68
movq 0x3d5b3(%rip), %rdi     # 0x4bfc8
leaq 0x2c600(%rip), %rsi     # 0x3b01c
movl $0x24, %edx
callq 0x43a0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x3d594(%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 0xed82
movq 0x3d559(%rip), %r15     # 0x4bfc8
leaq 0x2c5cb(%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 0x3d527(%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 0xece1
leaq 0x20(%rsp), %r13
leaq 0x8(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x30029(%rip), %r15     # 0x3eb0a
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)
movq 0x10(%rsp), %rdi
je 0xecb5
cmpb $0x23, (%rdi)
je 0xecb5
movb $0x9, 0x50(%rsp)
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
leaq 0x50(%rsp), %rdx
callq 0x367c0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
subq %rsi, %rax
cmpq $0x21, %rax
jb 0xeca6
movq %rbx, %rdi
callq 0xee9e
cmpq 0x48(%rsp), %rax
je 0xebc1
movl $0x1a, %edx
movq 0x3d445(%rip), %rdi     # 0x4bfc8
leaq 0x2c4ed(%rip), %rsi     # 0x3b077
callq 0x43a0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x3d428(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0xec93
movq 0x30(%rsp), %rsi
leaq 0x20(%rsi), %rdx
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
callq 0xee04
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xef28
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xec04
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xec20
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4340
movl $0x9, %edx
movq 0x3d39c(%rip), %rdi     # 0x4bfc8
leaq 0x2c28b(%rip), %rsi     # 0x3aebe
callq 0x43a0
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x3d37d(%rip), %rdi     # 0x4bfc8
callq 0x43a0
movq %rax, %rbp
movl $0xb, %edx
movq %rax, %rdi
leaq 0x2c409(%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 0x6aac
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0xecc7
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xb0(%rsp,%rax)
je 0xeae6
leaq 0x90(%rsp), %rdi
callq 0x40a0
movl 0xc(%rsp), %ebp
movq 0x3d2cf(%rip), %rdi     # 0x4bfc8
leaq 0x2c1be(%rip), %rsi     # 0x3aebe
movl $0x9, %edx
callq 0x43a0
movq 0x28(%rbx), %rsi
movq 0x3d2b3(%rip), %rdi     # 0x4bfc8
callq 0x4210
movq %rax, %rbx
leaq 0x2c36e(%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 0xee68
jmp 0xedc0
jmp 0xedbd
jmp 0xedbd
jmp 0xedd5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x6aac
jmp 0xedd8
jmp 0xedd0
jmp 0xedd0
movq %rax, %rbx
jmp 0xedef
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0xedef
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x90(%rsp), %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x45a0