// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movl 0x4(%rdi), %esi
testl %esi, %esi
jle 0x48f86
movq %rdi, %r15
movq %r15, %rdi
callq 0x265b0
movq %rax, %r14
movq 0x18(%r15), %rdi
movq 0x30(%r15), %rsi
movq (%rdi), %rax
movl %r14d, %edx
callq *0x40(%rax)
testq %rax, %rax
js 0x48f96
movq %rax, %rbx
cmpq %r14, %rax
jne 0x49057
addq %r14, 0x8(%r15)
movl 0x4(%r15), %esi
testl %esi, %esi
jg 0x48f4d
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 0xde04(%rip), %rsi      # 0x56dab
leaq 0xde0b(%rip), %rdx      # 0x56db9
leaq 0x8(%rsp), %rdi
callq 0x26750
movq 0x18(%r15), %rsi
movq (%rsi), %rax
leaq 0x28(%rsp), %rdi
callq *0x48(%rax)
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x29130
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48fee
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x48ffd
callq 0x27560
movl $0x28, %edi
callq 0x269d0
movq %rax, %r14
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0xdda1(%rip), %rsi      # 0x56dba
leaq 0xddb0(%rip), %rdx      # 0x56dd0
callq 0x26750
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %r14, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x21ef5(%rip), %rsi     # 0x6af38
movq 0x21f2e(%rip), %rdx     # 0x6af78
movq %r14, %rdi
callq 0x28a30
jmp 0x49142
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xce27(%rip), %rdx      # 0x55e8f
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x26750
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x18, %edx
callq 0x28750
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x49098
callq 0x27560
leaq 0x58(%rsp), %r15
leaq 0xdd2d(%rip), %rsi      # 0x56dd1
movl $0x12, %edx
movq %r15, %rdi
callq 0x27a70
movq %r15, %rdi
movq %r14, %rsi
callq 0x26fb0
movq %rax, %r14
leaq 0xdd1e(%rip), %rsi      # 0x56de4
movl $0x22, %edx
movq %rax, %rdi
callq 0x27a70
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27570
movl $0x28, %edi
callq 0x269d0
movq %rax, %r14
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0xdcc0(%rip), %rsi      # 0x56dba
leaq 0xdccf(%rip), %rdx      # 0x56dd0
callq 0x26750
leaq 0x60(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x28740
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x21e05(%rip), %rsi     # 0x6af38
movq 0x21e3e(%rip), %rdx     # 0x6af78
movq %r14, %rdi
callq 0x28a30
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x49160
callq 0x27560
jmp 0x49160
movq %rax, %rbx
movb $0x1, %bpl
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x49177
callq 0x27560
jmp 0x49177
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x491d8
movq %r14, %rdi
callq 0x27070
jmp 0x491d8
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x491a0
callq 0x27560
jmp 0x491a0
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x491ad
movq %r14, %rdi
callq 0x27070
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x491fb
jmp 0x49207
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x491f1
callq 0x27560
jmp 0x491f1
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x270d0
jmp 0x49207
movq %rax, %rdi
callq 0x2f0bd
jmp 0x491ee
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x49207
callq 0x27560
jmp 0x49207
jmp 0x49204
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c20
nop