static float ppp_pvq_search_c(float *X, int *y, int K, int N)

{

    int i, y_norm = 0;

    float res = 0.0f, xy_norm = 0.0f;



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

        res += FFABS(X[i]);



    res = K/(res + FLT_EPSILON);



    for (i = 0; i < N; i++) {

        y[i] = lrintf(res*X[i]);

        y_norm  += y[i]*y[i];

        xy_norm += y[i]*X[i];

        K -= FFABS(y[i]);

    }



    while (K) {

        int max_idx = 0, max_den = 1, phase = FFSIGN(K);

        float max_num = 0.0f;

        y_norm += 1.0f;



        for (i = 0; i < N; i++) {

            /* If the sum has been overshot and the best place has 0 pulses allocated

             * to it, attempting to decrease it further will actually increase the

             * sum. Prevent this by disregarding any 0 positions when decrementing. */

            const int ca = 1 ^ ((y[i] == 0) & (phase < 0));

            const int y_new = y_norm  + 2*phase*FFABS(y[i]);

            float xy_new = xy_norm + 1*phase*FFABS(X[i]);

            xy_new = xy_new * xy_new;

            if (ca && (max_den*xy_new) > (y_new*max_num)) {

                max_den = y_new;

                max_num = xy_new;

                max_idx = i;

            }

        }



        K -= phase;



        phase *= FFSIGN(X[max_idx]);

        xy_norm += 1*phase*X[max_idx];

        y_norm  += 2*phase*y[max_idx];

        y[max_idx] += phase;

    }



    return (float)y_norm;

}

static float ppp_pvq_search_c(float *X, int *y, int K, int N)

{

    int i, y_norm = 0;

    float res = 0.0f, xy_norm = 0.0f;



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

        res += FFABS(X[i]);



    res = K/(res + FLT_EPSILON);



    for (i = 0; i < N; i++) {

        y[i] = lrintf(res*X[i]);

        y_norm  += y[i]*y[i];

        xy_norm += y[i]*X[i];

        K -= FFABS(y[i]);

    }



    while (K) {

        int max_idx = 0, max_den = 1, phase = FFSIGN(K);

        float max_num = 0.0f;

        y_norm += 1.0f;



        for (i = 0; i < N; i++) {

            





            const int ca = 1 ^ ((y[i] == 0) & (phase < 0));

            const int y_new = y_norm  + 2*phase*FFABS(y[i]);

            float xy_new = xy_norm + 1*phase*FFABS(X[i]);

            xy_new = xy_new * xy_new;

            if (ca && (max_den*xy_new) > (y_new*max_num)) {

                max_den = y_new;

                max_num = xy_new;

                max_idx = i;

            }

        }



        K -= phase;



        phase *= FFSIGN(X[max_idx]);

        xy_norm += 1*phase*X[max_idx];

        y_norm  += 2*phase*y[max_idx];

        y[max_idx] += phase;

    }



    return (float)y_norm;

}

static float FUNC_0(float *VAR_0, int *VAR_1, int VAR_2, int VAR_3)

{

    int VAR_4, VAR_5 = 0;

    float VAR_6 = 0.0f, VAR_7 = 0.0f;



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

        VAR_6 += FFABS(VAR_0[VAR_4]);



    VAR_6 = VAR_2/(VAR_6 + FLT_EPSILON);



    for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

        VAR_1[VAR_4] = lrintf(VAR_6*VAR_0[VAR_4]);

        VAR_5  += VAR_1[VAR_4]*VAR_1[VAR_4];

        VAR_7 += VAR_1[VAR_4]*VAR_0[VAR_4];

        VAR_2 -= FFABS(VAR_1[VAR_4]);

    }



    while (VAR_2) {

        int VAR_8 = 0, VAR_9 = 1, VAR_10 = FFSIGN(VAR_2);

        float VAR_11 = 0.0f;

        VAR_5 += 1.0f;



        for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

            





            const int VAR_12 = 1 ^ ((VAR_1[VAR_4] == 0) & (VAR_10 < 0));

            const int VAR_13 = VAR_5  + 2*VAR_10*FFABS(VAR_1[VAR_4]);

            float VAR_14 = VAR_7 + 1*VAR_10*FFABS(VAR_0[VAR_4]);

            VAR_14 = VAR_14 * VAR_14;

            if (VAR_12 && (VAR_9*VAR_14) > (VAR_13*VAR_11)) {

                VAR_9 = VAR_13;

                VAR_11 = VAR_14;

                VAR_8 = VAR_4;

            }

        }



        VAR_2 -= VAR_10;



        VAR_10 *= FFSIGN(VAR_0[VAR_8]);

        VAR_7 += 1*VAR_10*VAR_0[VAR_8];

        VAR_5  += 2*VAR_10*VAR_1[VAR_8];

        VAR_1[VAR_8] += VAR_10;

    }



    return (float)VAR_5;

}

static float FUNC_0(float *VAR_0, int *VAR_1, int VAR_2, int VAR_3)
{ int VAR_4, VAR_5 = 0; float VAR_6 = 0.0f, VAR_7 = 0.0f; for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) VAR_6 += FFABS(VAR_0[VAR_4]); VAR_6 = VAR_2/(VAR_6 + FLT_EPSILON); for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { VAR_1[VAR_4] = lrintf(VAR_6*VAR_0[VAR_4]); VAR_5  += VAR_1[VAR_4]*VAR_1[VAR_4]; VAR_7 += VAR_1[VAR_4]*VAR_0[VAR_4]; VAR_2 -= FFABS(VAR_1[VAR_4]); } while (VAR_2) { int VAR_8 = 0, VAR_9 = 1, VAR_10 = FFSIGN(VAR_2); float VAR_11 = 0.0f; VAR_5 += 1.0f; for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { const int VAR_12 = 1 ^ ((VAR_1[VAR_4] == 0) & (VAR_10 < 0)); const int VAR_13 = VAR_5  + 2*VAR_10*FFABS(VAR_1[VAR_4]); float VAR_14 = VAR_7 + 1*VAR_10*FFABS(VAR_0[VAR_4]); VAR_14 = VAR_14 * VAR_14; if (VAR_12 && (VAR_9*VAR_14) > (VAR_13*VAR_11)) { VAR_9 = VAR_13; VAR_11 = VAR_14; VAR_8 = VAR_4; } } VAR_2 -= VAR_10; VAR_10 *= FFSIGN(VAR_0[VAR_8]); VAR_7 += 1*VAR_10*VAR_0[VAR_8]; VAR_5  += 2*VAR_10*VAR_1[VAR_8]; VAR_1[VAR_8] += VAR_10; } return (float)VAR_5; }