static inline int16_t g726_iterate(G726Context* c, int16_t I)

{

    int dq, re_signal, pk0, fa1, i, tr, ylint, ylfrac, thr2, al, dq0;

    Float11 f;

    

    dq = inverse_quant(c, I);

    if (I >> (c->tbls->bits - 1))  /* get the sign */

        dq = -dq;

    re_signal = c->se + dq;



    /* Transition detect */

    ylint = (c->yl >> 15);

    ylfrac = (c->yl >> 10) & 0x1f;

    thr2 = (ylint > 9) ? 0x1f << 10 : (0x20 + ylfrac) << ylint;

    if (c->td == 1 && abs(dq) > ((thr2+(thr2>>1))>>1))

        tr = 1;

    else

        tr = 0;

    

    /* Update second order predictor coefficient A2 and A1 */

    pk0 = (c->sez + dq) ? sgn(c->sez + dq) : 0;

    dq0 = dq ? sgn(dq) : 0;

    if (tr) {

        c->a[0] = 0;

	c->a[1] = 0;

        for (i=0; i<6; i++)

	   c->b[i] = 0;

    } else {

	/* This is a bit crazy, but it really is +255 not +256 */

	fa1 = clamp((-c->a[0]*c->pk[0]*pk0)>>5, -256, 255);

	

	c->a[1] += 128*pk0*c->pk[1] + fa1 - (c->a[1]>>7);

	c->a[1] = clamp(c->a[1], -12288, 12288);

        c->a[0] += 64*3*pk0*c->pk[0] - (c->a[0] >> 8);

	c->a[0] = clamp(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]);



        for (i=0; i<6; i++)

	     c->b[i] += 128*dq0*sgn(-c->dq[i].sign) - (c->b[i]>>8);

    }



    /* Update Dq and Sr and Pk */

    c->pk[1] = c->pk[0];

    c->pk[0] = pk0 ? pk0 : 1;

    c->sr[1] = c->sr[0];

    i2f(re_signal, &c->sr[0]);

    for (i=5; i>0; i--)

       c->dq[i] = c->dq[i-1];

    i2f(dq, &c->dq[0]);

    c->dq[0].sign = I >> (c->tbls->bits - 1); /* Isn't it crazy ?!?! */

    

    /* Update tone detect [I'm not sure 'tr == 0' is really needed] */

    c->td = (tr == 0 && c->a[1] < -11776); 

       

    /* Update Ap */

    c->dms += ((c->tbls->F[I]<<9) - c->dms) >> 5;

    c->dml += ((c->tbls->F[I]<<11) - c->dml) >> 7;

    if (tr) 

       c->ap = 256;

    else if (c->y > 1535 && !c->td && (abs((c->dms << 2) - c->dml) < (c->dml >> 3)))

       c->ap += (-c->ap) >> 4;

    else

       c->ap += (0x200 - c->ap) >> 4; 



    /* Update Yu and Yl */

    c->yu = clamp(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120);

    c->yl += c->yu + ((-c->yl)>>6);

 

    /* Next iteration for Y */

    al = (c->ap >= 256) ? 1<<6 : c->ap >> 2;

    c->y = (c->yl + (c->yu - (c->yl>>6))*al) >> 6;

	

    /* Next iteration for SE and SEZ */

    c->se = 0;

    for (i=0; i<6; i++)

       c->se += mult(i2f(c->b[i] >> 2, &f), &c->dq[i]);

    c->sez = c->se >> 1;

    for (i=0; i<2; i++)

       c->se += mult(i2f(c->a[i] >> 2, &f), &c->sr[i]);

    c->se >>= 1;



    return clamp(re_signal << 2, -0xffff, 0xffff);

}

static inline int16_t g726_iterate(G726Context* c, int16_t I)

{

    int dq, re_signal, pk0, fa1, i, tr, ylint, ylfrac, thr2, al, dq0;

    Float11 f;

    

    dq = inverse_quant(c, I);

    if (I >> (c->tbls->bits - 1))  

        dq = -dq;

    re_signal = c->se + dq;



    

    ylint = (c->yl >> 15);

    ylfrac = (c->yl >> 10) & 0x1f;

    thr2 = (ylint > 9) ? 0x1f << 10 : (0x20 + ylfrac) << ylint;

    if (c->td == 1 && abs(dq) > ((thr2+(thr2>>1))>>1))

        tr = 1;

    else

        tr = 0;

    

    

    pk0 = (c->sez + dq) ? sgn(c->sez + dq) : 0;

    dq0 = dq ? sgn(dq) : 0;

    if (tr) {

        c->a[0] = 0;

	c->a[1] = 0;

        for (i=0; i<6; i++)

	   c->b[i] = 0;

    } else {

	

	fa1 = clamp((-c->a[0]*c->pk[0]*pk0)>>5, -256, 255);

	

	c->a[1] += 128*pk0*c->pk[1] + fa1 - (c->a[1]>>7);

	c->a[1] = clamp(c->a[1], -12288, 12288);

        c->a[0] += 64*3*pk0*c->pk[0] - (c->a[0] >> 8);

	c->a[0] = clamp(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]);



        for (i=0; i<6; i++)

	     c->b[i] += 128*dq0*sgn(-c->dq[i].sign) - (c->b[i]>>8);

    }



    

    c->pk[1] = c->pk[0];

    c->pk[0] = pk0 ? pk0 : 1;

    c->sr[1] = c->sr[0];

    i2f(re_signal, &c->sr[0]);

    for (i=5; i>0; i--)

       c->dq[i] = c->dq[i-1];

    i2f(dq, &c->dq[0]);

    c->dq[0].sign = I >> (c->tbls->bits - 1); 

    

    

    c->td = (tr == 0 && c->a[1] < -11776); 

       

    

    c->dms += ((c->tbls->F[I]<<9) - c->dms) >> 5;

    c->dml += ((c->tbls->F[I]<<11) - c->dml) >> 7;

    if (tr) 

       c->ap = 256;

    else if (c->y > 1535 && !c->td && (abs((c->dms << 2) - c->dml) < (c->dml >> 3)))

       c->ap += (-c->ap) >> 4;

    else

       c->ap += (0x200 - c->ap) >> 4; 



    

    c->yu = clamp(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120);

    c->yl += c->yu + ((-c->yl)>>6);

 

    

    al = (c->ap >= 256) ? 1<<6 : c->ap >> 2;

    c->y = (c->yl + (c->yu - (c->yl>>6))*al) >> 6;

	

    

    c->se = 0;

    for (i=0; i<6; i++)

       c->se += mult(i2f(c->b[i] >> 2, &f), &c->dq[i]);

    c->sez = c->se >> 1;

    for (i=0; i<2; i++)

       c->se += mult(i2f(c->a[i] >> 2, &f), &c->sr[i]);

    c->se >>= 1;



    return clamp(re_signal << 2, -0xffff, 0xffff);

}

static inline int16_t FUNC_0(G726Context* c, int16_t I)

{

    int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;

    Float11 f;

    

    VAR_0 = inverse_quant(c, I);

    if (I >> (c->tbls->bits - 1))  

        VAR_0 = -VAR_0;

    VAR_1 = c->se + VAR_0;



    

    VAR_6 = (c->yl >> 15);

    VAR_7 = (c->yl >> 10) & 0x1f;

    VAR_8 = (VAR_6 > 9) ? 0x1f << 10 : (0x20 + VAR_7) << VAR_6;

    if (c->td == 1 && abs(VAR_0) > ((VAR_8+(VAR_8>>1))>>1))

        VAR_5 = 1;

    else

        VAR_5 = 0;

    

    

    VAR_2 = (c->sez + VAR_0) ? sgn(c->sez + VAR_0) : 0;

    VAR_10 = VAR_0 ? sgn(VAR_0) : 0;

    if (VAR_5) {

        c->a[0] = 0;

	c->a[1] = 0;

        for (VAR_4=0; VAR_4<6; VAR_4++)

	   c->b[VAR_4] = 0;

    } else {

	

	VAR_3 = clamp((-c->a[0]*c->pk[0]*VAR_2)>>5, -256, 255);

	

	c->a[1] += 128*VAR_2*c->pk[1] + VAR_3 - (c->a[1]>>7);

	c->a[1] = clamp(c->a[1], -12288, 12288);

        c->a[0] += 64*3*VAR_2*c->pk[0] - (c->a[0] >> 8);

	c->a[0] = clamp(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]);



        for (VAR_4=0; VAR_4<6; VAR_4++)

	     c->b[VAR_4] += 128*VAR_10*sgn(-c->VAR_0[VAR_4].sign) - (c->b[VAR_4]>>8);

    }



    

    c->pk[1] = c->pk[0];

    c->pk[0] = VAR_2 ? VAR_2 : 1;

    c->sr[1] = c->sr[0];

    i2f(VAR_1, &c->sr[0]);

    for (VAR_4=5; VAR_4>0; VAR_4--)

       c->VAR_0[VAR_4] = c->VAR_0[VAR_4-1];

    i2f(VAR_0, &c->VAR_0[0]);

    c->VAR_0[0].sign = I >> (c->tbls->bits - 1); 

    

    

    c->td = (VAR_5 == 0 && c->a[1] < -11776); 

       

    

    c->dms += ((c->tbls->F[I]<<9) - c->dms) >> 5;

    c->dml += ((c->tbls->F[I]<<11) - c->dml) >> 7;

    if (VAR_5) 

       c->ap = 256;

    else if (c->y > 1535 && !c->td && (abs((c->dms << 2) - c->dml) < (c->dml >> 3)))

       c->ap += (-c->ap) >> 4;

    else

       c->ap += (0x200 - c->ap) >> 4; 



    

    c->yu = clamp(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120);

    c->yl += c->yu + ((-c->yl)>>6);

 

    

    VAR_9 = (c->ap >= 256) ? 1<<6 : c->ap >> 2;

    c->y = (c->yl + (c->yu - (c->yl>>6))*VAR_9) >> 6;

	

    

    c->se = 0;

    for (VAR_4=0; VAR_4<6; VAR_4++)

       c->se += mult(i2f(c->b[VAR_4] >> 2, &f), &c->VAR_0[VAR_4]);

    c->sez = c->se >> 1;

    for (VAR_4=0; VAR_4<2; VAR_4++)

       c->se += mult(i2f(c->a[VAR_4] >> 2, &f), &c->sr[VAR_4]);

    c->se >>= 1;



    return clamp(VAR_1 << 2, -0xffff, 0xffff);

}

static inline int16_t FUNC_0(G726Context* c, int16_t I)
{ int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; Float11 f; VAR_0 = inverse_quant(c, I); if (I >> (c->tbls->bits - 1))
VAR_0 = -VAR_0; VAR_1 = c->se + VAR_0; VAR_6 = (c->yl >> 15); VAR_7 = (c->yl >> 10) & 0x1f; VAR_8 = (VAR_6 > 9) ? 0x1f << 10 : (0x20 + VAR_7) << VAR_6; if (c->td == 1 && abs(VAR_0) > ((VAR_8+(VAR_8>>1))>>1))
VAR_5 = 1; else
VAR_5 = 0; VAR_2 = (c->sez + VAR_0) ? sgn(c->sez + VAR_0) : 0; VAR_10 = VAR_0 ? sgn(VAR_0) : 0; if (VAR_5) { c->a[0] = 0; c->a[1] = 0; for (VAR_4=0; VAR_4<6; VAR_4++) c->b[VAR_4] = 0; } else { VAR_3 = clamp((-c->a[0]*c->pk[0]*VAR_2)>>5, -256, 255); c->a[1] += 128*VAR_2*c->pk[1] + VAR_3 - (c->a[1]>>7); c->a[1] = clamp(c->a[1], -12288, 12288); c->a[0] += 64*3*VAR_2*c->pk[0] - (c->a[0] >> 8); c->a[0] = clamp(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]); for (VAR_4=0; VAR_4<6; VAR_4++) c->b[VAR_4] += 128*VAR_10*sgn(-c->VAR_0[VAR_4].sign) - (c->b[VAR_4]>>8); } c->pk[1] = c->pk[0]; c->pk[0] = VAR_2 ? VAR_2 : 1; c->sr[1] = c->sr[0]; i2f(VAR_1, &c->sr[0]); for (VAR_4=5; VAR_4>0; VAR_4--) c->VAR_0[VAR_4] = c->VAR_0[VAR_4-1]; i2f(VAR_0, &c->VAR_0[0]); c->VAR_0[0].sign = I >> (c->tbls->bits - 1); c->td = (VAR_5 == 0 && c->a[1] < -11776); c->dms += ((c->tbls->F[I]<<9) - c->dms) >> 5; c->dml += ((c->tbls->F[I]<<11) - c->dml) >> 7; if (VAR_5)
c->ap = 256; else if (c->y > 1535 && !c->td && (abs((c->dms << 2) - c->dml) < (c->dml >> 3)))
c->ap += (-c->ap) >> 4; else
c->ap += (0x200 - c->ap) >> 4; c->yu = clamp(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120); c->yl += c->yu + ((-c->yl)>>6); VAR_9 = (c->ap >= 256) ? 1<<6 : c->ap >> 2; c->y = (c->yl + (c->yu - (c->yl>>6))*VAR_9) >> 6; c->se = 0; for (VAR_4=0; VAR_4<6; VAR_4++) c->se += mult(i2f(c->b[VAR_4] >> 2, &f), &c->VAR_0[VAR_4]); c->sez = c->se >> 1; for (VAR_4=0; VAR_4<2; VAR_4++) c->se += mult(i2f(c->a[VAR_4] >> 2, &f), &c->sr[VAR_4]); c->se >>= 1; return clamp(VAR_1 << 2, -0xffff, 0xffff); }