// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.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, 4);

    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, (uInt)ds->pending_buf_size);

    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:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0xd0920
cmpl $0x0, %eax
jne 0xd4635
cmpq $0x0, 0x18(%rsp)
jne 0xd4642
movl $0xfffffffe, 0x24(%rsp) # imm = 0xFFFFFFFE
jmp 0xd48f9
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x70, %edx
callq 0xb500
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x50(%rcx), %rdi
movl $0x1, %esi
movl $0x1740, %edx           # imm = 0x1740
callq *%rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0xd469b
movl $0xfffffffc, 0x24(%rsp) # imm = 0xFFFFFFFC
jmp 0xd48f9
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
movl $0x1740, %edx           # imm = 0x1740
callq 0xb500
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x50(%rcx), %rdi
movq 0x8(%rsp), %rcx
movl 0x50(%rcx), %esi
movl $0x2, %edx
callq *%rax
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x50(%rcx), %rdi
movq 0x8(%rsp), %rcx
movl 0x50(%rcx), %esi
movl $0x2, %edx
callq *%rax
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x50(%rcx), %rdi
movq 0x8(%rsp), %rcx
movl 0x84(%rcx), %esi
movl $0x2, %edx
callq *%rax
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x78(%rax)
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x50(%rcx), %rdi
movq 0x8(%rsp), %rcx
movl 0x1708(%rcx), %esi
movl $0x4, %edx
callq *%rax
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rax
cmpq $0x0, 0x60(%rax)
je 0xd47b3
movq 0x8(%rsp), %rax
cmpq $0x0, 0x70(%rax)
je 0xd47b3
movq 0x8(%rsp), %rax
cmpq $0x0, 0x78(%rax)
je 0xd47b3
movq 0x8(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xd47ca
movq 0x18(%rsp), %rdi
callq 0xd0400
movl $0xfffffffc, 0x24(%rsp) # imm = 0xFFFFFFFC
jmp 0xd48f9
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rdi
movq (%rsp), %rax
movq 0x60(%rax), %rsi
movq 0x8(%rsp), %rax
movl 0x50(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %edx
shlq $0x0, %rdx
callq 0xb500
movq 0x8(%rsp), %rax
movq 0x70(%rax), %rdi
movq (%rsp), %rax
movq 0x70(%rax), %rsi
movq 0x8(%rsp), %rax
movl 0x50(%rax), %eax
movl %eax, %edx
shlq %rdx
callq 0xb500
movq 0x8(%rsp), %rax
movq 0x78(%rax), %rdi
movq (%rsp), %rax
movq 0x78(%rax), %rsi
movq 0x8(%rsp), %rax
movl 0x84(%rax), %eax
movl %eax, %edx
shlq %rdx
callq 0xb500
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movq (%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movl %eax, %edx
callq 0xb500
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
movq (%rsp), %rax
movq 0x20(%rax), %rax
movq (%rsp), %rdx
movq 0x10(%rdx), %rdx
subq %rdx, %rax
addq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x8(%rsp), %rax
movl 0x1708(%rax), %eax
addq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x1700(%rax)
movq 0x8(%rsp), %rcx
addq $0xd4, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0xb58(%rax)
movq 0x8(%rsp), %rcx
addq $0x9c8, %rcx            # imm = 0x9C8
movq 0x8(%rsp), %rax
movq %rcx, 0xb70(%rax)
movq 0x8(%rsp), %rcx
addq $0xabc, %rcx            # imm = 0xABC
movq 0x8(%rsp), %rax
movq %rcx, 0xb88(%rax)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)