Let me try in whatever way I could understand.
enum state {S1, S2, S3, S4};
enum event {E1, E2, E3, E4, E5, E6, E7, E8};
Now lets assume funcE1 is the function for the event E1, funcE2 is for the E2 and so on. And also assume a func for the error condition Like S1-->S3 which does not exist as funcErr
So S1 State Machine
StateS1[State] = {
funcErr,
funcE1,
funcErr,
funcE5 }
S2 State Machine
StateS2[State] = {
funcE8,
funcE2,
funcErr,
funcErr }
And rest is so on. Remember all are function pointer so say you are in state S1 and move to say state Sx then just call StateS1" target="_blank">Sx
This is the design not the C code so you need to do the remaining talk of coding it. Comment if have any question -