// File: /workspace/github_c_makefile_star2_O0/Cyan4973[P]FiniteStateEntropy/programs/zlibh.c
// Function: ZLIBH_inflate
int ZLIBH_inflate(unsigned char* dest, const unsigned char* compressed)
{
    const unsigned char *next = (const unsigned char*)compressed;   /* next input */
    unsigned char *put  = (unsigned char*)dest;         /* next output */
    unsigned hold;              /* bit buffer */
    unsigned bits;              /* bits in bit buffer */
    unsigned copy;              /* number of stored or match bytes to copy */
    code here;                  /* current decoding table entry */
    unsigned len;               /* length to copy for repeats, bits to drop */
    int ret;                    /* return code */
    struct inflate_state state;
    static const unsigned short order[19] = /* permutation of code lengths */
    {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
    code const *lcode;
    unsigned lmask;             /* mask for first level of length codes */
    unsigned codebits;          /* code bits, operation, was op */

    state.mode = TYPEDO;      /* skip check */

    /* Clear the input bit accumulator */
    hold = 0;
    bits = 0;
    for (;;)
        switch (state.mode) {
        case TYPEDO:
            NEEDBITS(1);
            switch (BITS(1)) {
            case 0:                             /* dynamic block */
                state.mode = TABLE;
                break;

            case 1:                             /* fixed block */
                fixedtables(&state);
                state.mode = LEN;             /* decode codes */
                break;
            }
            DROPBITS(1);
            break;

        case TABLE:
            NEEDBITS(4);
            state.nlen = 257;
            state.ndist = 0;
            state.ncode = BITS(4) + 4;
            DROPBITS(4);

            state.have = 0;

            while (state.have < state.ncode) {
                NEEDBITS(3);
                state.lens[order[state.have++]] = (unsigned short)BITS(3);
                DROPBITS(3);
            }
            while (state.have < 19)
                state.lens[order[state.have++]] = 0;
            state.next = state.codes;
            state.lencode = (const code *)(state.next);
            state.lenbits = 7;
            ret = inflate_table(CODES, state.lens, 19, &(state.next),
                &(state.lenbits), state.work);
            if (ret) {
                state.mode = BAD;
                break;
            }
            state.have = 0;

            while (state.have < state.nlen) {
                for (;;) {
                    here = state.lencode[BITS(state.lenbits)];
                    if ((unsigned)(here.bits) <= bits) break;
                    PULLBYTE();
                }
                if (here.val < 16) {
                    DROPBITS(here.bits);
                    state.lens[state.have++] = here.val;
                }
                else {
                    if (here.val == 16) {
                        NEEDBITS(here.bits + 2);
                        DROPBITS(here.bits);
                        if (state.have == 0) {
                            state.mode = BAD;
                            break;
                        }
                        len = state.lens[state.have - 1];
                        copy = 3 + BITS(2);
                        DROPBITS(2);
                    }
                    else if (here.val == 17) {
                        NEEDBITS(here.bits + 3);
                        DROPBITS(here.bits);
                        len = 0;
                        copy = 3 + BITS(3);
                        DROPBITS(3);
                    }
                    else {
                        NEEDBITS(here.bits + 7);
                        DROPBITS(here.bits);
                        len = 0;
                        copy = 11 + BITS(7);
                        DROPBITS(7);
                    }
                    if (state.have + copy > state.nlen) {
                        state.mode = BAD;
                        break;
                    }
                    while (copy--)
                        state.lens[state.have++] = (unsigned short)len;
                }
            }

            /* handle error breaks in while */
            if (state.mode == BAD) break;

            /* check for end-of-block code (better have one) */
            if (state.lens[256] == 0) {
                state.mode = BAD;
                break;
            }

            /* build code tables -- note: do not change the lenbits or distbits
            values here (9 and 6) without reading the comments in inftrees.h
            concerning the ENOUGH constants, which depend on those values */
            state.next = state.codes;
            state.lencode = (const code *)(state.next);
            state.lenbits = 9;
            ret = inflate_table(LENS, state.lens, state.nlen, &(state.next),
                &(state.lenbits), state.work);
            if (ret) {
                state.mode = BAD;
                break;
            }
            state.mode = LEN;
            /* fallthrough */

        case LEN:
            lcode = state.lencode;
            lmask = (1U << state.lenbits) - 1;
            do {
                if (bits < 15) {
                    hold += (unsigned long)(*next++) << bits;
                    bits += 8;
                    hold += (unsigned long)(*next++) << bits;
                    bits += 8;
                }
                here = lcode[hold & lmask];
dolen:
                codebits = (unsigned)(here.bits);
                hold >>= codebits;
                bits -= codebits;
                codebits = (unsigned)(here.op);
                if (codebits == 0) {                          /* literal */
                    *put++ = (unsigned char)(here.val);
                }
                else if ((codebits & 64) == 0) {              /* 2nd level length code */
                    here = lcode[here.val + (hold & ((1U << codebits) - 1))];
                    goto dolen;
                }
                else if (codebits & 32) {                     /* end-of-block */
                    //len = bits >> 3;                        /* restitute unused bytes */
                    //next -= len;
                    break;
                }
            } while (1);
            state.mode = DONE;

        case DONE:
            goto inf_leave;
        case BAD:
            return 0;
    }
inf_leave:
    //return (int)(next-compressed);   // compressed size
    return (int)(put-dest);          // original size
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c50, %rsp           # imm = 0x1C50
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x1c28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x1c28(%rbp), %eax
movq %rax, -0x1c40(%rbp)
subq $0x4, %rax
ja 0xdd2b
movq -0x1c40(%rbp), %rax
leaq 0x18960(%rip), %rcx     # 0x25ef0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0xd59b
jmp 0xd59d
cmpl $0x1, -0x30(%rbp)
jae 0xd5d4
jmp 0xd5a5
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0xd59d
jmp 0xd5d6
movl -0x2c(%rbp), %eax
andl $0x1, %eax
movl %eax, -0x1c44(%rbp)
je 0xd5f3
jmp 0xd5e6
movl -0x1c44(%rbp), %eax
subl $0x1, %eax
je 0xd5ff
jmp 0xd615
movl $0x1, -0x1c28(%rbp)
jmp 0xd615
leaq -0x1c28(%rbp), %rdi
callq 0xdd50
movl $0x2, -0x1c28(%rbp)
jmp 0xd617
movl -0x2c(%rbp), %eax
shrl %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xdd2b
jmp 0xd62f
jmp 0xd631
cmpl $0x4, -0x30(%rbp)
jae 0xd668
jmp 0xd639
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0xd631
jmp 0xd66a
movl $0x101, -0x1bb4(%rbp)   # imm = 0x101
movl $0x0, -0x1bb0(%rbp)
movl -0x2c(%rbp), %eax
andl $0xf, %eax
addl $0x4, %eax
movl %eax, -0x1bb8(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x4, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x1bac(%rbp)
movl -0x1bac(%rbp), %eax
cmpl -0x1bb8(%rbp), %eax
jae 0xd740
jmp 0xd6bd
jmp 0xd6bf
cmpl $0x3, -0x30(%rbp)
jae 0xd6f6
jmp 0xd6c7
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0xd6bf
jmp 0xd6f8
movl -0x2c(%rbp), %eax
andl $0x7, %eax
movw %ax, %cx
movl -0x1bac(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1bac(%rbp)
movl %eax, %eax
movl %eax, %edx
leaq 0x18d93(%rip), %rax     # 0x264b0
movzwl (%rax,%rdx,2), %eax
movw %cx, -0x1ba0(%rbp,%rax,2)
movl -0x2c(%rbp), %eax
shrl $0x3, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x30(%rbp)
jmp 0xd6a9
jmp 0xd742
cmpl $0x13, -0x1bac(%rbp)
jae 0xd777
movl -0x1bac(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1bac(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x18d49(%rip), %rax     # 0x264b0
movzwl (%rax,%rcx,2), %eax
movw $0x0, -0x1ba0(%rbp,%rax,2)
jmp 0xd742
leaq -0x1c28(%rbp), %rax
addq $0x548, %rax            # imm = 0x548
movq %rax, -0x1ba8(%rbp)
movq -0x1ba8(%rbp), %rax
movq %rax, -0x1bd0(%rbp)
movl $0x7, -0x1bc0(%rbp)
leaq -0x1c28(%rbp), %rsi
addq $0x88, %rsi
leaq -0x1c28(%rbp), %rcx
addq $0x80, %rcx
leaq -0x1c28(%rbp), %r8
addq $0x68, %r8
leaq -0x1c28(%rbp), %r9
addq $0x308, %r9             # imm = 0x308
xorl %edi, %edi
movl $0x13, %edx
callq 0xcec0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0xd7fc
movl $0x4, -0x1c28(%rbp)
jmp 0xdd2b
movl $0x0, -0x1bac(%rbp)
movl -0x1bac(%rbp), %eax
cmpl -0x1bb4(%rbp), %eax
jae 0xdb01
jmp 0xd81a
movq -0x1bd0(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, -0x1c48(%rbp)
movl -0x1bc0(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl -0x1c48(%rbp), %ecx
subl $0x1, %edx
andl %edx, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movzbl -0x37(%rbp), %eax
cmpl -0x30(%rbp), %eax
ja 0xd855
jmp 0xd886
jmp 0xd857
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0xd81a
movzwl -0x36(%rbp), %eax
cmpl $0x10, %eax
jge 0xd8cd
jmp 0xd891
movzbl -0x37(%rbp), %ecx
movl -0x2c(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x2c(%rbp)
movzbl -0x37(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movw -0x36(%rbp), %cx
movl -0x1bac(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1bac(%rbp)
movl %eax, %eax
movw %cx, -0x1ba0(%rbp,%rax,2)
jmp 0xdafc
movzwl -0x36(%rbp), %eax
cmpl $0x10, %eax
jne 0xd98a
jmp 0xd8dc
jmp 0xd8de
movl -0x30(%rbp), %eax
movzbl -0x37(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jae 0xd91d
jmp 0xd8ee
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0xd8de
jmp 0xd91f
jmp 0xd921
movzbl -0x37(%rbp), %ecx
movl -0x2c(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x2c(%rbp)
movzbl -0x37(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x1bac(%rbp)
jne 0xd951
movl $0x4, -0x1c28(%rbp)
jmp 0xdb01
movl -0x1bac(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movzwl -0x1ba0(%rbp,%rax,2), %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
andl $0x3, %eax
addl $0x3, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x2, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x30(%rbp)
jmp 0xdaa8
movzwl -0x36(%rbp), %eax
cmpl $0x11, %eax
jne 0xda20
jmp 0xd999
jmp 0xd99b
movl -0x30(%rbp), %eax
movzbl -0x37(%rbp), %ecx
addl $0x3, %ecx
cmpl %ecx, %eax
jae 0xd9da
jmp 0xd9ab
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0xd99b
jmp 0xd9dc
jmp 0xd9de
movzbl -0x37(%rbp), %ecx
movl -0x2c(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x2c(%rbp)
movzbl -0x37(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
andl $0x7, %eax
addl $0x3, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x3, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x30(%rbp)
jmp 0xdaa6
jmp 0xda22
jmp 0xda24
movl -0x30(%rbp), %eax
movzbl -0x37(%rbp), %ecx
addl $0x7, %ecx
cmpl %ecx, %eax
jae 0xda63
jmp 0xda34
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
jmp 0xda24
jmp 0xda65
jmp 0xda67
movzbl -0x37(%rbp), %ecx
movl -0x2c(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x2c(%rbp)
movzbl -0x37(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
andl $0x7f, %eax
addl $0xb, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x7, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
subl $0x7, %eax
movl %eax, -0x30(%rbp)
jmp 0xdaa6
jmp 0xdaa8
movl -0x1bac(%rbp), %eax
addl -0x34(%rbp), %eax
cmpl -0x1bb4(%rbp), %eax
jbe 0xdac5
movl $0x4, -0x1c28(%rbp)
jmp 0xdb01
jmp 0xdac7
movl -0x34(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x34(%rbp)
cmpl $0x0, %eax
je 0xdafa
movl -0x3c(%rbp), %eax
movw %ax, %cx
movl -0x1bac(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1bac(%rbp)
movl %eax, %eax
movw %cx, -0x1ba0(%rbp,%rax,2)
jmp 0xdac7
jmp 0xdafc
jmp 0xd806
cmpl $0x4, -0x1c28(%rbp)
jne 0xdb0f
jmp 0xdd2b
movzwl -0x19a0(%rbp), %eax
cmpl $0x0, %eax
jne 0xdb2a
movl $0x4, -0x1c28(%rbp)
jmp 0xdd2b
leaq -0x1c28(%rbp), %rax
addq $0x548, %rax            # imm = 0x548
movq %rax, -0x1ba8(%rbp)
movq -0x1ba8(%rbp), %rax
movq %rax, -0x1bd0(%rbp)
movl $0x9, -0x1bc0(%rbp)
leaq -0x1c28(%rbp), %rsi
addq $0x88, %rsi
movl -0x1bb4(%rbp), %edx
leaq -0x1c28(%rbp), %rcx
addq $0x80, %rcx
leaq -0x1c28(%rbp), %r8
addq $0x68, %r8
leaq -0x1c28(%rbp), %r9
addq $0x308, %r9             # imm = 0x308
movl $0x1, %edi
callq 0xcec0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0xdbb3
movl $0x4, -0x1c28(%rbp)
jmp 0xdd2b
movl $0x2, -0x1c28(%rbp)
movq -0x1bd0(%rbp), %rax
movq %rax, -0x1c30(%rbp)
movl -0x1bc0(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
subl $0x1, %eax
movl %eax, -0x1c34(%rbp)
cmpl $0xf, -0x30(%rbp)
jae 0xdc41
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl -0x30(%rbp), %ecx
shlq %cl, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x30(%rbp)
movq -0x1c30(%rbp), %rax
movl -0x2c(%rbp), %ecx
andl -0x1c34(%rbp), %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movzbl -0x37(%rbp), %eax
movl %eax, -0x1c38(%rbp)
movl -0x1c38(%rbp), %ecx
movl -0x2c(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x2c(%rbp)
movl -0x1c38(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movzbl -0x38(%rbp), %eax
movl %eax, -0x1c38(%rbp)
cmpl $0x0, -0x1c38(%rbp)
jne 0xdcab
movw -0x36(%rbp), %ax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0xdd08
movl -0x1c38(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0xdcf4
movq -0x1c30(%rbp), %rax
movzwl -0x36(%rbp), %ecx
movl %ecx, -0x1c4c(%rbp)
movl -0x2c(%rbp), %edx
movl -0x1c38(%rbp), %ecx
movl $0x1, %esi
shll %cl, %esi
movl -0x1c4c(%rbp), %ecx
subl $0x1, %esi
andl %esi, %edx
addl %edx, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
jmp 0xdc59
movl -0x1c38(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0xdd04
jmp 0xdd16
jmp 0xdd06
jmp 0xdd08
jmp 0xdd0a
movb $0x1, %al
testb $0x1, %al
jne 0xdbe1
jmp 0xdd16
movl $0x3, -0x1c28(%rbp)
jmp 0xdd30
movl $0x0, -0x4(%rbp)
jmp 0xdd3e
jmp 0xd56b
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1c50, %rsp           # imm = 0x1C50
popq %rbp
retq
nopw (%rax,%rax)