// Quicksort benchmark - sorting algorithm
#include <stdio.h>
#include <stdlib.h>

void quicksort(int* arr, int low, int high) {
    if (low < high) {
        int pivot = arr[high];
        int i = low - 1;
        for (int j = low; j < high; j++) {
            if (arr[j] < pivot) {
                i++;
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
        int temp = arr[i + 1];
        arr[i + 1] = arr[high];
        arr[high] = temp;
        int pi = i + 1;
        quicksort(arr, low, pi - 1);
        quicksort(arr, pi + 1, high);
    }
}

int main() {
    int n = 1000;
    int* nums = malloc(n * sizeof(int));
    for (int i = 0; i < n; i++) {
        nums[i] = (i * 7 + 13) % 1000;
    }
    quicksort(nums, 0, n - 1);
    printf("Sorted %d elements\n", n);
    free(nums);
    return 0;
}
