static inline int ape_decode_value(APEContext *ctx, APERice *rice)

{

    int x, overflow;



    if (ctx->fileversion < 3990) {

        int tmpk;



        overflow = range_get_symbol(ctx, counts_3970, counts_diff_3970);



        if (overflow == (MODEL_ELEMENTS - 1)) {

            tmpk = range_decode_bits(ctx, 5);

            overflow = 0;

        } else

            tmpk = (rice->k < 1) ? 0 : rice->k - 1;



        if (tmpk <= 16)

            x = range_decode_bits(ctx, tmpk);

        else {

            x = range_decode_bits(ctx, 16);

            x |= (range_decode_bits(ctx, tmpk - 16) << 16);

        }

        x += overflow << tmpk;

    } else {

        int base, pivot;



        pivot = rice->ksum >> 5;

        if (pivot == 0)

            pivot = 1;



        overflow = range_get_symbol(ctx, counts_3980, counts_diff_3980);



        if (overflow == (MODEL_ELEMENTS - 1)) {

            overflow  = range_decode_bits(ctx, 16) << 16;

            overflow |= range_decode_bits(ctx, 16);

        }



        if (pivot < 0x10000) {

            base = range_decode_culfreq(ctx, pivot);

            range_decode_update(ctx, 1, base);

        } else {

            int base_hi = pivot, base_lo;

            int bbits = 0;



            while (base_hi & ~0xFFFF) {

                base_hi >>= 1;

                bbits++;

            }

            base_hi = range_decode_culfreq(ctx, base_hi + 1);

            range_decode_update(ctx, 1, base_hi);

            base_lo = range_decode_culfreq(ctx, 1 << bbits);

            range_decode_update(ctx, 1, base_lo);



            base = (base_hi << bbits) + base_lo;

        }



        x = base + overflow * pivot;

    }



    update_rice(rice, x);



    /* Convert to signed */

    if (x & 1)

        return (x >> 1) + 1;

    else

        return -(x >> 1);

}

static inline int ape_decode_value(APEContext *ctx, APERice *rice)

{

    int x, overflow;



    if (ctx->fileversion < 3990) {

        int tmpk;



        overflow = range_get_symbol(ctx, counts_3970, counts_diff_3970);



        if (overflow == (MODEL_ELEMENTS - 1)) {

            tmpk = range_decode_bits(ctx, 5);

            overflow = 0;

        } else

            tmpk = (rice->k < 1) ? 0 : rice->k - 1;



        if (tmpk <= 16)

            x = range_decode_bits(ctx, tmpk);

        else {

            x = range_decode_bits(ctx, 16);

            x |= (range_decode_bits(ctx, tmpk - 16) << 16);

        }

        x += overflow << tmpk;

    } else {

        int base, pivot;



        pivot = rice->ksum >> 5;

        if (pivot == 0)

            pivot = 1;



        overflow = range_get_symbol(ctx, counts_3980, counts_diff_3980);



        if (overflow == (MODEL_ELEMENTS - 1)) {

            overflow  = range_decode_bits(ctx, 16) << 16;

            overflow |= range_decode_bits(ctx, 16);

        }



        if (pivot < 0x10000) {

            base = range_decode_culfreq(ctx, pivot);

            range_decode_update(ctx, 1, base);

        } else {

            int base_hi = pivot, base_lo;

            int bbits = 0;



            while (base_hi & ~0xFFFF) {

                base_hi >>= 1;

                bbits++;

            }

            base_hi = range_decode_culfreq(ctx, base_hi + 1);

            range_decode_update(ctx, 1, base_hi);

            base_lo = range_decode_culfreq(ctx, 1 << bbits);

            range_decode_update(ctx, 1, base_lo);



            base = (base_hi << bbits) + base_lo;

        }



        x = base + overflow * pivot;

    }



    update_rice(rice, x);



    

    if (x & 1)

        return (x >> 1) + 1;

    else

        return -(x >> 1);

}

static inline int FUNC_0(APEContext *VAR_0, APERice *VAR_1)

{

    int VAR_2, VAR_3;



    if (VAR_0->fileversion < 3990) {

        int VAR_4;



        VAR_3 = range_get_symbol(VAR_0, counts_3970, counts_diff_3970);



        if (VAR_3 == (MODEL_ELEMENTS - 1)) {

            VAR_4 = range_decode_bits(VAR_0, 5);

            VAR_3 = 0;

        } else

            VAR_4 = (VAR_1->k < 1) ? 0 : VAR_1->k - 1;



        if (VAR_4 <= 16)

            VAR_2 = range_decode_bits(VAR_0, VAR_4);

        else {

            VAR_2 = range_decode_bits(VAR_0, 16);

            VAR_2 |= (range_decode_bits(VAR_0, VAR_4 - 16) << 16);

        }

        VAR_2 += VAR_3 << VAR_4;

    } else {

        int VAR_5, VAR_6;



        VAR_6 = VAR_1->ksum >> 5;

        if (VAR_6 == 0)

            VAR_6 = 1;



        VAR_3 = range_get_symbol(VAR_0, counts_3980, counts_diff_3980);



        if (VAR_3 == (MODEL_ELEMENTS - 1)) {

            VAR_3  = range_decode_bits(VAR_0, 16) << 16;

            VAR_3 |= range_decode_bits(VAR_0, 16);

        }



        if (VAR_6 < 0x10000) {

            VAR_5 = range_decode_culfreq(VAR_0, VAR_6);

            range_decode_update(VAR_0, 1, VAR_5);

        } else {

            int VAR_7 = VAR_6, VAR_8;

            int VAR_9 = 0;



            while (VAR_7 & ~0xFFFF) {

                VAR_7 >>= 1;

                VAR_9++;

            }

            VAR_7 = range_decode_culfreq(VAR_0, VAR_7 + 1);

            range_decode_update(VAR_0, 1, VAR_7);

            VAR_8 = range_decode_culfreq(VAR_0, 1 << VAR_9);

            range_decode_update(VAR_0, 1, VAR_8);



            VAR_5 = (VAR_7 << VAR_9) + VAR_8;

        }



        VAR_2 = VAR_5 + VAR_3 * VAR_6;

    }



    update_rice(VAR_1, VAR_2);



    

    if (VAR_2 & 1)

        return (VAR_2 >> 1) + 1;

    else

        return -(VAR_2 >> 1);

}

static inline int FUNC_0(APEContext *VAR_0, APERice *VAR_1)
{ int VAR_2, VAR_3; if (VAR_0->fileversion < 3990) { int VAR_4; VAR_3 = range_get_symbol(VAR_0, counts_3970, counts_diff_3970); if (VAR_3 == (MODEL_ELEMENTS - 1)) { VAR_4 = range_decode_bits(VAR_0, 5); VAR_3 = 0; } else VAR_4 = (VAR_1->k < 1) ? 0 : VAR_1->k - 1; if (VAR_4 <= 16)
VAR_2 = range_decode_bits(VAR_0, VAR_4); else { VAR_2 = range_decode_bits(VAR_0, 16); VAR_2 |= (range_decode_bits(VAR_0, VAR_4 - 16) << 16); } VAR_2 += VAR_3 << VAR_4; } else { int VAR_5, VAR_6; VAR_6 = VAR_1->ksum >> 5; if (VAR_6 == 0)
VAR_6 = 1; VAR_3 = range_get_symbol(VAR_0, counts_3980, counts_diff_3980); if (VAR_3 == (MODEL_ELEMENTS - 1)) { VAR_3  = range_decode_bits(VAR_0, 16) << 16; VAR_3 |= range_decode_bits(VAR_0, 16); } if (VAR_6 < 0x10000) { VAR_5 = range_decode_culfreq(VAR_0, VAR_6); range_decode_update(VAR_0, 1, VAR_5); } else { int VAR_7 = VAR_6, VAR_8; int VAR_9 = 0; while (VAR_7 & ~0xFFFF) { VAR_7 >>= 1; VAR_9++; } VAR_7 = range_decode_culfreq(VAR_0, VAR_7 + 1); range_decode_update(VAR_0, 1, VAR_7); VAR_8 = range_decode_culfreq(VAR_0, 1 << VAR_9); range_decode_update(VAR_0, 1, VAR_8); VAR_5 = (VAR_7 << VAR_9) + VAR_8; } VAR_2 = VAR_5 + VAR_3 * VAR_6; } update_rice(VAR_1, VAR_2); if (VAR_2 & 1)
return (VAR_2 >> 1) + 1; else
return -(VAR_2 >> 1); }