aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/pr55342.c
blob: 0d9e6c6238c3dc795728cee0fcd8a1a2223c81c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* PR rtl-optimization/55342 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-final { scan-assembler-not "notb" } } */


void convert_image(unsigned char *in, unsigned char *out, int size) {
    int i;
    unsigned char * read = in,
     * write = out;
    for(i = 0; i < size; i++) {
        unsigned char r = *read++;
        unsigned char g = *read++;
        unsigned char b = *read++;
        unsigned char c, m, y, k, tmp;
        c = 255 - r;
        m = 255 - g;
        y = 255 - b;
	if (c < m)
	  k = ((c) > (y)?(y):(c));
	else
          k = ((m) > (y)?(y):(m));
        *write++ = c - k;
        *write++ = m - k;
        *write++ = y - k;
        *write++ = k;
    }
}