1// SPDX-FileCopyrightText: 2017-2020 TheAlgorithms and contributors2// SPDX-FileCopyrightText: 2025 Sören Tempel <soeren+git@soeren-tempel.net>3//4// SPDX-License-Identifier: GPL-3.0-only56#include <stddef.h>78// Taken from: https://github.com/TheAlgorithms/C/blob/10d006c3b10340b901860e4810d2122b10e35b76/sorting/insertion_sort.c910extern void quebex_symbolic_array(void *, size_t, size_t, const char *);1112#define MAX 71314void insertionSort(unsigned char *arr, int size)15{16 for (int i = 1; i < size; i++)17 {18 int j = i - 1;19 unsigned char key = arr[i];20 /* Move all elements greater than key to one position */21 while (j >= 0 && key < arr[j])22 {23 arr[j + 1] = arr[j];24 j = j - 1;25 }26 /* Find a correct position for key */27 arr[j + 1] = key;28 }29}3031int32main(void)33{34 unsigned char array[MAX];3536 quebex_symbolic_array(array, MAX, sizeof(unsigned char), "array");37 insertionSort(array, MAX);3839 return 0;40}