// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.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:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jne 0xdd9fb
movq 0x28(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x28(%rsp), %rcx
movq 0x50(%rcx), %rdi
movq 0x10(%rsp), %rcx
movl 0x38(%rcx), %ecx
movl $0x1, %esi
shll %cl, %esi
movl $0x1, %edx
callq *%rax
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x10(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jne 0xdd9f9
movl $0x1, 0x34(%rsp)
jmp 0xddba1
jmp 0xdd9fb
movq 0x10(%rsp), %rax
cmpl $0x0, 0x3c(%rax)
jne 0xdda37
movq 0x10(%rsp), %rax
movl 0x38(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x3c(%rax)
movq 0x10(%rsp), %rax
movl $0x0, 0x44(%rax)
movq 0x10(%rsp), %rax
movl $0x0, 0x40(%rax)
movl 0x1c(%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl 0x3c(%rcx), %eax
jb 0xdda95
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rax
movl 0x3c(%rax), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movq 0x10(%rsp), %rax
movl 0x3c(%rax), %eax
movl %eax, %edx
callq 0xb500
movq 0x10(%rsp), %rax
movl $0x0, 0x44(%rax)
movq 0x10(%rsp), %rax
movl 0x3c(%rax), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x40(%rax)
jmp 0xddb99
movq 0x10(%rsp), %rax
movl 0x3c(%rax), %eax
movq 0x10(%rsp), %rcx
subl 0x44(%rcx), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jbe 0xddabb
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rsp), %rax
movl 0x44(%rax), %eax
addq %rax, %rdi
movq 0x20(%rsp), %rsi
movl 0x1c(%rsp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movl 0xc(%rsp), %eax
movl %eax, %edx
callq 0xb500
movl 0xc(%rsp), %ecx
movl 0x1c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x1c(%rsp)
cmpl $0x0, 0x1c(%rsp)
je 0xddb47
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rsp), %rsi
movl 0x1c(%rsp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movl 0x1c(%rsp), %eax
movl %eax, %edx
callq 0xb500
movl 0x1c(%rsp), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x44(%rax)
movq 0x10(%rsp), %rax
movl 0x3c(%rax), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x40(%rax)
jmp 0xddb97
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %rax
addl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
movq 0x10(%rsp), %rax
movl 0x44(%rax), %eax
movq 0x10(%rsp), %rcx
cmpl 0x3c(%rcx), %eax
jne 0xddb74
movq 0x10(%rsp), %rax
movl $0x0, 0x44(%rax)
movq 0x10(%rsp), %rax
movl 0x40(%rax), %eax
movq 0x10(%rsp), %rcx
cmpl 0x3c(%rcx), %eax
jae 0xddb95
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %rax
addl 0x40(%rax), %ecx
movl %ecx, 0x40(%rax)
jmp 0xddb97
jmp 0xddb99
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw (%rax,%rax)