// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdx, 0xa8(%rsp)
movq %rcx, 0xa0(%rsp)
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movq 0xa0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, (%rax)
je 0x4de22e
movq 0xb0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rax
movq $0x0, (%rax)
jmp 0x4de244
movq $0x1, 0x18(%rsp)
leaq 0x17(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x9b738(%rip), %rsi     # 0x5799bb
movl $0x70, %edx
callq 0x4e8670
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0x4de2a8
movl 0x2c(%rsp), %eax
movl %eax, 0xc4(%rsp)
jmp 0x4de426
movq 0xb8(%rsp), %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0x50(%rsp)
cmpl $0x0, 0x50(%rsp)
jne 0x4de2ff
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0x18(%rsp)
jbe 0x4de2db
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x10(%rsp)
jmp 0x4de2e4
movq 0x18(%rsp), %rax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
movl %eax, %ecx
movq 0x18(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x38(%rsp)
jne 0x4de341
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, 0x20(%rsp)
jbe 0x4de31d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xc(%rsp)
jmp 0x4de326
movq 0x20(%rsp), %rax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x38(%rsp), %eax
movl %eax, %ecx
movq 0x20(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x20(%rsp)
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x4e87a0
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0x4de2bd
movq 0x20(%rsp), %rdx
movl 0x38(%rsp), %eax
addq %rax, %rdx
movq 0xa0(%rsp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movq 0xb8(%rsp), %rax
leaq 0x17(%rsp), %rcx
cmpq %rcx, %rax
je 0x4de39d
movq 0x58(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq %rcx, (%rax)
jmp 0x4de3b7
cmpq $0x0, 0x58(%rsp)
je 0x4de3b5
cmpl $-0x5, 0x2c(%rsp)
jne 0x4de3b5
movq $0x1, 0x18(%rsp)
jmp 0x4de3b7
leaq 0x30(%rsp), %rdi
callq 0x4ec120
cmpl $0x1, 0x2c(%rsp)
jne 0x4de3d0
xorl %eax, %eax
movl %eax, 0x8(%rsp)
jmp 0x4de41b
cmpl $0x2, 0x2c(%rsp)
jne 0x4de3e2
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
movl %eax, 0x4(%rsp)
jmp 0x4de413
cmpl $-0x5, 0x2c(%rsp)
jne 0x4de405
movq 0x18(%rsp), %rax
movl 0x50(%rsp), %ecx
addq %rcx, %rax
cmpq $0x0, %rax
je 0x4de405
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
movl %eax, (%rsp)
jmp 0x4de40c
movl 0x2c(%rsp), %eax
movl %eax, (%rsp)
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)