Use symbolic names instead of magic values for the position parameter of get_irn_n().
[libfirm] / ir / be / test / duffs.c
1 const char *str = "12345678901234567890";
2
3 char str1[20], str2[20], str3[20];
4
5 char *duff_copy(char *dst, const char *from, int count)
6 {
7   int n = (count+7)/8;
8   char *to = dst;
9
10   switch (count % 8){
11           do {
12   case 0:     *to++ = *from++;
13   case 7:     *to++ = *from++;
14   case 6:     *to++ = *from++;
15   case 5:     *to++ = *from++;
16   case 4:     *to++ = *from++;
17   case 3:     *to++ = *from++;
18   case 2:     *to++ = *from++;
19   case 1:     *to++ = *from++;
20           }while(--n > 0);
21   }
22   return dst;
23 }
24
25 int main(int argc, char *argv[])
26 {
27   printf("duff's Device 15 : %s\n", duff_copy(str1, str, 15));
28   printf("duff's Device  3 : %s\n", duff_copy(str2, str, 3));
29   printf("duff's Device  8 : %s\n", duff_copy(str2, str, 8));
30
31   return 0;
32 }