// File: sisong[P]ApkDiffPatch/zlib1.3.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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0xffffffff, -0xa0(%rbp) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0xa2078
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
jmp 0xa208e
movq $0x1, -0xb0(%rbp)
leaq -0xb1(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0x90(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
leaq -0x98(%rbp), %rdi
leaq 0xab26(%rip), %rsi      # 0xacbef
movl $0x70, %edx
callq 0x9b0e0
movl %eax, -0x9c(%rbp)
cmpl $0x0, -0x9c(%rbp)
je 0xa20f0
movl -0x9c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xa22a5
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x78(%rbp)
cmpl $0x0, -0x78(%rbp)
jne 0xa214c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0xb0(%rbp)
jbe 0xa2120
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xb8(%rbp)
jmp 0xa212d
movq -0xb0(%rbp), %rax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl %eax, %ecx
movq -0xb0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
cmpl $0x0, -0x90(%rbp)
jne 0xa21a2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0xa8(%rbp)
jbe 0xa2170
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xbc(%rbp)
jmp 0xa217d
movq -0xa8(%rbp), %rax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, %ecx
movq -0xa8(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xa8(%rbp)
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x9b200
movl %eax, -0x9c(%rbp)
cmpl $0x0, -0x9c(%rbp)
je 0xa20ff
movq -0xa8(%rbp), %rdx
movl -0x90(%rbp), %eax
addq %rax, %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
leaq -0xb1(%rbp), %rcx
cmpq %rcx, %rax
je 0xa21fd
movq -0x70(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0xa221a
cmpq $0x0, -0x70(%rbp)
je 0xa2218
cmpl $-0x5, -0x9c(%rbp)
jne 0xa2218
movq $0x1, -0xb0(%rbp)
jmp 0xa221a
leaq -0x98(%rbp), %rdi
callq 0x9db40
cmpl $0x1, -0x9c(%rbp)
jne 0xa2239
xorl %eax, %eax
movl %eax, -0xc0(%rbp)
jmp 0xa229c
cmpl $0x2, -0x9c(%rbp)
jne 0xa224f
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
movl %eax, -0xc4(%rbp)
jmp 0xa2290
cmpl $-0x5, -0x9c(%rbp)
jne 0xa2278
movq -0xb0(%rbp), %rax
movl -0x78(%rbp), %ecx
addq %rcx, %rax
cmpq $0x0, %rax
je 0xa2278
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
movl %eax, -0xc8(%rbp)
jmp 0xa2284
movl -0x9c(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)