User`s guide

Writing Wrapper S-Functions
4-9
Wrapper S-functions are useful when creating new algorithms that are
procedural in nature or when integrating legacy code into Simulink. However,
if you want to create code that is
interpretive in nature in Simulink (i.e., highly-parameterized by operating
modes)
heavily optimized in the Real-Time Workshop (i.e., no extra tests to decide
what mode the code is operating in)
then you must create a fully inlined TLC file foryourS-function.