// File: /workspace/github_cpp_makefile_star2_O3/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), %r8
movq (%rdi), %rbx
movl 0x8(%rdi), %eax
addl $-0x5, %eax
leaq (%rbx,%rax), %r11
decq %r11
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, -0x10(%rsp)
addl $0xfffffeff, %ecx       # imm = 0xFFFFFEFF
leaq (%rax,%rcx), %r14
decq %r14
movl 0x34(%r8), %edx
movl 0x38(%r8), %eax
movl %eax, -0x1c(%rsp)
movl 0x3c(%r8), %esi
movq 0x40(%r8), %r12
movq 0x48(%r8), %r9
movl 0x50(%r8), %eax
movb 0x70(%r8), %cl
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
shll %cl, %ebp
movb 0x74(%r8), %cl
shll %cl, %r15d
notl %ebp
notl %r15d
movq %r15, -0x8(%rsp)
movq 0x60(%r8), %r13
movq 0x68(%r8), %r15
leaq -0x1(%r12), %rcx
movq %rcx, -0x30(%rsp)
movq %rdx, -0x18(%rsp)
movq %rsi, -0x28(%rsp)
leal (%rsi,%rdx), %ecx
movl %ecx, -0x20(%rsp)
cmpl $0xe, %eax
ja 0xa10ad
movzbl 0x1(%rbx), %edx
movl %eax, %ecx
shlq %cl, %rdx
addq %r9, %rdx
movzbl 0x2(%rbx), %r9d
leal 0x8(%rax), %ecx
shlq %cl, %r9
addq $0x2, %rbx
addq %rdx, %r9
orl $0x10, %eax
movl %r9d, %esi
andl %ebp, %esi
movzbl 0x1(%r13,%rsi,4), %edx
movl %edx, %ecx
shrq %cl, %r9
movb (%r13,%rsi,4), %cl
movzwl 0x2(%r13,%rsi,4), %esi
subl %edx, %eax
testb %cl, %cl
je 0xa10f0
testb $0x10, %cl
jne 0xa10fc
testb $0x40, %cl
jne 0xa1439
movzwl %si, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
shll %cl, %esi
notl %esi
andl %r9d, %esi
addq %rdx, %rsi
jmp 0xa10b2
movb %sil, 0x1(%r10)
incq %r10
jmp 0xa141c
movq %r12, -0x48(%rsp)
movq %r14, -0x40(%rsp)
movq %r11, -0x38(%rsp)
movzbl %cl, %edx
movzwl %si, %r12d
andl $0xf, %edx
je 0xa1143
cmpl %edx, %eax
jae 0xa112d
movzbl 0x1(%rbx), %esi
movl %eax, %ecx
shlq %cl, %rsi
incq %rbx
addq %rsi, %r9
addl $0x8, %eax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ecx
shll %cl, %esi
notl %esi
andl %r9d, %esi
addl %esi, %r12d
shrq %cl, %r9
subl %edx, %eax
cmpl $0xe, %eax
ja 0xa1169
movzbl 0x1(%rbx), %edx
movl %eax, %ecx
shlq %cl, %rdx
addq %r9, %rdx
movzbl 0x2(%rbx), %r9d
leal 0x8(%rax), %ecx
shlq %cl, %r9
addq $0x2, %rbx
addq %rdx, %r9
orl $0x10, %eax
movl %r9d, %esi
andl -0x8(%rsp), %esi
movzbl (%r15,%rsi,4), %edx
movzbl 0x1(%r15,%rsi,4), %ecx
movzwl 0x2(%r15,%rsi,4), %r11d
shrq %cl, %r9
subl %ecx, %eax
movq %r9, %r14
movl %eax, %esi
testb $0x10, %dl
jne 0xa11c9
testb $0x40, %dl
jne 0xa144c
movzwl %r11w, %eax
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl %edx, %ecx
shll %cl, %r9d
notl %r9d
andl %r14d, %r9d
addq %rax, %r9
movzbl 0x1(%r15,%r9,4), %ecx
shrq %cl, %r14
movzbl (%r15,%r9,4), %edx
movzwl 0x2(%r15,%r9,4), %r11d
subl %ecx, %esi
jmp 0xa118b
andl $0xf, %edx
cmpl %edx, %esi
jae 0xa11fc
movzbl 0x1(%rbx), %r9d
movl %esi, %ecx
shlq %cl, %r9
addq %r14, %r9
leal 0x8(%rsi), %eax
cmpl %edx, %eax
jae 0xa1203
movzbl 0x2(%rbx), %r14d
movl %eax, %ecx
shlq %cl, %r14
addq $0x2, %rbx
addq %r14, %r9
addl $0x10, %esi
movl %esi, %eax
jmp 0xa1206
movl %esi, %eax
movq %r14, %r9
jmp 0xa1206
incq %rbx
movq -0x28(%rsp), %r14
movzwl %r11w, %r11d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %ecx
shll %cl, %esi
notl %esi
andl %r9d, %esi
addl %r11d, %esi
shrq %cl, %r9
subl %edx, %eax
movl %r10d, %ecx
subl -0x10(%rsp), %ecx
movl %esi, %r11d
subl %ecx, %r11d
jbe 0xa12c4
cmpl -0x1c(%rsp), %r11d
jbe 0xa124d
cmpl $0x0, 0x1be0(%r8)
jne 0xa14c2
testq %r14, %r14
je 0xa1340
cmpl %r14d, %r11d
jbe 0xa1370
movl -0x20(%rsp), %ecx
subl %r11d, %ecx
subl %r14d, %r11d
movl %r12d, %edx
subl %r11d, %edx
jbe 0xa13a9
movl %r11d, %r11d
addq -0x48(%rsp), %rcx
xorl %r14d, %r14d
movb (%rcx,%r14), %r12b
movb %r12b, 0x1(%r10,%r14)
incq %r14
cmpl %r14d, %r11d
jne 0xa1280
addq %r14, %r10
movq -0x28(%rsp), %r14
cmpl %r14d, %edx
jbe 0xa142c
xorl %ecx, %ecx
movq -0x48(%rsp), %r12
movb (%r12,%rcx), %r11b
movb %r11b, 0x1(%r10)
incq %r10
incq %rcx
cmpl %ecx, %r14d
jne 0xa12a9
subl %r14d, %edx
jmp 0xa139c
movl %esi, %ecx
movq %r10, %rsi
subq %rcx, %rsi
negq %rcx
addq $0x3, %rsi
xorl %edx, %edx
movl %r12d, %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 0xa12d8
negl %r12d
leaq (%r12,%rdx), %rsi
testl %esi, %esi
je 0xa1338
leaq (%r12,%rdx), %r11
addq $0x2, %r11
leaq (%r10,%rdx), %rsi
movb 0x1(%rcx,%rsi), %r14b
movb %r14b, 0x1(%r10,%rdx)
testl %r11d, %r11d
je 0xa13ff
addq %rdx, %r10
incq %r10
jmp 0xa140d
addq %rdx, %r10
jmp 0xa140d
movq -0x18(%rsp), %rcx
subl %r11d, %ecx
movl %r12d, %edx
subl %r11d, %edx
jbe 0xa13a9
movl %r11d, %r11d
addq -0x48(%rsp), %rcx
xorl %r14d, %r14d
movb (%rcx,%r14), %r12b
movb %r12b, 0x1(%r10)
incq %r10
incq %r14
cmpl %r14d, %r11d
jne 0xa135b
jmp 0xa139c
movl %r14d, %ecx
subl %r11d, %ecx
movl %r12d, %edx
subl %r11d, %edx
jbe 0xa13a9
movl %r11d, %r11d
addq -0x48(%rsp), %rcx
xorl %r14d, %r14d
movb (%rcx,%r14), %r12b
movb %r12b, 0x1(%r10)
incq %r10
incq %r14
cmpl %r14d, %r11d
jne 0xa1389
movl %esi, %esi
movq %r10, %rcx
subq %rsi, %rcx
movl %edx, %r12d
jmp 0xa13ae
addq -0x30(%rsp), %rcx
cmpl $0x3, %r12d
jb 0xa13db
movb 0x1(%rcx), %dl
movb %dl, 0x1(%r10)
movb 0x2(%rcx), %dl
movb %dl, 0x2(%r10)
movb 0x3(%rcx), %dl
addq $0x3, %rcx
movb %dl, 0x3(%r10)
addq $0x3, %r10
addl $-0x3, %r12d
cmpl $0x2, %r12d
ja 0xa13b4
testl %r12d, %r12d
je 0xa140d
movb 0x1(%rcx), %dl
movb %dl, 0x1(%r10)
cmpl $0x2, %r12d
jne 0xa13fa
movb 0x2(%rcx), %cl
movb %cl, 0x2(%r10)
addq $0x2, %r10
jmp 0xa140d
incq %r10
jmp 0xa140d
movb 0x2(%rcx,%rsi), %cl
addq %rdx, %r10
addq $0x2, %r10
movb %cl, (%r10)
movq -0x38(%rsp), %r11
movq -0x40(%rsp), %r14
movq -0x48(%rsp), %r12
cmpq %r11, %rbx
jae 0xa146e
cmpq %r14, %r10
jb 0xa1087
jmp 0xa146e
movl %edx, %r12d
movq -0x30(%rsp), %rcx
jmp 0xa13ae
movl $0xb, %edx
testb $0x20, %cl
jne 0xa146b
leaq 0x106a7(%rip), %rcx     # 0xb1af1
jmp 0xa1462
movl %esi, %eax
movq %r14, %r9
movq -0x38(%rsp), %r11
movq -0x40(%rsp), %r14
leaq 0x106ab(%rip), %rcx     # 0xb1b0d
movq %rcx, 0x30(%rdi)
movl $0x1d, %edx
movl %edx, (%r8)
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, %r11d
addl $0x5, %r11d
andl $0x7, %eax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %eax, %ecx
shll %cl, %edx
movl %r11d, 0x8(%rdi)
subl %r10d, %r14d
notl %edx
andl %edx, %r9d
addl $0x101, %r14d           # imm = 0x101
movl %r14d, 0x20(%rdi)
movq %r9, 0x48(%r8)
movl %eax, 0x50(%r8)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1065a(%rip), %rcx     # 0xb1b23
movq -0x38(%rsp), %r11
movq -0x40(%rsp), %r14
jmp 0xa1462