/* Include files */

#include "blascompat32.h"
#include "ental_sfun.h"
#include "c8_ental.h"
#define CHARTINSTANCE_CHARTNUMBER      (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER   (chartInstance->instanceNumber)
#include "ental_sfun_debug_macros.h"

/* Type Definitions */

/* Named Constants */

/* Variable Declarations */

/* Variable Definitions */
static const char *c8_debug_family_names[4] = { "p", "nargin", "nargout", "A" };

/* Function Declarations */
static void initialize_c8_ental(SFc8_entalInstanceStruct *chartInstance);
static void initialize_params_c8_ental(SFc8_entalInstanceStruct *chartInstance);
static void enable_c8_ental(SFc8_entalInstanceStruct *chartInstance);
static void disable_c8_ental(SFc8_entalInstanceStruct *chartInstance);
static void c8_update_debugger_state_c8_ental(SFc8_entalInstanceStruct
  *chartInstance);
static const mxArray *get_sim_state_c8_ental(SFc8_entalInstanceStruct
  *chartInstance);
static void set_sim_state_c8_ental(SFc8_entalInstanceStruct *chartInstance,
  const mxArray *c8_st);
static void finalize_c8_ental(SFc8_entalInstanceStruct *chartInstance);
static void sf_c8_ental(SFc8_entalInstanceStruct *chartInstance);
static void compInitSubchartSimstructsFcn_c8_ental(SFc8_entalInstanceStruct
  *chartInstance);
static void init_script_number_translation(uint32_T c8_machineNumber, uint32_T
  c8_chartNumber);
static const mxArray *c8_sf_marshall(void *chartInstanceVoid, void *c8_u);
static const mxArray *c8_b_sf_marshall(void *chartInstanceVoid, void *c8_u);
static const mxArray *c8_c_sf_marshall(void *chartInstanceVoid, void *c8_u);
static void c8_emlrt_marshallIn(SFc8_entalInstanceStruct *chartInstance, const
  mxArray *c8_A, const char_T *c8_name, real_T c8_y[13]);
static uint8_T c8_b_emlrt_marshallIn(SFc8_entalInstanceStruct *chartInstance,
  const mxArray *c8_b_is_active_c8_ental, const char_T *c8_name);
static void init_dsm_address_info(SFc8_entalInstanceStruct *chartInstance);

/* Function Definitions */
static void initialize_c8_ental(SFc8_entalInstanceStruct *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  chartInstance->c8_is_active_c8_ental = 0U;
}

static void initialize_params_c8_ental(SFc8_entalInstanceStruct *chartInstance)
{
}

static void enable_c8_ental(SFc8_entalInstanceStruct *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
}

static void disable_c8_ental(SFc8_entalInstanceStruct *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
}

static void c8_update_debugger_state_c8_ental(SFc8_entalInstanceStruct
  *chartInstance)
{
}

static const mxArray *get_sim_state_c8_ental(SFc8_entalInstanceStruct
  *chartInstance)
{
  const mxArray *c8_st = NULL;
  const mxArray *c8_y = NULL;
  int32_T c8_i0;
  real_T c8_hoistedGlobal[13];
  int32_T c8_i1;
  real_T c8_u[13];
  const mxArray *c8_b_y = NULL;
  uint8_T c8_b_hoistedGlobal;
  uint8_T c8_b_u;
  const mxArray *c8_c_y = NULL;
  real_T (*c8_A)[13];
  c8_A = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  c8_st = NULL;
  c8_y = NULL;
  sf_mex_assign(&c8_y, sf_mex_createcellarray(2));
  for (c8_i0 = 0; c8_i0 < 13; c8_i0 = c8_i0 + 1) {
    c8_hoistedGlobal[c8_i0] = (*c8_A)[c8_i0];
  }

  for (c8_i1 = 0; c8_i1 < 13; c8_i1 = c8_i1 + 1) {
    c8_u[c8_i1] = c8_hoistedGlobal[c8_i1];
  }

  c8_b_y = NULL;
  sf_mex_assign(&c8_b_y, sf_mex_create("y", c8_u, 0, 0U, 1U, 0U, 1, 13));
  sf_mex_setcell(c8_y, 0, c8_b_y);
  c8_b_hoistedGlobal = chartInstance->c8_is_active_c8_ental;
  c8_b_u = c8_b_hoistedGlobal;
  c8_c_y = NULL;
  sf_mex_assign(&c8_c_y, sf_mex_create("y", &c8_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c8_y, 1, c8_c_y);
  sf_mex_assign(&c8_st, c8_y);
  return c8_st;
}

static void set_sim_state_c8_ental(SFc8_entalInstanceStruct *chartInstance,
  const mxArray *c8_st)
{
  const mxArray *c8_u;
  real_T c8_dv0[13];
  int32_T c8_i2;
  real_T (*c8_A)[13];
  c8_A = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  chartInstance->c8_doneDoubleBufferReInit = TRUE;
  c8_u = sf_mex_dup(c8_st);
  c8_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c8_u, 0)), "A",
                      c8_dv0);
  for (c8_i2 = 0; c8_i2 < 13; c8_i2 = c8_i2 + 1) {
    (*c8_A)[c8_i2] = c8_dv0[c8_i2];
  }

  chartInstance->c8_is_active_c8_ental = c8_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c8_u, 1)),
    "is_active_c8_ental");
  sf_mex_destroy(&c8_u);
  c8_update_debugger_state_c8_ental(chartInstance);
  sf_mex_destroy(&c8_st);
}

static void finalize_c8_ental(SFc8_entalInstanceStruct *chartInstance)
{
}

static void sf_c8_ental(SFc8_entalInstanceStruct *chartInstance)
{
  int32_T c8_i3;
  int32_T c8_previousEvent;
  uint32_T c8_debug_family_var_map[4];
  static const char *c8_sv0[4] = { "p", "nargin", "nargout", "A" };

  real_T c8_p;
  real_T c8_nargin = 0.0;
  real_T c8_nargout = 1.0;
  real_T c8_A[13];
  int32_T c8_i4;
  int32_T c8_i5;
  real_T (*c8_b_A)[13];
  c8_b_A = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 7);
  for (c8_i3 = 0; c8_i3 < 13; c8_i3 = c8_i3 + 1) {
    _SFD_DATA_RANGE_CHECK((*c8_b_A)[c8_i3], 0U);
  }

  c8_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 7);
  sf_debug_symbol_scope_push_eml(0U, 4U, 4U, c8_sv0, c8_debug_family_var_map);
  sf_debug_symbol_scope_add_eml(&c8_p, c8_b_sf_marshall, 0U);
  sf_debug_symbol_scope_add_eml(&c8_nargin, c8_b_sf_marshall, 1U);
  sf_debug_symbol_scope_add_eml(&c8_nargout, c8_b_sf_marshall, 2U);
  sf_debug_symbol_scope_add_eml(c8_A, c8_sf_marshall, 3U);
  CV_EML_FCN(0, 0);
  _SFD_EML_CALL(0, 4);
  c8_p = 13.0;
  _SFD_EML_CALL(0, 5);
  for (c8_i4 = 0; c8_i4 < 13; c8_i4 = c8_i4 + 1) {
    c8_A[c8_i4] = 2.0;
  }

  _SFD_EML_CALL(0, -5);
  sf_debug_symbol_scope_pop();
  for (c8_i5 = 0; c8_i5 < 13; c8_i5 = c8_i5 + 1) {
    (*c8_b_A)[c8_i5] = c8_A[c8_i5];
  }

  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 7);
  _sfEvent_ = c8_previousEvent;
  sf_debug_check_for_state_inconsistency(_entalMachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}

static void compInitSubchartSimstructsFcn_c8_ental(SFc8_entalInstanceStruct
  *chartInstance)
{
}

static void init_script_number_translation(uint32_T c8_machineNumber, uint32_T
  c8_chartNumber)
{
}

static const mxArray *c8_sf_marshall(void *chartInstanceVoid, void *c8_u)
{
  const mxArray *c8_y = NULL;
  int32_T c8_i6;
  real_T c8_b_u[13];
  int32_T c8_i7;
  real_T c8_c_u[13];
  const mxArray *c8_b_y = NULL;
  SFc8_entalInstanceStruct *chartInstance;
  chartInstance = (SFc8_entalInstanceStruct *)chartInstanceVoid;
  c8_y = NULL;
  for (c8_i6 = 0; c8_i6 < 13; c8_i6 = c8_i6 + 1) {
    c8_b_u[c8_i6] = (*((real_T (*)[13])c8_u))[c8_i6];
  }

  for (c8_i7 = 0; c8_i7 < 13; c8_i7 = c8_i7 + 1) {
    c8_c_u[c8_i7] = c8_b_u[c8_i7];
  }

  c8_b_y = NULL;
  sf_mex_assign(&c8_b_y, sf_mex_create("y", c8_c_u, 0, 0U, 1U, 0U, 1, 13));
  sf_mex_assign(&c8_y, c8_b_y);
  return c8_y;
}

static const mxArray *c8_b_sf_marshall(void *chartInstanceVoid, void *c8_u)
{
  const mxArray *c8_y = NULL;
  real_T c8_b_u;
  const mxArray *c8_b_y = NULL;
  SFc8_entalInstanceStruct *chartInstance;
  chartInstance = (SFc8_entalInstanceStruct *)chartInstanceVoid;
  c8_y = NULL;
  c8_b_u = *((real_T *)c8_u);
  c8_b_y = NULL;
  sf_mex_assign(&c8_b_y, sf_mex_create("y", &c8_b_u, 0, 0U, 0U, 0U, 0));
  sf_mex_assign(&c8_y, c8_b_y);
  return c8_y;
}

const mxArray *sf_c8_ental_get_eml_resolved_functions_info(void)
{
  const mxArray *c8_nameCaptureInfo = NULL;
  c8_ResolvedFunctionInfo c8_info[12];
  c8_ResolvedFunctionInfo (*c8_b_info)[12];
  const mxArray *c8_m0 = NULL;
  int32_T c8_i8;
  c8_ResolvedFunctionInfo *c8_r0;
  c8_nameCaptureInfo = NULL;
  c8_b_info = (c8_ResolvedFunctionInfo (*)[12])c8_info;
  (*c8_b_info)[0].context = "";
  (*c8_b_info)[0].name = "ones";
  (*c8_b_info)[0].dominantType = "double";
  (*c8_b_info)[0].resolved = "[B]ones";
  (*c8_b_info)[0].fileLength = 0U;
  (*c8_b_info)[0].fileTime1 = 0U;
  (*c8_b_info)[0].fileTime2 = 0U;
  (*c8_b_info)[1].context = "";
  (*c8_b_info)[1].name = "mtimes";
  (*c8_b_info)[1].dominantType = "double";
  (*c8_b_info)[1].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[1].fileLength = 3425U;
  (*c8_b_info)[1].fileTime1 = 1251031872U;
  (*c8_b_info)[1].fileTime2 = 0U;
  (*c8_b_info)[2].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[2].name = "nargin";
  (*c8_b_info)[2].dominantType = "";
  (*c8_b_info)[2].resolved = "[B]nargin";
  (*c8_b_info)[2].fileLength = 0U;
  (*c8_b_info)[2].fileTime1 = 0U;
  (*c8_b_info)[2].fileTime2 = 0U;
  (*c8_b_info)[3].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[3].name = "gt";
  (*c8_b_info)[3].dominantType = "double";
  (*c8_b_info)[3].resolved = "[B]gt";
  (*c8_b_info)[3].fileLength = 0U;
  (*c8_b_info)[3].fileTime1 = 0U;
  (*c8_b_info)[3].fileTime2 = 0U;
  (*c8_b_info)[4].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[4].name = "isa";
  (*c8_b_info)[4].dominantType = "double";
  (*c8_b_info)[4].resolved = "[B]isa";
  (*c8_b_info)[4].fileLength = 0U;
  (*c8_b_info)[4].fileTime1 = 0U;
  (*c8_b_info)[4].fileTime2 = 0U;
  (*c8_b_info)[5].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[5].name = "isinteger";
  (*c8_b_info)[5].dominantType = "double";
  (*c8_b_info)[5].resolved = "[B]isinteger";
  (*c8_b_info)[5].fileLength = 0U;
  (*c8_b_info)[5].fileTime1 = 0U;
  (*c8_b_info)[5].fileTime2 = 0U;
  (*c8_b_info)[6].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[6].name = "isscalar";
  (*c8_b_info)[6].dominantType = "double";
  (*c8_b_info)[6].resolved = "[B]isscalar";
  (*c8_b_info)[6].fileLength = 0U;
  (*c8_b_info)[6].fileTime1 = 0U;
  (*c8_b_info)[6].fileTime2 = 0U;
  (*c8_b_info)[7].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[7].name = "strcmp";
  (*c8_b_info)[7].dominantType = "char";
  (*c8_b_info)[7].resolved = "[B]strcmp";
  (*c8_b_info)[7].fileLength = 0U;
  (*c8_b_info)[7].fileTime1 = 0U;
  (*c8_b_info)[7].fileTime2 = 0U;
  (*c8_b_info)[8].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[8].name = "size";
  (*c8_b_info)[8].dominantType = "double";
  (*c8_b_info)[8].resolved = "[B]size";
  (*c8_b_info)[8].fileLength = 0U;
  (*c8_b_info)[8].fileTime1 = 0U;
  (*c8_b_info)[8].fileTime2 = 0U;
  (*c8_b_info)[9].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[9].name = "eq";
  (*c8_b_info)[9].dominantType = "double";
  (*c8_b_info)[9].resolved = "[B]eq";
  (*c8_b_info)[9].fileLength = 0U;
  (*c8_b_info)[9].fileTime1 = 0U;
  (*c8_b_info)[9].fileTime2 = 0U;
  (*c8_b_info)[10].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[10].name = "class";
  (*c8_b_info)[10].dominantType = "double";
  (*c8_b_info)[10].resolved = "[B]class";
  (*c8_b_info)[10].fileLength = 0U;
  (*c8_b_info)[10].fileTime1 = 0U;
  (*c8_b_info)[10].fileTime2 = 0U;
  (*c8_b_info)[11].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c8_b_info)[11].name = "not";
  (*c8_b_info)[11].dominantType = "logical";
  (*c8_b_info)[11].resolved = "[B]not";
  (*c8_b_info)[11].fileLength = 0U;
  (*c8_b_info)[11].fileTime1 = 0U;
  (*c8_b_info)[11].fileTime2 = 0U;
  sf_mex_assign(&c8_m0, sf_mex_createstruct("nameCaptureInfo", 1, 12));
  for (c8_i8 = 0; c8_i8 < 12; c8_i8 = c8_i8 + 1) {
    c8_r0 = &c8_info[c8_i8];
    sf_mex_addfield(c8_m0, sf_mex_create("nameCaptureInfo", c8_r0->context, 15,
      0U, 0U, 0U, 2, 1, strlen(c8_r0->context)), "context",
                    "nameCaptureInfo", c8_i8);
    sf_mex_addfield(c8_m0, sf_mex_create("nameCaptureInfo", c8_r0->name, 15, 0U,
      0U, 0U, 2, 1, strlen(c8_r0->name)), "name",
                    "nameCaptureInfo", c8_i8);
    sf_mex_addfield(c8_m0, sf_mex_create("nameCaptureInfo", c8_r0->dominantType,
      15, 0U, 0U, 0U, 2, 1, strlen(c8_r0->dominantType)),
                    "dominantType", "nameCaptureInfo", c8_i8);
    sf_mex_addfield(c8_m0, sf_mex_create("nameCaptureInfo", c8_r0->resolved, 15,
      0U, 0U, 0U, 2, 1, strlen(c8_r0->resolved)), "resolved"
                    , "nameCaptureInfo", c8_i8);
    sf_mex_addfield(c8_m0, sf_mex_create("nameCaptureInfo", &c8_r0->fileLength,
      7, 0U, 0U, 0U, 0), "fileLength", "nameCaptureInfo",
                    c8_i8);
    sf_mex_addfield(c8_m0, sf_mex_create("nameCaptureInfo", &c8_r0->fileTime1, 7,
      0U, 0U, 0U, 0), "fileTime1", "nameCaptureInfo", c8_i8);
    sf_mex_addfield(c8_m0, sf_mex_create("nameCaptureInfo", &c8_r0->fileTime2, 7,
      0U, 0U, 0U, 0), "fileTime2", "nameCaptureInfo", c8_i8);
  }

  sf_mex_assign(&c8_nameCaptureInfo, c8_m0);
  return c8_nameCaptureInfo;
}

static const mxArray *c8_c_sf_marshall(void *chartInstanceVoid, void *c8_u)
{
  const mxArray *c8_y = NULL;
  boolean_T c8_b_u;
  const mxArray *c8_b_y = NULL;
  SFc8_entalInstanceStruct *chartInstance;
  chartInstance = (SFc8_entalInstanceStruct *)chartInstanceVoid;
  c8_y = NULL;
  c8_b_u = *((boolean_T *)c8_u);
  c8_b_y = NULL;
  sf_mex_assign(&c8_b_y, sf_mex_create("y", &c8_b_u, 11, 0U, 0U, 0U, 0));
  sf_mex_assign(&c8_y, c8_b_y);
  return c8_y;
}

static void c8_emlrt_marshallIn(SFc8_entalInstanceStruct *chartInstance, const
  mxArray *c8_A, const char_T *c8_name, real_T c8_y[13]
  )
{
  real_T c8_dv1[13];
  int32_T c8_i9;
  sf_mex_import(c8_name, sf_mex_dup(c8_A), c8_dv1, 1, 0, 0U, 1, 0U, 1, 13);
  for (c8_i9 = 0; c8_i9 < 13; c8_i9 = c8_i9 + 1) {
    c8_y[c8_i9] = c8_dv1[c8_i9];
  }

  sf_mex_destroy(&c8_A);
}

static uint8_T c8_b_emlrt_marshallIn(SFc8_entalInstanceStruct *chartInstance,
  const mxArray *c8_b_is_active_c8_ental, const char_T *
  c8_name)
{
  uint8_T c8_y;
  uint8_T c8_u0;
  sf_mex_import(c8_name, sf_mex_dup(c8_b_is_active_c8_ental), &c8_u0, 1, 3, 0U,
                0, 0U, 0);
  c8_y = c8_u0;
  sf_mex_destroy(&c8_b_is_active_c8_ental);
  return c8_y;
}

static void init_dsm_address_info(SFc8_entalInstanceStruct *chartInstance)
{
}

/* SFunction Glue Code */
void sf_c8_ental_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1296508932U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(3163117022U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(1505398966U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(2349004707U);
}

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

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

  {
    mxArray *mxChecksum = mxCreateDoubleMatrix(4,1,mxREAL);
    double *pr = mxGetPr(mxChecksum);
    pr[0] = (double)(1619441990U);
    pr[1] = (double)(2854580734U);
    pr[2] = (double)(866228502U);
    pr[3] = (double)(1368402316U);
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
  }

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

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

  {
    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)(13);
      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,"outputs",mxData);
  }

  return(mxAutoinheritanceInfo);
}

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

  mxArray *mxInfo = mxCreateStructMatrix(1, 1, 2, infoFields);
  const char *infoEncStr[] = {
    "100 S1x2'type','srcId','name','auxInfo'{{M[1],M[5],T\"A\",},{M[8],M[0],T\"is_active_c8_ental\",}}"
  };

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 2, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c8_ental_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)) {
    SFc8_entalInstanceStruct *chartInstance;
    chartInstance = (SFc8_entalInstanceStruct *) ((ChartInfoStruct *)
      (ssGetUserData(S)))->chartInstance;
    if (ssIsFirstInitCond(S) && fullDebuggerInitialization==1) {
      /* do this only if simulation is starting */
      {
        unsigned int chartAlreadyPresent;
        chartAlreadyPresent = sf_debug_initialize_chart(_entalMachineNumber_,
          8,
          1,
          1,
          1,
          0,
          0,
          0,
          0,
          0,
          &(chartInstance->chartNumber),
          &(chartInstance->instanceNumber),
          ssGetPath(S),
          (void *)S);
        if (chartAlreadyPresent==0) {
          /* this is the first instance */
          init_script_number_translation(_entalMachineNumber_,
            chartInstance->chartNumber);
          sf_debug_set_chart_disable_implicit_casting(_entalMachineNumber_,
            chartInstance->chartNumber,1);
          sf_debug_set_chart_event_thresholds(_entalMachineNumber_,
            chartInstance->chartNumber,
            0,
            0,
            0);
          _SFD_SET_DATA_PROPS(0,2,0,1,"A");
          _SFD_STATE_INFO(0,0,2);
          _SFD_CH_SUBSTATE_COUNT(0);
          _SFD_CH_SUBSTATE_DECOMP(0);
        }

        _SFD_CV_INIT_CHART(0,0,0,0);

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

        _SFD_CV_INIT_TRANS(0,0,NULL,NULL,0,NULL);

        /* Initialization of EML Model Coverage */
        _SFD_CV_INIT_EML(0,1,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",0,-1,57);
        _SFD_TRANS_COV_WTS(0,0,0,1,0);
        if (chartAlreadyPresent==0) {
          _SFD_TRANS_COV_MAPS(0,
                              0,NULL,NULL,
                              0,NULL,NULL,
                              1,NULL,NULL,
                              0,NULL,NULL);
        }

        {
          unsigned int dimVector[1];
          dimVector[0]= 13;
          _SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,1,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c8_sf_marshall);
        }

        {
          real_T (*c8_A)[13];
          c8_A = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
          _SFD_SET_DATA_VALUE_PTR(0U, *c8_A);
        }
      }
    } else {
      sf_debug_reset_current_state_configuration(_entalMachineNumber_,
        chartInstance->chartNumber,chartInstance->instanceNumber);
    }
  }
}

static void sf_opaque_initialize_c8_ental(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc8_entalInstanceStruct*) chartInstanceVar)->S,0);
  initialize_params_c8_ental((SFc8_entalInstanceStruct*) chartInstanceVar);
  initialize_c8_ental((SFc8_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_enable_c8_ental(void *chartInstanceVar)
{
  enable_c8_ental((SFc8_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_disable_c8_ental(void *chartInstanceVar)
{
  disable_c8_ental((SFc8_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_gateway_c8_ental(void *chartInstanceVar)
{
  sf_c8_ental((SFc8_entalInstanceStruct*) chartInstanceVar);
}

static mxArray* sf_internal_get_sim_state_c8_ental(SimStruct* S)
{
  ChartInfoStruct *chartInfo = (ChartInfoStruct*) ssGetUserData(S);
  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_c8_ental((SFc8_entalInstanceStruct*)
    chartInfo->chartInstance);         /* raw sim ctx */
  prhs[3] = sf_get_sim_state_info_c8_ental();/* 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];
}

static void sf_internal_set_sim_state_c8_ental(SimStruct* S, const mxArray *st)
{
  ChartInfoStruct *chartInfo = (ChartInfoStruct*) ssGetUserData(S);
  mxArray *plhs[1] = { NULL };

  mxArray *prhs[4];
  int mxError = 0;
  prhs[0] = mxCreateString("chart_simctx_high2raw");
  prhs[1] = mxCreateDoubleScalar(ssGetSFuncBlockHandle(S));
  prhs[2] = mxDuplicateArray(st);      /* high level simctx */
  prhs[3] = (mxArray*) sf_get_sim_state_info_c8_ental();/* 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_high2raw'.\n");
  }

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

static mxArray* sf_opaque_get_sim_state_c8_ental(SimStruct* S)
{
  return sf_internal_get_sim_state_c8_ental(S);
}

static void sf_opaque_set_sim_state_c8_ental(SimStruct* S, const mxArray *st)
{
  sf_internal_set_sim_state_c8_ental(S, st);
}

static void sf_opaque_terminate_c8_ental(void *chartInstanceVar)
{
  if (chartInstanceVar!=NULL) {
    SimStruct *S = ((SFc8_entalInstanceStruct*) chartInstanceVar)->S;
    if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
      sf_clear_rtw_identifier(S);
    }

    finalize_c8_ental((SFc8_entalInstanceStruct*) chartInstanceVar);
    free((void *)chartInstanceVar);
    ssSetUserData(S,NULL);
  }
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  compInitSubchartSimstructsFcn_c8_ental((SFc8_entalInstanceStruct*)
    chartInstanceVar);
}

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

  if (sf_machine_global_initializer_called()) {
    initialize_params_c8_ental((SFc8_entalInstanceStruct*)(((ChartInfoStruct *)
      ssGetUserData(S))->chartInstance));
  }
}

static void mdlSetWorkWidths_c8_ental(SimStruct *S)
{
  if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
    int_T chartIsInlinable =
      (int_T)sf_is_chart_inlinable(S,"ental","ental",8);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetRTWCG(S,sf_rtw_info_uint_prop(S,"ental","ental",8,"RTWCG"));
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop(S,"ental","ental",8,
      "gatewayCannotBeInlinedMultipleTimes"));
    if (chartIsInlinable) {
      sf_mark_chart_reusable_outputs(S,"ental","ental",8,1);
    }

    sf_set_rtw_dwork_info(S,"ental","ental",8);
    ssSetHasSubFunctions(S,!(chartIsInlinable));
  } else {
  }

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(3983613792U));
  ssSetChecksum1(S,(3236371148U));
  ssSetChecksum2(S,(3347972221U));
  ssSetChecksum3(S,(4076023440U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
}

static void mdlRTW_c8_ental(SimStruct *S)
{
  if (sim_mode_is_rtw_gen(S)) {
    sf_write_symbol_mapping(S, "ental", "ental",8);
    ssWriteRTWStrParam(S, "StateflowChartType", "Embedded MATLAB");
  }
}

static void mdlStart_c8_ental(SimStruct *S)
{
  SFc8_entalInstanceStruct *chartInstance;
  chartInstance = (SFc8_entalInstanceStruct *)malloc(sizeof
    (SFc8_entalInstanceStruct));
  memset(chartInstance, 0, sizeof(SFc8_entalInstanceStruct));
  if (chartInstance==NULL) {
    sf_mex_error_message("Could not allocate memory for chart instance.");
  }

  chartInstance->chartInfo.chartInstance = chartInstance;
  chartInstance->chartInfo.isEMLChart = 1;
  chartInstance->chartInfo.chartInitialized = 0;
  chartInstance->chartInfo.sFunctionGateway = sf_opaque_gateway_c8_ental;
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c8_ental;
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c8_ental;
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c8_ental;
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c8_ental;
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c8_ental;
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c8_ental;
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c8_ental;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c8_ental;
  chartInstance->chartInfo.mdlStart = mdlStart_c8_ental;
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c8_ental;
  chartInstance->chartInfo.extModeExec = NULL;
  chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.storeCurrentConfiguration = NULL;
  chartInstance->S = S;
  ssSetUserData(S,(void *)(&(chartInstance->chartInfo)));/* 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 c8_ental_method_dispatcher(SimStruct *S, int_T method, void *data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c8_ental(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c8_ental(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c8_ental(S);
    break;

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