Optimization kills the switch statement that I need to use in a function
The switch statements gets killed because it gets optimized to lugar = (lugar &gt; 0) &amp;&amp; (lugar &lt; 7) ? lugar + 1 : 25.
If lugar is smaller than 8 and not equal to 0 you always do +1 otherwise it's equal to 25. Your code only needs an if statement. Hence only 2 options remain in the optimized code.