/**
 * sshapcsf.c
 *
 *    ABSTRACT:
 *      The purpose of this sfunction is to call a simple legacy
 *      function during simulation:
 *
 *         void sshap(single  y1[size(u1,2)],single  y2[size(u1,2)],single  y3[size(u1,2)],single  y4[size(u1,2)],single  y5[size(u1,2)],single  y6[size(u1,2)],single  y7[size(u1,2)],single  y8[size(u1,2)],single  y9[size(u1,2)],single y10[size(u1,2)],single y11[size(u1,2)],single y12[size(u1,2)],single y13[size(u1,2)],single y14[size(u1,2)],single y15[size(u1,2)],single y16[size(u1,2)],single  u1[][],single  u2[][],single  u3,single  u4,single  p1,single  p2,int32  p3,int32  p4)
 *
 *    Simulink version           : 10.6 (R2022b) 13-May-2022
 *    C source code generated on : 27-Jan-2023 10:44:39
 *
 * THIS S-FUNCTION IS GENERATED BY THE LEGACY CODE TOOL AND MAY NOT WORK IF MODIFIED
 */

/**
     %%%-MATLAB_Construction_Commands_Start
     def = legacy_code('initialize');
     def.SFunctionName = 'sshapcsf';
     def.OutputFcnSpec = 'void sshap(single  y1[size(u1,2)],single  y2[size(u1,2)],single  y3[size(u1,2)],single  y4[size(u1,2)],single  y5[size(u1,2)],single  y6[size(u1,2)],single  y7[size(u1,2)],single  y8[size(u1,2)],single  y9[size(u1,2)],single y10[size(u1,2)],single y11[size(u1,2)],single y12[size(u1,2)],single y13[size(u1,2)],single y14[size(u1,2)],single y15[size(u1,2)],single y16[size(u1,2)],single  u1[][],single  u2[][],single  u3,single  u4,single  p1,single  p2,int32  p3,int32  p4)';
     def.HeaderFiles = {'meq.h'};
     def.HostLibFiles = {'meqld('host')'};
     def.TargetLibFiles = {'meqld('target')'};
     def.IncPaths = {'C:\Users\amerle\codes\meq'};
     def.LibPaths = {'C:\Users\amerle\codes\meq'};
     legacy_code('sfcn_cmex_generate', def);
     legacy_code('compile', def);
     %%%-MATLAB_Construction_Commands_End
 */

/* Must specify the S_FUNCTION_NAME as the name of the S-function */
#define S_FUNCTION_NAME  sshapcsf
#define S_FUNCTION_LEVEL 2

/**
 * Need to include simstruc.h for the definition of the SimStruct and
 * its associated macro definitions.
 */
#include "simstruc.h"

/* Specific header file(s) required by the legacy code function */
#include "meq.h"

#define EDIT_OK(S, P_IDX) \
       (!((ssGetSimMode(S)==SS_SIMMODE_SIZES_CALL_ONLY) && mxIsEmpty(ssGetSFcnParam(S, P_IDX))))


#define MDL_CHECK_PARAMETERS
#if defined(MDL_CHECK_PARAMETERS) && defined(MATLAB_MEX_FILE)
/* Function: mdlCheckParameters ===========================================
 * Abstract:
 *   mdlCheckParameters verifies new parameter settings whenever parameter
 *   change or are re-evaluated during a simulation. When a simulation is
 *   running, changes to S-function parameters can occur at any time during
 *   the simulation loop.
 */
static void mdlCheckParameters(SimStruct *S)
{
    /* Check the parameter 1 */
    if (EDIT_OK(S, 0)) {
        int_T dimsArray[2] = {1, 1};

        /* Check the parameter attributes */
        ssCheckSFcnParamValueAttribs(S, 0, "P1", DYNAMICALLY_TYPED, 2, dimsArray, 0);
    } /* if */

    /* Check the parameter 2 */
    if (EDIT_OK(S, 1)) {
        int_T dimsArray[2] = {1, 1};

        /* Check the parameter attributes */
        ssCheckSFcnParamValueAttribs(S, 1, "P2", DYNAMICALLY_TYPED, 2, dimsArray, 0);
    } /* if */

    /* Check the parameter 3 */
    if (EDIT_OK(S, 2)) {
        int_T dimsArray[2] = {1, 1};

        /* Check the parameter attributes */
        ssCheckSFcnParamValueAttribs(S, 2, "P3", DYNAMICALLY_TYPED, 2, dimsArray, 0);
    } /* if */

    /* Check the parameter 4 */
    if (EDIT_OK(S, 3)) {
        int_T dimsArray[2] = {1, 1};

        /* Check the parameter attributes */
        ssCheckSFcnParamValueAttribs(S, 3, "P4", DYNAMICALLY_TYPED, 2, dimsArray, 0);
    } /* if */

}
#endif

#define MDL_PROCESS_PARAMETERS
#if defined(MDL_PROCESS_PARAMETERS) && defined(MATLAB_MEX_FILE)
/* Function: mdlProcessParameters =========================================
 * Abstract:
 *   Update run-time parameters.
 */
static void mdlProcessParameters(SimStruct *S)
{
    ssUpdateAllTunableParamsAsRunTimeParams(S);
}
#endif

/* Function: mdlInitializeSizes ===========================================
 * Abstract:
 *   The sizes information is used by Simulink to determine the S-function
 *   block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
    /* Number of expected parameters */
    ssSetNumSFcnParams(S, 4);

    #if defined(MATLAB_MEX_FILE) 
    if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) {
        /**
         * If the number of expected input parameters is not equal
         * to the number of parameters entered in the dialog box return.
         * Simulink will generate an error indicating that there is a
         * parameter mismatch.
         */
        mdlCheckParameters(S);
        if (ssGetErrorStatus(S) != NULL) return;
    } else {
        /* Return if number of expected != number of actual parameters */
        return;
    } /* if */
    #endif 

    /* Set the parameter's tunability */
    ssSetSFcnParamTunable(S, 0, 1);
    ssSetSFcnParamTunable(S, 1, 1);
    ssSetSFcnParamTunable(S, 2, 1);
    ssSetSFcnParamTunable(S, 3, 1);

    /* Set the number of work vectors */
    if (!ssSetNumDWork(S, 0)) return;
    ssSetNumPWork(S, 0);

    /* Set the number of input ports */
    if (!ssSetNumInputPorts(S, 4)) return;

    /* Configure the input port 1 */
    ssSetInputPortDataType(S, 0, SS_SINGLE);
    {
        int_T u1NumRows = DYNAMICALLY_SIZED;
        int_T u1NumCols = DYNAMICALLY_SIZED;
        ssSetInputPortMatrixDimensions(S, 0, u1NumRows, u1NumCols);
    }
    ssSetInputPortComplexSignal(S, 0, COMPLEX_NO);
    ssSetInputPortDirectFeedThrough(S, 0, 1);
    ssSetInputPortAcceptExprInRTW(S, 0, 0);
    ssSetInputPortOverWritable(S, 0, 0);
    ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
    ssSetInputPortRequiredContiguous(S, 0, 1);
    ssSetInputPortDimensionsMode(S, 0, FIXED_DIMS_MODE);

    /* Configure the input port 2 */
    ssSetInputPortDataType(S, 1, SS_SINGLE);
    {
        int_T u2NumRows = DYNAMICALLY_SIZED;
        int_T u2NumCols = DYNAMICALLY_SIZED;
        ssSetInputPortMatrixDimensions(S, 1, u2NumRows, u2NumCols);
    }
    ssSetInputPortComplexSignal(S, 1, COMPLEX_NO);
    ssSetInputPortDirectFeedThrough(S, 1, 1);
    ssSetInputPortAcceptExprInRTW(S, 1, 0);
    ssSetInputPortOverWritable(S, 1, 0);
    ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
    ssSetInputPortRequiredContiguous(S, 1, 1);
    ssSetInputPortDimensionsMode(S, 1, FIXED_DIMS_MODE);

    /* Configure the input port 3 */
    ssSetInputPortDataType(S, 2, SS_SINGLE);
    {
        int_T u3Width = 1;
        ssSetInputPortWidth(S, 2, u3Width);
    }
    ssSetInputPortComplexSignal(S, 2, COMPLEX_NO);
    ssSetInputPortDirectFeedThrough(S, 2, 1);
    ssSetInputPortAcceptExprInRTW(S, 2, 1);
    ssSetInputPortOverWritable(S, 2, 1);
    ssSetInputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL);
    ssSetInputPortRequiredContiguous(S, 2, 1);
    ssSetInputPortDimensionsMode(S, 2, FIXED_DIMS_MODE);

    /* Configure the input port 4 */
    ssSetInputPortDataType(S, 3, SS_SINGLE);
    {
        int_T u4Width = 1;
        ssSetInputPortWidth(S, 3, u4Width);
    }
    ssSetInputPortComplexSignal(S, 3, COMPLEX_NO);
    ssSetInputPortDirectFeedThrough(S, 3, 1);
    ssSetInputPortAcceptExprInRTW(S, 3, 1);
    ssSetInputPortOverWritable(S, 3, 1);
    ssSetInputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL);
    ssSetInputPortRequiredContiguous(S, 3, 1);
    ssSetInputPortDimensionsMode(S, 3, FIXED_DIMS_MODE);

    /* Set the number of output ports */
    if (!ssSetNumOutputPorts(S, 16)) return;

    /* Configure the output port 1 */
    ssSetOutputPortDataType(S, 0, SS_SINGLE);
    {
        int_T y1Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 0, y1Width);
    }
    ssSetOutputPortComplexSignal(S, 0, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 0, 0);
    ssSetOutputPortDimensionsMode(S, 0, FIXED_DIMS_MODE);

    /* Configure the output port 2 */
    ssSetOutputPortDataType(S, 1, SS_SINGLE);
    {
        int_T y2Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 1, y2Width);
    }
    ssSetOutputPortComplexSignal(S, 1, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 1, 0);
    ssSetOutputPortDimensionsMode(S, 1, FIXED_DIMS_MODE);

    /* Configure the output port 3 */
    ssSetOutputPortDataType(S, 2, SS_SINGLE);
    {
        int_T y3Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 2, y3Width);
    }
    ssSetOutputPortComplexSignal(S, 2, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 2, 0);
    ssSetOutputPortDimensionsMode(S, 2, FIXED_DIMS_MODE);

    /* Configure the output port 4 */
    ssSetOutputPortDataType(S, 3, SS_SINGLE);
    {
        int_T y4Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 3, y4Width);
    }
    ssSetOutputPortComplexSignal(S, 3, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 3, 0);
    ssSetOutputPortDimensionsMode(S, 3, FIXED_DIMS_MODE);

    /* Configure the output port 5 */
    ssSetOutputPortDataType(S, 4, SS_SINGLE);
    {
        int_T y5Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 4, y5Width);
    }
    ssSetOutputPortComplexSignal(S, 4, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 4, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 4, 0);
    ssSetOutputPortDimensionsMode(S, 4, FIXED_DIMS_MODE);

    /* Configure the output port 6 */
    ssSetOutputPortDataType(S, 5, SS_SINGLE);
    {
        int_T y6Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 5, y6Width);
    }
    ssSetOutputPortComplexSignal(S, 5, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 5, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 5, 0);
    ssSetOutputPortDimensionsMode(S, 5, FIXED_DIMS_MODE);

    /* Configure the output port 7 */
    ssSetOutputPortDataType(S, 6, SS_SINGLE);
    {
        int_T y7Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 6, y7Width);
    }
    ssSetOutputPortComplexSignal(S, 6, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 6, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 6, 0);
    ssSetOutputPortDimensionsMode(S, 6, FIXED_DIMS_MODE);

    /* Configure the output port 8 */
    ssSetOutputPortDataType(S, 7, SS_SINGLE);
    {
        int_T y8Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 7, y8Width);
    }
    ssSetOutputPortComplexSignal(S, 7, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 7, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 7, 0);
    ssSetOutputPortDimensionsMode(S, 7, FIXED_DIMS_MODE);

    /* Configure the output port 9 */
    ssSetOutputPortDataType(S, 8, SS_SINGLE);
    {
        int_T y9Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 8, y9Width);
    }
    ssSetOutputPortComplexSignal(S, 8, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 8, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 8, 0);
    ssSetOutputPortDimensionsMode(S, 8, FIXED_DIMS_MODE);

    /* Configure the output port 10 */
    ssSetOutputPortDataType(S, 9, SS_SINGLE);
    {
        int_T y10Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 9, y10Width);
    }
    ssSetOutputPortComplexSignal(S, 9, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 9, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 9, 0);
    ssSetOutputPortDimensionsMode(S, 9, FIXED_DIMS_MODE);

    /* Configure the output port 11 */
    ssSetOutputPortDataType(S, 10, SS_SINGLE);
    {
        int_T y11Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 10, y11Width);
    }
    ssSetOutputPortComplexSignal(S, 10, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 10, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 10, 0);
    ssSetOutputPortDimensionsMode(S, 10, FIXED_DIMS_MODE);

    /* Configure the output port 12 */
    ssSetOutputPortDataType(S, 11, SS_SINGLE);
    {
        int_T y12Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 11, y12Width);
    }
    ssSetOutputPortComplexSignal(S, 11, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 11, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 11, 0);
    ssSetOutputPortDimensionsMode(S, 11, FIXED_DIMS_MODE);

    /* Configure the output port 13 */
    ssSetOutputPortDataType(S, 12, SS_SINGLE);
    {
        int_T y13Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 12, y13Width);
    }
    ssSetOutputPortComplexSignal(S, 12, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 12, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 12, 0);
    ssSetOutputPortDimensionsMode(S, 12, FIXED_DIMS_MODE);

    /* Configure the output port 14 */
    ssSetOutputPortDataType(S, 13, SS_SINGLE);
    {
        int_T y14Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 13, y14Width);
    }
    ssSetOutputPortComplexSignal(S, 13, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 13, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 13, 0);
    ssSetOutputPortDimensionsMode(S, 13, FIXED_DIMS_MODE);

    /* Configure the output port 15 */
    ssSetOutputPortDataType(S, 14, SS_SINGLE);
    {
        int_T y15Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 14, y15Width);
    }
    ssSetOutputPortComplexSignal(S, 14, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 14, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 14, 0);
    ssSetOutputPortDimensionsMode(S, 14, FIXED_DIMS_MODE);

    /* Configure the output port 16 */
    ssSetOutputPortDataType(S, 15, SS_SINGLE);
    {
        int_T y16Width = DYNAMICALLY_SIZED;
        ssSetOutputPortWidth(S, 15, y16Width);
    }
    ssSetOutputPortComplexSignal(S, 15, COMPLEX_NO);
    ssSetOutputPortOptimOpts(S, 15, SS_REUSABLE_AND_LOCAL);
    ssSetOutputPortOutputExprInRTW(S, 15, 0);
    ssSetOutputPortDimensionsMode(S, 15, FIXED_DIMS_MODE);

    /* Register reserved identifiers to avoid name conflict */
    if (ssRTWGenIsCodeGen(S) || ssGetSimMode(S)==SS_SIMMODE_EXTERNAL) {

        /* Register reserved identifier for  */
        ssRegMdlInfo(S, "sshap", MDL_INFO_ID_RESERVED, 0, 0, ssGetPath(S));
    } /* if */

    /* This S-function can be used in referenced model simulating in normal mode */
    ssSetModelReferenceNormalModeSupport(S, MDL_START_AND_MDL_PROCESS_PARAMS_OK);

    /* Set the number of sample time */
    ssSetNumSampleTimes(S, 1);

    /* Set the compliance for the operating point save/restore. */
    ssSetOperatingPointCompliance(S, USE_DEFAULT_OPERATING_POINT);

    ssSetArrayLayoutForCodeGen(S, SS_COLUMN_MAJOR);

    /* Set the Simulink version this S-Function has been generated in */
    ssSetSimulinkVersionGeneratedIn(S, "10.6");

    /**
     * All options have the form SS_OPTION_<name> and are documented in
     * matlabroot/simulink/include/simstruc.h. The options should be
     * bitwise or'd together as in
     *    ssSetOptions(S, (SS_OPTION_name1 | SS_OPTION_name2))
     */
    ssSetOptions(S,
        SS_OPTION_USE_TLC_WITH_ACCELERATOR |
        SS_OPTION_CAN_BE_CALLED_CONDITIONALLY |
        SS_OPTION_EXCEPTION_FREE_CODE |
        SS_OPTION_WORKS_WITH_CODE_REUSE |
        SS_OPTION_SFUNCTION_INLINED_FOR_RTW |
        SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME
    );
}

/* Function: mdlInitializeSampleTimes =====================================
 * Abstract:
 *   This function is used to specify the sample time(s) for your
 *   S-function. You must register the same number of sample times as
 *   specified in ssSetNumSampleTimes.
 */
static void mdlInitializeSampleTimes(SimStruct *S)
{
    ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
    ssSetOffsetTime(S, 0, FIXED_IN_MINOR_STEP_OFFSET);

    #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
    ssSetModelReferenceSampleTimeDefaultInheritance(S);
    #endif
}

#define MDL_SET_INPUT_PORT_DIMENSION_INFO
#if defined(MDL_SET_INPUT_PORT_DIMENSION_INFO) && defined(MATLAB_MEX_FILE)
/* Function: mdlSetInputPortDimensionInfo =================================
 * Abstract:
 *   This method is called with the candidate dimensions for an input port
 *   with unknown dimensions. If the proposed dimensions are acceptable, the
 *   method should go ahead and set the actual port dimensions.
 *   If they are unacceptable an error should be generated via
 *   ssSetErrorStatus.
 *   Note that any other input or output ports whose dimensions are
 *   implicitly defined by virtue of knowing the dimensions of the given
 *   port can also have their dimensions set.
 */
static void mdlSetInputPortDimensionInfo(SimStruct *S, int_T portIndex, const DimsInfo_T *dimsInfo)
{
    /* Set input port dimension */
    if(!ssSetInputPortDimensionInfo(S, portIndex, dimsInfo)) return;

    /* Set output port 1 dimension */
    {
        int_T y1Width = ssGetInputPortDimensions(S, 0)[1];
        if (y1Width!=DYNAMICALLY_SIZED && y1Width < 1) { ssSetErrorStatus(S, "Output 1: the current width is < 1"); return; }
        if (y1Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 0, y1Width);
        } /* if */
    }

    /* Set output port 2 dimension */
    {
        int_T y2Width = ssGetInputPortDimensions(S, 0)[1];
        if (y2Width!=DYNAMICALLY_SIZED && y2Width < 1) { ssSetErrorStatus(S, "Output 2: the current width is < 1"); return; }
        if (y2Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 1, y2Width);
        } /* if */
    }

    /* Set output port 3 dimension */
    {
        int_T y3Width = ssGetInputPortDimensions(S, 0)[1];
        if (y3Width!=DYNAMICALLY_SIZED && y3Width < 1) { ssSetErrorStatus(S, "Output 3: the current width is < 1"); return; }
        if (y3Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 2, y3Width);
        } /* if */
    }

    /* Set output port 4 dimension */
    {
        int_T y4Width = ssGetInputPortDimensions(S, 0)[1];
        if (y4Width!=DYNAMICALLY_SIZED && y4Width < 1) { ssSetErrorStatus(S, "Output 4: the current width is < 1"); return; }
        if (y4Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 3, y4Width);
        } /* if */
    }

    /* Set output port 5 dimension */
    {
        int_T y5Width = ssGetInputPortDimensions(S, 0)[1];
        if (y5Width!=DYNAMICALLY_SIZED && y5Width < 1) { ssSetErrorStatus(S, "Output 5: the current width is < 1"); return; }
        if (y5Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 4, y5Width);
        } /* if */
    }

    /* Set output port 6 dimension */
    {
        int_T y6Width = ssGetInputPortDimensions(S, 0)[1];
        if (y6Width!=DYNAMICALLY_SIZED && y6Width < 1) { ssSetErrorStatus(S, "Output 6: the current width is < 1"); return; }
        if (y6Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 5, y6Width);
        } /* if */
    }

    /* Set output port 7 dimension */
    {
        int_T y7Width = ssGetInputPortDimensions(S, 0)[1];
        if (y7Width!=DYNAMICALLY_SIZED && y7Width < 1) { ssSetErrorStatus(S, "Output 7: the current width is < 1"); return; }
        if (y7Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 6, y7Width);
        } /* if */
    }

    /* Set output port 8 dimension */
    {
        int_T y8Width = ssGetInputPortDimensions(S, 0)[1];
        if (y8Width!=DYNAMICALLY_SIZED && y8Width < 1) { ssSetErrorStatus(S, "Output 8: the current width is < 1"); return; }
        if (y8Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 7, y8Width);
        } /* if */
    }

    /* Set output port 9 dimension */
    {
        int_T y9Width = ssGetInputPortDimensions(S, 0)[1];
        if (y9Width!=DYNAMICALLY_SIZED && y9Width < 1) { ssSetErrorStatus(S, "Output 9: the current width is < 1"); return; }
        if (y9Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 8, y9Width);
        } /* if */
    }

    /* Set output port 10 dimension */
    {
        int_T y10Width = ssGetInputPortDimensions(S, 0)[1];
        if (y10Width!=DYNAMICALLY_SIZED && y10Width < 1) { ssSetErrorStatus(S, "Output 10: the current width is < 1"); return; }
        if (y10Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 9, y10Width);
        } /* if */
    }

    /* Set output port 11 dimension */
    {
        int_T y11Width = ssGetInputPortDimensions(S, 0)[1];
        if (y11Width!=DYNAMICALLY_SIZED && y11Width < 1) { ssSetErrorStatus(S, "Output 11: the current width is < 1"); return; }
        if (y11Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 10, y11Width);
        } /* if */
    }

    /* Set output port 12 dimension */
    {
        int_T y12Width = ssGetInputPortDimensions(S, 0)[1];
        if (y12Width!=DYNAMICALLY_SIZED && y12Width < 1) { ssSetErrorStatus(S, "Output 12: the current width is < 1"); return; }
        if (y12Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 11, y12Width);
        } /* if */
    }

    /* Set output port 13 dimension */
    {
        int_T y13Width = ssGetInputPortDimensions(S, 0)[1];
        if (y13Width!=DYNAMICALLY_SIZED && y13Width < 1) { ssSetErrorStatus(S, "Output 13: the current width is < 1"); return; }
        if (y13Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 12, y13Width);
        } /* if */
    }

    /* Set output port 14 dimension */
    {
        int_T y14Width = ssGetInputPortDimensions(S, 0)[1];
        if (y14Width!=DYNAMICALLY_SIZED && y14Width < 1) { ssSetErrorStatus(S, "Output 14: the current width is < 1"); return; }
        if (y14Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 13, y14Width);
        } /* if */
    }

    /* Set output port 15 dimension */
    {
        int_T y15Width = ssGetInputPortDimensions(S, 0)[1];
        if (y15Width!=DYNAMICALLY_SIZED && y15Width < 1) { ssSetErrorStatus(S, "Output 15: the current width is < 1"); return; }
        if (y15Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 14, y15Width);
        } /* if */
    }

    /* Set output port 16 dimension */
    {
        int_T y16Width = ssGetInputPortDimensions(S, 0)[1];
        if (y16Width!=DYNAMICALLY_SIZED && y16Width < 1) { ssSetErrorStatus(S, "Output 16: the current width is < 1"); return; }
        if (y16Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 15, y16Width);
        } /* if */
    }
}
#endif

#define MDL_SET_OUTPUT_PORT_DIMENSION_INFO
#if defined(MDL_SET_OUTPUT_PORT_DIMENSION_INFO) && defined(MATLAB_MEX_FILE)
/* Function: mdlSetOutputPortDimensionInfo ================================
 * Abstract:
 *   This method is called with the candidate dimensions for an output port
 *   with unknown dimensions. If the proposed dimensions are acceptable, the
 *   method should go ahead and set the actual port dimensions.
 *   If they are unacceptable an error should be generated via
 *   ssSetErrorStatus.
 *   Note that any other input or output ports whose dimensions are
 *   implicitly defined by virtue of knowing the dimensions of the given
 *   port can also have their dimensions set.
 */
static void mdlSetOutputPortDimensionInfo(SimStruct *S, int_T portIndex, const DimsInfo_T *dimsInfo)
{
    /* Set output port dimension */
    if(!ssSetOutputPortDimensionInfo(S, portIndex, dimsInfo)) return;
    {
        int_T y1Width = ssGetInputPortDimensions(S, 0)[1];
        if (y1Width!=DYNAMICALLY_SIZED && y1Width < 1) { ssSetErrorStatus(S, "Output 1: the current width is < 1"); return; }
        if (y1Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y1Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 1 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y2Width = ssGetInputPortDimensions(S, 0)[1];
        if (y2Width!=DYNAMICALLY_SIZED && y2Width < 1) { ssSetErrorStatus(S, "Output 2: the current width is < 1"); return; }
        if (y2Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y2Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 2 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y3Width = ssGetInputPortDimensions(S, 0)[1];
        if (y3Width!=DYNAMICALLY_SIZED && y3Width < 1) { ssSetErrorStatus(S, "Output 3: the current width is < 1"); return; }
        if (y3Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y3Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 3 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y4Width = ssGetInputPortDimensions(S, 0)[1];
        if (y4Width!=DYNAMICALLY_SIZED && y4Width < 1) { ssSetErrorStatus(S, "Output 4: the current width is < 1"); return; }
        if (y4Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y4Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 4 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y5Width = ssGetInputPortDimensions(S, 0)[1];
        if (y5Width!=DYNAMICALLY_SIZED && y5Width < 1) { ssSetErrorStatus(S, "Output 5: the current width is < 1"); return; }
        if (y5Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y5Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 5 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y6Width = ssGetInputPortDimensions(S, 0)[1];
        if (y6Width!=DYNAMICALLY_SIZED && y6Width < 1) { ssSetErrorStatus(S, "Output 6: the current width is < 1"); return; }
        if (y6Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y6Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 6 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y7Width = ssGetInputPortDimensions(S, 0)[1];
        if (y7Width!=DYNAMICALLY_SIZED && y7Width < 1) { ssSetErrorStatus(S, "Output 7: the current width is < 1"); return; }
        if (y7Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y7Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 7 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y8Width = ssGetInputPortDimensions(S, 0)[1];
        if (y8Width!=DYNAMICALLY_SIZED && y8Width < 1) { ssSetErrorStatus(S, "Output 8: the current width is < 1"); return; }
        if (y8Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y8Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 8 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y9Width = ssGetInputPortDimensions(S, 0)[1];
        if (y9Width!=DYNAMICALLY_SIZED && y9Width < 1) { ssSetErrorStatus(S, "Output 9: the current width is < 1"); return; }
        if (y9Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y9Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 9 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y10Width = ssGetInputPortDimensions(S, 0)[1];
        if (y10Width!=DYNAMICALLY_SIZED && y10Width < 1) { ssSetErrorStatus(S, "Output 10: the current width is < 1"); return; }
        if (y10Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y10Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 10 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y11Width = ssGetInputPortDimensions(S, 0)[1];
        if (y11Width!=DYNAMICALLY_SIZED && y11Width < 1) { ssSetErrorStatus(S, "Output 11: the current width is < 1"); return; }
        if (y11Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y11Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 11 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y12Width = ssGetInputPortDimensions(S, 0)[1];
        if (y12Width!=DYNAMICALLY_SIZED && y12Width < 1) { ssSetErrorStatus(S, "Output 12: the current width is < 1"); return; }
        if (y12Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y12Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 12 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y13Width = ssGetInputPortDimensions(S, 0)[1];
        if (y13Width!=DYNAMICALLY_SIZED && y13Width < 1) { ssSetErrorStatus(S, "Output 13: the current width is < 1"); return; }
        if (y13Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y13Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 13 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y14Width = ssGetInputPortDimensions(S, 0)[1];
        if (y14Width!=DYNAMICALLY_SIZED && y14Width < 1) { ssSetErrorStatus(S, "Output 14: the current width is < 1"); return; }
        if (y14Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y14Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 14 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y15Width = ssGetInputPortDimensions(S, 0)[1];
        if (y15Width!=DYNAMICALLY_SIZED && y15Width < 1) { ssSetErrorStatus(S, "Output 15: the current width is < 1"); return; }
        if (y15Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y15Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 15 must be a 1D signal.");
            }
        } /* if */
    }
    {
        int_T y16Width = ssGetInputPortDimensions(S, 0)[1];
        if (y16Width!=DYNAMICALLY_SIZED && y16Width < 1) { ssSetErrorStatus(S, "Output 16: the current width is < 1"); return; }
        if (y16Width != DYNAMICALLY_SIZED) {
            if ((dimsInfo->numDims != 1) || (dimsInfo->width != y16Width)) {
                ssSetErrorStatus(S, "Invalid output port width. The output signal 16 must be a 1D signal.");
            }
        } /* if */
    }
}
#endif

#define MDL_SET_DEFAULT_PORT_DIMENSION_INFO
#if defined(MDL_SET_DEFAULT_PORT_DIMENSION_INFO) && defined(MATLAB_MEX_FILE)
/* Function: mdlSetDefaultPortDimensionInfo ===============================
 * Abstract:
 *   This method is called when there is not enough information in your
 *   model to uniquely determine the port dimensionality of signals
 *   entering or leaving your block. When this occurs, Simulink's
 *   dimension propagation engine calls this method to ask you to set
 *   your S-functions default dimensions for any input and output ports
 *   that are dynamically sized.
 *   If you do not provide this method and you have dynamically sized ports
 *   where Simulink does not have enough information to propagate the
 *   dimensionality to your S-function, then Simulink will set these unknown
 *   ports to the 'block width' which is determined by examining any known
 *   ports. If there are no known ports, the width will be set to 1.
 */
static void mdlSetDefaultPortDimensionInfo(SimStruct *S)
{

    /* Set input port 1 default dimension */
    if (ssGetInputPortWidth(S, 0) == DYNAMICALLY_SIZED) {
        if (!ssSetInputPortMatrixDimensions(S, 0, 1, 1)) return;
    } /* if */

    /* Set input port 2 default dimension */
    if (ssGetInputPortWidth(S, 1) == DYNAMICALLY_SIZED) {
        if (!ssSetInputPortMatrixDimensions(S, 1, 1, 1)) return;
    } /* if */

    /* Set output port 1 default dimension */
    {
        int_T y1Width = ssGetInputPortDimensions(S, 0)[1];
        if (y1Width!=DYNAMICALLY_SIZED && y1Width < 1) { ssSetErrorStatus(S, "Output 1: the current width is < 1"); return; }
        if (y1Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 0, y1Width);
        } /* if */
    }

    /* Set output port 2 default dimension */
    {
        int_T y2Width = ssGetInputPortDimensions(S, 0)[1];
        if (y2Width!=DYNAMICALLY_SIZED && y2Width < 1) { ssSetErrorStatus(S, "Output 2: the current width is < 1"); return; }
        if (y2Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 1, y2Width);
        } /* if */
    }

    /* Set output port 3 default dimension */
    {
        int_T y3Width = ssGetInputPortDimensions(S, 0)[1];
        if (y3Width!=DYNAMICALLY_SIZED && y3Width < 1) { ssSetErrorStatus(S, "Output 3: the current width is < 1"); return; }
        if (y3Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 2, y3Width);
        } /* if */
    }

    /* Set output port 4 default dimension */
    {
        int_T y4Width = ssGetInputPortDimensions(S, 0)[1];
        if (y4Width!=DYNAMICALLY_SIZED && y4Width < 1) { ssSetErrorStatus(S, "Output 4: the current width is < 1"); return; }
        if (y4Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 3, y4Width);
        } /* if */
    }

    /* Set output port 5 default dimension */
    {
        int_T y5Width = ssGetInputPortDimensions(S, 0)[1];
        if (y5Width!=DYNAMICALLY_SIZED && y5Width < 1) { ssSetErrorStatus(S, "Output 5: the current width is < 1"); return; }
        if (y5Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 4, y5Width);
        } /* if */
    }

    /* Set output port 6 default dimension */
    {
        int_T y6Width = ssGetInputPortDimensions(S, 0)[1];
        if (y6Width!=DYNAMICALLY_SIZED && y6Width < 1) { ssSetErrorStatus(S, "Output 6: the current width is < 1"); return; }
        if (y6Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 5, y6Width);
        } /* if */
    }

    /* Set output port 7 default dimension */
    {
        int_T y7Width = ssGetInputPortDimensions(S, 0)[1];
        if (y7Width!=DYNAMICALLY_SIZED && y7Width < 1) { ssSetErrorStatus(S, "Output 7: the current width is < 1"); return; }
        if (y7Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 6, y7Width);
        } /* if */
    }

    /* Set output port 8 default dimension */
    {
        int_T y8Width = ssGetInputPortDimensions(S, 0)[1];
        if (y8Width!=DYNAMICALLY_SIZED && y8Width < 1) { ssSetErrorStatus(S, "Output 8: the current width is < 1"); return; }
        if (y8Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 7, y8Width);
        } /* if */
    }

    /* Set output port 9 default dimension */
    {
        int_T y9Width = ssGetInputPortDimensions(S, 0)[1];
        if (y9Width!=DYNAMICALLY_SIZED && y9Width < 1) { ssSetErrorStatus(S, "Output 9: the current width is < 1"); return; }
        if (y9Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 8, y9Width);
        } /* if */
    }

    /* Set output port 10 default dimension */
    {
        int_T y10Width = ssGetInputPortDimensions(S, 0)[1];
        if (y10Width!=DYNAMICALLY_SIZED && y10Width < 1) { ssSetErrorStatus(S, "Output 10: the current width is < 1"); return; }
        if (y10Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 9, y10Width);
        } /* if */
    }

    /* Set output port 11 default dimension */
    {
        int_T y11Width = ssGetInputPortDimensions(S, 0)[1];
        if (y11Width!=DYNAMICALLY_SIZED && y11Width < 1) { ssSetErrorStatus(S, "Output 11: the current width is < 1"); return; }
        if (y11Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 10, y11Width);
        } /* if */
    }

    /* Set output port 12 default dimension */
    {
        int_T y12Width = ssGetInputPortDimensions(S, 0)[1];
        if (y12Width!=DYNAMICALLY_SIZED && y12Width < 1) { ssSetErrorStatus(S, "Output 12: the current width is < 1"); return; }
        if (y12Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 11, y12Width);
        } /* if */
    }

    /* Set output port 13 default dimension */
    {
        int_T y13Width = ssGetInputPortDimensions(S, 0)[1];
        if (y13Width!=DYNAMICALLY_SIZED && y13Width < 1) { ssSetErrorStatus(S, "Output 13: the current width is < 1"); return; }
        if (y13Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 12, y13Width);
        } /* if */
    }

    /* Set output port 14 default dimension */
    {
        int_T y14Width = ssGetInputPortDimensions(S, 0)[1];
        if (y14Width!=DYNAMICALLY_SIZED && y14Width < 1) { ssSetErrorStatus(S, "Output 14: the current width is < 1"); return; }
        if (y14Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 13, y14Width);
        } /* if */
    }

    /* Set output port 15 default dimension */
    {
        int_T y15Width = ssGetInputPortDimensions(S, 0)[1];
        if (y15Width!=DYNAMICALLY_SIZED && y15Width < 1) { ssSetErrorStatus(S, "Output 15: the current width is < 1"); return; }
        if (y15Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 14, y15Width);
        } /* if */
    }

    /* Set output port 16 default dimension */
    {
        int_T y16Width = ssGetInputPortDimensions(S, 0)[1];
        if (y16Width!=DYNAMICALLY_SIZED && y16Width < 1) { ssSetErrorStatus(S, "Output 16: the current width is < 1"); return; }
        if (y16Width != DYNAMICALLY_SIZED) {
            ssSetOutputPortWidth(S, 15, y16Width);
        } /* if */
    }
}
#endif

#define MDL_SET_WORK_WIDTHS
#if defined(MDL_SET_WORK_WIDTHS) && defined(MATLAB_MEX_FILE)
/* Function: mdlSetWorkWidths =============================================
 * Abstract:
 *   The optional method, mdlSetWorkWidths is called after input port
 *   width, output port width, and sample times of the S-function have
 *   been determined to set any state and work vector sizes which are
 *   a function of the input, output, and/or sample times. 
 *   Run-time parameters are registered in this method using methods 
 *   ssSetNumRunTimeParams, ssSetRunTimeParamInfo, and related methods.
 */
static void mdlSetWorkWidths(SimStruct *S)
{
    /* Set number of run-time parameters */
    if (!ssSetNumRunTimeParams(S, 4)) return;

    /* Register the run-time parameter 1 */
    ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", ssGetDataTypeId(S, "single"));

    /* Register the run-time parameter 2 */
    ssRegDlgParamAsRunTimeParam(S, 1, 1, "p2", ssGetDataTypeId(S, "single"));

    /* Register the run-time parameter 3 */
    ssRegDlgParamAsRunTimeParam(S, 2, 2, "p3", ssGetDataTypeId(S, "int32"));

    /* Register the run-time parameter 4 */
    ssRegDlgParamAsRunTimeParam(S, 3, 3, "p4", ssGetDataTypeId(S, "int32"));
}
#endif

/* Function: mdlOutputs ===================================================
 * Abstract:
 *   In this function, you compute the outputs of your S-function
 *   block. Generally outputs are placed in the output vector(s),
 *   ssGetOutputPortSignal.
 */
static void mdlOutputs(SimStruct *S, int_T tid)
{

    /* Get access to Parameter/Input/Output/DWork data */
    real32_T* y1 = (real32_T*) ssGetOutputPortSignal(S, 0);
    real32_T* y2 = (real32_T*) ssGetOutputPortSignal(S, 1);
    real32_T* y3 = (real32_T*) ssGetOutputPortSignal(S, 2);
    real32_T* y4 = (real32_T*) ssGetOutputPortSignal(S, 3);
    real32_T* y5 = (real32_T*) ssGetOutputPortSignal(S, 4);
    real32_T* y6 = (real32_T*) ssGetOutputPortSignal(S, 5);
    real32_T* y7 = (real32_T*) ssGetOutputPortSignal(S, 6);
    real32_T* y8 = (real32_T*) ssGetOutputPortSignal(S, 7);
    real32_T* y9 = (real32_T*) ssGetOutputPortSignal(S, 8);
    real32_T* y10 = (real32_T*) ssGetOutputPortSignal(S, 9);
    real32_T* y11 = (real32_T*) ssGetOutputPortSignal(S, 10);
    real32_T* y12 = (real32_T*) ssGetOutputPortSignal(S, 11);
    real32_T* y13 = (real32_T*) ssGetOutputPortSignal(S, 12);
    real32_T* y14 = (real32_T*) ssGetOutputPortSignal(S, 13);
    real32_T* y15 = (real32_T*) ssGetOutputPortSignal(S, 14);
    real32_T* y16 = (real32_T*) ssGetOutputPortSignal(S, 15);
    real32_T* u1 = (real32_T*) ssGetInputPortSignal(S, 0);
    real32_T* u2 = (real32_T*) ssGetInputPortSignal(S, 1);
    real32_T* u3 = (real32_T*) ssGetInputPortSignal(S, 2);
    real32_T* u4 = (real32_T*) ssGetInputPortSignal(S, 3);
    real32_T* p1 = (real32_T*) ssGetRunTimeParamInfo(S, 0)->data;
    real32_T* p2 = (real32_T*) ssGetRunTimeParamInfo(S, 1)->data;
    int32_T* p3 = (int32_T*) ssGetRunTimeParamInfo(S, 2)->data;
    int32_T* p4 = (int32_T*) ssGetRunTimeParamInfo(S, 3)->data;


    /* Call the legacy code function */
    sshap(y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, u1, u2, *u3, *u4, *p1, *p2, *p3, *p4);
}

/* Function: mdlTerminate =================================================
 * Abstract:
 *   In this function, you should perform any actions that are necessary
 *   at the termination of a simulation.
 */
static void mdlTerminate(SimStruct *S)
{
}

/* Required S-function trailer */
#ifdef    MATLAB_MEX_FILE
# include "simulink.c"
#else
# include "cg_sfun.h"
#endif

