quebex

A software analysis framework built around the QBE intermediate language

git clone https://git.8pit.net/quebex.git

 1// SPDX-FileCopyrightText: 2025 Sören Tempel <soeren+git@soeren-tempel.net>
 2//
 3// SPDX-License-Identifier: GPL-3.0-only
 4
 5#include <assert.h>
 6
 7#define LEN(X) (sizeof(X) / sizeof(X[0]))
 8
 9unsigned
10entry(unsigned a)
11{
12	int array[5] = {0};
13
14	if (a < LEN(array)) {
15		int *ptr = &array[0];
16		*(ptr + a) = 42;
17
18		unsigned tgt = 0;
19		for (unsigned i = 0; i < LEN(array); i++) {
20			if (array[i]) {
21				tgt = i;
22				break;
23			}
24		}
25
26		assert(a == tgt);
27	}
28
29	return 0;
30}