Regime switching in C