/* Include files */

#include "blascompat32.h"
#include "Hunt_crossley_Ident_sfun.h"
#include "c10_Hunt_crossley_Ident.h"
#include "mwmathutil.h"
#define CHARTINSTANCE_CHARTNUMBER      (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER   (chartInstance->instanceNumber)
#include "Hunt_crossley_Ident_sfun_debug_macros.h"

/* Type Definitions */

/* Named Constants */
#define CALL_EVENT                     (-1)

/* Variable Declarations */

/* Variable Definitions */
static const char * c10_debug_family_names[18] = { "p1", "p2", "t1", "t2", "t3",
  "patm", "ps", "f", "nargin", "nargout", "theta", "dtheta", "p", "uc", "ud",
  "tetaRLS", "ddtheta", "dpRLS" };

/* Function Declarations */
static void initialize_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static void initialize_params_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static void enable_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static void disable_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static void c10_update_debugger_state_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static const mxArray *get_sim_state_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static void set_sim_state_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance, const mxArray *c10_st);
static void finalize_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static void sf_c10_Hunt_crossley_Ident(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance);
static void initSimStructsc10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static void init_script_number_translation(uint32_T c10_machineNumber, uint32_T
  c10_chartNumber);
static const mxArray *c10_sf_marshallOut(void *chartInstanceVoid, void
  *c10_inData);
static real_T c10_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_dpRLS, const char_T *c10_identifier);
static real_T c10_b_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_u, const emlrtMsgIdentifier *c10_parentId);
static void c10_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c10_mxArrayInData, const char_T *c10_varName, void *c10_outData);
static const mxArray *c10_b_sf_marshallOut(void *chartInstanceVoid, void
  *c10_inData);
static void c10_eml_error(SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance);
static const mxArray *c10_c_sf_marshallOut(void *chartInstanceVoid, void
  *c10_inData);
static int32_T c10_c_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_u, const emlrtMsgIdentifier *c10_parentId);
static void c10_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c10_mxArrayInData, const char_T *c10_varName, void *c10_outData);
static uint8_T c10_d_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_b_is_active_c10_Hunt_crossley_Ident, const
  char_T *c10_identifier);
static uint8_T c10_e_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_u, const emlrtMsgIdentifier *c10_parentId);
static void init_dsm_address_info(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance);

/* Function Definitions */
static void initialize_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance)
{
  chartInstance->c10_sfEvent = CALL_EVENT;
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  chartInstance->c10_is_active_c10_Hunt_crossley_Ident = 0U;
}

static void initialize_params_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance)
{
}

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

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

static void c10_update_debugger_state_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance)
{
}

static const mxArray *get_sim_state_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance)
{
  const mxArray *c10_st;
  const mxArray *c10_y = NULL;
  real_T c10_hoistedGlobal;
  real_T c10_u;
  const mxArray *c10_b_y = NULL;
  real_T c10_b_hoistedGlobal;
  real_T c10_b_u;
  const mxArray *c10_c_y = NULL;
  uint8_T c10_c_hoistedGlobal;
  uint8_T c10_c_u;
  const mxArray *c10_d_y = NULL;
  real_T *c10_ddtheta;
  real_T *c10_dpRLS;
  c10_dpRLS = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2);
  c10_ddtheta = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  c10_st = NULL;
  c10_st = NULL;
  c10_y = NULL;
  sf_mex_assign(&c10_y, sf_mex_createcellarray(3), FALSE);
  c10_hoistedGlobal = *c10_ddtheta;
  c10_u = c10_hoistedGlobal;
  c10_b_y = NULL;
  sf_mex_assign(&c10_b_y, sf_mex_create("y", &c10_u, 0, 0U, 0U, 0U, 0), FALSE);
  sf_mex_setcell(c10_y, 0, c10_b_y);
  c10_b_hoistedGlobal = *c10_dpRLS;
  c10_b_u = c10_b_hoistedGlobal;
  c10_c_y = NULL;
  sf_mex_assign(&c10_c_y, sf_mex_create("y", &c10_b_u, 0, 0U, 0U, 0U, 0), FALSE);
  sf_mex_setcell(c10_y, 1, c10_c_y);
  c10_c_hoistedGlobal = chartInstance->c10_is_active_c10_Hunt_crossley_Ident;
  c10_c_u = c10_c_hoistedGlobal;
  c10_d_y = NULL;
  sf_mex_assign(&c10_d_y, sf_mex_create("y", &c10_c_u, 3, 0U, 0U, 0U, 0), FALSE);
  sf_mex_setcell(c10_y, 2, c10_d_y);
  sf_mex_assign(&c10_st, c10_y, FALSE);
  return c10_st;
}

static void set_sim_state_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance, const mxArray *c10_st)
{
  const mxArray *c10_u;
  real_T *c10_ddtheta;
  real_T *c10_dpRLS;
  c10_dpRLS = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2);
  c10_ddtheta = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  chartInstance->c10_doneDoubleBufferReInit = TRUE;
  c10_u = sf_mex_dup(c10_st);
  *c10_ddtheta = c10_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell
    (c10_u, 0)), "ddtheta");
  *c10_dpRLS = c10_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell
    (c10_u, 1)), "dpRLS");
  chartInstance->c10_is_active_c10_Hunt_crossley_Ident = c10_d_emlrt_marshallIn
    (chartInstance, sf_mex_dup(sf_mex_getcell(c10_u, 2)),
     "is_active_c10_Hunt_crossley_Ident");
  sf_mex_destroy(&c10_u);
  c10_update_debugger_state_c10_Hunt_crossley_Ident(chartInstance);
  sf_mex_destroy(&c10_st);
}

static void finalize_c10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance)
{
}

static void sf_c10_Hunt_crossley_Ident(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance)
{
  int32_T c10_i0;
  real_T c10_hoistedGlobal;
  real_T c10_b_hoistedGlobal;
  real_T c10_c_hoistedGlobal;
  real_T c10_d_hoistedGlobal;
  real_T c10_e_hoistedGlobal;
  real_T c10_theta;
  real_T c10_dtheta;
  real_T c10_p;
  real_T c10_uc;
  real_T c10_ud;
  int32_T c10_i1;
  real_T c10_tetaRLS[2];
  uint32_T c10_debug_family_var_map[18];
  real_T c10_p1;
  real_T c10_p2;
  real_T c10_t1;
  real_T c10_t2;
  real_T c10_t3;
  real_T c10_patm;
  real_T c10_ps;
  real_T c10_f;
  real_T c10_nargin = 6.0;
  real_T c10_nargout = 2.0;
  real_T c10_ddtheta;
  real_T c10_dpRLS;
  real_T c10_b;
  real_T c10_y;
  real_T c10_b_b;
  real_T c10_b_y;
  real_T c10_c_b;
  real_T c10_c_y;
  real_T c10_x;
  real_T c10_b_x;
  real_T c10_a;
  real_T c10_d_b;
  real_T c10_d_y;
  real_T c10_c_x;
  real_T c10_d_x;
  real_T c10_e_y;
  real_T c10_e_x;
  real_T c10_f_x;
  real_T c10_b_a;
  real_T c10_e_b;
  real_T c10_g_x;
  real_T c10_h_x;
  real_T c10_c_a;
  real_T c10_f_b;
  real_T c10_f_y;
  real_T c10_i_x;
  real_T c10_j_x;
  real_T c10_g_y;
  real_T c10_k_x;
  real_T c10_l_x;
  real_T c10_d_a;
  real_T c10_g_b;
  real_T c10_e_a;
  real_T c10_h_b;
  real_T c10_h_y;
  real_T c10_A;
  real_T c10_B;
  real_T c10_m_x;
  real_T c10_i_y;
  real_T c10_n_x;
  real_T c10_j_y;
  real_T *c10_b_dpRLS;
  real_T *c10_b_ddtheta;
  real_T *c10_b_ud;
  real_T *c10_b_uc;
  real_T *c10_b_p;
  real_T *c10_b_dtheta;
  real_T *c10_b_theta;
  real_T (*c10_b_tetaRLS)[2];
  c10_b_dpRLS = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2);
  c10_b_tetaRLS = (real_T (*)[2])ssGetInputPortSignal(chartInstance->S, 5);
  c10_b_ud = (real_T *)ssGetInputPortSignal(chartInstance->S, 4);
  c10_b_uc = (real_T *)ssGetInputPortSignal(chartInstance->S, 3);
  c10_b_p = (real_T *)ssGetInputPortSignal(chartInstance->S, 2);
  c10_b_dtheta = (real_T *)ssGetInputPortSignal(chartInstance->S, 1);
  c10_b_theta = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
  c10_b_ddtheta = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 8U, chartInstance->c10_sfEvent);
  _SFD_DATA_RANGE_CHECK(*c10_b_ddtheta, 0U);
  _SFD_DATA_RANGE_CHECK(*c10_b_theta, 1U);
  _SFD_DATA_RANGE_CHECK(*c10_b_dtheta, 2U);
  _SFD_DATA_RANGE_CHECK(*c10_b_p, 3U);
  _SFD_DATA_RANGE_CHECK(*c10_b_uc, 4U);
  _SFD_DATA_RANGE_CHECK(*c10_b_ud, 5U);
  for (c10_i0 = 0; c10_i0 < 2; c10_i0++) {
    _SFD_DATA_RANGE_CHECK((*c10_b_tetaRLS)[c10_i0], 6U);
  }

  _SFD_DATA_RANGE_CHECK(*c10_b_dpRLS, 7U);
  chartInstance->c10_sfEvent = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 8U, chartInstance->c10_sfEvent);
  c10_hoistedGlobal = *c10_b_theta;
  c10_b_hoistedGlobal = *c10_b_dtheta;
  c10_c_hoistedGlobal = *c10_b_p;
  c10_d_hoistedGlobal = *c10_b_uc;
  c10_e_hoistedGlobal = *c10_b_ud;
  c10_theta = c10_hoistedGlobal;
  c10_dtheta = c10_b_hoistedGlobal;
  c10_p = c10_c_hoistedGlobal;
  c10_uc = c10_d_hoistedGlobal;
  c10_ud = c10_e_hoistedGlobal;
  for (c10_i1 = 0; c10_i1 < 2; c10_i1++) {
    c10_tetaRLS[c10_i1] = (*c10_b_tetaRLS)[c10_i1];
  }

  sf_debug_symbol_scope_push_eml(0U, 18U, 18U, c10_debug_family_names,
    c10_debug_family_var_map);
  sf_debug_symbol_scope_add_eml_importable(&c10_p1, 0U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c10_p2, 1U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml(&c10_t1, 2U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml(&c10_t2, 3U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml(&c10_t3, 4U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml_importable(&c10_patm, 5U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c10_ps, 6U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c10_f, 7U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c10_nargin, 8U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c10_nargout, 9U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml(&c10_theta, 10U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml(&c10_dtheta, 11U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml(&c10_p, 12U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml(&c10_uc, 13U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml(&c10_ud, 14U, c10_sf_marshallOut);
  sf_debug_symbol_scope_add_eml(c10_tetaRLS, 15U, c10_b_sf_marshallOut);
  sf_debug_symbol_scope_add_eml_importable(&c10_ddtheta, 16U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c10_dpRLS, 17U, c10_sf_marshallOut,
    c10_sf_marshallIn);
  CV_EML_FCN(0, 0);
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 3);
  c10_p1 = c10_tetaRLS[0];
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 3);
  c10_p2 = c10_tetaRLS[1];
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 4);
  c10_t1 = 1408.5;
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 5);
  c10_t2 = 132.28;
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 6);
  c10_t3 = 3319.4;
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 7);
  c10_patm = 101325.0;
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 8);
  c10_ps = 800000.0;
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 10);
  c10_b = c10_p - c10_patm;
  c10_y = 1408.5 * c10_b;
  c10_b_b = c10_dtheta;
  c10_b_y = 132.28 * c10_b_b;
  c10_c_b = c10_theta;
  c10_c_y = 3319.4 * c10_c_b;
  c10_ddtheta = (c10_y - c10_b_y) - c10_c_y;
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 11);
  if (CV_EML_IF(0, 1, 0, c10_uc > 0.0)) {
    _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 12);
    c10_x = c10_ps - c10_p;
    c10_b_x = c10_x;
    c10_b_x = muDoubleScalarSign(c10_b_x);
    c10_a = c10_uc;
    c10_d_b = c10_b_x;
    c10_d_y = c10_a * c10_d_b;
    c10_c_x = c10_ps - c10_p;
    c10_d_x = c10_c_x;
    c10_e_y = muDoubleScalarAbs(c10_d_x);
    c10_e_x = c10_e_y;
    c10_f_x = c10_e_x;
    if (c10_f_x < 0.0) {
      c10_eml_error(chartInstance);
    }

    c10_f_x = muDoubleScalarSqrt(c10_f_x);
    c10_b_a = c10_d_y;
    c10_e_b = c10_f_x;
    c10_f = c10_b_a * c10_e_b;
  } else {
    _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 14);
    c10_g_x = c10_p - c10_patm;
    c10_h_x = c10_g_x;
    c10_h_x = muDoubleScalarSign(c10_h_x);
    c10_c_a = c10_ud;
    c10_f_b = c10_h_x;
    c10_f_y = c10_c_a * c10_f_b;
    c10_i_x = c10_p - c10_patm;
    c10_j_x = c10_i_x;
    c10_g_y = muDoubleScalarAbs(c10_j_x);
    c10_k_x = c10_g_y;
    c10_l_x = c10_k_x;
    if (c10_l_x < 0.0) {
      c10_eml_error(chartInstance);
    }

    c10_l_x = muDoubleScalarSqrt(c10_l_x);
    c10_d_a = c10_f_y;
    c10_g_b = c10_l_x;
    c10_f = c10_d_a * c10_g_b;
  }

  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, 17);
  c10_e_a = c10_p2;
  c10_h_b = c10_p;
  c10_h_y = c10_e_a * c10_h_b;
  c10_A = c10_p1 + c10_h_y;
  c10_B = c10_f;
  c10_m_x = c10_B;
  c10_i_y = c10_A;
  c10_n_x = c10_m_x;
  c10_j_y = c10_i_y;
  c10_dpRLS = c10_n_x / c10_j_y;
  _SFD_EML_CALL(0U, chartInstance->c10_sfEvent, -17);
  sf_debug_symbol_scope_pop();
  *c10_b_ddtheta = c10_ddtheta;
  *c10_b_dpRLS = c10_dpRLS;
  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 8U, chartInstance->c10_sfEvent);
  sf_debug_check_for_state_inconsistency(_Hunt_crossley_IdentMachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}

static void initSimStructsc10_Hunt_crossley_Ident
  (SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance)
{
}

static void init_script_number_translation(uint32_T c10_machineNumber, uint32_T
  c10_chartNumber)
{
}

static const mxArray *c10_sf_marshallOut(void *chartInstanceVoid, void
  *c10_inData)
{
  const mxArray *c10_mxArrayOutData = NULL;
  real_T c10_u;
  const mxArray *c10_y = NULL;
  SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance;
  chartInstance = (SFc10_Hunt_crossley_IdentInstanceStruct *)chartInstanceVoid;
  c10_mxArrayOutData = NULL;
  c10_u = *(real_T *)c10_inData;
  c10_y = NULL;
  sf_mex_assign(&c10_y, sf_mex_create("y", &c10_u, 0, 0U, 0U, 0U, 0), FALSE);
  sf_mex_assign(&c10_mxArrayOutData, c10_y, FALSE);
  return c10_mxArrayOutData;
}

static real_T c10_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_dpRLS, const char_T *c10_identifier)
{
  real_T c10_y;
  emlrtMsgIdentifier c10_thisId;
  c10_thisId.fIdentifier = c10_identifier;
  c10_thisId.fParent = NULL;
  c10_y = c10_b_emlrt_marshallIn(chartInstance, sf_mex_dup(c10_dpRLS),
    &c10_thisId);
  sf_mex_destroy(&c10_dpRLS);
  return c10_y;
}

static real_T c10_b_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_u, const emlrtMsgIdentifier *c10_parentId)
{
  real_T c10_y;
  real_T c10_d0;
  sf_mex_import(c10_parentId, sf_mex_dup(c10_u), &c10_d0, 1, 0, 0U, 0, 0U, 0);
  c10_y = c10_d0;
  sf_mex_destroy(&c10_u);
  return c10_y;
}

static void c10_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c10_mxArrayInData, const char_T *c10_varName, void *c10_outData)
{
  const mxArray *c10_dpRLS;
  const char_T *c10_identifier;
  emlrtMsgIdentifier c10_thisId;
  real_T c10_y;
  SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance;
  chartInstance = (SFc10_Hunt_crossley_IdentInstanceStruct *)chartInstanceVoid;
  c10_dpRLS = sf_mex_dup(c10_mxArrayInData);
  c10_identifier = c10_varName;
  c10_thisId.fIdentifier = c10_identifier;
  c10_thisId.fParent = NULL;
  c10_y = c10_b_emlrt_marshallIn(chartInstance, sf_mex_dup(c10_dpRLS),
    &c10_thisId);
  sf_mex_destroy(&c10_dpRLS);
  *(real_T *)c10_outData = c10_y;
  sf_mex_destroy(&c10_mxArrayInData);
}

static const mxArray *c10_b_sf_marshallOut(void *chartInstanceVoid, void
  *c10_inData)
{
  const mxArray *c10_mxArrayOutData = NULL;
  int32_T c10_i2;
  real_T c10_b_inData[2];
  int32_T c10_i3;
  real_T c10_u[2];
  const mxArray *c10_y = NULL;
  SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance;
  chartInstance = (SFc10_Hunt_crossley_IdentInstanceStruct *)chartInstanceVoid;
  c10_mxArrayOutData = NULL;
  for (c10_i2 = 0; c10_i2 < 2; c10_i2++) {
    c10_b_inData[c10_i2] = (*(real_T (*)[2])c10_inData)[c10_i2];
  }

  for (c10_i3 = 0; c10_i3 < 2; c10_i3++) {
    c10_u[c10_i3] = c10_b_inData[c10_i3];
  }

  c10_y = NULL;
  sf_mex_assign(&c10_y, sf_mex_create("y", c10_u, 0, 0U, 1U, 0U, 1, 2), FALSE);
  sf_mex_assign(&c10_mxArrayOutData, c10_y, FALSE);
  return c10_mxArrayOutData;
}

const mxArray *sf_c10_Hunt_crossley_Ident_get_eml_resolved_functions_info(void)
{
  const mxArray *c10_nameCaptureInfo;
  c10_ResolvedFunctionInfo c10_info[11];
  c10_ResolvedFunctionInfo (*c10_b_info)[11];
  const mxArray *c10_m0 = NULL;
  int32_T c10_i4;
  c10_ResolvedFunctionInfo *c10_r0;
  c10_nameCaptureInfo = NULL;
  c10_nameCaptureInfo = NULL;
  c10_b_info = (c10_ResolvedFunctionInfo (*)[11])c10_info;
  (*c10_b_info)[0].context = "";
  (*c10_b_info)[0].name = "mtimes";
  (*c10_b_info)[0].dominantType = "double";
  (*c10_b_info)[0].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m";
  (*c10_b_info)[0].fileTimeLo = 1289510692U;
  (*c10_b_info)[0].fileTimeHi = 0U;
  (*c10_b_info)[0].mFileTimeLo = 0U;
  (*c10_b_info)[0].mFileTimeHi = 0U;
  (*c10_b_info)[1].context = "";
  (*c10_b_info)[1].name = "sign";
  (*c10_b_info)[1].dominantType = "double";
  (*c10_b_info)[1].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/sign.m";
  (*c10_b_info)[1].fileTimeLo = 1286813350U;
  (*c10_b_info)[1].fileTimeHi = 0U;
  (*c10_b_info)[1].mFileTimeLo = 0U;
  (*c10_b_info)[1].mFileTimeHi = 0U;
  (*c10_b_info)[2].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/sign.m";
  (*c10_b_info)[2].name = "eml_scalar_sign";
  (*c10_b_info)[2].dominantType = "double";
  (*c10_b_info)[2].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_sign.m";
  (*c10_b_info)[2].fileTimeLo = 1307642238U;
  (*c10_b_info)[2].fileTimeHi = 0U;
  (*c10_b_info)[2].mFileTimeLo = 0U;
  (*c10_b_info)[2].mFileTimeHi = 0U;
  (*c10_b_info)[3].context = "";
  (*c10_b_info)[3].name = "abs";
  (*c10_b_info)[3].dominantType = "double";
  (*c10_b_info)[3].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/abs.m";
  (*c10_b_info)[3].fileTimeLo = 1286813294U;
  (*c10_b_info)[3].fileTimeHi = 0U;
  (*c10_b_info)[3].mFileTimeLo = 0U;
  (*c10_b_info)[3].mFileTimeHi = 0U;
  (*c10_b_info)[4].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/abs.m";
  (*c10_b_info)[4].name = "eml_scalar_abs";
  (*c10_b_info)[4].dominantType = "double";
  (*c10_b_info)[4].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_abs.m";
  (*c10_b_info)[4].fileTimeLo = 1286813312U;
  (*c10_b_info)[4].fileTimeHi = 0U;
  (*c10_b_info)[4].mFileTimeLo = 0U;
  (*c10_b_info)[4].mFileTimeHi = 0U;
  (*c10_b_info)[5].context = "";
  (*c10_b_info)[5].name = "sqrt";
  (*c10_b_info)[5].dominantType = "double";
  (*c10_b_info)[5].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/sqrt.m";
  (*c10_b_info)[5].fileTimeLo = 1286813352U;
  (*c10_b_info)[5].fileTimeHi = 0U;
  (*c10_b_info)[5].mFileTimeLo = 0U;
  (*c10_b_info)[5].mFileTimeHi = 0U;
  (*c10_b_info)[6].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/sqrt.m";
  (*c10_b_info)[6].name = "eml_error";
  (*c10_b_info)[6].dominantType = "char";
  (*c10_b_info)[6].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_error.m";
  (*c10_b_info)[6].fileTimeLo = 1305309000U;
  (*c10_b_info)[6].fileTimeHi = 0U;
  (*c10_b_info)[6].mFileTimeLo = 0U;
  (*c10_b_info)[6].mFileTimeHi = 0U;
  (*c10_b_info)[7].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/sqrt.m";
  (*c10_b_info)[7].name = "eml_scalar_sqrt";
  (*c10_b_info)[7].dominantType = "double";
  (*c10_b_info)[7].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/elfun/eml_scalar_sqrt.m";
  (*c10_b_info)[7].fileTimeLo = 1286813338U;
  (*c10_b_info)[7].fileTimeHi = 0U;
  (*c10_b_info)[7].mFileTimeLo = 0U;
  (*c10_b_info)[7].mFileTimeHi = 0U;
  (*c10_b_info)[8].context = "";
  (*c10_b_info)[8].name = "mldivide";
  (*c10_b_info)[8].dominantType = "double";
  (*c10_b_info)[8].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mldivide.p";
  (*c10_b_info)[8].fileTimeLo = 1342801944U;
  (*c10_b_info)[8].fileTimeHi = 0U;
  (*c10_b_info)[8].mFileTimeLo = 1319724566U;
  (*c10_b_info)[8].mFileTimeHi = 0U;
  (*c10_b_info)[9].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mldivide.p";
  (*c10_b_info)[9].name = "rdivide";
  (*c10_b_info)[9].dominantType = "double";
  (*c10_b_info)[9].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c10_b_info)[9].fileTimeLo = 1286813444U;
  (*c10_b_info)[9].fileTimeHi = 0U;
  (*c10_b_info)[9].mFileTimeLo = 0U;
  (*c10_b_info)[9].mFileTimeHi = 0U;
  (*c10_b_info)[10].context =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/rdivide.m";
  (*c10_b_info)[10].name = "eml_div";
  (*c10_b_info)[10].dominantType = "double";
  (*c10_b_info)[10].resolved =
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_div.m";
  (*c10_b_info)[10].fileTimeLo = 1313338810U;
  (*c10_b_info)[10].fileTimeHi = 0U;
  (*c10_b_info)[10].mFileTimeLo = 0U;
  (*c10_b_info)[10].mFileTimeHi = 0U;
  sf_mex_assign(&c10_m0, sf_mex_createstruct("nameCaptureInfo", 1, 11), FALSE);
  for (c10_i4 = 0; c10_i4 < 11; c10_i4++) {
    c10_r0 = &c10_info[c10_i4];
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo", c10_r0->context, 15,
      0U, 0U, 0U, 2, 1, strlen(c10_r0->context)), "context", "nameCaptureInfo",
                    c10_i4);
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo", c10_r0->name, 15,
      0U, 0U, 0U, 2, 1, strlen(c10_r0->name)), "name", "nameCaptureInfo", c10_i4);
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo",
      c10_r0->dominantType, 15, 0U, 0U, 0U, 2, 1, strlen(c10_r0->dominantType)),
                    "dominantType", "nameCaptureInfo", c10_i4);
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo", c10_r0->resolved,
      15, 0U, 0U, 0U, 2, 1, strlen(c10_r0->resolved)), "resolved",
                    "nameCaptureInfo", c10_i4);
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo", &c10_r0->fileTimeLo,
      7, 0U, 0U, 0U, 0), "fileTimeLo", "nameCaptureInfo", c10_i4);
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo", &c10_r0->fileTimeHi,
      7, 0U, 0U, 0U, 0), "fileTimeHi", "nameCaptureInfo", c10_i4);
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo",
      &c10_r0->mFileTimeLo, 7, 0U, 0U, 0U, 0), "mFileTimeLo", "nameCaptureInfo",
                    c10_i4);
    sf_mex_addfield(c10_m0, sf_mex_create("nameCaptureInfo",
      &c10_r0->mFileTimeHi, 7, 0U, 0U, 0U, 0), "mFileTimeHi", "nameCaptureInfo",
                    c10_i4);
  }

  sf_mex_assign(&c10_nameCaptureInfo, c10_m0, FALSE);
  sf_mex_emlrtNameCapturePostProcessR2012a(&c10_nameCaptureInfo);
  return c10_nameCaptureInfo;
}

static void c10_eml_error(SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance)
{
  int32_T c10_i5;
  static char_T c10_varargin_1[30] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o',
    'o', 'l', 'b', 'o', 'x', ':', 's', 'q', 'r', 't', '_', 'd', 'o', 'm', 'a',
    'i', 'n', 'E', 'r', 'r', 'o', 'r' };

  char_T c10_u[30];
  const mxArray *c10_y = NULL;
  for (c10_i5 = 0; c10_i5 < 30; c10_i5++) {
    c10_u[c10_i5] = c10_varargin_1[c10_i5];
  }

  c10_y = NULL;
  sf_mex_assign(&c10_y, sf_mex_create("y", c10_u, 10, 0U, 1U, 0U, 2, 1, 30),
                FALSE);
  sf_mex_call_debug("error", 0U, 1U, 14, sf_mex_call_debug("message", 1U, 1U, 14,
    c10_y));
}

static const mxArray *c10_c_sf_marshallOut(void *chartInstanceVoid, void
  *c10_inData)
{
  const mxArray *c10_mxArrayOutData = NULL;
  int32_T c10_u;
  const mxArray *c10_y = NULL;
  SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance;
  chartInstance = (SFc10_Hunt_crossley_IdentInstanceStruct *)chartInstanceVoid;
  c10_mxArrayOutData = NULL;
  c10_u = *(int32_T *)c10_inData;
  c10_y = NULL;
  sf_mex_assign(&c10_y, sf_mex_create("y", &c10_u, 6, 0U, 0U, 0U, 0), FALSE);
  sf_mex_assign(&c10_mxArrayOutData, c10_y, FALSE);
  return c10_mxArrayOutData;
}

static int32_T c10_c_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_u, const emlrtMsgIdentifier *c10_parentId)
{
  int32_T c10_y;
  int32_T c10_i6;
  sf_mex_import(c10_parentId, sf_mex_dup(c10_u), &c10_i6, 1, 6, 0U, 0, 0U, 0);
  c10_y = c10_i6;
  sf_mex_destroy(&c10_u);
  return c10_y;
}

static void c10_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c10_mxArrayInData, const char_T *c10_varName, void *c10_outData)
{
  const mxArray *c10_b_sfEvent;
  const char_T *c10_identifier;
  emlrtMsgIdentifier c10_thisId;
  int32_T c10_y;
  SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance;
  chartInstance = (SFc10_Hunt_crossley_IdentInstanceStruct *)chartInstanceVoid;
  c10_b_sfEvent = sf_mex_dup(c10_mxArrayInData);
  c10_identifier = c10_varName;
  c10_thisId.fIdentifier = c10_identifier;
  c10_thisId.fParent = NULL;
  c10_y = c10_c_emlrt_marshallIn(chartInstance, sf_mex_dup(c10_b_sfEvent),
    &c10_thisId);
  sf_mex_destroy(&c10_b_sfEvent);
  *(int32_T *)c10_outData = c10_y;
  sf_mex_destroy(&c10_mxArrayInData);
}

static uint8_T c10_d_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_b_is_active_c10_Hunt_crossley_Ident, const
  char_T *c10_identifier)
{
  uint8_T c10_y;
  emlrtMsgIdentifier c10_thisId;
  c10_thisId.fIdentifier = c10_identifier;
  c10_thisId.fParent = NULL;
  c10_y = c10_e_emlrt_marshallIn(chartInstance, sf_mex_dup
    (c10_b_is_active_c10_Hunt_crossley_Ident), &c10_thisId);
  sf_mex_destroy(&c10_b_is_active_c10_Hunt_crossley_Ident);
  return c10_y;
}

static uint8_T c10_e_emlrt_marshallIn(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance, const mxArray *c10_u, const emlrtMsgIdentifier *c10_parentId)
{
  uint8_T c10_y;
  uint8_T c10_u0;
  sf_mex_import(c10_parentId, sf_mex_dup(c10_u), &c10_u0, 1, 3, 0U, 0, 0U, 0);
  c10_y = c10_u0;
  sf_mex_destroy(&c10_u);
  return c10_y;
}

static void init_dsm_address_info(SFc10_Hunt_crossley_IdentInstanceStruct
  *chartInstance)
{
}

/* SFunction Glue Code */
void sf_c10_Hunt_crossley_Ident_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(3678789116U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(2415103967U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(3818897045U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(2653031297U);
}

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

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

  {
    mxArray *mxChecksum = mxCreateString("U037p1TYKPerbnjYL1wVAB");
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
  }

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

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

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,0,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,0,"type",mxType);
    }

    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,1,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,1,"type",mxType);
    }

    mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0));

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

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

    mxSetField(mxData,3,"complexity",mxCreateDoubleScalar(0));

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

    mxSetField(mxData,4,"complexity",mxCreateDoubleScalar(0));

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

    mxSetField(mxData,5,"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,2,3,dataFields);

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,0,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,0,"type",mxType);
    }

    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,1,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
      mxSetField(mxData,1,"type",mxType);
    }

    mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0));
    mxSetField(mxAutoinheritanceInfo,0,"outputs",mxData);
  }

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

  return(mxAutoinheritanceInfo);
}

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

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

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 3, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c10_Hunt_crossley_Ident_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)) {
    SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance;
    chartInstance = (SFc10_Hunt_crossley_IdentInstanceStruct *)
      ((ChartInfoStruct *)(ssGetUserData(S)))->chartInstance;
    if (ssIsFirstInitCond(S) && fullDebuggerInitialization==1) {
      /* do this only if simulation is starting */
      {
        unsigned int chartAlreadyPresent;
        chartAlreadyPresent = sf_debug_initialize_chart
          (_Hunt_crossley_IdentMachineNumber_,
           10,
           1,
           1,
           8,
           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(_Hunt_crossley_IdentMachineNumber_,
            chartInstance->chartNumber);
          sf_debug_set_chart_disable_implicit_casting
            (_Hunt_crossley_IdentMachineNumber_,chartInstance->chartNumber,1);
          sf_debug_set_chart_event_thresholds(_Hunt_crossley_IdentMachineNumber_,
            chartInstance->chartNumber,
            0,
            0,
            0);
          _SFD_SET_DATA_PROPS(0,2,0,1,"ddtheta");
          _SFD_SET_DATA_PROPS(1,1,1,0,"theta");
          _SFD_SET_DATA_PROPS(2,1,1,0,"dtheta");
          _SFD_SET_DATA_PROPS(3,1,1,0,"p");
          _SFD_SET_DATA_PROPS(4,1,1,0,"uc");
          _SFD_SET_DATA_PROPS(5,1,1,0,"ud");
          _SFD_SET_DATA_PROPS(6,1,1,0,"tetaRLS");
          _SFD_SET_DATA_PROPS(7,2,0,1,"dpRLS");
          _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 MATLAB Function Model Coverage */
        _SFD_CV_INIT_EML(0,1,1,1,0,0,0,0,0,0,0);
        _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",0,-1,346);
        _SFD_CV_INIT_EML_IF(0,1,0,223,230,270,321);
        _SFD_TRANS_COV_WTS(0,0,0,1,0);
        if (chartAlreadyPresent==0) {
          _SFD_TRANS_COV_MAPS(0,
                              0,NULL,NULL,
                              0,NULL,NULL,
                              1,NULL,NULL,
                              0,NULL,NULL);
        }

        _SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c10_sf_marshallOut,(MexInFcnForType)c10_sf_marshallIn);
        _SFD_SET_DATA_COMPILED_PROPS(1,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c10_sf_marshallOut,(MexInFcnForType)NULL);
        _SFD_SET_DATA_COMPILED_PROPS(2,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c10_sf_marshallOut,(MexInFcnForType)NULL);
        _SFD_SET_DATA_COMPILED_PROPS(3,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c10_sf_marshallOut,(MexInFcnForType)NULL);
        _SFD_SET_DATA_COMPILED_PROPS(4,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c10_sf_marshallOut,(MexInFcnForType)NULL);
        _SFD_SET_DATA_COMPILED_PROPS(5,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c10_sf_marshallOut,(MexInFcnForType)NULL);

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

        _SFD_SET_DATA_COMPILED_PROPS(7,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c10_sf_marshallOut,(MexInFcnForType)c10_sf_marshallIn);

        {
          real_T *c10_ddtheta;
          real_T *c10_theta;
          real_T *c10_dtheta;
          real_T *c10_p;
          real_T *c10_uc;
          real_T *c10_ud;
          real_T *c10_dpRLS;
          real_T (*c10_tetaRLS)[2];
          c10_dpRLS = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2);
          c10_tetaRLS = (real_T (*)[2])ssGetInputPortSignal(chartInstance->S, 5);
          c10_ud = (real_T *)ssGetInputPortSignal(chartInstance->S, 4);
          c10_uc = (real_T *)ssGetInputPortSignal(chartInstance->S, 3);
          c10_p = (real_T *)ssGetInputPortSignal(chartInstance->S, 2);
          c10_dtheta = (real_T *)ssGetInputPortSignal(chartInstance->S, 1);
          c10_theta = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
          c10_ddtheta = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
          _SFD_SET_DATA_VALUE_PTR(0U, c10_ddtheta);
          _SFD_SET_DATA_VALUE_PTR(1U, c10_theta);
          _SFD_SET_DATA_VALUE_PTR(2U, c10_dtheta);
          _SFD_SET_DATA_VALUE_PTR(3U, c10_p);
          _SFD_SET_DATA_VALUE_PTR(4U, c10_uc);
          _SFD_SET_DATA_VALUE_PTR(5U, c10_ud);
          _SFD_SET_DATA_VALUE_PTR(6U, *c10_tetaRLS);
          _SFD_SET_DATA_VALUE_PTR(7U, c10_dpRLS);
        }
      }
    } else {
      sf_debug_reset_current_state_configuration
        (_Hunt_crossley_IdentMachineNumber_,chartInstance->chartNumber,
         chartInstance->instanceNumber);
    }
  }
}

static const char* sf_get_instance_specialization()
{
  return "qyOdOHuIpLaayCR04Dk7eH";
}

static void sf_opaque_initialize_c10_Hunt_crossley_Ident(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc10_Hunt_crossley_IdentInstanceStruct*)
    chartInstanceVar)->S,0);
  initialize_params_c10_Hunt_crossley_Ident
    ((SFc10_Hunt_crossley_IdentInstanceStruct*) chartInstanceVar);
  initialize_c10_Hunt_crossley_Ident((SFc10_Hunt_crossley_IdentInstanceStruct*)
    chartInstanceVar);
}

static void sf_opaque_enable_c10_Hunt_crossley_Ident(void *chartInstanceVar)
{
  enable_c10_Hunt_crossley_Ident((SFc10_Hunt_crossley_IdentInstanceStruct*)
    chartInstanceVar);
}

static void sf_opaque_disable_c10_Hunt_crossley_Ident(void *chartInstanceVar)
{
  disable_c10_Hunt_crossley_Ident((SFc10_Hunt_crossley_IdentInstanceStruct*)
    chartInstanceVar);
}

static void sf_opaque_gateway_c10_Hunt_crossley_Ident(void *chartInstanceVar)
{
  sf_c10_Hunt_crossley_Ident((SFc10_Hunt_crossley_IdentInstanceStruct*)
    chartInstanceVar);
}

extern const mxArray* sf_internal_get_sim_state_c10_Hunt_crossley_Ident
  (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_c10_Hunt_crossley_Ident
    ((SFc10_Hunt_crossley_IdentInstanceStruct*)chartInfo->chartInstance);/* raw sim ctx */
  prhs[3] = (mxArray*) sf_get_sim_state_info_c10_Hunt_crossley_Ident();/* 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];
}

extern void sf_internal_set_sim_state_c10_Hunt_crossley_Ident(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_c10_Hunt_crossley_Ident();/* 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_c10_Hunt_crossley_Ident((SFc10_Hunt_crossley_IdentInstanceStruct*)
    chartInfo->chartInstance, mxDuplicateArray(plhs[0]));
  mxDestroyArray(plhs[0]);
}

static const mxArray* sf_opaque_get_sim_state_c10_Hunt_crossley_Ident(SimStruct*
  S)
{
  return sf_internal_get_sim_state_c10_Hunt_crossley_Ident(S);
}

static void sf_opaque_set_sim_state_c10_Hunt_crossley_Ident(SimStruct* S, const
  mxArray *st)
{
  sf_internal_set_sim_state_c10_Hunt_crossley_Ident(S, st);
}

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

    finalize_c10_Hunt_crossley_Ident((SFc10_Hunt_crossley_IdentInstanceStruct*)
      chartInstanceVar);
    free((void *)chartInstanceVar);
    ssSetUserData(S,NULL);
  }

  unload_Hunt_crossley_Ident_optimization_info();
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  initSimStructsc10_Hunt_crossley_Ident((SFc10_Hunt_crossley_IdentInstanceStruct*)
    chartInstanceVar);
}

extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c10_Hunt_crossley_Ident(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_c10_Hunt_crossley_Ident
      ((SFc10_Hunt_crossley_IdentInstanceStruct*)(((ChartInfoStruct *)
         ssGetUserData(S))->chartInstance));
  }
}

static void mdlSetWorkWidths_c10_Hunt_crossley_Ident(SimStruct *S)
{
  if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
    mxArray *infoStruct = load_Hunt_crossley_Ident_optimization_info();
    int_T chartIsInlinable =
      (int_T)sf_is_chart_inlinable(S,sf_get_instance_specialization(),infoStruct,
      10);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetRTWCG(S,sf_rtw_info_uint_prop(S,sf_get_instance_specialization(),
                infoStruct,10,"RTWCG"));
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop(S,
      sf_get_instance_specialization(),infoStruct,10,
      "gatewayCannotBeInlinedMultipleTimes"));
    if (chartIsInlinable) {
      ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 4, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 5, SS_REUSABLE_AND_LOCAL);
      sf_mark_chart_expressionable_inputs(S,sf_get_instance_specialization(),
        infoStruct,10,6);
      sf_mark_chart_reusable_outputs(S,sf_get_instance_specialization(),
        infoStruct,10,2);
    }

    sf_set_rtw_dwork_info(S,sf_get_instance_specialization(),infoStruct,10);
    ssSetHasSubFunctions(S,!(chartIsInlinable));
  } else {
  }

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(2813773295U));
  ssSetChecksum1(S,(2616032935U));
  ssSetChecksum2(S,(3758217321U));
  ssSetChecksum3(S,(1012117279U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
  ssSupportsMultipleExecInstances(S,1);
}

static void mdlRTW_c10_Hunt_crossley_Ident(SimStruct *S)
{
  if (sim_mode_is_rtw_gen(S)) {
    ssWriteRTWStrParam(S, "StateflowChartType", "Embedded MATLAB");
  }
}

static void mdlStart_c10_Hunt_crossley_Ident(SimStruct *S)
{
  SFc10_Hunt_crossley_IdentInstanceStruct *chartInstance;
  chartInstance = (SFc10_Hunt_crossley_IdentInstanceStruct *)malloc(sizeof
    (SFc10_Hunt_crossley_IdentInstanceStruct));
  memset(chartInstance, 0, sizeof(SFc10_Hunt_crossley_IdentInstanceStruct));
  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_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.initializeChart =
    sf_opaque_initialize_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.terminateChart =
    sf_opaque_terminate_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.enableChart =
    sf_opaque_enable_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.disableChart =
    sf_opaque_disable_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.getSimState =
    sf_opaque_get_sim_state_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.setSimState =
    sf_opaque_set_sim_state_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.getSimStateInfo =
    sf_get_sim_state_info_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.mdlStart = mdlStart_c10_Hunt_crossley_Ident;
  chartInstance->chartInfo.mdlSetWorkWidths =
    mdlSetWorkWidths_c10_Hunt_crossley_Ident;
  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 c10_Hunt_crossley_Ident_method_dispatcher(SimStruct *S, int_T method, void *
  data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c10_Hunt_crossley_Ident(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c10_Hunt_crossley_Ident(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c10_Hunt_crossley_Ident(S);
    break;

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