// File: /workspace/github_c_makefile_star2_O3/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 0x3275f6
movq %rdi, %r12
movq $0x0, (%rbx)
jmp 0x327601
movl $0x1, %r13d
leaq 0x7(%rsp), %r12
leaq 0x18(%rsp), %rdi
movq %rdx, (%rdi)
movl $0x0, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rdi)
movq $0x0, 0x50(%rdi)
leaq 0x8fee5(%rip), %rsi     # 0x3b750b
movl $0x70, %edx
callq 0x32cdb2
testl %eax, %eax
je 0x327646
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x10(%rsp)
movq %r12, %rax
leaq 0x18(%rsp), %r12
movq %rax, 0x8(%rsp)
movq %rax, 0x18(%r12)
movl $0x0, 0x20(%r12)
xorl %eax, %eax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x327685
cmpq %r14, %r13
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovbq %r13, %rax
movl %eax, 0x38(%rsp)
subq %rax, %r13
cmpl $0x0, 0x20(%rsp)
jne 0x32769f
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 0x32ce30
testl %eax, %eax
jne 0x3276b3
movl 0x38(%rsp), %eax
jmp 0x32766e
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 0x3276da
movq %rax, (%rbx)
jmp 0x3276ed
testq %rax, %rax
movl $0x1, %eax
cmoveq %r13, %rax
cmpl $-0x5, %ebp
cmoveq %rax, %r13
leaq 0x18(%rsp), %rdi
callq 0x32e9fc
cmpl $0x2, %ebp
je 0x327726
cmpl $0x1, %ebp
je 0x32771f
cmpl $-0x5, %ebp
jne 0x327718
movl 0x38(%rsp), %ecx
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
addq %rcx, %r13
jne 0x327634
movl %ebp, %eax
jmp 0x327634
xorl %eax, %eax
jmp 0x327634
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jmp 0x327634