// -- Some adjustments for didactic reasons ---------- typedef unsigned long uint64_t; // ok on theseus int putchar ( int character ); // --------------------------------------------------- void bubblesort(char *A, uint64_t n) { uint64_t swapped; uint64_t i; char tmp; bubblesort_do: swapped = 0; i = 1; bubblesort_for: if (i >= n) goto bubblesort_endfor; if (A[i-1] <= A[i]) goto bubblesort_endif; tmp = A[i]; A[i] = A[i-1]; A[i-1] = tmp; swapped = 1; bubblesort_endif: i = i + 1; goto bubblesort_for; n = n - 1; bubblesort_endfor: if (swapped) goto bubblesort_do; } void puts(char *str) { while (*str) { putchar(*str++); } putchar('\n'); } uint64_t strlen(char *str) { char *ch = str; while (*ch) { ++ch; } return ch - str; } char msg[] = "hello, world!"; int main() { puts(msg); bubblesort(msg, strlen(msg)); puts(msg); }