// A program that knows nothing of the tracer: a global array sorted by // swaps. Hooked at `swap` and watched at `numbers` from outside, each moment // of its recording is the array one swap later. #include int numbers[16] = {9, 3, 14, 0, 7, 12, 5, 1, 15, 8, 2, 11, 6, 13, 4, 10}; __attribute__((noinline)) void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; } int main(void) { int n = sizeof numbers / sizeof *numbers; for (int i = 0; i < n; i++) for (int j = 0; j + 1 < n - i; j++) if (numbers[j] > numbers[j + 1]) swap(&numbers[j], &numbers[j + 1]); for (int i = 0; i < n; i++) printf("%d ", numbers[i]); printf("\n"); return 0; }