1 typedef unsigned char uchar;
 2 typedef unsigned int  uint;
 3 
 4 void Foo (uchar num, uint idata *x);
 5 void Solve (uint idata *x);
 6 void Count (uchar u, uint idata *x);
 7 uchar Ones (uint x);
 8 
 9 void main (void)
10 {
11    uint idata x = 0xf0f0;
12    Foo (6, &x);
13    Solve (&x);
14 }
15 
16 void Foo (uchar num, uint idata *x)
17 {
18    Count (num + 3, x);
19 }
20 
21 void Count (uchar u, uint idata *x)
22 {
23    for (; u != 0; u--)
24    {  *x = *x ^ (uint) u;
25    }
26 }
27 
28 void Solve (uint idata *x)
29 {
30    uchar i, k;
31    for (i = 0; i < 8; i++)
32    {
33       k = Ones (*x);
34       if (k == 0) break;
35       Count (k, x);
36    }
37 }
38 
39 uchar Ones (uint x)
40 {
41    uchar v = 0;
42    while (x)
43    {
44       if (x & 1) v ++;
45       x >>= 1;
46    }
47    return v;
48 }