// File: jimmiebergmann[P]fbx-file/miniz.c
// Function: tinfl_decompress_mem_to_heap
void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
{
    tinfl_decompressor decomp;
    void *pBuf = NULL, *pNew_buf;
    size_t src_buf_ofs = 0, out_buf_capacity = 0;
    *pOut_len = 0;
    tinfl_init(&decomp);
    for (;;)
    {
        size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;
        tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL, &dst_buf_size,
                                               (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);
        if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT))
        {
            MZ_FREE(pBuf);
            *pOut_len = 0;
            return NULL;
        }
        src_buf_ofs += src_buf_size;
        *pOut_len += dst_buf_size;
        if (status == TINFL_STATUS_DONE)
            break;
        new_out_buf_capacity = out_buf_capacity * 2;
        if (new_out_buf_capacity < 128)
            new_out_buf_capacity = 128;
        pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity);
        if (!pNew_buf)
        {
            MZ_FREE(pBuf);
            *pOut_len = 0;
            return NULL;
        }
        pBuf = pNew_buf;
        out_buf_capacity = new_out_buf_capacity;
    }
    return pBuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b80, %rsp           # imm = 0x2B80
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq $0x0, -0x2b28(%rbp)
movq $0x0, -0x2b38(%rbp)
movq $0x0, -0x2b40(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x2b20(%rbp)
jmp 0xb742
movq -0x18(%rbp), %rax
subq -0x2b38(%rbp), %rax
movq %rax, -0x2b48(%rbp)
movq -0x2b40(%rbp), %rax
movq -0x20(%rbp), %rcx
subq (%rcx), %rax
movq %rax, -0x2b50(%rbp)
movq -0x10(%rbp), %rax
addq -0x2b38(%rbp), %rax
movq %rax, -0x2b70(%rbp)
movq -0x2b28(%rbp), %rax
movq %rax, -0x2b68(%rbp)
cmpq $0x0, -0x2b28(%rbp)
je 0xb7aa
movq -0x2b28(%rbp), %rax
movq -0x20(%rbp), %rcx
addq (%rcx), %rax
movq %rax, -0x2b78(%rbp)
jmp 0xb7b5
xorl %eax, %eax
movq %rax, -0x2b78(%rbp)
jmp 0xb7b5
movq -0x2b68(%rbp), %rcx
movq -0x2b70(%rbp), %rsi
movq -0x2b78(%rbp), %r8
movl -0x24(%rbp), %eax
andl $-0x3, %eax
orl $0x4, %eax
leaq -0x2b20(%rbp), %rdi
leaq -0x2b48(%rbp), %rdx
leaq -0x2b50(%rbp), %r9
movl %eax, (%rsp)
callq 0x5060
movl %eax, -0x2b5c(%rbp)
cmpl $0x0, -0x2b5c(%rbp)
jl 0xb808
cmpl $0x1, -0x2b5c(%rbp)
jne 0xb82c
movq -0x2b28(%rbp), %rdi
callq 0x3390
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0xb8fa
movq -0x2b48(%rbp), %rax
addq -0x2b38(%rbp), %rax
movq %rax, -0x2b38(%rbp)
movq -0x2b50(%rbp), %rcx
movq -0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
cmpl $0x0, -0x2b5c(%rbp)
jne 0xb860
jmp 0xb8ef
movq -0x2b40(%rbp), %rax
shlq %rax
movq %rax, -0x2b58(%rbp)
cmpq $0x80, -0x2b58(%rbp)
jae 0xb889
movq $0x80, -0x2b58(%rbp)
movq -0x2b28(%rbp), %rdi
movq -0x2b58(%rbp), %rsi
callq 0x3500
movq %rax, -0x2b30(%rbp)
cmpq $0x0, -0x2b30(%rbp)
jne 0xb8ce
movq -0x2b28(%rbp), %rdi
callq 0x3390
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0xb8fa
movq -0x2b30(%rbp), %rax
movq %rax, -0x2b28(%rbp)
movq -0x2b58(%rbp), %rax
movq %rax, -0x2b40(%rbp)
jmp 0xb742
movq -0x2b28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2b80, %rsp           # imm = 0x2B80
popq %rbp
retq
nopw (%rax,%rax)