MATLAB: Do conditional statements get optimized out in the code generated by Embedded Coder

Embedded Coderif elsemin/maxoptimizationoptimizeusespecifiedminmax

I have a MATLAB Function Block in my model. From the body of a sub-function in that MATLAB Function Block, an entire else-branch is missing in the C code. Why would Embedded Coder apply optimization to my if-else statement?
if( (my_var >= uint16(0)) && (my_var <= uint16(100)) )
%code here
else
%code here - completely missing in C code
end

Best Answer

This is an expected optimization performed by Embedded Coder. For example, the code could be written such that "my_var" can never be outside the range [0, 100], and so Embedded Coder optimized it out.
Another possible reason could be the Optimize using the specified minimum and maximum values (UseSpecifiedMinMax) setting. The if-statement does a range check on "my_var", which is why it could be that Embedded Coder is doing the min/max optimization. There are a few different places a user could be setting the min/max values:
1) On the root inport:
2) In the Ports and Data Manager of the MATLAB Function Block:
3) In a Simulink.Signal object mapped to that input signal: