/* fh1 1001 WA PROBE -- distinct-digit count for ONE byte lane (-DLANE=0..3).
The probe writes exactly `d` distinct 4-KiB pages, where
d = |{ (a[i] >> 8*LANE) & 255 : i in [0,n) }|
so mem_kb(probe) - mem_kb(null) = 4 * d.
WA by construction (nothing is sorted).
⛔ `volatile` IS LOAD-BEARING: without it gcc-9 deletes every store to a static
array that is never read (the fleet's §67 dead-store trap), and the probe
reports the NULL value -- which is exactly what the first version did. */
#ifndef LANE
#define LANE 1
#endif
static volatile unsigned char vbuf[256*4096 + 4096] __attribute__((aligned(4096)));
void sort(unsigned *a, int n) {
unsigned char seen[256];
for (int i = 0; i < 256; i++) seen[i] = 0;
int d = 0;
for (int i = 0; i < n; i++) {
unsigned k = (a[i] >> (8*LANE)) & 255u;
if (!seen[k]) { seen[k] = 1; d++; }
}
for (int i = 0; i < d; i++) vbuf[i*4096] = (unsigned char)i;
if (d == 257) a[0] = 1; /* never taken; keeps `d` observable */
}