// File: /workspace/github_cpp_makefile_star2_O3/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 0xd520(%rip), %rdx      # 0x56cfc
movq %rax, %rdi
movl $0xfffffff1, %esi       # imm = 0xFFFFFFF1
movl $0x70, %ecx
callq 0x27340
testl %eax, %eax
jne 0x49834
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x271a0
movl %eax, %ebp
movq %rbx, %rdi
callq 0x27850
cmpl $0x1, %ebp
jne 0x498b2
testl %eax, %eax
jne 0x49930
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 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xd5b6(%rip), %rsi      # 0x56e07
leaq 0xd5c7(%rip), %rdx      # 0x56e1f
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd5af(%rip), %rsi      # 0x56e20
leaq 0xd5bf(%rip), %rdx      # 0x56e37
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2169a(%rip), %rsi     # 0x6af38
movq 0x216d3(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
jmp 0x499b3
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xd538(%rip), %rsi      # 0x56e07
leaq 0xd549(%rip), %rdx      # 0x56e1f
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd549(%rip), %rsi      # 0x56e38
leaq 0xd555(%rip), %rdx      # 0x56e4b
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x2161c(%rip), %rsi     # 0x6af38
movq 0x21655(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
jmp 0x499b3
leaq 0x40(%rsp), %rdi
callq 0x27850
movl $0x28, %edi
callq 0x269d0
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xd4b0(%rip), %rsi      # 0x56e07
leaq 0xd4c1(%rip), %rdx      # 0x56e1f
movq %rsp, %rdi
callq 0x26750
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd4d5(%rip), %rsi      # 0x56e4c
leaq 0xd4e4(%rip), %rdx      # 0x56e62
leaq 0x20(%rsp), %rdi
callq 0x26750
movb $0x1, %bpl
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x28480
xorl %ebp, %ebp
movq 0x21594(%rip), %rsi     # 0x6af38
movq 0x215cd(%rip), %rdx     # 0x6af78
movq %rbx, %rdi
callq 0x28a20
jmp 0x499bb
jmp 0x499e2
jmp 0x499bb
jmp 0x499e2
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x499cd
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x499db
callq 0x27560
testb %bpl, %bpl
jne 0x499fc
jmp 0x49a04
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x499fc
callq 0x27560
jmp 0x499fc
jmp 0x499f9
jmp 0x499f9
movq %rax, %r14
movq %rbx, %rdi
callq 0x27070
movq %r14, %rdi
callq 0x28c10