static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,

                                       int width, int thresh,

                                       const uint16_t *dithers)

{

    intptr_t x;

    if (width & 3) {

        x = width & ~3;

        ff_gradfun_filter_line_c(dst + x, src + x, dc + x / 2, width - x, thresh, dithers);

        width = x;

    }

    x = -width;

    __asm__ volatile(

        "movd          %4, %%mm5 \n"

        "pxor       %%mm7, %%mm7 \n"

        "pshufw $0, %%mm5, %%mm5 \n"

        "movq          %6, %%mm6 \n"

        "movq          %5, %%mm4 \n"

        "1: \n"

        "movd     (%2,%0), %%mm0 \n"

        "movd     (%3,%0), %%mm1 \n"

        "punpcklbw  %%mm7, %%mm0 \n"

        "punpcklwd  %%mm1, %%mm1 \n"

        "psllw         $7, %%mm0 \n"

        "pxor       %%mm2, %%mm2 \n"

        "psubw      %%mm0, %%mm1 \n" // delta = dc - pix

        "psubw      %%mm1, %%mm2 \n"

        "pmaxsw     %%mm1, %%mm2 \n"

        "pmulhuw    %%mm5, %%mm2 \n" // m = abs(delta) * thresh >> 16

        "psubw      %%mm6, %%mm2 \n"

        "pminsw     %%mm7, %%mm2 \n" // m = -max(0, 127-m)

        "pmullw     %%mm2, %%mm2 \n"

        "paddw      %%mm4, %%mm0 \n" // pix += dither

        "pmulhw     %%mm2, %%mm1 \n"

        "psllw         $2, %%mm1 \n" // m = m*m*delta >> 14

        "paddw      %%mm1, %%mm0 \n" // pix += m

        "psraw         $7, %%mm0 \n"

        "packuswb   %%mm0, %%mm0 \n"

        "movd       %%mm0, (%1,%0) \n" // dst = clip(pix>>7)

        "add           $4, %0 \n"

        "jl 1b \n"

        "emms \n"

        :"+r"(x)

        :"r"(dst+width), "r"(src+width), "r"(dc+width/2),

         "rm"(thresh), "m"(*dithers), "m"(*pw_7f)

        :"memory"

    );

}

static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,

                                       int width, int thresh,

                                       const uint16_t *dithers)

{

    intptr_t x;

    if (width & 3) {

        x = width & ~3;

        ff_gradfun_filter_line_c(dst + x, src + x, dc + x / 2, width - x, thresh, dithers);

        width = x;

    }

    x = -width;

    __asm__ volatile(

        "movd          %4, %%mm5 \n"

        "pxor       %%mm7, %%mm7 \n"

        "pshufw $0, %%mm5, %%mm5 \n"

        "movq          %6, %%mm6 \n"

        "movq          %5, %%mm4 \n"

        "1: \n"

        "movd     (%2,%0), %%mm0 \n"

        "movd     (%3,%0), %%mm1 \n"

        "punpcklbw  %%mm7, %%mm0 \n"

        "punpcklwd  %%mm1, %%mm1 \n"

        "psllw         $7, %%mm0 \n"

        "pxor       %%mm2, %%mm2 \n"

        "psubw      %%mm0, %%mm1 \n" 

        "psubw      %%mm1, %%mm2 \n"

        "pmaxsw     %%mm1, %%mm2 \n"

        "pmulhuw    %%mm5, %%mm2 \n" 

        "psubw      %%mm6, %%mm2 \n"

        "pminsw     %%mm7, %%mm2 \n" 

        "pmullw     %%mm2, %%mm2 \n"

        "paddw      %%mm4, %%mm0 \n" 

        "pmulhw     %%mm2, %%mm1 \n"

        "psllw         $2, %%mm1 \n" 

        "paddw      %%mm1, %%mm0 \n" 

        "psraw         $7, %%mm0 \n"

        "packuswb   %%mm0, %%mm0 \n"

        "movd       %%mm0, (%1,%0) \n" 

        "add           $4, %0 \n"

        "jl 1b \n"

        "emms \n"

        :"+r"(x)

        :"r"(dst+width), "r"(src+width), "r"(dc+width/2),

         "rm"(thresh), "m"(*dithers), "m"(*pw_7f)

        :"memory"

    );

}

        "pmulhw     %%mm2, %%mm1 \n"
static void FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1, uint16_t *VAR_2,

                                       int VAR_3, int VAR_4,

                                       const uint16_t *VAR_5)

{

    intptr_t x;

    if (VAR_3 & 3) {

        x = VAR_3 & ~3;

        ff_gradfun_filter_line_c(VAR_0 + x, VAR_1 + x, VAR_2 + x / 2, VAR_3 - x, VAR_4, VAR_5);

        VAR_3 = x;

    }

    x = -VAR_3;

    __asm__ volatile(

        "movd          %4, %%mm5 \n"

        "pxor       %%mm7, %%mm7 \n"

        "pshufw $0, %%mm5, %%mm5 \n"

        "movq          %6, %%mm6 \n"

        "movq          %5, %%mm4 \n"

        "1: \n"

        "movd     (%2,%0), %%mm0 \n"

        "movd     (%3,%0), %%mm1 \n"

        "punpcklbw  %%mm7, %%mm0 \n"

        "punpcklwd  %%mm1, %%mm1 \n"

        "psllw         $7, %%mm0 \n"

        "pxor       %%mm2, %%mm2 \n"

        "psubw      %%mm0, %%mm1 \n" 

        "psubw      %%mm1, %%mm2 \n"

        "pmaxsw     %%mm1, %%mm2 \n"

        "pmulhuw    %%mm5, %%mm2 \n" 

        "psubw      %%mm6, %%mm2 \n"

        "pminsw     %%mm7, %%mm2 \n" 

        "pmullw     %%mm2, %%mm2 \n"

        "paddw      %%mm4, %%mm0 \n" 

        "pmulhw     %%mm2, %%mm1 \n"

        "psllw         $2, %%mm1 \n" 

        "paddw      %%mm1, %%mm0 \n" 

        "psraw         $7, %%mm0 \n"

        "packuswb   %%mm0, %%mm0 \n"

        "movd       %%mm0, (%1,%0) \n" 

        "add           $4, %0 \n"

        "jl 1b \n"

        "emms \n"

        :"+r"(x)

        :"r"(VAR_0+VAR_3), "r"(VAR_1+VAR_3), "r"(VAR_2+VAR_3/2),

         "rm"(VAR_4), "m"(*VAR_5), "m"(*pw_7f)

        :"memory"

    );

}

static void FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1, uint16_t *VAR_2,
int VAR_3, int VAR_4,
const uint16_t *VAR_5)
{ intptr_t x; if (VAR_3 & 3) { x = VAR_3 & ~3; ff_gradfun_filter_line_c(VAR_0 + x, VAR_1 + x, VAR_2 + x / 2, VAR_3 - x, VAR_4, VAR_5); VAR_3 = x; } x = -VAR_3; __asm__ volatile(
"movd          %4, %%mm5 \n"
"pxor       %%mm7, %%mm7 \n"
"pshufw $0, %%mm5, %%mm5 \n"
"movq          %6, %%mm6 \n"
"movq          %5, %%mm4 \n"
"1: \n"
"movd     (%2,%0), %%mm0 \n"
"movd     (%3,%0), %%mm1 \n"
"punpcklbw  %%mm7, %%mm0 \n"
"punpcklwd  %%mm1, %%mm1 \n"
"psllw         $7, %%mm0 \n"
"pxor       %%mm2, %%mm2 \n"
"psubw      %%mm0, %%mm1 \n"
"psubw      %%mm1, %%mm2 \n"
"pmaxsw     %%mm1, %%mm2 \n"
"pmulhuw    %%mm5, %%mm2 \n"
"psubw      %%mm6, %%mm2 \n"
"pminsw     %%mm7, %%mm2 \n"
"pmullw     %%mm2, %%mm2 \n"
"paddw      %%mm4, %%mm0 \n"
"pmulhw     %%mm2, %%mm1 \n"
"psllw         $2, %%mm1 \n"
"paddw      %%mm1, %%mm0 \n"
"psraw         $7, %%mm0 \n"
"packuswb   %%mm0, %%mm0 \n"
"movd       %%mm0, (%1,%0) \n"
"add           $4, %0 \n"
"jl 1b \n"
"emms \n"
:"+r"(x)
:"r"(VAR_0+VAR_3), "r"(VAR_1+VAR_3), "r"(VAR_2+VAR_3/2),
"rm"(VAR_4), "m"(*VAR_5), "m"(*pw_7f)
:"memory"
); }