// File: sisong[P]ApkDiffPatch/zlib1.3.1/compress.c
// Function: compress2
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
                      uLong sourceLen, int level) {
    z_stream stream;
    int err;
    const uInt max = (uInt)-1;
    uLong left;

    left = *destLen;
    *destLen = 0;

    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;

    err = deflateInit(&stream, level);
    if (err != Z_OK) return err;

    stream.next_out = dest;
    stream.avail_out = 0;
    stream.next_in = (z_const Bytef *)source;
    stream.avail_in = 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 = sourceLen > (uLong)max ? max : (uInt)sourceLen;
            sourceLen -= stream.avail_in;
        }
        err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
    } while (err == Z_OK);

    *destLen = stream.total_out;
    deflateEnd(&stream);
    return err == Z_STREAM_END ? Z_OK : err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl $0xffffffff, -0xa8(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movl -0x2c(%rbp), %esi
leaq -0xa0(%rbp), %rdi
leaq 0x1aef4(%rip), %rdx     # 0xacbef
movl $0x70, %ecx
callq 0x92c40
movl %eax, -0xa4(%rbp)
cmpl $0x0, -0xa4(%rbp)
je 0x91d22
movl -0xa4(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x91e50
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl $0x0, -0x98(%rbp)
cmpl $0x0, -0x80(%rbp)
jne 0x91d96
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0xb0(%rbp)
jbe 0x91d6a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xb4(%rbp)
jmp 0x91d77
movq -0xb0(%rbp), %rax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, %ecx
movq -0xb0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
cmpl $0x0, -0x98(%rbp)
jne 0x91de0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x28(%rbp)
jbe 0x91db7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xb8(%rbp)
jmp 0x91dc1
movq -0x28(%rbp), %rax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movl $0x4, %esi
xorl %eax, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0x94260
movl %eax, -0xa4(%rbp)
cmpl $0x0, -0xa4(%rbp)
je 0x91d49
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0xa0(%rbp), %rdi
callq 0x930c0
cmpl $0x1, -0xa4(%rbp)
jne 0x91e3b
xorl %eax, %eax
movl %eax, -0xbc(%rbp)
jmp 0x91e47
movl -0xa4(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)