// File: /workspace/github_cpp_makefile_star2_O2/mshabbirhasan[P]ups-indel/include/seqan/seq_io/fai_index.h
// Function: int seqan::readRegion<seqan::SimpleType<unsigned char, seqan::Dna5_>, seqan::Alloc<void>>(seqan::String<seqan::SimpleType<unsigned char, seqan::Dna5_>, seqan::Alloc<void>>&, seqan::FaiIndex const&, unsigned int, unsigned int, unsigned int)
inline int readRegion(String<TValue, TSpec> & str,
                      FaiIndex const & index,
                      unsigned refId,
                      unsigned beginPos,
                      unsigned endPos)
{
    // Limit region to the infix, make sure that beginPos < endPos, compute character to read.
    unsigned seqLen = index.indexEntryStore[refId].sequenceLength;;
    beginPos = std::min(beginPos, seqLen);
    endPos = std::min(std::max(beginPos, endPos), seqLen);
    unsigned toRead = endPos - beginPos;

    typedef typename Iterator<String<char, MMap<> > const, Standard>::Type TSourceIter;
    typedef typename Iterator<String<TValue, TSpec>, Standard>::Type TTargetIter;
    TSourceIter itSource = begin(index.mmapString, Standard());
    __uint64 offset = index.indexEntryStore[refId].offset;
    // First, compute offset of the completely filled lines.
    unsigned numLines = beginPos / index.indexEntryStore[refId].lineLength;
    unsigned numBytes = numLines * index.indexEntryStore[refId].overallLineLength;
    // Then, compute overall offset by adding remaining bytes, too.
    numBytes += beginPos % index.indexEntryStore[refId].lineLength;
    offset += numBytes;
    // Advance iterator in MMap file.
    itSource += offset;

    // Copy out the characters from FASTA file and convert via iterator assignment to target string's type.
    resize(str, toRead, TValue());
    TTargetIter itTarget = begin(str, Standard());
    for (unsigned i = 0; i < toRead; )
    {
        if (isspace(*itSource))
        {
            ++itSource;
            continue;  // Skip spaces.
        }
        *itTarget = *itSource;
        ++itTarget;
        ++itSource;
        ++i;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %ebx
movl %ecx, %r15d
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, -0x48(%rbp)
leaq 0x30(%rsi), %r13
movq %r13, %rdi
movl %edx, %esi
movl %edx, -0x30(%rbp)
callq 0xc090
movl 0x18(%rax), %eax
cmpl %r15d, %eax
cmovbl %eax, %r15d
cmpl %ebx, %r15d
cmoval %r15d, %ebx
cmpl %eax, %ebx
cmovael %eax, %ebx
subl %r15d, %ebx
movq 0xe0(%r14), %r14
movq %r13, %rdi
movl %r12d, %esi
callq 0xc090
addq 0x20(%rax), %r14
movq %r14, -0x40(%rbp)
movq %r13, %rdi
movq %r13, -0x38(%rbp)
movl %r12d, %esi
callq 0xc090
movq %rax, %rcx
xorl %r12d, %r12d
movl %r15d, %eax
xorl %edx, %edx
divl 0x28(%rcx)
movl %eax, %r14d
movq %r13, %rdi
movl -0x30(%rbp), %r13d
movl %r13d, %esi
callq 0xc090
imull 0x2c(%rax), %r14d
movq -0x38(%rbp), %rdi
movl %r13d, %esi
callq 0xc090
movq %rax, %rcx
movl %r15d, %eax
xorl %edx, %edx
divl 0x28(%rcx)
movl %edx, %r15d
addl %r14d, %r15d
addq -0x40(%rbp), %r15
leaq -0x29(%rbp), %rdx
movb $0x0, (%rdx)
movq -0x48(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xcbc6
movq (%r14), %r13
cmpl %ebx, %r12d
je 0xcba2
movsbl (%r15), %r14d
movl %r14d, %edi
callq 0x3070
incq %r15
testl %eax, %eax
jne 0xcb75
movzbl %r14b, %eax
leaq 0xddd(%rip), %rcx       # 0xd970
movb (%rax,%rcx), %al
movb %al, (%r13)
incq %r13
incl %r12d
jmp 0xcb70
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq