/* Include files */

#include <stddef.h>
#include "blas.h"
#include "main_sfun.h"
#include "c3_main.h"
#define CHARTINSTANCE_CHARTNUMBER      (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER   (chartInstance->instanceNumber)
#include "main_sfun_debug_macros.h"
#define _SF_MEX_LISTEN_FOR_CTRL_C(S)   sf_mex_listen_for_ctrl_c(sfGlobalDebugInstanceStruct,S);

/* Type Definitions */

/* Named Constants */
#define CALL_EVENT                     (-1)
#define c3_IN_NO_ACTIVE_CHILD          ((uint8_T)0U)
#define c3_IN_LEAL_28                  ((uint8_T)1U)
#define c3_IN_LEVC_30                  ((uint8_T)2U)
#define c3_IN_TAKE_OFF_12              ((uint8_T)3U)

/* Variable Declarations */

/* Variable Definitions */
static real_T _sfTime_;
static const char * c3_debug_family_names[2] = { "nargin", "nargout" };

static const char * c3_b_debug_family_names[2] = { "nargin", "nargout" };

static const char * c3_c_debug_family_names[2] = { "nargin", "nargout" };

static const char * c3_d_debug_family_names[3] = { "nargin", "nargout",
  "sf_internal_predicateOutput" };

static const char * c3_e_debug_family_names[3] = { "nargin", "nargout",
  "sf_internal_predicateOutput" };

static const char * c3_f_debug_family_names[3] = { "nargin", "nargout",
  "sf_internal_predicateOutput" };

static const char * c3_g_debug_family_names[3] = { "nargin", "nargout",
  "sf_internal_predicateOutput" };

static const char * c3_h_debug_family_names[3] = { "nargin", "nargout",
  "sf_internal_predicateOutput" };

static const char * c3_i_debug_family_names[3] = { "nargin", "nargout",
  "sf_internal_predicateOutput" };

static boolean_T c3_dataWrittenToVector[9];

/* Function Declarations */
static void initialize_c3_main(SFc3_mainInstanceStruct *chartInstance);
static void initialize_params_c3_main(SFc3_mainInstanceStruct *chartInstance);
static void enable_c3_main(SFc3_mainInstanceStruct *chartInstance);
static void disable_c3_main(SFc3_mainInstanceStruct *chartInstance);
static void c3_update_debugger_state_c3_main(SFc3_mainInstanceStruct
  *chartInstance);
static const mxArray *get_sim_state_c3_main(SFc3_mainInstanceStruct
  *chartInstance);
static void set_sim_state_c3_main(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_st);
static void c3_set_sim_state_side_effects_c3_main(SFc3_mainInstanceStruct
  *chartInstance);
static void finalize_c3_main(SFc3_mainInstanceStruct *chartInstance);
static void sf_gateway_c3_main(SFc3_mainInstanceStruct *chartInstance);
static void c3_enter_internal_c3_main(SFc3_mainInstanceStruct *chartInstance);
static void initSimStructsc3_main(SFc3_mainInstanceStruct *chartInstance);
static void init_script_number_translation(uint32_T c3_machineNumber, uint32_T
  c3_chartNumber, uint32_T c3_instanceNumber);
static const mxArray *c3_sf_marshallOut(void *chartInstanceVoid, void *c3_inData);
static real_T c3_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId);
static void c3_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData);
static const mxArray *c3_b_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData);
static boolean_T c3_b_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId);
static void c3_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData);
static const mxArray *c3_c_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData);
static int32_T c3_c_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId);
static void c3_c_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData);
static const mxArray *c3_d_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData);
static uint8_T c3_d_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_b_tp_TAKE_OFF_12, const char_T *c3_identifier);
static uint8_T c3_e_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId);
static void c3_d_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData);
static const mxArray *c3_e_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData);
static void c3_f_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_n, const char_T *c3_identifier, real_T c3_y[12]);
static void c3_g_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId, real_T c3_y[12]);
static void c3_e_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData);
static const mxArray *c3_h_emlrt_marshallIn(SFc3_mainInstanceStruct
  *chartInstance, const mxArray *c3_b_setSimStateSideEffectsInfo, const char_T
  *c3_identifier);
static const mxArray *c3_i_emlrt_marshallIn(SFc3_mainInstanceStruct
  *chartInstance, const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId);
static void c3_updateDataWrittenToVector(SFc3_mainInstanceStruct *chartInstance,
  uint32_T c3_vectorIndex);
static void init_dsm_address_info(SFc3_mainInstanceStruct *chartInstance);

/* Function Definitions */
static void initialize_c3_main(SFc3_mainInstanceStruct *chartInstance)
{
  chartInstance->c3_sfEvent = CALL_EVENT;
  _sfTime_ = sf_get_time(chartInstance->S);
  chartInstance->c3_doSetSimStateSideEffects = 0U;
  chartInstance->c3_setSimStateSideEffectsInfo = NULL;
  chartInstance->c3_tp_LEAL_28 = 0U;
  chartInstance->c3_tp_LEVC_30 = 0U;
  chartInstance->c3_tp_TAKE_OFF_12 = 0U;
  chartInstance->c3_is_active_c3_main = 0U;
  chartInstance->c3_is_c3_main = c3_IN_NO_ACTIVE_CHILD;
}

static void initialize_params_c3_main(SFc3_mainInstanceStruct *chartInstance)
{
  (void)chartInstance;
}

static void enable_c3_main(SFc3_mainInstanceStruct *chartInstance)
{
  _sfTime_ = sf_get_time(chartInstance->S);
}

static void disable_c3_main(SFc3_mainInstanceStruct *chartInstance)
{
  _sfTime_ = sf_get_time(chartInstance->S);
}

static void c3_update_debugger_state_c3_main(SFc3_mainInstanceStruct
  *chartInstance)
{
  uint32_T c3_prevAniVal;
  c3_prevAniVal = _SFD_GET_ANIMATION();
  _SFD_SET_ANIMATION(0U);
  _SFD_SET_HONOR_BREAKPOINTS(0U);
  if (chartInstance->c3_is_active_c3_main == 1U) {
    _SFD_CC_CALL(CHART_ACTIVE_TAG, 2U, chartInstance->c3_sfEvent);
  }

  if (chartInstance->c3_is_c3_main == c3_IN_TAKE_OFF_12) {
    _SFD_CS_CALL(STATE_ACTIVE_TAG, 2U, chartInstance->c3_sfEvent);
  } else {
    _SFD_CS_CALL(STATE_INACTIVE_TAG, 2U, chartInstance->c3_sfEvent);
  }

  if (chartInstance->c3_is_c3_main == c3_IN_LEVC_30) {
    _SFD_CS_CALL(STATE_ACTIVE_TAG, 1U, chartInstance->c3_sfEvent);
  } else {
    _SFD_CS_CALL(STATE_INACTIVE_TAG, 1U, chartInstance->c3_sfEvent);
  }

  if (chartInstance->c3_is_c3_main == c3_IN_LEAL_28) {
    _SFD_CS_CALL(STATE_ACTIVE_TAG, 0U, chartInstance->c3_sfEvent);
  } else {
    _SFD_CS_CALL(STATE_INACTIVE_TAG, 0U, chartInstance->c3_sfEvent);
  }

  _SFD_SET_ANIMATION(c3_prevAniVal);
  _SFD_SET_HONOR_BREAKPOINTS(1U);
  _SFD_ANIMATE();
}

static const mxArray *get_sim_state_c3_main(SFc3_mainInstanceStruct
  *chartInstance)
{
  const mxArray *c3_st;
  const mxArray *c3_y = NULL;
  int32_T c3_i0;
  real_T c3_u[12];
  const mxArray *c3_b_y = NULL;
  int32_T c3_i1;
  real_T c3_b_u[12];
  const mxArray *c3_c_y = NULL;
  int32_T c3_i2;
  real_T c3_c_u[12];
  const mxArray *c3_d_y = NULL;
  int32_T c3_i3;
  real_T c3_d_u[12];
  const mxArray *c3_e_y = NULL;
  int32_T c3_i4;
  real_T c3_e_u[12];
  const mxArray *c3_f_y = NULL;
  int32_T c3_i5;
  real_T c3_f_u[12];
  const mxArray *c3_g_y = NULL;
  int32_T c3_i6;
  real_T c3_g_u[12];
  const mxArray *c3_h_y = NULL;
  int32_T c3_i7;
  real_T c3_h_u[12];
  const mxArray *c3_i_y = NULL;
  int32_T c3_i8;
  real_T c3_i_u[12];
  const mxArray *c3_j_y = NULL;
  uint8_T c3_hoistedGlobal;
  uint8_T c3_j_u;
  const mxArray *c3_k_y = NULL;
  uint8_T c3_b_hoistedGlobal;
  uint8_T c3_k_u;
  const mxArray *c3_l_y = NULL;
  real_T (*c3_ok)[12];
  real_T (*c3_n)[12];
  real_T (*c3_lon)[12];
  real_T (*c3_lat)[12];
  real_T (*c3_dc)[12];
  real_T (*c3_alt)[12];
  real_T (*c3_Speed)[12];
  real_T (*c3_Rlon)[12];
  real_T (*c3_Rlat)[12];
  c3_dc = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 9);
  c3_Rlon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 8);
  c3_Rlat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 7);
  c3_ok = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 6);
  c3_Speed = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 5);
  c3_alt = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 4);
  c3_lon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 3);
  c3_lat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 2);
  c3_n = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 1);
  c3_st = NULL;
  c3_st = NULL;
  c3_y = NULL;
  sf_mex_assign(&c3_y, sf_mex_createcellmatrix(11, 1), false);
  for (c3_i0 = 0; c3_i0 < 12; c3_i0++) {
    c3_u[c3_i0] = (*c3_Rlat)[c3_i0];
  }

  c3_b_y = NULL;
  sf_mex_assign(&c3_b_y, sf_mex_create("y", c3_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 0, c3_b_y);
  for (c3_i1 = 0; c3_i1 < 12; c3_i1++) {
    c3_b_u[c3_i1] = (*c3_Rlon)[c3_i1];
  }

  c3_c_y = NULL;
  sf_mex_assign(&c3_c_y, sf_mex_create("y", c3_b_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 1, c3_c_y);
  for (c3_i2 = 0; c3_i2 < 12; c3_i2++) {
    c3_c_u[c3_i2] = (*c3_Speed)[c3_i2];
  }

  c3_d_y = NULL;
  sf_mex_assign(&c3_d_y, sf_mex_create("y", c3_c_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 2, c3_d_y);
  for (c3_i3 = 0; c3_i3 < 12; c3_i3++) {
    c3_d_u[c3_i3] = (*c3_alt)[c3_i3];
  }

  c3_e_y = NULL;
  sf_mex_assign(&c3_e_y, sf_mex_create("y", c3_d_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 3, c3_e_y);
  for (c3_i4 = 0; c3_i4 < 12; c3_i4++) {
    c3_e_u[c3_i4] = (*c3_dc)[c3_i4];
  }

  c3_f_y = NULL;
  sf_mex_assign(&c3_f_y, sf_mex_create("y", c3_e_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 4, c3_f_y);
  for (c3_i5 = 0; c3_i5 < 12; c3_i5++) {
    c3_f_u[c3_i5] = (*c3_lat)[c3_i5];
  }

  c3_g_y = NULL;
  sf_mex_assign(&c3_g_y, sf_mex_create("y", c3_f_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 5, c3_g_y);
  for (c3_i6 = 0; c3_i6 < 12; c3_i6++) {
    c3_g_u[c3_i6] = (*c3_lon)[c3_i6];
  }

  c3_h_y = NULL;
  sf_mex_assign(&c3_h_y, sf_mex_create("y", c3_g_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 6, c3_h_y);
  for (c3_i7 = 0; c3_i7 < 12; c3_i7++) {
    c3_h_u[c3_i7] = (*c3_n)[c3_i7];
  }

  c3_i_y = NULL;
  sf_mex_assign(&c3_i_y, sf_mex_create("y", c3_h_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 7, c3_i_y);
  for (c3_i8 = 0; c3_i8 < 12; c3_i8++) {
    c3_i_u[c3_i8] = (*c3_ok)[c3_i8];
  }

  c3_j_y = NULL;
  sf_mex_assign(&c3_j_y, sf_mex_create("y", c3_i_u, 0, 0U, 1U, 0U, 2, 1, 12),
                false);
  sf_mex_setcell(c3_y, 8, c3_j_y);
  c3_hoistedGlobal = chartInstance->c3_is_active_c3_main;
  c3_j_u = c3_hoistedGlobal;
  c3_k_y = NULL;
  sf_mex_assign(&c3_k_y, sf_mex_create("y", &c3_j_u, 3, 0U, 0U, 0U, 0), false);
  sf_mex_setcell(c3_y, 9, c3_k_y);
  c3_b_hoistedGlobal = chartInstance->c3_is_c3_main;
  c3_k_u = c3_b_hoistedGlobal;
  c3_l_y = NULL;
  sf_mex_assign(&c3_l_y, sf_mex_create("y", &c3_k_u, 3, 0U, 0U, 0U, 0), false);
  sf_mex_setcell(c3_y, 10, c3_l_y);
  sf_mex_assign(&c3_st, c3_y, false);
  return c3_st;
}

static void set_sim_state_c3_main(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_st)
{
  const mxArray *c3_u;
  real_T c3_dv0[12];
  int32_T c3_i9;
  real_T c3_dv1[12];
  int32_T c3_i10;
  real_T c3_dv2[12];
  int32_T c3_i11;
  real_T c3_dv3[12];
  int32_T c3_i12;
  real_T c3_dv4[12];
  int32_T c3_i13;
  real_T c3_dv5[12];
  int32_T c3_i14;
  real_T c3_dv6[12];
  int32_T c3_i15;
  real_T c3_dv7[12];
  int32_T c3_i16;
  real_T c3_dv8[12];
  int32_T c3_i17;
  real_T (*c3_ok)[12];
  real_T (*c3_n)[12];
  real_T (*c3_lon)[12];
  real_T (*c3_lat)[12];
  real_T (*c3_dc)[12];
  real_T (*c3_alt)[12];
  real_T (*c3_Speed)[12];
  real_T (*c3_Rlon)[12];
  real_T (*c3_Rlat)[12];
  c3_dc = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 9);
  c3_Rlon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 8);
  c3_Rlat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 7);
  c3_ok = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 6);
  c3_Speed = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 5);
  c3_alt = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 4);
  c3_lon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 3);
  c3_lat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 2);
  c3_n = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 1);
  c3_u = sf_mex_dup(c3_st);
  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 0)),
                        "Rlat", c3_dv0);
  for (c3_i9 = 0; c3_i9 < 12; c3_i9++) {
    (*c3_Rlat)[c3_i9] = c3_dv0[c3_i9];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 1)),
                        "Rlon", c3_dv1);
  for (c3_i10 = 0; c3_i10 < 12; c3_i10++) {
    (*c3_Rlon)[c3_i10] = c3_dv1[c3_i10];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 2)),
                        "Speed", c3_dv2);
  for (c3_i11 = 0; c3_i11 < 12; c3_i11++) {
    (*c3_Speed)[c3_i11] = c3_dv2[c3_i11];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 3)),
                        "alt", c3_dv3);
  for (c3_i12 = 0; c3_i12 < 12; c3_i12++) {
    (*c3_alt)[c3_i12] = c3_dv3[c3_i12];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 4)), "dc",
                        c3_dv4);
  for (c3_i13 = 0; c3_i13 < 12; c3_i13++) {
    (*c3_dc)[c3_i13] = c3_dv4[c3_i13];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 5)),
                        "lat", c3_dv5);
  for (c3_i14 = 0; c3_i14 < 12; c3_i14++) {
    (*c3_lat)[c3_i14] = c3_dv5[c3_i14];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 6)),
                        "lon", c3_dv6);
  for (c3_i15 = 0; c3_i15 < 12; c3_i15++) {
    (*c3_lon)[c3_i15] = c3_dv6[c3_i15];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 7)), "n",
                        c3_dv7);
  for (c3_i16 = 0; c3_i16 < 12; c3_i16++) {
    (*c3_n)[c3_i16] = c3_dv7[c3_i16];
  }

  c3_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 8)), "ok",
                        c3_dv8);
  for (c3_i17 = 0; c3_i17 < 12; c3_i17++) {
    (*c3_ok)[c3_i17] = c3_dv8[c3_i17];
  }

  chartInstance->c3_is_active_c3_main = c3_d_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c3_u, 9)), "is_active_c3_main");
  chartInstance->c3_is_c3_main = c3_d_emlrt_marshallIn(chartInstance, sf_mex_dup
    (sf_mex_getcell(c3_u, 10)), "is_c3_main");
  sf_mex_assign(&chartInstance->c3_setSimStateSideEffectsInfo,
                c3_h_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell
    (c3_u, 11)), "setSimStateSideEffectsInfo"), true);
  sf_mex_destroy(&c3_u);
  chartInstance->c3_doSetSimStateSideEffects = 1U;
  c3_update_debugger_state_c3_main(chartInstance);
  sf_mex_destroy(&c3_st);
}

static void c3_set_sim_state_side_effects_c3_main(SFc3_mainInstanceStruct
  *chartInstance)
{
  if (chartInstance->c3_doSetSimStateSideEffects != 0) {
    if (chartInstance->c3_is_c3_main == c3_IN_LEAL_28) {
      chartInstance->c3_tp_LEAL_28 = 1U;
    } else {
      chartInstance->c3_tp_LEAL_28 = 0U;
    }

    if (chartInstance->c3_is_c3_main == c3_IN_LEVC_30) {
      chartInstance->c3_tp_LEVC_30 = 1U;
    } else {
      chartInstance->c3_tp_LEVC_30 = 0U;
    }

    if (chartInstance->c3_is_c3_main == c3_IN_TAKE_OFF_12) {
      chartInstance->c3_tp_TAKE_OFF_12 = 1U;
    } else {
      chartInstance->c3_tp_TAKE_OFF_12 = 0U;
    }

    chartInstance->c3_doSetSimStateSideEffects = 0U;
  }
}

static void finalize_c3_main(SFc3_mainInstanceStruct *chartInstance)
{
  sf_mex_destroy(&chartInstance->c3_setSimStateSideEffectsInfo);
}

static void sf_gateway_c3_main(SFc3_mainInstanceStruct *chartInstance)
{
  int32_T c3_i18;
  int32_T c3_i19;
  int32_T c3_i20;
  int32_T c3_i21;
  int32_T c3_i22;
  int32_T c3_i23;
  int32_T c3_i24;
  int32_T c3_i25;
  int32_T c3_i26;
  real_T *c3_u;
  real_T (*c3_dc)[12];
  real_T (*c3_Rlon)[12];
  real_T (*c3_Rlat)[12];
  real_T (*c3_ok)[12];
  real_T (*c3_Speed)[12];
  real_T (*c3_alt)[12];
  real_T (*c3_lon)[12];
  real_T (*c3_lat)[12];
  real_T (*c3_n)[12];
  c3_dc = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 9);
  c3_Rlon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 8);
  c3_Rlat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 7);
  c3_ok = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 6);
  c3_Speed = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 5);
  c3_alt = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 4);
  c3_lon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 3);
  c3_lat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 2);
  c3_n = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 1);
  c3_u = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
  c3_set_sim_state_side_effects_c3_main(chartInstance);
  _SFD_SYMBOL_SCOPE_PUSH(0U, 0U);
  _sfTime_ = sf_get_time(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 2U, chartInstance->c3_sfEvent);
  _SFD_DATA_RANGE_CHECK(*c3_u, 0U);
  for (c3_i18 = 0; c3_i18 < 12; c3_i18++) {
    _SFD_DATA_RANGE_CHECK((*c3_n)[c3_i18], 1U);
  }

  for (c3_i19 = 0; c3_i19 < 12; c3_i19++) {
    _SFD_DATA_RANGE_CHECK((*c3_lat)[c3_i19], 2U);
  }

  for (c3_i20 = 0; c3_i20 < 12; c3_i20++) {
    _SFD_DATA_RANGE_CHECK((*c3_lon)[c3_i20], 3U);
  }

  for (c3_i21 = 0; c3_i21 < 12; c3_i21++) {
    _SFD_DATA_RANGE_CHECK((*c3_alt)[c3_i21], 4U);
  }

  for (c3_i22 = 0; c3_i22 < 12; c3_i22++) {
    _SFD_DATA_RANGE_CHECK((*c3_Speed)[c3_i22], 5U);
  }

  for (c3_i23 = 0; c3_i23 < 12; c3_i23++) {
    _SFD_DATA_RANGE_CHECK((*c3_ok)[c3_i23], 6U);
  }

  for (c3_i24 = 0; c3_i24 < 12; c3_i24++) {
    _SFD_DATA_RANGE_CHECK((*c3_Rlat)[c3_i24], 7U);
  }

  for (c3_i25 = 0; c3_i25 < 12; c3_i25++) {
    _SFD_DATA_RANGE_CHECK((*c3_Rlon)[c3_i25], 8U);
  }

  for (c3_i26 = 0; c3_i26 < 12; c3_i26++) {
    _SFD_DATA_RANGE_CHECK((*c3_dc)[c3_i26], 9U);
  }

  chartInstance->c3_sfEvent = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 2U, chartInstance->c3_sfEvent);
  if (chartInstance->c3_is_active_c3_main == 0U) {
    _SFD_CC_CALL(CHART_ENTER_ENTRY_FUNCTION_TAG, 2U, chartInstance->c3_sfEvent);
    chartInstance->c3_is_active_c3_main = 1U;
    _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 2U, chartInstance->c3_sfEvent);
    c3_enter_internal_c3_main(chartInstance);
  } else {
    switch (chartInstance->c3_is_c3_main) {
     case c3_IN_LEAL_28:
      CV_CHART_EVAL(2, 0, 1);
      _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG, 0U,
                   chartInstance->c3_sfEvent);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG, 0U, chartInstance->c3_sfEvent);
      break;

     case c3_IN_LEVC_30:
      CV_CHART_EVAL(2, 0, 2);
      _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG, 1U,
                   chartInstance->c3_sfEvent);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG, 1U, chartInstance->c3_sfEvent);
      break;

     case c3_IN_TAKE_OFF_12:
      CV_CHART_EVAL(2, 0, 3);
      _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG, 2U,
                   chartInstance->c3_sfEvent);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG, 2U, chartInstance->c3_sfEvent);
      break;

     default:
      CV_CHART_EVAL(2, 0, 0);
      chartInstance->c3_is_c3_main = c3_IN_NO_ACTIVE_CHILD;
      _SFD_CS_CALL(STATE_INACTIVE_TAG, 0U, chartInstance->c3_sfEvent);
      break;
    }
  }

  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 2U, chartInstance->c3_sfEvent);
  _SFD_SYMBOL_SCOPE_POP();
  _SFD_CHECK_FOR_STATE_INCONSISTENCY(_mainMachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}

static void c3_enter_internal_c3_main(SFc3_mainInstanceStruct *chartInstance)
{
  uint32_T c3_debug_family_var_map[3];
  real_T c3_nargin = 0.0;
  real_T c3_nargout = 1.0;
  boolean_T c3_out;
  uint32_T c3_b_debug_family_var_map[2];
  real_T c3_b_nargin = 0.0;
  real_T c3_b_nargout = 0.0;
  int32_T c3_i27;
  int32_T c3_i28;
  int32_T c3_i29;
  static real_T c3_dv9[12] = { 39.4, 39.40778, 39.44, 39.48478, 39.48614,
    39.48932, 39.49732, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i30;
  int32_T c3_i31;
  static real_T c3_dv10[12] = { -0.18, -0.26806, -0.35222, -0.46968, -0.47327,
    -0.48161, -0.50265, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i32;
  int32_T c3_i33;
  static real_T c3_dv11[12] = { 3700.0, 2500.0, 1500.0, 250.0, 193.0, 180.0,
    170.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i34;
  int32_T c3_i35;
  static real_T c3_dv12[12] = { 130.0, 120.0, 100.0, 90.0, 75.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i36;
  int32_T c3_i37;
  static real_T c3_dv13[12] = { 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
    1.0, 0.0 };

  int32_T c3_i38;
  int32_T c3_i39;
  int32_T c3_i40;
  int32_T c3_i41;
  int32_T c3_i42;
  int32_T c3_i43;
  int32_T c3_i44;
  real_T c3_c_nargin = 0.0;
  real_T c3_c_nargout = 1.0;
  boolean_T c3_b_out;
  real_T c3_d_nargin = 0.0;
  real_T c3_d_nargout = 0.0;
  int32_T c3_i45;
  int32_T c3_i46;
  int32_T c3_i47;
  static real_T c3_dv14[12] = { 39.49732, 39.48359, 39.38263, 39.48556, 38.73833,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i48;
  int32_T c3_i49;
  static real_T c3_dv15[12] = { -0.50265, -0.46661, -0.31513, -0.48333, -0.99861,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i50;
  int32_T c3_i51;
  static real_T c3_dv16[12] = { 270.0, 1500.0, 2000.0, 2000.0, 3000.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i52;
  int32_T c3_i53;
  static real_T c3_dv17[12] = { 120.0, 150.0, 150.0, 150.0, 150.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i54;
  int32_T c3_i55;
  static real_T c3_dv18[12] = { 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0 };

  int32_T c3_i56;
  int32_T c3_i57;
  static real_T c3_dv19[12] = { 0.0, 0.0, 0.0, 39.48556, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0 };

  int32_T c3_i58;
  int32_T c3_i59;
  static real_T c3_dv20[12] = { 0.0, 0.0, 0.0, -0.48333, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0 };

  int32_T c3_i60;
  int32_T c3_i61;
  static real_T c3_dv21[12] = { 0.0, 0.0, 0.0, 11.0, 198.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0 };

  int32_T c3_i62;
  real_T c3_e_nargin = 0.0;
  real_T c3_e_nargout = 1.0;
  boolean_T c3_c_out;
  real_T c3_f_nargin = 0.0;
  real_T c3_f_nargout = 0.0;
  int32_T c3_i63;
  int32_T c3_i64;
  int32_T c3_i65;
  static real_T c3_dv22[12] = { 38.46639, 38.2366, 38.25056, 38.26528, 38.27982,
    38.28038, 38.28309, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i66;
  int32_T c3_i67;
  static real_T c3_dv23[12] = { -0.22917, -0.2911, -0.3325, -0.43806, -0.54132,
    -0.54528, -0.56472, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i68;
  int32_T c3_i69;
  static real_T c3_dv24[12] = { 2500.0, 2500.0, 2500.0, 1700.0, 150.0, 100.0,
    121.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i70;
  int32_T c3_i71;
  static real_T c3_dv25[12] = { 130.0, 130.0, 120.0, 100.0, 100.0, 90.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0 };

  int32_T c3_i72;
  int32_T c3_i73;
  static real_T c3_dv26[12] = { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0,
    0.0, 0.0 };

  int32_T c3_i74;
  int32_T c3_i75;
  static real_T c3_dv27[12] = { 0.0, 38.28611, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0 };

  int32_T c3_i76;
  int32_T c3_i77;
  static real_T c3_dv28[12] = { 0.0, -0.58694, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0 };

  int32_T c3_i78;
  int32_T c3_i79;
  static real_T c3_dv29[12] = { 0.0, 18.0, 98.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0 };

  int32_T c3_i80;
  real_T *c3_u;
  real_T (*c3_dc)[12];
  real_T (*c3_Rlon)[12];
  real_T (*c3_Rlat)[12];
  real_T (*c3_ok)[12];
  real_T (*c3_Speed)[12];
  real_T (*c3_alt)[12];
  real_T (*c3_lon)[12];
  real_T (*c3_lat)[12];
  real_T (*c3_n)[12];
  c3_dc = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 9);
  c3_Rlon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 8);
  c3_Rlat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 7);
  c3_ok = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 6);
  c3_Speed = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 5);
  c3_alt = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 4);
  c3_lon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 3);
  c3_lat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 2);
  c3_n = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 1);
  c3_u = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
  _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 0U, chartInstance->c3_sfEvent);
  _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c3_e_debug_family_names,
    c3_debug_family_var_map);
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_nargin, 0U, c3_sf_marshallOut,
    c3_sf_marshallIn);
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_nargout, 1U, c3_sf_marshallOut,
    c3_sf_marshallIn);
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_out, 2U, c3_b_sf_marshallOut,
    c3_b_sf_marshallIn);
  c3_out = CV_EML_IF(0, 0, 0, *c3_u == 1.0);
  _SFD_SYMBOL_SCOPE_POP();
  if (c3_out) {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 0U, chartInstance->c3_sfEvent);
    chartInstance->c3_is_c3_main = c3_IN_LEVC_30;
    _SFD_CS_CALL(STATE_ACTIVE_TAG, 1U, chartInstance->c3_sfEvent);
    chartInstance->c3_tp_LEVC_30 = 1U;
    _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 2U, 2U, c3_b_debug_family_names,
      c3_b_debug_family_var_map);
    _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_b_nargin, 0U, c3_sf_marshallOut,
      c3_sf_marshallIn);
    _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_b_nargout, 1U, c3_sf_marshallOut,
      c3_sf_marshallIn);
    for (c3_i27 = 0; c3_i27 < 12; c3_i27++) {
      (*c3_n)[c3_i27] = 0.0;
    }

    c3_updateDataWrittenToVector(chartInstance, 0U);
    for (c3_i28 = 0; c3_i28 < 12; c3_i28++) {
      _SFD_DATA_RANGE_CHECK((*c3_n)[c3_i28], 1U);
    }

    for (c3_i29 = 0; c3_i29 < 12; c3_i29++) {
      (*c3_lat)[c3_i29] = c3_dv9[c3_i29];
    }

    c3_updateDataWrittenToVector(chartInstance, 1U);
    for (c3_i30 = 0; c3_i30 < 12; c3_i30++) {
      _SFD_DATA_RANGE_CHECK((*c3_lat)[c3_i30], 2U);
    }

    for (c3_i31 = 0; c3_i31 < 12; c3_i31++) {
      (*c3_lon)[c3_i31] = c3_dv10[c3_i31];
    }

    c3_updateDataWrittenToVector(chartInstance, 2U);
    for (c3_i32 = 0; c3_i32 < 12; c3_i32++) {
      _SFD_DATA_RANGE_CHECK((*c3_lon)[c3_i32], 3U);
    }

    for (c3_i33 = 0; c3_i33 < 12; c3_i33++) {
      (*c3_alt)[c3_i33] = c3_dv11[c3_i33];
    }

    c3_updateDataWrittenToVector(chartInstance, 3U);
    for (c3_i34 = 0; c3_i34 < 12; c3_i34++) {
      _SFD_DATA_RANGE_CHECK((*c3_alt)[c3_i34], 4U);
    }

    for (c3_i35 = 0; c3_i35 < 12; c3_i35++) {
      (*c3_Speed)[c3_i35] = c3_dv12[c3_i35];
    }

    c3_updateDataWrittenToVector(chartInstance, 4U);
    for (c3_i36 = 0; c3_i36 < 12; c3_i36++) {
      _SFD_DATA_RANGE_CHECK((*c3_Speed)[c3_i36], 5U);
    }

    for (c3_i37 = 0; c3_i37 < 12; c3_i37++) {
      (*c3_ok)[c3_i37] = c3_dv13[c3_i37];
    }

    c3_updateDataWrittenToVector(chartInstance, 5U);
    for (c3_i38 = 0; c3_i38 < 12; c3_i38++) {
      _SFD_DATA_RANGE_CHECK((*c3_ok)[c3_i38], 6U);
    }

    for (c3_i39 = 0; c3_i39 < 12; c3_i39++) {
      (*c3_Rlat)[c3_i39] = 0.0;
    }

    c3_updateDataWrittenToVector(chartInstance, 6U);
    for (c3_i40 = 0; c3_i40 < 12; c3_i40++) {
      _SFD_DATA_RANGE_CHECK((*c3_Rlat)[c3_i40], 7U);
    }

    for (c3_i41 = 0; c3_i41 < 12; c3_i41++) {
      (*c3_Rlon)[c3_i41] = 0.0;
    }

    c3_updateDataWrittenToVector(chartInstance, 7U);
    for (c3_i42 = 0; c3_i42 < 12; c3_i42++) {
      _SFD_DATA_RANGE_CHECK((*c3_Rlon)[c3_i42], 8U);
    }

    for (c3_i43 = 0; c3_i43 < 12; c3_i43++) {
      (*c3_dc)[c3_i43] = 0.0;
    }

    c3_updateDataWrittenToVector(chartInstance, 8U);
    for (c3_i44 = 0; c3_i44 < 12; c3_i44++) {
      _SFD_DATA_RANGE_CHECK((*c3_dc)[c3_i44], 9U);
    }

    _SFD_SYMBOL_SCOPE_POP();
  } else {
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 1U, chartInstance->c3_sfEvent);
    _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c3_d_debug_family_names,
      c3_debug_family_var_map);
    _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_c_nargin, 0U, c3_sf_marshallOut,
      c3_sf_marshallIn);
    _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_c_nargout, 1U, c3_sf_marshallOut,
      c3_sf_marshallIn);
    _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_b_out, 2U, c3_b_sf_marshallOut,
      c3_b_sf_marshallIn);
    c3_b_out = CV_EML_IF(1, 0, 0, *c3_u == 11.0);
    _SFD_SYMBOL_SCOPE_POP();
    if (c3_b_out) {
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 1U, chartInstance->c3_sfEvent);
      chartInstance->c3_is_c3_main = c3_IN_TAKE_OFF_12;
      _SFD_CS_CALL(STATE_ACTIVE_TAG, 2U, chartInstance->c3_sfEvent);
      chartInstance->c3_tp_TAKE_OFF_12 = 1U;
      _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 2U, 2U, c3_debug_family_names,
        c3_b_debug_family_var_map);
      _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_d_nargin, 0U, c3_sf_marshallOut,
        c3_sf_marshallIn);
      _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_d_nargout, 1U, c3_sf_marshallOut,
        c3_sf_marshallIn);
      for (c3_i45 = 0; c3_i45 < 12; c3_i45++) {
        (*c3_n)[c3_i45] = 1.0;
      }

      c3_updateDataWrittenToVector(chartInstance, 0U);
      for (c3_i46 = 0; c3_i46 < 12; c3_i46++) {
        _SFD_DATA_RANGE_CHECK((*c3_n)[c3_i46], 1U);
      }

      for (c3_i47 = 0; c3_i47 < 12; c3_i47++) {
        (*c3_lat)[c3_i47] = c3_dv14[c3_i47];
      }

      c3_updateDataWrittenToVector(chartInstance, 1U);
      for (c3_i48 = 0; c3_i48 < 12; c3_i48++) {
        _SFD_DATA_RANGE_CHECK((*c3_lat)[c3_i48], 2U);
      }

      for (c3_i49 = 0; c3_i49 < 12; c3_i49++) {
        (*c3_lon)[c3_i49] = c3_dv15[c3_i49];
      }

      c3_updateDataWrittenToVector(chartInstance, 2U);
      for (c3_i50 = 0; c3_i50 < 12; c3_i50++) {
        _SFD_DATA_RANGE_CHECK((*c3_lon)[c3_i50], 3U);
      }

      for (c3_i51 = 0; c3_i51 < 12; c3_i51++) {
        (*c3_alt)[c3_i51] = c3_dv16[c3_i51];
      }

      c3_updateDataWrittenToVector(chartInstance, 3U);
      for (c3_i52 = 0; c3_i52 < 12; c3_i52++) {
        _SFD_DATA_RANGE_CHECK((*c3_alt)[c3_i52], 4U);
      }

      for (c3_i53 = 0; c3_i53 < 12; c3_i53++) {
        (*c3_Speed)[c3_i53] = c3_dv17[c3_i53];
      }

      c3_updateDataWrittenToVector(chartInstance, 4U);
      for (c3_i54 = 0; c3_i54 < 12; c3_i54++) {
        _SFD_DATA_RANGE_CHECK((*c3_Speed)[c3_i54], 5U);
      }

      for (c3_i55 = 0; c3_i55 < 12; c3_i55++) {
        (*c3_ok)[c3_i55] = c3_dv18[c3_i55];
      }

      c3_updateDataWrittenToVector(chartInstance, 5U);
      for (c3_i56 = 0; c3_i56 < 12; c3_i56++) {
        _SFD_DATA_RANGE_CHECK((*c3_ok)[c3_i56], 6U);
      }

      for (c3_i57 = 0; c3_i57 < 12; c3_i57++) {
        (*c3_Rlat)[c3_i57] = c3_dv19[c3_i57];
      }

      c3_updateDataWrittenToVector(chartInstance, 6U);
      for (c3_i58 = 0; c3_i58 < 12; c3_i58++) {
        _SFD_DATA_RANGE_CHECK((*c3_Rlat)[c3_i58], 7U);
      }

      for (c3_i59 = 0; c3_i59 < 12; c3_i59++) {
        (*c3_Rlon)[c3_i59] = c3_dv20[c3_i59];
      }

      c3_updateDataWrittenToVector(chartInstance, 7U);
      for (c3_i60 = 0; c3_i60 < 12; c3_i60++) {
        _SFD_DATA_RANGE_CHECK((*c3_Rlon)[c3_i60], 8U);
      }

      for (c3_i61 = 0; c3_i61 < 12; c3_i61++) {
        (*c3_dc)[c3_i61] = c3_dv21[c3_i61];
      }

      c3_updateDataWrittenToVector(chartInstance, 8U);
      for (c3_i62 = 0; c3_i62 < 12; c3_i62++) {
        _SFD_DATA_RANGE_CHECK((*c3_dc)[c3_i62], 9U);
      }

      _SFD_SYMBOL_SCOPE_POP();
    } else {
      _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 2U,
                   chartInstance->c3_sfEvent);
      _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c3_f_debug_family_names,
        c3_debug_family_var_map);
      _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_e_nargin, 0U, c3_sf_marshallOut,
        c3_sf_marshallIn);
      _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_e_nargout, 1U, c3_sf_marshallOut,
        c3_sf_marshallIn);
      _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_c_out, 2U, c3_b_sf_marshallOut,
        c3_b_sf_marshallIn);
      c3_c_out = CV_EML_IF(2, 0, 0, *c3_u == 2.0);
      _SFD_SYMBOL_SCOPE_POP();
      if (c3_c_out) {
        _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 2U, chartInstance->c3_sfEvent);
        chartInstance->c3_is_c3_main = c3_IN_LEAL_28;
        _SFD_CS_CALL(STATE_ACTIVE_TAG, 0U, chartInstance->c3_sfEvent);
        chartInstance->c3_tp_LEAL_28 = 1U;
        _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 2U, 2U, c3_c_debug_family_names,
          c3_b_debug_family_var_map);
        _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_f_nargin, 0U, c3_sf_marshallOut,
          c3_sf_marshallIn);
        _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_f_nargout, 1U,
          c3_sf_marshallOut, c3_sf_marshallIn);
        for (c3_i63 = 0; c3_i63 < 12; c3_i63++) {
          (*c3_n)[c3_i63] = 2.0;
        }

        c3_updateDataWrittenToVector(chartInstance, 0U);
        for (c3_i64 = 0; c3_i64 < 12; c3_i64++) {
          _SFD_DATA_RANGE_CHECK((*c3_n)[c3_i64], 1U);
        }

        for (c3_i65 = 0; c3_i65 < 12; c3_i65++) {
          (*c3_lat)[c3_i65] = c3_dv22[c3_i65];
        }

        c3_updateDataWrittenToVector(chartInstance, 1U);
        for (c3_i66 = 0; c3_i66 < 12; c3_i66++) {
          _SFD_DATA_RANGE_CHECK((*c3_lat)[c3_i66], 2U);
        }

        for (c3_i67 = 0; c3_i67 < 12; c3_i67++) {
          (*c3_lon)[c3_i67] = c3_dv23[c3_i67];
        }

        c3_updateDataWrittenToVector(chartInstance, 2U);
        for (c3_i68 = 0; c3_i68 < 12; c3_i68++) {
          _SFD_DATA_RANGE_CHECK((*c3_lon)[c3_i68], 3U);
        }

        for (c3_i69 = 0; c3_i69 < 12; c3_i69++) {
          (*c3_alt)[c3_i69] = c3_dv24[c3_i69];
        }

        c3_updateDataWrittenToVector(chartInstance, 3U);
        for (c3_i70 = 0; c3_i70 < 12; c3_i70++) {
          _SFD_DATA_RANGE_CHECK((*c3_alt)[c3_i70], 4U);
        }

        for (c3_i71 = 0; c3_i71 < 12; c3_i71++) {
          (*c3_Speed)[c3_i71] = c3_dv25[c3_i71];
        }

        c3_updateDataWrittenToVector(chartInstance, 4U);
        for (c3_i72 = 0; c3_i72 < 12; c3_i72++) {
          _SFD_DATA_RANGE_CHECK((*c3_Speed)[c3_i72], 5U);
        }

        for (c3_i73 = 0; c3_i73 < 12; c3_i73++) {
          (*c3_ok)[c3_i73] = c3_dv26[c3_i73];
        }

        c3_updateDataWrittenToVector(chartInstance, 5U);
        for (c3_i74 = 0; c3_i74 < 12; c3_i74++) {
          _SFD_DATA_RANGE_CHECK((*c3_ok)[c3_i74], 6U);
        }

        for (c3_i75 = 0; c3_i75 < 12; c3_i75++) {
          (*c3_Rlat)[c3_i75] = c3_dv27[c3_i75];
        }

        c3_updateDataWrittenToVector(chartInstance, 6U);
        for (c3_i76 = 0; c3_i76 < 12; c3_i76++) {
          _SFD_DATA_RANGE_CHECK((*c3_Rlat)[c3_i76], 7U);
        }

        for (c3_i77 = 0; c3_i77 < 12; c3_i77++) {
          (*c3_Rlon)[c3_i77] = c3_dv28[c3_i77];
        }

        c3_updateDataWrittenToVector(chartInstance, 7U);
        for (c3_i78 = 0; c3_i78 < 12; c3_i78++) {
          _SFD_DATA_RANGE_CHECK((*c3_Rlon)[c3_i78], 8U);
        }

        for (c3_i79 = 0; c3_i79 < 12; c3_i79++) {
          (*c3_dc)[c3_i79] = c3_dv29[c3_i79];
        }

        c3_updateDataWrittenToVector(chartInstance, 8U);
        for (c3_i80 = 0; c3_i80 < 12; c3_i80++) {
          _SFD_DATA_RANGE_CHECK((*c3_dc)[c3_i80], 9U);
        }

        _SFD_SYMBOL_SCOPE_POP();
      }
    }
  }
}

static void initSimStructsc3_main(SFc3_mainInstanceStruct *chartInstance)
{
  (void)chartInstance;
}

static void init_script_number_translation(uint32_T c3_machineNumber, uint32_T
  c3_chartNumber, uint32_T c3_instanceNumber)
{
  (void)c3_machineNumber;
  (void)c3_chartNumber;
  (void)c3_instanceNumber;
}

static const mxArray *c3_sf_marshallOut(void *chartInstanceVoid, void *c3_inData)
{
  const mxArray *c3_mxArrayOutData = NULL;
  real_T c3_u;
  const mxArray *c3_y = NULL;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_mxArrayOutData = NULL;
  c3_u = *(real_T *)c3_inData;
  c3_y = NULL;
  sf_mex_assign(&c3_y, sf_mex_create("y", &c3_u, 0, 0U, 0U, 0U, 0), false);
  sf_mex_assign(&c3_mxArrayOutData, c3_y, false);
  return c3_mxArrayOutData;
}

static real_T c3_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId)
{
  real_T c3_y;
  real_T c3_d0;
  (void)chartInstance;
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), &c3_d0, 1, 0, 0U, 0, 0U, 0);
  c3_y = c3_d0;
  sf_mex_destroy(&c3_u);
  return c3_y;
}

static void c3_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData)
{
  const mxArray *c3_nargout;
  const char_T *c3_identifier;
  emlrtMsgIdentifier c3_thisId;
  real_T c3_y;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_nargout = sf_mex_dup(c3_mxArrayInData);
  c3_identifier = c3_varName;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  c3_y = c3_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_nargout), &c3_thisId);
  sf_mex_destroy(&c3_nargout);
  *(real_T *)c3_outData = c3_y;
  sf_mex_destroy(&c3_mxArrayInData);
}

static const mxArray *c3_b_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData)
{
  const mxArray *c3_mxArrayOutData = NULL;
  boolean_T c3_u;
  const mxArray *c3_y = NULL;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_mxArrayOutData = NULL;
  c3_u = *(boolean_T *)c3_inData;
  c3_y = NULL;
  sf_mex_assign(&c3_y, sf_mex_create("y", &c3_u, 11, 0U, 0U, 0U, 0), false);
  sf_mex_assign(&c3_mxArrayOutData, c3_y, false);
  return c3_mxArrayOutData;
}

static boolean_T c3_b_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId)
{
  boolean_T c3_y;
  boolean_T c3_b0;
  (void)chartInstance;
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), &c3_b0, 1, 11, 0U, 0, 0U, 0);
  c3_y = c3_b0;
  sf_mex_destroy(&c3_u);
  return c3_y;
}

static void c3_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData)
{
  const mxArray *c3_sf_internal_predicateOutput;
  const char_T *c3_identifier;
  emlrtMsgIdentifier c3_thisId;
  boolean_T c3_y;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_sf_internal_predicateOutput = sf_mex_dup(c3_mxArrayInData);
  c3_identifier = c3_varName;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  c3_y = c3_b_emlrt_marshallIn(chartInstance, sf_mex_dup
    (c3_sf_internal_predicateOutput), &c3_thisId);
  sf_mex_destroy(&c3_sf_internal_predicateOutput);
  *(boolean_T *)c3_outData = c3_y;
  sf_mex_destroy(&c3_mxArrayInData);
}

const mxArray *sf_c3_main_get_eml_resolved_functions_info(void)
{
  const mxArray *c3_nameCaptureInfo = NULL;
  c3_nameCaptureInfo = NULL;
  sf_mex_assign(&c3_nameCaptureInfo, sf_mex_create("nameCaptureInfo", NULL, 0,
    0U, 1U, 0U, 2, 0, 1), false);
  return c3_nameCaptureInfo;
}

static const mxArray *c3_c_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData)
{
  const mxArray *c3_mxArrayOutData = NULL;
  int32_T c3_u;
  const mxArray *c3_y = NULL;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_mxArrayOutData = NULL;
  c3_u = *(int32_T *)c3_inData;
  c3_y = NULL;
  sf_mex_assign(&c3_y, sf_mex_create("y", &c3_u, 6, 0U, 0U, 0U, 0), false);
  sf_mex_assign(&c3_mxArrayOutData, c3_y, false);
  return c3_mxArrayOutData;
}

static int32_T c3_c_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId)
{
  int32_T c3_y;
  int32_T c3_i81;
  (void)chartInstance;
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), &c3_i81, 1, 6, 0U, 0, 0U, 0);
  c3_y = c3_i81;
  sf_mex_destroy(&c3_u);
  return c3_y;
}

static void c3_c_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData)
{
  const mxArray *c3_b_sfEvent;
  const char_T *c3_identifier;
  emlrtMsgIdentifier c3_thisId;
  int32_T c3_y;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_b_sfEvent = sf_mex_dup(c3_mxArrayInData);
  c3_identifier = c3_varName;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  c3_y = c3_c_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_b_sfEvent),
    &c3_thisId);
  sf_mex_destroy(&c3_b_sfEvent);
  *(int32_T *)c3_outData = c3_y;
  sf_mex_destroy(&c3_mxArrayInData);
}

static const mxArray *c3_d_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData)
{
  const mxArray *c3_mxArrayOutData = NULL;
  uint8_T c3_u;
  const mxArray *c3_y = NULL;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_mxArrayOutData = NULL;
  c3_u = *(uint8_T *)c3_inData;
  c3_y = NULL;
  sf_mex_assign(&c3_y, sf_mex_create("y", &c3_u, 3, 0U, 0U, 0U, 0), false);
  sf_mex_assign(&c3_mxArrayOutData, c3_y, false);
  return c3_mxArrayOutData;
}

static uint8_T c3_d_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_b_tp_TAKE_OFF_12, const char_T *c3_identifier)
{
  uint8_T c3_y;
  emlrtMsgIdentifier c3_thisId;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  c3_y = c3_e_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_b_tp_TAKE_OFF_12),
    &c3_thisId);
  sf_mex_destroy(&c3_b_tp_TAKE_OFF_12);
  return c3_y;
}

static uint8_T c3_e_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance,
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId)
{
  uint8_T c3_y;
  uint8_T c3_u0;
  (void)chartInstance;
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), &c3_u0, 1, 3, 0U, 0, 0U, 0);
  c3_y = c3_u0;
  sf_mex_destroy(&c3_u);
  return c3_y;
}

static void c3_d_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData)
{
  const mxArray *c3_b_tp_TAKE_OFF_12;
  const char_T *c3_identifier;
  emlrtMsgIdentifier c3_thisId;
  uint8_T c3_y;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_b_tp_TAKE_OFF_12 = sf_mex_dup(c3_mxArrayInData);
  c3_identifier = c3_varName;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  c3_y = c3_e_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_b_tp_TAKE_OFF_12),
    &c3_thisId);
  sf_mex_destroy(&c3_b_tp_TAKE_OFF_12);
  *(uint8_T *)c3_outData = c3_y;
  sf_mex_destroy(&c3_mxArrayInData);
}

static const mxArray *c3_e_sf_marshallOut(void *chartInstanceVoid, void
  *c3_inData)
{
  const mxArray *c3_mxArrayOutData = NULL;
  int32_T c3_i82;
  real_T c3_b_inData[12];
  int32_T c3_i83;
  real_T c3_u[12];
  const mxArray *c3_y = NULL;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_mxArrayOutData = NULL;
  for (c3_i82 = 0; c3_i82 < 12; c3_i82++) {
    c3_b_inData[c3_i82] = (*(real_T (*)[12])c3_inData)[c3_i82];
  }

  for (c3_i83 = 0; c3_i83 < 12; c3_i83++) {
    c3_u[c3_i83] = c3_b_inData[c3_i83];
  }

  c3_y = NULL;
  sf_mex_assign(&c3_y, sf_mex_create("y", c3_u, 0, 0U, 1U, 0U, 2, 1, 12), false);
  sf_mex_assign(&c3_mxArrayOutData, c3_y, false);
  return c3_mxArrayOutData;
}

static void c3_f_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_n, const char_T *c3_identifier, real_T c3_y[12])
{
  emlrtMsgIdentifier c3_thisId;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  c3_g_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_n), &c3_thisId, c3_y);
  sf_mex_destroy(&c3_n);
}

static void c3_g_emlrt_marshallIn(SFc3_mainInstanceStruct *chartInstance, const
  mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId, real_T c3_y[12])
{
  real_T c3_dv30[12];
  int32_T c3_i84;
  (void)chartInstance;
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), c3_dv30, 1, 0, 0U, 1, 0U, 2, 1,
                12);
  for (c3_i84 = 0; c3_i84 < 12; c3_i84++) {
    c3_y[c3_i84] = c3_dv30[c3_i84];
  }

  sf_mex_destroy(&c3_u);
}

static void c3_e_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData)
{
  const mxArray *c3_n;
  const char_T *c3_identifier;
  emlrtMsgIdentifier c3_thisId;
  real_T c3_y[12];
  int32_T c3_i85;
  SFc3_mainInstanceStruct *chartInstance;
  chartInstance = (SFc3_mainInstanceStruct *)chartInstanceVoid;
  c3_n = sf_mex_dup(c3_mxArrayInData);
  c3_identifier = c3_varName;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  c3_g_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_n), &c3_thisId, c3_y);
  sf_mex_destroy(&c3_n);
  for (c3_i85 = 0; c3_i85 < 12; c3_i85++) {
    (*(real_T (*)[12])c3_outData)[c3_i85] = c3_y[c3_i85];
  }

  sf_mex_destroy(&c3_mxArrayInData);
}

static const mxArray *c3_h_emlrt_marshallIn(SFc3_mainInstanceStruct
  *chartInstance, const mxArray *c3_b_setSimStateSideEffectsInfo, const char_T
  *c3_identifier)
{
  const mxArray *c3_y = NULL;
  emlrtMsgIdentifier c3_thisId;
  c3_y = NULL;
  c3_thisId.fIdentifier = c3_identifier;
  c3_thisId.fParent = NULL;
  sf_mex_assign(&c3_y, c3_i_emlrt_marshallIn(chartInstance, sf_mex_dup
    (c3_b_setSimStateSideEffectsInfo), &c3_thisId), false);
  sf_mex_destroy(&c3_b_setSimStateSideEffectsInfo);
  return c3_y;
}

static const mxArray *c3_i_emlrt_marshallIn(SFc3_mainInstanceStruct
  *chartInstance, const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId)
{
  const mxArray *c3_y = NULL;
  (void)chartInstance;
  (void)c3_parentId;
  c3_y = NULL;
  sf_mex_assign(&c3_y, sf_mex_duplicatearraysafe(&c3_u), false);
  sf_mex_destroy(&c3_u);
  return c3_y;
}

static void c3_updateDataWrittenToVector(SFc3_mainInstanceStruct *chartInstance,
  uint32_T c3_vectorIndex)
{
  (void)chartInstance;
  c3_dataWrittenToVector[(uint32_T)_SFD_EML_ARRAY_BOUNDS_CHECK(0, (int32_T)
    c3_vectorIndex, 0, 8, 1, 0)] = true;
}

static void init_dsm_address_info(SFc3_mainInstanceStruct *chartInstance)
{
  (void)chartInstance;
}

/* SFunction Glue Code */
#ifdef utFree
#undef utFree
#endif

#ifdef utMalloc
#undef utMalloc
#endif

#ifdef __cplusplus

extern "C" void *utMalloc(size_t size);
extern "C" void utFree(void*);

#else

extern void *utMalloc(size_t size);
extern void utFree(void*);

#endif

void sf_c3_main_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(712791927U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(1130784462U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(4140400349U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(3177631014U);
}

mxArray *sf_c3_main_get_autoinheritance_info(void)
{
  const char *autoinheritanceFields[] = { "checksum", "inputs", "parameters",
    "outputs", "locals" };

  mxArray *mxAutoinheritanceInfo = mxCreateStructMatrix(1,1,5,
    autoinheritanceFields);

  {
    mxArray *mxChecksum = mxCreateString("X5kQJygQcsFgwXEIJkmCwD");
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
  }

  {
    const char *dataFields[] = { "size", "type", "complexity" };

    mxArray *mxData = mxCreateStructMatrix(1,1,3,dataFields);

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,0,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,0,"type",mxType);
    }

    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));
    mxSetField(mxAutoinheritanceInfo,0,"inputs",mxData);
  }

  {
    mxSetField(mxAutoinheritanceInfo,0,"parameters",mxCreateDoubleMatrix(0,0,
                mxREAL));
  }

  {
    const char *dataFields[] = { "size", "type", "complexity" };

    mxArray *mxData = mxCreateStructMatrix(1,9,3,dataFields);

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,0,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,0,"type",mxType);
    }

    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,1,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,1,"type",mxType);
    }

    mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,2,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,2,"type",mxType);
    }

    mxSetField(mxData,2,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,3,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,3,"type",mxType);
    }

    mxSetField(mxData,3,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,4,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,4,"type",mxType);
    }

    mxSetField(mxData,4,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,5,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,5,"type",mxType);
    }

    mxSetField(mxData,5,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,6,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,6,"type",mxType);
    }

    mxSetField(mxData,6,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,7,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,7,"type",mxType);
    }

    mxSetField(mxData,7,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(12);
      mxSetField(mxData,8,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,8,"type",mxType);
    }

    mxSetField(mxData,8,"complexity",mxCreateDoubleScalar(0));
    mxSetField(mxAutoinheritanceInfo,0,"outputs",mxData);
  }

  {
    mxSetField(mxAutoinheritanceInfo,0,"locals",mxCreateDoubleMatrix(0,0,mxREAL));
  }

  return(mxAutoinheritanceInfo);
}

mxArray *sf_c3_main_third_party_uses_info(void)
{
  mxArray * mxcell3p = mxCreateCellMatrix(1,0);
  return(mxcell3p);
}

mxArray *sf_c3_main_updateBuildInfo_args_info(void)
{
  mxArray *mxBIArgs = mxCreateCellMatrix(1,0);
  return mxBIArgs;
}

static const mxArray *sf_get_sim_state_info_c3_main(void)
{
  const char *infoFields[] = { "chartChecksum", "varInfo" };

  mxArray *mxInfo = mxCreateStructMatrix(1, 1, 2, infoFields);
  const char *infoEncStr[] = {
    "100 S1x10'type','srcId','name','auxInfo'{{M[1],M[53],T\"Rlat\",},{M[1],M[54],T\"Rlon\",},{M[1],M[15],T\"Speed\",},{M[1],M[14],T\"alt\",},{M[1],M[55],T\"dc\",},{M[1],M[12],T\"lat\",},{M[1],M[13],T\"lon\",},{M[1],M[11],T\"n\",},{M[1],M[16],T\"ok\",},{M[8],M[0],T\"is_active_c3_main\",}}",
    "100 S'type','srcId','name','auxInfo'{{M[9],M[0],T\"is_c3_main\",}}"
  };

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 11, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c3_main_get_check_sum(&mxChecksum);
  mxSetField(mxInfo, 0, infoFields[0], mxChecksum);
  mxSetField(mxInfo, 0, infoFields[1], mxVarInfo);
  return mxInfo;
}

static void chart_debug_initialization(SimStruct *S, unsigned int
  fullDebuggerInitialization)
{
  if (!sim_mode_is_rtw_gen(S)) {
    SFc3_mainInstanceStruct *chartInstance;
    ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
    ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
    chartInstance = (SFc3_mainInstanceStruct *) chartInfo->chartInstance;
    if (ssIsFirstInitCond(S) && fullDebuggerInitialization==1) {
      /* do this only if simulation is starting */
      {
        unsigned int chartAlreadyPresent;
        chartAlreadyPresent = sf_debug_initialize_chart
          (sfGlobalDebugInstanceStruct,
           _mainMachineNumber_,
           3,
           3,
           3,
           0,
           10,
           0,
           0,
           0,
           0,
           0,
           &(chartInstance->chartNumber),
           &(chartInstance->instanceNumber),
           (void *)S);

        /* Each instance must initialize ist own list of scripts */
        init_script_number_translation(_mainMachineNumber_,
          chartInstance->chartNumber,chartInstance->instanceNumber);
        if (chartAlreadyPresent==0) {
          /* this is the first instance */
          sf_debug_set_chart_disable_implicit_casting
            (sfGlobalDebugInstanceStruct,_mainMachineNumber_,
             chartInstance->chartNumber,1);
          sf_debug_set_chart_event_thresholds(sfGlobalDebugInstanceStruct,
            _mainMachineNumber_,
            chartInstance->chartNumber,
            0,
            0,
            0);
          _SFD_SET_DATA_PROPS(0,1,1,0,"u");
          _SFD_SET_DATA_PROPS(1,2,0,1,"n");
          _SFD_SET_DATA_PROPS(2,2,0,1,"lat");
          _SFD_SET_DATA_PROPS(3,2,0,1,"lon");
          _SFD_SET_DATA_PROPS(4,2,0,1,"alt");
          _SFD_SET_DATA_PROPS(5,2,0,1,"Speed");
          _SFD_SET_DATA_PROPS(6,2,0,1,"ok");
          _SFD_SET_DATA_PROPS(7,2,0,1,"Rlat");
          _SFD_SET_DATA_PROPS(8,2,0,1,"Rlon");
          _SFD_SET_DATA_PROPS(9,2,0,1,"dc");
          _SFD_STATE_INFO(0,0,0);
          _SFD_STATE_INFO(1,0,0);
          _SFD_STATE_INFO(2,0,0);
          _SFD_CH_SUBSTATE_COUNT(3);
          _SFD_CH_SUBSTATE_DECOMP(0);
          _SFD_CH_SUBSTATE_INDEX(0,0);
          _SFD_CH_SUBSTATE_INDEX(1,1);
          _SFD_CH_SUBSTATE_INDEX(2,2);
          _SFD_ST_SUBSTATE_COUNT(0,0);
          _SFD_ST_SUBSTATE_COUNT(1,0);
          _SFD_ST_SUBSTATE_COUNT(2,0);
        }

        _SFD_CV_INIT_CHART(3,1,0,0);

        {
          _SFD_CV_INIT_STATE(0,0,0,0,0,0,NULL,NULL);
        }

        {
          _SFD_CV_INIT_STATE(1,0,0,0,0,0,NULL,NULL);
        }

        {
          _SFD_CV_INIT_STATE(2,0,0,0,0,0,NULL,NULL);
        }

        _SFD_CV_INIT_TRANS(1,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(0,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(2,0,NULL,NULL,0,NULL);

        /* Initialization of MATLAB Function Model Coverage */
        _SFD_CV_INIT_EML(2,1,0,0,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML(1,1,0,0,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML(0,1,0,0,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML(1,0,0,1,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML_IF(1,0,0,1,6,1,6);
        _SFD_CV_INIT_EML(0,0,0,1,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML_IF(0,0,0,1,5,1,5);
        _SFD_CV_INIT_EML(2,0,0,1,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML_IF(2,0,0,1,5,1,5);
        _SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c3_sf_marshallOut,(MexInFcnForType)NULL);

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(1,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(2,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(3,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(4,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(5,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(6,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(7,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(8,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          unsigned int dimVector[2];
          dimVector[0]= 1;
          dimVector[1]= 12;
          _SFD_SET_DATA_COMPILED_PROPS(9,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c3_e_sf_marshallOut,(MexInFcnForType)
            c3_e_sf_marshallIn);
        }

        {
          real_T *c3_u;
          real_T (*c3_n)[12];
          real_T (*c3_lat)[12];
          real_T (*c3_lon)[12];
          real_T (*c3_alt)[12];
          real_T (*c3_Speed)[12];
          real_T (*c3_ok)[12];
          real_T (*c3_Rlat)[12];
          real_T (*c3_Rlon)[12];
          real_T (*c3_dc)[12];
          c3_dc = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 9);
          c3_Rlon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 8);
          c3_Rlat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 7);
          c3_ok = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 6);
          c3_Speed = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 5);
          c3_alt = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 4);
          c3_lon = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 3);
          c3_lat = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 2);
          c3_n = (real_T (*)[12])ssGetOutputPortSignal(chartInstance->S, 1);
          c3_u = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
          _SFD_SET_DATA_VALUE_PTR(0U, c3_u);
          _SFD_SET_DATA_VALUE_PTR(1U, *c3_n);
          _SFD_SET_DATA_VALUE_PTR(2U, *c3_lat);
          _SFD_SET_DATA_VALUE_PTR(3U, *c3_lon);
          _SFD_SET_DATA_VALUE_PTR(4U, *c3_alt);
          _SFD_SET_DATA_VALUE_PTR(5U, *c3_Speed);
          _SFD_SET_DATA_VALUE_PTR(6U, *c3_ok);
          _SFD_SET_DATA_VALUE_PTR(7U, *c3_Rlat);
          _SFD_SET_DATA_VALUE_PTR(8U, *c3_Rlon);
          _SFD_SET_DATA_VALUE_PTR(9U, *c3_dc);
        }
      }
    } else {
      sf_debug_reset_current_state_configuration(sfGlobalDebugInstanceStruct,
        _mainMachineNumber_,chartInstance->chartNumber,
        chartInstance->instanceNumber);
    }
  }
}

static const char* sf_get_instance_specialization(void)
{
  return "wwua1qTTmbKJgB8QhQkBnB";
}

static void sf_opaque_initialize_c3_main(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc3_mainInstanceStruct*) chartInstanceVar)->S,0);
  initialize_params_c3_main((SFc3_mainInstanceStruct*) chartInstanceVar);
  initialize_c3_main((SFc3_mainInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_enable_c3_main(void *chartInstanceVar)
{
  enable_c3_main((SFc3_mainInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_disable_c3_main(void *chartInstanceVar)
{
  disable_c3_main((SFc3_mainInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_gateway_c3_main(void *chartInstanceVar)
{
  sf_gateway_c3_main((SFc3_mainInstanceStruct*) chartInstanceVar);
}

extern const mxArray* sf_internal_get_sim_state_c3_main(SimStruct* S)
{
  ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
  ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
  mxArray *plhs[1] = { NULL };

  mxArray *prhs[4];
  int mxError = 0;
  prhs[0] = mxCreateString("chart_simctx_raw2high");
  prhs[1] = mxCreateDoubleScalar(ssGetSFuncBlockHandle(S));
  prhs[2] = (mxArray*) get_sim_state_c3_main((SFc3_mainInstanceStruct*)
    chartInfo->chartInstance);         /* raw sim ctx */
  prhs[3] = (mxArray*) sf_get_sim_state_info_c3_main();/* state var info */
  mxError = sf_mex_call_matlab(1, plhs, 4, prhs, "sfprivate");
  mxDestroyArray(prhs[0]);
  mxDestroyArray(prhs[1]);
  mxDestroyArray(prhs[2]);
  mxDestroyArray(prhs[3]);
  if (mxError || plhs[0] == NULL) {
    sf_mex_error_message("Stateflow Internal Error: \nError calling 'chart_simctx_raw2high'.\n");
  }

  return plhs[0];
}

extern void sf_internal_set_sim_state_c3_main(SimStruct* S, const mxArray *st)
{
  ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
  ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
  mxArray *plhs[1] = { NULL };

  mxArray *prhs[3];
  int mxError = 0;
  prhs[0] = mxCreateString("chart_simctx_high2raw");
  prhs[1] = mxDuplicateArray(st);      /* high level simctx */
  prhs[2] = (mxArray*) sf_get_sim_state_info_c3_main();/* state var info */
  mxError = sf_mex_call_matlab(1, plhs, 3, prhs, "sfprivate");
  mxDestroyArray(prhs[0]);
  mxDestroyArray(prhs[1]);
  mxDestroyArray(prhs[2]);
  if (mxError || plhs[0] == NULL) {
    sf_mex_error_message("Stateflow Internal Error: \nError calling 'chart_simctx_high2raw'.\n");
  }

  set_sim_state_c3_main((SFc3_mainInstanceStruct*)chartInfo->chartInstance,
                        mxDuplicateArray(plhs[0]));
  mxDestroyArray(plhs[0]);
}

static const mxArray* sf_opaque_get_sim_state_c3_main(SimStruct* S)
{
  return sf_internal_get_sim_state_c3_main(S);
}

static void sf_opaque_set_sim_state_c3_main(SimStruct* S, const mxArray *st)
{
  sf_internal_set_sim_state_c3_main(S, st);
}

static void sf_opaque_terminate_c3_main(void *chartInstanceVar)
{
  if (chartInstanceVar!=NULL) {
    SimStruct *S = ((SFc3_mainInstanceStruct*) chartInstanceVar)->S;
    ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
    if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
      sf_clear_rtw_identifier(S);
      unload_main_optimization_info();
    }

    finalize_c3_main((SFc3_mainInstanceStruct*) chartInstanceVar);
    utFree((void *)chartInstanceVar);
    if (crtInfo != NULL) {
      utFree((void *)crtInfo);
    }

    ssSetUserData(S,NULL);
  }
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  initSimStructsc3_main((SFc3_mainInstanceStruct*) chartInstanceVar);
}

extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c3_main(SimStruct *S)
{
  int i;
  for (i=0;i<ssGetNumRunTimeParams(S);i++) {
    if (ssGetSFcnParamTunable(S,i)) {
      ssUpdateDlgParamAsRunTimeParam(S,i);
    }
  }

  if (sf_machine_global_initializer_called()) {
    ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
    ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
    initialize_params_c3_main((SFc3_mainInstanceStruct*)
      (chartInfo->chartInstance));
  }
}

static void mdlSetWorkWidths_c3_main(SimStruct *S)
{
  if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
    mxArray *infoStruct = load_main_optimization_info();
    int_T chartIsInlinable =
      (int_T)sf_is_chart_inlinable(sf_get_instance_specialization(),infoStruct,3);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetRTWCG(S,sf_rtw_info_uint_prop(sf_get_instance_specialization(),
                infoStruct,3,"RTWCG"));
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop
      (sf_get_instance_specialization(),infoStruct,3,
       "gatewayCannotBeInlinedMultipleTimes"));
    sf_update_buildInfo(sf_get_instance_specialization(),infoStruct,3);
    if (chartIsInlinable) {
      ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
      sf_mark_chart_expressionable_inputs(S,sf_get_instance_specialization(),
        infoStruct,3,1);
      sf_mark_chart_reusable_outputs(S,sf_get_instance_specialization(),
        infoStruct,3,9);
    }

    {
      unsigned int outPortIdx;
      for (outPortIdx=1; outPortIdx<=9; ++outPortIdx) {
        ssSetOutputPortOptimizeInIR(S, outPortIdx, 1U);
      }
    }

    {
      unsigned int inPortIdx;
      for (inPortIdx=0; inPortIdx < 1; ++inPortIdx) {
        ssSetInputPortOptimizeInIR(S, inPortIdx, 1U);
      }
    }

    sf_set_rtw_dwork_info(S,sf_get_instance_specialization(),infoStruct,3);
    ssSetHasSubFunctions(S,!(chartIsInlinable));
  } else {
  }

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(3200480049U));
  ssSetChecksum1(S,(3357526637U));
  ssSetChecksum2(S,(3376847322U));
  ssSetChecksum3(S,(2180536598U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
  ssSupportsMultipleExecInstances(S,1);
}

static void mdlRTW_c3_main(SimStruct *S)
{
  if (sim_mode_is_rtw_gen(S)) {
    ssWriteRTWStrParam(S, "StateflowChartType", "Stateflow");
  }
}

static void mdlStart_c3_main(SimStruct *S)
{
  SFc3_mainInstanceStruct *chartInstance;
  ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)utMalloc(sizeof
    (ChartRunTimeInfo));
  chartInstance = (SFc3_mainInstanceStruct *)utMalloc(sizeof
    (SFc3_mainInstanceStruct));
  memset(chartInstance, 0, sizeof(SFc3_mainInstanceStruct));
  if (chartInstance==NULL) {
    sf_mex_error_message("Could not allocate memory for chart instance.");
  }

  chartInstance->chartInfo.chartInstance = chartInstance;
  chartInstance->chartInfo.isEMLChart = 0;
  chartInstance->chartInfo.chartInitialized = 0;
  chartInstance->chartInfo.sFunctionGateway = sf_opaque_gateway_c3_main;
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c3_main;
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c3_main;
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c3_main;
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c3_main;
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c3_main;
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c3_main;
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c3_main;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c3_main;
  chartInstance->chartInfo.mdlStart = mdlStart_c3_main;
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c3_main;
  chartInstance->chartInfo.extModeExec = NULL;
  chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.storeCurrentConfiguration = NULL;
  chartInstance->chartInfo.debugInstance = sfGlobalDebugInstanceStruct;
  chartInstance->S = S;
  crtInfo->instanceInfo = (&(chartInstance->chartInfo));
  crtInfo->isJITEnabled = false;
  ssSetUserData(S,(void *)(crtInfo));  /* register the chart instance with simstruct */
  init_dsm_address_info(chartInstance);
  if (!sim_mode_is_rtw_gen(S)) {
  }

  sf_opaque_init_subchart_simstructs(chartInstance->chartInfo.chartInstance);
  chart_debug_initialization(S,1);
}

void c3_main_method_dispatcher(SimStruct *S, int_T method, void *data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c3_main(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c3_main(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c3_main(S);
    break;

   default:
    /* Unhandled method */
    sf_mex_error_message("Stateflow Internal Error:\n"
                         "Error calling c3_main_method_dispatcher.\n"
                         "Can't handle method %d.\n", method);
    break;
  }
}
