// File: sisong[P]ApkDiffPatch/zlib1.3.1/deflate.c
// Function: deflateCopy
int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
#ifdef MAXSEG_64K
    (void)dest;
    (void)source;
    return Z_STREAM_ERROR;
#else
    deflate_state *ds;
    deflate_state *ss;


    if (deflateStateCheck(source) || dest == Z_NULL) {
        return Z_STREAM_ERROR;
    }

    ss = source->state;

    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));

    ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
    if (ds == Z_NULL) return Z_MEM_ERROR;
    dest->state = (struct internal_state FAR *) ds;
    zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
    ds->strm = dest;

    ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
    ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));
    ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));
    ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);

    if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
        ds->pending_buf == Z_NULL) {
        deflateEnd (dest);
        return Z_MEM_ERROR;
    }
    /* following zmemcpy do not work for 16-bit MSDOS */
    zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
    zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
    zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
    zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);

    ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
#ifdef LIT_MEM
    ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
    ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
#else
    ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
#endif

    ds->l_desc.dyn_tree = ds->dyn_ltree;
    ds->d_desc.dyn_tree = ds->dyn_dtree;
    ds->bl_desc.dyn_tree = ds->bl_tree;

    return Z_OK;
#endif /* MAXSEG_64K */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x93560
cmpl $0x0, %eax
jne 0x96db5
cmpq $0x0, -0x10(%rbp)
jne 0x96dc1
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x97046
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x70, %edx
callq 0x4320
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdi
movl $0x1, %esi
movl $0x1740, %edx           # imm = 0x1740
callq *%rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x96e12
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x97046
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x1740, %edx           # imm = 0x1740
callq 0x4320
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdi
movq -0x20(%rbp), %rcx
movl 0x50(%rcx), %esi
movl $0x2, %edx
callq *%rax
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdi
movq -0x20(%rbp), %rcx
movl 0x50(%rcx), %esi
movl $0x2, %edx
callq *%rax
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdi
movq -0x20(%rbp), %rcx
movl 0x84(%rcx), %esi
movl $0x2, %edx
callq *%rax
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdi
movq -0x20(%rbp), %rcx
movl 0x1708(%rcx), %esi
movl $0x4, %edx
callq *%rax
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x96f11
movq -0x20(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x96f11
movq -0x20(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x96f11
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x96f26
movq -0x10(%rbp), %rdi
callq 0x930c0
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x97046
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x60(%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x50(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %edx
shlq $0x0, %rdx
callq 0x4320
movq -0x20(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x70(%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, %edx
shlq %rdx
callq 0x4320
movq -0x20(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, %edx
shlq %rdx
callq 0x4320
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rax
movl 0x1708(%rax), %eax
shll $0x2, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x4320
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x28(%rbp), %rdx
movq 0x10(%rdx), %rdx
subq %rdx, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movl 0x1708(%rax), %eax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x1700(%rax)
movq -0x20(%rbp), %rcx
addq $0xd4, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0xb58(%rax)
movq -0x20(%rbp), %rcx
addq $0x9c8, %rcx            # imm = 0x9C8
movq -0x20(%rbp), %rax
movq %rcx, 0xb70(%rax)
movq -0x20(%rbp), %rcx
addq $0xabc, %rcx            # imm = 0xABC
movq -0x20(%rbp), %rax
movq %rcx, 0xb88(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop