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