Split up the three if conditions on the switch and state value into
three separate ifs. This is because p2c seems to generate incorrect
code id just the one if is used (???).