#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
typedef uint32_t (* issue_t)(const uint32_t);
uint32_t issue(const uint32_t a) {
uint32_t b = 0;
srand(a);
while(1) {
b = rand();
if(b > 255) break;
}
return b;
}
int main(int argc, char * argv[]) {
uint32_t a = 0;
// a is our secret value, we read its content from the environment so the
// compiler cannot play tricks on us by inlining
if (argc >= 2) {
a = (uint32_t) strtol(argv[1], NULL, 16);
}
else {
fprintf(stderr, "USAGE: %s hex_value\n", argv[0]);
return 1;
}
// declarations and markup here
volatile issue_t func = issue;
printf("%u\n", func(a));
return 0;
}
See the compilation results with different optimization levels on GodBolt.