// File: /workspace/github_cpp_makefile_star2_O3/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 0x4e621
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testq %rbx, %rbx
je 0x508ef
testl %eax, %eax
jne 0x508ef
movq 0x38(%r13), %r15
movq 0x50(%r13), %rdi
movl $0x1, %esi
movl $0x1bf8, %edx           # imm = 0x1BF8
callq *0x40(%r13)
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
testq %rax, %rax
je 0x508ef
movq %rax, %r14
cmpq $0x0, 0x48(%r15)
je 0x5083a
movq 0x50(%r13), %rdi
movb 0x38(%r15), %cl
movl $0x1, %esi
shll %cl, %esi
movl $0x1, %edx
callq *0x40(%r13)
movq %rax, %r12
testq %rax, %rax
jne 0x5083d
movq 0x50(%r13), %rdi
movq %r14, %rsi
callq *0x48(%r13)
jmp 0x508ef
xorl %r12d, %r12d
movl $0x70, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4290
movl $0x1bf8, %edx           # imm = 0x1BF8
movq %r14, %rdi
movq %r15, %rsi
callq 0x4290
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 0x508ad
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 0x508e5
movb 0x38(%r15), %cl
movl $0x1, %edx
shlq %cl, %rdx
movq 0x48(%r15), %rsi
movq %r12, %rdi
callq 0x4290
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