1 void copy0 (char *to
, char* from
, int count
)
10 case 3: *to
= *from
++;
11 case 2: *to
= *from
++;
12 case 1: *to
= *from
++;
16 void copy1 (char *to
, char *from
, int count
)
20 case 0: do {*to
= *from
++;
21 case 7: *to
= *from
++;
22 case 6: *to
= *from
++;
23 case 5: *to
= *from
++;
24 case 4: *to
= *from
++;
25 case 3: *to
= *from
++;
26 case 2: *to
= *from
++;
27 case 1: *to
= *from
++;
32 void copy2 (char *to
, char* from
, int count
)
35 switch (count
%8) while (n
-->0) {
36 case 0: *to
= *from
++;
37 case 7: *to
= *from
++;
38 case 6: *to
= *from
++;
39 case 5: *to
= *from
++;
40 case 4: *to
= *from
++;
41 case 3: *to
= *from
++;
42 case 2: *to
= *from
++;
43 case 1: *to
= *from
++;
47 void copy3 (char *to
, char *from
, int count
)
51 case 0: while (n
-->0) {*to
= *from
++;
52 case 7: *to
= *from
++;
53 case 6: *to
= *from
++;
54 case 5: *to
= *from
++;
55 case 4: *to
= *from
++;
56 case 3: *to
= *from
++;
57 case 2: *to
= *from
++;
58 case 1: *to
= *from
++;
63 void copy4 (char *to
, char* from
, int count
)
65 int n
= (count
+7)/8, i
;
66 switch (count
%8) for (i
=0; i
<n
; i
++) {
67 case 0: *to
= *from
++;
68 case 7: *to
= *from
++;
69 case 6: *to
= *from
++;
70 case 5: *to
= *from
++;
71 case 4: *to
= *from
++;
72 case 3: *to
= *from
++;
73 case 2: *to
= *from
++;
74 case 1: *to
= *from
++;
78 void copy5 (char *to
, char *from
, int count
)
80 int n
= (count
+7)/8, i
;
82 case 0: for (i
=0; i
<n
; i
++) {*to
= *from
++;
83 case 7: *to
= *from
++;
84 case 6: *to
= *from
++;
85 case 5: *to
= *from
++;
86 case 4: *to
= *from
++;
87 case 3: *to
= *from
++;
88 case 2: *to
= *from
++;
89 case 1: *to
= *from
++;
94 /* The semantics of func{0,1,2} () are the same:
95 * if (foo%2 == 0), func(foo) returns 2;
96 * if (foo%2 == 1), func(foo) returns 13 -- the initialization of the loop
97 * is skipped, thus the loop behaves as if started from -11. */
101 int bar
= 0, i
= -11;
117 int bar
= 0, i
= -11;
133 int bar
= 0, i
= -11;
150 if (func0 (7) != func1 (11))
152 if (func0 (4) != func2 (8))
154 if (func1 (6) != func2 (2))
160 /* The following two routines aren't true Duff's device implementations, but,
161 * inspired by it, test the imbrication of switch with if/else block. */