1 /* Simple test program: bubble sort of a fixed table. */
2 /* This demonstrates some of the compiler's common-subexpression*/
3 /* elimination capabilities. For example, inspect the code */
4 /* generated for procedure Sort_array. See the Programmer's */
5 /* Guide for how to request an assembly listing on your host. */
7 typedef unsigned char boolean;
15 for (L = 0; L < 1000; L++) {
16 /* Initialize the table that will be sorted. */
18 for (I = 9; I >= 0; I--)
19 for (J = I*10; J < (I+1)*10; J++)
20 Tab[K++] = J&1 ? J+1 : J-1;
23 Sort_array(Tab,99); /* Sort it. */
29 void Sort_array(Tab,Last) int Tab[]; int Last; {
34 for (I = 0; I<Last; I++)
35 if (Tab[I] > Tab[I+1]) {
48 /*printf("\nArray Contents:\n");*/
49 for (I=0; I<=9; I++) {
50 /*printf("%5d:",10*I); */
51 for (J=0; J<=9; J++); /*printf("%5d",Tab[10*I+J]); */