// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/io/BgzfStream_p.cpp
// Function: BamTools::Internal::BgzfStream::InflateBlock(unsigned long const&)
size_t BgzfStream::InflateBlock(const size_t& blockLength) {

    // setup zlib stream object
    z_stream zs;
    zs.zalloc    = NULL;
    zs.zfree     = NULL;
    zs.next_in   = (Bytef*)m_compressedBlock.Buffer + 18;
    zs.avail_in  = blockLength - 16;
    zs.next_out  = (Bytef*)m_uncompressedBlock.Buffer;
    zs.avail_out = Constants::BGZF_DEFAULT_BLOCK_SIZE;

    // initialize
    int status = inflateInit2(&zs, Constants::GZIP_WINDOW_BITS);
    if ( status != Z_OK )
        throw BamException("BgzfStream::InflateBlock", "zlib inflateInit failed");

    // decompress
    status = inflate(&zs, Z_FINISH);
    if ( status != Z_STREAM_END ) {
        inflateEnd(&zs);
        throw BamException("BgzfStream::InflateBlock", "zlib inflate failed");
    }

    // finalize
    status = inflateEnd(&zs);
    if ( status != Z_OK ) {
        inflateEnd(&zs);
        throw BamException("BgzfStream::InflateBlock", "zlib inflateEnd failed");
    }

    // return result
    return zs.total_out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb0, %rsp
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rax
movups %xmm0, 0x40(%rax)
movq 0x30(%rdi), %rcx
addq $0x12, %rcx
movq %rcx, (%rax)
movl (%rsi), %ecx
addl $-0x10, %ecx
movl %ecx, 0x8(%rax)
movq 0x20(%rdi), %rcx
movq %rcx, 0x18(%rax)
movl $0x10000, 0x20(%rax)    # imm = 0x10000
leaq 0xd4cc(%rip), %rdx      # 0x56cfc
movq %rax, %rdi
movl $0xfffffff1, %esi       # imm = 0xFFFFFFF1
movl $0x70, %ecx
callq 0x27340
testl %eax, %eax
jne 0x49888
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x271a0
movl %eax, %ebp
movq %rbx, %rdi
callq 0x27850
cmpl $0x1, %ebp
jne 0x49906
testl %eax, %eax
jne 0x49984
movq 0x68(%rsp), %rax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xd562(%rip), %rsi      # 0x56e07
leaq 0xd573(%rip), %rdx      # 0x56e1f
leaq 0x20(%rsp), %rdi
callq 0x26750
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd559(%rip), %rsi      # 0x56e20
leaq 0xd569(%rip), %rdx      # 0x56e37
movq %rsp, %rdi
callq 0x26750
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x21646(%rip), %rsi     # 0x6af38
movq 0x2167f(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a30
jmp 0x49a07
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xd4e4(%rip), %rsi      # 0x56e07
leaq 0xd4f5(%rip), %rdx      # 0x56e1f
leaq 0x20(%rsp), %rdi
callq 0x26750
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd4f3(%rip), %rsi      # 0x56e38
leaq 0xd4ff(%rip), %rdx      # 0x56e4b
movq %rsp, %rdi
callq 0x26750
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x215c8(%rip), %rsi     # 0x6af38
movq 0x21601(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a30
jmp 0x49a07
leaq 0x40(%rsp), %rdi
callq 0x27850
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xd45c(%rip), %rsi      # 0x56e07
leaq 0xd46d(%rip), %rdx      # 0x56e1f
leaq 0x20(%rsp), %rdi
callq 0x26750
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd47f(%rip), %rsi      # 0x56e4c
leaq 0xd48e(%rip), %rdx      # 0x56e62
movq %rsp, %rdi
callq 0x26750
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x28490
xorl %ebp, %ebp
movq 0x21540(%rip), %rsi     # 0x6af38
movq 0x21579(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a30
jmp 0x49a0f
jmp 0x49a22
jmp 0x49a0f
jmp 0x49a22
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x49a28
callq 0x27560
jmp 0x49a28
movq %rax, %r14
movb $0x1, %bpl
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x49a43
callq 0x27560
jmp 0x49a43
jmp 0x49a3d
jmp 0x49a3d
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x49a50
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c20