// File: sisong[P]ApkDiffPatch/zlib1.3.1/inflate.c
// Function: updatewindow
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
    struct inflate_state FAR *state;
    unsigned dist;

    state = (struct inflate_state FAR *)strm->state;

    /* if it hasn't been done already, allocate space for the window */
    if (state->window == Z_NULL) {
        state->window = (unsigned char FAR *)
                        ZALLOC(strm, 1U << state->wbits,
                               sizeof(unsigned char));
        if (state->window == Z_NULL) return 1;
    }

    /* if window not in use yet, initialize */
    if (state->wsize == 0) {
        state->wsize = 1U << state->wbits;
        state->wnext = 0;
        state->whave = 0;
    }

    /* copy state->wsize or less output bytes into the circular window */
    if (copy >= state->wsize) {
        zmemcpy(state->window, end - state->wsize, state->wsize);
        state->wnext = 0;
        state->whave = state->wsize;
    }
    else {
        dist = state->wsize - state->wnext;
        if (dist > copy) dist = copy;
        zmemcpy(state->window + state->wnext, end - copy, dist);
        copy -= dist;
        if (copy) {
            zmemcpy(state->window, end - copy, copy);
            state->wnext = copy;
            state->whave = state->wsize;
        }
        else {
            state->wnext += dist;
            if (state->wnext == state->wsize) state->wnext = 0;
            if (state->whave < state->wsize) state->whave += dist;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x9d9b3
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rdi
movq -0x28(%rbp), %rcx
movl 0x38(%rcx), %ecx
movl $0x1, %esi
shll %cl, %esi
movl $0x1, %edx
callq *%rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x9d9b1
movl $0x1, -0x4(%rbp)
jmp 0x9db29
jmp 0x9d9b3
movq -0x28(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jne 0x9d9ea
movq -0x28(%rbp), %rax
movl 0x38(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x40(%rax)
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x3c(%rcx), %eax
jb 0x9da3f
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movq -0x28(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, %edx
callq 0x4320
movq -0x28(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x28(%rbp), %rax
movl 0x3c(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x40(%rax)
jmp 0x9db22
movq -0x28(%rbp), %rax
movl 0x3c(%rax), %eax
movq -0x28(%rbp), %rcx
subl 0x44(%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jbe 0x9da5e
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x44(%rax), %eax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movl -0x2c(%rbp), %eax
movl %eax, %edx
callq 0x4320
movl -0x2c(%rbp), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x9dad9
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0x4320
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x28(%rbp), %rax
movl 0x3c(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x40(%rax)
jmp 0x9db20
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
addl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
movq -0x28(%rbp), %rax
movl 0x44(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x3c(%rcx), %eax
jne 0x9db01
movq -0x28(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x28(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x3c(%rcx), %eax
jae 0x9db1e
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
addl 0x40(%rax), %ecx
movl %ecx, 0x40(%rax)
jmp 0x9db20
jmp 0x9db22
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)