// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0xc0, %rsp
xorps %xmm0, %xmm0
leaq 0x50(%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 0xc12f(%rip), %rdx      # 0x5cd2b
pushq $-0xf
popq %rsi
pushq $0x70
popq %rcx
movq %rax, %rdi
callq 0x32cc0
testl %eax, %eax
jne 0x50c4a
leaq 0x50(%rsp), %rbx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x329f0
movl %eax, %ebp
movq %rbx, %rdi
callq 0x33320
cmpl $0x1, %ebp
jne 0x50cb3
testl %eax, %eax
jne 0x50d19
movq 0x78(%rsp), %rax
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0xc1da(%rip), %rsi      # 0x5ce36
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0xc1dd(%rip), %rsi      # 0x5ce4f
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 0x24299(%rip), %rsi     # 0x74f38
movq 0x242d2(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
jmp 0x50d87
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0xc171(%rip), %rsi      # 0x5ce36
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0xc18c(%rip), %rsi      # 0x5ce67
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 0x24230(%rip), %rsi     # 0x74f38
movq 0x24269(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
jmp 0x50d87
leaq 0x50(%rsp), %rdi
callq 0x33320
pushq $0x28
popq %rdi
callq 0x31e70
movq %rax, %rbx
leaq 0xc101(%rip), %rsi      # 0x5ce36
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x31b30
leaq 0xc130(%rip), %rsi      # 0x5ce7b
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 0x241c0(%rip), %rsi     # 0x74f38
movq 0x241f9(%rip), %rdx     # 0x74f78
movq %rbx, %rdi
callq 0x34c90
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x50d9c
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x50de8
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x50dbd
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
jmp 0x50de8
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x33a00
jmp 0x50dde
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x33a00
testb %bpl, %bpl
jne 0x50df6
jmp 0x50dfe
jmp 0x50df3
jmp 0x50df3
movq %rax, %r14
movq %rbx, %rdi
callq 0x327c0
movq %r14, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f