static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
{
    int i, tmp, partition, method_type, rice_order;
    int rice_bits, rice_esc;
    int samples;
    method_type = get_bits(&s->gb, 2);
    if (method_type > 1) {
        av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
               method_type);
    rice_order = get_bits(&s->gb, 4);
    samples= s->blocksize >> rice_order;
    if (pred_order > samples) {
        av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
               pred_order, samples);
    rice_bits = 4 + method_type;
    rice_esc  = (1 << rice_bits) - 1;
    decoded += pred_order;
    i= pred_order;
    for (partition = 0; partition < (1 << rice_order); partition++) {
        tmp = get_bits(&s->gb, rice_bits);
        if (tmp == rice_esc) {
            tmp = get_bits(&s->gb, 5);
            for (; i < samples; i++)
                *decoded++ = get_sbits_long(&s->gb, tmp);
        } else {
            for (; i < samples; i++) {
                *decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
        i= 0;
    return 0;
static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
{
    int i, tmp, partition, method_type, rice_order;
    int rice_bits, rice_esc;
    int samples;
    method_type = get_bits(&s->gb, 2);
    if (method_type > 1) {
        av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
               method_type);
    rice_order = get_bits(&s->gb, 4);
    samples= s->blocksize >> rice_order;
    if (pred_order > samples) {
        av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
               pred_order, samples);
    rice_bits = 4 + method_type;
    rice_esc  = (1 << rice_bits) - 1;
    decoded += pred_order;
    i= pred_order;
    for (partition = 0; partition < (1 << rice_order); partition++) {
        tmp = get_bits(&s->gb, rice_bits);
        if (tmp == rice_esc) {
            tmp = get_bits(&s->gb, 5);
            for (; i < samples; i++)
                *decoded++ = get_sbits_long(&s->gb, tmp);
        } else {
            for (; i < samples; i++) {
                *decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
        i= 0;
    return 0;
static int FUNC_0(FLACContext *VAR_0, int32_t *VAR_1, int VAR_2)
{
    int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
    int VAR_8, VAR_9;
    int VAR_10;
    VAR_6 = get_bits(&VAR_0->gb, 2);
    if (VAR_6 > 1) {
        av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
               VAR_6);
    VAR_7 = get_bits(&VAR_0->gb, 4);
    VAR_10= VAR_0->blocksize >> VAR_7;
    if (VAR_2 > VAR_10) {
        av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid predictor order: %VAR_3 > %VAR_3\n",
               VAR_2, VAR_10);
    VAR_8 = 4 + VAR_6;
    VAR_9  = (1 << VAR_8) - 1;
    VAR_1 += VAR_2;
    VAR_3= VAR_2;
    for (VAR_5 = 0; VAR_5 < (1 << VAR_7); VAR_5++) {
        VAR_4 = get_bits(&VAR_0->gb, VAR_8);
        if (VAR_4 == VAR_9) {
            VAR_4 = get_bits(&VAR_0->gb, 5);
            for (; VAR_3 < VAR_10; VAR_3++)
                *VAR_1++ = get_sbits_long(&VAR_0->gb, VAR_4);
        } else {
            for (; VAR_3 < VAR_10; VAR_3++) {
                *VAR_1++ = get_sr_golomb_flac(&VAR_0->gb, VAR_4, INT_MAX, 0);
        VAR_3= 0;
    return 0;
static int FUNC_0(FLACContext *VAR_0, int32_t *VAR_1, int VAR_2)
{ int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; int VAR_8, VAR_9; int VAR_10; VAR_6 = get_bits(&VAR_0->gb, 2); if (VAR_6 > 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
VAR_6); VAR_7 = get_bits(&VAR_0->gb, 4); VAR_10= VAR_0->blocksize >> VAR_7; if (VAR_2 > VAR_10) { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid predictor order: %VAR_3 > %VAR_3\n",
VAR_2, VAR_10); VAR_8 = 4 + VAR_6; VAR_9  = (1 << VAR_8) - 1; VAR_1 += VAR_2; VAR_3= VAR_2; for (VAR_5 = 0; VAR_5 < (1 << VAR_7); VAR_5++) { VAR_4 = get_bits(&VAR_0->gb, VAR_8); if (VAR_4 == VAR_9) { VAR_4 = get_bits(&VAR_0->gb, 5); for (; VAR_3 < VAR_10; VAR_3++) *VAR_1++ = get_sbits_long(&VAR_0->gb, VAR_4); } else { for (; VAR_3 < VAR_10; VAR_3++) { *VAR_1++ = get_sr_golomb_flac(&VAR_0->gb, VAR_4, INT_MAX, 0); VAR_3= 0; return 0;