// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/png/inffast.c
// Function: inflate_fast
void ZLIB_INTERNAL inflate_fast(strm, start)
z_streamp strm;
unsigned start;         /* inflate()'s starting value for strm->avail_out */
{
    struct inflate_state FAR *state;
    unsigned char FAR *in;      /* local strm->next_in */
    unsigned char FAR *last;    /* while in < last, enough input available */
    unsigned char FAR *out;     /* local strm->next_out */
    unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
    unsigned char FAR *end;     /* while out < end, enough space available */
#ifdef INFLATE_STRICT
    unsigned dmax;              /* maximum distance from zlib header */
#endif
    unsigned wsize;             /* window size or zero if not using window */
    unsigned whave;             /* valid bytes in the window */
    unsigned wnext;             /* window write index */
    unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
    unsigned long hold;         /* local strm->hold */
    unsigned bits;              /* local strm->bits */
    code const FAR *lcode;      /* local strm->lencode */
    code const FAR *dcode;      /* local strm->distcode */
    unsigned lmask;             /* mask for first level of length codes */
    unsigned dmask;             /* mask for first level of distance codes */
    code here;                  /* retrieved table entry */
    unsigned op;                /* code bits, operation, extra bits, or */
                                /*  window position, window bytes to copy */
    unsigned len;               /* match length, unused bytes */
    unsigned dist;              /* match distance */
    unsigned char FAR *from;    /* where to copy match from */

    /* copy state to local variables */
    state = (struct inflate_state FAR *)strm->state;
    in = strm->next_in - OFF;
    last = in + (strm->avail_in - 5);
    out = strm->next_out - OFF;
    beg = out - (start - strm->avail_out);
    end = out + (strm->avail_out - 257);
#ifdef INFLATE_STRICT
    dmax = state->dmax;
#endif
    wsize = state->wsize;
    whave = state->whave;
    wnext = state->wnext;
    window = state->window;
    hold = state->hold;
    bits = state->bits;
    lcode = state->lencode;
    dcode = state->distcode;
    lmask = (1U << state->lenbits) - 1;
    dmask = (1U << state->distbits) - 1;

    /* decode literals and length/distances until end-of-block or not enough
       input data or output space */
    do {
        if (bits < 15) {
            hold += (unsigned long)(PUP(in)) << bits;
            bits += 8;
            hold += (unsigned long)(PUP(in)) << bits;
            bits += 8;
        }
        here = lcode[hold & lmask];
      dolen:
        op = (unsigned)(here.bits);
        hold >>= op;
        bits -= op;
        op = (unsigned)(here.op);
        if (op == 0) {                          /* literal */
            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
                    "inflate:         literal '%c'\n" :
                    "inflate:         literal 0x%02x\n", here.val));
            PUP(out) = (unsigned char)(here.val);
        }
        else if (op & 16) {                     /* length base */
            len = (unsigned)(here.val);
            op &= 15;                           /* number of extra bits */
            if (op) {
                if (bits < op) {
                    hold += (unsigned long)(PUP(in)) << bits;
                    bits += 8;
                }
                len += (unsigned)hold & ((1U << op) - 1);
                hold >>= op;
                bits -= op;
            }
            Tracevv((stderr, "inflate:         length %u\n", len));
            if (bits < 15) {
                hold += (unsigned long)(PUP(in)) << bits;
                bits += 8;
                hold += (unsigned long)(PUP(in)) << bits;
                bits += 8;
            }
            here = dcode[hold & dmask];
          dodist:
            op = (unsigned)(here.bits);
            hold >>= op;
            bits -= op;
            op = (unsigned)(here.op);
            if (op & 16) {                      /* distance base */
                dist = (unsigned)(here.val);
                op &= 15;                       /* number of extra bits */
                if (bits < op) {
                    hold += (unsigned long)(PUP(in)) << bits;
                    bits += 8;
                    if (bits < op) {
                        hold += (unsigned long)(PUP(in)) << bits;
                        bits += 8;
                    }
                }
                dist += (unsigned)hold & ((1U << op) - 1);
#ifdef INFLATE_STRICT
                if (dist > dmax) {
                    strm->msg = (char *)"invalid distance too far back";
                    state->mode = BAD;
                    break;
                }
#endif
                hold >>= op;
                bits -= op;
                Tracevv((stderr, "inflate:         distance %u\n", dist));
                op = (unsigned)(out - beg);     /* max distance in output */
                if (dist > op) {                /* see if copy from window */
                    op = dist - op;             /* distance back in window */
                    if (op > whave) {
                        if (state->sane) {
                            strm->msg =
                                (char *)"invalid distance too far back";
                            state->mode = BAD;
                            break;
                        }
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
                        if (len <= op - whave) {
                            do {
                                PUP(out) = 0;
                            } while (--len);
                            continue;
                        }
                        len -= op - whave;
                        do {
                            PUP(out) = 0;
                        } while (--op > whave);
                        if (op == 0) {
                            from = out - dist;
                            do {
                                PUP(out) = PUP(from);
                            } while (--len);
                            continue;
                        }
#endif
                    }
                    from = window - OFF;
                    if (wnext == 0) {           /* very common case */
                        from += wsize - op;
                        if (op < len) {         /* some from window */
                            len -= op;
                            do {
                                PUP(out) = PUP(from);
                            } while (--op);
                            from = out - dist;  /* rest from output */
                        }
                    }
                    else if (wnext < op) {      /* wrap around window */
                        from += wsize + wnext - op;
                        op -= wnext;
                        if (op < len) {         /* some from end of window */
                            len -= op;
                            do {
                                PUP(out) = PUP(from);
                            } while (--op);
                            from = window - OFF;
                            if (wnext < len) {  /* some from start of window */
                                op = wnext;
                                len -= op;
                                do {
                                    PUP(out) = PUP(from);
                                } while (--op);
                                from = out - dist;      /* rest from output */
                            }
                        }
                    }
                    else {                      /* contiguous in window */
                        from += wnext - op;
                        if (op < len) {         /* some from window */
                            len -= op;
                            do {
                                PUP(out) = PUP(from);
                            } while (--op);
                            from = out - dist;  /* rest from output */
                        }
                    }
                    while (len > 2) {
                        PUP(out) = PUP(from);
                        PUP(out) = PUP(from);
                        PUP(out) = PUP(from);
                        len -= 3;
                    }
                    if (len) {
                        PUP(out) = PUP(from);
                        if (len > 1)
                            PUP(out) = PUP(from);
                    }
                }
                else {
                    from = out - dist;          /* copy direct from output */
                    do {                        /* minimum length is three */
                        PUP(out) = PUP(from);
                        PUP(out) = PUP(from);
                        PUP(out) = PUP(from);
                        len -= 3;
                    } while (len > 2);
                    if (len) {
                        PUP(out) = PUP(from);
                        if (len > 1)
                            PUP(out) = PUP(from);
                    }
                }
            }
            else if ((op & 64) == 0) {          /* 2nd level distance code */
                here = dcode[here.val + (hold & ((1U << op) - 1))];
                goto dodist;
            }
            else {
                strm->msg = (char *)"invalid distance code";
                state->mode = BAD;
                break;
            }
        }
        else if ((op & 64) == 0) {              /* 2nd level length code */
            here = lcode[here.val + (hold & ((1U << op) - 1))];
            goto dolen;
        }
        else if (op & 32) {                     /* end-of-block */
            Tracevv((stderr, "inflate:         end of block\n"));
            state->mode = TYPE;
            break;
        }
        else {
            strm->msg = (char *)"invalid literal/length code";
            state->mode = BAD;
            break;
        }
    } while (in < last && out < end);

    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
    len = bits >> 3;
    in -= len;
    bits -= len << 3;
    hold &= (1U << bits) - 1;

    /* update state and return */
    strm->next_in = in + OFF;
    strm->next_out = out + OFF;
    strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
    strm->avail_out = (unsigned)(out < end ?
                                 257 + (end - out) : 257 - (out - end));
    state->hold = hold;
    state->bits = bits;
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x38(%rdi), %r12
movq (%rdi), %rbx
movl 0x8(%rdi), %eax
addl $-0x5, %eax
leaq (%rbx,%rax), %r14
decq %r14
decq %rbx
movq 0x18(%rdi), %rax
leaq -0x1(%rax), %r10
movl 0x20(%rdi), %ecx
subl %ecx, %esi
movq %r10, %rdx
subq %rsi, %rdx
movq %rdx, -0x18(%rsp)
addl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
addq %rcx, %rax
decq %rax
movq %rax, -0x28(%rsp)
movl 0x34(%r12), %edx
movl 0x38(%r12), %eax
movl %eax, -0x34(%rsp)
movl 0x3c(%r12), %r11d
movq 0x40(%r12), %rsi
movq %rsi, -0x48(%rsp)
movb 0x70(%r12), %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
shll %cl, %eax
movq 0x48(%r12), %r8
notl %eax
movq %rax, -0x8(%rsp)
movb 0x74(%r12), %cl
movl %ebp, %eax
shll %cl, %eax
notl %eax
movq %rax, -0x10(%rsp)
movl 0x50(%r12), %eax
movq 0x60(%r12), %r15
movq 0x68(%r12), %r13
leaq -0x1(%rsi), %rcx
movq %rcx, -0x50(%rsp)
movq %rdx, -0x20(%rsp)
leal (%r11,%rdx), %ecx
movl %ecx, -0x38(%rsp)
cmpl $0xe, %eax
ja 0x92730
movzbl 0x1(%rbx), %edx
movl %eax, %ecx
shlq %cl, %rdx
addq %r8, %rdx
movzbl 0x2(%rbx), %r8d
leal 0x8(%rax), %ecx
shlq %cl, %r8
addq $0x2, %rbx
addq %rdx, %r8
orl $0x10, %eax
movl %r8d, %esi
andl -0x8(%rsp), %esi
movzbl 0x1(%r15,%rsi,4), %ecx
shrq %cl, %r8
movzbl (%r15,%rsi,4), %edx
subl %ecx, %eax
movzwl 0x2(%r15,%rsi,4), %r9d
testl %edx, %edx
je 0x9276f
testb $0x10, %dl
jne 0x9277b
testb $0x40, %dl
jne 0x92ad3
movl %ebp, %esi
movl %edx, %ecx
shll %cl, %esi
notl %esi
andl %r8d, %esi
addq %r9, %rsi
jmp 0x92737
movb %r9b, 0x1(%r10)
incq %r10
jmp 0x92aa4
andl $0xf, %edx
je 0x927ac
cmpl %edx, %eax
jae 0x92796
movzbl 0x1(%rbx), %esi
movl %eax, %ecx
shlq %cl, %rsi
incq %rbx
addq %rsi, %r8
addl $0x8, %eax
movl %ebp, %esi
movl %edx, %ecx
shll %cl, %esi
notl %esi
andl %r8d, %esi
shrq %cl, %r8
addl %r9d, %esi
subl %edx, %eax
movl %esi, %r9d
cmpl $0xe, %eax
movq %r12, -0x30(%rsp)
movq %r14, -0x60(%rsp)
movq %r11, -0x58(%rsp)
ja 0x927e1
movzbl 0x1(%rbx), %edx
movl %eax, %ecx
shlq %cl, %rdx
addq %r8, %rdx
movzbl 0x2(%rbx), %r8d
leal 0x8(%rax), %ecx
shlq %cl, %r8
addq $0x2, %rbx
addq %rdx, %r8
orl $0x10, %eax
movl %r8d, %r12d
andl -0x10(%rsp), %r12d
movl %eax, %esi
movq %r8, %r14
movzbl 0x1(%r13,%r12,4), %ecx
shrq %cl, %r14
movzbl (%r13,%r12,4), %edx
movzwl 0x2(%r13,%r12,4), %r11d
subl %ecx, %esi
testb $0x10, %dl
jne 0x92829
testb $0x40, %dl
jne 0x92ae1
movl %ebp, %r12d
movl %edx, %ecx
shll %cl, %r12d
movl %r11d, %eax
notl %r12d
andl %r14d, %r12d
addq %rax, %r12
jmp 0x927ee
andl $0xf, %edx
cmpl %edx, %esi
movq -0x30(%rsp), %r12
jae 0x92861
movzbl 0x1(%rbx), %r8d
movl %esi, %ecx
shlq %cl, %r8
addq %r14, %r8
leal 0x8(%rsi), %eax
cmpl %edx, %eax
jae 0x92868
movzbl 0x2(%rbx), %r14d
movl %eax, %ecx
shlq %cl, %r14
addq $0x2, %rbx
addq %r14, %r8
addl $0x10, %esi
movl %esi, %eax
jmp 0x9286b
movl %esi, %eax
movq %r14, %r8
jmp 0x9286b
incq %rbx
movl %ebp, %r14d
movl %edx, %ecx
shll %cl, %r14d
notl %r14d
andl %r8d, %r14d
addl %r11d, %r14d
shrq %cl, %r8
subl %edx, %eax
movl %r10d, %edx
subl -0x18(%rsp), %edx
movl %r14d, %ecx
subl %edx, %r14d
jbe 0x9293f
cmpl -0x34(%rsp), %r14d
jbe 0x928aa
cmpl $0x0, 0x1be0(%r12)
jne 0x92b5f
movl %r14d, %esi
movq -0x58(%rsp), %r11
testq %r11, %r11
je 0x929c2
cmpl %r11d, %r14d
jbe 0x929ef
movl -0x38(%rsp), %edx
subl %r14d, %edx
subl %r11d, %r14d
movl %r9d, %esi
subl %r14d, %esi
jbe 0x92a23
movl %r14d, %r9d
addq -0x48(%rsp), %rdx
xorl %r11d, %r11d
movb (%rdx,%r11), %r14b
movb %r14b, 0x1(%r10,%r11)
incq %r11
cmpl %r11d, %r9d
jne 0x928e5
addq %r11, %r10
movq -0x58(%rsp), %r11
cmpl %r11d, %esi
movq -0x60(%rsp), %r14
jbe 0x92ac6
movl %esi, -0x3c(%rsp)
xorl %edx, %edx
movq -0x48(%rsp), %rsi
movb (%rsi,%rdx), %r9b
movb %r9b, 0x1(%r10)
incq %r10
incq %rdx
cmpl %edx, %r11d
jne 0x92917
movl -0x3c(%rsp), %esi
subl %r11d, %esi
movq %r10, %rdx
subq %rcx, %rdx
movl %esi, %r9d
jmp 0x92a2d
movq %r10, %rsi
subq %rcx, %rsi
negq %rcx
addq $0x3, %rsi
xorl %edx, %edx
movl %r9d, %r11d
movb -0x2(%rsi,%rdx), %r14b
movb %r14b, 0x1(%r10,%rdx)
movb -0x1(%rsi,%rdx), %r14b
movb %r14b, 0x2(%r10,%rdx)
movb (%rsi,%rdx), %r14b
movb %r14b, 0x3(%r10,%rdx)
addl $-0x3, %r11d
addq $0x3, %rdx
cmpl $0x2, %r11d
ja 0x92951
negl %r9d
leaq (%r9,%rdx), %rsi
testl %esi, %esi
je 0x929b5
addq %rdx, %r9
addq $0x2, %r9
leaq (%r10,%rdx), %rsi
movb 0x1(%rcx,%rsi), %r11b
movb %r11b, 0x1(%r10,%rdx)
testl %r9d, %r9d
movq -0x60(%rsp), %r14
je 0x92a91
addq %rdx, %r10
incq %r10
jmp 0x92a9f
addq %rdx, %r10
movq -0x60(%rsp), %r14
jmp 0x92a9f
movq -0x20(%rsp), %rdx
subl %r14d, %edx
movl %r9d, %r11d
subl %r14d, %r11d
jbe 0x92a23
addq -0x48(%rsp), %rdx
xorl %r9d, %r9d
movb (%rdx,%r9), %r14b
movb %r14b, 0x1(%r10)
incq %r10
incq %r9
cmpl %r9d, %esi
jne 0x929da
jmp 0x92a18
movl %r11d, %edx
subl %r14d, %edx
movl %r9d, %r11d
subl %r14d, %r11d
jbe 0x92a23
addq -0x48(%rsp), %rdx
xorl %r9d, %r9d
movb (%rdx,%r9), %r14b
movb %r14b, 0x1(%r10)
incq %r10
incq %r9
cmpl %r9d, %esi
jne 0x92a05
movq %r10, %rdx
subq %rcx, %rdx
movl %r11d, %r9d
jmp 0x92a28
addq -0x50(%rsp), %rdx
movq -0x60(%rsp), %r14
xorl %ecx, %ecx
movl %r9d, %esi
cmpl $0x3, %esi
jb 0x92a5e
movb 0x1(%rdx,%rcx), %r11b
movb %r11b, 0x1(%r10,%rcx)
movb 0x2(%rdx,%rcx), %r11b
movb %r11b, 0x2(%r10,%rcx)
movb 0x3(%rdx,%rcx), %r11b
movb %r11b, 0x3(%r10,%rcx)
addl $-0x3, %esi
addq $0x3, %rcx
jmp 0x92a32
negl %r9d
leaq (%r9,%rcx), %rsi
testl %esi, %esi
je 0x92a8c
leaq (%r9,%rcx), %rsi
addq $0x2, %rsi
movb 0x1(%rdx,%rcx), %r9b
movb %r9b, 0x1(%r10,%rcx)
testl %esi, %esi
movq -0x58(%rsp), %r11
je 0x92ab6
addq %rcx, %r10
incq %r10
jmp 0x92aa4
addq %rcx, %r10
jmp 0x92a9f
movb 0x2(%rcx,%rsi), %cl
addq %rdx, %r10
addq $0x2, %r10
movb %cl, (%r10)
movq -0x58(%rsp), %r11
cmpq %r14, %rbx
jae 0x92b0b
cmpq -0x28(%rsp), %r10
jb 0x9270a
jmp 0x92b0b
movb 0x2(%rdx,%rcx), %dl
addq %rcx, %r10
addq $0x2, %r10
movb %dl, (%r10)
jmp 0x92aa4
movl %esi, %r9d
movq -0x50(%rsp), %rdx
jmp 0x92a2d
testb $0x20, %dl
jne 0x92b02
leaq 0xfcf2(%rip), %rcx      # 0xa27d1
jmp 0x92af7
leaq 0xfd05(%rip), %rcx      # 0xa27ed
movl %esi, %eax
movq %r14, %r8
movq -0x30(%rsp), %r12
movq -0x60(%rsp), %r14
movq %rcx, 0x30(%rdi)
movl $0x1d, %ecx
jmp 0x92b07
movl $0xb, %ecx
movl %ecx, (%r12)
movl %eax, %ecx
shrl $0x3, %ecx
subq %rcx, %rbx
leaq 0x1(%rbx), %rcx
movq %rcx, (%rdi)
leaq 0x1(%r10), %rcx
movq %rcx, 0x18(%rdi)
subl %ebx, %r14d
addl $0x5, %r14d
andl $0x7, %eax
movl %eax, %ecx
shll %cl, %ebp
movl %r14d, 0x8(%rdi)
movq -0x28(%rsp), %rcx
subl %r10d, %ecx
notl %ebp
andl %ebp, %r8d
addl $0x101, %ecx            # imm = 0x101
movl %ecx, 0x20(%rdi)
movq %r8, 0x48(%r12)
movl %eax, 0x50(%r12)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x60(%rsp), %r14
leaq 0xfc98(%rip), %rcx      # 0xa2803
jmp 0x92af7