A software analysis framework built around the QBE intermediate language
git clone https://git.8pit.net/quebex.git
1// SPDX-FileCopyrightText: 2021 Gabriel Fioravante 2// SPDX-FileCopyrightText: 2025 Sören Tempel <soeren+git@soeren-tempel.net> 3// 4// SPDX-License-Identifier: GPL-3.0-only 5 6// Taken from: https://github.com/TheAlgorithms/C/blob/f241de90e1691dc7cfcafcbecd89ef12db922e6b/sorting/bubble_sort_2.c 7 8#include <stddef.h> 9#include <stdbool.h>10#include <assert.h>1112#define MAX 61314extern void quebex_symbolic_array(void *, size_t, size_t, const char *);1516void bubble_sort(int* array_sort)17{18 bool is_sorted = false;1920 /* keep iterating over entire array21 * and swaping elements out of order22 * until it is sorted */23 while (!is_sorted)24 {25 is_sorted = true;2627 /* iterate over all elements */28 for (int i = 0; i < MAX - 1; i++)29 {30 /* check if adjacent elements are out of order */31 if (array_sort[i] > array_sort[i + 1])32 {33 /* swap elements */34 int change_place = array_sort[i];35 array_sort[i] = array_sort[i + 1];36 array_sort[i + 1] = change_place;37 /* elements out of order were found38 * so we reset the flag to keep ordering39 * until no swap operations are executed */40 is_sorted = false;41 }42 }43 }44}4546int47main(void)48{49 int array[MAX];5051 quebex_symbolic_array(array, MAX, sizeof(int), "array");52 bubble_sort(array);5354 return 0;55}