// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/io/BgzfStream_p.cpp
// Function: BamTools::Internal::BgzfStream::FlushBlock()
void BgzfStream::FlushBlock(void) {

    BT_ASSERT_X( m_device, "BgzfStream::FlushBlock() - attempting to flush to null device" );

    // flush all of the remaining blocks
    while ( m_blockOffset > 0 ) {

        // compress the data block
        const size_t blockLength = DeflateBlock(m_blockOffset);

        // flush the data to our output device
        const int64_t numBytesWritten = m_device->Write(m_compressedBlock.Buffer, blockLength);

        // check for device error
        if ( numBytesWritten < 0 ) {
            const string message = string("device error: ") + m_device->GetErrorString();
            throw BamException("BgzfStream::FlushBlock", message);
        }

        // check that we wrote expected numBytes
        if ( numBytesWritten != static_cast<int64_t>(blockLength) ) {
            stringstream s("");
            s << "expected to write " << blockLength
              << " bytes during flushing, but wrote " << numBytesWritten;
            throw BamException("BgzfStream::FlushBlock", s.str());
        }

        // update block data
        m_blockAddress += blockLength;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, %r15
movl 0x4(%r15), %esi
testl %esi, %esi
jle 0x50445
movq %r15, %rdi
callq 0x31890
movq %rax, %r14
movq 0x18(%r15), %rdi
movq 0x30(%r15), %rsi
movq (%rdi), %rax
movl %r14d, %edx
callq *0x40(%rax)
testq %rax, %rax
js 0x50453
movq %rax, %rbx
cmpq %r14, %rax
jne 0x504f3
addq %r14, 0x8(%r15)
jmp 0x5040a
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc980(%rip), %rsi      # 0x5cdda
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
movq 0x18(%r15), %rsi
movq (%rsi), %rax
leaq 0x30(%rsp), %rdi
callq *0x48(%rax)
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x355e0
leaq 0x30(%rsp), %rdi
callq 0x33a00
leaq 0x10(%rsp), %rdi
callq 0x33a00
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %r14
leaq 0xc937(%rip), %rsi      # 0x5cde9
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x31b30
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq %r14, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x24a59(%rip), %rsi     # 0x74f38
movq 0x24a92(%rip), %rdx     # 0x74f78
movq %r14, %rdi
callq 0x34c90
jmp 0x505b8
leaq 0xb96a(%rip), %rsi      # 0x5be64
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x31b30
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x34880
leaq 0x10(%rsp), %rdi
callq 0x33a00
leaq 0x60(%rsp), %rdi
leaq 0xc8cf(%rip), %rsi      # 0x5ce00
callq 0x330f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x326a0
leaq 0xc8cb(%rip), %rsi      # 0x5ce13
movq %rax, %rdi
callq 0x330f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x32fb0
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %r14
leaq 0xc87c(%rip), %rsi      # 0x5cde9
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0x68(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x34870
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x344c0
xorl %ebp, %ebp
movq 0x2498f(%rip), %rsi     # 0x74f38
movq 0x249c8(%rip), %rdx     # 0x74f78
movq %r14, %rdi
callq 0x34c90
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x505cd
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x10(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x505e1
jmp 0x50619
movq %rax, %rbx
movq %r14, %rdi
callq 0x327c0
jmp 0x50619
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x50602
jmp 0x5060a
movq %rax, %rbx
movq %r14, %rdi
callq 0x327c0
leaq 0x50(%rsp), %rdi
callq 0x33a00
jmp 0x5065f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x32870
jmp 0x5065f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x50646
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x5065f
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x5065f
movq %rax, %rdi
callq 0x39b2f
jmp 0x5065c
movq %rax, %rbx
movq %rbx, %rdi
callq 0x34ed0
nop