LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamIndexFactory_p.cpp
// Function: BamTools::Internal::BamIndexFactory::FileExtension(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
const string BamIndexFactory::FileExtension(const string& filename) {

    // if filename cannot contain valid path + extension, return empty string
    if ( filename.empty() || filename.length() <= 4 )
        return string();

    // look for last dot in filename
    const size_t lastDotPosition = filename.find_last_of('.');

    // if none found, return empty string
    if ( lastDotPosition == string::npos )
        return string();

    // return substring from last dot position
    return filename.substr(lastDotPosition);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x4, 0x8(%rsi)
jbe 0x3d9da
movq %rsi, %r14
movq %rsi, %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x29210
cmpq $-0x1, %rax
je 0x3d9da
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x277f0
jmp 0x3d9ed
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamIndexFactory_p.cpp
// Function: BamTools::Internal::BamIndexFactory::FindIndexFilename(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, BamTools::BamIndex::IndexType const&)
const string BamIndexFactory::FindIndexFilename(const string& bamFilename,
                                                const BamIndex::IndexType& preferredType)
{
    // skip if BAM filename provided is empty
    if ( bamFilename.empty() )
        return string();

    // try to find index of preferred type first
    // return index filename if found
    string indexFilename = CreateIndexFilename(bamFilename, preferredType);
    if ( !indexFilename.empty() )
        return indexFilename;

    // couldn't find preferred type, try the other supported types
    // return index filename if found
    if ( preferredType != BamIndex::STANDARD ) {
        indexFilename = CreateIndexFilename(bamFilename, BamIndex::STANDARD);
        if ( !indexFilename.empty() )
            return indexFilename;
    }
    if ( preferredType != BamIndex::BAMTOOLS ) {
        indexFilename = CreateIndexFilename(bamFilename, BamIndex::BAMTOOLS);
        if ( !indexFilename.empty() )
            return indexFilename;
    }

    // otherwise couldn't find any index matching this filename
    return string();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpq $0x0, 0x8(%rsi)
je 0x3dabe
movq %rdx, %r15
movq %rsi, %r14
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x26660
movq 0x8(%r12), %rdx
testq %rdx, %rdx
je 0x3dae0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x8(%rsp), %rsi
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x267c0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3dad1
callq 0x27560
jmp 0x3dad1
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpl $0x1, (%r15)
jne 0x3db30
leaq 0x4(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x26660
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x26b80
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3db20
callq 0x27560
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
jne 0x3da92
jmp 0x3db82
leaq 0x4(%rsp), %rdx
movl $0x1, (%rdx)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x26660
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x26b80
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3db6a
callq 0x27560
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
jne 0x3da92
cmpl $0x0, (%r15)
jne 0x3dae6
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
jmp 0x3daa9
jmp 0x3db9e
jmp 0x3dbb8
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3dbbb
callq 0x27560
jmp 0x3dbbb
jmp 0x3dbb8
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3dbce
callq 0x27560
movq %rbx, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::RaiiWrapper::~RaiiWrapper()
BamStandardIndex::RaiiWrapper::~RaiiWrapper(void) {

    if ( Device ) {
        Device->Close();
        delete Device;
        Device = 0;
    }

    if ( Buffer ) {
        delete[] Buffer;
        Buffer = 0;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x3dc07
movq (%rdi), %rax
callq *0x10(%rax)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3dc00
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, (%rbx)
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x3dc1d
callq 0x27e60
movq $0x0, 0x8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::CloseFile()
void BamStandardIndex::CloseFile(void) {

    // close file stream
    if ( IsDeviceOpen() ) {
        m_resources.Device->Close();
        delete m_resources.Device;
        m_resources.Device = 0;
    }

    // clear index file summary data
    m_indexFileSummary.clear();

    // clean up I/O buffer
    delete[] m_resources.Buffer;
    m_resources.Buffer = 0;
    m_bufferLength = 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
testq %rdi, %rdi
je 0x3dd92
movq (%rdi), %rax
callq *0x50(%rax)
testb %al, %al
je 0x3dd92
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x3dd8a
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x58(%rbx)
movq 0x38(%rbx), %rax
cmpq %rax, 0x40(%rbx)
je 0x3dda0
movq %rax, 0x40(%rbx)
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x3ddae
callq 0x27e60
movq $0x0, 0x60(%rbx)
movl $0x0, 0x50(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::AdjustRegion(BamTools::BamRegion const&, unsigned int&, unsigned int&)
void BamStandardIndex::AdjustRegion(const BamRegion& region, uint32_t& begin, uint32_t& end) {

    // retrieve references from reader
    const RefVector& references = m_reader->GetReferenceData();

    // LeftPosition cannot be greater than or equal to reference length
    if ( region.LeftPosition >= references.at(region.LeftRefID).RefLength )
        throw BamException("BamStandardIndex::AdjustRegion", "invalid region requested");

    // set region 'begin'
    begin = (unsigned int)region.LeftPosition;

    // if right bound specified AND left&right bounds are on same reference
    // OK to use right bound position as region 'end'
    if ( region.isRightBoundSpecified() && ( region.LeftRefID == region.RightRefID ) )
        end = (unsigned int)region.RightPosition;

    // otherwise, set region 'end' to last reference base
    else end = (unsigned int)references.at(region.LeftRefID).RefLength;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r14
movq 0x8(%rdi), %rdi
callq 0x27c20
movslq (%r14), %rsi
movq (%rax), %rcx
movq 0x8(%rax), %rax
subq %rcx, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rdx
cmpq %rsi, %rdx
jbe 0x3de85
movl 0x4(%r14), %eax
leaq (%rsi,%rsi,4), %rsi
cmpl 0x20(%rcx,%rsi,8), %eax
jge 0x3de93
movl %eax, (%r15)
movl (%r14), %eax
movl 0x8(%r14), %edi
testl %edi, %edi
setns %r8b
movl 0xc(%r14), %esi
testl %esi, %esi
setg %r9b
andb %r8b, %r9b
cmpl %edi, %eax
sete %dil
testb %dil, %r9b
jne 0x3de76
movslq %eax, %rsi
cmpq %rsi, %rdx
jbe 0x3de85
leaq (%rsi,%rsi,4), %rax
movl 0x20(%rcx,%rax,8), %esi
movl %esi, (%rbx)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17416(%rip), %rdi     # 0x552a2
xorl %eax, %eax
callq 0x284e0
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x17fe0(%rip), %rsi     # 0x55e90
leaq 0x17ff7(%rip), %rdx     # 0x55eae
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x187f2(%rip), %rsi     # 0x566c2
leaq 0x18803(%rip), %rdx     # 0x566da
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2d03b(%rip), %rsi     # 0x6af38
movq 0x2d074(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x3df1e
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3df2c
callq 0x27560
testb %bpl, %bpl
jne 0x3df49
jmp 0x3df51
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3df49
callq 0x27560
jmp 0x3df49
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::CalculateCandidateBins(unsigned int const&, unsigned int const&, std::set<unsigned short, std::less<unsigned short>, std::allocator<unsigned short>>&)
void BamStandardIndex::CalculateCandidateBins(const uint32_t& begin,
                                              const uint32_t& end,
                                              set<uint16_t>& candidateBins)
{
    // initialize list, bin '0' is always a valid bin
    candidateBins.insert(0);

    // get rest of bins that contain this region
    unsigned int k;
    for (k =    1 + (begin>>26); k <=    1 + (end>>26); ++k) { candidateBins.insert(k); }
    for (k =    9 + (begin>>23); k <=    9 + (end>>23); ++k) { candidateBins.insert(k); }
    for (k =   73 + (begin>>20); k <=   73 + (end>>20); ++k) { candidateBins.insert(k); }
    for (k =  585 + (begin>>17); k <=  585 + (end>>17); ++k) { candidateBins.insert(k); }
    for (k = 4681 + (begin>>14); k <= 4681 + (end>>14); ++k) { candidateBins.insert(k); }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
leaq 0x16(%rsp), %rsi
movw $0x0, (%rsi)
movq %rcx, %rdi
callq 0x272f0
movl (%r15), %ebp
movl %ebp, %r13d
shrl $0x1a, %r13d
movl (%r14), %eax
movl %eax, %ecx
shrl $0x1a, %ecx
cmpl %ecx, %r13d
ja 0x3dfc9
decl %r13d
leaq 0x14(%rsp), %r12
leal 0x2(%r13), %eax
movw %ax, 0x14(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x272f0
movl (%r14), %eax
movl %eax, %ecx
shrl $0x1a, %ecx
incl %r13d
cmpl %ecx, %r13d
jb 0x3dfa2
movl (%r15), %ebp
movl %ebp, %r13d
shrl $0x17, %r13d
movl %eax, %ecx
shrl $0x17, %ecx
cmpl %ecx, %r13d
ja 0x3e00a
addl $0x8, %r13d
leaq 0x12(%rsp), %r12
incl %r13d
movw %r13w, 0x12(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x272f0
movl (%r14), %eax
movl %eax, %ecx
shrl $0x17, %ecx
addl $0x9, %ecx
cmpl %ecx, %r13d
jb 0x3dfe3
movl (%r15), %ebp
movl %ebp, %r13d
shrl $0x14, %r13d
movl %eax, %ecx
shrl $0x14, %ecx
cmpl %ecx, %r13d
ja 0x3e04b
addl $0x48, %r13d
leaq 0x10(%rsp), %r12
incl %r13d
movw %r13w, 0x10(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x272f0
movl (%r14), %eax
movl %eax, %ecx
shrl $0x14, %ecx
addl $0x49, %ecx
cmpl %ecx, %r13d
jb 0x3e024
movl (%r15), %ebp
movl %ebp, %r13d
shrl $0x11, %r13d
movl %eax, %ecx
shrl $0x11, %ecx
cmpl %ecx, %r13d
ja 0x3e092
addl $0x248, %r13d           # imm = 0x248
leaq 0xe(%rsp), %r12
incl %r13d
movw %r13w, 0xe(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x272f0
movl (%r14), %eax
movl %eax, %ecx
shrl $0x11, %ecx
addl $0x249, %ecx            # imm = 0x249
cmpl %ecx, %r13d
jb 0x3e068
movl (%r15), %ebp
shrl $0xe, %ebp
shrl $0xe, %eax
cmpl %eax, %ebp
ja 0x3e0c8
addl $0x1248, %ebp           # imm = 0x1248
leaq 0xc(%rsp), %r15
incl %ebp
movw %bp, 0xc(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x272f0
movl (%r14), %eax
shrl $0xe, %eax
addl $0x1249, %eax           # imm = 0x1249
cmpl %eax, %ebp
jb 0x3e0a7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadBinIntoBuffer(unsigned int&, int&)
void BamStandardIndex::ReadBinIntoBuffer(uint32_t& binId, int32_t& numAlignmentChunks) {

    // read bin header
    ReadBinID(binId);
    ReadNumAlignmentChunks(numAlignmentChunks);

    // read bin contents
    const unsigned int bytesRequested = numAlignmentChunks*BamStandardIndex::SIZEOF_ALIGNMENTCHUNK;
    ReadIntoBuffer(bytesRequested);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
callq 0x26f00
movq %r14, %rdi
movq %rbx, %rsi
callq 0x291d0
movl (%rbx), %eax
shll $0x4, %eax
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
movq %r14, %rdi
callq 0x27a40
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::CalculateMinOffset(BamTools::Internal::BaiReferenceSummary const&, unsigned int const&)
uint64_t BamStandardIndex::CalculateMinOffset(const BaiReferenceSummary& refSummary,
                                              const uint32_t& begin)
{
    // if no linear offsets exist, return 0
    if ( refSummary.NumLinearOffsets == 0 )
        return 0;

    // if 'begin' starts beyond last linear offset, use the last linear offset as minimum
    // else use the offset corresponding to the requested start position
    const int shiftedBegin = begin>>BamStandardIndex::BAM_LIDX_SHIFT;
    if ( shiftedBegin >= refSummary.NumLinearOffsets )
        return LookupLinearOffset( refSummary, refSummary.NumLinearOffsets-1 );
    else
        return LookupLinearOffset( refSummary, shiftedBegin );
}

// Assembly:
movl 0x4(%rsi), %eax
testl %eax, %eax
je 0x3e383
pushq %rax
movl (%rdx), %ecx
shrl $0xe, %ecx
movl %ecx, (%rsp)
cmpl %eax, %ecx
jge 0x3e386
movq %rsp, %rdx
jmp 0x3e38f
xorl %eax, %eax
retq
decl %eax
leaq 0x4(%rsp), %rdx
movl %eax, (%rdx)
callq 0x263d0
addq $0x8, %rsp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::CheckBufferSize(char*&, unsigned int&, unsigned int const&)
void BamStandardIndex::CheckBufferSize(char*& buffer,
                                       unsigned int& bufferLength,
                                       const unsigned int& requestedBytes)
{
    try {
        if ( requestedBytes > bufferLength ) {
            bufferLength = requestedBytes + 10;
            delete[] buffer;
            buffer = new char[bufferLength];
        }
    } catch ( std::bad_alloc&  ) {
        stringstream s("");
        s << "out of memory when allocating " << requestedBytes << " bytes";
        throw BamException("BamStandardIndex::CheckBufferSize", s.str());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movl (%rdx), %eax
cmpl (%rsi), %eax
jbe 0x3e415
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
addl $0xa, %eax
movl %eax, (%rsi)
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x3e40b
callq 0x27e60
movl (%r15), %eax
movl %eax, %edi
callq 0x26070
movq %rax, (%rbx)
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x3e57f
movq %rbx, %rdi
callq 0x267d0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x17a48(%rip), %rdx     # 0x55e8f
movq %rsp, %rdi
movq %rdx, %rsi
callq 0x26750
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
movl $0x18, %edx
callq 0x28740
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3e472
callq 0x27560
leaq 0x50(%rsp), %rbx
leaq 0x17a31(%rip), %rsi     # 0x55eaf
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x27a70
movl (%r14), %esi
movq %rbx, %rdi
callq 0x26fb0
leaq 0x18d7e(%rip), %rsi     # 0x5721b
movl $0x6, %edx
movq %rax, %rdi
callq 0x27a70
movl $0x28, %edi
callq 0x269d0
movq %rax, %r14
movq %rsp, %rdi
movq %r15, (%rdi)
leaq 0x17a0a(%rip), %rsi     # 0x55ece
leaq 0x17a24(%rip), %rdx     # 0x55eef
callq 0x26750
leaq 0x58(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x28730
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %r14, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2ca3d(%rip), %rsi     # 0x6af38
movq 0x2ca76(%rip), %rdx     # 0x6af78
movq %r14, %rdi
callq 0x28a20
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3e520
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3e52e
callq 0x27560
testb %bpl, %bpl
jne 0x3e54b
jmp 0x3e558
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3e54b
callq 0x27560
jmp 0x3e54b
movq %rax, %rbx
movq %r14, %rdi
callq 0x27070
jmp 0x3e558
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x270d0
jmp 0x3e57a
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3e57a
callq 0x27560
jmp 0x3e57a
movq %rax, %rbx
callq 0x287d0
movq %rbx, %rdi
callq 0x28c10
movq %rax, %rdi
callq 0x2f047
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::CheckMagicNumber()
void BamStandardIndex::CheckMagicNumber(void) {

    // check 'magic number' to see if file is BAI index
    char magic[4];
    const int64_t numBytesRead = m_resources.Device->Read(magic, sizeof(magic));
    if ( numBytesRead != 4 )
        throw BamException("BamStandardIndex::CheckMagicNumber", "could not read BAI magic number");

    // compare to expected value
    if ( strncmp(magic, BamStandardIndex::BAI_MAGIC, 4) != 0 )
        throw BamException("BamStandardIndex::CheckMagicNumber", "invalid BAI magic number");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
callq *0x28(%rax)
cmpq $0x4, %rax
jne 0x3e787
cmpl $0x1494142, 0xc(%rsp)   # imm = 0x1494142
jne 0x3e806
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1774c(%rip), %rsi     # 0x55ef0
leaq 0x17767(%rip), %rdx     # 0x55f12
leaq 0x10(%rsp), %rdi
callq 0x26750
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1774d(%rip), %rsi     # 0x55f13
leaq 0x17765(%rip), %rdx     # 0x55f32
leaq 0x30(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2c743(%rip), %rsi     # 0x6af38
movq 0x2c77c(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
jmp 0x3e883
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x176cd(%rip), %rsi     # 0x55ef0
leaq 0x176e8(%rip), %rdx     # 0x55f12
leaq 0x10(%rsp), %rdi
callq 0x26750
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x176ee(%rip), %rsi     # 0x55f33
leaq 0x176ff(%rip), %rdx     # 0x55f4b
leaq 0x30(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2c6c4(%rip), %rsi     # 0x6af38
movq 0x2c6fd(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
jmp 0x3e887
jmp 0x3e8af
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x3e899
callq 0x27560
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x3e8a8
callq 0x27560
testb %bpl, %bpl
jne 0x3e8c8
jmp 0x3e8d0
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x3e8c8
callq 0x27560
jmp 0x3e8c8
jmp 0x3e8c5
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::WriteHeader()
void BamStandardIndex::WriteHeader(void) {

    int64_t numBytesWritten = 0;

    // write magic number
    numBytesWritten += m_resources.Device->Write(BamStandardIndex::BAI_MAGIC, 4);

    // write number of reference sequences
    int32_t numReferences = m_indexFileSummary.size();
    if ( m_isBigEndian ) SwapEndian_32(numReferences);
    numBytesWritten += m_resources.Device->Write((const char*)&numReferences, sizeof(numReferences));

    if ( numBytesWritten != sizeof(numReferences)+4 )
        throw BamException("BamStandardIndex::WriteHeader", "could not write BAI header");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
leaq 0x165e2(%rip), %rsi     # 0x55e8b
movl $0x4, %edx
callq *0x40(%rax)
movq %rax, %rbx
movq 0x40(%r14), %rax
subq 0x38(%r14), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x30(%r14)
jne 0x3f8f9
movl %eax, %ecx
sarl $0x18, %ecx
movl %eax, %edx
shll $0x8, %edx
andl $0xff0000, %edx         # imm = 0xFF0000
movl %eax, %esi
shrl $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
shll $0x18, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movl %eax, 0xc(%rsp)
movq 0x58(%r14), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
callq *0x40(%rax)
addq %rbx, %rax
cmpq $0x8, %rax
jne 0x3f923
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x16a75(%rip), %rsi     # 0x563b5
leaq 0x16a8b(%rip), %rdx     # 0x563d2
leaq 0x10(%rsp), %rdi
callq 0x26750
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x16a71(%rip), %rsi     # 0x563d3
leaq 0x16a84(%rip), %rdx     # 0x563ed
leaq 0x30(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2b5a7(%rip), %rsi     # 0x6af38
movq 0x2b5e0(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x3f9b2
callq 0x27560
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x3f9c1
callq 0x27560
testb %bpl, %bpl
jne 0x3f9df
jmp 0x3f9e7
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x3f9df
callq 0x27560
jmp 0x3f9df
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::SaveAlignmentChunkToBin(std::map<unsigned int, std::vector<BamTools::Internal::BaiAlignmentChunk, std::allocator<BamTools::Internal::BaiAlignmentChunk>>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, std::vector<BamTools::Internal::BaiAlignmentChunk, std::allocator<BamTools::Internal::BaiAlignmentChunk>>>>>&, unsigned int const&, unsigned long const&, unsigned long const&)
void BamStandardIndex::SaveAlignmentChunkToBin(BaiBinMap& binMap,
                                               const uint32_t& currentBin,
                                               const uint64_t& currentOffset,
                                               const uint64_t& lastOffset)
{
    // create new alignment chunk
    BaiAlignmentChunk newChunk(currentOffset, lastOffset);

    // if no entry exists yet for this bin, create one and store alignment chunk
    BaiBinMap::iterator binIter = binMap.find(currentBin);
    if ( binIter == binMap.end() ) {
        BaiAlignmentChunkVector newChunks;
        newChunks.push_back(newChunk);
        binMap.insert( pair<uint32_t, BaiAlignmentChunkVector>(currentBin, newChunks));
    }

    // otherwise, just append alignment chunk
    else {
        BaiAlignmentChunkVector& binChunks = (*binIter).second;
        binChunks.push_back( newChunk );
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq (%rcx), %rax
movq %rax, (%rsp)
movq (%r8), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsi), %rax
testq %rax, %rax
je 0x3fa44
leaq 0x8(%rbx), %rdx
movl (%r14), %ecx
movq %rdx, %rdi
xorl %esi, %esi
cmpl %ecx, 0x20(%rax)
setb %sil
cmovaeq %rax, %rdi
movq 0x10(%rax,%rsi,8), %rax
testq %rax, %rax
jne 0x3fa1f
cmpq %rdx, %rdi
je 0x3fa44
cmpl 0x20(%rdi), %ecx
jae 0x3fad0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rsp, %rdx
xorl %esi, %esi
callq 0x28540
movl (%r14), %eax
leaq 0x30(%rsp), %r14
movl %eax, -0x8(%r14)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x28200
movl 0x28(%rsp), %eax
leaq 0x50(%rsp), %rdi
movl %eax, -0x8(%rdi)
movq %r14, %rsi
callq 0x28200
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x28510
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3faaa
callq 0x27560
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3fab9
callq 0x27560
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3fac8
callq 0x27560
addq $0x68, %rsp
popq %rbx
popq %r14
retq
movq 0x30(%rdi), %rsi
cmpq 0x38(%rdi), %rsi
je 0x3fae8
movups (%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x30(%rdi)
jmp 0x3fac8
addq $0x28, %rdi
movq %rsp, %rdx
callq 0x28540
jmp 0x3fac8
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3fb0d
callq 0x27560
jmp 0x3fb0d
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3fb23
callq 0x27560
jmp 0x3fb23
jmp 0x3fb20
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3fb32
callq 0x27560
movq %rbx, %rdi
callq 0x28c10
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::SaveLinearOffsetEntry(std::vector<unsigned long, std::allocator<unsigned long>>&, int const&, int const&, unsigned long const&)
void BamStandardIndex::SaveLinearOffsetEntry(BaiLinearOffsetVector& offsets,
                                             const int& alignmentStartPosition,
                                             const int& alignmentStopPosition,
                                             const uint64_t& lastOffset)
{
    // get converted offsets
    const int beginOffset = alignmentStartPosition >> BamStandardIndex::BAM_LIDX_SHIFT;
    const int endOffset   = (alignmentStopPosition - 1) >> BamStandardIndex::BAM_LIDX_SHIFT;

    // resize vector if necessary
    int oldSize = offsets.size();
    int newSize = endOffset + 1;
    if ( oldSize < newSize )
        offsets.resize(newSize, 0);

    // store offset
    for( int i = beginOffset + 1; i <= endOffset; ++i ) {
        if ( offsets[i] == 0 )
            offsets[i] = lastOffset;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rsi, %r14
movl (%rdx), %ebp
sarl $0xe, %ebp
movl (%rcx), %r15d
decl %r15d
sarl $0xe, %r15d
movq 0x8(%rsi), %rax
subq (%rsi), %rax
shrq $0x3, %rax
cmpl %eax, %r15d
jl 0x3fba1
leal 0x1(%r15), %eax
movslq %eax, %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x26c30
cmpl %r15d, %ebp
jge 0x3fbc7
movq (%r14), %rax
movslq %ebp, %rcx
movslq %r15d, %rdx
cmpq $0x0, 0x8(%rax,%rcx,8)
jne 0x3fbbf
movq (%rbx), %rsi
movq %rsi, 0x8(%rax,%rcx,8)
incq %rcx
cmpq %rcx, %rdx
jne 0x3fbaf
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::HasAlignments(int const&) const
bool BamStandardIndex::HasAlignments(const int& referenceID) const {
    if ( referenceID < 0 || referenceID >= (int)m_indexFileSummary.size() )
        return false;
    const BaiReferenceSummary& refSummary = m_indexFileSummary.at(referenceID);
    return ( refSummary.NumBins > 0 );
}

// Assembly:
movslq (%rsi), %rsi
testq %rsi, %rsi
js 0x4005c
movq 0x38(%rdi), %rax
movq 0x40(%rdi), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpl %edx, %esi
jge 0x4005c
cmpq %rsi, %rdx
jbe 0x4005f
leaq (%rsi,%rsi,2), %rcx
cmpl $0x0, (%rax,%rcx,8)
setg %al
retq
xorl %eax, %eax
retq
pushq %rax
leaq 0x1523b(%rip), %rdi     # 0x552a2
xorl %eax, %eax
callq 0x284e0
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::Jump(BamTools::BamRegion const&, bool*)
bool BamStandardIndex::Jump(const BamRegion& region, bool* hasAlignmentsInRegion) {

    // clear out flag
    *hasAlignmentsInRegion = false;

    // skip if invalid reader or not open
    if ( m_reader == 0 || !m_reader->IsOpen() ) {
        SetErrorString("BamStandardIndex::Jump", "could not jump: reader is not open");
        return false;
    }

    // calculate nearest offset to jump to
    int64_t offset;
    try {
        GetOffset(region, offset, hasAlignmentsInRegion);
    } catch ( BamException& e ) {
        m_errorString = e.what();
        return false;
    }

    // if region has alignments, return success/fail of seeking there
    if ( *hasAlignmentsInRegion )
        return m_reader->Seek(offset);

    // otherwise, simply return true (but hasAlignmentsInRegion flag has been set to false)
    // (this is OK, BamReader will check this flag before trying to load data)
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movb $0x0, (%rdx)
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x400c6
movq %rdx, %r14
movq %rsi, %r15
callq 0x27b00
testb %al, %al
je 0x400c6
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x276e0
movb $0x1, %al
cmpb $0x1, (%r14)
jne 0x4013b
movq 0x8(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x27710
jmp 0x4013b
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15fa8(%rip), %rsi     # 0x5607e
leaq 0x15fb7(%rip), %rdx     # 0x56094
leaq 0x8(%rsp), %rdi
callq 0x26750
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15f9d(%rip), %rsi     # 0x56095
leaq 0x15fb8(%rip), %rdx     # 0x560b7
leaq 0x28(%rsp), %rdi
callq 0x26750
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x26370
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x4012a
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x40139
callq 0x27560
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %r14
cmpl $0x1, %edx
jne 0x401b3
movq %r14, %rdi
callq 0x267d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
addq $0x10, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x27ff0
callq 0x287d0
jmp 0x40139
movq %rax, %r14
callq 0x287d0
jmp 0x401b3
movq %rax, %rdi
callq 0x2f047
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x4019f
callq 0x27560
jmp 0x4019f
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x401b3
callq 0x27560
jmp 0x401b3
movq %rax, %r14
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool BamStandardIndex::Load(const std::string& filename) {

    try {

        // attempt to open file (read-only)
        OpenFile(filename, IBamIODevice::ReadOnly);

        // validate format
        CheckMagicNumber();

        // load in-memory summary of index data
        SummarizeIndexFile();

        // return success
        return true;

    } catch ( BamException& e ) {
        m_errorString = e.what();
        return false;
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x1, %edx
callq 0x28800
movq %rbx, %rdi
callq 0x27690
movb $0x1, %bpl
movq %rbx, %rdi
callq 0x28210
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
cmpl $0x1, %edx
jne 0x40220
movq %r14, %rdi
callq 0x267d0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
addq $0x10, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x27ff0
callq 0x287d0
xorl %ebp, %ebp
jmp 0x401e0
movq %rax, %r14
callq 0x287d0
movq %r14, %rdi
callq 0x28c10
movq %rax, %rdi
callq 0x2f047
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::SummarizeIndexFile()
void BamStandardIndex::SummarizeIndexFile(void) {

    // load number of reference sequences
    int numReferences;
    ReadNumReferences(numReferences);

    // initialize file summary data
    ReserveForSummary(numReferences);

    // iterate over reference entries
    BaiFileSummary::iterator summaryIter = m_indexFileSummary.begin();
    BaiFileSummary::iterator summaryEnd  = m_indexFileSummary.end();
    for ( int i = 0; summaryIter != summaryEnd; ++summaryIter, ++i )
        SummarizeReference(*summaryIter);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %rsi
callq 0x28ba0
leaq 0x38(%rbx), %rdi
movq 0x38(%rbx), %rax
cmpq %rax, 0x40(%rbx)
je 0x40258
movq %rax, 0x40(%rbx)
movslq 0xc(%rsp), %rsi
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
callq 0x28630
movq 0x38(%rbx), %r14
movq 0x40(%rbx), %r15
cmpq %r15, %r14
je 0x4029e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x27790
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26140
addq $0x18, %r14
jmp 0x4027d
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadLinearOffset(unsigned long&)
void BamStandardIndex::ReadLinearOffset(uint64_t& linearOffset) {
    const int64_t numBytesRead = m_resources.Device->Read((char*)&linearOffset, sizeof(linearOffset));
    if ( m_isBigEndian ) SwapEndian_64(linearOffset);
    if ( numBytesRead != sizeof(linearOffset) )
        throw BamException("BamStandardIndex::ReadLinearOffset", "could not read BAI linear offset");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
movl $0x8, %edx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x402d9
movq (%rbx), %rcx
bswapq %rcx
movq %rcx, (%rbx)
cmpq $0x8, %rax
jne 0x402ec
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15e50(%rip), %rsi     # 0x56159
leaq 0x15e6b(%rip), %rdx     # 0x5617b
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15e53(%rip), %rsi     # 0x5617c
leaq 0x15e6c(%rip), %rdx     # 0x5619c
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2abe2(%rip), %rsi     # 0x6af38
movq 0x2ac1b(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x40377
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x40385
callq 0x27560
testb %bpl, %bpl
jne 0x403a2
jmp 0x403aa
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x403a2
callq 0x27560
jmp 0x403a2
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadBinID(unsigned int&)
void BamStandardIndex::ReadBinID(uint32_t& binId) {
    const int64_t numBytesRead = m_resources.Device->Read((char*)&binId, sizeof(binId));
    if ( m_isBigEndian ) SwapEndian_32(binId);
    if ( numBytesRead != sizeof(binId) )
        throw BamException("BamStandardIndex::ReadBinID", "could not read BAI bin ID");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
movl $0x4, %edx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x404ca
movl (%rbx), %ecx
bswapl %ecx
movl %ecx, (%rbx)
cmpq $0x4, %rax
jne 0x404dd
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15bd9(%rip), %rsi     # 0x560d3
leaq 0x15bed(%rip), %rdx     # 0x560ee
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15bd5(%rip), %rsi     # 0x560ef
leaq 0x15be7(%rip), %rdx     # 0x56108
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2a9f1(%rip), %rsi     # 0x6af38
movq 0x2aa2a(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x40568
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x40576
callq 0x27560
testb %bpl, %bpl
jne 0x40593
jmp 0x4059b
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x40593
callq 0x27560
jmp 0x40593
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadNumAlignmentChunks(int&)
void BamStandardIndex::ReadNumAlignmentChunks(int& numAlignmentChunks) {
    const int64_t numBytesRead = m_resources.Device->Read((char*)&numAlignmentChunks, sizeof(numAlignmentChunks));
    if ( m_isBigEndian ) SwapEndian_32(numAlignmentChunks);
    if ( numBytesRead != sizeof(numAlignmentChunks) )
        throw BamException("BamStandardIndex::ReadNumAlignmentChunks", "could not read BAI chunk count");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
movl $0x4, %edx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x405f4
movl (%rbx), %ecx
movl %ecx, %edx
sarl $0x18, %edx
movl %ecx, %esi
shll $0x8, %esi
andl $0xff0000, %esi         # imm = 0xFF0000
movl %ecx, %edi
shrl $0x8, %edi
andl $0xff00, %edi           # imm = 0xFF00
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl %ecx, (%rbx)
cmpq $0x4, %rax
jne 0x40607
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15b79(%rip), %rsi     # 0x5619d
leaq 0x15b9a(%rip), %rdx     # 0x561c5
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15b82(%rip), %rsi     # 0x561c6
leaq 0x15b99(%rip), %rdx     # 0x561e4
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2a8c7(%rip), %rsi     # 0x6af38
movq 0x2a900(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x40692
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x406a0
callq 0x27560
testb %bpl, %bpl
jne 0x406bd
jmp 0x406c5
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x406bd
callq 0x27560
jmp 0x406bd
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadIntoBuffer(unsigned int const&)
void BamStandardIndex::ReadIntoBuffer(const unsigned int& bytesRequested) {

    // ensure that our buffer is big enough for request
    BamStandardIndex::CheckBufferSize(m_resources.Buffer, m_bufferLength, bytesRequested);

    // read from BAI file stream
    const int64_t bytesRead = m_resources.Device->Read(m_resources.Buffer, bytesRequested);
    if ( bytesRead != (int64_t)bytesRequested ) {
        stringstream s("");
        s << "expected to read: " << bytesRequested << " bytes, "
          << "but instead read: " << bytesRead;
        throw BamException("BamStandardIndex::ReadIntoBuffer", s.str());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rsi, %r14
movq %rdi, %rbx
addq $0x60, %rdi
leaq 0x50(%rbx), %rsi
movq %r14, %rdx
callq 0x263e0
movq 0x58(%rbx), %rdi
movq 0x60(%rbx), %rsi
movl (%r14), %edx
movq (%rdi), %rax
callq *0x28(%rax)
movq %rax, %rbx
movl (%r14), %eax
cmpq %rax, %rbx
jne 0x4071f
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1575f(%rip), %rdx     # 0x55e8f
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x26750
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x18, %edx
callq 0x28740
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x40760
callq 0x27560
leaq 0x58(%rsp), %r15
leaq 0x1599d(%rip), %rsi     # 0x56109
movl $0x12, %edx
movq %r15, %rdi
callq 0x27a70
movl (%r14), %esi
movq %r15, %rdi
callq 0x26fb0
movq %rax, %r14
leaq 0x1598e(%rip), %rsi     # 0x5611c
movl $0x8, %edx
movq %rax, %rdi
callq 0x27a70
leaq 0x15983(%rip), %rsi     # 0x56125
movl $0x12, %edx
movq %r14, %rdi
callq 0x27a70
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27570
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x15962(%rip), %rsi     # 0x56138
leaq 0x1597b(%rip), %rdx     # 0x56158
callq 0x26750
leaq 0x60(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x28730
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2a729(%rip), %rsi     # 0x6af38
movq 0x2a762(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40834
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x40843
callq 0x27560
testb %bpl, %bpl
jne 0x40861
jmp 0x4086e
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x40861
callq 0x27560
jmp 0x40861
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
jmp 0x4086e
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x270d0
jmp 0x40899
movq %rax, %rdi
callq 0x2f047
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x40899
callq 0x27560
jmp 0x40899
movq %rax, %r14
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadNumBins(int&)
void BamStandardIndex::ReadNumBins(int& numBins) {
    const int64_t numBytesRead = m_resources.Device->Read((char*)&numBins, sizeof(numBins));
    if ( m_isBigEndian ) SwapEndian_32(numBins);
    if ( numBytesRead != sizeof(numBins) )
        throw BamException("BamStandardIndex::ReadNumBins", "could not read BAI bin count");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
movl $0x4, %edx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x408f2
movl (%rbx), %ecx
movl %ecx, %edx
sarl $0x18, %edx
movl %ecx, %esi
shll $0x8, %esi
andl $0xff0000, %esi         # imm = 0xFF0000
movl %ecx, %edi
shrl $0x8, %edi
andl $0xff00, %edi           # imm = 0xFF00
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl %ecx, (%rbx)
cmpq $0x4, %rax
jne 0x40905
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x158c3(%rip), %rsi     # 0x561e5
leaq 0x158d9(%rip), %rdx     # 0x56202
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x158c1(%rip), %rsi     # 0x56203
leaq 0x158d6(%rip), %rdx     # 0x5621f
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2a5c9(%rip), %rsi     # 0x6af38
movq 0x2a602(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x40990
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x4099e
callq 0x27560
testb %bpl, %bpl
jne 0x409bb
jmp 0x409c3
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x409bb
callq 0x27560
jmp 0x409bb
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadNumLinearOffsets(int&)
void BamStandardIndex::ReadNumLinearOffsets(int& numLinearOffsets) {
    const int64_t numBytesRead = m_resources.Device->Read((char*)&numLinearOffsets, sizeof(numLinearOffsets));
    if ( m_isBigEndian ) SwapEndian_32(numLinearOffsets);
    if ( numBytesRead != sizeof(numLinearOffsets) )
        throw BamException("BamStandardIndex::ReadNumAlignmentChunks", "could not read BAI linear offset count");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
movl $0x4, %edx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x40a1c
movl (%rbx), %ecx
movl %ecx, %edx
sarl $0x18, %edx
movl %ecx, %esi
shll $0x8, %esi
andl $0xff0000, %esi         # imm = 0xFF0000
movl %ecx, %edi
shrl $0x8, %edi
andl $0xff00, %edi           # imm = 0xFF00
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl %ecx, (%rbx)
cmpq $0x4, %rax
jne 0x40a2f
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15751(%rip), %rsi     # 0x5619d
leaq 0x15772(%rip), %rdx     # 0x561c5
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x157b4(%rip), %rsi     # 0x56220
leaq 0x157d3(%rip), %rdx     # 0x56246
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2a49f(%rip), %rsi     # 0x6af38
movq 0x2a4d8(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x40aba
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x40ac8
callq 0x27560
testb %bpl, %bpl
jne 0x40ae5
jmp 0x40aed
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x40ae5
callq 0x27560
jmp 0x40ae5
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
nop
// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::ReadNumReferences(int&)
void BamStandardIndex::ReadNumReferences(int& numReferences) {
    const int64_t numBytesRead = m_resources.Device->Read((char*)&numReferences, sizeof(numReferences));
    if ( m_isBigEndian ) SwapEndian_32(numReferences);
    if ( numBytesRead != sizeof(numReferences) )
        throw BamException("BamStandardIndex::ReadNumReferences", "could not read reference count");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
movl $0x4, %edx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x40b46
movl (%rbx), %ecx
movl %ecx, %edx
sarl $0x18, %edx
movl %ecx, %esi
shll $0x8, %esi
andl $0xff0000, %esi         # imm = 0xFF0000
movl %ecx, %edi
shrl $0x8, %edi
andl $0xff00, %edi           # imm = 0xFF00
shll $0x18, %ecx
orl %edx, %ecx
orl %esi, %ecx
orl %edi, %ecx
movl %ecx, (%rbx)
cmpq $0x4, %rax
jne 0x40b59
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x156d1(%rip), %rsi     # 0x56247
leaq 0x156ed(%rip), %rdx     # 0x5626a
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x156d5(%rip), %rsi     # 0x5626b
leaq 0x156ec(%rip), %rdx     # 0x56289
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2a375(%rip), %rsi     # 0x6af38
movq 0x2a3ae(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x40be4
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x40bf2
callq 0x27560
testb %bpl, %bpl
jne 0x40c0f
jmp 0x40c17
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x40c0f
callq 0x27560
jmp 0x40c0f
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10
nop