// File: 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
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movl -0x14(%rbp), %esi
callq 0x18600
movq 0x18(%rax), %rax
movl %eax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x270b0
movl (%rax), %eax
movl %eax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x270f0
movq %rax, %rdi
leaq -0x20(%rbp), %rsi
callq 0x270b0
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0xe0, %rdi
callq 0xeab0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movl -0x14(%rbp), %esi
callq 0x18600
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movl -0x14(%rbp), %esi
callq 0x18600
movq %rax, %rcx
movl -0x7c(%rbp), %eax
xorl %edx, %edx
divl 0x28(%rcx)
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movl -0x14(%rbp), %esi
callq 0x18600
movq %rax, %rcx
movl -0x78(%rbp), %eax
imull 0x2c(%rcx), %eax
movl %eax, -0x48(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movl -0x14(%rbp), %esi
callq 0x18600
movq %rax, %rcx
movl -0x74(%rbp), %eax
xorl %edx, %edx
divl 0x28(%rcx)
addl -0x48(%rbp), %edx
movl %edx, -0x48(%rbp)
movl -0x48(%rbp), %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x64(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x27160
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %esi
leaq -0x49(%rbp), %rdx
callq 0x27130
movq -0x8(%rbp), %rdi
callq 0x27180
movq %rax, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x27070
movq -0x30(%rbp), %rax
movsbl (%rax), %edi
callq 0x40a0
cmpl $0x0, %eax
je 0x27040
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x27019
movq -0x30(%rbp), %rsi
movq -0x58(%rbp), %rdi
callq 0x271a0
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x27019
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)