static inline struct rgbvec interp_tetrahedral(const LUT3DContext *lut3d,

                                               const struct rgbvec *s)

{

    const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};

    const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];

    const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];

    const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];

    const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];

    const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];

    const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];

    const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];

    const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];

    struct rgbvec c;

    if (d.r > d.g) {

        if (d.g > d.b) {

            c.r = (1-d.r) * c000.r + (d.r-d.g) * c100.r + (d.g-d.b) * c110.r + (d.b) * c111.r;

            c.g = (1-d.r) * c000.g + (d.r-d.g) * c100.g + (d.g-d.b) * c110.g + (d.b) * c111.g;

            c.b = (1-d.r) * c000.b + (d.r-d.g) * c100.b + (d.g-d.b) * c110.b + (d.b) * c111.b;

        } else if (d.r > d.b) {

            c.r = (1-d.r) * c000.r + (d.r-d.b) * c100.r + (d.b-d.g) * c101.r + (d.g) * c111.r;

            c.g = (1-d.r) * c000.g + (d.r-d.b) * c100.g + (d.b-d.g) * c101.g + (d.g) * c111.g;

            c.b = (1-d.r) * c000.b + (d.r-d.b) * c100.b + (d.b-d.g) * c101.b + (d.g) * c111.b;

        } else {

            c.r = (1-d.b) * c000.r + (d.b-d.r) * c001.r + (d.r-d.g) * c101.r + (d.g) * c111.r;

            c.g = (1-d.b) * c000.g + (d.b-d.r) * c001.g + (d.r-d.g) * c101.g + (d.g) * c111.g;

            c.b = (1-d.b) * c000.b + (d.b-d.r) * c001.b + (d.r-d.g) * c101.b + (d.g) * c111.b;

        }

    } else {

        if (d.b > d.g) {

            c.r = (1-d.b) * c000.r + (d.b-d.g) * c001.r + (d.g-d.r) * c011.r + (d.r) * c111.r;

            c.g = (1-d.b) * c000.g + (d.b-d.g) * c001.g + (d.g-d.r) * c011.g + (d.r) * c111.g;

            c.b = (1-d.b) * c000.b + (d.b-d.g) * c001.b + (d.g-d.r) * c011.b + (d.r) * c111.b;

        } else if (d.b > d.r) {

            c.r = (1-d.g) * c000.r + (d.g-d.b) * c010.r + (d.b-d.r) * c011.r + (d.r) * c111.r;

            c.g = (1-d.g) * c000.g + (d.g-d.b) * c010.g + (d.b-d.r) * c011.g + (d.r) * c111.g;

            c.b = (1-d.g) * c000.b + (d.g-d.b) * c010.b + (d.b-d.r) * c011.b + (d.r) * c111.b;

        } else {

            c.r = (1-d.g) * c000.r + (d.g-d.r) * c010.r + (d.r-d.b) * c110.r + (d.b) * c111.r;

            c.g = (1-d.g) * c000.g + (d.g-d.r) * c010.g + (d.r-d.b) * c110.g + (d.b) * c111.g;

            c.b = (1-d.g) * c000.b + (d.g-d.r) * c010.b + (d.r-d.b) * c110.b + (d.b) * c111.b;

        }

    }

    return c;

}

static inline struct rgbvec interp_tetrahedral(const LUT3DContext *lut3d,

                                               const struct rgbvec *s)

{

    const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};

    const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];

    const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];

    const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];

    const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];

    const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];

    const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];

    const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];

    const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];

    struct rgbvec c;

    if (d.r > d.g) {

        if (d.g > d.b) {

            c.r = (1-d.r) * c000.r + (d.r-d.g) * c100.r + (d.g-d.b) * c110.r + (d.b) * c111.r;

            c.g = (1-d.r) * c000.g + (d.r-d.g) * c100.g + (d.g-d.b) * c110.g + (d.b) * c111.g;

            c.b = (1-d.r) * c000.b + (d.r-d.g) * c100.b + (d.g-d.b) * c110.b + (d.b) * c111.b;

        } else if (d.r > d.b) {

            c.r = (1-d.r) * c000.r + (d.r-d.b) * c100.r + (d.b-d.g) * c101.r + (d.g) * c111.r;

            c.g = (1-d.r) * c000.g + (d.r-d.b) * c100.g + (d.b-d.g) * c101.g + (d.g) * c111.g;

            c.b = (1-d.r) * c000.b + (d.r-d.b) * c100.b + (d.b-d.g) * c101.b + (d.g) * c111.b;

        } else {

            c.r = (1-d.b) * c000.r + (d.b-d.r) * c001.r + (d.r-d.g) * c101.r + (d.g) * c111.r;

            c.g = (1-d.b) * c000.g + (d.b-d.r) * c001.g + (d.r-d.g) * c101.g + (d.g) * c111.g;

            c.b = (1-d.b) * c000.b + (d.b-d.r) * c001.b + (d.r-d.g) * c101.b + (d.g) * c111.b;

        }

    } else {

        if (d.b > d.g) {

            c.r = (1-d.b) * c000.r + (d.b-d.g) * c001.r + (d.g-d.r) * c011.r + (d.r) * c111.r;

            c.g = (1-d.b) * c000.g + (d.b-d.g) * c001.g + (d.g-d.r) * c011.g + (d.r) * c111.g;

            c.b = (1-d.b) * c000.b + (d.b-d.g) * c001.b + (d.g-d.r) * c011.b + (d.r) * c111.b;

        } else if (d.b > d.r) {

            c.r = (1-d.g) * c000.r + (d.g-d.b) * c010.r + (d.b-d.r) * c011.r + (d.r) * c111.r;

            c.g = (1-d.g) * c000.g + (d.g-d.b) * c010.g + (d.b-d.r) * c011.g + (d.r) * c111.g;

            c.b = (1-d.g) * c000.b + (d.g-d.b) * c010.b + (d.b-d.r) * c011.b + (d.r) * c111.b;

        } else {

            c.r = (1-d.g) * c000.r + (d.g-d.r) * c010.r + (d.r-d.b) * c110.r + (d.b) * c111.r;

            c.g = (1-d.g) * c000.g + (d.g-d.r) * c010.g + (d.r-d.b) * c110.g + (d.b) * c111.g;

            c.b = (1-d.g) * c000.b + (d.g-d.r) * c010.b + (d.r-d.b) * c110.b + (d.b) * c111.b;

        }

    }

    return c;

}

    const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};     const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];     const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];     const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];     const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];     const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];     const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];     const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];     const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];     const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};     const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];     const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];     const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];     const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];     const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];     const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];     const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];     const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];
static inline struct rgbvec FUNC_0(const LUT3DContext *VAR_0,

                                               const struct rgbvec *VAR_1)

{

    const struct rgbvec VAR_2 = {VAR_1->r - PREV(VAR_1->r), VAR_1->g - PREV(VAR_1->g), VAR_1->b - PREV(VAR_1->b)};

    const struct rgbvec VAR_3 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)];

    const struct rgbvec VAR_4 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)];

    const struct rgbvec VAR_5 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)];

    const struct rgbvec VAR_6 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)];

    const struct rgbvec VAR_7 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)];

    const struct rgbvec VAR_8 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)];

    const struct rgbvec VAR_9 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)];

    const struct rgbvec VAR_10 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)];

    struct rgbvec VAR_11;

    if (VAR_2.r > VAR_2.g) {

        if (VAR_2.g > VAR_2.b) {

            VAR_11.r = (1-VAR_2.r) * VAR_3.r + (VAR_2.r-VAR_2.g) * VAR_7.r + (VAR_2.g-VAR_2.b) * VAR_9.r + (VAR_2.b) * VAR_10.r;

            VAR_11.g = (1-VAR_2.r) * VAR_3.g + (VAR_2.r-VAR_2.g) * VAR_7.g + (VAR_2.g-VAR_2.b) * VAR_9.g + (VAR_2.b) * VAR_10.g;

            VAR_11.b = (1-VAR_2.r) * VAR_3.b + (VAR_2.r-VAR_2.g) * VAR_7.b + (VAR_2.g-VAR_2.b) * VAR_9.b + (VAR_2.b) * VAR_10.b;

        } else if (VAR_2.r > VAR_2.b) {

            VAR_11.r = (1-VAR_2.r) * VAR_3.r + (VAR_2.r-VAR_2.b) * VAR_7.r + (VAR_2.b-VAR_2.g) * VAR_8.r + (VAR_2.g) * VAR_10.r;

            VAR_11.g = (1-VAR_2.r) * VAR_3.g + (VAR_2.r-VAR_2.b) * VAR_7.g + (VAR_2.b-VAR_2.g) * VAR_8.g + (VAR_2.g) * VAR_10.g;

            VAR_11.b = (1-VAR_2.r) * VAR_3.b + (VAR_2.r-VAR_2.b) * VAR_7.b + (VAR_2.b-VAR_2.g) * VAR_8.b + (VAR_2.g) * VAR_10.b;

        } else {

            VAR_11.r = (1-VAR_2.b) * VAR_3.r + (VAR_2.b-VAR_2.r) * VAR_4.r + (VAR_2.r-VAR_2.g) * VAR_8.r + (VAR_2.g) * VAR_10.r;

            VAR_11.g = (1-VAR_2.b) * VAR_3.g + (VAR_2.b-VAR_2.r) * VAR_4.g + (VAR_2.r-VAR_2.g) * VAR_8.g + (VAR_2.g) * VAR_10.g;

            VAR_11.b = (1-VAR_2.b) * VAR_3.b + (VAR_2.b-VAR_2.r) * VAR_4.b + (VAR_2.r-VAR_2.g) * VAR_8.b + (VAR_2.g) * VAR_10.b;

        }

    } else {

        if (VAR_2.b > VAR_2.g) {

            VAR_11.r = (1-VAR_2.b) * VAR_3.r + (VAR_2.b-VAR_2.g) * VAR_4.r + (VAR_2.g-VAR_2.r) * VAR_6.r + (VAR_2.r) * VAR_10.r;

            VAR_11.g = (1-VAR_2.b) * VAR_3.g + (VAR_2.b-VAR_2.g) * VAR_4.g + (VAR_2.g-VAR_2.r) * VAR_6.g + (VAR_2.r) * VAR_10.g;

            VAR_11.b = (1-VAR_2.b) * VAR_3.b + (VAR_2.b-VAR_2.g) * VAR_4.b + (VAR_2.g-VAR_2.r) * VAR_6.b + (VAR_2.r) * VAR_10.b;

        } else if (VAR_2.b > VAR_2.r) {

            VAR_11.r = (1-VAR_2.g) * VAR_3.r + (VAR_2.g-VAR_2.b) * VAR_5.r + (VAR_2.b-VAR_2.r) * VAR_6.r + (VAR_2.r) * VAR_10.r;

            VAR_11.g = (1-VAR_2.g) * VAR_3.g + (VAR_2.g-VAR_2.b) * VAR_5.g + (VAR_2.b-VAR_2.r) * VAR_6.g + (VAR_2.r) * VAR_10.g;

            VAR_11.b = (1-VAR_2.g) * VAR_3.b + (VAR_2.g-VAR_2.b) * VAR_5.b + (VAR_2.b-VAR_2.r) * VAR_6.b + (VAR_2.r) * VAR_10.b;

        } else {

            VAR_11.r = (1-VAR_2.g) * VAR_3.r + (VAR_2.g-VAR_2.r) * VAR_5.r + (VAR_2.r-VAR_2.b) * VAR_9.r + (VAR_2.b) * VAR_10.r;

            VAR_11.g = (1-VAR_2.g) * VAR_3.g + (VAR_2.g-VAR_2.r) * VAR_5.g + (VAR_2.r-VAR_2.b) * VAR_9.g + (VAR_2.b) * VAR_10.g;

            VAR_11.b = (1-VAR_2.g) * VAR_3.b + (VAR_2.g-VAR_2.r) * VAR_5.b + (VAR_2.r-VAR_2.b) * VAR_9.b + (VAR_2.b) * VAR_10.b;

        }

    }

    return VAR_11;

}

static inline struct rgbvec FUNC_0(const LUT3DContext *VAR_0,
const struct rgbvec *VAR_1)
{ const struct rgbvec VAR_2 = {VAR_1->r - PREV(VAR_1->r), VAR_1->g - PREV(VAR_1->g), VAR_1->b - PREV(VAR_1->b)}; const struct rgbvec VAR_3 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)]; const struct rgbvec VAR_4 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)]; const struct rgbvec VAR_5 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)]; const struct rgbvec VAR_6 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)]; const struct rgbvec VAR_7 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)]; const struct rgbvec VAR_8 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)]; const struct rgbvec VAR_9 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)]; const struct rgbvec VAR_10 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)]; struct rgbvec VAR_11; if (VAR_2.r > VAR_2.g) { if (VAR_2.g > VAR_2.b) { VAR_11.r = (1-VAR_2.r) * VAR_3.r + (VAR_2.r-VAR_2.g) * VAR_7.r + (VAR_2.g-VAR_2.b) * VAR_9.r + (VAR_2.b) * VAR_10.r; VAR_11.g = (1-VAR_2.r) * VAR_3.g + (VAR_2.r-VAR_2.g) * VAR_7.g + (VAR_2.g-VAR_2.b) * VAR_9.g + (VAR_2.b) * VAR_10.g; VAR_11.b = (1-VAR_2.r) * VAR_3.b + (VAR_2.r-VAR_2.g) * VAR_7.b + (VAR_2.g-VAR_2.b) * VAR_9.b + (VAR_2.b) * VAR_10.b; } else if (VAR_2.r > VAR_2.b) { VAR_11.r = (1-VAR_2.r) * VAR_3.r + (VAR_2.r-VAR_2.b) * VAR_7.r + (VAR_2.b-VAR_2.g) * VAR_8.r + (VAR_2.g) * VAR_10.r; VAR_11.g = (1-VAR_2.r) * VAR_3.g + (VAR_2.r-VAR_2.b) * VAR_7.g + (VAR_2.b-VAR_2.g) * VAR_8.g + (VAR_2.g) * VAR_10.g; VAR_11.b = (1-VAR_2.r) * VAR_3.b + (VAR_2.r-VAR_2.b) * VAR_7.b + (VAR_2.b-VAR_2.g) * VAR_8.b + (VAR_2.g) * VAR_10.b; } else { VAR_11.r = (1-VAR_2.b) * VAR_3.r + (VAR_2.b-VAR_2.r) * VAR_4.r + (VAR_2.r-VAR_2.g) * VAR_8.r + (VAR_2.g) * VAR_10.r; VAR_11.g = (1-VAR_2.b) * VAR_3.g + (VAR_2.b-VAR_2.r) * VAR_4.g + (VAR_2.r-VAR_2.g) * VAR_8.g + (VAR_2.g) * VAR_10.g; VAR_11.b = (1-VAR_2.b) * VAR_3.b + (VAR_2.b-VAR_2.r) * VAR_4.b + (VAR_2.r-VAR_2.g) * VAR_8.b + (VAR_2.g) * VAR_10.b; } } else { if (VAR_2.b > VAR_2.g) { VAR_11.r = (1-VAR_2.b) * VAR_3.r + (VAR_2.b-VAR_2.g) * VAR_4.r + (VAR_2.g-VAR_2.r) * VAR_6.r + (VAR_2.r) * VAR_10.r; VAR_11.g = (1-VAR_2.b) * VAR_3.g + (VAR_2.b-VAR_2.g) * VAR_4.g + (VAR_2.g-VAR_2.r) * VAR_6.g + (VAR_2.r) * VAR_10.g; VAR_11.b = (1-VAR_2.b) * VAR_3.b + (VAR_2.b-VAR_2.g) * VAR_4.b + (VAR_2.g-VAR_2.r) * VAR_6.b + (VAR_2.r) * VAR_10.b; } else if (VAR_2.b > VAR_2.r) { VAR_11.r = (1-VAR_2.g) * VAR_3.r + (VAR_2.g-VAR_2.b) * VAR_5.r + (VAR_2.b-VAR_2.r) * VAR_6.r + (VAR_2.r) * VAR_10.r; VAR_11.g = (1-VAR_2.g) * VAR_3.g + (VAR_2.g-VAR_2.b) * VAR_5.g + (VAR_2.b-VAR_2.r) * VAR_6.g + (VAR_2.r) * VAR_10.g; VAR_11.b = (1-VAR_2.g) * VAR_3.b + (VAR_2.g-VAR_2.b) * VAR_5.b + (VAR_2.b-VAR_2.r) * VAR_6.b + (VAR_2.r) * VAR_10.b; } else { VAR_11.r = (1-VAR_2.g) * VAR_3.r + (VAR_2.g-VAR_2.r) * VAR_5.r + (VAR_2.r-VAR_2.b) * VAR_9.r + (VAR_2.b) * VAR_10.r; VAR_11.g = (1-VAR_2.g) * VAR_3.g + (VAR_2.g-VAR_2.r) * VAR_5.g + (VAR_2.r-VAR_2.b) * VAR_9.g + (VAR_2.b) * VAR_10.g; VAR_11.b = (1-VAR_2.g) * VAR_3.b + (VAR_2.g-VAR_2.r) * VAR_5.b + (VAR_2.r-VAR_2.b) * VAR_9.b + (VAR_2.b) * VAR_10.b; } } return VAR_11; }