/* Include files */

#include "blascompat32.h"
#include "ental_sfun.h"
#include "c81_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 *c81_debug_family_names[14] = { "M", "N", "dz", "k", "j", "i",
  "h1", "h2", "nargin", "nargout", "h", "OP", "hTS", "hh" };

/* Function Declarations */
static void initialize_c81_ental(SFc81_entalInstanceStruct *chartInstance);
static void initialize_params_c81_ental(SFc81_entalInstanceStruct *chartInstance);
static void enable_c81_ental(SFc81_entalInstanceStruct *chartInstance);
static void disable_c81_ental(SFc81_entalInstanceStruct *chartInstance);
static void c81_update_debugger_state_c81_ental(SFc81_entalInstanceStruct
  *chartInstance);
static const mxArray *get_sim_state_c81_ental(SFc81_entalInstanceStruct
  *chartInstance);
static void set_sim_state_c81_ental(SFc81_entalInstanceStruct *chartInstance,
  const mxArray *c81_st);
static void finalize_c81_ental(SFc81_entalInstanceStruct *chartInstance);
static void sf_c81_ental(SFc81_entalInstanceStruct *chartInstance);
static void c81_c81_ental(SFc81_entalInstanceStruct *chartInstance);
static void compInitSubchartSimstructsFcn_c81_ental(SFc81_entalInstanceStruct
  *chartInstance);
static void init_script_number_translation(uint32_T c81_machineNumber, uint32_T
  c81_chartNumber);
static const mxArray *c81_sf_marshall(void *chartInstanceVoid, void *c81_u);
static const mxArray *c81_b_sf_marshall(void *chartInstanceVoid, void *c81_u);
static const mxArray *c81_c_sf_marshall(void *chartInstanceVoid, void *c81_u);
static const mxArray *c81_d_sf_marshall(void *chartInstanceVoid, void *c81_u);
static const mxArray *c81_e_sf_marshall(void *chartInstanceVoid, void *c81_u);
static void c81_emlrt_marshallIn(SFc81_entalInstanceStruct *chartInstance, const
  mxArray *c81_hh, const char_T *c81_name, real_T c81_y[7185]);
static uint8_T c81_b_emlrt_marshallIn(SFc81_entalInstanceStruct *chartInstance,
  const mxArray *c81_b_is_active_c81_ental, const char_T *c81_name);
static void init_dsm_address_info(SFc81_entalInstanceStruct *chartInstance);

/* Function Definitions */
static void initialize_c81_ental(SFc81_entalInstanceStruct *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  chartInstance->c81_is_active_c81_ental = 0U;
}

static void initialize_params_c81_ental(SFc81_entalInstanceStruct *chartInstance)
{
}

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

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

static void c81_update_debugger_state_c81_ental(SFc81_entalInstanceStruct
  *chartInstance)
{
}

static const mxArray *get_sim_state_c81_ental(SFc81_entalInstanceStruct
  *chartInstance)
{
  const mxArray *c81_st = NULL;
  const mxArray *c81_y = NULL;
  int32_T c81_i0;
  real_T c81_hoistedGlobal[7185];
  int32_T c81_i1;
  real_T c81_u[7185];
  const mxArray *c81_b_y = NULL;
  uint8_T c81_b_hoistedGlobal;
  uint8_T c81_b_u;
  const mxArray *c81_c_y = NULL;
  real_T (*c81_hh)[7185];
  c81_hh = (real_T (*)[7185])ssGetOutputPortSignal(chartInstance->S, 1);
  c81_st = NULL;
  c81_y = NULL;
  sf_mex_assign(&c81_y, sf_mex_createcellarray(2));
  for (c81_i0 = 0; c81_i0 < 7185; c81_i0 = c81_i0 + 1) {
    c81_hoistedGlobal[c81_i0] = (*c81_hh)[c81_i0];
  }

  for (c81_i1 = 0; c81_i1 < 7185; c81_i1 = c81_i1 + 1) {
    c81_u[c81_i1] = c81_hoistedGlobal[c81_i1];
  }

  c81_b_y = NULL;
  sf_mex_assign(&c81_b_y, sf_mex_create("y", c81_u, 0, 0U, 1U, 0U, 2, 15, 479));
  sf_mex_setcell(c81_y, 0, c81_b_y);
  c81_b_hoistedGlobal = chartInstance->c81_is_active_c81_ental;
  c81_b_u = c81_b_hoistedGlobal;
  c81_c_y = NULL;
  sf_mex_assign(&c81_c_y, sf_mex_create("y", &c81_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c81_y, 1, c81_c_y);
  sf_mex_assign(&c81_st, c81_y);
  return c81_st;
}

static void set_sim_state_c81_ental(SFc81_entalInstanceStruct *chartInstance,
  const mxArray *c81_st)
{
  const mxArray *c81_u;
  real_T c81_dv0[7185];
  int32_T c81_i2;
  real_T (*c81_hh)[7185];
  c81_hh = (real_T (*)[7185])ssGetOutputPortSignal(chartInstance->S, 1);
  chartInstance->c81_doneDoubleBufferReInit = TRUE;
  c81_u = sf_mex_dup(c81_st);
  c81_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c81_u, 0)), "hh",
                       c81_dv0);
  for (c81_i2 = 0; c81_i2 < 7185; c81_i2 = c81_i2 + 1) {
    (*c81_hh)[c81_i2] = c81_dv0[c81_i2];
  }

  chartInstance->c81_is_active_c81_ental = c81_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c81_u, 1)),
    "is_active_c81_ental");
  sf_mex_destroy(&c81_u);
  c81_update_debugger_state_c81_ental(chartInstance);
  sf_mex_destroy(&c81_st);
}

static void finalize_c81_ental(SFc81_entalInstanceStruct *chartInstance)
{
}

static void sf_c81_ental(SFc81_entalInstanceStruct *chartInstance)
{
  int32_T c81_i3;
  int32_T c81_i4;
  int32_T c81_i5;
  int32_T c81_previousEvent;
  real_T *c81_hTS;
  real_T (*c81_OP)[2874];
  real_T (*c81_hh)[7185];
  real_T (*c81_h)[7185];
  c81_hTS = (real_T *)ssGetInputPortSignal(chartInstance->S, 2);
  c81_OP = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 1);
  c81_hh = (real_T (*)[7185])ssGetOutputPortSignal(chartInstance->S, 1);
  c81_h = (real_T (*)[7185])ssGetInputPortSignal(chartInstance->S, 0);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 19);
  for (c81_i3 = 0; c81_i3 < 7185; c81_i3 = c81_i3 + 1) {
    _SFD_DATA_RANGE_CHECK((*c81_h)[c81_i3], 0U);
  }

  for (c81_i4 = 0; c81_i4 < 7185; c81_i4 = c81_i4 + 1) {
    _SFD_DATA_RANGE_CHECK((*c81_hh)[c81_i4], 1U);
  }

  for (c81_i5 = 0; c81_i5 < 2874; c81_i5 = c81_i5 + 1) {
    _SFD_DATA_RANGE_CHECK((*c81_OP)[c81_i5], 2U);
  }

  _SFD_DATA_RANGE_CHECK(*c81_hTS, 3U);
  c81_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  c81_c81_ental(chartInstance);
  _sfEvent_ = c81_previousEvent;
  sf_debug_check_for_state_inconsistency(_entalMachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}

static void c81_c81_ental(SFc81_entalInstanceStruct *chartInstance)
{
  int32_T c81_i6;
  static real_T c81_hoistedGlobal[7185];
  int32_T c81_i7;
  real_T c81_b_hoistedGlobal[2874];
  real_T c81_c_hoistedGlobal;
  int32_T c81_i8;
  real_T c81_h[7185];
  int32_T c81_i9;
  real_T c81_OP[2874];
  real_T c81_hTS;
  uint32_T c81_debug_family_var_map[14];
  static const char *c81_sv0[14] = { "M", "N", "dz", "k", "j", "i", "h1", "h2",
    "nargin", "nargout", "h", "OP", "hTS", "hh" };

  real_T c81_M;
  real_T c81_N;
  real_T c81_dz[478];
  real_T c81_k;
  real_T c81_j;
  real_T c81_i;
  real_T c81_h1;
  real_T c81_h2;
  real_T c81_nargin = 3.0;
  real_T c81_nargout = 1.0;
  real_T c81_hh[7185];
  int32_T c81_i10;
  int32_T c81_i11;
  real_T c81_b_k;
  int32_T c81_i12;
  real_T c81_A[478];
  int32_T c81_i13;
  real_T c81_x[478];
  int32_T c81_i14;
  real_T c81_b_x[478];
  int32_T c81_i15;
  real_T c81_c_x[478];
  int32_T c81_i16;
  real_T c81_b_j;
  real_T c81_b_i;
  real_T c81_b_A;
  real_T c81_B;
  real_T c81_d_x;
  real_T c81_y;
  real_T c81_e_x;
  real_T c81_b_y;
  real_T c81_f_x;
  real_T c81_c_y;
  real_T c81_d_y;
  real_T c81_c_A;
  real_T c81_b_B;
  real_T c81_g_x;
  real_T c81_e_y;
  real_T c81_h_x;
  real_T c81_f_y;
  real_T c81_i_x;
  real_T c81_g_y;
  real_T c81_h_y;
  real_T c81_d_A;
  real_T c81_c_B;
  real_T c81_j_x;
  real_T c81_i_y;
  real_T c81_k_x;
  real_T c81_j_y;
  real_T c81_l_x;
  real_T c81_k_y;
  real_T c81_l_y;
  real_T c81_e_A;
  real_T c81_d_B;
  real_T c81_m_x;
  real_T c81_m_y;
  real_T c81_n_x;
  real_T c81_n_y;
  real_T c81_o_x;
  real_T c81_o_y;
  real_T c81_p_y;
  real_T c81_f_A;
  real_T c81_e_B;
  real_T c81_p_x;
  real_T c81_q_y;
  real_T c81_q_x;
  real_T c81_r_y;
  real_T c81_r_x;
  real_T c81_s_y;
  real_T c81_t_y;
  real_T c81_g_A;
  real_T c81_f_B;
  real_T c81_s_x;
  real_T c81_u_y;
  real_T c81_t_x;
  real_T c81_v_y;
  real_T c81_u_x;
  real_T c81_w_y;
  real_T c81_x_y;
  real_T c81_h_A;
  real_T c81_g_B;
  real_T c81_v_x;
  real_T c81_y_y;
  real_T c81_w_x;
  real_T c81_ab_y;
  real_T c81_x_x;
  real_T c81_bb_y;
  real_T c81_cb_y;
  real_T c81_i_A;
  real_T c81_h_B;
  real_T c81_y_x;
  real_T c81_db_y;
  real_T c81_ab_x;
  real_T c81_eb_y;
  real_T c81_bb_x;
  real_T c81_fb_y;
  real_T c81_gb_y;
  real_T c81_j_A;
  real_T c81_i_B;
  real_T c81_cb_x;
  real_T c81_hb_y;
  real_T c81_db_x;
  real_T c81_ib_y;
  real_T c81_eb_x;
  real_T c81_jb_y;
  real_T c81_kb_y;
  int32_T c81_i17;
  real_T *c81_b_hTS;
  real_T (*c81_b_hh)[7185];
  real_T (*c81_b_OP)[2874];
  real_T (*c81_b_h)[7185];
  c81_b_hTS = (real_T *)ssGetInputPortSignal(chartInstance->S, 2);
  c81_b_OP = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 1);
  c81_b_hh = (real_T (*)[7185])ssGetOutputPortSignal(chartInstance->S, 1);
  c81_b_h = (real_T (*)[7185])ssGetInputPortSignal(chartInstance->S, 0);
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 19);
  for (c81_i6 = 0; c81_i6 < 7185; c81_i6 = c81_i6 + 1) {
    c81_hoistedGlobal[c81_i6] = (*c81_b_h)[c81_i6];
  }

  for (c81_i7 = 0; c81_i7 < 2874; c81_i7 = c81_i7 + 1) {
    c81_b_hoistedGlobal[c81_i7] = (*c81_b_OP)[c81_i7];
  }

  c81_c_hoistedGlobal = *c81_b_hTS;
  for (c81_i8 = 0; c81_i8 < 7185; c81_i8 = c81_i8 + 1) {
    c81_h[c81_i8] = c81_hoistedGlobal[c81_i8];
  }

  for (c81_i9 = 0; c81_i9 < 2874; c81_i9 = c81_i9 + 1) {
    c81_OP[c81_i9] = c81_b_hoistedGlobal[c81_i9];
  }

  c81_hTS = c81_c_hoistedGlobal;
  sf_debug_symbol_scope_push_eml(0U, 14U, 14U, c81_sv0, c81_debug_family_var_map);
  sf_debug_symbol_scope_add_eml(&c81_M, c81_b_sf_marshall, 0U);
  sf_debug_symbol_scope_add_eml(&c81_N, c81_b_sf_marshall, 1U);
  sf_debug_symbol_scope_add_eml(c81_dz, c81_d_sf_marshall, 2U);
  sf_debug_symbol_scope_add_eml(&c81_k, c81_b_sf_marshall, 3U);
  sf_debug_symbol_scope_add_eml(&c81_j, c81_b_sf_marshall, 4U);
  sf_debug_symbol_scope_add_eml(&c81_i, c81_b_sf_marshall, 5U);
  sf_debug_symbol_scope_add_eml(&c81_h1, c81_b_sf_marshall, 6U);
  sf_debug_symbol_scope_add_eml(&c81_h2, c81_b_sf_marshall, 7U);
  sf_debug_symbol_scope_add_eml(&c81_nargin, c81_b_sf_marshall, 8U);
  sf_debug_symbol_scope_add_eml(&c81_nargout, c81_b_sf_marshall, 9U);
  sf_debug_symbol_scope_add_eml(c81_h, c81_sf_marshall, 10U);
  sf_debug_symbol_scope_add_eml(c81_OP, c81_c_sf_marshall, 11U);
  sf_debug_symbol_scope_add_eml(&c81_hTS, c81_b_sf_marshall, 12U);
  sf_debug_symbol_scope_add_eml(c81_hh, c81_sf_marshall, 13U);
  CV_EML_FCN(0, 0);

  /* M=15; N=479; */
  _SFD_EML_CALL(0, 5);
  c81_M = 15.0;
  c81_N = 479.0;
  _SFD_EML_CALL(0, 6);
  for (c81_i10 = 0; c81_i10 < 478; c81_i10 = c81_i10 + 1) {
    c81_dz[c81_i10] = 0.0;
  }

  _SFD_EML_CALL(0, 7);
  for (c81_i11 = 0; c81_i11 < 7185; c81_i11 = c81_i11 + 1) {
    c81_hh[c81_i11] = 0.0;
  }

  c81_k = 1.0;
  c81_b_k = 1.0;
  while (c81_b_k <= 478.0) {
    c81_k = c81_b_k;
    CV_EML_FOR(0, 0, 1);
    _SFD_EML_CALL(0, 10);
    c81_dz[_SFD_EML_ARRAY_BOUNDS_CHECK("dz", (int32_T)_SFD_INTEGER_CHECK("k",
      c81_k), 1, 478, 1, 0) - 1] = c81_OP[
      _SFD_EML_ARRAY_BOUNDS_CHECK("OP", (int32_T)_SFD_INTEGER_CHECK("k+1", c81_k
      + 1.0), 1, 479, 1, 0) - 1] - c81_OP[
      _SFD_EML_ARRAY_BOUNDS_CHECK("OP", (int32_T)_SFD_INTEGER_CHECK("k", c81_k),
      1, 479, 1, 0) - 1];
    c81_b_k = c81_b_k + 1.0;
    sf_mex_listen_for_ctrl_c(chartInstance->S);
  }

  CV_EML_FOR(0, 0, 0);
  _SFD_EML_CALL(0, 12);
  for (c81_i12 = 0; c81_i12 < 478; c81_i12 = c81_i12 + 1) {
    c81_A[c81_i12] = c81_dz[c81_i12];
  }

  for (c81_i13 = 0; c81_i13 < 478; c81_i13 = c81_i13 + 1) {
    c81_x[c81_i13] = c81_A[c81_i13];
  }

  for (c81_i14 = 0; c81_i14 < 478; c81_i14 = c81_i14 + 1) {
    c81_b_x[c81_i14] = c81_x[c81_i14];
  }

  for (c81_i15 = 0; c81_i15 < 478; c81_i15 = c81_i15 + 1) {
    c81_c_x[c81_i15] = c81_b_x[c81_i15];
  }

  for (c81_i16 = 0; c81_i16 < 478; c81_i16 = c81_i16 + 1) {
    c81_dz[c81_i16] = c81_c_x[c81_i16] / 1000.0;
  }

  c81_j = 2.0;
  c81_b_j = 2.0;
  while (c81_b_j <= 478.0) {
    c81_j = c81_b_j;
    CV_EML_FOR(0, 1, 1);
    c81_i = 2.0;
    c81_b_i = 2.0;
    while (c81_b_i <= 14.0) {
      c81_i = c81_b_i;
      CV_EML_FOR(0, 2, 1);
      _SFD_EML_CALL(0, 15);
      c81_h1 = c81_h[(_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)
        _SFD_INTEGER_CHECK("i", c81_i), 1, 15, 1, 0) - 1) + 15 * (
        _SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)_SFD_INTEGER_CHECK("j", c81_j),
        1, 479, 2, 0) - 1)];
      _SFD_EML_CALL(0, 15);
      c81_h2 = c81_h[(_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)
        _SFD_INTEGER_CHECK("i", c81_i), 1, 15, 1, 0) - 1) + 15 * (
        _SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)_SFD_INTEGER_CHECK("j-1",
        c81_j - 1.0), 1, 479, 2, 0) - 1)];
      _SFD_EML_CALL(0, 16);
      c81_b_A = c81_h2 - c81_h1;
      c81_B = c81_dz[_SFD_EML_ARRAY_BOUNDS_CHECK("dz", (int32_T)
        _SFD_INTEGER_CHECK("j-1", c81_j - 1.0), 1, 478, 1, 0) - 1];
      c81_d_x = c81_b_A;
      c81_y = c81_B;
      c81_e_x = c81_d_x;
      c81_b_y = c81_y;
      c81_f_x = c81_e_x;
      c81_c_y = c81_b_y;
      c81_d_y = c81_f_x / c81_c_y;
      c81_hh[(_SFD_EML_ARRAY_BOUNDS_CHECK("hh", (int32_T)_SFD_INTEGER_CHECK("i",
                c81_i), 1, 15, 1, 0) - 1) + 15 * (
        _SFD_EML_ARRAY_BOUNDS_CHECK("hh", (int32_T)_SFD_INTEGER_CHECK("j", c81_j),
        1, 479, 2, 0) - 1)] = c81_d_y;

      /* uvnitr */
      _SFD_EML_CALL(0, 17);
      c81_c_A = c81_h[_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)
        _SFD_INTEGER_CHECK("i", c81_i), 1, 15, 1, 0) + 7154] - c81_h[
        _SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)_SFD_INTEGER_CHECK("i", c81_i),
        1, 15, 1, 0) + 7169];
      c81_b_B = c81_dz[477];
      c81_g_x = c81_c_A;
      c81_e_y = c81_b_B;
      c81_h_x = c81_g_x;
      c81_f_y = c81_e_y;
      c81_i_x = c81_h_x;
      c81_g_y = c81_f_y;
      c81_h_y = c81_i_x / c81_g_y;
      c81_hh[_SFD_EML_ARRAY_BOUNDS_CHECK("hh", (int32_T)_SFD_INTEGER_CHECK("i",
        c81_i), 1, 15, 1, 0) + 7169] = c81_h_y;

      /* konec */
      _SFD_EML_CALL(0, 18);
      c81_d_A = c81_hTS - c81_h[_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)
        _SFD_INTEGER_CHECK("i", c81_i), 1, 15, 1, 0) - 1];
      c81_c_B = c81_dz[0];
      c81_j_x = c81_d_A;
      c81_i_y = c81_c_B;
      c81_k_x = c81_j_x;
      c81_j_y = c81_i_y;
      c81_l_x = c81_k_x;
      c81_k_y = c81_j_y;
      c81_l_y = c81_l_x / c81_k_y;
      c81_hh[_SFD_EML_ARRAY_BOUNDS_CHECK("hh", (int32_T)_SFD_INTEGER_CHECK("i",
        c81_i), 1, 15, 1, 0) - 1] = c81_l_y;

      /* vstup */
      c81_b_i = c81_b_i + 1.0;
      sf_mex_listen_for_ctrl_c(chartInstance->S);
    }

    CV_EML_FOR(0, 2, 0);
    _SFD_EML_CALL(0, 20);
    c81_e_A = c81_h[14 + 15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)
      _SFD_INTEGER_CHECK("j-1", c81_j - 1.0), 1, 479, 2, 0) - 1)] -
      c81_h[14 + 15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)
      _SFD_INTEGER_CHECK("j", c81_j), 1, 479, 2, 0) - 1)];
    c81_d_B = c81_dz[_SFD_EML_ARRAY_BOUNDS_CHECK("dz", (int32_T)
      _SFD_INTEGER_CHECK("j-1", c81_j - 1.0), 1, 478, 1, 0) - 1];
    c81_m_x = c81_e_A;
    c81_m_y = c81_d_B;
    c81_n_x = c81_m_x;
    c81_n_y = c81_m_y;
    c81_o_x = c81_n_x;
    c81_o_y = c81_n_y;
    c81_p_y = c81_o_x / c81_o_y;
    c81_hh[14 + 15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("hh", (int32_T)
      _SFD_INTEGER_CHECK("j", c81_j), 1, 479, 2, 0) - 1)] = c81_p_y;

    /* strana (vr) */
    _SFD_EML_CALL(0, 21);
    c81_f_A = c81_h[15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)
      _SFD_INTEGER_CHECK("j-1", c81_j - 1.0), 1, 479, 2, 0) - 1)] - c81_h[
      15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("h", (int32_T)_SFD_INTEGER_CHECK("j",
              c81_j), 1, 479, 2, 0) - 1)];
    c81_e_B = c81_dz[_SFD_EML_ARRAY_BOUNDS_CHECK("dz", (int32_T)
      _SFD_INTEGER_CHECK("j-1", c81_j - 1.0), 1, 478, 1, 0) - 1];
    c81_p_x = c81_f_A;
    c81_q_y = c81_e_B;
    c81_q_x = c81_p_x;
    c81_r_y = c81_q_y;
    c81_r_x = c81_q_x;
    c81_s_y = c81_r_y;
    c81_t_y = c81_r_x / c81_s_y;
    c81_hh[15 * (_SFD_EML_ARRAY_BOUNDS_CHECK("hh", (int32_T)_SFD_INTEGER_CHECK(
      "j", c81_j), 1, 479, 2, 0) - 1)] = c81_t_y;

    /* strana (mr) */
    c81_b_j = c81_b_j + 1.0;
    sf_mex_listen_for_ctrl_c(chartInstance->S);
  }

  CV_EML_FOR(0, 1, 0);
  _SFD_EML_CALL(0, 23);
  c81_g_A = c81_h[7155] - c81_h[7170];
  c81_f_B = c81_dz[477];
  c81_s_x = c81_g_A;
  c81_u_y = c81_f_B;
  c81_t_x = c81_s_x;
  c81_v_y = c81_u_y;
  c81_u_x = c81_t_x;
  c81_w_y = c81_v_y;
  c81_x_y = c81_u_x / c81_w_y;
  c81_hh[7170] = c81_x_y;

  /* spodni okraje */
  _SFD_EML_CALL(0, 24);
  c81_h_A = c81_h[7169] - c81_h[7184];
  c81_g_B = c81_dz[477];
  c81_v_x = c81_h_A;
  c81_y_y = c81_g_B;
  c81_w_x = c81_v_x;
  c81_ab_y = c81_y_y;
  c81_x_x = c81_w_x;
  c81_bb_y = c81_ab_y;
  c81_cb_y = c81_x_x / c81_bb_y;
  c81_hh[7184] = c81_cb_y;
  _SFD_EML_CALL(0, 25);
  c81_i_A = c81_hTS - c81_h[0];
  c81_h_B = c81_dz[1];
  c81_y_x = c81_i_A;
  c81_db_y = c81_h_B;
  c81_ab_x = c81_y_x;
  c81_eb_y = c81_db_y;
  c81_bb_x = c81_ab_x;
  c81_fb_y = c81_eb_y;
  c81_gb_y = c81_bb_x / c81_fb_y;
  c81_hh[0] = c81_gb_y;

  /* spodni okraje vstup */
  _SFD_EML_CALL(0, 26);
  c81_j_A = c81_hTS - c81_h[14];
  c81_i_B = c81_dz[1];
  c81_cb_x = c81_j_A;
  c81_hb_y = c81_i_B;
  c81_db_x = c81_cb_x;
  c81_ib_y = c81_hb_y;
  c81_eb_x = c81_db_x;
  c81_jb_y = c81_ib_y;
  c81_kb_y = c81_eb_x / c81_jb_y;
  c81_hh[14] = c81_kb_y;
  _SFD_EML_CALL(0, -26);
  sf_debug_symbol_scope_pop();
  for (c81_i17 = 0; c81_i17 < 7185; c81_i17 = c81_i17 + 1) {
    (*c81_b_hh)[c81_i17] = c81_hh[c81_i17];
  }

  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 19);
}

static void compInitSubchartSimstructsFcn_c81_ental(SFc81_entalInstanceStruct
  *chartInstance)
{
}

static void init_script_number_translation(uint32_T c81_machineNumber, uint32_T
  c81_chartNumber)
{
}

static const mxArray *c81_sf_marshall(void *chartInstanceVoid, void *c81_u)
{
  const mxArray *c81_y = NULL;
  int32_T c81_i18;
  int32_T c81_i19;
  int32_T c81_i20;
  real_T c81_b_u[7185];
  int32_T c81_i21;
  int32_T c81_i22;
  int32_T c81_i23;
  real_T c81_c_u[7185];
  const mxArray *c81_b_y = NULL;
  SFc81_entalInstanceStruct *chartInstance;
  chartInstance = (SFc81_entalInstanceStruct *)chartInstanceVoid;
  c81_y = NULL;
  c81_i18 = 0;
  for (c81_i19 = 0; c81_i19 < 479; c81_i19 = c81_i19 + 1) {
    for (c81_i20 = 0; c81_i20 < 15; c81_i20 = c81_i20 + 1) {
      c81_b_u[c81_i20 + c81_i18] = (*((real_T (*)[7185])c81_u))[c81_i20 +
        c81_i18];
    }

    c81_i18 = c81_i18 + 15;
  }

  c81_i21 = 0;
  for (c81_i22 = 0; c81_i22 < 479; c81_i22 = c81_i22 + 1) {
    for (c81_i23 = 0; c81_i23 < 15; c81_i23 = c81_i23 + 1) {
      c81_c_u[c81_i23 + c81_i21] = c81_b_u[c81_i23 + c81_i21];
    }

    c81_i21 = c81_i21 + 15;
  }

  c81_b_y = NULL;
  sf_mex_assign(&c81_b_y, sf_mex_create("y", c81_c_u, 0, 0U, 1U, 0U, 2, 15, 479));
  sf_mex_assign(&c81_y, c81_b_y);
  return c81_y;
}

static const mxArray *c81_b_sf_marshall(void *chartInstanceVoid, void *c81_u)
{
  const mxArray *c81_y = NULL;
  real_T c81_b_u;
  const mxArray *c81_b_y = NULL;
  SFc81_entalInstanceStruct *chartInstance;
  chartInstance = (SFc81_entalInstanceStruct *)chartInstanceVoid;
  c81_y = NULL;
  c81_b_u = *((real_T *)c81_u);
  c81_b_y = NULL;
  sf_mex_assign(&c81_b_y, sf_mex_create("y", &c81_b_u, 0, 0U, 0U, 0U, 0));
  sf_mex_assign(&c81_y, c81_b_y);
  return c81_y;
}

static const mxArray *c81_c_sf_marshall(void *chartInstanceVoid, void *c81_u)
{
  const mxArray *c81_y = NULL;
  int32_T c81_i24;
  int32_T c81_i25;
  int32_T c81_i26;
  real_T c81_b_u[2874];
  int32_T c81_i27;
  int32_T c81_i28;
  int32_T c81_i29;
  real_T c81_c_u[2874];
  const mxArray *c81_b_y = NULL;
  SFc81_entalInstanceStruct *chartInstance;
  chartInstance = (SFc81_entalInstanceStruct *)chartInstanceVoid;
  c81_y = NULL;
  c81_i24 = 0;
  for (c81_i25 = 0; c81_i25 < 6; c81_i25 = c81_i25 + 1) {
    for (c81_i26 = 0; c81_i26 < 479; c81_i26 = c81_i26 + 1) {
      c81_b_u[c81_i26 + c81_i24] = (*((real_T (*)[2874])c81_u))[c81_i26 +
        c81_i24];
    }

    c81_i24 = c81_i24 + 479;
  }

  c81_i27 = 0;
  for (c81_i28 = 0; c81_i28 < 6; c81_i28 = c81_i28 + 1) {
    for (c81_i29 = 0; c81_i29 < 479; c81_i29 = c81_i29 + 1) {
      c81_c_u[c81_i29 + c81_i27] = c81_b_u[c81_i29 + c81_i27];
    }

    c81_i27 = c81_i27 + 479;
  }

  c81_b_y = NULL;
  sf_mex_assign(&c81_b_y, sf_mex_create("y", c81_c_u, 0, 0U, 1U, 0U, 2, 479, 6));
  sf_mex_assign(&c81_y, c81_b_y);
  return c81_y;
}

static const mxArray *c81_d_sf_marshall(void *chartInstanceVoid, void *c81_u)
{
  const mxArray *c81_y = NULL;
  int32_T c81_i30;
  real_T c81_b_u[478];
  int32_T c81_i31;
  real_T c81_c_u[478];
  const mxArray *c81_b_y = NULL;
  SFc81_entalInstanceStruct *chartInstance;
  chartInstance = (SFc81_entalInstanceStruct *)chartInstanceVoid;
  c81_y = NULL;
  for (c81_i30 = 0; c81_i30 < 478; c81_i30 = c81_i30 + 1) {
    c81_b_u[c81_i30] = (*((real_T (*)[478])c81_u))[c81_i30];
  }

  for (c81_i31 = 0; c81_i31 < 478; c81_i31 = c81_i31 + 1) {
    c81_c_u[c81_i31] = c81_b_u[c81_i31];
  }

  c81_b_y = NULL;
  sf_mex_assign(&c81_b_y, sf_mex_create("y", c81_c_u, 0, 0U, 1U, 0U, 2, 1, 478));
  sf_mex_assign(&c81_y, c81_b_y);
  return c81_y;
}

const mxArray *sf_c81_ental_get_eml_resolved_functions_info(void)
{
  const mxArray *c81_nameCaptureInfo = NULL;
  c81_ResolvedFunctionInfo c81_info[14];
  c81_ResolvedFunctionInfo (*c81_b_info)[14];
  const mxArray *c81_m0 = NULL;
  int32_T c81_i32;
  c81_ResolvedFunctionInfo *c81_r0;
  c81_nameCaptureInfo = NULL;
  c81_b_info = (c81_ResolvedFunctionInfo (*)[14])c81_info;
  (*c81_b_info)[0].context = "";
  (*c81_b_info)[0].name = "size";
  (*c81_b_info)[0].dominantType = "double";
  (*c81_b_info)[0].resolved = "[B]size";
  (*c81_b_info)[0].fileLength = 0U;
  (*c81_b_info)[0].fileTime1 = 0U;
  (*c81_b_info)[0].fileTime2 = 0U;
  (*c81_b_info)[1].context = "";
  (*c81_b_info)[1].name = "minus";
  (*c81_b_info)[1].dominantType = "double";
  (*c81_b_info)[1].resolved = "[B]minus";
  (*c81_b_info)[1].fileLength = 0U;
  (*c81_b_info)[1].fileTime1 = 0U;
  (*c81_b_info)[1].fileTime2 = 0U;
  (*c81_b_info)[2].context = "";
  (*c81_b_info)[2].name = "zeros";
  (*c81_b_info)[2].dominantType = "double";
  (*c81_b_info)[2].resolved = "[B]zeros";
  (*c81_b_info)[2].fileLength = 0U;
  (*c81_b_info)[2].fileTime1 = 0U;
  (*c81_b_info)[2].fileTime2 = 0U;
  (*c81_b_info)[3].context = "";
  (*c81_b_info)[3].name = "plus";
  (*c81_b_info)[3].dominantType = "double";
  (*c81_b_info)[3].resolved = "[B]plus";
  (*c81_b_info)[3].fileLength = 0U;
  (*c81_b_info)[3].fileTime1 = 0U;
  (*c81_b_info)[3].fileTime2 = 0U;
  (*c81_b_info)[4].context = "";
  (*c81_b_info)[4].name = "mrdivide";
  (*c81_b_info)[4].dominantType = "double";
  (*c81_b_info)[4].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c81_b_info)[4].fileLength = 432U;
  (*c81_b_info)[4].fileTime1 = 1277748222U;
  (*c81_b_info)[4].fileTime2 = 0U;
  (*c81_b_info)[5].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c81_b_info)[5].name = "nargin";
  (*c81_b_info)[5].dominantType = "";
  (*c81_b_info)[5].resolved = "[B]nargin";
  (*c81_b_info)[5].fileLength = 0U;
  (*c81_b_info)[5].fileTime1 = 0U;
  (*c81_b_info)[5].fileTime2 = 0U;
  (*c81_b_info)[6].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c81_b_info)[6].name = "ge";
  (*c81_b_info)[6].dominantType = "double";
  (*c81_b_info)[6].resolved = "[B]ge";
  (*c81_b_info)[6].fileLength = 0U;
  (*c81_b_info)[6].fileTime1 = 0U;
  (*c81_b_info)[6].fileTime2 = 0U;
  (*c81_b_info)[7].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c81_b_info)[7].name = "isscalar";
  (*c81_b_info)[7].dominantType = "double";
  (*c81_b_info)[7].resolved = "[B]isscalar";
  (*c81_b_info)[7].fileLength = 0U;
  (*c81_b_info)[7].fileTime1 = 0U;
  (*c81_b_info)[7].fileTime2 = 0U;
  (*c81_b_info)[8].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  (*c81_b_info)[8].name = "rdivide";
  (*c81_b_info)[8].dominantType = "double";
  (*c81_b_info)[8].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c81_b_info)[8].fileLength = 403U;
  (*c81_b_info)[8].fileTime1 = 1245102420U;
  (*c81_b_info)[8].fileTime2 = 0U;
  (*c81_b_info)[9].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c81_b_info)[9].name = "gt";
  (*c81_b_info)[9].dominantType = "double";
  (*c81_b_info)[9].resolved = "[B]gt";
  (*c81_b_info)[9].fileLength = 0U;
  (*c81_b_info)[9].fileTime1 = 0U;
  (*c81_b_info)[9].fileTime2 = 0U;
  (*c81_b_info)[10].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c81_b_info)[10].name = "isa";
  (*c81_b_info)[10].dominantType = "double";
  (*c81_b_info)[10].resolved = "[B]isa";
  (*c81_b_info)[10].fileLength = 0U;
  (*c81_b_info)[10].fileTime1 = 0U;
  (*c81_b_info)[10].fileTime2 = 0U;
  (*c81_b_info)[11].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c81_b_info)[11].name = "eml_div";
  (*c81_b_info)[11].dominantType = "double";
  (*c81_b_info)[11].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  (*c81_b_info)[11].fileLength = 4918U;
  (*c81_b_info)[11].fileTime1 = 1267063410U;
  (*c81_b_info)[11].fileTime2 = 0U;
  (*c81_b_info)[12].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  (*c81_b_info)[12].name = "isinteger";
  (*c81_b_info)[12].dominantType = "double";
  (*c81_b_info)[12].resolved = "[B]isinteger";
  (*c81_b_info)[12].fileLength = 0U;
  (*c81_b_info)[12].fileTime1 = 0U;
  (*c81_b_info)[12].fileTime2 = 0U;
  (*c81_b_info)[13].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m!eml_fldiv";
  (*c81_b_info)[13].name = "isreal";
  (*c81_b_info)[13].dominantType = "double";
  (*c81_b_info)[13].resolved = "[B]isreal";
  (*c81_b_info)[13].fileLength = 0U;
  (*c81_b_info)[13].fileTime1 = 0U;
  (*c81_b_info)[13].fileTime2 = 0U;
  sf_mex_assign(&c81_m0, sf_mex_createstruct("nameCaptureInfo", 1, 14));
  for (c81_i32 = 0; c81_i32 < 14; c81_i32 = c81_i32 + 1) {
    c81_r0 = &c81_info[c81_i32];
    sf_mex_addfield(c81_m0, sf_mex_create("nameCaptureInfo", c81_r0->context, 15,
      0U, 0U, 0U, 2, 1, strlen(c81_r0->context)), "context"
                    , "nameCaptureInfo", c81_i32);
    sf_mex_addfield(c81_m0, sf_mex_create("nameCaptureInfo", c81_r0->name, 15,
      0U, 0U, 0U, 2, 1, strlen(c81_r0->name)), "name",
                    "nameCaptureInfo", c81_i32);
    sf_mex_addfield(c81_m0, sf_mex_create("nameCaptureInfo",
      c81_r0->dominantType, 15, 0U, 0U, 0U, 2, 1, strlen(c81_r0->dominantType)),
                    "dominantType", "nameCaptureInfo", c81_i32);
    sf_mex_addfield(c81_m0, sf_mex_create("nameCaptureInfo", c81_r0->resolved,
      15, 0U, 0U, 0U, 2, 1, strlen(c81_r0->resolved)),
                    "resolved", "nameCaptureInfo", c81_i32);
    sf_mex_addfield(c81_m0, sf_mex_create("nameCaptureInfo", &c81_r0->fileLength,
      7, 0U, 0U, 0U, 0), "fileLength", "nameCaptureInfo",
                    c81_i32);
    sf_mex_addfield(c81_m0, sf_mex_create("nameCaptureInfo", &c81_r0->fileTime1,
      7, 0U, 0U, 0U, 0), "fileTime1", "nameCaptureInfo",
                    c81_i32);
    sf_mex_addfield(c81_m0, sf_mex_create("nameCaptureInfo", &c81_r0->fileTime2,
      7, 0U, 0U, 0U, 0), "fileTime2", "nameCaptureInfo",
                    c81_i32);
  }

  sf_mex_assign(&c81_nameCaptureInfo, c81_m0);
  return c81_nameCaptureInfo;
}

static const mxArray *c81_e_sf_marshall(void *chartInstanceVoid, void *c81_u)
{
  const mxArray *c81_y = NULL;
  boolean_T c81_b_u;
  const mxArray *c81_b_y = NULL;
  SFc81_entalInstanceStruct *chartInstance;
  chartInstance = (SFc81_entalInstanceStruct *)chartInstanceVoid;
  c81_y = NULL;
  c81_b_u = *((boolean_T *)c81_u);
  c81_b_y = NULL;
  sf_mex_assign(&c81_b_y, sf_mex_create("y", &c81_b_u, 11, 0U, 0U, 0U, 0));
  sf_mex_assign(&c81_y, c81_b_y);
  return c81_y;
}

static void c81_emlrt_marshallIn(SFc81_entalInstanceStruct *chartInstance, const
  mxArray *c81_hh, const char_T *c81_name, real_T
  c81_y[7185])
{
  real_T c81_dv1[7185];
  int32_T c81_i33;
  sf_mex_import(c81_name, sf_mex_dup(c81_hh), c81_dv1, 1, 0, 0U, 1, 0U, 2, 15,
                479);
  for (c81_i33 = 0; c81_i33 < 7185; c81_i33 = c81_i33 + 1) {
    c81_y[c81_i33] = c81_dv1[c81_i33];
  }

  sf_mex_destroy(&c81_hh);
}

static uint8_T c81_b_emlrt_marshallIn(SFc81_entalInstanceStruct *chartInstance,
  const mxArray *c81_b_is_active_c81_ental, const
  char_T *c81_name)
{
  uint8_T c81_y;
  uint8_T c81_u0;
  sf_mex_import(c81_name, sf_mex_dup(c81_b_is_active_c81_ental), &c81_u0, 1, 3,
                0U, 0, 0U, 0);
  c81_y = c81_u0;
  sf_mex_destroy(&c81_b_is_active_c81_ental);
  return c81_y;
}

static void init_dsm_address_info(SFc81_entalInstanceStruct *chartInstance)
{
}

/* SFunction Glue Code */
void sf_c81_ental_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1953855102U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(3804873087U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(1728267350U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(2988010464U);
}

mxArray *sf_c81_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)(2799258719U);
    pr[1] = (double)(757096480U);
    pr[2] = (double)(3402760460U);
    pr[3] = (double)(3789781536U);
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
  }

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

    mxArray *mxData = mxCreateStructMatrix(1,3,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)(479);
      pr[1] = (double)(6);
      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)(1);
      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));
    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)(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));
    mxSetField(mxAutoinheritanceInfo,0,"outputs",mxData);
  }

  return(mxAutoinheritanceInfo);
}

static mxArray *sf_get_sim_state_info_c81_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\"hh\",},{M[8],M[0],T\"is_active_c81_ental\",}}"
  };

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 2, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c81_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)) {
    SFc81_entalInstanceStruct *chartInstance;
    chartInstance = (SFc81_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_,
          81,
          1,
          1,
          4,
          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,1,1,0,"h");
          _SFD_SET_DATA_PROPS(1,2,0,1,"hh");
          _SFD_SET_DATA_PROPS(2,1,1,0,"OP");
          _SFD_SET_DATA_PROPS(3,1,1,0,"hTS");
          _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,3,0,0,0);
        _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",0,-1,592);
        _SFD_CV_INIT_EML_FOR(0,0,96,108,140);
        _SFD_CV_INIT_EML_FOR(0,1,153,165,426);
        _SFD_CV_INIT_EML_FOR(0,2,169,181,326);
        _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[2];
          dimVector[0]= 15;
          dimVector[1]= 479;
          _SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c81_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)c81_sf_marshall);
        }

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

        _SFD_SET_DATA_COMPILED_PROPS(3,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c81_b_sf_marshall);

        {
          real_T *c81_hTS;
          real_T (*c81_h)[7185];
          real_T (*c81_hh)[7185];
          real_T (*c81_OP)[2874];
          c81_hTS = (real_T *)ssGetInputPortSignal(chartInstance->S, 2);
          c81_OP = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 1);
          c81_hh = (real_T (*)[7185])ssGetOutputPortSignal(chartInstance->S, 1);
          c81_h = (real_T (*)[7185])ssGetInputPortSignal(chartInstance->S, 0);
          _SFD_SET_DATA_VALUE_PTR(0U, *c81_h);
          _SFD_SET_DATA_VALUE_PTR(1U, *c81_hh);
          _SFD_SET_DATA_VALUE_PTR(2U, *c81_OP);
          _SFD_SET_DATA_VALUE_PTR(3U, c81_hTS);
        }
      }
    } else {
      sf_debug_reset_current_state_configuration(_entalMachineNumber_,
        chartInstance->chartNumber,chartInstance->instanceNumber);
    }
  }
}

static void sf_opaque_initialize_c81_ental(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc81_entalInstanceStruct*) chartInstanceVar)->S,
    0);
  initialize_params_c81_ental((SFc81_entalInstanceStruct*) chartInstanceVar);
  initialize_c81_ental((SFc81_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_enable_c81_ental(void *chartInstanceVar)
{
  enable_c81_ental((SFc81_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_disable_c81_ental(void *chartInstanceVar)
{
  disable_c81_ental((SFc81_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_gateway_c81_ental(void *chartInstanceVar)
{
  sf_c81_ental((SFc81_entalInstanceStruct*) chartInstanceVar);
}

static mxArray* sf_internal_get_sim_state_c81_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_c81_ental((SFc81_entalInstanceStruct*)
    chartInfo->chartInstance);         /* raw sim ctx */
  prhs[3] = sf_get_sim_state_info_c81_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_c81_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_c81_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_c81_ental((SFc81_entalInstanceStruct*)chartInfo->chartInstance,
    mxDuplicateArray(plhs[0]));
  mxDestroyArray(plhs[0]);
}

static mxArray* sf_opaque_get_sim_state_c81_ental(SimStruct* S)
{
  return sf_internal_get_sim_state_c81_ental(S);
}

static void sf_opaque_set_sim_state_c81_ental(SimStruct* S, const mxArray *st)
{
  sf_internal_set_sim_state_c81_ental(S, st);
}

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

    finalize_c81_ental((SFc81_entalInstanceStruct*) chartInstanceVar);
    free((void *)chartInstanceVar);
    ssSetUserData(S,NULL);
  }
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  compInitSubchartSimstructsFcn_c81_ental((SFc81_entalInstanceStruct*)
    chartInstanceVar);
}

extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c81_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_c81_ental((SFc81_entalInstanceStruct*)(((ChartInfoStruct *)
      ssGetUserData(S))->chartInstance));
  }
}

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

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

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(3031668136U));
  ssSetChecksum1(S,(1663029639U));
  ssSetChecksum2(S,(1539368219U));
  ssSetChecksum3(S,(1122682087U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
}

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

static void mdlStart_c81_ental(SimStruct *S)
{
  SFc81_entalInstanceStruct *chartInstance;
  chartInstance = (SFc81_entalInstanceStruct *)malloc(sizeof
    (SFc81_entalInstanceStruct));
  memset(chartInstance, 0, sizeof(SFc81_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_c81_ental;
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c81_ental;
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c81_ental;
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c81_ental;
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c81_ental;
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c81_ental;
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c81_ental;
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c81_ental;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c81_ental;
  chartInstance->chartInfo.mdlStart = mdlStart_c81_ental;
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c81_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 c81_ental_method_dispatcher(SimStruct *S, int_T method, void *data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c81_ental(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c81_ental(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c81_ental(S);
    break;

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