// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/zlib-1.3.0.1/uncompr.c
// Function: uncompress2
int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
                        uLong *sourceLen) {
    z_stream stream;
    int err;
    const uInt max = (uInt)-1;
    uLong len, left;
    Byte buf[1];    /* for detection of incomplete stream when *destLen == 0 */

    len = *sourceLen;
    if (*destLen) {
        left = *destLen;
        *destLen = 0;
    }
    else {
        left = 1;
        dest = buf;
    }

    stream.next_in = (z_const Bytef *)source;
    stream.avail_in = 0;
    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;

    err = inflateInit(&stream);
    if (err != Z_OK) return err;

    stream.next_out = dest;
    stream.avail_out = 0;

    do {
        if (stream.avail_out == 0) {
            stream.avail_out = left > (uLong)max ? max : (uInt)left;
            left -= stream.avail_out;
        }
        if (stream.avail_in == 0) {
            stream.avail_in = len > (uLong)max ? max : (uInt)len;
            len -= stream.avail_in;
        }
        err = inflate(&stream, Z_NO_FLUSH);
    } while (err == Z_OK);

    *sourceLen -= len + stream.avail_in;
    if (dest != buf)
        *destLen = stream.total_out;
    else if (stream.total_out && err == Z_BUF_ERROR)
        left = 1;

    inflateEnd(&stream);
    return err == Z_STREAM_END ? Z_OK :
           err == Z_NEED_DICT ? Z_DATA_ERROR  :
           err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
           err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r14
movq %rsi, %rbx
movq (%rcx), %r15
movq (%rsi), %r13
testq %r13, %r13
je 0x33088a
movq %rdi, %rbp
movq $0x0, (%rbx)
jmp 0x330895
movl $0x1, %r13d
leaq 0x7(%rsp), %rbp
leaq 0x18(%rsp), %rdi
movq %rdx, (%rdi)
movl $0x0, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rdi)
movq $0x0, 0x50(%rdi)
leaq 0x90361(%rip), %rsi     # 0x3c0c1b
movl $0x70, %edx
callq 0x336070
testl %eax, %eax
je 0x3308da
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x10(%rsp)
leaq 0x18(%rsp), %r12
movq %rbp, 0x8(%rsp)
movq %rbp, 0x18(%r12)
movl $0x0, 0x20(%r12)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x0, 0x38(%rsp)
jne 0x330917
cmpq %r14, %r13
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovbq %r13, %rax
movl %eax, 0x38(%rsp)
subq %rax, %r13
cmpl $0x0, 0x20(%rsp)
jne 0x330931
cmpq %r14, %r15
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovbq %r15, %rax
movl %eax, 0x20(%rsp)
subq %rax, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x3360ee
testl %eax, %eax
je 0x3308fd
movl %eax, %ebp
movl 0x20(%rsp), %eax
addq %rax, %r15
movq 0x10(%rsp), %rax
subq %r15, (%rax)
leaq 0x7(%rsp), %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, 0x8(%rsp)
je 0x330966
movq %rax, (%rbx)
jmp 0x330979
testq %rax, %rax
movl $0x1, %eax
cmoveq %r13, %rax
cmpl $-0x5, %ebp
cmoveq %rax, %r13
leaq 0x18(%rsp), %rdi
callq 0x337ae6
cmpl $0x2, %ebp
je 0x3309b2
cmpl $0x1, %ebp
je 0x3309ab
cmpl $-0x5, %ebp
jne 0x3309a4
movl 0x38(%rsp), %ecx
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
addq %rcx, %r13
jne 0x3308c8
movl %ebp, %eax
jmp 0x3308c8
xorl %eax, %eax
jmp 0x3308c8
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jmp 0x3308c8