#define
is an instruction to the preprocessor to literally replace each occurrence of the macro with its expansion. So the relevant lines in your code will pass to the compiler as:
b1 = a1++ * a1++;
b2 = ++a2 * ++a2;
As Seva states, these expressions are officially undefined; but even if we take what is arguably the most sensible reading you'll still get b1 = 2 * 3;
and b2 = 3 * 4;
(with both a1
and a2
set to 4 after the lines.