static real_T c2_mpower(SFc2_QuadsimInstanceStruct *chartInstance, real_T c2_a)
{
  real_T c2_b_a;
  real_T c2_c_a;
  real_T c2_ak;
  c2_b_a = c2_a;
  c2_c_a = c2_b_a;
  c2_eml_scalar_eg(chartInstance);
  c2_ak = c2_c_a;
  return muDoubleScalarPower(c2_ak, 2.0);
}
static real_T c2_mpower
  (SFc2_MigrationOWBG_Proto4_1DLinear2DNonLinearInstanceStruct *chartInstance,
   real_T c2_a)
{
  real_T c2_b_a;
  real_T c2_c_a;
  real_T c2_ak;
  real_T c2_d_a;
  real_T c2_e_a;
  real_T c2_b;
  c2_b_a = c2_a;
  c2_c_a = c2_b_a;
  c2_eml_scalar_eg(chartInstance);
  c2_ak = c2_c_a;
  c2_d_a = c2_ak;
  c2_eml_scalar_eg(chartInstance);
  c2_e_a = c2_d_a;
  c2_b = c2_d_a;
  return c2_e_a * c2_b;
}
static void sf_c2_controller1(SFc2_controller1InstanceStruct *chartInstance)
{
  int32_T c2_previousEvent;
  real_T c2_hoistedGlobal;
  real_T c2_u;
  uint32_T c2_debug_family_var_map[4];
  real_T c2_nargin = 1.0;
  real_T c2_nargout = 1.0;
  real_T c2_y;
  real_T c2_x;
  real_T c2_b_x;
  real_T c2_b_y;
  real_T c2_c_x;
  real_T c2_xk;
  real_T c2_d_x;
  real_T c2_e_x;
  real_T c2_f_x;
  real_T *c2_b_u;
  real_T *c2_c_y;
  c2_c_y = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  c2_b_u = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 1);
  _SFD_DATA_RANGE_CHECK(*c2_b_u, 0U);
  _SFD_DATA_RANGE_CHECK(*c2_c_y, 1U);
  c2_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 1);
  c2_hoistedGlobal = *c2_b_u;
  c2_u = c2_hoistedGlobal;
  sf_debug_symbol_scope_push_eml(0U, 4U, 4U, c2_debug_family_names,
    c2_debug_family_var_map);
  sf_debug_symbol_scope_add_eml(&c2_nargin, c2_sf_marshall, 0U);
  sf_debug_symbol_scope_add_eml(&c2_nargout, c2_sf_marshall, 1U);
  sf_debug_symbol_scope_add_eml(&c2_u, c2_sf_marshall, 2U);
  sf_debug_symbol_scope_add_eml(&c2_y, c2_sf_marshall, 3U);
  CV_EML_FCN(0, 0);
  _SFD_EML_CALL(0, 2);
  c2_x = c2_u;
  c2_b_x = c2_x;
  c2_b_y = muDoubleScalarAbs(c2_b_x);
  if (CV_EML_IF(0, 0, c2_b_y > 90.0)) {
    _SFD_EML_CALL(0, 3);
    c2_c_x = c2_u;
    c2_eml_scalar_eg(chartInstance);
    c2_xk = c2_c_x;
    c2_d_x = c2_xk;
    c2_eml_scalar_eg(chartInstance);
    c2_e_x = c2_d_x / 90.0;
    c2_f_x = c2_e_x;
    c2_f_x = muDoubleScalarFloor(c2_f_x);
    c2_u = c2_d_x - c2_f_x * 90.0;
  }

  _SFD_EML_CALL(0, 5);
  c2_y = c2_u;
  _SFD_EML_CALL(0, -5);
  sf_debug_symbol_scope_pop();
  *c2_c_y = c2_y;
  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 1);
  _sfEvent_ = c2_previousEvent;
  sf_debug_check_for_state_inconsistency(_controller1MachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}
static void c2_chartstep_c2_gesamtmodell(SFc2_gesamtmodellInstanceStruct
  *chartInstance)
{
  int32_T c2_i4;
  real_T c2_u[4];
  uint32_T c2_debug_family_var_map[9];
  real_T c2_T;
  real_T c2_phi;
  real_T c2_theta;
  real_T c2_psi;
  real_T c2_Mt[9];
  real_T c2_nargin = 1.0;
  real_T c2_nargout = 1.0;
  real_T c2_y[3];
  real_T c2_x;
  real_T c2_b_x;
  real_T c2_c_x;
  real_T c2_d_x;
  real_T c2_a;
  real_T c2_b;
  real_T c2_b_y;
  real_T c2_e_x;
  real_T c2_f_x;
  real_T c2_g_x;
  real_T c2_h_x;
  real_T c2_b_a;
  real_T c2_b_b;
  real_T c2_c_y;
  real_T c2_i_x;
  real_T c2_j_x;
  real_T c2_c_a;
  real_T c2_c_b;
  real_T c2_d_y;
  real_T c2_k_x;
  real_T c2_l_x;
  real_T c2_m_x;
  real_T c2_n_x;
  real_T c2_d_a;
  real_T c2_d_b;
  real_T c2_e_y;
  real_T c2_o_x;
  real_T c2_p_x;
  real_T c2_q_x;
  real_T c2_r_x;
  real_T c2_e_a;
  real_T c2_e_b;
  real_T c2_f_y;
  real_T c2_s_x;
  real_T c2_t_x;
  real_T c2_f_a;
  real_T c2_f_b;
  real_T c2_g_y;
  real_T c2_u_x;
  real_T c2_v_x;
  real_T c2_w_x;
  real_T c2_x_x;
  real_T c2_g_a;
  real_T c2_g_b;
  real_T c2_h_y;
  real_T c2_y_x;
  real_T c2_ab_x;
  real_T c2_bb_x;
  real_T c2_cb_x;
  real_T c2_h_a;
  real_T c2_h_b;
  real_T c2_i_y;
  real_T c2_db_x;
  real_T c2_eb_x;
  real_T c2_fb_x;
  real_T c2_gb_x;
  real_T c2_i_a;
  real_T c2_i_b;
  real_T c2_j_y;
  real_T c2_hb_x;
  real_T c2_ib_x;
  real_T c2_j_a;
  real_T c2_j_b;
  real_T c2_k_y;
  real_T c2_jb_x;
  real_T c2_kb_x;
  real_T c2_lb_x;
  real_T c2_mb_x;
  real_T c2_k_a;
  real_T c2_k_b;
  real_T c2_l_y;
  real_T c2_nb_x;
  real_T c2_ob_x;
  real_T c2_pb_x;
  real_T c2_qb_x;
  real_T c2_l_a;
  real_T c2_l_b;
  real_T c2_m_y;
  real_T c2_rb_x;
  real_T c2_sb_x;
  real_T c2_m_a;
  real_T c2_m_b;
  real_T c2_n_y;
  real_T c2_tb_x;
  real_T c2_ub_x;
  real_T c2_vb_x;
  real_T c2_wb_x;
  real_T c2_n_a;
  real_T c2_n_b;
  real_T c2_o_y;
  real_T c2_xb_x;
  real_T c2_yb_x;
  real_T c2_ac_x;
  real_T c2_bc_x;
  real_T c2_cc_x;
  real_T c2_dc_x;
  real_T c2_o_a;
  real_T c2_o_b;
  real_T c2_p_y;
  real_T c2_ec_x;
  real_T c2_fc_x;
  real_T c2_gc_x;
  real_T c2_hc_x;
  real_T c2_p_a;
  real_T c2_p_b;
  real_T c2_q_y;
  int32_T c2_i5;
  real_T c2_q_a[9];
  real_T c2_q_b[3];
  int32_T c2_i6;
  int32_T c2_i7;
  int32_T c2_i8;
  real_T c2_C[3];
  int32_T c2_i9;
  int32_T c2_i10;
  int32_T c2_i11;
  int32_T c2_i12;
  int32_T c2_i13;
  int32_T c2_i14;
  int32_T c2_i15;
  real_T (*c2_r_y)[3];
  real_T (*c2_b_u)[4];
  c2_r_y = (real_T (*)[3])ssGetOutputPortSignal(chartInstance->S, 1);
  c2_b_u = (real_T (*)[4])ssGetInputPortSignal(chartInstance->S, 0);
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 1U, chartInstance->c2_sfEvent);
  for (c2_i4 = 0; c2_i4 < 4; c2_i4++) {
    c2_u[c2_i4] = (*c2_b_u)[c2_i4];
  }

  sf_debug_symbol_scope_push_eml(0U, 9U, 9U, c2_debug_family_names,
    c2_debug_family_var_map);
  sf_debug_symbol_scope_add_eml_importable(&c2_T, 0U, c2_c_sf_marshallOut,
    c2_b_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c2_phi, 1U, c2_c_sf_marshallOut,
    c2_b_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c2_theta, 2U, c2_c_sf_marshallOut,
    c2_b_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c2_psi, 3U, c2_c_sf_marshallOut,
    c2_b_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(c2_Mt, 4U, c2_d_sf_marshallOut,
    c2_c_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c2_nargin, 5U, c2_c_sf_marshallOut,
    c2_b_sf_marshallIn);
  sf_debug_symbol_scope_add_eml_importable(&c2_nargout, 6U, c2_c_sf_marshallOut,
    c2_b_sf_marshallIn);
  sf_debug_symbol_scope_add_eml(c2_u, 7U, c2_b_sf_marshallOut);
  sf_debug_symbol_scope_add_eml_importable(c2_y, 8U, c2_sf_marshallOut,
    c2_sf_marshallIn);
  CV_EML_FCN(0, 0);
  _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 2);
  c2_T = c2_u[0];
  _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 3);
  c2_phi = c2_u[1];
  _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 4);
  c2_theta = c2_u[2];
  _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 5);
  c2_psi = c2_u[3];
  _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 7);
  c2_x = c2_theta;
  c2_b_x = c2_x;
  c2_b_x = muDoubleScalarCos(c2_b_x);
  c2_c_x = c2_psi;
  c2_d_x = c2_c_x;
  c2_d_x = muDoubleScalarCos(c2_d_x);
  c2_a = c2_b_x;
  c2_b = c2_d_x;
  c2_b_y = c2_a * c2_b;
  c2_e_x = c2_phi;
  c2_f_x = c2_e_x;
  c2_f_x = muDoubleScalarSin(c2_f_x);
  c2_g_x = c2_theta;
  c2_h_x = c2_g_x;
  c2_h_x = muDoubleScalarSin(c2_h_x);
  c2_b_a = c2_f_x;
  c2_b_b = c2_h_x;
  c2_c_y = c2_b_a * c2_b_b;
  c2_i_x = c2_psi;
  c2_j_x = c2_i_x;
  c2_j_x = muDoubleScalarCos(c2_j_x);
  c2_c_a = c2_c_y;
  c2_c_b = c2_j_x;
  c2_d_y = c2_c_a * c2_c_b;
  c2_k_x = c2_phi;
  c2_l_x = c2_k_x;
  c2_l_x = muDoubleScalarCos(c2_l_x);
  c2_m_x = c2_psi;
  c2_n_x = c2_m_x;
  c2_n_x = muDoubleScalarSin(c2_n_x);
  c2_d_a = c2_l_x;
  c2_d_b = c2_n_x;
  c2_e_y = c2_d_a * c2_d_b;
  c2_o_x = c2_phi;
  c2_p_x = c2_o_x;
  c2_p_x = muDoubleScalarCos(c2_p_x);
  c2_q_x = c2_theta;
  c2_r_x = c2_q_x;
  c2_r_x = muDoubleScalarSin(c2_r_x);
  c2_e_a = c2_p_x;
  c2_e_b = c2_r_x;
  c2_f_y = c2_e_a * c2_e_b;
  c2_s_x = c2_psi;
  c2_t_x = c2_s_x;
  c2_t_x = muDoubleScalarCos(c2_t_x);
  c2_f_a = c2_f_y;
  c2_f_b = c2_t_x;
  c2_g_y = c2_f_a * c2_f_b;
  c2_u_x = c2_phi;
  c2_v_x = c2_u_x;
  c2_v_x = muDoubleScalarSin(c2_v_x);
  c2_w_x = c2_psi;
  c2_x_x = c2_w_x;
  c2_x_x = muDoubleScalarSin(c2_x_x);
  c2_g_a = c2_v_x;
  c2_g_b = c2_x_x;
  c2_h_y = c2_g_a * c2_g_b;
  c2_y_x = c2_theta;
  c2_ab_x = c2_y_x;
  c2_ab_x = muDoubleScalarCos(c2_ab_x);
  c2_bb_x = c2_psi;
  c2_cb_x = c2_bb_x;
  c2_cb_x = muDoubleScalarSin(c2_cb_x);
  c2_h_a = c2_ab_x;
  c2_h_b = c2_cb_x;
  c2_i_y = c2_h_a * c2_h_b;
  c2_db_x = c2_phi;
  c2_eb_x = c2_db_x;
  c2_eb_x = muDoubleScalarSin(c2_eb_x);
  c2_fb_x = c2_theta;
  c2_gb_x = c2_fb_x;
  c2_gb_x = muDoubleScalarSin(c2_gb_x);
  c2_i_a = c2_eb_x;
  c2_i_b = c2_gb_x;
  c2_j_y = c2_i_a * c2_i_b;
  c2_hb_x = c2_psi;
  c2_ib_x = c2_hb_x;
  c2_ib_x = muDoubleScalarSin(c2_ib_x);
  c2_j_a = c2_j_y;
  c2_j_b = c2_ib_x;
  c2_k_y = c2_j_a * c2_j_b;
  c2_jb_x = c2_phi;
  c2_kb_x = c2_jb_x;
  c2_kb_x = muDoubleScalarCos(c2_kb_x);
  c2_lb_x = c2_psi;
  c2_mb_x = c2_lb_x;
  c2_mb_x = muDoubleScalarCos(c2_mb_x);
  c2_k_a = c2_kb_x;
  c2_k_b = c2_mb_x;
  c2_l_y = c2_k_a * c2_k_b;
  c2_nb_x = c2_phi;
  c2_ob_x = c2_nb_x;
  c2_ob_x = muDoubleScalarCos(c2_ob_x);
  c2_pb_x = c2_theta;
  c2_qb_x = c2_pb_x;
  c2_qb_x = muDoubleScalarSin(c2_qb_x);
  c2_l_a = c2_ob_x;
  c2_l_b = c2_qb_x;
  c2_m_y = c2_l_a * c2_l_b;
  c2_rb_x = c2_psi;
  c2_sb_x = c2_rb_x;
  c2_sb_x = muDoubleScalarSin(c2_sb_x);
  c2_m_a = c2_m_y;
  c2_m_b = c2_sb_x;
  c2_n_y = c2_m_a * c2_m_b;
  c2_tb_x = c2_phi;
  c2_ub_x = c2_tb_x;
  c2_ub_x = muDoubleScalarSin(c2_ub_x);
  c2_vb_x = c2_psi;
  c2_wb_x = c2_vb_x;
  c2_wb_x = muDoubleScalarCos(c2_wb_x);
  c2_n_a = c2_ub_x;
  c2_n_b = c2_wb_x;
  c2_o_y = c2_n_a * c2_n_b;
  c2_xb_x = c2_theta;
  c2_yb_x = c2_xb_x;
  c2_yb_x = muDoubleScalarSin(c2_yb_x);
  c2_ac_x = c2_phi;
  c2_bc_x = c2_ac_x;
  c2_bc_x = muDoubleScalarSin(c2_bc_x);
  c2_cc_x = c2_theta;
  c2_dc_x = c2_cc_x;
  c2_dc_x = muDoubleScalarCos(c2_dc_x);
  c2_o_a = c2_bc_x;
  c2_o_b = c2_dc_x;
  c2_p_y = c2_o_a * c2_o_b;
  c2_ec_x = c2_phi;
  c2_fc_x = c2_ec_x;
  c2_fc_x = muDoubleScalarCos(c2_fc_x);
  c2_gc_x = c2_theta;
  c2_hc_x = c2_gc_x;
  c2_hc_x = muDoubleScalarCos(c2_hc_x);
  c2_p_a = c2_fc_x;
  c2_p_b = c2_hc_x;
  c2_q_y = c2_p_a * c2_p_b;
  c2_Mt[0] = c2_b_y;
  c2_Mt[3] = c2_d_y - c2_e_y;
  c2_Mt[6] = c2_g_y + c2_h_y;
  c2_Mt[1] = c2_i_y;
  c2_Mt[4] = c2_k_y + c2_l_y;
  c2_Mt[7] = c2_n_y - c2_o_y;
  c2_Mt[2] = -c2_yb_x;
  c2_Mt[5] = c2_p_y;
  c2_Mt[8] = c2_q_y;
  _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 10);
  for (c2_i5 = 0; c2_i5 < 9; c2_i5++) {
    c2_q_a[c2_i5] = c2_Mt[c2_i5];
  }

  c2_q_b[0] = 0.0;
  c2_q_b[1] = 0.0;
  c2_q_b[2] = c2_T;
  c2_eml_scalar_eg(chartInstance);
  c2_eml_scalar_eg(chartInstance);
  for (c2_i6 = 0; c2_i6 < 3; c2_i6++) {
    c2_y[c2_i6] = 0.0;
  }

  for (c2_i7 = 0; c2_i7 < 3; c2_i7++) {
    c2_y[c2_i7] = 0.0;
  }

  for (c2_i8 = 0; c2_i8 < 3; c2_i8++) {
    c2_C[c2_i8] = c2_y[c2_i8];
  }

  for (c2_i9 = 0; c2_i9 < 3; c2_i9++) {
    c2_y[c2_i9] = c2_C[c2_i9];
  }

  for (c2_i10 = 0; c2_i10 < 3; c2_i10++) {
    c2_C[c2_i10] = c2_y[c2_i10];
  }

  for (c2_i11 = 0; c2_i11 < 3; c2_i11++) {
    c2_y[c2_i11] = c2_C[c2_i11];
  }

  for (c2_i12 = 0; c2_i12 < 3; c2_i12++) {
    c2_y[c2_i12] = 0.0;
    c2_i13 = 0;
    for (c2_i14 = 0; c2_i14 < 3; c2_i14++) {
      c2_y[c2_i12] += c2_q_a[c2_i13 + c2_i12] * c2_q_b[c2_i14];
      c2_i13 += 3;
    }
  }

  _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, -10);
  sf_debug_symbol_scope_pop();
  for (c2_i15 = 0; c2_i15 < 3; c2_i15++) {
    (*c2_r_y)[c2_i15] = c2_y[c2_i15];
  }

  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 1U, chartInstance->c2_sfEvent);
}