// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/zlib1.3.1/inflate.c
// Function: inflateCopy
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
    struct inflate_state FAR *state;
    struct inflate_state FAR *copy;
    unsigned char FAR *window;
    unsigned wsize;

    /* check input */
    if (inflateStateCheck(source) || dest == Z_NULL)
        return Z_STREAM_ERROR;
    state = (struct inflate_state FAR *)source->state;

    /* allocate space */
    copy = (struct inflate_state FAR *)
           ZALLOC(source, 1, sizeof(struct inflate_state));
    if (copy == Z_NULL) return Z_MEM_ERROR;
    window = Z_NULL;
    if (state->window != Z_NULL) {
        window = (unsigned char FAR *)
                 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
        if (window == Z_NULL) {
            ZFREE(source, copy);
            return Z_MEM_ERROR;
        }
    }

    /* copy state */
    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
    zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
    copy->strm = dest;
    if (state->lencode >= state->codes &&
        state->lencode <= state->codes + ENOUGH - 1) {
        copy->lencode = copy->codes + (state->lencode - state->codes);
        copy->distcode = copy->codes + (state->distcode - state->codes);
    }
    copy->next = copy->codes + (state->next - state->codes);
    if (window != Z_NULL) {
        wsize = 1U << state->wbits;
        zmemcpy(window, state->window, wsize);
    }
    copy->window = window;
    dest->state = (struct internal_state FAR *)copy;
    return Z_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r13
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x44ae0
pushq $-0x2
popq %rbp
testq %rbx, %rbx
je 0x46e3b
testl %eax, %eax
jne 0x46e3b
movq 0x38(%r13), %r15
movq 0x50(%r13), %rdi
pushq $0x1
popq %r12
movl %r12d, %esi
movl $0x1bf8, %edx           # imm = 0x1BF8
callq *0x40(%r13)
pushq $-0x4
popq %rbp
testq %rax, %rax
je 0x46e3b
movq %rax, %r14
cmpq $0x0, 0x48(%r15)
je 0x46d8a
movq 0x50(%r13), %rdi
movb 0x38(%r15), %cl
movl %r12d, %esi
shll %cl, %esi
movl %r12d, %edx
callq *0x40(%r13)
movq %rax, %r12
testq %rax, %rax
jne 0x46d8d
movq 0x50(%r13), %rdi
movq %r14, %rsi
callq *0x48(%r13)
jmp 0x46e3b
xorl %r12d, %r12d
pushq $0x70
popq %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x42c0
movl $0x1bf8, %edx           # imm = 0x1BF8
movq %r14, %rdi
movq %r15, %rsi
callq 0x42c0
movq %rbx, (%r14)
movq 0x68(%r15), %rdx
leaq 0x558(%r15), %rax
movq %rdx, %rcx
subq %rax, %rcx
setb %sil
leaq 0x1be4(%r15), %rdi
cmpq %rdi, %rdx
seta %dl
orb %sil, %dl
cmpb $0x1, %dl
je 0x46dfb
addq %r14, %rcx
addq $0x558, %rcx            # imm = 0x558
movq %rcx, 0x68(%r14)
movq 0x70(%r15), %rcx
subq %rax, %rcx
addq %r14, %rcx
addq $0x558, %rcx            # imm = 0x558
movq %rcx, 0x70(%r14)
movq 0x90(%r15), %rcx
subq %rax, %rcx
leaq (%r14,%rcx), %rax
addq $0x558, %rax            # imm = 0x558
movq %rax, 0x90(%r14)
testq %r12, %r12
je 0x46e31
movb 0x38(%r15), %cl
pushq $0x1
popq %rdx
shlq %cl, %rdx
movq 0x48(%r15), %rsi
movq %r12, %rdi
callq 0x42c0
movq %r12, 0x48(%r14)
movq %r14, 0x38(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq