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 <stdbool.h> 9#include <assert.h>1011#define MAX 41213void bubble_sort(int* array_sort)14{15 bool is_sorted = false;1617 /* keep iterating over entire array18 * and swaping elements out of order19 * until it is sorted */20 while (!is_sorted)21 {22 is_sorted = true;2324 /* iterate over all elements */25 for (int i = 0; i < MAX - 1; i++)26 {27 /* check if adjacent elements are out of order */28 if (array_sort[i] > array_sort[i + 1])29 {30 /* swap elements */31 int change_place = array_sort[i];32 array_sort[i] = array_sort[i + 1];33 array_sort[i + 1] = change_place;34 /* elements out of order were found35 * so we reset the flag to keep ordering36 * until no swap operations are executed */37 is_sorted = false;38 }39 }40 }41}4243unsigned entry(int a, int b, int c, int d)44{45 int array[MAX];4647 array[0] = a;48 array[1] = b;49 array[2] = c;50 array[3] = d;5152 bubble_sort(array);53 return 0;54}