// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rdi
callq 0x4a4de
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testq %r15, %r15
je 0x4c36b
testl %eax, %eax
jne 0x4c36b
movq 0x38(%r14), %rbx
movl $0x70, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x4290
movq 0x50(%r15), %rdi
movl $0x1, %esi
movl $0x1740, %edx           # imm = 0x1740
callq *0x40(%r15)
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
testq %rax, %rax
je 0x4c36b
movq %rax, %r14
movq %rax, 0x38(%r15)
movl $0x1740, %edx           # imm = 0x1740
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4290
movq %r15, (%r14)
movq 0x50(%r15), %rdi
movl 0x50(%r14), %esi
movl $0x2, %edx
callq *0x40(%r15)
movq %rax, 0x60(%r14)
movq 0x50(%r15), %rdi
movl 0x50(%r14), %esi
movl $0x2, %edx
callq *0x40(%r15)
movq %rax, 0x70(%r14)
movq 0x50(%r15), %rdi
movl 0x84(%r14), %esi
movl $0x2, %edx
callq *0x40(%r15)
movq %rax, 0x78(%r14)
movq 0x50(%r15), %rdi
movl 0x1708(%r14), %esi
movl $0x4, %edx
callq *0x40(%r15)
movq %rax, 0x10(%r14)
movq 0x60(%r14), %rdi
testq %rdi, %rdi
je 0x4c363
cmpq $0x0, 0x70(%r14)
je 0x4c363
cmpq $0x0, 0x78(%r14)
sete %cl
testq %rax, %rax
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0x4c378
movq %r15, %rdi
callq 0x4a16a
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x60(%rbx), %rsi
movl 0x50(%r14), %edx
addl %edx, %edx
callq 0x4290
movq 0x70(%r14), %rdi
movq 0x70(%rbx), %rsi
movl 0x50(%r14), %edx
addq %rdx, %rdx
callq 0x4290
movq 0x78(%r14), %rdi
movq 0x78(%rbx), %rsi
movl 0x84(%r14), %edx
addq %rdx, %rdx
callq 0x4290
movq 0x10(%r14), %rdi
movq 0x10(%rbx), %rsi
movl 0x1708(%r14), %edx
shll $0x2, %edx
callq 0x4290
movq 0x10(%r14), %rax
movq 0x20(%rbx), %rcx
subq 0x10(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0x20(%r14)
movl 0x1708(%r14), %ecx
addq %rax, %rcx
movq %rcx, 0x1700(%r14)
leaq 0xd4(%r14), %rax
movq %rax, 0xb58(%r14)
leaq 0x9c8(%r14), %rax
movq %rax, 0xb70(%r14)
movq %r14, %rax
addq $0xabc, %rax            # imm = 0xABC
movq %rax, 0xb88(%r14)
xorl %ebp, %ebp
jmp 0x4c36b