// File: /workspace/github_cpp_makefile_star2_O3/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 0x48eaa
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 0x48eba
movq %rax, %rbx
cmpq %r14, %rax
jne 0x48f7b
addq %r14, 0x8(%r15)
movl 0x4(%r15), %esi
testl %esi, %esi
jg 0x48e71
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 0xdee0(%rip), %rsi      # 0x56dab
leaq 0xdee7(%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 0x29120
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48f12
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x48f21
callq 0x27560
movl $0x28, %edi
callq 0x269d0
movq %rax, %r14
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0xde7d(%rip), %rsi      # 0x56dba
leaq 0xde8c(%rip), %rdx      # 0x56dd0
callq 0x26750
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %r14, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x21fd1(%rip), %rsi     # 0x6af38
movq 0x2200a(%rip), %rdx     # 0x6af78
movq %r14, %rdi
callq 0x28a20
jmp 0x49066
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xcf03(%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 0x48fbc
callq 0x27560
leaq 0x58(%rsp), %r15
leaq 0xde09(%rip), %rsi      # 0x56dd1
movl $0x12, %edx
movq %r15, %rdi
callq 0x27a70
movq %r15, %rdi
movq %r14, %rsi
callq 0x26fb0
movq %rax, %r14
leaq 0xddfa(%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 0xdd9c(%rip), %rsi      # 0x56dba
leaq 0xddab(%rip), %rdx      # 0x56dd0
callq 0x26750
leaq 0x60(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x28730
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x21ee1(%rip), %rsi     # 0x6af38
movq 0x21f1a(%rip), %rdx     # 0x6af78
movq %r14, %rdi
callq 0x28a20
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4907c
callq 0x27560
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x4908b
callq 0x27560
testb %bpl, %bpl
jne 0x490a9
jmp 0x49102
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x490a9
callq 0x27560
jmp 0x490a9
movq %rax, %rbx
movq %r14, %rdi
callq 0x27070
jmp 0x49102
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x490c5
callq 0x27560
testb %bpl, %bpl
jne 0x490cf
jmp 0x490d7
movq %rax, %rbx
movq %r14, %rdi
callq 0x27070
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x49125
jmp 0x49131
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4911b
callq 0x27560
jmp 0x4911b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x270d0
jmp 0x49131
movq %rax, %rdi
callq 0x2f047
jmp 0x49118
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x49131
callq 0x27560
jmp 0x49131
jmp 0x4912e
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c10
nop