LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::OpenFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, BamTools::IBamIODevice::OpenMode)
void BamStandardIndex::OpenFile(const std::string& filename, IBamIODevice::OpenMode mode) {

    // make sure any previous index file is closed
    CloseFile();

    m_resources.Device = BamDeviceFactory::CreateDevice(filename);
    if ( m_resources.Device == 0 ) {
        const string message = string("could not open file: ") + filename;
        throw BamException("BamStandardIndex::OpenFile", message);
    }

    // attempt to open file
    m_resources.Device->Open(mode);
    if ( !IsDeviceOpen() ) {
        const string message = string("could not open file: ") + filename;
        throw BamException("BamStandardIndex::OpenFile", message);
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x33b70
movq %rbx, %rdi
callq 0x32bd0
movq %rax, 0x58(%r14)
testq %rax, %rax
je 0x47eea
movq (%rax), %rcx
movq %rax, %rdi
movl %ebp, %esi
callq *0x20(%rcx)
movq 0x58(%r14), %rdi
testq %rdi, %rdi
je 0x47e65
movq (%rdi), %rax
callq *0x50(%rax)
testb %al, %al
je 0x47e65
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1372a(%rip), %rsi     # 0x5b596
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x355e0
leaq 0x10(%rsp), %rdi
callq 0x33a00
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %r14
leaq 0x141e4(%rip), %rsi     # 0x5c08d
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2d062(%rip), %rsi     # 0x74f38
movq 0x2d09b(%rip), %rdx     # 0x74f78
movq %r14, %rdi
callq 0x34c90
jmp 0x47f6a
leaq 0x136a5(%rip), %rsi     # 0x5b596
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x355e0
leaq 0x10(%rsp), %rdi
callq 0x33a00
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %r14
leaq 0x1415f(%rip), %rsi     # 0x5c08d
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2cfdd(%rip), %rsi     # 0x74f38
movq 0x2d016(%rip), %rdx     # 0x74f78
movq %r14, %rdi
callq 0x34c90
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x47f81
jmp 0x47f89
movq %rax, %rbx
movq %r14, %rdi
callq 0x327c0
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x47feb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x47fac
jmp 0x47fb4
movq %rax, %rbx
movq %r14, %rdi
callq 0x327c0
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x47feb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x47feb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x47feb
movq %rax, %rdi
callq 0x39b2f
jmp 0x47fe8
movq %rax, %rbx
movq %rbx, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x50, %rsp
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
leaq 0x13e1f(%rip), %rsi     # 0x5be60
pushq $0x4
popq %rdx
callq *0x40(%rax)
movq %rax, %rbx
movq 0x40(%r14), %rax
subq 0x38(%r14), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x30(%r14)
jne 0x4806f
leaq 0xc(%rsp), %rdi
callq 0x32c90
movq 0x58(%r14), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
addq %rbx, %rax
cmpq $0x8, %rax
jne 0x48093
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x142e5(%rip), %rsi     # 0x5c38a
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
leaq 0x142ed(%rip), %rsi     # 0x5c3a8
leaq 0x10(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2ce50(%rip), %rsi     # 0x74f38
movq 0x2ce89(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x4810c
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x48128
jmp 0x48130
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
// File: /workspace/github_cpp_makefile_star2_O2/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 %rsi, %rdi
movq %rdx, %rsi
callq 0x34bd0
leaq 0x8(%rbx), %rcx
cmpq %rcx, %rax
je 0x48179
addq $0x28, %rax
movq %rsp, %rsi
movq %rax, %rdi
callq 0x335f0
jmp 0x481dd
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %rsp, %rsi
callq 0x335f0
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
callq 0x311c0
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x32860
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x34590
leaq 0x50(%rsp), %rdi
callq 0x32340
leaq 0x30(%rsp), %rdi
callq 0x32340
leaq 0x10(%rsp), %rdi
callq 0x32340
addq $0x68, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x32340
jmp 0x481fe
jmp 0x481f6
movq %rax, %rbx
jmp 0x48208
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x32340
leaq 0x10(%rsp), %rdi
callq 0x32340
movq %rbx, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
// File: /workspace/github_cpp_makefile_star2_O2/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
movl (%rdx), %ebp
sarl $0xe, %ebp
movl (%rcx), %r15d
decl %r15d
sarl $0xe, %r15d
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
cmpl %ecx, %r15d
jl 0x4828f
movq %rsi, %r14
leal 0x1(%r15), %eax
movslq %eax, %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x32190
movq (%r14), %rax
movslq %ebp, %rcx
movslq %r15d, %rdx
cmpq %rdx, %rcx
jge 0x482af
cmpq $0x0, 0x8(%rax,%rcx,8)
jne 0x482aa
movq (%rbx), %rsi
movq %rsi, 0x8(%rax,%rcx,8)
incq %rcx
jmp 0x48295
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 0x48661
movq 0x40(%rdi), %rax
subq 0x38(%rdi), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
cmpl %eax, %esi
jge 0x48661
pushq %rax
addq $0x38, %rdi
callq 0x31a10
cmpl $0x0, (%rax)
setg %al
addq $0x8, %rsp
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x50, %rsp
movq %rdi, %rbx
movb $0x0, (%rdx)
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x486b6
movq %rdx, %r14
movq %rsi, %r15
callq 0x33780
testb %al, %al
je 0x486b6
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x33160
movb $0x1, %al
cmpb $0x1, (%r14)
jne 0x4870a
movq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x33190
jmp 0x4870a
leaq 0x13996(%rip), %rsi     # 0x5c053
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x13997(%rip), %rsi     # 0x5c06a
leaq 0x30(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x31b30
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x31500
leaq 0x30(%rsp), %rdi
callq 0x33a00
leaq 0x10(%rsp), %rdi
callq 0x33a00
xorl %eax, %eax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
cmpl $0x1, %edx
jne 0x4876e
movq %r14, %rdi
callq 0x31bb0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
addq $0x10, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x35550
callq 0x34970
jmp 0x48708
movq %rax, %r14
callq 0x34970
jmp 0x4876e
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x48764
movq %rax, %r14
jmp 0x4876e
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
movq %r14, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x1
popq %rdx
callq 0x349c0
movq %rbx, %rdi
callq 0x33110
movb $0x1, %bpl
movq %rbx, %rdi
callq 0x341d0
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
cmpl $0x1, %edx
jne 0x487e0
movq %r14, %rdi
callq 0x31bb0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
addq $0x10, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x35550
callq 0x34970
xorl %ebp, %ebp
jmp 0x487a0
movq %rax, %r14
callq 0x34970
movq %r14, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
// File: /workspace/github_cpp_makefile_star2_O2/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 $0x10, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %r14
movq %r14, %rsi
callq 0x34e60
movq %rbx, %rdi
movq %r14, %rsi
callq 0x34900
movq 0x38(%rbx), %r14
movq 0x40(%rbx), %r15
cmpq %r15, %r14
je 0x48832
movq %rbx, %rdi
movq %r14, %rsi
callq 0x310a0
addq $0x18, %r14
jmp 0x4881c
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
pushq $0x8
popq %rdx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x48867
movq (%rbx), %rcx
bswapq %rcx
movq %rcx, (%rbx)
cmpq $0x8, %rax
jne 0x48876
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x138a6(%rip), %rsi     # 0x5c12e
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x138b3(%rip), %rsi     # 0x5c151
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2c66d(%rip), %rsi     # 0x74f38
movq 0x2c6a6(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x488ef
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x4890b
jmp 0x48913
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::MergeAlignmentChunks(std::vector<BamTools::Internal::BaiAlignmentChunk, std::allocator<BamTools::Internal::BaiAlignmentChunk>>&)
void BamStandardIndex::MergeAlignmentChunks(BaiAlignmentChunkVector& chunks) {

    // skip if chunks are empty, nothing to merge
    if ( chunks.empty() )
        return;

    // set up merged alignment chunk container
    BaiAlignmentChunkVector mergedChunks;
    mergedChunks.push_back( chunks[0] );

    // iterate over chunks
    int i = 0;
    BaiAlignmentChunkVector::iterator chunkIter = chunks.begin();
    BaiAlignmentChunkVector::iterator chunkEnd  = chunks.end();
    for ( ++chunkIter; chunkIter != chunkEnd; ++chunkIter) {

        // get 'currentMergeChunk' based on numeric index
        BaiAlignmentChunk& currentMergeChunk = mergedChunks[i];

        // get sourceChunk based on source vector iterator
        BaiAlignmentChunk& sourceChunk = (*chunkIter);

        // if currentMergeChunk ends where sourceChunk starts, then merge the two
        if ( currentMergeChunk.Stop>>16 == sourceChunk.Start>>16 )
            currentMergeChunk.Stop = sourceChunk.Stop;

        // otherwise
        else {
            // append sourceChunk after currentMergeChunk
            mergedChunks.push_back(sourceChunk);

            // update i, so the next iteration will consider the
            // recently-appended sourceChunk as new mergeChunk candidate
            ++i;
        }
    }

    // saved newly-merged chunks into (parameter) chunks
    chunks = mergedChunks;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movq (%rsi), %rsi
cmpq 0x8(%rbx), %rsi
je 0x489a7
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
callq 0x335f0
movq (%rbx), %r14
movq 0x8(%rbx), %r12
xorl %ebp, %ebp
movq %rsp, %r15
movl %ebp, %eax
movq (%rsp), %rcx
shlq $0x4, %rax
addq %rcx, %rax
addq $0x8, %rax
addq $0x10, %r14
cmpq %r12, %r14
je 0x48994
movq (%r14), %rcx
xorq (%rax), %rcx
cmpq $0xffff, %rcx           # imm = 0xFFFF
ja 0x48985
movq 0x8(%r14), %rcx
movq %rcx, (%rax)
jmp 0x48964
movq %r15, %rdi
movq %r14, %rsi
callq 0x335f0
incl %ebp
jmp 0x48953
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x34060
movq %rsp, %rdi
callq 0x32340
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x489b8
jmp 0x489b8
movq %rax, %rbx
movq %rsp, %rdi
callq 0x32340
movq %rbx, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
pushq $0x4
popq %rdx
callq *0x28(%rax)
cmpb $0x1, 0x30(%r14)
jne 0x489fc
movl (%rbx), %ecx
bswapl %ecx
movl %ecx, (%rbx)
cmpq $0x4, %rax
jne 0x48a0b
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x1368b(%rip), %rsi     # 0x5c0a8
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x13691(%rip), %rsi     # 0x5c0c4
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2c4d8(%rip), %rsi     # 0x74f38
movq 0x2c511(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x48a84
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x48aa0
jmp 0x48aa8
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
pushq $0x4
popq %rdx
callq *0x28(%rax)
movq %rax, %r14
cmpb $0x1, 0x30(%r15)
jne 0x48adf
movq %rbx, %rdi
callq 0x32c90
cmpq $0x4, %r14
jne 0x48af0
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x13670(%rip), %rsi     # 0x5c172
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x13683(%rip), %rsi     # 0x5c19b
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2c3f3(%rip), %rsi     # 0x74f38
movq 0x2c42c(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x48b69
movq %rax, %r14
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x48b85
jmp 0x48b8d
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rsi, %r14
movq %rdi, %rbx
addq $0x60, %rdi
leaq 0x50(%rbx), %rsi
movq %r14, %rdx
callq 0x31590
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 0x48bdf
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1327e(%rip), %rsi     # 0x5be64
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x31b30
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x34880
leaq 0x8(%rsp), %rdi
callq 0x33a00
leaq 0x58(%rsp), %rdi
leaq 0x134c1(%rip), %rsi     # 0x5c0de
callq 0x330f0
movl (%r14), %esi
movq %rax, %rdi
callq 0x326a0
leaq 0x134bd(%rip), %rsi     # 0x5c0f1
movq %rax, %rdi
callq 0x330f0
leaq 0x134b7(%rip), %rsi     # 0x5c0fa
movq %rax, %rdi
callq 0x330f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x32fb0
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x134a5(%rip), %rsi     # 0x5c10d
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x60(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x34870
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2c294(%rip), %rsi     # 0x74f38
movq 0x2c2cd(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x33a00
jmp 0x48cc8
movq %rax, %r14
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x48cdc
jmp 0x48ce9
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
jmp 0x48ce9
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x32870
jmp 0x48d0f
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x48d0f
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
pushq $0x4
popq %rdx
callq *0x28(%rax)
movq %rax, %r14
cmpb $0x1, 0x30(%r15)
jne 0x48d47
movq %rbx, %rdi
callq 0x32c90
cmpq $0x4, %r14
jne 0x48d58
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x13450(%rip), %rsi     # 0x5c1ba
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x13458(%rip), %rsi     # 0x5c1d8
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2c18b(%rip), %rsi     # 0x74f38
movq 0x2c1c4(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x48dd1
movq %rax, %r14
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x48ded
jmp 0x48df5
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
pushq $0x4
popq %rdx
callq *0x28(%rax)
movq %rax, %r14
cmpb $0x1, 0x30(%r15)
jne 0x48e2d
movq %rbx, %rdi
callq 0x32c90
cmpq $0x4, %r14
jne 0x48e3e
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x13322(%rip), %rsi     # 0x5c172
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x1338f(%rip), %rsi     # 0x5c1f5
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2c0a5(%rip), %rsi     # 0x74f38
movq 0x2c0de(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x48eb7
movq %rax, %r14
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x48ed3
jmp 0x48edb
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movq 0x58(%rdi), %rdi
movq (%rdi), %rax
pushq $0x4
popq %rdx
callq *0x28(%rax)
movq %rax, %r14
cmpb $0x1, 0x30(%r15)
jne 0x48f13
movq %rbx, %rdi
callq 0x32c90
cmpq $0x4, %r14
jne 0x48f24
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x132e6(%rip), %rsi     # 0x5c21c
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x132f4(%rip), %rsi     # 0x5c240
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2bfbf(%rip), %rsi     # 0x74f38
movq 0x2bff8(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x48f9d
movq %rax, %r14
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x48fb9
jmp 0x48fc1
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::SkipBins(int const&)
void BamStandardIndex::SkipBins(const int& numBins) {
    uint32_t binId;
    int32_t numAlignmentChunks;
    for (int i = 0; i < numBins; ++i)
        ReadBinIntoBuffer(binId, numAlignmentChunks); // results & buffer ignored
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %ebp, %ebp
leaq 0xc(%rsp), %r15
leaq 0x8(%rsp), %r12
cmpl (%rbx), %ebp
jge 0x49070
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x33330
incl %ebp
jmp 0x4905a
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::SummarizeBins(BamTools::Internal::BaiReferenceSummary&)
void BamStandardIndex::SummarizeBins(BaiReferenceSummary& refSummary) {

    // load number of bins
    int numBins;
    ReadNumBins(numBins);

    // store bins summary for this reference
    refSummary.NumBins = numBins;
    refSummary.FirstBinFilePosition = Tell();

    // skip this reference's bins
    SkipBins(numBins);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xc(%rsp), %r15
movq %r15, %rsi
callq 0x331b0
movl (%r15), %eax
movl %eax, (%rbx)
movq 0x58(%r14), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, 0x8(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x33710
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::SummarizeLinearOffsets(BamTools::Internal::BaiReferenceSummary&)
void BamStandardIndex::SummarizeLinearOffsets(BaiReferenceSummary& refSummary) {

    // load number of linear offsets
    int numLinearOffsets;
    ReadNumLinearOffsets(numLinearOffsets);

    // store bin summary data for this reference
    refSummary.NumLinearOffsets = numLinearOffsets;
    refSummary.FirstLinearOffsetFilePosition = Tell();

    // skip linear offsets in index file
    SkipLinearOffsets(numLinearOffsets);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xc(%rsp), %r15
movq %r15, %rsi
callq 0x32480
movl (%r15), %eax
movl %eax, 0x4(%rbx)
movq 0x58(%r14), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, 0x10(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x32f90
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::WriteAlignmentChunk(BamTools::Internal::BaiAlignmentChunk const&)
void BamStandardIndex::WriteAlignmentChunk(const BaiAlignmentChunk& chunk) {

    // localize alignment chunk offsets
    uint64_t start = chunk.Start;
    uint64_t stop  = chunk.Stop;

    // swap endian-ness if necessary
    if ( m_isBigEndian ) {
        SwapEndian_64(start);
        SwapEndian_64(stop);
    }

    // write to index file
    int64_t numBytesWritten = 0;
    numBytesWritten += m_resources.Device->Write((const char*)&start, sizeof(start));
    numBytesWritten += m_resources.Device->Write((const char*)&stop, sizeof(stop));
    if ( numBytesWritten != (sizeof(start)+sizeof(stop)) )
        throw BamException("BamStandardIndex::WriteAlignmentChunk", "could not write BAI alignment chunk");
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
movq (%rsi), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x10(%rsp)
cmpb $0x1, 0x30(%rdi)
jne 0x4917c
bswapq %rcx
movq %rcx, 0x18(%rsp)
bswapq %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
leaq 0x18(%rsp), %rsi
pushq $0x8
popq %rbp
movl %ebp, %edx
callq *0x40(%rax)
movq %rax, %r14
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
leaq 0x10(%rsp), %rsi
movl %ebp, %edx
callq *0x40(%rax)
addq %r14, %rax
cmpq $0x10, %rax
jne 0x491b6
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x130c9(%rip), %rsi     # 0x5c291
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x130d9(%rip), %rsi     # 0x5c2b7
leaq 0x20(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2bd2d(%rip), %rsi     # 0x74f38
movq 0x2bd66(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x33a00
jmp 0x4922f
movq %rax, %r14
movb $0x1, %bpl
leaq 0x40(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x4924b
jmp 0x49253
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::WriteAlignmentChunks(std::vector<BamTools::Internal::BaiAlignmentChunk, std::allocator<BamTools::Internal::BaiAlignmentChunk>>&)
void BamStandardIndex::WriteAlignmentChunks(BaiAlignmentChunkVector& chunks) {

    // make sure chunks are merged (simplified) before writing & saving summary
    MergeAlignmentChunks(chunks);

    // write chunks
    int32_t chunkCount = chunks.size();
    if ( m_isBigEndian ) SwapEndian_32(chunkCount);
    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&chunkCount, sizeof(chunkCount));
    if ( numBytesWritten != sizeof(chunkCount) )
        throw BamException("BamStandardIndex::WriteAlignmentChunks", "could not write BAI chunk count");

    // iterate over chunks
    BaiAlignmentChunkVector::const_iterator chunkIter = chunks.begin();
    BaiAlignmentChunkVector::const_iterator chunkEnd  = chunks.end();
    for ( ; chunkIter != chunkEnd; ++chunkIter )
        WriteAlignmentChunk( (*chunkIter) );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x354a0
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x4, %rax
movl %eax, 0x4(%rsp)
cmpb $0x1, 0x30(%rbx)
jne 0x49290
leaq 0x4(%rsp), %rdi
callq 0x32c90
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
leaq 0x4(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
cmpq $0x4, %rax
jne 0x492d0
movq (%r14), %r15
movq 0x8(%r14), %r14
cmpq %r14, %r15
je 0x492c5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x35540
addq $0x10, %r15
jmp 0x492af
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x12ff9(%rip), %rsi     # 0x5c2db
leaq 0x28(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0x31b30
leaq 0x1300a(%rip), %rsi     # 0x5c302
leaq 0x8(%rsp), %rdi
leaq 0x2(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2bc13(%rip), %rsi     # 0x74f38
movq 0x2bc4c(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x49349
movq %rax, %r14
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x49365
jmp 0x4936d
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::WriteBin(unsigned int const&, std::vector<BamTools::Internal::BaiAlignmentChunk, std::allocator<BamTools::Internal::BaiAlignmentChunk>>&)
void BamStandardIndex::WriteBin(const uint32_t& binId, BaiAlignmentChunkVector& chunks) {

    // write BAM bin ID
    uint32_t binKey = binId;
    if ( m_isBigEndian ) SwapEndian_32(binKey);
    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&binKey, sizeof(binKey));
    if ( numBytesWritten != sizeof(binKey) )
        throw BamException("BamStandardIndex::WriteBin", "could not write bin ID");

    // write bin's alignment chunks
    WriteAlignmentChunks(chunks);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rdx, %rbx
movq %rdi, %r14
movl (%rsi), %eax
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x30(%rdi)
jne 0x49396
bswapl %eax
movl %eax, 0xc(%rsp)
movq 0x58(%r14), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
cmpq $0x4, %rax
jne 0x493c2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x34b20
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x12f4e(%rip), %rsi     # 0x5c322
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
leaq 0x12f53(%rip), %rsi     # 0x5c33d
leaq 0x10(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2bb21(%rip), %rsi     # 0x74f38
movq 0x2bb5a(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x4943b
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x49457
jmp 0x4945f
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::WriteBins(int const&, 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>>>>>&)
void BamStandardIndex::WriteBins(const int& refId, BaiBinMap& bins) {

    // write number of bins
    int32_t binCount = bins.size();
    if ( m_isBigEndian ) SwapEndian_32(binCount);
    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&binCount, sizeof(binCount));
    if ( numBytesWritten != sizeof(binCount) )
        throw BamException("BamStandardIndex::WriteBins", "could not write bin count");

    // save summary for reference's bins
    SaveBinsSummary(refId, bins.size());

    // iterate over bins
    BaiBinMap::iterator binIter = bins.begin();
    BaiBinMap::iterator binEnd  = bins.end();
    for ( ; binIter != binEnd; ++binIter )
        WriteBin( (*binIter).first, (*binIter).second );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movl 0x28(%rdx), %eax
movl %eax, 0x4(%rsp)
cmpb $0x1, 0x30(%rdi)
jne 0x49492
leaq 0x4(%rsp), %rdi
callq 0x32c90
movq 0x58(%r14), %rdi
movq (%rdi), %rax
leaq 0x4(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
cmpq $0x4, %rax
jne 0x494f4
movl 0x28(%rbx), %eax
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x31440
movq 0x18(%rbx), %r15
addq $0x8, %rbx
cmpq %rbx, %r15
je 0x494e9
leaq 0x20(%r15), %rsi
leaq 0x28(%r15), %rdx
movq %r14, %rdi
callq 0x34450
movq %r15, %rdi
callq 0x32740
movq %rax, %r15
jmp 0x494c7
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x12e4e(%rip), %rsi     # 0x5c354
leaq 0x8(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0x31b30
leaq 0x12e54(%rip), %rsi     # 0x5c370
leaq 0x28(%rsp), %rdi
leaq 0x2(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2b9ef(%rip), %rsi     # 0x74f38
movq 0x2ba28(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x33a00
jmp 0x4956d
movq %rax, %r14
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x49589
jmp 0x49591
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamToolsIndex_p.cpp
// Function: BamTools::Internal::BamToolsIndex::RaiiWrapper::~RaiiWrapper()
BamToolsIndex::RaiiWrapper::~RaiiWrapper(void) {
    if ( Device ) {
        Device->Close();
        delete Device;
        Device = 0;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x4aeee
movq (%rdi), %rax
callq *0x10(%rax)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x4aeea
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, (%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamToolsIndex_p.cpp
// Function: BamTools::Internal::BamToolsIndex::CloseFile()
void BamToolsIndex::CloseFile(void) {
    if ( IsDeviceOpen() ) {
        m_resources.Device->Close();
        delete m_resources.Device;
        m_resources.Device = 0;
    }
    m_indexFileSummary.clear();
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x60(%rdi), %rdi
testq %rdi, %rdi
je 0x4b017
movq (%rdi), %rax
callq *0x50(%rax)
testb %al, %al
je 0x4b017
movq 0x60(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x4b012
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, 0x60(%rbx)
movq 0x38(%rbx), %rax
cmpq %rax, 0x40(%rbx)
je 0x4b025
movq %rax, 0x40(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamToolsIndex_p.cpp
// Function: BamTools::Internal::BamToolsIndex::CheckMagicNumber()
void BamToolsIndex::CheckMagicNumber(void) {

    // read magic number
    char magic[4];
    const int64_t numBytesRead = m_resources.Device->Read(magic, 4);
    if ( numBytesRead != 4 )
        throw BamException("BamToolsIndex::CheckMagicNumber", "could not read BTI magic number");

    // validate expected magic number
    if ( strncmp(magic, BamToolsIndex::BTI_MAGIC, 4) != 0 )
        throw BamException("BamToolsIndex::CheckMagicNumber", "invalid BTI magic number");
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq 0x60(%rdi), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x28(%rax)
cmpq $0x4, %rax
jne 0x4b089
cmpl $0x1495442, 0xc(%rsp)   # imm = 0x1495442
jne 0x4b0ef
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x113eb(%rip), %rsi     # 0x5c486
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
leaq 0x113f5(%rip), %rsi     # 0x5c4a6
leaq 0x10(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x29e5a(%rip), %rsi     # 0x74f38
movq 0x29e93(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
jmp 0x4b153
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x11385(%rip), %rsi     # 0x5c486
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
leaq 0x113af(%rip), %rsi     # 0x5c4c6
leaq 0x10(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x29df4(%rip), %rsi     # 0x74f38
movq 0x29e2d(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x4b168
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x4b193
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x4b189
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x4b19f
jmp 0x4b1a7
jmp 0x4b19c
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f
nop
// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/index/BamToolsIndex_p.cpp
// Function: BamTools::Internal::BamToolsIndex::WriteReferenceEntry(BamTools::Internal::BtiReferenceEntry const&)
void BamToolsIndex::WriteReferenceEntry(const BtiReferenceEntry& refEntry) {

    // write number of blocks this reference
    uint32_t numBlocks = refEntry.Blocks.size();
    if ( m_isBigEndian ) SwapEndian_32(numBlocks);
    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&numBlocks, sizeof(numBlocks));
    if ( numBytesWritten != sizeof(numBlocks) )
        throw BamException("BamToolsIndex::WriteReferenceEntry", "could not write number of blocks");

    // write actual block entries
    WriteBlocks(refEntry.Blocks);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10(%rsi), %rax
subq 0x8(%rsi), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x30(%rdi)
jne 0x4beb4
bswapl %eax
movl %eax, 0xc(%rsp)
movq 0x60(%r14), %rdi
movq (%rdi), %rax
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
callq *0x40(%rax)
cmpq $0x4, %rax
jne 0x4bee4
addq $0x8, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x31c40
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0x10996(%rip), %rsi     # 0x5c88c
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x31b30
leaq 0x109a3(%rip), %rsi     # 0x5c8af
leaq 0x10(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x28fff(%rip), %rsi     # 0x74f38
movq 0x29038(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x4bf5d
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x4bf79
jmp 0x4bf81
movq %rax, %rdi
callq 0x39b2f
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
nop