/* Include files */

#include "blascompat32.h"
#include "ental_sfun.h"
#include "c14_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 *c14_debug_family_names[4] = { "p", "nargin", "nargout",
  "beta" };

/* Function Declarations */
static void initialize_c14_ental(SFc14_entalInstanceStruct *chartInstance);
static void initialize_params_c14_ental(SFc14_entalInstanceStruct *chartInstance);
static void enable_c14_ental(SFc14_entalInstanceStruct *chartInstance);
static void disable_c14_ental(SFc14_entalInstanceStruct *chartInstance);
static void c14_update_debugger_state_c14_ental(SFc14_entalInstanceStruct
  *chartInstance);
static const mxArray *get_sim_state_c14_ental(SFc14_entalInstanceStruct
  *chartInstance);
static void set_sim_state_c14_ental(SFc14_entalInstanceStruct *chartInstance,
  const mxArray *c14_st);
static void finalize_c14_ental(SFc14_entalInstanceStruct *chartInstance);
static void sf_c14_ental(SFc14_entalInstanceStruct *chartInstance);
static void compInitSubchartSimstructsFcn_c14_ental(SFc14_entalInstanceStruct
  *chartInstance);
static void init_script_number_translation(uint32_T c14_machineNumber, uint32_T
  c14_chartNumber);
static const mxArray *c14_sf_marshall(void *chartInstanceVoid, void *c14_u);
static const mxArray *c14_b_sf_marshall(void *chartInstanceVoid, void *c14_u);
static const mxArray *c14_c_sf_marshall(void *chartInstanceVoid, void *c14_u);
static void c14_emlrt_marshallIn(SFc14_entalInstanceStruct *chartInstance, const
  mxArray *c14_beta, const char_T *c14_name, real_T c14_y[13]);
static uint8_T c14_b_emlrt_marshallIn(SFc14_entalInstanceStruct *chartInstance,
  const mxArray *c14_b_is_active_c14_ental, const char_T *c14_name);
static void init_dsm_address_info(SFc14_entalInstanceStruct *chartInstance);

/* Function Definitions */
static void initialize_c14_ental(SFc14_entalInstanceStruct *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  chartInstance->c14_is_active_c14_ental = 0U;
}

static void initialize_params_c14_ental(SFc14_entalInstanceStruct *chartInstance)
{
}

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

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

static void c14_update_debugger_state_c14_ental(SFc14_entalInstanceStruct
  *chartInstance)
{
}

static const mxArray *get_sim_state_c14_ental(SFc14_entalInstanceStruct
  *chartInstance)
{
  const mxArray *c14_st = NULL;
  const mxArray *c14_y = NULL;
  int32_T c14_i0;
  real_T c14_hoistedGlobal[13];
  int32_T c14_i1;
  real_T c14_u[13];
  const mxArray *c14_b_y = NULL;
  uint8_T c14_b_hoistedGlobal;
  uint8_T c14_b_u;
  const mxArray *c14_c_y = NULL;
  real_T (*c14_beta)[13];
  c14_beta = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  c14_st = NULL;
  c14_y = NULL;
  sf_mex_assign(&c14_y, sf_mex_createcellarray(2));
  for (c14_i0 = 0; c14_i0 < 13; c14_i0 = c14_i0 + 1) {
    c14_hoistedGlobal[c14_i0] = (*c14_beta)[c14_i0];
  }

  for (c14_i1 = 0; c14_i1 < 13; c14_i1 = c14_i1 + 1) {
    c14_u[c14_i1] = c14_hoistedGlobal[c14_i1];
  }

  c14_b_y = NULL;
  sf_mex_assign(&c14_b_y, sf_mex_create("y", c14_u, 0, 0U, 1U, 0U, 1, 13));
  sf_mex_setcell(c14_y, 0, c14_b_y);
  c14_b_hoistedGlobal = chartInstance->c14_is_active_c14_ental;
  c14_b_u = c14_b_hoistedGlobal;
  c14_c_y = NULL;
  sf_mex_assign(&c14_c_y, sf_mex_create("y", &c14_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c14_y, 1, c14_c_y);
  sf_mex_assign(&c14_st, c14_y);
  return c14_st;
}

static void set_sim_state_c14_ental(SFc14_entalInstanceStruct *chartInstance,
  const mxArray *c14_st)
{
  const mxArray *c14_u;
  real_T c14_dv0[13];
  int32_T c14_i2;
  real_T (*c14_beta)[13];
  c14_beta = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  chartInstance->c14_doneDoubleBufferReInit = TRUE;
  c14_u = sf_mex_dup(c14_st);
  c14_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c14_u, 0)),
                       "beta", c14_dv0);
  for (c14_i2 = 0; c14_i2 < 13; c14_i2 = c14_i2 + 1) {
    (*c14_beta)[c14_i2] = c14_dv0[c14_i2];
  }

  chartInstance->c14_is_active_c14_ental = c14_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c14_u, 1)),
    "is_active_c14_ental");
  sf_mex_destroy(&c14_u);
  c14_update_debugger_state_c14_ental(chartInstance);
  sf_mex_destroy(&c14_st);
}

static void finalize_c14_ental(SFc14_entalInstanceStruct *chartInstance)
{
}

static void sf_c14_ental(SFc14_entalInstanceStruct *chartInstance)
{
  int32_T c14_i3;
  int32_T c14_previousEvent;
  uint32_T c14_debug_family_var_map[4];
  static const char *c14_sv0[4] = { "p", "nargin", "nargout", "beta" };

  real_T c14_p;
  real_T c14_nargin = 0.0;
  real_T c14_nargout = 1.0;
  real_T c14_beta[13];
  int32_T c14_i4;
  int32_T c14_i5;
  real_T (*c14_b_beta)[13];
  c14_b_beta = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 13);
  for (c14_i3 = 0; c14_i3 < 13; c14_i3 = c14_i3 + 1) {
    _SFD_DATA_RANGE_CHECK((*c14_b_beta)[c14_i3], 0U);
  }

  c14_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 13);
  sf_debug_symbol_scope_push_eml(0U, 4U, 4U, c14_sv0, c14_debug_family_var_map);
  sf_debug_symbol_scope_add_eml(&c14_p, c14_b_sf_marshall, 0U);
  sf_debug_symbol_scope_add_eml(&c14_nargin, c14_b_sf_marshall, 1U);
  sf_debug_symbol_scope_add_eml(&c14_nargout, c14_b_sf_marshall, 2U);
  sf_debug_symbol_scope_add_eml(c14_beta, c14_sf_marshall, 3U);
  CV_EML_FCN(0, 0);
  _SFD_EML_CALL(0, 4);
  c14_p = 13.0;
  _SFD_EML_CALL(0, 5);
  for (c14_i4 = 0; c14_i4 < 13; c14_i4 = c14_i4 + 1) {
    c14_beta[c14_i4] = 0.5;
  }

  _SFD_EML_CALL(0, 7);
  c14_beta[0] = 0.5;
  _SFD_EML_CALL(0, 8);
  c14_beta[1] = 0.55;

  /* 2 nemam */
  _SFD_EML_CALL(0, 9);
  c14_beta[2] = 0.6;
  _SFD_EML_CALL(0, 10);
  c14_beta[3] = 0.7;
  _SFD_EML_CALL(0, 11);
  c14_beta[4] = 0.8;
  _SFD_EML_CALL(0, 13);
  c14_beta[5] = 0.99;
  _SFD_EML_CALL(0, 14);
  c14_beta[6] = 0.99;
  _SFD_EML_CALL(0, 15);
  c14_beta[7] = 0.99;
  _SFD_EML_CALL(0, 16);
  c14_beta[8] = 0.99;
  _SFD_EML_CALL(0, 17);
  c14_beta[9] = 0.99;
  _SFD_EML_CALL(0, 18);
  c14_beta[10] = 0.99;
  _SFD_EML_CALL(0, 19);
  c14_beta[11] = 0.99;
  _SFD_EML_CALL(0, 20);
  c14_beta[12] = 0.99;
  _SFD_EML_CALL(0, -20);
  sf_debug_symbol_scope_pop();
  for (c14_i5 = 0; c14_i5 < 13; c14_i5 = c14_i5 + 1) {
    (*c14_b_beta)[c14_i5] = c14_beta[c14_i5];
  }

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

static void compInitSubchartSimstructsFcn_c14_ental(SFc14_entalInstanceStruct
  *chartInstance)
{
}

static void init_script_number_translation(uint32_T c14_machineNumber, uint32_T
  c14_chartNumber)
{
}

static const mxArray *c14_sf_marshall(void *chartInstanceVoid, void *c14_u)
{
  const mxArray *c14_y = NULL;
  int32_T c14_i6;
  real_T c14_b_u[13];
  int32_T c14_i7;
  real_T c14_c_u[13];
  const mxArray *c14_b_y = NULL;
  SFc14_entalInstanceStruct *chartInstance;
  chartInstance = (SFc14_entalInstanceStruct *)chartInstanceVoid;
  c14_y = NULL;
  for (c14_i6 = 0; c14_i6 < 13; c14_i6 = c14_i6 + 1) {
    c14_b_u[c14_i6] = (*((real_T (*)[13])c14_u))[c14_i6];
  }

  for (c14_i7 = 0; c14_i7 < 13; c14_i7 = c14_i7 + 1) {
    c14_c_u[c14_i7] = c14_b_u[c14_i7];
  }

  c14_b_y = NULL;
  sf_mex_assign(&c14_b_y, sf_mex_create("y", c14_c_u, 0, 0U, 1U, 0U, 1, 13));
  sf_mex_assign(&c14_y, c14_b_y);
  return c14_y;
}

static const mxArray *c14_b_sf_marshall(void *chartInstanceVoid, void *c14_u)
{
  const mxArray *c14_y = NULL;
  real_T c14_b_u;
  const mxArray *c14_b_y = NULL;
  SFc14_entalInstanceStruct *chartInstance;
  chartInstance = (SFc14_entalInstanceStruct *)chartInstanceVoid;
  c14_y = NULL;
  c14_b_u = *((real_T *)c14_u);
  c14_b_y = NULL;
  sf_mex_assign(&c14_b_y, sf_mex_create("y", &c14_b_u, 0, 0U, 0U, 0U, 0));
  sf_mex_assign(&c14_y, c14_b_y);
  return c14_y;
}

const mxArray *sf_c14_ental_get_eml_resolved_functions_info(void)
{
  const mxArray *c14_nameCaptureInfo = NULL;
  c14_ResolvedFunctionInfo c14_info[11];
  c14_ResolvedFunctionInfo (*c14_b_info)[11];
  const mxArray *c14_m0 = NULL;
  int32_T c14_i8;
  c14_ResolvedFunctionInfo *c14_r0;
  c14_nameCaptureInfo = NULL;
  c14_b_info = (c14_ResolvedFunctionInfo (*)[11])c14_info;
  (*c14_b_info)[0].context = "";
  (*c14_b_info)[0].name = "ones";
  (*c14_b_info)[0].dominantType = "double";
  (*c14_b_info)[0].resolved = "[B]ones";
  (*c14_b_info)[0].fileLength = 0U;
  (*c14_b_info)[0].fileTime1 = 0U;
  (*c14_b_info)[0].fileTime2 = 0U;
  (*c14_b_info)[1].context = "";
  (*c14_b_info)[1].name = "mrdivide";
  (*c14_b_info)[1].dominantType = "double";
  (*c14_b_info)[1].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c14_b_info)[1].fileLength = 432U;
  (*c14_b_info)[1].fileTime1 = 1277748222U;
  (*c14_b_info)[1].fileTime2 = 0U;
  (*c14_b_info)[2].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c14_b_info)[2].name = "nargin";
  (*c14_b_info)[2].dominantType = "";
  (*c14_b_info)[2].resolved = "[B]nargin";
  (*c14_b_info)[2].fileLength = 0U;
  (*c14_b_info)[2].fileTime1 = 0U;
  (*c14_b_info)[2].fileTime2 = 0U;
  (*c14_b_info)[3].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c14_b_info)[3].name = "ge";
  (*c14_b_info)[3].dominantType = "double";
  (*c14_b_info)[3].resolved = "[B]ge";
  (*c14_b_info)[3].fileLength = 0U;
  (*c14_b_info)[3].fileTime1 = 0U;
  (*c14_b_info)[3].fileTime2 = 0U;
  (*c14_b_info)[4].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c14_b_info)[4].name = "isscalar";
  (*c14_b_info)[4].dominantType = "double";
  (*c14_b_info)[4].resolved = "[B]isscalar";
  (*c14_b_info)[4].fileLength = 0U;
  (*c14_b_info)[4].fileTime1 = 0U;
  (*c14_b_info)[4].fileTime2 = 0U;
  (*c14_b_info)[5].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c14_b_info)[5].name = "rdivide";
  (*c14_b_info)[5].dominantType = "double";
  (*c14_b_info)[5].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c14_b_info)[5].fileLength = 403U;
  (*c14_b_info)[5].fileTime1 = 1245102420U;
  (*c14_b_info)[5].fileTime2 = 0U;
  (*c14_b_info)[6].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c14_b_info)[6].name = "gt";
  (*c14_b_info)[6].dominantType = "double";
  (*c14_b_info)[6].resolved = "[B]gt";
  (*c14_b_info)[6].fileLength = 0U;
  (*c14_b_info)[6].fileTime1 = 0U;
  (*c14_b_info)[6].fileTime2 = 0U;
  (*c14_b_info)[7].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c14_b_info)[7].name = "isa";
  (*c14_b_info)[7].dominantType = "double";
  (*c14_b_info)[7].resolved = "[B]isa";
  (*c14_b_info)[7].fileLength = 0U;
  (*c14_b_info)[7].fileTime1 = 0U;
  (*c14_b_info)[7].fileTime2 = 0U;
  (*c14_b_info)[8].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c14_b_info)[8].name = "eml_div";
  (*c14_b_info)[8].dominantType = "double";
  (*c14_b_info)[8].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  (*c14_b_info)[8].fileLength = 4918U;
  (*c14_b_info)[8].fileTime1 = 1267063410U;
  (*c14_b_info)[8].fileTime2 = 0U;
  (*c14_b_info)[9].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  (*c14_b_info)[9].name = "isinteger";
  (*c14_b_info)[9].dominantType = "double";
  (*c14_b_info)[9].resolved = "[B]isinteger";
  (*c14_b_info)[9].fileLength = 0U;
  (*c14_b_info)[9].fileTime1 = 0U;
  (*c14_b_info)[9].fileTime2 = 0U;
  (*c14_b_info)[10].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m!eml_fldiv";
  (*c14_b_info)[10].name = "isreal";
  (*c14_b_info)[10].dominantType = "double";
  (*c14_b_info)[10].resolved = "[B]isreal";
  (*c14_b_info)[10].fileLength = 0U;
  (*c14_b_info)[10].fileTime1 = 0U;
  (*c14_b_info)[10].fileTime2 = 0U;
  sf_mex_assign(&c14_m0, sf_mex_createstruct("nameCaptureInfo", 1, 11));
  for (c14_i8 = 0; c14_i8 < 11; c14_i8 = c14_i8 + 1) {
    c14_r0 = &c14_info[c14_i8];
    sf_mex_addfield(c14_m0, sf_mex_create("nameCaptureInfo", c14_r0->context, 15,
      0U, 0U, 0U, 2, 1, strlen(c14_r0->context)), "context"
                    , "nameCaptureInfo", c14_i8);
    sf_mex_addfield(c14_m0, sf_mex_create("nameCaptureInfo", c14_r0->name, 15,
      0U, 0U, 0U, 2, 1, strlen(c14_r0->name)), "name",
                    "nameCaptureInfo", c14_i8);
    sf_mex_addfield(c14_m0, sf_mex_create("nameCaptureInfo",
      c14_r0->dominantType, 15, 0U, 0U, 0U, 2, 1, strlen(c14_r0->dominantType)),
                    "dominantType", "nameCaptureInfo", c14_i8);
    sf_mex_addfield(c14_m0, sf_mex_create("nameCaptureInfo", c14_r0->resolved,
      15, 0U, 0U, 0U, 2, 1, strlen(c14_r0->resolved)),
                    "resolved", "nameCaptureInfo", c14_i8);
    sf_mex_addfield(c14_m0, sf_mex_create("nameCaptureInfo", &c14_r0->fileLength,
      7, 0U, 0U, 0U, 0), "fileLength", "nameCaptureInfo",
                    c14_i8);
    sf_mex_addfield(c14_m0, sf_mex_create("nameCaptureInfo", &c14_r0->fileTime1,
      7, 0U, 0U, 0U, 0), "fileTime1", "nameCaptureInfo",
                    c14_i8);
    sf_mex_addfield(c14_m0, sf_mex_create("nameCaptureInfo", &c14_r0->fileTime2,
      7, 0U, 0U, 0U, 0), "fileTime2", "nameCaptureInfo",
                    c14_i8);
  }

  sf_mex_assign(&c14_nameCaptureInfo, c14_m0);
  return c14_nameCaptureInfo;
}

static const mxArray *c14_c_sf_marshall(void *chartInstanceVoid, void *c14_u)
{
  const mxArray *c14_y = NULL;
  boolean_T c14_b_u;
  const mxArray *c14_b_y = NULL;
  SFc14_entalInstanceStruct *chartInstance;
  chartInstance = (SFc14_entalInstanceStruct *)chartInstanceVoid;
  c14_y = NULL;
  c14_b_u = *((boolean_T *)c14_u);
  c14_b_y = NULL;
  sf_mex_assign(&c14_b_y, sf_mex_create("y", &c14_b_u, 11, 0U, 0U, 0U, 0));
  sf_mex_assign(&c14_y, c14_b_y);
  return c14_y;
}

static void c14_emlrt_marshallIn(SFc14_entalInstanceStruct *chartInstance, const
  mxArray *c14_beta, const char_T *c14_name, real_T
  c14_y[13])
{
  real_T c14_dv1[13];
  int32_T c14_i9;
  sf_mex_import(c14_name, sf_mex_dup(c14_beta), c14_dv1, 1, 0, 0U, 1, 0U, 1, 13);
  for (c14_i9 = 0; c14_i9 < 13; c14_i9 = c14_i9 + 1) {
    c14_y[c14_i9] = c14_dv1[c14_i9];
  }

  sf_mex_destroy(&c14_beta);
}

static uint8_T c14_b_emlrt_marshallIn(SFc14_entalInstanceStruct *chartInstance,
  const mxArray *c14_b_is_active_c14_ental, const
  char_T *c14_name)
{
  uint8_T c14_y;
  uint8_T c14_u0;
  sf_mex_import(c14_name, sf_mex_dup(c14_b_is_active_c14_ental), &c14_u0, 1, 3,
                0U, 0, 0U, 0);
  c14_y = c14_u0;
  sf_mex_destroy(&c14_b_is_active_c14_ental);
  return c14_y;
}

static void init_dsm_address_info(SFc14_entalInstanceStruct *chartInstance)
{
}

/* SFunction Glue Code */
void sf_c14_ental_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1006588569U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(423593351U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(1965860645U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(881481850U);
}

mxArray *sf_c14_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)(4077071758U);
    pr[1] = (double)(4071205321U);
    pr[2] = (double)(3188751512U);
    pr[3] = (double)(3027897888U);
    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_c14_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\"beta\",},{M[8],M[0],T\"is_active_c14_ental\",}}"
  };

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 2, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c14_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)) {
    SFc14_entalInstanceStruct *chartInstance;
    chartInstance = (SFc14_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_,
          14,
          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,"beta");
          _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,256);
        _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)c14_sf_marshall);
        }

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

static void sf_opaque_initialize_c14_ental(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc14_entalInstanceStruct*) chartInstanceVar)->S,
    0);
  initialize_params_c14_ental((SFc14_entalInstanceStruct*) chartInstanceVar);
  initialize_c14_ental((SFc14_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_enable_c14_ental(void *chartInstanceVar)
{
  enable_c14_ental((SFc14_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_disable_c14_ental(void *chartInstanceVar)
{
  disable_c14_ental((SFc14_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_gateway_c14_ental(void *chartInstanceVar)
{
  sf_c14_ental((SFc14_entalInstanceStruct*) chartInstanceVar);
}

static mxArray* sf_internal_get_sim_state_c14_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_c14_ental((SFc14_entalInstanceStruct*)
    chartInfo->chartInstance);         /* raw sim ctx */
  prhs[3] = sf_get_sim_state_info_c14_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_c14_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_c14_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_c14_ental((SFc14_entalInstanceStruct*)chartInfo->chartInstance,
    mxDuplicateArray(plhs[0]));
  mxDestroyArray(plhs[0]);
}

static mxArray* sf_opaque_get_sim_state_c14_ental(SimStruct* S)
{
  return sf_internal_get_sim_state_c14_ental(S);
}

static void sf_opaque_set_sim_state_c14_ental(SimStruct* S, const mxArray *st)
{
  sf_internal_set_sim_state_c14_ental(S, st);
}

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

    finalize_c14_ental((SFc14_entalInstanceStruct*) chartInstanceVar);
    free((void *)chartInstanceVar);
    ssSetUserData(S,NULL);
  }
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  compInitSubchartSimstructsFcn_c14_ental((SFc14_entalInstanceStruct*)
    chartInstanceVar);
}

extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c14_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_c14_ental((SFc14_entalInstanceStruct*)(((ChartInfoStruct *)
      ssGetUserData(S))->chartInstance));
  }
}

static void mdlSetWorkWidths_c14_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",14);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetRTWCG(S,sf_rtw_info_uint_prop(S,"ental","ental",14,"RTWCG"));
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop(S,"ental","ental",14,
      "gatewayCannotBeInlinedMultipleTimes"));
    if (chartIsInlinable) {
      sf_mark_chart_reusable_outputs(S,"ental","ental",14,1);
    }

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

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(3741335915U));
  ssSetChecksum1(S,(1399492006U));
  ssSetChecksum2(S,(122133382U));
  ssSetChecksum3(S,(1137514804U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
}

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

static void mdlStart_c14_ental(SimStruct *S)
{
  SFc14_entalInstanceStruct *chartInstance;
  chartInstance = (SFc14_entalInstanceStruct *)malloc(sizeof
    (SFc14_entalInstanceStruct));
  memset(chartInstance, 0, sizeof(SFc14_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_c14_ental;
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c14_ental;
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c14_ental;
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c14_ental;
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c14_ental;
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c14_ental;
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c14_ental;
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c14_ental;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c14_ental;
  chartInstance->chartInfo.mdlStart = mdlStart_c14_ental;
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c14_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 c14_ental_method_dispatcher(SimStruct *S, int_T method, void *data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c14_ental(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c14_ental(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c14_ental(S);
    break;

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