Dang, though the question is mute, maybe using static volatile for a and b will avoid the compiler optimizations;
static uint64_t cnt = 0;
static volatile uint64_t a, b;
void check(uint64_t x, uint64_t y) {
if (x != y) {
Serial.printf("ERROR %llx %llx cnt = %lld\n", x, y, cnt);
}
}...