static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,

                      GetByteContext *gb, int nbits,

                      int rlc, int no, uint16_t *out)

{

    uint64_t c        = 0;

    uint16_t *outb    = out;

    uint16_t *oe      = out + no;

    const uint8_t *ie = gb->buffer + (nbits + 7) / 8; // input byte size

    uint8_t cs, s;

    int i, lc = 0;



    while (gb->buffer < ie) {

        get_char(c, lc, gb);



        while (lc >= HUF_DECBITS) {

            const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK];



            if (pl.len) {

                lc -= pl.len;

                get_code(pl.lit, rlc, c, lc, gb, out, oe);

            } else {

                int j;



                if (!pl.p)

                    return AVERROR_INVALIDDATA;



                for (j = 0; j < pl.lit; j++) {

                    int l = hcode[pl.p[j]] & 63;



                    while (lc < l && bytestream2_get_bytes_left(gb) > 0)

                        get_char(c, lc, gb);



                    if (lc >= l) {

                        if ((hcode[pl.p[j]] >> 6) ==

                            ((c >> (lc - l)) & ((1LL << l) - 1))) {

                            lc -= l;

                            get_code(pl.p[j], rlc, c, lc, gb, out, oe);

                            break;

                        }

                    }

                }



                if (j == pl.lit)

                    return AVERROR_INVALIDDATA;

            }

        }

    }



    i   = (8 - nbits) & 7;

    c >>= i;

    lc -= i;



    while (lc > 0) {

        const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK];



        if (pl.len) {

            lc -= pl.len;

            get_code(pl.lit, rlc, c, lc, gb, out, oe);

        } else {

            return AVERROR_INVALIDDATA;

        }

    }



    if (out - outb != no)

        return AVERROR_INVALIDDATA;

    return 0;

}

static int huf_decode(const uint64_t *hcode, const HufDec *hdecod,

                      GetByteContext *gb, int nbits,

                      int rlc, int no, uint16_t *out)

{

    uint64_t c        = 0;

    uint16_t *outb    = out;

    uint16_t *oe      = out + no;

    const uint8_t *ie = gb->buffer + (nbits + 7) / 8; 

    uint8_t cs, s;

    int i, lc = 0;



    while (gb->buffer < ie) {

        get_char(c, lc, gb);



        while (lc >= HUF_DECBITS) {

            const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK];



            if (pl.len) {

                lc -= pl.len;

                get_code(pl.lit, rlc, c, lc, gb, out, oe);

            } else {

                int j;



                if (!pl.p)

                    return AVERROR_INVALIDDATA;



                for (j = 0; j < pl.lit; j++) {

                    int l = hcode[pl.p[j]] & 63;



                    while (lc < l && bytestream2_get_bytes_left(gb) > 0)

                        get_char(c, lc, gb);



                    if (lc >= l) {

                        if ((hcode[pl.p[j]] >> 6) ==

                            ((c >> (lc - l)) & ((1LL << l) - 1))) {

                            lc -= l;

                            get_code(pl.p[j], rlc, c, lc, gb, out, oe);

                            break;

                        }

                    }

                }



                if (j == pl.lit)

                    return AVERROR_INVALIDDATA;

            }

        }

    }



    i   = (8 - nbits) & 7;

    c >>= i;

    lc -= i;



    while (lc > 0) {

        const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK];



        if (pl.len) {

            lc -= pl.len;

            get_code(pl.lit, rlc, c, lc, gb, out, oe);

        } else {

            return AVERROR_INVALIDDATA;

        }

    }



    if (out - outb != no)

        return AVERROR_INVALIDDATA;

    return 0;

}

                get_code(pl.lit, rlc, c, lc, gb, out, oe);                             get_code(pl.p[j], rlc, c, lc, gb, out, oe);             get_code(pl.lit, rlc, c, lc, gb, out, oe);
static int FUNC_0(const uint64_t *VAR_0, const HufDec *VAR_1,

                      GetByteContext *VAR_2, int VAR_3,

                      int VAR_4, int VAR_5, uint16_t *VAR_6)

{

    uint64_t c        = 0;

    uint16_t *outb    = VAR_6;

    uint16_t *oe      = VAR_6 + VAR_5;

    const uint8_t *VAR_7 = VAR_2->buffer + (VAR_3 + 7) / 8; 

    uint8_t cs, s;

    int VAR_8, VAR_9 = 0;



    while (VAR_2->buffer < VAR_7) {

        get_char(c, VAR_9, VAR_2);



        while (VAR_9 >= HUF_DECBITS) {

            const HufDec VAR_12 = VAR_1[(c >> (VAR_9 - HUF_DECBITS)) & HUF_DECMASK];



            if (VAR_12.len) {

                VAR_9 -= VAR_12.len;

                get_code(VAR_12.lit, VAR_4, c, VAR_9, VAR_2, VAR_6, oe);

            } else {

                int VAR_11;



                if (!VAR_12.p)

                    return AVERROR_INVALIDDATA;



                for (VAR_11 = 0; VAR_11 < VAR_12.lit; VAR_11++) {

                    int l = VAR_0[VAR_12.p[VAR_11]] & 63;



                    while (VAR_9 < l && bytestream2_get_bytes_left(VAR_2) > 0)

                        get_char(c, VAR_9, VAR_2);



                    if (VAR_9 >= l) {

                        if ((VAR_0[VAR_12.p[VAR_11]] >> 6) ==

                            ((c >> (VAR_9 - l)) & ((1LL << l) - 1))) {

                            VAR_9 -= l;

                            get_code(VAR_12.p[VAR_11], VAR_4, c, VAR_9, VAR_2, VAR_6, oe);

                            break;

                        }

                    }

                }



                if (VAR_11 == VAR_12.lit)

                    return AVERROR_INVALIDDATA;

            }

        }

    }



    VAR_8   = (8 - VAR_3) & 7;

    c >>= VAR_8;

    VAR_9 -= VAR_8;



    while (VAR_9 > 0) {

        const HufDec VAR_12 = VAR_1[(c << (HUF_DECBITS - VAR_9)) & HUF_DECMASK];



        if (VAR_12.len) {

            VAR_9 -= VAR_12.len;

            get_code(VAR_12.lit, VAR_4, c, VAR_9, VAR_2, VAR_6, oe);

        } else {

            return AVERROR_INVALIDDATA;

        }

    }



    if (VAR_6 - outb != VAR_5)

        return AVERROR_INVALIDDATA;

    return 0;

}

static int FUNC_0(const uint64_t *VAR_0, const HufDec *VAR_1,
GetByteContext *VAR_2, int VAR_3,
int VAR_4, int VAR_5, uint16_t *VAR_6)
{ uint64_t c        = 0; uint16_t *outb    = VAR_6; uint16_t *oe      = VAR_6 + VAR_5; const uint8_t *VAR_7 = VAR_2->buffer + (VAR_3 + 7) / 8; uint8_t cs, s; int VAR_8, VAR_9 = 0; while (VAR_2->buffer < VAR_7) { get_char(c, VAR_9, VAR_2); while (VAR_9 >= HUF_DECBITS) { const HufDec VAR_12 = VAR_1[(c >> (VAR_9 - HUF_DECBITS)) & HUF_DECMASK]; if (VAR_12.len) { VAR_9 -= VAR_12.len; get_code(VAR_12.lit, VAR_4, c, VAR_9, VAR_2, VAR_6, oe); } else { int VAR_11; if (!VAR_12.p)
return AVERROR_INVALIDDATA; for (VAR_11 = 0; VAR_11 < VAR_12.lit; VAR_11++) { int l = VAR_0[VAR_12.p[VAR_11]] & 63; while (VAR_9 < l && bytestream2_get_bytes_left(VAR_2) > 0)
get_char(c, VAR_9, VAR_2); if (VAR_9 >= l) { if ((VAR_0[VAR_12.p[VAR_11]] >> 6) ==
((c >> (VAR_9 - l)) & ((1LL << l) - 1))) { VAR_9 -= l; get_code(VAR_12.p[VAR_11], VAR_4, c, VAR_9, VAR_2, VAR_6, oe); break; } } } if (VAR_11 == VAR_12.lit)
return AVERROR_INVALIDDATA; } } } VAR_8   = (8 - VAR_3) & 7; c >>= VAR_8; VAR_9 -= VAR_8; while (VAR_9 > 0) { const HufDec VAR_12 = VAR_1[(c << (HUF_DECBITS - VAR_9)) & HUF_DECMASK]; if (VAR_12.len) { VAR_9 -= VAR_12.len; get_code(VAR_12.lit, VAR_4, c, VAR_9, VAR_2, VAR_6, oe); } else { return AVERROR_INVALIDDATA; } } if (VAR_6 - outb != VAR_5)
return AVERROR_INVALIDDATA; return 0; }