/* Include files */

#include "blascompat32.h"
#include "ental_sfun.h"
#include "c5_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 *c5_debug_family_names[11] = { "M", "N", "Md", "j", "d", "hhs",
  "nargin", "nargout", "uu", "Ts", "m" };

/* Function Declarations */
static void initialize_c5_ental(SFc5_entalInstanceStruct *chartInstance);
static void initialize_params_c5_ental(SFc5_entalInstanceStruct *chartInstance);
static void enable_c5_ental(SFc5_entalInstanceStruct *chartInstance);
static void disable_c5_ental(SFc5_entalInstanceStruct *chartInstance);
static void c5_update_debugger_state_c5_ental(SFc5_entalInstanceStruct
  *chartInstance);
static const mxArray *get_sim_state_c5_ental(SFc5_entalInstanceStruct
  *chartInstance);
static void set_sim_state_c5_ental(SFc5_entalInstanceStruct *chartInstance,
  const mxArray *c5_st);
static void finalize_c5_ental(SFc5_entalInstanceStruct *chartInstance);
static void sf_c5_ental(SFc5_entalInstanceStruct *chartInstance);
static void compInitSubchartSimstructsFcn_c5_ental(SFc5_entalInstanceStruct
  *chartInstance);
static void init_script_number_translation(uint32_T c5_machineNumber, uint32_T
  c5_chartNumber);
static const mxArray *c5_sf_marshall(void *chartInstanceVoid, void *c5_u);
static const mxArray *c5_b_sf_marshall(void *chartInstanceVoid, void *c5_u);
static const mxArray *c5_c_sf_marshall(void *chartInstanceVoid, void *c5_u);
static void c5_info_helper(c5_ResolvedFunctionInfo c5_info[22]);
static const mxArray *c5_d_sf_marshall(void *chartInstanceVoid, void *c5_u);
static real_T c5_emlrt_marshallIn(SFc5_entalInstanceStruct *chartInstance, const
  mxArray *c5_m, const char_T *c5_name);
static uint8_T c5_b_emlrt_marshallIn(SFc5_entalInstanceStruct *chartInstance,
  const mxArray *c5_b_is_active_c5_ental, const char_T *c5_name);
static void init_dsm_address_info(SFc5_entalInstanceStruct *chartInstance);

/* Function Definitions */
static void initialize_c5_ental(SFc5_entalInstanceStruct *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  chartInstance->c5_is_active_c5_ental = 0U;
}

static void initialize_params_c5_ental(SFc5_entalInstanceStruct *chartInstance)
{
}

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

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

static void c5_update_debugger_state_c5_ental(SFc5_entalInstanceStruct
  *chartInstance)
{
}

static const mxArray *get_sim_state_c5_ental(SFc5_entalInstanceStruct
  *chartInstance)
{
  const mxArray *c5_st = NULL;
  const mxArray *c5_y = NULL;
  real_T c5_hoistedGlobal;
  real_T c5_u;
  const mxArray *c5_b_y = NULL;
  uint8_T c5_b_hoistedGlobal;
  uint8_T c5_b_u;
  const mxArray *c5_c_y = NULL;
  real_T *c5_m;
  c5_m = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  c5_st = NULL;
  c5_y = NULL;
  sf_mex_assign(&c5_y, sf_mex_createcellarray(2));
  c5_hoistedGlobal = *c5_m;
  c5_u = c5_hoistedGlobal;
  c5_b_y = NULL;
  sf_mex_assign(&c5_b_y, sf_mex_create("y", &c5_u, 0, 0U, 0U, 0U, 0));
  sf_mex_setcell(c5_y, 0, c5_b_y);
  c5_b_hoistedGlobal = chartInstance->c5_is_active_c5_ental;
  c5_b_u = c5_b_hoistedGlobal;
  c5_c_y = NULL;
  sf_mex_assign(&c5_c_y, sf_mex_create("y", &c5_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c5_y, 1, c5_c_y);
  sf_mex_assign(&c5_st, c5_y);
  return c5_st;
}

static void set_sim_state_c5_ental(SFc5_entalInstanceStruct *chartInstance,
  const mxArray *c5_st)
{
  const mxArray *c5_u;
  real_T *c5_m;
  c5_m = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  chartInstance->c5_doneDoubleBufferReInit = TRUE;
  c5_u = sf_mex_dup(c5_st);
  *c5_m = c5_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c5_u, 0)),
    "m");
  chartInstance->c5_is_active_c5_ental = c5_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c5_u, 1)),
    "is_active_c5_ental");
  sf_mex_destroy(&c5_u);
  c5_update_debugger_state_c5_ental(chartInstance);
  sf_mex_destroy(&c5_st);
}

static void finalize_c5_ental(SFc5_entalInstanceStruct *chartInstance)
{
}

static void sf_c5_ental(SFc5_entalInstanceStruct *chartInstance)
{
  int32_T c5_i0;
  int32_T c5_previousEvent;
  int32_T c5_i1;
  real_T c5_hoistedGlobal[7185];
  real_T c5_b_hoistedGlobal;
  int32_T c5_i2;
  real_T c5_uu[7185];
  real_T c5_Ts;
  uint32_T c5_debug_family_var_map[11];
  static const char *c5_sv0[11] = { "M", "N", "Md", "j", "d", "hhs", "nargin",
    "nargout", "uu", "Ts", "m" };

  real_T c5_M;
  real_T c5_N;
  real_T c5_Md[479];
  real_T c5_j;
  real_T c5_d;
  real_T c5_hhs;
  real_T c5_nargin = 2.0;
  real_T c5_nargout = 1.0;
  real_T c5_m;
  int32_T c5_i3;
  int32_T c5_i4;
  real_T c5_b_j;
  real_T c5_A;
  real_T c5_B;
  real_T c5_x;
  real_T c5_y;
  real_T c5_b_x;
  real_T c5_b_y;
  real_T c5_c_x;
  real_T c5_c_y;
  real_T c5_b;
  real_T *c5_b_m;
  real_T *c5_b_Ts;
  real_T (*c5_b_uu)[7185];
  c5_b_Ts = (real_T *)ssGetInputPortSignal(chartInstance->S, 1);
  c5_b_uu = (real_T (*)[7185])ssGetInputPortSignal(chartInstance->S, 0);
  c5_b_m = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 4);
  _SFD_DATA_RANGE_CHECK(*c5_b_m, 0U);
  for (c5_i0 = 0; c5_i0 < 7185; c5_i0 = c5_i0 + 1) {
    _SFD_DATA_RANGE_CHECK((*c5_b_uu)[c5_i0], 1U);
  }

  _SFD_DATA_RANGE_CHECK(*c5_b_Ts, 2U);
  c5_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 4);
  for (c5_i1 = 0; c5_i1 < 7185; c5_i1 = c5_i1 + 1) {
    c5_hoistedGlobal[c5_i1] = (*c5_b_uu)[c5_i1];
  }

  c5_b_hoistedGlobal = *c5_b_Ts;
  for (c5_i2 = 0; c5_i2 < 7185; c5_i2 = c5_i2 + 1) {
    c5_uu[c5_i2] = c5_hoistedGlobal[c5_i2];
  }

  c5_Ts = c5_b_hoistedGlobal;
  sf_debug_symbol_scope_push_eml(0U, 11U, 11U, c5_sv0, c5_debug_family_var_map);
  sf_debug_symbol_scope_add_eml(&c5_M, c5_sf_marshall, 0U);
  sf_debug_symbol_scope_add_eml(&c5_N, c5_sf_marshall, 1U);
  sf_debug_symbol_scope_add_eml(c5_Md, c5_c_sf_marshall, 2U);
  sf_debug_symbol_scope_add_eml(&c5_j, c5_sf_marshall, 3U);
  sf_debug_symbol_scope_add_eml(&c5_d, c5_sf_marshall, 4U);
  sf_debug_symbol_scope_add_eml(&c5_hhs, c5_sf_marshall, 5U);
  sf_debug_symbol_scope_add_eml(&c5_nargin, c5_sf_marshall, 6U);
  sf_debug_symbol_scope_add_eml(&c5_nargout, c5_sf_marshall, 7U);
  sf_debug_symbol_scope_add_eml(c5_uu, c5_b_sf_marshall, 8U);
  sf_debug_symbol_scope_add_eml(&c5_Ts, c5_sf_marshall, 9U);
  sf_debug_symbol_scope_add_eml(&c5_m, c5_sf_marshall, 10U);
  CV_EML_FCN(0, 0);

  /* M=15;N=479; */
  _SFD_EML_CALL(0, 4);
  c5_M = 15.0;
  c5_N = 479.0;
  _SFD_EML_CALL(0, 5);
  c5_i3 = 0;
  for (c5_i4 = 0; c5_i4 < 479; c5_i4 = c5_i4 + 1) {
    c5_Md[c5_i4] = c5_uu[c5_i3 + 7];
    c5_i3 = c5_i3 + 15;
  }

  _SFD_EML_CALL(0, 6);
  c5_m = 0.0;
  c5_j = 1.0;
  c5_b_j = 1.0;
 label_1:
  ;
  if (c5_b_j <= 479.0) {
    c5_j = c5_b_j;
    CV_EML_FOR(0, 0, 1);
    _SFD_EML_CALL(0, 8);
    if (CV_EML_IF(0, 0, c5_Ts >= c5_Md[_SFD_EML_ARRAY_BOUNDS_CHECK("Md",
          (int32_T)_SFD_INTEGER_CHECK("j", c5_j), 1, 479, 1, 0) - 1])) {
      _SFD_EML_CALL(0, 9);
      c5_A = c5_uu[7 + 15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("uu", (int32_T)
        _SFD_INTEGER_CHECK("j-1", c5_j - 1.0), 1, 479, 2, 0) - 1)] - c5_Ts;
      c5_B = c5_uu[7 + 15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("uu", (int32_T)
        _SFD_INTEGER_CHECK("j-1", c5_j - 1.0), 1, 479, 2, 0) - 1)] - c5_uu
        [7 + 15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("uu", (int32_T)_SFD_INTEGER_CHECK
                    ("j", c5_j), 1, 479, 2, 0) - 1)];
      c5_x = c5_A;
      c5_y = c5_B;
      c5_b_x = c5_x;
      c5_b_y = c5_y;
      c5_c_x = c5_b_x;
      c5_c_y = c5_b_y;
      c5_d = c5_c_x / c5_c_y;

      /* interpolace metalurgicke delky */
      _SFD_EML_CALL(0, 10);
      c5_hhs = (c5_j - 1.0) + c5_d;
      _SFD_EML_CALL(0, 11);
      c5_b = c5_hhs;
      c5_m = 0.050348643006263051 * c5_b;
    } else {
      c5_b_j = c5_b_j + 1.0;
      sf_mex_listen_for_ctrl_c(chartInstance->S);
      goto label_1;
    }
  } else {
    CV_EML_FOR(0, 0, 0);
  }

  _SFD_EML_CALL(0, -11);
  sf_debug_symbol_scope_pop();
  *c5_b_m = c5_m;
  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 4);
  _sfEvent_ = c5_previousEvent;
  sf_debug_check_for_state_inconsistency(_entalMachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}

static void compInitSubchartSimstructsFcn_c5_ental(SFc5_entalInstanceStruct
  *chartInstance)
{
}

static void init_script_number_translation(uint32_T c5_machineNumber, uint32_T
  c5_chartNumber)
{
}

static const mxArray *c5_sf_marshall(void *chartInstanceVoid, void *c5_u)
{
  const mxArray *c5_y = NULL;
  real_T c5_b_u;
  const mxArray *c5_b_y = NULL;
  SFc5_entalInstanceStruct *chartInstance;
  chartInstance = (SFc5_entalInstanceStruct *)chartInstanceVoid;
  c5_y = NULL;
  c5_b_u = *((real_T *)c5_u);
  c5_b_y = NULL;
  sf_mex_assign(&c5_b_y, sf_mex_create("y", &c5_b_u, 0, 0U, 0U, 0U, 0));
  sf_mex_assign(&c5_y, c5_b_y);
  return c5_y;
}

static const mxArray *c5_b_sf_marshall(void *chartInstanceVoid, void *c5_u)
{
  const mxArray *c5_y = NULL;
  int32_T c5_i5;
  int32_T c5_i6;
  int32_T c5_i7;
  real_T c5_b_u[7185];
  int32_T c5_i8;
  int32_T c5_i9;
  int32_T c5_i10;
  real_T c5_c_u[7185];
  const mxArray *c5_b_y = NULL;
  SFc5_entalInstanceStruct *chartInstance;
  chartInstance = (SFc5_entalInstanceStruct *)chartInstanceVoid;
  c5_y = NULL;
  c5_i5 = 0;
  for (c5_i6 = 0; c5_i6 < 479; c5_i6 = c5_i6 + 1) {
    for (c5_i7 = 0; c5_i7 < 15; c5_i7 = c5_i7 + 1) {
      c5_b_u[c5_i7 + c5_i5] = (*((real_T (*)[7185])c5_u))[c5_i7 + c5_i5];
    }

    c5_i5 = c5_i5 + 15;
  }

  c5_i8 = 0;
  for (c5_i9 = 0; c5_i9 < 479; c5_i9 = c5_i9 + 1) {
    for (c5_i10 = 0; c5_i10 < 15; c5_i10 = c5_i10 + 1) {
      c5_c_u[c5_i10 + c5_i8] = c5_b_u[c5_i10 + c5_i8];
    }

    c5_i8 = c5_i8 + 15;
  }

  c5_b_y = NULL;
  sf_mex_assign(&c5_b_y, sf_mex_create("y", c5_c_u, 0, 0U, 1U, 0U, 2, 15, 479));
  sf_mex_assign(&c5_y, c5_b_y);
  return c5_y;
}

static const mxArray *c5_c_sf_marshall(void *chartInstanceVoid, void *c5_u)
{
  const mxArray *c5_y = NULL;
  int32_T c5_i11;
  real_T c5_b_u[479];
  int32_T c5_i12;
  real_T c5_c_u[479];
  const mxArray *c5_b_y = NULL;
  SFc5_entalInstanceStruct *chartInstance;
  chartInstance = (SFc5_entalInstanceStruct *)chartInstanceVoid;
  c5_y = NULL;
  for (c5_i11 = 0; c5_i11 < 479; c5_i11 = c5_i11 + 1) {
    c5_b_u[c5_i11] = (*((real_T (*)[479])c5_u))[c5_i11];
  }

  for (c5_i12 = 0; c5_i12 < 479; c5_i12 = c5_i12 + 1) {
    c5_c_u[c5_i12] = c5_b_u[c5_i12];
  }

  c5_b_y = NULL;
  sf_mex_assign(&c5_b_y, sf_mex_create("y", c5_c_u, 0, 0U, 1U, 0U, 2, 1, 479));
  sf_mex_assign(&c5_y, c5_b_y);
  return c5_y;
}

const mxArray *sf_c5_ental_get_eml_resolved_functions_info(void)
{
  const mxArray *c5_nameCaptureInfo = NULL;
  c5_ResolvedFunctionInfo c5_info[22];
  const mxArray *c5_m0 = NULL;
  int32_T c5_i13;
  c5_ResolvedFunctionInfo *c5_r0;
  c5_nameCaptureInfo = NULL;
  c5_info_helper(c5_info);
  sf_mex_assign(&c5_m0, sf_mex_createstruct("nameCaptureInfo", 1, 22));
  for (c5_i13 = 0; c5_i13 < 22; c5_i13 = c5_i13 + 1) {
    c5_r0 = &c5_info[c5_i13];
    sf_mex_addfield(c5_m0, sf_mex_create("nameCaptureInfo", c5_r0->context, 15,
      0U, 0U, 0U, 2, 1, strlen(c5_r0->context)), "context",
                    "nameCaptureInfo", c5_i13);
    sf_mex_addfield(c5_m0, sf_mex_create("nameCaptureInfo", c5_r0->name, 15, 0U,
      0U, 0U, 2, 1, strlen(c5_r0->name)), "name",
                    "nameCaptureInfo", c5_i13);
    sf_mex_addfield(c5_m0, sf_mex_create("nameCaptureInfo", c5_r0->dominantType,
      15, 0U, 0U, 0U, 2, 1, strlen(c5_r0->dominantType)),
                    "dominantType", "nameCaptureInfo", c5_i13);
    sf_mex_addfield(c5_m0, sf_mex_create("nameCaptureInfo", c5_r0->resolved, 15,
      0U, 0U, 0U, 2, 1, strlen(c5_r0->resolved)), "resolved"
                    , "nameCaptureInfo", c5_i13);
    sf_mex_addfield(c5_m0, sf_mex_create("nameCaptureInfo", &c5_r0->fileLength,
      7, 0U, 0U, 0U, 0), "fileLength", "nameCaptureInfo",
                    c5_i13);
    sf_mex_addfield(c5_m0, sf_mex_create("nameCaptureInfo", &c5_r0->fileTime1, 7,
      0U, 0U, 0U, 0), "fileTime1", "nameCaptureInfo", c5_i13
                    );
    sf_mex_addfield(c5_m0, sf_mex_create("nameCaptureInfo", &c5_r0->fileTime2, 7,
      0U, 0U, 0U, 0), "fileTime2", "nameCaptureInfo", c5_i13
                    );
  }

  sf_mex_assign(&c5_nameCaptureInfo, c5_m0);
  return c5_nameCaptureInfo;
}

static void c5_info_helper(c5_ResolvedFunctionInfo c5_info[22])
{
  c5_info[0].context = "";
  c5_info[0].name = "size";
  c5_info[0].dominantType = "double";
  c5_info[0].resolved = "[B]size";
  c5_info[0].fileLength = 0U;
  c5_info[0].fileTime1 = 0U;
  c5_info[0].fileTime2 = 0U;
  c5_info[1].context = "";
  c5_info[1].name = "mrdivide";
  c5_info[1].dominantType = "double";
  c5_info[1].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c5_info[1].fileLength = 432U;
  c5_info[1].fileTime1 = 1277748222U;
  c5_info[1].fileTime2 = 0U;
  c5_info[2].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c5_info[2].name = "nargin";
  c5_info[2].dominantType = "";
  c5_info[2].resolved = "[B]nargin";
  c5_info[2].fileLength = 0U;
  c5_info[2].fileTime1 = 0U;
  c5_info[2].fileTime2 = 0U;
  c5_info[3].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c5_info[3].name = "ge";
  c5_info[3].dominantType = "double";
  c5_info[3].resolved = "[B]ge";
  c5_info[3].fileLength = 0U;
  c5_info[3].fileTime1 = 0U;
  c5_info[3].fileTime2 = 0U;
  c5_info[4].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c5_info[4].name = "isscalar";
  c5_info[4].dominantType = "double";
  c5_info[4].resolved = "[B]isscalar";
  c5_info[4].fileLength = 0U;
  c5_info[4].fileTime1 = 0U;
  c5_info[4].fileTime2 = 0U;
  c5_info[5].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c5_info[5].name = "rdivide";
  c5_info[5].dominantType = "double";
  c5_info[5].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  c5_info[5].fileLength = 403U;
  c5_info[5].fileTime1 = 1245102420U;
  c5_info[5].fileTime2 = 0U;
  c5_info[6].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  c5_info[6].name = "gt";
  c5_info[6].dominantType = "double";
  c5_info[6].resolved = "[B]gt";
  c5_info[6].fileLength = 0U;
  c5_info[6].fileTime1 = 0U;
  c5_info[6].fileTime2 = 0U;
  c5_info[7].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  c5_info[7].name = "isa";
  c5_info[7].dominantType = "double";
  c5_info[7].resolved = "[B]isa";
  c5_info[7].fileLength = 0U;
  c5_info[7].fileTime1 = 0U;
  c5_info[7].fileTime2 = 0U;
  c5_info[8].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  c5_info[8].name = "eml_div";
  c5_info[8].dominantType = "double";
  c5_info[8].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  c5_info[8].fileLength = 4918U;
  c5_info[8].fileTime1 = 1267063410U;
  c5_info[8].fileTime2 = 0U;
  c5_info[9].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  c5_info[9].name = "isinteger";
  c5_info[9].dominantType = "double";
  c5_info[9].resolved = "[B]isinteger";
  c5_info[9].fileLength = 0U;
  c5_info[9].fileTime1 = 0U;
  c5_info[9].fileTime2 = 0U;
  c5_info[10].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m!eml_fldiv";
  c5_info[10].name = "isreal";
  c5_info[10].dominantType = "double";
  c5_info[10].resolved = "[B]isreal";
  c5_info[10].fileLength = 0U;
  c5_info[10].fileTime1 = 0U;
  c5_info[10].fileTime2 = 0U;
  c5_info[11].context = "";
  c5_info[11].name = "round";
  c5_info[11].dominantType = "double";
  c5_info[11].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/round.m";
  c5_info[11].fileLength = 331U;
  c5_info[11].fileTime1 = 1203448036U;
  c5_info[11].fileTime2 = 0U;
  c5_info[12].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/round.m";
  c5_info[12].name = "eml_scalar_round";
  c5_info[12].dominantType = "double";
  c5_info[12].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_round.m";
  c5_info[12].fileLength = 523U;
  c5_info[12].fileTime1 = 1203448008U;
  c5_info[12].fileTime2 = 0U;
  c5_info[13].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_round.m";
  c5_info[13].name = "isfloat";
  c5_info[13].dominantType = "double";
  c5_info[13].resolved = "[B]isfloat";
  c5_info[13].fileLength = 0U;
  c5_info[13].fileTime1 = 0U;
  c5_info[13].fileTime2 = 0U;
  c5_info[14].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_round.m!scalar_round";
  c5_info[14].name = "lt";
  c5_info[14].dominantType = "double";
  c5_info[14].resolved = "[B]lt";
  c5_info[14].fileLength = 0U;
  c5_info[14].fileTime1 = 0U;
  c5_info[14].fileTime2 = 0U;
  c5_info[15].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_round.m!scalar_round";
  c5_info[15].name = "minus";
  c5_info[15].dominantType = "double";
  c5_info[15].resolved = "[B]minus";
  c5_info[15].fileLength = 0U;
  c5_info[15].fileTime1 = 0U;
  c5_info[15].fileTime2 = 0U;
  c5_info[16].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_round.m!scalar_round";
  c5_info[16].name = "plus";
  c5_info[16].dominantType = "double";
  c5_info[16].resolved = "[B]plus";
  c5_info[16].fileLength = 0U;
  c5_info[16].fileTime1 = 0U;
  c5_info[16].fileTime2 = 0U;
  c5_info[17].context = "";
  c5_info[17].name = "mtimes";
  c5_info[17].dominantType = "double";
  c5_info[17].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  c5_info[17].fileLength = 3425U;
  c5_info[17].fileTime1 = 1251031872U;
  c5_info[17].fileTime2 = 0U;
  c5_info[18].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  c5_info[18].name = "strcmp";
  c5_info[18].dominantType = "char";
  c5_info[18].resolved = "[B]strcmp";
  c5_info[18].fileLength = 0U;
  c5_info[18].fileTime1 = 0U;
  c5_info[18].fileTime2 = 0U;
  c5_info[19].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  c5_info[19].name = "eq";
  c5_info[19].dominantType = "double";
  c5_info[19].resolved = "[B]eq";
  c5_info[19].fileLength = 0U;
  c5_info[19].fileTime1 = 0U;
  c5_info[19].fileTime2 = 0U;
  c5_info[20].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  c5_info[20].name = "class";
  c5_info[20].dominantType = "double";
  c5_info[20].resolved = "[B]class";
  c5_info[20].fileLength = 0U;
  c5_info[20].fileTime1 = 0U;
  c5_info[20].fileTime2 = 0U;
  c5_info[21].context = "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  c5_info[21].name = "not";
  c5_info[21].dominantType = "logical";
  c5_info[21].resolved = "[B]not";
  c5_info[21].fileLength = 0U;
  c5_info[21].fileTime1 = 0U;
  c5_info[21].fileTime2 = 0U;
}

static const mxArray *c5_d_sf_marshall(void *chartInstanceVoid, void *c5_u)
{
  const mxArray *c5_y = NULL;
  boolean_T c5_b_u;
  const mxArray *c5_b_y = NULL;
  SFc5_entalInstanceStruct *chartInstance;
  chartInstance = (SFc5_entalInstanceStruct *)chartInstanceVoid;
  c5_y = NULL;
  c5_b_u = *((boolean_T *)c5_u);
  c5_b_y = NULL;
  sf_mex_assign(&c5_b_y, sf_mex_create("y", &c5_b_u, 11, 0U, 0U, 0U, 0));
  sf_mex_assign(&c5_y, c5_b_y);
  return c5_y;
}

static real_T c5_emlrt_marshallIn(SFc5_entalInstanceStruct *chartInstance, const
  mxArray *c5_m, const char_T *c5_name)
{
  real_T c5_y;
  real_T c5_d0;
  sf_mex_import(c5_name, sf_mex_dup(c5_m), &c5_d0, 1, 0, 0U, 0, 0U, 0);
  c5_y = c5_d0;
  sf_mex_destroy(&c5_m);
  return c5_y;
}

static uint8_T c5_b_emlrt_marshallIn(SFc5_entalInstanceStruct *chartInstance,
  const mxArray *c5_b_is_active_c5_ental, const char_T *
  c5_name)
{
  uint8_T c5_y;
  uint8_T c5_u0;
  sf_mex_import(c5_name, sf_mex_dup(c5_b_is_active_c5_ental), &c5_u0, 1, 3, 0U,
                0, 0U, 0);
  c5_y = c5_u0;
  sf_mex_destroy(&c5_b_is_active_c5_ental);
  return c5_y;
}

static void init_dsm_address_info(SFc5_entalInstanceStruct *chartInstance)
{
}

/* SFunction Glue Code */
void sf_c5_ental_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(661730966U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(4194459239U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(1528323372U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(2207118434U);
}

mxArray *sf_c5_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)(1263014576U);
    pr[1] = (double)(4205284979U);
    pr[2] = (double)(1490484138U);
    pr[3] = (double)(936602136U);
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
  }

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

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

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(15);
      pr[1] = (double)(479);
      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)(1);
      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));
    mxSetField(mxAutoinheritanceInfo,0,"inputs",mxData);
  }

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

  return(mxAutoinheritanceInfo);
}

static mxArray *sf_get_sim_state_info_c5_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\"m\",},{M[8],M[0],T\"is_active_c5_ental\",}}"
  };

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 2, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c5_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)) {
    SFc5_entalInstanceStruct *chartInstance;
    chartInstance = (SFc5_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_,
          5,
          1,
          1,
          3,
          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,"m");
          _SFD_SET_DATA_PROPS(1,1,1,0,"uu");
          _SFD_SET_DATA_PROPS(2,1,1,0,"Ts");
          _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,1,0,0,1,0,0,0);
        _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",0,-1,306);
        _SFD_CV_INIT_EML_IF(0,0,113,127,-1,-2);
        _SFD_CV_INIT_EML_FOR(0,0,99,109,306);
        _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);
        }

        _SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c5_sf_marshall);

        {
          unsigned int dimVector[2];
          dimVector[0]= 15;
          dimVector[1]= 479;
          _SFD_SET_DATA_COMPILED_PROPS(1,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c5_b_sf_marshall);
        }

        _SFD_SET_DATA_COMPILED_PROPS(2,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c5_sf_marshall);

        {
          real_T *c5_m;
          real_T *c5_Ts;
          real_T (*c5_uu)[7185];
          c5_Ts = (real_T *)ssGetInputPortSignal(chartInstance->S, 1);
          c5_uu = (real_T (*)[7185])ssGetInputPortSignal(chartInstance->S, 0);
          c5_m = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
          _SFD_SET_DATA_VALUE_PTR(0U, c5_m);
          _SFD_SET_DATA_VALUE_PTR(1U, *c5_uu);
          _SFD_SET_DATA_VALUE_PTR(2U, c5_Ts);
        }
      }
    } else {
      sf_debug_reset_current_state_configuration(_entalMachineNumber_,
        chartInstance->chartNumber,chartInstance->instanceNumber);
    }
  }
}

static void sf_opaque_initialize_c5_ental(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc5_entalInstanceStruct*) chartInstanceVar)->S,0);
  initialize_params_c5_ental((SFc5_entalInstanceStruct*) chartInstanceVar);
  initialize_c5_ental((SFc5_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_enable_c5_ental(void *chartInstanceVar)
{
  enable_c5_ental((SFc5_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_disable_c5_ental(void *chartInstanceVar)
{
  disable_c5_ental((SFc5_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_gateway_c5_ental(void *chartInstanceVar)
{
  sf_c5_ental((SFc5_entalInstanceStruct*) chartInstanceVar);
}

static mxArray* sf_internal_get_sim_state_c5_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_c5_ental((SFc5_entalInstanceStruct*)
    chartInfo->chartInstance);         /* raw sim ctx */
  prhs[3] = sf_get_sim_state_info_c5_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_c5_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_c5_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_c5_ental((SFc5_entalInstanceStruct*)chartInfo->chartInstance,
    mxDuplicateArray(plhs[0]));
  mxDestroyArray(plhs[0]);
}

static mxArray* sf_opaque_get_sim_state_c5_ental(SimStruct* S)
{
  return sf_internal_get_sim_state_c5_ental(S);
}

static void sf_opaque_set_sim_state_c5_ental(SimStruct* S, const mxArray *st)
{
  sf_internal_set_sim_state_c5_ental(S, st);
}

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

    finalize_c5_ental((SFc5_entalInstanceStruct*) chartInstanceVar);
    free((void *)chartInstanceVar);
    ssSetUserData(S,NULL);
  }
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  compInitSubchartSimstructsFcn_c5_ental((SFc5_entalInstanceStruct*)
    chartInstanceVar);
}

extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c5_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_c5_ental((SFc5_entalInstanceStruct*)(((ChartInfoStruct *)
      ssGetUserData(S))->chartInstance));
  }
}

static void mdlSetWorkWidths_c5_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",5);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetRTWCG(S,sf_rtw_info_uint_prop(S,"ental","ental",5,"RTWCG"));
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop(S,"ental","ental",5,
      "gatewayCannotBeInlinedMultipleTimes"));
    if (chartIsInlinable) {
      ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
      sf_mark_chart_expressionable_inputs(S,"ental","ental",5,2);
      sf_mark_chart_reusable_outputs(S,"ental","ental",5,1);
    }

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

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(2714158724U));
  ssSetChecksum1(S,(91380119U));
  ssSetChecksum2(S,(3771993556U));
  ssSetChecksum3(S,(3716384210U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
}

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

static void mdlStart_c5_ental(SimStruct *S)
{
  SFc5_entalInstanceStruct *chartInstance;
  chartInstance = (SFc5_entalInstanceStruct *)malloc(sizeof
    (SFc5_entalInstanceStruct));
  memset(chartInstance, 0, sizeof(SFc5_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_c5_ental;
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c5_ental;
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c5_ental;
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c5_ental;
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c5_ental;
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c5_ental;
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c5_ental;
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c5_ental;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c5_ental;
  chartInstance->chartInfo.mdlStart = mdlStart_c5_ental;
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c5_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 c5_ental_method_dispatcher(SimStruct *S, int_T method, void *data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c5_ental(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c5_ental(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c5_ental(S);
    break;

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