#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
typedef uint8_t(* issue_t)(const uint32_t, const uint8_t, const uint8_t);
uint8_t issue(const uint32_t c, const uint8_t a, const uint8_t b) {
if(c) {
return a;
}
else {
return b;
}
}
int main(int argc, char *argv[]) {
uint32_t a = 2, b = 5, c = 0;
// c is our secret value, we read its content from the environment so the
// compiler cannot play tricks on us by inlining
if (argc >= 2) {
c = (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("%d\n", func(c, a, b));
return 0;
}
See the compilation results with different optimization levels on GodBolt.