If you have a Simulink® Coder™ or Embedded Coder® license, you can generate C or C++ code from models that include Stateflow® blocks. The following table directs you to code generation information based on your goals.
See the Following Information in the Simulink Coder documentation
Generate C/C++ source code
You cannot generate code only for the Stateflow blocks in a library model. You must first create a link to the library block in your main model and then generate code for the main model.
Generate C/C++ source code and build executable
Optimize generated code
Include custom code
Include custom code only for library charts in a portable, self-contained library for use in multiple models