Simulating a PLC ladder diagram on arduino

Ladder still rocks and is a powerful tool for process control and machine control.

Absolutely, ladder logic is a very easy to use yet powerful tool for solving many problems.
However it is not a good idea to devise a solution to your problem in ladder logic and then implement it in C/C++, which is what ash901226 seems to be trying to do.

If your solution is in ladder then implement it in ladder, not C or C++.
Likewise if your solution is devised in C/C++ implement it in C/C++, don't tie yourself in knots trying to convert to ladder.