/* Include files */

#include "blascompat32.h"
#include "ental_sfun.h"
#include "c17_ental.h"
#include "mwmathutil.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 *c17_debug_family_names[19] = { "N", "M", "p", "a", "jStart",
  "jStop", "jj", "i", "k", "jstart", "jstop", "j", "nargin", "nargout", "OPm",
  "OPv", "S", "b", "n" };

/* Function Declarations */
static void initialize_c17_ental(SFc17_entalInstanceStruct *chartInstance);
static void initialize_params_c17_ental(SFc17_entalInstanceStruct *chartInstance);
static void enable_c17_ental(SFc17_entalInstanceStruct *chartInstance);
static void disable_c17_ental(SFc17_entalInstanceStruct *chartInstance);
static void c17_update_debugger_state_c17_ental(SFc17_entalInstanceStruct
  *chartInstance);
static const mxArray *get_sim_state_c17_ental(SFc17_entalInstanceStruct
  *chartInstance);
static void set_sim_state_c17_ental(SFc17_entalInstanceStruct *chartInstance,
  const mxArray *c17_st);
static void finalize_c17_ental(SFc17_entalInstanceStruct *chartInstance);
static void sf_c17_ental(SFc17_entalInstanceStruct *chartInstance);
static void c17_c17_ental(SFc17_entalInstanceStruct *chartInstance);
static void compInitSubchartSimstructsFcn_c17_ental(SFc17_entalInstanceStruct
  *chartInstance);
static void init_script_number_translation(uint32_T c17_machineNumber, uint32_T
  c17_chartNumber);
static real_T c17_min(SFc17_entalInstanceStruct *chartInstance, real_T
                      c17_varargin_1[2]);
static real_T c17_max(SFc17_entalInstanceStruct *chartInstance, real_T
                      c17_varargin_1[13]);
static real_T c17_b_max(SFc17_entalInstanceStruct *chartInstance, real_T
  c17_varargin_1_data[13], int32_T c17_varargin_1_sizes[1]);
static const mxArray *c17_sf_marshall(void *chartInstanceVoid, void *c17_u);
static const mxArray *c17_b_sf_marshall(void *chartInstanceVoid, void *c17_u);
static const mxArray *c17_c_sf_marshall(void *chartInstanceVoid, void *c17_u);
static const mxArray *c17_d_sf_marshall(void *chartInstanceVoid, void *c17_u);
static void c17_info_helper(c17_ResolvedFunctionInfo c17_info[38]);
static const mxArray *c17_e_sf_marshall(void *chartInstanceVoid, void *c17_u);
static void c17_emlrt_marshallIn(SFc17_entalInstanceStruct *chartInstance, const
  mxArray *c17_S, const char_T *c17_name, real_T c17_y[13]);
static void c17_b_emlrt_marshallIn(SFc17_entalInstanceStruct *chartInstance,
  const mxArray *c17_b, const char_T *c17_name, real_T c17_y[1950]);
static uint8_T c17_c_emlrt_marshallIn(SFc17_entalInstanceStruct *chartInstance,
  const mxArray *c17_b_is_active_c17_ental, const char_T *c17_name);
static void init_dsm_address_info(SFc17_entalInstanceStruct *chartInstance);

/* Function Definitions */
static void initialize_c17_ental(SFc17_entalInstanceStruct *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  chartInstance->c17_is_active_c17_ental = 0U;
}

static void initialize_params_c17_ental(SFc17_entalInstanceStruct *chartInstance)
{
}

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

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

static void c17_update_debugger_state_c17_ental(SFc17_entalInstanceStruct
  *chartInstance)
{
}

static const mxArray *get_sim_state_c17_ental(SFc17_entalInstanceStruct
  *chartInstance)
{
  const mxArray *c17_st = NULL;
  const mxArray *c17_y = NULL;
  int32_T c17_i0;
  real_T c17_hoistedGlobal[13];
  int32_T c17_i1;
  real_T c17_u[13];
  const mxArray *c17_b_y = NULL;
  int32_T c17_i2;
  real_T c17_b_hoistedGlobal[1950];
  int32_T c17_i3;
  real_T c17_b_u[1950];
  const mxArray *c17_c_y = NULL;
  int32_T c17_i4;
  real_T c17_c_hoistedGlobal[13];
  int32_T c17_i5;
  real_T c17_c_u[13];
  const mxArray *c17_d_y = NULL;
  uint8_T c17_d_hoistedGlobal;
  uint8_T c17_d_u;
  const mxArray *c17_e_y = NULL;
  real_T (*c17_n)[13];
  real_T (*c17_b)[1950];
  real_T (*c17_S)[13];
  c17_n = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 3);
  c17_b = (real_T (*)[1950])ssGetOutputPortSignal(chartInstance->S, 2);
  c17_S = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  c17_st = NULL;
  c17_y = NULL;
  sf_mex_assign(&c17_y, sf_mex_createcellarray(4));
  for (c17_i0 = 0; c17_i0 < 13; c17_i0 = c17_i0 + 1) {
    c17_hoistedGlobal[c17_i0] = (*c17_S)[c17_i0];
  }

  for (c17_i1 = 0; c17_i1 < 13; c17_i1 = c17_i1 + 1) {
    c17_u[c17_i1] = c17_hoistedGlobal[c17_i1];
  }

  c17_b_y = NULL;
  sf_mex_assign(&c17_b_y, sf_mex_create("y", c17_u, 0, 0U, 1U, 0U, 1, 13));
  sf_mex_setcell(c17_y, 0, c17_b_y);
  for (c17_i2 = 0; c17_i2 < 1950; c17_i2 = c17_i2 + 1) {
    c17_b_hoistedGlobal[c17_i2] = (*c17_b)[c17_i2];
  }

  for (c17_i3 = 0; c17_i3 < 1950; c17_i3 = c17_i3 + 1) {
    c17_b_u[c17_i3] = c17_b_hoistedGlobal[c17_i3];
  }

  c17_c_y = NULL;
  sf_mex_assign(&c17_c_y, sf_mex_create("y", c17_b_u, 0, 0U, 1U, 0U, 2, 13, 150));
  sf_mex_setcell(c17_y, 1, c17_c_y);
  for (c17_i4 = 0; c17_i4 < 13; c17_i4 = c17_i4 + 1) {
    c17_c_hoistedGlobal[c17_i4] = (*c17_n)[c17_i4];
  }

  for (c17_i5 = 0; c17_i5 < 13; c17_i5 = c17_i5 + 1) {
    c17_c_u[c17_i5] = c17_c_hoistedGlobal[c17_i5];
  }

  c17_d_y = NULL;
  sf_mex_assign(&c17_d_y, sf_mex_create("y", c17_c_u, 0, 0U, 1U, 0U, 1, 13));
  sf_mex_setcell(c17_y, 2, c17_d_y);
  c17_d_hoistedGlobal = chartInstance->c17_is_active_c17_ental;
  c17_d_u = c17_d_hoistedGlobal;
  c17_e_y = NULL;
  sf_mex_assign(&c17_e_y, sf_mex_create("y", &c17_d_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c17_y, 3, c17_e_y);
  sf_mex_assign(&c17_st, c17_y);
  return c17_st;
}

static void set_sim_state_c17_ental(SFc17_entalInstanceStruct *chartInstance,
  const mxArray *c17_st)
{
  const mxArray *c17_u;
  real_T c17_dv0[13];
  int32_T c17_i6;
  real_T c17_dv1[1950];
  int32_T c17_i7;
  real_T c17_dv2[13];
  int32_T c17_i8;
  real_T (*c17_S)[13];
  real_T (*c17_b)[1950];
  real_T (*c17_n)[13];
  c17_n = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 3);
  c17_b = (real_T (*)[1950])ssGetOutputPortSignal(chartInstance->S, 2);
  c17_S = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  chartInstance->c17_doneDoubleBufferReInit = TRUE;
  c17_u = sf_mex_dup(c17_st);
  c17_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c17_u, 0)), "S",
                       c17_dv0);
  for (c17_i6 = 0; c17_i6 < 13; c17_i6 = c17_i6 + 1) {
    (*c17_S)[c17_i6] = c17_dv0[c17_i6];
  }

  c17_b_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c17_u, 1)),
    "b", c17_dv1);
  for (c17_i7 = 0; c17_i7 < 1950; c17_i7 = c17_i7 + 1) {
    (*c17_b)[c17_i7] = c17_dv1[c17_i7];
  }

  c17_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c17_u, 2)), "n",
                       c17_dv2);
  for (c17_i8 = 0; c17_i8 < 13; c17_i8 = c17_i8 + 1) {
    (*c17_n)[c17_i8] = c17_dv2[c17_i8];
  }

  chartInstance->c17_is_active_c17_ental = c17_c_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c17_u, 3)),
    "is_active_c17_ental");
  sf_mex_destroy(&c17_u);
  c17_update_debugger_state_c17_ental(chartInstance);
  sf_mex_destroy(&c17_st);
}

static void finalize_c17_ental(SFc17_entalInstanceStruct *chartInstance)
{
}

static void sf_c17_ental(SFc17_entalInstanceStruct *chartInstance)
{
  int32_T c17_i9;
  int32_T c17_i10;
  int32_T c17_i11;
  int32_T c17_i12;
  int32_T c17_i13;
  int32_T c17_previousEvent;
  real_T (*c17_n)[13];
  real_T (*c17_b)[1950];
  real_T (*c17_OPv)[2874];
  real_T (*c17_S)[13];
  real_T (*c17_OPm)[2874];
  c17_n = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 3);
  c17_b = (real_T (*)[1950])ssGetOutputPortSignal(chartInstance->S, 2);
  c17_OPv = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 1);
  c17_S = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  c17_OPm = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 0);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 16);
  for (c17_i9 = 0; c17_i9 < 2874; c17_i9 = c17_i9 + 1) {
    _SFD_DATA_RANGE_CHECK((*c17_OPm)[c17_i9], 0U);
  }

  for (c17_i10 = 0; c17_i10 < 13; c17_i10 = c17_i10 + 1) {
    _SFD_DATA_RANGE_CHECK((*c17_S)[c17_i10], 1U);
  }

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

  for (c17_i12 = 0; c17_i12 < 1950; c17_i12 = c17_i12 + 1) {
    _SFD_DATA_RANGE_CHECK((*c17_b)[c17_i12], 3U);
  }

  for (c17_i13 = 0; c17_i13 < 13; c17_i13 = c17_i13 + 1) {
    _SFD_DATA_RANGE_CHECK((*c17_n)[c17_i13], 4U);
  }

  c17_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  c17_c17_ental(chartInstance);
  _sfEvent_ = c17_previousEvent;
  sf_debug_check_for_state_inconsistency(_entalMachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}

static void c17_c17_ental(SFc17_entalInstanceStruct *chartInstance)
{
  int32_T c17_i14;
  real_T c17_hoistedGlobal[2874];
  int32_T c17_i15;
  real_T c17_b_hoistedGlobal[2874];
  int32_T c17_i16;
  real_T c17_OPm[2874];
  int32_T c17_i17;
  real_T c17_OPv[2874];
  uint32_T c17_debug_family_var_map[19];
  static const char *c17_sv0[19] = { "N", "M", "p", "a", "jStart", "jStop", "jj",
    "i", "k", "jstart", "jstop", "j", "nargin",
    "nargout", "OPm", "OPv", "S", "b", "n" };

  real_T c17_N;
  real_T c17_M;
  real_T c17_p;
  real_T c17_a[1950];
  real_T c17_jStart[13];
  real_T c17_jStop[13];
  real_T c17_jj;
  real_T c17_i;
  real_T c17_k;
  real_T c17_jstart;
  real_T c17_jstop;
  real_T c17_j;
  real_T c17_nargin = 2.0;
  real_T c17_nargout = 3.0;
  real_T c17_S[13];
  real_T c17_b[1950];
  real_T c17_n[13];
  int32_T c17_i18;
  real_T c17_dv3[2];
  int32_T c17_i19;
  int32_T c17_i20;
  int32_T c17_i21;
  int32_T c17_i22;
  int32_T c17_i23;
  int32_T c17_i24;
  real_T c17_b_i;
  real_T c17_b_jj;
  real_T c17_b_j;
  int32_T c17_i25;
  real_T c17_b_jStop[13];
  real_T c17_b_b;
  real_T c17_y;
  real_T c17_A;
  real_T c17_x;
  real_T c17_b_x;
  real_T c17_c_x;
  real_T c17_b_y;
  real_T c17_c_i;
  real_T c17_c_jj;
  real_T c17_c_j;
  int32_T c17_i26;
  int32_T c17_tmp_sizes;
  int32_T c17_loop_ub;
  int32_T c17_i27;
  int32_T c17_tmp_data[13];
  int32_T c17_b_tmp_sizes[2];
  int32_T c17_iv0[2];
  int32_T c17_i28;
  int32_T c17_i29;
  int32_T c17_b_loop_ub;
  int32_T c17_i30;
  real_T c17_b_tmp_data[13];
  int32_T c17_jStop_sizes;
  int32_T c17_c_loop_ub;
  int32_T c17_i31;
  real_T c17_jStop_data[13];
  real_T c17_c_b;
  real_T c17_c_y;
  real_T c17_b_A;
  real_T c17_d_x;
  real_T c17_e_x;
  real_T c17_f_x;
  real_T c17_d_y;
  int32_T c17_i32;
  int32_T c17_i33;
  int32_T c17_i34;
  real_T (*c17_b_S)[13];
  real_T (*c17_d_b)[1950];
  real_T (*c17_b_n)[13];
  real_T (*c17_b_OPv)[2874];
  real_T (*c17_b_OPm)[2874];
  c17_b_n = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 3);
  c17_d_b = (real_T (*)[1950])ssGetOutputPortSignal(chartInstance->S, 2);
  c17_b_OPv = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 1);
  c17_b_S = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
  c17_b_OPm = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 0);
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 16);
  for (c17_i14 = 0; c17_i14 < 2874; c17_i14 = c17_i14 + 1) {
    c17_hoistedGlobal[c17_i14] = (*c17_b_OPm)[c17_i14];
  }

  for (c17_i15 = 0; c17_i15 < 2874; c17_i15 = c17_i15 + 1) {
    c17_b_hoistedGlobal[c17_i15] = (*c17_b_OPv)[c17_i15];
  }

  for (c17_i16 = 0; c17_i16 < 2874; c17_i16 = c17_i16 + 1) {
    c17_OPm[c17_i16] = c17_hoistedGlobal[c17_i16];
  }

  for (c17_i17 = 0; c17_i17 < 2874; c17_i17 = c17_i17 + 1) {
    c17_OPv[c17_i17] = c17_b_hoistedGlobal[c17_i17];
  }

  sf_debug_symbol_scope_push_eml(0U, 19U, 19U, c17_sv0, c17_debug_family_var_map);
  sf_debug_symbol_scope_add_eml(&c17_N, c17_d_sf_marshall, 0U);
  sf_debug_symbol_scope_add_eml(&c17_M, c17_d_sf_marshall, 1U);
  sf_debug_symbol_scope_add_eml(&c17_p, c17_d_sf_marshall, 2U);
  sf_debug_symbol_scope_add_eml(c17_a, c17_b_sf_marshall, 3U);
  sf_debug_symbol_scope_add_eml(c17_jStart, c17_sf_marshall, 4U);
  sf_debug_symbol_scope_add_eml(c17_jStop, c17_sf_marshall, 5U);
  sf_debug_symbol_scope_add_eml(&c17_jj, c17_d_sf_marshall, 6U);
  sf_debug_symbol_scope_add_eml(&c17_i, c17_d_sf_marshall, 7U);
  sf_debug_symbol_scope_add_eml(&c17_k, c17_d_sf_marshall, 8U);
  sf_debug_symbol_scope_add_eml(&c17_jstart, c17_d_sf_marshall, 9U);
  sf_debug_symbol_scope_add_eml(&c17_jstop, c17_d_sf_marshall, 10U);
  sf_debug_symbol_scope_add_eml(&c17_j, c17_d_sf_marshall, 11U);
  sf_debug_symbol_scope_add_eml(&c17_nargin, c17_d_sf_marshall, 12U);
  sf_debug_symbol_scope_add_eml(&c17_nargout, c17_d_sf_marshall, 13U);
  sf_debug_symbol_scope_add_eml(c17_OPm, c17_c_sf_marshall, 14U);
  sf_debug_symbol_scope_add_eml(c17_OPv, c17_c_sf_marshall, 15U);
  sf_debug_symbol_scope_add_eml(c17_S, c17_sf_marshall, 16U);
  sf_debug_symbol_scope_add_eml(c17_b, c17_b_sf_marshall, 17U);
  sf_debug_symbol_scope_add_eml(c17_n, c17_sf_marshall, 18U);
  CV_EML_FCN(0, 0);
  _SFD_EML_CALL(0, 3);
  c17_N = 479.0;
  _SFD_EML_CALL(0, 3);
  for (c17_i18 = 0; c17_i18 < 2; c17_i18 = c17_i18 + 1) {
    c17_dv3[c17_i18] = 479.0 + -473.0 * (real_T)c17_i18;
  }

  c17_M = c17_min(chartInstance, c17_dv3);
  _SFD_EML_CALL(0, 3);
  c17_p = 13.0;

  /* pocet chladicich okruhu */
  _SFD_EML_CALL(0, 4);
  for (c17_i19 = 0; c17_i19 < 1950; c17_i19 = c17_i19 + 1) {
    c17_a[c17_i19] = 0.0;
  }

  _SFD_EML_CALL(0, 4);
  for (c17_i20 = 0; c17_i20 < 1950; c17_i20 = c17_i20 + 1) {
    c17_b[c17_i20] = c17_a[c17_i20];
  }

  _SFD_EML_CALL(0, 5);
  for (c17_i21 = 0; c17_i21 < 13; c17_i21 = c17_i21 + 1) {
    c17_jStart[c17_i21] = 0.0;
  }

  _SFD_EML_CALL(0, 5);
  for (c17_i22 = 0; c17_i22 < 13; c17_i22 = c17_i22 + 1) {
    c17_jStop[c17_i22] = c17_jStart[c17_i22];
  }

  _SFD_EML_CALL(0, 5);
  for (c17_i23 = 0; c17_i23 < 13; c17_i23 = c17_i23 + 1) {
    c17_n[c17_i23] = 0.0;
  }

  _SFD_EML_CALL(0, 6);
  for (c17_i24 = 0; c17_i24 < 13; c17_i24 = c17_i24 + 1) {
    c17_S[c17_i24] = 1.0;
  }

  _SFD_EML_CALL(0, 8);
  c17_jj = 1.0;
  c17_i = 1.0;
  c17_b_i = 1.0;
  while (c17_b_i <= 13.0) {
    c17_i = c17_b_i;
    CV_EML_FOR(0, 0, 1);
    _SFD_EML_CALL(0, 10);
    c17_k = 0.0;
    _SFD_EML_CALL(0, 10);
    c17_jstart = 999.0;
    _SFD_EML_CALL(0, 10);
    c17_jstop = 0.0;
    c17_b_jj = c17_jj;
    c17_j = c17_b_jj;
    c17_b_j = c17_b_jj;
   label_1:
    ;
    if (c17_b_j <= 479.0) {
      c17_j = c17_b_j;
      CV_EML_FOR(0, 1, 1);
      _SFD_EML_CALL(0, 12);
      if (CV_EML_IF(0, 0, c17_OPv[_SFD_EML_ARRAY_BOUNDS_CHECK("OPv", (int32_T)
            c17_j, 1, 479, 1, 0) + 957] == c17_i)) {
        _SFD_EML_CALL(0, 13);
        c17_k = c17_k + 1.0;
        _SFD_EML_CALL(0, 13);
        c17_a[((int32_T)c17_i - 1) + 13 * (_SFD_EML_ARRAY_BOUNDS_CHECK("a",
          (int32_T)c17_k, 1, 150, 2, 0) - 1)] = c17_OPv[
          _SFD_EML_ARRAY_BOUNDS_CHECK("OPv", (int32_T)c17_j, 1, 479, 1, 0) - 1];

        /* vzdalenost rezu */
        _SFD_EML_CALL(0, 14);
        c17_b[((int32_T)c17_i - 1) + 13 * ((int32_T)c17_k - 1)] = c17_j;

        /* poradi rezu */
        _SFD_EML_CALL(0, 15);
        if (CV_EML_IF(0, 1, c17_j < c17_jstart)) {
          _SFD_EML_CALL(0, 16);
          c17_jStart[(int32_T)c17_i - 1] = c17_j;

          /* poradi prvniho rezu v okruhu */
          _SFD_EML_CALL(0, 17);
          c17_jstart = c17_jStart[(int32_T)c17_i - 1];
        }

        _SFD_EML_CALL(0, 19);
        CV_EML_IF(0, 2, c17_j > c17_jstop);
        _SFD_EML_CALL(0, 20);
        c17_jStop[(int32_T)c17_i - 1] = c17_j;

        /* poradi posledniho rezu v okruhu */
      }

      _SFD_EML_CALL(0, 23);
      c17_n[(int32_T)c17_i - 1] = c17_k;
      _SFD_EML_CALL(0, 24);
      if (CV_EML_IF(0, 3, c17_OPv[_SFD_EML_ARRAY_BOUNDS_CHECK("OPv", (int32_T)
            c17_j, 1, 479, 1, 0) + 957] > c17_i)) {
        /* neprochazim nasledujici okruhy */
      } else {
        c17_b_j = c17_b_j + 1.0;
        sf_mex_listen_for_ctrl_c(chartInstance->S);
        goto label_1;
      }
    } else {
      CV_EML_FOR(0, 1, 0);
    }

    /* j - vsechny rezy */
    _SFD_EML_CALL(0, 28);
    for (c17_i25 = 0; c17_i25 < 13; c17_i25 = c17_i25 + 1) {
      c17_b_jStop[c17_i25] = c17_jStop[c17_i25];
    }

    c17_jj = c17_max(chartInstance, c17_b_jStop);

    /* neprochazim predesle okruhy */
    _SFD_EML_CALL(0, 29);
    if (CV_EML_IF(0, 4, c17_n[(int32_T)c17_i - 1] != 0.0)) {
      _SFD_EML_CALL(0, 30);
      c17_b_b = c17_a[(int32_T)c17_i - 1] + c17_a[((int32_T)c17_i - 1) + 13 *
        (_SFD_EML_ARRAY_BOUNDS_CHECK("a", (int32_T)c17_n[(int32_T)
          c17_i - 1], 1, 150, 2, 0) - 1)];
      c17_y = 0.5 * c17_b_b;
      c17_A = c17_y;
      c17_x = c17_A;
      c17_b_x = c17_x;
      c17_c_x = c17_b_x;
      c17_b_y = c17_c_x / 1000.0;
      c17_S[(int32_T)c17_i - 1] = c17_b_y;

      /* stred okruhu v m */
    }

    c17_b_i = c17_b_i + 1.0;
    sf_mex_listen_for_ctrl_c(chartInstance->S);
  }

  CV_EML_FOR(0, 0, 0);

  /* i chladici okruhy */
  _SFD_EML_CALL(0, 33);
  c17_jj = 1.0;
  c17_i = 6.0;
  c17_c_i = 6.0;
  while (c17_c_i <= 13.0) {
    c17_i = c17_c_i;
    CV_EML_FOR(0, 2, 1);
    _SFD_EML_CALL(0, 35);
    c17_k = 0.0;
    _SFD_EML_CALL(0, 35);
    c17_jstart = 999.0;
    _SFD_EML_CALL(0, 35);
    c17_jstop = 0.0;
    c17_c_jj = c17_jj;
    c17_j = c17_c_jj;
    c17_c_j = c17_c_jj;
   label_2:
    ;
    if (c17_c_j <= 479.0) {
      c17_j = c17_c_j;
      CV_EML_FOR(0, 3, 1);
      _SFD_EML_CALL(0, 37);
      if (CV_EML_IF(0, 5, c17_OPm[_SFD_EML_ARRAY_BOUNDS_CHECK("OPm", (int32_T)
            c17_j, 1, 479, 1, 0) + 957] == c17_i)) {
        _SFD_EML_CALL(0, 38);
        c17_k = c17_k + 1.0;
        _SFD_EML_CALL(0, 38);
        c17_a[((int32_T)c17_i - 1) + 13 * (_SFD_EML_ARRAY_BOUNDS_CHECK("a",
          (int32_T)c17_k, 1, 150, 2, 0) - 1)] = c17_OPm[
          _SFD_EML_ARRAY_BOUNDS_CHECK("OPm", (int32_T)c17_j, 1, 479, 1, 0) - 1];

        /* vzdalenost rezu */
        _SFD_EML_CALL(0, 39);
        c17_b[((int32_T)c17_i - 1) + 13 * ((int32_T)c17_k - 1)] = c17_j;

        /* poradi rezu */
        _SFD_EML_CALL(0, 40);
        if (CV_EML_IF(0, 6, c17_j < c17_jstart)) {
          _SFD_EML_CALL(0, 41);
          c17_jStart[(int32_T)c17_i - 1] = c17_j;

          /* poradi prvniho rezu v okruhu */
          _SFD_EML_CALL(0, 42);
          c17_jstart = c17_jStart[(int32_T)c17_i - 1];
        }

        _SFD_EML_CALL(0, 44);
        CV_EML_IF(0, 7, c17_j > c17_jstop);
        _SFD_EML_CALL(0, 45);
        c17_jStop[(int32_T)c17_i - 1] = c17_j;

        /* poradi posledniho rezu v okruhu */
      }

      _SFD_EML_CALL(0, 48);
      if (CV_EML_IF(0, 8, c17_OPm[_SFD_EML_ARRAY_BOUNDS_CHECK("OPm", (int32_T)
            c17_j, 1, 479, 1, 0) + 957] > c17_i)) {
        /* neprochazim nasledujici okruhy */
      } else {
        c17_c_j = c17_c_j + 1.0;
        sf_mex_listen_for_ctrl_c(chartInstance->S);
        goto label_2;
      }
    } else {
      CV_EML_FOR(0, 3, 0);
    }

    /* j - vsechny rezy */
    _SFD_EML_CALL(0, 52);
    c17_i26 = (int32_T)c17_i;
    c17_tmp_sizes = c17_i26;
    c17_loop_ub = c17_i26 - 1;
    for (c17_i27 = 0; c17_i27 <= c17_loop_ub; c17_i27 = c17_i27 + 1) {
      c17_tmp_data[c17_i27] = 1 + c17_i27;
    }

    c17_b_tmp_sizes[0] = 1;
    c17_iv0[0] = 1;
    c17_iv0[1] = c17_tmp_sizes;
    c17_b_tmp_sizes[1] = c17_iv0[1];
    c17_i28 = c17_b_tmp_sizes[0];
    c17_i29 = c17_b_tmp_sizes[1];
    c17_b_loop_ub = c17_tmp_sizes - 1;
    for (c17_i30 = 0; c17_i30 <= c17_b_loop_ub; c17_i30 = c17_i30 + 1) {
      c17_b_tmp_data[c17_i30] = c17_jStop[c17_tmp_data[c17_i30] - 1];
    }

    c17_jStop_sizes = c17_b_tmp_sizes[1];
    c17_c_loop_ub = c17_b_tmp_sizes[1] - 1;
    for (c17_i31 = 0; c17_i31 <= c17_c_loop_ub; c17_i31 = c17_i31 + 1) {
      c17_jStop_data[c17_i31] = c17_b_tmp_data[c17_i31];
    }

    c17_jj = c17_b_max(chartInstance, c17_jStop_data, *((int32_T (*)[1])&
      c17_jStop_sizes));

    /* neprochazim predesle okruhy */
    _SFD_EML_CALL(0, 53);
    if (CV_EML_IF(0, 9, c17_k != 0.0)) {
      _SFD_EML_CALL(0, 54);
      c17_n[(int32_T)c17_i - 1] = c17_k;
      _SFD_EML_CALL(0, 54);
      c17_c_b = c17_a[(int32_T)c17_i - 1] + c17_a[((int32_T)c17_i - 1) + 13 *
        (_SFD_EML_ARRAY_BOUNDS_CHECK("a", (int32_T)c17_n[(int32_T)
          c17_i - 1], 1, 150, 2, 0) - 1)];
      c17_c_y = 0.5 * c17_c_b;
      c17_b_A = c17_c_y;
      c17_d_x = c17_b_A;
      c17_e_x = c17_d_x;
      c17_f_x = c17_e_x;
      c17_d_y = c17_f_x / 1000.0;
      c17_S[(int32_T)c17_i - 1] = c17_d_y;

      /* stred okruhu v m */
    }

    c17_c_i = c17_c_i + 1.0;
    sf_mex_listen_for_ctrl_c(chartInstance->S);
  }

  CV_EML_FOR(0, 2, 0);

  /* i chladici okruhy */
  _SFD_EML_CALL(0, -54);
  sf_debug_symbol_scope_pop();
  for (c17_i32 = 0; c17_i32 < 13; c17_i32 = c17_i32 + 1) {
    (*c17_b_S)[c17_i32] = c17_S[c17_i32];
  }

  for (c17_i33 = 0; c17_i33 < 1950; c17_i33 = c17_i33 + 1) {
    (*c17_d_b)[c17_i33] = c17_b[c17_i33];
  }

  for (c17_i34 = 0; c17_i34 < 13; c17_i34 = c17_i34 + 1) {
    (*c17_b_n)[c17_i34] = c17_n[c17_i34];
  }

  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 16);
}

static void compInitSubchartSimstructsFcn_c17_ental(SFc17_entalInstanceStruct
  *chartInstance)
{
}

static void init_script_number_translation(uint32_T c17_machineNumber, uint32_T
  c17_chartNumber)
{
}

static real_T c17_min(SFc17_entalInstanceStruct *chartInstance, real_T
                      c17_varargin_1[2])
{
  real_T c17_mtmp;
  int32_T c17_ix;
  int32_T c17_k;
  int32_T c17_a;
  real_T c17_b_mtmp;
  c17_mtmp = 479.0;
  c17_ix = 1;
  for (c17_k = 2; c17_k < 3; c17_k = 3) {
    c17_a = c17_ix;
    c17_ix = c17_a + 1;
    _SFD_EML_ARRAY_BOUNDS_CHECK("", c17_ix, 1, 2, 1, 0);
    if (6.0 < c17_mtmp) {
      c17_mtmp = 6.0;
    }
  }

  c17_b_mtmp = c17_mtmp;
  return c17_b_mtmp;
}

static real_T c17_max(SFc17_entalInstanceStruct *chartInstance, real_T
                      c17_varargin_1[13])
{
  int32_T c17_i35;
  real_T c17_x[13];
  int32_T c17_i36;
  real_T c17_b_x[13];
  real_T c17_mtmp;
  int32_T c17_ix;
  int32_T c17_k;
  int32_T c17_a;
  real_T c17_b_mtmp;
  for (c17_i35 = 0; c17_i35 < 13; c17_i35 = c17_i35 + 1) {
    c17_x[c17_i35] = c17_varargin_1[c17_i35];
  }

  for (c17_i36 = 0; c17_i36 < 13; c17_i36 = c17_i36 + 1) {
    c17_b_x[c17_i36] = c17_x[c17_i36];
  }

  c17_mtmp = c17_b_x[0];
  c17_ix = 1;
  for (c17_k = 2; c17_k < 14; c17_k = c17_k + 1) {
    c17_a = c17_ix;
    c17_ix = c17_a + 1;
    if (c17_b_x[_SFD_EML_ARRAY_BOUNDS_CHECK("", c17_ix, 1, 13, 1, 0) - 1] >
        c17_mtmp) {
      c17_mtmp = c17_b_x[c17_ix - 1];
    }
  }

  c17_b_mtmp = c17_mtmp;
  return c17_b_mtmp;
}

static real_T c17_b_max(SFc17_entalInstanceStruct *chartInstance, real_T
  c17_varargin_1_data[13], int32_T c17_varargin_1_sizes[1])
{
  int32_T c17_x_sizes;
  int32_T c17_loop_ub;
  int32_T c17_i37;
  real_T c17_x_data[13];
  boolean_T c17_b0;
  int32_T c17_i38;
  static char_T c17_cv0[52] = { 'E', 'm', 'b', 'e', 'd', 'd', 'e', 'd', 'M', 'A',
    'T', 'L', 'A', 'B', ':', 'e', 'm', 'l', '_', 'm',
    'i', 'n', '_', 'o', 'r', '_', 'm', 'a', 'x', ':', 'a', 'u', 't', 'o', 'D',
    'i', 'm', 'I', 'n', 'c',
    'o', 'm', 'p', 'a', 't', 'i', 'b', 'i', 'l', 'i', 't', 'y' };

  char_T c17_u[52];
  const mxArray *c17_y = NULL;
  int32_T c17_i39;
  static char_T c17_cv1[191] = { 'T', 'h', 'e', ' ', 'w', 'o', 'r', 'k', 'i',
    'n', 'g', ' ', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o',
    'n', ' ', 'w', 'a', 's', ' ', 's', 'e', 'l', 'e', 'c', 't', 'e', 'd', ' ',
    'a', 'u', 't', 'o', 'm',
    'a', 't', 'i', 'c', 'a', 'l', 'l', 'y', ',', ' ', 'i', 's', ' ', 'v', 'a',
    'r', 'i', 'a', 'b', 'l',
    'e', '-', 'l', 'e', 'n', 'g', 't', 'h', ',', ' ', 'a', 'n', 'd', ' ', 'h',
    'a', 's', ' ', 'l', 'e',
    'n', 'g', 't', 'h', ' ', '1', ' ', 'a', 't', ' ', 'r', 'u', 'n', '-', 't',
    'i', 'm', 'e', '.', ' ',
    'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p',
    'p', 'o', 'r', 't', 'e',
    'd', '.', ' ', 'M', 'a', 'n', 'u', 'a', 'l', 'l', 'y', ' ', 's', 'e', 'l',
    'e', 'c', 't', ' ', 't',
    'h', 'e', ' ', 'w', 'o', 'r', 'k', 'i', 'n', 'g', ' ', 'd', 'i', 'm', 'e',
    'n', 's', 'i', 'o', 'n',
    ' ', 'b', 'y', ' ', 's', 'u', 'p', 'p', 'l', 'y', 'i', 'n', 'g', ' ', 't',
    'h', 'e', ' ', 'D', 'I',
    'M', ' ', 'a', 'r', 'g', 'u', 'm', 'e', 'n', 't', '.' };

  char_T c17_b_u[191];
  const mxArray *c17_b_y = NULL;
  int32_T c17_i40;
  static char_T c17_cv2[40] = { 'E', 'm', 'b', 'e', 'd', 'd', 'e', 'd', 'M', 'A',
    'T', 'L', 'A', 'B', ':', 'e', 'm', 'l', '_', 'm',
    'i', 'n', '_', 'o', 'r', '_', 'm', 'a', 'x', ':', 'v', 'a', 'r', 'D', 'i',
    'm', 'Z', 'e', 'r', 'o' };

  char_T c17_c_u[40];
  const mxArray *c17_c_y = NULL;
  int32_T c17_i41;
  static char_T c17_cv3[102] = { 'I', 'f', ' ', 't', 'h', 'e', ' ', 'w', 'o',
    'r', 'k', 'i', 'n', 'g', ' ', 'd', 'i', 'm', 'e', 'n',
    's', 'i', 'o', 'n', ' ', 'o', 'f', ' ', 'M', 'A', 'X', ' ', 'o', 'r', ' ',
    'M', 'I', 'N', ' ', 'i',
    's', ' ', 'v', 'a', 'r', 'i', 'a', 'b', 'l', 'e', ' ', 'i', 'n', ' ', 'l',
    'e', 'n', 'g', 't', 'h',
    ',', ' ', 'i', 't', ' ', 'm', 'u', 's', 't', ' ', 'n', 'o', 't', ' ', 'h',
    'a', 'v', 'e', ' ', 'z',
    'e', 'r', 'o', ' ', 'l', 'e', 'n', 'g', 't', 'h', ' ', 'a', 't', ' ', 'r',
    'u', 'n', 't', 'i', 'm',
    'e', '.' };

  char_T c17_d_u[102];
  const mxArray *c17_d_y = NULL;
  int32_T c17_b_x_sizes;
  int32_T c17_b_loop_ub;
  int32_T c17_i42;
  real_T c17_b_x_data[13];
  real_T c17_d0;
  real_T c17_d1;
  real_T c17_d2;
  int32_T c17_i43;
  int32_T c17_n;
  real_T c17_mtmp;
  int32_T c17_ix;
  int32_T c17_k;
  int32_T c17_a;
  real_T c17_b_mtmp;
  c17_x_sizes = c17_varargin_1_sizes[0];
  c17_loop_ub = c17_varargin_1_sizes[0] - 1;
  for (c17_i37 = 0; c17_i37 <= c17_loop_ub; c17_i37 = c17_i37 + 1) {
    c17_x_data[c17_i37] = c17_varargin_1_data[c17_i37];
  }

  if (c17_x_sizes == 1) {
  } else if ((real_T)c17_x_sizes != 1.0) {
  } else {
    c17_b0 = FALSE;
    goto label_1;
  }

  c17_b0 = TRUE;
 label_1:
  ;
  if (c17_b0) {
  } else {
    for (c17_i38 = 0; c17_i38 < 52; c17_i38 = c17_i38 + 1) {
      c17_u[c17_i38] = c17_cv0[c17_i38];
    }

    c17_y = NULL;
    sf_mex_assign(&c17_y, sf_mex_create("y", c17_u, 10, 0U, 1U, 0U, 2, 1, 52));
    for (c17_i39 = 0; c17_i39 < 191; c17_i39 = c17_i39 + 1) {
      c17_b_u[c17_i39] = c17_cv1[c17_i39];
    }

    c17_b_y = NULL;
    sf_mex_assign(&c17_b_y, sf_mex_create("y", c17_b_u, 10, 0U, 1U, 0U, 2, 1,
      191));
    sf_mex_call_debug("error", 0U, 2U, 14, c17_y, 14, c17_b_y);
  }

  if ((real_T)c17_x_sizes > 0.0) {
  } else {
    for (c17_i40 = 0; c17_i40 < 40; c17_i40 = c17_i40 + 1) {
      c17_c_u[c17_i40] = c17_cv2[c17_i40];
    }

    c17_c_y = NULL;
    sf_mex_assign(&c17_c_y, sf_mex_create("y", c17_c_u, 10, 0U, 1U, 0U, 2, 1, 40));
    for (c17_i41 = 0; c17_i41 < 102; c17_i41 = c17_i41 + 1) {
      c17_d_u[c17_i41] = c17_cv3[c17_i41];
    }

    c17_d_y = NULL;
    sf_mex_assign(&c17_d_y, sf_mex_create("y", c17_d_u, 10, 0U, 1U, 0U, 2, 1,
      102));
    sf_mex_call_debug("error", 0U, 2U, 14, c17_c_y, 14, c17_d_y);
  }

  c17_b_x_sizes = c17_x_sizes;
  c17_b_loop_ub = c17_x_sizes - 1;
  for (c17_i42 = 0; c17_i42 <= c17_b_loop_ub; c17_i42 = c17_i42 + 1) {
    c17_b_x_data[c17_i42] = c17_x_data[c17_i42];
  }

  c17_d0 = (real_T)c17_b_x_sizes;
  c17_d1 = c17_d0;
  c17_d1 = c17_d1 < 0.0 ? muDoubleScalarCeil(c17_d1 - 0.5) : muDoubleScalarFloor
    (c17_d1 + 0.5);
  c17_d2 = c17_d1;
  if (c17_d2 < 2.147483648E+9) {
    if (c17_d2 >= -2.147483648E+9) {
      c17_i43 = (int32_T)c17_d2;
    } else {
      c17_i43 = MIN_int32_T;
    }
  } else if (c17_d2 >= 2.147483648E+9) {
    c17_i43 = MAX_int32_T;
  } else {
    c17_i43 = 0;
  }

  c17_n = c17_i43;
  c17_mtmp = c17_b_x_data[0];
  if ((real_T)c17_n == 1.0) {
  } else {
    c17_ix = 1;
    for (c17_k = 2; c17_k <= c17_n; c17_k = c17_k + 1) {
      c17_a = c17_ix;
      c17_ix = c17_a + 1;
      if (c17_b_x_data[_SFD_EML_ARRAY_BOUNDS_CHECK("", c17_ix, 1, c17_b_x_sizes,
           1, 0) - 1] > c17_mtmp) {
        c17_mtmp = c17_b_x_data[_SFD_EML_ARRAY_BOUNDS_CHECK("", c17_ix, 1,
          c17_b_x_sizes, 1, 0) - 1];
      }
    }
  }

  c17_b_mtmp = c17_mtmp;
  return c17_b_mtmp;
}

static const mxArray *c17_sf_marshall(void *chartInstanceVoid, void *c17_u)
{
  const mxArray *c17_y = NULL;
  int32_T c17_i44;
  real_T c17_b_u[13];
  int32_T c17_i45;
  real_T c17_c_u[13];
  const mxArray *c17_b_y = NULL;
  SFc17_entalInstanceStruct *chartInstance;
  chartInstance = (SFc17_entalInstanceStruct *)chartInstanceVoid;
  c17_y = NULL;
  for (c17_i44 = 0; c17_i44 < 13; c17_i44 = c17_i44 + 1) {
    c17_b_u[c17_i44] = (*((real_T (*)[13])c17_u))[c17_i44];
  }

  for (c17_i45 = 0; c17_i45 < 13; c17_i45 = c17_i45 + 1) {
    c17_c_u[c17_i45] = c17_b_u[c17_i45];
  }

  c17_b_y = NULL;
  sf_mex_assign(&c17_b_y, sf_mex_create("y", c17_c_u, 0, 0U, 1U, 0U, 1, 13));
  sf_mex_assign(&c17_y, c17_b_y);
  return c17_y;
}

static const mxArray *c17_b_sf_marshall(void *chartInstanceVoid, void *c17_u)
{
  const mxArray *c17_y = NULL;
  int32_T c17_i46;
  int32_T c17_i47;
  int32_T c17_i48;
  real_T c17_b_u[1950];
  int32_T c17_i49;
  int32_T c17_i50;
  int32_T c17_i51;
  real_T c17_c_u[1950];
  const mxArray *c17_b_y = NULL;
  SFc17_entalInstanceStruct *chartInstance;
  chartInstance = (SFc17_entalInstanceStruct *)chartInstanceVoid;
  c17_y = NULL;
  c17_i46 = 0;
  for (c17_i47 = 0; c17_i47 < 150; c17_i47 = c17_i47 + 1) {
    for (c17_i48 = 0; c17_i48 < 13; c17_i48 = c17_i48 + 1) {
      c17_b_u[c17_i48 + c17_i46] = (*((real_T (*)[1950])c17_u))[c17_i48 +
        c17_i46];
    }

    c17_i46 = c17_i46 + 13;
  }

  c17_i49 = 0;
  for (c17_i50 = 0; c17_i50 < 150; c17_i50 = c17_i50 + 1) {
    for (c17_i51 = 0; c17_i51 < 13; c17_i51 = c17_i51 + 1) {
      c17_c_u[c17_i51 + c17_i49] = c17_b_u[c17_i51 + c17_i49];
    }

    c17_i49 = c17_i49 + 13;
  }

  c17_b_y = NULL;
  sf_mex_assign(&c17_b_y, sf_mex_create("y", c17_c_u, 0, 0U, 1U, 0U, 2, 13, 150));
  sf_mex_assign(&c17_y, c17_b_y);
  return c17_y;
}

static const mxArray *c17_c_sf_marshall(void *chartInstanceVoid, void *c17_u)
{
  const mxArray *c17_y = NULL;
  int32_T c17_i52;
  int32_T c17_i53;
  int32_T c17_i54;
  real_T c17_b_u[2874];
  int32_T c17_i55;
  int32_T c17_i56;
  int32_T c17_i57;
  real_T c17_c_u[2874];
  const mxArray *c17_b_y = NULL;
  SFc17_entalInstanceStruct *chartInstance;
  chartInstance = (SFc17_entalInstanceStruct *)chartInstanceVoid;
  c17_y = NULL;
  c17_i52 = 0;
  for (c17_i53 = 0; c17_i53 < 6; c17_i53 = c17_i53 + 1) {
    for (c17_i54 = 0; c17_i54 < 479; c17_i54 = c17_i54 + 1) {
      c17_b_u[c17_i54 + c17_i52] = (*((real_T (*)[2874])c17_u))[c17_i54 +
        c17_i52];
    }

    c17_i52 = c17_i52 + 479;
  }

  c17_i55 = 0;
  for (c17_i56 = 0; c17_i56 < 6; c17_i56 = c17_i56 + 1) {
    for (c17_i57 = 0; c17_i57 < 479; c17_i57 = c17_i57 + 1) {
      c17_c_u[c17_i57 + c17_i55] = c17_b_u[c17_i57 + c17_i55];
    }

    c17_i55 = c17_i55 + 479;
  }

  c17_b_y = NULL;
  sf_mex_assign(&c17_b_y, sf_mex_create("y", c17_c_u, 0, 0U, 1U, 0U, 2, 479, 6));
  sf_mex_assign(&c17_y, c17_b_y);
  return c17_y;
}

static const mxArray *c17_d_sf_marshall(void *chartInstanceVoid, void *c17_u)
{
  const mxArray *c17_y = NULL;
  real_T c17_b_u;
  const mxArray *c17_b_y = NULL;
  SFc17_entalInstanceStruct *chartInstance;
  chartInstance = (SFc17_entalInstanceStruct *)chartInstanceVoid;
  c17_y = NULL;
  c17_b_u = *((real_T *)c17_u);
  c17_b_y = NULL;
  sf_mex_assign(&c17_b_y, sf_mex_create("y", &c17_b_u, 0, 0U, 0U, 0U, 0));
  sf_mex_assign(&c17_y, c17_b_y);
  return c17_y;
}

const mxArray *sf_c17_ental_get_eml_resolved_functions_info(void)
{
  const mxArray *c17_nameCaptureInfo = NULL;
  c17_ResolvedFunctionInfo c17_info[38];
  const mxArray *c17_m0 = NULL;
  int32_T c17_i58;
  c17_ResolvedFunctionInfo *c17_r0;
  c17_nameCaptureInfo = NULL;
  c17_info_helper(c17_info);
  sf_mex_assign(&c17_m0, sf_mex_createstruct("nameCaptureInfo", 1, 38));
  for (c17_i58 = 0; c17_i58 < 38; c17_i58 = c17_i58 + 1) {
    c17_r0 = &c17_info[c17_i58];
    sf_mex_addfield(c17_m0, sf_mex_create("nameCaptureInfo", c17_r0->context, 15,
      0U, 0U, 0U, 2, 1, strlen(c17_r0->context)), "context"
                    , "nameCaptureInfo", c17_i58);
    sf_mex_addfield(c17_m0, sf_mex_create("nameCaptureInfo", c17_r0->name, 15,
      0U, 0U, 0U, 2, 1, strlen(c17_r0->name)), "name",
                    "nameCaptureInfo", c17_i58);
    sf_mex_addfield(c17_m0, sf_mex_create("nameCaptureInfo",
      c17_r0->dominantType, 15, 0U, 0U, 0U, 2, 1, strlen(c17_r0->dominantType)),
                    "dominantType", "nameCaptureInfo", c17_i58);
    sf_mex_addfield(c17_m0, sf_mex_create("nameCaptureInfo", c17_r0->resolved,
      15, 0U, 0U, 0U, 2, 1, strlen(c17_r0->resolved)),
                    "resolved", "nameCaptureInfo", c17_i58);
    sf_mex_addfield(c17_m0, sf_mex_create("nameCaptureInfo", &c17_r0->fileLength,
      7, 0U, 0U, 0U, 0), "fileLength", "nameCaptureInfo",
                    c17_i58);
    sf_mex_addfield(c17_m0, sf_mex_create("nameCaptureInfo", &c17_r0->fileTime1,
      7, 0U, 0U, 0U, 0), "fileTime1", "nameCaptureInfo",
                    c17_i58);
    sf_mex_addfield(c17_m0, sf_mex_create("nameCaptureInfo", &c17_r0->fileTime2,
      7, 0U, 0U, 0U, 0), "fileTime2", "nameCaptureInfo",
                    c17_i58);
  }

  sf_mex_assign(&c17_nameCaptureInfo, c17_m0);
  return c17_nameCaptureInfo;
}

static void c17_info_helper(c17_ResolvedFunctionInfo c17_info[38])
{
  c17_info[0].context = "";
  c17_info[0].name = "size";
  c17_info[0].dominantType = "double";
  c17_info[0].resolved = "[B]size";
  c17_info[0].fileLength = 0U;
  c17_info[0].fileTime1 = 0U;
  c17_info[0].fileTime2 = 0U;
  c17_info[1].context = "";
  c17_info[1].name = "max";
  c17_info[1].dominantType = "double";
  c17_info[1].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/datafun/max.m";
  c17_info[1].fileLength = 362U;
  c17_info[1].fileTime1 = 1245102360U;
  c17_info[1].fileTime2 = 0U;
  c17_info[2].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/datafun/max.m";
  c17_info[2].name = "nargin";
  c17_info[2].dominantType = "";
  c17_info[2].resolved = "[B]nargin";
  c17_info[2].fileLength = 0U;
  c17_info[2].fileTime1 = 0U;
  c17_info[2].fileTime2 = 0U;
  c17_info[3].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/datafun/max.m";
  c17_info[3].name = "gt";
  c17_info[3].dominantType = "double";
  c17_info[3].resolved = "[B]gt";
  c17_info[3].fileLength = 0U;
  c17_info[3].fileTime1 = 0U;
  c17_info[3].fileTime2 = 0U;
  c17_info[4].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/datafun/max.m";
  c17_info[4].name = "le";
  c17_info[4].dominantType = "double";
  c17_info[4].resolved = "[B]le";
  c17_info[4].fileLength = 0U;
  c17_info[4].fileTime1 = 0U;
  c17_info[4].fileTime2 = 0U;
  c17_info[5].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/datafun/max.m";
  c17_info[5].name = "nargout";
  c17_info[5].dominantType = "";
  c17_info[5].resolved = "[B]nargout";
  c17_info[5].fileLength = 0U;
  c17_info[5].fileTime1 = 0U;
  c17_info[5].fileTime2 = 0U;
  c17_info[6].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/datafun/max.m";
  c17_info[6].name = "eml_min_or_max";
  c17_info[6].dominantType = "char";
  c17_info[6].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[6].fileLength = 9967U;
  c17_info[6].fileTime1 = 1261951870U;
  c17_info[6].fileTime2 = 0U;
  c17_info[7].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[7].name = "ischar";
  c17_info[7].dominantType = "char";
  c17_info[7].resolved = "[B]ischar";
  c17_info[7].fileLength = 0U;
  c17_info[7].fileTime1 = 0U;
  c17_info[7].fileTime2 = 0U;
  c17_info[8].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[8].name = "strcmp";
  c17_info[8].dominantType = "char";
  c17_info[8].resolved = "[B]strcmp";
  c17_info[8].fileLength = 0U;
  c17_info[8].fileTime1 = 0U;
  c17_info[8].fileTime2 = 0U;
  c17_info[9].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[9].name = "isnumeric";
  c17_info[9].dominantType = "double";
  c17_info[9].resolved = "[B]isnumeric";
  c17_info[9].fileLength = 0U;
  c17_info[9].fileTime1 = 0U;
  c17_info[9].fileTime2 = 0U;
  c17_info[10].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[10].name = "isreal";
  c17_info[10].dominantType = "double";
  c17_info[10].resolved = "[B]isreal";
  c17_info[10].fileLength = 0U;
  c17_info[10].fileTime1 = 0U;
  c17_info[10].fileTime2 = 0U;
  c17_info[11].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[11].name = "eq";
  c17_info[11].dominantType = "double";
  c17_info[11].resolved = "[B]eq";
  c17_info[11].fileLength = 0U;
  c17_info[11].fileTime1 = 0U;
  c17_info[11].fileTime2 = 0U;
  c17_info[12].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[12].name = "eml_const_nonsingleton_dim";
  c17_info[12].dominantType = "double";
  c17_info[12].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_const_nonsingleton_dim.m";
  c17_info[12].fileLength = 1473U;
  c17_info[12].fileTime1 = 1240262002U;
  c17_info[12].fileTime2 = 0U;
  c17_info[13].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_const_nonsingleton_dim.m!local_const_nonsingleton_dim";
  c17_info[13].name = "not";
  c17_info[13].dominantType = "logical";
  c17_info[13].resolved = "[B]not";
  c17_info[13].fileLength = 0U;
  c17_info[13].fileTime1 = 0U;
  c17_info[13].fileTime2 = 0U;
  c17_info[14].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_const_nonsingleton_dim.m!local_const_nonsingleton_dim";
  c17_info[14].name = "ne";
  c17_info[14].dominantType = "double";
  c17_info[14].resolved = "[B]ne";
  c17_info[14].fileLength = 0U;
  c17_info[14].fileTime1 = 0U;
  c17_info[14].fileTime2 = 0U;
  c17_info[15].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[15].name = "eml_scalar_eg";
  c17_info[15].dominantType = "double";
  c17_info[15].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m";
  c17_info[15].fileLength = 3068U;
  c17_info[15].fileTime1 = 1240262010U;
  c17_info[15].fileTime2 = 0U;
  c17_info[16].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m!any_enums";
  c17_info[16].name = "false";
  c17_info[16].dominantType = "";
  c17_info[16].resolved = "[B]false";
  c17_info[16].fileLength = 0U;
  c17_info[16].fileTime1 = 0U;
  c17_info[16].fileTime2 = 0U;
  c17_info[17].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m";
  c17_info[17].name = "isstruct";
  c17_info[17].dominantType = "double";
  c17_info[17].resolved = "[B]isstruct";
  c17_info[17].fileLength = 0U;
  c17_info[17].fileTime1 = 0U;
  c17_info[17].fileTime2 = 0U;
  c17_info[18].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m";
  c17_info[18].name = "isa";
  c17_info[18].dominantType = "double";
  c17_info[18].resolved = "[B]isa";
  c17_info[18].fileLength = 0U;
  c17_info[18].fileTime1 = 0U;
  c17_info[18].fileTime2 = 0U;
  c17_info[19].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m!zerosum";
  c17_info[19].name = "class";
  c17_info[19].dominantType = "double";
  c17_info[19].resolved = "[B]class";
  c17_info[19].fileLength = 0U;
  c17_info[19].fileTime1 = 0U;
  c17_info[19].fileTime2 = 0U;
  c17_info[20].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m!zerosum";
  c17_info[20].name = "cast";
  c17_info[20].dominantType = "double";
  c17_info[20].resolved = "[B]cast";
  c17_info[20].fileLength = 0U;
  c17_info[20].fileTime1 = 0U;
  c17_info[20].fileTime2 = 0U;
  c17_info[21].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[21].name = "ones";
  c17_info[21].dominantType = "double";
  c17_info[21].resolved = "[B]ones";
  c17_info[21].fileLength = 0U;
  c17_info[21].fileTime1 = 0U;
  c17_info[21].fileTime2 = 0U;
  c17_info[22].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[22].name = "eml_index_class";
  c17_info[22].dominantType = "";
  c17_info[22].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_index_class.m";
  c17_info[22].fileLength = 909U;
  c17_info[22].fileTime1 = 1192466782U;
  c17_info[22].fileTime2 = 0U;
  c17_info[23].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[23].name = "isempty";
  c17_info[23].dominantType = "double";
  c17_info[23].resolved = "[B]isempty";
  c17_info[23].fileLength = 0U;
  c17_info[23].fileTime1 = 0U;
  c17_info[23].fileTime2 = 0U;
  c17_info[24].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m";
  c17_info[24].name = "isscalar";
  c17_info[24].dominantType = "double";
  c17_info[24].resolved = "[B]isscalar";
  c17_info[24].fileLength = 0U;
  c17_info[24].fileTime1 = 0U;
  c17_info[24].fileTime2 = 0U;
  c17_info[25].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m!eml_extremum_sub";
  c17_info[25].name = "lt";
  c17_info[25].dominantType = "double";
  c17_info[25].resolved = "[B]lt";
  c17_info[25].fileLength = 0U;
  c17_info[25].fileTime1 = 0U;
  c17_info[25].fileTime2 = 0U;
  c17_info[26].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m!eml_extremum_sub";
  c17_info[26].name = "isnan";
  c17_info[26].dominantType = "double";
  c17_info[26].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elmat/isnan.m";
  c17_info[26].fileLength = 541U;
  c17_info[26].fileTime1 = 1271405588U;
  c17_info[26].fileTime2 = 0U;
  c17_info[27].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m!eml_extremum_sub";
  c17_info[27].name = "true";
  c17_info[27].dominantType = "";
  c17_info[27].resolved = "[B]true";
  c17_info[27].fileLength = 0U;
  c17_info[27].fileTime1 = 0U;
  c17_info[27].fileTime2 = 0U;
  c17_info[28].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_min_or_max.m!eml_extremum_sub";
  c17_info[28].name = "eml_index_plus";
  c17_info[28].dominantType = "int32";
  c17_info[28].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_index_plus.m";
  c17_info[28].fileLength = 272U;
  c17_info[28].fileTime1 = 1192466784U;
  c17_info[28].fileTime2 = 0U;
  c17_info[29].context = "";
  c17_info[29].name = "min";
  c17_info[29].dominantType = "double";
  c17_info[29].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/datafun/min.m";
  c17_info[29].fileLength = 362U;
  c17_info[29].fileTime1 = 1245102364U;
  c17_info[29].fileTime2 = 0U;
  c17_info[30].context = "";
  c17_info[30].name = "zeros";
  c17_info[30].dominantType = "double";
  c17_info[30].resolved = "[B]zeros";
  c17_info[30].fileLength = 0U;
  c17_info[30].fileTime1 = 0U;
  c17_info[30].fileTime2 = 0U;
  c17_info[31].context = "";
  c17_info[31].name = "plus";
  c17_info[31].dominantType = "double";
  c17_info[31].resolved = "[B]plus";
  c17_info[31].fileLength = 0U;
  c17_info[31].fileTime1 = 0U;
  c17_info[31].fileTime2 = 0U;
  c17_info[32].context = "";
  c17_info[32].name = "mrdivide";
  c17_info[32].dominantType = "double";
  c17_info[32].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c17_info[32].fileLength = 432U;
  c17_info[32].fileTime1 = 1277748222U;
  c17_info[32].fileTime2 = 0U;
  c17_info[33].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c17_info[33].name = "ge";
  c17_info[33].dominantType = "double";
  c17_info[33].resolved = "[B]ge";
  c17_info[33].fileLength = 0U;
  c17_info[33].fileTime1 = 0U;
  c17_info[33].fileTime2 = 0U;
  c17_info[34].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mrdivide.p";
  c17_info[34].name = "rdivide";
  c17_info[34].dominantType = "double";
  c17_info[34].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  c17_info[34].fileLength = 403U;
  c17_info[34].fileTime1 = 1245102420U;
  c17_info[34].fileTime2 = 0U;
  c17_info[35].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  c17_info[35].name = "eml_div";
  c17_info[35].dominantType = "double";
  c17_info[35].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  c17_info[35].fileLength = 4918U;
  c17_info[35].fileTime1 = 1267063410U;
  c17_info[35].fileTime2 = 0U;
  c17_info[36].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  c17_info[36].name = "isinteger";
  c17_info[36].dominantType = "double";
  c17_info[36].resolved = "[B]isinteger";
  c17_info[36].fileLength = 0U;
  c17_info[36].fileTime1 = 0U;
  c17_info[36].fileTime2 = 0U;
  c17_info[37].context = "";
  c17_info[37].name = "mtimes";
  c17_info[37].dominantType = "double";
  c17_info[37].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  c17_info[37].fileLength = 3425U;
  c17_info[37].fileTime1 = 1251031872U;
  c17_info[37].fileTime2 = 0U;
}

static const mxArray *c17_e_sf_marshall(void *chartInstanceVoid, void *c17_u)
{
  const mxArray *c17_y = NULL;
  boolean_T c17_b_u;
  const mxArray *c17_b_y = NULL;
  SFc17_entalInstanceStruct *chartInstance;
  chartInstance = (SFc17_entalInstanceStruct *)chartInstanceVoid;
  c17_y = NULL;
  c17_b_u = *((boolean_T *)c17_u);
  c17_b_y = NULL;
  sf_mex_assign(&c17_b_y, sf_mex_create("y", &c17_b_u, 11, 0U, 0U, 0U, 0));
  sf_mex_assign(&c17_y, c17_b_y);
  return c17_y;
}

static void c17_emlrt_marshallIn(SFc17_entalInstanceStruct *chartInstance, const
  mxArray *c17_S, const char_T *c17_name, real_T
  c17_y[13])
{
  real_T c17_dv4[13];
  int32_T c17_i59;
  sf_mex_import(c17_name, sf_mex_dup(c17_S), c17_dv4, 1, 0, 0U, 1, 0U, 1, 13);
  for (c17_i59 = 0; c17_i59 < 13; c17_i59 = c17_i59 + 1) {
    c17_y[c17_i59] = c17_dv4[c17_i59];
  }

  sf_mex_destroy(&c17_S);
}

static void c17_b_emlrt_marshallIn(SFc17_entalInstanceStruct *chartInstance,
  const mxArray *c17_b, const char_T *c17_name, real_T
  c17_y[1950])
{
  real_T c17_dv5[1950];
  int32_T c17_i60;
  sf_mex_import(c17_name, sf_mex_dup(c17_b), c17_dv5, 1, 0, 0U, 1, 0U, 2, 13,
                150);
  for (c17_i60 = 0; c17_i60 < 1950; c17_i60 = c17_i60 + 1) {
    c17_y[c17_i60] = c17_dv5[c17_i60];
  }

  sf_mex_destroy(&c17_b);
}

static uint8_T c17_c_emlrt_marshallIn(SFc17_entalInstanceStruct *chartInstance,
  const mxArray *c17_b_is_active_c17_ental, const
  char_T *c17_name)
{
  uint8_T c17_y;
  uint8_T c17_u0;
  sf_mex_import(c17_name, sf_mex_dup(c17_b_is_active_c17_ental), &c17_u0, 1, 3,
                0U, 0, 0U, 0);
  c17_y = c17_u0;
  sf_mex_destroy(&c17_b_is_active_c17_ental);
  return c17_y;
}

static void init_dsm_address_info(SFc17_entalInstanceStruct *chartInstance)
{
}

/* SFunction Glue Code */
void sf_c17_ental_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(2996278658U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(423646557U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(4011927867U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(3144734915U);
}

mxArray *sf_c17_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)(4274052511U);
    pr[1] = (double)(2405438418U);
    pr[2] = (double)(813979285U);
    pr[3] = (double)(2948542406U);
    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)(479);
      pr[1] = (double)(6);
      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));
    mxSetField(mxAutoinheritanceInfo,0,"inputs",mxData);
  }

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

  {
    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)(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));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(13);
      pr[1] = (double)(150);
      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)(13);
      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,"outputs",mxData);
  }

  return(mxAutoinheritanceInfo);
}

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

  mxArray *mxInfo = mxCreateStructMatrix(1, 1, 2, infoFields);
  const char *infoEncStr[] = {
    "100 S1x4'type','srcId','name','auxInfo'{{M[1],M[5],T\"S\",},{M[1],M[36],T\"b\",},{M[1],M[37],T\"n\",},{M[8],M[0],T\"is_active_c17_ental\",}}"
  };

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 4, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c17_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)) {
    SFc17_entalInstanceStruct *chartInstance;
    chartInstance = (SFc17_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_,
          17,
          1,
          1,
          5,
          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,"OPm");
          _SFD_SET_DATA_PROPS(1,2,0,1,"S");
          _SFD_SET_DATA_PROPS(2,1,1,0,"OPv");
          _SFD_SET_DATA_PROPS(3,2,0,1,"b");
          _SFD_SET_DATA_PROPS(4,2,0,1,"n");
          _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,10,0,0,4,0,0,0);
        _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",0,-1,1571);
        _SFD_CV_INIT_EML_IF(0,0,248,262,-1,595);
        _SFD_CV_INIT_EML_IF(0,1,363,374,-1,483);
        _SFD_CV_INIT_EML_IF(0,2,496,506,-1,583);
        _SFD_CV_INIT_EML_IF(0,3,622,635,-1,-2);
        _SFD_CV_INIT_EML_IF(0,4,777,787,-1,855);
        _SFD_CV_INIT_EML_IF(0,5,947,961,-1,1294);
        _SFD_CV_INIT_EML_IF(0,6,1062,1073,-1,1182);
        _SFD_CV_INIT_EML_IF(0,7,1195,1205,-1,1282);
        _SFD_CV_INIT_EML_IF(0,8,1305,1318,-1,-2);
        _SFD_CV_INIT_EML_IF(0,9,1465,1472,-1,1548);
        _SFD_CV_INIT_EML_FOR(0,0,186,196,859);
        _SFD_CV_INIT_EML_FOR(0,1,229,240,706);
        _SFD_CV_INIT_EML_FOR(0,2,885,895,1552);
        _SFD_CV_INIT_EML_FOR(0,3,928,939,1389);
        _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]= 479;
          dimVector[1]= 6;
          _SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c17_c_sf_marshall);
        }

        {
          unsigned int dimVector[1];
          dimVector[0]= 13;
          _SFD_SET_DATA_COMPILED_PROPS(1,SF_DOUBLE,1,&(dimVector[0]),0,0,0,0.0,
            1.0,0,0,(MexFcnForType)c17_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)c17_c_sf_marshall);
        }

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

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

        {
          real_T (*c17_OPm)[2874];
          real_T (*c17_S)[13];
          real_T (*c17_OPv)[2874];
          real_T (*c17_b)[1950];
          real_T (*c17_n)[13];
          c17_n = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 3);
          c17_b = (real_T (*)[1950])ssGetOutputPortSignal(chartInstance->S, 2);
          c17_OPv = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 1);
          c17_S = (real_T (*)[13])ssGetOutputPortSignal(chartInstance->S, 1);
          c17_OPm = (real_T (*)[2874])ssGetInputPortSignal(chartInstance->S, 0);
          _SFD_SET_DATA_VALUE_PTR(0U, *c17_OPm);
          _SFD_SET_DATA_VALUE_PTR(1U, *c17_S);
          _SFD_SET_DATA_VALUE_PTR(2U, *c17_OPv);
          _SFD_SET_DATA_VALUE_PTR(3U, *c17_b);
          _SFD_SET_DATA_VALUE_PTR(4U, *c17_n);
        }
      }
    } else {
      sf_debug_reset_current_state_configuration(_entalMachineNumber_,
        chartInstance->chartNumber,chartInstance->instanceNumber);
    }
  }
}

static void sf_opaque_initialize_c17_ental(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc17_entalInstanceStruct*) chartInstanceVar)->S,
    0);
  initialize_params_c17_ental((SFc17_entalInstanceStruct*) chartInstanceVar);
  initialize_c17_ental((SFc17_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_enable_c17_ental(void *chartInstanceVar)
{
  enable_c17_ental((SFc17_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_disable_c17_ental(void *chartInstanceVar)
{
  disable_c17_ental((SFc17_entalInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_gateway_c17_ental(void *chartInstanceVar)
{
  sf_c17_ental((SFc17_entalInstanceStruct*) chartInstanceVar);
}

static mxArray* sf_internal_get_sim_state_c17_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_c17_ental((SFc17_entalInstanceStruct*)
    chartInfo->chartInstance);         /* raw sim ctx */
  prhs[3] = sf_get_sim_state_info_c17_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_c17_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_c17_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_c17_ental((SFc17_entalInstanceStruct*)chartInfo->chartInstance,
    mxDuplicateArray(plhs[0]));
  mxDestroyArray(plhs[0]);
}

static mxArray* sf_opaque_get_sim_state_c17_ental(SimStruct* S)
{
  return sf_internal_get_sim_state_c17_ental(S);
}

static void sf_opaque_set_sim_state_c17_ental(SimStruct* S, const mxArray *st)
{
  sf_internal_set_sim_state_c17_ental(S, st);
}

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

    finalize_c17_ental((SFc17_entalInstanceStruct*) chartInstanceVar);
    free((void *)chartInstanceVar);
    ssSetUserData(S,NULL);
  }
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  compInitSubchartSimstructsFcn_c17_ental((SFc17_entalInstanceStruct*)
    chartInstanceVar);
}

extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c17_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_c17_ental((SFc17_entalInstanceStruct*)(((ChartInfoStruct *)
      ssGetUserData(S))->chartInstance));
  }
}

static void mdlSetWorkWidths_c17_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",17);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetRTWCG(S,sf_rtw_info_uint_prop(S,"ental","ental",17,"RTWCG"));
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop(S,"ental","ental",17,
      "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",17,2);
      sf_mark_chart_reusable_outputs(S,"ental","ental",17,3);
    }

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

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(117175846U));
  ssSetChecksum1(S,(2554954246U));
  ssSetChecksum2(S,(797817377U));
  ssSetChecksum3(S,(1167513888U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
}

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

static void mdlStart_c17_ental(SimStruct *S)
{
  SFc17_entalInstanceStruct *chartInstance;
  chartInstance = (SFc17_entalInstanceStruct *)malloc(sizeof
    (SFc17_entalInstanceStruct));
  memset(chartInstance, 0, sizeof(SFc17_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_c17_ental;
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c17_ental;
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c17_ental;
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c17_ental;
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c17_ental;
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c17_ental;
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c17_ental;
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c17_ental;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c17_ental;
  chartInstance->chartInfo.mdlStart = mdlStart_c17_ental;
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c17_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 c17_ental_method_dispatcher(SimStruct *S, int_T method, void *data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c17_ental(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c17_ental(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c17_ental(S);
    break;

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