[Side-Effect] Bug in transforming if-else
For the following 2 code:
void combine1(int a, int b, int c) {
printf("a=%d, b=%d, c=%d, ", a, b, c);
if ((pass(a) && pass(b)) || pass(c)) {
printf("(a && b) || c\n");
return;
} else {
printf("!((a && b) || c)\n");
return;
}
}
void combine2(int a, int b, int c) {
printf("a=%d, b=%d, c=%d, ", a, b, c);
if ((pass(a) && pass(b)) || pass(c)) {
printf("(a || b) && c\n");
return;
} else {
printf("!((a || b) && c)\n");
return;
}
}
The code after side-effect produce wrong transformation at cases
a=0, b=1, c=1, !((a && b) || c) // X
a=0, b=1, c=1, !((a || b) && c) // X
a=0, b=0, c=1, !((a || b) && c) // X