[Side-Effect] Separating if conditions will result in segfault
int do_ptr(int a, int *b) {
if (pass(a)
&& (!b || *b != NULL)
)
return 0
else
return 1;
}
Transform into
int do_ptr(int a, int *b) {
{
int temp_1 = pass(a);
int temp_2 = !b;
int temp_3 = *b;
if (temp_1 && (temp_2 || temp_3 != ((void *)0))) {
return 0;
} else {
return 1;
}
}
}
temp_3 should not be executed if !temp_2. will result in segfault