// Sort a list of 10 integers // The compiler does not use all the instructions when exporting code // but this does test the cache. int list[10]; void swap(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; } void quickSort(int start, int end) { int lower; int upper; lower = start + 1; upper = end; swap(&list[start], list + (start + end) / 2); while (lower <= upper) { while (list[lower] < list[start]) { lower = lower + 1; } while (list[start] < list[upper]) { upper = upper - 1; } if (lower < upper) { swap(list + lower, list + upper); lower = lower + 1; upper = upper + 1; } else { lower = lower + 1; } } swap(list + upper, list + start); if (start < upper - 1) { quickSort(start, upper - 1); } if (upper + 1 < end) { quickSort(upper + 1, end); } } void main() { int length; int i; list[0] = 5; list[1] = -2; list[2] = -6; list[3] = 8; list[4] = -4; list[5] = -2; list[6] = 12; list[7] = -12; list[8] = -3; list[9] = 11; length = 10; if (length >= 2) { int max; max = 0; //put the largest element at the end of the array for (i = 1; i < length; i = i + 1) { if (list[max] < list[i]) { max = i; } } swap(list + length - 1, list + max); quickSort(0, length - 2); } }